1 line
3.3 MiB
1 line
3.3 MiB
var eSe=Object.create,Y1=Object.defineProperty,tSe=Object.defineProperties,nSe=Object.getOwnPropertyDescriptor,rSe=Object.getOwnPropertyDescriptors,iSe=Object.getOwnPropertyNames,tG=Object.getOwnPropertySymbols,nG=Object.getPrototypeOf,rG=Object.prototype.hasOwnProperty,sSe=Object.prototype.propertyIsEnumerable,aSe=Reflect.get,gg=Math.pow,UI=(e,t,n)=>t in e?Y1(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ir=(e,t)=>{for(var n in t||(t={}))rG.call(t,n)&&UI(e,n,t[n]);if(tG)for(var n of tG(t))sSe.call(t,n)&&UI(e,n,t[n]);return e},Ci=(e,t)=>tSe(e,rSe(t)),HI=(e=>"undefined"!=typeof require?require:"undefined"!=typeof Proxy?new Proxy(e,{get:(e,t)=>("undefined"!=typeof require?require:e)[t]}):e)((function(e){if("undefined"!=typeof require)return require.apply(this,arguments);throw new Error('Dynamic require of "'+e+'" is not supported')})),oSe=(e,t)=>()=>(e&&(t=e(e=0)),t),J=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),bT=(e,t)=>{for(var n in t)Y1(e,n,{get:t[n],enumerable:!0})},iG=(e,t,n,i)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let r of iSe(t))!rG.call(e,r)&&r!==n&&Y1(e,r,{get:()=>t[r],enumerable:!(i=nSe(t,r))||i.enumerable});return e},ss=(e,t,n)=>(n=null!=e?eSe(nG(e)):{},iG(!t&&e&&e.__esModule?n:Y1(n,"default",{value:e,enumerable:!0}),e)),lSe=e=>iG(Y1({},"__esModule",{value:!0}),e),Yi=(e,t,n)=>(UI(e,"symbol"!=typeof t?t+"":t,n),n),VI=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},le=(e,t,n)=>(VI(e,t,"read from private field"),n?n.call(e):t.get(e)),Je=(e,t,n)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,n)},wt=(e,t,n,i)=>(VI(e,t,"write to private field"),i?i.call(e,n):t.set(e,n),n),ET=(e,t,n,i)=>({set _(i){wt(e,t,i,n)},get _(){return le(e,t,i)}}),ft=(e,t,n)=>(VI(e,t,"access private method"),n),_T=(e,t,n)=>aSe(nG(e),n,t),it=(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())})),oG={};function TT(e){return(TT="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 uSe(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function sG(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 hSe(e,t,n){return t&&sG(e.prototype,t),n&&sG(e,n),e}function mSe(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]:{};uSe(this,r),this._locale=function(e){for(var t=aG(e),n=0;n<t.length;++n){var r=i(t[n]);if(r)return r}return i(fSe())}(n),this._select=t(this._locale),this._type=pSe(a.type),this._nf=new e("en",a)}return hSe(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 aG(e).filter(i)}}]),r}();return Object.defineProperty(r,"prototype",{writable:!1}),r}bT(oG,{default:()=>mSe});var dSe,aG,fSe,pSe,lG=oSe((()=>{dSe=function(e){return e.split("-").every((function(e){return/[a-z0-9]+/i.test(e)}))},aG=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"===TT(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(!dSe(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)},fSe=function(){return"undefined"!=typeof navigator&&navigator&&(navigator.userLanguage||navigator.language)||"en-US"},pSe=function(e){if(!e)return"cardinal";if("cardinal"===e||"ordinal"===e)return e;throw new RangeError("Not a valid plural type: "+JSON.stringify(e))}})),hG=J(((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})),xG=J(((e,t)=>{"use strict";var n=(lG(),lSe(oG)),i=hG();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,u,c,d,p,f,m,g,v={exports:{}};h=v,c=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"},u={_in:m=function(e,t){return"other"},af:c,ak:d,am:p,an:c,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:c,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:c,bez:c,bg:c,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:c,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:c,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:c,chr:c,ckb:c,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:c,dz:m,ee:c,el:c,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:c,es:c,et:f,eu:c,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:c,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:c,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:c,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:c,haw:c,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:c,ji:f,jmc:c,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:c,kcg:c,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:c,kl:c,km:m,kn:p,ko:m,ks:c,ksb:c,ksh:function(e,t){return t?"other":0==e?"zero":1==e?"one":"other"},ku:c,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:c,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:c,lg:c,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:c,mg:d,mgo:c,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:c,mn:c,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:c,naq:g,nb:c,nd:c,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:c,nnh:c,no:c,nqo:m,nr:c,nso:d,ny:c,nyn:c,om:c,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:c,osa:m,pa:d,pap:c,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:c,pt:function(e,t){var n=String(e).split(".")[0];return t?"other":0==n||1==n?"one":"other"},pt_PT:f,rm:c,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:c,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:c,sah:m,saq:c,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:c,sdh:c,se:g,seh:c,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:c,so:c,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:c,ssy:c,st:c,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:c,ta:c,te:c,teo:c,th:m,ti:d,tig:c,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:c,to:m,tr:c,ts:c,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:c,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:c,ve:c,vi:function(e,t){return t&&1==e?"one":"other"},vo:c,vun:c,wa:d,wae:c,wo:m,xh:c,xog:c,yi:f,yo:m,yue:m,zh:m,zu:p},Object.defineProperty(u,"__esModule",{value:!0}),h.exports=u;var y=l(v.exports),x=Object.freeze(Object.assign(Object.create(null),v.exports,{default:y})),b={exports:{}};!function(e,t){var n,i="zero",r="one",a="two",s="few",o="many",l="other",h={cardinal:[r,l],ordinal:[l]},u={cardinal:[l],ordinal:[l]},c={cardinal:[r,s,o,l],ordinal:[l]},d={cardinal:[r,l],ordinal:[r,l]},p={cardinal:[r,a,l],ordinal:[l]};n={_in:u,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:u,bn:{cardinal:[r,l],ordinal:[r,a,s,o,l]},bo:u,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:c,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:u,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:u,ig:u,ii:u,io:h,is:h,it:{cardinal:[r,l],ordinal:[o,l]},iu:p,iw:{cardinal:[r,a,o,l],ordinal:[l]},ja:u,jbo:u,jgo:h,ji:h,jmc:h,jv:u,jw:u,ka:{cardinal:[r,l],ordinal:[r,o,l]},kab:h,kaj:h,kcg:h,kde:u,kea:u,kk:{cardinal:[r,l],ordinal:[o,l]},kkj:h,kl:h,km:u,kn:h,ko:u,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:u,ln:h,lo:{cardinal:[l],ordinal:[r,l]},lt:c,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:c,my:u,nah:h,naq:p,nb:h,nd:h,ne:d,nl:h,nn:h,nnh:h,no:h,nqo:u,nr:h,nso:h,ny:h,nyn:h,om:h,or:{cardinal:[r,l],ordinal:[r,a,s,o,l]},os:h,osa:u,pa:h,pap:h,pcm:h,pl:c,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:u,ru:c,rwk:h,sah:u,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:u,sg:u,sh:{cardinal:[r,s,l],ordinal:[l]},shi:{cardinal:[r,s,l],ordinal:[l]},si:h,sk:c,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:u,sv:d,sw:h,syr:h,ta:h,te:h,teo:h,th:u,ti:h,tig:h,tk:{cardinal:[r,l],ordinal:[s,l]},tl:d,tn:h,to:u,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:u,xh:h,xog:h,yi:h,yo:u,yue:u,zh:u,zu:h},Object.defineProperty(n,"__esModule",{value:!0}),e.exports=n}(b);var _=l(b.exports),w=Object.freeze(Object.assign(Object.create(null),b.exports,{default:_})),S=y||x,M=_||w,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 S[T(e)]}),(function(e,t){return M[T(e)][t?"ordinal":"cardinal"]}));t.exports=A})),_G=J((e=>{"use strict";var t,n,i=(t=xG())&&"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)})),wn=J(((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}()||e||Function("return this")()})),Yt=J(((e,t)=>{t.exports=function(e){try{return!!e()}catch(e){return!0}}})),Kn=J(((e,t)=>{var n=Yt();t.exports=!n((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]}))})),vg=J(((e,t)=>{var n=Yt();t.exports=!n((function(){var e=function(){}.bind();return"function"!=typeof e||e.hasOwnProperty("prototype")}))})),vr=J(((e,t)=>{var n=vg(),i=Function.prototype.call;t.exports=n?i.bind(i):function(){return i.apply(i,arguments)}})),$1=J((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})),Oo=J(((e,t)=>{t.exports=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}}})),Jt=J(((e,t)=>{var n=vg(),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)}}})),ua=J(((e,t)=>{var n=Jt(),i=n({}.toString),r=n("".slice);t.exports=function(e){return r(i(e),8,-1)}})),dp=J(((e,t)=>{var n=Jt(),i=Yt(),r=ua(),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})),Ca=J(((e,t)=>{t.exports=function(e){return null==e}})),as=J(((e,t)=>{var n=Ca(),i=TypeError;t.exports=function(e){if(n(e))throw i("Can't call method on "+e);return e}})),Is=J(((e,t)=>{var n=dp(),i=as();t.exports=function(e){return n(i(e))}})),YI=J(((e,t)=>{var n="object"==typeof document&&document.all,i=void 0===n&&void 0!==n;t.exports={all:n,IS_HTMLDDA:i}})),Lr=J(((e,t)=>{var n=YI(),i=n.all;t.exports=n.IS_HTMLDDA?function(e){return"function"==typeof e||e===i}:function(e){return"function"==typeof e}})),Dr=J(((e,t)=>{var n=Lr(),i=YI(),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)}})),Ui=J(((e,t)=>{var n=wn(),i=Lr();t.exports=function(e,t){return arguments.length<2?function(e){return i(e)?e:void 0}(n[e]):n[e]&&n[e][t]}})),ko=J(((e,t)=>{var n=Jt();t.exports=n({}.isPrototypeOf)})),ru=J(((e,t)=>{t.exports="undefined"!=typeof navigator&&String(navigator.userAgent)||""})),iu=J(((e,t)=>{var n,i,r=wn(),a=ru(),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})),fp=J(((e,t)=>{var n=iu(),i=Yt(),r=wn().String;t.exports=!!Object.getOwnPropertySymbols&&!i((function(){var e=Symbol();return!r(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&n&&n<41}))})),KI=J(((e,t)=>{var n=fp();t.exports=n&&!Symbol.sham&&"symbol"==typeof Symbol.iterator})),Td=J(((e,t)=>{var n=Ui(),i=Lr(),r=ko(),a=KI(),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))}})),wd=J(((e,t)=>{var n=String;t.exports=function(e){try{return n(e)}catch(e){return"Object"}}})),os=J(((e,t)=>{var n=Lr(),i=wd(),r=TypeError;t.exports=function(e){if(n(e))return e;throw r(i(e)+" is not a function")}})),su=J(((e,t)=>{var n=os(),i=Ca();t.exports=function(e,t){var r=e[t];return i(r)?void 0:n(r)}})),t3=J(((e,t)=>{var n=vr(),i=Lr(),r=Dr(),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")}})),ls=J(((e,t)=>{t.exports=!1})),RT=J(((e,t)=>{var n=wn(),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}})),CT=J(((e,t)=>{var n=wn(),i=RT(),r="__core-js_shared__",a=n[r]||i(r,{});t.exports=a})),pp=J(((e,t)=>{var n=ls(),i=CT();(t.exports=function(e,t){return i[e]||(i[e]=void 0!==t?t:{})})("versions",[]).push({version:"3.31.1",mode:n?"pure":"global",copyright:"\xa9 2014-2023 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.31.1/LICENSE",source:"https://github.com/zloirock/core-js"})})),oi=J(((e,t)=>{var n=as(),i=Object;t.exports=function(e){return i(n(e))}})),jr=J(((e,t)=>{var n=Jt(),i=oi(),r=n({}.hasOwnProperty);t.exports=Object.hasOwn||function(e,t){return r(i(e),t)}})),mp=J(((e,t)=>{var n=Jt(),i=0,r=Math.random(),a=n(1..toString);t.exports=function(e){return"Symbol("+(void 0===e?"":e)+")_"+a(++i+r,36)}})),Or=J(((e,t)=>{var n=wn(),i=pp(),r=jr(),a=mp(),s=fp(),o=KI(),l=n.Symbol,h=i("wks"),u=o?l.for||l:l&&l.withoutSetter||a;t.exports=function(e){return r(h,e)||(h[e]=s&&r(l,e)?l[e]:u("Symbol."+e)),h[e]}})),Z1=J(((e,t)=>{var n=vr(),i=Dr(),r=Td(),a=su(),s=t3(),o=Or(),l=TypeError,h=o("toPrimitive");t.exports=function(e,t){if(!i(e)||r(e))return e;var o,u=a(e,h);if(u){if(void 0===t&&(t="default"),o=n(u,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)}})),lh=J(((e,t)=>{var n=Z1(),i=Td();t.exports=function(e){var t=n(e,"string");return i(t)?t:t+""}})),K1=J(((e,t)=>{var n=wn(),i=Dr(),r=n.document,a=i(r)&&i(r.createElement);t.exports=function(e){return a?r.createElement(e):{}}})),i3=J(((e,t)=>{var n=Kn(),i=Yt(),r=K1();t.exports=!n&&!i((function(){return 7!=Object.defineProperty(r("div"),"a",{get:function(){return 7}}).a}))})),Qs=J((e=>{var t=Kn(),n=vr(),i=$1(),r=Oo(),a=Is(),s=lh(),o=jr(),l=i3(),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])}})),s3=J(((e,t)=>{var n=Kn(),i=Yt();t.exports=n&&i((function(){return 42!=Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype}))})),yr=J(((e,t)=>{var n=Dr(),i=String,r=TypeError;t.exports=function(e){if(n(e))return e;throw r(i(e)+" is not an object")}})),qi=J((e=>{var t=Kn(),n=i3(),i=s3(),r=yr(),a=lh(),s=TypeError,o=Object.defineProperty,l=Object.getOwnPropertyDescriptor,h="enumerable",u="configurable",c="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&&c in n&&!n[c]){var i=l(e,t);i&&i[c]&&(e[t]=n.value,n={configurable:u in n?n[u]:i[u],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}})),ha=J(((e,t)=>{var n=Kn(),i=qi(),r=Oo();t.exports=n?function(e,t,n){return i.f(e,t,r(1,n))}:function(e,t,n){return e[t]=n,e}})),gp=J(((e,t)=>{var n=Kn(),i=jr(),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}})),IT=J(((e,t)=>{var n=Jt(),i=Lr(),r=CT(),a=n(Function.toString);i(r.inspectSource)||(r.inspectSource=function(e){return a(e)}),t.exports=r.inspectSource})),f3=J(((e,t)=>{var n=wn(),i=Lr(),r=n.WeakMap;t.exports=i(r)&&/native code/.test(String(r))})),J1=J(((e,t)=>{var n=pp(),i=mp(),r=n("keys");t.exports=function(e){return r[e]||(r[e]=i(e))}})),xg=J(((e,t)=>{t.exports={}})),Es=J(((e,t)=>{var n,i,r,a,s,o=f3(),l=wn(),h=Dr(),u=ha(),c=jr(),d=CT(),p=J1(),f=xg(),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(c(e,s))throw g(m);return t.facade=e,u(e,s,t),t},i=function(e){return c(e,s)?e[s]:{}},r=function(e){return c(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}}}})),FT=J(((e,t)=>{var n=Jt(),i=Yt(),r=Lr(),a=jr(),s=Kn(),o=gp().CONFIGURABLE,l=IT(),h=Es(),u=h.enforce,c=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=u(e);return a(i,"source")||(i.source=g(y,"string"==typeof t?t:"")),e};Function.prototype.toString=x((function(){return r(this)&&c(this).source||l(this)}),"toString")})),Hi=J(((e,t)=>{var n=Lr(),i=qi(),r=FT(),a=RT();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}})),x3=J(((e,t)=>{var n=Math.ceil,i=Math.floor;t.exports=Math.trunc||function(e){var t=+e;return(t>0?i:n)(t)}})),cs=J(((e,t)=>{var n=x3();t.exports=function(e){var t=+e;return t!=t||0===t?0:n(t)}})),lc=J(((e,t)=>{var n=cs(),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)}})),to=J(((e,t)=>{var n=cs(),i=Math.min;t.exports=function(e){return e>0?i(n(e),9007199254740991):0}})),ui=J(((e,t)=>{var n=to();t.exports=function(e){return n(e.length)}})),bg=J(((e,t)=>{var n=Is(),i=lc(),r=ui(),a=function(e){return function(t,a,s){var o,l=n(t),h=r(l),u=i(s,h);if(e&&a!=a){for(;h>u;)if((o=l[u++])!=o)return!0}else for(;h>u;u++)if((e||u in l)&&l[u]===a)return e||u||0;return!e&&-1}};t.exports={includes:a(!0),indexOf:a(!1)}})),E3=J(((e,t)=>{var n=Jt(),i=jr(),r=Is(),a=bg().indexOf,s=xg(),o=n([].push);t.exports=function(e,t){var n,l=r(e),h=0,u=[];for(n in l)!i(s,n)&&i(l,n)&&o(u,n);for(;t.length>h;)i(l,n=t[h++])&&(~a(u,n)||o(u,n));return u}})),NT=J(((e,t)=>{t.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]})),ch=J((e=>{var t=E3(),n=NT().concat("length","prototype");e.f=Object.getOwnPropertyNames||function(e){return t(e,n)}})),ey=J((e=>{e.f=Object.getOwnPropertySymbols})),BT=J(((e,t)=>{var n=Ui(),i=Jt(),r=ch(),a=ey(),s=yr(),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}})),ty=J(((e,t)=>{var n=jr(),i=BT(),r=Qs(),a=qi();t.exports=function(e,t,s){for(var o=i(t),l=a.f,h=r.f,u=0;u<o.length;u++){var c=o[u];!n(e,c)&&(!s||!n(s,c))&&l(e,c,h(t,c))}}})),Eg=J(((e,t)=>{var n=Yt(),i=Lr(),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})),et=J(((e,t)=>{var n=wn(),i=Qs().f,r=ha(),a=Hi(),s=RT(),o=ty(),l=Eg();t.exports=function(e,t){var h,u,c,d,p,f=e.target,m=e.global,g=e.stat;if(h=m?n:g?n[f]||s(f,{}):(n[f]||{}).prototype)for(u in t){if(d=t[u],c=e.dontCallGetSet?(p=i(h,u))&&p.value:h[u],!l(m?u:f+(g?".":"#")+u,e.forced)&&void 0!==c){if(typeof d==typeof c)continue;o(d,c)}(e.sham||c&&c.sham)&&r(d,"sham",!0),a(h,u,d,e)}}})),UT=J(((e,t)=>{var n={};n[Or()("toStringTag")]="z",t.exports="[object z]"===String(n)})),cc=J(((e,t)=>{var n=UT(),i=Lr(),r=ua(),a=Or()("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}})),ur=J(((e,t)=>{var n=cc(),i=String;t.exports=function(e){if("Symbol"===n(e))throw TypeError("Cannot convert a Symbol value to a string");return i(e)}})),_g=J(((e,t)=>{var n=E3(),i=NT();t.exports=Object.keys||function(e){return n(e,i)}})),VT=J((e=>{var t=Kn(),n=s3(),i=qi(),r=yr(),a=Is(),s=_g();e.f=t&&!n?Object.defineProperties:function(e,t){r(e);for(var n,o=a(t),l=s(t),h=l.length,u=0;h>u;)i.f(e,n=l[u++],o[n]);return e}})),T3=J(((e,t)=>{var n=Ui();t.exports=n("document","documentElement")})),no=J(((e,t)=>{var n,i=yr(),r=VT(),a=NT(),s=xg(),o=T3(),l=K1(),h=J1(),u="prototype",c="script",d=h("IE_PROTO"),p=function(){},f=function(e){return"<"+c+">"+e+"</"+c+">"},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"+c+":";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[u][a[e]];return g()};s[d]=!0,t.exports=Object.create||function(e,t){var n;return null!==e?(p[u]=i(e),n=new p,p[u]=null,n[d]=e):n=g(),void 0===t?n:r.f(n,t)}})),au=J(((e,t)=>{"use strict";var n=lh(),i=qi(),r=Oo();t.exports=function(e,t,a){var s=n(t);s in e?i.f(e,s,r(0,a)):e[s]=a}})),Tg=J(((e,t)=>{var n=lc(),i=ui(),r=au(),a=Array,s=Math.max;t.exports=function(e,t,o){for(var l=i(e),h=n(t,l),u=n(void 0===o?l:o,l),c=a(s(u-h,0)),d=0;h<u;h++,d++)r(c,d,e[h]);return c.length=d,c}})),qT=J(((e,t)=>{var n=ua(),i=Is(),r=ch().f,a=Tg(),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))}})),Hs=J(((e,t)=>{var n=FT(),i=qi();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)}})),A3=J((e=>{var t=Or();e.f=t})),WT=J(((e,t)=>{var n=wn();t.exports=n})),Pa=J(((e,t)=>{var n=WT(),i=jr(),r=A3(),a=qi().f;t.exports=function(e){var t=n.Symbol||(n.Symbol={});i(t,e)||a(t,e,{value:r.f(e)})}})),R3=J(((e,t)=>{var n=vr(),i=Ui(),r=Or(),a=Hi();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})}})),ro=J(((e,t)=>{var n=qi().f,i=jr(),r=Or()("toStringTag");t.exports=function(e,t,a){e&&!a&&(e=e.prototype),e&&!i(e,r)&&n(e,r,{configurable:!0,value:t})}})),uh=J(((e,t)=>{var n=ua(),i=Jt();t.exports=function(e){if("Function"===n(e))return i(e)}})),cl=J(((e,t)=>{var n=uh(),i=os(),r=vg(),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)}}})),hh=J(((e,t)=>{var n=ua();t.exports=Array.isArray||function(e){return"Array"==n(e)}})),yp=J(((e,t)=>{var n=Jt(),i=Yt(),r=Lr(),a=cc(),s=Ui(),o=IT(),l=function(){},h=[],u=s("Reflect","construct"),c=/^\s*(?:class|function)\b/,d=n(c.exec),p=!c.exec(l),f=function(e){if(!r(e))return!1;try{return u(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(c,o(e))}catch(e){return!0}};m.sham=!0,t.exports=!u||i((function(){var e;return f(f.call)||!f(Object)||!f((function(){e=!0}))||e}))?m:f})),n9=J(((e,t)=>{var n=hh(),i=yp(),r=Dr(),a=Or()("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}})),wg=J(((e,t)=>{var n=n9();t.exports=function(e,t){return new(n(e))(0===t?0:t)}})),Vs=J(((e,t)=>{var n=cl(),i=Jt(),r=dp(),a=oi(),s=ui(),o=wg(),l=i([].push),h=function(e){var t=1==e,i=2==e,h=3==e,u=4==e,c=6==e,d=7==e,p=5==e||c;return function(f,m,g,v){for(var y,x,b=a(f),_=r(b),w=n(m,g),S=s(_),M=0,E=v||o,T=t?E(f,S):i||d?E(f,0):void 0;S>M;M++)if((p||M in _)&&(x=w(y=_[M],M,b),e))if(t)T[M]=x;else if(x)switch(e){case 3:return!0;case 5:return y;case 6:return M;case 2:l(T,y)}else switch(e){case 4:return!1;case 7:l(T,y)}return c?-1:h||u?u: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)}})),E9=J((()=>{"use strict";var e=et(),t=wn(),n=vr(),i=Jt(),r=ls(),a=Kn(),s=fp(),o=Yt(),l=jr(),h=ko(),u=yr(),c=Is(),d=lh(),p=ur(),f=Oo(),m=no(),g=_g(),v=ch(),y=qT(),x=ey(),b=Qs(),_=qi(),w=VT(),S=$1(),M=Hi(),E=Hs(),T=pp(),A=J1(),C=xg(),P=mp(),R=Or(),L=A3(),I=Pa(),k=R3(),O=ro(),D=Es(),N=Vs().forEach,U=A("hidden"),F="Symbol",B="prototype",z=D.set,H=D.getterFor(F),V=Object[B],j=t.Symbol,G=j&&j[B],W=t.TypeError,X=t.QObject,Y=b.f,q=_.f,J=y.f,Z=S.f,K=i([].push),$=T("symbols"),Q=T("op-symbols"),ee=T("wks"),te=!X||!X[B]||!X[B].findChild,ne=a&&o((function(){return 7!=m(q({},"a",{get:function(){return q(this,"a",{value:7}).a}})).a}))?function(e,t,n){var i=Y(V,t);i&&delete V[t],q(e,t,n),i&&e!==V&&q(V,t,i)}:q,ie=function(e,t){var n=$[e]=m(G);return z(n,{type:F,tag:e,description:t}),a||(n.description=t),n},re=function(e,t,n){e===V&&re(Q,t,n),u(e);var i=d(t);return u(n),l($,i)?(n.enumerable?(l(e,U)&&e[U][i]&&(e[U][i]=!1),n=m(n,{enumerable:f(0,!1)})):(l(e,U)||q(e,U,f(1,{})),e[U][i]=!0),ne(e,i,n)):q(e,i,n)},ae=function(e,t){u(e);var i=c(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(Z,this,t);return!(this===V&&l($,t)&&!l(Q,t))&&(!(i||!l(this,t)||!l($,t)||l(this,U)&&this[U][t])||i)},oe=function(e,t){var n=c(e),i=d(t);if(n!==V||!l($,i)||l(Q,i)){var r=Y(n,i);return r&&l($,i)&&!(l(n,U)&&n[U][i])&&(r.enumerable=!0),r}},le=function(e){var t=J(c(e)),n=[];return N(t,(function(e){!l($,e)&&!l(C,e)&&K(n,e)})),n},he=function(e){var t=e===V,n=J(t?Q:c(e)),i=[];return N(n,(function(e){l($,e)&&(!t||l(V,e))&&K(i,$[e])})),i};s||(M(G=(j=function(){if(h(G,this))throw W("Symbol is not a constructor");var e=arguments.length&&void 0!==arguments[0]?p(arguments[0]):void 0,t=P(e),i=function(e){this===V&&n(i,Q,e),l(this,U)&&l(this[U],t)&&(this[U][t]=!1),ne(this,t,f(1,e))};return a&&te&&ne(V,t,{configurable:!0,set:i}),ie(t,e)})[B],"toString",(function(){return H(this).tag})),M(j,"withoutSetter",(function(e){return ie(P(e),e)})),S.f=se,_.f=re,w.f=ae,b.f=oe,v.f=y.f=le,x.f=he,L.f=function(e){return ie(R(e),e)},a&&(E(G,"description",{configurable:!0,get:function(){return H(this).description}}),r||M(V,"propertyIsEnumerable",se,{unsafe:!0}))),e({global:!0,constructor:!0,wrap:!0,forced:!s,sham:!s},{Symbol:j}),N(g(ee),(function(e){I(e)})),e({target:F,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}),k(),O(j,F),C[U]=!0})),G3=J(((e,t)=>{var n=fp();t.exports=n&&!!Symbol.for&&!!Symbol.keyFor})),w9=J((()=>{var e=et(),t=Ui(),n=jr(),i=ur(),r=pp(),a=G3(),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}})})),M9=J((()=>{var e=et(),t=jr(),n=Td(),i=wd(),r=pp(),a=G3(),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]}})})),Fo=J(((e,t)=>{var n=vg(),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)})})),Md=J(((e,t)=>{var n=Jt();t.exports=n([].slice)})),F9=J(((e,t)=>{var n=Jt(),i=hh(),r=Lr(),a=ua(),s=ur(),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 u=n.length,c=!0;return function(e,t){if(c)return c=!1,t;if(i(this))return t;for(var r=0;r<u;r++)if(n[r]===e)return t}}}})),W3=J((()=>{var e=et(),t=Ui(),n=Fo(),i=vr(),r=Jt(),a=Yt(),s=Lr(),o=Td(),l=Md(),h=F9(),u=fp(),c=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]$/,b=/^[\uDC00-\uDFFF]$/,_=!u||a((function(){var e=t("Symbol")();return"[null]"!=d([e])||"{}"!=d({a:e})||"{}"!=d(Object(e))})),w=a((function(){return'"\\udf06\\ud834"'!==d("\udf06\ud834")||'"\\udead"'!==d("\udead")})),S=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,c(e),t)),!o(t))return t},n(d,null,r)},M=function(e,t,n){var i=f(n,t-1),r=f(n,t+1);return p(x,e)&&!p(b,r)||p(b,e)&&!p(x,i)?"\\u"+v(m(e,0),16):e};d&&e({target:"JSON",stat:!0,arity:3,forced:_||w},{stringify:function(e,t,i){var r=l(arguments),a=n(_?S:d,null,r);return w&&"string"==typeof a?g(a,y,M):a}})})),$9=J((()=>{var e=et(),t=fp(),n=Yt(),i=ey(),r=oi();e({target:"Object",stat:!0,forced:!t||n((function(){i.f(1)}))},{getOwnPropertySymbols:function(e){var t=i.f;return t?t(r(e)):[]}})})),Z9=J((()=>{E9(),w9(),M9(),W3(),$9()})),rW=J((()=>{"use strict";var e,t,n,i,r,a,s,o,l=et(),h=Kn(),u=wn(),c=Jt(),d=jr(),p=Lr(),f=ko(),m=ur(),g=Hs(),v=ty(),y=u.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=c(x.valueOf),r=c(x.toString),a=/^Symbol\((.*)\)[^)]+$/,s=c("".replace),o=c("".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}))})),iW=J((()=>{Pa()("asyncIterator")})),sW=J((()=>{Pa()("hasInstance")})),aW=J((()=>{Pa()("isConcatSpreadable")})),oW=J((()=>{Pa()("iterator")})),lW=J((()=>{Pa()("match")})),cW=J((()=>{Pa()("matchAll")})),uW=J((()=>{Pa()("replace")})),hW=J((()=>{Pa()("search")})),dW=J((()=>{Pa()("species")})),fW=J((()=>{Pa()("split")})),pW=J((()=>{var e=Pa(),t=R3();e("toPrimitive"),t()})),mW=J((()=>{var e=Ui(),t=Pa(),n=ro();t("toStringTag"),n(e("Symbol"),"Symbol")})),gW=J((()=>{Pa()("unscopables")})),yW=J(((e,t)=>{var n=Jt(),i=os();t.exports=function(e,t,r){try{return n(i(Object.getOwnPropertyDescriptor(e,t)[r]))}catch(e){}}})),X3=J(((e,t)=>{var n=Lr(),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")}})),uc=J(((e,t)=>{var n=yW(),i=yr(),r=X3();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)})),Y3=J(((e,t)=>{var n=qi().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}})}})),_p=J(((e,t)=>{var n=Lr(),i=Dr(),r=uc();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}})),Ag=J(((e,t)=>{var n=ur();t.exports=function(e,t){return void 0===e?arguments.length<2?"":t:n(e)}})),$3=J(((e,t)=>{var n=Dr(),i=ha();t.exports=function(e,t){n(t)&&"cause"in t&&i(e,"cause",t.cause)}})),QT=J(((e,t)=>{var n=Jt(),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}})),Z3=J(((e,t)=>{var n=Yt(),i=Oo();t.exports=!n((function(){var e=Error("a");return!("stack"in e)||(Object.defineProperty(e,"stack",i(1,7)),7!==e.stack)}))})),K3=J(((e,t)=>{var n=ha(),i=QT(),r=Z3(),a=Error.captureStackTrace;t.exports=function(e,t,s,o){r&&(a?a(e,t):n(e,"stack",i(s,o)))}})),J3=J(((e,t)=>{"use strict";var n=Ui(),i=jr(),r=ha(),a=ko(),s=uc(),o=ty(),l=Y3(),h=_p(),u=Ag(),c=$3(),d=K3(),p=Kn(),f=ls();t.exports=function(e,t,m,g){var v="stackTraceLimit",y=g?2:1,x=e.split("."),b=x[x.length-1],_=n.apply(null,x);if(_){var w=_.prototype;if(!f&&i(w,"cause")&&delete w.cause,!m)return _;var S=n("Error"),M=t((function(e,t){var n=u(g?t:e,void 0),i=g?new _(e):new _;return void 0!==n&&r(i,"message",n),d(i,M,i.stack,2),this&&a(w,this)&&h(i,this,M),arguments.length>y&&c(i,arguments[y]),i}));if(M.prototype=w,"Error"!==b?s?s(M,S):o(M,S,{name:!0}):p&&v in _&&(l(M,_,v),l(M,_,"prepareStackTrace")),o(M,_),!f)try{w.name!==b&&r(w,"name",b),w.constructor=M}catch(e){}return M}}})),zW=J((()=>{var e=et(),t=wn(),n=Fo(),i=J3(),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)}}))})),tL=J(((e,t)=>{"use strict";var n=Kn(),i=Yt(),r=yr(),a=no(),s=Ag(),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})),XW=J((()=>{var e=Hi(),t=tL(),n=Error.prototype;n.toString!==t&&e(n,"toString",t)})),nw=J(((e,t)=>{var n=Yt();t.exports=!n((function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype}))})),so=J(((e,t)=>{var n=jr(),i=Lr(),r=oi(),a=J1(),s=nw(),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}})),Rg=J(((e,t)=>{t.exports={}})),rw=J(((e,t)=>{var n=Or(),i=Rg(),r=n("iterator"),a=Array.prototype;t.exports=function(e){return void 0!==e&&(i.Array===e||a[r]===e)}})),Cg=J(((e,t)=>{var n=cc(),i=su(),r=Ca(),a=Rg(),s=Or()("iterator");t.exports=function(e){if(!r(e))return i(e,s)||i(e,"@@iterator")||a[n(e)]}})),uy=J(((e,t)=>{var n=vr(),i=os(),r=yr(),a=wd(),s=Cg(),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")}})),rL=J(((e,t)=>{var n=vr(),i=yr(),r=su();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}})),hc=J(((e,t)=>{var n=cl(),i=vr(),r=yr(),a=wd(),s=rw(),o=ui(),l=ko(),h=uy(),u=Cg(),c=rL(),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,_,w,S=m&&m.that,M=!(!m||!m.AS_ENTRIES),E=!(!m||!m.IS_RECORD),T=!(!m||!m.IS_ITERATOR),A=!(!m||!m.INTERRUPTED),C=n(t,S),P=function(e){return g&&c(g,"normal",e),new p(!0,e)},R=function(e){return M?(r(e),A?C(e[0],e[1],P):C(e[0],e[1])):A?C(e,P):C(e)};if(E)g=e.iterator;else if(T)g=e;else{if(!(v=u(e)))throw d(a(e)+" is not iterable");if(s(v)){for(y=0,x=o(e);x>y;y++)if((b=R(e[y]))&&l(f,b))return b;return new p(!1)}g=h(e,v)}for(_=E?e.next:g.next;!(w=i(_,g)).done;){try{b=R(w.value)}catch(e){c(g,"throw",e)}if("object"==typeof b&&b&&l(f,b))return b}return new p(!1)}})),cj=J((()=>{"use strict";var e=et(),t=ko(),n=so(),i=uc(),r=ty(),a=no(),s=ha(),o=Oo(),l=$3(),h=K3(),u=hc(),c=Ag(),d=Or()("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",c(r)),h(o,m,o.stack,1),arguments.length>2&&l(o,arguments[2]);var y=[];return u(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})})),uj=J((()=>{cj()})),pj=J((()=>{var e=et(),t=Ui(),n=Fo(),i=Yt(),r=J3(),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)})})),Ia=J(((e,t)=>{var n=Or(),i=no(),r=qi().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}})),gj=J((()=>{"use strict";var e=et(),t=oi(),n=ui(),i=cs(),r=Ia();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")})),wp=J(((e,t)=>{var n=TypeError;t.exports=function(e){if(e>9007199254740991)throw n("Maximum allowed index exceeded");return e}})),Ig=J(((e,t)=>{var n=Yt(),i=Or(),r=iu(),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}))}})),_j=J((()=>{"use strict";var e=et(),t=Yt(),n=hh(),i=Dr(),r=oi(),a=ui(),s=wp(),o=au(),l=wg(),h=Ig(),u=Or(),c=iu(),d=u("isConcatSpreadable"),p=c>=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,u,c=r(this),d=l(c,0),p=0;for(t=-1,i=arguments.length;t<i;t++)if(f(u=-1===t?c:arguments[t]))for(h=a(u),s(p+h),n=0;n<h;n++,p++)n in u&&o(d,p,u[n]);else s(p+1),o(d,p++,u);return d.length=p,d}})})),hy=J(((e,t)=>{"use strict";var n=wd(),i=TypeError;t.exports=function(e,t){if(!delete e[t])throw i("Cannot delete property "+n(t)+" of "+n(e))}})),hL=J(((e,t)=>{"use strict";var n=oi(),i=lc(),r=ui(),a=hy(),s=Math.min;t.exports=[].copyWithin||function(e,t){var o=n(this),l=r(o),h=i(e,l),u=i(t,l),c=arguments.length>2?arguments[2]:void 0,d=s((void 0===c?l:i(c,l))-u,l-h),p=1;for(u<h&&h<u+d&&(p=-1,u+=d-1,h+=d-1);d-- >0;)u in o?o[h]=o[u]:a(o,h),h+=p,u+=p;return o}})),Mj=J((()=>{var e=et(),t=hL(),n=Ia();e({target:"Array",proto:!0},{copyWithin:t}),n("copyWithin")})),lu=J(((e,t)=>{"use strict";var n=Yt();t.exports=function(e,t){var i=[][e];return!!i&&n((function(){i.call(null,t||function(){return 1},1)}))}})),Rj=J((()=>{"use strict";var e=et(),t=Vs().every;e({target:"Array",proto:!0,forced:!lu()("every")},{every:function(e){return t(this,e,arguments.length>1?arguments[1]:void 0)}})})),ow=J(((e,t)=>{"use strict";var n=oi(),i=lc(),r=ui();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}})),Ij=J((()=>{var e=et(),t=ow(),n=Ia();e({target:"Array",proto:!0},{fill:t}),n("fill")})),Lj=J((()=>{"use strict";var e=et(),t=Vs().filter;e({target:"Array",proto:!0,forced:!Ig()("filter")},{filter:function(e){return t(this,e,arguments.length>1?arguments[1]:void 0)}})})),Oj=J((()=>{"use strict";var e=et(),t=Vs().find,n=Ia(),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)})),Fj=J((()=>{"use strict";var e=et(),t=Vs().findIndex,n=Ia(),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)})),dy=J(((e,t)=>{var n=cl(),i=dp(),r=oi(),a=ui(),s=function(e){var t=1==e;return function(s,o,l){for(var h,u=r(s),c=i(u),d=n(o,l),p=a(c);p-- >0;)if(d(h=c[p],p,u))switch(e){case 0:return h;case 1:return p}return t?-1:void 0}};t.exports={findLast:s(0),findLastIndex:s(1)}})),Uj=J((()=>{"use strict";var e=et(),t=dy().findLast,n=Ia();e({target:"Array",proto:!0},{findLast:function(e){return t(this,e,arguments.length>1?arguments[1]:void 0)}}),n("findLast")})),Hj=J((()=>{"use strict";var e=et(),t=dy().findLastIndex,n=Ia();e({target:"Array",proto:!0},{findLastIndex:function(e){return t(this,e,arguments.length>1?arguments[1]:void 0)}}),n("findLastIndex")})),pL=J(((e,t)=>{"use strict";var n=hh(),i=ui(),r=wp(),a=cl(),s=function(e,t,o,l,h,u,c,d){for(var p,f,m=h,g=0,v=!!c&&a(c,d);g<l;)g in o&&(p=v?v(o[g],g,t):o[g],u>0&&n(p)?(f=i(p),m=s(e,t,p,f,m,u-1)-1):(r(m+1),e[m]=p),m++),g++;return m};t.exports=s})),Gj=J((()=>{"use strict";var e=et(),t=pL(),n=oi(),i=ui(),r=cs(),a=wg();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}})})),qj=J((()=>{"use strict";var e=et(),t=pL(),n=os(),i=oi(),r=ui(),a=wg();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}})})),mL=J(((e,t)=>{"use strict";var n=Vs().forEach,i=lu()("forEach");t.exports=i?[].forEach:function(e){return n(this,e,arguments.length>1?arguments[1]:void 0)}})),Xj=J((()=>{"use strict";var e=et(),t=mL();e({target:"Array",proto:!0,forced:[].forEach!=t},{forEach:t})})),$j=J(((e,t)=>{var n=yr(),i=rL();t.exports=function(e,t,r,a){try{return a?t(n(r)[0],r[1]):t(r)}catch(t){i(e,"throw",t)}}})),gL=J(((e,t)=>{"use strict";var n=cl(),i=vr(),r=oi(),a=$j(),s=rw(),o=yp(),l=ui(),h=au(),u=uy(),c=Cg(),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,_,w,S=c(t),M=0;if(!S||this===d&&s(S))for(v=l(t),y=p?new this(v):d(v);v>M;M++)w=g?m(t[M],M):t[M],h(y,M,w);else for(_=(b=u(t,S)).next,y=p?new this:[];!(x=i(_,b)).done;M++)w=g?a(b,m,[x.value,M],!0):x.value,h(y,M,w);return y.length=M,y}})),fy=J(((e,t)=>{var n,i,r=Or()("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}})),rX=J((()=>{var e=et(),t=gL();e({target:"Array",stat:!0,forced:!fy()((function(e){Array.from(e)}))},{from:t})})),iX=J((()=>{"use strict";var e=et(),t=bg().includes,n=Yt(),i=Ia();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")})),aX=J((()=>{"use strict";var e=et(),t=uh(),n=bg().indexOf,i=lu(),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)}})})),oX=J((()=>{et()({target:"Array",stat:!0},{isArray:hh()})})),_L=J(((e,t)=>{"use strict";var n,i,r,a=Yt(),s=Lr(),o=Dr(),l=no(),h=so(),u=Hi(),c=Or(),d=ls(),p=c("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])||u(n,p,(function(){return this})),t.exports={IteratorPrototype:n,BUGGY_SAFARI_ITERATORS:f}})),lw=J(((e,t)=>{"use strict";var n=_L().IteratorPrototype,i=no(),r=Oo(),a=ro(),s=Rg(),o=function(){return this};t.exports=function(e,t,l,h){var u=t+" Iterator";return e.prototype=i(n,{next:r(+!h,l)}),a(e,u,!1,!0),s[u]=o,e}})),hw=J(((e,t)=>{"use strict";var n=et(),i=vr(),r=ls(),a=gp(),s=Lr(),o=lw(),l=so(),h=uc(),u=ro(),c=ha(),d=Hi(),p=Or(),f=Rg(),m=_L(),g=a.PROPER,v=a.CONFIGURABLE,y=m.IteratorPrototype,x=m.BUGGY_SAFARI_ITERATORS,b=p("iterator"),_="keys",w="values",S="entries",M=function(){return this};t.exports=function(e,t,a,p,m,E,T){o(a,t,p);var A,C,P,R=function(e){if(e===m&&D)return D;if(!x&&e in k)return k[e];switch(e){case _:case w:case S:return function(){return new a(this,e)}}return function(){return new a(this)}},L=t+" Iterator",I=!1,k=e.prototype,O=k[b]||k["@@iterator"]||m&&k[m],D=!x&&O||R(m),N="Array"==t&&k.entries||O;if(N&&(A=l(N.call(new e)))!==Object.prototype&&A.next&&(!r&&l(A)!==y&&(h?h(A,y):s(A[b])||d(A,b,M)),u(A,L,!0,!0),r&&(f[L]=M)),g&&m==w&&O&&O.name!==w&&(!r&&v?c(k,"name",w):(I=!0,D=function(){return i(O,this)})),m)if(C={values:R(w),keys:E?D:R(_),entries:R(S)},T)for(P in C)(x||I||!(P in k))&&d(k,P,C[P]);else n({target:t,proto:!0,forced:x||I},C);return(!r||T)&&k[b]!==D&&d(k,b,D,{name:m}),f[t]=D,C}})),gy=J(((e,t)=>{t.exports=function(e,t){return{value:e,done:t}}})),vy=J(((e,t)=>{"use strict";var n=Is(),i=Ia(),r=Rg(),a=Es(),s=qi().f,o=hw(),l=gy(),h=ls(),u=Kn(),c="Array Iterator",d=a.set,p=a.getterFor(c);t.exports=o(Array,"Array",(function(e,t){d(this,{type:c,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&&u&&"values"!==f.name)try{s(f,"name",{value:"values"})}catch(e){}})),RX=J((()=>{"use strict";var e=et(),t=Jt(),n=dp(),i=Is(),r=lu(),a=t([].join);e({target:"Array",proto:!0,forced:n!=Object||!r("join",",")},{join:function(e){return a(i(this),void 0===e?",":e)}})})),ML=J(((e,t)=>{"use strict";var n=Fo(),i=Is(),r=cs(),a=ui(),s=lu(),o=Math.min,l=[].lastIndexOf,h=!!l&&1/[1].lastIndexOf(1,-0)<0,u=s("lastIndexOf"),c=h||!u;t.exports=c?function(e){if(h)return n(l,this,arguments)||0;var t=i(this),s=a(t),u=s-1;for(arguments.length>1&&(u=o(u,r(arguments[1]))),u<0&&(u=s+u);u>=0;u--)if(u in t&&t[u]===e)return u||0;return-1}:l})),LX=J((()=>{var e=et(),t=ML();e({target:"Array",proto:!0,forced:t!==[].lastIndexOf},{lastIndexOf:t})})),DX=J((()=>{"use strict";var e=et(),t=Vs().map;e({target:"Array",proto:!0,forced:!Ig()("map")},{map:function(e){return t(this,e,arguments.length>1?arguments[1]:void 0)}})})),kX=J((()=>{"use strict";var e=et(),t=Yt(),n=yp(),i=au(),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}})})),fw=J(((e,t)=>{"use strict";var n=Kn(),i=hh(),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}})),NX=J((()=>{"use strict";var e=et(),t=oi(),n=ui(),i=fw(),r=wp();e({target:"Array",proto:!0,arity:1,forced:Yt()((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}})})),yy=J(((e,t)=>{var n=os(),i=oi(),r=dp(),a=ui(),s=TypeError,o=function(e){return function(t,o,l,h){n(o);var u=i(t),c=r(u),d=a(u),p=e?d-1:0,f=e?-1:1;if(l<2)for(;;){if(p in c){h=c[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 c&&(h=o(h,c[p],p,u));return h}};t.exports={left:o(!1),right:o(!0)}})),cu=J(((e,t)=>{var n=ua();t.exports="undefined"!=typeof process&&"process"==n(process)})),zX=J((()=>{"use strict";var e=et(),t=yy().left,n=lu(),i=iu();e({target:"Array",proto:!0,forced:!cu()&&i>79&&i<83||!n("reduce")},{reduce:function(e){var n=arguments.length;return t(this,e,n,n>1?arguments[1]:void 0)}})})),qX=J((()=>{"use strict";var e=et(),t=yy().right,n=lu(),i=iu();e({target:"Array",proto:!0,forced:!cu()&&i>79&&i<83||!n("reduceRight")},{reduceRight:function(e){return t(this,e,arguments.length,arguments.length>1?arguments[1]:void 0)}})})),jX=J((()=>{"use strict";var e=et(),t=Jt(),n=hh(),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)}})})),$X=J((()=>{"use strict";var e=et(),t=hh(),n=yp(),i=Dr(),r=lc(),a=ui(),s=Is(),o=au(),l=Or(),h=Ig(),u=Md(),c=h("slice"),d=l("species"),p=Array,f=Math.max;e({target:"Array",proto:!0,forced:!c},{slice:function(e,l){var h,c,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 u(g,y,x);for(c=new(void 0===h?p:h)(f(x-y,0)),m=0;y<x;y++,m++)y in g&&o(c,m,g[y]);return c.length=m,c}})})),ZX=J((()=>{"use strict";var e=et(),t=Vs().some;e({target:"Array",proto:!0,forced:!lu()("some")},{some:function(e){return t(this,e,arguments.length>1?arguments[1]:void 0)}})})),pw=J(((e,t)=>{var n=Tg(),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})),CL=J(((e,t)=>{var n=ru().match(/firefox\/(\d+)/i);t.exports=!!n&&+n[1]})),PL=J(((e,t)=>{var n=ru();t.exports=/MSIE|Trident/.test(n)})),mw=J(((e,t)=>{var n=ru().match(/AppleWebKit\/(\d+)\./);t.exports=!!n&&+n[1]})),dY=J((()=>{"use strict";var e=et(),t=Jt(),n=os(),i=oi(),r=ui(),a=hy(),s=ur(),o=Yt(),l=pw(),h=lu(),u=CL(),c=PL(),d=iu(),p=mw(),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"),b=!o((function(){if(d)return d<70;if(!(u&&u>3)){if(c)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||!b},{sort:function(e){void 0!==e&&n(e);var t=i(this);if(b)return void 0===e?m(t):m(t,e);var o,h,u=[],c=r(t);for(h=0;h<c;h++)h in t&&g(u,t[h]);for(l(u,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(u),h=0;h<o;)t[h]=u[h++];for(;h<c;)a(t,h++);return t}})})),Sp=J(((e,t)=>{"use strict";var n=Ui(),i=Hs(),r=Or(),a=Kn(),s=r("species");t.exports=function(e){var t=n(e);a&&t&&!t[s]&&i(t,s,{configurable:!0,get:function(){return this}})}})),mY=J((()=>{Sp()("Array")})),gY=J((()=>{"use strict";var e=et(),t=oi(),n=lc(),i=cs(),r=ui(),a=fw(),s=wp(),o=wg(),l=au(),h=hy(),u=Ig()("splice"),c=Math.max,d=Math.min;e({target:"Array",proto:!0,forced:!u},{splice:function(e,u){var p,f,m,g,v,y,x=t(this),b=r(x),_=n(e,b),w=arguments.length;for(0===w?p=f=0:1===w?(p=0,f=b-_):(p=w-2,f=d(c(i(u),0),b-_)),s(b+p-f),m=o(x,f),g=0;g<f;g++)(v=_+g)in x&&l(m,g,x[v]);if(m.length=f,p<f){for(g=_;g<b-f;g++)y=g+p,(v=g+f)in x?x[y]=x[v]:h(x,y);for(g=b;g>b-f+p;g--)h(x,g-1)}else if(p>f)for(g=b-f;g>_;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+_]=arguments[g+2];return a(x,b-f+p),m}})})),DL=J(((e,t)=>{var n=ui();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}})),yY=J((()=>{"use strict";var e=et(),t=DL(),n=Is(),i=Ia(),r=Array;e({target:"Array",proto:!0},{toReversed:function(){return t(n(this),r)}}),i("toReversed")})),gw=J(((e,t)=>{var n=ui();t.exports=function(e,t){for(var i=0,r=n(t),a=new e(r);r>i;)a[i]=t[i++];return a}})),EY=J(((e,t)=>{var n=wn();t.exports=function(e){return n[e].prototype}})),_Y=J((()=>{"use strict";var e=et(),t=Jt(),n=os(),i=Is(),r=gw(),a=EY(),s=Ia(),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")})),TY=J((()=>{"use strict";var e=et(),t=Ia(),n=wp(),i=ui(),r=lc(),a=Is(),s=cs(),o=Array,l=Math.max,h=Math.min;e({target:"Array",proto:!0},{toSpliced:function(e,t){var u,c,d,p,f=a(this),m=i(f),g=r(e,m),v=arguments.length,y=0;for(0===v?u=c=0:1===v?(u=0,c=m-g):(u=v-2,c=h(l(s(t),0),m-g)),d=n(m+u-c),p=o(d);y<g;y++)p[y]=f[y];for(;y<g+u;y++)p[y]=arguments[y-g+2];for(;y<d;y++)p[y]=f[y+c-u];return p}}),t("toSpliced")})),wY=J((()=>{Ia()("flat")})),SY=J((()=>{Ia()("flatMap")})),MY=J((()=>{"use strict";var e=et(),t=oi(),n=ui(),i=fw(),r=hy(),a=wp();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 u=h+l;h in s?s[u]=s[h]:r(s,u)}for(var c=0;c<l;c++)s[c]=arguments[c]}return i(s,o+l)}})})),OL=J(((e,t)=>{var n=ui(),i=cs(),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 u=new t(o),c=0;c<o;c++)u[c]=c===h?s:e[c];return u}})),RY=J((()=>{"use strict";var e=et(),t=OL(),n=Is(),i=Array;e({target:"Array",proto:!0},{with:function(e,r){return t(n(this),i,e,r)}})})),vw=J(((e,t)=>{t.exports="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof DataView})),Lg=J(((e,t)=>{var n=Hi();t.exports=function(e,t,i){for(var r in t)n(e,r,t[r],i);return e}})),dc=J(((e,t)=>{var n=ko(),i=TypeError;t.exports=function(e,t){if(n(t,e))return e;throw i("Incorrect invocation")}})),kL=J(((e,t)=>{var n=cs(),i=to(),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}})),OY=J(((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,u,c,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?(u=e!=e?1:0,h=f):(h=a(s(e)/o),e*(c=r(2,-h))<1&&(h--,c*=2),(e+=h+m>=1?g/c:g*r(2,1-m))*c>=2&&(h++,c/=2),h+m>=f?(u=0,h=f):h+m>=1?(u=(e*c-1)*r(2,t),h+=m):(u=e*r(2,m-1)*r(2,t),h=0));t>=8;)d[y++]=255&u,u/=256,t-=8;for(h=h<<t|u,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,u=e[h--],c=127&u;for(u>>=7;l>0;)c=256*c+e[h--],l-=8;for(n=c&(1<<-l)-1,c>>=-l,l+=t;l>0;)n=256*n+e[h--],l-=8;if(0===c)c=1-o;else{if(c===s)return n?NaN:u?-1/0:1/0;n+=r(2,t),c-=o}return(u?-1:1)*n*r(2,c-t)}}})),Ey=J(((e,t)=>{"use strict";var n,i,r,a,s,o,l=wn(),h=Jt(),u=Kn(),c=vw(),d=gp(),p=ha(),f=Hs(),m=Lg(),g=Yt(),v=dc(),y=cs(),x=to(),b=kL(),_=OY(),w=so(),S=uc(),M=ch().f,E=ow(),T=Tg(),A=ro(),C=Es(),P=d.PROPER,R=d.CONFIGURABLE,L="ArrayBuffer",I="DataView",k="prototype",O="Wrong index",D=C.getterFor(L),N=C.getterFor(I),U=C.set,F=l[L],B=F,z=B&&B[k],H=l[I],V=H&&H[k],j=Object.prototype,G=l.Array,W=l.RangeError,X=h(E),Y=h([].reverse),q=_.pack,J=_.unpack,Z=function(e){return[255&e]},K=function(e){return[255&e,e>>8&255]},$=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 q(e,23,4)},te=function(e){return q(e,52,8)},ne=function(e,t,n){f(e[k],t,{configurable:!0,get:function(){return n(this)[t]}})},ie=function(e,t,n,i){var r=N(e),a=b(n),s=!!i;if(a+t>r.byteLength)throw W(O);var o=r.bytes,l=a+r.byteOffset,h=T(o,l,l+t);return s?h:Y(h)},re=function(e,t,n,i,r,a){var s=N(e),o=b(n),l=i(+r),h=!!a;if(o+t>s.byteLength)throw W(O);for(var u=s.bytes,c=o+s.byteOffset,d=0;d<t;d++)u[c+d]=l[h?d:t-d-1]};if(c){if(n=P&&F.name!==L,g((function(){F(1)}))&&g((function(){new F(-1)}))&&!g((function(){return new F,new F(1.5),new F(NaN),1!=F.length||n&&!R})))n&&R&&p(F,"name",L);else{for((B=function(e){return v(this,z),new F(b(e))})[k]=z,i=M(F),r=0;i.length>r;)(a=i[r++])in B||p(B,a,F[a]);z.constructor=B}S&&w(V)!==j&&S(V,j),s=new H(new B(2)),o=h(V.setInt8),s.setInt8(0,2147483648),s.setInt8(1,2147483649),(s.getInt8(0)||!s.getInt8(1))&&m(V,{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=b(e);U(this,{type:L,bytes:X(G(t),0),byteLength:t}),u||(this.byteLength=t,this.detached=!1)})[k],V=(H=function(e,t,n){v(this,V),v(e,z);var i=D(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");U(this,{type:I,buffer:e,byteLength:n,byteOffset:a,bytes:i.bytes}),u||(this.buffer=e,this.byteLength=n,this.byteOffset=a)})[k],u&&(ne(B,"byteLength",D),ne(H,"buffer",N),ne(H,"byteLength",N),ne(H,"byteOffset",N)),m(V,{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]);return(t[1]<<8|t[0])<<16>>16},getUint16:function(e){var t=ie(this,2,e,arguments.length>1&&arguments[1]);return t[1]<<8|t[0]},getInt32:function(e){return Q(ie(this,4,e,arguments.length>1&&arguments[1]))},getUint32:function(e){return Q(ie(this,4,e,arguments.length>1&&arguments[1]))>>>0},getFloat32:function(e){return J(ie(this,4,e,arguments.length>1&&arguments[1]),23)},getFloat64:function(e){return J(ie(this,8,e,arguments.length>1&&arguments[1]),52)},setInt8:function(e,t){re(this,1,e,Z,t)},setUint8:function(e,t){re(this,1,e,Z,t)},setInt16:function(e,t){re(this,2,e,K,t,arguments.length>2&&arguments[2])},setUint16:function(e,t){re(this,2,e,K,t,arguments.length>2&&arguments[2])},setInt32:function(e,t){re(this,4,e,$,t,arguments.length>2&&arguments[2])},setUint32:function(e,t){re(this,4,e,$,t,arguments.length>2&&arguments[2])},setFloat32:function(e,t){re(this,4,e,ee,t,arguments.length>2&&arguments[2])},setFloat64:function(e,t){re(this,8,e,te,t,arguments.length>2&&arguments[2])}});A(B,L),A(H,I),t.exports={ArrayBuffer:B,DataView:H}})),e$=J((()=>{"use strict";var e=et(),t=wn(),n=Ey(),i=Sp(),r="ArrayBuffer",a=n[r];e({global:!0,constructor:!0,forced:t[r]!==a},{ArrayBuffer:a}),i(r)})),Mr=J(((e,t)=>{"use strict";var n,i,r,a=vw(),s=Kn(),o=wn(),l=Lr(),h=Dr(),u=jr(),c=cc(),d=wd(),p=ha(),f=Hi(),m=Hs(),g=ko(),v=so(),y=uc(),x=Or(),b=mp(),_=Es(),w=_.enforce,S=_.get,M=o.Int8Array,E=M&&M.prototype,T=o.Uint8ClampedArray,A=T&&T.prototype,C=M&&v(M),P=E&&v(E),R=Object.prototype,L=o.TypeError,I=x("toStringTag"),k=b("TYPED_ARRAY_TAG"),O="TypedArrayConstructor",D=a&&!!y&&"Opera"!==c(o.opera),N=!1,U={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8},F={BigInt64Array:8,BigUint64Array:8},B=function(e){var t=v(e);if(h(t)){var n=S(t);return n&&u(n,O)?n[O]:B(t)}},z=function(e){if(!h(e))return!1;var t=c(e);return u(U,t)||u(F,t)};for(n in U)(r=(i=o[n])&&i.prototype)?w(r)[O]=i:D=!1;for(n in F)(r=(i=o[n])&&i.prototype)&&(w(r)[O]=i);if((!D||!l(C)||C===Function.prototype)&&(C=function(){throw L("Incorrect invocation")},D))for(n in U)o[n]&&y(o[n],C);if((!D||!P||P===R)&&(P=C.prototype,D))for(n in U)o[n]&&y(o[n].prototype,P);if(D&&v(A)!==P&&y(A,P),s&&!u(P,I))for(n in N=!0,m(P,I,{configurable:!0,get:function(){return h(this)?this[k]:void 0}}),U)o[n]&&p(o[n],k,n);t.exports={NATIVE_ARRAY_BUFFER_VIEWS:D,TYPED_ARRAY_TAG:N&&k,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 U){var a=o[r];if(a&&u(a.prototype,e))try{delete a.prototype[e]}catch(n){try{a.prototype[e]=t}catch(e){}}}(!P[e]||n)&&f(P,e,n?t:D&&E[e]||t,i)}},exportTypedArrayStaticMethod:function(e,t,n){var i,r;if(s){if(y){if(n)for(i in U)if((r=o[i])&&u(r,e))try{delete r[e]}catch(e){}if(C[e]&&!n)return;try{return f(C,e,n?t:D&&C[e]||t)}catch(e){}}for(i in U)(r=o[i])&&(!r[e]||n)&&f(r,e,t)}},getTypedArrayConstructor:B,isView:function(e){if(!h(e))return!1;var t=c(e);return"DataView"===t||u(U,t)||u(F,t)},isTypedArray:z,TypedArray:C,TypedArrayPrototype:P}})),d$=J((()=>{var e=et(),t=Mr();e({target:"ArrayBuffer",stat:!0,forced:!t.NATIVE_ARRAY_BUFFER_VIEWS},{isView:t.isView})})),Cw=J(((e,t)=>{var n=yp(),i=wd(),r=TypeError;t.exports=function(e){if(n(e))return e;throw r(i(e)+" is not a constructor")}})),Ap=J(((e,t)=>{var n=yr(),i=Cw(),r=Ca(),a=Or()("species");t.exports=function(e,t){var s,o=n(e).constructor;return void 0===o||r(s=n(o)[a])?t:i(s)}})),E$=J((()=>{"use strict";var e=et(),t=uh(),n=Yt(),i=Ey(),r=yr(),a=lc(),s=to(),o=Ap(),l=i.ArrayBuffer,h=i.DataView,u=h.prototype,c=t(l.prototype.slice),d=t(u.getUint8),p=t(u.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(c&&void 0===t)return c(r(this),e);for(var n=r(this).byteLength,i=a(e,n),u=a(void 0===t?n:t,n),f=new(o(this,l))(s(u-i)),m=new h(this),g=new h(f),v=0;i<u;)p(g,v++,d(m,i++));return f}})})),_$=J((()=>{var e=et(),t=Ey();e({global:!0,constructor:!0,forced:!vw()},{DataView:t.DataView})})),T$=J((()=>{_$()})),w$=J((()=>{"use strict";var e=et(),t=Jt(),n=Yt()((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}})})),M$=J((()=>{var e=et(),t=Jt(),n=Date,i=t(n.prototype.getTime);e({target:"Date",stat:!0},{now:function(){return i(new n)}})})),C$=J((()=>{"use strict";var e=et(),t=Jt(),n=cs(),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)}})})),P$=J((()=>{et()({target:"Date",proto:!0},{toGMTString:Date.prototype.toUTCString})})),_y=J(((e,t)=>{"use strict";var n=cs(),i=ur(),r=as(),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}})),Pw=J(((e,t)=>{var n=Jt(),i=to(),r=ur(),a=_y(),s=as(),o=n(a),l=n("".slice),h=Math.ceil,u=function(e){return function(t,n,a){var u,c,d=r(s(t)),p=i(n),f=d.length,m=void 0===a?" ":r(a);return p<=f||""==m?d:((c=o(m,h((u=p-f)/m.length))).length>u&&(c=l(c,0,u)),e?d+c:c+d)}};t.exports={start:u(!1),end:u(!0)}})),B$=J(((e,t)=>{"use strict";var n=Jt(),i=Yt(),r=Pw().start,a=RangeError,s=isFinite,o=Math.abs,l=Date.prototype,h=l.toISOString,u=n(l.getTime),c=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(u(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(c(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})),H$=J((()=>{var e=et(),t=B$();e({target:"Date",proto:!0,forced:Date.prototype.toISOString!==t},{toISOString:t})})),V$=J((()=>{"use strict";var e=et(),t=Yt(),n=oi(),i=Z1();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}})})),G$=J(((e,t)=>{"use strict";var n=yr(),i=t3(),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)}})),j$=J((()=>{var e=jr(),t=Hi(),n=G$(),i=Or()("toPrimitive"),r=Date.prototype;e(r,i)||t(r,i,n)})),Z$=J((()=>{var e=Jt(),t=Hi(),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}))})),J$=J((()=>{"use strict";var e=et(),t=Jt(),n=ur(),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,u=n(e),c="",d=u.length,p=0;p<d;)t=i(u,p++),a(l,t)?c+=t:c+=(s=r(t,0))<256?"%"+h(s,2):"%u"+o(h(s,4));return c}})})),iD=J(((e,t)=>{"use strict";var n=Jt(),i=os(),r=Dr(),a=jr(),s=Md(),o=vg(),l=Function,h=n([].concat),u=n([].join),c={};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(c,t)){for(var i=[],r=0;r<t;r++)i[r]="a["+r+"]";c[t]=l("C,a","return new C("+u(i,",")+")")}return c[t](e,n)}(t,n.length,n):t.apply(e,n)};return r(n)&&(d.prototype=n),d}})),iZ=J((()=>{var e=et(),t=iD();e({target:"Function",proto:!0,forced:Function.bind!==t},{bind:t})})),oZ=J((()=>{"use strict";var e=Lr(),t=Dr(),n=qi(),i=so(),r=Or(),a=FT(),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)})})),hZ=J((()=>{var e=Kn(),t=gp().EXISTS,n=Jt(),i=Hs(),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""}}})})),dZ=J((()=>{var e=et(),t=wn();e({global:!0,forced:t.globalThis!==t},{globalThis:t})})),fZ=J((()=>{var e=wn();ro()(e.JSON,"JSON",!0)})),Iw=J(((e,t)=>{var n=Yt();t.exports=n((function(){if("function"==typeof ArrayBuffer){var e=new ArrayBuffer(8);Object.isExtensible(e)&&Object.defineProperty(e,"a",{value:8})}}))})),Dw=J(((e,t)=>{var n=Yt(),i=Dr(),r=ua(),a=Iw(),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})),Cp=J(((e,t)=>{var n=Yt();t.exports=!n((function(){return Object.isExtensible(Object.preventExtensions({}))}))})),Od=J(((e,t)=>{var n=et(),i=Jt(),r=xg(),a=Dr(),s=jr(),o=qi().f,l=ch(),h=qT(),u=Dw(),c=mp(),d=Cp(),p=!1,f=c("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(!u(e))return"F";if(!t)return"E";g(e)}return e[f].objectID},getWeakData:function(e,t){if(!s(e,f)){if(!u(e))return!0;if(!t)return!1;g(e)}return e[f].weakData},onFreeze:function(e){return d&&p&&u(e)&&!s(e,f)&&g(e),e}};r[f]=!0})),wy=J(((e,t)=>{"use strict";var n=et(),i=wn(),r=Jt(),a=Eg(),s=Hi(),o=Od(),l=hc(),h=dc(),u=Lr(),c=Ca(),d=Dr(),p=Yt(),f=fy(),m=ro(),g=_p();t.exports=function(e,t,v){var y=-1!==e.indexOf("Map"),x=-1!==e.indexOf("Weak"),b=y?"set":"add",_=i[e],w=_&&_.prototype,S=_,M={},E=function(e){var t=r(w[e]);s(w,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,!u(_)||!(x||w.forEach&&!p((function(){(new _).entries().next()})))))S=v.getConstructor(t,e,y,b),o.enable();else if(a(e,!0)){var T=new S,A=T[b](x?{}:-0,1)!=T,C=p((function(){T.has(1)})),P=f((function(e){new _(e)})),R=!x&&p((function(){for(var e=new _,t=5;t--;)e[b](t,t);return!e.has(-0)}));P||((S=t((function(e,t){h(e,w);var n=g(new _,e,S);return c(t)||l(t,n[b],{that:n,AS_ENTRIES:y}),n}))).prototype=w,w.constructor=S),(C||R)&&(E("delete"),E("has"),y&&E("get")),(R||A)&&E(b),x&&w.clear&&delete w.clear}return M[e]=S,n({global:!0,constructor:!0,forced:S!=_},M),m(S,e),x||v.setStrong(S,e,y),S}})),fD=J(((e,t)=>{"use strict";var n=no(),i=Hs(),r=Lg(),a=cl(),s=dc(),o=Ca(),l=hc(),h=hw(),u=gy(),c=Sp(),d=Kn(),p=Od().fastKey,f=Es(),m=f.set,g=f.getterFor;t.exports={getConstructor:function(e,t,h,u){var c=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[u],{that:e,AS_ENTRIES:h})})),f=c.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}}),c},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)?u("keys"==t?n.key:"values"==t?n.value:[n.key,n.value],!1):(e.target=void 0,u(void 0,!0))}),n?"entries":"values",!n,!0),c(t)}}})),RZ=J((()=>{"use strict";wy()("Map",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),fD())})),CZ=J((()=>{RZ()})),pD=J(((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)}})),LZ=J((()=>{var e=et(),t=pD(),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))}})})),kZ=J((()=>{var e=et(),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}})})),NZ=J((()=>{var e=et(),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}})})),kw=J(((e,t)=>{t.exports=Math.sign||function(e){var t=+e;return 0==t||t!=t?t:t<0?-1:1}})),UZ=J((()=>{var e=et(),t=kw(),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)}})})),HZ=J((()=>{var e=et(),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}})})),Ay=J(((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})),GZ=J((()=>{var e=et(),t=Ay(),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)}})})),WZ=J((()=>{var e=et(),t=Ay();e({target:"Math",stat:!0,forced:t!=Math.expm1},{expm1:t})})),XZ=J(((e,t)=>{var n=kw(),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,u=i(h),c=n(h);return u<l?c*(u/l/s+1/a-1/a)*l*s:(r=(t=(1+s/a)*u)-(t-u))>o||r!=r?c*(1/0):c*r}})),YZ=J((()=>{et()({target:"Math",stat:!0},{fround:XZ()})})),ZZ=J((()=>{var e=et(),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)}})})),JZ=J((()=>{var e=et(),t=Yt(),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)}})})),xD=J(((e,t)=>{var n=Math.log,i=Math.LOG10E;t.exports=Math.log10||function(e){return n(e)*i}})),eK=J((()=>{et()({target:"Math",stat:!0},{log10:xD()})})),tK=J((()=>{et()({target:"Math",stat:!0},{log1p:pD()})})),nK=J((()=>{var e=et(),t=Math.log,n=Math.LN2;e({target:"Math",stat:!0},{log2:function(e){return t(e)/n}})})),rK=J((()=>{et()({target:"Math",stat:!0},{sign:kw()})})),aK=J((()=>{var e=et(),t=Yt(),n=Ay(),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)}})})),cK=J((()=>{var e=et(),t=Ay(),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))}})})),uK=J((()=>{ro()(Math,"Math",!0)})),hK=J((()=>{et()({target:"Math",stat:!0},{trunc:x3()})})),Ry=J(((e,t)=>{var n=Jt();t.exports=n(1..valueOf)})),Cy=J(((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"})),Pp=J(((e,t)=>{var n=Jt(),i=as(),r=ur(),a=Cy(),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)}})),_K=J((()=>{"use strict";var e=et(),t=ls(),n=Kn(),i=wn(),r=WT(),a=Jt(),s=Eg(),o=jr(),l=_p(),h=ko(),u=Td(),c=Z1(),d=Yt(),p=ch().f,f=Qs().f,m=qi().f,g=Ry(),v=Pp().trim,y="Number",x=i[y],b=r[y],_=x.prototype,w=i.TypeError,S=a("".slice),M=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=c(e,"number");return"bigint"==typeof t?t:function(e){var t,n,i,r,a,s,o,l,h=c(e,"number");if(u(h))throw w("Cannot convert a Symbol value to a number");if("string"==typeof h&&h.length>2)if(h=v(h),43===(t=M(h,0))||45===t){if(88===(n=M(h,2))||120===n)return NaN}else if(48===t){switch(M(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=S(h,2)).length,o=0;o<s;o++)if((l=M(a,o))<48||l>r)return NaN;return parseInt(a,i)}return+h}(t)}(e));return h(_,t=this)&&d((function(){g(t)}))?l(Object(n),this,T):n};T.prototype=_,E&&!t&&(_.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&&b&&A(r[y],b),(E||t)&&A(r[y],x)})),TK=J((()=>{et()({target:"Number",stat:!0,nonConfigurable:!0,nonWritable:!0},{EPSILON:Math.pow(2,-52)})})),SK=J(((e,t)=>{var n=wn().isFinite;t.exports=Number.isFinite||function(e){return"number"==typeof e&&n(e)}})),MK=J((()=>{et()({target:"Number",stat:!0},{isFinite:SK()})})),Hw=J(((e,t)=>{var n=Dr(),i=Math.floor;t.exports=Number.isInteger||function(e){return!n(e)&&isFinite(e)&&i(e)===e}})),RK=J((()=>{et()({target:"Number",stat:!0},{isInteger:Hw()})})),CK=J((()=>{et()({target:"Number",stat:!0},{isNaN:function(e){return e!=e}})})),PK=J((()=>{var e=et(),t=Hw(),n=Math.abs;e({target:"Number",stat:!0},{isSafeInteger:function(e){return t(e)&&n(e)<=9007199254740991}})})),IK=J((()=>{et()({target:"Number",stat:!0,nonConfigurable:!0,nonWritable:!0},{MAX_SAFE_INTEGER:9007199254740991})})),LK=J((()=>{et()({target:"Number",stat:!0,nonConfigurable:!0,nonWritable:!0},{MIN_SAFE_INTEGER:-9007199254740991})})),MD=J(((e,t)=>{var n=wn(),i=Yt(),r=Jt(),a=ur(),s=Pp().trim,o=Cy(),l=r("".charAt),h=n.parseFloat,u=n.Symbol,c=u&&u.iterator,d=1/h(o+"-0")!=-1/0||c&&!i((function(){h(Object(c))}));t.exports=d?function(e){var t=s(a(e)),n=h(t);return 0===n&&"-"==l(t,0)?-0:n}:h})),BK=J((()=>{var e=et(),t=MD();e({target:"Number",stat:!0,forced:Number.parseFloat!=t},{parseFloat:t})})),AD=J(((e,t)=>{var n=wn(),i=Yt(),r=Jt(),a=ur(),s=Pp().trim,o=Cy(),l=n.parseInt,h=n.Symbol,u=h&&h.iterator,c=/^[+-]?0x/i,d=r(c.exec),p=8!==l(o+"08")||22!==l(o+"0x16")||u&&!i((function(){l(Object(u))}));t.exports=p?function(e,t){var n=s(a(e));return l(n,t>>>0||(d(c,n)?16:10))}:l})),jK=J((()=>{var e=et(),t=AD();e({target:"Number",stat:!0,forced:Number.parseInt!=t},{parseInt:t})})),KK=J((()=>{"use strict";var e=et(),t=Jt(),n=cs(),i=Ry(),r=_y(),a=xD(),s=Yt(),o=RangeError,l=String,h=isFinite,u=Math.abs,c=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 w=a(t);x=c(w);var S=0,M=d(10,x-r);2*t>=(2*(S=p(t/M))+1)*M&&(S+=1),S>=d(10,r+1)&&(S/=10,x+=1),y=l(S)}return 0!==r&&(y=g(y,0,1)+"."+g(y,1)),0===x?(b="+",_="0"):(b=x>0?"+":"-",_=l(u(x))),s+(y+"e")+b+_}})})),rJ=J((()=>{"use strict";var e=et(),t=Jt(),n=cs(),i=Ry(),r=_y(),a=Yt(),s=RangeError,o=String,l=Math.floor,h=t(r),u=t("".slice),c=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"!==c(8e-5,3)||"1"!==c(.9,0)||"1.25"!==c(1.255,2)||"1000000000000000128"!==c(0xde0b6b3a7640080,0)}))||!a((function(){c({})}))},{toFixed:function(e){var t,r,a,l,c=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(c!=c)return"NaN";if(c<=-1e21||c>=1e21)return o(c);if(c<0&&(y="-",c=-c),c>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}(c*d(2,69,1))-69,r=t<0?c*d(2,-t,1):c/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:u(x,0,l-g)+"."+u(x,l-g)):y+x}})})),aJ=J((()=>{"use strict";var e=et(),t=Jt(),n=Yt(),i=Ry(),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)}})})),OD=J(((e,t)=>{"use strict";var n=Kn(),i=Jt(),r=vr(),a=Yt(),s=_g(),o=ey(),l=$1(),h=oi(),u=dp(),c=Object.assign,d=Object.defineProperty,p=i([].concat);t.exports=!c||a((function(){if(n&&1!==c({b:1},c(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!=c({},e)[i]||s(c({},t)).join("")!=r}))?function(e,t){for(var i=h(e),a=arguments.length,c=1,d=o.f,f=l.f;a>c;)for(var m,g=u(arguments[c++]),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}:c})),hJ=J((()=>{var e=et(),t=OD();e({target:"Object",stat:!0,arity:2,forced:Object.assign!==t},{assign:t})})),dJ=J((()=>{et()({target:"Object",stat:!0,sham:!Kn()},{create:no()})})),Dy=J(((e,t)=>{"use strict";var n=ls(),i=wn(),r=Yt(),a=mw();t.exports=n||!r((function(){if(!(a&&a<535)){var e=Math.random();__defineSetter__.call(null,e,(function(){})),delete i[e]}}))})),mJ=J((()=>{"use strict";var e=et(),t=Kn(),n=Dy(),i=os(),r=oi(),a=qi();t&&e({target:"Object",proto:!0,forced:n},{__defineGetter__:function(e,t){a.f(r(this),e,{get:i(t),enumerable:!0,configurable:!0})}})})),vJ=J((()=>{var e=et(),t=Kn(),n=VT().f;e({target:"Object",stat:!0,forced:Object.defineProperties!==n,sham:!t},{defineProperties:n})})),xJ=J((()=>{var e=et(),t=Kn(),n=qi().f;e({target:"Object",stat:!0,forced:Object.defineProperty!==n,sham:!t},{defineProperty:n})})),bJ=J((()=>{"use strict";var e=et(),t=Kn(),n=Dy(),i=os(),r=oi(),a=qi();t&&e({target:"Object",proto:!0,forced:n},{__defineSetter__:function(e,t){a.f(r(this),e,{set:i(t),enumerable:!0,configurable:!0})}})})),kD=J(((e,t)=>{var n=Kn(),i=Yt(),r=Jt(),a=so(),s=_g(),o=Is(),l=r($1().f),h=r([].push),u=n&&i((function(){var e=Object.create(null);return e[2]=2,!l(e,2)})),c=function(e){return function(t){for(var i,r=o(t),c=s(r),d=u&&null===a(r),p=c.length,f=0,m=[];p>f;)i=c[f++],(!n||(d?i in r:l(r,i)))&&h(m,e?[i,r[i]]:r[i]);return m}};t.exports={entries:c(!0),values:c(!1)}})),MJ=J((()=>{var e=et(),t=kD().entries;e({target:"Object",stat:!0},{entries:function(e){return t(e)}})})),AJ=J((()=>{var e=et(),t=Cp(),n=Yt(),i=Dr(),r=Od().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}})})),RJ=J((()=>{var e=et(),t=hc(),n=au();e({target:"Object",stat:!0},{fromEntries:function(e){var i={};return t(e,(function(e,t){n(i,e,t)}),{AS_ENTRIES:!0}),i}})})),IJ=J((()=>{var e=et(),t=Yt(),n=Is(),i=Qs().f,r=Kn();e({target:"Object",stat:!0,forced:!r||t((function(){i(1)})),sham:!r},{getOwnPropertyDescriptor:function(e,t){return i(n(e),t)}})})),LJ=J((()=>{var e=et(),t=Kn(),n=BT(),i=Is(),r=Qs(),a=au();e({target:"Object",stat:!0,sham:!t},{getOwnPropertyDescriptors:function(e){for(var t,s,o=i(e),l=r.f,h=n(o),u={},c=0;h.length>c;)void 0!==(s=l(o,t=h[c++]))&&a(u,t,s);return u}})})),DJ=J((()=>{var e=et(),t=Yt(),n=qT().f;e({target:"Object",stat:!0,forced:t((function(){return!Object.getOwnPropertyNames(1)}))},{getOwnPropertyNames:n})})),kJ=J((()=>{var e=et(),t=Yt(),n=oi(),i=so(),r=nw();e({target:"Object",stat:!0,forced:t((function(){i(1)})),sham:!r},{getPrototypeOf:function(e){return i(n(e))}})})),FJ=J((()=>{et()({target:"Object",stat:!0},{hasOwn:jr()})})),ND=J(((e,t)=>{t.exports=Object.is||function(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}})),BJ=J((()=>{et()({target:"Object",stat:!0},{is:ND()})})),HJ=J((()=>{var e=et(),t=Dw();e({target:"Object",stat:!0,forced:Object.isExtensible!==t},{isExtensible:t})})),zJ=J((()=>{var e=et(),t=Yt(),n=Dr(),i=ua(),r=Iw(),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)}})})),qJ=J((()=>{var e=et(),t=Yt(),n=Dr(),i=ua(),r=Iw(),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)}})})),jJ=J((()=>{var e=et(),t=oi(),n=_g();e({target:"Object",stat:!0,forced:Yt()((function(){n(1)}))},{keys:function(e){return n(t(e))}})})),XJ=J((()=>{"use strict";var e=et(),t=Kn(),n=Dy(),i=oi(),r=lh(),a=so(),s=Qs().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))}})})),YJ=J((()=>{"use strict";var e=et(),t=Kn(),n=Dy(),i=oi(),r=lh(),a=so(),s=Qs().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))}})})),$J=J((()=>{var e=et(),t=Dr(),n=Od().onFreeze,i=Cp(),r=Yt(),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}})})),tQ=J((()=>{"use strict";var e=Kn(),t=Hs(),n=Dr(),i=oi(),r=as(),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){}})),nQ=J((()=>{var e=et(),t=Dr(),n=Od().onFreeze,i=Cp(),r=Yt(),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}})})),rQ=J((()=>{et()({target:"Object",stat:!0},{setPrototypeOf:uc()})})),sQ=J(((e,t)=>{"use strict";var n=UT(),i=cc();t.exports=n?{}.toString:function(){return"[object "+i(this)+"]"}})),aQ=J((()=>{var e=UT(),t=Hi(),n=sQ();e||t(Object.prototype,"toString",n,{unsafe:!0})})),oQ=J((()=>{var e=et(),t=kD().values;e({target:"Object",stat:!0},{values:function(e){return t(e)}})})),cQ=J((()=>{var e=et(),t=MD();e({global:!0,forced:parseFloat!=t},{parseFloat:t})})),hQ=J((()=>{var e=et(),t=AD();e({global:!0,forced:parseInt!=t},{parseInt:t})})),dl=J(((e,t)=>{var n=TypeError;t.exports=function(e,t){if(e<t)throw n("Not enough arguments");return e}})),zD=J(((e,t)=>{var n=ru();t.exports=/(?:ipad|iphone|ipod).*applewebkit/i.test(n)})),Fy=J(((e,t)=>{var n,i,r,a,s=wn(),o=Fo(),l=cl(),h=Lr(),u=jr(),c=Yt(),d=T3(),p=Md(),f=K1(),m=dl(),g=zD(),v=cu(),y=s.setImmediate,x=s.clearImmediate,b=s.process,_=s.Dispatch,w=s.Function,S=s.MessageChannel,M=s.String,E=0,T={},A="onreadystatechange";c((function(){n=s.location}));var C=function(e){if(u(T,e)){var t=T[e];delete T[e],t()}},P=function(e){return function(){C(e)}},R=function(e){C(e.data)},L=function(e){s.postMessage(M(e),n.protocol+"//"+n.host)};(!y||!x)&&(y=function(e){m(arguments.length,1);var t=h(e)?e:w(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){b.nextTick(P(e))}:_&&_.now?i=function(e){_.now(P(e))}:S&&!g?(a=(r=new S).port2,r.port1.onmessage=R,i=l(a.postMessage,a)):s.addEventListener&&h(s.postMessage)&&!s.importScripts&&n&&"file:"!==n.protocol&&!c(L)?(i=L,s.addEventListener("message",R,!1)):i=A in f("script")?function(e){d.appendChild(f("script"))[A]=function(){d.removeChild(this),C(e)}}:function(e){setTimeout(P(e),0)}),t.exports={set:y,clear:x}})),KD=J(((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})),MQ=J(((e,t)=>{var n=ru();t.exports=/ipad|iphone|ipod/i.test(n)&&"undefined"!=typeof Pebble})),RQ=J(((e,t)=>{var n=ru();t.exports=/web0s(?!.*chrome)/i.test(n)})),rO=J(((e,t)=>{var n,i,r,a,s,o,l,h=wn(),u=cl(),c=Qs().f,d=Fy().set,p=KD(),f=zD(),m=MQ(),g=RQ(),v=cu(),y=h.MutationObserver||h.WebKitMutationObserver,x=h.document,b=h.process,_=h.Promise,w=c(h,"queueMicrotask"),S=w&&w.value;S||(o=new p,l=function(){var e,t;for(v&&(e=b.domain)&&e.exit();t=o.get();)try{t()}catch(e){throw o.head&&n(),e}e&&e.enter()},f||v||g||!y||!x?!m&&_&&_.resolve?((a=_.resolve(void 0)).constructor=_,s=u(a.then,a),n=function(){s(l)}):v?n=function(){b.nextTick(l)}:(d=u(d,h),n=function(){d(l)}):(i=!0,r=x.createTextNode(""),new y(l).observe(r,{characterData:!0}),n=function(){r.data=i=!i}),S=function(e){o.head||n(),o.add(e)}),t.exports=S})),NQ=J(((e,t)=>{t.exports=function(e,t){try{1==arguments.length?console.error(e):console.error(e,t)}catch(e){}}})),Gg=J(((e,t)=>{t.exports=function(e){try{return{error:!1,value:e()}}catch(e){return{error:!0,value:e}}}})),Dp=J(((e,t)=>{var n=wn();t.exports=n.Promise})),Ww=J(((e,t)=>{t.exports="object"==typeof Deno&&Deno&&"object"==typeof Deno.version})),iO=J(((e,t)=>{var n=Ww(),i=cu();t.exports=!n&&!i&&"object"==typeof window&&"object"==typeof document})),qg=J(((e,t)=>{var n=wn(),i=Dp(),r=Lr(),a=Eg(),s=IT(),o=Or(),l=iO(),h=Ww(),u=ls(),c=iu(),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===c||u&&(!d.catch||!d.finally))return!0;if(!c||c<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}})),kd=J(((e,t)=>{"use strict";var n=os(),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)}})),hee=J((()=>{"use strict";var e,t,n,i=et(),r=ls(),a=cu(),s=wn(),o=vr(),l=Hi(),h=uc(),u=ro(),c=Sp(),d=os(),p=Lr(),f=Dr(),m=dc(),g=Ap(),v=Fy().set,y=rO(),x=NQ(),b=Gg(),_=KD(),w=Es(),S=Dp(),M=qg(),E=kd(),T="Promise",A=M.CONSTRUCTOR,C=M.REJECTION_EVENT,P=M.SUBCLASSING,R=w.getterFor(T),L=w.set,I=S&&S.prototype,k=S,O=I,D=s.TypeError,N=s.document,U=s.process,F=E.f,B=F,z=!!(N&&N.createEvent&&s.dispatchEvent),H="unhandledrejection",V=function(e){var t;return!(!f(e)||!p(t=e.then))&&t},j=function(e,t){var n,i,r,a=t.value,s=1==t.state,l=s?e.ok:e.fail,h=e.resolve,u=e.reject,c=e.domain;try{l?(s||(2===t.rejection&&q(t),t.rejection=1),!0===l?n=a:(c&&c.enter(),n=l(a),c&&(c.exit(),r=!0)),n===e.promise?u(D("Promise-chain cycle")):(i=V(n))?o(i,n,h,u):h(n)):u(a)}catch(e){c&&!r&&c.exit(),u(e)}},G=function(e,t){e.notified||(e.notified=!0,y((function(){for(var n,i=e.reactions;n=i.get();)j(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===H&&x("Unhandled promise rejection",n)},X=function(e){o(v,s,(function(){var t,n=e.facade,i=e.value;if(Y(e)&&(t=b((function(){a?U.emit("unhandledRejection",i,n):W(H,n,i)})),e.rejection=a||Y(e)?2:1,t.error))throw t.value}))},Y=function(e){return 1!==e.rejection&&!e.parent},q=function(e){o(v,s,(function(){var t=e.facade;a?U.emit("rejectionHandled",t):W("rejectionhandled",t,e.value)}))},J=function(e,t,n){return function(i){e(t,i,n)}},Z=function(e,t,n){e.done||(e.done=!0,n&&(e=n),e.value=t,e.state=2,G(e,!0))},K=function(e,t,n){if(!e.done){e.done=!0,n&&(e=n);try{if(e.facade===t)throw D("Promise can't be resolved itself");var i=V(t);i?y((function(){var n={done:!1};try{o(i,t,J(K,n,e),J(Z,n,e))}catch(t){Z(n,t,e)}})):(e.value=t,e.state=1,G(e,!1))}catch(t){Z({done:!1},t,e)}}};if(A&&(O=(k=function(t){m(this,O),d(t),o(e,this);var n=R(this);try{t(J(K,n),J(Z,n))}catch(e){Z(n,e)}}).prototype,(e=function(e){L(this,{type:T,done:!1,notified:!1,parent:!1,reactions:new _,rejection:!1,state:0,value:void 0})}).prototype=l(O,"then",(function(e,t){var n=R(this),i=F(g(this,k));return n.parent=!0,i.ok=!p(e)||e,i.fail=p(t)&&t,i.domain=a?U.domain:void 0,0==n.state?n.reactions.add(i):y((function(){j(i,n)})),i.promise})),t=function(){var t=new e,n=R(t);this.promise=t,this.resolve=J(K,n),this.reject=J(Z,n)},E.f=F=function(e){return e===k||void 0===e?new t(e):B(e)},!r&&p(S)&&I!==Object.prototype)){n=I.then,P||l(I,"then",(function(e,t){var i=this;return new k((function(e,t){o(n,i,e,t)})).then(e,t)}),{unsafe:!0});try{delete I.constructor}catch(e){}h&&h(I,O)}i({global:!0,constructor:!0,wrap:!0,forced:A},{Promise:k}),u(k,T,!1,!0),c(T)})),Hy=J(((e,t)=>{var n=Dp(),i=fy(),r=qg().CONSTRUCTOR;t.exports=r||!i((function(e){n.all(e).then(void 0,(function(){}))}))})),fee=J((()=>{"use strict";var e=et(),t=vr(),n=os(),i=kd(),r=Gg(),a=hc();e({target:"Promise",stat:!0,forced:Hy()},{all:function(e){var s=this,o=i.f(s),l=o.resolve,h=o.reject,u=r((function(){var i=n(s.resolve),r=[],o=0,u=1;a(e,(function(e){var n=o++,a=!1;u++,t(i,s,e).then((function(e){a||(a=!0,r[n]=e,--u||l(r))}),h)})),--u||l(r)}));return u.error&&h(u.value),o.promise}})})),mee=J((()=>{"use strict";var e,t=et(),n=ls(),i=qg().CONSTRUCTOR,r=Dp(),a=Ui(),s=Lr(),o=Hi(),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}))})),gee=J((()=>{"use strict";var e=et(),t=vr(),n=os(),i=kd(),r=Gg(),a=hc();e({target:"Promise",stat:!0,forced:Hy()},{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}})})),vee=J((()=>{"use strict";var e=et(),t=vr(),n=kd();e({target:"Promise",stat:!0,forced:qg().CONSTRUCTOR},{reject:function(e){var i=n.f(this);return t(i.reject,void 0,e),i.promise}})})),vO=J(((e,t)=>{var n=yr(),i=Dr(),r=kd();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}})),Eee=J((()=>{"use strict";var e=et(),t=Ui(),n=ls(),i=Dp(),r=qg().CONSTRUCTOR,a=vO(),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)}})})),_ee=J((()=>{hee(),fee(),mee(),gee(),vee(),Eee()})),Tee=J((()=>{"use strict";var e=et(),t=vr(),n=os(),i=kd(),r=Gg(),a=hc();e({target:"Promise",stat:!0,forced:Hy()},{allSettled:function(e){var s=this,o=i.f(s),l=o.resolve,h=o.reject,u=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 u.error&&h(u.value),o.promise}})})),See=J((()=>{"use strict";var e=et(),t=vr(),n=os(),i=Ui(),r=kd(),a=Gg(),s=hc(),o=Hy(),l="No one promise resolved";e({target:"Promise",stat:!0,forced:o},{any:function(e){var o=this,h=i("AggregateError"),u=r.f(o),c=u.resolve,d=u.reject,p=a((function(){var i=n(o.resolve),r=[],a=0,u=1,p=!1;s(e,(function(e){var n=a++,s=!1;u++,t(i,o,e).then((function(e){s||p||(p=!0,c(e))}),(function(e){s||p||(s=!0,r[n]=e,--u||d(new h(r,l)))}))})),--u||d(new h(r,l))}));return p.error&&d(p.value),u.promise}})})),Cee=J((()=>{"use strict";var e,t=et(),n=ls(),i=Dp(),r=Yt(),a=Ui(),s=Lr(),o=Ap(),l=vO(),h=Hi(),u=i&&i.prototype;t({target:"Promise",proto:!0,real:!0,forced:!!i&&r((function(){u.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,u.finally!==e&&h(u,"finally",e,{unsafe:!0}))})),Pee=J((()=>{var e=et(),t=Fo(),n=os(),i=yr();e({target:"Reflect",stat:!0,forced:!Yt()((function(){Reflect.apply((function(){}))}))},{apply:function(e,r,a){return t(n(e),r,i(a))}})})),Nee=J((()=>{var e=et(),t=Ui(),n=Fo(),i=iD(),r=Cw(),a=yr(),s=Dr(),o=no(),l=Yt(),h=t("Reflect","construct"),u=Object.prototype,c=[].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(c,f,t),new(n(i,e,f))}var m=l.prototype,g=o(s(m)?m:u),v=n(e,g,t);return s(v)?v:g}})})),Hee=J((()=>{var e=et(),t=Kn(),n=yr(),i=lh(),r=qi();e({target:"Reflect",stat:!0,forced:Yt()((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}}})})),Vee=J((()=>{var e=et(),t=yr(),n=Qs().f;e({target:"Reflect",stat:!0},{deleteProperty:function(e,i){var r=n(t(e),i);return!(r&&!r.configurable)&&delete e[i]}})})),_O=J(((e,t)=>{var n=jr();t.exports=function(e){return void 0!==e&&(n(e,"value")||n(e,"writable"))}})),Wee=J((()=>{var e=et(),t=vr(),n=Dr(),i=yr(),r=_O(),a=Qs(),s=so();e({target:"Reflect",stat:!0},{get:function e(o,l){var h,u,c=arguments.length<3?o:arguments[2];return i(o)===c?o[l]:(h=a.f(o,l))?r(h)?h.value:void 0===h.get?void 0:t(h.get,c):n(u=s(o))?e(u,l,c):void 0}})})),jee=J((()=>{var e=et(),t=Kn(),n=yr(),i=Qs();e({target:"Reflect",stat:!0,sham:!t},{getOwnPropertyDescriptor:function(e,t){return i.f(n(e),t)}})})),Xee=J((()=>{var e=et(),t=yr(),n=so();e({target:"Reflect",stat:!0,sham:!nw()},{getPrototypeOf:function(e){return n(t(e))}})})),Yee=J((()=>{et()({target:"Reflect",stat:!0},{has:function(e,t){return t in e}})})),$ee=J((()=>{var e=et(),t=yr(),n=Dw();e({target:"Reflect",stat:!0},{isExtensible:function(e){return t(e),n(e)}})})),Zee=J((()=>{et()({target:"Reflect",stat:!0},{ownKeys:BT()})})),Kee=J((()=>{var e=et(),t=Ui(),n=yr();e({target:"Reflect",stat:!0,sham:!Cp()},{preventExtensions:function(e){n(e);try{var i=t("Object","preventExtensions");return i&&i(e),!0}catch(e){return!1}}})})),nte=J((()=>{var e=et(),t=vr(),n=yr(),i=Dr(),r=_O(),a=Yt(),s=qi(),o=Qs(),l=so(),h=Oo();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,u,c){var d,p,f,m=arguments.length<4?a:arguments[3],g=o.f(n(a),u);if(!g){if(i(p=l(a)))return e(p,u,c,m);g=h(0)}if(r(g)){if(!1===g.writable||!i(m))return!1;if(d=o.f(m,u)){if(d.get||d.set||!1===d.writable)return!1;d.value=c,s.f(m,u,d)}else s.f(m,u,h(0,c))}else{if(void 0===(f=g.set))return!1;t(f,m,c)}return!0}})})),ite=J((()=>{var e=et(),t=yr(),n=X3(),i=uc();i&&e({target:"Reflect",stat:!0},{setPrototypeOf:function(e,r){t(e),n(r);try{return i(e,r),!0}catch(e){return!1}}})})),ste=J((()=>{var e=et(),t=wn(),n=ro();e({global:!0},{Reflect:{}}),n(t.Reflect,"Reflect",!0)})),$g=J(((e,t)=>{var n=Dr(),i=ua(),r=Or()("match");t.exports=function(e){var t;return n(e)&&(void 0!==(t=e[r])?!!t:"RegExp"==i(e))}})),Qw=J(((e,t)=>{"use strict";var n=yr();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}})),Zg=J(((e,t)=>{var n=vr(),i=jr(),r=ko(),a=Qw(),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)}})),Vy=J(((e,t)=>{var n=Yt(),i=wn().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}})),eS=J(((e,t)=>{var n=Yt(),i=wn().RegExp;t.exports=n((function(){var e=i(".","s");return!(e.dotAll&&e.exec("\n")&&"s"===e.flags)}))})),AO=J(((e,t)=>{var n=Yt(),i=wn().RegExp;t.exports=n((function(){var e=i("(?<a>b)","g");return"b"!==e.exec("b").groups.a||"bc"!=="b".replace(e,"$<a>c")}))})),Ete=J((()=>{var e,t,n,i=Kn(),r=wn(),a=Jt(),s=Eg(),o=_p(),l=ha(),h=ch().f,u=ko(),c=$g(),d=ur(),p=Zg(),f=Vy(),m=Y3(),g=Hi(),v=Yt(),y=jr(),x=Es().enforce,b=Sp(),_=Or(),w=eS(),S=AO(),M=_("match"),E=r.RegExp,T=E.prototype,A=r.SyntaxError,C=a(T.exec),P=a("".charAt),R=a("".replace),L=a("".indexOf),I=a("".slice),k=/^\?<[^\s\d!#%&*+<=>@^][^\s!#%&*+<=>@^]*>/,O=/a/g,D=/a/g,N=new E(O)!==O,U=f.MISSED_STICKY,F=f.UNSUPPORTED_Y;if(s("RegExp",i&&(!N||U||w||S||v((function(){return D[M]=!1,E(O)!=O||E(D)==D||"/a/i"!=E(O,"i")}))))){for(e=function(t,n){var i,r,a,s,h,f,m=u(T,this),g=c(t),v=void 0===n,b=[],_=t;if(!m&&g&&v&&t.constructor===e)return t;if((g||u(T,t))&&(t=t.source,v&&(n=p(_))),t=void 0===t?"":d(t),n=void 0===n?"":d(n),_=t,w&&"dotAll"in O&&(r=!!n&&L(n,"s")>-1)&&(n=R(n,/s/g,"")),i=n,U&&"sticky"in O&&(a=!!n&&L(n,"y")>-1)&&F&&(n=R(n,/y/g,"")),S&&(s=function(e){for(var t,n=e.length,i=0,r="",a=[],s={},o=!1,l=!1,h=0,u="";i<=n;i++){if("\\"===(t=P(e,i)))t+=P(e,++i);else if("]"===t)o=!1;else if(!o)switch(!0){case"["===t:o=!0;break;case"("===t:C(k,I(e,i+1))&&(i+=2,l=!0),r+=t,h++;continue;case">"===t&&l:if(""===u||y(s,u))throw new A("Invalid capture group name");s[u]=!0,a[a.length]=[u,h],l=!1,u="";continue}l?u+=t:r+=t}return[r,a]}(t),t=s[0],b=s[1]),h=o(E(t,n),m?this:T,e),(r||a||b.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=P(e,i))?a||"."!==t?("["===t?a=!0:"]"===t&&(a=!1),r+=t):r+="[\\s\\S]":r+=t+P(e,++i);return r}(t),i)),a&&(f.sticky=!0),b.length&&(f.groups=b)),t!==_)try{l(h,"source",""===_?"(?:)":_)}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})}b("RegExp")})),Tte=J((()=>{var e=Kn(),t=eS(),n=ua(),i=Hs(),r=Es().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")}}})})),Gy=J(((e,t)=>{"use strict";var n,i,r=vr(),a=Jt(),s=ur(),o=Qw(),l=Vy(),h=pp(),u=no(),c=Es().get,d=eS(),p=AO(),f=h("native-string-replace",String.prototype.replace),m=RegExp.prototype.exec,g=m,v=a("".charAt),y=a("".indexOf),x=a("".replace),b=a("".slice),_=(i=/b*/g,r(m,n=/a/,"a"),r(m,i,"a"),0!==n.lastIndex||0!==i.lastIndex),w=l.BROKEN_CARET,S=void 0!==/()??/.exec("")[1];(_||S||w||d||p)&&(g=function(e){var t,n,i,a,l,h,d,p=this,M=c(p),E=s(e),T=M.raw;if(T)return T.lastIndex=p.lastIndex,t=r(g,T,E),p.lastIndex=T.lastIndex,t;var A=M.groups,C=w&&p.sticky,P=r(o,p),R=p.source,L=0,I=E;if(C&&(P=x(P,"y",""),-1===y(P,"g")&&(P+="g"),I=b(E,p.lastIndex),p.lastIndex>0&&(!p.multiline||p.multiline&&"\n"!==v(E,p.lastIndex-1))&&(R="(?: "+R+")",I=" "+I,L++),n=new RegExp("^(?:"+R+")",P)),S&&(n=new RegExp("^"+R+"$(?!\\s)",P)),_&&(i=p.lastIndex),a=r(m,C?n:p,I),C?a?(a.input=b(a.input,L),a[0]=b(a[0],L),a.index=p.lastIndex,p.lastIndex+=a[0].length):p.lastIndex=0:_&&a&&(p.lastIndex=p.global?a.index+a[0].length:i),S&&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=u(null),l=0;l<A.length;l++)h[(d=A[l])[0]]=a[d[1]];return a}),t.exports=g})),iS=J((()=>{"use strict";var e=et(),t=Gy();e({target:"RegExp",proto:!0,forced:/./.exec!==t},{exec:t})})),Cte=J((()=>{var e=wn(),t=Kn(),n=Hs(),i=Qw(),r=Yt(),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})})),Ite=J((()=>{var e=Kn(),t=Vy().MISSED_STICKY,n=ua(),i=Hs(),r=Es().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")}}})})),Ote=J((()=>{"use strict";iS();var e,t,n=et(),i=vr(),r=Lr(),a=yr(),s=ur(),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)}})})),Nte=J((()=>{"use strict";var e=gp().PROPER,t=Hi(),n=yr(),i=ur(),r=Yt(),a=Zg(),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})})),Bte=J((()=>{"use strict";wy()("Set",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),fD())})),Ute=J((()=>{Bte()})),Hte=J((()=>{"use strict";var e=et(),t=Jt(),n=as(),i=cs(),r=ur(),a=Yt(),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)}})})),qy=J(((e,t)=>{var n=Jt(),i=cs(),r=ur(),a=as(),s=n("".charAt),o=n("".charCodeAt),l=n("".slice),h=function(e){return function(t,n){var h,u,c=r(a(t)),d=i(n),p=c.length;return d<0||d>=p?e?"":void 0:(h=o(c,d))<55296||h>56319||d+1===p||(u=o(c,d+1))<56320||u>57343?e?s(c,d):h:e?l(c,d,d+2):u-56320+(h-55296<<10)+65536}};t.exports={codeAt:h(!1),charAt:h(!0)}})),qte=J((()=>{"use strict";var e=et(),t=qy().codeAt;e({target:"String",proto:!0},{codePointAt:function(e){return t(this,e)}})})),sS=J(((e,t)=>{var n=$g(),i=TypeError;t.exports=function(e){if(n(e))throw i("The method doesn't accept regular expressions");return e}})),aS=J(((e,t)=>{var n=Or()("match");t.exports=function(e){var t=/./;try{"/./"[e](t)}catch(i){try{return t[n]=!1,"/./"[e](t)}catch(e){}}return!1}})),Kte=J((()=>{"use strict";var e,t=et(),n=uh(),i=Qs().f,r=to(),a=ur(),s=sS(),o=as(),l=aS(),h=ls(),u=n("".endsWith),c=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 u?u(t,h,l):c(t,l-h.length,l)===h}})})),ene=J((()=>{var e=et(),t=Jt(),n=lc(),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,"")}})})),nne=J((()=>{"use strict";var e=et(),t=Jt(),n=sS(),i=as(),r=ur(),a=aS(),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)}})})),ine=J((()=>{"use strict";var e=et(),t=Jt(),n=as(),i=ur(),r=t("".charCodeAt);e({target:"String",proto:!0},{isWellFormed:function(){for(var e=i(n(this)),t=e.length,a=0;a<t;a++){var s=r(e,a);if(55296==(63488&s)&&(s>=56320||++a>=t||56320!=(64512&r(e,a))))return!1}return!0}})})),BO=J((()=>{"use strict";var e=qy().charAt,t=ur(),n=Es(),i=hw(),r=gy(),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))}))})),Wy=J(((e,t)=>{"use strict";iS();var n=uh(),i=Hi(),r=Gy(),a=Yt(),s=Or(),o=ha(),l=s("species"),h=RegExp.prototype;t.exports=function(e,t,u,c){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||u){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])}c&&o(h[d],"sham",!0)}})),jy=J(((e,t)=>{"use strict";var n=qy().charAt;t.exports=function(e,t,i){return t+(i?n(e,t).length:1)}})),Qg=J(((e,t)=>{var n=vr(),i=yr(),r=Lr(),a=ua(),s=Gy(),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")}})),vne=J((()=>{"use strict";var e=vr(),t=Wy(),n=yr(),i=Ca(),r=to(),a=ur(),s=as(),o=su(),l=jy(),h=Qg();t("match",(function(t,u,c){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=c(u,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}]}))})),Ane=J((()=>{"use strict";var e=et(),t=vr(),n=uh(),i=lw(),r=gy(),a=as(),s=to(),o=ur(),l=yr(),h=Ca(),u=ua(),c=$g(),d=Zg(),p=su(),f=Hi(),m=Yt(),g=Or(),v=Ap(),y=jy(),x=Qg(),b=Es(),_=ls(),w=g("matchAll"),S="RegExp String",M=S+" Iterator",E=b.set,T=b.getterFor(M),A=RegExp.prototype,C=TypeError,P=n("".indexOf),R=n("".matchAll),L=!!R&&!m((function(){R("a",/./)})),I=i((function(e,t,n,i){E(this,{type:M,regexp:e,string:t,global:n,unicode:i,done:!1})}),S,(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))})),k=function(e){var t,n,i,r=l(this),a=o(e),h=v(r,RegExp),u=o(d(r));return t=new h(h===RegExp?r.source:r,u),n=!!~P(u,"g"),i=!!~P(u,"u"),t.lastIndex=s(r.lastIndex),new I(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 R(l,e)}else{if(c(e)&&(n=o(a(d(e))),!~P(n,"g")))throw C("`.matchAll` does not allow non-global regexes");if(L)return R(l,e);if(void 0===(r=p(e,w))&&_&&"RegExp"==u(e)&&(r=k),r)return t(r,e,l)}return i=o(l),s=new RegExp(e,"g"),_?t(k,s,i):s[w](i)}}),_||w in A||f(A,w,k)})),WO=J(((e,t)=>{var n=ru();t.exports=/Version\/10(?:\.\d+){1,2}(?: [\w./]+)?(?: Mobile\/\w+)? Safari\//.test(n)})),Cne=J((()=>{"use strict";var e=et(),t=Pw().end;e({target:"String",proto:!0,forced:WO()},{padEnd:function(e){return t(this,e,arguments.length>1?arguments[1]:void 0)}})})),Pne=J((()=>{"use strict";var e=et(),t=Pw().start;e({target:"String",proto:!0,forced:WO()},{padStart:function(e){return t(this,e,arguments.length>1?arguments[1]:void 0)}})})),One=J((()=>{var e=et(),t=Jt(),n=Is(),i=oi(),r=ur(),a=ui(),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,u=[],c=0;;){if(s(u,r(t[c++])),c===l)return o(u,"");c<h&&s(u,r(arguments[c]))}}})})),kne=J((()=>{et()({target:"String",proto:!0},{repeat:_y()})})),$O=J(((e,t)=>{var n=Jt(),i=oi(),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,u,c,d){var p=n+e.length,f=u.length,m=h;return void 0!==c&&(c=i(c),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=c[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===u[d-1]?a(s,1):u[d-1]+a(s,1):i}l=u[h-1]}return void 0===l?"":l}))}})),Vne=J((()=>{"use strict";var e=Fo(),t=vr(),n=Jt(),i=Wy(),r=Yt(),a=yr(),s=Lr(),o=Ca(),l=cs(),h=to(),u=ur(),c=as(),d=jy(),p=su(),f=$O(),m=Qg(),g=Or()("replace"),v=Math.max,y=Math.min,x=n([].concat),b=n([].push),_=n("".indexOf),w=n("".slice),S=function(e){return void 0===e?e:String(e)},M="$0"==="a".replace(/./,"$0"),E=!!/./[g]&&""===/./[g]("a","$0");i("replace",(function(n,i,r){var M=E?"$":"$0";return[function(e,n){var r=c(this),a=o(e)?void 0:p(e,g);return a?t(a,e,r,n):t(i,u(r),e,n)},function(t,n){var o=a(this),c=u(t);if("string"==typeof n&&-1===_(n,M)&&-1===_(n,"$<")){var p=r(i,o,c,n);if(p.done)return p.value}var g=s(n);g||(n=u(n));var E=o.global;if(E){var T=o.unicode;o.lastIndex=0}for(var A=[];;){var C=m(o,c);if(null===C||(b(A,C),!E))break;""===u(C[0])&&(o.lastIndex=d(c,h(o.lastIndex),T))}for(var P="",R=0,L=0;L<A.length;L++){for(var I=u((C=A[L])[0]),k=v(y(l(C.index),c.length),0),O=[],D=1;D<C.length;D++)b(O,S(C[D]));var N=C.groups;if(g){var U=x([I],O,k,c);void 0!==N&&b(U,N);var F=u(e(n,void 0,U))}else F=f(I,c,k,O,N,n);k>=R&&(P+=w(c,R,k)+F,R=k+I.length)}return P+w(c,R)}]}),!!r((function(){var e=/./;return e.exec=function(){var e=[];return e.groups={a:"7"},e},"7"!=="".replace(e,"$<a>")}))||!M||E)})),jne=J((()=>{"use strict";var e=et(),t=vr(),n=Jt(),i=as(),r=Lr(),a=Ca(),s=$g(),o=ur(),l=su(),h=Zg(),u=$O(),c=Or(),d=ls(),p=c("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 c,b,_,w,S,M,E,T,A,C=i(this),P=0,R=0,L="";if(!a(e)){if((c=s(e))&&(b=o(i(h(e))),!~m(b,"g")))throw f("`.replaceAll` does not allow non-global regexes");if(_=l(e,p))return t(_,e,C,n);if(d&&c)return g(o(C),e,n)}for(w=o(C),S=o(e),(M=r(n))||(n=o(n)),E=S.length,T=y(1,E),P=x(w,S,0);-1!==P;)A=M?o(n(S,P,w)):u(S,w,P,[],void 0,n),L+=v(w,R,P)+A,R=P+E,P=x(w,S,P+T);return R<w.length&&(L+=v(w,R)),L}})})),$ne=J((()=>{"use strict";var e=vr(),t=Wy(),n=yr(),i=Ca(),r=as(),a=ND(),s=ur(),o=su(),l=Qg();t("search",(function(t,h,u){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=u(h,t,i);if(r.done)return r.value;var o=t.lastIndex;a(o,0)||(t.lastIndex=0);var c=l(t,i);return a(t.lastIndex,o)||(t.lastIndex=o),null===c?-1:c.index}]}))})),tre=J((()=>{"use strict";var e=Fo(),t=vr(),n=Jt(),i=Wy(),r=yr(),a=Ca(),s=$g(),o=as(),l=Ap(),h=jy(),u=to(),c=ur(),d=su(),p=Tg(),f=Qg(),m=Gy(),g=Vy(),v=Yt(),y=g.UNSUPPORTED_Y,x=4294967295,b=Math.min,_=[].push,w=n(/./.exec),S=n(_),M=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=c(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,u,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))&&!((u=y.lastIndex)>v&&(S(f,M(a,v,h.index)),h.length>1&&h.index<a.length&&e(_,f,p(h,1)),d=h[0].length,v=u,f.length>=l));)y.lastIndex===h.index&&y.lastIndex++;return v===a.length?(d||!w(y,""))&&S(f,""):S(f,M(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,c(r),e,i)},function(e,t){var n=r(this),a=c(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),_=void 0===t?x:t>>>0;if(0===_)return[];if(0===a.length)return null===f(m,a)?[a]:[];for(var w=0,E=0,T=[];E<a.length;){m.lastIndex=y?0:E;var A,C=f(m,y?M(a,E):a);if(null===C||(A=b(u(m.lastIndex+(y?E:0)),a.length))===w)E=h(a,E,d);else{if(S(T,M(a,w,E)),T.length===_)return T;for(var P=1;P<=C.length-1;P++)if(S(T,C[P]),T.length===_)return T;E=w=A}}return S(T,M(a,w)),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)})),are=J((()=>{"use strict";var e,t=et(),n=uh(),i=Qs().f,r=to(),a=ur(),s=sS(),o=as(),l=aS(),h=ls(),u=n("".startsWith),c=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 u?u(t,i,n):c(t,n,n+i.length)===i}})})),lre=J((()=>{"use strict";var e=et(),t=Jt(),n=as(),i=cs(),r=ur(),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,u=r(n(this)),c=u.length,d=i(e);return d===1/0&&(d=0),d<0&&(d=s(c+d,0)),(l=void 0===t?c:i(t))<=0||l===1/0||d>=(h=o(d+l,c))?"":a(u,d,h)}})})),dre=J((()=>{"use strict";var e=et(),t=vr(),n=Jt(),i=as(),r=ur(),a=Yt(),s=Array,o=n("".charAt),l=n("".charCodeAt),h=n([].join),u="".toWellFormed,c=u&&a((function(){return"1"!==t(u,1)}));e({target:"String",proto:!0,forced:c},{toWellFormed:function(){var e=r(i(this));if(c)return t(u,e);for(var n=e.length,a=s(n),d=0;d<n;d++){var p=l(e,d);55296!=(63488&p)?a[d]=o(e,d):p>=56320||d+1>=n||56320!=(64512&l(e,d+1))?a[d]="\ufffd":(a[d]=o(e,d),a[++d]=o(e,d))}return h(a,"")}})})),hS=J(((e,t)=>{var n=gp().PROPER,i=Yt(),r=Cy();t.exports=function(e){return i((function(){return!!r[e]()||"\u200b\x85\u180e"!=="\u200b\x85\u180e"[e]()||n&&r[e].name!==e}))}})),gre=J((()=>{"use strict";var e=et(),t=Pp().trim;e({target:"String",proto:!0,forced:hS()("trim")},{trim:function(){return t(this)}})})),ik=J(((e,t)=>{"use strict";var n=Pp().end,i=hS();t.exports=i("trimEnd")?function(){return n(this)}:"".trimEnd})),xre=J((()=>{var e=et(),t=ik();e({target:"String",proto:!0,name:"trimEnd",forced:"".trimRight!==t},{trimRight:t})})),Ere=J((()=>{xre();var e=et(),t=ik();e({target:"String",proto:!0,name:"trimEnd",forced:"".trimEnd!==t},{trimEnd:t})})),sk=J(((e,t)=>{"use strict";var n=Pp().start,i=hS();t.exports=i("trimStart")?function(){return n(this)}:"".trimStart})),wre=J((()=>{var e=et(),t=sk();e({target:"String",proto:!0,name:"trimStart",forced:"".trimLeft!==t},{trimLeft:t})})),Mre=J((()=>{wre();var e=et(),t=sk();e({target:"String",proto:!0,name:"trimStart",forced:"".trimStart!==t},{trimStart:t})})),oo=J(((e,t)=>{var n=Jt(),i=as(),r=ur(),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,""")+'"'),h+">"+l+"</"+t+">"}})),lo=J(((e,t)=>{var n=Yt();t.exports=function(e){return n((function(){var t=""[e]('"');return t!==t.toLowerCase()||t.split('"').length>3}))}})),Pre=J((()=>{"use strict";var e=et(),t=oo();e({target:"String",proto:!0,forced:lo()("anchor")},{anchor:function(e){return t(this,"a","name",e)}})})),Ire=J((()=>{"use strict";var e=et(),t=oo();e({target:"String",proto:!0,forced:lo()("big")},{big:function(){return t(this,"big","","")}})})),Lre=J((()=>{"use strict";var e=et(),t=oo();e({target:"String",proto:!0,forced:lo()("blink")},{blink:function(){return t(this,"blink","","")}})})),Dre=J((()=>{"use strict";var e=et(),t=oo();e({target:"String",proto:!0,forced:lo()("bold")},{bold:function(){return t(this,"b","","")}})})),Ore=J((()=>{"use strict";var e=et(),t=oo();e({target:"String",proto:!0,forced:lo()("fixed")},{fixed:function(){return t(this,"tt","","")}})})),kre=J((()=>{"use strict";var e=et(),t=oo();e({target:"String",proto:!0,forced:lo()("fontcolor")},{fontcolor:function(e){return t(this,"font","color",e)}})})),Fre=J((()=>{"use strict";var e=et(),t=oo();e({target:"String",proto:!0,forced:lo()("fontsize")},{fontsize:function(e){return t(this,"font","size",e)}})})),Nre=J((()=>{"use strict";var e=et(),t=oo();e({target:"String",proto:!0,forced:lo()("italics")},{italics:function(){return t(this,"i","","")}})})),Bre=J((()=>{"use strict";var e=et(),t=oo();e({target:"String",proto:!0,forced:lo()("link")},{link:function(e){return t(this,"a","href",e)}})})),Ure=J((()=>{"use strict";var e=et(),t=oo();e({target:"String",proto:!0,forced:lo()("small")},{small:function(){return t(this,"small","","")}})})),Hre=J((()=>{"use strict";var e=et(),t=oo();e({target:"String",proto:!0,forced:lo()("strike")},{strike:function(){return t(this,"strike","","")}})})),Vre=J((()=>{"use strict";var e=et(),t=oo();e({target:"String",proto:!0,forced:lo()("sub")},{sub:function(){return t(this,"sub","","")}})})),zre=J((()=>{"use strict";var e=et(),t=oo();e({target:"String",proto:!0,forced:lo()("sup")},{sup:function(){return t(this,"sup","","")}})})),dS=J(((e,t)=>{var n=wn(),i=Yt(),r=fy(),a=Mr().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}))})),jre=J(((e,t)=>{var n=cs(),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}})),ok=J(((e,t)=>{var n=jre(),i=RangeError;t.exports=function(e,t){var r=n(e);if(r%t)throw i("Wrong offset");return r}})),lk=J(((e,t)=>{var n=cc();t.exports=function(e){var t=n(e);return"BigInt64Array"==t||"BigUint64Array"==t}})),fS=J(((e,t)=>{var n=Z1(),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)}})),ck=J(((e,t)=>{var n=cl(),i=vr(),r=Cw(),a=oi(),s=ui(),o=uy(),l=Cg(),h=rw(),u=lk(),c=Mr().aTypedArrayConstructor,d=fS();t.exports=function(e){var t,p,f,m,g,v,y,x,b=r(this),_=a(e),w=arguments.length,S=w>1?arguments[1]:void 0,M=void 0!==S,E=l(_);if(E&&!h(E))for(x=(y=o(_,E)).next,_=[];!(v=i(x,y)).done;)_.push(v.value);for(M&&w>2&&(S=n(S,arguments[2])),p=s(_),f=new(c(b))(p),m=u(f),t=0;p>t;t++)g=M?S(_[t],t):_[t],f[t]=m?d(g):+g;return f}})),fu=J(((e,t)=>{"use strict";var n=et(),i=wn(),r=vr(),a=Kn(),s=dS(),o=Mr(),l=Ey(),h=dc(),u=Oo(),c=ha(),d=Hw(),p=to(),f=kL(),m=ok(),g=lh(),v=jr(),y=cc(),x=Dr(),b=Td(),_=no(),w=ko(),S=uc(),M=ch().f,E=ck(),T=Vs().forEach,A=Sp(),C=Hs(),P=qi(),R=Qs(),L=Es(),I=_p(),k=L.get,O=L.set,D=L.enforce,N=P.f,U=R.f,F=Math.round,B=i.RangeError,z=l.ArrayBuffer,H=z.prototype,V=l.DataView,j=o.NATIVE_ARRAY_BUFFER_VIEWS,G=o.TYPED_ARRAY_TAG,W=o.TypedArray,X=o.TypedArrayPrototype,Y=o.aTypedArrayConstructor,q=o.isTypedArray,J="BYTES_PER_ELEMENT",Z="Wrong length",K=function(e,t){Y(e);for(var n=0,i=t.length,r=new e(i);i>n;)r[n]=t[n++];return r},$=function(e,t){C(e,t,{configurable:!0,get:function(){return k(this)[t]}})},Q=function(e){var t;return w(H,e)||"ArrayBuffer"==(t=y(e))||"SharedArrayBuffer"==t},ee=function(e,t){return q(e)&&!b(t)&&t in e&&d(+t)&&t>=0},te=function(e,t){return t=g(t),ee(e,t)?u(2,e[t]):U(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?(j||(R.f=te,P.f=ne,$(X,"buffer"),$(X,"byteOffset"),$(X,"byteLength"),$(X,"length")),n({target:"Object",stat:!0,forced:!j},{getOwnPropertyDescriptor:te,defineProperty:ne}),t.exports=function(e,t,a){var o=e.match(/\d+/)[0]/8,l=e+(a?"Clamped":"")+"Array",u="get"+e,d="set"+e,g=i[l],v=g,y=v&&v.prototype,b={},w=function(e,t){N(e,t,{get:function(){return function(e,t){var n=k(e);return n.view[u](t*o+n.byteOffset,!0)}(this,t)},set:function(e){return function(e,t,n){var i=k(e);a&&(n=(n=F(n))<0?0:n>255?255:255&n),i.view[d](t*o+i.byteOffset,n,!0)}(this,t,e)},enumerable:!0})};j?s&&(v=t((function(e,t,n,i){return h(e,y),I(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):q(t)?K(v,t):r(E,v,t):new g(f(t)),e,v)})),S&&S(v,W),T(M(g),(function(e){e in v||c(v,e,g[e])})),v.prototype=y):(v=t((function(e,t,n,i){h(e,y);var a,s,l,u=0,c=0;if(x(t)){if(!Q(t))return q(t)?K(v,t):r(E,v,t);a=t,c=m(n,o);var d=t.byteLength;if(void 0===i){if(d%o||(s=d-c)<0)throw B(Z)}else if((s=p(i)*o)+c>d)throw B(Z);l=s/o}else l=f(t),a=new z(s=l*o);for(O(e,{buffer:a,byteOffset:c,byteLength:s,length:l,view:new V(a)});u<l;)w(e,u++)})),S&&S(v,W),y=v.prototype=_(X)),y.constructor!==v&&c(y,"constructor",v),D(y).TypedArrayConstructor=v,G&&c(y,G,l);var C=v!=g;b[l]=v,n({global:!0,constructor:!0,forced:C,sham:!j},b),J in v||c(v,J,o),J in y||c(y,J,o),A(l)}):t.exports=function(){}})),gie=J((()=>{fu()("Float32",(function(e){return function(t,n,i){return e(this,t,n,i)}}))})),vie=J((()=>{fu()("Float64",(function(e){return function(t,n,i){return e(this,t,n,i)}}))})),yie=J((()=>{fu()("Int8",(function(e){return function(t,n,i){return e(this,t,n,i)}}))})),xie=J((()=>{fu()("Int16",(function(e){return function(t,n,i){return e(this,t,n,i)}}))})),bie=J((()=>{fu()("Int32",(function(e){return function(t,n,i){return e(this,t,n,i)}}))})),Eie=J((()=>{fu()("Uint8",(function(e){return function(t,n,i){return e(this,t,n,i)}}))})),_ie=J((()=>{fu()("Uint8",(function(e){return function(t,n,i){return e(this,t,n,i)}}),!0)})),Tie=J((()=>{fu()("Uint16",(function(e){return function(t,n,i){return e(this,t,n,i)}}))})),wie=J((()=>{fu()("Uint32",(function(e){return function(t,n,i){return e(this,t,n,i)}}))})),Mie=J((()=>{"use strict";var e=Mr(),t=ui(),n=cs(),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]}))})),Rie=J((()=>{"use strict";var e=Jt(),t=Mr(),n=e(hL()),i=t.aTypedArray;(0,t.exportTypedArrayMethod)("copyWithin",(function(e,t){return n(i(this),e,t,arguments.length>2?arguments[2]:void 0)}))})),Pie=J((()=>{"use strict";var e=Mr(),t=Vs().every,n=e.aTypedArray;(0,e.exportTypedArrayMethod)("every",(function(e){return t(n(this),e,arguments.length>1?arguments[1]:void 0)}))})),Lie=J((()=>{"use strict";var e=Mr(),t=ow(),n=fS(),i=cc(),r=vr(),a=Jt(),s=Yt(),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})))})),Qy=J(((e,t)=>{var n=Mr(),i=Ap(),r=n.aTypedArrayConstructor,a=n.getTypedArrayConstructor;t.exports=function(e){return r(i(e,a(e)))}})),Fie=J(((e,t)=>{var n=gw(),i=Qy();t.exports=function(e,t){return n(i(e),t)}})),Bie=J((()=>{"use strict";var e=Mr(),t=Vs().filter,n=Fie(),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)}))})),Hie=J((()=>{"use strict";var e=Mr(),t=Vs().find,n=e.aTypedArray;(0,e.exportTypedArrayMethod)("find",(function(e){return t(n(this),e,arguments.length>1?arguments[1]:void 0)}))})),zie=J((()=>{"use strict";var e=Mr(),t=Vs().findIndex,n=e.aTypedArray;(0,e.exportTypedArrayMethod)("findIndex",(function(e){return t(n(this),e,arguments.length>1?arguments[1]:void 0)}))})),qie=J((()=>{"use strict";var e=Mr(),t=dy().findLast,n=e.aTypedArray;(0,e.exportTypedArrayMethod)("findLast",(function(e){return t(n(this),e,arguments.length>1?arguments[1]:void 0)}))})),jie=J((()=>{"use strict";var e=Mr(),t=dy().findLastIndex,n=e.aTypedArray;(0,e.exportTypedArrayMethod)("findLastIndex",(function(e){return t(n(this),e,arguments.length>1?arguments[1]:void 0)}))})),Yie=J((()=>{"use strict";var e=Mr(),t=Vs().forEach,n=e.aTypedArray;(0,e.exportTypedArrayMethod)("forEach",(function(e){t(n(this),e,arguments.length>1?arguments[1]:void 0)}))})),$ie=J((()=>{"use strict";var e=dS();(0,Mr().exportTypedArrayStaticMethod)("from",ck(),e)})),Kie=J((()=>{"use strict";var e=Mr(),t=bg().includes,n=e.aTypedArray;(0,e.exportTypedArrayMethod)("includes",(function(e){return t(n(this),e,arguments.length>1?arguments[1]:void 0)}))})),Qie=J((()=>{"use strict";var e=Mr(),t=bg().indexOf,n=e.aTypedArray;(0,e.exportTypedArrayMethod)("indexOf",(function(e){return t(n(this),e,arguments.length>1?arguments[1]:void 0)}))})),ise=J((()=>{"use strict";var e=wn(),t=Yt(),n=Jt(),i=Mr(),r=vy(),a=Or()("iterator"),s=e.Uint8Array,o=n(r.values),l=n(r.keys),h=n(r.entries),u=i.aTypedArray,c=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(u(this))};c("entries",(function(){return h(u(this))}),p),c("keys",(function(){return l(u(this))}),p),c("values",m,p||!f,{name:"values"}),c(a,m,p||!f,{name:"values"})})),ase=J((()=>{"use strict";var e=Mr(),t=Jt(),n=e.aTypedArray,i=e.exportTypedArrayMethod,r=t([].join);i("join",(function(e){return r(n(this),e)}))})),lse=J((()=>{"use strict";var e=Mr(),t=Fo(),n=ML(),i=e.aTypedArray;(0,e.exportTypedArrayMethod)("lastIndexOf",(function(e){var r=arguments.length;return t(n,i(this),r>1?[e,arguments[1]]:[e])}))})),use=J((()=>{"use strict";var e=Mr(),t=Vs().map,n=Qy(),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)}))}))})),dse=J((()=>{"use strict";var e=Mr(),t=dS(),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)})),pse=J((()=>{"use strict";var e=Mr(),t=yy().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)}))})),gse=J((()=>{"use strict";var e=Mr(),t=yy().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)}))})),yse=J((()=>{"use strict";var e=Mr(),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}))})),wse=J((()=>{"use strict";var e=wn(),t=vr(),n=Mr(),i=ui(),r=ok(),a=oi(),s=Yt(),o=e.RangeError,l=e.Int8Array,h=l&&l.prototype,u=h&&h.set,c=n.aTypedArray,d=n.exportTypedArrayMethod,p=!s((function(){var e=new Uint8ClampedArray(2);return t(u,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){c(this);var n=r(arguments.length>1?arguments[1]:void 0,1),s=a(e);if(p)return t(u,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)})),Mse=J((()=>{"use strict";var e=Mr(),t=Qy(),n=Yt(),i=Md(),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()})))})),Rse=J((()=>{"use strict";var e=Mr(),t=Vs().some,n=e.aTypedArray;(0,e.exportTypedArrayMethod)("some",(function(e){return t(n(this),e,arguments.length>1?arguments[1]:void 0)}))})),Ose=J((()=>{"use strict";var e=wn(),t=uh(),n=Yt(),i=os(),r=pw(),a=Mr(),s=CL(),o=PL(),l=iu(),h=mw(),u=a.aTypedArray,c=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}));c("sort",(function(e){return void 0!==e&&i(e),m?p(this,e):r(u(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)})),Nse=J((()=>{"use strict";var e=Mr(),t=to(),n=lc(),i=Qy(),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))}))})),zse=J((()=>{"use strict";var e=wn(),t=Fo(),n=Mr(),i=Yt(),r=Md(),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])})))})),Gse=J((()=>{"use strict";var e=DL(),t=Mr(),n=t.aTypedArray,i=t.exportTypedArrayMethod,r=t.getTypedArrayConstructor;i("toReversed",(function(){return e(n(this),r(this))}))})),qse=J((()=>{"use strict";var e=Mr(),t=Jt(),n=os(),i=gw(),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)}))})),jse=J((()=>{"use strict";var e=Mr().exportTypedArrayMethod,t=Yt(),n=wn(),i=Jt(),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)})),Xse=J((()=>{"use strict";var e=OL(),t=Mr(),n=lk(),i=cs(),r=fS(),a=t.aTypedArray,s=t.getTypedArrayConstructor;(0,t.exportTypedArrayMethod)("with",(function(t,o){var l=a(this),h=i(t),u=n(l)?r(o):+o;return e(l,s(l),h,u)}),!function(){try{new Int8Array(1).with(2,{valueOf:function(){throw 8}})}catch(e){return 8===e}}())})),Jse=J((()=>{"use strict";var e=et(),t=Jt(),n=ur(),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,u=n(e),c="",d=u.length,p=0;p<d;){if("%"===(t=r(u,p++)))if("u"===r(u,p)){if(h=s(u,p+1,p+5),a(l,h)){c+=i(parseInt(h,16)),p+=5;continue}}else if(h=s(u,p,p+2),a(o,h)){c+=i(parseInt(h,16)),p+=2;continue}c+=t}return c}})})),Lk=J(((e,t)=>{"use strict";var n=Jt(),i=Lg(),r=Od().getWeakData,a=dc(),s=yr(),o=Ca(),l=Dr(),h=hc(),u=Vs(),c=jr(),d=Es(),p=d.set,f=d.getterFor,m=u.find,g=u.findIndex,v=n([].splice),y=0,x=function(e){return e.frozen||(e.frozen=new b)},b=function(){this.entries=[]},_=function(e,t){return m(e.entries,(function(e){return e[0]===t}))};b.prototype={get:function(e){var t=_(this,e);if(t)return t[1]},has:function(e){return!!_(this,e)},set:function(e,t){var n=_(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,u){var d=e((function(e,i){a(e,m),p(e,{type:t,id:y++,frozen:void 0}),o(i)||h(i,e[u],{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&&c(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&&c(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}}})),pae=J((()=>{"use strict";var e,t,n,i,r=Cp(),a=wn(),s=Jt(),o=Lg(),l=Od(),h=wy(),u=Lk(),c=Dr(),d=Es().enforce,p=Yt(),f=f3(),m=Object,g=Array.isArray,v=m.isExtensible,y=m.isFrozen,x=m.isSealed,b=m.freeze,_=m.seal,w={},S={},M=!a.ActiveXObject&&"ActiveXObject"in a,E=function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}},T=h("WeakMap",E,u),A=T.prototype,C=s(A.set);f&&(M?(e=u.getConstructor(E,"WeakMap",!0),l.enable(),t=s(A.delete),n=s(A.has),i=s(A.get),o(A,{delete:function(n){if(c(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(c(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(c(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(c(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=b([]);return C(new T,e,1),!y(e)}))&&o(A,{set:function(e,t){var n;return g(e)&&(y(e)?n=w:x(e)&&(n=S)),C(this,e,t),n==w&&b(e),n==S&&_(e),this}}))})),mae=J((()=>{pae()})),gae=J((()=>{"use strict";wy()("WeakSet",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),Lk())})),vae=J((()=>{gae()})),kk=J(((e,t)=>{var n,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",r={};for(n=0;n<66;n++)r[i.charAt(n)]=n;t.exports={itoc:i,ctoi:r}})),Mae=J((()=>{var e=et(),t=wn(),n=Ui(),i=Jt(),r=vr(),a=Yt(),s=ur(),o=jr(),l=dl(),h=kk().ctoi,u=/[^\d+/a-z]/i,c=/[\t\n\f\r ]+/g,d=/[=]{1,2}$/,p=n("atob"),f=String.fromCharCode,m=i("".charAt),g=i("".replace),v=i(u.exec),y=a((function(){return""!==p(" ")})),x=!a((function(){p("a")})),b=!y&&!x&&!a((function(){p()})),_=!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),c,""),x="",w=0,S=0;if(y.length%4==0&&(y=g(y,d,"")),y.length%4==1||v(u,y))throw new(n("DOMException"))("The string is not correctly encoded","InvalidCharacterError");for(;i=m(y,w++);)o(h,i)&&(a=S%4?64*a+h[i]:h[i],S++%4&&(x+=f(255&a>>(-2*S&6))));return x}})})),kae=J((()=>{var e=et(),t=wn(),n=Ui(),i=Jt(),r=vr(),a=Yt(),s=ur(),o=dl(),l=kk().itoc,h=n("btoa"),u=i("".charAt),c=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;u(m,v)||(y="=",v%1);){if((a=c(m,v+=3/4))>255)throw new(n("DOMException"))("The string contains characters outside of the Latin1 range","InvalidCharacterError");g+=u(y,63&(i=i<<8|a)>>8-v%1*8)}return g}})})),Vk=J(((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}})),Gk=J(((e,t)=>{var n=K1()("span").classList,i=n&&n.constructor&&n.constructor.prototype;t.exports=i===Object.prototype?void 0:i})),zae=J((()=>{var e,t=wn(),n=Vk(),i=Gk(),r=mL(),a=ha(),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)})),Yae=J((()=>{var e,t=wn(),n=Vk(),i=Gk(),r=vy(),a=ha(),s=Or(),o=s("iterator"),l=s("toStringTag"),h=r.values,u=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)u(t[e]&&t[e].prototype,e);u(i,"DOMTokenList")})),Zae=J(((e,t)=>{var n=cu();t.exports=function(e){try{if(n)return Function('return require("'+e+'")')()}catch(e){}}})),Yk=J(((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}}})),loe=J((()=>{"use strict";var e=et(),t=Zae(),n=Ui(),i=Yt(),r=no(),a=Oo(),s=qi().f,o=Hi(),l=Hs(),h=jr(),u=dc(),c=yr(),d=tL(),p=Ag(),f=Yk(),m=QT(),g=Es(),v=Kn(),y=ls(),x="DOMException",b="DATA_CLONE_ERR",_=n("Error"),w=n(x)||function(){try{(new(n("MessageChannel")||t("worker_threads").MessageChannel)).port1.postMessage(new WeakMap)}catch(e){if(e.name==b&&25==e.code)return e.constructor}}(),S=w&&w.prototype,M=_.prototype,E=g.set,T=g.getterFor(x),A="stack"in _(x),C=function(e){return h(f,e)&&f[e].m?f[e].c:0},P=function(){u(this,R);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=_(t);r.name=x,s(this,"stack",a(1,m(r.stack,1)))}},R=P.prototype=r(M),L=function(e){return{enumerable:!0,configurable:!0,get:e}},I=function(e){return L((function(){return T(this)[e]}))};v&&(l(R,"code",I("code")),l(R,"message",I("message")),l(R,"name",I("name"))),s(R,"constructor",a(1,P));var k=i((function(){return!(new w instanceof _)})),O=k||i((function(){return M.toString!==d||"2: 1"!==String(new w(1,2))})),D=k||i((function(){return 25!==new w(1,"DataCloneError").code})),N=k||25!==w[b]||25!==S[b],U=y?O||D||N:k;e({global:!0,constructor:!0,forced:U},{DOMException:U?P:w});var F,B,z,H,V=n(x),j=V.prototype;for(H in O&&(y||w===V)&&o(j,"toString",d),D&&v&&w===V&&l(j,"code",L((function(){return C(c(this).name)}))),f)h(f,H)&&(B=(F=f[H]).s,z=a(6,F.c),h(V,B)||s(V,B,z),h(j,B)||s(j,B,z))})),moe=J((()=>{"use strict";var e=et(),t=wn(),n=Ui(),i=Oo(),r=qi().f,a=jr(),s=dc(),o=_p(),l=Ag(),h=Yk(),u=QT(),c=Kn(),d=ls(),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,u(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),b=m&&c&&Object.getOwnPropertyDescriptor(t,p),_=!(!b||b.writable&&b.configurable),w=y&&!_&&!x;e({global:!0,constructor:!0,forced:d||w},{DOMException:w?g:m});var S,M,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,M=(S=h[E]).s)||r(T,M,i(6,S.c)))})),voe=J((()=>{var e=Ui(),t="DOMException";ro()(e(t),t)})),xoe=J((()=>{var e=et(),t=wn(),n=Fy().clear;e({global:!0,bind:!0,enumerable:!0,forced:t.clearImmediate!==n},{clearImmediate:n})})),Eoe=J(((e,t)=>{t.exports="function"==typeof Bun&&Bun&&"string"==typeof Bun.version})),US=J(((e,t)=>{"use strict";var n,i=wn(),r=Fo(),a=Lr(),s=Eoe(),o=ru(),l=Md(),h=dl(),u=i.Function,c=/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 c?function(i,s){var o=h(arguments.length,1)>n,c=a(i)?i:u(i),d=o?l(arguments,n):[],p=o?function(){r(c,this,d)}:c;return t?e(p,s):e(p)}:e}})),Aoe=J((()=>{var e=et(),t=wn(),n=Fy().set,i=US(),r=t.setImmediate?i(n,!1):n;e({global:!0,bind:!0,enumerable:!0,forced:t.setImmediate!==r},{setImmediate:r})})),Roe=J((()=>{xoe(),Aoe()})),Coe=J((()=>{var e=et(),t=wn(),n=rO(),i=os(),r=dl(),a=cu(),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)}})})),Ioe=J((()=>{"use strict";var e,t=et(),n=wn(),i=Hs(),r=Kn(),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){}})),Doe=J(((e,t)=>{var n=Jt(),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}})),koe=J(((e,t)=>{var n=Jt(),i=Set.prototype;t.exports={Set:Set,add:n(i.add),has:n(i.has),remove:n(i.delete),proto:i}})),Boe=J(((e,t)=>{var n=wn(),i=Yt(),r=iu(),a=iO(),s=Ww(),o=cu(),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}))})),Joe=J((()=>{var e,t=ls(),n=et(),i=wn(),r=Ui(),a=Jt(),s=Yt(),o=mp(),l=Lr(),h=yp(),u=Ca(),c=Dr(),d=Td(),p=hc(),f=yr(),m=cc(),g=jr(),v=au(),y=ha(),x=ui(),b=dl(),_=Zg(),w=Doe(),S=koe(),M=Z3(),E=Boe(),T=i.Object,A=i.Array,C=i.Date,P=i.Error,R=i.EvalError,L=i.RangeError,I=i.ReferenceError,k=i.SyntaxError,O=i.TypeError,D=i.URIError,N=i.PerformanceMark,U=i.WebAssembly,F=U&&U.CompileError||P,B=U&&U.LinkError||P,z=U&&U.RuntimeError||P,H=r("DOMException"),V=w.Map,j=w.has,G=w.get,W=w.set,X=S.Set,Y=S.add,q=r("Object","keys"),J=a([].push),Z=a((!0).valueOf),K=a(1..valueOf),$=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,P)||!re(ae,H)||(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 H("Uncloneable type: "+e,te)},ue=function(e,t){throw new H((t||"Cloning")+" of "+e+" cannot be properly polyfilled in this engine",te)},ce=function(e,t){return le||ue(t),le(e)},de=function(e,t,n){if(j(t,e))return G(t,e);var r,a,s,o,l,h;if("SharedArrayBuffer"===(n||m(e)))r=le?le(e):e;else{var u=i.DataView;!u&&"function"!=typeof e.slice&&ue("ArrayBuffer");try{if("function"!=typeof e.slice||e.resizable)for((a=e.byteLength,s="maxByteLength"in e?{maxByteLength:e.maxByteLength}:void 0,r=new ArrayBuffer(a,s),o=new u(e),l=new u(r),h=0);h<a;h++)l.setUint8(h,o.getUint8(h));else r=e.slice(0)}catch(e){throw new H("ArrayBuffer is detached",te)}}return W(t,e,r),r},pe=function(e,t,n,r,a){var s=i[t];return c(s)||ue(t),new s(de(e.buffer,a),n,r)},fe=function(e,t,n){this.object=e,this.type=t,this.metadata=n},me=function(e,t,n){if(d(e)&&he("Symbol"),!c(e))return e;if(t){if(j(t,e))return G(t,e)}else t=new V;var a,s,o,h,u,p,f,b,w=m(e);switch(w){case"Array":o=A(x(e));break;case"Object":o={};break;case"Map":o=new V;break;case"Set":o=new X;break;case"RegExp":o=new RegExp(e.source,_(e));break;case"Error":switch(s=e.name){case"AggregateError":o=r("AggregateError")([]);break;case"EvalError":o=R();break;case"RangeError":o=L();break;case"ReferenceError":o=I();break;case"SyntaxError":o=k();break;case"TypeError":o=O();break;case"URIError":o=D();break;case"CompileError":o=F();break;case"LinkError":o=B();break;case"RuntimeError":o=z();break;default:o=P()}break;case"DOMException":o=new H(e.message,e.name);break;case"ArrayBuffer":case"SharedArrayBuffer":o=n?new fe(e,w):de(e,t,w);break;case"DataView":case"Int8Array":case"Uint8Array":case"Uint8ClampedArray":case"Int16Array":case"Uint16Array":case"Int32Array":case"Uint32Array":case"Float16Array":case"Float32Array":case"Float64Array":case"BigInt64Array":case"BigUint64Array":p="DataView"===w?e.byteLength:e.length,o=n?new fe(e,w,{offset:e.byteOffset,length:p}):pe(e,w,e.byteOffset,p,t);break;case"DOMQuad":try{o=new DOMQuad(me(e.p1,t,n),me(e.p2,t,n),me(e.p3,t,n),me(e.p4,t,n))}catch(t){o=ce(e,w)}break;case"File":if(le)try{o=le(e),m(o)!==w&&(o=void 0)}catch(e){}if(!o)try{o=new File([e],e.name,e)}catch(e){}o||ue(w);break;case"FileList":if(h=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}(),h){for(u=0,p=x(e);u<p;u++)h.items.add(me(e[u],t,n));o=h.files}else o=ce(e,w);break;case"ImageData":try{o=new ImageData(me(e.data,t,n),e.width,e.height,{colorSpace:e.colorSpace})}catch(t){o=ce(e,w)}break;default:if(le)o=le(e);else switch(w){case"BigInt":o=T(e.valueOf());break;case"Boolean":o=T(Z(e));break;case"Number":o=T(K(e));break;case"String":o=T($(e));break;case"Date":o=new C(Q(e));break;case"Blob":try{o=e.slice(0,e.size,e.type)}catch(e){ue(w)}break;case"DOMPoint":case"DOMPointReadOnly":a=i[w];try{o=a.fromPoint?a.fromPoint(e):new a(e.x,e.y,e.z,e.w)}catch(e){ue(w)}break;case"DOMRect":case"DOMRectReadOnly":a=i[w];try{o=a.fromRect?a.fromRect(e):new a(e.x,e.y,e.width,e.height)}catch(e){ue(w)}break;case"DOMMatrix":case"DOMMatrixReadOnly":a=i[w];try{o=a.fromMatrix?a.fromMatrix(e):new a(e)}catch(e){ue(w)}break;case"AudioData":case"VideoFrame":l(e.clone)||ue(w);try{o=e.clone()}catch(e){he(w)}break;case"CropTarget":case"CryptoKey":case"FileSystemDirectoryHandle":case"FileSystemFileHandle":case"FileSystemHandle":case"GPUCompilationInfo":case"GPUCompilationMessage":case"ImageBitmap":case"RTCCertificate":case"WebAssembly.Module":ue(w);default:he(w)}}switch(W(t,e,o),w){case"Array":case"Object":for(f=q(e),u=0,p=x(f);u<p;u++)b=f[u],v(o,b,me(e[b],t,n));break;case"Map":e.forEach((function(e,i){W(o,me(i,t,n),me(e,t,n))}));break;case"Set":e.forEach((function(e){Y(o,me(e,t,n))}));break;case"Error":y(o,"message",me(e.message,t,n)),g(e,"cause")&&y(o,"cause",me(e.cause,t,n)),"AggregateError"==s&&(o.errors=me(e.errors,t,n));case"DOMException":M&&y(o,"stack",me(e.stack,t,n))}return o},ge=function(e,t){if(!c(e))return e;if(j(t,e))return G(t,e);var n,i,r,a,s,o,l,h;if(e instanceof fe)switch(n=e.type,i=e.object,n){case"ArrayBuffer":case"SharedArrayBuffer":h=de(i,t,n);break;case"DataView":case"Int8Array":case"Uint8Array":case"Uint8ClampedArray":case"Int16Array":case"Uint16Array":case"Int32Array":case"Uint32Array":case"Float16Array":case"Float32Array":case"Float64Array":case"BigInt64Array":case"BigUint64Array":r=e.metadata,h=pe(i,n,r.offset,r.length,t)}else switch(m(e)){case"Array":case"Object":for(o=q(e),a=0,s=x(o);a<s;a++)e[l=o[a]]=ge(e[l],t);break;case"Map":h=new V,e.forEach((function(e,n){W(h,ge(n,t),ge(e,t))}));break;case"Set":h=new X,e.forEach((function(e){Y(h,ge(e,t))}));break;case"Error":e.message=ge(e.message,t),g(e,"cause")&&(e.cause=ge(e.cause,t)),"AggregateError"==e.name&&(e.errors=ge(e.errors,t));case"DOMException":M&&(e.stack=ge(e.stack,t))}return W(t,e,h||e),h||e};n({global:!0,enumerable:!0,sham:!E,forced:se},{structuredClone:function(e){var t,n,r=b(arguments.length,1)>1&&!u(arguments[1])?f(arguments[1]):void 0,a=r?r.transfer:void 0,s=!1;void 0!==a&&(n=function(e,t){if(!c(e))throw O("Transfer option cannot be converted to a sequence");var n=[];p(e,(function(e){J(n,f(e))}));for(var r,a,s,o,u,d=0,g=x(n),v=[];d<g;)if(r=n[d++],"ArrayBuffer"!==(a=m(r))){if(j(t,r))throw new H("Duplicate transferable",te);if(E)o=ae(r,{transfer:[r]});else switch(a){case"ImageBitmap":s=i.OffscreenCanvas,h(s)||ue(a,ne);try{(u=new s(r.width,r.height)).getContext("bitmaprenderer").transferFromImageBitmap(r),o=u.transferToImageBitmap()}catch(e){}break;case"AudioData":case"VideoFrame":(!l(r.clone)||!l(r.close))&&ue(a,ne);try{o=r.clone(),r.close()}catch(e){}break;case"MediaSourceHandle":case"MessagePort":case"OffscreenCanvas":case"ReadableStream":case"TransformStream":case"WritableStream":ue(a,ne)}if(void 0===o)throw new H("This object cannot be transferred: "+a,te);W(t,r,o)}else J(v,r);return v}(a,t=new V),s=!!x(n));var o=me(e,t,s);return s&&(function(e,t){for(var n,i,r=0,a=x(e);r<a;){if(n=e[r++],j(t,n))throw new H("Duplicate transferable",te);E?i=ae(n,{transfer:[n]}):(l(n.transfer)||ue("ArrayBuffer",ne),i=n.transfer()),W(t,n,i)}}(a,t=new V),o=ge(o,t)),o}})})),tle=J((()=>{var e=et(),t=wn(),n=US()(t.setInterval,!0);e({global:!0,bind:!0,forced:t.setInterval!==n},{setInterval:n})})),ile=J((()=>{var e=et(),t=wn(),n=US()(t.setTimeout,!0);e({global:!0,bind:!0,forced:t.setTimeout!==n},{setTimeout:n})})),sle=J((()=>{tle(),ile()})),XS=J(((e,t)=>{var n=Yt(),i=Or(),r=Kn(),a=ls(),s=i("iterator");t.exports=!n((function(){var e=new URL("b?a=1&b=2&c=3","http://a"),t=e.searchParams,n=new URLSearchParams("a=1&a=2"),i="";return e.pathname="c%20d",t.forEach((function(e,n){t.delete("b"),i+=n+e})),n.delete("a",2),a&&(!e.toJSON||!n.has("a",1)||n.has("a",2))||!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"!==i||"x"!==new URL("http://x",void 0).host}))})),gle=J(((e,t)=>{var n=Jt(),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,u=String.fromCharCode,c=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=c(e,n++);if(r>=55296&&r<=56319&&n<i){var a=c(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,u(r));var g=t.length,x=g;for(g&&p(t,"-");x<a;){var b=i;for(n=0;n<e.length;n++)(r=e[n])>=l&&r<b&&(b=r);var _=x+1;if(b-l>h((i-f)/_))throw o(s);for(f+=(b-l)*_,l=b,n=0;n<e.length;n++){if((r=e[n])<l&&++f>i)throw o(s);if(r==l){for(var w=f,S=36;;){var M=S<=m?1:S>=m+26?26:S-m;if(w<M)break;var E=w-M,T=36-M;p(t,u(v(M+E%T))),w=h(E/T),S+=36}p(t,u(v(w))),m=y(f,_,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,".")}})),BF=J(((e,t)=>{"use strict";vy();var n=et(),i=wn(),r=vr(),a=Jt(),s=Kn(),o=XS(),l=Hi(),h=Hs(),u=Lg(),c=ro(),d=lw(),p=Es(),f=dc(),m=Lr(),g=jr(),v=cl(),y=cc(),x=yr(),b=Dr(),_=ur(),w=no(),S=Oo(),M=uy(),E=Cg(),T=dl(),A=Or(),C=pw(),P=A("iterator"),R="URLSearchParams",L=R+"Iterator",I=p.set,k=p.getterFor(R),O=p.getterFor(L),D=Object.getOwnPropertyDescriptor,N=function(e){if(!s)return i[e];var t=D(i,e);return t&&t.value},U=N("fetch"),F=N("Request"),B=N("Headers"),z=F&&F.prototype,H=B&&B.prototype,V=i.RegExp,j=i.TypeError,G=i.decodeURIComponent,W=i.encodeURIComponent,X=a("".charAt),Y=a([].join),q=a([].push),J=a("".replace),Z=a([].shift),K=a([].splice),$=a("".split),Q=a("".slice),ee=/\+/g,te=Array(4),ne=function(e){return te[e-1]||(te[e-1]=V("((?:%[\\da-f]{2}){"+e+"})","gi"))},ie=function(e){try{return G(e)}catch(t){return e}},re=function(e){var t=J(e,ee," "),n=4;try{return G(t)}catch(e){for(;n;)t=J(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 J(W(e),ae,oe)},he=d((function(e,t){I(this,{type:L,iterator:M(k(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),ue=function(e){this.entries=[],this.url=null,void 0!==e&&(b(e)?this.parseObject(e):this.parseQuery("string"==typeof e?"?"===X(e,0)?Q(e,1):e:_(e)))};ue.prototype={type:R,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=M(e,h)).next;!(i=r(n,t)).done;){if(s=(a=M(x(i.value))).next,(o=r(s,a)).done||(l=r(s,a)).done||!r(s,a).done)throw j("Expected sequence with length 2");q(this.entries,{key:_(o.value),value:_(l.value)})}else for(var u in e)g(e,u)&&q(this.entries,{key:u,value:_(e[u])})},parseQuery:function(e){if(e)for(var t,n,i=$(e,"&"),r=0;r<i.length;)(t=i[r++]).length&&(n=$(t,"="),q(this.entries,{key:re(Z(n)),value:re(Y(n,"="))}))},serialize:function(){for(var e,t=this.entries,n=[],i=0;i<t.length;)e=t[i++],q(n,le(e.key)+"="+le(e.value));return Y(n,"&")},update:function(){this.entries.length=0,this.parseQuery(this.url.query)},updateURL:function(){this.url&&this.url.update()}};var ce,de,pe,fe,me=function(){f(this,ge);var e=I(this,new ue(arguments.length>0?arguments[0]:void 0));s||(this.size=e.entries.length)},ge=me.prototype;u(ge,{append:function(e,t){var n=k(this);T(arguments.length,2),q(n.entries,{key:_(e),value:_(t)}),s||this.length++,n.updateURL()},delete:function(e){for(var t=k(this),n=T(arguments.length,1),i=t.entries,r=_(e),a=n<2?void 0:arguments[1],o=void 0===a?a:_(a),l=0;l<i.length;){var h=i[l];if(h.key!==r||void 0!==o&&h.value!==o)l++;else if(K(i,l,1),void 0!==o)break}s||(this.size=i.length),t.updateURL()},get:function(e){var t=k(this).entries;T(arguments.length,1);for(var n=_(e),i=0;i<t.length;i++)if(t[i].key===n)return t[i].value;return null},getAll:function(e){var t=k(this).entries;T(arguments.length,1);for(var n=_(e),i=[],r=0;r<t.length;r++)t[r].key===n&&q(i,t[r].value);return i},has:function(e){for(var t=k(this).entries,n=T(arguments.length,1),i=_(e),r=n<2?void 0:arguments[1],a=void 0===r?r:_(r),s=0;s<t.length;){var o=t[s++];if(o.key===i&&(void 0===a||o.value===a))return!0}return!1},set:function(e,t){var n=k(this);T(arguments.length,1);for(var i,r=n.entries,a=!1,o=_(e),l=_(t),h=0;h<r.length;h++)(i=r[h]).key===o&&(a?K(r,h--,1):(a=!0,i.value=l));a||q(r,{key:o,value:l}),s||(this.size=r.length),n.updateURL()},sort:function(){var e=k(this);C(e.entries,(function(e,t){return e.key>t.key?1:-1})),e.updateURL()},forEach:function(e){for(var t,n=k(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,P,ge.entries,{name:"entries"}),l(ge,"toString",(function(){return k(this).serialize()}),{enumerable:!0}),s&&h(ge,"size",{get:function(){return k(this).entries.length},configurable:!0,enumerable:!0}),c(me,R),n({global:!0,constructor:!0,forced:!o},{URLSearchParams:me}),!o&&m(B)&&(ce=a(H.has),de=a(H.set),pe=function(e){if(b(e)){var t,n=e.body;if(y(n)===R)return t=e.headers?new B(e.headers):new B,ce(t,"content-type")||de(t,"content-type","application/x-www-form-urlencoded;charset=UTF-8"),w(e,{body:S(0,_(n)),headers:S(0,t)})}return e},m(U)&&n({global:!0,enumerable:!0,dontCallGetSet:!0,forced:!0},{fetch:function(e){return U(e,arguments.length>1?pe(arguments[1]):{})}}),m(F)&&(fe=function(e){return f(this,z),new F(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:k}})),ece=J((()=>{"use strict";BO();var e,t=et(),n=Kn(),i=XS(),r=wn(),a=cl(),s=Jt(),o=Hi(),l=Hs(),h=dc(),u=jr(),c=OD(),d=gL(),p=Tg(),f=qy().codeAt,m=gle(),g=ur(),v=ro(),y=dl(),x=BF(),b=Es(),_=b.set,w=b.getterFor("URL"),S=x.URLSearchParams,M=x.getState,E=r.URL,T=r.TypeError,A=r.parseInt,C=Math.floor,P=Math.pow,R=s("".charAt),L=s(/./.exec),I=s([].join),k=s(1..toString),O=s([].pop),D=s([].push),N=s("".replace),U=s([].shift),F=s("".split),B=s("".slice),z=s("".toLowerCase),H=s([].unshift),V="Invalid scheme",j="Invalid host",G="Invalid port",W=/[a-z]/i,X=/[\d+-.a-z]/i,Y=/\d/,q=/^0x/i,J=/^[0-7]+$/,Z=/^\d+$/,K=/^[\da-f]+$/i,$=/[\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++)H(t,e%256),e=C(e/256);return I(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+=k(e[n],16),n<7&&(t+=":")));return"["+t+"]"}return e},re={},ae=c({},re,{" ":1,'"':1,"<":1,">":1,"`":1}),se=c({},ae,{"#":1,"?":1,"{":1,"}":1}),oe=c({},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&&!u(t,e)?e:encodeURIComponent(e)},he={ftp:21,file:null,http:80,https:443,ws:80,wss:443},ue=function(e,t){var n;return 2==e.length&&L(W,R(e,0))&&(":"==(n=R(e,1))||!t&&"|"==n)},ce=function(e){var t;return e.length>1&&ue(B(e,0,2))&&(2==e.length||"/"===(t=R(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={},be={},_e={},we={},Se={},Me={},Ee={},Te={},Ae={},Ce={},Pe={},Re={},Le={},Ie={},ke={},Oe={},De=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 De(n,!0)),r=this.parse(s,null,i))throw T(r);(a=M(new S)).bindURL(this),this.searchParams=a}};De.prototype={type:"URL",parse:function(t,n,i){var r,a,s,o,l=this,h=n||fe,c=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);c<=r.length;){switch(a=r[c],h){case fe:if(!a||!L(W,a)){if(n)return V;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 V;f="",h=ge,c=0;continue}if(n&&(l.isSpecial()!=u(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=Ae:l.isSpecial()&&i&&i.scheme==l.scheme?h=ve:l.isSpecial()?h=_e:"/"==r[c+1]?(h=ye,c++):(l.cannotBeABaseURL=!0,D(l.path,""),h=Ie)}break;case ge:if(!i||i.cannotBeABaseURL&&"#"!=a)return V;if(i.cannotBeABaseURL&&"#"==a){l.scheme=i.scheme,l.path=p(i.path),l.query=i.query,l.fragment="",l.cannotBeABaseURL=!0,h=Oe;break}h="file"==i.scheme?Ae:xe;continue;case ve:if("/"!=a||"/"!=r[c+1]){h=xe;continue}h=we,c++;break;case ye:if("/"==a){h=Se;break}h=Le;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=be;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=ke;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=Le;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=Oe}break;case be:if(!l.isSpecial()||"/"!=a&&"\\"!=a){if("/"!=a){l.username=i.username,l.password=i.password,l.host=i.host,l.port=i.port,h=Le;continue}h=Se}else h=we;break;case _e:if(h=we,"/"!=a||"/"!=R(f,c+1))continue;c++;break;case we: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 b=s[x];if(":"!=b||y){var _=le(b,oe);y?l.password+=_:l.username+=_}else y=!0}f=""}else if(a==e||"/"==a||"?"==a||"#"==a||"\\"==a&&l.isSpecial()){if(m&&""==f)return"Invalid authority";c-=d(f).length+1,f="",h=Me}else f+=a;break;case Me:case Ee: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 j;if(n&&""==f&&(l.includesCredentials()||null!==l.port))return;if(o=l.parseHost(f))return o;if(f="",h=Re,n)return;continue}"["==a?v=!0:"]"==a&&(v=!1),f+=a}else{if(""==f)return j;if(o=l.parseHost(f))return o;if(f="",h=Te,n==Ee)return}break;case Te:if(!L(Y,a)){if(a==e||"/"==a||"?"==a||"#"==a||"\\"==a&&l.isSpecial()||n){if(""!=f){var w=A(f,10);if(w>65535)return G;l.port=l.isSpecial()&&w===he[l.scheme]?null:w,f=""}if(n)return;h=Re;continue}return G}f+=a;break;case Ae:if(l.scheme="file","/"==a||"\\"==a)h=Ce;else{if(!i||"file"!=i.scheme){h=Le;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=ke;else{if("#"!=a){ce(I(p(r,c),""))||(l.host=i.host,l.path=p(i.path),l.shortenPath()),h=Le;continue}l.host=i.host,l.path=p(i.path),l.query=i.query,l.fragment="",h=Oe}}break;case Ce:if("/"==a||"\\"==a){h=Pe;break}i&&"file"==i.scheme&&!ce(I(p(r,c),""))&&(ue(i.path[0],!0)?D(l.path,i.path[0]):l.host=i.host),h=Le;continue;case Pe:if(a==e||"/"==a||"\\"==a||"?"==a||"#"==a){if(!n&&ue(f))h=Le;else if(""==f){if(l.host="",n)return;h=Re}else{if(o=l.parseHost(f))return o;if("localhost"==l.host&&(l.host=""),n)return;f="",h=Re}continue}f+=a;break;case Re:if(l.isSpecial()){if(h=Le,"/"!=a&&"\\"!=a)continue}else if(n||"?"!=a)if(n||"#"!=a){if(a!=e&&(h=Le,"/"!=a))continue}else l.fragment="",h=Oe;else l.query="",h=ke;break;case Le:if(a==e||"/"==a||"\\"==a&&l.isSpecial()||!n&&("?"==a||"#"==a)){if(pe(f)?(l.shortenPath(),"/"!=a&&!("\\"==a&&l.isSpecial())&&D(l.path,"")):de(f)?"/"!=a&&!("\\"==a&&l.isSpecial())&&D(l.path,""):("file"==l.scheme&&!l.path.length&&ue(f)&&(l.host&&(l.host=""),f=R(f,0)+":"),D(l.path,f)),f="","file"==l.scheme&&(a==e||"?"==a||"#"==a))for(;l.path.length>1&&""===l.path[0];)U(l.path);"?"==a?(l.query="",h=ke):"#"==a&&(l.fragment="",h=Oe)}else f+=le(a,se);break;case Ie:"?"==a?(l.query="",h=ke):"#"==a?(l.fragment="",h=Oe):a!=e&&(l.path[0]+=le(a,re));break;case ke:n||"#"!=a?a!=e&&("'"==a&&l.isSpecial()?l.query+="%27":l.query+="#"==a?"%23":le(a,re)):(l.fragment="",h=Oe);break;case Oe:a!=e&&(l.fragment+=le(a,ae))}c++}},parseHost:function(e){var t,n,i;if("["==R(e,0)){if("]"!=R(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,u=null,c=0,d=function(){return R(e,c)};if(":"==d()){if(":"!=R(e,1))return;c+=2,u=++h}for(;d();){if(8==h)return;if(":"!=d()){for(t=n=0;n<4&&L(K,d());)t=16*t+A(d(),16),c++,n++;if("."==d()){if(0==n||(c-=n,h>6))return;for(i=0;d();){if(r=null,i>0){if(!("."==d()&&i<4))return;c++}if(!L(Y,d()))return;for(;L(Y,d());){if(a=A(d(),10),null===r)r=a;else{if(0==r)return;r=10*r+a}if(r>255)return;c++}l[h]=256*l[h]+r,(2==++i||4==i)&&h++}if(4!=i)return;break}if(":"==d()){if(c++,!d())return}else if(d())return;l[h++]=t}else{if(null!==u)return;c++,u=++h}}if(null!==u)for(s=h-u,h=7;0!=h&&s>0;)o=l[h],l[h--]=l[u+s-1],l[u+--s]=o;else if(8!=h)return;return l}(B(e,1,-1)),!t))return j;this.host=t}else if(this.isSpecial()){if(e=m(e),L($,e)||(t=function(e){var t,n,i,r,a,s,o,l=F(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"==R(r,0)&&(a=L(q,r)?16:8,r=B(r,8==a?1:2)),""===r)s=0;else{if(!L(10==a?Z:8==a?J:K,r))return e;s=A(r,a)}D(n,s)}for(i=0;i<t;i++)if(s=n[i],i==t-1){if(s>=P(256,5-t))return null}else if(s>255)return null;for(o=O(n),i=0;i<n.length;i++)o+=n[i]*P(256,3-i);return o}(e),null===t))return j;this.host=t}else{if(L(Q,e))return j;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 u(he,this.scheme)},shortenPath:function(){var e=this.path,t=e.length;t&&("file"!=this.scheme||1!=t||!ue(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?"/"+I(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 Fe(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,Me)},getHostname:function(){var e=this.host;return null===e?"":ie(e)},setHostname:function(e){this.cannotBeABaseURL||this.parse(e,Ee)},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,Te))},getPathname:function(){var e=this.path;return this.cannotBeABaseURL?e[0]:e.length?"/"+I(e,"/"):""},setPathname:function(e){this.cannotBeABaseURL||(this.path=[],this.parse(e,Re))},getSearch:function(){var e=this.query;return e?"?"+e:""},setSearch:function(e){""==(e=g(e))?this.query=null:("?"==R(e,0)&&(e=B(e,1)),this.query="",this.parse(e,ke)),this.searchParams.update()},getSearchParams:function(){return this.searchParams.facade},getHash:function(){var e=this.fragment;return e?"#"+e:""},setHash:function(e){""!=(e=g(e))?("#"==R(e,0)&&(e=B(e,1)),this.fragment="",this.parse(e,Oe)):this.fragment=null},update:function(){this.query=this.searchParams.serialize()||null}};var Ne,Ue,Fe=function(e){var t=h(this,Be),i=y(arguments.length,1)>1?arguments[1]:void 0,r=_(t,new De(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())},Be=Fe.prototype,ze=function(e,t){return{get:function(){return w(this)[e]()},set:t&&function(e){return w(this)[t](e)},configurable:!0,enumerable:!0}};n&&(l(Be,"href",ze("serialize","setHref")),l(Be,"origin",ze("getOrigin")),l(Be,"protocol",ze("getProtocol","setProtocol")),l(Be,"username",ze("getUsername","setUsername")),l(Be,"password",ze("getPassword","setPassword")),l(Be,"host",ze("getHost","setHost")),l(Be,"hostname",ze("getHostname","setHostname")),l(Be,"port",ze("getPort","setPort")),l(Be,"pathname",ze("getPathname","setPathname")),l(Be,"search",ze("getSearch","setSearch")),l(Be,"searchParams",ze("getSearchParams")),l(Be,"hash",ze("getHash","setHash"))),o(Be,"toJSON",(function(){return w(this).serialize()}),{enumerable:!0}),o(Be,"toString",(function(){return w(this).serialize()}),{enumerable:!0}),E&&(Ne=E.createObjectURL,Ue=E.revokeObjectURL,Ne&&o(Fe,"createObjectURL",a(Ne,E)),Ue&&o(Fe,"revokeObjectURL",a(Ue,E))),v(Fe,"URL"),t({global:!0,constructor:!0,forced:!i,sham:!n},{URL:Fe})})),tce=J((()=>{ece()})),ice=J((()=>{var e=et(),t=Ui(),n=Yt(),i=dl(),r=ur(),a=XS(),s=t("URL");e({target:"URL",stat:!0,forced:!(a&&n((function(){s.canParse()})))},{canParse:function(e){var t=i(arguments.length,1),n=r(e),a=t<2||void 0===arguments[1]?void 0:r(arguments[1]);try{return!!new s(n,a)}catch(e){return!1}}})})),sce=J((()=>{"use strict";var e=et(),t=vr();e({target:"URL",proto:!0,enumerable:!0},{toJSON:function(){return t(URL.prototype.toString,this)}})})),ace=J((()=>{BF()})),hce=J((()=>{"use strict";var e=Hi(),t=Jt(),n=ur(),i=dl(),r=URLSearchParams,a=r.prototype,s=t(a.append),o=t(a.delete),l=t(a.forEach),h=t([].push),u=new r("a=1&a=2");u.delete("a",1),u+""!="a=2"&&e(a,"delete",(function(e){var t=arguments.length,r=t<2?void 0:arguments[1];if(t&&void 0===r)return o(this,e);var a=[];l(this,(function(e,t){h(a,{key:t,value:e})})),i(t,1);for(var u,c=n(e),d=n(r),p=0,f=0,m=!1,g=a.length;p<g;)u=a[p++],m||u.key===c?(m=!0,o(this,u.key)):f++;for(;f<g;)(u=a[f++]).key===c&&u.value===d||s(this,u.key,u.value)}),{enumerable:!0,unsafe:!0})})),pce=J((()=>{"use strict";var e=Hi(),t=Jt(),n=ur(),i=dl(),r=URLSearchParams,a=r.prototype,s=t(a.getAll),o=t(a.has);new r("a=1").has("a",2)&&e(a,"has",(function(e){var t=arguments.length,r=t<2?void 0:arguments[1];if(t&&void 0===r)return o(this,e);var a=s(this,e);i(t,1);for(var l=n(r),h=0;h<a.length;)if(a[h++]===l)return!0;return!1}),{enumerable:!0,unsafe:!0})})),mce=J((()=>{"use strict";var e=Kn(),t=Jt(),n=Hs(),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})})),vce=J(((e,t)=>{Z9(),rW(),iW(),sW(),aW(),oW(),lW(),cW(),uW(),hW(),dW(),fW(),pW(),mW(),gW(),zW(),XW(),uj(),pj(),gj(),_j(),Mj(),Rj(),Ij(),Lj(),Oj(),Fj(),Uj(),Hj(),Gj(),qj(),Xj(),rX(),iX(),aX(),oX(),vy(),RX(),LX(),DX(),kX(),NX(),zX(),qX(),jX(),$X(),ZX(),dY(),mY(),gY(),yY(),_Y(),TY(),wY(),SY(),MY(),RY(),e$(),d$(),E$(),T$(),w$(),M$(),C$(),P$(),H$(),V$(),j$(),Z$(),J$(),iZ(),oZ(),hZ(),dZ(),W3(),fZ(),CZ(),LZ(),kZ(),NZ(),UZ(),HZ(),GZ(),WZ(),YZ(),ZZ(),JZ(),eK(),tK(),nK(),rK(),aK(),cK(),uK(),hK(),_K(),TK(),MK(),RK(),CK(),PK(),IK(),LK(),BK(),jK(),KK(),rJ(),aJ(),hJ(),dJ(),mJ(),vJ(),xJ(),bJ(),MJ(),AJ(),RJ(),IJ(),LJ(),DJ(),kJ(),FJ(),BJ(),HJ(),zJ(),qJ(),jJ(),XJ(),YJ(),$J(),tQ(),nQ(),rQ(),aQ(),oQ(),cQ(),hQ(),_ee(),Tee(),See(),Cee(),Pee(),Nee(),Hee(),Vee(),Wee(),jee(),Xee(),Yee(),$ee(),Zee(),Kee(),nte(),ite(),ste(),Ete(),Tte(),iS(),Cte(),Ite(),Ote(),Nte(),Ute(),Hte(),qte(),Kte(),ene(),nne(),ine(),BO(),vne(),Ane(),Cne(),Pne(),One(),kne(),Vne(),jne(),$ne(),tre(),are(),lre(),dre(),gre(),Ere(),Mre(),Pre(),Ire(),Lre(),Dre(),Ore(),kre(),Fre(),Nre(),Bre(),Ure(),Hre(),Vre(),zre(),gie(),vie(),yie(),xie(),bie(),Eie(),_ie(),Tie(),wie(),Mie(),Rie(),Pie(),Lie(),Bie(),Hie(),zie(),qie(),jie(),Yie(),$ie(),Kie(),Qie(),ise(),ase(),lse(),use(),dse(),pse(),gse(),yse(),wse(),Mse(),Rse(),Ose(),Nse(),zse(),Gse(),qse(),jse(),Xse(),Jse(),mae(),vae(),Mae(),kae(),zae(),Yae(),loe(),moe(),voe(),Roe(),Coe(),Ioe(),Joe(),sle(),tce(),ice(),sce(),ace(),hce(),pce(),mce(),t.exports=WT()})),yce=J(((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 u(e,t,n,i){var a=t&&t.prototype instanceof v?t:v,s=Object.create(a.prototype),o=new R(i||[]);return r(s,"_invoke",{value:T(e,n,o)}),s}function c(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=u;var d="suspendedStart",p="suspendedYield",f="executing",m="completed",g={};function v(){}function y(){}function x(){}var b={};h(b,s,(function(){return this}));var _=Object.getPrototypeOf,w=_&&_(_(L([])));w&&w!==n&&i.call(w,s)&&(b=w);var S=x.prototype=v.prototype=Object.create(b);function M(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=c(e[r],e,a);if("throw"!==l.type){var h=l.arg,u=h.value;return u&&"object"==typeof u&&i.call(u,"__await")?t.resolve(u.__await).then((function(e){n("next",e,s,o)}),(function(e){n("throw",e,s,o)})):t.resolve(u).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 I()}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=c(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=c(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 P(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function R(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:I}}function I(){return{value:t,done:!0}}return y.prototype=x,r(S,"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(S),e},e.awrap=function(e){return{__await:e}},M(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(u(t,n,i,r),a);return e.isGeneratorFunction(n)?s:s.next().then((function(e){return e.done?e.value:s.next()}))},M(S),h(S,l,"Generator"),h(S,s,(function(){return this})),h(S,"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,R.prototype={constructor:R,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(P),!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),P(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;P(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)}})),Pde=J(((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 u(){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,u()||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 c=u();null==c&&(c=n),o.setLevel(c,!1)}var u=new h,c={};u.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=c[e];return t||(t=c[e]=new h(e,u.getLevel(),u.methodFactory)),t};var d=typeof window!==t?window.log:void 0;return u.noConflict=function(){return typeof window!==t&&window.log===u&&(window.log=d),u},u.getLoggers=function(){return c},u.default=u,u}))})),RR=J(((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),u=t-h,c=o*u-(r-s*h-o*h-s*u);return i?(i[0]=c,i[1]=r,i):[c,r]};var n=+(Math.pow(2,27)+1)})),NH=J(((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,u=Math.abs,c=e[l],d=u(c),p=t[h],f=u(p);d<f?(a=c,(l+=1)<n&&(d=u(c=e[l]))):(a=p,(h+=1)<i&&(f=u(p=t[h]))),l<n&&d<f||h>=i?(r=c,(l+=1)<n&&(d=u(c=e[l]))):(r=p,(h+=1)<i&&(f=u(p=t[h])));for(var m,g,v=r+a,y=v-r,x=a-y,b=x,_=v;l<n&&h<i;)d<f?(r=c,(l+=1)<n&&(d=u(c=e[l]))):(r=p,(h+=1)<i&&(f=u(p=t[h]))),(x=(a=b)-(y=(v=r+a)-r))&&(s[o++]=x),b=_-((m=_+v)-(g=m-_))+(v-g),_=m;for(;l<n;)(x=(a=b)-(y=(v=(r=c)+a)-r))&&(s[o++]=x),b=_-((m=_+v)-(g=m-_))+(v-g),_=m,(l+=1)<n&&(c=e[l]);for(;h<i;)(x=(a=b)-(y=(v=(r=p)+a)-r))&&(s[o++]=x),b=_-((m=_+v)-(g=m-_))+(v-g),_=m,(h+=1)<i&&(p=t[h]);return b&&(s[o++]=b),_&&(s[o++]=_),o||(s[o++]=0),s.length=o,s}})),_fe=J(((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]}})),UH=J(((e,t)=>{"use strict";var n=RR(),i=_fe();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 u=1;u<r;++u){n(e[u],t,l);var c=o[1];i(c,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}})),Sfe=J(((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}})),Afe=J(((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,u=Math.abs,c=e[l],d=u(c),p=-t[h],f=u(p);d<f?(a=c,(l+=1)<n&&(d=u(c=e[l]))):(a=p,(h+=1)<i&&(f=u(p=-t[h]))),l<n&&d<f||h>=i?(r=c,(l+=1)<n&&(d=u(c=e[l]))):(r=p,(h+=1)<i&&(f=u(p=-t[h])));for(var m,g,v=r+a,y=v-r,x=a-y,b=x,_=v;l<n&&h<i;)d<f?(r=c,(l+=1)<n&&(d=u(c=e[l]))):(r=p,(h+=1)<i&&(f=u(p=-t[h]))),(x=(a=b)-(y=(v=r+a)-r))&&(s[o++]=x),b=_-((m=_+v)-(g=m-_))+(v-g),_=m;for(;l<n;)(x=(a=b)-(y=(v=(r=c)+a)-r))&&(s[o++]=x),b=_-((m=_+v)-(g=m-_))+(v-g),_=m,(l+=1)<n&&(c=e[l]);for(;h<i;)(x=(a=b)-(y=(v=(r=p)+a)-r))&&(s[o++]=x),b=_-((m=_+v)-(g=m-_))+(v-g),_=m,(h+=1)<i&&(p=-t[h]);return b&&(s[o++]=b),_&&(s[o++]=_),o||(s[o++]=0),s.length=o,s}})),Cfe=J(((e,t)=>{"use strict";var n=RR(),i=NH(),r=UH(),a=Afe();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])))),u=i(l,h);return u[u.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]))))),u=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])))),c=i(h,u);return c[c.length-1]}}function h(e){return(3===e?s:4===e?o:l)(i,n,r,a)}var u=h(3),c=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:u(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],u=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,b=u*(f-m)+d*(g-v)+p*(y-x),_=7771561172376103e-31*((Math.abs(f)+Math.abs(m))*Math.abs(u)+(Math.abs(g)+Math.abs(v))*Math.abs(d)+(Math.abs(y)+Math.abs(x))*Math.abs(p));return b>_||-b>_?b:c(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 u=new Array(arguments.length),c=0;c<arguments.length;++c)u[c]=arguments[c];return e(u)}}!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]}()})),Ife=J(((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],u=i[r],c=Math.min(h,u);if(Math.max(h,u)<o||l<c)return!1}return!0}(e,t,i,r))};var n=Cfe()[3]})),Dfe=J(((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]]),u=i([-o[0]],[l[0]]),c=i(i(r(u,e[1]),r(u,-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(c)]};var n=RR(),i=NH(),r=UH(),a=Sfe(),s=Ife()})),kfe=J(((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}})),Nfe=J(((e,t)=>{var n=Dfe(),i=kfe();function r(e,t){return e[0]===t[0]&&e[1]===t[1]}t.exports=function(e,t){for(var u={},c=e.length,d=[],p=0;p<c;p++){var f=e[p],m=e[(p+1)%c];h(f,o),h(m,l);for(var g=0;g<c;g++)if(p!==g){var v=e[g],y=e[(g+1)%c];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),b=x[2];if(1!==b.length||b[0]){var _=i(x[2]);if(x[0]=i(x[0])/_,x[1]=i(x[1])/_,x.pop(),!(r(x,o)||r(x,l)||r(x,a)||r(x,s))){var w=x+"",S=!u[w];S&&(u[w]=!0);var M=S;t&&(M=t(x,p,f,m,g,v,y,S)),M&&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)}})),cpe=J(((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}})),dpe=J(((e,t)=>{var n=cpe();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}})),fpe=J(((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 u(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 c(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=u(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),u=32767&h,c=h>>>15,d=o.__imul(u,i),p=o.__imul(u,r),f=o.__imul(c,i),m=s+d+a;a=m>>>30,m&=1073741823,a+=(m+=((32767&p)<<15)+((32767&f)<<15))>>>30,s=o.__imul(c,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),u=(r>>>15)-(32767&h)-i;if(i=1&u>>>15,this.__setDigit(t+s,(32767&u)<<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 c=0;c<e.length-1;c++){var d=this.__digit(t+c),p=e.__digit(c),f=(32767&d)-(32767&p)-i,m=(d>>>15)-(p>>>15)-(i=1&f>>>15);i=1&m>>>15,this.__setDigit(t+c,(32767&m)<<15|32767&f)}var g=this.__digit(t+c),v=e.__digit(c),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+c,(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,u=r+3,c=32===u?0:l<<u;c>>>=12;var d=u-12,p=12<=u?0:l<<20+u,f=20+u;for(0<d&&0<h&&(h--,c|=(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)&&++c>>>20!=0&&(c=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|c,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=c(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=c(i?[4,0]:[0,4],2),h=l[0],u=l[1];e.setUint32(t+h,r,i),e.setUint32(t+u,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 u=20-l;h=u+32,t=a>>>u,a=a<<32-u|s>>>u,s<<=32-u}else if(20===l)h=32,t=a,a=s,s=0;else{var c=l-20;h=32-c,t=a<<c|s>>>32-c,a=s<<c,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 u=new o(0|(29+(l*s+h>>>o.__kBitsPerCharTableShift))/30,!1),c=10>t?t:10,d=10<t?t-10:0;if(t&t-1){u.__initializeDigits();var p=!1,f=0;do{for(var m,g=0,v=1;;){if(m=void 0,a-48>>>0<c)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;u.__inplaceMultiplyAdd(v,g,x)}while(!p)}else{l>>=o.__kBitsPerCharTableShift;var b=[],_=[],w=!1;do{for(var S,M=0,E=0;;){if(S=void 0,a-48>>>0<c)S=a-48;else{if(!((32|a)-97>>>0<d)){w=!0;break}S=(32|a)-87}if(E+=l,M=M<<l|S,++r===i){w=!0;break}if(a=e.charCodeAt(r),30<E+l)break}b.push(M),_.push(E)}while(!w);o.__fillFromParts(u,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 u.sign=-1===n,u.__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),u=l-1,c=0,d=0,p=0;p<n-1;p++){var f=e.__digit(p),m=(c|f<<d)&a;h[u--]=o.__kConversionChars[m];var g=r-d;for(c=f>>>g,d=30-g;d>=r;)h[u--]=o.__kConversionChars[c&a],c>>>=r,d-=r}var v=(c|s<<d)&a;for(h[u--]=o.__kConversionChars[v],c=s>>>r-d;0!==c;)h[u--]=o.__kConversionChars[c&a],c>>>=r;if(e.sign&&(h[u--]="-"),-1!==u)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,u=l*o.__kBitsPerCharTableMultiplier,c=1+(u=0|(u+=h-1)/h)>>1,d=o.exponentiate(o.__oneDigit(t,!1),o.__oneDigit(c,!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<c;)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,u=r+1;if(h<u)return o.__absoluteLess(n);if(h>u)return o.__absoluteGreater(n);var c=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=c>>>g,c=c<<32-g|d>>>g,d<<=32-g}else if(20===p)m=32,f=c,c=d,d=0;else{var v=p-20;m=32-v,f=c<<v|d>>>32-v,c=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=c>>>2,c=c<<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!==c||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 u=0;u<a;u++)n.__setDigit(u,e.__digit(u)&t.__digit(u));for(;u<h;u++)n.__setDigit(u,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 u=0;u<a;u++)n.__setDigit(u,e.__digit(u)|t.__digit(u));for(;u<i;u++)n.__setDigit(u,e.__digit(u));for(;u<h;u++)n.__setDigit(u,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 u=0;u<a;u++)n.__setDigit(u,e.__digit(u)^t.__digit(u));for(;u<i;u++)n.__setDigit(u,e.__digit(u));for(;u<h;u++)n.__setDigit(u,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 u=n.__digit(i),c=e.__digit(h),d=32767&c,p=c>>>15,f=o.__imul(d,r),m=o.__imul(d,a),g=o.__imul(p,r);s=(u+=l+f+s)>>>30,u&=1073741823,s+=(u+=((32767&m)<<15)+((32767&g)<<15))>>>30,l=o.__imul(p,a)+(m>>>15)+(g>>>15),n.__setDigit(i,1073741823&u)}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),u=o.__imul(32767&h,t),c=o.__imul(h>>>15,t),d=u+((32767&c)<<15)+s+a;a=d>>>30,s=c>>>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 u=o.__clz15(t.__halfDigit(r-1));0<u&&(t=o.__specialLeftShift(t,u,0));for(var c=o.__specialLeftShift(e,u,1),d=t.__halfDigit(r-1),p=0,f=s;0<=f;f--){var m=32767,g=c.__halfDigit(f+r);if(g!==d){var v=(g<<15|c.__halfDigit(f+r-1))>>>0;m=0|v/d;for(var y=0|v%d,x=t.__halfDigit(r-2),b=c.__halfDigit(f+r-2);o.__imul(m,x)>>>0>(y<<16|b)>>>0&&(m--,!(32767<(y+=d))););}o.__internalMultiplyAdd(t,m,0,a,h);var _=c.__inplaceSub(h,f,r+1);0!==_&&(_=c.__inplaceAdd(t,f,r),c.__setHalfDigit(f+r,32767&c.__halfDigit(f+r)+_),m--),n&&(1&f?p=m<<15:l.__setDigit(f>>>1,p|m))}if(i)return c.__inplaceRightShift(u),n?{quotient:l,remainder:c}:c;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 u=0;u<i;u++)h.__setDigit(u,0);for(;u<l;u++)h.__setDigit(u,e.__digit(u-i))}else{for(var c=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|c),c=p>>>30-r;if(s)h.__setDigit(a+i,c);else if(0!==c)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 u=0;u<a;u++)if(0!==e.__digit(u)){h=!0;break}h&&0===s&&!~e.__digit(n-1)&&l++;var c=new o(l,i);if(0===s){c.__setDigit(l-1,0);for(var d=a;d<n;d++)c.__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),c.__setDigit(g,1073741823&p<<30-s|f),f=p>>>s;c.__setDigit(m,f)}return h&&(c=o.__absoluteAddOne(c,!0,c)),c.__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,u=0,c=r(h,t.length);l<c;l++)u=1&(i=0-t.__digit(l)-u)>>>30,s.__setDigit(l,1073741823&i);for(;l<h;l++)s.__setDigit(l,0|1073741823&-u);var d,p=h<t.length?t.__digit(h):0,f=e%30;if(0===f)d=0-p-u,d&=1073741823;else{var m=32-f,g=1<<32-m;d=g-(p=p<<m>>>m)-u,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()})),Lc=J(((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,u=NaN,c=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]",b="[object Map]",_="[object Number]",w="[object Object]",S="[object Promise]",M="[object RegExp]",E="[object Set]",T="[object String]",A="[object Symbol]",C="[object WeakMap]",P="[object ArrayBuffer]",R="[object DataView]",L="[object Float32Array]",I="[object Float64Array]",k="[object Int8Array]",O="[object Int16Array]",D="[object Int32Array]",N="[object Uint8Array]",U="[object Uint8ClampedArray]",F="[object Uint16Array]",B="[object Uint32Array]",z=/\b__p \+= '';/g,H=/\b(__p \+=) '' \+/g,V=/(__e\(.*?\)|\b__t\)) \+\n'';/g,j=/&(?:amp|lt|gt|quot|#39);/g,G=/[&<>"']/g,W=RegExp(j.source),X=RegExp(G.source),Y=/<%-([\s\S]+?)%>/g,q=/<%([\s\S]+?)%>/g,J=/<%=([\s\S]+?)%>/g,Z=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,K=/^\w*$/,$=/[^.[\]]+|\[(?:(-?\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,ue=/\w*$/,ce=/^[-+]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",be="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",_e="\\u2700-\\u27bf",we="a-z\\xdf-\\xf6\\xf8-\\xff",Se="A-Z\\xc0-\\xd6\\xd8-\\xde",Me="\\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="["+be+"]",Pe="\\d+",Re="["+_e+"]",Le="["+we+"]",Ie="[^"+xe+Ee+Pe+_e+we+Se+"]",ke="\\ud83c[\\udffb-\\udfff]",Oe="[^"+xe+"]",De="(?:\\ud83c[\\udde6-\\uddff]){2}",Ne="[\\ud800-\\udbff][\\udc00-\\udfff]",Ue="["+Se+"]",Fe="\\u200d",Be="(?:"+Le+"|"+Ie+")",ze="(?:"+Ue+"|"+Ie+")",He="(?:['\u2019](?:d|ll|m|re|s|t|ve))?",Ve="(?:['\u2019](?:D|LL|M|RE|S|T|VE))?",je="(?:"+Ce+"|"+ke+")?",Ge="["+Me+"]?",We=Ge+je+"(?:"+Fe+"(?:"+[Oe,De,Ne].join("|")+")"+Ge+je+")*",Xe="(?:"+[Re,De,Ne].join("|")+")"+We,Ye="(?:"+[Oe+Ce+"?",Ce,De,Ne,Te].join("|")+")",qe=RegExp("['\u2019]","g"),Je=RegExp(Ce,"g"),Ze=RegExp(ke+"(?="+ke+")|"+Ye+We,"g"),Ke=RegExp([Ue+"?"+Le+"+"+He+"(?="+[Ae,Ue,"$"].join("|")+")",ze+"+"+Ve+"(?="+[Ae,Ue+Be,"$"].join("|")+")",Ue+"?"+Be+"+"+He,Ue+"+"+Ve,"\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Pe,Xe].join("|"),"g"),$e=RegExp("["+Fe+xe+be+Me+"]"),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[I]=nt[k]=nt[O]=nt[D]=nt[N]=nt[U]=nt[F]=nt[B]=!0,nt[p]=nt[f]=nt[P]=nt[m]=nt[R]=nt[g]=nt[v]=nt[y]=nt[b]=nt[_]=nt[w]=nt[M]=nt[E]=nt[T]=nt[C]=!1;var it={};it[p]=it[f]=it[P]=it[R]=it[m]=it[g]=it[L]=it[I]=it[k]=it[O]=it[D]=it[b]=it[_]=it[w]=it[M]=it[E]=it[T]=it[A]=it[N]=it[U]=it[F]=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")(),ut="object"==typeof e&&e&&!e.nodeType&&e,ct=ut&&"object"==typeof t&&t&&!t.nodeType&&t,dt=ct&&ct.exports===ut,pt=dt&&ot.process,ft=function(){try{return ct&&ct.require&&ct.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,bt=ft&&ft.isTypedArray;function _t(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 wt(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 St(e,t){for(var n=-1,i=null==e?0:e.length;++n<i&&!1!==t(e[n],n,e););return e}function Mt(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)&&Ut(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 Pt(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 Rt(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 It(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 kt(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=Ht("length");function Dt(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 Ut(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 Ft(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?Gt(e,t)/n:u}function Ht(e){return function(t){return null==t?n:t[e]}}function Vt(e){return function(t){return null==e?n:e[t]}}function jt(e,t,n,i,r){return r(e,(function(e,r,a){n=i?(i=!1,e):t(n,e,r,a)})),n}function Gt(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 Yt(e){return function(t){return e(t)}}function qt(e,t){return Pt(t,(function(t){return e[t]}))}function Jt(e,t){return e.has(t)}function Zt(e,t){for(var n=-1,i=e.length;++n<i&&Ut(t,e[n],0)>-1;);return n}function Kt(e,t){for(var n=e.length;n--&&Ut(t,e[n],0)>-1;);return n}var $t=Vt({"\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=Vt({"&":"&","<":"<",">":">",'"':""","'":"'"});function en(e){return"\\"+rt[e]}function tn(e){return $e.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=Ze.lastIndex=0;Ze.test(e);)++t;return t}(e):Ot(e)}function ln(e){return tn(e)?function(e){return e.match(Ze)||[]}(e):function(e){return e.split("")}(e)}function hn(e){for(var t=e.length;t--&&ne.test(e.charAt(t)););return t}var un=Vt({"&":"&","<":"<",">":">",""":'"',"'":"'"}),cn=function e(t){var ne,xe=(t=null==t?ht:cn.defaults(ht.Object(),t,cn.pick(ht,et))).Array,be=t.Date,_e=t.Error,we=t.Function,Se=t.Math,Me=t.Object,Ee=t.RegExp,Te=t.String,Ae=t.TypeError,Ce=xe.prototype,Pe=we.prototype,Re=Me.prototype,Le=t["__core-js_shared__"],Ie=Pe.toString,ke=Re.hasOwnProperty,Oe=0,De=(ne=/[^.]+$/.exec(Le&&Le.keys&&Le.keys.IE_PROTO||""))?"Symbol(src)_1."+ne:"",Ne=Re.toString,Ue=Ie.call(Me),Fe=ht._,Be=Ee("^"+Ie.call(ke).replace(Q,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),ze=dt?t.Buffer:n,He=t.Symbol,Ve=t.Uint8Array,je=ze?ze.allocUnsafe:n,Ge=rn(Me.getPrototypeOf,Me),We=Me.create,Xe=Re.propertyIsEnumerable,Ye=Ce.splice,Ze=He?He.isConcatSpreadable:n,$e=He?He.iterator:n,rt=He?He.toStringTag:n,ot=function(){try{var e=oa(Me,"defineProperty");return e({},"",{}),e}catch(e){}}(),lt=t.clearTimeout!==ht.clearTimeout&&t.clearTimeout,ut=be&&be.now!==ht.Date.now&&be.now,ct=t.setTimeout!==ht.setTimeout&&t.setTimeout,pt=Se.ceil,ft=Se.floor,Ot=Me.getOwnPropertySymbols,Vt=ze?ze.isBuffer:n,dn=t.isFinite,pn=Ce.join,fn=rn(Me.keys,Me),mn=Se.max,gn=Se.min,vn=be.now,yn=t.parseInt,xn=Se.random,bn=Ce.reverse,_n=oa(t,"DataView"),wn=oa(t,"Map"),Sn=oa(t,"Promise"),Mn=oa(t,"Set"),En=oa(t,"WeakMap"),Tn=oa(Me,"create"),An=En&&new En,Cn={},Pn=ka(_n),Rn=ka(wn),Ln=ka(Sn),In=ka(Mn),kn=ka(En),On=He?He.prototype:n,Dn=On?On.valueOf:n,Nn=On?On.toString:n;function Un(e){if(Zs(e)&&!Bs(e)&&!(e instanceof Hn)){if(e instanceof zn)return e;if(ke.call(e,"__wrapped__"))return Oa(e)}return new zn(e)}var Fn=function(){function e(){}return function(t){if(!Js(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 Hn(e){this.__wrapped__=e,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=c,this.__views__=[]}function Vn(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 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 Wn(e){var t=-1,n=null==e?0:e.length;for(this.__data__=new Gn;++t<n;)this.add(e[t])}function Xn(e){var t=this.__data__=new jn(e);this.size=t.size}function Yn(e,t){var n=Bs(e),i=!n&&Fs(e),r=!n&&!i&&js(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||ke.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 qn(e){var t=e.length;return t?e[Gi(0,t-1)]:n}function Jn(e,t){return Ra(Er(e),ri(t,0,e.length))}function Zn(e){return Ra(Er(e))}function Kn(e,t,i){(i!==n&&!Ds(e[t],i)||i===n&&!(t in e))&&ni(e,t,i)}function $n(e,t,i){var r=e[t];(!ke.call(e,t)||!Ds(r,i)||i===n&&!(t in e))&&ni(e,t,i)}function Qn(e,t){for(var n=e.length;n--;)if(Ds(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:wo(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,u=4&t;if(i&&(o=a?i(e,r,a,s):i(e)),o!==n)return o;if(!Js(e))return e;var c=Bs(e);if(c){if(o=function(e){var t=e.length,n=new e.constructor(t);return t&&"string"==typeof e[0]&&ke.call(e,"index")&&(n.index=e.index,n.input=e.input),n}(e),!l)return Er(e,o)}else{var d=ua(e),f=d==y||d==x;if(js(e))return xr(e,l);if(d==w||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 P:return br(e);case m:case g:return new i(+e);case R:return function(e,t){var n=t?br(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.byteLength)}(e,n);case L:case I:case k:case O:case D:case N:case U:case F:case B:return _r(e,n);case b:return new i;case _:case T:return new i(e);case M:return function(e){var t=new e.constructor(e.source,ue.exec(e));return t.lastIndex=e.lastIndex,t}(e);case E:return new i;case A:return function(e){return Dn?Me(Dn.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))})):Ks(e)&&e.forEach((function(n,r){o.set(r,ai(n,t,i,r,e,s))}));var S=c?n:(u?h?ea:Qr:h?Co:Ao)(e);return St(S||e,(function(n,r){S&&(n=e[r=n]),$n(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=Me(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=Pt(t,Yt(n))),i?(a=Ct,s=!1):t.length>=200&&(a=Jt,s=!1,t=new Wn(t));e:for(;++r<o;){var u=e[r],c=null==n?u:n(u);if(u=i||0!==u?u:0,s&&c==c){for(var d=h;d--;)if(t[d]===c)continue e;l.push(u)}else a(t,c,i)||l.push(u)}return l}Un.templateSettings={escape:Y,evaluate:q,interpolate:J,variable:"",imports:{_:Un}},Un.prototype=Bn.prototype,Un.prototype.constructor=Un,zn.prototype=Fn(Bn.prototype),zn.prototype.constructor=zn,Hn.prototype=Fn(Bn.prototype),Hn.prototype.constructor=Hn,Vn.prototype.clear=function(){this.__data__=Tn?Tn(null):{},this.size=0},Vn.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},Vn.prototype.get=function(e){var t=this.__data__;if(Tn){var i=t[e];return i===r?n:i}return ke.call(t,e)?t[e]:n},Vn.prototype.has=function(e){var t=this.__data__;return Tn?t[e]!==n:ke.call(t,e)},Vn.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},jn.prototype.clear=function(){this.__data__=[],this.size=0},jn.prototype.delete=function(e){var t=this.__data__,n=Qn(t,e);return!(n<0)&&(n==t.length-1?t.pop():Ye.call(t,n,1),--this.size,!0)},jn.prototype.get=function(e){var t=this.__data__,i=Qn(t,e);return i<0?n:t[i][1]},jn.prototype.has=function(e){return Qn(this.__data__,e)>-1},jn.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},Gn.prototype.clear=function(){this.size=0,this.__data__={hash:new Vn,map:new(wn||jn),string:new Vn}},Gn.prototype.delete=function(e){var t=aa(this,e).delete(e);return this.size-=t?1:0,t},Gn.prototype.get=function(e){return aa(this,e).get(e)},Gn.prototype.has=function(e){return aa(this,e).has(e)},Gn.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 jn,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 jn){var i=n.__data__;if(!wn||i.length<199)return i.push([e,t]),this.size=++n.size,this;n=this.__data__=new Gn(i)}return n.set(e,t),this.size=n.size,this};var hi=Pr(vi),ui=Pr(yi,!0);function ci(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):Rt(r,o):i||(r[r.length]=o)}return r}var mi=Rr(),gi=Rr(!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 bi(e,t){for(var i=0,r=(t=mr(t,e)).length;null!=e&&i<r;)e=e[Ia(t[i++])];return i&&i==r?e:n}function _i(e,t,n){var i=t(e);return Bs(e)?i:Rt(i,n(e))}function wi(e){return null==e?e===n?"[object Undefined]":"[object Null]":rt&&rt in Me(e)?function(e){var t=ke.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 Si(e,t){return e>t}function Mi(e,t){return null!=e&&ke.call(e,t)}function Ei(e,t){return null!=e&&t in Me(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,u=[];o--;){var c=e[o];o&&t&&(c=Pt(c,Yt(t))),h=gn(c.length,h),l[o]=!i&&(t||a>=120&&c.length>=120)?new Wn(o&&c):n}c=e[0];var d=-1,p=l[0];e:for(;++d<a&&u.length<h;){var f=c[d],m=t?t(f):f;if(f=i||0!==f?f:0,!(p?Jt(p,m):r(u,m,i))){for(o=s;--o;){var g=l[o];if(!(g?Jt(g,m):r(e[o],m,i)))continue e}p&&p.push(m),u.push(f)}}return u}function Ai(e,t,i){var r=null==(e=Sa(e,t=mr(t,e)))?e:e[Ia(Wa(t))];return null==r?n:_t(r,e,i)}function Ci(e){return Zs(e)&&wi(e)==p}function Pi(e,t,i,r,a){return e===t||(null==e||null==t||!Zs(e)&&!Zs(t)?e!=e&&t!=t:function(e,t,i,r,a,s){var o=Bs(e),l=Bs(t),h=o?f:ua(e),u=l?f:ua(t),c=(h=h==p?w:h)==w,d=(u=u==p?w:u)==w,y=h==u;if(y&&js(e)){if(!js(t))return!1;o=!0,c=!1}if(y&&!c)return s||(s=new Xn),o||ro(e)?Kr(e,t,i,r,a,s):function(e,t,n,i,r,a,s){switch(n){case R:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case P:return!(e.byteLength!=t.byteLength||!a(new Ve(e),new Ve(t)));case m:case g:case _:return Ds(+e,+t);case v:return e.name==t.name&&e.message==t.message;case M:case T:return e==t+"";case b: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 u=Kr(o(e),o(t),i,r,a,s);return s.delete(e),u;case A:if(Dn)return Dn.call(e)==Dn.call(t)}return!1}(e,t,h,i,r,a,s);if(!(1&i)){var x=c&&ke.call(e,"__wrapped__"),S=d&&ke.call(t,"__wrapped__");if(x||S){var C=x?e.value():e,L=S?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 u=h;u--;){var c=l[u];if(!(o?c in t:ke.call(t,c)))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;++u<h;){var g=e[c=l[u]],v=t[c];if(r)var y=o?r(v,g,c,t,e,s):r(g,v,c,e,t,s);if(!(y===n?g===v||a(g,v,i,r,s):y)){f=!1;break}m||(m="constructor"==c)}if(f&&!m){var x=e.constructor,b=t.constructor;x!=b&&"constructor"in e&&"constructor"in t&&!("function"==typeof x&&x instanceof x&&"function"==typeof b&&b instanceof b)&&(f=!1)}return s.delete(e),s.delete(t),f}(e,t,i,r,a,s))}(e,t,i,r,Pi,a))}function Ri(e,t,i,r){var a=i.length,s=a,o=!r;if(null==e)return!s;for(e=Me(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],u=e[h],c=l[1];if(o&&l[2]){if(u===n&&!(h in e))return!1}else{var d=new Xn;if(r)var p=r(u,c,h,e,t,d);if(!(p===n?Pi(c,u,3,r,d):p))return!1}}return!0}function Li(e){return!(!Js(e)||function(e){return!!De&&De in e}(e))&&(Xs(e)?Be:pe).test(ka(e))}function Ii(e){return"function"==typeof e?e:null==e?Qo:"object"==typeof e?Bs(e)?Ui(e[0],e[1]):Ni(e):ll(e)}function ki(e){if(!xa(e))return fn(e);var t=[];for(var n in Me(e))ke.call(e,n)&&"constructor"!=n&&t.push(n);return t}function Oi(e,t){return e<t}function Di(e,t){var n=-1,i=Hs(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]?_a(t[0][0],t[0][1]):function(n){return n===e||Ri(n,e,t)}}function Ui(e,t){return ga(e)&&ba(t)?_a(Ia(e),t):function(i){var r=wo(i,e);return r===n&&r===t?So(i,e):Pi(t,r,3)}}function Fi(e,t,i,r,a){e!==t&&mi(t,(function(s,o){if(a||(a=new Xn),Js(s))!function(e,t,i,r,a,s,o){var l=Ma(e,i),h=Ma(t,i),u=o.get(h);if(u)Kn(e,i,u);else{var c=s?s(l,h,i+"",e,t,o):n,d=c===n;if(d){var p=Bs(h),f=!p&&js(h),m=!p&&!f&&ro(h);c=h,p||f||m?Bs(l)?c=l:Vs(l)?c=Er(l):f?(d=!1,c=xr(h,!0)):m?(d=!1,c=_r(h,!0)):c=[]:Qs(h)||Fs(h)?(c=l,Fs(l)?c=po(l):(!Js(l)||Xs(l))&&(c=da(h))):d=!1}d&&(o.set(h,c),a(c,h,r,s,o),o.delete(h)),Kn(e,i,c)}}(e,t,o,i,Fi,r,a);else{var l=r?r(Ma(e,o),s,o+"",e,t,a):n;l===n&&(l=s),Kn(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?Pt(t,(function(e){return Bs(e)?function(t){return bi(t,1===e.length?e[0]:e)}:e})):[Qo];var i=-1;return t=Pt(t,Yt(ra())),function(e,t){var n=e.length;for(e.sort(t);n--;)e[n]=e[n].value;return e}(Di(e,(function(e,n,r){return{criteria:Pt(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=wr(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 Hi(e,t,n){for(var i=-1,r=t.length,a={};++i<r;){var s=t[i],o=bi(e,s);n(o,s)&&Ji(a,mr(s,e),o)}return a}function Vi(e,t,n,i){var r=i?Ft:Ut,a=-1,s=t.length,o=e;for(e===t&&(t=Er(t)),n&&(o=Pt(e,Yt(n)));++a<s;)for(var l=0,h=t[a],u=n?n(h):h;(l=r(o,u,l,i))>-1;)o!==e&&Ye.call(o,l,1),Ye.call(e,l,1);return e}function ji(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)?Ye.call(e,r,1):or(e,r)}}return e}function Gi(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(wa(e,t,Qo),e+"")}function Yi(e){return qn(No(e))}function qi(e,t){var n=No(e);return Ra(n,ri(t,0,n.length))}function Ji(e,t,i,r){if(!Js(e))return e;for(var a=-1,s=(t=mr(t,e)).length,o=s-1,l=e;null!=l&&++a<s;){var h=Ia(t[a]),u=i;if("__proto__"===h||"constructor"===h||"prototype"===h)return e;if(a!=o){var c=l[h];(u=r?r(c,h,l):n)===n&&(u=Js(c)?c:fa(t[a+1])?[]:{})}$n(l,h,u),l=l[h]}return e}var Zi=An?function(e,t){return An.set(e,t),e}:Qo,Ki=ot?function(e,t){return ot(e,"toString",{configurable:!0,enumerable:!1,value:Zo(t),writable:!0})}:Qo;function $i(e){return Ra(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),u=t===n;a<s;){var c=ft((a+s)/2),d=i(e[c]),p=d!==n,f=null===d,m=d==d,g=io(d);if(o)var v=r||m;else v=u?m&&(r||p):l?m&&p&&(r||!f):h?m&&p&&!f&&(r||!g):!f&&!g&&(r?d<=t:d<t);v?a=c+1:s=c}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||!Ds(o,l)){var l=o;a[r++]=0===s?0:s}}return a}function rr(e){return"number"==typeof e?e:io(e)?u:+e}function ar(e){if("string"==typeof e)return e;if(Bs(e))return Pt(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=Jt,l=new Wn}else l=t?[]:o;e:for(;++i<a;){var u=e[i],c=t?t(u):u;if(u=n||0!==u?u:0,s&&c==c){for(var d=l.length;d--;)if(l[d]===c)continue e;t&&l.push(c),o.push(u)}else r(l,c,n)||(l!==o&&l.push(c),o.push(u))}return o}function or(e,t){return null==(e=Sa(e,t=mr(t,e)))||delete e[Ia(Wa(t))]}function lr(e,t,n,i){return Ji(e,t,n(bi(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 ur(e,t){var n=e;return n instanceof Hn&&(n=n.value()),Lt(t,(function(e,t){return t.func.apply(t.thisArg,Rt([e],t.args))}),n)}function cr(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 Vs(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=je?je(n):new e.constructor(n);return e.copy(i),i}function br(e){var t=new e.constructor(e.byteLength);return new Ve(t).set(new Ve(e)),t}function _r(e,t){var n=t?br(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}function wr(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,u=io(t);if(!l&&!u&&!s&&e>t||s&&o&&h&&!l&&!u||r&&o&&h||!i&&h||!a)return 1;if(!r&&!s&&!u&&e<t||u&&i&&a&&!r&&!s||l&&i&&a||!o&&a||!h)return-1}return 0}function Sr(e,t,n,i){for(var r=-1,a=e.length,s=n.length,o=-1,l=t.length,h=mn(a-s,0),u=xe(l+h),c=!i;++o<l;)u[o]=t[o];for(;++r<s;)(c||r<a)&&(u[n[r]]=e[r]);for(;h--;)u[o++]=e[r++];return u}function Mr(e,t,n,i){for(var r=-1,a=e.length,s=-1,o=n.length,l=-1,h=t.length,u=mn(a-o,0),c=xe(u+h),d=!i;++r<u;)c[r]=e[r];for(var p=r;++l<h;)c[p+l]=t[l];for(;++s<o;)(d||r<a)&&(c[p+n[s]]=e[r++]);return c}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):$n(i,l,h)}return i}function Ar(e,t){return function(n,i){var r=Bs(n)?wt: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=Me(t);++r<a;){var l=i[r];l&&e(t,l,r,s)}return t}))}function Pr(e,t){return function(n,i){if(null==n)return n;if(!Hs(n))return e(n,i);for(var r=n.length,a=t?r:-1,s=Me(n);(t?a--:++a<r)&&!1!==i(s[a],a,s););return n}}function Rr(e){return function(t,n,i){for(var r=-1,a=Me(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 Ir(e){return function(t){return Lt(Yo(Bo(t).replace(qe,"")),e,"")}}function kr(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=Fn(e.prototype),i=e.apply(n,t);return Js(i)?i:n}}function Or(e){return function(t,i,r){var a=Me(t);if(!Hs(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 Dr(e){return $r((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]),u="wrapper"==h?ta(o):n;l=u&&va(u[0])&&424==u[1]&&!u[4].length&&1==u[9]?l[na(u[0])].apply(l,u[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,u,c){var d=t&o,p=1&t,f=2&t,m=24&t,g=512&t,v=f?n:kr(e);return function o(){for(var y=arguments.length,x=xe(y),b=y;b--;)x[b]=arguments[b];if(m)var _=ia(o),w=function(e,t){for(var n=e.length,i=0;n--;)e[n]===t&&++i;return i}(x,_);if(r&&(x=Sr(x,r,a,m)),s&&(x=Mr(x,s,l,m)),y-=w,m&&y<c){var S=an(x,_);return jr(e,t,Nr,o.placeholder,i,x,S,h,u,c-y)}var M=p?i:this,E=f?M[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&&u<y&&(x.length=u),this&&this!==ht&&this instanceof o&&(E=v||kr(E)),E.apply(M,x)}}function Ur(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 Fr(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 $r((function(t){return t=Pt(t,Yt(ra())),Xi((function(n){var i=this;return e(t,(function(e){return _t(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 Hr(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 Vr(e){return function(t,n){return"string"==typeof t&&"string"==typeof n||(t=co(t),n=co(n)),e(t,n)}}function jr(e,t,i,r,a,o,l,h,u,c){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,u,c],f=i.apply(n,p);return va(e)&&Ea(f,p),f.placeholder=r,Ca(f,e,t)}function Gr(e){var t=Se[e];return function(e,n){if(e=co(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=Mn&&1/sn(new Mn([,-0]))[1]==l?function(e){return new Mn(e)}:rl;function Xr(e){return function(t){var n=ua(t);return n==b?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 Pt(t,(function(t){return[t,e[t]]}))}(t,e(t))}}function Yr(e,t,r,l,h,u,c,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),c=c===n?c:mn(ho(c),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,u,c,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 u=e[3];e[3]=u?Sr(u,h,t[4]):h,e[4]=u?an(e[3],a):t[4]}(h=t[5])&&(u=e[5],e[5]=u?Mr(u,h,t[6]):h,e[6]=u?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=kr(e);return function a(){for(var s=arguments.length,o=xe(s),l=s,h=ia(a);l--;)o[l]=arguments[l];var u=s<3&&o[0]!==h&&o[s-1]!==h?[]:an(o,h);return(s-=u.length)<i?jr(e,t,Nr,a.placeholder,n,o,u,n,n,i-s):_t(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=kr(e);return function t(){for(var s=-1,o=arguments.length,l=-1,h=i.length,u=xe(h+o),c=this&&this!==ht&&this instanceof t?a:e;++l<h;)u[l]=i[l];for(;o--;)u[l++]=arguments[++s];return _t(c,r?n:this,u)}}(e,t,r,l);else var x=function(e,t,n){var i=1&t,r=kr(e);return function t(){return(this&&this!==ht&&this instanceof t?r:e).apply(i?n:this,arguments)}}(e,t,r);return Ca((v?Zi:Ea)(x,y),e,t)}function qr(e,t,i,r){return e===n||Ds(e,Re[i])&&!ke.call(r,i)?t:e}function Jr(e,t,i,r,a,s){return Js(e)&&Js(t)&&(s.set(t,e),Fi(e,t,n,Jr,s),s.delete(t)),e}function Zr(e){return Qs(e)?n:e}function Kr(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 u=s.get(e),c=s.get(t);if(u&&c)return u==t&&c==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(!kt(t,(function(e,t){if(!Jt(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 $r(e){return Aa(wa(e,n,za),e+"")}function Qr(e){return _i(e,Ao,la)}function ea(e){return _i(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=ke.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(ke.call(Un,"placeholder")?Un:e).placeholder}function ra(){var e=Un.iteratee||el;return e=e===el?Ii: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,ba(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=Me(e),Tt(Ot(e),(function(t){return Xe.call(e,t)})))}:cl,ha=Ot?function(e){for(var t=[];e;)Rt(t,la(e)),e=Ge(e);return t}:cl,ua=wi;function ca(e,t,n){for(var i=-1,r=(t=mr(t,e)).length,a=!1;++i<r;){var s=Ia(t[i]);if(!(a=null!=e&&n(e,s)))break;e=e[s]}return a||++i!=r?a:!!(r=null==e?0:e.length)&&qs(r)&&fa(s,r)&&(Bs(e)||Fs(e))}function da(e){return"function"!=typeof e.constructor||xa(e)?{}:Fn(Ge(e))}function pa(e){return Bs(e)||Fs(e)||!!(Ze&&e&&e[Ze])}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(!Js(n))return!1;var i=typeof t;return!!("number"==i?Hs(n)&&fa(t,n.length):"string"==i&&t in n)&&Ds(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))||K.test(e)||!Z.test(e)||null!=t&&e in Me(t)}function va(e){var t=na(e),n=Un[t];if("function"!=typeof n||!(t in Hn.prototype))return!1;if(e===n)return!0;var i=ta(n);return!!i&&e===i[0]}(_n&&ua(new _n(new ArrayBuffer(1)))!=R||wn&&ua(new wn)!=b||Sn&&ua(Sn.resolve())!=S||Mn&&ua(new Mn)!=E||En&&ua(new En)!=C)&&(ua=function(e){var t=wi(e),i=t==w?e.constructor:n,r=i?ka(i):"";if(r)switch(r){case Pn:return R;case Rn:return b;case Ln:return S;case In:return E;case kn:return C}return t});var ya=Le?Xs:dl;function xa(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||Re)}function ba(e){return e==e&&!Js(e)}function _a(e,t){return function(i){return null!=i&&i[e]===t&&(t!==n||e in Me(i))}}function wa(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),_t(e,this,o)}}function Sa(e,t){return t.length<2?e:bi(e,Qi(t,0,-1))}function Ma(e,t){if(("constructor"!==t||"function"!=typeof e[t])&&"__proto__"!=t)return e[t]}var Ea=Pa(Zi),Ta=ct||function(e,t){return ht.setTimeout(e,t)},Aa=Pa(Ki);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 St(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 Pa(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 Ra(e,t){var i=-1,r=e.length,a=r-1;for(t=t===n?r:t;++i<t;){var s=Gi(i,a),o=e[s];e[s]=e[i],e[i]=o}return e.length=t,e}var La=function(e){var t=Ps((function(e){var t=[];return 46===e.charCodeAt(0)&&t.push(""),e.replace($,(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 Ia(e){if("string"==typeof e||io(e))return e;var t=e+"";return"0"==t&&1/e==-l?"-0":t}function ka(e){if(null!=e){try{return Ie.call(e)}catch(e){}try{return e+""}catch(e){}}return""}function Oa(e){if(e instanceof Hn)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 Da=Xi((function(e,t){return Vs(e)?li(e,fi(t,1,Vs,!0)):[]})),Na=Xi((function(e,t){var i=Wa(t);return Vs(i)&&(i=n),Vs(e)?li(e,fi(t,1,Vs,!0),ra(i,2)):[]})),Ua=Xi((function(e,t){var i=Wa(t);return Vs(i)&&(i=n),Vs(e)?li(e,fi(t,1,Vs,!0),n,i):[]}));function Fa(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 Ha(e){return e&&e.length?e[0]:n}var Va=Xi((function(e){var t=Pt(e,pr);return t.length&&t[0]===e[0]?Ti(t):[]})),ja=Xi((function(e){var t=Wa(e),i=Pt(e,pr);return t===Wa(i)?t=n:i.pop(),i.length&&i[0]===e[0]?Ti(i,ra(t,2)):[]})),Ga=Xi((function(e){var t=Wa(e),i=Pt(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(Ya);function Ya(e,t){return e&&e.length&&t&&t.length?Vi(e,t):e}var qa=$r((function(e,t){var n=null==e?0:e.length,i=ii(e,t);return ji(e,Pt(t,(function(e){return fa(e,n)?+e:e})).sort(wr)),i}));function Ja(e){return null==e?e:bn.call(e)}var Za=Xi((function(e){return sr(fi(e,1,Vs,!0))})),Ka=Xi((function(e){var t=Wa(e);return Vs(t)&&(t=n),sr(fi(e,1,Vs,!0),ra(t,2))})),$a=Xi((function(e){var t=Wa(e);return t="function"==typeof t?t:n,sr(fi(e,1,Vs,!0),n,t)}));function Qa(e){if(!e||!e.length)return[];var t=0;return e=Tt(e,(function(e){if(Vs(e))return t=mn(e.length,t),!0})),Wt(t,(function(t){return Pt(e,Ht(t))}))}function es(e,t){if(!e||!e.length)return[];var i=Qa(e);return null==t?i:Pt(i,(function(e){return _t(t,n,e)}))}var ts=Xi((function(e,t){return Vs(e)?li(e,t):[]})),ns=Xi((function(e){return cr(Tt(e,Vs))})),is=Xi((function(e){var t=Wa(e);return Vs(t)&&(t=n),cr(Tt(e,Vs),ra(t,2))})),rs=Xi((function(e){var t=Wa(e);return t="function"==typeof t?t:n,cr(Tt(e,Vs),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=Un(e);return t.__chain__=!0,t}function ls(e,t){return t(e)}var hs=$r((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 Hn&&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)})),us=Ar((function(e,t,n){ke.call(e,n)?++e[n]:ni(e,n,1)})),cs=Or(Fa),ds=Or(Ba);function ps(e,t){return(Bs(e)?St:hi)(e,ra(t,3))}function fs(e,t){return(Bs(e)?Mt:ui)(e,ra(t,3))}var ms=Ar((function(e,t,n){ke.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=Hs(e)?xe(e.length):[];return hi(e,(function(e){a[++i]=r?_t(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)?Pt:Di)(e,ra(t,3))}var xs=Ar((function(e,t,n){e[n?0:1].push(t)}),(function(){return[[],[]]})),bs=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),[])})),_s=ut||function(){return ht.Date.now()};function ws(e,t,i){return t=i?n:t,t=e&&null==t?e.length:t,Yr(e,o,n,n,n,n,t)}function Ss(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 Ms=Xi((function(e,t,n){var i=1;if(n.length){var r=an(n,ia(Ms));i|=s}return Yr(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 Yr(t,i,e,n,r)}));function Ts(e,t,r){var a,s,o,l,h,u,c=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,c=t,l=e.apply(r,i)}function g(e){var i=e-u;return u===n||i>=t||i<0||p&&e-c>=o}function v(){var e=_s();if(g(e))return y(e);h=Ta(v,function(e){var n=t-(e-u);return p?gn(n,o-(e-c)):n}(e))}function y(e){return h=n,f&&a?m(e):(a=s=n,l)}function x(){var e=_s(),i=g(e);if(a=arguments,s=this,u=e,i){if(h===n)return function(e){return c=e,h=Ta(v,t),d?m(e):l}(u);if(p)return yr(h),h=Ta(v,t),m(u)}return h===n&&(h=Ta(v,t)),l}return t=co(t)||0,Js(r)&&(d=!!r.leading,o=(p="maxWait"in r)?mn(co(r.maxWait)||0,t):o,f="trailing"in r?!!r.trailing:f),x.cancel=function(){h!==n&&yr(h),c=0,a=u=s=h=n},x.flush=function(){return h===n?l:y(_s())},x}var As=Xi((function(e,t){return oi(e,1,t)})),Cs=Xi((function(e,t,n){return oi(e,co(t)||0,n)}));function Ps(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(Ps.Cache||Gn),n}function Rs(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)}}Ps.Cache=Gn;var Ls=gr((function(e,t){var n=(t=1==t.length&&Bs(t[0])?Pt(t[0],Yt(ra())):Pt(fi(t,1),Yt(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 _t(e,this,i)}))})),Is=Xi((function(e,t){var i=an(t,ia(Is));return Yr(e,s,n,t,i)})),ks=Xi((function(e,t){var i=an(t,ia(ks));return Yr(e,64,n,t,i)})),Os=$r((function(e,t){return Yr(e,256,n,n,n,t)}));function Ds(e,t){return e===t||e!=e&&t!=t}var Ns=Vr(Si),Us=Vr((function(e,t){return e>=t})),Fs=Ci(function(){return arguments}())?Ci:function(e){return Zs(e)&&ke.call(e,"callee")&&!Xe.call(e,"callee")},Bs=xe.isArray,zs=mt?Yt(mt):function(e){return Zs(e)&&wi(e)==P};function Hs(e){return null!=e&&qs(e.length)&&!Xs(e)}function Vs(e){return Zs(e)&&Hs(e)}var js=Vt||dl,Gs=gt?Yt(gt):function(e){return Zs(e)&&wi(e)==g};function Ws(e){if(!Zs(e))return!1;var t=wi(e);return t==v||"[object DOMException]"==t||"string"==typeof e.message&&"string"==typeof e.name&&!Qs(e)}function Xs(e){if(!Js(e))return!1;var t=wi(e);return t==y||t==x||"[object AsyncFunction]"==t||"[object Proxy]"==t}function Ys(e){return"number"==typeof e&&e==ho(e)}function qs(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=h}function Js(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function Zs(e){return null!=e&&"object"==typeof e}var Ks=vt?Yt(vt):function(e){return Zs(e)&&ua(e)==b};function $s(e){return"number"==typeof e||Zs(e)&&wi(e)==_}function Qs(e){if(!Zs(e)||wi(e)!=w)return!1;var t=Ge(e);if(null===t)return!0;var n=ke.call(t,"constructor")&&t.constructor;return"function"==typeof n&&n instanceof n&&Ie.call(n)==Ue}var eo=yt?Yt(yt):function(e){return Zs(e)&&wi(e)==M},to=xt?Yt(xt):function(e){return Zs(e)&&ua(e)==E};function no(e){return"string"==typeof e||!Bs(e)&&Zs(e)&&wi(e)==T}function io(e){return"symbol"==typeof e||Zs(e)&&wi(e)==A}var ro=bt?Yt(bt):function(e){return Zs(e)&&qs(e.length)&&!!nt[wi(e)]},ao=Vr(Oi),so=Vr((function(e,t){return e<=t}));function oo(e){if(!e)return[];if(Hs(e))return no(e)?ln(e):Er(e);if($e&&e[$e])return function(e){for(var t,n=[];!(t=e.next()).done;)n.push(t.value);return n}(e[$e]());var t=ua(e);return(t==b?nn:t==E?sn:No)(e)}function lo(e){return e?(e=co(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 uo(e){return e?ri(ho(e),0,c):0}function co(e){if("number"==typeof e)return e;if(io(e))return u;if(Js(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=Js(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):ce.test(e)?u:+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)||Hs(t))Tr(t,Ao(t),e);else for(var n in t)ke.call(t,n)&&$n(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=$r(ii),bo=Xi((function(e,t){e=Me(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 u=o[l],c=e[u];(c===n||Ds(c,Re[u])&&!ke.call(e,u))&&(e[u]=s[u])}return e})),_o=Xi((function(e){return e.push(n,Jr),_t(Ro,n,e)}));function wo(e,t,i){var r=null==e?n:bi(e,t);return r===n?i:r}function So(e,t){return null!=e&&ca(e,t,Ei)}var Mo=Ur((function(e,t,n){null!=t&&"function"!=typeof t.toString&&(t=Ne.call(t)),e[t]=n}),Zo(Qo)),Eo=Ur((function(e,t,n){null!=t&&"function"!=typeof t.toString&&(t=Ne.call(t)),ke.call(e,t)?e[t].push(n):e[t]=[n]}),ra),To=Xi(Ai);function Ao(e){return Hs(e)?Yn(e):ki(e)}function Co(e){return Hs(e)?Yn(e,!0):function(e){if(!Js(e))return function(e){var t=[];if(null!=e)for(var n in Me(e))t.push(n);return t}(e);var t=xa(e),n=[];for(var i in e)"constructor"==i&&(t||!ke.call(e,i))||n.push(i);return n}(e)}var Po=Cr((function(e,t,n){Fi(e,t,n)})),Ro=Cr((function(e,t,n,i){Fi(e,t,n,i)})),Lo=$r((function(e,t){var n={};if(null==e)return n;var i=!1;t=Pt(t,(function(t){return t=mr(t,e),i||(i=t.length>1),t})),Tr(e,ea(e),n),i&&(n=ai(n,7,Zr));for(var r=t.length;r--;)or(n,t[r]);return n})),Io=$r((function(e,t){return null==e?{}:function(e,t){return Hi(e,t,(function(t,n){return So(e,n)}))}(e,t)}));function ko(e,t){if(null==e)return{};var n=Pt(ea(e),(function(e){return[e]}));return t=ra(t),Hi(e,n,(function(e,n){return t(e,n[0])}))}var Oo=Xr(Ao),Do=Xr(Co);function No(e){return null==e?[]:qt(e,Ao(e))}var Uo=Ir((function(e,t,n){return t=t.toLowerCase(),e+(n?Fo(t):t)}));function Fo(e){return Xo(fo(e).toLowerCase())}function Bo(e){return(e=fo(e))&&e.replace(ge,$t).replace(Je,"")}var zo=Ir((function(e,t,n){return e+(n?"-":"")+t.toLowerCase()})),Ho=Ir((function(e,t,n){return e+(n?" ":"")+t.toLowerCase()})),Vo=Lr("toLowerCase"),jo=Ir((function(e,t,n){return e+(n?"_":"")+t.toLowerCase()})),Go=Ir((function(e,t,n){return e+(n?" ":"")+Xo(t)})),Wo=Ir((function(e,t,n){return e+(n?" ":"")+t.toUpperCase()})),Xo=Lr("toUpperCase");function Yo(e,t,i){return e=fo(e),(t=i?n:t)===n?function(e){return Qe.test(e)}(e)?function(e){return e.match(Ke)||[]}(e):function(e){return e.match(se)||[]}(e):e.match(t)||[]}var qo=Xi((function(e,t){try{return _t(e,n,t)}catch(e){return Ws(e)?e:new _e(e)}})),Jo=$r((function(e,t){return St(t,(function(t){t=Ia(t),ni(e,t,Ms(e[t],e))})),e}));function Zo(e){return function(){return e}}var Ko=Dr(),$o=Dr(!0);function Qo(e){return e}function el(e){return Ii("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&&(!Js(t)||!r.length&&i.length)&&(n=t,t=e,e=this,r=xi(t,Ao(t)));var a=!(Js(n)&&"chain"in n&&!n.chain),s=Xs(e);return St(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,Rt([this.value()],arguments))})})),e}function rl(){}var al=Br(Pt),sl=Br(Et),ol=Br(kt);function ll(e){return ga(e)?Ht(Ia(e)):function(e){return function(t){return bi(t,e)}}(e)}var hl=Hr(),ul=Hr(!0);function cl(){return[]}function dl(){return!1}var pl=Fr((function(e,t){return e+t}),0),fl=Gr("ceil"),ml=Fr((function(e,t){return e/t}),1),gl=Gr("floor"),vl=Fr((function(e,t){return e*t}),1),yl=Gr("round"),xl=Fr((function(e,t){return e-t}),0);return Un.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)}},Un.ary=ws,Un.assign=mo,Un.assignIn=go,Un.assignInWith=vo,Un.assignWith=yo,Un.at=xo,Un.before=Ss,Un.bind=Ms,Un.bindAll=Jo,Un.bindKey=Es,Un.castArray=function(){if(!arguments.length)return[];var e=arguments[0];return Bs(e)?e:[e]},Un.chain=os,Un.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},Un.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},Un.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 Rt(Bs(n)?Er(n):[n],fi(t,1))},Un.cond=function(e){var t=null==e?0:e.length,n=ra();return e=t?Pt(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(_t(r[0],this,n))return _t(r[1],this,n)}}))},Un.conforms=function(e){return function(e){var t=Ao(e);return function(n){return si(n,e,t)}}(ai(e,1))},Un.constant=Zo,Un.countBy=us,Un.create=function(e,t){var n=Fn(e);return null==t?n:ti(n,t)},Un.curry=function e(t,i,r){var a=Yr(t,8,n,n,n,n,n,i=r?n:i);return a.placeholder=e.placeholder,a},Un.curryRight=function e(t,i,r){var a=Yr(t,16,n,n,n,n,n,i=r?n:i);return a.placeholder=e.placeholder,a},Un.debounce=Ts,Un.defaults=bo,Un.defaultsDeep=_o,Un.defer=As,Un.delay=Cs,Un.difference=Da,Un.differenceBy=Na,Un.differenceWith=Ua,Un.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):[]},Un.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):[]},Un.dropRightWhile=function(e,t){return e&&e.length?hr(e,ra(t,3),!0,!0):[]},Un.dropWhile=function(e,t){return e&&e.length?hr(e,ra(t,3),!0):[]},Un.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:uo(r);i<r;)e[i++]=t;return e}(e,t,i,r)):[]},Un.filter=function(e,t){return(Bs(e)?Tt:pi)(e,ra(t,3))},Un.flatMap=function(e,t){return fi(ys(e,t),1)},Un.flatMapDeep=function(e,t){return fi(ys(e,t),l)},Un.flatMapDepth=function(e,t,i){return i=i===n?1:ho(i),fi(ys(e,t),i)},Un.flatten=za,Un.flattenDeep=function(e){return null!=e&&e.length?fi(e,l):[]},Un.flattenDepth=function(e,t){return null!=e&&e.length?fi(e,t=t===n?1:ho(t)):[]},Un.flip=function(e){return Yr(e,512)},Un.flow=Ko,Un.flowRight=$o,Un.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},Un.functions=function(e){return null==e?[]:xi(e,Ao(e))},Un.functionsIn=function(e){return null==e?[]:xi(e,Co(e))},Un.groupBy=ms,Un.initial=function(e){return null!=e&&e.length?Qi(e,0,-1):[]},Un.intersection=Va,Un.intersectionBy=ja,Un.intersectionWith=Ga,Un.invert=Mo,Un.invertBy=Eo,Un.invokeMap=gs,Un.iteratee=el,Un.keyBy=vs,Un.keys=Ao,Un.keysIn=Co,Un.map=ys,Un.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},Un.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},Un.matches=function(e){return Ni(ai(e,1))},Un.matchesProperty=function(e,t){return Ui(e,ai(t,1))},Un.memoize=Ps,Un.merge=Po,Un.mergeWith=Ro,Un.method=tl,Un.methodOf=nl,Un.mixin=il,Un.negate=Rs,Un.nthArg=function(e){return e=ho(e),Xi((function(t){return Bi(t,e)}))},Un.omit=Lo,Un.omitBy=function(e,t){return ko(e,Rs(ra(t)))},Un.once=function(e){return Ss(2,e)},Un.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))},Un.over=al,Un.overArgs=Ls,Un.overEvery=sl,Un.overSome=ol,Un.partial=Is,Un.partialRight=ks,Un.partition=xs,Un.pick=Io,Un.pickBy=ko,Un.property=ll,Un.propertyOf=function(e){return function(t){return null==e?n:bi(e,t)}},Un.pull=Xa,Un.pullAll=Ya,Un.pullAllBy=function(e,t,n){return e&&e.length&&t&&t.length?Vi(e,t,ra(n,2)):e},Un.pullAllWith=function(e,t,i){return e&&e.length&&t&&t.length?Vi(e,t,n,i):e},Un.pullAt=qa,Un.range=hl,Un.rangeRight=ul,Un.rearg=Os,Un.reject=function(e,t){return(Bs(e)?Tt:pi)(e,Rs(ra(t,3)))},Un.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 ji(e,r),n},Un.rest=function(e,t){if("function"!=typeof e)throw new Ae(i);return Xi(e,t=t===n?t:ho(t))},Un.reverse=Ja,Un.sampleSize=function(e,t,i){return t=(i?ma(e,t,i):t===n)?1:ho(t),(Bs(e)?Jn:qi)(e,t)},Un.set=function(e,t,n){return null==e?e:Ji(e,t,n)},Un.setWith=function(e,t,i,r){return r="function"==typeof r?r:n,null==e?e:Ji(e,t,i,r)},Un.shuffle=function(e){return(Bs(e)?Zn:$i)(e)},Un.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)):[]},Un.sortBy=bs,Un.sortedUniq=function(e){return e&&e.length?ir(e):[]},Un.sortedUniqBy=function(e,t){return e&&e.length?ir(e,ra(t,2)):[]},Un.split=function(e,t,i){return i&&"number"!=typeof i&&ma(e,t,i)&&(t=i=n),(i=i===n?c: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):[]},Un.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&&Rt(r,i),_t(e,this,r)}))},Un.tail=function(e){var t=null==e?0:e.length;return t?Qi(e,1,t):[]},Un.take=function(e,t,i){return e&&e.length?Qi(e,0,(t=i||t===n?1:ho(t))<0?0:t):[]},Un.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):[]},Un.takeRightWhile=function(e,t){return e&&e.length?hr(e,ra(t,3),!1,!0):[]},Un.takeWhile=function(e,t){return e&&e.length?hr(e,ra(t,3)):[]},Un.tap=function(e,t){return t(e),e},Un.throttle=function(e,t,n){var r=!0,a=!0;if("function"!=typeof e)throw new Ae(i);return Js(n)&&(r="leading"in n?!!n.leading:r,a="trailing"in n?!!n.trailing:a),Ts(e,t,{leading:r,maxWait:t,trailing:a})},Un.thru=ls,Un.toArray=oo,Un.toPairs=Oo,Un.toPairsIn=Do,Un.toPath=function(e){return Bs(e)?Pt(e,Ia):io(e)?[e]:Er(La(fo(e)))},Un.toPlainObject=po,Un.transform=function(e,t,n){var i=Bs(e),r=i||js(e)||ro(e);if(t=ra(t,4),null==n){var a=e&&e.constructor;n=r?i?new a:[]:Js(e)&&Xs(a)?Fn(Ge(e)):{}}return(r?St:vi)(e,(function(e,i,r){return t(n,e,i,r)})),n},Un.unary=function(e){return ws(e,1)},Un.union=Za,Un.unionBy=Ka,Un.unionWith=$a,Un.uniq=function(e){return e&&e.length?sr(e):[]},Un.uniqBy=function(e,t){return e&&e.length?sr(e,ra(t,2)):[]},Un.uniqWith=function(e,t){return t="function"==typeof t?t:n,e&&e.length?sr(e,n,t):[]},Un.unset=function(e,t){return null==e||or(e,t)},Un.unzip=Qa,Un.unzipWith=es,Un.update=function(e,t,n){return null==e?e:lr(e,t,fr(n))},Un.updateWith=function(e,t,i,r){return r="function"==typeof r?r:n,null==e?e:lr(e,t,fr(i),r)},Un.values=No,Un.valuesIn=function(e){return null==e?[]:qt(e,Co(e))},Un.without=ts,Un.words=Yo,Un.wrap=function(e,t){return Is(fr(t),e)},Un.xor=ns,Un.xorBy=is,Un.xorWith=rs,Un.zip=as,Un.zipObject=function(e,t){return dr(e||[],t||[],$n)},Un.zipObjectDeep=function(e,t){return dr(e||[],t||[],Ji)},Un.zipWith=ss,Un.entries=Oo,Un.entriesIn=Do,Un.extend=go,Un.extendWith=vo,il(Un,Un),Un.add=pl,Un.attempt=qo,Un.camelCase=Uo,Un.capitalize=Fo,Un.ceil=fl,Un.clamp=function(e,t,i){return i===n&&(i=t,t=n),i!==n&&(i=(i=co(i))==i?i:0),t!==n&&(t=(t=co(t))==t?t:0),ri(co(e),t,i)},Un.clone=function(e){return ai(e,4)},Un.cloneDeep=function(e){return ai(e,5)},Un.cloneDeepWith=function(e,t){return ai(e,5,t="function"==typeof t?t:n)},Un.cloneWith=function(e,t){return ai(e,4,t="function"==typeof t?t:n)},Un.conformsTo=function(e,t){return null==t||si(e,t,Ao(t))},Un.deburr=Bo,Un.defaultTo=function(e,t){return null==e||e!=e?t:e},Un.divide=ml,Un.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},Un.eq=Ds,Un.escape=function(e){return(e=fo(e))&&X.test(e)?e.replace(G,Qt):e},Un.escapeRegExp=function(e){return(e=fo(e))&&ee.test(e)?e.replace(Q,"\\$&"):e},Un.every=function(e,t,i){var r=Bs(e)?Et:ci;return i&&ma(e,t,i)&&(t=n),r(e,ra(t,3))},Un.find=cs,Un.findIndex=Fa,Un.findKey=function(e,t){return Dt(e,ra(t,3),vi)},Un.findLast=ds,Un.findLastIndex=Ba,Un.findLastKey=function(e,t){return Dt(e,ra(t,3),yi)},Un.floor=gl,Un.forEach=ps,Un.forEachRight=fs,Un.forIn=function(e,t){return null==e?e:mi(e,ra(t,3),Co)},Un.forInRight=function(e,t){return null==e?e:gi(e,ra(t,3),Co)},Un.forOwn=function(e,t){return e&&vi(e,ra(t,3))},Un.forOwnRight=function(e,t){return e&&yi(e,ra(t,3))},Un.get=wo,Un.gt=Ns,Un.gte=Us,Un.has=function(e,t){return null!=e&&ca(e,t,Mi)},Un.hasIn=So,Un.head=Ha,Un.identity=Qo,Un.includes=function(e,t,n,i){e=Hs(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&&Ut(e,t,n)>-1},Un.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)),Ut(e,t,r)},Un.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=co(e),t,i)},Un.invoke=To,Un.isArguments=Fs,Un.isArray=Bs,Un.isArrayBuffer=zs,Un.isArrayLike=Hs,Un.isArrayLikeObject=Vs,Un.isBoolean=function(e){return!0===e||!1===e||Zs(e)&&wi(e)==m},Un.isBuffer=js,Un.isDate=Gs,Un.isElement=function(e){return Zs(e)&&1===e.nodeType&&!Qs(e)},Un.isEmpty=function(e){if(null==e)return!0;if(Hs(e)&&(Bs(e)||"string"==typeof e||"function"==typeof e.splice||js(e)||ro(e)||Fs(e)))return!e.length;var t=ua(e);if(t==b||t==E)return!e.size;if(xa(e))return!ki(e).length;for(var n in e)if(ke.call(e,n))return!1;return!0},Un.isEqual=function(e,t){return Pi(e,t)},Un.isEqualWith=function(e,t,i){var r=(i="function"==typeof i?i:n)?i(e,t):n;return r===n?Pi(e,t,n,i):!!r},Un.isError=Ws,Un.isFinite=function(e){return"number"==typeof e&&dn(e)},Un.isFunction=Xs,Un.isInteger=Ys,Un.isLength=qs,Un.isMap=Ks,Un.isMatch=function(e,t){return e===t||Ri(e,t,sa(t))},Un.isMatchWith=function(e,t,i){return i="function"==typeof i?i:n,Ri(e,t,sa(t),i)},Un.isNaN=function(e){return $s(e)&&e!=+e},Un.isNative=function(e){if(ya(e))throw new _e("Unsupported core-js use. Try https://npms.io/search?q=ponyfill.");return Li(e)},Un.isNil=function(e){return null==e},Un.isNull=function(e){return null===e},Un.isNumber=$s,Un.isObject=Js,Un.isObjectLike=Zs,Un.isPlainObject=Qs,Un.isRegExp=eo,Un.isSafeInteger=function(e){return Ys(e)&&e>=-h&&e<=h},Un.isSet=to,Un.isString=no,Un.isSymbol=io,Un.isTypedArray=ro,Un.isUndefined=function(e){return e===n},Un.isWeakMap=function(e){return Zs(e)&&ua(e)==C},Un.isWeakSet=function(e){return Zs(e)&&"[object WeakSet]"==wi(e)},Un.join=function(e,t){return null==e?"":pn.call(e,t)},Un.kebabCase=zo,Un.last=Wa,Un.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)},Un.lowerCase=Ho,Un.lowerFirst=Vo,Un.lt=ao,Un.lte=so,Un.max=function(e){return e&&e.length?di(e,Qo,Si):n},Un.maxBy=function(e,t){return e&&e.length?di(e,ra(t,2),Si):n},Un.mean=function(e){return zt(e,Qo)},Un.meanBy=function(e,t){return zt(e,ra(t,2))},Un.min=function(e){return e&&e.length?di(e,Qo,Oi):n},Un.minBy=function(e,t){return e&&e.length?di(e,ra(t,2),Oi):n},Un.stubArray=cl,Un.stubFalse=dl,Un.stubObject=function(){return{}},Un.stubString=function(){return""},Un.stubTrue=function(){return!0},Un.multiply=vl,Un.nth=function(e,t){return e&&e.length?Bi(e,ho(t)):n},Un.noConflict=function(){return ht._===this&&(ht._=Fe),this},Un.noop=rl,Un.now=_s,Un.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)},Un.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},Un.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},Un.parseInt=function(e,t,n){return n||null==t?t=0:t&&(t=+t),yn(fo(e).replace(te,""),t||0)},Un.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 Gi(e,t)},Un.reduce=function(e,t,n){var i=Bs(e)?Lt:jt,r=arguments.length<3;return i(e,ra(t,4),n,r,hi)},Un.reduceRight=function(e,t,n){var i=Bs(e)?It:jt,r=arguments.length<3;return i(e,ra(t,4),n,r,ui)},Un.repeat=function(e,t,i){return t=(i?ma(e,t,i):t===n)?1:ho(t),Wi(fo(e),t)},Un.replace=function(){var e=arguments,t=fo(e[0]);return e.length<3?t:t.replace(e[1],e[2])},Un.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[Ia(t[r])];s===n&&(r=a,s=i),e=Xs(s)?s.call(e):s}return e},Un.round=yl,Un.runInContext=e,Un.sample=function(e){return(Bs(e)?qn:Yi)(e)},Un.size=function(e){if(null==e)return 0;if(Hs(e))return no(e)?on(e):e.length;var t=ua(e);return t==b||t==E?e.size:ki(e).length},Un.snakeCase=jo,Un.some=function(e,t,i){var r=Bs(e)?kt:er;return i&&ma(e,t,i)&&(t=n),r(e,ra(t,3))},Un.sortedIndex=function(e,t){return tr(e,t)},Un.sortedIndexBy=function(e,t,n){return nr(e,t,ra(n,2))},Un.sortedIndexOf=function(e,t){var n=null==e?0:e.length;if(n){var i=tr(e,t);if(i<n&&Ds(e[i],t))return i}return-1},Un.sortedLastIndex=function(e,t){return tr(e,t,!0)},Un.sortedLastIndexBy=function(e,t,n){return nr(e,t,ra(n,2),!0)},Un.sortedLastIndexOf=function(e,t){if(null!=e&&e.length){var n=tr(e,t,!0)-1;if(Ds(e[n],t))return n}return-1},Un.startCase=Go,Un.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},Un.subtract=xl,Un.sum=function(e){return e&&e.length?Gt(e,Qo):0},Un.sumBy=function(e,t){return e&&e.length?Gt(e,ra(t,2)):0},Un.template=function(e,t,i){var r=Un.templateSettings;i&&ma(e,t,i)&&(t=n),e=fo(e),t=vo({},t,r,qr);var a,s,o=vo({},t.imports,r.imports,qr),l=Ao(o),h=qt(o,l),u=0,c=t.interpolate||ve,d="__p += '",p=Ee((t.escape||ve).source+"|"+c.source+"|"+(c===J?he:ve).source+"|"+(t.evaluate||ve).source+"|$","g"),f="//# sourceURL="+(ke.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(u,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'"),u=l+t.length,t})),d+="';\n";var m=ke.call(t,"variable")&&t.variable;if(m){if(oe.test(m))throw new _e("Invalid `variable` option passed into `_.template`")}else d="with (obj) {\n"+d+"\n}\n";d=(s?d.replace(z,""):d).replace(H,"$1").replace(V,"$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=qo((function(){return we(l,f+"return "+d).apply(n,h)}));if(g.source=d,Ws(g))throw g;return g},Un.times=function(e,t){if((e=ho(e))<1||e>h)return[];var n=c,i=gn(e,c);t=ra(t),e-=c;for(var r=Wt(i,t);++n<e;)t(n);return r},Un.toFinite=lo,Un.toInteger=ho,Un.toLength=uo,Un.toLower=function(e){return fo(e).toLowerCase()},Un.toNumber=co,Un.toSafeInteger=function(e){return e?ri(ho(e),-h,h):0===e?e:0},Un.toString=fo,Un.toUpper=function(e){return fo(e).toUpperCase()},Un.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,Zt(r,a),Kt(r,a)+1).join("")},Un.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,Kt(r,ln(t))+1).join("")},Un.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,Zt(r,ln(t))).join("")},Un.truncate=function(e,t){var i=30,r="...";if(Js(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 u,c=h;for(a.global||(a=Ee(a.source,fo(ue.exec(a))+"g")),a.lastIndex=0;u=a.exec(c);)var d=u.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},Un.unescape=function(e){return(e=fo(e))&&W.test(e)?e.replace(j,un):e},Un.uniqueId=function(e){var t=++Oe;return fo(e)+t},Un.upperCase=Wo,Un.upperFirst=Xo,Un.each=ps,Un.eachRight=fs,Un.first=Ha,il(Un,function(){var e={};return vi(Un,(function(t,n){ke.call(Un.prototype,n)||(e[n]=t)})),e}(),{chain:!1}),Un.VERSION="4.17.21",St(["bind","bindKey","curry","curryRight","partial","partialRight"],(function(e){Un[e].placeholder=Un})),St(["drop","take"],(function(e,t){Hn.prototype[e]=function(i){i=i===n?1:mn(ho(i),0);var r=this.__filtered__&&!t?new Hn(this):this.clone();return r.__filtered__?r.__takeCount__=gn(i,r.__takeCount__):r.__views__.push({size:gn(i,c),type:e+(r.__dir__<0?"Right":"")}),r},Hn.prototype[e+"Right"]=function(t){return this.reverse()[e](t).reverse()}})),St(["filter","map","takeWhile"],(function(e,t){var n=t+1,i=1==n||3==n;Hn.prototype[e]=function(e){var t=this.clone();return t.__iteratees__.push({iteratee:ra(e,3),type:n}),t.__filtered__=t.__filtered__||i,t}})),St(["head","last"],(function(e,t){var n="take"+(t?"Right":"");Hn.prototype[e]=function(){return this[n](1).value()[0]}})),St(["initial","tail"],(function(e,t){var n="drop"+(t?"":"Right");Hn.prototype[e]=function(){return this.__filtered__?new Hn(this):this[n](1)}})),Hn.prototype.compact=function(){return this.filter(Qo)},Hn.prototype.find=function(e){return this.filter(e).head()},Hn.prototype.findLast=function(e){return this.reverse().find(e)},Hn.prototype.invokeMap=Xi((function(e,t){return"function"==typeof e?new Hn(this):this.map((function(n){return Ai(n,e,t)}))})),Hn.prototype.reject=function(e){return this.filter(Rs(ra(e)))},Hn.prototype.slice=function(e,t){e=ho(e);var i=this;return i.__filtered__&&(e>0||t<0)?new Hn(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)},Hn.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},Hn.prototype.toArray=function(){return this.take(c)},vi(Hn.prototype,(function(e,t){var i=/^(?:filter|find|map|reject)|While$/.test(t),r=/^(?:head|last)$/.test(t),a=Un[r?"take"+("last"==t?"Right":""):t],s=r||/^find/.test(t);a&&(Un.prototype[t]=function(){var t=this.__wrapped__,o=r?[1]:arguments,l=t instanceof Hn,h=o[0],u=l||Bs(t),c=function(e){var t=a.apply(Un,Rt([e],o));return r&&d?t[0]:t};u&&i&&"function"==typeof h&&1!=h.length&&(l=u=!1);var d=this.__chain__,p=!!this.__actions__.length,f=s&&!d,m=l&&!p;if(!s&&u){t=m?t:new Hn(this);var g=e.apply(t,o);return g.__actions__.push({func:ls,args:[c],thisArg:n}),new zn(g,d)}return f&&m?e.apply(this,o):(g=this.thru(c),f?r?g.value()[0]:g.value():g)})})),St(["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);Un.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(Hn.prototype,(function(e,t){var n=Un[t];if(n){var i=n.name+"";ke.call(Cn,i)||(Cn[i]=[]),Cn[i].push({name:t,func:n})}})),Cn[Nr(n,2).name]=[{name:"wrapper",func:n}],Hn.prototype.clone=function(){var e=new Hn(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},Hn.prototype.reverse=function(){if(this.__filtered__){var e=new Hn(this);e.__dir__=-1,e.__filtered__=!0}else(e=this.clone()).__dir__*=-1;return e},Hn.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,u=this.__iteratees__,c=u.length,d=0,p=gn(l,this.__takeCount__);if(!n||!i&&r==l&&p==l)return ur(e,this.__actions__);var f=[];e:for(;l--&&d<p;){for(var m=-1,g=e[h+=t];++m<c;){var v=u[m],y=v.iteratee,x=v.type,b=y(g);if(2==x)g=b;else if(!b){if(1==x)continue e;break e}}f[d++]=g}return f},Un.prototype.at=hs,Un.prototype.chain=function(){return os(this)},Un.prototype.commit=function(){return new zn(this.value(),this.__chain__)},Un.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__++]}},Un.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},Un.prototype.reverse=function(){var e=this.__wrapped__;if(e instanceof Hn){var t=e;return this.__actions__.length&&(t=new Hn(this)),(t=t.reverse()).__actions__.push({func:ls,args:[Ja],thisArg:n}),new zn(t,this.__chain__)}return this.thru(Ja)},Un.prototype.toJSON=Un.prototype.valueOf=Un.prototype.value=function(){return ur(this.__wrapped__,this.__actions__)},Un.prototype.first=Un.prototype.head,$e&&(Un.prototype[$e]=function(){return this}),Un}();"function"==typeof define&&"object"==typeof define.amd&&define.amd?(ht._=cn,define((function(){return cn}))):ct?((ct.exports=cn)._=cn,ut._=cn):ht._=cn}).call(e)})),_pe=J(((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),u=.5*Math.exp(2*h/3),c=.5*Math.sqrt(h*u*(o-u)/o)*(l-o/2<0?-1:1);e(n,i,Math.max(r,Math.floor(i-l*u/o+c)),Math.min(a,Math.floor(i+(o-l)*u/o+c)),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 u(e){return(e.maxX-e.minX)*(e.maxY-e.minY)}function c(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 u=r(e,s.children,t);if(-1!==u)return s.children.splice(u,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 u=t;u<=n;u+=h){var c=Math.min(u+h-1,n);m(e,u,c,l,this.compareMinY);for(var d=u;d<=c;d+=l){var p=Math.min(d+l-1,c);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=u(l),c=(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);c<a?(a=c,r=h<r?h:r,s=l):c===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,c,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),c=Math.min(r.maxY,a.maxY),Math.max(0,h-o)*Math.max(0,c-l)),y=u(m)+u(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=c(a)+c(l),u=t;u<n-t;u++){var d=e.children[u];o(a,e.leaf?r(d):d),h+=c(a)}for(var p=n-t-1;p>=t;p--){var f=e.children[p];o(l,e.leaf?r(f):f),h+=c(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()})),Tpe=J(((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()})),Spe=J(((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 u=t[n+2*l+0],c=t[n+2*l+1],d=t[n+2*h+0],p=t[n+2*h+1];c>a!=p>a&&r<(d-u)*(a-c)/(p-c)+u&&(s=!s)}return s}})),Ape=J(((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 u=t[l+n][0],c=t[l+n][1],d=t[h+n][0],p=t[h+n][1];c>a!=p>a&&r<(d-u)*(a-c)/(p-c)+u&&(s=!s)}return s}})),Ppe=J(((e,t)=>{var n=Spe(),i=Ape();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})),Lpe=J(((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],u=i[0],c=0,d=0;u>h==u>-h?(a=h,h=t[++c]):(a=u,u=i[++d]);let p=0;if(c<e&&d<n)for(u>h==u>-h?(o=a-((s=h+a)-h),h=t[++c]):(o=a-((s=u+a)-u),u=i[++d]),a=s,0!==o&&(r[p++]=o);c<e&&d<n;)u>h==u>-h?(o=a-((s=a+h)-(l=s-a))+(h-l),h=t[++c]):(o=a-((s=a+u)-(l=s-a))+(u-l),u=i[++d]),a=s,0!==o&&(r[p++]=o);for(;c<e;)o=a-((s=a+h)-(l=s-a))+(h-l),h=t[++c],a=s,0!==o&&(r[p++]=o);for(;d<n;)o=a-((s=a+u)-(l=s-a))+(u-l),u=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,u,c){let d=(n-c)*(l-u),p=(e-u)*(h-c),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,u,c,d){let p,f,m,g,v,y,x,b,_,w,S,M,E,T,A,C,P,R,L=e-u,I=l-u,k=n-c,O=h-c;v=(A=(b=L-(x=(y=134217729*L)-(y-L)))*(w=O-(_=(y=134217729*O)-(y-O)))-((T=L*O)-x*_-b*_-x*w))-(S=A-(P=(b=k-(x=(y=134217729*k)-(y-k)))*(w=I-(_=(y=134217729*I)-(y-I)))-((C=k*I)-x*_-b*_-x*w))),i[0]=A-(S+v)+(v-P),v=(E=T-((M=T+S)-(v=M-T))+(S-v))-(S=E-C),i[1]=E-(S+v)+(v-C),v=(R=M+S)-M,i[2]=M-(R-v)+(S-v),i[3]=R;let D=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(D>=N||-D>=N||(p=e-(L+(v=e-L))+(v-u),m=l-(I+(v=l-I))+(v-u),f=n-(k+(v=n-k))+(v-c),g=h-(O+(v=h-O))+(v-c),0===p&&0===f&&0===m&&0===g)||(N=11093356479670487e-47*d+33306690738754706e-32*Math.abs(D),(D+=L*g+O*p-(k*m+I*f))>=N||-D>=N))return D;v=(A=(b=p-(x=(y=134217729*p)-(y-p)))*(w=O-(_=(y=134217729*O)-(y-O)))-((T=p*O)-x*_-b*_-x*w))-(S=A-(P=(b=f-(x=(y=134217729*f)-(y-f)))*(w=I-(_=(y=134217729*I)-(y-I)))-((C=f*I)-x*_-b*_-x*w))),o[0]=A-(S+v)+(v-P),v=(E=T-((M=T+S)-(v=M-T))+(S-v))-(S=E-C),o[1]=E-(S+v)+(v-C),v=(R=M+S)-M,o[2]=M-(R-v)+(S-v),o[3]=R;let U=t(4,i,4,o,r);v=(A=(b=L-(x=(y=134217729*L)-(y-L)))*(w=g-(_=(y=134217729*g)-(y-g)))-((T=L*g)-x*_-b*_-x*w))-(S=A-(P=(b=k-(x=(y=134217729*k)-(y-k)))*(w=m-(_=(y=134217729*m)-(y-m)))-((C=k*m)-x*_-b*_-x*w))),o[0]=A-(S+v)+(v-P),v=(E=T-((M=T+S)-(v=M-T))+(S-v))-(S=E-C),o[1]=E-(S+v)+(v-C),v=(R=M+S)-M,o[2]=M-(R-v)+(S-v),o[3]=R;let F=t(U,r,4,o,a);v=(A=(b=p-(x=(y=134217729*p)-(y-p)))*(w=g-(_=(y=134217729*g)-(y-g)))-((T=p*g)-x*_-b*_-x*w))-(S=A-(P=(b=f-(x=(y=134217729*f)-(y-f)))*(w=m-(_=(y=134217729*m)-(y-m)))-((C=f*m)-x*_-b*_-x*w))),o[0]=A-(S+v)+(v-P),v=(E=T-((M=T+S)-(v=M-T))+(S-v))-(S=E-C),o[1]=E-(S+v)+(v-C),v=(R=M+S)-M,o[2]=M-(R-v)+(S-v),o[3]=R;let B=t(F,a,4,o,s);return s[B-1]}(e,n,l,h,u,c,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={})})),Bpe=J(((e,t)=>{"use strict";var n=_pe(),i=Tpe(),r=Ppe(),a=Lpe().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=[],u=0;u<a.length;u++){var c=a[u];s.remove(c),l=m(c,l),h.push(l)}var p=new n(16);for(u=0;u<h.length;u++)p.insert(f(h[u]));for(var v=t*t,y=i*i;h.length;){var b=h.shift(),_=b.p,w=b.next.p,S=g(_,w);if(!(S<y)){var M=S/v;(c=o(s,b.prev.p,_,w,b.next.next.p,M,p))&&Math.min(g(c,_),g(c,w))<=M&&(h.push(b),h.push(m(c,b)),s.remove(c),p.remove(b),p.insert(f(b)),p.insert(f(b.next)))}}b=l;var E=[];do{E.push(b.p),b=b.next}while(b!==l);return E.push(b.p),E}function o(e,t,n,r,a,s,o){for(var u=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||u.push({node:f,dist:m})}for(;u.length&&!u.peek().node.children;){var g=u.pop(),y=g.node,x=v(y,t,n),b=v(y,r,a);if(g.dist<x&&g.dist<b&&c(n,y,o)&&c(r,y,o))return y}(d=u.pop())&&(d=d.node)}return null}function l(e,t){return e.dist-t.dist}function h(e,t,n){if(u(e,n)||u(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 u(e,t){return e[0]>=t.minX&&e[0]<=t.maxX&&e[1]>=t.minY&&e[1]<=t.maxY}function c(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,u,c,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,b=f*f+m*m,_=d*g+p*v,w=f*g+m*v,S=y*b-x*x,M=S,E=S;0===S?(h=0,M=1,c=w,E=b):(c=y*w-x*_,(h=x*w-b*_)<0?(h=0,c=w,E=b):h>M&&(h=M,c=w+x,E=b)),c<0?(c=0,-_<0?h=0:-_>y?h=M:(h=-_,M=y)):c>E&&(c=E,-_+x<0?h=0:-_+x>y?h=M:(h=-_+x,M=y));var T=(1-(u=0===c?0:c/E))*r+u*s-((1-(l=0===h?0:h/M))*e+l*n),A=(1-u)*a+u*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})),sme=J(((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")}}}})),ome=J(((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 u=t[0]-i[0],c=t[1]-i[1],d=(o*c-l*u)/h,p=(a*c-s*u)/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],u=n[l][1];u-r>e!=s-r>e&&(a-h)*(r-u)/(s-u)+h-i>e&&(o=!o),a=h,s=u}return o}};return t}})),cme=J(((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}}})),hme=J(((e,t)=>{var n=cme();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 u(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 u(e,n){var r=e.seg,a=n.seg,s=r.start,o=r.end,l=a.start,u=a.end;i&&i.checkIntersection(r,a);var c=t.linesIntersect(s,o,l,u);if(!1===c){if(!t.pointsCollinear(s,o,l)||t.pointsSame(s,u)||t.pointsSame(o,l))return!1;var d=t.pointsSame(s,l),p=t.pointsSame(o,u);if(d&&p)return n;var f=!d&&t.pointBetween(s,l,u),m=!p&&t.pointBetween(o,l,u);if(d)return m?h(n,o):h(e,u),n;f&&(p||(m?h(n,o):h(e,u)),h(n,s))}else 0===c.alongA&&(-1===c.alongB?h(e,l):0===c.alongB?h(e,c.pt):1===c.alongB&&h(e,u)),0===c.alongB&&(-1===c.alongA?h(n,s):0===c.alongA?h(n,c.pt):1===c.alongA&&h(n,o));return!1}for(var c=[];!s.isEmpty();){var d=s.getHead();if(i&&i.vert(d.pt[0]),d.isStart){let t=function(){if(f){var e=u(d,f);if(e)return e}return!!m&&u(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)&&u(x.prev.ev,x.next.ev),i&&i.statusRemove(x.ev.seg),x.remove(),!d.primary){var b=d.seg.myFill;d.seg.myFill=d.seg.otherFill,d.seg.otherFill=b}c.push(d.seg)}s.getHead().remove()}return i&&i.done(),c}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 u(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)})),u(t,i)}}}})),fme=J(((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,u=0;u<i.length;u++){var c=(g=i[u])[0],d=(g[1],g[g.length-1]);if(g[g.length-2],t.pointsSame(c,a)){if(M(u,!0,!0))break}else if(t.pointsSame(c,s)){if(M(u,!0,!1))break}else if(t.pointsSame(d,a)){if(M(u,!1,!0))break}else if(t.pointsSame(d,s)&&M(u,!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],b=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(b,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 _=o.index,w=l.index;n&&n.chainConnect(_,w);var S=i[_].length<i[w].length;o.matches_head?l.matches_head?S?(E(_),T(_,w)):(E(w),T(w,_)):T(w,_):l.matches_head?T(_,w):S?(E(_),T(w,_)):(E(w),T(_,w))}function M(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],u=s[1];t.pointsCollinear(l,o,h)&&(n&&n.chainRemoveTail(e,o),a.pop(),o=l),t.pointsCollinear(o,h,u)&&(n&&n.chainRemoveHead(r,h),s.shift()),n&&n.chainJoin(e,r),i[e]=a.concat(s),i.splice(r,1)}})),r}})),mme=J(((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})),vme=J(((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 u=[];function c(e){var t=[h(e.region,!1)];u.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++)c(e.children[t]);return h(e.region,!0)}for(o=0;o<a.children.length;o++)c(a.children[o]);return u.length<=0?{type:"Polygon",coordinates:[]}:1==u.length?{type:"Polygon",coordinates:u[0]}:{type:"MultiPolygon",coordinates:u}}};t.exports=n})),Eme=J(((e,t)=>{var n,i=sme(),r=ome(),a=hme(),s=fme(),o=mme(),l=vme(),h=!1,u=r();function c(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 u.epsilon(e)},segments:function(e){var t=a(!0,u,h);return e.regions.forEach(t.addRegion),{segments:t.calculate(e.inverted),inverted:e.inverted}},combine:function(e,t){return{combined:a(!1,u,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,u,h),inverted:e.inverted}},polygonFromGeoJSON:function(e){return l.toPolygon(n,e)},polygonToGeoJSON:function(e){return l.fromPolygon(n,u,e)},union:function(e,t){return c(e,t,n.selectUnion)},intersect:function(e,t){return c(e,t,n.selectIntersect)},difference:function(e,t){return c(e,t,n.selectDifference)},differenceRev:function(e,t){return c(e,t,n.selectDifferenceRev)},xor:function(e,t){return c(e,t,n.selectXor)}},"object"==typeof window&&(window.PolyBool=n),t.exports=n})),dC=J((()=>{})),Sve=J(((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=u(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=c({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 u(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=u(e,t,n,s),h.right=u(e,t,s+1,r),h}return null}function c(e,t,n){var i=n-t;if(i>0){var r=t+Math.floor(i/2),a=c(e,t,r),s=e.head;return s.left=a,e.head=e.head.next,s.right=c(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}(),b=new y,_=function(e,t){return e.x*t.y-e.y*t.x},w=function(e,t){return e.x*t.x+e.y*t.y},S=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=_(i,r);return v(a,0)},M=function(e){return Math.sqrt(w(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 _(r,i)/M(r)/M(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 w(r,i)/M(r)/M(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)}},P=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}(),R=0,L=function(){function t(n,i,r,a){e(this,t),this.id=++R,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 u=e.comparePoint(t.leftSE.point);if(u<0)return 1;if(u>0)return-1;var c=t.comparePoint(e.rightSE.point);return 0!==c?c:-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),u=p(t,o)&&0===this.comparePoint(o),c=p(n,a)&&0===e.comparePoint(a);if(h&&l)return c&&!u?a:!c&&u?o:null;if(h)return u&&r.x===o.x&&r.y===o.y?null:r;if(l)return c&&a.x===s.x&&a.y===s.y?null:s;if(c&&u)return null;if(c)return a;if(u)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=_(t,i);if(0==r)return null;var a={x:n.x-e.x,y:n.y-e.y},s=_(a,t)/r,o=_(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)?b.round(d.x,d.y):null}},{key:"split",value:function(e){var n=[],i=void 0!==e.events,r=new P(e,!0),a=new P(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 P.comparePoints(o.leftSE.point,o.rightSE.point)>0&&o.swapEvents(),P.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],u=i.windings[o],c=n.rings.indexOf(h);-1===c?(n.rings.push(h),n.windings.push(u)):n.windings[c]+=u}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=[],u=[],c=0,d=t.length;c<d;c++)if(0!==n[c]){var p=t[c],f=p.poly;if(-1===u.indexOf(f))if(p.isExterior)h.push(f);else{-1===u.indexOf(f)&&u.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(H.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===H.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(H.type))}return this._isInResult}}],[{key:"fromRing",value:function(e,n,i){var r,a,s,o=P.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 P(r,!0),new P(a,!1),[i],[s])}}]),t}(),I=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=b.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=b.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}(),k=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 I(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 I(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 k(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}(),D=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],u=o.point,c=[];s=o,o=l,h.push(o),o.point!==u;)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=c.length;g<v;g++)if(c[g].point===o.point){m=g;break}if(null===m){c.push({index:h.length,point:o.point});var y=o.getLeftmostComparator(s);l=d.sort(y)[0].otherSE;break}var x=c.splice(m)[0],b=h.splice(x.index);b.unshift(b[0].otherSE),n.push(new t(b.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!==S(r,e,a)&&(t.push(r),e=r)}if(1===t.length)return null;var s=t[0],o=t[1];0===S(s,e,o)&&t.shift(),t.push(t[0]);for(var l=this.isExteriorRing()?1:-1,h=this.isExteriorRing()?0:t.length-1,u=this.isExteriorRing()?t.length:-1,c=[],d=h;d!=u;d+=l)c.push([t[d].x,t[d].y]);return c}},{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];P.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}(),U=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}(),F=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 u=this._splitSafely(s,h),c=0,d=u.length;c<d;c++)n.push(u[c])}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||P.comparePoints(l,p)<=0?l:p,this.queue.remove(t.rightSE),n.push(t.rightSE);for(var x=t.split(y),b=0,_=x.length;b<_;b++)n.push(x[b])}n.length>0?(this.tree.remove(t),n.push(e)):(this.segments.push(t),t.prev=s)}else{if(s&&o){var w=s.getIntersection(o);if(null!==w){if(!s.isAnEndpoint(w))for(var S=this._splitSafely(s,w),M=0,E=S.length;M<E;M++)n.push(S[M]);if(!o.isAnEndpoint(w))for(var T=this._splitSafely(o,w),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,H=new(function(){function t(){e(this,t)}return n(t,[{key:"run",value:function(e,t,n){H.type=e,b.reset();for(var i=[new O(t,!0)],r=0,a=n.length;r<a;r++)i.push(new O(n[r],!1));if(H.numMultiPolys=i.length,"difference"===H.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"===H.type)for(var l=0,u=i.length;l<u;l++)for(var c=i[l],d=l+1,p=i.length;d<p;d++)if(null===f(c.bbox,i[d].bbox))return[];for(var m=new h(P.compare),g=0,v=i.length;g<v;g++)for(var y=i[g].getSweepEvents(),x=0,_=y.length;x<_;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 w=new F(m),S=m.size,M=m.pop();M;){var E=M.key;if(m.size===S){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(w.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=w.process(E),C=0,R=A.length;C<R;C++){var L=A[C];void 0===L.consumedBy&&m.insert(L)}S=m.size,M=m.pop()}b.reset();var I=D.factory(w.segments);return new U(I).getGeom()}}]),t}()),V={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 H.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 H.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 H.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 H.run("difference",e,n)}};return V},"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()})),x1e=J(((e,t)=>{!function(){"use strict";var e,n={version:"6.4.2.2",use_lines:!0,use_xyz:!1},i=!1;if(void 0!==t&&t.exports?(t.exports=n,i=!0):("function"==typeof define&&define.amd&&define(n),"undefined"!=typeof document?window.ClipperLib=n:self.ClipperLib=n),i){var r="chrome";e="Netscape"}else r=navigator.userAgent.toString().toLowerCase(),e=navigator.appName;var a,s={};function o(e,t,i){n.biginteger_used=1,null!=e&&("number"==typeof e&&void 0===t?this.fromInt(e):"number"==typeof e?this.fromNumber(e,t,i):null==t&&"string"!=typeof e?this.fromString(e,256):this.fromString(e,t))}function l(){return new o(null,void 0,void 0)}-1!=r.indexOf("chrome")&&-1==r.indexOf("chromium")?s.chrome=1:s.chrome=0,-1!=r.indexOf("chromium")?s.chromium=1:s.chromium=0,-1!=r.indexOf("safari")&&-1==r.indexOf("chrome")&&-1==r.indexOf("chromium")?s.safari=1:s.safari=0,-1!=r.indexOf("firefox")?s.firefox=1:s.firefox=0,-1!=r.indexOf("firefox/17")?s.firefox17=1:s.firefox17=0,-1!=r.indexOf("firefox/15")?s.firefox15=1:s.firefox15=0,-1!=r.indexOf("firefox/3")?s.firefox3=1:s.firefox3=0,-1!=r.indexOf("opera")?s.opera=1:s.opera=0,-1!=r.indexOf("msie 10")?s.msie10=1:s.msie10=0,-1!=r.indexOf("msie 9")?s.msie9=1:s.msie9=0,-1!=r.indexOf("msie 8")?s.msie8=1:s.msie8=0,-1!=r.indexOf("msie 7")?s.msie7=1:s.msie7=0,-1!=r.indexOf("msie ")?s.msie=1:s.msie=0,n.biginteger_used=null,"Microsoft Internet Explorer"==e?(o.prototype.am=function(e,t,n,i,r,a){for(var s=32767&t,o=t>>15;--a>=0;){var l=32767&this[e],h=this[e++]>>15,u=o*l+h*s;r=((l=s*l+((32767&u)<<15)+n[i]+(1073741823&r))>>>30)+(u>>>15)+o*h+(r>>>30),n[i++]=1073741823&l}return r},a=30):"Netscape"!=e?(o.prototype.am=function(e,t,n,i,r,a){for(;--a>=0;){var s=t*this[e++]+n[i]+r;r=Math.floor(s/67108864),n[i++]=67108863&s}return r},a=26):(o.prototype.am=function(e,t,n,i,r,a){for(var s=16383&t,o=t>>14;--a>=0;){var l=16383&this[e],h=this[e++]>>14,u=o*l+h*s;r=((l=s*l+((16383&u)<<14)+n[i]+r)>>28)+(u>>14)+o*h,n[i++]=268435455&l}return r},a=28),o.prototype.DB=a,o.prototype.DM=(1<<a)-1,o.prototype.DV=1<<a,o.prototype.FV=Math.pow(2,52),o.prototype.F1=52-a,o.prototype.F2=2*a-52;var h,u,c=new Array;for(h="0".charCodeAt(0),u=0;u<=9;++u)c[h++]=u;for(h="a".charCodeAt(0),u=10;u<36;++u)c[h++]=u;for(h="A".charCodeAt(0),u=10;u<36;++u)c[h++]=u;function d(e){return"0123456789abcdefghijklmnopqrstuvwxyz".charAt(e)}function p(e,t){var n=c[e.charCodeAt(t)];return null==n?-1:n}function f(e){var t=l();return t.fromInt(e),t}function m(e){var t,n=1;return 0!=(t=e>>>16)&&(e=t,n+=16),0!=(t=e>>8)&&(e=t,n+=8),0!=(t=e>>4)&&(e=t,n+=4),0!=(t=e>>2)&&(e=t,n+=2),0!=(t=e>>1)&&(e=t,n+=1),n}function g(e){this.m=e}function v(e){this.m=e,this.mp=e.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<<e.DB-15)-1,this.mt2=2*e.t}function y(e,t){return e&t}function x(e,t){return e|t}function b(e,t){return e^t}function _(e,t){return e&~t}function w(e){if(0==e)return-1;var t=0;return 65535&e||(e>>=16,t+=16),255&e||(e>>=8,t+=8),15&e||(e>>=4,t+=4),3&e||(e>>=2,t+=2),1&e||++t,t}function S(e){for(var t=0;0!=e;)e&=e-1,++t;return t}function M(){}function E(e){return e}function T(e){this.r2=l(),this.q3=l(),o.ONE.dlShiftTo(2*e.t,this.r2),this.mu=this.r2.divide(e),this.m=e}g.prototype.convert=function(e){return e.s<0||e.compareTo(this.m)>=0?e.mod(this.m):e},g.prototype.revert=function(e){return e},g.prototype.reduce=function(e){e.divRemTo(this.m,null,e)},g.prototype.mulTo=function(e,t,n){e.multiplyTo(t,n),this.reduce(n)},g.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},v.prototype.convert=function(e){var t=l();return e.abs().dlShiftTo(this.m.t,t),t.divRemTo(this.m,null,t),e.s<0&&t.compareTo(o.ZERO)>0&&this.m.subTo(t,t),t},v.prototype.revert=function(e){var t=l();return e.copyTo(t),this.reduce(t),t},v.prototype.reduce=function(e){for(;e.t<=this.mt2;)e[e.t++]=0;for(var t=0;t<this.m.t;++t){var n=32767&e[t],i=n*this.mpl+((n*this.mph+(e[t]>>15)*this.mpl&this.um)<<15)&e.DM;for(e[n=t+this.m.t]+=this.m.am(0,i,e,t,0,this.m.t);e[n]>=e.DV;)e[n]-=e.DV,e[++n]++}e.clamp(),e.drShiftTo(this.m.t,e),e.compareTo(this.m)>=0&&e.subTo(this.m,e)},v.prototype.mulTo=function(e,t,n){e.multiplyTo(t,n),this.reduce(n)},v.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},o.prototype.copyTo=function(e){for(var t=this.t-1;t>=0;--t)e[t]=this[t];e.t=this.t,e.s=this.s},o.prototype.fromInt=function(e){this.t=1,this.s=e<0?-1:0,e>0?this[0]=e:e<-1?this[0]=e+this.DV:this.t=0},o.prototype.fromString=function(e,t){var n;if(16==t)n=4;else if(8==t)n=3;else if(256==t)n=8;else if(2==t)n=1;else if(32==t)n=5;else{if(4!=t)return void this.fromRadix(e,t);n=2}this.t=0,this.s=0;for(var i=e.length,r=!1,a=0;--i>=0;){var s=8==n?255&e[i]:p(e,i);s<0?"-"==e.charAt(i)&&(r=!0):(r=!1,0==a?this[this.t++]=s:a+n>this.DB?(this[this.t-1]|=(s&(1<<this.DB-a)-1)<<a,this[this.t++]=s>>this.DB-a):this[this.t-1]|=s<<a,(a+=n)>=this.DB&&(a-=this.DB))}8==n&&128&e[0]&&(this.s=-1,a>0&&(this[this.t-1]|=(1<<this.DB-a)-1<<a)),this.clamp(),r&&o.ZERO.subTo(this,this)},o.prototype.clamp=function(){for(var e=this.s&this.DM;this.t>0&&this[this.t-1]==e;)--this.t},o.prototype.dlShiftTo=function(e,t){var n;for(n=this.t-1;n>=0;--n)t[n+e]=this[n];for(n=e-1;n>=0;--n)t[n]=0;t.t=this.t+e,t.s=this.s},o.prototype.drShiftTo=function(e,t){for(var n=e;n<this.t;++n)t[n-e]=this[n];t.t=Math.max(this.t-e,0),t.s=this.s},o.prototype.lShiftTo=function(e,t){var n,i=e%this.DB,r=this.DB-i,a=(1<<r)-1,s=Math.floor(e/this.DB),o=this.s<<i&this.DM;for(n=this.t-1;n>=0;--n)t[n+s+1]=this[n]>>r|o,o=(this[n]&a)<<i;for(n=s-1;n>=0;--n)t[n]=0;t[s]=o,t.t=this.t+s+1,t.s=this.s,t.clamp()},o.prototype.rShiftTo=function(e,t){t.s=this.s;var n=Math.floor(e/this.DB);if(n>=this.t)t.t=0;else{var i=e%this.DB,r=this.DB-i,a=(1<<i)-1;t[0]=this[n]>>i;for(var s=n+1;s<this.t;++s)t[s-n-1]|=(this[s]&a)<<r,t[s-n]=this[s]>>i;i>0&&(t[this.t-n-1]|=(this.s&a)<<r),t.t=this.t-n,t.clamp()}},o.prototype.subTo=function(e,t){for(var n=0,i=0,r=Math.min(e.t,this.t);n<r;)i+=this[n]-e[n],t[n++]=i&this.DM,i>>=this.DB;if(e.t<this.t){for(i-=e.s;n<this.t;)i+=this[n],t[n++]=i&this.DM,i>>=this.DB;i+=this.s}else{for(i+=this.s;n<e.t;)i-=e[n],t[n++]=i&this.DM,i>>=this.DB;i-=e.s}t.s=i<0?-1:0,i<-1?t[n++]=this.DV+i:i>0&&(t[n++]=i),t.t=n,t.clamp()},o.prototype.multiplyTo=function(e,t){var n=this.abs(),i=e.abs(),r=n.t;for(t.t=r+i.t;--r>=0;)t[r]=0;for(r=0;r<i.t;++r)t[r+n.t]=n.am(0,i[r],t,r,0,n.t);t.s=0,t.clamp(),this.s!=e.s&&o.ZERO.subTo(t,t)},o.prototype.squareTo=function(e){for(var t=this.abs(),n=e.t=2*t.t;--n>=0;)e[n]=0;for(n=0;n<t.t-1;++n){var i=t.am(n,t[n],e,2*n,0,1);(e[n+t.t]+=t.am(n+1,2*t[n],e,2*n+1,i,t.t-n-1))>=t.DV&&(e[n+t.t]-=t.DV,e[n+t.t+1]=1)}e.t>0&&(e[e.t-1]+=t.am(n,t[n],e,2*n,0,1)),e.s=0,e.clamp()},o.prototype.divRemTo=function(e,t,n){var i=e.abs();if(!(i.t<=0)){var r=this.abs();if(r.t<i.t)return null!=t&&t.fromInt(0),void(null!=n&&this.copyTo(n));null==n&&(n=l());var a=l(),s=this.s,h=e.s,u=this.DB-m(i[i.t-1]);u>0?(i.lShiftTo(u,a),r.lShiftTo(u,n)):(i.copyTo(a),r.copyTo(n));var c=a.t,d=a[c-1];if(0!=d){var p=d*(1<<this.F1)+(c>1?a[c-2]>>this.F2:0),f=this.FV/p,g=(1<<this.F1)/p,v=1<<this.F2,y=n.t,x=y-c,b=null==t?l():t;for(a.dlShiftTo(x,b),n.compareTo(b)>=0&&(n[n.t++]=1,n.subTo(b,n)),o.ONE.dlShiftTo(c,b),b.subTo(a,a);a.t<c;)a[a.t++]=0;for(;--x>=0;){var _=n[--y]==d?this.DM:Math.floor(n[y]*f+(n[y-1]+v)*g);if((n[y]+=a.am(0,_,n,x,0,c))<_)for(a.dlShiftTo(x,b),n.subTo(b,n);n[y]<--_;)n.subTo(b,n)}null!=t&&(n.drShiftTo(c,t),s!=h&&o.ZERO.subTo(t,t)),n.t=c,n.clamp(),u>0&&n.rShiftTo(u,n),s<0&&o.ZERO.subTo(n,n)}}},o.prototype.invDigit=function(){if(this.t<1)return 0;var e=this[0];if(!(1&e))return 0;var t=3&e;return(t=(t=(t=(t=t*(2-(15&e)*t)&15)*(2-(255&e)*t)&255)*(2-((65535&e)*t&65535))&65535)*(2-e*t%this.DV)%this.DV)>0?this.DV-t:-t},o.prototype.isEven=function(){return 0==(this.t>0?1&this[0]:this.s)},o.prototype.exp=function(e,t){if(e>4294967295||e<1)return o.ONE;var n=l(),i=l(),r=t.convert(this),a=m(e)-1;for(r.copyTo(n);--a>=0;)if(t.sqrTo(n,i),(e&1<<a)>0)t.mulTo(i,r,n);else{var s=n;n=i,i=s}return t.revert(n)},o.prototype.toString=function(e){if(this.s<0)return"-"+this.negate().toString(e);var t;if(16==e)t=4;else if(8==e)t=3;else if(2==e)t=1;else if(32==e)t=5;else{if(4!=e)return this.toRadix(e);t=2}var n,i=(1<<t)-1,r=!1,a="",s=this.t,o=this.DB-s*this.DB%t;if(s-- >0)for(o<this.DB&&(n=this[s]>>o)>0&&(r=!0,a=d(n));s>=0;)o<t?(n=(this[s]&(1<<o)-1)<<t-o,n|=this[--s]>>(o+=this.DB-t)):(n=this[s]>>(o-=t)&i,o<=0&&(o+=this.DB,--s)),n>0&&(r=!0),r&&(a+=d(n));return r?a:"0"},o.prototype.negate=function(){var e=l();return o.ZERO.subTo(this,e),e},o.prototype.abs=function(){return this.s<0?this.negate():this},o.prototype.compareTo=function(e){var t=this.s-e.s;if(0!=t)return t;var n=this.t;if(0!=(t=n-e.t))return this.s<0?-t:t;for(;--n>=0;)if(0!=(t=this[n]-e[n]))return t;return 0},o.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+m(this[this.t-1]^this.s&this.DM)},o.prototype.mod=function(e){var t=l();return this.abs().divRemTo(e,null,t),this.s<0&&t.compareTo(o.ZERO)>0&&e.subTo(t,t),t},o.prototype.modPowInt=function(e,t){var n;return n=e<256||t.isEven()?new g(t):new v(t),this.exp(e,n)},o.ZERO=f(0),o.ONE=f(1),M.prototype.convert=E,M.prototype.revert=E,M.prototype.mulTo=function(e,t,n){e.multiplyTo(t,n)},M.prototype.sqrTo=function(e,t){e.squareTo(t)},T.prototype.convert=function(e){if(e.s<0||e.t>2*this.m.t)return e.mod(this.m);if(e.compareTo(this.m)<0)return e;var t=l();return e.copyTo(t),this.reduce(t),t},T.prototype.revert=function(e){return e},T.prototype.reduce=function(e){for(e.drShiftTo(this.m.t-1,this.r2),e.t>this.m.t+1&&(e.t=this.m.t+1,e.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);e.compareTo(this.r2)<0;)e.dAddOffset(1,this.m.t+1);for(e.subTo(this.r2,e);e.compareTo(this.m)>=0;)e.subTo(this.m,e)},T.prototype.mulTo=function(e,t,n){e.multiplyTo(t,n),this.reduce(n)},T.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)};var A=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],C=(1<<26)/A[A.length-1];o.prototype.chunkSize=function(e){return Math.floor(Math.LN2*this.DB/Math.log(e))},o.prototype.toRadix=function(e){if(null==e&&(e=10),0==this.signum()||e<2||e>36)return"0";var t=this.chunkSize(e),n=Math.pow(e,t),i=f(n),r=l(),a=l(),s="";for(this.divRemTo(i,r,a);r.signum()>0;)s=(n+a.intValue()).toString(e).substr(1)+s,r.divRemTo(i,r,a);return a.intValue().toString(e)+s},o.prototype.fromRadix=function(e,t){this.fromInt(0),null==t&&(t=10);for(var n=this.chunkSize(t),i=Math.pow(t,n),r=!1,a=0,s=0,l=0;l<e.length;++l){var h=p(e,l);h<0?"-"==e.charAt(l)&&0==this.signum()&&(r=!0):(s=t*s+h,++a>=n&&(this.dMultiply(i),this.dAddOffset(s,0),a=0,s=0))}a>0&&(this.dMultiply(Math.pow(t,a)),this.dAddOffset(s,0)),r&&o.ZERO.subTo(this,this)},o.prototype.fromNumber=function(e,t,n){if("number"==typeof t)if(e<2)this.fromInt(1);else for(this.fromNumber(e,n),this.testBit(e-1)||this.bitwiseTo(o.ONE.shiftLeft(e-1),x,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(t);)this.dAddOffset(2,0),this.bitLength()>e&&this.subTo(o.ONE.shiftLeft(e-1),this);else{var i=new Array,r=7&e;i.length=1+(e>>3),t.nextBytes(i),r>0?i[0]&=(1<<r)-1:i[0]=0,this.fromString(i,256)}},o.prototype.bitwiseTo=function(e,t,n){var i,r,a=Math.min(e.t,this.t);for(i=0;i<a;++i)n[i]=t(this[i],e[i]);if(e.t<this.t){for(r=e.s&this.DM,i=a;i<this.t;++i)n[i]=t(this[i],r);n.t=this.t}else{for(r=this.s&this.DM,i=a;i<e.t;++i)n[i]=t(r,e[i]);n.t=e.t}n.s=t(this.s,e.s),n.clamp()},o.prototype.changeBit=function(e,t){var n=o.ONE.shiftLeft(e);return this.bitwiseTo(n,t,n),n},o.prototype.addTo=function(e,t){for(var n=0,i=0,r=Math.min(e.t,this.t);n<r;)i+=this[n]+e[n],t[n++]=i&this.DM,i>>=this.DB;if(e.t<this.t){for(i+=e.s;n<this.t;)i+=this[n],t[n++]=i&this.DM,i>>=this.DB;i+=this.s}else{for(i+=this.s;n<e.t;)i+=e[n],t[n++]=i&this.DM,i>>=this.DB;i+=e.s}t.s=i<0?-1:0,i>0?t[n++]=i:i<-1&&(t[n++]=this.DV+i),t.t=n,t.clamp()},o.prototype.dMultiply=function(e){this[this.t]=this.am(0,e-1,this,0,0,this.t),++this.t,this.clamp()},o.prototype.dAddOffset=function(e,t){if(0!=e){for(;this.t<=t;)this[this.t++]=0;for(this[t]+=e;this[t]>=this.DV;)this[t]-=this.DV,++t>=this.t&&(this[this.t++]=0),++this[t]}},o.prototype.multiplyLowerTo=function(e,t,n){var i,r=Math.min(this.t+e.t,t);for(n.s=0,n.t=r;r>0;)n[--r]=0;for(i=n.t-this.t;r<i;++r)n[r+this.t]=this.am(0,e[r],n,r,0,this.t);for(i=Math.min(e.t,t);r<i;++r)this.am(0,e[r],n,r,0,t-r);n.clamp()},o.prototype.multiplyUpperTo=function(e,t,n){--t;var i=n.t=this.t+e.t-t;for(n.s=0;--i>=0;)n[i]=0;for(i=Math.max(t-this.t,0);i<e.t;++i)n[this.t+i-t]=this.am(t-i,e[i],n,0,0,this.t+i-t);n.clamp(),n.drShiftTo(1,n)},o.prototype.modInt=function(e){if(e<=0)return 0;var t=this.DV%e,n=this.s<0?e-1:0;if(this.t>0)if(0==t)n=this[0]%e;else for(var i=this.t-1;i>=0;--i)n=(t*n+this[i])%e;return n},o.prototype.millerRabin=function(e){var t=this.subtract(o.ONE),n=t.getLowestSetBit();if(n<=0)return!1;var i=t.shiftRight(n);(e=e+1>>1)>A.length&&(e=A.length);for(var r=l(),a=0;a<e;++a){r.fromInt(A[Math.floor(Math.random()*A.length)]);var s=r.modPow(i,this);if(0!=s.compareTo(o.ONE)&&0!=s.compareTo(t)){for(var h=1;h++<n&&0!=s.compareTo(t);)if(0==(s=s.modPowInt(2,this)).compareTo(o.ONE))return!1;if(0!=s.compareTo(t))return!1}}return!0},o.prototype.clone=function(){var e=l();return this.copyTo(e),e},o.prototype.intValue=function(){if(this.s<0){if(1==this.t)return this[0]-this.DV;if(0==this.t)return-1}else{if(1==this.t)return this[0];if(0==this.t)return 0}return(this[1]&(1<<32-this.DB)-1)<<this.DB|this[0]},o.prototype.byteValue=function(){return 0==this.t?this.s:this[0]<<24>>24},o.prototype.shortValue=function(){return 0==this.t?this.s:this[0]<<16>>16},o.prototype.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1},o.prototype.toByteArray=function(){var e=this.t,t=new Array;t[0]=this.s;var n,i=this.DB-e*this.DB%8,r=0;if(e-- >0)for(i<this.DB&&(n=this[e]>>i)!=(this.s&this.DM)>>i&&(t[r++]=n|this.s<<this.DB-i);e>=0;)i<8?(n=(this[e]&(1<<i)-1)<<8-i,n|=this[--e]>>(i+=this.DB-8)):(n=this[e]>>(i-=8)&255,i<=0&&(i+=this.DB,--e)),128&n&&(n|=-256),0==r&&(128&this.s)!=(128&n)&&++r,(r>0||n!=this.s)&&(t[r++]=n);return t},o.prototype.equals=function(e){return 0==this.compareTo(e)},o.prototype.min=function(e){return this.compareTo(e)<0?this:e},o.prototype.max=function(e){return this.compareTo(e)>0?this:e},o.prototype.and=function(e){var t=l();return this.bitwiseTo(e,y,t),t},o.prototype.or=function(e){var t=l();return this.bitwiseTo(e,x,t),t},o.prototype.xor=function(e){var t=l();return this.bitwiseTo(e,b,t),t},o.prototype.andNot=function(e){var t=l();return this.bitwiseTo(e,_,t),t},o.prototype.not=function(){for(var e=l(),t=0;t<this.t;++t)e[t]=this.DM&~this[t];return e.t=this.t,e.s=~this.s,e},o.prototype.shiftLeft=function(e){var t=l();return e<0?this.rShiftTo(-e,t):this.lShiftTo(e,t),t},o.prototype.shiftRight=function(e){var t=l();return e<0?this.lShiftTo(-e,t):this.rShiftTo(e,t),t},o.prototype.getLowestSetBit=function(){for(var e=0;e<this.t;++e)if(0!=this[e])return e*this.DB+w(this[e]);return this.s<0?this.t*this.DB:-1},o.prototype.bitCount=function(){for(var e=0,t=this.s&this.DM,n=0;n<this.t;++n)e+=S(this[n]^t);return e},o.prototype.testBit=function(e){var t=Math.floor(e/this.DB);return t>=this.t?0!=this.s:0!=(this[t]&1<<e%this.DB)},o.prototype.setBit=function(e){return this.changeBit(e,x)},o.prototype.clearBit=function(e){return this.changeBit(e,_)},o.prototype.flipBit=function(e){return this.changeBit(e,b)},o.prototype.add=function(e){var t=l();return this.addTo(e,t),t},o.prototype.subtract=function(e){var t=l();return this.subTo(e,t),t},o.prototype.multiply=function(e){var t=l();return this.multiplyTo(e,t),t},o.prototype.divide=function(e){var t=l();return this.divRemTo(e,t,null),t},o.prototype.remainder=function(e){var t=l();return this.divRemTo(e,null,t),t},o.prototype.divideAndRemainder=function(e){var t=l(),n=l();return this.divRemTo(e,t,n),new Array(t,n)},o.prototype.modPow=function(e,t){var n,i,r=e.bitLength(),a=f(1);if(r<=0)return a;n=r<18?1:r<48?3:r<144?4:r<768?5:6,i=r<8?new g(t):t.isEven()?new T(t):new v(t);var s=new Array,o=3,h=n-1,u=(1<<n)-1;if(s[1]=i.convert(this),n>1){var c=l();for(i.sqrTo(s[1],c);o<=u;)s[o]=l(),i.mulTo(c,s[o-2],s[o]),o+=2}var d,p,y=e.t-1,x=!0,b=l();for(r=m(e[y])-1;y>=0;){for(r>=h?d=e[y]>>r-h&u:(d=(e[y]&(1<<r+1)-1)<<h-r,y>0&&(d|=e[y-1]>>this.DB+r-h)),o=n;!(1&d);)d>>=1,--o;if((r-=o)<0&&(r+=this.DB,--y),x)s[d].copyTo(a),x=!1;else{for(;o>1;)i.sqrTo(a,b),i.sqrTo(b,a),o-=2;o>0?i.sqrTo(a,b):(p=a,a=b,b=p),i.mulTo(b,s[d],a)}for(;y>=0&&!(e[y]&1<<r);)i.sqrTo(a,b),p=a,a=b,b=p,--r<0&&(r=this.DB-1,--y)}return i.revert(a)},o.prototype.modInverse=function(e){var t=e.isEven();if(this.isEven()&&t||0==e.signum())return o.ZERO;for(var n=e.clone(),i=this.clone(),r=f(1),a=f(0),s=f(0),l=f(1);0!=n.signum();){for(;n.isEven();)n.rShiftTo(1,n),t?((!r.isEven()||!a.isEven())&&(r.addTo(this,r),a.subTo(e,a)),r.rShiftTo(1,r)):a.isEven()||a.subTo(e,a),a.rShiftTo(1,a);for(;i.isEven();)i.rShiftTo(1,i),t?((!s.isEven()||!l.isEven())&&(s.addTo(this,s),l.subTo(e,l)),s.rShiftTo(1,s)):l.isEven()||l.subTo(e,l),l.rShiftTo(1,l);n.compareTo(i)>=0?(n.subTo(i,n),t&&r.subTo(s,r),a.subTo(l,a)):(i.subTo(n,i),t&&s.subTo(r,s),l.subTo(a,l))}return 0!=i.compareTo(o.ONE)?o.ZERO:l.compareTo(e)>=0?l.subtract(e):l.signum()<0?(l.addTo(e,l),l.signum()<0?l.add(e):l):l},o.prototype.pow=function(e){return this.exp(e,new M)},o.prototype.gcd=function(e){var t=this.s<0?this.negate():this.clone(),n=e.s<0?e.negate():e.clone();if(t.compareTo(n)<0){var i=t;t=n,n=i}var r=t.getLowestSetBit(),a=n.getLowestSetBit();if(a<0)return t;for(r<a&&(a=r),a>0&&(t.rShiftTo(a,t),n.rShiftTo(a,n));t.signum()>0;)(r=t.getLowestSetBit())>0&&t.rShiftTo(r,t),(r=n.getLowestSetBit())>0&&n.rShiftTo(r,n),t.compareTo(n)>=0?(t.subTo(n,t),t.rShiftTo(1,t)):(n.subTo(t,n),n.rShiftTo(1,n));return a>0&&n.lShiftTo(a,n),n},o.prototype.isProbablePrime=function(e){var t,n=this.abs();if(1==n.t&&n[0]<=A[A.length-1]){for(t=0;t<A.length;++t)if(n[0]==A[t])return!0;return!1}if(n.isEven())return!1;for(t=1;t<A.length;){for(var i=A[t],r=t+1;r<A.length&&i<C;)i*=A[r++];for(i=n.modInt(i);t<r;)if(i%A[t++]==0)return!1}return n.millerRabin(e)},o.prototype.square=function(){var e=l();return this.squareTo(e),e};var P=o;P.prototype.IsNegative=function(){return-1==this.compareTo(P.ZERO)},P.op_Equality=function(e,t){return 0==e.compareTo(t)},P.op_Inequality=function(e,t){return 0!=e.compareTo(t)},P.op_GreaterThan=function(e,t){return e.compareTo(t)>0},P.op_LessThan=function(e,t){return e.compareTo(t)<0},P.op_Addition=function(e,t){return new P(e,void 0,void 0).add(new P(t,void 0,void 0))},P.op_Subtraction=function(e,t){return new P(e,void 0,void 0).subtract(new P(t,void 0,void 0))},P.Int128Mul=function(e,t){return new P(e,void 0,void 0).multiply(new P(t,void 0,void 0))},P.op_Division=function(e,t){return e.divide(t)},P.prototype.ToDouble=function(){return parseFloat(this.toString())};var R=function(e,t){var n;if(void 0===Object.getOwnPropertyNames){for(n in t.prototype)(void 0===e.prototype[n]||e.prototype[n]===Object.prototype[n])&&(e.prototype[n]=t.prototype[n]);for(n in t)void 0===e[n]&&(e[n]=t[n]);e.$baseCtor=t}else{for(var i=Object.getOwnPropertyNames(t.prototype),r=0;r<i.length;r++)void 0===Object.getOwnPropertyDescriptor(e.prototype,i[r])&&Object.defineProperty(e.prototype,i[r],Object.getOwnPropertyDescriptor(t.prototype,i[r]));for(n in t)void 0===e[n]&&(e[n]=t[n]);e.$baseCtor=t}};n.Path=function(){return[]},n.Path.prototype.push=Array.prototype.push,n.Paths=function(){return[]},n.Paths.prototype.push=Array.prototype.push,n.DoublePoint=function(){var e=arguments;this.X=0,this.Y=0,1===e.length?(this.X=e[0].X,this.Y=e[0].Y):2===e.length&&(this.X=e[0],this.Y=e[1])},n.DoublePoint0=function(){this.X=0,this.Y=0},n.DoublePoint0.prototype=n.DoublePoint.prototype,n.DoublePoint1=function(e){this.X=e.X,this.Y=e.Y},n.DoublePoint1.prototype=n.DoublePoint.prototype,n.DoublePoint2=function(e,t){this.X=e,this.Y=t},n.DoublePoint2.prototype=n.DoublePoint.prototype,n.PolyNode=function(){this.m_Parent=null,this.m_polygon=new n.Path,this.m_Index=0,this.m_jointype=0,this.m_endtype=0,this.m_Childs=[],this.IsOpen=!1},n.PolyNode.prototype.IsHoleNode=function(){for(var e=!0,t=this.m_Parent;null!==t;)e=!e,t=t.m_Parent;return e},n.PolyNode.prototype.ChildCount=function(){return this.m_Childs.length},n.PolyNode.prototype.Contour=function(){return this.m_polygon},n.PolyNode.prototype.AddChild=function(e){var t=this.m_Childs.length;this.m_Childs.push(e),e.m_Parent=this,e.m_Index=t},n.PolyNode.prototype.GetNext=function(){return this.m_Childs.length>0?this.m_Childs[0]:this.GetNextSiblingUp()},n.PolyNode.prototype.GetNextSiblingUp=function(){return null===this.m_Parent?null:this.m_Index===this.m_Parent.m_Childs.length-1?this.m_Parent.GetNextSiblingUp():this.m_Parent.m_Childs[this.m_Index+1]},n.PolyNode.prototype.Childs=function(){return this.m_Childs},n.PolyNode.prototype.Parent=function(){return this.m_Parent},n.PolyNode.prototype.IsHole=function(){return this.IsHoleNode()},n.PolyTree=function(){this.m_AllPolys=[],n.PolyNode.call(this)},n.PolyTree.prototype.Clear=function(){for(var e=0,t=this.m_AllPolys.length;e<t;e++)this.m_AllPolys[e]=null;this.m_AllPolys.length=0,this.m_Childs.length=0},n.PolyTree.prototype.GetFirst=function(){return this.m_Childs.length>0?this.m_Childs[0]:null},n.PolyTree.prototype.Total=function(){var e=this.m_AllPolys.length;return e>0&&this.m_Childs[0]!==this.m_AllPolys[0]&&e--,e},R(n.PolyTree,n.PolyNode),n.Math_Abs_Int64=n.Math_Abs_Int32=n.Math_Abs_Double=function(e){return Math.abs(e)},n.Math_Max_Int32_Int32=function(e,t){return Math.max(e,t)},s.msie||s.opera||s.safari?n.Cast_Int32=function(e){return 0|e}:n.Cast_Int32=function(e){return~~e},void 0===Number.toInteger&&(Number.toInteger=null),s.chrome?n.Cast_Int64=function(e){return e<-2147483648||e>2147483647?e<0?Math.ceil(e):Math.floor(e):~~e}:s.firefox&&"function"==typeof Number.toInteger?n.Cast_Int64=function(e){return Number.toInteger(e)}:s.msie7||s.msie8?n.Cast_Int64=function(e){return parseInt(e,10)}:s.msie?n.Cast_Int64=function(e){return e<-2147483648||e>2147483647?e<0?Math.ceil(e):Math.floor(e):0|e}:n.Cast_Int64=function(e){return e<0?Math.ceil(e):Math.floor(e)},n.Clear=function(e){e.length=0},n.PI=3.141592653589793,n.PI2=6.283185307179586,n.IntPoint=function(){var e=arguments,t=e.length;if(this.X=0,this.Y=0,n.use_xyz)if(this.Z=0,3===t)this.X=e[0],this.Y=e[1],this.Z=e[2];else if(2===t)this.X=e[0],this.Y=e[1],this.Z=0;else if(1===t)if(e[0]instanceof n.DoublePoint){var i=e[0];this.X=n.Clipper.Round(i.X),this.Y=n.Clipper.Round(i.Y),this.Z=0}else void 0===(r=e[0]).Z&&(r.Z=0),this.X=r.X,this.Y=r.Y,this.Z=r.Z;else this.X=0,this.Y=0,this.Z=0;else if(2===t)this.X=e[0],this.Y=e[1];else if(1===t)if(e[0]instanceof n.DoublePoint)i=e[0],this.X=n.Clipper.Round(i.X),this.Y=n.Clipper.Round(i.Y);else{var r=e[0];this.X=r.X,this.Y=r.Y}else this.X=0,this.Y=0},n.IntPoint.op_Equality=function(e,t){return e.X===t.X&&e.Y===t.Y},n.IntPoint.op_Inequality=function(e,t){return e.X!==t.X||e.Y!==t.Y},n.IntPoint0=function(){this.X=0,this.Y=0,n.use_xyz&&(this.Z=0)},n.IntPoint0.prototype=n.IntPoint.prototype,n.IntPoint1=function(e){this.X=e.X,this.Y=e.Y,n.use_xyz&&(void 0===e.Z?this.Z=0:this.Z=e.Z)},n.IntPoint1.prototype=n.IntPoint.prototype,n.IntPoint1dp=function(e){this.X=n.Clipper.Round(e.X),this.Y=n.Clipper.Round(e.Y),n.use_xyz&&(this.Z=0)},n.IntPoint1dp.prototype=n.IntPoint.prototype,n.IntPoint2=function(e,t,i){this.X=e,this.Y=t,n.use_xyz&&(this.Z=void 0===i?0:i)},n.IntPoint2.prototype=n.IntPoint.prototype,n.IntRect=function(){var e=arguments,t=e.length;if(4===t)this.left=e[0],this.top=e[1],this.right=e[2],this.bottom=e[3];else if(1===t){var n=e[0];this.left=n.left,this.top=n.top,this.right=n.right,this.bottom=n.bottom}else this.left=0,this.top=0,this.right=0,this.bottom=0},n.IntRect0=function(){this.left=0,this.top=0,this.right=0,this.bottom=0},n.IntRect0.prototype=n.IntRect.prototype,n.IntRect1=function(e){this.left=e.left,this.top=e.top,this.right=e.right,this.bottom=e.bottom},n.IntRect1.prototype=n.IntRect.prototype,n.IntRect4=function(e,t,n,i){this.left=e,this.top=t,this.right=n,this.bottom=i},n.IntRect4.prototype=n.IntRect.prototype,n.ClipType={ctIntersection:0,ctUnion:1,ctDifference:2,ctXor:3},n.PolyType={ptSubject:0,ptClip:1},n.PolyFillType={pftEvenOdd:0,pftNonZero:1,pftPositive:2,pftNegative:3},n.JoinType={jtSquare:0,jtRound:1,jtMiter:2},n.EndType={etOpenSquare:0,etOpenRound:1,etOpenButt:2,etClosedLine:3,etClosedPolygon:4},n.EdgeSide={esLeft:0,esRight:1},n.Direction={dRightToLeft:0,dLeftToRight:1},n.TEdge=function(){this.Bot=new n.IntPoint0,this.Curr=new n.IntPoint0,this.Top=new n.IntPoint0,this.Delta=new n.IntPoint0,this.Dx=0,this.PolyTyp=n.PolyType.ptSubject,this.Side=n.EdgeSide.esLeft,this.WindDelta=0,this.WindCnt=0,this.WindCnt2=0,this.OutIdx=0,this.Next=null,this.Prev=null,this.NextInLML=null,this.NextInAEL=null,this.PrevInAEL=null,this.NextInSEL=null,this.PrevInSEL=null},n.IntersectNode=function(){this.Edge1=null,this.Edge2=null,this.Pt=new n.IntPoint0},n.MyIntersectNodeSort=function(){},n.MyIntersectNodeSort.Compare=function(e,t){var n=t.Pt.Y-e.Pt.Y;return n>0?1:n<0?-1:0},n.LocalMinima=function(){this.Y=0,this.LeftBound=null,this.RightBound=null,this.Next=null},n.Scanbeam=function(){this.Y=0,this.Next=null},n.Maxima=function(){this.X=0,this.Next=null,this.Prev=null},n.OutRec=function(){this.Idx=0,this.IsHole=!1,this.IsOpen=!1,this.FirstLeft=null,this.Pts=null,this.BottomPt=null,this.PolyNode=null},n.OutPt=function(){this.Idx=0,this.Pt=new n.IntPoint0,this.Next=null,this.Prev=null},n.Join=function(){this.OutPt1=null,this.OutPt2=null,this.OffPt=new n.IntPoint0},n.ClipperBase=function(){this.m_MinimaList=null,this.m_CurrentLM=null,this.m_edges=new Array,this.m_UseFullRange=!1,this.m_HasOpenPaths=!1,this.PreserveCollinear=!1,this.m_Scanbeam=null,this.m_PolyOuts=null,this.m_ActiveEdges=null},n.ClipperBase.horizontal=-9007199254740992,n.ClipperBase.Skip=-2,n.ClipperBase.Unassigned=-1,n.ClipperBase.tolerance=1e-20,n.ClipperBase.loRange=47453132,n.ClipperBase.hiRange=0xfffffffffffff,n.ClipperBase.near_zero=function(e){return e>-n.ClipperBase.tolerance&&e<n.ClipperBase.tolerance},n.ClipperBase.IsHorizontal=function(e){return 0===e.Delta.Y},n.ClipperBase.prototype.PointIsVertex=function(e,t){var i=t;do{if(n.IntPoint.op_Equality(i.Pt,e))return!0;i=i.Next}while(i!==t);return!1},n.ClipperBase.prototype.PointOnLineSegment=function(e,t,n,i){return i?e.X===t.X&&e.Y===t.Y||e.X===n.X&&e.Y===n.Y||e.X>t.X==e.X<n.X&&e.Y>t.Y==e.Y<n.Y&&P.op_Equality(P.Int128Mul(e.X-t.X,n.Y-t.Y),P.Int128Mul(n.X-t.X,e.Y-t.Y)):e.X===t.X&&e.Y===t.Y||e.X===n.X&&e.Y===n.Y||e.X>t.X==e.X<n.X&&e.Y>t.Y==e.Y<n.Y&&(e.X-t.X)*(n.Y-t.Y)==(n.X-t.X)*(e.Y-t.Y)},n.ClipperBase.prototype.PointOnPolygon=function(e,t,n){for(var i=t;;){if(this.PointOnLineSegment(e,i.Pt,i.Next.Pt,n))return!0;if((i=i.Next)===t)break}return!1},n.ClipperBase.prototype.SlopesEqual=n.ClipperBase.SlopesEqual=function(){var e,t,i,r,a,s,o=arguments,l=o.length;return 3===l?(e=o[0],t=o[1],o[2]?P.op_Equality(P.Int128Mul(e.Delta.Y,t.Delta.X),P.Int128Mul(e.Delta.X,t.Delta.Y)):n.Cast_Int64(e.Delta.Y*t.Delta.X)===n.Cast_Int64(e.Delta.X*t.Delta.Y)):4===l?(i=o[0],r=o[1],a=o[2],o[3]?P.op_Equality(P.Int128Mul(i.Y-r.Y,r.X-a.X),P.Int128Mul(i.X-r.X,r.Y-a.Y)):n.Cast_Int64((i.Y-r.Y)*(r.X-a.X))-n.Cast_Int64((i.X-r.X)*(r.Y-a.Y))==0):(i=o[0],r=o[1],a=o[2],s=o[3],o[4]?P.op_Equality(P.Int128Mul(i.Y-r.Y,a.X-s.X),P.Int128Mul(i.X-r.X,a.Y-s.Y)):n.Cast_Int64((i.Y-r.Y)*(a.X-s.X))-n.Cast_Int64((i.X-r.X)*(a.Y-s.Y))==0)},n.ClipperBase.SlopesEqual3=function(e,t,i){return i?P.op_Equality(P.Int128Mul(e.Delta.Y,t.Delta.X),P.Int128Mul(e.Delta.X,t.Delta.Y)):n.Cast_Int64(e.Delta.Y*t.Delta.X)===n.Cast_Int64(e.Delta.X*t.Delta.Y)},n.ClipperBase.SlopesEqual4=function(e,t,i,r){return r?P.op_Equality(P.Int128Mul(e.Y-t.Y,t.X-i.X),P.Int128Mul(e.X-t.X,t.Y-i.Y)):n.Cast_Int64((e.Y-t.Y)*(t.X-i.X))-n.Cast_Int64((e.X-t.X)*(t.Y-i.Y))==0},n.ClipperBase.SlopesEqual5=function(e,t,i,r,a){return a?P.op_Equality(P.Int128Mul(e.Y-t.Y,i.X-r.X),P.Int128Mul(e.X-t.X,i.Y-r.Y)):n.Cast_Int64((e.Y-t.Y)*(i.X-r.X))-n.Cast_Int64((e.X-t.X)*(i.Y-r.Y))==0},n.ClipperBase.prototype.Clear=function(){this.DisposeLocalMinimaList();for(var e=0,t=this.m_edges.length;e<t;++e){for(var i=0,r=this.m_edges[e].length;i<r;++i)this.m_edges[e][i]=null;n.Clear(this.m_edges[e])}n.Clear(this.m_edges),this.m_UseFullRange=!1,this.m_HasOpenPaths=!1},n.ClipperBase.prototype.DisposeLocalMinimaList=function(){for(;null!==this.m_MinimaList;){var e=this.m_MinimaList.Next;this.m_MinimaList=null,this.m_MinimaList=e}this.m_CurrentLM=null},n.ClipperBase.prototype.RangeTest=function(e,t){t.Value?(e.X>n.ClipperBase.hiRange||e.Y>n.ClipperBase.hiRange||-e.X>n.ClipperBase.hiRange||-e.Y>n.ClipperBase.hiRange)&&n.Error("Coordinate outside allowed range in RangeTest()."):(e.X>n.ClipperBase.loRange||e.Y>n.ClipperBase.loRange||-e.X>n.ClipperBase.loRange||-e.Y>n.ClipperBase.loRange)&&(t.Value=!0,this.RangeTest(e,t))},n.ClipperBase.prototype.InitEdge=function(e,t,i,r){e.Next=t,e.Prev=i,e.Curr.X=r.X,e.Curr.Y=r.Y,n.use_xyz&&(e.Curr.Z=r.Z),e.OutIdx=-1},n.ClipperBase.prototype.InitEdge2=function(e,t){e.Curr.Y>=e.Next.Curr.Y?(e.Bot.X=e.Curr.X,e.Bot.Y=e.Curr.Y,n.use_xyz&&(e.Bot.Z=e.Curr.Z),e.Top.X=e.Next.Curr.X,e.Top.Y=e.Next.Curr.Y,n.use_xyz&&(e.Top.Z=e.Next.Curr.Z)):(e.Top.X=e.Curr.X,e.Top.Y=e.Curr.Y,n.use_xyz&&(e.Top.Z=e.Curr.Z),e.Bot.X=e.Next.Curr.X,e.Bot.Y=e.Next.Curr.Y,n.use_xyz&&(e.Bot.Z=e.Next.Curr.Z)),this.SetDx(e),e.PolyTyp=t},n.ClipperBase.prototype.FindNextLocMin=function(e){for(var t;;){for(;n.IntPoint.op_Inequality(e.Bot,e.Prev.Bot)||n.IntPoint.op_Equality(e.Curr,e.Top);)e=e.Next;if(e.Dx!==n.ClipperBase.horizontal&&e.Prev.Dx!==n.ClipperBase.horizontal)break;for(;e.Prev.Dx===n.ClipperBase.horizontal;)e=e.Prev;for(t=e;e.Dx===n.ClipperBase.horizontal;)e=e.Next;if(e.Top.Y!==e.Prev.Bot.Y){t.Prev.Bot.X<e.Bot.X&&(e=t);break}}return e},n.ClipperBase.prototype.ProcessBound=function(e,t){var i,r,a=e;if(a.OutIdx===n.ClipperBase.Skip){if(e=a,t){for(;e.Top.Y===e.Next.Bot.Y;)e=e.Next;for(;e!==a&&e.Dx===n.ClipperBase.horizontal;)e=e.Prev}else{for(;e.Top.Y===e.Prev.Bot.Y;)e=e.Prev;for(;e!==a&&e.Dx===n.ClipperBase.horizontal;)e=e.Next}if(e===a)a=t?e.Next:e.Prev;else{e=t?a.Next:a.Prev;var s=new n.LocalMinima;s.Next=null,s.Y=e.Bot.Y,s.LeftBound=null,s.RightBound=e,e.WindDelta=0,a=this.ProcessBound(e,t),this.InsertLocalMinima(s)}return a}if(e.Dx===n.ClipperBase.horizontal&&((i=t?e.Prev:e.Next).Dx===n.ClipperBase.horizontal?i.Bot.X!==e.Bot.X&&i.Top.X!==e.Bot.X&&this.ReverseHorizontal(e):i.Bot.X!==e.Bot.X&&this.ReverseHorizontal(e)),i=e,t){for(;a.Top.Y===a.Next.Bot.Y&&a.Next.OutIdx!==n.ClipperBase.Skip;)a=a.Next;if(a.Dx===n.ClipperBase.horizontal&&a.Next.OutIdx!==n.ClipperBase.Skip){for(r=a;r.Prev.Dx===n.ClipperBase.horizontal;)r=r.Prev;r.Prev.Top.X>a.Next.Top.X&&(a=r.Prev)}for(;e!==a;)e.NextInLML=e.Next,e.Dx===n.ClipperBase.horizontal&&e!==i&&e.Bot.X!==e.Prev.Top.X&&this.ReverseHorizontal(e),e=e.Next;e.Dx===n.ClipperBase.horizontal&&e!==i&&e.Bot.X!==e.Prev.Top.X&&this.ReverseHorizontal(e),a=a.Next}else{for(;a.Top.Y===a.Prev.Bot.Y&&a.Prev.OutIdx!==n.ClipperBase.Skip;)a=a.Prev;if(a.Dx===n.ClipperBase.horizontal&&a.Prev.OutIdx!==n.ClipperBase.Skip){for(r=a;r.Next.Dx===n.ClipperBase.horizontal;)r=r.Next;(r.Next.Top.X===a.Prev.Top.X||r.Next.Top.X>a.Prev.Top.X)&&(a=r.Next)}for(;e!==a;)e.NextInLML=e.Prev,e.Dx===n.ClipperBase.horizontal&&e!==i&&e.Bot.X!==e.Next.Top.X&&this.ReverseHorizontal(e),e=e.Prev;e.Dx===n.ClipperBase.horizontal&&e!==i&&e.Bot.X!==e.Next.Top.X&&this.ReverseHorizontal(e),a=a.Prev}return a},n.ClipperBase.prototype.AddPath=function(e,t,i){n.use_lines?!i&&t===n.PolyType.ptClip&&n.Error("AddPath: Open paths must be subject."):i||n.Error("AddPath: Open paths have been disabled.");var r=e.length-1;if(i)for(;r>0&&n.IntPoint.op_Equality(e[r],e[0]);)--r;for(;r>0&&n.IntPoint.op_Equality(e[r],e[r-1]);)--r;if(i&&r<2||!i&&r<1)return!1;for(var a=new Array,s=0;s<=r;s++)a.push(new n.TEdge);var o=!0;a[1].Curr.X=e[1].X,a[1].Curr.Y=e[1].Y,n.use_xyz&&(a[1].Curr.Z=e[1].Z);var l={Value:this.m_UseFullRange};for(this.RangeTest(e[0],l),this.m_UseFullRange=l.Value,l.Value=this.m_UseFullRange,this.RangeTest(e[r],l),this.m_UseFullRange=l.Value,this.InitEdge(a[0],a[1],a[r],e[0]),this.InitEdge(a[r],a[0],a[r-1],e[r]),s=r-1;s>=1;--s)l.Value=this.m_UseFullRange,this.RangeTest(e[s],l),this.m_UseFullRange=l.Value,this.InitEdge(a[s],a[s+1],a[s-1],e[s]);for(var h=a[0],u=h,c=h;;)if(u.Curr!==u.Next.Curr||!i&&u.Next===h){if(u.Prev===u.Next)break;if(!i||!n.ClipperBase.SlopesEqual4(u.Prev.Curr,u.Curr,u.Next.Curr,this.m_UseFullRange)||this.PreserveCollinear&&this.Pt2IsBetweenPt1AndPt3(u.Prev.Curr,u.Curr,u.Next.Curr)){if((u=u.Next)===c||!i&&u.Next===h)break}else u===h&&(h=u.Next),c=u=(u=this.RemoveEdge(u)).Prev}else{if(u===u.Next)break;u===h&&(h=u.Next),c=u=this.RemoveEdge(u)}if(!i&&u===u.Next||i&&u.Prev===u.Next)return!1;i||(this.m_HasOpenPaths=!0,h.Prev.OutIdx=n.ClipperBase.Skip),u=h;do{this.InitEdge2(u,t),u=u.Next,o&&u.Curr.Y!==h.Curr.Y&&(o=!1)}while(u!==h);if(o){if(i)return!1;for(u.Prev.OutIdx=n.ClipperBase.Skip,(f=new n.LocalMinima).Next=null,f.Y=u.Bot.Y,f.LeftBound=null,f.RightBound=u,f.RightBound.Side=n.EdgeSide.esRight,f.RightBound.WindDelta=0;u.Bot.X!==u.Prev.Top.X&&this.ReverseHorizontal(u),u.Next.OutIdx!==n.ClipperBase.Skip;)u.NextInLML=u.Next,u=u.Next;return this.InsertLocalMinima(f),this.m_edges.push(a),!0}this.m_edges.push(a);var d,p=null;for(n.IntPoint.op_Equality(u.Prev.Bot,u.Prev.Top)&&(u=u.Next);(u=this.FindNextLocMin(u))!==p;){var f;null===p&&(p=u),(f=new n.LocalMinima).Next=null,f.Y=u.Bot.Y,u.Dx<u.Prev.Dx?(f.LeftBound=u.Prev,f.RightBound=u,d=!1):(f.LeftBound=u,f.RightBound=u.Prev,d=!0),f.LeftBound.Side=n.EdgeSide.esLeft,f.RightBound.Side=n.EdgeSide.esRight,i?f.LeftBound.Next===f.RightBound?f.LeftBound.WindDelta=-1:f.LeftBound.WindDelta=1:f.LeftBound.WindDelta=0,f.RightBound.WindDelta=-f.LeftBound.WindDelta,(u=this.ProcessBound(f.LeftBound,d)).OutIdx===n.ClipperBase.Skip&&(u=this.ProcessBound(u,d));var m=this.ProcessBound(f.RightBound,!d);m.OutIdx===n.ClipperBase.Skip&&(m=this.ProcessBound(m,!d)),f.LeftBound.OutIdx===n.ClipperBase.Skip?f.LeftBound=null:f.RightBound.OutIdx===n.ClipperBase.Skip&&(f.RightBound=null),this.InsertLocalMinima(f),d||(u=m)}return!0},n.ClipperBase.prototype.AddPaths=function(e,t,n){for(var i=!1,r=0,a=e.length;r<a;++r)this.AddPath(e[r],t,n)&&(i=!0);return i},n.ClipperBase.prototype.Pt2IsBetweenPt1AndPt3=function(e,t,i){return!(n.IntPoint.op_Equality(e,i)||n.IntPoint.op_Equality(e,t)||n.IntPoint.op_Equality(i,t))&&(e.X!==i.X?t.X>e.X==t.X<i.X:t.Y>e.Y==t.Y<i.Y)},n.ClipperBase.prototype.RemoveEdge=function(e){e.Prev.Next=e.Next,e.Next.Prev=e.Prev;var t=e.Next;return e.Prev=null,t},n.ClipperBase.prototype.SetDx=function(e){e.Delta.X=e.Top.X-e.Bot.X,e.Delta.Y=e.Top.Y-e.Bot.Y,0===e.Delta.Y?e.Dx=n.ClipperBase.horizontal:e.Dx=e.Delta.X/e.Delta.Y},n.ClipperBase.prototype.InsertLocalMinima=function(e){if(null===this.m_MinimaList)this.m_MinimaList=e;else if(e.Y>=this.m_MinimaList.Y)e.Next=this.m_MinimaList,this.m_MinimaList=e;else{for(var t=this.m_MinimaList;null!==t.Next&&e.Y<t.Next.Y;)t=t.Next;e.Next=t.Next,t.Next=e}},n.ClipperBase.prototype.PopLocalMinima=function(e,t){return t.v=this.m_CurrentLM,null!==this.m_CurrentLM&&this.m_CurrentLM.Y===e&&(this.m_CurrentLM=this.m_CurrentLM.Next,!0)},n.ClipperBase.prototype.ReverseHorizontal=function(e){var t=e.Top.X;e.Top.X=e.Bot.X,e.Bot.X=t,n.use_xyz&&(t=e.Top.Z,e.Top.Z=e.Bot.Z,e.Bot.Z=t)},n.ClipperBase.prototype.Reset=function(){if(this.m_CurrentLM=this.m_MinimaList,null!==this.m_CurrentLM){this.m_Scanbeam=null;for(var e=this.m_MinimaList;null!==e;){this.InsertScanbeam(e.Y);var t=e.LeftBound;null!==t&&(t.Curr.X=t.Bot.X,t.Curr.Y=t.Bot.Y,n.use_xyz&&(t.Curr.Z=t.Bot.Z),t.OutIdx=n.ClipperBase.Unassigned),null!==(t=e.RightBound)&&(t.Curr.X=t.Bot.X,t.Curr.Y=t.Bot.Y,n.use_xyz&&(t.Curr.Z=t.Bot.Z),t.OutIdx=n.ClipperBase.Unassigned),e=e.Next}this.m_ActiveEdges=null}},n.ClipperBase.prototype.InsertScanbeam=function(e){if(null===this.m_Scanbeam)this.m_Scanbeam=new n.Scanbeam,this.m_Scanbeam.Next=null,this.m_Scanbeam.Y=e;else if(e>this.m_Scanbeam.Y){var t=new n.Scanbeam;t.Y=e,t.Next=this.m_Scanbeam,this.m_Scanbeam=t}else{for(var i=this.m_Scanbeam;null!==i.Next&&e<=i.Next.Y;)i=i.Next;if(e===i.Y)return;var r=new n.Scanbeam;r.Y=e,r.Next=i.Next,i.Next=r}},n.ClipperBase.prototype.PopScanbeam=function(e){return null===this.m_Scanbeam?(e.v=0,!1):(e.v=this.m_Scanbeam.Y,this.m_Scanbeam=this.m_Scanbeam.Next,!0)},n.ClipperBase.prototype.LocalMinimaPending=function(){return null!==this.m_CurrentLM},n.ClipperBase.prototype.CreateOutRec=function(){var e=new n.OutRec;return e.Idx=n.ClipperBase.Unassigned,e.IsHole=!1,e.IsOpen=!1,e.FirstLeft=null,e.Pts=null,e.BottomPt=null,e.PolyNode=null,this.m_PolyOuts.push(e),e.Idx=this.m_PolyOuts.length-1,e},n.ClipperBase.prototype.DisposeOutRec=function(e){var t=this.m_PolyOuts[e];t.Pts=null,t=null,this.m_PolyOuts[e]=null},n.ClipperBase.prototype.UpdateEdgeIntoAEL=function(e){null===e.NextInLML&&n.Error("UpdateEdgeIntoAEL: invalid call");var t=e.PrevInAEL,i=e.NextInAEL;return e.NextInLML.OutIdx=e.OutIdx,null!==t?t.NextInAEL=e.NextInLML:this.m_ActiveEdges=e.NextInLML,null!==i&&(i.PrevInAEL=e.NextInLML),e.NextInLML.Side=e.Side,e.NextInLML.WindDelta=e.WindDelta,e.NextInLML.WindCnt=e.WindCnt,e.NextInLML.WindCnt2=e.WindCnt2,(e=e.NextInLML).Curr.X=e.Bot.X,e.Curr.Y=e.Bot.Y,e.PrevInAEL=t,e.NextInAEL=i,n.ClipperBase.IsHorizontal(e)||this.InsertScanbeam(e.Top.Y),e},n.ClipperBase.prototype.SwapPositionsInAEL=function(e,t){if(e.NextInAEL!==e.PrevInAEL&&t.NextInAEL!==t.PrevInAEL){if(e.NextInAEL===t){var n=t.NextInAEL;null!==n&&(n.PrevInAEL=e);var i=e.PrevInAEL;null!==i&&(i.NextInAEL=t),t.PrevInAEL=i,t.NextInAEL=e,e.PrevInAEL=t,e.NextInAEL=n}else if(t.NextInAEL===e){var r=e.NextInAEL;null!==r&&(r.PrevInAEL=t);var a=t.PrevInAEL;null!==a&&(a.NextInAEL=e),e.PrevInAEL=a,e.NextInAEL=t,t.PrevInAEL=e,t.NextInAEL=r}else{var s=e.NextInAEL,o=e.PrevInAEL;e.NextInAEL=t.NextInAEL,null!==e.NextInAEL&&(e.NextInAEL.PrevInAEL=e),e.PrevInAEL=t.PrevInAEL,null!==e.PrevInAEL&&(e.PrevInAEL.NextInAEL=e),t.NextInAEL=s,null!==t.NextInAEL&&(t.NextInAEL.PrevInAEL=t),t.PrevInAEL=o,null!==t.PrevInAEL&&(t.PrevInAEL.NextInAEL=t)}null===e.PrevInAEL?this.m_ActiveEdges=e:null===t.PrevInAEL&&(this.m_ActiveEdges=t)}},n.ClipperBase.prototype.DeleteFromAEL=function(e){var t=e.PrevInAEL,n=e.NextInAEL;null===t&&null===n&&e!==this.m_ActiveEdges||(null!==t?t.NextInAEL=n:this.m_ActiveEdges=n,null!==n&&(n.PrevInAEL=t),e.NextInAEL=null,e.PrevInAEL=null)},n.Clipper=function(e){void 0===e&&(e=0),this.m_PolyOuts=null,this.m_ClipType=n.ClipType.ctIntersection,this.m_Scanbeam=null,this.m_Maxima=null,this.m_ActiveEdges=null,this.m_SortedEdges=null,this.m_IntersectList=null,this.m_IntersectNodeComparer=null,this.m_ExecuteLocked=!1,this.m_ClipFillType=n.PolyFillType.pftEvenOdd,this.m_SubjFillType=n.PolyFillType.pftEvenOdd,this.m_Joins=null,this.m_GhostJoins=null,this.m_UsingPolyTree=!1,this.ReverseSolution=!1,this.StrictlySimple=!1,n.ClipperBase.call(this),this.m_Scanbeam=null,this.m_Maxima=null,this.m_ActiveEdges=null,this.m_SortedEdges=null,this.m_IntersectList=new Array,this.m_IntersectNodeComparer=n.MyIntersectNodeSort.Compare,this.m_ExecuteLocked=!1,this.m_UsingPolyTree=!1,this.m_PolyOuts=new Array,this.m_Joins=new Array,this.m_GhostJoins=new Array,this.ReverseSolution=0!=(1&e),this.StrictlySimple=0!=(2&e),this.PreserveCollinear=0!=(4&e),n.use_xyz&&(this.ZFillFunction=null)},n.Clipper.ioReverseSolution=1,n.Clipper.ioStrictlySimple=2,n.Clipper.ioPreserveCollinear=4,n.Clipper.prototype.Clear=function(){0!==this.m_edges.length&&(this.DisposeAllPolyPts(),n.ClipperBase.prototype.Clear.call(this))},n.Clipper.prototype.InsertMaxima=function(e){var t=new n.Maxima;if(t.X=e,null===this.m_Maxima)this.m_Maxima=t,this.m_Maxima.Next=null,this.m_Maxima.Prev=null;else if(e<this.m_Maxima.X)t.Next=this.m_Maxima,t.Prev=null,this.m_Maxima=t;else{for(var i=this.m_Maxima;null!==i.Next&&e>=i.Next.X;)i=i.Next;if(e===i.X)return;t.Next=i.Next,t.Prev=i,null!==i.Next&&(i.Next.Prev=t),i.Next=t}},n.Clipper.prototype.Execute=function(){var e=arguments,t=e.length,i=e[1]instanceof n.PolyTree;if(4===t&&!i){var r=e[0],a=e[1],s=e[2],o=e[3];if(this.m_ExecuteLocked)return!1;this.m_HasOpenPaths&&n.Error("Error: PolyTree struct is needed for open path clipping."),this.m_ExecuteLocked=!0,n.Clear(a),this.m_SubjFillType=s,this.m_ClipFillType=o,this.m_ClipType=r,this.m_UsingPolyTree=!1;try{(h=this.ExecuteInternal())&&this.BuildResult(a)}finally{this.DisposeAllPolyPts(),this.m_ExecuteLocked=!1}return h}if(4===t&&i){r=e[0];var l=e[1];if(s=e[2],o=e[3],this.m_ExecuteLocked)return!1;this.m_ExecuteLocked=!0,this.m_SubjFillType=s,this.m_ClipFillType=o,this.m_ClipType=r,this.m_UsingPolyTree=!0;try{var h;(h=this.ExecuteInternal())&&this.BuildResult2(l)}finally{this.DisposeAllPolyPts(),this.m_ExecuteLocked=!1}return h}return 2!==t||i?2===t&&i?(r=e[0],l=e[1],this.Execute(r,l,n.PolyFillType.pftEvenOdd,n.PolyFillType.pftEvenOdd)):void 0:(r=e[0],a=e[1],this.Execute(r,a,n.PolyFillType.pftEvenOdd,n.PolyFillType.pftEvenOdd))},n.Clipper.prototype.FixHoleLinkage=function(e){if(null!==e.FirstLeft&&(e.IsHole===e.FirstLeft.IsHole||null===e.FirstLeft.Pts)){for(var t=e.FirstLeft;null!==t&&(t.IsHole===e.IsHole||null===t.Pts);)t=t.FirstLeft;e.FirstLeft=t}},n.Clipper.prototype.ExecuteInternal=function(){try{this.Reset(),this.m_SortedEdges=null,this.m_Maxima=null;var e,t,n,i={},r={};if(!this.PopScanbeam(i))return!1;for(this.InsertLocalMinimaIntoAEL(i.v);this.PopScanbeam(r)||this.LocalMinimaPending();){if(this.ProcessHorizontals(),this.m_GhostJoins.length=0,!this.ProcessIntersections(r.v))return!1;this.ProcessEdgesAtTopOfScanbeam(r.v),i.v=r.v,this.InsertLocalMinimaIntoAEL(i.v)}for(t=0,n=this.m_PolyOuts.length;t<n;t++)null!==(e=this.m_PolyOuts[t]).Pts&&!e.IsOpen&&(e.IsHole^this.ReverseSolution)==this.Area$1(e)>0&&this.ReversePolyPtLinks(e.Pts);for(this.JoinCommonEdges(),t=0,n=this.m_PolyOuts.length;t<n;t++)null!==(e=this.m_PolyOuts[t]).Pts&&(e.IsOpen?this.FixupOutPolyline(e):this.FixupOutPolygon(e));return this.StrictlySimple&&this.DoSimplePolygons(),!0}finally{this.m_Joins.length=0,this.m_GhostJoins.length=0}},n.Clipper.prototype.DisposeAllPolyPts=function(){for(var e=0,t=this.m_PolyOuts.length;e<t;++e)this.DisposeOutRec(e);n.Clear(this.m_PolyOuts)},n.Clipper.prototype.AddJoin=function(e,t,i){var r=new n.Join;r.OutPt1=e,r.OutPt2=t,r.OffPt.X=i.X,r.OffPt.Y=i.Y,n.use_xyz&&(r.OffPt.Z=i.Z),this.m_Joins.push(r)},n.Clipper.prototype.AddGhostJoin=function(e,t){var i=new n.Join;i.OutPt1=e,i.OffPt.X=t.X,i.OffPt.Y=t.Y,n.use_xyz&&(i.OffPt.Z=t.Z),this.m_GhostJoins.push(i)},n.Clipper.prototype.SetZ=function(e,t,i){if(null!==this.ZFillFunction){if(0!==e.Z||null===this.ZFillFunction)return;n.IntPoint.op_Equality(e,t.Bot)?e.Z=t.Bot.Z:n.IntPoint.op_Equality(e,t.Top)?e.Z=t.Top.Z:n.IntPoint.op_Equality(e,i.Bot)?e.Z=i.Bot.Z:n.IntPoint.op_Equality(e,i.Top)?e.Z=i.Top.Z:this.ZFillFunction(t.Bot,t.Top,i.Bot,i.Top,e)}},n.Clipper.prototype.InsertLocalMinimaIntoAEL=function(e){for(var t,i,r={};this.PopLocalMinima(e,r);){t=r.v.LeftBound,i=r.v.RightBound;var a=null;if(null===t?(this.InsertEdgeIntoAEL(i,null),this.SetWindingCount(i),this.IsContributing(i)&&(a=this.AddOutPt(i,i.Bot))):null===i?(this.InsertEdgeIntoAEL(t,null),this.SetWindingCount(t),this.IsContributing(t)&&(a=this.AddOutPt(t,t.Bot)),this.InsertScanbeam(t.Top.Y)):(this.InsertEdgeIntoAEL(t,null),this.InsertEdgeIntoAEL(i,t),this.SetWindingCount(t),i.WindCnt=t.WindCnt,i.WindCnt2=t.WindCnt2,this.IsContributing(t)&&(a=this.AddLocalMinPoly(t,i,t.Bot)),this.InsertScanbeam(t.Top.Y)),null!==i&&(n.ClipperBase.IsHorizontal(i)?(null!==i.NextInLML&&this.InsertScanbeam(i.NextInLML.Top.Y),this.AddEdgeToSEL(i)):this.InsertScanbeam(i.Top.Y)),null!==t&&null!==i){if(null!==a&&n.ClipperBase.IsHorizontal(i)&&this.m_GhostJoins.length>0&&0!==i.WindDelta)for(var s=0,o=this.m_GhostJoins.length;s<o;s++){var l=this.m_GhostJoins[s];this.HorzSegmentsOverlap(l.OutPt1.Pt.X,l.OffPt.X,i.Bot.X,i.Top.X)&&this.AddJoin(l.OutPt1,a,l.OffPt)}if(t.OutIdx>=0&&null!==t.PrevInAEL&&t.PrevInAEL.Curr.X===t.Bot.X&&t.PrevInAEL.OutIdx>=0&&n.ClipperBase.SlopesEqual5(t.PrevInAEL.Curr,t.PrevInAEL.Top,t.Curr,t.Top,this.m_UseFullRange)&&0!==t.WindDelta&&0!==t.PrevInAEL.WindDelta){var h=this.AddOutPt(t.PrevInAEL,t.Bot);this.AddJoin(a,h,t.Top)}if(t.NextInAEL!==i){i.OutIdx>=0&&i.PrevInAEL.OutIdx>=0&&n.ClipperBase.SlopesEqual5(i.PrevInAEL.Curr,i.PrevInAEL.Top,i.Curr,i.Top,this.m_UseFullRange)&&0!==i.WindDelta&&0!==i.PrevInAEL.WindDelta&&(h=this.AddOutPt(i.PrevInAEL,i.Bot),this.AddJoin(a,h,i.Top));var u=t.NextInAEL;if(null!==u)for(;u!==i;)this.IntersectEdges(i,u,t.Curr),u=u.NextInAEL}}}},n.Clipper.prototype.InsertEdgeIntoAEL=function(e,t){if(null===this.m_ActiveEdges)e.PrevInAEL=null,e.NextInAEL=null,this.m_ActiveEdges=e;else if(null===t&&this.E2InsertsBeforeE1(this.m_ActiveEdges,e))e.PrevInAEL=null,e.NextInAEL=this.m_ActiveEdges,this.m_ActiveEdges.PrevInAEL=e,this.m_ActiveEdges=e;else{for(null===t&&(t=this.m_ActiveEdges);null!==t.NextInAEL&&!this.E2InsertsBeforeE1(t.NextInAEL,e);)t=t.NextInAEL;e.NextInAEL=t.NextInAEL,null!==t.NextInAEL&&(t.NextInAEL.PrevInAEL=e),e.PrevInAEL=t,t.NextInAEL=e}},n.Clipper.prototype.E2InsertsBeforeE1=function(e,t){return t.Curr.X===e.Curr.X?t.Top.Y>e.Top.Y?t.Top.X<n.Clipper.TopX(e,t.Top.Y):e.Top.X>n.Clipper.TopX(t,e.Top.Y):t.Curr.X<e.Curr.X},n.Clipper.prototype.IsEvenOddFillType=function(e){return e.PolyTyp===n.PolyType.ptSubject?this.m_SubjFillType===n.PolyFillType.pftEvenOdd:this.m_ClipFillType===n.PolyFillType.pftEvenOdd},n.Clipper.prototype.IsEvenOddAltFillType=function(e){return e.PolyTyp===n.PolyType.ptSubject?this.m_ClipFillType===n.PolyFillType.pftEvenOdd:this.m_SubjFillType===n.PolyFillType.pftEvenOdd},n.Clipper.prototype.IsContributing=function(e){var t,i;switch(e.PolyTyp===n.PolyType.ptSubject?(t=this.m_SubjFillType,i=this.m_ClipFillType):(t=this.m_ClipFillType,i=this.m_SubjFillType),t){case n.PolyFillType.pftEvenOdd:if(0===e.WindDelta&&1!==e.WindCnt)return!1;break;case n.PolyFillType.pftNonZero:if(1!==Math.abs(e.WindCnt))return!1;break;case n.PolyFillType.pftPositive:if(1!==e.WindCnt)return!1;break;default:if(-1!==e.WindCnt)return!1}switch(this.m_ClipType){case n.ClipType.ctIntersection:switch(i){case n.PolyFillType.pftEvenOdd:case n.PolyFillType.pftNonZero:return 0!==e.WindCnt2;case n.PolyFillType.pftPositive:return e.WindCnt2>0;default:return e.WindCnt2<0}case n.ClipType.ctUnion:switch(i){case n.PolyFillType.pftEvenOdd:case n.PolyFillType.pftNonZero:return 0===e.WindCnt2;case n.PolyFillType.pftPositive:return e.WindCnt2<=0;default:return e.WindCnt2>=0}case n.ClipType.ctDifference:if(e.PolyTyp===n.PolyType.ptSubject)switch(i){case n.PolyFillType.pftEvenOdd:case n.PolyFillType.pftNonZero:return 0===e.WindCnt2;case n.PolyFillType.pftPositive:return e.WindCnt2<=0;default:return e.WindCnt2>=0}else switch(i){case n.PolyFillType.pftEvenOdd:case n.PolyFillType.pftNonZero:return 0!==e.WindCnt2;case n.PolyFillType.pftPositive:return e.WindCnt2>0;default:return e.WindCnt2<0}case n.ClipType.ctXor:if(0!==e.WindDelta)return!0;switch(i){case n.PolyFillType.pftEvenOdd:case n.PolyFillType.pftNonZero:return 0===e.WindCnt2;case n.PolyFillType.pftPositive:return e.WindCnt2<=0;default:return e.WindCnt2>=0}}return!0},n.Clipper.prototype.SetWindingCount=function(e){for(var t=e.PrevInAEL;null!==t&&(t.PolyTyp!==e.PolyTyp||0===t.WindDelta);)t=t.PrevInAEL;if(null===t){var i=e.PolyTyp===n.PolyType.ptSubject?this.m_SubjFillType:this.m_ClipFillType;0===e.WindDelta?e.WindCnt=i===n.PolyFillType.pftNegative?-1:1:e.WindCnt=e.WindDelta,e.WindCnt2=0,t=this.m_ActiveEdges}else if(0===e.WindDelta&&this.m_ClipType!==n.ClipType.ctUnion)e.WindCnt=1,e.WindCnt2=t.WindCnt2,t=t.NextInAEL;else if(this.IsEvenOddFillType(e)){if(0===e.WindDelta){for(var r=!0,a=t.PrevInAEL;null!==a;)a.PolyTyp===t.PolyTyp&&0!==a.WindDelta&&(r=!r),a=a.PrevInAEL;e.WindCnt=r?0:1}else e.WindCnt=e.WindDelta;e.WindCnt2=t.WindCnt2,t=t.NextInAEL}else t.WindCnt*t.WindDelta<0?Math.abs(t.WindCnt)>1?t.WindDelta*e.WindDelta<0?e.WindCnt=t.WindCnt:e.WindCnt=t.WindCnt+e.WindDelta:e.WindCnt=0===e.WindDelta?1:e.WindDelta:0===e.WindDelta?e.WindCnt=t.WindCnt<0?t.WindCnt-1:t.WindCnt+1:t.WindDelta*e.WindDelta<0?e.WindCnt=t.WindCnt:e.WindCnt=t.WindCnt+e.WindDelta,e.WindCnt2=t.WindCnt2,t=t.NextInAEL;if(this.IsEvenOddAltFillType(e))for(;t!==e;)0!==t.WindDelta&&(e.WindCnt2=0===e.WindCnt2?1:0),t=t.NextInAEL;else for(;t!==e;)e.WindCnt2+=t.WindDelta,t=t.NextInAEL},n.Clipper.prototype.AddEdgeToSEL=function(e){null===this.m_SortedEdges?(this.m_SortedEdges=e,e.PrevInSEL=null,e.NextInSEL=null):(e.NextInSEL=this.m_SortedEdges,e.PrevInSEL=null,this.m_SortedEdges.PrevInSEL=e,this.m_SortedEdges=e)},n.Clipper.prototype.PopEdgeFromSEL=function(e){if(e.v=this.m_SortedEdges,null===e.v)return!1;var t=e.v;return this.m_SortedEdges=e.v.NextInSEL,null!==this.m_SortedEdges&&(this.m_SortedEdges.PrevInSEL=null),t.NextInSEL=null,t.PrevInSEL=null,!0},n.Clipper.prototype.CopyAELToSEL=function(){var e=this.m_ActiveEdges;for(this.m_SortedEdges=e;null!==e;)e.PrevInSEL=e.PrevInAEL,e.NextInSEL=e.NextInAEL,e=e.NextInAEL},n.Clipper.prototype.SwapPositionsInSEL=function(e,t){if(!(null===e.NextInSEL&&null===e.PrevInSEL||null===t.NextInSEL&&null===t.PrevInSEL)){if(e.NextInSEL===t)null!==(n=t.NextInSEL)&&(n.PrevInSEL=e),null!==(i=e.PrevInSEL)&&(i.NextInSEL=t),t.PrevInSEL=i,t.NextInSEL=e,e.PrevInSEL=t,e.NextInSEL=n;else if(t.NextInSEL===e)null!==(n=e.NextInSEL)&&(n.PrevInSEL=t),null!==(i=t.PrevInSEL)&&(i.NextInSEL=e),e.PrevInSEL=i,e.NextInSEL=t,t.PrevInSEL=e,t.NextInSEL=n;else{var n=e.NextInSEL,i=e.PrevInSEL;e.NextInSEL=t.NextInSEL,null!==e.NextInSEL&&(e.NextInSEL.PrevInSEL=e),e.PrevInSEL=t.PrevInSEL,null!==e.PrevInSEL&&(e.PrevInSEL.NextInSEL=e),t.NextInSEL=n,null!==t.NextInSEL&&(t.NextInSEL.PrevInSEL=t),t.PrevInSEL=i,null!==t.PrevInSEL&&(t.PrevInSEL.NextInSEL=t)}null===e.PrevInSEL?this.m_SortedEdges=e:null===t.PrevInSEL&&(this.m_SortedEdges=t)}},n.Clipper.prototype.AddLocalMaxPoly=function(e,t,n){this.AddOutPt(e,n),0===t.WindDelta&&this.AddOutPt(t,n),e.OutIdx===t.OutIdx?(e.OutIdx=-1,t.OutIdx=-1):e.OutIdx<t.OutIdx?this.AppendPolygon(e,t):this.AppendPolygon(t,e)},n.Clipper.prototype.AddLocalMinPoly=function(e,t,i){var r,a,s;if(n.ClipperBase.IsHorizontal(t)||e.Dx>t.Dx?(r=this.AddOutPt(e,i),t.OutIdx=e.OutIdx,e.Side=n.EdgeSide.esLeft,t.Side=n.EdgeSide.esRight,s=(a=e).PrevInAEL===t?t.PrevInAEL:a.PrevInAEL):(r=this.AddOutPt(t,i),e.OutIdx=t.OutIdx,e.Side=n.EdgeSide.esRight,t.Side=n.EdgeSide.esLeft,s=(a=t).PrevInAEL===e?e.PrevInAEL:a.PrevInAEL),null!==s&&s.OutIdx>=0&&s.Top.Y<i.Y&&a.Top.Y<i.Y){var o=n.Clipper.TopX(s,i.Y),l=n.Clipper.TopX(a,i.Y);if(o===l&&0!==a.WindDelta&&0!==s.WindDelta&&n.ClipperBase.SlopesEqual5(new n.IntPoint2(o,i.Y),s.Top,new n.IntPoint2(l,i.Y),a.Top,this.m_UseFullRange)){var h=this.AddOutPt(s,i);this.AddJoin(r,h,a.Top)}}return r},n.Clipper.prototype.AddOutPt=function(e,t){if(e.OutIdx<0){(r=this.CreateOutRec()).IsOpen=0===e.WindDelta;var i=new n.OutPt;return r.Pts=i,i.Idx=r.Idx,i.Pt.X=t.X,i.Pt.Y=t.Y,n.use_xyz&&(i.Pt.Z=t.Z),i.Next=i,i.Prev=i,r.IsOpen||this.SetHoleState(e,r),e.OutIdx=r.Idx,i}var r,a=(r=this.m_PolyOuts[e.OutIdx]).Pts,s=e.Side===n.EdgeSide.esLeft;return s&&n.IntPoint.op_Equality(t,a.Pt)?a:!s&&n.IntPoint.op_Equality(t,a.Prev.Pt)?a.Prev:((i=new n.OutPt).Idx=r.Idx,i.Pt.X=t.X,i.Pt.Y=t.Y,n.use_xyz&&(i.Pt.Z=t.Z),i.Next=a,i.Prev=a.Prev,i.Prev.Next=i,a.Prev=i,s&&(r.Pts=i),i)},n.Clipper.prototype.GetLastOutPt=function(e){var t=this.m_PolyOuts[e.OutIdx];return e.Side===n.EdgeSide.esLeft?t.Pts:t.Pts.Prev},n.Clipper.prototype.SwapPoints=function(e,t){var i=new n.IntPoint1(e.Value);e.Value.X=t.Value.X,e.Value.Y=t.Value.Y,n.use_xyz&&(e.Value.Z=t.Value.Z),t.Value.X=i.X,t.Value.Y=i.Y,n.use_xyz&&(t.Value.Z=i.Z)},n.Clipper.prototype.HorzSegmentsOverlap=function(e,t,n,i){var r;return e>t&&(r=e,e=t,t=r),n>i&&(r=n,n=i,i=r),e<i&&n<t},n.Clipper.prototype.SetHoleState=function(e,t){for(var n=e.PrevInAEL,i=null;null!==n;)n.OutIdx>=0&&0!==n.WindDelta&&(null===i?i=n:i.OutIdx===n.OutIdx&&(i=null)),n=n.PrevInAEL;null===i?(t.FirstLeft=null,t.IsHole=!1):(t.FirstLeft=this.m_PolyOuts[i.OutIdx],t.IsHole=!t.FirstLeft.IsHole)},n.Clipper.prototype.GetDx=function(e,t){return e.Y===t.Y?n.ClipperBase.horizontal:(t.X-e.X)/(t.Y-e.Y)},n.Clipper.prototype.FirstIsBottomPt=function(e,t){for(var i=e.Prev;n.IntPoint.op_Equality(i.Pt,e.Pt)&&i!==e;)i=i.Prev;var r=Math.abs(this.GetDx(e.Pt,i.Pt));for(i=e.Next;n.IntPoint.op_Equality(i.Pt,e.Pt)&&i!==e;)i=i.Next;var a=Math.abs(this.GetDx(e.Pt,i.Pt));for(i=t.Prev;n.IntPoint.op_Equality(i.Pt,t.Pt)&&i!==t;)i=i.Prev;var s=Math.abs(this.GetDx(t.Pt,i.Pt));for(i=t.Next;n.IntPoint.op_Equality(i.Pt,t.Pt)&&i!==t;)i=i.Next;var o=Math.abs(this.GetDx(t.Pt,i.Pt));return Math.max(r,a)===Math.max(s,o)&&Math.min(r,a)===Math.min(s,o)?this.Area(e)>0:r>=s&&r>=o||a>=s&&a>=o},n.Clipper.prototype.GetBottomPt=function(e){for(var t=null,i=e.Next;i!==e;)i.Pt.Y>e.Pt.Y?(e=i,t=null):i.Pt.Y===e.Pt.Y&&i.Pt.X<=e.Pt.X&&(i.Pt.X<e.Pt.X?(t=null,e=i):i.Next!==e&&i.Prev!==e&&(t=i)),i=i.Next;if(null!==t)for(;t!==i;)for(this.FirstIsBottomPt(i,t)||(e=t),t=t.Next;n.IntPoint.op_Inequality(t.Pt,e.Pt);)t=t.Next;return e},n.Clipper.prototype.GetLowermostRec=function(e,t){null===e.BottomPt&&(e.BottomPt=this.GetBottomPt(e.Pts)),null===t.BottomPt&&(t.BottomPt=this.GetBottomPt(t.Pts));var n=e.BottomPt,i=t.BottomPt;return n.Pt.Y>i.Pt.Y?e:n.Pt.Y<i.Pt.Y?t:n.Pt.X<i.Pt.X?e:n.Pt.X>i.Pt.X||n.Next===n?t:i.Next===i||this.FirstIsBottomPt(n,i)?e:t},n.Clipper.prototype.OutRec1RightOfOutRec2=function(e,t){do{if((e=e.FirstLeft)===t)return!0}while(null!==e);return!1},n.Clipper.prototype.GetOutRec=function(e){for(var t=this.m_PolyOuts[e];t!==this.m_PolyOuts[t.Idx];)t=this.m_PolyOuts[t.Idx];return t},n.Clipper.prototype.AppendPolygon=function(e,t){var i,r=this.m_PolyOuts[e.OutIdx],a=this.m_PolyOuts[t.OutIdx];i=this.OutRec1RightOfOutRec2(r,a)?a:this.OutRec1RightOfOutRec2(a,r)?r:this.GetLowermostRec(r,a);var s=r.Pts,o=s.Prev,l=a.Pts,h=l.Prev;e.Side===n.EdgeSide.esLeft?t.Side===n.EdgeSide.esLeft?(this.ReversePolyPtLinks(l),l.Next=s,s.Prev=l,o.Next=h,h.Prev=o,r.Pts=h):(h.Next=s,s.Prev=h,l.Prev=o,o.Next=l,r.Pts=l):t.Side===n.EdgeSide.esRight?(this.ReversePolyPtLinks(l),o.Next=h,h.Prev=o,l.Next=s,s.Prev=l):(o.Next=l,l.Prev=o,s.Prev=h,h.Next=s),r.BottomPt=null,i===a&&(a.FirstLeft!==r&&(r.FirstLeft=a.FirstLeft),r.IsHole=a.IsHole),a.Pts=null,a.BottomPt=null,a.FirstLeft=r;var u=e.OutIdx,c=t.OutIdx;e.OutIdx=-1,t.OutIdx=-1;for(var d=this.m_ActiveEdges;null!==d;){if(d.OutIdx===c){d.OutIdx=u,d.Side=e.Side;break}d=d.NextInAEL}a.Idx=r.Idx},n.Clipper.prototype.ReversePolyPtLinks=function(e){if(null!==e){var t,n;t=e;do{n=t.Next,t.Next=t.Prev,t.Prev=n,t=n}while(t!==e)}},n.Clipper.SwapSides=function(e,t){var n=e.Side;e.Side=t.Side,t.Side=n},n.Clipper.SwapPolyIndexes=function(e,t){var n=e.OutIdx;e.OutIdx=t.OutIdx,t.OutIdx=n},n.Clipper.prototype.IntersectEdges=function(e,t,i){var r=e.OutIdx>=0,a=t.OutIdx>=0;if(n.use_xyz&&this.SetZ(i,e,t),!n.use_lines||0!==e.WindDelta&&0!==t.WindDelta){if(e.PolyTyp===t.PolyTyp)if(this.IsEvenOddFillType(e)){var s=e.WindCnt;e.WindCnt=t.WindCnt,t.WindCnt=s}else e.WindCnt+t.WindDelta===0?e.WindCnt=-e.WindCnt:e.WindCnt+=t.WindDelta,t.WindCnt-e.WindDelta==0?t.WindCnt=-t.WindCnt:t.WindCnt-=e.WindDelta;else this.IsEvenOddFillType(t)?e.WindCnt2=0===e.WindCnt2?1:0:e.WindCnt2+=t.WindDelta,this.IsEvenOddFillType(e)?t.WindCnt2=0===t.WindCnt2?1:0:t.WindCnt2-=e.WindDelta;var o,l,h,u,c,d;switch(e.PolyTyp===n.PolyType.ptSubject?(o=this.m_SubjFillType,h=this.m_ClipFillType):(o=this.m_ClipFillType,h=this.m_SubjFillType),t.PolyTyp===n.PolyType.ptSubject?(l=this.m_SubjFillType,u=this.m_ClipFillType):(l=this.m_ClipFillType,u=this.m_SubjFillType),o){case n.PolyFillType.pftPositive:c=e.WindCnt;break;case n.PolyFillType.pftNegative:c=-e.WindCnt;break;default:c=Math.abs(e.WindCnt)}switch(l){case n.PolyFillType.pftPositive:d=t.WindCnt;break;case n.PolyFillType.pftNegative:d=-t.WindCnt;break;default:d=Math.abs(t.WindCnt)}if(r&&a)0!==c&&1!==c||0!==d&&1!==d||e.PolyTyp!==t.PolyTyp&&this.m_ClipType!==n.ClipType.ctXor?this.AddLocalMaxPoly(e,t,i):(this.AddOutPt(e,i),this.AddOutPt(t,i),n.Clipper.SwapSides(e,t),n.Clipper.SwapPolyIndexes(e,t));else if(r)(0===d||1===d)&&(this.AddOutPt(e,i),n.Clipper.SwapSides(e,t),n.Clipper.SwapPolyIndexes(e,t));else if(a)(0===c||1===c)&&(this.AddOutPt(t,i),n.Clipper.SwapSides(e,t),n.Clipper.SwapPolyIndexes(e,t));else if(!(0!==c&&1!==c||0!==d&&1!==d)){var p,f;switch(h){case n.PolyFillType.pftPositive:p=e.WindCnt2;break;case n.PolyFillType.pftNegative:p=-e.WindCnt2;break;default:p=Math.abs(e.WindCnt2)}switch(u){case n.PolyFillType.pftPositive:f=t.WindCnt2;break;case n.PolyFillType.pftNegative:f=-t.WindCnt2;break;default:f=Math.abs(t.WindCnt2)}if(e.PolyTyp!==t.PolyTyp)this.AddLocalMinPoly(e,t,i);else if(1===c&&1===d)switch(this.m_ClipType){case n.ClipType.ctIntersection:p>0&&f>0&&this.AddLocalMinPoly(e,t,i);break;case n.ClipType.ctUnion:p<=0&&f<=0&&this.AddLocalMinPoly(e,t,i);break;case n.ClipType.ctDifference:(e.PolyTyp===n.PolyType.ptClip&&p>0&&f>0||e.PolyTyp===n.PolyType.ptSubject&&p<=0&&f<=0)&&this.AddLocalMinPoly(e,t,i);break;case n.ClipType.ctXor:this.AddLocalMinPoly(e,t,i)}else n.Clipper.SwapSides(e,t)}}else{if(0===e.WindDelta&&0===t.WindDelta)return;e.PolyTyp===t.PolyTyp&&e.WindDelta!==t.WindDelta&&this.m_ClipType===n.ClipType.ctUnion?0===e.WindDelta?a&&(this.AddOutPt(e,i),r&&(e.OutIdx=-1)):r&&(this.AddOutPt(t,i),a&&(t.OutIdx=-1)):e.PolyTyp!==t.PolyTyp&&(0!==e.WindDelta||1!==Math.abs(t.WindCnt)||this.m_ClipType===n.ClipType.ctUnion&&0!==t.WindCnt2?0===t.WindDelta&&1===Math.abs(e.WindCnt)&&(this.m_ClipType!==n.ClipType.ctUnion||0===e.WindCnt2)&&(this.AddOutPt(t,i),a&&(t.OutIdx=-1)):(this.AddOutPt(e,i),r&&(e.OutIdx=-1)))}},n.Clipper.prototype.DeleteFromSEL=function(e){var t=e.PrevInSEL,n=e.NextInSEL;null===t&&null===n&&e!==this.m_SortedEdges||(null!==t?t.NextInSEL=n:this.m_SortedEdges=n,null!==n&&(n.PrevInSEL=t),e.NextInSEL=null,e.PrevInSEL=null)},n.Clipper.prototype.ProcessHorizontals=function(){for(var e={};this.PopEdgeFromSEL(e);)this.ProcessHorizontal(e.v)},n.Clipper.prototype.GetHorzDirection=function(e,t){e.Bot.X<e.Top.X?(t.Left=e.Bot.X,t.Right=e.Top.X,t.Dir=n.Direction.dLeftToRight):(t.Left=e.Top.X,t.Right=e.Bot.X,t.Dir=n.Direction.dRightToLeft)},n.Clipper.prototype.ProcessHorizontal=function(e){var t={Dir:null,Left:null,Right:null};this.GetHorzDirection(e,t);for(var i=t.Dir,r=t.Left,a=t.Right,s=0===e.WindDelta,o=e,l=null;null!==o.NextInLML&&n.ClipperBase.IsHorizontal(o.NextInLML);)o=o.NextInLML;null===o.NextInLML&&(l=this.GetMaximaPair(o));var h=this.m_Maxima;if(null!==h)if(i===n.Direction.dLeftToRight){for(;null!==h&&h.X<=e.Bot.X;)h=h.Next;null!==h&&h.X>=o.Top.X&&(h=null)}else{for(;null!==h.Next&&h.Next.X<e.Bot.X;)h=h.Next;h.X<=o.Top.X&&(h=null)}for(var u=null;;){for(var c=e===o,d=this.GetNextInAEL(e,i);null!==d;){if(null!==h)if(i===n.Direction.dLeftToRight)for(;null!==h&&h.X<d.Curr.X;)e.OutIdx>=0&&!s&&this.AddOutPt(e,new n.IntPoint2(h.X,e.Bot.Y)),h=h.Next;else for(;null!==h&&h.X>d.Curr.X;)e.OutIdx>=0&&!s&&this.AddOutPt(e,new n.IntPoint2(h.X,e.Bot.Y)),h=h.Prev;if(i===n.Direction.dLeftToRight&&d.Curr.X>a||i===n.Direction.dRightToLeft&&d.Curr.X<r||d.Curr.X===e.Top.X&&null!==e.NextInLML&&d.Dx<e.NextInLML.Dx)break;if(e.OutIdx>=0&&!s){n.use_xyz&&(i===n.Direction.dLeftToRight?this.SetZ(d.Curr,e,d):this.SetZ(d.Curr,d,e)),u=this.AddOutPt(e,d.Curr);for(var p=this.m_SortedEdges;null!==p;){if(p.OutIdx>=0&&this.HorzSegmentsOverlap(e.Bot.X,e.Top.X,p.Bot.X,p.Top.X)){var f=this.GetLastOutPt(p);this.AddJoin(f,u,p.Top)}p=p.NextInSEL}this.AddGhostJoin(u,e.Bot)}if(d===l&&c)return e.OutIdx>=0&&this.AddLocalMaxPoly(e,l,e.Top),this.DeleteFromAEL(e),void this.DeleteFromAEL(l);if(i===n.Direction.dLeftToRight){var m=new n.IntPoint2(d.Curr.X,e.Curr.Y);this.IntersectEdges(e,d,m)}else m=new n.IntPoint2(d.Curr.X,e.Curr.Y),this.IntersectEdges(d,e,m);var g=this.GetNextInAEL(d,i);this.SwapPositionsInAEL(e,d),d=g}if(null===e.NextInLML||!n.ClipperBase.IsHorizontal(e.NextInLML))break;(e=this.UpdateEdgeIntoAEL(e)).OutIdx>=0&&this.AddOutPt(e,e.Bot),t={Dir:i,Left:r,Right:a},this.GetHorzDirection(e,t),i=t.Dir,r=t.Left,a=t.Right}if(e.OutIdx>=0&&null===u){for(u=this.GetLastOutPt(e),p=this.m_SortedEdges;null!==p;)p.OutIdx>=0&&this.HorzSegmentsOverlap(e.Bot.X,e.Top.X,p.Bot.X,p.Top.X)&&(f=this.GetLastOutPt(p),this.AddJoin(f,u,p.Top)),p=p.NextInSEL;this.AddGhostJoin(u,e.Top)}if(null!==e.NextInLML)if(e.OutIdx>=0){if(u=this.AddOutPt(e,e.Top),0===(e=this.UpdateEdgeIntoAEL(e)).WindDelta)return;var v=e.PrevInAEL;g=e.NextInAEL,null!==v&&v.Curr.X===e.Bot.X&&v.Curr.Y===e.Bot.Y&&0===v.WindDelta&&v.OutIdx>=0&&v.Curr.Y>v.Top.Y&&n.ClipperBase.SlopesEqual3(e,v,this.m_UseFullRange)?(f=this.AddOutPt(v,e.Bot),this.AddJoin(u,f,e.Top)):null!==g&&g.Curr.X===e.Bot.X&&g.Curr.Y===e.Bot.Y&&0!==g.WindDelta&&g.OutIdx>=0&&g.Curr.Y>g.Top.Y&&n.ClipperBase.SlopesEqual3(e,g,this.m_UseFullRange)&&(f=this.AddOutPt(g,e.Bot),this.AddJoin(u,f,e.Top))}else e=this.UpdateEdgeIntoAEL(e);else e.OutIdx>=0&&this.AddOutPt(e,e.Top),this.DeleteFromAEL(e)},n.Clipper.prototype.GetNextInAEL=function(e,t){return t===n.Direction.dLeftToRight?e.NextInAEL:e.PrevInAEL},n.Clipper.prototype.IsMinima=function(e){return null!==e&&e.Prev.NextInLML!==e&&e.Next.NextInLML!==e},n.Clipper.prototype.IsMaxima=function(e,t){return null!==e&&e.Top.Y===t&&null===e.NextInLML},n.Clipper.prototype.IsIntermediate=function(e,t){return e.Top.Y===t&&null!==e.NextInLML},n.Clipper.prototype.GetMaximaPair=function(e){return n.IntPoint.op_Equality(e.Next.Top,e.Top)&&null===e.Next.NextInLML?e.Next:n.IntPoint.op_Equality(e.Prev.Top,e.Top)&&null===e.Prev.NextInLML?e.Prev:null},n.Clipper.prototype.GetMaximaPairEx=function(e){var t=this.GetMaximaPair(e);return null===t||t.OutIdx===n.ClipperBase.Skip||t.NextInAEL===t.PrevInAEL&&!n.ClipperBase.IsHorizontal(t)?null:t},n.Clipper.prototype.ProcessIntersections=function(e){if(null===this.m_ActiveEdges)return!0;try{if(this.BuildIntersectList(e),0===this.m_IntersectList.length)return!0;if(1!==this.m_IntersectList.length&&!this.FixupIntersectionOrder())return!1;this.ProcessIntersectList()}catch(e){this.m_SortedEdges=null,this.m_IntersectList.length=0,n.Error("ProcessIntersections error")}return this.m_SortedEdges=null,!0},n.Clipper.prototype.BuildIntersectList=function(e){if(null!==this.m_ActiveEdges){var t=this.m_ActiveEdges;for(this.m_SortedEdges=t;null!==t;)t.PrevInSEL=t.PrevInAEL,t.NextInSEL=t.NextInAEL,t.Curr.X=n.Clipper.TopX(t,e),t=t.NextInAEL;for(var i=!0;i&&null!==this.m_SortedEdges;){for(i=!1,t=this.m_SortedEdges;null!==t.NextInSEL;){var r=t.NextInSEL,a=new n.IntPoint0;if(t.Curr.X>r.Curr.X){this.IntersectPoint(t,r,a),a.Y<e&&(a=new n.IntPoint2(n.Clipper.TopX(t,e),e));var s=new n.IntersectNode;s.Edge1=t,s.Edge2=r,s.Pt.X=a.X,s.Pt.Y=a.Y,n.use_xyz&&(s.Pt.Z=a.Z),this.m_IntersectList.push(s),this.SwapPositionsInSEL(t,r),i=!0}else t=r}if(null===t.PrevInSEL)break;t.PrevInSEL.NextInSEL=null}this.m_SortedEdges=null}},n.Clipper.prototype.EdgesAdjacent=function(e){return e.Edge1.NextInSEL===e.Edge2||e.Edge1.PrevInSEL===e.Edge2},n.Clipper.IntersectNodeSort=function(e,t){return t.Pt.Y-e.Pt.Y},n.Clipper.prototype.FixupIntersectionOrder=function(){this.m_IntersectList.sort(this.m_IntersectNodeComparer),this.CopyAELToSEL();for(var e=this.m_IntersectList.length,t=0;t<e;t++){if(!this.EdgesAdjacent(this.m_IntersectList[t])){for(var n=t+1;n<e&&!this.EdgesAdjacent(this.m_IntersectList[n]);)n++;if(n===e)return!1;var i=this.m_IntersectList[t];this.m_IntersectList[t]=this.m_IntersectList[n],this.m_IntersectList[n]=i}this.SwapPositionsInSEL(this.m_IntersectList[t].Edge1,this.m_IntersectList[t].Edge2)}return!0},n.Clipper.prototype.ProcessIntersectList=function(){for(var e=0,t=this.m_IntersectList.length;e<t;e++){var n=this.m_IntersectList[e];this.IntersectEdges(n.Edge1,n.Edge2,n.Pt),this.SwapPositionsInAEL(n.Edge1,n.Edge2)}this.m_IntersectList.length=0},s.msie?n.Clipper.Round=function(e){return e<0?Math.ceil(e-.5):Math.round(e)}:s.chromium?n.Clipper.Round=function(e){return e<0?-Math.round(Math.abs(e)):Math.round(e)}:s.safari?n.Clipper.Round=function(e){return e<0?(e-=.5)<-2147483648?Math.ceil(e):0|e:(e+=.5)>2147483647?Math.floor(e):0|e}:n.Clipper.Round=function(e){return e<0?Math.ceil(e-.5):Math.floor(e+.5)},n.Clipper.TopX=function(e,t){return t===e.Top.Y?e.Top.X:e.Bot.X+n.Clipper.Round(e.Dx*(t-e.Bot.Y))},n.Clipper.prototype.IntersectPoint=function(e,t,i){var r,a;if(i.X=0,i.Y=0,e.Dx===t.Dx)return i.Y=e.Curr.Y,void(i.X=n.Clipper.TopX(e,i.Y));if(0===e.Delta.X)i.X=e.Bot.X,n.ClipperBase.IsHorizontal(t)?i.Y=t.Bot.Y:(a=t.Bot.Y-t.Bot.X/t.Dx,i.Y=n.Clipper.Round(i.X/t.Dx+a));else if(0===t.Delta.X)i.X=t.Bot.X,n.ClipperBase.IsHorizontal(e)?i.Y=e.Bot.Y:(r=e.Bot.Y-e.Bot.X/e.Dx,i.Y=n.Clipper.Round(i.X/e.Dx+r));else{r=e.Bot.X-e.Bot.Y*e.Dx;var s=((a=t.Bot.X-t.Bot.Y*t.Dx)-r)/(e.Dx-t.Dx);i.Y=n.Clipper.Round(s),Math.abs(e.Dx)<Math.abs(t.Dx)?i.X=n.Clipper.Round(e.Dx*s+r):i.X=n.Clipper.Round(t.Dx*s+a)}if(i.Y<e.Top.Y||i.Y<t.Top.Y){if(e.Top.Y>t.Top.Y)return i.Y=e.Top.Y,i.X=n.Clipper.TopX(t,e.Top.Y),i.X<e.Top.X;i.Y=t.Top.Y,Math.abs(e.Dx)<Math.abs(t.Dx)?i.X=n.Clipper.TopX(e,i.Y):i.X=n.Clipper.TopX(t,i.Y)}i.Y>e.Curr.Y&&(i.Y=e.Curr.Y,Math.abs(e.Dx)>Math.abs(t.Dx)?i.X=n.Clipper.TopX(t,i.Y):i.X=n.Clipper.TopX(e,i.Y))},n.Clipper.prototype.ProcessEdgesAtTopOfScanbeam=function(e){for(var t=this.m_ActiveEdges;null!==t;){var i=this.IsMaxima(t,e);if(i){var r=this.GetMaximaPairEx(t);i=null===r||!n.ClipperBase.IsHorizontal(r)}if(i){this.StrictlySimple&&this.InsertMaxima(t.Top.X);var a=t.PrevInAEL;this.DoMaxima(t),t=null===a?this.m_ActiveEdges:a.NextInAEL}else{if(this.IsIntermediate(t,e)&&n.ClipperBase.IsHorizontal(t.NextInLML)?((t=this.UpdateEdgeIntoAEL(t)).OutIdx>=0&&this.AddOutPt(t,t.Bot),this.AddEdgeToSEL(t)):(t.Curr.X=n.Clipper.TopX(t,e),t.Curr.Y=e),n.use_xyz&&(t.Top.Y===e?t.Curr.Z=t.Top.Z:t.Bot.Y===e?t.Curr.Z=t.Bot.Z:t.Curr.Z=0),this.StrictlySimple&&(a=t.PrevInAEL,t.OutIdx>=0&&0!==t.WindDelta&&null!==a&&a.OutIdx>=0&&a.Curr.X===t.Curr.X&&0!==a.WindDelta)){var s=new n.IntPoint1(t.Curr);n.use_xyz&&this.SetZ(s,a,t);var o=this.AddOutPt(a,s),l=this.AddOutPt(t,s);this.AddJoin(o,l,s)}t=t.NextInAEL}}for(this.ProcessHorizontals(),this.m_Maxima=null,t=this.m_ActiveEdges;null!==t;){if(this.IsIntermediate(t,e)){o=null,t.OutIdx>=0&&(o=this.AddOutPt(t,t.Top)),a=(t=this.UpdateEdgeIntoAEL(t)).PrevInAEL;var h=t.NextInAEL;null!==a&&a.Curr.X===t.Bot.X&&a.Curr.Y===t.Bot.Y&&null!==o&&a.OutIdx>=0&&a.Curr.Y===a.Top.Y&&n.ClipperBase.SlopesEqual5(t.Curr,t.Top,a.Curr,a.Top,this.m_UseFullRange)&&0!==t.WindDelta&&0!==a.WindDelta?(l=this.AddOutPt(ePrev2,t.Bot),this.AddJoin(o,l,t.Top)):null!==h&&h.Curr.X===t.Bot.X&&h.Curr.Y===t.Bot.Y&&null!==o&&h.OutIdx>=0&&h.Curr.Y===h.Top.Y&&n.ClipperBase.SlopesEqual5(t.Curr,t.Top,h.Curr,h.Top,this.m_UseFullRange)&&0!==t.WindDelta&&0!==h.WindDelta&&(l=this.AddOutPt(h,t.Bot),this.AddJoin(o,l,t.Top))}t=t.NextInAEL}},n.Clipper.prototype.DoMaxima=function(e){var t=this.GetMaximaPairEx(e);if(null===t)return e.OutIdx>=0&&this.AddOutPt(e,e.Top),void this.DeleteFromAEL(e);for(var i=e.NextInAEL;null!==i&&i!==t;)this.IntersectEdges(e,i,e.Top),this.SwapPositionsInAEL(e,i),i=e.NextInAEL;-1===e.OutIdx&&-1===t.OutIdx?(this.DeleteFromAEL(e),this.DeleteFromAEL(t)):e.OutIdx>=0&&t.OutIdx>=0?(e.OutIdx>=0&&this.AddLocalMaxPoly(e,t,e.Top),this.DeleteFromAEL(e),this.DeleteFromAEL(t)):n.use_lines&&0===e.WindDelta?(e.OutIdx>=0&&(this.AddOutPt(e,e.Top),e.OutIdx=n.ClipperBase.Unassigned),this.DeleteFromAEL(e),t.OutIdx>=0&&(this.AddOutPt(t,e.Top),t.OutIdx=n.ClipperBase.Unassigned),this.DeleteFromAEL(t)):n.Error("DoMaxima error")},n.Clipper.ReversePaths=function(e){for(var t=0,n=e.length;t<n;t++)e[t].reverse()},n.Clipper.Orientation=function(e){return n.Clipper.Area(e)>=0},n.Clipper.prototype.PointCount=function(e){if(null===e)return 0;var t=0,n=e;do{t++,n=n.Next}while(n!==e);return t},n.Clipper.prototype.BuildResult=function(e){n.Clear(e);for(var t=0,i=this.m_PolyOuts.length;t<i;t++){var r=this.m_PolyOuts[t];if(null!==r.Pts){var a=r.Pts.Prev,s=this.PointCount(a);if(!(s<2)){for(var o=new Array(s),l=0;l<s;l++)o[l]=a.Pt,a=a.Prev;e.push(o)}}}},n.Clipper.prototype.BuildResult2=function(e){e.Clear();for(var t=0,i=this.m_PolyOuts.length;t<i;t++){var r=this.m_PolyOuts[t],a=this.PointCount(r.Pts);if(!(r.IsOpen&&a<2||!r.IsOpen&&a<3)){this.FixHoleLinkage(r);var s=new n.PolyNode;e.m_AllPolys.push(s),r.PolyNode=s,s.m_polygon.length=a;for(var o=r.Pts.Prev,l=0;l<a;l++)s.m_polygon[l]=o.Pt,o=o.Prev}}for(t=0,i=this.m_PolyOuts.length;t<i;t++)null!==(r=this.m_PolyOuts[t]).PolyNode&&(r.IsOpen?(r.PolyNode.IsOpen=!0,e.AddChild(r.PolyNode)):null!==r.FirstLeft&&null!==r.FirstLeft.PolyNode?r.FirstLeft.PolyNode.AddChild(r.PolyNode):e.AddChild(r.PolyNode))},n.Clipper.prototype.FixupOutPolyline=function(e){for(var t=e.Pts,i=t.Prev;t!==i;)if(t=t.Next,n.IntPoint.op_Equality(t.Pt,t.Prev.Pt)){t===i&&(i=t.Prev);var r=t.Prev;r.Next=t.Next,t.Next.Prev=r,t=r}t===t.Prev&&(e.Pts=null)},n.Clipper.prototype.FixupOutPolygon=function(e){var t=null;e.BottomPt=null;for(var i=e.Pts,r=this.PreserveCollinear||this.StrictlySimple;;){if(i.Prev===i||i.Prev===i.Next)return void(e.Pts=null);if(n.IntPoint.op_Equality(i.Pt,i.Next.Pt)||n.IntPoint.op_Equality(i.Pt,i.Prev.Pt)||n.ClipperBase.SlopesEqual4(i.Prev.Pt,i.Pt,i.Next.Pt,this.m_UseFullRange)&&(!r||!this.Pt2IsBetweenPt1AndPt3(i.Prev.Pt,i.Pt,i.Next.Pt)))t=null,i.Prev.Next=i.Next,i.Next.Prev=i.Prev,i=i.Prev;else{if(i===t)break;null===t&&(t=i),i=i.Next}}e.Pts=i},n.Clipper.prototype.DupOutPt=function(e,t){var i=new n.OutPt;return i.Pt.X=e.Pt.X,i.Pt.Y=e.Pt.Y,n.use_xyz&&(i.Pt.Z=e.Pt.Z),i.Idx=e.Idx,t?(i.Next=e.Next,i.Prev=e,e.Next.Prev=i,e.Next=i):(i.Prev=e.Prev,i.Next=e,e.Prev.Next=i,e.Prev=i),i},n.Clipper.prototype.GetOverlap=function(e,t,n,i,r){return e<t?n<i?(r.Left=Math.max(e,n),r.Right=Math.min(t,i)):(r.Left=Math.max(e,i),r.Right=Math.min(t,n)):n<i?(r.Left=Math.max(t,n),r.Right=Math.min(e,i)):(r.Left=Math.max(t,i),r.Right=Math.min(e,n)),r.Left<r.Right},n.Clipper.prototype.JoinHorz=function(e,t,i,r,a,s){var o=e.Pt.X>t.Pt.X?n.Direction.dRightToLeft:n.Direction.dLeftToRight,l=i.Pt.X>r.Pt.X?n.Direction.dRightToLeft:n.Direction.dLeftToRight;if(o===l)return!1;if(o===n.Direction.dLeftToRight){for(;e.Next.Pt.X<=a.X&&e.Next.Pt.X>=e.Pt.X&&e.Next.Pt.Y===a.Y;)e=e.Next;s&&e.Pt.X!==a.X&&(e=e.Next),t=this.DupOutPt(e,!s),n.IntPoint.op_Inequality(t.Pt,a)&&((e=t).Pt.X=a.X,e.Pt.Y=a.Y,n.use_xyz&&(e.Pt.Z=a.Z),t=this.DupOutPt(e,!s))}else{for(;e.Next.Pt.X>=a.X&&e.Next.Pt.X<=e.Pt.X&&e.Next.Pt.Y===a.Y;)e=e.Next;!s&&e.Pt.X!==a.X&&(e=e.Next),t=this.DupOutPt(e,s),n.IntPoint.op_Inequality(t.Pt,a)&&((e=t).Pt.X=a.X,e.Pt.Y=a.Y,n.use_xyz&&(e.Pt.Z=a.Z),t=this.DupOutPt(e,s))}if(l===n.Direction.dLeftToRight){for(;i.Next.Pt.X<=a.X&&i.Next.Pt.X>=i.Pt.X&&i.Next.Pt.Y===a.Y;)i=i.Next;s&&i.Pt.X!==a.X&&(i=i.Next),r=this.DupOutPt(i,!s),n.IntPoint.op_Inequality(r.Pt,a)&&((i=r).Pt.X=a.X,i.Pt.Y=a.Y,n.use_xyz&&(i.Pt.Z=a.Z),r=this.DupOutPt(i,!s))}else{for(;i.Next.Pt.X>=a.X&&i.Next.Pt.X<=i.Pt.X&&i.Next.Pt.Y===a.Y;)i=i.Next;!s&&i.Pt.X!==a.X&&(i=i.Next),r=this.DupOutPt(i,s),n.IntPoint.op_Inequality(r.Pt,a)&&((i=r).Pt.X=a.X,i.Pt.Y=a.Y,n.use_xyz&&(i.Pt.Z=a.Z),r=this.DupOutPt(i,s))}return o===n.Direction.dLeftToRight===s?(e.Prev=i,i.Next=e,t.Next=r,r.Prev=t):(e.Next=i,i.Prev=e,t.Prev=r,r.Next=t),!0},n.Clipper.prototype.JoinPoints=function(e,t,i){var r=e.OutPt1,a=new n.OutPt,s=e.OutPt2,o=new n.OutPt,l=e.OutPt1.Pt.Y===e.OffPt.Y;if(l&&n.IntPoint.op_Equality(e.OffPt,e.OutPt1.Pt)&&n.IntPoint.op_Equality(e.OffPt,e.OutPt2.Pt)){if(t!==i)return!1;for(a=e.OutPt1.Next;a!==r&&n.IntPoint.op_Equality(a.Pt,e.OffPt);)a=a.Next;var h=a.Pt.Y>e.OffPt.Y;for(o=e.OutPt2.Next;o!==s&&n.IntPoint.op_Equality(o.Pt,e.OffPt);)o=o.Next;return h!==o.Pt.Y>e.OffPt.Y&&(h?(a=this.DupOutPt(r,!1),o=this.DupOutPt(s,!0),r.Prev=s,s.Next=r,a.Next=o,o.Prev=a,e.OutPt1=r,e.OutPt2=a,!0):(a=this.DupOutPt(r,!0),o=this.DupOutPt(s,!1),r.Next=s,s.Prev=r,a.Prev=o,o.Next=a,e.OutPt1=r,e.OutPt2=a,!0))}if(l){for(a=r;r.Prev.Pt.Y===r.Pt.Y&&r.Prev!==a&&r.Prev!==s;)r=r.Prev;for(;a.Next.Pt.Y===a.Pt.Y&&a.Next!==r&&a.Next!==s;)a=a.Next;if(a.Next===r||a.Next===s)return!1;for(o=s;s.Prev.Pt.Y===s.Pt.Y&&s.Prev!==o&&s.Prev!==a;)s=s.Prev;for(;o.Next.Pt.Y===o.Pt.Y&&o.Next!==s&&o.Next!==r;)o=o.Next;if(o.Next===s||o.Next===r)return!1;var u={Left:null,Right:null};if(!this.GetOverlap(r.Pt.X,a.Pt.X,s.Pt.X,o.Pt.X,u))return!1;var c,d=u.Left,p=u.Right,f=new n.IntPoint0;return r.Pt.X>=d&&r.Pt.X<=p?(f.X=r.Pt.X,f.Y=r.Pt.Y,n.use_xyz&&(f.Z=r.Pt.Z),c=r.Pt.X>a.Pt.X):s.Pt.X>=d&&s.Pt.X<=p?(f.X=s.Pt.X,f.Y=s.Pt.Y,n.use_xyz&&(f.Z=s.Pt.Z),c=s.Pt.X>o.Pt.X):a.Pt.X>=d&&a.Pt.X<=p?(f.X=a.Pt.X,f.Y=a.Pt.Y,n.use_xyz&&(f.Z=a.Pt.Z),c=a.Pt.X>r.Pt.X):(f.X=o.Pt.X,f.Y=o.Pt.Y,n.use_xyz&&(f.Z=o.Pt.Z),c=o.Pt.X>s.Pt.X),e.OutPt1=r,e.OutPt2=s,this.JoinHorz(r,a,s,o,f,c)}for(a=r.Next;n.IntPoint.op_Equality(a.Pt,r.Pt)&&a!==r;)a=a.Next;var m=a.Pt.Y>r.Pt.Y||!n.ClipperBase.SlopesEqual4(r.Pt,a.Pt,e.OffPt,this.m_UseFullRange);if(m){for(a=r.Prev;n.IntPoint.op_Equality(a.Pt,r.Pt)&&a!==r;)a=a.Prev;if(a.Pt.Y>r.Pt.Y||!n.ClipperBase.SlopesEqual4(r.Pt,a.Pt,e.OffPt,this.m_UseFullRange))return!1}for(o=s.Next;n.IntPoint.op_Equality(o.Pt,s.Pt)&&o!==s;)o=o.Next;var g=o.Pt.Y>s.Pt.Y||!n.ClipperBase.SlopesEqual4(s.Pt,o.Pt,e.OffPt,this.m_UseFullRange);if(g){for(o=s.Prev;n.IntPoint.op_Equality(o.Pt,s.Pt)&&o!==s;)o=o.Prev;if(o.Pt.Y>s.Pt.Y||!n.ClipperBase.SlopesEqual4(s.Pt,o.Pt,e.OffPt,this.m_UseFullRange))return!1}return a!==r&&o!==s&&a!==o&&(t!==i||m!==g)&&(m?(a=this.DupOutPt(r,!1),o=this.DupOutPt(s,!0),r.Prev=s,s.Next=r,a.Next=o,o.Prev=a,e.OutPt1=r,e.OutPt2=a,!0):(a=this.DupOutPt(r,!0),o=this.DupOutPt(s,!1),r.Next=s,s.Prev=r,a.Prev=o,o.Next=a,e.OutPt1=r,e.OutPt2=a,!0))},n.Clipper.GetBounds=function(e){for(var t=0,i=e.length;t<i&&0===e[t].length;)t++;if(t===i)return new n.IntRect(0,0,0,0);var r=new n.IntRect;for(r.left=e[t][0].X,r.right=r.left,r.top=e[t][0].Y,r.bottom=r.top;t<i;t++)for(var a=0,s=e[t].length;a<s;a++)e[t][a].X<r.left?r.left=e[t][a].X:e[t][a].X>r.right&&(r.right=e[t][a].X),e[t][a].Y<r.top?r.top=e[t][a].Y:e[t][a].Y>r.bottom&&(r.bottom=e[t][a].Y);return r},n.Clipper.prototype.GetBounds2=function(e){var t=e,i=new n.IntRect;for(i.left=e.Pt.X,i.right=e.Pt.X,i.top=e.Pt.Y,i.bottom=e.Pt.Y,e=e.Next;e!==t;)e.Pt.X<i.left&&(i.left=e.Pt.X),e.Pt.X>i.right&&(i.right=e.Pt.X),e.Pt.Y<i.top&&(i.top=e.Pt.Y),e.Pt.Y>i.bottom&&(i.bottom=e.Pt.Y),e=e.Next;return i},n.Clipper.PointInPolygon=function(e,t){var n=0,i=t.length;if(i<3)return 0;for(var r=t[0],a=1;a<=i;++a){var s=a===i?t[0]:t[a];if(s.Y===e.Y&&(s.X===e.X||r.Y===e.Y&&s.X>e.X==r.X<e.X))return-1;if(r.Y<e.Y!=s.Y<e.Y)if(r.X>=e.X)if(s.X>e.X)n=1-n;else{if(0===(o=(r.X-e.X)*(s.Y-e.Y)-(s.X-e.X)*(r.Y-e.Y)))return-1;o>0==s.Y>r.Y&&(n=1-n)}else if(s.X>e.X){var o;if(0===(o=(r.X-e.X)*(s.Y-e.Y)-(s.X-e.X)*(r.Y-e.Y)))return-1;o>0==s.Y>r.Y&&(n=1-n)}r=s}return n},n.Clipper.prototype.PointInPolygon=function(e,t){var n=0,i=t,r=e.X,a=e.Y,s=t.Pt.X,o=t.Pt.Y;do{var l=(t=t.Next).Pt.X,h=t.Pt.Y;if(h===a&&(l===r||o===a&&l>r==s<r))return-1;if(o<a!=h<a)if(s>=r)if(l>r)n=1-n;else{if(0===(u=(s-r)*(h-a)-(l-r)*(o-a)))return-1;u>0==h>o&&(n=1-n)}else if(l>r){var u;if(0===(u=(s-r)*(h-a)-(l-r)*(o-a)))return-1;u>0==h>o&&(n=1-n)}s=l,o=h}while(i!==t);return n},n.Clipper.prototype.Poly2ContainsPoly1=function(e,t){var n=e;do{var i=this.PointInPolygon(n.Pt,t);if(i>=0)return i>0;n=n.Next}while(n!==e);return!0},n.Clipper.prototype.FixupFirstLefts1=function(e,t){for(var i,r,a=0,s=this.m_PolyOuts.length;a<s;a++)i=this.m_PolyOuts[a],r=n.Clipper.ParseFirstLeft(i.FirstLeft),null!==i.Pts&&r===e&&this.Poly2ContainsPoly1(i.Pts,t.Pts)&&(i.FirstLeft=t)},n.Clipper.prototype.FixupFirstLefts2=function(e,t){for(var i,r,a=t.FirstLeft,s=0,o=this.m_PolyOuts.length;s<o;s++)null!==(i=this.m_PolyOuts[s]).Pts&&i!==t&&i!==e&&((r=n.Clipper.ParseFirstLeft(i.FirstLeft))===a||r===e||r===t)&&(this.Poly2ContainsPoly1(i.Pts,e.Pts)?i.FirstLeft=e:this.Poly2ContainsPoly1(i.Pts,t.Pts)?i.FirstLeft=t:(i.FirstLeft===e||i.FirstLeft===t)&&(i.FirstLeft=a))},n.Clipper.prototype.FixupFirstLefts3=function(e,t){for(var i,r,a=0,s=this.m_PolyOuts.length;a<s;a++)i=this.m_PolyOuts[a],r=n.Clipper.ParseFirstLeft(i.FirstLeft),null!==i.Pts&&r===e&&(i.FirstLeft=t)},n.Clipper.ParseFirstLeft=function(e){for(;null!==e&&null===e.Pts;)e=e.FirstLeft;return e},n.Clipper.prototype.JoinCommonEdges=function(){for(var e=0,t=this.m_Joins.length;e<t;e++){var n,i=this.m_Joins[e],r=this.GetOutRec(i.OutPt1.Idx),a=this.GetOutRec(i.OutPt2.Idx);null===r.Pts||null===a.Pts||r.IsOpen||a.IsOpen||(n=r===a?r:this.OutRec1RightOfOutRec2(r,a)?a:this.OutRec1RightOfOutRec2(a,r)?r:this.GetLowermostRec(r,a),this.JoinPoints(i,r,a)&&(r===a?(r.Pts=i.OutPt1,r.BottomPt=null,(a=this.CreateOutRec()).Pts=i.OutPt2,this.UpdateOutPtIdxs(a),this.Poly2ContainsPoly1(a.Pts,r.Pts)?(a.IsHole=!r.IsHole,a.FirstLeft=r,this.m_UsingPolyTree&&this.FixupFirstLefts2(a,r),(a.IsHole^this.ReverseSolution)==this.Area$1(a)>0&&this.ReversePolyPtLinks(a.Pts)):this.Poly2ContainsPoly1(r.Pts,a.Pts)?(a.IsHole=r.IsHole,r.IsHole=!a.IsHole,a.FirstLeft=r.FirstLeft,r.FirstLeft=a,this.m_UsingPolyTree&&this.FixupFirstLefts2(r,a),(r.IsHole^this.ReverseSolution)==this.Area$1(r)>0&&this.ReversePolyPtLinks(r.Pts)):(a.IsHole=r.IsHole,a.FirstLeft=r.FirstLeft,this.m_UsingPolyTree&&this.FixupFirstLefts1(r,a))):(a.Pts=null,a.BottomPt=null,a.Idx=r.Idx,r.IsHole=n.IsHole,n===a&&(r.FirstLeft=a.FirstLeft),a.FirstLeft=r,this.m_UsingPolyTree&&this.FixupFirstLefts3(a,r))))}},n.Clipper.prototype.UpdateOutPtIdxs=function(e){var t=e.Pts;do{t.Idx=e.Idx,t=t.Prev}while(t!==e.Pts)},n.Clipper.prototype.DoSimplePolygons=function(){for(var e=0;e<this.m_PolyOuts.length;){var t=this.m_PolyOuts[e++],i=t.Pts;if(null!==i&&!t.IsOpen)do{for(var r=i.Next;r!==t.Pts;){if(n.IntPoint.op_Equality(i.Pt,r.Pt)&&r.Next!==i&&r.Prev!==i){var a=i.Prev,s=r.Prev;i.Prev=s,s.Next=i,r.Prev=a,a.Next=r,t.Pts=i;var o=this.CreateOutRec();o.Pts=r,this.UpdateOutPtIdxs(o),this.Poly2ContainsPoly1(o.Pts,t.Pts)?(o.IsHole=!t.IsHole,o.FirstLeft=t,this.m_UsingPolyTree&&this.FixupFirstLefts2(o,t)):this.Poly2ContainsPoly1(t.Pts,o.Pts)?(o.IsHole=t.IsHole,t.IsHole=!o.IsHole,o.FirstLeft=t.FirstLeft,t.FirstLeft=o,this.m_UsingPolyTree&&this.FixupFirstLefts2(t,o)):(o.IsHole=t.IsHole,o.FirstLeft=t.FirstLeft,this.m_UsingPolyTree&&this.FixupFirstLefts1(t,o)),r=i}r=r.Next}i=i.Next}while(i!==t.Pts)}},n.Clipper.Area=function(e){if(!Array.isArray(e))return 0;var t=e.length;if(t<3)return 0;for(var n=0,i=0,r=t-1;i<t;++i)n+=(e[r].X+e[i].X)*(e[r].Y-e[i].Y),r=i;return.5*-n},n.Clipper.prototype.Area=function(e){var t=e;if(null===e)return 0;var n=0;do{n+=(e.Prev.Pt.X+e.Pt.X)*(e.Prev.Pt.Y-e.Pt.Y),e=e.Next}while(e!==t);return.5*n},n.Clipper.prototype.Area$1=function(e){return this.Area(e.Pts)},n.Clipper.SimplifyPolygon=function(e,t){var i=new Array,r=new n.Clipper(0);return r.StrictlySimple=!0,r.AddPath(e,n.PolyType.ptSubject,!0),r.Execute(n.ClipType.ctUnion,i,t,t),i},n.Clipper.SimplifyPolygons=function(e,t){void 0===t&&(t=n.PolyFillType.pftEvenOdd);var i=new Array,r=new n.Clipper(0);return r.StrictlySimple=!0,r.AddPaths(e,n.PolyType.ptSubject,!0),r.Execute(n.ClipType.ctUnion,i,t,t),i},n.Clipper.DistanceSqrd=function(e,t){var n=e.X-t.X,i=e.Y-t.Y;return n*n+i*i},n.Clipper.DistanceFromLineSqrd=function(e,t,n){var i=t.Y-n.Y,r=n.X-t.X,a=i*t.X+r*t.Y;return(a=i*e.X+r*e.Y-a)*a/(i*i+r*r)},n.Clipper.SlopesNearCollinear=function(e,t,i,r){return Math.abs(e.X-t.X)>Math.abs(e.Y-t.Y)?e.X>t.X==e.X<i.X?n.Clipper.DistanceFromLineSqrd(e,t,i)<r:t.X>e.X==t.X<i.X?n.Clipper.DistanceFromLineSqrd(t,e,i)<r:n.Clipper.DistanceFromLineSqrd(i,e,t)<r:e.Y>t.Y==e.Y<i.Y?n.Clipper.DistanceFromLineSqrd(e,t,i)<r:t.Y>e.Y==t.Y<i.Y?n.Clipper.DistanceFromLineSqrd(t,e,i)<r:n.Clipper.DistanceFromLineSqrd(i,e,t)<r},n.Clipper.PointsAreClose=function(e,t,n){var i=e.X-t.X,r=e.Y-t.Y;return i*i+r*r<=n},n.Clipper.ExcludeOp=function(e){var t=e.Prev;return t.Next=e.Next,e.Next.Prev=t,t.Idx=0,t},n.Clipper.CleanPolygon=function(e,t){void 0===t&&(t=1.415);var i=e.length;if(0===i)return new Array;for(var r=new Array(i),a=0;a<i;++a)r[a]=new n.OutPt;for(a=0;a<i;++a)r[a].Pt=e[a],r[a].Next=r[(a+1)%i],r[a].Next.Prev=r[a],r[a].Idx=0;for(var s=t*t,o=r[0];0===o.Idx&&o.Next!==o.Prev;)n.Clipper.PointsAreClose(o.Pt,o.Prev.Pt,s)?(o=n.Clipper.ExcludeOp(o),i--):n.Clipper.PointsAreClose(o.Prev.Pt,o.Next.Pt,s)?(n.Clipper.ExcludeOp(o.Next),o=n.Clipper.ExcludeOp(o),i-=2):n.Clipper.SlopesNearCollinear(o.Prev.Pt,o.Pt,o.Next.Pt,s)?(o=n.Clipper.ExcludeOp(o),i--):(o.Idx=1,o=o.Next);i<3&&(i=0);var l=new Array(i);for(a=0;a<i;++a)l[a]=new n.IntPoint1(o.Pt),o=o.Next;return r=null,l},n.Clipper.CleanPolygons=function(e,t){for(var i=new Array(e.length),r=0,a=e.length;r<a;r++)i[r]=n.Clipper.CleanPolygon(e[r],t);return i},n.Clipper.Minkowski=function(e,t,i,r){var a=r?1:0,s=e.length,o=t.length,l=new Array;if(i)for(var h=0;h<o;h++){for(var u=new Array(s),c=0,d=e.length,p=e[c];c<d;p=e[++c])u[c]=new n.IntPoint2(t[h].X+p.X,t[h].Y+p.Y);l.push(u)}else for(h=0;h<o;h++){for(u=new Array(s),c=0,d=e.length,p=e[c];c<d;p=e[++c])u[c]=new n.IntPoint2(t[h].X-p.X,t[h].Y-p.Y);l.push(u)}var f=new Array;for(h=0;h<o-1+a;h++)for(c=0;c<s;c++){var m=new Array;m.push(l[h%o][c%s]),m.push(l[(h+1)%o][c%s]),m.push(l[(h+1)%o][(c+1)%s]),m.push(l[h%o][(c+1)%s]),n.Clipper.Orientation(m)||m.reverse(),f.push(m)}return f},n.Clipper.MinkowskiSum=function(e,t,i){if(t[0]instanceof Array){for(var r=t,a=new n.Paths,s=new n.Clipper,o=0;o<r.length;++o){var l=n.Clipper.Minkowski(e,r[o],!0,i);if(s.AddPaths(l,n.PolyType.ptSubject,!0),i){var h=n.Clipper.TranslatePath(r[o],e[0]);s.AddPath(h,n.PolyType.ptClip,!0)}}return s.Execute(n.ClipType.ctUnion,a,n.PolyFillType.pftNonZero,n.PolyFillType.pftNonZero),a}return h=t,r=n.Clipper.Minkowski(e,h,!0,i),(s=new n.Clipper).AddPaths(r,n.PolyType.ptSubject,!0),s.Execute(n.ClipType.ctUnion,r,n.PolyFillType.pftNonZero,n.PolyFillType.pftNonZero),r},n.Clipper.TranslatePath=function(e,t){for(var i=new n.Path,r=0;r<e.length;r++)i.push(new n.IntPoint2(e[r].X+t.X,e[r].Y+t.Y));return i},n.Clipper.MinkowskiDiff=function(e,t){var i=n.Clipper.Minkowski(e,t,!1,!0),r=new n.Clipper;return r.AddPaths(i,n.PolyType.ptSubject,!0),r.Execute(n.ClipType.ctUnion,i,n.PolyFillType.pftNonZero,n.PolyFillType.pftNonZero),i},n.Clipper.PolyTreeToPaths=function(e){var t=new Array;return n.Clipper.AddPolyNodeToPaths(e,n.Clipper.NodeType.ntAny,t),t},n.Clipper.AddPolyNodeToPaths=function(e,t,i){var r=!0;switch(t){case n.Clipper.NodeType.ntOpen:return;case n.Clipper.NodeType.ntClosed:r=!e.IsOpen}e.m_polygon.length>0&&r&&i.push(e.m_polygon);for(var a=0,s=e.Childs(),o=s.length,l=s[a];a<o;l=s[++a])n.Clipper.AddPolyNodeToPaths(l,t,i)},n.Clipper.OpenPathsFromPolyTree=function(e){for(var t=new n.Paths,i=0,r=e.ChildCount();i<r;i++)e.Childs()[i].IsOpen&&t.push(e.Childs()[i].m_polygon);return t},n.Clipper.ClosedPathsFromPolyTree=function(e){var t=new n.Paths;return n.Clipper.AddPolyNodeToPaths(e,n.Clipper.NodeType.ntClosed,t),t},R(n.Clipper,n.ClipperBase),n.Clipper.NodeType={ntAny:0,ntOpen:1,ntClosed:2},n.ClipperOffset=function(e,t){void 0===e&&(e=2),void 0===t&&(t=n.ClipperOffset.def_arc_tolerance),this.m_destPolys=new n.Paths,this.m_srcPoly=new n.Path,this.m_destPoly=new n.Path,this.m_normals=new Array,this.m_delta=0,this.m_sinA=0,this.m_sin=0,this.m_cos=0,this.m_miterLim=0,this.m_StepsPerRad=0,this.m_lowest=new n.IntPoint0,this.m_polyNodes=new n.PolyNode,this.MiterLimit=e,this.ArcTolerance=t,this.m_lowest.X=-1},n.ClipperOffset.two_pi=6.28318530717959,n.ClipperOffset.def_arc_tolerance=.25,n.ClipperOffset.prototype.Clear=function(){n.Clear(this.m_polyNodes.Childs()),this.m_lowest.X=-1},n.ClipperOffset.Round=n.Clipper.Round,n.ClipperOffset.prototype.AddPath=function(e,t,i){var r=e.length-1;if(!(r<0)){var a=new n.PolyNode;if(a.m_jointype=t,a.m_endtype=i,i===n.EndType.etClosedLine||i===n.EndType.etClosedPolygon)for(;r>0&&n.IntPoint.op_Equality(e[0],e[r]);)r--;a.m_polygon.push(e[0]);for(var s=0,o=0,l=1;l<=r;l++)n.IntPoint.op_Inequality(a.m_polygon[s],e[l])&&(s++,a.m_polygon.push(e[l]),(e[l].Y>a.m_polygon[o].Y||e[l].Y===a.m_polygon[o].Y&&e[l].X<a.m_polygon[o].X)&&(o=s));if(!(i===n.EndType.etClosedPolygon&&s<2)&&(this.m_polyNodes.AddChild(a),i===n.EndType.etClosedPolygon))if(this.m_lowest.X<0)this.m_lowest=new n.IntPoint2(this.m_polyNodes.ChildCount()-1,o);else{var h=this.m_polyNodes.Childs()[this.m_lowest.X].m_polygon[this.m_lowest.Y];(a.m_polygon[o].Y>h.Y||a.m_polygon[o].Y===h.Y&&a.m_polygon[o].X<h.X)&&(this.m_lowest=new n.IntPoint2(this.m_polyNodes.ChildCount()-1,o))}}},n.ClipperOffset.prototype.AddPaths=function(e,t,n){for(var i=0,r=e.length;i<r;i++)this.AddPath(e[i],t,n)},n.ClipperOffset.prototype.FixOrientations=function(){if(this.m_lowest.X>=0&&!n.Clipper.Orientation(this.m_polyNodes.Childs()[this.m_lowest.X].m_polygon))for(var e=0;e<this.m_polyNodes.ChildCount();e++)((t=this.m_polyNodes.Childs()[e]).m_endtype===n.EndType.etClosedPolygon||t.m_endtype===n.EndType.etClosedLine&&n.Clipper.Orientation(t.m_polygon))&&t.m_polygon.reverse();else for(e=0;e<this.m_polyNodes.ChildCount();e++){var t;(t=this.m_polyNodes.Childs()[e]).m_endtype===n.EndType.etClosedLine&&!n.Clipper.Orientation(t.m_polygon)&&t.m_polygon.reverse()}},n.ClipperOffset.GetUnitNormal=function(e,t){var i=t.X-e.X,r=t.Y-e.Y;if(0===i&&0===r)return new n.DoublePoint2(0,0);var a=1/Math.sqrt(i*i+r*r);return i*=a,r*=a,new n.DoublePoint2(r,-i)},n.ClipperOffset.prototype.DoOffset=function(e){if(this.m_destPolys=new Array,this.m_delta=e,n.ClipperBase.near_zero(e))for(var t=0;t<this.m_polyNodes.ChildCount();t++)(a=this.m_polyNodes.Childs()[t]).m_endtype===n.EndType.etClosedPolygon&&this.m_destPolys.push(a.m_polygon);else{var i;this.MiterLimit>2?this.m_miterLim=2/(this.MiterLimit*this.MiterLimit):this.m_miterLim=.5,i=this.ArcTolerance<=0?n.ClipperOffset.def_arc_tolerance:this.ArcTolerance>Math.abs(e)*n.ClipperOffset.def_arc_tolerance?Math.abs(e)*n.ClipperOffset.def_arc_tolerance:this.ArcTolerance;var r=3.14159265358979/Math.acos(1-i/Math.abs(e));for(this.m_sin=Math.sin(n.ClipperOffset.two_pi/r),this.m_cos=Math.cos(n.ClipperOffset.two_pi/r),this.m_StepsPerRad=r/n.ClipperOffset.two_pi,e<0&&(this.m_sin=-this.m_sin),t=0;t<this.m_polyNodes.ChildCount();t++){var a=this.m_polyNodes.Childs()[t];this.m_srcPoly=a.m_polygon;var s=this.m_srcPoly.length;if(!(0===s||e<=0&&(s<3||a.m_endtype!==n.EndType.etClosedPolygon))){if(this.m_destPoly=new Array,1===s){if(a.m_jointype===n.JoinType.jtRound)for(var o=1,l=0,h=1;h<=r;h++){this.m_destPoly.push(new n.IntPoint2(n.ClipperOffset.Round(this.m_srcPoly[0].X+o*e),n.ClipperOffset.Round(this.m_srcPoly[0].Y+l*e)));var u=o;o=o*this.m_cos-this.m_sin*l,l=u*this.m_sin+l*this.m_cos}else for(o=-1,l=-1,h=0;h<4;++h)this.m_destPoly.push(new n.IntPoint2(n.ClipperOffset.Round(this.m_srcPoly[0].X+o*e),n.ClipperOffset.Round(this.m_srcPoly[0].Y+l*e))),o<0?o=1:l<0?l=1:o=-1;this.m_destPolys.push(this.m_destPoly);continue}for(this.m_normals.length=0,h=0;h<s-1;h++)this.m_normals.push(n.ClipperOffset.GetUnitNormal(this.m_srcPoly[h],this.m_srcPoly[h+1]));if(a.m_endtype===n.EndType.etClosedLine||a.m_endtype===n.EndType.etClosedPolygon?this.m_normals.push(n.ClipperOffset.GetUnitNormal(this.m_srcPoly[s-1],this.m_srcPoly[0])):this.m_normals.push(new n.DoublePoint1(this.m_normals[s-2])),a.m_endtype===n.EndType.etClosedPolygon){var c=s-1;for(h=0;h<s;h++)c=this.OffsetPoint(h,c,a.m_jointype);this.m_destPolys.push(this.m_destPoly)}else if(a.m_endtype===n.EndType.etClosedLine){for(c=s-1,h=0;h<s;h++)c=this.OffsetPoint(h,c,a.m_jointype);this.m_destPolys.push(this.m_destPoly),this.m_destPoly=new Array;var d=this.m_normals[s-1];for(h=s-1;h>0;h--)this.m_normals[h]=new n.DoublePoint2(-this.m_normals[h-1].X,-this.m_normals[h-1].Y);for(this.m_normals[0]=new n.DoublePoint2(-d.X,-d.Y),c=0,h=s-1;h>=0;h--)c=this.OffsetPoint(h,c,a.m_jointype);this.m_destPolys.push(this.m_destPoly)}else{for(c=0,h=1;h<s-1;++h)c=this.OffsetPoint(h,c,a.m_jointype);var p;for(a.m_endtype===n.EndType.etOpenButt?(h=s-1,p=new n.IntPoint2(n.ClipperOffset.Round(this.m_srcPoly[h].X+this.m_normals[h].X*e),n.ClipperOffset.Round(this.m_srcPoly[h].Y+this.m_normals[h].Y*e)),this.m_destPoly.push(p),p=new n.IntPoint2(n.ClipperOffset.Round(this.m_srcPoly[h].X-this.m_normals[h].X*e),n.ClipperOffset.Round(this.m_srcPoly[h].Y-this.m_normals[h].Y*e)),this.m_destPoly.push(p)):(h=s-1,c=s-2,this.m_sinA=0,this.m_normals[h]=new n.DoublePoint2(-this.m_normals[h].X,-this.m_normals[h].Y),a.m_endtype===n.EndType.etOpenSquare?this.DoSquare(h,c):this.DoRound(h,c)),h=s-1;h>0;h--)this.m_normals[h]=new n.DoublePoint2(-this.m_normals[h-1].X,-this.m_normals[h-1].Y);for(this.m_normals[0]=new n.DoublePoint2(-this.m_normals[1].X,-this.m_normals[1].Y),h=(c=s-1)-1;h>0;--h)c=this.OffsetPoint(h,c,a.m_jointype);a.m_endtype===n.EndType.etOpenButt?(p=new n.IntPoint2(n.ClipperOffset.Round(this.m_srcPoly[0].X-this.m_normals[0].X*e),n.ClipperOffset.Round(this.m_srcPoly[0].Y-this.m_normals[0].Y*e)),this.m_destPoly.push(p),p=new n.IntPoint2(n.ClipperOffset.Round(this.m_srcPoly[0].X+this.m_normals[0].X*e),n.ClipperOffset.Round(this.m_srcPoly[0].Y+this.m_normals[0].Y*e)),this.m_destPoly.push(p)):(c=1,this.m_sinA=0,a.m_endtype===n.EndType.etOpenSquare?this.DoSquare(0,1):this.DoRound(0,1)),this.m_destPolys.push(this.m_destPoly)}}}}},n.ClipperOffset.prototype.Execute=function(){var e=arguments;if(e[0]instanceof n.PolyTree){var t=e[1];if((l=e[0]).Clear(),this.FixOrientations(),this.DoOffset(t),(s=new n.Clipper(0)).AddPaths(this.m_destPolys,n.PolyType.ptSubject,!0),t>0)s.Execute(n.ClipType.ctUnion,l,n.PolyFillType.pftPositive,n.PolyFillType.pftPositive);else{var i=n.Clipper.GetBounds(this.m_destPolys);if((o=new n.Path).push(new n.IntPoint2(i.left-10,i.bottom+10)),o.push(new n.IntPoint2(i.right+10,i.bottom+10)),o.push(new n.IntPoint2(i.right+10,i.top-10)),o.push(new n.IntPoint2(i.left-10,i.top-10)),s.AddPath(o,n.PolyType.ptSubject,!0),s.ReverseSolution=!0,s.Execute(n.ClipType.ctUnion,l,n.PolyFillType.pftNegative,n.PolyFillType.pftNegative),1===l.ChildCount()&&l.Childs()[0].ChildCount()>0){var r=l.Childs()[0];l.Childs()[0]=r.Childs()[0],l.Childs()[0].m_Parent=l;for(var a=1;a<r.ChildCount();a++)l.AddChild(r.Childs()[a])}else l.Clear()}}else{var s,o,l=e[0];if(t=e[1],n.Clear(l),this.FixOrientations(),this.DoOffset(t),(s=new n.Clipper(0)).AddPaths(this.m_destPolys,n.PolyType.ptSubject,!0),t>0)s.Execute(n.ClipType.ctUnion,l,n.PolyFillType.pftPositive,n.PolyFillType.pftPositive);else i=n.Clipper.GetBounds(this.m_destPolys),(o=new n.Path).push(new n.IntPoint2(i.left-10,i.bottom+10)),o.push(new n.IntPoint2(i.right+10,i.bottom+10)),o.push(new n.IntPoint2(i.right+10,i.top-10)),o.push(new n.IntPoint2(i.left-10,i.top-10)),s.AddPath(o,n.PolyType.ptSubject,!0),s.ReverseSolution=!0,s.Execute(n.ClipType.ctUnion,l,n.PolyFillType.pftNegative,n.PolyFillType.pftNegative),l.length>0&&l.splice(0,1)}},n.ClipperOffset.prototype.OffsetPoint=function(e,t,i){if(this.m_sinA=this.m_normals[t].X*this.m_normals[e].Y-this.m_normals[e].X*this.m_normals[t].Y,Math.abs(this.m_sinA*this.m_delta)<1){if(this.m_normals[t].X*this.m_normals[e].X+this.m_normals[e].Y*this.m_normals[t].Y>0)return this.m_destPoly.push(new n.IntPoint2(n.ClipperOffset.Round(this.m_srcPoly[e].X+this.m_normals[t].X*this.m_delta),n.ClipperOffset.Round(this.m_srcPoly[e].Y+this.m_normals[t].Y*this.m_delta))),t}else this.m_sinA>1?this.m_sinA=1:this.m_sinA<-1&&(this.m_sinA=-1);if(this.m_sinA*this.m_delta<0)this.m_destPoly.push(new n.IntPoint2(n.ClipperOffset.Round(this.m_srcPoly[e].X+this.m_normals[t].X*this.m_delta),n.ClipperOffset.Round(this.m_srcPoly[e].Y+this.m_normals[t].Y*this.m_delta))),this.m_destPoly.push(new n.IntPoint1(this.m_srcPoly[e])),this.m_destPoly.push(new n.IntPoint2(n.ClipperOffset.Round(this.m_srcPoly[e].X+this.m_normals[e].X*this.m_delta),n.ClipperOffset.Round(this.m_srcPoly[e].Y+this.m_normals[e].Y*this.m_delta)));else switch(i){case n.JoinType.jtMiter:var r=this.m_normals[e].X*this.m_normals[t].X+this.m_normals[e].Y*this.m_normals[t].Y+1;r>=this.m_miterLim?this.DoMiter(e,t,r):this.DoSquare(e,t);break;case n.JoinType.jtSquare:this.DoSquare(e,t);break;case n.JoinType.jtRound:this.DoRound(e,t)}return e},n.ClipperOffset.prototype.DoSquare=function(e,t){var i=Math.tan(Math.atan2(this.m_sinA,this.m_normals[t].X*this.m_normals[e].X+this.m_normals[t].Y*this.m_normals[e].Y)/4);this.m_destPoly.push(new n.IntPoint2(n.ClipperOffset.Round(this.m_srcPoly[e].X+this.m_delta*(this.m_normals[t].X-this.m_normals[t].Y*i)),n.ClipperOffset.Round(this.m_srcPoly[e].Y+this.m_delta*(this.m_normals[t].Y+this.m_normals[t].X*i)))),this.m_destPoly.push(new n.IntPoint2(n.ClipperOffset.Round(this.m_srcPoly[e].X+this.m_delta*(this.m_normals[e].X+this.m_normals[e].Y*i)),n.ClipperOffset.Round(this.m_srcPoly[e].Y+this.m_delta*(this.m_normals[e].Y-this.m_normals[e].X*i))))},n.ClipperOffset.prototype.DoMiter=function(e,t,i){var r=this.m_delta/i;this.m_destPoly.push(new n.IntPoint2(n.ClipperOffset.Round(this.m_srcPoly[e].X+(this.m_normals[t].X+this.m_normals[e].X)*r),n.ClipperOffset.Round(this.m_srcPoly[e].Y+(this.m_normals[t].Y+this.m_normals[e].Y)*r)))},n.ClipperOffset.prototype.DoRound=function(e,t){for(var i,r=Math.atan2(this.m_sinA,this.m_normals[t].X*this.m_normals[e].X+this.m_normals[t].Y*this.m_normals[e].Y),a=Math.max(n.Cast_Int32(n.ClipperOffset.Round(this.m_StepsPerRad*Math.abs(r))),1),s=this.m_normals[t].X,o=this.m_normals[t].Y,l=0;l<a;++l)this.m_destPoly.push(new n.IntPoint2(n.ClipperOffset.Round(this.m_srcPoly[e].X+s*this.m_delta),n.ClipperOffset.Round(this.m_srcPoly[e].Y+o*this.m_delta))),i=s,s=s*this.m_cos-this.m_sin*o,o=i*this.m_sin+o*this.m_cos;this.m_destPoly.push(new n.IntPoint2(n.ClipperOffset.Round(this.m_srcPoly[e].X+this.m_normals[e].X*this.m_delta),n.ClipperOffset.Round(this.m_srcPoly[e].Y+this.m_normals[e].Y*this.m_delta)))},n.Error=function(e){try{throw new Error(e)}catch(e){alert(e.message)}},n.JS={},n.JS.AreaOfPolygon=function(e,t){return t||(t=1),n.Clipper.Area(e)/(t*t)},n.JS.AreaOfPolygons=function(e,t){t||(t=1);for(var i=0,r=0;r<e.length;r++)i+=n.Clipper.Area(e[r]);return i/(t*t)},n.JS.BoundsOfPath=function(e,t){return n.JS.BoundsOfPaths([e],t)},n.JS.BoundsOfPaths=function(e,t){t||(t=1);var i=n.Clipper.GetBounds(e);return i.left/=t,i.bottom/=t,i.right/=t,i.top/=t,i},n.JS.Clean=function(e,t){if(!(e instanceof Array))return[];var i=e[0]instanceof Array;if(e=n.JS.Clone(e),"number"!=typeof t||null===t)return n.Error("Delta is not a number in Clean()."),e;if(0===e.length||1===e.length&&0===e[0].length||t<0)return e;i||(e=[e]);for(var r,a,s,o,l,h,u,c=e.length,d=[],p=0;p<c;p++)if(0!==(r=(a=e[p]).length)){if(r<3){s=a,d.push(s);continue}for(s=a,o=t*t,l=a[0],h=1,u=1;u<r;u++)(a[u].X-l.X)*(a[u].X-l.X)+(a[u].Y-l.Y)*(a[u].Y-l.Y)<=o||(s[h]=a[u],l=a[u],h++);l=a[h-1],(a[0].X-l.X)*(a[0].X-l.X)+(a[0].Y-l.Y)*(a[0].Y-l.Y)<=o&&h--,h<r&&s.splice(h,r-h),s.length&&d.push(s)}return!i&&d.length?d=d[0]:i||0!==d.length?i&&0===d.length&&(d=[[]]):d=[],d},n.JS.Clone=function(e){if(!(e instanceof Array))return[];if(0===e.length)return[];if(1===e.length&&0===e[0].length)return[[]];var t=e[0]instanceof Array;t||(e=[e]);var n,i,r,a,s=e.length,o=new Array(s);for(i=0;i<s;i++){for(n=e[i].length,a=new Array(n),r=0;r<n;r++)a[r]={X:e[i][r].X,Y:e[i][r].Y};o[i]=a}return t||(o=o[0]),o},n.JS.Lighten=function(e,t){if(!(e instanceof Array))return[];if("number"!=typeof t||null===t)return n.Error("Tolerance is not a number in Lighten()."),n.JS.Clone(e);if(0===e.length||1===e.length&&0===e[0].length||t<0)return n.JS.Clone(e);var i=e[0]instanceof Array;i||(e=[e]);var r,a,s,o,l,h,u,c,d,p,f,m,g,v,y,x,b=e.length,_=t*t,w=[];for(r=0;r<b;r++)if(0!==(h=(s=e[r]).length)){for(o=0;o<1e6;o++){for(l=[],s[(h=s.length)-1].X!==s[0].X||s[h-1].Y!==s[0].Y?(f=1,s.push({X:s[0].X,Y:s[0].Y}),h=s.length):f=0,p=[],a=0;a<h-2;a++)u=s[a],d=s[a+1],c=s[a+2],y=u.X,x=u.Y,m=c.X-y,g=c.Y-x,(0!==m||0!==g)&&((v=((d.X-y)*m+(d.Y-x)*g)/(m*m+g*g))>1?(y=c.X,x=c.Y):v>0&&(y+=m*v,x+=g*v)),(m=d.X-y)*m+(g=d.Y-x)*g<=_&&(p[a+1]=1,a++);for(l.push({X:s[0].X,Y:s[0].Y}),a=1;a<h-1;a++)p[a]||l.push({X:s[a].X,Y:s[a].Y});if(l.push({X:s[h-1].X,Y:s[h-1].Y}),f&&s.pop(),!p.length)break;s=l}l[(h=l.length)-1].X===l[0].X&&l[h-1].Y===l[0].Y&&l.pop(),l.length>2&&w.push(l)}return i||(w=w[0]),void 0===w&&(w=[]),w},n.JS.PerimeterOfPath=function(e,t,n){if(void 0===e)return 0;var i,r,a=Math.sqrt,s=0,o=0,l=0,h=0,u=0,c=e.length;if(c<2)return 0;for(t&&(e[c]=e[0],c++);--c;)o=(i=e[c]).X,l=i.Y,s+=a((o-(h=(r=e[c-1]).X))*(o-h)+(l-(u=r.Y))*(l-u));return t&&e.pop(),s/n},n.JS.PerimeterOfPaths=function(e,t,i){i||(i=1);for(var r=0,a=0;a<e.length;a++)r+=n.JS.PerimeterOfPath(e[a],t,i);return r},n.JS.ScaleDownPath=function(e,t){var n,i;for(t||(t=1),n=e.length;n--;)(i=e[n]).X=i.X/t,i.Y=i.Y/t},n.JS.ScaleDownPaths=function(e,t){var n,i,r;for(t||(t=1),n=e.length;n--;)for(i=e[n].length;i--;)(r=e[n][i]).X=r.X/t,r.Y=r.Y/t},n.JS.ScaleUpPath=function(e,t){var n,i,r=Math.round;for(t||(t=1),n=e.length;n--;)(i=e[n]).X=r(i.X*t),i.Y=r(i.Y*t)},n.JS.ScaleUpPaths=function(e,t){var n,i,r,a=Math.round;for(t||(t=1),n=e.length;n--;)for(i=e[n].length;i--;)(r=e[n][i]).X=a(r.X*t),r.Y=a(r.Y*t)},n.ExPolygons=function(){return[]},n.ExPolygon=function(){this.outer=null,this.holes=null},n.JS.AddOuterPolyNodeToExPolygons=function(e,t){var i=new n.ExPolygon;i.outer=e.Contour();var r,a,s,o,l,h,u=e.Childs(),c=u.length;for(i.holes=new Array(c),s=0;s<c;s++)for(r=u[s],i.holes[s]=r.Contour(),o=0,h=(l=r.Childs()).length;o<h;o++)a=l[o],n.JS.AddOuterPolyNodeToExPolygons(a,t);t.push(i)},n.JS.ExPolygonsToPaths=function(e){var t,i,r,a,s=new n.Paths;for(t=0,r=e.length;t<r;t++)for(s.push(e[t].outer),i=0,a=e[t].holes.length;i<a;i++)s.push(e[t].holes[i]);return s},n.JS.PolyTreeToExPolygons=function(e){var t,i,r,a,s=new n.ExPolygons;for(i=0,a=(r=e.Childs()).length;i<a;i++)t=r[i],n.JS.AddOuterPolyNodeToExPolygons(t,s);return s}}()})),b1e=J((()=>{})),E1e=J((()=>{})),_1e=J((()=>{})),T1e=J((()=>{})),w1e=J((()=>{})),Q1e=J(((exports,module)=>{var t,e;t=globalThis,e=()=>(()=>{"use strict";var __webpack_modules__=[,(e,t)=>{var n;Object.defineProperty(t,"__esModule",{value:!0}),t.VerbosityLevel=t.Util=t.UnknownErrorException=t.UnexpectedResponseException=t.TextRenderingMode=t.RenderingIntentFlag=t.PromiseCapability=t.PermissionFlag=t.PasswordResponses=t.PasswordException=t.PageActionEventType=t.OPS=t.MissingPDFException=t.MAX_IMAGE_SIZE_TO_CACHE=t.LINE_FACTOR=t.LINE_DESCENT_FACTOR=t.InvalidPDFException=t.ImageKind=t.IDENTITY_MATRIX=t.FormatError=t.FeatureTest=t.FONT_IDENTITY_MATRIX=t.DocumentActionEventType=t.CMapCompressionType=t.BaseException=t.BASELINE_FACTOR=t.AnnotationType=t.AnnotationReplyType=t.AnnotationMode=t.AnnotationFlag=t.AnnotationFieldFlag=t.AnnotationEditorType=t.AnnotationEditorPrefix=t.AnnotationEditorParamsType=t.AnnotationBorderStyleType=t.AnnotationActionEventType=t.AbortException=void 0,t.assert=function(e,t){e||s(t)},t.bytesToString=function(e){("object"!=typeof e||void 0===(null==e?void 0:e.length))&&s("Invalid argument for bytesToString");let t=e.length,n=8192;if(t<n)return String.fromCharCode.apply(null,e);let i=[];for(let r=0;r<t;r+=n){let a=Math.min(r+n,t),s=e.subarray(r,a);i.push(String.fromCharCode.apply(null,s))}return i.join("")},t.createValidAbsoluteUrl=function(e,t=null,n=null){if(!e)return null;try{if(n&&"string"==typeof e){if(n.addDefaultProtocol&&e.startsWith("www.")){let t=e.match(/\./g);(null==t?void 0:t.length)>=2&&(e=`http://${e}`)}if(n.tryConvertEncoding)try{e=d(e)}catch(e){}}let i=t?new URL(e,t):new URL(e);if(function(e){switch(null==e?void 0:e.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}(i))return i}catch(e){}return null},t.getModificationDate=function(e=new Date){return[e.getUTCFullYear().toString(),(e.getUTCMonth()+1).toString().padStart(2,"0"),e.getUTCDate().toString().padStart(2,"0"),e.getUTCHours().toString().padStart(2,"0"),e.getUTCMinutes().toString().padStart(2,"0"),e.getUTCSeconds().toString().padStart(2,"0")].join("")},t.getVerbosityLevel=function(){return r},t.info=function(e){r>=i.INFOS&&console.log(`Info: ${e}`)},t.isArrayBuffer=function(e){return"object"==typeof e&&void 0!==(null==e?void 0:e.byteLength)},t.isArrayEqual=function(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},t.normalizeUnicode=function(e){return p||(p=/([\u00a0\u00b5\u037e\u0eb3\u2000-\u200a\u202f\u2126\ufb00-\ufb04\ufb06\ufb20-\ufb36\ufb38-\ufb3c\ufb3e\ufb40-\ufb41\ufb43-\ufb44\ufb46-\ufba1\ufba4-\ufba9\ufbae-\ufbb1\ufbd3-\ufbdc\ufbde-\ufbe7\ufbea-\ufbf8\ufbfc-\ufbfd\ufc00-\ufc5d\ufc64-\ufcf1\ufcf5-\ufd3d\ufd88\ufdf4\ufdfa-\ufdfb\ufe71\ufe77\ufe79\ufe7b\ufe7d]+)|(\ufb05+)/gu,f=new Map([["\ufb05","\u017ft"]])),e.replaceAll(p,((e,t,n)=>t?t.normalize("NFKC"):f.get(n)))},t.objectFromMap=function(e){let t=Object.create(null);for(let[n,i]of e)t[n]=i;return t},t.objectSize=function(e){return Object.keys(e).length},t.setVerbosityLevel=function(e){Number.isInteger(e)&&(r=e)},t.shadow=o,t.string32=function(e){return String.fromCharCode(e>>24&255,e>>16&255,e>>8&255,255&e)},t.stringToBytes=h,t.stringToPDFString=function(e){if(e[0]>="\xef"){let t;if("\xfe"===e[0]&&"\xff"===e[1]?t="utf-16be":"\xff"===e[0]&&"\xfe"===e[1]?t="utf-16le":"\xef"===e[0]&&"\xbb"===e[1]&&"\xbf"===e[2]&&(t="utf-8"),t)try{let n=new TextDecoder(t,{fatal:!0}),i=h(e);return n.decode(i)}catch(e){a(`stringToPDFString: "${e}".`)}}let t=[];for(let n=0,i=e.length;n<i;n++){let i=c[e.charCodeAt(n)];t.push(i?String.fromCharCode(i):e.charAt(n))}return t.join("")},t.stringToUTF8String=d,t.unreachable=s,t.utf8StringToString=function(e){return unescape(encodeURIComponent(e))},t.warn=a,t.IDENTITY_MATRIX=[1,0,0,1,0,0],t.FONT_IDENTITY_MATRIX=[.001,0,0,.001,0,0],t.MAX_IMAGE_SIZE_TO_CACHE=1e7,t.LINE_FACTOR=1.35,t.LINE_DESCENT_FACTOR=.35,t.BASELINE_FACTOR=.25925925925925924,t.RenderingIntentFlag={ANY:1,DISPLAY:2,PRINT:4,SAVE:8,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,OPLIST:256},t.AnnotationMode={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},t.AnnotationEditorPrefix="pdfjs_internal_editor_",t.AnnotationEditorType={DISABLE:-1,NONE:0,FREETEXT:3,STAMP:13,INK:15},t.AnnotationEditorParamsType={FREETEXT_SIZE:1,FREETEXT_COLOR:2,FREETEXT_OPACITY:3,INK_COLOR:11,INK_THICKNESS:12,INK_OPACITY:13},t.PermissionFlag={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},t.TextRenderingMode={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_ADD_TO_PATH:4,STROKE_ADD_TO_PATH:5,FILL_STROKE_ADD_TO_PATH:6,ADD_TO_PATH:7,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4},t.ImageKind={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},t.AnnotationType={TEXT:1,LINK:2,FREETEXT:3,LINE:4,SQUARE:5,CIRCLE:6,POLYGON:7,POLYLINE:8,HIGHLIGHT:9,UNDERLINE:10,SQUIGGLY:11,STRIKEOUT:12,STAMP:13,CARET:14,INK:15,POPUP:16,FILEATTACHMENT:17,SOUND:18,MOVIE:19,WIDGET:20,SCREEN:21,PRINTERMARK:22,TRAPNET:23,WATERMARK:24,THREED:25,REDACT:26},t.AnnotationReplyType={GROUP:"Group",REPLY:"R"},t.AnnotationFlag={INVISIBLE:1,HIDDEN:2,PRINT:4,NOZOOM:8,NOROTATE:16,NOVIEW:32,READONLY:64,LOCKED:128,TOGGLENOVIEW:256,LOCKEDCONTENTS:512},t.AnnotationFieldFlag={READONLY:1,REQUIRED:2,NOEXPORT:4,MULTILINE:4096,PASSWORD:8192,NOTOGGLETOOFF:16384,RADIO:32768,PUSHBUTTON:65536,COMBO:131072,EDIT:262144,SORT:524288,FILESELECT:1048576,MULTISELECT:2097152,DONOTSPELLCHECK:4194304,DONOTSCROLL:8388608,COMB:16777216,RICHTEXT:33554432,RADIOSINUNISON:33554432,COMMITONSELCHANGE:67108864},t.AnnotationBorderStyleType={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5},t.AnnotationActionEventType={E:"Mouse Enter",X:"Mouse Exit",D:"Mouse Down",U:"Mouse Up",Fo:"Focus",Bl:"Blur",PO:"PageOpen",PC:"PageClose",PV:"PageVisible",PI:"PageInvisible",K:"Keystroke",F:"Format",V:"Validate",C:"Calculate"},t.DocumentActionEventType={WC:"WillClose",WS:"WillSave",DS:"DidSave",WP:"WillPrint",DP:"DidPrint"},t.PageActionEventType={O:"PageOpen",C:"PageClose"};let i={ERRORS:0,WARNINGS:1,INFOS:5};t.VerbosityLevel=i,t.CMapCompressionType={NONE:0,BINARY:1},t.OPS={dependency:1,setLineWidth:2,setLineCap:3,setLineJoin:4,setMiterLimit:5,setDash:6,setRenderingIntent:7,setFlatness:8,setGState:9,save:10,restore:11,transform:12,moveTo:13,lineTo:14,curveTo:15,curveTo2:16,curveTo3:17,closePath:18,rectangle:19,stroke:20,closeStroke:21,fill:22,eoFill:23,fillStroke:24,eoFillStroke:25,closeFillStroke:26,closeEOFillStroke:27,endPath:28,clip:29,eoClip:30,beginText:31,endText:32,setCharSpacing:33,setWordSpacing:34,setHScale:35,setLeading:36,setFont:37,setTextRenderingMode:38,setTextRise:39,moveText:40,setLeadingMoveText:41,setTextMatrix:42,nextLine:43,showText:44,showSpacedText:45,nextLineShowText:46,nextLineSetSpacingShowText:47,setCharWidth:48,setCharWidthAndBounds:49,setStrokeColorSpace:50,setFillColorSpace:51,setStrokeColor:52,setStrokeColorN:53,setFillColor:54,setFillColorN:55,setStrokeGray:56,setFillGray:57,setStrokeRGBColor:58,setFillRGBColor:59,setStrokeCMYKColor:60,setFillCMYKColor:61,shadingFill:62,beginInlineImage:63,beginImageData:64,endInlineImage:65,paintXObject:66,markPoint:67,markPointProps:68,beginMarkedContent:69,beginMarkedContentProps:70,endMarkedContent:71,beginCompat:72,endCompat:73,paintFormXObjectBegin:74,paintFormXObjectEnd:75,beginGroup:76,endGroup:77,beginAnnotation:80,endAnnotation:81,paintImageMaskXObject:83,paintImageMaskXObjectGroup:84,paintImageXObject:85,paintInlineImageXObject:86,paintInlineImageXObjectGroup:87,paintImageXObjectRepeat:88,paintImageMaskXObjectRepeat:89,paintSolidColorImageMask:90,constructPath:91},t.PasswordResponses={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let r=i.WARNINGS;function a(e){r>=i.WARNINGS&&console.log(`Warning: ${e}`)}function s(e){throw new Error(e)}function o(e,t,n,i=!1){return Object.defineProperty(e,t,{value:n,enumerable:!i,configurable:!0,writable:!1}),n}let l=function(){function e(t,n){this.constructor===e&&s("Cannot initialize BaseException."),this.message=t,this.name=n}return e.prototype=new Error,e.constructor=e,e}();function h(e){"string"!=typeof e&&s("Invalid argument for stringToBytes");let t=e.length,n=new Uint8Array(t);for(let i=0;i<t;++i)n[i]=255&e.charCodeAt(i);return n}t.BaseException=l,t.PasswordException=class extends l{constructor(e,t){super(e,"PasswordException"),this.code=t}},t.UnknownErrorException=class extends l{constructor(e,t){super(e,"UnknownErrorException"),this.details=t}},t.InvalidPDFException=class extends l{constructor(e){super(e,"InvalidPDFException")}},t.MissingPDFException=class extends l{constructor(e){super(e,"MissingPDFException")}},t.UnexpectedResponseException=class extends l{constructor(e,t){super(e,"UnexpectedResponseException"),this.status=t}},t.FormatError=class extends l{constructor(e){super(e,"FormatError")}},t.AbortException=class extends l{constructor(e){super(e,"AbortException")}},t.FeatureTest=class{static get isLittleEndian(){return o(this,"isLittleEndian",function(){let e=new Uint8Array(4);return e[0]=1,1===new Uint32Array(e.buffer,0,1)[0]}())}static get isEvalSupported(){return o(this,"isEvalSupported",function(){try{return new Function(""),!0}catch(e){return!1}}())}static get isOffscreenCanvasSupported(){return o(this,"isOffscreenCanvasSupported","undefined"!=typeof OffscreenCanvas)}static get platform(){return"undefined"==typeof navigator?o(this,"platform",{isWin:!1,isMac:!1}):o(this,"platform",{isWin:navigator.platform.includes("Win"),isMac:navigator.platform.includes("Mac")})}};let u=[...Array(256).keys()].map((e=>e.toString(16).padStart(2,"0")));t.Util=class{static makeHexColor(e,t,n){return`#${u[e]}${u[t]}${u[n]}`}static scaleMinMax(e,t){let n;e[0]?(e[0]<0&&(n=t[0],t[0]=t[1],t[1]=n),t[0]*=e[0],t[1]*=e[0],e[3]<0&&(n=t[2],t[2]=t[3],t[3]=n),t[2]*=e[3],t[3]*=e[3]):(n=t[0],t[0]=t[2],t[2]=n,n=t[1],t[1]=t[3],t[3]=n,e[1]<0&&(n=t[2],t[2]=t[3],t[3]=n),t[2]*=e[1],t[3]*=e[1],e[2]<0&&(n=t[0],t[0]=t[1],t[1]=n),t[0]*=e[2],t[1]*=e[2]),t[0]+=e[4],t[1]+=e[4],t[2]+=e[5],t[3]+=e[5]}static transform(e,t){return[e[0]*t[0]+e[2]*t[1],e[1]*t[0]+e[3]*t[1],e[0]*t[2]+e[2]*t[3],e[1]*t[2]+e[3]*t[3],e[0]*t[4]+e[2]*t[5]+e[4],e[1]*t[4]+e[3]*t[5]+e[5]]}static applyTransform(e,t){return[e[0]*t[0]+e[1]*t[2]+t[4],e[0]*t[1]+e[1]*t[3]+t[5]]}static applyInverseTransform(e,t){let n=t[0]*t[3]-t[1]*t[2];return[(e[0]*t[3]-e[1]*t[2]+t[2]*t[5]-t[4]*t[3])/n,(-e[0]*t[1]+e[1]*t[0]+t[4]*t[1]-t[5]*t[0])/n]}static getAxialAlignedBoundingBox(e,t){let n=this.applyTransform(e,t),i=this.applyTransform(e.slice(2,4),t),r=this.applyTransform([e[0],e[3]],t),a=this.applyTransform([e[2],e[1]],t);return[Math.min(n[0],i[0],r[0],a[0]),Math.min(n[1],i[1],r[1],a[1]),Math.max(n[0],i[0],r[0],a[0]),Math.max(n[1],i[1],r[1],a[1])]}static inverseTransform(e){let t=e[0]*e[3]-e[1]*e[2];return[e[3]/t,-e[1]/t,-e[2]/t,e[0]/t,(e[2]*e[5]-e[4]*e[3])/t,(e[4]*e[1]-e[5]*e[0])/t]}static singularValueDecompose2dScale(e){let t=[e[0],e[2],e[1],e[3]],n=e[0]*t[0]+e[1]*t[2],i=e[0]*t[1]+e[1]*t[3],r=e[2]*t[0]+e[3]*t[2],a=e[2]*t[1]+e[3]*t[3],s=(n+a)/2,o=Math.sqrt(gg(n+a,2)-4*(n*a-r*i))/2,l=s+o||1,h=s-o||1;return[Math.sqrt(l),Math.sqrt(h)]}static normalizeRect(e){let t=e.slice(0);return e[0]>e[2]&&(t[0]=e[2],t[2]=e[0]),e[1]>e[3]&&(t[1]=e[3],t[3]=e[1]),t}static intersect(e,t){let n=Math.max(Math.min(e[0],e[2]),Math.min(t[0],t[2])),i=Math.min(Math.max(e[0],e[2]),Math.max(t[0],t[2]));if(n>i)return null;let r=Math.max(Math.min(e[1],e[3]),Math.min(t[1],t[3])),a=Math.min(Math.max(e[1],e[3]),Math.max(t[1],t[3]));return r>a?null:[n,r,i,a]}static bezierBoundingBox(e,t,n,i,r,a,s,o){let l,h,u,c,d,p,f,m,g=[],v=[[],[]];for(let _=0;_<2;++_)if(0===_?(h=6*e-12*n+6*r,l=-3*e+9*n-9*r+3*s,u=3*n-3*e):(h=6*t-12*i+6*a,l=-3*t+9*i-9*a+3*o,u=3*i-3*t),Math.abs(l)<1e-12){if(Math.abs(h)<1e-12)continue;c=-u/h,0<c&&c<1&&g.push(c)}else f=h*h-4*u*l,m=Math.sqrt(f),!(f<0)&&(d=(-h+m)/(2*l),0<d&&d<1&&g.push(d),p=(-h-m)/(2*l),0<p&&p<1&&g.push(p));let y,x=g.length,b=x;for(;x--;)c=g[x],y=1-c,v[0][x]=y*y*y*e+3*y*y*c*n+3*y*c*c*r+c*c*c*s,v[1][x]=y*y*y*t+3*y*y*c*i+3*y*c*c*a+c*c*c*o;return v[0][b]=e,v[1][b]=t,v[0][b+1]=s,v[1][b+1]=o,v[0].length=v[1].length=b+2,[Math.min(...v[0]),Math.min(...v[1]),Math.max(...v[0]),Math.max(...v[1])]}};let c=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,728,711,710,729,733,731,730,732,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,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,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,8226,8224,8225,8230,8212,8211,402,8260,8249,8250,8722,8240,8222,8220,8221,8216,8217,8218,8482,64257,64258,321,338,352,376,381,305,322,339,353,382,0,8364];function d(e){return decodeURIComponent(escape(e))}n=new WeakMap,t.PromiseCapability=class{constructor(){Je(this,n,!1),this.promise=new Promise(((e,t)=>{this.resolve=t=>{wt(this,n,!0),e(t)},this.reject=e=>{wt(this,n,!0),t(e)}}))}get settled(){return le(this,n)}};let p=null,f=null},(__unused_webpack_module,exports,__w_pdfjs_require__)=>{var i,e,n,r,A1,a,h2,l,c,u,h,d,f,p,g,J4,v,E,Q4,_,C;Object.defineProperty(exports,"__esModule",{value:!0}),exports.build=exports.RenderTask=exports.PDFWorkerUtil=exports.PDFWorker=exports.PDFPageProxy=exports.PDFDocumentProxy=exports.PDFDocumentLoadingTask=exports.PDFDataRangeTransport=exports.LoopbackPort=exports.DefaultStandardFontDataFactory=exports.DefaultFilterFactory=exports.DefaultCanvasFactory=exports.DefaultCMapReaderFactory=void 0,exports.getDocument=getDocument,exports.version=void 0;var _util=__w_pdfjs_require__(1),_annotation_storage=__w_pdfjs_require__(3),_display_utils=__w_pdfjs_require__(6),_font_loader=__w_pdfjs_require__(9),_canvas=__w_pdfjs_require__(11),_worker_options=__w_pdfjs_require__(14),_is_node=__w_pdfjs_require__(10),_message_handler=__w_pdfjs_require__(15),_metadata=__w_pdfjs_require__(16),_optional_content_config=__w_pdfjs_require__(17),_transport_stream=__w_pdfjs_require__(18),_xfa_text=__w_pdfjs_require__(19);let DEFAULT_RANGE_CHUNK_SIZE=65536,RENDERING_CANCELLED_TIMEOUT=100,DELAYED_CLEANUP_TIMEOUT=5e3,DefaultCanvasFactory=_is_node.isNodeJS?__w_pdfjs_require__(20).NodeCanvasFactory:_display_utils.DOMCanvasFactory;exports.DefaultCanvasFactory=DefaultCanvasFactory;let DefaultCMapReaderFactory=_is_node.isNodeJS?__w_pdfjs_require__(20).NodeCMapReaderFactory:_display_utils.DOMCMapReaderFactory;exports.DefaultCMapReaderFactory=DefaultCMapReaderFactory;let DefaultFilterFactory=_is_node.isNodeJS?__w_pdfjs_require__(20).NodeFilterFactory:_display_utils.DOMFilterFactory;exports.DefaultFilterFactory=DefaultFilterFactory;let DefaultStandardFontDataFactory=_is_node.isNodeJS?__w_pdfjs_require__(20).NodeStandardFontDataFactory:_display_utils.DOMStandardFontDataFactory,createPDFNetworkStream;if(exports.DefaultStandardFontDataFactory=DefaultStandardFontDataFactory,_is_node.isNodeJS){let{PDFNodeStream:e}=__w_pdfjs_require__(21);createPDFNetworkStream=t=>new e(t)}else{let{PDFNetworkStream:e}=__w_pdfjs_require__(24),{PDFFetchStream:t}=__w_pdfjs_require__(25);createPDFNetworkStream=n=>(0,_display_utils.isValidFetchUrl)(n.url)?new t(n):new e(n)}function getDocument(e){var t,n;if("string"==typeof e||e instanceof URL?e={url:e}:(0,_util.isArrayBuffer)(e)&&(e={data:e}),"object"!=typeof e)throw new Error("Invalid parameter in getDocument, need parameter object.");if(!e.url&&!e.data&&!e.range)throw new Error("Invalid parameter object: need either .data, .range or .url");let i=new PDFDocumentLoadingTask,{docId:r}=i,a=e.url?getUrlProp(e.url):null,s=e.data?getDataProp(e.data):null,o=e.httpHeaders||null,l=!0===e.withCredentials,h=null!=(t=e.password)?t:null,u=e.range instanceof PDFDataRangeTransport?e.range:null,c=Number.isInteger(e.rangeChunkSize)&&e.rangeChunkSize>0?e.rangeChunkSize:DEFAULT_RANGE_CHUNK_SIZE,d=e.worker instanceof PDFWorker?e.worker:null,p=e.verbosity,f="string"!=typeof e.docBaseUrl||(0,_display_utils.isDataScheme)(e.docBaseUrl)?null:e.docBaseUrl,m="string"==typeof e.cMapUrl?e.cMapUrl:null,g=!1!==e.cMapPacked,v=e.CMapReaderFactory||DefaultCMapReaderFactory,y="string"==typeof e.standardFontDataUrl?e.standardFontDataUrl:null,x=e.StandardFontDataFactory||DefaultStandardFontDataFactory,b=!0!==e.stopAtErrors,_=Number.isInteger(e.maxImageSize)&&e.maxImageSize>-1?e.maxImageSize:-1,w=!1!==e.isEvalSupported,S="boolean"==typeof e.isOffscreenCanvasSupported?e.isOffscreenCanvasSupported:!_is_node.isNodeJS,M=Number.isInteger(e.canvasMaxAreaInBytes)?e.canvasMaxAreaInBytes:-1,E="boolean"==typeof e.disableFontFace?e.disableFontFace:_is_node.isNodeJS,T=!0===e.fontExtraProperties,A=!0===e.enableXfa,C=e.ownerDocument||globalThis.document,P=!0===e.disableRange,R=!0===e.disableStream,L=!0===e.disableAutoFetch,I=!0===e.pdfBug,k=u?u.length:null!=(n=e.length)?n:NaN,O="boolean"==typeof e.useSystemFonts?e.useSystemFonts:!_is_node.isNodeJS&&!E,D="boolean"==typeof e.useWorkerFetch?e.useWorkerFetch:v===_display_utils.DOMCMapReaderFactory&&x===_display_utils.DOMStandardFontDataFactory&&(0,_display_utils.isValidFetchUrl)(m,document.baseURI)&&(0,_display_utils.isValidFetchUrl)(y,document.baseURI),N=e.canvasFactory||new DefaultCanvasFactory({ownerDocument:C}),U=e.filterFactory||new DefaultFilterFactory({docId:r,ownerDocument:C});(0,_util.setVerbosityLevel)(p);let F={canvasFactory:N,filterFactory:U};if(D||(F.cMapReaderFactory=new v({baseUrl:m,isCompressed:g}),F.standardFontDataFactory=new x({baseUrl:y})),!d){let e={verbosity:p,port:_worker_options.GlobalWorkerOptions.workerPort};d=e.port?PDFWorker.fromPort(e):new PDFWorker(e),i._worker=d}let B={docId:r,apiVersion:"3.8.162",data:s,password:h,disableAutoFetch:L,rangeChunkSize:c,length:k,docBaseUrl:f,enableXfa:A,evaluatorOptions:{maxImageSize:_,disableFontFace:E,ignoreErrors:b,isEvalSupported:w,isOffscreenCanvasSupported:S,canvasMaxAreaInBytes:M,fontExtraProperties:T,useSystemFonts:O,cMapUrl:D?m:null,standardFontDataUrl:D?y:null}},z={ignoreErrors:b,isEvalSupported:w,disableFontFace:E,fontExtraProperties:T,enableXfa:A,ownerDocument:C,disableAutoFetch:L,pdfBug:I,styleElement:null};return d.promise.then((function(){if(i.destroyed)throw new Error("Loading aborted");let e=_fetchDocument(d,B),t=new Promise((function(e){let t;u?t=new _transport_stream.PDFDataTransportStream({length:k,initialData:u.initialData,progressiveDone:u.progressiveDone,contentDispositionFilename:u.contentDispositionFilename,disableRange:P,disableStream:R},u):s||(t=createPDFNetworkStream({url:a,length:k,httpHeaders:o,withCredentials:l,rangeChunkSize:c,disableRange:P,disableStream:R})),e(t)}));return Promise.all([e,t]).then((function([e,t]){if(i.destroyed)throw new Error("Loading aborted");let n=new _message_handler.MessageHandler(r,e,d.port),a=new WorkerTransport(n,i,t,z,F);i._transport=a,n.send("Ready",null)}))})).catch(i._capability.reject),i}function _fetchDocument(e,t){return it(this,null,(function*(){if(e.destroyed)throw new Error("Worker was destroyed");let n=yield e.messageHandler.sendWithPromise("GetDocRequest",t,t.data?[t.data.buffer]:null);if(e.destroyed)throw new Error("Worker was destroyed");return n}))}function getUrlProp(e){if(e instanceof URL)return e.href;try{return new URL(e,window.location).href}catch(t){if(_is_node.isNodeJS&&"string"==typeof e)return e}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}function getDataProp(e){if(_is_node.isNodeJS&&"undefined"!=typeof Buffer&&e instanceof Buffer)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(e instanceof Uint8Array&&e.byteLength===e.buffer.byteLength)return e;if("string"==typeof e)return(0,_util.stringToBytes)(e);if("object"==typeof e&&!isNaN(null==e?void 0:e.length)||(0,_util.isArrayBuffer)(e))return new Uint8Array(e);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}let t=class{constructor(){this._capability=new _util.PromiseCapability,this._transport=null,this._worker=null,this.docId="d"+ET(t,i)._++,this.destroyed=!1,this.onPassword=null,this.onProgress=null}get promise(){return this._capability.promise}destroy(){return it(this,null,(function*(){var e;this.destroyed=!0,yield null==(e=this._transport)?void 0:e.destroy(),this._transport=null,this._worker&&(this._worker.destroy(),this._worker=null)}))}},PDFDocumentLoadingTask=t;i=new WeakMap,Je(PDFDocumentLoadingTask,i,0),exports.PDFDocumentLoadingTask=PDFDocumentLoadingTask;class PDFDataRangeTransport{constructor(e,t,n=!1,i=null){this.length=e,this.initialData=t,this.progressiveDone=n,this.contentDispositionFilename=i,this._rangeListeners=[],this._progressListeners=[],this._progressiveReadListeners=[],this._progressiveDoneListeners=[],this._readyCapability=new _util.PromiseCapability}addRangeListener(e){this._rangeListeners.push(e)}addProgressListener(e){this._progressListeners.push(e)}addProgressiveReadListener(e){this._progressiveReadListeners.push(e)}addProgressiveDoneListener(e){this._progressiveDoneListeners.push(e)}onDataRange(e,t){for(let n of this._rangeListeners)n(e,t)}onDataProgress(e,t){this._readyCapability.promise.then((()=>{for(let n of this._progressListeners)n(e,t)}))}onDataProgressiveRead(e){this._readyCapability.promise.then((()=>{for(let t of this._progressiveReadListeners)t(e)}))}onDataProgressiveDone(){this._readyCapability.promise.then((()=>{for(let e of this._progressiveDoneListeners)e()}))}transportReady(){this._readyCapability.resolve()}requestDataRange(e,t){(0,_util.unreachable)("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}exports.PDFDataRangeTransport=PDFDataRangeTransport;class PDFDocumentProxy{constructor(e,t){this._pdfInfo=e,this._transport=t}get annotationStorage(){return this._transport.annotationStorage}get filterFactory(){return this._transport.filterFactory}get numPages(){return this._pdfInfo.numPages}get fingerprints(){return this._pdfInfo.fingerprints}get isPureXfa(){return(0,_util.shadow)(this,"isPureXfa",!!this._transport._htmlForXfa)}get allXfaHtml(){return this._transport._htmlForXfa}getPage(e){return this._transport.getPage(e)}getPageIndex(e){return this._transport.getPageIndex(e)}getDestinations(){return this._transport.getDestinations()}getDestination(e){return this._transport.getDestination(e)}getPageLabels(){return this._transport.getPageLabels()}getPageLayout(){return this._transport.getPageLayout()}getPageMode(){return this._transport.getPageMode()}getViewerPreferences(){return this._transport.getViewerPreferences()}getOpenAction(){return this._transport.getOpenAction()}getAttachments(){return this._transport.getAttachments()}getJavaScript(){return this._transport.getJavaScript()}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig(){return this._transport.getOptionalContentConfig()}getPermissions(){return this._transport.getPermissions()}getMetadata(){return this._transport.getMetadata()}getMarkInfo(){return this._transport.getMarkInfo()}getData(){return this._transport.getData()}saveDocument(){return this._transport.saveDocument()}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}cleanup(e=!1){return this._transport.startCleanup(e||this.isPureXfa)}destroy(){return this.loadingTask.destroy()}get loadingParams(){return this._transport.loadingParams}get loadingTask(){return this._transport.loadingTask}getFieldObjects(){return this._transport.getFieldObjects()}hasJSActions(){return this._transport.hasJSActions()}getCalculationOrderIds(){return this._transport.getCalculationOrderIds()}}exports.PDFDocumentProxy=PDFDocumentProxy;class PDFPageProxy{constructor(t,i,s,o=!1){Je(this,r),Je(this,a),Je(this,e,null),Je(this,n,!1),this._pageIndex=t,this._pageInfo=i,this._transport=s,this._stats=o?new _display_utils.StatTimer:null,this._pdfBug=o,this.commonObjs=s.commonObjs,this.objs=new PDFObjects,this._maybeCleanupAfterRender=!1,this._intentStates=new Map,this.destroyed=!1}get pageNumber(){return this._pageIndex+1}get rotate(){return this._pageInfo.rotate}get ref(){return this._pageInfo.ref}get userUnit(){return this._pageInfo.userUnit}get view(){return this._pageInfo.view}getViewport({scale:e,rotation:t=this.rotate,offsetX:n=0,offsetY:i=0,dontFlip:r=!1}={}){return new _display_utils.PageViewport({viewBox:this.view,scale:e,rotation:t,offsetX:n,offsetY:i,dontFlip:r})}getAnnotations({intent:e="display"}={}){let t=this._transport.getRenderingIntent(e);return this._transport.getAnnotations(this._pageIndex,t.renderingIntent)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return(0,_util.shadow)(this,"isPureXfa",!!this._transport._htmlForXfa)}getXfa(){return it(this,null,(function*(){var e;return(null==(e=this._transport._htmlForXfa)?void 0:e.children[this._pageIndex])||null}))}render({canvasContext:e,viewport:t,intent:i="display",annotationMode:s=_util.AnnotationMode.ENABLE,transform:o=null,background:l=null,optionalContentConfigPromise:h=null,annotationCanvasMap:u=null,pageColors:c=null,printAnnotationStorage:d=null}){var p,f;null==(p=this._stats)||p.time("Overall");let m=this._transport.getRenderingIntent(i,s,d);wt(this,n,!1),ft(this,a,h2).call(this),h||(h=this._transport.getOptionalContentConfig());let g=this._intentStates.get(m.cacheKey);g||(g=Object.create(null),this._intentStates.set(m.cacheKey,g)),g.streamReaderCancelTimeout&&(clearTimeout(g.streamReaderCancelTimeout),g.streamReaderCancelTimeout=null);let v=!!(m.renderingIntent&_util.RenderingIntentFlag.PRINT);g.displayReadyCapability||(g.displayReadyCapability=new _util.PromiseCapability,g.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},null==(f=this._stats)||f.time("Page Request"),this._pumpOperatorList(m));let y=e=>{var t,i;g.renderTasks.delete(x),(this._maybeCleanupAfterRender||v)&&wt(this,n,!0),ft(this,r,A1).call(this,!v),e?(x.capability.reject(e),this._abortOperatorList({intentState:g,reason:e instanceof Error?e:new Error(e)})):x.capability.resolve(),null==(t=this._stats)||t.timeEnd("Rendering"),null==(i=this._stats)||i.timeEnd("Overall")},x=new InternalRenderTask({callback:y,params:{canvasContext:e,viewport:t,transform:o,background:l},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:u,operatorList:g.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!v,pdfBug:this._pdfBug,pageColors:c});(g.renderTasks||(g.renderTasks=new Set)).add(x);let b=x.task;return Promise.all([g.displayReadyCapability.promise,h]).then((([e,t])=>{var n;this.destroyed?y():(null==(n=this._stats)||n.time("Rendering"),x.initializeGraphics({transparency:e,optionalContentConfig:t}),x.operatorListChanged())})).catch(y),b}getOperatorList({intent:e="display",annotationMode:t=_util.AnnotationMode.ENABLE,printAnnotationStorage:n=null}={}){var i;let r,a=this._transport.getRenderingIntent(e,t,n,!0),s=this._intentStates.get(a.cacheKey);return s||(s=Object.create(null),this._intentStates.set(a.cacheKey,s)),s.opListReadCapability||(r=Object.create(null),r.operatorListChanged=function(){s.operatorList.lastChunk&&(s.opListReadCapability.resolve(s.operatorList),s.renderTasks.delete(r))},s.opListReadCapability=new _util.PromiseCapability,(s.renderTasks||(s.renderTasks=new Set)).add(r),s.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},null==(i=this._stats)||i.time("Page Request"),this._pumpOperatorList(a)),s.opListReadCapability.promise}streamTextContent({includeMarkedContent:e=!1,disableNormalization:t=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageIndex:this._pageIndex,includeMarkedContent:!0===e,disableNormalization:!0===t},{highWaterMark:100,size:e=>e.items.length})}getTextContent(e={}){if(this._transport._htmlForXfa)return this.getXfa().then((e=>_xfa_text.XfaText.textContent(e)));let t=this.streamTextContent(e);return new Promise((function(e,n){let i=t.getReader(),r={items:[],styles:Object.create(null)};!function t(){i.read().then((function({value:n,done:i}){i?e(r):(Object.assign(r.styles,n.styles),r.items.push(...n.items),t())}),n)}()}))}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;let e=[];for(let t of this._intentStates.values())if(this._abortOperatorList({intentState:t,reason:new Error("Page was destroyed."),force:!0}),!t.opListReadCapability)for(let n of t.renderTasks)e.push(n.completed),n.cancel();return this.objs.clear(),wt(this,n,!1),ft(this,a,h2).call(this),Promise.all(e)}cleanup(e=!1){wt(this,n,!0);let t=ft(this,r,A1).call(this,!1);return e&&t&&this._stats&&(this._stats=new _display_utils.StatTimer),t}_startRenderPage(e,t){var n,i;let r=this._intentStates.get(t);r&&(null==(n=this._stats)||n.timeEnd("Page Request"),null==(i=r.displayReadyCapability)||i.resolve(e))}_renderPageChunk(e,t){for(let n=0,i=e.length;n<i;n++)t.operatorList.fnArray.push(e.fnArray[n]),t.operatorList.argsArray.push(e.argsArray[n]);t.operatorList.lastChunk=e.lastChunk,t.operatorList.separateAnnots=e.separateAnnots;for(let n of t.renderTasks)n.operatorListChanged();e.lastChunk&&ft(this,r,A1).call(this,!0)}_pumpOperatorList({renderingIntent:e,cacheKey:t,annotationStorageSerializable:n}){let{map:i,transfers:a}=n,s=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:this._pageIndex,intent:e,cacheKey:t,annotationStorage:i},a).getReader(),o=this._intentStates.get(t);o.streamReader=s;let l=()=>{s.read().then((({value:e,done:t})=>{t?o.streamReader=null:this._transport.destroyed||(this._renderPageChunk(e,o),l())}),(e=>{if(o.streamReader=null,!this._transport.destroyed){if(o.operatorList){o.operatorList.lastChunk=!0;for(let e of o.renderTasks)e.operatorListChanged();ft(this,r,A1).call(this,!0)}if(o.displayReadyCapability)o.displayReadyCapability.reject(e);else{if(!o.opListReadCapability)throw e;o.opListReadCapability.reject(e)}}}))};l()}_abortOperatorList({intentState:e,reason:t,force:n=!1}){if(e.streamReader){if(e.streamReaderCancelTimeout&&(clearTimeout(e.streamReaderCancelTimeout),e.streamReaderCancelTimeout=null),!n){if(e.renderTasks.size>0)return;if(t instanceof _display_utils.RenderingCancelledException){let n=RENDERING_CANCELLED_TIMEOUT;return t.extraDelay>0&&t.extraDelay<1e3&&(n+=t.extraDelay),void(e.streamReaderCancelTimeout=setTimeout((()=>{e.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:e,reason:t,force:!0})}),n))}}if(e.streamReader.cancel(new _util.AbortException(t.message)).catch((()=>{})),e.streamReader=null,!this._transport.destroyed){for(let[t,n]of this._intentStates)if(n===e){this._intentStates.delete(t);break}this.cleanup()}}}get stats(){return this._stats}}e=new WeakMap,n=new WeakMap,r=new WeakSet,A1=function(t=!1){if(ft(this,a,h2).call(this),!le(this,n)||this.destroyed)return!1;if(t)return wt(this,e,setTimeout((()=>{wt(this,e,null),ft(this,r,A1).call(this,!1)}),DELAYED_CLEANUP_TIMEOUT)),!1;for(let{renderTasks:e,operatorList:n}of this._intentStates.values())if(e.size>0||!n.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),wt(this,n,!1),!0},a=new WeakSet,h2=function(){le(this,e)&&(clearTimeout(le(this,e)),wt(this,e,null))},exports.PDFPageProxy=PDFPageProxy;class LoopbackPort{constructor(){Je(this,l,new Set),Je(this,c,Promise.resolve())}postMessage(e,t){let n={data:structuredClone(e,t?{transfer:t}:null)};le(this,c).then((()=>{for(let e of le(this,l))e.call(this,n)}))}addEventListener(e,t){le(this,l).add(t)}removeEventListener(e,t){le(this,l).delete(t)}terminate(){le(this,l).clear()}}l=new WeakMap,c=new WeakMap,exports.LoopbackPort=LoopbackPort;let PDFWorkerUtil={isWorkerDisabled:!1,fallbackWorkerSrc:null,fakeWorkerId:0};if(exports.PDFWorkerUtil=PDFWorkerUtil,_is_node.isNodeJS&&"function"==typeof HI)PDFWorkerUtil.isWorkerDisabled=!0,PDFWorkerUtil.fallbackWorkerSrc="./pdf.worker.js";else if("object"==typeof document){let e=null==(u=null==document?void 0:document.currentScript)?void 0:u.src;e&&(PDFWorkerUtil.fallbackWorkerSrc=e.replace(/(\.(?:min\.)?js)(\?.*)?$/i,".worker$1$2"))}PDFWorkerUtil.isSameOrigin=function(e,t){let n;try{if(n=new URL(e),!n.origin||"null"===n.origin)return!1}catch(e){return!1}let i=new URL(t,n);return n.origin===i.origin},PDFWorkerUtil.createCDNWrapper=function(e){let t=`importScripts("${e}");`;return URL.createObjectURL(new Blob([t]))};let _PDFWorker=class{constructor({name:e=null,port:t=null,verbosity:n=(0,_util.getVerbosityLevel)()}={}){if(t&&le(_PDFWorker,h).has(t))throw new Error("Cannot use more than one PDFWorker per port.");if(this.name=e,this.destroyed=!1,this.verbosity=n,this._readyCapability=new _util.PromiseCapability,this._port=null,this._webWorker=null,this._messageHandler=null,t)return le(_PDFWorker,h).set(t,this),void this._initializeFromPort(t);this._initialize()}get promise(){return this._readyCapability.promise}get port(){return this._port}get messageHandler(){return this._messageHandler}_initializeFromPort(e){this._port=e,this._messageHandler=new _message_handler.MessageHandler("main","worker",e),this._messageHandler.on("ready",(function(){})),this._readyCapability.resolve(),this._messageHandler.send("configure",{verbosity:this.verbosity})}_initialize(){if(!PDFWorkerUtil.isWorkerDisabled&&!_PDFWorker._mainThreadWorkerMessageHandler){let{workerSrc:t}=_PDFWorker;try{PDFWorkerUtil.isSameOrigin(window.location.href,t)||(t=PDFWorkerUtil.createCDNWrapper(new URL(t,window.location).href));let e=new Worker(t),n=new _message_handler.MessageHandler("main","worker",e),i=()=>{e.removeEventListener("error",r),n.destroy(),e.terminate(),this.destroyed?this._readyCapability.reject(new Error("Worker was destroyed")):this._setupFakeWorker()},r=()=>{this._webWorker||i()};e.addEventListener("error",r),n.on("test",(t=>{e.removeEventListener("error",r),this.destroyed?i():t?(this._messageHandler=n,this._port=e,this._webWorker=e,this._readyCapability.resolve(),n.send("configure",{verbosity:this.verbosity})):(this._setupFakeWorker(),n.destroy(),e.terminate())})),n.on("ready",(t=>{if(e.removeEventListener("error",r),this.destroyed)i();else try{a()}catch(t){this._setupFakeWorker()}}));let a=()=>{let e=new Uint8Array;n.send("test",e,[e.buffer])};return void a()}catch(e){(0,_util.info)("The worker has been disabled.")}}this._setupFakeWorker()}_setupFakeWorker(){PDFWorkerUtil.isWorkerDisabled||((0,_util.warn)("Setting up fake worker."),PDFWorkerUtil.isWorkerDisabled=!0),_PDFWorker._setupFakeWorkerGlobal.then((e=>{if(this.destroyed)return void this._readyCapability.reject(new Error("Worker was destroyed"));let t=new LoopbackPort;this._port=t;let n="fake"+PDFWorkerUtil.fakeWorkerId++,i=new _message_handler.MessageHandler(n+"_worker",n,t);e.setup(i,t);let r=new _message_handler.MessageHandler(n,n+"_worker",t);this._messageHandler=r,this._readyCapability.resolve(),r.send("configure",{verbosity:this.verbosity})})).catch((e=>{this._readyCapability.reject(new Error(`Setting up fake worker failed: "${e.message}".`))}))}destroy(){this.destroyed=!0,this._webWorker&&(this._webWorker.terminate(),this._webWorker=null),le(_PDFWorker,h).delete(this._port),this._port=null,this._messageHandler&&(this._messageHandler.destroy(),this._messageHandler=null)}static fromPort(e){if(null==e||!e.port)throw new Error("PDFWorker.fromPort - invalid method signature.");return le(this,h).has(e.port)?le(this,h).get(e.port):new _PDFWorker(e)}static get workerSrc(){if(_worker_options.GlobalWorkerOptions.workerSrc)return _worker_options.GlobalWorkerOptions.workerSrc;if(null!==PDFWorkerUtil.fallbackWorkerSrc)return _is_node.isNodeJS||(0,_display_utils.deprecated)('No "GlobalWorkerOptions.workerSrc" specified.'),PDFWorkerUtil.fallbackWorkerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get _mainThreadWorkerMessageHandler(){var e;try{return(null==(e=globalThis.pdfjsWorker)?void 0:e.WorkerMessageHandler)||null}catch(e){return null}}static get _setupFakeWorkerGlobal(){let loader=()=>it(this,null,(function*(){let mainWorkerMessageHandler=this._mainThreadWorkerMessageHandler;if(mainWorkerMessageHandler)return mainWorkerMessageHandler;if(_is_node.isNodeJS&&"function"==typeof HI){let worker=eval("require")(this.workerSrc);return worker.WorkerMessageHandler}return yield(0,_display_utils.loadScript)(this.workerSrc),window.pdfjsWorker.WorkerMessageHandler}));return(0,_util.shadow)(this,"_setupFakeWorkerGlobal",loader())}},PDFWorker=_PDFWorker;h=new WeakMap,Je(PDFWorker,h,new WeakMap),exports.PDFWorker=PDFWorker;class WorkerTransport{constructor(e,t,n,i,r){Je(this,g),Je(this,d,new Map),Je(this,f,new Map),Je(this,p,new Map),this.messageHandler=e,this.loadingTask=t,this.commonObjs=new PDFObjects,this.fontLoader=new _font_loader.FontLoader({ownerDocument:i.ownerDocument,styleElement:i.styleElement}),this._params=i,this.canvasFactory=r.canvasFactory,this.filterFactory=r.filterFactory,this.cMapReaderFactory=r.cMapReaderFactory,this.standardFontDataFactory=r.standardFontDataFactory,this.destroyed=!1,this.destroyCapability=null,this._passwordCapability=null,this._networkStream=n,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=new _util.PromiseCapability,this.setupMessageHandler()}get annotationStorage(){return(0,_util.shadow)(this,"annotationStorage",new _annotation_storage.AnnotationStorage)}getRenderingIntent(e,t=_util.AnnotationMode.ENABLE,n=null,i=!1){let r=_util.RenderingIntentFlag.DISPLAY,a=_annotation_storage.SerializableEmpty;switch(e){case"any":r=_util.RenderingIntentFlag.ANY;break;case"display":break;case"print":r=_util.RenderingIntentFlag.PRINT;break;default:(0,_util.warn)(`getRenderingIntent - invalid intent: ${e}`)}switch(t){case _util.AnnotationMode.DISABLE:r+=_util.RenderingIntentFlag.ANNOTATIONS_DISABLE;break;case _util.AnnotationMode.ENABLE:break;case _util.AnnotationMode.ENABLE_FORMS:r+=_util.RenderingIntentFlag.ANNOTATIONS_FORMS;break;case _util.AnnotationMode.ENABLE_STORAGE:r+=_util.RenderingIntentFlag.ANNOTATIONS_STORAGE,a=(r&_util.RenderingIntentFlag.PRINT&&n instanceof _annotation_storage.PrintAnnotationStorage?n:this.annotationStorage).serializable;break;default:(0,_util.warn)(`getRenderingIntent - invalid annotationMode: ${t}`)}return i&&(r+=_util.RenderingIntentFlag.OPLIST),{renderingIntent:r,cacheKey:`${r}_${a.hash}`,annotationStorageSerializable:a}}destroy(){if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=new _util.PromiseCapability,this._passwordCapability&&this._passwordCapability.reject(new Error("Worker was destroyed during onPassword callback"));let e=[];for(let n of le(this,f).values())e.push(n._destroy());le(this,f).clear(),le(this,p).clear(),this.hasOwnProperty("annotationStorage")&&this.annotationStorage.resetModified();let t=this.messageHandler.sendWithPromise("Terminate",null);return e.push(t),Promise.all(e).then((()=>{this.commonObjs.clear(),this.fontLoader.clear(),le(this,d).clear(),this.filterFactory.destroy(),this._networkStream&&this._networkStream.cancelAllRequests(new _util.AbortException("Worker was terminated.")),this.messageHandler&&(this.messageHandler.destroy(),this.messageHandler=null),this.destroyCapability.resolve()}),this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){let{messageHandler:e,loadingTask:t}=this;e.on("GetReader",((e,t)=>{(0,_util.assert)(this._networkStream,"GetReader - no `IPDFStream` instance available."),this._fullReader=this._networkStream.getFullReader(),this._fullReader.onProgress=e=>{this._lastProgress={loaded:e.loaded,total:e.total}},t.onPull=()=>{this._fullReader.read().then((function({value:e,done:n}){n?t.close():((0,_util.assert)(e instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),t.enqueue(new Uint8Array(e),1,[e]))})).catch((e=>{t.error(e)}))},t.onCancel=e=>{this._fullReader.cancel(e),t.ready.catch((e=>{if(!this.destroyed)throw e}))}})),e.on("ReaderHeadersReady",(e=>{let n=new _util.PromiseCapability,i=this._fullReader;return i.headersReady.then((()=>{var e;(!i.isStreamingSupported||!i.isRangeSupported)&&(this._lastProgress&&(null==(e=t.onProgress)||e.call(t,this._lastProgress)),i.onProgress=e=>{var n;null==(n=t.onProgress)||n.call(t,{loaded:e.loaded,total:e.total})}),n.resolve({isStreamingSupported:i.isStreamingSupported,isRangeSupported:i.isRangeSupported,contentLength:i.contentLength})}),n.reject),n.promise})),e.on("GetRangeReader",((e,t)=>{(0,_util.assert)(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");let n=this._networkStream.getRangeReader(e.begin,e.end);n?(t.onPull=()=>{n.read().then((function({value:e,done:n}){n?t.close():((0,_util.assert)(e instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),t.enqueue(new Uint8Array(e),1,[e]))})).catch((e=>{t.error(e)}))},t.onCancel=e=>{n.cancel(e),t.ready.catch((e=>{if(!this.destroyed)throw e}))}):t.close()})),e.on("GetDoc",(({pdfInfo:e})=>{this._numPages=e.numPages,this._htmlForXfa=e.htmlForXfa,delete e.htmlForXfa,t._capability.resolve(new PDFDocumentProxy(e,this))})),e.on("DocException",(function(e){let n;switch(e.name){case"PasswordException":n=new _util.PasswordException(e.message,e.code);break;case"InvalidPDFException":n=new _util.InvalidPDFException(e.message);break;case"MissingPDFException":n=new _util.MissingPDFException(e.message);break;case"UnexpectedResponseException":n=new _util.UnexpectedResponseException(e.message,e.status);break;case"UnknownErrorException":n=new _util.UnknownErrorException(e.message,e.details);break;default:(0,_util.unreachable)("DocException - expected a valid Error.")}t._capability.reject(n)})),e.on("PasswordRequest",(e=>{if(this._passwordCapability=new _util.PromiseCapability,t.onPassword){let n=e=>{e instanceof Error?this._passwordCapability.reject(e):this._passwordCapability.resolve({password:e})};try{t.onPassword(n,e.code)}catch(e){this._passwordCapability.reject(e)}}else this._passwordCapability.reject(new _util.PasswordException(e.message,e.code));return this._passwordCapability.promise})),e.on("DataLoaded",(e=>{var n;null==(n=t.onProgress)||n.call(t,{loaded:e.length,total:e.length}),this.downloadInfoCapability.resolve(e)})),e.on("StartRenderPage",(e=>{this.destroyed||le(this,f).get(e.pageIndex)._startRenderPage(e.transparency,e.cacheKey)})),e.on("commonobj",(([t,n,i])=>{var r;if(!this.destroyed&&!this.commonObjs.has(t))switch(n){case"Font":let a=this._params;if("error"in i){let e=i.error;(0,_util.warn)(`Error during font loading: ${e}`),this.commonObjs.resolve(t,e);break}let s=a.pdfBug&&null!=(r=globalThis.FontInspector)&&r.enabled?(e,t)=>globalThis.FontInspector.fontAdded(e,t):null,o=new _font_loader.FontFaceObject(i,{isEvalSupported:a.isEvalSupported,disableFontFace:a.disableFontFace,ignoreErrors:a.ignoreErrors,inspectFont:s});this.fontLoader.bind(o).catch((n=>e.sendWithPromise("FontFallback",{id:t}))).finally((()=>{!a.fontExtraProperties&&o.data&&(o.data=null),this.commonObjs.resolve(t,o)}));break;case"FontPath":case"Image":case"Pattern":this.commonObjs.resolve(t,i);break;default:throw new Error(`Got unknown common object type ${n}`)}})),e.on("obj",(([e,t,n,i])=>{var r;if(this.destroyed)return;let a=le(this,f).get(t);if(!a.objs.has(e))switch(n){case"Image":if(a.objs.resolve(e,i),i){let e;if(i.bitmap){let{width:t,height:n}=i;e=t*n*4}else e=(null==(r=i.data)?void 0:r.length)||0;e>_util.MAX_IMAGE_SIZE_TO_CACHE&&(a._maybeCleanupAfterRender=!0)}break;case"Pattern":a.objs.resolve(e,i);break;default:throw new Error(`Got unknown object type ${n}`)}})),e.on("DocProgress",(e=>{var n;this.destroyed||null==(n=t.onProgress)||n.call(t,{loaded:e.loaded,total:e.total})})),e.on("FetchBuiltInCMap",(e=>this.destroyed?Promise.reject(new Error("Worker was destroyed.")):this.cMapReaderFactory?this.cMapReaderFactory.fetch(e):Promise.reject(new Error("CMapReaderFactory not initialized, see the `useWorkerFetch` parameter.")))),e.on("FetchStandardFontData",(e=>this.destroyed?Promise.reject(new Error("Worker was destroyed.")):this.standardFontDataFactory?this.standardFontDataFactory.fetch(e):Promise.reject(new Error("StandardFontDataFactory not initialized, see the `useWorkerFetch` parameter."))))}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){var e,t;this.annotationStorage.size<=0&&(0,_util.warn)("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");let{map:n,transfers:i}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:n,filename:null!=(t=null==(e=this._fullReader)?void 0:e.filename)?t:null},i).finally((()=>{this.annotationStorage.resetModified()}))}getPage(e){if(!Number.isInteger(e)||e<=0||e>this._numPages)return Promise.reject(new Error("Invalid page request."));let t=e-1,n=le(this,p).get(t);if(n)return n;let i=this.messageHandler.sendWithPromise("GetPage",{pageIndex:t}).then((e=>{if(this.destroyed)throw new Error("Transport destroyed");let n=new PDFPageProxy(t,e,this,this._params.pdfBug);return le(this,f).set(t,n),n}));return le(this,p).set(t,i),i}getPageIndex(e){return"object"!=typeof e||null===e||!Number.isInteger(e.num)||e.num<0||!Number.isInteger(e.gen)||e.gen<0?Promise.reject(new Error("Invalid pageIndex request.")):this.messageHandler.sendWithPromise("GetPageIndex",{num:e.num,gen:e.gen})}getAnnotations(e,t){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:e,intent:t})}getFieldObjects(){return ft(this,g,J4).call(this,"GetFieldObjects")}hasJSActions(){return ft(this,g,J4).call(this,"HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(e){return"string"!=typeof e?Promise.reject(new Error("Invalid destination request.")):this.messageHandler.sendWithPromise("GetDestination",{id:e})}getPageLabels(){return this.messageHandler.sendWithPromise("GetPageLabels",null)}getPageLayout(){return this.messageHandler.sendWithPromise("GetPageLayout",null)}getPageMode(){return this.messageHandler.sendWithPromise("GetPageMode",null)}getViewerPreferences(){return this.messageHandler.sendWithPromise("GetViewerPreferences",null)}getOpenAction(){return this.messageHandler.sendWithPromise("GetOpenAction",null)}getAttachments(){return this.messageHandler.sendWithPromise("GetAttachments",null)}getJavaScript(){return this.messageHandler.sendWithPromise("GetJavaScript",null)}getDocJSActions(){return this.messageHandler.sendWithPromise("GetDocJSActions",null)}getPageJSActions(e){return this.messageHandler.sendWithPromise("GetPageJSActions",{pageIndex:e})}getStructTree(e){return this.messageHandler.sendWithPromise("GetStructTree",{pageIndex:e})}getOutline(){return this.messageHandler.sendWithPromise("GetOutline",null)}getOptionalContentConfig(){return this.messageHandler.sendWithPromise("GetOptionalContentConfig",null).then((e=>new _optional_content_config.OptionalContentConfig(e)))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){let e="GetMetadata",t=le(this,d).get(e);if(t)return t;let n=this.messageHandler.sendWithPromise(e,null).then((e=>{var t,n,i,r;return{info:e[0],metadata:e[1]?new _metadata.Metadata(e[1]):null,contentDispositionFilename:null!=(n=null==(t=this._fullReader)?void 0:t.filename)?n:null,contentLength:null!=(r=null==(i=this._fullReader)?void 0:i.contentLength)?r:null}}));return le(this,d).set(e,n),n}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}startCleanup(e=!1){return it(this,null,(function*(){if(!this.destroyed){yield this.messageHandler.sendWithPromise("Cleanup",null);for(let e of le(this,f).values())if(!e.cleanup())throw new Error(`startCleanup: Page ${e.pageNumber} is currently rendering.`);this.commonObjs.clear(),e||this.fontLoader.clear(),le(this,d).clear(),this.filterFactory.destroy(!0)}}))}get loadingParams(){let{disableAutoFetch:e,enableXfa:t}=this._params;return(0,_util.shadow)(this,"loadingParams",{disableAutoFetch:e,enableXfa:t})}}d=new WeakMap,f=new WeakMap,p=new WeakMap,g=new WeakSet,J4=function(e,t=null){let n=le(this,d).get(e);if(n)return n;let i=this.messageHandler.sendWithPromise(e,t);return le(this,d).set(e,i),i};class PDFObjects{constructor(){Je(this,E),Je(this,v,Object.create(null))}get(e,t=null){if(t){let n=ft(this,E,Q4).call(this,e);return n.capability.promise.then((()=>t(n.data))),null}let n=le(this,v)[e];if(null==n||!n.capability.settled)throw new Error(`Requesting object that isn't resolved yet ${e}.`);return n.data}has(e){let t=le(this,v)[e];return(null==t?void 0:t.capability.settled)||!1}resolve(e,t=null){let n=ft(this,E,Q4).call(this,e);n.data=t,n.capability.resolve()}clear(){var e;for(let t in le(this,v)){let{data:n}=le(this,v)[t];null==(e=null==n?void 0:n.bitmap)||e.close()}wt(this,v,Object.create(null))}}v=new WeakMap,E=new WeakSet,Q4=function(e){return le(this,v)[e]||(le(this,v)[e]={capability:new _util.PromiseCapability,data:null})};class RenderTask{constructor(e){Je(this,_,null),wt(this,_,e),this.onContinue=null}get promise(){return le(this,_).capability.promise}cancel(e=0){le(this,_).cancel(null,e)}get separateAnnots(){let{separateAnnots:e}=le(this,_).operatorList;if(!e)return!1;let{annotationCanvasMap:t}=le(this,_);return e.form||e.canvas&&(null==t?void 0:t.size)>0}}_=new WeakMap,exports.RenderTask=RenderTask;let M=class{constructor({callback:e,params:t,objs:n,commonObjs:i,annotationCanvasMap:r,operatorList:a,pageIndex:s,canvasFactory:o,filterFactory:l,useRequestAnimationFrame:h=!1,pdfBug:u=!1,pageColors:c=null}){this.callback=e,this.params=t,this.objs=n,this.commonObjs=i,this.annotationCanvasMap=r,this.operatorListIdx=null,this.operatorList=a,this._pageIndex=s,this.canvasFactory=o,this.filterFactory=l,this._pdfBug=u,this.pageColors=c,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=!0===h&&"undefined"!=typeof window,this.cancelled=!1,this.capability=new _util.PromiseCapability,this.task=new RenderTask(this),this._cancelBound=this.cancel.bind(this),this._continueBound=this._continue.bind(this),this._scheduleNextBound=this._scheduleNext.bind(this),this._nextBound=this._next.bind(this),this._canvas=t.canvasContext.canvas}get completed(){return this.capability.promise.catch((function(){}))}initializeGraphics({transparency:e=!1,optionalContentConfig:t}){var n,i;if(this.cancelled)return;if(this._canvas){if(le(M,C).has(this._canvas))throw new Error("Cannot use the same canvas during multiple render() operations. Use different canvas or ensure previous operations were cancelled or completed.");le(M,C).add(this._canvas)}this._pdfBug&&null!=(n=globalThis.StepperManager)&&n.enabled&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint());let{canvasContext:r,viewport:a,transform:s,background:o}=this.params;this.gfx=new _canvas.CanvasGraphics(r,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:t},this.annotationCanvasMap,this.pageColors),this.gfx.beginDrawing({transform:s,viewport:a,transparency:e,background:o}),this.operatorListIdx=0,this.graphicsReady=!0,null==(i=this.graphicsReadyCallback)||i.call(this)}cancel(e=null,t=0){var n;this.running=!1,this.cancelled=!0,null==(n=this.gfx)||n.endDrawing(),this._canvas&&le(M,C).delete(this._canvas),this.callback(e||new _display_utils.RenderingCancelledException(`Rendering cancelled, page ${this._pageIndex+1}`,t))}operatorListChanged(){var e;this.graphicsReady?(null==(e=this.stepper)||e.updateOperatorList(this.operatorList),!this.running&&this._continue()):this.graphicsReadyCallback||(this.graphicsReadyCallback=this._continueBound)}_continue(){this.running=!0,!this.cancelled&&(this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext())}_scheduleNext(){this._useRequestAnimationFrame?window.requestAnimationFrame((()=>{this._nextBound().catch(this._cancelBound)})):Promise.resolve().then(this._nextBound).catch(this._cancelBound)}_next(){return it(this,null,(function*(){this.cancelled||(this.operatorListIdx=this.gfx.executeOperatorList(this.operatorList,this.operatorListIdx,this._continueBound,this.stepper),this.operatorListIdx===this.operatorList.argsArray.length&&(this.running=!1,this.operatorList.lastChunk&&(this.gfx.endDrawing(this.pageColors),this._canvas&&le(M,C).delete(this._canvas),this.callback())))}))}},InternalRenderTask=M;C=new WeakMap,Je(InternalRenderTask,C,new WeakSet);let version="3.8.162";exports.version=version;let build="2c74323e3";exports.build=build},(e,t,n)=>{var i,r,a,s,o;Object.defineProperty(t,"__esModule",{value:!0}),t.SerializableEmpty=t.PrintAnnotationStorage=t.AnnotationStorage=void 0;var l=n(1),h=n(4),u=n(8);let c=Object.freeze({map:null,hash:"",transfers:void 0});t.SerializableEmpty=c;class d{constructor(){Je(this,a),Je(this,i,!1),Je(this,r,new Map),this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(e,t){let n=le(this,r).get(e);return void 0===n?t:Object.assign(t,n)}getRawValue(e){return le(this,r).get(e)}remove(e){if(le(this,r).delete(e),0===le(this,r).size&&this.resetModified(),"function"==typeof this.onAnnotationEditor){for(let e of le(this,r).values())if(e instanceof h.AnnotationEditor)return;this.onAnnotationEditor(null)}}setValue(e,t){let n=le(this,r).get(e),i=!1;if(void 0!==n)for(let[r,a]of Object.entries(t))n[r]!==a&&(i=!0,n[r]=a);else i=!0,le(this,r).set(e,t);i&&ft(this,a,s).call(this),t instanceof h.AnnotationEditor&&"function"==typeof this.onAnnotationEditor&&this.onAnnotationEditor(t.constructor._type)}has(e){return le(this,r).has(e)}getAll(){return le(this,r).size>0?(0,l.objectFromMap)(le(this,r)):null}setAll(e){for(let[t,n]of Object.entries(e))this.setValue(t,n)}get size(){return le(this,r).size}resetModified(){le(this,i)&&(wt(this,i,!1),"function"==typeof this.onResetModified&&this.onResetModified())}get print(){return new p(this)}get serializable(){if(0===le(this,r).size)return c;let e=new Map,t=new u.MurmurHash3_64,n=[];for(let[i,a]of le(this,r)){let r=a instanceof h.AnnotationEditor?a.serialize():a;r&&(e.set(i,r),t.update(`${i}:${JSON.stringify(r)}`),r.bitmap&&n.push(r.bitmap))}return e.size>0?{map:e,hash:t.hexdigest(),transfers:n}:c}}i=new WeakMap,r=new WeakMap,a=new WeakSet,s=function(){le(this,i)||(wt(this,i,!0),"function"==typeof this.onSetModified&&this.onSetModified())},t.AnnotationStorage=d;class p extends d{constructor(e){super(),Je(this,o,void 0);let{map:t,hash:n,transfers:i}=e.serializable,r=structuredClone(t,i?{transfer:i}:null);wt(this,o,{map:r,hash:n,transfers:i})}get print(){(0,l.unreachable)("Should not call PrintAnnotationStorage.print")}get serializable(){return le(this,o)}}o=new WeakMap,t.PrintAnnotationStorage=p},(e,t,n)=>{var i,r,a,s,o,l;Object.defineProperty(t,"__esModule",{value:!0}),t.AnnotationEditor=void 0;var h=n(5),u=n(1);let c=class{constructor(e){Je(this,i,this.focusin.bind(this)),Je(this,r,this.focusout.bind(this)),Je(this,a,!1),Je(this,s,!1),Je(this,o,!1),Yi(this,"_uiManager",null),Je(this,l,c._zIndex++),this.constructor===c&&(0,u.unreachable)("Cannot initialize AnnotationEditor."),this.parent=e.parent,this.id=e.id,this.width=this.height=null,this.pageIndex=e.parent.pageIndex,this.name=e.name,this.div=null,this._uiManager=e.uiManager,this.annotationElementId=null;let{rotation:t,rawDims:{pageWidth:n,pageHeight:h,pageX:d,pageY:p}}=this.parent.viewport;this.rotation=t,this.pageRotation=(360+t-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[n,h],this.pageTranslation=[d,p];let[f,m]=this.parentDimensions;this.x=e.x/f,this.y=e.y/m,this.isAttachedToDOM=!1,this.deleted=!1}static get _defaultLineColor(){return(0,u.shadow)(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(e){let t=new p({id:e.parent.getNextId(),parent:e.parent,uiManager:e._uiManager});t.annotationElementId=e.annotationElementId,t.deleted=!0,t._uiManager.addToAnnotationStorage(t)}addCommands(e){this._uiManager.addCommands(e)}get currentLayer(){return this._uiManager.currentLayer}setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=le(this,l)}setParent(e){null!==e&&(this.pageIndex=e.pageIndex,this.pageDimensions=e.pageDimensions),this.parent=e}focusin(e){le(this,a)?wt(this,a,!1):this.parent.setSelected(this)}focusout(e){var t;if(!this.isAttachedToDOM)return;let n=e.relatedTarget;null!=n&&n.closest(`#${this.id}`)||(e.preventDefault(),null!=(t=this.parent)&&t.isMultipleSelection||this.commitOrRemove())}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}dragstart(e){let t=this.parent.div.getBoundingClientRect();this.startX=e.clientX-t.x,this.startY=e.clientY-t.y,e.dataTransfer.setData("text/plain",this.id),e.dataTransfer.effectAllowed="move"}setAt(e,t,n,i){let[r,a]=this.parentDimensions;[n,i]=this.screenToPageTranslation(n,i),this.x=(e+n)/r,this.y=(t+i)/a,this.div.style.left=100*this.x+"%",this.div.style.top=100*this.y+"%"}translate(e,t){let[n,i]=this.parentDimensions;[e,t]=this.screenToPageTranslation(e,t),this.x+=e/n,this.y+=t/i,this.div.style.left=100*this.x+"%",this.div.style.top=100*this.y+"%"}screenToPageTranslation(e,t){switch(this.parentRotation){case 90:return[t,-e];case 180:return[-e,-t];case 270:return[-t,e];default:return[e,t]}}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){let{realScale:e}=this._uiManager.viewParameters,[t,n]=this.pageDimensions;return[t*e,n*e]}setDims(e,t){let[n,i]=this.parentDimensions;this.div.style.width=100*e/n+"%",this.div.style.height=100*t/i+"%"}fixDims(){let{style:e}=this.div,{height:t,width:n}=e,i=n.endsWith("%"),r=t.endsWith("%");if(i&&r)return;let[a,s]=this.parentDimensions;i||(e.width=100*parseFloat(n)/a+"%"),r||(e.height=100*parseFloat(t)/s+"%")}getInitialTranslation(){return[0,0]}render(){this.div=document.createElement("div"),this.div.setAttribute("data-editor-rotation",(360-this.rotation)%360),this.div.className=this.name,this.div.setAttribute("id",this.id),this.div.setAttribute("tabIndex",0),this.setInForeground(),this.div.addEventListener("focusin",le(this,i)),this.div.addEventListener("focusout",le(this,r));let[e,t]=this.getInitialTranslation();return this.translate(e,t),(0,h.bindEvents)(this,this.div,["dragstart","pointerdown"]),this.div}pointerdown(e){let{isMac:t}=u.FeatureTest.platform;0!==e.button||e.ctrlKey&&t?e.preventDefault():(e.ctrlKey&&!t||e.shiftKey||e.metaKey&&t?this.parent.toggleSelected(this):this.parent.setSelected(this),wt(this,a,!0))}getRect(e,t){let n=this.parentScale,[i,r]=this.pageDimensions,[a,s]=this.pageTranslation,o=e/n,l=t/n,h=this.x*i,u=this.y*r,c=this.width*i,d=this.height*r;switch(this.rotation){case 0:return[h+o+a,r-u-l-d+s,h+o+c+a,r-u-l+s];case 90:return[h+l+a,r-u+o+s,h+l+d+a,r-u+o+c+s];case 180:return[h-o-c+a,r-u+l+s,h-o+a,r-u+l+d+s];case 270:return[h-l-d+a,r-u-o-c+s,h-l+a,r-u-o+s];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(e,t){let[n,i,r,a]=e,s=r-n,o=a-i;switch(this.rotation){case 0:return[n,t-a,s,o];case 90:return[n,t-i,o,s];case 180:return[r,t-i,s,o];case 270:return[r,t-a,o,s];default:throw new Error("Invalid rotation")}}onceAdded(){}isEmpty(){return!1}enableEditMode(){wt(this,o,!0)}disableEditMode(){wt(this,o,!1)}isInEditMode(){return le(this,o)}shouldGetKeyboardEvents(){return!1}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}rebuild(){var e,t;null==(e=this.div)||e.addEventListener("focusin",le(this,i)),null==(t=this.div)||t.addEventListener("focusout",le(this,r))}serialize(e=!1){(0,u.unreachable)("An editor must be serializable")}static deserialize(e,t,n){let i=new this.prototype.constructor({parent:t,id:t.getNextId(),uiManager:n});i.rotation=e.rotation;let[r,a]=i.pageDimensions,[s,o,l,h]=i.getRectInCurrentCoords(e.rect,a);return i.x=s/r,i.y=o/a,i.width=l/r,i.height=h/a,i}remove(){this.div.removeEventListener("focusin",le(this,i)),this.div.removeEventListener("focusout",le(this,r)),this.isEmpty()||this.commit(),this.parent.remove(this)}select(){var e;null==(e=this.div)||e.classList.add("selectedEditor")}unselect(){var e;null==(e=this.div)||e.classList.remove("selectedEditor")}updateParams(e,t){}disableEditing(){}enableEditing(){}get propertiesToUpdate(){return{}}get contentDiv(){return this.div}get isEditing(){return le(this,s)}set isEditing(e){wt(this,s,e),e?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null)}},d=c;i=new WeakMap,r=new WeakMap,a=new WeakMap,s=new WeakMap,o=new WeakMap,l=new WeakMap,Yi(d,"_colorManager",new h.ColorManager),Yi(d,"_zIndex",1),t.AnnotationEditor=d;class p extends d{constructor(e){super(e),this.annotationElementId=e.annotationElementId,this.deleted=!0}serialize(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex}}}},(e,t,n)=>{var i,r,a,s,o,l,h,u,c,d,p,f,m,g,v,y,x,b,_,w,S,M,E,T,A,C,P,R,L,I,k,O,D,N,U,F,B,z,H,V,j,G,W,X,Y,q,J,Z,K,$,Q,ee,te;Object.defineProperty(t,"__esModule",{value:!0}),t.KeyboardManager=t.CommandManager=t.ColorManager=t.AnnotationEditorUIManager=void 0,t.bindEvents=function(e,t,n){for(let i of n)t.addEventListener(i,e[i].bind(e))},t.opacityToHex=function(e){return Math.round(Math.min(255,Math.max(1,255*e))).toString(16).padStart(2,"0")};var ne=n(1),ie=n(6);class re{constructor(){Je(this,i,0)}getId(){return`${ne.AnnotationEditorPrefix}${ET(this,i)._++}`}}i=new WeakMap;class ae{constructor(e=128){Je(this,r,[]),Je(this,a,!1),Je(this,s,void 0),Je(this,o,-1),wt(this,s,e)}add({cmd:e,undo:t,mustExec:n,type:i=NaN,overwriteIfSameType:l=!1,keepUndo:h=!1}){if(n&&e(),le(this,a))return;let u={cmd:e,undo:t,type:i};if(-1===le(this,o))return le(this,r).length>0&&(le(this,r).length=0),wt(this,o,0),void le(this,r).push(u);if(l&&le(this,r)[le(this,o)].type===i)return h&&(u.undo=le(this,r)[le(this,o)].undo),void(le(this,r)[le(this,o)]=u);let c=le(this,o)+1;c===le(this,s)?le(this,r).splice(0,1):(wt(this,o,c),c<le(this,r).length&&le(this,r).splice(c)),le(this,r).push(u)}undo(){-1!==le(this,o)&&(wt(this,a,!0),le(this,r)[le(this,o)].undo(),wt(this,a,!1),wt(this,o,le(this,o)-1))}redo(){le(this,o)<le(this,r).length-1&&(wt(this,o,le(this,o)+1),wt(this,a,!0),le(this,r)[le(this,o)].cmd(),wt(this,a,!1))}hasSomethingToUndo(){return-1!==le(this,o)}hasSomethingToRedo(){return le(this,o)<le(this,r).length-1}destroy(){wt(this,r,null)}}r=new WeakMap,a=new WeakMap,s=new WeakMap,o=new WeakMap,t.CommandManager=ae;class se{constructor(e){Je(this,l),this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;let{isMac:t}=ne.FeatureTest.platform;for(let[n,i,r=!1]of e)for(let e of n){let n=e.startsWith("mac+");t&&n?(this.callbacks.set(e.slice(4),{callback:i,bubbles:r}),this.allKeys.add(e.split("+").at(-1))):!t&&!n&&(this.callbacks.set(e,{callback:i,bubbles:r}),this.allKeys.add(e.split("+").at(-1)))}}exec(e,t){if(!this.allKeys.has(t.key))return;let n=this.callbacks.get(ft(this,l,h).call(this,t));if(!n)return;let{callback:i,bubbles:r}=n;i.bind(e)(),r||(t.stopPropagation(),t.preventDefault())}}l=new WeakSet,h=function(e){e.altKey&&this.buffer.push("alt"),e.ctrlKey&&this.buffer.push("ctrl"),e.metaKey&&this.buffer.push("meta"),e.shiftKey&&this.buffer.push("shift"),this.buffer.push(e.key);let t=this.buffer.join("+");return this.buffer.length=0,t},t.KeyboardManager=se;let oe=class{get _colors(){let e=new Map([["CanvasText",null],["Canvas",null]]);return(0,ie.getColorValues)(e),(0,ne.shadow)(this,"_colors",e)}convert(e){let t=(0,ie.getRGB)(e);if(!window.matchMedia("(forced-colors: active)").matches)return t;for(let[n,i]of this._colors)if(i.every(((e,n)=>e===t[n])))return oe._colorsMapping.get(n);return t}getHexCode(e){let t=this._colors.get(e);return t?ne.Util.makeHexColor(...t):e}},he=oe;Yi(he,"_colorsMapping",new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]])),t.ColorManager=he;let ue=class{constructor(e,t,n){Je(this,O),Je(this,N),Je(this,F),Je(this,z),Je(this,V),Je(this,G),Je(this,X),Je(this,q),Je(this,Z),Je(this,$),Je(this,ee),Je(this,u,null),Je(this,c,new Map),Je(this,d,new Map),Je(this,p,null),Je(this,f,new ae),Je(this,m,0),Je(this,g,new Set),Je(this,v,null),Je(this,y,new Set),Je(this,x,null),Je(this,b,new re),Je(this,_,!1),Je(this,w,ne.AnnotationEditorType.NONE),Je(this,S,new Set),Je(this,M,this.copy.bind(this)),Je(this,E,this.cut.bind(this)),Je(this,T,this.paste.bind(this)),Je(this,A,this.keydown.bind(this)),Je(this,C,this.onEditingAction.bind(this)),Je(this,P,this.onPageChanging.bind(this)),Je(this,R,this.onScaleChanging.bind(this)),Je(this,L,this.onRotationChanging.bind(this)),Je(this,I,{isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1}),Je(this,k,null),wt(this,k,e),wt(this,x,t),le(this,x)._on("editingaction",le(this,C)),le(this,x)._on("pagechanging",le(this,P)),le(this,x)._on("scalechanging",le(this,R)),le(this,x)._on("rotationchanging",le(this,L)),wt(this,p,n),this.viewParameters={realScale:ie.PixelsPerInch.PDF_TO_CSS_UNITS,rotation:0}}static get _keyboardManager(){return(0,ne.shadow)(this,"_keyboardManager",new se([[["ctrl+a","mac+meta+a"],ue.prototype.selectAll],[["ctrl+z","mac+meta+z"],ue.prototype.undo],[["ctrl+y","ctrl+shift+Z","mac+meta+shift+Z"],ue.prototype.redo],[["Backspace","alt+Backspace","ctrl+Backspace","shift+Backspace","mac+Backspace","mac+alt+Backspace","mac+ctrl+Backspace","Delete","ctrl+Delete","shift+Delete"],ue.prototype.delete],[["Escape","mac+Escape"],ue.prototype.unselectAll]]))}destroy(){ft(this,N,U).call(this),le(this,x)._off("editingaction",le(this,C)),le(this,x)._off("pagechanging",le(this,P)),le(this,x)._off("scalechanging",le(this,R)),le(this,x)._off("rotationchanging",le(this,L));for(let e of le(this,d).values())e.destroy();le(this,d).clear(),le(this,c).clear(),le(this,y).clear(),wt(this,u,null),le(this,S).clear(),le(this,f).destroy()}onPageChanging({pageNumber:e}){wt(this,m,e-1)}focusMainContainer(){le(this,k).focus()}addShouldRescale(e){le(this,y).add(e)}removeShouldRescale(e){le(this,y).delete(e)}onScaleChanging({scale:e}){this.commitOrRemove(),this.viewParameters.realScale=e*ie.PixelsPerInch.PDF_TO_CSS_UNITS;for(let t of le(this,y))t.onScaleChanging()}onRotationChanging({pagesRotation:e}){this.commitOrRemove(),this.viewParameters.rotation=e}addToAnnotationStorage(e){!e.isEmpty()&&le(this,p)&&!le(this,p).has(e.id)&&le(this,p).setValue(e.id,e)}copy(e){if(e.preventDefault(),le(this,u)&&le(this,u).commitOrRemove(),!this.hasSelection)return;let t=[];for(let n of le(this,S)){let e=n.serialize(!0);e&&t.push(e)}0!==t.length&&e.clipboardData.setData("application/pdfjs",JSON.stringify(t))}cut(e){this.copy(e),this.delete()}paste(e){e.preventDefault();let t=e.clipboardData.getData("application/pdfjs");if(!t)return;try{t=JSON.parse(t)}catch(e){return void(0,ne.warn)(`paste: "${e.message}".`)}if(!Array.isArray(t))return;this.unselectAll();let n=le(this,d).get(le(this,m));try{let e=[];for(let a of t){let t=n.deserialize(a);if(!t)return;e.push(t)}let i=()=>{for(let t of e)ft(this,Z,K).call(this,t);ft(this,ee,te).call(this,e)},r=()=>{for(let t of e)t.remove()};this.addCommands({cmd:i,undo:r,mustExec:!0})}catch(e){(0,ne.warn)(`paste: "${e.message}".`)}}keydown(e){var t;null!=(t=this.getActive())&&t.shouldGetKeyboardEvents()||ue._keyboardManager.exec(this,e)}onEditingAction(e){["undo","redo","delete","selectAll"].includes(e.name)&&this[e.name]()}setEditingState(e){e?(ft(this,O,D).call(this),ft(this,F,B).call(this),ft(this,V,j).call(this,{isEditing:le(this,w)!==ne.AnnotationEditorType.NONE,isEmpty:ft(this,$,Q).call(this),hasSomethingToUndo:le(this,f).hasSomethingToUndo(),hasSomethingToRedo:le(this,f).hasSomethingToRedo(),hasSelectedEditor:!1})):(ft(this,N,U).call(this),ft(this,z,H).call(this),ft(this,V,j).call(this,{isEditing:!1}))}registerEditorTypes(e){if(!le(this,v)){wt(this,v,e);for(let e of le(this,v))ft(this,G,W).call(this,e.defaultPropertiesToUpdate)}}getId(){return le(this,b).getId()}get currentLayer(){return le(this,d).get(le(this,m))}get currentPageIndex(){return le(this,m)}addLayer(e){le(this,d).set(e.pageIndex,e),le(this,_)?e.enable():e.disable()}removeLayer(e){le(this,d).delete(e.pageIndex)}updateMode(e){if(wt(this,w,e),e===ne.AnnotationEditorType.NONE)this.setEditingState(!1),ft(this,q,J).call(this);else{this.setEditingState(!0),ft(this,X,Y).call(this);for(let t of le(this,d).values())t.updateMode(e)}}updateToolbar(e){e!==le(this,w)&&le(this,x).dispatch("switchannotationeditormode",{source:this,mode:e})}updateParams(e,t){if(le(this,v)){for(let n of le(this,S))n.updateParams(e,t);for(let n of le(this,v))n.updateDefaultParams(e,t)}}getEditors(e){let t=[];for(let n of le(this,c).values())n.pageIndex===e&&t.push(n);return t}getEditor(e){return le(this,c).get(e)}addEditor(e){le(this,c).set(e.id,e)}removeEditor(e){var t;le(this,c).delete(e.id),this.unselect(e),(!e.annotationElementId||!le(this,g).has(e.annotationElementId))&&(null==(t=le(this,p))||t.remove(e.id))}addDeletedAnnotationElement(e){le(this,g).add(e.annotationElementId),e.deleted=!0}isDeletedAnnotationElement(e){return le(this,g).has(e)}removeDeletedAnnotationElement(e){le(this,g).delete(e.annotationElementId),e.deleted=!1}setActiveEditor(e){le(this,u)!==e&&(wt(this,u,e),e&&ft(this,G,W).call(this,e.propertiesToUpdate))}toggleSelected(e){if(le(this,S).has(e))return le(this,S).delete(e),e.unselect(),void ft(this,V,j).call(this,{hasSelectedEditor:this.hasSelection});le(this,S).add(e),e.select(),ft(this,G,W).call(this,e.propertiesToUpdate),ft(this,V,j).call(this,{hasSelectedEditor:!0})}setSelected(e){for(let t of le(this,S))t!==e&&t.unselect();le(this,S).clear(),le(this,S).add(e),e.select(),ft(this,G,W).call(this,e.propertiesToUpdate),ft(this,V,j).call(this,{hasSelectedEditor:!0})}isSelected(e){return le(this,S).has(e)}unselect(e){e.unselect(),le(this,S).delete(e),ft(this,V,j).call(this,{hasSelectedEditor:this.hasSelection})}get hasSelection(){return 0!==le(this,S).size}undo(){le(this,f).undo(),ft(this,V,j).call(this,{hasSomethingToUndo:le(this,f).hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:ft(this,$,Q).call(this)})}redo(){le(this,f).redo(),ft(this,V,j).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:le(this,f).hasSomethingToRedo(),isEmpty:ft(this,$,Q).call(this)})}addCommands(e){le(this,f).add(e),ft(this,V,j).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:ft(this,$,Q).call(this)})}delete(){if(this.commitOrRemove(),!this.hasSelection)return;let e=[...le(this,S)];this.addCommands({cmd:()=>{for(let t of e)t.remove()},undo:()=>{for(let t of e)ft(this,Z,K).call(this,t)},mustExec:!0})}commitOrRemove(){var e;null==(e=le(this,u))||e.commitOrRemove()}selectAll(){for(let e of le(this,S))e.commit();ft(this,ee,te).call(this,le(this,c).values())}unselectAll(){if(le(this,u))le(this,u).commitOrRemove();else if(0!==le(this,S).size){for(let e of le(this,S))e.unselect();le(this,S).clear(),ft(this,V,j).call(this,{hasSelectedEditor:!1})}}isActive(e){return le(this,u)===e}getActive(){return le(this,u)}getMode(){return le(this,w)}},ce=ue;u=new WeakMap,c=new WeakMap,d=new WeakMap,p=new WeakMap,f=new WeakMap,m=new WeakMap,g=new WeakMap,v=new WeakMap,y=new WeakMap,x=new WeakMap,b=new WeakMap,_=new WeakMap,w=new WeakMap,S=new WeakMap,M=new WeakMap,E=new WeakMap,T=new WeakMap,A=new WeakMap,C=new WeakMap,P=new WeakMap,R=new WeakMap,L=new WeakMap,I=new WeakMap,k=new WeakMap,O=new WeakSet,D=function(){le(this,k).addEventListener("keydown",le(this,A))},N=new WeakSet,U=function(){le(this,k).removeEventListener("keydown",le(this,A))},F=new WeakSet,B=function(){document.addEventListener("copy",le(this,M)),document.addEventListener("cut",le(this,E)),document.addEventListener("paste",le(this,T))},z=new WeakSet,H=function(){document.removeEventListener("copy",le(this,M)),document.removeEventListener("cut",le(this,E)),document.removeEventListener("paste",le(this,T))},V=new WeakSet,j=function(e){Object.entries(e).some((([e,t])=>le(this,I)[e]!==t))&&le(this,x).dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(le(this,I),e)})},G=new WeakSet,W=function(e){le(this,x).dispatch("annotationeditorparamschanged",{source:this,details:e})},X=new WeakSet,Y=function(){if(!le(this,_)){wt(this,_,!0);for(let e of le(this,d).values())e.enable()}},q=new WeakSet,J=function(){if(this.unselectAll(),le(this,_)){wt(this,_,!1);for(let e of le(this,d).values())e.disable()}},Z=new WeakSet,K=function(e){let t=le(this,d).get(e.pageIndex);t?t.addOrRebuild(e):this.addEditor(e)},$=new WeakSet,Q=function(){if(0===le(this,c).size)return!0;if(1===le(this,c).size)for(let e of le(this,c).values())return e.isEmpty();return!1},ee=new WeakSet,te=function(e){le(this,S).clear();for(let t of e)t.isEmpty()||(le(this,S).add(t),t.select());ft(this,V,j).call(this,{hasSelectedEditor:!0})},t.AnnotationEditorUIManager=ce},(e,t,n)=>{var i,r,a,s,o,l,h,u,c,d,p,f,m,g,v,y,x,b,_,w,S,M,E,T,A;Object.defineProperty(t,"__esModule",{value:!0}),t.StatTimer=t.RenderingCancelledException=t.PixelsPerInch=t.PageViewport=t.PDFDateString=t.DOMStandardFontDataFactory=t.DOMSVGFactory=t.DOMFilterFactory=t.DOMCanvasFactory=t.DOMCMapReaderFactory=t.AnnotationPrefix=void 0,t.deprecated=function(e){console.log("Deprecated API usage: "+e)},t.getColorValues=function(e){let t=document.createElement("span");t.style.visibility="hidden",document.body.append(t);for(let n of e.keys()){t.style.color=n;let i=window.getComputedStyle(t).color;e.set(n,G(i))}t.remove()},t.getCurrentTransform=function(e){let{a:t,b:n,c:i,d:r,e:a,f:s}=e.getTransform();return[t,n,i,r,a,s]},t.getCurrentTransformInverse=function(e){let{a:t,b:n,c:i,d:r,e:a,f:s}=e.getTransform().invertSelf();return[t,n,i,r,a,s]},t.getFilenameFromUrl=function(e,t=!1){return t||([e]=e.split(/[#?]/,1)),e.substring(e.lastIndexOf("/")+1)},t.getPdfFilenameFromUrl=function(e,t="document.pdf"){if("string"!=typeof e)return t;if(V(e))return(0,P.warn)('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),t;let n=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i,i=/^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/.exec(e),r=n.exec(i[1])||n.exec(i[2])||n.exec(i[3]);if(r&&(r=r[0],r.includes("%")))try{r=n.exec(decodeURIComponent(r))[0]}catch(e){}return r||t},t.getRGB=G,t.getXfaPageViewport=function(e,{scale:t=1,rotation:n=0}){let{width:i,height:r}=e.attributes.style,a=[0,0,parseInt(i),parseInt(r)];return new z({viewBox:a,scale:t,rotation:n})},t.isDataScheme=V,t.isPdfFile=function(e){return"string"==typeof e&&/\.pdf$/i.test(e)},t.isValidFetchUrl=j,t.loadScript=function(e,t=!1){return new Promise(((n,i)=>{let r=document.createElement("script");r.src=e,r.onload=function(e){t&&r.remove(),n(e)},r.onerror=function(){i(new Error(`Cannot load script at: ${r.src}`))},(document.head||document.documentElement).append(r)}))},t.setLayerDimensions=function(e,t,n=!1,i=!0){if(t instanceof z){let{pageWidth:i,pageHeight:r}=t.rawDims,{style:a}=e,s=`calc(var(--scale-factor) * ${i}px)`,o=`calc(var(--scale-factor) * ${r}px)`;n&&t.rotation%180!=0?(a.width=o,a.height=s):(a.width=s,a.height=o)}i&&e.setAttribute("data-main-rotation",t.rotation)};var C=n(7),P=n(1);let R="http://www.w3.org/2000/svg";t.AnnotationPrefix="pdfjs_internal_id_";let L,I=class{},k=I;Yi(k,"CSS",96),Yi(k,"PDF",72),Yi(k,"PDF_TO_CSS_UNITS",I.CSS/I.PDF),t.PixelsPerInch=k;class O extends C.BaseFilterFactory{constructor({docId:e,ownerDocument:t=globalThis.document}={}){super(),Je(this,f),Je(this,g),Je(this,y),Je(this,b),Je(this,w),Je(this,M),Je(this,T),Je(this,i,void 0),Je(this,r,void 0),Je(this,a,void 0),Je(this,s,void 0),Je(this,o,void 0),Je(this,l,void 0),Je(this,h,void 0),Je(this,u,void 0),Je(this,c,void 0),Je(this,d,void 0),Je(this,p,0),wt(this,a,e),wt(this,s,t)}addFilter(e){if(!e)return"none";let t,n,i,r,s=le(this,f,m).get(e);if(s)return s;if(1===e.length){let a=e[0],s=new Array(256);for(let e=0;e<256;e++)s[e]=a[e]/255;r=t=n=i=s.join(",")}else{let[a,s,o]=e,l=new Array(256),h=new Array(256),u=new Array(256);for(let e=0;e<256;e++)l[e]=a[e]/255,h[e]=s[e]/255,u[e]=o[e]/255;t=l.join(","),n=h.join(","),i=u.join(","),r=`${t}${n}${i}`}if(s=le(this,f,m).get(r),s)return le(this,f,m).set(e,s),s;let o=`g_${le(this,a)}_transfer_map_${ET(this,p)._++}`,l=`url(#${o})`;le(this,f,m).set(e,l),le(this,f,m).set(r,l);let h=ft(this,b,_).call(this,o);return ft(this,M,E).call(this,t,n,i,h),l}addHCMFilter(e,t){var n;let i=`${e}-${t}`;if(le(this,l)===i)return le(this,h);if(wt(this,l,i),wt(this,h,"none"),null==(n=le(this,o))||n.remove(),!e||!t)return le(this,h);let r=ft(this,T,A).call(this,e);e=P.Util.makeHexColor(...r);let s=ft(this,T,A).call(this,t);if(t=P.Util.makeHexColor(...s),le(this,g,v).style.color="","#000000"===e&&"#ffffff"===t||e===t)return le(this,h);let c=new Array(256);for(let a=0;a<=255;a++){let e=a/255;c[a]=e<=.03928?e/12.92:gg((e+.055)/1.055,2.4)}let d=c.join(","),p=`g_${le(this,a)}_hcm_filter`,f=wt(this,u,ft(this,b,_).call(this,p));ft(this,M,E).call(this,d,d,d,f),ft(this,y,x).call(this,f);let m=(e,t)=>{let n=r[e]/255,i=s[e]/255,a=new Array(t+1);for(let r=0;r<=t;r++)a[r]=n+r/t*(i-n);return a.join(",")};return ft(this,M,E).call(this,m(0,5),m(1,5),m(2,5),f),wt(this,h,`url(#${p})`),le(this,h)}addHighlightHCMFilter(e,t,n,i){var r;let s=`${e}-${t}-${n}-${i}`;if(le(this,c)===s)return le(this,d);if(wt(this,c,s),wt(this,d,"none"),null==(r=le(this,u))||r.remove(),!e||!t)return le(this,d);let[o,l]=[e,t].map(ft(this,T,A).bind(this)),h=Math.round(.2126*o[0]+.7152*o[1]+.0722*o[2]),p=Math.round(.2126*l[0]+.7152*l[1]+.0722*l[2]),[f,m]=[n,i].map(ft(this,T,A).bind(this));p<h&&([h,p,f,m]=[p,h,m,f]),le(this,g,v).style.color="";let w=(e,t,n)=>{let i=new Array(256),r=(p-h)/n,a=e/255,s=(t-e)/(255*n),o=0;for(let l=0;l<=n;l++){let e=Math.round(h+l*r),t=a+l*s;for(let n=o;n<=e;n++)i[n]=t;o=e+1}for(let l=o;l<256;l++)i[l]=i[o-1];return i.join(",")},S=`g_${le(this,a)}_hcm_highlight_filter`,C=wt(this,u,ft(this,b,_).call(this,S));return ft(this,y,x).call(this,C),ft(this,M,E).call(this,w(f[0],m[0],5),w(f[1],m[1],5),w(f[2],m[2],5),C),wt(this,d,`url(#${S})`),le(this,d)}destroy(e=!1){e&&(le(this,h)||le(this,d))||(le(this,r)&&(le(this,r).parentNode.parentNode.remove(),wt(this,r,null)),le(this,i)&&(le(this,i).clear(),wt(this,i,null)),wt(this,p,0))}}i=new WeakMap,r=new WeakMap,a=new WeakMap,s=new WeakMap,o=new WeakMap,l=new WeakMap,h=new WeakMap,u=new WeakMap,c=new WeakMap,d=new WeakMap,p=new WeakMap,f=new WeakSet,m=function(){return le(this,i)||wt(this,i,new Map)},g=new WeakSet,v=function(){if(!le(this,r)){let e=le(this,s).createElement("div"),{style:t}=e;t.visibility="hidden",t.contain="strict",t.width=t.height=0,t.position="absolute",t.top=t.left=0,t.zIndex=-1;let n=le(this,s).createElementNS(R,"svg");n.setAttribute("width",0),n.setAttribute("height",0),wt(this,r,le(this,s).createElementNS(R,"defs")),e.append(n),n.append(le(this,r)),le(this,s).body.append(e)}return le(this,r)},y=new WeakSet,x=function(e){let t=le(this,s).createElementNS(R,"feColorMatrix");t.setAttribute("type","matrix"),t.setAttribute("values","0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0 0 0 1 0"),e.append(t)},b=new WeakSet,_=function(e){let t=le(this,s).createElementNS(R,"filter");return t.setAttribute("color-interpolation-filters","sRGB"),t.setAttribute("id",e),le(this,g,v).append(t),t},w=new WeakSet,S=function(e,t,n){let i=le(this,s).createElementNS(R,t);i.setAttribute("type","discrete"),i.setAttribute("tableValues",n),e.append(i)},M=new WeakSet,E=function(e,t,n,i){let r=le(this,s).createElementNS(R,"feComponentTransfer");i.append(r),ft(this,w,S).call(this,r,"feFuncR",e),ft(this,w,S).call(this,r,"feFuncG",t),ft(this,w,S).call(this,r,"feFuncB",n)},T=new WeakSet,A=function(e){return le(this,g,v).style.color=e,G(getComputedStyle(le(this,g,v)).getPropertyValue("color"))},t.DOMFilterFactory=O;class D extends C.BaseCanvasFactory{constructor({ownerDocument:e=globalThis.document}={}){super(),this._document=e}_createCanvas(e,t){let n=this._document.createElement("canvas");return n.width=e,n.height=t,n}}function N(e,t=!1){return it(this,null,(function*(){if(j(e,document.baseURI)){let n=yield fetch(e);if(!n.ok)throw new Error(n.statusText);return t?new Uint8Array(yield n.arrayBuffer()):(0,P.stringToBytes)(yield n.text())}return new Promise(((n,i)=>{let r=new XMLHttpRequest;r.open("GET",e,!0),t&&(r.responseType="arraybuffer"),r.onreadystatechange=()=>{if(r.readyState===XMLHttpRequest.DONE){if(200===r.status||0===r.status){let e;if(t&&r.response?e=new Uint8Array(r.response):!t&&r.responseText&&(e=(0,P.stringToBytes)(r.responseText)),e)return void n(e)}i(new Error(r.statusText))}},r.send(null)}))}))}t.DOMCanvasFactory=D;class U extends C.BaseCMapReaderFactory{_fetchData(e,t){return N(e,this.isCompressed).then((e=>({cMapData:e,compressionType:t})))}}t.DOMCMapReaderFactory=U;class F extends C.BaseStandardFontDataFactory{_fetchData(e){return N(e,!0)}}t.DOMStandardFontDataFactory=F;class B extends C.BaseSVGFactory{_createSVG(e){return document.createElementNS(R,e)}}t.DOMSVGFactory=B;class z{constructor({viewBox:e,scale:t,rotation:n,offsetX:i=0,offsetY:r=0,dontFlip:a=!1}){this.viewBox=e,this.scale=t,this.rotation=n,this.offsetX=i,this.offsetY=r;let s,o,l,h,u,c,d,p,f=(e[2]+e[0])/2,m=(e[3]+e[1])/2;switch((n%=360)<0&&(n+=360),n){case 180:s=-1,o=0,l=0,h=1;break;case 90:s=0,o=1,l=1,h=0;break;case 270:s=0,o=-1,l=-1,h=0;break;case 0:s=1,o=0,l=0,h=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}a&&(l=-l,h=-h),0===s?(u=Math.abs(m-e[1])*t+i,c=Math.abs(f-e[0])*t+r,d=(e[3]-e[1])*t,p=(e[2]-e[0])*t):(u=Math.abs(f-e[0])*t+i,c=Math.abs(m-e[1])*t+r,d=(e[2]-e[0])*t,p=(e[3]-e[1])*t),this.transform=[s*t,o*t,l*t,h*t,u-s*t*f-l*t*m,c-o*t*f-h*t*m],this.width=d,this.height=p}get rawDims(){let{viewBox:e}=this;return(0,P.shadow)(this,"rawDims",{pageWidth:e[2]-e[0],pageHeight:e[3]-e[1],pageX:e[0],pageY:e[1]})}clone({scale:e=this.scale,rotation:t=this.rotation,offsetX:n=this.offsetX,offsetY:i=this.offsetY,dontFlip:r=!1}={}){return new z({viewBox:this.viewBox.slice(),scale:e,rotation:t,offsetX:n,offsetY:i,dontFlip:r})}convertToViewportPoint(e,t){return P.Util.applyTransform([e,t],this.transform)}convertToViewportRectangle(e){let t=P.Util.applyTransform([e[0],e[1]],this.transform),n=P.Util.applyTransform([e[2],e[3]],this.transform);return[t[0],t[1],n[0],n[1]]}convertToPdfPoint(e,t){return P.Util.applyInverseTransform([e,t],this.transform)}}t.PageViewport=z;class H extends P.BaseException{constructor(e,t=0){super(e,"RenderingCancelledException"),this.extraDelay=t}}function V(e){let t=e.length,n=0;for(;n<t&&""===e[n].trim();)n++;return"data:"===e.substring(n,n+5).toLowerCase()}function j(e,t){try{let{protocol:n}=t?new URL(e,t):new URL(e);return"http:"===n||"https:"===n}catch(e){return!1}}function G(e){if(e.startsWith("#")){let t=parseInt(e.slice(1),16);return[(16711680&t)>>16,(65280&t)>>8,255&t]}return e.startsWith("rgb(")?e.slice(4,-1).split(",").map((e=>parseInt(e))):e.startsWith("rgba(")?e.slice(5,-1).split(",").map((e=>parseInt(e))).slice(0,3):((0,P.warn)(`Not a valid color format: "${e}"`),[0,0,0])}t.RenderingCancelledException=H,t.StatTimer=class{constructor(){Yi(this,"started",Object.create(null)),Yi(this,"times",[])}time(e){e in this.started&&(0,P.warn)(`Timer is already running for ${e}`),this.started[e]=Date.now()}timeEnd(e){e in this.started||(0,P.warn)(`Timer has not been started for ${e}`),this.times.push({name:e,start:this.started[e],end:Date.now()}),delete this.started[e]}toString(){let e=[],t=0;for(let{name:n}of this.times)t=Math.max(n.length,t);for(let{name:n,start:i,end:r}of this.times)e.push(`${n.padEnd(t)} ${r-i}ms\n`);return e.join("")}},t.PDFDateString=class{static toDateObject(e){if(!e||"string"!=typeof e)return null;L||(L=new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?"));let t=L.exec(e);if(!t)return null;let n=parseInt(t[1],10),i=parseInt(t[2],10);i=i>=1&&i<=12?i-1:0;let r=parseInt(t[3],10);r=r>=1&&r<=31?r:1;let a=parseInt(t[4],10);a=a>=0&&a<=23?a:0;let s=parseInt(t[5],10);s=s>=0&&s<=59?s:0;let o=parseInt(t[6],10);o=o>=0&&o<=59?o:0;let l=t[7]||"Z",h=parseInt(t[8],10);h=h>=0&&h<=23?h:0;let u=parseInt(t[9],10)||0;return u=u>=0&&u<=59?u:0,"-"===l?(a+=h,s+=u):"+"===l&&(a-=h,s-=u),new Date(Date.UTC(n,i,r,a,s,o))}}},(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BaseStandardFontDataFactory=t.BaseSVGFactory=t.BaseFilterFactory=t.BaseCanvasFactory=t.BaseCMapReaderFactory=void 0;var i=n(1);class r{constructor(){this.constructor===r&&(0,i.unreachable)("Cannot initialize BaseFilterFactory.")}addFilter(e){return"none"}addHCMFilter(e,t){return"none"}addHighlightHCMFilter(e,t,n,i){return"none"}destroy(e=!1){}}t.BaseFilterFactory=r;class a{constructor(){this.constructor===a&&(0,i.unreachable)("Cannot initialize BaseCanvasFactory.")}create(e,t){if(e<=0||t<=0)throw new Error("Invalid canvas size");let n=this._createCanvas(e,t);return{canvas:n,context:n.getContext("2d")}}reset(e,t,n){if(!e.canvas)throw new Error("Canvas is not specified");if(t<=0||n<=0)throw new Error("Invalid canvas size");e.canvas.width=t,e.canvas.height=n}destroy(e){if(!e.canvas)throw new Error("Canvas is not specified");e.canvas.width=0,e.canvas.height=0,e.canvas=null,e.context=null}_createCanvas(e,t){(0,i.unreachable)("Abstract method `_createCanvas` called.")}}t.BaseCanvasFactory=a;class s{constructor({baseUrl:e=null,isCompressed:t=!0}){this.constructor===s&&(0,i.unreachable)("Cannot initialize BaseCMapReaderFactory."),this.baseUrl=e,this.isCompressed=t}fetch(e){return it(this,arguments,(function*({name:e}){if(!this.baseUrl)throw new Error('The CMap "baseUrl" parameter must be specified, ensure that the "cMapUrl" and "cMapPacked" API parameters are provided.');if(!e)throw new Error("CMap name must be specified.");let t=this.baseUrl+e+(this.isCompressed?".bcmap":""),n=this.isCompressed?i.CMapCompressionType.BINARY:i.CMapCompressionType.NONE;return this._fetchData(t,n).catch((e=>{throw new Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${t}`)}))}))}_fetchData(e,t){(0,i.unreachable)("Abstract method `_fetchData` called.")}}t.BaseCMapReaderFactory=s;class o{constructor({baseUrl:e=null}){this.constructor===o&&(0,i.unreachable)("Cannot initialize BaseStandardFontDataFactory."),this.baseUrl=e}fetch(e){return it(this,arguments,(function*({filename:e}){if(!this.baseUrl)throw new Error('The standard font "baseUrl" parameter must be specified, ensure that the "standardFontDataUrl" API parameter is provided.');if(!e)throw new Error("Font filename must be specified.");let t=`${this.baseUrl}${e}`;return this._fetchData(t).catch((e=>{throw new Error(`Unable to load font data at: ${t}`)}))}))}_fetchData(e){(0,i.unreachable)("Abstract method `_fetchData` called.")}}t.BaseStandardFontDataFactory=o;class l{constructor(){this.constructor===l&&(0,i.unreachable)("Cannot initialize BaseSVGFactory.")}create(e,t,n=!1){if(e<=0||t<=0)throw new Error("Invalid SVG dimensions");let i=this._createSVG("svg:svg");return i.setAttribute("version","1.1"),n||(i.setAttribute("width",`${e}px`),i.setAttribute("height",`${t}px`)),i.setAttribute("preserveAspectRatio","none"),i.setAttribute("viewBox",`0 0 ${e} ${t}`),i}createElement(e){if("string"!=typeof e)throw new Error("Invalid SVG element type");return this._createSVG(e)}_createSVG(e){(0,i.unreachable)("Abstract method `_createSVG` called.")}}t.BaseSVGFactory=l},(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.MurmurHash3_64=void 0;var i=n(1);let r=3285377520,a=4294901760,s=65535;t.MurmurHash3_64=class{constructor(e){this.h1=e?4294967295&e:r,this.h2=e?4294967295&e:r}update(e){let t,n;if("string"==typeof e){t=new Uint8Array(2*e.length),n=0;for(let i=0,r=e.length;i<r;i++){let r=e.charCodeAt(i);r<=255?t[n++]=r:(t[n++]=r>>>8,t[n++]=255&r)}}else{if(!(0,i.isArrayBuffer)(e))throw new Error("Wrong data format in MurmurHash3_64_update. Input must be a string or array.");t=e.slice(),n=t.byteLength}let r=n>>2,o=n-4*r,l=new Uint32Array(t.buffer,0,r),h=0,u=0,c=this.h1,d=this.h2,p=3432918353,f=461845907,m=p&s,g=f&s;for(let i=0;i<r;i++)1&i?(h=l[i],h=h*p&a|h*m&s,h=h<<15|h>>>17,h=h*f&a|h*g&s,c^=h,c=c<<13|c>>>19,c=5*c+3864292196):(u=l[i],u=u*p&a|u*m&s,u=u<<15|u>>>17,u=u*f&a|u*g&s,d^=u,d=d<<13|d>>>19,d=5*d+3864292196);switch(h=0,o){case 3:h^=t[4*r+2]<<16;case 2:h^=t[4*r+1]<<8;case 1:h^=t[4*r],h=h*p&a|h*m&s,h=h<<15|h>>>17,h=h*f&a|h*g&s,1&r?c^=h:d^=h}this.h1=c,this.h2=d}hexdigest(){let e=this.h1,t=this.h2;return e^=t>>>1,e=3981806797*e&a|36045*e&s,t=4283543511*t&a|(2950163797*(t<<16|e>>>16)&a)>>>16,e^=t>>>1,e=444984403*e&a|60499*e&s,t=3301882366*t&a|(3120437893*(t<<16|e>>>16)&a)>>>16,e^=t>>>1,(e>>>0).toString(16).padStart(8,"0")+(t>>>0).toString(16).padStart(8,"0")}}},(e,t,n)=>{var i;Object.defineProperty(t,"__esModule",{value:!0}),t.FontLoader=t.FontFaceObject=void 0;var r=n(1),a=n(10);i=new WeakMap,t.FontLoader=class{constructor({ownerDocument:e=globalThis.document,styleElement:t=null}){Je(this,i,new Set),this._document=e,this.nativeFontFaces=new Set,this.styleElement=null,this.loadingRequests=[],this.loadTestFontId=0}addNativeFontFace(e){this.nativeFontFaces.add(e),this._document.fonts.add(e)}removeNativeFontFace(e){this.nativeFontFaces.delete(e),this._document.fonts.delete(e)}insertRule(e){this.styleElement||(this.styleElement=this._document.createElement("style"),this._document.documentElement.getElementsByTagName("head")[0].append(this.styleElement));let t=this.styleElement.sheet;t.insertRule(e,t.cssRules.length)}clear(){for(let e of this.nativeFontFaces)this._document.fonts.delete(e);this.nativeFontFaces.clear(),le(this,i).clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}loadSystemFont(e){return it(this,null,(function*(){if(e&&!le(this,i).has(e.loadedName)){if((0,r.assert)(!this.disableFontFace,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){let{loadedName:n,src:a,style:s}=e,o=new FontFace(n,a,s);this.addNativeFontFace(o);try{yield o.load(),le(this,i).add(n)}catch(t){(0,r.warn)(`Cannot load system font: ${e.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(o)}return}(0,r.unreachable)("Not implemented: loadSystemFont without the Font Loading API.")}}))}bind(e){return it(this,null,(function*(){if(e.attached||e.missingFile&&!e.systemFontInfo)return;if(e.attached=!0,e.systemFontInfo)return void(yield this.loadSystemFont(e.systemFontInfo));if(this.isFontLoadingAPISupported){let t=e.createNativeFontFace();if(t){this.addNativeFontFace(t);try{yield t.loaded}catch(n){throw(0,r.warn)(`Failed to load font '${t.family}': '${n}'.`),e.disableFontFace=!0,n}}return}let t=e.createFontFaceRule();if(t){if(this.insertRule(t),this.isSyncFontLoadingSupported)return;yield new Promise((t=>{let n=this._queueLoadingCallback(t);this._prepareFontLoadEvent(e,n)}))}}))}get isFontLoadingAPISupported(){var e;let t=!(null==(e=this._document)||!e.fonts);return(0,r.shadow)(this,"isFontLoadingAPISupported",t)}get isSyncFontLoadingSupported(){let e=!1;return(a.isNodeJS||"undefined"!=typeof navigator&&/Mozilla\/5.0.*?rv:\d+.*? Gecko/.test(navigator.userAgent))&&(e=!0),(0,r.shadow)(this,"isSyncFontLoadingSupported",e)}_queueLoadingCallback(e){let{loadingRequests:t}=this,n={done:!1,complete:function(){for((0,r.assert)(!n.done,"completeRequest() cannot be called twice."),n.done=!0;t.length>0&&t[0].done;){let e=t.shift();setTimeout(e.callback,0)}},callback:e};return t.push(n),n}get _loadTestFont(){let e=atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA==");return(0,r.shadow)(this,"_loadTestFont",e)}_prepareFontLoadEvent(e,t){function n(e,t){return e.charCodeAt(t)<<24|e.charCodeAt(t+1)<<16|e.charCodeAt(t+2)<<8|255&e.charCodeAt(t+3)}function i(e,t,n,i){return e.substring(0,t)+i+e.substring(t+n)}let a,s,o=this._document.createElement("canvas");o.width=1,o.height=1;let l=o.getContext("2d"),h=0,u=`lt${Date.now()}${this.loadTestFontId++}`,c=this._loadTestFont;c=i(c,976,u.length,u);let d=1482184792,p=n(c,16);for(a=0,s=u.length-3;a<s;a+=4)p=p-d+n(u,a)|0;a<u.length&&(p=p-d+n(u+"XXX",a)|0),c=i(c,16,4,(0,r.string32)(p));let f=`@font-face {font-family:"${u}";src:url(data:font/opentype;base64,${btoa(c)});}`;this.insertRule(f);let m=this._document.createElement("div");m.style.visibility="hidden",m.style.width=m.style.height="10px",m.style.position="absolute",m.style.top=m.style.left="0px";for(let r of[e.loadedName,u]){let e=this._document.createElement("span");e.textContent="Hi",e.style.fontFamily=r,m.append(e)}this._document.body.append(m),function e(t,n){if(++h>30)return(0,r.warn)("Load test font never loaded."),void n();l.font="30px "+t,l.fillText(".",0,20),l.getImageData(0,0,1,1).data[3]>0?n():setTimeout(e.bind(null,t,n))}(u,(()=>{m.remove(),t.complete()}))}},t.FontFaceObject=class{constructor(e,{isEvalSupported:t=!0,disableFontFace:n=!1,ignoreErrors:i=!1,inspectFont:r=null}){this.compiledGlyphs=Object.create(null);for(let a in e)this[a]=e[a];this.isEvalSupported=!1!==t,this.disableFontFace=!0===n,this.ignoreErrors=!0===i,this._inspectFont=r}createNativeFontFace(){var e;if(!this.data||this.disableFontFace)return null;let t;if(this.cssFontInfo){let e={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(e.style=`oblique ${this.cssFontInfo.italicAngle}deg`),t=new FontFace(this.cssFontInfo.fontFamily,this.data,e)}else t=new FontFace(this.loadedName,this.data,{});return null==(e=this._inspectFont)||e.call(this,this),t}createFontFaceRule(){var e;if(!this.data||this.disableFontFace)return null;let t,n=(0,r.bytesToString)(this.data),i=`url(data:${this.mimetype};base64,${btoa(n)});`;if(this.cssFontInfo){let e=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(e+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),t=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${e}src:${i}}`}else t=`@font-face {font-family:"${this.loadedName}";src:${i}}`;return null==(e=this._inspectFont)||e.call(this,this,i),t}getPathGenerator(e,t){if(void 0!==this.compiledGlyphs[t])return this.compiledGlyphs[t];let n;try{n=e.get(this.loadedName+"_path_"+t)}catch(e){if(!this.ignoreErrors)throw e;return(0,r.warn)(`getPathGenerator - ignoring character: "${e}".`),this.compiledGlyphs[t]=function(e,t){}}if(this.isEvalSupported&&r.FeatureTest.isEvalSupported){let e=[];for(let t of n){let n=void 0!==t.args?t.args.join(","):"";e.push("c.",t.cmd,"(",n,");\n")}return this.compiledGlyphs[t]=new Function("c","size",e.join(""))}return this.compiledGlyphs[t]=function(e,t){for(let i of n)"scale"===i.cmd&&(i.args=[t,-t]),e[i.cmd].apply(e,i.args)}}}},(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isNodeJS=void 0;let n=!("object"!=typeof process||process+""!="[object process]"||process.versions.nw||process.versions.electron&&process.type&&"browser"!==process.type);t.isNodeJS=n},(e,t,n)=>{var i,r,a,s;Object.defineProperty(t,"__esModule",{value:!0}),t.CanvasGraphics=void 0;var o=n(1),l=n(6),h=n(12),u=n(13),c=n(10);let d=4096,p=16;class f{constructor(e){this.canvasFactory=e,this.cache=Object.create(null)}getCanvas(e,t,n){let i;return void 0!==this.cache[e]?(i=this.cache[e],this.canvasFactory.reset(i,t,n)):(i=this.canvasFactory.create(t,n),this.cache[e]=i),i}delete(e){delete this.cache[e]}clear(){for(let e in this.cache){let t=this.cache[e];this.canvasFactory.destroy(t),delete this.cache[e]}}}function m(e,t,n,i,r,a,s,o,h,u){let[c,d,p,f,m,g]=(0,l.getCurrentTransform)(e);if(0===d&&0===p){let l=s*c+m,v=Math.round(l),y=o*f+g,x=Math.round(y),b=(s+h)*c+m,_=Math.abs(Math.round(b)-v)||1,w=(o+u)*f+g,S=Math.abs(Math.round(w)-x)||1;return e.setTransform(Math.sign(c),0,0,Math.sign(f),v,x),e.drawImage(t,n,i,r,a,0,0,_,S),e.setTransform(c,d,p,f,m,g),[_,S]}if(0===c&&0===f){let l=o*p+m,v=Math.round(l),y=s*d+g,x=Math.round(y),b=(o+u)*p+m,_=Math.abs(Math.round(b)-v)||1,w=(s+h)*d+g,S=Math.abs(Math.round(w)-x)||1;return e.setTransform(0,Math.sign(d),Math.sign(p),0,v,x),e.drawImage(t,n,i,r,a,0,0,S,_),e.setTransform(c,d,p,f,m,g),[S,_]}return e.drawImage(t,n,i,r,a,s,o,h,u),[Math.hypot(c,d)*h,Math.hypot(p,f)*u]}class g{constructor(e,t){this.alphaIsShape=!1,this.fontSize=0,this.fontSizeScale=1,this.textMatrix=o.IDENTITY_MATRIX,this.textMatrixScale=1,this.fontMatrix=o.FONT_IDENTITY_MATRIX,this.leading=0,this.x=0,this.y=0,this.lineX=0,this.lineY=0,this.charSpacing=0,this.wordSpacing=0,this.textHScale=1,this.textRenderingMode=o.TextRenderingMode.FILL,this.textRise=0,this.fillColor="#000000",this.strokeColor="#000000",this.patternFill=!1,this.fillAlpha=1,this.strokeAlpha=1,this.lineWidth=1,this.activeSMask=null,this.transferMaps="none",this.startNewPathAndClipBox([0,0,e,t])}clone(){let e=Object.create(this);return e.clipBox=this.clipBox.slice(),e}setCurrentPoint(e,t){this.x=e,this.y=t}updatePathMinMax(e,t,n){[t,n]=o.Util.applyTransform([t,n],e),this.minX=Math.min(this.minX,t),this.minY=Math.min(this.minY,n),this.maxX=Math.max(this.maxX,t),this.maxY=Math.max(this.maxY,n)}updateRectMinMax(e,t){let n=o.Util.applyTransform(t,e),i=o.Util.applyTransform(t.slice(2),e);this.minX=Math.min(this.minX,n[0],i[0]),this.minY=Math.min(this.minY,n[1],i[1]),this.maxX=Math.max(this.maxX,n[0],i[0]),this.maxY=Math.max(this.maxY,n[1],i[1])}updateScalingPathMinMax(e,t){o.Util.scaleMinMax(e,t),this.minX=Math.min(this.minX,t[0]),this.maxX=Math.max(this.maxX,t[1]),this.minY=Math.min(this.minY,t[2]),this.maxY=Math.max(this.maxY,t[3])}updateCurvePathMinMax(e,t,n,i,r,a,s,l,h,u){let c=o.Util.bezierBoundingBox(t,n,i,r,a,s,l,h);if(u)return u[0]=Math.min(u[0],c[0],c[2]),u[1]=Math.max(u[1],c[0],c[2]),u[2]=Math.min(u[2],c[1],c[3]),void(u[3]=Math.max(u[3],c[1],c[3]));this.updateRectMinMax(e,c)}getPathBoundingBox(e=h.PathType.FILL,t=null){let n=[this.minX,this.minY,this.maxX,this.maxY];if(e===h.PathType.STROKE){t||(0,o.unreachable)("Stroke bounding box must include transform.");let e=o.Util.singularValueDecompose2dScale(t),i=e[0]*this.lineWidth/2,r=e[1]*this.lineWidth/2;n[0]-=i,n[1]-=r,n[2]+=i,n[3]+=r}return n}updateClipFromPath(){let e=o.Util.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(e||[0,0,0,0])}isEmptyClip(){return this.minX===1/0}startNewPathAndClipBox(e){this.clipBox=e,this.minX=1/0,this.minY=1/0,this.maxX=0,this.maxY=0}getClippedPathBoundingBox(e=h.PathType.FILL,t=null){return o.Util.intersect(this.clipBox,this.getPathBoundingBox(e,t))}}function v(e,t){if("undefined"!=typeof ImageData&&t instanceof ImageData)return void e.putImageData(t,0,0);let n,i,r,a,s,l=t.height,h=t.width,u=l%p,c=(l-u)/p,d=0===u?c:c+1,f=e.createImageData(h,p),m=0,g=t.data,v=f.data;if(t.kind===o.ImageKind.GRAYSCALE_1BPP){let t=g.byteLength,s=new Uint32Array(v.buffer,0,v.byteLength>>2),l=s.length,y=h+7>>3,x=4294967295,b=o.FeatureTest.isLittleEndian?4278190080:255;for(i=0;i<d;i++){for(a=i<c?p:u,n=0,r=0;r<a;r++){let e=t-m,i=0,r=e>y?h:8*e-7,a=-8&r,o=0,l=0;for(;i<a;i+=8)l=g[m++],s[n++]=128&l?x:b,s[n++]=64&l?x:b,s[n++]=32&l?x:b,s[n++]=16&l?x:b,s[n++]=8&l?x:b,s[n++]=4&l?x:b,s[n++]=2&l?x:b,s[n++]=1&l?x:b;for(;i<r;i++)0===o&&(l=g[m++],o=128),s[n++]=l&o?x:b,o>>=1}for(;n<l;)s[n++]=0;e.putImageData(f,0,i*p)}}else if(t.kind===o.ImageKind.RGBA_32BPP){for(r=0,s=h*p*4,i=0;i<c;i++)v.set(g.subarray(m,m+s)),m+=s,e.putImageData(f,0,r),r+=p;i<d&&(s=h*u*4,v.set(g.subarray(m,m+s)),e.putImageData(f,0,r))}else{if(t.kind!==o.ImageKind.RGB_24BPP)throw new Error(`bad image kind: ${t.kind}`);for(a=p,s=h*a,i=0;i<d;i++){for(i>=c&&(a=u,s=h*a),n=0,r=s;r--;)v[n++]=g[m++],v[n++]=g[m++],v[n++]=g[m++],v[n++]=255;e.putImageData(f,0,i*p)}}}function y(e,t){if(t.bitmap)return void e.drawImage(t.bitmap,0,0);let n=t.height,i=t.width,r=n%p,a=(n-r)/p,s=0===r?a:a+1,o=e.createImageData(i,p),l=0,h=t.data,c=o.data;for(let d=0;d<s;d++){let t=d<a?p:r;({srcPos:l}=(0,u.convertBlackAndWhiteToRGBA)({src:h,srcPos:l,dest:c,width:i,height:t,nonBlackColor:0})),e.putImageData(o,0,d*p)}}function x(e,t){let n=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"];for(let i of n)void 0!==e[i]&&(t[i]=e[i]);void 0!==e.setLineDash&&(t.setLineDash(e.getLineDash()),t.lineDashOffset=e.lineDashOffset)}function b(e){e.strokeStyle=e.fillStyle="#000000",e.fillRule="nonzero",e.globalAlpha=1,e.lineWidth=1,e.lineCap="butt",e.lineJoin="miter",e.miterLimit=10,e.globalCompositeOperation="source-over",e.font="10px sans-serif",void 0!==e.setLineDash&&(e.setLineDash([]),e.lineDashOffset=0),c.isNodeJS||(e.filter="none")}function _(e,t,n,i){let r=e.length;for(let a=3;a<r;a+=4){let r=e[a];if(0===r)e[a-3]=t,e[a-2]=n,e[a-1]=i;else if(r<255){let s=255-r;e[a-3]=e[a-3]*r+t*s>>8,e[a-2]=e[a-2]*r+n*s>>8,e[a-1]=e[a-1]*r+i*s>>8}}}function w(e,t,n){let i=e.length;for(let r=3;r<i;r+=4){let i=n?n[e[r]]:e[r];t[r]=t[r]*i*.00392156862745098|0}}function S(e,t,n){let i=e.length;for(let r=3;r<i;r+=4){let i=77*e[r-3]+152*e[r-2]+28*e[r-1];t[r]=n?t[r]*n[i>>8]>>8:t[r]*i>>16}}function M(e,t){let n=o.Util.singularValueDecompose2dScale(e);n[0]=Math.fround(n[0]),n[1]=Math.fround(n[1]);let i=Math.fround((globalThis.devicePixelRatio||1)*l.PixelsPerInch.PDF_TO_CSS_UNITS);return void 0!==t?t:n[0]<=i||n[1]<=i}let E=["butt","round","square"],T=["miter","round","bevel"],A={},C={},P=class{constructor(e,t,n,r,s,{optionalContentConfig:o,markedContentStack:l=null},h,u){Je(this,i),Je(this,a),this.ctx=e,this.current=new g(this.ctx.canvas.width,this.ctx.canvas.height),this.stateStack=[],this.pendingClip=null,this.pendingEOFill=!1,this.res=null,this.xobjs=null,this.commonObjs=t,this.objs=n,this.canvasFactory=r,this.filterFactory=s,this.groupStack=[],this.processingType3=null,this.baseTransform=null,this.baseTransformStack=[],this.groupLevel=0,this.smaskStack=[],this.smaskCounter=0,this.tempSMask=null,this.suspendedCtx=null,this.contentVisible=!0,this.markedContentStack=l||[],this.optionalContentConfig=o,this.cachedCanvases=new f(this.canvasFactory),this.cachedPatterns=new Map,this.annotationCanvasMap=h,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=u,this._cachedScaleForStroking=[-1,0],this._cachedGetSinglePixelWidth=null,this._cachedBitmapsMap=new Map}getObject(e,t=null){return"string"==typeof e?e.startsWith("g_")?this.commonObjs.get(e):this.objs.get(e):t}beginDrawing({transform:e,viewport:t,transparency:n=!1,background:i=null}){let r=this.ctx.canvas.width,a=this.ctx.canvas.height,s=this.ctx.fillStyle;if(this.ctx.fillStyle=i||"#ffffff",this.ctx.fillRect(0,0,r,a),this.ctx.fillStyle=s,n){let e=this.cachedCanvases.getCanvas("transparent",r,a);this.compositeCtx=this.ctx,this.transparentCanvas=e.canvas,this.ctx=e.context,this.ctx.save(),this.ctx.transform(...(0,l.getCurrentTransform)(this.compositeCtx))}this.ctx.save(),b(this.ctx),e&&(this.ctx.transform(...e),this.outputScaleX=e[0],this.outputScaleY=e[0]),this.ctx.transform(...t.transform),this.viewportScale=t.scale,this.baseTransform=(0,l.getCurrentTransform)(this.ctx)}executeOperatorList(e,t,n,i){let r=e.argsArray,a=e.fnArray,s=t||0,l=r.length;if(l===s)return s;let h,u=l-s>10&&"function"==typeof n,c=u?Date.now()+15:0,d=0,p=this.commonObjs,f=this.objs;for(;;){if(void 0!==i&&s===i.nextBreakPoint)return i.breakIt(s,n),s;if(h=a[s],h!==o.OPS.dependency)this[h].apply(this,r[s]);else for(let e of r[s]){let t=e.startsWith("g_")?p:f;if(!t.has(e))return t.get(e,n),s}if(s++,s===l)return s;if(u&&++d>10){if(Date.now()>c)return n(),s;d=0}}}endDrawing(){ft(this,i,r).call(this),this.cachedCanvases.clear(),this.cachedPatterns.clear();for(let e of this._cachedBitmapsMap.values()){for(let t of e.values())"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement&&(t.width=t.height=0);e.clear()}this._cachedBitmapsMap.clear(),ft(this,a,s).call(this)}_scaleImage(e,t){let n,i,r=e.width,a=e.height,s=Math.max(Math.hypot(t[0],t[1]),1),o=Math.max(Math.hypot(t[2],t[3]),1),l=r,h=a,u="prescale1";for(;s>2&&l>1||o>2&&h>1;){let t=l,r=h;s>2&&l>1&&(t=l>=16384?Math.floor(l/2)-1||1:Math.ceil(l/2),s/=l/t),o>2&&h>1&&(r=h>=16384?Math.floor(h/2)-1||1:Math.ceil(h)/2,o/=h/r),n=this.cachedCanvases.getCanvas(u,t,r),i=n.context,i.clearRect(0,0,t,r),i.drawImage(e,0,0,l,h,0,0,t,r),e=n.canvas,l=t,h=r,u="prescale1"===u?"prescale2":"prescale1"}return{img:e,paintWidth:l,paintHeight:h}}_createMaskCanvas(e){let t,n,i,r,a=this.ctx,{width:s,height:u}=e,c=this.current.fillColor,d=this.current.patternFill,p=(0,l.getCurrentTransform)(a);if((e.bitmap||e.data)&&e.count>1){let r=e.bitmap||e.data.buffer;n=JSON.stringify(d?p:[p.slice(0,4),c]),t=this._cachedBitmapsMap.get(r),t||(t=new Map,this._cachedBitmapsMap.set(r,t));let a=t.get(n);if(a&&!d)return{canvas:a,offsetX:Math.round(Math.min(p[0],p[2])+p[4]),offsetY:Math.round(Math.min(p[1],p[3])+p[5])};i=a}i||(r=this.cachedCanvases.getCanvas("maskCanvas",s,u),y(r.context,e));let f=o.Util.transform(p,[1/s,0,0,-1/u,0,0]);f=o.Util.transform(f,[1,0,0,1,0,-u]);let g=o.Util.applyTransform([0,0],f),v=o.Util.applyTransform([s,u],f),x=o.Util.normalizeRect([g[0],g[1],v[0],v[1]]),b=Math.round(x[2]-x[0])||1,_=Math.round(x[3]-x[1])||1,w=this.cachedCanvases.getCanvas("fillCanvas",b,_),S=w.context,E=Math.min(g[0],v[0]),T=Math.min(g[1],v[1]);S.translate(-E,-T),S.transform(...f),i||(i=this._scaleImage(r.canvas,(0,l.getCurrentTransformInverse)(S)),i=i.img,t&&d&&t.set(n,i)),S.imageSmoothingEnabled=M((0,l.getCurrentTransform)(S),e.interpolate),m(S,i,0,0,i.width,i.height,0,0,s,u),S.globalCompositeOperation="source-in";let A=o.Util.transform((0,l.getCurrentTransformInverse)(S),[1,0,0,1,-E,-T]);return S.fillStyle=d?c.getPattern(a,this,A,h.PathType.FILL):c,S.fillRect(0,0,s,u),t&&!d&&(this.cachedCanvases.delete("fillCanvas"),t.set(n,w.canvas)),{canvas:w.canvas,offsetX:Math.round(E),offsetY:Math.round(T)}}setLineWidth(e){e!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=e,this.ctx.lineWidth=e}setLineCap(e){this.ctx.lineCap=E[e]}setLineJoin(e){this.ctx.lineJoin=T[e]}setMiterLimit(e){this.ctx.miterLimit=e}setDash(e,t){let n=this.ctx;void 0!==n.setLineDash&&(n.setLineDash(e),n.lineDashOffset=t)}setRenderingIntent(e){}setFlatness(e){}setGState(e){for(let[t,n]of e)switch(t){case"LW":this.setLineWidth(n);break;case"LC":this.setLineCap(n);break;case"LJ":this.setLineJoin(n);break;case"ML":this.setMiterLimit(n);break;case"D":this.setDash(n[0],n[1]);break;case"RI":this.setRenderingIntent(n);break;case"FL":this.setFlatness(n);break;case"Font":this.setFont(n[0],n[1]);break;case"CA":this.current.strokeAlpha=n;break;case"ca":this.current.fillAlpha=n,this.ctx.globalAlpha=n;break;case"BM":this.ctx.globalCompositeOperation=n;break;case"SMask":this.current.activeSMask=n?this.tempSMask:null,this.tempSMask=null,this.checkSMaskState();break;case"TR":this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(n)}}get inSMaskMode(){return!!this.suspendedCtx}checkSMaskState(){let e=this.inSMaskMode;this.current.activeSMask&&!e?this.beginSMaskMode():!this.current.activeSMask&&e&&this.endSMaskMode()}beginSMaskMode(){if(this.inSMaskMode)throw new Error("beginSMaskMode called while already in smask mode");let e=this.ctx.canvas.width,t=this.ctx.canvas.height,n="smaskGroupAt"+this.groupLevel,i=this.cachedCanvases.getCanvas(n,e,t);this.suspendedCtx=this.ctx,this.ctx=i.context;let r=this.ctx;r.setTransform(...(0,l.getCurrentTransform)(this.suspendedCtx)),x(this.suspendedCtx,r),function(e,t){if(e._removeMirroring)throw new Error("Context is already forwarding operations.");e.__originalSave=e.save,e.__originalRestore=e.restore,e.__originalRotate=e.rotate,e.__originalScale=e.scale,e.__originalTranslate=e.translate,e.__originalTransform=e.transform,e.__originalSetTransform=e.setTransform,e.__originalResetTransform=e.resetTransform,e.__originalClip=e.clip,e.__originalMoveTo=e.moveTo,e.__originalLineTo=e.lineTo,e.__originalBezierCurveTo=e.bezierCurveTo,e.__originalRect=e.rect,e.__originalClosePath=e.closePath,e.__originalBeginPath=e.beginPath,e._removeMirroring=()=>{e.save=e.__originalSave,e.restore=e.__originalRestore,e.rotate=e.__originalRotate,e.scale=e.__originalScale,e.translate=e.__originalTranslate,e.transform=e.__originalTransform,e.setTransform=e.__originalSetTransform,e.resetTransform=e.__originalResetTransform,e.clip=e.__originalClip,e.moveTo=e.__originalMoveTo,e.lineTo=e.__originalLineTo,e.bezierCurveTo=e.__originalBezierCurveTo,e.rect=e.__originalRect,e.closePath=e.__originalClosePath,e.beginPath=e.__originalBeginPath,delete e._removeMirroring},e.save=function(){t.save(),this.__originalSave()},e.restore=function(){t.restore(),this.__originalRestore()},e.translate=function(e,n){t.translate(e,n),this.__originalTranslate(e,n)},e.scale=function(e,n){t.scale(e,n),this.__originalScale(e,n)},e.transform=function(e,n,i,r,a,s){t.transform(e,n,i,r,a,s),this.__originalTransform(e,n,i,r,a,s)},e.setTransform=function(e,n,i,r,a,s){t.setTransform(e,n,i,r,a,s),this.__originalSetTransform(e,n,i,r,a,s)},e.resetTransform=function(){t.resetTransform(),this.__originalResetTransform()},e.rotate=function(e){t.rotate(e),this.__originalRotate(e)},e.clip=function(e){t.clip(e),this.__originalClip(e)},e.moveTo=function(e,n){t.moveTo(e,n),this.__originalMoveTo(e,n)},e.lineTo=function(e,n){t.lineTo(e,n),this.__originalLineTo(e,n)},e.bezierCurveTo=function(e,n,i,r,a,s){t.bezierCurveTo(e,n,i,r,a,s),this.__originalBezierCurveTo(e,n,i,r,a,s)},e.rect=function(e,n,i,r){t.rect(e,n,i,r),this.__originalRect(e,n,i,r)},e.closePath=function(){t.closePath(),this.__originalClosePath()},e.beginPath=function(){t.beginPath(),this.__originalBeginPath()}}(r,this.suspendedCtx),this.setGState([["BM","source-over"],["ca",1],["CA",1]])}endSMaskMode(){if(!this.inSMaskMode)throw new Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),x(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null}compose(e){if(!this.current.activeSMask)return;e?(e[0]=Math.floor(e[0]),e[1]=Math.floor(e[1]),e[2]=Math.ceil(e[2]),e[3]=Math.ceil(e[3])):e=[0,0,this.ctx.canvas.width,this.ctx.canvas.height];let t=this.current.activeSMask;(function(e,t,n,i){let r=i[0],a=i[1],s=i[2]-r,o=i[3]-a;0===s||0===o||(function(e,t,n,i,r,a,s,o,l,h,u){let c,d=!!a,p=d?a[0]:0,f=d?a[1]:0,m=d?a[2]:0;c="Luminosity"===r?S:w;let g=Math.min(i,Math.ceil(1048576/n));for(let v=0;v<i;v+=g){let r=Math.min(g,i-v),a=e.getImageData(o-h,v+(l-u),n,r),y=t.getImageData(o,v+l,n,r);d&&_(a.data,p,f,m),c(a.data,y.data,s),t.putImageData(y,o,v+l)}}(t.context,n,s,o,t.subtype,t.backdrop,t.transferMap,r,a,t.offsetX,t.offsetY),e.save(),e.globalAlpha=1,e.globalCompositeOperation="source-over",e.setTransform(1,0,0,1,0,0),e.drawImage(n.canvas,0,0),e.restore())})(this.suspendedCtx,t,this.ctx,e),this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height),this.ctx.restore()}save(){this.inSMaskMode?(x(this.ctx,this.suspendedCtx),this.suspendedCtx.save()):this.ctx.save();let e=this.current;this.stateStack.push(e),this.current=e.clone()}restore(){0===this.stateStack.length&&this.inSMaskMode&&this.endSMaskMode(),0!==this.stateStack.length&&(this.current=this.stateStack.pop(),this.inSMaskMode?(this.suspendedCtx.restore(),x(this.suspendedCtx,this.ctx)):this.ctx.restore(),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null)}transform(e,t,n,i,r,a){this.ctx.transform(e,t,n,i,r,a),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(e,t,n){let i,r,a=this.ctx,s=this.current,h=s.x,u=s.y,c=(0,l.getCurrentTransform)(a),d=0===c[0]&&0===c[3]||0===c[1]&&0===c[2],p=d?n.slice(0):null;for(let l=0,f=0,m=e.length;l<m;l++)switch(0|e[l]){case o.OPS.rectangle:h=t[f++],u=t[f++];let e=t[f++],n=t[f++],l=h+e,m=u+n;a.moveTo(h,u),0===e||0===n?a.lineTo(l,m):(a.lineTo(l,u),a.lineTo(l,m),a.lineTo(h,m)),d||s.updateRectMinMax(c,[h,u,l,m]),a.closePath();break;case o.OPS.moveTo:h=t[f++],u=t[f++],a.moveTo(h,u),d||s.updatePathMinMax(c,h,u);break;case o.OPS.lineTo:h=t[f++],u=t[f++],a.lineTo(h,u),d||s.updatePathMinMax(c,h,u);break;case o.OPS.curveTo:i=h,r=u,h=t[f+4],u=t[f+5],a.bezierCurveTo(t[f],t[f+1],t[f+2],t[f+3],h,u),s.updateCurvePathMinMax(c,i,r,t[f],t[f+1],t[f+2],t[f+3],h,u,p),f+=6;break;case o.OPS.curveTo2:i=h,r=u,a.bezierCurveTo(h,u,t[f],t[f+1],t[f+2],t[f+3]),s.updateCurvePathMinMax(c,i,r,h,u,t[f],t[f+1],t[f+2],t[f+3],p),h=t[f+2],u=t[f+3],f+=4;break;case o.OPS.curveTo3:i=h,r=u,h=t[f+2],u=t[f+3],a.bezierCurveTo(t[f],t[f+1],h,u,h,u),s.updateCurvePathMinMax(c,i,r,t[f],t[f+1],h,u,h,u,p),f+=4;break;case o.OPS.closePath:a.closePath()}d&&s.updateScalingPathMinMax(c,p),s.setCurrentPoint(h,u)}closePath(){this.ctx.closePath()}stroke(e=!0){let t=this.ctx,n=this.current.strokeColor;t.globalAlpha=this.current.strokeAlpha,this.contentVisible&&("object"==typeof n&&null!=n&&n.getPattern?(t.save(),t.strokeStyle=n.getPattern(t,this,(0,l.getCurrentTransformInverse)(t),h.PathType.STROKE),this.rescaleAndStroke(!1),t.restore()):this.rescaleAndStroke(!0)),e&&this.consumePath(this.current.getClippedPathBoundingBox()),t.globalAlpha=this.current.fillAlpha}closeStroke(){this.closePath(),this.stroke()}fill(e=!0){let t=this.ctx,n=this.current.fillColor,i=!1;this.current.patternFill&&(t.save(),t.fillStyle=n.getPattern(t,this,(0,l.getCurrentTransformInverse)(t),h.PathType.FILL),i=!0);let r=this.current.getClippedPathBoundingBox();this.contentVisible&&null!==r&&(this.pendingEOFill?(t.fill("evenodd"),this.pendingEOFill=!1):t.fill()),i&&t.restore(),e&&this.consumePath(r)}eoFill(){this.pendingEOFill=!0,this.fill()}fillStroke(){this.fill(!1),this.stroke(!1),this.consumePath()}eoFillStroke(){this.pendingEOFill=!0,this.fillStroke()}closeFillStroke(){this.closePath(),this.fillStroke()}closeEOFillStroke(){this.pendingEOFill=!0,this.closePath(),this.fillStroke()}endPath(){this.consumePath()}clip(){this.pendingClip=A}eoClip(){this.pendingClip=C}beginText(){this.current.textMatrix=o.IDENTITY_MATRIX,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}endText(){let e=this.pendingTextPaths,t=this.ctx;if(void 0!==e){t.save(),t.beginPath();for(let n of e)t.setTransform(...n.transform),t.translate(n.x,n.y),n.addToPath(t,n.fontSize);t.restore(),t.clip(),t.beginPath(),delete this.pendingTextPaths}else t.beginPath()}setCharSpacing(e){this.current.charSpacing=e}setWordSpacing(e){this.current.wordSpacing=e}setHScale(e){this.current.textHScale=e/100}setLeading(e){this.current.leading=-e}setFont(e,t){var n;let i=this.commonObjs.get(e),r=this.current;if(!i)throw new Error(`Can't find font for ${e}`);if(r.fontMatrix=i.fontMatrix||o.FONT_IDENTITY_MATRIX,(0===r.fontMatrix[0]||0===r.fontMatrix[3])&&(0,o.warn)("Invalid font matrix for font "+e),t<0?(t=-t,r.fontDirection=-1):r.fontDirection=1,this.current.font=i,this.current.fontSize=t,i.isType3Font)return;let a=i.loadedName||"sans-serif",s=(null==(n=i.systemFontInfo)?void 0:n.css)||`"${a}", ${i.fallbackName}`,l="normal";i.black?l="900":i.bold&&(l="bold");let h=i.italic?"italic":"normal",u=t;t<16?u=16:t>100&&(u=100),this.current.fontSizeScale=t/u,this.ctx.font=`${h} ${l} ${u}px ${s}`}setTextRenderingMode(e){this.current.textRenderingMode=e}setTextRise(e){this.current.textRise=e}moveText(e,t){this.current.x=this.current.lineX+=e,this.current.y=this.current.lineY+=t}setLeadingMoveText(e,t){this.setLeading(-t),this.moveText(e,t)}setTextMatrix(e,t,n,i,r,a){this.current.textMatrix=[e,t,n,i,r,a],this.current.textMatrixScale=Math.hypot(e,t),this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}nextLine(){this.moveText(0,this.current.leading)}paintChar(e,t,n,i){let r,a=this.ctx,s=this.current,h=s.font,u=s.textRenderingMode,c=s.fontSize/s.fontSizeScale,d=u&o.TextRenderingMode.FILL_STROKE_MASK,p=!!(u&o.TextRenderingMode.ADD_TO_PATH_FLAG),f=s.patternFill&&!h.missingFile;(h.disableFontFace||p||f)&&(r=h.getPathGenerator(this.commonObjs,e)),h.disableFontFace||f?(a.save(),a.translate(t,n),a.beginPath(),r(a,c),i&&a.setTransform(...i),(d===o.TextRenderingMode.FILL||d===o.TextRenderingMode.FILL_STROKE)&&a.fill(),(d===o.TextRenderingMode.STROKE||d===o.TextRenderingMode.FILL_STROKE)&&a.stroke(),a.restore()):((d===o.TextRenderingMode.FILL||d===o.TextRenderingMode.FILL_STROKE)&&a.fillText(e,t,n),(d===o.TextRenderingMode.STROKE||d===o.TextRenderingMode.FILL_STROKE)&&a.strokeText(e,t,n)),p&&(this.pendingTextPaths||(this.pendingTextPaths=[])).push({transform:(0,l.getCurrentTransform)(a),x:t,y:n,fontSize:c,addToPath:r})}get isFontSubpixelAAEnabled(){let{context:e}=this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled",10,10);e.scale(1.5,1),e.fillText("I",0,10);let t=e.getImageData(0,0,10,10).data,n=!1;for(let i=3;i<t.length;i+=4)if(t[i]>0&&t[i]<255){n=!0;break}return(0,o.shadow)(this,"isFontSubpixelAAEnabled",n)}showText(e){let t=this.current,n=t.font;if(n.isType3Font)return this.showType3Text(e);let i=t.fontSize;if(0===i)return;let r,a=this.ctx,s=t.fontSizeScale,u=t.charSpacing,c=t.wordSpacing,d=t.fontDirection,p=t.textHScale*d,f=e.length,m=n.vertical,g=m?1:-1,v=n.defaultVMetrics,y=i*t.fontMatrix[0],x=t.textRenderingMode===o.TextRenderingMode.FILL&&!n.disableFontFace&&!t.patternFill;if(a.save(),a.transform(...t.textMatrix),a.translate(t.x,t.y+t.textRise),d>0?a.scale(p,-1):a.scale(p,1),t.patternFill){a.save();let e=t.fillColor.getPattern(a,this,(0,l.getCurrentTransformInverse)(a),h.PathType.FILL);r=(0,l.getCurrentTransform)(a),a.restore(),a.fillStyle=e}let b=t.lineWidth,_=t.textMatrixScale;if(0===_||0===b){let e=t.textRenderingMode&o.TextRenderingMode.FILL_STROKE_MASK;(e===o.TextRenderingMode.STROKE||e===o.TextRenderingMode.FILL_STROKE)&&(b=this.getSinglePixelWidth())}else b/=_;if(1!==s&&(a.scale(s,s),b/=s),a.lineWidth=b,n.isInvalidPDFjsFont){let n=[],i=0;for(let t of e)n.push(t.unicode),i+=t.width;return a.fillText(n.join(""),0,0),t.x+=i*y*p,a.restore(),void this.compose()}let w,S=0;for(w=0;w<f;++w){let t=e[w];if("number"==typeof t){S+=g*t*i/1e3;continue}let o,l,h,p=!1,f=(t.isSpace?c:0)+u,b=t.fontChar,_=t.accent,M=t.width;if(m){let e=t.vmetric||v,n=-(t.vmetric?e[1]:.5*M)*y,i=e[2]*y;M=e?-e[0]:M,o=n/s,l=(S+i)/s}else o=S/s,l=0;if(n.remeasure&&M>0){let e=1e3*a.measureText(b).width/i*s;if(M<e&&this.isFontSubpixelAAEnabled){let t=M/e;p=!0,a.save(),a.scale(t,1),o/=t}else M!==e&&(o+=(M-e)/2e3*i/s)}if(this.contentVisible&&(t.isInFont||n.missingFile))if(x&&!_)a.fillText(b,o,l);else if(this.paintChar(b,o,l,r),_){let e=o+i*_.offset.x/s,t=l-i*_.offset.y/s;this.paintChar(_.fontChar,e,t,r)}h=m?M*y-f*d:M*y+f*d,S+=h,p&&a.restore()}m?t.y-=S:t.x+=S*p,a.restore(),this.compose()}showType3Text(e){let t,n,i,r,a=this.ctx,s=this.current,l=s.font,h=s.fontSize,u=s.fontDirection,c=l.vertical?1:-1,d=s.charSpacing,p=s.wordSpacing,f=s.textHScale*u,m=s.fontMatrix||o.FONT_IDENTITY_MATRIX,g=e.length;if(s.textRenderingMode!==o.TextRenderingMode.INVISIBLE&&0!==h){for(this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,a.save(),a.transform(...s.textMatrix),a.translate(s.x,s.y),a.scale(f,u),t=0;t<g;++t){if(n=e[t],"number"==typeof n){r=c*n*h/1e3,this.ctx.translate(r,0),s.x+=r*f;continue}let u=(n.isSpace?p:0)+d,g=l.charProcOperatorList[n.operatorListId];g?(this.contentVisible&&(this.processingType3=n,this.save(),a.scale(h,h),a.transform(...m),this.executeOperatorList(g),this.restore()),i=o.Util.applyTransform([n.width,0],m)[0]*h+u,a.translate(i,0),s.x+=i*f):(0,o.warn)(`Type3 character "${n.operatorListId}" is not available.`)}a.restore(),this.processingType3=null}}setCharWidth(e,t){}setCharWidthAndBounds(e,t,n,i,r,a){this.ctx.rect(n,i,r-n,a-i),this.ctx.clip(),this.endPath()}getColorN_Pattern(e){let t;if("TilingPattern"===e[0]){let n=e[1],i=this.baseTransform||(0,l.getCurrentTransform)(this.ctx),r={createCanvasGraphics:e=>new P(e,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack})};t=new h.TilingPattern(e,n,this.ctx,r,i)}else t=this._getPattern(e[1],e[2]);return t}setStrokeColorN(){this.current.strokeColor=this.getColorN_Pattern(arguments)}setFillColorN(){this.current.fillColor=this.getColorN_Pattern(arguments),this.current.patternFill=!0}setStrokeRGBColor(e,t,n){let i=o.Util.makeHexColor(e,t,n);this.ctx.strokeStyle=i,this.current.strokeColor=i}setFillRGBColor(e,t,n){let i=o.Util.makeHexColor(e,t,n);this.ctx.fillStyle=i,this.current.fillColor=i,this.current.patternFill=!1}_getPattern(e,t=null){let n;return this.cachedPatterns.has(e)?n=this.cachedPatterns.get(e):(n=(0,h.getShadingPattern)(this.getObject(e)),this.cachedPatterns.set(e,n)),t&&(n.matrix=t),n}shadingFill(e){if(!this.contentVisible)return;let t=this.ctx;this.save();let n=this._getPattern(e);t.fillStyle=n.getPattern(t,this,(0,l.getCurrentTransformInverse)(t),h.PathType.SHADING);let i=(0,l.getCurrentTransformInverse)(t);if(i){let{width:e,height:n}=t.canvas,[r,a,s,l]=o.Util.getAxialAlignedBoundingBox([0,0,e,n],i);this.ctx.fillRect(r,a,s-r,l-a)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.compose(this.current.getClippedPathBoundingBox()),this.restore()}beginInlineImage(){(0,o.unreachable)("Should not call beginInlineImage")}beginImageData(){(0,o.unreachable)("Should not call beginImageData")}paintFormXObjectBegin(e,t){if(this.contentVisible&&(this.save(),this.baseTransformStack.push(this.baseTransform),Array.isArray(e)&&6===e.length&&this.transform(...e),this.baseTransform=(0,l.getCurrentTransform)(this.ctx),t)){let e=t[2]-t[0],n=t[3]-t[1];this.ctx.rect(t[0],t[1],e,n),this.current.updateRectMinMax((0,l.getCurrentTransform)(this.ctx),t),this.clip(),this.endPath()}}paintFormXObjectEnd(){this.contentVisible&&(this.restore(),this.baseTransform=this.baseTransformStack.pop())}beginGroup(e){if(!this.contentVisible)return;this.save(),this.inSMaskMode&&(this.endSMaskMode(),this.current.activeSMask=null);let t=this.ctx;e.isolated||(0,o.info)("TODO: Support non-isolated groups."),e.knockout&&(0,o.warn)("Knockout groups not supported.");let n=(0,l.getCurrentTransform)(t);if(e.matrix&&t.transform(...e.matrix),!e.bbox)throw new Error("Bounding box is required.");let i=o.Util.getAxialAlignedBoundingBox(e.bbox,(0,l.getCurrentTransform)(t)),r=[0,0,t.canvas.width,t.canvas.height];i=o.Util.intersect(i,r)||[0,0,0,0];let a=Math.floor(i[0]),s=Math.floor(i[1]),h=Math.max(Math.ceil(i[2])-a,1),u=Math.max(Math.ceil(i[3])-s,1),c=1,p=1;h>d&&(c=h/d,h=d),u>d&&(p=u/d,u=d),this.current.startNewPathAndClipBox([0,0,h,u]);let f="groupAt"+this.groupLevel;e.smask&&(f+="_smask_"+this.smaskCounter++%2);let m=this.cachedCanvases.getCanvas(f,h,u),g=m.context;g.scale(1/c,1/p),g.translate(-a,-s),g.transform(...n),e.smask?this.smaskStack.push({canvas:m.canvas,context:g,offsetX:a,offsetY:s,scaleX:c,scaleY:p,subtype:e.smask.subtype,backdrop:e.smask.backdrop,transferMap:e.smask.transferMap||null,startTransformInverse:null}):(t.setTransform(1,0,0,1,0,0),t.translate(a,s),t.scale(c,p),t.save()),x(t,g),this.ctx=g,this.setGState([["BM","source-over"],["ca",1],["CA",1]]),this.groupStack.push(t),this.groupLevel++}endGroup(e){if(!this.contentVisible)return;this.groupLevel--;let t=this.ctx,n=this.groupStack.pop();if(this.ctx=n,this.ctx.imageSmoothingEnabled=!1,e.smask)this.tempSMask=this.smaskStack.pop(),this.restore();else{this.ctx.restore();let e=(0,l.getCurrentTransform)(this.ctx);this.restore(),this.ctx.save(),this.ctx.setTransform(...e);let n=o.Util.getAxialAlignedBoundingBox([0,0,t.canvas.width,t.canvas.height],e);this.ctx.drawImage(t.canvas,0,0),this.ctx.restore(),this.compose(n)}}beginAnnotation(e,t,n,a,s){if(ft(this,i,r).call(this),b(this.ctx),this.ctx.save(),this.save(),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),Array.isArray(t)&&4===t.length){let i=t[2]-t[0],r=t[3]-t[1];if(s&&this.annotationCanvasMap){(n=n.slice())[4]-=t[0],n[5]-=t[1],(t=t.slice())[0]=t[1]=0,t[2]=i,t[3]=r;let[a,s]=o.Util.singularValueDecompose2dScale((0,l.getCurrentTransform)(this.ctx)),{viewportScale:h}=this,u=Math.ceil(i*this.outputScaleX*h),c=Math.ceil(r*this.outputScaleY*h);this.annotationCanvas=this.canvasFactory.create(u,c);let{canvas:d,context:p}=this.annotationCanvas;this.annotationCanvasMap.set(e,d),this.annotationCanvas.savedCtx=this.ctx,this.ctx=p,this.ctx.save(),this.ctx.setTransform(a,0,0,-s,0,r*s),b(this.ctx)}else b(this.ctx),this.ctx.rect(t[0],t[1],i,r),this.ctx.clip(),this.endPath()}this.current=new g(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(...n),this.transform(...a)}endAnnotation(){this.annotationCanvas&&(this.ctx.restore(),ft(this,a,s).call(this),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas)}paintImageMaskXObject(e){if(!this.contentVisible)return;let t=e.count;(e=this.getObject(e.data,e)).count=t;let n=this.ctx,i=this.processingType3;if(i&&(void 0===i.compiled&&(i.compiled=function(e){let{width:t,height:n}=e;if(t>1e3||n>1e3)return null;let i,r,a,s=new Uint8Array([0,2,4,0,1,0,5,4,8,10,0,8,0,2,1,0]),o=t+1,l=new Uint8Array(o*(n+1)),h=t+7&-8,u=new Uint8Array(h*n),c=0;for(let m of e.data){let e=128;for(;e>0;)u[c++]=m&e?0:255,e>>=1}let d=0;for(c=0,0!==u[c]&&(l[0]=1,++d),r=1;r<t;r++)u[c]!==u[c+1]&&(l[r]=u[c]?2:1,++d),c++;for(0!==u[c]&&(l[r]=2,++d),i=1;i<n;i++){c=i*h,a=i*o,u[c-h]!==u[c]&&(l[a]=u[c]?1:8,++d);let e=(u[c]?4:0)+(u[c-h]?8:0);for(r=1;r<t;r++)e=(e>>2)+(u[c+1]?4:0)+(u[c-h+1]?8:0),s[e]&&(l[a+r]=s[e],++d),c++;if(u[c-h]!==u[c]&&(l[a+r]=u[c]?2:4,++d),d>1e3)return null}for(c=h*(n-1),a=i*o,0!==u[c]&&(l[a]=8,++d),r=1;r<t;r++)u[c]!==u[c+1]&&(l[a+r]=u[c]?4:8,++d),c++;if(0!==u[c]&&(l[a+r]=4,++d),d>1e3)return null;let p=new Int32Array([0,o,-1,0,-o,0,0,0,1]),f=new Path2D;for(i=0;d&&i<=n;i++){let e=i*o,n=e+t;for(;e<n&&!l[e];)e++;if(e===n)continue;f.moveTo(e%o,i);let r=e,a=l[e];do{let t=p[a];do{e+=t}while(!l[e]);let n=l[e];5!==n&&10!==n?(a=n,l[e]=0):(a=n&51*a>>4,l[e]&=a>>2|a<<2),f.lineTo(e%o,e/o|0),l[e]||--d}while(r!==e);--i}return u=null,l=null,function(e){e.save(),e.scale(1/t,-1/n),e.translate(0,-n),e.fill(f),e.beginPath(),e.restore()}}(e)),i.compiled))return void i.compiled(n);let r=this._createMaskCanvas(e),a=r.canvas;n.save(),n.setTransform(1,0,0,1,0,0),n.drawImage(a,r.offsetX,r.offsetY),n.restore(),this.compose()}paintImageMaskXObjectRepeat(e,t,n=0,i=0,r,a){if(!this.contentVisible)return;e=this.getObject(e.data,e);let s=this.ctx;s.save();let h=(0,l.getCurrentTransform)(s);s.transform(t,n,i,r,0,0);let u=this._createMaskCanvas(e);s.setTransform(1,0,0,1,u.offsetX-h[4],u.offsetY-h[5]);for(let l=0,c=a.length;l<c;l+=2){let e=o.Util.transform(h,[t,n,i,r,a[l],a[l+1]]),[c,d]=o.Util.applyTransform([0,0],e);s.drawImage(u.canvas,c,d)}s.restore(),this.compose()}paintImageMaskXObjectGroup(e){if(!this.contentVisible)return;let t=this.ctx,n=this.current.fillColor,i=this.current.patternFill;for(let r of e){let{data:e,width:a,height:s,transform:o}=r,u=this.cachedCanvases.getCanvas("maskCanvas",a,s),c=u.context;c.save(),y(c,this.getObject(e,r)),c.globalCompositeOperation="source-in",c.fillStyle=i?n.getPattern(c,this,(0,l.getCurrentTransformInverse)(t),h.PathType.FILL):n,c.fillRect(0,0,a,s),c.restore(),t.save(),t.transform(...o),t.scale(1,-1),m(t,u.canvas,0,0,a,s,0,-1,1,1),t.restore()}this.compose()}paintImageXObject(e){if(!this.contentVisible)return;let t=this.getObject(e);t?this.paintInlineImageXObject(t):(0,o.warn)("Dependent image isn't ready yet")}paintImageXObjectRepeat(e,t,n,i){if(!this.contentVisible)return;let r=this.getObject(e);if(!r)return void(0,o.warn)("Dependent image isn't ready yet");let a=r.width,s=r.height,l=[];for(let o=0,h=i.length;o<h;o+=2)l.push({transform:[t,0,0,n,i[o],i[o+1]],x:0,y:0,w:a,h:s});this.paintInlineImageXObjectGroup(r,l)}applyTransferMapsToCanvas(e){return"none"!==this.current.transferMaps&&(e.filter=this.current.transferMaps,e.drawImage(e.canvas,0,0),e.filter="none"),e.canvas}applyTransferMapsToBitmap(e){if("none"===this.current.transferMaps)return e.bitmap;let{bitmap:t,width:n,height:i}=e,r=this.cachedCanvases.getCanvas("inlineImage",n,i),a=r.context;return a.filter=this.current.transferMaps,a.drawImage(t,0,0),a.filter="none",r.canvas}paintInlineImageXObject(e){if(!this.contentVisible)return;let t,n=e.width,i=e.height,r=this.ctx;if(this.save(),c.isNodeJS||(r.filter="none"),r.scale(1/n,-1/i),e.bitmap)t=this.applyTransferMapsToBitmap(e);else if("function"==typeof HTMLElement&&e instanceof HTMLElement||!e.data)t=e;else{let r=this.cachedCanvases.getCanvas("inlineImage",n,i).context;v(r,e),t=this.applyTransferMapsToCanvas(r)}let a=this._scaleImage(t,(0,l.getCurrentTransformInverse)(r));r.imageSmoothingEnabled=M((0,l.getCurrentTransform)(r),e.interpolate),m(r,a.img,0,0,a.paintWidth,a.paintHeight,0,-i,n,i),this.compose(),this.restore()}paintInlineImageXObjectGroup(e,t){if(!this.contentVisible)return;let n,i=this.ctx;if(e.bitmap)n=e.bitmap;else{let t=e.width,i=e.height,r=this.cachedCanvases.getCanvas("inlineImage",t,i).context;v(r,e),n=this.applyTransferMapsToCanvas(r)}for(let r of t)i.save(),i.transform(...r.transform),i.scale(1,-1),m(i,n,r.x,r.y,r.w,r.h,0,-1,1,1),i.restore();this.compose()}paintSolidColorImageMask(){this.contentVisible&&(this.ctx.fillRect(0,0,1,1),this.compose())}markPoint(e){}markPointProps(e,t){}beginMarkedContent(e){this.markedContentStack.push({visible:!0})}beginMarkedContentProps(e,t){"OC"===e?this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(t)}):this.markedContentStack.push({visible:!0}),this.contentVisible=this.isContentVisible()}endMarkedContent(){this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(){}endCompat(){}consumePath(e){let t=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(e);let n=this.ctx;this.pendingClip&&(t||(this.pendingClip===C?n.clip("evenodd"):n.clip()),this.pendingClip=null),this.current.startNewPathAndClipBox(this.current.clipBox),n.beginPath()}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){let e=(0,l.getCurrentTransform)(this.ctx);if(0===e[1]&&0===e[2])this._cachedGetSinglePixelWidth=1/Math.min(Math.abs(e[0]),Math.abs(e[3]));else{let t=Math.abs(e[0]*e[3]-e[2]*e[1]),n=Math.hypot(e[0],e[2]),i=Math.hypot(e[1],e[3]);this._cachedGetSinglePixelWidth=Math.max(n,i)/t}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(-1===this._cachedScaleForStroking[0]){let e,t,{lineWidth:n}=this.current,{a:i,b:r,c:a,d:s}=this.ctx.getTransform();if(0===r&&0===a){let r=Math.abs(i),a=Math.abs(s);if(r===a)if(0===n)e=t=1/r;else{let i=r*n;e=t=i<1?1/i:1}else if(0===n)e=1/r,t=1/a;else{let i=r*n,s=a*n;e=i<1?1/i:1,t=s<1?1/s:1}}else{let o=Math.abs(i*s-r*a),l=Math.hypot(i,r),h=Math.hypot(a,s);if(0===n)e=h/o,t=l/o;else{let i=n*o;e=h>i?h/i:1,t=l>i?l/i:1}}this._cachedScaleForStroking[0]=e,this._cachedScaleForStroking[1]=t}return this._cachedScaleForStroking}rescaleAndStroke(e){let{ctx:t}=this,{lineWidth:n}=this.current,[i,r]=this.getScaleForStroking();if(t.lineWidth=n||1,1===i&&1===r)return void t.stroke();let a=t.getLineDash();if(e&&t.save(),t.scale(i,r),a.length>0){let e=Math.max(i,r);t.setLineDash(a.map((t=>t/e))),t.lineDashOffset/=e}t.stroke(),e&&t.restore()}isContentVisible(){for(let e=this.markedContentStack.length-1;e>=0;e--)if(!this.markedContentStack[e].visible)return!1;return!0}},R=P;i=new WeakSet,r=function(){for(;this.stateStack.length||this.inSMaskMode;)this.restore();this.ctx.restore(),this.transparentCanvas&&(this.ctx=this.compositeCtx,this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.drawImage(this.transparentCanvas,0,0),this.ctx.restore(),this.transparentCanvas=null)},a=new WeakSet,s=function(){if(this.pageColors){let e=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if("none"!==e){let t=this.ctx.filter;this.ctx.filter=e,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=t}}},t.CanvasGraphics=R;for(let L in o.OPS)void 0!==R.prototype[L]&&(R.prototype[o.OPS[L]]=R.prototype[L])},(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.TilingPattern=t.PathType=void 0,t.getShadingPattern=function(e){switch(e[0]){case"RadialAxial":return new l(e);case"Mesh":return new c(e);case"Dummy":return new d}throw new Error(`Unknown IR type: ${e[0]}`)};var i=n(1),r=n(6);let a={FILL:"Fill",STROKE:"Stroke",SHADING:"Shading"};function s(e,t){if(!t)return;let n=t[2]-t[0],i=t[3]-t[1],r=new Path2D;r.rect(t[0],t[1],n,i),e.clip(r)}t.PathType=a;class o{constructor(){this.constructor===o&&(0,i.unreachable)("Cannot initialize BaseShadingPattern.")}getPattern(){(0,i.unreachable)("Abstract method `getPattern` called.")}}class l extends o{constructor(e){super(),this._type=e[1],this._bbox=e[2],this._colorStops=e[3],this._p0=e[4],this._p1=e[5],this._r0=e[6],this._r1=e[7],this.matrix=null}_createGradient(e){let t;"axial"===this._type?t=e.createLinearGradient(this._p0[0],this._p0[1],this._p1[0],this._p1[1]):"radial"===this._type&&(t=e.createRadialGradient(this._p0[0],this._p0[1],this._r0,this._p1[0],this._p1[1],this._r1));for(let n of this._colorStops)t.addColorStop(n[0],n[1]);return t}getPattern(e,t,n,o){let l;if(o===a.STROKE||o===a.FILL){let a=t.current.getClippedPathBoundingBox(o,(0,r.getCurrentTransform)(e))||[0,0,0,0],h=Math.ceil(a[2]-a[0])||1,u=Math.ceil(a[3]-a[1])||1,c=t.cachedCanvases.getCanvas("pattern",h,u,!0),d=c.context;d.clearRect(0,0,d.canvas.width,d.canvas.height),d.beginPath(),d.rect(0,0,d.canvas.width,d.canvas.height),d.translate(-a[0],-a[1]),n=i.Util.transform(n,[1,0,0,1,a[0],a[1]]),d.transform(...t.baseTransform),this.matrix&&d.transform(...this.matrix),s(d,this._bbox),d.fillStyle=this._createGradient(d),d.fill(),l=e.createPattern(c.canvas,"no-repeat");let p=new DOMMatrix(n);l.setTransform(p)}else s(e,this._bbox),l=this._createGradient(e);return l}}function h(e,t,n,i,r,a,s,o){let l,h=t.coords,u=t.colors,c=e.data,d=4*e.width;h[n+1]>h[i+1]&&(l=n,n=i,i=l,l=a,a=s,s=l),h[i+1]>h[r+1]&&(l=i,i=r,r=l,l=s,s=o,o=l),h[n+1]>h[i+1]&&(l=n,n=i,i=l,l=a,a=s,s=l);let p=(h[n]+t.offsetX)*t.scaleX,f=(h[n+1]+t.offsetY)*t.scaleY,m=(h[i]+t.offsetX)*t.scaleX,g=(h[i+1]+t.offsetY)*t.scaleY,v=(h[r]+t.offsetX)*t.scaleX,y=(h[r+1]+t.offsetY)*t.scaleY;if(f>=y)return;let x,b,_,w,S,M,E,T,A=u[a],C=u[a+1],P=u[a+2],R=u[s],L=u[s+1],I=u[s+2],k=u[o],O=u[o+1],D=u[o+2],N=Math.round(f),U=Math.round(y);for(let F=N;F<=U;F++){if(F<g){let e;e=F<f?0:(f-F)/(f-g),x=p-(p-m)*e,b=A-(A-R)*e,_=C-(C-L)*e,w=P-(P-I)*e}else{let e;e=F>y?1:g===y?0:(g-F)/(g-y),x=m-(m-v)*e,b=R-(R-k)*e,_=L-(L-O)*e,w=I-(I-D)*e}let e;e=F<f?0:F>y?1:(f-F)/(f-y),S=p-(p-v)*e,M=A-(A-k)*e,E=C-(C-O)*e,T=P-(P-D)*e;let t=Math.round(Math.min(x,S)),n=Math.round(Math.max(x,S)),i=d*F+4*t;for(let r=t;r<=n;r++)e=(x-r)/(x-S),e<0?e=0:e>1&&(e=1),c[i++]=b-(b-M)*e|0,c[i++]=_-(_-E)*e|0,c[i++]=w-(w-T)*e|0,c[i++]=255}}function u(e,t,n){let i,r,a=t.coords,s=t.colors;switch(t.type){case"lattice":let o=t.verticesPerRow,l=Math.floor(a.length/o)-1,u=o-1;for(i=0;i<l;i++){let t=i*o;for(let i=0;i<u;i++,t++)h(e,n,a[t],a[t+1],a[t+o],s[t],s[t+1],s[t+o]),h(e,n,a[t+o+1],a[t+1],a[t+o],s[t+o+1],s[t+1],s[t+o])}break;case"triangles":for(i=0,r=a.length;i<r;i+=3)h(e,n,a[i],a[i+1],a[i+2],s[i],s[i+1],s[i+2]);break;default:throw new Error("illegal figure")}}class c extends o{constructor(e){super(),this._coords=e[2],this._colors=e[3],this._figures=e[4],this._bounds=e[5],this._bbox=e[7],this._background=e[8],this.matrix=null}_createMeshCanvas(e,t,n){let i=Math.floor(this._bounds[0]),r=Math.floor(this._bounds[1]),a=Math.ceil(this._bounds[2])-i,s=Math.ceil(this._bounds[3])-r,o=Math.min(Math.ceil(Math.abs(a*e[0]*1.1)),3e3),l=Math.min(Math.ceil(Math.abs(s*e[1]*1.1)),3e3),h=a/o,c=s/l,d={coords:this._coords,colors:this._colors,offsetX:-i,offsetY:-r,scaleX:1/h,scaleY:1/c},p=o+4,f=l+4,m=n.getCanvas("mesh",p,f,!1),g=m.context,v=g.createImageData(o,l);if(t){let e=v.data;for(let n=0,i=e.length;n<i;n+=4)e[n]=t[0],e[n+1]=t[1],e[n+2]=t[2],e[n+3]=255}for(let y of this._figures)u(v,y,d);return g.putImageData(v,2,2),{canvas:m.canvas,offsetX:i-2*h,offsetY:r-2*c,scaleX:h,scaleY:c}}getPattern(e,t,n,o){let l;if(s(e,this._bbox),o===a.SHADING)l=i.Util.singularValueDecompose2dScale((0,r.getCurrentTransform)(e));else if(l=i.Util.singularValueDecompose2dScale(t.baseTransform),this.matrix){let e=i.Util.singularValueDecompose2dScale(this.matrix);l=[l[0]*e[0],l[1]*e[1]]}let h=this._createMeshCanvas(l,o===a.SHADING?null:this._background,t.cachedCanvases);return o!==a.SHADING&&(e.setTransform(...t.baseTransform),this.matrix&&e.transform(...this.matrix)),e.translate(h.offsetX,h.offsetY),e.scale(h.scaleX,h.scaleY),e.createPattern(h.canvas,"no-repeat")}}class d extends o{getPattern(){return"hotpink"}}let p=class{constructor(e,t,n,i,r){this.operatorList=e[2],this.matrix=e[3]||[1,0,0,1,0,0],this.bbox=e[4],this.xstep=e[5],this.ystep=e[6],this.paintType=e[7],this.tilingType=e[8],this.color=t,this.ctx=n,this.canvasGraphicsFactory=i,this.baseTransform=r}createPatternCanvas(e){let t=this.operatorList,n=this.bbox,a=this.xstep,s=this.ystep,o=this.paintType,l=this.tilingType,h=this.color,u=this.canvasGraphicsFactory;(0,i.info)("TilingType: "+l);let c=n[0],d=n[1],p=n[2],f=n[3],m=i.Util.singularValueDecompose2dScale(this.matrix),g=i.Util.singularValueDecompose2dScale(this.baseTransform),v=[m[0]*g[0],m[1]*g[1]],y=this.getSizeAndScale(a,this.ctx.canvas.width,v[0]),x=this.getSizeAndScale(s,this.ctx.canvas.height,v[1]),b=e.cachedCanvases.getCanvas("pattern",y.size,x.size,!0),_=b.context,w=u.createCanvasGraphics(_);w.groupLevel=e.groupLevel,this.setFillAndStrokeStyleToContext(w,o,h);let S=c,M=d,E=p,T=f;return c<0&&(S=0,E+=Math.abs(c)),d<0&&(M=0,T+=Math.abs(d)),_.translate(-y.scale*S,-x.scale*M),w.transform(y.scale,0,0,x.scale,0,0),_.save(),this.clipBbox(w,S,M,E,T),w.baseTransform=(0,r.getCurrentTransform)(w.ctx),w.executeOperatorList(t),w.endDrawing(),{canvas:b.canvas,scaleX:y.scale,scaleY:x.scale,offsetX:S,offsetY:M}}getSizeAndScale(e,t,n){e=Math.abs(e);let i=Math.max(p.MAX_PATTERN_SIZE,t),r=Math.ceil(e*n);return r>=i?r=i:n=r/e,{scale:n,size:r}}clipBbox(e,t,n,i,a){let s=i-t,o=a-n;e.ctx.rect(t,n,s,o),e.current.updateRectMinMax((0,r.getCurrentTransform)(e.ctx),[t,n,i,a]),e.clip(),e.endPath()}setFillAndStrokeStyleToContext(e,t,n){let r=e.ctx,a=e.current;switch(t){case 1:let e=this.ctx;r.fillStyle=e.fillStyle,r.strokeStyle=e.strokeStyle,a.fillColor=e.fillStyle,a.strokeColor=e.strokeStyle;break;case 2:let s=i.Util.makeHexColor(n[0],n[1],n[2]);r.fillStyle=s,r.strokeStyle=s,a.fillColor=s,a.strokeColor=s;break;default:throw new i.FormatError(`Unsupported paint type: ${t}`)}}getPattern(e,t,n,r){let s=n;r!==a.SHADING&&(s=i.Util.transform(s,t.baseTransform),this.matrix&&(s=i.Util.transform(s,this.matrix)));let o=this.createPatternCanvas(t),l=new DOMMatrix(s);l=l.translate(o.offsetX,o.offsetY),l=l.scale(1/o.scaleX,1/o.scaleY);let h=e.createPattern(o.canvas,"repeat");return h.setTransform(l),h}},f=p;Yi(f,"MAX_PATTERN_SIZE",3e3),t.TilingPattern=f},(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.convertBlackAndWhiteToRGBA=r,t.convertToRGBA=function(e){switch(e.kind){case i.ImageKind.GRAYSCALE_1BPP:return r(e);case i.ImageKind.RGB_24BPP:return function({src:e,srcPos:t=0,dest:n,destPos:r=0,width:a,height:s}){let o=0,l=e.length>>2,h=new Uint32Array(e.buffer,t,l);if(i.FeatureTest.isLittleEndian){for(;o<l-2;o+=3,r+=4){let e=h[o],t=h[o+1],i=h[o+2];n[r]=4278190080|e,n[r+1]=e>>>24|t<<8|4278190080,n[r+2]=t>>>16|i<<16|4278190080,n[r+3]=i>>>8|4278190080}for(let t=4*o,i=e.length;t<i;t+=3)n[r++]=e[t]|e[t+1]<<8|e[t+2]<<16|4278190080}else{for(;o<l-2;o+=3,r+=4){let e=h[o],t=h[o+1],i=h[o+2];n[r]=255|e,n[r+1]=e<<24|t>>>8|255,n[r+2]=t<<16|i>>>16|255,n[r+3]=i<<8|255}for(let t=4*o,i=e.length;t<i;t+=3)n[r++]=e[t]<<24|e[t+1]<<16|e[t+2]<<8|255}return{srcPos:t,destPos:r}}(e)}return null},t.grayToRGBA=function(e,t){if(i.FeatureTest.isLittleEndian)for(let n=0,i=e.length;n<i;n++)t[n]=65793*e[n]|4278190080;else for(let n=0,i=e.length;n<i;n++)t[n]=16843008*e[n]|255};var i=n(1);function r({src:e,srcPos:t=0,dest:n,width:r,height:a,nonBlackColor:s=4294967295,inverseDecode:o=!1}){let l=i.FeatureTest.isLittleEndian?4278190080:255,[h,u]=o?[s,l]:[l,s],c=r>>3,d=7&r,p=e.length;n=new Uint32Array(n.buffer);let f=0;for(let i=0;i<a;i++){for(let r=t+c;t<r;t++){let i=t<p?e[t]:255;n[f++]=128&i?u:h,n[f++]=64&i?u:h,n[f++]=32&i?u:h,n[f++]=16&i?u:h,n[f++]=8&i?u:h,n[f++]=4&i?u:h,n[f++]=2&i?u:h,n[f++]=1&i?u:h}if(0===d)continue;let i=t<p?e[t++]:255;for(let e=0;e<d;e++)n[f++]=i&1<<7-e?u:h}return{srcPos:t,destPos:f}}},(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.GlobalWorkerOptions=void 0;let n=Object.create(null);t.GlobalWorkerOptions=n,n.workerPort=null,n.workerSrc=""},(e,t,n)=>{var i,r,a,s,o,l;Object.defineProperty(t,"__esModule",{value:!0}),t.MessageHandler=void 0;var h=n(1);function u(e){switch(e instanceof Error||"object"==typeof e&&null!==e||(0,h.unreachable)('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),e.name){case"AbortException":return new h.AbortException(e.message);case"MissingPDFException":return new h.MissingPDFException(e.message);case"PasswordException":return new h.PasswordException(e.message,e.code);case"UnexpectedResponseException":return new h.UnexpectedResponseException(e.message,e.status);case"UnknownErrorException":return new h.UnknownErrorException(e.message,e.details);default:return new h.UnknownErrorException(e.message,e.toString())}}i=new WeakSet,r=function(e){let t=e.streamId,n=this.sourceName,i=e.sourceName,r=this.comObj,a=this,s=this.actionHandler[e.action],o={enqueue(e,a=1,s){if(this.isCancelled)return;let o=this.desiredSize;this.desiredSize-=a,o>0&&this.desiredSize<=0&&(this.sinkCapability=new h.PromiseCapability,this.ready=this.sinkCapability.promise),r.postMessage({sourceName:n,targetName:i,stream:4,streamId:t,chunk:e},s)},close(){this.isCancelled||(this.isCancelled=!0,r.postMessage({sourceName:n,targetName:i,stream:3,streamId:t}),delete a.streamSinks[t])},error(e){(0,h.assert)(e instanceof Error,"error must have a valid reason"),!this.isCancelled&&(this.isCancelled=!0,r.postMessage({sourceName:n,targetName:i,stream:5,streamId:t,reason:u(e)}))},sinkCapability:new h.PromiseCapability,onPull:null,onCancel:null,isCancelled:!1,desiredSize:e.desiredSize,ready:null};o.sinkCapability.resolve(),o.ready=o.sinkCapability.promise,this.streamSinks[t]=o,new Promise((function(t){t(s(e.data,o))})).then((function(){r.postMessage({sourceName:n,targetName:i,stream:8,streamId:t,success:!0})}),(function(e){r.postMessage({sourceName:n,targetName:i,stream:8,streamId:t,reason:u(e)})}))},a=new WeakSet,s=function(e){let t=e.streamId,n=this.sourceName,i=e.sourceName,r=this.comObj,a=this.streamControllers[t],s=this.streamSinks[t];switch(e.stream){case 8:e.success?a.startCall.resolve():a.startCall.reject(u(e.reason));break;case 7:e.success?a.pullCall.resolve():a.pullCall.reject(u(e.reason));break;case 6:if(!s){r.postMessage({sourceName:n,targetName:i,stream:7,streamId:t,success:!0});break}s.desiredSize<=0&&e.desiredSize>0&&s.sinkCapability.resolve(),s.desiredSize=e.desiredSize,new Promise((function(e){var t;e(null==(t=s.onPull)?void 0:t.call(s))})).then((function(){r.postMessage({sourceName:n,targetName:i,stream:7,streamId:t,success:!0})}),(function(e){r.postMessage({sourceName:n,targetName:i,stream:7,streamId:t,reason:u(e)})}));break;case 4:if((0,h.assert)(a,"enqueue should have stream controller"),a.isClosed)break;a.controller.enqueue(e.chunk);break;case 3:if((0,h.assert)(a,"close should have stream controller"),a.isClosed)break;a.isClosed=!0,a.controller.close(),ft(this,o,l).call(this,a,t);break;case 5:(0,h.assert)(a,"error should have stream controller"),a.controller.error(u(e.reason)),ft(this,o,l).call(this,a,t);break;case 2:e.success?a.cancelCall.resolve():a.cancelCall.reject(u(e.reason)),ft(this,o,l).call(this,a,t);break;case 1:if(!s)break;new Promise((function(t){var n;t(null==(n=s.onCancel)?void 0:n.call(s,u(e.reason)))})).then((function(){r.postMessage({sourceName:n,targetName:i,stream:2,streamId:t,success:!0})}),(function(e){r.postMessage({sourceName:n,targetName:i,stream:2,streamId:t,reason:u(e)})})),s.sinkCapability.reject(u(e.reason)),s.isCancelled=!0,delete this.streamSinks[t];break;default:throw new Error("Unexpected stream case")}},o=new WeakSet,l=function(e,t){return it(this,null,(function*(){var n,i,r;yield Promise.allSettled([null==(n=e.startCall)?void 0:n.promise,null==(i=e.pullCall)?void 0:i.promise,null==(r=e.cancelCall)?void 0:r.promise]),delete this.streamControllers[t]}))},t.MessageHandler=class{constructor(e,t,n){Je(this,i),Je(this,a),Je(this,o),this.sourceName=e,this.targetName=t,this.comObj=n,this.callbackId=1,this.streamId=1,this.streamSinks=Object.create(null),this.streamControllers=Object.create(null),this.callbackCapabilities=Object.create(null),this.actionHandler=Object.create(null),this._onComObjOnMessage=e=>{let t=e.data;if(t.targetName!==this.sourceName)return;if(t.stream)return void ft(this,a,s).call(this,t);if(t.callback){let e=t.callbackId,n=this.callbackCapabilities[e];if(!n)throw new Error(`Cannot resolve callback ${e}`);if(delete this.callbackCapabilities[e],1===t.callback)n.resolve(t.data);else{if(2!==t.callback)throw new Error("Unexpected callback case");n.reject(u(t.reason))}return}let o=this.actionHandler[t.action];if(!o)throw new Error(`Unknown action from worker: ${t.action}`);if(t.callbackId){let e=this.sourceName,i=t.sourceName;new Promise((function(e){e(o(t.data))})).then((function(r){n.postMessage({sourceName:e,targetName:i,callback:1,callbackId:t.callbackId,data:r})}),(function(r){n.postMessage({sourceName:e,targetName:i,callback:2,callbackId:t.callbackId,reason:u(r)})}))}else t.streamId?ft(this,i,r).call(this,t):o(t.data)},n.addEventListener("message",this._onComObjOnMessage)}on(e,t){let n=this.actionHandler;if(n[e])throw new Error(`There is already an actionName called "${e}"`);n[e]=t}send(e,t,n){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:e,data:t},n)}sendWithPromise(e,t,n){let i=this.callbackId++,r=new h.PromiseCapability;this.callbackCapabilities[i]=r;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:e,callbackId:i,data:t},n)}catch(e){r.reject(e)}return r.promise}sendWithStream(e,t,n,i){let r=this.streamId++,a=this.sourceName,s=this.targetName,o=this.comObj;return new ReadableStream({start:n=>{let l=new h.PromiseCapability;return this.streamControllers[r]={controller:n,startCall:l,pullCall:null,cancelCall:null,isClosed:!1},o.postMessage({sourceName:a,targetName:s,action:e,streamId:r,data:t,desiredSize:n.desiredSize},i),l.promise},pull:e=>{let t=new h.PromiseCapability;return this.streamControllers[r].pullCall=t,o.postMessage({sourceName:a,targetName:s,stream:6,streamId:r,desiredSize:e.desiredSize}),t.promise},cancel:e=>{(0,h.assert)(e instanceof Error,"cancel must have a valid reason");let t=new h.PromiseCapability;return this.streamControllers[r].cancelCall=t,this.streamControllers[r].isClosed=!0,o.postMessage({sourceName:a,targetName:s,stream:1,streamId:r,reason:u(e)}),t.promise}},n)}destroy(){this.comObj.removeEventListener("message",this._onComObjOnMessage)}}},(e,t,n)=>{var i,r;Object.defineProperty(t,"__esModule",{value:!0}),t.Metadata=void 0;var a=n(1);i=new WeakMap,r=new WeakMap,t.Metadata=class{constructor({parsedData:e,rawData:t}){Je(this,i,void 0),Je(this,r,void 0),wt(this,i,e),wt(this,r,t)}getRaw(){return le(this,r)}get(e){var t;return null!=(t=le(this,i).get(e))?t:null}getAll(){return(0,a.objectFromMap)(le(this,i))}has(e){return le(this,i).has(e)}}},(e,t,n)=>{var i,r,a,s,o,l,h;Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalContentConfig=void 0;var u=n(1),c=n(8);let d=Symbol("INTERNAL");class p{constructor(e,t){Je(this,i,!0),this.name=e,this.intent=t}get visible(){return le(this,i)}_setVisible(e,t){e!==d&&(0,u.unreachable)("Internal method `_setVisible` called."),wt(this,i,t)}}i=new WeakMap,r=new WeakMap,a=new WeakMap,s=new WeakMap,o=new WeakMap,l=new WeakSet,h=function(e){let t=e.length;if(t<2)return!0;let n=e[0];for(let i=1;i<t;i++){let t,r=e[i];if(Array.isArray(r))t=ft(this,l,h).call(this,r);else{if(!le(this,a).has(r))return(0,u.warn)(`Optional content group not found: ${r}`),!0;t=le(this,a).get(r).visible}switch(n){case"And":if(!t)return!1;break;case"Or":if(t)return!0;break;case"Not":return!t;default:return!0}}return"And"===n},t.OptionalContentConfig=class{constructor(e){if(Je(this,l),Je(this,r,null),Je(this,a,new Map),Je(this,s,null),Je(this,o,null),this.name=null,this.creator=null,null!==e){this.name=e.name,this.creator=e.creator,wt(this,o,e.order);for(let t of e.groups)le(this,a).set(t.id,new p(t.name,t.intent));if("OFF"===e.baseState)for(let e of le(this,a).values())e._setVisible(d,!1);for(let t of e.on)le(this,a).get(t)._setVisible(d,!0);for(let t of e.off)le(this,a).get(t)._setVisible(d,!1);wt(this,s,this.getHash())}}isVisible(e){if(0===le(this,a).size)return!0;if(!e)return(0,u.warn)("Optional content group not defined."),!0;if("OCG"===e.type)return le(this,a).has(e.id)?le(this,a).get(e.id).visible:((0,u.warn)(`Optional content group not found: ${e.id}`),!0);if("OCMD"===e.type){if(e.expression)return ft(this,l,h).call(this,e.expression);if(!e.policy||"AnyOn"===e.policy){for(let t of e.ids){if(!le(this,a).has(t))return(0,u.warn)(`Optional content group not found: ${t}`),!0;if(le(this,a).get(t).visible)return!0}return!1}if("AllOn"===e.policy){for(let t of e.ids){if(!le(this,a).has(t))return(0,u.warn)(`Optional content group not found: ${t}`),!0;if(!le(this,a).get(t).visible)return!1}return!0}if("AnyOff"===e.policy){for(let t of e.ids){if(!le(this,a).has(t))return(0,u.warn)(`Optional content group not found: ${t}`),!0;if(!le(this,a).get(t).visible)return!0}return!1}if("AllOff"===e.policy){for(let t of e.ids){if(!le(this,a).has(t))return(0,u.warn)(`Optional content group not found: ${t}`),!0;if(le(this,a).get(t).visible)return!1}return!0}return(0,u.warn)(`Unknown optional content policy ${e.policy}.`),!0}return(0,u.warn)(`Unknown group type ${e.type}.`),!0}setVisibility(e,t=!0){le(this,a).has(e)?(le(this,a).get(e)._setVisible(d,!!t),wt(this,r,null)):(0,u.warn)(`Optional content group not found: ${e}`)}get hasInitialVisibility(){return this.getHash()===le(this,s)}getOrder(){return le(this,a).size?le(this,o)?le(this,o).slice():[...le(this,a).keys()]:null}getGroups(){return le(this,a).size>0?(0,u.objectFromMap)(le(this,a)):null}getGroup(e){return le(this,a).get(e)||null}getHash(){if(null!==le(this,r))return le(this,r);let e=new c.MurmurHash3_64;for(let[t,n]of le(this,a))e.update(`${t}:${n.visible}`);return wt(this,r,e.hexdigest())}}},(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PDFDataTransportStream=void 0;var i=n(1),r=n(6);t.PDFDataTransportStream=class{constructor({length:e,initialData:t,progressiveDone:n=!1,contentDispositionFilename:r=null,disableRange:a=!1,disableStream:s=!1},o){if((0,i.assert)(o,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.'),this._queuedChunks=[],this._progressiveDone=n,this._contentDispositionFilename=r,(null==t?void 0:t.length)>0){let e=t instanceof Uint8Array&&t.byteLength===t.buffer.byteLength?t.buffer:new Uint8Array(t).buffer;this._queuedChunks.push(e)}this._pdfDataRangeTransport=o,this._isStreamingSupported=!s,this._isRangeSupported=!a,this._contentLength=e,this._fullRequestReader=null,this._rangeReaders=[],this._pdfDataRangeTransport.addRangeListener(((e,t)=>{this._onReceiveData({begin:e,chunk:t})})),this._pdfDataRangeTransport.addProgressListener(((e,t)=>{this._onProgress({loaded:e,total:t})})),this._pdfDataRangeTransport.addProgressiveReadListener((e=>{this._onReceiveData({chunk:e})})),this._pdfDataRangeTransport.addProgressiveDoneListener((()=>{this._onProgressiveDone()})),this._pdfDataRangeTransport.transportReady()}_onReceiveData({begin:e,chunk:t}){let n=t instanceof Uint8Array&&t.byteLength===t.buffer.byteLength?t.buffer:new Uint8Array(t).buffer;if(void 0===e)this._fullRequestReader?this._fullRequestReader._enqueue(n):this._queuedChunks.push(n);else{let t=this._rangeReaders.some((function(t){return t._begin===e&&(t._enqueue(n),!0)}));(0,i.assert)(t,"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}}get _progressiveDataLength(){var e,t;return null!=(t=null==(e=this._fullRequestReader)?void 0:e._loaded)?t:0}_onProgress(e){var t,n,i,r;void 0===e.total?null==(n=null==(t=this._rangeReaders[0])?void 0:t.onProgress)||n.call(t,{loaded:e.loaded}):null==(r=null==(i=this._fullRequestReader)?void 0:i.onProgress)||r.call(i,{loaded:e.loaded,total:e.total})}_onProgressiveDone(){var e;null==(e=this._fullRequestReader)||e.progressiveDone(),this._progressiveDone=!0}_removeRangeReader(e){let t=this._rangeReaders.indexOf(e);t>=0&&this._rangeReaders.splice(t,1)}getFullReader(){(0,i.assert)(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");let e=this._queuedChunks;return this._queuedChunks=null,new a(this,e,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(e,t){if(t<=this._progressiveDataLength)return null;let n=new s(this,e,t);return this._pdfDataRangeTransport.requestDataRange(e,t),this._rangeReaders.push(n),n}cancelAllRequests(e){var t;null==(t=this._fullRequestReader)||t.cancel(e);for(let n of this._rangeReaders.slice(0))n.cancel(e);this._pdfDataRangeTransport.abort()}};class a{constructor(e,t,n=!1,i=null){this._stream=e,this._done=n||!1,this._filename=(0,r.isPdfFile)(i)?i:null,this._queuedChunks=t||[],this._loaded=0;for(let r of this._queuedChunks)this._loaded+=r.byteLength;this._requests=[],this._headersReady=Promise.resolve(),e._fullRequestReader=this,this.onProgress=null}_enqueue(e){this._done||(this._requests.length>0?this._requests.shift().resolve({value:e,done:!1}):this._queuedChunks.push(e),this._loaded+=e.byteLength)}get headersReady(){return this._headersReady}get filename(){return this._filename}get isRangeSupported(){return this._stream._isRangeSupported}get isStreamingSupported(){return this._stream._isStreamingSupported}get contentLength(){return this._stream._contentLength}read(){return it(this,null,(function*(){if(this._queuedChunks.length>0)return{value:this._queuedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};let e=new i.PromiseCapability;return this._requests.push(e),e.promise}))}cancel(e){this._done=!0;for(let t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0}progressiveDone(){this._done||(this._done=!0)}}class s{constructor(e,t,n){this._stream=e,this._begin=t,this._end=n,this._queuedChunk=null,this._requests=[],this._done=!1,this.onProgress=null}_enqueue(e){if(!this._done){if(0===this._requests.length)this._queuedChunk=e;else{this._requests.shift().resolve({value:e,done:!1});for(let e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}this._done=!0,this._stream._removeRangeReader(this)}}get isStreamingSupported(){return!1}read(){return it(this,null,(function*(){if(this._queuedChunk){let e=this._queuedChunk;return this._queuedChunk=null,{value:e,done:!1}}if(this._done)return{value:void 0,done:!0};let e=new i.PromiseCapability;return this._requests.push(e),e.promise}))}cancel(e){this._done=!0;for(let t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0,this._stream._removeRangeReader(this)}}},(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.XfaText=void 0;class n{static textContent(e){let t=[],i={items:t,styles:Object.create(null)};return function e(i){var r;if(!i)return;let a=null,s=i.name;if("#text"===s)a=i.value;else{if(!n.shouldBuildText(s))return;null!=(r=null==i?void 0:i.attributes)&&r.textContent?a=i.attributes.textContent:i.value&&(a=i.value)}if(null!==a&&t.push({str:a}),i.children)for(let t of i.children)e(t)}(e),i}static shouldBuildText(e){return!("textarea"===e||"input"===e||"option"===e||"select"===e)}}t.XfaText=n},(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.NodeStandardFontDataFactory=t.NodeFilterFactory=t.NodeCanvasFactory=t.NodeCMapReaderFactory=void 0;var i=n(7);let r=function(e){return new Promise(((t,n)=>{dC().readFile(e,((e,i)=>{!e&&i?t(new Uint8Array(i)):n(new Error(e))}))}))};class a extends i.BaseFilterFactory{}t.NodeFilterFactory=a;class s extends i.BaseCanvasFactory{_createCanvas(e,t){return b1e().createCanvas(e,t)}}t.NodeCanvasFactory=s;class o extends i.BaseCMapReaderFactory{_fetchData(e,t){return r(e).then((e=>({cMapData:e,compressionType:t})))}}t.NodeCMapReaderFactory=o;class l extends i.BaseStandardFontDataFactory{_fetchData(e){return r(e)}}t.NodeStandardFontDataFactory=l},(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PDFNodeStream=void 0;var i=n(1),r=n(22);let a=dC(),s=E1e(),o=_1e(),l=T1e(),h=/^file:\/\/\/[a-zA-Z]:\//;t.PDFNodeStream=class{constructor(e){this.source=e,this.url=function(e){let t=l.parse(e);return"file:"===t.protocol||t.host?t:/^[a-z]:[/\\]/i.test(e)?l.parse(`file:///${e}`):(t.host||(t.protocol="file:"),t)}(e.url),this.isHttp="http:"===this.url.protocol||"https:"===this.url.protocol,this.isFsUrl="file:"===this.url.protocol,this.httpHeaders=this.isHttp&&e.httpHeaders||{},this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){var e,t;return null!=(t=null==(e=this._fullRequestReader)?void 0:e._loaded)?t:0}getFullReader(){return(0,i.assert)(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=this.isFsUrl?new m(this):new p(this),this._fullRequestReader}getRangeReader(e,t){if(t<=this._progressiveDataLength)return null;let n=this.isFsUrl?new g(this,e,t):new f(this,e,t);return this._rangeRequestReaders.push(n),n}cancelAllRequests(e){var t;null==(t=this._fullRequestReader)||t.cancel(e);for(let n of this._rangeRequestReaders.slice(0))n.cancel(e)}};class u{constructor(e){this._url=e.url,this._done=!1,this._storedError=null,this.onProgress=null;let t=e.source;this._contentLength=t.length,this._loaded=0,this._filename=null,this._disableRange=t.disableRange||!1,this._rangeChunkSize=t.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._isStreamingSupported=!t.disableStream,this._isRangeSupported=!t.disableRange,this._readableStream=null,this._readCapability=new i.PromiseCapability,this._headersCapability=new i.PromiseCapability}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}read(){return it(this,null,(function*(){var e;if(yield this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;let t=this._readableStream.read();return null===t?(this._readCapability=new i.PromiseCapability,this.read()):(this._loaded+=t.length,null==(e=this.onProgress)||e.call(this,{loaded:this._loaded,total:this._contentLength}),{value:new Uint8Array(t).buffer,done:!1})}))}cancel(e){this._readableStream?this._readableStream.destroy(e):this._error(e)}_error(e){this._storedError=e,this._readCapability.resolve()}_setReadableStream(e){this._readableStream=e,e.on("readable",(()=>{this._readCapability.resolve()})),e.on("end",(()=>{e.destroy(),this._done=!0,this._readCapability.resolve()})),e.on("error",(e=>{this._error(e)})),!this._isStreamingSupported&&this._isRangeSupported&&this._error(new i.AbortException("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class c{constructor(e){this._url=e.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=new i.PromiseCapability;let t=e.source;this._isStreamingSupported=!t.disableStream}get isStreamingSupported(){return this._isStreamingSupported}read(){return it(this,null,(function*(){var e;if(yield this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;let t=this._readableStream.read();return null===t?(this._readCapability=new i.PromiseCapability,this.read()):(this._loaded+=t.length,null==(e=this.onProgress)||e.call(this,{loaded:this._loaded}),{value:new Uint8Array(t).buffer,done:!1})}))}cancel(e){this._readableStream?this._readableStream.destroy(e):this._error(e)}_error(e){this._storedError=e,this._readCapability.resolve()}_setReadableStream(e){this._readableStream=e,e.on("readable",(()=>{this._readCapability.resolve()})),e.on("end",(()=>{e.destroy(),this._done=!0,this._readCapability.resolve()})),e.on("error",(e=>{this._error(e)})),this._storedError&&this._readableStream.destroy(this._storedError)}}function d(e,t){return{protocol:e.protocol,auth:e.auth,host:e.hostname,port:e.port,path:e.path,method:"GET",headers:t}}class p extends u{constructor(e){super(e);let t=t=>{if(404===t.statusCode){let e=new i.MissingPDFException(`Missing PDF "${this._url}".`);return this._storedError=e,void this._headersCapability.reject(e)}this._headersCapability.resolve(),this._setReadableStream(t);let n=e=>this._readableStream.headers[e.toLowerCase()],{allowRangeRequests:a,suggestedLength:s}=(0,r.validateRangeRequestCapabilities)({getResponseHeader:n,isHttp:e.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=a,this._contentLength=s||this._contentLength,this._filename=(0,r.extractFilenameFromHeader)(n)};this._request=null,"http:"===this._url.protocol?this._request=s.request(d(this._url,e.httpHeaders),t):this._request=o.request(d(this._url,e.httpHeaders),t),this._request.on("error",(e=>{this._storedError=e,this._headersCapability.reject(e)})),this._request.end()}}class f extends c{constructor(e,t,n){super(e),this._httpHeaders={};for(let i in e.httpHeaders){let t=e.httpHeaders[i];void 0!==t&&(this._httpHeaders[i]=t)}this._httpHeaders.Range=`bytes=${t}-${n-1}`;let r=e=>{if(404!==e.statusCode)this._setReadableStream(e);else{let e=new i.MissingPDFException(`Missing PDF "${this._url}".`);this._storedError=e}};this._request=null,"http:"===this._url.protocol?this._request=s.request(d(this._url,this._httpHeaders),r):this._request=o.request(d(this._url,this._httpHeaders),r),this._request.on("error",(e=>{this._storedError=e})),this._request.end()}}class m extends u{constructor(e){super(e);let t=decodeURIComponent(this._url.path);h.test(this._url.href)&&(t=t.replace(/^\//,"")),a.lstat(t,((e,n)=>{if(e)return"ENOENT"===e.code&&(e=new i.MissingPDFException(`Missing PDF "${t}".`)),this._storedError=e,void this._headersCapability.reject(e);this._contentLength=n.size,this._setReadableStream(a.createReadStream(t)),this._headersCapability.resolve()}))}}class g extends c{constructor(e,t,n){super(e);let i=decodeURIComponent(this._url.path);h.test(this._url.href)&&(i=i.replace(/^\//,"")),this._setReadableStream(a.createReadStream(i,{start:t,end:n-1}))}}},(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.createResponseStatusError=function(e,t){return 404===e||0===e&&t.startsWith("file:")?new i.MissingPDFException('Missing PDF "'+t+'".'):new i.UnexpectedResponseException(`Unexpected server response (${e}) while retrieving PDF "${t}".`,e)},t.extractFilenameFromHeader=function(e){let t=e("Content-Disposition");if(t){let n=(0,r.getFilenameFromContentDispositionHeader)(t);if(n.includes("%"))try{n=decodeURIComponent(n)}catch(e){}if((0,a.isPdfFile)(n))return n}return null},t.validateRangeRequestCapabilities=function({getResponseHeader:e,isHttp:t,rangeChunkSize:n,disableRange:i}){let r={allowRangeRequests:!1,suggestedLength:void 0},a=parseInt(e("Content-Length"),10);return!Number.isInteger(a)||(r.suggestedLength=a,a<=2*n)||i||!t||"bytes"!==e("Accept-Ranges")||"identity"!==(e("Content-Encoding")||"identity")||(r.allowRangeRequests=!0),r},t.validateResponseStatus=function(e){return 200===e||206===e};var i=n(1),r=n(23),a=n(6)},(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getFilenameFromContentDispositionHeader=function(e){let t=!0,n=r("filename\\*","i").exec(e);if(n){n=n[1];let e=o(n);return e=unescape(e),e=l(e),e=h(e),s(e)}if(n=function(e){let t,n=[],i=r("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;null!==(t=i.exec(e));){let[,e,i,r]=t;if(e=parseInt(e,10),e in n){if(0===e)break}else n[e]=[i,r]}let a=[];for(let r=0;r<n.length&&r in n;++r){let[e,t]=n[r];t=o(t),e&&(t=unescape(t),0===r&&(t=l(t))),a.push(t)}return a.join("")}(e),n)return s(h(n));if(n=r("filename","i").exec(e),n){n=n[1];let e=o(n);return e=h(e),s(e)}function r(e,t){return new RegExp("(?:^|;)\\s*"+e+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',t)}function a(e,n){if(e){if(!/^[\x00-\xFF]+$/.test(n))return n;try{let r=new TextDecoder(e,{fatal:!0}),a=(0,i.stringToBytes)(n);n=r.decode(a),t=!1}catch(e){}}return n}function s(e){return t&&/[\x80-\xff]/.test(e)&&(e=a("utf-8",e),t&&(e=a("iso-8859-1",e))),e}function o(e){if(e.startsWith('"')){let t=e.slice(1).split('\\"');for(let e=0;e<t.length;++e){let n=t[e].indexOf('"');-1!==n&&(t[e]=t[e].slice(0,n),t.length=e+1),t[e]=t[e].replaceAll(/\\(.)/g,"$1")}e=t.join('"')}return e}function l(e){let t=e.indexOf("'");return-1===t?e:a(e.slice(0,t),e.slice(t+1).replace(/^[^']*'/,""))}function h(e){return!e.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(e)?e:e.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,(function(e,t,n,i){if("q"===n||"Q"===n)return a(t,i=(i=i.replaceAll("_"," ")).replaceAll(/=([0-9a-fA-F]{2})/g,(function(e,t){return String.fromCharCode(parseInt(t,16))})));try{i=atob(i)}catch(e){}return a(t,i)}))}return""};var i=n(1)},(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PDFNetworkStream=void 0;var i=n(1),r=n(22);class a{constructor(e,t={}){this.url=e,this.isHttp=/^https?:/i.test(e),this.httpHeaders=this.isHttp&&t.httpHeaders||Object.create(null),this.withCredentials=t.withCredentials||!1,this.currXhrId=0,this.pendingRequests=Object.create(null)}requestRange(e,t,n){let i={begin:e,end:t};for(let r in n)i[r]=n[r];return this.request(i)}requestFull(e){return this.request(e)}request(e){let t=new XMLHttpRequest,n=this.currXhrId++,i=this.pendingRequests[n]={xhr:t};t.open("GET",this.url),t.withCredentials=this.withCredentials;for(let r in this.httpHeaders){let e=this.httpHeaders[r];void 0!==e&&t.setRequestHeader(r,e)}return this.isHttp&&"begin"in e&&"end"in e?(t.setRequestHeader("Range",`bytes=${e.begin}-${e.end-1}`),i.expectedStatus=206):i.expectedStatus=200,t.responseType="arraybuffer",e.onError&&(t.onerror=function(n){e.onError(t.status)}),t.onreadystatechange=this.onStateChange.bind(this,n),t.onprogress=this.onProgress.bind(this,n),i.onHeadersReceived=e.onHeadersReceived,i.onDone=e.onDone,i.onError=e.onError,i.onProgress=e.onProgress,t.send(null),n}onProgress(e,t){var n;let i=this.pendingRequests[e];i&&(null==(n=i.onProgress)||n.call(i,t))}onStateChange(e,t){var n,r,a;let s=this.pendingRequests[e];if(!s)return;let o=s.xhr;if(o.readyState>=2&&s.onHeadersReceived&&(s.onHeadersReceived(),delete s.onHeadersReceived),4!==o.readyState||!(e in this.pendingRequests))return;if(delete this.pendingRequests[e],0===o.status&&this.isHttp)return void(null==(n=s.onError)||n.call(s,o.status));let l=o.status||200;if((200!==l||206!==s.expectedStatus)&&l!==s.expectedStatus)return void(null==(r=s.onError)||r.call(s,o.status));let h=function(e){let t=e.response;return"string"!=typeof t?t:(0,i.stringToBytes)(t).buffer}(o);if(206===l){let e=o.getResponseHeader("Content-Range"),t=/bytes (\d+)-(\d+)\/(\d+)/.exec(e);s.onDone({begin:parseInt(t[1],10),chunk:h})}else h?s.onDone({begin:0,chunk:h}):null==(a=s.onError)||a.call(s,o.status)}getRequestXhr(e){return this.pendingRequests[e].xhr}isPendingRequest(e){return e in this.pendingRequests}abortRequest(e){let t=this.pendingRequests[e].xhr;delete this.pendingRequests[e],t.abort()}}t.PDFNetworkStream=class{constructor(e){this._source=e,this._manager=new a(e.url,{httpHeaders:e.httpHeaders,withCredentials:e.withCredentials}),this._rangeChunkSize=e.rangeChunkSize,this._fullRequestReader=null,this._rangeRequestReaders=[]}_onRangeRequestReaderClosed(e){let t=this._rangeRequestReaders.indexOf(e);t>=0&&this._rangeRequestReaders.splice(t,1)}getFullReader(){return(0,i.assert)(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new s(this._manager,this._source),this._fullRequestReader}getRangeReader(e,t){let n=new o(this._manager,e,t);return n.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(n),n}cancelAllRequests(e){var t;null==(t=this._fullRequestReader)||t.cancel(e);for(let n of this._rangeRequestReaders.slice(0))n.cancel(e)}};class s{constructor(e,t){this._manager=e;let n={onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)};this._url=t.url,this._fullRequestId=e.requestFull(n),this._headersReceivedCapability=new i.PromiseCapability,this._disableRange=t.disableRange||!1,this._contentLength=t.length,this._rangeChunkSize=t.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._isStreamingSupported=!1,this._isRangeSupported=!1,this._cachedChunks=[],this._requests=[],this._done=!1,this._storedError=void 0,this._filename=null,this.onProgress=null}_onHeadersReceived(){let e=this._fullRequestId,t=this._manager.getRequestXhr(e),n=e=>t.getResponseHeader(e),{allowRangeRequests:i,suggestedLength:a}=(0,r.validateRangeRequestCapabilities)({getResponseHeader:n,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});i&&(this._isRangeSupported=!0),this._contentLength=a||this._contentLength,this._filename=(0,r.extractFilenameFromHeader)(n),this._isRangeSupported&&this._manager.abortRequest(e),this._headersReceivedCapability.resolve()}_onDone(e){if(e&&(this._requests.length>0?this._requests.shift().resolve({value:e.chunk,done:!1}):this._cachedChunks.push(e.chunk)),this._done=!0,!(this._cachedChunks.length>0)){for(let e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}}_onError(e){this._storedError=(0,r.createResponseStatusError)(e,this._url),this._headersReceivedCapability.reject(this._storedError);for(let t of this._requests)t.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}_onProgress(e){var t;null==(t=this.onProgress)||t.call(this,{loaded:e.loaded,total:e.lengthComputable?e.total:this._contentLength})}get filename(){return this._filename}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}get contentLength(){return this._contentLength}get headersReady(){return this._headersReceivedCapability.promise}read(){return it(this,null,(function*(){if(this._storedError)throw this._storedError;if(this._cachedChunks.length>0)return{value:this._cachedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};let e=new i.PromiseCapability;return this._requests.push(e),e.promise}))}cancel(e){this._done=!0,this._headersReceivedCapability.reject(e);for(let t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._fullRequestId)&&this._manager.abortRequest(this._fullRequestId),this._fullRequestReader=null}}class o{constructor(e,t,n){this._manager=e;let i={onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)};this._url=e.url,this._requestId=e.requestRange(t,n,i),this._requests=[],this._queuedChunk=null,this._done=!1,this._storedError=void 0,this.onProgress=null,this.onClosed=null}_close(){var e;null==(e=this.onClosed)||e.call(this,this)}_onDone(e){let t=e.chunk;this._requests.length>0?this._requests.shift().resolve({value:t,done:!1}):this._queuedChunk=t,this._done=!0;for(let n of this._requests)n.resolve({value:void 0,done:!0});this._requests.length=0,this._close()}_onError(e){this._storedError=(0,r.createResponseStatusError)(e,this._url);for(let t of this._requests)t.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}_onProgress(e){var t;this.isStreamingSupported||null==(t=this.onProgress)||t.call(this,{loaded:e.loaded})}get isStreamingSupported(){return!1}read(){return it(this,null,(function*(){if(this._storedError)throw this._storedError;if(null!==this._queuedChunk){let e=this._queuedChunk;return this._queuedChunk=null,{value:e,done:!1}}if(this._done)return{value:void 0,done:!0};let e=new i.PromiseCapability;return this._requests.push(e),e.promise}))}cancel(e){this._done=!0;for(let t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._requestId)&&this._manager.abortRequest(this._requestId),this._close()}}},(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PDFFetchStream=void 0;var i=n(1),r=n(22);function a(e,t,n){return{method:"GET",headers:e,signal:n.signal,mode:"cors",credentials:t?"include":"same-origin",redirect:"follow"}}function s(e){let t=new Headers;for(let n in e){let i=e[n];void 0!==i&&t.append(n,i)}return t}function o(e){return e instanceof Uint8Array?e.buffer:e instanceof ArrayBuffer?e:((0,i.warn)(`getArrayBuffer - unexpected data format: ${e}`),new Uint8Array(e).buffer)}t.PDFFetchStream=class{constructor(e){this.source=e,this.isHttp=/^https?:/i.test(e.url),this.httpHeaders=this.isHttp&&e.httpHeaders||{},this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){var e,t;return null!=(t=null==(e=this._fullRequestReader)?void 0:e._loaded)?t:0}getFullReader(){return(0,i.assert)(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new l(this),this._fullRequestReader}getRangeReader(e,t){if(t<=this._progressiveDataLength)return null;let n=new h(this,e,t);return this._rangeRequestReaders.push(n),n}cancelAllRequests(e){var t;null==(t=this._fullRequestReader)||t.cancel(e);for(let n of this._rangeRequestReaders.slice(0))n.cancel(e)}};class l{constructor(e){this._stream=e,this._reader=null,this._loaded=0,this._filename=null;let t=e.source;this._withCredentials=t.withCredentials||!1,this._contentLength=t.length,this._headersCapability=new i.PromiseCapability,this._disableRange=t.disableRange||!1,this._rangeChunkSize=t.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._abortController=new AbortController,this._isStreamingSupported=!t.disableStream,this._isRangeSupported=!t.disableRange,this._headers=s(this._stream.httpHeaders);let n=t.url;fetch(n,a(this._headers,this._withCredentials,this._abortController)).then((e=>{if(!(0,r.validateResponseStatus)(e.status))throw(0,r.createResponseStatusError)(e.status,n);this._reader=e.body.getReader(),this._headersCapability.resolve();let t=t=>e.headers.get(t),{allowRangeRequests:a,suggestedLength:s}=(0,r.validateRangeRequestCapabilities)({getResponseHeader:t,isHttp:this._stream.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=a,this._contentLength=s||this._contentLength,this._filename=(0,r.extractFilenameFromHeader)(t),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new i.AbortException("Streaming is disabled."))})).catch(this._headersCapability.reject),this.onProgress=null}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}read(){return it(this,null,(function*(){var e;yield this._headersCapability.promise;let{value:t,done:n}=yield this._reader.read();return n?{value:t,done:n}:(this._loaded+=t.byteLength,null==(e=this.onProgress)||e.call(this,{loaded:this._loaded,total:this._contentLength}),{value:o(t),done:!1})}))}cancel(e){var t;null==(t=this._reader)||t.cancel(e),this._abortController.abort()}}class h{constructor(e,t,n){this._stream=e,this._reader=null,this._loaded=0;let o=e.source;this._withCredentials=o.withCredentials||!1,this._readCapability=new i.PromiseCapability,this._isStreamingSupported=!o.disableStream,this._abortController=new AbortController,this._headers=s(this._stream.httpHeaders),this._headers.append("Range",`bytes=${t}-${n-1}`);let l=o.url;fetch(l,a(this._headers,this._withCredentials,this._abortController)).then((e=>{if(!(0,r.validateResponseStatus)(e.status))throw(0,r.createResponseStatusError)(e.status,l);this._readCapability.resolve(),this._reader=e.body.getReader()})).catch(this._readCapability.reject),this.onProgress=null}get isStreamingSupported(){return this._isStreamingSupported}read(){return it(this,null,(function*(){var e;yield this._readCapability.promise;let{value:t,done:n}=yield this._reader.read();return n?{value:t,done:n}:(this._loaded+=t.byteLength,null==(e=this.onProgress)||e.call(this,{loaded:this._loaded}),{value:o(t),done:!1})}))}cancel(e){var t;null==(t=this._reader)||t.cancel(e),this._abortController.abort()}}},(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.TextLayerRenderTask=void 0,t.renderTextLayer=function(e){!e.textContentSource&&(e.textContent||e.textContentStream)&&((0,r.deprecated)("The TextLayerRender `textContent`/`textContentStream` parameters will be removed in the future, please use `textContentSource` instead."),e.textContentSource=e.textContent||e.textContentStream);let{container:t,viewport:n}=e,i=getComputedStyle(t),a=i.getPropertyValue("visibility"),s=parseFloat(i.getPropertyValue("--scale-factor"));"visible"===a&&(!s||Math.abs(s-n.scale)>1e-5)&&console.error("The `--scale-factor` CSS-variable must be set, to the same value as `viewport.scale`, either on the `container`-element itself or higher up in the DOM.");let o=new u(e);return o._render(),o},t.updateTextLayer=function({container:e,viewport:t,textDivs:n,textDivProperties:i,isOffscreenCanvasSupported:a,mustRotate:s=!0,mustRescale:l=!0}){if(s&&(0,r.setLayerDimensions)(e,{rotation:t.rotation}),l){let e=o(0,a),r={prevFontSize:null,prevFontFamily:null,div:null,scale:t.scale*(globalThis.devicePixelRatio||1),properties:null,ctx:e};for(let t of n)r.properties=i.get(t),r.div=t,h(r)}};var i=n(1),r=n(6);let a=30,s=new Map;function o(e,t){let n;if(t&&i.FeatureTest.isOffscreenCanvasSupported)n=new OffscreenCanvas(e,e).getContext("2d",{alpha:!1});else{let t=document.createElement("canvas");t.width=t.height=e,n=t.getContext("2d",{alpha:!1})}return n}function l(e,t,n){let r=document.createElement("span"),l={angle:0,canvasWidth:0,hasText:""!==t.str,hasEOL:t.hasEOL,fontSize:0};e._textDivs.push(r);let h=i.Util.transform(e._transform,t.transform),u=Math.atan2(h[1],h[0]),c=n[t.fontName];c.vertical&&(u+=Math.PI/2);let d,p,f=Math.hypot(h[2],h[3]),m=f*function(e,t){let n=s.get(e);if(n)return n;let i=o(a,t);i.font=`30px ${e}`;let r=i.measureText(""),l=r.fontBoundingBoxAscent,h=Math.abs(r.fontBoundingBoxDescent);if(l){let t=l/(l+h);return s.set(e,t),i.canvas.width=i.canvas.height=0,t}i.strokeStyle="red",i.clearRect(0,0,a,a),i.strokeText("g",0,0);let u=i.getImageData(0,0,a,a).data;h=0;for(let s=u.length-1-3;s>=0;s-=4)if(u[s]>0){h=Math.ceil(s/4/a);break}i.clearRect(0,0,a,a),i.strokeText("A",0,a),u=i.getImageData(0,0,a,a).data,l=0;for(let s=0,o=u.length;s<o;s+=4)if(u[s]>0){l=a-Math.floor(s/4/a);break}if(i.canvas.width=i.canvas.height=0,l){let t=l/(l+h);return s.set(e,t),t}return s.set(e,.8),.8}(c.fontFamily,e._isOffscreenCanvasSupported);0===u?(d=h[4],p=h[5]-m):(d=h[4]+m*Math.sin(u),p=h[5]-m*Math.cos(u));let g="calc(var(--scale-factor)*",v=r.style;e._container===e._rootContainer?(v.left=`${(100*d/e._pageWidth).toFixed(2)}%`,v.top=`${(100*p/e._pageHeight).toFixed(2)}%`):(v.left=`${g}${d.toFixed(2)}px)`,v.top=`${g}${p.toFixed(2)}px)`),v.fontSize=`${g}${f.toFixed(2)}px)`,v.fontFamily=c.fontFamily,l.fontSize=f,r.setAttribute("role","presentation"),r.textContent=t.str,r.dir=t.dir,e._fontInspectorEnabled&&(r.dataset.fontName=t.fontName),0!==u&&(l.angle=u*(180/Math.PI));let y=!1;if(t.str.length>1)y=!0;else if(" "!==t.str&&t.transform[0]!==t.transform[3]){let e=Math.abs(t.transform[0]),n=Math.abs(t.transform[3]);e!==n&&Math.max(e,n)/Math.min(e,n)>1.5&&(y=!0)}y&&(l.canvasWidth=c.vertical?t.height:t.width),e._textDivProperties.set(r,l),e._isReadableStream&&e._layoutText(r)}function h(e){let{div:t,scale:n,properties:i,ctx:r,prevFontSize:a,prevFontFamily:s}=e,{style:o}=t,l="";if(0!==i.canvasWidth&&i.hasText){let{fontFamily:h}=o,{canvasWidth:u,fontSize:c}=i;(a!==c||s!==h)&&(r.font=`${c*n}px ${h}`,e.prevFontSize=c,e.prevFontFamily=h);let{width:d}=r.measureText(t.textContent);d>0&&(l=`scaleX(${u*n/d})`)}0!==i.angle&&(l=`rotate(${i.angle}deg) ${l}`),l.length>0&&(o.transform=l)}class u{constructor({textContentSource:e,container:t,viewport:n,textDivs:a,textDivProperties:s,textContentItemsStr:l,isOffscreenCanvasSupported:h}){var u;this._textContentSource=e,this._isReadableStream=e instanceof ReadableStream,this._container=this._rootContainer=t,this._textDivs=a||[],this._textContentItemsStr=l||[],this._isOffscreenCanvasSupported=h,this._fontInspectorEnabled=!(null==(u=globalThis.FontInspector)||!u.enabled),this._reader=null,this._textDivProperties=s||new WeakMap,this._canceled=!1,this._capability=new i.PromiseCapability,this._layoutTextParams={prevFontSize:null,prevFontFamily:null,div:null,scale:n.scale*(globalThis.devicePixelRatio||1),properties:null,ctx:o(0,h)};let{pageWidth:c,pageHeight:d,pageX:p,pageY:f}=n.rawDims;this._transform=[1,0,0,-1,-p,f+d],this._pageWidth=c,this._pageHeight=d,(0,r.setLayerDimensions)(t,n),this._capability.promise.finally((()=>{this._layoutTextParams=null})).catch((()=>{}))}get promise(){return this._capability.promise}cancel(){this._canceled=!0,this._reader&&(this._reader.cancel(new i.AbortException("TextLayer task cancelled.")).catch((()=>{})),this._reader=null),this._capability.reject(new i.AbortException("TextLayer task cancelled."))}_processItems(e,t){for(let n of e)if(void 0!==n.str)this._textContentItemsStr.push(n.str),l(this,n,t);else if("beginMarkedContentProps"===n.type||"beginMarkedContent"===n.type){let e=this._container;this._container=document.createElement("span"),this._container.classList.add("markedContent"),null!==n.id&&this._container.setAttribute("id",`${n.id}`),e.append(this._container)}else"endMarkedContent"===n.type&&(this._container=this._container.parentNode)}_layoutText(e){let t=this._layoutTextParams.properties=this._textDivProperties.get(e);if(this._layoutTextParams.div=e,h(this._layoutTextParams),t.hasText&&this._container.append(e),t.hasEOL){let e=document.createElement("br");e.setAttribute("role","presentation"),this._container.append(e)}}_render(){let e=new i.PromiseCapability,t=Object.create(null);if(this._isReadableStream){let n=()=>{this._reader.read().then((({value:i,done:r})=>{r?e.resolve():(Object.assign(t,i.styles),this._processItems(i.items,t),n())}),e.reject)};this._reader=this._textContentSource.getReader(),n()}else{if(!this._textContentSource)throw new Error('No "textContentSource" parameter specified.');{let{items:t,styles:n}=this._textContentSource;this._processItems(t,n),e.resolve()}}e.promise.then((()=>{t=null,function(e){if(e._canceled)return;let t=e._textDivs,n=e._capability;if(t.length>1e5)n.resolve();else{if(!e._isReadableStream)for(let n of t)e._layoutText(n);n.resolve()}}(this)}),this._capability.reject)}}t.TextLayerRenderTask=u},(e,t,n)=>{var i,r,a,s,o,l,h,u,c,d,p,f,m,g,v,y,x,b;Object.defineProperty(t,"__esModule",{value:!0}),t.AnnotationEditorLayer=void 0;var _=n(1),w=n(4),S=n(5),M=n(28),E=n(33),T=n(6);let A=class{constructor(e){Je(this,p),Je(this,m),Je(this,v),Je(this,x),Je(this,i,void 0),Je(this,r,!1),Je(this,a,null),Je(this,s,this.pointerup.bind(this)),Je(this,o,this.pointerdown.bind(this)),Je(this,l,new Map),Je(this,h,!1),Je(this,u,!1),Je(this,c,!1),Je(this,d,void 0),A._initialized||(A._initialized=!0,M.FreeTextEditor.initialize(e.l10n),E.InkEditor.initialize(e.l10n)),e.uiManager.registerEditorTypes([M.FreeTextEditor,E.InkEditor]),wt(this,d,e.uiManager),this.pageIndex=e.pageIndex,this.div=e.div,wt(this,i,e.accessibilityManager),wt(this,a,e.annotationLayer),this.viewport=e.viewport,le(this,d).addLayer(this)}get isEmpty(){return 0===le(this,l).size}updateToolbar(e){le(this,d).updateToolbar(e)}updateMode(e=le(this,d).getMode()){ft(this,x,b).call(this),e===_.AnnotationEditorType.INK?(this.addInkEditorIfNeeded(!1),this.disableClick()):this.enableClick(),le(this,d).unselectAll(),e!==_.AnnotationEditorType.NONE&&(this.div.classList.toggle("freeTextEditing",e===_.AnnotationEditorType.FREETEXT),this.div.classList.toggle("inkEditing",e===_.AnnotationEditorType.INK),this.div.hidden=!1)}addInkEditorIfNeeded(e){if(e||le(this,d).getMode()===_.AnnotationEditorType.INK){if(!e)for(let e of le(this,l).values())if(e.isEmpty())return void e.setInBackground();ft(this,v,y).call(this,{offsetX:0,offsetY:0}).setInBackground()}}setEditingState(e){le(this,d).setEditingState(e)}addCommands(e){le(this,d).addCommands(e)}enable(){this.div.style.pointerEvents="auto";let e=new Set;for(let n of le(this,l).values())n.enableEditing(),n.annotationElementId&&e.add(n.annotationElementId);if(!le(this,a))return;let t=le(this,a).getEditableAnnotations();for(let n of t){if(n.hide(),le(this,d).isDeletedAnnotationElement(n.data.id)||e.has(n.data.id))continue;let t=this.deserialize(n);t&&(this.addOrRebuild(t),t.enableEditing())}}disable(){var e;wt(this,c,!0),this.div.style.pointerEvents="none";let t=new Set;for(let n of le(this,l).values())n.disableEditing(),n.annotationElementId&&null===n.serialize()?(null==(e=this.getEditableAnnotation(n.annotationElementId))||e.show(),n.remove()):t.add(n.annotationElementId);if(le(this,a)){let e=le(this,a).getEditableAnnotations();for(let n of e){let{id:e}=n.data;t.has(e)||le(this,d).isDeletedAnnotationElement(e)||n.show()}}ft(this,x,b).call(this),this.isEmpty&&(this.div.hidden=!0),wt(this,c,!1)}getEditableAnnotation(e){var t;return(null==(t=le(this,a))?void 0:t.getEditableAnnotation(e))||null}setActiveEditor(e){le(this,d).getActive()!==e&&le(this,d).setActiveEditor(e)}enableClick(){this.div.addEventListener("pointerdown",le(this,o)),this.div.addEventListener("pointerup",le(this,s))}disableClick(){this.div.removeEventListener("pointerdown",le(this,o)),this.div.removeEventListener("pointerup",le(this,s))}attach(e){le(this,l).set(e.id,e);let{annotationElementId:t}=e;t&&le(this,d).isDeletedAnnotationElement(t)&&le(this,d).removeDeletedAnnotationElement(e)}detach(e){var t;le(this,l).delete(e.id),null==(t=le(this,i))||t.removePointerInTextLayer(e.contentDiv),!le(this,c)&&e.annotationElementId&&le(this,d).addDeletedAnnotationElement(e)}remove(e){this.detach(e),le(this,d).removeEditor(e),e.div.style.display="none",setTimeout((()=>{e.div.style.display="",e.div.remove(),e.isAttachedToDOM=!1,document.activeElement===document.body&&le(this,d).focusMainContainer()}),0),le(this,u)||this.addInkEditorIfNeeded(!1)}add(e){if(ft(this,p,f).call(this,e),le(this,d).addEditor(e),this.attach(e),!e.isAttachedToDOM){let t=e.render();this.div.append(t),e.isAttachedToDOM=!0}this.moveEditorInDOM(e),e.onceAdded(),le(this,d).addToAnnotationStorage(e)}moveEditorInDOM(e){var t;null==(t=le(this,i))||t.moveElementInDOM(this.div,e.div,e.contentDiv,!0)}addOrRebuild(e){e.needsToBeRebuilt()?e.rebuild():this.add(e)}getNextId(){return le(this,d).getId()}deserialize(e){var t;switch(null!=(t=e.annotationType)?t:e.annotationEditorType){case _.AnnotationEditorType.FREETEXT:return M.FreeTextEditor.deserialize(e,this,le(this,d));case _.AnnotationEditorType.INK:return E.InkEditor.deserialize(e,this,le(this,d))}return null}setSelected(e){le(this,d).setSelected(e)}toggleSelected(e){le(this,d).toggleSelected(e)}isSelected(e){return le(this,d).isSelected(e)}unselect(e){le(this,d).unselect(e)}pointerup(e){let{isMac:t}=_.FeatureTest.platform;if(!(0!==e.button||e.ctrlKey&&t)&&e.target===this.div&&le(this,h)){if(wt(this,h,!1),!le(this,r))return void wt(this,r,!0);ft(this,v,y).call(this,e)}}pointerdown(e){let{isMac:t}=_.FeatureTest.platform;if(0!==e.button||e.ctrlKey&&t||e.target!==this.div)return;wt(this,h,!0);let n=le(this,d).getActive();wt(this,r,!n||n.isEmpty())}drop(e){let t=e.dataTransfer.getData("text/plain"),n=le(this,d).getEditor(t);if(!n)return;e.preventDefault(),e.dataTransfer.dropEffect="move",ft(this,p,f).call(this,n);let i=this.div.getBoundingClientRect(),r=e.clientX-i.x,a=e.clientY-i.y;n.translate(r-n.startX,a-n.startY),this.moveEditorInDOM(n),n.div.focus()}dragover(e){e.preventDefault()}destroy(){var e,t;(null==(e=le(this,d).getActive())?void 0:e.parent)===this&&le(this,d).setActiveEditor(null);for(let n of le(this,l).values())null==(t=le(this,i))||t.removePointerInTextLayer(n.contentDiv),n.setParent(null),n.isAttachedToDOM=!1,n.div.remove();this.div=null,le(this,l).clear(),le(this,d).removeLayer(this)}render({viewport:e}){this.viewport=e,(0,T.setLayerDimensions)(this.div,e),(0,S.bindEvents)(this,this.div,["dragover","drop"]);for(let t of le(this,d).getEditors(this.pageIndex))this.add(t);this.updateMode()}update({viewport:e}){le(this,d).commitOrRemove(),this.viewport=e,(0,T.setLayerDimensions)(this.div,{rotation:e.rotation}),this.updateMode()}get pageDimensions(){let{pageWidth:e,pageHeight:t}=this.viewport.rawDims;return[e,t]}},C=A;i=new WeakMap,r=new WeakMap,a=new WeakMap,s=new WeakMap,o=new WeakMap,l=new WeakMap,h=new WeakMap,u=new WeakMap,c=new WeakMap,d=new WeakMap,p=new WeakSet,f=function(e){var t;e.parent!==this&&(e.annotationElementId&&(le(this,d).addDeletedAnnotationElement(e.annotationElementId),w.AnnotationEditor.deleteAnnotationElement(e),e.annotationElementId=null),this.attach(e),null==(t=e.parent)||t.detach(e),e.setParent(this),e.div&&e.isAttachedToDOM&&(e.div.remove(),this.div.append(e.div)))},m=new WeakSet,g=function(e){switch(le(this,d).getMode()){case _.AnnotationEditorType.FREETEXT:return new M.FreeTextEditor(e);case _.AnnotationEditorType.INK:return new E.InkEditor(e)}return null},v=new WeakSet,y=function(e){let t=this.getNextId(),n=ft(this,m,g).call(this,{parent:this,id:t,x:e.offsetX,y:e.offsetY,uiManager:le(this,d)});return n&&this.add(n),n},x=new WeakSet,b=function(){wt(this,u,!0);for(let e of le(this,l).values())e.isEmpty()&&e.remove();wt(this,u,!1)},Yi(C,"_initialized",!1),t.AnnotationEditorLayer=C},(e,t,n)=>{var i,r,a,s,o,l,h,u,c,d,p,f,m,g,v,y,x,b,_,w,S,M,E;Object.defineProperty(t,"__esModule",{value:!0}),t.FreeTextEditor=void 0;var T=n(1),A=n(5),C=n(4),P=n(29);let R=class extends C.AnnotationEditor{constructor(e){super(Ci(Ir({},e),{name:"freeTextEditor"})),Je(this,d),Je(this,f),Je(this,g),Je(this,y),Je(this,b),Je(this,w),Je(this,M),Je(this,i,this.editorDivBlur.bind(this)),Je(this,r,this.editorDivFocus.bind(this)),Je(this,a,this.editorDivInput.bind(this)),Je(this,s,this.editorDivKeydown.bind(this)),Je(this,o,void 0),Je(this,l,""),Je(this,h,`${this.id}-editor`),Je(this,u,void 0),Je(this,c,null),wt(this,o,e.color||R._defaultColor||C.AnnotationEditor._defaultLineColor),wt(this,u,e.fontSize||R._defaultFontSize)}static get _keyboardManager(){return(0,T.shadow)(this,"_keyboardManager",new A.KeyboardManager([[["ctrl+s","mac+meta+s","ctrl+p","mac+meta+p"],R.prototype.commitOrRemove,!0],[["ctrl+Enter","mac+meta+Enter","Escape","mac+Escape"],R.prototype.commitOrRemove]]))}static initialize(e){this._l10nPromise=new Map(["free_text2_default_content","editor_free_text2_aria_label"].map((t=>[t,e.get(t)])));let t=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(t.getPropertyValue("--freetext-padding"))}static updateDefaultParams(e,t){switch(e){case T.AnnotationEditorParamsType.FREETEXT_SIZE:R._defaultFontSize=t;break;case T.AnnotationEditorParamsType.FREETEXT_COLOR:R._defaultColor=t}}updateParams(e,t){switch(e){case T.AnnotationEditorParamsType.FREETEXT_SIZE:ft(this,d,p).call(this,t);break;case T.AnnotationEditorParamsType.FREETEXT_COLOR:ft(this,f,m).call(this,t)}}static get defaultPropertiesToUpdate(){return[[T.AnnotationEditorParamsType.FREETEXT_SIZE,R._defaultFontSize],[T.AnnotationEditorParamsType.FREETEXT_COLOR,R._defaultColor||C.AnnotationEditor._defaultLineColor]]}get propertiesToUpdate(){return[[T.AnnotationEditorParamsType.FREETEXT_SIZE,le(this,u)],[T.AnnotationEditorParamsType.FREETEXT_COLOR,le(this,o)]]}getInitialTranslation(){let e=this.parentScale;return[-R._internalPadding*e,-(R._internalPadding+le(this,u))*e]}rebuild(){super.rebuild(),null!==this.div&&(this.isAttachedToDOM||this.parent.add(this))}enableEditMode(){this.isInEditMode()||(this.parent.setEditingState(!1),this.parent.updateToolbar(T.AnnotationEditorType.FREETEXT),super.enableEditMode(),this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this.div.draggable=!1,this.div.removeAttribute("aria-activedescendant"),this.editorDiv.addEventListener("keydown",le(this,s)),this.editorDiv.addEventListener("focus",le(this,r)),this.editorDiv.addEventListener("blur",le(this,i)),this.editorDiv.addEventListener("input",le(this,a)))}disableEditMode(){this.isInEditMode()&&(this.parent.setEditingState(!0),super.disableEditMode(),this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",le(this,h)),this.div.draggable=!0,this.editorDiv.removeEventListener("keydown",le(this,s)),this.editorDiv.removeEventListener("focus",le(this,r)),this.editorDiv.removeEventListener("blur",le(this,i)),this.editorDiv.removeEventListener("input",le(this,a)),this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freeTextEditing"))}focusin(e){super.focusin(e),e.target!==this.editorDiv&&this.editorDiv.focus()}onceAdded(){this.width?ft(this,M,E).call(this):(this.enableEditMode(),this.editorDiv.focus())}isEmpty(){return!this.editorDiv||""===this.editorDiv.innerText.trim()}remove(){this.isEditing=!1,this.parent.setEditingState(!0),this.parent.div.classList.add("freeTextEditing"),super.remove()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();let e=le(this,l),t=wt(this,l,ft(this,g,v).call(this).trimEnd());if(e===t)return;let n=e=>{wt(this,l,e),e?(ft(this,b,_).call(this),this.rebuild(),ft(this,y,x).call(this)):this.remove()};this.addCommands({cmd:()=>{n(t)},undo:()=>{n(e)},mustExec:!1}),ft(this,y,x).call(this)}shouldGetKeyboardEvents(){return this.isInEditMode()}dblclick(e){this.enableEditMode(),this.editorDiv.focus()}keydown(e){e.target===this.div&&"Enter"===e.key&&(this.enableEditMode(),this.editorDiv.focus())}editorDivKeydown(e){R._keyboardManager.exec(this,e)}editorDivFocus(e){this.isEditing=!0}editorDivBlur(e){this.isEditing=!1}editorDivInput(e){this.parent.div.classList.toggle("freeTextEditing",this.isEmpty())}disableEditing(){this.editorDiv.setAttribute("role","comment"),this.editorDiv.removeAttribute("aria-multiline")}enableEditing(){this.editorDiv.setAttribute("role","textbox"),this.editorDiv.setAttribute("aria-multiline",!0)}render(){if(this.div)return this.div;let e,t;this.width&&(e=this.x,t=this.y),super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",le(this,h)),this.enableEditing(),R._l10nPromise.get("editor_free_text2_aria_label").then((e=>{var t;return null==(t=this.editorDiv)?void 0:t.setAttribute("aria-label",e)})),R._l10nPromise.get("free_text2_default_content").then((e=>{var t;return null==(t=this.editorDiv)?void 0:t.setAttribute("default-content",e)})),this.editorDiv.contentEditable=!0;let{style:n}=this.editorDiv;if(n.fontSize=`calc(${le(this,u)}px * var(--scale-factor))`,n.color=le(this,o),this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),(0,A.bindEvents)(this,this.div,["dblclick","keydown"]),this.width){let[n,i]=this.parentDimensions;if(this.annotationElementId){let[r]=this.getInitialTranslation();this.setAt(e*n,t*i,r,r)}else this.setAt(e*n,t*i,this.width*n,this.height*i);ft(this,b,_).call(this),this.div.draggable=!0,this.editorDiv.contentEditable=!1}else this.div.draggable=!1,this.editorDiv.contentEditable=!0;return this.div}get contentDiv(){return this.editorDiv}static deserialize(e,t,n){let i=null;if(e instanceof P.FreeTextAnnotationElement){let{data:{defaultAppearanceData:{fontSize:t,fontColor:n},rect:r,rotation:a,id:s},textContent:o,parent:{page:{pageNumber:l}}}=e;if(!o||0===o.length)return null;i=e={annotationType:T.AnnotationEditorType.FREETEXT,color:Array.from(n),fontSize:t,value:o.join("\n"),pageIndex:l-1,rect:r,rotation:a,id:s,deleted:!1}}let r=super.deserialize(e,t,n);return wt(r,u,e.fontSize),wt(r,o,T.Util.makeHexColor(...e.color)),wt(r,l,e.value),r.annotationElementId=e.id||null,wt(r,c,i),r}serialize(e=!1){if(this.isEmpty())return null;if(this.deleted)return{pageIndex:this.pageIndex,id:this.annotationElementId,deleted:!0};let t=R._internalPadding*this.parentScale,n=this.getRect(t,t),i=C.AnnotationEditor._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:le(this,o)),r={annotationType:T.AnnotationEditorType.FREETEXT,color:i,fontSize:le(this,u),value:le(this,l),pageIndex:this.pageIndex,rect:n,rotation:this.rotation};return e?r:this.annotationElementId&&!ft(this,w,S).call(this,r)?null:(r.id=this.annotationElementId,r)}},L=R;i=new WeakMap,r=new WeakMap,a=new WeakMap,s=new WeakMap,o=new WeakMap,l=new WeakMap,h=new WeakMap,u=new WeakMap,c=new WeakMap,d=new WeakSet,p=function(e){let t=e=>{this.editorDiv.style.fontSize=`calc(${e}px * var(--scale-factor))`,this.translate(0,-(e-le(this,u))*this.parentScale),wt(this,u,e),ft(this,y,x).call(this)},n=le(this,u);this.addCommands({cmd:()=>{t(e)},undo:()=>{t(n)},mustExec:!0,type:T.AnnotationEditorParamsType.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})},f=new WeakSet,m=function(e){let t=le(this,o);this.addCommands({cmd:()=>{wt(this,o,this.editorDiv.style.color=e)},undo:()=>{wt(this,o,this.editorDiv.style.color=t)},mustExec:!0,type:T.AnnotationEditorParamsType.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})},g=new WeakSet,v=function(){let e=this.editorDiv.getElementsByTagName("div");if(0===e.length)return this.editorDiv.innerText;let t=[];for(let n of e)t.push(n.innerText.replace(/\r\n?|\n/,""));return t.join("\n")},y=new WeakSet,x=function(){let e,[t,n]=this.parentDimensions;if(this.isAttachedToDOM)e=this.div.getBoundingClientRect();else{let{currentLayer:t,div:n}=this,i=n.style.display;n.style.display="hidden",t.div.append(this.div),e=n.getBoundingClientRect(),n.remove(),n.style.display=i}this.width=e.width/t,this.height=e.height/n},b=new WeakSet,_=function(){if(this.editorDiv.replaceChildren(),le(this,l))for(let e of le(this,l).split("\n")){let t=document.createElement("div");t.append(e?document.createTextNode(e):document.createElement("br")),this.editorDiv.append(t)}},w=new WeakSet,S=function(e){let{value:t,fontSize:n,color:i,rect:r,pageIndex:a}=le(this,c);return e.value!==t||e.fontSize!==n||e.rect.some(((e,t)=>Math.abs(e-r[t])>=1))||e.color.some(((e,t)=>e!==i[t]))||e.pageIndex!==a},M=new WeakSet,E=function(e=!1){if(!this.annotationElementId)return;if(ft(this,y,x).call(this),!e&&(0===this.width||0===this.height))return void setTimeout((()=>ft(this,M,E).call(this,!0)),0);let t=R._internalPadding*this.parentScale;le(this,c).rect=this.getRect(t,t)},Yi(L,"_freeTextDefaultContent",""),Yi(L,"_l10nPromise"),Yi(L,"_internalPadding",0),Yi(L,"_defaultColor",null),Yi(L,"_defaultFontSize",10),Yi(L,"_type","freetext"),t.FreeTextEditor=L},(e,t,n)=>{var i,r,a,s,o,l,h,u,c,d,p,f,m,g,v,y,x,b,_,w,S,M,E,T,A,C,P,R,L,I,k,O,D,N,U,F,B,z,H;Object.defineProperty(t,"__esModule",{value:!0}),t.InkAnnotationElement=t.FreeTextAnnotationElement=t.AnnotationLayer=void 0;var V=n(1),j=n(6),G=n(3),W=n(30),X=n(31);let Y=1e3,q=new WeakSet;function J(e){return{width:e[2]-e[0],height:e[3]-e[1]}}class Z{static create(e){switch(e.data.annotationType){case V.AnnotationType.LINK:return new $(e);case V.AnnotationType.TEXT:return new Q(e);case V.AnnotationType.WIDGET:switch(e.data.fieldType){case"Tx":return new te(e);case"Btn":return e.data.radioButton?new re(e):e.data.checkBox?new ie(e):new ae(e);case"Ch":return new se(e);case"Sig":return new ne(e)}return new ee(e);case V.AnnotationType.POPUP:return new oe(e);case V.AnnotationType.FREETEXT:return new ue(e);case V.AnnotationType.LINE:return new ce(e);case V.AnnotationType.SQUARE:return new de(e);case V.AnnotationType.CIRCLE:return new pe(e);case V.AnnotationType.POLYLINE:return new fe(e);case V.AnnotationType.CARET:return new ge(e);case V.AnnotationType.INK:return new ve(e);case V.AnnotationType.POLYGON:return new me(e);case V.AnnotationType.HIGHLIGHT:return new ye(e);case V.AnnotationType.UNDERLINE:return new xe(e);case V.AnnotationType.SQUIGGLY:return new be(e);case V.AnnotationType.STRIKEOUT:return new _e(e);case V.AnnotationType.STAMP:return new we(e);case V.AnnotationType.FILEATTACHMENT:return new Se(e);default:return new K(e)}}}class K{constructor(e,{isRenderable:t=!1,ignoreBorder:n=!1,createQuadrilaterals:i=!1}={}){this.isRenderable=t,this.data=e.data,this.layer=e.layer,this.linkService=e.linkService,this.downloadManager=e.downloadManager,this.imageResourcesPath=e.imageResourcesPath,this.renderForms=e.renderForms,this.svgFactory=e.svgFactory,this.annotationStorage=e.annotationStorage,this.enableScripting=e.enableScripting,this.hasJSActions=e.hasJSActions,this._fieldObjects=e.fieldObjects,this.parent=e.parent,t&&(this.container=this._createContainer(n)),i&&(this.quadrilaterals=this._createQuadrilaterals(n))}_createContainer(e){let{data:t,parent:{page:n,viewport:i}}=this,r=document.createElement("section");r.setAttribute("data-annotation-id",t.id),r.style.zIndex=this.parent.zIndex++,this.data.popupRef&&r.setAttribute("aria-haspopup","dialog"),t.noRotate&&r.classList.add("norotate");let{pageWidth:a,pageHeight:s,pageX:o,pageY:l}=i.rawDims;if(!t.rect||this instanceof oe){let{rotation:e}=t;return!t.hasOwnCanvas&&0!==e&&this.setRotation(e,r),r}let{width:h,height:u}=J(t.rect),c=V.Util.normalizeRect([t.rect[0],n.view[3]-t.rect[1]+n.view[1],t.rect[2],n.view[3]-t.rect[3]+n.view[1]]);if(!e&&t.borderStyle.width>0){r.style.borderWidth=`${t.borderStyle.width}px`;let e=t.borderStyle.horizontalCornerRadius,n=t.borderStyle.verticalCornerRadius;if(e>0||n>0){let t=`calc(${e}px * var(--scale-factor)) / calc(${n}px * var(--scale-factor))`;r.style.borderRadius=t}else if(this instanceof re){let e=`calc(${h}px * var(--scale-factor)) / calc(${u}px * var(--scale-factor))`;r.style.borderRadius=e}switch(t.borderStyle.style){case V.AnnotationBorderStyleType.SOLID:r.style.borderStyle="solid";break;case V.AnnotationBorderStyleType.DASHED:r.style.borderStyle="dashed";break;case V.AnnotationBorderStyleType.BEVELED:(0,V.warn)("Unimplemented border style: beveled");break;case V.AnnotationBorderStyleType.INSET:(0,V.warn)("Unimplemented border style: inset");break;case V.AnnotationBorderStyleType.UNDERLINE:r.style.borderBottomStyle="solid"}let i=t.borderColor||null;i?r.style.borderColor=V.Util.makeHexColor(0|i[0],0|i[1],0|i[2]):r.style.borderWidth=0}r.style.left=100*(c[0]-o)/a+"%",r.style.top=100*(c[1]-l)/s+"%";let{rotation:d}=t;return t.hasOwnCanvas||0===d?(r.style.width=100*h/a+"%",r.style.height=100*u/s+"%"):this.setRotation(d,r),r}setRotation(e,t=this.container){let n,i,{pageWidth:r,pageHeight:a}=this.parent.viewport.rawDims,{width:s,height:o}=J(this.data.rect);e%180==0?(n=100*s/r,i=100*o/a):(n=100*o/r,i=100*s/a),t.style.width=`${n}%`,t.style.height=`${i}%`,t.setAttribute("data-main-rotation",(360-e)%360)}get _commonActions(){let e=(e,t,n)=>{let i=n.detail[e];n.target.style[t]=W.ColorConverters[`${i[0]}_HTML`](i.slice(1))};return(0,V.shadow)(this,"_commonActions",{display:e=>{let t=e.detail.display%2==1;this.container.style.visibility=t?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{hidden:t,print:0===e.detail.display||3===e.detail.display})},print:e=>{this.annotationStorage.setValue(this.data.id,{print:e.detail.print})},hidden:e=>{this.container.style.visibility=e.detail.hidden?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{hidden:e.detail.hidden})},focus:e=>{setTimeout((()=>e.target.focus({preventScroll:!1})),0)},userName:e=>{e.target.title=e.detail.userName},readonly:e=>{e.detail.readonly?e.target.setAttribute("readonly",""):e.target.removeAttribute("readonly")},required:e=>{this._setRequired(e.target,e.detail.required)},bgColor:t=>{e("bgColor","backgroundColor",t)},fillColor:t=>{e("fillColor","backgroundColor",t)},fgColor:t=>{e("fgColor","color",t)},textColor:t=>{e("textColor","color",t)},borderColor:t=>{e("borderColor","borderColor",t)},strokeColor:t=>{e("strokeColor","borderColor",t)},rotation:e=>{let t=e.detail.rotation;this.setRotation(t),this.annotationStorage.setValue(this.data.id,{rotation:t})}})}_dispatchEventFromSandbox(e,t){let n=this._commonActions;for(let i of Object.keys(t.detail)){let r=e[i]||n[i];null==r||r(t)}}_setDefaultPropertiesFromJS(e){if(!this.enableScripting)return;let t=this.annotationStorage.getRawValue(this.data.id);if(!t)return;let n=this._commonActions;for(let[i,r]of Object.entries(t)){let a=n[i];a&&(a({detail:{[i]:r},target:e}),delete t[i])}}_createQuadrilaterals(e=!1){if(!this.data.quadPoints)return null;let t=[],n=this.data.rect,i=null;for(let r of this.data.quadPoints)this.data.rect=[r[2].x,r[2].y,r[1].x,r[1].y],t.push(this._createContainer(e)),i||(i=this.data.rect);return this.data.rect=n,this.firstQuadRect=i,t}_createPopup(){let{container:e,data:t}=this;e.setAttribute("aria-haspopup","dialog");let n=new oe({data:{color:t.color,titleObj:t.titleObj,modificationDate:t.modificationDate,contentsObj:t.contentsObj,richText:t.richText,parentRect:this.firstQuadRect||t.rect,borderStyle:0,id:`popup_${t.id}`,rotation:t.rotation},parent:this.parent,elements:[this]});this.parent.div.append(n.render())}_renderQuadrilaterals(e){for(let t of this.quadrilaterals)t.classList.add(e);return this.quadrilaterals}render(){(0,V.unreachable)("Abstract method `AnnotationElement.render` called")}_getElementsByName(e,t=null){let n=[];if(this._fieldObjects){let i=this._fieldObjects[e];if(i)for(let{page:e,id:r,exportValues:a}of i){if(-1===e||r===t)continue;let i="string"==typeof a?a:null,s=document.querySelector(`[data-element-id="${r}"]`);!s||q.has(s)?n.push({id:r,exportValue:i,domElement:s}):(0,V.warn)(`_getElementsByName - element not allowed: ${r}`)}return n}for(let i of document.getElementsByName(e)){let{exportValue:e}=i,r=i.getAttribute("data-element-id");r!==t&&q.has(i)&&n.push({id:r,exportValue:e,domElement:i})}return n}show(){var e;this.container&&(this.container.hidden=!1),null==(e=this.popup)||e.maybeShow()}hide(){var e;this.container&&(this.container.hidden=!0),null==(e=this.popup)||e.forceHide()}getElementsToTriggerPopup(){return this.quadrilaterals||this.container}addHighlightArea(){let e=this.getElementsToTriggerPopup();if(Array.isArray(e))for(let t of e)t.classList.add("highlightArea");else e.classList.add("highlightArea")}}class $ extends K{constructor(e,t=null){super(e,{isRenderable:!0,ignoreBorder:!(null==t||!t.ignoreBorder),createQuadrilaterals:!0}),Je(this,i),Je(this,a),this.isTooltipOnly=e.data.isTooltipOnly}render(){let{data:e,linkService:t}=this,n=document.createElement("a");n.setAttribute("data-element-id",e.id);let i=!1;return e.url?(t.addLinkAttributes(n,e.url,e.newWindow),i=!0):e.action?(this._bindNamedAction(n,e.action),i=!0):e.attachment?(this._bindAttachment(n,e.attachment),i=!0):e.setOCGState?(ft(this,a,s).call(this,n,e.setOCGState),i=!0):e.dest?(this._bindLink(n,e.dest),i=!0):(e.actions&&(e.actions.Action||e.actions["Mouse Up"]||e.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(n,e),i=!0),e.resetForm?(this._bindResetFormAction(n,e.resetForm),i=!0):this.isTooltipOnly&&!i&&(this._bindLink(n,""),i=!0)),this.quadrilaterals?this._renderQuadrilaterals("linkAnnotation").map(((e,t)=>{let i=0===t?n:n.cloneNode();return e.append(i),e})):(this.container.classList.add("linkAnnotation"),i&&this.container.append(n),this.container)}_bindLink(e,t){e.href=this.linkService.getDestinationHash(t),e.onclick=()=>(t&&this.linkService.goToDestination(t),!1),(t||""===t)&&ft(this,i,r).call(this)}_bindNamedAction(e,t){e.href=this.linkService.getAnchorUrl(""),e.onclick=()=>(this.linkService.executeNamedAction(t),!1),ft(this,i,r).call(this)}_bindAttachment(e,t){e.href=this.linkService.getAnchorUrl(""),e.onclick=()=>{var e;return null==(e=this.downloadManager)||e.openOrDownloadData(this.container,t.content,t.filename),!1},ft(this,i,r).call(this)}_bindJSAction(e,t){e.href=this.linkService.getAnchorUrl("");let n=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(let i of Object.keys(t.actions)){let r=n.get(i);r&&(e[r]=()=>{var e;return null==(e=this.linkService.eventBus)||e.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t.id,name:i}}),!1})}e.onclick||(e.onclick=()=>!1),ft(this,i,r).call(this)}_bindResetFormAction(e,t){let n=e.onclick;if(n||(e.href=this.linkService.getAnchorUrl("")),ft(this,i,r).call(this),!this._fieldObjects)return(0,V.warn)('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),void(n||(e.onclick=()=>!1));e.onclick=()=>{var e;null==n||n();let{fields:i,refs:r,include:a}=t,s=[];if(0!==i.length||0!==r.length){let e=new Set(r);for(let t of i){let n=this._fieldObjects[t]||[];for(let{id:t}of n)e.add(t)}for(let t of Object.values(this._fieldObjects))for(let n of t)e.has(n.id)===a&&s.push(n)}else for(let t of Object.values(this._fieldObjects))s.push(...t);let o=this.annotationStorage,l=[];for(let t of s){let{id:e}=t;switch(l.push(e),t.type){case"text":{let n=t.defaultValue||"";o.setValue(e,{value:n});break}case"checkbox":case"radiobutton":{let n=t.defaultValue===t.exportValues;o.setValue(e,{value:n});break}case"combobox":case"listbox":{let n=t.defaultValue||"";o.setValue(e,{value:n});break}default:continue}let n=document.querySelector(`[data-element-id="${e}"]`);n&&(q.has(n)?n.dispatchEvent(new Event("resetform")):(0,V.warn)(`_bindResetFormAction - element not allowed: ${e}`))}return this.enableScripting&&(null==(e=this.linkService.eventBus)||e.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:l,name:"ResetForm"}})),!1}}}i=new WeakSet,r=function(){this.container.setAttribute("data-internal-link","")},a=new WeakSet,s=function(e,t){e.href=this.linkService.getAnchorUrl(""),e.onclick=()=>(this.linkService.executeSetOCGState(t),!1),ft(this,i,r).call(this)};class Q extends K{constructor(e){var t,n,i;super(e,{isRenderable:!!(e.data.popupRef||null!=(t=e.data.titleObj)&&t.str||null!=(n=e.data.contentsObj)&&n.str||null!=(i=e.data.richText)&&i.str)})}render(){this.container.classList.add("textAnnotation");let e=document.createElement("img");return e.src=this.imageResourcesPath+"annotation-"+this.data.name.toLowerCase()+".svg",e.alt="[{{type}} Annotation]",e.dataset.l10nId="text_annotation_type",e.dataset.l10nArgs=JSON.stringify({type:this.data.name}),this.data.popupRef||this._createPopup(),this.container.append(e),this.container}}class ee extends K{render(){return this.data.alternativeText&&(this.container.title=this.data.alternativeText),this.container}showElementAndHideCanvas(e){var t;this.data.hasOwnCanvas&&("CANVAS"===(null==(t=e.previousSibling)?void 0:t.nodeName)&&(e.previousSibling.hidden=!0),e.hidden=!1)}_getKeyModifier(e){let{isWin:t,isMac:n}=V.FeatureTest.platform;return t&&e.ctrlKey||n&&e.metaKey}_setEventListener(e,t,n,i){t.includes("mouse")?e.addEventListener(t,(e=>{var t;null==(t=this.linkService.eventBus)||t.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:n,value:i(e),shift:e.shiftKey,modifier:this._getKeyModifier(e)}})})):e.addEventListener(t,(e=>{var t;null==(t=this.linkService.eventBus)||t.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:n,value:i(e)}})}))}_setEventListeners(e,t,n){var i;for(let[r,a]of t)("Action"===a||null!=(i=this.data.actions)&&i[a])&&this._setEventListener(e,r,a,n)}_setBackgroundColor(e){let t=this.data.backgroundColor||null;e.style.backgroundColor=null===t?"transparent":V.Util.makeHexColor(t[0],t[1],t[2])}_setTextStyle(e){let t,{fontColor:n}=this.data.defaultAppearanceData,i=this.data.defaultAppearanceData.fontSize||9,r=e.style,a=e=>Math.round(10*e)/10;if(this.data.multiLine){let e=Math.abs(this.data.rect[3]-this.data.rect[1]-2),n=e/(Math.round(e/(V.LINE_FACTOR*i))||1);t=Math.min(i,a(n/V.LINE_FACTOR))}else{let e=Math.abs(this.data.rect[3]-this.data.rect[1]-2);t=Math.min(i,a(e/V.LINE_FACTOR))}r.fontSize=`calc(${t}px * var(--scale-factor))`,r.color=V.Util.makeHexColor(n[0],n[1],n[2]),null!==this.data.textAlignment&&(r.textAlign=["left","center","right"][this.data.textAlignment])}_setRequired(e,t){t?e.setAttribute("required",!0):e.removeAttribute("required"),e.setAttribute("aria-required",t)}}class te extends ee{constructor(e){super(e,{isRenderable:e.renderForms||!e.data.hasAppearance&&!!e.data.fieldValue})}setPropertyOnSiblings(e,t,n,i){let r=this.annotationStorage;for(let a of this._getElementsByName(e.name,e.id))a.domElement&&(a.domElement[t]=n),r.setValue(a.id,{[i]:n})}render(){var e,t;let n=this.annotationStorage,i=this.data.id;this.container.classList.add("textWidgetAnnotation");let r=null;if(this.renderForms){let a=n.getValue(i,{value:this.data.fieldValue}),s=a.value||"",o=n.getValue(i,{charLimit:this.data.maxLen}).charLimit;o&&s.length>o&&(s=s.slice(0,o));let l=a.formattedValue||(null==(e=this.data.textContent)?void 0:e.join("\n"))||null;l&&this.data.comb&&(l=l.replaceAll(/\s+/g,""));let h={userValue:s,formattedValue:l,lastCommittedValue:null,commitKey:1};this.data.multiLine?(r=document.createElement("textarea"),r.textContent=null!=l?l:s,this.data.doNotScroll&&(r.style.overflowY="hidden")):(r=document.createElement("input"),r.type="text",r.setAttribute("value",null!=l?l:s),this.data.doNotScroll&&(r.style.overflowX="hidden")),this.data.hasOwnCanvas&&(r.hidden=!0),q.add(r),r.setAttribute("data-element-id",i),r.disabled=this.data.readOnly,r.name=this.data.baseFieldName||this.data.fieldName,r.tabIndex=Y,this._setRequired(r,this.data.required),o&&(r.maxLength=o),r.addEventListener("input",(e=>{n.setValue(i,{value:e.target.value}),this.setPropertyOnSiblings(r,"value",e.target.value,"value"),h.formattedValue=null})),r.addEventListener("resetform",(e=>{var t;let n=null!=(t=this.data.defaultFieldValue)?t:"";r.value=h.userValue=n,h.formattedValue=null}));let u=e=>{let{formattedValue:t}=h;null!=t&&(e.target.value=t),e.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){r.addEventListener("focus",(e=>{let{target:t}=e;h.userValue&&(t.value=h.userValue),h.lastCommittedValue=t.value,h.commitKey=1})),r.addEventListener("updatefromsandbox",(e=>{this.showElementAndHideCanvas(e.target);let t={value(e){var t;h.userValue=null!=(t=e.detail.value)?t:"",n.setValue(i,{value:h.userValue.toString()}),e.target.value=h.userValue},formattedValue(e){let{formattedValue:t}=e.detail;h.formattedValue=t,null!=t&&e.target!==document.activeElement&&(e.target.value=t),n.setValue(i,{formattedValue:t})},selRange(e){e.target.setSelectionRange(...e.detail.selRange)},charLimit:e=>{var t;let{charLimit:r}=e.detail,{target:a}=e;if(0===r)return void a.removeAttribute("maxLength");a.setAttribute("maxLength",r);let s=h.userValue;!s||s.length<=r||(s=s.slice(0,r),a.value=h.userValue=s,n.setValue(i,{value:s}),null==(t=this.linkService.eventBus)||t.dispatch("dispatcheventinsandbox",{source:this,detail:{id:i,name:"Keystroke",value:s,willCommit:!0,commitKey:1,selStart:a.selectionStart,selEnd:a.selectionEnd}}))}};this._dispatchEventFromSandbox(t,e)})),r.addEventListener("keydown",(e=>{var t;h.commitKey=1;let n=-1;if("Escape"===e.key?n=0:"Enter"!==e.key||this.data.multiLine?"Tab"===e.key&&(h.commitKey=3):n=2,-1===n)return;let{value:r}=e.target;h.lastCommittedValue!==r&&(h.lastCommittedValue=r,h.userValue=r,null==(t=this.linkService.eventBus)||t.dispatch("dispatcheventinsandbox",{source:this,detail:{id:i,name:"Keystroke",value:r,willCommit:!0,commitKey:n,selStart:e.target.selectionStart,selEnd:e.target.selectionEnd}}))}));let e=u;u=null,r.addEventListener("blur",(t=>{var n;if(!t.relatedTarget)return;let{value:r}=t.target;h.userValue=r,h.lastCommittedValue!==r&&(null==(n=this.linkService.eventBus)||n.dispatch("dispatcheventinsandbox",{source:this,detail:{id:i,name:"Keystroke",value:r,willCommit:!0,commitKey:h.commitKey,selStart:t.target.selectionStart,selEnd:t.target.selectionEnd}})),e(t)})),null!=(t=this.data.actions)&&t.Keystroke&&r.addEventListener("beforeinput",(e=>{var t;h.lastCommittedValue=null;let{data:n,target:r}=e,{value:a,selectionStart:s,selectionEnd:o}=r,l=s,u=o;switch(e.inputType){case"deleteWordBackward":{let e=a.substring(0,s).match(/\w*[^\w]*$/);e&&(l-=e[0].length);break}case"deleteWordForward":{let e=a.substring(s).match(/^[^\w]*\w*/);e&&(u+=e[0].length);break}case"deleteContentBackward":s===o&&(l-=1);break;case"deleteContentForward":s===o&&(u+=1)}e.preventDefault(),null==(t=this.linkService.eventBus)||t.dispatch("dispatcheventinsandbox",{source:this,detail:{id:i,name:"Keystroke",value:a,change:n||"",willCommit:!1,selStart:l,selEnd:u}})})),this._setEventListeners(r,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(e=>e.target.value))}if(u&&r.addEventListener("blur",u),this.data.comb){let e=(this.data.rect[2]-this.data.rect[0])/o;r.classList.add("comb"),r.style.letterSpacing=`calc(${e}px * var(--scale-factor) - 1ch)`}}else r=document.createElement("div"),r.textContent=this.data.fieldValue,r.style.verticalAlign="middle",r.style.display="table-cell";return this._setTextStyle(r),this._setBackgroundColor(r),this._setDefaultPropertiesFromJS(r),this.container.append(r),this.container}}class ne extends ee{constructor(e){super(e,{isRenderable:!!e.data.hasOwnCanvas})}}class ie extends ee{constructor(e){super(e,{isRenderable:e.renderForms})}render(){let e=this.annotationStorage,t=this.data,n=t.id,i=e.getValue(n,{value:t.exportValue===t.fieldValue}).value;"string"==typeof i&&(i="Off"!==i,e.setValue(n,{value:i})),this.container.classList.add("buttonWidgetAnnotation","checkBox");let r=document.createElement("input");return q.add(r),r.setAttribute("data-element-id",n),r.disabled=t.readOnly,this._setRequired(r,this.data.required),r.type="checkbox",r.name=t.baseFieldName||t.fieldName,i&&r.setAttribute("checked",!0),r.setAttribute("exportValue",t.exportValue),r.tabIndex=Y,r.addEventListener("change",(i=>{let{name:r,checked:a}=i.target;for(let s of this._getElementsByName(r,n)){let n=a&&s.exportValue===t.exportValue;s.domElement&&(s.domElement.checked=n),e.setValue(s.id,{value:n})}e.setValue(n,{value:a})})),r.addEventListener("resetform",(e=>{let n=t.defaultFieldValue||"Off";e.target.checked=n===t.exportValue})),this.enableScripting&&this.hasJSActions&&(r.addEventListener("updatefromsandbox",(t=>{let i={value(t){t.target.checked="Off"!==t.detail.value,e.setValue(n,{value:t.target.checked})}};this._dispatchEventFromSandbox(i,t)})),this._setEventListeners(r,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(e=>e.target.checked))),this._setBackgroundColor(r),this._setDefaultPropertiesFromJS(r),this.container.append(r),this.container}}class re extends ee{constructor(e){super(e,{isRenderable:e.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");let e=this.annotationStorage,t=this.data,n=t.id,i=e.getValue(n,{value:t.fieldValue===t.buttonValue}).value;"string"==typeof i&&(i=i!==t.buttonValue,e.setValue(n,{value:i}));let r=document.createElement("input");if(q.add(r),r.setAttribute("data-element-id",n),r.disabled=t.readOnly,this._setRequired(r,this.data.required),r.type="radio",r.name=t.baseFieldName||t.fieldName,i&&r.setAttribute("checked",!0),r.tabIndex=Y,r.addEventListener("change",(t=>{let{name:i,checked:r}=t.target;for(let a of this._getElementsByName(i,n))e.setValue(a.id,{value:!1});e.setValue(n,{value:r})})),r.addEventListener("resetform",(e=>{let n=t.defaultFieldValue;e.target.checked=null!=n&&n===t.buttonValue})),this.enableScripting&&this.hasJSActions){let i=t.buttonValue;r.addEventListener("updatefromsandbox",(t=>{let r={value:t=>{let r=i===t.detail.value;for(let i of this._getElementsByName(t.target.name)){let t=r&&i.id===n;i.domElement&&(i.domElement.checked=t),e.setValue(i.id,{value:t})}}};this._dispatchEventFromSandbox(r,t)})),this._setEventListeners(r,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(e=>e.target.checked))}return this._setBackgroundColor(r),this._setDefaultPropertiesFromJS(r),this.container.append(r),this.container}}class ae extends ${constructor(e){super(e,{ignoreBorder:e.data.hasAppearance})}render(){let e=super.render();e.classList.add("buttonWidgetAnnotation","pushButton"),this.data.alternativeText&&(e.title=this.data.alternativeText);let t=e.lastChild;return this.enableScripting&&this.hasJSActions&&t&&(this._setDefaultPropertiesFromJS(t),t.addEventListener("updatefromsandbox",(e=>{this._dispatchEventFromSandbox({},e)}))),e}}class se extends ee{constructor(e){super(e,{isRenderable:e.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");let e=this.annotationStorage,t=this.data.id,n=e.getValue(t,{value:this.data.fieldValue}),i=document.createElement("select");q.add(i),i.setAttribute("data-element-id",t),i.disabled=this.data.readOnly,this._setRequired(i,this.data.required),i.name=this.data.baseFieldName||this.data.fieldName,i.tabIndex=Y;let r=this.data.combo&&this.data.options.length>0;this.data.combo||(i.size=this.data.options.length,this.data.multiSelect&&(i.multiple=!0)),i.addEventListener("resetform",(e=>{let t=this.data.defaultFieldValue;for(let n of i.options)n.selected=n.value===t}));for(let h of this.data.options){let e=document.createElement("option");e.textContent=h.displayValue,e.value=h.exportValue,n.value.includes(h.exportValue)&&(e.setAttribute("selected",!0),r=!1),i.append(e)}let a=null;if(r){let e=document.createElement("option");e.value=" ",e.setAttribute("hidden",!0),e.setAttribute("selected",!0),i.prepend(e),a=()=>{e.remove(),i.removeEventListener("input",a),a=null},i.addEventListener("input",a)}let s=e=>{let t=e?"value":"textContent",{options:n,multiple:r}=i;return r?Array.prototype.filter.call(n,(e=>e.selected)).map((e=>e[t])):-1===n.selectedIndex?null:n[n.selectedIndex][t]},o=s(!1),l=e=>{let t=e.target.options;return Array.prototype.map.call(t,(e=>({displayValue:e.textContent,exportValue:e.value})))};return this.enableScripting&&this.hasJSActions?(i.addEventListener("updatefromsandbox",(n=>{let r={value(n){null==a||a();let r=n.detail.value,l=new Set(Array.isArray(r)?r:[r]);for(let e of i.options)e.selected=l.has(e.value);e.setValue(t,{value:s(!0)}),o=s(!1)},multipleSelection(e){i.multiple=!0},remove(n){let r=i.options,a=n.detail.remove;r[a].selected=!1,i.remove(a),r.length>0&&-1===Array.prototype.findIndex.call(r,(e=>e.selected))&&(r[0].selected=!0),e.setValue(t,{value:s(!0),items:l(n)}),o=s(!1)},clear(n){for(;0!==i.length;)i.remove(0);e.setValue(t,{value:null,items:[]}),o=s(!1)},insert(n){let{index:r,displayValue:a,exportValue:h}=n.detail.insert,u=i.children[r],c=document.createElement("option");c.textContent=a,c.value=h,u?u.before(c):i.append(c),e.setValue(t,{value:s(!0),items:l(n)}),o=s(!1)},items(n){let{items:r}=n.detail;for(;0!==i.length;)i.remove(0);for(let e of r){let{displayValue:t,exportValue:n}=e,r=document.createElement("option");r.textContent=t,r.value=n,i.append(r)}i.options.length>0&&(i.options[0].selected=!0),e.setValue(t,{value:s(!0),items:l(n)}),o=s(!1)},indices(n){let i=new Set(n.detail.indices);for(let e of n.target.options)e.selected=i.has(e.index);e.setValue(t,{value:s(!0)}),o=s(!1)},editable(e){e.target.disabled=!e.detail.editable}};this._dispatchEventFromSandbox(r,n)})),i.addEventListener("input",(n=>{var i;let r=s(!0);e.setValue(t,{value:r}),n.preventDefault(),null==(i=this.linkService.eventBus)||i.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:o,changeEx:r,willCommit:!1,commitKey:1,keyDown:!1}})})),this._setEventListeners(i,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"],["input","Action"],["input","Validate"]],(e=>e.target.value))):i.addEventListener("input",(function(n){e.setValue(t,{value:s(!0)})})),this.data.combo&&this._setTextStyle(i),this._setBackgroundColor(i),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}}class oe extends K{constructor(e){var t,n,i;let{data:r,elements:a}=e;super(e,{isRenderable:!!(null!=(t=r.titleObj)&&t.str||null!=(n=r.contentsObj)&&n.str||null!=(i=r.richText)&&i.str)}),this.elements=a}render(){this.container.classList.add("popupAnnotation");let e=new he({container:this.container,color:this.data.color,titleObj:this.data.titleObj,modificationDate:this.data.modificationDate,contentsObj:this.data.contentsObj,richText:this.data.richText,rect:this.data.rect,parentRect:this.data.parentRect||null,parent:this.parent,elements:this.elements,open:this.data.open}),t=[];for(let n of this.elements)n.popup=e,t.push(n.data.id),n.addHighlightArea();return this.container.setAttribute("aria-controls",t.join(",")),this.container}}class he{constructor({container:e,color:t,elements:n,titleObj:i,modificationDate:r,contentsObj:a,richText:s,parent:P,rect:R,parentRect:L,open:I}){Je(this,S),Je(this,E),Je(this,A),Je(this,o,null),Je(this,l,ft(this,A,C).bind(this)),Je(this,h,ft(this,E,T).bind(this)),Je(this,u,ft(this,S,M).bind(this)),Je(this,c,null),Je(this,d,null),Je(this,p,null),Je(this,f,null),Je(this,m,null),Je(this,g,null),Je(this,v,!1),Je(this,y,null),Je(this,x,null),Je(this,b,null),Je(this,_,null),Je(this,w,!1),wt(this,d,e),wt(this,_,i),wt(this,p,a),wt(this,b,s),wt(this,m,P),wt(this,c,t),wt(this,x,R),wt(this,g,L),wt(this,f,n);let k=j.PDFDateString.toDateObject(r);k&&wt(this,o,P.l10n.get("annotation_date_string",{date:k.toLocaleDateString(),time:k.toLocaleTimeString()})),this.trigger=n.flatMap((e=>e.getElementsToTriggerPopup()));for(let o of this.trigger)o.addEventListener("click",le(this,u)),o.addEventListener("mouseenter",le(this,h)),o.addEventListener("mouseleave",le(this,l));le(this,d).hidden=!0,I&&ft(this,S,M).call(this)}render(){if(le(this,y))return;let{page:{view:e},viewport:{rawDims:{pageWidth:t,pageHeight:n,pageX:i,pageY:r}}}=le(this,m),a=wt(this,y,document.createElement("div"));if(a.className="popup",le(this,c)){let e=a.style.outlineColor=V.Util.makeHexColor(...le(this,c));CSS.supports("background-color","color-mix(in srgb, red 30%, white)")?a.style.backgroundColor=`color-mix(in srgb, ${e} 30%, white)`:a.style.backgroundColor=V.Util.makeHexColor(...le(this,c).map((e=>Math.floor(.7*(255-e)+e))))}let s=document.createElement("span");s.className="header";let l=document.createElement("h1");if(s.append(l),({dir:l.dir,str:l.textContent}=le(this,_)),a.append(s),le(this,o)){let e=document.createElement("span");e.classList.add("popupDate"),le(this,o).then((t=>{e.textContent=t})),s.append(e)}let h=le(this,p),u=le(this,b);if(null==u||!u.str||null!=h&&h.str&&h.str!==u.str){let e=this._formatContents(h);a.append(e)}else X.XfaLayer.render({xfaHtml:u.html,intent:"richText",div:a}),a.lastChild.classList.add("richText","popupContent");let v=!!le(this,g),w=le(this,v?g:x);for(let o of le(this,f))if(!w||null!==V.Util.intersect(o.data.rect,w)){w=o.data.rect,v=!0;break}let S=V.Util.normalizeRect([w[0],e[3]-w[1]+e[1],w[2],e[3]-w[3]+e[1]]),M=v?w[2]-w[0]+5:0,E=S[0]+M,T=S[1],{style:A}=le(this,d);A.left=100*(E-i)/t+"%",A.top=100*(T-r)/n+"%",le(this,d).append(a)}_formatContents({str:e,dir:t}){let n=document.createElement("p");n.classList.add("popupContent"),n.dir=t;let i=e.split(/(?:\r\n?|\n)/);for(let r=0,a=i.length;r<a;++r){let e=i[r];n.append(document.createTextNode(e)),r<a-1&&n.append(document.createElement("br"))}return n}forceHide(){wt(this,w,this.isVisible),le(this,w)&&(le(this,d).hidden=!0)}maybeShow(){le(this,w)&&(wt(this,w,!1),le(this,d).hidden=!1)}get isVisible(){return!1===le(this,d).hidden}}o=new WeakMap,l=new WeakMap,h=new WeakMap,u=new WeakMap,c=new WeakMap,d=new WeakMap,p=new WeakMap,f=new WeakMap,m=new WeakMap,g=new WeakMap,v=new WeakMap,y=new WeakMap,x=new WeakMap,b=new WeakMap,_=new WeakMap,w=new WeakMap,S=new WeakSet,M=function(){wt(this,v,!le(this,v)),le(this,v)?(ft(this,E,T).call(this),le(this,d).addEventListener("click",le(this,u))):(ft(this,A,C).call(this),le(this,d).removeEventListener("click",le(this,u)))},E=new WeakSet,T=function(){le(this,y)||this.render(),this.isVisible?le(this,v)&&le(this,d).classList.add("focused"):(le(this,d).hidden=!1,le(this,d).style.zIndex=parseInt(le(this,d).style.zIndex)+1e3)},A=new WeakSet,C=function(){le(this,d).classList.remove("focused"),!le(this,v)&&(le(this,d).hidden=!0,le(this,d).style.zIndex=parseInt(le(this,d).style.zIndex)-1e3)};class ue extends K{constructor(e){var t,n,i;super(e,{isRenderable:!!(e.data.popupRef||null!=(t=e.data.titleObj)&&t.str||null!=(n=e.data.contentsObj)&&n.str||null!=(i=e.data.richText)&&i.str),ignoreBorder:!0}),this.textContent=e.data.textContent,this.annotationEditorType=V.AnnotationEditorType.FREETEXT}render(){if(this.container.classList.add("freeTextAnnotation"),this.textContent){let e=document.createElement("div");e.classList.add("annotationTextContent"),e.setAttribute("role","comment");for(let t of this.textContent){let n=document.createElement("span");n.textContent=t,e.append(n)}this.container.append(e)}return this.data.popupRef||this._createPopup(),this.container}}t.FreeTextAnnotationElement=ue;class ce extends K{constructor(e){var t,n,i;super(e,{isRenderable:!!(e.data.popupRef||null!=(t=e.data.titleObj)&&t.str||null!=(n=e.data.contentsObj)&&n.str||null!=(i=e.data.richText)&&i.str),ignoreBorder:!0}),Je(this,P,null)}render(){this.container.classList.add("lineAnnotation");let e=this.data,{width:t,height:n}=J(e.rect),i=this.svgFactory.create(t,n,!0),r=wt(this,P,this.svgFactory.createElement("svg:line"));return r.setAttribute("x1",e.rect[2]-e.lineCoordinates[0]),r.setAttribute("y1",e.rect[3]-e.lineCoordinates[1]),r.setAttribute("x2",e.rect[2]-e.lineCoordinates[2]),r.setAttribute("y2",e.rect[3]-e.lineCoordinates[3]),r.setAttribute("stroke-width",e.borderStyle.width||1),r.setAttribute("stroke","transparent"),r.setAttribute("fill","transparent"),i.append(r),this.container.append(i),e.popupRef||this._createPopup(),this.container}getElementsToTriggerPopup(){return le(this,P)}addHighlightArea(){this.container.classList.add("highlightArea")}}P=new WeakMap;class de extends K{constructor(e){var t,n,i;super(e,{isRenderable:!!(e.data.popupRef||null!=(t=e.data.titleObj)&&t.str||null!=(n=e.data.contentsObj)&&n.str||null!=(i=e.data.richText)&&i.str),ignoreBorder:!0}),Je(this,R,null)}render(){this.container.classList.add("squareAnnotation");let e=this.data,{width:t,height:n}=J(e.rect),i=this.svgFactory.create(t,n,!0),r=e.borderStyle.width,a=wt(this,R,this.svgFactory.createElement("svg:rect"));return a.setAttribute("x",r/2),a.setAttribute("y",r/2),a.setAttribute("width",t-r),a.setAttribute("height",n-r),a.setAttribute("stroke-width",r||1),a.setAttribute("stroke","transparent"),a.setAttribute("fill","transparent"),i.append(a),this.container.append(i),e.popupRef||this._createPopup(),this.container}getElementsToTriggerPopup(){return le(this,R)}addHighlightArea(){this.container.classList.add("highlightArea")}}R=new WeakMap;class pe extends K{constructor(e){var t,n,i;super(e,{isRenderable:!!(e.data.popupRef||null!=(t=e.data.titleObj)&&t.str||null!=(n=e.data.contentsObj)&&n.str||null!=(i=e.data.richText)&&i.str),ignoreBorder:!0}),Je(this,L,null)}render(){this.container.classList.add("circleAnnotation");let e=this.data,{width:t,height:n}=J(e.rect),i=this.svgFactory.create(t,n,!0),r=e.borderStyle.width,a=wt(this,L,this.svgFactory.createElement("svg:ellipse"));return a.setAttribute("cx",t/2),a.setAttribute("cy",n/2),a.setAttribute("rx",t/2-r/2),a.setAttribute("ry",n/2-r/2),a.setAttribute("stroke-width",r||1),a.setAttribute("stroke","transparent"),a.setAttribute("fill","transparent"),i.append(a),this.container.append(i),e.popupRef||this._createPopup(),this.container}getElementsToTriggerPopup(){return le(this,L)}addHighlightArea(){this.container.classList.add("highlightArea")}}L=new WeakMap;class fe extends K{constructor(e){var t,n,i;super(e,{isRenderable:!!(e.data.popupRef||null!=(t=e.data.titleObj)&&t.str||null!=(n=e.data.contentsObj)&&n.str||null!=(i=e.data.richText)&&i.str),ignoreBorder:!0}),Je(this,I,null),this.containerClassName="polylineAnnotation",this.svgElementName="svg:polyline"}render(){this.container.classList.add(this.containerClassName);let e=this.data,{width:t,height:n}=J(e.rect),i=this.svgFactory.create(t,n,!0),r=[];for(let s of e.vertices){let t=s.x-e.rect[0],n=e.rect[3]-s.y;r.push(t+","+n)}r=r.join(" ");let a=wt(this,I,this.svgFactory.createElement(this.svgElementName));return a.setAttribute("points",r),a.setAttribute("stroke-width",e.borderStyle.width||1),a.setAttribute("stroke","transparent"),a.setAttribute("fill","transparent"),i.append(a),this.container.append(i),e.popupRef||this._createPopup(a,e),this.container}getElementsToTriggerPopup(){return le(this,I)}addHighlightArea(){this.container.classList.add("highlightArea")}}I=new WeakMap;class me extends fe{constructor(e){super(e),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class ge extends K{constructor(e){var t,n,i;super(e,{isRenderable:!!(e.data.popupRef||null!=(t=e.data.titleObj)&&t.str||null!=(n=e.data.contentsObj)&&n.str||null!=(i=e.data.richText)&&i.str),ignoreBorder:!0})}render(){return this.container.classList.add("caretAnnotation"),this.data.popupRef||this._createPopup(),this.container}}class ve extends K{constructor(e){var t,n,i;super(e,{isRenderable:!!(e.data.popupRef||null!=(t=e.data.titleObj)&&t.str||null!=(n=e.data.contentsObj)&&n.str||null!=(i=e.data.richText)&&i.str),ignoreBorder:!0}),Je(this,k,[]),this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType=V.AnnotationEditorType.INK}render(){this.container.classList.add(this.containerClassName);let e=this.data,{width:t,height:n}=J(e.rect),i=this.svgFactory.create(t,n,!0);for(let r of e.inkLists){let t=[];for(let i of r){let n=i.x-e.rect[0],r=e.rect[3]-i.y;t.push(`${n},${r}`)}t=t.join(" ");let n=this.svgFactory.createElement(this.svgElementName);le(this,k).push(n),n.setAttribute("points",t),n.setAttribute("stroke-width",e.borderStyle.width||1),n.setAttribute("stroke","transparent"),n.setAttribute("fill","transparent"),e.popupRef||this._createPopup(n,e),i.append(n)}return this.container.append(i),this.container}getElementsToTriggerPopup(){return le(this,k)}addHighlightArea(){this.container.classList.add("highlightArea")}}k=new WeakMap,t.InkAnnotationElement=ve;class ye extends K{constructor(e){var t,n,i;super(e,{isRenderable:!!(e.data.popupRef||null!=(t=e.data.titleObj)&&t.str||null!=(n=e.data.contentsObj)&&n.str||null!=(i=e.data.richText)&&i.str),ignoreBorder:!0,createQuadrilaterals:!0})}render(){return this.data.popupRef||this._createPopup(),this.quadrilaterals?this._renderQuadrilaterals("highlightAnnotation"):(this.container.classList.add("highlightAnnotation"),this.container)}}class xe extends K{constructor(e){var t,n,i;super(e,{isRenderable:!!(e.data.popupRef||null!=(t=e.data.titleObj)&&t.str||null!=(n=e.data.contentsObj)&&n.str||null!=(i=e.data.richText)&&i.str),ignoreBorder:!0,createQuadrilaterals:!0})}render(){return this.data.popupRef||this._createPopup(),this.quadrilaterals?this._renderQuadrilaterals("underlineAnnotation"):(this.container.classList.add("underlineAnnotation"),this.container)}}class be extends K{constructor(e){var t,n,i;super(e,{isRenderable:!!(e.data.popupRef||null!=(t=e.data.titleObj)&&t.str||null!=(n=e.data.contentsObj)&&n.str||null!=(i=e.data.richText)&&i.str),ignoreBorder:!0,createQuadrilaterals:!0})}render(){return this.data.popupRef||this._createPopup(),this.quadrilaterals?this._renderQuadrilaterals("squigglyAnnotation"):(this.container.classList.add("squigglyAnnotation"),this.container)}}class _e extends K{constructor(e){var t,n,i;super(e,{isRenderable:!!(e.data.popupRef||null!=(t=e.data.titleObj)&&t.str||null!=(n=e.data.contentsObj)&&n.str||null!=(i=e.data.richText)&&i.str),ignoreBorder:!0,createQuadrilaterals:!0})}render(){return this.data.popupRef||this._createPopup(),this.quadrilaterals?this._renderQuadrilaterals("strikeoutAnnotation"):(this.container.classList.add("strikeoutAnnotation"),this.container)}}class we extends K{constructor(e){var t,n,i;super(e,{isRenderable:!!(e.data.popupRef||null!=(t=e.data.titleObj)&&t.str||null!=(n=e.data.contentsObj)&&n.str||null!=(i=e.data.richText)&&i.str),ignoreBorder:!0})}render(){return this.container.classList.add("stampAnnotation"),this.data.popupRef||this._createPopup(),this.container}}class Se extends K{constructor(e){var t;super(e,{isRenderable:!0}),Je(this,O,null);let{filename:n,content:i}=this.data.file;this.filename=(0,j.getFilenameFromUrl)(n,!0),this.content=i,null==(t=this.linkService.eventBus)||t.dispatch("fileattachmentannotation",{source:this,filename:n,content:i})}render(){var e,t;let n;return this.container.classList.add("fileAttachmentAnnotation"),this.data.hasAppearance?n=document.createElement("div"):(n=document.createElement("img"),n.src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(this.data.name)?"paperclip":"pushpin"}.svg`),n.classList.add("popupTriggerArea"),n.addEventListener("dblclick",this._download.bind(this)),wt(this,O,n),!this.data.popupRef&&(null!=(e=this.data.titleObj)&&e.str||null!=(t=this.data.contentsObj)&&t.str||this.data.richText)&&this._createPopup(),this.container.append(n),this.container}getElementsToTriggerPopup(){return le(this,O)}addHighlightArea(){this.container.classList.add("highlightArea")}_download(){var e;null==(e=this.downloadManager)||e.openOrDownloadData(this.container,this.content,this.filename)}}O=new WeakMap,D=new WeakMap,N=new WeakMap,U=new WeakMap,F=new WeakSet,B=function(e,t){var n;let i=e.firstChild||e;i.id=`${j.AnnotationPrefix}${t}`,this.div.append(e),null==(n=le(this,D))||n.moveElementInDOM(this.div,e,i,!1)},z=new WeakSet,H=function(){if(!le(this,N))return;let e=this.div;for(let[t,n]of le(this,N)){let i=e.querySelector(`[data-annotation-id="${t}"]`);if(!i)continue;let{firstChild:r}=i;r?"CANVAS"===r.nodeName?r.replaceWith(n):r.before(n):i.append(n)}le(this,N).clear()},t.AnnotationLayer=class{constructor({div:e,accessibilityManager:t,annotationCanvasMap:i,l10n:r,page:a,viewport:s}){Je(this,F),Je(this,z),Je(this,D,null),Je(this,N,null),Je(this,U,new Map),this.div=e,wt(this,D,t),wt(this,N,i),this.l10n=r,this.page=a,this.viewport=s,this.zIndex=0;let{NullL10n:o}=n(32);this.l10n||(this.l10n=o)}render(e){return it(this,null,(function*(){let{annotations:t}=e,n=this.div;(0,j.setLayerDimensions)(n,this.viewport);let i=new Map,r={data:null,layer:n,linkService:e.linkService,downloadManager:e.downloadManager,imageResourcesPath:e.imageResourcesPath||"",renderForms:!1!==e.renderForms,svgFactory:new j.DOMSVGFactory,annotationStorage:e.annotationStorage||new G.AnnotationStorage,enableScripting:!0===e.enableScripting,hasJSActions:e.hasJSActions,fieldObjects:e.fieldObjects,parent:this,elements:null};for(let e of t){if(e.noHTML)continue;let t=e.annotationType===V.AnnotationType.POPUP;if(t){let t=i.get(e.id);if(!t)continue;r.elements=t}else{let{width:t,height:n}=J(e.rect);if(t<=0||n<=0)continue}r.data=e;let n=Z.create(r);if(!n.isRenderable)continue;if(!t&&e.popupRef){let t=i.get(e.popupRef);t?t.push(n):i.set(e.popupRef,[n])}n.annotationEditorType>0&&le(this,U).set(n.data.id,n);let a=n.render();if(e.hidden&&(a.style.visibility="hidden"),Array.isArray(a))for(let i of a)ft(this,F,B).call(this,i,e.id);else ft(this,F,B).call(this,a,e.id)}ft(this,z,H).call(this),yield this.l10n.translate(n)}))}update({viewport:e}){let t=this.div;this.viewport=e,(0,j.setLayerDimensions)(t,{rotation:e.rotation}),ft(this,z,H).call(this),t.hidden=!1}getEditableAnnotations(){return Array.from(le(this,U).values())}getEditableAnnotation(e){return le(this,U).get(e)}}},(e,t)=>{function n(e){return Math.floor(255*Math.max(0,Math.min(1,e))).toString(16).padStart(2,"0")}Object.defineProperty(t,"__esModule",{value:!0}),t.ColorConverters=void 0,t.ColorConverters=class{static CMYK_G([e,t,n,i]){return["G",1-Math.min(1,.3*e+.59*n+.11*t+i)]}static G_CMYK([e]){return["CMYK",0,0,0,1-e]}static G_RGB([e]){return["RGB",e,e,e]}static G_HTML([e]){let t=n(e);return`#${t}${t}${t}`}static RGB_G([e,t,n]){return["G",.3*e+.59*t+.11*n]}static RGB_HTML([e,t,i]){return`#${n(e)}${n(t)}${n(i)}`}static T_HTML(){return"#00000000"}static CMYK_RGB([e,t,n,i]){return["RGB",1-Math.min(1,e+i),1-Math.min(1,n+i),1-Math.min(1,t+i)]}static CMYK_HTML(e){let t=this.CMYK_RGB(e).slice(1);return this.RGB_HTML(t)}static RGB_CMYK([e,t,n]){let i=1-e,r=1-t,a=1-n;return["CMYK",i,r,a,Math.min(i,r,a)]}}},(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.XfaLayer=void 0;var i=n(19);t.XfaLayer=class{static setupStorage(e,t,n,i,r){let a=i.getValue(t,{value:null});switch(n.name){case"textarea":if(null!==a.value&&(e.textContent=a.value),"print"===r)break;e.addEventListener("input",(e=>{i.setValue(t,{value:e.target.value})}));break;case"input":if("radio"===n.attributes.type||"checkbox"===n.attributes.type){if(a.value===n.attributes.xfaOn?e.setAttribute("checked",!0):a.value===n.attributes.xfaOff&&e.removeAttribute("checked"),"print"===r)break;e.addEventListener("change",(e=>{i.setValue(t,{value:e.target.checked?e.target.getAttribute("xfaOn"):e.target.getAttribute("xfaOff")})}))}else{if(null!==a.value&&e.setAttribute("value",a.value),"print"===r)break;e.addEventListener("input",(e=>{i.setValue(t,{value:e.target.value})}))}break;case"select":if(null!==a.value)for(let e of n.children)e.attributes.value===a.value&&(e.attributes.selected=!0);e.addEventListener("input",(e=>{let n=e.target.options,r=-1===n.selectedIndex?"":n[n.selectedIndex].value;i.setValue(t,{value:r})}))}}static setAttributes({html:e,element:t,storage:n=null,intent:i,linkService:r}){let{attributes:a}=t,s=e instanceof HTMLAnchorElement;"radio"===a.type&&(a.name=`${a.name}-${i}`);for(let[o,l]of Object.entries(a))if(null!=l)switch(o){case"class":l.length&&e.setAttribute(o,l.join(" "));break;case"dataId":break;case"id":e.setAttribute("data-element-id",l);break;case"style":Object.assign(e.style,l);break;case"textContent":e.textContent=l;break;default:(!s||"href"!==o&&"newWindow"!==o)&&e.setAttribute(o,l)}s&&r.addLinkAttributes(e,a.href,a.newWindow),n&&a.dataId&&this.setupStorage(e,a.dataId,t,n)}static render(e){var t;let n=e.annotationStorage,r=e.linkService,a=e.xfaHtml,s=e.intent||"display",o=document.createElement(a.name);a.attributes&&this.setAttributes({html:o,element:a,intent:s,linkService:r});let l=[[a,-1,o]],h=e.div;if(h.append(o),e.viewport){let t=`matrix(${e.viewport.transform.join(",")})`;h.style.transform=t}"richText"!==s&&h.setAttribute("class","xfaLayer xfaFont");let u=[];for(;l.length>0;){let[e,a,o]=l.at(-1);if(a+1===e.children.length){l.pop();continue}let h=e.children[++l.at(-1)[1]];if(null===h)continue;let c,{name:d}=h;if("#text"!==d){if(c=null!=(t=null==h?void 0:h.attributes)&&t.xmlns?document.createElementNS(h.attributes.xmlns,d):document.createElement(d),o.append(c),h.attributes&&this.setAttributes({html:c,element:h,storage:n,intent:s,linkService:r}),h.children&&h.children.length>0)l.push([h,-1,c]);else if(h.value){let e=document.createTextNode(h.value);i.XfaText.shouldBuildText(d)&&u.push(e),c.append(e)}}else{let e=document.createTextNode(h.value);u.push(e),o.append(e)}}for(let i of h.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))i.setAttribute("readOnly",!0);return{textDivs:u}}static update(e){let t=`matrix(${e.viewport.transform.join(",")})`;e.div.style.transform=t,e.div.hidden=!1}}},(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.NullL10n=void 0,t.getL10nFallback=i;let n={of_pages:"of {{pagesCount}}",page_of_pages:"({{pageNumber}} of {{pagesCount}})",document_properties_kb:"{{size_kb}} KB ({{size_b}} bytes)",document_properties_mb:"{{size_mb}} MB ({{size_b}} bytes)",document_properties_date_string:"{{date}}, {{time}}",document_properties_page_size_unit_inches:"in",document_properties_page_size_unit_millimeters:"mm",document_properties_page_size_orientation_portrait:"portrait",document_properties_page_size_orientation_landscape:"landscape",document_properties_page_size_name_a3:"A3",document_properties_page_size_name_a4:"A4",document_properties_page_size_name_letter:"Letter",document_properties_page_size_name_legal:"Legal",document_properties_page_size_dimension_string:"{{width}} \xd7 {{height}} {{unit}} ({{orientation}})",document_properties_page_size_dimension_name_string:"{{width}} \xd7 {{height}} {{unit}} ({{name}}, {{orientation}})",document_properties_linearized_yes:"Yes",document_properties_linearized_no:"No",additional_layers:"Additional Layers",page_landmark:"Page {{page}}",thumb_page_title:"Page {{page}}",thumb_page_canvas:"Thumbnail of Page {{page}}",find_reached_top:"Reached top of document, continued from bottom",find_reached_bottom:"Reached end of document, continued from top","find_match_count[one]":"{{current}} of {{total}} match","find_match_count[other]":"{{current}} of {{total}} matches","find_match_count_limit[one]":"More than {{limit}} match","find_match_count_limit[other]":"More than {{limit}} matches",find_not_found:"Phrase not found",page_scale_width:"Page Width",page_scale_fit:"Page Fit",page_scale_auto:"Automatic Zoom",page_scale_actual:"Actual Size",page_scale_percent:"{{scale}}%",loading_error:"An error occurred while loading the PDF.",invalid_file_error:"Invalid or corrupted PDF file.",missing_file_error:"Missing PDF file.",unexpected_response_error:"Unexpected server response.",rendering_error:"An error occurred while rendering the page.",annotation_date_string:"{{date}}, {{time}}",printing_not_supported:"Warning: Printing is not fully supported by this browser.",printing_not_ready:"Warning: The PDF is not fully loaded for printing.",web_fonts_disabled:"Web fonts are disabled: unable to use embedded PDF fonts.",free_text2_default_content:"Start typing\u2026",editor_free_text2_aria_label:"Text Editor",editor_ink2_aria_label:"Draw Editor",editor_ink_canvas_aria_label:"User-created image"};function i(e,t){switch(e){case"find_match_count":e=`find_match_count[${1===t.total?"one":"other"}]`;break;case"find_match_count_limit":e=`find_match_count_limit[${1===t.limit?"one":"other"}]`}return n[e]||""}n.print_progress_percent="{{progress}}%";let r={getLanguage(){return it(this,null,(function*(){return"en-us"}))},getDirection(){return it(this,null,(function*(){return"ltr"}))},get(e){return it(this,arguments,(function*(e,t=null,n=i(e,t)){return function(e,t){return t?e.replaceAll(/\{\{\s*(\w+)\s*\}\}/g,((e,n)=>n in t?t[n]:"{{"+n+"}}")):e}(n,t)}))},translate(e){return it(this,null,(function*(){}))}};t.NullL10n=r},(e,t,n)=>{var i,r,a,s,o,l,h,u,c,d,p,f,m,g,v,y,x,b,_,w,S,M,E,T,A,C,P,R,L,I,k,O,D,N,U,F,B,z,H,V,j,G,W,X,Y,q,J,Z,K,$,Q,ee,te,ne,ie,re,ae,se,oe,he,ue,ce,de,pe,fe,me,ge,ve,ye,xe;Object.defineProperty(t,"__esModule",{value:!0}),t.InkEditor=void 0;var be=n(1),_e=n(4),we=n(29),Se=n(5);let Me=16,Ee=class extends _e.AnnotationEditor{constructor(e){super(Ci(Ir({},e),{name:"inkEditor"})),Je(this,x),Je(this,_),Je(this,S),Je(this,E),Je(this,A),Je(this,P),Je(this,L),Je(this,k),Je(this,D),Je(this,U),Je(this,B),Je(this,H),Je(this,j),Je(this,W),Je(this,Y),Je(this,J),Je(this,K),Je(this,Q),Je(this,te),Je(this,ue),Je(this,de),Je(this,fe),Je(this,ge),Je(this,ye),Je(this,i,0),Je(this,r,0),Je(this,a,0),Je(this,s,this.canvasContextMenu.bind(this)),Je(this,o,this.canvasPointermove.bind(this)),Je(this,l,this.canvasPointerleave.bind(this)),Je(this,h,this.canvasPointerup.bind(this)),Je(this,u,this.canvasPointerdown.bind(this)),Je(this,c,new Path2D),Je(this,d,!1),Je(this,p,!1),Je(this,f,!1),Je(this,m,null),Je(this,g,0),Je(this,v,0),Je(this,y,null),this.color=e.color||null,this.thickness=e.thickness||null,this.opacity=e.opacity||null,this.paths=[],this.bezierPath2D=[],this.allRawPaths=[],this.currentPath=[],this.scaleFactor=1,this.translationX=this.translationY=0,this.x=0,this.y=0}static initialize(e){this._l10nPromise=new Map(["editor_ink_canvas_aria_label","editor_ink2_aria_label"].map((t=>[t,e.get(t)])))}static updateDefaultParams(e,t){switch(e){case be.AnnotationEditorParamsType.INK_THICKNESS:Ee._defaultThickness=t;break;case be.AnnotationEditorParamsType.INK_COLOR:Ee._defaultColor=t;break;case be.AnnotationEditorParamsType.INK_OPACITY:Ee._defaultOpacity=t/100}}updateParams(e,t){switch(e){case be.AnnotationEditorParamsType.INK_THICKNESS:ft(this,x,b).call(this,t);break;case be.AnnotationEditorParamsType.INK_COLOR:ft(this,_,w).call(this,t);break;case be.AnnotationEditorParamsType.INK_OPACITY:ft(this,S,M).call(this,t)}}static get defaultPropertiesToUpdate(){return[[be.AnnotationEditorParamsType.INK_THICKNESS,Ee._defaultThickness],[be.AnnotationEditorParamsType.INK_COLOR,Ee._defaultColor||_e.AnnotationEditor._defaultLineColor],[be.AnnotationEditorParamsType.INK_OPACITY,Math.round(100*Ee._defaultOpacity)]]}get propertiesToUpdate(){var e;return[[be.AnnotationEditorParamsType.INK_THICKNESS,this.thickness||Ee._defaultThickness],[be.AnnotationEditorParamsType.INK_COLOR,this.color||Ee._defaultColor||_e.AnnotationEditor._defaultLineColor],[be.AnnotationEditorParamsType.INK_OPACITY,Math.round(100*(null!=(e=this.opacity)?e:Ee._defaultOpacity))]]}rebuild(){super.rebuild(),null!==this.div&&(this.canvas||(ft(this,Y,q).call(this),ft(this,J,Z).call(this)),this.isAttachedToDOM||(this.parent.add(this),ft(this,K,$).call(this)),ft(this,ge,ve).call(this))}remove(){null!==this.canvas&&(this.isEmpty()||this.commit(),this.canvas.width=this.canvas.height=0,this.canvas.remove(),this.canvas=null,le(this,m).disconnect(),wt(this,m,null),super.remove())}setParent(e){!this.parent&&e?this._uiManager.removeShouldRescale(this):this.parent&&null===e&&this._uiManager.addShouldRescale(this),super.setParent(e)}onScaleChanging(){let[e,t]=this.parentDimensions,n=this.width*e,i=this.height*t;this.setDimensions(n,i)}enableEditMode(){le(this,d)||null===this.canvas||(super.enableEditMode(),this.div.draggable=!1,this.canvas.addEventListener("pointerdown",le(this,u)))}disableEditMode(){!this.isInEditMode()||null===this.canvas||(super.disableEditMode(),this.div.draggable=!this.isEmpty(),this.div.classList.remove("editing"),this.canvas.removeEventListener("pointerdown",le(this,u)))}onceAdded(){this.div.draggable=!this.isEmpty()}isEmpty(){return 0===this.paths.length||1===this.paths.length&&0===this.paths[0].length}commit(){le(this,d)||(super.commit(),this.isEditing=!1,this.disableEditMode(),this.setInForeground(),wt(this,d,!0),this.div.classList.add("disabled"),ft(this,ge,ve).call(this,!0),this.parent.addInkEditorIfNeeded(!0),this.parent.moveEditorInDOM(this),this.div.focus({preventScroll:!0}))}focusin(e){super.focusin(e),this.enableEditMode()}canvasPointerdown(e){0!==e.button||!this.isInEditMode()||le(this,d)||(this.setInForeground(),e.preventDefault(),"mouse"!==e.type&&this.div.focus(),ft(this,P,R).call(this,e.offsetX,e.offsetY))}canvasContextMenu(e){e.preventDefault()}canvasPointermove(e){e.preventDefault(),ft(this,L,I).call(this,e.offsetX,e.offsetY)}canvasPointerup(e){e.preventDefault(),ft(this,W,X).call(this,e)}canvasPointerleave(e){ft(this,W,X).call(this,e)}render(){if(this.div)return this.div;let e,t;this.width&&(e=this.x,t=this.y),super.render(),Ee._l10nPromise.get("editor_ink2_aria_label").then((e=>{var t;return null==(t=this.div)?void 0:t.setAttribute("aria-label",e)}));let[n,i,r,a]=ft(this,E,T).call(this);if(this.setAt(n,i,0,0),this.setDims(r,a),ft(this,Y,q).call(this),this.width){let[n,i]=this.parentDimensions;this.setAt(e*n,t*i,this.width*n,this.height*i),wt(this,f,!0),ft(this,K,$).call(this),this.setDims(this.width*n,this.height*i),ft(this,j,G).call(this),ft(this,ye,xe).call(this),this.div.classList.add("disabled")}else this.div.classList.add("editing"),this.enableEditMode();return ft(this,J,Z).call(this),this.div}setDimensions(e,t){let n=Math.round(e),r=Math.round(t);if(le(this,g)===n&&le(this,v)===r)return;wt(this,g,n),wt(this,v,r),this.canvas.style.visibility="hidden",le(this,i)&&Math.abs(le(this,i)-e/t)>.01&&(t=Math.ceil(e/le(this,i)),this.setDims(e,t));let[a,s]=this.parentDimensions;this.width=e/a,this.height=t/s,le(this,d)&&ft(this,Q,ee).call(this,e,t),ft(this,K,$).call(this),ft(this,j,G).call(this),this.canvas.style.visibility="visible",this.fixDims()}static deserialize(e,t,n){var s,o,l;if(e instanceof we.InkAnnotationElement)return null;let h=super.deserialize(e,t,n);h.thickness=e.thickness,h.color=be.Util.makeHexColor(...e.color),h.opacity=e.opacity;let[u,c]=h.pageDimensions,p=h.width*u,f=h.height*c,m=h.parentScale,y=e.thickness/2;wt(h,i,p/f),wt(h,d,!0),wt(h,g,Math.round(p)),wt(h,v,Math.round(f));let{paths:x,rect:b,rotation:_}=e;for(let{bezier:i}of x){i=ft(s=Ee,oe,he).call(s,i,b,_);let e=[];h.paths.push(e);let t=m*(i[0]-y),n=m*(i[1]-y);for(let a=2,s=i.length;a<s;a+=6){let r=m*(i[a]-y),s=m*(i[a+1]-y),o=m*(i[a+2]-y),l=m*(i[a+3]-y),h=m*(i[a+4]-y),u=m*(i[a+5]-y);e.push([[t,n],[r,s],[o,l],[h,u]]),t=h,n=u}let r=ft(this,ie,re).call(this,e);h.bezierPath2D.push(r)}let w=ft(o=h,de,pe).call(o);return wt(h,a,Math.max(Me,w[2]-w[0])),wt(h,r,Math.max(Me,w[3]-w[1])),ft(l=h,Q,ee).call(l,p,f),h}serialize(){if(this.isEmpty())return null;let e=this.getRect(0,0),t=_e.AnnotationEditor._colorManager.convert(this.ctx.strokeStyle);return{annotationType:be.AnnotationEditorType.INK,color:t,thickness:this.thickness,opacity:this.opacity,paths:ft(this,ue,ce).call(this,this.scaleFactor/this.parentScale,this.translationX,this.translationY,e),pageIndex:this.pageIndex,rect:e,rotation:this.rotation}}},Te=Ee;i=new WeakMap,r=new WeakMap,a=new WeakMap,s=new WeakMap,o=new WeakMap,l=new WeakMap,h=new WeakMap,u=new WeakMap,c=new WeakMap,d=new WeakMap,p=new WeakMap,f=new WeakMap,m=new WeakMap,g=new WeakMap,v=new WeakMap,y=new WeakMap,x=new WeakSet,b=function(e){let t=this.thickness;this.addCommands({cmd:()=>{this.thickness=e,ft(this,ge,ve).call(this)},undo:()=>{this.thickness=t,ft(this,ge,ve).call(this)},mustExec:!0,type:be.AnnotationEditorParamsType.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0})},_=new WeakSet,w=function(e){let t=this.color;this.addCommands({cmd:()=>{this.color=e,ft(this,j,G).call(this)},undo:()=>{this.color=t,ft(this,j,G).call(this)},mustExec:!0,type:be.AnnotationEditorParamsType.INK_COLOR,overwriteIfSameType:!0,keepUndo:!0})},S=new WeakSet,M=function(e){e/=100;let t=this.opacity;this.addCommands({cmd:()=>{this.opacity=e,ft(this,j,G).call(this)},undo:()=>{this.opacity=t,ft(this,j,G).call(this)},mustExec:!0,type:be.AnnotationEditorParamsType.INK_OPACITY,overwriteIfSameType:!0,keepUndo:!0})},E=new WeakSet,T=function(){let{parentRotation:e,parentDimensions:[t,n]}=this;switch(e){case 90:return[0,n,n,t];case 180:return[t,n,t,n];case 270:return[t,0,n,t];default:return[0,0,t,n]}},A=new WeakSet,C=function(){let{ctx:e,color:t,opacity:n,thickness:i,parentScale:r,scaleFactor:a}=this;e.lineWidth=i*r/a,e.lineCap="round",e.lineJoin="round",e.miterLimit=10,e.strokeStyle=`${t}${(0,Se.opacityToHex)(n)}`},P=new WeakSet,R=function(e,t){this.canvas.addEventListener("contextmenu",le(this,s)),this.canvas.addEventListener("pointerleave",le(this,l)),this.canvas.addEventListener("pointermove",le(this,o)),this.canvas.addEventListener("pointerup",le(this,h)),this.canvas.removeEventListener("pointerdown",le(this,u)),this.isEditing=!0,le(this,f)||(wt(this,f,!0),ft(this,K,$).call(this),this.thickness||(this.thickness=Ee._defaultThickness),this.color||(this.color=Ee._defaultColor||_e.AnnotationEditor._defaultLineColor),null!=this.opacity||(this.opacity=Ee._defaultOpacity)),this.currentPath.push([e,t]),wt(this,p,!1),ft(this,A,C).call(this),wt(this,y,(()=>{ft(this,U,F).call(this),le(this,y)&&window.requestAnimationFrame(le(this,y))})),window.requestAnimationFrame(le(this,y))},L=new WeakSet,I=function(e,t){let[n,i]=this.currentPath.at(-1);if(this.currentPath.length>1&&e===n&&t===i)return;let r=this.currentPath,a=le(this,c);if(r.push([e,t]),wt(this,p,!0),r.length<=2)return a.moveTo(...r[0]),void a.lineTo(e,t);3===r.length&&(wt(this,c,a=new Path2D),a.moveTo(...r[0])),ft(this,B,z).call(this,a,...r.at(-3),...r.at(-2),e,t)},k=new WeakSet,O=function(){if(0===this.currentPath.length)return;let e=this.currentPath.at(-1);le(this,c).lineTo(...e)},D=new WeakSet,N=function(e,t){let n;if(wt(this,y,null),e=Math.min(Math.max(e,0),this.canvas.width),t=Math.min(Math.max(t,0),this.canvas.height),ft(this,L,I).call(this,e,t),ft(this,k,O).call(this),1!==this.currentPath.length)n=ft(this,H,V).call(this);else{let i=[e,t];n=[[i,i.slice(),i.slice(),i]]}let i=le(this,c),r=this.currentPath;this.currentPath=[],wt(this,c,new Path2D),this.addCommands({cmd:()=>{this.allRawPaths.push(r),this.paths.push(n),this.bezierPath2D.push(i),this.rebuild()},undo:()=>{this.allRawPaths.pop(),this.paths.pop(),this.bezierPath2D.pop(),0===this.paths.length?this.remove():(this.canvas||(ft(this,Y,q).call(this),ft(this,J,Z).call(this)),ft(this,ge,ve).call(this))},mustExec:!0})},U=new WeakSet,F=function(){if(!le(this,p))return;wt(this,p,!1),Math.ceil(this.thickness*this.parentScale);let e=this.currentPath.slice(-3),t=e.map((e=>e[0])),n=e.map((e=>e[1])),{ctx:i}=(Math.min(...t),Math.max(...t),Math.min(...n),Math.max(...n),this);i.save(),i.clearRect(0,0,this.canvas.width,this.canvas.height);for(let r of this.bezierPath2D)i.stroke(r);i.stroke(le(this,c)),i.restore()},B=new WeakSet,z=function(e,t,n,i,r,a,s){let o=(t+i)/2,l=(n+r)/2,h=(i+a)/2,u=(r+s)/2;e.bezierCurveTo(o+2*(i-o)/3,l+2*(r-l)/3,h+2*(i-h)/3,u+2*(r-u)/3,h,u)},H=new WeakSet,V=function(){let e=this.currentPath;if(e.length<=2)return[[e[0],e[0],e.at(-1),e.at(-1)]];let t,n=[],[i,r]=e[0];for(t=1;t<e.length-2;t++){let[a,s]=e[t],[o,l]=e[t+1],h=(a+o)/2,u=(s+l)/2,c=[i+2*(a-i)/3,r+2*(s-r)/3],d=[h+2*(a-h)/3,u+2*(s-u)/3];n.push([[i,r],c,d,[h,u]]),[i,r]=[h,u]}let[a,s]=e[t],[o,l]=e[t+1],h=[i+2*(a-i)/3,r+2*(s-r)/3],u=[o+2*(a-o)/3,l+2*(s-l)/3];return n.push([[i,r],h,u,[o,l]]),n},j=new WeakSet,G=function(){if(this.isEmpty())return void ft(this,te,ne).call(this);ft(this,A,C).call(this);let{canvas:e,ctx:t}=this;t.setTransform(1,0,0,1,0,0),t.clearRect(0,0,e.width,e.height),ft(this,te,ne).call(this);for(let n of this.bezierPath2D)t.stroke(n)},W=new WeakSet,X=function(e){this.canvas.removeEventListener("pointerleave",le(this,l)),this.canvas.removeEventListener("pointermove",le(this,o)),this.canvas.removeEventListener("pointerup",le(this,h)),this.canvas.addEventListener("pointerdown",le(this,u)),setTimeout((()=>{this.canvas.removeEventListener("contextmenu",le(this,s))}),10),ft(this,D,N).call(this,e.offsetX,e.offsetY),this.addToAnnotationStorage(),this.setInBackground()},Y=new WeakSet,q=function(){this.canvas=document.createElement("canvas"),this.canvas.width=this.canvas.height=0,this.canvas.className="inkEditorCanvas",Ee._l10nPromise.get("editor_ink_canvas_aria_label").then((e=>{var t;return null==(t=this.canvas)?void 0:t.setAttribute("aria-label",e)})),this.div.append(this.canvas),this.ctx=this.canvas.getContext("2d")},J=new WeakSet,Z=function(){wt(this,m,new ResizeObserver((e=>{let t=e[0].contentRect;t.width&&t.height&&this.setDimensions(t.width,t.height)}))),le(this,m).observe(this.div)},K=new WeakSet,$=function(){if(!le(this,f))return;let[e,t]=this.parentDimensions;this.canvas.width=Math.ceil(this.width*e),this.canvas.height=Math.ceil(this.height*t),ft(this,te,ne).call(this)},Q=new WeakSet,ee=function(e,t){let n=ft(this,fe,me).call(this),i=(e-n)/le(this,a),s=(t-n)/le(this,r);this.scaleFactor=Math.min(i,s)},te=new WeakSet,ne=function(){let e=ft(this,fe,me).call(this)/2;this.ctx.setTransform(this.scaleFactor,0,0,this.scaleFactor,this.translationX*this.scaleFactor+e,this.translationY*this.scaleFactor+e)},ie=new WeakSet,re=function(e){let t=new Path2D;for(let n=0,i=e.length;n<i;n++){let[i,r,a,s]=e[n];0===n&&t.moveTo(...i),t.bezierCurveTo(r[0],r[1],a[0],a[1],s[0],s[1])}return t},ae=new WeakSet,se=function(e,t,n){let[i,r,a,s]=t;switch(n){case 0:for(let t=0,n=e.length;t<n;t+=2)e[t]+=i,e[t+1]=s-e[t+1];break;case 90:for(let t=0,n=e.length;t<n;t+=2){let n=e[t];e[t]=e[t+1]+i,e[t+1]=n+r}break;case 180:for(let t=0,n=e.length;t<n;t+=2)e[t]=a-e[t],e[t+1]+=r;break;case 270:for(let t=0,n=e.length;t<n;t+=2){let n=e[t];e[t]=a-e[t+1],e[t+1]=s-n}break;default:throw new Error("Invalid rotation")}return e},oe=new WeakSet,he=function(e,t,n){let[i,r,a,s]=t;switch(n){case 0:for(let t=0,n=e.length;t<n;t+=2)e[t]-=i,e[t+1]=s-e[t+1];break;case 90:for(let t=0,n=e.length;t<n;t+=2){let n=e[t];e[t]=e[t+1]-r,e[t+1]=n-i}break;case 180:for(let t=0,n=e.length;t<n;t+=2)e[t]=a-e[t],e[t+1]-=r;break;case 270:for(let t=0,n=e.length;t<n;t+=2){let n=e[t];e[t]=s-e[t+1],e[t+1]=a-n}break;default:throw new Error("Invalid rotation")}return e},ue=new WeakSet,ce=function(e,t,n,i){var r,a;let s=[],o=this.thickness/2,l=e*t+o,h=e*n+o;for(let u of this.paths){let t=[],n=[];for(let i=0,r=u.length;i<r;i++){let[a,s,o,c]=u[i],d=e*a[0]+l,p=e*a[1]+h,f=e*s[0]+l,m=e*s[1]+h,g=e*o[0]+l,v=e*o[1]+h,y=e*c[0]+l,x=e*c[1]+h;0===i&&(t.push(d,p),n.push(d,p)),t.push(f,m,g,v,y,x),n.push(f,m),i===r-1&&n.push(y,x)}s.push({bezier:ft(r=Ee,ae,se).call(r,t,i,this.rotation),points:ft(a=Ee,ae,se).call(a,n,i,this.rotation)})}return s},de=new WeakSet,pe=function(){let e=1/0,t=-1/0,n=1/0,i=-1/0;for(let r of this.paths)for(let[a,s,o,l]of r){let r=be.Util.bezierBoundingBox(...a,...s,...o,...l);e=Math.min(e,r[0]),n=Math.min(n,r[1]),t=Math.max(t,r[2]),i=Math.max(i,r[3])}return[e,n,t,i]},fe=new WeakSet,me=function(){return le(this,d)?Math.ceil(this.thickness*this.parentScale):0},ge=new WeakSet,ve=function(e=!1){if(this.isEmpty())return;if(!le(this,d))return void ft(this,j,G).call(this);let t=ft(this,de,pe).call(this),n=ft(this,fe,me).call(this);wt(this,a,Math.max(Me,t[2]-t[0])),wt(this,r,Math.max(Me,t[3]-t[1]));let s=Math.ceil(n+le(this,a)*this.scaleFactor),o=Math.ceil(n+le(this,r)*this.scaleFactor),[l,h]=this.parentDimensions;this.width=s/l,this.height=o/h,wt(this,i,s/o),ft(this,ye,xe).call(this);let u=this.translationX,c=this.translationY;this.translationX=-t[0],this.translationY=-t[1],ft(this,K,$).call(this),ft(this,j,G).call(this),wt(this,g,s),wt(this,v,o),this.setDims(s,o);let p=e?n/this.scaleFactor/2:0;this.translate(u-this.translationX-p,c-this.translationY-p)},ye=new WeakSet,xe=function(){let{style:e}=this.div;le(this,i)>=1?(e.minHeight="16px",e.minWidth=`${Math.round(le(this,i)*Me)}px`):(e.minWidth="16px",e.minHeight=`${Math.round(Me/le(this,i))}px`)},Je(Te,ie),Je(Te,ae),Je(Te,oe),Yi(Te,"_defaultColor",null),Yi(Te,"_defaultOpacity",1),Yi(Te,"_defaultThickness",1),Yi(Te,"_l10nPromise"),Yi(Te,"_type","ink"),t.InkEditor=Te},(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SVGGraphics=void 0;var i=n(6),r=n(1),a=n(10);let s="normal",o="#000000",l=["butt","round","square"],h=["miter","round","bevel"],u=function(e,t="",n=!1){if(URL.createObjectURL&&"undefined"!=typeof Blob&&!n)return URL.createObjectURL(new Blob([e],{type:t}));let i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",r=`data:${t};base64,`;for(let a=0,s=e.length;a<s;a+=3){let t=255&e[a],n=255&e[a+1],o=255&e[a+2];r+=i[t>>2]+i[(3&t)<<4|n>>4]+i[a+1<s?(15&n)<<2|o>>6:64]+i[a+2<s?63&o:64]}return r},c=function(){let e=new Uint8Array([137,80,78,71,13,10,26,10]),t=new Int32Array(256);for(let r=0;r<256;r++){let e=r;for(let t=0;t<8;t++)e=1&e?3988292384^e>>1&2147483647:e>>1&2147483647;t[r]=e}function n(e,n,i,r){let a=r,s=n.length;i[a]=s>>24&255,i[a+1]=s>>16&255,i[a+2]=s>>8&255,i[a+3]=255&s,a+=4,i[a]=255&e.charCodeAt(0),i[a+1]=255&e.charCodeAt(1),i[a+2]=255&e.charCodeAt(2),i[a+3]=255&e.charCodeAt(3),a+=4,i.set(n,a),a+=n.length;let o=function(e,n,i){let r=-1;for(let a=n;a<i;a++){let n=255&(r^e[a]);r=r>>>8^t[n]}return-1^r}(i,r+4,a);i[a]=o>>24&255,i[a+1]=o>>16&255,i[a+2]=o>>8&255,i[a+3]=255&o}function i(e){let t=e.length,n=65535,i=Math.ceil(t/n),r=new Uint8Array(2+t+5*i+4),a=0;r[a++]=120,r[a++]=156;let s=0;for(;t>n;)r[a++]=0,r[a++]=255,r[a++]=255,r[a++]=0,r[a++]=0,r.set(e.subarray(s,s+n),a),a+=n,s+=n,t-=n;r[a++]=1,r[a++]=255&t,r[a++]=t>>8&255,r[a++]=255&~t,r[a++]=(65535&~t)>>8&255,r.set(e.subarray(s),a),a+=e.length-s;let o=function(e,t,n){let i=1,r=0;for(let a=0;a<n;++a)i=(i+(255&e[a]))%65521,r=(r+i)%65521;return r<<16|i}(e,0,e.length);return r[a++]=o>>24&255,r[a++]=o>>16&255,r[a++]=o>>8&255,r[a++]=255&o,r}function s(t,s,o,l){let h,c,d,p=t.width,f=t.height,m=t.data;switch(s){case r.ImageKind.GRAYSCALE_1BPP:c=0,h=1,d=p+7>>3;break;case r.ImageKind.RGB_24BPP:c=2,h=8,d=3*p;break;case r.ImageKind.RGBA_32BPP:c=6,h=8,d=4*p;break;default:throw new Error("invalid format")}let g=new Uint8Array((1+d)*f),v=0,y=0;for(let e=0;e<f;++e)g[v++]=0,g.set(m.subarray(y,y+d),v),y+=d,v+=d;if(s===r.ImageKind.GRAYSCALE_1BPP&&l){v=0;for(let e=0;e<f;e++){v++;for(let e=0;e<d;e++)g[v++]^=255}}let x=new Uint8Array([p>>24&255,p>>16&255,p>>8&255,255&p,f>>24&255,f>>16&255,f>>8&255,255&f,h,c,0,0,0]),b=function(e){if(!a.isNodeJS)return i(e);try{let t;t=parseInt(process.versions.node)>=8?e:Buffer.from(e);let n=w1e().deflateSync(t,{level:9});return n instanceof Uint8Array?n:new Uint8Array(n)}catch(e){(0,r.warn)("Not compressing PNG because zlib.deflateSync is unavailable: "+e)}return i(e)}(g),_=e.length+36+x.length+b.length,w=new Uint8Array(_),S=0;return w.set(e,S),S+=e.length,n("IHDR",x,w,S),S+=12+x.length,n("IDATA",b,w,S),S+=12+b.length,n("IEND",new Uint8Array(0),w,S),u(w,"image/png",o)}return function(e,t,n){return s(e,void 0===e.kind?r.ImageKind.GRAYSCALE_1BPP:e.kind,t,n)}}();class d{constructor(){this.fontSizeScale=1,this.fontWeight=s,this.fontSize=0,this.textMatrix=r.IDENTITY_MATRIX,this.fontMatrix=r.FONT_IDENTITY_MATRIX,this.leading=0,this.textRenderingMode=r.TextRenderingMode.FILL,this.textMatrixScale=1,this.x=0,this.y=0,this.lineX=0,this.lineY=0,this.charSpacing=0,this.wordSpacing=0,this.textHScale=1,this.textRise=0,this.fillColor=o,this.strokeColor="#000000",this.fillAlpha=1,this.strokeAlpha=1,this.lineWidth=1,this.lineJoin="",this.lineCap="",this.miterLimit=0,this.dashArray=[],this.dashPhase=0,this.dependencies=[],this.activeClipUrl=null,this.clipGroup=null,this.maskId=""}clone(){return Object.create(this)}setCurrentPoint(e,t){this.x=e,this.y=t}}function p(e){if(Number.isInteger(e))return e.toString();let t=e.toFixed(10),n=t.length-1;if("0"!==t[n])return t;do{n--}while("0"===t[n]);return t.substring(0,"."===t[n]?n:n+1)}function f(e){if(0===e[4]&&0===e[5]){if(0===e[1]&&0===e[2])return 1===e[0]&&1===e[3]?"":`scale(${p(e[0])} ${p(e[3])})`;if(e[0]===e[3]&&e[1]===-e[2])return`rotate(${p(180*Math.acos(e[0])/Math.PI)})`}else if(1===e[0]&&0===e[1]&&0===e[2]&&1===e[3])return`translate(${p(e[4])} ${p(e[5])})`;return`matrix(${p(e[0])} ${p(e[1])} ${p(e[2])} ${p(e[3])} ${p(e[4])} ${p(e[5])})`}let m=0,g=0,v=0;t.SVGGraphics=class{constructor(e,t,n=!1){(0,i.deprecated)("The SVG back-end is no longer maintained and *may* be removed in the future."),this.svgFactory=new i.DOMSVGFactory,this.current=new d,this.transformMatrix=r.IDENTITY_MATRIX,this.transformStack=[],this.extraStack=[],this.commonObjs=e,this.objs=t,this.pendingClip=null,this.pendingEOFill=!1,this.embedFonts=!1,this.embeddedFonts=Object.create(null),this.cssStyle=null,this.forceDataSchema=!!n,this._operatorIdMapping=[];for(let i in r.OPS)this._operatorIdMapping[r.OPS[i]]=i}getObject(e,t=null){return"string"==typeof e?e.startsWith("g_")?this.commonObjs.get(e):this.objs.get(e):t}save(){this.transformStack.push(this.transformMatrix);let e=this.current;this.extraStack.push(e),this.current=e.clone()}restore(){this.transformMatrix=this.transformStack.pop(),this.current=this.extraStack.pop(),this.pendingClip=null,this.tgrp=null}group(e){this.save(),this.executeOpTree(e),this.restore()}loadDependencies(e){let t=e.fnArray,n=e.argsArray;for(let i=0,a=t.length;i<a;i++)if(t[i]===r.OPS.dependency)for(let e of n[i]){let t=e.startsWith("g_")?this.commonObjs:this.objs,n=new Promise((n=>{t.get(e,n)}));this.current.dependencies.push(n)}return Promise.all(this.current.dependencies)}transform(e,t,n,i,a,s){let o=[e,t,n,i,a,s];this.transformMatrix=r.Util.transform(this.transformMatrix,o),this.tgrp=null}getSVG(e,t){this.viewport=t;let n=this._initialize(t);return this.loadDependencies(e).then((()=>(this.transformMatrix=r.IDENTITY_MATRIX,this.executeOpTree(this.convertOpList(e)),n)))}convertOpList(e){let t=this._operatorIdMapping,n=e.argsArray,i=e.fnArray,r=[];for(let a=0,s=i.length;a<s;a++){let e=i[a];r.push({fnId:e,fn:t[e],args:n[a]})}return function(e){let t=[],n=[];for(let i of e)"save"!==i.fn?"restore"===i.fn?t=n.pop():t.push(i):(t.push({fnId:92,fn:"group",items:[]}),n.push(t),t=t.at(-1).items);return t}(r)}executeOpTree(e){for(let t of e){let e=t.fn,n=t.fnId,i=t.args;switch(0|n){case r.OPS.beginText:this.beginText();break;case r.OPS.dependency:break;case r.OPS.setLeading:this.setLeading(i);break;case r.OPS.setLeadingMoveText:this.setLeadingMoveText(i[0],i[1]);break;case r.OPS.setFont:this.setFont(i);break;case r.OPS.showText:case r.OPS.showSpacedText:this.showText(i[0]);break;case r.OPS.endText:this.endText();break;case r.OPS.moveText:this.moveText(i[0],i[1]);break;case r.OPS.setCharSpacing:this.setCharSpacing(i[0]);break;case r.OPS.setWordSpacing:this.setWordSpacing(i[0]);break;case r.OPS.setHScale:this.setHScale(i[0]);break;case r.OPS.setTextMatrix:this.setTextMatrix(i[0],i[1],i[2],i[3],i[4],i[5]);break;case r.OPS.setTextRise:this.setTextRise(i[0]);break;case r.OPS.setTextRenderingMode:this.setTextRenderingMode(i[0]);break;case r.OPS.setLineWidth:this.setLineWidth(i[0]);break;case r.OPS.setLineJoin:this.setLineJoin(i[0]);break;case r.OPS.setLineCap:this.setLineCap(i[0]);break;case r.OPS.setMiterLimit:this.setMiterLimit(i[0]);break;case r.OPS.setFillRGBColor:this.setFillRGBColor(i[0],i[1],i[2]);break;case r.OPS.setStrokeRGBColor:this.setStrokeRGBColor(i[0],i[1],i[2]);break;case r.OPS.setStrokeColorN:this.setStrokeColorN(i);break;case r.OPS.setFillColorN:this.setFillColorN(i);break;case r.OPS.shadingFill:this.shadingFill(i[0]);break;case r.OPS.setDash:this.setDash(i[0],i[1]);break;case r.OPS.setRenderingIntent:this.setRenderingIntent(i[0]);break;case r.OPS.setFlatness:this.setFlatness(i[0]);break;case r.OPS.setGState:this.setGState(i[0]);break;case r.OPS.fill:this.fill();break;case r.OPS.eoFill:this.eoFill();break;case r.OPS.stroke:this.stroke();break;case r.OPS.fillStroke:this.fillStroke();break;case r.OPS.eoFillStroke:this.eoFillStroke();break;case r.OPS.clip:this.clip("nonzero");break;case r.OPS.eoClip:this.clip("evenodd");break;case r.OPS.paintSolidColorImageMask:this.paintSolidColorImageMask();break;case r.OPS.paintImageXObject:this.paintImageXObject(i[0]);break;case r.OPS.paintInlineImageXObject:this.paintInlineImageXObject(i[0]);break;case r.OPS.paintImageMaskXObject:this.paintImageMaskXObject(i[0]);break;case r.OPS.paintFormXObjectBegin:this.paintFormXObjectBegin(i[0],i[1]);break;case r.OPS.paintFormXObjectEnd:this.paintFormXObjectEnd();break;case r.OPS.closePath:this.closePath();break;case r.OPS.closeStroke:this.closeStroke();break;case r.OPS.closeFillStroke:this.closeFillStroke();break;case r.OPS.closeEOFillStroke:this.closeEOFillStroke();break;case r.OPS.nextLine:this.nextLine();break;case r.OPS.transform:this.transform(i[0],i[1],i[2],i[3],i[4],i[5]);break;case r.OPS.constructPath:this.constructPath(i[0],i[1]);break;case r.OPS.endPath:this.endPath();break;case 92:this.group(t.items);break;default:(0,r.warn)(`Unimplemented operator ${e}`)}}}setWordSpacing(e){this.current.wordSpacing=e}setCharSpacing(e){this.current.charSpacing=e}nextLine(){this.moveText(0,this.current.leading)}setTextMatrix(e,t,n,i,r,a){let s=this.current;s.textMatrix=s.lineMatrix=[e,t,n,i,r,a],s.textMatrixScale=Math.hypot(e,t),s.x=s.lineX=0,s.y=s.lineY=0,s.xcoords=[],s.ycoords=[],s.tspan=this.svgFactory.createElement("svg:tspan"),s.tspan.setAttributeNS(null,"font-family",s.fontFamily),s.tspan.setAttributeNS(null,"font-size",`${p(s.fontSize)}px`),s.tspan.setAttributeNS(null,"y",p(-s.y)),s.txtElement=this.svgFactory.createElement("svg:text"),s.txtElement.append(s.tspan)}beginText(){let e=this.current;e.x=e.lineX=0,e.y=e.lineY=0,e.textMatrix=r.IDENTITY_MATRIX,e.lineMatrix=r.IDENTITY_MATRIX,e.textMatrixScale=1,e.tspan=this.svgFactory.createElement("svg:tspan"),e.txtElement=this.svgFactory.createElement("svg:text"),e.txtgrp=this.svgFactory.createElement("svg:g"),e.xcoords=[],e.ycoords=[]}moveText(e,t){let n=this.current;n.x=n.lineX+=e,n.y=n.lineY+=t,n.xcoords=[],n.ycoords=[],n.tspan=this.svgFactory.createElement("svg:tspan"),n.tspan.setAttributeNS(null,"font-family",n.fontFamily),n.tspan.setAttributeNS(null,"font-size",`${p(n.fontSize)}px`),n.tspan.setAttributeNS(null,"y",p(-n.y))}showText(e){let t=this.current,n=t.font,i=t.fontSize;if(0===i)return;let a=t.fontSizeScale,l=t.charSpacing,h=t.wordSpacing,u=t.fontDirection,c=t.textHScale*u,d=n.vertical,m=d?1:-1,g=n.defaultVMetrics,v=i*t.fontMatrix[0],y=0;for(let r of e){if(null===r){y+=u*h;continue}if("number"==typeof r){y+=m*r*i/1e3;continue}let e,s,o,c=(r.isSpace?h:0)+l,p=r.fontChar,f=r.width;if(d){let t,n=r.vmetric||g;t=r.vmetric?n[1]:.5*f,t=-t*v;let i=n[2]*v;f=n?-n[0]:f,e=t/a,s=(y+i)/a}else e=y/a,s=0;(r.isInFont||n.missingFile)&&(t.xcoords.push(t.x+e),d&&t.ycoords.push(-t.y+s),t.tspan.textContent+=p),o=d?f*v-c*u:f*v+c*u,y+=o}t.tspan.setAttributeNS(null,"x",t.xcoords.map(p).join(" ")),d?t.tspan.setAttributeNS(null,"y",t.ycoords.map(p).join(" ")):t.tspan.setAttributeNS(null,"y",p(-t.y)),d?t.y-=y:t.x+=y*c,t.tspan.setAttributeNS(null,"font-family",t.fontFamily),t.tspan.setAttributeNS(null,"font-size",`${p(t.fontSize)}px`),"normal"!==t.fontStyle&&t.tspan.setAttributeNS(null,"font-style",t.fontStyle),t.fontWeight!==s&&t.tspan.setAttributeNS(null,"font-weight",t.fontWeight);let x=t.textRenderingMode&r.TextRenderingMode.FILL_STROKE_MASK;if(x===r.TextRenderingMode.FILL||x===r.TextRenderingMode.FILL_STROKE?(t.fillColor!==o&&t.tspan.setAttributeNS(null,"fill",t.fillColor),t.fillAlpha<1&&t.tspan.setAttributeNS(null,"fill-opacity",t.fillAlpha)):t.textRenderingMode===r.TextRenderingMode.ADD_TO_PATH?t.tspan.setAttributeNS(null,"fill","transparent"):t.tspan.setAttributeNS(null,"fill","none"),x===r.TextRenderingMode.STROKE||x===r.TextRenderingMode.FILL_STROKE){let e=1/(t.textMatrixScale||1);this._setStrokeAttributes(t.tspan,e)}let b=t.textMatrix;0!==t.textRise&&(b=b.slice(),b[5]+=t.textRise),t.txtElement.setAttributeNS(null,"transform",`${f(b)} scale(${p(c)}, -1)`),t.txtElement.setAttributeNS("http://www.w3.org/XML/1998/namespace","xml:space","preserve"),t.txtElement.append(t.tspan),t.txtgrp.append(t.txtElement),this._ensureTransformGroup().append(t.txtElement)}setLeadingMoveText(e,t){this.setLeading(-t),this.moveText(e,t)}addFontStyle(e){if(!e.data)throw new Error('addFontStyle: No font data available, ensure that the "fontExtraProperties" API parameter is set.');this.cssStyle||(this.cssStyle=this.svgFactory.createElement("svg:style"),this.cssStyle.setAttributeNS(null,"type","text/css"),this.defs.append(this.cssStyle));let t=u(e.data,e.mimetype,this.forceDataSchema);this.cssStyle.textContent+=`@font-face { font-family: "${e.loadedName}"; src: url(${t}); }\n`}setFont(e){let t=this.current,n=this.commonObjs.get(e[0]),i=e[1];t.font=n,this.embedFonts&&!n.missingFile&&!this.embeddedFonts[n.loadedName]&&(this.addFontStyle(n),this.embeddedFonts[n.loadedName]=n),t.fontMatrix=n.fontMatrix||r.FONT_IDENTITY_MATRIX;let a="normal";n.black?a="900":n.bold&&(a="bold");let s=n.italic?"italic":"normal";i<0?(i=-i,t.fontDirection=-1):t.fontDirection=1,t.fontSize=i,t.fontFamily=n.loadedName,t.fontWeight=a,t.fontStyle=s,t.tspan=this.svgFactory.createElement("svg:tspan"),t.tspan.setAttributeNS(null,"y",p(-t.y)),t.xcoords=[],t.ycoords=[]}endText(){var e;let t=this.current;t.textRenderingMode&r.TextRenderingMode.ADD_TO_PATH_FLAG&&null!=(e=t.txtElement)&&e.hasChildNodes()&&(t.element=t.txtElement,this.clip("nonzero"),this.endPath())}setLineWidth(e){e>0&&(this.current.lineWidth=e)}setLineCap(e){this.current.lineCap=l[e]}setLineJoin(e){this.current.lineJoin=h[e]}setMiterLimit(e){this.current.miterLimit=e}setStrokeAlpha(e){this.current.strokeAlpha=e}setStrokeRGBColor(e,t,n){this.current.strokeColor=r.Util.makeHexColor(e,t,n)}setFillAlpha(e){this.current.fillAlpha=e}setFillRGBColor(e,t,n){this.current.fillColor=r.Util.makeHexColor(e,t,n),this.current.tspan=this.svgFactory.createElement("svg:tspan"),this.current.xcoords=[],this.current.ycoords=[]}setStrokeColorN(e){this.current.strokeColor=this._makeColorN_Pattern(e)}setFillColorN(e){this.current.fillColor=this._makeColorN_Pattern(e)}shadingFill(e){let{width:t,height:n}=this.viewport,i=r.Util.inverseTransform(this.transformMatrix),[a,s,o,l]=r.Util.getAxialAlignedBoundingBox([0,0,t,n],i),h=this.svgFactory.createElement("svg:rect");h.setAttributeNS(null,"x",a),h.setAttributeNS(null,"y",s),h.setAttributeNS(null,"width",o-a),h.setAttributeNS(null,"height",l-s),h.setAttributeNS(null,"fill",this._makeShadingPattern(e)),this.current.fillAlpha<1&&h.setAttributeNS(null,"fill-opacity",this.current.fillAlpha),this._ensureTransformGroup().append(h)}_makeColorN_Pattern(e){return"TilingPattern"===e[0]?this._makeTilingPattern(e):this._makeShadingPattern(e)}_makeTilingPattern(e){let t=e[1],n=e[2],i=e[3]||r.IDENTITY_MATRIX,[a,s,o,l]=e[4],h=e[5],u=e[6],c=e[7],d="shading"+v++,[p,f,m,g]=r.Util.normalizeRect([...r.Util.applyTransform([a,s],i),...r.Util.applyTransform([o,l],i)]),[y,x]=r.Util.singularValueDecompose2dScale(i),b=h*y,_=u*x,w=this.svgFactory.createElement("svg:pattern");w.setAttributeNS(null,"id",d),w.setAttributeNS(null,"patternUnits","userSpaceOnUse"),w.setAttributeNS(null,"width",b),w.setAttributeNS(null,"height",_),w.setAttributeNS(null,"x",`${p}`),w.setAttributeNS(null,"y",`${f}`);let S=this.svg,M=this.transformMatrix,E=this.current.fillColor,T=this.current.strokeColor,A=this.svgFactory.create(m-p,g-f);if(this.svg=A,this.transformMatrix=i,2===c){let e=r.Util.makeHexColor(...t);this.current.fillColor=e,this.current.strokeColor=e}return this.executeOpTree(this.convertOpList(n)),this.svg=S,this.transformMatrix=M,this.current.fillColor=E,this.current.strokeColor=T,w.append(A.childNodes[0]),this.defs.append(w),`url(#${d})`}_makeShadingPattern(e){switch("string"==typeof e&&(e=this.objs.get(e)),e[0]){case"RadialAxial":let t,n="shading"+v++,i=e[3];switch(e[1]){case"axial":let i=e[4],r=e[5];t=this.svgFactory.createElement("svg:linearGradient"),t.setAttributeNS(null,"id",n),t.setAttributeNS(null,"gradientUnits","userSpaceOnUse"),t.setAttributeNS(null,"x1",i[0]),t.setAttributeNS(null,"y1",i[1]),t.setAttributeNS(null,"x2",r[0]),t.setAttributeNS(null,"y2",r[1]);break;case"radial":let a=e[4],s=e[5],o=e[6],l=e[7];t=this.svgFactory.createElement("svg:radialGradient"),t.setAttributeNS(null,"id",n),t.setAttributeNS(null,"gradientUnits","userSpaceOnUse"),t.setAttributeNS(null,"cx",s[0]),t.setAttributeNS(null,"cy",s[1]),t.setAttributeNS(null,"r",l),t.setAttributeNS(null,"fx",a[0]),t.setAttributeNS(null,"fy",a[1]),t.setAttributeNS(null,"fr",o);break;default:throw new Error(`Unknown RadialAxial type: ${e[1]}`)}for(let e of i){let n=this.svgFactory.createElement("svg:stop");n.setAttributeNS(null,"offset",e[0]),n.setAttributeNS(null,"stop-color",e[1]),t.append(n)}return this.defs.append(t),`url(#${n})`;case"Mesh":return(0,r.warn)("Unimplemented pattern Mesh"),null;case"Dummy":return"hotpink";default:throw new Error(`Unknown IR type: ${e[0]}`)}}setDash(e,t){this.current.dashArray=e,this.current.dashPhase=t}constructPath(e,t){let n=this.current,i=n.x,a=n.y,s=[],o=0;for(let l of e)switch(0|l){case r.OPS.rectangle:i=t[o++],a=t[o++];let e=i+t[o++],n=a+t[o++];s.push("M",p(i),p(a),"L",p(e),p(a),"L",p(e),p(n),"L",p(i),p(n),"Z");break;case r.OPS.moveTo:i=t[o++],a=t[o++],s.push("M",p(i),p(a));break;case r.OPS.lineTo:i=t[o++],a=t[o++],s.push("L",p(i),p(a));break;case r.OPS.curveTo:i=t[o+4],a=t[o+5],s.push("C",p(t[o]),p(t[o+1]),p(t[o+2]),p(t[o+3]),p(i),p(a)),o+=6;break;case r.OPS.curveTo2:s.push("C",p(i),p(a),p(t[o]),p(t[o+1]),p(t[o+2]),p(t[o+3])),i=t[o+2],a=t[o+3],o+=4;break;case r.OPS.curveTo3:i=t[o+2],a=t[o+3],s.push("C",p(t[o]),p(t[o+1]),p(i),p(a),p(i),p(a)),o+=4;break;case r.OPS.closePath:s.push("Z")}s=s.join(" "),n.path&&e.length>0&&e[0]!==r.OPS.rectangle&&e[0]!==r.OPS.moveTo?s=n.path.getAttributeNS(null,"d")+s:(n.path=this.svgFactory.createElement("svg:path"),this._ensureTransformGroup().append(n.path)),n.path.setAttributeNS(null,"d",s),n.path.setAttributeNS(null,"fill","none"),n.element=n.path,n.setCurrentPoint(i,a)}endPath(){let e=this.current;if(e.path=null,!this.pendingClip)return;if(!e.element)return void(this.pendingClip=null);let t="clippath"+m++,n=this.svgFactory.createElement("svg:clipPath");n.setAttributeNS(null,"id",t),n.setAttributeNS(null,"transform",f(this.transformMatrix));let i=e.element.cloneNode(!0);if("evenodd"===this.pendingClip?i.setAttributeNS(null,"clip-rule","evenodd"):i.setAttributeNS(null,"clip-rule","nonzero"),this.pendingClip=null,n.append(i),this.defs.append(n),e.activeClipUrl){e.clipGroup=null;for(let e of this.extraStack)e.clipGroup=null;n.setAttributeNS(null,"clip-path",e.activeClipUrl)}e.activeClipUrl=`url(#${t})`,this.tgrp=null}clip(e){this.pendingClip=e}closePath(){let e=this.current;if(e.path){let t=`${e.path.getAttributeNS(null,"d")}Z`;e.path.setAttributeNS(null,"d",t)}}setLeading(e){this.current.leading=-e}setTextRise(e){this.current.textRise=e}setTextRenderingMode(e){this.current.textRenderingMode=e}setHScale(e){this.current.textHScale=e/100}setRenderingIntent(e){}setFlatness(e){}setGState(e){for(let[t,n]of e)switch(t){case"LW":this.setLineWidth(n);break;case"LC":this.setLineCap(n);break;case"LJ":this.setLineJoin(n);break;case"ML":this.setMiterLimit(n);break;case"D":this.setDash(n[0],n[1]);break;case"RI":this.setRenderingIntent(n);break;case"FL":this.setFlatness(n);break;case"Font":this.setFont(n);break;case"CA":this.setStrokeAlpha(n);break;case"ca":this.setFillAlpha(n);break;default:(0,r.warn)(`Unimplemented graphic state operator ${t}`)}}fill(){let e=this.current;e.element&&(e.element.setAttributeNS(null,"fill",e.fillColor),e.element.setAttributeNS(null,"fill-opacity",e.fillAlpha),this.endPath())}stroke(){let e=this.current;e.element&&(this._setStrokeAttributes(e.element),e.element.setAttributeNS(null,"fill","none"),this.endPath())}_setStrokeAttributes(e,t=1){let n=this.current,i=n.dashArray;1!==t&&i.length>0&&(i=i.map((function(e){return t*e}))),e.setAttributeNS(null,"stroke",n.strokeColor),e.setAttributeNS(null,"stroke-opacity",n.strokeAlpha),e.setAttributeNS(null,"stroke-miterlimit",p(n.miterLimit)),e.setAttributeNS(null,"stroke-linecap",n.lineCap),e.setAttributeNS(null,"stroke-linejoin",n.lineJoin),e.setAttributeNS(null,"stroke-width",p(t*n.lineWidth)+"px"),e.setAttributeNS(null,"stroke-dasharray",i.map(p).join(" ")),e.setAttributeNS(null,"stroke-dashoffset",p(t*n.dashPhase)+"px")}eoFill(){var e;null==(e=this.current.element)||e.setAttributeNS(null,"fill-rule","evenodd"),this.fill()}fillStroke(){this.stroke(),this.fill()}eoFillStroke(){var e;null==(e=this.current.element)||e.setAttributeNS(null,"fill-rule","evenodd"),this.fillStroke()}closeStroke(){this.closePath(),this.stroke()}closeFillStroke(){this.closePath(),this.fillStroke()}closeEOFillStroke(){this.closePath(),this.eoFillStroke()}paintSolidColorImageMask(){let e=this.svgFactory.createElement("svg:rect");e.setAttributeNS(null,"x","0"),e.setAttributeNS(null,"y","0"),e.setAttributeNS(null,"width","1px"),e.setAttributeNS(null,"height","1px"),e.setAttributeNS(null,"fill",this.current.fillColor),this._ensureTransformGroup().append(e)}paintImageXObject(e){let t=this.getObject(e);t?this.paintInlineImageXObject(t):(0,r.warn)(`Dependent image with object ID ${e} is not ready yet`)}paintInlineImageXObject(e,t){let n=e.width,i=e.height,r=c(e,this.forceDataSchema,!!t),a=this.svgFactory.createElement("svg:rect");a.setAttributeNS(null,"x","0"),a.setAttributeNS(null,"y","0"),a.setAttributeNS(null,"width",p(n)),a.setAttributeNS(null,"height",p(i)),this.current.element=a,this.clip("nonzero");let s=this.svgFactory.createElement("svg:image");s.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",r),s.setAttributeNS(null,"x","0"),s.setAttributeNS(null,"y",p(-i)),s.setAttributeNS(null,"width",p(n)+"px"),s.setAttributeNS(null,"height",p(i)+"px"),s.setAttributeNS(null,"transform",`scale(${p(1/n)} ${p(-1/i)})`),t?t.append(s):this._ensureTransformGroup().append(s)}paintImageMaskXObject(e){let t=this.getObject(e.data,e);if(t.bitmap)return void(0,r.warn)("paintImageMaskXObject: ImageBitmap support is not implemented, ensure that the `isOffscreenCanvasSupported` API parameter is disabled.");let n=this.current,i=t.width,a=t.height,s=n.fillColor;n.maskId="mask"+g++;let o=this.svgFactory.createElement("svg:mask");o.setAttributeNS(null,"id",n.maskId);let l=this.svgFactory.createElement("svg:rect");l.setAttributeNS(null,"x","0"),l.setAttributeNS(null,"y","0"),l.setAttributeNS(null,"width",p(i)),l.setAttributeNS(null,"height",p(a)),l.setAttributeNS(null,"fill",s),l.setAttributeNS(null,"mask",`url(#${n.maskId})`),this.defs.append(o),this._ensureTransformGroup().append(l),this.paintInlineImageXObject(t,o)}paintFormXObjectBegin(e,t){if(Array.isArray(e)&&6===e.length&&this.transform(e[0],e[1],e[2],e[3],e[4],e[5]),t){let e=t[2]-t[0],n=t[3]-t[1],i=this.svgFactory.createElement("svg:rect");i.setAttributeNS(null,"x",t[0]),i.setAttributeNS(null,"y",t[1]),i.setAttributeNS(null,"width",p(e)),i.setAttributeNS(null,"height",p(n)),this.current.element=i,this.clip("nonzero"),this.endPath()}}paintFormXObjectEnd(){}_initialize(e){let t=this.svgFactory.create(e.width,e.height),n=this.svgFactory.createElement("svg:defs");t.append(n),this.defs=n;let i=this.svgFactory.createElement("svg:g");return i.setAttributeNS(null,"transform",f(e.transform)),t.append(i),this.svg=i,t}_ensureClipGroup(){if(!this.current.clipGroup){let e=this.svgFactory.createElement("svg:g");e.setAttributeNS(null,"clip-path",this.current.activeClipUrl),this.svg.append(e),this.current.clipGroup=e}return this.current.clipGroup}_ensureTransformGroup(){return this.tgrp||(this.tgrp=this.svgFactory.createElement("svg:g"),this.tgrp.setAttributeNS(null,"transform",f(this.transformMatrix)),this.current.activeClipUrl?this._ensureClipGroup().append(this.tgrp):this.svg.append(this.tgrp)),this.tgrp}}}],__webpack_module_cache__={};function __w_pdfjs_require__(e){var t=__webpack_module_cache__[e];if(void 0!==t)return t.exports;var n=__webpack_module_cache__[e]={exports:{}};return __webpack_modules__[e](n,n.exports,__w_pdfjs_require__),n.exports}var __webpack_exports__={};return(()=>{var e=__webpack_exports__;Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"AbortException",{enumerable:!0,get:function(){return t.AbortException}}),Object.defineProperty(e,"AnnotationEditorLayer",{enumerable:!0,get:function(){return a.AnnotationEditorLayer}}),Object.defineProperty(e,"AnnotationEditorParamsType",{enumerable:!0,get:function(){return t.AnnotationEditorParamsType}}),Object.defineProperty(e,"AnnotationEditorType",{enumerable:!0,get:function(){return t.AnnotationEditorType}}),Object.defineProperty(e,"AnnotationEditorUIManager",{enumerable:!0,get:function(){return s.AnnotationEditorUIManager}}),Object.defineProperty(e,"AnnotationLayer",{enumerable:!0,get:function(){return o.AnnotationLayer}}),Object.defineProperty(e,"AnnotationMode",{enumerable:!0,get:function(){return t.AnnotationMode}}),Object.defineProperty(e,"CMapCompressionType",{enumerable:!0,get:function(){return t.CMapCompressionType}}),Object.defineProperty(e,"FeatureTest",{enumerable:!0,get:function(){return t.FeatureTest}}),Object.defineProperty(e,"GlobalWorkerOptions",{enumerable:!0,get:function(){return l.GlobalWorkerOptions}}),Object.defineProperty(e,"ImageKind",{enumerable:!0,get:function(){return t.ImageKind}}),Object.defineProperty(e,"InvalidPDFException",{enumerable:!0,get:function(){return t.InvalidPDFException}}),Object.defineProperty(e,"MissingPDFException",{enumerable:!0,get:function(){return t.MissingPDFException}}),Object.defineProperty(e,"OPS",{enumerable:!0,get:function(){return t.OPS}}),Object.defineProperty(e,"PDFDataRangeTransport",{enumerable:!0,get:function(){return n.PDFDataRangeTransport}}),Object.defineProperty(e,"PDFDateString",{enumerable:!0,get:function(){return i.PDFDateString}}),Object.defineProperty(e,"PDFWorker",{enumerable:!0,get:function(){return n.PDFWorker}}),Object.defineProperty(e,"PasswordResponses",{enumerable:!0,get:function(){return t.PasswordResponses}}),Object.defineProperty(e,"PermissionFlag",{enumerable:!0,get:function(){return t.PermissionFlag}}),Object.defineProperty(e,"PixelsPerInch",{enumerable:!0,get:function(){return i.PixelsPerInch}}),Object.defineProperty(e,"PromiseCapability",{enumerable:!0,get:function(){return t.PromiseCapability}}),Object.defineProperty(e,"RenderingCancelledException",{enumerable:!0,get:function(){return i.RenderingCancelledException}}),e.SVGGraphics=void 0,Object.defineProperty(e,"UnexpectedResponseException",{enumerable:!0,get:function(){return t.UnexpectedResponseException}}),Object.defineProperty(e,"Util",{enumerable:!0,get:function(){return t.Util}}),Object.defineProperty(e,"VerbosityLevel",{enumerable:!0,get:function(){return t.VerbosityLevel}}),Object.defineProperty(e,"XfaLayer",{enumerable:!0,get:function(){return h.XfaLayer}}),Object.defineProperty(e,"build",{enumerable:!0,get:function(){return n.build}}),Object.defineProperty(e,"createValidAbsoluteUrl",{enumerable:!0,get:function(){return t.createValidAbsoluteUrl}}),Object.defineProperty(e,"getDocument",{enumerable:!0,get:function(){return n.getDocument}}),Object.defineProperty(e,"getFilenameFromUrl",{enumerable:!0,get:function(){return i.getFilenameFromUrl}}),Object.defineProperty(e,"getPdfFilenameFromUrl",{enumerable:!0,get:function(){return i.getPdfFilenameFromUrl}}),Object.defineProperty(e,"getXfaPageViewport",{enumerable:!0,get:function(){return i.getXfaPageViewport}}),Object.defineProperty(e,"isDataScheme",{enumerable:!0,get:function(){return i.isDataScheme}}),Object.defineProperty(e,"isPdfFile",{enumerable:!0,get:function(){return i.isPdfFile}}),Object.defineProperty(e,"loadScript",{enumerable:!0,get:function(){return i.loadScript}}),Object.defineProperty(e,"normalizeUnicode",{enumerable:!0,get:function(){return t.normalizeUnicode}}),Object.defineProperty(e,"renderTextLayer",{enumerable:!0,get:function(){return r.renderTextLayer}}),Object.defineProperty(e,"setLayerDimensions",{enumerable:!0,get:function(){return i.setLayerDimensions}}),Object.defineProperty(e,"shadow",{enumerable:!0,get:function(){return t.shadow}}),Object.defineProperty(e,"updateTextLayer",{enumerable:!0,get:function(){return r.updateTextLayer}}),Object.defineProperty(e,"version",{enumerable:!0,get:function(){return n.version}});var t=__w_pdfjs_require__(1),n=__w_pdfjs_require__(2),i=__w_pdfjs_require__(6),r=__w_pdfjs_require__(26),a=__w_pdfjs_require__(27),s=__w_pdfjs_require__(5),o=__w_pdfjs_require__(29),l=__w_pdfjs_require__(14),h=__w_pdfjs_require__(31);let u=__w_pdfjs_require__(34).SVGGraphics;e.SVGGraphics=u})(),__webpack_exports__})(),"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("pdfjs-dist/build/pdf",[],e):"object"==typeof exports?exports["pdfjs-dist/build/pdf"]=e():t["pdfjs-dist/build/pdf"]=t.pdfjsLib=e()}));!function(){if("undefined"!=typeof document&&!document.getElementById("ab2abb6de03627668a657c741a17bd89df3c81c22bbbc1cf9e791fcb1731531a")){var e=document.createElement("style");e.id="ab2abb6de03627668a657c741a17bd89df3c81c22bbbc1cf9e791fcb1731531a",e.textContent='@import"https://at.alicdn.com/t/c/font_2809422_kipm6ycaet.css";@import"https://at.alicdn.com/t/c/font_2802048_dc945363jlf.css";.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}.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}.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}.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}.layer-manager{position:absolute;top:30px;left:20px;width:330px;height:600px;max-height:90%;border-radius:4px;box-shadow:1px 3px 10px #0006;background-color:#ffffffe6;color:#000;z-index:2;overflow:hidden;user-select:none}.layer-manager:hover{background-color:#fffffff2}.layer-manager input[type=checkbox]{width:16px;height:16px;cursor:pointer}.layer-manager input[type=color]{width:30px;height:16px;border:0;padding:0;background-color:#0000;overflow:hidden}.layer-manager ::-webkit-color-swatch{position:relative;margin-top:-5px;width:40px;height:16px}.layer-manager .header{display:flex;align-items:center;padding-left:6px;width:100%;height:40px;border-bottom:1px solid #ccc;cursor:move;font-size:16px}.layer-manager .header .close{position:absolute;right:8px;cursor:pointer;padding:10px}.layer-manager .header .close:hover{font-weight:700}.layer-manager .layer-list{width:100%;height:calc(100% - 40px);padding:0;margin:0;border-bottom:1px solid #ccc;overflow-y:scroll}.layer-manager .layer-list-item{display:flex;align-items:center;padding:6px;border-bottom:1px solid #ccc;white-space:nowrap}.layer-manager .layer-list-item:hover{background-color:#f0f8ff}.layer-manager .popup-layer-color{display:inline-block;margin-left:5px;width:20px;font-size:12px}.layer-manager .item-color{margin-left:8px;font-size:12px;border:1px solid black;width:18px;height:16px;min-width:18px}.layer-manager .item-layer-name{display:inline-block;margin-left:10px;padding:1px 0;width:280px;font-size:12px;text-overflow:ellipsis;overflow:hidden}.layer-manager .popup-freeze{margin-right:5px;color:#ccc;font-size:12px;width:50px}#axisGizmo{width:100px;height:100px;position:absolute;display:block;bottom:1px;left:10px;background:#ffffff00}.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}.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}#navCube{width:135px;height:135px;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}#gemini-viewer-overview-map{width:200px;height:200px;top:10px;left:10px;position:absolute;z-index:1;border:1px #50505090 solid;background-color:#80808030}.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)}}.statsOutput{position:absolute;opacity:.6;top:1px;left:1px}.toolbar{position:absolute;display:flex;box-sizing:border-box;height:68px;left:50%;bottom:40px;padding:8px 20px;box-shadow:1px 3px 10px #0006;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%;box-shadow:1px 3px 10px #0006}.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}@media screen and (max-width:768px){.toolbar .toolbar-menu{width:30px;height:30px;margin:0}.toolbar .toolbar-menu .icon+span{display:none}.toolbar .toolbar-parent-menu:after{top:1px;right:0}.toolbar .toolbar-sub-menu{min-width:30px}}#gemini-viewer-viewCube{width:150px;height:150px;position:absolute;bottom:10px;right:10px;z-index:1}.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 cSe=fetch;window.fetch=(...e)=>Promise.resolve(cSe(...e));var Qcn=ss(_G(),1),eun=ss(vce(),1),tun=ss(yce(),1),Vt={};bT(Vt,{ACESFilmicToneMapping:()=>fhe,AddEquation:()=>Vo,AddOperation:()=>che,AdditiveAnimationBlendMode:()=>RU,AdditiveBlending:()=>_c,AlphaFormat:()=>vhe,AlwaysCompare:()=>khe,AlwaysDepth:()=>nhe,AlwaysStencilFunc:()=>Ahe,AmbientLight:()=>mo,AmbientLightProbe:()=>ZB,AnimationAction:()=>PA,AnimationClip:()=>po,AnimationLoader:()=>zB,AnimationMixer:()=>rU,AnimationObjectGroup:()=>nU,AnimationUtils:()=>Nlt,ArcCurve:()=>um,ArrayCamera:()=>lA,ArrowHelper:()=>Rc,Audio:()=>RA,AudioAnalyser:()=>eU,AudioContext:()=>pb,AudioListener:()=>JB,AudioLoader:()=>YB,AxesHelper:()=>yU,BackSide:()=>Ki,BasicDepthPacking:()=>She,BasicShadowMap:()=>Snt,Bone:()=>Sl,BooleanKeyframeTrack:()=>Wh,Box2:()=>_i,Box3:()=>Nt,Box3Helper:()=>gU,BoxGeometry:()=>ma,BoxHelper:()=>mU,BufferAttribute:()=>yn,BufferGeometry:()=>Ot,BufferGeometryLoader:()=>AA,ByteType:()=>mhe,Cache:()=>mm,Camera:()=>Uh,CameraHelper:()=>vb,CanvasTexture:()=>nb,CapsuleGeometry:()=>ev,CatmullRomCurve3:()=>dA,CineonToneMapping:()=>dhe,CircleGeometry:()=>tv,ClampToEdgeWrapping:()=>Pi,Clock:()=>Pl,Color:()=>ct,ColorKeyframeTrack:()=>ub,ColorManagement:()=>bl,CompressedArrayTexture:()=>FB,CompressedCubeTexture:()=>NB,CompressedTexture:()=>wu,CompressedTextureLoader:()=>GB,ConeGeometry:()=>nv,CubeCamera:()=>aA,CubeReflectionMapping:()=>kh,CubeRefractionMapping:()=>Zd,CubeTexture:()=>cm,CubeTextureLoader:()=>hb,CubeUVReflectionMapping:()=>pv,CubicBezierCurve:()=>rb,CubicBezierCurve3:()=>fA,CubicInterpolant:()=>EA,CullFaceBack:()=>VN,CullFaceFront:()=>jue,CullFaceFrontBack:()=>wnt,CullFaceNone:()=>Wue,Curve:()=>Ha,CurvePath:()=>mA,CustomBlending:()=>xm,CustomToneMapping:()=>phe,CylinderGeometry:()=>Sc,Cylindrical:()=>cU,Data3DTexture:()=>Kx,DataArrayTexture:()=>$0,DataTexture:()=>_l,DataTextureLoader:()=>gm,DataUtils:()=>yv,DecrementStencilOp:()=>Ont,DecrementWrapStencilOp:()=>Fnt,DefaultLoadingManager:()=>UA,DepthFormat:()=>$d,DepthStencilFormat:()=>Nh,DepthTexture:()=>Qd,DirectionalLight:()=>va,DirectionalLightHelper:()=>gb,DiscreteInterpolant:()=>_A,DisplayP3ColorSpace:()=>IU,DodecahedronGeometry:()=>rv,DoubleSide:()=>hr,DstAlphaFactor:()=>dv,DstColorFactor:()=>fv,DynamicCopyUsage:()=>Knt,DynamicDrawUsage:()=>Wnt,DynamicReadUsage:()=>Ynt,EdgesGeometry:()=>Au,EllipseCurve:()=>Gh,EqualCompare:()=>Phe,EqualDepth:()=>ihe,EqualStencilFunc:()=>Hnt,EquirectangularReflectionMapping:()=>om,EquirectangularRefractionMapping:()=>Wx,Euler:()=>Xn,EventDispatcher:()=>Tc,ExtrudeGeometry:()=>Ws,FileLoader:()=>Zr,Float16BufferAttribute:()=>wB,Float32BufferAttribute:()=>Bt,Float64BufferAttribute:()=>SB,FloatType:()=>pa,Fog:()=>_u,FogExp2:()=>K0,FramebufferTexture:()=>kB,FrontSide:()=>hi,Frustum:()=>wl,GLBufferAttribute:()=>aU,GLSL1:()=>Qnt,GLSL3:()=>mB,GreaterCompare:()=>Lhe,GreaterDepth:()=>ahe,GreaterEqualCompare:()=>Ohe,GreaterEqualDepth:()=>she,GreaterEqualStencilFunc:()=>qnt,GreaterStencilFunc:()=>znt,GridHelper:()=>mb,Group:()=>Bn,HalfFloatType:()=>Tr,HemisphereLight:()=>Pu,HemisphereLightHelper:()=>fU,HemisphereLightProbe:()=>$B,IcosahedronGeometry:()=>iv,ImageBitmapLoader:()=>fb,ImageLoader:()=>Xh,ImageUtils:()=>Zx,IncrementStencilOp:()=>Dnt,IncrementWrapStencilOp:()=>knt,InstancedBufferAttribute:()=>zh,InstancedBufferGeometry:()=>MA,InstancedInterleavedBuffer:()=>sU,InstancedMesh:()=>Os,Int16BufferAttribute:()=>_B,Int32BufferAttribute:()=>TB,Int8BufferAttribute:()=>bB,IntType:()=>_U,InterleavedBuffer:()=>Vh,InterleavedBufferAttribute:()=>fo,Interpolant:()=>qh,InterpolateDiscrete:()=>Bh,InterpolateLinear:()=>Eu,InterpolateSmooth:()=>eA,InvertStencilOp:()=>Nnt,KeepStencilOp:()=>tA,KeyframeTrack:()=>qo,LOD:()=>hA,LatheGeometry:()=>dm,Layers:()=>Jd,LessCompare:()=>Che,LessDepth:()=>rhe,LessEqualCompare:()=>Ihe,LessEqualDepth:()=>nA,LessEqualStencilFunc:()=>Vnt,LessStencilFunc:()=>Unt,Light:()=>Cl,LightProbe:()=>cv,Line:()=>Vr,Line3:()=>ra,LineBasicMaterial:()=>zn,LineCurve:()=>Q0,LineCurve3:()=>pA,LineDashedMaterial:()=>Cu,LineLoop:()=>J0,LineSegments:()=>zr,LinearEncoding:()=>PU,LinearFilter:()=>Xr,LinearInterpolant:()=>cb,LinearMipMapLinearFilter:()=>Pnt,LinearMipMapNearestFilter:()=>Cnt,LinearMipmapLinearFilter:()=>Ba,LinearMipmapNearestFilter:()=>bm,LinearSRGBColorSpace:()=>Ua,LinearToneMapping:()=>uhe,Loader:()=>xr,LoaderUtils:()=>na,LoadingManager:()=>nf,LoopOnce:()=>_he,LoopPingPong:()=>whe,LoopRepeat:()=>The,LuminanceAlphaFormat:()=>yhe,LuminanceFormat:()=>OA,MOUSE:()=>LA,Material:()=>Ar,MaterialLoader:()=>uv,MathUtils:()=>Un,Matrix3:()=>In,Matrix4:()=>ht,MaxEquation:()=>WN,Mesh:()=>St,MeshBasicMaterial:()=>cn,MeshDepthMaterial:()=>wc,MeshDistanceMaterial:()=>eb,MeshLambertMaterial:()=>Ru,MeshMatcapMaterial:()=>bA,MeshNormalMaterial:()=>tf,MeshPhongMaterial:()=>ta,MeshPhysicalMaterial:()=>Go,MeshStandardMaterial:()=>za,MeshToonMaterial:()=>xA,MinEquation:()=>qN,MirroredRepeatWrapping:()=>Fh,MixOperation:()=>lhe,MultiplyBlending:()=>GN,MultiplyOperation:()=>yb,NearestFilter:()=>Jr,NearestMipMapLinearFilter:()=>Rnt,NearestMipMapNearestFilter:()=>Ant,NearestMipmapLinearFilter:()=>Oh,NearestMipmapNearestFilter:()=>Kd,NeverCompare:()=>Rhe,NeverDepth:()=>the,NeverStencilFunc:()=>Bnt,NoBlending:()=>Qr,NoColorSpace:()=>bu,NoToneMapping:()=>Dh,NormalAnimationBlendMode:()=>FA,NormalBlending:()=>sm,NotEqualCompare:()=>Dhe,NotEqualDepth:()=>ohe,NotEqualStencilFunc:()=>Gnt,NumberKeyframeTrack:()=>Rl,Object3D:()=>an,ObjectLoader:()=>XB,ObjectSpaceNormalMap:()=>Mhe,OctahedronGeometry:()=>pm,OneFactor:()=>$ue,OneMinusDstAlphaFactor:()=>Jue,OneMinusDstColorFactor:()=>Que,OneMinusSrcAlphaFactor:()=>EU,OneMinusSrcColorFactor:()=>Kue,OrthographicCamera:()=>xi,PCFShadowMap:()=>xU,PCFSoftShadowMap:()=>hv,PMREMGenerator:()=>Hh,Path:()=>Su,PerspectiveCamera:()=>Yr,Plane:()=>Ur,PlaneGeometry:()=>mi,PlaneHelper:()=>vU,PointLight:()=>Mc,PointLightHelper:()=>dU,Points:()=>Di,PointsMaterial:()=>Li,PolarGridHelper:()=>pU,PolyhedronGeometry:()=>Mu,PositionalAudio:()=>QB,PropertyBinding:()=>Jn,PropertyMixer:()=>CA,QuadraticBezierCurve:()=>ib,QuadraticBezierCurve3:()=>sb,Quaternion:()=>_r,QuaternionKeyframeTrack:()=>Ga,QuaternionLinearInterpolant:()=>TA,RED_GREEN_RGTC2_Format:()=>fB,RED_RGTC1_Format:()=>Ehe,REVISION:()=>IA,RGBADepthPacking:()=>vv,RGBAFormat:()=>ea,RGBAIntegerFormat:()=>AU,RGBA_ASTC_10x10_Format:()=>cB,RGBA_ASTC_10x5_Format:()=>aB,RGBA_ASTC_10x6_Format:()=>oB,RGBA_ASTC_10x8_Format:()=>lB,RGBA_ASTC_12x10_Format:()=>uB,RGBA_ASTC_12x12_Format:()=>hB,RGBA_ASTC_4x4_Format:()=>JN,RGBA_ASTC_5x4_Format:()=>QN,RGBA_ASTC_5x5_Format:()=>eB,RGBA_ASTC_6x5_Format:()=>tB,RGBA_ASTC_6x6_Format:()=>nB,RGBA_ASTC_8x5_Format:()=>rB,RGBA_ASTC_8x6_Format:()=>iB,RGBA_ASTC_8x8_Format:()=>sB,RGBA_BPTC_Format:()=>QM,RGBA_ETC2_EAC_Format:()=>KN,RGBA_PVRTC_2BPPV1_Format:()=>$N,RGBA_PVRTC_4BPPV1_Format:()=>YN,RGBA_S3TC_DXT1_Format:()=>ZM,RGBA_S3TC_DXT3_Format:()=>KM,RGBA_S3TC_DXT5_Format:()=>JM,RGB_ETC1_Format:()=>bhe,RGB_ETC2_Format:()=>ZN,RGB_PVRTC_2BPPV1_Format:()=>XN,RGB_PVRTC_4BPPV1_Format:()=>jN,RGB_S3TC_DXT1_Format:()=>$M,RGFormat:()=>xhe,RGIntegerFormat:()=>MU,RawShaderMaterial:()=>yA,Ray:()=>Tl,Raycaster:()=>Ac,RectAreaLight:()=>wA,RedFormat:()=>kA,RedIntegerFormat:()=>SU,ReinhardToneMapping:()=>hhe,RenderTarget:()=>sA,RepeatWrapping:()=>Ii,ReplaceStencilOp:()=>Lnt,ReverseSubtractEquation:()=>Yue,RingGeometry:()=>sv,SIGNED_RED_GREEN_RGTC2_Format:()=>pB,SIGNED_RED_RGTC1_Format:()=>dB,SRGBColorSpace:()=>sn,Scene:()=>Ji,ShaderChunk:()=>$n,ShaderLib:()=>xc,ShaderMaterial:()=>hn,ShadowMaterial:()=>vA,Shape:()=>Ts,ShapeGeometry:()=>Al,ShapePath:()=>ym,ShapeUtils:()=>qs,ShortType:()=>ghe,Skeleton:()=>Ml,SkeletonHelper:()=>hU,SkinnedMesh:()=>Tu,Source:()=>bc,Sphere:()=>$r,SphereGeometry:()=>Va,Spherical:()=>lU,SphericalHarmonics3:()=>SA,SplineCurve:()=>hm,SpotLight:()=>Iu,SpotLightHelper:()=>uU,Sprite:()=>uA,SpriteMaterial:()=>tb,SrcAlphaFactor:()=>bU,SrcAlphaSaturateFactor:()=>ehe,SrcColorFactor:()=>Zue,StaticCopyUsage:()=>Znt,StaticDrawUsage:()=>Xx,StaticReadUsage:()=>Xnt,StereoCamera:()=>KB,StreamCopyUsage:()=>Jnt,StreamDrawUsage:()=>jnt,StreamReadUsage:()=>$nt,StringKeyframeTrack:()=>jh,SubtractEquation:()=>Xue,SubtractiveBlending:()=>zN,TOUCH:()=>Tnt,TangentSpaceNormalMap:()=>sf,TetrahedronGeometry:()=>av,Texture:()=>Hr,TextureLoader:()=>ws,TorusGeometry:()=>ef,TorusKnotGeometry:()=>ov,Triangle:()=>ni,TriangleFanDrawMode:()=>gv,TriangleStripDrawMode:()=>xb,TrianglesDrawMode:()=>CU,TubeGeometry:()=>lv,TwoPassDoubleSide:()=>Mnt,UVMapping:()=>DA,Uint16BufferAttribute:()=>lm,Uint32BufferAttribute:()=>Qx,Uint8BufferAttribute:()=>Jx,Uint8ClampedBufferAttribute:()=>EB,Uniform:()=>vm,UniformsGroup:()=>iU,UniformsLib:()=>Qt,UniformsUtils:()=>Ti,UnsignedByteType:()=>Ec,UnsignedInt248Type:()=>yu,UnsignedIntType:()=>Lh,UnsignedShort4444Type:()=>TU,UnsignedShort5551Type:()=>wU,UnsignedShortType:()=>mv,VSMShadowMap:()=>gu,Vector2:()=>_e,Vector3:()=>k,Vector4:()=>mr,VectorKeyframeTrack:()=>qa,VideoTexture:()=>OB,WebGL1Renderer:()=>cA,WebGL3DRenderTarget:()=>yB,WebGLArrayRenderTarget:()=>vB,WebGLCoordinateSystem:()=>vu,WebGLCubeRenderTarget:()=>oA,WebGLMultipleRenderTargets:()=>xB,WebGLRenderTarget:()=>er,WebGLRenderer:()=>ga,WebGLUtils:()=>Whe,WebGPUCoordinateSystem:()=>Yx,WireframeGeometry:()=>gA,WrapAroundEnding:()=>jx,ZeroCurvatureEnding:()=>nm,ZeroFactor:()=>rf,ZeroSlopeEnding:()=>rm,ZeroStencilOp:()=>Int,_SRGBAFormat:()=>rA,sRGBEncoding:()=>xu});var IA="155",LA={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},Tnt={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},Wue=0,VN=1,jue=2,wnt=3,Snt=0,xU=1,hv=2,gu=3,hi=0,Ki=1,hr=2,Mnt=2,Qr=0,sm=1,_c=2,zN=3,GN=4,xm=5,Vo=100,Xue=101,Yue=102,qN=103,WN=104,rf=200,$ue=201,Zue=202,Kue=203,bU=204,EU=205,dv=206,Jue=207,fv=208,Que=209,ehe=210,the=0,nhe=1,rhe=2,nA=3,ihe=4,she=5,ahe=6,ohe=7,yb=0,lhe=1,che=2,Dh=0,uhe=1,hhe=2,dhe=3,fhe=4,phe=5,DA=300,kh=301,Zd=302,om=303,Wx=304,pv=306,Ii=1e3,Pi=1001,Fh=1002,Jr=1003,Kd=1004,Ant=1004,Oh=1005,Rnt=1005,Xr=1006,bm=1007,Cnt=1007,Ba=1008,Pnt=1008,Ec=1009,mhe=1010,ghe=1011,mv=1012,_U=1013,Lh=1014,pa=1015,Tr=1016,TU=1017,wU=1018,yu=1020,vhe=1021,ea=1023,OA=1024,yhe=1025,$d=1026,Nh=1027,kA=1028,SU=1029,xhe=1030,MU=1031,AU=1033,$M=33776,ZM=33777,KM=33778,JM=33779,jN=35840,XN=35841,YN=35842,$N=35843,bhe=36196,ZN=37492,KN=37496,JN=37808,QN=37809,eB=37810,tB=37811,nB=37812,rB=37813,iB=37814,sB=37815,aB=37816,oB=37817,lB=37818,cB=37819,uB=37820,hB=37821,QM=36492,Ehe=36283,dB=36284,fB=36285,pB=36286,_he=2200,The=2201,whe=2202,Bh=2300,Eu=2301,eA=2302,nm=2400,rm=2401,jx=2402,FA=2500,RU=2501,CU=0,xb=1,gv=2,PU=3e3,xu=3001,She=3200,vv=3201,sf=0,Mhe=1,bu="",sn="srgb",Ua="srgb-linear",IU="display-p3",Int=0,tA=7680,Lnt=7681,Dnt=7682,Ont=7683,knt=34055,Fnt=34056,Nnt=5386,Bnt=512,Unt=513,Hnt=514,Vnt=515,znt=516,Gnt=517,qnt=518,Ahe=519,Rhe=512,Che=513,Phe=514,Ihe=515,Lhe=516,Dhe=517,Ohe=518,khe=519,Xx=35044,Wnt=35048,jnt=35040,Xnt=35045,Ynt=35049,$nt=35041,Znt=35046,Knt=35050,Jnt=35042,Qnt="100",mB="300 es",rA=1035,vu=2e3,Yx=2001,Tc=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}}},da=["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"],xce=1234567,am=Math.PI/180,Y0=180/Math.PI;function zo(){let e=4294967295*Math.random()|0,t=4294967295*Math.random()|0,n=4294967295*Math.random()|0,i=4294967295*Math.random()|0;return(da[255&e]+da[e>>8&255]+da[e>>16&255]+da[e>>24&255]+"-"+da[255&t]+da[t>>8&255]+"-"+da[t>>16&15|64]+da[t>>24&255]+"-"+da[63&n|128]+da[n>>8&255]+"-"+da[n>>16&255]+da[n>>24&255]+da[255&i]+da[i>>8&255]+da[i>>16&255]+da[i>>24&255]).toLowerCase()}function hs(e,t,n){return Math.max(t,Math.min(n,e))}function LU(e,t){return(e%t+t)%t}function ert(e,t,n,i,r){return i+(e-t)*(r-i)/(n-t)}function trt(e,t,n){return e!==t?(n-e)/(t-e):0}function Hx(e,t,n){return(1-n)*e+n*t}function nrt(e,t,n,i){return Hx(e,t,1-Math.exp(-n*i))}function rrt(e,t=1){return t-Math.abs(LU(e,2*t)-t)}function irt(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t))*e*(3-2*e)}function srt(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t))*e*e*(e*(6*e-15)+10)}function art(e,t){return e+Math.floor(Math.random()*(t-e+1))}function ort(e,t){return e+Math.random()*(t-e)}function lrt(e){return e*(.5-Math.random())}function crt(e){void 0!==e&&(xce=e);let t=xce+=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 urt(e){return e*am}function hrt(e){return e*Y0}function gB(e){return 0==(e&e-1)&&0!==e}function Fhe(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))}function iA(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}function drt(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),u=s((t+i)/2),c=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*u,l*c,l*d,o*h);break;case"YZY":e.set(l*d,o*u,l*c,o*h);break;case"ZXZ":e.set(l*c,l*d,o*u,o*h);break;case"XZX":e.set(o*u,l*f,l*p,o*h);break;case"YXY":e.set(l*p,o*u,l*f,o*h);break;case"ZYZ":e.set(l*f,l*p,o*u,o*h);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function ho(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return e/4294967295;case Uint16Array:return e/65535;case Uint8Array:return e/255;case Int32Array:return Math.max(e/2147483647,-1);case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw new Error("Invalid component type.")}}function pr(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return Math.round(4294967295*e);case Uint16Array:return Math.round(65535*e);case Uint8Array:return Math.round(255*e);case Int32Array:return Math.round(2147483647*e);case Int16Array:return Math.round(32767*e);case Int8Array:return Math.round(127*e);default:throw new Error("Invalid component type.")}}var Un={DEG2RAD:am,RAD2DEG:Y0,generateUUID:zo,clamp:hs,euclideanModulo:LU,mapLinear:ert,inverseLerp:trt,lerp:Hx,damp:nrt,pingpong:rrt,smoothstep:irt,smootherstep:srt,randInt:art,randFloat:ort,randFloatSpread:lrt,seededRandom:crt,degToRad:urt,radToDeg:hrt,isPowerOfTwo:gB,ceilPowerOfTwo:Fhe,floorPowerOfTwo:iA,setQuaternionFromProperEuler:drt,normalize:pr,denormalize:ho},_e=class{constructor(e=0,t=0){_e.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(hs(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}},In=class{constructor(e,t,n,i,r,a,s,o,l){In.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],void 0!==e&&this.set(e,t,n,i,r,a,s,o,l)}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],u=n[7],c=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],b=i[2],_=i[5],w=i[8];return r[0]=a*f+s*v+o*b,r[3]=a*m+s*y+o*_,r[6]=a*g+s*x+o*w,r[1]=l*f+h*v+u*b,r[4]=l*m+h*y+u*_,r[7]=l*g+h*x+u*w,r[2]=c*f+d*v+p*b,r[5]=c*m+d*y+p*_,r[8]=c*g+d*x+p*w,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],u=h*a-s*l,c=s*o-h*r,d=l*r-a*o,p=t*u+n*c+i*d;if(0===p)return this.set(0,0,0,0,0,0,0,0,0);let f=1/p;return e[0]=u*f,e[1]=(i*l-h*n)*f,e[2]=(s*n-i*a)*f,e[3]=c*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(cN.makeScale(e,t)),this}rotate(e){return this.premultiply(cN.makeRotation(-e)),this}translate(e,t){return this.premultiply(cN.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){let t=this.elements,n=e.elements;for(let 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)}},cN=new In;function Nhe(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}var frt={Int8Array:Int8Array,Uint8Array:Uint8Array,Uint8ClampedArray:Uint8ClampedArray,Int16Array:Int16Array,Uint16Array:Uint16Array,Int32Array:Int32Array,Uint32Array:Uint32Array,Float32Array:Float32Array,Float64Array:Float64Array};function G0(e,t){return new frt[e](t)}function $x(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}var bce={};function Vx(e){e in bce||(bce[e]=!0,console.warn(e))}function j0(e){return e<.04045?.0773993808*e:Math.pow(.9478672986*e+.0521327014,2.4)}function uN(e){return e<.0031308?12.92*e:1.055*Math.pow(e,.41666)-.055}var prt=(new In).fromArray([.8224621,.0331941,.0170827,.177538,.9668058,.0723974,-1e-7,1e-7,.9105199]),mrt=(new In).fromArray([1.2249401,-.0420569,-.0196376,-.2249404,1.0420571,-.0786361,1e-7,0,1.0982735]);function grt(e){return e.convertSRGBToLinear().applyMatrix3(mrt)}function vrt(e){return e.applyMatrix3(prt).convertLinearToSRGB()}var yrt={[Ua]:e=>e,[sn]:e=>e.convertSRGBToLinear(),[IU]:grt},xrt={[Ua]:e=>e,[sn]:e=>e.convertLinearToSRGB(),[IU]:vrt},bl={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 Ua},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=yrt[t],r=xrt[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)}},E0,Zx=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===E0&&(E0=$x("canvas")),E0.width=e.width,E0.height=e.height;let n=E0.getContext("2d");e instanceof ImageData?n.putImageData(e,0,0):n.drawImage(e,0,0,e.width,e.height),t=E0}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=$x("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*j0(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*j0(t[e]/255)):t[e]=j0(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}},brt=0,bc=class{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:brt++}),this.uuid=zo(),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(hN(i[t].image)):e.push(hN(i[t]))}else e=hN(i);n.url=e}return t||(e.images[this.uuid]=n),n}};function hN(e){return"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap?Zx.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 Ert=0,Hr=class extends Tc{constructor(e=Hr.DEFAULT_IMAGE,t=Hr.DEFAULT_MAPPING,n=Pi,i=Pi,r=Xr,a=Ba,s=ea,o=Ec,l=Hr.DEFAULT_ANISOTROPY,h=bu){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Ert++}),this.uuid=zo(),this.name="",this.source=new bc(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 _e(0,0),this.repeat=new _e(1,1),this.center=new _e(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new In,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,"string"==typeof h?this.colorSpace=h:(Vx("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=h===xu?sn:bu),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.6,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!==DA)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Ii:e.x=e.x-Math.floor(e.x);break;case Pi:e.x=e.x<0?0:1;break;case Fh: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 Ii:e.y=e.y-Math.floor(e.y);break;case Pi:e.y=e.y<0?0:1;break;case Fh: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 Vx("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace===sn?xu:PU}set encoding(e){Vx("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=e===xu?sn:bu}};Hr.DEFAULT_IMAGE=null,Hr.DEFAULT_MAPPING=DA,Hr.DEFAULT_ANISOTROPY=1;var mr=class{constructor(e=0,t=0,n=0,i=1){mr.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],u=a[5],c=a[9],d=a[2],p=a[6],f=a[10];if(Math.abs(o-h)<.01&&Math.abs(l-d)<.01&&Math.abs(c-p)<.01){if(Math.abs(o+h)<.1&&Math.abs(l+d)<.1&&Math.abs(c+p)<.1&&Math.abs(s+u+f-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;let e=(s+1)/2,a=(u+1)/2,m=(f+1)/2,g=(o+h)/4,v=(l+d)/4,y=(c+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-c)*(p-c)+(l-d)*(l-d)+(h-o)*(h-o));return Math.abs(m)<.001&&(m=1),this.x=(p-c)/m,this.y=(l-d)/m,this.z=(h-o)/m,this.w=Math.acos((s+u+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}},sA=class extends Tc{constructor(e=1,t=1,n={}){super(),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=1,this.scissor=new mr(0,0,e,t),this.scissorTest=!1,this.viewport=new mr(0,0,e,t);let i={width:e,height:t,depth:1};void 0!==n.encoding&&(Vx("THREE.WebGLRenderTarget: option.encoding has been replaced by option.colorSpace."),n.colorSpace=n.encoding===xu?sn:bu),this.texture=new Hr(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:Xr,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 bc(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"})}},er=class extends sA{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}},$0=class extends Hr{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=Jr,this.minFilter=Jr,this.wrapR=Pi,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},vB=class extends er{constructor(e=1,t=1,n=1){super(e,t),this.isWebGLArrayRenderTarget=!0,this.depth=n,this.texture=new $0(null,e,t,n),this.texture.isRenderTargetTexture=!0}},Kx=class extends Hr{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=Jr,this.minFilter=Jr,this.wrapR=Pi,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},yB=class extends er{constructor(e=1,t=1,n=1){super(e,t),this.isWebGL3DRenderTarget=!0,this.depth=n,this.texture=new Kx(null,e,t,n),this.texture.isRenderTargetTexture=!0}},xB=class extends er{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()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}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}},_r=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],u=n[i+3],c=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]=u);if(1===s)return e[t+0]=c,e[t+1]=d,e[t+2]=p,void(e[t+3]=f);if(u!==f||o!==c||l!==d||h!==p){let e=1-s,t=o*c+l*d+h*p+u*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+c*r,l=l*e+d*r,h=h*e+p*r,u=u*e+f*r,e===1-s){let e=1/Math.sqrt(o*o+l*l+h*h+u*u);o*=e,l*=e,h*=e,u*=e}}e[t]=o,e[t+1]=l,e[t+2]=h,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,i,r,a){let s=n[i],o=n[i+1],l=n[i+2],h=n[i+3],u=r[a],c=r[a+1],d=r[a+2],p=r[a+3];return e[t]=s*p+h*u+o*d-l*c,e[t+1]=o*p+h*c+l*u-s*d,e[t+2]=l*p+h*d+s*c-o*u,e[t+3]=h*p-s*u-o*c-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),u=s(r/2),c=o(n/2),d=o(i/2),p=o(r/2);switch(a){case"XYZ":this._x=c*h*u+l*d*p,this._y=l*d*u-c*h*p,this._z=l*h*p+c*d*u,this._w=l*h*u-c*d*p;break;case"YXZ":this._x=c*h*u+l*d*p,this._y=l*d*u-c*h*p,this._z=l*h*p-c*d*u,this._w=l*h*u+c*d*p;break;case"ZXY":this._x=c*h*u-l*d*p,this._y=l*d*u+c*h*p,this._z=l*h*p+c*d*u,this._w=l*h*u-c*d*p;break;case"ZYX":this._x=c*h*u-l*d*p,this._y=l*d*u+c*h*p,this._z=l*h*p-c*d*u,this._w=l*h*u+c*d*p;break;case"YZX":this._x=c*h*u+l*d*p,this._y=l*d*u+c*h*p,this._z=l*h*p-c*d*u,this._w=l*h*u-c*d*p;break;case"XZY":this._x=c*h*u-l*d*p,this._y=l*d*u-c*h*p,this._z=l*h*p+c*d*u,this._w=l*h*u+c*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],u=t[10],c=n+s+u;if(c>0){let e=.5/Math.sqrt(c+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>u){let e=2*Math.sqrt(1+n-s-u);this._w=(h-o)/e,this._x=.25*e,this._y=(i+a)/e,this._z=(r+l)/e}else if(s>u){let e=2*Math.sqrt(1+s-n-u);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+u-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(hs(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),u=Math.sin((1-t)*h)/l,c=Math.sin(t*h)/l;return this._w=a*u+this._w*c,this._x=n*u+this._x*c,this._y=i*u+this._y*c,this._z=r*u+this._z*c,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}},k=class{constructor(e=0,t=0,n=0){k.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(Ece.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Ece.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,u=o*i+r*n-a*t,c=-r*t-a*n-s*i;return this.x=l*o+c*-r+h*-s-u*-a,this.y=h*o+c*-a+u*-r-l*-s,this.z=u*o+c*-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 dN.copy(this).projectOnVector(e),this.sub(dN)}reflect(e){return this.sub(dN.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(hs(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-gg(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}},dN=new k,Ece=new _r,Nt=class{constructor(e=new k(1/0,1/0,1/0),t=new k(-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(Sh.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(Sh.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=Sh.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(),_0.copy(e.boundingBox),_0.applyMatrix4(e.matrixWorld),this.union(_0);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++)Sh.fromBufferAttribute(t,n).applyMatrix4(e.matrixWorld),this.expandByPoint(Sh)}else null===n.boundingBox&&n.computeBoundingBox(),_0.copy(n.boundingBox),_0.applyMatrix4(e.matrixWorld),this.union(_0)}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,Sh),Sh.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(Rx),lM.subVectors(this.max,Rx),T0.subVectors(e.a,Rx),w0.subVectors(e.b,Rx),S0.subVectors(e.c,Rx),qd.subVectors(w0,T0),Wd.subVectors(S0,w0),Wp.subVectors(T0,S0);let t=[0,-qd.z,qd.y,0,-Wd.z,Wd.y,0,-Wp.z,Wp.y,qd.z,0,-qd.x,Wd.z,0,-Wd.x,Wp.z,0,-Wp.x,-qd.y,qd.x,0,-Wd.y,Wd.x,0,-Wp.y,Wp.x,0];return!(!fN(t,T0,w0,S0,lM)||(t=[1,0,0,0,1,0,0,0,1],!fN(t,T0,w0,S0,lM)))&&(cM.crossVectors(qd,Wd),t=[cM.x,cM.y,cM.z],fN(t,T0,w0,S0,lM))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Sh).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=.5*this.getSize(Sh).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()||(wh[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),wh[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),wh[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),wh[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),wh[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),wh[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),wh[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),wh[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(wh)),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)}},wh=[new k,new k,new k,new k,new k,new k,new k,new k],Sh=new k,_0=new Nt,T0=new k,w0=new k,S0=new k,qd=new k,Wd=new k,Wp=new k,Rx=new k,lM=new k,cM=new k,jp=new k;function fN(e,t,n,i,r){for(let a=0,s=e.length-3;a<=s;a+=3){jp.fromArray(e,a);let s=r.x*Math.abs(jp.x)+r.y*Math.abs(jp.y)+r.z*Math.abs(jp.z),o=t.dot(jp),l=n.dot(jp),h=i.dot(jp);if(Math.max(-Math.max(o,l,h),Math.min(o,l,h))>s)return!1}return!0}var _rt=new Nt,Cx=new k,pN=new k,$r=class{constructor(e=new k,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):_rt.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;Cx.subVectors(e,this.center);let t=Cx.lengthSq();if(t>this.radius*this.radius){let e=Math.sqrt(t),n=.5*(e-this.radius);this.center.addScaledVector(Cx,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):(pN.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Cx.copy(e.center).add(pN)),this.expandByPoint(Cx.copy(e.center).sub(pN))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return(new this.constructor).copy(this)}},Mh=new k,mN=new k,uM=new k,jd=new k,gN=new k,hM=new k,vN=new k,Tl=class{constructor(e=new k,t=new k(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,Mh)),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=Mh.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Mh.copy(this.origin).addScaledVector(this.direction,t),Mh.distanceToSquared(e))}distanceSqToSegment(e,t,n,i){mN.copy(e).add(t).multiplyScalar(.5),uM.copy(t).sub(e).normalize(),jd.copy(this.origin).sub(mN);let r,a,s,o,l=.5*e.distanceTo(t),h=-this.direction.dot(uM),u=jd.dot(this.direction),c=-jd.dot(uM),d=jd.lengthSq(),p=Math.abs(1-h*h);if(p>0)if(r=h*c-u,a=h*u-c,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*u)+a*(h*r+a+2*c)+d}else a=l,r=Math.max(0,-(h*a+u)),s=-r*r+a*(a+2*c)+d;else a=-l,r=Math.max(0,-(h*a+u)),s=-r*r+a*(a+2*c)+d;else a<=-o?(r=Math.max(0,-(-h*l+u)),a=r>0?-l:Math.min(Math.max(-l,-c),l),s=-r*r+a*(a+2*c)+d):a<=o?(r=0,a=Math.min(Math.max(-l,-c),l),s=a*(a+2*c)+d):(r=Math.max(0,-(h*l+u)),a=r>0?l:Math.min(Math.max(-l,-c),l),s=-r*r+a*(a+2*c)+d);else a=h>0?-l:l,r=Math.max(0,-(h*a+u)),s=-r*r+a*(a+2*c)+d;return n&&n.copy(this.origin).addScaledVector(this.direction,r),i&&i.copy(mN).addScaledVector(uM,a),s}intersectSphere(e,t){Mh.subVectors(e.center,this.origin);let n=Mh.dot(this.direction),i=Mh.dot(Mh)-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,u=1/this.direction.z,c=this.origin;return l>=0?(n=(e.min.x-c.x)*l,i=(e.max.x-c.x)*l):(n=(e.max.x-c.x)*l,i=(e.min.x-c.x)*l),h>=0?(r=(e.min.y-c.y)*h,a=(e.max.y-c.y)*h):(r=(e.max.y-c.y)*h,a=(e.min.y-c.y)*h),n>a||r>i||((r>n||isNaN(n))&&(n=r),(a<i||isNaN(i))&&(i=a),u>=0?(s=(e.min.z-c.z)*u,o=(e.max.z-c.z)*u):(s=(e.max.z-c.z)*u,o=(e.min.z-c.z)*u),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,Mh)}intersectTriangle(e,t,n,i,r){gN.subVectors(t,e),hM.subVectors(n,e),vN.crossVectors(gN,hM);let a,s=this.direction.dot(vN);if(s>0){if(i)return null;a=1}else{if(!(s<0))return null;a=-1,s=-s}jd.subVectors(this.origin,e);let o=a*this.direction.dot(hM.crossVectors(jd,hM));if(o<0)return null;let l=a*this.direction.dot(gN.cross(jd));if(l<0||o+l>s)return null;let h=-a*jd.dot(vN);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)}},ht=class{constructor(e,t,n,i,r,a,s,o,l,h,u,c,d,p,f,m){ht.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],void 0!==e&&this.set(e,t,n,i,r,a,s,o,l,h,u,c,d,p,f,m)}set(e,t,n,i,r,a,s,o,l,h,u,c,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]=u,g[14]=c,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 ht).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/M0.setFromMatrixColumn(e,0).length(),r=1/M0.setFromMatrixColumn(e,1).length(),a=1/M0.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),u=Math.sin(r);if("XYZ"===e.order){let e=a*h,n=a*u,i=s*h,r=s*u;t[0]=o*h,t[4]=-o*u,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*u,i=l*h,r=l*u;t[0]=e+r*s,t[4]=i*s-n,t[8]=a*l,t[1]=a*u,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*u,i=l*h,r=l*u;t[0]=e-r*s,t[4]=-a*u,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*u,i=s*h,r=s*u;t[0]=o*h,t[4]=i*l-n,t[8]=e*l+r,t[1]=o*u,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*u,t[8]=i*u+n,t[1]=u,t[5]=a*h,t[9]=-s*h,t[2]=-l*h,t[6]=n*u+i,t[10]=e-r*u}else if("XZY"===e.order){let e=a*o,n=a*l,i=s*o,r=s*l;t[0]=o*h,t[4]=-u,t[8]=l*h,t[1]=e*u+r,t[5]=a*h,t[9]=n*u-i,t[2]=i*u-n,t[6]=s*h,t[10]=r*u+e}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(Trt,e,wrt)}lookAt(e,t,n){let i=this.elements;return Uo.subVectors(e,t),0===Uo.lengthSq()&&(Uo.z=1),Uo.normalize(),Xd.crossVectors(n,Uo),0===Xd.lengthSq()&&(1===Math.abs(n.z)?Uo.x+=1e-4:Uo.z+=1e-4,Uo.normalize(),Xd.crossVectors(n,Uo)),Xd.normalize(),dM.crossVectors(Uo,Xd),i[0]=Xd.x,i[4]=dM.x,i[8]=Uo.x,i[1]=Xd.y,i[5]=dM.y,i[9]=Uo.y,i[2]=Xd.z,i[6]=dM.z,i[10]=Uo.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],u=n[5],c=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],b=n[15],_=i[0],w=i[4],S=i[8],M=i[12],E=i[1],T=i[5],A=i[9],C=i[13],P=i[2],R=i[6],L=i[10],I=i[14],k=i[3],O=i[7],D=i[11],N=i[15];return r[0]=a*_+s*E+o*P+l*k,r[4]=a*w+s*T+o*R+l*O,r[8]=a*S+s*A+o*L+l*D,r[12]=a*M+s*C+o*I+l*N,r[1]=h*_+u*E+c*P+d*k,r[5]=h*w+u*T+c*R+d*O,r[9]=h*S+u*A+c*L+d*D,r[13]=h*M+u*C+c*I+d*N,r[2]=p*_+f*E+m*P+g*k,r[6]=p*w+f*T+m*R+g*O,r[10]=p*S+f*A+m*L+g*D,r[14]=p*M+f*C+m*I+g*N,r[3]=v*_+y*E+x*P+b*k,r[7]=v*w+y*T+x*R+b*O,r[11]=v*S+y*A+x*L+b*D,r[15]=v*M+y*C+x*I+b*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],u=e[6],c=e[10],d=e[14];return e[3]*(+r*o*u-i*l*u-r*s*c+n*l*c+i*s*d-n*o*d)+e[7]*(+t*o*d-t*l*c+r*a*c-i*a*d+i*l*h-r*o*h)+e[11]*(+t*l*u-t*s*d-r*a*u+n*a*d+r*s*h-n*l*h)+e[15]*(-i*s*h-t*o*u+t*s*c+i*a*u-n*a*c+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],u=e[9],c=e[10],d=e[11],p=e[12],f=e[13],m=e[14],g=e[15],v=u*m*l-f*c*l+f*o*d-s*m*d-u*o*g+s*c*g,y=p*c*l-h*m*l-p*o*d+a*m*d+h*o*g-a*c*g,x=h*f*l-p*u*l+p*s*d-a*f*d-h*s*g+a*u*g,b=p*u*o-h*f*o-p*s*c+a*f*c+h*s*m-a*u*m,_=t*v+n*y+i*x+r*b;if(0===_)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let w=1/_;return e[0]=v*w,e[1]=(f*c*r-u*m*r-f*i*d+n*m*d+u*i*g-n*c*g)*w,e[2]=(s*m*r-f*o*r+f*i*l-n*m*l-s*i*g+n*o*g)*w,e[3]=(u*o*r-s*c*r-u*i*l+n*c*l+s*i*d-n*o*d)*w,e[4]=y*w,e[5]=(h*m*r-p*c*r+p*i*d-t*m*d-h*i*g+t*c*g)*w,e[6]=(p*o*r-a*m*r-p*i*l+t*m*l+a*i*g-t*o*g)*w,e[7]=(a*c*r-h*o*r+h*i*l-t*c*l-a*i*d+t*o*d)*w,e[8]=x*w,e[9]=(p*u*r-h*f*r-p*n*d+t*f*d+h*n*g-t*u*g)*w,e[10]=(a*f*r-p*s*r+p*n*l-t*f*l-a*n*g+t*s*g)*w,e[11]=(h*s*r-a*u*r-h*n*l+t*u*l+a*n*d-t*s*d)*w,e[12]=b*w,e[13]=(h*f*i-p*u*i+p*n*c-t*f*c-h*n*m+t*u*m)*w,e[14]=(p*s*i-a*f*i-p*n*o+t*f*o+a*n*m-t*s*m)*w,e[15]=(a*u*i-h*s*i+h*n*o-t*u*o-a*n*c+t*s*c)*w,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 e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){let t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let n=Math.cos(t),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,u=s+s,c=r*l,d=r*h,p=r*u,f=a*h,m=a*u,g=s*u,v=o*l,y=o*h,x=o*u,b=n.x,_=n.y,w=n.z;return i[0]=(1-(f+g))*b,i[1]=(d+x)*b,i[2]=(p-y)*b,i[3]=0,i[4]=(d-x)*_,i[5]=(1-(c+g))*_,i[6]=(m+v)*_,i[7]=0,i[8]=(p+y)*w,i[9]=(m-v)*w,i[10]=(1-(c+f))*w,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=M0.set(i[0],i[1],i[2]).length(),a=M0.set(i[4],i[5],i[6]).length(),s=M0.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],gc.copy(this);let o=1/r,l=1/a,h=1/s;return gc.elements[0]*=o,gc.elements[1]*=o,gc.elements[2]*=o,gc.elements[4]*=l,gc.elements[5]*=l,gc.elements[6]*=l,gc.elements[8]*=h,gc.elements[9]*=h,gc.elements[10]*=h,t.setFromRotationMatrix(gc),n.x=r,n.y=a,n.z=s,this}makePerspective(e,t,n,i,r,a,s=vu){let o,l,h=this.elements,u=2*r/(t-e),c=2*r/(n-i),d=(t+e)/(t-e),p=(n+i)/(n-i);if(s===vu)o=-(a+r)/(a-r),l=-2*a*r/(a-r);else{if(s!==Yx)throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+s);o=-a/(a-r),l=-a*r/(a-r)}return h[0]=u,h[4]=0,h[8]=d,h[12]=0,h[1]=0,h[5]=c,h[9]=p,h[13]=0,h[2]=0,h[6]=0,h[10]=o,h[14]=l,h[3]=0,h[7]=0,h[11]=-1,h[15]=0,this}makeOrthographic(e,t,n,i,r,a,s=vu){let o,l,h=this.elements,u=1/(t-e),c=1/(n-i),d=1/(a-r),p=(t+e)*u,f=(n+i)*c;if(s===vu)o=(a+r)*d,l=-2*d;else{if(s!==Yx)throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+s);o=r*d,l=-1*d}return h[0]=2*u,h[4]=0,h[8]=0,h[12]=-p,h[1]=0,h[5]=2*c,h[9]=0,h[13]=-f,h[2]=0,h[6]=0,h[10]=l,h[14]=-o,h[3]=0,h[7]=0,h[11]=0,h[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}},M0=new k,gc=new ht,Trt=new k(0,0,0),wrt=new k(1,1,1),Xd=new k,dM=new k,Uo=new k,_ce=new ht,Tce=new _r,Xn=class{constructor(e=0,t=0,n=0,i=Xn.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],u=i[2],c=i[6],d=i[10];switch(t){case"XYZ":this._y=Math.asin(hs(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(-h,d),this._z=Math.atan2(-a,r)):(this._x=Math.atan2(c,l),this._z=0);break;case"YXZ":this._x=Math.asin(-hs(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(s,d),this._z=Math.atan2(o,l)):(this._y=Math.atan2(-u,r),this._z=0);break;case"ZXY":this._x=Math.asin(hs(c,-1,1)),Math.abs(c)<.9999999?(this._y=Math.atan2(-u,d),this._z=Math.atan2(-a,l)):(this._y=0,this._z=Math.atan2(o,r));break;case"ZYX":this._y=Math.asin(-hs(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(c,d),this._z=Math.atan2(o,r)):(this._x=0,this._z=Math.atan2(-a,l));break;case"YZX":this._z=Math.asin(hs(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,l),this._y=Math.atan2(-u,r)):(this._x=0,this._y=Math.atan2(s,d));break;case"XZY":this._z=Math.asin(-hs(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(c,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 _ce.makeRotationFromQuaternion(e),this.setFromRotationMatrix(_ce,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Tce.setFromEuler(this),this.setFromQuaternion(Tce,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}};Xn.DEFAULT_ORDER="XYZ";var Jd=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))}},Srt=0,wce=new k,A0=new _r,Ah=new ht,fM=new k,Px=new k,Mrt=new k,Art=new _r,Sce=new k(1,0,0),Mce=new k(0,1,0),Ace=new k(0,0,1),Rrt={type:"added"},Rce={type:"removed"},an=class extends Tc{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Srt++}),this.uuid=zo(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=an.DEFAULT_UP.clone();let e=new k,t=new Xn,n=new _r,i=new k(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 ht},normalMatrix:{value:new In}}),this.matrix=new ht,this.matrixWorld=new ht,this.matrixAutoUpdate=an.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.matrixWorldAutoUpdate=an.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.layers=new Jd,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 A0.setFromAxisAngle(e,t),this.quaternion.multiply(A0),this}rotateOnWorldAxis(e,t){return A0.setFromAxisAngle(e,t),this.quaternion.premultiply(A0),this}rotateX(e){return this.rotateOnAxis(Sce,e)}rotateY(e){return this.rotateOnAxis(Mce,e)}rotateZ(e){return this.rotateOnAxis(Ace,e)}translateOnAxis(e,t){return wce.copy(e).applyQuaternion(this.quaternion),this.position.add(wce.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(Sce,e)}translateY(e){return this.translateOnAxis(Mce,e)}translateZ(e){return this.translateOnAxis(Ace,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Ah.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?fM.copy(e):fM.set(e,t,n);let i=this.parent;this.updateWorldMatrix(!0,!1),Px.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Ah.lookAt(Px,fM,this.up):Ah.lookAt(fM,Px,this.up),this.quaternion.setFromRotationMatrix(Ah),i&&(Ah.extractRotation(i.matrixWorld),A0.setFromRotationMatrix(Ah),this.quaternion.premultiply(A0.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(Rrt)):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(Rce)),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(Rce)}return this.children.length=0,this}attach(e){return this.updateWorldMatrix(!0,!1),Ah.copy(this.matrixWorld).invert(),null!==e.parent&&(e.parent.updateWorldMatrix(!0,!1),Ah.multiply(e.parent.matrixWorld)),e.applyMatrix4(Ah),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(Px,e,Mrt),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Px,Art,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.6,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),u=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),u.length>0&&(n.nodes=u)}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.slice(),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}};an.DEFAULT_UP=new k(0,1,0),an.DEFAULT_MATRIX_AUTO_UPDATE=!0,an.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;var vc=new k,Rh=new k,yN=new k,Ch=new k,R0=new k,C0=new k,Cce=new k,xN=new k,bN=new k,EN=new k,pM=!1,ni=class{constructor(e=new k,t=new k,n=new k){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,i){i.subVectors(n,t),vc.subVectors(e,t),i.cross(vc);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){vc.subVectors(i,t),Rh.subVectors(n,t),yN.subVectors(e,t);let a=vc.dot(vc),s=vc.dot(Rh),o=vc.dot(yN),l=Rh.dot(Rh),h=Rh.dot(yN),u=a*l-s*s;if(0===u)return r.set(-2,-1,-1);let c=1/u,d=(l*o-s*h)*c,p=(a*h-s*o)*c;return r.set(1-d-p,p,d)}static containsPoint(e,t,n,i){return this.getBarycoord(e,t,n,i,Ch),Ch.x>=0&&Ch.y>=0&&Ch.x+Ch.y<=1}static getUV(e,t,n,i,r,a,s,o){return!1===pM&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),pM=!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,Ch),o.setScalar(0),o.addScaledVector(r,Ch.x),o.addScaledVector(a,Ch.y),o.addScaledVector(s,Ch.z),o}static isFrontFacing(e,t,n,i){return vc.subVectors(n,t),Rh.subVectors(e,t),vc.cross(Rh).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 vc.subVectors(this.c,this.b),Rh.subVectors(this.a,this.b),.5*vc.cross(Rh).length()}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return ni.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return ni.getBarycoord(e,this.a,this.b,this.c,t)}getUV(e,t,n,i,r){return!1===pM&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),pM=!0),ni.getInterpolation(e,this.a,this.b,this.c,t,n,i,r)}getInterpolation(e,t,n,i,r){return ni.getInterpolation(e,this.a,this.b,this.c,t,n,i,r)}containsPoint(e){return ni.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return ni.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;R0.subVectors(a,r),C0.subVectors(s,r),xN.subVectors(e,r);let o=R0.dot(xN),l=C0.dot(xN);if(o<=0&&l<=0)return t.copy(r);bN.subVectors(e,a);let h=R0.dot(bN),u=C0.dot(bN);if(h>=0&&u<=h)return t.copy(a);let c=o*u-h*l;if(c<=0&&o>=0&&h<=0)return n=o/(o-h),t.copy(r).addScaledVector(R0,n);EN.subVectors(e,s);let d=R0.dot(EN),p=C0.dot(EN);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(C0,i);let m=h*p-d*u;if(m<=0&&u-h>=0&&d-p>=0)return Cce.subVectors(s,a),i=(u-h)/(u-h+(d-p)),t.copy(a).addScaledVector(Cce,i);let g=1/(m+f+c);return n=f*g,i=c*g,t.copy(r).addScaledVector(R0,n).addScaledVector(C0,i)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},Crt=0,Ar=class extends Tc{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Crt++}),this.uuid=zo(),this.name="",this.type="Material",this.blending=sm,this.side=hi,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=bU,this.blendDst=EU,this.blendEquation=Vo,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=nA,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Ahe,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=tA,this.stencilZFail=tA,this.stencilZPass=tA,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.6,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),void 0!==this.anisotropy&&(n.anisotropy=this.anisotropy),void 0!==this.anisotropyRotation&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,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!==sm&&(n.blending=this.blending),this.side!==hi&&(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.alphaHash&&(n.alphaHash=this.alphaHash),!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.alphaHash=e.alphaHash,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++}},Bhe={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},yc={h:0,s:0,l:0},mM={h:0,s:0,l:0};function _N(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 ct=class{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(void 0===t&&void 0===n){let t=e;t&&t.isColor?this.copy(t):"number"==typeof t?this.setHex(t):"string"==typeof t&&this.setStyle(t)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=sn){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(255&e)/255,bl.toWorkingColorSpace(this,t),this}setRGB(e,t,n,i=bl.workingColorSpace){return this.r=e,this.g=t,this.b=n,bl.toWorkingColorSpace(this,i),this}setHSL(e,t,n,i=bl.workingColorSpace){if(e=LU(e,1),t=hs(t,0,1),n=hs(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=_N(r,i,e+1/3),this.g=_N(r,i,e),this.b=_N(r,i,e-1/3)}return bl.toWorkingColorSpace(this,i),this}setStyle(e,t=sn){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=sn){let n=Bhe[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=j0(e.r),this.g=j0(e.g),this.b=j0(e.b),this}copyLinearToSRGB(e){return this.r=uN(e.r),this.g=uN(e.g),this.b=uN(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=sn){return bl.fromWorkingColorSpace(fa.copy(this),e),65536*Math.round(hs(255*fa.r,0,255))+256*Math.round(hs(255*fa.g,0,255))+Math.round(hs(255*fa.b,0,255))}getHexString(e=sn){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=bl.workingColorSpace){bl.fromWorkingColorSpace(fa.copy(this),t);let n,i,r=fa.r,a=fa.g,s=fa.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=bl.workingColorSpace){return bl.fromWorkingColorSpace(fa.copy(this),t),e.r=fa.r,e.g=fa.g,e.b=fa.b,e}getStyle(e=sn){bl.fromWorkingColorSpace(fa.copy(this),e);let t=fa.r,n=fa.g,i=fa.b;return e!==sn?`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(yc),yc.h+=e,yc.s+=t,yc.l+=n,this.setHSL(yc.h,yc.s,yc.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(yc),e.getHSL(mM);let n=Hx(yc.h,mM.h,t),i=Hx(yc.s,mM.s,t),r=Hx(yc.l,mM.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}},fa=new ct;ct.NAMES=Bhe;var cn=class extends Ar{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new ct(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=yb,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}},Ih=Prt();function Prt(){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 uo(e){Math.abs(e)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),e=hs(e,-65504,65504),Ih.floatView[0]=e;let t=Ih.uint32View[0],n=t>>23&511;return Ih.baseTable[n]+((8388607&t)>>Ih.shiftTable[n])}function Bx(e){let t=e>>10;return Ih.uint32View[0]=Ih.mantissaTable[Ih.offsetTable[t]+(1023&e)]+Ih.exponentTable[t],Ih.floatView[0]}var yv={toHalfFloat:uo,fromHalfFloat:Bx},_s=new k,gM=new _e,yn=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=Xx,this.updateRange={offset:0,count:-1},this.gpuType=pa,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.gpuType=e.gpuType,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++)gM.fromBufferAttribute(this,t),gM.applyMatrix3(e),this.setXY(t,gM.x,gM.y);else if(3===this.itemSize)for(let t=0,n=this.count;t<n;t++)_s.fromBufferAttribute(this,t),_s.applyMatrix3(e),this.setXYZ(t,_s.x,_s.y,_s.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)_s.fromBufferAttribute(this,t),_s.applyMatrix4(e),this.setXYZ(t,_s.x,_s.y,_s.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)_s.fromBufferAttribute(this,t),_s.applyNormalMatrix(e),this.setXYZ(t,_s.x,_s.y,_s.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)_s.fromBufferAttribute(this,t),_s.transformDirection(e),this.setXYZ(t,_s.x,_s.y,_s.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];return this.normalized&&(n=ho(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=pr(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=ho(t,this.array)),t}setX(e,t){return this.normalized&&(t=pr(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=ho(t,this.array)),t}setY(e,t){return this.normalized&&(t=pr(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=ho(t,this.array)),t}setZ(e,t){return this.normalized&&(t=pr(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=ho(t,this.array)),t}setW(e,t){return this.normalized&&(t=pr(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=pr(t,this.array),n=pr(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=pr(t,this.array),n=pr(n,this.array),i=pr(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=pr(t,this.array),n=pr(n,this.array),i=pr(i,this.array),r=pr(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!==Xx&&(e.usage=this.usage),(0!==this.updateRange.offset||-1!==this.updateRange.count)&&(e.updateRange=this.updateRange),e}},bB=class extends yn{constructor(e,t,n){super(new Int8Array(e),t,n)}},Jx=class extends yn{constructor(e,t,n){super(new Uint8Array(e),t,n)}},EB=class extends yn{constructor(e,t,n){super(new Uint8ClampedArray(e),t,n)}},_B=class extends yn{constructor(e,t,n){super(new Int16Array(e),t,n)}},lm=class extends yn{constructor(e,t,n){super(new Uint16Array(e),t,n)}},TB=class extends yn{constructor(e,t,n){super(new Int32Array(e),t,n)}},Qx=class extends yn{constructor(e,t,n){super(new Uint32Array(e),t,n)}},wB=class extends yn{constructor(e,t,n){super(new Uint16Array(e),t,n),this.isFloat16BufferAttribute=!0}getX(e){let t=Bx(this.array[e*this.itemSize]);return this.normalized&&(t=ho(t,this.array)),t}setX(e,t){return this.normalized&&(t=pr(t,this.array)),this.array[e*this.itemSize]=uo(t),this}getY(e){let t=Bx(this.array[e*this.itemSize+1]);return this.normalized&&(t=ho(t,this.array)),t}setY(e,t){return this.normalized&&(t=pr(t,this.array)),this.array[e*this.itemSize+1]=uo(t),this}getZ(e){let t=Bx(this.array[e*this.itemSize+2]);return this.normalized&&(t=ho(t,this.array)),t}setZ(e,t){return this.normalized&&(t=pr(t,this.array)),this.array[e*this.itemSize+2]=uo(t),this}getW(e){let t=Bx(this.array[e*this.itemSize+3]);return this.normalized&&(t=ho(t,this.array)),t}setW(e,t){return this.normalized&&(t=pr(t,this.array)),this.array[e*this.itemSize+3]=uo(t),this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=pr(t,this.array),n=pr(n,this.array)),this.array[e+0]=uo(t),this.array[e+1]=uo(n),this}setXYZ(e,t,n,i){return e*=this.itemSize,this.normalized&&(t=pr(t,this.array),n=pr(n,this.array),i=pr(i,this.array)),this.array[e+0]=uo(t),this.array[e+1]=uo(n),this.array[e+2]=uo(i),this}setXYZW(e,t,n,i,r){return e*=this.itemSize,this.normalized&&(t=pr(t,this.array),n=pr(n,this.array),i=pr(i,this.array),r=pr(r,this.array)),this.array[e+0]=uo(t),this.array[e+1]=uo(n),this.array[e+2]=uo(i),this.array[e+3]=uo(r),this}},Bt=class extends yn{constructor(e,t,n){super(new Float32Array(e),t,n)}},SB=class extends yn{constructor(e,t,n){super(new Float64Array(e),t,n)}},Irt=0,xl=new ht,TN=new an,P0=new k,Ho=new Nt,Ix=new Nt,Gs=new k,Ot=class extends Tc{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Irt++}),this.uuid=zo(),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(Nhe(e)?Qx:lm)(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 In).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 xl.makeRotationFromQuaternion(e),this.applyMatrix4(xl),this}rotateX(e){return xl.makeRotationX(e),this.applyMatrix4(xl),this}rotateY(e){return xl.makeRotationY(e),this.applyMatrix4(xl),this}rotateZ(e){return xl.makeRotationZ(e),this.applyMatrix4(xl),this}translate(e,t,n){return xl.makeTranslation(e,t,n),this.applyMatrix4(xl),this}scale(e,t,n){return xl.makeScale(e,t,n),this.applyMatrix4(xl),this}lookAt(e){return TN.lookAt(e),TN.updateMatrix(),this.applyMatrix4(TN.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(P0).negate(),this.translate(P0.x,P0.y,P0.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 Bt(t,3)),this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new Nt);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 k(-1/0,-1/0,-1/0),new k(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];Ho.setFromBufferAttribute(e),this.morphTargetsRelative?(Gs.addVectors(this.boundingBox.min,Ho.min),this.boundingBox.expandByPoint(Gs),Gs.addVectors(this.boundingBox.max,Ho.max),this.boundingBox.expandByPoint(Gs)):(this.boundingBox.expandByPoint(Ho.min),this.boundingBox.expandByPoint(Ho.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 $r);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 k,1/0);if(e){let n=this.boundingSphere.center;if(Ho.setFromBufferAttribute(e),t)for(let e=0,r=t.length;e<r;e++){let n=t[e];Ix.setFromBufferAttribute(n),this.morphTargetsRelative?(Gs.addVectors(Ho.min,Ix.min),Ho.expandByPoint(Gs),Gs.addVectors(Ho.max,Ix.max),Ho.expandByPoint(Gs)):(Ho.expandByPoint(Ix.min),Ho.expandByPoint(Ix.max))}Ho.getCenter(n);let i=0;for(let t=0,r=e.count;t<r;t++)Gs.fromBufferAttribute(e,t),i=Math.max(i,n.distanceToSquared(Gs));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++)Gs.fromBufferAttribute(a,t),s&&(P0.fromBufferAttribute(e,t),Gs.add(P0)),i=Math.max(i,n.distanceToSquared(Gs))}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 yn(new Float32Array(4*s),4));let o=this.getAttribute("tangent").array,l=[],h=[];for(let E=0;E<s;E++)l[E]=new k,h[E]=new k;let u=new k,c=new k,d=new k,p=new _e,f=new _e,m=new _e,g=new k,v=new k;function y(e,t,n){u.fromArray(i,3*e),c.fromArray(i,3*t),d.fromArray(i,3*n),p.fromArray(a,2*e),f.fromArray(a,2*t),m.fromArray(a,2*n),c.sub(u),d.sub(u),f.sub(p),m.sub(p);let r=1/(f.x*m.y-m.x*f.y);isFinite(r)&&(g.copy(c).multiplyScalar(m.y).addScaledVector(d,-f.y).multiplyScalar(r),v.copy(d).multiplyScalar(f.x).addScaledVector(c,-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 E=0,T=x.length;E<T;++E){let e=x[E],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 b=new k,_=new k,w=new k,S=new k;function M(e){w.fromArray(r,3*e),S.copy(w);let t=l[e];b.copy(t),b.sub(w.multiplyScalar(w.dot(t))).normalize(),_.crossVectors(S,t);let n=_.dot(h[e])<0?-1:1;o[4*e]=b.x,o[4*e+1]=b.y,o[4*e+2]=b.z,o[4*e+3]=n}for(let E=0,T=x.length;E<T;++E){let e=x[E],t=e.start;for(let i=t,r=t+e.count;i<r;i+=3)M(n[i+0]),M(n[i+1]),M(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 yn(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 k,r=new k,a=new k,s=new k,o=new k,l=new k,h=new k,u=new k;if(e)for(let c=0,d=e.count;c<d;c+=3){let d=e.getX(c+0),p=e.getX(c+1),f=e.getX(c+2);i.fromBufferAttribute(t,d),r.fromBufferAttribute(t,p),a.fromBufferAttribute(t,f),h.subVectors(a,r),u.subVectors(i,r),h.cross(u),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,c=t.count;e<c;e+=3)i.fromBufferAttribute(t,e+0),r.fromBufferAttribute(t,e+1),a.fromBufferAttribute(t,e+2),h.subVectors(a,r),u.subVectors(i,r),h.cross(u),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}}normalizeNormals(){let e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)Gs.fromBufferAttribute(e,t),Gs.normalize(),e.setXYZ(t,Gs.x,Gs.y,Gs.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 yn(a,i,r)}if(null===this.index)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;let t=new Ot,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.6,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"})}},Pce=new ht,Xp=new Tl,vM=new $r,Ice=new k,I0=new k,L0=new k,D0=new k,wN=new k,yM=new k,xM=new _e,bM=new _e,EM=new _e,Lce=new k,Dce=new k,Oce=new k,_M=new k,TM=new k,St=class extends an{constructor(e=new Ot,t=new cn){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){yM.set(0,0,0);for(let n=0,i=r.length;n<i;n++){let i=s[n],o=r[n];0!==i&&(wN.fromBufferAttribute(o,e),a?yM.addScaledVector(wN,i):yM.addScaledVector(wN.sub(t),i))}t.add(yM)}return t}raycast(e,t){let n=this.geometry,i=this.material,r=this.matrixWorld;void 0!==i&&(null===n.boundingSphere&&n.computeBoundingSphere(),vM.copy(n.boundingSphere),vM.applyMatrix4(r),Xp.copy(e.ray).recast(e.near),(!1!==vM.containsPoint(Xp.origin)||!(null===Xp.intersectSphere(vM,Ice)||Xp.origin.distanceToSquared(Ice)>gg(e.far-e.near,2)))&&(Pce.copy(r).invert(),Xp.copy(e.ray).applyMatrix4(Pce),(null===n.boundingBox||!1!==Xp.intersectsBox(n.boundingBox))&&this._computeIntersections(e,t,Xp)))}_computeIntersections(e,t,n){let i,r=this.geometry,a=this.material,s=r.index,o=r.attributes.position,l=r.attributes.uv,h=r.attributes.uv1,u=r.attributes.normal,c=r.groups,d=r.drawRange;if(null!==s)if(Array.isArray(a))for(let p=0,f=c.length;p<f;p++){let r=c[p],o=a[r.materialIndex];for(let a=Math.max(r.start,d.start),c=Math.min(s.count,Math.min(r.start+r.count,d.start+d.count));a<c;a+=3)i=wM(this,o,e,n,l,h,u,s.getX(a),s.getX(a+1),s.getX(a+2)),i&&(i.faceIndex=Math.floor(a/3),i.face.materialIndex=r.materialIndex,t.push(i))}else for(let p=Math.max(0,d.start),f=Math.min(s.count,d.start+d.count);p<f;p+=3)i=wM(this,a,e,n,l,h,u,s.getX(p),s.getX(p+1),s.getX(p+2)),i&&(i.faceIndex=Math.floor(p/3),t.push(i));else if(void 0!==o)if(Array.isArray(a))for(let p=0,f=c.length;p<f;p++){let r=c[p],s=a[r.materialIndex];for(let a=Math.max(r.start,d.start),c=Math.min(o.count,Math.min(r.start+r.count,d.start+d.count));a<c;a+=3)i=wM(this,s,e,n,l,h,u,a,a+1,a+2),i&&(i.faceIndex=Math.floor(a/3),i.face.materialIndex=r.materialIndex,t.push(i))}else for(let p=Math.max(0,d.start),f=Math.min(o.count,d.start+d.count);p<f;p+=3)i=wM(this,a,e,n,l,h,u,p,p+1,p+2),i&&(i.faceIndex=Math.floor(p/3),t.push(i))}};function Lrt(e,t,n,i,r,a,s,o){let l;if(l=t.side===Ki?i.intersectTriangle(s,a,r,!0,o):i.intersectTriangle(r,a,s,t.side===hi,o),null===l)return null;TM.copy(o),TM.applyMatrix4(e.matrixWorld);let h=n.ray.origin.distanceTo(TM);return h<n.near||h>n.far?null:{distance:h,point:TM.clone(),object:e}}function wM(e,t,n,i,r,a,s,o,l,h){e.getVertexPosition(o,I0),e.getVertexPosition(l,L0),e.getVertexPosition(h,D0);let u=Lrt(e,t,n,i,I0,L0,D0,_M);if(u){r&&(xM.fromBufferAttribute(r,o),bM.fromBufferAttribute(r,l),EM.fromBufferAttribute(r,h),u.uv=ni.getInterpolation(_M,I0,L0,D0,xM,bM,EM,new _e)),a&&(xM.fromBufferAttribute(a,o),bM.fromBufferAttribute(a,l),EM.fromBufferAttribute(a,h),u.uv1=ni.getInterpolation(_M,I0,L0,D0,xM,bM,EM,new _e),u.uv2=u.uv1),s&&(Lce.fromBufferAttribute(s,o),Dce.fromBufferAttribute(s,l),Oce.fromBufferAttribute(s,h),u.normal=ni.getInterpolation(_M,I0,L0,D0,Lce,Dce,Oce,new k),u.normal.dot(i.direction)>0&&u.normal.multiplyScalar(-1));let e={a:o,b:l,c:h,normal:new k,materialIndex:0};ni.getNormal(I0,L0,D0,e.normal),u.face=e}return u}var ma=class extends Ot{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=[],u=[],c=0,d=0;function p(e,t,n,i,r,a,p,f,m,g,v){let y=a/m,x=p/g,b=a/2,_=p/2,w=f/2,S=m+1,M=g+1,E=0,T=0,A=new k;for(let s=0;s<M;s++){let a=s*x-_;for(let o=0;o<S;o++){let c=o*y-b;A[e]=c*i,A[t]=a*r,A[n]=w,l.push(A.x,A.y,A.z),A[e]=0,A[t]=0,A[n]=f>0?1:-1,h.push(A.x,A.y,A.z),u.push(o/m),u.push(1-s/g),E+=1}}for(let s=0;s<g;s++)for(let e=0;e<m;e++){let t=c+e+S*s,n=c+e+S*(s+1),i=c+(e+1)+S*(s+1),r=c+(e+1)+S*s;o.push(t,n,r),o.push(n,i,r),T+=6}s.addGroup(d,T,v),d+=T,c+=E}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 Bt(l,3)),this.setAttribute("normal",new Bt(h,3)),this.setAttribute("uv",new Bt(u,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new ma(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}};function Z0(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 Na(e){let t={};for(let n=0;n<e.length;n++){let i=Z0(e[n]);for(let e in i)t[e]=i[e]}return t}function Drt(e){let t=[];for(let n=0;n<e.length;n++)t.push(e[n].clone());return t}function Uhe(e){return null===e.getRenderTarget()?e.outputColorSpace:Ua}var Ti={clone:Z0,merge:Na},Ort="void main() {\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",krt="void main() {\n\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}",hn=class extends Ar{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=Ort,this.fragmentShader=krt,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=Z0(e.uniforms),this.uniformsGroups=Drt(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}},Uh=class extends an{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new ht,this.projectionMatrix=new ht,this.projectionMatrixInverse=new ht,this.coordinateSystem=vu}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){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)}},Yr=class extends Uh{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*Y0*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(.5*am*this.fov);return.5*this.getFilmHeight()/e}getEffectiveFOV(){return 2*Y0*Math.atan(Math.tan(.5*am*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*am*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.coordinateSystem),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}},O0=-90,k0=1,aA=class extends an{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null;let i=new Yr(O0,k0,e,t);i.layers=this.layers,this.add(i);let r=new Yr(O0,k0,e,t);r.layers=this.layers,this.add(r);let a=new Yr(O0,k0,e,t);a.layers=this.layers,this.add(a);let s=new Yr(O0,k0,e,t);s.layers=this.layers,this.add(s);let o=new Yr(O0,k0,e,t);o.layers=this.layers,this.add(o);let l=new Yr(O0,k0,e,t);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){let e=this.coordinateSystem,t=this.children.concat(),[n,i,r,a,s,o]=t;for(let l of t)this.remove(l);if(e===vu)n.up.set(0,1,0),n.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),s.up.set(0,1,0),s.lookAt(0,0,1),o.up.set(0,1,0),o.lookAt(0,0,-1);else{if(e!==Yx)throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);n.up.set(0,-1,0),n.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),s.up.set(0,-1,0),s.lookAt(0,0,1),o.up.set(0,-1,0),o.lookAt(0,0,-1)}for(let l of t)this.add(l),l.updateMatrixWorld()}update(e,t){null===this.parent&&this.updateMatrixWorld();let n=this.renderTarget;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());let[i,r,a,s,o,l]=this.children,h=e.getRenderTarget(),u=e.xr.enabled;e.xr.enabled=!1;let c=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=c,e.setRenderTarget(n,5),e.render(t,l),e.setRenderTarget(h),e.xr.enabled=u,n.texture.needsPMREMUpdate=!0}},cm=class extends Hr{constructor(e,t,n,i,r,a,s,o,l,h){super(e=void 0!==e?e:[],t=void 0!==t?t:kh,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}},oA=class extends er{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&&(Vx("THREE.WebGLCubeRenderTarget: option.encoding has been replaced by option.colorSpace."),t.colorSpace=t.encoding===xu?sn:bu),this.texture=new cm(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:Xr}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 ma(5,5,5),s=new hn({name:"CubemapFromEquirect",uniforms:Z0(n),vertexShader:i,fragmentShader:r,side:Ki,blending:Qr});s.uniforms.tEquirect.value=t;let o=new St(a,s),l=t.minFilter;return t.minFilter===Ba&&(t.minFilter=Xr),new aA(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)}},SN=new k,Frt=new k,Nrt=new In,Ur=class{constructor(e=new k(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=SN.subVectors(n,t).cross(Frt.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(SN),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||Nrt.getNormalMatrix(e),i=this.coplanarPoint(SN).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)}},Yp=new $r,SM=new k,wl=class{constructor(e=new Ur,t=new Ur,n=new Ur,i=new Ur,r=new Ur,a=new Ur){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,t=vu){let n=this.planes,i=e.elements,r=i[0],a=i[1],s=i[2],o=i[3],l=i[4],h=i[5],u=i[6],c=i[7],d=i[8],p=i[9],f=i[10],m=i[11],g=i[12],v=i[13],y=i[14],x=i[15];if(n[0].setComponents(o-r,c-l,m-d,x-g).normalize(),n[1].setComponents(o+r,c+l,m+d,x+g).normalize(),n[2].setComponents(o+a,c+h,m+p,x+v).normalize(),n[3].setComponents(o-a,c-h,m-p,x-v).normalize(),n[4].setComponents(o-s,c-u,m-f,x-y).normalize(),t===vu)n[5].setComponents(o+s,c+u,m+f,x+y).normalize();else{if(t!==Yx)throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);n[5].setComponents(s,u,f,y).normalize()}return this}intersectsObject(e){if(void 0!==e.boundingSphere)null===e.boundingSphere&&e.computeBoundingSphere(),Yp.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{let t=e.geometry;null===t.boundingSphere&&t.computeBoundingSphere(),Yp.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Yp)}intersectsSprite(e){return Yp.center.set(0,0,0),Yp.radius=.7071067811865476,Yp.applyMatrix4(e.matrixWorld),this.intersectsSphere(Yp)}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(SM.x=i.normal.x>0?e.max.x:e.min.x,SM.y=i.normal.y>0?e.max.y:e.min.y,SM.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(SM)<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 Hhe(){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 Brt(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 mi=class extends Ot{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,u=e/s,c=t/o,d=[],p=[],f=[],m=[];for(let g=0;g<h;g++){let e=g*c-a;for(let t=0;t<l;t++){let n=t*u-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 Bt(p,3)),this.setAttribute("normal",new Bt(f,3)),this.setAttribute("uv",new Bt(m,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)}},Urt="#ifdef USE_ALPHAHASH\n\tif ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;\n#endif",Hrt="#ifdef USE_ALPHAHASH\n\tconst float ALPHA_HASH_SCALE = 0.05;\n\tfloat hash2D( vec2 value ) {\n\t\treturn fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );\n\t}\n\tfloat hash3D( vec3 value ) {\n\t\treturn hash2D( vec2( hash2D( value.xy ), value.z ) );\n\t}\n\tfloat getAlphaHashThreshold( vec3 position ) {\n\t\tfloat maxDeriv = max(\n\t\t\tlength( dFdx( position.xyz ) ),\n\t\t\tlength( dFdy( position.xyz ) )\n\t\t);\n\t\tfloat pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );\n\t\tvec2 pixScales = vec2(\n\t\t\texp2( floor( log2( pixScale ) ) ),\n\t\t\texp2( ceil( log2( pixScale ) ) )\n\t\t);\n\t\tvec2 alpha = vec2(\n\t\t\thash3D( floor( pixScales.x * position.xyz ) ),\n\t\t\thash3D( floor( pixScales.y * position.xyz ) )\n\t\t);\n\t\tfloat lerpFactor = fract( log2( pixScale ) );\n\t\tfloat x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;\n\t\tfloat a = min( lerpFactor, 1.0 - lerpFactor );\n\t\tvec3 cases = vec3(\n\t\t\tx * x / ( 2.0 * a * ( 1.0 - a ) ),\n\t\t\t( x - 0.5 * a ) / ( 1.0 - a ),\n\t\t\t1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )\n\t\t);\n\t\tfloat threshold = ( x < ( 1.0 - a ) )\n\t\t\t? ( ( x < a ) ? cases.x : cases.y )\n\t\t\t: cases.z;\n\t\treturn clamp( threshold , 1.0e-6, 1.0 );\n\t}\n#endif",Vrt="#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;\n#endif",zrt="#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",Grt="#ifdef USE_ALPHATEST\n\tif ( diffuseColor.a < alphaTest ) discard;\n#endif",qrt="#ifdef USE_ALPHATEST\n\tuniform float alphaTest;\n#endif",Wrt="#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",jrt="#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif",Xrt="vec3 transformed = vec3( position );\n#ifdef USE_ALPHAHASH\n\tvPosition = vec3( position );\n#endif",Yrt="vec3 objectNormal = vec3( normal );\n#ifdef USE_TANGENT\n\tvec3 objectTangent = vec3( tangent.xyz );\n#endif",$rt="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",Zrt="#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\treturn 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 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",Krt="#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",Jrt="#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",Qrt="#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",eit="#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n#endif",tit="#if NUM_CLIPPING_PLANES > 0\n\tvClipPosition = - mvPosition.xyz;\n#endif",nit="#if defined( USE_COLOR_ALPHA )\n\tdiffuseColor *= vColor;\n#elif defined( USE_COLOR )\n\tdiffuseColor.rgb *= vColor;\n#endif",rit="#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR )\n\tvarying vec3 vColor;\n#endif",iit="#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvarying vec3 vColor;\n#endif",sit="#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",ait="#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};\n#ifdef USE_ALPHAHASH\n\tvarying vec3 vPosition;\n#endif\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",oit="#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",lit="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",cit="#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif",uit="#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );\n#endif",hit="#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif",dit="#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif",fit="gl_FragColor = linearToOutputTexel( gl_FragColor );",pit="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}",mit="#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",git="#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",vit="#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",yit="#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",xit="#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",bit="#ifdef USE_FOG\n\tvFogDepth = - mvPosition.z;\n#endif",Eit="#ifdef USE_FOG\n\tvarying float vFogDepth;\n#endif",_it="#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",Tit="#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",wit="#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}",Sit="#ifdef USE_LIGHTMAP\n\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\treflectedLight.indirectDiffuse += lightMapIrradiance;\n#endif",Mit="#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",Ait="LambertMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularStrength = specularStrength;",Rit="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",Cit="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",Pit="#ifdef USE_ENVMAP\n\tvec3 getIBLIrradiance( const in vec3 normal ) {\n\t\t#ifdef 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#ifdef 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\t#ifdef USE_ANISOTROPY\n\t\tvec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {\n\t\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\t\tvec3 bentNormal = cross( bitangent, viewDir );\n\t\t\t\tbentNormal = normalize( cross( bentNormal, bitangent ) );\n\t\t\t\tbentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );\n\t\t\t\treturn getIBLRadiance( viewDir, bentNormal, roughness );\n\t\t\t#else\n\t\t\t\treturn vec3( 0.0 );\n\t\t\t#endif\n\t\t}\n\t#endif\n#endif",Iit="ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;",Lit="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",Dit="BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",Oit="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",kit="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\n#ifdef USE_ANISOTROPY\n\t#ifdef USE_ANISOTROPYMAP\n\t\tmat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );\n\t\tvec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;\n\t\tvec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;\n\t#else\n\t\tvec2 anisotropyV = anisotropyVector;\n\t#endif\n\tmaterial.anisotropy = length( anisotropyV );\n\tanisotropyV /= material.anisotropy;\n\tmaterial.anisotropy = saturate( material.anisotropy );\n\tmaterial.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );\n\tmaterial.anisotropyT = tbn[ 0 ] * anisotropyV.x - tbn[ 1 ] * anisotropyV.y;\n\tmaterial.anisotropyB = tbn[ 1 ] * anisotropyV.x + tbn[ 0 ] * anisotropyV.y;\n#endif",Fit="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\t#ifdef USE_ANISOTROPY\n\t\tfloat anisotropy;\n\t\tfloat alphaT;\n\t\tvec3 anisotropyT;\n\t\tvec3 anisotropyB;\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_ANISOTROPY\n\tfloat V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {\n\t\tfloat gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );\n\t\tfloat gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );\n\t\tfloat v = 0.5 / ( gv + gl );\n\t\treturn saturate(v);\n\t}\n\tfloat D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {\n\t\tfloat a2 = alphaT * alphaB;\n\t\thighp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );\n\t\thighp float v2 = dot( v, v );\n\t\tfloat w2 = a2 / v2;\n\t\treturn RECIPROCAL_PI * a2 * pow2 ( w2 );\n\t}\n#endif\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\t#ifdef USE_ANISOTROPY\n\t\tfloat dotTL = dot( material.anisotropyT, lightDir );\n\t\tfloat dotTV = dot( material.anisotropyT, viewDir );\n\t\tfloat dotTH = dot( material.anisotropyT, halfDir );\n\t\tfloat dotBL = dot( material.anisotropyB, lightDir );\n\t\tfloat dotBV = dot( material.anisotropyB, viewDir );\n\t\tfloat dotBH = dot( material.anisotropyB, halfDir );\n\t\tfloat V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );\n\t\tfloat D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );\n\t#else\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t#endif\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}",Nit="\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",Bit="#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\t#ifdef USE_ANISOTROPY\n\t\tradiance += getIBLAnisotropyRadiance( geometry.viewDir, geometry.normal, material.roughness, material.anisotropyB, material.anisotropy );\n\t#else\n\t\tradiance += getIBLRadiance( geometry.viewDir, geometry.normal, material.roughness );\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatRadiance += getIBLRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness );\n\t#endif\n#endif",Uit="#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",Hit="#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",Vit="#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",zit="#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",Git="#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",qit="#ifdef USE_MAP\n\tdiffuseColor *= texture2D( map, vMapUv );\n#endif",Wit="#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif",jit="#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",Xit="#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",Yit="float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif",$it="#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",Zit="#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",Kit="#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",Jit="#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",Qit="#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",est="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#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )\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,\n\t\t#if defined( USE_NORMALMAP )\n\t\t\tvNormalMapUv\n\t\t#elif defined( USE_CLEARCOAT_NORMALMAP )\n\t\t\tvClearcoatNormalMapUv\n\t\t#else\n\t\t\tvUv\n\t\t#endif\n\t\t);\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;",tst="#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",nst="#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",rst="#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",ist="#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",sst="#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 ) || defined( USE_ANISOTROPY ) )\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",ast="#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal = geometryNormal;\n#endif",ost="#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",lst="#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",cst="#ifdef USE_IRIDESCENCEMAP\n\tuniform sampler2D iridescenceMap;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform sampler2D iridescenceThicknessMap;\n#endif",ust="#ifdef OPAQUE\ndiffuseColor.a = 1.0;\n#endif\n#ifdef USE_TRANSMISSION\ndiffuseColor.a *= material.transmissionAlpha;\n#endif\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );",hst="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}",dst="#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif",fst="vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;",pst="#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif",mst="#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",gst="float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );\n\troughnessFactor *= texelRoughness.g;\n#endif",vst="#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",yst="#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",xst="#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",bst="#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",Est="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}",_st="#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",Tst="#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",wst="#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",Sst="#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",Mst="float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",Ast="#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",Rst="#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif",Cst="#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn saturate( 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; }",Pst="#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 transmitted = 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, transmitted.a, material.transmission );\n\ttotalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );\n#endif",Ist="#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 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tif ( isinf( attenuationDistance ) ) {\n\t\t\treturn vec3( 1.0 );\n\t\t} else {\n\t\t\tvec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;\n\t\t\tvec3 transmittance = exp( - attenuationCoefficient * transmissionDistance );\t\t\treturn transmittance;\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 transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );\n\t\tvec3 attenuatedColor = transmittance * transmittedLight.rgb;\n\t\tvec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );\n\t\tfloat transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;\n\t\treturn vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );\n\t}\n#endif",Lst="#if defined( USE_UV ) || defined( USE_ANISOTROPY )\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_ANISOTROPYMAP\n\tvarying vec2 vAnisotropyMapUv;\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",Dst="#if defined( USE_UV ) || defined( USE_ANISOTROPY )\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_ANISOTROPYMAP\n\tuniform mat3 anisotropyMapTransform;\n\tvarying vec2 vAnisotropyMapUv;\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",Ost="#if defined( USE_UV ) || defined( USE_ANISOTROPY )\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_ANISOTROPYMAP\n\tvAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_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",kst="#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",Fst="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}",Nst="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 <colorspace_fragment>\n}",Bst="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}",Ust="#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 <colorspace_fragment>\n}",Hst="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}",Vst="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 <colorspace_fragment>\n}",zst="#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}",Gst="#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 <alphahash_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 <alphahash_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}",qst="#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}",Wst="#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 <alphahash_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\t#include <alphahash_fragment>\n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}",jst="varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n}",Xst="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 <colorspace_fragment>\n}",Yst="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}",$st="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 <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",Zst="#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}",Kst="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 <alphahash_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 <alphahash_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 <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",Jst="#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}",Qst="#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 <alphahash_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 <alphahash_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 <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",eat="#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}",tat="#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 <alphahash_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 <alphahash_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 <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",nat="#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}",rat="#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}",iat="#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}",sat="#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 <alphahash_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 <alphahash_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 <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",aat="#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}",oat="#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\n#ifdef USE_ANISOTROPY\n\tuniform vec2 anisotropyVector;\n\t#ifdef USE_ANISOTROPYMAP\n\t\tuniform sampler2D anisotropyMap;\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 <alphahash_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 <alphahash_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 <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",lat="#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}",cat="#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 <alphahash_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 <alphahash_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 <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",uat="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}",hat="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 <alphahash_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\t#include <alphahash_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",dat="#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}",fat="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 <colorspace_fragment>\n\t#include <fog_fragment>\n}",pat="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}",mat="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 <alphahash_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\t#include <alphahash_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n}",$n={alphahash_fragment:Urt,alphahash_pars_fragment:Hrt,alphamap_fragment:Vrt,alphamap_pars_fragment:zrt,alphatest_fragment:Grt,alphatest_pars_fragment:qrt,aomap_fragment:Wrt,aomap_pars_fragment:jrt,begin_vertex:Xrt,beginnormal_vertex:Yrt,bsdfs:$rt,iridescence_fragment:Zrt,bumpmap_pars_fragment:Krt,clipping_planes_fragment:Jrt,clipping_planes_pars_fragment:Qrt,clipping_planes_pars_vertex:eit,clipping_planes_vertex:tit,color_fragment:nit,color_pars_fragment:rit,color_pars_vertex:iit,color_vertex:sit,common:ait,cube_uv_reflection_fragment:oit,defaultnormal_vertex:lit,displacementmap_pars_vertex:cit,displacementmap_vertex:uit,emissivemap_fragment:hit,emissivemap_pars_fragment:dit,colorspace_fragment:fit,colorspace_pars_fragment:pit,envmap_fragment:mit,envmap_common_pars_fragment:git,envmap_pars_fragment:vit,envmap_pars_vertex:yit,envmap_physical_pars_fragment:Pit,envmap_vertex:xit,fog_vertex:bit,fog_pars_vertex:Eit,fog_fragment:_it,fog_pars_fragment:Tit,gradientmap_pars_fragment:wit,lightmap_fragment:Sit,lightmap_pars_fragment:Mit,lights_lambert_fragment:Ait,lights_lambert_pars_fragment:Rit,lights_pars_begin:Cit,lights_toon_fragment:Iit,lights_toon_pars_fragment:Lit,lights_phong_fragment:Dit,lights_phong_pars_fragment:Oit,lights_physical_fragment:kit,lights_physical_pars_fragment:Fit,lights_fragment_begin:Nit,lights_fragment_maps:Bit,lights_fragment_end:Uit,logdepthbuf_fragment:Hit,logdepthbuf_pars_fragment:Vit,logdepthbuf_pars_vertex:zit,logdepthbuf_vertex:Git,map_fragment:qit,map_pars_fragment:Wit,map_particle_fragment:jit,map_particle_pars_fragment:Xit,metalnessmap_fragment:Yit,metalnessmap_pars_fragment:$it,morphcolor_vertex:Zit,morphnormal_vertex:Kit,morphtarget_pars_vertex:Jit,morphtarget_vertex:Qit,normal_fragment_begin:est,normal_fragment_maps:tst,normal_pars_fragment:nst,normal_pars_vertex:rst,normal_vertex:ist,normalmap_pars_fragment:sst,clearcoat_normal_fragment_begin:ast,clearcoat_normal_fragment_maps:ost,clearcoat_pars_fragment:lst,iridescence_pars_fragment:cst,opaque_fragment:ust,packing:hst,premultiplied_alpha_fragment:dst,project_vertex:fst,dithering_fragment:pst,dithering_pars_fragment:mst,roughnessmap_fragment:gst,roughnessmap_pars_fragment:vst,shadowmap_pars_fragment:yst,shadowmap_pars_vertex:xst,shadowmap_vertex:bst,shadowmask_pars_fragment:Est,skinbase_vertex:_st,skinning_pars_vertex:Tst,skinning_vertex:wst,skinnormal_vertex:Sst,specularmap_fragment:Mst,specularmap_pars_fragment:Ast,tonemapping_fragment:Rst,tonemapping_pars_fragment:Cst,transmission_fragment:Pst,transmission_pars_fragment:Ist,uv_pars_fragment:Lst,uv_pars_vertex:Dst,uv_vertex:Ost,worldpos_vertex:kst,background_vert:Fst,background_frag:Nst,backgroundCube_vert:Bst,backgroundCube_frag:Ust,cube_vert:Hst,cube_frag:Vst,depth_vert:zst,depth_frag:Gst,distanceRGBA_vert:qst,distanceRGBA_frag:Wst,equirect_vert:jst,equirect_frag:Xst,linedashed_vert:Yst,linedashed_frag:$st,meshbasic_vert:Zst,meshbasic_frag:Kst,meshlambert_vert:Jst,meshlambert_frag:Qst,meshmatcap_vert:eat,meshmatcap_frag:tat,meshnormal_vert:nat,meshnormal_frag:rat,meshphong_vert:iat,meshphong_frag:sat,meshphysical_vert:aat,meshphysical_frag:oat,meshtoon_vert:lat,meshtoon_frag:cat,points_vert:uat,points_frag:hat,shadow_vert:dat,shadow_frag:fat,sprite_vert:pat,sprite_frag:mat},Qt={common:{diffuse:{value:new ct(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new In},alphaMap:{value:null},alphaMapTransform:{value:new In},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new In}},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 In}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new In}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new In},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new In},normalScale:{value:new _e(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new In},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new In}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new In}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new In}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new ct(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 ct(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new In},alphaTest:{value:0},uvTransform:{value:new In}},sprite:{diffuse:{value:new ct(16777215)},opacity:{value:1},center:{value:new _e(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new In},alphaMap:{value:null},alphaMapTransform:{value:new In},alphaTest:{value:0}}},xc={basic:{uniforms:Na([Qt.common,Qt.specularmap,Qt.envmap,Qt.aomap,Qt.lightmap,Qt.fog]),vertexShader:$n.meshbasic_vert,fragmentShader:$n.meshbasic_frag},lambert:{uniforms:Na([Qt.common,Qt.specularmap,Qt.envmap,Qt.aomap,Qt.lightmap,Qt.emissivemap,Qt.bumpmap,Qt.normalmap,Qt.displacementmap,Qt.fog,Qt.lights,{emissive:{value:new ct(0)}}]),vertexShader:$n.meshlambert_vert,fragmentShader:$n.meshlambert_frag},phong:{uniforms:Na([Qt.common,Qt.specularmap,Qt.envmap,Qt.aomap,Qt.lightmap,Qt.emissivemap,Qt.bumpmap,Qt.normalmap,Qt.displacementmap,Qt.fog,Qt.lights,{emissive:{value:new ct(0)},specular:{value:new ct(1118481)},shininess:{value:30}}]),vertexShader:$n.meshphong_vert,fragmentShader:$n.meshphong_frag},standard:{uniforms:Na([Qt.common,Qt.envmap,Qt.aomap,Qt.lightmap,Qt.emissivemap,Qt.bumpmap,Qt.normalmap,Qt.displacementmap,Qt.roughnessmap,Qt.metalnessmap,Qt.fog,Qt.lights,{emissive:{value:new ct(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:$n.meshphysical_vert,fragmentShader:$n.meshphysical_frag},toon:{uniforms:Na([Qt.common,Qt.aomap,Qt.lightmap,Qt.emissivemap,Qt.bumpmap,Qt.normalmap,Qt.displacementmap,Qt.gradientmap,Qt.fog,Qt.lights,{emissive:{value:new ct(0)}}]),vertexShader:$n.meshtoon_vert,fragmentShader:$n.meshtoon_frag},matcap:{uniforms:Na([Qt.common,Qt.bumpmap,Qt.normalmap,Qt.displacementmap,Qt.fog,{matcap:{value:null}}]),vertexShader:$n.meshmatcap_vert,fragmentShader:$n.meshmatcap_frag},points:{uniforms:Na([Qt.points,Qt.fog]),vertexShader:$n.points_vert,fragmentShader:$n.points_frag},dashed:{uniforms:Na([Qt.common,Qt.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:$n.linedashed_vert,fragmentShader:$n.linedashed_frag},depth:{uniforms:Na([Qt.common,Qt.displacementmap]),vertexShader:$n.depth_vert,fragmentShader:$n.depth_frag},normal:{uniforms:Na([Qt.common,Qt.bumpmap,Qt.normalmap,Qt.displacementmap,{opacity:{value:1}}]),vertexShader:$n.meshnormal_vert,fragmentShader:$n.meshnormal_frag},sprite:{uniforms:Na([Qt.sprite,Qt.fog]),vertexShader:$n.sprite_vert,fragmentShader:$n.sprite_frag},background:{uniforms:{uvTransform:{value:new In},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:$n.background_vert,fragmentShader:$n.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:$n.backgroundCube_vert,fragmentShader:$n.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:$n.cube_vert,fragmentShader:$n.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:$n.equirect_vert,fragmentShader:$n.equirect_frag},distanceRGBA:{uniforms:Na([Qt.common,Qt.displacementmap,{referencePosition:{value:new k},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:$n.distanceRGBA_vert,fragmentShader:$n.distanceRGBA_frag},shadow:{uniforms:Na([Qt.lights,Qt.fog,{color:{value:new ct(0)},opacity:{value:1}}]),vertexShader:$n.shadow_vert,fragmentShader:$n.shadow_frag}};xc.physical={uniforms:Na([xc.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new In},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new In},clearcoatNormalScale:{value:new _e(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new In},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new In},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new In},sheen:{value:0},sheenColor:{value:new ct(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new In},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new In},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new In},transmissionSamplerSize:{value:new _e},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new In},attenuationDistance:{value:0},attenuationColor:{value:new ct(0)},specularColor:{value:new ct(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new In},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new In},anisotropyVector:{value:new _e},anisotropyMap:{value:null},anisotropyMapTransform:{value:new In}}]),vertexShader:$n.meshphysical_vert,fragmentShader:$n.meshphysical_frag};var MM={r:0,b:0,g:0};function gat(e,t,n,i,r,a,s){let o,l,h=new ct(0),u=!0===a?0:1,c=null,d=0,p=null;function f(t,n){t.getRGB(MM,Uhe(e)),i.buffers.color.setClear(MM.r,MM.g,MM.b,n,s)}return{getClearColor:function(){return h},setClearColor:function(e,t=1){h.set(e),u=t,f(h,u)},getClearAlpha:function(){return u},setClearAlpha:function(e){u=e,f(h,u)},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,u):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===pv)?(void 0===l&&(l=new St(new ma(1,1,1),new hn({name:"BackgroundCubeMaterial",uniforms:Z0(xc.backgroundCube.uniforms),vertexShader:xc.backgroundCube.vertexShader,fragmentShader:xc.backgroundCube.fragmentShader,side:Ki,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!==sn,(c!==v||d!==v.version||p!==e.toneMapping)&&(l.material.needsUpdate=!0,c=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 St(new mi(2,2),new hn({name:"BackgroundMaterial",uniforms:Z0(xc.background.uniforms),vertexShader:xc.background.vertexShader,fragmentShader:xc.background.fragmentShader,side:hi,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!==sn,!0===v.matrixAutoUpdate&&v.updateMatrix(),o.material.uniforms.uvTransform.value.copy(v.matrix),(c!==v||d!==v.version||p!==e.toneMapping)&&(o.material.needsUpdate=!0,c=v,d=v.version,p=e.toneMapping),o.layers.enableAll(),a.unshift(o,o.geometry,o.material,0,0,null))}}}function vat(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,u=!1;function c(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,i,r,a,s,o){!0===o?e.vertexAttribIPointer(t,n,i,a,s):e.vertexAttribPointer(t,n,i,r,a,s)}function x(){b(),u=!0,h!==l&&(h=l,c(h.object))}function b(){l.geometry=null,l.program=null,l.wireframe=!1}return{setup:function(r,l,d,x,b){let _=!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 u=h[s];return void 0===u&&(u=p(i.isWebGL2?e.createVertexArray():a.createVertexArrayOES()),h[s]=u),u}(x,d,l);h!==t&&(h=t,c(h.object)),_=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,b)}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,_=!0)}null!==b&&n.update(b,e.ELEMENT_ARRAY_BUFFER),(_||u)&&(u=!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(),u=a.defaultAttributeValues;for(let t in h){let a=h[t];if(a.location>=0){let s=l[t];if(void 0===s&&("instanceMatrix"===t&&r.instanceMatrix&&(s=r.instanceMatrix),"instanceColor"===t&&r.instanceColor&&(s=r.instanceColor)),void 0!==s){let t=s.normalized,l=s.itemSize,h=n.get(s);if(void 0===h)continue;let u=h.buffer,c=h.type,d=h.bytesPerElement,p=!0===i.isWebGL2&&(c===e.INT||c===e.UNSIGNED_INT||s.gpuType===_U);if(s.isInterleavedBufferAttribute){let n=s.data,i=n.stride,h=s.offset;if(n.isInstancedInterleavedBuffer){for(let e=0;e<a.locationSize;e++)g(a.location+e,n.meshPerAttribute);!0!==r.isInstancedMesh&&void 0===o._maxInstanceCount&&(o._maxInstanceCount=n.meshPerAttribute*n.count)}else for(let e=0;e<a.locationSize;e++)m(a.location+e);e.bindBuffer(e.ARRAY_BUFFER,u);for(let e=0;e<a.locationSize;e++)y(a.location+e,l/a.locationSize,c,t,i*d,(h+l/a.locationSize*e)*d,p)}else{if(s.isInstancedBufferAttribute){for(let e=0;e<a.locationSize;e++)g(a.location+e,s.meshPerAttribute);!0!==r.isInstancedMesh&&void 0===o._maxInstanceCount&&(o._maxInstanceCount=s.meshPerAttribute*s.count)}else for(let e=0;e<a.locationSize;e++)m(a.location+e);e.bindBuffer(e.ARRAY_BUFFER,u);for(let e=0;e<a.locationSize;e++)y(a.location+e,l/a.locationSize,c,t,l*d,l/a.locationSize*e*d,p)}}else if(void 0!==u){let n=u[t];if(void 0!==n)switch(n.length){case 2:e.vertexAttrib2fv(a.location,n);break;case 3:e.vertexAttrib3fv(a.location,n);break;case 4:e.vertexAttrib4fv(a.location,n);break;default:e.vertexAttrib1fv(a.location,n)}}}}v()}(r,l,d,x),null!==b&&e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,n.get(b).buffer))},reset:x,resetDefaultState:b,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 yat(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 xat(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,u=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),c=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=c>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:u,maxVertexTextures:c,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 bat(e){let t=this,n=null,i=0,r=!1,a=!1,s=new Ur,o=new In,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,u){let c=s.clippingPlanes,d=s.clipIntersection,p=s.clipShadows,f=e.get(s);if(!r||null===c||0===c.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(c,o,t,u);for(let i=0;i!==t;++i)r[i]=n[i];f.clippingState=r,this.numIntersection=d?this.numPlanes:0,this.numPlanes+=e}}}function Eat(e){let t=new WeakMap;function n(e,t){return t===om?e.mapping=kh:t===Wx&&(e.mapping=Zd),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===om||a===Wx){if(t.has(r))return n(t.get(r).texture,r.mapping);{let a=r.image;if(a&&a.height>0){let s=new oA(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 xi=class extends Uh{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.coordinateSystem),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}},q0=4,kce=[.125,.215,.35,.446,.526,.582],tm=20,MN=new xi,Fce=new ct,AN=null,em=(1+Math.sqrt(5))/2,F0=1/em,Nce=[new k(1,1,1),new k(-1,1,1),new k(1,1,-1),new k(-1,1,-1),new k(0,em,F0),new k(0,em,-F0),new k(F0,0,em),new k(-F0,0,em),new k(em,F0,0),new k(-em,F0,0)],Hh=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){AN=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=Hce(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=Uce(),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(AN),e.scissorTest=!1,AM(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===kh||e.mapping===Zd?this._setSize(0===e.image.length?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),AN=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:Xr,minFilter:Xr,generateMipmaps:!1,type:Tr,format:ea,colorSpace:Ua,depthBuffer:!1},i=Bce(e,t,n);if(null===this._pingPongRenderTarget||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){null!==this._pingPongRenderTarget&&this._dispose(),this._pingPongRenderTarget=Bce(e,t,n);let{_lodMax:i}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=_at(i)),this._blurMaterial=Tat(i,e,t)}return i}_compileMaterial(e){let t=new St(this._lodPlanes[0],e);this._renderer.compile(t,MN)}_sceneToCubeUV(e,t,n,i){let r=new Yr(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(Fce),o.toneMapping=Dh,o.autoClear=!1;let u=new cn({name:"PMREM.Background",side:Ki,depthWrite:!1,depthTest:!1}),c=new St(new ma,u),d=!1,p=e.background;p?p.isColor&&(u.color.copy(p),e.background=null,d=!0):(u.color.copy(Fce),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;AM(i,t*n,f>2?n:0,n,n),o.setRenderTarget(i),d&&o.render(c,r),o.render(e,r)}c.geometry.dispose(),c.material.dispose(),o.toneMapping=h,o.autoClear=l,e.background=p}_textureToCubeUV(e,t){let n=this._renderer,i=e.mapping===kh||e.mapping===Zd;i?(null===this._cubemapMaterial&&(this._cubemapMaterial=Hce()),this._cubemapMaterial.uniforms.flipEnvMap.value=!1===e.isRenderTargetTexture?-1:1):null===this._equirectMaterial&&(this._equirectMaterial=Uce());let r=i?this._cubemapMaterial:this._equirectMaterial,a=new St(this._lodPlanes[0],r);r.uniforms.envMap.value=e;let s=this._cubeSize;AM(t,0,0,3*s,2*s),n.setRenderTarget(t),n.render(a,MN)}_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=Nce[(i-1)%Nce.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 St(this._lodPlanes[i],l),u=l.uniforms,c=this._sizeLods[n]-1,d=isFinite(r)?Math.PI/(2*c):2*Math.PI/(2*tm-1),p=r/d,f=isFinite(r)?1+Math.floor(3*p):tm;f>tm&&console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${f} samples when the maximum is set to ${tm}`);let m=[],g=0;for(let x=0;x<tm;++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;u.envMap.value=e.texture,u.samples.value=f,u.weights.value=m,u.latitudinal.value="latitudinal"===a,s&&(u.poleAxis.value=s);let{_lodMax:v}=this;u.dTheta.value=d,u.mipInt.value=v-n;let y=this._sizeLods[i];AM(t,3*y*(i>v-q0?i-v+q0:0),4*(this._cubeSize-y),3*y,2*y),o.setRenderTarget(t),o.render(h,MN)}};function _at(e){let t=[],n=[],i=[],r=e,a=e-q0+1+kce.length;for(let s=0;s<a;s++){let a=Math.pow(2,r);n.push(a);let o=1/a;s>e-q0?o=kce[s-e+q0-1]:0===s&&(o=0),i.push(o);let l=1/(a-2),h=-l,u=1+l,c=[h,h,u,h,u,u,h,h,u,u,h,u],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(c,m*p*e);let r=[e,e,e,e,e,e];x.set(r,g*p*e)}let b=new Ot;b.setAttribute("position",new yn(v,f)),b.setAttribute("uv",new yn(y,m)),b.setAttribute("faceIndex",new yn(x,g)),t.push(b),r>q0&&r--}return{lodPlanes:t,sizeLods:n,sigmas:i}}function Bce(e,t,n){let i=new er(e,t,n);return i.texture.mapping=pv,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function AM(e,t,n,i,r){e.viewport.set(t,n,i,r),e.scissor.set(t,n,i,r)}function Tat(e,t,n){let i=new Float32Array(tm),r=new k(0,1,0);return new hn({name:"SphericalGaussianBlur",defines:{n:tm,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:DU(),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:Qr,depthTest:!1,depthWrite:!1})}function Uce(){return new hn({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:DU(),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:Qr,depthTest:!1,depthWrite:!1})}function Hce(){return new hn({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:DU(),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:Qr,depthTest:!1,depthWrite:!1})}function DU(){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 wat(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===om||a===Wx,o=a===kh||a===Zd;if(s||o){if(r.isRenderTargetTexture&&!0===r.needsPMREMUpdate){r.needsPMREMUpdate=!1;let i=t.get(r);return null===n&&(n=new Hh(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 Hh(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 Sat(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 Mat(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]);for(let n in o.morphAttributes){let e=o.morphAttributes[n];for(let n=0,i=e.length;n<i;n++)t.remove(e[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{if(void 0===r)return;{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(Nhe(n)?Qx:lm)(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 Aat(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 u,c;if(o)u=e,c="drawElementsInstanced";else if(u=t.get("ANGLE_instanced_arrays"),c="drawElementsInstancedANGLE",null===u)return void console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");u[c](r,l,a,i*s,h),n.update(l,r,h)}}function Rat(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.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 Cat(e,t){return e[0]-t[0]}function Pat(e,t){return Math.abs(t[1])-Math.abs(e[1])}function Iat(e,t,n){let i={},r=new Float32Array(8),a=new WeakMap,s=new mr,o=[];for(let l=0;l<8;l++)o[l]=[l,0];return{update:function(l,h,u){let c=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,u=h.morphAttributes.position||[],c=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 $0(g,f,m,r);v.type=pa,v.needsUpdate=!0;let y=4*p;for(let t=0;t<r;t++){let e=u[t],r=c[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 _e(f,m)},a.set(h,o),h.addEventListener("dispose",e)}let l=0;for(let e=0;e<c.length;e++)l+=c[e];let d=h.morphTargetsRelative?1:1-l;u.getUniforms().setValue(e,"morphTargetBaseInfluence",d),u.getUniforms().setValue(e,"morphTargetInfluences",c),u.getUniforms().setValue(e,"morphTargetsTexture",o.texture,n),u.getUniforms().setValue(e,"morphTargetsTextureSize",o.size)}else{let t=void 0===c?0:c.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]=c[e]}n.sort(Pat);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(Cat);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;u.getUniforms().setValue(e,"morphTargetBaseInfluence",d),u.getUniforms().setValue(e,"morphTargetInfluences",r)}}}}function Lat(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);if(r.get(h)!==o&&(t.update(h),r.set(h,o)),s.isInstancedMesh&&(!1===s.hasEventListener("dispose",a)&&s.addEventListener("dispose",a),r.get(s)!==o&&(n.update(s.instanceMatrix,e.ARRAY_BUFFER),null!==s.instanceColor&&n.update(s.instanceColor,e.ARRAY_BUFFER),r.set(s,o))),s.isSkinnedMesh){let e=s.skeleton;r.get(e)!==o&&(e.update(),r.set(e,o))}return h},dispose:function(){r=new WeakMap}}}var Vhe=new Hr,zhe=new $0,Ghe=new Kx,qhe=new cm,Vce=[],zce=[],Gce=new Float32Array(16),qce=new Float32Array(9),Wce=new Float32Array(4);function xv(e,t,n){let i=e[0];if(i<=0||i>0)return e;let r=t*n,a=Vce[r];if(void 0===a&&(a=new Float32Array(r),Vce[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 Ls(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 Ds(e,t){for(let n=0,i=t.length;n<i;n++)e[n]=t[n]}function NA(e,t){let n=zce[t];void 0===n&&(n=new Int32Array(t),zce[t]=n);for(let i=0;i!==t;++i)n[i]=e.allocateTextureUnit();return n}function Dat(e,t){let n=this.cache;n[0]!==t&&(e.uniform1f(this.addr,t),n[0]=t)}function Oat(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(Ls(n,t))return;e.uniform2fv(this.addr,t),Ds(n,t)}}function kat(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(Ls(n,t))return;e.uniform3fv(this.addr,t),Ds(n,t)}}function Fat(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(Ls(n,t))return;e.uniform4fv(this.addr,t),Ds(n,t)}}function Nat(e,t){let n=this.cache,i=t.elements;if(void 0===i){if(Ls(n,t))return;e.uniformMatrix2fv(this.addr,!1,t),Ds(n,t)}else{if(Ls(n,i))return;Wce.set(i),e.uniformMatrix2fv(this.addr,!1,Wce),Ds(n,i)}}function Bat(e,t){let n=this.cache,i=t.elements;if(void 0===i){if(Ls(n,t))return;e.uniformMatrix3fv(this.addr,!1,t),Ds(n,t)}else{if(Ls(n,i))return;qce.set(i),e.uniformMatrix3fv(this.addr,!1,qce),Ds(n,i)}}function Uat(e,t){let n=this.cache,i=t.elements;if(void 0===i){if(Ls(n,t))return;e.uniformMatrix4fv(this.addr,!1,t),Ds(n,t)}else{if(Ls(n,i))return;Gce.set(i),e.uniformMatrix4fv(this.addr,!1,Gce),Ds(n,i)}}function Hat(e,t){let n=this.cache;n[0]!==t&&(e.uniform1i(this.addr,t),n[0]=t)}function Vat(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(Ls(n,t))return;e.uniform2iv(this.addr,t),Ds(n,t)}}function zat(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(Ls(n,t))return;e.uniform3iv(this.addr,t),Ds(n,t)}}function Gat(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(Ls(n,t))return;e.uniform4iv(this.addr,t),Ds(n,t)}}function qat(e,t){let n=this.cache;n[0]!==t&&(e.uniform1ui(this.addr,t),n[0]=t)}function Wat(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(Ls(n,t))return;e.uniform2uiv(this.addr,t),Ds(n,t)}}function jat(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(Ls(n,t))return;e.uniform3uiv(this.addr,t),Ds(n,t)}}function Xat(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(Ls(n,t))return;e.uniform4uiv(this.addr,t),Ds(n,t)}}function Yat(e,t,n){let i=this.cache,r=n.allocateTextureUnit();i[0]!==r&&(e.uniform1i(this.addr,r),i[0]=r),n.setTexture2D(t||Vhe,r)}function $at(e,t,n){let i=this.cache,r=n.allocateTextureUnit();i[0]!==r&&(e.uniform1i(this.addr,r),i[0]=r),n.setTexture3D(t||Ghe,r)}function Zat(e,t,n){let i=this.cache,r=n.allocateTextureUnit();i[0]!==r&&(e.uniform1i(this.addr,r),i[0]=r),n.setTextureCube(t||qhe,r)}function Kat(e,t,n){let i=this.cache,r=n.allocateTextureUnit();i[0]!==r&&(e.uniform1i(this.addr,r),i[0]=r),n.setTexture2DArray(t||zhe,r)}function Jat(e){switch(e){case 5126:return Dat;case 35664:return Oat;case 35665:return kat;case 35666:return Fat;case 35674:return Nat;case 35675:return Bat;case 35676:return Uat;case 5124:case 35670:return Hat;case 35667:case 35671:return Vat;case 35668:case 35672:return zat;case 35669:case 35673:return Gat;case 5125:return qat;case 36294:return Wat;case 36295:return jat;case 36296:return Xat;case 35678:case 36198:case 36298:case 36306:case 35682:return Yat;case 35679:case 36299:case 36307:return $at;case 35680:case 36300:case 36308:case 36293:return Zat;case 36289:case 36303:case 36311:case 36292:return Kat}}function Qat(e,t){e.uniform1fv(this.addr,t)}function eot(e,t){let n=xv(t,this.size,2);e.uniform2fv(this.addr,n)}function tot(e,t){let n=xv(t,this.size,3);e.uniform3fv(this.addr,n)}function not(e,t){let n=xv(t,this.size,4);e.uniform4fv(this.addr,n)}function rot(e,t){let n=xv(t,this.size,4);e.uniformMatrix2fv(this.addr,!1,n)}function iot(e,t){let n=xv(t,this.size,9);e.uniformMatrix3fv(this.addr,!1,n)}function sot(e,t){let n=xv(t,this.size,16);e.uniformMatrix4fv(this.addr,!1,n)}function aot(e,t){e.uniform1iv(this.addr,t)}function oot(e,t){e.uniform2iv(this.addr,t)}function lot(e,t){e.uniform3iv(this.addr,t)}function cot(e,t){e.uniform4iv(this.addr,t)}function uot(e,t){e.uniform1uiv(this.addr,t)}function hot(e,t){e.uniform2uiv(this.addr,t)}function dot(e,t){e.uniform3uiv(this.addr,t)}function fot(e,t){e.uniform4uiv(this.addr,t)}function pot(e,t,n){let i=this.cache,r=t.length,a=NA(n,r);Ls(i,a)||(e.uniform1iv(this.addr,a),Ds(i,a));for(let s=0;s!==r;++s)n.setTexture2D(t[s]||Vhe,a[s])}function mot(e,t,n){let i=this.cache,r=t.length,a=NA(n,r);Ls(i,a)||(e.uniform1iv(this.addr,a),Ds(i,a));for(let s=0;s!==r;++s)n.setTexture3D(t[s]||Ghe,a[s])}function got(e,t,n){let i=this.cache,r=t.length,a=NA(n,r);Ls(i,a)||(e.uniform1iv(this.addr,a),Ds(i,a));for(let s=0;s!==r;++s)n.setTextureCube(t[s]||qhe,a[s])}function vot(e,t,n){let i=this.cache,r=t.length,a=NA(n,r);Ls(i,a)||(e.uniform1iv(this.addr,a),Ds(i,a));for(let s=0;s!==r;++s)n.setTexture2DArray(t[s]||zhe,a[s])}function yot(e){switch(e){case 5126:return Qat;case 35664:return eot;case 35665:return tot;case 35666:return not;case 35674:return rot;case 35675:return iot;case 35676:return sot;case 5124:case 35670:return aot;case 35667:case 35671:return oot;case 35668:case 35672:return lot;case 35669:case 35673:return cot;case 5125:return uot;case 36294:return hot;case 36295:return dot;case 36296:return fot;case 35678:case 36198:case 36298:case 36306:case 35682:return pot;case 35679:case 36299:case 36307:return mot;case 35680:case 36300:case 36308:case 36293:return got;case 36289:case 36303:case 36311:case 36292:return vot}}var MB=class{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.setValue=Jat(t.type)}},AB=class{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.size=t.size,this.setValue=yot(t.type)}},RB=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)}}},RN=/(\w+)(\])?(\[|\.)?/g;function jce(e,t){e.seq.push(t),e.map[t.id]=t}function xot(e,t,n){let i=e.name,r=i.length;for(RN.lastIndex=0;;){let a=RN.exec(i),s=RN.lastIndex,o=a[1],l="]"===a[2],h=a[3];if(l&&(o|=0),void 0===h||"["===h&&s+2===r){jce(n,void 0===h?new MB(o,e,t):new AB(o,e,t));break}{let e=n.map[o];void 0===e&&(e=new RB(o),jce(n,e)),n=e}}}var X0=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);xot(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 Xce(e,t,n){let i=e.createShader(t);return e.shaderSource(i,n),e.compileShader(i),i}var bot=0;function Eot(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 _ot(e){switch(e){case Ua:return["Linear","( value )"];case sn:return["sRGB","( value )"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",e),["Linear","( value )"]}}function Yce(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"+Eot(e.getShaderSource(t),i)}return r}function Tot(e,t){let n=_ot(t);return"vec4 "+e+"( vec4 value ) { return LinearTo"+n[0]+n[1]+"; }"}function wot(e,t){let n;switch(t){case uhe:n="Linear";break;case hhe:n="Reinhard";break;case dhe:n="OptimizedCineon";break;case fhe:n="ACESFilmic";break;case phe:n="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",t),n="Linear"}return"vec3 "+e+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}function Sot(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(Ux).join("\n")}function Mot(e){let t=[];for(let n in e){let i=e[n];!1!==i&&t.push("#define "+n+" "+i)}return t.join("\n")}function Aot(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 Ux(e){return""!==e}function $ce(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 Zce(e,t){return e.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}var Rot=/^[ \t]*#include +<([\w\d./]+)>/gm;function CB(e){return e.replace(Rot,Pot)}var Cot=new Map([["encodings_fragment","colorspace_fragment"],["encodings_pars_fragment","colorspace_pars_fragment"],["output_fragment","opaque_fragment"]]);function Pot(e,t){let n=$n[t];if(void 0===n){let e=Cot.get(t);if(void 0===e)throw new Error("Can not resolve #include <"+t+">");n=$n[e],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,e)}return CB(n)}var Iot=/#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 Kce(e){return e.replace(Iot,Lot)}function Lot(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 Jce(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 Dot(e){let t="SHADOWMAP_TYPE_BASIC";return e.shadowMapType===xU?t="SHADOWMAP_TYPE_PCF":e.shadowMapType===hv?t="SHADOWMAP_TYPE_PCF_SOFT":e.shadowMapType===gu&&(t="SHADOWMAP_TYPE_VSM"),t}function Oot(e){let t="ENVMAP_TYPE_CUBE";if(e.envMap)switch(e.envMapMode){case kh:case Zd:t="ENVMAP_TYPE_CUBE";break;case pv:t="ENVMAP_TYPE_CUBE_UV"}return t}function kot(e){let t="ENVMAP_MODE_REFLECTION";return e.envMap&&e.envMapMode===Zd&&(t="ENVMAP_MODE_REFRACTION"),t}function Fot(e){let t="ENVMAP_BLENDING_NONE";if(e.envMap)switch(e.combine){case yb:t="ENVMAP_BLENDING_MULTIPLY";break;case lhe:t="ENVMAP_BLENDING_MIX";break;case che:t="ENVMAP_BLENDING_ADD"}return t}function Not(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 Bot(e,t,n,i){let r,a,s=e.getContext(),o=n.defines,l=n.vertexShader,h=n.fragmentShader,u=Dot(n),c=Oot(n),d=kot(n),p=Fot(n),f=Not(n),m=n.isWebGL2?"":Sot(n),g=Mot(o),v=s.createProgram(),y=n.glslVersion?"#version "+n.glslVersion+"\n":"";n.isRawShaderMaterial?(r=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,g].filter(Ux).join("\n"),r.length>0&&(r+="\n"),a=[m,"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,g].filter(Ux).join("\n"),a.length>0&&(a+="\n")):(r=[Jce(n),"#define SHADER_TYPE "+n.shaderType,"#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.anisotropyMap?"#define USE_ANISOTROPYMAP":"",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.alphaHash?"#define USE_ALPHAHASH":"",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.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",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&&!1===n.flatShading?"#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 "+u:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.useLegacyLights?"#define LEGACY_LIGHTS":"",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(Ux).join("\n"),a=[m,Jce(n),"#define SHADER_TYPE "+n.shaderType,"#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 "+c:"",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.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",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.alphaHash?"#define USE_ALPHAHASH":"",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&&!1===n.flatShading?"#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 "+u:"",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!==Dh?"#define TONE_MAPPING":"",n.toneMapping!==Dh?$n.tonemapping_pars_fragment:"",n.toneMapping!==Dh?wot("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",$n.colorspace_pars_fragment,Tot("linearToOutputTexel",n.outputColorSpace),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"","\n"].filter(Ux).join("\n")),l=CB(l),l=$ce(l,n),l=Zce(l,n),h=CB(h),h=$ce(h,n),h=Zce(h,n),l=Kce(l),h=Kce(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===mB?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===mB?"":"#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,w=y+a+h,S=Xce(s,s.VERTEX_SHADER,_),M=Xce(s,s.FRAGMENT_SHADER,w);if(s.attachShader(v,S),s.attachShader(v,M),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(S).trim(),i=s.getShaderInfoLog(M).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,S,M);else{let e=Yce(s,S,"vertex"),n=Yce(s,M,"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(S),s.deleteShader(M),this.getUniforms=function(){return void 0===x&&(x=new X0(s,v)),x},this.getAttributes=function(){return void 0===b&&(b=Aot(s,v)),b},this.destroy=function(){i.releaseStatesOfProgram(this),s.deleteProgram(v),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=bot++,this.cacheKey=t,this.usedTimes=1,this.program=v,this.vertexShader=S,this.fragmentShader=M,this}var Uot=0,PB=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 IB(e),t.set(e,n)),n}},IB=class{constructor(e){this.id=Uot++,this.code=e,this.usedTimes=0}};function Hot(e,t,n,i,r,a,s){let o=new Jd,l=new PB,h=[],u=r.isWebGL2,c=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 0===e?"uv":`uv${e}`}return{getParameters:function(a,o,h,g,v){let y=g.fog,x=v.geometry,b=a.isMeshStandardMaterial?g.environment:null,_=(a.isMeshStandardMaterial?n:t).get(a.envMap||b),w=_&&_.mapping===pv?_.image.height:null,S=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 M,E,T,A,C=x.morphAttributes.position||x.morphAttributes.normal||x.morphAttributes.color,P=void 0!==C?C.length:0,R=0;if(void 0!==x.morphAttributes.position&&(R=1),void 0!==x.morphAttributes.normal&&(R=2),void 0!==x.morphAttributes.color&&(R=3),S){let e=xc[S];M=e.vertexShader,E=e.fragmentShader}else M=a.vertexShader,E=a.fragmentShader,l.update(a),T=l.getVertexShaderID(a),A=l.getFragmentShaderID(a);let L=e.getRenderTarget(),I=!0===v.isInstancedMesh,k=!!a.map,O=!!a.matcap,D=!!_,N=!!a.aoMap,U=!!a.lightMap,F=!!a.bumpMap,B=!!a.normalMap,z=!!a.displacementMap,H=!!a.emissiveMap,V=!!a.metalnessMap,j=!!a.roughnessMap,G=a.anisotropy>0,W=a.clearcoat>0,X=a.iridescence>0,Y=a.sheen>0,q=a.transmission>0,J=G&&!!a.anisotropyMap,Z=W&&!!a.clearcoatMap,K=W&&!!a.clearcoatNormalMap,$=W&&!!a.clearcoatRoughnessMap,Q=X&&!!a.iridescenceMap,ee=X&&!!a.iridescenceThicknessMap,te=Y&&!!a.sheenColorMap,ne=Y&&!!a.sheenRoughnessMap,ie=!!a.specularMap,re=!!a.specularColorMap,ae=!!a.specularIntensityMap,se=q&&!!a.transmissionMap,oe=q&&!!a.thicknessMap,le=!!a.gradientMap,he=!!a.alphaMap,ue=a.alphaTest>0,ce=!!a.alphaHash,de=!!a.extensions,pe=!!x.attributes.uv1,fe=!!x.attributes.uv2,me=!!x.attributes.uv3,ge=Dh;return a.toneMapped&&(null===L||!0===L.isXRRenderTarget)&&(ge=e.toneMapping),{isWebGL2:u,shaderID:S,shaderType:a.type,shaderName:a.name,vertexShader:M,fragmentShader:E,defines:a.defines,customVertexShaderID:T,customFragmentShaderID:A,isRawShaderMaterial:!0===a.isRawShaderMaterial,glslVersion:a.glslVersion,precision:p,instancing:I,instancingColor:I&&null!==v.instanceColor,supportsVertexTextures:d,outputColorSpace:null===L?e.outputColorSpace:!0===L.isXRRenderTarget?L.texture.colorSpace:Ua,map:k,matcap:O,envMap:D,envMapMode:D&&_.mapping,envMapCubeUVHeight:w,aoMap:N,lightMap:U,bumpMap:F,normalMap:B,displacementMap:d&&z,emissiveMap:H,normalMapObjectSpace:B&&a.normalMapType===Mhe,normalMapTangentSpace:B&&a.normalMapType===sf,metalnessMap:V,roughnessMap:j,anisotropy:G,anisotropyMap:J,clearcoat:W,clearcoatMap:Z,clearcoatNormalMap:K,clearcoatRoughnessMap:$,iridescence:X,iridescenceMap:Q,iridescenceThicknessMap:ee,sheen:Y,sheenColorMap:te,sheenRoughnessMap:ne,specularMap:ie,specularColorMap:re,specularIntensityMap:ae,transmission:q,transmissionMap:se,thicknessMap:oe,gradientMap:le,opaque:!1===a.transparent&&a.blending===sm,alphaMap:he,alphaTest:ue,alphaHash:ce,combine:a.combine,mapUv:k&&m(a.map.channel),aoMapUv:N&&m(a.aoMap.channel),lightMapUv:U&&m(a.lightMap.channel),bumpMapUv:F&&m(a.bumpMap.channel),normalMapUv:B&&m(a.normalMap.channel),displacementMapUv:z&&m(a.displacementMap.channel),emissiveMapUv:H&&m(a.emissiveMap.channel),metalnessMapUv:V&&m(a.metalnessMap.channel),roughnessMapUv:j&&m(a.roughnessMap.channel),anisotropyMapUv:J&&m(a.anisotropyMap.channel),clearcoatMapUv:Z&&m(a.clearcoatMap.channel),clearcoatNormalMapUv:K&&m(a.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:$&&m(a.clearcoatRoughnessMap.channel),iridescenceMapUv:Q&&m(a.iridescenceMap.channel),iridescenceThicknessMapUv:ee&&m(a.iridescenceThicknessMap.channel),sheenColorMapUv:te&&m(a.sheenColorMap.channel),sheenRoughnessMapUv:ne&&m(a.sheenRoughnessMap.channel),specularMapUv:ie&&m(a.specularMap.channel),specularColorMapUv:re&&m(a.specularColorMap.channel),specularIntensityMapUv:ae&&m(a.specularIntensityMap.channel),transmissionMapUv:se&&m(a.transmissionMap.channel),thicknessMapUv:oe&&m(a.thicknessMap.channel),alphaMapUv:he&&m(a.alphaMap.channel),vertexTangents:!!x.attributes.tangent&&(B||G),vertexColors:a.vertexColors,vertexAlphas:!0===a.vertexColors&&!!x.attributes.color&&4===x.attributes.color.itemSize,vertexUv1s:pe,vertexUv2s:fe,vertexUv3s:me,pointsUvs:!0===v.isPoints&&!!x.attributes.uv&&(k||he),fog:!!y,useFog:!0===a.fog,fogExp2:y&&y.isFogExp2,flatShading:!0===a.flatShading,sizeAttenuation:!0===a.sizeAttenuation,logarithmicDepthBuffer:c,skinning:!0===v.isSkinnedMesh,morphTargets:void 0!==x.morphAttributes.position,morphNormals:void 0!==x.morphAttributes.normal,morphColors:void 0!==x.morphAttributes.color,morphTargetsCount:P,morphTextureStride:R,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:ge,useLegacyLights:e._useLegacyLights,premultipliedAlpha:a.premultipliedAlpha,doubleSided:a.side===hr,flipSided:a.side===Ki,useDepthPacking:a.depthPacking>=0,depthPacking:a.depthPacking||0,index0AttributeName:a.index0AttributeName,extensionDerivatives:de&&!0===a.extensions.derivatives,extensionFragDepth:de&&!0===a.extensions.fragDepth,extensionDrawBuffers:de&&!0===a.extensions.drawBuffers,extensionShaderTextureLOD:de&&!0===a.extensions.shaderTextureLOD,rendererExtensionFragDepth:u||i.has("EXT_frag_depth"),rendererExtensionDrawBuffers:u||i.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:u||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.anisotropyMapUv),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),t.anisotropy&&o.enable(17),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=xc[n];t=Ti.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 Bot(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 Vot(){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 zot(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 Qce(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 eue(){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 u=a(e,t,s,o,l,h);s.transmission>0?i.push(u):!0===s.transparent?r.push(u):n.push(u)},unshift:function(e,t,s,o,l,h){let u=a(e,t,s,o,l,h);s.transmission>0?i.unshift(u):!0===s.transparent?r.unshift(u):n.unshift(u)},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||zot),i.length>1&&i.sort(t||Qce),r.length>1&&r.sort(t||Qce)}}}function Got(){let e=new WeakMap;return{get:function(t,n){let i,r=e.get(t);return void 0===r?(i=new eue,e.set(t,[i])):n>=r.length?(i=new eue,r.push(i)):i=r[n],i},dispose:function(){e=new WeakMap}}}function qot(){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 k,color:new ct};break;case"SpotLight":n={position:new k,direction:new k,color:new ct,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new k,color:new ct,distance:0,decay:0};break;case"HemisphereLight":n={direction:new k,skyColor:new ct,groundColor:new ct};break;case"RectAreaLight":n={color:new ct,position:new k,halfWidth:new k,halfHeight:new k}}return e[t.id]=n,n}}}function Wot(){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 _e};break;case"PointLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new _e,shadowCameraNear:1,shadowCameraFar:1e3}}return e[t.id]=n,n}}}var jot=0;function Xot(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+(t.map?1:0)-(e.map?1:0)}function Yot(e,t){let n=new qot,i=Wot(),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 k);let a=new k,s=new ht,o=new ht;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 u=0,c=0,d=0,p=0,f=0,m=0,g=0,v=0,y=0,x=0;a.sort(Xot);let b=!0===s?Math.PI:1;for(let e=0,t=a.length;e<t;e++){let t=a[e],s=t.color,_=t.intensity,w=t.distance,S=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],_);else if(t.isDirectionalLight){let e=n.get(t);if(e.color.copy(t.color).multiplyScalar(t.intensity*b),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[u]=n,r.directionalShadowMap[u]=S,r.directionalShadowMatrix[u]=t.shadow.matrix,m++}r.directional[u]=e,u++}else if(t.isSpotLight){let e=n.get(t);e.position.setFromMatrixPosition(t.matrixWorld),e.color.copy(s).multiplyScalar(_*b),e.distance=w,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]=S,v++}d++}else if(t.isRectAreaLight){let e=n.get(t);e.color.copy(s).multiplyScalar(_),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*b),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[c]=n,r.pointShadowMap[c]=S,r.pointShadowMatrix[c]=t.shadow.matrix,g++}r.point[c]=e,c++}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=Qt.LTC_FLOAT_1,r.rectAreaLTC2=Qt.LTC_FLOAT_2):!0===e.has("OES_texture_half_float_linear")?(r.rectAreaLTC1=Qt.LTC_HALF_1,r.rectAreaLTC2=Qt.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 _=r.hash;(_.directionalLength!==u||_.pointLength!==c||_.spotLength!==d||_.rectAreaLength!==p||_.hemiLength!==f||_.numDirectionalShadows!==m||_.numPointShadows!==g||_.numSpotShadows!==v||_.numSpotMaps!==y)&&(r.directional.length=u,r.spot.length=d,r.rectArea.length=p,r.point.length=c,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,_.directionalLength=u,_.pointLength=c,_.spotLength=d,_.rectAreaLength=p,_.hemiLength=f,_.numDirectionalShadows=m,_.numPointShadows=g,_.numSpotShadows=v,_.numSpotMaps=y,r.version=jot++)},setupView:function(e,t){let n=0,i=0,l=0,h=0,u=0,c=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(c),n++}else if(t.isSpotLight){let e=r.spot[l];e.position.setFromMatrixPosition(t.matrixWorld),e.position.applyMatrix4(c),e.direction.setFromMatrixPosition(t.matrixWorld),a.setFromMatrixPosition(t.target.matrixWorld),e.direction.sub(a),e.direction.transformDirection(c),l++}else if(t.isRectAreaLight){let e=r.rectArea[h];e.position.setFromMatrixPosition(t.matrixWorld),e.position.applyMatrix4(c),o.identity(),s.copy(t.matrixWorld),s.premultiply(c),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(c),i++}else if(t.isHemisphereLight){let e=r.hemi[u];e.direction.setFromMatrixPosition(t.matrixWorld),e.direction.transformDirection(c),u++}}},state:r}}function tue(e,t){let n=new Yot(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 $ot(e,t){let n=new WeakMap;return{get:function(i,r=0){let a,s=n.get(i);return void 0===s?(a=new tue(e,t),n.set(i,[a])):r>=s.length?(a=new tue(e,t),s.push(a)):a=s[r],a},dispose:function(){n=new WeakMap}}}var wc=class extends Ar{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=She,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}},eb=class extends Ar{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}},Zot="void main() {\n\tgl_Position = vec4( position, 1.0 );\n}",Kot="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 Jot(e,t,n){let i=new wl,r=new _e,a=new _e,s=new mr,o=new wc({depthPacking:vv}),l=new eb,h={},u=n.maxTextureSize,c={[hi]:Ki,[Ki]:hi,[hr]:hr},d=new hn({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new _e},radius:{value:4}},vertexShader:Zot,fragmentShader:Kot}),p=d.clone();p.defines.HORIZONTAL_PASS=1;let f=new Ot;f.setAttribute("position",new yn(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let m=new St(f,d),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=xU;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 er(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===gu?null!==n.shadowSide?n.shadowSide:n.side:null!==n.shadowSide?n.shadowSide:c[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 b(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===gu)&&(!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],u=r[h.materialIndex];if(u&&u.visible){let t=x(n,u,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++)b(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(),c=e.getActiveMipmapLevel(),d=e.state;d.setBlending(Qr),d.buffers.color.setClear(1,1,1,1),d.buffers.depth.setTest(!0),d.setScissorTest(!1);let p=v!==gu&&this.type===gu,f=v===gu&&this.type!==gu;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 c=h.getFrameExtents();if(r.multiply(c),a.copy(h.mapSize),(r.x>u||r.y>u)&&(r.x>u&&(a.x=Math.floor(u/c.x),r.x=a.x*c.x,h.mapSize.x=a.x),r.y>u&&(a.y=Math.floor(u/c.y),r.y=a.y*c.y,h.mapSize.y=a.y)),null===h.map||!0===p||!0===f){let e=this.type!==gu?{minFilter:Jr,magFilter:Jr}:{};null!==h.map&&h.map.dispose(),h.map=new er(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(),b(n,o,h.camera,l,this.type)}!0!==h.isPointLightShadow&&this.type===gu&&y(h,o),h.needsUpdate=!1}v=this.type,g.needsUpdate=!1,e.setRenderTarget(l,h,c)}}function Qot(e,t,n){let i=n.isWebGL2,r=new function(){let t=!1,n=new mr,i=null,r=new mr(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):H(e.DEPTH_TEST)},setMask:function(i){n!==i&&!t&&(e.depthMask(i),n=i)},setFunc:function(t){if(i!==t){switch(t){case the:e.depthFunc(e.NEVER);break;case nhe:e.depthFunc(e.ALWAYS);break;case rhe:e.depthFunc(e.LESS);break;case nA:e.depthFunc(e.LEQUAL);break;case ihe:e.depthFunc(e.EQUAL);break;case she:e.depthFunc(e.GEQUAL);break;case ahe:e.depthFunc(e.GREATER);break;case ohe: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):H(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={},u={},c=new WeakMap,d=[],p=null,f=!1,m=null,g=null,v=null,y=null,x=null,b=null,_=null,w=!1,S=null,M=null,E=null,T=null,A=null,C=e.getParameter(e.MAX_COMBINED_TEXTURE_IMAGE_UNITS),P=!1,R=0,L=e.getParameter(e.VERSION);-1!==L.indexOf("WebGL")?(R=parseFloat(/^WebGL (\d)/.exec(L)[1]),P=R>=1):-1!==L.indexOf("OpenGL ES")&&(R=parseFloat(/^OpenGL ES (\d)/.exec(L)[1]),P=R>=2);let I=null,k={},O=e.getParameter(e.SCISSOR_BOX),D=e.getParameter(e.VIEWPORT),N=(new mr).fromArray(O),U=(new mr).fromArray(D);function F(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 H(t){!1!==h[t]&&(e.disable(t),h[t]=!1)}B[e.TEXTURE_2D]=F(e.TEXTURE_2D,e.TEXTURE_2D,1),B[e.TEXTURE_CUBE_MAP]=F(e.TEXTURE_CUBE_MAP,e.TEXTURE_CUBE_MAP_POSITIVE_X,6),i&&(B[e.TEXTURE_2D_ARRAY]=F(e.TEXTURE_2D_ARRAY,e.TEXTURE_2D_ARRAY,1,1),B[e.TEXTURE_3D]=F(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(nA),W(!1),X(VN),z(e.CULL_FACE),G(Qr);let V={[Vo]:e.FUNC_ADD,[Xue]:e.FUNC_SUBTRACT,[Yue]:e.FUNC_REVERSE_SUBTRACT};if(i)V[qN]=e.MIN,V[WN]=e.MAX;else{let e=t.get("EXT_blend_minmax");null!==e&&(V[qN]=e.MIN_EXT,V[WN]=e.MAX_EXT)}let j={[rf]:e.ZERO,[$ue]:e.ONE,[Zue]:e.SRC_COLOR,[bU]:e.SRC_ALPHA,[ehe]:e.SRC_ALPHA_SATURATE,[fv]:e.DST_COLOR,[dv]:e.DST_ALPHA,[Kue]:e.ONE_MINUS_SRC_COLOR,[EU]:e.ONE_MINUS_SRC_ALPHA,[Que]:e.ONE_MINUS_DST_COLOR,[Jue]:e.ONE_MINUS_DST_ALPHA};function G(t,n,i,r,a,s,o,l){if(t!==Qr){if(!1===f&&(z(e.BLEND),f=!0),t===xm)a=a||n,s=s||i,o=o||r,(n!==g||a!==x)&&(e.blendEquationSeparate(V[n],V[a]),g=n,x=a),(i!==v||r!==y||s!==b||o!==_)&&(e.blendFuncSeparate(j[i],j[r],j[s],j[o]),v=i,y=r,b=s,_=o),m=t,w=!1;else if(t!==m||l!==w){if((g!==Vo||x!==Vo)&&(e.blendEquation(e.FUNC_ADD),g=Vo,x=Vo),l)switch(t){case sm:e.blendFuncSeparate(e.ONE,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case _c:e.blendFunc(e.ONE,e.ONE);break;case zN:e.blendFuncSeparate(e.ZERO,e.ONE_MINUS_SRC_COLOR,e.ZERO,e.ONE);break;case GN: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 sm:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case _c:e.blendFunc(e.SRC_ALPHA,e.ONE);break;case zN:e.blendFuncSeparate(e.ZERO,e.ONE_MINUS_SRC_COLOR,e.ZERO,e.ONE);break;case GN:e.blendFunc(e.ZERO,e.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",t)}v=null,y=null,b=null,_=null,m=t,w=l}}else!0===f&&(H(e.BLEND),f=!1)}function W(t){S!==t&&(t?e.frontFace(e.CW):e.frontFace(e.CCW),S=t)}function X(t){t!==Wue?(z(e.CULL_FACE),t!==M&&(t===VN?e.cullFace(e.BACK):t===jue?e.cullFace(e.FRONT):e.cullFace(e.FRONT_AND_BACK))):H(e.CULL_FACE),M=t}function Y(t,n,i){t?(z(e.POLYGON_OFFSET_FILL),(T!==n||A!==i)&&(e.polygonOffset(n,i),T=n,A=i)):H(e.POLYGON_OFFSET_FILL)}return{buffers:{color:r,depth:a,stencil:s},enable:z,disable:H,bindFramebuffer:function(t,n){return u[t]!==n&&(e.bindFramebuffer(t,n),u[t]=n,i&&(t===e.DRAW_FRAMEBUFFER&&(u[e.FRAMEBUFFER]=n),t===e.FRAMEBUFFER&&(u[e.DRAW_FRAMEBUFFER]=n)),!0)},drawBuffers:function(i,r){let a=d,s=!1;if(i)if(a=c.get(r),void 0===a&&(a=[],c.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:G,setMaterial:function(t,n){t.side===hr?H(e.CULL_FACE):z(e.CULL_FACE);let i=t.side===Ki;n&&(i=!i),W(i),t.blending===sm&&!1===t.transparent?G(Qr):G(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)),Y(t.polygonOffset,t.polygonOffsetFactor,t.polygonOffsetUnits),!0===t.alphaToCoverage?z(e.SAMPLE_ALPHA_TO_COVERAGE):H(e.SAMPLE_ALPHA_TO_COVERAGE)},setFlipSided:W,setCullFace:X,setLineWidth:function(t){t!==E&&(P&&e.lineWidth(t),E=t)},setPolygonOffset:Y,setScissorTest:function(t){t?z(e.SCISSOR_TEST):H(e.SCISSOR_TEST)},activeTexture:function(t){void 0===t&&(t=e.TEXTURE0+C-1),I!==t&&(e.activeTexture(t),I=t)},bindTexture:function(t,n,i){void 0===i&&(i=null===I?e.TEXTURE0+C-1:I);let r=k[i];void 0===r&&(r={type:void 0,texture:void 0},k[i]=r),(r.type!==t||r.texture!==n)&&(I!==i&&(e.activeTexture(i),I=i),e.bindTexture(t,n||B[t]),r.type=t,r.texture=n)},unbindTexture:function(){let t=k[I];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===U.equals(t)&&(e.viewport(t.x,t.y,t.z,t.w),U.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={},I=null,k={},u={},c=new WeakMap,d=[],p=null,f=!1,m=null,g=null,v=null,y=null,x=null,b=null,_=null,w=!1,S=null,M=null,E=null,T=null,A=null,N.set(0,0,e.canvas.width,e.canvas.height),U.set(0,0,e.canvas.width,e.canvas.height),r.reset(),a.reset(),s.reset()}}}function elt(e,t,n,i,r,a,s){let o,l=r.isWebGL2,h=r.maxTextures,u=r.maxCubemapSize,c=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):$x("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?iA: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 b(e){return gB(e.width)&&gB(e.height)}function _(e,t){return e.generateMipmaps&&t&&e.minFilter!==Jr&&e.minFilter!==Xr}function w(t){e.generateMipmap(t)}function S(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.RED_INTEGER&&(r===e.UNSIGNED_BYTE&&(o=e.R8UI),r===e.UNSIGNED_SHORT&&(o=e.R16UI),r===e.UNSIGNED_INT&&(o=e.R32UI),r===e.BYTE&&(o=e.R8I),r===e.SHORT&&(o=e.R16I),r===e.INT&&(o=e.R32I)),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===sn&&!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 M(e,t,n){return!0===_(e,n)||e.isFramebufferTexture&&e.minFilter!==Jr&&e.minFilter!==Xr?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===Jr||t===Kd||t===Oh?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++){if(Array.isArray(r.__webglFramebuffer[i]))for(let t=0;t<r.__webglFramebuffer[i].length;t++)e.deleteFramebuffer(r.__webglFramebuffer[i][t]);else e.deleteFramebuffer(r.__webglFramebuffer[i]);r.__webglDepthbuffer&&e.deleteRenderbuffer(r.__webglDepthbuffer[i])}else{if(Array.isArray(r.__webglFramebuffer))for(let t=0;t<r.__webglFramebuffer.length;t++)e.deleteFramebuffer(r.__webglFramebuffer[t]);else e.deleteFramebuffer(r.__webglFramebuffer);if(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 P=0;function R(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 N(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={[Ii]:e.REPEAT,[Pi]:e.CLAMP_TO_EDGE,[Fh]:e.MIRRORED_REPEAT},I={[Jr]:e.NEAREST,[Kd]:e.NEAREST_MIPMAP_NEAREST,[Oh]:e.NEAREST_MIPMAP_LINEAR,[Xr]:e.LINEAR,[bm]:e.LINEAR_MIPMAP_NEAREST,[Ba]:e.LINEAR_MIPMAP_LINEAR},k={[Rhe]:e.NEVER,[khe]:e.ALWAYS,[Che]:e.LESS,[Ihe]:e.LEQUAL,[Phe]:e.EQUAL,[Ohe]:e.GEQUAL,[Lhe]:e.GREATER,[Dhe]:e.NOTEQUAL};function O(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,I[a.magFilter]),e.texParameteri(n,e.TEXTURE_MIN_FILTER,I[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!==Pi||a.wrapT!==Pi)&&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!==Jr&&a.minFilter!==Xr&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),a.compareFunction&&(e.texParameteri(n,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE),e.texParameteri(n,e.TEXTURE_COMPARE_FUNC,k[a.compareFunction])),!0===t.has("EXT_texture_filter_anisotropic")){let s=t.get("EXT_texture_filter_anisotropic");if(a.magFilter===Jr||a.minFilter!==Oh&&a.minFilter!==Ba||a.type===pa&&!1===t.has("OES_texture_float_linear")||!1===l&&a.type===Tr&&!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 D(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 N(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=D(t,r),u=r.source;n.bindTexture(o,t.__webglTexture,e.TEXTURE0+s);let d=i.get(u);if(u.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!==Pi||e.wrapT!==Pi||e.minFilter!==Jr&&e.minFilter!==Xr)}(r)&&!1===b(r.image),i=x(r.image,t,!1,c);i=V(r,i);let p=b(i)||l,f=a.convert(r.format,r.colorSpace),m=a.convert(r.type),g=S(r.internalFormat,f,m,r.colorSpace);O(o,r,p);let v,y=r.mipmaps,E=l&&!0!==r.isVideoTexture,T=void 0===d.__version||!0===h,A=M(r,i,p);if(r.isDepthTexture)g=e.DEPTH_COMPONENT,l?g=r.type===pa?e.DEPTH_COMPONENT32F:r.type===Lh?e.DEPTH_COMPONENT24:r.type===yu?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT16:r.type===pa&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),r.format===$d&&g===e.DEPTH_COMPONENT&&r.type!==mv&&r.type!==Lh&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),r.type=Lh,m=a.convert(r.type)),r.format===Nh&&g===e.DEPTH_COMPONENT&&(g=e.DEPTH_STENCIL,r.type!==yu&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),r.type=yu,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!==ea?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!==ea?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);_(r,p)&&w(o),d.__version=u.version,r.onUpdate&&r.onUpdate(r)}t.__version=r.version}function U(t,r,s,o,l,h){let u=a.convert(s.format,s.colorSpace),c=a.convert(s.type),d=S(s.internalFormat,u,c,s.colorSpace);if(!i.get(r).__hasExternalTextures){let t=Math.max(1,r.width>>h),i=Math.max(1,r.height>>h);l===e.TEXTURE_3D||l===e.TEXTURE_2D_ARRAY?n.texImage3D(l,h,d,t,i,r.depth,0,u,c,null):n.texImage2D(l,h,d,t,i,0,u,c,null)}n.bindFramebuffer(e.FRAMEBUFFER,t),H(r)?p.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,o,l,i.get(s).__webglTexture,0,z(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,h),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||H(n)){let t=n.depthTexture;t&&t.isDepthTexture&&(t.type===pa?r=e.DEPTH_COMPONENT32F:t.type===Lh&&(r=e.DEPTH_COMPONENT24));let i=z(n);H(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=z(n);i&&!1===H(n)?e.renderbufferStorageMultisample(e.RENDERBUFFER,r,e.DEPTH24_STENCIL8,n.width,n.height):H(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=S(s.internalFormat,o,l,s.colorSpace),u=z(n);i&&!1===H(n)?e.renderbufferStorageMultisample(e.RENDERBUFFER,u,h,n.width,n.height):H(n)?p.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,u,h,n.width,n.height):e.renderbufferStorage(e.RENDERBUFFER,h,n.width,n.height)}}e.bindRenderbuffer(e.RENDERBUFFER,null)}function B(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),R(r.depthTexture,0);let a=i.get(r.depthTexture).__webglTexture,s=z(r);if(r.depthTexture.format===$d)H(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!==Nh)throw new Error("Unknown depthTexture format");H(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 z(e){return Math.min(d,e.samples)}function H(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===rA||i!==Ua&&i!==bu&&(i===sn?!1===l?!0===t.has("EXT_sRGB")&&r===ea?(e.format=rA,e.minFilter=Xr,e.generateMipmaps=!1):n=Zx.sRGBToLinear(n):(r!==ea||a!==Ec)&&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=P;return e>=h&&console.warn("THREE.WebGLTextures: Trying to use "+e+" texture units while this GPU supports only "+h),P+=1,e},this.resetTextureUnits=function(){P=0},this.setTexture2D=R,this.setTexture2DArray=function(t,r){let a=i.get(t);t.version>0&&a.__version!==t.version?N(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?N(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=D(t,r),h=r.source;n.bindTexture(e.TEXTURE_CUBE_MAP,t.__webglTexture,e.TEXTURE0+s);let c=i.get(h);if(h.version!==c.__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,u),d[e]=V(r,d[e]);let p,f=d[0],m=b(f)||l,g=a.convert(r.format,r.colorSpace),v=a.convert(r.type),y=S(r.internalFormat,g,v,r.colorSpace),E=l&&!0!==r.isVideoTexture,T=void 0===c.__version||!0===o,A=M(r,f,m);if(O(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!==ea?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])}}}_(r,m)&&w(e.TEXTURE_CUBE_MAP),c.__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&&U(a.__webglFramebuffer,t,t.texture,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,0),void 0!==r&&B(t)},this.setupRenderTarget=function(t){let o=t.texture,h=i.get(t),u=i.get(o);t.addEventListener("dispose",A),!0!==t.isWebGLMultipleRenderTargets&&(void 0===u.__webglTexture&&(u.__webglTexture=e.createTexture()),u.__version=o.version,s.memory.textures++);let c=!0===t.isWebGLCubeRenderTarget,d=!0===t.isWebGLMultipleRenderTargets,p=b(t)||l;if(c){h.__webglFramebuffer=[];for(let t=0;t<6;t++)if(l&&o.mipmaps&&o.mipmaps.length>0){h.__webglFramebuffer[t]=[];for(let n=0;n<o.mipmaps.length;n++)h.__webglFramebuffer[t][n]=e.createFramebuffer()}else h.__webglFramebuffer[t]=e.createFramebuffer()}else{if(l&&o.mipmaps&&o.mipmaps.length>0){h.__webglFramebuffer=[];for(let t=0;t<o.mipmaps.length;t++)h.__webglFramebuffer[t]=e.createFramebuffer()}else h.__webglFramebuffer=e.createFramebuffer();if(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===H(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=S(r.internalFormat,s,o,r.colorSpace,!0===t.isXRRenderTarget),u=z(t);e.renderbufferStorageMultisample(e.RENDERBUFFER,u,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(c){n.bindTexture(e.TEXTURE_CUBE_MAP,u.__webglTexture),O(e.TEXTURE_CUBE_MAP,o,p);for(let n=0;n<6;n++)if(l&&o.mipmaps&&o.mipmaps.length>0)for(let i=0;i<o.mipmaps.length;i++)U(h.__webglFramebuffer[n][i],t,o,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+n,i);else U(h.__webglFramebuffer[n],t,o,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+n,0);_(o,p)&&w(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),O(e.TEXTURE_2D,s,p),U(h.__webglFramebuffer,t,s,e.COLOR_ATTACHMENT0+a,e.TEXTURE_2D,0),_(s,p)&&w(e.TEXTURE_2D)}n.unbindTexture()}else{let i=e.TEXTURE_2D;if((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,u.__webglTexture),O(i,o,p),l&&o.mipmaps&&o.mipmaps.length>0)for(let n=0;n<o.mipmaps.length;n++)U(h.__webglFramebuffer[n],t,o,e.COLOR_ATTACHMENT0,i,n);else U(h.__webglFramebuffer,t,o,e.COLOR_ATTACHMENT0,i,0);_(o,p)&&w(i),n.unbindTexture()}t.depthBuffer&&B(t)},this.updateRenderTargetMipmap=function(t){let r=b(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(_(o,r)){let r=t.isWebGLCubeRenderTarget?e.TEXTURE_CUBE_MAP:e.TEXTURE_2D,a=i.get(o).__webglTexture;n.bindTexture(r,a),w(r),n.unbindTexture()}}},this.updateMultisampleRenderTarget=function(t){if(l&&t.samples>0&&!1===H(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,u=i.get(t),c=!0===t.isWebGLMultipleRenderTargets;if(c)for(let t=0;t<r.length;t++)n.bindFramebuffer(e.FRAMEBUFFER,u.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.RENDERBUFFER,null),n.bindFramebuffer(e.FRAMEBUFFER,u.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.TEXTURE_2D,null,0);n.bindFramebuffer(e.READ_FRAMEBUFFER,u.__webglMultisampledFramebuffer),n.bindFramebuffer(e.DRAW_FRAMEBUFFER,u.__webglFramebuffer);for(let n=0;n<r.length;n++){l.push(e.COLOR_ATTACHMENT0+n),t.depthBuffer&&l.push(h);let d=void 0!==u.__ignoreDepthValues&&u.__ignoreDepthValues;if(!1===d&&(t.depthBuffer&&(o|=e.DEPTH_BUFFER_BIT),t.stencilBuffer&&(o|=e.STENCIL_BUFFER_BIT)),c&&e.framebufferRenderbuffer(e.READ_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.RENDERBUFFER,u.__webglColorRenderbuffer[n]),!0===d&&(e.invalidateFramebuffer(e.READ_FRAMEBUFFER,[h]),e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,[h])),c){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),c)for(let t=0;t<r.length;t++){n.bindFramebuffer(e.FRAMEBUFFER,u.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.RENDERBUFFER,u.__webglColorRenderbuffer[t]);let a=i.get(r[t]).__webglTexture;n.bindFramebuffer(e.FRAMEBUFFER,u.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.TEXTURE_2D,a,0)}n.bindFramebuffer(e.DRAW_FRAMEBUFFER,u.__webglMultisampledFramebuffer)}},this.setupDepthRenderbuffer=B,this.setupFrameBufferTexture=U,this.useMultisampledRTT=H}function Whe(e,t,n){let i=n.isWebGL2;return{convert:function(n,r=bu){let a;if(n===Ec)return e.UNSIGNED_BYTE;if(n===TU)return e.UNSIGNED_SHORT_4_4_4_4;if(n===wU)return e.UNSIGNED_SHORT_5_5_5_1;if(n===mhe)return e.BYTE;if(n===ghe)return e.SHORT;if(n===mv)return e.UNSIGNED_SHORT;if(n===_U)return e.INT;if(n===Lh)return e.UNSIGNED_INT;if(n===pa)return e.FLOAT;if(n===Tr)return i?e.HALF_FLOAT:(a=t.get("OES_texture_half_float"),null!==a?a.HALF_FLOAT_OES:null);if(n===vhe)return e.ALPHA;if(n===ea)return e.RGBA;if(n===OA)return e.LUMINANCE;if(n===yhe)return e.LUMINANCE_ALPHA;if(n===$d)return e.DEPTH_COMPONENT;if(n===Nh)return e.DEPTH_STENCIL;if(n===rA)return a=t.get("EXT_sRGB"),null!==a?a.SRGB_ALPHA_EXT:null;if(n===kA)return e.RED;if(n===SU)return e.RED_INTEGER;if(n===xhe)return e.RG;if(n===MU)return e.RG_INTEGER;if(n===AU)return e.RGBA_INTEGER;if(n===$M||n===ZM||n===KM||n===JM)if(r===sn){if(a=t.get("WEBGL_compressed_texture_s3tc_srgb"),null===a)return null;if(n===$M)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===ZM)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===KM)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===JM)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else{if(a=t.get("WEBGL_compressed_texture_s3tc"),null===a)return null;if(n===$M)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===ZM)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===KM)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===JM)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(n===jN||n===XN||n===YN||n===$N){if(a=t.get("WEBGL_compressed_texture_pvrtc"),null===a)return null;if(n===jN)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===XN)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===YN)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===$N)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(n===bhe)return a=t.get("WEBGL_compressed_texture_etc1"),null!==a?a.COMPRESSED_RGB_ETC1_WEBGL:null;if(n===ZN||n===KN){if(a=t.get("WEBGL_compressed_texture_etc"),null===a)return null;if(n===ZN)return r===sn?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(n===KN)return r===sn?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC}if(n===JN||n===QN||n===eB||n===tB||n===nB||n===rB||n===iB||n===sB||n===aB||n===oB||n===lB||n===cB||n===uB||n===hB){if(a=t.get("WEBGL_compressed_texture_astc"),null===a)return null;if(n===JN)return r===sn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===QN)return r===sn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===eB)return r===sn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===tB)return r===sn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===nB)return r===sn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===rB)return r===sn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===iB)return r===sn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===sB)return r===sn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===aB)return r===sn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===oB)return r===sn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===lB)return r===sn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===cB)return r===sn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===uB)return r===sn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===hB)return r===sn?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}if(n===QM){if(a=t.get("EXT_texture_compression_bptc"),null===a)return null;if(n===QM)return r===sn?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT}if(n===Ehe||n===dB||n===fB||n===pB){if(a=t.get("EXT_texture_compression_rgtc"),null===a)return null;if(n===QM)return a.COMPRESSED_RED_RGTC1_EXT;if(n===dB)return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===fB)return a.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===pB)return a.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}return n===yu?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 lA=class extends Yr{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}},Bn=class extends an{constructor(){super(),this.isGroup=!0,this.type="Group"}},tlt={type:"move"},zx=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return null===this._hand&&(this._hand=new Bn,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 Bn,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new k,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new k),this._targetRay}getGripSpace(){return null===this._grip&&(this._grip=new Bn,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new k,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new k),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(tlt)))}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 Bn;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}},Qd=class extends Hr{constructor(e,t,n,i,r,a,s,o,l,h){if((h=void 0!==h?h:$d)!==$d&&h!==Nh)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===n&&h===$d&&(n=Lh),void 0===n&&h===Nh&&(n=yu),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:Jr,this.minFilter=void 0!==o?o:Jr,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return null!==this.compareFunction&&(t.compareFunction=this.compareFunction),t}},LB=class extends Tc{constructor(e,t){super();let n=this,i=null,r=1,a=null,s="local-floor",o=1,l=null,h=null,u=null,c=null,d=null,p=null,f=t.getContextAttributes(),m=null,g=null,v=[],y=[],x=new Yr;x.layers.enable(1),x.viewport=new mr;let b=new Yr;b.layers.enable(2),b.viewport=new mr;let _=[x,b],w=new lA;w.layers.enable(1),w.layers.enable(2);let S=null,M=null;function E(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 T(){i.removeEventListener("select",E),i.removeEventListener("selectstart",E),i.removeEventListener("selectend",E),i.removeEventListener("squeeze",E),i.removeEventListener("squeezestart",E),i.removeEventListener("squeezeend",E),i.removeEventListener("end",T),i.removeEventListener("inputsourceschange",A);for(let e=0;e<v.length;e++){let t=y[e];null!==t&&(y[e]=null,v[e].disconnect(t))}S=null,M=null,e.setRenderTarget(m),d=null,c=null,u=null,i=null,g=null,I.stop(),n.isPresenting=!1,n.dispatchEvent({type:"sessionend"})}function A(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 zx,v[e]=t),t.getTargetRaySpace()},this.getControllerGrip=function(e){let t=v[e];return void 0===t&&(t=new zx,v[e]=t),t.getGripSpace()},this.getHand=function(e){let t=v[e];return void 0===t&&(t=new zx,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!==c?c:d},this.getBinding=function(){return u},this.getFrame=function(){return p},this.getSession=function(){return i},this.setSession=function(h){return it(this,null,(function*(){if(i=h,null!==i){if(m=e.getRenderTarget(),i.addEventListener("select",E),i.addEventListener("selectstart",E),i.addEventListener("selectend",E),i.addEventListener("squeeze",E),i.addEventListener("squeezestart",E),i.addEventListener("squeezeend",E),i.addEventListener("end",T),i.addEventListener("inputsourceschange",A),!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 er(d.framebufferWidth,d.framebufferHeight,{format:ea,type:Ec,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?Nh:$d,a=f.stencil?yu:Lh);let o={colorFormat:t.RGBA8,depthFormat:s,scaleFactor:r};u=new XRWebGLBinding(i,t),c=u.createProjectionLayer(o),i.updateRenderState({layers:[c]}),g=new er(c.textureWidth,c.textureHeight,{format:ea,type:Ec,depthTexture:new Qd(c.textureWidth,c.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=c.ignoreDepthValues}g.isXRRenderTarget=!0,this.setFoveation(o),l=null,a=yield i.requestReferenceSpace(s),I.setContext(i),I.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}}))},this.getEnvironmentBlendMode=function(){if(null!==i)return i.environmentBlendMode};let C=new k,P=new k;function R(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;w.near=b.near=x.near=e.near,w.far=b.far=x.far=e.far,(S!==w.near||M!==w.far)&&(i.updateRenderState({depthNear:w.near,depthFar:w.far}),S=w.near,M=w.far);let t=e.parent,n=w.cameras;R(w,t);for(let i=0;i<n.length;i++)R(n[i],t);2===n.length?function(e,t,n){C.setFromMatrixPosition(t.matrixWorld),P.setFromMatrixPosition(n.matrixWorld);let i=C.distanceTo(P),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],u=(r[8]-1)/r[0],c=(a[8]+1)/a[0],d=s*u,p=s*c,f=i/(-u+c),m=f*-u;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),b=l*o/v*g,_=h*o/v*g;e.projectionMatrix.makePerspective(y,x,b,_,g,v),e.projectionMatrixInverse.copy(e.projectionMatrix).invert()}(w,x,b):w.projectionMatrix.copy(x.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*Y0*Math.atan(1/e.projectionMatrix.elements[5]),e.zoom=1)}(e,w,t)},this.getCamera=function(){return w},this.getFoveation=function(){if(null!==c||null!==d)return o},this.setFoveation=function(e){o=e,null!==c&&(c.fixedFoveation=e),null!==d&&void 0!==d.fixedFoveation&&(d.fixedFoveation=e)};let L=null,I=new Hhe;I.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!==w.cameras.length&&(w.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=u.getViewSubImage(c,r);a=t.viewport,0===i&&(e.setRenderTargetTextures(g,t.colorTexture,c.ignoreDepthValues?void 0:t.depthStencilTexture),e.setRenderTarget(g))}let s=_[i];void 0===s&&(s=new Yr,s.layers.enable(i),s.viewport=new mr,_[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&&(w.matrix.copy(s.matrix),w.matrix.decompose(w.position,w.quaternion,w.scale)),!0===n&&w.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)}L&&L(t,i),i.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:i}),p=null})),this.setAnimationLoop=function(e){L=e},this.dispose=function(){}}};function nlt(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===Ki&&(i.bumpScale.value*=-1)),r.normalMap&&(i.normalMap.value=r.normalMap,n(r.normalMap,i.normalMapTransform),i.normalScale.value.copy(r.normalScale),r.side===Ki&&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,Uhe(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===Ki&&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)),t.anisotropy>0&&(e.anisotropyVector.value.set(t.anisotropy*Math.cos(t.anisotropyRotation),t.anisotropy*Math.sin(t.anisotropyRotation)),t.anisotropyMap&&(e.anisotropyMap.value=t.anisotropyMap,n(t.anisotropyMap,e.anisotropyMapTransform))),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,n(t.alphaMap,e.alphaMapTransform)),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,n(t.alphaMap,e.alphaMapTransform)),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 rlt(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 u(t){let n=t.target;n.removeEventListener("dispose",u);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,c){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",u));let p=c.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 ilt(){let e=$x("canvas");return e.style.display="block",e}var ga=class{constructor(e={}){let t,{canvas:n=ilt(),context:i=null,depth:r=!0,stencil:a=!0,alpha:s=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:h=!1,powerPreference:u="default",failIfMajorPerformanceCaveat:c=!1}=e;this.isWebGLRenderer=!0,t=null!==i?i.getContextAttributes().alpha:s;let d=new Uint32Array(4),p=new Int32Array(4),f=null,m=null,g=[],v=[];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=sn,this._useLegacyLights=!1,this.toneMapping=Dh,this.toneMappingExposure=1;let y=this,x=!1,b=0,_=0,w=null,S=-1,M=null,E=new mr,T=new mr,A=null,C=new ct(0),P=0,R=n.width,L=n.height,I=1,O=null,D=null,N=new mr(0,0,R,L),U=new mr(0,0,R,L),F=!1,B=new wl,z=!1,H=!1,V=null,j=new ht,G=new _e,W=new k,X={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function Y(){return null===w?I:1}let q,J,Z,K,$,Q,ee,te,ne,ie,re,ae,se,oe,le,he,ue,ce,de,pe,fe,me,ge,ve,ye=i;function xe(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:u,failIfMajorPerformanceCaveat:c};if("setAttribute"in n&&n.setAttribute("data-engine",`three.js r${IA}`),n.addEventListener("webglcontextlost",Se,!1),n.addEventListener("webglcontextrestored",Me,!1),n.addEventListener("webglcontextcreationerror",Ee,!1),null===ye){let t=["webgl2","webgl","experimental-webgl"];if(!0===y.isWebGL1Renderer&&t.shift(),ye=xe(t,e),null===ye)throw xe(t)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}"undefined"!=typeof WebGLRenderingContext&&ye instanceof WebGLRenderingContext&&console.warn("THREE.WebGLRenderer: WebGL 1 support was deprecated in r153 and will be removed in r163."),void 0===ye.getShaderPrecisionFormat&&(ye.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(e){throw console.error("THREE.WebGLRenderer: "+e.message),e}function be(){q=new Sat(ye),J=new xat(ye,q,e),q.init(J),me=new Whe(ye,q,J),Z=new Qot(ye,q,J),K=new Rat(ye),$=new Vot,Q=new elt(ye,q,Z,$,J,me,K),ee=new Eat(y),te=new wat(y),ne=new Brt(ye,J),ge=new vat(ye,q,ne,J),ie=new Mat(ye,ne,K,ge),re=new Lat(ye,ie,ne,K),de=new Iat(ye,J,Q),he=new bat($),ae=new Hot(y,ee,te,q,J,ge,he),se=new nlt(y,$),oe=new Got,le=new $ot(q,J),ce=new gat(y,ee,te,Z,re,t,l),ue=new Jot(y,re,J),ve=new rlt(ye,K,J,Z),pe=new yat(ye,q,K,J),fe=new Aat(ye,q,K,J),K.programs=ae.programs,y.capabilities=J,y.extensions=q,y.properties=$,y.renderLists=oe,y.shadowMap=ue,y.state=Z,y.info=K}be();let we=new LB(y,ye);function Se(e){e.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),x=!0}function Me(){console.log("THREE.WebGLRenderer: Context Restored."),x=!1;let e=K.autoReset,t=ue.enabled,n=ue.autoUpdate,i=ue.needsUpdate,r=ue.type;be(),K.autoReset=e,ue.enabled=t,ue.autoUpdate=n,ue.needsUpdate=i,ue.type=r}function Ee(e){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",e.statusMessage)}function Te(e){let t=e.target;t.removeEventListener("dispose",Te),function(e){(function(e){let t=$.get(e).programs;void 0!==t&&(t.forEach((function(e){ae.releaseProgram(e)})),e.isShaderMaterial&&ae.releaseShaderCache(e))})(e),$.remove(e)}(t)}this.xr=we,this.getContext=function(){return ye},this.getContextAttributes=function(){return ye.getContextAttributes()},this.forceContextLoss=function(){let e=q.get("WEBGL_lose_context");e&&e.loseContext()},this.forceContextRestore=function(){let e=q.get("WEBGL_lose_context");e&&e.restoreContext()},this.getPixelRatio=function(){return I},this.setPixelRatio=function(e){void 0!==e&&(I=e,this.setSize(R,L,!1))},this.getSize=function(e){return e.set(R,L)},this.setSize=function(e,t,i=!0){we.isPresenting?console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting."):(R=e,L=t,n.width=Math.floor(e*I),n.height=Math.floor(t*I),!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(R*I,L*I).floor()},this.setDrawingBufferSize=function(e,t,i){R=e,L=t,I=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(E)},this.getViewport=function(e){return e.copy(N)},this.setViewport=function(e,t,n,i){e.isVector4?N.set(e.x,e.y,e.z,e.w):N.set(e,t,n,i),Z.viewport(E.copy(N).multiplyScalar(I).floor())},this.getScissor=function(e){return e.copy(U)},this.setScissor=function(e,t,n,i){e.isVector4?U.set(e.x,e.y,e.z,e.w):U.set(e,t,n,i),Z.scissor(T.copy(U).multiplyScalar(I).floor())},this.getScissorTest=function(){return F},this.setScissorTest=function(e){Z.setScissorTest(F=e)},this.setOpaqueSort=function(e){O=e},this.setTransparentSort=function(e){D=e},this.getClearColor=function(e){return e.copy(ce.getClearColor())},this.setClearColor=function(){ce.setClearColor.apply(ce,arguments)},this.getClearAlpha=function(){return ce.getClearAlpha()},this.setClearAlpha=function(){ce.setClearAlpha.apply(ce,arguments)},this.clear=function(e=!0,t=!0,n=!0){let i=0;if(e){let e=!1;if(null!==w){let t=w.texture.format;e=t===AU||t===MU||t===SU}if(e){let e=w.texture.type,t=e===Ec||e===Lh||e===mv||e===yu||e===TU||e===wU,n=ce.getClearColor(),i=ce.getClearAlpha(),r=n.r,a=n.g,s=n.b;t?(d[0]=r,d[1]=a,d[2]=s,d[3]=i,ye.clearBufferuiv(ye.COLOR,0,d)):(p[0]=r,p[1]=a,p[2]=s,p[3]=i,ye.clearBufferiv(ye.COLOR,0,p))}else i|=ye.COLOR_BUFFER_BIT}t&&(i|=ye.DEPTH_BUFFER_BIT),n&&(i|=ye.STENCIL_BUFFER_BIT),ye.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",Se,!1),n.removeEventListener("webglcontextrestored",Me,!1),n.removeEventListener("webglcontextcreationerror",Ee,!1),oe.dispose(),le.dispose(),$.dispose(),ee.dispose(),te.dispose(),re.dispose(),ge.dispose(),ve.dispose(),ae.dispose(),we.dispose(),we.removeEventListener("sessionstart",Ce),we.removeEventListener("sessionend",Pe),V&&(V.dispose(),V=null),Re.stop()},this.renderBufferDirect=function(e,t,n,i,r,a){null===t&&(t=X);let s=r.isMesh&&r.matrixWorld.determinant()<0,o=function(e,t,n,i,r){!0!==t.isScene&&(t=X),Q.resetTextureUnits();let a=t.fog,s=i.isMeshStandardMaterial?t.environment:null,o=null===w?y.outputColorSpace:!0===w.isXRRenderTarget?w.texture.colorSpace:Ua,l=(i.isMeshStandardMaterial?te:ee).get(i.envMap||s),h=!0===i.vertexColors&&!!n.attributes.color&&4===n.attributes.color.itemSize,u=!!n.attributes.tangent&&(!!i.normalMap||i.anisotropy>0),c=!!n.morphAttributes.position,d=!!n.morphAttributes.normal,p=!!n.morphAttributes.color,f=Dh;i.toneMapped&&(null===w||!0===w.isXRRenderTarget)&&(f=y.toneMapping);let g=n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color,v=void 0!==g?g.length:0,x=$.get(i),b=m.state.lights;if(!0===z&&(!0===H||e!==M)){let t=e===M&&i.id===S;he.setState(i,e,t)}let _=!1;i.version===x.__version?(x.needsLights&&x.lightsStateVersion!==b.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||r.isInstancedMesh&&!0===x.instancingColor&&null===r.instanceColor||r.isInstancedMesh&&!1===x.instancingColor&&null!==r.instanceColor||x.envMap!==l||!0===i.fog&&x.fog!==a||void 0!==x.numClippingPlanes&&(x.numClippingPlanes!==he.numPlanes||x.numIntersection!==he.numIntersection)||x.vertexAlphas!==h||x.vertexTangents!==u||x.morphTargets!==c||x.morphNormals!==d||x.morphColors!==p||x.toneMapping!==f||!0===J.isWebGL2&&x.morphTargetsCount!==v)&&(_=!0):(_=!0,x.__version=i.version);let E=x.currentProgram;!0===_&&(E=De(i,t,r));let T=!1,A=!1,C=!1,P=E.getUniforms(),R=x.uniforms;if(Z.useProgram(E.program)&&(T=!0,A=!0,C=!0),i.id!==S&&(S=i.id,A=!0),T||M!==e){if(P.setValue(ye,"projectionMatrix",e.projectionMatrix),J.logarithmicDepthBuffer&&P.setValue(ye,"logDepthBufFC",2/(Math.log(e.far+1)/Math.LN2)),M!==e&&(M=e,A=!0,C=!0),i.isShaderMaterial||i.isMeshPhongMaterial||i.isMeshToonMaterial||i.isMeshStandardMaterial||i.envMap){let t=P.map.cameraPosition;void 0!==t&&t.setValue(ye,W.setFromMatrixPosition(e.matrixWorld))}(i.isMeshPhongMaterial||i.isMeshToonMaterial||i.isMeshLambertMaterial||i.isMeshBasicMaterial||i.isMeshStandardMaterial||i.isShaderMaterial)&&P.setValue(ye,"isOrthographic",!0===e.isOrthographicCamera),(i.isMeshPhongMaterial||i.isMeshToonMaterial||i.isMeshLambertMaterial||i.isMeshBasicMaterial||i.isMeshStandardMaterial||i.isShaderMaterial||i.isShadowMaterial||r.isSkinnedMesh)&&P.setValue(ye,"viewMatrix",e.matrixWorldInverse)}if(r.isSkinnedMesh){P.setOptional(ye,r,"bindMatrix"),P.setOptional(ye,r,"bindMatrixInverse");let e=r.skeleton;e&&(J.floatVertexTextures?(null===e.boneTexture&&e.computeBoneTexture(),P.setValue(ye,"boneTexture",e.boneTexture,Q),P.setValue(ye,"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 k=n.morphAttributes;if((void 0!==k.position||void 0!==k.normal||void 0!==k.color&&!0===J.isWebGL2)&&de.update(r,n,E),(A||x.receiveShadow!==r.receiveShadow)&&(x.receiveShadow=r.receiveShadow,P.setValue(ye,"receiveShadow",r.receiveShadow)),i.isMeshGouraudMaterial&&null!==i.envMap&&(R.envMap.value=l,R.flipEnvMap.value=l.isCubeTexture&&!1===l.isRenderTargetTexture?-1:1),A&&(P.setValue(ye,"toneMappingExposure",y.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}(R,C),a&&!0===i.fog&&se.refreshFogUniforms(R,a),se.refreshMaterialUniforms(R,i,I,L,V),X0.upload(ye,x.uniformsList,R,Q)),i.isShaderMaterial&&!0===i.uniformsNeedUpdate&&(X0.upload(ye,x.uniformsList,R,Q),i.uniformsNeedUpdate=!1),i.isSpriteMaterial&&P.setValue(ye,"center",r.center),P.setValue(ye,"modelViewMatrix",r.modelViewMatrix),P.setValue(ye,"normalMatrix",r.normalMatrix),P.setValue(ye,"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];ve.update(n,E),ve.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);Z.setMaterial(i,s);let l=n.index,h=1;if(!0===i.wireframe){if(l=ie.getWireframeAttribute(n),void 0===l)return;h=2}let u=n.drawRange,c=n.attributes.position,d=u.start*h,p=(u.start+u.count)*h;null!==a&&(d=Math.max(d,a.start*h),p=Math.min(p,(a.start+a.count)*h)),null!==l?(d=Math.max(d,0),p=Math.min(p,l.count)):null!=c&&(d=Math.max(d,0),p=Math.min(p,c.count));let f=p-d;if(f<0||f===1/0)return;ge.setup(r,i,o,n,l);let g,v=pe;if(null!==l&&(g=ne.get(l),v=fe,v.setIndex(g)),r.isMesh)!0===i.wireframe?(Z.setLineWidth(i.wireframeLinewidth*Y()),v.setMode(ye.LINES)):v.setMode(ye.TRIANGLES);else if(r.isLine){let e=i.linewidth;void 0===e&&(e=1),Z.setLineWidth(e*Y()),r.isLineSegments?v.setMode(ye.LINES):r.isLineLoop?v.setMode(ye.LINE_LOOP):v.setMode(ye.LINE_STRIP)}else r.isPoints?v.setMode(ye.POINTS):r.isSprite&&v.setMode(ye.TRIANGLES);if(r.isInstancedMesh)v.renderInstances(d,f,r.count);else if(n.isInstancedBufferGeometry){let e=void 0!==n._maxInstanceCount?n._maxInstanceCount:1/0,t=Math.min(n.instanceCount,e);v.renderInstances(d,f,t)}else v.render(d,f)},this.compile=function(e,t){function n(e,t,n){!0===e.transparent&&e.side===hr&&!1===e.forceSinglePass?(e.side=Ki,e.needsUpdate=!0,De(e,t,n),e.side=hi,e.needsUpdate=!0,De(e,t,n),e.side=hr):De(e,t,n)}m=le.get(e),m.init(),v.push(m),e.traverseVisible((function(e){e.isLight&&e.layers.test(t.layers)&&(m.pushLight(e),e.castShadow&&m.pushShadow(e))})),m.setupLights(y._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)})),v.pop(),m=null};let Ae=null;function Ce(){Re.stop()}function Pe(){Re.start()}let Re=new Hhe;function Le(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)m.pushLight(e),e.castShadow&&m.pushShadow(e);else if(e.isSprite){if(!e.frustumCulled||B.intersectsSprite(e)){i&&W.setFromMatrixPosition(e.matrixWorld).applyMatrix4(j);let t=re.update(e),r=e.material;r.visible&&f.push(e,t,r,n,W.z,null)}}else if((e.isMesh||e.isLine||e.isPoints)&&(!e.frustumCulled||B.intersectsObject(e))){let t=re.update(e),r=e.material;if(i&&(void 0!==e.boundingSphere?(null===e.boundingSphere&&e.computeBoundingSphere(),W.copy(e.boundingSphere.center)):(null===t.boundingSphere&&t.computeBoundingSphere(),W.copy(t.boundingSphere.center)),W.applyMatrix4(e.matrixWorld).applyMatrix4(j)),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&&f.push(e,t,o,n,W.z,s)}}else r.visible&&f.push(e,t,r,n,W.z,null)}let r=e.children;for(let a=0,s=r.length;a<s;a++)Le(r[a],t,n,i)}function Ie(e,t,n,i){let r=e.opaque,a=e.transmissive,s=e.transparent;m.setupLightsView(n),!0===z&&he.setGlobalState(y.clippingPlanes,n),a.length>0&&function(e,t,n,i){let r=J.isWebGL2;null===V&&(V=new er(1,1,{generateMipmaps:!0,type:q.has("EXT_color_buffer_half_float")?Tr:Ec,minFilter:Ba,samples:r?4:0})),y.getDrawingBufferSize(G),r?V.setSize(G.x,G.y):V.setSize(iA(G.x),iA(G.y));let a=y.getRenderTarget();y.setRenderTarget(V),y.getClearColor(C),P=y.getClearAlpha(),P<1&&y.setClearColor(16777215,.5),y.clear();let s=y.toneMapping;y.toneMapping=Dh,ke(e,n,i),Q.updateMultisampleRenderTarget(V),Q.updateRenderTargetMipmap(V);let o=!1;for(let l=0,h=t.length;l<h;l++){let e=t[l],r=e.object,a=e.geometry,s=e.material,h=e.group;if(s.side===hr&&r.layers.test(i.layers)){let e=s.side;s.side=Ki,s.needsUpdate=!0,Oe(r,n,i,a,s,h),s.side=e,s.needsUpdate=!0,o=!0}}!0===o&&(Q.updateMultisampleRenderTarget(V),Q.updateRenderTargetMipmap(V)),y.setRenderTarget(a),y.setClearColor(C,P),y.toneMapping=s}(r,a,t,n),i&&Z.viewport(E.copy(i)),r.length>0&&ke(r,t,n),a.length>0&&ke(a,t,n),s.length>0&&ke(s,t,n),Z.buffers.depth.setTest(!0),Z.buffers.depth.setMask(!0),Z.buffers.color.setMask(!0),Z.setPolygonOffset(!1)}function ke(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)&&Oe(s,t,n,o,l,h)}}function Oe(e,t,n,i,r,a){e.onBeforeRender(y,t,n,i,r,a),e.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,e.matrixWorld),e.normalMatrix.getNormalMatrix(e.modelViewMatrix),r.onBeforeRender(y,t,n,i,e,a),!0===r.transparent&&r.side===hr&&!1===r.forceSinglePass?(r.side=Ki,r.needsUpdate=!0,y.renderBufferDirect(n,t,i,r,e,a),r.side=hi,r.needsUpdate=!0,y.renderBufferDirect(n,t,i,r,e,a),r.side=hr):y.renderBufferDirect(n,t,i,r,e,a),e.onAfterRender(y,t,n,i,r,a)}function De(e,t,n){!0!==t.isScene&&(t=X);let i=$.get(e),r=m.state.lights,a=m.state.shadowsArray,s=r.state.version,o=ae.getParameters(e,r.state,a,t,n),l=ae.getProgramCacheKey(o),h=i.programs;i.environment=e.isMeshStandardMaterial?t.environment:null,i.fog=t.fog,i.envMap=(e.isMeshStandardMaterial?te:ee).get(e.envMap||i.environment),void 0===h&&(e.addEventListener("dispose",Te),h=new Map,i.programs=h);let u=h.get(l);if(void 0!==u){if(i.currentProgram===u&&i.lightsStateVersion===s)return Ne(e,o),u}else o.uniforms=ae.getUniforms(e),e.onBuild(n,o,y),e.onBeforeCompile(o,y),u=ae.acquireProgram(o,l),h.set(l,u),i.uniforms=o.uniforms;let c=i.uniforms;(!e.isShaderMaterial&&!e.isRawShaderMaterial||!0===e.clipping)&&(c.clippingPlanes=he.uniform),Ne(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&&(c.ambientLightColor.value=r.state.ambient,c.lightProbe.value=r.state.probe,c.directionalLights.value=r.state.directional,c.directionalLightShadows.value=r.state.directionalShadow,c.spotLights.value=r.state.spot,c.spotLightShadows.value=r.state.spotShadow,c.rectAreaLights.value=r.state.rectArea,c.ltc_1.value=r.state.rectAreaLTC1,c.ltc_2.value=r.state.rectAreaLTC2,c.pointLights.value=r.state.point,c.pointLightShadows.value=r.state.pointShadow,c.hemisphereLights.value=r.state.hemi,c.directionalShadowMap.value=r.state.directionalShadowMap,c.directionalShadowMatrix.value=r.state.directionalShadowMatrix,c.spotShadowMap.value=r.state.spotShadowMap,c.spotLightMatrix.value=r.state.spotLightMatrix,c.spotLightMap.value=r.state.spotLightMap,c.pointShadowMap.value=r.state.pointShadowMap,c.pointShadowMatrix.value=r.state.pointShadowMatrix);let d=u.getUniforms(),p=X0.seqWithValue(d.seq,c);return i.currentProgram=u,i.uniformsList=p,u}function Ne(e,t){let n=$.get(e);n.outputColorSpace=t.outputColorSpace,n.instancing=t.instancing,n.instancingColor=t.instancingColor,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}Re.setAnimationLoop((function(e){Ae&&Ae(e)})),"undefined"!=typeof self&&Re.setContext(self),this.setAnimationLoop=function(e){Ae=e,we.setAnimationLoop(e),null===e?Re.stop():Re.start()},we.addEventListener("sessionstart",Ce),we.addEventListener("sessionend",Pe),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===x)return;!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),null===t.parent&&!0===t.matrixWorldAutoUpdate&&t.updateMatrixWorld(),!0===we.enabled&&!0===we.isPresenting&&(!0===we.cameraAutoUpdate&&we.updateCamera(t),t=we.getCamera()),!0===e.isScene&&e.onBeforeRender(y,e,t,w),m=le.get(e,v.length),m.init(),v.push(m),j.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),B.setFromProjectionMatrix(j),H=this.localClippingEnabled,z=he.init(this.clippingPlanes,H),f=oe.get(e,g.length),f.init(),g.push(f),Le(e,t,0,y.sortObjects),f.finish(),!0===y.sortObjects&&f.sort(O,D),this.info.render.frame++,!0===z&&he.beginShadows();let n=m.state.shadowsArray;if(ue.render(n,e,t),!0===z&&he.endShadows(),!0===this.info.autoReset&&this.info.reset(),ce.render(f,e),m.setupLights(y._useLegacyLights),t.isArrayCamera){let n=t.cameras;for(let t=0,i=n.length;t<i;t++){let i=n[t];Ie(f,e,i,i.viewport)}}else Ie(f,e,t);null!==w&&(Q.updateMultisampleRenderTarget(w),Q.updateRenderTargetMipmap(w)),!0===e.isScene&&e.onAfterRender(y,e,t),ge.resetDefaultState(),S=-1,M=null,v.pop(),m=v.length>0?v[v.length-1]:null,g.pop(),f=g.length>0?g[g.length-1]:null},this.getActiveCubeFace=function(){return b},this.getActiveMipmapLevel=function(){return _},this.getRenderTarget=function(){return w},this.setRenderTargetTextures=function(e,t,n){$.get(e.texture).__webglTexture=t,$.get(e.depthTexture).__webglTexture=n;let i=$.get(e);i.__hasExternalTextures=!0,i.__hasExternalTextures&&(i.__autoAllocateDepthBuffer=void 0===n,i.__autoAllocateDepthBuffer||!0===q.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=$.get(e);n.__webglFramebuffer=t,n.__useDefaultFramebuffer=void 0===t},this.setRenderTarget=function(e,t=0,n=0){w=e,b=t,_=n;let i=!0,r=null,a=!1,s=!1;if(e){let o=$.get(e);void 0!==o.__useDefaultFramebuffer?(Z.bindFramebuffer(ye.FRAMEBUFFER,null),i=!1):void 0===o.__webglFramebuffer?Q.setupRenderTarget(e):o.__hasExternalTextures&&Q.rebindTextures(e,$.get(e.texture).__webglTexture,$.get(e.depthTexture).__webglTexture);let l=e.texture;(l.isData3DTexture||l.isDataArrayTexture||l.isCompressedArrayTexture)&&(s=!0);let h=$.get(e).__webglFramebuffer;e.isWebGLCubeRenderTarget?(r=Array.isArray(h[t])?h[t][n]:h[t],a=!0):r=J.isWebGL2&&e.samples>0&&!1===Q.useMultisampledRTT(e)?$.get(e).__webglMultisampledFramebuffer:Array.isArray(h)?h[n]:h,E.copy(e.viewport),T.copy(e.scissor),A=e.scissorTest}else E.copy(N).multiplyScalar(I).floor(),T.copy(U).multiplyScalar(I).floor(),A=F;if(Z.bindFramebuffer(ye.FRAMEBUFFER,r)&&J.drawBuffers&&i&&Z.drawBuffers(e,r),Z.viewport(E),Z.scissor(T),Z.setScissorTest(A),a){let i=$.get(e.texture);ye.framebufferTexture2D(ye.FRAMEBUFFER,ye.COLOR_ATTACHMENT0,ye.TEXTURE_CUBE_MAP_POSITIVE_X+t,i.__webglTexture,n)}else if(s){let i=$.get(e.texture),r=t||0;ye.framebufferTextureLayer(ye.FRAMEBUFFER,ye.COLOR_ATTACHMENT0,i.__webglTexture,n||0,r)}S=-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=$.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&void 0!==s&&(o=o[s]),o){Z.bindFramebuffer(ye.FRAMEBUFFER,o);try{let s=e.texture,o=s.format,l=s.type;if(o!==ea&&me.convert(o)!==ye.getParameter(ye.IMPLEMENTATION_COLOR_READ_FORMAT))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");let h=l===Tr&&(q.has("EXT_color_buffer_half_float")||J.isWebGL2&&q.has("EXT_color_buffer_float"));if(!(l===Ec||me.convert(l)===ye.getParameter(ye.IMPLEMENTATION_COLOR_READ_TYPE)||l===pa&&(J.isWebGL2||q.has("OES_texture_float")||q.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&&ye.readPixels(t,n,i,r,me.convert(o),me.convert(l),a)}finally{let e=null!==w?$.get(w).__webglFramebuffer:null;Z.bindFramebuffer(ye.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);Q.setTexture2D(t,0),ye.copyTexSubImage2D(ye.TEXTURE_2D,n,0,0,e.x,e.y,r,a),Z.unbindTexture()},this.copyTextureToTexture=function(e,t,n,i=0){let r=t.image.width,a=t.image.height,s=me.convert(n.format),o=me.convert(n.type);Q.setTexture2D(n,0),ye.pixelStorei(ye.UNPACK_FLIP_Y_WEBGL,n.flipY),ye.pixelStorei(ye.UNPACK_PREMULTIPLY_ALPHA_WEBGL,n.premultiplyAlpha),ye.pixelStorei(ye.UNPACK_ALIGNMENT,n.unpackAlignment),t.isDataTexture?ye.texSubImage2D(ye.TEXTURE_2D,i,e.x,e.y,r,a,s,o,t.image.data):t.isCompressedTexture?ye.compressedTexSubImage2D(ye.TEXTURE_2D,i,e.x,e.y,t.mipmaps[0].width,t.mipmaps[0].height,s,t.mipmaps[0].data):ye.texSubImage2D(ye.TEXTURE_2D,i,e.x,e.y,s,o,t.image),0===i&&n.generateMipmaps&&ye.generateMipmap(ye.TEXTURE_2D),Z.unbindTexture()},this.copyTextureToTexture3D=function(e,t,n,i,r=0){if(y.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=me.convert(i.format),u=me.convert(i.type);if(i.isData3DTexture)Q.setTexture3D(i,0),a=ye.TEXTURE_3D;else{if(!i.isDataArrayTexture)return void console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");Q.setTexture2DArray(i,0),a=ye.TEXTURE_2D_ARRAY}ye.pixelStorei(ye.UNPACK_FLIP_Y_WEBGL,i.flipY),ye.pixelStorei(ye.UNPACK_PREMULTIPLY_ALPHA_WEBGL,i.premultiplyAlpha),ye.pixelStorei(ye.UNPACK_ALIGNMENT,i.unpackAlignment);let c=ye.getParameter(ye.UNPACK_ROW_LENGTH),d=ye.getParameter(ye.UNPACK_IMAGE_HEIGHT),p=ye.getParameter(ye.UNPACK_SKIP_PIXELS),f=ye.getParameter(ye.UNPACK_SKIP_ROWS),m=ye.getParameter(ye.UNPACK_SKIP_IMAGES),g=n.isCompressedTexture?n.mipmaps[0]:n.image;ye.pixelStorei(ye.UNPACK_ROW_LENGTH,g.width),ye.pixelStorei(ye.UNPACK_IMAGE_HEIGHT,g.height),ye.pixelStorei(ye.UNPACK_SKIP_PIXELS,e.min.x),ye.pixelStorei(ye.UNPACK_SKIP_ROWS,e.min.y),ye.pixelStorei(ye.UNPACK_SKIP_IMAGES,e.min.z),n.isDataTexture||n.isData3DTexture?ye.texSubImage3D(a,r,t.x,t.y,t.z,s,o,l,h,u,g.data):n.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),ye.compressedTexSubImage3D(a,r,t.x,t.y,t.z,s,o,l,h,g.data)):ye.texSubImage3D(a,r,t.x,t.y,t.z,s,o,l,h,u,g),ye.pixelStorei(ye.UNPACK_ROW_LENGTH,c),ye.pixelStorei(ye.UNPACK_IMAGE_HEIGHT,d),ye.pixelStorei(ye.UNPACK_SKIP_PIXELS,p),ye.pixelStorei(ye.UNPACK_SKIP_ROWS,f),ye.pixelStorei(ye.UNPACK_SKIP_IMAGES,m),0===r&&i.generateMipmaps&&ye.generateMipmap(a),Z.unbindTexture()},this.initTexture=function(e){e.isCubeTexture?Q.setTextureCube(e,0):e.isData3DTexture?Q.setTexture3D(e,0):e.isDataArrayTexture||e.isCompressedArrayTexture?Q.setTexture2DArray(e,0):Q.setTexture2D(e,0),Z.unbindTexture()},this.resetState=function(){b=0,_=0,w=null,Z.reset(),ge.reset()},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return vu}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===sn?xu:PU}set outputEncoding(e){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=e===xu?sn:Ua}get useLegacyLights(){return console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights}set useLegacyLights(e){console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights=e}},cA=class extends ga{};cA.prototype.isWebGL1Renderer=!0;var K0=class{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new ct(e),this.density=t}clone(){return new K0(this.color,this.density)}toJSON(){return{type:"FogExp2",color:this.color.getHex(),density:this.density}}},_u=class{constructor(e,t=1,n=1e3){this.isFog=!0,this.name="",this.color=new ct(e),this.near=t,this.far=n}clone(){return new _u(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}},Ji=class extends an{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}},Vh=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=void 0!==e?e.length/t:0,this.usage=Xx,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=zo()}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=zo()),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=zo()),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}}},Fa=new k,fo=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++)Fa.fromBufferAttribute(this,t),Fa.applyMatrix4(e),this.setXYZ(t,Fa.x,Fa.y,Fa.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Fa.fromBufferAttribute(this,t),Fa.applyNormalMatrix(e),this.setXYZ(t,Fa.x,Fa.y,Fa.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Fa.fromBufferAttribute(this,t),Fa.transformDirection(e),this.setXYZ(t,Fa.x,Fa.y,Fa.z);return this}setX(e,t){return this.normalized&&(t=pr(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=pr(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=pr(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=pr(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=ho(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=ho(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=ho(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=ho(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=pr(t,this.array),n=pr(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=pr(t,this.array),n=pr(n,this.array),i=pr(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=pr(t,this.array),n=pr(n,this.array),i=pr(i,this.array),r=pr(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 yn(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 fo(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}}},tb=class extends Ar{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new ct(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}},N0,Lx=new k,B0=new k,U0=new k,H0=new _e,Dx=new _e,jhe=new ht,RM=new k,Ox=new k,CM=new k,nue=new _e,CN=new _e,rue=new _e,uA=class extends an{constructor(e){if(super(),this.isSprite=!0,this.type="Sprite",void 0===N0){N0=new Ot;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 Vh(e,5);N0.setIndex([0,1,2,0,2,3]),N0.setAttribute("position",new fo(t,3,0,!1)),N0.setAttribute("uv",new fo(t,2,3,!1))}this.geometry=N0,this.material=void 0!==e?e:new tb,this.center=new _e(.5,.5)}raycast(e,t){null===e.camera&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),B0.setFromMatrixScale(this.matrixWorld),jhe.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),U0.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&!1===this.material.sizeAttenuation&&B0.multiplyScalar(-U0.z);let n,i,r=this.material.rotation;0!==r&&(i=Math.cos(r),n=Math.sin(r));let a=this.center;PM(RM.set(-.5,-.5,0),U0,a,B0,n,i),PM(Ox.set(.5,-.5,0),U0,a,B0,n,i),PM(CM.set(.5,.5,0),U0,a,B0,n,i),nue.set(0,0),CN.set(1,0),rue.set(1,1);let s=e.ray.intersectTriangle(RM,Ox,CM,!1,Lx);if(null===s&&(PM(Ox.set(-.5,.5,0),U0,a,B0,n,i),CN.set(0,1),s=e.ray.intersectTriangle(RM,CM,Ox,!1,Lx),null===s))return;let o=e.ray.origin.distanceTo(Lx);o<e.near||o>e.far||t.push({distance:o,point:Lx.clone(),uv:ni.getInterpolation(Lx,RM,Ox,CM,nue,CN,rue,new _e),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 PM(e,t,n,i,r,a){H0.subVectors(e,n).addScalar(.5).multiply(i),void 0!==r?(Dx.x=a*H0.x-r*H0.y,Dx.y=r*H0.x+a*H0.y):Dx.copy(H0),e.copy(t),e.x+=Dx.x,e.y+=Dx.y,e.applyMatrix4(jhe)}var IM=new k,iue=new k,hA=class extends an{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){IM.setFromMatrixPosition(this.matrixWorld);let n=e.ray.origin.distanceTo(IM);this.getObjectForDistance(n).raycast(e,t)}}update(e){let t=this.levels;if(t.length>1){IM.setFromMatrixPosition(e.matrixWorld),iue.setFromMatrixPosition(this.matrixWorld);let n,i,r=IM.distanceTo(iue)/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}},sue=new k,aue=new mr,oue=new mr,slt=new k,lue=new ht,V0=new k,PN=new $r,cue=new ht,IN=new Tl,Tu=class extends St{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new ht,this.bindMatrixInverse=new ht,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){let e=this.geometry;null===this.boundingBox&&(this.boundingBox=new Nt),this.boundingBox.makeEmpty();let t=e.getAttribute("position");for(let n=0;n<t.count;n++)V0.fromBufferAttribute(t,n),this.applyBoneTransform(n,V0),this.boundingBox.expandByPoint(V0)}computeBoundingSphere(){let e=this.geometry;null===this.boundingSphere&&(this.boundingSphere=new $r),this.boundingSphere.makeEmpty();let t=e.getAttribute("position");for(let n=0;n<t.count;n++)V0.fromBufferAttribute(t,n),this.applyBoneTransform(n,V0),this.boundingSphere.expandByPoint(V0)}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,null!==e.boundingBox&&(this.boundingBox=e.boundingBox.clone()),null!==e.boundingSphere&&(this.boundingSphere=e.boundingSphere.clone()),this}raycast(e,t){let n=this.material,i=this.matrixWorld;void 0!==n&&(null===this.boundingSphere&&this.computeBoundingSphere(),PN.copy(this.boundingSphere),PN.applyMatrix4(i),!1!==e.ray.intersectsSphere(PN)&&(cue.copy(i).invert(),IN.copy(e.ray).applyMatrix4(cue),(null===this.boundingBox||!1!==IN.intersectsBox(this.boundingBox))&&this._computeIntersections(e,t,IN)))}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 mr,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;aue.fromBufferAttribute(i.attributes.skinIndex,e),oue.fromBufferAttribute(i.attributes.skinWeight,e),sue.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let r=0;r<4;r++){let e=oue.getComponent(r);if(0!==e){let i=aue.getComponent(r);lue.multiplyMatrices(n.bones[i].matrixWorld,n.boneInverses[i]),t.addScaledVector(slt.copy(sue).applyMatrix4(lue),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)}},Sl=class extends an{constructor(){super(),this.isBone=!0,this.type="Bone"}},_l=class extends Hr{constructor(e=null,t=1,n=1,i,r,a,s,o,l=Jr,h=Jr,u,c){super(null,a,s,o,l,h,i,r,u,c),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},uue=new ht,alt=new ht,Ml=class{constructor(e=[],t=[]){this.uuid=zo(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.boneTextureSize=0,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 ht)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){let t=new ht;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:alt;uue.multiplyMatrices(i,t[r]),uue.toArray(n,16*r)}null!==i&&(i.needsUpdate=!0)}clone(){return new Ml(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(4*this.bones.length);e=Fhe(e),e=Math.max(e,4);let t=new Float32Array(e*e*4);t.set(this.boneMatrices);let n=new _l(t,e,e,ea,pa);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 Sl),this.bones.push(r),this.boneInverses.push((new ht).fromArray(e.boneInverses[n]))}return this.init(),this}toJSON(){let e={metadata:{version:4.6,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}},zh=class extends yn{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}},z0=new ht,hue=new ht,LM=[],due=new Nt,olt=new ht,kx=new St,Fx=new $r,Os=class extends St{constructor(e,t,n){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new zh(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,olt)}computeBoundingBox(){let e=this.geometry,t=this.count;null===this.boundingBox&&(this.boundingBox=new Nt),null===e.boundingBox&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,z0),due.copy(e.boundingBox).applyMatrix4(z0),this.boundingBox.union(due)}computeBoundingSphere(){let e=this.geometry,t=this.count;null===this.boundingSphere&&(this.boundingSphere=new $r),null===e.boundingSphere&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,z0),Fx.copy(e.boundingSphere).applyMatrix4(z0),this.boundingSphere.union(Fx)}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,null!==e.boundingBox&&(this.boundingBox=e.boundingBox.clone()),null!==e.boundingSphere&&(this.boundingSphere=e.boundingSphere.clone()),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(kx.geometry=this.geometry,kx.material=this.material,void 0!==kx.material&&(null===this.boundingSphere&&this.computeBoundingSphere(),Fx.copy(this.boundingSphere),Fx.applyMatrix4(n),!1!==e.ray.intersectsSphere(Fx)))for(let r=0;r<i;r++){this.getMatrixAt(r,z0),hue.multiplyMatrices(n,z0),kx.matrixWorld=hue,kx.raycast(e,LM);for(let e=0,n=LM.length;e<n;e++){let n=LM[e];n.instanceId=r,n.object=this,t.push(n)}LM.length=0}}setColorAt(e,t){null===this.instanceColor&&(this.instanceColor=new zh(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"})}},zn=class extends Ar{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new ct(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}},fue=new k,pue=new k,mue=new ht,LN=new Tl,DM=new $r,Vr=class extends an{constructor(e=new Ot,t=new zn){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++)fue.fromBufferAttribute(t,e-1),pue.fromBufferAttribute(t,e),n[e]=n[e-1],n[e]+=fue.distanceTo(pue);e.setAttribute("lineDistance",new Bt(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(),DM.copy(n.boundingSphere),DM.applyMatrix4(i),DM.radius+=r,!1===e.ray.intersectsSphere(DM))return;mue.copy(i).invert(),LN.copy(e.ray).applyMatrix4(mue);let s=r/((this.scale.x+this.scale.y+this.scale.z)/3),o=s*s,l=new k,h=new k,u=new k,c=new k,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),LN.distanceSqToSegment(l,h,c,u)>o)continue;c.applyMatrix4(this.matrixWorld);let r=e.ray.origin.distanceTo(c);r<e.near||r>e.far||t.push({distance:r,point:u.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),LN.distanceSqToSegment(l,h,c,u)>o)continue;c.applyMatrix4(this.matrixWorld);let n=e.ray.origin.distanceTo(c);n<e.near||n>e.far||t.push({distance:n,point:u.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}}}}},gue=new k,vue=new k,zr=class extends Vr{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)gue.fromBufferAttribute(t,e),vue.fromBufferAttribute(t,e+1),n[e]=0===e?0:n[e-1],n[e+1]=n[e]+gue.distanceTo(vue);e.setAttribute("lineDistance",new Bt(n,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}},J0=class extends Vr{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}},Li=class extends Ar{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new ct(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}},yue=new ht,DB=new Tl,OM=new $r,kM=new k,Di=class extends an{constructor(e=new Ot,t=new Li){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(),OM.copy(n.boundingSphere),OM.applyMatrix4(i),OM.radius+=r,!1===e.ray.intersectsSphere(OM))return;yue.copy(i).invert(),DB.copy(e.ray).applyMatrix4(yue);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 u=Math.max(0,a.start),c=Math.min(l.count,a.start+a.count);u<c;u++){let n=l.getX(u);kM.fromBufferAttribute(h,n),xue(kM,n,o,i,e,t,this)}else for(let u=Math.max(0,a.start),c=Math.min(h.count,a.start+a.count);u<c;u++)kM.fromBufferAttribute(h,u),xue(kM,u,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 xue(e,t,n,i,r,a,s){let o=DB.distanceSqToPoint(e);if(o<n){let n=new k;DB.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 OB=class extends Hr{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:Xr,this.magFilter=void 0!==r?r:Xr,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)}},kB=class extends Hr{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=Jr,this.minFilter=Jr,this.generateMipmaps=!1,this.needsUpdate=!0}},wu=class extends Hr{constructor(e,t,n,i,r,a,s,o,l,h,u,c){super(null,a,s,o,l,h,i,r,u,c),this.isCompressedTexture=!0,this.image={width:t,height:n},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}},FB=class extends wu{constructor(e,t,n,i,r,a){super(e,t,n,r,a),this.isCompressedArrayTexture=!0,this.image.depth=i,this.wrapR=Pi}},NB=class extends wu{constructor(e,t,n){super(void 0,e[0].width,e[0].height,t,n,kh),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=e}},nb=class extends Hr{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}},Ha=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 _e:new k);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 k,i=[],r=[],a=[],s=new k,o=new ht;for(let d=0;d<=e;d++){let t=d/e;i[d]=this.getTangentAt(t,new k)}r[0]=new k,a[0]=new k;let l=Number.MAX_VALUE,h=Math.abs(i[0].x),u=Math.abs(i[0].y),c=Math.abs(i[0].z);h<=l&&(l=h,n.set(1,0,0)),u<=l&&(l=u,n.set(0,1,0)),c<=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(hs(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(hs(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.6,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}},Gh=class extends Ha{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 _e,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}},um=class extends Gh{constructor(e,t,n,i,r,a){super(e,t,n,n,i,r,a),this.isArcCurve=!0,this.type="ArcCurve"}};function OU(){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 FM=new k,DN=new OU,ON=new OU,kN=new OU,dA=class extends Ha{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 k){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]:(FM.subVectors(a[0],a[1]).add(a[0]),n=FM);let u=a[l%s],c=a[(l+1)%s];if(this.closed||l+2<s?i=a[(l+2)%s]:(FM.subVectors(a[s-1],a[s-2]).add(a[s-1]),i=FM),"centripetal"===this.curveType||"chordal"===this.curveType){let e="chordal"===this.curveType?.5:.25,t=Math.pow(n.distanceToSquared(u),e),r=Math.pow(u.distanceToSquared(c),e),a=Math.pow(c.distanceToSquared(i),e);r<1e-4&&(r=1),t<1e-4&&(t=r),a<1e-4&&(a=r),DN.initNonuniformCatmullRom(n.x,u.x,c.x,i.x,t,r,a),ON.initNonuniformCatmullRom(n.y,u.y,c.y,i.y,t,r,a),kN.initNonuniformCatmullRom(n.z,u.z,c.z,i.z,t,r,a)}else"catmullrom"===this.curveType&&(DN.initCatmullRom(n.x,u.x,c.x,i.x,this.tension),ON.initCatmullRom(n.y,u.y,c.y,i.y,this.tension),kN.initCatmullRom(n.z,u.z,c.z,i.z,this.tension));return r.set(DN.calc(h),ON.calc(h),kN.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 k).fromArray(n))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}};function bue(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 llt(e,t){let n=1-e;return n*n*t}function clt(e,t){return 2*(1-e)*e*t}function ult(e,t){return e*e*t}function Gx(e,t,n,i){return llt(e,t)+clt(e,n)+ult(e,i)}function hlt(e,t){let n=1-e;return n*n*n*t}function dlt(e,t){let n=1-e;return 3*n*n*e*t}function flt(e,t){return 3*(1-e)*e*e*t}function plt(e,t){return e*e*e*t}function qx(e,t,n,i,r){return hlt(e,t)+dlt(e,n)+flt(e,i)+plt(e,r)}var rb=class extends Ha{constructor(e=new _e,t=new _e,n=new _e,i=new _e){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=n,this.v3=i}getPoint(e,t=new _e){let n=t,i=this.v0,r=this.v1,a=this.v2,s=this.v3;return n.set(qx(e,i.x,r.x,a.x,s.x),qx(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}},fA=class extends Ha{constructor(e=new k,t=new k,n=new k,i=new k){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=n,this.v3=i}getPoint(e,t=new k){let n=t,i=this.v0,r=this.v1,a=this.v2,s=this.v3;return n.set(qx(e,i.x,r.x,a.x,s.x),qx(e,i.y,r.y,a.y,s.y),qx(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}},Q0=class extends Ha{constructor(e=new _e,t=new _e){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new _e){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 _e){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}},pA=class extends Ha{constructor(e=new k,t=new k){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new k){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 k){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}},ib=class extends Ha{constructor(e=new _e,t=new _e,n=new _e){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new _e){let n=t,i=this.v0,r=this.v1,a=this.v2;return n.set(Gx(e,i.x,r.x,a.x),Gx(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}},sb=class extends Ha{constructor(e=new k,t=new k,n=new k){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new k){let n=t,i=this.v0,r=this.v1,a=this.v2;return n.set(Gx(e,i.x,r.x,a.x),Gx(e,i.y,r.y,a.y),Gx(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}},hm=class extends Ha{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new _e){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],u=i[a>i.length-3?i.length-1:a+2];return n.set(bue(s,o.x,l.x,h.x,u.x),bue(s,o.y,l.y,h.y,u.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 _e).fromArray(n))}return this}},kU=Object.freeze({__proto__:null,ArcCurve:um,CatmullRomCurve3:dA,CubicBezierCurve:rb,CubicBezierCurve3:fA,EllipseCurve:Gh,LineCurve:Q0,LineCurve3:pA,QuadraticBezierCurve:ib,QuadraticBezierCurve3:sb,SplineCurve:hm}),mA=class extends Ha{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 Q0(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 kU[n.type]).fromJSON(n))}return this}},Su=class extends mA{constructor(e){super(),this.type="Path",this.currentPoint=new _e,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 Q0(this.currentPoint.clone(),new _e(e,t));return this.curves.push(n),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,n,i){let r=new ib(this.currentPoint.clone(),new _e(e,t),new _e(n,i));return this.curves.push(r),this.currentPoint.set(n,i),this}bezierCurveTo(e,t,n,i,r,a){let s=new rb(this.currentPoint.clone(),new _e(e,t),new _e(n,i),new _e(r,a));return this.curves.push(s),this.currentPoint.set(r,a),this}splineThru(e){let t=[this.currentPoint.clone()].concat(e),n=new hm(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 Gh(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}},dm=class extends Ot{constructor(e=[new _e(0,-.5),new _e(.5,0),new _e(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=hs(i,0,2*Math.PI);let r=[],a=[],s=[],o=[],l=[],h=1/t,u=new k,c=new _e,d=new k,p=new k,f=new k,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++){u.x=e[n].x*d,u.y=e[n].y,u.z=e[n].x*p,a.push(u.x,u.y,u.z),c.x=v/t,c.y=n/(e.length-1),s.push(c.x,c.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 Bt(a,3)),this.setAttribute("uv",new Bt(s,2)),this.setAttribute("normal",new Bt(l,3))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new dm(e.points,e.segments,e.phiStart,e.phiLength)}},ev=class extends dm{constructor(e=1,t=1,n=4,i=8){let r=new Su;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,length:t,capSegments:n,radialSegments:i}}static fromJSON(e){return new ev(e.radius,e.length,e.capSegments,e.radialSegments)}},tv=class extends Ot{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 k,h=new _e;a.push(0,0,0),s.push(0,0,1),o.push(.5,.5);for(let u=0,c=3;u<=t;u++,c+=3){let r=n+u/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[c]/e+1)/2,h.y=(a[c+1]/e+1)/2,o.push(h.x,h.y)}for(let u=1;u<=t;u++)r.push(u,u+1,0);this.setIndex(r),this.setAttribute("position",new Bt(a,3)),this.setAttribute("normal",new Bt(s,3)),this.setAttribute("uv",new Bt(o,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new tv(e.radius,e.segments,e.thetaStart,e.thetaLength)}},Sc=class extends Ot{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=[],u=[],c=[],d=[],p=0,f=[],m=n/2,g=0;function v(n){let r=p,a=new _e,f=new k,v=0,y=!0===n?e:t,x=!0===n?1:-1;for(let e=1;e<=i;e++)u.push(0,m*x,0),c.push(0,x,0),d.push(.5,.5),p++;let b=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,u.push(f.x,f.y,f.z),c.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=b+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 k,v=new k,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,u.push(v.x,v.y,v.z),a.set(l,x,f).normalize(),c.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 Bt(u,3)),this.setAttribute("normal",new Bt(c,3)),this.setAttribute("uv",new Bt(d,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Sc(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},nv=class extends Sc{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 nv(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},Mu=class extends Ot{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 u(e){return Math.atan2(e.z,-e.x)}function c(e){return Math.atan2(-e.y,Math.sqrt(e.x*e.x+e.z*e.z))}(function(e){let n=new k,i=new k,r=new k;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 k;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 k;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=u(e)/2/Math.PI+.5,i=c(e)/Math.PI+.5;a.push(n,1-i)}(function(){let e=new k,t=new k,n=new k,i=new k,s=new _e,o=new _e,l=new _e;for(let c=0,d=0;c<r.length;c+=9,d+=6){e.set(r[c+0],r[c+1],r[c+2]),t.set(r[c+3],r[c+4],r[c+5]),n.set(r[c+6],r[c+7],r[c+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=u(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 Bt(r,3)),this.setAttribute("normal",new Bt(r.slice(),3)),this.setAttribute("uv",new Bt(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 Mu(e.vertices,e.indices,e.radius,e.details)}},rv=class extends Mu{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 rv(e.radius,e.detail)}},NM=new k,BM=new k,FN=new k,UM=new ni,Au=class extends Ot{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(am*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),u={},c=[];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}=UM;if(t.fromBufferAttribute(a,o[0]),s.fromBufferAttribute(a,o[1]),d.fromBufferAttribute(a,o[2]),UM.getNormal(FN),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=UM[l[e]],s=UM[l[t]],d=`${n}_${r}`,p=`${r}_${n}`;p in u&&u[p]?(FN.dot(u[p].normal)<=i&&(c.push(a.x,a.y,a.z),c.push(s.x,s.y,s.z)),u[p]=null):d in u||(u[d]={index0:o[e],index1:o[t],normal:FN.clone()})}}for(let e in u)if(u[e]){let{index0:t,index1:n}=u[e];NM.fromBufferAttribute(a,t),BM.fromBufferAttribute(a,n),c.push(NM.x,NM.y,NM.z),c.push(BM.x,BM.y,BM.z)}this.setAttribute("position",new Bt(c,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}},Ts=class extends Su{constructor(e){super(e),this.uuid=zo(),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 Su).fromJSON(n))}return this}},mlt={triangulate:function(e,t,n=2){let i,r,a,s,o,l,h,u=t&&t.length,c=u?t[0]*n:e.length,d=Xhe(e,0,c,n,!0),p=[];if(!d||d.next===d.prev)return p;if(u&&(d=blt(e,t,d,n)),e.length>80*n){i=a=e[0],r=s=e[1];for(let t=n;t<c;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 ab(d,p,n,i,r,h,0),p}};function Xhe(e,t,n,i,r){let a,s;if(r===Ilt(e,t,n,i)>0)for(a=t;a<n;a+=i)s=Eue(a,e[a],e[a+1],s);else for(a=n-i;a>=t;a-=i)s=Eue(a,e[a],e[a+1],s);return s&&BA(s,s.next)&&(lb(s),s=s.next),s}function fm(e,t){if(!e)return e;t||(t=e);let n,i=e;do{if(n=!1,i.steiner||!BA(i,i.next)&&0!==Zi(i.prev,i,i.next))i=i.next;else{if(lb(i),i=t=i.prev,i===i.next)break;n=!0}}while(n||i!==t);return t}function ab(e,t,n,i,r,a,s){if(!e)return;!s&&a&&Slt(e,i,r,a);let o,l,h=e;for(;e.prev!==e.next;)if(o=e.prev,l=e.next,a?vlt(e,i,r,a):glt(e))t.push(o.i/n|0),t.push(e.i/n|0),t.push(l.i/n|0),lb(e),e=l.next,h=l.next;else if((e=l)===h){s?1===s?ab(e=ylt(fm(e),t,n),t,n,i,r,a,2):2===s&&xlt(e,t,n,i,r,a):ab(fm(e),t,n,i,r,a,1);break}}function glt(e){let t=e.prev,n=e,i=e.next;if(Zi(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,u=r<a?r<s?r:s:a<s?a:s,c=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>=u&&f.x<=d&&f.y>=c&&f.y<=p&&W0(r,o,a,l,s,h,f.x,f.y)&&Zi(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function vlt(e,t,n,i){let r=e.prev,a=e,s=e.next;if(Zi(r,a,s)>=0)return!1;let o=r.x,l=a.x,h=s.x,u=r.y,c=a.y,d=s.y,p=o<l?o<h?o:h:l<h?l:h,f=u<c?u<d?u:d:c<d?c:d,m=o>l?o>h?o:h:l>h?l:h,g=u>c?u>d?u:d:c>d?c:d,v=BB(p,f,t,n,i),y=BB(m,g,t,n,i),x=e.prevZ,b=e.nextZ;for(;x&&x.z>=v&&b&&b.z<=y;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==r&&x!==s&&W0(o,u,l,c,h,d,x.x,x.y)&&Zi(x.prev,x,x.next)>=0||(x=x.prevZ,b.x>=p&&b.x<=m&&b.y>=f&&b.y<=g&&b!==r&&b!==s&&W0(o,u,l,c,h,d,b.x,b.y)&&Zi(b.prev,b,b.next)>=0))return!1;b=b.nextZ}for(;x&&x.z>=v;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==r&&x!==s&&W0(o,u,l,c,h,d,x.x,x.y)&&Zi(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;b&&b.z<=y;){if(b.x>=p&&b.x<=m&&b.y>=f&&b.y<=g&&b!==r&&b!==s&&W0(o,u,l,c,h,d,b.x,b.y)&&Zi(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function ylt(e,t,n){let i=e;do{let r=i.prev,a=i.next.next;!BA(r,a)&&Yhe(r,i,i.next,a)&&ob(r,a)&&ob(a,r)&&(t.push(r.i/n|0),t.push(i.i/n|0),t.push(a.i/n|0),lb(i),lb(i.next),i=e=a),i=i.next}while(i!==e);return fm(i)}function xlt(e,t,n,i,r,a){let s=e;do{let e=s.next.next;for(;e!==s.prev;){if(s.i!==e.i&&Rlt(s,e)){let o=$he(s,e);return s=fm(s,s.next),o=fm(o,o.next),ab(s,t,n,i,r,a,0),void ab(o,t,n,i,r,a,0)}e=e.next}s=s.next}while(s!==e)}function blt(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=Xhe(e,s,o,i,!1),l===l.next&&(l.steiner=!0),h.push(Alt(l));for(h.sort(Elt),r=0;r<h.length;r++)n=_lt(h[r],n);return n}function Elt(e,t){return e.x-t.x}function _lt(e,t){let n=Tlt(e,t);if(!n)return t;let i=$he(n,e);return fm(i,i.next),fm(n,n.next)}function Tlt(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,u=n.y,c=1/0;i=n;do{a>=i.x&&i.x>=h&&a!==i.x&&W0(s<u?a:r,s,h,u,s<u?r:a,s,i.x,i.y)&&(o=Math.abs(s-i.y)/(a-i.x),ob(i,e)&&(o<c||o===c&&(i.x>n.x||i.x===n.x&&wlt(n,i)))&&(n=i,c=o)),i=i.next}while(i!==l);return n}function wlt(e,t){return Zi(e.prev,e,t.prev)<0&&Zi(t.next,e,e.next)<0}function Slt(e,t,n,i){let r=e;do{0===r.z&&(r.z=BB(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,Mlt(r)}function Mlt(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 BB(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 Alt(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 W0(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 Rlt(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!Clt(e,t)&&(ob(e,t)&&ob(t,e)&&Plt(e,t)&&(Zi(e.prev,e,t.prev)||Zi(e,t.prev,t))||BA(e,t)&&Zi(e.prev,e,e.next)>0&&Zi(t.prev,t,t.next)>0)}function Zi(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function BA(e,t){return e.x===t.x&&e.y===t.y}function Yhe(e,t,n,i){let r=VM(Zi(e,t,n)),a=VM(Zi(e,t,i)),s=VM(Zi(n,i,e)),o=VM(Zi(n,i,t));return!!(r!==a&&s!==o||0===r&&HM(e,n,t)||0===a&&HM(e,i,t)||0===s&&HM(n,e,i)||0===o&&HM(n,t,i))}function HM(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 VM(e){return e>0?1:e<0?-1:0}function Clt(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&&Yhe(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}function ob(e,t){return Zi(e.prev,e,e.next)<0?Zi(e,t,e.next)>=0&&Zi(e,e.prev,t)>=0:Zi(e,t,e.prev)<0||Zi(e,e.next,t)<0}function Plt(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 $he(e,t){let n=new UB(e.i,e.x,e.y),i=new UB(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 Eue(e,t,n,i){let r=new UB(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 lb(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 UB(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 Ilt(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 qs=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 qs.area(e)<0}static triangulateShape(e,t){let n=[],i=[],r=[];_ue(e),Tue(n,e);let a=e.length;t.forEach(_ue);for(let o=0;o<t.length;o++)i.push(a),a+=t[o].length,Tue(n,t[o]);let s=mlt.triangulate(n,i);for(let o=0;o<s.length;o+=3)r.push(s.slice(o,o+3));return r}};function _ue(e){let t=e.length;t>2&&e[t-1].equals(e[0])&&e.pop()}function Tue(e,t){for(let n=0;n<t.length;n++)e.push(t[n].x),e.push(t[n].y)}var Ws=class extends Ot{constructor(e=new Ts([new _e(.5,.5),new _e(-.5,.5),new _e(-.5,-.5),new _e(.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,u=[],c=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,b=void 0!==t.UVGenerator?t.UVGenerator:Llt,_=!1;x&&(a=x.getSpacedPoints(d),_=!0,f=!1,s=x.computeFrenetFrames(d,!1),o=new k,l=new k,h=new k),f||(y=0,m=0,g=0,v=0);let w=e.extractPoints(c),S=w.shape,M=w.holes;if(!qs.isClockWise(S)){S=S.reverse();for(let e=0,t=M.length;e<t;e++){let t=M[e];qs.isClockWise(t)&&(M[e]=t.reverse())}}let E=qs.triangulateShape(S,M),T=S;for(let t=0,n=M.length;t<n;t++){let e=M[t];S=S.concat(e)}function A(e,t,n){return t||console.error("THREE.ExtrudeGeometry: vec does not exist"),e.clone().addScaledVector(t,n)}let C=S.length,P=E.length;function R(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,u=s*s+o*o,c=s*h-o*l;if(Math.abs(c)>Number.EPSILON){let c=Math.sqrt(u),d=Math.sqrt(l*l+h*h),p=t.x-o/c,f=t.y+s/c,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 _e(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(u)):(i=s,r=o,a=Math.sqrt(u/2))}return new _e(i/a,r/a)}let L=[];for(let t=0,n=T.length,i=n-1,r=t+1;t<n;t++,i++,r++)i===n&&(i=0),r===n&&(r=0),L[t]=R(T[t],T[i],T[r]);let I,O=[],D=L.concat();for(let t=0,n=M.length;t<n;t++){let e=M[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]=R(e[t],e[i],e[r]);O.push(I),D=D.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=T.length;t<r;t++){let e=A(T[t],L[t],i);F(e.x,e.y,-n)}for(let t=0,r=M.length;t<r;t++){let e=M[t];I=O[t];for(let t=0,r=e.length;t<r;t++){let r=A(e[t],I[t],i);F(r.x,r.y,-n)}}}let N=g+v;for(let t=0;t<C;t++){let e=f?A(S[t],D[t],N):S[t];_?(l.copy(s.normals[0]).multiplyScalar(e.x),o.copy(s.binormals[0]).multiplyScalar(e.y),h.copy(a[0]).add(l).add(o),F(h.x,h.y,h.z)):F(e.x,e.y,0)}for(let t=1;t<=d;t++)for(let e=0;e<C;e++){let n=f?A(S[e],D[e],N):S[e];_?(l.copy(s.normals[t]).multiplyScalar(n.x),o.copy(s.binormals[t]).multiplyScalar(n.y),h.copy(a[t]).add(l).add(o),F(h.x,h.y,h.z)):F(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=T.length;t<r;t++){let e=A(T[t],L[t],i);F(e.x,e.y,p+n)}for(let t=0,r=M.length;t<r;t++){let e=M[t];I=O[t];for(let t=0,r=e.length;t<r;t++){let r=A(e[t],I[t],i);_?F(r.x,r.y+a[d-1].y,a[d-1].x+n):F(r.x,r.y,p+n)}}}function U(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=C*e,a=C*(e+1);z(t+i+n,t+r+n,t+r+a,t+i+a)}}}function F(e,t,n){u.push(e),u.push(t),u.push(n)}function B(e,t,r){H(e),H(t),H(r);let a=i.length/3,s=b.generateTopUV(n,i,a-3,a-2,a-1);V(s[0]),V(s[1]),V(s[2])}function z(e,t,r,a){H(e),H(t),H(a),H(t),H(r),H(a);let s=i.length/3,o=b.generateSideWallUV(n,i,s-6,s-3,s-2,s-1);V(o[0]),V(o[1]),V(o[3]),V(o[1]),V(o[2]),V(o[3])}function H(e){i.push(u[3*e+0]),i.push(u[3*e+1]),i.push(u[3*e+2])}function V(e){r.push(e.x),r.push(e.y)}(function(){let e=i.length/3;if(f){let e=0,t=C*e;for(let n=0;n<P;n++){let e=E[n];B(e[2]+t,e[1]+t,e[0]+t)}e=d+2*y,t=C*e;for(let n=0;n<P;n++){let e=E[n];B(e[0]+t,e[1]+t,e[2]+t)}}else{for(let e=0;e<P;e++){let t=E[e];B(t[2],t[1],t[0])}for(let e=0;e<P;e++){let t=E[e];B(t[0]+C*d,t[1]+C*d,t[2]+C*d)}}n.addGroup(e,i.length/3-e,0)})(),function(){let e=i.length/3,t=0;U(T,t),t+=T.length;for(let n=0,i=M.length;n<i;n++){let e=M[n];U(e,t),t+=e.length}n.addGroup(e,i.length/3-e,1)}()}this.setAttribute("position",new Bt(i,3)),this.setAttribute("uv",new Bt(r,2)),this.computeVertexNormals()}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){let e=super.toJSON();return Dlt(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 kU[i.type]).fromJSON(i)),new Ws(n,e.options)}},Llt={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],u=t[3*r+1];return[new _e(a,s),new _e(o,l),new _e(h,u)]},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],u=t[3*i+1],c=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-u)<Math.abs(s-h)?[new _e(s,1-l),new _e(h,1-c),new _e(d,1-f),new _e(m,1-v)]:[new _e(o,1-l),new _e(u,1-c),new _e(p,1-f),new _e(g,1-v)]}};function Dlt(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 iv=class extends Mu{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 iv(e.radius,e.detail)}},pm=class extends Mu{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 pm(e.radius,e.detail)}},sv=class extends Ot{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=[],u=e,c=(t-e)/(i=Math.max(1,i)),d=new k,p=new _e;for(let f=0;f<=i;f++){for(let e=0;e<=n;e++){let i=r+e/n*a;d.x=u*Math.cos(i),d.y=u*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)}u+=c}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 Bt(o,3)),this.setAttribute("normal",new Bt(l,3)),this.setAttribute("uv",new Bt(h,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new sv(e.innerRadius,e.outerRadius,e.thetaSegments,e.phiSegments,e.thetaStart,e.thetaLength)}},Al=class extends Ot{constructor(e=new Ts([new _e(0,.5),new _e(-.5,-.5),new _e(.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,u=l.holes;!1===qs.isClockWise(h)&&(h=h.reverse());for(let t=0,n=u.length;t<n;t++){let e=u[t];!0===qs.isClockWise(e)&&(u[t]=e.reverse())}let c=qs.triangulateShape(h,u);for(let t=0,n=u.length;t<n;t++){let e=u[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=c.length;t<i;t++){let e=c[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 Bt(i,3)),this.setAttribute("normal",new Bt(r,3)),this.setAttribute("uv",new Bt(a,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){let e=super.toJSON();return Olt(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 Al(n,e.curveSegments)}};function Olt(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 Va=class extends Ot{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=[],u=new k,c=new k,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;u.x=-e*Math.cos(i+o*r)*Math.sin(a+v*s),u.y=e*Math.cos(a+v*s),u.z=e*Math.sin(i+o*r)*Math.sin(a+v*s),p.push(u.x,u.y,u.z),c.copy(u).normalize(),f.push(c.x,c.y,c.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 Bt(p,3)),this.setAttribute("normal",new Bt(f,3)),this.setAttribute("uv",new Bt(m,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Va(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}},av=class extends Mu{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 av(e.radius,e.detail)}},ef=class extends Ot{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 k,u=new k,c=new k;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;u.x=(e+t*Math.cos(f))*Math.cos(p),u.y=(e+t*Math.cos(f))*Math.sin(p),u.z=t*Math.sin(f),s.push(u.x,u.y,u.z),h.x=e*Math.cos(p),h.y=e*Math.sin(p),c.subVectors(u,h).normalize(),o.push(c.x,c.y,c.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 Bt(s,3)),this.setAttribute("normal",new Bt(o,3)),this.setAttribute("uv",new Bt(l,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new ef(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}},ov=class extends Ot{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=[],u=new k,c=new k,d=new k,p=new k,f=new k,m=new k,g=new k;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);u.x=d.x+(a*g.x+s*f.x),u.y=d.y+(a*g.y+s*f.y),u.z=d.z+(a*g.z+s*f.z),o.push(u.x,u.y,u.z),c.subVectors(u,d).normalize(),l.push(c.x,c.y,c.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 Bt(o,3)),this.setAttribute("normal",new Bt(l,3)),this.setAttribute("uv",new Bt(h,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new ov(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}},lv=class extends Ot{constructor(e=new sb(new k(-1,-1,0),new k(-1,1,0),new k(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 k,o=new k,l=new _e,h=new k,u=[],c=[],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(),c.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,u.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 Bt(u,3)),this.setAttribute("normal",new Bt(c,3)),this.setAttribute("uv",new Bt(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 lv((new kU[e.path.type]).fromJSON(e.path),e.tubularSegments,e.radius,e.radialSegments,e.closed)}},gA=class extends Ot{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},null!==e){let t=[],n=new Set,i=new k,r=new k;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===wue(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===wue(i,r,n)&&(t.push(i.x,i.y,i.z),t.push(r.x,r.y,r.z))}}this.setAttribute("position",new Bt(t,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}};function wue(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 Sue=Object.freeze({__proto__:null,BoxGeometry:ma,CapsuleGeometry:ev,CircleGeometry:tv,ConeGeometry:nv,CylinderGeometry:Sc,DodecahedronGeometry:rv,EdgesGeometry:Au,ExtrudeGeometry:Ws,IcosahedronGeometry:iv,LatheGeometry:dm,OctahedronGeometry:pm,PlaneGeometry:mi,PolyhedronGeometry:Mu,RingGeometry:sv,ShapeGeometry:Al,SphereGeometry:Va,TetrahedronGeometry:av,TorusGeometry:ef,TorusKnotGeometry:ov,TubeGeometry:lv,WireframeGeometry:gA}),vA=class extends Ar{constructor(e){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new ct(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}},yA=class extends hn{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}},za=class extends Ar{constructor(e){super(),this.isMeshStandardMaterial=!0,this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new ct(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 ct(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=sf,this.normalScale=new _e(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}},Go=class extends za{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new _e(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return hs(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 ct(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 ct(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new ct(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.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}},ta=class extends Ar{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new ct(16777215),this.specular=new ct(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ct(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=sf,this.normalScale=new _e(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=yb,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}},xA=class extends Ar{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new ct(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ct(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=sf,this.normalScale=new _e(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}},tf=class extends Ar{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=sf,this.normalScale=new _e(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}},Ru=class extends Ar{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new ct(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ct(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=sf,this.normalScale=new _e(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=yb,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}},bA=class extends Ar{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new ct(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=sf,this.normalScale=new _e(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}},Cu=class extends zn{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 El(e,t,n){return FU(e)?new e.constructor(e.subarray(t,void 0!==n?n:e.length)):e.slice(t,n)}function im(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 FU(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Zhe(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 HB(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 NU(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 klt(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=im(o,e.times.constructor),e.values=im(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 Flt(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,u=r.getValueSize();r.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(h=u/3);let c,d=t.times.length-1;if(a<=t.times[0]){let e=o,n=l-o;c=El(t.values,e,n)}else if(a>=t.times[d]){let e=d*l+o,n=e+l-o;c=El(t.values,e,n)}else{let e=t.createInterpolant(),n=o,i=l-o;e.evaluate(a),c=El(e.resultBuffer,n,i)}"quaternion"===i&&(new _r).fromArray(c).normalize().conjugate().toArray(c);let p=r.times.length;for(let e=0;e<p;++e){let t=e*u+h;if("quaternion"===i)_r.multiplyQuaternionsFlat(r.values,t,c,0,r.values,t);else{let e=u-2*h;for(let n=0;n<e;++n)r.values[t+n]-=c[n]}}}return e.blendMode=RU,e}var Nlt={arraySlice:El,convertArray:im,isTypedArray:FU,getKeyframeOrder:Zhe,sortedArray:HB,flattenJSON:NU,subclip:klt,makeClipAdditive:Flt},qh=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_(){}},EA=class extends qh{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:nm,endingEnd:nm}}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 rm:r=e,s=2*t-n;break;case jx: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 rm:a=e,o=2*n-t;break;case jx: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,u=this._offsetNext,c=this._weightPrev,d=this._weightNext,p=(n-t)/(i-t),f=p*p,m=f*p,g=-c*m+2*c*f-c*p,v=(1+c)*m+(-1.5-2*c)*f+(-.5+c)*p+1,y=(-1-d)*m+(1.5+d)*f+.5*p,x=d*m-d*f;for(let b=0;b!==s;++b)r[b]=g*a[h+b]+v*a[l+b]+y*a[o+b]+x*a[u+b];return r}},cb=class extends qh{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),u=1-h;for(let c=0;c!==s;++c)r[c]=a[l+c]*u+a[o+c]*h;return r}},_A=class extends qh{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e){return this.copySampleValue_(e-1)}},qo=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=im(t,this.TimeBufferType),this.values=im(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:im(e.times,Array),values:im(e.values,Array)};let n=e.getInterpolation();n!==e.DefaultInterpolation&&(t.interpolation=n)}return t.type=e.ValueTypeName,t}InterpolantFactoryMethodDiscrete(e){return new _A(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new cb(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new EA(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case Bh:t=this.InterpolantFactoryMethodDiscrete;break;case Eu:t=this.InterpolantFactoryMethodLinear;break;case eA: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 Bh;case this.InterpolantFactoryMethodLinear:return Eu;case this.InterpolantFactoryMethodSmooth:return eA}}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=El(n,r,a),this.values=El(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&&FU(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=El(this.times),t=El(this.values),n=this.getValueSize(),i=this.getInterpolation()===eA,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=El(e,0,a),this.values=El(t,0,a*n)):(this.times=e,this.values=t),this}clone(){let e=El(this.times,0),t=El(this.values,0),n=new(0,this.constructor)(this.name,e,t);return n.createInterpolant=this.createInterpolant,n}};qo.prototype.TimeBufferType=Float32Array,qo.prototype.ValueBufferType=Float32Array,qo.prototype.DefaultInterpolation=Eu;var Wh=class extends qo{};Wh.prototype.ValueTypeName="bool",Wh.prototype.ValueBufferType=Array,Wh.prototype.DefaultInterpolation=Bh,Wh.prototype.InterpolantFactoryMethodLinear=void 0,Wh.prototype.InterpolantFactoryMethodSmooth=void 0;var ub=class extends qo{};ub.prototype.ValueTypeName="color";var Rl=class extends qo{};Rl.prototype.ValueTypeName="number";var TA=class extends qh{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)_r.slerpFlat(r,0,a,l-s,a,l,o);return r}},Ga=class extends qo{InterpolantFactoryMethodLinear(e){return new TA(this.times,this.values,this.getValueSize(),e)}};Ga.prototype.ValueTypeName="quaternion",Ga.prototype.DefaultInterpolation=Eu,Ga.prototype.InterpolantFactoryMethodSmooth=void 0;var jh=class extends qo{};jh.prototype.ValueTypeName="string",jh.prototype.ValueBufferType=Array,jh.prototype.DefaultInterpolation=Bh,jh.prototype.InterpolantFactoryMethodLinear=void 0,jh.prototype.InterpolantFactoryMethodSmooth=void 0;var qa=class extends qo{};qa.prototype.ValueTypeName="vector";var po=class{constructor(e,t=-1,n,i=FA){this.name=e,this.tracks=n,this.duration=t,this.blendMode=i,this.uuid=zo(),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(Ult(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(qo.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=Zhe(e);e=HB(e,1,l),o=HB(o,1,l),!i&&0===e[0]&&(e.push(r),o.push(o[0])),a.push(new Rl(".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=[];NU(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 Rl(".morphTargetInfluence["+r+"]",n,a))}o=n.length*a}else{let r=".bones["+t[h].name+"]";n(qa,r+".position",e,"pos",i),n(Ga,r+".quaternion",e,"rot",i),n(qa,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 Blt(e){switch(e.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Rl;case"vector":case"vector2":case"vector3":case"vector4":return qa;case"color":return ub;case"quaternion":return Ga;case"bool":case"boolean":return Wh;case"string":return jh}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+e)}function Ult(e){if(void 0===e.type)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");let t=Blt(e.type);if(void 0===e.times){let t=[],n=[];NU(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={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={}}},nf=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}}},UA=new nf,xr=class{constructor(e){this.manager=void 0!==e?e:UA,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}};xr.DEFAULT_MATERIAL_NAME="__DEFAULT";var Ph={},VB=class extends Error{constructor(e,t){super(e),this.response=t}},Zr=class extends xr{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=mm.get(e);if(void 0!==r)return this.manager.itemStart(e),setTimeout((()=>{t&&t(r),this.manager.itemEnd(e)}),0),r;if(void 0!==Ph[e])return void Ph[e].push({onLoad:t,onProgress:n,onError:i});Ph[e]=[],Ph[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=Ph[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 VB(`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=>{mm.add(e,t);let n=Ph[e];delete Ph[e];for(let e=0,i=n.length;e<i;e++){let i=n[e];i.onLoad&&i.onLoad(t)}})).catch((t=>{let n=Ph[e];if(void 0===n)throw this.manager.itemError(e),t;delete Ph[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}},zB=class extends xr{constructor(e){super(e)}load(e,t,n,i){let r=this,a=new Zr(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=po.parse(e[n]);t.push(i)}return t}},GB=class extends xr{constructor(e){super(e)}load(e,t,n,i){let r=this,a=[],s=new wu,o=new Zr(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=Xr),s.image=a,s.format=n.format,s.needsUpdate=!0,t&&t(s))}),n,i)}if(Array.isArray(e))for(let u=0,c=e.length;u<c;++u)h(u);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=Xr),s.format=n.format,s.needsUpdate=!0,t&&t(s)}),n,i);return s}},Xh=class extends xr{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=mm.get(e);if(void 0!==a)return r.manager.itemStart(e),setTimeout((function(){t&&t(a),r.manager.itemEnd(e)}),0),a;let s=$x("img");function o(){h(),mm.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}},hb=class extends xr{constructor(e){super(e)}load(e,t,n,i){let r=new cm;r.colorSpace=sn;let a=new Xh(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}},gm=class extends xr{constructor(e){super(e)}load(e,t,n,i){let r=this,a=new _l,s=new Zr(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;try{n=r.parse(e)}catch(e){if(void 0===i)return void console.error(e);i(e)}if(!n)return i();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:Pi,a.wrapT=void 0!==n.wrapT?n.wrapT:Pi,a.magFilter=void 0!==n.magFilter?n.magFilter:Xr,a.minFilter=void 0!==n.minFilter?n.minFilter:Xr,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=Ba),1===n.mipmapCount&&(a.minFilter=Xr),void 0!==n.generateMipmaps&&(a.generateMipmaps=n.generateMipmaps),a.needsUpdate=!0,t&&t(a,n)}),n,i),a}},ws=class extends xr{constructor(e){super(e)}load(e,t,n,i){let r=new Hr,a=new Xh(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}},Cl=class extends an{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new ct(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}},Pu=class extends Cl{constructor(e,t,n){super(e,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(an.DEFAULT_UP),this.updateMatrix(),this.groundColor=new ct(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}},NN=new ht,Mue=new k,Aue=new k,db=class{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new _e(512,512),this.map=null,this.mapPass=null,this.matrix=new ht,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new wl,this._frameExtents=new _e(1,1),this._viewportCount=1,this._viewports=[new mr(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera,n=this.matrix;Mue.setFromMatrixPosition(e.matrixWorld),t.position.copy(Mue),Aue.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(Aue),t.updateMatrixWorld(),NN.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(NN),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(NN)}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}},qB=class extends db{constructor(){super(new Yr(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){let t=this.camera,n=2*Y0*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}},Iu=class extends Cl{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(an.DEFAULT_UP),this.updateMatrix(),this.target=new an,this.distance=n,this.angle=i,this.penumbra=r,this.decay=a,this.map=null,this.shadow=new qB}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}},Rue=new ht,Nx=new k,BN=new k,WB=class extends db{constructor(){super(new Yr(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new _e(4,2),this._viewportCount=6,this._viewports=[new mr(2,1,1,1),new mr(0,1,1,1),new mr(3,1,1,1),new mr(1,1,1,1),new mr(3,0,1,1),new mr(1,0,1,1)],this._cubeDirections=[new k(1,0,0),new k(-1,0,0),new k(0,0,1),new k(0,0,-1),new k(0,1,0),new k(0,-1,0)],this._cubeUps=[new k(0,1,0),new k(0,1,0),new k(0,1,0),new k(0,1,0),new k(0,0,1),new k(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()),Nx.setFromMatrixPosition(e.matrixWorld),n.position.copy(Nx),BN.copy(n.position),BN.add(this._cubeDirections[t]),n.up.copy(this._cubeUps[t]),n.lookAt(BN),n.updateMatrixWorld(),i.makeTranslation(-Nx.x,-Nx.y,-Nx.z),Rue.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Rue)}},Mc=class extends Cl{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 WB}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}},jB=class extends db{constructor(){super(new xi(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},va=class extends Cl{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(an.DEFAULT_UP),this.updateMatrix(),this.target=new an,this.shadow=new jB}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}},mo=class extends Cl{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}},wA=class extends Cl{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}},SA=class{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new k)}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)}},cv=class extends Cl{constructor(e=new SA,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}},uv=class extends xr{constructor(e){super(e),this.textures={}}load(e,t,n,i){let r=this,a=new Zr(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=uv.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 ct).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.anisotropy&&(i.anisotropy=e.anisotropy),void 0!==e.anisotropyRotation&&(i.anisotropyRotation=e.anisotropyRotation),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.alphaHash&&(i.alphaHash=e.alphaHash),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 ct).setHex(t.value);break;case"v2":i.uniforms[r].value=(new _e).fromArray(t.value);break;case"v3":i.uniforms[r].value=(new k).fromArray(t.value);break;case"v4":i.uniforms[r].value=(new mr).fromArray(t.value);break;case"m3":i.uniforms[r].value=(new In).fromArray(t.value);break;case"m4":i.uniforms[r].value=(new ht).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 _e).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 _e).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.anisotropyMap&&(i.anisotropyMap=n(e.anisotropyMap)),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:vA,SpriteMaterial:tb,RawShaderMaterial:yA,ShaderMaterial:hn,PointsMaterial:Li,MeshPhysicalMaterial:Go,MeshStandardMaterial:za,MeshPhongMaterial:ta,MeshToonMaterial:xA,MeshNormalMaterial:tf,MeshLambertMaterial:Ru,MeshDepthMaterial:wc,MeshDistanceMaterial:eb,MeshBasicMaterial:cn,MeshMatcapMaterial:bA,LineDashedMaterial:Cu,LineBasicMaterial:zn,Material:Ar}[e]}},na=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)}},MA=class extends Ot{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}},AA=class extends xr{constructor(e){super(e)}load(e,t,n,i){let r=this,a=new Zr(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=G0(r.type,a),o=new Vh(s,r.stride);return o.uuid=r.uuid,t[i]=o,o}let r=e.isInstancedBufferGeometry?new MA:new Ot,a=e.data.index;if(void 0!==a){let e=G0(a.type,a.array);r.setIndex(new yn(e,1))}let s=e.data.attributes;for(let u in s){let t,n=s[u];if(n.isInterleavedBufferAttribute){let r=i(e.data,n.data);t=new fo(r,n.itemSize,n.offset,n.normalized)}else{let e=G0(n.type,n.array);t=new(n.isInstancedBufferAttribute?zh:yn)(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(u,t)}let o=e.data.morphAttributes;if(o)for(let u in o){let t=o[u],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 fo(t,s.itemSize,s.offset,s.normalized)}else{let e=G0(s.type,s.array);a=new yn(e,s.itemSize,s.normalized)}void 0!==s.name&&(a.name=s.name),n.push(a)}r.morphAttributes[u]=n}e.data.morphTargetsRelative&&(r.morphTargetsRelative=!0);let l=e.data.groups||e.data.drawcalls||e.data.offsets;if(void 0!==l)for(let u=0,c=l.length;u!==c;++u){let e=l[u];r.addGroup(e.start,e.count,e.materialIndex)}let h=e.data.boundingSphere;if(void 0!==h){let e=new k;void 0!==h.center&&e.fromArray(h.center),r.boundingSphere=new $r(e,h.radius)}return e.name&&(r.name=e.name),e.userData&&(r.userData=e.userData),r}},XB=class extends xr{constructor(e){super(e)}load(e,t,n,i){let r=this,a=""===this.path?na.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||a;let s=new Zr(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 it(this,null,(function*(){let n=""===this.path?na.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||n;let i=new Zr(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 it(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 Ts).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 Ml).fromJSON(e[r],i);n[t.uuid]=t}return n}parseGeometries(e,t){let n={};if(void 0!==e){let i=new AA;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 Sue?a=Sue[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 uv;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=po.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:G0(e.type,e.data),width:e.width,height:e.height}:null}if(void 0!==e&&e.length>0){let i=new nf(t);n=new Xh(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 _l(n.data,n.width,n.height)))}r[n.uuid]=new bc(e)}else{let e=a(n.url);r[n.uuid]=new bc(e)}}}return r}parseImagesAsync(e){return it(this,null,(function*(){let t,n=this,i={};function r(e){return it(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:G0(e.type,e.data),width:e.width,height:e.height}:null}))}if(void 0!==e&&e.length>0){t=new Xh(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 _l(i.data,i.width,i.height)))}i[n.uuid]=new bc(e)}else{let e=yield r(n.url);i[n.uuid]=new bc(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 cm,6===l.length&&(s.needsUpdate=!0)):(s=l&&l.data?new _l:new Hr,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,Hlt)),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],Cue),s.wrapT=n(a.wrap[1],Cue)),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,Pue)),void 0!==a.magFilter&&(s.magFilter=n(a.magFilter,Pue)),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.compareFunction&&(s.compareFunction=a.compareFunction),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 u(e){return void 0===i[e]&&console.warn("THREE.ObjectLoader: Undefined texture",e),i[e]}switch(e.type){case"Scene":a=new Ji,void 0!==e.background&&(Number.isInteger(e.background)?a.background=new ct(e.background):a.background=u(e.background)),void 0!==e.environment&&(a.environment=u(e.environment)),void 0!==e.fog&&("Fog"===e.fog.type?a.fog=new _u(e.fog.color,e.fog.near,e.fog.far):"FogExp2"===e.fog.type&&(a.fog=new K0(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 Yr(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 xi(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 mo(e.color,e.intensity);break;case"DirectionalLight":a=new va(e.color,e.intensity);break;case"PointLight":a=new Mc(e.color,e.intensity,e.distance,e.decay);break;case"RectAreaLight":a=new wA(e.color,e.intensity,e.width,e.height);break;case"SpotLight":a=new Iu(e.color,e.intensity,e.distance,e.angle,e.penumbra,e.decay);break;case"HemisphereLight":a=new Pu(e.color,e.groundColor,e.intensity);break;case"LightProbe":a=(new cv).fromJSON(e);break;case"SkinnedMesh":s=l(e.geometry),o=h(e.material),a=new Tu(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 St(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 Os(s,o,t),a.instanceMatrix=new zh(new Float32Array(n.array),16),void 0!==i&&(a.instanceColor=new zh(new Float32Array(i.array),i.itemSize));break;case"LOD":a=new hA;break;case"Line":a=new Vr(l(e.geometry),h(e.material));break;case"LineLoop":a=new J0(l(e.geometry),h(e.material));break;case"LineSegments":a=new zr(l(e.geometry),h(e.material));break;case"PointCloud":case"Points":a=new Di(l(e.geometry),h(e.material));break;case"Sprite":a=new uA(h(e.material));break;case"Group":a=new Bn;break;case"Bone":a=new Sl;break;default:a=new an}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)}}))}},Hlt={UVMapping:DA,CubeReflectionMapping:kh,CubeRefractionMapping:Zd,EquirectangularReflectionMapping:om,EquirectangularRefractionMapping:Wx,CubeUVReflectionMapping:pv},Cue={RepeatWrapping:Ii,ClampToEdgeWrapping:Pi,MirroredRepeatWrapping:Fh},Pue={NearestFilter:Jr,NearestMipmapNearestFilter:Kd,NearestMipmapLinearFilter:Oh,LinearFilter:Xr,LinearMipmapNearestFilter:bm,LinearMipmapLinearFilter:Ba},fb=class extends xr{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=mm.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){mm.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)}},zM,pb=class{static getContext(){return void 0===zM&&(zM=new(window.AudioContext||window.webkitAudioContext)),zM}static setContext(e){zM=e}},YB=class extends xr{constructor(e){super(e)}load(e,t,n,i){let r=this,a=new Zr(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);pb.getContext().decodeAudioData(n,(function(e){t(e)}),s)}catch(e){s(e)}}),n,i)}},$B=class extends cv{constructor(e,t,n=1){super(void 0,n),this.isHemisphereLightProbe=!0;let i=(new ct).set(e),r=(new ct).set(t),a=new k(i.r,i.g,i.b),s=new k(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)}},ZB=class extends cv{constructor(e,t=1){super(void 0,t),this.isAmbientLightProbe=!0;let n=(new ct).set(e);this.sh.coefficients[0].set(n.r,n.g,n.b).multiplyScalar(2*Math.sqrt(Math.PI))}},Iue=new ht,Lue=new ht,$p=new ht,KB=class{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new Yr,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new Yr,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,$p.copy(e.projectionMatrix);let n,i,r=t.eyeSep/2,a=r*t.near/t.focus,s=t.near*Math.tan(am*t.fov*.5)/t.zoom;Lue.elements[12]=-r,Iue.elements[12]=r,n=-s*t.aspect+a,i=s*t.aspect+a,$p.elements[0]=2*t.near/(i-n),$p.elements[8]=(i+n)/(i-n),this.cameraL.projectionMatrix.copy($p),n=-s*t.aspect-a,i=s*t.aspect-a,$p.elements[0]=2*t.near/(i-n),$p.elements[8]=(i+n)/(i-n),this.cameraR.projectionMatrix.copy($p)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(Lue),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(Iue)}},Pl=class{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=Due(),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=Due();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}};function Due(){return("undefined"==typeof performance?Date:performance).now()}var Zp=new k,Oue=new _r,Vlt=new k,Kp=new k,JB=class extends an{constructor(){super(),this.type="AudioListener",this.context=pb.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new Pl}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(Zp,Oue,Vlt),Kp.set(0,0,-1).applyQuaternion(Oue),t.positionX){let e=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(Zp.x,e),t.positionY.linearRampToValueAtTime(Zp.y,e),t.positionZ.linearRampToValueAtTime(Zp.z,e),t.forwardX.linearRampToValueAtTime(Kp.x,e),t.forwardY.linearRampToValueAtTime(Kp.y,e),t.forwardZ.linearRampToValueAtTime(Kp.z,e),t.upX.linearRampToValueAtTime(n.x,e),t.upY.linearRampToValueAtTime(n.y,e),t.upZ.linearRampToValueAtTime(n.z,e)}else t.setPosition(Zp.x,Zp.y,Zp.z),t.setOrientation(Kp.x,Kp.y,Kp.z,n.x,n.y,n.z)}},RA=class extends an{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}},Jp=new k,kue=new _r,zlt=new k,Qp=new k,QB=class extends RA{constructor(e){super(e),this.panner=this.context.createPanner(),this.panner.panningModel="HRTF",this.panner.connect(this.gain)}connect(){super.connect(),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(Jp,kue,zlt),Qp.set(0,0,1).applyQuaternion(kue);let t=this.panner;if(t.positionX){let e=this.context.currentTime+this.listener.timeDelta;t.positionX.linearRampToValueAtTime(Jp.x,e),t.positionY.linearRampToValueAtTime(Jp.y,e),t.positionZ.linearRampToValueAtTime(Jp.z,e),t.orientationX.linearRampToValueAtTime(Qp.x,e),t.orientationY.linearRampToValueAtTime(Qp.y,e),t.orientationZ.linearRampToValueAtTime(Qp.z,e)}else t.setPosition(Jp.x,Jp.y,Jp.z),t.setOrientation(Qp.x,Qp.y,Qp.z)}},eU=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}},CA=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){_r.slerpFlat(e,t,e,t,e,n,i)}_slerpAdditive(e,t,n,i,r){let a=this._workIndex*r;_r.multiplyQuaternionsFlat(e,a,e,t,e,n),_r.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}}},BU="\\[\\]\\.:\\/",Glt=new RegExp("["+BU+"]","g"),UU="[^"+BU+"]",qlt="[^"+BU.replace("\\.","")+"]",Wlt=/((?:WC+[\/:])*)/.source.replace("WC",UU),jlt=/(WCOD+)?/.source.replace("WCOD",qlt),Xlt=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",UU),Ylt=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",UU),$lt=new RegExp("^"+Wlt+jlt+Xlt+Ylt+"$"),Zlt=["material","materials","bones","map"],tU=class{constructor(e,t,n){let i=n||Jn.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()}},Jn=class{constructor(e,t,n){this.path=t,this.parsedPath=n||Jn.parseTrackName(t),this.node=Jn.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 Jn.Composite(e,t,n):new Jn(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(Glt,"")}static parseTrackName(e){let t=$lt.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!==Zlt.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=Jn.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e)return void console.warn("THREE.PropertyBinding: No target node found for track: "+this.path+".");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}};Jn.Composite=tU,Jn.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},Jn.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},Jn.prototype.GetterByBindingType=[Jn.prototype._getValue_direct,Jn.prototype._getValue_array,Jn.prototype._getValue_arrayElement,Jn.prototype._getValue_toArray],Jn.prototype.SetterByBindingTypeAndVersioning=[[Jn.prototype._setValue_direct,Jn.prototype._setValue_direct_setNeedsUpdate,Jn.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Jn.prototype._setValue_array,Jn.prototype._setValue_array_setNeedsUpdate,Jn.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Jn.prototype._setValue_arrayElement,Jn.prototype._setValue_arrayElement_setNeedsUpdate,Jn.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Jn.prototype._setValue_fromArray,Jn.prototype._setValue_fromArray_setNeedsUpdate,Jn.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var nU=class{constructor(){this.isAnimationObjectGroup=!0,this.uuid=zo(),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,u=arguments.length;h!==u;++h){let u=arguments[h],c=u.uuid,d=n[c];if(void 0===d){d=o++,n[c]=d,t.push(u);for(let e=0,t=s;e!==t;++e)a[e].push(new Jn(u,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[c]=o,t[o]=u;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 Jn(u,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,u=e[h];t[o.uuid]=l,e[l]=o,t[u.uuid]=s,e[s]=u,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_,u=new Array(l);i=r.length,n[e]=i,a.push(e),s.push(t),r.push(u);for(let c=h,d=o.length;c!==d;++c){let n=o[c];u[c]=new Jn(n,e,t)}return u}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()}}},PA=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:nm,endingEnd:nm};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=The,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===RU)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===whe;if(0===e)return-1===r?i:a&&1==(1&r)?t-i:i;if(n===_he){-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=rm,i.endingEnd=rm):(i.endingStart=e?this.zeroSlopeAtStart?rm:nm:jx,i.endingEnd=t?this.zeroSlopeAtEnd?rm:nm:jx)}_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}},Klt=new Float32Array(1),rU=class extends Tc{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 u=0;u!==r;++u){let e=i[u],r=e.name,l=h[r];if(void 0!==l)++l.referenceCount,a[u]=l;else{if(l=a[u],void 0!==l){null===l._cacheIndex&&(++l.referenceCount,this._addInactiveBinding(l,o,r));continue}let i=t&&t._propertyBindings[u].binding.parsedPath;l=new CA(Jn.create(n,r,i),e.ValueTypeName,e.getValueSize()),++l.referenceCount,this._addInactiveBinding(l,o,r),a[u]=l}s[u].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 cb(new Float32Array(2),new Float32Array(2),1,Klt),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?po.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:FA),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 PA(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?po.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))}},vm=class{constructor(e){this.value=e}clone(){return new vm(void 0===this.value.clone?this.value:this.value.clone())}},Jlt=0,iU=class extends Tc{constructor(){super(),this.isUniformsGroup=!0,Object.defineProperty(this,"id",{value:Jlt++}),this.name="",this.usage=Xx,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)}},sU=class extends Vh{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}},aU=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}},Ac=class{constructor(e,t,n=0,i=1/0){this.ray=new Tl(e,t),this.near=n,this.far=i,this.camera=null,this.layers=new Jd,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 oU(e,this,n,t),n.sort(Fue),n}intersectObjects(e,t=!0,n=[]){for(let i=0,r=e.length;i<r;i++)oU(e[i],this,n,t);return n.sort(Fue),n}};function Fue(e,t){return e.distance-t.distance}function oU(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++)oU(i[e],t,n,!0)}}var lU=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(hs(t/this.radius,-1,1))),this}clone(){return(new this.constructor).copy(this)}},cU=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)}},Nue=new _e,_i=class{constructor(e=new _e(1/0,1/0),t=new _e(-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=Nue.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,Nue).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)}},Bue=new k,GM=new k,ra=class{constructor(e=new k,t=new k){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){Bue.subVectors(e,this.start),GM.subVectors(this.end,this.start);let n=GM.dot(GM),i=GM.dot(Bue)/n;return t&&(i=hs(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)}},Uue=new k,uU=class extends an{constructor(e,t){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";let n=new Ot,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 Bt(i,3));let r=new zn({fog:!1,toneMapped:!1});this.cone=new zr(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),Uue.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(Uue),void 0!==this.color?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}},Yd=new k,qM=new ht,UN=new ht,hU=class extends zr{constructor(e){let t=Khe(e),n=new Ot,i=[],r=[],a=new ct(0,0,1),s=new ct(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 Bt(i,3)),n.setAttribute("color",new Bt(r,3)),super(n,new zn({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");UN.copy(this.root.matrixWorld).invert();for(let r=0,a=0;r<t.length;r++){let e=t[r];e.parent&&e.parent.isBone&&(qM.multiplyMatrices(UN,e.matrixWorld),Yd.setFromMatrixPosition(qM),i.setXYZ(a,Yd.x,Yd.y,Yd.z),qM.multiplyMatrices(UN,e.parent.matrixWorld),Yd.setFromMatrixPosition(qM),i.setXYZ(a+1,Yd.x,Yd.y,Yd.z),a+=2)}n.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(e)}dispose(){this.geometry.dispose(),this.material.dispose()}};function Khe(e){let t=[];!0===e.isBone&&t.push(e);for(let n=0;n<e.children.length;n++)t.push.apply(t,Khe(e.children[n]));return t}var dU=class extends St{constructor(e,t,n){super(new Va(t,4,2),new cn({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)}},Qlt=new k,Hue=new ct,Vue=new ct,fU=class extends an{constructor(e,t,n){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=n,this.type="HemisphereLightHelper";let i=new pm(t);i.rotateY(.5*Math.PI),this.material=new cn({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 yn(a,3)),this.add(new St(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");Hue.copy(this.light.color),Vue.copy(this.light.groundColor);for(let e=0,n=t.count;e<n;e++){let i=e<n/2?Hue:Vue;t.setXYZ(e,i.r,i.g,i.b)}t.needsUpdate=!0}this.light.updateWorldMatrix(!0,!1),e.lookAt(Qlt.setFromMatrixPosition(this.light.matrixWorld).negate())}},mb=class extends zr{constructor(e=10,t=10,n=4473924,i=8947848){n=new ct(n),i=new ct(i);let r=t/2,a=e/t,s=e/2,o=[],l=[];for(let u=0,c=0,d=-s;u<=t;u++,d+=a){o.push(-s,0,d,s,0,d),o.push(d,0,-s,d,0,s);let e=u===r?n:i;e.toArray(l,c),c+=3,e.toArray(l,c),c+=3,e.toArray(l,c),c+=3,e.toArray(l,c),c+=3}let h=new Ot;h.setAttribute("position",new Bt(o,3)),h.setAttribute("color",new Bt(l,3)),super(h,new zn({vertexColors:!0,toneMapped:!1})),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}},pU=class extends zr{constructor(e=10,t=16,n=8,i=64,r=4473924,a=8947848){r=new ct(r),a=new ct(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 u=1&h?r:a;o.push(u.r,u.g,u.b),o.push(u.r,u.g,u.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 Ot;l.setAttribute("position",new Bt(s,3)),l.setAttribute("color",new Bt(o,3)),super(l,new zn({vertexColors:!0,toneMapped:!1})),this.type="PolarGridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}},zue=new k,WM=new k,Gue=new k,gb=class extends an{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 Ot;i.setAttribute("position",new Bt([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));let r=new zn({fog:!1,toneMapped:!1});this.lightPlane=new Vr(i,r),this.add(this.lightPlane),i=new Ot,i.setAttribute("position",new Bt([0,0,0,0,0,1],3)),this.targetLine=new Vr(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),zue.setFromMatrixPosition(this.light.matrixWorld),WM.setFromMatrixPosition(this.light.target.matrixWorld),Gue.subVectors(WM,zue),this.lightPlane.lookAt(WM),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(WM),this.targetLine.scale.z=Gue.length()}},jM=new k,us=new Uh,vb=class extends zr{constructor(e){let t=new Ot,n=new zn({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 Bt(i,3)),t.setAttribute("color",new Bt(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 ct(16755200),h=new ct(16711680),u=new ct(43775),c=new ct(16777215),d=new ct(3355443);this.setColors(l,h,u,c,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;us.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),gs("c",t,e,us,0,0,-1),gs("t",t,e,us,0,0,1),gs("n1",t,e,us,-1,-1,-1),gs("n2",t,e,us,1,-1,-1),gs("n3",t,e,us,-1,1,-1),gs("n4",t,e,us,1,1,-1),gs("f1",t,e,us,-1,-1,1),gs("f2",t,e,us,1,-1,1),gs("f3",t,e,us,-1,1,1),gs("f4",t,e,us,1,1,1),gs("u1",t,e,us,.7,1.1,-1),gs("u2",t,e,us,-.7,1.1,-1),gs("u3",t,e,us,0,2,-1),gs("cf1",t,e,us,-1,0,1),gs("cf2",t,e,us,1,0,1),gs("cf3",t,e,us,0,-1,1),gs("cf4",t,e,us,0,1,1),gs("cn1",t,e,us,-1,0,-1),gs("cn2",t,e,us,1,0,-1),gs("cn3",t,e,us,0,-1,-1),gs("cn4",t,e,us,0,1,-1),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function gs(e,t,n,i,r,a,s){jM.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],jM.x,jM.y,jM.z)}}var XM=new Nt,mU=class extends zr{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 Ot;r.setIndex(new yn(n,1)),r.setAttribute("position",new yn(i,3)),super(r,new zn({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&&XM.setFromObject(this.object),XM.isEmpty())return;let t=XM.min,n=XM.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()}},gU=class extends zr{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 Ot;i.setIndex(new yn(n,1)),i.setAttribute("position",new Bt([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 zn({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()}},vU=class extends Vr{constructor(e,t=1,n=16776960){let i=n,r=new Ot;r.setAttribute("position",new Bt([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 zn({color:i,toneMapped:!1})),this.type="PlaneHelper",this.plane=e,this.size=t;let a=new Ot;a.setAttribute("position",new Bt([1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],3)),a.computeBoundingSphere(),this.add(new St(a,new cn({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()}},que=new k,YM,HN,Rc=class extends an{constructor(e=new k(0,0,1),t=new k(0,0,0),n=1,i=16776960,r=.2*n,a=.2*r){super(),this.type="ArrowHelper",void 0===YM&&((YM=new Ot).setAttribute("position",new Bt([0,0,0,0,1,0],3)),(HN=new Sc(0,.5,1,5,1)).translate(0,-.5,0)),this.position.copy(t),this.line=new Vr(YM,new zn({color:i,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new St(HN,new cn({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{que.set(e.z,0,-e.x).normalize();let t=Math.acos(e.y);this.quaternion.setFromAxisAngle(que,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()}},yU=class extends zr{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 Ot;n.setAttribute("position",new Bt(t,3)),n.setAttribute("color",new Bt([1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],3)),super(n,new zn({vertexColors:!0,toneMapped:!1})),this.type="AxesHelper"}setColors(e,t,n){let i=new ct,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()}},ym=class{constructor(){this.type="ShapePath",this.color=new ct,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new Su,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=qs.isClockWise,i=this.subPaths;if(0===i.length)return[];let r,a,s,o=[];if(1===i.length)return a=i[0],s=new Ts,s.curves=a.curves,o.push(s),o;let l=!n(i[0].getPoints());l=e?!l:l;let h,u,c=[],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 Ts,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 Ts;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++)c[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,c[r].push(s)):e=!0);o&&c[i].push(s)}}n>0&&!1===e&&(p=c)}for(let m=0,g=d.length;m<g;m++){s=d[m].s,o.push(s),u=p[m];for(let e=0,t=u.length;e<t;e++)s.holes.push(u[e].h)}return o}};"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:IA}})),"undefined"!=typeof window&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=IA);var Lu=new $r,Jhe=new k,Qhe=new k,ede=new k,tde=new k;function HA(e,t,n,i,r,a,s){if(Jhe.fromBufferAttribute(t,i).applyMatrix4(e.matrixWorld),Qhe.fromBufferAttribute(t,r).applyMatrix4(e.matrixWorld),n.ray.distanceSqToSegment(Jhe,Qhe,tde,ede)>a)return!1;let o=n.ray.origin.distanceTo(tde);return!(o<n.near||o>n.far)&&(s.push({distance:o,point:ede.clone(),index:i,object:e}),!0)}Vr.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(),Lu.copy(n.boundingSphere),Lu.applyMatrix4(i),Lu.radius+=r,!1===e.ray.intersectsSphere(Lu))return;let s=r*r,o=this.isLineSegments?2:1,l=n.index,h=n.attributes.position,u=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(Lu.copy(a.boundingSphere),Lu.applyMatrix4(i),!1!==e.ray.intersectsSphere(Lu))for(let n=a.indexStart,i=a.indexStart+a.indexCount-1;n<i;n+=o)if(HA(this,h,e,l.getX(n),l.getX(n+1),s,t)&&(t[t.length-1].index=n,t.length-u>=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(HA(this,h,e,l.getX(i),l.getX(i+1),s,t)&&(t[t.length-1].index=i,t.length-u>=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(Lu.copy(a.boundingSphere),Lu.applyMatrix4(i),!1!==e.ray.intersectsSphere(Lu))for(let n=a.positionStart,i=a.positionStart+a.positionCount-1;n<i;n+=o)if(HA(this,h,e,n,n+1,s,t)&&t.length-u>=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(HA(this,h,e,i,i+1,s,t)&&t.length-u>=1)return}};var nde=Math.pow(2,-24),_m=class{constructor(){}};function Il(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 HU(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 VU(e,t){t.set(e)}function zU(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 bb(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 bv(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 nct(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 yn(n,1));for(let e=0;e<i;e++)n[e]=e}}function rct(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 qU(e,t,n,i,r=null){let a=1/0,s=1/0,o=1/0,l=-1/0,h=-1/0,u=-1/0,c=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<c&&(c=t),v&&t>f&&(f=t);let x=e[y+2],b=e[y+3],_=x-b,w=x+b;_<s&&(s=_),w>h&&(h=w),v&&x<d&&(d=x),v&&x>m&&(m=x);let S=e[y+4],M=e[y+5],E=S-M,T=S+M;E<o&&(o=E),T>u&&(u=T),v&&S<p&&(p=S),v&&S>g&&(g=S)}i[0]=a,i[1]=s,i[2]=o,i[3]=l,i[4]=h,i[5]=u,v&&(r[0]=c,r[1]=d,r[2]=p,r[3]=f,r[4]=m,r[5]=g)}function ict(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 u=6*t,c=6*(t+n);u<c;u+=6){let t=e[u+0];t<r&&(r=t),t>o&&(o=t);let n=e[u+2];n<a&&(a=n),n>l&&(l=n);let i=e[u+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 sct(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 Yh=32,act=(e,t)=>e.candidate-t.candidate,af=new Array(Yh).fill().map((()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0}))),VA=new Float32Array(6);function oct(e,t,n,i,r,a){let s=-1,o=0;if(0===a)s=HU(t),-1!==s&&(o=(t[s]+t[s+3])/2);else if(1===a)s=HU(e),-1!==s&&(o=lct(n,i,r,s));else if(2===a){let a=bv(e),l=1.25*r,h=6*i,u=6*(i+r);for(let e=0;e<3;e++){let i=t[e],c=(t[e+3]-i)/Yh;if(r<Yh/4){let t=[...af];t.length=r;let i=0;for(let r=h;r<u;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;bb(r,n,s)}t.sort(act);let c=r;for(let e=0;e<c;e++){let n=t[e];for(;e+1<c&&t[e+1].candidate===n.candidate;)t.splice(e+1,1),c--}for(let r=h;r<u;r+=6){let i=n[r+2*e];for(let e=0;e<c;e++){let a=t[e];i>=a.candidate?bb(r,n,a.rightCacheBounds):(bb(r,n,a.leftCacheBounds),a.count++)}}for(let n=0;n<c;n++){let i=t[n],h=i.count,u=r-i.count,c=i.leftCacheBounds,d=i.rightCacheBounds,p=0;0!==h&&(p=bv(c)/a);let f=0;0!==u&&(f=bv(d)/a);let m=1+1.25*(p*h+f*u);m<l&&(s=e,l=m,o=i.candidate)}}else{for(let e=0;e<Yh;e++){let t=af[e];t.count=0,t.candidate=i+c+e*c;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<u;r+=6){let t=~~((n[r+2*e]-i)/c);t>=Yh&&(t=Yh-1);let a=af[t];a.count++,bb(r,n,a.bounds)}let t=af[Yh-1];VU(t.bounds,t.rightCacheBounds);for(let e=Yh-2;e>=0;e--){let t=af[e],n=af[e+1];zU(t.bounds,n.rightCacheBounds,t.rightCacheBounds)}let d=0;for(let n=0;n<Yh-1;n++){let t=af[n],i=t.count,h=t.bounds,u=af[n+1].rightCacheBounds;0!==i&&(0===d?VU(h,VA):zU(h,VA,VA)),d+=i;let c=0,p=0;0!==d&&(c=bv(VA)/a);let f=r-d;0!==f&&(p=bv(u)/a);let m=1+1.25*(c*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 lct(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 cct(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 u=["getX","getY","getZ"];for(let c=0;c<r;c++){let e,r,d,p=3*c,f=6*c;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,c;s?(l=n[u[i]](e),h=n[u[i]](r),c=n[u[i]](d)):(l=o[e+i],h=o[r+i],c=o[d+i]);let p=l;h<p&&(p=h),c<p&&(p=c);let m=l;h>m&&(m=h),c>m&&(m=c);let g=(m-p)/2,v=2*i;a[f+v+0]=p+g,a[f+v+1]=g+(Math.abs(p)+g)*nde,p<t[i]&&(t[i]=p),m>t[i+3]&&(t[i+3]=m)}}return a}function uct(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<=u||m>=l)return n(r+d),t.offset=r,t.count=d,t;let g=oct(t.boundingData,p,s,r,d,c);if(-1===g.axis)return n(r+d),t.offset=r,t.count=d,t;let v=sct(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 _m,n=r,o=v-r;t.left=e,e.boundingData=new Float32Array(6),qU(s,n,o,e.boundingData,a),i(e,n,o,a,m+1);let l=new _m,h=v,u=d-o;t.right=l,l.boundingData=new Float32Array(6),qU(s,h,u,l.boundingData,a),i(l,h,u,a,m+1)}return t}nct(e,t);let r=new Float32Array(6),a=new Float32Array(6),s=cct(e,r),o=e.index.array,l=t.maxDepth,h=t.verbose,u=t.maxLeafTris,c=t.strategy,d=t.onProgress,p=e.index.count/3,f=!1,m=[],g=rct(e);if(1===g.length){let e=g[0],t=new _m;t.boundingData=r,ict(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 _m;e.boundingData=new Float32Array(6),qU(s,v.offset,v.count,e.boundingData,a),i(e,v.offset,v.count,a),m.push(e)}return m}function sde(e,t){let n,i,r,a=uct(e,t),s=[],o=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;for(let u=0;u<a.length;u++){let e=a[u],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 go=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}};go.prototype.setFromBox=function(){let e=new k;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 XIt=function(){let e=new go;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}}}(),hct=function(){let e=new k,t=new k,n=new k;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 u,c,d=n.dot(h),p=h.dot(o),f=h.dot(h),m=n.dot(o),g=o.dot(o)*f-p*p;u=0!==g?(d*p-m*f)/g:0,c=(d+u*p)/f,a.x=u,a.y=c}}(),Eb=function(){let e=new _e,t=new k,n=new k;return function(i,r,a,s){hct(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 u=t,c=n;return i.closestPointToPoint(h,!0,t),r.closestPointToPoint(e,!0,n),u.distanceToSquared(h)<=c.distanceToSquared(e)?(a.copy(u),void s.copy(h)):(a.copy(e),void s.copy(c))}}}(),ade=function(){let e=new k,t=new k,n=new Ur,i=new ra;return function(r,a){let{radius:s,center:o}=r,{a:l,b:h,c:u}=a;if(i.start=l,i.end=h,i.closestPointToPoint(o,!0,e).distanceTo(o)<=s||(i.start=l,i.end=u,i.closestPointToPoint(o,!0,e).distanceTo(o)<=s)||(i.start=h,i.end=u,i.closestPointToPoint(o,!0,e).distanceTo(o)<=s))return!0;let c=a.getPlane(n);if(Math.abs(c.distanceToPoint(o))<=s){let e=c.projectPoint(o,t);if(a.containsPoint(e))return!0}return!1}}(),dct=1e-15;function Ev(e){return Math.abs(e)<dct}var vo=class extends ni{constructor(...e){super(...e),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map((()=>new k)),this.satBounds=new Array(4).fill().map((()=>new go)),this.points=[this.a,this.b,this.c],this.sphere=new $r,this.plane=new Ur,this.needsUpdate=!0}intersectsSphere(e){return ade(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 u=r[2],c=a[2];u.subVectors(t,n),c.setFromPoints(u,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}};vo.prototype.closestPointToSegment=function(){let e=new k,t=new k,n=new ra;return function(i,r=null,a=null){let s,{start:o,end:l}=i,h=this.points,u=1/0;for(let c=0;c<3;c++){let o=(c+1)%3;n.start.copy(h[c]),n.end.copy(h[o]),Eb(n,i,e,t),s=e.distanceToSquared(t),s<u&&(u=s,r&&r.copy(e),a&&a.copy(t))}return this.closestPointToPoint(o,e),s=o.distanceToSquared(e),s<u&&(u=s,r&&r.copy(e),a&&a.copy(o)),this.closestPointToPoint(l,e),s=l.distanceToSquared(e),s<u&&(u=s,r&&r.copy(e),a&&a.copy(l)),Math.sqrt(u)}}(),vo.prototype.intersectsTriangle=function(){let e=new vo,t=new Array(3),n=new Array(3),i=new go,r=new go,a=new k,s=new k,o=new k,l=new k,h=new ra,u=new ra,c=new ra;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?u.start:u.end,l=Ev(g.distanceToPoint(i));if(Ev(g.normal.dot(s))&&l){u.copy(h),n=2;break}if((g.intersectLine(h,a)||l)&&!Ev(a.distanceTo(r))){if(n++,t)break;t=!0}}if(1===n&&d.containsPoint(u.end))return p&&(p.start.copy(u.end),p.end.copy(u.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?c.start:c.end,l=Ev(m.distanceToPoint(e));if(Ev(m.normal.dot(o))&&l){c.copy(h),a=2;break}if((m.intersectLine(h,n)||l)&&!Ev(n.distanceTo(t))){if(a++,r)break;r=!0}}if(1===a&&this.containsPoint(c.end))return p&&(p.start.copy(c.end),p.end.copy(c.end)),!0;if(2!==a)return!1;if(u.delta(s),c.delta(o),s.dot(o)<0){let e=c.start;c.start=c.end,c.end=e}let f=u.start.dot(s),v=u.end.dot(s),y=c.start.dot(s),x=c.end.dot(s);return(f===x||y===v||v<y!==f<x)&&(p&&(l.subVectors(u.start,c.start),l.dot(s)>0?p.start.copy(u.start):p.start.copy(c.start),l.subVectors(u.end,c.end),l.dot(s)<0?p.end.copy(u.end):p.end.copy(c.end)),!0)}}}(),vo.prototype.distanceToPoint=function(){let e=new k;return function(t){return this.closestPointToPoint(t,e),t.distanceTo(e)}}(),vo.prototype.distanceToTriangle=function(){let e=new k,t=new k,n=["a","b","c"],i=new ra,r=new ra;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 u=this[r];a.closestPointToPoint(u,e),i=u.distanceToSquared(e),i<h&&(h=i,s&&s.copy(u),o&&o.copy(e))}for(let u=0;u<3;u++){let l=n[u],c=n[(u+1)%3];i.set(this[l],this[c]);for(let u=0;u<3;u++){let l=n[u],c=n[(u+1)%3];r.set(a[l],a[c]),Eb(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 yo=class{constructor(e,t,n){this.isOrientedBox=!0,this.min=new k,this.max=new k,this.matrix=new ht,this.invMatrix=new ht,this.points=new Array(8).fill().map((()=>new k)),this.satAxes=new Array(3).fill().map((()=>new k)),this.satBounds=new Array(3).fill().map((()=>new go)),this.alignedSatBounds=new Array(3).fill().map((()=>new go)),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}};yo.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},yo.prototype.intersectsBox=function(){let e=new go;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}}(),yo.prototype.intersectsTriangle=function(){let e=new vo,t=new Array(3),n=new go,i=new go,r=new k;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,u=this.points;for(let e=0;e<3;e++){let t=l[e],i=h[e];if(n.setFromPoints(i,u),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,u),n.isSeparated(i))return!1}}return!0}}(),yo.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},yo.prototype.distanceToPoint=function(){let e=new k;return function(t){return this.closestPointToPoint(t,e),t.distanceTo(e)}}(),yo.prototype.distanceToBox=function(){let e=["x","y","z"],t=new Array(12).fill().map((()=>new ra)),n=new Array(12).fill().map((()=>new ra)),i=new k,r=new k;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,u=a.min,c=a.max,d=this.points,p=1/0;for(let e=0;e<8;e++){let t=d[e];r.copy(t).clamp(u,c);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,b=y.end;x[m]=u[m],x[g]=r?u[g]:c[g],x[v]=a?u[v]:c[g],b[m]=c[m],b[g]=r?u[g]:c[g],b[v]=a?u[v]:c[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?c.x:u.x,r.y=t?c.y:u.y,r.z=n?c.z:u.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];Eb(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 GA=new k,qA=new k,WA=new k,ode=new _e,lde=new _e,cde=new _e,ude=new k;function fct(e,t,n,i,r,a){let s;return s=a===Ki?e.intersectTriangle(i,n,t,!0,r):e.intersectTriangle(t,n,i,a!==hr,r),null===s?null:{distance:e.origin.distanceTo(r),point:r.clone()}}function pct(e,t,n,i,r,a,s){GA.fromBufferAttribute(t,i),qA.fromBufferAttribute(t,r),WA.fromBufferAttribute(t,a);let o=fct(e,GA,qA,WA,ude,s);if(o){n&&(ode.fromBufferAttribute(n,i),lde.fromBufferAttribute(n,r),cde.fromBufferAttribute(n,a),o.uv=ni.getUV(ude,GA,qA,WA,ode,lde,cde,new _e));let e={a:i,b:r,c:a,normal:new k,materialIndex:0};ni.getNormal(GA,qA,WA,e.normal),o.face=e,o.faceIndex=i}return o}function jU(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=pct(n,e.attributes.position,e.attributes.uv,s,o,l,t);return h?(h.faceIndex=i,r&&r.push(h),h):null}function hde(e,t,n,i,r,a){for(let s=i,o=i+r;s<o;s++)jU(e,t,n,s,a)}function dde(e,t,n,i,r){let a=1/0,s=null;for(let o=i,l=i+r;o<l;o++){let i=jU(e,t,n,o);i&&i.distance<a&&(s=i,a=i.distance)}return s}function XU(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 Ll(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 YU(e,t,n,i,r,a,s){let o=n.index,l=n.attributes.position;for(let h=e,u=t+e;h<u;h++)if(Ll(s,3*h,o,l),s.needsUpdate=!0,i(s,h,r,a))return!0;return!1}var _v=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 $h(e,t){return 65535===t[e+15]}function Tm(e,t){return t[e+6]}function Tv(e,t){return t[e+14]}function wv(e){return e+8}function Sv(e,t){return t[e+6]}function fde(e,t){return t[e+7]}var Mv=new Nt,XA=new k,gct=["x","y","z"];function YA(e,t,n,i,r){let a=2*e,s=Av,o=of,l=lf;if($h(a,o))hde(t,n,i,Tm(e,l),Tv(a,o),r);else{let a=wv(e);ZA(a,s,i,XA)&&YA(a,t,n,i,r);let o=Sv(e,l);ZA(o,s,i,XA)&&YA(o,t,n,i,r)}}function $A(e,t,n,i){let r=2*e,a=Av,s=of,o=lf;if($h(r,s))return dde(t,n,i,Tm(e,o),Tv(r,s));{let r,s,l=fde(e,o),h=gct[l],u=i.direction[h]>=0;u?(r=wv(e),s=Sv(e,o)):(r=Sv(e,o),s=wv(e));let c=ZA(r,a,i,XA)?$A(r,t,n,i):null;if(c){let e=c.point[h];if(u?e<=a[s+l]:e>=a[s+l+3])return c}let d=ZA(s,a,i,XA)?$A(s,t,n,i):null;return c&&d?c.distance<=d.distance?c:d:c||d||null}}var pde=function(){let e,t,n=[],i=new _v((()=>new Nt));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 u(e){let t=2*e,n=of,i=lf;for(;!$h(t,n);)t=2*(e=wv(e));return Tm(e,i)}function c(e){let t=2*e,n=of,i=lf;for(;!$h(t,n);)t=2*(e=Sv(e,i));return Tm(e,i)+Tv(t,n)}let d=2*n,p=Av,f=of,m=lf;if($h(d,f)){let t=Tm(n,m),i=Tv(d,f);return Il(n,p,e),s(t,i,!1,h,l+n,e)}{let d,g,v,y,x=wv(n),b=Sv(n,m),_=x,w=b;if(o&&(v=e,y=t,Il(_,p,v),Il(w,p,y),d=o(v),g=o(y),g<d)){_=b,w=x;let e=d;d=g,g=e,v=y}v||(v=e,Il(_,p,v));let S,M=a(v,$h(2*_,f),d,h+1,l+_);if(2===M){let e=u(_);S=s(e,c(_)-e,!0,h+1,l+_,v)}else S=M&&r(_,i,a,s,o,l,h+1);if(S)return!0;y=t,Il(w,p,y);let E,T=a(y,$h(2*w,f),g,h+1,l+w);if(2===T){let e=u(w);E=s(e,c(w)-e,!0,h+1,l+w,y)}else E=T&&r(w,i,a,s,o,l,h+1);return!!E}}}(),mde=function(){let e=new vo,t=new vo,n=new ht,i=new yo,r=new yo;return function a(s,o,l,h,u=null){let c=2*s,d=Av,p=of,f=lf;if(null===u&&(l.boundingBox||l.computeBoundingBox(),i.set(l.boundingBox.min,l.boundingBox.max,h),u=i),!$h(c,p)){let e=s+8,t=f[s+6];return Il(e,d,Mv),!!(u.intersectsBox(Mv)&&a(e,o,l,h,u)||(Il(t,d,Mv),u.intersectsBox(Mv)&&a(t,o,l,h,u)))}{let i=o,a=i.index,u=i.attributes.position,m=l.index,g=l.attributes.position,v=Tm(s,f),y=Tv(c,p);if(n.copy(h).invert(),l.boundsTree)return Il(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(Ll(t,n,a,u),t.needsUpdate=!0,e.intersectsTriangle(t))return!0;return!1}});for(let r=3*v,s=y+3*v;r<s;r+=3){Ll(e,r,a,u),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(Ll(t,n,m,g),t.needsUpdate=!0,e.intersectsTriangle(t))return!0}}}}();function ZA(e,t,n,i){return Il(e,t,Mv),n.intersectBox(Mv,i)}var $U=[],jA,Av,of,lf;function Rv(e){jA&&$U.push(jA),jA=e,Av=new Float32Array(e),of=new Uint16Array(e),lf=new Uint32Array(e)}function _b(){jA=null,Av=null,of=null,lf=null,$U.length&&Rv($U.pop())}var ZU=Symbol("skip tree generation"),KU=new Nt,JU=new Nt,Cv=new ht,wm=new yo,Tb=new yo,wb=new k,KA=new k,vct=new k,yct=new k,xct=new k,gde=new Nt,Du=new _v((()=>new vo)),Cc=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."),Cc.serialize(arguments[0],{cloneBuffers:void 0===arguments[2]||arguments[2]});t=Ir({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."),Cc.deserialize(arguments[0],arguments[1],{setIndex:void 0===arguments[2]||arguments[2]});n=Ir({setIndex:!0},n);let{index:i,roots:r}=e,a=new Cc(t,Ci(Ir({},n),{[ZU]:!0}));if(a._roots=r,n.setIndex){let n=t.getIndex();if(null===n){let n=new yn(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,[ZU]:!1},t)).useSharedArrayBuffer&&"undefined"==typeof SharedArrayBuffer)throw new Error("MeshBVH: SharedArrayBuffer is not available.");this._roots=null,t[ZU]||(this._roots=sde(e,t),!e.boundingBox&&t.setBoundingBox&&(e.boundingBox=this.getBoundingBox(new Nt))),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 c=0,d=h.length;c<d;c++)t=h[c],n=new Uint32Array(t),i=new Uint16Array(t),r=new Float32Array(t),u(0,l),l+=t.byteLength;function u(t,a,l=!1){let h=2*t;if(65535===i[h+15]){let e=n[t+6],a=1/0,l=1/0,u=1/0,c=-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>c&&(c=n),i<l&&(l=i),i>d&&(d=i),r<u&&(u=r),r>p&&(p=r)}return(r[t+0]!==a||r[t+1]!==l||r[t+2]!==u||r[t+3]!==c||r[t+4]!==d||r[t+5]!==p)&&(r[t+0]=a,r[t+1]=l,r[t+2]=u,r[t+3]=c,r[t+4]=d,r[t+5]=p,!0)}{let i=t+8,s=n[t+6],o=i+a,h=s+a,c=l,d=!1,p=!1;e?c||(d=e.has(o),p=e.has(h),c=!d&&!p):(d=!0,p=!0);let f=c||p,m=!1;(c||d)&&(m=u(i,a,c));let g=!1;f&&(g=u(s,a,c));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],u=r[a+3];r[t+e]=o<h?o:h,r[t+e+3]=l>u?l:u}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=hi){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,u=n.length;h<u;h++){let a=s?t[o[h].materialIndex].side:l,u=r.length;if(Rv(n[h]),YA(0,i,a,e,r),_b(),s){let e=o[h].materialIndex;for(let t=u,n=r.length;t<n;t++)r[t].face.materialIndex=e}}return r}raycastFirst(e,t=hi){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,u=n.length;h<u;h++){let r=a?t[o[h].materialIndex].side:l;Rv(n[h]);let u=$A(0,i,r,e);_b(),null!=u&&(null==s||u.distance<s.distance)&&(s=u,a&&(u.face.materialIndex=o[h].materialIndex))}return s}intersectsGeometry(e,t){let n=this.geometry,i=!1;for(let r of this._roots)if(Rv(r),i=mde(0,n,e,t),_b(),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=Du.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)||YU(t,n,i,l,a,s,r)}else o||(o=l?(e,t,n,a)=>YU(e,t,i,l,n,a,r):(e,t,n)=>n);let h=!1,u=0;for(let c of this._roots){if(Rv(c),h=pde(0,i,s,o,a,u),_b(),h)break;u+=c.byteLength}return Du.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;Cv.copy(t).invert();let h=Du.getPrimitive(),u=Du.getPrimitive();if(r){let e=function(e,n,i,c,d,p,f,m){for(let g=i,v=i+c;g<v;g++){Ll(u,3*g,o,l),u.a.applyMatrix4(t),u.b.applyMatrix4(t),u.c.applyMatrix4(t),u.needsUpdate=!0;for(let t=e,i=e+n;t<i;t++)if(Ll(h,3*t,a,s),h.needsUpdate=!0,r(h,u,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(JU),JU.applyMatrix4(t);let c=this.shapecast({intersectsBounds:e=>JU.intersectsBox(e),intersectsRange:(t,n,r,a,s,o)=>(KU.copy(o),KU.applyMatrix4(Cv),e.shapecast({intersectsBounds:e=>KU.intersectsBox(e),intersectsRange:(e,r,o,l,h)=>i(t,n,e,r,a,s,l,h)}))});return Du.releasePrimitive(h),Du.releasePrimitive(u),c}intersectsBox(e,t){return wm.set(e.min,e.max,t),wm.needsUpdate=!0,this.shapecast({intersectsBounds:e=>wm.intersectsBox(e),intersectsTriangle:e=>wm.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(),wm.set(e.boundingBox.min,e.boundingBox.max,t),wm.needsUpdate=!0;let s=this.geometry,o=s.attributes.position,l=s.index,h=e.attributes.position,u=e.index,c=Du.getPrimitive(),d=Du.getPrimitive(),p=KA,f=vct,m=null,g=null;i&&(m=yct,g=xct);let v=1/0,y=null,x=null;return Cv.copy(t).invert(),Tb.matrix.copy(Cv),this.shapecast({boundsTraverseOrder:e=>wm.distanceToBox(e),intersectsBounds:(e,t,n)=>n<v&&n<a&&(t&&(Tb.min.copy(e.min),Tb.max.copy(e.max),Tb.needsUpdate=!0),!0),intersectsRange:(n,i)=>{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:e=>Tb.distanceToBox(e),intersectsBounds:(e,t,n)=>n<v&&n<a,intersectsRange:(e,a)=>{for(let s=3*e,b=3*(e+a);s<b;s+=3){Ll(d,s,u,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){Ll(c,e,l,o),c.needsUpdate=!0;let t=c.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=u?u.count:h.count;e<a;e+=3){Ll(d,e,u,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){Ll(c,t,l,o),c.needsUpdate=!0;let n=c.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}}}}),Du.releasePrimitive(c),Du.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(Cv),f.applyMatrix4(Cv),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=>(wb.copy(e).clamp(t.min,t.max),wb.distanceToSquared(e)),intersectsBounds:(e,t,n)=>n<s&&n<a,intersectsTriangle:(t,n)=>{t.closestPointToPoint(e,wb);let i=e.distanceToSquared(wb);return i<s&&(KA.copy(wb),s=i,o=n),i<r}}),s===1/0)return null;let l=Math.sqrt(s);return t.point?t.point.copy(KA):t.point=KA.clone(),t.distance=l,t.faceIndex=o,t}getBoundingBox(e){return e.makeEmpty(),this._roots.forEach((t=>{Il(0,new Float32Array(t),gde),e.union(gde)})),e}},QU=new Tl,vde=new ht,bct=St.prototype.raycast;function eH(e,t){if(this.geometry.boundsTree){if(void 0===this.material)return;vde.copy(this.matrixWorld).invert(),QU.copy(e.ray).applyMatrix4(vde);let n=this.geometry.boundsTree;if(!0===e.firstHitOnly){let i=XU(n.raycastFirst(QU,this.material),this,e);i&&t.push(i)}else{let i=n.raycast(QU,this.material);for(let n=0,r=i.length;n<r;n++){let r=XU(i[n],this,e);r&&t.push(r)}}}else bct.call(this,e,t)}var yde=new ht,Pv=new Tl,tH=new $r,cf=new k,uf=new k,hf=new k,nH=new k,rH=new k,iH=new k,JA=new k,QA=new k,eR=new k,tR=new _e,nR=new _e,rR=new _e,sH=new k,iR=new k;function Ect(e,t,n,i,r,a,s,o){let l;if(l=t.side===Ki?i.intersectTriangle(s,a,r,!0,o):i.intersectTriangle(r,a,s,t.side!==hr,o),null===l)return null;iR.copy(o),iR.applyMatrix4(e.matrixWorld);let h=n.ray.origin.distanceTo(iR);return h<n.near||h>n.far?null:{distance:h,point:iR.clone(),object:e}}function sR(e,t,n,i,r,a,s,o,l,h,u,c){cf.fromBufferAttribute(r,h),uf.fromBufferAttribute(r,u),hf.fromBufferAttribute(r,c);let d=e.morphTargetInfluences;if(a&&d){JA.set(0,0,0),QA.set(0,0,0),eR.set(0,0,0);for(let e=0,t=a.length;e<t;e++){let t=d[e],n=a[e];0!==t&&(nH.fromBufferAttribute(n,h),rH.fromBufferAttribute(n,u),iH.fromBufferAttribute(n,c),s?(JA.addScaledVector(nH,t),QA.addScaledVector(rH,t),eR.addScaledVector(iH,t)):(JA.addScaledVector(nH.sub(cf),t),QA.addScaledVector(rH.sub(uf),t),eR.addScaledVector(iH.sub(hf),t)))}cf.add(JA),uf.add(QA),hf.add(eR)}e.isSkinnedMesh&&(e.boneTransform(h,cf),e.boneTransform(u,uf),e.boneTransform(c,hf));let p=Ect(e,t,n,i,cf,uf,hf,sH);if(p){o&&(tR.fromBufferAttribute(o,h),nR.fromBufferAttribute(o,u),rR.fromBufferAttribute(o,c),p.uv=ni.getUV(sH,cf,uf,hf,tR,nR,rR,new _e)),l&&(tR.fromBufferAttribute(l,h),nR.fromBufferAttribute(l,u),rR.fromBufferAttribute(l,c),p.uv2=ni.getUV(sH,cf,uf,hf,tR,nR,rR,new _e));let e={a:h,b:u,c:c,normal:new k,materialIndex:0};ni.getNormal(cf,uf,hf,e.normal),p.face=e}return p}St.prototype.raycast=function(e,t){let n=this.geometry,i=this.material,r=this.matrixWorld;if(void 0===i||(null===n.boundingSphere&&n.computeBoundingSphere(),tH.copy(n.boundingSphere),tH.applyMatrix4(r),!1===e.ray.intersectsSphere(tH))||(yde.copy(r).invert(),Pv.copy(e.ray).applyMatrix4(yde),null!==n.boundingBox&&!1===Pv.intersectsBox(n.boundingBox)))return;let a,s=n.index,o=n.attributes.position,l=n.morphAttributes.position,h=n.morphTargetsRelative,u=n.attributes.uv,c=n.attributes.uv2,d=n.groups,p=n.drawRange;if(null!==s)if(Array.isArray(i))for(let f=0,m=d.length;f<m;f++){let n=d[f],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),f=s.getX(i+2);a=sR(this,r,e,Pv,o,l,h,u,c,d,p,f),a&&(a.faceIndex=Math.floor(i/3),a.face.materialIndex=n.materialIndex,t.push(a))}}else for(let f=Math.max(0,p.start),m=Math.min(s.count,p.start+p.count);f<m;f+=3){let n=s.getX(f),r=s.getX(f+1),d=s.getX(f+2);a=sR(this,i,e,Pv,o,l,h,u,c,n,r,d),a&&(a.faceIndex=Math.floor(f/3),t.push(a))}else if(void 0!==o)if(Array.isArray(i))for(let f=0,m=d.length;f<m;f++){let n=d[f],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)a=sR(this,r,e,Pv,o,l,h,u,c,i,i+1,i+2),a&&(a.faceIndex=Math.floor(i/3),a.face.materialIndex=n.materialIndex,t.push(a))}else for(let f=Math.max(0,p.start),m=Math.min(o.count,p.start+p.count);f<m;f+=3)a=sR(this,i,e,Pv,o,l,h,u,c,f,f+1,f+2),a&&(a.faceIndex=Math.floor(f/3),t.push(a))},St.prototype.raycast=eH;var aR=new $r,oR=new k;function xde(e,t,n,i,r,a){let s=i.ray.distanceSqToPoint(e);if(s<n){let n=new k;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})}}Di.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(),aR.copy(n.boundingSphere),aR.applyMatrix4(i),aR.radius+=r,!1===e.ray.intersectsSphere(aR))return;let s=r*r,o=n.index,l=n.attributes.position,h=t.length;if(null!==o)for(let u=Math.max(0,a.start),c=Math.min(o.count,a.start+a.count);u<c;u++){let n=o.getX(u);if(oR.fromBufferAttribute(l,n).applyMatrix4(i),xde(oR,n,s,e,t,this),t.length-h>=1)return}else for(let u=Math.max(0,a.start),c=Math.min(l.count,a.start+a.count);u<c;u++)if(oR.fromBufferAttribute(l,u).applyMatrix4(i),xde(oR,u,s,e,t,this),t.length-h>=1)return};var aH=class{constructor(){this.id=0,this.object=null,this.z=0,this.renderOrder=0}},Sb=class{constructor(){this.id=0,this.v1=new df,this.v2=new df,this.v3=new df,this.normalModel=new k,this.vertexNormalsModel=[new k,new k,new k],this.vertexNormalsLength=0,this.color=new ct,this.material=null,this.uvs=[new _e,new _e,new _e],this.z=0,this.renderOrder=0}},df=class{constructor(){this.position=new k,this.positionWorld=new k,this.positionScreen=new mr,this.visible=!0}copy(e){this.positionWorld.copy(e.positionWorld),this.positionScreen.copy(e.positionScreen)}},Mb=class{constructor(){this.id=0,this.v1=new df,this.v2=new df,this.vertexColors=[new ct,new ct],this.material=null,this.z=0,this.renderOrder=0}},Ab=class{constructor(){this.id=0,this.object=null,this.x=0,this.y=0,this.z=0,this.rotation=0,this.scale=new _e,this.material=null,this.renderOrder=0}},lR=class{constructor(){let e,t,n,i,r,a,s,o,l,h,u,c=0,d=0,p=0,f=0,m=0,g={objects:[],lights:[],elements:[]},v=new k,y=new mr,x=new Nt(new k(-1,-1,-1),new k(1,1,1)),b=new Nt,_=new Array(3),w=new ht,S=new ht,M=new ht,E=new wl,T=[],A=[],C=[],P=[],R=[],L=new function(){let e=[],t=[],l=[],h=null,c=new In;function m(e){let t=e.position,n=e.positionWorld,i=e.positionScreen;n.copy(t).applyMatrix4(u),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 w(e,t,n){return!0===e.visible||!0===t.visible||!0===n.visible||(_[0]=e.positionScreen,_[1]=t.positionScreen,_[2]=n.positionScreen,x.intersectsBox(b.setFromPoints(_)))}function E(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,c.getNormalMatrix(h.matrixWorld),e.length=0,t.length=0,l.length=0},projectVertex:m,checkTriangleVisibility:w,checkBackfaceCulling:E,pushVertex:function(e,t,r){n=function(){if(i===d){let e=new df;return A.push(e),d++,i++,e}return A[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=A[e],r=A[n];i.positionScreen.copy(i.position).applyMatrix4(M),r.positionScreen.copy(r.position).applyMatrix4(M),!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 Mb;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 u=A[n],d=A[i],f=A[s];if(!1!==w(u,d,f)&&(o.side===hr||!0===E(u,d,f))){r=function(){if(a===p){let e=new Sb;return C.push(e),p++,a++,e}return C[a++]}(),r.id=h.id,r.v1.copy(u),r.v2.copy(d),r.v3.copy(f),r.z=(u.positionScreen.z+d.positionScreen.z+f.positionScreen.z)/3,r.renderOrder=h.renderOrder,v.subVectors(f.position,d.position),y.subVectors(u.position,d.position),v.cross(y),r.normalModel.copy(v),r.normalModel.applyMatrix3(c).normalize();for(let t=0;t<3;t++){let n=r.vertexNormalsModel[t];n.fromArray(e,3*arguments[t]),n.applyMatrix3(c).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===E.intersectsObject(e))return;O(e)}else if(e.isSprite){if(!1===e.material.visible||!0===e.frustumCulled&&!1===E.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===c){let e=new aH;return T.push(e),c++,t++,e}return T[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 D(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 Ab;return R.push(e),m++,h++,e}return R[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),E.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(L.setObject(e),u=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 u=a[e];l?(t+=u.getX(o/3)*r,n+=u.getY(o/3)*r,i+=u.getZ(o/3)*r):(t+=(u.getX(o/3)-s[o])*r,n+=(u.getY(o/3)-s[o+1])*r,i+=(u.getZ(o/3)-s[o+2])*r)}}L.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)L.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)L.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)L.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)L.pushTriangle(i[e],i[e+1],i[e+2],t)}else for(let e=0,n=i.length;e<n;e+=3)L.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)L.pushTriangle(e,e+1,e+2,t)}else for(let e=0,r=s.length/3;e<r;e+=3)L.pushTriangle(e,e+1,e+2,t)}else if(e.isLine){M.multiplyMatrices(S,u);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)L.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)L.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)L.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)L.pushLine(e,e+1)}}}else if(e.isPoints){M.multiplyMatrices(S,u);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(M),D(y,e,n)}}else e.isSprite&&(e.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,e.matrixWorld),y.set(u.elements[12],u.elements[13],u.elements[14],1),y.applyMatrix4(S),D(y,e,n))}return!0===s&&g.elements.sort(N),g}}},bde=class extends an{constructor(e){super(),this.isSVGObject=!0,this.node=e}},Ede=class{constructor(){let e,t,n,i,r,a,s,o,l,h,u,c,d,p,f,m=0,g=null,v=1,y=this,x=new _i,b=new _i,_=new ct,w=new ct,S=new ct,M=new ct,E=new ct,T=new k,A=new k,C=new k,P=new In,R=new ht,L=new ht,I=[],O=new lR,D=document.createElementNS("http://www.w3.org/2000/svg","svg");function N(){for(m=0;D.childNodes.length>0;)D.removeChild(D.childNodes[0])}function U(e){return null!==g?e.toFixed(g):e}function F(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"+U(e.x-.5*i)+","+U(e.y-.5*r)+"h"+U(i)+"v"+U(r)+"h"+U(-i)+"z",l="";(n.isSpriteMaterial||n.isPointsMaterial)&&(l="fill:"+n.color.getStyle()+";fill-opacity:"+n.opacity),V(l,o)}function B(e,t,n){let i="M"+U(e.positionScreen.x)+","+U(e.positionScreen.y)+"L"+U(t.positionScreen.x)+","+U(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),V(e,i)}}function z(e,t,i,r,a){y.info.render.vertices+=3,y.info.render.faces++;let s="M"+U(e.positionScreen.x)+","+U(e.positionScreen.y)+"L"+U(t.positionScreen.x)+","+U(t.positionScreen.y)+"L"+U(i.positionScreen.x)+","+U(i.positionScreen.y)+"z",o="";a.isMeshBasicMaterial?(_.copy(a.color),a.vertexColors&&_.multiply(r.color)):a.isMeshLambertMaterial||a.isMeshPhongMaterial||a.isMeshStandardMaterial?(w.copy(a.color),a.vertexColors&&w.multiply(r.color),_.copy(S),A.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=T.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=T.setFromMatrixPosition(a.matrixWorld),r=n.dot(T.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,A,r.normalModel,_),_.multiply(w).add(a.emissive)):a.isMeshNormalMaterial&&(C.copy(r.normalModel).applyMatrix3(P).normalize(),_.setRGB(C.x,C.y,C.z).multiplyScalar(.5).addScalar(.5)),o=a.wireframe?"fill:none;stroke:"+_.getStyle()+";stroke-opacity:"+a.opacity+";stroke-width:"+a.wireframeLinewidth+";stroke-linecap:"+a.wireframeLinecap+";stroke-linejoin:"+a.wireframeLinejoin:"fill:"+_.getStyle()+";fill-opacity:"+a.opacity,V(o,s)}function H(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 V(e,t){d===e?c+=t:(j(),d=e,c=t)}function j(){var e;c&&(e=m++,null==I[e]&&(I[e]=document.createElementNS("http://www.w3.org/2000/svg","path"),0==v&&I[e].setAttribute("shape-rendering","crispEdges")),u=I[e],u.setAttribute("d",c),u.setAttribute("style",d),D.appendChild(u)),c="",d=""}this.domElement=D,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,D.setAttribute("viewBox",-a+" "+-s+" "+i+" "+r),D.setAttribute("width",i),D.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=_ct(p);D.style.backgroundColor=`rgba(${e.r}, ${e.g}, ${e.b}, ${f})`}else D.style.backgroundColor=p.getStyle()},this.render=function(i,r){if(!(r instanceof Uh))return void console.error("THREE.SVGRenderer.render: camera is not an instance of Camera.");let u=i.background;u&&u.isColor?(N(),D.style.backgroundColor=u.getStyle()):!0===this.autoClear&&this.clear(),y.info.render.vertices=0,y.info.render.faces=0,R.copy(r.matrixWorldInverse),L.multiplyMatrices(r.projectionMatrix,R),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),M.setRGB(0,0,0),E.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?(M.r+=i.r,M.g+=i.g,M.b+=i.b):n.isPointLight&&(E.r+=i.r,E.g+=i.g,E.b+=i.b)}}(n),c="",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(b.makeEmpty(),n instanceof Ab)o=n,o.x*=a,o.y*=-s,F(o,n,i);else if(n instanceof Mb)o=n.v1,l=n.v2,o.positionScreen.x*=a,o.positionScreen.y*=-s,l.positionScreen.x*=a,l.positionScreen.y*=-s,b.setFromPoints([o.positionScreen,l.positionScreen]),!0===x.intersectsBox(b)&&B(o,l,i);else if(n instanceof Sb){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&&(H(o.positionScreen,l.positionScreen,this.overdraw),H(l.positionScreen,h.positionScreen,this.overdraw),H(h.positionScreen,o.positionScreen,this.overdraw)),b.setFromPoints([o.positionScreen,l.positionScreen,h.positionScreen]),!0===x.intersectsBox(b)&&z(o,l,h,n,i)}}j(),i.traverseVisible((function(e){if(e.isSVGObject){if(T.setFromMatrixPosition(e.matrixWorld),T.applyMatrix4(L),T.z<-1||T.z>1)return;let t=T.x*a,n=-T.y*s,i=e.node;i.setAttribute("transform",`translate(${t}, ${n}) rotate(${e.rotation.z})`),D.appendChild(i)}}))}}};function _ct(e){let t={};return t.r=(e>>16&255)/255,t.g=(e>>8&255)/255,t.b=(255&e)/255,t}var _de="\n #ifdef USE_BC_OUTLINE\n // Restore barycentric coordinates\n int barycentricX = int(barycentric) & 0x1;\n int barycentricY = int(barycentric) & 0x2;\n int barycentricZ = int(barycentric) & 0x4;\n vBarycentric = vec3(float(barycentricX), float(barycentricY), float(barycentricZ));\n #endif\n",Tde="\n #ifdef USE_BC_OUTLINE\n vec3 finWireframeColor = outlineColor;\n vec3 _tempColor = gl_FragColor.rgb;\n\n gl_FragColor.rgb = mix(finWireframeColor, _tempColor, edgeFactor3());\n #endif\n",wde="\n #ifdef USE_BC_OUTLINE\n varying vec3 vBarycentric;\n uniform vec3 outlineColor;\n\n float edgeFactor3(){\n vec3 d = fwidth(vBarycentric);\n float minValue = 0.0000001;\n // make sure d is not 0\n d = clamp(d, vec3(minValue), vec3(10.0));\n vec3 a3 = smoothstep(vec3(0.0), d * 0.8, vBarycentric);\n return min(min(a3.x, a3.y), a3.z);\n }\n #endif\n",Sde="\n #ifdef USE_BC_OUTLINE \n attribute float barycentric;\n varying vec3 vBarycentric;\n #endif\n",Mde="\n#define STANDARD\n\nvarying vec3 vViewPosition;\n\n#ifdef USE_TRANSMISSION\n\n\tvarying vec3 vWorldPosition;\n\n#endif\n\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>\n\n#include <outline_bc_pars_vertex>\n\nvoid main() {\n\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\n #include <outline_bc_vertex>\n\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\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\n\tvViewPosition = - mvPosition.xyz;\n\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n\n#ifdef USE_TRANSMISSION\n\n\tvWorldPosition = worldPosition.xyz;\n\n#endif\n}\n",Ade="\n#define STANDARD\n\n#ifdef PHYSICAL\n\t#define IOR\n\t#define USE_SPECULAR\n#endif\n\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n\n#ifdef IOR\n\tuniform float ior;\n#endif\n\n#ifdef USE_SPECULAR\n\tuniform float specularIntensity;\n\tuniform vec3 specularColor;\n\n\t#ifdef USE_SPECULAR_COLORMAP\n\t\tuniform sampler2D specularColorMap;\n\t#endif\n\n\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\tuniform sampler2D specularIntensityMap;\n\t#endif\n#endif\n\n#ifdef USE_CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n\n#ifdef USE_IRIDESCENCE\n\tuniform float iridescence;\n\tuniform float iridescenceIOR;\n\tuniform float iridescenceThicknessMinimum;\n\tuniform float iridescenceThicknessMaximum;\n#endif\n\n#ifdef USE_SHEEN\n\tuniform vec3 sheenColor;\n\tuniform float sheenRoughness;\n\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tuniform sampler2D sheenColorMap;\n\t#endif\n\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tuniform sampler2D sheenRoughnessMap;\n\t#endif\n#endif\n\n#ifdef USE_ANISOTROPY\n\tuniform vec2 anisotropyVector;\n\n\t#ifdef USE_ANISOTROPYMAP\n\t\tuniform sampler2D anisotropyMap;\n\t#endif\n#endif\n\nvarying vec3 vViewPosition;\n\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 <alphahash_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>\n\n#include <outline_bc_pars_fragment>\n\nvoid main() {\n\n\t#include <clipping_planes_fragment>\n\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\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 <alphahash_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\n\t// accumulation\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\n\t// modulation\n\t#include <aomap_fragment>\n\n\tvec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\tvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\n\t#include <transmission_fragment>\n\n\tvec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n\n\t#ifdef USE_SHEEN\n\n\t\t// Sheen energy compensation approximation calculation can be found at the end of\n\t\t// https://drive.google.com/file/d/1T0D1VSyR4AllqIJTQAraEIzjlb5h4FKH/view?usp=sharing\n\t\tfloat sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );\n\n\t\toutgoingLight = outgoingLight * sheenEnergyComp + sheenSpecular;\n\n\t#endif\n\n\t#ifdef USE_CLEARCOAT\n\n\t\tfloat dotNVcc = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );\n\n\t\tvec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n\n\t\toutgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + clearcoatSpecular * material.clearcoat;\n\n\t#endif\n\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n\n #include <outline_bc_fragment>\n}\n";$n.outline_bc_vertex=_de,$n.outline_bc_fragment=Tde,$n.outline_bc_pars_fragment=wde,$n.outline_bc_pars_vertex=Sde,$n.gemini_standard_vertex=Mde,$n.gemini_standard_fragment=Ade;var Rde=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"})}},ELt={enableSpinner:!0,containerId:"myCanvas",units:"meters"},wct=ss(Pde(),1),fe=wct;fe.setLevel("warn");var Ide=e=>{try{fe.setLevel(e)}catch(e){fe.setLevel("error"),fe.error(e)}},oH=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=oH.isTouchScreenDevice();t&&fe.debug("[DI] is android"),n&&fe.debug("[DI] is fireFox"),i&&fe.debug("[DI] is chrome"),r&&fe.debug("[DI] is tablet"),a&&fe.debug("[DI] is iPhone"),s&&fe.debug("[DI] is PC"),o&&fe.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:()=>{}}}},dr=oH;dr.isMobile=/mobile/i.test(navigator.userAgent),dr.isBrowser="undefined"!=typeof document,dr.isNode="undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process);var uR=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 Array.isArray(e)?`(${this.numberToString(e[0])}, ${this.numberToString(e[1])}, ${this.numberToString(e[2])})`:e instanceof k?`(${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 _e?e:Array.isArray(e)&&e.length>=2?new _e(e[0],e[1]):void 0:e}static arrayToVector3(e){return e?e instanceof k?e:Array.isArray(e)&&e.length>=2?new k(e[0],e[1],e.length>2?e[2]:0):void 0:e}static arrayToEuler(e){return e?e instanceof Xn?e:Array.isArray(e)&&e.length>=3?new Xn(e[0],e[1],e[2]):void 0:e}static arrayOrObjectToVector3(e){if(!e)return e;if(e instanceof k)return e;if(e instanceof _e)return new k(e.x,e.y,0);if(Array.isArray(e)&&e.length>=2)return new k(e[0],e[1],e[2]||0);let t=e;return null!=t.x&&null!=t.y?new k(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 k&&(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 k;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 k(n.x-i/2,n.y-r/2,n.z-a/2),o=new k(n.x+i/2,n.y+r/2,n.z+a/2);e.set(s,o)}static expandBoxByMinSize(e,t){let n=new k;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(dr.isBrowser){let t=performance.memory;if(!t)return void fe.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);fe.info(`[CommonUtils] ${e}. jsHeapSizeLimit: ${n}M , totalJSHeapSize: ${i}M , usedJSHeapSize: ${r}M `)}}static printGpuInfo(e){if(dr.isBrowser){let t=e.getExtension("webgl_debug_renderer_info"),n=e.getParameter(t.UNMASKED_RENDERER_WEBGL);fe.info("[CommonUtils] gpu:",n)}}static sleep(e){return it(this,null,(function*(){let t;return new Promise((n=>{t=setTimeout((()=>{n("")}),e)})).then((()=>{clearTimeout(t)}))}))}static twinkle(e,t=500){return it(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])}))}static getUpdateProgressFunc(e){return t=>{e&&e(new ProgressEvent("",{loaded:t,total:100}))}}static getUpdateProgressFuncAsync(e){let t=Date.now();return n=>it(this,null,(function*(){if(e){e(new ProgressEvent("",{loaded:n,total:100}));let i=500,r=Date.now();r-t>i&&(yield uR.sleep(0),t=r)}}))}static getUpdateProgressFuncForLoop(e,t){let n=Math.round(Math.pow(e,.5)),i=Date.now();return r=>it(this,null,(function*(){if(t&&(r%n==0||r===e-1)){t(new ProgressEvent("",{loaded:r+1,total:e}));let n=500,a=Date.now();(a-i>n||r===e-1)&&(yield uR.sleep(0),i=a)}}))}static getUpdateSubProgressFunc(e,t,n){let i=!1;return r=>{let a=100*r.loaded/r.total;a=a*(t-e)/100+e,a>t&&(i||(fe.warn("[Progress] Invalid ProgressEvent:",r),i=!0),a=t),n&&n(new ProgressEvent(r.type,{loaded:a,total:100}))}}},Pt=uR;Pt.twinklingObjectIds={};var hR=(e,t,n)=>{let{default:i,active:r}=t;n?(e.remove(i),e.add(r||i)):(r&&e.remove(r),e.add(i))},An=class{static color2rgba(e){let t,n=[0,0,0,1];if(t=/^(\w+)\(([^)]*)\)/.exec(e)){let i,r=t[1],a=t[2];switch(r){case"rgb":case"rgba":(i=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))&&(n=[Math.min(255,parseInt(i[1],10))/255,Math.min(255,parseInt(i[2],10))/255,Math.min(255,parseInt(i[3],10))/255,Number(i[4]||1)]),(i=/^\s*(\d+)%\s*,\s*(\d+)%\s*,\s*(\d+)%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))&&(n=[Math.min(100,parseInt(i[1],10))/100,Math.min(100,parseInt(i[2],10))/100,Math.min(100,parseInt(i[3],10))/100,Number(i[4]||1)]);break;case"hsl":case"hsla":(i=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)%\s*,\s*(\d*\.?\d+)%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))&&(n=[parseFloat(i[1])/360,parseFloat(i[2])/100,parseFloat(i[3])/100,Number(i[4]||1)]);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(t=/^#([A-Fa-f\d]+)$/.exec(e)){let i=t[1],r=i.length;if(3===r)n=[parseInt(i.charAt(0),16)/15,parseInt(i.charAt(1),16)/15,parseInt(i.charAt(2),16)/15,1];else if(6===r){let e=parseInt(i,16);n=[(e>>16&255)/255,(e>>8&255)/255,(255&e)/255,1]}else console.warn("THREE.Color: Invalid hex color "+e)}return n}static rgba2Color(e){return`rgba(${this.to255(e[0])},${this.to255(e[1])},${this.to255(e[2])},${null!=e[3]?e[3]:1})`}static colorStr2Rgba(e){let t=e.replace("rgba(","");t=t.replace(")","");let n=t.split(","),i=[];return i.push(this.to1(parseInt(n[0]))),i.push(this.to1(parseInt(n[1]))),i.push(this.to1(parseInt(n[2]))),null!=n[3]&&i.push(parseFloat(n[3])),i}static rgb2Hex(e){return(this.to255(e[0])<<16)+(this.to255(e[1])<<8)+this.to255(e[2])}static to255(e){let t=Math.max(e,0);return t=Math.min(e,1),255*t}static to1(e){let t=Math.max(e,0);return t=Math.min(e,255),t/255}},Sn=class{static getScreenCoordinateByEvent(e,t){let n=new _e,{left:i,top:r}=t.getBoundingClientRect();return n.x=e.clientX-i,n.y=e.clientY-r,n}static getScreenCoordinateByTouchEvent(e,t){let n=new _e,{left:i,top:r}=t.getBoundingClientRect();return n.x=e.touches[0].clientX-i,n.y=e.touches[0].clientY-r,n}static world2Screen(e,t,n){let{clientWidth:i,clientHeight:r}=n,a=e.clone(),s=new _e;return a.project(t),s.x=Math.round((.5+a.x/2)*i),s.y=Math.round((.5-a.y/2)*r),s}static worldBBox2Screen(e,t,n){let i=new _i,r=e.min,a=e.max,s=(e,r,a)=>{let s=new k(e,r,a),o=this.world2Screen(s,t,n);i.expandByPoint(o)};return s(r.x,r.y,r.z),s(r.x,r.y,a.z),s(r.x,a.y,r.z),s(r.x,a.y,a.z),s(a.x,r.y,r.z),s(a.x,r.y,a.z),s(a.x,a.y,r.z),s(a.x,a.y,a.z),i}static screen2World(e,t,n){let i=Sn.screen2Ndc(e,t,n);return new k(i.x,i.y,1).unproject(t)}static screen2Ndc(e,t,n){let{clientWidth:i,clientHeight:r}=n,a=new _e;return a.x=e.x/i*2-1,a.y=-e.y/r*2+1,a}static world2NormalizedScreen(e,t,n){let i=new k,r=e instanceof _e?0:e.z;i.set(e.x,e.y,r);let a=Sn.world2Screen(i,t,n);return a.x/=n.clientWidth,a.y/=n.clientHeight,a}},ff=class extends an{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 _e(.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}},Iv=new k,Lde=new ht,Dde=new ht,Ode=new k,kde=new k,Lv=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){Iv.setFromMatrixPosition(e.matrixWorld),Iv.applyMatrix4(Dde);let l=!0===e.visible&&Iv.z>=-1&&Iv.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("+(Iv.x*i+i)+"px,"+(-Iv.y*r+r)+"px)",s.parentNode!==o&&o.appendChild(s),e.onAfterRender(a,t,n)}let u={distanceToCameraSquared:h(n,e)};s.objects.set(e,u)}for(let i=0,r=e.children.length;i<r;i++)l(e.children[i],t,n)}function h(e,t){return Ode.setFromMatrixPosition(e.matrixWorld),kde.setFromMatrixPosition(t.matrixWorld),Ode.distanceToSquared(kde)}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(),Lde.copy(t.matrixWorldInverse),Dde.multiplyMatrices(t.projectionMatrix,Lde),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"}}},pf=class{static createCSS2DObject(e){let t=new ff(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)}},Fde={"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},Ou=(e,t)=>e.toFixed(t===Fde["Precision from file"]?2:t),Qi=!1,GLt=!1,dR=10,Ss=11,wi=12,fR="gemini-viewer-iconfont",qLt="keydown",WLt="keyup",mf="mousemove",lH="mouseup",cH="mousedown",jLt="Escape",XLt="Enter",YLt="axis-section-plane",$Lt="axis-section-plane-control",ZLt="section-plane",KLt="section-plane-control",JLt="section-box",QLt="plane-section-boxface",Nde=-1e3,pR=10,mR=(e=>(e.ObjectsBoxSection="ObjectsBoxSection",e.PickPlaneSection="PickPlaneSection",e.AxisPlaneSection="AxisPlaneSection",e))(mR||{}),Bde=(e=>(e.Default="Default",e.BoxSelection="BoxSelection",e.PickMarkup="PickMarkup",e))(Bde||{}),Ude=new k,Hde=new k,Vde=new k,Rb=new k,Zh=new k,zde=new ni;function Sct(e,t,n,i,r){let a,s,o,l,h,u,c=[],d={},p=Math.pow(10,4),f=0;for(h=0,u=e.length;h<u;h+=3)a=e[h],s=e[h+1],o=e[h+2],l=Math.round(a*p)+"_"+Math.round(s*p)+"_"+Math.round(o*p),d[l]||(d[l]=f/3,n[f++]=a,n[f++]=s,n[f++]=o),c[h/3]=d[l];for(h=0,u=t.length;h<u;h++)r[h]=c[t[h]],i[r[h]]=t[h]}function Mct(e,t,n,i){for(let r=0,a=e;r<a;r+=3){let e=3*t[r],a=3*t[r+1],s=3*t[r+2];Ude.set(n[e],n[e+1],n[e+2]),Hde.set(n[a],n[a+1],n[a+2]),Vde.set(n[s],n[s+1],n[s+2]),ni.getNormal(Ude,Hde,Vde,Rb),i.push({normal:Rb.clone()})}}var uH=[new k(1,0,0),new k(0,1,0),new k(0,0,1),new k(1,1,0),new k(0,1,1),new k(1,0,1),new k(1,1,1),new k(0,0,0)];function Act(e,t){return Zh.addVectors(e,t),0===Zh.x||0===Zh.y||0===Zh.z}var gR=class{static buildEdge(e,t,n=10){let i=[],r=[],a=[];Sct(e,t,i,r,a);let s=[];Mct(t.length,a,i,s);let o,l,h,u,c,d,p,f,m,g,v=[],y=Math.cos(Un.DEG2RAD*n),x={},b=!1;for(let _=0,w=t.length;_<w;_+=3){let e=_/3;for(let t=0;t<3;t++)o=a[_+t],l=a[_+(t+1)%3],h=Math.min(o,l),u=Math.max(o,l),c=h+","+u,void 0===x[c]?x[c]={index1:h,index2:u,face1:e,face2:void 0}:x[c].face2=e}for(c in x)d=x[c],!(void 0!==d.face2&&(p=s[d.face1].normal,f=s[d.face2].normal,p.dot(f)>y))&&(m=r[d.index1],g=r[d.index2],(!b&&m>65535||g>65535)&&(b=!0),v.push(m),v.push(g));return b?new Uint32Array(v):new Uint16Array(v)}static buildBarycentrics(e){let t=e.getAttribute("position");if(!t||0===t.count)return console.warn(" no positions in geometry !"),!1;let n=Math.pow(10,4),i=Math.cos(20*Un.DEG2RAD),r=e.getIndex(),a=r?r.count:t.count,s=[0,0,0],o=new Array(3),l=uH.length,h=[];for(let S=0;S<t.count;S++)h.push({point:new k(1,1,1),inited:!1,barycentricIndex:-1});let u={},c={},d={},p={};for(let S=0;S<a;S+=3){r?(s[0]=r.getX(S),s[1]=r.getX(S+1),s[2]=r.getX(S+2)):(s[0]=S,s[1]=S+1,s[2]=S+2);let{a:e,b:a,c:l}=zde;if(e.fromBufferAttribute(t,s[0]),a.fromBufferAttribute(t,s[1]),l.fromBufferAttribute(t,s[2]),zde.getNormal(Rb),d[s[0]]?o[0]=d[s[0]]:(o[0]=`${Math.round(e.x*n)},${Math.round(e.y*n)},${Math.round(e.z*n)}`,d[s[0]]=o[0]),d[s[1]]?o[1]=d[s[1]]:(o[1]=`${Math.round(a.x*n)},${Math.round(a.y*n)},${Math.round(a.z*n)}`,d[s[1]]=o[1]),d[s[2]]?o[2]=d[s[2]]:(o[2]=`${Math.round(l.x*n)},${Math.round(l.y*n)},${Math.round(l.z*n)}`,d[s[2]]=o[2]),o[0]===o[1]||o[1]===o[2]||o[2]===o[0]){fe.warn(" skip degenerate triangles in geometry !");continue}let h={a:s[0],b:s[1],c:s[2]};c[s[0]]||(c[s[0]]=[]),c[s[0]].push(h),c[s[1]]||(c[s[1]]=[]),c[s[1]].push(h),c[s[2]]||(c[s[2]]=[]),c[s[2]].push(h);for(let t=0;t<3;t++){let e=(t+1)%3,n=o[t],r=o[e],a=s[t],l=s[e];u[a]||(u[a]=new Set),u[a].add(l),u[l]||(u[l]=new Set),u[l].add(a);let h=`${n}_${r}`,c=`${r}_${n}`;if(c in p&&p[c]){if(p[c].outer){fe.warn(`edge: ${c} is already outer !`);continue}Rb.dot(p[c].normal)<=i?p[c].outer=!0:p[c].find=!0}else h in p?fe.warn(`${h} has existed in geometry !`):p[h]={startIndex:a,endIndex:l,normal:Rb.clone(),outer:!1,find:!1}}}for(let S in p)p[S]&&!p[S].find&&!p[S].outer&&(p[S].outer=!0);let f=[],m=[];for(let S in c)m.push(c[S]);let g=new Set;for(let S of m[0])g.add(S.a),g.add(S.b),g.add(S.c);let v=0;for(m.splice(v,1);;){let e=!1;for(let t=0;t<m.length&&!e;t++)for(let n of m[t])if(g.has(n.a)||g.has(n.b)||g.has(n.c)){v=t,e=!0;break}if(e){for(let e of m[v])g.add(e.a),g.add(e.b),g.add(e.c);if(m.splice(v,1),v=0,0===m.length){f.push(g);break}}else if(!e){if(f.push(g),!(m.length>0))break;g=new Set;for(let e of m[v])g.add(e.a),g.add(e.b),g.add(e.c);m.splice(v,1),v=0}}let y=new Set;for(let S=0;S<f.length;S++)f[S].forEach((e=>{y.has(e)?fe.warn(`${e} is already in positionIndexSet !`):y.add(e)}));let x=(e,t)=>{let n=!1,i=d[e];if(!i)return console.warn(`${e} is not in positionIndexHash !`),n;let r=d[t];if(!r)return console.warn(`${t} is not in positionIndexHash !`),n;let a=`${i}_${r}`;if(p[a])n=p[a].outer;else{let e=`${r}_${i}`;p[e]&&(n=p[e].outer)}return n},b=(e,t,n)=>{let i=[];return i.push(x(e,t)),i.push(x(t,n)),i.push(x(n,e)),i.filter((e=>!0===e)).length>=2},_=(e,t)=>{if(!u[e])return fe.warn(`${e} position isn't used !`),!0;let n=u[e];for(let r of n){let n=x(e,r),i=h[r];if(!i.inited)continue;let a=Act(t,i.point);if(n&&!a||!n&&a)return!1}let i=c[e];for(let r of i){let n=t,i=h[r.b],a=h[r.c];if(r.b===e?i=h[r.a]:r.c===e&&(a=h[r.a]),b(r.a,r.b,r.c)&&(i.inited&&n.equals(i.point)||a.inited&&n.equals(a.point)))return!1;if(i.inited&&a.inited&&(Zh.addVectors(n,i.point),Zh.add(a.point),Zh.x+Zh.y+Zh.z<2))return!1}return!0},w=!1;for(let S=0;S<f.length;S++){let e=Array.from(f[S]);w=!1;let t=0,n=0;for(;n>=0;){t=e[n];let i=h[t].inited?h[t].barycentricIndex+1:0;for(;i<l&&!_(t,uH[i]);i++);if(i<l){if(h[t].inited=!0,h[t].barycentricIndex=i,h[t].point.copy(uH[i]),n==e.length-1){w=!0,fe.debug(h);break}n++}else h[t].inited=!1,n--}if(!w){fe.warn(`no result: ${e} !`);break}}if(w){let t=[];for(let e=0;e<h.length;e++){h[e].inited||fe.warn(`${e} is not initialized !`);let n=0;n|=h[e].point.x,n|=h[e].point.y<<1,n|=h[e].point.z<<2,t.push(n)}let n=new Jx(t,1,!1);e.setAttribute("barycentric",n)}else fe.warn("No suitable barycentric found !");return w}},Ms=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)}},ya=class{parse(e,t={}){if(t=Object.assign({decodeSpeed:5,encodeSpeed:5,encoderMethod:ya.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=Gde(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=Gde(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,u=void 0!==t.decodeSpeed?t.decodeSpeed:5;if(s.SetSpeedOptions(h,u),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 c=new Int8Array(new ArrayBuffer(o));for(let d=0;d<o;d++)c[d]=l.GetValue(d);return a.destroy(l),a.destroy(s),a.destroy(n),c}},vR,hH,Dv,yR;function Gde(e){let t=new ct,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}function xR(e,t=1/0,n=null){hH||(hH=new mi(2,2,1,1)),Dv||(Dv=new hn({uniforms:{blitTexture:new vm(e)},vertexShader:"\n varying vec2 vUv;\n void main(){\n vUv = uv;\n gl_Position = vec4(position.xy * 1.0,0.,.999999);\n }",fragmentShader:"\n uniform sampler2D blitTexture; \n varying vec2 vUv;\n\n void main(){ \n gl_FragColor = vec4(vUv.xy, 0, 1);\n \n #ifdef IS_SRGB\n gl_FragColor = LinearTosRGB( texture2D( blitTexture, vUv) );\n #else\n gl_FragColor = texture2D( blitTexture, vUv);\n #endif\n }"})),Dv.uniforms.blitTexture.value=e,Dv.defines.IS_SRGB=e.colorSpace==sn,Dv.needsUpdate=!0,yR||((yR=new St(hH,Dv)).frustrumCulled=!1);let i=new Yr,r=new Ji;r.add(yR),n||(n=vR=new ga({antialias:!1})),n.setSize(Math.min(e.image.width,t),Math.min(e.image.height,t)),n.clear(),n.render(r,i);let a=new Hr(n.domElement);return a.minFilter=e.minFilter,a.magFilter=e.magFilter,a.wrapS=e.wrapS,a.wrapT=e.wrapT,a.name=e.name,vR&&(vR.dispose(),vR=null),a}ya.MESH_EDGEBREAKER_ENCODING=1,ya.MESH_SEQUENTIAL_ENCODING=0,ya.POINT_CLOUD=0,ya.TRIANGULAR_MESH=1,ya.INVALID=-1,ya.POSITION=0,ya.NORMAL=1,ya.COLOR=2,ya.TEX_COORD=3,ya.GENERIC=4;var qde={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"]},Ov=class{constructor(){this.pluginCallbacks=[],this.register((function(e){return new mH(e)})),this.register((function(e){return new gH(e)})),this.register((function(e){return new xH(e)})),this.register((function(e){return new bH(e)})),this.register((function(e){return new EH(e)})),this.register((function(e){return new _H(e)})),this.register((function(e){return new vH(e)})),this.register((function(e){return new yH(e)})),this.register((function(e){return new TH(e)})),this.register((function(e){return new wH(e)})),this.register((function(e){return new SH(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 pH,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)}))}},kr={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},dH="KHR_mesh_quantization",Wo={};Wo[Jr]=kr.NEAREST,Wo[Kd]=kr.NEAREST_MIPMAP_NEAREST,Wo[Oh]=kr.NEAREST_MIPMAP_LINEAR,Wo[Xr]=kr.LINEAR,Wo[bm]=kr.LINEAR_MIPMAP_NEAREST,Wo[Ba]=kr.LINEAR_MIPMAP_LINEAR,Wo[Pi]=kr.CLAMP_TO_EDGE,Wo[Ii]=kr.REPEAT,Wo[Fh]=kr.MIRRORED_REPEAT;var Wde={scale:"scale",position:"translation",quaternion:"rotation",morphTargetInfluences:"weights"},Rct=new ct,jde=12,Cct=1179937895,Pct=2,Xde=8,Ict=1313821514,Lct=5130562;function Cb(e,t){return e.length===t.length&&e.every((function(e,n){return e===t[n]}))}function Dct(e){return(new TextEncoder).encode(e).buffer}function Oct(e){return Cb(e.elements,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}function kct(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=Un.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 Zde(e){return 4*Math.ceil(e/4)}function fH(e,t=0){let n=Zde(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 Yde(){return"undefined"==typeof document&&"undefined"!=typeof OffscreenCanvas?new OffscreenCanvas(1,1):document.createElement("canvas")}function $de(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 pH=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 it(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),u=Object.keys(o);if(h.length>0&&(a.extensionsUsed=h),u.length>0&&(a.extensionsRequired=u),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=fH(e.result),i=new DataView(new ArrayBuffer(Xde));i.setUint32(0,n.byteLength,!0),i.setUint32(4,Lct,!0);let r=fH(Dct(JSON.stringify(a)),32),s=new DataView(new ArrayBuffer(Xde));s.setUint32(0,r.byteLength,!0),s.setUint32(4,Ict,!0);let o=new ArrayBuffer(jde),l=new DataView(o);l.setUint32(0,Cct,!0),l.setUint32(4,Pct,!0);let h=jde+s.byteLength+r.byteLength+i.byteLength+n.byteLength;l.setUint32(8,h,!0);let u=new Blob([o,s,r,i,n],{type:"application/octet-stream"}),c=new FileReader;c.readAsArrayBuffer(u),c.onloadend=function(){t(c.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 k;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 k;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===sn?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."),e instanceof wu&&(e=xR(e)),t instanceof wu&&(t=xR(t));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=Yde();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 u=(e||t).clone();return u.source=new bc(o),u.colorSpace=bu,u.channel=(e||t).channel,e&&t&&e.channel!==t.channel&&console.warn("THREE.GLTFExporter: UV channels for metalnessMap and roughnessMap textures must match."),u}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 kr.BYTE:case kr.UNSIGNED_BYTE:a=1;break;case kr.SHORT:case kr.UNSIGNED_SHORT:a=2;break;default:a=4}let o=Zde(i*e.itemSize*a),l=new DataView(new ArrayBuffer(o)),h=0;for(let c=n;c<n+i;c++)for(let n=0;n<e.itemSize;n++){let i;e.itemSize>4?i=e.array[c*e.itemSize+n]:(0===n?i=e.getX(c):1===n?i=e.getY(c):2===n?i=e.getZ(c):3===n&&(i=e.getW(c)),!0===e.normalized&&(i=Un.normalize(i,e.array))),t===kr.FLOAT?l.setFloat32(h,i,!0):t===kr.INT?l.setInt32(h,i,!0):t===kr.UNSIGNED_INT?l.setUint32(h,i,!0):t===kr.SHORT?l.setInt16(h,i,!0):t===kr.UNSIGNED_SHORT?l.setUint16(h,i,!0):t===kr.BYTE?l.setInt8(h,i):t===kr.UNSIGNED_BYTE&&l.setUint8(h,i),h+=a}let u={buffer:this.processBuffer(l.buffer),byteOffset:this.byteOffset,byteLength:o};return void 0!==r&&(u.target=r),r===kr.ARRAY_BUFFER&&(u.byteStride=e.itemSize*a),this.byteOffset+=o,s.bufferViews.push(u),{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=fH(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=kr.FLOAT;else if(e.array.constructor===Int32Array)r=kr.INT;else if(e.array.constructor===Uint32Array)r=kr.UNSIGNED_INT;else if(e.array.constructor===Int16Array)r=kr.SHORT;else if(e.array.constructor===Uint16Array)r=kr.UNSIGNED_SHORT;else if(e.array.constructor===Int8Array)r=kr.BYTE;else{if(e.array.constructor!==Uint8Array)throw new Error("THREE.GLTFExporter: Unsupported bufferAttribute component type: "+e.array.constructor.name);r=kr.UNSIGNED_BYTE}if(void 0===n&&(n=0),void 0===i&&(i=e.count),0===i)return null;let s,o=kct(e,n,i);void 0!==t&&(s=e===t.index?kr.ELEMENT_ARRAY_BUFFER:kr.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),u=i+":flipY/"+n.toString();if(void 0!==h[u])return h[u];s.images||(s.images=[]);let c={mimeType:i},d=Yde();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!==ea&&console.error("GLTFExporter: Only RGBAFormat is supported.",t),(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($de(d,i).then((e=>r.processBufferViewImage(e))).then((e=>{c.bufferView=e}))):void 0!==d.toDataURL?c.uri=d.toDataURL(i):l.push($de(d,i).then((e=>(new FileReader).readAsDataURL(e))).then((e=>{c.uri=e})));let f=s.images.push(c)-1;return h[u]=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:Wo[e.magFilter],minFilter:Wo[e.minFilter],wrapS:Wo[e.wrapS],wrapT:Wo[e.wrapT]};return t.samplers.push(n)-1}processTexture(e){let t=this.options,n=this.cache,i=this.json;if(n.textures.has(e))return n.textures.get(e);i.textures||(i.textures=[]),e instanceof wu&&(e=xR(e,t.maxTextureSize));let r=e.userData.mimeType;"image/webp"===r&&(r="image/png");let a={sampler:this.processSampler(e),source:this.processImage(e.image,e.format,e.flipY,r)};e.name&&(a.name=e.name),this._invokeAll((function(t){t.writeTexture&&t.writeTexture(e,a)}));let s=i.textures.push(a)-1;return n.textures.set(e,s),s}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(Cb(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===hr&&(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?kr.LINES:e.isLineLoop?kr.LINE_LOOP:e.isLine?kr.LINE_STRIP:e.isPoints?kr.POINTS:e.material.wireframe?kr.LINES:kr.TRIANGLES;let o={},l={},h=[],u=[],c={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=c[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 yn(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])}u.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),u.length>0&&(e.targets=u),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[dH])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];qde[i]&&qde[i].includes(n)&&(this.extensionsUsed[dH]=!0,this.extensionsRequired[dH]=!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:Un.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=Ov.Utils.mergeMorphTargetTracks(e.clone(),t)).tracks,a=[],s=[];for(let o=0;o<r.length;++o){let e=r[o],n=Jn.parseTrackName(e.name),l=Jn.findNode(t,n.nodeName),h=Wde[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 u,c=1,d=e.values.length/e.times.length;h===Wde.morphTargetInfluences&&(d/=l.morphTargetInfluences.length),!0===e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline?(u="CUBICSPLINE",d/=3):u=e.getInterpolation()===Bh?"STEP":"LINEAR",s.push({input:this.processAccessor(new yn(e.times,c)),output:this.processAccessor(new yn(e.values,d)),interpolation:u}),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 ht;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 yn(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();Cb(t,[0,0,0,1])||(r.rotation=t),Cb(n,[0,0,0])||(r.translation=n),Cb(i,[1,1,1])||(r.scale=i)}else e.matrixAutoUpdate&&e.updateMatrix(),!1===Oct(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 Ji;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 Ji?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])}},mH=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}}},gH=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}},vH=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}},yH=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}},xH=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}},bH=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}},EH=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}},_H=class{constructor(e){this.writer=e,this.name="KHR_materials_specular"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||1===e.specularIntensity&&e.specularColor.equals(Rct)&&!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}},TH=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}},wH=class{constructor(e){this.writer=e,this.name="KHR_materials_anisotropy"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0==e.anisotropy)return;let n=this.writer,i=n.extensionsUsed,r={};if(e.anisotropyMap){let t={index:n.processTexture(e.anisotropyMap)};n.applyTextureTransform(t,e.anisotropyMap),r.anisotropyTexture=t}r.anisotropyStrength=e.anisotropy,r.anisotropyRotation=e.anisotropyRotation,t.extensions=t.extensions||{},t.extensions[this.name]=r,i[this.name]=!0}},SH=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}};Ov.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=Jn.parseTrackName(e.name),o=Jn.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(Eu)}let l,h=o.morphTargetInfluences.length,u=o.morphTargetDictionary[s.propertyIndex];if(void 0===u)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+u]=l.values[e];l.name=(s.nodeName||"")+".morphTargetInfluences",l.values=t,i[o.uuid]=l,n.push(l);continue}let c=e.createInterpolant(new e.ValueBufferType(1));l=i[o.uuid];for(let t=0;t<l.times.length;t++)l.values[t*h+u]=c.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+u]=e.values[t]}}return e.tracks=n,e}};var bR=class{parse(e){let t="",n=0,i=0,r=0,a=new k,s=new ct,o=new k,l=new _e,h=[];return e.traverse((function(e){!0===e.isMesh&&function(e){let s=0,u=0,c=0,d=e.geometry,p=new In,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++,c++)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++,u++)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+=c,r+=u}(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}},ER=class{parse(e,t={}){let n=(t=Object.assign({binary:!1},t)).binary,i=[],r=0;e.traverse((function(e){if(e.isMesh){let t=e.geometry,n=t.index,a=t.getAttribute("position");r+=null!==n?n.count/3:a.count/3,i.push({object3d:e,geometry:t})}}));let a,s=80;if(!0===n){let e=new ArrayBuffer(2*r+3*r*4*4+80+4);a=new DataView(e),a.setUint32(s,r,!0),s+=4}else a="",a+="solid exported\n";let o=new k,l=new k,h=new k,u=new k,c=new k,d=new k;for(let m=0,g=i.length;m<g;m++){let e=i[m].object3d,t=i[m].geometry,n=t.index,r=t.getAttribute("position");if(null!==n)for(let i=0;i<n.count;i+=3)p(n.getX(i+0),n.getX(i+1),n.getX(i+2),r,e);else for(let i=0;i<r.count;i+=3)p(i+0,i+1,i+2,r,e)}return!1===n&&(a+="endsolid exported\n"),a;function p(e,t,i,r,p){o.fromBufferAttribute(r,e),l.fromBufferAttribute(r,t),h.fromBufferAttribute(r,i),!0===p.isSkinnedMesh&&(p.applyBoneTransform(e,o),p.applyBoneTransform(t,l),p.applyBoneTransform(i,h)),o.applyMatrix4(p.matrixWorld),l.applyMatrix4(p.matrixWorld),h.applyMatrix4(p.matrixWorld),function(e,t,i){u.subVectors(i,t),c.subVectors(e,t),u.cross(c).normalize(),d.copy(u).normalize(),!0===n?(a.setFloat32(s,d.x,!0),s+=4,a.setFloat32(s,d.y,!0),s+=4,a.setFloat32(s,d.z,!0),s+=4):(a+="\tfacet normal "+d.x+" "+d.y+" "+d.z+"\n",a+="\t\touter loop\n")}(o,l,h),f(o),f(l),f(h),!0===n?(a.setUint16(s,0,!0),s+=2):(a+="\t\tendloop\n",a+="\tendfacet\n")}function f(e){!0===n?(a.setFloat32(s,e.x,!0),s+=4,a.setFloat32(s,e.y,!0),s+=4,a.setFloat32(s,e.z,!0),s+=4):a+="\t\t\tvertex "+e.x+" "+e.y+" "+e.z+"\n"}}},di=class{static exportToGltf(e,t){di.exportToGltfOrGlb(e,t,{binary:!1})}static exportToGlb(e,t){di.exportToGltfOrGlb(e,t,{binary:!0})}static exportToGltfOrGlb(e,t,n={}){if(!e||!t)throw new Error("Invalid input or filename!");let i=new Ov;n=Object.assign({},{binary:!0,onlyVisible:!1,includeCustomExtensions:!1},n),i.parse(e,(e=>{if(n.binary){t=di.addExtention(t,di.EXTENSION_GLB);let n=e;di.saveArrayBuffer(n,t)}else t=di.addExtention(t,di.EXTENSION_GLTF),di.saveJson(e,t)}),(e=>console.log(e)),n)}static exportToObj(e,t){if(!e||!t)throw new Error("Invalid input or filename!");t=di.addExtention(t,di.EXTENSION_OBJ);let n=(new bR).parse(e);di.saveString(n,t)}static exportToDraco(e,t,n={}){if(!e||!t)throw new Error("Invalid input or filename!");t=di.addExtention(t,di.EXTENSION_DRACO);let i=new ya;n=Object.assign({},{encodeSpeed:5},n);let r=i.parse(e,n);di.saveArrayBuffer(r,t)}static exportToStl(e,t,n=!1){if(!e||!t)throw new Error("Invalid input or filename!");t=di.addExtention(t,di.EXTENSION_STL);let i=new ER;if(n){let n={binary:!0},r=i.parse(e,n);di.saveDataView(r,t)}else{let n=i.parse(e);di.saveString(n,t)}}static exportToThreeJsJson(e,t){let n=e.toJSON();t.toLowerCase().endsWith(di.EXTENSION_JSON)||(t+=di.EXTENSION_JSON),di.saveJson(n,t)}static save(e,t){let n=di.downloadLink;n||(n=document.createElement("a"),n.style.display="none",document.body.appendChild(n),di.downloadLink=n),n.href=URL.createObjectURL(e),n.download=t,n.click()}static saveArrayBuffer(e,t){di.save(new Blob([e],{type:"application/octet-stream"}),t)}static saveJson(e,t){di.saveJsonString(JSON.stringify(e),t)}static saveJsonString(e,t){di.save(new Blob([e],{type:"application/json"}),t)}static saveString(e,t){di.save(new Blob([e],{type:"text/plain"}),t)}static saveDataView(e,t){di.save(new Blob([e],{type:"application/octet-stream"}),t)}static addExtention(e,t){return e.toLowerCase().endsWith(t.toLowerCase())||(e+=t),e}},gf=di;gf.EXTENSION_GLTF=".gltf",gf.EXTENSION_GLB=".glb",gf.EXTENSION_OBJ=".obj",gf.EXTENSION_DRACO=".drc",gf.EXTENSION_JSON=".json",gf.EXTENSION_STL=".stl";var Kde=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()}},IH={exports:{}};function wR(e,t,n){n=n||2;var i,r,a,s,o,l,h,u=t&&t.length,c=u?t[0]*n:e.length,d=rfe(e,0,c,n,!0),p=[];if(!d||d.next===d.prev)return p;if(u&&(d=Hct(e,t,d,n)),e.length>80*n){i=a=e[0],r=s=e[1];for(var f=n;f<c;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 Pb(d,p,n,i,r,h,0),p}function rfe(e,t,n,i,r){var a,s;if(r===PH(e,t,n,i)>0)for(a=t;a<n;a+=i)s=Jde(a,e[a],e[a+1],s);else for(a=n-i;a>=t;a-=i)s=Jde(a,e[a],e[a+1],s);return s&&SR(s,s.next)&&(Lb(s),s=s.next),s}function Sm(e,t){if(!e)return e;t||(t=e);var n,i=e;do{if(n=!1,i.steiner||!SR(i,i.next)&&0!==es(i.prev,i,i.next))i=i.next;else{if(Lb(i),(i=t=i.prev)===i.next)break;n=!0}}while(n||i!==t);return t}function Pb(e,t,n,i,r,a,s){if(e){!s&&a&&Wct(e,i,r,a);for(var o,l,h=e;e.prev!==e.next;)if(o=e.prev,l=e.next,a?Nct(e,i,r,a):Fct(e))t.push(o.i/n|0),t.push(e.i/n|0),t.push(l.i/n|0),Lb(e),e=l.next,h=l.next;else if((e=l)===h){s?1===s?Pb(e=Bct(Sm(e),t,n),t,n,i,r,a,2):2===s&&Uct(e,t,n,i,r,a):Pb(Sm(e),t,n,i,r,a,1);break}}}function Fct(e){var t=e.prev,n=e,i=e.next;if(es(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,u=r<a?r<s?r:s:a<s?a:s,c=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>=u&&f.x<=d&&f.y>=c&&f.y<=p&&kv(r,o,a,l,s,h,f.x,f.y)&&es(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function Nct(e,t,n,i){var r=e.prev,a=e,s=e.next;if(es(r,a,s)>=0)return!1;for(var o=r.x,l=a.x,h=s.x,u=r.y,c=a.y,d=s.y,p=o<l?o<h?o:h:l<h?l:h,f=u<c?u<d?u:d:c<d?c:d,m=o>l?o>h?o:h:l>h?l:h,g=u>c?u>d?u:d:c>d?c:d,v=RH(p,f,t,n,i),y=RH(m,g,t,n,i),x=e.prevZ,b=e.nextZ;x&&x.z>=v&&b&&b.z<=y;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==r&&x!==s&&kv(o,u,l,c,h,d,x.x,x.y)&&es(x.prev,x,x.next)>=0||(x=x.prevZ,b.x>=p&&b.x<=m&&b.y>=f&&b.y<=g&&b!==r&&b!==s&&kv(o,u,l,c,h,d,b.x,b.y)&&es(b.prev,b,b.next)>=0))return!1;b=b.nextZ}for(;x&&x.z>=v;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==r&&x!==s&&kv(o,u,l,c,h,d,x.x,x.y)&&es(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;b&&b.z<=y;){if(b.x>=p&&b.x<=m&&b.y>=f&&b.y<=g&&b!==r&&b!==s&&kv(o,u,l,c,h,d,b.x,b.y)&&es(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function Bct(e,t,n){var i=e;do{var r=i.prev,a=i.next.next;!SR(r,a)&&ife(r,i,i.next,a)&&Ib(r,a)&&Ib(a,r)&&(t.push(r.i/n|0),t.push(i.i/n|0),t.push(a.i/n|0),Lb(i),Lb(i.next),i=e=a),i=i.next}while(i!==e);return Sm(i)}function Uct(e,t,n,i,r,a){var s=e;do{for(var o=s.next.next;o!==s.prev;){if(s.i!==o.i&&Yct(s,o)){var l=sfe(s,o);return s=Sm(s,s.next),l=Sm(l,l.next),Pb(s,t,n,i,r,a,0),void Pb(l,t,n,i,r,a,0)}o=o.next}s=s.next}while(s!==e)}function Hct(e,t,n,i){var r,a,s,o=[];for(r=0,a=t.length;r<a;r++)(s=rfe(e,t[r]*i,r<a-1?t[r+1]*i:e.length,i,!1))===s.next&&(s.steiner=!0),o.push(Xct(s));for(o.sort(Vct),r=0;r<o.length;r++)n=zct(o[r],n);return n}function Vct(e,t){return e.x-t.x}function zct(e,t){var n=Gct(e,t);if(!n)return t;var i=sfe(n,e);return Sm(i,i.next),Sm(n,n.next)}function Gct(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,u=n.x,c=n.y,d=1/0;i=n;do{r>=i.x&&i.x>=u&&r!==i.x&&kv(a<c?r:s,a,u,c,a<c?s:r,a,i.x,i.y)&&(l=Math.abs(a-i.y)/(r-i.x),Ib(i,e)&&(l<d||l===d&&(i.x>n.x||i.x===n.x&&qct(n,i)))&&(n=i,d=l)),i=i.next}while(i!==h);return n}function qct(e,t){return es(e.prev,e,t.prev)<0&&es(t.next,e,e.next)<0}function Wct(e,t,n,i){var r=e;do{0===r.z&&(r.z=RH(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,jct(r)}function jct(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 RH(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 Xct(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 kv(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 Yct(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!$ct(e,t)&&(Ib(e,t)&&Ib(t,e)&&Zct(e,t)&&(es(e.prev,e,t.prev)||es(e,t.prev,t))||SR(e,t)&&es(e.prev,e,e.next)>0&&es(t.prev,t,t.next)>0)}function es(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function SR(e,t){return e.x===t.x&&e.y===t.y}function ife(e,t,n,i){var r=TR(es(e,t,n)),a=TR(es(e,t,i)),s=TR(es(n,i,e)),o=TR(es(n,i,t));return!!(r!==a&&s!==o||0===r&&_R(e,n,t)||0===a&&_R(e,i,t)||0===s&&_R(n,e,i)||0===o&&_R(n,t,i))}function _R(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 TR(e){return e>0?1:e<0?-1:0}function $ct(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&&ife(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}function Ib(e,t){return es(e.prev,e,e.next)<0?es(e,t,e.next)>=0&&es(e,e.prev,t)>=0:es(e,t,e.prev)<0||es(e,e.next,t)<0}function Zct(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 sfe(e,t){var n=new CH(e.i,e.x,e.y),i=new CH(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 Jde(e,t,n,i){var r=new CH(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 Lb(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 CH(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 PH(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}IH.exports=wR,IH.exports.default=wR,wR.deviation=function(e,t,n,i){var r=t&&t.length,a=r?t[0]*n:e.length,s=Math.abs(PH(e,0,a,n));if(r)for(var o=0,l=t.length;o<l;o++){var h=t[o]*n,u=o<l-1?t[o+1]*n:e.length;s-=Math.abs(PH(e,h,u,n))}var c=0;for(o=0;o<i.length;o+=3){var d=i[o]*n,p=i[o+1]*n,f=i[o+2]*n;c+=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===c?0:Math.abs((c-s)/s)},wR.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 wDt=IH.exports;function Qde(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e[2]=t[2]-n[2],e}function Kct(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 Jct(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 Qct(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,u=new Float32Array(t.length),c=0;c<h;){var d=3*e[c],p=3*e[c+1],f=3*e[c+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]),Qde(o,a,r),Qde(s,i,r),Jct(l,o,s);for(var m=0;m<3;m++)u[d+m]+=l[m],u[p+m]+=l[m],u[f+m]+=l[m];c+=3}for(var g=0,v=u.length;g<v;)n(l,u[g],u[g+1],u[g+2]),Kct(l,l),u[g]=l[0]||0,u[g+1]=l[1]||0,u[g+2]=l[2]||0,g+=3;return u}function eut(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,u=0,c=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 b=0,_=v.length;b<_;){var w=v[b]+u;l.indices[c]=w,c++,b++}d+=x.length,h+=g.length,u+=g.length/3}return l}function tut(e){return 180*e/Math.PI}function efe(e){return e/180*Math.PI}function nut(e,t,n,i,r,a){var s=3*n,o=3*i,l=3*r,h=3*a,u=t[s],c=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],b=t[h+1],_=t[h+2];Math.abs(c-f)<Math.abs(u-p)?(e.push(u,1-d),e.push(p,1-m),e.push(g,1-y),e.push(x,1-_)):(e.push(c,1-d),e.push(f,1-m),e.push(v,1-y),e.push(b,1-_))}function afe(e,t){t=Object.assign({},{depth:2,lineWidth:1},t);var n=eut(e.map((function(e){var n=sut(e,t);return n.line=e,rut(n,t),iut(n,t),n.position=new Float32Array(n.points),n.indices=new Uint32Array(n.index),n.uv=new Float32Array(n.uvs),n.normal=Qct(n.indices,n.position),n})));return n.lines=e,n}function rut(e,t){for(var n=t.depth,i=[],r=[],a=[],s=e.leftPoints,o=e.rightPoints,l=0,h=s.length;l<h;){var u=3*l,c=s[l],d=c[0],p=c[1],f=c[2];i[u]=d,i[u+1]=p,i[u+2]=n+f;var m=o[l],g=m[0],v=m[1],y=m[2],x=3*h+u;i[x]=g,i[x+1]=v,i[x+2]=n+y;var b=2*h*3+u;i[b]=d,i[b+1]=p,i[b+2]=f;var _=2*h*3+3*h+u;i[_]=g,i[_+1]=v,i[_+2]=y,l++}for(l=0,h=i.length;l<h;){var w=i[l],S=i[l+1];a.push(w,S),l+=3}for(l=0,h=s.length;l<h-1;){var M=l,E=l+1,T=M+h,A=E+h;r.push(M,T,E),r.push(T,A,E);var C=l+2*h,P=C+1,R=C+h,L=P+h;r.push(C,R,P),r.push(R,L,P),l++}e.index=r,e.points=i,e.uvs=a}function iut(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,u=r+1;i.push(a,h,l,h,u,l),nut(s,n,a,l,h,u)}for(var u=0,c=l.length;u<c;u++){var d=l[u];u>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 MH={x:0,y:0},AH={x:0,y:0};function sut(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],u=e[l+1],c=u[1]-h[1],d=u[0]-h[0],p=0,f=tut(Math.atan(c/d));if(n=f,0===l)p=f,p-=90;else{var m=e[l-1];MH.x=m[0]-h[0],MH.y=m[1]-h[1],AH.x=u[0]-h[0],AH.y=u[1]-h[1],p=f-aut(MH,AH)/2}var g=tfe(efe(p),i,h),v=g[0],y=g[1];r.push(v,y),nfe(v,h,u)?(a.push(v),s.push(y)):(a.push(y),s.push(v)),l++}var x=n,b=efe(x-=90),_=e[o-2],w=e[o-1],S=tfe(b,i,w),M=S[0],E=S[1];return r.push(M,E),nfe(M,_,w)?(a.push(M),s.push(E)):(a.push(E),s.push(M)),{offsetPoints:r,leftPoints:a,rightPoints:s}}function tfe(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 aut=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 nfe(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 LH=1e-15,ofe=(new ht).set(0,0,-1,0,1,0,0,0,0,1,0,0,0,0,0,1),lfe=(new ht).set(0,1,0,0,1,0,0,0,0,0,1,0,0,0,0,1),Zt=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 Zt.areNumbersEqual(e.x,t.x,n)&&Zt.areNumbersEqual(e.y,t.y,n)}static areVector3sEqual(e,t,n=1e-7){return Zt.areNumbersEqual(e.x,t.x,n)&&Zt.areNumbersEqual(e.y,t.y,n)&&Zt.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 Zt.areNumbersClose(e,t,LH)?0:(e%=n,Zt.areNumbersClose(e,t%n,LH)?n:(Zt.areNumbersClose(t,n,LH)&&(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=Zt.getIntegerPartLength(e);return Math.max(Math.pow(10,n)*t,t)}static getVector2RelativeEps(e,t=1e-7){return Math.min(Zt.getRelativeEps(e.x,t),Zt.getRelativeEps(e.y,t))}static getControlPointByTwoPoints(e,t){let n=(new _e).subVectors(t,e),i=n.angle(),r=n.length(),a=Un.degToRad(45),s=r/2/Math.cos(a);return new _e(e.x+s*Math.cos(a-i),e.y-s*Math.sin(a-i))}static convertPointFromUEToGltf(e){let t=new k(e.x,e.y,e.z);return t.applyMatrix4(ofe.clone().invert()),{x:t.x,y:t.y,z:t.z}}static convertPointFromGltfToUE(e){let t=new k(e.x,e.y,e.z);return t.applyMatrix4(ofe),{x:t.x,y:t.y,z:t.z}}static convertPointFromUEToRevit(e){let t=new k(e.x,e.y,e.z);return t.applyMatrix4(lfe.clone().invert()),{x:t.x,y:t.y,z:t.z}}static convertPointFromRevitToUE(e){let t=new k(e.x,e.y,e.z);return t.applyMatrix4(lfe),{x:t.x,y:t.y,z:t.z}}static getBox(e,t){return[Math.min(e.x,t.x),Math.min(e.y,t.y),Math.min(e.z,t.z),Math.max(e.x,t.x),Math.max(e.y,t.y),Math.max(e.z,t.z)]}static getCenter(e){let t=new k(e[0],e[1],e[2]),n=new k(e[3],e[4],e[5]),i=(new k).addVectors(t,n).multiplyScalar(.5);return{x:i.x,y:i.y,z:i.z}}static convertBoxFromGltfToUE(e){let t=Zt.convertPointFromGltfToUE({x:e[0],y:e[1],z:e[2]}),n=Zt.convertPointFromGltfToUE({x:e[3],y:e[4],z:e[5]});return Zt.getBox(t,n)}static convertBoxFromUEToGltf(e){let t=Zt.convertPointFromUEToGltf({x:e[0],y:e[1],z:e[2]}),n=Zt.convertPointFromUEToGltf({x:e[3],y:e[4],z:e[5]});return Zt.getBox(t,n)}static convertBoxFromRevitToUE(e){let t=Zt.convertPointFromRevitToUE({x:e[0],y:e[1],z:e[2]}),n=Zt.convertPointFromRevitToUE({x:e[3],y:e[4],z:e[5]});return Zt.getBox(t,n)}static convertBoxFromUEToRevit(e){let t=Zt.convertPointFromUEToRevit({x:e[0],y:e[1],z:e[2]}),n=Zt.convertPointFromUEToRevit({x:e[3],y:e[4],z:e[5]});return Zt.getBox(t,n)}static clamp(e,t,n){return Math.max(t,Math.min(n,e))}static getLookAtMatrix(e,t,n){let i=new ht,r=new k(e.x,e.y,e.z),a=new k(t.x,t.y,t.z),s=new k(n.x,n.y,n.z);i.lookAt(r,a,s),i.transpose();let o=[];return i.toArray(o),o}static getLocationFromMatrix(e){let t=new k;return t.setFromMatrixPosition((new ht).fromArray(e)),{x:t.x,y:t.y,z:t.z}}static toDegrees(e){return Un.radToDeg(e)}static toRadians(e){return Un.degToRad(e)}},DH=1e7,cfe=new _i,ufe=new _i,hfe=new k,dfe=new k,ffe=new k,vf=new ni,en=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 fo){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,u=t[l].y,c=s>r!=u>r;n&&(c=s>=r!=u>=r),c&&i<(h-e)*(r-s)/(u-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 k,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 _e,a=new _e;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)),u=n.clone().sub(r),c=a.clone().sub(r),d=i.clone().sub(r),p=u.cross(c).dot(d.cross(c));return h<0&&p<0}static getLineSegmentsIntersectingPoint(e,t){let{start:n,end:i}=e,{start:r,end:a}=t,s=hfe.subVectors(i,n).normalize(),o=dfe.subVectors(a,r).normalize();if(1===s.dot(o))return null;let l=ffe.subVectors(r,n),h=s.clone().cross(o),u=l.clone().cross(o),c=l.clone().dot(h);if(c>=1e-5||c<=-1e-5)return null;let d=h.lengthSq();if(Zt.areNumbersEqual(0,d))return;let p=u.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=hfe.subVectors(i,r).length(),s=dfe.subVectors(e,i).length(),o=ffe.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 k;e.forEach((e=>{n?t.add(e):(t.x+=e.x,t.y+=e.y)})),t.divideScalar(e.length);let i=!1;if(en.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 k(r,a,e[i].z-t.z):new _e(r,a)}}else t.setScalar(0);return i}static shouldRebasePositionOnRTC(e){return Math.abs(e.x)>DH||Math.abs(e.y)>DH||e instanceof k&&Math.abs(e.z)>DH}static calculateSurfaceArea(e){let t=0,n=e.getAttribute("position"),i=e.index;if(i)for(let r=0;r<i.count;r+=3)vf.a.fromBufferAttribute(n,i.getX(r)),vf.b.fromBufferAttribute(n,i.getX(r+1)),vf.c.fromBufferAttribute(n,i.getX(r+2)),t+=vf.getArea();else for(let r=0;r<n.count;r+=3)vf.a.fromBufferAttribute(n,r),vf.b.fromBufferAttribute(n,r+1),vf.c.fromBufferAttribute(n,r+2),t+=vf.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 Ot,n=e.index;for(let i in e.attributes)t.setAttribute(i,en.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 yn(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 k(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||(cfe.setFromPoints(e),ufe.setFromPoints(t),!cfe.intersectsBox(ufe)))return!1;for(let n=0;n<e.length;){if(this.isPointInPolygon(e[n],t,!0))return!0;n<e.length-1&&Zt.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,u=i.y-n.y,c=n.x-i.x,d=u*n.x+c*n.y,p=o*c-u*l;return Math.abs(p)<r?void 0:new _e((c*h-l*d)/p,(o*d-u*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 _e(-a*r,a*i)}static convertSimpleWidthLineToMeshGeometry(e,t){let n,i,r,a=!1,s=!1,o=[],l=[],h=new _e,u=new _e,c=new _e,d=new _e,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 _e(e[y].x+n.x,e[y].y+n.y),u=new _e(e[y+1].x+n.x,e[y+1].y+n.y),c=new _e(e[y].x-n.x,e[y].y-n.y),d=new _e(e[y+1].x-n.x,e[y+1].y-n.y),a||(i=this.getLineLineIntersectionPoint(o[0],o[1],h,u),void 0!==i?p.unshift(i):p.unshift(h),r=this.getLineLineIntersectionPoint(l[0],l[1],c,d),void 0!==r?p.push(r):p.push(c)),a&&(p.unshift(h),p.push(c)),s&&(p.unshift(u),p.push(d)),s||(o=[h,u],l=[c,d]);if(p.length<3)return;let m=qs.triangulateShape(p,[]),g=[];for(let y=0;y<m.length;y++)g.push(...m[y]);let v=(new Ot).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}=afe([n],{lineWidth:t,depth:1}),r=new Ot;return r.setAttribute("position",new Bt(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++)Zt.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}},pfe={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, click start point 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"}},mfe={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\u70b9\u51fb\u8d77\u70b9\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"}},Si=class{static materialEquals(e,t){if(e===t)return!0;if(e.type!==t.type)return!1;if(e instanceof Ar&&t instanceof Ar){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 Ar&&t instanceof Ar&&this.materialEquals(e,t)}static colorEquals(e,t){return e===t||e instanceof ct&&t instanceof ct&&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 Ar)return this.clonedHighlightMaterial(n,t);console.warn(`[MaterialUtils] Invalid material: ${n}`)}static clonedHighlightMaterial(e,t={}){let{depthTest:n,highlightColor:i=new ct(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=hr),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 ct(16777215);return e instanceof Li||e instanceof zn||e instanceof cn?t=e.color:e instanceof hn&&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 setMaterialOpacity(e,t){var n;let i=e;i.transparent=!0,i.opacity=t,null!=(n=i.uniforms)&&n.opacity&&(i.uniforms.opacity.value=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 Oi(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 Ot,h=0;for(let u=0;u<e.length;++u){let c=e[u],d=0;if(n!==(null!==c.index))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(let e in c.attributes){if(!i.has(e))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+'. 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(c.attributes[e]),d++}if(d!==i.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+". Make sure all geometries have the same number of attributes."),null;if(o!==c.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(let e in c.morphAttributes){if(!r.has(e))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+". .morphAttributes must be consistent throughout all geometries."),null;void 0===s[e]&&(s[e]=[]),s[e].push(c.morphAttributes[e])}if(t){let e;if(n)e=c.index.count;else{if(void 0===c.attributes.position)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+". The geometry must have either an index or a position attribute"),null;e=c.attributes.position.count}l.addGroup(h,e,u),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 u in a){let e=gfe(a[u]);if(!e)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+u+" attribute."),null;l.setAttribute(u,e)}for(let u in s){let e=s[u][0].length;if(0===e)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[u]=[];for(let t=0;t<e;++t){let e=[];for(let i=0;i<s[u].length;++i)e.push(s[u][i][t]);let n=gfe(e);if(!n)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+u+" morphAttribute."),null;l.morphAttributes[u].push(n)}}return l}function gfe(e){let t,n,i,r=-1,a=0;for(let h=0;h<e.length;++h){let s=e[h];if(s.isInterleavedBufferAttribute)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. InterleavedBufferAttributes are not supported."),null;if(void 0===t&&(t=s.array.constructor),t!==s.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(void 0===n&&(n=s.itemSize),n!==s.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(void 0===i&&(i=s.normalized),i!==s.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(-1===r&&(r=s.gpuType),r!==s.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;a+=s.array.length}let s=new t(a),o=0;for(let h=0;h<e.length;++h)s.set(e[h].array,o),o+=e[h].array.length;let l=new yn(s,n,i);return void 0!==r&&(l.gpuType=r),l}function vfe(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={},u=[],c=["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 yn(new n.array.constructor(n.count*n.itemSize),n.itemSize,n.normalized);let i=e.morphAttributes[t];i&&(h[t]=new yn(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[c[e]](t)*f)+","}if(r in n)u.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],u=r.itemSize,p=l[i],f=h[i];for(let e=0;e<u;e++){let n=c[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,u.push(s),s++}}let m=e.clone();for(let g in e.attributes){let e=l[g];if(m.setAttribute(g,new yn(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 yn(e.array.slice(0,s*e.itemSize),e.itemSize,e.normalized)}}return m.setIndex(u),m}function OH(e,t){if(t===CU)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),e;if(t===gv||t===xb){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===gv)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}var kH=new Nt,FH=new ht,pn=class{constructor(e=0){this.name="",this.type=0,this.matrix=new ht,this.children=[],this.layers=new Jd,this.renderOrder=0,this.userData={},this.type=e}add(e,...t){for(let n=0;n<t.length;n++)this.add(t[n]);return e===this?(console.error("object can't be added as a child of itself.",e),this):(e.parent&&e.parent.remove(e),e.parent=this,this.children.push(e),this)}remove(e,...t){for(let i=0;i<t.length;i++)this.remove(t[i]);let n=this.children.indexOf(e);return-1!==n&&(e.parent=void 0,this.children.splice(n,1)),this}removeFromParent(){let e=this.parent;return e&&e.remove(this),this}clear(){this.material=void 0,this.geometry=void 0;for(let e=0;e<this.children.length;e++)this.children[e].parent=void 0;return this.children.length=0,this}traverse(e){e(this);let t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverse(e)}clone(e=!0){return(new pn).copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.type=e.type,this.matrix.copy(e.matrix),this.layers.mask=e.layers.mask,this.renderOrder=e.renderOrder,this.userData=JSON.parse(JSON.stringify(e.userData)),this.material=e.material,this.geometry=e.geometry,!0===t)for(let n=0;n<e.children.length;n++){let t=e.children[n];this.add(t.clone())}return this}convertToThreejsObject(e=!0){let t;switch(this.type){case 0:t=new an;break;case 1:if(!this.geometry)return;t=new Di(this.geometry,this.material);break;case 2:if(!this.geometry)return;t=new Vr(this.geometry,this.material);break;case 3:if(!this.geometry)return;t=new zr(this.geometry,this.material);break;case 4:if(!this.geometry)return;t=new St(this.geometry,this.material)}if(t){if(t.name=this.name,t.matrixAutoUpdate=!1,t.applyMatrix4(this.matrix),t.layers.mask=this.layers.mask,t.renderOrder=this.renderOrder,t.userData=this.userData,!0===e)for(let n=0;n<this.children.length;n++){let i=this.children[n].convertToThreejsObject(e);i&&t.add(i)}return t}}static getBox(e,t,n){if(e.geometry)e.geometry.boundingBox||e.geometry.computeBoundingBox(),FH.copy(e.matrix),n&&FH.premultiply(n),kH.copy(e.geometry.boundingBox),kH.applyMatrix4(FH),t.union(kH);else if(e.children.length>0){e.matrixWorld||(e.matrixWorld=new ht),e.matrixWorld.copy(e.matrix),n&&e.matrixWorld.premultiply(n);let i=e.children;for(let n=0,r=i.length;n<r;n++)this.getBox(i[n],t,e.matrixWorld)}return t}},lut=new k(0,1,0),Pc=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=hr)},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 St){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&&fe.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 St)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 Pc.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}`);Pc.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 St&&(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 cn({color:0,transparent:!0,opacity:.05});this.applyMaterialToObject(e,i,t,n)}static setWireframeMode(e){let t=new cn({color:16732160,wireframe:!0,transparent:!0,opacity:.8});e.traverseVisible((e=>{if(e instanceof St){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}`);Pc.setWireframeMode(n)}static revertWireframeMode(e){e.traverseVisible((e=>{e instanceof St&&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}`);Pc.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){return it(this,arguments,(function*(e,t={onlyVisible:!0,meshOnly:!0},n){if(!e)return[];if(0===e.children.length&&(t.onlyVisible&&!e.visible||t.meshOnly&&!(e instanceof St)))return[];let i=[],r=e,a=r.children.length,s=Math.round(Math.pow(a,.5)),o=Pt.getUpdateProgressFuncAsync(n);for(let l=a-1;l>=0;--l){let e,o=a-l-1;if(n&&(o%s==0||0===o||o===a-1)){let t=90*o/a,i=90*(o+1)/a;e=Pt.getUpdateSubProgressFunc(t,i,n)}let h=r.children[l],u=yield this.createOutlines(h,t,e);i.push(...u)}if(!r.geometry)return yield o(100),i;if(r instanceof St&&!this.hasOutline(r,!1)){yield o(50);let e=this.createOutline(r.geometry);r.add(e),e.updateWorldMatrix(!0,!1),i.push(e)}return yield o(100),i}))}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,t=!0){let n=!1;for(let i=0;i<e.children.length;++i){let r=e.children[i];if(r.userData.isOutline){n=!0;break}if(t&&r.children.length>0&&(n=this.hasOutline(r),n))break}return n}static setOutlinesVisibility(e,t){e.traverse((e=>{e.userData.isOutline&&(e.visible=t)}))}static createOutline(e,t=this.OUTLINE_MATERIAL,n){let i=new Au(e,10),r=new zr(i,t);return r.layers.enableAll(),Pc.disableLayerChannels(r,[12,11]),r.userData.isOutline=!0,r.matrixAutoUpdate=!1,n&&r.applyMatrix4(n),r}static cloneObject(e,t=!0){let n=e.clone();return t&&n.traverse((e=>{(e instanceof St||e instanceof Vr)&&(e.material=Si.cloneMaterial(e.material))})),n}static createBox(e,t,n,i=Pc.BOX_FACE_MATERIAL,r=!0){let a=[],s=(e,t,n)=>{a.push(new k(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 Ot;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 St(o,i)}static rebaseObjectOnRTC(e){let t=e;if(!((t.isMesh||t.isLine||t.isPoints)&&t.geometry&&t.geometry instanceof Ot))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=lut;let t=e;t.material&&(Array.isArray(t.material)?t.material.forEach((e=>{e.uuid&&(e.uuid="")})):t.material.uuid&&(t.material.uuid=""))}static isLeafObject(e){return(e instanceof St||e instanceof Vr||e instanceof Di)&&!!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++)Pc.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++)Pc.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++)Pc.setLayerChannels(n[e],t,!0)}}static isObjectHittable(e){return e.layers.isEnabled(10)}static isObjectSnapable(e){return e.layers.isEnabled(11)}static isObjectSelectable(e){return e.layers.isEnabled(12)}},rr=Pc;rr.OUTLINE_MATERIAL=new zn({name:"outline",color:0,transparent:!0,opacity:.2}),rr.BOX_FACE_MATERIAL=new ta({color:11648971,transparent:!0,opacity:.3,side:hi});var MR=new ht,cut=new ht,AR=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.isInstancedMesh||!n.geometry||!(n.geometry instanceof Ot))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]],u=[],c=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),en.tryConvertInterleavedBufferAttributes(o),o.userData.isLineSegments=!0===s.isLineSegments,u.push(o),t){let e=s.name,t=null==(r=null==(i=o.attributes)?void 0:i.position)?void 0:r.count,n=(null==(a=o.index)?void 0:a.count)||0,l={batchId:c,name:e,positionStart:d,positionCount:t,indexStart:p,indexCount:n};0!==Object.keys(s.userData).length&&(l.userData=s.userData),f.push(l),d+=t,p+=n,c++}})),0!==u.length){if(h.isMesh){let e=Oi(u);if(!e)return;e.userData={},i=new St(e,h.material),a.push(i)}else if(h.isLine){let e=this.mergeLineGeometries(u,t,h.material instanceof Cu||h.material instanceof hn,f);if(!e)return;i=new zr(e,h.material),s.push(i)}else if(h.isPoints){let e=Oi(u);if(!e)return;e.userData={},i=new Di(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)),u.forEach((e=>{e.dispose(),en.releaseGeometryManually(e)})),u=[]}})),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)&&Si.materialsEquals(l.material,h.material)&&(i[n]||(i[n]={indexes:[n]},this.removeFromArray(r,n)),i[n].indexes.push(t),a=!0),a}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 t=e[m];if(t.isInstancedMesh||!t.geometry||!(t.geometry instanceof Ot))continue;let n=!1,i=Object.values(o);for(let r=i.length-1;r>=0;--r){let t=i[r].indexes[0];if(n=this.tryHandleMergeableObjects(e,m,t,o,l),n)break}for(let r=l.length-1;!n&&r>=0;--r){let t=l[r];if(n=this.tryHandleMergeableObjects(e,m,t,o,l),n)break}n||l.push(m)}if(Object.keys(o).length<=0)return a;fe.debug(`[Merge] Built merged indexes for ${e.length} objects in ${(Date.now()-s)/1e3}s`),s=Date.now();let h=[],u=[],c=[],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 u=e[n],c=u.geometry.clone();if(s.material instanceof zn&&c.deleteAttribute("lineDistance"),this.applyMatrix(c,u,t),c.userData.isLineSegments=!0===u.isLineSegments,o.push(c),r){let e,t=u.name,n=null==(a=null==(i=c.attributes)?void 0:i.position)?void 0:a.count,r=(null==(h=c.index)?void 0:h.count)||0;s.isLine&&(c.boundingSphere||c.computeBoundingSphere(),e=c.boundingSphere.clone());let o={batchId:l,name:t,positionStart:p,positionCount:n,indexStart:f,indexCount:r,boundingSphere:e};!u.parent.geometry&&0!==Object.keys(u.parent.userData).length&&(o.parentUserData=u.parent.userData),0!==Object.keys(u.userData).length&&(o.userData=u.userData),m.push(o),p+=n,f+=r,l++}})),0!==o.length){if(s.isMesh){let e=Oi(o);if(!e)return;e.userData={},a=new St(e,s.material),h.push(a)}else if(s.isLine){let e=this.mergeLineGeometries(o,r,s.material instanceof Cu||s.material instanceof hn,m);if(!e)return;a=new zr(e,s.material),u.push(a)}else if(s.isPoints){let e=Oi(o);if(!e)return;e.userData={},a=new Di(e,s.material),c.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=>{e.dispose(),en.releaseGeometryManually(e)})),o=[]}})),fe.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,...u,...c].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+=u.length,this.mergeInfo.mergedPoints+=c.length,i&&t&&rr.removeEmptyObjects(t),a}static applyMatrix(e,t,n){let i=t;for(MR.identity();i&&i!==n&&(MR.premultiply(i.matrix),i.parent);)i=i.parent;return MR.equals(cut)?e:e.applyMatrix4(MR)}static mergeLineGeometries(e,t,n,i){let r;if(n)r=AR.mergeBufferGeometriesWithLinesToLineSegments(e,t,i);else{if(r=Oi(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 Ot,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&&(fe.debug(`[Merge] Geometry '${l}' contains index buffer, going to convert it to non-indexed.`),a=en.convertGeometryWithIndexedToNonIndexed(a));let u=0;for(let e in a.attributes){if(!i.has(e))return void fe.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]),u++}if(u!==i.size)return void fe.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=AR.mergeBufferAttributesWithLinesToLineSegments(r[l],s);if(!e)return void fe.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 fe.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 fe.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 fe.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,u=r.itemSize,c=new n(h*u),d=0;for(let e=0;e<r.count;e++){let t=e*u,n=0!==e&&e!==r.count-1&&!i;for(let e=0;e<u;e++)c[d+e]=r.array[t+e],n&&(c[d+u+e]=r.array[t+e]);d+=n?2*u:u}s.set(c,o),o+=h*u}return new yn(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 fe.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 getBatchByLineIndex(e,t){if(t<0)return void fe.error(`[Merge]: Invalid index: ${t}`);let n=e&&e.geometry&&e.userData.batches;if(!n)return;let i=e.geometry.index;for(let r=0;r<n.length;++r){let e=n[r];if(i){if(t>=e.indexStart&&t<e.indexStart+e.indexCount)return e}else if(t>=e.positionStart&&t<e.positionStart+e.positionCount)return e}}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 fe.warn(`[Merge]: Unexpected position: ${a}, or index: ${s}!`);let o=new Ot,l=t.positionStart,h=t.positionStart+t.positionCount,u=i.attributes;for(let m in u){let e=u[m],t=e.itemSize,n=e.array.slice(l*t,h*t);o.setAttribute(m,new yn(n,t,e.normalized))}if(i.boundsTree&&(s=i.userData.originalIndex,!s))return void fe.warn("[Merge] After building bvh, the original index data is not preserved !");let c=t.indexStart,d=t.indexStart+t.indexCount,p=[],f=0;for(let m=c;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}},Mi=AR;Mi.mergeInfo={removedObjects:0,mergedMeshes:0,mergedLines:0,mergedPoints:0,mergedUnknownTypeObjects:0,elapsedTime:0};var Gfe=ss(Nfe(),1),Ufe={triangulate:function(e,t,n=2){let i,r,a,s,o,l,h,u=t&&t.length,c=u?t[0]*n:e.length,d=Hfe(e,0,c,n,!0),p=[];if(!d||d.next===d.prev)return p;if(u&&(d=qut(e,t,d,n)),e.length>80*n){i=a=e[0],r=s=e[1];for(let t=n;t<c;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 Nb(d,p,n,i,r,h,0),p}};function Hfe(e,t,n,i,r){let a,s;if(r===tht(e,t,n,i)>0)for(a=t;a<n;a+=i)s=Bfe(a,e[a],e[a+1],s);else for(a=n-i;a>=t;a-=i)s=Bfe(a,e[a],e[a+1],s);return s&&FR(s,s.next)&&(Ub(s),s=s.next),s}function Am(e,t){if(!e)return e;t||(t=e);let n,i=e;do{if(n=!1,i.steiner||!FR(i,i.next)&&0!==ts(i.prev,i,i.next))i=i.next;else{if(Ub(i),i=t=i.prev,i===i.next)break;n=!0}}while(n||i!==t);return t}function Nb(e,t,n,i,r,a,s){if(!e)return;!s&&a&&$ut(e,i,r,a);let o,l,h=e;for(;e.prev!==e.next;)if(o=e.prev,l=e.next,a?Vut(e,i,r,a):Hut(e))t.push(o.i/n|0),t.push(e.i/n|0),t.push(l.i/n|0),Ub(e),e=l.next,h=l.next;else if((e=l)===h){s?1===s?Nb(e=zut(Am(e),t,n),t,n,i,r,a,2):2===s&&Gut(e,t,n,i,r,a):Nb(Am(e),t,n,i,r,a,1);break}}function Hut(e){let t=e.prev,n=e,i=e.next;if(ts(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,u=r<a?r<s?r:s:a<s?a:s,c=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>=u&&f.x<=d&&f.y>=c&&f.y<=p&&Fv(r,o,a,l,s,h,f.x,f.y)&&ts(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function Vut(e,t,n,i){let r=e.prev,a=e,s=e.next;if(ts(r,a,s)>=0)return!1;let o=r.x,l=a.x,h=s.x,u=r.y,c=a.y,d=s.y,p=o<l?o<h?o:h:l<h?l:h,f=u<c?u<d?u:d:c<d?c:d,m=o>l?o>h?o:h:l>h?l:h,g=u>c?u>d?u:d:c>d?c:d,v=GH(p,f,t,n,i),y=GH(m,g,t,n,i),x=e.prevZ,b=e.nextZ;for(;x&&x.z>=v&&b&&b.z<=y;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==r&&x!==s&&Fv(o,u,l,c,h,d,x.x,x.y)&&ts(x.prev,x,x.next)>=0||(x=x.prevZ,b.x>=p&&b.x<=m&&b.y>=f&&b.y<=g&&b!==r&&b!==s&&Fv(o,u,l,c,h,d,b.x,b.y)&&ts(b.prev,b,b.next)>=0))return!1;b=b.nextZ}for(;x&&x.z>=v;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==r&&x!==s&&Fv(o,u,l,c,h,d,x.x,x.y)&&ts(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;b&&b.z<=y;){if(b.x>=p&&b.x<=m&&b.y>=f&&b.y<=g&&b!==r&&b!==s&&Fv(o,u,l,c,h,d,b.x,b.y)&&ts(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function zut(e,t,n){let i=e;do{let r=i.prev,a=i.next.next;!FR(r,a)&&Vfe(r,i,i.next,a)&&Bb(r,a)&&Bb(a,r)&&(t.push(r.i/n|0),t.push(i.i/n|0),t.push(a.i/n|0),Ub(i),Ub(i.next),i=e=a),i=i.next}while(i!==e);return Am(i)}function Gut(e,t,n,i,r,a){let s=e;do{let e=s.next.next;for(;e!==s.prev;){if(s.i!==e.i&&Jut(s,e)){let o=zfe(s,e);return s=Am(s,s.next),o=Am(o,o.next),Nb(s,t,n,i,r,a,0),void Nb(o,t,n,i,r,a,0)}e=e.next}s=s.next}while(s!==e)}function qut(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=Hfe(e,s,o,i,!1),l===l.next&&(l.steiner=!0),h.push(Kut(l));for(h.sort(Wut),r=0;r<h.length;r++)n=jut(h[r],n);return n}function Wut(e,t){return e.x-t.x}function jut(e,t){let n=Xut(e,t);if(!n)return t;let i=zfe(n,e);return Am(i,i.next),Am(n,n.next)}function Xut(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,u=n.y,c=1/0;i=n;do{a>=i.x&&i.x>=h&&a!==i.x&&Fv(s<u?a:r,s,h,u,s<u?r:a,s,i.x,i.y)&&(o=Math.abs(s-i.y)/(a-i.x),Bb(i,e)&&(o<c||o===c&&(i.x>n.x||i.x===n.x&&Yut(n,i)))&&(n=i,c=o)),i=i.next}while(i!==l);return n}function Yut(e,t){return ts(e.prev,e,t.prev)<0&&ts(t.next,e,e.next)<0}function $ut(e,t,n,i){let r=e;do{0===r.z&&(r.z=GH(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,Zut(r)}function Zut(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 GH(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 Kut(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 Fv(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 Jut(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!Qut(e,t)&&(Bb(e,t)&&Bb(t,e)&&eht(e,t)&&(ts(e.prev,e,t.prev)||ts(e,t.prev,t))||FR(e,t)&&ts(e.prev,e,e.next)>0&&ts(t.prev,t,t.next)>0)}function ts(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function FR(e,t){return e.x===t.x&&e.y===t.y}function Vfe(e,t,n,i){let r=kR(ts(e,t,n)),a=kR(ts(e,t,i)),s=kR(ts(n,i,e)),o=kR(ts(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 kR(e){return e>0?1:e<0?-1:0}function Qut(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&&Vfe(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}function Bb(e,t){return ts(e.prev,e,e.next)<0?ts(e,t,e.next)>=0&&ts(e,e.prev,t)>=0:ts(e,t,e.prev)<0||ts(e,e.next,t)<0}function eht(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 zfe(e,t){let n=new qH(e.i,e.x,e.y),i=new qH(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 Bfe(e,t,n,i){let r=new qH(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 Ub(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 qH(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 tht(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 nht=.01,Rm=class{static getFaces(e){let t=e.map((e=>e.toArray())).reduce(((e,t)=>(e.push(...t),e)),[]),n=[];return Ufe.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()>nht)return!1;return!0}static isSelfIntersecting(e){let t=e.map((e=>e.toArray().slice(0,-1)));return(0,Gfe.default)(t).length>0}},Ol=class{static getVisibleObjectBoundingBox(e){let t=new Nt;return e.traverse((e=>{e.visible&&(e instanceof St||e instanceof Vr)&&rr.isObjectSelectable(e)&&t.expandByObject(e)})),t}static getObjectsBoundingBox(e,t,n){let i=new Nt;return t.forEach((t=>{let r=e.getObjectById(t);if(r){let e=Ol.getBoundingBox(r,n);e.isEmpty()||i.union(e)}})),i}static getBoundingBox(e,t=!0){let n=new Nt;if(e instanceof Os)return Ol.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 Os){let e=Ol.getInstancedMeshBoundingBox(i);e.isEmpty()||n.union(e)}else if(Pt.isMatrixValid(i.matrixWorld)){let e=Ol.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 Nt,n=new ht;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()&&Pt.isBoxValid(e)&&t.union(e)}}return t.applyMatrix4(e.matrixWorld),t}static getObjectCenter(e,t){let n=Ol.getBoundingBox(e);n.getCenter(t),t.y=n.min.y}},ku=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=[]})):t&&(t.clippingPlanes=[])}))}static addSection(e,t,n=!1,i=!1){e&&e.traverse((e=>{let r=e.material;Array.isArray(r)?r.forEach((e=>{ku.setMaterialSection(e,t,n,i)})):r&&ku.setMaterialSection(r,t,n,i)}))}static generateSectionPlanesByBox(e){let t=e.min,n=e.max;return[new Ur(new k(0,-1,0),n.y),new Ur(new k(0,1,0),-t.y),new Ur(new k(1,0,0),-t.x),new Ur(new k(-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 Ur;o.setFromCoplanarPoints(new k(a.x,a.y,-1),new k(a.x,a.y,0),new k(s.x,s.y,0)),t||o.negate(),i.push(o)}return i}},WH=new k,qfe=new k,NR=class{modify(e,t){let n=(e=e.clone()).attributes;for(let c in n)"position"!==c&&e.deleteAttribute(c);let i=[],r=[],a=(e=vfe(e)).getAttribute("position");for(let c=0;c<a.count;c++){let e=(new k).fromBufferAttribute(a,c),t=new jH(e);i.push(t)}let s=e.getIndex();if(null!==s)for(let c=0;c<s.count;c+=3){let e=s.getX(c),t=s.getX(c+1),n=s.getX(c+2),a=new BR(i[e],i[t],i[n],e,t,n);r.push(a)}else for(let c=0;c<a.count;c+=3){let e=c,t=c+1,n=c+2,a=new BR(i[e],i[t],i[n],e,t,n);r.push(a)}for(let c=0,d=i.length;c<d;c++)jfe(i[c]);let o,l=t;for(;l--;){if(o=oht(i),!o){console.log("THREE.SimplifyModifier: No next vertex");break}aht(i,r,o,o.collapseNeighbor)}let h=new Ot,u=[];s=[];for(let c=0;c<i.length;c++){let e=i[c].position;u.push(e.x,e.y,e.z),i[c].id=c}for(let c=0;c<r.length;c++){let e=r[c];s.push(e.v1.id,e.v2.id,e.v3.id)}return h.setAttribute("position",new Bt(u,3)),h.setIndex(s),h}};function rht(e,t){-1===e.indexOf(t)&&e.push(t)}function Cm(e,t){let n=e.indexOf(t);n>-1&&e.splice(n,1)}function iht(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 jfe(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=iht(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 Wfe(e,t){for(console.assert(0===e.faces.length);e.neighbors.length;)Cm(e.neighbors.pop().neighbors,e);Cm(t,e)}function sht(e,t){Cm(t,e),e.v1&&Cm(e.v1.faces,e),e.v2&&Cm(e.v2.faces,e),e.v3&&Cm(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 aht(e,t,n,i){if(!i)return void Wfe(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)&&sht(n.faces[a],t);for(let a=n.faces.length-1;a>=0;a--)n.faces[a].replaceVertex(n,i);Wfe(n,e);for(let a=0;a<r.length;a++)jfe(r[a])}function oht(e){let t=e[0];for(let n=0;n<e.length;n++)e[n].collapseCost<t.collapseCost&&(t=e[n]);return t}var BR=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 k,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;WH.subVectors(n,t),qfe.subVectors(e,t),WH.cross(qfe).normalize(),this.normal.copy(WH)}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),Cm(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()}},jH=class{constructor(e){this.position=e,this.id=-1,this.faces=[],this.neighbors=[],this.collapseCost=0,this.collapseNeighbor=null}addUniqueNeighbor(e){rht(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)}}},Xfe=class{static simplifyGeometry(e,t){let n=this.getNumberOfVerticesToRemove(e,t);return n>0?(new NR).modify(e,n):e}static getNumberOfVerticesToRemove(e,t){let n=0;e instanceof Ot&&e.index&&(n=e.attributes.position.count);let i=Math.floor(n*t);return n<20?0:i}},UR=class extends an{constructor(e){super(),this.isSVGObject=!0,this.node=e}},ROt=10,$fe=(e=>(e.TripleCross="TripleCross",e.Square="Square",e.Triangle="Triangle",e.CircleWithCross="CircleWithCross",e.Cross="Cross",e.Perpendicular="Perpendicular",e))($fe||{}),Yfe=class{static createSVGObject(e){return new UR(e)}},HR=class extends gm{constructor(e){super(e),this.type=Tr}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]=yv.toHalfFloat(Math.min(e[t+0]*a,65504)),n[i+1]=yv.toHalfFloat(Math.min(e[t+1]*a,65504)),n[i+2]=yv.toHalfFloat(Math.min(e[t+2]*a,65504)),n[i+3]=yv.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),u=new Uint8Array(l),c=i;for(;c>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++)u[i++]=t}else u.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]=u[e+t],t+=r,a[s+1]=u[e+t],t+=r,a[s+2]=u[e+t],t+=r,a[s+3]=u[e+t],s+=4}c--}return a}(a.subarray(a.pos),e,n);if(-1!==o){let t,a,l;switch(this.type){case pa: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=pa;break;case Tr: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=Tr;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 pa:case Tr:e.colorSpace=Ua,e.minFilter=Xr,e.magFilter=Xr,e.generateMipmaps=!1,e.flipY=!0}t&&t(e,n)}),n,i)}},xf=class{static createEnvTexture(e,t){return it(this,null,(function*(){let n=new HR;return new Promise((i=>{n.load(t,(t=>{if(e){let n=e.fromEquirectangular(t).texture;e.dispose(),i(n)}}))}))}))}static createEnvTextureFromDataArray(e){return it(this,arguments,(function*(e,t=this.HDR_CITY_STREET_64x32,n=64,i=32){if(e){let r=new _l(t,n,i);r.flipY=!0,r.magFilter=Xr,r.minFilter=Xr,r.type=Tr,r.version=1;let a=e.fromEquirectangular(r).texture;return e.dispose(),Promise.resolve(a)}return Promise.reject("Invalid pmremGenerator!")}))}};function lht(){if(dr.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}xf.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 Zfe={file:1,m:1,mm:.001,cm:.01,ft:.3048,in:.0254,pt:lht()},cht={file:"m",m:"m",mm:"mm",cm:"cm",ft:"ft",in:"in",pt:"pt"},Kfe=e=>2===e?"\xb2":3===e?"\xb3":"",Hb=(e,t=1)=>cht[e]+Kfe(t),FOt=(e,t,n,i=1)=>(null==n&&(n=t),n===t?{value:e,unit:Hb(n)}:{value:e*Math.pow(Zfe[t]/Zfe[n],i),unit:Hb(n)+Kfe(i)}),XH=(e=>(e.Top="Top",e.Bottom="Bottom",e.Front="Front",e.Back="Back",e.Left="Left",e.Right="Right",e))(XH||{}),VR=class{static getCameraPositionByBBoxAndDirection(e,t,n,i,r){if(e.isEmpty()||!i)return;let a=new k,s=new k,o=new k(0,1,0);e.getSize(s),e.getCenter(a);let l,h,u=(s.x+s.y+s.z)/3*1.5;if(!r||null!=r&&r.equals(new k))l=new k(a.x+u,a.y+u/1.5,a.z+u),h=l.clone().sub(a);else{let e=new k(u,u/1.5,u).length();h=new k(-r.x,-r.y,-r.z).normalize().multiplyScalar(e),l=h.clone().add(a)}u=h.length(),h=h.normalize();let c=new ht;c.lookAt(l,a,o);let d=new ht;d.makeTranslation(-l.x,-l.y,-l.z);let p=e.clone().applyMatrix4(d).applyMatrix4(c.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));u*=1.1*Math.sqrt(Math.pow(f,2)+Math.pow(m,2)),l=h.multiplyScalar(u).add(a),n.set(a.x,a.y,a.z),t.set(l.x,l.y,l.z)}static getCameraDirectionByView(e){let t=new k(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}},uht=!1,Wi=class extends Ms{constructor(e){super(),this.DEFAULT_LINE_WIDTH=1,this.DEFAULT_STROKE_STYLE=[0,0,0,1],this.DEFAULT_FILL_STYLE=[0,0,0,1],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.editPointFillColor="#ffffff",this.editPointStrokeColor="#939ea4",this.matrix=new ht,this.id=e||Pt.guid()}setTolerance(e){this.tolerance=e}render(e,t){this.ctx=e,this.draw(e,t),this.selected&&this.drawSelect(e,t),uht&&(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 k(this.x,this.y,0),new k(this.x+this.width,this.y,0),new k(this.x+this.width,this.y-this.height,0),new k(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 k)}transToScreenCoord(e,t){return this.ctx?Sn.world2Screen(e,t,this.ctx.canvas):new _e}drawBounds(e,t){let{min:n,max:i}=this.getBounds(),r=[],a=(e,t,n)=>r.push(new k(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 Nt).setFromPoints(e)}},gi=(e=>(e.MouseClicked="MouseClicked",e.LayoutChanged="LayoutChanged",e.ModelLoaded="ModelLoaded",e.BeforeRender="BeforeRender",e.AfterRender="AfterRender",e.OnAnimate="OnAnimate",e.CameraChanged="CameraChanged",e.ControlChanged="ControlChanged",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.HotpointClicked="HotpointClicked",e))(gi||{}),Jfe={},Gn=class extends Ms{constructor(e){super(),this.drawableLists=[],this.frustum=new wl,this.projScreenMatrix=new ht,this.viewer=e,this.init()}static _registerDrawableClass(e){Jfe[e.prototype.getClassType()]=e}static createDrawable(e){let t=Jfe[e.type];if(!t)throw new Error(`Invalid drawable type: ${t}`);let n=e.points.map((e=>new k(e[0],e[1],e[2]||0))),i=new t(e.id,n);return i.setData(e),i}get is3d(){return this.viewer.is3d()}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(dr.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=dr.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(!1);if(0===e.length)return;let t=new $r,n=this.viewer.getPixelSizeInWorldCoord();for(let i=0;i<e.length;i++){let r=e[i];r.setTolerance(n),r.visible&&(r.getBounds().getBoundingSphere(t),!r.needsFrustumCulled||this.frustum.intersectsSphere(t))&&r.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(e=!1){let t=[];return this.drawableLists.forEach((n=>{let i=Array.from(n.getDrawables().values());e&&(i=i.filter((e=>e.visible))),i.length>0&&t.push(...i)})),t.sort(((e,t)=>e.renderOrder===t.renderOrder?t.getCenter().distanceTo(this.camera.position)-e.getCenter().distanceTo(this.camera.position):e.renderOrder-t.renderOrder)),t}getDrawablesByDrawableListAndPosition(e,t){return this.is3d||(t.z=0),e.getDrawableByPosition(t,this.raycaster)}getDrawablesByPosition(e){this.is3d||(e.z=0);let t=this.getSortedDrawables(),n=[];for(let i=0;i<t.length;i++){let r=t[i];r.isPointInPath(e,this.raycaster)&&n.push(r)}return n}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 it(this,arguments,(function*(e={type:"image/png",quality:.8}){var t,n,i;if(!this.canvas)return;let r=yield Pt.canvasToImage(this.canvas),a=yield Pt.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 Pt.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)}},Xo=class extends Ms{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=Gn.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}},hht=new Nt,ki=class extends Wi{constructor(e){super(e),this.editPointSize=3,this.editPointFillColor="#ffffff",this.editPointStrokeColor="#939ea4",this.id=e||Pt.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.editPointFillColor,e.strokeStyle=this.editPointStrokeColor,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.stroke(),e.fill(),e.restore()}setEditPointSize(e){this.editPointSize=e}setEditPointFillColor(e){this.editPointFillColor=e}setEditPointStrokeColor(e){this.editPointStrokeColor=e}getCenter(){return this.getBounds().getCenter(new k)}isPointInPath(e){let t=this.getVertexes().map((e=>new _e(e.x,e.y)));return en.isPointInPolygon(new _e(e.x,e.y),t,!0)}setData(e){super.setData(e),this.update(e.points.map((e=>new k(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}=hht.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 k(e,t,0);return this.points.forEach((e=>e.add(n))),this.update(this.points),this}rotate(){return this}scale(){return this}},Wa=(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))(Wa||{}),YH=class extends ki{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 k).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=An.rgba2Color(this.lineColor);let[i,r]=t,a=(new _e).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),u=r*Math.cos(o),c=r*Math.sin(o),d=new _e(n.x+l,n.y+h),p=new _e(n.x+u,n.y+c);e.save(),e.fillStyle=An.rgba2Color(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 en.isPointOnLineSegments(e,this.points,this.tolerance)}getClassType(){return"ArrowMarkup"}};Gn._registerDrawableClass(YH);var dht=new _e,Qfe=new k,$H=class extends ki{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=dht.subVectors(i,n).length(),e.save(),e.lineWidth=this.lineWidth,e.strokeStyle=An.rgba2Color(this.lineColor),e.fillStyle=An.rgba2Color(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=Qfe.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=Qfe.subVectors(t,n).length();return Math.abs(e.distanceTo(t)-i)<=2*this.tolerance}getClassType(){return"CircleMarkup"}};Gn._registerDrawableClass($H);var epe=new Nt,Ic=class extends ki{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=An.rgba2Color(this.lineColor),e.fillStyle=An.rgba2Color(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=Ic.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],Sn.screen2World(o,t,this.ctx.canvas))}e.stroke(),e.restore(),epe.setFromPoints(i);let{min:r,max:a}=epe;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 _e).subVectors(t,e),i=n.angle(),r=n.length(),a=Un.degToRad(45),s=r/2/Math.cos(a);return new _e(e.x+s*Math.cos(a-i),e.y-s*Math.sin(a-i))}getClassType(){return"CloudLineMarkup"}};Gn._registerDrawableClass(Ic);var ZH=class extends ki{constructor(e,t){super(e),this.type="CloudRectMarkup",this.update(t)}draw(e,t){e.save(),e.lineWidth=this.lineWidth,e.strokeStyle=An.rgba2Color(this.lineColor),e.fillStyle=An.rgba2Color(this.fillColor),e.beginPath();let n=this.getVertexes();n.push(n[0]);let i,r=[],a=new k;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=Ic.getControlPointByTwoPoints(a,o);this.vertexes.push(n,i,Sn.screen2World(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 en.isPointOnLineSegments(e,n,3*this.tolerance)}getClassType(){return"CloudRectMarkup"}};Gn._registerDrawableClass(ZH);var KH=class extends ki{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=An.rgba2Color(this.lineColor),e.fillStyle=An.rgba2Color(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"}};Gn._registerDrawableClass(KH);var JH=class extends ki{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 _e).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=An.rgba2Color(this.lineColor),e.fillStyle=An.rgba2Color(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 k).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),u=a/(l*l),c=Math.abs(n.x-t.x)/2+s,d=Math.abs(n.y-t.y)/2+s;return h+u>=1&&r/(c*c)+a/(d*d)<=1}getClassType(){return"EllipseMarkup"}};Gn._registerDrawableClass(JH);var Vb=class extends ki{constructor(e,t,n){super(e),this.text="",this.fontSize=12,this.type="TextMarkup",this.padding=300,this.inputStatus="CHAR_TYPING",this.isEditing=!1,this.handleClick=()=>{},this.handleKeydown=e=>{if(this.textInput)if("Enter"===e.key){let e=parseInt(this.textInput.style.height);this.textInput.style.height=`${Math.round(e+this.fontSize/this.tolerance)}px`}else"Escape"===e.code&&this.exitEditing()},this.handleInput=()=>{var e;if(!this.textInput||!this.manager||"CHINESE_TYPING"===this.inputStatus)return;let t=this.textInput.value,n=(null==(e=this.manager.overlayRender)?void 0:e.measureTextLength(t,this.fontSize/this.tolerance+"px Arial"))||0;n>Vb.DEFAULT_INPUT_WIDTH&&(this.textInput.style.width=`${Math.round(n+this.padding/this.tolerance*2)}px`),this.inputStatus="CHAR_TYPING",this.text=t},this.handleCompositionStart=()=>{this.inputStatus="CHINESE_TYPING"},this.handleCompositionEnd=()=>{var e;if(!this.textInput||!this.manager||"CHINESE_TYPING"!==this.inputStatus)return;let t=this.textInput.value,n=(null==(e=this.manager.overlayRender)?void 0:e.measureTextLength(t,this.fontSize/this.tolerance+"px Arial"))||0;n>Vb.DEFAULT_INPUT_WIDTH&&(this.textInput.style.width=`${Math.round(n+this.padding/this.tolerance*2)}px`),this.text=t,this.inputStatus="CHAR_TYPING"},this.handleBlur=()=>{this.exitEditing()},this.handleFoucs=()=>{},this.update(t),this.text=n}draw(e,t){this.isEditing||this.drawText(e,t,this.text)}drawText(e,t,n){let i=this.transToScreenCoord(new k(this.x,this.y,0),t),r=n.split("\n"),a=this.fontSize/this.tolerance,s=0;e.save(),e.lineWidth=this.lineWidth,e.strokeStyle=An.rgba2Color(this.lineColor),e.fillStyle=An.rgba2Color(this.lineColor),e.textAlign="left",e.textBaseline="top",e.font=`${a}px Arial`;for(let h=0;h<r.length;h++){let t=r[h],n=e.measureText(t).width;n>s&&(s=n)}let o=this.padding/this.tolerance,l=new _e(i.x,i.y);for(let h=0;h<r.length;h++){let t=r[h];e.fillText(t,l.x+o,l.y+o+h*a,s+2*o)}e.strokeRect(l.x,l.y,s+2*o,r.length*a+2*o),e.restore(),this.width=(s+2*o)*this.tolerance,this.height=(r.length*a+2*o)*this.tolerance}setFontSize(e){this.fontSize=e,this.padding=e/2}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),this.padding=e.fontSize/2}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"}addInput(e,t,n){var i;this.textInput||(this.textInput=document.createElement("textarea"),this.textInput.style.cssText=`\n position: absolute;\n border: ${this.lineWidth}px solid ${An.rgba2Color(this.lineColor)};\n background: transparent;\n outline: none;\n resize: none;\n overflow: hidden;\n z-index: 1000;\n box-sizing: content-box;\n display: inline-block;\n padding: ${this.padding/this.tolerance}px;\n whiteSpace: 'nowrap';\n color: ${this.lineColor}`,this.textInput.style.display="inline-block",null==(i=e.viewerCanvas.parentElement)||i.appendChild(this.textInput),this.addInputEvents()),this.manager=e,this.enterEditing(),this.textInput.style.left=`${t}px`,this.textInput.style.top=`${n}px`,this.textInput.style.width=`${Vb.DEFAULT_INPUT_WIDTH}px`,this.textInput.style.height=this.fontSize/this.tolerance+"px",this.textInput.style.lineHeight=this.fontSize/this.tolerance+"px",this.textInput.style.fontSize=this.fontSize/this.tolerance+"px",this.textInput.style.color=An.rgba2Color(this.lineColor)}addInputEvents(){var e,t,n,i,r,a,s;null==(e=this.textInput)||e.addEventListener("click",this.handleClick),null==(t=this.textInput)||t.addEventListener("blur",this.handleBlur),null==(n=this.textInput)||n.addEventListener("foucs",this.handleFoucs),null==(i=this.textInput)||i.addEventListener("keydown",this.handleKeydown),null==(r=this.textInput)||r.addEventListener("input",this.handleInput),null==(a=this.textInput)||a.addEventListener("compositionstart",this.handleCompositionStart),null==(s=this.textInput)||s.addEventListener("compositionend",this.handleCompositionEnd)}enterEditing(){this.textInput&&(this.textInput.value=this.text,this.textInput.focus(),this.isEditing=!0,this.dispatchEvent("EnterEditing"))}exitEditing(){var e,t,n,i,r,a,s,o;null==(e=this.textInput)||e.removeEventListener("click",this.handleClick),null==(t=this.textInput)||t.removeEventListener("blur",this.handleBlur),null==(n=this.textInput)||n.removeEventListener("foucs",this.handleFoucs),null==(i=this.textInput)||i.removeEventListener("keydown",this.handleKeydown),null==(r=this.textInput)||r.removeEventListener("input",this.handleInput),null==(a=this.textInput)||a.removeEventListener("compositionstart",this.handleCompositionStart),null==(s=this.textInput)||s.removeEventListener("compositionend",this.handleCompositionEnd),null==(o=this.textInput)||o.remove(),this.textInput=void 0,this.isEditing=!1,this.dispatchEvent("ExitEditing")}},kl=Vb;kl.DEFAULT_INPUT_WIDTH=50,Gn._registerDrawableClass(kl);var tpe=new _e,npe=new _e(1,0),rpe=new _e(0,-1),QH=class extends kl{constructor(e,t,n){super(e,t,n),this.type="LeaderLineMarkup",this.text="LeaderLine",this.fontSize=12,this.textBounds=new Nt,this.handleInput=()=>{!this.textInput||!this.manager||"CHINESE_TYPING"===this.inputStatus||(this.text=this.textInput.value,this.calcuTextInputPositionByText(this.text),this.inputStatus="CHAR_TYPING")},this.handleCompositionEnd=()=>{!this.textInput||!this.manager||"CHINESE_TYPING"!==this.inputStatus||(this.text=this.textInput.value,this.calcuTextInputPositionByText(this.text),this.inputStatus="CHAR_TYPING")}}draw(e,t){if(this.points.length<2)return;let n=this.points.map((e=>this.transToScreenCoord(e,t))),[i,r]=this.points,a=(new k).subVectors(i,r).length()/10/this.tolerance;this.drawArrowLine(e,n,a),this.drawArrowHead(e,n[1],n[0],10,a),!this.isEditing&&this.text.length>0&&this.drawText(e,t,this.text)}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),u=r*Math.cos(o),c=r*Math.sin(o),d=new _e(n.x+l,n.y+h),p=new _e(n.x+u,n.y+c);e.save(),e.fillStyle=An.rgba2Color(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=An.rgba2Color(this.lineColor);let[i,r]=t,a=(new _e).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,t))),a=(new _e).subVectors(r,i).normalize(),s=a.cross(rpe)<0,o=a.cross(npe)<0,l=n.split("\n"),h=this.fontSize/this.tolerance,u=0;e.save(),e.lineWidth=this.lineWidth,e.strokeStyle=An.rgba2Color(this.lineColor),e.fillStyle=An.rgba2Color(this.lineColor),e.textAlign="left",e.textBaseline="top",e.font=`${h}px Arial`;for(let v=0;v<l.length;v++){let t=l[v],n=e.measureText(t).width;n>u&&(u=n)}let c=this.padding/this.tolerance,d=c+h/2,p=l.length*h+2*c,f=new _e(s?r.x:r.x-u-2*c,o?r.y-d:r.y-p+(p-d));for(let v=0;v<l.length;v++){let t=l[v];e.fillText(t,f.x+c,f.y+c+v*h,u+2*c)}e.strokeRect(f.x,f.y,u+2*c,l.length*h+2*c),e.restore();let m=Sn.screen2World(tpe.set(f.x,f.y),t,this.ctx.canvas);m.z=0;let g=Sn.screen2World(tpe.set(f.x+u+2*c,f.y+p),t,this.ctx.canvas);g.z=0,this.textBounds.setFromPoints([m,g])}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}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 en.isPointOnLineSegments(e,this.points,this.tolerance)||this.textBounds.containsPoint(e)}updateText(e){this.text=e}getClassType(){return"LeaderLineMarkup"}addInput(e,t,n){let[i,r]=this.points.map((t=>Sn.world2Screen(t,e.camera,e.viewerCanvas))),a=(new _e).subVectors(r,i).normalize(),s=a.cross(rpe)<0,o=a.cross(npe)<0,l=this.fontSize/this.tolerance,h=this.padding/this.tolerance,u=h+l/2,c=kl.DEFAULT_INPUT_WIDTH,d=l;super.addInput(e,s?t:t-c-2*h,o?n-u:n-d+(d-u))}calcuTextInputPositionByText(e){var t;if(!this.textInput||!this.manager)return;let n=(null==(t=this.manager.overlayRender)?void 0:t.measureTextLength(e,this.fontSize/this.tolerance+"px Arial"))||0;if(n>kl.DEFAULT_INPUT_WIDTH){let e=this.points[1],t=Sn.world2Screen(this.points[0],this.manager.camera,this.manager.viewerCanvas),i=Sn.world2Screen(e,this.manager.camera,this.manager.viewerCanvas).clone().sub(t).normalize().cross(new _e(0,-1))<0,r=Sn.world2Screen(e,this.manager.camera,this.manager.viewerCanvas);i||(this.textInput.style.left=r.x-n-this.padding/this.tolerance*2+"px"),this.textInput.style.width=`${Math.round(n)}px`}}};Gn._registerDrawableClass(QH);var e5=class extends ki{constructor(e,t){super(e),this.type="PolylineMarkup",this.update(t)}draw(e,t){e.save(),e.lineWidth=this.lineWidth,e.strokeStyle=An.rgba2Color(this.lineColor),e.fillStyle=An.rgba2Color(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 en.isPointOnLineSegments(e,n,1*this.tolerance)}getVertexes(){return this.points}getClassType(){return"PolylineMarkup"}};Gn._registerDrawableClass(e5);var t5=class extends ki{constructor(e,t){super(e),this.type="RectMarkup",this.update(t)}draw(e,t){e.save(),e.lineWidth=this.lineWidth,e.strokeStyle=An.rgba2Color(this.lineColor),e.fillStyle=An.rgba2Color(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 en.isPointOnLineSegments(e,n,2*this.tolerance)}getClassType(){return"RectMarkup"}};Gn._registerDrawableClass(t5);var n5=class extends ki{constructor(e,t){super(e),this.type="XMarkup",this.update(t)}draw(e,t){e.save(),e.lineWidth=this.lineWidth,e.strokeStyle=An.rgba2Color(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 en.isPointOnLineSegments(e,[t,i,n,r],.1)}getClassType(){return"XMarkup"}};Gn._registerDrawableClass(n5);var ipe=new Nt,r5=new k,i5=new _e,fht=new _e(1,0),pht=new _e(0,-1),s5=class extends kl{constructor(e,t,n=""){super(e,t,n),this.type="CloudRectWithTextMarkup",this.textPosition=new k,this.textBounds=new Nt,this.text="CloudRectWithText",this.fontSize=12,this.handleClick=()=>{var e;null==(e=this.textInput)||e.blur()},this.handleInput=()=>{!this.textInput||!this.manager||"CHINESE_TYPING"===this.inputStatus||(this.text=this.textInput.value,this.calcInputPositionByText(this.text),this.inputStatus="CHAR_TYPING")},this.handleCompositionEnd=()=>{!this.textInput||!this.manager||"CHINESE_TYPING"!==this.inputStatus||(this.text=this.textInput.value,this.calcInputPositionByText(this.text),this.inputStatus="CHAR_TYPING")}}draw(e,t){this.drawCloudRect(e,t),(this.isEditing||this.text.length>0)&&this.drawLeaderLine(e,t),!this.isEditing&&this.text.length>0&&this.drawText(e,t,this.text)}drawCloudRect(e,t){e.save(),e.lineWidth=this.lineWidth,e.strokeStyle=An.rgba2Color(this.lineColor),e.fillStyle=An.rgba2Color(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=r5.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=Ic.getControlPointByTwoPoints(s,o);this.controlPoints.push(s,o),this.vertexes.push(n,i,Sn.screen2World(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=s5.LEADER_LINE_WIDTH,e.strokeStyle=An.rgba2Color(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=i5.subVectors(r,i).normalize(),s=a.cross(fht)<0,o=a.cross(pht)<0,l=n.split("\n"),h=this.fontSize/this.tolerance,u=0;e.save(),e.lineWidth=this.lineWidth,e.strokeStyle=An.rgba2Color(this.lineColor),e.fillStyle=An.rgba2Color(this.lineColor),e.textAlign="left",e.textBaseline="top",e.font=`${h}px Arial`;for(let v=0;v<l.length;v++){let t=l[v],n=e.measureText(t).width;n>u&&(u=n)}let c=this.padding/this.tolerance,d=c+h/2,p=l.length*h+2*c,f=new _e(o?r.x:r.x-u-2*c,s?r.y-d:r.y-p+(p-d));for(let v=0;v<l.length;v++){let t=l[v];e.fillText(t,f.x+c,f.y+c+v*h,u+2*c)}e.strokeRect(f.x,f.y,u+2*c,l.length*h+2*c),e.restore();let m=Sn.screen2World(i5.set(f.x,f.y),t,this.ctx.canvas);m.z=0;let g=Sn.screen2World(i5.set(f.x+u+2*c,f.y+p),t,this.ctx.canvas);g.z=0,this.textBounds.setFromPoints([m,g])}translate(e,t){let n=r5.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||(this.textPosition=new k),this.textPosition.set(Math.max(t.x,n.x),Math.max(t.y,n.y),0),this}getCloudPoints(){return[new k(this.x,this.y,0),new k(this.x+this.width,this.y,0),new k(this.x+this.width,this.y-this.height,0),new k(this.x,this.y-this.height,0)]}getBounds(){return ipe.setFromPoints([...this.points,...this.vertexes||[]]),ipe.union(this.textBounds)}getVertexes(){let e=this.getBounds(),t=e.min,n=e.getSize(r5);return[new k(t.x,t.y,0),new k(t.x+n.x,t.y,0),new k(t.x+n.x,t.y+n.y,0),new k(t.x,t.y+n.y,0)]}isLeaderTextSelected(e){return this.textBounds.containsPoint(e)}translateLeaderText(e,t){let n=new k(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 en.isPointOnLineSegments(e,n,3*this.tolerance)||this.textBounds.containsPoint(e)}setData(e){super.setData(e);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"}addInput(e,t,n){let i=this.padding/this.tolerance+this.fontSize/this.tolerance/2;super.addInput(e,t,n-i)}updateInputPosition(e,t){var n;if(!this.manager||!this.textInput)return;let i=t.clone().sub(e).normalize().cross(new _e(0,-1))<0,r=this.textInput.value,a=(null==(n=this.manager.overlayRender)?void 0:n.measureTextLength(r,this.fontSize/this.tolerance+"px Arial"))||kl.DEFAULT_INPUT_WIDTH,s=this.padding/this.tolerance+this.fontSize/this.tolerance/2;this.textInput.style.left=`${i?t.x:t.x-this.padding/this.tolerance*2-a}px`,this.textInput.style.top=t.y-s+"px",this.textPosition.copy(Sn.screen2World(t,this.manager.camera,this.manager.viewerCanvas))}calcInputPositionByText(e){var t;if(!this.textInput||!this.manager)return;let n=(null==(t=this.manager.overlayRender)?void 0:t.measureTextLength(e,this.fontSize/this.tolerance+"px Arial"))||0;if(n>kl.DEFAULT_INPUT_WIDTH){let e=Sn.world2Screen(this.points[0],this.manager.camera,this.manager.viewerCanvas),t=Sn.world2Screen(this.textPosition,this.manager.camera,this.manager.viewerCanvas).clone().sub(e).normalize().cross(new _e(0,-1))<0,i=Sn.world2Screen(this.textPosition,this.manager.camera,this.manager.viewerCanvas);t||(this.textInput.style.left=i.x-n-this.padding/this.tolerance*2+"px"),this.textInput.style.width=`${Math.round(n)}px`}}},Pm=s5;Pm.LEADER_LINE_WIDTH=1,Gn._registerDrawableClass(Pm);var Fl=class{constructor(e){this.name=e}},zR=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}},zb=class extends Fl{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)}},GR=class extends Fl{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)}},Gb=class extends Fl{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)}},qb=class extends Fl{constructor(e,t){super("AddMeasurement"),this.manager=e,this.data=t}undo(){let e=this.manager.getById(this.data.id);return!!e&&(this.manager.remove(e),!0)}redo(){let e=this.manager.create(this.data);return!!e&&(this.manager.add(e),!0)}},qR=class extends Fl{constructor(e,t){super("RemoveMeasurement"),this.manager=e,this.data=t}undo(){let e=this.manager.create(this.data);return!!e&&(this.manager.add(e),!0)}redo(){let e=this.manager.getById(this.data.id);return!!e&&(this.manager.remove(e),!0)}},spe=new k,Wb=class extends Ms{constructor(e,t){super(),this.drawableList=new Xo("markup"),this.lineWidth=2,this.lineColor=[1,0,0,1],this.fillColor=[1,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.handleDbClick=()=>{},this.handleInputMousemove=e=>{if(!this.mouseDown&&"CloudRectWithTextMarkup"===this.type&&this.isDrawing&&this.creatingShape){let t=Sn.getScreenCoordinateByEvent(e,this.viewerCanvas);this.creatingShape.updateInputPosition(this.mousedownPoint,t),this.render()}},this.mousedown=e=>{var t;if(e.pointers&&e.pointers.length>1)return;let n=this.pickThreejsPositionByMouse(e);if(n){if(n.z=0,this.mouseDownPositionX=n.x,this.mouseDownPositionY=n.y,this.mousedownPoint=new _e(e.x,e.y),0===e.button&&(this.mouseDown=!0),2===e.button)return void(this.isDrawing&&this.endDraw(this.creatingShape));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 Pm&&(this.isSelectLeaderText=e.isLeaderTextSelected(n)),this.render())}if(this.isCreateTextMode()&&this.mouseDown&&!this.selectedShape){this.creatingShape||(this.creatingShape=this.drawText(n,""));let t=this.creatingShape;0===t.text.length?(t.setTolerance(this.viewer.getPixelSizeInWorldCoord()),t.update([n]),t.addInput(this,e.x,e.y)):(t.exitEditing(),this.addMarkup(t,!1),this.endDraw(t)),this.render()}if(this.isCreateLineMode()&&this.mouseDown&&!this.selectedShape){if(this.tempPoints.length>0){let e=this.tempPoints[0];if(spe.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())}},this.mousemove=e=>{if(e.pointers&&e.pointers.length>1)return;let t=this.pickThreejsPositionByMouse(e);if(t)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 Pm&&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 k(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];spe.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&&this.creatingShape)if("LeaderLineMarkup"===this.type){let t=this.creatingShape;t.isEditing?t.exitEditing():(t.setFontSize(this.fontSize*this.viewer.getPixelSizeInWorldCoord()),t.addInput(this,e.x,e.y)),t.addEventListener("ExitEditing",(()=>{this.isDrawing=!1,this.endDraw(this.creatingShape)}))}else if("CloudRectWithTextMarkup"===this.type){let t=this.creatingShape;t.setFontSize(this.fontSize*this.viewer.getPixelSizeInWorldCoord()),t.addInput(this,e.x,e.y),t.addEventListener("ExitEditing",(()=>{this.isDrawing=!1,this.endDraw(this.creatingShape)}))}else this.endDraw(this.creatingShape)},this.keydown=e=>{"Delete"===e.code?this.selectedShape&&(this.viewer.hasEventListener("BeforeRemoveMarkup")?this.viewer.dispatchEvent("BeforeRemoveMarkup",this.confirmToRemove.bind(this)):(this.removeMarkup(this.selectedShape),this.viewer.getUndoRedoManager().addCommand(new Gb(this,this.selectedShape.getData())),this.selectedShape=void 0)):"Escape"===e.code&&this.cancelDraw(this.creatingShape)},this.viewer=e,this.inputManager=t,this.overlayRender=this.viewer.getOverlayRender(),this.overlayRender.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.isDrawing&&this.reset(),this.render()}isMarkupActive(){return this.activated}activate(){this.activated=!0,dr.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("dblclick",this.handleDbClick)),this.inputManager.addEventListener("keydown",this.keydown),window.addEventListener("mousemove",this.handleInputMousemove),this.viewer.getCameraManager().enableMouseLeft(!1),this.viewer.getCameraManager().enableKeyControl(!1),this.render()}deactivate(){this.activated=!1,dr.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("dblclick",this.handleDbClick)),this.inputManager.removeEventListener("keydown",this.keydown),window.removeEventListener("mousemove",this.handleInputMousemove),this.viewer.getCameraManager().enableMouseLeft(!0),this.viewer.getCameraManager().enableKeyControl(!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=this.viewer.pickModel({x:e.x,y:e.y});return null==t?void 0:t.point}pickThreejsPositionByMouse(e){return this.pickPositionByScreenPoint(new _e(e.x,e.y))}confirmToRemove(e){this.selectedShape&&e&&(this.removeMarkup(this.selectedShape),this.viewer.getUndoRedoManager().addCommand(new Gb(this,this.selectedShape.getData())),this.selectedShape=void 0)}isEditing(){return!!this.initialDataForEditing}endEdit(e){if(!this.initialDataForEditing)return;let t=e.getData();this.viewer.dispatchEvent("MarkupUpdated",{oldData:this.initialDataForEditing,newData:t}),this.dispatchEvent("EndEdit",e),this.viewer.getUndoRedoManager().addCommand(new GR(this,this.initialDataForEditing,t)),this.initialDataForEditing=void 0,this.isSelectLeaderText=!1}endDraw(e){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 t=e.getData();this.viewer.dispatchEvent("MarkupAdded",t),this.viewer.getUndoRedoManager().addCommand(new zb(this,t))}this.dispatchEvent("EndDraw",e),this.reset()}cancelDraw(e){e&&this.removeMarkup(e,!1),this.reset()}reset(){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 Gn.createDrawable(e)}getMarkupById(e){return this.drawableList.getDrawableById(e)}getMarkupData(){return this.drawableList.getDrawableDatas()}setMarkupData(e){this.viewer.getUndoRedoManager().startTransaction(),e.forEach((e=>{this.addMarkup(this.createMarkup(e)),this.viewer.getUndoRedoManager().addCommand(new zb(this,e))})),this.viewer.getUndoRedoManager().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]),Gn.createDrawable({id:Pt.guid(),lineWidth:this.lineWidth,lineColor:this.lineColor,fillColor:this.fillColor,type:this.type,points:n})}drawLine(e){return Gn.createDrawable({id:Pt.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 Gn.createDrawable({id:Pt.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]]})}destroy(){this.deactivate(),this.clearAll()}},ape=new k,Im=class extends Wi{constructor(e,t){super(e),this.lineSegments=[],this.boxes=t,this.lineColor=[1,0,0,1],this.lineWidth=2,this.calculateCloudLineSegments(t)}calculateCloudLineSegments(e){var t;for(let n=0;n<e.length;n++){let i=e[n],r=[new k(i.min.x,i.min.y),new k(i.max.x,i.min.y),new k(i.max.x,i.max.y),new k(i.min.x,i.max.y),new k(i.min.x,i.min.y)],a=ape.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=ape.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=An.rgba2Color(this.lineColor),e.fillStyle=An.rgba2Color(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=Ic.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 Nt;for(let t=0;t<this.boxes.length;t++){let n=this.boxes[t];e.union(n)}return e}getClassType(){return"CompareDrawable"}};Gn._registerDrawableClass(Im);var Nv="BYLAYER",Bv="BYBLOCK",ope=(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))(ope||{}),Lm=["INSERT","DIMENSION"],A4t=ss(dpe(),1),WR=[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],Uv=class{constructor(){this.pointer=0,this.eof=!1}},l5=ss(fpe(),1),bf=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=l5.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=l5.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}},ppe=1e3,Xb=class extends Uv{constructor(e){super(),this.int8Array=new Int8Array(ppe),this.caches=new Map,this.reader=new bf(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 mpe(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?mpe(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 fe.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>ppe)return fe.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 mpe(e){return Array.prototype.map.call(e,(e=>("00"+e.toString(16)).slice(-2))).join("")}var Hv=class extends Uv{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=ght(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 ght(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?vht(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):(fe.info("WARNING: Group code does not have a defined type: %j",{code:e,value:t}),t)}function vht(e){if("0"===e)return!1;if("1"===e)return!0;throw TypeError("String '"+e+"' cannot be cast to Boolean type")}var ype=ss(Lc(),1),yht="OriginalHandle",xht="OriginalType",bht="Outlines",gpe=["PROXY","REGION","INSERT","HATCH"];function Dm(e){return WR[e]}function Dt(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 vpe(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 On(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&&fe.warn("[DxfParser] a negative value of colorIndex indicates that the layer is turned off"),e.color=Dm(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(yht)){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(bht)&&(e.extendedData||(e.extendedData={}),e.extendedData.outlines=[]),t.value&&t.value.includes(xht)){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 Nl(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 $b=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=Eht(e,t),t=e.lastReadGroup;break;case 101:for(;0!=t.code;)t=e.next();break;default:On(n,t),t=e.next()}return n}};function Eht(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,ype.isEmpty)(a)||n.push(a),i=!1,r=!1}return n}var Zb=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=Dt(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:On(n,t),t=e.next()}return n}},Kb=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=Dt(e),t=e.lastReadGroup;break;case 11:n.endPoint=Dt(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:On(n,t),t=e.next()}return n}},Jb=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=Dt(e),t=e.lastReadGroup;break;case 11:n.endPoint=Dt(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:On(n,t),t=e.next()}return n}},Qb=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=Dt(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:On(n,t),t=e.next()}return n}},eE=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=Dt(e),t=e.lastReadGroup;break;case 11:n.middleOfText=Dt(e),t=e.lastReadGroup;break;case 12:n.insertionPoint=Dt(e),t=e.lastReadGroup;break;case 13:n.linearOrAngularPoint1=Dt(e),t=e.lastReadGroup;break;case 14:n.linearOrAngularPoint2=Dt(e),t=e.lastReadGroup;break;case 15:n.diameterOrRadiusPoint=Dt(e),t=e.lastReadGroup;break;case 16:n.arcPoint=Dt(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:On(n,t),t=e.next()}return n}},tE=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=Dt(e),t=e.lastReadGroup;break;case 11:n.majorAxisEndPoint=Dt(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=Dt(e),t=e.lastReadGroup;break;case 2:n.name=t.value,t=e.next();break;default:On(n,t),t=e.next()}return n}},Om=class{constructor(e){this.type=e,this.startPoint={x:0,y:0,z:0},this.endPoint={x:0,y:0,z:0}}},c5=class extends Om{constructor(){super(0),this.points=[],this.isClosed=!0}},u5=class extends Om{constructor(){super(1)}},h5=class extends Om{constructor(){super(2),this.center={x:0,y:0,z:0},this.radius=0,this.startAngle=0,this.endAngle=0,this.bCounterclockwise=!1}},d5=class extends Om{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}},f5=class extends Om{constructor(){super(4),this.controlPoints=[],this.numControlPoints=0,this.knotValues=[],this.numKnots=0,this.bPeriodic=!1,this.bRational=!1,this.degreeOfSplineCurve=0}},nE=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=Sht(t.value,e),t=e.lastReadGroup;break;case 91:n.boundaryPathsCount=t.value,n.boundaryPaths=wht(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=Mht(n.gradientColorCount,e),t=e.next();break;case 101:for(;0!=t.code;)t=e.next();break;default:On(n,t),t=e.next()}return n}};function _ht(e){let t=new c5,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=Dt(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 Tht(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 u5;e.startPoint=Dt(t),e.endPoint=Dt(t),i=t.lastReadGroup,n.push(e);break}case 2:{i=t.next();let e=new h5;e.center=Dt(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 d5;e.center=Dt(t),e.majorAxisEndPoint=Dt(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 f5;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 wht(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=_ht(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=Tht(r.value,t),e.pathTypeFlag=i,n.push(e),r=t.lastReadGroup;break;default:r=t.next()}}return n}function Sht(e,t){if(e<=0)return void t.next();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 Mht(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 rE=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=Dt(e),t=e.lastReadGroup;break;case 11:n.uPixel=Dt(e),t=e.lastReadGroup;break;case 12:n.vPixel=Dt(e),t=e.lastReadGroup;break;case 13:n.imageSize=Dt(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(Dt(e)),t=e.lastReadGroup;break;case 290:n.clipMode=t.value,t=e.next();default:On(n,t),t=e.next()}return n}},iE=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=Dt(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=Dt(e),t=e.lastReadGroup;break;case 101:for(;0!=t.code;)t=e.next();break;default:On(n,t),t=e.next()}return n}},sE=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(Dt(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=Aht(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=Dm(Math.abs(t.value))))}t=e.next();break;default:On(n,t),t=e.next()}return n}};function Aht(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 aE=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(Dt(e)),t=e.lastReadGroup;break;case 11:n.vertices.push(Dt(e)),t=e.lastReadGroup;break;case 210:n.extrusionDirection=Dt(e),t=e.lastReadGroup;break;case 100:t=e.next();break;case 101:for(;0!=t.code;)t=e.next();break;default:On(n,t),t=e.next()}return n}},oE=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(...Rht(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:On(n,t),t=e.next()}return n}};function Rht(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 lE=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=Dt(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=Dt(e),t=e.lastReadGroup;break;case 12:n.contextData.textLocation=Dt(e),t=e.lastReadGroup;break;case 13:n.contextData.textDirection=Dt(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=Dt(e),t=e.lastReadGroup;break;case 15:n.contextData.blockContentPosition=Dt(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=vpe(e,47),t=e.lastReadGroup;break;case 110:n.contextData.planeOriginPoint=Dt(e),t=e.lastReadGroup;break;case 111:n.contextData.planeXAxisDirection=Dt(e),t=e.lastReadGroup;break;case 112:n.contextData.planeYAxisDirection=Dt(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=Dt(e),t=e.lastReadGroup;break;case 11:i.doglegVector=Dt(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(Dt(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=Dt(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:On(n,t),t=e.next()}}(),n}},cE=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=Dt(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=Dt(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:On(n,t),t=e.next()}return n}},uE=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:On(n,t),t=e.next()}return n}},hE=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=Dt(e),t=e.lastReadGroup;break;case 39:n.thickness=t.value,t=e.next();break;case 210:n.extrusionDirection=Dt(e),t=e.lastReadGroup;break;case 100:t=e.next();break;case 101:for(;0!=t.code;)t=e.next();break;default:On(n,t),t=e.next()}return n}},dE=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:On(n,t),t=e.next()}return n}},fE=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=Dt(e),t=e.lastReadGroup;break;case 101:for(;0!=t.code;)t=e.next();break;default:On(n,t),t=e.next()}return n.vertices=Cht(e,t),n}};function Cht(e,t){let n=new dE,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){Pht(e,t);break}return i}function Pht(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 On(n,t),t=e.next();return n}var pE=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(Dt(e)),t=e.lastReadGroup;break;case 11:n.directionVector=Dt(e),t=e.lastReadGroup;break;case 100:t=e.next();break;case 101:for(;0!=t.code;)t=e.next();break;default:On(n,t),t=e.next()}return n}},mE=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:On(n,t),t=e.next()}return n}},gE=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||(On(n,t),t=e.next());return n}},vE=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]=Dt(e),t=e.lastReadGroup;break;case 11:n.points[1]=Dt(e),t=e.lastReadGroup;break;case 12:n.points[2]=Dt(e),t=e.lastReadGroup;break;case 13:n.points[3]=Dt(e),t=e.lastReadGroup;break;case 210:n.extrusionDirection=Dt(e),t=e.lastReadGroup;break;case 101:for(;0!=t.code;)t=e.next();break;default:On(n,t),t=e.next()}return n}},yE=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(Dt(e)),t=e.lastReadGroup;break;case 11:n.fitPoints||(n.fitPoints=[]),n.fitPoints.push(Dt(e)),t=e.lastReadGroup;break;case 12:n.startTangent=Dt(e),t=e.lastReadGroup;break;case 13:n.endTangent=Dt(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=Dt(e),t=e.lastReadGroup;break;case 101:for(;0!=t.code;)t=e.next();break;default:On(n,t),t=e.next()}return n}},xE=class{constructor(){this.ForEntityName="ACAD_TABLE"}parseEntity(e,t){let n={type:t.value};for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 10:n.startPoint=Dt(e),t=e.lastReadGroup;break;case 11:n.directionVector=Dt(e),t=e.lastReadGroup;break;case 90:n.tableValue=t.value,t=e.next();break;case 91:n.rowCount=t.value,t=e.next();break;case 92:n.columnCount=t.value,t=e.next();break;case 93:n.overrideFlag=t.value,t=e.next();break;case 94:n.borderColorOverrideFlag=t.value,t=e.next();break;case 95:n.borderLineWeightOverrideFlag=t.value,t=e.next();break;case 96:n.borderVisibilityOverrideFlag=t.value,t=e.next();break;case 141:n.rowHeightArr?n.rowHeightArr.push(t.value):n.rowHeightArr=[t.value],t=e.next();break;case 142:n.columnWidthArr?n.columnWidthArr.push(t.value):n.columnWidthArr=[t.value],t=e.next();break;case 280:n.version=t.value,t=e.next();break;case 342:n.tableStyleId=t.value,t=e.next();break;case 343:n.blockRecordHandle=t.value,t=e.next();break;case 171:n.cells?n.cells.push(xpe(t,e)):n.cells=[xpe(t,e)],t=e.lastReadGroup;break;default:console.log(t.code,t.value),On(n,t),t=e.next()}return n}};function xpe(e,t){let n=!1,i=!1,r={};for(;!t.isEOF()&&0!==e.code&&!i;)switch(e.code){case 171:if(n){i=!0;continue}r.cellType=e.value,n=!0,e=t.next();break;case 172:r.flagValue=e.value,e=t.next();break;case 173:r.mergedValue=e.value,e=t.next();break;case 174:r.autoFit=e.value,e=t.next();break;case 175:r.borderWidth=e.value,e=t.next();break;case 176:r.borderHeight=e.value,e=t.next();break;case 91:r.overrideFlag=e.value,e=t.next();break;case 178:r.virtualEdgeFlag=e.value,e=t.next();break;case 145:r.rotation=e.value,e=t.next();break;case 345:r.fieldObjetId=e.value,e=t.next();break;case 340:r.blockTableRecordId=e.value,e=t.next();break;case 146:r.blockScale=e.value,e=t.next();break;case 177:r.blockAttrNum=e.value,e=t.next();break;case 7:r.textStyle=e.value,e=t.next();break;case 140:r.textHeight=e.value,e=t.next();break;case 170:r.attachmentPoint=e.value,e=t.next();break;case 92:r.extendedCellFlags=e.value,e=t.next();break;case 301:Iht(e,r,t),e=t.next();break;default:return r}return n=!1,i=!1,r}function Iht(e,t,n){for(;304!==e.code;)switch(e.code){case 301:case 93:case 90:case 94:e=n.next();break;case 1:t.text=e.value,e=n.next();break;case 300:t.attrText=e.value,e=n.next();break;case 302:t.text=e.value?e.value:t.text,e=n.next();break;default:console.log(`[DXF ACAD_TABLE] ignore code: ${e.code}, value: ${e.value}`),e=n.next()}}var bE=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=Dt(e),t=e.lastReadGroup;break;case 11:n.endPoint=Dt(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:On(n,t),t=e.next()}return n}},EE=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=Dt(e),t=e.lastReadGroup;break;case 12:n.centerPoint_dcs=Dt(e),t=e.lastReadGroup;break;case 13:n.snapBasePoint_dcs=Dt(e),t=e.lastReadGroup;break;case 14:n.snapSpacing_dcs=Dt(e),t=e.lastReadGroup;break;case 15:n.gridSpacing_dcs=Dt(e),t=e.lastReadGroup;break;case 16:n.viewDirection=Dt(e),t=e.lastReadGroup;break;case 17:n.viewTarget=Dt(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=Dt(e),t=e.lastReadGroup;break;case 111:n.ucsXAxis=Dt(e),t=e.lastReadGroup;break;case 112:n.ucsYAxis=Dt(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:On(n,t),t=e.next()}return n}},_E=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(Dt(e)),t=e.lastReadGroup;break;case 11:n.directionVector=Dt(e),t=e.lastReadGroup;break;case 100:t=e.next();break;case 101:for(;0!=t.code;)t=e.next();break;default:On(n,t),t=e.next()}return n}},jR=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:Nl(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}},XR=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=Dt(e),t=e.next();break;case 11:n.pixelSize=Dt(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:Nl(n,t),t=e.next()}return n}},YR=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=Dt(e),t=e.lastReadGroup;break;case 11:n.maxLimit=Dt(e),t=e.lastReadGroup;break;case 12:n.basePoint=Dt(e),t=e.lastReadGroup;break;case 13:n.origin=Dt(e),t=e.lastReadGroup;break;case 14:n.minExtent=Dt(e),t=e.lastReadGroup;break;case 15:n.maxExtent=Dt(e),t=e.lastReadGroup;break;case 16:n.XAxis=Dt(e),t=e.lastReadGroup;break;case 17:n.YAxis=Dt(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:Nl(n,t),t=e.next()}return n.blockTableHandle=n.ownerHandle,n}},$R=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:Nl(n,t),t=e.next()}return n}},ZR=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=Dt(e),t=e.lastReadGroup;break;case 70:r.numberOfPointsOnClipBoundary=t.value,2===r.numberOfPointsOnClipBoundary?(t=e.next(),n=Dt(e),t=e.lastReadGroup,i=Dt(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=Lht(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=bpe(e,40),r.matrix=bpe(e,40),t=e.lastReadGroup;break;default:Nl(r,t),t=e.next()}return r}};function Lht(e,t){t.next();let n=[];for(;n.length<e;)n.push(Dt(t));return n}function bpe(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 KR=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:Nl(n,t),t=e.next()}return n}};function Dht(e){e.registerEntityHandler($b),e.registerEntityHandler(Zb),e.registerEntityHandler(Kb),e.registerEntityHandler(Jb),e.registerEntityHandler(Qb),e.registerEntityHandler(eE),e.registerEntityHandler(lE),e.registerEntityHandler(tE),e.registerEntityHandler(nE),e.registerEntityHandler(rE),e.registerEntityHandler(iE),e.registerEntityHandler(sE),e.registerEntityHandler(aE),e.registerEntityHandler(oE),e.registerEntityHandler(cE),e.registerEntityHandler(uE),e.registerEntityHandler(hE),e.registerEntityHandler(fE),e.registerEntityHandler(mE),e.registerEntityHandler(pE),e.registerEntityHandler(gE),e.registerEntityHandler(vE),e.registerEntityHandler(yE),e.registerEntityHandler(xE),e.registerEntityHandler(bE),e.registerEntityHandler(EE),e.registerEntityHandler(_E)}function Oht(e){e.registerObjectHandler(jR),e.registerObjectHandler(XR),e.registerObjectHandler(YR),e.registerObjectHandler($R),e.registerObjectHandler(ZR),e.registerObjectHandler(KR)}function kht(e){let t=new bf(e).readBytes(22),n="";for(let i=0;i<18;i++)n+=String.fromCharCode(t[i]);return"AutoCAD Binary DXF"===n}var km=class{constructor(e){this._entityHandlers={},this._objectHandlers={},this._layoutBlocks={},this.unhandledSections={},this.unhandledObjects={},this.unhandledEntities={},this.unsupportedLineTypes={},this.encoding=e,Dht(this),Oht(this)}parse(e){if("string"==typeof e){let t=this.splitByLineSeparator(e),n=new Hv(t);return this._parse(n)}{let t;if(kht(e))t=new Xb(e);else{let n=new TextDecoder(this.encoding).decode(e),i=Date.now(),r=this.splitByLineSeparator(n);fe.info(`[DxfParser] string.split costed ${(Date.now()-i)/1e3}s, it is avoidable by using dxf in binary.`),t=new Hv(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($o(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&&!$o(i,0,"ENDSEC");)if($o(i,0,"BLOCK")){fe.trace("block {");let e=o();fe.trace("}"),m(e),e.name?t[e.name]=e:fe.error(`[DxfParser] Block with handle '${e.handle}' is missing a name, ignored!`)}else Kh(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:Kh(i),i=e.next()}if($o(i,0,"ENDBLK")){i=e.next();break}}return t}function l(){let t={};for(i=e.next();"EOF"!==i.value&&!$o(i,0,"ENDSEC");)$o(i,0,"TABLE")?(i=e.next(),c[i.value]?(fe.trace(i.value+" Table {"),t[c[i.value].tableName]=u(i),fe.trace("}")):fe.trace("Unhandled Table "+i.value)):i=e.next();return i=e.next(),t}let h="ENDTAB";function u(t){let n=c[t.value],r={},a=0;for(i=e.next();!$o(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||Kh(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():(Kh(i),i=e.next());break;default:Kh(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&&fe.warn(`[DxfParser] Parsed ${e} ${n.dxfSymbolName}s but expected ${a}`)}return i=e.next(),r}let c={VPORT:{tableRecordsProperty:"viewports",tableName:"viewport",dxfSymbolName:"VPORT",parseTableRecords:function(){let t=[],n={};for(fe.trace("Viewport {"),i=e.next();!$o(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&&(fe.trace("}"),t.push(n),fe.trace("Viewport {"),n={},i=e.next());break;default:Kh(i),i=e.next()}return fe.trace("}"),t.push(n),t}},LTYPE:{tableRecordsProperty:"lineTypes",tableName:"lineType",dxfSymbolName:"LTYPE",parseTableRecords:function(){let t={},n={},a=0,s="",o=!1;for(fe.trace("LType {"),i=e.next();!$o(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:fe.trace("}"),a>0&&a!==n.pattern.length&&fe.warn("[DxfParser] lengths do not match on LTYPE pattern"),t[s]=n,n={},fe.trace("LType {"),i=e.next()}return fe.trace("}"),t[s]=n,t}},LAYER:{tableRecordsProperty:"layers",tableName:"layer",dxfSymbolName:"LAYER",parseTableRecords:function(){let t,n={},r={};for(fe.trace("Layer {"),i=e.next();!$o(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=Fht(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&&(fe.trace("}"),t&&(n[t]=r),fe.trace("Layer {"),r={},t=void 0,i=e.next());break;default:Kh(i),i=e.next()}return fe.trace("}"),t&&(n[t]=r),n}},BLOCK_RECORD:{tableRecordsProperty:"blockRecords",tableName:"blockRecord",dxfSymbolName:"BLOCK_RECORD",parseTableRecords:function(){let t,n={},a={};for(fe.trace("BlockRecord {"),i=e.next();!$o(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){fe.trace("}"),t&&(n[t]=a);let s=a.layoutHandle;t&&s&&s.length>0&&"0"!==s&&(r._layoutBlocks[s]=a),fe.trace("BlockRecord {"),a={},t=void 0,i=e.next()}else Kh(i),i=e.next();break;default:Kh(i),i=e.next()}fe.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(fe.trace("Style {"),i=e.next();!$o(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&&(fe.trace("}"),t&&(n[t]=r),fe.trace("Style {"),r={},t=void 0,i=e.next())}return fe.trace("}"),t&&(n[t]=r),n}},DIMSTYLE:{tableRecordsProperty:"dimStyles",tableName:"dimStyle",dxfSymbolName:"DIMSTYLE",parseTableRecords:function(){let t,n={},r={};for(fe.trace("DimStyle {"),i=e.next();!$o(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&&(fe.trace("}"),t&&(n[t]=r),fe.trace("DimStyle {"),r={},t=void 0,i=e.next())}return fe.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}{fe.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=Nv)),i=e.lastReadGroup,fe.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}{fe.trace(i.value+" {");let r=n.parseObject(e,i),a=i.value;i=e.lastReadGroup,fe.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&&fe.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){fe.error("Unexpected code %s after 0:SECTION",Epe(i)),i=e.next();continue}if("HEADER"===i.value)fe.trace("> HEADER"),t.header=a(),fe.trace("<");else if("TABLES"===i.value)fe.trace("> TABLES"),t.tables=l(),fe.trace("<");else if("BLOCKS"===i.value)fe.trace("> BLOCKS"),t.blocks=s(),fe.trace("<");else if("ENTITIES"===i.value)fe.trace("> ENTITIES"),t.entities=d(!1),fe.trace("<");else if("OBJECTS"===i.value)fe.trace("> OBJECTS"),t.objects=p(),fe.trace("<");else if("EOF"===i.value)fe.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 $o(e,t,n){return e.code===t&&e.value===n}function Kh(e){fe.trace("unhandled group "+Epe(e))}function Epe(e){return e.code+":"+e.value}function Fht(e){return WR[e]}var p5=(e=>(e.Added="Added",e.Removed="Removed",e.Modified="Modified",e.NoChange="NoChange",e))(p5||{}),ja=1,JR=class{constructor(e,t,n){if(this.changes={},this.comparedBlocks=new Map,this.isComparingBlock=!1,this.isComparingDimension=!1,this.enableDetailComparision=!0,this.dxf1=e,this.dxf2=t,this.enableDetailComparision=!n||(null==n?void 0:n.enableDetailComparision),!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 it(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);!JR.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);!JR.ignoreEntityTypes.includes(e.type)&&!t&&n.set(e.handle,e)}})),yield this.compareEntities(t,n,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(e,t,n,i),this.isComparingDimension=!1,fe.debug(`[DxfCompare] compare block: ${a} cost ${(Date.now()-s)/1e3}s`)}else{if(!this.comparedBlocks.has(a)){let n=this.dxf1.blocks[a],i=this.dxf2.blocks[a],r=Date.now(),s=this.compareBlock(e,t,n,i);this.comparedBlocks.set(a,s),fe.debug(`[DxfCompare] compare block: ${a} cost ${(Date.now()-r)/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[ja]=Ci(Ir({id:ja},t),{parentHandles:n})),ja++}})),!n&&!i&&(this.isComparingBlock=!1),r}compareBlock(e,t,n,i){var r,a;let s=[],o=[];null==(r=null==n?void 0:n.entities)||r.forEach((e=>{"ATTDEF"!==e.type&&!this.bIgnoreChildEntitiesOriginalType(e)&&s.push(e)})),null==(a=null==i?void 0:i.entities)||a.forEach((e=>{"ATTDEF"!==e.type&&!this.bIgnoreChildEntitiesOriginalType(e)&&o.push(e)}));let l=[],h=[];for(let u=0;u<s.length;u++){let n=s[u],i=!1;0===o.length&&(i=!0),this.isComparingDimension||(this.isComparingDimension="DIMENSION"===n.type);for(let r=0;r<o.length;r++){let a=o[r];if(this.entitiesEqual(n,a,e,t)){if("INSERT"===n.type&&"INSERT"===a.type||"DIMENSION"===n.type&&"DIMENSION"===a.type){let e=this.compareInsertOrDemensionEntities(n,a,n.handle,a.handle);e&&e.length>0&&l.push(...e),i=!1,o.splice(r--,1);break}i=!1,o.splice(r--,1);break}i=!0}i&&(l.push({type:"Removed",handle:n.handle}),h.push(n.handle))}return o.forEach((e=>{h.includes(e.handle)||l.push({type:"Added",handle:e.handle})})),l}compareEntities(e,t,n){return it(this,null,(function*(){var i,r;let a=Pt.getUpdateProgressFuncForLoop(e.length,n);for(let n=0;n<e.length;n++){let s=e[n].handle;if(t.has(s)){let a=e[n],o=t.get(s),l={};if(this.entitiesEqual(a,o,void 0,void 0,l)){if(Lm.includes(a.type)){if(this.bIgnoreChildEntitiesOriginalType(a)){t.delete(s),fe.warn(`[DxfCompare] We cannot compare insert (handle '${a.handle}') yet, ignored!`);continue}this.compareInsertOrDemensionEntities(a,o)}}else{if(null!=(i=a.extendedData)&&i.originalType&&null!=(r=o.extendedData)&&r.originalType&&a.block!==o.block){t.delete(s);continue}this.changes[ja]={id:ja,type:"Modified",handle:s},this.enableDetailComparision&&Object.keys(l).length>0&&(this.changes[ja].detailChanges=l),ja++}t.delete(s)}else this.changes[ja]={id:ja,type:"Removed",handle:s},ja++;yield a(n)}for(let e of t){let t=e[0];this.changes[ja]={id:ja,type:"Added",handle:t},ja++}}))}bIgnoreChildEntitiesOriginalType(e){var t;return gpe.includes(null==(t=e.extendedData)?void 0:t.originalType)}entitiesEqual(e,t,n,i,r){if(!this.baseEntitiesEqual(e,t,n,i,r))return!1;let a=e.type,s=!0;return"CIRCLE"===a||"ARC"===a?s=this.arcsEqual(e,t):"LWPOLYLINE"===a||"LINE"===a?s=this.linesEqual(e,t,r):"POLYLINE"===a?s=this.polylinesEqual(e,t):"TEXT"===a?s=this.textsEqual(e,t):"SOLID"===a?s=this.solidsEqual(e,t):"POINT"===a?s=this.pointEntitiesEqual(e,t):"INSERT"===a?s=this.insertsEqual(e,t):"SPLINE"===a?s=this.splinesEqual(e,t):"MTEXT"===a?s=this.mtextsEqual(e,t):"ELLIPSE"===a?s=this.ellipsesEqual(e,t):"DIMENSION"===a?s=this.dimensionsEqual(e,t):"REGION"===a?s=this.regionsEqual(e,t):"ATTDEF"===a?s=this.attDefsEqual(e,t):"ATTRIB"===a?s=this.attribsEqual(e,t):"HATCH"===a?s=this.hatchesEqual(e,t):"VIEWPORT"===a?s=this.viewportsEqual(e,t):"LEADER"===a?s=this.leadersEqual(e,t):"MULTILEADER"===a?s=this.mleadersEqual(e,t):"OLE2FRAME"===a&&(s=this.ole2framesEqual(e,t)),s}getColor(e,t,n){var i,r,a,s,o,l;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;let h=0;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],u=i&&n&&i[n.layer];h=r&&"0"!==r.name?r.color:u?u.color:r?r.color:null==(l=null==(o=t.tables)?void 0:o.layer)?void 0:l.layers[0].color}return h}getLineType(e,t,n){var i,r;if(n&&"DIMENSION"===n.type)return this.getLineType(n,t);if(e.lineType!==Nv&&e.lineType!==Bv)return e.lineType;if(e.lineType===Bv)return n?this.getLineType(n,t):e.lineType;let a=null==(r=null==(i=t.tables)?void 0:i.layer)?void 0:r.layers;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"CONTINUOUS"}addModificationItem(e,t,n,i){i&&(i[n]={old:e,new:t})}baseEntitiesEqual(e,t,n,i,r){var a,s;let o=!0,l=this.getColor(e,this.dxf1,n),h=this.getColor(t,this.dxf2,i);if(l!==h){if(o=!1,!this.enableDetailComparision)return o;this.addModificationItem(l,h,"color",r)}let u=this.getLineType(e,this.dxf1,n),c=this.getLineType(t,this.dxf2,i);return u!==c?(o=!1,this.enableDetailComparision?(this.addModificationItem(u,c,"lineType",r),!1):o):!((null==(a=e.extendedData)?void 0:a.originalType)!==(null==(s=t.extendedData)?void 0:s.originalType)||!this.isComparingBlock&&!this.isComparingDimension&&e.handle!==t.handle||!this.isComparingDimension&&e.ownerHandle!==t.ownerHandle||e.type!==t.type)&&o}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,n){let i=!0,r=e.constantWidth,a=t.constantWidth;if(r!==a){if(i=!1,!this.enableDetailComparision)return!1;this.addModificationItem(r||0,a||0,"constantWidth",n)}return!(!this.verticesEqual(e.vertices,t.vertices)||e.shape!==t.shape)&&i}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)?(fe.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 fe.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&&Zt.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)}},js=JR;js.ENTITY_COLOR_ADDED=65280,js.ENTITY_COLOR_REMOVED=16711680,js.ENTITY_COLOR_NO_CHANGE=10066329,js.ENTITY_COLOR_MARKUP=16744231,js.ignoreEntityTypes=["ATTRIB","SEQEND"];var x0e=ss(Bpe(),1),qpe="3.7.5",jht=qpe,Xht="function"==typeof atob,Yht="function"==typeof btoa,qv="function"==typeof Buffer,Upe="function"==typeof TextDecoder?new TextDecoder:void 0,Hpe="function"==typeof TextEncoder?new TextEncoder:void 0,$ht="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",TE=Array.prototype.slice.call($ht),rC=(e=>{let t={};return TE.forEach(((e,n)=>t[e]=n)),t})(),Zht=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,ia=String.fromCharCode.bind(String),Vpe="function"==typeof Uint8Array.from?Uint8Array.from.bind(Uint8Array):e=>new Uint8Array(Array.prototype.slice.call(e,0)),Wpe=e=>e.replace(/=/g,"").replace(/[+\/]/g,(e=>"+"==e?"-":"_")),jpe=e=>e.replace(/[^A-Za-z0-9\+\/]/g,""),Xpe=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+=TE[t>>18&63]+TE[t>>12&63]+TE[t>>6&63]+TE[63&t]}return s?a.slice(0,s-3)+"===".substring(s):a},S5=Yht?e=>btoa(e):qv?e=>Buffer.from(e,"binary").toString("base64"):Xpe,T5=qv?e=>Buffer.from(e).toString("base64"):e=>{let t=[];for(let n=0,i=e.length;n<i;n+=4096)t.push(ia.apply(null,e.subarray(n,n+4096)));return S5(t.join(""))},iC=(e,t=!1)=>t?Wpe(T5(e)):T5(e),Kht=e=>{if(e.length<2)return(t=e.charCodeAt(0))<128?e:t<2048?ia(192|t>>>6)+ia(128|63&t):ia(224|t>>>12&15)+ia(128|t>>>6&63)+ia(128|63&t);var t=65536+1024*(e.charCodeAt(0)-55296)+(e.charCodeAt(1)-56320);return ia(240|t>>>18&7)+ia(128|t>>>12&63)+ia(128|t>>>6&63)+ia(128|63&t)},Jht=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,Ype=e=>e.replace(Jht,Kht),zpe=qv?e=>Buffer.from(e,"utf8").toString("base64"):Hpe?e=>T5(Hpe.encode(e)):e=>S5(Ype(e)),Gv=(e,t=!1)=>t?Wpe(zpe(e)):zpe(e),Gpe=e=>Gv(e,!0),Qht=/[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g,edt=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 ia(55296+(t>>>10))+ia(56320+(1023&t));case 3:return ia((15&e.charCodeAt(0))<<12|(63&e.charCodeAt(1))<<6|63&e.charCodeAt(2));default:return ia((31&e.charCodeAt(0))<<6|63&e.charCodeAt(1))}},$pe=e=>e.replace(Qht,edt),Zpe=e=>{if(e=e.replace(/\s+/g,""),!Zht.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=rC[e.charAt(a++)]<<18|rC[e.charAt(a++)]<<12|(n=rC[e.charAt(a++)])<<6|(i=rC[e.charAt(a++)]),r+=64===n?ia(t>>16&255):64===i?ia(t>>16&255,t>>8&255):ia(t>>16&255,t>>8&255,255&t);return r},M5=Xht?e=>atob(jpe(e)):qv?e=>Buffer.from(e,"base64").toString("binary"):Zpe,Kpe=qv?e=>Vpe(Buffer.from(e,"base64")):e=>Vpe(M5(e).split("").map((e=>e.charCodeAt(0)))),Jpe=e=>Kpe(Qpe(e)),tdt=qv?e=>Buffer.from(e,"base64").toString("utf8"):Upe?e=>Upe.decode(Kpe(e)):e=>$pe(M5(e)),Qpe=e=>jpe(e.replace(/[-_]/g,(e=>"-"==e?"+":"/"))),w5=e=>tdt(Qpe(e)),ndt=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)},eme=e=>({value:e,enumerable:!1,writable:!0,configurable:!0}),tme=function(){let e=(e,t)=>Object.defineProperty(String.prototype,e,eme(t));e("fromBase64",(function(){return w5(this)})),e("toBase64",(function(e){return Gv(this,e)})),e("toBase64URI",(function(){return Gv(this,!0)})),e("toBase64URL",(function(){return Gv(this,!0)})),e("toUint8Array",(function(){return Jpe(this)}))},nme=function(){let e=(e,t)=>Object.defineProperty(Uint8Array.prototype,e,eme(t));e("toBase64",(function(e){return iC(this,e)})),e("toBase64URI",(function(){return iC(this,!0)})),e("toBase64URL",(function(){return iC(this,!0)}))},rdt=()=>{tme(),nme()},rme={version:qpe,VERSION:jht,atob:M5,atobPolyfill:Zpe,btoa:S5,btoaPolyfill:Xpe,fromBase64:w5,toBase64:Gv,encode:Gv,encodeURI:Gpe,encodeURL:Gpe,utob:Ype,btou:$pe,decode:w5,isValid:ndt,fromUint8Array:iC,toUint8Array:Jpe,extendString:tme,extendUint8Array:nme,extendBuiltins:rdt},zl=ss(Eme(),1),sC=new ht,mdt=new ht,Dc=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.geometry)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]],u=[],c=0,d=0,p=0,f=[];if(r.forEach((n=>{var i,r,a,s;let o=e.children[n],l=null==(i=o.geometry)?void 0:i.clone();if(l.applyMatrix4(o.matrix),l.userData.isLineSegments=3===o.type,u.push(l),t){let e=null==(a=null==(r=l.attributes)?void 0:r.position)?void 0:a.count,t=(null==(s=l.index)?void 0:s.count)||0;f.push({batchId:c,positionStart:d,positionCount:e,indexStart:p,indexCount:t}),d+=e,p+=t,c++}})),0!==u.length){if(4===h.type){let e=Oi(u);if(!e)return;e.userData={},i=new pn(h.type),i.geometry=e,i.material=h.material,a.push(i)}else if(2===h.type||3===h.type){let e=Mi.mergeLineGeometries(u,t,h.material instanceof Cu||h.material instanceof hn,f);if(!e)return;i=new pn(3),i.geometry=e,i.material=h.material,s.push(i)}else if(1===h.type){let e=Oi(u);if(!e)return;e.userData={},i=new pn(h.type),i.geometry=e,i.material=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.renderOrder=h.renderOrder,i.layers.mask=h.layers.mask,l.push(...r)),u.forEach((e=>{e.dispose(),en.releaseGeometryManually(e)})),u=[]}})),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)})),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)&&Mi.areGeometriesMergeable(l.geometry,h.geometry)&&Si.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(4===n.type&&n.material&&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){if(!e[m].geometry||this.isFilteredByOtherFactors(e[m],t))continue;let n=!1,i=Object.values(o);for(let t=i.length-1;t>=0;--t){let r=i[t].indexes[0];if(n=this.tryHandleMergeableObjects(e,m,r,o,l),n)break}for(let t=l.length-1;!n&&t>=0;--t){let i=l[t];if(n=this.tryHandleMergeableObjects(e,m,i,o,l),n)break}n||l.push(m)}if(Object.keys(o).length<=0)return a;fe.debug(`[Merge] Built merged indexes for ${e.length} objects in ${(Date.now()-s)/1e3}s`),s=Date.now();let h=[],u=[],c=[],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,u,c;let d=e[n],g=null==(i=d.geometry)?void 0:i.clone();if(s.material instanceof zn&&g.deleteAttribute("lineDistance"),this.applyMatrix(g,d,t),g.userData.isLineSegments=3===d.type,o.push(g),r){let e,t=null==(h=null==(a=g.attributes)?void 0:a.position)?void 0:h.count,n=(null==(u=g.index)?void 0:u.count)||0;(2===s.type||3===s.type)&&(g.boundingSphere||g.computeBoundingSphere(),e=null==(c=g.boundingSphere)?void 0:c.clone()),m.push({batchId:l,positionStart:p,positionCount:t,indexStart:f,indexCount:n,boundingSphere:e}),p+=t,f+=n,l++}})),0!==o.length){if(4===s.type){let e=Oi(o);if(!e)return;e.userData={},a=new pn(s.type),a.geometry=e,a.material=s.material,h.push(a)}else if(2===s.type||3===s.type){let e=Mi.mergeLineGeometries(o,r,s.material instanceof Cu||s.material instanceof hn,m);if(!e)return;a=new pn(3),a.geometry=e,a.material=s.material,u.push(a)}else if(1===s.type){let e=Oi(o);if(!e)return;e.userData={},a=new pn(s.type),a.geometry=e,a.material=s.material,c.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.renderOrder=s.renderOrder,a.layers.mask=s.layers.mask,i.forEach((e=>d.push(e)))),o.forEach((e=>{e.dispose(),en.releaseGeometryManually(e)})),o=[]}})),fe.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,...u,...c].forEach((e=>{f.push(e),n&&t&&t.add(e)})),this.mergeInfo.removedObjects+=d.length,this.mergeInfo.mergedMeshes+=h.length,this.mergeInfo.mergedLines+=u.length,this.mergeInfo.mergedPoints+=c.length,i&&t&&rr.removeEmptyObjects(t),a}static applyMatrix(e,t,n){let i=t;for(sC.identity();i&&i!==n&&(sC.premultiply(i.matrix),i.parent);)i=i.parent;return sC.equals(mdt)?e:e.applyMatrix4(sC)}static removeFromArray(e,t){for(let n=e.length-1;n>=0;--n)if(e[n]===t)return void e.splice(n,1)}static areObjectsMergeable(e,t){return e.layers.mask===t.layers.mask&&e.renderOrder===t.renderOrder&&e.userData.layerName===t.userData.layerName&&(e.type===t.type||!(2!==e.type&&3!==e.type||2!==t.type&&3!==t.type))}};function _me(e,t,n,i,r=0){let a={u_cameraZoom:n,u_patternLines:{value:e},u_patternAngle:{value:t},u_color:{value:i}},s=`\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 // Idealy, the thickness of lines in hatch pattern should always be 1 pixel.\n // In DxfViewer, it uses orthographic camera and always in top view,\n // so we adjust thickness by cameraZoom (and also consider worldScale).\n // While 3d view is more complex, it can use perspective camera,\n // its camera position and direction is flexible. We cannot keep line thickness\n // in a fixed pixel any more, and there is no proper way to adjust thickness as camera\n // position changes. So, we need to use a fixed thickness in world coordinates.\n#if ${r} > 0\n float thick = float(${r});\n#else\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#endif\n\n if(thick > EPS) {\n gl_FragColor = vec4(u_color, 1.0);\n #include <colorspace_fragment>\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 #include <colorspace_fragment>\n }\n `;return new hn({uniforms:a,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:s,clipping:!0})}Dc.mergeInfo={removedObjects:0,mergedMeshes:0,mergedLines:0,mergedPoints:0,mergedUnknownTypeObjects:0,elapsedTime:0};var aC=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=Ti.merge([Qt.common,{pattern:{type:"fv1",value:s},patternLength:{type:"f",value:a},u_color:{value:new ct(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 #include <colorspace_fragment>\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 #include <colorspace_fragment>\n }`;return new hn({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})}},P5={};bT(P5,{default:()=>C5});var R5={};bT(R5,{default:()=>A5});var A5=(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)))),C5=(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]],u=i[l[1]];for(e=e*(u-h)+h,e=Math.max(e,h),e=Math.min(e,u),o=l[0];o<l[1]&&!(e>=i[o]&&e<=i[o+1]);o++);let c,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--){c=(e-i[n])/(i[n+t+1-f]-i[n]);for(let e=0;e<s+1;e++)d[n][e]=(1-c)*d[n-1][e]+c*d[n][e]}let p=[];for(let f=0;f<s;f++)p[f]=A5(d[o][f]/d[o][s],-9);return p},gdt={d:"\xb0",c:"\u2300",p:"\xb1"},oC=(e,t)=>{if(!e)return[];e=e.replace(/%%(.)/g,((e,t)=>gdt[t]||t)).replace(/\^I/g," ");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;break;case"\\":switch(n=e[++l]){default:a+=n;break;case"p":{let t=e.slice(l,l=e.indexOf(";",l));t.startsWith("pxq")||t.startsWith("pxi")||t.startsWith("pxt")||t.startsWith("pt")||t.startsWith("pi")||(t.startsWith("psm")?o({[t.slice(0,t.length-1)]:t[t.length-1]}):t.startsWith("pq")?o({[t.slice(0,t.length-1)]:t[t.length-1]}):o({[t.slice(0,t.length-1)]:t[t.length-1]}));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("/"===t||"#"===t?i+"/"+r:i+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,[,i,r]=e.slice(t,l=e.indexOf(";",l)).match(/^(\d*(?:\.\d+)?)(\D*)$/);o({[n]:[+i,r]})}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(oC(e.slice(i+1,l)));break}}else"\\"===n&&l++;break}}return a&&s.push(a),s},vdt={d:"\xb0",c:"\u2300",p:"\xb1"},ydt=(e,t)=>(e=xdt(e),t?bdt(e,t):e),xdt=e=>e.replace(/\\[uU]\+([0-9a-fA-F]{4})/g,((e,t)=>String.fromCodePoint(parseInt(t,16)))),bdt=(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)]))))},lC=(e,t)=>{let n=0,i={text:""},r=[i],a=(e=ydt(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=vdt[t];a?i.text+=a:3===t.length?i.text+=String.fromCodePoint(+t):"k"===t||"o"===t||"u"===t?(i=Ci(Ir({},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))},cC=(e=>(e.Unitless="Unitless",e.Inches="Inches",e.Feet="Feet",e.Millimeters="Millimeters",e.Centimeters="Centimeters",e.Meters="Meters",e))(cC||{}),Tme=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),w8t=(e,t)=>Tme(e)/Tme(t),uC=class extends Ws{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"}},hC=class{constructor(e){this.isFont=!0,this.type="Font",this.data=e}generateShapes(e,t=100){let n=[],i=Edt(e,t,this.data);for(let r=0,a=i.length;r<a;r++)n.push(...i[r].toShapes());return n}};function Edt(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=_dt(e,r,o,l,n);o+=t.offsetX,s.push(t.path)}}return s}function _dt(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,u,c,d,p,f=new ym;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,u=e[r++]*t+n,c=e[r++]*t+i,f.quadraticCurveTo(u,c,l,h);break;case"b":l=e[r++]*t+n,h=e[r++]*t+i,u=e[r++]*t+n,c=e[r++]*t+i,d=e[r++]*t+n,p=e[r++]*t+i,f.bezierCurveTo(u,c,d,p,l,h)}}return{offsetX:a.ha*t,path:f}}var CE="0.2.69",wme="VERSION",Tdt=()=>window.localStorage.getItem(wme),wdt=()=>{window.localStorage.setItem(wme,CE)},Sme=()=>Tdt()!==CE&&(wdt(),!0),Wv=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:"fileName",autoIncrement:!0},indexArray:[]},{name:"imageData",options:{keyPath:"fileName",autoIncrement:!0},indexArray:[]}],this.db=void 0}static instance(){return Wv._instance||(Wv._instance=new Wv),Wv._instance}getDatabase(){return it(this,null,(function*(){let e=yield this.getDB(this.DATABASE_NAME);return this.db||(e.close(),Sme()&&(yield this.deleteDataBase(this.DATABASE_NAME)),e=yield this.getUpgradedDB(e)),e.onclose=()=>{this.db=void 0,fe.debug(`[DB] Db ${e.name} is closed.`)},e.onerror=t=>{this.db=void 0,fe.debug(`[DB] Db ${e.name} encountered error.`,t)},e.onabort=t=>{this.db=void 0,fe.debug(`[DB] Db ${e.name} aborted.`,t)},e.onversionchange=e=>{fe.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=>{fe.debug(e),n(e)},i.onsuccess=n=>{let i=n.target;fe.debug(`[DB] Db ${e} delete old version ${n.oldVersion}.`),t(i)}}))}getDB(e){return it(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;fe.debug(`[DB] Db ${n.name} opened (version ${n.version}).`),t(n)}}))}))}getUpgradedDB(e){return it(this,null,(function*(){return new Promise(((t,n)=>{fe.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=>{fe.debug("onblocked",e)},i.onupgradeneeded=e=>{e.target.transaction.oncomplete=()=>{fe.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)){fe.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((()=>{fe.debug(`[DB] All(${n.length}) tables created.`)}))},i.onsuccess=e=>{let n=e.target.result;fe.debug(`[DB] Db ${n.name} opened (version ${n.version}).`),t(n)}}))}))}createTable(e,t,n,i){return it(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})})),fe.debug(`[DB] Table ${t} created.`),r(e)}))}))}},ns=Wv;ns._instance=void 0;var Ul=class{constructor(){if(this.db=void 0,this.isCreatingTable=!1,-1===ns.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();ns.instance().getDatabase().then((r=>{let a=r.transaction([i],"readwrite").objectStore(i).add(e);a.onsuccess=t,a.onerror=n})).finally((()=>{ns.instance().closeDatabase()})).catch((e=>{n&&n(e)}))}save(e,t,n){let i=this.tableName();ns.instance().getDatabase().then((r=>{let a=r.transaction([i],"readwrite").objectStore(i).put(e);a.onsuccess=t,a.onerror=n})).finally((()=>{ns.instance().closeDatabase()}))}delete(e,t,n){let i=this.tableName();ns.instance().getDatabase().then((r=>{let a=r.transaction([i],"readwrite").objectStore(i).delete(e);a.onsuccess=t,a.onerror=n})).finally((()=>{ns.instance().closeDatabase()}))}update(){ns.instance().getDatabase().then((()=>{}))}query(e,t){let n=this.tableName();ns.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((()=>{ns.instance().closeDatabase()}))}queryByIndex(e,t,n,i){let r=this.tableName();ns.instance().getDatabase().then((a=>{let s=a.transaction([r],"readonly").objectStore(r).index(e).get(t);s.onerror=i,s.onsuccess=function(e){var t;let i=null==(t=e.target)?void 0:t.result;n&&n(i)}})).finally((()=>{ns.instance().closeDatabase()}))}queryAll(e,t){let n=this.tableName();ns.instance().getDatabase().then((i=>{let r=i.transaction([n],"readonly").objectStore(n).getAll();r.onsuccess=t=>{e&&e(r.result)},r.onerror=t})).finally((()=>{ns.instance().closeDatabase()}))}clearAll(e,t){let n=this.tableName();ns.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((()=>{ns.instance().closeDatabase()}))}},jv=class extends Ul{tableName(){return"annotation"}static instance(){return jv._instance||(jv._instance=new jv),jv._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)}))}},I5=jv;I5._instance=void 0;var Xv=class extends Ul{tableName(){return"viewpoint"}static instance(){return Xv._instance||(Xv._instance=new Xv),Xv._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)}))}},L5=Xv;L5._instance=void 0;var Yv=class extends Ul{tableName(){return"dxfdata"}static instance(){return Yv._instance||(Yv._instance=new Yv),Yv._instance}query(e,t,n){let i=[],r=this.tableName();ns.instance().getDatabase().then((a=>{let s=a.transaction([r],"readonly").objectStore(r).get(e);s.onerror=e=>{n&&n(e),fe.info("[DxfDataTable] Failed to query !",e)},s.onsuccess=()=>{s.result&&i.push(s.result),t&&t(i)}})).finally((()=>{ns.instance().closeDatabase()}))}},$v=Yv;$v._instance=void 0;var Fm=class extends Ul{tableName(){return"fontdata"}static instance(){return Fm._instance||(Fm._instance=new Fm),Fm._instance}query(e){let t;return new Promise(((n,i)=>{super.query((i=>{i?!i.value||i.value.fileName!==e||(t=i.value):n(t)}),(e=>{i(e)}))}))}queryAll(){return it(this,null,(function*(){return new Promise(((e,t)=>{_T(Fm.prototype,this,"queryAll").call(this,(t=>{e(t)}),(e=>{t(e)}))}))}))}},Jh=Fm;Jh._instance=void 0;var Nm=class extends Ul{tableName(){return"imageData"}static instance(){return Nm._instance||(Nm._instance=new Nm),Nm._instance}query(e){let t;return new Promise(((n,i)=>{super.query((i=>{i?!i.value||i.value.fileName!==e||(t=i.value):n(t)}),(e=>{i(e)}))}))}queryAll(){return it(this,null,(function*(){return new Promise(((e,t)=>{_T(Nm.prototype,this,"queryAll").call(this,(t=>{e(t)}),(e=>{t(e)}))}))}))}},Ef=Nm;Ef._instance=void 0;var Zv=class extends hC{constructor(e,t){super(t),this.info="",this.orientation=0,this.baseUp=0,this.baseDown=0,this.fileHeader="",this.fileVersion="",this.order=0,this.unsupportedChars={},this.fileName=e}addUnsupportedChar(e){this.unsupportedChars[e]||(this.unsupportedChars[e]=0),this.unsupportedChars[e]++}getFontFile(){return{order:this.order,data:this.data,info:this.info,orientation:this.orientation,baseUp:this.baseUp,baseDown:this.baseDown,fileName:this.fileName,fileHeader:this.fileHeader,fileVersion:this.fileVersion}}setFontFile(e){this.fileName=e.fileName,this.data=e.data,this.info=e.info,this.order=e.order,this.orientation=e.orientation,this.baseUp=e.baseUp,this.baseDown=e.baseDown,this.fileHeader=e.fileHeader,this.fileVersion=e.fileVersion}setFontDataToIndexedDb(){return it(this,null,(function*(){let e=this.getFontFile();return new Promise(((t,n)=>{Jh.instance().save(e,(()=>{console.log(`[FontFile] Saved '${this.fileName}' (${this.fileHeader}) to indexedDb`),t()}),(e=>n(`[FontFile] Failed to save '${this.fileName}' (${this.fileHeader}) to indexedDb! ${e}`)))}))}))}getFontDataByIndexedDb(){return it(this,null,(function*(){return Jh.instance().query(this.fileName)}))}releaseFontData(){this.data={}}};String.prototype.codePointAt||function(){var e=function(){try{var e={},t=Object.defineProperty,n=t(e,e,e)&&t}catch(e){}return n}(),t=function(e){if(null==this)throw TypeError();var t=String(this),n=t.length,i=e?Number(e):0;if(i!=i&&(i=0),!(i<0||i>=n)){var r,a=t.charCodeAt(i);return a>=55296&&a<=56319&&n>i+1&&(r=t.charCodeAt(i+1))>=56320&&r<=57343?1024*(a-55296)+r-56320+65536:a}};e?e(String.prototype,"codePointAt",{value:t,configurable:!0,writable:!0}):String.prototype.codePointAt=t}();var K5=0,hge=-3;function LE(){this.table=new Uint16Array(16),this.trans=new Uint16Array(288)}function Sdt(e,t){this.source=e,this.sourceIndex=0,this.tag=0,this.bitcount=0,this.dest=t,this.destLen=0,this.ltree=new LE,this.dtree=new LE}var dge=new LE,fge=new LE,J5=new Uint8Array(30),Q5=new Uint16Array(30),pge=new Uint8Array(30),mge=new Uint16Array(30),Mdt=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Mme=new LE,Fu=new Uint8Array(320);function gge(e,t,n,i){var r,a;for(r=0;r<n;++r)e[r]=0;for(r=0;r<30-n;++r)e[r+n]=r/n|0;for(a=i,r=0;r<30;++r)t[r]=a,a+=1<<e[r]}function Adt(e,t){var n;for(n=0;n<7;++n)e.table[n]=0;for(e.table[7]=24,e.table[8]=152,e.table[9]=112,n=0;n<24;++n)e.trans[n]=256+n;for(n=0;n<144;++n)e.trans[24+n]=n;for(n=0;n<8;++n)e.trans[168+n]=280+n;for(n=0;n<112;++n)e.trans[176+n]=144+n;for(n=0;n<5;++n)t.table[n]=0;for(t.table[5]=32,n=0;n<32;++n)t.trans[n]=n}var Ame=new Uint16Array(16);function D5(e,t,n,i){var r,a;for(r=0;r<16;++r)e.table[r]=0;for(r=0;r<i;++r)e.table[t[n+r]]++;for(e.table[0]=0,a=0,r=0;r<16;++r)Ame[r]=a,a+=e.table[r];for(r=0;r<i;++r)t[n+r]&&(e.trans[Ame[t[n+r]]++]=r)}function Rdt(e){e.bitcount--||(e.tag=e.source[e.sourceIndex++],e.bitcount=7);var t=1&e.tag;return e.tag>>>=1,t}function Nu(e,t,n){if(!t)return n;for(;e.bitcount<24;)e.tag|=e.source[e.sourceIndex++]<<e.bitcount,e.bitcount+=8;var i=e.tag&65535>>>16-t;return e.tag>>>=t,e.bitcount-=t,i+n}function z5(e,t){for(;e.bitcount<24;)e.tag|=e.source[e.sourceIndex++]<<e.bitcount,e.bitcount+=8;var n=0,i=0,r=0,a=e.tag;do{i=2*i+(1&a),a>>>=1,++r,n+=t.table[r],i-=t.table[r]}while(i>=0);return e.tag=a,e.bitcount-=r,t.trans[n+i]}function Cdt(e,t,n){var i,r,a,s,o,l;for(i=Nu(e,5,257),r=Nu(e,5,1),a=Nu(e,4,4),s=0;s<19;++s)Fu[s]=0;for(s=0;s<a;++s){var h=Nu(e,3,0);Fu[Mdt[s]]=h}for(D5(Mme,Fu,0,19),o=0;o<i+r;){var u=z5(e,Mme);switch(u){case 16:var c=Fu[o-1];for(l=Nu(e,2,3);l;--l)Fu[o++]=c;break;case 17:for(l=Nu(e,3,3);l;--l)Fu[o++]=0;break;case 18:for(l=Nu(e,7,11);l;--l)Fu[o++]=0;break;default:Fu[o++]=u}}D5(t,Fu,0,i),D5(n,Fu,i,r)}function Rme(e,t,n){for(;;){var i,r,a,s,o=z5(e,t);if(256===o)return K5;if(o<256)e.dest[e.destLen++]=o;else for(i=Nu(e,J5[o-=257],Q5[o]),r=z5(e,n),s=a=e.destLen-Nu(e,pge[r],mge[r]);s<a+i;++s)e.dest[e.destLen++]=e.dest[s]}}function Pdt(e){for(var t,n;e.bitcount>8;)e.sourceIndex--,e.bitcount-=8;if((t=256*(t=e.source[e.sourceIndex+1])+e.source[e.sourceIndex])!==(65535&~(256*e.source[e.sourceIndex+3]+e.source[e.sourceIndex+2])))return hge;for(e.sourceIndex+=4,n=t;n;--n)e.dest[e.destLen++]=e.source[e.sourceIndex++];return e.bitcount=0,K5}function Idt(e,t){var n,i,r=new Sdt(e,t);do{switch(n=Rdt(r),Nu(r,2,0)){case 0:i=Pdt(r);break;case 1:i=Rme(r,dge,fge);break;case 2:Cdt(r,r.ltree,r.dtree),i=Rme(r,r.ltree,r.dtree);break;default:i=hge}if(i!==K5)throw new Error("Data error")}while(!n);return r.destLen<r.dest.length?"function"==typeof r.dest.slice?r.dest.slice(0,r.destLen):r.dest.subarray(0,r.destLen):r.dest}Adt(dge,fge),gge(J5,Q5,4,3),gge(pge,mge,2,1),J5[28]=0,Q5[28]=258;var Ldt=Idt;function Kv(e,t,n,i,r){return Math.pow(1-r,3)*e+3*Math.pow(1-r,2)*r*t+3*(1-r)*Math.pow(r,2)*n+Math.pow(r,3)*i}function Rf(){this.x1=Number.NaN,this.y1=Number.NaN,this.x2=Number.NaN,this.y2=Number.NaN}function ks(){this.commands=[],this.fill="black",this.stroke=null,this.strokeWidth=1}function vge(e){throw new Error(e)}function Cme(e,t){e||vge(t)}Rf.prototype.isEmpty=function(){return isNaN(this.x1)||isNaN(this.y1)||isNaN(this.x2)||isNaN(this.y2)},Rf.prototype.addPoint=function(e,t){"number"==typeof e&&((isNaN(this.x1)||isNaN(this.x2))&&(this.x1=e,this.x2=e),e<this.x1&&(this.x1=e),e>this.x2&&(this.x2=e)),"number"==typeof t&&((isNaN(this.y1)||isNaN(this.y2))&&(this.y1=t,this.y2=t),t<this.y1&&(this.y1=t),t>this.y2&&(this.y2=t))},Rf.prototype.addX=function(e){this.addPoint(e,null)},Rf.prototype.addY=function(e){this.addPoint(null,e)},Rf.prototype.addBezier=function(e,t,n,i,r,a,s,o){var l=[e,t],h=[n,i],u=[r,a],c=[s,o];this.addPoint(e,t),this.addPoint(s,o);for(var d=0;d<=1;d++){var p=6*l[d]-12*h[d]+6*u[d],f=-3*l[d]+9*h[d]-9*u[d]+3*c[d],m=3*h[d]-3*l[d];if(0!==f){var g=Math.pow(p,2)-4*m*f;if(!(g<0)){var v=(-p+Math.sqrt(g))/(2*f);0<v&&v<1&&(0===d&&this.addX(Kv(l[d],h[d],u[d],c[d],v)),1===d&&this.addY(Kv(l[d],h[d],u[d],c[d],v)));var y=(-p-Math.sqrt(g))/(2*f);0<y&&y<1&&(0===d&&this.addX(Kv(l[d],h[d],u[d],c[d],y)),1===d&&this.addY(Kv(l[d],h[d],u[d],c[d],y)))}}else{if(0===p)continue;var x=-m/p;0<x&&x<1&&(0===d&&this.addX(Kv(l[d],h[d],u[d],c[d],x)),1===d&&this.addY(Kv(l[d],h[d],u[d],c[d],x)))}}},Rf.prototype.addQuad=function(e,t,n,i,r,a){var s=e+.6666666666666666*(n-e),o=t+2/3*(i-t),l=s+1/3*(r-e),h=o+1/3*(a-t);this.addBezier(e,t,s,o,l,h,r,a)},ks.prototype.moveTo=function(e,t){this.commands.push({type:"M",x:e,y:t})},ks.prototype.lineTo=function(e,t){this.commands.push({type:"L",x:e,y:t})},ks.prototype.curveTo=ks.prototype.bezierCurveTo=function(e,t,n,i,r,a){this.commands.push({type:"C",x1:e,y1:t,x2:n,y2:i,x:r,y:a})},ks.prototype.quadTo=ks.prototype.quadraticCurveTo=function(e,t,n,i){this.commands.push({type:"Q",x1:e,y1:t,x:n,y:i})},ks.prototype.close=ks.prototype.closePath=function(){this.commands.push({type:"Z"})},ks.prototype.extend=function(e){if(e.commands)e=e.commands;else if(e instanceof Rf){var t=e;return this.moveTo(t.x1,t.y1),this.lineTo(t.x2,t.y1),this.lineTo(t.x2,t.y2),this.lineTo(t.x1,t.y2),void this.close()}Array.prototype.push.apply(this.commands,e)},ks.prototype.getBoundingBox=function(){for(var e=new Rf,t=0,n=0,i=0,r=0,a=0;a<this.commands.length;a++){var s=this.commands[a];switch(s.type){case"M":e.addPoint(s.x,s.y),t=i=s.x,n=r=s.y;break;case"L":e.addPoint(s.x,s.y),i=s.x,r=s.y;break;case"Q":e.addQuad(i,r,s.x1,s.y1,s.x,s.y),i=s.x,r=s.y;break;case"C":e.addBezier(i,r,s.x1,s.y1,s.x2,s.y2,s.x,s.y),i=s.x,r=s.y;break;case"Z":i=t,r=n;break;default:throw new Error("Unexpected path command "+s.type)}}return e.isEmpty()&&e.addPoint(0,0),e},ks.prototype.draw=function(e){e.beginPath();for(var t=0;t<this.commands.length;t+=1){var n=this.commands[t];"M"===n.type?e.moveTo(n.x,n.y):"L"===n.type?e.lineTo(n.x,n.y):"C"===n.type?e.bezierCurveTo(n.x1,n.y1,n.x2,n.y2,n.x,n.y):"Q"===n.type?e.quadraticCurveTo(n.x1,n.y1,n.x,n.y):"Z"===n.type&&e.closePath()}this.fill&&(e.fillStyle=this.fill,e.fill()),this.stroke&&(e.strokeStyle=this.stroke,e.lineWidth=this.strokeWidth,e.stroke())},ks.prototype.toPathData=function(e){function t(t){return Math.round(t)===t?""+Math.round(t):t.toFixed(e)}function n(){for(var e=arguments,n="",i=0;i<arguments.length;i+=1){var r=e[i];r>=0&&i>0&&(n+=" "),n+=t(r)}return n}e=void 0!==e?e:2;for(var i="",r=0;r<this.commands.length;r+=1){var a=this.commands[r];"M"===a.type?i+="M"+n(a.x,a.y):"L"===a.type?i+="L"+n(a.x,a.y):"C"===a.type?i+="C"+n(a.x1,a.y1,a.x2,a.y2,a.x,a.y):"Q"===a.type?i+="Q"+n(a.x1,a.y1,a.x,a.y):"Z"===a.type&&(i+="Z")}return i},ks.prototype.toSVG=function(e){var t='<path d="';return t+=this.toPathData(e),t+='"',this.fill&&"black"!==this.fill&&(null===this.fill?t+=' fill="none"':t+=' fill="'+this.fill+'"'),this.stroke&&(t+=' stroke="'+this.stroke+'" stroke-width="'+this.strokeWidth+'"'),t+"/>"},ks.prototype.toDOMElement=function(e){var t=this.toPathData(e),n=document.createElementNS("http://www.w3.org/2000/svg","path");return n.setAttribute("d",t),n};var Yn={fail:vge,argument:Cme,assert:Cme},Pme=32768,Ime=2147483648,Qv={},tn={},Qn={};function Nc(e){return function(){return e}}tn.BYTE=function(e){return Yn.argument(e>=0&&e<=255,"Byte value should be between 0 and 255."),[e]},Qn.BYTE=Nc(1),tn.CHAR=function(e){return[e.charCodeAt(0)]},Qn.CHAR=Nc(1),tn.CHARARRAY=function(e){void 0===e&&(e="",console.warn("Undefined CHARARRAY encountered and treated as an empty string. This is probably caused by a missing glyph name."));for(var t=[],n=0;n<e.length;n+=1)t[n]=e.charCodeAt(n);return t},Qn.CHARARRAY=function(e){return void 0===e?0:e.length},tn.USHORT=function(e){return[e>>8&255,255&e]},Qn.USHORT=Nc(2),tn.SHORT=function(e){return e>=Pme&&(e=-(2*Pme-e)),[e>>8&255,255&e]},Qn.SHORT=Nc(2),tn.UINT24=function(e){return[e>>16&255,e>>8&255,255&e]},Qn.UINT24=Nc(3),tn.ULONG=function(e){return[e>>24&255,e>>16&255,e>>8&255,255&e]},Qn.ULONG=Nc(4),tn.LONG=function(e){return e>=Ime&&(e=-(2*Ime-e)),[e>>24&255,e>>16&255,e>>8&255,255&e]},Qn.LONG=Nc(4),tn.FIXED=tn.ULONG,Qn.FIXED=Qn.ULONG,tn.FWORD=tn.SHORT,Qn.FWORD=Qn.SHORT,tn.UFWORD=tn.USHORT,Qn.UFWORD=Qn.USHORT,tn.LONGDATETIME=function(e){return[0,0,0,0,e>>24&255,e>>16&255,e>>8&255,255&e]},Qn.LONGDATETIME=Nc(8),tn.TAG=function(e){return Yn.argument(4===e.length,"Tag should be exactly 4 ASCII characters."),[e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)]},Qn.TAG=Nc(4),tn.Card8=tn.BYTE,Qn.Card8=Qn.BYTE,tn.Card16=tn.USHORT,Qn.Card16=Qn.USHORT,tn.OffSize=tn.BYTE,Qn.OffSize=Qn.BYTE,tn.SID=tn.USHORT,Qn.SID=Qn.USHORT,tn.NUMBER=function(e){return e>=-107&&e<=107?[e+139]:e>=108&&e<=1131?[247+((e-=108)>>8),255&e]:e>=-1131&&e<=-108?[251+((e=-e-108)>>8),255&e]:e>=-32768&&e<=32767?tn.NUMBER16(e):tn.NUMBER32(e)},Qn.NUMBER=function(e){return tn.NUMBER(e).length},tn.NUMBER16=function(e){return[28,e>>8&255,255&e]},Qn.NUMBER16=Nc(3),tn.NUMBER32=function(e){return[29,e>>24&255,e>>16&255,e>>8&255,255&e]},Qn.NUMBER32=Nc(5),tn.REAL=function(e){var t=e.toString(),n=/\.(\d*?)(?:9{5,20}|0{5,20})\d{0,2}(?:e(.+)|$)/.exec(t);if(n){var i=parseFloat("1e"+((n[2]?+n[2]:0)+n[1].length));t=(Math.round(e*i)/i).toString()}for(var r="",a=0,s=t.length;a<s;a+=1){var o=t[a];r+="e"===o?"-"===t[++a]?"c":"b":"."===o?"a":"-"===o?"e":o}for(var l=[30],h=0,u=(r+=1&r.length?"f":"ff").length;h<u;h+=2)l.push(parseInt(r.substr(h,2),16));return l},Qn.REAL=function(e){return tn.REAL(e).length},tn.NAME=tn.CHARARRAY,Qn.NAME=Qn.CHARARRAY,tn.STRING=tn.CHARARRAY,Qn.STRING=Qn.CHARARRAY,Qv.UTF8=function(e,t,n){for(var i=[],r=n,a=0;a<r;a++,t+=1)i[a]=e.getUint8(t);return String.fromCharCode.apply(null,i)},Qv.UTF16=function(e,t,n){for(var i=[],r=n/2,a=0;a<r;a++,t+=2)i[a]=e.getUint16(t);return String.fromCharCode.apply(null,i)},tn.UTF16=function(e){for(var t=[],n=0;n<e.length;n+=1){var i=e.charCodeAt(n);t[t.length]=i>>8&255,t[t.length]=255&i}return t},Qn.UTF16=function(e){return 2*e.length};var G5={"x-mac-croatian":"\xc4\xc5\xc7\xc9\xd1\xd6\xdc\xe1\xe0\xe2\xe4\xe3\xe5\xe7\xe9\xe8\xea\xeb\xed\xec\xee\xef\xf1\xf3\xf2\xf4\xf6\xf5\xfa\xf9\xfb\xfc\u2020\xb0\xa2\xa3\xa7\u2022\xb6\xdf\xae\u0160\u2122\xb4\xa8\u2260\u017d\xd8\u221e\xb1\u2264\u2265\u2206\xb5\u2202\u2211\u220f\u0161\u222b\xaa\xba\u03a9\u017e\xf8\xbf\xa1\xac\u221a\u0192\u2248\u0106\xab\u010c\u2026\xa0\xc0\xc3\xd5\u0152\u0153\u0110\u2014\u201c\u201d\u2018\u2019\xf7\u25ca\uf8ff\xa9\u2044\u20ac\u2039\u203a\xc6\xbb\u2013\xb7\u201a\u201e\u2030\xc2\u0107\xc1\u010d\xc8\xcd\xce\xcf\xcc\xd3\xd4\u0111\xd2\xda\xdb\xd9\u0131\u02c6\u02dc\xaf\u03c0\xcb\u02da\xb8\xca\xe6\u02c7","x-mac-cyrillic":"\u0410\u0411\u0412\u0413\u0414\u0415\u0416\u0417\u0418\u0419\u041a\u041b\u041c\u041d\u041e\u041f\u0420\u0421\u0422\u0423\u0424\u0425\u0426\u0427\u0428\u0429\u042a\u042b\u042c\u042d\u042e\u042f\u2020\xb0\u0490\xa3\xa7\u2022\xb6\u0406\xae\xa9\u2122\u0402\u0452\u2260\u0403\u0453\u221e\xb1\u2264\u2265\u0456\xb5\u0491\u0408\u0404\u0454\u0407\u0457\u0409\u0459\u040a\u045a\u0458\u0405\xac\u221a\u0192\u2248\u2206\xab\xbb\u2026\xa0\u040b\u045b\u040c\u045c\u0455\u2013\u2014\u201c\u201d\u2018\u2019\xf7\u201e\u040e\u045e\u040f\u045f\u2116\u0401\u0451\u044f\u0430\u0431\u0432\u0433\u0434\u0435\u0436\u0437\u0438\u0439\u043a\u043b\u043c\u043d\u043e\u043f\u0440\u0441\u0442\u0443\u0444\u0445\u0446\u0447\u0448\u0449\u044a\u044b\u044c\u044d\u044e","x-mac-gaelic":"\xc4\xc5\xc7\xc9\xd1\xd6\xdc\xe1\xe0\xe2\xe4\xe3\xe5\xe7\xe9\xe8\xea\xeb\xed\xec\xee\xef\xf1\xf3\xf2\xf4\xf6\xf5\xfa\xf9\xfb\xfc\u2020\xb0\xa2\xa3\xa7\u2022\xb6\xdf\xae\xa9\u2122\xb4\xa8\u2260\xc6\xd8\u1e02\xb1\u2264\u2265\u1e03\u010a\u010b\u1e0a\u1e0b\u1e1e\u1e1f\u0120\u0121\u1e40\xe6\xf8\u1e41\u1e56\u1e57\u027c\u0192\u017f\u1e60\xab\xbb\u2026\xa0\xc0\xc3\xd5\u0152\u0153\u2013\u2014\u201c\u201d\u2018\u2019\u1e61\u1e9b\xff\u0178\u1e6a\u20ac\u2039\u203a\u0176\u0177\u1e6b\xb7\u1ef2\u1ef3\u204a\xc2\xca\xc1\xcb\xc8\xcd\xce\xcf\xcc\xd3\xd4\u2663\xd2\xda\xdb\xd9\u0131\xdd\xfd\u0174\u0175\u1e84\u1e85\u1e80\u1e81\u1e82\u1e83","x-mac-greek":"\xc4\xb9\xb2\xc9\xb3\xd6\xdc\u0385\xe0\xe2\xe4\u0384\xa8\xe7\xe9\xe8\xea\xeb\xa3\u2122\xee\xef\u2022\xbd\u2030\xf4\xf6\xa6\u20ac\xf9\xfb\xfc\u2020\u0393\u0394\u0398\u039b\u039e\u03a0\xdf\xae\xa9\u03a3\u03aa\xa7\u2260\xb0\xb7\u0391\xb1\u2264\u2265\xa5\u0392\u0395\u0396\u0397\u0399\u039a\u039c\u03a6\u03ab\u03a8\u03a9\u03ac\u039d\xac\u039f\u03a1\u2248\u03a4\xab\xbb\u2026\xa0\u03a5\u03a7\u0386\u0388\u0153\u2013\u2015\u201c\u201d\u2018\u2019\xf7\u0389\u038a\u038c\u038e\u03ad\u03ae\u03af\u03cc\u038f\u03cd\u03b1\u03b2\u03c8\u03b4\u03b5\u03c6\u03b3\u03b7\u03b9\u03be\u03ba\u03bb\u03bc\u03bd\u03bf\u03c0\u03ce\u03c1\u03c3\u03c4\u03b8\u03c9\u03c2\u03c7\u03c5\u03b6\u03ca\u03cb\u0390\u03b0\xad","x-mac-icelandic":"\xc4\xc5\xc7\xc9\xd1\xd6\xdc\xe1\xe0\xe2\xe4\xe3\xe5\xe7\xe9\xe8\xea\xeb\xed\xec\xee\xef\xf1\xf3\xf2\xf4\xf6\xf5\xfa\xf9\xfb\xfc\xdd\xb0\xa2\xa3\xa7\u2022\xb6\xdf\xae\xa9\u2122\xb4\xa8\u2260\xc6\xd8\u221e\xb1\u2264\u2265\xa5\xb5\u2202\u2211\u220f\u03c0\u222b\xaa\xba\u03a9\xe6\xf8\xbf\xa1\xac\u221a\u0192\u2248\u2206\xab\xbb\u2026\xa0\xc0\xc3\xd5\u0152\u0153\u2013\u2014\u201c\u201d\u2018\u2019\xf7\u25ca\xff\u0178\u2044\u20ac\xd0\xf0\xde\xfe\xfd\xb7\u201a\u201e\u2030\xc2\xca\xc1\xcb\xc8\xcd\xce\xcf\xcc\xd3\xd4\uf8ff\xd2\xda\xdb\xd9\u0131\u02c6\u02dc\xaf\u02d8\u02d9\u02da\xb8\u02dd\u02db\u02c7","x-mac-inuit":"\u1403\u1404\u1405\u1406\u140a\u140b\u1431\u1432\u1433\u1434\u1438\u1439\u1449\u144e\u144f\u1450\u1451\u1455\u1456\u1466\u146d\u146e\u146f\u1470\u1472\u1473\u1483\u148b\u148c\u148d\u148e\u1490\u1491\xb0\u14a1\u14a5\u14a6\u2022\xb6\u14a7\xae\xa9\u2122\u14a8\u14aa\u14ab\u14bb\u14c2\u14c3\u14c4\u14c5\u14c7\u14c8\u14d0\u14ef\u14f0\u14f1\u14f2\u14f4\u14f5\u1505\u14d5\u14d6\u14d7\u14d8\u14da\u14db\u14ea\u1528\u1529\u152a\u152b\u152d\u2026\xa0\u152e\u153e\u1555\u1556\u1557\u2013\u2014\u201c\u201d\u2018\u2019\u1558\u1559\u155a\u155d\u1546\u1547\u1548\u1549\u154b\u154c\u1550\u157f\u1580\u1581\u1582\u1583\u1584\u1585\u158f\u1590\u1591\u1592\u1593\u1594\u1595\u1671\u1672\u1673\u1674\u1675\u1676\u1596\u15a0\u15a1\u15a2\u15a3\u15a4\u15a5\u15a6\u157c\u0141\u0142","x-mac-ce":"\xc4\u0100\u0101\xc9\u0104\xd6\xdc\xe1\u0105\u010c\xe4\u010d\u0106\u0107\xe9\u0179\u017a\u010e\xed\u010f\u0112\u0113\u0116\xf3\u0117\xf4\xf6\xf5\xfa\u011a\u011b\xfc\u2020\xb0\u0118\xa3\xa7\u2022\xb6\xdf\xae\xa9\u2122\u0119\xa8\u2260\u0123\u012e\u012f\u012a\u2264\u2265\u012b\u0136\u2202\u2211\u0142\u013b\u013c\u013d\u013e\u0139\u013a\u0145\u0146\u0143\xac\u221a\u0144\u0147\u2206\xab\xbb\u2026\xa0\u0148\u0150\xd5\u0151\u014c\u2013\u2014\u201c\u201d\u2018\u2019\xf7\u25ca\u014d\u0154\u0155\u0158\u2039\u203a\u0159\u0156\u0157\u0160\u201a\u201e\u0161\u015a\u015b\xc1\u0164\u0165\xcd\u017d\u017e\u016a\xd3\xd4\u016b\u016e\xda\u016f\u0170\u0171\u0172\u0173\xdd\xfd\u0137\u017b\u0141\u017c\u0122\u02c7",macintosh:"\xc4\xc5\xc7\xc9\xd1\xd6\xdc\xe1\xe0\xe2\xe4\xe3\xe5\xe7\xe9\xe8\xea\xeb\xed\xec\xee\xef\xf1\xf3\xf2\xf4\xf6\xf5\xfa\xf9\xfb\xfc\u2020\xb0\xa2\xa3\xa7\u2022\xb6\xdf\xae\xa9\u2122\xb4\xa8\u2260\xc6\xd8\u221e\xb1\u2264\u2265\xa5\xb5\u2202\u2211\u220f\u03c0\u222b\xaa\xba\u03a9\xe6\xf8\xbf\xa1\xac\u221a\u0192\u2248\u2206\xab\xbb\u2026\xa0\xc0\xc3\xd5\u0152\u0153\u2013\u2014\u201c\u201d\u2018\u2019\xf7\u25ca\xff\u0178\u2044\u20ac\u2039\u203a\ufb01\ufb02\u2021\xb7\u201a\u201e\u2030\xc2\xca\xc1\xcb\xc8\xcd\xce\xcf\xcc\xd3\xd4\uf8ff\xd2\xda\xdb\xd9\u0131\u02c6\u02dc\xaf\u02d8\u02d9\u02da\xb8\u02dd\u02db\u02c7","x-mac-romanian":"\xc4\xc5\xc7\xc9\xd1\xd6\xdc\xe1\xe0\xe2\xe4\xe3\xe5\xe7\xe9\xe8\xea\xeb\xed\xec\xee\xef\xf1\xf3\xf2\xf4\xf6\xf5\xfa\xf9\xfb\xfc\u2020\xb0\xa2\xa3\xa7\u2022\xb6\xdf\xae\xa9\u2122\xb4\xa8\u2260\u0102\u0218\u221e\xb1\u2264\u2265\xa5\xb5\u2202\u2211\u220f\u03c0\u222b\xaa\xba\u03a9\u0103\u0219\xbf\xa1\xac\u221a\u0192\u2248\u2206\xab\xbb\u2026\xa0\xc0\xc3\xd5\u0152\u0153\u2013\u2014\u201c\u201d\u2018\u2019\xf7\u25ca\xff\u0178\u2044\u20ac\u2039\u203a\u021a\u021b\u2021\xb7\u201a\u201e\u2030\xc2\xca\xc1\xcb\xc8\xcd\xce\xcf\xcc\xd3\xd4\uf8ff\xd2\xda\xdb\xd9\u0131\u02c6\u02dc\xaf\u02d8\u02d9\u02da\xb8\u02dd\u02db\u02c7","x-mac-turkish":"\xc4\xc5\xc7\xc9\xd1\xd6\xdc\xe1\xe0\xe2\xe4\xe3\xe5\xe7\xe9\xe8\xea\xeb\xed\xec\xee\xef\xf1\xf3\xf2\xf4\xf6\xf5\xfa\xf9\xfb\xfc\u2020\xb0\xa2\xa3\xa7\u2022\xb6\xdf\xae\xa9\u2122\xb4\xa8\u2260\xc6\xd8\u221e\xb1\u2264\u2265\xa5\xb5\u2202\u2211\u220f\u03c0\u222b\xaa\xba\u03a9\xe6\xf8\xbf\xa1\xac\u221a\u0192\u2248\u2206\xab\xbb\u2026\xa0\xc0\xc3\xd5\u0152\u0153\u2013\u2014\u201c\u201d\u2018\u2019\xf7\u25ca\xff\u0178\u011e\u011f\u0130\u0131\u015e\u015f\u2021\xb7\u201a\u201e\u2030\xc2\xca\xc1\xcb\xc8\xcd\xce\xcf\xcc\xd3\xd4\uf8ff\xd2\xda\xdb\xd9\uf8a0\u02c6\u02dc\xaf\u02d8\u02d9\u02da\xb8\u02dd\u02db\u02c7"};Qv.MACSTRING=function(e,t,n,i){var r=G5[i];if(void 0!==r){for(var a="",s=0;s<n;s++){var o=e.getUint8(t+s);a+=o<=127?String.fromCharCode(o):r[127&o]}return a}};var fC="function"==typeof WeakMap&&new WeakMap,pC,Ddt=function(e){if(!pC)for(var t in pC={},G5)pC[t]=new String(t);var n=pC[e];if(void 0!==n){if(fC){var i=fC.get(n);if(void 0!==i)return i}var r=G5[e];if(void 0!==r){for(var a={},s=0;s<r.length;s++)a[r.charCodeAt(s)]=s+128;return fC&&fC.set(n,a),a}}};function q5(e){return e>=-128&&e<=127}function Odt(e,t,n){for(var i=0,r=e.length;t<r&&i<64&&0===e[t];)++t,++i;return n.push(128|i-1),t}function kdt(e,t,n){for(var i=0,r=e.length,a=t;a<r&&i<64;){var s=e[a];if(!q5(s)||0===s&&a+1<r&&0===e[a+1])break;++a,++i}n.push(i-1);for(var o=t;o<a;++o)n.push(e[o]+256&255);return a}function Fdt(e,t,n){for(var i=0,r=e.length,a=t;a<r&&i<64;){var s=e[a];if(0===s||q5(s)&&a+1<r&&q5(e[a+1]))break;++a,++i}n.push(64|i-1);for(var o=t;o<a;++o){var l=e[o];n.push(l+65536>>8&255,l+256&255)}return a}tn.MACSTRING=function(e,t){var n=Ddt(t);if(void 0!==n){for(var i=[],r=0;r<e.length;r++){var a=e.charCodeAt(r);if(a>=128&&void 0===(a=n[a]))return;i[r]=a}return i}},Qn.MACSTRING=function(e,t){var n=tn.MACSTRING(e,t);return void 0!==n?n.length:0},tn.VARDELTAS=function(e){for(var t=0,n=[];t<e.length;){var i=e[t];t=0===i?Odt(e,t,n):i>=-128&&i<=127?kdt(e,t,n):Fdt(e,t,n)}return n},tn.INDEX=function(e){for(var t=1,n=[t],i=[],r=0;r<e.length;r+=1){var a=tn.OBJECT(e[r]);Array.prototype.push.apply(i,a),t+=a.length,n.push(t)}if(0===i.length)return[0,0];for(var s=[],o=1+Math.floor(Math.log(t)/Math.log(2))/8|0,l=[void 0,tn.BYTE,tn.USHORT,tn.UINT24,tn.ULONG][o],h=0;h<n.length;h+=1){var u=l(n[h]);Array.prototype.push.apply(s,u)}return Array.prototype.concat(tn.Card16(e.length),tn.OffSize(o),s,i)},Qn.INDEX=function(e){return tn.INDEX(e).length},tn.DICT=function(e){for(var t=[],n=Object.keys(e),i=n.length,r=0;r<i;r+=1){var a=parseInt(n[r],0),s=e[a];t=(t=t.concat(tn.OPERAND(s.value,s.type))).concat(tn.OPERATOR(a))}return t},Qn.DICT=function(e){return tn.DICT(e).length},tn.OPERATOR=function(e){return e<1200?[e]:[12,e-1200]},tn.OPERAND=function(e,t){var n=[];if(Array.isArray(t))for(var i=0;i<t.length;i+=1)Yn.argument(e.length===t.length,"Not enough arguments given for type"+t),n=n.concat(tn.OPERAND(e[i],t[i]));else if("SID"===t)n=n.concat(tn.NUMBER(e));else if("offset"===t)n=n.concat(tn.NUMBER32(e));else if("number"===t)n=n.concat(tn.NUMBER(e));else{if("real"!==t)throw new Error("Unknown operand type "+t);n=n.concat(tn.REAL(e))}return n},tn.OP=tn.BYTE,Qn.OP=Qn.BYTE;var mC="function"==typeof WeakMap&&new WeakMap;function Xs(e,t,n){if(t.length&&("coverageFormat"!==t[0].name||1===t[0].value))for(var i=0;i<t.length;i+=1){var r=t[i];this[r.name]=r.value}if(this.tableName=e,this.fields=t,n)for(var a=Object.keys(n),s=0;s<a.length;s+=1){var o=a[s],l=n[o];void 0!==this[o]&&(this[o]=l)}}function DE(e,t,n){void 0===n&&(n=t.length);var i=new Array(t.length+1);i[0]={name:e+"Count",type:"USHORT",value:n};for(var r=0;r<t.length;r++)i[r+1]={name:e+r,type:"USHORT",value:t[r]};return i}function W5(e,t,n){var i=t.length,r=new Array(i+1);r[0]={name:e+"Count",type:"USHORT",value:i};for(var a=0;a<i;a++)r[a+1]={name:e+a,type:"TABLE",value:n(t[a],a)};return r}function OE(e,t,n){var i=t.length,r=[];r[0]={name:e+"Count",type:"USHORT",value:i};for(var a=0;a<i;a++)r=r.concat(n(t[a],a));return r}function bC(e){1===e.format?Xs.call(this,"coverageTable",[{name:"coverageFormat",type:"USHORT",value:1}].concat(DE("glyph",e.glyphs))):2===e.format?Xs.call(this,"coverageTable",[{name:"coverageFormat",type:"USHORT",value:2}].concat(OE("rangeRecord",e.ranges,(function(e){return[{name:"startGlyphID",type:"USHORT",value:e.start},{name:"endGlyphID",type:"USHORT",value:e.end},{name:"startCoverageIndex",type:"USHORT",value:e.index}]})))):Yn.assert(!1,"Coverage format must be 1 or 2.")}function EC(e){Xs.call(this,"scriptListTable",OE("scriptRecord",e,(function(e,t){var n=e.script,i=n.defaultLangSys;return Yn.assert(!!i,"Unable to write GSUB: script "+e.tag+" has no default language system."),[{name:"scriptTag"+t,type:"TAG",value:e.tag},{name:"script"+t,type:"TABLE",value:new Xs("scriptTable",[{name:"defaultLangSys",type:"TABLE",value:new Xs("defaultLangSys",[{name:"lookupOrder",type:"USHORT",value:0},{name:"reqFeatureIndex",type:"USHORT",value:i.reqFeatureIndex}].concat(DE("featureIndex",i.featureIndexes)))}].concat(OE("langSys",n.langSysRecords,(function(e,t){var n=e.langSys;return[{name:"langSysTag"+t,type:"TAG",value:e.tag},{name:"langSys"+t,type:"TABLE",value:new Xs("langSys",[{name:"lookupOrder",type:"USHORT",value:0},{name:"reqFeatureIndex",type:"USHORT",value:n.reqFeatureIndex}].concat(DE("featureIndex",n.featureIndexes)))}]}))))}]})))}function _C(e){Xs.call(this,"featureListTable",OE("featureRecord",e,(function(e,t){var n=e.feature;return[{name:"featureTag"+t,type:"TAG",value:e.tag},{name:"feature"+t,type:"TABLE",value:new Xs("featureTable",[{name:"featureParams",type:"USHORT",value:n.featureParams}].concat(DE("lookupListIndex",n.lookupListIndexes)))}]})))}function TC(e,t){Xs.call(this,"lookupListTable",W5("lookup",e,(function(e){var n=t[e.lookupType];return Yn.assert(!!n,"Unable to write GSUB lookup type "+e.lookupType+" tables."),new Xs("lookupTable",[{name:"lookupType",type:"USHORT",value:e.lookupType},{name:"lookupFlag",type:"USHORT",value:e.lookupFlag}].concat(W5("subtable",e.subtables,n)))})))}tn.CHARSTRING=function(e){if(mC){var t=mC.get(e);if(void 0!==t)return t}for(var n=[],i=e.length,r=0;r<i;r+=1){var a=e[r];n=n.concat(tn[a.type](a.value))}return mC&&mC.set(e,n),n},Qn.CHARSTRING=function(e){return tn.CHARSTRING(e).length},tn.OBJECT=function(e){var t=tn[e.type];return Yn.argument(void 0!==t,"No encoding function for type "+e.type),t(e.value)},Qn.OBJECT=function(e){var t=Qn[e.type];return Yn.argument(void 0!==t,"No sizeOf function for type "+e.type),t(e.value)},tn.TABLE=function(e){for(var t=[],n=e.fields.length,i=[],r=[],a=0;a<n;a+=1){var s=e.fields[a],o=tn[s.type];Yn.argument(void 0!==o,"No encoding function for field type "+s.type+" ("+s.name+")");var l=e[s.name];void 0===l&&(l=s.value);var h=o(l);"TABLE"===s.type?(r.push(t.length),t=t.concat([0,0]),i.push(h)):t=t.concat(h)}for(var u=0;u<i.length;u+=1){var c=r[u],d=t.length;Yn.argument(d<65536,"Table "+e.tableName+" too big."),t[c]=d>>8,t[c+1]=255&d,t=t.concat(i[u])}return t},Qn.TABLE=function(e){for(var t=0,n=e.fields.length,i=0;i<n;i+=1){var r=e.fields[i],a=Qn[r.type];Yn.argument(void 0!==a,"No sizeOf function for field type "+r.type+" ("+r.name+")");var s=e[r.name];void 0===s&&(s=r.value),t+=a(s),"TABLE"===r.type&&(t+=2)}return t},tn.RECORD=tn.TABLE,Qn.RECORD=Qn.TABLE,tn.LITERAL=function(e){return e},Qn.LITERAL=function(e){return e.length},Xs.prototype.encode=function(){return tn.TABLE(this)},Xs.prototype.sizeOf=function(){return Qn.TABLE(this)},bC.prototype=Object.create(Xs.prototype),bC.prototype.constructor=bC,EC.prototype=Object.create(Xs.prototype),EC.prototype.constructor=EC,_C.prototype=Object.create(Xs.prototype),_C.prototype.constructor=_C,TC.prototype=Object.create(Xs.prototype),TC.prototype.constructor=TC;var dn={Table:Xs,Record:Xs,Coverage:bC,ScriptList:EC,FeatureList:_C,LookupList:TC,ushortList:DE,tableList:W5,recordList:OE};function Lme(e,t){return e.getUint8(t)}function wC(e,t){return e.getUint16(t,!1)}function Ndt(e,t){return e.getInt16(t,!1)}function e6(e,t){return e.getUint32(t,!1)}function yge(e,t){return e.getInt16(t,!1)+e.getUint16(t+2,!1)/65535}function Bdt(e,t){for(var n="",i=t;i<t+4;i+=1)n+=String.fromCharCode(e.getInt8(i));return n}function Udt(e,t,n){for(var i=0,r=0;r<n;r+=1)i<<=8,i+=e.getUint8(t+r);return i}function Hdt(e,t,n){for(var i=[],r=t;r<n;r+=1)i.push(e.getUint8(r));return i}function Vdt(e){for(var t="",n=0;n<e.length;n+=1)t+=String.fromCharCode(e[n]);return t}var zdt={byte:1,uShort:2,short:2,uLong:4,fixed:4,longDateTime:8,tag:4};function Et(e,t){this.data=e,this.offset=t,this.relativeOffset=0}Et.prototype.parseByte=function(){var e=this.data.getUint8(this.offset+this.relativeOffset);return this.relativeOffset+=1,e},Et.prototype.parseChar=function(){var e=this.data.getInt8(this.offset+this.relativeOffset);return this.relativeOffset+=1,e},Et.prototype.parseCard8=Et.prototype.parseByte,Et.prototype.parseUShort=function(){var e=this.data.getUint16(this.offset+this.relativeOffset);return this.relativeOffset+=2,e},Et.prototype.parseCard16=Et.prototype.parseUShort,Et.prototype.parseSID=Et.prototype.parseUShort,Et.prototype.parseOffset16=Et.prototype.parseUShort,Et.prototype.parseShort=function(){var e=this.data.getInt16(this.offset+this.relativeOffset);return this.relativeOffset+=2,e},Et.prototype.parseF2Dot14=function(){var e=this.data.getInt16(this.offset+this.relativeOffset)/16384;return this.relativeOffset+=2,e},Et.prototype.parseULong=function(){var e=e6(this.data,this.offset+this.relativeOffset);return this.relativeOffset+=4,e},Et.prototype.parseOffset32=Et.prototype.parseULong,Et.prototype.parseFixed=function(){var e=yge(this.data,this.offset+this.relativeOffset);return this.relativeOffset+=4,e},Et.prototype.parseString=function(e){var t=this.data,n=this.offset+this.relativeOffset,i="";this.relativeOffset+=e;for(var r=0;r<e;r++)i+=String.fromCharCode(t.getUint8(n+r));return i},Et.prototype.parseTag=function(){return this.parseString(4)},Et.prototype.parseLongDateTime=function(){var e=e6(this.data,this.offset+this.relativeOffset+4);return e-=2082844800,this.relativeOffset+=8,e},Et.prototype.parseVersion=function(e){var t=wC(this.data,this.offset+this.relativeOffset),n=wC(this.data,this.offset+this.relativeOffset+2);return this.relativeOffset+=4,void 0===e&&(e=4096),t+n/e/10},Et.prototype.skip=function(e,t){void 0===t&&(t=1),this.relativeOffset+=zdt[e]*t},Et.prototype.parseULongList=function(e){void 0===e&&(e=this.parseULong());for(var t=new Array(e),n=this.data,i=this.offset+this.relativeOffset,r=0;r<e;r++)t[r]=n.getUint32(i),i+=4;return this.relativeOffset+=4*e,t},Et.prototype.parseOffset16List=Et.prototype.parseUShortList=function(e){void 0===e&&(e=this.parseUShort());for(var t=new Array(e),n=this.data,i=this.offset+this.relativeOffset,r=0;r<e;r++)t[r]=n.getUint16(i),i+=2;return this.relativeOffset+=2*e,t},Et.prototype.parseShortList=function(e){for(var t=new Array(e),n=this.data,i=this.offset+this.relativeOffset,r=0;r<e;r++)t[r]=n.getInt16(i),i+=2;return this.relativeOffset+=2*e,t},Et.prototype.parseByteList=function(e){for(var t=new Array(e),n=this.data,i=this.offset+this.relativeOffset,r=0;r<e;r++)t[r]=n.getUint8(i++);return this.relativeOffset+=e,t},Et.prototype.parseList=function(e,t){t||(t=e,e=this.parseUShort());for(var n=new Array(e),i=0;i<e;i++)n[i]=t.call(this);return n},Et.prototype.parseList32=function(e,t){t||(t=e,e=this.parseULong());for(var n=new Array(e),i=0;i<e;i++)n[i]=t.call(this);return n},Et.prototype.parseRecordList=function(e,t){t||(t=e,e=this.parseUShort());for(var n=new Array(e),i=Object.keys(t),r=0;r<e;r++){for(var a={},s=0;s<i.length;s++){var o=i[s],l=t[o];a[o]=l.call(this)}n[r]=a}return n},Et.prototype.parseRecordList32=function(e,t){t||(t=e,e=this.parseULong());for(var n=new Array(e),i=Object.keys(t),r=0;r<e;r++){for(var a={},s=0;s<i.length;s++){var o=i[s],l=t[o];a[o]=l.call(this)}n[r]=a}return n},Et.prototype.parseStruct=function(e){if("function"==typeof e)return e.call(this);for(var t=Object.keys(e),n={},i=0;i<t.length;i++){var r=t[i],a=e[r];n[r]=a.call(this)}return n},Et.prototype.parseValueRecord=function(e){if(void 0===e&&(e=this.parseUShort()),0!==e){var t={};return 1&e&&(t.xPlacement=this.parseShort()),2&e&&(t.yPlacement=this.parseShort()),4&e&&(t.xAdvance=this.parseShort()),8&e&&(t.yAdvance=this.parseShort()),16&e&&(t.xPlaDevice=void 0,this.parseShort()),32&e&&(t.yPlaDevice=void 0,this.parseShort()),64&e&&(t.xAdvDevice=void 0,this.parseShort()),128&e&&(t.yAdvDevice=void 0,this.parseShort()),t}},Et.prototype.parseValueRecordList=function(){for(var e=this.parseUShort(),t=this.parseUShort(),n=new Array(t),i=0;i<t;i++)n[i]=this.parseValueRecord(e);return n},Et.prototype.parsePointer=function(e){var t=this.parseOffset16();if(t>0)return new Et(this.data,this.offset+t).parseStruct(e)},Et.prototype.parsePointer32=function(e){var t=this.parseOffset32();if(t>0)return new Et(this.data,this.offset+t).parseStruct(e)},Et.prototype.parseListOfLists=function(e){for(var t=this.parseOffset16List(),n=t.length,i=this.relativeOffset,r=new Array(n),a=0;a<n;a++){var s=t[a];if(0!==s)if(this.relativeOffset=s,e){for(var o=this.parseOffset16List(),l=new Array(o.length),h=0;h<o.length;h++)this.relativeOffset=s+o[h],l[h]=e.call(this);r[a]=l}else r[a]=this.parseUShortList();else r[a]=void 0}return this.relativeOffset=i,r},Et.prototype.parseCoverage=function(){var e=this.offset+this.relativeOffset,t=this.parseUShort(),n=this.parseUShort();if(1===t)return{format:1,glyphs:this.parseUShortList(n)};if(2===t){for(var i=new Array(n),r=0;r<n;r++)i[r]={start:this.parseUShort(),end:this.parseUShort(),index:this.parseUShort()};return{format:2,ranges:i}}throw new Error("0x"+e.toString(16)+": Coverage format must be 1 or 2.")},Et.prototype.parseClassDef=function(){var e=this.offset+this.relativeOffset,t=this.parseUShort();if(1===t)return{format:1,startGlyph:this.parseUShort(),classes:this.parseUShortList()};if(2===t)return{format:2,ranges:this.parseRecordList({start:Et.uShort,end:Et.uShort,classId:Et.uShort})};throw new Error("0x"+e.toString(16)+": ClassDef format must be 1 or 2.")},Et.list=function(e,t){return function(){return this.parseList(e,t)}},Et.list32=function(e,t){return function(){return this.parseList32(e,t)}},Et.recordList=function(e,t){return function(){return this.parseRecordList(e,t)}},Et.recordList32=function(e,t){return function(){return this.parseRecordList32(e,t)}},Et.pointer=function(e){return function(){return this.parsePointer(e)}},Et.pointer32=function(e){return function(){return this.parsePointer32(e)}},Et.tag=Et.prototype.parseTag,Et.byte=Et.prototype.parseByte,Et.uShort=Et.offset16=Et.prototype.parseUShort,Et.uShortList=Et.prototype.parseUShortList,Et.uLong=Et.offset32=Et.prototype.parseULong,Et.uLongList=Et.prototype.parseULongList,Et.struct=Et.prototype.parseStruct,Et.coverage=Et.prototype.parseCoverage,Et.classDef=Et.prototype.parseClassDef;var Dme={reserved:Et.uShort,reqFeatureIndex:Et.uShort,featureIndexes:Et.uShortList};Et.prototype.parseScriptList=function(){return this.parsePointer(Et.recordList({tag:Et.tag,script:Et.pointer({defaultLangSys:Et.pointer(Dme),langSysRecords:Et.recordList({tag:Et.tag,langSys:Et.pointer(Dme)})})}))||[]},Et.prototype.parseFeatureList=function(){return this.parsePointer(Et.recordList({tag:Et.tag,feature:Et.pointer({featureParams:Et.offset16,lookupListIndexes:Et.uShortList})}))||[]},Et.prototype.parseLookupList=function(e){return this.parsePointer(Et.list(Et.pointer((function(){var t=this.parseUShort();Yn.argument(1<=t&&t<=9,"GPOS/GSUB lookup type "+t+" unknown.");var n=this.parseUShort(),i=16&n;return{lookupType:t,lookupFlag:n,subtables:this.parseList(Et.pointer(e[t])),markFilteringSet:i?this.parseUShort():void 0}}))))||[]},Et.prototype.parseFeatureVariationsList=function(){return this.parsePointer32((function(){var e=this.parseUShort(),t=this.parseUShort();return Yn.argument(1===e&&t<1,"GPOS/GSUB feature variations table unknown."),this.parseRecordList32({conditionSetOffset:Et.offset32,featureTableSubstitutionOffset:Et.offset32})}))||[]};var _n={getByte:Lme,getCard8:Lme,getUShort:wC,getCard16:wC,getShort:Ndt,getULong:e6,getFixed:yge,getTag:Bdt,getOffset:Udt,getBytes:Hdt,bytesToString:Vdt,Parser:Et};function Gdt(e,t){var n;t.parseUShort(),e.length=t.parseULong(),e.language=t.parseULong(),e.groupCount=n=t.parseULong(),e.glyphIndexMap={};for(var i=0;i<n;i+=1)for(var r=t.parseULong(),a=t.parseULong(),s=t.parseULong(),o=r;o<=a;o+=1)e.glyphIndexMap[o]=s,s++}function qdt(e,t,n,i,r){var a;e.length=t.parseUShort(),e.language=t.parseUShort(),e.segCount=a=t.parseUShort()>>1,t.skip("uShort",3),e.glyphIndexMap={};for(var s=new _n.Parser(n,i+r+14),o=new _n.Parser(n,i+r+16+2*a),l=new _n.Parser(n,i+r+16+4*a),h=new _n.Parser(n,i+r+16+6*a),u=i+r+16+8*a,c=0;c<a-1;c+=1)for(var d=void 0,p=s.parseUShort(),f=o.parseUShort(),m=l.parseShort(),g=h.parseUShort(),v=f;v<=p;v+=1)0!==g?(u=h.offset+h.relativeOffset-2,u+=g,u+=2*(v-f),0!==(d=_n.getUShort(n,u))&&(d=d+m&65535)):d=v+m&65535,e.glyphIndexMap[v]=d}function Wdt(e,t){var n={};n.version=_n.getUShort(e,t),Yn.argument(0===n.version,"cmap table version should be 0."),n.numTables=_n.getUShort(e,t+2);for(var i=-1,r=n.numTables-1;r>=0;r-=1){var a=_n.getUShort(e,t+4+8*r),s=_n.getUShort(e,t+4+8*r+2);if(3===a&&(0===s||1===s||10===s)||0===a&&(0===s||1===s||2===s||3===s||4===s)){i=_n.getULong(e,t+4+8*r+4);break}}if(-1===i)throw new Error("No valid cmap sub-tables found.");var o=new _n.Parser(e,t+i);if(n.format=o.parseUShort(),12===n.format)Gdt(n,o);else{if(4!==n.format)throw new Error("Only format 4 and 12 cmap tables are supported (found format "+n.format+").");qdt(n,o,e,t,i)}return n}function jdt(e,t,n){e.segments.push({end:t,start:t,delta:-(t-n),offset:0,glyphIndex:n})}function Xdt(e){e.segments.push({end:65535,start:65535,delta:1,offset:0})}function Ydt(e){var t,n=!0;for(t=e.length-1;t>0;t-=1)if(e.get(t).unicode>65535){console.log("Adding CMAP format 12 (needed!)"),n=!1;break}var i=[{name:"version",type:"USHORT",value:0},{name:"numTables",type:"USHORT",value:n?1:2},{name:"platformID",type:"USHORT",value:3},{name:"encodingID",type:"USHORT",value:1},{name:"offset",type:"ULONG",value:n?12:20}];n||(i=i.concat([{name:"cmap12PlatformID",type:"USHORT",value:3},{name:"cmap12EncodingID",type:"USHORT",value:10},{name:"cmap12Offset",type:"ULONG",value:0}])),i=i.concat([{name:"format",type:"USHORT",value:4},{name:"cmap4Length",type:"USHORT",value:0},{name:"language",type:"USHORT",value:0},{name:"segCountX2",type:"USHORT",value:0},{name:"searchRange",type:"USHORT",value:0},{name:"entrySelector",type:"USHORT",value:0},{name:"rangeShift",type:"USHORT",value:0}]);var r=new dn.Table("cmap",i);for(r.segments=[],t=0;t<e.length;t+=1){for(var a=e.get(t),s=0;s<a.unicodes.length;s+=1)jdt(r,a.unicodes[s],t);r.segments=r.segments.sort((function(e,t){return e.start-t.start}))}Xdt(r);var o=r.segments.length,l=0,h=[],u=[],c=[],d=[],p=[],f=[];for(t=0;t<o;t+=1){var m=r.segments[t];m.end<=65535&&m.start<=65535?(h=h.concat({name:"end_"+t,type:"USHORT",value:m.end}),u=u.concat({name:"start_"+t,type:"USHORT",value:m.start}),c=c.concat({name:"idDelta_"+t,type:"SHORT",value:m.delta}),d=d.concat({name:"idRangeOffset_"+t,type:"USHORT",value:m.offset}),void 0!==m.glyphId&&(p=p.concat({name:"glyph_"+t,type:"USHORT",value:m.glyphId}))):l+=1,!n&&void 0!==m.glyphIndex&&(f=(f=(f=f.concat({name:"cmap12Start_"+t,type:"ULONG",value:m.start})).concat({name:"cmap12End_"+t,type:"ULONG",value:m.end})).concat({name:"cmap12Glyph_"+t,type:"ULONG",value:m.glyphIndex}))}if(r.segCountX2=2*(o-l),r.searchRange=2*Math.pow(2,Math.floor(Math.log(o-l)/Math.log(2))),r.entrySelector=Math.log(r.searchRange/2)/Math.log(2),r.rangeShift=r.segCountX2-r.searchRange,r.fields=r.fields.concat(h),r.fields.push({name:"reservedPad",type:"USHORT",value:0}),r.fields=r.fields.concat(u),r.fields=r.fields.concat(c),r.fields=r.fields.concat(d),r.fields=r.fields.concat(p),r.cmap4Length=14+2*h.length+2+2*u.length+2*c.length+2*d.length+2*p.length,!n){var g=16+4*f.length;r.cmap12Offset=20+r.cmap4Length,r.fields=r.fields.concat([{name:"cmap12Format",type:"USHORT",value:12},{name:"cmap12Reserved",type:"USHORT",value:0},{name:"cmap12Length",type:"ULONG",value:g},{name:"cmap12Language",type:"ULONG",value:0},{name:"cmap12nGroups",type:"ULONG",value:f.length/3}]),r.fields=r.fields.concat(f)}return r}var xge={parse:Wdt,make:Ydt},yC=[".notdef","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quoteright","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","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","bracketleft","backslash","bracketright","asciicircum","underscore","quoteleft","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","braceleft","bar","braceright","asciitilde","exclamdown","cent","sterling","fraction","yen","florin","section","currency","quotesingle","quotedblleft","guillemotleft","guilsinglleft","guilsinglright","fi","fl","endash","dagger","daggerdbl","periodcentered","paragraph","bullet","quotesinglbase","quotedblbase","quotedblright","guillemotright","ellipsis","perthousand","questiondown","grave","acute","circumflex","tilde","macron","breve","dotaccent","dieresis","ring","cedilla","hungarumlaut","ogonek","caron","emdash","AE","ordfeminine","Lslash","Oslash","OE","ordmasculine","ae","dotlessi","lslash","oslash","oe","germandbls","onesuperior","logicalnot","mu","trademark","Eth","onehalf","plusminus","Thorn","onequarter","divide","brokenbar","degree","thorn","threequarters","twosuperior","registered","minus","eth","multiply","threesuperior","copyright","Aacute","Acircumflex","Adieresis","Agrave","Aring","Atilde","Ccedilla","Eacute","Ecircumflex","Edieresis","Egrave","Iacute","Icircumflex","Idieresis","Igrave","Ntilde","Oacute","Ocircumflex","Odieresis","Ograve","Otilde","Scaron","Uacute","Ucircumflex","Udieresis","Ugrave","Yacute","Ydieresis","Zcaron","aacute","acircumflex","adieresis","agrave","aring","atilde","ccedilla","eacute","ecircumflex","edieresis","egrave","iacute","icircumflex","idieresis","igrave","ntilde","oacute","ocircumflex","odieresis","ograve","otilde","scaron","uacute","ucircumflex","udieresis","ugrave","yacute","ydieresis","zcaron","exclamsmall","Hungarumlautsmall","dollaroldstyle","dollarsuperior","ampersandsmall","Acutesmall","parenleftsuperior","parenrightsuperior","266 ff","onedotenleader","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","commasuperior","threequartersemdash","periodsuperior","questionsmall","asuperior","bsuperior","centsuperior","dsuperior","esuperior","isuperior","lsuperior","msuperior","nsuperior","osuperior","rsuperior","ssuperior","tsuperior","ff","ffi","ffl","parenleftinferior","parenrightinferior","Circumflexsmall","hyphensuperior","Gravesmall","Asmall","Bsmall","Csmall","Dsmall","Esmall","Fsmall","Gsmall","Hsmall","Ismall","Jsmall","Ksmall","Lsmall","Msmall","Nsmall","Osmall","Psmall","Qsmall","Rsmall","Ssmall","Tsmall","Usmall","Vsmall","Wsmall","Xsmall","Ysmall","Zsmall","colonmonetary","onefitted","rupiah","Tildesmall","exclamdownsmall","centoldstyle","Lslashsmall","Scaronsmall","Zcaronsmall","Dieresissmall","Brevesmall","Caronsmall","Dotaccentsmall","Macronsmall","figuredash","hypheninferior","Ogoneksmall","Ringsmall","Cedillasmall","questiondownsmall","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","zerosuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior","Agravesmall","Aacutesmall","Acircumflexsmall","Atildesmall","Adieresissmall","Aringsmall","AEsmall","Ccedillasmall","Egravesmall","Eacutesmall","Ecircumflexsmall","Edieresissmall","Igravesmall","Iacutesmall","Icircumflexsmall","Idieresissmall","Ethsmall","Ntildesmall","Ogravesmall","Oacutesmall","Ocircumflexsmall","Otildesmall","Odieresissmall","OEsmall","Oslashsmall","Ugravesmall","Uacutesmall","Ucircumflexsmall","Udieresissmall","Yacutesmall","Thornsmall","Ydieresissmall","001.000","001.001","001.002","001.003","Black","Bold","Book","Light","Medium","Regular","Roman","Semibold"],$dt=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quoteright","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","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","bracketleft","backslash","bracketright","asciicircum","underscore","quoteleft","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","braceleft","bar","braceright","asciitilde","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","exclamdown","cent","sterling","fraction","yen","florin","section","currency","quotesingle","quotedblleft","guillemotleft","guilsinglleft","guilsinglright","fi","fl","","endash","dagger","daggerdbl","periodcentered","","paragraph","bullet","quotesinglbase","quotedblbase","quotedblright","guillemotright","ellipsis","perthousand","","questiondown","","grave","acute","circumflex","tilde","macron","breve","dotaccent","dieresis","","ring","cedilla","","hungarumlaut","ogonek","caron","emdash","","","","","","","","","","","","","","","","","AE","","ordfeminine","","","","","Lslash","Oslash","OE","ordmasculine","","","","","","ae","","","","dotlessi","","","lslash","oslash","oe","germandbls"],Zdt=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","space","exclamsmall","Hungarumlautsmall","","dollaroldstyle","dollarsuperior","ampersandsmall","Acutesmall","parenleftsuperior","parenrightsuperior","twodotenleader","onedotenleader","comma","hyphen","period","fraction","zerooldstyle","oneoldstyle","twooldstyle","threeoldstyle","fouroldstyle","fiveoldstyle","sixoldstyle","sevenoldstyle","eightoldstyle","nineoldstyle","colon","semicolon","commasuperior","threequartersemdash","periodsuperior","questionsmall","","asuperior","bsuperior","centsuperior","dsuperior","esuperior","","","isuperior","","","lsuperior","msuperior","nsuperior","osuperior","","","rsuperior","ssuperior","tsuperior","","ff","fi","fl","ffi","ffl","parenleftinferior","","parenrightinferior","Circumflexsmall","hyphensuperior","Gravesmall","Asmall","Bsmall","Csmall","Dsmall","Esmall","Fsmall","Gsmall","Hsmall","Ismall","Jsmall","Ksmall","Lsmall","Msmall","Nsmall","Osmall","Psmall","Qsmall","Rsmall","Ssmall","Tsmall","Usmall","Vsmall","Wsmall","Xsmall","Ysmall","Zsmall","colonmonetary","onefitted","rupiah","Tildesmall","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","exclamdownsmall","centoldstyle","Lslashsmall","","","Scaronsmall","Zcaronsmall","Dieresissmall","Brevesmall","Caronsmall","","Dotaccentsmall","","","Macronsmall","","","figuredash","hypheninferior","","","Ogoneksmall","Ringsmall","Cedillasmall","","","","onequarter","onehalf","threequarters","questiondownsmall","oneeighth","threeeighths","fiveeighths","seveneighths","onethird","twothirds","","","zerosuperior","onesuperior","twosuperior","threesuperior","foursuperior","fivesuperior","sixsuperior","sevensuperior","eightsuperior","ninesuperior","zeroinferior","oneinferior","twoinferior","threeinferior","fourinferior","fiveinferior","sixinferior","seveninferior","eightinferior","nineinferior","centinferior","dollarinferior","periodinferior","commainferior","Agravesmall","Aacutesmall","Acircumflexsmall","Atildesmall","Adieresissmall","Aringsmall","AEsmall","Ccedillasmall","Egravesmall","Eacutesmall","Ecircumflexsmall","Edieresissmall","Igravesmall","Iacutesmall","Icircumflexsmall","Idieresissmall","Ethsmall","Ntildesmall","Ogravesmall","Oacutesmall","Ocircumflexsmall","Otildesmall","Odieresissmall","OEsmall","Oslashsmall","Ugravesmall","Uacutesmall","Ucircumflexsmall","Udieresissmall","Yacutesmall","Thornsmall","Ydieresissmall"],Um=[".notdef",".null","nonmarkingreturn","space","exclam","quotedbl","numbersign","dollar","percent","ampersand","quotesingle","parenleft","parenright","asterisk","plus","comma","hyphen","period","slash","zero","one","two","three","four","five","six","seven","eight","nine","colon","semicolon","less","equal","greater","question","at","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","bracketleft","backslash","bracketright","asciicircum","underscore","grave","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","braceleft","bar","braceright","asciitilde","Adieresis","Aring","Ccedilla","Eacute","Ntilde","Odieresis","Udieresis","aacute","agrave","acircumflex","adieresis","atilde","aring","ccedilla","eacute","egrave","ecircumflex","edieresis","iacute","igrave","icircumflex","idieresis","ntilde","oacute","ograve","ocircumflex","odieresis","otilde","uacute","ugrave","ucircumflex","udieresis","dagger","degree","cent","sterling","section","bullet","paragraph","germandbls","registered","copyright","trademark","acute","dieresis","notequal","AE","Oslash","infinity","plusminus","lessequal","greaterequal","yen","mu","partialdiff","summation","product","pi","integral","ordfeminine","ordmasculine","Omega","ae","oslash","questiondown","exclamdown","logicalnot","radical","florin","approxequal","Delta","guillemotleft","guillemotright","ellipsis","nonbreakingspace","Agrave","Atilde","Otilde","OE","oe","endash","emdash","quotedblleft","quotedblright","quoteleft","quoteright","divide","lozenge","ydieresis","Ydieresis","fraction","currency","guilsinglleft","guilsinglright","fi","fl","daggerdbl","periodcentered","quotesinglbase","quotedblbase","perthousand","Acircumflex","Ecircumflex","Aacute","Edieresis","Egrave","Iacute","Icircumflex","Idieresis","Igrave","Oacute","Ocircumflex","apple","Ograve","Uacute","Ucircumflex","Ugrave","dotlessi","circumflex","tilde","macron","breve","dotaccent","ring","cedilla","hungarumlaut","ogonek","caron","Lslash","lslash","Scaron","scaron","Zcaron","zcaron","brokenbar","Eth","eth","Yacute","yacute","Thorn","thorn","minus","multiply","onesuperior","twosuperior","threesuperior","onehalf","onequarter","threequarters","franc","Gbreve","gbreve","Idotaccent","Scedilla","scedilla","Cacute","cacute","Ccaron","ccaron","dcroat"];function bge(e){this.font=e}function Ege(e){this.cmap=e}function SC(e,t){this.encoding=e,this.charset=t}function t6(e){switch(e.version){case 1:this.names=Um.slice();break;case 2:this.names=new Array(e.numberOfGlyphs);for(var t=0;t<e.numberOfGlyphs;t++)e.glyphNameIndex[t]<Um.length?this.names[t]=Um[e.glyphNameIndex[t]]:this.names[t]=e.names[e.glyphNameIndex[t]-Um.length];break;case 2.5:this.names=new Array(e.numberOfGlyphs);for(var n=0;n<e.numberOfGlyphs;n++)this.names[n]=Um[n+e.glyphNameIndex[n]];break;default:this.names=[]}}function Kdt(e){for(var t,n=e.tables.cmap.glyphIndexMap,i=Object.keys(n),r=0;r<i.length;r+=1){var a=i[r],s=n[a];(t=e.glyphs.get(s)).addUnicode(parseInt(a))}for(var o=0;o<e.glyphs.length;o+=1)t=e.glyphs.get(o),e.cffEncoding?e.isCIDFont?t.name="gid"+o:t.name=e.cffEncoding.charset[o]:e.glyphNames.names&&(t.name=e.glyphNames.glyphIndexToName(o))}function Jdt(e){e._IndexToUnicodeMap={};for(var t=e.tables.cmap.glyphIndexMap,n=Object.keys(t),i=0;i<n.length;i+=1){var r=n[i],a=t[r];void 0===e._IndexToUnicodeMap[a]?e._IndexToUnicodeMap[a]={unicodes:[parseInt(r)]}:e._IndexToUnicodeMap[a].unicodes.push(parseInt(r))}}function Qdt(e,t){t.lowMemory?Jdt(e):Kdt(e)}function eft(e,t,n,i,r){e.beginPath(),e.moveTo(t,n),e.lineTo(i,r),e.stroke()}bge.prototype.charToGlyphIndex=function(e){var t=e.codePointAt(0),n=this.font.glyphs;if(n)for(var i=0;i<n.length;i+=1)for(var r=n.get(i),a=0;a<r.unicodes.length;a+=1)if(r.unicodes[a]===t)return i;return null},Ege.prototype.charToGlyphIndex=function(e){return this.cmap.glyphIndexMap[e.codePointAt(0)]||0},SC.prototype.charToGlyphIndex=function(e){var t=e.codePointAt(0),n=this.encoding[t];return this.charset.indexOf(n)},t6.prototype.nameToGlyphIndex=function(e){return this.names.indexOf(e)},t6.prototype.glyphIndexToName=function(e){return this.names[e]};var Bm={line:eft};function tft(e,t){var n=t||new ks;return{configurable:!0,get:function(){return"function"==typeof n&&(n=n()),n},set:function(e){n=e}}}function Hl(e){this.bindConstructorValues(e)}function gC(e,t,n){Object.defineProperty(e,t,{get:function(){return e.path,e[n]},set:function(t){e[n]=t},enumerable:!0,configurable:!0})}function n6(e,t){if(this.font=e,this.glyphs={},Array.isArray(t))for(var n=0;n<t.length;n++){var i=t[n];i.path.unitsPerEm=e.unitsPerEm,this.glyphs[n]=i}this.length=t&&t.length||0}function nft(e,t){return new Hl({index:t,font:e})}function rft(e,t,n,i,r,a){return function(){var s=new Hl({index:t,font:e});return s.path=function(){n(s,i,r);var t=a(e.glyphs,s);return t.unitsPerEm=e.unitsPerEm,t},gC(s,"xMin","_xMin"),gC(s,"xMax","_xMax"),gC(s,"yMin","_yMin"),gC(s,"yMax","_yMax"),s}}function ift(e,t,n,i){return function(){var r=new Hl({index:t,font:e});return r.path=function(){var t=n(e,r,i);return t.unitsPerEm=e.unitsPerEm,t},r}}Hl.prototype.bindConstructorValues=function(e){this.index=e.index||0,this.name=e.name||null,this.unicode=e.unicode||void 0,this.unicodes=e.unicodes||void 0!==e.unicode?[e.unicode]:[],"xMin"in e&&(this.xMin=e.xMin),"yMin"in e&&(this.yMin=e.yMin),"xMax"in e&&(this.xMax=e.xMax),"yMax"in e&&(this.yMax=e.yMax),"advanceWidth"in e&&(this.advanceWidth=e.advanceWidth),Object.defineProperty(this,"path",tft(this,e.path))},Hl.prototype.addUnicode=function(e){0===this.unicodes.length&&(this.unicode=e),this.unicodes.push(e)},Hl.prototype.getBoundingBox=function(){return this.path.getBoundingBox()},Hl.prototype.getPath=function(e,t,n,i,r){var a,s;e=void 0!==e?e:0,t=void 0!==t?t:0,n=void 0!==n?n:72,i||(i={});var o=i.xScale,l=i.yScale;if(i.hinting&&r&&r.hinting&&(s=this.path&&r.hinting.exec(this,n)),s)a=r.hinting.getCommands(s),e=Math.round(e),t=Math.round(t),o=l=1;else{a=this.path.commands;var h=1/(this.path.unitsPerEm||1e3)*n;void 0===o&&(o=h),void 0===l&&(l=h)}for(var u=new ks,c=0;c<a.length;c+=1){var d=a[c];"M"===d.type?u.moveTo(e+d.x*o,t+-d.y*l):"L"===d.type?u.lineTo(e+d.x*o,t+-d.y*l):"Q"===d.type?u.quadraticCurveTo(e+d.x1*o,t+-d.y1*l,e+d.x*o,t+-d.y*l):"C"===d.type?u.curveTo(e+d.x1*o,t+-d.y1*l,e+d.x2*o,t+-d.y2*l,e+d.x*o,t+-d.y*l):"Z"===d.type&&u.closePath()}return u},Hl.prototype.getContours=function(){if(void 0===this.points)return[];for(var e=[],t=[],n=0;n<this.points.length;n+=1){var i=this.points[n];t.push(i),i.lastPointOfContour&&(e.push(t),t=[])}return Yn.argument(0===t.length,"There are still points left in the current contour."),e},Hl.prototype.getMetrics=function(){for(var e=this.path.commands,t=[],n=[],i=0;i<e.length;i+=1){var r=e[i];"Z"!==r.type&&(t.push(r.x),n.push(r.y)),("Q"===r.type||"C"===r.type)&&(t.push(r.x1),n.push(r.y1)),"C"===r.type&&(t.push(r.x2),n.push(r.y2))}var a={xMin:Math.min.apply(null,t),yMin:Math.min.apply(null,n),xMax:Math.max.apply(null,t),yMax:Math.max.apply(null,n),leftSideBearing:this.leftSideBearing};return isFinite(a.xMin)||(a.xMin=0),isFinite(a.xMax)||(a.xMax=this.advanceWidth),isFinite(a.yMin)||(a.yMin=0),isFinite(a.yMax)||(a.yMax=0),a.rightSideBearing=this.advanceWidth-a.leftSideBearing-(a.xMax-a.xMin),a},Hl.prototype.draw=function(e,t,n,i,r){this.getPath(t,n,i,r).draw(e)},Hl.prototype.drawPoints=function(e,t,n,i){function r(t,n,i,r){e.beginPath();for(var a=0;a<t.length;a+=1)e.moveTo(n+t[a].x*r,i+t[a].y*r),e.arc(n+t[a].x*r,i+t[a].y*r,2,0,2*Math.PI,!1);e.closePath(),e.fill()}t=void 0!==t?t:0,n=void 0!==n?n:0,i=void 0!==i?i:24;for(var a=1/this.path.unitsPerEm*i,s=[],o=[],l=this.path,h=0;h<l.commands.length;h+=1){var u=l.commands[h];void 0!==u.x&&s.push({x:u.x,y:-u.y}),void 0!==u.x1&&o.push({x:u.x1,y:-u.y1}),void 0!==u.x2&&o.push({x:u.x2,y:-u.y2})}e.fillStyle="blue",r(s,t,n,a),e.fillStyle="red",r(o,t,n,a)},Hl.prototype.drawMetrics=function(e,t,n,i){var r;t=void 0!==t?t:0,n=void 0!==n?n:0,i=void 0!==i?i:24,r=1/this.path.unitsPerEm*i,e.lineWidth=1,e.strokeStyle="black",Bm.line(e,t,-1e4,t,1e4),Bm.line(e,-1e4,n,1e4,n);var a=this.xMin||0,s=this.yMin||0,o=this.xMax||0,l=this.yMax||0,h=this.advanceWidth||0;e.strokeStyle="blue",Bm.line(e,t+a*r,-1e4,t+a*r,1e4),Bm.line(e,t+o*r,-1e4,t+o*r,1e4),Bm.line(e,-1e4,n+-s*r,1e4,n+-s*r),Bm.line(e,-1e4,n+-l*r,1e4,n+-l*r),e.strokeStyle="green",Bm.line(e,t+h*r,-1e4,t+h*r,1e4)},n6.prototype.get=function(e){if(void 0===this.glyphs[e]){this.font._push(e),"function"==typeof this.glyphs[e]&&(this.glyphs[e]=this.glyphs[e]());var t=this.glyphs[e],n=this.font._IndexToUnicodeMap[e];if(n)for(var i=0;i<n.unicodes.length;i++)t.addUnicode(n.unicodes[i]);this.font.cffEncoding?this.font.isCIDFont?t.name="gid"+e:t.name=this.font.cffEncoding.charset[e]:this.font.glyphNames.names&&(t.name=this.font.glyphNames.glyphIndexToName(e)),this.glyphs[e].advanceWidth=this.font._hmtxTableData[e].advanceWidth,this.glyphs[e].leftSideBearing=this.font._hmtxTableData[e].leftSideBearing}else"function"==typeof this.glyphs[e]&&(this.glyphs[e]=this.glyphs[e]());return this.glyphs[e]},n6.prototype.push=function(e,t){this.glyphs[e]=t,this.length++};var Uu={GlyphSet:n6,glyphLoader:nft,ttfGlyphLoader:rft,cffGlyphLoader:ift};function _ge(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(var n=0;n<e.length;n+=1)if(!_ge(e[n],t[n]))return!1;return!0}return!1}function j5(e){return e.length<1240?107:e.length<33900?1131:32768}function wf(e,t,n){var i,r,a=[],s=[],o=_n.getCard16(e,t);if(0!==o){var l=_n.getByte(e,t+2);i=t+(o+1)*l+2;for(var h=t+3,u=0;u<o+1;u+=1)a.push(_n.getOffset(e,h,l)),h+=l;r=i+a[o]}else r=t+2;for(var c=0;c<a.length-1;c+=1){var d=_n.getBytes(e,i+a[c],i+a[c+1]);n&&(d=n(d)),s.push(d)}return{objects:s,startOffset:t,endOffset:r}}function sft(e,t){var n,i,r=[],a=_n.getCard16(e,t);if(0!==a){var s=_n.getByte(e,t+2);n=t+(a+1)*s+2;for(var o=t+3,l=0;l<a+1;l+=1)r.push(_n.getOffset(e,o,s)),o+=s;i=n+r[a]}else i=t+2;return{offsets:r,startOffset:t,endOffset:i}}function aft(e,t,n,i,r){var a=_n.getCard16(n,i),s=0;0!==a&&(s=i+(a+1)*_n.getByte(n,i+2)+2);var o=_n.getBytes(n,s+t[e],s+t[e+1]);return r&&(o=r(o)),o}function oft(e){for(var t="",n=["0","1","2","3","4","5","6","7","8","9",".","E","E-",null,"-"];;){var i=e.parseByte(),r=i>>4,a=15&i;if(15===r||(t+=n[r],15===a))break;t+=n[a]}return parseFloat(t)}function lft(e,t){if(28===t)return e.parseByte()<<8|e.parseByte();if(29===t)return e.parseByte()<<24|e.parseByte()<<16|e.parseByte()<<8|e.parseByte();if(30===t)return oft(e);if(t>=32&&t<=246)return t-139;if(t>=247&&t<=250)return 256*(t-247)+e.parseByte()+108;if(t>=251&&t<=254)return 256*-(t-251)-e.parseByte()-108;throw new Error("Invalid b0 "+t)}function cft(e){for(var t={},n=0;n<e.length;n+=1){var i,r=e[n][0],a=e[n][1];if(i=1===a.length?a[0]:a,t.hasOwnProperty(r)&&!isNaN(t[r]))throw new Error("Object "+t+" already has key "+r);t[r]=i}return t}function Tge(e,t,n){t=void 0!==t?t:0;var i=new _n.Parser(e,t),r=[],a=[];for(n=void 0!==n?n:e.length;i.relativeOffset<n;){var s=i.parseByte();s<=21?(12===s&&(s=1200+i.parseByte()),r.push([s,a]),a=[]):a.push(lft(i,s))}return cft(r)}function IE(e,t){return t<=390?yC[t]:e[t-391]}function wge(e,t,n){for(var i,r={},a=0;a<t.length;a+=1){var s=t[a];if(Array.isArray(s.type)){var o=[];o.length=s.type.length;for(var l=0;l<s.type.length;l++)void 0===(i=void 0!==e[s.op]?e[s.op][l]:void 0)&&(i=void 0!==s.value&&void 0!==s.value[l]?s.value[l]:null),"SID"===s.type[l]&&(i=IE(n,i)),o[l]=i;r[s.name]=o}else void 0===(i=e[s.op])&&(i=void 0!==s.value?s.value:null),"SID"===s.type&&(i=IE(n,i)),r[s.name]=i}return r}function uft(e,t){var n={};return n.formatMajor=_n.getCard8(e,t),n.formatMinor=_n.getCard8(e,t+1),n.size=_n.getCard8(e,t+2),n.offsetSize=_n.getCard8(e,t+3),n.startOffset=t,n.endOffset=t+4,n}var Sge=[{name:"version",op:0,type:"SID"},{name:"notice",op:1,type:"SID"},{name:"copyright",op:1200,type:"SID"},{name:"fullName",op:2,type:"SID"},{name:"familyName",op:3,type:"SID"},{name:"weight",op:4,type:"SID"},{name:"isFixedPitch",op:1201,type:"number",value:0},{name:"italicAngle",op:1202,type:"number",value:0},{name:"underlinePosition",op:1203,type:"number",value:-100},{name:"underlineThickness",op:1204,type:"number",value:50},{name:"paintType",op:1205,type:"number",value:0},{name:"charstringType",op:1206,type:"number",value:2},{name:"fontMatrix",op:1207,type:["real","real","real","real","real","real"],value:[.001,0,0,.001,0,0]},{name:"uniqueId",op:13,type:"number"},{name:"fontBBox",op:5,type:["number","number","number","number"],value:[0,0,0,0]},{name:"strokeWidth",op:1208,type:"number",value:0},{name:"xuid",op:14,type:[],value:null},{name:"charset",op:15,type:"offset",value:0},{name:"encoding",op:16,type:"offset",value:0},{name:"charStrings",op:17,type:"offset",value:0},{name:"private",op:18,type:["number","offset"],value:[0,0]},{name:"ros",op:1230,type:["SID","SID","number"]},{name:"cidFontVersion",op:1231,type:"number",value:0},{name:"cidFontRevision",op:1232,type:"number",value:0},{name:"cidFontType",op:1233,type:"number",value:0},{name:"cidCount",op:1234,type:"number",value:8720},{name:"uidBase",op:1235,type:"number"},{name:"fdArray",op:1236,type:"offset"},{name:"fdSelect",op:1237,type:"offset"},{name:"fontName",op:1238,type:"SID"}],Mge=[{name:"subrs",op:19,type:"offset",value:0},{name:"defaultWidthX",op:20,type:"number",value:0},{name:"nominalWidthX",op:21,type:"number",value:0}];function hft(e,t){return wge(Tge(e,0,e.byteLength),Sge,t)}function Age(e,t,n,i){return wge(Tge(e,t,n),Mge,i)}function Ome(e,t,n,i){for(var r=[],a=0;a<n.length;a+=1){var s=hft(new DataView(new Uint8Array(n[a]).buffer),i);s._subrs=[],s._subrsBias=0,s._defaultWidthX=0,s._nominalWidthX=0;var o=s.private[0],l=s.private[1];if(0!==o&&0!==l){var h=Age(e,l+t,o,i);if(s._defaultWidthX=h.defaultWidthX,s._nominalWidthX=h.nominalWidthX,0!==h.subrs){var u=wf(e,l+h.subrs+t);s._subrs=u.objects,s._subrsBias=j5(s._subrs)}s._privateDict=h}r.push(s)}return r}function dft(e,t,n,i){var r,a,s=new _n.Parser(e,t);n-=1;var o=[".notdef"],l=s.parseCard8();if(0===l)for(var h=0;h<n;h+=1)r=s.parseSID(),o.push(IE(i,r));else if(1===l)for(;o.length<=n;){r=s.parseSID(),a=s.parseCard8();for(var u=0;u<=a;u+=1)o.push(IE(i,r)),r+=1}else{if(2!==l)throw new Error("Unknown charset format "+l);for(;o.length<=n;){r=s.parseSID(),a=s.parseCard16();for(var c=0;c<=a;c+=1)o.push(IE(i,r)),r+=1}}return o}function fft(e,t,n){var i,r={},a=new _n.Parser(e,t),s=a.parseCard8();if(0===s)for(var o=a.parseCard8(),l=0;l<o;l+=1)r[i=a.parseCard8()]=l;else{if(1!==s)throw new Error("Unknown encoding format "+s);var h=a.parseCard8();i=1;for(var u=0;u<h;u+=1)for(var c=a.parseCard8(),d=a.parseCard8(),p=c;p<=c+d;p+=1)r[p]=i,i+=1}return new SC(r,n)}function kme(e,t,n){var i,r,a,s,o,l,h,u,c=new ks,d=[],p=0,f=!1,m=!1,g=0,v=0;if(e.isCIDFont){var y=e.tables.cff.topDict._fdSelect[t.index],x=e.tables.cff.topDict._fdArray[y];o=x._subrs,l=x._subrsBias,h=x._defaultWidthX,u=x._nominalWidthX}else o=e.tables.cff.topDict._subrs,l=e.tables.cff.topDict._subrsBias,h=e.tables.cff.topDict._defaultWidthX,u=e.tables.cff.topDict._nominalWidthX;var b=h;function _(e,t){m&&c.closePath(),c.moveTo(e,t),m=!0}function w(){d.length%2!=0&&!f&&(b=d.shift()+u),p+=d.length>>1,d.length=0,f=!0}return function n(h){for(var y,x,S,M,E,T,A,C,P,R,L,I,k=0;k<h.length;){var O=h[k];switch(k+=1,O){case 1:case 3:case 18:case 23:w();break;case 4:d.length>1&&!f&&(b=d.shift()+u,f=!0),v+=d.pop(),_(g,v);break;case 5:for(;d.length>0;)g+=d.shift(),v+=d.shift(),c.lineTo(g,v);break;case 6:for(;d.length>0&&(g+=d.shift(),c.lineTo(g,v),0!==d.length);)v+=d.shift(),c.lineTo(g,v);break;case 7:for(;d.length>0&&(v+=d.shift(),c.lineTo(g,v),0!==d.length);)g+=d.shift(),c.lineTo(g,v);break;case 8:for(;d.length>0;)i=g+d.shift(),r=v+d.shift(),a=i+d.shift(),s=r+d.shift(),g=a+d.shift(),v=s+d.shift(),c.curveTo(i,r,a,s,g,v);break;case 10:E=d.pop()+l,(T=o[E])&&n(T);break;case 11:return;case 12:switch(O=h[k],k+=1,O){case 35:i=g+d.shift(),r=v+d.shift(),a=i+d.shift(),s=r+d.shift(),A=a+d.shift(),C=s+d.shift(),P=A+d.shift(),R=C+d.shift(),L=P+d.shift(),I=R+d.shift(),g=L+d.shift(),v=I+d.shift(),d.shift(),c.curveTo(i,r,a,s,A,C),c.curveTo(P,R,L,I,g,v);break;case 34:i=g+d.shift(),r=v,a=i+d.shift(),s=r+d.shift(),A=a+d.shift(),C=s,P=A+d.shift(),R=s,L=P+d.shift(),I=v,g=L+d.shift(),c.curveTo(i,r,a,s,A,C),c.curveTo(P,R,L,I,g,v);break;case 36:i=g+d.shift(),r=v+d.shift(),a=i+d.shift(),s=r+d.shift(),A=a+d.shift(),C=s,P=A+d.shift(),R=s,L=P+d.shift(),I=R+d.shift(),g=L+d.shift(),c.curveTo(i,r,a,s,A,C),c.curveTo(P,R,L,I,g,v);break;case 37:i=g+d.shift(),r=v+d.shift(),a=i+d.shift(),s=r+d.shift(),A=a+d.shift(),C=s+d.shift(),P=A+d.shift(),R=C+d.shift(),L=P+d.shift(),I=R+d.shift(),Math.abs(L-g)>Math.abs(I-v)?g=L+d.shift():v=I+d.shift(),c.curveTo(i,r,a,s,A,C),c.curveTo(P,R,L,I,g,v);break;default:console.log("Glyph "+t.index+": unknown operator 1200"+O),d.length=0}break;case 14:d.length>0&&!f&&(b=d.shift()+u,f=!0),m&&(c.closePath(),m=!1);break;case 19:case 20:w(),k+=p+7>>3;break;case 21:d.length>2&&!f&&(b=d.shift()+u,f=!0),v+=d.pop(),_(g+=d.pop(),v);break;case 22:d.length>1&&!f&&(b=d.shift()+u,f=!0),_(g+=d.pop(),v);break;case 24:for(;d.length>2;)i=g+d.shift(),r=v+d.shift(),a=i+d.shift(),s=r+d.shift(),g=a+d.shift(),v=s+d.shift(),c.curveTo(i,r,a,s,g,v);g+=d.shift(),v+=d.shift(),c.lineTo(g,v);break;case 25:for(;d.length>6;)g+=d.shift(),v+=d.shift(),c.lineTo(g,v);i=g+d.shift(),r=v+d.shift(),a=i+d.shift(),s=r+d.shift(),g=a+d.shift(),v=s+d.shift(),c.curveTo(i,r,a,s,g,v);break;case 26:for(d.length%2&&(g+=d.shift());d.length>0;)i=g,r=v+d.shift(),a=i+d.shift(),s=r+d.shift(),g=a,v=s+d.shift(),c.curveTo(i,r,a,s,g,v);break;case 27:for(d.length%2&&(v+=d.shift());d.length>0;)i=g+d.shift(),r=v,a=i+d.shift(),s=r+d.shift(),g=a+d.shift(),v=s,c.curveTo(i,r,a,s,g,v);break;case 28:y=h[k],x=h[k+1],d.push((y<<24|x<<16)>>16),k+=2;break;case 29:E=d.pop()+e.gsubrsBias,(T=e.gsubrs[E])&&n(T);break;case 30:for(;d.length>0&&(i=g,r=v+d.shift(),a=i+d.shift(),s=r+d.shift(),g=a+d.shift(),v=s+(1===d.length?d.shift():0),c.curveTo(i,r,a,s,g,v),0!==d.length);)i=g+d.shift(),r=v,a=i+d.shift(),s=r+d.shift(),v=s+d.shift(),g=a+(1===d.length?d.shift():0),c.curveTo(i,r,a,s,g,v);break;case 31:for(;d.length>0&&(i=g+d.shift(),r=v,a=i+d.shift(),s=r+d.shift(),v=s+d.shift(),g=a+(1===d.length?d.shift():0),c.curveTo(i,r,a,s,g,v),0!==d.length);)i=g,r=v+d.shift(),a=i+d.shift(),s=r+d.shift(),g=a+d.shift(),v=s+(1===d.length?d.shift():0),c.curveTo(i,r,a,s,g,v);break;default:O<32?console.log("Glyph "+t.index+": unknown operator "+O):O<247?d.push(O-139):O<251?(y=h[k],k+=1,d.push(256*(O-247)+y+108)):O<255?(y=h[k],k+=1,d.push(256*-(O-251)-y-108)):(y=h[k],x=h[k+1],S=h[k+2],M=h[k+3],k+=4,d.push((y<<24|x<<16|S<<8|M)/65536))}}}(n),t.advanceWidth=b,c}function pft(e,t,n,i){var r,a=[],s=new _n.Parser(e,t),o=s.parseCard8();if(0===o)for(var l=0;l<n;l++){if((r=s.parseCard8())>=i)throw new Error("CFF table CID Font FDSelect has bad FD index value "+r+" (FD count "+i+")");a.push(r)}else{if(3!==o)throw new Error("CFF Table CID Font FDSelect table has unsupported format "+o);var h=s.parseCard16(),u=s.parseCard16();if(0!==u)throw new Error("CFF Table CID Font FDSelect format 3 range has bad initial GID "+u);for(var c,d=0;d<h;d++){if(r=s.parseCard8(),c=s.parseCard16(),r>=i)throw new Error("CFF table CID Font FDSelect has bad FD index value "+r+" (FD count "+i+")");if(c>n)throw new Error("CFF Table CID Font FDSelect format 3 range has bad GID "+c);for(;u<c;u++)a.push(r);u=c}if(c!==n)throw new Error("CFF Table CID Font FDSelect format 3 range has bad final GID "+c)}return a}function mft(e,t,n,i){n.tables.cff={};var r=uft(e,t),a=wf(e,r.endOffset,_n.bytesToString),s=wf(e,a.endOffset),o=wf(e,s.endOffset,_n.bytesToString),l=wf(e,o.endOffset);n.gsubrs=l.objects,n.gsubrsBias=j5(n.gsubrs);var h=Ome(e,t,s.objects,o.objects);if(1!==h.length)throw new Error("CFF table has too many fonts in 'FontSet' - count of fonts NameIndex.length = "+h.length);var u=h[0];if(n.tables.cff.topDict=u,u._privateDict&&(n.defaultWidthX=u._privateDict.defaultWidthX,n.nominalWidthX=u._privateDict.nominalWidthX),void 0!==u.ros[0]&&void 0!==u.ros[1]&&(n.isCIDFont=!0),n.isCIDFont){var c=u.fdArray,d=u.fdSelect;if(0===c||0===d)throw new Error("Font is marked as a CID font, but FDArray and/or FDSelect information is missing");var p=wf(e,c+=t),f=Ome(e,t,p.objects,o.objects);u._fdArray=f,d+=t,u._fdSelect=pft(e,d,n.numGlyphs,f.length)}var m,g=t+u.private[1],v=Age(e,g,u.private[0],o.objects);if(n.defaultWidthX=v.defaultWidthX,n.nominalWidthX=v.nominalWidthX,0!==v.subrs){var y=g+v.subrs,x=wf(e,y);n.subrs=x.objects,n.subrsBias=j5(n.subrs)}else n.subrs=[],n.subrsBias=0;i.lowMemory?(m=sft(e,t+u.charStrings),n.nGlyphs=m.offsets.length):(m=wf(e,t+u.charStrings),n.nGlyphs=m.objects.length);var b=dft(e,t+u.charset,n.nGlyphs,o.objects);if(0===u.encoding?n.cffEncoding=new SC($dt,b):1===u.encoding?n.cffEncoding=new SC(Zdt,b):n.cffEncoding=fft(e,t+u.encoding,b),n.encoding=n.encoding||n.cffEncoding,n.glyphs=new Uu.GlyphSet(n),i.lowMemory)n._push=function(i){var r=aft(i,m.offsets,e,t+u.charStrings);n.glyphs.push(i,Uu.cffGlyphLoader(n,i,kme,r))};else for(var _=0;_<n.nGlyphs;_+=1){var w=m.objects[_];n.glyphs.push(_,Uu.cffGlyphLoader(n,_,kme,w))}}function Rge(e,t){var n,i=yC.indexOf(e);return i>=0&&(n=i),(i=t.indexOf(e))>=0?n=i+yC.length:(n=yC.length+t.length,t.push(e)),n}function gft(){return new dn.Record("Header",[{name:"major",type:"Card8",value:1},{name:"minor",type:"Card8",value:0},{name:"hdrSize",type:"Card8",value:4},{name:"major",type:"Card8",value:1}])}function vft(e){var t=new dn.Record("Name INDEX",[{name:"names",type:"INDEX",value:[]}]);t.names=[];for(var n=0;n<e.length;n+=1)t.names.push({name:"name_"+n,type:"NAME",value:e[n]});return t}function Cge(e,t,n){for(var i={},r=0;r<e.length;r+=1){var a=e[r],s=t[a.name];void 0!==s&&!_ge(s,a.value)&&("SID"===a.type&&(s=Rge(s,n)),i[a.op]={name:a.name,type:a.type,value:s})}return i}function Fme(e,t){var n=new dn.Record("Top DICT",[{name:"dict",type:"DICT",value:{}}]);return n.dict=Cge(Sge,e,t),n}function Nme(e){var t=new dn.Record("Top DICT INDEX",[{name:"topDicts",type:"INDEX",value:[]}]);return t.topDicts=[{name:"topDict_0",type:"TABLE",value:e}],t}function yft(e){var t=new dn.Record("String INDEX",[{name:"strings",type:"INDEX",value:[]}]);t.strings=[];for(var n=0;n<e.length;n+=1)t.strings.push({name:"string_"+n,type:"STRING",value:e[n]});return t}function xft(){return new dn.Record("Global Subr INDEX",[{name:"subrs",type:"INDEX",value:[]}])}function bft(e,t){for(var n=new dn.Record("Charsets",[{name:"format",type:"Card8",value:0}]),i=0;i<e.length;i+=1){var r=Rge(e[i],t);n.fields.push({name:"glyph_"+i,type:"SID",value:r})}return n}function Eft(e){var t=[],n=e.path;t.push({name:"width",type:"NUMBER",value:e.advanceWidth});for(var i=0,r=0,a=0;a<n.commands.length;a+=1){var s=void 0,o=void 0,l=n.commands[a];if("Q"===l.type){var h=.3333333333333333,u=2/3;l={type:"C",x:l.x,y:l.y,x1:Math.round(h*i+u*l.x1),y1:Math.round(h*r+u*l.y1),x2:Math.round(h*l.x+u*l.x1),y2:Math.round(h*l.y+u*l.y1)}}if("M"===l.type)s=Math.round(l.x-i),o=Math.round(l.y-r),t.push({name:"dx",type:"NUMBER",value:s}),t.push({name:"dy",type:"NUMBER",value:o}),t.push({name:"rmoveto",type:"OP",value:21}),i=Math.round(l.x),r=Math.round(l.y);else if("L"===l.type)s=Math.round(l.x-i),o=Math.round(l.y-r),t.push({name:"dx",type:"NUMBER",value:s}),t.push({name:"dy",type:"NUMBER",value:o}),t.push({name:"rlineto",type:"OP",value:5}),i=Math.round(l.x),r=Math.round(l.y);else if("C"===l.type){var c=Math.round(l.x1-i),d=Math.round(l.y1-r),p=Math.round(l.x2-l.x1),f=Math.round(l.y2-l.y1);s=Math.round(l.x-l.x2),o=Math.round(l.y-l.y2),t.push({name:"dx1",type:"NUMBER",value:c}),t.push({name:"dy1",type:"NUMBER",value:d}),t.push({name:"dx2",type:"NUMBER",value:p}),t.push({name:"dy2",type:"NUMBER",value:f}),t.push({name:"dx",type:"NUMBER",value:s}),t.push({name:"dy",type:"NUMBER",value:o}),t.push({name:"rrcurveto",type:"OP",value:8}),i=Math.round(l.x),r=Math.round(l.y)}}return t.push({name:"endchar",type:"OP",value:14}),t}function _ft(e){for(var t=new dn.Record("CharStrings INDEX",[{name:"charStrings",type:"INDEX",value:[]}]),n=0;n<e.length;n+=1){var i=e.get(n),r=Eft(i);t.charStrings.push({name:i.name,type:"CHARSTRING",value:r})}return t}function Tft(e,t){var n=new dn.Record("Private DICT",[{name:"dict",type:"DICT",value:{}}]);return n.dict=Cge(Mge,e,t),n}function wft(e,t){for(var n,i=new dn.Table("CFF ",[{name:"header",type:"RECORD"},{name:"nameIndex",type:"RECORD"},{name:"topDictIndex",type:"RECORD"},{name:"stringIndex",type:"RECORD"},{name:"globalSubrIndex",type:"RECORD"},{name:"charsets",type:"RECORD"},{name:"charStringsIndex",type:"RECORD"},{name:"privateDict",type:"RECORD"}]),r=1/t.unitsPerEm,a={version:t.version,fullName:t.fullName,familyName:t.familyName,weight:t.weightName,fontBBox:t.fontBBox||[0,0,0,0],fontMatrix:[r,0,0,r,0,0],charset:999,encoding:0,charStrings:999,private:[0,999]},s=[],o=1;o<e.length;o+=1)n=e.get(o),s.push(n.name);var l=[];i.header=gft(),i.nameIndex=vft([t.postScriptName]);var h=Fme(a,l);i.topDictIndex=Nme(h),i.globalSubrIndex=xft(),i.charsets=bft(s,l),i.charStringsIndex=_ft(e),i.privateDict=Tft({},l),i.stringIndex=yft(l);var u=i.header.sizeOf()+i.nameIndex.sizeOf()+i.topDictIndex.sizeOf()+i.stringIndex.sizeOf()+i.globalSubrIndex.sizeOf();return a.charset=u,a.encoding=0,a.charStrings=a.charset+i.charsets.sizeOf(),a.private[1]=a.charStrings+i.charStringsIndex.sizeOf(),h=Fme(a,l),i.topDictIndex=Nme(h),i}var Pge={parse:mft,make:wft};function Sft(e,t){var n={},i=new _n.Parser(e,t);return n.version=i.parseVersion(),n.fontRevision=Math.round(1e3*i.parseFixed())/1e3,n.checkSumAdjustment=i.parseULong(),n.magicNumber=i.parseULong(),Yn.argument(1594834165===n.magicNumber,"Font header has wrong magic number."),n.flags=i.parseUShort(),n.unitsPerEm=i.parseUShort(),n.created=i.parseLongDateTime(),n.modified=i.parseLongDateTime(),n.xMin=i.parseShort(),n.yMin=i.parseShort(),n.xMax=i.parseShort(),n.yMax=i.parseShort(),n.macStyle=i.parseUShort(),n.lowestRecPPEM=i.parseUShort(),n.fontDirectionHint=i.parseShort(),n.indexToLocFormat=i.parseShort(),n.glyphDataFormat=i.parseShort(),n}function Mft(e){var t=Math.round((new Date).getTime()/1e3)+2082844800,n=t;return e.createdTimestamp&&(n=e.createdTimestamp+2082844800),new dn.Table("head",[{name:"version",type:"FIXED",value:65536},{name:"fontRevision",type:"FIXED",value:65536},{name:"checkSumAdjustment",type:"ULONG",value:0},{name:"magicNumber",type:"ULONG",value:1594834165},{name:"flags",type:"USHORT",value:0},{name:"unitsPerEm",type:"USHORT",value:1e3},{name:"created",type:"LONGDATETIME",value:n},{name:"modified",type:"LONGDATETIME",value:t},{name:"xMin",type:"SHORT",value:0},{name:"yMin",type:"SHORT",value:0},{name:"xMax",type:"SHORT",value:0},{name:"yMax",type:"SHORT",value:0},{name:"macStyle",type:"USHORT",value:0},{name:"lowestRecPPEM",type:"USHORT",value:0},{name:"fontDirectionHint",type:"SHORT",value:2},{name:"indexToLocFormat",type:"SHORT",value:0},{name:"glyphDataFormat",type:"SHORT",value:0}],e)}var Ige={parse:Sft,make:Mft};function Aft(e,t){var n={},i=new _n.Parser(e,t);return n.version=i.parseVersion(),n.ascender=i.parseShort(),n.descender=i.parseShort(),n.lineGap=i.parseShort(),n.advanceWidthMax=i.parseUShort(),n.minLeftSideBearing=i.parseShort(),n.minRightSideBearing=i.parseShort(),n.xMaxExtent=i.parseShort(),n.caretSlopeRise=i.parseShort(),n.caretSlopeRun=i.parseShort(),n.caretOffset=i.parseShort(),i.relativeOffset+=8,n.metricDataFormat=i.parseShort(),n.numberOfHMetrics=i.parseUShort(),n}function Rft(e){return new dn.Table("hhea",[{name:"version",type:"FIXED",value:65536},{name:"ascender",type:"FWORD",value:0},{name:"descender",type:"FWORD",value:0},{name:"lineGap",type:"FWORD",value:0},{name:"advanceWidthMax",type:"UFWORD",value:0},{name:"minLeftSideBearing",type:"FWORD",value:0},{name:"minRightSideBearing",type:"FWORD",value:0},{name:"xMaxExtent",type:"FWORD",value:0},{name:"caretSlopeRise",type:"SHORT",value:1},{name:"caretSlopeRun",type:"SHORT",value:0},{name:"caretOffset",type:"SHORT",value:0},{name:"reserved1",type:"SHORT",value:0},{name:"reserved2",type:"SHORT",value:0},{name:"reserved3",type:"SHORT",value:0},{name:"reserved4",type:"SHORT",value:0},{name:"metricDataFormat",type:"SHORT",value:0},{name:"numberOfHMetrics",type:"USHORT",value:0}],e)}var Lge={parse:Aft,make:Rft};function Cft(e,t,n,i,r){for(var a,s,o=new _n.Parser(e,t),l=0;l<i;l+=1){l<n&&(a=o.parseUShort(),s=o.parseShort());var h=r.get(l);h.advanceWidth=a,h.leftSideBearing=s}}function Pft(e,t,n,i,r){e._hmtxTableData={};for(var a,s,o=new _n.Parser(t,n),l=0;l<r;l+=1)l<i&&(a=o.parseUShort(),s=o.parseShort()),e._hmtxTableData[l]={advanceWidth:a,leftSideBearing:s}}function Ift(e,t,n,i,r,a,s){s.lowMemory?Pft(e,t,n,i,r):Cft(t,n,i,r,a)}function Lft(e){for(var t=new dn.Table("hmtx",[]),n=0;n<e.length;n+=1){var i=e.get(n),r=i.advanceWidth||0,a=i.leftSideBearing||0;t.fields.push({name:"advanceWidth_"+n,type:"USHORT",value:r}),t.fields.push({name:"leftSideBearing_"+n,type:"SHORT",value:a})}return t}var Dge={parse:Ift,make:Lft};function Dft(e){for(var t=new dn.Table("ltag",[{name:"version",type:"ULONG",value:1},{name:"flags",type:"ULONG",value:0},{name:"numTags",type:"ULONG",value:e.length}]),n="",i=12+4*e.length,r=0;r<e.length;++r){var a=n.indexOf(e[r]);a<0&&(a=n.length,n+=e[r]),t.fields.push({name:"offset "+r,type:"USHORT",value:i+a}),t.fields.push({name:"length "+r,type:"USHORT",value:e[r].length})}return t.fields.push({name:"stringPool",type:"CHARARRAY",value:n}),t}function Oft(e,t){var n=new _n.Parser(e,t),i=n.parseULong();Yn.argument(1===i,"Unsupported ltag table version."),n.skip("uLong",1);for(var r=n.parseULong(),a=[],s=0;s<r;s++){for(var o="",l=t+n.parseUShort(),h=n.parseUShort(),u=l;u<l+h;++u)o+=String.fromCharCode(e.getInt8(u));a.push(o)}return a}var Oge={make:Dft,parse:Oft};function kft(e,t){var n={},i=new _n.Parser(e,t);return n.version=i.parseVersion(),n.numGlyphs=i.parseUShort(),1===n.version&&(n.maxPoints=i.parseUShort(),n.maxContours=i.parseUShort(),n.maxCompositePoints=i.parseUShort(),n.maxCompositeContours=i.parseUShort(),n.maxZones=i.parseUShort(),n.maxTwilightPoints=i.parseUShort(),n.maxStorage=i.parseUShort(),n.maxFunctionDefs=i.parseUShort(),n.maxInstructionDefs=i.parseUShort(),n.maxStackElements=i.parseUShort(),n.maxSizeOfInstructions=i.parseUShort(),n.maxComponentElements=i.parseUShort(),n.maxComponentDepth=i.parseUShort()),n}function Fft(e){return new dn.Table("maxp",[{name:"version",type:"FIXED",value:20480},{name:"numGlyphs",type:"USHORT",value:e}])}var kge={parse:kft,make:Fft},Fge=["copyright","fontFamily","fontSubfamily","uniqueID","fullName","version","postScriptName","trademark","manufacturer","designer","description","manufacturerURL","designerURL","license","licenseURL","reserved","preferredFamily","preferredSubfamily","compatibleFullName","sampleText","postScriptFindFontName","wwsFamily","wwsSubfamily"],Nge={0:"en",1:"fr",2:"de",3:"it",4:"nl",5:"sv",6:"es",7:"da",8:"pt",9:"no",10:"he",11:"ja",12:"ar",13:"fi",14:"el",15:"is",16:"mt",17:"tr",18:"hr",19:"zh-Hant",20:"ur",21:"hi",22:"th",23:"ko",24:"lt",25:"pl",26:"hu",27:"es",28:"lv",29:"se",30:"fo",31:"fa",32:"ru",33:"zh",34:"nl-BE",35:"ga",36:"sq",37:"ro",38:"cz",39:"sk",40:"si",41:"yi",42:"sr",43:"mk",44:"bg",45:"uk",46:"be",47:"uz",48:"kk",49:"az-Cyrl",50:"az-Arab",51:"hy",52:"ka",53:"mo",54:"ky",55:"tg",56:"tk",57:"mn-CN",58:"mn",59:"ps",60:"ks",61:"ku",62:"sd",63:"bo",64:"ne",65:"sa",66:"mr",67:"bn",68:"as",69:"gu",70:"pa",71:"or",72:"ml",73:"kn",74:"ta",75:"te",76:"si",77:"my",78:"km",79:"lo",80:"vi",81:"id",82:"tl",83:"ms",84:"ms-Arab",85:"am",86:"ti",87:"om",88:"so",89:"sw",90:"rw",91:"rn",92:"ny",93:"mg",94:"eo",128:"cy",129:"eu",130:"ca",131:"la",132:"qu",133:"gn",134:"ay",135:"tt",136:"ug",137:"dz",138:"jv",139:"su",140:"gl",141:"af",142:"br",143:"iu",144:"gd",145:"gv",146:"ga",147:"to",148:"el-polyton",149:"kl",150:"az",151:"nn"},Nft={0:0,1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0,9:0,10:5,11:1,12:4,13:0,14:6,15:0,16:0,17:0,18:0,19:2,20:4,21:9,22:21,23:3,24:29,25:29,26:29,27:29,28:29,29:0,30:0,31:4,32:7,33:25,34:0,35:0,36:0,37:0,38:29,39:29,40:0,41:5,42:7,43:7,44:7,45:7,46:7,47:7,48:7,49:7,50:4,51:24,52:23,53:7,54:7,55:7,56:7,57:27,58:7,59:4,60:4,61:4,62:4,63:26,64:9,65:9,66:9,67:13,68:13,69:11,70:10,71:12,72:17,73:16,74:14,75:15,76:18,77:19,78:20,79:22,80:30,81:0,82:0,83:0,84:4,85:28,86:28,87:28,88:0,89:0,90:0,91:0,92:0,93:0,94:0,128:0,129:0,130:0,131:0,132:0,133:0,134:0,135:7,136:4,137:26,138:0,139:0,140:0,141:0,142:0,143:28,144:0,145:0,146:0,147:0,148:6,149:0,150:0,151:0},Bge={1078:"af",1052:"sq",1156:"gsw",1118:"am",5121:"ar-DZ",15361:"ar-BH",3073:"ar",2049:"ar-IQ",11265:"ar-JO",13313:"ar-KW",12289:"ar-LB",4097:"ar-LY",6145:"ary",8193:"ar-OM",16385:"ar-QA",1025:"ar-SA",10241:"ar-SY",7169:"aeb",14337:"ar-AE",9217:"ar-YE",1067:"hy",1101:"as",2092:"az-Cyrl",1068:"az",1133:"ba",1069:"eu",1059:"be",2117:"bn",1093:"bn-IN",8218:"bs-Cyrl",5146:"bs",1150:"br",1026:"bg",1027:"ca",3076:"zh-HK",5124:"zh-MO",2052:"zh",4100:"zh-SG",1028:"zh-TW",1155:"co",1050:"hr",4122:"hr-BA",1029:"cs",1030:"da",1164:"prs",1125:"dv",2067:"nl-BE",1043:"nl",3081:"en-AU",10249:"en-BZ",4105:"en-CA",9225:"en-029",16393:"en-IN",6153:"en-IE",8201:"en-JM",17417:"en-MY",5129:"en-NZ",13321:"en-PH",18441:"en-SG",7177:"en-ZA",11273:"en-TT",2057:"en-GB",1033:"en",12297:"en-ZW",1061:"et",1080:"fo",1124:"fil",1035:"fi",2060:"fr-BE",3084:"fr-CA",1036:"fr",5132:"fr-LU",6156:"fr-MC",4108:"fr-CH",1122:"fy",1110:"gl",1079:"ka",3079:"de-AT",1031:"de",5127:"de-LI",4103:"de-LU",2055:"de-CH",1032:"el",1135:"kl",1095:"gu",1128:"ha",1037:"he",1081:"hi",1038:"hu",1039:"is",1136:"ig",1057:"id",1117:"iu",2141:"iu-Latn",2108:"ga",1076:"xh",1077:"zu",1040:"it",2064:"it-CH",1041:"ja",1099:"kn",1087:"kk",1107:"km",1158:"quc",1159:"rw",1089:"sw",1111:"kok",1042:"ko",1088:"ky",1108:"lo",1062:"lv",1063:"lt",2094:"dsb",1134:"lb",1071:"mk",2110:"ms-BN",1086:"ms",1100:"ml",1082:"mt",1153:"mi",1146:"arn",1102:"mr",1148:"moh",1104:"mn",2128:"mn-CN",1121:"ne",1044:"nb",2068:"nn",1154:"oc",1096:"or",1123:"ps",1045:"pl",1046:"pt",2070:"pt-PT",1094:"pa",1131:"qu-BO",2155:"qu-EC",3179:"qu",1048:"ro",1047:"rm",1049:"ru",9275:"smn",4155:"smj-NO",5179:"smj",3131:"se-FI",1083:"se",2107:"se-SE",8251:"sms",6203:"sma-NO",7227:"sms",1103:"sa",7194:"sr-Cyrl-BA",3098:"sr",6170:"sr-Latn-BA",2074:"sr-Latn",1132:"nso",1074:"tn",1115:"si",1051:"sk",1060:"sl",11274:"es-AR",16394:"es-BO",13322:"es-CL",9226:"es-CO",5130:"es-CR",7178:"es-DO",12298:"es-EC",17418:"es-SV",4106:"es-GT",18442:"es-HN",2058:"es-MX",19466:"es-NI",6154:"es-PA",15370:"es-PY",10250:"es-PE",20490:"es-PR",3082:"es",1034:"es",21514:"es-US",14346:"es-UY",8202:"es-VE",2077:"sv-FI",1053:"sv",1114:"syr",1064:"tg",2143:"tzm",1097:"ta",1092:"tt",1098:"te",1054:"th",1105:"bo",1055:"tr",1090:"tk",1152:"ug",1058:"uk",1070:"hsb",1056:"ur",2115:"uz-Cyrl",1091:"uz",1066:"vi",1106:"cy",1160:"wo",1157:"sah",1144:"ii",1130:"yo"};function Bft(e,t,n){switch(e){case 0:if(65535===t)return"und";if(n)return n[t];break;case 1:return Nge[t];case 3:return Bge[t]}}var X5="utf-16",Uft={0:"macintosh",1:"x-mac-japanese",2:"x-mac-chinesetrad",3:"x-mac-korean",6:"x-mac-greek",7:"x-mac-cyrillic",9:"x-mac-devanagai",10:"x-mac-gurmukhi",11:"x-mac-gujarati",12:"x-mac-oriya",13:"x-mac-bengali",14:"x-mac-tamil",15:"x-mac-telugu",16:"x-mac-kannada",17:"x-mac-malayalam",18:"x-mac-sinhalese",19:"x-mac-burmese",20:"x-mac-khmer",21:"x-mac-thai",22:"x-mac-lao",23:"x-mac-georgian",24:"x-mac-armenian",25:"x-mac-chinesesimp",26:"x-mac-tibetan",27:"x-mac-mongolian",28:"x-mac-ethiopic",29:"x-mac-ce",30:"x-mac-vietnamese",31:"x-mac-extarabic"},Hft={15:"x-mac-icelandic",17:"x-mac-turkish",18:"x-mac-croatian",24:"x-mac-ce",25:"x-mac-ce",26:"x-mac-ce",27:"x-mac-ce",28:"x-mac-ce",30:"x-mac-icelandic",37:"x-mac-romanian",38:"x-mac-ce",39:"x-mac-ce",40:"x-mac-ce",143:"x-mac-inuit",146:"x-mac-gaelic"};function Uge(e,t,n){switch(e){case 0:return X5;case 1:return Hft[n]||Uft[t];case 3:if(1===t||10===t)return X5}}function Vft(e,t,n){for(var i={},r=new _n.Parser(e,t),a=r.parseUShort(),s=r.parseUShort(),o=r.offset+r.parseUShort(),l=0;l<s;l++){var h=r.parseUShort(),u=r.parseUShort(),c=r.parseUShort(),d=r.parseUShort(),p=Fge[d]||d,f=r.parseUShort(),m=r.parseUShort(),g=Bft(h,c,n),v=Uge(h,u,c);if(void 0!==v&&void 0!==g){var y;if(y=v===X5?Qv.UTF16(e,o+m,f):Qv.MACSTRING(e,o+m,f,v)){var x=i[p];void 0===x&&(x=i[p]={}),x[g]=y}}}return 1===a&&r.parseUShort(),i}function O5(e){var t={};for(var n in e)t[e[n]]=parseInt(n);return t}function Bme(e,t,n,i,r,a){return new dn.Record("NameRecord",[{name:"platformID",type:"USHORT",value:e},{name:"encodingID",type:"USHORT",value:t},{name:"languageID",type:"USHORT",value:n},{name:"nameID",type:"USHORT",value:i},{name:"length",type:"USHORT",value:r},{name:"offset",type:"USHORT",value:a}])}function zft(e,t){var n=e.length,i=t.length-n+1;e:for(var r=0;r<i;r++)for(;r<i;r++){for(var a=0;a<n;a++)if(t[r+a]!==e[a])continue e;return r}return-1}function Ume(e,t){var n=zft(e,t);if(n<0){n=t.length;for(var i=0,r=e.length;i<r;++i)t.push(e[i])}return n}function Gft(e,t){var n,i=[],r={},a=O5(Fge);for(var s in e){var o=a[s];if(void 0===o&&(o=s),n=parseInt(o),isNaN(n))throw new Error('Name table entry "'+s+'" does not exist, see nameTableNames for complete list.');r[n]=e[s],i.push(n)}for(var l=O5(Nge),h=O5(Bge),u=[],c=[],d=0;d<i.length;d++){var p=r[n=i[d]];for(var f in p){var m=p[f],g=1,v=l[f],y=Nft[v],x=Uge(g,y,v),b=tn.MACSTRING(m,x);void 0===b&&(g=0,(v=t.indexOf(f))<0&&(v=t.length,t.push(f)),y=4,b=tn.UTF16(m));var _=Ume(b,c);u.push(Bme(g,y,v,n,b.length,_));var w=h[f];if(void 0!==w){var S=tn.UTF16(m),M=Ume(S,c);u.push(Bme(3,1,w,n,S.length,M))}}}u.sort((function(e,t){return e.platformID-t.platformID||e.encodingID-t.encodingID||e.languageID-t.languageID||e.nameID-t.nameID}));for(var E=new dn.Table("name",[{name:"format",type:"USHORT",value:0},{name:"count",type:"USHORT",value:u.length},{name:"stringOffset",type:"USHORT",value:6+12*u.length}]),T=0;T<u.length;T++)E.fields.push({name:"record_"+T,type:"RECORD",value:u[T]});return E.fields.push({name:"strings",type:"LITERAL",value:c}),E}var Hge={parse:Vft,make:Gft},Y5=[{begin:0,end:127},{begin:128,end:255},{begin:256,end:383},{begin:384,end:591},{begin:592,end:687},{begin:688,end:767},{begin:768,end:879},{begin:880,end:1023},{begin:11392,end:11519},{begin:1024,end:1279},{begin:1328,end:1423},{begin:1424,end:1535},{begin:42240,end:42559},{begin:1536,end:1791},{begin:1984,end:2047},{begin:2304,end:2431},{begin:2432,end:2559},{begin:2560,end:2687},{begin:2688,end:2815},{begin:2816,end:2943},{begin:2944,end:3071},{begin:3072,end:3199},{begin:3200,end:3327},{begin:3328,end:3455},{begin:3584,end:3711},{begin:3712,end:3839},{begin:4256,end:4351},{begin:6912,end:7039},{begin:4352,end:4607},{begin:7680,end:7935},{begin:7936,end:8191},{begin:8192,end:8303},{begin:8304,end:8351},{begin:8352,end:8399},{begin:8400,end:8447},{begin:8448,end:8527},{begin:8528,end:8591},{begin:8592,end:8703},{begin:8704,end:8959},{begin:8960,end:9215},{begin:9216,end:9279},{begin:9280,end:9311},{begin:9312,end:9471},{begin:9472,end:9599},{begin:9600,end:9631},{begin:9632,end:9727},{begin:9728,end:9983},{begin:9984,end:10175},{begin:12288,end:12351},{begin:12352,end:12447},{begin:12448,end:12543},{begin:12544,end:12591},{begin:12592,end:12687},{begin:43072,end:43135},{begin:12800,end:13055},{begin:13056,end:13311},{begin:44032,end:55215},{begin:55296,end:57343},{begin:67840,end:67871},{begin:19968,end:40959},{begin:57344,end:63743},{begin:12736,end:12783},{begin:64256,end:64335},{begin:64336,end:65023},{begin:65056,end:65071},{begin:65040,end:65055},{begin:65104,end:65135},{begin:65136,end:65279},{begin:65280,end:65519},{begin:65520,end:65535},{begin:3840,end:4095},{begin:1792,end:1871},{begin:1920,end:1983},{begin:3456,end:3583},{begin:4096,end:4255},{begin:4608,end:4991},{begin:5024,end:5119},{begin:5120,end:5759},{begin:5760,end:5791},{begin:5792,end:5887},{begin:6016,end:6143},{begin:6144,end:6319},{begin:10240,end:10495},{begin:40960,end:42127},{begin:5888,end:5919},{begin:66304,end:66351},{begin:66352,end:66383},{begin:66560,end:66639},{begin:118784,end:119039},{begin:119808,end:120831},{begin:1044480,end:1048573},{begin:65024,end:65039},{begin:917504,end:917631},{begin:6400,end:6479},{begin:6480,end:6527},{begin:6528,end:6623},{begin:6656,end:6687},{begin:11264,end:11359},{begin:11568,end:11647},{begin:19904,end:19967},{begin:43008,end:43055},{begin:65536,end:65663},{begin:65856,end:65935},{begin:66432,end:66463},{begin:66464,end:66527},{begin:66640,end:66687},{begin:66688,end:66735},{begin:67584,end:67647},{begin:68096,end:68191},{begin:119552,end:119647},{begin:73728,end:74751},{begin:119648,end:119679},{begin:7040,end:7103},{begin:7168,end:7247},{begin:7248,end:7295},{begin:43136,end:43231},{begin:43264,end:43311},{begin:43312,end:43359},{begin:43520,end:43615},{begin:65936,end:65999},{begin:66e3,end:66047},{begin:66208,end:66271},{begin:127024,end:127135}];function qft(e){for(var t=0;t<Y5.length;t+=1){var n=Y5[t];if(e>=n.begin&&e<n.end)return t}return-1}function Wft(e,t){var n={},i=new _n.Parser(e,t);n.version=i.parseUShort(),n.xAvgCharWidth=i.parseShort(),n.usWeightClass=i.parseUShort(),n.usWidthClass=i.parseUShort(),n.fsType=i.parseUShort(),n.ySubscriptXSize=i.parseShort(),n.ySubscriptYSize=i.parseShort(),n.ySubscriptXOffset=i.parseShort(),n.ySubscriptYOffset=i.parseShort(),n.ySuperscriptXSize=i.parseShort(),n.ySuperscriptYSize=i.parseShort(),n.ySuperscriptXOffset=i.parseShort(),n.ySuperscriptYOffset=i.parseShort(),n.yStrikeoutSize=i.parseShort(),n.yStrikeoutPosition=i.parseShort(),n.sFamilyClass=i.parseShort(),n.panose=[];for(var r=0;r<10;r++)n.panose[r]=i.parseByte();return n.ulUnicodeRange1=i.parseULong(),n.ulUnicodeRange2=i.parseULong(),n.ulUnicodeRange3=i.parseULong(),n.ulUnicodeRange4=i.parseULong(),n.achVendID=String.fromCharCode(i.parseByte(),i.parseByte(),i.parseByte(),i.parseByte()),n.fsSelection=i.parseUShort(),n.usFirstCharIndex=i.parseUShort(),n.usLastCharIndex=i.parseUShort(),n.sTypoAscender=i.parseShort(),n.sTypoDescender=i.parseShort(),n.sTypoLineGap=i.parseShort(),n.usWinAscent=i.parseUShort(),n.usWinDescent=i.parseUShort(),n.version>=1&&(n.ulCodePageRange1=i.parseULong(),n.ulCodePageRange2=i.parseULong()),n.version>=2&&(n.sxHeight=i.parseShort(),n.sCapHeight=i.parseShort(),n.usDefaultChar=i.parseUShort(),n.usBreakChar=i.parseUShort(),n.usMaxContent=i.parseUShort()),n}function jft(e){return new dn.Table("OS/2",[{name:"version",type:"USHORT",value:3},{name:"xAvgCharWidth",type:"SHORT",value:0},{name:"usWeightClass",type:"USHORT",value:0},{name:"usWidthClass",type:"USHORT",value:0},{name:"fsType",type:"USHORT",value:0},{name:"ySubscriptXSize",type:"SHORT",value:650},{name:"ySubscriptYSize",type:"SHORT",value:699},{name:"ySubscriptXOffset",type:"SHORT",value:0},{name:"ySubscriptYOffset",type:"SHORT",value:140},{name:"ySuperscriptXSize",type:"SHORT",value:650},{name:"ySuperscriptYSize",type:"SHORT",value:699},{name:"ySuperscriptXOffset",type:"SHORT",value:0},{name:"ySuperscriptYOffset",type:"SHORT",value:479},{name:"yStrikeoutSize",type:"SHORT",value:49},{name:"yStrikeoutPosition",type:"SHORT",value:258},{name:"sFamilyClass",type:"SHORT",value:0},{name:"bFamilyType",type:"BYTE",value:0},{name:"bSerifStyle",type:"BYTE",value:0},{name:"bWeight",type:"BYTE",value:0},{name:"bProportion",type:"BYTE",value:0},{name:"bContrast",type:"BYTE",value:0},{name:"bStrokeVariation",type:"BYTE",value:0},{name:"bArmStyle",type:"BYTE",value:0},{name:"bLetterform",type:"BYTE",value:0},{name:"bMidline",type:"BYTE",value:0},{name:"bXHeight",type:"BYTE",value:0},{name:"ulUnicodeRange1",type:"ULONG",value:0},{name:"ulUnicodeRange2",type:"ULONG",value:0},{name:"ulUnicodeRange3",type:"ULONG",value:0},{name:"ulUnicodeRange4",type:"ULONG",value:0},{name:"achVendID",type:"CHARARRAY",value:"XXXX"},{name:"fsSelection",type:"USHORT",value:0},{name:"usFirstCharIndex",type:"USHORT",value:0},{name:"usLastCharIndex",type:"USHORT",value:0},{name:"sTypoAscender",type:"SHORT",value:0},{name:"sTypoDescender",type:"SHORT",value:0},{name:"sTypoLineGap",type:"SHORT",value:0},{name:"usWinAscent",type:"USHORT",value:0},{name:"usWinDescent",type:"USHORT",value:0},{name:"ulCodePageRange1",type:"ULONG",value:0},{name:"ulCodePageRange2",type:"ULONG",value:0},{name:"sxHeight",type:"SHORT",value:0},{name:"sCapHeight",type:"SHORT",value:0},{name:"usDefaultChar",type:"USHORT",value:0},{name:"usBreakChar",type:"USHORT",value:0},{name:"usMaxContext",type:"USHORT",value:0}],e)}var $5={parse:Wft,make:jft,unicodeRanges:Y5,getUnicodeRange:qft};function Xft(e,t){var n={},i=new _n.Parser(e,t);switch(n.version=i.parseVersion(),n.italicAngle=i.parseFixed(),n.underlinePosition=i.parseShort(),n.underlineThickness=i.parseShort(),n.isFixedPitch=i.parseULong(),n.minMemType42=i.parseULong(),n.maxMemType42=i.parseULong(),n.minMemType1=i.parseULong(),n.maxMemType1=i.parseULong(),n.version){case 1:n.names=Um.slice();break;case 2:n.numberOfGlyphs=i.parseUShort(),n.glyphNameIndex=new Array(n.numberOfGlyphs);for(var r=0;r<n.numberOfGlyphs;r++)n.glyphNameIndex[r]=i.parseUShort();n.names=[];for(var a=0;a<n.numberOfGlyphs;a++)if(n.glyphNameIndex[a]>=Um.length){var s=i.parseChar();n.names.push(i.parseString(s))}break;case 2.5:n.numberOfGlyphs=i.parseUShort(),n.offset=new Array(n.numberOfGlyphs);for(var o=0;o<n.numberOfGlyphs;o++)n.offset[o]=i.parseChar()}return n}function Yft(){return new dn.Table("post",[{name:"version",type:"FIXED",value:196608},{name:"italicAngle",type:"FIXED",value:0},{name:"underlinePosition",type:"FWORD",value:0},{name:"underlineThickness",type:"FWORD",value:0},{name:"isFixedPitch",type:"ULONG",value:0},{name:"minMemType42",type:"ULONG",value:0},{name:"maxMemType42",type:"ULONG",value:0},{name:"minMemType1",type:"ULONG",value:0},{name:"maxMemType1",type:"ULONG",value:0}])}var Vge={parse:Xft,make:Yft},Oc=new Array(9);Oc[1]=function(){var e=this.offset+this.relativeOffset,t=this.parseUShort();return 1===t?{substFormat:1,coverage:this.parsePointer(Et.coverage),deltaGlyphId:this.parseUShort()}:2===t?{substFormat:2,coverage:this.parsePointer(Et.coverage),substitute:this.parseOffset16List()}:void Yn.assert(!1,"0x"+e.toString(16)+": lookup type 1 format must be 1 or 2.")},Oc[2]=function(){var e=this.parseUShort();return Yn.argument(1===e,"GSUB Multiple Substitution Subtable identifier-format must be 1"),{substFormat:e,coverage:this.parsePointer(Et.coverage),sequences:this.parseListOfLists()}},Oc[3]=function(){var e=this.parseUShort();return Yn.argument(1===e,"GSUB Alternate Substitution Subtable identifier-format must be 1"),{substFormat:e,coverage:this.parsePointer(Et.coverage),alternateSets:this.parseListOfLists()}},Oc[4]=function(){var e=this.parseUShort();return Yn.argument(1===e,"GSUB ligature table identifier-format must be 1"),{substFormat:e,coverage:this.parsePointer(Et.coverage),ligatureSets:this.parseListOfLists((function(){return{ligGlyph:this.parseUShort(),components:this.parseUShortList(this.parseUShort()-1)}}))}};var Jv={sequenceIndex:Et.uShort,lookupListIndex:Et.uShort};function $ft(e,t){var n=new Et(e,t=t||0),i=n.parseVersion(1);return Yn.argument(1===i||1.1===i,"Unsupported GSUB table version."),1===i?{version:i,scripts:n.parseScriptList(),features:n.parseFeatureList(),lookups:n.parseLookupList(Oc)}:{version:i,scripts:n.parseScriptList(),features:n.parseFeatureList(),lookups:n.parseLookupList(Oc),variations:n.parseFeatureVariationsList()}}Oc[5]=function(){var e=this.offset+this.relativeOffset,t=this.parseUShort();if(1===t)return{substFormat:t,coverage:this.parsePointer(Et.coverage),ruleSets:this.parseListOfLists((function(){var e=this.parseUShort(),t=this.parseUShort();return{input:this.parseUShortList(e-1),lookupRecords:this.parseRecordList(t,Jv)}}))};if(2===t)return{substFormat:t,coverage:this.parsePointer(Et.coverage),classDef:this.parsePointer(Et.classDef),classSets:this.parseListOfLists((function(){var e=this.parseUShort(),t=this.parseUShort();return{classes:this.parseUShortList(e-1),lookupRecords:this.parseRecordList(t,Jv)}}))};if(3===t){var n=this.parseUShort(),i=this.parseUShort();return{substFormat:t,coverages:this.parseList(n,Et.pointer(Et.coverage)),lookupRecords:this.parseRecordList(i,Jv)}}Yn.assert(!1,"0x"+e.toString(16)+": lookup type 5 format must be 1, 2 or 3.")},Oc[6]=function(){var e=this.offset+this.relativeOffset,t=this.parseUShort();return 1===t?{substFormat:1,coverage:this.parsePointer(Et.coverage),chainRuleSets:this.parseListOfLists((function(){return{backtrack:this.parseUShortList(),input:this.parseUShortList(this.parseShort()-1),lookahead:this.parseUShortList(),lookupRecords:this.parseRecordList(Jv)}}))}:2===t?{substFormat:2,coverage:this.parsePointer(Et.coverage),backtrackClassDef:this.parsePointer(Et.classDef),inputClassDef:this.parsePointer(Et.classDef),lookaheadClassDef:this.parsePointer(Et.classDef),chainClassSet:this.parseListOfLists((function(){return{backtrack:this.parseUShortList(),input:this.parseUShortList(this.parseShort()-1),lookahead:this.parseUShortList(),lookupRecords:this.parseRecordList(Jv)}}))}:3===t?{substFormat:3,backtrackCoverage:this.parseList(Et.pointer(Et.coverage)),inputCoverage:this.parseList(Et.pointer(Et.coverage)),lookaheadCoverage:this.parseList(Et.pointer(Et.coverage)),lookupRecords:this.parseRecordList(Jv)}:void Yn.assert(!1,"0x"+e.toString(16)+": lookup type 6 format must be 1, 2 or 3.")},Oc[7]=function(){var e=this.parseUShort();Yn.argument(1===e,"GSUB Extension Substitution subtable identifier-format must be 1");var t=this.parseUShort(),n=new Et(this.data,this.offset+this.parseULong());return{substFormat:1,lookupType:t,extension:Oc[t].call(n)}},Oc[8]=function(){var e=this.parseUShort();return Yn.argument(1===e,"GSUB Reverse Chaining Contextual Single Substitution Subtable identifier-format must be 1"),{substFormat:e,coverage:this.parsePointer(Et.coverage),backtrackCoverage:this.parseList(Et.pointer(Et.coverage)),lookaheadCoverage:this.parseList(Et.pointer(Et.coverage)),substitutes:this.parseUShortList()}};var e1=new Array(9);function Zft(e){return new dn.Table("GSUB",[{name:"version",type:"ULONG",value:65536},{name:"scripts",type:"TABLE",value:new dn.ScriptList(e.scripts)},{name:"features",type:"TABLE",value:new dn.FeatureList(e.features)},{name:"lookups",type:"TABLE",value:new dn.LookupList(e.lookups,e1)}])}e1[1]=function(e){return 1===e.substFormat?new dn.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new dn.Coverage(e.coverage)},{name:"deltaGlyphID",type:"USHORT",value:e.deltaGlyphId}]):new dn.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:2},{name:"coverage",type:"TABLE",value:new dn.Coverage(e.coverage)}].concat(dn.ushortList("substitute",e.substitute)))},e1[2]=function(e){return Yn.assert(1===e.substFormat,"Lookup type 2 substFormat must be 1."),new dn.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new dn.Coverage(e.coverage)}].concat(dn.tableList("seqSet",e.sequences,(function(e){return new dn.Table("sequenceSetTable",dn.ushortList("sequence",e))}))))},e1[3]=function(e){return Yn.assert(1===e.substFormat,"Lookup type 3 substFormat must be 1."),new dn.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new dn.Coverage(e.coverage)}].concat(dn.tableList("altSet",e.alternateSets,(function(e){return new dn.Table("alternateSetTable",dn.ushortList("alternate",e))}))))},e1[4]=function(e){return Yn.assert(1===e.substFormat,"Lookup type 4 substFormat must be 1."),new dn.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new dn.Coverage(e.coverage)}].concat(dn.tableList("ligSet",e.ligatureSets,(function(e){return new dn.Table("ligatureSetTable",dn.tableList("ligature",e,(function(e){return new dn.Table("ligatureTable",[{name:"ligGlyph",type:"USHORT",value:e.ligGlyph}].concat(dn.ushortList("component",e.components,e.components.length+1)))})))}))))},e1[6]=function(e){if(1===e.substFormat)return new dn.Table("chainContextTable",[{name:"substFormat",type:"USHORT",value:e.substFormat},{name:"coverage",type:"TABLE",value:new dn.Coverage(e.coverage)}].concat(dn.tableList("chainRuleSet",e.chainRuleSets,(function(e){return new dn.Table("chainRuleSetTable",dn.tableList("chainRule",e,(function(e){var t=dn.ushortList("backtrackGlyph",e.backtrack,e.backtrack.length).concat(dn.ushortList("inputGlyph",e.input,e.input.length+1)).concat(dn.ushortList("lookaheadGlyph",e.lookahead,e.lookahead.length)).concat(dn.ushortList("substitution",[],e.lookupRecords.length));return e.lookupRecords.forEach((function(e,n){t=t.concat({name:"sequenceIndex"+n,type:"USHORT",value:e.sequenceIndex}).concat({name:"lookupListIndex"+n,type:"USHORT",value:e.lookupListIndex})})),new dn.Table("chainRuleTable",t)})))}))));if(2===e.substFormat)Yn.assert(!1,"lookup type 6 format 2 is not yet supported.");else if(3===e.substFormat){var t=[{name:"substFormat",type:"USHORT",value:e.substFormat}];return t.push({name:"backtrackGlyphCount",type:"USHORT",value:e.backtrackCoverage.length}),e.backtrackCoverage.forEach((function(e,n){t.push({name:"backtrackCoverage"+n,type:"TABLE",value:new dn.Coverage(e)})})),t.push({name:"inputGlyphCount",type:"USHORT",value:e.inputCoverage.length}),e.inputCoverage.forEach((function(e,n){t.push({name:"inputCoverage"+n,type:"TABLE",value:new dn.Coverage(e)})})),t.push({name:"lookaheadGlyphCount",type:"USHORT",value:e.lookaheadCoverage.length}),e.lookaheadCoverage.forEach((function(e,n){t.push({name:"lookaheadCoverage"+n,type:"TABLE",value:new dn.Coverage(e)})})),t.push({name:"substitutionCount",type:"USHORT",value:e.lookupRecords.length}),e.lookupRecords.forEach((function(e,n){t=t.concat({name:"sequenceIndex"+n,type:"USHORT",value:e.sequenceIndex}).concat({name:"lookupListIndex"+n,type:"USHORT",value:e.lookupListIndex})})),new dn.Table("chainContextTable",t)}Yn.assert(!1,"lookup type 6 format must be 1, 2 or 3.")};var zge={parse:$ft,make:Zft};function Kft(e,t){var n=new _n.Parser(e,t),i=n.parseULong();Yn.argument(1===i,"Unsupported META table version."),n.parseULong(),n.parseULong();for(var r=n.parseULong(),a={},s=0;s<r;s++){var o=n.parseTag(),l=n.parseULong(),h=n.parseULong(),u=Qv.UTF8(e,t+l,h);a[o]=u}return a}function Jft(e){var t=Object.keys(e).length,n="",i=16+12*t,r=new dn.Table("meta",[{name:"version",type:"ULONG",value:1},{name:"flags",type:"ULONG",value:0},{name:"offset",type:"ULONG",value:i},{name:"numTags",type:"ULONG",value:t}]);for(var a in e){var s=n.length;n+=e[a],r.fields.push({name:"tag "+a,type:"TAG",value:a}),r.fields.push({name:"offset "+a,type:"ULONG",value:i+s}),r.fields.push({name:"length "+a,type:"ULONG",value:e[a].length})}return r.fields.push({name:"stringPool",type:"CHARARRAY",value:n}),r}var Gge={parse:Kft,make:Jft};function Hme(e){return Math.log(e)/Math.log(2)|0}function r6(e){for(;e.length%4!=0;)e.push(0);for(var t=0,n=0;n<e.length;n+=4)t+=(e[n]<<24)+(e[n+1]<<16)+(e[n+2]<<8)+e[n+3];return t%Math.pow(2,32)}function Vme(e,t,n,i){return new dn.Record("Table Record",[{name:"tag",type:"TAG",value:void 0!==e?e:""},{name:"checkSum",type:"ULONG",value:void 0!==t?t:0},{name:"offset",type:"ULONG",value:void 0!==n?n:0},{name:"length",type:"ULONG",value:void 0!==i?i:0}])}function qge(e){var t=new dn.Table("sfnt",[{name:"version",type:"TAG",value:"OTTO"},{name:"numTables",type:"USHORT",value:0},{name:"searchRange",type:"USHORT",value:0},{name:"entrySelector",type:"USHORT",value:0},{name:"rangeShift",type:"USHORT",value:0}]);t.tables=e,t.numTables=e.length;var n=Math.pow(2,Hme(t.numTables));t.searchRange=16*n,t.entrySelector=Hme(n),t.rangeShift=16*t.numTables-t.searchRange;for(var i=[],r=[],a=t.sizeOf()+Vme().sizeOf()*t.numTables;a%4!=0;)a+=1,r.push({name:"padding",type:"BYTE",value:0});for(var s=0;s<e.length;s+=1){var o=e[s];Yn.argument(4===o.tableName.length,"Table name"+o.tableName+" is invalid.");var l=o.sizeOf(),h=Vme(o.tableName,r6(o.encode()),a,l);for(i.push({name:h.tag+" Table Record",type:"RECORD",value:h}),r.push({name:o.tableName+" table",type:"RECORD",value:o}),a+=l,Yn.argument(!isNaN(a),"Something went wrong calculating the offset.");a%4!=0;)a+=1,r.push({name:"padding",type:"BYTE",value:0})}return i.sort((function(e,t){return e.value.tag>t.value.tag?1:-1})),t.fields=t.fields.concat(i),t.fields=t.fields.concat(r),t}function zme(e,t,n){for(var i=0;i<t.length;i+=1){var r=e.charToGlyphIndex(t[i]);if(r>0)return e.glyphs.get(r).getMetrics()}return n}function Qft(e){for(var t=0,n=0;n<e.length;n+=1)t+=e[n];return t/e.length}function ept(e){for(var t,n=[],i=[],r=[],a=[],s=[],o=[],l=[],h=0,u=0,c=0,d=0,p=0,f=0;f<e.glyphs.length;f+=1){var m=e.glyphs.get(f),g=0|m.unicode;if(isNaN(m.advanceWidth))throw new Error("Glyph "+m.name+" ("+f+"): advanceWidth is not a number.");(t>g||void 0===t)&&g>0&&(t=g),h<g&&(h=g);var v=$5.getUnicodeRange(g);if(v<32)u|=1<<v;else if(v<64)c|=1<<v-32;else if(v<96)d|=1<<v-64;else{if(!(v<123))throw new Error("Unicode ranges bits > 123 are reserved for internal usage");p|=1<<v-96}if(".notdef"!==m.name){var y=m.getMetrics();n.push(y.xMin),i.push(y.yMin),r.push(y.xMax),a.push(y.yMax),o.push(y.leftSideBearing),l.push(y.rightSideBearing),s.push(m.advanceWidth)}}var x={xMin:Math.min.apply(null,n),yMin:Math.min.apply(null,i),xMax:Math.max.apply(null,r),yMax:Math.max.apply(null,a),advanceWidthMax:Math.max.apply(null,s),advanceWidthAvg:Qft(s),minLeftSideBearing:Math.min.apply(null,o),maxLeftSideBearing:Math.max.apply(null,o),minRightSideBearing:Math.min.apply(null,l)};x.ascender=e.ascender,x.descender=e.descender;var b=Ige.make({flags:3,unitsPerEm:e.unitsPerEm,xMin:x.xMin,yMin:x.yMin,xMax:x.xMax,yMax:x.yMax,lowestRecPPEM:3,createdTimestamp:e.createdTimestamp}),_=Lge.make({ascender:x.ascender,descender:x.descender,advanceWidthMax:x.advanceWidthMax,minLeftSideBearing:x.minLeftSideBearing,minRightSideBearing:x.minRightSideBearing,xMaxExtent:x.maxLeftSideBearing+(x.xMax-x.xMin),numberOfHMetrics:e.glyphs.length}),w=kge.make(e.glyphs.length),S=$5.make(Object.assign({xAvgCharWidth:Math.round(x.advanceWidthAvg),usFirstCharIndex:t,usLastCharIndex:h,ulUnicodeRange1:u,ulUnicodeRange2:c,ulUnicodeRange3:d,ulUnicodeRange4:p,sTypoAscender:x.ascender,sTypoDescender:x.descender,sTypoLineGap:0,usWinAscent:x.yMax,usWinDescent:Math.abs(x.yMin),ulCodePageRange1:1,sxHeight:zme(e,"xyvw",{yMax:Math.round(x.ascender/2)}).yMax,sCapHeight:zme(e,"HIKLEFJMNTZBDPRAGOQSUVWXY",x).yMax,usDefaultChar:e.hasChar(" ")?32:0,usBreakChar:e.hasChar(" ")?32:0},e.tables.os2)),M=Dge.make(e.glyphs),E=xge.make(e.glyphs),T=e.getEnglishName("fontFamily"),A=e.getEnglishName("fontSubfamily"),C=T+" "+A,P=e.getEnglishName("postScriptName");P||(P=T.replace(/\s/g,"")+"-"+A);var R={};for(var L in e.names)R[L]=e.names[L];R.uniqueID||(R.uniqueID={en:e.getEnglishName("manufacturer")+":"+C}),R.postScriptName||(R.postScriptName={en:P}),R.preferredFamily||(R.preferredFamily=e.names.fontFamily),R.preferredSubfamily||(R.preferredSubfamily=e.names.fontSubfamily);var I=[],k=Hge.make(R,I),O=I.length>0?Oge.make(I):void 0,D=Vge.make(),N=Pge.make(e.glyphs,{version:e.getEnglishName("version"),fullName:C,familyName:T,weightName:A,postScriptName:P,unitsPerEm:e.unitsPerEm,fontBBox:[0,x.yMin,x.ascender,x.advanceWidthMax]}),U=e.metas&&Object.keys(e.metas).length>0?Gge.make(e.metas):void 0,F=[b,_,w,S,k,E,D,N,M];O&&F.push(O),e.tables.gsub&&F.push(zge.make(e.tables.gsub)),U&&F.push(U);for(var B=qge(F),z=r6(B.encode()),H=B.fields,V=!1,j=0;j<H.length;j+=1)if("head table"===H[j].name){H[j].value.checkSumAdjustment=2981146554-z,V=!0;break}if(!V)throw new Error("Could not find head table with checkSum to adjust.");return B}var tpt={make:qge,fontToTable:ept,computeCheckSum:r6};function k5(e,t){for(var n=0,i=e.length-1;n<=i;){var r=n+i>>>1,a=e[r].tag;if(a===t)return r;a<t?n=r+1:i=r-1}return-n-1}function Gme(e,t){for(var n=0,i=e.length-1;n<=i;){var r=n+i>>>1,a=e[r];if(a===t)return r;a<t?n=r+1:i=r-1}return-n-1}function qme(e,t){for(var n,i=0,r=e.length-1;i<=r;){var a=i+r>>>1,s=(n=e[a]).start;if(s===t)return n;s<t?i=a+1:r=a-1}if(i>0)return t>(n=e[i-1]).end?0:n}function FE(e,t){this.font=e,this.tableName=t}function NE(e){FE.call(this,e,"gpos")}function Zo(e){FE.call(this,e,"gsub")}function npt(e,t){var n=e.length;if(n!==t.length)return!1;for(var i=0;i<n;i++)if(e[i]!==t[i])return!1;return!0}function i6(e,t,n){for(var i=e.subtables,r=0;r<i.length;r++){var a=i[r];if(a.substFormat===t)return a}if(n)return i.push(n),n}function rpt(){return"undefined"!=typeof window}function ipt(e){for(var t=new Buffer(e.byteLength),n=new Uint8Array(e),i=0;i<t.length;++i)t[i]=n[i];return t}function PE(e,t){if(!e)throw t}function Wme(e,t,n,i,r){var a;return(t&i)>0?(a=e.parseByte(),t&r||(a=-a),a=n+a):a=(t&r)>0?n:n+e.parseShort(),a}function Wge(e,t,n){var i,r,a=new _n.Parser(t,n);if(e.numberOfContours=a.parseShort(),e._xMin=a.parseShort(),e._yMin=a.parseShort(),e._xMax=a.parseShort(),e._yMax=a.parseShort(),e.numberOfContours>0){for(var s=e.endPointIndices=[],o=0;o<e.numberOfContours;o+=1)s.push(a.parseUShort());e.instructionLength=a.parseUShort(),e.instructions=[];for(var l=0;l<e.instructionLength;l+=1)e.instructions.push(a.parseByte());var h=s[s.length-1]+1;i=[];for(var u=0;u<h;u+=1)if(r=a.parseByte(),i.push(r),(8&r)>0)for(var c=a.parseByte(),d=0;d<c;d+=1)i.push(r),u+=1;if(Yn.argument(i.length===h,"Bad flags."),s.length>0){var p,f=[];if(h>0){for(var m=0;m<h;m+=1)r=i[m],(p={}).onCurve=!!(1&r),p.lastPointOfContour=s.indexOf(m)>=0,f.push(p);for(var g=0,v=0;v<h;v+=1)r=i[v],(p=f[v]).x=Wme(a,r,g,2,16),g=p.x;for(var y=0,x=0;x<h;x+=1)r=i[x],(p=f[x]).y=Wme(a,r,y,4,32),y=p.y}e.points=f}else e.points=[]}else if(0===e.numberOfContours)e.points=[];else{e.isComposite=!0,e.points=[],e.components=[];for(var b=!0;b;){i=a.parseUShort();var _={glyphIndex:a.parseUShort(),xScale:1,scale01:0,scale10:0,yScale:1,dx:0,dy:0};(1&i)>0?(2&i)>0?(_.dx=a.parseShort(),_.dy=a.parseShort()):_.matchedPoints=[a.parseUShort(),a.parseUShort()]:(2&i)>0?(_.dx=a.parseChar(),_.dy=a.parseChar()):_.matchedPoints=[a.parseByte(),a.parseByte()],(8&i)>0?_.xScale=_.yScale=a.parseF2Dot14():(64&i)>0?(_.xScale=a.parseF2Dot14(),_.yScale=a.parseF2Dot14()):(128&i)>0&&(_.xScale=a.parseF2Dot14(),_.scale01=a.parseF2Dot14(),_.scale10=a.parseF2Dot14(),_.yScale=a.parseF2Dot14()),e.components.push(_),b=!!(32&i)}if(256&i){e.instructionLength=a.parseUShort(),e.instructions=[];for(var w=0;w<e.instructionLength;w+=1)e.instructions.push(a.parseByte())}}}function F5(e,t){for(var n=[],i=0;i<e.length;i+=1){var r=e[i],a={x:t.xScale*r.x+t.scale01*r.y+t.dx,y:t.scale10*r.x+t.yScale*r.y+t.dy,onCurve:r.onCurve,lastPointOfContour:r.lastPointOfContour};n.push(a)}return n}function spt(e){for(var t=[],n=[],i=0;i<e.length;i+=1){var r=e[i];n.push(r),r.lastPointOfContour&&(t.push(n),n=[])}return Yn.argument(0===n.length,"There are still points left in the current contour."),t}function jge(e){var t=new ks;if(!e)return t;for(var n=spt(e),i=0;i<n.length;++i){var r=n[i],a=null,s=r[r.length-1],o=r[0];if(s.onCurve)t.moveTo(s.x,s.y);else if(o.onCurve)t.moveTo(o.x,o.y);else{var l={x:.5*(s.x+o.x),y:.5*(s.y+o.y)};t.moveTo(l.x,l.y)}for(var h=0;h<r.length;++h)if(a=s,s=o,o=r[(h+1)%r.length],s.onCurve)t.lineTo(s.x,s.y);else{var u=o;a.onCurve||(s.x,a.x,s.y,a.y),o.onCurve||(u={x:.5*(s.x+o.x),y:.5*(s.y+o.y)}),t.quadraticCurveTo(s.x,s.y,u.x,u.y)}t.closePath()}return t}function Xge(e,t){if(t.isComposite)for(var n=0;n<t.components.length;n+=1){var i=t.components[n],r=e.get(i.glyphIndex);if(r.getPath(),r.points){var a=void 0;if(void 0===i.matchedPoints)a=F5(r.points,i);else{if(i.matchedPoints[0]>t.points.length-1||i.matchedPoints[1]>r.points.length-1)throw Error("Matched points out of range in "+t.name);var s=t.points[i.matchedPoints[0]],o=r.points[i.matchedPoints[1]],l={xScale:i.xScale,scale01:i.scale01,scale10:i.scale10,yScale:i.yScale,dx:0,dy:0};o=F5([o],l)[0],l.dx=s.x-o.x,l.dy=s.y-o.y,a=F5(r.points,l)}t.points=t.points.concat(a)}}return jge(t.points)}function apt(e,t,n,i){for(var r=new Uu.GlyphSet(i),a=0;a<n.length-1;a+=1){var s=n[a];s!==n[a+1]?r.push(a,Uu.ttfGlyphLoader(i,a,Wge,e,t+s,Xge)):r.push(a,Uu.glyphLoader(i,a))}return r}function opt(e,t,n,i){var r=new Uu.GlyphSet(i);return i._push=function(a){var s=n[a];s!==n[a+1]?r.push(a,Uu.ttfGlyphLoader(i,a,Wge,e,t+s,Xge)):r.push(a,Uu.glyphLoader(i,a))},r}function lpt(e,t,n,i,r){return r.lowMemory?opt(e,t,n,i):apt(e,t,n,i)}FE.prototype={searchTag:k5,binSearch:Gme,getTable:function(e){var t=this.font.tables[this.tableName];return!t&&e&&(t=this.font.tables[this.tableName]=this.createDefaultTable()),t},getScriptNames:function(){var e=this.getTable();return e?e.scripts.map((function(e){return e.tag})):[]},getDefaultScriptName:function(){var e=this.getTable();if(e){for(var t=!1,n=0;n<e.scripts.length;n++){var i=e.scripts[n].tag;if("DFLT"===i)return i;"latn"===i&&(t=!0)}if(t)return"latn"}},getScriptTable:function(e,t){var n=this.getTable(t);if(n){e=e||"DFLT";var i=n.scripts,r=k5(n.scripts,e);if(r>=0)return i[r].script;if(t){var a={tag:e,script:{defaultLangSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]},langSysRecords:[]}};return i.splice(-1-r,0,a),a.script}}},getLangSysTable:function(e,t,n){var i=this.getScriptTable(e,n);if(i){if(!t||"dflt"===t||"DFLT"===t)return i.defaultLangSys;var r=k5(i.langSysRecords,t);if(r>=0)return i.langSysRecords[r].langSys;if(n){var a={tag:t,langSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]}};return i.langSysRecords.splice(-1-r,0,a),a.langSys}}},getFeatureTable:function(e,t,n,i){var r=this.getLangSysTable(e,t,i);if(r){for(var a,s=r.featureIndexes,o=this.font.tables[this.tableName].features,l=0;l<s.length;l++)if((a=o[s[l]]).tag===n)return a.feature;if(i){var h=o.length;return Yn.assert(0===h||n>=o[h-1].tag,"Features must be added in alphabetical order."),a={tag:n,feature:{params:0,lookupListIndexes:[]}},o.push(a),s.push(h),a.feature}}},getLookupTables:function(e,t,n,i,r){var a=this.getFeatureTable(e,t,n,r),s=[];if(a){for(var o,l=a.lookupListIndexes,h=this.font.tables[this.tableName].lookups,u=0;u<l.length;u++)(o=h[l[u]]).lookupType===i&&s.push(o);if(0===s.length&&r){o={lookupType:i,lookupFlag:0,subtables:[],markFilteringSet:void 0};var c=h.length;return h.push(o),l.push(c),[o]}}return s},getGlyphClass:function(e,t){switch(e.format){case 1:return e.startGlyph<=t&&t<e.startGlyph+e.classes.length?e.classes[t-e.startGlyph]:0;case 2:var n=qme(e.ranges,t);return n?n.classId:0}},getCoverageIndex:function(e,t){switch(e.format){case 1:var n=Gme(e.glyphs,t);return n>=0?n:-1;case 2:var i=qme(e.ranges,t);return i?i.index+t-i.start:-1}},expandCoverage:function(e){if(1===e.format)return e.glyphs;for(var t=[],n=e.ranges,i=0;i<n.length;i++)for(var r=n[i],a=r.start,s=r.end,o=a;o<=s;o++)t.push(o);return t}},NE.prototype=FE.prototype,NE.prototype.init=function(){var e=this.getDefaultScriptName();this.defaultKerningTables=this.getKerningTables(e)},NE.prototype.getKerningValue=function(e,t,n){for(var i=0;i<e.length;i++)for(var r=e[i].subtables,a=0;a<r.length;a++){var s=r[a],o=this.getCoverageIndex(s.coverage,t);if(!(o<0))switch(s.posFormat){case 1:for(var l=s.pairSets[o],h=0;h<l.length;h++){var u=l[h];if(u.secondGlyph===n)return u.value1&&u.value1.xAdvance||0}break;case 2:var c=this.getGlyphClass(s.classDef1,t),d=this.getGlyphClass(s.classDef2,n),p=s.classRecords[c][d];return p.value1&&p.value1.xAdvance||0}}return 0},NE.prototype.getKerningTables=function(e,t){if(this.font.tables.gpos)return this.getLookupTables(e,t,"kern",2)},Zo.prototype=FE.prototype,Zo.prototype.createDefaultTable=function(){return{version:1,scripts:[{tag:"DFLT",script:{defaultLangSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]},langSysRecords:[]}}],features:[],lookups:[]}},Zo.prototype.getSingle=function(e,t,n){for(var i=[],r=this.getLookupTables(t,n,e,1),a=0;a<r.length;a++)for(var s=r[a].subtables,o=0;o<s.length;o++){var l=s[o],h=this.expandCoverage(l.coverage),u=void 0;if(1===l.substFormat){var c=l.deltaGlyphId;for(u=0;u<h.length;u++){var d=h[u];i.push({sub:d,by:d+c})}}else{var p=l.substitute;for(u=0;u<h.length;u++)i.push({sub:h[u],by:p[u]})}}return i},Zo.prototype.getMultiple=function(e,t,n){for(var i=[],r=this.getLookupTables(t,n,e,2),a=0;a<r.length;a++)for(var s=r[a].subtables,o=0;o<s.length;o++){var l=s[o],h=this.expandCoverage(l.coverage),u=void 0;for(u=0;u<h.length;u++){var c=h[u],d=l.sequences[u];i.push({sub:c,by:d})}}return i},Zo.prototype.getAlternates=function(e,t,n){for(var i=[],r=this.getLookupTables(t,n,e,3),a=0;a<r.length;a++)for(var s=r[a].subtables,o=0;o<s.length;o++)for(var l=s[o],h=this.expandCoverage(l.coverage),u=l.alternateSets,c=0;c<h.length;c++)i.push({sub:h[c],by:u[c]});return i},Zo.prototype.getLigatures=function(e,t,n){for(var i=[],r=this.getLookupTables(t,n,e,4),a=0;a<r.length;a++)for(var s=r[a].subtables,o=0;o<s.length;o++)for(var l=s[o],h=this.expandCoverage(l.coverage),u=l.ligatureSets,c=0;c<h.length;c++)for(var d=h[c],p=u[c],f=0;f<p.length;f++){var m=p[f];i.push({sub:[d].concat(m.components),by:m.ligGlyph})}return i},Zo.prototype.addSingle=function(e,t,n,i){var r=i6(this.getLookupTables(n,i,e,1,!0)[0],2,{substFormat:2,coverage:{format:1,glyphs:[]},substitute:[]});Yn.assert(1===r.coverage.format,"Single: unable to modify coverage table format "+r.coverage.format);var a=t.sub,s=this.binSearch(r.coverage.glyphs,a);s<0&&(s=-1-s,r.coverage.glyphs.splice(s,0,a),r.substitute.splice(s,0,0)),r.substitute[s]=t.by},Zo.prototype.addMultiple=function(e,t,n,i){Yn.assert(t.by instanceof Array&&t.by.length>1,'Multiple: "by" must be an array of two or more ids');var r=i6(this.getLookupTables(n,i,e,2,!0)[0],1,{substFormat:1,coverage:{format:1,glyphs:[]},sequences:[]});Yn.assert(1===r.coverage.format,"Multiple: unable to modify coverage table format "+r.coverage.format);var a=t.sub,s=this.binSearch(r.coverage.glyphs,a);s<0&&(s=-1-s,r.coverage.glyphs.splice(s,0,a),r.sequences.splice(s,0,0)),r.sequences[s]=t.by},Zo.prototype.addAlternate=function(e,t,n,i){var r=i6(this.getLookupTables(n,i,e,3,!0)[0],1,{substFormat:1,coverage:{format:1,glyphs:[]},alternateSets:[]});Yn.assert(1===r.coverage.format,"Alternate: unable to modify coverage table format "+r.coverage.format);var a=t.sub,s=this.binSearch(r.coverage.glyphs,a);s<0&&(s=-1-s,r.coverage.glyphs.splice(s,0,a),r.alternateSets.splice(s,0,0)),r.alternateSets[s]=t.by},Zo.prototype.addLigature=function(e,t,n,i){var r=this.getLookupTables(n,i,e,4,!0)[0],a=r.subtables[0];a||(a={substFormat:1,coverage:{format:1,glyphs:[]},ligatureSets:[]},r.subtables[0]=a),Yn.assert(1===a.coverage.format,"Ligature: unable to modify coverage table format "+a.coverage.format);var s=t.sub[0],o=t.sub.slice(1),l={ligGlyph:t.by,components:o},h=this.binSearch(a.coverage.glyphs,s);if(h>=0){for(var u=a.ligatureSets[h],c=0;c<u.length;c++)if(npt(u[c].components,o))return;u.push(l)}else h=-1-h,a.coverage.glyphs.splice(h,0,s),a.ligatureSets.splice(h,0,[l])},Zo.prototype.getFeature=function(e,t,n){if(/ss\d\d/.test(e))return this.getSingle(e,t,n);switch(e){case"aalt":case"salt":return this.getSingle(e,t,n).concat(this.getAlternates(e,t,n));case"dlig":case"liga":case"rlig":return this.getLigatures(e,t,n);case"ccmp":return this.getMultiple(e,t,n).concat(this.getLigatures(e,t,n));case"stch":return this.getMultiple(e,t,n)}},Zo.prototype.add=function(e,t,n,i){if(/ss\d\d/.test(e))return this.addSingle(e,t,n,i);switch(e){case"aalt":case"salt":return"number"==typeof t.by?this.addSingle(e,t,n,i):this.addAlternate(e,t,n,i);case"dlig":case"liga":case"rlig":return this.addLigature(e,t,n,i);case"ccmp":return t.by instanceof Array?this.addMultiple(e,t,n,i):this.addLigature(e,t,n,i)}};var Yge={getPath:jge,parse:lpt},$ge,Vm,Zge,Z5;function Kge(e){this.font=e,this.getCommands=function(e){return Yge.getPath(e).commands},this._fpgmState=this._prepState=void 0,this._errorState=0}function cpt(e){return e}function Jge(e){return Math.sign(e)*Math.round(Math.abs(e))}function upt(e){return Math.sign(e)*Math.round(Math.abs(2*e))/2}function hpt(e){return Math.sign(e)*(Math.round(Math.abs(e)+.5)-.5)}function dpt(e){return Math.sign(e)*Math.ceil(Math.abs(e))}function fpt(e){return Math.sign(e)*Math.floor(Math.abs(e))}var Qge=function(e){var t=this.srPeriod,n=this.srPhase,i=1;return e<0&&(e=-e,i=-1),e+=this.srThreshold-n,e=Math.trunc(e/t)*t,(e+=n)<0?n*i:e*i},Bu={x:1,y:0,axis:"x",distance:function(e,t,n,i){return(n?e.xo:e.x)-(i?t.xo:t.x)},interpolate:function(e,t,n,i){var r,a,s,o,l,h,u;if(!i||i===this)return r=e.xo-t.xo,a=e.xo-n.xo,l=t.x-t.xo,h=n.x-n.xo,0===(u=(s=Math.abs(r))+(o=Math.abs(a)))?void(e.x=e.xo+(l+h)/2):void(e.x=e.xo+(l*o+h*s)/u);r=i.distance(e,t,!0,!0),a=i.distance(e,n,!0,!0),l=i.distance(t,t,!1,!0),h=i.distance(n,n,!1,!0),0!==(u=(s=Math.abs(r))+(o=Math.abs(a)))?Bu.setRelative(e,e,(l*o+h*s)/u,i,!0):Bu.setRelative(e,e,(l+h)/2,i,!0)},normalSlope:Number.NEGATIVE_INFINITY,setRelative:function(e,t,n,i,r){if(i&&i!==this){var a=r?t.xo:t.x,s=r?t.yo:t.y,o=a+n*i.x,l=s+n*i.y;e.x=o+(e.y-l)/i.normalSlope}else e.x=(r?t.xo:t.x)+n},slope:0,touch:function(e){e.xTouched=!0},touched:function(e){return e.xTouched},untouch:function(e){e.xTouched=!1}},Qh={x:0,y:1,axis:"y",distance:function(e,t,n,i){return(n?e.yo:e.y)-(i?t.yo:t.y)},interpolate:function(e,t,n,i){var r,a,s,o,l,h,u;if(!i||i===this)return r=e.yo-t.yo,a=e.yo-n.yo,l=t.y-t.yo,h=n.y-n.yo,0===(u=(s=Math.abs(r))+(o=Math.abs(a)))?void(e.y=e.yo+(l+h)/2):void(e.y=e.yo+(l*o+h*s)/u);r=i.distance(e,t,!0,!0),a=i.distance(e,n,!0,!0),l=i.distance(t,t,!1,!0),h=i.distance(n,n,!1,!0),0!==(u=(s=Math.abs(r))+(o=Math.abs(a)))?Qh.setRelative(e,e,(l*o+h*s)/u,i,!0):Qh.setRelative(e,e,(l+h)/2,i,!0)},normalSlope:0,setRelative:function(e,t,n,i,r){if(i&&i!==this){var a=r?t.xo:t.x,s=r?t.yo:t.y,o=a+n*i.x,l=s+n*i.y;e.y=l+i.normalSlope*(e.x-o)}else e.y=(r?t.yo:t.y)+n},slope:Number.POSITIVE_INFINITY,touch:function(e){e.yTouched=!0},touched:function(e){return e.yTouched},untouch:function(e){e.yTouched=!1}};function BE(e,t){this.x=e,this.y=t,this.axis=void 0,this.slope=t/e,this.normalSlope=-e/t,Object.freeze(this)}function UE(e,t){var n=Math.sqrt(e*e+t*t);return t/=n,1===(e/=n)&&0===t?Bu:0===e&&1===t?Qh:new BE(e,t)}function ed(e,t,n,i){this.x=this.xo=Math.round(64*e)/64,this.y=this.yo=Math.round(64*t)/64,this.lastPointOfContour=n,this.onCurve=i,this.prevPointOnContour=void 0,this.nextPointOnContour=void 0,this.xTouched=!1,this.yTouched=!1,Object.preventExtensions(this)}Object.freeze(Bu),Object.freeze(Qh),BE.prototype.distance=function(e,t,n,i){return this.x*Bu.distance(e,t,n,i)+this.y*Qh.distance(e,t,n,i)},BE.prototype.interpolate=function(e,t,n,i){var r,a,s,o,l,h,u;s=i.distance(e,t,!0,!0),o=i.distance(e,n,!0,!0),r=i.distance(t,t,!1,!0),a=i.distance(n,n,!1,!0),0!==(u=(l=Math.abs(s))+(h=Math.abs(o)))?this.setRelative(e,e,(r*h+a*l)/u,i,!0):this.setRelative(e,e,(r+a)/2,i,!0)},BE.prototype.setRelative=function(e,t,n,i,r){i=i||this;var a=r?t.xo:t.x,s=r?t.yo:t.y,o=a+n*i.x,l=s+n*i.y,h=i.normalSlope,u=this.slope,c=e.x,d=e.y;e.x=(u*c-h*o+l-d)/(u-h),e.y=u*(e.x-c)+d},BE.prototype.touch=function(e){e.xTouched=!0,e.yTouched=!0},ed.prototype.nextTouched=function(e){for(var t=this.nextPointOnContour;!e.touched(t)&&t!==this;)t=t.nextPointOnContour;return t},ed.prototype.prevTouched=function(e){for(var t=this.prevPointOnContour;!e.touched(t)&&t!==this;)t=t.prevPointOnContour;return t};var kE=Object.freeze(new ed(0,0)),ppt={cvCutIn:17/16,deltaBase:9,deltaShift:.125,loop:1,minDis:1,autoFlip:!0};function Sf(e,t){switch(this.env=e,this.stack=[],this.prog=t,e){case"glyf":this.zp0=this.zp1=this.zp2=1,this.rp0=this.rp1=this.rp2=0;case"prep":this.fv=this.pv=this.dpv=Bu,this.round=Jge}}function MC(e){for(var t=e.tZone=new Array(e.gZone.length),n=0;n<t.length;n++)t[n]=new ed(0,0)}function e0e(e,t){var n,i=e.prog,r=e.ip,a=1;do{if(88===(n=i[++r]))a++;else if(89===n)a--;else if(64===n)r+=i[r+1]+1;else if(65===n)r+=2*i[r+1]+1;else if(n>=176&&n<=183)r+=n-176+1;else if(n>=184&&n<=191)r+=2*(n-184+1);else if(t&&1===a&&27===n)break}while(a>0);e.ip=r}function jme(e,t){exports.DEBUG&&console.log(t.step,"SVTCA["+e.axis+"]"),t.fv=t.pv=t.dpv=e}function Xme(e,t){exports.DEBUG&&console.log(t.step,"SPVTCA["+e.axis+"]"),t.pv=t.dpv=e}function Yme(e,t){exports.DEBUG&&console.log(t.step,"SFVTCA["+e.axis+"]"),t.fv=e}function $me(e,t){var n,i,r=t.stack,a=r.pop(),s=r.pop(),o=t.z2[a],l=t.z1[s];exports.DEBUG&&console.log("SPVTL["+e+"]",a,s),e?(n=o.y-l.y,i=l.x-o.x):(n=l.x-o.x,i=l.y-o.y),t.pv=t.dpv=UE(n,i)}function Zme(e,t){var n,i,r=t.stack,a=r.pop(),s=r.pop(),o=t.z2[a],l=t.z1[s];exports.DEBUG&&console.log("SFVTL["+e+"]",a,s),e?(n=o.y-l.y,i=l.x-o.x):(n=l.x-o.x,i=l.y-o.y),t.fv=UE(n,i)}function mpt(e){var t=e.stack,n=t.pop(),i=t.pop();exports.DEBUG&&console.log(e.step,"SPVFS[]",n,i),e.pv=e.dpv=UE(i,n)}function gpt(e){var t=e.stack,n=t.pop(),i=t.pop();exports.DEBUG&&console.log(e.step,"SPVFS[]",n,i),e.fv=UE(i,n)}function vpt(e){var t=e.stack,n=e.pv;exports.DEBUG&&console.log(e.step,"GPV[]"),t.push(16384*n.x),t.push(16384*n.y)}function ypt(e){var t=e.stack,n=e.fv;exports.DEBUG&&console.log(e.step,"GFV[]"),t.push(16384*n.x),t.push(16384*n.y)}function xpt(e){e.fv=e.pv,exports.DEBUG&&console.log(e.step,"SFVTPV[]")}function bpt(e){var t=e.stack,n=t.pop(),i=t.pop(),r=t.pop(),a=t.pop(),s=t.pop(),o=e.z0,l=e.z1,h=o[n],u=o[i],c=l[r],d=l[a],p=e.z2[s];exports.DEBUG&&console.log("ISECT[], ",n,i,r,a,s);var f=h.x,m=h.y,g=u.x,v=u.y,y=c.x,x=c.y,b=d.x,_=d.y,w=(f-g)*(x-_)-(m-v)*(y-b),S=f*v-m*g,M=y*_-x*b;p.x=(S*(y-b)-M*(f-g))/w,p.y=(S*(x-_)-M*(m-v))/w}function Ept(e){e.rp0=e.stack.pop(),exports.DEBUG&&console.log(e.step,"SRP0[]",e.rp0)}function _pt(e){e.rp1=e.stack.pop(),exports.DEBUG&&console.log(e.step,"SRP1[]",e.rp1)}function Tpt(e){e.rp2=e.stack.pop(),exports.DEBUG&&console.log(e.step,"SRP2[]",e.rp2)}function wpt(e){var t=e.stack.pop();switch(exports.DEBUG&&console.log(e.step,"SZP0[]",t),e.zp0=t,t){case 0:e.tZone||MC(e),e.z0=e.tZone;break;case 1:e.z0=e.gZone;break;default:throw new Error("Invalid zone pointer")}}function Spt(e){var t=e.stack.pop();switch(exports.DEBUG&&console.log(e.step,"SZP1[]",t),e.zp1=t,t){case 0:e.tZone||MC(e),e.z1=e.tZone;break;case 1:e.z1=e.gZone;break;default:throw new Error("Invalid zone pointer")}}function Mpt(e){var t=e.stack.pop();switch(exports.DEBUG&&console.log(e.step,"SZP2[]",t),e.zp2=t,t){case 0:e.tZone||MC(e),e.z2=e.tZone;break;case 1:e.z2=e.gZone;break;default:throw new Error("Invalid zone pointer")}}function Apt(e){var t=e.stack.pop();switch(exports.DEBUG&&console.log(e.step,"SZPS[]",t),e.zp0=e.zp1=e.zp2=t,t){case 0:e.tZone||MC(e),e.z0=e.z1=e.z2=e.tZone;break;case 1:e.z0=e.z1=e.z2=e.gZone;break;default:throw new Error("Invalid zone pointer")}}function Rpt(e){e.loop=e.stack.pop(),exports.DEBUG&&console.log(e.step,"SLOOP[]",e.loop)}function Cpt(e){exports.DEBUG&&console.log(e.step,"RTG[]"),e.round=Jge}function Ppt(e){exports.DEBUG&&console.log(e.step,"RTHG[]"),e.round=hpt}function Ipt(e){var t=e.stack.pop();exports.DEBUG&&console.log(e.step,"SMD[]",t),e.minDis=t/64}function Lpt(e){exports.DEBUG&&console.log(e.step,"ELSE[]"),e0e(e,!1)}function Dpt(e){var t=e.stack.pop();exports.DEBUG&&console.log(e.step,"JMPR[]",t),e.ip+=t-1}function Opt(e){var t=e.stack.pop();exports.DEBUG&&console.log(e.step,"SCVTCI[]",t),e.cvCutIn=t/64}function kpt(e){var t=e.stack;exports.DEBUG&&console.log(e.step,"DUP[]"),t.push(t[t.length-1])}function N5(e){exports.DEBUG&&console.log(e.step,"POP[]"),e.stack.pop()}function Fpt(e){exports.DEBUG&&console.log(e.step,"CLEAR[]"),e.stack.length=0}function Npt(e){var t=e.stack,n=t.pop(),i=t.pop();exports.DEBUG&&console.log(e.step,"SWAP[]"),t.push(n),t.push(i)}function Bpt(e){var t=e.stack;exports.DEBUG&&console.log(e.step,"DEPTH[]"),t.push(t.length)}function Upt(e){var t=e.stack,n=t.pop(),i=t.pop();exports.DEBUG&&console.log(e.step,"LOOPCALL[]",n,i);var r=e.ip,a=e.prog;e.prog=e.funcs[n];for(var s=0;s<i;s++)Vm(e),exports.DEBUG&&console.log(++e.step,s+1<i?"next loopcall":"done loopcall",s);e.ip=r,e.prog=a}function Hpt(e){var t=e.stack.pop();exports.DEBUG&&console.log(e.step,"CALL[]",t);var n=e.ip,i=e.prog;e.prog=e.funcs[t],Vm(e),e.ip=n,e.prog=i,exports.DEBUG&&console.log(++e.step,"returning from",t)}function Vpt(e){var t=e.stack,n=t.pop();exports.DEBUG&&console.log(e.step,"CINDEX[]",n),t.push(t[t.length-n])}function zpt(e){var t=e.stack,n=t.pop();exports.DEBUG&&console.log(e.step,"MINDEX[]",n),t.push(t.splice(t.length-n,1)[0])}function Gpt(e){if("fpgm"!==e.env)throw new Error("FDEF not allowed here");var t=e.stack,n=e.prog,i=e.ip,r=t.pop(),a=i;for(exports.DEBUG&&console.log(e.step,"FDEF[]",r);45!==n[++i];);e.ip=i,e.funcs[r]=n.slice(a+1,i)}function Kme(e,t){var n=t.stack.pop(),i=t.z0[n],r=t.fv,a=t.pv;exports.DEBUG&&console.log(t.step,"MDAP["+e+"]",n);var s=a.distance(i,kE);e&&(s=t.round(s)),r.setRelative(i,kE,s,a),r.touch(i),t.rp0=t.rp1=n}function Jme(e,t){var n,i,r,a=t.z2,s=a.length-2;exports.DEBUG&&console.log(t.step,"IUP["+e.axis+"]");for(var o=0;o<s;o++)n=a[o],!e.touched(n)&&(i=n.prevTouched(e))!==n&&(i===(r=n.nextTouched(e))&&e.setRelative(n,n,e.distance(i,i,!1,!0),e,!0),e.interpolate(n,i,r,e))}function Qme(e,t){for(var n=t.stack,i=e?t.rp1:t.rp2,r=(e?t.z0:t.z1)[i],a=t.fv,s=t.pv,o=t.loop,l=t.z2;o--;){var h=n.pop(),u=l[h],c=s.distance(r,r,!1,!0);a.setRelative(u,u,c,s),a.touch(u),exports.DEBUG&&console.log(t.step,(t.loop>1?"loop "+(t.loop-o)+": ":"")+"SHP["+(e?"rp1":"rp2")+"]",h)}t.loop=1}function ege(e,t){var n=t.stack,i=e?t.rp1:t.rp2,r=(e?t.z0:t.z1)[i],a=t.fv,s=t.pv,o=n.pop(),l=t.z2[t.contours[o]],h=l;exports.DEBUG&&console.log(t.step,"SHC["+e+"]",o);var u=s.distance(r,r,!1,!0);do{h!==r&&a.setRelative(h,h,u,s),h=h.nextPointOnContour}while(h!==l)}function tge(e,t){var n,i=t.stack,r=e?t.rp1:t.rp2,a=(e?t.z0:t.z1)[r],s=t.fv,o=t.pv,l=i.pop();switch(exports.DEBUG&&console.log(t.step,"SHZ["+e+"]",l),l){case 0:n=t.tZone;break;case 1:n=t.gZone;break;default:throw new Error("Invalid zone")}for(var h,u=o.distance(a,a,!1,!0),c=n.length-2,d=0;d<c;d++)h=n[d],s.setRelative(h,h,u,o)}function qpt(e){for(var t=e.stack,n=e.loop,i=e.fv,r=t.pop()/64,a=e.z2;n--;){var s=t.pop(),o=a[s];exports.DEBUG&&console.log(e.step,(e.loop>1?"loop "+(e.loop-n)+": ":"")+"SHPIX[]",s,r),i.setRelative(o,o,r),i.touch(o)}e.loop=1}function Wpt(e){for(var t=e.stack,n=e.rp1,i=e.rp2,r=e.loop,a=e.z0[n],s=e.z1[i],o=e.fv,l=e.dpv,h=e.z2;r--;){var u=t.pop(),c=h[u];exports.DEBUG&&console.log(e.step,(e.loop>1?"loop "+(e.loop-r)+": ":"")+"IP[]",u,n,"<->",i),o.interpolate(c,a,s,l),o.touch(c)}e.loop=1}function nge(e,t){var n=t.stack,i=n.pop()/64,r=n.pop(),a=t.z1[r],s=t.z0[t.rp0],o=t.fv,l=t.pv;o.setRelative(a,s,i,l),o.touch(a),exports.DEBUG&&console.log(t.step,"MSIRP["+e+"]",i,r),t.rp1=t.rp0,t.rp2=r,e&&(t.rp0=r)}function jpt(e){for(var t=e.stack,n=e.rp0,i=e.z0[n],r=e.loop,a=e.fv,s=e.pv,o=e.z1;r--;){var l=t.pop(),h=o[l];exports.DEBUG&&console.log(e.step,(e.loop>1?"loop "+(e.loop-r)+": ":"")+"ALIGNRP[]",l),a.setRelative(h,i,0,s),a.touch(h)}e.loop=1}function Xpt(e){exports.DEBUG&&console.log(e.step,"RTDG[]"),e.round=upt}function rge(e,t){var n=t.stack,i=n.pop(),r=n.pop(),a=t.z0[r],s=t.fv,o=t.pv,l=t.cvt[i];exports.DEBUG&&console.log(t.step,"MIAP["+e+"]",i,"(",l,")",r);var h=o.distance(a,kE);e&&(Math.abs(h-l)<t.cvCutIn&&(h=l),h=t.round(h)),s.setRelative(a,kE,h,o),0===t.zp0&&(a.xo=a.x,a.yo=a.y),s.touch(a),t.rp0=t.rp1=r}function Ypt(e){var t=e.prog,n=e.ip,i=e.stack,r=t[++n];exports.DEBUG&&console.log(e.step,"NPUSHB[]",r);for(var a=0;a<r;a++)i.push(t[++n]);e.ip=n}function $pt(e){var t=e.ip,n=e.prog,i=e.stack,r=n[++t];exports.DEBUG&&console.log(e.step,"NPUSHW[]",r);for(var a=0;a<r;a++){var s=n[++t]<<8|n[++t];32768&s&&(s=-(1+(65535^s))),i.push(s)}e.ip=t}function Zpt(e){var t=e.stack,n=e.store;n||(n=e.store=[]);var i=t.pop(),r=t.pop();exports.DEBUG&&console.log(e.step,"WS",i,r),n[r]=i}function Kpt(e){var t=e.stack,n=e.store,i=t.pop();exports.DEBUG&&console.log(e.step,"RS",i);var r=n&&n[i]||0;t.push(r)}function Jpt(e){var t=e.stack,n=t.pop(),i=t.pop();exports.DEBUG&&console.log(e.step,"WCVTP",n,i),e.cvt[i]=n/64}function Qpt(e){var t=e.stack,n=t.pop();exports.DEBUG&&console.log(e.step,"RCVT",n),t.push(64*e.cvt[n])}function ige(e,t){var n=t.stack,i=n.pop(),r=t.z2[i];exports.DEBUG&&console.log(t.step,"GC["+e+"]",i),n.push(64*t.dpv.distance(r,kE,e,!1))}function sge(e,t){var n=t.stack,i=n.pop(),r=n.pop(),a=t.z1[i],s=t.z0[r],o=t.dpv.distance(s,a,e,e);exports.DEBUG&&console.log(t.step,"MD["+e+"]",i,r,"->",o),t.stack.push(Math.round(64*o))}function emt(e){exports.DEBUG&&console.log(e.step,"MPPEM[]"),e.stack.push(e.ppem)}function tmt(e){exports.DEBUG&&console.log(e.step,"FLIPON[]"),e.autoFlip=!0}function nmt(e){var t=e.stack,n=t.pop(),i=t.pop();exports.DEBUG&&console.log(e.step,"LT[]",n,i),t.push(i<n?1:0)}function rmt(e){var t=e.stack,n=t.pop(),i=t.pop();exports.DEBUG&&console.log(e.step,"LTEQ[]",n,i),t.push(i<=n?1:0)}function imt(e){var t=e.stack,n=t.pop(),i=t.pop();exports.DEBUG&&console.log(e.step,"GT[]",n,i),t.push(i>n?1:0)}function smt(e){var t=e.stack,n=t.pop(),i=t.pop();exports.DEBUG&&console.log(e.step,"GTEQ[]",n,i),t.push(i>=n?1:0)}function amt(e){var t=e.stack,n=t.pop(),i=t.pop();exports.DEBUG&&console.log(e.step,"EQ[]",n,i),t.push(n===i?1:0)}function omt(e){var t=e.stack,n=t.pop(),i=t.pop();exports.DEBUG&&console.log(e.step,"NEQ[]",n,i),t.push(n!==i?1:0)}function lmt(e){var t=e.stack,n=t.pop();exports.DEBUG&&console.log(e.step,"ODD[]",n),t.push(Math.trunc(n)%2?1:0)}function cmt(e){var t=e.stack,n=t.pop();exports.DEBUG&&console.log(e.step,"EVEN[]",n),t.push(Math.trunc(n)%2?0:1)}function umt(e){var t=e.stack.pop();exports.DEBUG&&console.log(e.step,"IF[]",t),t||(e0e(e,!0),exports.DEBUG&&console.log(e.step,"EIF[]"))}function hmt(e){exports.DEBUG&&console.log(e.step,"EIF[]")}function dmt(e){var t=e.stack,n=t.pop(),i=t.pop();exports.DEBUG&&console.log(e.step,"AND[]",n,i),t.push(n&&i?1:0)}function fmt(e){var t=e.stack,n=t.pop(),i=t.pop();exports.DEBUG&&console.log(e.step,"OR[]",n,i),t.push(n||i?1:0)}function pmt(e){var t=e.stack,n=t.pop();exports.DEBUG&&console.log(e.step,"NOT[]",n),t.push(n?0:1)}function B5(e,t){var n=t.stack,i=n.pop(),r=t.fv,a=t.pv,s=t.ppem,o=t.deltaBase+16*(e-1),l=t.deltaShift,h=t.z0;exports.DEBUG&&console.log(t.step,"DELTAP["+e+"]",i,n);for(var u=0;u<i;u++){var c=n.pop(),d=n.pop();if(o+((240&d)>>4)===s){var p=(15&d)-8;p>=0&&p++,exports.DEBUG&&console.log(t.step,"DELTAPFIX",c,"by",p*l);var f=h[c];r.setRelative(f,f,p*l,a)}}}function mmt(e){var t=e.stack.pop();exports.DEBUG&&console.log(e.step,"SDB[]",t),e.deltaBase=t}function gmt(e){var t=e.stack.pop();exports.DEBUG&&console.log(e.step,"SDS[]",t),e.deltaShift=Math.pow(.5,t)}function vmt(e){var t=e.stack,n=t.pop(),i=t.pop();exports.DEBUG&&console.log(e.step,"ADD[]",n,i),t.push(i+n)}function ymt(e){var t=e.stack,n=t.pop(),i=t.pop();exports.DEBUG&&console.log(e.step,"SUB[]",n,i),t.push(i-n)}function xmt(e){var t=e.stack,n=t.pop(),i=t.pop();exports.DEBUG&&console.log(e.step,"DIV[]",n,i),t.push(64*i/n)}function bmt(e){var t=e.stack,n=t.pop(),i=t.pop();exports.DEBUG&&console.log(e.step,"MUL[]",n,i),t.push(i*n/64)}function Emt(e){var t=e.stack,n=t.pop();exports.DEBUG&&console.log(e.step,"ABS[]",n),t.push(Math.abs(n))}function _mt(e){var t=e.stack,n=t.pop();exports.DEBUG&&console.log(e.step,"NEG[]",n),t.push(-n)}function Tmt(e){var t=e.stack,n=t.pop();exports.DEBUG&&console.log(e.step,"FLOOR[]",n),t.push(64*Math.floor(n/64))}function wmt(e){var t=e.stack,n=t.pop();exports.DEBUG&&console.log(e.step,"CEILING[]",n),t.push(64*Math.ceil(n/64))}function vC(e,t){var n=t.stack,i=n.pop();exports.DEBUG&&console.log(t.step,"ROUND[]"),n.push(64*t.round(i/64))}function Smt(e){var t=e.stack,n=t.pop(),i=t.pop();exports.DEBUG&&console.log(e.step,"WCVTF[]",n,i),e.cvt[i]=n*e.ppem/e.font.unitsPerEm}function U5(e,t){var n=t.stack,i=n.pop(),r=t.ppem,a=t.deltaBase+16*(e-1),s=t.deltaShift;exports.DEBUG&&console.log(t.step,"DELTAC["+e+"]",i,n);for(var o=0;o<i;o++){var l=n.pop(),h=n.pop();if(a+((240&h)>>4)===r){var u=(15&h)-8;u>=0&&u++;var c=u*s;exports.DEBUG&&console.log(t.step,"DELTACFIX",l,"by",c),t.cvt[l]+=c}}}function Mmt(e){var t,n=e.stack.pop();switch(exports.DEBUG&&console.log(e.step,"SROUND[]",n),e.round=Qge,192&n){case 0:t=.5;break;case 64:t=1;break;case 128:t=2;break;default:throw new Error("invalid SROUND value")}switch(e.srPeriod=t,48&n){case 0:e.srPhase=0;break;case 16:e.srPhase=.25*t;break;case 32:e.srPhase=.5*t;break;case 48:e.srPhase=.75*t;break;default:throw new Error("invalid SROUND value")}n&=15,e.srThreshold=0===n?0:(n/8-.5)*t}function Amt(e){var t,n=e.stack.pop();switch(exports.DEBUG&&console.log(e.step,"S45ROUND[]",n),e.round=Qge,192&n){case 0:t=Math.sqrt(2)/2;break;case 64:t=Math.sqrt(2);break;case 128:t=2*Math.sqrt(2);break;default:throw new Error("invalid S45ROUND value")}switch(e.srPeriod=t,48&n){case 0:e.srPhase=0;break;case 16:e.srPhase=.25*t;break;case 32:e.srPhase=.5*t;break;case 48:e.srPhase=.75*t;break;default:throw new Error("invalid S45ROUND value")}n&=15,e.srThreshold=0===n?0:(n/8-.5)*t}function Rmt(e){exports.DEBUG&&console.log(e.step,"ROFF[]"),e.round=cpt}function Cmt(e){exports.DEBUG&&console.log(e.step,"RUTG[]"),e.round=dpt}function Pmt(e){exports.DEBUG&&console.log(e.step,"RDTG[]"),e.round=fpt}function Imt(e){var t=e.stack.pop();exports.DEBUG&&console.log(e.step,"SCANCTRL[]",t)}function age(e,t){var n,i,r=t.stack,a=r.pop(),s=r.pop(),o=t.z2[a],l=t.z1[s];exports.DEBUG&&console.log(t.step,"SDPVTL["+e+"]",a,s),e?(n=o.y-l.y,i=l.x-o.x):(n=l.x-o.x,i=l.y-o.y),t.dpv=UE(n,i)}function Lmt(e){var t=e.stack,n=t.pop(),i=0;exports.DEBUG&&console.log(e.step,"GETINFO[]",n),1&n&&(i=35),32&n&&(i|=4096),t.push(i)}function Dmt(e){var t=e.stack,n=t.pop(),i=t.pop(),r=t.pop();exports.DEBUG&&console.log(e.step,"ROLL[]"),t.push(i),t.push(n),t.push(r)}function Omt(e){var t=e.stack,n=t.pop(),i=t.pop();exports.DEBUG&&console.log(e.step,"MAX[]",n,i),t.push(Math.max(i,n))}function kmt(e){var t=e.stack,n=t.pop(),i=t.pop();exports.DEBUG&&console.log(e.step,"MIN[]",n,i),t.push(Math.min(i,n))}function Fmt(e){var t=e.stack.pop();exports.DEBUG&&console.log(e.step,"SCANTYPE[]",t)}function Nmt(e){var t=e.stack.pop(),n=e.stack.pop();switch(exports.DEBUG&&console.log(e.step,"INSTCTRL[]",t,n),t){case 1:return void(e.inhibitGridFit=!!n);case 2:return void(e.ignoreCvt=!!n);default:throw new Error("invalid INSTCTRL[] selector")}}function _f(e,t){var n=t.stack,i=t.prog,r=t.ip;exports.DEBUG&&console.log(t.step,"PUSHB["+e+"]");for(var a=0;a<e;a++)n.push(i[++r]);t.ip=r}function Tf(e,t){var n=t.ip,i=t.prog,r=t.stack;exports.DEBUG&&console.log(t.ip,"PUSHW["+e+"]");for(var a=0;a<e;a++){var s=i[++n]<<8|i[++n];32768&s&&(s=-(1+(65535^s))),r.push(s)}t.ip=n}function xn(e,t,n,i,r,a){var s,o,l,h,u=a.stack,c=e&&u.pop(),d=u.pop(),p=a.rp0,f=a.z0[p],m=a.z1[d],g=a.minDis,v=a.fv,y=a.dpv;l=(o=s=y.distance(m,f,!0,!0))>=0?1:-1,o=Math.abs(o),e&&(h=a.cvt[c],i&&Math.abs(o-h)<a.cvCutIn&&(o=h)),n&&o<g&&(o=g),i&&(o=a.round(o)),v.setRelative(m,f,l*o,y),v.touch(m),exports.DEBUG&&console.log(a.step,(e?"MIRP[":"MDRP[")+(t?"M":"m")+(n?">":"_")+(i?"R":"_")+(0===r?"Gr":1===r?"Bl":2===r?"Wh":"")+"]",e?c+"("+a.cvt[c]+","+h+")":"",d,"(d =",s,"->",l*o,")"),a.rp1=a.rp0,a.rp2=d,t&&(a.rp0=d)}function t1(e){this.char=e,this.state={},this.activeState=null}function s6(e,t,n){this.contextName=n,this.startIndex=e,this.endOffset=t}function Bmt(e,t,n){this.contextName=e,this.openRange=null,this.ranges=[],this.checkStart=t,this.checkEnd=n}function kc(e,t){this.context=e,this.index=t,this.length=e.length,this.current=e[t],this.backtrack=e.slice(0,t),this.lookahead=e.slice(t+1)}function AC(e){this.eventId=e,this.subscribers=[]}function Umt(e){var t=this,n=["start","end","next","newToken","contextStart","contextEnd","insertToken","removeToken","removeRange","replaceToken","replaceRange","composeRUD","updateContextsRanges"];n.forEach((function(e){Object.defineProperty(t.events,e,{value:new AC(e)})})),e&&n.forEach((function(n){var i=e[n];"function"==typeof i&&t.events[n].subscribe(i)})),["insertToken","removeToken","removeRange","replaceToken","replaceRange","composeRUD"].forEach((function(e){t.events[e].subscribe(t.updateContextsRanges)}))}function ds(e){this.tokens=[],this.registeredContexts={},this.contextCheckers=[],this.events={},this.registeredModifiers=[],Umt.call(this,e)}function Mf(e){return/[\u0600-\u065F\u066A-\u06D2\u06FA-\u06FF]/.test(e)}function t0e(e){return/[\u0630\u0690\u0621\u0631\u0661\u0671\u0622\u0632\u0672\u0692\u06C2\u0623\u0673\u0693\u06C3\u0624\u0694\u06C4\u0625\u0675\u0695\u06C5\u06E5\u0676\u0696\u06C6\u0627\u0677\u0697\u06C7\u0648\u0688\u0698\u06C8\u0689\u0699\u06C9\u068A\u06CA\u066B\u068B\u06CB\u068C\u068D\u06CD\u06FD\u068E\u06EE\u06FE\u062F\u068F\u06CF\u06EF]/.test(e)}function Af(e){return/[\u0600-\u0605\u060C-\u060E\u0610-\u061B\u061E\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED]/.test(e)}function xC(e){return/[A-z]/.test(e)}function Hmt(e){return/\s/.test(e)}function Ko(e){this.font=e,this.features={}}function Hm(e){this.id=e.id,this.tag=e.tag,this.substitution=e.substitution}function HE(e,t){if(!e)return-1;switch(t.format){case 1:return t.glyphs.indexOf(e);case 2:for(var n=t.ranges,i=0;i<n.length;i++){var r=n[i];if(e>=r.start&&e<=r.end){var a=e-r.start;return r.index+a}}break;default:return-1}return-1}function Vmt(e,t){return-1===HE(e,t.coverage)?null:e+t.deltaGlyphId}function zmt(e,t){var n=HE(e,t.coverage);return-1===n?null:t.substitute[n]}function H5(e,t){for(var n=[],i=0;i<e.length;i++){var r=e[i],a=t.current,s=HE(a=Array.isArray(a)?a[0]:a,r);-1!==s&&n.push(s)}return n.length!==e.length?-1:n}function Gmt(e,t){var n=t.inputCoverage.length+t.lookaheadCoverage.length+t.backtrackCoverage.length;if(e.context.length<n)return[];var i=H5(t.inputCoverage,e);if(-1===i)return[];var r=t.inputCoverage.length-1;if(e.lookahead.length<t.lookaheadCoverage.length)return[];for(var a=e.lookahead.slice(r);a.length&&Af(a[0].char);)a.shift();var s=new kc(a,0),o=H5(t.lookaheadCoverage,s),l=[].concat(e.backtrack);for(l.reverse();l.length&&Af(l[0].char);)l.shift();if(l.length<t.backtrackCoverage.length)return[];var h=new kc(l,0),u=H5(t.backtrackCoverage,h),c=[];if(i.length===t.inputCoverage.length&&o.length===t.lookaheadCoverage.length&&u.length===t.backtrackCoverage.length)for(var d=0;d<t.lookupRecords.length;d++)for(var p=t.lookupRecords[d].lookupListIndex,f=this.getLookupByIndex(p),m=0;m<f.subtables.length;m++){var g=f.subtables[m],v=this.getLookupMethod(f,g);if("12"===this.getSubstitutionType(f,g))for(var y=0;y<i.length;y++){var x=v(e.get(y));x&&c.push(x)}}return c}function qmt(e,t){var n=HE(e.current,t.coverage);if(-1===n)return null;for(var i,r=t.ligatureSets[n],a=0;a<r.length;a++){i=r[a];for(var s=0;s<i.components.length&&e.lookahead[s]===i.components[s];s++)if(s===i.components.length-1)return i}return null}function Wmt(e,t){var n=HE(e,t.coverage);return-1===n?null:t.sequences[n]}function jmt(e){var t=e.current,n=e.get(-1);return null===n&&Mf(t)||!Mf(n)&&Mf(t)}function Xmt(e){var t=e.get(1);return null===t||!Mf(t)}Kge.prototype.exec=function(e,t){if("number"!=typeof t)throw new Error("Point size is not a number!");if(!(this._errorState>2)){var n=this.font,i=this._prepState;if(!i||i.ppem!==t){var r=this._fpgmState;if(!r){Sf.prototype=ppt,(r=this._fpgmState=new Sf("fpgm",n.tables.fpgm)).funcs=[],r.font=n,exports.DEBUG&&(console.log("---EXEC FPGM---"),r.step=-1);try{Vm(r)}catch(e){return console.log("Hinting error in FPGM:"+e),void(this._errorState=3)}}Sf.prototype=r,(i=this._prepState=new Sf("prep",n.tables.prep)).ppem=t;var a=n.tables.cvt;if(a)for(var s=i.cvt=new Array(a.length),o=t/n.unitsPerEm,l=0;l<a.length;l++)s[l]=a[l]*o;else i.cvt=[];exports.DEBUG&&(console.log("---EXEC PREP---"),i.step=-1);try{Vm(i)}catch(e){this._errorState<2&&console.log("Hinting error in PREP:"+e),this._errorState=2}}if(!(this._errorState>1))try{return Zge(e,i)}catch(e){return this._errorState<1&&(console.log("Hinting error:"+e),console.log("Note: further hinting errors are silenced")),void(this._errorState=1)}}},Zge=function(e,t){var n,i,r,a=t.ppem/t.font.unitsPerEm,s=a,o=e.components;if(Sf.prototype=t,o){var l=t.font;i=[],n=[];for(var h=0;h<o.length;h++){var u=o[h],c=l.glyphs.get(u.glyphIndex);r=new Sf("glyf",c.instructions),exports.DEBUG&&(console.log("---EXEC COMP "+h+"---"),r.step=-1),Z5(c,r,a,s);for(var d=Math.round(u.dx*a),p=Math.round(u.dy*s),f=r.gZone,m=r.contours,g=0;g<f.length;g++){var v=f[g];v.xTouched=v.yTouched=!1,v.xo=v.x=v.x+d,v.yo=v.y=v.y+p}var y=i.length;i.push.apply(i,f);for(var x=0;x<m.length;x++)n.push(m[x]+y)}e.instructions&&!r.inhibitGridFit&&((r=new Sf("glyf",e.instructions)).gZone=r.z0=r.z1=r.z2=i,r.contours=n,i.push(new ed(0,0),new ed(Math.round(e.advanceWidth*a),0)),exports.DEBUG&&(console.log("---EXEC COMPOSITE---"),r.step=-1),Vm(r),i.length-=2)}else r=new Sf("glyf",e.instructions),exports.DEBUG&&(console.log("---EXEC GLYPH---"),r.step=-1),Z5(e,r,a,s),i=r.gZone;return i},Z5=function(e,t,n,i){for(var r,a=e.points||[],s=a.length,o=t.gZone=t.z0=t.z1=t.z2=[],l=t.contours=[],h=0;h<s;h++)r=a[h],o[h]=new ed(r.x*n,r.y*i,r.lastPointOfContour,r.onCurve);for(var u,c,d=0;d<s;d++)r=o[d],u||(u=r,l.push(d)),r.lastPointOfContour?(r.nextPointOnContour=u,u.prevPointOnContour=r,u=void 0):(c=o[d+1],r.nextPointOnContour=c,c.prevPointOnContour=r);if(!t.inhibitGridFit){if(exports.DEBUG){console.log("PROCESSING GLYPH",t.stack);for(var p=0;p<s;p++)console.log(p,o[p].x,o[p].y)}if(o.push(new ed(0,0),new ed(Math.round(e.advanceWidth*n),0)),Vm(t),o.length-=2,exports.DEBUG){console.log("FINISHED GLYPH",t.stack);for(var f=0;f<s;f++)console.log(f,o[f].x,o[f].y)}}},Vm=function(e){var t=e.prog;if(t){var n,i=t.length;for(e.ip=0;e.ip<i;e.ip++){if(exports.DEBUG&&e.step++,!(n=$ge[t[e.ip]]))throw new Error("unknown instruction: 0x"+Number(t[e.ip]).toString(16));n(e)}}},$ge=[jme.bind(void 0,Qh),jme.bind(void 0,Bu),Xme.bind(void 0,Qh),Xme.bind(void 0,Bu),Yme.bind(void 0,Qh),Yme.bind(void 0,Bu),$me.bind(void 0,0),$me.bind(void 0,1),Zme.bind(void 0,0),Zme.bind(void 0,1),mpt,gpt,vpt,ypt,xpt,bpt,Ept,_pt,Tpt,wpt,Spt,Mpt,Apt,Rpt,Cpt,Ppt,Ipt,Lpt,Dpt,Opt,void 0,void 0,kpt,N5,Fpt,Npt,Bpt,Vpt,zpt,void 0,void 0,void 0,Upt,Hpt,Gpt,void 0,Kme.bind(void 0,0),Kme.bind(void 0,1),Jme.bind(void 0,Qh),Jme.bind(void 0,Bu),Qme.bind(void 0,0),Qme.bind(void 0,1),ege.bind(void 0,0),ege.bind(void 0,1),tge.bind(void 0,0),tge.bind(void 0,1),qpt,Wpt,nge.bind(void 0,0),nge.bind(void 0,1),jpt,Xpt,rge.bind(void 0,0),rge.bind(void 0,1),Ypt,$pt,Zpt,Kpt,Jpt,Qpt,ige.bind(void 0,0),ige.bind(void 0,1),void 0,sge.bind(void 0,0),sge.bind(void 0,1),emt,void 0,tmt,void 0,void 0,nmt,rmt,imt,smt,amt,omt,lmt,cmt,umt,hmt,dmt,fmt,pmt,B5.bind(void 0,1),mmt,gmt,vmt,ymt,xmt,bmt,Emt,_mt,Tmt,wmt,vC.bind(void 0,0),vC.bind(void 0,1),vC.bind(void 0,2),vC.bind(void 0,3),void 0,void 0,void 0,void 0,Smt,B5.bind(void 0,2),B5.bind(void 0,3),U5.bind(void 0,1),U5.bind(void 0,2),U5.bind(void 0,3),Mmt,Amt,void 0,void 0,Rmt,void 0,Cmt,Pmt,N5,N5,void 0,void 0,void 0,void 0,void 0,Imt,age.bind(void 0,0),age.bind(void 0,1),Lmt,void 0,Dmt,Omt,kmt,Fmt,Nmt,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,_f.bind(void 0,1),_f.bind(void 0,2),_f.bind(void 0,3),_f.bind(void 0,4),_f.bind(void 0,5),_f.bind(void 0,6),_f.bind(void 0,7),_f.bind(void 0,8),Tf.bind(void 0,1),Tf.bind(void 0,2),Tf.bind(void 0,3),Tf.bind(void 0,4),Tf.bind(void 0,5),Tf.bind(void 0,6),Tf.bind(void 0,7),Tf.bind(void 0,8),xn.bind(void 0,0,0,0,0,0),xn.bind(void 0,0,0,0,0,1),xn.bind(void 0,0,0,0,0,2),xn.bind(void 0,0,0,0,0,3),xn.bind(void 0,0,0,0,1,0),xn.bind(void 0,0,0,0,1,1),xn.bind(void 0,0,0,0,1,2),xn.bind(void 0,0,0,0,1,3),xn.bind(void 0,0,0,1,0,0),xn.bind(void 0,0,0,1,0,1),xn.bind(void 0,0,0,1,0,2),xn.bind(void 0,0,0,1,0,3),xn.bind(void 0,0,0,1,1,0),xn.bind(void 0,0,0,1,1,1),xn.bind(void 0,0,0,1,1,2),xn.bind(void 0,0,0,1,1,3),xn.bind(void 0,0,1,0,0,0),xn.bind(void 0,0,1,0,0,1),xn.bind(void 0,0,1,0,0,2),xn.bind(void 0,0,1,0,0,3),xn.bind(void 0,0,1,0,1,0),xn.bind(void 0,0,1,0,1,1),xn.bind(void 0,0,1,0,1,2),xn.bind(void 0,0,1,0,1,3),xn.bind(void 0,0,1,1,0,0),xn.bind(void 0,0,1,1,0,1),xn.bind(void 0,0,1,1,0,2),xn.bind(void 0,0,1,1,0,3),xn.bind(void 0,0,1,1,1,0),xn.bind(void 0,0,1,1,1,1),xn.bind(void 0,0,1,1,1,2),xn.bind(void 0,0,1,1,1,3),xn.bind(void 0,1,0,0,0,0),xn.bind(void 0,1,0,0,0,1),xn.bind(void 0,1,0,0,0,2),xn.bind(void 0,1,0,0,0,3),xn.bind(void 0,1,0,0,1,0),xn.bind(void 0,1,0,0,1,1),xn.bind(void 0,1,0,0,1,2),xn.bind(void 0,1,0,0,1,3),xn.bind(void 0,1,0,1,0,0),xn.bind(void 0,1,0,1,0,1),xn.bind(void 0,1,0,1,0,2),xn.bind(void 0,1,0,1,0,3),xn.bind(void 0,1,0,1,1,0),xn.bind(void 0,1,0,1,1,1),xn.bind(void 0,1,0,1,1,2),xn.bind(void 0,1,0,1,1,3),xn.bind(void 0,1,1,0,0,0),xn.bind(void 0,1,1,0,0,1),xn.bind(void 0,1,1,0,0,2),xn.bind(void 0,1,1,0,0,3),xn.bind(void 0,1,1,0,1,0),xn.bind(void 0,1,1,0,1,1),xn.bind(void 0,1,1,0,1,2),xn.bind(void 0,1,1,0,1,3),xn.bind(void 0,1,1,1,0,0),xn.bind(void 0,1,1,1,0,1),xn.bind(void 0,1,1,1,0,2),xn.bind(void 0,1,1,1,0,3),xn.bind(void 0,1,1,1,1,0),xn.bind(void 0,1,1,1,1,1),xn.bind(void 0,1,1,1,1,2),xn.bind(void 0,1,1,1,1,3)],t1.prototype.setState=function(e,t){return this.state[e]=t,this.activeState={key:e,value:this.state[e]},this.activeState},t1.prototype.getState=function(e){return this.state[e]||null},ds.prototype.inboundIndex=function(e){return e>=0&&e<this.tokens.length},ds.prototype.composeRUD=function(e){var t=this,n=e.map((function(e){return t[e[0]].apply(t,e.slice(1).concat(!0))})),i=function(e){return"object"==typeof e&&e.hasOwnProperty("FAIL")};if(n.every(i))return{FAIL:"composeRUD: one or more operations hasn't completed successfully",report:n.filter(i)};this.dispatch("composeRUD",[n.filter((function(e){return!i(e)}))])},ds.prototype.replaceRange=function(e,t,n,i){t=null!==t?t:this.tokens.length;var r=n.every((function(e){return e instanceof t1}));if(!isNaN(e)&&this.inboundIndex(e)&&r){var a=this.tokens.splice.apply(this.tokens,[e,t].concat(n));return i||this.dispatch("replaceToken",[e,t,n]),[a,n]}return{FAIL:"replaceRange: invalid tokens or startIndex."}},ds.prototype.replaceToken=function(e,t,n){if(!isNaN(e)&&this.inboundIndex(e)&&t instanceof t1){var i=this.tokens.splice(e,1,t);return n||this.dispatch("replaceToken",[e,t]),[i[0],t]}return{FAIL:"replaceToken: invalid token or index."}},ds.prototype.removeRange=function(e,t,n){t=isNaN(t)?this.tokens.length:t;var i=this.tokens.splice(e,t);return n||this.dispatch("removeRange",[i,e,t]),i},ds.prototype.removeToken=function(e,t){if(!isNaN(e)&&this.inboundIndex(e)){var n=this.tokens.splice(e,1);return t||this.dispatch("removeToken",[n,e]),n}return{FAIL:"removeToken: invalid token index."}},ds.prototype.insertToken=function(e,t,n){return e.every((function(e){return e instanceof t1}))?(this.tokens.splice.apply(this.tokens,[t,0].concat(e)),n||this.dispatch("insertToken",[e,t]),e):{FAIL:"insertToken: invalid token(s)."}},ds.prototype.registerModifier=function(e,t,n){this.events.newToken.subscribe((function(i,r){var a=[i,r],s=[i,r];if(null===t||!0===t.apply(this,a)){var o=n.apply(this,s);i.setState(e,o)}})),this.registeredModifiers.push(e)},AC.prototype.subscribe=function(e){return"function"==typeof e?this.subscribers.push(e)-1:{FAIL:"invalid '"+this.eventId+"' event handler"}},AC.prototype.unsubscribe=function(e){this.subscribers.splice(e,1)},kc.prototype.setCurrentIndex=function(e){this.index=e,this.current=this.context[e],this.backtrack=this.context.slice(0,e),this.lookahead=this.context.slice(e+1)},kc.prototype.get=function(e){switch(!0){case 0===e:return this.current;case e<0&&Math.abs(e)<=this.backtrack.length:return this.backtrack.slice(e)[0];case e>0&&e<=this.lookahead.length:return this.lookahead[e-1];default:return null}},ds.prototype.rangeToText=function(e){if(e instanceof s6)return this.getRangeTokens(e).map((function(e){return e.char})).join("")},ds.prototype.getText=function(){return this.tokens.map((function(e){return e.char})).join("")},ds.prototype.getContext=function(e){return this.registeredContexts[e]||null},ds.prototype.on=function(e,t){var n=this.events[e];return n?n.subscribe(t):null},ds.prototype.dispatch=function(e,t){var n=this,i=this.events[e];i instanceof AC&&i.subscribers.forEach((function(e){e.apply(n,t||[])}))},ds.prototype.registerContextChecker=function(e,t,n){if(this.getContext(e))return{FAIL:"context name '"+e+"' is already registered."};if("function"!=typeof t)return{FAIL:"missing context start check."};if("function"!=typeof n)return{FAIL:"missing context end check."};var i=new Bmt(e,t,n);return this.registeredContexts[e]=i,this.contextCheckers.push(i),i},ds.prototype.getRangeTokens=function(e){var t=e.startIndex+e.endOffset;return[].concat(this.tokens.slice(e.startIndex,t))},ds.prototype.getContextRanges=function(e){var t=this.getContext(e);return t?t.ranges:{FAIL:"context checker '"+e+"' is not registered."}},ds.prototype.resetContextsRanges=function(){var e=this.registeredContexts;for(var t in e)e.hasOwnProperty(t)&&(e[t].ranges=[])},ds.prototype.updateContextsRanges=function(){this.resetContextsRanges();for(var e=this.tokens.map((function(e){return e.char})),t=0;t<e.length;t++){var n=new kc(e,t);this.runContextCheck(n)}this.dispatch("updateContextsRanges",[this.registeredContexts])},ds.prototype.setEndOffset=function(e,t){var n=new s6(this.getContext(t).openRange.startIndex,e,t),i=this.getContext(t).ranges;return n.rangeId=t+"."+i.length,i.push(n),this.getContext(t).openRange=null,n},ds.prototype.runContextCheck=function(e){var t=this,n=e.index;this.contextCheckers.forEach((function(i){var r=i.contextName,a=t.getContext(r).openRange;if(!a&&i.checkStart(e)&&(a=new s6(n,null,r),t.getContext(r).openRange=a,t.dispatch("contextStart",[r,n])),a&&i.checkEnd(e)){var s=n-a.startIndex+1,o=t.setEndOffset(s,r);t.dispatch("contextEnd",[r,o])}}))},ds.prototype.tokenize=function(e){this.tokens=[],this.resetContextsRanges();var t=Array.from(e);this.dispatch("start");for(var n=0;n<t.length;n++){var i=t[n],r=new kc(t,n);this.dispatch("next",[r]),this.runContextCheck(r);var a=new t1(i);this.tokens.push(a),this.dispatch("newToken",[a,r])}return this.dispatch("end",[this.tokens]),this.tokens},Ko.prototype.getDefaultScriptFeaturesIndexes=function(){for(var e=this.font.tables.gsub.scripts,t=0;t<e.length;t++){var n=e[t];if("DFLT"===n.tag)return n.script.defaultLangSys.featureIndexes}return[]},Ko.prototype.getScriptFeaturesIndexes=function(e){if(!this.font.tables.gsub)return[];if(!e)return this.getDefaultScriptFeaturesIndexes();for(var t=this.font.tables.gsub.scripts,n=0;n<t.length;n++){var i=t[n];if(i.tag===e&&i.script.defaultLangSys)return i.script.defaultLangSys.featureIndexes;var r=i.langSysRecords;if(r)for(var a=0;a<r.length;a++){var s=r[a];if(s.tag===e)return s.langSys.featureIndexes}}return this.getDefaultScriptFeaturesIndexes()},Ko.prototype.mapTagsToFeatures=function(e,t){for(var n={},i=0;i<e.length;i++){var r=e[i].tag,a=e[i].feature;n[r]=a}this.features[t].tags=n},Ko.prototype.getScriptFeatures=function(e){var t=this.features[e];if(this.features.hasOwnProperty(e))return t;var n=this.getScriptFeaturesIndexes(e);if(!n)return null;var i=this.font.tables.gsub;return t=n.map((function(e){return i.features[e]})),this.features[e]=t,this.mapTagsToFeatures(t,e),t},Ko.prototype.getSubstitutionType=function(e,t){return e.lookupType.toString()+t.substFormat.toString()},Ko.prototype.getLookupMethod=function(e,t){var n=this;switch(this.getSubstitutionType(e,t)){case"11":return function(e){return Vmt.apply(n,[e,t])};case"12":return function(e){return zmt.apply(n,[e,t])};case"63":return function(e){return Gmt.apply(n,[e,t])};case"41":return function(e){return qmt.apply(n,[e,t])};case"21":return function(e){return Wmt.apply(n,[e,t])};default:throw new Error("lookupType: "+e.lookupType+" - substFormat: "+t.substFormat+" is not yet supported")}},Ko.prototype.lookupFeature=function(e){var t=e.contextParams,n=t.index,i=this.getFeature({tag:e.tag,script:e.script});if(!i)return new Error("font '"+this.font.names.fullName.en+"' doesn't support feature '"+e.tag+"' for script '"+e.script+"'.");for(var r=this.getFeatureLookups(i),a=[].concat(t.context),s=0;s<r.length;s++)for(var o=r[s],l=this.getLookupSubtables(o),h=0;h<l.length;h++){var u=l[h],c=this.getSubstitutionType(o,u),d=this.getLookupMethod(o,u),p=void 0;switch(c){case"11":(p=d(t.current))&&a.splice(n,1,new Hm({id:11,tag:e.tag,substitution:p}));break;case"12":(p=d(t.current))&&a.splice(n,1,new Hm({id:12,tag:e.tag,substitution:p}));break;case"63":p=d(t),Array.isArray(p)&&p.length&&a.splice(n,1,new Hm({id:63,tag:e.tag,substitution:p}));break;case"41":(p=d(t))&&a.splice(n,1,new Hm({id:41,tag:e.tag,substitution:p}));break;case"21":(p=d(t.current))&&a.splice(n,1,new Hm({id:21,tag:e.tag,substitution:p}))}t=new kc(a,n),(!Array.isArray(p)||p.length)&&(p=null)}return a.length?a:null},Ko.prototype.supports=function(e){if(!e.script)return!1;this.getScriptFeatures(e.script);var t=this.features.hasOwnProperty(e.script);if(!e.tag)return t;var n=this.features[e.script].some((function(t){return t.tag===e.tag}));return t&&n},Ko.prototype.getLookupSubtables=function(e){return e.subtables||null},Ko.prototype.getLookupByIndex=function(e){return this.font.tables.gsub.lookups[e]||null},Ko.prototype.getFeatureLookups=function(e){return e.lookupListIndexes.map(this.getLookupByIndex.bind(this))},Ko.prototype.getFeature=function(e){if(!this.font)return{FAIL:"No font was found"};this.features.hasOwnProperty(e.script)||this.getScriptFeatures(e.script);var t=this.features[e.script];return t?t.tags[e.tag]?this.features[e.script].tags[e.tag]:null:{FAIL:"No feature for script "+e.script}};var Ymt={startCheck:jmt,endCheck:Xmt};function $mt(e){var t=e.current,n=e.get(-1);return(Mf(t)||Af(t))&&!Mf(n)}function Zmt(e){var t=e.get(1);switch(!0){case null===t:return!0;case!Mf(t)&&!Af(t):var n=Hmt(t);if(!n)return!0;if(n&&!e.lookahead.some((function(e){return Mf(e)||Af(e)})))return!0;break;default:return!1}}var Kmt={startCheck:$mt,endCheck:Zmt};function Jmt(e,t,n){t[n].setState(e.tag,e.substitution)}function Qmt(e,t,n){t[n].setState(e.tag,e.substitution)}function egt(e,t,n){e.substitution.forEach((function(i,r){t[n+r].setState(e.tag,i)}))}function tgt(e,t,n){var i=t[n];i.setState(e.tag,e.substitution.ligGlyph);for(var r=e.substitution.components.length,a=0;a<r;a++)(i=t[n+a+1]).setState("deleted",!0)}var oge={11:Jmt,12:Qmt,63:egt,41:tgt};function a6(e,t,n){e instanceof Hm&&oge[e.id]&&oge[e.id](e,t,n)}function ngt(e){for(var t=[].concat(e.backtrack),n=t.length-1;n>=0;n--){var i=t[n],r=t0e(i),a=Af(i);if(!r&&!a)return!0;if(r)return!1}return!1}function rgt(e){if(t0e(e.current))return!1;for(var t=0;t<e.lookahead.length;t++)if(!Af(e.lookahead[t]))return!0;return!1}function igt(e){var t=this,n="arab",i=this.featuresTags[n],r=this.tokenizer.getRangeTokens(e);if(1!==r.length){var a=new kc(r.map((function(e){return e.getState("glyphIndex")})),0),s=new kc(r.map((function(e){return e.char})),0);r.forEach((function(e,o){if(!Af(e.char)){a.setCurrentIndex(o),s.setCurrentIndex(o);var l,h=0;switch(ngt(s)&&(h|=1),rgt(s)&&(h|=2),h){case 1:l="fina";break;case 2:l="init";break;case 3:l="medi"}if(-1!==i.indexOf(l)){var u=t.query.lookupFeature({tag:l,script:n,contextParams:a});if(u instanceof Error)return console.info(u.message);u.forEach((function(e,t){e instanceof Hm&&(a6(e,r,t),a.context[t]=e.substitution)}))}}}))}}function lge(e,t){return new kc(e.map((function(e){return e.activeState.value})),t||0)}function sgt(e){var t=this,n=this.tokenizer.getRangeTokens(e),i=lge(n);i.context.forEach((function(e,r){i.setCurrentIndex(r);var a=t.query.lookupFeature({tag:"rlig",script:"arab",contextParams:i});a.length&&(a.forEach((function(e){return a6(e,n,r)})),i=lge(n))}))}function agt(e){var t=e.current,n=e.get(-1);return null===n&&xC(t)||!xC(n)&&xC(t)}function ogt(e){var t=e.get(1);return null===t||!xC(t)}var lgt={startCheck:agt,endCheck:ogt};function cge(e,t){return new kc(e.map((function(e){return e.activeState.value})),t||0)}function cgt(e){var t=this,n=this.tokenizer.getRangeTokens(e),i=cge(n);i.context.forEach((function(e,r){i.setCurrentIndex(r);var a=t.query.lookupFeature({tag:"liga",script:"latn",contextParams:i});a.length&&(a.forEach((function(e){return a6(e,n,r)})),i=cge(n))}))}function Bc(e){this.baseDir=e||"ltr",this.tokenizer=new ds,this.featuresTags={}}function V5(e){var t=this.contextChecks[e+"Check"];return this.tokenizer.registerContextChecker(e,t.startCheck,t.endCheck)}function ugt(){return V5.call(this,"latinWord"),V5.call(this,"arabicWord"),V5.call(this,"arabicSentence"),this.tokenizer.tokenize(this.text)}function hgt(){var e=this;this.tokenizer.getContextRanges("arabicSentence").forEach((function(t){var n=e.tokenizer.getRangeTokens(t);e.tokenizer.replaceRange(t.startIndex,t.endOffset,n.reverse())}))}function o6(){if(-1===this.tokenizer.registeredModifiers.indexOf("glyphIndex"))throw new Error("glyphIndex modifier is required to apply arabic presentation features.")}function dgt(){var e=this;this.featuresTags.hasOwnProperty("arab")&&(o6.call(this),this.tokenizer.getContextRanges("arabicWord").forEach((function(t){igt.call(e,t)})))}function fgt(){var e=this,t="arab";this.featuresTags.hasOwnProperty(t)&&-1!==this.featuresTags[t].indexOf("rlig")&&(o6.call(this),this.tokenizer.getContextRanges("arabicWord").forEach((function(t){sgt.call(e,t)})))}function pgt(){var e=this,t="latn";this.featuresTags.hasOwnProperty(t)&&-1!==this.featuresTags[t].indexOf("liga")&&(o6.call(this),this.tokenizer.getContextRanges("latinWord").forEach((function(t){cgt.call(e,t)})))}function Ai(e){(e=e||{}).tables=e.tables||{},e.empty||(PE(e.familyName,"When creating a new Font object, familyName is required."),PE(e.styleName,"When creating a new Font object, styleName is required."),PE(e.unitsPerEm,"When creating a new Font object, unitsPerEm is required."),PE(e.ascender,"When creating a new Font object, ascender is required."),PE(e.descender<=0,"When creating a new Font object, negative descender value is required."),this.names={fontFamily:{en:e.familyName||" "},fontSubfamily:{en:e.styleName||" "},fullName:{en:e.fullName||e.familyName+" "+e.styleName},postScriptName:{en:e.postScriptName||(e.familyName+e.styleName).replace(/\s/g,"")},designer:{en:e.designer||" "},designerURL:{en:e.designerURL||" "},manufacturer:{en:e.manufacturer||" "},manufacturerURL:{en:e.manufacturerURL||" "},license:{en:e.license||" "},licenseURL:{en:e.licenseURL||" "},version:{en:e.version||"Version 0.1"},description:{en:e.description||" "},copyright:{en:e.copyright||" "},trademark:{en:e.trademark||" "}},this.unitsPerEm=e.unitsPerEm||1e3,this.ascender=e.ascender,this.descender=e.descender,this.createdTimestamp=e.createdTimestamp,this.tables=Object.assign(e.tables,{os2:Object.assign({usWeightClass:e.weightClass||this.usWeightClasses.MEDIUM,usWidthClass:e.widthClass||this.usWidthClasses.MEDIUM,fsSelection:e.fsSelection||this.fsSelectionValues.REGULAR},e.tables.os2)})),this.supported=!0,this.glyphs=new Uu.GlyphSet(this,e.glyphs||[]),this.encoding=new bge(this),this.position=new NE(this),this.substitution=new Zo(this),this.tables=this.tables||{},this._push=null,this._hmtxTableData={},Object.defineProperty(this,"hinting",{get:function(){return this._hinting?this._hinting:"truetype"===this.outlinesFormat?this._hinting=new Kge(this):void 0}})}function n0e(e,t){var n=JSON.stringify(e),i=256;for(var r in t){var a=parseInt(r);if(a&&!(a<256)){if(JSON.stringify(t[r])===n)return a;i<=a&&(i=a+1)}}return t[i]=e,i}function mgt(e,t,n){var i=n0e(t.name,n);return[{name:"tag_"+e,type:"TAG",value:t.tag},{name:"minValue_"+e,type:"FIXED",value:t.minValue<<16},{name:"defaultValue_"+e,type:"FIXED",value:t.defaultValue<<16},{name:"maxValue_"+e,type:"FIXED",value:t.maxValue<<16},{name:"flags_"+e,type:"USHORT",value:0},{name:"nameID_"+e,type:"USHORT",value:i}]}function ggt(e,t,n){var i={},r=new _n.Parser(e,t);return i.tag=r.parseTag(),i.minValue=r.parseFixed(),i.defaultValue=r.parseFixed(),i.maxValue=r.parseFixed(),r.skip("uShort",1),i.name=n[r.parseUShort()]||{},i}function vgt(e,t,n,i){for(var r=[{name:"nameID_"+e,type:"USHORT",value:n0e(t.name,i)},{name:"flags_"+e,type:"USHORT",value:0}],a=0;a<n.length;++a){var s=n[a].tag;r.push({name:"axis_"+e+" "+s,type:"FIXED",value:t.coordinates[s]<<16})}return r}function ygt(e,t,n,i){var r={},a=new _n.Parser(e,t);r.name=i[a.parseUShort()]||{},a.skip("uShort",1),r.coordinates={};for(var s=0;s<n.length;++s)r.coordinates[n[s].tag]=a.parseFixed();return r}function xgt(e,t){var n=new dn.Table("fvar",[{name:"version",type:"ULONG",value:65536},{name:"offsetToData",type:"USHORT",value:0},{name:"countSizePairs",type:"USHORT",value:2},{name:"axisCount",type:"USHORT",value:e.axes.length},{name:"axisSize",type:"USHORT",value:20},{name:"instanceCount",type:"USHORT",value:e.instances.length},{name:"instanceSize",type:"USHORT",value:4+4*e.axes.length}]);n.offsetToData=n.sizeOf();for(var i=0;i<e.axes.length;i++)n.fields=n.fields.concat(mgt(i,e.axes[i],t));for(var r=0;r<e.instances.length;r++)n.fields=n.fields.concat(vgt(r,e.instances[r],e.axes,t));return n}function bgt(e,t,n){var i=new _n.Parser(e,t),r=i.parseULong();Yn.argument(65536===r,"Unsupported fvar table version.");var a=i.parseOffset16();i.skip("uShort",1);for(var s=i.parseUShort(),o=i.parseUShort(),l=i.parseUShort(),h=i.parseUShort(),u=[],c=0;c<s;c++)u.push(ggt(e,t+a+c*o,n));for(var d=[],p=t+a+s*o,f=0;f<l;f++)d.push(ygt(e,p+f*h,u,n));return{axes:u,instances:d}}Bc.prototype.setText=function(e){this.text=e},Bc.prototype.contextChecks={latinWordCheck:lgt,arabicWordCheck:Ymt,arabicSentenceCheck:Kmt},Bc.prototype.registerFeatures=function(e,t){var n=this,i=t.filter((function(t){return n.query.supports({script:e,tag:t})}));this.featuresTags.hasOwnProperty(e)?this.featuresTags[e]=this.featuresTags[e].concat(i):this.featuresTags[e]=i},Bc.prototype.applyFeatures=function(e,t){if(!e)throw new Error("No valid font was provided to apply features");this.query||(this.query=new Ko(e));for(var n=0;n<t.length;n++){var i=t[n];this.query.supports({script:i.script})&&this.registerFeatures(i.script,i.tags)}},Bc.prototype.registerModifier=function(e,t,n){this.tokenizer.registerModifier(e,t,n)},Bc.prototype.checkContextReady=function(e){return!!this.tokenizer.getContext(e)},Bc.prototype.applyFeaturesToContexts=function(){this.checkContextReady("arabicWord")&&(dgt.call(this),fgt.call(this)),this.checkContextReady("latinWord")&&pgt.call(this),this.checkContextReady("arabicSentence")&&hgt.call(this)},Bc.prototype.processText=function(e){(!this.text||this.text!==e)&&(this.setText(e),ugt.call(this),this.applyFeaturesToContexts())},Bc.prototype.getBidiText=function(e){return this.processText(e),this.tokenizer.getText()},Bc.prototype.getTextGlyphs=function(e){this.processText(e);for(var t=[],n=0;n<this.tokenizer.tokens.length;n++){var i=this.tokenizer.tokens[n];if(!i.state.deleted){var r=i.activeState.value;t.push(Array.isArray(r)?r[0]:r)}}return t},Ai.prototype.hasChar=function(e){return null!==this.encoding.charToGlyphIndex(e)},Ai.prototype.charToGlyphIndex=function(e){return this.encoding.charToGlyphIndex(e)},Ai.prototype.charToGlyph=function(e){var t=this.charToGlyphIndex(e),n=this.glyphs.get(t);return n||(n=this.glyphs.get(0)),n},Ai.prototype.updateFeatures=function(e){return this.defaultRenderOptions.features.map((function(t){return"latn"===t.script?{script:"latn",tags:t.tags.filter((function(t){return e[t]}))}:t}))},Ai.prototype.stringToGlyphs=function(e,t){var n=this,i=new Bc;i.registerModifier("glyphIndex",null,(function(e){return n.charToGlyphIndex(e.char)}));var r=t?this.updateFeatures(t.features):this.defaultRenderOptions.features;i.applyFeatures(this,r);for(var a=i.getTextGlyphs(e),s=a.length,o=new Array(s),l=this.glyphs.get(0),h=0;h<s;h+=1)o[h]=this.glyphs.get(a[h])||l;return o},Ai.prototype.nameToGlyphIndex=function(e){return this.glyphNames.nameToGlyphIndex(e)},Ai.prototype.nameToGlyph=function(e){var t=this.nameToGlyphIndex(e),n=this.glyphs.get(t);return n||(n=this.glyphs.get(0)),n},Ai.prototype.glyphIndexToName=function(e){return this.glyphNames.glyphIndexToName?this.glyphNames.glyphIndexToName(e):""},Ai.prototype.getKerningValue=function(e,t){e=e.index||e,t=t.index||t;var n=this.position.defaultKerningTables;return n?this.position.getKerningValue(n,e,t):this.kerningPairs[e+","+t]||0},Ai.prototype.defaultRenderOptions={kerning:!0,features:[{script:"arab",tags:["init","medi","fina","rlig"]},{script:"latn",tags:["liga","rlig"]}]},Ai.prototype.forEachGlyph=function(e,t,n,i,r,a){t=void 0!==t?t:0,n=void 0!==n?n:0,i=void 0!==i?i:72,r=Object.assign({},this.defaultRenderOptions,r);var s,o=1/this.unitsPerEm*i,l=this.stringToGlyphs(e,r);if(r.kerning){var h=r.script||this.position.getDefaultScriptName();s=this.position.getKerningTables(h,r.language)}for(var u=0;u<l.length;u+=1){var c=l[u];a.call(this,c,t,n,i,r),c.advanceWidth&&(t+=c.advanceWidth*o),r.kerning&&u<l.length-1&&(t+=(s?this.position.getKerningValue(s,c.index,l[u+1].index):this.getKerningValue(c,l[u+1]))*o),r.letterSpacing?t+=r.letterSpacing*i:r.tracking&&(t+=r.tracking/1e3*i)}return t},Ai.prototype.getPath=function(e,t,n,i,r){var a=new ks;return this.forEachGlyph(e,t,n,i,r,(function(e,t,n,i){var s=e.getPath(t,n,i,r,this);a.extend(s)})),a},Ai.prototype.getPaths=function(e,t,n,i,r){var a=[];return this.forEachGlyph(e,t,n,i,r,(function(e,t,n,i){var s=e.getPath(t,n,i,r,this);a.push(s)})),a},Ai.prototype.getAdvanceWidth=function(e,t,n){return this.forEachGlyph(e,0,0,t,n,(function(){}))},Ai.prototype.draw=function(e,t,n,i,r,a){this.getPath(t,n,i,r,a).draw(e)},Ai.prototype.drawPoints=function(e,t,n,i,r,a){this.forEachGlyph(t,n,i,r,a,(function(t,n,i,r){t.drawPoints(e,n,i,r)}))},Ai.prototype.drawMetrics=function(e,t,n,i,r,a){this.forEachGlyph(t,n,i,r,a,(function(t,n,i,r){t.drawMetrics(e,n,i,r)}))},Ai.prototype.getEnglishName=function(e){var t=this.names[e];if(t)return t.en},Ai.prototype.validate=function(){var e=this;function t(t){var n=e.getEnglishName(t);n&&n.trim().length}t("fontFamily"),t("weightName"),t("manufacturer"),t("copyright"),t("version"),this.unitsPerEm},Ai.prototype.toTables=function(){return tpt.fontToTable(this)},Ai.prototype.toBuffer=function(){return console.warn("Font.toBuffer is deprecated. Use Font.toArrayBuffer instead."),this.toArrayBuffer()},Ai.prototype.toArrayBuffer=function(){for(var e=this.toTables().encode(),t=new ArrayBuffer(e.length),n=new Uint8Array(t),i=0;i<e.length;i++)n[i]=e[i];return t},Ai.prototype.download=function(e){var t=this.getEnglishName("fontFamily"),n=this.getEnglishName("fontSubfamily");e=e||t.replace(/\s/g,"")+"-"+n+".otf";var i=this.toArrayBuffer();if(rpt())if(window.URL=window.URL||window.webkitURL,window.URL){var r=new DataView(i),a=new Blob([r],{type:"font/opentype"}),s=document.createElement("a");s.href=window.URL.createObjectURL(a),s.download=e;var o=document.createEvent("MouseEvents");o.initEvent("click",!0,!1),s.dispatchEvent(o)}else console.warn("Font file could not be downloaded. Try using a different browser.");else{var l=dC(),h=ipt(i);l.writeFileSync(e,h)}},Ai.prototype.fsSelectionValues={ITALIC:1,UNDERSCORE:2,NEGATIVE:4,OUTLINED:8,STRIKEOUT:16,BOLD:32,REGULAR:64,USER_TYPO_METRICS:128,WWS:256,OBLIQUE:512},Ai.prototype.usWidthClasses={ULTRA_CONDENSED:1,EXTRA_CONDENSED:2,CONDENSED:3,SEMI_CONDENSED:4,MEDIUM:5,SEMI_EXPANDED:6,EXPANDED:7,EXTRA_EXPANDED:8,ULTRA_EXPANDED:9},Ai.prototype.usWeightClasses={THIN:100,EXTRA_LIGHT:200,LIGHT:300,NORMAL:400,MEDIUM:500,SEMI_BOLD:600,BOLD:700,EXTRA_BOLD:800,BLACK:900};var Egt={make:xgt,parse:bgt},_gt=function(){return{coverage:this.parsePointer(Et.coverage),attachPoints:this.parseList(Et.pointer(Et.uShortList))}},Tgt=function(){var e=this.parseUShort();return Yn.argument(1===e||2===e||3===e,"Unsupported CaretValue table version."),1===e?{coordinate:this.parseShort()}:2===e?{pointindex:this.parseShort()}:3===e?{coordinate:this.parseShort()}:void 0},wgt=function(){return this.parseList(Et.pointer(Tgt))},Sgt=function(){return{coverage:this.parsePointer(Et.coverage),ligGlyphs:this.parseList(Et.pointer(wgt))}},Mgt=function(){return this.parseUShort(),this.parseList(Et.pointer(Et.coverage))};function Agt(e,t){var n=new Et(e,t=t||0),i=n.parseVersion(1);Yn.argument(1===i||1.2===i||1.3===i,"Unsupported GDEF table version.");var r={version:i,classDef:n.parsePointer(Et.classDef),attachList:n.parsePointer(_gt),ligCaretList:n.parsePointer(Sgt),markAttachClassDef:n.parsePointer(Et.classDef)};return i>=1.2&&(r.markGlyphSets=n.parsePointer(Mgt)),r}var Rgt={parse:Agt},Fc=new Array(10);function Cgt(e,t){var n=new Et(e,t=t||0),i=n.parseVersion(1);return Yn.argument(1===i||1.1===i,"Unsupported GPOS table version "+i),1===i?{version:i,scripts:n.parseScriptList(),features:n.parseFeatureList(),lookups:n.parseLookupList(Fc)}:{version:i,scripts:n.parseScriptList(),features:n.parseFeatureList(),lookups:n.parseLookupList(Fc),variations:n.parseFeatureVariationsList()}}Fc[1]=function(){var e=this.offset+this.relativeOffset,t=this.parseUShort();return 1===t?{posFormat:1,coverage:this.parsePointer(Et.coverage),value:this.parseValueRecord()}:2===t?{posFormat:2,coverage:this.parsePointer(Et.coverage),values:this.parseValueRecordList()}:void Yn.assert(!1,"0x"+e.toString(16)+": GPOS lookup type 1 format must be 1 or 2.")},Fc[2]=function(){var e=this.offset+this.relativeOffset,t=this.parseUShort();Yn.assert(1===t||2===t,"0x"+e.toString(16)+": GPOS lookup type 2 format must be 1 or 2.");var n=this.parsePointer(Et.coverage),i=this.parseUShort(),r=this.parseUShort();if(1===t)return{posFormat:t,coverage:n,valueFormat1:i,valueFormat2:r,pairSets:this.parseList(Et.pointer(Et.list((function(){return{secondGlyph:this.parseUShort(),value1:this.parseValueRecord(i),value2:this.parseValueRecord(r)}}))))};if(2===t){var a=this.parsePointer(Et.classDef),s=this.parsePointer(Et.classDef),o=this.parseUShort(),l=this.parseUShort();return{posFormat:t,coverage:n,valueFormat1:i,valueFormat2:r,classDef1:a,classDef2:s,class1Count:o,class2Count:l,classRecords:this.parseList(o,Et.list(l,(function(){return{value1:this.parseValueRecord(i),value2:this.parseValueRecord(r)}})))}}},Fc[3]=function(){return{error:"GPOS Lookup 3 not supported"}},Fc[4]=function(){return{error:"GPOS Lookup 4 not supported"}},Fc[5]=function(){return{error:"GPOS Lookup 5 not supported"}},Fc[6]=function(){return{error:"GPOS Lookup 6 not supported"}},Fc[7]=function(){return{error:"GPOS Lookup 7 not supported"}},Fc[8]=function(){return{error:"GPOS Lookup 8 not supported"}},Fc[9]=function(){return{error:"GPOS Lookup 9 not supported"}};var Pgt=new Array(10);function Igt(e){return new dn.Table("GPOS",[{name:"version",type:"ULONG",value:65536},{name:"scripts",type:"TABLE",value:new dn.ScriptList(e.scripts)},{name:"features",type:"TABLE",value:new dn.FeatureList(e.features)},{name:"lookups",type:"TABLE",value:new dn.LookupList(e.lookups,Pgt)}])}var Lgt={parse:Cgt,make:Igt};function Dgt(e){var t={};e.skip("uShort");var n=e.parseUShort();Yn.argument(0===n,"Unsupported kern sub-table version."),e.skip("uShort",2);var i=e.parseUShort();e.skip("uShort",3);for(var r=0;r<i;r+=1){var a=e.parseUShort(),s=e.parseUShort(),o=e.parseShort();t[a+","+s]=o}return t}function Ogt(e){var t={};e.skip("uShort"),e.parseULong()>1&&console.warn("Only the first kern subtable is supported."),e.skip("uLong");var n=255&e.parseUShort();if(e.skip("uShort"),0===n){var i=e.parseUShort();e.skip("uShort",3);for(var r=0;r<i;r+=1){var a=e.parseUShort(),s=e.parseUShort(),o=e.parseShort();t[a+","+s]=o}}return t}function kgt(e,t){var n=new _n.Parser(e,t),i=n.parseUShort();if(0===i)return Dgt(n);if(1===i)return Ogt(n);throw new Error("Unsupported kern table version ("+i+").")}var Fgt={parse:kgt};function Ngt(e,t,n,i){for(var r=new _n.Parser(e,t),a=i?r.parseUShort:r.parseULong,s=[],o=0;o<n+1;o+=1){var l=a.call(r);i&&(l*=2),s.push(l)}return s}var Bgt={parse:Ngt};function uge(e,t){for(var n=[],i=12,r=0;r<t;r+=1){var a=_n.getTag(e,i),s=_n.getULong(e,i+4),o=_n.getULong(e,i+8),l=_n.getULong(e,i+12);n.push({tag:a,checksum:s,offset:o,length:l,compression:!1}),i+=16}return n}function Ugt(e,t){for(var n=[],i=44,r=0;r<t;r+=1){var a,s=_n.getTag(e,i),o=_n.getULong(e,i+4),l=_n.getULong(e,i+8),h=_n.getULong(e,i+12);a=l<h&&"WOFF",n.push({tag:s,offset:o,compression:a,compressedLength:l,length:h}),i+=20}return n}function vs(e,t){if("WOFF"===t.compression){var n=new Uint8Array(e.buffer,t.offset+2,t.compressedLength-2),i=new Uint8Array(t.length);if(Ldt(n,i),i.byteLength!==t.length)throw new Error("Decompression error: "+t.tag+" decompressed length doesn't match recorded length");return{data:new DataView(i.buffer,0),offset:0}}return{data:e,offset:t.offset}}function r0e(e,t){t=null==t?{}:t;var n,i,r,a=new Ai({empty:!0}),s=new DataView(e,0),o=[],l=_n.getTag(s,0);if(l===String.fromCharCode(0,1,0,0)||"true"===l||"typ1"===l)a.outlinesFormat="truetype",o=uge(s,r=_n.getUShort(s,4));else if("OTTO"===l)a.outlinesFormat="cff",o=uge(s,r=_n.getUShort(s,4));else{if("wOFF"!==l)throw new Error("Unsupported OpenType signature "+l);var h=_n.getTag(s,4);if(h===String.fromCharCode(0,1,0,0))a.outlinesFormat="truetype";else{if("OTTO"!==h)throw new Error("Unsupported OpenType flavor "+l);a.outlinesFormat="cff"}o=Ugt(s,r=_n.getUShort(s,12))}for(var u,c,d,p,f,m,g,v,y,x,b,_,w=0;w<r;w+=1){var S=o[w],M=void 0;switch(S.tag){case"cmap":M=vs(s,S),a.tables.cmap=xge.parse(M.data,M.offset),a.encoding=new Ege(a.tables.cmap);break;case"cvt ":M=vs(s,S),_=new _n.Parser(M.data,M.offset),a.tables.cvt=_.parseShortList(S.length/2);break;case"fvar":c=S;break;case"fpgm":M=vs(s,S),_=new _n.Parser(M.data,M.offset),a.tables.fpgm=_.parseByteList(S.length);break;case"head":M=vs(s,S),a.tables.head=Ige.parse(M.data,M.offset),a.unitsPerEm=a.tables.head.unitsPerEm,n=a.tables.head.indexToLocFormat;break;case"hhea":M=vs(s,S),a.tables.hhea=Lge.parse(M.data,M.offset),a.ascender=a.tables.hhea.ascender,a.descender=a.tables.hhea.descender,a.numberOfHMetrics=a.tables.hhea.numberOfHMetrics;break;case"hmtx":g=S;break;case"ltag":M=vs(s,S),i=Oge.parse(M.data,M.offset);break;case"maxp":M=vs(s,S),a.tables.maxp=kge.parse(M.data,M.offset),a.numGlyphs=a.tables.maxp.numGlyphs;break;case"name":x=S;break;case"OS/2":M=vs(s,S),a.tables.os2=$5.parse(M.data,M.offset);break;case"post":M=vs(s,S),a.tables.post=Vge.parse(M.data,M.offset),a.glyphNames=new t6(a.tables.post);break;case"prep":M=vs(s,S),_=new _n.Parser(M.data,M.offset),a.tables.prep=_.parseByteList(S.length);break;case"glyf":d=S;break;case"loca":y=S;break;case"CFF ":u=S;break;case"kern":v=S;break;case"GDEF":p=S;break;case"GPOS":f=S;break;case"GSUB":m=S;break;case"meta":b=S}}var E=vs(s,x);if(a.tables.name=Hge.parse(E.data,E.offset,i),a.names=a.tables.name,d&&y){var T=0===n,A=vs(s,y),C=Bgt.parse(A.data,A.offset,a.numGlyphs,T),P=vs(s,d);a.glyphs=Yge.parse(P.data,P.offset,C,a,t)}else{if(!u)throw new Error("Font doesn't contain TrueType or CFF outlines.");var R=vs(s,u);Pge.parse(R.data,R.offset,a,t)}var L=vs(s,g);if(Dge.parse(a,L.data,L.offset,a.numberOfHMetrics,a.numGlyphs,a.glyphs,t),Qdt(a,t),v){var I=vs(s,v);a.kerningPairs=Fgt.parse(I.data,I.offset)}else a.kerningPairs={};if(p){var k=vs(s,p);a.tables.gdef=Rgt.parse(k.data,k.offset)}if(f){var O=vs(s,f);a.tables.gpos=Lgt.parse(O.data,O.offset),a.position.init()}if(m){var D=vs(s,m);a.tables.gsub=zge.parse(D.data,D.offset)}if(c){var N=vs(s,c);a.tables.fvar=Egt.parse(N.data,N.offset,a.names)}if(b){var U=vs(s,b);a.tables.meta=Gge.parse(U.data,U.offset),a.metas=a.tables.meta}return a}var Cf=class extends Zv{constructor(e,t){super(e,t),this.reversed=!1,t instanceof ArrayBuffer?this.data=this.parseTTF(t):t.fileName?this.setFontFile(t):this.data=t,this.type="MeshFont"}generateShapes(e,t){return super.generateShapes(e,t)}getCharShape(e,t){var n;let i=null==(n=i0e(e,t,0,0,this.data))?void 0:n.path;return i||this.addUnsupportedChar(e),i}getNotFoundTextShape(e){var t;return null==(t=i0e("?",e,0,0,this.data))?void 0:t.path}parseTTF(e){function t(e){let t,n=[];e.forEach((function(e){"m"===e.type.toLowerCase()?(t=[e],n.push(t)):"z"!==e.type.toLowerCase()&&t.push(e)}));let i=[];return n.forEach((function(e){let t={type:"m",x:e[e.length-1].x,y:e[e.length-1].y};i.push(t);for(let n=e.length-1;n>0;n--){let t=e[n],r={type:t.type};void 0!==t.x2&&void 0!==t.y2?(r.x1=t.x2,r.y1=t.y2,r.x2=t.x1,r.y2=t.y1):void 0!==t.x1&&void 0!==t.y1&&(r.x1=t.x1,r.y1=t.y1),r.x=e[n-1].x,r.y=e[n-1].y,i.push(r)}})),i}return function(e,n){let i=Math.round,r={},a=1e5/(72*(e.unitsPerEm||2048)),s=e.encoding.cmap.glyphIndexMap,o=Object.keys(s);for(let l=0;l<o.length;l++){let h=o[l],u=e.glyphs.glyphs[s[h]];if(void 0!==h){let e={ha:i(u.advanceWidth*a),x_min:i(u.xMin*a),x_max:i(u.xMax*a),o:""};n&&(u.path.commands=t(u.path.commands)),u.path.commands.forEach((function(t){"c"===t.type.toLowerCase()&&(t.type="b"),e.o+=t.type.toLowerCase()+" ",void 0!==t.x&&void 0!==t.y&&(e.o+=i(t.x*a)+" "+i(t.y*a)+" "),void 0!==t.x1&&void 0!==t.y1&&(e.o+=i(t.x1*a)+" "+i(t.y1*a)+" "),void 0!==t.x2&&void 0!==t.y2&&(e.o+=i(t.x2*a)+" "+i(t.y2*a)+" ")})),r[String.fromCodePoint(u.unicode)]=e}}return{glyphs:r,familyName:e.getEnglishName("fullName"),ascender:i(e.ascender*a),descender:i(e.descender*a),underlinePosition:e.tables.post.underlinePosition,underlineThickness:e.tables.post.underlineThickness,boundingBox:{xMin:e.tables.head.xMin,xMax:e.tables.head.xMax,yMin:e.tables.head.yMin,yMax:e.tables.head.yMax},resolution:1e3,original_font_information:e.tables.name}}(r0e(e),this.reversed)}};function i0e(e,t,n,i,r){let a=r.glyphs[e];if(!a)return;let s,o,l,h,u,c,d,p,f=new ym;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,u=e[r++]*t+n,c=e[r++]*t+i,f.quadraticCurveTo(u,c,l,h);break;case"b":l=e[r++]*t+n,h=e[r++]*t+i,u=e[r++]*t+n,c=e[r++]*t+i,d=e[r++]*t+n,p=e[r++]*t+i,f.bezierCurveTo(u,c,d,p,l,h)}}return{offsetX:a.ha*t,path:f}}var RC={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]]]},Hgt=!1,Vgt=new _e,td=class extends Ts{constructor(e,t){super(),this.width=0,this.bounds=new _i,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 td(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 td(this.lastPoint.clone().applyMatrix3(e),t)}calcWidth(e){let t=this.bounds;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;if(Hgt&&e.length>0){let t=this.bounds.min,n=this.bounds.getSize(Vgt),i=new _e(t.x,t.y),r=new _e(t.x+n.width,t.y),a=new _e(t.x+n.width,t.y+n.height),s=new _e(t.x,t.y+n.height);e.push([i,r],[r,a],[a,s],[s,i])}let t=[],n=[],i=0,r=new Ot;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 Bt(t,3)),r.setIndex(n),r}},CC;function zgt(){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(CC=new Uint16Array(65536),n=0;n<i.length;n++)CC[i.charCodeAt(n)]=t[n]}function s0e(e){CC||zgt();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=CC[r];t[n++]=255&e,t[n++]=e>>8}}return t.subarray(0,n)}var Ggt="\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",a0e="\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 o0e(e){return Ggt.charAt(a0e.indexOf(e.charAt(0)))}var Azt=new RegExp("[\u4e00-\u9fa5]+");function l0e(e){return a0e.includes(e)}var Gr=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(Gr.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]}},Pf=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=s0e(e);return t.length<2?t[0]:t.length<4?Gr.ToUInt16(t,0):Gr.ToUInt32(t,0)}static parserCode(e,t,n){let i=new _e,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,u=i.clone();switch(a.length>1&&(r.push(a.slice()),a=[]),e.fontType){case 0:l++,o=t[l];break;case 1:l++,o=t[l],0==o&&(l++,o=Gr.ToUInt16(new Uint8Array([t[l++],t[l++]]),0),u.x=t[l++]*n,u.y=t[l++]*n,h=t[l]*n);break;case 2:l+=2,o=Gr.ToUInt16(new Uint8Array([t[l-1],t[l]]),0)}0!==o&&(s=e.getGraphicDataByCodeWithOffset(o,h,u),s&&(r.push(...s.polylines.slice()),i=s.lastPoint.clone()))}break;case 8:{let e=new _e;e.x=Gr.byteTosbyte(t[++l]),e.y=Gr.byteTosbyte(t[++l]),i.add(e.multiplyScalar(n)),o&&a.push(i.clone())}break;case 9:for(;;){let e=new _e;if(e.x=Gr.byteTosbyte(t[++l]),e.y=Gr.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=Gr.byteTosbyte(t[++l]),s=(112&r)>>4,h=7&r;0==h&&(h=8);let u=Math.PI/4,c=u*h,d=Pf.CIRCLE_SPAN;r<0&&(d=-d,c=-c);let p=u*s,f=p+c,m=i.clone().sub(new _e(Math.cos(p)*e,Math.sin(p)*e));if(i=m.clone().add(new _e(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 _e(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=Gr.byteTosbyte(t[++l]),u=(112&h)>>4,c=7&h;0==c&&(c=8),0!=r&&c--;let d=Math.PI/4,p=d*c,f=Pf.CIRCLE_SPAN,m=1;h<0&&(f=-f,p=-p,m=-1);let g=d*u,v=g+p;g+=d*e/256*m,v+=d*r/256*m;let y=i.clone().sub(new _e(s*Math.cos(g),s*Math.sin(g)));if(i=y.clone().add(new _e(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 _e(s*Math.cos(e),s*Math.sin(e))));a.push(i.clone())}}break;case 12:{let e=new _e;e.x=Gr.byteTosbyte(t[++l])*n,e.y=Gr.byteTosbyte(t[++l])*n;let r=Gr.byteTosbyte(t[++l]);r<-127&&(r=-127),o&&(0==r?a.push(i.clone().add(e)):a.push(Pf.generateArcPoints(i,e,r/127))),i.add(e)}break;case 13:for(;;){let e=new _e;if(e.x=Gr.byteTosbyte(t[++l])*n,e.y=Gr.byteTosbyte(t[++l])*n,0==e.x&&0==e.y)break;let r=Gr.byteTosbyte(t[++l]);r<-127&&(r=-127),o&&(0==r?a.push(i.clone().add(e)):a.push(Pf.generateArcPoints(i.clone(),e,r/127))),i.add(e)}break;case 14:l=Pf.skipCode(e,t,++l);break;default:if(h>15){let e=(240&h)>>4,t=15&h,r=new _e;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 td(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.fontType){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 _e(t.y,-t.x);l.normalize(),l.multiplyScalar(s);let h=Math.abs(a/Math.sin(o/2)),u=e.add(t.divideScalar(2));!1!==r?u.add(l):u.sub(l);let c=e.sub(u),d=i.sub(u),p=Math.atan2(c.y,c.x),f=Math.atan2(d.y,d.x),m=Pf.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 u.add(new _e(h*Math.cos(g),h*Math.sin(g)));break}return i}},Uc=Pf;Uc.FILE_STOP_FLAG=["\r","\n","\x1a"],Uc.CIRCLE_SPAN=Math.PI/18;var c0e=new In,PC=class extends Zv{constructor(e,t){if(super(e,t),this.isExtend=!1,this.isUniCode=!0,this.isEmbedded=!1,this.fontType=2,this.textShapesCache=new Map,this.graphicData=new Map,t instanceof ArrayBuffer){let e=new bf(t),n=Uc.parserHeader(e,Uc.FILE_STOP_FLAG).split(" ");switch(n[1]){case"shapes":this.parseShapeFont(e),this.fontType=0;break;case"bigfont":this.parseBigFont(e),this.fontType=1;break;case"unifont":this.parseUniFont(e),this.fontType=2}this.fileHeader=n[0],this.fileVersion=n[2]}else this.setFontFile(t)}generateShapes(e,t){let n=[],i=0;for(let r=0;r<e.length;r++){let a=e[r];if(" "===a){i+=t;continue}let s=this.getCharShape(a,t);s?(n.push(s.offset(new _e(i,0))),i+=s.width):(i+=t,this.addUnsupportedChar(a))}return n}getCharShape(e,t){l0e(e)&&(e=o0e(e));let n=Uc.getCode(e);0===n&&(n=e.charCodeAt(0));let i=this.getGraphicDataByCode(n,t);return i&&0===i.polylines.length&&(i.width=t),i}getGraphicDataByCode(e,t){let n=`${e}_${t}`;if(this.textShapesCache.has(n))return this.textShapesCache.get(n);if(0===e)return;let i,r=this.data;if(!this.graphicData.has(e))if(r[e]){let t=r[e],n=PC.DEFAULT_SIZE/this.baseUp;i=Uc.parserCode(this,t,n),this.graphicData.set(e,i)}else if(RC[e]){let t=[];for(let n=0;n<RC[e].length;n++)t.push(RC[e][n].map((e=>new _e(e[0],e[1]))));i=new td(new _e,t),this.graphicData.set(e,i)}if(this.graphicData.has(e)){let n=t/PC.DEFAULT_SIZE;c0e.identity().scale(n,n),i=this.graphicData.get(e).transform(c0e)}return i}getGraphicDataByCodeWithOffset(e,t,n){var i;return null==(i=this.getGraphicDataByCode(e,t))?void 0:i.offset(n)}parseBigFont(e){Gr.ToInt16(e.readBytes(2),0);let t=Gr.ToInt16(e.readBytes(2),0),n=Gr.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=Gr.ToUInt16(new Uint8Array([t[1],t[0]]),0),r=Gr.ToUInt16(t,2),a=Gr.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=Wgt(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.data=r}parseUniFont(e){let t=Gr.ToInt32(e.readBytes(4),0),n=Gr.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=Gr.ToUInt16(e.readBytes(2),0),n=Gr.ToUInt16(e.readBytes(2),0);a[t]=e.readBytes(n)}this.data=a}parseShapeFont(e){e.readBytes(2),e.readBytes(2);let t=Gr.ToInt16(e.readBytes(2),0),n=[];for(let s=0;s<t;s++){let t=Gr.ToUInt16(e.readBytes(2),0),i=Gr.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.data=i}getNotFoundTextShape(e){let t=0;return 1===this.fontType&&(t=Uc.getCode("\uff1f")),2===this.fontType&&(t=Uc.getCode("?")),this.getGraphicDataByCode(t,e)}getFontFile(){return{fontType:this.fontType,order:this.order,data:this.data,info:this.info,orientation:this.orientation,baseUp:this.baseUp,baseDown:this.baseDown,fileName:this.fileName,fileHeader:this.fileHeader,fileVersion:this.fileVersion}}setFontFile(e){this.fileName=e.fileName,this.fontType=e.fontType||2,this.data=e.data,this.info=e.info,this.order=e.order,this.orientation=e.orientation,this.baseUp=e.baseUp,this.baseDown=e.baseDown,this.fileHeader=e.fileHeader,this.fileVersion=e.fileVersion}releaseFontData(){super.releaseFontData(),this.graphicData.clear(),this.textShapesCache.clear()}},nd=PC;function Wgt(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}nd.DEFAULT_SIZE=12;var Vl=class{constructor(){this.fontMap=new Map,this.unsupportedChars={},this.missingFonts={},this.loader=new Zr}loadFonts(e){return it(this,null,(function*(){if(e=Array.isArray(e)?e:[e],this.fileNames=e.map((e=>Vl.getFileName(e.toLowerCase()))),!(yield this.checkAllFontsLoaded(e))){for(let t=0;t<e.length;t++){let n,i=e[t],r=Vl.getFileName(i).toLowerCase();if(Vl.isJsonFile(i)){this.loader.setResponseType("json");let e=yield this.loader.loadAsync(i);n=new Cf(r,e)}else if(Vl.isShxFile(i)){this.loader.setResponseType("arraybuffer");let e=yield this.loader.loadAsync(i);n=new nd(r,e)}else if(Vl.isTtfFile(i)){this.loader.setResponseType("arraybuffer");let e=yield this.loader.loadAsync(i);n=new Cf(r,e)}n&&(n.order=t+1,this.fontMap.set(r,n))}Vl.enableFontCache&&dr.isBrowser&&(this.fontMap.forEach((e=>it(this,null,(function*(){yield e.setFontDataToIndexedDb()})))),this.releaseFontData())}}))}getTextShape(e,t,n){if(0===this.fontMap.size)return void fe.warn("[FontManager] no font loaded.");let i=this.fontMap.get(t.toLowerCase());return i||(i=this.fontMap.get(this.fontMap.keys().next().value),this.missingFonts[t]||(this.missingFonts[t]=0),this.missingFonts[t]++),null==i?void 0:i.generateShapes(e,n)}getCharShape(e,t,n){if(0===this.fontMap.size)return void fe.warn("[FontManager] no font loaded.");null==t&&(t="");let i=this.fontMap.get(t.toLowerCase());if(!i){this.missingFonts[t]||(this.missingFonts[t]=0),this.missingFonts[t]++;for(let[t,r]of this.fontMap)if(r.getCharShape(e,n)){i=r;break}}let r=null==i?void 0:i.getCharShape(e,n);if(r){if(i instanceof nd)return r.toThreeGeometry();if(i instanceof Cf)return new uC(e,{font:i,height:0,size:n||12,curveSegments:3,bevelSegments:3})}}getNotFoundTextShape(e){let t,n;for(let[i,r]of this.fontMap){let i=r.getNotFoundTextShape(e);if(i){t=i,n=r;break}}return n instanceof nd?t.toThreeGeometry():n instanceof Cf?new Ws(t.toShapes(!1),{curveSegments:3,bevelSegments:3}):void 0}checkAllFontsLoaded(e){return it(this,null,(function*(){if(!dr.isBrowser)return!1;let t=!1;for(let n=0;n<e.length;n++){let i=e[n],r=Vl.getFileName(i.toLowerCase()),a=yield Jh.instance().query(r);if(!a){t=!1;break}if(t=!0,void 0!==a.codes){t=!1;break}}return t}))}getFontFromIndexeddb(){return it(this,null,(function*(){if(0!==this.fontMap.size)return;let e=(yield Jh.instance().queryAll()).sort(((e,t)=>e.order-t.order));for(let t=0;t<e.length;t++){let n,i=e[t],{fileName:r,fontType:a}=i;this.fileNames&&!this.fileNames.includes(r)||(n=a?new nd(r,i):new Cf(r,i),this.fontMap.set(r,n))}fe.debug("[FontManager] Loaded font data from cache.")}))}isShxFont(e){if(0===this.fontMap.size)return void fe.warn("[FontManager] no font loaded.");let t=this.fontMap.get(e);return t||(t=this.fontMap.get(this.fontMap.keys().next().value),this.missingFonts[e]||(this.missingFonts[e]=0),this.missingFonts[e]++),t instanceof nd}getUnsupportedChar(){return this.fontMap.forEach((e=>{Object.assign(this.unsupportedChars,e.unsupportedChars)})),this.unsupportedChars}releaseFontData(){this.fontMap.forEach((e=>{e.releaseFontData()})),this.fontMap.clear()}destroy(){this.releaseFontData(),this.fontMap.clear()}static isShxFile(e){return"shx"===Vl.getExtension(e)}static isTtfFile(e){return["WOFF","OTF","TTF"].includes(Vl.getExtension(e).toUpperCase())}static isJsonFile(e){return"json"===Vl.getExtension(e)}static getFileName(e){let t=e.lastIndexOf("/");return e.substring(t+1)}static getExtension(e){return e.substring(e.lastIndexOf(".")+1)}},zm=Vl;zm.enableFontCache=!0;var Hc=new k(1,0,0),l6=new k(0,1,0),n1=new k(0,0,1),u0e=new k(0,0,0),Of=16777215,jgt="CONTINUOUS",IC=new Li({color:Of}),sa=new zn({color:Of}),r1=new cn({color:Of}),h0e=(new Ot).setFromPoints([new k]),d0e=new ht,If=new ht,Ys=new ht,Rn=new k,ri=new k,Lf=new k,VE=new _e,xa=new _r,LC=new an,Df=new Nt,f0e=new Li({color:65280,size:5,depthTest:!1}),p0e=new Li({color:65280,depthTest:!1}),m0e=new Li({color:65280,depthTest:!1}),Xgt=e=>void 0!==e.viewDirectionFromTarget,Ygt=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 rme.decode(e)}}}return null},g0e=(e,t)=>{let n=new _e(e.x,e.y),i=new _e(t.x,t.y);return i.sub(n),i.normalize(),i.y<0?-Math.acos(i.x):Math.acos(i.x)},v0e=(e,t,n)=>({x:e.x+t*Math.cos(n),y:e.y+t*Math.sin(n)}),$gt=(e,t,n,i)=>{let r=e?new _e(e.x,e.y):new _e(0,0),a=t?new _e(t.x,t.y):new _e(1,0);n=n||1;let s=4*Math.atan(n),o=r.distanceTo(a)/2/Math.sin(s/2),l=v0e(e,o,g0e(r,a)+(Math.PI/2-s/2));i=i||Math.max(Math.abs(Math.ceil(s/(Math.PI/18))),6);let h=g0e(l,r),u=s/i,c=[];c.push(new k(r.x,r.y,0));for(let d=1;d<=i-1;d++){let e=v0e(l,Math.abs(o),h+u*d);c.push(new k(e.x,e.y,0))}return c},y0e=(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=C5(o,t,s,n,r);a.push(new k(e[0],e[1],0))}return a},c6=(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=$gt(a,s,t);n.push(...o)}else n.push(new k(a.x,a.y,0))}return n},Zgt=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},Kgt=e=>{let t=[],n=[];e.forEach((e=>{e.polyfaceMeshVertex&&(e.threeDPolylineMesh?t.push(new k(e.x,e.y,e.z)):n.push(Zgt(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},Zn=class extends xr{constructor(e,t){super(e),this.timer=Date.now(),this.ignorePaperSpace=!1,this.encoding="UTF-8",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:{},unsupportedPolylineCount:0,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)}},Zn.abortJobs=!1,t&&(this.ignorePaperSpace=!0===t.ignorePaperSpace,this.enableLocalCache=!1!==t.enableLocalCache,this.enableMerge=!1!==t.enableMerge,this.encoding=t.encoding||"UTF-8",null!=t.overrideColor&&(this.overrideColor=An.rgb2Hex(t.overrideColor)),null!=t.overrideHatchPatternLineThickness&&(this.overrideHatchPatternLineThickness=t.overrideHatchPatternLineThickness)),this.pointsMaterials[Of]=IC,this.lineBasicMaterials[Of]=sa,this.meshBasicMaterials[Of]=r1}setFont(e){this.font=e}download(e,t){return it(this,null,(function*(){let n=Ygt(e);if(!n){let i=Date.now(),r=new Zr(this.manager);r.setResponseType("arraybuffer"),r.setPath(this.path),n=yield r.loadAsync(e,t),fe.info(`[DxfLoader] ${e} dxf file downloaded in ${(Date.now()-i)/1e3}s`)}return n}))}load(e,t,n){return it(this,null,(function*(){return this.enableLocalCache&&t&&(t=t.trim()).length>0&&(this.dxfDataId=t),this.loadAsync(e,n)}))}loadAsync(e,t){return it(this,null,(function*(){let n=Pt.getUpdateSubProgressFunc(0,50,t),i=Pt.getUpdateSubProgressFunc(50,100,t),r=Pt.getUpdateSubProgressFunc(10,100,t);if(dr.isBrowser&&this.enableLocalCache&&this.dxfDataId){let t;try{if(this.timer=Date.now(),t=yield this.getDxfDataFromIndexedDb(this.dxfDataId),t){this.tryFixDxfData(t),fe.info(`[DxfLoader] Loaded DxfData from indexedDb in ${(Date.now()-this.timer)/1e3}s`);let e=yield this.loadEntities(t,r);return Promise.resolve(e)}}catch(e){fe.warn("[DxfLoader] Failed to parse data from indexedDb",e)}}let a=yield this.parse(e,n);return this.tryFixDxfData(a),yield this.loadEntities(a,i)}))}parse(e,t){return it(this,null,(function*(){let n=Pt.getUpdateProgressFunc(t),i=Pt.getUpdateSubProgressFunc(0,40,t),r=yield this.download(e,i);if(!r)return Promise.reject(`[DxfLoader] Failed to download ${e}`);if(Zn.abortJobs)return Promise.reject("[DxfLoader] Job aborted");this.timer=Date.now(),fe.info("[DxfLoader] Start parsing...");let a=new km(this.encoding).parseSync(r);if(this.tryFixDxfData(a),n(80),fe.info(`[DxfLoader] Parsed in ${(Date.now()-this.timer)/1e3}s, creating entities...`),Zn.abortJobs)return Promise.reject("[DxfLoader] Job aborted");if(a&&dr.isBrowser&&this.enableLocalCache&&this.dxfDataId){let t=Date.now();try{yield this.setDxfDataToIndexedDb(this.dxfDataId,a),fe.info(`[DxfLoader] Saved to indexedDb in ${(Date.now()-t)/1e3}s`)}catch(e){fe.warn(`[DxfLoader] Failed to save '${this.dxfDataId}' to indexedDb!`,e)}}return n(100),a}))}parseHeader(e){if(!e)return void fe.error("[DxfLoader]: Invalid header!");this.header=e;let t=e.$ACADVER.toString();"AC1032"!==t&&fe.warn(`[DxfLoader] Unexpected version: ${t}. But we'll try to continue.`),this.angBase=e.$ANGBASE||0,this.angDir=e.$ANGDIR||0}tryFixDxfData(e){e&&(e.objects||(fe.warn("[DxfLoader] No objects found, Will add one."),e.objects={}),e.objects.LAYOUT||(fe.warn("[DxfLoader] No layout defined! Will add a default 'Model' layout!"),e.objects.LAYOUT=[{layoutName:Zn.MODEL_LAYOUT_NAME}]),e.tables||(fe.warn("[DxfLoader] No tables found, Will add one."),e.tables={}),e.tables.layer||(e.tables.layer={}),e.tables.layer.layers||(e.tables.layer.layers={}))}loadEntities(e,t){return it(this,null,(function*(){let n=Date.now();this.parseHeader(e.header),this.enableRenderOrder&&(this.initRenderOrderInfo(e),this.enableMerge=!1),this.getFontFilesFromDxf(e);let i=0,r=e.entities.length;this.entityCount=r,Object.keys(e.blocks).forEach((t=>{var n;this.entityCount+=(null==(n=e.blocks[t].entities)?void 0:n.length)||0}));let a=Pt.getUpdateProgressFuncForLoop(r,t),s={},o=e=>{let t=e.userData.layerName,n=s[t];n||(n=[],s[t]=n),n.push(e)},l={},h={},u=new pn;for(let t=0;t<r&&!Zn.abortJobs;t++){let n=e.entities[t];this.addViewport(n,l);let r=this.drawEntity(n,e);if(r||(yield a(t)),!r)continue;let s=this.getLayout(e,n).layoutName,c=u.children.find((e=>e.name===s));if(c||(c=new pn,c.name=s,c.userData.isLayoutLevelObject=!0,u.add(c)),r.traverse((e=>{e.userData.isSnapObject&&(this.layoutsSnapObjectsMap[s]||(this.layoutsSnapObjectsMap[s]=[]),this.layoutsSnapObjectsMap[s].push(e))})),this.enableMerge){Dc.merge(r,!1),h[s]||(h[s]={object:c,layerObjects:{}});let e=h[s];if(r.geometry){let t=r.userData.layerName;e.layerObjects[t]||(e.layerObjects[t]=[]),e.layerObjects[t].push(r),r.children.forEach((e=>{e.userData.isSnapObject&&o(e)}))}else r.children.length>0&&(c.add(r),r.traverse((e=>{e.geometry&&o(e)})))}else c.add(r),r.traverse((e=>{e.geometry&&o(e)}));i++,yield a(t)}e.objects.LAYOUT.forEach((t=>{let n=t,i=n.layoutName;if(this.ignorePaperSpace&&i!==Zn.MODEL_LAYOUT_NAME)return;let r=n.associatedBlockName,a=e.blocks[r];a&&this.drawLayout(a,e,n,u,s,l)})),fe.debug(`[DxfLoader] Drew entities in ${(Date.now()-n)/1e3}s`);for(let t in this.layoutsSnapObjectsMap){let n=u.children.find((e=>e.name===t)),i=new pn;i.name=Zn.SNAP_GROUP_NAME,i.userData.isSnapGroup=!0,n.add(i);let r=this.layoutsSnapObjectsMap[t];for(let t=0;t<r.length;t++){let n=r[t],a=n.userData.layerName;!1===this.getLayerVisible(e,a)&&n.layers.disable(11),Zn.SHOW_SNAP_OBJECT&&(n.layers.enableAll(),n.material instanceof Li?n.material=f0e:n.material instanceof zn?n.material=p0e:n.material instanceof cn&&(n.material=m0e));let s=n,o=Ys.identity();for(;s&&!0!==s.userData.isLayoutLevelObject;)o.premultiply(s.matrix),s=s.parent;n.matrix.copy(o),i.add(n)}}if(this.enableMerge)for(let e in h){let t=h[e],n=t.object;for(let e in t.layerObjects){let i=t.layerObjects[e],r=Dc.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),o(e))}}for(let e=0;e<a.length;e++){let t=a[e];n.add(t),o(t)}t.layerObjects[e]=[]}}this.printStatsInfo(),this.enableReleaseData&&(this.releaseCachedData(),this.releaseDxfData(e)),this.enableMerge&&Zn.mergeDxfObjects({root:u,layersAndObjects:s});let c=u.convertToThreejsObject();u.clear(),s={};let d={};e.objects.LAYOUT.forEach((e=>{let t=e;d[t.layoutName]=t}));let p={};c.children.forEach((t=>{if(rr.setSharedVariablesOfObject(t),!t.userData.isLayoutLevelObject)return;let n,i=t.name;if(i!==Zn.MODEL_LAYOUT_NAME){let e=d[i];e.directAssociatedLeafObjectSet||(e.directAssociatedLeafObjectSet=new Set),n=e.directAssociatedLeafObjectSet}t.traverse((t=>{if(rr.setSharedVariablesOfObject(t),t.userData.isSnapGroup&&(t.visible=Zn.SHOW_SNAP_OBJECT),t.geometry){let i=t.userData.layerName;!1===this.getLayerVisible(e,i)&&(t.visible=!1,t.userData.layerVisible=!1),(e=>{let t=e.userData.layerName,n=p[t];n||(n=[],p[t]=n),n.push(e)})(t),n&&n.add(t)}}))})),fe.info(`[DxfLoader] loadEntities() done in ${(Date.now()-n)/1e3}s`);let f=Ci(Ir({},e),{threejsObject:c,layersAndThreejsObjects:p,loadedEntityCount:i,layoutViewportsMap:l});return Promise.resolve(f)}))}getFontFilesFromDxf(e){var t,n;let i=new Set,r=null==(n=null==(t=e.tables)?void 0:t.style)?void 0:n.styles;if(r)for(let a in r){let e=r[a],t=e.fontFile,n=e.bigFontFile;t&&i.add(t),n&&i.add(n)}fe.info(`[DxfLoader] These are fonts used by dxf: ${Array.from(i).join()}`)}loadEntitiesForCompare(e,t,n,i=!0,r){return it(this,null,(function*(){let a=e.entities.length,s=t.entities.length,o=()=>it(this,null,(function*(){var o;let l=this.compareContext,h=l.isTheFirstFile,u=h?e:t,c=new pn,d=h?a:s,p=u.entities.length;this.entityCount=p,Object.keys(u.blocks).forEach((e=>{var t;this.entityCount+=(null==(t=u.blocks[e].entities)?void 0:t.length)||0}));let f=Math.round(Math.pow(d,.5)),m=Date.now(),g=e=>it(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 Pt.sleep(0),m=i)}}));this.parseHeader(u.header);let v={};for(let e=0;e<d;e++){if(Zn.abortJobs)return;let t=u.entities[e],n=this.getLayout(u,t);if(n.layoutName!==Zn.MODEL_LAYOUT_NAME){yield g(e);continue}let i=this.drawEntity(t,u);if(!i){yield g(e);continue}let r=c.children.find((e=>e.name===Zn.MODEL_LAYOUT_NAME));r||(r=new pn,r.name=Zn.MODEL_LAYOUT_NAME,r.userData.isLayoutLevelObject=!0,c.add(r)),r.add(i),i.traverse((e=>{if(e.geometry){let t=e.userData.layerName,r=this.getLayerVisible(u,t);e.userData.isSnapObject&&(this.layoutsSnapObjectsMap[n.layoutName]||(this.layoutsSnapObjectsMap[n.layoutName]=[]),this.layoutsSnapObjectsMap[n.layoutName].push(e),!1===r&&i.layers.disable(11));let a=v[t];a||(a=[],v[t]=a),a.push(e)}})),yield g(e)}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)}if("NoChange"!==t.type&&i){let e=i.parent,n=Ys.identity();for(;e&&!0!==e.userData.isLayoutLevelObject;)n.premultiply(e.matrix),e=e.parent;Df.makeEmpty();let r=pn.getBox(i,Df);r.applyMatrix4(n),"Added"===t.type?!h&&(t.box=(new Nt).copy(r)):"Removed"===t.type?h&&(t.box=(new Nt).copy(r)):"Modified"===t.type&&(t.box?t.box.union(r):t.box=(new Nt).copy(r))}}for(let e in this.layoutsSnapObjectsMap){let t=c.children.find((t=>t.name===e)),n=new pn;n.name=Zn.SNAP_GROUP_NAME,t.add(n);let i=this.layoutsSnapObjectsMap[e];for(let e=0;e<i.length;e++){let t=i[e];Zn.SHOW_SNAP_OBJECT&&(t.layers.enableAll(),t.material instanceof Li?t.material=f0e:t.material instanceof zn?t.material=p0e:t.material instanceof cn&&(t.material=m0e));let r=t,a=Ys.identity();for(;r&&!0!==r.userData.isLayoutLevelObject;)a.premultiply(r.matrix),r=r.parent;t.matrix.copy(a),n.add(t)}}this.enableMerge&&Zn.mergeDxfObjects({root:c,layersAndObjects:v});let y=c.convertToThreejsObject();c.clear(),v={};let x={};y.children.forEach((e=>{rr.setSharedVariablesOfObject(e),e.userData.isLayoutLevelObject&&e.traverse((e=>{if(rr.setSharedVariablesOfObject(e),e.userData.isSnapGroup&&(e.visible=Zn.SHOW_SNAP_OBJECT),e.geometry){let t=e.userData.layerName;!1===this.getLayerVisible(u,t)&&(e.visible=!1,e.userData.layerVisible=!1),(e=>{let t=e.userData.layerName,n=x[t];n||(n=[],x[t]=n),n.push(e)})(e)}}))}));let b=u;b.threejsObject=y,b.layersAndThreejsObjects=x,b.layoutViewportsMap={}})),l=Date.now();this.compareContext={changes:n,isTheFirstFile:!0},Pt.printMemory("Before loading entities for first dxf"),yield o(),fe.info(`[DxfLoader] loadEntities for first dxf in ${(Date.now()-l)/1e3}s`),Pt.printMemory("After loading entities for first dxf"),this.releaseCachedData(!1),this.releaseDxfData(e),Pt.printMemory("Before loading entities for second dxf"),l=Date.now(),this.compareContext.isTheFirstFile=!1,yield o(),fe.info(`[DxfLoader] loadEntities for second dxf in ${(Date.now()-l)/1e3}s`),this.printStatsInfo();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)),Pt.printMemory("After loading entities for second dxf")}))}setObjectColorByChange(e,t){let n=(e,t)=>{e.traverse((e=>{if(e.material)if(e.material instanceof zn)e.material=this.getLineBasicMaterial(t);else if(e.material instanceof cn)e.material=this.getMeshBasicMaterial(t);else if(e.material instanceof Li)e.material=this.getPointsMaterial(t);else if(e.material instanceof hn){let n=e.material.clone();Zn.updateMaterialUniforms(n),n.uniforms.u_color.value.set(t),e.material=n}}))},i=(e=>{var t;let n=js.ENTITY_COLOR_NO_CHANGE;return"Added"===e.type?n=js.ENTITY_COLOR_ADDED:"Removed"===e.type?n=js.ENTITY_COLOR_REMOVED:"Modified"===e.type&&(n=null!=(t=this.compareContext)&&t.isTheFirstFile?js.ENTITY_COLOR_REMOVED:js.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:{},unsupportedPolylineCount:0,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)&&Lm.includes(e.type)&&(i=!0),!i&&this.compareContext&&this.compareContext.preservedHandles&&!Lm.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,n,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):"ACAD_TABLE"===e.type&&(r=this.drawTable(e,t));r&&(this.entityThreejsCache[e.handle]=r),this.enableReleaseData&&!this.compareContext&&this.releaseEntity(e)}if(r){let i=this.getLayerName(e,t,n);r.userData.handle=e.handle,"INSERT"!==e.type&&"DIMENSION"!==e.type&&r.traverse((r=>{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 Lm.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,Lm.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),Zt.areNumbersEqual(i,r,1e-5))return void fe.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=Zt.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 Gh(e.center.x,e.center.y,s,o,i,r,!1,l),u=1,c=n;null!=c&&c.xScale&&null!=c&&c.yScale&&(u=Math.max(Math.abs(c.xScale),Math.abs(c.yScale)));let d=this.getDivision(i,r,Math.max(s,o)*u),p=h.getPoints(d),f=[],m=p.length;for(let _=0;_<m-1;_++)Zt.areVector2sEqual(p[_],p[_+1],1e-9)||f.push(p[_]);if(f.push(p[m-1]),f.length<2)return void fe.warn("[DxfLoader] Ellipse entity (handle '%s') contains less than 2 points, ignored!",e.handle);let g=new k,v=!1;this.enableRTC&&(v=en.checkAndRebasePositionsOnRTC(f,g));let y=(new Ot).setFromPoints(f),x=new pn(2);x.geometry=y,x.material=sa;let b=new pn(1);return b.geometry=h0e,b.material=IC,b.matrix.setPosition(e.center.x,e.center.y,e.center.z),b.userData.isSnapObject=!0,b.userData.type="CircleCenter",b.layers.set(11),x.add(b),v&&(this.setRTCUserData(x),x.matrix.setPosition(g.x,g.y,0)),x.layers.enableAll(),x}drawMText(e,t,n){if(!e.text)return;if(!this.font)return void fe.info("[DxfLoader] Font file not set, ignoring text entity.");let i=this.getTextStyle(t,e),r=oC(e.text,{encoding:this.getTextEncoding(i)}),a=this.getMTextGroup(r,e,i,t,n),s=a&&a.object;if(!s)return;s.matrix.decompose(ri,xa,Lf),e.position&&(ri.x+=e.position.x,ri.y+=e.position.y,s.matrix.compose(ri,xa,Lf)),Df.makeEmpty();let o=pn.getBox(s,Df).getSize(Rn),l=e.width||o.x,h=e.height||o.y,u=0,c=0;switch(e.attachmentPoint){case 1:u=0,c=0;break;case 2:u-=l/2,c=0;break;case 3:u-=l,c=0;break;case 4:u=0,c+=h/2;break;case 5:u-=l/2,c+=h/2;break;case 6:u-=l,c+=h/2;break;case 7:u=0,c+=h;break;case 8:u-=l/2,c+=h;break;case 9:u-=l,c+=h;break;default:return}s.traverse((e=>{e.geometry&&e.geometry.translate(u,c,0),e.layers.enableAll()}));let d=0;if(e.rotation&&(d=e.rotation*Math.PI/180),e.directionVector){let t=e.directionVector,n=new k(t.x,t.y,t.z),i=n.clone().cross(Hc),r=Hc.angleTo(n);d=i.z>0?-r:r}en.shouldRebasePositionOnRTC(ri)&&this.setRTCUserData(s),s.matrix.compose(ri,xa,Lf);let p=e.position?ri.clone().sub(e.position):ri;return If.makeTranslation(-p.x,-p.y,0),Ys.makeRotationZ(d),s.matrix.multiply(If),s.matrix.multiply(Ys),s.matrix.multiply(If.invert()),s}getMTextGroup(e,t,n,i,r,a=0,s=0,o=[]){var l,h,u,c;if(0===e.length)return;let d=t.height||t.contextData&&t.contextData.textHeight||0;if(t.textStyle){if(n&&n.fontFile&&n.fontFile.endsWith(".shx")){let e=`${n.fontFile}_${n.styleName}`;this.statsInfo.unsupportedTextStyles[e]||(this.statsInfo.unsupportedTextStyles[e]=0),this.statsInfo.unsupportedTextStyles[e]++}d=d||n.textHeight}let p=t.lineSpaceFactor||1,f="Left";t.width&&t.attachmentPoint&&([1,4,7].includes(t.attachmentPoint)?f="Left":[2,5,8].includes(t.attachmentPoint)?f="Center":[3,6,9].includes(t.attachmentPoint)&&(f="Right"));let m,g=t.width||0,v=new pn,y=n.fontFile,x=1,b=1,_=256,w=p*d*.3,S=w+d;for(let M=0;M<e.length;M++){let E=e[M];if("string"==typeof E){let e,M=[],T=e=>{let t;if(e.forEach(((e,n)=>{e.boundingBox||e.computeBoundingBox(),0===n?t=e.boundingBox:t.union(e.boundingBox)})),t){let n=t.getSize(Rn);switch(f){case"Left":default:break;case"Center":e.forEach((e=>e.translate((g-n.x)/2,0,0)));break;case"Right":e.forEach((e=>e.translate(g-n.x,0,0)))}}M.push(...e)};for(let t=0;t<E.length;t++){let i=E[t];if("\n"!==i)if(w=p*d*.3,S=w+d,e=null==(l=this.font)?void 0:l.getCharShape(i,y,d),n.bigFontFile&&!e&&(e=null==(h=this.font)?void 0:h.getCharShape(i,n.bigFontFile,d)),e||(e=null==(u=this.font)?void 0:u.getCharShape(i,"",d)),e||(e=null==(c=this.font)?void 0:c.getNotFoundTextShape(d)),e)if(e.translate(a,s,0),e.scale(x,1,1),a>(g||1/0))a=0,s-=S,o.length>0&&T(o),o=[];else{e.boundingBox||e.computeBoundingBox();let t=e.boundingBox.getSize(Rn).x;" "===i&&(t=d/2),a+=t+b*(d/6),o.push(e)}else a+=d+b*(d/6);else a=0,s-=S,o.length>0&&T(o),o=[]}o.length>0&&(T(o),o=[]);let A=new pn;if(M.length>0){m||(m=t.colorIndex),void 0!==_&&256!==_?(t.color=Dm(_),t.colorIndex=_):t.colorIndex=m;let e=this.getColor(t,i,r),n=M.filter((e=>e instanceof Ws)),a=M.filter((e=>!(e instanceof Ws)));if(n.length>0){let t=new pn(4);t.geometry=Oi(n),t.material=this.getMeshBasicMaterial(e),A.add(t)}if(a.length>0){let t=new pn(3);t.geometry=Oi(a),t.material=this.getLineBasicMaterial(e),A.add(t)}}A.matrix.makeTranslation(0,-d,0),v.add(A),x=1,b=1,_=256,p=t.lineSpaceFactor||1}else if(Array.isArray(E)){let e=this.getMTextGroup(E,t,n,i,r,a,s,o);e&&(v.add(e.object),a=e.hOffset,s=e.vOffset)}else"object"==typeof E&&(E.f&&(y=E.f,y&&y.includes(".shx")&&fe.info(`[DxfLoader] Doesn't support custom fonts: ${y}`)),E.C&&(_=E.C),E.W&&(x="x"===E.W[1]?E.W[0]*t.width:E.W[0]),E.H&&(d="x"===E.H[1]?E.H[0]*t.height:E.H[0]),E.T&&(b=E.T))}return 0!==v.children.length?(Dc.merge(v,!1),m&&(t.colorIndex=m),1===v.children.length?{object:v.children[0],hOffset:a,vOffset:s}:{object:v,hOffset:a,vOffset:s}):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);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 fe.warn("[DxfLoader] Entity is missing vertices:",e.handle);let t=e.vertices.map((e=>new k(e.x,e.y,e.z)));if(0===t.length)return;Zt.areVector3sEqual(t[0],t[t.length-1])||t.push(t[0]);let n=new k,i=!1;this.enableRTC&&(i=en.checkAndRebasePositionsOnRTC(t,n));let r=(new Ot).setFromPoints(t),a=new pn(2);return a.geometry=r,a.material=sa,i&&(this.setRTCUserData(a),a.matrix.setPosition(n.x,n.y,0)),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),u=y0e(e.controlPoints,e.degreeOfSplineCurve,e.knotValues,h),c=new k,d=!1;this.enableRTC&&(d=en.checkAndRebasePositionsOnRTC(u,c));let p=en.getAdjacentNonRepeatPoints(u);if(p.length<2)return void fe.warn("[DxfLoader] Spline entity (handle '%s') contains less than 2 points, ignored!",e.handle);let f=(new Ot).setFromPoints(p),m=new pn(2);return m.geometry=f,m.material=sa,d&&(this.setRTCUserData(m),m.matrix.setPosition(c.x,c.y,0)),m.layers.enableAll(),m}drawXLine(e){if(!e.vertices||0===e.vertices.length)return void fe.warn("[DxfLoader] Entity is missing vertices:",e.handle);let t=Pt.arrayOrObjectToVector3(e.directionVector),n=new k(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 k,a=!1;this.enableRTC&&(a=en.checkAndRebasePositionsOnRTC(i,r));let s=(new Ot).setFromPoints(i),o=new pn(2);return o.geometry=s,o.material=sa,a&&(this.setRTCUserData(o),o.matrix.setPosition(r.x,r.y,0)),o.layers.enableAll(),o}drawRay(e){if(!e.vertices||0===e.vertices.length)return void fe.warn("[DxfLoader] Entity is missing vertices:",e.handle);let t=Pt.arrayOrObjectToVector3(e.directionVector),n=e.vertices.map((e=>new k(e.x,e.y,0)));if(n.push(t.multiplyScalar(1e6).add(n[0])),0===n.length)return;let i=new k,r=!1;this.enableRTC&&(r=en.checkAndRebasePositionsOnRTC(n,i));let a=(new Ot).setFromPoints(n),s=new pn(2);return s.geometry=a,s.material=sa,r&&(this.setRTCUserData(s),s.matrix.setPosition(i.x,i.y,0)),s.layers.enableAll(),s}drawLine(e){if(!e.vertices||0===e.vertices.length)return void fe.warn("[DxfLoader] Entity is missing vertices:",e.handle);let t=[];if(e.isPolyfaceMesh)t=Kgt(e.vertices);else{let n=c6(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];Zt.areVector3sEqual(e,i)&&t[s].length<=2?(n.push(e),t.splice(s,1)):s++}let i,r=new k,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=en.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 k(o,l,h))):e.push(t[i]),i>0&&n.push(s+i-1,s+i);s=t.length}));let u=(new Ot).setFromPoints(e);u.setIndex(n),i=new pn(3),i.geometry=u,i.material=sa}if(n.length>0){this.enableRTC&&(a=en.checkAndRebasePositionsOnRTC(n,r));let e=(new Ot).setFromPoints(n);i=new pn(1),i.geometry=e,i.material=IC}return i?(a&&(this.setRTCUserData(i),i.matrix.setPosition(r.x,r.y,0)),i.layers.enableAll(),i):void 0}drawLWPolyline(e,t,n){var i,r,a;if(!e.vertices||e.vertices.length<2)return void fe.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){Rn.set(s.extrusionDirectionX,s.extrusionDirectionY,s.extrusionDirectionZ);let e=Zn.getOcsMatrix(Rn).invert(),t=0;void 0!==s.elevation&&s.elevation>0&&(t=s.elevation),s.vertices.forEach((n=>{let i=Rn.set(n.x,n.y,t).applyMatrix4(e);n.x=i.x,n.y=i.y}))}let o=c6(e.vertices,e.shape);if(e.shape&&o.length>0&&!Zt.areVector3sEqual(o[0],o[o.length-1])&&o.push(o[0]),o.length<2)return void fe.warn("[DxfLoader] Invalid LWPolyline entity (handle '%s'), ignored!",e.handle);let l=new pn;if(null!=(i=e.extendedData)&&i.outlines){let t=e.extendedData.outlines,n=[];t.forEach((e=>{let t=new Ts;e.forEach(((e,n)=>{0===n?t.moveTo(e[0],e[1]):t.lineTo(e[0],e[1])})),t.closePath(),n.push(new Al(t))}));let i=Oi(n),r=new pn(4);r.geometry=i,r.material=r1,r.layers.enableAll(),l.add(r)}let h=new k,u=!1;this.enableRTC&&(u=en.checkAndRebasePositionsOnRTC(o,h));let c=en.getAdjacentNonRepeatPoints(o);if(c.length<2)return void fe.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){this.statsInfo.unsupportedPolylineCount++;let t=en.convertWidthLineToMeshGeometry(c,s.constantWidth);if(t){let e=new pn(4);e.geometry=t,e.material=r1,e.layers.enableAll(),e.layers.disable(11),l.add(e);let n=rr.createOutline(t,sa,e.matrix),i=new pn(3);i.geometry=n.geometry,i.material=n.material,i.matrix=n.matrix,i.layers.enableAll(),i.layers.disable(11),l.add(i)}else fe.warn("[DxfLoader] Failed to convert line with width to mesh geometry: %s",e.handle)}}let d=new pn(2);return d.geometry=(new Ot).setFromPoints(c),d.material=sa,d.layers.enableAll(),l.children.length>0?l.add(d):l=d,u&&(this.setRTCUserData(l),l.matrix.setPosition(h)),l}drawMLeader(e,t,n){var i,r,a,s,o,l,h;let u=t.tables.dimStyle.dimStyles[e.dimensionStyle]||this.getDefaultDimensionStyle(t),c=null==(i=e.contextData)?void 0:i.defaultTextContents;if(!c)return;let d=new pn,p=oC(c),f=this.getTextStyle(t,e),m=this.getMTextGroup(p,e,f,t,n),g=m&&m.object;if(g){g.matrix.decompose(ri,xa,Lf),null!=(r=e.contextData)&&r.textLocation&&(ri.x+=e.contextData.textLocation.x,ri.y+=e.contextData.textLocation.y,g.matrix.compose(ri,xa,Lf)),Df.makeEmpty();let t=pn.getBox(g,Df).getSize(Rn),n=t.x,i=t.y,l=0,h=0;switch(null==(a=e.contextData)?void 0:a.textAttachment){case 1:l=0,h=0;break;case 2:l-=n/2,h=0;break;case 3:l-=n,h=0;break;case 4:l=0,h+=i/2;break;case 5:l-=n/2,h+=i/2;break;case 6:l-=n,h+=i/2;break;case 7:l=0,h+=i;break;case 8:l-=n/2,h+=i;break;case 9:l-=n,h+=i;break;default:return}g.traverse((e=>{e.geometry&&e.geometry.translate(l,h,0)}));let u=0;if(null!=(s=e.contextData)&&s.textRotation&&(u=e.contextData.textRotation*Math.PI/180),null!=(o=e.contextData)&&o.textDirection){let t=e.contextData.textDirection,n=new k(t.x,t.y,t.z),i=n.clone().cross(Hc),r=Hc.angleTo(n);u+=i.z>0?-r:r}en.shouldRebasePositionOnRTC(ri)&&this.setRTCUserData(g),g.matrix.compose(ri,xa,Lf),e.contextData.textLocation?Rn.set(e.contextData.textLocation.x,e.contextData.textLocation.y,0):Rn.set(0,0,0);let c=ri.clone().sub(Rn);If.makeTranslation(-c.x,-c.y,0),Ys.makeRotationZ(u),g.matrix.multiply(If),g.matrix.multiply(Ys),g.matrix.multiply(If.invert()),g.renderOrder=5,d.add(g)}if(0===e.leaderLineType)return null==g||g.traverse((e=>{e.layers.enableAll()})),g;{let n=[],i=null==(l=e.contextData)?void 0:l.leaders[0];if(!i)return d;let r=i.lastLeaderLinePoint;if(e.enableDogLeg){let e=new k(r.x,r.y,r.z),t=i.doglegLength,a=new k(i.doglegVector.x,i.doglegVector.y,i.doglegVector.z).multiplyScalar(t),s=e.clone().add(a);n.push(s,e)}let a=(null==(h=e.contextData)?void 0:h.leaders[0].leaderLines)||[];for(let l=0;l<a.length;l++){let i=a[l].vertices[0].reverse().map((e=>new k(e.x,e.y,e.z))),s=new k(r.x,r.y,r.z);for(let e=0;e<i.length;e++)n.push(s,i[e]),s=i[e];let o=Rn.subVectors(n[0],n[1]).length(),h=(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 k(n[n.length-1].x,n[n.length-1].y,n[n.length-1].z),t=new k(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);Rn.copy(e),ri.setScalar(h),xa.setFromAxisAngle(n1,i),a.matrix.compose(Rn,xa,ri),d.add(a)}}}else this.drawDefaultLeadArrow(n[n.length-2],n[n.length-1],o/2e3,n)}let s=new k,o=!1;this.enableRTC&&(o=en.checkAndRebasePositionsOnRTC(n,s));let c=(new Ot).setFromPoints(n),p=new pn(3);p.geometry=c,p.material=sa,p.renderOrder=2,o&&(this.setRTCUserData(p),p.matrix.setPosition(s.x,s.y,0)),d.add(p)}return Dc.merge(d,!1),d.traverse((e=>{e.layers.enableAll()})),1===d.children.length?d.children[0]:d}drawLeader(e,t,n){let i=[];if(!e.vertices)return void fe.warn("[DxfLoader] Entity is missing vertices:",e.handle);if(e.vertices.length<2)return void fe.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 hm(e.vertices).getPoints(50)),e.textWidth){let t=e.textWidth,n=new k(a[a.length-1].x,a[a.length-1].y,a[a.length-1].z);if(0===e.direction){let e=new k(1,0,0).multiplyScalar(t);a.push(e.add(n))}else{let e=new k(-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=Rn.subVectors(i[0],i[1]).setZ(0).length(),o=(e.arrowHeight||r.DIMASZ||2.5)*(e.arrowHeadScale||r.DIMSCALE||1),l=new pn;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=Dm(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 k(i[0].x,i[0].y,i[0].z),t=new k(i[1].x,i[1].y,i[1].z),n=Math.atan2(e.y-t.y,e.x-t.x);Rn.copy(e),ri.setScalar(o),xa.setFromAxisAngle(n1,n),r.matrix.compose(Rn,xa,ri),l.add(r)}}}else this.drawDefaultLeadArrow(i[1],i[0],o/s/2,i)}if(0===i.length)return;let h=new k,u=!1;this.enableRTC&&(u=en.checkAndRebasePositionsOnRTC(i,h));let c=(new Ot).setFromPoints(i),d=new pn(2);return d.geometry=c,d.material=sa,d.renderOrder=2,u&&(this.setRTCUserData(d),d.matrix.setPosition(h.x,h.y,0)),l.children.length>0?(l.add(d),Dc.merge(l,!1),l.traverse((e=>{e.layers.enableAll()})),1===l.children.length?l.children[0]:l):(d.layers.enableAll(),d)}getTableTextOffset(e,t,n){let i=new k;switch(e){case 1:break;case 2:i.setX(t/2);break;case 3:i.setX(t);break;case 4:i.setY(-n/2);break;case 5:i.set(t/2,-n/2,0);break;case 6:i.set(t,-n/2,0);break;case 7:i.setY(-n);break;case 8:i.set(t/2,-n,0);break;case 9:i.set(t,-n,0)}return i}drawTable(e,t,n){if(!e.startPoint)return void fe.warn("[DxfLoader] Entity is missing startPoint:",e.handle);if(0===e.cells.length)return void fe.warn("[DxfLoader] Entity is missing cells:",e.handle);if(0===e.rowHeightArr.length)return void fe.warn("[DxfLoader] Entity is missing rowHeightArr:",e.handle);if(0===e.columnWidthArr.length)return void fe.warn("[DxfLoader] Entity is missing columnWidthArr:",e.handle);let i=new pn,{cells:r,rowCount:a,columnCount:s,rowHeightArr:o,columnWidthArr:l}=e,h=[],u=0,c=0;for(let m=0;m<=a;m++){u+=m>0?o[m-1]:0,Rn.set(0,-u,0);let e=[Rn.clone()];for(let t=0;t<s;t++){ri.set(l[t],0,0);let n=Rn.add(ri);e.push(n.clone())}h.push(e)}for(let m=0;m<=s;m++){c+=m>0?l[m-1]:0,Rn.set(c,0,0);let e=[Rn.clone()];for(let t=0;t<a;t++){ri.set(0,-o[t],0);let n=Rn.add(ri);e.push(n.clone())}h.push(e)}let d=[];h.forEach((e=>{for(let t=0;t<e.length-1;t++)d.push(e[t],e[t+1])}));let p=(new Ot).setFromPoints(d),f=new pn(3);f.geometry=p,f.material=sa,f.layers.enableAll(),i.add(f),c=0;for(let m=0;m<s;m++){let h=l[m];c+=m>0?l[m-1]:0,u=0;for(let l=0;l<a;l++){let a=o[l];u+=l>0?o[l-1]:0,Rn.set(c,-u,0);let d=r[l*s+m];if(d){d.colorIndex=e.colorIndex,d.height=d.textHeight;let r=this.getTableTextOffset(d.attachmentPoint,h,a);d.position=Rn.clone().add(r);let s=this.drawMText(d,t,n);s&&i.add(s)}}}if(e.blockRecordHandle){let n=this.getBlockByHandle(t.blocks,e.blockRecordHandle);if(n&&n.entities)for(let r=0;r<n.entities.length;r++){let a=n.entities[r],s=this.drawEntity(a,t,e);s&&i.add(s)}}return i.matrix.decompose(Rn,xa,Lf),Rn.x+=e.startPoint.x,Rn.y+=e.startPoint.y,i.matrix.compose(Rn,xa,Lf),i}drawDefaultLeadArrow(e,t,n,i){let r=n*(e.x-t.x),a=n*(e.y-t.y),s=a,o=-r,l=new k(t.x+r+s/6,t.y+a+o/6,0),h=new k(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 hn&&(e.uniforms.u_cameraZoom&&(e.uniforms.u_cameraZoom=Zn.cameraZoomUniform),e.uniforms.u_viewportScale&&(e.uniforms.u_viewportScale=Zn.viewportScaleUniform))}static transformAngleByOcsMatrix(e,t){let n=Rn.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=Zt.getArcAngleSpanInRadian(t,n),a=Zn.transformAngleByOcsMatrix(e,t),s=Zn.transformAngleByOcsMatrix(e,n);if(Zt.areNumbersClose(r,Math.PI)){r=1;let n=Zn.transformAngleByOcsMatrix(e,t+r);i=Zt.getArcAngleSpanInRadian(a,n)}else{if(Zt.areNumbersClose(r,2*Math.PI))return[a,a+2*Math.PI];i=Zt.getArcAngleSpanInRadian(a,s)}return Zt.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 fe.warn(`[DxfLoader] The radius of arc (handle '${e.handle}') is undefined, ignored!`);if(!e.radius||e.radius<.001)return void fe.warn(`[DxfLoader] The radius of arc (handle '${e.handle}') is too small, ignored!`);let s=new k(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=Zn.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,Zt.areNumbersEqual(o,l,1e-6)))return;if(!Zt.areNumbersClose(Zt.getArcAngleSpanInRadian(o,l),2*Math.PI)){let e=Zn.getArcAnglesByOcsMatrix(h,o,l);o=e[0],l=e[1]}}let u=new um(0,0,e.radius,o,l,0!==this.angBase),c=1,d=n;null!=d&&d.xScale&&null!=d&&d.yScale&&(c=Math.max(Math.abs(d.xScale),Math.abs(d.yScale)));let p=this.getDivision(o,l,e.radius*c),f=u.getPoints(p),m=new k,g=!1;this.enableRTC&&(g=en.checkAndRebasePositionsOnRTC(f,m));let v=(new Ot).setFromPoints(f),y=new pn(2);y.geometry=v,y.material=sa;let x=new k;e.center&&(x.x=e.center.x,x.y=e.center.y);let b=new k(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=b.x,x.y=b.y;let _=x,w=new pn(1);return w.geometry=h0e,w.material=IC,w.userData.handle=e.handle,w.userData.isSnapObject=!0,w.userData.type="CircleCenter",w.layers.set(11),y.add(w),g?(this.setRTCUserData(y),_.x+=m.x,_.y+=m.y):en.shouldRebasePositionOnRTC(_)&&this.setRTCUserData(y),y.matrix.setPosition(_),y.layers.enableAll(),y}addTriangleFacingCamera(e,t,n,i){let r=new k,a=new k;r.subVectors(n,t),a.subVectors(i,t),r.cross(a);let s=new k(t.x,t.y,t.z),o=new k(n.x,n.y,n.z),l=new k(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){Rn.set(0,0,e.extrusionDirection.z);let t=Zn.getOcsMatrix(Rn).invert();i.forEach((e=>{let n=Rn.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 k,o=!1;this.enableRTC&&(o=en.checkAndRebasePositionsOnRTC(r,s));let l=(new Ot).setFromPoints(r);l.setIndex(a);let h=new pn(4);return h.geometry=l,h.material=r1,o&&(this.setRTCUserData(h),h.matrix.setPosition(s.x,s.y,0)),h.layers.enableAll(),h}getTextStyle(e,t){var n,i;let r=null==(i=null==(n=e.tables)?void 0:n.style)?void 0:i.styles;return r&&(r[t.textStyle]||r.STANDARD||r.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){if(!e)return;let r=(null==n?void 0:n.styleName)||"";if(n&&n.fontFile&&n.fontFile.endsWith(".shx")){let e=`${n.fontFile}_${n.styleName}`;this.statsInfo.unsupportedTextStyles[e]||(this.statsInfo.unsupportedTextStyles[e]=0),this.statsInfo.unsupportedTextStyles[e]++}let a=.67,s={_TCH_DIM:1.45,ROMANS:1};r&&s[r]&&(a=s[r]),i.xScale&&(a*=i.xScale),r&&(a*=(null==n?void 0:n.xScale)||1,t=t||(null==n?void 0:n.textHeight)||0),0===t&&(t=r?1:.2);let o=this.createTextMeshByText(e,n,t,0,t/8);return o.traverse((e=>{e.geometry&&e.geometry.scale(a,1,1)})),o}createTextMeshByText(e,t,n=12,i=0,r=0,a=1,s=1/0){var o,l,h;let u=new pn,c=[],d=0,p=0,f=i+n;for(let m=0;m<e.length;m++){let i=e[m];if(" "===i){d+=n;continue}if("\n"===i){d=0,p-=f;continue}let u=null==(o=this.font)?void 0:o.getCharShape(i,t.fontFile,n);t.bigFontFile&&!u&&(u=null==(l=this.font)?void 0:l.getCharShape(i,t.bigFontFile,n)),u||(u=null==(h=this.font)?void 0:h.getNotFoundTextShape(n)),u&&(u.translate(d,p,0),u.scale(a,1,1),d>s?(d=0,p-=f):(u.boundingBox||u.computeBoundingBox(),d+=u.boundingBox.getSize(Rn).x+r),c.push(u))}if(c.length>0){let e=c.filter((e=>e instanceof Ws)),t=c.filter((e=>!(e instanceof Ws)));if(e.length>0){let t=new pn(4);t.geometry=Oi(e),t.material=r1,u.add(t)}if(t.length>0){let e=new pn(3);e.geometry=Oi(t),e.material=sa,u.add(e)}}return u}transformTextMesh(e,t){Df.makeEmpty();let n=pn.getBox(t,Df).getSize(Rn),{halign:i,valign:r}=e;t.matrix.decompose(LC.position,LC.quaternion,LC.scale);let a=LC,s=e.width||e.textWidth||n.x,o=e.height||e.textHeight||n.y;if(void 0===i&&void 0===r&&e.startPoint||[3,5].includes(i)&&e.startPoint?(a.position.x+=e.startPoint.x,a.position.y+=e.startPoint.y,a.position.z+=e.startPoint.z):e.endPoint&&(a.position.x+=e.endPoint.x,a.position.y+=e.endPoint.y,a.position.z+=e.endPoint.z),3!==i&&5!==i){if(e.rotation){let t=e.rotation*Math.PI/180;a.rotateZ(t)}2===e.mirrored?a.rotateY(Math.PI):4===e.mirrored&&a.rotateX(Math.PI)}switch(i){case 0:default:break;case 1:a.translateX(-s/2);break;case 2:a.translateX(-s);break;case 3:if(e.startPoint&&e.endPoint){let t=new k(e.startPoint.x,e.startPoint.y,e.startPoint.z),n=new k(e.endPoint.x,e.endPoint.y,e.endPoint.z),i=(new k).subVectors(t,n),r=i.length()/s;a.scale.multiplyScalar(r);let o=i.clone().cross(Hc),l=i.angleTo(Hc);a.rotateZ(o.z>0?Math.PI-l:l-Math.PI),(2===e.mirrored||4===e.mirrored)&&a.rotateX(Math.PI)}break;case 4:a.translateX(-s/2),a.translateY(-o/2);break;case 5:if(e.startPoint&&e.endPoint){let t=new k(e.startPoint.x,e.startPoint.y,e.startPoint.z),n=new k(e.endPoint.x,e.endPoint.y,e.endPoint.z),i=(new k).subVectors(t,n),r=i.length()/s;a.scale.setX(r);let o=i.clone().cross(Hc),l=i.angleTo(Hc);a.rotateZ(o.z>0?Math.PI-l:l-Math.PI),(2===e.mirrored||4===e.mirrored)&&a.rotateX(Math.PI)}}switch(r){case 0:case 1:default:break;case 2:a.translateY(-o/2);break;case 3:a.translateY(-o)}return a.position.z=0,a.updateMatrix(),t.matrix.copy(a.matrix),t}drawText(e,t,n){let i=e.text;if(!i)return;if(!this.font)return void fe.info("[DxfLoader] Font file not set, ignoring text entity.");let r=this.getTextStyle(t,e);i=lC(i,{encoding:this.getTextEncoding(r)}).map((e=>e.text)).join("");let a=this.getTextMesh(i,e.textHeight,r,e);if(!a||0===a.children.length)return;this.transformTextMesh(e,a),Rn.set(a.matrix.elements[12],a.matrix.elements[13],a.matrix.elements[14]);let s=en.shouldRebasePositionOnRTC(Rn);return s&&this.setRTCUserData(a),a.traverse((e=>{let t=e.geometry;if(t){if(e instanceof St&&!t.getIndex()){let e=t.getAttribute("position"),n=[];for(let t=0;t<e.count;t+=3)n.push(t,t+1,t+2);t.setIndex(n)}if(t.hasAttribute("uv")&&t.deleteAttribute("uv"),t.hasAttribute("normal")&&t.deleteAttribute("normal"),!s){let n=en.caculateGeometryCenter(t);n&&en.shouldRebasePositionOnRTC(n)&&this.setRTCUserData(e)}}})),a.layers.enableAll(),a}drawAttDef(e,t,n){let i=e.tag||e.text||e.prompt;if(!i||!this.font)return;let r=this.getTextStyle(t,e);i=lC(i).map((e=>e.text)).join();let a=this.getTextMesh(i,e.textHeight,r,e);if(!a||0===a.children.length)return;this.transformTextMesh(e,a),Rn.set(a.matrix.elements[12],a.matrix.elements[13],a.matrix.elements[14]);let s=en.shouldRebasePositionOnRTC(Rn);return s&&this.setRTCUserData(a),a.traverse((e=>{let t=e.geometry;if(t){if(e instanceof St&&!t.getIndex()){let e=t.getAttribute("position"),n=[];for(let t=0;t<e.count;t+=3)n.push(t,t+1,t+2);t.setIndex(n)}if(t.hasAttribute("uv")&&t.deleteAttribute("uv"),t.hasAttribute("normal")&&t.deleteAttribute("normal"),!s){let n=en.caculateGeometryCenter(t);n&&en.shouldRebasePositionOnRTC(n)&&this.setRTCUserData(e)}}})),a.layers.enableAll(),a}drawAttrib(e,t,n){let i=e.text;if(!i||!this.font)return;let r=this.getTextStyle(t,e);i=lC(i).map((e=>e.text)).join();let a=this.getTextMesh(i,e.textHeight,r,e);if(!a||0===a.children.length)return;this.transformTextMesh(e,a),Rn.set(a.matrix.elements[12],a.matrix.elements[13],a.matrix.elements[14]);let s=en.shouldRebasePositionOnRTC(Rn);return s&&this.setRTCUserData(a),a.traverse((e=>{let t=e.geometry;if(t){if(e instanceof St&&!t.getIndex()){let e=t.getAttribute("position"),n=[];for(let t=0;t<e.count;t+=3)n.push(t,t+1,t+2);t.setIndex(n)}if(t.hasAttribute("uv")&&t.deleteAttribute("uv"),t.hasAttribute("normal")&&t.deleteAttribute("normal"),!s){let n=en.caculateGeometryCenter(t);n&&en.shouldRebasePositionOnRTC(n)&&this.setRTCUserData(e)}}})),a.layers.enableAll(),a}drawPoint(e,t,n){if(!e.position)return;let i=new Ot,r=[new k(e.position.x,e.position.y,e.position.z)];Rn.set(0,0,0);let a=Rn,s=!1;this.enableRTC&&(s=en.checkAndRebasePositionsOnRTC(r,a)),i.setFromPoints(r);let o=new pn(1);return o.geometry=i,o.material=sa,s&&(this.setRTCUserData(o),o.matrix.setPosition(a.x,a.y,0)),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=Dm(e.colorIndex));let r=new pn;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){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 Rn.set(0,0,0),a&&Rn.set(a.x,a.y,0),en.shouldRebasePositionOnRTC(Rn)&&this.setRTCUserData(r),r.matrix.setPosition(Rn),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 pn,l=!1;2===e.flags||4===e.flags||8===e.flags||(l=!0);let h=new mi(a,s);if(l){let e=new ws(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.")}));e.colorSpace=sn;let t=new cn({transparent:!0,side:hi,map:e}),n=new pn(4);n.geometry=h,n.material=t,o.add(n)}let u=new Au(h),c=this.getColor(e,t,n),d=new pn(2);d.geometry=u,d.material=this.getLineBasicMaterial(c);let p=e.uPixel?new k(e.uPixel.x,e.uPixel.y,e.uPixel.z):new k(r.pixelSize.x,0,0),f=e.vPixel?new k(e.vPixel.x,e.vPixel.y,e.vPixel.z):new k(r.pixelSize.y,0,0);if(o.add(d),ri.set(p.x,f.y,1),Rn.set(0,0,0),e.position){let t=new k(e.position.x,e.position.y,e.position.z);t.add(p.multiplyScalar(a/2)).add(f.multiplyScalar(s/2)),Rn.copy(t)}return en.shouldRebasePositionOnRTC(Rn)&&this.setRTCUserData(o),xa.identity(),o.matrix.compose(Rn,xa,ri),o}drawInsert(e,t,n,i=!1){var r,a;if(!e.block)return;let s=t.blocks[e.block];if(!s.entities)return;n&&"0"===e.layer&&(e.layer=n.layer),e.blockPosition=s.position;let o=new pn;for(let d=0;d<s.entities.length;d++){if("ATTDEF"===s.entities[d].type)continue;let n=this.drawEntity(s.entities[d],t,e,i);n&&o.add(n)}if(0===o.children.length){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++,o.name=`${e.type}<${s.name}>`,o.userData.entityType=e.type,null!=(r=e.extendedData)&&r.originalType&&(o.userData.originalType=null==(a=e.extendedData)?void 0:a.originalType),null!=e&&e.blockPosition&&o.matrix.setPosition(-e.blockPosition.x,-e.blockPosition.y,0);let l=Rn.set(1,1,1);e.xScale&&(l.x=e.xScale),e.yScale&&(l.y=e.yScale);let h=new Xn;e.rotation&&(h.z=e.rotation*Math.PI/180),xa.setFromEuler(h,!1);let u=ri.set(0,0,0);e.position&&(u.x=e.position.x,u.y=e.position.y),Ys.compose(u,xa,l),e.extrusionDirection&&e.extrusionDirection.z<0&&Ys.premultiply(d0e.identity().makeScale(-1,1,1)),If.copy(o.matrix),o.matrix.premultiply(Ys),ri.set(o.matrix.elements[12],o.matrix.elements[13],o.matrix.elements[14]),en.shouldRebasePositionOnRTC(ri)&&this.setRTCUserData(o);let c=this.findSpatialFilterByHandle(e.handle,t);if(c){this.drawSpatialFilter(c);let t=c;t&&t.clipPolylines&&t.clipPolylines.length>0&&(o.userData.spatialFilterHandle=c.handle,this.cloneMaterialsForSpatialFilter(o),fe.debug("[DxfLoader] Spatial filter:",e.associatedSpatialFilter))}return o}drawSpatialFilter(e){let t=e;if(t.threejsObject)return t.threejsObject.clone();let n=e.invertBlockMatrix;Ys.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 k(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 fe.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(Zt.areVector3sEqual(n,o)&&e+1<r-1&&e+1<t-1&&Zt.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 fe.warn(`[DxfLoader] Invalid clipBoundary: ${e.handle}!`);let o=[],l=[];if(a.forEach((e=>{o.push(new _e(e.x,e.y)),l.push([e.x,e.y])})),!en.isConvex(o)){fe.warn(`[DxfLoader] Concave polygon is not supported for spatial filter (handle '${e.handle}'), converting to convex polygon!`);let t=(0,x0e.default)(l,1/0);a=[],t.forEach((e=>{a.push(new k(e[0],e[1],0))}))}Zt.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=Ys.clone(),t.clipPolylines=[],void t.clipPolylines.push(r)}drawLayout(e,t,n,i,r,a){if(!e.entities)return;let s=new pn;for(let h=0;h<e.entities.length;h++){let i=e.entities[h];this.addViewport(i,a);let o=this.drawEntity(i,t);o&&(this.enableMerge&&Dc.merge(o,!1),s.add(o),o.traverse((e=>{if(e.geometry){let t=e.userData.layerName,i=r[t];i||(i=[],r[t]=i),i.push(e),e.userData.isSnapObject&&(this.layoutsSnapObjectsMap[n.layoutName]||(this.layoutsSnapObjectsMap[n.layoutName]=[]),this.layoutsSnapObjectsMap[n.layoutName].push(e))}})))}if(0===s.children.length)return;s.userData.layerName=e.layer;let o=n.layoutName,l=i.children.find((e=>e.name===o));l||(l=new pn,l.name=o,l.userData.isLayoutLevelObject=!0,i.add(l)),l.add(s),e.position&&s.matrix.setPosition(e.position.x,e.position.y,e.position.z||0)}convertEdgeToPoints(e){let t=[];switch(e.type){case 1:{let n=e;t.push(new _e(n.startPoint.x,n.startPoint.y)),t.push(new _e(n.endPoint.x,n.endPoint.y));break}case 2:{let n=e,i=n.startAngle*Un.DEG2RAD,r=n.endAngle*Un.DEG2RAD;n.bCounterclockwise||(i=2*Math.PI-i,r=2*Math.PI-r);let a=new um(n.center.x,n.center.y,n.radius,i,r,!n.bCounterclockwise),s=this.getDivision(i,r,n.radius),o=a.getPoints(s);e.startPoint=o[0],e.endPoint=o[o.length-1],t.push(...o);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*Un.DEG2RAD,o=n.endAngle*Un.DEG2RAD;n.bCounterclockwise||(s=2*Math.PI-s,o=2*Math.PI-o);let l=new Gh(n.center.x,n.center.y,i,r,s,o,!n.bCounterclockwise,a),h=this.getDivision(s,o,Math.max(i,r)),u=l.getPoints(h);e.startPoint=u[0],e.endPoint=u[u.length-1],t.push(...u);break}case 4:{let n=e,i=y0e(n.controlPoints,n.degreeOfSplineCurve,n.knotValues);e.startPoint=i[0],e.endPoint=i[i.length-1],t.push(...i);break}case 0:{let n=e,i=c6(n.points,n.isClosed);e.startPoint=i[0],e.endPoint=i[i.length-1],t.push(...i);break}}return t}drawHatch(e,t,n){var i,r;let a=e;if(0==a.boundaryPaths.length)return;if(!(a.solidFill||null!=(i=a.patternLines)&&i.length))return void fe.warn(`[DxfLoader] Hatch entity(handle: '${a.handle}') doesn't have solid fill, nor patternLines, ignored!`);let s=[],o=[],l=[],h=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]);Zt.areVector2sEqual(a[a.length-1],r[0])?Zt.areVector2sEqual(n[0],r[r.length-1],1e-5)&&(t.push(n),n=[]):Zt.areVector2sEqual(a[0],r[r.length-1])?Zt.areVector2sEqual(n[1],r[0],1e-5)&&(t.push(n),n=[]):n=[]}}return t};if(a.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 fe.info(n,e.pathTypeFlag,t,a.handle)}let i=e.edges;if(0===i.length)return;let r=[];for(let s=0;s<i.length;s++){let e=this.convertEdgeToPoints(i[s]);if(e.length<2){let e="[DxfLoader] The %dth edge of the %dth boundaryPath (hatch handle '%s') has less than 2 points, ignored!";fe.warn(e,s,t,a.handle)}else r.push(...e)}if(r.length<3){let e="[DxfLoader] The %dth boundaryPath (hatch handle '%s') has less than 3 points, ignored!";fe.warn(e,t,a.handle)}else if(n.push(r),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||!Zt.areVector2sEqual(n,i))return!1}return!0})(e.edges)||!a.associativity)&&(n=h(i),n.length<2)){let e="[DxfLoader] The %dth boundaryPath (hatch handle '%s') has unknown path, ignored!";fe.warn(e,t,a.handle)}else n.forEach((e=>{Zt.areVector2sEqual(e[0],e[e.length-1])||e.push(e[0]);let t=e.map((e=>new _e(Pt.roundNumber(e.x,7),Pt.roundNumber(e.y,7))));if((null==t?void 0:t.length)>0){s.push(t);let e=(new _i).setFromPoints(t);o.push(e);let n=e.getSize(VE),i=n.x*n.y;l.push({area:i,index:s.length-1})}}))})),0===s.length)return;let u=new _e,c=this.checkAndRebasePolygonsOnRTC(s,u);l.sort(((e,t)=>e.area-t.area));let d=[];l.forEach((e=>{d.push(e.index)}));let p,f=this.buildContainHierarchyTree(s,o,d),m=[];if(this.buildHatchGeometry(s,f,m),m.length>0&&(p=Oi(m)),!p||!p.getIndex()||0===(null==(r=p.getIndex())?void 0:r.count))return void fe.warn("[DxfLoader] Failed to convert hatch boundaries!");let g=new pn(4);g.geometry=p,g.material=r1,this.setHatchMaterial(g,a,t,u,n);let v=g;return c&&(this.setRTCUserData(v),v.matrix.setPosition(u.x,u.y,0)),v.traverse((e=>{e.layers.enableAll(),e.layers.disable(11)})),v}drawOle2frame(e,t){let{leftUpX:n,leftUpY:i,rightDownX:r,rightDownY:a}=e;if(!(n&&i&&r&&a))return;let s=[new _e(n,i),new _e(n,a),new _e(r,a),new _e(r,i),new _e(n,i)],o=new k,l=!1;this.enableRTC&&(l=en.checkAndRebasePositionsOnRTC(s,o));let h=(new Ot).setFromPoints(s),u=this.getLineBasicMaterial(16777215),c=new pn(2);c.geometry=h,c.material=u,c.layers.enableAll(),l&&(this.setRTCUserData(c),c.matrix.setPosition(o.x,o.y,0));let d=new pn;d.add(c);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,"+Pt.hexToBase64(t),i=new ws(this.manager).load(n);i.colorSpace=sn;let r=new cn({transparent:!0,map:i});this.meshTextureMaterials[p]=r,f=r;break}}if(f){let e=(new _i).setFromPoints(s),t=e.getSize(VE),n=new mi(t.x,t.y),i=new pn(4);i.geometry=n,i.material=f;let r=e.getCenter(VE);Rn.set(r.x,r.y,0),l&&(this.setRTCUserData(i),Rn.x+=o.x,Rn.y+=o.y),i.matrix.setPosition(Rn),i.layers.enableAll(),d.add(i)}return d.children.length>1?d:c}static getOcsMatrix(e){let t=Hc,n=l6,i=n1,r=new k(0,1,0),a=new k(0,0,1);return Zt.areVectorsClose(e,a)?Ys.identity():(i=e.clone().normalize(),Zt.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()),Ys.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=Xgt(e)?e.viewDirectionFromTarget:e.viewDirection;let i,r,a,s=new k(Zt.roundNumber(n.x,7),Zt.roundNumber(n.y,7),n.z),o=new k(e.viewTarget.x,e.viewTarget.y,e.viewTarget.z),l=e.viewTwistAngle||0;a=s.clone().normalize(),i=n1.clone().cross(s),i.length()>0?(i.normalize(),r=a.clone().cross(i)):a.z<0?(i=Hc.clone().negate(),r=l6,a=n1.clone().negate()):(i=Hc,r=l6,a=n1);let h=new ht,u=Ys.identity();return u.makeBasis(i,r,a),h.premultiply(u),h.premultiply(Ys.identity().compose(o.clone(),(new _r).setFromAxisAngle(new k(0,0,1),Un.degToRad(t?l:-l)),new k(1,1,1))),h}getViewportMsToPsMatrix(e){let t=new k(e.centerPoint_dcs.x,e.centerPoint_dcs.y,0),n=new k(e.centerPoint.x,e.centerPoint.y,e.centerPoint.z),i=e.viewHeight/e.height_paperSpace,r=Zn.getDcs2WcsMatrix(e,this.angDir),a=new ht;a.setPosition(u0e.clone().sub(n));let s=d0e.identity();s.scale(Rn.set(i,i,i));let o=If.identity().setPosition(u0e.clone().sub(n));s.premultiply(o.clone().invert()).multiply(o),a.multiply(s);let l=Ys.identity();l.setPosition(t),r.multiply(l);let h=Ys.identity();return a.invert().multiply(h).multiply(r.invert())}drawViewport(e,t,n){let i=e;if("1"==i.viewportId)return e.psBBox=new Nt,void(e.msToPsMatrix=new ht);let r=[],a=i.centerPoint,s=i.width_paperSpace/2,o=i.height_paperSpace/2;r.push(new k(a.x-s,a.y-o,0)),r.push(new k(a.x-s,a.y+o,0)),r.push(new k(a.x+s,a.y+o,0)),r.push(new k(a.x+s,a.y-o,0)),r.push(r[0]),e.psBBox=new Nt(r[0],r[2]),e.msToPsMatrix=this.getViewportMsToPsMatrix(i);let l=new k,h=!1;this.enableRTC&&(h=en.checkAndRebasePositionsOnRTC(r,l));let u=(new Ot).setFromPoints(r),c=new pn(2);c.geometry=u,c.material=sa,h&&(this.setRTCUserData(c),c.matrix.setPosition(l.x,l.y,0)),c.userData.entityType=e.type,c.layers.enableAll();let d=new pn;d.add(c);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 k(p.min.x,p.max.y,0)),f.push(p.max),f.push(new k(p.max.x,p.min.y,0)),f.push(f[0]);let m=new k,g=!1;this.enableRTC&&(g=en.checkAndRebasePositionsOnRTC(f,m));let v=(new Ot).setFromPoints(f),y=new pn(2);return y.geometry=v,y.material=sa,g&&(this.setRTCUserData(y),y.matrix.setPosition(m.x,m.y,0)),y.userData.entityType=e.type,y.userData.inPaperSpace=!0,y.layers.enableAll(),d.add(y),c}getColor(e,t,n){var i,r,a,s;if(this.compareContext)return js.ENTITY_COLOR_NO_CHANGE;if(null!=this.overrideColor)return this.overrideColor;let o=e;if(o&&o.isGradientColor){let t=o.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!`;fe.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],o=i&&n&&i[n.layer],l=Of;return r&&"0"!==r.name?l=r.color:o?l=o.color:r?l=r.color:i&&i[0].color&&(l=i[0].color),l}return fe.warn("[DxfLoader] Unknown colorIndex"),Of}getLineType(e,t,n){var i,r;if(n&&"DIMENSION"===n.type)return this.getLineType(n,t);if(e.lineType!==Nv&&e.lineType!==Bv)return e.lineType;if(e.lineType===Bv)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=jgt;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=t=>{s&&t&&!s[e.layer]&&(console.warn(`[DxfLoader] Failed to find layer object for '${t}', adding a default one.`),s[t]={name:t,handle:"",colorIndex:256,lineType:"",visible:!0})},s=null==(r=null==(i=t.tables)?void 0:i.layer)?void 0:r.layers;a(e.layer);let o=s&&s[e.layer];a(null==n?void 0:n.layer);let l=s&&n&&s[n.layer],h=(null==o?void 0:o.name)||"";return o&&"0"===o.name&&l&&(h=l.name),h}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 VE.set(0,0),void this.setHatchMaterial(e,t,n,VE,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 Li)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,u=h&&h[this.getLineType(t,n,i)];if(u&&u.pattern&&0!==u.pattern.length){let n=t.lineTypeScale||1;o=this.getLineShaderMaterial(u,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(2===a.type||3===a.type)return void(a.material=this.getLineBasicMaterial(s));let o,l=-1;if(t.solidFill)o=this.getMeshBasicMaterial(s);else{if(a.material instanceof hn){o=a.material;let e=new ct(s);a.material.uniforms.u_color.value.equals(e)||(o=a.material.clone(),Zn.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 Li({size:.2,color:e})),this.pointsMaterials[e]}getLineBasicMaterial(e){return this.lineBasicMaterials[e]||(this.lineBasicMaterials[e]=new zn({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]=aC.createLineShaderMaterial(e.pattern,t,a,Zn.viewportScaleUniform,Zn.cameraZoomUniform)}return this.lineShaderMaterials[i]}getMeshBasicMaterial(e){return this.meshBasicMaterials[e]||(this.meshBasicMaterials[e]=new cn({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 _e;for(let h of e.patternLines){let t=new _e(h.origin.x,h.origin.y).sub(n).rotateAround(o,-Un.degToRad(e.patternAngle)),i=new _e(h.delta.x,h.delta.y).rotateAround(o,-Un.degToRad(h.angle));if(0===i.y)return void fe.warn("[DxfLoader] delta.y is equal to zero !");let l=h.dashPattern.length,u=!0,c=0;for(let e=0;e<l;++e){let t=h.dashPattern[e];t>0&&(u=!1),c+=Math.abs(t)}let d=u?.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*c),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>Zn.maxFragmentUniforms){fe.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=_me(s,e.patternAngle,Zn.cameraZoomUniform,new ct(t),this.overrideHatchPatternLineThickness);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 it(this,null,(function*(){let n={dxfDataId:e,dxf:t};return new Promise(((t,i)=>{$v.instance().add(n,(()=>{fe.info(`[DxfLoader] Saved '${e}' to indexedDb`),t()}),(e=>{i(e)}))}))}))}getDxfDataFromIndexedDb(e){return it(this,null,(function*(){return new Promise(((t,n)=>{$v.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],u=t[l],c=o+1;for(;c<a;c++){let a=n[c],s=e[a];if(t[a].containsBox(u)&&en.isPointInPolygon(h[Pt.generateRandomInt(0,h.length-1)],s)){null==(i=r.get(a))||i.children.push(r.get(l));break}}c===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 Al(e);t.hasAttribute("uv")&&t.deleteAttribute("uv"),t.hasAttribute("normal")&&t.deleteAttribute("normal"),n.push(t)}catch(t){fe.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 Ts(n);a(i)}));let s=e=>e.map((e=>e.toArray()));for(let o of r){let t=new Ts(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(zl.epsilon(Zt.getVector2RelativeEps(e[i][0]),1e-6),0===a)r=zl.segments({regions:[s(e[i])],inverted:!1});else{let a=zl.segments({regions:[s(e[i])],inverted:!1}),o=zl.combine(r,a);n=zl.polygon(zl.selectUnion(o)),n.regions.length>0?n.regions.forEach((e=>{if(0===e.length)return;let n=e.map((e=>new _e(e[0],e[1])));t.holes.push(new Su(n))})):fe.warn("[DxfLoader] mergedHoles.regions is empty")}}))}catch(e){fe.warn(`[DxfLoader] polybooljs has error: ${e}, epsilon is ${zl.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 Su(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]];en.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&&en.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 _e(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]&&fe.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]&&fe.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]]?fe.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,i;if(!this.blockRecordsCache){this.blockRecordsCache={};let t=this.blockRecordsCache,r=null==(i=null==(n=e.tables)?void 0:n.blockRecord)?void 0:i.blockRecords;r&&Object.values(r).forEach((e=>{t[e.handle]=e.layoutHandle}))}let r=this.blockRecordsCache[t.ownerHandle];if(r){let t=e.objects.LAYOUT.find((e=>e.handle===r));if(t)return t}if(!this.entitiesCache){this.entitiesCache={};let t=this.entitiesCache;Object.values(e.entities).forEach((e=>{t[e.handle]=e}))}let a=this.entitiesCache[t.ownerHandle];return a?this.getLayout(e,a):(fe.warn("[DxfLoader] Failed to find layout name for entity:",t),e.objects.LAYOUT.find((e=>e.layoutName===Zn.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();Zn.updateMaterialUniforms(i),t.set(e.id,i),n.push(i)}}))):e&&(t.has(e.id)?n=t.get(e.id):(n=e.clone(),Zn.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:fe.warn(`[DxfLoader] Unsupported $INSUNITS '${e}'`)}return"Unitless"}static computeLineDistance(e){let t=!0===e.isLineSegments,n=e.geometry,i=e.matrixWorld;if(n.index&&(fe.debug(`[DxfLoader] Line with id '${e.id}' contains index buffer, going to convert it to non-indexed.`),n=en.convertGeometryWithIndexedToNonIndexed(n),e.userData.batches&&e.userData.batches.length>0)){fe.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)Rn.fromBufferAttribute(r,e).applyMatrix4(i),ri.fromBufferAttribute(r,e+1).applyMatrix4(i),a[e]=0===e?0:a[e-1],a[e+1]=a[e]+Rn.distanceTo(ri);else{a[0]=0;for(let e=1,t=r.count;e<t;e++)Rn.fromBufferAttribute(r,e-1).applyMatrix4(i),ri.fromBufferAttribute(r,e).applyMatrix4(i),a[e]=a[e-1],a[e]+=Rn.distanceTo(ri)}n.setAttribute("lineDistance",new Bt(a,1)),e.geometry=n}else fe.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 hn&&Zn.computeLineDistance(t)})),fe.debug(`[DxfLoader] Computed line distances in ${(Date.now()-t)/1e3}s`)}static mergeDxfObjects(e){let t=Date.now(),n={},i={},r=0,a=0,s=()=>{let e=Date.now();for(let t in n){let e=n[t];Zn.removeEmptyObjectsFromRemovingMarkedObjects2(e.children,e.object),e.children=[]}r=0,a+=Date.now()-e};for(let l in e.layersAndObjects){let t=e.layersAndObjects[l];if(t.length<=1)continue;let o=Date.now(),h={},u=[];for(let e of t){if(e.userData.isSnapObject){u.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;h[i]||(h[i]={object:t,children:[]}),h[i].children.push(e)}for(let e in h){let t=h[e],o=Dc.deepMerge(t.children,t.object,!1,!1,!0),l=o.added,c=o.removed;n[e]||(n[e]={object:t.object,children:[]}),i[e]||(i[e]={object:t.object,children:[]});let d=c.length>15e3;if(d){let e=Date.now();Zn.removeEmptyObjectsFromRemovingMarkedObjects2(c,t.object),a+=Date.now()-e}else r+=c.length;if(c.length===t.children.length)d||c.forEach((t=>{n[e].children.push(t)}));else{let i=c;c.length>=100&&(i=new Set(c));let r=e=>Array.isArray(i)?i.indexOf(e)>=0:i.has(e);for(let a=0;a<t.children.length;a++){let i=t.children[a];r(i)?d||n[e].children.push(i):u.push(i)}}for(let n=0;n<l.length;n++){let t=l[n];u.push(t),i[e].children.push(t)}r>15e3&&s()}e.layersAndObjects[l]=u,fe.debug(`[DxfLoader] Merged layer '${l}' in ${(Date.now()-o)/1e3}s`)}r>0&&s();for(let l in i){let t=i[l];e.root.children.find((e=>e.name===l))||e.root.add(t.object),t.children.forEach((e=>{t.object.add(e)})),t.children=[]}fe.debug(`[DxfLoader] MergeUtils.deepMerge costed ${Mi.mergeInfo.elapsedTime/1e3}s`),fe.debug(`[DxfLoader] The remove operation of deep merge costed ${a/1e3}s`),fe.debug(`[DxfLoader] Deep merge totally costed ${(Date.now()-t)/1e3}s`);let o=Mi.mergeInfo;fe.debug(`[DxfLoader] Totally merged ${o.removedObjects} objects to ${o.mergedMeshes} meshes, ${o.mergedLines} lines, ${o.mergedPoints} points, ${o.mergedUnknownTypeObjects?o.mergedUnknownTypeObjects+" unknown type,":""} `)}static merge(e,t){return it(this,null,(function*(){let n=Pt.getUpdateProgressFuncAsync(t),i={};e.objects.LAYOUT.forEach((e=>{var t;let n=e;i[n.layoutName]=n,null==(t=n.directAssociatedLeafObjectSet)||t.clear()}));let r=Date.now(),a={},s={},o=0,l=0,h=()=>{let e=Date.now();for(let t in a){let e=a[t];Zn.removeEmptyObjectsFromRemovingMarkedObjects(e.children,e.object),e.children=[]}o=0,l+=Date.now()-e},u=Object.keys(e.layersAndThreejsObjects).length,c=0;for(let t in e.layersAndThreejsObjects){let r=e.layersAndThreejsObjects[t];if(r.length<=1){yield n(++c/u*100);continue}let d=Date.now(),p={},f=[];for(let e of r){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!==Zn.MODEL_LAYOUT_NAME){let n=i[e];n.directAssociatedLeafObjectSet||(n.directAssociatedLeafObjectSet=new Set),t=n.directAssociatedLeafObjectSet}let r=p[e],d=Mi.deepMerge(r.children,r.object,!1,!1,!0),v=d.added,y=d.removed;a[e]||(a[e]={object:r.object,children:[]}),s[e]||(s[e]={object:r.object,children:[]});let x=y.length>15e3;if(x){let e=Date.now();Zn.removeEmptyObjectsFromRemovingMarkedObjects(y,r.object),l+=Date.now()-e}else o+=y.length;if(y.length===r.children.length)x||y.forEach((t=>{a[e].children.push(t)}));else{let n=y;y.length>=100&&(n=new Set(y));let i=e=>Array.isArray(n)?n.indexOf(e)>=0:n.has(e);for(let s=0;s<r.children.length;s++){let n=r.children[s];i(n)?x||a[e].children.push(n):(f.push(n),t&&t.add(n))}}for(let n=0;n<v.length;n++){let i=v[n];rr.setSharedVariablesOfObject(i),f.push(i),s[e].children.push(i),t&&t.add(i)}o>15e3&&h(),yield n((c+ ++g/m)/u*100)}yield n(++c/u*100),e.layersAndThreejsObjects[t]=f,fe.debug(`[DxfLoader] Merged layer '${t}' in ${(Date.now()-d)/1e3}s`)}o>0&&h();for(let t in s){let n=s[t],r=e.threejsObject.children.find((e=>e.name===t));if(r){let e=r.children.find((e=>e.name===Zn.SNAP_GROUP_NAME));if(e&&t!==Zn.MODEL_LAYOUT_NAME){let n=i[t];n.directAssociatedLeafObjectSet||(n.directAssociatedLeafObjectSet=new Set),e.children.forEach((e=>{var t;return null==(t=n.directAssociatedLeafObjectSet)?void 0:t.add(e)}))}}r||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=[]}fe.debug(`[DxfLoader] MergeUtils.deepMerge costed ${Mi.mergeInfo.elapsedTime/1e3}s`),fe.debug(`[DxfLoader] The remove operation of deep merge costed ${l/1e3}s`),fe.debug(`[DxfLoader] Deep merge totally costed ${(Date.now()-r)/1e3}s`);let d=Mi.mergeInfo;fe.debug(`[DxfLoader] Totally merged ${d.removedObjects} objects to ${d.mergedMeshes} meshes, ${d.mergedLines} lines, ${d.mergedPoints} points, ${d.mergedUnknownTypeObjects?d.mergedUnknownTypeObjects+" unknown type,":""} `),n(100)}))}printStatsInfo(){for(let n in this.entityTypesAndTimes)this.entityTypesAndTimes[n].averageTime=this.entityTypesAndTimes[n].totalTime/this.entityTypesAndTimes[n].createCount;fe.debug("[DxfLoader] Entity types and cost times in ms:",this.entityTypesAndTimes),fe.debug("[DxfLoader] Entity types and mesh count:",this.statsInfo.entityTypesAndMeshCount);let e=0;if(Object.values(this.statsInfo.entityTypesAndMeshCount).forEach((t=>{e+=t})),this.enableRTC&&fe.debug(`[DxfLoader] Totally rebased ${this.statsInfo.rebasedEntityCount}(out of ${e}) entities`),this.enableMerge){let e=Mi.mergeInfo;fe.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 t=(e,t,...n)=>{Object.keys(t).length};t(0,this.statsInfo.unsupportedEntityTypes),t(0,this.statsInfo.unsupportedTextStyles),t(0,this.statsInfo.unsupportedHatchPatterns),this.statsInfo.unsupportedPolylineCount&&fe.warn(`[DxfLoader] Unsupported polyline (with both width and linetype) count: ${this.statsInfo.unsupportedPolylineCount}, linetype will be ignored.`),t(0,this.statsInfo.invisibleEntities),t(0,this.statsInfo.ignoredFrozenLayersAndEntityCount),t(0,this.statsInfo.ignoredInserts),this.ignorePaperSpace&&t(0,this.statsInfo.ignoredPaperSpaceEntityTypesAndCount),this.font&&t(0,this.font.getUnsupportedChar())}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))}));fe.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||rr.isEmptyObject(e))return e.removeFromParent(),!0;for(let t=0;t<e.children.length;)this.removeEmptyObjectsFromMark(e.children[t])||++t;return!1}static removeEmptyObjectsFromRemovingMarkedObjects2(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.removeEmptyObjectsFromMark2(t)}static removeEmptyObjectsFromMark2(e){if(0===e.userData.validCount||0===e.type&&0===e.children.length)return e.removeFromParent(),!0;for(let t=0;t<e.children.length;)this.removeEmptyObjectsFromMark2(e.children[t])||++t;return!1}},Ln=Zn;Ln.MODEL_LAYOUT_NAME="Model",Ln.SNAP_GROUP_NAME="InvisibleObjectGroupForOSnap",Ln.SHOW_SNAP_OBJECT=!1,Ln.cameraZoomUniform={value:1},Ln.viewportScaleUniform={value:1},Ln.transformMatrixUniform={value:new ht},Ln.resolutionUniform={value:new _e},Ln.maxFragmentUniforms=1024,Ln.abortJobs=!1;var b0e=class extends Ms{constructor(e){var t;super(),this.drawableList=new Xo("compare"),this.viewer=e,this.overlayRender=this.viewer.getOverlayRender(),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=en.mergeBBoxes(t),a=en.mergeBBoxes(n),s=en.mergeBBoxes(i);this.drawableList.addDrawable(new Im(Pt.guid(),r)),this.drawableList.addDrawable(new Im(Pt.guid(),a)),this.drawableList.addDrawable(new Im(Pt.guid(),s)),this.viewer.enableRender()}setCompareDrawableVisible(e){this.drawableList.getDrawables().forEach((t=>t.visible=e)),this.viewer.enableRender()}};function ba(e){return(ba="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 Gl(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u6(e,t){if("object"!==ba(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,t||"default");if("object"!==ba(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}function zE(e){var t=u6(e,"string");return"symbol"===ba(t)?t:String(t)}function E0e(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,zE(i.key),i)}}function ql(e,t,n){return t&&E0e(e.prototype,t),n&&E0e(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function Vc(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function GE(e,t){return(GE=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function i1(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&GE(e,t)}function Gm(e,t){if(t&&("object"===ba(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return Vc(e)}function Wl(e){return(Wl=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function Hu(e,t,n){return(t=zE(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function h6(e){if(Array.isArray(e))return e}function d6(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function DC(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 f6(e,t){if(e){if("string"==typeof e)return DC(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 DC(e,t)}}function p6(){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 m6(e){return h6(e)||d6(e)||f6(e)||p6()}function _0e(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 T0e(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?_0e(Object(n),!0).forEach((function(t){Hu(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):_0e(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var Jgt={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)}},Qgt=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Gl(this,e),this.init(t,n)}return ql(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||Jgt,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,T0e(T0e({},{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}(),zu=new Qgt,Ff=function(){function e(){Gl(this,e),this.observers={}}return ql(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 qE(){var e,t,n=new Promise((function(n,i){e=n,t=i}));return n.resolve=e,n.reject=t,n}function w0e(e){return null==e?"":""+e}function e0t(e,t,n){e.forEach((function(e){t[e]&&(n[e]=t[e])}))}function v6(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 S0e(e,t,n){var i=v6(e,t,Object);i.obj[i.k]=n}function t0t(e,t,n,i){var r=v6(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 FC(e,t){var n=v6(e,t),i=n.obj,r=n.k;if(i)return i[r]}function M0e(e,t,n){var i=FC(e,n);return void 0!==i?i:FC(t,n)}function B0e(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]):B0e(e[i],t[i],n):e[i]=t[i]);return e}function s1(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")}var n0t={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};function r0t(e){return"string"==typeof e?e.replace(/[&<>"'\/]/g,(function(e){return n0t[e]})):e}var BC="undefined"!=typeof window&&window.navigator&&void 0===window.navigator.userAgentData&&window.navigator.userAgent&&window.navigator.userAgent.indexOf("MSIE")>-1,i0t=[" ",",","?","!",";"];function s0t(e,t,n){t=t||"",n=n||"";var i=i0t.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 A0e(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 OC(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?A0e(Object(n),!0).forEach((function(t){Hu(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):A0e(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function a0t(e){var t=o0t();return function(){var n,i=Wl(e);if(t){var r=Wl(this).constructor;n=Reflect.construct(i,arguments,r)}else n=i.apply(this,arguments);return Gm(this,n)}}function o0t(){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 U0e(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?U0e(l,h,n):void 0}r=r[i[a]]}return r}}var l0t=function(e){i1(n,Ff);var t=a0t(n);function n(e){var i,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{ns:["translation"],defaultNS:"translation"};return Gl(this,n),i=t.call(this),BC&&Ff.call(Vc(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 ql(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=FC(this.data,s);return o||!a||"string"!=typeof n?o:U0e(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),S0e(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=FC(this.data,s)||{};i?B0e(o,n,r):o=OC(OC({},o),n),S0e(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?OC(OC({},{}),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}(),H0e={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 R0e(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 Xa(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?R0e(Object(n),!0).forEach((function(t){Hu(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):R0e(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function c0t(e){var t=u0t();return function(){var n,i=Wl(e);if(t){var r=Wl(this).constructor;n=Reflect.construct(i,arguments,r)}else n=i.apply(this,arguments);return Gm(this,n)}}function u0t(){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 C0e={},P0e=function(e){i1(n,Ff);var t=c0t(n);function n(e){var i,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return Gl(this,n),i=t.call(this),BC&&Ff.call(Vc(i)),e0t(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,Vc(i)),i.options=r,void 0===i.options.keySeparator&&(i.options.keySeparator="."),i.logger=zu.create("translator"),i}return ql(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||s0t(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"!==ba(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,u=h[h.length-1],c=t.lng||this.language,d=t.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(c&&"cimode"===c.toLowerCase()){if(d){var p=t.nsSeparator||this.options.nsSeparator;return a?(f.res="".concat(u).concat(p).concat(l),f):"".concat(u).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,b=!this.i18nFormat||this.i18nFormat.handleAsObject;if(b&&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 _=this.options.returnedObjectHandler?this.options.returnedObjectHandler(g,m,Xa(Xa({},t),{},{ns:h})):"key '".concat(l," (").concat(this.language,")' returned an object instead of string.");return a?(f.res=_,f):_}if(s){var w="[object Array]"===y,S=w?[]:{},M=w?v:g;for(var E in m)if(Object.prototype.hasOwnProperty.call(m,E)){var T="".concat(M).concat(s).concat(E);S[E]=this.translate(T,Xa(Xa({},t),{joinArrays:!1,ns:h})),S[E]===T&&(S[E]=m[E])}m=S}}else if(b&&"string"==typeof x&&"[object Array]"===y)(m=m.join(x))&&(m=this.extendTranslation(m,e,t,i));else{var A=!1,C=!1,P=void 0!==t.count&&"string"!=typeof t.count,R=n.hasDefaultValue(t),L=P?this.pluralResolver.getSuffix(c,t.count,t):"",I=t["defaultValue".concat(L)]||t.defaultValue;!this.isValidLookup(m)&&R&&(A=!0,m=I),this.isValidLookup(m)||(C=!0,m=l);var k=(t.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&C?void 0:m,O=R&&I!==m&&this.options.updateMissing;if(C||A||O){if(this.logger.log(O?"updateKey":"missingKey",c,u,l,O?I:m),s){var D=this.resolve(l,Xa(Xa({},t),{},{keySeparator:!1}));D&&D.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=[],U=this.languageUtils.getFallbackCodes(this.options.fallbackLng,t.lng||this.language);if("fallback"===this.options.saveMissingTo&&U&&U[0])for(var F=0;F<U.length;F++)N.push(U[F]);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=R&&i!==m?i:k;r.options.missingKeyHandler?r.options.missingKeyHandler(e,u,n,a,O,t):r.backendConnector&&r.backendConnector.saveMissing&&r.backendConnector.saveMissing(e,u,n,a,O,t),r.emit("missingKey",e,u,n,m)};this.options.saveMissing&&(this.options.saveMissingPlurals&&P?N.forEach((function(e){r.pluralResolver.getSuffixes(e,t).forEach((function(n){B([e],l+n,t["defaultValue".concat(n)]||I)}))})):B(N,l,I))}m=this.extendTranslation(m,e,t,f,i),C&&m===l&&this.options.appendNamespaceToMissingKey&&(m="".concat(u,":").concat(l)),(C||A)&&this.options.parseMissingKeyHandler&&(m="v1"!==this.options.compatibilityAPI?this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?"".concat(u,":").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,Xa(Xa({},this.options.interpolation.defaultVariables),n),i.usedLng,i.usedNS,i.usedKey,{resolved:i});else if(!n.skipInterpolation){n.interpolation&&this.interpolator.init(Xa(Xa({},n),{interpolation:Xa(Xa({},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=Xa(Xa({},this.options.interpolation.defaultVariables),h)),e=this.interpolator.interpolate(e,h,n.lng||this.language,n),o){var u=e.match(this.interpolator.nestingRegexp);s<(u&&u.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 c=n.postProcess||this.options.postProcess,d="string"==typeof c?[c]:c;return null!=e&&d&&d.length&&!1!==n.applyPostProcessor&&(e=H0e.handle(d,e,t,this.options&&this.options.postProcessPassResolved?Xa({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 u=l.namespaces;s.options.fallbackNS&&(u=u.concat(s.options.fallbackNS));var c=void 0!==o.count&&"string"!=typeof o.count,d=c&&!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);u.forEach((function(e){s.isValidLookup(t)||(a=e,!C0e["".concat(f[0],"-").concat(e)]&&s.utils&&s.utils.hasLoadedNamespace&&!s.utils.hasLoadedNamespace(a)&&(C0e["".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 u;c&&(u=s.pluralResolver.getSuffix(n,o.count,o));var f="".concat(s.options.pluralSeparator,"zero");if(c&&(l.push(h+u),d&&l.push(h+f)),p){var m="".concat(h).concat(s.options.contextSeparator).concat(o.context);l.push(m),c&&(l.push(m+u),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){for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&"defaultValue"===t.substring(0,12)&&void 0!==e[t])return!0;return!1}}]),n}();function g6(e){return e.charAt(0).toUpperCase()+e.slice(1)}var h0t=function(){function e(t){Gl(this,e),this.options=t,this.supportedLngs=this.options.supportedLngs||!1,this.logger=zu.create("languageUtils")}return ql(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]=g6(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]=g6(n[1].toLowerCase())),t.indexOf(n[2].toLowerCase())>-1&&(n[2]=g6(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}(),d0t=[{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}],f0t={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)}},p0t=["v1","v2","v3"],I0e={zero:0,one:1,two:2,few:3,many:4,other:5};function m0t(){var e={};return d0t.forEach((function(t){t.lngs.forEach((function(n){e[n]={numbers:t.nr,plurals:f0t[t.fc]}}))})),e}var g0t=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Gl(this,e),this.languageUtils=t,this.options=n,this.logger=zu.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=m0t()}return ql(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 I0e[e]-I0e[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!p0t.includes(this.options.compatibilityJSON)}}]),e}();function L0e(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 zc(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?L0e(Object(n),!0).forEach((function(t){Hu(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):L0e(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var v0t=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Gl(this,e),this.logger=zu.create("interpolator"),this.options=t,this.format=t.interpolation&&t.interpolation.format||function(e){return e},this.init(t)}return ql(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:r0t,this.escapeValue=void 0===t.escapeValue||t.escapeValue,this.useRawValueToEscape=void 0!==t.useRawValueToEscape&&t.useRawValueToEscape,this.prefix=t.prefix?s1(t.prefix):t.prefixEscaped||"{{",this.suffix=t.suffix?s1(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?s1(t.nestingPrefix):t.nestingPrefixEscaped||s1("$t("),this.nestingSuffix=t.nestingSuffix?s1(t.nestingSuffix):t.nestingSuffixEscaped||s1(")"),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 u=function(e){if(e.indexOf(o.formatSeparator)<0){var r=M0e(t,l,e);return o.alwaysFormat?o.format(r,void 0,n,zc(zc(zc({},i),t),{},{interpolationkey:e})):r}var a=e.split(o.formatSeparator),s=a.shift().trim(),h=a.join(o.formatSeparator).trim();return o.format(M0e(t,l,s),h,n,zc(zc(zc({},i),t),{},{interpolationkey:s}))};this.resetRegExp();var c=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=u(n)))if("function"==typeof c){var l=c(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=w0e(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=zc({},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=zc(zc({},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 u=n[1].split(this.formatSeparator).map((function(e){return e.trim()}));n[1]=u.shift(),l=u,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=w0e(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,zc(zc({},a),{},{interpolationkey:n[1].trim()}))}),i.trim())),e=e.replace(n[0],i),this.regexp.lastIndex=0}return e}}]),e}();function D0e(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 kf(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?D0e(Object(n),!0).forEach((function(t){Hu(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):D0e(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function y0t(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=m6(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 a1(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 x0t=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Gl(this,e),this.logger=zu.create("formatter"),this.options=t,this.formats={number:a1((function(e,t){var n=new Intl.NumberFormat(e,t);return function(e){return n.format(e)}})),currency:a1((function(e,t){var n=new Intl.NumberFormat(e,kf(kf({},t),{},{style:"currency"}));return function(e){return n.format(e)}})),datetime:a1((function(e,t){var n=new Intl.DateTimeFormat(e,kf({},t));return function(e){return n.format(e)}})),relativetime:a1((function(e,t){var n=new Intl.RelativeTimeFormat(e,kf({},t));return function(e){return n.format(e,t.range||"day")}})),list:a1((function(e,t){var n=new Intl.ListFormat(e,kf({},t));return function(e){return n.format(e)}}))},this.init(t)}return ql(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()]=a1(t)}},{key:"format",value:function(e,t,n,i){var r=this;return t.split(this.formatSeparator).reduce((function(e,t){var a=y0t(t),s=a.formatName,o=a.formatOptions;if(r.formats[s]){var l=e;try{var h=i&&i.formatParams&&i.formatParams[i.interpolationkey]||{},u=h.locale||h.lng||i.locale||i.lng||n;l=r.formats[s](e,u,kf(kf(kf({},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 O0e(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 k0e(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?O0e(Object(n),!0).forEach((function(t){Hu(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):O0e(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function b0t(e){var t=E0t();return function(){var n,i=Wl(e);if(t){var r=Wl(this).constructor;n=Reflect.construct(i,arguments,r)}else n=i.apply(this,arguments);return Gm(this,n)}}function E0t(){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 _0t(e,t){void 0!==e.pending[t]&&(delete e.pending[t],e.pendingCount--)}var T0t=function(e){i1(n,Ff);var t=b0t(n);function n(e,i,r){var a,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return Gl(this,n),a=t.call(this),BC&&Ff.call(Vc(a)),a.backend=e,a.store=i,a.services=r,a.languageUtils=r.languageUtils,a.options=s,a.logger=zu.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 ql(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){t0t(n.loaded,[r],a),_0t(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,k0e(k0e({},a),{},{isUpdate:r})),e&&e[0]&&this.store.addResource(e[0],t,n,i))}}]),n}();function w0t(){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"===ba(e[1])&&(t=e[1]),"string"==typeof e[1]&&(t.defaultValue=e[1]),"string"==typeof e[2]&&(t.tDescription=e[2]),"object"===ba(e[2])||"object"===ba(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 F0e(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 N0e(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 Vu(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?N0e(Object(n),!0).forEach((function(t){Hu(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):N0e(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function S0t(e){var t=M0t();return function(){var n,i=Wl(e);if(t){var r=Wl(this).constructor;n=Reflect.construct(i,arguments,r)}else n=i.apply(this,arguments);return Gm(this,n)}}function M0t(){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 kC(){}function A0t(e){Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach((function(t){"function"==typeof e[t]&&(e[t]=e[t].bind(e))}))}var NC=function(e){i1(n,Ff);var t=S0t(n);function n(){var e,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0;if(Gl(this,n),e=t.call(this),BC&&Ff.call(Vc(e)),e.options=F0e(i),e.services={},e.logger=zu,e.modules={external:[]},A0t(Vc(e)),r&&!e.isInitialized&&!i.isClone){if(!e.options.initImmediate)return e.init(i,r),Gm(e,Vc(e));setTimeout((function(){e.init(i,r)}),0)}return e}return ql(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=w0t();function r(e){return e?"function"==typeof e?new e:e:null}if(this.options=Vu(Vu(Vu({},i),this.options),F0e(t)),"v1"!==this.options.compatibilityAPI&&(this.options.interpolation=Vu(Vu({},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?zu.init(r(this.modules.logger),this.options):zu.init(null,this.options),this.modules.formatter?a=this.modules.formatter:"undefined"!=typeof Intl&&(a=x0t);var s=new h0t(this.options);this.store=new l0t(this.options.resources,this.options);var o=this.services;o.logger=zu,o.resourceStore=this.store,o.languageUtils=s,o.pluralResolver=new g0t(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 v0t(this.options),o.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},o.backendConnector=new T0t(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 P0e(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=kC),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=qE(),u=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?u():setTimeout(u,0),h}},{key:"loadResources",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:kC,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=qE();return e||(e=this.languages),t||(t=this.options.ns),n||(n=kC),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&&H0e.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=qE();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"!==ba(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=Vu({},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||".",u=a.keyPrefix?"".concat(a.keyPrefix).concat(h).concat(t):t;return i.t(u,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=qE();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=qE();"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]:kC,r=Vu(Vu(Vu({},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=Vu({},this.services),a.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},a.translator=new P0e(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}();Hu(NC,"createInstance",(function(){return new NC(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},arguments.length>1?arguments[1]:void 0)}));var Ya=NC.createInstance();Ya.createInstance=NC.createInstance;var Eqt=Ya.createInstance,_qt=Ya.init,Tqt=Ya.loadResources,wqt=Ya.reloadResources,Sqt=Ya.use,Mqt=Ya.changeLanguage,Aqt=Ya.getFixedT,wr=Ya.t,Rqt=Ya.exists,Cqt=Ya.setDefaultNamespace,Pqt=Ya.hasLoadedNamespace,Iqt=Ya.loadNamespaces,Lqt=Ya.loadLanguages,rd=Ya,id=class extends Ms{constructor(e){super(),this.enabled=!0,this.keyboardEnabled=!0,this.mouseDownPositionX=0,this.mouseDownPositionY=0,this.lastLeftPointerUpTime=0,this.pointers=[],this.handleClick=e=>{if(!this.enabled)return;let t=this.getBaseEvent(e);this.dispatchEvent("click",t)},this.handlePointerDown=e=>{if(!this.enabled)return;this.stop(e);let t=this.getBaseEvent(e);this.isDoubleClick(t)?(this.lastLeftPointerUpTime=0,this.mouseDownPositionX=-1,this.mouseDownPositionY=-1,this.dispatchEvent("dblclick",t)):(this.mouseDownPositionX=t.x,this.mouseDownPositionY=t.y),this.dispatchEvent("pointerdown",t),"touch"===e.pointerType?(this.pointers.push(t),t.pointers=this.pointers,this.dispatchEvent("touchstart",t)):this.dispatchEvent("mousedown",t)},this.handlePointerMove=e=>{if(!this.enabled)return;this.stop(e);let t=this.getBaseEvent(e);this.isCloseToLastPosition(t)||(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.enabled)return;this.stop(e);let t=this.getBaseEvent(e);0===t.button&&(this.lastLeftPointerUpTime=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.handlePointerCancel=e=>{this.enabled&&(this.stop(e),this.dispatchEvent("pointercancel",this.getBaseEvent(e)))},this.handleMouseWheel=e=>{this.enabled&&(this.stop(e),this.dispatchEvent("wheel",this.getBaseEvent(e)))},this.handleContextMenu=e=>{if(this.enabled)return this.stop(e),this.dispatchEvent("contextmenu",this.getBaseEvent(e)),!1},this.handlePointerEnter=e=>{this.enabled&&(this.stop(e),this.dispatchEvent("pointerenter",this.getBaseEvent(e)))},this.handlePointerLeave=e=>{this.enabled&&(this.stop(e),this.dispatchEvent("pointerleave",this.getBaseEvent(e)))},this.handleResize=e=>{this.enabled&&(this.stop(e),this.dispatchEvent("resize",this.getBaseEvent(e)))},this.handleKeydown=e=>{!this.enabled||!this.keyboardEnabled||this.dispatchEvent("keydown",this.getBaseEvent(e))},this.handleKeyup=e=>{!this.enabled||!this.keyboardEnabled||this.dispatchEvent("keyup",this.getBaseEvent(e))},this.style={},this.element=e,this.bindEvents()}getEnabled(){return this.enabled}setEnabled(e){this.enabled=e}getkKeyboardEnabled(){return this.keyboardEnabled}setkKeyboardEnabled(e){this.keyboardEnabled=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,originalEvent:e};if(t.timestamp=e.timeStamp,UC(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,UC(e,"pointerId")){t.pointerType=e.pointerType,t.buttons=e.buttons,t.pageX=e.pageX,t.pageY=e.pageY,t.pointerId=e.pointerId;let n=Sn.getScreenCoordinateByEvent(e,this.element);t.x=n.x,t.y=n.y,t.movementX=e.movementX,t.movementY=e.movementY}else UC(e,"deltaX")&&(t.deltaMode=e.deltaMode,t.deltaX=e.deltaX,t.deltaY=e.deltaY);else UC(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()}isCloseToLastPosition(e){return-1!==this.mouseDownPositionX&&-1!==this.mouseDownPositionY&&Math.abs(e.x-this.mouseDownPositionX)<5&&Math.abs(e.y-this.mouseDownPositionY)<5}isDoubleClick(e){let t=e.timestamp-this.lastLeftPointerUpTime;return!!(0===e.button&&t<300&&this.isCloseToLastPosition(e))}};function UC(e,t){return void 0!==e[t]}var tr={LEFT:1,RIGHT:2,MIDDLE:4},Tt=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 bo(e){return e.isPerspectiveCamera}function Fs(e){return e.isOrthographicCamera}var qm=2*Math.PI,y6=Math.PI/2,o1=Math.PI/180;function Wm(e,t,n){return Math.max(t,Math.min(n,e))}function Vi(e,t=1e-5){return Math.abs(e)<t}function zi(e,t,n=1e-5){return Vi(e-t,n)}function x6(e,t){return Math.round(e/t)*t}function l1(e){return isFinite(e)?e:e<0?-Number.MAX_VALUE:Number.MAX_VALUE}function c1(e){return Math.abs(e)<Number.MAX_VALUE?e:e*(1/0)}function WE(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,u=t,c=r*i;h=Wm(h,-c,c),t=e-h;let d=(n.value+s*h)*a;n.value=(n.value-s*d)*l;let p=t+(h+d)*l;return u-e>0==p>u&&(p=u,n.value=(p-u)/a),p}function b6(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),u=t.x,c=t.y,d=t.z,p=e.x-u,f=e.y-c,m=e.z-d,g=u,v=c,y=d,x=r*i,b=p*p+f*f+m*m;if(b>x*x){let e=Math.sqrt(b);p=p/e*x,f=f/e*x,m=m/e*x}u=e.x-p,c=e.y-f,d=e.z-m;let _=(n.x+o*p)*a,w=(n.y+o*f)*a,S=(n.z+o*m)*a;n.x=(n.x-o*_)*h,n.y=(n.y-o*w)*h,n.z=(n.z-o*S)*h,s.x=u+(p+_)*h,s.y=c+(f+w)*h,s.z=d+(m+S)*h;let M=g-e.x,E=v-e.y,T=y-e.z;return M*(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 HC(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 VC(e,t){return!!Fs(e)&&(console.warn(`${t} is not supported in OrthographicCamera`),!0)}var zC=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)}}},GC=1/8,R0t=dr.isBrowser&&/Mac/.test(navigator.platform),C0t=!(dr.isBrowser&&"PointerEvent"in window),nr,V0e,qC,E6,Eo,sr,bi,u1,Gu,qu,jm,z0e,G0e,Gc,jE,h1,q0e,_6,W0e,T6,w6,WC,Wu=class extends zC{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=Tt.NONE,this._viewport=null,this._dollyControlAmount=0,this._hasRested=!0,this._boundaryEnclosesCamera=!1,this._needsUpdate=!0,this._updatedLastTime=!1,this._elementRect=dr.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 nr.Vector3,this._focalOffsetVelocity=new nr.Vector3,this._zoomVelocity={value:0},this._truckInternal=(e,t,n)=>{if(bo(this._camera)){let i=sr.copy(this._camera.position).sub(this._target),r=this._camera.getEffectiveFOV()*o1,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(Fs(this._camera)){let i=this._camera,r=this.truckSpeed*e*(i.right-i.left)/i.zoom/this._elementRect.width,a=this.truckSpeed*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=qm*this.azimuthRotateSpeed*e/this._elementRect.height,i=qm*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(sr),this._targetEnd.add(sr.normalize().multiplyScalar(s)),this._target.add(sr.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===nr&&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 nr.Quaternion).setFromUnitVectors(this._camera.up,qC),this._yAxisUpSpaceInverse=this._yAxisUpSpace.clone().invert(),this._state=Tt.NONE,this._target=new nr.Vector3,this._targetEnd=this._target.clone(),this._focalOffset=new nr.Vector3,this._focalOffsetEnd=this._focalOffset.clone(),this._spherical=(new nr.Spherical).setFromVector3(sr.copy(this._camera.position).applyQuaternion(this._yAxisUpSpace)),this._sphericalEnd=this._spherical.clone(),this._zoom=this._camera.zoom,this._zoomEnd=this._zoom,this._nearPlaneCorners=[new nr.Vector3,new nr.Vector3,new nr.Vector3,new nr.Vector3],this._updateNearPlaneCorners(),this._boundary=new nr.Box3(new nr.Vector3(-1/0,-1/0,-1/0),new nr.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 nr.Vector2,this.mouseButtons={left:Tt.ROTATE,middle:Tt.DOLLY,right:Tt.TRUCK,wheel:bo(this._camera)?Tt.DOLLY:Fs(this._camera)?Tt.ZOOM:Tt.NONE},this.touches={one:Tt.TOUCH_ROTATE,two:bo(this._camera)?Tt.TOUCH_DOLLY_TRUCK:Fs(this._camera)?Tt.TOUCH_ZOOM_TRUCK:Tt.NONE,three:Tt.TOUCH_TRUCK};let n=new nr.Vector2,i=new nr.Vector2,r=new nr.Vector2,a=e=>{if(!this._enabled||!this._domElement)return;let t="mouse"!==e.pointerType?null:(e.buttons&tr.LEFT)===tr.LEFT?tr.LEFT:(e.buttons&tr.MIDDLE)===tr.MIDDLE?tr.MIDDLE:(e.buttons&tr.RIGHT)===tr.RIGHT?tr.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&tr.LEFT)===tr.LEFT?tr.LEFT:(e.buttons&tr.MIDDLE)===tr.MIDDLE?tr.MIDDLE:(e.buttons&tr.RIGHT)===tr.RIGHT?tr.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&tr.LEFT)===tr.LEFT?tr.LEFT:(e.buttons&tr.MIDDLE)===tr.LEFT?tr.MIDDLE:(e.buttons&tr.RIGHT)===tr.LEFT?tr.RIGHT:null};this._activePointers.push(n),this._domElement.removeEventListener("mousemove",l),this._domElement.removeEventListener("mouseup",u),this._domElement.addEventListener("mousemove",l),this._domElement.addEventListener("mouseup",u),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&tr.LEFT)===tr.LEFT&&(this._state=this._state|this.mouseButtons.left),(e.buttons&tr.MIDDLE)===tr.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),(e.buttons&tr.RIGHT)===tr.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&tr.LEFT)===tr.LEFT&&(this._state=this._state|this.mouseButtons.left),(e.buttons&tr.MIDDLE)===tr.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),(e.buttons&tr.RIGHT)===tr.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=Tt.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=Tt.NONE;g()},u=()=>{let e=this._findPointerById(0);e&&this._activePointers.splice(this._activePointers.indexOf(e),1),this._state=Tt.NONE,g()},c=-1,d=e=>{if(!this._enabled||this.mouseButtons.wheel===Tt.NONE)return;if(this.dollyToCursor||this.mouseButtons.wheel===Tt.ROTATE||this.mouseButtons.wheel===Tt.TRUCK){let e=performance.now();c-e<1e3&&this._getClientRect(this._elementRect),c=e}let t=R0t?-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 Tt.ROTATE:this._rotateInternal(e.deltaX,e.deltaY),this._isUserControllingRotate=!0;break;case Tt.TRUCK:this._truckInternal(e.deltaX,e.deltaY,!1),this._isUserControllingTruck=!0;break;case Tt.OFFSET:this._truckInternal(e.deltaX,e.deltaY,!0),this._isUserControllingOffset=!0;break;case Tt.DOLLY:this._dollyInternal(-n,i,r),this._isUserControllingDolly=!0;break;case Tt.ZOOM:this._zoomInternal(-n,i,r),this._isUserControllingZoom=!0}this.dispatchEvent({type:"control"})},p=e=>{if(this._domElement&&this._enabled&&this.mouseButtons.right===Wu.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",u)}},f=e=>{if(this._enabled){if(HC(this._activePointers,Eo),this._getClientRect(this._elementRect),n.copy(Eo),i.copy(Eo),this._activePointers.length>=2){let e=Eo.x-this._activePointers[1].clientX,t=Eo.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&tr.LEFT)===tr.LEFT&&(this._state=this._state|this.mouseButtons.left),(e.buttons&tr.MIDDLE)===tr.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),(e.buttons&tr.RIGHT)===tr.RIGHT&&(this._state=this._state|this.mouseButtons.right);((this._state&Tt.ROTATE)===Tt.ROTATE||(this._state&Tt.TOUCH_ROTATE)===Tt.TOUCH_ROTATE||(this._state&Tt.TOUCH_DOLLY_ROTATE)===Tt.TOUCH_DOLLY_ROTATE||(this._state&Tt.TOUCH_ZOOM_ROTATE)===Tt.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&Tt.TRUCK)===Tt.TRUCK||(this._state&Tt.TOUCH_TRUCK)===Tt.TOUCH_TRUCK||(this._state&Tt.TOUCH_DOLLY_TRUCK)===Tt.TOUCH_DOLLY_TRUCK||(this._state&Tt.TOUCH_ZOOM_TRUCK)===Tt.TOUCH_ZOOM_TRUCK)&&(this._targetEnd.copy(this._target),this._targetVelocity.set(0,0,0)),((this._state&Tt.DOLLY)===Tt.DOLLY||(this._state&Tt.TOUCH_DOLLY)===Tt.TOUCH_DOLLY||(this._state&Tt.TOUCH_DOLLY_TRUCK)===Tt.TOUCH_DOLLY_TRUCK||(this._state&Tt.TOUCH_DOLLY_OFFSET)===Tt.TOUCH_DOLLY_OFFSET||(this._state&Tt.TOUCH_DOLLY_ROTATE)===Tt.TOUCH_DOLLY_ROTATE)&&(this._sphericalEnd.radius=this._spherical.radius,this._radiusVelocity.value=0),((this._state&Tt.ZOOM)===Tt.ZOOM||(this._state&Tt.TOUCH_ZOOM)===Tt.TOUCH_ZOOM||(this._state&Tt.TOUCH_ZOOM_TRUCK)===Tt.TOUCH_ZOOM_TRUCK||(this._state&Tt.TOUCH_ZOOM_OFFSET)===Tt.TOUCH_ZOOM_OFFSET||(this._state&Tt.TOUCH_ZOOM_ROTATE)===Tt.TOUCH_ZOOM_ROTATE)&&(this._zoomEnd=this._zoom,this._zoomVelocity.value=0),((this._state&Tt.OFFSET)===Tt.OFFSET||(this._state&Tt.TOUCH_OFFSET)===Tt.TOUCH_OFFSET||(this._state&Tt.TOUCH_DOLLY_OFFSET)===Tt.TOUCH_DOLLY_OFFSET||(this._state&Tt.TOUCH_ZOOM_OFFSET)===Tt.TOUCH_ZOOM_OFFSET)&&(this._focalOffsetEnd.copy(this._focalOffset),this._focalOffsetVelocity.set(0,0,0)),this.dispatchEvent({type:"controlstart"})}},m=()=>{if(!this._enabled)return;HC(this._activePointers,Eo);let e=!!dr.isBrowser&&this._domElement&&document.pointerLockElement===this._domElement,t=e?-this._activePointers[0].deltaX:i.x-Eo.x,a=e?-this._activePointers[0].deltaY:i.y-Eo.y;if(i.copy(Eo),((this._state&Tt.ROTATE)===Tt.ROTATE||(this._state&Tt.TOUCH_ROTATE)===Tt.TOUCH_ROTATE||(this._state&Tt.TOUCH_DOLLY_ROTATE)===Tt.TOUCH_DOLLY_ROTATE||(this._state&Tt.TOUCH_ZOOM_ROTATE)===Tt.TOUCH_ZOOM_ROTATE)&&(this._rotateInternal(t,a),this._isUserControllingRotate=!0),(this._state&Tt.DOLLY)===Tt.DOLLY||(this._state&Tt.ZOOM)===Tt.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&Tt.DOLLY)===Tt.DOLLY?(this._dollyInternal(a*GC,e,t),this._isUserControllingDolly=!0):(this._zoomInternal(a*GC,e,t),this._isUserControllingZoom=!0)}if((this._state&Tt.TOUCH_DOLLY)===Tt.TOUCH_DOLLY||(this._state&Tt.TOUCH_ZOOM)===Tt.TOUCH_ZOOM||(this._state&Tt.TOUCH_DOLLY_TRUCK)===Tt.TOUCH_DOLLY_TRUCK||(this._state&Tt.TOUCH_ZOOM_TRUCK)===Tt.TOUCH_ZOOM_TRUCK||(this._state&Tt.TOUCH_DOLLY_OFFSET)===Tt.TOUCH_DOLLY_OFFSET||(this._state&Tt.TOUCH_ZOOM_OFFSET)===Tt.TOUCH_ZOOM_OFFSET||(this._state&Tt.TOUCH_DOLLY_ROTATE)===Tt.TOUCH_DOLLY_ROTATE||(this._state&Tt.TOUCH_ZOOM_ROTATE)===Tt.TOUCH_ZOOM_ROTATE){let e=Eo.x-this._activePointers[1].clientX,t=Eo.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&Tt.TOUCH_DOLLY)===Tt.TOUCH_DOLLY||(this._state&Tt.TOUCH_DOLLY_ROTATE)===Tt.TOUCH_DOLLY_ROTATE||(this._state&Tt.TOUCH_DOLLY_TRUCK)===Tt.TOUCH_DOLLY_TRUCK||(this._state&Tt.TOUCH_DOLLY_OFFSET)===Tt.TOUCH_DOLLY_OFFSET?(this._dollyInternal(a*GC,s,o),this._isUserControllingDolly=!0):(this._zoomInternal(a*GC,s,o),this._isUserControllingZoom=!0)}((this._state&Tt.TRUCK)===Tt.TRUCK||(this._state&Tt.TOUCH_TRUCK)===Tt.TOUCH_TRUCK||(this._state&Tt.TOUCH_DOLLY_TRUCK)===Tt.TOUCH_DOLLY_TRUCK||(this._state&Tt.TOUCH_ZOOM_TRUCK)===Tt.TOUCH_ZOOM_TRUCK)&&(this._truckInternal(t,a,!1),this._isUserControllingTruck=!0),((this._state&Tt.OFFSET)===Tt.OFFSET||(this._state&Tt.TOUCH_OFFSET)===Tt.TOUCH_OFFSET||(this._state&Tt.TOUCH_DOLLY_OFFSET)===Tt.TOUCH_DOLLY_OFFSET||(this._state&Tt.TOUCH_ZOOM_OFFSET)===Tt.TOUCH_ZOOM_OFFSET)&&(this._truckInternal(t,a,!0),this._isUserControllingOffset=!0),this.dispatchEvent({type:"control"})},g=()=>{HC(this._activePointers,Eo),i.copy(Eo),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",u),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),C0t&&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",u))},this.cancel=()=>{this._state!==Tt.NONE&&(this._state=Tt.NONE,this._activePointers.length=0,g())},t&&this.connect(t),this.update(0)}static install(e){nr=e.THREE,V0e=Object.freeze(new nr.Vector3(0,0,0)),qC=Object.freeze(new nr.Vector3(0,1,0)),E6=Object.freeze(new nr.Vector3(0,0,1)),Eo=new nr.Vector2,sr=new nr.Vector3,bi=new nr.Vector3,u1=new nr.Vector3,Gu=new nr.Vector3,qu=new nr.Vector3,jm=new nr.Vector3,z0e=new nr.Vector3,G0e=new nr.Vector3,Gc=new nr.Spherical,jE=new nr.Spherical,h1=new nr.Box3,q0e=new nr.Box3,_6=new nr.Sphere,W0e=new nr.Quaternion,T6=new nr.Quaternion,w6=new nr.Matrix4,WC=new nr.Raycaster}static get ACTION(){return Tt}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=Wm(e,this.minAzimuthAngle,this.maxAzimuthAngle),r=Wm(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||zi(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&zi(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=Wm(e,this.minDistance,this.maxDistance);if(this.colliderMeshes.length>=1){let e=this._collisionTest(),t=zi(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||zi(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=Wm(e,this.minZoom,this.maxZoom),this._needsUpdate=!0,t||(this._zoom=this._zoomEnd);let n=!t||zi(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(),Gu.setFromMatrixColumn(this._camera.matrix,0),qu.setFromMatrixColumn(this._camera.matrix,1),Gu.multiplyScalar(e),qu.multiplyScalar(-t);let i=sr.copy(Gu).add(qu),r=bi.copy(this._targetEnd).add(i);return this.moveTo(r.x,r.y,r.z,n)}forward(e,t=!1){sr.setFromMatrixColumn(this._camera.matrix,0),sr.crossVectors(this._camera.up,sr),sr.multiplyScalar(e);let n=bi.copy(this._targetEnd).add(sr);return this.moveTo(n.x,n.y,n.z,t)}elevate(e,t=!1){return sr.copy(this._camera.up).multiplyScalar(e),this.moveTo(this._targetEnd.x+sr.x,this._targetEnd.y+sr.y,this._targetEnd.z+sr.z,t)}moveTo(e,t,n,i=!1){this._isUserControllingTruck=!1;let r=sr.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||zi(this._target.x,this._targetEnd.x,this.restThreshold)&&zi(this._target.y,this._targetEnd.y,this.restThreshold)&&zi(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(a)}lookInDirectionOf(e,t,n,i=!1){let r=sr.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?h1.copy(e):h1.setFromObject(e);l.isEmpty()&&(console.warn("camera-controls: fitTo() cannot be used with an empty box. Aborting"),Promise.resolve());let h=x6(this._sphericalEnd.theta,y6),u=x6(this._sphericalEnd.phi,y6);o.push(this.rotateTo(h,u,t));let c=sr.setFromSpherical(this._sphericalEnd).normalize(),d=W0e.setFromUnitVectors(c,E6),p=zi(Math.abs(c.y),1);p&&d.multiply(T6.setFromAxisAngle(qC,h)),d.multiply(this._yAxisUpSpaceInverse);let f=q0e.makeEmpty();bi.copy(l.min).applyQuaternion(d),f.expandByPoint(bi),bi.copy(l.min).setX(l.max.x).applyQuaternion(d),f.expandByPoint(bi),bi.copy(l.min).setY(l.max.y).applyQuaternion(d),f.expandByPoint(bi),bi.copy(l.max).setZ(l.min.z).applyQuaternion(d),f.expandByPoint(bi),bi.copy(l.min).setZ(l.max.z).applyQuaternion(d),f.expandByPoint(bi),bi.copy(l.max).setY(l.min.y).applyQuaternion(d),f.expandByPoint(bi),bi.copy(l.max).setX(l.min.x).applyQuaternion(d),f.expandByPoint(bi),bi.copy(l.max).applyQuaternion(d),f.expandByPoint(bi),f.min.x-=i,f.min.y-=a,f.max.x+=r,f.max.y+=s,d.setFromUnitVectors(E6,c),p&&d.premultiply(T6.invert()),d.premultiply(this._yAxisUpSpace);let m=f.getSize(sr),g=f.getCenter(bi).applyQuaternion(d);if(bo(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(Fs(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 nr.Sphere?_6.copy(e):Wu.createBoundingSphere(e,_6);if(n.push(this.moveTo(i.center.x,i.center.y,i.center.z,t)),bo(this._camera)){let e=this.getDistanceToFitSphere(i.radius);n.push(this.dollyTo(e,t))}else if(Fs(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=bi.set(i,r,a),l=sr.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||zi(this._target.x,this._targetEnd.x,this.restThreshold)&&zi(this._target.y,this._targetEnd.y,this.restThreshold)&&zi(this._target.z,this._targetEnd.z,this.restThreshold)&&zi(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&zi(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&zi(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(h)}lerpLookAt(e,t,n,i,r,a,s,o,l,h,u,c,d,p=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1;let f=sr.set(i,r,a),m=bi.set(e,t,n);Gc.setFromVector3(m.sub(f).applyQuaternion(this._yAxisUpSpace));let g=u1.set(h,u,c),v=bi.set(s,o,l);jE.setFromVector3(v.sub(g).applyQuaternion(this._yAxisUpSpace)),this._targetEnd.copy(f.lerp(g,d));let y=jE.theta-Gc.theta,x=jE.phi-Gc.phi,b=jE.radius-Gc.radius;this._sphericalEnd.set(Gc.radius+b*d,Gc.phi+x*d,Gc.theta+y*d),this.normalizeRotations(),this._needsUpdate=!0,p||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));let _=!p||zi(this._target.x,this._targetEnd.x,this.restThreshold)&&zi(this._target.y,this._targetEnd.y,this.restThreshold)&&zi(this._target.z,this._targetEnd.z,this.restThreshold)&&zi(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&zi(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&zi(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(_)}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(sr),a=this.setLookAt(r.x,r.y,r.z,e,t,n,i);return this._sphericalEnd.phi=Wm(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||zi(this._focalOffset.x,this._focalOffsetEnd.x,this.restThreshold)&&zi(this._focalOffset.y,this._focalOffsetEnd.y,this.restThreshold)&&zi(this._focalOffset.z,this._focalOffsetEnd.z,this.restThreshold);return this._createOnRestPromise(r)}setOrbitPoint(e,t,n){this._camera.updateMatrixWorld(),Gu.setFromMatrixColumn(this._camera.matrixWorldInverse,0),qu.setFromMatrixColumn(this._camera.matrixWorldInverse,1),jm.setFromMatrixColumn(this._camera.matrixWorldInverse,2);let i=sr.set(e,t,n),r=i.distanceTo(this._camera.position),a=i.sub(this._camera.position);Gu.multiplyScalar(a.x),qu.multiplyScalar(a.y),jm.multiplyScalar(a.z),sr.copy(Gu).add(qu).add(jm),sr.z=sr.z+r,this.dollyTo(r,!1),this.setFocalOffset(-sr.x,sr.y,-sr.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 nr.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(VC(this._camera,"getDistanceToFitBox"))return this._spherical.radius;let r=e/t,a=this._camera.getEffectiveFOV()*o1,s=this._camera.aspect;return.5*((i?r>s:r<s)?t:e/s)/Math.tan(.5*a)+.5*n}getDistanceToFitSphere(e){if(VC(this._camera,"getDistanceToFitSphere"))return this._spherical.radius;let t=this._camera.getEffectiveFOV()*o1,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 nr.Vector3).copy(this._targetEnd)}getPosition(e){return(e&&e.isVector3?e:new nr.Vector3).setFromSpherical(this._sphericalEnd).applyQuaternion(this._yAxisUpSpaceInverse).add(this._targetEnd)}getFocalOffset(e){return(e&&e.isVector3?e:new nr.Vector3).copy(this._focalOffsetEnd)}normalizeRotations(){this._sphericalEnd.theta=this._sphericalEnd.theta%qm,this._sphericalEnd.theta<0&&(this._sphericalEnd.theta+=qm),this._spherical.theta+=qm*Math.round((this._sphericalEnd.theta-this._spherical.theta)/qm)}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,qC),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=z0e.subVectors(this._targetEnd,this._target),a=G0e.subVectors(this._focalOffsetEnd,this._focalOffset),s=this._zoomEnd-this._zoom;if(Vi(t))this._thetaVelocity.value=0,this._spherical.theta=this._sphericalEnd.theta;else{let t=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.theta=WE(this._spherical.theta,this._sphericalEnd.theta,this._thetaVelocity,t,1/0,e),this._needsUpdate=!0}if(Vi(n))this._phiVelocity.value=0,this._spherical.phi=this._sphericalEnd.phi;else{let t=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.phi=WE(this._spherical.phi,this._sphericalEnd.phi,this._phiVelocity,t,1/0,e),this._needsUpdate=!0}if(Vi(i))this._radiusVelocity.value=0,this._spherical.radius=this._sphericalEnd.radius;else{let t=this._isUserControllingDolly?this.draggingSmoothTime:this.smoothTime;this._spherical.radius=WE(this._spherical.radius,this._sphericalEnd.radius,this._radiusVelocity,t,this.maxSpeed,e),this._needsUpdate=!0}if(Vi(r.x)&&Vi(r.y)&&Vi(r.z))this._targetVelocity.set(0,0,0),this._target.copy(this._targetEnd);else{let t=this._isUserControllingTruck?this.draggingSmoothTime:this.smoothTime;b6(this._target,this._targetEnd,this._targetVelocity,t,this.maxSpeed,e,this._target),this._needsUpdate=!0}if(Vi(a.x)&&Vi(a.y)&&Vi(a.z))this._focalOffsetVelocity.set(0,0,0),this._focalOffset.copy(this._focalOffsetEnd);else{let t=this._isUserControllingOffset?this.draggingSmoothTime:this.smoothTime;b6(this._focalOffset,this._focalOffsetEnd,this._focalOffsetVelocity,t,this.maxSpeed,e,this._focalOffset),this._needsUpdate=!0}if(0!==this._dollyControlAmount){if(bo(this._camera)){let e=this._camera,t=sr.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).normalize().negate(),n=bi.copy(t).cross(e.up).normalize();0===n.lengthSq()&&(n.x=1);let i=u1.crossVectors(n,t),r=this._sphericalEnd.radius*Math.tan(e.getEffectiveFOV()*o1*.5),a=(this._sphericalEnd.radius-this._dollyControlAmount-this._sphericalEnd.radius)/this._sphericalEnd.radius,s=sr.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(Fs(this._camera)){let e=this._camera,t=sr.set(this._dollyControlCoord.x,this._dollyControlCoord.y,(e.near+e.far)/(e.near-e.far)).unproject(e),n=bi.set(0,0,-1).applyQuaternion(e.quaternion),i=u1.copy(t).add(n.multiplyScalar(-t.dot(e.up))),r=-(this._zoom-this._dollyControlAmount-this._zoomEnd)/this._zoom,a=sr.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(Vi(s))this._zoomVelocity.value=0,this._zoom=this._zoomEnd;else{let t=this._isUserControllingZoom?this.draggingSmoothTime:this.smoothTime;this._zoom=WE(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),(!Vi(this._focalOffset.x)||!Vi(this._focalOffset.y)||!Vi(this._focalOffset.z))&&(this._camera.updateMatrixWorld(),Gu.setFromMatrixColumn(this._camera.matrix,0),qu.setFromMatrixColumn(this._camera.matrix,1),jm.setFromMatrixColumn(this._camera.matrix,2),Gu.multiplyScalar(this._focalOffset.x),qu.multiplyScalar(-this._focalOffset.y),jm.multiplyScalar(this._focalOffset.z),sr.copy(Gu).add(qu).add(jm),this._camera.position.add(sr)),this._boundaryEnclosesCamera&&this._encloseToBoundary(this._camera.position.copy(this._target),sr.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"}),Vi(t,this.restThreshold)&&Vi(n,this.restThreshold)&&Vi(i,this.restThreshold)&&Vi(r.x,this.restThreshold)&&Vi(r.y,this.restThreshold)&&Vi(r.z,this.restThreshold)&&Vi(a.x,this.restThreshold)&&Vi(a.y,this.restThreshold)&&Vi(a.z,this.restThreshold)&&Vi(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:l1(this.maxDistance),minZoom:this.minZoom,maxZoom:l1(this.maxZoom),minPolarAngle:this.minPolarAngle,maxPolarAngle:l1(this.maxPolarAngle),minAzimuthAngle:l1(this.minAzimuthAngle),maxAzimuthAngle:l1(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:sr.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=sr.fromArray(n.position);this.enabled=n.enabled,this.minDistance=n.minDistance,this.maxDistance=c1(n.maxDistance),this.minZoom=n.minZoom,this.maxZoom=c1(n.maxZoom),this.minPolarAngle=n.minPolarAngle,this.maxPolarAngle=c1(n.maxPolarAngle),this.minAzimuthAngle=c1(n.minAzimuthAngle),this.maxAzimuthAngle=c1(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),Gc.setFromVector3(i.sub(this._targetEnd).applyQuaternion(this._yAxisUpSpace)),this.rotateTo(Gc.theta,Gc.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=bi.copy(t).add(e),a=this._boundary.clampPoint(r,u1).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(bi.copy(t).multiplyScalar(i)).add(a.multiplyScalar(1-n))}}_updateNearPlaneCorners(){if(bo(this._camera)){let e=this._camera,t=e.near,n=e.getEffectiveFOV()*o1,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(Fs(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)||VC(this._camera,"_collisionTest"))return e;let t=sr.setFromSpherical(this._spherical).divideScalar(this._spherical.radius);w6.lookAt(V0e,t,this._camera.up);for(let n=0;n<4;n++){let i=bi.copy(this._nearPlaneCorners[n]);i.applyMatrix4(w6);let r=u1.addVectors(this._target,i);WC.set(r,t),WC.far=this._spherical.radius+1;let a=WC.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 nr.Sphere){let n=t,i=n.center;h1.makeEmpty(),e.traverseVisible((e=>{e.isMesh&&h1.expandByObject(e)})),h1.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++)sr.fromBufferAttribute(e,t),r=Math.max(r,i.distanceToSquared(sr))}else{let e=n.attributes.position;for(let t=0,n=e.count;t<n;t++)sr.fromBufferAttribute(e,t),r=Math.max(r,i.distanceToSquared(sr))}})),n.radius=Math.sqrt(r),n}},br=Wu,d1=class{},f1=new ht,S6=new Nt,jl=class extends d1{constructor(e){var t,n;super(),this.modelData=e,this.modelId=e.modelId,this.modelObject=(null==(t=e.dxfData)?void 0:t.threejsObject)||(null==(n=e.pdfData)?void 0:n.threejsObject),this.modelObject.name=this.modelId,this.modelObject.userData.modelId=this.modelId}get pdfData(){return this.modelData.pdfData}get dxfData(){return this.modelData.dxfData}get msTransformMatrix(){return this.modelData.msTransformMatrix}set msTransformMatrix(e){this.modelData.msTransformMatrix=e}get loadedEntityCount(){var e,t;return(null==(e=this.dxfData)?void 0:e.loadedEntityCount)||(null==(t=this.pdfData)?void 0:t.loadedEntityCount)||0}get header(){var e;return null==(e=this.dxfData)?void 0:e.header}get viewports(){var e;return null==(e=this.dxfData)?void 0:e.tables.viewport.viewports}get layers(){var e;let t=this.dxfData||this.pdfData;return(null==(e=t.tables)?void 0:e.layer.layers)||t.layers}get layoutViewportsMap(){var e;return null==(e=this.dxfData)?void 0:e.layoutViewportsMap}getModelObject(){let e=this.dxfData||this.pdfData;if(!e)throw new Error(`Failed to find model by modelId '${this.modelId}'!`);return e.threejsObject}getBBox(){if(!this.bbox){let e=new Nt,t=this.getModelObject();e.setFromObject(t),this.bbox=e}return this.bbox}getUnits(){if(!this.dxfData)return"Unitless";let e=this.dxfData.header;if(!e)return fe.warn("DxfData or its header is undefined!"),"Unitless";let t=e.$INSUNITS;return Ln.getDxfUnits(t)}getModelSpaceExtent(){let e=this.header,t=new k,n=new k;if(!e)return void fe.error(`Header is undefined in ${this.modelId}!`);let i=this.viewports,r=e.$EXTMIN,a=e.$EXTMAX,s=e.$ANGDIR;if(i&&i.length>0)for(let o=0;o<i.length;o++){let e=i[o];if("*ACTIVE"===e.name.toLocaleUpperCase()){let{center:t,viewHeight:n,aspectRatio:i}=e,o=n*i,l=Ln.getDcs2WcsMatrix(e,s),h=new k(t.x,t.y,0);h.applyMatrix4(l),r={x:h.x-o/2,y:h.y-n/2,z:0},a={x:h.x+o/2,y:h.y+n/2,z:0};break}}return t.set(r.x,r.y,r.z),n.set(a.x,a.y,a.z),new Nt(t,n)}getLayer(e){if(this.layers)return this.layers[e]}getObjectsByLayer(e){let t=this.dxfData||this.pdfData;return(null==t?void 0:t.layersAndThreejsObjects)&&t.layersAndThreejsObjects[e]}getLayouts(){let e=[],t=this.dxfData,n=null==t?void 0:t.objects.LAYOUT;return null==n||n.forEach((t=>{e.push(t)})),e}getLayoutByName(e){let t,n=this.getLayouts();for(let i of n)if(i.layoutName===e){t=i;break}return t}getLayoutExtent(e){let t=this.header,n=new k,i=new k;if(!t)throw new Error(`Header is undefined in ${this.modelId}!`);let r=this.getLayoutViewports(e),a=t.$PEXTMIN,s=t.$PEXTMAX,o=t.$ANGDIR;if(r&&r.length>0){let e,t=r.filter((e=>1===parseInt(e.viewportId)));e=t.length>0?t[0]:r[0];let{centerPoint:n,width_paperSpace:i,height_paperSpace:l}=e,h=Ln.getDcs2WcsMatrix(e,o),u=new k(n.x,n.y,0);u.applyMatrix4(h),a={x:u.x-i/2,y:u.y-l/2,z:0},s={x:u.x+i/2,y:u.y+l/2,z:0}}return n.set(a.x,a.y,a.z),i.set(s.x,s.y,s.z),new Nt(n,i)}getLayoutViewports(e){return this.layoutViewportsMap[e.ownerHandle]||[]}getLayoutLevelObject(e){let t=this.getModelObject();return null==t?void 0:t.children.find((t=>t.name===e))}setVisible(e){this.getModelObject().visible=e}setLayerVisible(e,t,n,i){let r=this.getLayer(e);r?r.visible=t:fe.warn(`[Viewer] Layer '${e}' not found from modelData!`);let a=this.getObjectsByLayer(e);if(a)for(let s=0;s<a.length;s++){let e=a[s];n&&t&&i&&e.userData.visibleMinZoom&&i<e.userData.visibleMinZoom||(e.visible=t),(!1===t||null!=e.userData.layerVisible)&&(e.userData.layerVisible=t),e.userData.isSnapObject&&(e.visible?Ln.SHOW_SNAP_OBJECT?e.layers.enableAll():e.layers.set(11):Ln.SHOW_SNAP_OBJECT?e.layers.disableAll():e.layers.disable(11))}else fe.info(`[Viewer] No object found for layer '${e}'`)}setLayerOpacity(e,t){if(!this.getLayer(e))throw new Error(`Failed to find layer by layerName '${e}'!`);let n=this.getObjectsByLayer(e);n?n.forEach((e=>{let n=e;if(n.material){n.userData.originalMaterial||(n.userData.originalMaterial=Si.cloneMaterial(n.material));let e=Si.cloneMaterial(n.material);Si.setMaterialOpacity(e,t),Ln.updateMaterialUniforms(e),n.material=e}})):fe.info(`[Viewer] No object found for layer '${e}'`)}setLayerColor(e,t){if(!this.getLayer(e))throw new Error(`Failed to find layer by layerName '${e}'!`);let n=this.getObjectsByLayer(e);n?n.forEach((e=>{let n=e;if(n.material){n.userData.originalMaterial||(n.userData.originalMaterial=Si.cloneMaterial(n.material));let e=Si.cloneMaterial(n.material);Si.setMaterialColor(e,new ct(t)),Ln.updateMaterialUniforms(e),n.material=e}})):fe.info(`[Viewer] No object found for layer '${e}'`)}resetLayerColor(e){if(!this.getLayer(e))throw new Error(`Failed to find layer by layerName '${e}'!`);let t=this.getObjectsByLayer(e);t?t.forEach((e=>{let t=e;t.material&&t.userData.originalMaterial&&(t.material.dispose(),t.material=t.userData.originalMaterial,delete t.userData.originalMaterial)})):fe.info(`[Viewer] No object found for layer '${e}'`)}switchTransformMs(e){let t=this.msTransformMatrix;if(f1.identity(),!t||!Pt.isMatrixValid(t)||t.equals(f1))return;let n=this.getLayoutLevelObject(Ln.MODEL_LAYOUT_NAME);n&&(e===Ln.MODEL_LAYOUT_NAME?n.applyMatrix4(t):n.applyMatrix4(t.clone().invert()),n.updateMatrixWorld(!0))}activateLayout(e=Ln.MODEL_LAYOUT_NAME,t){this.switchTransformMs(e);let n=this.getLayoutByName(e);if(n){if(!t){let t=this.getLayoutViewports(n),i=[];t.length>0&&(i=t[0].frozenLayerHandles);let r=e!==Ln.MODEL_LAYOUT_NAME,a=this.getLayoutLevelObject(e);if(a){let t=[];a.traverse((n=>{this.addSpatialFilterSection(n,this.dxfData);let a=n;if(r&&a.material&&a.geometry){let n=a.userData.layerName;if(!this.isLayerFrozenForViewport(n,i))return;t.push(a);let r=-1,s=this.getObjectsByLayer(n);s&&(r=s.indexOf(a),r>=0&&s.splice(r,1)),r<0&&fe.warn(`[Viewer] Failed to find object for modelId '${this.modelId}', layer '${n}', layout '${e}'`)}})),t.forEach((e=>{e.removeFromParent()}))}let s=this.getFilteredViewports(n);fe.debug("[Viewer] Active layout:",e,", viewports:",s);let o=Date.now();s.forEach((t=>{this.generateObjectsByViewport(e,t,this)})),fe.info(`[Viewer] generateObjectsByViewport in ${(Date.now()-o)/1e3}s`)}this.showLayoutObjects(e)}}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!");Ln.transformMatrixUniform={value:r.msToPsMatrix},Ln.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,u=new _i(new _e(l.x,l.y),new _e(h.x,h.y)),c=ku.generateSectionPlanesByBox(u),d=[],p=e=>(d[e.id]||(d[e.id]=e.clone(),this.setMaterialUniforms(d[e.id],n.dxfData),ku.setMaterialSection(d[e.id],c)),d[e.id]),f=[...i,...t.frozenLayerHandles||[]];if(e!==Ln.MODEL_LAYOUT_NAME){let e=t;e.associatedLeafObjectSet||(e.associatedLeafObjectSet=new Set),o=e.associatedLeafObjectSet}let m=new Bn;m.name=t.viewportId;let g=[];if(s.forEach((t=>{let i=t.clone();i.traverse((t=>{if(t.material&&t.geometry){let i=t.userData.layerName;if(this.isLayerFrozenForViewport(i,f))return void g.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);let r=n.getObjectsByLayer(i);r?r.push(t):fe.warn(`[Viewer] Failed to find object for modelId '${this.modelId}', layer '${i}', layout '${e}'`)}})),m.add(i)})),o&&0===o.size)return;let v=n.getModelObject(),y=n.getLayoutLevelObject(e);y||(y=new Bn,rr.setSharedVariablesOfObject(y),y.name=e,null==v||v.add(y)),y.add(m),m.applyMatrix4(r.msToPsMatrix),m.updateMatrixWorld(!0);let x=y.children.find((e=>e.name===Ln.SNAP_GROUP_NAME));x||(x=new Bn,x.visible=Ln.SHOW_SNAP_OBJECT,x.name=Ln.SNAP_GROUP_NAME,y.add(x));let b=n.getLayoutLevelObject(Ln.MODEL_LAYOUT_NAME),_=null==b?void 0:b.children.find((e=>e.name===Ln.SNAP_GROUP_NAME));_&&_.traverse((e=>{if(!e.geometry)return;let t=e.userData.layerName;if(this.isLayerFrozenForViewport(t,f)||(S6.makeEmpty(),S6.expandByObject(e),!a.intersectsBox(S6)))return;let i=e.clone();rr.setSharedVariablesOfObject(i);let s=i.parent,l=f1.identity();for(;s&&!0!==s.userData.isLayoutLevelObject;)l.premultiply(s.matrix),s=s.parent;l.premultiply(r.msToPsMatrix),i.applyMatrix4(l),null==x||x.add(i),null==o||o.add(i);let h=n.getObjectsByLayer(t);h&&h.push(i)})),g.length>0&&rr.removeEmptyObjectsFromRemovingObjects(g,m),m.traverse((e=>{rr.setSharedVariablesOfObject(e),this.addSpatialFilterSection(e,n.dxfData,!0)}))}setMaterialUniforms(e,t){e instanceof hn&&(e.uniforms.u_cameraZoom&&(e.uniforms.u_cameraZoom=Ln.cameraZoomUniform),e.uniforms.u_viewportScale&&1===(null==t?void 0:t.header.$PSLTSCALE)&&(e.uniforms.u_viewportScale=Ln.viewportScaleUniform))}getObjectsByBoundingBox(e){let t=[];if(e.isEmpty())return fe.warn("[Viewer] bbox is empty !"),t;let n=this.getLayoutLevelObject(Ln.MODEL_LAYOUT_NAME);return n&&n.children.forEach((n=>{n.name!==Ln.SNAP_GROUP_NAME&&(n=>{let i=Ol.getBoundingBox(n,!1);e.intersectsBox(i)&&t.push(n)})(n)})),t}showLayoutObjects(e){let t=0,n=0,i=this.getModelObject();i.children.forEach((i=>{let r=i.name===e;i.visible=r,r?t++:n++})),fe.debug(`[Viewer] showLayoutObjects('${e}') sets ${t} layout level object(s) to visible and ${n} to hidden for model '${null==i?void 0:i.name}'`)}isLayerFrozenForViewport(e,t){let n=this.getLayer(e);return!!(n&&(1&n.flag)>0)||!(!t||t.length<=0)&&n&&t.indexOf(n.handle)>=0}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 fe.warn("[Viewer] 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>Ln.maxFragmentUniforms},i=new Set,a=e=>{i.has(e.id)||(i.add(e.id),n(e)||ku.setMaterialSection(e,s,t,r))};e.traverse((e=>{let t=e.material;Array.isArray(t)?t.forEach((e=>{a(e)})):t&&a(t)}))}}}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}generateSectionsBySpatialFilter(e,t){let n=e.clipPolylines[0];if(n.bConcave)return void fe.warn("[Viewer] clipPolyline.bConcave = true is not supported yet in spatialFilter !");f1.copy(t),e.localMatrix&&f1.multiply(e.localMatrix);let i=n.polyline,r=[];i.forEach((e=>{let t=e.clone().applyMatrix4(f1);r.push(new _e(t.x,t.y))}));let a=qs.isClockWise(r),s=!a&&!n.bReversed||a&&n.bReversed;return ku.generateSectionPlanesByPoints(r,s)}hasObject(e){return!!this.modelObject.getObjectById(e.id)}hasObjectWithId(e){return!!this.modelObject.getObjectById(e)}highlightObject(e){if(!this.hasObject(e))return;let t=Si.clonedHighlightMaterials(e,{depthTest:!1});t&&(e.userData.originalMaterial=e.material,e.material=t)}unHighlightObject(e){if(!this.hasObject(e))return;let t=e.material;e.material=e.userData.originalMaterial,delete e.userData.originalMaterial,Array.isArray(t)?t.forEach((e=>e.dispose())):t instanceof Ar&&t.dispose()}clearHighlight(){}},XE=class extends d1{constructor(e){super(),this.modelData=e,this.modelId=e.modelId,this.modelObject=e.object,this.tilesRenderer=e.tilesRenderer,this.modelGroup=new Bn,this.modelGroup.name=`modelGroup-${this.modelId}`,this.modelGroup.userData.modelId=this.modelId,this.highlighGroup=new Bn,this.highlighGroup.layers.disable(12),this.highlighGroup.name=`highlighGroup-${this.modelId}`,this.transparentGroup=new Bn,this.transparentGroup.layers.disable(12),this.transparentGroup.name=`transparentGroup-${this.modelId}`,this.modelGroup.add(this.highlighGroup),this.modelGroup.add(this.transparentGroup),this.modelGroup.add(e.object)}getModelObject(){return this.modelGroup}getBBox(){return this._bbox||(this._bbox=new Nt,this._bbox.setFromObject(this.getModelObject())),this._bbox}enableEdges(e,t){return it(this,null,(function*(){e&&(this.edges||(this.edges=yield rr.createOutlines(this.getModelObject(),void 0,t))),this.edges&&this.edges.forEach((t=>t.visible=e))}))}setObjectColor(e,t){this.hasObject(e)&&e.material.color.set(t)}setObjectOpacity(e,t=.5,n,i){if(this.hasObject(e)){if(e instanceof Os&&i){let n=this.createInstanceMeshById(e,i,{opacity:t});n.material.opacity*=t,e.userData.instanceId=i,e.userData.transparentedMesh=n,this.transparentGroup.add(n)}else if(Mi.isMergedMesh(e)&&n){let i=this.createBatchMeshById(e,n,{opacity:t});i.material.opacity*=t,e.userData.batchId=n,e.userData.transparentedMesh=i,this.transparentGroup.add(i)}else{let t=new cn({color:0,transparent:!0,opacity:.05});t&&(e.userData.originalMaterial=e.material,e.material=t)}e.userData.isTransparent=!0}}clearObjectOpacity(e,t,n){if(!this.isObjectTransparent(e))return;let{transparentedMesh:i,originalMaterial:r}=e.userData;i&&(this.transparentGroup.remove(i),delete e.userData.batchId,delete e.userData.instanceId,delete e.userData.transparentedMesh),r&&(e.material=r),delete e.userData.isTransparent}isObjectTransparent(e){let{isTransparent:t}=e.userData;return!!t}setOpacity(e=.5){this.getModelObject().traverse((t=>{t instanceof St&&this.setObjectOpacity(t,e)}))}clearOpacity(){this.getModelObject().traverse((e=>{e instanceof St&&this.clearObjectOpacity(e)}))}highlightObjectById(e,t,n){if(!this.hasObjectWithId(e))return;let i=this.getModelObject().getObjectById(e);i&&this.highlightObject(i,t,n)}highlightObject(e,t,n){if(!this.hasObject(e))return;let i=new ct(583902);if(e instanceof Os&&n){let t=this.createInstanceMeshById(e,n,{depthTest:!1});t.material.opacity=.7,Si.setMaterialColor(t.material,i),e.userData.instanceId=n,e.userData.clonedMesh=t,this.highlighGroup.add(t)}else if(Mi.isMergedMesh(e)&&t){let n=this.createBatchMeshById(e,t,{depthTest:!1});n.material.opacity=.7,Si.setMaterialColor(n.material,i),e.userData.batchId=t,e.userData.clonedMesh=n,this.highlighGroup.add(n)}else{let t=Si.clonedHighlightMaterials(e,{depthTest:!1});t&&(e.userData.originalMaterial=e.material,e.material=t)}e.userData.isHighlight=!0,this.highlighObject=e}clearHighlight(){if(this.highlighObject&&this.highlighObject.userData){let e=this.highlighObject.userData,{clonedMesh:t,originalMaterial:n,instanceId:i,originalMatrix:r}=e;t&&(t.removeFromParent(),t.geometry.dispose(),delete e.clonedMesh),i&&r&&(this.highlighObject.setMatrixAt(i,r),delete e.instanceId,delete e.originalMatrix),n&&(this.highlighObject.material=n,delete e.originalMaterial),delete e.isHighlight}this.highlighGroup.clear(),this.highlighObject=void 0}setObjectVisible(e,t){this.hasObject(e)&&(e.visible=t)}setVisible(e){this.getModelObject().traverse((t=>{t instanceof St&&(t.visible=e)}))}createBatchMeshById(e,t,{opacity:n=1,depthTest:i=!0}){let r=Mi.getBatchByBatchId(e,t),a=`[Viewer] Clicked on merged mesh(id: ${e.id}).`;a+=` batchId: ${t}, object name: ${null==r?void 0:r.name}`,null!=r&&r.userData&&(a+=`\nuserData: ${JSON.stringify(r.userData)}`),null!=r&&r.parentUserData&&(a+=`\nparentUserData: ${JSON.stringify(r.parentUserData)}`),fe.info(a);let s=Si.cloneMaterial(e.material);s.opacity=n,s.transparent=n<1,i||(s.depthTest=i,s.depthWrite=i,s.side=hr);let o=Mi.cloneGeometryForBatch(e,r),l=new St(o,s);return l.applyMatrix4(e.matrixWorld),l.matrixWorldNeedsUpdate=!0,l.name="Cloned mesh for highlighting",l.layers.enableAll(),l}createInstanceMeshById(e,t,{opacity:n=1,depthTest:i=!0}){let r=e,a=new ht,s=new ht;s.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),r.getMatrixAt(t,a);let o=Si.cloneMaterial(r.material);o.opacity=n,o.transparent=n<1,i||(o.depthTest=i,o.depthWrite=i,o.side=hr);let l=new St(r.geometry.clone(),o);l.applyMatrix4(e.matrixWorld.multiply(a)),l.matrixWorldNeedsUpdate=!0,l.name="Cloned mesh for highlighting",l.layers.enableAll();let h=a.clone();return h.multiplyMatrices(a,s),r.setMatrixAt(t,h),r.instanceMatrix.needsUpdate=!0,r.updateMatrix(),e.userData.originalMatrix=a,l}getObjectTree(){}hasObject(e){return!!this.modelObject.getObjectById(e.id)}hasObjectWithId(e){return!!this.modelObject.getObjectById(e)}},jC=class{constructor(e){this.progresseItems=[],this.element=document.createElement("div"),this.element.classList.add("progress-bar"),e.appendChild(this.element)}setVisible(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.setVisible(!0)}updateProgress(e,t,n){let i=this.progresseItems.find((t=>t.id===e));if(!i)return;let r=t?`${t}`:"";t&&null!=n&&(r+=": "),null!=n&&(n<0||n>100?(console.warn(`[ProgressBar] Invalid progress value: ${n}`),r+="--%"):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.setVisible(!1)}delayRemoveProgressItem(e,t=3e3){setTimeout((()=>{this.removeProgressItem(e)}),t)}},XC=class{constructor(e){var t;this.jobCount=0;let n=document.createElement("div");n.classList.add("gemini-spinner"),n.appendChild(document.createElement("span")),n.appendChild(document.createElement("span")),n.appendChild(document.createElement("span")),n.appendChild(document.createElement("span")),null==(t=e.viewerContainer)||t.appendChild(n),this.element=n,this.setSpinnerVisibility(this.jobCount>0)}setSpinnerVisibility(e){e?this.element.classList.remove("hidden"):this.element.classList.add("hidden")}increaseJobCount(){this.setSpinnerVisibility(++this.jobCount>0)}decreaseJobCount(){this.jobCount<=0?fe.warn("[Viewer] jobCount should be at least 1 here!"):this.setSpinnerVisibility(--this.jobCount>0)}destroy(){this.element.remove(),this.jobCount=0}},YC=class{constructor(e){this.width=0,this.height=0;let t=document.getElementById(e);t||(fe.warn("[Container] containerId:",e,"is not found in dom tree! will append to document body"),t=document.body);let n=document.createElement("div");n.classList.add("gemini-container"),n.style.cssText="width: 100%; height: 100%; position: relative;",t.appendChild(n),this.container=n,this.width=t.clientWidth,this.height=t.clientHeight,this.initViewerContainer(),this.initWidgetContainer()}initViewerContainer(){let e=this.container;if(!e)return;let t=document.createElement("div");t.classList.add("gemini-viewer-container"),t.style.cssText="width: 100%; height: 100%; display: inline-block; position: relative; overflow: hidden;",e.appendChild(t),this.viewerContainer=t}initWidgetContainer(){let e=this.container;if(!e)return;let t=document.createElement("div");t.classList.add("gemini-widget-container"),e.appendChild(t),this.widgetContainer=t}get needResize(){let e=this.width!==this.container.clientWidth||this.height!==this.container.clientHeight;return e&&(this.width=this.container.clientWidth,this.height=this.container.clientHeight),e}destroy(){this.widgetContainer&&(this.widgetContainer.remove(),this.widgetContainer=void 0),this.viewerContainer&&(this.viewerContainer.remove(),this.viewerContainer=void 0),this.container.remove()}},$C=class{constructor(e){var t;this.progressItems=new Map,this.replaceReg=new RegExp(/<em>[\s\S]*<\/em>/,"g");let n=document.createElement("div");n.classList.add("gemini-progress-bar"),null==(t=e.widgetContainer)||t.appendChild(n),this.element=n}addProgressItem(e,t="ProgressBar.Loading",n){this.progressItems.get(e)&&fe.error(`[Viewer] ProgressItem with id ${e} already exists!`);let i=document.createElement("div");i.classList.add("gemini-progress-bar-item"),i.innerHTML=`${rd.t(t)}: <em></em>`,this.element.append(i),this.progressItems.set(e,{div:i,onProgress:n})}removeProgressItem(e){let t=this.progressItems.get(e);null==t||t.div.remove(),this.progressItems.delete(e),0===this.progressItems.size&&this.setVisible(!1)}updateProgressBar(e,t,n=0,i=100){var r;let a=this.progressItems.get(e);if(!a)return;let s=100*(t instanceof ProgressEvent?t.loaded:t)/(t instanceof ProgressEvent?t.total:100)*(i-n)/100+n;a.div.innerHTML=a.div.innerHTML.replace(this.replaceReg,`<em>${s<0||s>100?"--":s.toFixed(2)}%</em>`),null==(r=a.onProgress)||r.call(a,new ProgressEvent("LoadProgress",{loaded:s,total:100}))}setVisible(e){e?this.element.classList.remove("hidden"):this.element.classList.add("hidden")}delayRemoveProgressItem(e,t=3e3){setTimeout((()=>{let t=this.progressItems.get(e);null==t||t.div.remove(),this.progressItems.delete(e)}),t)}destroy(){this.progressItems.forEach((e=>{e.div.remove()})),this.progressItems.clear(),this.element.remove()}},Xm=(e=>(e.BaseViewer="BaseViewer",e.BimViewer="BimViewer",e.DxfViewer="DxfViewer",e.VRViewer="VRViewer",e))(Xm||{}),ar=class extends Ms{constructor(e,t){if(!t.id)throw new Error("[Plugin] Missing plugin id!");super(),this.id=t.id,this.viewer=e,e.addPlugin(this)}destroy(){this.viewer.removePlugin(this)}},Nf=(e=>(e[e.Orbit=0]="Orbit",e[e.FirstPerson=1]="FirstPerson",e[e.Plan=2]="Plan",e[e.VR=3]="VR",e))(Nf||{}),ZC=class{constructor(e){this.mode=0,this.cameraManager=e}setupControl(){let e=this.cameraManager.camera,t=this.cameraManager.cameraControls;t.mouseButtons={left:br.ACTION.ROTATE,middle:br.ACTION.DOLLY,right:br.ACTION.TRUCK,wheel:bo(e)?br.ACTION.DOLLY:Fs(e)?br.ACTION.ZOOM:br.ACTION.NONE},t.touches={one:br.ACTION.TOUCH_ROTATE,two:bo(e)?br.ACTION.TOUCH_DOLLY_TRUCK:Fs(e)?br.ACTION.TOUCH_ZOOM_TRUCK:br.ACTION.NONE,three:br.ACTION.TOUCH_TRUCK},t.dollyToCursor=!0,t.azimuthRotateSpeed=1,t.polarRotateSpeed=1,t.minDistance=1,t.maxDistance=300,t.minZoom=3,this.cameraManager.cameraControls.truckSpeed=2}adjustCameraByBbox(e){let t=this.cameraManager.cameraControls,n=new k;e.getSize(n);let i=n.length();t.minDistance=1,t.maxDistance=10*i,t.minZoom=3}},KC=class{constructor(e){this.mode=2,this.cameraManager=e}setupControl(){let e=this.cameraManager.camera,t=this.cameraManager.cameraControls;t.mouseButtons={left:br.ACTION.TRUCK,middle:br.ACTION.TRUCK,right:br.ACTION.TRUCK,wheel:bo(e)?br.ACTION.DOLLY:Fs(e)?br.ACTION.ZOOM:br.ACTION.NONE},t.touches={one:br.ACTION.TOUCH_TRUCK,two:bo(e)?br.ACTION.TOUCH_DOLLY_TRUCK:Fs(e)?br.ACTION.TOUCH_ZOOM_TRUCK:br.ACTION.NONE,three:br.ACTION.NONE},t.dollyToCursor=!0,t.azimuthRotateSpeed=0,t.polarRotateSpeed=0,t.truckSpeed=1,t.maxZoom=1/0,t.minZoom=-1/0}adjustCameraByBbox(e){}},JC=class{constructor(e){this.mode=1,this.cameraManager=e}setupControl(){let e=this.cameraManager.cameraControls;e.mouseButtons={left:br.ACTION.ROTATE,middle:br.ACTION.NONE,right:br.ACTION.ROTATE,wheel:br.ACTION.ZOOM},e.touches={one:br.ACTION.TOUCH_ROTATE,two:br.ACTION.TOUCH_ZOOM,three:br.ACTION.NONE},e.dollyToCursor=!1,e.infinityDolly=!1,e.azimuthRotateSpeed=-.2,e.polarRotateSpeed=-.2,e.minPolarAngle=.05*Math.PI,e.maxPolarAngle=.95*Math.PI,e.minZoom=.5,e.maxZoom=2,this.cameraManager.enablePan(!1)}adjustCameraByBbox(e){}},Bf=50,M6=new k,QC=class{constructor(e){this.previousDistance=-1,this.previousAzimuthRotateSpeed=1,this.previousPolarRotateSpeed=1,this.previousDollySpeed=1,this.previousTruckSpeed=2,this.previousMouseLeft=br.ACTION.NONE,this.enableKeyDown=!0,this.currentProjection=0,this.onKeyDown=e=>{if(!this.enableKeyDown)return;let t=10*this.viewer.getPixelSizeInWorldCoord();switch(e.code){case"ArrowLeft":"BimViewer"===this.viewer.name?this.cameraControls.rotate(.1,0,!0):"DxfViewer"===this.viewer.name?this.cameraControls.truck(t,0,!0):"VRViewer"===this.viewer.name&&this.cameraControls.rotate(.1,0,!0);break;case"ArrowRight":"BimViewer"===this.viewer.name?this.cameraControls.rotate(-.1,0,!0):"DxfViewer"===this.viewer.name?this.cameraControls.truck(-t,0,!0):"VRViewer"===this.viewer.name&&this.cameraControls.rotate(-.1,0,!0);break;case"ArrowUp":"BimViewer"===this.viewer.name?this.cameraControls.rotate(0,.1,!0):"DxfViewer"===this.viewer.name?this.cameraControls.truck(0,t,!0):"VRViewer"===this.viewer.name&&this.cameraControls.rotate(0,.1,!0);break;case"ArrowDown":"BimViewer"===this.viewer.name?this.cameraControls.rotate(0,-.1,!0):"DxfViewer"===this.viewer.name?this.cameraControls.truck(0,-t,!0):"VRViewer"===this.viewer.name&&this.cameraControls.rotate(0,-.1,!0);break;case"KeyW":"BimViewer"===this.viewer.name&&(Fs(this.activeCamera)?this.cameraControls.zoom(.01,!0):this.cameraControls.dolly(1,!0));break;case"KeyA":"BimViewer"===this.viewer.name&&this.cameraControls.truck(t,0,!0);break;case"KeyS":"BimViewer"===this.viewer.name&&(Fs(this.activeCamera)?this.cameraControls.zoom(-.01,!0):this.cameraControls.dolly(-1,!0));break;case"KeyD":"BimViewer"===this.viewer.name&&this.cameraControls.truck(-t,0,!0);break;case"KeyQ":"BimViewer"===this.viewer.name&&this.cameraControls.truck(0,-t,!0);break;case"KeyE":"BimViewer"===this.viewer.name&&this.cameraControls.truck(0,t,!0)}},this.onChange=()=>{this.viewer.enableRender()},this.viewer=e;let t=e.viewerContainer,n=t.clientWidth/t.clientHeight;this.perspectiveCamera=new Yr(45,n,.1,2e3),this.orthographicCamera=new xi(Bf*n/-2,Bf*n/2,Bf/2,Bf/-2,.1,1e3),this.activeCamera=this.perspectiveCamera,this.setupCameras(),br.install({THREE:Vt}),this.cameraControls=new br(this.perspectiveCamera,e.getInputManager()),this.navMode={0:new ZC(this),2:new KC(this),3:new JC(this)},this.currentNavMode=this.navMode[0],this.setupControls(),this.setProjection(0),this.anchor=this.createAnchor()}get viewerContainer(){return this.viewer.viewerContainer}get inputManager(){return this.viewer.getInputManager()}createAnchor(){var e;let t=document.createElement("div");return t.className="anchor",null==(e=this.viewerContainer)||e.appendChild(t),this.cameraControls.addEventListener("control",(()=>{let e=this.getTarget(),t=Sn.world2Screen(e,this.activeCamera,this.viewerContainer);this.setAnchorPosition(t.x,t.y)})),t}setAnchorPosition(e,t){this.anchor.style.left=`${e}px`,this.anchor.style.top=`${t}px`}setOrbitPointVisible(e){e?this.anchor.classList.add("active"):this.anchor.classList.remove("active")}setOrthoCameraAspect(e,t){let n=e/t;this.orthographicCamera.left=-Bf*n/2,this.orthographicCamera.right=Bf*n/2,this.orthographicCamera.top=Bf/2,this.orthographicCamera.bottom=-Bf/2,this.orthographicCamera.updateProjectionMatrix()}setupCameras(){this.setCameraPositionAndTarget(this.perspectiveCamera)}setCameraPositionAndTarget(e){e.position.z=10,e.position.y=10,e.position.x=10,e.lookAt(new k(0,0,0))}setupControls(){this.cameraControls.smoothTime=.1,this.cameraControls.draggingSmoothTime=0,this.cameraControls.infinityDolly=!0,this.cameraControls.setTarget(0,0,0),this.cameraControls.addEventListener("controlend",(()=>this.onChange)),this.cameraControls.addEventListener("update",(()=>this.viewer.dispatchEvent("ControlChanged"))),this.cameraControls.addEventListener("rest",(()=>this.onChange)),this.inputManager.addEventListener("keydown",this.onKeyDown)}setOrthoCamera(){if(1===this.currentNavMode.mode)return;this.previousDistance=this.cameraControls.distance,this.cameraControls.distance=200;let{width:e,height:t}=this.getDims();this.setupOrthoCamera(t,e),this.activeCamera=this.orthographicCamera,this.currentProjection=1}getDims(){let e=new k;this.perspectiveCamera.getWorldDirection(e);let t=new k;this.cameraControls.getTarget(t);let n=t.clone().sub(this.perspectiveCamera.position).dot(e),{clientWidth:i,clientHeight:r}=this.viewer.viewerContainer,a=i/r,s=this.perspectiveCamera.fov,o=2*n*Math.atan(s*(Math.PI/180)/2);return{width:o*a,height:o}}setupOrthoCamera(e,t){this.cameraControls.mouseButtons.wheel=br.ACTION.ZOOM,this.orthographicCamera.zoom=1,this.orthographicCamera.left=t/-2,this.orthographicCamera.right=t/2,this.orthographicCamera.top=e/2,this.orthographicCamera.bottom=e/-2,this.orthographicCamera.updateProjectionMatrix(),this.orthographicCamera.position.copy(this.perspectiveCamera.position),this.orthographicCamera.quaternion.copy(this.perspectiveCamera.quaternion),this.cameraControls.camera=this.orthographicCamera}setPerspectiveCamera(){this.cameraControls.mouseButtons.wheel=br.ACTION.DOLLY,this.perspectiveCamera.position.copy(this.orthographicCamera.position),this.perspectiveCamera.quaternion.copy(this.orthographicCamera.quaternion),this.perspectiveCamera.updateProjectionMatrix(),this.cameraControls.camera=this.perspectiveCamera,this.cameraControls.mouseButtons.wheel=br.ACTION.DOLLY,this.activeCamera=this.perspectiveCamera,this.currentProjection=0,this.cameraControls.distance=this.previousDistance,this.cameraControls.zoomTo(1)}update(e){return this.cameraControls.update(e)}updateAspect(){let{clientWidth:e,clientHeight:t}=this.viewer.viewerContainer;this.perspectiveCamera.aspect=e/t,this.perspectiveCamera.updateProjectionMatrix(),this.setOrthoCameraAspect(e,t)}get camera(){return this.activeCamera}enableKeyControl(e){this.enableKeyDown=e}getTarget(){return this.cameraControls.getTarget(M6)}getPosition(){return this.cameraControls.getPosition(M6)}adjustCameraByBbox(e){let t=this.camera.near,n=this.camera.far,i=new k;e.getSize(i);let r=i.length(),a=r/5,s=5*r;if(t>a||n<s){let e=e=>Pt.numberToString(e);fe.info(`[Viewer] BBox's longest side is: ${e(r)}`),t>a&&(fe.warn(`[Viewer] camera.near(${e(t)}) shouldn't bigger than ${e(a)}, will change it!`),this.camera.near=a),n<s&&(fe.warn(`[Viewer] camera.far(${e(n)}) shouldn't smaller than ${e(s)}, will change it!`),this.camera.far=s)}this.currentNavMode.adjustCameraByBbox(e),this.cameraControls.update(0)}enableControl(e){this.cameraControls.enabled=e}enableRotate(e){e?(this.cameraControls.azimuthRotateSpeed=this.previousAzimuthRotateSpeed,this.cameraControls.polarRotateSpeed=this.previousPolarRotateSpeed):(this.previousAzimuthRotateSpeed=this.cameraControls.azimuthRotateSpeed,this.previousPolarRotateSpeed=this.cameraControls.polarRotateSpeed,this.cameraControls.azimuthRotateSpeed=0,this.cameraControls.polarRotateSpeed=0)}enableZoom(e){e?this.cameraControls.dollySpeed=this.previousDollySpeed:(this.previousDollySpeed=this.cameraControls.dollySpeed,this.cameraControls.dollySpeed=0)}enablePan(e){e?this.cameraControls.truckSpeed=this.previousTruckSpeed:(this.previousTruckSpeed=this.cameraControls.dollySpeed,this.cameraControls.truckSpeed=0)}enableMouseLeft(e){e?this.cameraControls.mouseButtons.left=this.previousMouseLeft:(this.previousMouseLeft=this.cameraControls.mouseButtons.left,this.cameraControls.mouseButtons.left=br.ACTION.NONE)}setCameraPosition(e){this.cameraControls.setPosition(e.x,e.y,e.z)}setCameraTarget(e){this.cameraControls.setTarget(e.x,e.y,e.z)}flyTo(e,t){this.cameraControls.setLookAt(e.x,e.y,e.z,t.x,t.y,t.z,!0),this.cameraControls.setFocalOffset(0,0,0,!0)}flyToPosition(e,t,n){this.cameraControls.moveTo(e,t,n,!0)}flyToBox(e){let t=new $r;e.getBoundingSphere(t),this.cameraControls.fitToSphere(t,!0)}fitToSphere(e){this.cameraControls.fitToSphere(e,!0)}flyToObject(e){let t=(new Nt).setFromObject(e),n=new $r;t.getBoundingSphere(n),this.cameraControls.fitToSphere(n,!0)}getDistanceToFitSphere(e){return this.cameraControls.getDistanceToFitSphere(e)}setNavigationMode(e){this.currentNavMode.mode!==e&&(this.currentNavMode=this.navMode[e],this.currentNavMode.setupControl())}setProjection(e){this.currentProjection!==e&&(this.currentProjection=e,1===e?this.setOrthoCamera():this.setPerspectiveCamera())}setOrbitPoint(e){this.cameraControls.setOrbitPoint(e.x,e.y,e.z)}getCameraDirection(){return this.activeCamera.getWorldDirection(M6)}getCameraInfo(){return{near:this.activeCamera.near,far:this.activeCamera.far,zoom:this.activeCamera.zoom,eye:this.activeCamera.position.toArray(),up:this.activeCamera.up.toArray(),look:this.getTarget().toArray()}}setCameraInfo(e){let{near:t=.1,far:n=1e5,up:i=[0,1,0],zoom:r=1,eye:a,look:s}=e;this.activeCamera.near=t,this.activeCamera.far=n,this.activeCamera.up.set(i[0],i[1],i[2]),this.activeCamera.updateProjectionMatrix(),this.cameraControls.updateCameraUp(),this.cameraControls.zoomTo(r),this.cameraControls.setLookAt(a[0],a[1],a[2],s[0],s[1],s[2],!0),this.cameraControls.setFocalOffset(0,0,0,!0)}destroy(){this.anchor.remove(),this.inputManager.removeEventListener("keydown",this.onKeyDown),this.perspectiveCamera.removeFromParent(),this.orthographicCamera.removeFromParent()}},j0e=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)&&Si.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)&&Si.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 Ar)s=s.clone();else if(Array.isArray(s)){let e=[];s.forEach((t=>e.push(t.clone()))),s=e}let o=new Os(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 en.geometryEquals(e,t)}},p1=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])}},YE=class extends gm{constructor(e){super(e)}parse(e){if(e.length<19)throw new 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++]};if(function(e){switch(e.image_type){case 1:case 9:if(e.colormap_length>256||24!==e.colormap_size||1!==e.colormap_type)throw new Error("THREE.TGALoader: Invalid type colormap data for indexed type.");break;case 2:case 3:case 10:case 11:if(e.colormap_type)throw new Error("THREE.TGALoader: Invalid type colormap data for colormap type.");break;case 0:throw new Error("THREE.TGALoader: No data.");default:throw new Error("THREE.TGALoader: Invalid type "+e.image_type)}if(e.width<=0||e.height<=0)throw new Error("THREE.TGALoader: Invalid image size.");if(8!==e.pixel_size&&16!==e.pixel_size&&24!==e.pixel_size&&32!==e.pixel_size)throw new Error("THREE.TGALoader: Invalid pixel size "+e.pixel_size)}(i),i.id_length+t>e.length)throw new 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,u,c,d;switch((48&i.flags)>>4){default:case 2:o=0,h=1,c=t,l=0,u=1,d=n;break;case 0:o=0,h=1,c=t,l=n-1,u=-1,d=-1;break;case 3:o=t-1,h=-1,c=-1,l=0,u=1,d=n;break;case 1:o=t-1,h=-1,c=-1,l=n-1,u=-1,d=-1}if(s)switch(i.pixel_size){case 8:!function(e,t,n,r,a,s,o,l){let h,u,c,d=0,p=i.width;for(c=t;c!==r;c+=n)for(u=a;u!==o;u+=s,d++)h=l[d],e[4*(u+p*c)+0]=h,e[4*(u+p*c)+1]=h,e[4*(u+p*c)+2]=h,e[4*(u+p*c)+3]=255}(e,l,u,d,o,h,c,r);break;case 16:!function(e,t,n,r,a,s,o,l){let h,u,c=0,d=i.width;for(u=t;u!==r;u+=n)for(h=a;h!==o;h+=s,c+=2)e[4*(h+d*u)+0]=l[c+0],e[4*(h+d*u)+1]=l[c+0],e[4*(h+d*u)+2]=l[c+0],e[4*(h+d*u)+3]=l[c+1]}(e,l,u,d,o,h,c,r);break;default:throw new Error("THREE.TGALoader: Format not supported.")}else switch(i.pixel_size){case 8:!function(e,t,n,r,a,s,o,l,h){let u,c,d,p=h,f=0,m=i.width;for(d=t;d!==r;d+=n)for(c=a;c!==o;c+=s,f++)u=l[f],e[4*(c+m*d)+3]=255,e[4*(c+m*d)+2]=p[3*u+0],e[4*(c+m*d)+1]=p[3*u+1],e[4*(c+m*d)+0]=p[3*u+2]}(e,l,u,d,o,h,c,r,a);break;case 16:!function(e,t,n,r,a,s,o,l){let h,u,c,d=0,p=i.width;for(c=t;c!==r;c+=n)for(u=a;u!==o;u+=s,d+=2)h=l[d+0]+(l[d+1]<<8),e[4*(u+p*c)+0]=(31744&h)>>7,e[4*(u+p*c)+1]=(992&h)>>2,e[4*(u+p*c)+2]=(31&h)<<3,e[4*(u+p*c)+3]=32768&h?0:255}(e,l,u,d,o,h,c,r);break;case 24:!function(e,t,n,r,a,s,o,l){let h,u,c=0,d=i.width;for(u=t;u!==r;u+=n)for(h=a;h!==o;h+=s,c+=3)e[4*(h+d*u)+3]=255,e[4*(h+d*u)+2]=l[c+0],e[4*(h+d*u)+1]=l[c+1],e[4*(h+d*u)+0]=l[c+2]}(e,l,u,d,o,h,c,r);break;case 32:!function(e,t,n,r,a,s,o,l){let h,u,c=0,d=i.width;for(u=t;u!==r;u+=n)for(h=a;h!==o;h+=s,c+=4)e[4*(h+d*u)+2]=l[c+0],e[4*(h+d*u)+1]=l[c+1],e[4*(h+d*u)+0]=l[c+2],e[4*(h+d*u)+3]=l[c+3]}(e,l,u,d,o,h,c,r);break;default:throw new 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:Ba}}},eP=class extends xr{constructor(e){super(e)}load(e,t,n,i){let r=this,a=""===r.path?na.extractUrlBase(e):r.path,s=new Zr(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 u(e,t){return void 0!==e.build||(e.build=t(e)),e.build}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=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 u(Qe.animations[e],p)}function m(e,t,n){let i,r,a,s,o,l,h=Qe.nodes[e.id],u=Ue(h.id),c=h.transforms[e.sid],d=h.matrix.clone().transpose(),p={};switch(c){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.',c)}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++)b(n,i,t.elements[i]);return n}(p,d);return{name:u.uuid,keyframes:f}}let g=new k,v=new k,y=new _r;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 qa(i+".position",r,a)),s.length>0&&t.push(new Ga(i+".quaternion",r,s)),o.length>0&&t.push(new qa(i+".scale",r,o)),t}function b(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=_(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 _(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 M(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 po(n,i,t)}function E(e){return u(Qe.clips[e],M)}function T(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]=ae(i);break;case"joints":t.joints=A(i);break;case"vertex_weights":t.vertexWeights=C(i)}}return t}function A(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 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)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=Qe.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,u=s.inputs.WEIGHT.offset,c=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+u]];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 ht).fromArray(e.bindShapeMatrix).transpose():r.bindMatrix=(new ht).identity(),t=0,i=c.array.length;t<i;t++){let e=c.array[t],n=(new ht).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 R(e){return u(Qe.controllers[e],P)}function L(e){return void 0!==e.build?e.build:e.init_from}function I(e){let t=Qe.images[e];return void 0!==t?u(t,L):(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":D(i,t);break;case"technique":t.technique=F(i);break;case"extra":t.extra=G(i)}}return t}function D(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]=U(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 U(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 F(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=G(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:H(i)}}}return t}function H(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&&V(i,t)}return t}function V(e,t){for(let n=0,i=e.childNodes.length;n<i;n++){let i=e.childNodes[n];1===i.nodeType&&"technique"===i.nodeName&&j(i,t)}}function j(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 G(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:H(i)})}return t}function Y(e){return e}function q(e){let t,n=function(e){return u(Qe.effects[e],Y)}(e.url),i=n.profile.technique;switch(i.type){case"phong":case"blinn":t=new ta;break;case"lambert":t=new Ru;break;default:t=new cn}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)?qe:Xe,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?Ii:Pi,i.wrapT=e.wrapV?Ii:Pi,i.offset.set(e.offsetU||0,e.offsetV||0),i.repeat.set(e.repeatU||1,e.repeatV||1)}else i.wrapS=Ii,i.wrapT=Ii;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,sn));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,sn));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,sn))}}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?hr:hi;break;case"bump":t.normalMap=r(i.texture),t.normalScale=new _e(1,1)}}}return t}function J(e){return u(Qe.materials[e],q)}function Z(e){for(let t=0;t<e.childNodes.length;t++){let n=e.childNodes[t];if("technique_common"===n.nodeName)return K(n)}return{}}function K(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=$(i)}}return t}function $(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 Q(e){let t;switch(e.optics.technique){case"perspective":t=new Yr(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 xi(-i,i,n,-n,e.optics.parameters.znear,e.optics.parameters.zfar);break;default:t=new Yr}return t.name=e.name||"",t}function ee(e){let t=Qe.cameras[e];return void 0!==t?u(t,Q):(console.warn("THREE.ColladaLoader: Couldn't find camera with ID:",e),null)}function te(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=ne(i)}}return t}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"color":let e=r(i.textContent);t.color=(new ct).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 ie(e){let t;switch(e.technique){case"directional":t=new va;break;case"point":t=new Mc;break;case"spot":t=new Iu;break;case"ambient":t=new mo}return e.parameters.color&&t.color.copy(e.parameters.color),e.parameters.distance&&(t.distance=e.parameters.distance),t}function re(e){let t=Qe.lights[e];return void 0!==t?u(t,ie):(console.warn("THREE.ColladaLoader: Couldn't find light with ID:",e),null)}function ae(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 se(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 oe(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 le(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 he(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];le(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=[],u=[],c=new Ot,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)}c.addGroup(p,g,f),p+=g,i.material&&d.push(i.material);for(let c in m){let d=m[c];switch(c){case"VERTEX":for(let c in n){let p=n[c];switch(c){case"POSITION":let n=r.array.length;if(ce(i,t[p],d.offset,r.array),r.stride=t[p].stride,t.skinWeights&&t.skinIndices&&(ce(i,t.skinIndices,d.offset,h),ce(i,t.skinWeights,d.offset,u)),!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":ce(i,t[p],d.offset,a.array),a.stride=t[p].stride;break;case"COLOR":ce(i,t[p],d.offset,l.array),l.stride=t[p].stride;break;case"TEXCOORD":ce(i,t[p],d.offset,s.array),s.stride=t[p].stride;break;case"TEXCOORD1":ce(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.',c)}}break;case"NORMAL":ce(i,t[d.id],d.offset,a.array),a.stride=t[d.id].stride;break;case"COLOR":ce(i,t[d.id],d.offset,l.array,!0),l.stride=t[d.id].stride;break;case"TEXCOORD":ce(i,t[d.id],d.offset,s.array),s.stride=t[d.id].stride;break;case"TEXCOORD1":ce(i,t[d.id],d.offset,o.array),o.stride=t[d.id].stride}}}return r.array.length>0&&c.setAttribute("position",new Bt(r.array,r.stride)),a.array.length>0&&c.setAttribute("normal",new Bt(a.array,a.stride)),l.array.length>0&&c.setAttribute("color",new Bt(l.array,l.stride)),s.array.length>0&&c.setAttribute("uv",new Bt(s.array,s.stride)),o.array.length>0&&c.setAttribute("uv1",new Bt(o.array,o.stride)),h.length>0&&c.setAttribute("skinIndex",new Bt(h,4)),u.length>0&&c.setAttribute("skinWeight",new Bt(u,4)),i.data=c,i.type=e[0].type,i.materialKeys=d,i}function ce(e,t,n,i,r=!1){let a=e.p,s=e.stride,o=e.vcount;function l(e){let t=a[e+n]*u,s=t+u;for(;t<s;t++)i.push(h[t]);if(r){let e=i.length-u-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,u=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 c=0,d=a.length;c<d;c+=s)l(c)}function de(e){return u(Qe.geometries[e],he)}function pe(e){return void 0!==e.build?e.build:e}function fe(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")]=me(i);break;case"link":t.links.push(ve(i))}}}function me(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=ge(i)}}return t}function ge(e){let t={sid:e.getAttribute("sid"),name:e.getAttribute("name")||"",axis:new k,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 ve(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(ye(i));break;case"matrix":case"translate":case"rotate":t.transforms.push(xe(i))}}return t}function ye(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(ve(i));break;case"matrix":case"translate":case"rotate":t.transforms.push(xe(i))}}return t}function xe(e){let t={type:e.nodeName},n=r(e.textContent);switch(t.type){case"matrix":t.obj=new ht,t.obj.fromArray(n).transpose();break;case"translate":t.obj=new k,t.obj.fromArray(n);break;case"rotate":t.obj=new k,t.obj.fromArray(n),t.angle=Un.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&&we(i,t)}}function we(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 Se(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 Me(e){return void 0!==e.build?e.build:e}function Ee(e){let t=[],n=Ve.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 ht).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 k).fromArray(e),t.push({sid:s.getAttribute("sid"),type:s.nodeName,obj:a});break;case"rotate":e=r(s.textContent),a=(new k).fromArray(e);let i=Un.degToRad(e[3]);t.push({sid:s.getAttribute("sid"),type:s.nodeName,obj:a,angle:i})}}return t}let Te=new ht,Ae=new k;function Ce(e){let t={name:e.getAttribute("name")||"",type:e.getAttribute("type"),id:e.getAttribute("id"),sid:e.getAttribute("sid"),matrix:new ht,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")),Ce(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),Ae.fromArray(i),t.matrix.multiply(Te.makeTranslation(Ae.x,Ae.y,Ae.z)),t.transforms[a.getAttribute("sid")]=a.nodeName;break;case"rotate":i=r(a.textContent);let e=Un.degToRad(i[3]);t.matrix.multiply(Te.makeRotationAxis(Ae.fromArray(i),e)),t.transforms[a.getAttribute("sid")]=a.nodeName;break;case"scale":i=r(a.textContent),t.matrix.scale(Ae.fromArray(i)),t.transforms[a.getAttribute("sid")]=a.nodeName;break;case"extra":break;default:console.log(a)}}return Ne(t.id)?console.warn("THREE.ColladaLoader: There is already a node with ID %s. Exclude current node from further processing.",t.id):Qe.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 Re(e,t){let n,i,r,a=[],s=[];for(n=0;n<e.length;n++){let i,r=e[n];if(Ne(r))i=Ue(r),Le(i,t,a);else if(Be(r)){let e=Qe.visualScenes[r].children;for(let n=0;n<e.length;n++){let i=e[n];"JOINT"===i.type&&Le(Ue(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 Ml(o,l)}function Le(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 ht),n.push({bone:e,boneInverse:i,processed:!1})}}))}function Ie(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,u=e.instanceNodes;for(let c=0,d=r.length;c<d;c++)n.push(Ue(r[c]));for(let c=0,d=s.length;c<d;c++){let e=ee(s[c]);null!==e&&n.push(e.clone())}for(let c=0,d=o.length;c<d;c++){let e=o[c],t=R(e.id),i=De(de(t.id),e.materials),r=Re(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 c=0,d=l.length;c<d;c++){let e=re(l[c]);null!==e&&n.push(e.clone())}for(let c=0,d=h.length;c<d;c++){let e=h[c],t=De(de(e.id),e.materials);for(let i=0,r=t.length;i<r;i++)n.push(t[i])}for(let c=0,d=u.length;c<d;c++)n.push(Ue(u[c]).clone());if(0===r.length&&1===n.length)t=n[0];else{t="JOINT"===a?new Sl:new Bn;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 ke=new cn({name:xr.DEFAULT_MATERIAL_NAME,color:16711935});function Oe(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(ke)):n.push(J(r))}return n}function De(e,t){let n=[];for(let i in e){let r=e[i],a=Oe(r.materialKeys,t);if(0===a.length&&("lines"===i||"linestrips"===i?a.push(new zn):a.push(new ta)),"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 zn;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 zr(r.data,l);break;case"linestrips":s=new Vr(r.data,l);break;case"triangles":case"polylist":s=o?new Tu(r.data,l):new St(r.data,l)}n.push(s)}return n}function Ne(e){return void 0!==Qe.nodes[e]}function Ue(e){return u(Qe.nodes[e],Ie)}function Fe(e){let t=new Bn;t.name=e.name;let n=e.children;for(let i=0;i<n.length;i++){let e=n[i];t.add(Ue(e.id))}return t}function Be(e){return void 0!==Qe.visualScenes[e]}function ze(e){return u(Qe.visualScenes[e],Fe)}if(0===e.length)return{scene:new Ji};let He=(new DOMParser).parseFromString(e,"application/xml"),Ve=n(He,"COLLADA")[0],je=He.getElementsByTagName("parsererror")[0];if(void 0!==je){let e,t=n(je,"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()}(je),console.error("THREE.ColladaLoader: Failed to parse collada file.\n",e),null}let Ge=Ve.getAttribute("version");console.debug("THREE.ColladaLoader: File version",Ge);let We=(Ye=n(Ve,"asset")[0],{unit:function(e){return void 0!==e&&!0===e.hasAttribute("meter")?parseFloat(e.getAttribute("meter")):1}(n(Ye,"unit")[0]),upAxis:function(e){return void 0!==e?e.textContent:"Y_UP"}(n(Ye,"up_axis")[0])}),Xe=new ws(this.manager);var Ye;let qe;Xe.setPath(this.resourcePath||t).setCrossOrigin(this.crossOrigin),YE&&(qe=new YE(this.manager),qe.setPath(this.resourcePath||t));let Je=new ct,Ze=[],Ke={},$e=0,Qe={animations:{},clips:{},controllers:{},images:{},effects:{},materials:{},cameras:{},lights:{},geometries:{},nodes:{},visualScenes:{},kinematicsModels:{},physicsModels:{},kinematicsScenes:{}};l(Ve,"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]=ae(s);break;case"sampler":a=s.getAttribute("id"),n.samplers[a]=c(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&&(Qe.animations[t.getAttribute("id")||Un.generateUUID()]=n)})),l(Ve,"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")))}Qe.clips[e.getAttribute("id")]=t})),l(Ve,"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=T(i);break;case"morph":t.id=s(i.getAttribute("source")),console.warn("THREE.ColladaLoader: Morph target animation not supported yet.")}}Qe.controllers[e.getAttribute("id")]=t})),l(Ve,"library_images","image",(function(e){let t={init_from:n(e,"init_from")[0].textContent};Qe.images[e.getAttribute("id")]=t})),l(Ve,"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))}Qe.effects[e.getAttribute("id")]=t})),l(Ve,"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")))}Qe.materials[e.getAttribute("id")]=t})),l(Ve,"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=Z(i))}Qe.cameras[e.getAttribute("id")]=t})),l(Ve,"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=te(i))}Qe.lights[e.getAttribute("id")]=t})),l(Ve,"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]=ae(n);break;case"vertices":t.vertices=se(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(oe(n));break;default:console.log(n)}}Qe.geometries[e.getAttribute("id")]=t}})),l(Ve,"library_nodes","node",Ce),l(Ve,"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_"+$e++)}}(e);let i=n(e,"node");for(let n=0;n<i.length;n++)t.children.push(Ce(i[n]));Qe.visualScenes[e.getAttribute("id")]=t})),l(Ve,"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&&fe(i,t)}Qe.kinematicsModels[e.getAttribute("id")]=t})),l(Ve,"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")]))}Qe.physicsModels[e.getAttribute("id")]=t})),l(Ve,"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(Se(i))}Qe.kinematicsScenes[s(e.getAttribute("url"))]=t})),h(Qe.animations,p),h(Qe.clips,M),h(Qe.controllers,P),h(Qe.images,L),h(Qe.effects,Y),h(Qe.materials,q),h(Qe.cameras,Q),h(Qe.lights,ie),h(Qe.geometries,he),h(Qe.visualScenes,Fe),function(){let e=Qe.clips;if(!0===o(e)){if(!1===o(Qe.animations)){let e=[];for(let t in Qe.animations){let n=f(t);for(let t=0,i=n.length;t<i;t++)e.push(n[t])}Ze.push(new po("default",-1,e))}}else for(let t in e)Ze.push(E(t))}(),function(){let e=Object.keys(Qe.kinematicsModels)[0],t=Object.keys(Qe.kinematicsScenes)[0],n=Object.keys(Qe.visualScenes)[0];if(void 0===e||void 0===t)return;let i=function(e){return u(Qe.kinematicsModels[e],pe)}(e),r=function(e){return u(Qe.kinematicsScenes[e],Me)}(t),a=ze(n),s=r.bindJointAxis,o={};for(let u=0,c=s.length;u<c;u++){let e=s[u],t=Ve.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 ht;Ke={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,Un.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 et=function(e){return ze(s(n(e,"instance_visual_scene")[0].getAttribute("url")))}(n(Ve,"scene")[0]);return et.animations=Ze,"Z_UP"===We.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."),et.rotation.set(-Math.PI/2,0,0)),et.scale.multiplyScalar(We.unit),{get animations(){return console.warn("THREE.ColladaLoader: Please access animations over scene.animations now."),Ze},kinematics:Ke,library:Qe,scene:et}}},A6=new WeakMap,tP=class extends xr{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 Zr(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,sn).catch(n)}decodeDracoFile(e,t,n,i,r=Ua){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(A6.has(e)){let t=A6.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)})),A6.set(e,{key:n,promise:s}),s}_createGeometry(e){let t=new Ot;e.index&&t.setIndex(new yn(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 yn(a,s);"color"===r&&(this._assignVertexColorSpace(o,i.vertexColorSpace),o.normalized=!(a instanceof Float32Array)),t.setAttribute(r,o)}return t}_assignVertexColorSpace(e,t){if(t!==sn)return;let n=new ct;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 Zr(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=P0t.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 P0t(){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),u=e._malloc(l);t.GetAttributeDataArrayForAllPoints(n,a,h,l,u);let c=new r(e.HEAPF32.buffer,u,o).slice();return e._free(u),{name:i,array:c,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 u={index:null,attributes:[]};for(let c in o){let i,s,h=self[l[c]];if(r.useUniqueIDs)s=o[c],i=t.GetAttributeByUniqueId(a,s);else{if(s=t.GetAttributeId(a,e[o[c]]),-1===s)continue;i=t.GetAttribute(a,s)}let d=n(e,t,a,c,h,i);"color"===c&&(d.vertexColorSpace=r.vertexColorSpace),u.attributes.push(d)}return h===e.TRIANGULAR_MESH&&(u.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),u}(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 X0e=function(e){return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))},I0t=function(e){return new Worker(e)};try{URL.revokeObjectURL(X0e(""))}catch(e){X0e=function(e){return"data:application/javascript;charset=UTF-8,"+encodeURI(e)},I0t=function(e){return new Worker(e,{type:"module"})}}var Xl=Uint8Array,Uf=Uint16Array,P6=Uint32Array,Y0e=new Xl([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]),$0e=new Xl([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]),L0t=new Xl([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Z0e=function(e,t){for(var n=new Uf(31),i=0;i<31;++i)n[i]=t+=1<<e[i-1];var r=new P6(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]},K0e=Z0e(Y0e,2),J0e=K0e[0],D0t=K0e[1];J0e[28]=258,D0t[258]=28;var Q0e=Z0e($0e,0),O0t=Q0e[0],ejt=Q0e[1],I6=new Uf(32768);for(li=0;li<32768;++li)sd=(43690&li)>>>1|(21845&li)<<1,sd=(52428&sd)>>>2|(13107&sd)<<2,sd=(61680&sd)>>>4|(3855&sd)<<4,I6[li]=((65280&sd)>>>8|(255&sd)<<8)>>>1;var sd,li,$E=function(e,t,n){for(var i=e.length,r=0,a=new Uf(t);r<i;++r)++a[e[r]-1];var s,o=new Uf(t);for(r=0;r<t;++r)o[r]=o[r-1]+a[r-1]<<1;if(n){s=new Uf(1<<t);var l=15-t;for(r=0;r<i;++r)if(e[r])for(var h=r<<4|e[r],u=t-e[r],c=o[e[r]-1]++<<u,d=c|(1<<u)-1;c<=d;++c)s[I6[c]>>>l]=h}else for(s=new Uf(i),r=0;r<i;++r)e[r]&&(s[r]=I6[o[e[r]-1]++]>>>15-e[r]);return s},ZE=new Xl(288),li,li,li;for(li=0;li<144;++li)ZE[li]=8;for(li=144;li<256;++li)ZE[li]=9;for(li=256;li<280;++li)ZE[li]=7;for(li=280;li<288;++li)ZE[li]=8;var li,eve=new Xl(32),li;for(li=0;li<32;++li)eve[li]=5;var k0t=$E(ZE,9,1),F0t=$E(eve,5,1),R6=function(e){for(var t=e[0],n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},qc=function(e,t,n){var i=t/8|0;return(e[i]|e[i+1]<<8)>>(7&t)&n},C6=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(7&t)},N0t=function(e){return(e/8|0)+(7&e&&1)},B0t=function(e,t,n){(null==t||t<0)&&(t=0),(null==n||n>e.length)&&(n=e.length);var i=new(e instanceof Uf?Uf:e instanceof P6?P6:Xl)(n-t);return i.set(e.subarray(t,n)),i},U0t=function(e,t,n){var i=e.length;if(!i||n&&!n.l&&i<5)return t||new Xl(0);var r=!t||n,a=!n||n.i;n||(n={}),t||(t=new Xl(3*i));var s=function(e){var n=t.length;if(e>n){var i=new Xl(Math.max(2*n,e));i.set(t),t=i}},o=n.f||0,l=n.p||0,h=n.b||0,u=n.l,c=n.d,d=n.m,p=n.n,f=8*i;do{if(!u){n.f=o=qc(e,l,1);var m=qc(e,l+1,3);if(l+=3,!m){var g=e[(A=N0t(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)u=k0t,c=F0t,d=9,p=5;else{if(2!=m)throw"invalid block type";var y=qc(e,l,31)+257,x=qc(e,l+10,15)+4,b=y+qc(e,l+5,31)+1;l+=14;for(var _=new Xl(b),w=new Xl(19),S=0;S<x;++S)w[L0t[S]]=qc(e,l+3*S,7);l+=3*x;var M=R6(w),E=(1<<M)-1,T=$E(w,M,1);for(S=0;S<b;){var A,C=T[qc(e,l,E)];if(l+=15&C,(A=C>>>4)<16)_[S++]=A;else{var P=0,R=0;for(16==A?(R=3+qc(e,l,3),l+=2,P=_[S-1]):17==A?(R=3+qc(e,l,7),l+=3):18==A&&(R=11+qc(e,l,127),l+=7);R--;)_[S++]=P}}var L=_.subarray(0,y),I=_.subarray(y);d=R6(L),p=R6(I),u=$E(L,d,1),c=$E(I,p,1)}if(l>f){if(a)throw"unexpected EOF";break}}r&&s(h+131072);for(var k=(1<<d)-1,O=(1<<p)-1,D=l;;D=l){var N=(P=u[C6(e,l)&k])>>>4;if((l+=15&P)>f){if(a)throw"unexpected EOF";break}if(!P)throw"invalid length/literal";if(N<256)t[h++]=N;else{if(256==N){D=l,u=null;break}var U=N-254;if(N>264){var F=Y0e[S=N-257];U=qc(e,l,(1<<F)-1)+J0e[S],l+=F}var B=c[C6(e,l)&O],z=B>>>4;if(!B)throw"invalid distance";if(l+=15&B,I=O0t[z],z>3&&(F=$0e[z],I+=C6(e,l)&(1<<F)-1,l+=F),l>f){if(a)throw"unexpected EOF";break}r&&s(h+131072);for(var H=h+U;h<H;h+=4)t[h]=t[h-I],t[h+1]=t[h+1-I],t[h+2]=t[h+2-I],t[h+3]=t[h+3-I];h=H}}n.l=u,n.p=D,n.b=h,u&&(o=1,n.m=d,n.d=c,n.n=p)}while(!o);return h==t.length?t:B0t(t,0,h)},H0t=new Xl(0),V0t=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 tve(e,t){return U0t((V0t(e),e.subarray(2,-4)),t)}var z0t="undefined"!=typeof TextDecoder&&new TextDecoder,G0t=0;try{z0t.decode(H0t,{stream:!0}),G0t=1}catch(e){}function nve(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 W0t(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 rve(e,t,n,i){let r=nve(e,i,t),a=W0t(r,i,e,t),s=new mr(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 j0t(e,t,n,i,r){let a=[];for(let c=0;c<=n;++c)a[c]=0;let s=[];for(let c=0;c<=i;++c)s[c]=a.slice(0);let o=[];for(let c=0;c<=n;++c)o[c]=a.slice(0);o[0][0]=1;let l=a.slice(0),h=a.slice(0);for(let c=1;c<=n;++c){l[c]=t-r[e+1-c],h[c]=r[e+c]-t;let n=0;for(let e=0;e<c;++e){let t=h[e+1],i=l[c-e];o[c][e]=t+i;let r=o[e][c-1]/o[c][e];o[e][c]=n+t*r,n=i*r}o[c][c]=n}for(let c=0;c<=n;++c)s[0][c]=o[c][n];for(let c=0;c<=n;++c){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=c-a,h=n-a;c>=a&&(r[t][0]=r[e][0]/o[h+1][l],i=r[t][0]*o[l][h]);let u=c-1<=h?a-1:n-c;for(let n=l>=-1?1:-l;n<=u;++n)r[t][n]=(r[e][n]-r[e][n-1])/o[h+1][l+n],i+=r[t][n]*o[l+n][h];c<=h&&(r[t][a]=-r[e][a-1]/o[h+1][c],i+=r[t][a]*o[c][h]),s[a][c]=i;let d=e;e=t,t=d}}let u=n;for(let c=1;c<=i;++c){for(let e=0;e<=n;++e)s[c][e]*=u;u*=n-c}return s}function X0t(e,t,n,i,r){let a=r<e?r:e,s=[],o=nve(e,i,t),l=j0t(o,i,e,a,t),h=[];for(let u=0;u<n.length;++u){let e=n[u].clone(),t=e.w;e.x*=t,e.y*=t,e.z*=t,h[u]=e}for(let u=0;u<=a;++u){let t=h[o-e].clone().multiplyScalar(l[u][0]);for(let n=1;n<=e;++n)t.add(h[o-e+n].clone().multiplyScalar(l[u][n]));s[u]=t}for(let u=a+1;u<=r+1;++u)s[u]=new mr(0,0,0);return s}function Y0t(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 $0t(e){let t=e.length,n=[],i=[];for(let a=0;a<t;++a){let t=e[a];n[a]=new k(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(Y0t(a,t)*i[t]));r[a]=e.divideScalar(i[0])}return r}function ive(e,t,n,i,r){return $0t(X0t(e,t,n,i,r))}var nP=class extends Ha{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 mr(e.x,e.y,e.z,e.w)}}getPoint(e,t=new k){let n=t,i=this.knots[this.startKnot]+e*(this.knots[this.endKnot]-this.knots[this.startKnot]),r=rve(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 k){let n=t,i=this.knots[0]+e*(this.knots[this.knots.length-1]-this.knots[0]),r=ive(this.degree,this.knots,this.controlPoints,i,1);return n.copy(r[1]).normalize(),n}},Rr,ys,_o,iP=class extends xr{constructor(e){super(e)}load(e,t,n,i){let r=this,a=""===r.path?na.extractUrlBase(e):r.path,s=new Zr(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(K0t(e))Rr=(new B6).parse(e);else{let t=cve(e);if(!J0t(t))throw new Error("THREE.FBXLoader: Unknown format.");if(sve(t)<7e3)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+sve(t));Rr=(new N6).parse(t)}let n=new ws(this.manager).setPath(this.resourcePath||t).setCrossOrigin(this.crossOrigin);return new O6(n,this.manager).parse(Rr)}},O6=class{constructor(e,t){this.textureLoader=e,this.manager=t}parse(){ys=this.parseConnections();let e=this.parseImages(),t=this.parseTextures(e),n=this.parseMaterials(t),i=this.parseDeformers(),r=(new k6).parse(i);return this.parseScene(i,r,n),_o}parseConnections(){let e=new Map;return"Connections"in Rr&&Rr.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 Rr.Objects){let n=Rr.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 Rr.Objects){let n=Rr.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?Ii:Pi,n.wrapT=0===s?Ii:Pi,"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=ys.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 Hr):(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 Hr):a=this.textureLoader.load(n);return this.textureLoader.setPath(i),a}parseMaterials(e){let t=new Map;if("Material"in Rr.Objects){let n=Rr.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),!ys.has(n))return null;let a,s=this.parseParameters(e,t,n);switch(r.toLowerCase()){case"phong":a=new ta;break;case"lambert":a=new Ru;break;default:console.warn('THREE.FBXLoader: unknown material type "%s". Defaulting to MeshPhongMaterial.',r),a=new ta}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 ct).fromArray(e.Diffuse.value).convertSRGBToLinear():e.DiffuseColor&&("Color"===e.DiffuseColor.type||"ColorRGB"===e.DiffuseColor.type)&&(i.color=(new ct).fromArray(e.DiffuseColor.value).convertSRGBToLinear()),e.DisplacementFactor&&(i.displacementScale=e.DisplacementFactor.value),e.Emissive?i.emissive=(new ct).fromArray(e.Emissive.value).convertSRGBToLinear():e.EmissiveColor&&("Color"===e.EmissiveColor.type||"ColorRGB"===e.EmissiveColor.type)&&(i.emissive=(new ct).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 ct).fromArray(e.Specular.value).convertSRGBToLinear():e.SpecularColor&&"Color"===e.SpecularColor.type&&(i.specular=(new ct).fromArray(e.SpecularColor.value).convertSRGBToLinear());let r=this;return ys.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=sn);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=sn);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=om,i.envMap.colorSpace=sn);break;case"SpecularColor":i.specularMap=r.getTexture(t,e.ID),void 0!==i.specularMap&&(i.specularMap.colorSpace=sn);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 Rr.Objects&&t in Rr.Objects.LayeredTexture&&(console.warn("THREE.FBXLoader: layered textures are not supported in three.js. Discarding all but first layer."),t=ys.get(t).children[0].ID),e.get(t)}parseDeformers(){let e={},t={};if("Deformer"in Rr.Objects){let n=Rr.Objects.Deformer;for(let i in n){let r=n[i],a=ys.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 ht).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=ys.get(parseInt(r.ID)).children.filter((function(e){return void 0===e.relationship}))[0].ID,n.push(s)}return n}parseScene(e,t,n){_o=new Bn;let i=this.parseModels(e.skeletons,t,n),r=Rr.Objects.Model,a=this;i.forEach((function(e){let t=r[e.ID];a.setLookAtProperties(e,t),ys.get(e.ID).parents.forEach((function(t){let n=i.get(t.ID);void 0!==n&&n.add(e)})),null===e.parent&&_o.add(e)})),this.bindSkeleton(e.skeletons,t,i),this.createAmbientLight(),_o.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=ove(e.userData.transformData);e.applyMatrix4(t),e.updateWorldMatrix()}}));let s=(new F6).parse();1===_o.children.length&&_o.children[0].isGroup&&(_o.children[0].animations=s,_o=_o.children[0]),_o.animations=s}parseModels(e,t,n){let i=new Map,r=Rr.Objects.Model;for(let a in r){let s=parseInt(a),o=r[a],l=ys.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 Sl;break;default:h=new Bn}h.name=o.attrName?Jn.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 Sl,r.matrixWorld.copy(t.transformLink),r.name=i?Jn.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=Rr.Objects.NodeAttribute[e.ID];void 0!==t&&(n=t)})),void 0===n)t=new an;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 Yr(l,o,i,r),null!==h&&t.setFocalLength(h);break;case 1:t=new xi(-a/2,a/2,s/2,-s/2,i,r);break;default:console.warn("THREE.FBXLoader: Unknown camera type "+e+"."),t=new an}}return t}createLight(e){let t,n;if(e.children.forEach((function(e){let t=Rr.Objects.NodeAttribute[e.ID];void 0!==t&&(n=t)})),void 0===n)t=new an;else{let e;e=void 0===n.LightType?0:n.LightType.value;let i=16777215;void 0!==n.Color&&(i=(new ct).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 Mc(i,r,a,s);break;case 1:t=new va(i,r);break;case 2:let e=Math.PI/3;void 0!==n.InnerAngle&&(e=Un.degToRad(n.InnerAngle.value));let o=0;void 0!==n.OuterAngle&&(o=Un.degToRad(n.OuterAngle.value),o=Math.max(o,1)),t=new Iu(i,r,a,e,o,s);break;default:console.warn("THREE.FBXLoader: Unknown light type "+n.LightType.value+", defaulting to a PointLight."),t=new Mc(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 ta({name:xr.DEFAULT_MATERIAL_NAME,color:13421772}),s.push(a)),"color"in r.attributes&&s.forEach((function(e){e.vertexColors=!0})),r.FBX_Deformer?(i=new Tu(r,a),i.normalizeSkinWeights()):i=new St(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 zn({name:xr.DEFAULT_MATERIAL_NAME,color:3342591,linewidth:1});return new Vr(n,i)}getTransformData(e,t){let n={};"InheritType"in t&&(n.inheritType=parseInt(t.InheritType.value)),n.eulerOrder="RotationOrder"in t?lve(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&&ys.get(e.ID).children.forEach((function(t){if("LookAtProperty"===t.relationship){let n=Rr.Objects.Model[t.ID];if("Lcl_Translation"in n){let t=n.Lcl_Translation.value;void 0!==e.target?(e.target.position.fromArray(t),_o.add(e.target)):e.lookAt((new k).fromArray(t))}}}))}bindSkeleton(e,t,n){let i=this.parsePoseNodes();for(let r in e){let a=e[r];ys.get(parseInt(a.ID)).parents.forEach((function(e){if(t.has(e.ID)){let t=e.ID;ys.get(t).parents.forEach((function(e){n.has(e.ID)&&n.get(e.ID).bind(new Ml(a.bones),i[e.ID])}))}}))}}parsePoseNodes(){let e={};if("Pose"in Rr.Objects){let t=Rr.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 ht).fromArray(t.Matrix.a)})):e[i.Node]=(new ht).fromArray(i.Matrix.a)}}return e}createAmbientLight(){if("GlobalSettings"in Rr&&"AmbientColor"in Rr.GlobalSettings){let e=Rr.GlobalSettings.AmbientColor.value,t=e[0],n=e[1],i=e[2];if(0!==t||0!==n||0!==i){let e=new ct(t,n,i).convertSRGBToLinear();_o.add(new mo(e,1))}}}},k6=class{constructor(){this.negativeMaterialIndices=!1}parse(e){let t=new Map;if("Geometry"in Rr.Objects){let n=Rr.Objects.Geometry;for(let i in n){let r=ys.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 Rr.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=lve(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=ove(l);return this.genGeometry(t,s,r,h)}genGeometry(e,t,n,i){let r=new Ot;e.attrName&&(r.name=e.attrName);let a=this.parseGeoNode(e,t),s=this.genBuffers(a),o=new Bt(s.vertex,3);if(o.applyMatrix4(i),r.setAttribute("position",o),s.colors.length>0&&r.setAttribute("color",new Bt(s.colors,3)),t&&(r.setAttribute("skinIndex",new lm(s.weightsIndices,4)),r.setAttribute("skinWeight",new Bt(s.vertexWeights,4)),r.FBX_Deformer=t),s.normal.length>0){let e=(new In).getNormalMatrix(i),t=new Bt(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 Bt(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=[],u=[],c=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=rP(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]),u.push(g[e])}if(e.normal){let t=rP(p,n,d,e.normal);s.push(t[0],t[1],t[2])}e.material&&"AllSame"!==e.material.mappingType&&(f=rP(p,n,d,e.material)[0],f<0&&(c.negativeMaterialIndices=!0,f=0)),e.uv&&e.uv.forEach((function(e,t){let i=rP(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."),c.genFace(t,e,a,f,s,o,l,h,u,i),n++,i=0,a=[],s=[],o=[],l=[],h=[],u=[])})),t}genFace(e,t,n,i,r,a,s,o,l,h){for(let u=2;u<h;u++)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*(u-1)]]),e.vertex.push(t.vertexPositions[n[3*(u-1)+1]]),e.vertex.push(t.vertexPositions[n[3*(u-1)+2]]),e.vertex.push(t.vertexPositions[n[3*u]]),e.vertex.push(t.vertexPositions[n[3*u+1]]),e.vertex.push(t.vertexPositions[n[3*u+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*(u-1)]),e.vertexWeights.push(o[4*(u-1)+1]),e.vertexWeights.push(o[4*(u-1)+2]),e.vertexWeights.push(o[4*(u-1)+3]),e.vertexWeights.push(o[4*u]),e.vertexWeights.push(o[4*u+1]),e.vertexWeights.push(o[4*u+2]),e.vertexWeights.push(o[4*u+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*(u-1)]),e.weightsIndices.push(l[4*(u-1)+1]),e.weightsIndices.push(l[4*(u-1)+2]),e.weightsIndices.push(l[4*(u-1)+3]),e.weightsIndices.push(l[4*u]),e.weightsIndices.push(l[4*u+1]),e.weightsIndices.push(l[4*u+2]),e.weightsIndices.push(l[4*u+3])),t.color&&(e.colors.push(a[0]),e.colors.push(a[1]),e.colors.push(a[2]),e.colors.push(a[3*(u-1)]),e.colors.push(a[3*(u-1)+1]),e.colors.push(a[3*(u-1)+2]),e.colors.push(a[3*u]),e.colors.push(a[3*u+1]),e.colors.push(a[3*u+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*(u-1)]),e.normal.push(r[3*(u-1)+1]),e.normal.push(r[3*(u-1)+2]),e.normal.push(r[3*u]),e.normal.push(r[3*u+1]),e.normal.push(r[3*u+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*(u-1)]),e.uvs[n].push(s[n][2*(u-1)+1]),e.uvs[n].push(s[n][2*u]),e.uvs[n].push(s[n][2*u+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=Rr.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 u={vertexIndices:a,vertexPositions:h},c=this.genBuffers(u),d=new Bt(c.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 ct;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 Ot;let n,i,r=t-1,a=e.KnotVector.a,s=[],o=e.Points.a;for(let h=0,u=o.length;h<u;h+=4)s.push((new mr).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 nP(r,a,s,n,i).getPoints(12*s.length);return(new Ot).setFromPoints(l)}},F6=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===Rr.Objects.AnimationCurve)return;let e=this.parseAnimationCurveNodes();this.parseAnimationCurves(e);let t=this.parseAnimationLayers(e);return this.parseAnimStacks(t)}parseAnimationCurveNodes(){let e=Rr.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=Rr.Objects.AnimationCurve;for(let n in t){let i={id:t[n].id,times:t[n].KeyTime.a.map(Q0t),values:t[n].KeyValueFloat.a},r=ys.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=Rr.Objects.AnimationLayer,n=new Map;for(let i in t){let t=[],r=ys.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=ys.get(n.ID).parents.filter((function(e){return void 0!==e.relationship}))[0].ID;if(void 0!==e){let r=Rr.Objects.Model[e.toString()];if(void 0===r)return void console.warn("THREE.FBXLoader: Encountered a unused curve.",n);let a={modelName:r.attrName?Jn.sanitizeNodeName(r.attrName):"",ID:r.id,initialPosition:[0,0,0],initialRotation:[0,0,0],initialScale:[1,1,1]};_o.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 ht),"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=ys.get(n.ID).parents.filter((function(e){return void 0!==e.relationship}))[0].ID,r=ys.get(e).parents[0].ID,a=ys.get(r).parents[0].ID,s=ys.get(a).parents[0].ID,o=Rr.Objects.Model[s],l={modelName:o.attrName?Jn.sanitizeNodeName(o.attrName):"",morphName:Rr.Objects.Deformer[e].attrName};t[i]=l}t[i][r.attr]=r}}})),n.set(parseInt(i),t))}return n}parseAnimStacks(e){let t=Rr.Objects.AnimationStack,n={};for(let i in t){let r=ys.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 po(e.name,-1,t)}generateTracks(e){let t=[],n=new k,i=new _r,r=new k;if(e.transform&&e.transform.decompose(n,i,r),n=n.toArray(),i=(new Xn).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 qa(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(Un.degToRad)),void 0!==t.y&&(this.interpolateRotations(t.y),t.y.values=t.y.values.map(Un.degToRad)),void 0!==t.z&&(this.interpolateRotations(t.z),t.z.values=t.z.values.map(Un.degToRad));let s=this.getTimesForAllAxes(t),o=this.getKeyframeTrackValues(s,t,n);void 0!==i&&((i=i.map(Un.degToRad)).push(a),i=(new Xn).fromArray(i),i=(new _r).setFromEuler(i)),void 0!==r&&((r=r.map(Un.degToRad)).push(a),r=(new Xn).fromArray(r),r=(new _r).setFromEuler(r).invert());let l=new _r,h=new Xn,u=[];for(let c=0;c<o.length;c+=3)h.set(o[c],o[c+1],o[c+2],a),l.setFromEuler(h),void 0!==i&&l.premultiply(i),void 0!==r&&l.multiply(r),l.toArray(u,c/3*4);return new Ga(e+".quaternion",s,u)}generateMorphTrack(e){let t=e.DeformPercent.curves.morph,n=t.values.map((function(e){return e/100})),i=_o.getObjectByName(e.modelName).morphTargetDictionary[e.morphName];return new Rl(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,u=l+h,c=[],d=[];for(;u<e.times[t];)c.push(u),u+=h,d.push(o),o+=s;e.times=ave(e.times,t,c),e.values=ave(e.values,t,d)}}}},N6=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 aP,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],tvt(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=D6(r))}else this.parseNodeSpecialProperty(e,i,r)}parseNodePropertyContinued(e){let t=this.getCurrentNode();t.a+=e,","!==e.slice(-1)&&(t.a=D6(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=D6(l)}this.getPrevNode()[r]={type:a,type2:s,flag:o,value:l},this.setCurrentProp(this.getPrevNode(),r)}},B6=class{parse(e){let t=new sP(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 aP;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 c=0;c<r;c++)o.push(this.parseProperty(e));let l=o.length>0?o[0]:"",h=o.length>1?o[1]:"",u=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),""!==u&&(n.attrType=u),""!==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=tve(new Uint8Array(e.getArrayBuffer(a))),o=new sP(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)}}},sP=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)}},aP=class{add(e,t){this[e]=t}};function K0t(e){return e.byteLength>=21&&"Kaydara FBX Binary \0"===cve(e,0,21)}function J0t(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 sve(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 Q0t(e){return e/46186158e3}var evt=[];function rP(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 nvt(evt,i.buffer,a,s)}var L6=new Xn,m1=new k;function ove(e){let t=new ht,n=new ht,i=new ht,r=new ht,a=new ht,s=new ht,o=new ht,l=new ht,h=new ht,u=new ht,c=new ht,d=new ht,p=e.inheritType?e.inheritType:0;if(e.translation&&t.setPosition(m1.fromArray(e.translation)),e.preRotation){let t=e.preRotation.map(Un.degToRad);t.push(e.eulerOrder||Xn.DEFAULT_ORDER),n.makeRotationFromEuler(L6.fromArray(t))}if(e.rotation){let t=e.rotation.map(Un.degToRad);t.push(e.eulerOrder||Xn.DEFAULT_ORDER),i.makeRotationFromEuler(L6.fromArray(t))}if(e.postRotation){let t=e.postRotation.map(Un.degToRad);t.push(e.eulerOrder||Xn.DEFAULT_ORDER),r.makeRotationFromEuler(L6.fromArray(t)),r.invert()}e.scale&&a.scale(m1.fromArray(e.scale)),e.scalingOffset&&o.setPosition(m1.fromArray(e.scalingOffset)),e.scalingPivot&&s.setPosition(m1.fromArray(e.scalingPivot)),e.rotationOffset&&l.setPosition(m1.fromArray(e.rotationOffset)),e.rotationPivot&&h.setPosition(m1.fromArray(e.rotationPivot)),e.parentMatrixWorld&&(c.copy(e.parentMatrix),u.copy(e.parentMatrixWorld));let f=n.clone().multiply(i).multiply(r),m=new ht;m.extractRotation(u);let g=new ht;g.copyPosition(u);let v=g.clone().invert().multiply(u),y=m.clone().invert().multiply(v),x=a,b=new ht;if(0===p)b.copy(m).multiply(f).multiply(y).multiply(x);else if(1===p)b.copy(m).multiply(y).multiply(f).multiply(x);else{let e=(new ht).scale((new k).setFromMatrixScale(c)).clone().invert(),t=y.clone().multiply(e);b.copy(m).multiply(f).multiply(t).multiply(x)}let _=h.clone().invert(),w=s.clone().invert(),S=t.clone().multiply(l).multiply(h).multiply(n).multiply(i).multiply(r).multiply(_).multiply(o).multiply(s).multiply(a).multiply(w),M=(new ht).copyPosition(S),E=u.clone().multiply(M);return d.copyPosition(E),S=d.clone().multiply(b),S.premultiply(u.invert()),S}function lve(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 D6(e){return e.split(",").map((function(e){return parseFloat(e)}))}function cve(e,t,n){return void 0===t&&(t=0),void 0===n&&(n=e.byteLength),(new TextDecoder).decode(new Uint8Array(e,t,n))}function tvt(e,t){for(let n=0,i=e.length,r=t.length;n<r;n++,i++)e[i]=t[n]}function nvt(e,t,n,i){for(let r=n,a=0;r<i;r++,a++)e[a]=t[r];return e}function ave(e,t,n){return e.slice(0,t).concat(n).concat(e.slice(t))}var oP=class extends xr{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register((function(e){return new W6(e)})),this.register((function(e){return new Q6(e)})),this.register((function(e){return new e4(e)})),this.register((function(e){return new t4(e)})),this.register((function(e){return new X6(e)})),this.register((function(e){return new Y6(e)})),this.register((function(e){return new $6(e)})),this.register((function(e){return new Z6(e)})),this.register((function(e){return new q6(e)})),this.register((function(e){return new K6(e)})),this.register((function(e){return new j6(e)})),this.register((function(e){return new J6(e)})),this.register((function(e){return new z6(e)})),this.register((function(e){return new n4(e)})),this.register((function(e){return new r4(e)}))}load(e,t,n,i){let r,a=this;r=""!==this.resourcePath?this.resourcePath:""!==this.path?this.path:na.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 Zr(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))===pve){try{a[qr.KHR_BINARY_GLTF]=new i4(e)}catch(e){return void(i&&i(e))}r=JSON.parse(a[qr.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 h4(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 qr.KHR_MATERIALS_UNLIT:a[e]=new G6;break;case qr.KHR_DRACO_MESH_COMPRESSION:a[e]=new s4(r,this.dracoLoader);break;case qr.KHR_TEXTURE_TRANSFORM:a[e]=new a4;break;case qr.KHR_MESH_QUANTIZATION:a[e]=new o4;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 rvt(){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 qr={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_ANISOTROPY:"KHR_materials_anisotropy",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"},z6=class{constructor(e){this.parser=e,this.name=qr.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 ct(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 va(o),r.target.position.set(0,0,-1),r.add(r.target);break;case"point":r=new Mc(o),r.distance=l;break;case"spot":r=new Iu(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,Vf(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)}))}},G6=class{constructor(){this.name=qr.KHR_MATERIALS_UNLIT}getMaterialType(){return cn}extendParams(e,t,n){let i=[];e.color=new ct(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,sn))}return Promise.all(i)}},q6=class{constructor(e){this.parser=e,this.name=qr.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()}},W6=class{constructor(e){this.parser=e,this.name=qr.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){let t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Go: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 _e(e,e)}return Promise.all(r)}},j6=class{constructor(e){this.parser=e,this.name=qr.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){let t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Go: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)}},X6=class{constructor(e){this.parser=e,this.name=qr.KHR_MATERIALS_SHEEN}getMaterialType(e){let t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Go: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 ct(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,sn)),void 0!==a.sheenRoughnessTexture&&r.push(n.assignTexture(t,"sheenRoughnessMap",a.sheenRoughnessTexture)),Promise.all(r)}},Y6=class{constructor(e){this.parser=e,this.name=qr.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){let t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Go: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)}},$6=class{constructor(e){this.parser=e,this.name=qr.KHR_MATERIALS_VOLUME}getMaterialType(e){let t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Go: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 ct(s[0],s[1],s[2]),Promise.all(r)}},Z6=class{constructor(e){this.parser=e,this.name=qr.KHR_MATERIALS_IOR}getMaterialType(e){let t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Go: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()}},K6=class{constructor(e){this.parser=e,this.name=qr.KHR_MATERIALS_SPECULAR}getMaterialType(e){let t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Go: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 ct(s[0],s[1],s[2]),void 0!==a.specularColorTexture&&r.push(n.assignTexture(t,"specularColorMap",a.specularColorTexture,sn)),Promise.all(r)}},J6=class{constructor(e){this.parser=e,this.name=qr.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){let t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Go: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.anisotropyStrength&&(t.anisotropy=a.anisotropyStrength),void 0!==a.anisotropyRotation&&(t.anisotropyRotation=a.anisotropyRotation),void 0!==a.anisotropyTexture&&r.push(n.assignTexture(t,"anisotropyMap",a.anisotropyTexture)),Promise.all(r)}},Q6=class{constructor(e){this.parser=e,this.name=qr.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)}},e4=class{constructor(e){this.parser=e,this.name=qr.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}},t4=class{constructor(e){this.parser=e,this.name=qr.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}},n4=class{constructor(e){this.name=qr.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}},r4=class{constructor(e){this.name=qr.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!==Yl.TRIANGLES&&o.mode!==Yl.TRIANGLE_STRIP&&o.mode!==Yl.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 ht,t=new k,n=new _r,o=new k(1,1,1),l=new Os(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]);an.prototype.copy.call(l,a),this.parser.assignFinalMaterial(l),r.push(l)}return t.isGroup?(t.clear(),t.add(...r),t):r[0]})))}},pve="glTF",KE=12,uve={JSON:1313821514,BIN:5130562},i4=class{constructor(e){this.name=qr.KHR_BINARY_GLTF,this.content=null,this.body=null;let t=new DataView(e,0,KE),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!==pve)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-KE,r=new DataView(e,KE),a=0;for(;a<i;){let t=r.getUint32(a,!0);a+=4;let i=r.getUint32(a,!0);if(a+=4,i===uve.JSON){let i=new Uint8Array(e,KE+a,t);this.content=n.decode(i)}else if(i===uve.BIN){let n=KE+a;this.body=e.slice(n,n+t)}a+=t}if(null===this.content)throw new Error("THREE.GLTFLoader: JSON content not found.")}},s4=class{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=qr.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=c4[h]||h.toLowerCase();s[e]=a[h]}for(let h in e.attributes){let t=c4[h]||h.toLowerCase();if(void 0!==a[h]){let i=n.accessors[e.attributes[h]],r=g1[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)}))}))}},a4=class{constructor(){this.name=qr.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}},o4=class{constructor(){this.name=qr.KHR_MESH_QUANTIZATION}},lP=class extends qh{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,u=(n-t)/h,c=u*u,d=c*u,p=e*l,f=p-l,m=-2*d+3*c,g=d-c,v=1-m,y=g-c+u;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}},ivt=new _r,l4=class extends lP{interpolate_(e,t,n,i){let r=super.interpolate_(e,t,n,i);return ivt.fromArray(r).normalize().toArray(r),r}},Yl={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},g1={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},hve={9728:Jr,9729:Xr,9984:Kd,9985:bm,9986:Oh,9987:Ba},dve={33071:Pi,33648:Fh,10497:Ii},U6={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},c4={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"},Hf={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},svt={CUBICSPLINE:void 0,LINEAR:Eu,STEP:Bh},H6={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function avt(e){return void 0===e.DefaultMaterial&&(e.DefaultMaterial=new za({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:hi})),e.DefaultMaterial}function Ym(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 Vf(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 ovt(e,t,n){let i=!1,r=!1,a=!1;for(let h=0,u=t.length;h<u;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,u=t.length;h<u;h++){let u=t[h];if(i){let t=void 0!==u.POSITION?n.getDependency("accessor",u.POSITION):e.attributes.position;s.push(t)}if(r){let t=void 0!==u.NORMAL?n.getDependency("accessor",u.NORMAL):e.attributes.normal;o.push(t)}if(a){let t=void 0!==u.COLOR_0?n.getDependency("accessor",u.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 lvt(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 cvt(e){let t,n=e.extensions&&e.extensions[qr.KHR_DRACO_MESH_COMPRESSION];if(t=n?"draco:"+n.bufferView+":"+n.indices+":"+V6(n.attributes):e.indices+":"+V6(e.attributes)+":"+e.mode,void 0!==e.targets)for(let i=0,r=e.targets.length;i<r;i++)t+=":"+V6(e.targets[i]);return t}function V6(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 u4(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 uvt(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 hvt=new ht,h4=class{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new rvt,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 ws(this.options.manager):this.textureLoader=new fb(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new Zr(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:{}};Ym(r,a,i),Vf(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[qr.KHR_BINARY_GLTF].body);let i=this.options;return new Promise((function(e,r){n.load(na.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=U6[i.type],t=g1[i.componentType],n=!0===i.normalized,r=new t(i.count*e);return Promise.resolve(new yn(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=U6[i.type],l=g1[i.componentType],h=l.BYTES_PER_ELEMENT,u=h*o,c=i.byteOffset||0,d=void 0!==i.bufferView?n.bufferViews[i.bufferView].byteStride:void 0,p=!0===i.normalized;if(d&&d!==u){let e=Math.floor(c/d),n="InterleavedBuffer:"+i.bufferView+":"+i.componentType+":"+e+":"+i.count,u=t.cache.get(n);u||(r=new l(s,e*d,i.count*d/h),u=new Vh(r,d/h),t.cache.add(n,u)),a=new fo(u,o,c%d/h,p)}else r=null===s?new l(i.count*o):new l(s,c,i.count*o),a=new yn(r,o,p);if(void 0!==i.sparse){let t=U6.SCALAR,n=g1[i.sparse.indices.componentType],r=i.sparse.indices.byteOffset||0,h=i.sparse.values.byteOffset||0,u=new n(e[1],r,i.sparse.count*t),c=new l(e[2],h,i.sparse.count*o);null!==s&&(a=new yn(a.array.slice(),a.itemSize,a.normalized));for(let e=0,i=u.length;e<i;e++){let t=u[e];if(a.setX(t,c[e*o]),o>=2&&a.setY(t,c[e*o+1]),o>=3&&a.setZ(t,c[e*o+2]),o>=4&&a.setW(t,c[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=hve[n.magFilter]||Xr,t.minFilter=hve[n.minFilter]||Ba,t.wrapS=dve[n.wrapS]||Ii,t.wrapT=dve[n.wrapT]||Ii,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 Hr(e);t.needsUpdate=!0,n(t)}),t.load(na.resolveURL(e,i.path),a,void 0,r)}))})).then((function(e){return!0===o&&a.revokeObjectURL(s),e.userData.mimeType=r.mimeType||uvt(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[qr.KHR_TEXTURE_TRANSFORM]){let e=void 0!==n.extensions?n.extensions[qr.KHR_TEXTURE_TRANSFORM]:void 0;if(e){let t=r.associations.get(a);a=r.extensions[qr.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 Li,Ar.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 zn,Ar.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 za}loadMaterial(e){let t,n=this,i=this.json,r=this.extensions,a=i.materials[e],s={},o=[];if((a.extensions||{})[qr.KHR_MATERIALS_UNLIT]){let e=r[qr.KHR_MATERIALS_UNLIT];t=e.getMaterialType(),o.push(e.extendParams(s,a,n))}else{let i=a.pbrMetallicRoughness||{};if(s.color=new ct(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,sn)),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=hr);let l=a.alphaMode||H6.OPAQUE;if(l===H6.BLEND?(s.transparent=!0,s.depthWrite=!1):(s.transparent=!1,l===H6.MASK&&(s.alphaTest=void 0!==a.alphaCutoff?a.alphaCutoff:.5)),void 0!==a.normalTexture&&t!==cn&&(o.push(n.assignTexture(s,"normalMap",a.normalTexture)),s.normalScale=new _e(1,1),void 0!==a.normalTexture.scale)){let e=a.normalTexture.scale;s.normalScale.set(e,e)}return void 0!==a.occlusionTexture&&t!==cn&&(o.push(n.assignTexture(s,"aoMap",a.occlusionTexture)),void 0!==a.occlusionTexture.strength&&(s.aoMapIntensity=a.occlusionTexture.strength)),void 0!==a.emissiveFactor&&t!==cn&&(s.emissive=(new ct).fromArray(a.emissiveFactor)),void 0!==a.emissiveTexture&&t!==cn&&o.push(n.assignTexture(s,"emissiveMap",a.emissiveTexture,sn)),Promise.all(o).then((function(){let i=new t(s);return a.name&&(i.name=a.name),Vf(i,a),n.associations.set(i,{materials:e}),a.extensions&&Ym(r,i,a),i}))}createUniqueName(e){let t=Jn.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){let t=this,n=this.extensions,i=this.primitiveCache;function r(e){return n[qr.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then((function(n){return fve(n,e,t)}))}let a=[];for(let s=0,o=e.length;s<o;s++){let n=e[s],o=cvt(n),l=i[o];if(l)a.push(l.promise);else{let e;e=n.extensions&&n.extensions[qr.KHR_DRACO_MESH_COMPRESSION]?r(n):fve(new Ot,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?avt(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 u=0,c=o.length;u<c;u++){let n,h=o[u],c=a[u],d=s[u];if(c.mode===Yl.TRIANGLES||c.mode===Yl.TRIANGLE_STRIP||c.mode===Yl.TRIANGLE_FAN||void 0===c.mode)n=!0===r.isSkinnedMesh?new Tu(h,d):new St(h,d),!0===n.isSkinnedMesh&&n.normalizeSkinWeights(),c.mode===Yl.TRIANGLE_STRIP?n.geometry=OH(n.geometry,xb):c.mode===Yl.TRIANGLE_FAN&&(n.geometry=OH(n.geometry,gv));else if(c.mode===Yl.LINES)n=new zr(h,d);else if(c.mode===Yl.LINE_STRIP)n=new Vr(h,d);else if(c.mode===Yl.LINE_LOOP)n=new J0(h,d);else{if(c.mode!==Yl.POINTS)throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+c.mode);n=new Di(h,d)}Object.keys(n.geometry.morphAttributes).length>0&&lvt(n,r),n.name=t.createUniqueName(r.name||"mesh_"+e),Vf(n,r),c.extensions&&Ym(i,n,c),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 r.extensions&&Ym(i,l[0],r),l[0];let h=new Bn;r.extensions&&Ym(i,h,r),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 Yr(Un.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2e6):"orthographic"===n.type&&(t=new xi(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),Vf(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 ht;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 Ml(r,a)}))}loadAnimation(e){let t=this.json,n=this,i=t.animations[e],r=i.name?i.name:"animation_"+e,a=[],s=[],o=[],l=[],h=[];for(let u=0,c=i.channels.length;u<c;u++){let e=i.channels[u],t=i.samplers[e.sampler],n=e.target,r=n.node,c=void 0!==i.parameters?i.parameters[t.input]:t.input,d=void 0!==i.parameters?i.parameters[t.output]:t.output;void 0!==n.node&&(a.push(this.getDependency("node",r)),s.push(this.getDependency("accessor",c)),o.push(this.getDependency("accessor",d)),l.push(t),h.push(n))}return Promise.all([Promise.all(a),Promise.all(s),Promise.all(o),Promise.all(l),Promise.all(h)]).then((function(e){let t=e[0],i=e[1],a=e[2],s=e[3],o=e[4],l=[];for(let r=0,h=t.length;r<h;r++){let e=t[r],h=i[r],u=a[r],c=s[r],d=o[r];if(void 0===e)continue;e.updateMatrix&&e.updateMatrix();let p=n._createAnimationTracks(e,h,u,c,d);if(p)for(let t=0;t<p.length;t++)l.push(p[t])}return new po(r,void 0,l)}))}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,hvt)}));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 Sl:t.length>1?new Bn:1===t.length?t[0]:new an,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),Vf(s,r),r.extensions&&Ym(n,s,r),void 0!==r.matrix){let e=new ht;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 Bn;n.name&&(r.name=i.createUniqueName(n.name)),Vf(r,n),n.extensions&&Ym(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 Ar||n instanceof Hr)&&t.set(n,r);return e.traverse((e=>{let n=i.associations.get(e);null!=n&&t.set(e,n)})),t})(r),r}))}_createAnimationTracks(e,t,n,i,r){let a,s=[],o=e.name?e.name:e.uuid,l=[];switch(Hf[r.path]===Hf.weights?e.traverse((function(e){e.morphTargetInfluences&&l.push(e.name?e.name:e.uuid)})):l.push(o),Hf[r.path]){case Hf.weights:a=Rl;break;case Hf.rotation:a=Ga;break;case Hf.position:case Hf.scale:a=qa;break;default:a=1===n.itemSize?Rl:qa}let h=void 0!==i.interpolation?svt[i.interpolation]:Eu,u=this._getArrayFromAccessor(n);for(let c=0,d=l.length;c<d;c++){let e=new a(l[c]+"."+Hf[r.path],t.array,u,h);"CUBICSPLINE"===i.interpolation&&this._createCubicSplineTrackInterpolant(e),s.push(e)}return s}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){let e=u4(t.constructor),n=new Float32Array(t.length);for(let i=0,r=t.length;i<r;i++)n[i]=t[i]*e;t=n}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(e){return new(this instanceof Ga?l4:lP)(this.times,this.values,this.getValueSize()/3,e)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}};function dvt(e,t,n){let i=t.attributes,r=new Nt;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 k(t[0],t[1],t[2]),new k(a[0],a[1],a[2])),e.normalized){let t=u4(g1[e.componentType]);r.min.multiplyScalar(t),r.max.multiplyScalar(t)}}let a=t.targets;if(void 0!==a){let e=new k,t=new k;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=u4(g1[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 $r;r.getCenter(s.center),s.radius=r.min.distanceTo(r.max)/2,e.boundingSphere=s}function fve(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=c4[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 Vf(e,t),dvt(e,t,n),Promise.all(r).then((function(){return void 0!==t.targets?ovt(e,t.targets,n):e}))}var cP=class extends xr{constructor(e){super(e)}load(e,t,n,i){let r=this,a=""===this.path?na.extractUrlBase(e):this.path,s=new Zr(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 d4(this.resourcePath||t,this.materialOptions);return s.setCrossOrigin(this.crossOrigin),s.setManager(this.manager),s.setMaterials(a),s}},d4=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:hi,this.wrap=void 0!==this.options.wrap?this.options.wrap:Ii}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=sn),i[e]=a}for(let a in n){let e,t=n[a];if(""!==t)switch(a.toLowerCase()){case"kd":i.color=(new ct).fromArray(t).convertSRGBToLinear();break;case"ks":i.specular=(new ct).fromArray(t).convertSRGBToLinear();break;case"ke":i.emissive=(new ct).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 ta(i),this.materials[e]}getTextureParams(e,t){let n,i={scale:new _e(1,1),offset:new _e(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:UA,s=a.getHandler(e);null===s&&(s=new ws(a)),s.setCrossOrigin&&s.setCrossOrigin(this.crossOrigin);let o=s.load(e,n,i,r);return void 0!==t&&(o.mapping=t),o}},fvt=/^[og]\s*(.+)?/,pvt=/^mtllib /,mvt=/^usemtl /,gvt=/^usemap /,mve=/\s+/,gve=new k,f4=new k,vve=new k,yve=new k,$l=new k,uP=new ct;function vvt(){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;gve.fromArray(i,e),f4.fromArray(i,t),vve.fromArray(i,n),$l.subVectors(vve,f4),yve.subVectors(gve,f4),$l.cross(yve),$l.normalize(),r.push($l.x,$l.y,$l.z),r.push($l.x,$l.y,$l.z),r.push($l.x,$l.y,$l.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,u=this.parseVertexIndex(e,h),c=this.parseVertexIndex(t,h),d=this.parseVertexIndex(n,h);if(this.addVertex(u,c,d),this.addColor(u,c,d),void 0!==s&&""!==s){let e=this.normals.length;u=this.parseNormalIndex(s,e),c=this.parseNormalIndex(o,e),d=this.parseNormalIndex(l,e),this.addNormal(u,c,d)}else this.addFaceNormal(u,c,d);if(void 0!==i&&""!==i){let e=this.uvs.length;u=this.parseUVIndex(i,e),c=this.parseUVIndex(r,e),d=this.parseUVIndex(a,e),this.addUV(u,c,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 hP=class extends xr{constructor(e){super(e),this.materials=null}load(e,t,n,i){let r=this,a=new Zr(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 vvt;-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(mve);switch(n[0]){case"v":t.vertices.push(parseFloat(n[1]),parseFloat(n[2]),parseFloat(n[3])),n.length>=7?(uP.setRGB(parseFloat(n[4]),parseFloat(n[5]),parseFloat(n[6])).convertSRGBToLinear(),t.colors.push(uP.r,uP.g,uP.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(mve),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=fvt.exec(e))){let e=(" "+i[0].slice(1).trim()).slice(1);t.startObject(e)}else if(mvt.test(e))t.object.startMaterial(e.substring(7).trim(),t.materialLibraries);else if(pvt.test(e))t.materialLibraries.push(e.substring(7).trim());else if(gvt.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 Bn;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 Ot;h.setAttribute("position",new Bt(n.vertices,3)),n.normals.length>0&&h.setAttribute("normal",new Bt(n.normals,3)),n.colors.length>0&&(l=!0,h.setAttribute("color",new Bt(n.colors,3))),!0===n.hasUVIndices&&h.setAttribute("uv",new Bt(n.uvs,2));let u,c=[];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 zn){if(o&&a&&!(a instanceof Li)){let e=new Li({size:10,sizeAttenuation:!1});Ar.prototype.copy.call(e,a),e.color.copy(a.color),e.map=a.map,a=e}}else{let e=new zn;Ar.prototype.copy.call(e,a),e.color.copy(a.color),a=e}void 0===a&&(a=s?new zn:o?new Li({size:1,sizeAttenuation:!1}):new ta,a.name=e.name,a.flatShading=!e.smooth,a.vertexColors=l,t.materials[n]=a),c.push(a)}if(c.length>1){for(let e=0,t=i.length;e<t;e++){let t=i[e];h.addGroup(t.groupStart,t.groupCount,e)}u=s?new zr(h,c):o?new Di(h,c):new St(h,c)}else u=s?new zr(h,c[0]):o?new Di(h,c[0]):new St(h,c[0]);u.name=e.name,r.add(u)}else if(t.vertices.length>0){let e=new Li({size:1,sizeAttenuation:!1}),n=new Ot;n.setAttribute("position",new Bt(t.vertices,3)),t.colors.length>0&&void 0!==t.colors[0]&&(n.setAttribute("color",new Bt(t.colors,3)),e.vertexColors=!0);let i=new Di(n,e);r.add(i)}return r}},To=new ct,dP=class extends xr{constructor(e){super(e),this.propertyNameMapping={},this.customPropertyMapping={}}load(e,t,n,i){let r=this,a=new Zr(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,t=0){let n="",i=/^ply([\s\S]*)end_header(\r\n|\r|\n)/.exec(e);null!==i&&(n=i[1]);let r,a={comments:[],elements:[],headerLength:t,objInfo:""},s=n.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:[],faceVertexColors:[]};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 u=new p4(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,u);if(!t)break e;l(h,e.name,t,n)}}return o(h)}function o(e){let t=new Ot;e.indices.length>0&&t.setIndex(e.indices),t.setAttribute("position",new Bt(e.vertices,3)),e.normals.length>0&&t.setAttribute("normal",new Bt(e.normals,3)),e.uvs.length>0&&t.setAttribute("uv",new Bt(e.uvs,2)),e.colors.length>0&&t.setAttribute("color",new Bt(e.colors,3)),(e.faceVertexUvs.length>0||e.faceVertexColors.length>0)&&(t=t.toNonIndexed(),e.faceVertexUvs.length>0&&t.setAttribute("uv",new Bt(e.faceVertexUvs,2)),e.faceVertexColors.length>0&&t.setAttribute("color",new Bt(e.faceVertexColors,3)));for(let n of Object.keys(d.customPropertyMapping))e[n].length>0&&t.setAttribute(n,new Bt(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&&(To.setRGB(n[i.attrR]/255,n[i.attrG]/255,n[i.attrB]/255).convertSRGBToLinear(),e.colors.push(To.r,To.g,To.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,r=n.texcoord;3===t.length?(e.indices.push(t[0],t[1],t[2]),r&&6===r.length&&(e.faceVertexUvs.push(r[0],r[1]),e.faceVertexUvs.push(r[2],r[3]),e.faceVertexUvs.push(r[4],r[5]))):4===t.length&&(e.indices.push(t[0],t[1],t[3]),e.indices.push(t[1],t[2],t[3])),null!==i.attrR&&null!==i.attrG&&null!==i.attrB&&(To.setRGB(n[i.attrR]/255,n[i.attrG]/255,n[i.attrB]/255).convertSRGBToLinear(),e.faceVertexColors.push(To.r,To.g,To.b),e.faceVertexColors.push(To.r,To.g,To.b),e.faceVertexColors.push(To.r,To.g,To.b))}}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 u(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 c,d=this;if(e instanceof ArrayBuffer){let n=new Uint8Array(e),{headerText:i,headerLength:d}=function(e){let t=0,n=!0,i="",r=[],a=(new TextDecoder).decode(e.subarray(0,5)),s=/^ply\r\n/.test(a);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!0===s&&t++,{headerText:r.join("\r")+"\r",headerLength:t}}(n),p=t(i,d);c="ascii"===p.format?s((new TextDecoder).decode(n),p):function(e,t){let n,i=r(),s="binary_little_endian"===t.format,c=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);u(o,c,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,p)}else c=s(e,t(e));return c}},p4=class{constructor(e){this.arr=e,this.i=0}empty(){return this.i>=this.arr.length}next(){return this.arr[this.i++]}},fP=class extends xr{constructor(e){super(e)}load(e,t,n,i){let r=this,a=new Zr(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),u=h.getUint32(80,!0),c=!1;for(let g=0;g<70;g++)1129270351==h.getUint32(g,!1)&&82==h.getUint8(g+4)&&61==h.getUint8(g+5)&&(c=!0,r=new Float32Array(3*u*3),a=h.getUint8(g+6)/255,s=h.getUint8(g+7)/255,o=h.getUint8(g+8)/255,l=h.getUint8(g+9)/255);let d=new Ot,p=new Float32Array(3*u*3),f=new Float32Array(3*u*3),m=new ct;for(let g=0;g<u;g++){let e=84+50*g,l=h.getFloat32(e,!0),u=h.getFloat32(e+4,!0),d=h.getFloat32(e+8,!0);if(c){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*g*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]=u,f[o+2]=d,c&&(m.set(t,n,i).convertSRGBToLinear(),r[o]=m.r,r[o+1]=m.g,r[o+2]=m.b)}}return d.setAttribute("position",new yn(p,3)),d.setAttribute("normal",new yn(f,3)),c&&(d.setAttribute("color",new yn(r,3)),d.hasColors=!0,d.alpha=l),d}(n):function(e){let t,n=new Ot,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=[],u=[],c=new k,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));)c.x=parseFloat(t[1]),c.y=parseFloat(t[2]),c.z=parseFloat(t[3]),n++;for(;null!==(t=o.exec(i));)h.push(parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3])),u.push(c.x,c.y,c.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 Bt(h,3)),n.setAttribute("normal",new Bt(u,3)),n}("string"!=typeof(i=e)?(new TextDecoder).decode(i):i);var i}},$m=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),u=Math.max(12-l-h,0),c=255<<l;this.u8[n]=(this.u8[n]&c)+a;var d=~(255<<8-h);this.u8[n+1]=(this.u8[n+1]&d)+s;var p=~(255<<8-u);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 u=~(255<<8-l);this.u8[n+1]=(this.u8[n+1]&u)+s}test(){var e,t,n=new ArrayBuffer(3),i=new $m(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}},pP=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}},mP=class{constructor(){this.LINE_MATERIAL=new zn({color:0,linewidth:2,opacity:.8,transparent:!0}),this.MESH_MATERIAL=new cn({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 u=a[2*l],c=a[2*l+1];e.push(new k(u,c,0))}if(5===r.type){let i=qs.triangulateShape(e,[]),r=[];i.forEach((e=>r.push(...e)));let a=new Ot;a.setFromPoints(e),a.setIndex(r),t.push(a);let s=new Ot;e.length>2&&!e[0].equals(e[e.length-1])&&e.push(e[0]),s.setFromPoints(e),n.push(s)}else{let t=new Ot;t.setFromPoints(e),n.push(t)}}}var d=new an;for(i=0;i<n.length;i++)d.add(new Vr(n[i],this.LINE_MATERIAL));for(i=0;i<t.length;i++)d.add(new St(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 k(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 Ot;t.setFromPoints(o),n.push(t),e=[]}}var h=new an;for(r=0;r<i.length;r++)h.add(new Vr(i[r],this.LINE_MATERIAL));for(r=0;r<n.length;r++)h.add(new St(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],u=r[2*o+1];t.push(h/180*32767,u/180*32767)}t.push(-32768)}}var c=new Int16Array(t);console.log("16-bit quantized byteLength",c.buffer.byteLength);var d=this.deltaEncode6(c);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 $m(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 $m(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}},gP=class{load(e,t,n,i){return it(this,null,(function*(){this.updateProgress(n,0);let r=new XMLHttpRequest;r.responseType="arraybuffer",r.onload=()=>{this.updateProgress(n,50);let e=(new pP).parse(r.response),i=(new mP).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}))}},m4=class{constructor(e){this.manager=e}setLoadManager(e){this.manager=e}loadLocalModel(e,t,n){return it(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")?(fe.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 it(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 fe.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 it(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,(e=>{0===e.total&&e.loaded>0||t&&t(e)}));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 it(this,null,(function*(){let n=yield new iP(this.manager).loadAsync(e,t);return Promise.resolve(n)}))}loadObj(e,t){return it(this,null,(function*(){let n=new hP(this.manager),i=new cP(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 it(this,null,(function*(){let n=yield new fP(this.manager).loadAsync(e,t),i=new za({color:11184810,metalness:.1,roughness:.8}),r=new St(n,i);return Promise.resolve(r)}))}loadShp(e,t){return it(this,null,(function*(){let n=new gP;return new Promise(((i,r)=>{n.load(e,(e=>{i(e)}),t,(e=>{r(e)}))}))}))}loadDae(e,t){return it(this,null,(function*(){let n=yield new eP(this.manager).loadAsync(e,t);return Promise.resolve(n.scene)}))}loadDxf(e,t){return it(this,null,(function*(){var n;this.font||console.warn("[LoadingHelper] Should set font first!");let i=new Ln(this.manager,{ignorePaperSpace:!0,enableLocalCache:!1,overrideHatchPatternLineThickness:2});i.setFont(this.font),yield null==(n=this.font)?void 0:n.getFontFromIndexeddb();try{let n=yield i.loadAsync(e,t);return Promise.resolve(n.threejsObject)}catch(e){let n=new ErrorEvent("");return Promise.reject(n)}}))}loadPly(e,t){return it(this,null,(function*(){let n=yield new dP(this.manager).loadAsync(e,t);return Promise.resolve(new St(n))}))}loadImage(e,t){return it(this,null,(function*(){let n=yield new ws(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 cn({map:n,side:hr,transparent:!0}),o=new mi(a,r),l=new St(o,s);return Promise.resolve(l)}))}loadDxfData(e,t,n,i,r){return it(this,null,(function*(){var a;this.font||console.warn("[LoadingHelper] Should set font first!");let s=new Ln(this.manager,r);return s.setFont(this.font),yield null==(a=this.font)?void 0:a.getFontFromIndexeddb(),s.manager.onLoad=()=>{i&&i()},s.load(e,t,n)}))}setFont(e){this.font=e}static setDracoDecoderPath(e){this.decoderPath=e}getGltfLoader(){if(!this.gltfLoader){this.gltfLoader=new oP(this.manager);let e=new tP(this.manager);e.setDecoderPath(m4.decoderPath),this.gltfLoader.setDRACOLoader(e)}return this.gltfLoader}},ju=m4;function g4(e){let t=new Blob([e],{type:"text/javascript"}),n=URL.createObjectURL(t),i=new Worker(n);return URL.revokeObjectURL(n),i}function v4(){return g4('var Jc=Object.defineProperty,$c=Object.defineProperties;var Kc=Object.getOwnPropertyDescriptors;var zo=Object.getOwnPropertySymbols;var Qc=Object.prototype.hasOwnProperty,jc=Object.prototype.propertyIsEnumerable;var Vo=(i,t,e)=>t in i?Jc(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,ts=(i,t)=>{for(var e in t||(t={}))Qc.call(t,e)&&Vo(i,e,t[e]);if(zo)for(var e of zo(t))jc.call(t,e)&&Vo(i,e,t[e]);return i},ko=(i,t)=>$c(i,Kc(t));var mo="155";var tl=0,Ho=1,el=2;var ac=1,nl=2,rn=3,He=0,he=1,ze=2;var vn=0,fi=1,Go=2,Wo=3,Xo=4,il=5,li=100,sl=101,rl=102,qo=103,Yo=104,ol=200,al=201,cl=202,ll=203,cc=204,lc=205,hl=206,ul=207,fl=208,dl=209,pl=210,ml=0,gl=1,_l=2,Lr=3,xl=4,yl=5,vl=6,Ml=7,hc=0,Sl=1,bl=2,Mn=0,El=1,Tl=2,wl=3,Al=4,Rl=5,uc=300,mi=301,gi=302,Ir=303,Ur=304,Bs=306,Dr=1e3,Ve=1001,Nr=1002,pe=1003,Zo=1004;var er=1005;var Ie=1006,Cl=1007;var Hi=1008;var Sn=1009,Pl=1010,Ll=1011,go=1012,fc=1013,xn=1014,yn=1015,Gi=1016,dc=1017,pc=1018,Fn=1020,Il=1021,ke=1023,Ul=1024,Dl=1025,On=1026,_i=1027,Nl=1028,mc=1029,Fl=1030,gc=1031,_c=1033,nr=33776,ir=33777,sr=33778,rr=33779,Jo=35840,$o=35841,Ko=35842,Qo=35843,Ol=36196,jo=37492,ta=37496,ea=37808,na=37809,ia=37810,sa=37811,ra=37812,oa=37813,aa=37814,ca=37815,la=37816,ha=37817,ua=37818,fa=37819,da=37820,pa=37821,or=36492,Bl=36283,ma=36284,ga=36285,_a=36286;var bs=2300,Es=2301,ar=2302,xa=2400,ya=2401,va=2402;var xc=3e3,Bn=3001,zl=3200,Vl=3201,kl=0,Hl=1,zn="",Rt="srgb",Ze="srgb-linear",yc="display-p3";var cr=7680;var Gl=519,Wl=512,Xl=513,ql=514,Yl=515,Zl=516,Jl=517,$l=518,Kl=519,Ma=35044;var Sa="300 es",Fr=1035,on=2e3,Ts=2001,bn=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}}},ce=["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 lr=Math.PI/180,Or=180/Math.PI;function qi(){let i=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(ce[i&255]+ce[i>>8&255]+ce[i>>16&255]+ce[i>>24&255]+"-"+ce[t&255]+ce[t>>8&255]+"-"+ce[t>>16&15|64]+ce[t>>24&255]+"-"+ce[e&63|128]+ce[e>>8&255]+"-"+ce[e>>16&255]+ce[e>>24&255]+ce[n&255]+ce[n>>8&255]+ce[n>>16&255]+ce[n>>24&255]).toLowerCase()}function me(i,t,e){return Math.max(t,Math.min(e,i))}function Ql(i,t){return(i%t+t)%t}function hr(i,t,e){return(1-e)*i+e*t}function ba(i){return(i&i-1)===0&&i!==0}function Br(i){return Math.pow(2,Math.floor(Math.log(i)/Math.LN2))}function Di(i,t){switch(t.constructor){case Float32Array:return i;case Uint32Array:return i/4294967295;case Uint16Array:return i/65535;case Uint8Array:return i/255;case Int32Array:return Math.max(i/2147483647,-1);case Int16Array:return Math.max(i/32767,-1);case Int8Array:return Math.max(i/127,-1);default:throw new Error("Invalid component type.")}}function ye(i,t){switch(t.constructor){case Float32Array:return i;case Uint32Array:return Math.round(i*4294967295);case Uint16Array:return Math.round(i*65535);case Uint8Array:return Math.round(i*255);case Int32Array:return Math.round(i*2147483647);case Int16Array:return Math.round(i*32767);case Int8Array:return Math.round(i*127);default:throw new Error("Invalid component type.")}}var Nt=class{constructor(t=0,e=0){Nt.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(me(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(t,e,n,s,r,a,o,c,l){Ct.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,e,n,s,r,a,o,c,l)}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],u=n[2],m=n[5],g=n[8],x=s[0],p=s[3],f=s[6],v=s[1],_=s[4],b=s[7],S=s[2],T=s[5],A=s[8];return r[0]=a*x+o*v+c*S,r[3]=a*p+o*_+c*T,r[6]=a*f+o*b+c*A,r[1]=l*x+h*v+d*S,r[4]=l*p+h*_+d*T,r[7]=l*f+h*b+d*A,r[2]=u*x+m*v+g*S,r[5]=u*p+m*_+g*T,r[8]=u*f+m*b+g*A,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,u=o*c-h*r,m=l*r-a*c,g=e*d+n*u+s*m;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]=u*x,t[4]=(h*e-s*c)*x,t[5]=(s*r-o*e)*x,t[6]=m*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(ur.makeScale(t,e)),this}rotate(t){return this.premultiply(ur.makeRotation(-t)),this}translate(t,e){return this.premultiply(ur.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):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)}},ur=new Ct;function vc(i){for(let t=i.length-1;t>=0;--t)if(i[t]>=65535)return!0;return!1}function ws(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}var Ea={};function Vi(i){i in Ea||(Ea[i]=!0,console.warn(i))}function di(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function fr(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}var jl=new Ct().fromArray([.8224621,.0331941,.0170827,.177538,.9668058,.0723974,-1e-7,1e-7,.9105199]),th=new Ct().fromArray([1.2249401,-.0420569,-.0196376,-.2249404,1.0420571,-.0786361,1e-7,0,1.0982735]);function eh(i){return i.convertSRGBToLinear().applyMatrix3(th)}function nh(i){return i.applyMatrix3(jl).convertLinearToSRGB()}var ih={[Ze]:i=>i,[Rt]:i=>i.convertSRGBToLinear(),[yc]:eh},sh={[Ze]:i=>i,[Rt]:i=>i.convertLinearToSRGB(),[yc]:nh},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 Ze},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=ih[t],s=sh[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)}},Yn,As=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{Yn===void 0&&(Yn=ws("canvas")),Yn.width=t.width,Yn.height=t.height;let n=Yn.getContext("2d");t instanceof ImageData?n.putImageData(t,0,0):n.drawImage(t,0,0,t.width,t.height),e=Yn}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=ws("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]=di(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(di(e[n]/255)*255):e[n]=di(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}},rh=0,Rs=class{constructor(t=null){this.isSource=!0,Object.defineProperty(this,"id",{value:rh++}),this.uuid=qi(),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(dr(s[a].image)):r.push(dr(s[a]))}else r=dr(s);n.url=r}return e||(t.images[this.uuid]=n),n}};function dr(i){return typeof HTMLImageElement!="undefined"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement!="undefined"&&i instanceof HTMLCanvasElement||typeof ImageBitmap!="undefined"&&i instanceof ImageBitmap?As.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 oh=0,ge=class extends bn{constructor(t=ge.DEFAULT_IMAGE,e=ge.DEFAULT_MAPPING,n=Ve,s=Ve,r=Ie,a=Hi,o=ke,c=Sn,l=ge.DEFAULT_ANISOTROPY,h=zn){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:oh++}),this.uuid=qi(),this.name="",this.source=new Rs(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 Nt(0,0),this.repeat=new Nt(1,1),this.center=new Nt(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:(Vi("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=h===Bn?Rt:zn),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.6,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!==uc)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case Dr:t.x=t.x-Math.floor(t.x);break;case Ve:t.x=t.x<0?0:1;break;case Nr: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 Dr:t.y=t.y-Math.floor(t.y);break;case Ve:t.y=t.y<0?0:1;break;case Nr: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 Vi("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace===Rt?Bn:xc}set encoding(t){Vi("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=t===Bn?Rt:zn}};ge.DEFAULT_IMAGE=null;ge.DEFAULT_MAPPING=uc;ge.DEFAULT_ANISOTROPY=1;var jt=class{constructor(t=0,e=0,n=0,s=1){jt.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],u=c[1],m=c[5],g=c[9],x=c[2],p=c[6],f=c[10];if(Math.abs(h-u)<.01&&Math.abs(d-x)<.01&&Math.abs(g-p)<.01){if(Math.abs(h+u)<.1&&Math.abs(d+x)<.1&&Math.abs(g+p)<.1&&Math.abs(l+m+f-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;let _=(l+1)/2,b=(m+1)/2,S=(f+1)/2,T=(h+u)/4,A=(d+x)/4,L=(g+p)/4;return _>b&&_>S?_<.01?(n=0,s=.707106781,r=.707106781):(n=Math.sqrt(_),s=T/n,r=A/n):b>S?b<.01?(n=.707106781,s=0,r=.707106781):(s=Math.sqrt(b),n=T/s,r=L/s):S<.01?(n=.707106781,s=.707106781,r=0):(r=Math.sqrt(S),n=A/r,s=L/r),this.set(n,s,r,e),this}let v=Math.sqrt((p-g)*(p-g)+(d-x)*(d-x)+(u-h)*(u-h));return Math.abs(v)<.001&&(v=1),this.x=(p-g)/v,this.y=(d-x)/v,this.z=(u-h)/v,this.w=Math.acos((l+m+f-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}},zr=class extends bn{constructor(t=1,e=1,n={}){super(),this.isRenderTarget=!0,this.width=t,this.height=e,this.depth=1,this.scissor=new jt(0,0,t,e),this.scissorTest=!1,this.viewport=new jt(0,0,t,e);let s={width:t,height:e,depth:1};n.encoding!==void 0&&(Vi("THREE.WebGLRenderTarget: option.encoding has been replaced by option.colorSpace."),n.colorSpace=n.encoding===Bn?Rt:zn),this.texture=new ge(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:Ie,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 Rs(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"})}},cn=class extends zr{constructor(t=1,e=1,n={}){super(t,e,n),this.isWebGLRenderTarget=!0}},Cs=class extends ge{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=pe,this.minFilter=pe,this.wrapR=Ve,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};var Vr=class extends ge{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=pe,this.minFilter=pe,this.wrapR=Ve,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};var En=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],u=r[a+0],m=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]=u,t[e+1]=m,t[e+2]=g,t[e+3]=x;return}if(d!==x||c!==u||l!==m||h!==g){let p=1-o,f=c*u+l*m+h*g+d*x,v=f>=0?1:-1,_=1-f*f;if(_>Number.EPSILON){let S=Math.sqrt(_),T=Math.atan2(S,f*v);p=Math.sin(p*T)/S,o=Math.sin(o*T)/S}let b=o*v;if(c=c*p+u*b,l=l*p+m*b,h=h*p+g*b,d=d*p+x*b,p===1-o){let S=1/Math.sqrt(c*c+l*l+h*h+d*d);c*=S,l*=S,h*=S,d*=S}}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],u=r[a+1],m=r[a+2],g=r[a+3];return t[e]=o*g+h*d+c*m-l*u,t[e+1]=c*g+h*u+l*d-o*m,t[e+2]=l*g+h*m+o*u-c*d,t[e+3]=h*g-o*d-c*u-l*m,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),u=c(n/2),m=c(s/2),g=c(r/2);switch(a){case"XYZ":this._x=u*h*d+l*m*g,this._y=l*m*d-u*h*g,this._z=l*h*g+u*m*d,this._w=l*h*d-u*m*g;break;case"YXZ":this._x=u*h*d+l*m*g,this._y=l*m*d-u*h*g,this._z=l*h*g-u*m*d,this._w=l*h*d+u*m*g;break;case"ZXY":this._x=u*h*d-l*m*g,this._y=l*m*d+u*h*g,this._z=l*h*g+u*m*d,this._w=l*h*d-u*m*g;break;case"ZYX":this._x=u*h*d-l*m*g,this._y=l*m*d+u*h*g,this._z=l*h*g-u*m*d,this._w=l*h*d+u*m*g;break;case"YZX":this._x=u*h*d+l*m*g,this._y=l*m*d+u*h*g,this._z=l*h*g-u*m*d,this._w=l*h*d-u*m*g;break;case"XZY":this._x=u*h*d-l*m*g,this._y=l*m*d-u*h*g,this._z=l*h*g+u*m*d,this._w=l*h*d+u*m*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],u=n+o+d;if(u>0){let m=.5/Math.sqrt(u+1);this._w=.25/m,this._x=(h-c)*m,this._y=(r-l)*m,this._z=(a-s)*m}else if(n>o&&n>d){let m=2*Math.sqrt(1+n-o-d);this._w=(h-c)/m,this._x=.25*m,this._y=(s+a)/m,this._z=(r+l)/m}else if(o>d){let m=2*Math.sqrt(1+o-n-d);this._w=(r-l)/m,this._x=(s+a)/m,this._y=.25*m,this._z=(c+h)/m}else{let m=2*Math.sqrt(1+d-n-o);this._w=(a-s)/m,this._x=(r+l)/m,this._y=(c+h)/m,this._z=.25*m}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(me(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 m=1-e;return this._w=m*a+e*this._w,this._x=m*n+e*this._x,this._y=m*s+e*this._y,this._z=m*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,u=Math.sin(e*h)/l;return this._w=a*d+this._w*u,this._x=n*d+this._x*u,this._y=s*d+this._y*u,this._z=r*d+this._z*u,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(Ta.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(Ta.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,u=-r*e-a*n-o*s;return this.x=l*c+u*-r+h*-o-d*-a,this.y=h*c+u*-a+d*-r-l*-o,this.z=d*c+u*-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 pr.copy(this).projectOnVector(t),this.sub(pr)}reflect(t){return this.sub(pr.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(me(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}},pr=new P,Ta=new En,_e=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(je.fromArray(t,e));return this}setFromBufferAttribute(t){this.makeEmpty();for(let e=0,n=t.count;e<n;e++)this.expandByPoint(je.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=je.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(),Zn.copy(t.boundingBox),Zn.applyMatrix4(t.matrixWorld),this.union(Zn);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++)je.fromBufferAttribute(r,a).applyMatrix4(t.matrixWorld),this.expandByPoint(je)}else s.boundingBox===null&&s.computeBoundingBox(),Zn.copy(s.boundingBox),Zn.applyMatrix4(t.matrixWorld),this.union(Zn)}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,je),je.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(Ni),es.subVectors(this.max,Ni),Jn.subVectors(t.a,Ni),$n.subVectors(t.b,Ni),Kn.subVectors(t.c,Ni),dn.subVectors($n,Jn),pn.subVectors(Kn,$n),Pn.subVectors(Jn,Kn);let e=[0,-dn.z,dn.y,0,-pn.z,pn.y,0,-Pn.z,Pn.y,dn.z,0,-dn.x,pn.z,0,-pn.x,Pn.z,0,-Pn.x,-dn.y,dn.x,0,-pn.y,pn.x,0,-Pn.y,Pn.x,0];return!mr(e,Jn,$n,Kn,es)||(e=[1,0,0,0,1,0,0,0,1],!mr(e,Jn,$n,Kn,es))?!1:(ns.crossVectors(dn,pn),e=[ns.x,ns.y,ns.z],mr(e,Jn,$n,Kn,es))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,je).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=this.getSize(je).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:(Qe[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),Qe[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),Qe[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),Qe[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),Qe[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),Qe[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),Qe[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),Qe[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(Qe),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)}},Qe=[new P,new P,new P,new P,new P,new P,new P,new P],je=new P,Zn=new _e,Jn=new P,$n=new P,Kn=new P,dn=new P,pn=new P,Pn=new P,Ni=new P,es=new P,ns=new P,Ln=new P;function mr(i,t,e,n,s){for(let r=0,a=i.length-3;r<=a;r+=3){Ln.fromArray(i,r);let o=s.x*Math.abs(Ln.x)+s.y*Math.abs(Ln.y)+s.z*Math.abs(Ln.z),c=t.dot(Ln),l=e.dot(Ln),h=n.dot(Ln);if(Math.max(-Math.max(c,l,h),Math.min(c,l,h))>o)return!1}return!0}var ah=new _e,Fi=new P,gr=new P,Vn=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):ah.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;Fi.subVectors(t,this.center);let e=Fi.lengthSq();if(e>this.radius*this.radius){let n=Math.sqrt(e),s=(n-this.radius)*.5;this.center.addScaledVector(Fi,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):(gr.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(Fi.copy(t.center).add(gr)),this.expandByPoint(Fi.copy(t.center).sub(gr))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return new this.constructor().copy(this)}},tn=new P,_r=new P,is=new P,mn=new P,xr=new P,ss=new P,yr=new P,kr=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){_r.copy(t).add(e).multiplyScalar(.5),is.copy(e).sub(t).normalize(),mn.copy(this.origin).sub(_r);let r=t.distanceTo(e)*.5,a=-this.direction.dot(is),o=mn.dot(this.direction),c=-mn.dot(is),l=mn.lengthSq(),h=Math.abs(1-a*a),d,u,m,g;if(h>0)if(d=a*c-o,u=a*o-c,g=r*h,d>=0)if(u>=-g)if(u<=g){let x=1/h;d*=x,u*=x,m=d*(d+a*u+2*o)+u*(a*d+u+2*c)+l}else u=r,d=Math.max(0,-(a*u+o)),m=-d*d+u*(u+2*c)+l;else u=-r,d=Math.max(0,-(a*u+o)),m=-d*d+u*(u+2*c)+l;else u<=-g?(d=Math.max(0,-(-a*r+o)),u=d>0?-r:Math.min(Math.max(-r,-c),r),m=-d*d+u*(u+2*c)+l):u<=g?(d=0,u=Math.min(Math.max(-r,-c),r),m=u*(u+2*c)+l):(d=Math.max(0,-(a*r+o)),u=d>0?r:Math.min(Math.max(-r,-c),r),m=-d*d+u*(u+2*c)+l);else u=a>0?-r:r,d=Math.max(0,-(a*u+o)),m=-d*d+u*(u+2*c)+l;return n&&n.copy(this.origin).addScaledVector(this.direction,d),s&&s.copy(_r).addScaledVector(is,u),m}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,u=this.origin;return l>=0?(n=(t.min.x-u.x)*l,s=(t.max.x-u.x)*l):(n=(t.max.x-u.x)*l,s=(t.min.x-u.x)*l),h>=0?(r=(t.min.y-u.y)*h,a=(t.max.y-u.y)*h):(r=(t.max.y-u.y)*h,a=(t.min.y-u.y)*h),n>a||r>s||((r>n||isNaN(n))&&(n=r),(a<s||isNaN(s))&&(s=a),d>=0?(o=(t.min.z-u.z)*d,c=(t.max.z-u.z)*d):(o=(t.max.z-u.z)*d,c=(t.min.z-u.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){xr.subVectors(e,t),ss.subVectors(n,t),yr.crossVectors(xr,ss);let a=this.direction.dot(yr),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(ss.crossVectors(mn,ss));if(c<0)return null;let l=o*this.direction.dot(xr.cross(mn));if(l<0||c+l>a)return null;let h=-o*mn.dot(yr);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(t,e,n,s,r,a,o,c,l,h,d,u,m,g,x,p){Gt.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,e,n,s,r,a,o,c,l,h,d,u,m,g,x,p)}set(t,e,n,s,r,a,o,c,l,h,d,u,m,g,x,p){let f=this.elements;return f[0]=t,f[4]=e,f[8]=n,f[12]=s,f[1]=r,f[5]=a,f[9]=o,f[13]=c,f[2]=l,f[6]=h,f[10]=d,f[14]=u,f[3]=m,f[7]=g,f[11]=x,f[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 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/Qn.setFromMatrixColumn(t,0).length(),r=1/Qn.setFromMatrixColumn(t,1).length(),a=1/Qn.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 u=a*h,m=a*d,g=o*h,x=o*d;e[0]=c*h,e[4]=-c*d,e[8]=l,e[1]=m+g*l,e[5]=u-x*l,e[9]=-o*c,e[2]=x-u*l,e[6]=g+m*l,e[10]=a*c}else if(t.order==="YXZ"){let u=c*h,m=c*d,g=l*h,x=l*d;e[0]=u+x*o,e[4]=g*o-m,e[8]=a*l,e[1]=a*d,e[5]=a*h,e[9]=-o,e[2]=m*o-g,e[6]=x+u*o,e[10]=a*c}else if(t.order==="ZXY"){let u=c*h,m=c*d,g=l*h,x=l*d;e[0]=u-x*o,e[4]=-a*d,e[8]=g+m*o,e[1]=m+g*o,e[5]=a*h,e[9]=x-u*o,e[2]=-a*l,e[6]=o,e[10]=a*c}else if(t.order==="ZYX"){let u=a*h,m=a*d,g=o*h,x=o*d;e[0]=c*h,e[4]=g*l-m,e[8]=u*l+x,e[1]=c*d,e[5]=x*l+u,e[9]=m*l-g,e[2]=-l,e[6]=o*c,e[10]=a*c}else if(t.order==="YZX"){let u=a*c,m=a*l,g=o*c,x=o*l;e[0]=c*h,e[4]=x-u*d,e[8]=g*d+m,e[1]=d,e[5]=a*h,e[9]=-o*h,e[2]=-l*h,e[6]=m*d+g,e[10]=u-x*d}else if(t.order==="XZY"){let u=a*c,m=a*l,g=o*c,x=o*l;e[0]=c*h,e[4]=-d,e[8]=l*h,e[1]=u*d+x,e[5]=a*h,e[9]=m*d-g,e[2]=g*d-m,e[6]=o*h,e[10]=x*d+u}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(ch,t,lh)}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(),rs.crossVectors(we,gn),s[0]=gn.x,s[4]=rs.x,s[8]=we.x,s[1]=gn.y,s[5]=rs.y,s[9]=we.y,s[2]=gn.z,s[6]=rs.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],u=n[9],m=n[13],g=n[2],x=n[6],p=n[10],f=n[14],v=n[3],_=n[7],b=n[11],S=n[15],T=s[0],A=s[4],L=s[8],y=s[12],w=s[1],z=s[5],Y=s[9],I=s[13],D=s[2],O=s[6],$=s[10],G=s[14],q=s[3],J=s[7],K=s[11],B=s[15];return r[0]=a*T+o*w+c*D+l*q,r[4]=a*A+o*z+c*O+l*J,r[8]=a*L+o*Y+c*$+l*K,r[12]=a*y+o*I+c*G+l*B,r[1]=h*T+d*w+u*D+m*q,r[5]=h*A+d*z+u*O+m*J,r[9]=h*L+d*Y+u*$+m*K,r[13]=h*y+d*I+u*G+m*B,r[2]=g*T+x*w+p*D+f*q,r[6]=g*A+x*z+p*O+f*J,r[10]=g*L+x*Y+p*$+f*K,r[14]=g*y+x*I+p*G+f*B,r[3]=v*T+_*w+b*D+S*q,r[7]=v*A+_*z+b*O+S*J,r[11]=v*L+_*Y+b*$+S*K,r[15]=v*y+_*I+b*G+S*B,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],u=t[10],m=t[14],g=t[3],x=t[7],p=t[11],f=t[15];return g*(+r*c*d-s*l*d-r*o*u+n*l*u+s*o*m-n*c*m)+x*(+e*c*m-e*l*u+r*a*u-s*a*m+s*l*h-r*c*h)+p*(+e*l*d-e*o*m-r*a*d+n*a*m+r*o*h-n*l*h)+f*(-s*o*h-e*c*d+e*o*u+s*a*d-n*a*u+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],u=t[10],m=t[11],g=t[12],x=t[13],p=t[14],f=t[15],v=d*p*l-x*u*l+x*c*m-o*p*m-d*c*f+o*u*f,_=g*u*l-h*p*l-g*c*m+a*p*m+h*c*f-a*u*f,b=h*x*l-g*d*l+g*o*m-a*x*m-h*o*f+a*d*f,S=g*d*c-h*x*c-g*o*u+a*x*u+h*o*p-a*d*p,T=e*v+n*_+s*b+r*S;if(T===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let A=1/T;return t[0]=v*A,t[1]=(x*u*r-d*p*r-x*s*m+n*p*m+d*s*f-n*u*f)*A,t[2]=(o*p*r-x*c*r+x*s*l-n*p*l-o*s*f+n*c*f)*A,t[3]=(d*c*r-o*u*r-d*s*l+n*u*l+o*s*m-n*c*m)*A,t[4]=_*A,t[5]=(h*p*r-g*u*r+g*s*m-e*p*m-h*s*f+e*u*f)*A,t[6]=(g*c*r-a*p*r-g*s*l+e*p*l+a*s*f-e*c*f)*A,t[7]=(a*u*r-h*c*r+h*s*l-e*u*l-a*s*m+e*c*m)*A,t[8]=b*A,t[9]=(g*d*r-h*x*r-g*n*m+e*x*m+h*n*f-e*d*f)*A,t[10]=(a*x*r-g*o*r+g*n*l-e*x*l-a*n*f+e*o*f)*A,t[11]=(h*o*r-a*d*r-h*n*l+e*d*l+a*n*m-e*o*m)*A,t[12]=S*A,t[13]=(h*x*s-g*d*s+g*n*u-e*x*u-h*n*p+e*d*p)*A,t[14]=(g*o*s-a*x*s-g*n*c+e*x*c+a*n*p-e*o*p)*A,t[15]=(a*d*s-h*o*s+h*n*c-e*d*c-a*n*u+e*o*u)*A,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 t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):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,u=r*l,m=r*h,g=r*d,x=a*h,p=a*d,f=o*d,v=c*l,_=c*h,b=c*d,S=n.x,T=n.y,A=n.z;return s[0]=(1-(x+f))*S,s[1]=(m+b)*S,s[2]=(g-_)*S,s[3]=0,s[4]=(m-b)*T,s[5]=(1-(u+f))*T,s[6]=(p+v)*T,s[7]=0,s[8]=(g+_)*A,s[9]=(p-v)*A,s[10]=(1-(u+x))*A,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=Qn.set(s[0],s[1],s[2]).length(),a=Qn.set(s[4],s[5],s[6]).length(),o=Qn.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,o=on){let c=this.elements,l=2*r/(e-t),h=2*r/(n-s),d=(e+t)/(e-t),u=(n+s)/(n-s),m,g;if(o===on)m=-(a+r)/(a-r),g=-2*a*r/(a-r);else if(o===Ts)m=-a/(a-r),g=-a*r/(a-r);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return c[0]=l,c[4]=0,c[8]=d,c[12]=0,c[1]=0,c[5]=h,c[9]=u,c[13]=0,c[2]=0,c[6]=0,c[10]=m,c[14]=g,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(t,e,n,s,r,a,o=on){let c=this.elements,l=1/(e-t),h=1/(n-s),d=1/(a-r),u=(e+t)*l,m=(n+s)*h,g,x;if(o===on)g=(a+r)*d,x=-2*d;else if(o===Ts)g=r*d,x=-1*d;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return c[0]=2*l,c[4]=0,c[8]=0,c[12]=-u,c[1]=0,c[5]=2*h,c[9]=0,c[13]=-m,c[2]=0,c[6]=0,c[10]=x,c[14]=-g,c[3]=0,c[7]=0,c[11]=0,c[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}},Qn=new P,Fe=new Gt,ch=new P(0,0,0),lh=new P(1,1,1),gn=new P,rs=new P,we=new P,wa=new Gt,Aa=new En,xi=class{constructor(t=0,e=0,n=0,s=xi.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],u=s[6],m=s[10];switch(e){case"XYZ":this._y=Math.asin(me(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,m),this._z=Math.atan2(-a,r)):(this._x=Math.atan2(u,l),this._z=0);break;case"YXZ":this._x=Math.asin(-me(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(o,m),this._z=Math.atan2(c,l)):(this._y=Math.atan2(-d,r),this._z=0);break;case"ZXY":this._x=Math.asin(me(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(-d,m),this._z=Math.atan2(-a,l)):(this._y=0,this._z=Math.atan2(c,r));break;case"ZYX":this._y=Math.asin(-me(d,-1,1)),Math.abs(d)<.9999999?(this._x=Math.atan2(u,m),this._z=Math.atan2(c,r)):(this._x=0,this._z=Math.atan2(-a,l));break;case"YZX":this._z=Math.asin(me(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,m));break;case"XZY":this._z=Math.asin(-me(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(u,l),this._y=Math.atan2(o,r)):(this._x=Math.atan2(-h,m),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 wa.makeRotationFromQuaternion(t),this.setFromRotationMatrix(wa,e,n)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return Aa.setFromEuler(this),this.setFromQuaternion(Aa,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}};xi.DEFAULT_ORDER="XYZ";var Ps=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}},hh=0,Ra=new P,jn=new En,en=new Gt,os=new P,Oi=new P,uh=new P,fh=new En,Ca=new P(1,0,0),Pa=new P(0,1,0),La=new P(0,0,1),dh={type:"added"},Ia={type:"removed"},ve=class extends bn{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:hh++}),this.uuid=qi(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=ve.DEFAULT_UP.clone();let t=new P,e=new xi,n=new En,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=ve.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.matrixWorldAutoUpdate=ve.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.layers=new Ps,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 jn.setFromAxisAngle(t,e),this.quaternion.multiply(jn),this}rotateOnWorldAxis(t,e){return jn.setFromAxisAngle(t,e),this.quaternion.premultiply(jn),this}rotateX(t){return this.rotateOnAxis(Ca,t)}rotateY(t){return this.rotateOnAxis(Pa,t)}rotateZ(t){return this.rotateOnAxis(La,t)}translateOnAxis(t,e){return Ra.copy(t).applyQuaternion(this.quaternion),this.position.add(Ra.multiplyScalar(e)),this}translateX(t){return this.translateOnAxis(Ca,t)}translateY(t){return this.translateOnAxis(Pa,t)}translateZ(t){return this.translateOnAxis(La,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?os.copy(t):os.set(t,e,n);let s=this.parent;this.updateWorldMatrix(!0,!1),Oi.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?en.lookAt(Oi,os,this.up):en.lookAt(os,Oi,this.up),this.quaternion.setFromRotationMatrix(en),s&&(en.extractRotation(s.matrixWorld),jn.setFromRotationMatrix(en),this.quaternion.premultiply(jn.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(dh)):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(Ia)),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(Ia)}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(Oi,t,uh),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Oi,fh,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.6,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),u=a(t.skeletons),m=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),u.length>0&&(n.skeletons=u),m.length>0&&(n.animations=m),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.slice(),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}};ve.DEFAULT_UP=new P(0,1,0);ve.DEFAULT_MATRIX_AUTO_UPDATE=!0;ve.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;var Oe=new P,nn=new P,vr=new P,sn=new P,ti=new P,ei=new P,Ua=new P,Mr=new P,Sr=new P,br=new P,as=!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),vr.subVectors(t,e);let a=Oe.dot(Oe),o=Oe.dot(nn),c=Oe.dot(vr),l=nn.dot(nn),h=nn.dot(vr),d=a*l-o*o;if(d===0)return r.set(-2,-1,-1);let u=1/d,m=(l*c-o*h)*u,g=(a*h-o*c)*u;return r.set(1-m-g,g,m)}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 as===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),as=!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 as===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),as=!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;ti.subVectors(s,n),ei.subVectors(r,n),Mr.subVectors(t,n);let c=ti.dot(Mr),l=ei.dot(Mr);if(c<=0&&l<=0)return e.copy(n);Sr.subVectors(t,s);let h=ti.dot(Sr),d=ei.dot(Sr);if(h>=0&&d<=h)return e.copy(s);let u=c*d-h*l;if(u<=0&&c>=0&&h<=0)return a=c/(c-h),e.copy(n).addScaledVector(ti,a);br.subVectors(t,r);let m=ti.dot(br),g=ei.dot(br);if(g>=0&&m<=g)return e.copy(r);let x=m*l-c*g;if(x<=0&&l>=0&&g<=0)return o=l/(l-g),e.copy(n).addScaledVector(ei,o);let p=h*g-m*d;if(p<=0&&d-h>=0&&m-g>=0)return Ua.subVectors(r,s),o=(d-h)/(d-h+(m-g)),e.copy(s).addScaledVector(Ua,o);let f=1/(p+x+u);return a=x*f,o=u*f,e.copy(n).addScaledVector(ti,a).addScaledVector(ei,o)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}},ph=0,yi=class extends bn{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:ph++}),this.uuid=qi(),this.name="",this.type="Material",this.blending=fi,this.side=He,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=cc,this.blendDst=lc,this.blendEquation=li,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=Lr,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Gl,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=cr,this.stencilZFail=cr,this.stencilZPass=cr,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.6,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.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(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!==fi&&(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.alphaHash===!0&&(n.alphaHash=this.alphaHash),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.alphaHash=t.alphaHash,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++}},Mc={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},cs={h:0,s:0,l:0};function Er(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 kt=class{constructor(t,e,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,e,n)}set(t,e,n){if(e===void 0&&n===void 0){let s=t;s&&s.isColor?this.copy(s):typeof s=="number"?this.setHex(s):typeof s=="string"&&this.setStyle(s)}else this.setRGB(t,e,n);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=Rt){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=Ql(t,1),e=me(e,0,1),n=me(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=Er(a,r,t+1/3),this.g=Er(a,r,t),this.b=Er(a,r,t-1/3)}return Ne.toWorkingColorSpace(this,s),this}setStyle(t,e=Rt){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=Rt){let n=Mc[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=di(t.r),this.g=di(t.g),this.b=di(t.b),this}copyLinearToSRGB(t){return this.r=fr(t.r),this.g=fr(t.g),this.b=fr(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=Rt){return Ne.fromWorkingColorSpace(le.copy(this),t),Math.round(me(le.r*255,0,255))*65536+Math.round(me(le.g*255,0,255))*256+Math.round(me(le.b*255,0,255))}getHexString(t=Rt){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=Ne.workingColorSpace){Ne.fromWorkingColorSpace(le.copy(this),e);let n=le.r,s=le.g,r=le.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(le.copy(this),e),t.r=le.r,t.g=le.g,t.b=le.b,t}getStyle(t=Rt){Ne.fromWorkingColorSpace(le.copy(this),t);let e=le.r,n=le.g,s=le.b;return t!==Rt?`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(cs);let n=hr(Be.h,cs.h,e),s=hr(Be.s,cs.s,e),r=hr(Be.l,cs.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}},le=new kt;kt.NAMES=Mc;var Ls=class extends yi{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new kt(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=hc,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 Qt=new P,ls=new Nt,te=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=Ma,this.updateRange={offset:0,count:-1},this.gpuType=yn,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.gpuType=t.gpuType,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++)ls.fromBufferAttribute(this,e),ls.applyMatrix3(t),this.setXY(e,ls.x,ls.y);else if(this.itemSize===3)for(let e=0,n=this.count;e<n;e++)Qt.fromBufferAttribute(this,e),Qt.applyMatrix3(t),this.setXYZ(e,Qt.x,Qt.y,Qt.z);return this}applyMatrix4(t){for(let e=0,n=this.count;e<n;e++)Qt.fromBufferAttribute(this,e),Qt.applyMatrix4(t),this.setXYZ(e,Qt.x,Qt.y,Qt.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)Qt.fromBufferAttribute(this,e),Qt.applyNormalMatrix(t),this.setXYZ(e,Qt.x,Qt.y,Qt.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)Qt.fromBufferAttribute(this,e),Qt.transformDirection(t),this.setXYZ(e,Qt.x,Qt.y,Qt.z);return this}set(t,e=0){return this.array.set(t,e),this}getComponent(t,e){let n=this.array[t*this.itemSize+e];return this.normalized&&(n=Di(n,this.array)),n}setComponent(t,e,n){return this.normalized&&(n=ye(n,this.array)),this.array[t*this.itemSize+e]=n,this}getX(t){let e=this.array[t*this.itemSize];return this.normalized&&(e=Di(e,this.array)),e}setX(t,e){return this.normalized&&(e=ye(e,this.array)),this.array[t*this.itemSize]=e,this}getY(t){let e=this.array[t*this.itemSize+1];return this.normalized&&(e=Di(e,this.array)),e}setY(t,e){return this.normalized&&(e=ye(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=Di(e,this.array)),e}setZ(t,e){return this.normalized&&(e=ye(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=Di(e,this.array)),e}setW(t,e){return this.normalized&&(e=ye(e,this.array)),this.array[t*this.itemSize+3]=e,this}setXY(t,e,n){return t*=this.itemSize,this.normalized&&(e=ye(e,this.array),n=ye(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=ye(e,this.array),n=ye(n,this.array),s=ye(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=ye(e,this.array),n=ye(n,this.array),s=ye(s,this.array),r=ye(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!==Ma&&(t.usage=this.usage),(this.updateRange.offset!==0||this.updateRange.count!==-1)&&(t.updateRange=this.updateRange),t}};var Is=class extends te{constructor(t,e,n){super(new Uint16Array(t),e,n)}};var Us=class extends te{constructor(t,e,n){super(new Uint32Array(t),e,n)}};var an=class extends te{constructor(t,e,n){super(new Float32Array(t),e,n)}};var mh=0,Le=new Gt,Tr=new ve,ni=new P,Ae=new _e,Bi=new _e,ie=new P,Ge=class extends bn{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:mh++}),this.uuid=qi(),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(vc(t)?Us:Is)(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 Le.makeRotationFromQuaternion(t),this.applyMatrix4(Le),this}rotateX(t){return Le.makeRotationX(t),this.applyMatrix4(Le),this}rotateY(t){return Le.makeRotationY(t),this.applyMatrix4(Le),this}rotateZ(t){return Le.makeRotationZ(t),this.applyMatrix4(Le),this}translate(t,e,n){return Le.makeTranslation(t,e,n),this.applyMatrix4(Le),this}scale(t,e,n){return Le.makeScale(t,e,n),this.applyMatrix4(Le),this}lookAt(t){return Tr.lookAt(t),Tr.updateMatrix(),this.applyMatrix4(Tr.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(ni).negate(),this.translate(ni.x,ni.y,ni.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 _e);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];Ae.setFromBufferAttribute(r),this.morphTargetsRelative?(ie.addVectors(this.boundingBox.min,Ae.min),this.boundingBox.expandByPoint(ie),ie.addVectors(this.boundingBox.max,Ae.max),this.boundingBox.expandByPoint(ie)):(this.boundingBox.expandByPoint(Ae.min),this.boundingBox.expandByPoint(Ae.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 Vn);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(Ae.setFromBufferAttribute(t),e)for(let r=0,a=e.length;r<a;r++){let o=e[r];Bi.setFromBufferAttribute(o),this.morphTargetsRelative?(ie.addVectors(Ae.min,Bi.min),Ae.expandByPoint(ie),ie.addVectors(Ae.max,Bi.max),Ae.expandByPoint(ie)):(Ae.expandByPoint(Bi.min),Ae.expandByPoint(Bi.max))}Ae.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&&(ni.fromBufferAttribute(t,l),ie.add(ni)),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 te(new Float32Array(4*o),4));let c=this.getAttribute("tangent").array,l=[],h=[];for(let w=0;w<o;w++)l[w]=new P,h[w]=new P;let d=new P,u=new P,m=new P,g=new Nt,x=new Nt,p=new Nt,f=new P,v=new P;function _(w,z,Y){d.fromArray(s,w*3),u.fromArray(s,z*3),m.fromArray(s,Y*3),g.fromArray(a,w*2),x.fromArray(a,z*2),p.fromArray(a,Y*2),u.sub(d),m.sub(d),x.sub(g),p.sub(g);let I=1/(x.x*p.y-p.x*x.y);isFinite(I)&&(f.copy(u).multiplyScalar(p.y).addScaledVector(m,-x.y).multiplyScalar(I),v.copy(m).multiplyScalar(x.x).addScaledVector(u,-p.x).multiplyScalar(I),l[w].add(f),l[z].add(f),l[Y].add(f),h[w].add(v),h[z].add(v),h[Y].add(v))}let b=this.groups;b.length===0&&(b=[{start:0,count:n.length}]);for(let w=0,z=b.length;w<z;++w){let Y=b[w],I=Y.start,D=Y.count;for(let O=I,$=I+D;O<$;O+=3)_(n[O+0],n[O+1],n[O+2])}let S=new P,T=new P,A=new P,L=new P;function y(w){A.fromArray(r,w*3),L.copy(A);let z=l[w];S.copy(z),S.sub(A.multiplyScalar(A.dot(z))).normalize(),T.crossVectors(L,z);let I=T.dot(h[w])<0?-1:1;c[w*4]=S.x,c[w*4+1]=S.y,c[w*4+2]=S.z,c[w*4+3]=I}for(let w=0,z=b.length;w<z;++w){let Y=b[w],I=Y.start,D=Y.count;for(let O=I,$=I+D;O<$;O+=3)y(n[O+0]),y(n[O+1]),y(n[O+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 te(new Float32Array(e.count*3),3),this.setAttribute("normal",n);else for(let u=0,m=n.count;u<m;u++)n.setXYZ(u,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 u=0,m=t.count;u<m;u+=3){let g=t.getX(u+0),x=t.getX(u+1),p=t.getX(u+2);s.fromBufferAttribute(e,g),r.fromBufferAttribute(e,x),a.fromBufferAttribute(e,p),h.subVectors(a,r),d.subVectors(s,r),h.cross(d),o.fromBufferAttribute(n,g),c.fromBufferAttribute(n,x),l.fromBufferAttribute(n,p),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(p,l.x,l.y,l.z)}else for(let u=0,m=e.count;u<m;u+=3)s.fromBufferAttribute(e,u+0),r.fromBufferAttribute(e,u+1),a.fromBufferAttribute(e,u+2),h.subVectors(a,r),d.subVectors(s,r),h.cross(d),n.setXYZ(u+0,h.x,h.y,h.z),n.setXYZ(u+1,h.x,h.y,h.z),n.setXYZ(u+2,h.x,h.y,h.z);this.normalizeNormals(),n.needsUpdate=!0}}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,u=new l.constructor(c.length*h),m=0,g=0;for(let x=0,p=c.length;x<p;x++){o.isInterleavedBufferAttribute?m=c[x]*o.data.stride+o.offset:m=c[x]*h;for(let f=0;f<h;f++)u[g++]=l[m++]}return new te(u,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 u=l[h],m=t(u,n);c.push(m)}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.6,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,u=l.length;d<u;d++){let m=l[d];h.push(m.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 u=0,m=d.length;u<m;u++)h.push(d[u].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"})}},Da=new Gt,In=new kr,hs=new Vn,Na=new P,ii=new P,si=new P,ri=new P,wr=new P,us=new P,fs=new Nt,ds=new Nt,ps=new Nt,Fa=new P,Oa=new P,Ba=new P,ms=new P,gs=new P,Ye=class extends ve{constructor(t=new Ge,e=new Ls){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){us.set(0,0,0);for(let c=0,l=r.length;c<l;c++){let h=o[c],d=r[c];h!==0&&(wr.fromBufferAttribute(d,t),a?us.addScaledVector(wr,h):us.addScaledVector(wr.sub(e),h))}e.add(us)}return e}raycast(t,e){let n=this.geometry,s=this.material,r=this.matrixWorld;s!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),hs.copy(n.boundingSphere),hs.applyMatrix4(r),In.copy(t.ray).recast(t.near),!(hs.containsPoint(In.origin)===!1&&(In.intersectSphere(hs,Na)===null||In.origin.distanceToSquared(Na)>(t.far-t.near)**2))&&(Da.copy(r).invert(),In.copy(t.ray).applyMatrix4(Da),!(n.boundingBox!==null&&In.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(t,e,In)))}_computeIntersections(t,e,n){let s,r=this.geometry,a=this.material,o=r.index,c=r.attributes.position,l=r.attributes.uv,h=r.attributes.uv1,d=r.attributes.normal,u=r.groups,m=r.drawRange;if(o!==null)if(Array.isArray(a))for(let g=0,x=u.length;g<x;g++){let p=u[g],f=a[p.materialIndex],v=Math.max(p.start,m.start),_=Math.min(o.count,Math.min(p.start+p.count,m.start+m.count));for(let b=v,S=_;b<S;b+=3){let T=o.getX(b),A=o.getX(b+1),L=o.getX(b+2);s=_s(this,f,t,n,l,h,d,T,A,L),s&&(s.faceIndex=Math.floor(b/3),s.face.materialIndex=p.materialIndex,e.push(s))}}else{let g=Math.max(0,m.start),x=Math.min(o.count,m.start+m.count);for(let p=g,f=x;p<f;p+=3){let v=o.getX(p),_=o.getX(p+1),b=o.getX(p+2);s=_s(this,a,t,n,l,h,d,v,_,b),s&&(s.faceIndex=Math.floor(p/3),e.push(s))}}else if(c!==void 0)if(Array.isArray(a))for(let g=0,x=u.length;g<x;g++){let p=u[g],f=a[p.materialIndex],v=Math.max(p.start,m.start),_=Math.min(c.count,Math.min(p.start+p.count,m.start+m.count));for(let b=v,S=_;b<S;b+=3){let T=b,A=b+1,L=b+2;s=_s(this,f,t,n,l,h,d,T,A,L),s&&(s.faceIndex=Math.floor(b/3),s.face.materialIndex=p.materialIndex,e.push(s))}}else{let g=Math.max(0,m.start),x=Math.min(c.count,m.start+m.count);for(let p=g,f=x;p<f;p+=3){let v=p,_=p+1,b=p+2;s=_s(this,a,t,n,l,h,d,v,_,b),s&&(s.faceIndex=Math.floor(p/3),e.push(s))}}}};function gh(i,t,e,n,s,r,a,o){let c;if(t.side===he?c=n.intersectTriangle(a,r,s,!0,o):c=n.intersectTriangle(s,r,a,t.side===He,o),c===null)return null;gs.copy(o),gs.applyMatrix4(i.matrixWorld);let l=e.ray.origin.distanceTo(gs);return l<e.near||l>e.far?null:{distance:l,point:gs.clone(),object:i}}function _s(i,t,e,n,s,r,a,o,c,l){i.getVertexPosition(o,ii),i.getVertexPosition(c,si),i.getVertexPosition(l,ri);let h=gh(i,t,e,n,ii,si,ri,ms);if(h){s&&(fs.fromBufferAttribute(s,o),ds.fromBufferAttribute(s,c),ps.fromBufferAttribute(s,l),h.uv=se.getInterpolation(ms,ii,si,ri,fs,ds,ps,new Nt)),r&&(fs.fromBufferAttribute(r,o),ds.fromBufferAttribute(r,c),ps.fromBufferAttribute(r,l),h.uv1=se.getInterpolation(ms,ii,si,ri,fs,ds,ps,new Nt),h.uv2=h.uv1),a&&(Fa.fromBufferAttribute(a,o),Oa.fromBufferAttribute(a,c),Ba.fromBufferAttribute(a,l),h.normal=se.getInterpolation(ms,ii,si,ri,Fa,Oa,Ba,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(ii,si,ri,d.normal),h.face=d}return h}var kn=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=[],u=0,m=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,p,f,v,_,b,S,T,A,L,y){let w=b/A,z=S/L,Y=b/2,I=S/2,D=T/2,O=A+1,$=L+1,G=0,q=0,J=new P;for(let K=0;K<$;K++){let B=K*z-I;for(let Z=0;Z<O;Z++){let ot=Z*w-Y;J[x]=ot*v,J[p]=B*_,J[f]=D,l.push(J.x,J.y,J.z),J[x]=0,J[p]=0,J[f]=T>0?1:-1,h.push(J.x,J.y,J.z),d.push(Z/A),d.push(1-K/L),G+=1}}for(let K=0;K<L;K++)for(let B=0;B<A;B++){let Z=u+B+O*K,ot=u+B+O*(K+1),at=u+(B+1)+O*(K+1),ct=u+(B+1)+O*K;c.push(Z,ot,ct),c.push(ot,at,ct),q+=6}o.addGroup(m,q,y),m+=q,u+=G}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new kn(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}};function vi(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 de(i){let t={};for(let e=0;e<i.length;e++){let n=vi(i[e]);for(let s in n)t[s]=n[s]}return t}function _h(i){let t=[];for(let e=0;e<i.length;e++)t.push(i[e].clone());return t}function Sc(i){return i.getRenderTarget()===null?i.outputColorSpace:Ze}var xh={clone:vi,merge:de},yh=`void main() {\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}`,vh=`void main() {\n\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}`,ln=class extends yi{constructor(t){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=yh,this.fragmentShader=vh,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=vi(t.uniforms),this.uniformsGroups=_h(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}},Ds=class extends ve{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Gt,this.projectionMatrix=new Gt,this.projectionMatrixInverse=new Gt,this.coordinateSystem=on}copy(t,e){return super.copy(t,e),this.matrixWorldInverse.copy(t.matrixWorldInverse),this.projectionMatrix.copy(t.projectionMatrix),this.projectionMatrixInverse.copy(t.projectionMatrixInverse),this.coordinateSystem=t.coordinateSystem,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)}},Re=class extends Ds{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=Or*2*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){let t=Math.tan(lr*.5*this.fov);return .5*this.getFilmHeight()/t}getEffectiveFOV(){return Or*2*Math.atan(Math.tan(lr*.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(lr*.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.coordinateSystem),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}},oi=-90,ai=1,Hr=class extends ve{constructor(t,e,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null;let s=new Re(oi,ai,t,e);s.layers=this.layers,this.add(s);let r=new Re(oi,ai,t,e);r.layers=this.layers,this.add(r);let a=new Re(oi,ai,t,e);a.layers=this.layers,this.add(a);let o=new Re(oi,ai,t,e);o.layers=this.layers,this.add(o);let c=new Re(oi,ai,t,e);c.layers=this.layers,this.add(c);let l=new Re(oi,ai,t,e);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){let t=this.coordinateSystem,e=this.children.concat(),[n,s,r,a,o,c]=e;for(let l of e)this.remove(l);if(t===on)n.up.set(0,1,0),n.lookAt(1,0,0),s.up.set(0,1,0),s.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),c.up.set(0,1,0),c.lookAt(0,0,-1);else if(t===Ts)n.up.set(0,-1,0),n.lookAt(-1,0,0),s.up.set(0,-1,0),s.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),c.up.set(0,-1,0),c.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+t);for(let l of e)this.add(l),l.updateMatrixWorld()}update(t,e){this.parent===null&&this.updateMatrixWorld();let n=this.renderTarget;this.coordinateSystem!==t.coordinateSystem&&(this.coordinateSystem=t.coordinateSystem,this.updateCoordinateSystem());let[s,r,a,o,c,l]=this.children,h=t.getRenderTarget(),d=t.xr.enabled;t.xr.enabled=!1;let u=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=u,t.setRenderTarget(n,5),t.render(e,l),t.setRenderTarget(h),t.xr.enabled=d,n.texture.needsPMREMUpdate=!0}},Ns=class extends ge{constructor(t,e,n,s,r,a,o,c,l,h){t=t!==void 0?t:[],e=e!==void 0?e:mi,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}},Gr=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&&(Vi("THREE.WebGLCubeRenderTarget: option.encoding has been replaced by option.colorSpace."),e.colorSpace=e.encoding===Bn?Rt:zn),this.texture=new Ns(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:Ie}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 kn(5,5,5),r=new ln({name:"CubemapFromEquirect",uniforms:vi(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:he,blending:vn});r.uniforms.tEquirect.value=e;let a=new Ye(s,r),o=e.minFilter;return e.minFilter===Hi&&(e.minFilter=Ie),new Hr(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)}},Ar=new P,Mh=new P,Sh=new Ct,Ce=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=Ar.subVectors(n,e).cross(Mh.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(Ar),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||Sh.getNormalMatrix(t),s=this.coplanarPoint(Ar).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)}},Un=new Vn,xs=new P,Fs=class{constructor(t=new Ce,e=new Ce,n=new Ce,s=new Ce,r=new Ce,a=new Ce){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,e=on){let n=this.planes,s=t.elements,r=s[0],a=s[1],o=s[2],c=s[3],l=s[4],h=s[5],d=s[6],u=s[7],m=s[8],g=s[9],x=s[10],p=s[11],f=s[12],v=s[13],_=s[14],b=s[15];if(n[0].setComponents(c-r,u-l,p-m,b-f).normalize(),n[1].setComponents(c+r,u+l,p+m,b+f).normalize(),n[2].setComponents(c+a,u+h,p+g,b+v).normalize(),n[3].setComponents(c-a,u-h,p-g,b-v).normalize(),n[4].setComponents(c-o,u-d,p-x,b-_).normalize(),e===on)n[5].setComponents(c+o,u+d,p+x,b+_).normalize();else if(e===Ts)n[5].setComponents(o,d,x,_).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+e);return this}intersectsObject(t){if(t.boundingSphere!==void 0)t.boundingSphere===null&&t.computeBoundingSphere(),Un.copy(t.boundingSphere).applyMatrix4(t.matrixWorld);else{let e=t.geometry;e.boundingSphere===null&&e.computeBoundingSphere(),Un.copy(e.boundingSphere).applyMatrix4(t.matrixWorld)}return this.intersectsSphere(Un)}intersectsSprite(t){return Un.center.set(0,0,0),Un.radius=.7071067811865476,Un.applyMatrix4(t.matrixWorld),this.intersectsSphere(Un)}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(xs.x=s.normal.x>0?t.max.x:t.min.x,xs.y=s.normal.y>0?t.max.y:t.min.y,xs.z=s.normal.z>0?t.max.z:t.min.z,s.distanceToPoint(xs)<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 bc(){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 bh(i,t){let e=t.isWebGL2,n=new WeakMap;function s(l,h){let d=l.array,u=l.usage,m=i.createBuffer();i.bindBuffer(h,m),i.bufferData(h,d,u),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:m,type:g,bytesPerElement:d.BYTES_PER_ELEMENT,version:l.version}}function r(l,h,d){let u=h.array,m=h.updateRange;i.bindBuffer(d,l),m.count===-1?i.bufferSubData(d,0,u):(e?i.bufferSubData(d,m.offset*u.BYTES_PER_ELEMENT,u,m.offset,m.count):i.bufferSubData(d,m.offset*u.BYTES_PER_ELEMENT,u.subarray(m.offset,m.offset+m.count)),m.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 u=n.get(l);(!u||u.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 Wi=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,u=e/c,m=[],g=[],x=[],p=[];for(let f=0;f<h;f++){let v=f*u-a;for(let _=0;_<l;_++){let b=_*d-r;g.push(b,-v,0),x.push(0,0,1),p.push(_/o),p.push(1-f/c)}}for(let f=0;f<c;f++)for(let v=0;v<o;v++){let _=v+l*f,b=v+l*(f+1),S=v+1+l*(f+1),T=v+1+l*f;m.push(_,b,T),m.push(b,S,T)}this.setIndex(m),this.setAttribute("position",new an(g,3)),this.setAttribute("normal",new an(x,3)),this.setAttribute("uv",new an(p,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Wi(t.width,t.height,t.widthSegments,t.heightSegments)}},Eh=`#ifdef USE_ALPHAHASH\n\tif ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;\n#endif`,Th=`#ifdef USE_ALPHAHASH\n\tconst float ALPHA_HASH_SCALE = 0.05;\n\tfloat hash2D( vec2 value ) {\n\t\treturn fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );\n\t}\n\tfloat hash3D( vec3 value ) {\n\t\treturn hash2D( vec2( hash2D( value.xy ), value.z ) );\n\t}\n\tfloat getAlphaHashThreshold( vec3 position ) {\n\t\tfloat maxDeriv = max(\n\t\t\tlength( dFdx( position.xyz ) ),\n\t\t\tlength( dFdy( position.xyz ) )\n\t\t);\n\t\tfloat pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );\n\t\tvec2 pixScales = vec2(\n\t\t\texp2( floor( log2( pixScale ) ) ),\n\t\t\texp2( ceil( log2( pixScale ) ) )\n\t\t);\n\t\tvec2 alpha = vec2(\n\t\t\thash3D( floor( pixScales.x * position.xyz ) ),\n\t\t\thash3D( floor( pixScales.y * position.xyz ) )\n\t\t);\n\t\tfloat lerpFactor = fract( log2( pixScale ) );\n\t\tfloat x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;\n\t\tfloat a = min( lerpFactor, 1.0 - lerpFactor );\n\t\tvec3 cases = vec3(\n\t\t\tx * x / ( 2.0 * a * ( 1.0 - a ) ),\n\t\t\t( x - 0.5 * a ) / ( 1.0 - a ),\n\t\t\t1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )\n\t\t);\n\t\tfloat threshold = ( x < ( 1.0 - a ) )\n\t\t\t? ( ( x < a ) ? cases.x : cases.y )\n\t\t\t: cases.z;\n\t\treturn clamp( threshold , 1.0e-6, 1.0 );\n\t}\n#endif`,wh=`#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;\n#endif`,Ah=`#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif`,Rh=`#ifdef USE_ALPHATEST\n\tif ( diffuseColor.a < alphaTest ) discard;\n#endif`,Ch=`#ifdef USE_ALPHATEST\n\tuniform float alphaTest;\n#endif`,Ph=`#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`,Lh=`#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif`,Ih=`vec3 transformed = vec3( position );\n#ifdef USE_ALPHAHASH\n\tvPosition = vec3( position );\n#endif`,Uh=`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`,Nh=`#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\treturn 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 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`,Fh=`#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`,Oh=`#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`,Bh=`#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif`,zh=`#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n#endif`,Vh=`#if NUM_CLIPPING_PLANES > 0\n\tvClipPosition = - mvPosition.xyz;\n#endif`,kh=`#if defined( USE_COLOR_ALPHA )\n\tdiffuseColor *= vColor;\n#elif defined( USE_COLOR )\n\tdiffuseColor.rgb *= vColor;\n#endif`,Hh=`#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR )\n\tvarying vec3 vColor;\n#endif`,Gh=`#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvarying vec3 vColor;\n#endif`,Wh=`#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`,Xh=`#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};\n#ifdef USE_ALPHAHASH\n\tvarying vec3 vPosition;\n#endif\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`,qh=`#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`,Yh=`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`,Zh=`#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif`,Jh=`#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );\n#endif`,$h=`#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif`,Kh=`#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif`,Qh="gl_FragColor = linearToOutputTexel( gl_FragColor );",jh=`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}`,tu=`#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`,eu=`#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`,nu=`#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`,iu=`#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`,su=`#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`,ru=`#ifdef USE_FOG\n\tvFogDepth = - mvPosition.z;\n#endif`,ou=`#ifdef USE_FOG\n\tvarying float vFogDepth;\n#endif`,au=`#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`,cu=`#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`,lu=`#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}`,hu=`#ifdef USE_LIGHTMAP\n\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\treflectedLight.indirectDiffuse += lightMapIrradiance;\n#endif`,uu=`#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif`,fu=`LambertMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularStrength = specularStrength;`,du=`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`,pu=`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`,mu=`#ifdef USE_ENVMAP\n\tvec3 getIBLIrradiance( const in vec3 normal ) {\n\t\t#ifdef 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#ifdef 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\t#ifdef USE_ANISOTROPY\n\t\tvec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {\n\t\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\t\tvec3 bentNormal = cross( bitangent, viewDir );\n\t\t\t\tbentNormal = normalize( cross( bentNormal, bitangent ) );\n\t\t\t\tbentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );\n\t\t\t\treturn getIBLRadiance( viewDir, bentNormal, roughness );\n\t\t\t#else\n\t\t\t\treturn vec3( 0.0 );\n\t\t\t#endif\n\t\t}\n\t#endif\n#endif`,gu=`ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;`,_u=`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`,xu=`BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;`,yu=`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`,vu=`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\n#ifdef USE_ANISOTROPY\n\t#ifdef USE_ANISOTROPYMAP\n\t\tmat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );\n\t\tvec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;\n\t\tvec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;\n\t#else\n\t\tvec2 anisotropyV = anisotropyVector;\n\t#endif\n\tmaterial.anisotropy = length( anisotropyV );\n\tanisotropyV /= material.anisotropy;\n\tmaterial.anisotropy = saturate( material.anisotropy );\n\tmaterial.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );\n\tmaterial.anisotropyT = tbn[ 0 ] * anisotropyV.x - tbn[ 1 ] * anisotropyV.y;\n\tmaterial.anisotropyB = tbn[ 1 ] * anisotropyV.x + tbn[ 0 ] * anisotropyV.y;\n#endif`,Mu=`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\t#ifdef USE_ANISOTROPY\n\t\tfloat anisotropy;\n\t\tfloat alphaT;\n\t\tvec3 anisotropyT;\n\t\tvec3 anisotropyB;\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_ANISOTROPY\n\tfloat V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {\n\t\tfloat gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );\n\t\tfloat gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );\n\t\tfloat v = 0.5 / ( gv + gl );\n\t\treturn saturate(v);\n\t}\n\tfloat D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {\n\t\tfloat a2 = alphaT * alphaB;\n\t\thighp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );\n\t\thighp float v2 = dot( v, v );\n\t\tfloat w2 = a2 / v2;\n\t\treturn RECIPROCAL_PI * a2 * pow2 ( w2 );\n\t}\n#endif\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\t#ifdef USE_ANISOTROPY\n\t\tfloat dotTL = dot( material.anisotropyT, lightDir );\n\t\tfloat dotTV = dot( material.anisotropyT, viewDir );\n\t\tfloat dotTH = dot( material.anisotropyT, halfDir );\n\t\tfloat dotBL = dot( material.anisotropyB, lightDir );\n\t\tfloat dotBV = dot( material.anisotropyB, viewDir );\n\t\tfloat dotBH = dot( material.anisotropyB, halfDir );\n\t\tfloat V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );\n\t\tfloat D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );\n\t#else\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t#endif\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}`,Su=`\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`,bu=`#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\t#ifdef USE_ANISOTROPY\n\t\tradiance += getIBLAnisotropyRadiance( geometry.viewDir, geometry.normal, material.roughness, material.anisotropyB, material.anisotropy );\n\t#else\n\t\tradiance += getIBLRadiance( geometry.viewDir, geometry.normal, material.roughness );\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatRadiance += getIBLRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness );\n\t#endif\n#endif`,Eu=`#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`,Tu=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif`,wu=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif`,Au=`#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`,Ru=`#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`,Pu=`#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif`,Lu=`#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`,Iu=`#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`,Uu=`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`,Nu=`#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`,Fu=`#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`,Ou=`#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`,Bu=`#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`,zu=`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#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )\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,\n\t\t#if defined( USE_NORMALMAP )\n\t\t\tvNormalMapUv\n\t\t#elif defined( USE_CLEARCOAT_NORMALMAP )\n\t\t\tvClearcoatNormalMapUv\n\t\t#else\n\t\t\tvUv\n\t\t#endif\n\t\t);\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;`,Vu=`#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`,ku=`#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`,Hu=`#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`,Gu=`#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`,Wu=`#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 ) || defined( USE_ANISOTROPY ) )\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`,Xu=`#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal = geometryNormal;\n#endif`,qu=`#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`,Yu=`#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`,Zu=`#ifdef USE_IRIDESCENCEMAP\n\tuniform sampler2D iridescenceMap;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform sampler2D iridescenceThicknessMap;\n#endif`,Ju=`#ifdef OPAQUE\ndiffuseColor.a = 1.0;\n#endif\n#ifdef USE_TRANSMISSION\ndiffuseColor.a *= material.transmissionAlpha;\n#endif\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );`,$u=`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}`,Ku=`#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif`,Qu=`vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;`,ju=`#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif`,tf=`#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`,ef=`float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );\n\troughnessFactor *= texelRoughness.g;\n#endif`,nf=`#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif`,sf=`#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`,rf=`#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`,of=`#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`,af=`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}`,cf=`#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`,lf=`#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`,hf=`#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`,uf=`#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`,ff=`float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif`,df=`#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif`,pf=`#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif`,mf=`#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn saturate( 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; }`,gf=`#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 transmitted = 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, transmitted.a, material.transmission );\n\ttotalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );\n#endif`,_f=`#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 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tif ( isinf( attenuationDistance ) ) {\n\t\t\treturn vec3( 1.0 );\n\t\t} else {\n\t\t\tvec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;\n\t\t\tvec3 transmittance = exp( - attenuationCoefficient * transmissionDistance );\t\t\treturn transmittance;\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 transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );\n\t\tvec3 attenuatedColor = transmittance * transmittedLight.rgb;\n\t\tvec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );\n\t\tfloat transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;\n\t\treturn vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );\n\t}\n#endif`,xf=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )\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_ANISOTROPYMAP\n\tvarying vec2 vAnisotropyMapUv;\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`,yf=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )\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_ANISOTROPYMAP\n\tuniform mat3 anisotropyMapTransform;\n\tvarying vec2 vAnisotropyMapUv;\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`,vf=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )\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_ANISOTROPYMAP\n\tvAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_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`,Mf=`#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`,Sf=`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}`,bf=`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 <colorspace_fragment>\n}`,Ef=`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}`,Tf=`#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 <colorspace_fragment>\n}`,wf=`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}`,Af=`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 <colorspace_fragment>\n}`,Rf=`#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 <alphahash_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 <alphahash_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}`,Pf=`#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}`,Lf=`#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 <alphahash_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\t#include <alphahash_fragment>\n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}`,If=`varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n}`,Uf=`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 <colorspace_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}`,Nf=`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 <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}`,Ff=`#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}`,Of=`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 <alphahash_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 <alphahash_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 <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}`,Bf=`#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}`,zf=`#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 <alphahash_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 <alphahash_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 <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}`,Vf=`#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}`,kf=`#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 <alphahash_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 <alphahash_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 <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}`,Hf=`#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}`,Gf=`#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}`,Wf=`#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}`,Xf=`#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 <alphahash_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 <alphahash_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 <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}`,qf=`#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}`,Yf=`#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\n#ifdef USE_ANISOTROPY\n\tuniform vec2 anisotropyVector;\n\t#ifdef USE_ANISOTROPYMAP\n\t\tuniform sampler2D anisotropyMap;\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 <alphahash_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 <alphahash_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 <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}`,Zf=`#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}`,Jf=`#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 <alphahash_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 <alphahash_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 <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}`,$f=`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}`,Kf=`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 <alphahash_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\t#include <alphahash_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}`,Qf=`#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}`,jf=`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 <colorspace_fragment>\n\t#include <fog_fragment>\n}`,td=`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}`,ed=`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 <alphahash_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\t#include <alphahash_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n}`,At={alphahash_fragment:Eh,alphahash_pars_fragment:Th,alphamap_fragment:wh,alphamap_pars_fragment:Ah,alphatest_fragment:Rh,alphatest_pars_fragment:Ch,aomap_fragment:Ph,aomap_pars_fragment:Lh,begin_vertex:Ih,beginnormal_vertex:Uh,bsdfs:Dh,iridescence_fragment:Nh,bumpmap_pars_fragment:Fh,clipping_planes_fragment:Oh,clipping_planes_pars_fragment:Bh,clipping_planes_pars_vertex:zh,clipping_planes_vertex:Vh,color_fragment:kh,color_pars_fragment:Hh,color_pars_vertex:Gh,color_vertex:Wh,common:Xh,cube_uv_reflection_fragment:qh,defaultnormal_vertex:Yh,displacementmap_pars_vertex:Zh,displacementmap_vertex:Jh,emissivemap_fragment:$h,emissivemap_pars_fragment:Kh,colorspace_fragment:Qh,colorspace_pars_fragment:jh,envmap_fragment:tu,envmap_common_pars_fragment:eu,envmap_pars_fragment:nu,envmap_pars_vertex:iu,envmap_physical_pars_fragment:mu,envmap_vertex:su,fog_vertex:ru,fog_pars_vertex:ou,fog_fragment:au,fog_pars_fragment:cu,gradientmap_pars_fragment:lu,lightmap_fragment:hu,lightmap_pars_fragment:uu,lights_lambert_fragment:fu,lights_lambert_pars_fragment:du,lights_pars_begin:pu,lights_toon_fragment:gu,lights_toon_pars_fragment:_u,lights_phong_fragment:xu,lights_phong_pars_fragment:yu,lights_physical_fragment:vu,lights_physical_pars_fragment:Mu,lights_fragment_begin:Su,lights_fragment_maps:bu,lights_fragment_end:Eu,logdepthbuf_fragment:Tu,logdepthbuf_pars_fragment:wu,logdepthbuf_pars_vertex:Au,logdepthbuf_vertex:Ru,map_fragment:Cu,map_pars_fragment:Pu,map_particle_fragment:Lu,map_particle_pars_fragment:Iu,metalnessmap_fragment:Uu,metalnessmap_pars_fragment:Du,morphcolor_vertex:Nu,morphnormal_vertex:Fu,morphtarget_pars_vertex:Ou,morphtarget_vertex:Bu,normal_fragment_begin:zu,normal_fragment_maps:Vu,normal_pars_fragment:ku,normal_pars_vertex:Hu,normal_vertex:Gu,normalmap_pars_fragment:Wu,clearcoat_normal_fragment_begin:Xu,clearcoat_normal_fragment_maps:qu,clearcoat_pars_fragment:Yu,iridescence_pars_fragment:Zu,opaque_fragment:Ju,packing:$u,premultiplied_alpha_fragment:Ku,project_vertex:Qu,dithering_fragment:ju,dithering_pars_fragment:tf,roughnessmap_fragment:ef,roughnessmap_pars_fragment:nf,shadowmap_pars_fragment:sf,shadowmap_pars_vertex:rf,shadowmap_vertex:of,shadowmask_pars_fragment:af,skinbase_vertex:cf,skinning_pars_vertex:lf,skinning_vertex:hf,skinnormal_vertex:uf,specularmap_fragment:ff,specularmap_pars_fragment:df,tonemapping_fragment:pf,tonemapping_pars_fragment:mf,transmission_fragment:gf,transmission_pars_fragment:_f,uv_pars_fragment:xf,uv_pars_vertex:yf,uv_vertex:vf,worldpos_vertex:Mf,background_vert:Sf,background_frag:bf,backgroundCube_vert:Ef,backgroundCube_frag:Tf,cube_vert:wf,cube_frag:Af,depth_vert:Rf,depth_frag:Cf,distanceRGBA_vert:Pf,distanceRGBA_frag:Lf,equirect_vert:If,equirect_frag:Uf,linedashed_vert:Df,linedashed_frag:Nf,meshbasic_vert:Ff,meshbasic_frag:Of,meshlambert_vert:Bf,meshlambert_frag:zf,meshmatcap_vert:Vf,meshmatcap_frag:kf,meshnormal_vert:Hf,meshnormal_frag:Gf,meshphong_vert:Wf,meshphong_frag:Xf,meshphysical_vert:qf,meshphysical_frag:Yf,meshtoon_vert:Zf,meshtoon_frag:Jf,points_vert:$f,points_frag:Kf,shadow_vert:Qf,shadow_frag:jf,sprite_vert:td,sprite_frag:ed},it={common:{diffuse:{value:new kt(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 Nt(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 kt(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 kt(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Ct},alphaTest:{value:0},uvTransform:{value:new Ct}},sprite:{diffuse:{value:new kt(16777215)},opacity:{value:1},center:{value:new Nt(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Ct},alphaMap:{value:null},alphaMapTransform:{value:new Ct},alphaTest:{value:0}}},qe={basic:{uniforms:de([it.common,it.specularmap,it.envmap,it.aomap,it.lightmap,it.fog]),vertexShader:At.meshbasic_vert,fragmentShader:At.meshbasic_frag},lambert:{uniforms:de([it.common,it.specularmap,it.envmap,it.aomap,it.lightmap,it.emissivemap,it.bumpmap,it.normalmap,it.displacementmap,it.fog,it.lights,{emissive:{value:new kt(0)}}]),vertexShader:At.meshlambert_vert,fragmentShader:At.meshlambert_frag},phong:{uniforms:de([it.common,it.specularmap,it.envmap,it.aomap,it.lightmap,it.emissivemap,it.bumpmap,it.normalmap,it.displacementmap,it.fog,it.lights,{emissive:{value:new kt(0)},specular:{value:new kt(1118481)},shininess:{value:30}}]),vertexShader:At.meshphong_vert,fragmentShader:At.meshphong_frag},standard:{uniforms:de([it.common,it.envmap,it.aomap,it.lightmap,it.emissivemap,it.bumpmap,it.normalmap,it.displacementmap,it.roughnessmap,it.metalnessmap,it.fog,it.lights,{emissive:{value:new kt(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:At.meshphysical_vert,fragmentShader:At.meshphysical_frag},toon:{uniforms:de([it.common,it.aomap,it.lightmap,it.emissivemap,it.bumpmap,it.normalmap,it.displacementmap,it.gradientmap,it.fog,it.lights,{emissive:{value:new kt(0)}}]),vertexShader:At.meshtoon_vert,fragmentShader:At.meshtoon_frag},matcap:{uniforms:de([it.common,it.bumpmap,it.normalmap,it.displacementmap,it.fog,{matcap:{value:null}}]),vertexShader:At.meshmatcap_vert,fragmentShader:At.meshmatcap_frag},points:{uniforms:de([it.points,it.fog]),vertexShader:At.points_vert,fragmentShader:At.points_frag},dashed:{uniforms:de([it.common,it.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:At.linedashed_vert,fragmentShader:At.linedashed_frag},depth:{uniforms:de([it.common,it.displacementmap]),vertexShader:At.depth_vert,fragmentShader:At.depth_frag},normal:{uniforms:de([it.common,it.bumpmap,it.normalmap,it.displacementmap,{opacity:{value:1}}]),vertexShader:At.meshnormal_vert,fragmentShader:At.meshnormal_frag},sprite:{uniforms:de([it.sprite,it.fog]),vertexShader:At.sprite_vert,fragmentShader:At.sprite_frag},background:{uniforms:{uvTransform:{value:new Ct},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:At.background_vert,fragmentShader:At.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:At.backgroundCube_vert,fragmentShader:At.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:At.cube_vert,fragmentShader:At.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:At.equirect_vert,fragmentShader:At.equirect_frag},distanceRGBA:{uniforms:de([it.common,it.displacementmap,{referencePosition:{value:new P},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:At.distanceRGBA_vert,fragmentShader:At.distanceRGBA_frag},shadow:{uniforms:de([it.lights,it.fog,{color:{value:new kt(0)},opacity:{value:1}}]),vertexShader:At.shadow_vert,fragmentShader:At.shadow_frag}};qe.physical={uniforms:de([qe.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Ct},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Ct},clearcoatNormalScale:{value:new Nt(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 kt(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 Nt},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Ct},attenuationDistance:{value:0},attenuationColor:{value:new kt(0)},specularColor:{value:new kt(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Ct},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Ct},anisotropyVector:{value:new Nt},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Ct}}]),vertexShader:At.meshphysical_vert,fragmentShader:At.meshphysical_frag};var ys={r:0,b:0,g:0};function nd(i,t,e,n,s,r,a){let o=new kt(0),c=r===!0?0:1,l,h,d=null,u=0,m=null;function g(p,f){let v=!1,_=f.isScene===!0?f.background:null;switch(_&&_.isTexture&&(_=(f.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===Bs)?(h===void 0&&(h=new Ye(new kn(1,1,1),new ln({name:"BackgroundCubeMaterial",uniforms:vi(qe.backgroundCube.uniforms),vertexShader:qe.backgroundCube.vertexShader,fragmentShader:qe.backgroundCube.fragmentShader,side:he,depthTest:!1,depthWrite:!1,fog:!1})),h.geometry.deleteAttribute("normal"),h.geometry.deleteAttribute("uv"),h.onBeforeRender=function(T,A,L){this.matrixWorld.copyPosition(L.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=f.backgroundBlurriness,h.material.uniforms.backgroundIntensity.value=f.backgroundIntensity,h.material.toneMapped=_.colorSpace!==Rt,(d!==_||u!==_.version||m!==i.toneMapping)&&(h.material.needsUpdate=!0,d=_,u=_.version,m=i.toneMapping),h.layers.enableAll(),p.unshift(h,h.geometry,h.material,0,0,null)):_&&_.isTexture&&(l===void 0&&(l=new Ye(new Wi(2,2),new ln({name:"BackgroundMaterial",uniforms:vi(qe.background.uniforms),vertexShader:qe.background.vertexShader,fragmentShader:qe.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=f.backgroundIntensity,l.material.toneMapped=_.colorSpace!==Rt,_.matrixAutoUpdate===!0&&_.updateMatrix(),l.material.uniforms.uvTransform.value.copy(_.matrix),(d!==_||u!==_.version||m!==i.toneMapping)&&(l.material.needsUpdate=!0,d=_,u=_.version,m=i.toneMapping),l.layers.enableAll(),p.unshift(l,l.geometry,l.material,0,0,null))}function x(p,f){p.getRGB(ys,Sc(i)),n.buffers.color.setClear(ys.r,ys.g,ys.b,f,a)}return{getClearColor:function(){return o},setClearColor:function(p,f=1){o.set(p),c=f,x(o,c)},getClearAlpha:function(){return c},setClearAlpha:function(p){c=p,x(o,c)},render:g}}function id(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=p(null),l=c,h=!1;function d(D,O,$,G,q){let J=!1;if(a){let K=x(G,$,O);l!==K&&(l=K,m(l.object)),J=f(D,G,$,q),J&&v(D,G,$,q)}else{let K=O.wireframe===!0;(l.geometry!==G.id||l.program!==$.id||l.wireframe!==K)&&(l.geometry=G.id,l.program=$.id,l.wireframe=K,J=!0)}q!==null&&e.update(q,i.ELEMENT_ARRAY_BUFFER),(J||h)&&(h=!1,L(D,O,$,G),q!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e.get(q).buffer))}function u(){return n.isWebGL2?i.createVertexArray():r.createVertexArrayOES()}function m(D){return n.isWebGL2?i.bindVertexArray(D):r.bindVertexArrayOES(D)}function g(D){return n.isWebGL2?i.deleteVertexArray(D):r.deleteVertexArrayOES(D)}function x(D,O,$){let G=$.wireframe===!0,q=o[D.id];q===void 0&&(q={},o[D.id]=q);let J=q[O.id];J===void 0&&(J={},q[O.id]=J);let K=J[G];return K===void 0&&(K=p(u()),J[G]=K),K}function p(D){let O=[],$=[],G=[];for(let q=0;q<s;q++)O[q]=0,$[q]=0,G[q]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:O,enabledAttributes:$,attributeDivisors:G,object:D,attributes:{},index:null}}function f(D,O,$,G){let q=l.attributes,J=O.attributes,K=0,B=$.getAttributes();for(let Z in B)if(B[Z].location>=0){let at=q[Z],ct=J[Z];if(ct===void 0&&(Z==="instanceMatrix"&&D.instanceMatrix&&(ct=D.instanceMatrix),Z==="instanceColor"&&D.instanceColor&&(ct=D.instanceColor)),at===void 0||at.attribute!==ct||ct&&at.data!==ct.data)return!0;K++}return l.attributesNum!==K||l.index!==G}function v(D,O,$,G){let q={},J=O.attributes,K=0,B=$.getAttributes();for(let Z in B)if(B[Z].location>=0){let at=J[Z];at===void 0&&(Z==="instanceMatrix"&&D.instanceMatrix&&(at=D.instanceMatrix),Z==="instanceColor"&&D.instanceColor&&(at=D.instanceColor));let ct={};ct.attribute=at,at&&at.data&&(ct.data=at.data),q[Z]=ct,K++}l.attributes=q,l.attributesNum=K,l.index=G}function _(){let D=l.newAttributes;for(let O=0,$=D.length;O<$;O++)D[O]=0}function b(D){S(D,0)}function S(D,O){let $=l.newAttributes,G=l.enabledAttributes,q=l.attributeDivisors;$[D]=1,G[D]===0&&(i.enableVertexAttribArray(D),G[D]=1),q[D]!==O&&((n.isWebGL2?i:t.get("ANGLE_instanced_arrays"))[n.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](D,O),q[D]=O)}function T(){let D=l.newAttributes,O=l.enabledAttributes;for(let $=0,G=O.length;$<G;$++)O[$]!==D[$]&&(i.disableVertexAttribArray($),O[$]=0)}function A(D,O,$,G,q,J,K){K===!0?i.vertexAttribIPointer(D,O,$,q,J):i.vertexAttribPointer(D,O,$,G,q,J)}function L(D,O,$,G){if(n.isWebGL2===!1&&(D.isInstancedMesh||G.isInstancedBufferGeometry)&&t.get("ANGLE_instanced_arrays")===null)return;_();let q=G.attributes,J=$.getAttributes(),K=O.defaultAttributeValues;for(let B in J){let Z=J[B];if(Z.location>=0){let ot=q[B];if(ot===void 0&&(B==="instanceMatrix"&&D.instanceMatrix&&(ot=D.instanceMatrix),B==="instanceColor"&&D.instanceColor&&(ot=D.instanceColor)),ot!==void 0){let at=ot.normalized,ct=ot.itemSize,_t=e.get(ot);if(_t===void 0)continue;let Et=_t.buffer,xt=_t.type,zt=_t.bytesPerElement,xe=n.isWebGL2===!0&&(xt===i.INT||xt===i.UNSIGNED_INT||ot.gpuType===fc);if(ot.isInterleavedBufferAttribute){let Pt=ot.data,F=Pt.stride,oe=ot.offset;if(Pt.isInstancedInterleavedBuffer){for(let yt=0;yt<Z.locationSize;yt++)S(Z.location+yt,Pt.meshPerAttribute);D.isInstancedMesh!==!0&&G._maxInstanceCount===void 0&&(G._maxInstanceCount=Pt.meshPerAttribute*Pt.count)}else for(let yt=0;yt<Z.locationSize;yt++)b(Z.location+yt);i.bindBuffer(i.ARRAY_BUFFER,Et);for(let yt=0;yt<Z.locationSize;yt++)A(Z.location+yt,ct/Z.locationSize,xt,at,F*zt,(oe+ct/Z.locationSize*yt)*zt,xe)}else{if(ot.isInstancedBufferAttribute){for(let Pt=0;Pt<Z.locationSize;Pt++)S(Z.location+Pt,ot.meshPerAttribute);D.isInstancedMesh!==!0&&G._maxInstanceCount===void 0&&(G._maxInstanceCount=ot.meshPerAttribute*ot.count)}else for(let Pt=0;Pt<Z.locationSize;Pt++)b(Z.location+Pt);i.bindBuffer(i.ARRAY_BUFFER,Et);for(let Pt=0;Pt<Z.locationSize;Pt++)A(Z.location+Pt,ct/Z.locationSize,xt,at,ct*zt,ct/Z.locationSize*Pt*zt,xe)}}else if(K!==void 0){let at=K[B];if(at!==void 0)switch(at.length){case 2:i.vertexAttrib2fv(Z.location,at);break;case 3:i.vertexAttrib3fv(Z.location,at);break;case 4:i.vertexAttrib4fv(Z.location,at);break;default:i.vertexAttrib1fv(Z.location,at)}}}}T()}function y(){Y();for(let D in o){let O=o[D];for(let $ in O){let G=O[$];for(let q in G)g(G[q].object),delete G[q];delete O[$]}delete o[D]}}function w(D){if(o[D.id]===void 0)return;let O=o[D.id];for(let $ in O){let G=O[$];for(let q in G)g(G[q].object),delete G[q];delete O[$]}delete o[D.id]}function z(D){for(let O in o){let $=o[O];if($[D.id]===void 0)continue;let G=$[D.id];for(let q in G)g(G[q].object),delete G[q];delete $[D.id]}}function Y(){I(),h=!0,l!==c&&(l=c,m(l.object))}function I(){c.geometry=null,c.program=null,c.wireframe=!1}return{setup:d,reset:Y,resetDefaultState:I,dispose:y,releaseStatesOfGeometry:w,releaseStatesOfProgram:z,initAttributes:_,enableAttribute:b,disableUnusedAttributes:T}}function sd(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 u,m;if(s)u=i,m="drawArraysInstanced";else if(u=t.get("ANGLE_instanced_arrays"),m="drawArraysInstancedANGLE",u===null){console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}u[m](r,l,h,d),e.update(h,r,d)}this.setMode=a,this.render=o,this.renderInstances=c}function rd(i,t,e){let n;function s(){if(n!==void 0)return n;if(t.has("EXT_texture_filter_anisotropic")===!0){let A=t.get("EXT_texture_filter_anisotropic");n=i.getParameter(A.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else n=0;return n}function r(A){if(A==="highp"){if(i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.HIGH_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision>0)return"highp";A="mediump"}return A==="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),u=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),f=i.getParameter(i.MAX_VARYING_VECTORS),v=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),_=u>0,b=a||t.has("OES_texture_float"),S=_&&b,T=a?i.getParameter(i.MAX_SAMPLES):0;return{isWebGL2:a,drawBuffers:l,getMaxAnisotropy:s,getMaxPrecision:r,precision:o,logarithmicDepthBuffer:h,maxTextures:d,maxVertexTextures:u,maxTextureSize:m,maxCubemapSize:g,maxAttributes:x,maxVertexUniforms:p,maxVaryings:f,maxFragmentUniforms:v,vertexTextures:_,floatFragmentTextures:b,floatVertexTextures:S,maxSamples:T}}function od(i){let t=this,e=null,n=0,s=!1,r=!1,a=new Ce,o=new Ct,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(d,u){let m=d.length!==0||u||n!==0||s;return s=u,n=d.length,m},this.beginShadows=function(){r=!0,h(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(d,u){e=h(d,u,0)},this.setState=function(d,u,m){let g=d.clippingPlanes,x=d.clipIntersection,p=d.clipShadows,f=i.get(d);if(!s||g===null||g.length===0||r&&!p)r?h(null):l();else{let v=r?0:n,_=v*4,b=f.clippingState||null;c.value=b,b=h(g,u,_,m);for(let S=0;S!==_;++S)b[S]=e[S];f.clippingState=b,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,u,m,g){let x=d!==null?d.length:0,p=null;if(x!==0){if(p=c.value,g!==!0||p===null){let f=m+x*4,v=u.matrixWorldInverse;o.getNormalMatrix(v),(p===null||p.length<f)&&(p=new Float32Array(f));for(let _=0,b=m;_!==x;++_,b+=4)a.copy(d[_]).applyMatrix4(v,o),a.normal.toArray(p,b),p[b+3]=a.constant}c.value=p,c.needsUpdate=!0}return t.numPlanes=x,t.numIntersection=0,p}}function ad(i){let t=new WeakMap;function e(a,o){return o===Ir?a.mapping=mi:o===Ur&&(a.mapping=gi),a}function n(a){if(a&&a.isTexture&&a.isRenderTargetTexture===!1){let o=a.mapping;if(o===Ir||o===Ur)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 Gr(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 Wr=class extends Ds{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.coordinateSystem),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}},hi=4,za=[.125,.215,.35,.446,.526,.582],Nn=20,Rr=new Wr,Va=new kt,Cr=null,Dn=(1+Math.sqrt(5))/2,ci=1/Dn,ka=[new P(1,1,1),new P(-1,1,1),new P(1,1,-1),new P(-1,1,-1),new P(0,Dn,ci),new P(0,Dn,-ci),new P(ci,0,Dn),new P(-ci,0,Dn),new P(Dn,ci,0),new P(-Dn,ci,0)],Os=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){Cr=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=Wa(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Ga(),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(Cr),t.scissorTest=!1,vs(t,0,0,t.width,t.height)}_fromTexture(t,e){t.mapping===mi||t.mapping===gi?this._setSize(t.image.length===0?16:t.image[0].width||t.image[0].image.width):this._setSize(t.image.width/4),Cr=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:Ie,minFilter:Ie,generateMipmaps:!1,type:Gi,format:ke,colorSpace:Ze,depthBuffer:!1},s=Ha(t,e,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==t||this._pingPongRenderTarget.height!==e){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=Ha(t,e,n);let{_lodMax:r}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=cd(r)),this._blurMaterial=ld(r,t,e)}return s}_compileMaterial(t){let e=new Ye(this._lodPlanes[0],t);this._renderer.compile(e,Rr)}_sceneToCubeUV(t,e,n,s){let o=new Re(90,1,e,n),c=[1,-1,1,1,1,1],l=[1,1,1,-1,-1,-1],h=this._renderer,d=h.autoClear,u=h.toneMapping;h.getClearColor(Va),h.toneMapping=Mn,h.autoClear=!1;let m=new Ls({name:"PMREM.Background",side:he,depthWrite:!1,depthTest:!1}),g=new Ye(new kn,m),x=!1,p=t.background;p?p.isColor&&(m.color.copy(p),t.background=null,x=!0):(m.color.copy(Va),x=!0);for(let f=0;f<6;f++){let v=f%3;v===0?(o.up.set(0,c[f],0),o.lookAt(l[f],0,0)):v===1?(o.up.set(0,0,c[f]),o.lookAt(0,l[f],0)):(o.up.set(0,c[f],0),o.lookAt(0,0,l[f]));let _=this._cubeSize;vs(s,v*_,f>2?_:0,_,_),h.setRenderTarget(s),x&&h.render(g,o),h.render(t,o)}g.geometry.dispose(),g.material.dispose(),h.toneMapping=u,h.autoClear=d,t.background=p}_textureToCubeUV(t,e){let n=this._renderer,s=t.mapping===mi||t.mapping===gi;s?(this._cubemapMaterial===null&&(this._cubemapMaterial=Wa()),this._cubemapMaterial.uniforms.flipEnvMap.value=t.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Ga());let r=s?this._cubemapMaterial:this._equirectMaterial,a=new Ye(this._lodPlanes[0],r),o=r.uniforms;o.envMap.value=t;let c=this._cubeSize;vs(e,0,0,3*c,2*c),n.setRenderTarget(e),n.render(a,Rr)}_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=ka[(s-1)%ka.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 Ye(this._lodPlanes[s],l),u=l.uniforms,m=this._sizeLods[n]-1,g=isFinite(r)?Math.PI/(2*m):2*Math.PI/(2*Nn-1),x=r/g,p=isFinite(r)?1+Math.floor(h*x):Nn;p>Nn&&console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${p} samples when the maximum is set to ${Nn}`);let f=[],v=0;for(let A=0;A<Nn;++A){let L=A/x,y=Math.exp(-L*L/2);f.push(y),A===0?v+=y:A<p&&(v+=2*y)}for(let A=0;A<f.length;A++)f[A]=f[A]/v;u.envMap.value=t.texture,u.samples.value=p,u.weights.value=f,u.latitudinal.value=a==="latitudinal",o&&(u.poleAxis.value=o);let{_lodMax:_}=this;u.dTheta.value=g,u.mipInt.value=_-n;let b=this._sizeLods[s],S=3*b*(s>_-hi?s-_+hi:0),T=4*(this._cubeSize-b);vs(e,S,T,3*b,2*b),c.setRenderTarget(e),c.render(d,Rr)}};function cd(i){let t=[],e=[],n=[],s=i,r=i-hi+1+za.length;for(let a=0;a<r;a++){let o=Math.pow(2,s);e.push(o);let c=1/o;a>i-hi?c=za[a-i+hi-1]:a===0&&(c=0),n.push(c);let l=1/(o-2),h=-l,d=1+l,u=[h,h,d,h,d,d,h,h,d,d,h,d],m=6,g=6,x=3,p=2,f=1,v=new Float32Array(x*g*m),_=new Float32Array(p*g*m),b=new Float32Array(f*g*m);for(let T=0;T<m;T++){let A=T%3*2/3-1,L=T>2?0:-1,y=[A,L,0,A+2/3,L,0,A+2/3,L+1,0,A,L,0,A+2/3,L+1,0,A,L+1,0];v.set(y,x*g*T),_.set(u,p*g*T);let w=[T,T,T,T,T,T];b.set(w,f*g*T)}let S=new Ge;S.setAttribute("position",new te(v,x)),S.setAttribute("uv",new te(_,p)),S.setAttribute("faceIndex",new te(b,f)),t.push(S),s>hi&&s--}return{lodPlanes:t,sizeLods:e,sigmas:n}}function Ha(i,t,e){let n=new cn(i,t,e);return n.texture.mapping=Bs,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function vs(i,t,e,n,s){i.viewport.set(t,e,n,s),i.scissor.set(t,e,n,s)}function ld(i,t,e){let n=new Float32Array(Nn),s=new P(0,1,0);return new ln({name:"SphericalGaussianBlur",defines:{n:Nn,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:_o(),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:vn,depthTest:!1,depthWrite:!1})}function Ga(){return new ln({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:_o(),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:vn,depthTest:!1,depthWrite:!1})}function Wa(){return new ln({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:_o(),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:vn,depthTest:!1,depthWrite:!1})}function _o(){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 hd(i){let t=new WeakMap,e=null;function n(o){if(o&&o.isTexture){let c=o.mapping,l=c===Ir||c===Ur,h=c===mi||c===gi;if(l||h)if(o.isRenderTargetTexture&&o.needsPMREMUpdate===!0){o.needsPMREMUpdate=!1;let d=t.get(o);return e===null&&(e=new Os(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 Os(i));let u=l?e.fromEquirectangular(o):e.fromCubemap(o);return t.set(o,u),o.addEventListener("dispose",r),u.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 ud(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 fd(i,t,e,n){let s={},r=new WeakMap;function a(d){let u=d.target;u.index!==null&&t.remove(u.index);for(let g in u.attributes)t.remove(u.attributes[g]);for(let g in u.morphAttributes){let x=u.morphAttributes[g];for(let p=0,f=x.length;p<f;p++)t.remove(x[p])}u.removeEventListener("dispose",a),delete s[u.id];let m=r.get(u);m&&(t.remove(m),r.delete(u)),n.releaseStatesOfGeometry(u),u.isInstancedBufferGeometry===!0&&delete u._maxInstanceCount,e.memory.geometries--}function o(d,u){return s[u.id]===!0||(u.addEventListener("dispose",a),s[u.id]=!0,e.memory.geometries++),u}function c(d){let u=d.attributes;for(let g in u)t.update(u[g],i.ARRAY_BUFFER);let m=d.morphAttributes;for(let g in m){let x=m[g];for(let p=0,f=x.length;p<f;p++)t.update(x[p],i.ARRAY_BUFFER)}}function l(d){let u=[],m=d.index,g=d.attributes.position,x=0;if(m!==null){let v=m.array;x=m.version;for(let _=0,b=v.length;_<b;_+=3){let S=v[_+0],T=v[_+1],A=v[_+2];u.push(S,T,T,A,A,S)}}else if(g!==void 0){let v=g.array;x=g.version;for(let _=0,b=v.length/3-1;_<b;_+=3){let S=_+0,T=_+1,A=_+2;u.push(S,T,T,A,A,S)}}else return;let p=new(vc(u)?Us:Is)(u,1);p.version=x;let f=r.get(d);f&&t.remove(f),r.set(d,p)}function h(d){let u=r.get(d);if(u){let m=d.index;m!==null&&u.version<m.version&&l(d)}else l(d);return r.get(d)}return{get:o,update:c,getWireframeAttribute:h}}function dd(i,t,e,n){let s=n.isWebGL2,r;function a(u){r=u}let o,c;function l(u){o=u.type,c=u.bytesPerElement}function h(u,m){i.drawElements(r,m,o,u*c),e.update(m,r,1)}function d(u,m,g){if(g===0)return;let x,p;if(s)x=i,p="drawElementsInstanced";else if(x=t.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,o,u*c,g),e.update(m,r,g)}this.setMode=a,this.setIndex=l,this.render=h,this.renderInstances=d}function pd(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.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 md(i,t){return i[0]-t[0]}function gd(i,t){return Math.abs(t[1])-Math.abs(i[1])}function _d(i,t,e){let n={},s=new Float32Array(8),r=new WeakMap,a=new jt,o=[];for(let l=0;l<8;l++)o[l]=[l,0];function c(l,h,d){let u=l.morphTargetInfluences;if(t.isWebGL2===!0){let m=h.morphAttributes.position||h.morphAttributes.normal||h.morphAttributes.color,g=m!==void 0?m.length:0,x=r.get(h);if(x===void 0||x.count!==g){let D=function(){Y.dispose(),r.delete(h),h.removeEventListener("dispose",D)};x!==void 0&&x.texture.dispose();let v=h.morphAttributes.position!==void 0,_=h.morphAttributes.normal!==void 0,b=h.morphAttributes.color!==void 0,S=h.morphAttributes.position||[],T=h.morphAttributes.normal||[],A=h.morphAttributes.color||[],L=0;v===!0&&(L=1),_===!0&&(L=2),b===!0&&(L=3);let y=h.attributes.position.count*L,w=1;y>t.maxTextureSize&&(w=Math.ceil(y/t.maxTextureSize),y=t.maxTextureSize);let z=new Float32Array(y*w*4*g),Y=new Cs(z,y,w,g);Y.type=yn,Y.needsUpdate=!0;let I=L*4;for(let O=0;O<g;O++){let $=S[O],G=T[O],q=A[O],J=y*w*4*O;for(let K=0;K<$.count;K++){let B=K*I;v===!0&&(a.fromBufferAttribute($,K),z[J+B+0]=a.x,z[J+B+1]=a.y,z[J+B+2]=a.z,z[J+B+3]=0),_===!0&&(a.fromBufferAttribute(G,K),z[J+B+4]=a.x,z[J+B+5]=a.y,z[J+B+6]=a.z,z[J+B+7]=0),b===!0&&(a.fromBufferAttribute(q,K),z[J+B+8]=a.x,z[J+B+9]=a.y,z[J+B+10]=a.z,z[J+B+11]=q.itemSize===4?a.w:1)}}x={count:g,texture:Y,size:new Nt(y,w)},r.set(h,x),h.addEventListener("dispose",D)}let p=0;for(let v=0;v<u.length;v++)p+=u[v];let f=h.morphTargetsRelative?1:1-p;d.getUniforms().setValue(i,"morphTargetBaseInfluence",f),d.getUniforms().setValue(i,"morphTargetInfluences",u),d.getUniforms().setValue(i,"morphTargetsTexture",x.texture,e),d.getUniforms().setValue(i,"morphTargetsTextureSize",x.size)}else{let m=u===void 0?0:u.length,g=n[h.id];if(g===void 0||g.length!==m){g=[];for(let _=0;_<m;_++)g[_]=[_,0];n[h.id]=g}for(let _=0;_<m;_++){let b=g[_];b[0]=_,b[1]=u[_]}g.sort(gd);for(let _=0;_<8;_++)_<m&&g[_][1]?(o[_][0]=g[_][0],o[_][1]=g[_][1]):(o[_][0]=Number.MAX_SAFE_INTEGER,o[_][1]=0);o.sort(md);let x=h.morphAttributes.position,p=h.morphAttributes.normal,f=0;for(let _=0;_<8;_++){let b=o[_],S=b[0],T=b[1];S!==Number.MAX_SAFE_INTEGER&&T?(x&&h.getAttribute("morphTarget"+_)!==x[S]&&h.setAttribute("morphTarget"+_,x[S]),p&&h.getAttribute("morphNormal"+_)!==p[S]&&h.setAttribute("morphNormal"+_,p[S]),s[_]=T,f+=T):(x&&h.hasAttribute("morphTarget"+_)===!0&&h.deleteAttribute("morphTarget"+_),p&&h.hasAttribute("morphNormal"+_)===!0&&h.deleteAttribute("morphNormal"+_),s[_]=0)}let v=h.morphTargetsRelative?1:1-f;d.getUniforms().setValue(i,"morphTargetBaseInfluence",v),d.getUniforms().setValue(i,"morphTargetInfluences",s)}}return{update:c}}function xd(i,t,e,n){let s=new WeakMap;function r(c){let l=n.render.frame,h=c.geometry,d=t.get(c,h);if(s.get(d)!==l&&(t.update(d),s.set(d,l)),c.isInstancedMesh&&(c.hasEventListener("dispose",o)===!1&&c.addEventListener("dispose",o),s.get(c)!==l&&(e.update(c.instanceMatrix,i.ARRAY_BUFFER),c.instanceColor!==null&&e.update(c.instanceColor,i.ARRAY_BUFFER),s.set(c,l))),c.isSkinnedMesh){let u=c.skeleton;s.get(u)!==l&&(u.update(),s.set(u,l))}return 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 Ec=new ge,Tc=new Cs,wc=new Vr,Ac=new Ns,Xa=[],qa=[],Ya=new Float32Array(16),Za=new Float32Array(9),Ja=new Float32Array(4);function Si(i,t,e){let n=i[0];if(n<=0||n>0)return i;let s=t*e,r=Xa[s];if(r===void 0&&(r=new Float32Array(s),Xa[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 ee(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 ne(i,t){for(let e=0,n=t.length;e<n;e++)i[e]=t[e]}function zs(i,t){let e=qa[t];e===void 0&&(e=new Int32Array(t),qa[t]=e);for(let n=0;n!==t;++n)e[n]=i.allocateTextureUnit();return e}function yd(i,t){let e=this.cache;e[0]!==t&&(i.uniform1f(this.addr,t),e[0]=t)}function vd(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(ee(e,t))return;i.uniform2fv(this.addr,t),ne(e,t)}}function Md(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(ee(e,t))return;i.uniform3fv(this.addr,t),ne(e,t)}}function Sd(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(ee(e,t))return;i.uniform4fv(this.addr,t),ne(e,t)}}function bd(i,t){let e=this.cache,n=t.elements;if(n===void 0){if(ee(e,t))return;i.uniformMatrix2fv(this.addr,!1,t),ne(e,t)}else{if(ee(e,n))return;Ja.set(n),i.uniformMatrix2fv(this.addr,!1,Ja),ne(e,n)}}function Ed(i,t){let e=this.cache,n=t.elements;if(n===void 0){if(ee(e,t))return;i.uniformMatrix3fv(this.addr,!1,t),ne(e,t)}else{if(ee(e,n))return;Za.set(n),i.uniformMatrix3fv(this.addr,!1,Za),ne(e,n)}}function Td(i,t){let e=this.cache,n=t.elements;if(n===void 0){if(ee(e,t))return;i.uniformMatrix4fv(this.addr,!1,t),ne(e,t)}else{if(ee(e,n))return;Ya.set(n),i.uniformMatrix4fv(this.addr,!1,Ya),ne(e,n)}}function wd(i,t){let e=this.cache;e[0]!==t&&(i.uniform1i(this.addr,t),e[0]=t)}function Ad(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(ee(e,t))return;i.uniform2iv(this.addr,t),ne(e,t)}}function Rd(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(ee(e,t))return;i.uniform3iv(this.addr,t),ne(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(ee(e,t))return;i.uniform4iv(this.addr,t),ne(e,t)}}function Pd(i,t){let e=this.cache;e[0]!==t&&(i.uniform1ui(this.addr,t),e[0]=t)}function Ld(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(ee(e,t))return;i.uniform2uiv(this.addr,t),ne(e,t)}}function Id(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(ee(e,t))return;i.uniform3uiv(this.addr,t),ne(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||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(ee(e,t))return;i.uniform4uiv(this.addr,t),ne(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||Ec,s)}function Nd(i,t,e){let n=this.cache,s=e.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),e.setTexture3D(t||wc,s)}function Fd(i,t,e){let n=this.cache,s=e.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),e.setTextureCube(t||Ac,s)}function Od(i,t,e){let n=this.cache,s=e.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),e.setTexture2DArray(t||Tc,s)}function Bd(i){switch(i){case 5126:return yd;case 35664:return vd;case 35665:return Md;case 35666:return Sd;case 35674:return bd;case 35675:return Ed;case 35676:return Td;case 5124:case 35670:return wd;case 35667:case 35671:return Ad;case 35668:case 35672:return Rd;case 35669:case 35673:return Cd;case 5125:return Pd;case 36294:return Ld;case 36295:return Id;case 36296:return Ud;case 35678:case 36198:case 36298:case 36306:case 35682:return Dd;case 35679:case 36299:case 36307:return Nd;case 35680:case 36300:case 36308:case 36293:return Fd;case 36289:case 36303:case 36311:case 36292:return Od}}function zd(i,t){i.uniform1fv(this.addr,t)}function Vd(i,t){let e=Si(t,this.size,2);i.uniform2fv(this.addr,e)}function kd(i,t){let e=Si(t,this.size,3);i.uniform3fv(this.addr,e)}function Hd(i,t){let e=Si(t,this.size,4);i.uniform4fv(this.addr,e)}function Gd(i,t){let e=Si(t,this.size,4);i.uniformMatrix2fv(this.addr,!1,e)}function Wd(i,t){let e=Si(t,this.size,9);i.uniformMatrix3fv(this.addr,!1,e)}function Xd(i,t){let e=Si(t,this.size,16);i.uniformMatrix4fv(this.addr,!1,e)}function qd(i,t){i.uniform1iv(this.addr,t)}function Yd(i,t){i.uniform2iv(this.addr,t)}function Zd(i,t){i.uniform3iv(this.addr,t)}function Jd(i,t){i.uniform4iv(this.addr,t)}function $d(i,t){i.uniform1uiv(this.addr,t)}function Kd(i,t){i.uniform2uiv(this.addr,t)}function Qd(i,t){i.uniform3uiv(this.addr,t)}function jd(i,t){i.uniform4uiv(this.addr,t)}function tp(i,t,e){let n=this.cache,s=t.length,r=zs(e,s);ee(n,r)||(i.uniform1iv(this.addr,r),ne(n,r));for(let a=0;a!==s;++a)e.setTexture2D(t[a]||Ec,r[a])}function ep(i,t,e){let n=this.cache,s=t.length,r=zs(e,s);ee(n,r)||(i.uniform1iv(this.addr,r),ne(n,r));for(let a=0;a!==s;++a)e.setTexture3D(t[a]||wc,r[a])}function np(i,t,e){let n=this.cache,s=t.length,r=zs(e,s);ee(n,r)||(i.uniform1iv(this.addr,r),ne(n,r));for(let a=0;a!==s;++a)e.setTextureCube(t[a]||Ac,r[a])}function ip(i,t,e){let n=this.cache,s=t.length,r=zs(e,s);ee(n,r)||(i.uniform1iv(this.addr,r),ne(n,r));for(let a=0;a!==s;++a)e.setTexture2DArray(t[a]||Tc,r[a])}function sp(i){switch(i){case 5126:return zd;case 35664:return Vd;case 35665:return kd;case 35666:return Hd;case 35674:return Gd;case 35675:return Wd;case 35676:return Xd;case 5124:case 35670:return qd;case 35667:case 35671:return Yd;case 35668:case 35672:return Zd;case 35669:case 35673:return Jd;case 5125:return $d;case 36294:return Kd;case 36295:return Qd;case 36296:return jd;case 35678:case 36198:case 36298:case 36306:case 35682:return tp;case 35679:case 36299:case 36307:return ep;case 35680:case 36300:case 36308:case 36293:return np;case 36289:case 36303:case 36311:case 36292:return ip}}var Xr=class{constructor(t,e,n){this.id=t,this.addr=n,this.cache=[],this.setValue=Bd(e.type)}},qr=class{constructor(t,e,n){this.id=t,this.addr=n,this.cache=[],this.size=e.size,this.setValue=sp(e.type)}},Yr=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)}}},Pr=/(\\w+)(\\])?(\\[|\\.)?/g;function $a(i,t){i.seq.push(t),i.map[t.id]=t}function rp(i,t,e){let n=i.name,s=n.length;for(Pr.lastIndex=0;;){let r=Pr.exec(n),a=Pr.lastIndex,o=r[1],c=r[2]==="]",l=r[3];if(c&&(o=o|0),l===void 0||l==="["&&a+2===s){$a(e,l===void 0?new Xr(o,i,t):new qr(o,i,t));break}else{let d=e.map[o];d===void 0&&(d=new Yr(o),$a(e,d)),e=d}}}var pi=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);rp(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 op=0;function ap(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 cp(i){switch(i){case Ze:return["Linear","( value )"];case Rt:return["sRGB","( value )"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",i),["Linear","( value )"]}}function Qa(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`+ap(i.getShaderSource(t),a)}else return s}function lp(i,t){let e=cp(t);return"vec4 "+i+"( vec4 value ) { return LinearTo"+e[0]+e[1]+"; }"}function hp(i,t){let e;switch(t){case El:e="Linear";break;case Tl:e="Reinhard";break;case wl:e="OptimizedCineon";break;case Al:e="ACESFilmic";break;case Rl:e="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",t),e="Linear"}return"vec3 "+i+"( vec3 color ) { return "+e+"ToneMapping( color ); }"}function up(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(zi).join(`\n`)}function fp(i){let t=[];for(let e in i){let n=i[e];n!==!1&&t.push("#define "+e+" "+n)}return t.join(`\n`)}function dp(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 zi(i){return i!==""}function ja(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 tc(i,t){return i.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}var pp=/^[ \\t]*#include +<([\\w\\d./]+)>/gm;function Zr(i){return i.replace(pp,gp)}var mp=new Map([["encodings_fragment","colorspace_fragment"],["encodings_pars_fragment","colorspace_pars_fragment"],["output_fragment","opaque_fragment"]]);function gp(i,t){let e=At[t];if(e===void 0){let n=mp.get(t);if(n!==void 0)e=At[n],console.warn(\'THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.\',t,n);else throw new Error("Can not resolve #include <"+t+">")}return Zr(e)}var _p=/#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 ec(i){return i.replace(_p,xp)}function xp(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 nc(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 yp(i){let t="SHADOWMAP_TYPE_BASIC";return i.shadowMapType===ac?t="SHADOWMAP_TYPE_PCF":i.shadowMapType===nl?t="SHADOWMAP_TYPE_PCF_SOFT":i.shadowMapType===rn&&(t="SHADOWMAP_TYPE_VSM"),t}function vp(i){let t="ENVMAP_TYPE_CUBE";if(i.envMap)switch(i.envMapMode){case mi:case gi:t="ENVMAP_TYPE_CUBE";break;case Bs:t="ENVMAP_TYPE_CUBE_UV";break}return t}function Mp(i){let t="ENVMAP_MODE_REFLECTION";if(i.envMap)switch(i.envMapMode){case gi:t="ENVMAP_MODE_REFRACTION";break}return t}function Sp(i){let t="ENVMAP_BLENDING_NONE";if(i.envMap)switch(i.combine){case hc:t="ENVMAP_BLENDING_MULTIPLY";break;case Sl:t="ENVMAP_BLENDING_MIX";break;case bl:t="ENVMAP_BLENDING_ADD";break}return t}function bp(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 Ep(i,t,e,n){let s=i.getContext(),r=e.defines,a=e.vertexShader,o=e.fragmentShader,c=yp(e),l=vp(e),h=Mp(e),d=Sp(e),u=bp(e),m=e.isWebGL2?"":up(e),g=fp(r),x=s.createProgram(),p,f,v=e.glslVersion?"#version "+e.glslVersion+`\n`:"";e.isRawShaderMaterial?(p=["#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,g].filter(zi).join(`\n`),p.length>0&&(p+=`\n`),f=[m,"#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,g].filter(zi).join(`\n`),f.length>0&&(f+=`\n`)):(p=[nc(e),"#define SHADER_TYPE "+e.shaderType,"#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.anisotropyMap?"#define USE_ANISOTROPYMAP":"",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.alphaHash?"#define USE_ALPHAHASH":"",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.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+e.anisotropyMapUv:"",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&&e.flatShading===!1?"#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.useLegacyLights?"#define LEGACY_LIGHTS":"",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(zi).join(`\n`),f=[m,nc(e),"#define SHADER_TYPE "+e.shaderType,"#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:"",u?"#define CUBEUV_TEXEL_WIDTH "+u.texelWidth:"",u?"#define CUBEUV_TEXEL_HEIGHT "+u.texelHeight:"",u?"#define CUBEUV_MAX_MIP "+u.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.anisotropy?"#define USE_ANISOTROPY":"",e.anisotropyMap?"#define USE_ANISOTROPYMAP":"",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.alphaHash?"#define USE_ALPHAHASH":"",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&&e.flatShading===!1?"#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!==Mn?"#define TONE_MAPPING":"",e.toneMapping!==Mn?At.tonemapping_pars_fragment:"",e.toneMapping!==Mn?hp("toneMapping",e.toneMapping):"",e.dithering?"#define DITHERING":"",e.opaque?"#define OPAQUE":"",At.colorspace_pars_fragment,lp("linearToOutputTexel",e.outputColorSpace),e.useDepthPacking?"#define DEPTH_PACKING "+e.depthPacking:"",`\n`].filter(zi).join(`\n`)),a=Zr(a),a=ja(a,e),a=tc(a,e),o=Zr(o),o=ja(o,e),o=tc(o,e),a=ec(a),o=ec(o),e.isWebGL2&&e.isRawShaderMaterial!==!0&&(v=`#version 300 es\n`,p=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join(`\n`)+`\n`+p,f=["#define varying in",e.glslVersion===Sa?"":"layout(location = 0) out highp vec4 pc_fragColor;",e.glslVersion===Sa?"":"#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`+f);let _=v+p+a,b=v+f+o,S=Ka(s,s.VERTEX_SHADER,_),T=Ka(s,s.FRAGMENT_SHADER,b);if(s.attachShader(x,S),s.attachShader(x,T),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(),w=s.getShaderInfoLog(S).trim(),z=s.getShaderInfoLog(T).trim(),Y=!0,I=!0;if(s.getProgramParameter(x,s.LINK_STATUS)===!1)if(Y=!1,typeof i.debug.onShaderError=="function")i.debug.onShaderError(s,x,S,T);else{let D=Qa(s,S,"vertex"),O=Qa(s,T,"fragment");console.error("THREE.WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(x,s.VALIDATE_STATUS)+`\n\nProgram Info Log: `+y+`\n`+D+`\n`+O)}else y!==""?console.warn("THREE.WebGLProgram: Program Info Log:",y):(w===""||z==="")&&(I=!1);I&&(this.diagnostics={runnable:Y,programLog:y,vertexShader:{log:w,prefix:p},fragmentShader:{log:z,prefix:f}})}s.deleteShader(S),s.deleteShader(T);let A;this.getUniforms=function(){return A===void 0&&(A=new pi(s,x)),A};let L;return this.getAttributes=function(){return L===void 0&&(L=dp(s,x)),L},this.destroy=function(){n.releaseStatesOfProgram(this),s.deleteProgram(x),this.program=void 0},this.type=e.shaderType,this.name=e.shaderName,this.id=op++,this.cacheKey=t,this.usedTimes=1,this.program=x,this.vertexShader=S,this.fragmentShader=T,this}var Tp=0,Jr=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 $r(t),e.set(t,n)),n}},$r=class{constructor(t){this.id=Tp++,this.code=t,this.usedTimes=0}};function wp(i,t,e,n,s,r,a){let o=new Ps,c=new Jr,l=[],h=s.isWebGL2,d=s.logarithmicDepthBuffer,u=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(y){return y===0?"uv":`uv${y}`}function p(y,w,z,Y,I){let D=Y.fog,O=I.geometry,$=y.isMeshStandardMaterial?Y.environment:null,G=(y.isMeshStandardMaterial?e:t).get(y.envMap||$),q=G&&G.mapping===Bs?G.image.height:null,J=g[y.type];y.precision!==null&&(m=s.getMaxPrecision(y.precision),m!==y.precision&&console.warn("THREE.WebGLProgram.getParameters:",y.precision,"not supported, using",m,"instead."));let K=O.morphAttributes.position||O.morphAttributes.normal||O.morphAttributes.color,B=K!==void 0?K.length:0,Z=0;O.morphAttributes.position!==void 0&&(Z=1),O.morphAttributes.normal!==void 0&&(Z=2),O.morphAttributes.color!==void 0&&(Z=3);let ot,at,ct,_t;if(J){let Wt=qe[J];ot=Wt.vertexShader,at=Wt.fragmentShader}else ot=y.vertexShader,at=y.fragmentShader,c.update(y),ct=c.getVertexShaderID(y),_t=c.getFragmentShaderID(y);let Et=i.getRenderTarget(),xt=I.isInstancedMesh===!0,zt=!!y.map,xe=!!y.matcap,Pt=!!G,F=!!y.aoMap,oe=!!y.lightMap,yt=!!y.bumpMap,Tt=!!y.normalMap,bt=!!y.displacementMap,Xt=!!y.emissiveMap,Ft=!!y.metalnessMap,Lt=!!y.roughnessMap,Vt=y.anisotropy>0,re=y.clearcoat>0,ae=y.iridescence>0,R=y.sheen>0,M=y.transmission>0,V=Vt&&!!y.anisotropyMap,j=re&&!!y.clearcoatMap,Q=re&&!!y.clearcoatNormalMap,tt=re&&!!y.clearcoatRoughnessMap,ft=ae&&!!y.iridescenceMap,et=ae&&!!y.iridescenceThicknessMap,H=R&&!!y.sheenColorMap,mt=R&&!!y.sheenRoughnessMap,dt=!!y.specularMap,pt=!!y.specularColorMap,ht=!!y.specularIntensityMap,ut=M&&!!y.transmissionMap,It=M&&!!y.thicknessMap,Ht=!!y.gradientMap,C=!!y.alphaMap,st=y.alphaTest>0,k=!!y.alphaHash,nt=!!y.extensions,rt=!!O.attributes.uv1,Ot=!!O.attributes.uv2,qt=!!O.attributes.uv3,Jt=Mn;return y.toneMapped&&(Et===null||Et.isXRRenderTarget===!0)&&(Jt=i.toneMapping),{isWebGL2:h,shaderID:J,shaderType:y.type,shaderName:y.name,vertexShader:ot,fragmentShader:at,defines:y.defines,customVertexShaderID:ct,customFragmentShaderID:_t,isRawShaderMaterial:y.isRawShaderMaterial===!0,glslVersion:y.glslVersion,precision:m,instancing:xt,instancingColor:xt&&I.instanceColor!==null,supportsVertexTextures:u,outputColorSpace:Et===null?i.outputColorSpace:Et.isXRRenderTarget===!0?Et.texture.colorSpace:Ze,map:zt,matcap:xe,envMap:Pt,envMapMode:Pt&&G.mapping,envMapCubeUVHeight:q,aoMap:F,lightMap:oe,bumpMap:yt,normalMap:Tt,displacementMap:u&&bt,emissiveMap:Xt,normalMapObjectSpace:Tt&&y.normalMapType===Hl,normalMapTangentSpace:Tt&&y.normalMapType===kl,metalnessMap:Ft,roughnessMap:Lt,anisotropy:Vt,anisotropyMap:V,clearcoat:re,clearcoatMap:j,clearcoatNormalMap:Q,clearcoatRoughnessMap:tt,iridescence:ae,iridescenceMap:ft,iridescenceThicknessMap:et,sheen:R,sheenColorMap:H,sheenRoughnessMap:mt,specularMap:dt,specularColorMap:pt,specularIntensityMap:ht,transmission:M,transmissionMap:ut,thicknessMap:It,gradientMap:Ht,opaque:y.transparent===!1&&y.blending===fi,alphaMap:C,alphaTest:st,alphaHash:k,combine:y.combine,mapUv:zt&&x(y.map.channel),aoMapUv:F&&x(y.aoMap.channel),lightMapUv:oe&&x(y.lightMap.channel),bumpMapUv:yt&&x(y.bumpMap.channel),normalMapUv:Tt&&x(y.normalMap.channel),displacementMapUv:bt&&x(y.displacementMap.channel),emissiveMapUv:Xt&&x(y.emissiveMap.channel),metalnessMapUv:Ft&&x(y.metalnessMap.channel),roughnessMapUv:Lt&&x(y.roughnessMap.channel),anisotropyMapUv:V&&x(y.anisotropyMap.channel),clearcoatMapUv:j&&x(y.clearcoatMap.channel),clearcoatNormalMapUv:Q&&x(y.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:tt&&x(y.clearcoatRoughnessMap.channel),iridescenceMapUv:ft&&x(y.iridescenceMap.channel),iridescenceThicknessMapUv:et&&x(y.iridescenceThicknessMap.channel),sheenColorMapUv:H&&x(y.sheenColorMap.channel),sheenRoughnessMapUv:mt&&x(y.sheenRoughnessMap.channel),specularMapUv:dt&&x(y.specularMap.channel),specularColorMapUv:pt&&x(y.specularColorMap.channel),specularIntensityMapUv:ht&&x(y.specularIntensityMap.channel),transmissionMapUv:ut&&x(y.transmissionMap.channel),thicknessMapUv:It&&x(y.thicknessMap.channel),alphaMapUv:C&&x(y.alphaMap.channel),vertexTangents:!!O.attributes.tangent&&(Tt||Vt),vertexColors:y.vertexColors,vertexAlphas:y.vertexColors===!0&&!!O.attributes.color&&O.attributes.color.itemSize===4,vertexUv1s:rt,vertexUv2s:Ot,vertexUv3s:qt,pointsUvs:I.isPoints===!0&&!!O.attributes.uv&&(zt||C),fog:!!D,useFog:y.fog===!0,fogExp2:D&&D.isFogExp2,flatShading:y.flatShading===!0,sizeAttenuation:y.sizeAttenuation===!0,logarithmicDepthBuffer:d,skinning:I.isSkinnedMesh===!0,morphTargets:O.morphAttributes.position!==void 0,morphNormals:O.morphAttributes.normal!==void 0,morphColors:O.morphAttributes.color!==void 0,morphTargetsCount:B,morphTextureStride:Z,numDirLights:w.directional.length,numPointLights:w.point.length,numSpotLights:w.spot.length,numSpotLightMaps:w.spotLightMap.length,numRectAreaLights:w.rectArea.length,numHemiLights:w.hemi.length,numDirLightShadows:w.directionalShadowMap.length,numPointLightShadows:w.pointShadowMap.length,numSpotLightShadows:w.spotShadowMap.length,numSpotLightShadowsWithMaps:w.numSpotLightShadowsWithMaps,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:y.dithering,shadowMapEnabled:i.shadowMap.enabled&&z.length>0,shadowMapType:i.shadowMap.type,toneMapping:Jt,useLegacyLights:i._useLegacyLights,premultipliedAlpha:y.premultipliedAlpha,doubleSided:y.side===ze,flipSided:y.side===he,useDepthPacking:y.depthPacking>=0,depthPacking:y.depthPacking||0,index0AttributeName:y.index0AttributeName,extensionDerivatives:nt&&y.extensions.derivatives===!0,extensionFragDepth:nt&&y.extensions.fragDepth===!0,extensionDrawBuffers:nt&&y.extensions.drawBuffers===!0,extensionShaderTextureLOD:nt&&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 f(y){let w=[];if(y.shaderID?w.push(y.shaderID):(w.push(y.customVertexShaderID),w.push(y.customFragmentShaderID)),y.defines!==void 0)for(let z in y.defines)w.push(z),w.push(y.defines[z]);return y.isRawShaderMaterial===!1&&(v(w,y),_(w,y),w.push(i.outputColorSpace)),w.push(y.customProgramCacheKey),w.join()}function v(y,w){y.push(w.precision),y.push(w.outputColorSpace),y.push(w.envMapMode),y.push(w.envMapCubeUVHeight),y.push(w.mapUv),y.push(w.alphaMapUv),y.push(w.lightMapUv),y.push(w.aoMapUv),y.push(w.bumpMapUv),y.push(w.normalMapUv),y.push(w.displacementMapUv),y.push(w.emissiveMapUv),y.push(w.metalnessMapUv),y.push(w.roughnessMapUv),y.push(w.anisotropyMapUv),y.push(w.clearcoatMapUv),y.push(w.clearcoatNormalMapUv),y.push(w.clearcoatRoughnessMapUv),y.push(w.iridescenceMapUv),y.push(w.iridescenceThicknessMapUv),y.push(w.sheenColorMapUv),y.push(w.sheenRoughnessMapUv),y.push(w.specularMapUv),y.push(w.specularColorMapUv),y.push(w.specularIntensityMapUv),y.push(w.transmissionMapUv),y.push(w.thicknessMapUv),y.push(w.combine),y.push(w.fogExp2),y.push(w.sizeAttenuation),y.push(w.morphTargetsCount),y.push(w.morphAttributeCount),y.push(w.numDirLights),y.push(w.numPointLights),y.push(w.numSpotLights),y.push(w.numSpotLightMaps),y.push(w.numHemiLights),y.push(w.numRectAreaLights),y.push(w.numDirLightShadows),y.push(w.numPointLightShadows),y.push(w.numSpotLightShadows),y.push(w.numSpotLightShadowsWithMaps),y.push(w.shadowMapType),y.push(w.toneMapping),y.push(w.numClippingPlanes),y.push(w.numClipIntersection),y.push(w.depthPacking)}function _(y,w){o.disableAll(),w.isWebGL2&&o.enable(0),w.supportsVertexTextures&&o.enable(1),w.instancing&&o.enable(2),w.instancingColor&&o.enable(3),w.matcap&&o.enable(4),w.envMap&&o.enable(5),w.normalMapObjectSpace&&o.enable(6),w.normalMapTangentSpace&&o.enable(7),w.clearcoat&&o.enable(8),w.iridescence&&o.enable(9),w.alphaTest&&o.enable(10),w.vertexColors&&o.enable(11),w.vertexAlphas&&o.enable(12),w.vertexUv1s&&o.enable(13),w.vertexUv2s&&o.enable(14),w.vertexUv3s&&o.enable(15),w.vertexTangents&&o.enable(16),w.anisotropy&&o.enable(17),y.push(o.mask),o.disableAll(),w.fog&&o.enable(0),w.useFog&&o.enable(1),w.flatShading&&o.enable(2),w.logarithmicDepthBuffer&&o.enable(3),w.skinning&&o.enable(4),w.morphTargets&&o.enable(5),w.morphNormals&&o.enable(6),w.morphColors&&o.enable(7),w.premultipliedAlpha&&o.enable(8),w.shadowMapEnabled&&o.enable(9),w.useLegacyLights&&o.enable(10),w.doubleSided&&o.enable(11),w.flipSided&&o.enable(12),w.useDepthPacking&&o.enable(13),w.dithering&&o.enable(14),w.transmission&&o.enable(15),w.sheen&&o.enable(16),w.opaque&&o.enable(17),w.pointsUvs&&o.enable(18),y.push(o.mask)}function b(y){let w=g[y.type],z;if(w){let Y=qe[w];z=xh.clone(Y.uniforms)}else z=y.uniforms;return z}function S(y,w){let z;for(let Y=0,I=l.length;Y<I;Y++){let D=l[Y];if(D.cacheKey===w){z=D,++z.usedTimes;break}}return z===void 0&&(z=new Ep(i,w,y,r),l.push(z)),z}function T(y){if(--y.usedTimes===0){let w=l.indexOf(y);l[w]=l[l.length-1],l.pop(),y.destroy()}}function A(y){c.remove(y)}function L(){c.dispose()}return{getParameters:p,getProgramCacheKey:f,getUniforms:b,acquireProgram:S,releaseProgram:T,releaseShaderCache:A,programs:l,dispose:L}}function Ap(){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 Rp(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 ic(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 sc(){let i=[],t=0,e=[],n=[],s=[];function r(){t=0,e.length=0,n.length=0,s.length=0}function a(d,u,m,g,x,p){let f=i[t];return f===void 0?(f={id:d.id,object:d,geometry:u,material:m,groupOrder:g,renderOrder:d.renderOrder,z:x,group:p},i[t]=f):(f.id=d.id,f.object=d,f.geometry=u,f.material=m,f.groupOrder=g,f.renderOrder=d.renderOrder,f.z=x,f.group=p),t++,f}function o(d,u,m,g,x,p){let f=a(d,u,m,g,x,p);m.transmission>0?n.push(f):m.transparent===!0?s.push(f):e.push(f)}function c(d,u,m,g,x,p){let f=a(d,u,m,g,x,p);m.transmission>0?n.unshift(f):m.transparent===!0?s.unshift(f):e.unshift(f)}function l(d,u){e.length>1&&e.sort(d||Rp),n.length>1&&n.sort(u||ic),s.length>1&&s.sort(u||ic)}function h(){for(let d=t,u=i.length;d<u;d++){let m=i[d];if(m.id===null)break;m.id=null,m.object=null,m.geometry=null,m.material=null,m.group=null}}return{opaque:e,transmissive:n,transparent:s,init:r,push:o,unshift:c,finish:h,sort:l}}function Cp(){let i=new WeakMap;function t(n,s){let r=i.get(n),a;return r===void 0?(a=new sc,i.set(n,[a])):s>=r.length?(a=new sc,r.push(a)):a=r[s],a}function e(){i=new WeakMap}return{get:t,dispose:e}}function Pp(){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 kt};break;case"SpotLight":e={position:new P,direction:new P,color:new kt,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":e={position:new P,color:new kt,distance:0,decay:0};break;case"HemisphereLight":e={direction:new P,skyColor:new kt,groundColor:new kt};break;case"RectAreaLight":e={color:new kt,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 Nt};break;case"SpotLight":e={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Nt};break;case"PointLight":e={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Nt,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[t.id]=e,e}}}var Ip=0;function Up(i,t){return(t.castShadow?2:0)-(i.castShadow?2:0)+(t.map?1:0)-(i.map?1:0)}function Dp(i,t){let e=new Pp,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 u=0,m=0,g=0;for(let z=0;z<9;z++)s.probe[z].set(0,0,0);let x=0,p=0,f=0,v=0,_=0,b=0,S=0,T=0,A=0,L=0;h.sort(Up);let y=d===!0?Math.PI:1;for(let z=0,Y=h.length;z<Y;z++){let I=h[z],D=I.color,O=I.intensity,$=I.distance,G=I.shadow&&I.shadow.map?I.shadow.map.texture:null;if(I.isAmbientLight)u+=D.r*O*y,m+=D.g*O*y,g+=D.b*O*y;else if(I.isLightProbe)for(let q=0;q<9;q++)s.probe[q].addScaledVector(I.sh.coefficients[q],O);else if(I.isDirectionalLight){let q=e.get(I);if(q.color.copy(I.color).multiplyScalar(I.intensity*y),I.castShadow){let J=I.shadow,K=n.get(I);K.shadowBias=J.bias,K.shadowNormalBias=J.normalBias,K.shadowRadius=J.radius,K.shadowMapSize=J.mapSize,s.directionalShadow[x]=K,s.directionalShadowMap[x]=G,s.directionalShadowMatrix[x]=I.shadow.matrix,b++}s.directional[x]=q,x++}else if(I.isSpotLight){let q=e.get(I);q.position.setFromMatrixPosition(I.matrixWorld),q.color.copy(D).multiplyScalar(O*y),q.distance=$,q.coneCos=Math.cos(I.angle),q.penumbraCos=Math.cos(I.angle*(1-I.penumbra)),q.decay=I.decay,s.spot[f]=q;let J=I.shadow;if(I.map&&(s.spotLightMap[A]=I.map,A++,J.updateMatrices(I),I.castShadow&&L++),s.spotLightMatrix[f]=J.matrix,I.castShadow){let K=n.get(I);K.shadowBias=J.bias,K.shadowNormalBias=J.normalBias,K.shadowRadius=J.radius,K.shadowMapSize=J.mapSize,s.spotShadow[f]=K,s.spotShadowMap[f]=G,T++}f++}else if(I.isRectAreaLight){let q=e.get(I);q.color.copy(D).multiplyScalar(O),q.halfWidth.set(I.width*.5,0,0),q.halfHeight.set(0,I.height*.5,0),s.rectArea[v]=q,v++}else if(I.isPointLight){let q=e.get(I);if(q.color.copy(I.color).multiplyScalar(I.intensity*y),q.distance=I.distance,q.decay=I.decay,I.castShadow){let J=I.shadow,K=n.get(I);K.shadowBias=J.bias,K.shadowNormalBias=J.normalBias,K.shadowRadius=J.radius,K.shadowMapSize=J.mapSize,K.shadowCameraNear=J.camera.near,K.shadowCameraFar=J.camera.far,s.pointShadow[p]=K,s.pointShadowMap[p]=G,s.pointShadowMatrix[p]=I.shadow.matrix,S++}s.point[p]=q,p++}else if(I.isHemisphereLight){let q=e.get(I);q.skyColor.copy(I.color).multiplyScalar(O*y),q.groundColor.copy(I.groundColor).multiplyScalar(O*y),s.hemi[_]=q,_++}}v>0&&(t.isWebGL2||i.has("OES_texture_float_linear")===!0?(s.rectAreaLTC1=it.LTC_FLOAT_1,s.rectAreaLTC2=it.LTC_FLOAT_2):i.has("OES_texture_half_float_linear")===!0?(s.rectAreaLTC1=it.LTC_HALF_1,s.rectAreaLTC2=it.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),s.ambient[0]=u,s.ambient[1]=m,s.ambient[2]=g;let w=s.hash;(w.directionalLength!==x||w.pointLength!==p||w.spotLength!==f||w.rectAreaLength!==v||w.hemiLength!==_||w.numDirectionalShadows!==b||w.numPointShadows!==S||w.numSpotShadows!==T||w.numSpotMaps!==A)&&(s.directional.length=x,s.spot.length=f,s.rectArea.length=v,s.point.length=p,s.hemi.length=_,s.directionalShadow.length=b,s.directionalShadowMap.length=b,s.pointShadow.length=S,s.pointShadowMap.length=S,s.spotShadow.length=T,s.spotShadowMap.length=T,s.directionalShadowMatrix.length=b,s.pointShadowMatrix.length=S,s.spotLightMatrix.length=T+A-L,s.spotLightMap.length=A,s.numSpotLightShadowsWithMaps=L,w.directionalLength=x,w.pointLength=p,w.spotLength=f,w.rectAreaLength=v,w.hemiLength=_,w.numDirectionalShadows=b,w.numPointShadows=S,w.numSpotShadows=T,w.numSpotMaps=A,s.version=Ip++)}function l(h,d){let u=0,m=0,g=0,x=0,p=0,f=d.matrixWorldInverse;for(let v=0,_=h.length;v<_;v++){let b=h[v];if(b.isDirectionalLight){let S=s.directional[u];S.direction.setFromMatrixPosition(b.matrixWorld),r.setFromMatrixPosition(b.target.matrixWorld),S.direction.sub(r),S.direction.transformDirection(f),u++}else if(b.isSpotLight){let S=s.spot[g];S.position.setFromMatrixPosition(b.matrixWorld),S.position.applyMatrix4(f),S.direction.setFromMatrixPosition(b.matrixWorld),r.setFromMatrixPosition(b.target.matrixWorld),S.direction.sub(r),S.direction.transformDirection(f),g++}else if(b.isRectAreaLight){let S=s.rectArea[x];S.position.setFromMatrixPosition(b.matrixWorld),S.position.applyMatrix4(f),o.identity(),a.copy(b.matrixWorld),a.premultiply(f),o.extractRotation(a),S.halfWidth.set(b.width*.5,0,0),S.halfHeight.set(0,b.height*.5,0),S.halfWidth.applyMatrix4(o),S.halfHeight.applyMatrix4(o),x++}else if(b.isPointLight){let S=s.point[m];S.position.setFromMatrixPosition(b.matrixWorld),S.position.applyMatrix4(f),m++}else if(b.isHemisphereLight){let S=s.hemi[p];S.direction.setFromMatrixPosition(b.matrixWorld),S.direction.transformDirection(f),p++}}}return{setup:c,setupView:l,state:s}}function rc(i,t){let e=new Dp(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 Np(i,t){let e=new WeakMap;function n(r,a=0){let o=e.get(r),c;return o===void 0?(c=new rc(i,t),e.set(r,[c])):a>=o.length?(c=new rc(i,t),o.push(c)):c=o[a],c}function s(){e=new WeakMap}return{get:n,dispose:s}}var Kr=class extends yi{constructor(t){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=zl,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}},Qr=class extends yi{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}},Fp=`void main() {\n\tgl_Position = vec4( position, 1.0 );\n}`,Op=`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 Bp(i,t,e){let n=new Fs,s=new Nt,r=new Nt,a=new jt,o=new Kr({depthPacking:Vl}),c=new Qr,l={},h=e.maxTextureSize,d={[He]:he,[he]:He,[ze]:ze},u=new ln({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Nt},radius:{value:4}},vertexShader:Fp,fragmentShader:Op}),m=u.clone();m.defines.HORIZONTAL_PASS=1;let g=new Ge;g.setAttribute("position",new te(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let x=new Ye(g,u),p=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=ac;let f=this.type;this.render=function(S,T,A){if(p.enabled===!1||p.autoUpdate===!1&&p.needsUpdate===!1||S.length===0)return;let L=i.getRenderTarget(),y=i.getActiveCubeFace(),w=i.getActiveMipmapLevel(),z=i.state;z.setBlending(vn),z.buffers.color.setClear(1,1,1,1),z.buffers.depth.setTest(!0),z.setScissorTest(!1);let Y=f!==rn&&this.type===rn,I=f===rn&&this.type!==rn;for(let D=0,O=S.length;D<O;D++){let $=S[D],G=$.shadow;if(G===void 0){console.warn("THREE.WebGLShadowMap:",$,"has no shadow.");continue}if(G.autoUpdate===!1&&G.needsUpdate===!1)continue;s.copy(G.mapSize);let q=G.getFrameExtents();if(s.multiply(q),r.copy(G.mapSize),(s.x>h||s.y>h)&&(s.x>h&&(r.x=Math.floor(h/q.x),s.x=r.x*q.x,G.mapSize.x=r.x),s.y>h&&(r.y=Math.floor(h/q.y),s.y=r.y*q.y,G.mapSize.y=r.y)),G.map===null||Y===!0||I===!0){let K=this.type!==rn?{minFilter:pe,magFilter:pe}:{};G.map!==null&&G.map.dispose(),G.map=new cn(s.x,s.y,K),G.map.texture.name=$.name+".shadowMap",G.camera.updateProjectionMatrix()}i.setRenderTarget(G.map),i.clear();let J=G.getViewportCount();for(let K=0;K<J;K++){let B=G.getViewport(K);a.set(r.x*B.x,r.y*B.y,r.x*B.z,r.y*B.w),z.viewport(a),G.updateMatrices($,K),n=G.getFrustum(),b(T,A,G.camera,$,this.type)}G.isPointLightShadow!==!0&&this.type===rn&&v(G,A),G.needsUpdate=!1}f=this.type,p.needsUpdate=!1,i.setRenderTarget(L,y,w)};function v(S,T){let A=t.update(x);u.defines.VSM_SAMPLES!==S.blurSamples&&(u.defines.VSM_SAMPLES=S.blurSamples,m.defines.VSM_SAMPLES=S.blurSamples,u.needsUpdate=!0,m.needsUpdate=!0),S.mapPass===null&&(S.mapPass=new cn(s.x,s.y)),u.uniforms.shadow_pass.value=S.map.texture,u.uniforms.resolution.value=S.mapSize,u.uniforms.radius.value=S.radius,i.setRenderTarget(S.mapPass),i.clear(),i.renderBufferDirect(T,null,A,u,x,null),m.uniforms.shadow_pass.value=S.mapPass.texture,m.uniforms.resolution.value=S.mapSize,m.uniforms.radius.value=S.radius,i.setRenderTarget(S.map),i.clear(),i.renderBufferDirect(T,null,A,m,x,null)}function _(S,T,A,L){let y=null,w=A.isPointLight===!0?S.customDistanceMaterial:S.customDepthMaterial;if(w!==void 0)y=w;else if(y=A.isPointLight===!0?c:o,i.localClippingEnabled&&T.clipShadows===!0&&Array.isArray(T.clippingPlanes)&&T.clippingPlanes.length!==0||T.displacementMap&&T.displacementScale!==0||T.alphaMap&&T.alphaTest>0||T.map&&T.alphaTest>0){let z=y.uuid,Y=T.uuid,I=l[z];I===void 0&&(I={},l[z]=I);let D=I[Y];D===void 0&&(D=y.clone(),I[Y]=D),y=D}if(y.visible=T.visible,y.wireframe=T.wireframe,L===rn?y.side=T.shadowSide!==null?T.shadowSide:T.side:y.side=T.shadowSide!==null?T.shadowSide:d[T.side],y.alphaMap=T.alphaMap,y.alphaTest=T.alphaTest,y.map=T.map,y.clipShadows=T.clipShadows,y.clippingPlanes=T.clippingPlanes,y.clipIntersection=T.clipIntersection,y.displacementMap=T.displacementMap,y.displacementScale=T.displacementScale,y.displacementBias=T.displacementBias,y.wireframeLinewidth=T.wireframeLinewidth,y.linewidth=T.linewidth,A.isPointLight===!0&&y.isMeshDistanceMaterial===!0){let z=i.properties.get(y);z.light=A}return y}function b(S,T,A,L,y){if(S.visible===!1)return;if(S.layers.test(T.layers)&&(S.isMesh||S.isLine||S.isPoints)&&(S.castShadow||S.receiveShadow&&y===rn)&&(!S.frustumCulled||n.intersectsObject(S))){S.modelViewMatrix.multiplyMatrices(A.matrixWorldInverse,S.matrixWorld);let Y=t.update(S),I=S.material;if(Array.isArray(I)){let D=Y.groups;for(let O=0,$=D.length;O<$;O++){let G=D[O],q=I[G.materialIndex];if(q&&q.visible){let J=_(S,q,L,y);i.renderBufferDirect(A,null,Y,J,S,G)}}}else if(I.visible){let D=_(S,I,L,y);i.renderBufferDirect(A,null,Y,D,S,null)}}let z=S.children;for(let Y=0,I=z.length;Y<I;Y++)b(z[Y],T,A,L,y)}}function zp(i,t,e){let n=e.isWebGL2;function s(){let C=!1,st=new jt,k=null,nt=new jt(0,0,0,0);return{setMask:function(rt){k!==rt&&!C&&(i.colorMask(rt,rt,rt,rt),k=rt)},setLocked:function(rt){C=rt},setClear:function(rt,Ot,qt,Jt,fn){fn===!0&&(rt*=Jt,Ot*=Jt,qt*=Jt),st.set(rt,Ot,qt,Jt),nt.equals(st)===!1&&(i.clearColor(rt,Ot,qt,Jt),nt.copy(st))},reset:function(){C=!1,k=null,nt.set(-1,0,0,0)}}}function r(){let C=!1,st=null,k=null,nt=null;return{setTest:function(rt){rt?Et(i.DEPTH_TEST):xt(i.DEPTH_TEST)},setMask:function(rt){st!==rt&&!C&&(i.depthMask(rt),st=rt)},setFunc:function(rt){if(k!==rt){switch(rt){case ml:i.depthFunc(i.NEVER);break;case gl:i.depthFunc(i.ALWAYS);break;case _l:i.depthFunc(i.LESS);break;case Lr:i.depthFunc(i.LEQUAL);break;case xl:i.depthFunc(i.EQUAL);break;case yl:i.depthFunc(i.GEQUAL);break;case vl:i.depthFunc(i.GREATER);break;case Ml:i.depthFunc(i.NOTEQUAL);break;default:i.depthFunc(i.LEQUAL)}k=rt}},setLocked:function(rt){C=rt},setClear:function(rt){nt!==rt&&(i.clearDepth(rt),nt=rt)},reset:function(){C=!1,st=null,k=null,nt=null}}}function a(){let C=!1,st=null,k=null,nt=null,rt=null,Ot=null,qt=null,Jt=null,fn=null;return{setTest:function(Wt){C||(Wt?Et(i.STENCIL_TEST):xt(i.STENCIL_TEST))},setMask:function(Wt){st!==Wt&&!C&&(i.stencilMask(Wt),st=Wt)},setFunc:function(Wt,Xe,ue){(k!==Wt||nt!==Xe||rt!==ue)&&(i.stencilFunc(Wt,Xe,ue),k=Wt,nt=Xe,rt=ue)},setOp:function(Wt,Xe,ue){(Ot!==Wt||qt!==Xe||Jt!==ue)&&(i.stencilOp(Wt,Xe,ue),Ot=Wt,qt=Xe,Jt=ue)},setLocked:function(Wt){C=Wt},setClear:function(Wt){fn!==Wt&&(i.clearStencil(Wt),fn=Wt)},reset:function(){C=!1,st=null,k=null,nt=null,rt=null,Ot=null,qt=null,Jt=null,fn=null}}}let o=new s,c=new r,l=new a,h=new WeakMap,d=new WeakMap,u={},m={},g=new WeakMap,x=[],p=null,f=!1,v=null,_=null,b=null,S=null,T=null,A=null,L=null,y=!1,w=null,z=null,Y=null,I=null,D=null,O=i.getParameter(i.MAX_COMBINED_TEXTURE_IMAGE_UNITS),$=!1,G=0,q=i.getParameter(i.VERSION);q.indexOf("WebGL")!==-1?(G=parseFloat(/^WebGL (\\d)/.exec(q)[1]),$=G>=1):q.indexOf("OpenGL ES")!==-1&&(G=parseFloat(/^OpenGL ES (\\d)/.exec(q)[1]),$=G>=2);let J=null,K={},B=i.getParameter(i.SCISSOR_BOX),Z=i.getParameter(i.VIEWPORT),ot=new jt().fromArray(B),at=new jt().fromArray(Z);function ct(C,st,k,nt){let rt=new Uint8Array(4),Ot=i.createTexture();i.bindTexture(C,Ot),i.texParameteri(C,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(C,i.TEXTURE_MAG_FILTER,i.NEAREST);for(let qt=0;qt<k;qt++)n&&(C===i.TEXTURE_3D||C===i.TEXTURE_2D_ARRAY)?i.texImage3D(st,0,i.RGBA,1,1,nt,0,i.RGBA,i.UNSIGNED_BYTE,rt):i.texImage2D(st+qt,0,i.RGBA,1,1,0,i.RGBA,i.UNSIGNED_BYTE,rt);return Ot}let _t={};_t[i.TEXTURE_2D]=ct(i.TEXTURE_2D,i.TEXTURE_2D,1),_t[i.TEXTURE_CUBE_MAP]=ct(i.TEXTURE_CUBE_MAP,i.TEXTURE_CUBE_MAP_POSITIVE_X,6),n&&(_t[i.TEXTURE_2D_ARRAY]=ct(i.TEXTURE_2D_ARRAY,i.TEXTURE_2D_ARRAY,1,1),_t[i.TEXTURE_3D]=ct(i.TEXTURE_3D,i.TEXTURE_3D,1,1)),o.setClear(0,0,0,1),c.setClear(1),l.setClear(0),Et(i.DEPTH_TEST),c.setFunc(Lr),bt(!1),Xt(Ho),Et(i.CULL_FACE),yt(vn);function Et(C){u[C]!==!0&&(i.enable(C),u[C]=!0)}function xt(C){u[C]!==!1&&(i.disable(C),u[C]=!1)}function zt(C,st){return m[C]!==st?(i.bindFramebuffer(C,st),m[C]=st,n&&(C===i.DRAW_FRAMEBUFFER&&(m[i.FRAMEBUFFER]=st),C===i.FRAMEBUFFER&&(m[i.DRAW_FRAMEBUFFER]=st)),!0):!1}function xe(C,st){let k=x,nt=!1;if(C)if(k=g.get(st),k===void 0&&(k=[],g.set(st,k)),C.isWebGLMultipleRenderTargets){let rt=C.texture;if(k.length!==rt.length||k[0]!==i.COLOR_ATTACHMENT0){for(let Ot=0,qt=rt.length;Ot<qt;Ot++)k[Ot]=i.COLOR_ATTACHMENT0+Ot;k.length=rt.length,nt=!0}}else k[0]!==i.COLOR_ATTACHMENT0&&(k[0]=i.COLOR_ATTACHMENT0,nt=!0);else k[0]!==i.BACK&&(k[0]=i.BACK,nt=!0);nt&&(e.isWebGL2?i.drawBuffers(k):t.get("WEBGL_draw_buffers").drawBuffersWEBGL(k))}function Pt(C){return p!==C?(i.useProgram(C),p=C,!0):!1}let F={[li]:i.FUNC_ADD,[sl]:i.FUNC_SUBTRACT,[rl]:i.FUNC_REVERSE_SUBTRACT};if(n)F[qo]=i.MIN,F[Yo]=i.MAX;else{let C=t.get("EXT_blend_minmax");C!==null&&(F[qo]=C.MIN_EXT,F[Yo]=C.MAX_EXT)}let oe={[ol]:i.ZERO,[al]:i.ONE,[cl]:i.SRC_COLOR,[cc]:i.SRC_ALPHA,[pl]:i.SRC_ALPHA_SATURATE,[fl]:i.DST_COLOR,[hl]:i.DST_ALPHA,[ll]:i.ONE_MINUS_SRC_COLOR,[lc]:i.ONE_MINUS_SRC_ALPHA,[dl]:i.ONE_MINUS_DST_COLOR,[ul]:i.ONE_MINUS_DST_ALPHA};function yt(C,st,k,nt,rt,Ot,qt,Jt){if(C===vn){f===!0&&(xt(i.BLEND),f=!1);return}if(f===!1&&(Et(i.BLEND),f=!0),C!==il){if(C!==v||Jt!==y){if((_!==li||T!==li)&&(i.blendEquation(i.FUNC_ADD),_=li,T=li),Jt)switch(C){case fi:i.blendFuncSeparate(i.ONE,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case Go:i.blendFunc(i.ONE,i.ONE);break;case Wo:i.blendFuncSeparate(i.ZERO,i.ONE_MINUS_SRC_COLOR,i.ZERO,i.ONE);break;case Xo: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 fi:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case Go:i.blendFunc(i.SRC_ALPHA,i.ONE);break;case Wo:i.blendFuncSeparate(i.ZERO,i.ONE_MINUS_SRC_COLOR,i.ZERO,i.ONE);break;case Xo:i.blendFunc(i.ZERO,i.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",C);break}b=null,S=null,A=null,L=null,v=C,y=Jt}return}rt=rt||st,Ot=Ot||k,qt=qt||nt,(st!==_||rt!==T)&&(i.blendEquationSeparate(F[st],F[rt]),_=st,T=rt),(k!==b||nt!==S||Ot!==A||qt!==L)&&(i.blendFuncSeparate(oe[k],oe[nt],oe[Ot],oe[qt]),b=k,S=nt,A=Ot,L=qt),v=C,y=!1}function Tt(C,st){C.side===ze?xt(i.CULL_FACE):Et(i.CULL_FACE);let k=C.side===he;st&&(k=!k),bt(k),C.blending===fi&&C.transparent===!1?yt(vn):yt(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 nt=C.stencilWrite;l.setTest(nt),nt&&(l.setMask(C.stencilWriteMask),l.setFunc(C.stencilFunc,C.stencilRef,C.stencilFuncMask),l.setOp(C.stencilFail,C.stencilZFail,C.stencilZPass)),Lt(C.polygonOffset,C.polygonOffsetFactor,C.polygonOffsetUnits),C.alphaToCoverage===!0?Et(i.SAMPLE_ALPHA_TO_COVERAGE):xt(i.SAMPLE_ALPHA_TO_COVERAGE)}function bt(C){w!==C&&(C?i.frontFace(i.CW):i.frontFace(i.CCW),w=C)}function Xt(C){C!==tl?(Et(i.CULL_FACE),C!==z&&(C===Ho?i.cullFace(i.BACK):C===el?i.cullFace(i.FRONT):i.cullFace(i.FRONT_AND_BACK))):xt(i.CULL_FACE),z=C}function Ft(C){C!==Y&&($&&i.lineWidth(C),Y=C)}function Lt(C,st,k){C?(Et(i.POLYGON_OFFSET_FILL),(I!==st||D!==k)&&(i.polygonOffset(st,k),I=st,D=k)):xt(i.POLYGON_OFFSET_FILL)}function Vt(C){C?Et(i.SCISSOR_TEST):xt(i.SCISSOR_TEST)}function re(C){C===void 0&&(C=i.TEXTURE0+O-1),J!==C&&(i.activeTexture(C),J=C)}function ae(C,st,k){k===void 0&&(J===null?k=i.TEXTURE0+O-1:k=J);let nt=K[k];nt===void 0&&(nt={type:void 0,texture:void 0},K[k]=nt),(nt.type!==C||nt.texture!==st)&&(J!==k&&(i.activeTexture(k),J=k),i.bindTexture(C,st||_t[C]),nt.type=C,nt.texture=st)}function R(){let C=K[J];C!==void 0&&C.type!==void 0&&(i.bindTexture(C.type,null),C.type=void 0,C.texture=void 0)}function M(){try{i.compressedTexImage2D.apply(i,arguments)}catch(C){console.error("THREE.WebGLState:",C)}}function V(){try{i.compressedTexImage3D.apply(i,arguments)}catch(C){console.error("THREE.WebGLState:",C)}}function j(){try{i.texSubImage2D.apply(i,arguments)}catch(C){console.error("THREE.WebGLState:",C)}}function Q(){try{i.texSubImage3D.apply(i,arguments)}catch(C){console.error("THREE.WebGLState:",C)}}function tt(){try{i.compressedTexSubImage2D.apply(i,arguments)}catch(C){console.error("THREE.WebGLState:",C)}}function ft(){try{i.compressedTexSubImage3D.apply(i,arguments)}catch(C){console.error("THREE.WebGLState:",C)}}function et(){try{i.texStorage2D.apply(i,arguments)}catch(C){console.error("THREE.WebGLState:",C)}}function H(){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 dt(){try{i.texImage3D.apply(i,arguments)}catch(C){console.error("THREE.WebGLState:",C)}}function pt(C){ot.equals(C)===!1&&(i.scissor(C.x,C.y,C.z,C.w),ot.copy(C))}function ht(C){at.equals(C)===!1&&(i.viewport(C.x,C.y,C.z,C.w),at.copy(C))}function ut(C,st){let k=d.get(st);k===void 0&&(k=new WeakMap,d.set(st,k));let nt=k.get(C);nt===void 0&&(nt=i.getUniformBlockIndex(st,C.name),k.set(C,nt))}function It(C,st){let nt=d.get(st).get(C);h.get(st)!==nt&&(i.uniformBlockBinding(st,nt,C.__bindingPointIndex),h.set(st,nt))}function Ht(){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),u={},J=null,K={},m={},g=new WeakMap,x=[],p=null,f=!1,v=null,_=null,b=null,S=null,T=null,A=null,L=null,y=!1,w=null,z=null,Y=null,I=null,D=null,ot.set(0,0,i.canvas.width,i.canvas.height),at.set(0,0,i.canvas.width,i.canvas.height),o.reset(),c.reset(),l.reset()}return{buffers:{color:o,depth:c,stencil:l},enable:Et,disable:xt,bindFramebuffer:zt,drawBuffers:xe,useProgram:Pt,setBlending:yt,setMaterial:Tt,setFlipSided:bt,setCullFace:Xt,setLineWidth:Ft,setPolygonOffset:Lt,setScissorTest:Vt,activeTexture:re,bindTexture:ae,unbindTexture:R,compressedTexImage2D:M,compressedTexImage3D:V,texImage2D:mt,texImage3D:dt,updateUBOMapping:ut,uniformBlockBinding:It,texStorage2D:et,texStorage3D:H,texSubImage2D:j,texSubImage3D:Q,compressedTexSubImage2D:tt,compressedTexSubImage3D:ft,scissor:pt,viewport:ht,reset:Ht}}function Vp(i,t,e,n,s,r,a){let o=s.isWebGL2,c=s.maxTextures,l=s.maxCubemapSize,h=s.maxTextureSize,d=s.maxSamples,u=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,m=typeof navigator=="undefined"?!1:/OculusBrowser/g.test(navigator.userAgent),g=new WeakMap,x,p=new WeakMap,f=!1;try{f=typeof OffscreenCanvas!="undefined"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch(R){}function v(R,M){return f?new OffscreenCanvas(R,M):ws("canvas")}function _(R,M,V,j){let Q=1;if((R.width>j||R.height>j)&&(Q=j/Math.max(R.width,R.height)),Q<1||M===!0)if(typeof HTMLImageElement!="undefined"&&R instanceof HTMLImageElement||typeof HTMLCanvasElement!="undefined"&&R instanceof HTMLCanvasElement||typeof ImageBitmap!="undefined"&&R instanceof ImageBitmap){let tt=M?Br:Math.floor,ft=tt(Q*R.width),et=tt(Q*R.height);x===void 0&&(x=v(ft,et));let H=V?v(ft,et):x;return H.width=ft,H.height=et,H.getContext("2d").drawImage(R,0,0,ft,et),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+R.width+"x"+R.height+") to ("+ft+"x"+et+")."),H}else return"data"in R&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+R.width+"x"+R.height+")."),R;return R}function b(R){return ba(R.width)&&ba(R.height)}function S(R){return o?!1:R.wrapS!==Ve||R.wrapT!==Ve||R.minFilter!==pe&&R.minFilter!==Ie}function T(R,M){return R.generateMipmaps&&M&&R.minFilter!==pe&&R.minFilter!==Ie}function A(R){i.generateMipmap(R)}function L(R,M,V,j,Q=!1){if(o===!1)return M;if(R!==null){if(i[R]!==void 0)return i[R];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format \'"+R+"\'")}let tt=M;return M===i.RED&&(V===i.FLOAT&&(tt=i.R32F),V===i.HALF_FLOAT&&(tt=i.R16F),V===i.UNSIGNED_BYTE&&(tt=i.R8)),M===i.RED_INTEGER&&(V===i.UNSIGNED_BYTE&&(tt=i.R8UI),V===i.UNSIGNED_SHORT&&(tt=i.R16UI),V===i.UNSIGNED_INT&&(tt=i.R32UI),V===i.BYTE&&(tt=i.R8I),V===i.SHORT&&(tt=i.R16I),V===i.INT&&(tt=i.R32I)),M===i.RG&&(V===i.FLOAT&&(tt=i.RG32F),V===i.HALF_FLOAT&&(tt=i.RG16F),V===i.UNSIGNED_BYTE&&(tt=i.RG8)),M===i.RGBA&&(V===i.FLOAT&&(tt=i.RGBA32F),V===i.HALF_FLOAT&&(tt=i.RGBA16F),V===i.UNSIGNED_BYTE&&(tt=j===Rt&&Q===!1?i.SRGB8_ALPHA8:i.RGBA8),V===i.UNSIGNED_SHORT_4_4_4_4&&(tt=i.RGBA4),V===i.UNSIGNED_SHORT_5_5_5_1&&(tt=i.RGB5_A1)),(tt===i.R16F||tt===i.R32F||tt===i.RG16F||tt===i.RG32F||tt===i.RGBA16F||tt===i.RGBA32F)&&t.get("EXT_color_buffer_float"),tt}function y(R,M,V){return T(R,V)===!0||R.isFramebufferTexture&&R.minFilter!==pe&&R.minFilter!==Ie?Math.log2(Math.max(M.width,M.height))+1:R.mipmaps!==void 0&&R.mipmaps.length>0?R.mipmaps.length:R.isCompressedTexture&&Array.isArray(R.image)?M.mipmaps.length:1}function w(R){return R===pe||R===Zo||R===er?i.NEAREST:i.LINEAR}function z(R){let M=R.target;M.removeEventListener("dispose",z),I(M),M.isVideoTexture&&g.delete(M)}function Y(R){let M=R.target;M.removeEventListener("dispose",Y),O(M)}function I(R){let M=n.get(R);if(M.__webglInit===void 0)return;let V=R.source,j=p.get(V);if(j){let Q=j[M.__cacheKey];Q.usedTimes--,Q.usedTimes===0&&D(R),Object.keys(j).length===0&&p.delete(V)}n.remove(R)}function D(R){let M=n.get(R);i.deleteTexture(M.__webglTexture);let V=R.source,j=p.get(V);delete j[M.__cacheKey],a.memory.textures--}function O(R){let M=R.texture,V=n.get(R),j=n.get(M);if(j.__webglTexture!==void 0&&(i.deleteTexture(j.__webglTexture),a.memory.textures--),R.depthTexture&&R.depthTexture.dispose(),R.isWebGLCubeRenderTarget)for(let Q=0;Q<6;Q++){if(Array.isArray(V.__webglFramebuffer[Q]))for(let tt=0;tt<V.__webglFramebuffer[Q].length;tt++)i.deleteFramebuffer(V.__webglFramebuffer[Q][tt]);else i.deleteFramebuffer(V.__webglFramebuffer[Q]);V.__webglDepthbuffer&&i.deleteRenderbuffer(V.__webglDepthbuffer[Q])}else{if(Array.isArray(V.__webglFramebuffer))for(let Q=0;Q<V.__webglFramebuffer.length;Q++)i.deleteFramebuffer(V.__webglFramebuffer[Q]);else i.deleteFramebuffer(V.__webglFramebuffer);if(V.__webglDepthbuffer&&i.deleteRenderbuffer(V.__webglDepthbuffer),V.__webglMultisampledFramebuffer&&i.deleteFramebuffer(V.__webglMultisampledFramebuffer),V.__webglColorRenderbuffer)for(let Q=0;Q<V.__webglColorRenderbuffer.length;Q++)V.__webglColorRenderbuffer[Q]&&i.deleteRenderbuffer(V.__webglColorRenderbuffer[Q]);V.__webglDepthRenderbuffer&&i.deleteRenderbuffer(V.__webglDepthRenderbuffer)}if(R.isWebGLMultipleRenderTargets)for(let Q=0,tt=M.length;Q<tt;Q++){let ft=n.get(M[Q]);ft.__webglTexture&&(i.deleteTexture(ft.__webglTexture),a.memory.textures--),n.remove(M[Q])}n.remove(M),n.remove(R)}let $=0;function G(){$=0}function q(){let R=$;return R>=c&&console.warn("THREE.WebGLTextures: Trying to use "+R+" texture units while this GPU supports only "+c),$+=1,R}function J(R){let M=[];return M.push(R.wrapS),M.push(R.wrapT),M.push(R.wrapR||0),M.push(R.magFilter),M.push(R.minFilter),M.push(R.anisotropy),M.push(R.internalFormat),M.push(R.format),M.push(R.type),M.push(R.generateMipmaps),M.push(R.premultiplyAlpha),M.push(R.flipY),M.push(R.unpackAlignment),M.push(R.colorSpace),M.join()}function K(R,M){let V=n.get(R);if(R.isVideoTexture&&re(R),R.isRenderTargetTexture===!1&&R.version>0&&V.__version!==R.version){let j=R.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{zt(V,R,M);return}}e.bindTexture(i.TEXTURE_2D,V.__webglTexture,i.TEXTURE0+M)}function B(R,M){let V=n.get(R);if(R.version>0&&V.__version!==R.version){zt(V,R,M);return}e.bindTexture(i.TEXTURE_2D_ARRAY,V.__webglTexture,i.TEXTURE0+M)}function Z(R,M){let V=n.get(R);if(R.version>0&&V.__version!==R.version){zt(V,R,M);return}e.bindTexture(i.TEXTURE_3D,V.__webglTexture,i.TEXTURE0+M)}function ot(R,M){let V=n.get(R);if(R.version>0&&V.__version!==R.version){xe(V,R,M);return}e.bindTexture(i.TEXTURE_CUBE_MAP,V.__webglTexture,i.TEXTURE0+M)}let at={[Dr]:i.REPEAT,[Ve]:i.CLAMP_TO_EDGE,[Nr]:i.MIRRORED_REPEAT},ct={[pe]:i.NEAREST,[Zo]:i.NEAREST_MIPMAP_NEAREST,[er]:i.NEAREST_MIPMAP_LINEAR,[Ie]:i.LINEAR,[Cl]:i.LINEAR_MIPMAP_NEAREST,[Hi]:i.LINEAR_MIPMAP_LINEAR},_t={[Wl]:i.NEVER,[Kl]:i.ALWAYS,[Xl]:i.LESS,[Yl]:i.LEQUAL,[ql]:i.EQUAL,[$l]:i.GEQUAL,[Zl]:i.GREATER,[Jl]:i.NOTEQUAL};function Et(R,M,V){if(V?(i.texParameteri(R,i.TEXTURE_WRAP_S,at[M.wrapS]),i.texParameteri(R,i.TEXTURE_WRAP_T,at[M.wrapT]),(R===i.TEXTURE_3D||R===i.TEXTURE_2D_ARRAY)&&i.texParameteri(R,i.TEXTURE_WRAP_R,at[M.wrapR]),i.texParameteri(R,i.TEXTURE_MAG_FILTER,ct[M.magFilter]),i.texParameteri(R,i.TEXTURE_MIN_FILTER,ct[M.minFilter])):(i.texParameteri(R,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(R,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),(R===i.TEXTURE_3D||R===i.TEXTURE_2D_ARRAY)&&i.texParameteri(R,i.TEXTURE_WRAP_R,i.CLAMP_TO_EDGE),(M.wrapS!==Ve||M.wrapT!==Ve)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),i.texParameteri(R,i.TEXTURE_MAG_FILTER,w(M.magFilter)),i.texParameteri(R,i.TEXTURE_MIN_FILTER,w(M.minFilter)),M.minFilter!==pe&&M.minFilter!==Ie&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),M.compareFunction&&(i.texParameteri(R,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(R,i.TEXTURE_COMPARE_FUNC,_t[M.compareFunction])),t.has("EXT_texture_filter_anisotropic")===!0){let j=t.get("EXT_texture_filter_anisotropic");if(M.magFilter===pe||M.minFilter!==er&&M.minFilter!==Hi||M.type===yn&&t.has("OES_texture_float_linear")===!1||o===!1&&M.type===Gi&&t.has("OES_texture_half_float_linear")===!1)return;(M.anisotropy>1||n.get(M).__currentAnisotropy)&&(i.texParameterf(R,j.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(M.anisotropy,s.getMaxAnisotropy())),n.get(M).__currentAnisotropy=M.anisotropy)}}function xt(R,M){let V=!1;R.__webglInit===void 0&&(R.__webglInit=!0,M.addEventListener("dispose",z));let j=M.source,Q=p.get(j);Q===void 0&&(Q={},p.set(j,Q));let tt=J(M);if(tt!==R.__cacheKey){Q[tt]===void 0&&(Q[tt]={texture:i.createTexture(),usedTimes:0},a.memory.textures++,V=!0),Q[tt].usedTimes++;let ft=Q[R.__cacheKey];ft!==void 0&&(Q[R.__cacheKey].usedTimes--,ft.usedTimes===0&&D(M)),R.__cacheKey=tt,R.__webglTexture=Q[tt].texture}return V}function zt(R,M,V){let j=i.TEXTURE_2D;(M.isDataArrayTexture||M.isCompressedArrayTexture)&&(j=i.TEXTURE_2D_ARRAY),M.isData3DTexture&&(j=i.TEXTURE_3D);let Q=xt(R,M),tt=M.source;e.bindTexture(j,R.__webglTexture,i.TEXTURE0+V);let ft=n.get(tt);if(tt.version!==ft.__version||Q===!0){e.activeTexture(i.TEXTURE0+V),i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,M.flipY),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,M.premultiplyAlpha),i.pixelStorei(i.UNPACK_ALIGNMENT,M.unpackAlignment),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,i.NONE);let et=S(M)&&b(M.image)===!1,H=_(M.image,et,!1,h);H=ae(M,H);let mt=b(H)||o,dt=r.convert(M.format,M.colorSpace),pt=r.convert(M.type),ht=L(M.internalFormat,dt,pt,M.colorSpace);Et(j,M,mt);let ut,It=M.mipmaps,Ht=o&&M.isVideoTexture!==!0,C=ft.__version===void 0||Q===!0,st=y(M,H,mt);if(M.isDepthTexture)ht=i.DEPTH_COMPONENT,o?M.type===yn?ht=i.DEPTH_COMPONENT32F:M.type===xn?ht=i.DEPTH_COMPONENT24:M.type===Fn?ht=i.DEPTH24_STENCIL8:ht=i.DEPTH_COMPONENT16:M.type===yn&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),M.format===On&&ht===i.DEPTH_COMPONENT&&M.type!==go&&M.type!==xn&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),M.type=xn,pt=r.convert(M.type)),M.format===_i&&ht===i.DEPTH_COMPONENT&&(ht=i.DEPTH_STENCIL,M.type!==Fn&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),M.type=Fn,pt=r.convert(M.type))),C&&(Ht?e.texStorage2D(i.TEXTURE_2D,1,ht,H.width,H.height):e.texImage2D(i.TEXTURE_2D,0,ht,H.width,H.height,0,dt,pt,null));else if(M.isDataTexture)if(It.length>0&&mt){Ht&&C&&e.texStorage2D(i.TEXTURE_2D,st,ht,It[0].width,It[0].height);for(let k=0,nt=It.length;k<nt;k++)ut=It[k],Ht?e.texSubImage2D(i.TEXTURE_2D,k,0,0,ut.width,ut.height,dt,pt,ut.data):e.texImage2D(i.TEXTURE_2D,k,ht,ut.width,ut.height,0,dt,pt,ut.data);M.generateMipmaps=!1}else Ht?(C&&e.texStorage2D(i.TEXTURE_2D,st,ht,H.width,H.height),e.texSubImage2D(i.TEXTURE_2D,0,0,0,H.width,H.height,dt,pt,H.data)):e.texImage2D(i.TEXTURE_2D,0,ht,H.width,H.height,0,dt,pt,H.data);else if(M.isCompressedTexture)if(M.isCompressedArrayTexture){Ht&&C&&e.texStorage3D(i.TEXTURE_2D_ARRAY,st,ht,It[0].width,It[0].height,H.depth);for(let k=0,nt=It.length;k<nt;k++)ut=It[k],M.format!==ke?dt!==null?Ht?e.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,k,0,0,0,ut.width,ut.height,H.depth,dt,ut.data,0,0):e.compressedTexImage3D(i.TEXTURE_2D_ARRAY,k,ht,ut.width,ut.height,H.depth,0,ut.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Ht?e.texSubImage3D(i.TEXTURE_2D_ARRAY,k,0,0,0,ut.width,ut.height,H.depth,dt,pt,ut.data):e.texImage3D(i.TEXTURE_2D_ARRAY,k,ht,ut.width,ut.height,H.depth,0,dt,pt,ut.data)}else{Ht&&C&&e.texStorage2D(i.TEXTURE_2D,st,ht,It[0].width,It[0].height);for(let k=0,nt=It.length;k<nt;k++)ut=It[k],M.format!==ke?dt!==null?Ht?e.compressedTexSubImage2D(i.TEXTURE_2D,k,0,0,ut.width,ut.height,dt,ut.data):e.compressedTexImage2D(i.TEXTURE_2D,k,ht,ut.width,ut.height,0,ut.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Ht?e.texSubImage2D(i.TEXTURE_2D,k,0,0,ut.width,ut.height,dt,pt,ut.data):e.texImage2D(i.TEXTURE_2D,k,ht,ut.width,ut.height,0,dt,pt,ut.data)}else if(M.isDataArrayTexture)Ht?(C&&e.texStorage3D(i.TEXTURE_2D_ARRAY,st,ht,H.width,H.height,H.depth),e.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,0,H.width,H.height,H.depth,dt,pt,H.data)):e.texImage3D(i.TEXTURE_2D_ARRAY,0,ht,H.width,H.height,H.depth,0,dt,pt,H.data);else if(M.isData3DTexture)Ht?(C&&e.texStorage3D(i.TEXTURE_3D,st,ht,H.width,H.height,H.depth),e.texSubImage3D(i.TEXTURE_3D,0,0,0,0,H.width,H.height,H.depth,dt,pt,H.data)):e.texImage3D(i.TEXTURE_3D,0,ht,H.width,H.height,H.depth,0,dt,pt,H.data);else if(M.isFramebufferTexture){if(C)if(Ht)e.texStorage2D(i.TEXTURE_2D,st,ht,H.width,H.height);else{let k=H.width,nt=H.height;for(let rt=0;rt<st;rt++)e.texImage2D(i.TEXTURE_2D,rt,ht,k,nt,0,dt,pt,null),k>>=1,nt>>=1}}else if(It.length>0&&mt){Ht&&C&&e.texStorage2D(i.TEXTURE_2D,st,ht,It[0].width,It[0].height);for(let k=0,nt=It.length;k<nt;k++)ut=It[k],Ht?e.texSubImage2D(i.TEXTURE_2D,k,0,0,dt,pt,ut):e.texImage2D(i.TEXTURE_2D,k,ht,dt,pt,ut);M.generateMipmaps=!1}else Ht?(C&&e.texStorage2D(i.TEXTURE_2D,st,ht,H.width,H.height),e.texSubImage2D(i.TEXTURE_2D,0,0,0,dt,pt,H)):e.texImage2D(i.TEXTURE_2D,0,ht,dt,pt,H);T(M,mt)&&A(j),ft.__version=tt.version,M.onUpdate&&M.onUpdate(M)}R.__version=M.version}function xe(R,M,V){if(M.image.length!==6)return;let j=xt(R,M),Q=M.source;e.bindTexture(i.TEXTURE_CUBE_MAP,R.__webglTexture,i.TEXTURE0+V);let tt=n.get(Q);if(Q.version!==tt.__version||j===!0){e.activeTexture(i.TEXTURE0+V),i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,M.flipY),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,M.premultiplyAlpha),i.pixelStorei(i.UNPACK_ALIGNMENT,M.unpackAlignment),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,i.NONE);let ft=M.isCompressedTexture||M.image[0].isCompressedTexture,et=M.image[0]&&M.image[0].isDataTexture,H=[];for(let k=0;k<6;k++)!ft&&!et?H[k]=_(M.image[k],!1,!0,l):H[k]=et?M.image[k].image:M.image[k],H[k]=ae(M,H[k]);let mt=H[0],dt=b(mt)||o,pt=r.convert(M.format,M.colorSpace),ht=r.convert(M.type),ut=L(M.internalFormat,pt,ht,M.colorSpace),It=o&&M.isVideoTexture!==!0,Ht=tt.__version===void 0||j===!0,C=y(M,mt,dt);Et(i.TEXTURE_CUBE_MAP,M,dt);let st;if(ft){It&&Ht&&e.texStorage2D(i.TEXTURE_CUBE_MAP,C,ut,mt.width,mt.height);for(let k=0;k<6;k++){st=H[k].mipmaps;for(let nt=0;nt<st.length;nt++){let rt=st[nt];M.format!==ke?pt!==null?It?e.compressedTexSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+k,nt,0,0,rt.width,rt.height,pt,rt.data):e.compressedTexImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+k,nt,ut,rt.width,rt.height,0,rt.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):It?e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+k,nt,0,0,rt.width,rt.height,pt,ht,rt.data):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+k,nt,ut,rt.width,rt.height,0,pt,ht,rt.data)}}}else{st=M.mipmaps,It&&Ht&&(st.length>0&&C++,e.texStorage2D(i.TEXTURE_CUBE_MAP,C,ut,H[0].width,H[0].height));for(let k=0;k<6;k++)if(et){It?e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+k,0,0,0,H[k].width,H[k].height,pt,ht,H[k].data):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+k,0,ut,H[k].width,H[k].height,0,pt,ht,H[k].data);for(let nt=0;nt<st.length;nt++){let Ot=st[nt].image[k].image;It?e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+k,nt+1,0,0,Ot.width,Ot.height,pt,ht,Ot.data):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+k,nt+1,ut,Ot.width,Ot.height,0,pt,ht,Ot.data)}}else{It?e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+k,0,0,0,pt,ht,H[k]):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+k,0,ut,pt,ht,H[k]);for(let nt=0;nt<st.length;nt++){let rt=st[nt];It?e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+k,nt+1,0,0,pt,ht,rt.image[k]):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+k,nt+1,ut,pt,ht,rt.image[k])}}}T(M,dt)&&A(i.TEXTURE_CUBE_MAP),tt.__version=Q.version,M.onUpdate&&M.onUpdate(M)}R.__version=M.version}function Pt(R,M,V,j,Q,tt){let ft=r.convert(V.format,V.colorSpace),et=r.convert(V.type),H=L(V.internalFormat,ft,et,V.colorSpace);if(!n.get(M).__hasExternalTextures){let dt=Math.max(1,M.width>>tt),pt=Math.max(1,M.height>>tt);Q===i.TEXTURE_3D||Q===i.TEXTURE_2D_ARRAY?e.texImage3D(Q,tt,H,dt,pt,M.depth,0,ft,et,null):e.texImage2D(Q,tt,H,dt,pt,0,ft,et,null)}e.bindFramebuffer(i.FRAMEBUFFER,R),Vt(M)?u.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,j,Q,n.get(V).__webglTexture,0,Lt(M)):(Q===i.TEXTURE_2D||Q>=i.TEXTURE_CUBE_MAP_POSITIVE_X&&Q<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,j,Q,n.get(V).__webglTexture,tt),e.bindFramebuffer(i.FRAMEBUFFER,null)}function F(R,M,V){if(i.bindRenderbuffer(i.RENDERBUFFER,R),M.depthBuffer&&!M.stencilBuffer){let j=i.DEPTH_COMPONENT16;if(V||Vt(M)){let Q=M.depthTexture;Q&&Q.isDepthTexture&&(Q.type===yn?j=i.DEPTH_COMPONENT32F:Q.type===xn&&(j=i.DEPTH_COMPONENT24));let tt=Lt(M);Vt(M)?u.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,tt,j,M.width,M.height):i.renderbufferStorageMultisample(i.RENDERBUFFER,tt,j,M.width,M.height)}else i.renderbufferStorage(i.RENDERBUFFER,j,M.width,M.height);i.framebufferRenderbuffer(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.RENDERBUFFER,R)}else if(M.depthBuffer&&M.stencilBuffer){let j=Lt(M);V&&Vt(M)===!1?i.renderbufferStorageMultisample(i.RENDERBUFFER,j,i.DEPTH24_STENCIL8,M.width,M.height):Vt(M)?u.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,j,i.DEPTH24_STENCIL8,M.width,M.height):i.renderbufferStorage(i.RENDERBUFFER,i.DEPTH_STENCIL,M.width,M.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.RENDERBUFFER,R)}else{let j=M.isWebGLMultipleRenderTargets===!0?M.texture:[M.texture];for(let Q=0;Q<j.length;Q++){let tt=j[Q],ft=r.convert(tt.format,tt.colorSpace),et=r.convert(tt.type),H=L(tt.internalFormat,ft,et,tt.colorSpace),mt=Lt(M);V&&Vt(M)===!1?i.renderbufferStorageMultisample(i.RENDERBUFFER,mt,H,M.width,M.height):Vt(M)?u.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,mt,H,M.width,M.height):i.renderbufferStorage(i.RENDERBUFFER,H,M.width,M.height)}}i.bindRenderbuffer(i.RENDERBUFFER,null)}function oe(R,M){if(M&&M.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(e.bindFramebuffer(i.FRAMEBUFFER,R),!(M.depthTexture&&M.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!n.get(M.depthTexture).__webglTexture||M.depthTexture.image.width!==M.width||M.depthTexture.image.height!==M.height)&&(M.depthTexture.image.width=M.width,M.depthTexture.image.height=M.height,M.depthTexture.needsUpdate=!0),K(M.depthTexture,0);let j=n.get(M.depthTexture).__webglTexture,Q=Lt(M);if(M.depthTexture.format===On)Vt(M)?u.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,j,0,Q):i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,j,0);else if(M.depthTexture.format===_i)Vt(M)?u.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.TEXTURE_2D,j,0,Q):i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.TEXTURE_2D,j,0);else throw new Error("Unknown depthTexture format")}function yt(R){let M=n.get(R),V=R.isWebGLCubeRenderTarget===!0;if(R.depthTexture&&!M.__autoAllocateDepthBuffer){if(V)throw new Error("target.depthTexture not supported in Cube render targets");oe(M.__webglFramebuffer,R)}else if(V){M.__webglDepthbuffer=[];for(let j=0;j<6;j++)e.bindFramebuffer(i.FRAMEBUFFER,M.__webglFramebuffer[j]),M.__webglDepthbuffer[j]=i.createRenderbuffer(),F(M.__webglDepthbuffer[j],R,!1)}else e.bindFramebuffer(i.FRAMEBUFFER,M.__webglFramebuffer),M.__webglDepthbuffer=i.createRenderbuffer(),F(M.__webglDepthbuffer,R,!1);e.bindFramebuffer(i.FRAMEBUFFER,null)}function Tt(R,M,V){let j=n.get(R);M!==void 0&&Pt(j.__webglFramebuffer,R,R.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,0),V!==void 0&&yt(R)}function bt(R){let M=R.texture,V=n.get(R),j=n.get(M);R.addEventListener("dispose",Y),R.isWebGLMultipleRenderTargets!==!0&&(j.__webglTexture===void 0&&(j.__webglTexture=i.createTexture()),j.__version=M.version,a.memory.textures++);let Q=R.isWebGLCubeRenderTarget===!0,tt=R.isWebGLMultipleRenderTargets===!0,ft=b(R)||o;if(Q){V.__webglFramebuffer=[];for(let et=0;et<6;et++)if(o&&M.mipmaps&&M.mipmaps.length>0){V.__webglFramebuffer[et]=[];for(let H=0;H<M.mipmaps.length;H++)V.__webglFramebuffer[et][H]=i.createFramebuffer()}else V.__webglFramebuffer[et]=i.createFramebuffer()}else{if(o&&M.mipmaps&&M.mipmaps.length>0){V.__webglFramebuffer=[];for(let et=0;et<M.mipmaps.length;et++)V.__webglFramebuffer[et]=i.createFramebuffer()}else V.__webglFramebuffer=i.createFramebuffer();if(tt)if(s.drawBuffers){let et=R.texture;for(let H=0,mt=et.length;H<mt;H++){let dt=n.get(et[H]);dt.__webglTexture===void 0&&(dt.__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&&R.samples>0&&Vt(R)===!1){let et=tt?M:[M];V.__webglMultisampledFramebuffer=i.createFramebuffer(),V.__webglColorRenderbuffer=[],e.bindFramebuffer(i.FRAMEBUFFER,V.__webglMultisampledFramebuffer);for(let H=0;H<et.length;H++){let mt=et[H];V.__webglColorRenderbuffer[H]=i.createRenderbuffer(),i.bindRenderbuffer(i.RENDERBUFFER,V.__webglColorRenderbuffer[H]);let dt=r.convert(mt.format,mt.colorSpace),pt=r.convert(mt.type),ht=L(mt.internalFormat,dt,pt,mt.colorSpace,R.isXRRenderTarget===!0),ut=Lt(R);i.renderbufferStorageMultisample(i.RENDERBUFFER,ut,ht,R.width,R.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+H,i.RENDERBUFFER,V.__webglColorRenderbuffer[H])}i.bindRenderbuffer(i.RENDERBUFFER,null),R.depthBuffer&&(V.__webglDepthRenderbuffer=i.createRenderbuffer(),F(V.__webglDepthRenderbuffer,R,!0)),e.bindFramebuffer(i.FRAMEBUFFER,null)}}if(Q){e.bindTexture(i.TEXTURE_CUBE_MAP,j.__webglTexture),Et(i.TEXTURE_CUBE_MAP,M,ft);for(let et=0;et<6;et++)if(o&&M.mipmaps&&M.mipmaps.length>0)for(let H=0;H<M.mipmaps.length;H++)Pt(V.__webglFramebuffer[et][H],R,M,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+et,H);else Pt(V.__webglFramebuffer[et],R,M,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+et,0);T(M,ft)&&A(i.TEXTURE_CUBE_MAP),e.unbindTexture()}else if(tt){let et=R.texture;for(let H=0,mt=et.length;H<mt;H++){let dt=et[H],pt=n.get(dt);e.bindTexture(i.TEXTURE_2D,pt.__webglTexture),Et(i.TEXTURE_2D,dt,ft),Pt(V.__webglFramebuffer,R,dt,i.COLOR_ATTACHMENT0+H,i.TEXTURE_2D,0),T(dt,ft)&&A(i.TEXTURE_2D)}e.unbindTexture()}else{let et=i.TEXTURE_2D;if((R.isWebGL3DRenderTarget||R.isWebGLArrayRenderTarget)&&(o?et=R.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),e.bindTexture(et,j.__webglTexture),Et(et,M,ft),o&&M.mipmaps&&M.mipmaps.length>0)for(let H=0;H<M.mipmaps.length;H++)Pt(V.__webglFramebuffer[H],R,M,i.COLOR_ATTACHMENT0,et,H);else Pt(V.__webglFramebuffer,R,M,i.COLOR_ATTACHMENT0,et,0);T(M,ft)&&A(et),e.unbindTexture()}R.depthBuffer&&yt(R)}function Xt(R){let M=b(R)||o,V=R.isWebGLMultipleRenderTargets===!0?R.texture:[R.texture];for(let j=0,Q=V.length;j<Q;j++){let tt=V[j];if(T(tt,M)){let ft=R.isWebGLCubeRenderTarget?i.TEXTURE_CUBE_MAP:i.TEXTURE_2D,et=n.get(tt).__webglTexture;e.bindTexture(ft,et),A(ft),e.unbindTexture()}}}function Ft(R){if(o&&R.samples>0&&Vt(R)===!1){let M=R.isWebGLMultipleRenderTargets?R.texture:[R.texture],V=R.width,j=R.height,Q=i.COLOR_BUFFER_BIT,tt=[],ft=R.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,et=n.get(R),H=R.isWebGLMultipleRenderTargets===!0;if(H)for(let mt=0;mt<M.length;mt++)e.bindFramebuffer(i.FRAMEBUFFER,et.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+mt,i.RENDERBUFFER,null),e.bindFramebuffer(i.FRAMEBUFFER,et.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+mt,i.TEXTURE_2D,null,0);e.bindFramebuffer(i.READ_FRAMEBUFFER,et.__webglMultisampledFramebuffer),e.bindFramebuffer(i.DRAW_FRAMEBUFFER,et.__webglFramebuffer);for(let mt=0;mt<M.length;mt++){tt.push(i.COLOR_ATTACHMENT0+mt),R.depthBuffer&&tt.push(ft);let dt=et.__ignoreDepthValues!==void 0?et.__ignoreDepthValues:!1;if(dt===!1&&(R.depthBuffer&&(Q|=i.DEPTH_BUFFER_BIT),R.stencilBuffer&&(Q|=i.STENCIL_BUFFER_BIT)),H&&i.framebufferRenderbuffer(i.READ_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,et.__webglColorRenderbuffer[mt]),dt===!0&&(i.invalidateFramebuffer(i.READ_FRAMEBUFFER,[ft]),i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,[ft])),H){let pt=n.get(M[mt]).__webglTexture;i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,pt,0)}i.blitFramebuffer(0,0,V,j,0,0,V,j,Q,i.NEAREST),m&&i.invalidateFramebuffer(i.READ_FRAMEBUFFER,tt)}if(e.bindFramebuffer(i.READ_FRAMEBUFFER,null),e.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),H)for(let mt=0;mt<M.length;mt++){e.bindFramebuffer(i.FRAMEBUFFER,et.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+mt,i.RENDERBUFFER,et.__webglColorRenderbuffer[mt]);let dt=n.get(M[mt]).__webglTexture;e.bindFramebuffer(i.FRAMEBUFFER,et.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+mt,i.TEXTURE_2D,dt,0)}e.bindFramebuffer(i.DRAW_FRAMEBUFFER,et.__webglMultisampledFramebuffer)}}function Lt(R){return Math.min(d,R.samples)}function Vt(R){let M=n.get(R);return o&&R.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&M.__useRenderToTexture!==!1}function re(R){let M=a.render.frame;g.get(R)!==M&&(g.set(R,M),R.update())}function ae(R,M){let V=R.colorSpace,j=R.format,Q=R.type;return R.isCompressedTexture===!0||R.format===Fr||V!==Ze&&V!==zn&&(V===Rt?o===!1?t.has("EXT_sRGB")===!0&&j===ke?(R.format=Fr,R.minFilter=Ie,R.generateMipmaps=!1):M=As.sRGBToLinear(M):(j!==ke||Q!==Sn)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",V)),M}this.allocateTextureUnit=q,this.resetTextureUnits=G,this.setTexture2D=K,this.setTexture2DArray=B,this.setTexture3D=Z,this.setTextureCube=ot,this.rebindTextures=Tt,this.setupRenderTarget=bt,this.updateRenderTargetMipmap=Xt,this.updateMultisampleRenderTarget=Ft,this.setupDepthRenderbuffer=yt,this.setupFrameBufferTexture=Pt,this.useMultisampledRTT=Vt}function kp(i,t,e){let n=e.isWebGL2;function s(r,a=zn){let o;if(r===Sn)return i.UNSIGNED_BYTE;if(r===dc)return i.UNSIGNED_SHORT_4_4_4_4;if(r===pc)return i.UNSIGNED_SHORT_5_5_5_1;if(r===Pl)return i.BYTE;if(r===Ll)return i.SHORT;if(r===go)return i.UNSIGNED_SHORT;if(r===fc)return i.INT;if(r===xn)return i.UNSIGNED_INT;if(r===yn)return i.FLOAT;if(r===Gi)return n?i.HALF_FLOAT:(o=t.get("OES_texture_half_float"),o!==null?o.HALF_FLOAT_OES:null);if(r===Il)return i.ALPHA;if(r===ke)return i.RGBA;if(r===Ul)return i.LUMINANCE;if(r===Dl)return i.LUMINANCE_ALPHA;if(r===On)return i.DEPTH_COMPONENT;if(r===_i)return i.DEPTH_STENCIL;if(r===Fr)return o=t.get("EXT_sRGB"),o!==null?o.SRGB_ALPHA_EXT:null;if(r===Nl)return i.RED;if(r===mc)return i.RED_INTEGER;if(r===Fl)return i.RG;if(r===gc)return i.RG_INTEGER;if(r===_c)return i.RGBA_INTEGER;if(r===nr||r===ir||r===sr||r===rr)if(a===Rt)if(o=t.get("WEBGL_compressed_texture_s3tc_srgb"),o!==null){if(r===nr)return o.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(r===ir)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(r===sr)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(r===rr)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(o=t.get("WEBGL_compressed_texture_s3tc"),o!==null){if(r===nr)return o.COMPRESSED_RGB_S3TC_DXT1_EXT;if(r===ir)return o.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(r===sr)return o.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(r===rr)return o.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(r===Jo||r===$o||r===Ko||r===Qo)if(o=t.get("WEBGL_compressed_texture_pvrtc"),o!==null){if(r===Jo)return o.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(r===$o)return o.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(r===Ko)return o.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(r===Qo)return o.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(r===Ol)return o=t.get("WEBGL_compressed_texture_etc1"),o!==null?o.COMPRESSED_RGB_ETC1_WEBGL:null;if(r===jo||r===ta)if(o=t.get("WEBGL_compressed_texture_etc"),o!==null){if(r===jo)return a===Rt?o.COMPRESSED_SRGB8_ETC2:o.COMPRESSED_RGB8_ETC2;if(r===ta)return a===Rt?o.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:o.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(r===ea||r===na||r===ia||r===sa||r===ra||r===oa||r===aa||r===ca||r===la||r===ha||r===ua||r===fa||r===da||r===pa)if(o=t.get("WEBGL_compressed_texture_astc"),o!==null){if(r===ea)return a===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:o.COMPRESSED_RGBA_ASTC_4x4_KHR;if(r===na)return a===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:o.COMPRESSED_RGBA_ASTC_5x4_KHR;if(r===ia)return a===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:o.COMPRESSED_RGBA_ASTC_5x5_KHR;if(r===sa)return a===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:o.COMPRESSED_RGBA_ASTC_6x5_KHR;if(r===ra)return a===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:o.COMPRESSED_RGBA_ASTC_6x6_KHR;if(r===oa)return a===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:o.COMPRESSED_RGBA_ASTC_8x5_KHR;if(r===aa)return a===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:o.COMPRESSED_RGBA_ASTC_8x6_KHR;if(r===ca)return a===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:o.COMPRESSED_RGBA_ASTC_8x8_KHR;if(r===la)return a===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:o.COMPRESSED_RGBA_ASTC_10x5_KHR;if(r===ha)return a===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:o.COMPRESSED_RGBA_ASTC_10x6_KHR;if(r===ua)return a===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:o.COMPRESSED_RGBA_ASTC_10x8_KHR;if(r===fa)return a===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:o.COMPRESSED_RGBA_ASTC_10x10_KHR;if(r===da)return a===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:o.COMPRESSED_RGBA_ASTC_12x10_KHR;if(r===pa)return a===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:o.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(r===or)if(o=t.get("EXT_texture_compression_bptc"),o!==null){if(r===or)return a===Rt?o.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:o.COMPRESSED_RGBA_BPTC_UNORM_EXT}else return null;if(r===Bl||r===ma||r===ga||r===_a)if(o=t.get("EXT_texture_compression_rgtc"),o!==null){if(r===or)return o.COMPRESSED_RED_RGTC1_EXT;if(r===ma)return o.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(r===ga)return o.COMPRESSED_RED_GREEN_RGTC2_EXT;if(r===_a)return o.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return r===Fn?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 jr=class extends Re{constructor(t=[]){super(),this.isArrayCamera=!0,this.cameras=t}},ui=class extends ve{constructor(){super(),this.isGroup=!0,this.type="Group"}},Hp={type:"move"},ki=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new ui,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 ui,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 ui,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 p=e.getJointPose(x,n),f=this._getHandJoint(l,x);p!==null&&(f.matrix.fromArray(p.transform.matrix),f.matrix.decompose(f.position,f.rotation,f.scale),f.matrixWorldNeedsUpdate=!0,f.jointRadius=p.radius),f.visible=p!==null}let h=l.joints["index-finger-tip"],d=l.joints["thumb-tip"],u=h.position.distanceTo(d.position),m=.02,g=.005;l.inputState.pinching&&u>m+g?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!l.inputState.pinching&&u<=m-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(Hp)))}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 ui;n.matrixAutoUpdate=!1,n.visible=!1,t.joints[e.jointName]=n,t.add(n)}return t.joints[e.jointName]}},to=class extends ge{constructor(t,e,n,s,r,a,o,c,l,h){if(h=h!==void 0?h:On,h!==On&&h!==_i)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");n===void 0&&h===On&&(n=xn),n===void 0&&h===_i&&(n=Fn),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:pe,this.minFilter=c!==void 0?c:pe,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(t){return super.copy(t),this.compareFunction=t.compareFunction,this}toJSON(t){let e=super.toJSON(t);return this.compareFunction!==null&&(e.compareFunction=this.compareFunction),e}},eo=class extends bn{constructor(t,e){super();let n=this,s=null,r=1,a=null,o="local-floor",c=1,l=null,h=null,d=null,u=null,m=null,g=null,x=e.getContextAttributes(),p=null,f=null,v=[],_=[],b=new Re;b.layers.enable(1),b.viewport=new jt;let S=new Re;S.layers.enable(2),S.viewport=new jt;let T=[b,S],A=new jr;A.layers.enable(1),A.layers.enable(2);let L=null,y=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(B){let Z=v[B];return Z===void 0&&(Z=new ki,v[B]=Z),Z.getTargetRaySpace()},this.getControllerGrip=function(B){let Z=v[B];return Z===void 0&&(Z=new ki,v[B]=Z),Z.getGripSpace()},this.getHand=function(B){let Z=v[B];return Z===void 0&&(Z=new ki,v[B]=Z),Z.getHandSpace()};function w(B){let Z=_.indexOf(B.inputSource);if(Z===-1)return;let ot=v[Z];ot!==void 0&&(ot.update(B.inputSource,B.frame,l||a),ot.dispatchEvent({type:B.type,data:B.inputSource}))}function z(){s.removeEventListener("select",w),s.removeEventListener("selectstart",w),s.removeEventListener("selectend",w),s.removeEventListener("squeeze",w),s.removeEventListener("squeezestart",w),s.removeEventListener("squeezeend",w),s.removeEventListener("end",z),s.removeEventListener("inputsourceschange",Y);for(let B=0;B<v.length;B++){let Z=_[B];Z!==null&&(_[B]=null,v[B].disconnect(Z))}L=null,y=null,t.setRenderTarget(p),m=null,u=null,d=null,s=null,f=null,K.stop(),n.isPresenting=!1,n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(B){r=B,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(B){o=B,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||a},this.setReferenceSpace=function(B){l=B},this.getBaseLayer=function(){return u!==null?u:m},this.getBinding=function(){return d},this.getFrame=function(){return g},this.getSession=function(){return s},this.setSession=async function(B){if(s=B,s!==null){if(p=t.getRenderTarget(),s.addEventListener("select",w),s.addEventListener("selectstart",w),s.addEventListener("selectend",w),s.addEventListener("squeeze",w),s.addEventListener("squeezestart",w),s.addEventListener("squeezeend",w),s.addEventListener("end",z),s.addEventListener("inputsourceschange",Y),x.xrCompatible!==!0&&await e.makeXRCompatible(),s.renderState.layers===void 0||t.capabilities.isWebGL2===!1){let Z={antialias:s.renderState.layers===void 0?x.antialias:!0,alpha:!0,depth:x.depth,stencil:x.stencil,framebufferScaleFactor:r};m=new XRWebGLLayer(s,e,Z),s.updateRenderState({baseLayer:m}),f=new cn(m.framebufferWidth,m.framebufferHeight,{format:ke,type:Sn,colorSpace:t.outputColorSpace,stencilBuffer:x.stencil})}else{let Z=null,ot=null,at=null;x.depth&&(at=x.stencil?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT24,Z=x.stencil?_i:On,ot=x.stencil?Fn:xn);let ct={colorFormat:e.RGBA8,depthFormat:at,scaleFactor:r};d=new XRWebGLBinding(s,e),u=d.createProjectionLayer(ct),s.updateRenderState({layers:[u]}),f=new cn(u.textureWidth,u.textureHeight,{format:ke,type:Sn,depthTexture:new to(u.textureWidth,u.textureHeight,ot,void 0,void 0,void 0,void 0,void 0,void 0,Z),stencilBuffer:x.stencil,colorSpace:t.outputColorSpace,samples:x.antialias?4:0});let _t=t.properties.get(f);_t.__ignoreDepthValues=u.ignoreDepthValues}f.isXRRenderTarget=!0,this.setFoveation(c),l=null,a=await s.requestReferenceSpace(o),K.setContext(s),K.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(s!==null)return s.environmentBlendMode};function Y(B){for(let Z=0;Z<B.removed.length;Z++){let ot=B.removed[Z],at=_.indexOf(ot);at>=0&&(_[at]=null,v[at].disconnect(ot))}for(let Z=0;Z<B.added.length;Z++){let ot=B.added[Z],at=_.indexOf(ot);if(at===-1){for(let _t=0;_t<v.length;_t++)if(_t>=_.length){_.push(ot),at=_t;break}else if(_[_t]===null){_[_t]=ot,at=_t;break}if(at===-1)break}let ct=v[at];ct&&ct.connect(ot)}}let I=new P,D=new P;function O(B,Z,ot){I.setFromMatrixPosition(Z.matrixWorld),D.setFromMatrixPosition(ot.matrixWorld);let at=I.distanceTo(D),ct=Z.projectionMatrix.elements,_t=ot.projectionMatrix.elements,Et=ct[14]/(ct[10]-1),xt=ct[14]/(ct[10]+1),zt=(ct[9]+1)/ct[5],xe=(ct[9]-1)/ct[5],Pt=(ct[8]-1)/ct[0],F=(_t[8]+1)/_t[0],oe=Et*Pt,yt=Et*F,Tt=at/(-Pt+F),bt=Tt*-Pt;Z.matrixWorld.decompose(B.position,B.quaternion,B.scale),B.translateX(bt),B.translateZ(Tt),B.matrixWorld.compose(B.position,B.quaternion,B.scale),B.matrixWorldInverse.copy(B.matrixWorld).invert();let Xt=Et+Tt,Ft=xt+Tt,Lt=oe-bt,Vt=yt+(at-bt),re=zt*xt/Ft*Xt,ae=xe*xt/Ft*Xt;B.projectionMatrix.makePerspective(Lt,Vt,re,ae,Xt,Ft),B.projectionMatrixInverse.copy(B.projectionMatrix).invert()}function $(B,Z){Z===null?B.matrixWorld.copy(B.matrix):B.matrixWorld.multiplyMatrices(Z.matrixWorld,B.matrix),B.matrixWorldInverse.copy(B.matrixWorld).invert()}this.updateCamera=function(B){if(s===null)return;A.near=S.near=b.near=B.near,A.far=S.far=b.far=B.far,(L!==A.near||y!==A.far)&&(s.updateRenderState({depthNear:A.near,depthFar:A.far}),L=A.near,y=A.far);let Z=B.parent,ot=A.cameras;$(A,Z);for(let at=0;at<ot.length;at++)$(ot[at],Z);ot.length===2?O(A,b,S):A.projectionMatrix.copy(b.projectionMatrix),G(B,A,Z)};function G(B,Z,ot){ot===null?B.matrix.copy(Z.matrixWorld):(B.matrix.copy(ot.matrixWorld),B.matrix.invert(),B.matrix.multiply(Z.matrixWorld)),B.matrix.decompose(B.position,B.quaternion,B.scale),B.updateMatrixWorld(!0);let at=B.children;for(let ct=0,_t=at.length;ct<_t;ct++)at[ct].updateMatrixWorld(!0);B.projectionMatrix.copy(Z.projectionMatrix),B.projectionMatrixInverse.copy(Z.projectionMatrixInverse),B.isPerspectiveCamera&&(B.fov=Or*2*Math.atan(1/B.projectionMatrix.elements[5]),B.zoom=1)}this.getCamera=function(){return A},this.getFoveation=function(){if(!(u===null&&m===null))return c},this.setFoveation=function(B){c=B,u!==null&&(u.fixedFoveation=B),m!==null&&m.fixedFoveation!==void 0&&(m.fixedFoveation=B)};let q=null;function J(B,Z){if(h=Z.getViewerPose(l||a),g=Z,h!==null){let ot=h.views;m!==null&&(t.setRenderTargetFramebuffer(f,m.framebuffer),t.setRenderTarget(f));let at=!1;ot.length!==A.cameras.length&&(A.cameras.length=0,at=!0);for(let ct=0;ct<ot.length;ct++){let _t=ot[ct],Et=null;if(m!==null)Et=m.getViewport(_t);else{let zt=d.getViewSubImage(u,_t);Et=zt.viewport,ct===0&&(t.setRenderTargetTextures(f,zt.colorTexture,u.ignoreDepthValues?void 0:zt.depthStencilTexture),t.setRenderTarget(f))}let xt=T[ct];xt===void 0&&(xt=new Re,xt.layers.enable(ct),xt.viewport=new jt,T[ct]=xt),xt.matrix.fromArray(_t.transform.matrix),xt.matrix.decompose(xt.position,xt.quaternion,xt.scale),xt.projectionMatrix.fromArray(_t.projectionMatrix),xt.projectionMatrixInverse.copy(xt.projectionMatrix).invert(),xt.viewport.set(Et.x,Et.y,Et.width,Et.height),ct===0&&(A.matrix.copy(xt.matrix),A.matrix.decompose(A.position,A.quaternion,A.scale)),at===!0&&A.cameras.push(xt)}}for(let ot=0;ot<v.length;ot++){let at=_[ot],ct=v[ot];at!==null&&ct!==void 0&&ct.update(at,Z,l||a)}q&&q(B,Z),Z.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:Z}),g=null}let K=new bc;K.setAnimationLoop(J),this.setAnimationLoop=function(B){q=B},this.dispose=function(){}}};function Gp(i,t){function e(p,f){p.matrixAutoUpdate===!0&&p.updateMatrix(),f.value.copy(p.matrix)}function n(p,f){f.color.getRGB(p.fogColor.value,Sc(i)),f.isFog?(p.fogNear.value=f.near,p.fogFar.value=f.far):f.isFogExp2&&(p.fogDensity.value=f.density)}function s(p,f,v,_,b){f.isMeshBasicMaterial||f.isMeshLambertMaterial?r(p,f):f.isMeshToonMaterial?(r(p,f),d(p,f)):f.isMeshPhongMaterial?(r(p,f),h(p,f)):f.isMeshStandardMaterial?(r(p,f),u(p,f),f.isMeshPhysicalMaterial&&m(p,f,b)):f.isMeshMatcapMaterial?(r(p,f),g(p,f)):f.isMeshDepthMaterial?r(p,f):f.isMeshDistanceMaterial?(r(p,f),x(p,f)):f.isMeshNormalMaterial?r(p,f):f.isLineBasicMaterial?(a(p,f),f.isLineDashedMaterial&&o(p,f)):f.isPointsMaterial?c(p,f,v,_):f.isSpriteMaterial?l(p,f):f.isShadowMaterial?(p.color.value.copy(f.color),p.opacity.value=f.opacity):f.isShaderMaterial&&(f.uniformsNeedUpdate=!1)}function r(p,f){p.opacity.value=f.opacity,f.color&&p.diffuse.value.copy(f.color),f.emissive&&p.emissive.value.copy(f.emissive).multiplyScalar(f.emissiveIntensity),f.map&&(p.map.value=f.map,e(f.map,p.mapTransform)),f.alphaMap&&(p.alphaMap.value=f.alphaMap,e(f.alphaMap,p.alphaMapTransform)),f.bumpMap&&(p.bumpMap.value=f.bumpMap,e(f.bumpMap,p.bumpMapTransform),p.bumpScale.value=f.bumpScale,f.side===he&&(p.bumpScale.value*=-1)),f.normalMap&&(p.normalMap.value=f.normalMap,e(f.normalMap,p.normalMapTransform),p.normalScale.value.copy(f.normalScale),f.side===he&&p.normalScale.value.negate()),f.displacementMap&&(p.displacementMap.value=f.displacementMap,e(f.displacementMap,p.displacementMapTransform),p.displacementScale.value=f.displacementScale,p.displacementBias.value=f.displacementBias),f.emissiveMap&&(p.emissiveMap.value=f.emissiveMap,e(f.emissiveMap,p.emissiveMapTransform)),f.specularMap&&(p.specularMap.value=f.specularMap,e(f.specularMap,p.specularMapTransform)),f.alphaTest>0&&(p.alphaTest.value=f.alphaTest);let v=t.get(f).envMap;if(v&&(p.envMap.value=v,p.flipEnvMap.value=v.isCubeTexture&&v.isRenderTargetTexture===!1?-1:1,p.reflectivity.value=f.reflectivity,p.ior.value=f.ior,p.refractionRatio.value=f.refractionRatio),f.lightMap){p.lightMap.value=f.lightMap;let _=i._useLegacyLights===!0?Math.PI:1;p.lightMapIntensity.value=f.lightMapIntensity*_,e(f.lightMap,p.lightMapTransform)}f.aoMap&&(p.aoMap.value=f.aoMap,p.aoMapIntensity.value=f.aoMapIntensity,e(f.aoMap,p.aoMapTransform))}function a(p,f){p.diffuse.value.copy(f.color),p.opacity.value=f.opacity,f.map&&(p.map.value=f.map,e(f.map,p.mapTransform))}function o(p,f){p.dashSize.value=f.dashSize,p.totalSize.value=f.dashSize+f.gapSize,p.scale.value=f.scale}function c(p,f,v,_){p.diffuse.value.copy(f.color),p.opacity.value=f.opacity,p.size.value=f.size*v,p.scale.value=_*.5,f.map&&(p.map.value=f.map,e(f.map,p.uvTransform)),f.alphaMap&&(p.alphaMap.value=f.alphaMap,e(f.alphaMap,p.alphaMapTransform)),f.alphaTest>0&&(p.alphaTest.value=f.alphaTest)}function l(p,f){p.diffuse.value.copy(f.color),p.opacity.value=f.opacity,p.rotation.value=f.rotation,f.map&&(p.map.value=f.map,e(f.map,p.mapTransform)),f.alphaMap&&(p.alphaMap.value=f.alphaMap,e(f.alphaMap,p.alphaMapTransform)),f.alphaTest>0&&(p.alphaTest.value=f.alphaTest)}function h(p,f){p.specular.value.copy(f.specular),p.shininess.value=Math.max(f.shininess,1e-4)}function d(p,f){f.gradientMap&&(p.gradientMap.value=f.gradientMap)}function u(p,f){p.metalness.value=f.metalness,f.metalnessMap&&(p.metalnessMap.value=f.metalnessMap,e(f.metalnessMap,p.metalnessMapTransform)),p.roughness.value=f.roughness,f.roughnessMap&&(p.roughnessMap.value=f.roughnessMap,e(f.roughnessMap,p.roughnessMapTransform)),t.get(f).envMap&&(p.envMapIntensity.value=f.envMapIntensity)}function m(p,f,v){p.ior.value=f.ior,f.sheen>0&&(p.sheenColor.value.copy(f.sheenColor).multiplyScalar(f.sheen),p.sheenRoughness.value=f.sheenRoughness,f.sheenColorMap&&(p.sheenColorMap.value=f.sheenColorMap,e(f.sheenColorMap,p.sheenColorMapTransform)),f.sheenRoughnessMap&&(p.sheenRoughnessMap.value=f.sheenRoughnessMap,e(f.sheenRoughnessMap,p.sheenRoughnessMapTransform))),f.clearcoat>0&&(p.clearcoat.value=f.clearcoat,p.clearcoatRoughness.value=f.clearcoatRoughness,f.clearcoatMap&&(p.clearcoatMap.value=f.clearcoatMap,e(f.clearcoatMap,p.clearcoatMapTransform)),f.clearcoatRoughnessMap&&(p.clearcoatRoughnessMap.value=f.clearcoatRoughnessMap,e(f.clearcoatRoughnessMap,p.clearcoatRoughnessMapTransform)),f.clearcoatNormalMap&&(p.clearcoatNormalMap.value=f.clearcoatNormalMap,e(f.clearcoatNormalMap,p.clearcoatNormalMapTransform),p.clearcoatNormalScale.value.copy(f.clearcoatNormalScale),f.side===he&&p.clearcoatNormalScale.value.negate())),f.iridescence>0&&(p.iridescence.value=f.iridescence,p.iridescenceIOR.value=f.iridescenceIOR,p.iridescenceThicknessMinimum.value=f.iridescenceThicknessRange[0],p.iridescenceThicknessMaximum.value=f.iridescenceThicknessRange[1],f.iridescenceMap&&(p.iridescenceMap.value=f.iridescenceMap,e(f.iridescenceMap,p.iridescenceMapTransform)),f.iridescenceThicknessMap&&(p.iridescenceThicknessMap.value=f.iridescenceThicknessMap,e(f.iridescenceThicknessMap,p.iridescenceThicknessMapTransform))),f.transmission>0&&(p.transmission.value=f.transmission,p.transmissionSamplerMap.value=v.texture,p.transmissionSamplerSize.value.set(v.width,v.height),f.transmissionMap&&(p.transmissionMap.value=f.transmissionMap,e(f.transmissionMap,p.transmissionMapTransform)),p.thickness.value=f.thickness,f.thicknessMap&&(p.thicknessMap.value=f.thicknessMap,e(f.thicknessMap,p.thicknessMapTransform)),p.attenuationDistance.value=f.attenuationDistance,p.attenuationColor.value.copy(f.attenuationColor)),f.anisotropy>0&&(p.anisotropyVector.value.set(f.anisotropy*Math.cos(f.anisotropyRotation),f.anisotropy*Math.sin(f.anisotropyRotation)),f.anisotropyMap&&(p.anisotropyMap.value=f.anisotropyMap,e(f.anisotropyMap,p.anisotropyMapTransform))),p.specularIntensity.value=f.specularIntensity,p.specularColor.value.copy(f.specularColor),f.specularColorMap&&(p.specularColorMap.value=f.specularColorMap,e(f.specularColorMap,p.specularColorMapTransform)),f.specularIntensityMap&&(p.specularIntensityMap.value=f.specularIntensityMap,e(f.specularIntensityMap,p.specularIntensityMapTransform))}function g(p,f){f.matcap&&(p.matcap.value=f.matcap)}function x(p,f){let v=t.get(f).light;p.referencePosition.value.setFromMatrixPosition(v.matrixWorld),p.nearDistance.value=v.shadow.camera.near,p.farDistance.value=v.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:s}}function Wp(i,t,e,n){let s={},r={},a=[],o=e.isWebGL2?i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS):0;function c(v,_){let b=_.program;n.uniformBlockBinding(v,b)}function l(v,_){let b=s[v.id];b===void 0&&(g(v),b=h(v),s[v.id]=b,v.addEventListener("dispose",p));let S=_.program;n.updateUBOMapping(v,S);let T=t.render.frame;r[v.id]!==T&&(u(v),r[v.id]=T)}function h(v){let _=d();v.__bindingPointIndex=_;let b=i.createBuffer(),S=v.__size,T=v.usage;return i.bindBuffer(i.UNIFORM_BUFFER,b),i.bufferData(i.UNIFORM_BUFFER,S,T),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,_,b),b}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 u(v){let _=s[v.id],b=v.uniforms,S=v.__cache;i.bindBuffer(i.UNIFORM_BUFFER,_);for(let T=0,A=b.length;T<A;T++){let L=b[T];if(m(L,T,S)===!0){let y=L.__offset,w=Array.isArray(L.value)?L.value:[L.value],z=0;for(let Y=0;Y<w.length;Y++){let I=w[Y],D=x(I);typeof I=="number"?(L.__data[0]=I,i.bufferSubData(i.UNIFORM_BUFFER,y+z,L.__data)):I.isMatrix3?(L.__data[0]=I.elements[0],L.__data[1]=I.elements[1],L.__data[2]=I.elements[2],L.__data[3]=I.elements[0],L.__data[4]=I.elements[3],L.__data[5]=I.elements[4],L.__data[6]=I.elements[5],L.__data[7]=I.elements[0],L.__data[8]=I.elements[6],L.__data[9]=I.elements[7],L.__data[10]=I.elements[8],L.__data[11]=I.elements[0]):(I.toArray(L.__data,z),z+=D.storage/Float32Array.BYTES_PER_ELEMENT)}i.bufferSubData(i.UNIFORM_BUFFER,y,L.__data)}}i.bindBuffer(i.UNIFORM_BUFFER,null)}function m(v,_,b){let S=v.value;if(b[_]===void 0){if(typeof S=="number")b[_]=S;else{let T=Array.isArray(S)?S:[S],A=[];for(let L=0;L<T.length;L++)A.push(T[L].clone());b[_]=A}return!0}else if(typeof S=="number"){if(b[_]!==S)return b[_]=S,!0}else{let T=Array.isArray(b[_])?b[_]:[b[_]],A=Array.isArray(S)?S:[S];for(let L=0;L<T.length;L++){let y=T[L];if(y.equals(A[L])===!1)return y.copy(A[L]),!0}}return!1}function g(v){let _=v.uniforms,b=0,S=16,T=0;for(let A=0,L=_.length;A<L;A++){let y=_[A],w={boundary:0,storage:0},z=Array.isArray(y.value)?y.value:[y.value];for(let Y=0,I=z.length;Y<I;Y++){let D=z[Y],O=x(D);w.boundary+=O.boundary,w.storage+=O.storage}if(y.__data=new Float32Array(w.storage/Float32Array.BYTES_PER_ELEMENT),y.__offset=b,A>0){T=b%S;let Y=S-T;T!==0&&Y-w.boundary<0&&(b+=S-T,y.__offset=b)}b+=w.storage}return T=b%S,T>0&&(b+=S-T),v.__size=b,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 p(v){let _=v.target;_.removeEventListener("dispose",p);let b=a.indexOf(_.__bindingPointIndex);a.splice(b,1),i.deleteBuffer(s[_.id]),delete s[_.id],delete r[_.id]}function f(){for(let v in s)i.deleteBuffer(s[v]);a=[],s={},r={}}return{bind:c,update:l,dispose:f}}function Xp(){let i=ws("canvas");return i.style.display="block",i}var no=class{constructor(t={}){let{canvas:e=Xp(),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 u;n!==null?u=n.getContextAttributes().alpha:u=a;let m=new Uint32Array(4),g=new Int32Array(4),x=null,p=null,f=[],v=[];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=Rt,this._useLegacyLights=!1,this.toneMapping=Mn,this.toneMappingExposure=1;let _=this,b=!1,S=0,T=0,A=null,L=-1,y=null,w=new jt,z=new jt,Y=null,I=new kt(0),D=0,O=e.width,$=e.height,G=1,q=null,J=null,K=new jt(0,0,O,$),B=new jt(0,0,O,$),Z=!1,ot=new Fs,at=!1,ct=!1,_t=null,Et=new Gt,xt=new Nt,zt=new P,xe={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function Pt(){return A===null?G:1}let F=n;function oe(E,N){for(let X=0;X<E.length;X++){let U=E[X],W=e.getContext(U,N);if(W!==null)return W}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${mo}`),e.addEventListener("webglcontextlost",st,!1),e.addEventListener("webglcontextrestored",k,!1),e.addEventListener("webglcontextcreationerror",nt,!1),F===null){let N=["webgl2","webgl","experimental-webgl"];if(_.isWebGL1Renderer===!0&&N.shift(),F=oe(N,E),F===null)throw oe(N)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}typeof WebGLRenderingContext!="undefined"&&F instanceof WebGLRenderingContext&&console.warn("THREE.WebGLRenderer: WebGL 1 support was deprecated in r153 and will be removed in r163."),F.getShaderPrecisionFormat===void 0&&(F.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(E){throw console.error("THREE.WebGLRenderer: "+E.message),E}let yt,Tt,bt,Xt,Ft,Lt,Vt,re,ae,R,M,V,j,Q,tt,ft,et,H,mt,dt,pt,ht,ut,It;function Ht(){yt=new ud(F),Tt=new rd(F,yt,t),yt.init(Tt),ht=new kp(F,yt,Tt),bt=new zp(F,yt,Tt),Xt=new pd(F),Ft=new Ap,Lt=new Vp(F,yt,bt,Ft,Tt,ht,Xt),Vt=new ad(_),re=new hd(_),ae=new bh(F,Tt),ut=new id(F,yt,ae,Tt),R=new fd(F,ae,Xt,ut),M=new xd(F,R,ae,Xt),mt=new _d(F,Tt,Lt),ft=new od(Ft),V=new wp(_,Vt,re,yt,Tt,ut,ft),j=new Gp(_,Ft),Q=new Cp,tt=new Np(yt,Tt),H=new nd(_,Vt,re,bt,M,u,c),et=new Bp(_,M,Tt),It=new Wp(F,Xt,Tt,bt),dt=new sd(F,yt,Xt,Tt),pt=new dd(F,yt,Xt,Tt),Xt.programs=V.programs,_.capabilities=Tt,_.extensions=yt,_.properties=Ft,_.renderLists=Q,_.shadowMap=et,_.state=bt,_.info=Xt}Ht();let C=new eo(_,F);this.xr=C,this.getContext=function(){return F},this.getContextAttributes=function(){return F.getContextAttributes()},this.forceContextLoss=function(){let E=yt.get("WEBGL_lose_context");E&&E.loseContext()},this.forceContextRestore=function(){let E=yt.get("WEBGL_lose_context");E&&E.restoreContext()},this.getPixelRatio=function(){return G},this.setPixelRatio=function(E){E!==void 0&&(G=E,this.setSize(O,$,!1))},this.getSize=function(E){return E.set(O,$)},this.setSize=function(E,N,X=!0){if(C.isPresenting){console.warn("THREE.WebGLRenderer: Can\'t change size while VR device is presenting.");return}O=E,$=N,e.width=Math.floor(E*G),e.height=Math.floor(N*G),X===!0&&(e.style.width=E+"px",e.style.height=N+"px"),this.setViewport(0,0,E,N)},this.getDrawingBufferSize=function(E){return E.set(O*G,$*G).floor()},this.setDrawingBufferSize=function(E,N,X){O=E,$=N,G=X,e.width=Math.floor(E*X),e.height=Math.floor(N*X),this.setViewport(0,0,E,N)},this.getCurrentViewport=function(E){return E.copy(w)},this.getViewport=function(E){return E.copy(K)},this.setViewport=function(E,N,X,U){E.isVector4?K.set(E.x,E.y,E.z,E.w):K.set(E,N,X,U),bt.viewport(w.copy(K).multiplyScalar(G).floor())},this.getScissor=function(E){return E.copy(B)},this.setScissor=function(E,N,X,U){E.isVector4?B.set(E.x,E.y,E.z,E.w):B.set(E,N,X,U),bt.scissor(z.copy(B).multiplyScalar(G).floor())},this.getScissorTest=function(){return Z},this.setScissorTest=function(E){bt.setScissorTest(Z=E)},this.setOpaqueSort=function(E){q=E},this.setTransparentSort=function(E){J=E},this.getClearColor=function(E){return E.copy(H.getClearColor())},this.setClearColor=function(){H.setClearColor.apply(H,arguments)},this.getClearAlpha=function(){return H.getClearAlpha()},this.setClearAlpha=function(){H.setClearAlpha.apply(H,arguments)},this.clear=function(E=!0,N=!0,X=!0){let U=0;if(E){let W=!1;if(A!==null){let lt=A.texture.format;W=lt===_c||lt===gc||lt===mc}if(W){let lt=A.texture.type,gt=lt===Sn||lt===xn||lt===go||lt===Fn||lt===dc||lt===pc,Mt=H.getClearColor(),St=H.getClearAlpha(),Ut=Mt.r,vt=Mt.g,wt=Mt.b;gt?(m[0]=Ut,m[1]=vt,m[2]=wt,m[3]=St,F.clearBufferuiv(F.COLOR,0,m)):(g[0]=Ut,g[1]=vt,g[2]=wt,g[3]=St,F.clearBufferiv(F.COLOR,0,g))}else U|=F.COLOR_BUFFER_BIT}N&&(U|=F.DEPTH_BUFFER_BIT),X&&(U|=F.STENCIL_BUFFER_BIT),F.clear(U)},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",st,!1),e.removeEventListener("webglcontextrestored",k,!1),e.removeEventListener("webglcontextcreationerror",nt,!1),Q.dispose(),tt.dispose(),Ft.dispose(),Vt.dispose(),re.dispose(),M.dispose(),ut.dispose(),It.dispose(),V.dispose(),C.dispose(),C.removeEventListener("sessionstart",Wt),C.removeEventListener("sessionend",Xe),_t&&(_t.dispose(),_t=null),ue.stop()};function st(E){E.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),b=!0}function k(){console.log("THREE.WebGLRenderer: Context Restored."),b=!1;let E=Xt.autoReset,N=et.enabled,X=et.autoUpdate,U=et.needsUpdate,W=et.type;Ht(),Xt.autoReset=E,et.enabled=N,et.autoUpdate=X,et.needsUpdate=U,et.type=W}function nt(E){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",E.statusMessage)}function rt(E){let N=E.target;N.removeEventListener("dispose",rt),Ot(N)}function Ot(E){qt(E),Ft.remove(E)}function qt(E){let N=Ft.get(E).programs;N!==void 0&&(N.forEach(function(X){V.releaseProgram(X)}),E.isShaderMaterial&&V.releaseShaderCache(E))}this.renderBufferDirect=function(E,N,X,U,W,lt){N===null&&(N=xe);let gt=W.isMesh&&W.matrixWorld.determinant()<0,Mt=Xc(E,N,X,U,W);bt.setMaterial(U,gt);let St=X.index,Ut=1;if(U.wireframe===!0){if(St=R.getWireframeAttribute(X),St===void 0)return;Ut=2}let vt=X.drawRange,wt=X.attributes.position,Yt=vt.start*Ut,Zt=(vt.start+vt.count)*Ut;lt!==null&&(Yt=Math.max(Yt,lt.start*Ut),Zt=Math.min(Zt,(lt.start+lt.count)*Ut)),St!==null?(Yt=Math.max(Yt,0),Zt=Math.min(Zt,St.count)):wt!=null&&(Yt=Math.max(Yt,0),Zt=Math.min(Zt,wt.count));let Pe=Zt-Yt;if(Pe<0||Pe===1/0)return;ut.setup(W,U,Mt,X,St);let Ke,$t=dt;if(St!==null&&(Ke=ae.get(St),$t=pt,$t.setIndex(Ke)),W.isMesh)U.wireframe===!0?(bt.setLineWidth(U.wireframeLinewidth*Pt()),$t.setMode(F.LINES)):$t.setMode(F.TRIANGLES);else if(W.isLine){let Dt=U.linewidth;Dt===void 0&&(Dt=1),bt.setLineWidth(Dt*Pt()),W.isLineSegments?$t.setMode(F.LINES):W.isLineLoop?$t.setMode(F.LINE_LOOP):$t.setMode(F.LINE_STRIP)}else W.isPoints?$t.setMode(F.POINTS):W.isSprite&&$t.setMode(F.TRIANGLES);if(W.isInstancedMesh)$t.renderInstances(Yt,Pe,W.count);else if(X.isInstancedBufferGeometry){let Dt=X._maxInstanceCount!==void 0?X._maxInstanceCount:1/0,Ks=Math.min(X.instanceCount,Dt);$t.renderInstances(Yt,Pe,Ks)}else $t.render(Yt,Pe)},this.compile=function(E,N){function X(U,W,lt){U.transparent===!0&&U.side===ze&&U.forceSinglePass===!1?(U.side=he,U.needsUpdate=!0,ji(U,W,lt),U.side=He,U.needsUpdate=!0,ji(U,W,lt),U.side=ze):ji(U,W,lt)}p=tt.get(E),p.init(),v.push(p),E.traverseVisible(function(U){U.isLight&&U.layers.test(N.layers)&&(p.pushLight(U),U.castShadow&&p.pushShadow(U))}),p.setupLights(_._useLegacyLights),E.traverse(function(U){let W=U.material;if(W)if(Array.isArray(W))for(let lt=0;lt<W.length;lt++){let gt=W[lt];X(gt,E,U)}else X(W,E,U)}),v.pop(),p=null};let Jt=null;function fn(E){Jt&&Jt(E)}function Wt(){ue.stop()}function Xe(){ue.start()}let ue=new bc;ue.setAnimationLoop(fn),typeof self!="undefined"&&ue.setContext(self),this.setAnimationLoop=function(E){Jt=E,C.setAnimationLoop(E),E===null?ue.stop():ue.start()},C.addEventListener("sessionstart",Wt),C.addEventListener("sessionend",Xe),this.render=function(E,N){if(N!==void 0&&N.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(b===!0)return;E.matrixWorldAutoUpdate===!0&&E.updateMatrixWorld(),N.parent===null&&N.matrixWorldAutoUpdate===!0&&N.updateMatrixWorld(),C.enabled===!0&&C.isPresenting===!0&&(C.cameraAutoUpdate===!0&&C.updateCamera(N),N=C.getCamera()),E.isScene===!0&&E.onBeforeRender(_,E,N,A),p=tt.get(E,v.length),p.init(),v.push(p),Et.multiplyMatrices(N.projectionMatrix,N.matrixWorldInverse),ot.setFromProjectionMatrix(Et),ct=this.localClippingEnabled,at=ft.init(this.clippingPlanes,ct),x=Q.get(E,f.length),x.init(),f.push(x),Uo(E,N,0,_.sortObjects),x.finish(),_.sortObjects===!0&&x.sort(q,J),this.info.render.frame++,at===!0&&ft.beginShadows();let X=p.state.shadowsArray;if(et.render(X,E,N),at===!0&&ft.endShadows(),this.info.autoReset===!0&&this.info.reset(),H.render(x,E),p.setupLights(_._useLegacyLights),N.isArrayCamera){let U=N.cameras;for(let W=0,lt=U.length;W<lt;W++){let gt=U[W];Do(x,E,gt,gt.viewport)}}else Do(x,E,N);A!==null&&(Lt.updateMultisampleRenderTarget(A),Lt.updateRenderTargetMipmap(A)),E.isScene===!0&&E.onAfterRender(_,E,N),ut.resetDefaultState(),L=-1,y=null,v.pop(),v.length>0?p=v[v.length-1]:p=null,f.pop(),f.length>0?x=f[f.length-1]:x=null};function Uo(E,N,X,U){if(E.visible===!1)return;if(E.layers.test(N.layers)){if(E.isGroup)X=E.renderOrder;else if(E.isLOD)E.autoUpdate===!0&&E.update(N);else if(E.isLight)p.pushLight(E),E.castShadow&&p.pushShadow(E);else if(E.isSprite){if(!E.frustumCulled||ot.intersectsSprite(E)){U&&zt.setFromMatrixPosition(E.matrixWorld).applyMatrix4(Et);let gt=M.update(E),Mt=E.material;Mt.visible&&x.push(E,gt,Mt,X,zt.z,null)}}else if((E.isMesh||E.isLine||E.isPoints)&&(!E.frustumCulled||ot.intersectsObject(E))){let gt=M.update(E),Mt=E.material;if(U&&(E.boundingSphere!==void 0?(E.boundingSphere===null&&E.computeBoundingSphere(),zt.copy(E.boundingSphere.center)):(gt.boundingSphere===null&>.computeBoundingSphere(),zt.copy(gt.boundingSphere.center)),zt.applyMatrix4(E.matrixWorld).applyMatrix4(Et)),Array.isArray(Mt)){let St=gt.groups;for(let Ut=0,vt=St.length;Ut<vt;Ut++){let wt=St[Ut],Yt=Mt[wt.materialIndex];Yt&&Yt.visible&&x.push(E,gt,Yt,X,zt.z,wt)}}else Mt.visible&&x.push(E,gt,Mt,X,zt.z,null)}}let lt=E.children;for(let gt=0,Mt=lt.length;gt<Mt;gt++)Uo(lt[gt],N,X,U)}function Do(E,N,X,U){let W=E.opaque,lt=E.transmissive,gt=E.transparent;p.setupLightsView(X),at===!0&&ft.setGlobalState(_.clippingPlanes,X),lt.length>0&&Wc(W,lt,N,X),U&&bt.viewport(w.copy(U)),W.length>0&&Qi(W,N,X),lt.length>0&&Qi(lt,N,X),gt.length>0&&Qi(gt,N,X),bt.buffers.depth.setTest(!0),bt.buffers.depth.setMask(!0),bt.buffers.color.setMask(!0),bt.setPolygonOffset(!1)}function Wc(E,N,X,U){let W=Tt.isWebGL2;_t===null&&(_t=new cn(1,1,{generateMipmaps:!0,type:yt.has("EXT_color_buffer_half_float")?Gi:Sn,minFilter:Hi,samples:W?4:0})),_.getDrawingBufferSize(xt),W?_t.setSize(xt.x,xt.y):_t.setSize(Br(xt.x),Br(xt.y));let lt=_.getRenderTarget();_.setRenderTarget(_t),_.getClearColor(I),D=_.getClearAlpha(),D<1&&_.setClearColor(16777215,.5),_.clear();let gt=_.toneMapping;_.toneMapping=Mn,Qi(E,X,U),Lt.updateMultisampleRenderTarget(_t),Lt.updateRenderTargetMipmap(_t);let Mt=!1;for(let St=0,Ut=N.length;St<Ut;St++){let vt=N[St],wt=vt.object,Yt=vt.geometry,Zt=vt.material,Pe=vt.group;if(Zt.side===ze&&wt.layers.test(U.layers)){let Ke=Zt.side;Zt.side=he,Zt.needsUpdate=!0,No(wt,X,U,Yt,Zt,Pe),Zt.side=Ke,Zt.needsUpdate=!0,Mt=!0}}Mt===!0&&(Lt.updateMultisampleRenderTarget(_t),Lt.updateRenderTargetMipmap(_t)),_.setRenderTarget(lt),_.setClearColor(I,D),_.toneMapping=gt}function Qi(E,N,X){let U=N.isScene===!0?N.overrideMaterial:null;for(let W=0,lt=E.length;W<lt;W++){let gt=E[W],Mt=gt.object,St=gt.geometry,Ut=U===null?gt.material:U,vt=gt.group;Mt.layers.test(X.layers)&&No(Mt,N,X,St,Ut,vt)}}function No(E,N,X,U,W,lt){E.onBeforeRender(_,N,X,U,W,lt),E.modelViewMatrix.multiplyMatrices(X.matrixWorldInverse,E.matrixWorld),E.normalMatrix.getNormalMatrix(E.modelViewMatrix),W.onBeforeRender(_,N,X,U,E,lt),W.transparent===!0&&W.side===ze&&W.forceSinglePass===!1?(W.side=he,W.needsUpdate=!0,_.renderBufferDirect(X,N,U,W,E,lt),W.side=He,W.needsUpdate=!0,_.renderBufferDirect(X,N,U,W,E,lt),W.side=ze):_.renderBufferDirect(X,N,U,W,E,lt),E.onAfterRender(_,N,X,U,W,lt)}function ji(E,N,X){N.isScene!==!0&&(N=xe);let U=Ft.get(E),W=p.state.lights,lt=p.state.shadowsArray,gt=W.state.version,Mt=V.getParameters(E,W.state,lt,N,X),St=V.getProgramCacheKey(Mt),Ut=U.programs;U.environment=E.isMeshStandardMaterial?N.environment:null,U.fog=N.fog,U.envMap=(E.isMeshStandardMaterial?re:Vt).get(E.envMap||U.environment),Ut===void 0&&(E.addEventListener("dispose",rt),Ut=new Map,U.programs=Ut);let vt=Ut.get(St);if(vt!==void 0){if(U.currentProgram===vt&&U.lightsStateVersion===gt)return Fo(E,Mt),vt}else Mt.uniforms=V.getUniforms(E),E.onBuild(X,Mt,_),E.onBeforeCompile(Mt,_),vt=V.acquireProgram(Mt,St),Ut.set(St,vt),U.uniforms=Mt.uniforms;let wt=U.uniforms;(!E.isShaderMaterial&&!E.isRawShaderMaterial||E.clipping===!0)&&(wt.clippingPlanes=ft.uniform),Fo(E,Mt),U.needsLights=Yc(E),U.lightsStateVersion=gt,U.needsLights&&(wt.ambientLightColor.value=W.state.ambient,wt.lightProbe.value=W.state.probe,wt.directionalLights.value=W.state.directional,wt.directionalLightShadows.value=W.state.directionalShadow,wt.spotLights.value=W.state.spot,wt.spotLightShadows.value=W.state.spotShadow,wt.rectAreaLights.value=W.state.rectArea,wt.ltc_1.value=W.state.rectAreaLTC1,wt.ltc_2.value=W.state.rectAreaLTC2,wt.pointLights.value=W.state.point,wt.pointLightShadows.value=W.state.pointShadow,wt.hemisphereLights.value=W.state.hemi,wt.directionalShadowMap.value=W.state.directionalShadowMap,wt.directionalShadowMatrix.value=W.state.directionalShadowMatrix,wt.spotShadowMap.value=W.state.spotShadowMap,wt.spotLightMatrix.value=W.state.spotLightMatrix,wt.spotLightMap.value=W.state.spotLightMap,wt.pointShadowMap.value=W.state.pointShadowMap,wt.pointShadowMatrix.value=W.state.pointShadowMatrix);let Yt=vt.getUniforms(),Zt=pi.seqWithValue(Yt.seq,wt);return U.currentProgram=vt,U.uniformsList=Zt,vt}function Fo(E,N){let X=Ft.get(E);X.outputColorSpace=N.outputColorSpace,X.instancing=N.instancing,X.instancingColor=N.instancingColor,X.skinning=N.skinning,X.morphTargets=N.morphTargets,X.morphNormals=N.morphNormals,X.morphColors=N.morphColors,X.morphTargetsCount=N.morphTargetsCount,X.numClippingPlanes=N.numClippingPlanes,X.numIntersection=N.numClipIntersection,X.vertexAlphas=N.vertexAlphas,X.vertexTangents=N.vertexTangents,X.toneMapping=N.toneMapping}function Xc(E,N,X,U,W){N.isScene!==!0&&(N=xe),Lt.resetTextureUnits();let lt=N.fog,gt=U.isMeshStandardMaterial?N.environment:null,Mt=A===null?_.outputColorSpace:A.isXRRenderTarget===!0?A.texture.colorSpace:Ze,St=(U.isMeshStandardMaterial?re:Vt).get(U.envMap||gt),Ut=U.vertexColors===!0&&!!X.attributes.color&&X.attributes.color.itemSize===4,vt=!!X.attributes.tangent&&(!!U.normalMap||U.anisotropy>0),wt=!!X.morphAttributes.position,Yt=!!X.morphAttributes.normal,Zt=!!X.morphAttributes.color,Pe=Mn;U.toneMapped&&(A===null||A.isXRRenderTarget===!0)&&(Pe=_.toneMapping);let Ke=X.morphAttributes.position||X.morphAttributes.normal||X.morphAttributes.color,$t=Ke!==void 0?Ke.length:0,Dt=Ft.get(U),Ks=p.state.lights;if(at===!0&&(ct===!0||E!==y)){let Te=E===y&&U.id===L;ft.setState(U,E,Te)}let Kt=!1;U.version===Dt.__version?(Dt.needsLights&&Dt.lightsStateVersion!==Ks.state.version||Dt.outputColorSpace!==Mt||W.isInstancedMesh&&Dt.instancing===!1||!W.isInstancedMesh&&Dt.instancing===!0||W.isSkinnedMesh&&Dt.skinning===!1||!W.isSkinnedMesh&&Dt.skinning===!0||W.isInstancedMesh&&Dt.instancingColor===!0&&W.instanceColor===null||W.isInstancedMesh&&Dt.instancingColor===!1&&W.instanceColor!==null||Dt.envMap!==St||U.fog===!0&&Dt.fog!==lt||Dt.numClippingPlanes!==void 0&&(Dt.numClippingPlanes!==ft.numPlanes||Dt.numIntersection!==ft.numIntersection)||Dt.vertexAlphas!==Ut||Dt.vertexTangents!==vt||Dt.morphTargets!==wt||Dt.morphNormals!==Yt||Dt.morphColors!==Zt||Dt.toneMapping!==Pe||Tt.isWebGL2===!0&&Dt.morphTargetsCount!==$t)&&(Kt=!0):(Kt=!0,Dt.__version=U.version);let Rn=Dt.currentProgram;Kt===!0&&(Rn=ji(U,N,W));let Oo=!1,Ui=!1,Qs=!1,fe=Rn.getUniforms(),Cn=Dt.uniforms;if(bt.useProgram(Rn.program)&&(Oo=!0,Ui=!0,Qs=!0),U.id!==L&&(L=U.id,Ui=!0),Oo||y!==E){if(fe.setValue(F,"projectionMatrix",E.projectionMatrix),Tt.logarithmicDepthBuffer&&fe.setValue(F,"logDepthBufFC",2/(Math.log(E.far+1)/Math.LN2)),y!==E&&(y=E,Ui=!0,Qs=!0),U.isShaderMaterial||U.isMeshPhongMaterial||U.isMeshToonMaterial||U.isMeshStandardMaterial||U.envMap){let Te=fe.map.cameraPosition;Te!==void 0&&Te.setValue(F,zt.setFromMatrixPosition(E.matrixWorld))}(U.isMeshPhongMaterial||U.isMeshToonMaterial||U.isMeshLambertMaterial||U.isMeshBasicMaterial||U.isMeshStandardMaterial||U.isShaderMaterial)&&fe.setValue(F,"isOrthographic",E.isOrthographicCamera===!0),(U.isMeshPhongMaterial||U.isMeshToonMaterial||U.isMeshLambertMaterial||U.isMeshBasicMaterial||U.isMeshStandardMaterial||U.isShaderMaterial||U.isShadowMaterial||W.isSkinnedMesh)&&fe.setValue(F,"viewMatrix",E.matrixWorldInverse)}if(W.isSkinnedMesh){fe.setOptional(F,W,"bindMatrix"),fe.setOptional(F,W,"bindMatrixInverse");let Te=W.skeleton;Te&&(Tt.floatVertexTextures?(Te.boneTexture===null&&Te.computeBoneTexture(),fe.setValue(F,"boneTexture",Te.boneTexture,Lt),fe.setValue(F,"boneTextureSize",Te.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 js=X.morphAttributes;if((js.position!==void 0||js.normal!==void 0||js.color!==void 0&&Tt.isWebGL2===!0)&&mt.update(W,X,Rn),(Ui||Dt.receiveShadow!==W.receiveShadow)&&(Dt.receiveShadow=W.receiveShadow,fe.setValue(F,"receiveShadow",W.receiveShadow)),U.isMeshGouraudMaterial&&U.envMap!==null&&(Cn.envMap.value=St,Cn.flipEnvMap.value=St.isCubeTexture&&St.isRenderTargetTexture===!1?-1:1),Ui&&(fe.setValue(F,"toneMappingExposure",_.toneMappingExposure),Dt.needsLights&&qc(Cn,Qs),lt&&U.fog===!0&&j.refreshFogUniforms(Cn,lt),j.refreshMaterialUniforms(Cn,U,G,$,_t),pi.upload(F,Dt.uniformsList,Cn,Lt)),U.isShaderMaterial&&U.uniformsNeedUpdate===!0&&(pi.upload(F,Dt.uniformsList,Cn,Lt),U.uniformsNeedUpdate=!1),U.isSpriteMaterial&&fe.setValue(F,"center",W.center),fe.setValue(F,"modelViewMatrix",W.modelViewMatrix),fe.setValue(F,"normalMatrix",W.normalMatrix),fe.setValue(F,"modelMatrix",W.matrixWorld),U.isShaderMaterial||U.isRawShaderMaterial){let Te=U.uniformsGroups;for(let tr=0,Zc=Te.length;tr<Zc;tr++)if(Tt.isWebGL2){let Bo=Te[tr];It.update(Bo,Rn),It.bind(Bo,Rn)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return Rn}function qc(E,N){E.ambientLightColor.needsUpdate=N,E.lightProbe.needsUpdate=N,E.directionalLights.needsUpdate=N,E.directionalLightShadows.needsUpdate=N,E.pointLights.needsUpdate=N,E.pointLightShadows.needsUpdate=N,E.spotLights.needsUpdate=N,E.spotLightShadows.needsUpdate=N,E.rectAreaLights.needsUpdate=N,E.hemisphereLights.needsUpdate=N}function Yc(E){return E.isMeshLambertMaterial||E.isMeshToonMaterial||E.isMeshPhongMaterial||E.isMeshStandardMaterial||E.isShadowMaterial||E.isShaderMaterial&&E.lights===!0}this.getActiveCubeFace=function(){return S},this.getActiveMipmapLevel=function(){return T},this.getRenderTarget=function(){return A},this.setRenderTargetTextures=function(E,N,X){Ft.get(E.texture).__webglTexture=N,Ft.get(E.depthTexture).__webglTexture=X;let U=Ft.get(E);U.__hasExternalTextures=!0,U.__hasExternalTextures&&(U.__autoAllocateDepthBuffer=X===void 0,U.__autoAllocateDepthBuffer||yt.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),U.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(E,N){let X=Ft.get(E);X.__webglFramebuffer=N,X.__useDefaultFramebuffer=N===void 0},this.setRenderTarget=function(E,N=0,X=0){A=E,S=N,T=X;let U=!0,W=null,lt=!1,gt=!1;if(E){let St=Ft.get(E);St.__useDefaultFramebuffer!==void 0?(bt.bindFramebuffer(F.FRAMEBUFFER,null),U=!1):St.__webglFramebuffer===void 0?Lt.setupRenderTarget(E):St.__hasExternalTextures&&Lt.rebindTextures(E,Ft.get(E.texture).__webglTexture,Ft.get(E.depthTexture).__webglTexture);let Ut=E.texture;(Ut.isData3DTexture||Ut.isDataArrayTexture||Ut.isCompressedArrayTexture)&&(gt=!0);let vt=Ft.get(E).__webglFramebuffer;E.isWebGLCubeRenderTarget?(Array.isArray(vt[N])?W=vt[N][X]:W=vt[N],lt=!0):Tt.isWebGL2&&E.samples>0&&Lt.useMultisampledRTT(E)===!1?W=Ft.get(E).__webglMultisampledFramebuffer:Array.isArray(vt)?W=vt[X]:W=vt,w.copy(E.viewport),z.copy(E.scissor),Y=E.scissorTest}else w.copy(K).multiplyScalar(G).floor(),z.copy(B).multiplyScalar(G).floor(),Y=Z;if(bt.bindFramebuffer(F.FRAMEBUFFER,W)&&Tt.drawBuffers&&U&&bt.drawBuffers(E,W),bt.viewport(w),bt.scissor(z),bt.setScissorTest(Y),lt){let St=Ft.get(E.texture);F.framebufferTexture2D(F.FRAMEBUFFER,F.COLOR_ATTACHMENT0,F.TEXTURE_CUBE_MAP_POSITIVE_X+N,St.__webglTexture,X)}else if(gt){let St=Ft.get(E.texture),Ut=N||0;F.framebufferTextureLayer(F.FRAMEBUFFER,F.COLOR_ATTACHMENT0,St.__webglTexture,X||0,Ut)}L=-1},this.readRenderTargetPixels=function(E,N,X,U,W,lt,gt){if(!(E&&E.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Mt=Ft.get(E).__webglFramebuffer;if(E.isWebGLCubeRenderTarget&>!==void 0&&(Mt=Mt[gt]),Mt){bt.bindFramebuffer(F.FRAMEBUFFER,Mt);try{let St=E.texture,Ut=St.format,vt=St.type;if(Ut!==ke&&ht.convert(Ut)!==F.getParameter(F.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}let wt=vt===Gi&&(yt.has("EXT_color_buffer_half_float")||Tt.isWebGL2&&yt.has("EXT_color_buffer_float"));if(vt!==Sn&&ht.convert(vt)!==F.getParameter(F.IMPLEMENTATION_COLOR_READ_TYPE)&&!(vt===yn&&(Tt.isWebGL2||yt.has("OES_texture_float")||yt.has("WEBGL_color_buffer_float")))&&!wt){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}N>=0&&N<=E.width-U&&X>=0&&X<=E.height-W&&F.readPixels(N,X,U,W,ht.convert(Ut),ht.convert(vt),lt)}finally{let St=A!==null?Ft.get(A).__webglFramebuffer:null;bt.bindFramebuffer(F.FRAMEBUFFER,St)}}},this.copyFramebufferToTexture=function(E,N,X=0){let U=Math.pow(2,-X),W=Math.floor(N.image.width*U),lt=Math.floor(N.image.height*U);Lt.setTexture2D(N,0),F.copyTexSubImage2D(F.TEXTURE_2D,X,0,0,E.x,E.y,W,lt),bt.unbindTexture()},this.copyTextureToTexture=function(E,N,X,U=0){let W=N.image.width,lt=N.image.height,gt=ht.convert(X.format),Mt=ht.convert(X.type);Lt.setTexture2D(X,0),F.pixelStorei(F.UNPACK_FLIP_Y_WEBGL,X.flipY),F.pixelStorei(F.UNPACK_PREMULTIPLY_ALPHA_WEBGL,X.premultiplyAlpha),F.pixelStorei(F.UNPACK_ALIGNMENT,X.unpackAlignment),N.isDataTexture?F.texSubImage2D(F.TEXTURE_2D,U,E.x,E.y,W,lt,gt,Mt,N.image.data):N.isCompressedTexture?F.compressedTexSubImage2D(F.TEXTURE_2D,U,E.x,E.y,N.mipmaps[0].width,N.mipmaps[0].height,gt,N.mipmaps[0].data):F.texSubImage2D(F.TEXTURE_2D,U,E.x,E.y,gt,Mt,N.image),U===0&&X.generateMipmaps&&F.generateMipmap(F.TEXTURE_2D),bt.unbindTexture()},this.copyTextureToTexture3D=function(E,N,X,U,W=0){if(_.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}let lt=E.max.x-E.min.x+1,gt=E.max.y-E.min.y+1,Mt=E.max.z-E.min.z+1,St=ht.convert(U.format),Ut=ht.convert(U.type),vt;if(U.isData3DTexture)Lt.setTexture3D(U,0),vt=F.TEXTURE_3D;else if(U.isDataArrayTexture)Lt.setTexture2DArray(U,0),vt=F.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}F.pixelStorei(F.UNPACK_FLIP_Y_WEBGL,U.flipY),F.pixelStorei(F.UNPACK_PREMULTIPLY_ALPHA_WEBGL,U.premultiplyAlpha),F.pixelStorei(F.UNPACK_ALIGNMENT,U.unpackAlignment);let wt=F.getParameter(F.UNPACK_ROW_LENGTH),Yt=F.getParameter(F.UNPACK_IMAGE_HEIGHT),Zt=F.getParameter(F.UNPACK_SKIP_PIXELS),Pe=F.getParameter(F.UNPACK_SKIP_ROWS),Ke=F.getParameter(F.UNPACK_SKIP_IMAGES),$t=X.isCompressedTexture?X.mipmaps[0]:X.image;F.pixelStorei(F.UNPACK_ROW_LENGTH,$t.width),F.pixelStorei(F.UNPACK_IMAGE_HEIGHT,$t.height),F.pixelStorei(F.UNPACK_SKIP_PIXELS,E.min.x),F.pixelStorei(F.UNPACK_SKIP_ROWS,E.min.y),F.pixelStorei(F.UNPACK_SKIP_IMAGES,E.min.z),X.isDataTexture||X.isData3DTexture?F.texSubImage3D(vt,W,N.x,N.y,N.z,lt,gt,Mt,St,Ut,$t.data):X.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),F.compressedTexSubImage3D(vt,W,N.x,N.y,N.z,lt,gt,Mt,St,$t.data)):F.texSubImage3D(vt,W,N.x,N.y,N.z,lt,gt,Mt,St,Ut,$t),F.pixelStorei(F.UNPACK_ROW_LENGTH,wt),F.pixelStorei(F.UNPACK_IMAGE_HEIGHT,Yt),F.pixelStorei(F.UNPACK_SKIP_PIXELS,Zt),F.pixelStorei(F.UNPACK_SKIP_ROWS,Pe),F.pixelStorei(F.UNPACK_SKIP_IMAGES,Ke),W===0&&U.generateMipmaps&&F.generateMipmap(vt),bt.unbindTexture()},this.initTexture=function(E){E.isCubeTexture?Lt.setTextureCube(E,0):E.isData3DTexture?Lt.setTexture3D(E,0):E.isDataArrayTexture||E.isCompressedArrayTexture?Lt.setTexture2DArray(E,0):Lt.setTexture2D(E,0),bt.unbindTexture()},this.resetState=function(){S=0,T=0,A=null,bt.reset(),ut.reset()},typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return on}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===Rt?Bn:xc}set outputEncoding(t){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=t===Bn?Rt:Ze}get useLegacyLights(){return console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights}set useLegacyLights(t){console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights=t}},io=class extends no{};io.prototype.isWebGL1Renderer=!0;function _n(i,t,e){return Rc(i)?new i.constructor(i.subarray(t,e!==void 0?e:i.length)):i.slice(t,e)}function Ms(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 Rc(i){return ArrayBuffer.isView(i)&&!(i instanceof DataView)}var Mi=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_(){}},so=class extends Mi{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:xa,endingEnd:xa}}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 ya:r=t,o=2*e-n;break;case va: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 ya:a=t,c=2*n-e;break;case va: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,u=this._weightPrev,m=this._weightNext,g=(n-e)/(s-e),x=g*g,p=x*g,f=-u*p+2*u*x-u*g,v=(1+u)*p+(-1.5-2*u)*x+(-.5+u)*g+1,_=(-1-m)*p+(1.5+m)*x+.5*g,b=m*p-m*x;for(let S=0;S!==o;++S)r[S]=f*a[h+S]+v*a[l+S]+_*a[c+S]+b*a[d+S];return r}},ro=class extends Mi{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 u=0;u!==o;++u)r[u]=a[l+u]*d+a[c+u]*h;return r}},oo=class extends Mi{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=Ms(e,this.TimeBufferType),this.values=Ms(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:Ms(t.times,Array),values:Ms(t.values,Array)};let s=t.getInterpolation();s!==t.DefaultInterpolation&&(n.interpolation=s)}return n.type=t.ValueTypeName,n}InterpolantFactoryMethodDiscrete(t){return new oo(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodLinear(t){return new ro(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodSmooth(t){return new so(this.times,this.values,this.getValueSize(),t)}setInterpolation(t){let e;switch(t){case bs:e=this.InterpolantFactoryMethodDiscrete;break;case Es:e=this.InterpolantFactoryMethodLinear;break;case ar: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 bs;case this.InterpolantFactoryMethodLinear:return Es;case this.InterpolantFactoryMethodSmooth:return ar}}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&&Rc(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()===ar,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,u=d-n,m=d+n;for(let g=0;g!==n;++g){let x=e[d+g];if(x!==e[u+g]||x!==e[m+g]){c=!0;break}}}if(c){if(o!==a){t[a]=t[o];let d=o*n,u=a*n;for(let m=0;m!==n;++m)e[u+m]=e[d+m]}++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=Es;var Hn=class extends We{};Hn.prototype.ValueTypeName="bool";Hn.prototype.ValueBufferType=Array;Hn.prototype.DefaultInterpolation=bs;Hn.prototype.InterpolantFactoryMethodLinear=void 0;Hn.prototype.InterpolantFactoryMethodSmooth=void 0;var ao=class extends We{};ao.prototype.ValueTypeName="color";var co=class extends We{};co.prototype.ValueTypeName="number";var lo=class extends Mi{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)En.slerpFlat(r,0,a,l-o,a,l,c);return r}},Xi=class extends We{InterpolantFactoryMethodLinear(t){return new lo(this.times,this.values,this.getValueSize(),t)}};Xi.prototype.ValueTypeName="quaternion";Xi.prototype.DefaultInterpolation=Es;Xi.prototype.InterpolantFactoryMethodSmooth=void 0;var Gn=class extends We{};Gn.prototype.ValueTypeName="string";Gn.prototype.ValueBufferType=Array;Gn.prototype.DefaultInterpolation=bs;Gn.prototype.InterpolantFactoryMethodLinear=void 0;Gn.prototype.InterpolantFactoryMethodSmooth=void 0;var ho=class extends We{};ho.prototype.ValueTypeName="vector";var uo=class{constructor(t,e,n){let s=this,r=!1,a=0,o=0,c,l=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=n,this.itemStart=function(h){o++,r===!1&&s.onStart!==void 0&&s.onStart(h,a,o),r=!0},this.itemEnd=function(h){a++,s.onProgress!==void 0&&s.onProgress(h,a,o),a===o&&(r=!1,s.onLoad!==void 0&&s.onLoad())},this.itemError=function(h){s.onError!==void 0&&s.onError(h)},this.resolveURL=function(h){return c?c(h):h},this.setURLModifier=function(h){return c=h,this},this.addHandler=function(h,d){return l.push(h,d),this},this.removeHandler=function(h){let d=l.indexOf(h);return d!==-1&&l.splice(d,2),this},this.getHandler=function(h){for(let d=0,u=l.length;d<u;d+=2){let m=l[d],g=l[d+1];if(m.global&&(m.lastIndex=0),m.test(h))return g}return null}}},qp=new uo,fo=class{constructor(t){this.manager=t!==void 0?t:qp,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(t,e){let n=this;return new Promise(function(s,r){n.load(t,s,e,r)})}parse(){}setCrossOrigin(t){return this.crossOrigin=t,this}setWithCredentials(t){return this.withCredentials=t,this}setPath(t){return this.path=t,this}setResourcePath(t){return this.resourcePath=t,this}setRequestHeader(t){return this.requestHeader=t,this}};fo.DEFAULT_MATERIAL_NAME="__DEFAULT";var xo="\\\\[\\\\]\\\\.:\\\\/",Yp=new RegExp("["+xo+"]","g"),yo="[^"+xo+"]",Zp="[^"+xo.replace("\\\\.","")+"]",Jp=/((?:WC+[\\/:])*)/.source.replace("WC",yo),$p=/(WCOD+)?/.source.replace("WCOD",Zp),Kp=/(?:\\.(WC+)(?:\\[(.+)\\])?)?/.source.replace("WC",yo),Qp=/\\.(WC+)(?:\\[(.+)\\])?/.source.replace("WC",yo),jp=new RegExp("^"+Jp+$p+Kp+Qp+"$"),tm=["material","materials","bones","map"],po=class{constructor(t,e,n){let s=n||Bt.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()}},Bt=class{constructor(t,e,n){this.path=e,this.parsedPath=n||Bt.parseTrackName(e),this.node=Bt.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 Bt.Composite(t,e,n):new Bt(t,e,n)}static sanitizeNodeName(t){return t.replace(/\\s/g,"_").replace(Yp,"")}static parseTrackName(t){let e=jp.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);tm.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=Bt.findNode(this.rootNode,e.nodeName),this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!t){console.warn("THREE.PropertyBinding: No target node found for track: "+this.path+".");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}};Bt.Composite=po;Bt.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};Bt.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};Bt.prototype.GetterByBindingType=[Bt.prototype._getValue_direct,Bt.prototype._getValue_array,Bt.prototype._getValue_arrayElement,Bt.prototype._getValue_toArray];Bt.prototype.SetterByBindingTypeAndVersioning=[[Bt.prototype._setValue_direct,Bt.prototype._setValue_direct_setNeedsUpdate,Bt.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Bt.prototype._setValue_array,Bt.prototype._setValue_array_setNeedsUpdate,Bt.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Bt.prototype._setValue_arrayElement,Bt.prototype._setValue_arrayElement_setNeedsUpdate,Bt.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Bt.prototype._setValue_fromArray,Bt.prototype._setValue_fromArray_setNeedsUpdate,Bt.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var Sm=new Float32Array(1);var oc=new P,Ss=new P,Me=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){oc.subVectors(t,this.start),Ss.subVectors(this.end,this.start);let n=Ss.dot(Ss),r=Ss.dot(oc)/n;return e&&(r=me(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:mo}}));typeof window!="undefined"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=mo);var Cc=Math.pow(2,-24);var Wn=class{constructor(){}};function Ue(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 vo(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 Mo(i,t){t.set(i)}function So(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 Yi(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 bi(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 im(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 te(s,1));for(let r=0;r<e;r++)s[r]=r}}function sm(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 Eo(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,u=1/0,m=1/0,g=-1/0,x=-1/0,p=-1/0,f=s!==null;for(let v=t*6,_=(t+e)*6;v<_;v+=6){let b=i[v+0],S=i[v+1],T=b-S,A=b+S;T<r&&(r=T),A>c&&(c=A),f&&b<d&&(d=b),f&&b>g&&(g=b);let L=i[v+2],y=i[v+3],w=L-y,z=L+y;w<a&&(a=w),z>l&&(l=z),f&&L<u&&(u=L),f&&L>x&&(x=L);let Y=i[v+4],I=i[v+5],D=Y-I,O=Y+I;D<o&&(o=D),O>h&&(h=O),f&&Y<m&&(m=Y),f&&Y>p&&(p=Y)}n[0]=r,n[1]=a,n[2]=o,n[3]=c,n[4]=l,n[5]=h,f&&(s[0]=d,s[1]=u,s[2]=m,s[3]=g,s[4]=x,s[5]=p)}function rm(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 u=i[h+0];u<s&&(s=u),u>o&&(o=u);let m=i[h+2];m<r&&(r=m),m>c&&(c=m);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 om(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 u=t[r*6+l*2+1];t[r*6+l*2+1]=t[a*6+l*2+1],t[a*6+l*2+1]=u}r++,a--}else return r}}var hn=32,am=(i,t)=>i.candidate-t.candidate,Tn=new Array(hn).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),Vs=new Float32Array(6);function cm(i,t,e,n,s,r){let a=-1,o=0;if(r===0)a=vo(t),a!==-1&&(o=(t[a]+t[a+3])/2);else if(r===1)a=vo(i),a!==-1&&(o=lm(e,n,s,a));else if(r===2){let c=bi(i),l=1.25*s,h=n*6,d=(n+s)*6;for(let u=0;u<3;u++){let m=t[u],p=(t[u+3]-m)/hn;if(s<hn/4){let f=[...Tn];f.length=s;let v=0;for(let b=h;b<d;b+=6,v++){let S=f[v];S.candidate=e[b+2*u],S.count=0;let{bounds:T,leftCacheBounds:A,rightCacheBounds:L}=S;for(let y=0;y<3;y++)L[y]=1/0,L[y+3]=-1/0,A[y]=1/0,A[y+3]=-1/0,T[y]=1/0,T[y+3]=-1/0;Yi(b,e,T)}f.sort(am);let _=s;for(let b=0;b<_;b++){let S=f[b];for(;b+1<_&&f[b+1].candidate===S.candidate;)f.splice(b+1,1),_--}for(let b=h;b<d;b+=6){let S=e[b+2*u];for(let T=0;T<_;T++){let A=f[T];S>=A.candidate?Yi(b,e,A.rightCacheBounds):(Yi(b,e,A.leftCacheBounds),A.count++)}}for(let b=0;b<_;b++){let S=f[b],T=S.count,A=s-S.count,L=S.leftCacheBounds,y=S.rightCacheBounds,w=0;T!==0&&(w=bi(L)/c);let z=0;A!==0&&(z=bi(y)/c);let Y=1+1.25*(w*T+z*A);Y<l&&(a=u,l=Y,o=S.candidate)}}else{for(let _=0;_<hn;_++){let b=Tn[_];b.count=0,b.candidate=m+p+_*p;let S=b.bounds;for(let T=0;T<3;T++)S[T]=1/0,S[T+3]=-1/0}for(let _=h;_<d;_+=6){let T=~~((e[_+2*u]-m)/p);T>=hn&&(T=hn-1);let A=Tn[T];A.count++,Yi(_,e,A.bounds)}let f=Tn[hn-1];Mo(f.bounds,f.rightCacheBounds);for(let _=hn-2;_>=0;_--){let b=Tn[_],S=Tn[_+1];So(b.bounds,S.rightCacheBounds,b.rightCacheBounds)}let v=0;for(let _=0;_<hn-1;_++){let b=Tn[_],S=b.count,T=b.bounds,L=Tn[_+1].rightCacheBounds;S!==0&&(v===0?Mo(T,Vs):So(T,Vs,Vs)),v+=S;let y=0,w=0;v!==0&&(y=bi(Vs)/c);let z=s-v;z!==0&&(w=bi(L)/c);let Y=1+1.25*(y*v+w*z);Y<l&&(a=u,l=Y,o=b.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${r} used.`);return{axis:a,pos:o}}function lm(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 hm(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 u=d*3,m=d*6,g,x,p;a?(g=n[u+0],x=n[u+1],p=n[u+2]):(g=n[u+0]*l+c,x=n[u+1]*l+c,p=n[u+2]*l+c);for(let f=0;f<3;f++){let v,_,b;a?(v=e[h[f]](g),_=e[h[f]](x),b=e[h[f]](p)):(v=o[g+f],_=o[x+f],b=o[p+f]);let S=v;_<S&&(S=_),b<S&&(S=b);let T=v;_>T&&(T=_),b>T&&(T=b);let A=(T-S)/2,L=f*2;r[m+L+0]=S+A,r[m+L+1]=A+(Math.abs(S)+A)*Cc,S<t[f]&&(t[f]=S),T>t[f+3]&&(t[f+3]=T)}}return r}function um(i,t){function e(f){u&&u(f/m)}function n(f,v,_,b=null,S=0){if(!g&&S>=c&&(g=!0,l&&(console.warn(`MeshBVH: Max depth of ${c} reached when generating BVH. Consider increasing maxDepth.`),console.warn(i))),_<=h||S>=c)return e(v+_),f.offset=v,f.count=_,f;let T=cm(f.boundingData,b,a,v,_,d);if(T.axis===-1)return e(v+_),f.offset=v,f.count=_,f;let A=om(o,a,v,_,T);if(A===v||A===v+_)e(v+_),f.offset=v,f.count=_;else{f.splitAxis=T.axis;let L=new Wn,y=v,w=A-v;f.left=L,L.boundingData=new Float32Array(6),Eo(a,y,w,L.boundingData,r),n(L,y,w,r,S+1);let z=new Wn,Y=A,I=_-w;f.right=z,z.boundingData=new Float32Array(6),Eo(a,Y,I,z.boundingData,r),n(z,Y,I,r,S+1)}return f}im(i,t);let s=new Float32Array(6),r=new Float32Array(6),a=hm(i,s),o=i.index.array,c=t.maxDepth,l=t.verbose,h=t.maxLeafTris,d=t.strategy,u=t.onProgress,m=i.index.count/3,g=!1,x=[],p=sm(i);if(p.length===1){let f=p[0],v=new Wn;v.boundingData=s,rm(a,f.offset,f.count,r),n(v,f.offset,f.count,r),x.push(v)}else for(let f of p){let v=new Wn;v.boundingData=new Float32Array(6),Eo(a,f.offset,f.count,v.boundingData,r),n(v,f.offset,f.count,r),x.push(v)}return x}function Ic(i,t){let e=um(i,t),n,s,r,a=[],o=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;for(let h=0;h<e.length;h++){let d=e[h],u=c(d),m=new o(32*u);n=new Float32Array(m),s=new Uint32Array(m),r=new Uint16Array(m),l(0,d),a.push(m)}return a;function c(h){return h.count?1:1+c(h.left)+c(h.right)}function l(h,d){let u=h/4,m=h/2,g=!!d.count,x=d.boundingData;for(let p=0;p<6;p++)n[u+p]=x[p];if(g){let p=d.offset,f=d.count;return s[u+6]=p,r[m+14]=f,r[m+15]=65535,h+32}else{let p=d.left,f=d.right,v=d.splitAxis,_;if(_=l(h+32,p),_/4>Math.pow(2,32))throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return s[u+6]=_/4,_=l(_,f),s[u+7]=v,_}}}var Se=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}};Se.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 Um=function(){let i=new Se;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],u=r[h];if(i.setFromPoints(u,o),d.isSeparated(i))return!1}for(let h=0;h<3;h++){let d=l[h],u=c[h];if(i.setFromPoints(u,s),d.isSeparated(i))return!1}}}();var fm=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),u=h.dot(c),m=h.dot(h),g=e.dot(c),p=c.dot(c)*m-u*u,f,v;p!==0?f=(d*u-g*m)/p:f=0,v=(d+f*u)/m,a.x=f,a.y=v}}(),Zi=function(){let i=new Nt,t=new P,e=new P;return function(s,r,a,o){fm(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 u=t,m=e;if(s.closestPointToPoint(d,!0,t),r.closestPointToPoint(h,!0,e),u.distanceToSquared(d)<=m.distanceToSquared(h)){a.copy(u),o.copy(d);return}else{a.copy(h),o.copy(m);return}}}}(),Uc=function(){let i=new P,t=new P,e=new Ce,n=new Me;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 f=x.projectPoint(c,t);if(a.containsPoint(f))return!0}return!1}}();var dm=1e-15;function Ei(i){return Math.abs(i)<dm}var be=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 Se),this.points=[this.a,this.b,this.c],this.sphere=new Vn,this.plane=new Ce,this.needsUpdate=!0}intersectsSphere(t){return Uc(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],u=a[2];d.subVectors(e,n),u.setFromPoints(d,s);let m=r[3],g=a[3];m.subVectors(n,t),g.setFromPoints(m,s),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(o,t),this.needsUpdate=!1}};be.prototype.closestPointToSegment=function(){let i=new P,t=new P,e=new Me;return function(s,r=null,a=null){let{start:o,end:c}=s,l=this.points,h,d=1/0;for(let u=0;u<3;u++){let m=(u+1)%3;e.start.copy(l[u]),e.end.copy(l[m]),Zi(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)}}();be.prototype.intersectsTriangle=function(){let i=new be,t=new Array(3),e=new Array(3),n=new Se,s=new Se,r=new P,a=new P,o=new P,c=new P,l=new Me,h=new Me,d=new Me;return function(m,g=null,x=!1){this.needsUpdate&&this.update(),m.isExtendedTriangle?m.needsUpdate&&m.update():(i.copy(m),i.update(),m=i);let p=this.plane,f=m.plane;if(Math.abs(p.normal.dot(f.normal))>1-1e-10){let v=this.satBounds,_=this.satAxes;e[0]=m.a,e[1]=m.b,e[2]=m.c;for(let T=0;T<4;T++){let A=v[T],L=_[T];if(n.setFromPoints(L,e),A.isSeparated(n))return!1}let b=m.satBounds,S=m.satAxes;t[0]=this.a,t[1]=this.b,t[2]=this.c;for(let T=0;T<4;T++){let A=b[T],L=S[T];if(n.setFromPoints(L,t),A.isSeparated(n))return!1}for(let T=0;T<4;T++){let A=_[T];for(let L=0;L<4;L++){let y=S[L];if(r.crossVectors(A,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,b=0;for(let D=0;D<3;D++){let O=v[D],$=v[(D+1)%3];l.start.copy(O),l.end.copy($),l.delta(a);let G=_?h.start:h.end,q=Ei(f.distanceToPoint(O));if(Ei(f.normal.dot(a))&&q){h.copy(l),b=2;break}if((f.intersectLine(l,G)||q)&&!Ei(G.distanceTo($))){if(b++,_)break;_=!0}}if(b===1&&m.containsPoint(h.end))return g&&(g.start.copy(h.end),g.end.copy(h.end)),!0;if(b!==2)return!1;let S=m.points,T=!1,A=0;for(let D=0;D<3;D++){let O=S[D],$=S[(D+1)%3];l.start.copy(O),l.end.copy($),l.delta(o);let G=T?d.start:d.end,q=Ei(p.distanceToPoint(O));if(Ei(p.normal.dot(o))&&q){d.copy(l),A=2;break}if((p.intersectLine(l,G)||q)&&!Ei(G.distanceTo($))){if(A++,T)break;T=!0}}if(A===1&&this.containsPoint(d.end))return g&&(g.start.copy(d.end),g.end.copy(d.end)),!0;if(A!==2)return!1;if(h.delta(a),d.delta(o),a.dot(o)<0){let D=d.start;d.start=d.end,d.end=D}let L=h.start.dot(a),y=h.end.dot(a),w=d.start.dot(a),z=d.end.dot(a),Y=y<w,I=L<z;return L!==z&&w!==y&&Y===I?!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)}}}();be.prototype.distanceToPoint=function(){let i=new P;return function(e){return this.closestPointToPoint(e,i),e.distanceTo(i)}}();be.prototype.distanceToTriangle=function(){let i=new P,t=new P,e=["a","b","c"],n=new Me,s=new Me;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 u,m=e[d],g=a[m];this.closestPointToPoint(g,i),u=g.distanceToSquared(i),u<h&&(h=u,o&&o.copy(i),c&&c.copy(g));let x=this[m];a.closestPointToPoint(x,i),u=x.distanceToSquared(i),u<h&&(h=u,o&&o.copy(x),c&&c.copy(i))}for(let d=0;d<3;d++){let u=e[d],m=e[(d+1)%3];n.set(this[u],this[m]);for(let g=0;g<3;g++){let x=e[g],p=e[(g+1)%3];s.set(a[x],a[p]),Zi(n,s,i,t);let f=i.distanceToSquared(t);f<h&&(h=f,o&&o.copy(i),c&&c.copy(t))}}return Math.sqrt(h)}}();var Ee=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 Se),this.alignedSatBounds=new Array(3).fill().map(()=>new Se),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}};Ee.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 u=1*l|2*h|4*d,m=s[u];m.x=l?n.x:e.x,m.y=h?n.y:e.y,m.z=d?n.z:e.z,m.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],u=1<<l,m=s[u];h.subVectors(o,m),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}}();Ee.prototype.intersectsBox=function(){let i=new Se;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}}();Ee.prototype.intersectsTriangle=function(){let i=new be,t=new Array(3),e=new Se,n=new Se,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 u=0;u<3;u++){let m=o[u],g=c[u];if(e.setFromPoints(g,t),m.isSeparated(e))return!1}let l=a.satBounds,h=a.satAxes,d=this.points;for(let u=0;u<3;u++){let m=l[u],g=h[u];if(e.setFromPoints(g,d),m.isSeparated(e))return!1}for(let u=0;u<3;u++){let m=c[u];for(let g=0;g<4;g++){let x=h[g];if(s.crossVectors(m,x),e.setFromPoints(s,t),n.setFromPoints(s,d),e.isSeparated(n))return!1}}return!0}}();Ee.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}}();Ee.prototype.distanceToPoint=function(){let i=new P;return function(e){return this.closestPointToPoint(e,i),e.distanceTo(i)}}();Ee.prototype.distanceToBox=function(){let i=["x","y","z"],t=new Array(12).fill().map(()=>new Me),e=new Array(12).fill().map(()=>new Me),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,u=a.max,m=this.points,g=1/0;for(let p=0;p<8;p++){let f=m[p];s.copy(f).clamp(d,u);let v=f.distanceToSquared(s);if(v<g&&(g=v,c&&c.copy(f),l&&l.copy(s),v<h))return Math.sqrt(v)}let x=0;for(let p=0;p<3;p++)for(let f=0;f<=1;f++)for(let v=0;v<=1;v++){let _=(p+1)%3,b=(p+2)%3,S=f<<_|v<<b,T=1<<p|f<<_|v<<b,A=m[S],L=m[T];t[x].set(A,L);let w=i[p],z=i[_],Y=i[b],I=e[x],D=I.start,O=I.end;D[w]=d[w],D[z]=f?d[z]:u[z],D[Y]=v?d[Y]:u[z],O[w]=u[w],O[z]=f?d[z]:u[z],O[Y]=v?d[Y]:u[z],x++}for(let p=0;p<=1;p++)for(let f=0;f<=1;f++)for(let v=0;v<=1;v++){s.x=p?u.x:d.x,s.y=f?u.y:d.y,s.z=v?u.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 p=0;p<12;p++){let f=t[p];for(let v=0;v<12;v++){let _=e[v];Zi(f,_,n,s);let b=n.distanceToSquared(s);if(b<g&&(g=b,c&&c.copy(n),l&&l.copy(s),b<h))return Math.sqrt(b)}}return Math.sqrt(g)}}();var Hs=new P,Gs=new P,Ws=new P,Dc=new Nt,Nc=new Nt,Fc=new Nt,Oc=new P;function pm(i,t,e,n,s,r){let a;return r===he?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 mm(i,t,e,n,s,r,a){Hs.fromBufferAttribute(t,n),Gs.fromBufferAttribute(t,s),Ws.fromBufferAttribute(t,r);let o=pm(i,Hs,Gs,Ws,Oc,a);if(o){e&&(Dc.fromBufferAttribute(e,n),Nc.fromBufferAttribute(e,s),Fc.fromBufferAttribute(e,r),o.uv=se.getUV(Oc,Hs,Gs,Ws,Dc,Nc,Fc,new Nt));let c={a:n,b:s,c:r,normal:new P,materialIndex:0};se.getNormal(Hs,Gs,Ws,c.normal),o.face=c,o.faceIndex=n}return o}function wo(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=mm(e,i.attributes.position,i.attributes.uv,a,o,c,t);return l?(l.faceIndex=n,s&&s.push(l),l):null}function Bc(i,t,e,n,s,r){for(let a=n,o=n+s;a<o;a++)wo(i,t,e,a,r)}function zc(i,t,e,n,s){let r=1/0,a=null;for(let o=n,c=n+s;o<c;o++){let l=wo(i,t,e,o);l&&l.distance<r&&(a=l,r=l.distance)}return a}function De(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 Ao(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(De(a,l*3,o,c),a.needsUpdate=!0,n(a,l,s,r))return!0;return!1}var Ti=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 Xn(i,t){return t[i+6]}function wi(i,t){return t[i+14]}function Ai(i){return i+8}function Ri(i,t){return t[i+6]}function Vc(i,t){return t[i+7]}var Ci=new _e,qs=new P,_m=["x","y","z"];function Ys(i,t,e,n,s){let r=i*2,a=Pi,o=wn,c=An;if(un(r,o)){let h=Xn(i,c),d=wi(r,o);Bc(t,e,n,h,d,s)}else{let h=Ai(i);Js(h,a,n,qs)&&Ys(h,t,e,n,s);let d=Ri(i,c);Js(d,a,n,qs)&&Ys(d,t,e,n,s)}}function Zs(i,t,e,n){let s=i*2,r=Pi,a=wn,o=An;if(un(s,a)){let l=Xn(i,o),h=wi(s,a);return zc(t,e,n,l,h)}else{let l=Vc(i,o),h=_m[l],u=n.direction[h]>=0,m,g;u?(m=Ai(i),g=Ri(i,o)):(m=Ri(i,o),g=Ai(i));let p=Js(m,r,n,qs)?Zs(m,t,e,n):null;if(p){let _=p.point[h];if(u?_<=r[g+l]:_>=r[g+l+3])return p}let v=Js(g,r,n,qs)?Zs(g,t,e,n):null;return p&&v?p.distance<=v.distance?p:v:p||v||null}}var kc=function(){let i,t,e=[],n=new Ti(()=>new _e);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 u(_){let b=_*2,S=wn,T=An;for(;!un(b,S);)_=Ai(_),b=_*2;return Xn(_,T)}function m(_){let b=_*2,S=wn,T=An;for(;!un(b,S);)_=Ri(_,T),b=_*2;return Xn(_,T)+wi(b,S)}let g=r*2,x=Pi,p=wn,f=An;if(un(g,p)){let _=Xn(r,f),b=wi(g,p);return Ue(r,x,i),c(_,b,!1,d,h+r,i)}else{let _=Ai(r),b=Ri(r,f),S=_,T=b,A,L,y,w;if(l&&(y=i,w=t,Ue(S,x,y),Ue(T,x,w),A=l(y),L=l(w),L<A)){S=b,T=_;let G=A;A=L,L=G,y=w}y||(y=i,Ue(S,x,y));let z=un(S*2,p),Y=o(y,z,A,d+1,h+S),I;if(Y===2){let G=u(S),J=m(S)-G;I=c(G,J,!0,d+1,h+S,y)}else I=Y&&s(S,a,o,c,l,h,d+1);if(I)return!0;w=t,Ue(T,x,w);let D=un(T*2,p),O=o(w,D,L,d+1,h+T),$;if(O===2){let G=u(T),J=m(T)-G;$=c(G,J,!0,d+1,h+T,w)}else $=O&&s(T,a,o,c,l,h,d+1);return!!$}}}(),Hc=function(){let i=new be,t=new be,e=new Gt,n=new Ee,s=new Ee;return function r(a,o,c,l,h=null){let d=a*2,u=Pi,m=wn,g=An;if(h===null&&(c.boundingBox||c.computeBoundingBox(),n.set(c.boundingBox.min,c.boundingBox.max,l),h=n),un(d,m)){let p=o,f=p.index,v=p.attributes.position,_=c.index,b=c.attributes.position,S=Xn(a,g),T=wi(d,m);if(e.copy(l).invert(),c.boundsTree)return Ue(a,u,s),s.matrix.copy(e),s.needsUpdate=!0,c.boundsTree.shapecast({intersectsBounds:L=>s.intersectsBox(L),intersectsTriangle:L=>{L.a.applyMatrix4(l),L.b.applyMatrix4(l),L.c.applyMatrix4(l),L.needsUpdate=!0;for(let y=S*3,w=(T+S)*3;y<w;y+=3)if(De(t,y,f,v),t.needsUpdate=!0,L.intersectsTriangle(t))return!0;return!1}});for(let A=S*3,L=T+S*3;A<L;A+=3){De(i,A,f,v),i.a.applyMatrix4(e),i.b.applyMatrix4(e),i.c.applyMatrix4(e),i.needsUpdate=!0;for(let y=0,w=_.count;y<w;y+=3)if(De(t,y,_,b),t.needsUpdate=!0,i.intersectsTriangle(t))return!0}}else{let p=a+8,f=g[a+6];return Ue(p,u,Ci),!!(h.intersectsBox(Ci)&&r(p,o,c,l,h)||(Ue(f,u,Ci),h.intersectsBox(Ci)&&r(f,o,c,l,h)))}}}();function Js(i,t,e,n){return Ue(i,t,Ci),e.intersectBox(Ci,n)}var Ro=[],Xs,Pi,wn,An;function Li(i){Xs&&Ro.push(Xs),Xs=i,Pi=new Float32Array(i),wn=new Uint16Array(i),An=new Uint32Array(i)}function Ji(){Xs=null,Pi=null,wn=null,An=null,Ro.length&&Li(Ro.pop())}var Co=Symbol("skip tree generation"),Po=new _e,Lo=new _e,Ii=new Gt,qn=new Ee,$i=new Ee,Ki=new P,$s=new P,xm=new P,ym=new P,vm=new P,Gc=new _e,Je=new Ti(()=>new be),$e=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."),$e.serialize(arguments[0],{cloneBuffers:arguments[2]===void 0?!0:arguments[2]});e=ts({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."),$e.deserialize(arguments[0],arguments[1],{setIndex:arguments[2]===void 0?!0:arguments[2]});n=ts({setIndex:!0},n);let{index:s,roots:r}=t,a=new $e(e,ko(ts({},n),{[Co]:!0}));if(a._roots=r,n.setIndex){let o=e.getIndex();if(o===null){let c=new te(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,[Co]:!1},e),e.useSharedArrayBuffer&&typeof SharedArrayBuffer=="undefined")throw new Error("MeshBVH: SharedArrayBuffer is not available.");this._roots=null,e[Co]||(this._roots=Ic(t,e),!t.boundingBox&&e.setBoundingBox&&(t.boundingBox=this.getBoundingBox(new _e))),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 u=0,m=h.length;u<m;u++)r=h[u],a=new Uint32Array(r),o=new Uint16Array(r),c=new Float32Array(r),d(0,l),l+=r.byteLength;function d(u,m,g=!1){let x=u*2;if(o[x+15]===65535){let f=a[u+6],v=o[x+14],_=1/0,b=1/0,S=1/0,T=-1/0,A=-1/0,L=-1/0;for(let y=3*f,w=3*(f+v);y<w;y++){let z=n[y],Y=s.getX(z),I=s.getY(z),D=s.getZ(z);Y<_&&(_=Y),Y>T&&(T=Y),I<b&&(b=I),I>A&&(A=I),D<S&&(S=D),D>L&&(L=D)}return c[u+0]!==_||c[u+1]!==b||c[u+2]!==S||c[u+3]!==T||c[u+4]!==A||c[u+5]!==L?(c[u+0]=_,c[u+1]=b,c[u+2]=S,c[u+3]=T,c[u+4]=A,c[u+5]=L,!0):!1}else{let f=u+8,v=a[u+6],_=f+m,b=v+m,S=g,T=!1,A=!1;t?S||(T=t.has(_),A=t.has(b),S=!T&&!A):(T=!0,A=!0);let L=S||T,y=S||A,w=!1;L&&(w=d(f,m,S));let z=!1;y&&(z=d(v,m,S));let Y=w||z;if(Y)for(let I=0;I<3;I++){let D=f+I,O=v+I,$=c[D],G=c[D+3],q=c[O],J=c[O+3];c[u+I]=$<q?$:q,c[u+I+3]=G>J?G:J}return Y}}}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],u=r[l+14];t(c,h,new Float32Array(n,o*4,6),d,u)}else{let d=o+32/4,u=s[o+6],m=s[o+7];t(c,h,new Float32Array(n,o*4,6),m)||(a(d,c+1),a(u,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 u=o?e[c[h].materialIndex].side:l,m=r.length;if(Li(n[h]),Ys(0,s,u,t,r),Ji(),o){let g=c[h].materialIndex;for(let x=m,p=r.length;x<p;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 u=a?e[c[h].materialIndex].side:l;Li(n[h]);let m=Zs(0,s,u,t);Ji(),m!=null&&(o==null||m.distance<o.distance)&&(o=m,a&&(m.face.materialIndex=c[h].materialIndex))}return o}intersectsGeometry(t,e){let n=this.geometry,s=!1;for(let r of this._roots)if(Li(r),s=Hc(0,n,t,e),Ji(),s)break;return s}shapecast(t,e,n){let s=this.geometry;if(t instanceof Function){if(e){let u=e;e=(m,g,x,p)=>{let f=g*3;return u(m,f,f+1,f+2,x,p)}}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=Je.getPrimitive(),{boundsTraverseOrder:a,intersectsBounds:o,intersectsRange:c,intersectsTriangle:l}=t;if(c&&l){let u=c;c=(m,g,x,p,f)=>u(m,g,x,p,f)?!0:Ao(m,g,s,l,x,p,r)}else c||(l?c=(u,m,g,x)=>Ao(u,m,s,l,g,x,r):c=(u,m,g)=>g);let h=!1,d=0;for(let u of this._roots){if(Li(u),h=kc(0,s,o,c,a,d),Ji(),h)break;d+=u.byteLength}return Je.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;Ii.copy(e).invert();let h=Je.getPrimitive(),d=Je.getPrimitive();if(r){let m=function(g,x,p,f,v,_,b,S){for(let T=p,A=p+f;T<A;T++){De(d,T*3,c,l),d.a.applyMatrix4(e),d.b.applyMatrix4(e),d.c.applyMatrix4(e),d.needsUpdate=!0;for(let L=g,y=g+x;L<y;L++)if(De(h,L*3,a,o),h.needsUpdate=!0,r(h,d,L,T,v,_,b,S))return!0}return!1};if(s){let g=s;s=function(x,p,f,v,_,b,S,T){return g(x,p,f,v,_,b,S,T)?!0:m(x,p,f,v,_,b,S,T)}}else s=m}t.getBoundingBox(Lo),Lo.applyMatrix4(e);let u=this.shapecast({intersectsBounds:m=>Lo.intersectsBox(m),intersectsRange:(m,g,x,p,f,v)=>(Po.copy(v),Po.applyMatrix4(Ii),t.shapecast({intersectsBounds:_=>Po.intersectsBox(_),intersectsRange:(_,b,S,T,A)=>s(m,g,_,b,p,f,T,A)}))});return Je.releasePrimitive(h),Je.releasePrimitive(d),u}intersectsBox(t,e){return qn.set(t.min,t.max,e),qn.needsUpdate=!0,this.shapecast({intersectsBounds:n=>qn.intersectsBox(n),intersectsTriangle:n=>qn.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(),qn.set(t.boundingBox.min,t.boundingBox.max,e),qn.needsUpdate=!0;let o=this.geometry,c=o.attributes.position,l=o.index,h=t.attributes.position,d=t.index,u=Je.getPrimitive(),m=Je.getPrimitive(),g=$s,x=xm,p=null,f=null;s&&(p=ym,f=vm);let v=1/0,_=null,b=null;return Ii.copy(e).invert(),$i.matrix.copy(Ii),this.shapecast({boundsTraverseOrder:S=>qn.distanceToBox(S),intersectsBounds:(S,T,A)=>A<v&&A<a?(T&&($i.min.copy(S.min),$i.max.copy(S.max),$i.needsUpdate=!0),!0):!1,intersectsRange:(S,T)=>{if(t.boundsTree)return t.boundsTree.shapecast({boundsTraverseOrder:A=>$i.distanceToBox(A),intersectsBounds:(A,L,y)=>y<v&&y<a,intersectsRange:(A,L)=>{for(let y=A*3,w=(A+L)*3;y<w;y+=3){De(m,y,d,h),m.a.applyMatrix4(e),m.b.applyMatrix4(e),m.c.applyMatrix4(e),m.needsUpdate=!0;for(let z=S*3,Y=(S+T)*3;z<Y;z+=3){De(u,z,l,c),u.needsUpdate=!0;let I=u.distanceToTriangle(m,g,p);if(I<v&&(x.copy(g),f&&f.copy(p),v=I,_=z/3,b=y/3),I<r)return!0}}}});{let A=d?d.count:h.count;for(let L=0,y=A;L<y;L+=3){De(m,L,d,h),m.a.applyMatrix4(e),m.b.applyMatrix4(e),m.c.applyMatrix4(e),m.needsUpdate=!0;for(let w=S*3,z=(S+T)*3;w<z;w+=3){De(u,w,l,c),u.needsUpdate=!0;let Y=u.distanceToTriangle(m,g,p);if(Y<v&&(x.copy(g),f&&f.copy(p),v=Y,_=w/3,b=L/3),Y<r)return!0}}}}}),Je.releasePrimitive(u),Je.releasePrimitive(m),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(f):s.point=f.clone(),s.point.applyMatrix4(Ii),x.applyMatrix4(Ii),s.distance=x.sub(s.point).length(),s.faceIndex=b),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=>(Ki.copy(t).clamp(h.min,h.max),Ki.distanceToSquared(t)),intersectsBounds:(h,d,u)=>u<o&&u<a,intersectsTriangle:(h,d)=>{h.closestPointToPoint(t,Ki);let u=t.distanceToSquared(Ki);return u<o&&($s.copy(Ki),o=u,c=d),u<r}}),o===1/0)return null;let l=Math.sqrt(o);return e.point?e.point.copy($s):e.point=$s.clone(),e.distance=l,e.faceIndex=c,e}getBoundingBox(t){return t.makeEmpty(),this._roots.forEach(n=>{Ue(0,new Float32Array(n),Gc),t.union(Gc)}),t}};var Io=self;Io.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 te(r,3,!1)),s&&o.setIndex(new te(s,1,!1)),a.includedProgressCallback&&(a.onProgress=e),a.groups){let h=a.groups;for(let d in h){let u=h[d];o.addGroup(u.start,u.count,u.materialIndex)}}let c=new $e(o,a),l=$e.serialize(c,{cloneBuffers:!1});Io.postMessage({id:n,error:void 0,serialized:l,position:r,progress:1},[l.index.buffer,r.buffer,...l.roots])}catch(o){Io.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')}ju.decoderPath="libs/draco/gltf/";var vP=class{constructor(){this.running=!1,this.worker=new v4,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 fe.warn("[GenerateMeshBVHWorker] Already running job.");if(!this.worker)return void fe.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=>{fe.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)fe.warn(n.error),s();else if(n.serialized){let{serialized:e,position:r,id:a}=n,o=i.get(a),l=Cc.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),fe.debug("before update, index:",o.index.array),o.index.array=e.index;else{let t=new yn(e.index,1,!1);o.setIndex(t)}o.index&&(fe.debug("after update, index:",o.index.array),o.index.needsUpdate=!0),h.setBoundingBox&&!o.boundingBox&&(o.boundingBox=l.getBoundingBox(new Nt)),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){fe.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:Ci(Ir({},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}},yP=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 vP}isRunning(){return this.running}generate(e){return it(this,arguments,(function*(e,t={}){if(this.running)fe.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 u=0;u<i;u++){let n=this.workers[u];if(u<o?(l=u*s+u,h=l+s+1):(l=u*s+o,h=l+s),l=Math.min(l,r),h=Math.min(h,r),l>=h)break;fe.debug("startIndex: "+l+" endIndex: "+h),a.push(n.generate(e.slice(l,h),t))}Promise.allSettled(a).then((()=>{this.running=!1,n()}))}));fe.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&&Mi.isMergedMesh(i)&&!(i instanceof Os)){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 Cc(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&&Mi.isMergedMesh(t)&&!(t instanceof Os)){if(n.has(t.geometry.id))return;i.push(t.geometry),n.add(t.geometry.id)}}))}));let r=new yP;return r.generate(i,t).then((()=>{r.dispose()}))}},xve=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 Nt;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=yvt(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()}},yvt=(e,t,n=800,i=45)=>{let r=i*(Math.PI/180);return n*(e/(2*Math.tan(r/2)*t))},xP,bP=new _e,EP=new _e,_P=new _e,bve=new _e,xvt=new _e,bvt=new _e,wo=class extends Wi{constructor(e){super(Pt.guid()),this.needsFrustumCulled=!1,this.renderOrder=1e3,this.snapType="TripleCross",this.snapLineVisible=!1,this.snapType=e,this.drawSnapFunctions={TripleCross:this.drawTripleCorss.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=wo.FILL_COLOR_NONE,e.strokeStyle=wo.lineColor,e.lineWidth=wo.lineWidth,e.beginPath(),this.drawSnapFunctions[this.snapType](e,t),xP&&this.drawDebug(e,t),e.closePath(),e.fill(),e.stroke(),e.restore())}drawDebug(e,t){null==xP||xP.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=wo.SNAP_LINE_COLOR,e.lineWidth=wo.lineWidth;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()}drawTripleCorss(e,t){let n=this.transToScreenCoord(this.osnapInfo.point,t),i=wo.iconSize/1.6,r=bP.set(n.x,n.y-i),a=EP.set(n.x-.87*i,n.y+i/1.4),s=_P.set(n.x+.87*i,n.y+i/1.4);e.moveTo(n.x,n.y),e.lineTo(r.x,r.y),e.moveTo(n.x,n.y),e.lineTo(a.x,a.y),e.moveTo(n.x,n.y),e.lineTo(s.x,s.y)}drawSquare(e,t){let n=this.transToScreenCoord(this.osnapInfo.point,t),i=wo.iconSize,r=wo.iconSize;e.rect(n.x-i/2,n.y-r/2,i,r)}drawTriangle(e,t){let n=this.transToScreenCoord(this.osnapInfo.point,t),i=wo.iconSize/1.6,r=bP.set(n.x,n.y-i),a=EP.set(n.x-.87*i,n.y+i/2),s=_P.set(n.x+.87*i,n.y+i/2);e.moveTo(r.x,r.y),e.lineTo(a.x,a.y),e.lineTo(s.x,s.y)}drawCircleWithCross(e,t){let n=this.transToScreenCoord(this.osnapInfo.point,t),i=wo.iconSize/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=wo.iconSize/2,r=bP.set(n.x-i,n.y-i),a=EP.set(n.x+i,n.y+i),s=_P.set(n.x+i,n.y-i),o=bve.set(n.x-i,n.y+i);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=wo.iconSize/2,r=bP.set(n.x,n.y),a=EP.set(n.x-i,n.y),s=_P.set(n.x,n.y+i),o=bve.set(n.x-i,n.y-i),l=xvt.set(n.x-i,n.y+i),h=bvt.set(n.x+i,n.y+i);e.moveTo(a.x,a.y),e.lineTo(r.x,r.y),e.lineTo(s.x,s.y),e.moveTo(o.x,o.y),e.lineTo(l.x,l.y),e.lineTo(h.x,h.y),e.lineTo(o.x,o.y)}update(e){this.osnapInfo=e}getClassType(){return"SnapDrawable"}},As=wo;As.lineColor="rgba(255, 119, 0, 1)",As.FILL_COLOR_NONE="rgba(0, 0, 0, 0)",As.SNAP_LINE_COLOR="rgba(255, 240, 0, 0.3)",As.lineWidth=2,As.iconSize=14,Gn._registerDrawableClass(As);var y4=(e=>(e[e.None=0]="None",e[e.Vertex=1]="Vertex",e[e.MiddlePoint=2]="MiddlePoint",e[e.Edge=4]="Edge",e[e.Face=8]="Face",e[e.FootOfPerpendicular=16]="FootOfPerpendicular",e[e.Intersection=32]="Intersection",e[e.CircleCenter=64]="CircleCenter",e))(y4||{}),Evt=1e-5,ji=new k,aa=new k,v1=new k,JE=new k,Zm=new ht,QE=new ra;function _vt(e,t){let n=Number.MAX_VALUE,i=0;for(let r=0;r<e.vertices.length;r++){let a=t.distanceTo(e.vertices[r]);a<n&&(i=r,n=a)}return{vertex:e.vertices[i],distance:n}}function Tvt(e){if(!(e.object instanceof St&&e.face))return;let t=e.object,n=t.geometry.attributes.position,i=t.geometry.index;if(n.count<3)return;let r=Mi.getBatchByFaceIndex(t,e.faceIndex);t.geometry.boundsTree&&(i=new yn(t.geometry.userData.originalIndex,1,!1)),Zm.identity(),t instanceof Os&&void 0!==e.instanceId&&t.getMatrixAt(e.instanceId,Zm),Zm.premultiply(t.matrixWorld);let a,s=t.geometry.drawRange,o=n.array;if(i){let e=Math.max(0,s.start),t=Math.min(i.count,s.start+s.count);if(a=i.array,r){e=Math.max(e,r.indexStart),t=Math.min(t,r.indexStart+r.indexCount),a=i.array.slice(e,t),o=n.array.slice(3*r.positionStart,3*(r.positionStart+r.positionCount));for(let e=0;e<a.length;e++)a[e]=a[e]-r.positionStart}else(0!==e||t!==i.count)&&(a=i.array.slice(e,t))}else{let e=Math.max(0,s.start),t=Math.min(n.count,s.start+s.count);r?(e=Math.max(e,r.positionStart),t=Math.min(t,r.positionStart+r.positionCount),o=n.array.slice(3*r.positionStart,3*(r.positionStart+r.positionCount))):(0!==e||t!==n.count)&&(o=n.array.slice(3*e,3*t));let i=o.length/3;a=i>65535?new Uint32Array(i):new Uint16Array(i);for(let n=0,r=i;n<r;n++)a[n]=n}let l=gR.buildEdge(o,a,20),h=Number.MAX_VALUE,u=0;for(let p=0;p<l.length;p+=2){let t=l[p],n=l[p+1];ji.set(o[3*t],o[3*t+1],o[3*t+2]),ji.applyMatrix4(Zm),aa.set(o[3*n],o[3*n+1],o[3*n+2]),aa.applyMatrix4(Zm),QE.set(ji,aa),QE.closestPointToPoint(e.point,!0,v1);let i=e.point.distanceTo(v1);i<h&&(u=p,h=i,JE.copy(v1))}let c=l[u],d=l[u+1];return ji.set(o[3*c],o[3*c+1],o[3*c+2]),ji.applyMatrix4(Zm),aa.set(o[3*d],o[3*d+1],o[3*d+2]),aa.applyMatrix4(Zm),{vertices:[ji.clone(),aa.clone()],vertex:JE.clone(),distance:h}}var TP=class{constructor(e){var t;this.drawableList=new Xo("snap"),this.markers={},this.activeOSnapType=0,this.snapToleranceInWorldCoord=1,this.intersectionLimit=10,this.osnapTypePriorities={1:0,2:1,64:2,32:3,16:4,4:5,8:6,0:100},this.enabledOSnapTypes=127,this.overlayRender=e,null==(t=this.overlayRender)||t.addDrawableList(this.drawableList),this.initOSnapMarkers()}initOSnapMarkers(){let e=new As("TripleCross"),t=new As("Square"),n=new As("Triangle"),i=new As("CircleWithCross"),r=new As("Cross"),a=new As("Perpendicular");this.markers[1]=t,this.markers[2]=n,this.markers[4]=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)}))}isOSnapTypeEnabled(e){return!!(this.enabledOSnapTypes&e)}setOSnapTypeEnabled(e,t){if(t)this.enabledOSnapTypes|=e;else{let t=~e;this.enabledOSnapTypes&=t}}setSnapTolerance(e){this.snapToleranceInWorldCoord=e}getSnapTolerance(){return this.snapToleranceInWorldCoord}setIntersectionLimit(e){this.intersectionLimit=e}getIntersectionLimit(){return this.intersectionLimit}getMarkerLineColor(){return An.colorStr2Rgba(As.lineColor)}setMarkerLineColor(e){As.lineColor=An.rgba2Color(e)}getMarkerLineWidth(){return As.lineWidth}setMarkerLineWidth(e){As.lineWidth=e}getMarkerIconSize(){return As.iconSize}setMarkerIconSize(e){As.iconSize=e}getMarker(e){return this.markers[e]}setAllSnapLinesVisible(e){Object.values(this.markers).forEach((t=>{t.setSnapLineVisible(e)}))}deactivate(){var e;this.activeOSnapType&&(this.markers[this.activeOSnapType].visible=!1,null==(e=this.overlayRender)||e.render()),this.activeOSnapType=0}destroy(){}handleSnap(e,t,n){if(!e||e.length<1)return void this.deactivate();fe.debug("[OSnap] intersections before handleSnap:",e);let i,r=[],a=!1;for(let o of e)o.object instanceof St?(i||(i=o.point),!a&&"groundPlane"!==o.object.name&&(r.push(o),a=!0)):r.push(o);if(!t&&i){i.setZ(0);for(let t of r)t.point.z=0,t.distance=t.point.distanceTo(i);let e=e=>e instanceof Di?0:e instanceof zr?2:e instanceof Vr?1:3;r.sort(((t,n)=>{let i=e(t.object),r=e(n.object);return i!==r?i-r:t.distance-n.distance}))}i||(fe.warn("[OSnap] Potential to produce erroneous snap results"),i=r[0].point),fe.debug("[OSnap] intersections:",r),fe.debug("[OSnap] mousePosition:",i);let s=this.getSnapPointAndUpdateMarker(i,r,t,n);return(null==s?void 0:s.clone())||i}getSnapPointAndUpdateMarker(e,t,n,i){if(!t.length)return void this.activateMarker(0);let r=this.getSnapInfo(e,t,n,i);if(r&&0!==r.type)return this.activateMarker(r.type,r),r.point;this.activateMarker(0)}activateMarker(e,t){var n;this.activeOSnapType&&(this.markers[this.activeOSnapType].visible=!1),this.activeOSnapType=e;let i=this.markers[e];i&&t&&(i.update(t),i.visible=!0),null==(n=this.overlayRender)||n.render()}getFootOfPerpendicular(e,t,n=Evt){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 k(i.x+l*a,i.y+l*s,i.z+l*o)}getSnapInfo(e,t,n,i){let r=2*this.snapToleranceInWorldCoord;fe.debug("[OSnap] snap radius:",r);let a=[],s={line:void 0},o=this.osnapTypePriorities[0];for(let l=0;l<t.length&&l<this.intersectionLimit;++l){let h,u=t[l],c=u.object;c instanceof St?h=this.getOsnapInfoListFromMesh(e,u,r,o):c instanceof Vr?h=this.getOsnapInfoListFromLine(e,u,n,r,s,o,i):c instanceof Di&&(h=this.getOsnapInfoListFromPoint(e,u,n,r,o)),h&&(o=this.osnapTypePriorities[h.type],a.push(h))}if(0!==a.length)return a.sort(((e,t)=>{let n=this.osnapTypePriorities[e.type],i=this.osnapTypePriorities[t.type];return n!==i?n-i:e.distance-t.distance})),a[0]}getOsnapInfoListFromMesh(e,t,n,i){if(i<this.osnapTypePriorities[1])return;let r=Date.now(),a=Tvt(t);if(!a)return void fe.warn("[OSnap] Failed to get edge !");let s=Date.now();fe.debug(`[OSnap] getEdgeSnappingInfo costs ${(s-r)/1e3}s `),fe.debug("[OSnap] edge:",a);let o=_vt(a,e);if(fe.debug("[OSnap] vertex:",o),o.distance<=n&&this.isOSnapTypeEnabled(1))return{distance:o.distance,type:1,point:o.vertex};if(a.distance<=n){if(this.isOSnapTypeEnabled(2)&&i<this.osnapTypePriorities[2])return;ji.copy(a.vertices[0]),ji.add(a.vertices[1]),ji.divideScalar(2);let t=ji.distanceTo(e);return t<=n&&this.isOSnapTypeEnabled(2)?{distance:t,type:2,point:ji.clone()}:!this.isOSnapTypeEnabled(4)||i<this.osnapTypePriorities[4]?void 0:{distance:a.distance,type:4,point:a.vertex,line:{start:a.vertices[0],end:a.vertices[1]}}}fe.debug("[OSnap] Face")}getOsnapInfoFromSegment(e,t,n,i,r,a,s){let o={start:t,end:n};if(s&&a>=this.osnapTypePriorities[16]&&this.isOSnapTypeEnabled(16)){let t=this.getFootOfPerpendicular(s,o,i),n=e.distanceTo(t);if(n<=i)return{distance:Zt.floorNumber(n,7),type:16,point:t.clone()}}if(a<this.osnapTypePriorities[1])return;QE.set(t,n),QE.closestPointToPoint(e,!0,v1);let l=e.distanceTo(v1);if(l>i)return;let h=e.distanceTo(t),u=e.distanceTo(n);if(Math.min(h,u)<=i&&this.isOSnapTypeEnabled(1)){let e=h,i=t;return u<h&&(e=u,i=n),{distance:Zt.floorNumber(e,7),type:1,point:i.clone()}}if(a<this.osnapTypePriorities[2])return;QE.getCenter(JE);let c=e.distanceTo(JE);if(c<i&&this.isOSnapTypeEnabled(2))return{point:JE.clone(),distance:Zt.floorNumber(c,7),type:2};if(!(a<this.osnapTypePriorities[4])){if(r.line&&this.isOSnapTypeEnabled(32)){let t=en.getLineSegmentsIntersectingPoint(r.line,o);if(!t)return;let n=e.distanceTo(t)/2;return n<i?(r.line=void 0,{point:t.clone(),distance:Zt.floorNumber(n,7),type:32}):void 0}if(this.isOSnapTypeEnabled(4))return r.line={start:t.clone(),end:n.clone()},{point:v1.clone(),distance:Zt.floorNumber(l,7),type:4,line:{start:t.clone(),end:n.clone()}}}}getOsnapInfoListFromLine(e,t,n,i,r,a,s){let o=[],l=t.object,h=l instanceof zr?2:1,u=l.geometry.index,c=l.geometry.attributes.position,d=l.geometry.drawRange,p=Mi.getBatchByLineIndex(l,t.index);if(u){let t=Math.max(0,d.start),f=Math.min(u.count,d.start+d.count);p&&(t=Math.max(t,p.indexStart),f=Math.min(f,p.indexStart+p.indexCount));for(let d=t,p=f;d<p-1;d+=h){let t=u.getX(d),h=u.getX(d+1);ji.fromBufferAttribute(c,t),aa.fromBufferAttribute(c,h),ji.applyMatrix4(l.matrixWorld),aa.applyMatrix4(l.matrixWorld),n||(ji.setZ(0),aa.setZ(0));let p=this.getOsnapInfoFromSegment(e,ji,aa,i,r,a,s);p&&(a=this.osnapTypePriorities[p.type],o.push(p))}}else{let t=Math.max(0,d.start),u=Math.min(c.count,d.start+d.count);p&&(t=Math.max(t,p.positionStart),u=Math.min(u,p.positionStart+p.positionCount));for(let d=t,p=u;d<p-1;d+=h){ji.fromBufferAttribute(c,d),aa.fromBufferAttribute(c,d+1),ji.applyMatrix4(l.matrixWorld),aa.applyMatrix4(l.matrixWorld),n||(ji.setZ(0),aa.setZ(0));let t=this.getOsnapInfoFromSegment(e,ji,aa,i,r,a,s);t&&(a=this.osnapTypePriorities[t.type],o.push(t))}}if(0!==o.length)return o.sort(((e,t)=>{let n=this.osnapTypePriorities[e.type],i=this.osnapTypePriorities[t.type];return n!==i?n-i:e.distance-t.distance})),o[0]}getOsnapInfoListFromPoint(e,t,n,i,r){if(r<this.osnapTypePriorities[1])return;let a=t.object,s=a.geometry.getAttribute("position");ji.fromBufferAttribute(s,t.index),ji.applyMatrix4(a.matrixWorld),aa.copy(e),n||(ji.setZ(0),aa.setZ(0));let o=aa.distanceTo(ji);if(o>i)return;let l={distance:o,point:ji.clone(),type:1};if("CircleCenter"===a.userData.type){if(!this.isOSnapTypeEnabled(64))return;l.type=64}else if(fe.debug("[OSnap] Other types of vertices !"),!this.isOSnapTypeEnabled(1))return;return l}getIntersectsIncludeOutline(e,t){let n=e.slice(),i=[];for(let a=0;a<e.length&&a<this.intersectionLimit;a++){let t=e[a].object;if(t.updateWorldMatrix(!0,!1),t instanceof St&&!rr.hasOutline(t,!1)){let e=rr.createOutline(t.geometry);e.visible=!1,t.add(e),e.updateWorldMatrix(!0,!1),i.push(e)}}let r=[];return i.length>0&&(r=t.intersectObjects(i)||[],fe.debug("[OSnap] Intersected with newly created edges: ",r),r.length>0&&n.push(...r)),n.sort(((e,t)=>e.distance-t.distance)),n}},x4=ss(Lc(),1),Zl=class{constructor(e,t,n){this.follow=e=>{this.node.style.left=e.offsetX+15+"px",this.node.style.top=e.offsetY-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(mf,this.follow):document.removeEventListener(mf,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(mf,this.follow):document.addEventListener(mf,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,x4.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,x4.forEach)(this.childNode.children,(e=>{this.childNode.removeChild(e)})),this.childNode.append(e)}},wP=class{constructor(e){this.active=!1,this.isResolvedOrRejected=!1,this.mouseClicked=e=>{if(e.markupData){let t=e.markupData.id,n=this.viewer.getOverlayRender().getDrawableById(t);if(n){let e=n.getBounds();e=e.clone().expandByScalar(20*this.viewer.getPixelSizeInWorldCoord());let t=Sn.world2NormalizedScreen(e.min,this.camera,this.viewerContainer),i=Sn.world2NormalizedScreen(e.max,this.camera,this.viewerContainer),r=new _i(new _e(Math.min(t.x,i.x),Math.min(t.y,i.y)),new _e(Math.max(t.x,i.x),Math.max(t.y,i.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();let a=this.viewer;"function"==typeof a.clearSelection&&a.clearSelection()}}},this.keydown=e=>{"Escape"===e.code&&this.deactivate()},this.viewer=e}get viewerContainer(){return this.viewer.viewerContainer}get camera(){return this.viewer.camera}isActive(){return this.active}activate(){var e,t;if(this.isActive())return void(this.reject&&(this.deactivate(),this.reject("PickMarkupHelper is already actived!"),this.isResolvedOrRejected=!0));this.active=!0,this.viewer.addEventListener("MouseClicked",this.mouseClicked),null==(e=this.viewer.getInputManager())||e.addEventListener("keydown",this.keydown),this.tooltip=new Zl("pick-markup-tooltip",wr("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=wr("Tooltip.pickMarkup");i&&this.tooltip&&(null==(t=this.tooltip)||t.setContent(i)),this.viewer.dispatchEvent("PickMarkupActivated")}deactivate(){var e,t,n;this.active=!1,this.viewer.removeEventListener("MouseClicked",this.mouseClicked),null==(e=this.viewer.getInputManager())||e.removeEventListener("keydown",this.keydown),null==(t=this.tooltip)||t.hide(),null==(n=this.tooltip)||n.destroy(),this.tooltip=void 0,this.viewer.dispatchEvent("PickMarkupDeactivated"),this.resolve&&!this.isResolvedOrRejected&&(this.resolve(void 0),this.isResolvedOrRejected=!0)}pick(){return it(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!")}},SP=class{constructor(e){this.mouseDown=!1,this.mouseMove=!1,this.mouseDownPositionX=-1,this.mouseDownPositionY=-1,this.tempEnableRotate=!1,this.active=!1,this.isResolvedOrRejected=!1,this.mousedown=e=>{var t,n;if(0===e.button){this.mouseDown=!0;let i=new _e(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 _e(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 _e(Math.min(this.mouseDownPositionX,t.x),Math.min(this.mouseDownPositionY,t.y)),n=new _e(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 _e(e.x,e.y),n=new _e(Math.min(this.mouseDownPositionX,t.x),Math.min(this.mouseDownPositionY,t.y)),i=new _e(Math.max(this.mouseDownPositionX,t.x),Math.max(this.mouseDownPositionY,t.y)),r=new _i(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.keydown=e=>{"Escape"===e.code&&this.deactivate()},this.viewer=e,this.input=e.getInputManager()}get viewerContainer(){return this.viewer.viewerContainer}isActive(){return this.active}activate(){var e;if(this.isActive())return void(this.reject&&(this.deactivate(),this.reject("BoxSelectHelper is already actived!"),this.isResolvedOrRejected=!0));this.active=!0,this.input.addEventListener("pointerdown",this.mousedown),this.input.addEventListener("pointermove",this.mousemove),this.input.addEventListener("pointerup",this.mouseup),this.input.addEventListener("keydown",this.keydown),this.viewer.getCameraManager().enableMouseLeft(!1),this.tooltip=new Zl("box-select-tooltip",wr("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 n=wr("Tooltip.boxSelect");n&&this.tooltip&&(null==(e=this.tooltip)||e.setContent(n)),this.viewer.dispatchEvent("BoxSelectActivated")}deactivate(){var e,t;this.active=!1,this.input.removeEventListener("pointerdown",this.mousedown),this.input.removeEventListener("pointermove",this.mousemove),this.input.removeEventListener("pointerup",this.mouseup),this.input.removeEventListener("keydown",this.keydown),null==(e=this.tooltip)||e.hide(),null==(t=this.tooltip)||t.destroy(),this.tooltip=void 0,this.viewer.getCameraManager().enableMouseLeft(!0),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: ${SP.BORDER_WIDTH} solid ${SP.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 it(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!")}},zf=SP;zf.BORDER_COLOR="#fff000",zf.BORDER_WIDTH="2px";var MP=class{constructor(e){this.active=!1,this.viewer=e,this.boxSelectHelper=new zf(e)}get viewerContainer(){return this.viewer.viewerContainer}get camera(){return this.viewer.camera}get raycaster(){return this.viewer.getRaycaster()}isActive(){return this.active}activate(){var e;this.active=!0,null==(e=this.boxSelectHelper)||e.select().then((e=>{e&&this.handleZoomToRect(e.min,e.max)}))}deactivate(){var e;this.active=!1,null==(e=this.boxSelectHelper)||e.deactivate()}pickPositionByScreenPoint(e){var t;return null==(t=this.viewer.pickModel({x:e.x,y:e.y}))?void 0:t.point}handleZoomToRect(e,t){let n=this.pickPositionByScreenPoint(e),i=this.pickPositionByScreenPoint(t);if(n&&i){let e=new k(Math.min(n.x,i.x),Math.min(n.y,i.y),Math.min(n.z,i.z)),t=new k(Math.max(n.x,i.x),Math.max(n.y,i.y),Math.max(n.z,i.z)),r=new Nt(e,t);this.viewer.zoomToBBox(r)}}destroy(){var e;null==(e=this.boxSelectHelper)||e.destroy(),this.boxSelectHelper=void 0}},AP=class extends Wi{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 _e(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"}},y1=class{constructor(e){this.CLEAR_COLOR=(new ct).setRGB(1,1,1),this.CLEAR_COLOR_ALPHA=1,this.EMPTY_MODEL_ID=255,this.viewer=e,this.raycaster=new Ac,this.pickingTexture=new er(1,1)}get scene(){return this.viewer.scene}get camera(){return this.viewer.camera}get renderer(){return this.viewer.renderer}get overlayRender(){return this.viewer.getOverlayRender()}get viewerContainer(){return this.viewer.viewerContainer}getRaycaster(){return this.raycaster}pickObjectByNdc(e,t){this.raycaster.setFromCamera(e,this.camera);let n=this.raycaster.intersectObjects(Array.isArray(t)?t:[t],!0);if(n.length)return{object:n[0].object,point:n[0].point,distance:n[0].distance,face:n[0].face||void 0,instanceId:n[0].instanceId||void 0}}pickObject(e,t){let n=Sn.screen2Ndc(e,this.camera,this.viewerContainer);return this.pickObjectByNdc(n,t)}pickObjects(e,t){let n=Sn.screen2Ndc(e,this.camera,this.viewerContainer);return this.raycaster.setFromCamera(n,this.camera),this.raycaster.intersectObjects(Array.isArray(t)?t:[t],!0)||[]}pickDrawable(e){return this.overlayRender.getDrawablesByPosition(e)}pickBuffer(e,t,n=1,i=1){let{pickingTexture:r,renderer:a,camera:s}=this;r.setSize(n,i);let o=a.getPixelRatio();s.setViewOffset(a.getContext().drawingBufferWidth,a.getContext().drawingBufferHeight,e.x*o|0,e.y*o|0,n,i),a.setRenderTarget(r);let l=new ct;a.getClearColor(l);let h=a.getClearAlpha();a.setClearColor(this.CLEAR_COLOR,this.CLEAR_COLOR_ALPHA),a.render(t,s),a.setRenderTarget(null),s.clearViewOffset(),a.setClearColor(l),a.setClearAlpha(h);let u=new Uint8Array(4*n*i);return a.readRenderTargetPixels(r,0,0,n,i,u),u}},RP=class{constructor(e){this.viewer=e;let t=new Ji;t.matrixAutoUpdate=!1,t.matrixWorldAutoUpdate=!1,this.scene=t,this.modelGroup=new Bn,this.modelGroup.name="models",this.scene.add(this.modelGroup);let{width:n,height:i,viewerContainer:r}=e.container;this.renderer=new ga({antialias:!0,preserveDrawingBuffer:!0}),this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setSize(n,i),this.renderer.outputColorSpace=sn,this.renderer.toneMappingExposure=1,this.renderer.useLegacyLights=!1,this.renderer.localClippingEnabled=!0,this.renderer.shadowMap.enabled=!1,this.renderer.shadowMap.type=hv,this.renderer.shadowMap.autoUpdate=!1,this.renderer.domElement.style.outlineWidth="0",null==r||r.appendChild(this.renderer.domElement),Pt.printGpuInfo(this.renderer.getContext())}initLights(){let e=new Bn;e.name="lights";let t=16777215,n=new va(t,1.5);n.name="sun",n.castShadow=!0,n.position.set(-2,2,4),n.shadow.autoUpdate=!1,n.shadow.mapSize.width=1024,n.shadow.mapSize.height=1024;let i=new mo(t);i.name="ambient";let r=new Pu(t,14540253,.2);r.name="hemisphere",r.position.set(0,300,0);let a=new Bn;a.name="lightHelper",a.visible=!1;let s=new gb(n);s.visible=!0;let o=new vb(n.shadow.camera);return o.visible=!0,a.add(s),a.add(o),e.add(n),e.add(n.target),e.add(i),e.add(r),e.add(a),this.scene.add(e),this.lightsHelper=a,this.lights=e,e}initPMREMGenerator(){this.pmremGenerator=new Hh(this.renderer),this.pmremGenerator.compileEquirectangularShader()}get maxFragmentUniforms(){return this.renderer.capabilities.maxFragmentUniforms-20}addModel(e){this.modelGroup.add(e.getModelObject())}enableShadow(e){this.renderer.shadowMap.enabled=e}enableClipping(e){this.renderer.localClippingEnabled=e}enableLights(e){let t=this.lights;t||(t=this.initLights()),t.visible=e}debugLights(e){!this.lights||!this.lightsHelper||(this.lightsHelper.visible=e)}setBackground(e){this.scene.background=e}get directionLight(){var e;return null==(e=this.lights)?void 0:e.getObjectByName("sun")}get ambientLight(){var e;return null==(e=this.lights)?void 0:e.getObjectByName("ambient")}get hemisphereLight(){var e;return null==(e=this.lights)?void 0:e.getObjectByName("hemisphere")}setEnvironmentFromData(e){return it(this,null,(function*(){this.pmremGenerator||this.initPMREMGenerator();let t=yield xf.createEnvTextureFromDataArray(this.pmremGenerator,e);this.scene.environment=t}))}setEnvironment(e){return it(this,null,(function*(){this.pmremGenerator||this.initPMREMGenerator();let t=yield xf.createEnvTexture(this.pmremGenerator,e);this.scene.environment&&this.scene.environment.dispose(),this.scene.environment=t}))}resize(){let{width:e,height:t}=this.viewer.container;this.renderer.setSize(e,t)}getRaycastableObjects(){let e=[];return this.modelGroup.traverse((t=>{e.push(t)})),e}destroy(){var e,t,n,i,r,a,s;null==(e=this.lightsHelper)||e.clear(),null==(t=this.lightsHelper)||t.removeFromParent(),null==(n=this.lightsHelper)||n.traverse((e=>{var t;null==(t=e.dispose)||t.call(e)})),this.lightsHelper=void 0,null==(i=this.lights)||i.clear(),null==(r=this.lights)||r.removeFromParent(),null==(a=this.lights)||a.traverse((e=>{var t;null==(t=e.dispose)||t.call(e)})),this.lights=void 0,null==(s=this.pmremGenerator)||s.dispose(),this.renderer.domElement.remove(),this.renderer.clear(),this.renderer.dispose(),this.renderer.forceContextLoss(),this.scene.clear()}},Gf=class extends Ms{constructor(e){super(),this.name="BaseViewer",this.clock=new Pl,this.fps=60,this.timeStamp=0,this.renderEnabled=!0,this.plugins=[],this.loadedModels=[],this.raf=new p1,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.viewerCfg=e,this.initLogLevel(),this.initLocalization(),this.container=new YC(e.containerId),this.progressBar=new $C(this.container),this.spinner=new XC(this.container),this.sceneManager=new RP(this),this.pickManager=new y1(this),this.overlayRender=new Gn(this),this.css2dRenderer=this.initCSS2DRenderer(),this.inputManager=new id(this.viewerContainer),this.cameraManager=new QC(this),this.loaderHelper=new ju,this.undoRedoManager=new zR,this.resize(),this.clock.start(),this.animate()}initLogLevel(){let e=this.viewerCfg.logLevel;e&&Ide(e)}initLocalization(){var e;let t=(null==(e=this.viewerCfg)?void 0:e.language)||"cn";return rd.init({lng:t,debug:!1,resources:{en:{translation:pfe},cn:{translation:mfe}}}),rd.t}get viewerContainer(){return this.container.viewerContainer}get widgetContainer(){return this.container.widgetContainer}getUndoRedoManager(){return this.undoRedoManager}getInputManager(){return this.inputManager}getCameraManager(){return this.cameraManager}getOverlayRender(){return this.overlayRender}get renderer(){return this.sceneManager.renderer}get camera(){return this.cameraManager.camera}get scene(){return this.sceneManager.scene}getRaycaster(){return this.pickManager.getRaycaster()}getViewConfig(){return this.viewerCfg}getSpinner(){return this.spinner}getFontManager(){return this.fontManager}initCSS2DRenderer(){var e;let t=new Lv,{width:n,height:i}=this.viewerContainer.getBoundingClientRect();return t.setSize(n,i),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),t}animate(){if(Date.now()-this.timeStamp<1/this.fps)return void(this.requestAnimationFrameHandle=requestAnimationFrame(this.animate.bind(this)));let e=this.cameraManager.update(this.clock.getDelta());this.container.needResize&&(this.resize(),this.renderEnabled=!0),(this.renderEnabled||e)&&(this.dispatchEvent("BeforeRender"),this.renderer.render(this.scene,this.camera),this.css2dRenderer.render(this.scene,this.camera),this.dispatchEvent("AfterRender"),this.renderEnabled=!1),this.requestAnimationFrameHandle=requestAnimationFrame(this.animate.bind(this)),this.timeStamp=Date.now(),this.dispatchEvent("OnAnimate")}resize(){this.sceneManager.resize(),this.cameraManager.updateAspect();let{clientWidth:e,clientHeight:t}=this.viewerContainer;this.css2dRenderer.setSize(e,t),this.overlayRender.setSize(e,t)}setDracoDecoderPath(e){ju.setDracoDecoderPath(e)}addModel(e){let t=e.getModelObject();t.name=e.modelId,this.sceneManager.addModel(e),t.matrixAutoUpdate=!1,t.updateMatrix(),t.updateMatrixWorld(!0),this.loadedModels.push(e),this.enableRender(0)}setFont(e){return it(this,null,(function*(){this.fontManager||(this.fontManager=new zm),yield this.fontManager.loadFonts(e)}))}is3d(){return!1}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=new k;e.getWorldPosition(r);let a=this.cameraManager.getTarget();r&&a&&(i=r.distanceTo(a)*Math.tan(t.fov/2*Math.PI/180)*2/n)}return i}zoomToRect(){this.zoomToRectHelper||(this.zoomToRectHelper=new MP(this)),this.zoomToRectHelper.activate()}deactivateZoomRect(){var e;null==(e=this.zoomToRectHelper)||e.deactivate()}getUniqueModelId(e){let t=e,n=e=>!!this.loadedModels.find((t=>t.modelId===e));if(n(t)){let e=1;for(;n(`${t}_${e}`);)e++;t=`${t}_${e}`,fe.warn(`[Viewer] Model '${t}' is loaded more than once!`)}return t}getBBox(){let e=new Nt;return this.loadedModels.forEach((t=>{e.union(t.getBBox())})),e}flyToObject(e){this.cameraManager.flyToObject(e)}flyToObjects(e){let t=new Nt;e.forEach((e=>{let n=(new Nt).setFromObject(e);t.union(n)}));let n=new $r;t.getBoundingSphere(n),this.cameraManager.fitToSphere(n)}flyTo(e,t){let n=this.camera;if(e.equals(t))return void fe.error("[Viewer] camera position and lookAt cannot be the same!");if(!Pt.isVectorValid(e)||!Pt.isVectorValid(t))return void fe.error("[Viewer] invalid position or lookAt!");let i=e.distanceTo(t);i<n.near?(e=e.clone().sub(t).normalize().multiplyScalar(1.1*n.near),fe.warn("[Viewer] camera could be too close to see the object!")):i>n.far&&(e=e.clone().sub(t).normalize().multiplyScalar(.9*n.far),fe.warn("[Viewer] camera could be too far to see the object!")),this.cameraManager.flyTo(e,t)}flyToDirection(e){let t=this.getBBox().getSize(new k),n=Math.max(t.x,t.y,t.z)/2,i=this.cameraManager.getDistanceToFitSphere(n),r=this.cameraManager.getTarget(),a=r.clone().add(e.clone().multiplyScalar(i));this.flyTo(a,r)}goToHomeView(){this.homeView&&this.cameraManager.setCameraInfo(this.homeView)}viewFitAll(){let e=this.getBBox(),t=new $r;e.getBoundingSphere(t),this.cameraManager.fitToSphere(t)}zoomToBBox(e){this.cameraManager.flyToBox(e)}pickModel(e){var t;let n=this.pickManager.pickObject(e,this.getRaycastableObjects());return this.renderer&&this.renderer.clippingPlanes.length>0&&null!=(t=this.renderer)&&t.clippingPlanes.every((e=>{n&&e.distanceToPoint(n.point)}))&&(n=void 0),n}pickObjectsByMouse(e){let t=this.pickManager.pickObjects(e,this.getRaycastableObjects());return t&&this.renderer.clippingPlanes.length>0&&(t=t.filter((e=>this.renderer.clippingPlanes.every((function(t){return t.distanceToPoint(e.point)>0}))))),t}getRaycastableObjects(){return this.sceneManager.getRaycastableObjects()}setBackgroundColor(e,t,n){this.sceneManager.setBackground(new ct(e,t,n)),this.enableRender()}setCameraProjection(e){this.cameraManager.setProjection(e)}enableControl(e){this.cameraManager.enableControl(e)}enableRotate(e){this.cameraManager.enableRotate(e)}enableZoom(e){this.cameraManager.enableZoom(e)}enablePan(e){this.cameraManager.enablePan(e)}getCameraInfo(){return this.cameraManager.getCameraInfo()}setCameraInfo(e){return this.cameraManager.setCameraInfo(e)}getCameraDirection(){return this.cameraManager.getCameraDirection()}getRenderInfo(){var e;let t=this.renderer.info;return{drawCalls:t.render.calls,lines:t.render.lines,points:t.render.points,triangles:t.render.triangles,geometries:t.memory.geometries,textures:t.memory.textures,materials:(null==(e=t.programs)?void 0:e.length)||0}}destroy(){this.requestAnimationFrameHandle&&cancelAnimationFrame(this.requestAnimationFrameHandle),this.css2dRenderer.domElement.remove(),this.container.destroy(),this.sceneManager.destroy(),this.cameraManager.destroy(),this.overlayRender.destroy(),this.spinner.destroy(),this.progressBar.destroy(),this.undoRedoManager.destroy()}addPlugin(e){this.plugins.find((t=>t.id===e.id))?fe.warn(`[Viewer] Plugin already exist: ${e.id}`):(this.plugins.push(e),fe.debug(`[Viewer] Added plugin: ${e.id}`))}removePlugin(e){for(let t=0,n=this.plugins.length;t<n;t++)if(this.plugins[t]===e)return void this.plugins.splice(t,1)}clearPlugins(){this.plugins=[]}findPlugin(e){return this.plugins.find((t=>t.id===e))}};function x1(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 CP=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 b4(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")}},b4=class{constructor(e,t){this.viewer=e,this.eventBus=x1(),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")}},Kl=(e=>(e.Distance="Distance",e.Area="Area",e.Angle="Angle",e.Coordinate="Coordinate",e))(Kl||{}),Xu=class extends Ms{constructor(e,t,n,i,r){super(),this.actived=!1,this.mouseMoved=!1,this.mouseDowned=!1,this.touchDowned=!1,this.mouseDownPositionX=-1,this.mouseDownPositionY=-1,this.snapPoint=void 0,this.touchstart=e=>{this.mobileTouchHelper&&this.mobileTouchHelper.isIntersect(e)&&!this.touchDowned&&(this.clearClickedDrawable(),this.viewer.getCameraManager().enableControl(!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.viewer.viewerContainer.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 void this.osnapHelper.deactivate();let a=Date.now();if(this.snapPoint=this.osnapHelper.handleSnap(r,this.viewer.is3d(),this.lastMouseDownPosition),fe.debug(`[BaseMeasurement] 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.getCameraManager().enableControl(!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);dr.isMobile&&(this.osnapHelper.deactivate(),this.dispatchEvent("Updated"))}},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 void this.osnapHelper.deactivate();let n=Date.now();this.snapPoint=this.osnapHelper.handleSnap(t,this.viewer.is3d(),this.lastMouseDownPosition),fe.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=()=>{fe.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=>this.viewer.pickObjectsByMouse({x:e.x,y:e.y}),this.type=e,this.viewer=t,this.inputManager=n,this.drawList=i,this.osnapHelper=r}get overlayRender(){return this.viewer.getOverlayRender()}get renderer(){return this.viewer.renderer}get isActive(){return this.actived}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(this.actived=!0,dr.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),this.tooltip=new Zl("measure-tooltip",wr("Tooltip.measure"),{followPointer:!0,showOnCreate:!0,parentNode:this.viewer.widgetContainer,target:this.viewer.viewerContainer});let e=document.getElementById("measure-tooltip");e&&(e.style.pointerEvents="none"),this.setTooltipContent()}this.inputManager.addEventListener("dblclick",this.dblclick),this.inputManager.addEventListener("keydown",this.keydown)}deactivate(){var e,t;this.actived=!1,dr.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.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(dr.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.overlayRender.getDrawablesByDrawableListAndPosition(this.drawList,t.point);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(),this.currentMeasureDrawable&&(this.currentMeasureDrawable.selected=!0),void this.dispatchEvent("WillBeAdded",this.currentMeasureDrawable);e&&t.push(e),this.currentMeasureDrawable.selected=!0,this.currentMeasureDrawable.update(t),this.currentMeasureDrawable.setDrawingState(!0),this.dispatchEvent("Updated")}},Ea=class extends Wi{constructor(e,t){super(e),this.type="Distance",this.labelBounds=new _i,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=Ea.MAJOR_COLOR,e.strokeStyle=Ea.MINOR_COLOR,e.lineWidth=Ea.LINE_WIDTH,e.beginPath(),(this.drawing?n.slice(0,n.length-1):n).forEach((n=>{let i=this.transToScreenCoord(n,t);e.moveTo(i.x+Ea.POINT_RADIUS,i.y),e.arc(i.x,i.y,Ea.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=`${Ea.LABEL_FONT_SIZE}px Arial`;let n=1.2*e.measureText(this.label).width,i=1.5*Ea.LABEL_FONT_SIZE;this.labelBounds.setFromCenterAndSize(this.labelPositon,new _e(n,i)),this.drawRoundRect(e,this.labelPositon.x-n/2,this.labelPositon.y-i/2,n,i,4),e.save(),e.fillStyle=Ea.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=Ea.MAJOR_COLOR,e.strokeStyle=Ea.MINOR_COLOR,e.lineWidth=Ea.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 Nt).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 Nt).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(An.colorStr2Rgba(Ea.MAJOR_COLOR)),this.setFillColor(An.colorStr2Rgba(Ea.AREA_FILL_COLOR)),this.setLineWidth(Ea.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 k,s=new k,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?Hb("mm"):"Area"===this.type?`${Hb("m",2)}`:"Angle"===this.type?"\xb0":""}},Fr=Ea;Fr.MAJOR_COLOR="rgba(249, 157, 11, 0.9)",Fr.MINOR_COLOR="rgb(255, 255, 255)",Fr.AREA_FILL_COLOR="rgba(249, 157, 11, 0.3)",Fr.LINE_WIDTH=2,Fr.POINT_RADIUS=5,Fr.LABEL_FONT_SIZE=14;var e_=class extends Fr{constructor(e,t){super(e,t),this.type="Angle",this.update(t)}draw(e,t){e.save(),e.lineWidth=Fr.LINE_WIDTH,e.strokeStyle=Fr.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 _e).subVectors(n,i).normalize(),s=(new _e).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=`${Ou(s,2)} ${this.getUnitString()}`;let o=.3*Math.min(n.distanceTo(i),r.distanceTo(i));this.labelPositon=this.transToScreenCoord(i.clone().add(new k(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 k(i.x-r.x,i.y-r.y,i.z-r.z).normalize(),o=new k(a.x-r.x,a.y-r.y,a.z-r.z).normalize();return new k(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 k(i.x-r.x,i.y-r.y,i.z-r.z),o=new k(a.x-r.x,a.y-r.y,a.z-r.z);return 180*s.angleTo(o)/Math.PI}getClassType(){return"Angle"}};Gn._registerDrawableClass(e_);var PP=class extends Xu{constructor(e,t,n,i){super("Angle",e,t,n,i)}createMeasureDrawable(){if(this.drawingPoints)return new e_(Pt.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]&&Zt.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=wr("Tooltip.measure");t&&this.tooltip&&(null==(e=this.tooltip)||e.setContent(t))}},Wf=class extends Fr{constructor(e,t,n){super(e,t),this.type="Area",this.scale=n,this.update(t)}draw(e,t){let n=this.points;if(e.save(),e.lineWidth=Fr.LINE_WIDTH,e.strokeStyle=Fr.MAJOR_COLOR,e.fillStyle=Fr.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.scale&&(i*=Math.pow(this.scale,2)),this.label=`${Ou(i,2)}`,this.labelPositon=this.transToScreenCoord(this.getBarycenter(n),t),super.drawText(e,t)}calculateArea(e){let t=0,n=Rm.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 k(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 k,s=new k,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=Rm.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"}};Gn._registerDrawableClass(Wf);var Eve=new k,IP=class extends Xu{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 Wf(Pt.guid(),this.drawingPoints,this.scale)}onMouseMove(e){if(super.onMouseMove(e),this.drawingPoints&&this.drawingPoints.length>2&&this.drawingPoints[0]){let t=this.drawingPoints[0];Eve.subVectors(e,t).length()<3*this.viewer.getPixelSizeInWorldCoord()&&(this.osnapHelper.activateMarker(1,{point:t,type:1,distance:0}),fe.info("[AreaMeasurement] auto close area measurement."))}}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 fe.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&&this.drawingPoints.length>2&&this.drawingPoints[0]){let e=this.drawingPoints[0];if(Eve.subVectors(a,e).length()<3*this.viewer.getPixelSizeInWorldCoord())return fe.info("[AreaMeasurement] auto close area measurement."),this.touchDowned=!1,void this.exitDrawing()}this.drawingPoints[0]&&Zt.areVector3sEqual(this.drawingPoints[0],a)||(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&&(fe.warn("[Measure] If the number of points is less than 3, the measurement area cannot be formed !"),t=!1),t&&Rm.isSelfIntersecting(e)&&(fe.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=wr("Tooltip.areaMeasurement");t&&this.tooltip&&(null==(e=this.tooltip)||e.setContent(t))}getScale(){return this.scale}setScale(e){this.scale=e;let t=this.drawList.getDrawables();for(let n of t){let t=n[1];t instanceof Wf&&(t.scale=e)}}},t_=class extends Fr{constructor(e,t){super(e,t),this.type="Coordinate",this.update(t)}draw(e,t){this.drawText(e,t),e.save(),e.lineWidth=Fr.LINE_WIDTH,e.strokeStyle=Fr.MAJOR_COLOR,e.fillStyle=Fr.AREA_FILL_COLOR;let n=this.points;e.beginPath(),n.forEach((n=>{let i=this.transToScreenCoord(n,t);e.arc(i.x,i.y,Fr.POINT_RADIUS,0,2*Math.PI)})),e.fill(),e.stroke(),e.restore()}drawText(e,t){let n=this.points[0];Zt.areNumbersEqual(n.x,0);let i=Zt.areNumbersEqual(n.x,0)?0:n.x,r=Zt.areNumbersEqual(n.y,0)?0:n.y,a=Zt.areNumbersEqual(n.z,0)?0:n.z;this.label=`${Ou(i,2)}, ${Ou(r,2)}, ${Ou(a,2)}`,e.font=`${Fr.LABEL_FONT_SIZE}px Arial`;let s=1.2*e.measureText(this.label).width,o=1.5*Fr.LABEL_FONT_SIZE;this.labelPositon=this.transToScreenCoord(n,t),this.labelPositon.y-=o/2,this.labelBounds.setFromCenterAndSize(this.labelPositon,new _e(s,o)),this.drawRoundRect(e,this.labelPositon.x-s/2,this.labelPositon.y-o/2,s,o,4),e.save(),e.fillStyle=Fr.MINOR_COLOR,e.textBaseline="middle",e.textAlign="center",e.fillText(this.label,this.labelPositon.x,this.labelPositon.y),e.restore()}getClassType(){return"Coordinate"}};Gn._registerDrawableClass(t_);var LP=class extends Xu{constructor(e,t,n,i){super("Coordinate",e,t,n,i)}createMeasureDrawable(){if(this.drawingPoints)return new t_(Pt.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=wr("Tooltip.measure");t&&this.tooltip&&(null==(e=this.tooltip)||e.setContent(t))}},E4=class extends Fr{constructor(e,t,n){super(e,t),this.type="Distance",this.scale=n,this.update(t)}draw(e,t){let n=this.points;if(e.save(),e.lineWidth=Fr.LINE_WIDTH,e.strokeStyle=Fr.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.scale&&(r*=this.scale),this.label=`${Ou(r,2)}`,this.labelPositon=this.transToScreenCoord((new k).lerpVectors(n,i,.5),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=Fr.LINE_WIDTH,e.strokeStyle=Fr.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 _e).subVectors(t,e).normalize(),i=E4.SHORT_LINE_LENGTH/2,r=Math.PI/2;return[n.clone().rotateAround(new _e,r).normalize().multiplyScalar(i).add(e),n.clone().rotateAround(new _e,-r).normalize().multiplyScalar(i).add(e)]}getClassType(){return"Distance"}setScale(e){this.scale=e}},Km=E4;Km.SHORT_LINE_LENGTH=12,Gn._registerDrawableClass(Km);var DP=class extends Xu{constructor(e,t,n,i){super("Distance",e,t,n,i)}createMeasureDrawable(){if(this.drawingPoints)return new Km(Pt.guid(),this.drawingPoints,this.scale)}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]&&Zt.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=wr("Tooltip.measure");t&&this.tooltip&&(null==(e=this.tooltip)||e.setContent(t))}getScale(){return this.scale}setScale(e){this.scale=e;let t=this.drawList.getDrawables();for(let n of t){let t=n[1];(t instanceof Km||t instanceof Wf)&&(t.scale=e)}}},_4=class extends ar{constructor(e){var t,n;super(e,{id:_4.DEFAULT_ID}),this.selectedDrawable=void 0,this.drawableList=new Xo("measure"),this.drawableHelperList=new Xo("touchHelper"),this.snapToleranceInPixel=3,this.measurements={},this.activeMeasurementType=void 0,this.keydown=e=>{var t;let n,i=this.getActiveMeasurementType();i&&(n=this.measurements[i]);let r=this.selectedDrawable;r&&"Delete"===e.code&&(this.remove(r),null==(t=this.viewer.undoRedoManager)||t.addCommand(new qR(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};let i=e.getInputManager();if(!i)throw"InputManager init error";this.inputManager=i,this.overlayRender=this.viewer.overlayRender,null==(t=this.overlayRender)||t.addDrawableList(this.drawableHelperList),null==(n=this.overlayRender)||n.addDrawableList(this.drawableList);let r=new TP(this.overlayRender);e.is3d()&&(r.setOSnapTypeEnabled(32,!1),r.setOSnapTypeEnabled(64,!1)),this.measurements.Distance=new DP(e,i,this.drawableList,r),this.measurements.Area=new IP(e,i,this.drawableList,r),this.measurements.Angle=new PP(e,i,this.drawableList,r),this.measurements.Coordinate=new LP(e,i,this.drawableList,r),this.osnapHelper=r,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 qb(this,e.getData())),this.select(e)})),e.addEventListener("WillBeAdded",(e=>{this.add(e,!1)})),e.addEventListener("Updated",(()=>{this.render()})),e.addEventListener("WillBeRemoved",(e=>{this.remove(e,!1)})),e.addEventListener("Deactivate",(()=>{this.osnapHelper.deactivate(),this.viewer.deactivateMeasurement()})),e.addEventListener("FirstPointPicked",(()=>{this.unselect()})),e.addEventListener("ClickedOnMeasurement",(e=>{this.select(e)}))}))}get canvas(){var e;return null==(e=this.viewer.renderer)?void 0:e.domElement}get raycaster(){return this.viewer.getRaycaster()}add(e,t=!0){this.drawableList.addDrawable(e),this.selectedDrawable=e,this.render(),t&&this.viewer.dispatchEvent("MeasurementAdded",e.getData())}create(e){return Gn.createDrawable(e)}remove(e,t=!0){this.drawableList.removeDrawable(e),this.render(),t&&this.viewer.dispatchEvent("MeasurementRemoved",e.getData())}setSnapTolerance(e){this.snapToleranceInPixel=e,this.updateSnapTolerance()}updateSnapTolerance(){let e=this.viewer.getPixelSizeInWorldCoord()*this.snapToleranceInPixel;this.osnapHelper.setSnapTolerance(e)}activate(e){this.activeMeasurementType&&this.deactivate(),this.measurements[e]?(this.measurements[e].activate(),this.activeMeasurementType=e,this.updateSnapTolerance()):(this.activeMeasurementType=void 0,fe.error("[Measure] Failed to activate measurement, type:",e));let{width:t,height:n}=this.canvas.getBoundingClientRect();dr.isMobile&&this.canvas&&!this.mobileTouchHelper&&(this.mobileTouchHelper=new AP(new _e(t/2,n/2)),this.drawableHelperList.addDrawable(this.mobileTouchHelper)),this.mobileTouchHelper&&(this.mobileTouchHelper.setPosition(new _e(t/2,n/2)),this.measurements[e].setTouchHelper(this.mobileTouchHelper),this.mobileTouchHelper.visible=!0,this.render()),this.inputManager.addEventListener("keydown",this.keydown)}deactivate(){this.unselect();let e=this.activeMeasurementType;e&&this.measurements[e].deactivate(),this.activeMeasurementType=void 0,this.mobileTouchHelper&&(this.mobileTouchHelper.visible=!1,this.render()),this.inputManager.removeEventListener("keydown",this.keydown)}getActiveMeasurementType(){return this.activeMeasurementType}isActive(){let e=this.activeMeasurementType;return e?this.measurements[e].isActive:!!this.getActiveMeasurementType()}isMeasuring(){let e=this.activeMeasurementType;return!!e&&this.measurements[e].isMeasuring}getData(){return this.drawableList.getDrawableDatas()}cancel(){let e=this.activeMeasurementType;e&&this.measurements[e].exitDrawing()}setData(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.add(Gn.createDrawable(e)),null==(t=this.viewer.undoRedoManager)||t.addCommand(new qb(this,e))):fe.info("[Measure] Invalid points found in MeasurementData:",e):fe.warn("[Measure] Failed to add measurement data for",e)})),null==(n=this.viewer.undoRedoManager)||n.endTransaction()}setVisibleById(e,t){let n=this.drawableList.getDrawables().get(e);return!!n&&(n.visible!==t&&(n.visible=t,this.render()),!0)}setVisibilities(e){let t=!1;this.drawableList.getDrawables().forEach((n=>{n.visible!==e&&(n.visible=e,t=!0)})),t&&this.render()}clear(){let e=this.activeMeasurementType;e&&this.measurements[e].exitDrawing(),this.drawableList.clear(),this.render()}getById(e){return this.drawableList.getDrawableById(e)}removeById(e){let t=this.drawableList.getDrawableById(e);t?this.remove(t):fe.warn("[Measure] Failed to find measurement by id:",e)}selectById(e){let t=this.drawableList.getDrawableById(e);t&&this.select(t)}select(e){this.unselect(!1),e.selected=!0,this.selectedDrawable=e,this.render()}unselect(e=!0){this.selectedDrawable&&(this.selectedDrawable.selected=!1,e&&this.render()),this.selectedDrawable=void 0}getScale(){return this.measurements.Distance.getScale()}setScale(e){if(!e||e<=0)return void fe.error("[Measure] Invalid scale value:",e);let t=this.measurements.Distance,n=this.measurements.Area;t.setScale(e),n.setScale(e)}destroy(){super.destroy(),this.deactivate(),this.clear(),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()}},Jm=_4;Jm.DEFAULT_ID="MeasurementPlugin";var OP=new k,_ve=new ht,Tve=new wl,T4=new Nt,jf=class extends Gf{constructor(e){super(e),this.name="DxfViewer",this.enableSelection=!0,this.loadedModels=[],this.masterModelId="",this.activeLayoutName="",this.layoutInfos={},this.units=void 0,this.enableHideVisuallySmallObjects=!0,this.sortedHidableObjects={},this.lastCameraZoom=1/0,this.loadingDxfCount=0,null!=e.enableSelection&&(this.enableSelection=e.enableSelection),e.enableLayoutBar&&(this.dxfLayoutBar=new CP(this)),this.cameraManager.setProjection(1),this.cameraManager.setNavigationMode(2),this.cameraManager.setCameraInfo({eye:[0,0,100],look:[0,0,0]}),this.resize(),this.setupDefaultEvents(),this.setDefaultBackground(),this.addEventListener("BeforeRender",(()=>{this.updateRaycasterThreshold(),this.updateCameraZoomUniform(this.camera.zoom),this.updateHidableObjectsVisibility()}))}get camera(){return this.cameraManager.camera}setupDefaultEvents(){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 ki&&(r.markupData=this.selectedObject.getData()),this.selectedObject&&this.selectedObject instanceof Fr&&(r.measureData=this.selectedObject.getData()),this.selectedObject&&this.selectedObject instanceof an){let e=t=>!t.userData.modelId&&t.parent?e(t.parent):t.userData.modelId;r.entityData={modelId:e(this.selectedObject),layerName:this.selectedObject.userData.layerName}}this.dispatchEvent("MouseClicked",r)}))}handleMouseClick(e){if(!this.enableSelection)return;this.clearSelection();let t=this.pickPosition(e);if(!t)return;let n=this.overlayRender.getDrawablesByPosition(t)[0];if(n)return this.selectedObject=n,this.selectedObject.selected=!0,void this.enableRender();let i=this.pickModel({x:e.x,y:e.y});i&&(this.selectedObject=null==i?void 0:i.object,this.setObjectHighlight(this.selectedObject))}setDefaultBackground(){this.setBackgroundColor(.0295,.0212,.0152)}loadModelAsync(e,t){return it(this,null,(function*(){return this.loadModel(e,t)}))}loadModel(e,t){return it(this,null,(function*(){let n=this.getUniqueModelId(e.modelId||e.src);this.spinner.increaseJobCount(),this.loaderHelper.setFont(this.fontManager),this.masterModelId||(this.masterModelId=n);let i=this.viewerCfg,r=yield this.loaderHelper.loadDxfData(e.src,e.modelId,t,void 0,{ignorePaperSpace:e.ignorePaperSpace,enableLocalCache:i.enableLocalCache,enableMerge:e.merge,encoding:e.encoding,overrideColor:e.overrideColor}).finally((()=>{this.loadingDxfCount--,0===this.loadingDxfCount&&this.fontManager&&this.fontManager.releaseFontData()})),a=r.threejsObject;if(e.matrix&&16===e.matrix.length){let t=new ht;t.elements=e.matrix,a.applyMatrix4(t)}let s=new jl({modelId:n,dxfData:r});this.addModel(s),this.spinner.decreaseJobCount(),this.dispatchEvent("ModelLoaded")}))}addModel(e){super.addModel(e);let t=e.modelId;if(e.dxfData){this.masterModelId===t?this.activateLayout(Ln.MODEL_LAYOUT_NAME):this.handleOverlayDxf(t);let n=e.getBBox(),i=new k;n.getCenter(i),this.cameraManager.adjustCameraByBbox(n);let r=this.getDxfUnits(e);this.masterModelId===t&&(this.units=r)}else{let t=e.getModelObject();this.activeLayoutName=Ln.MODEL_LAYOUT_NAME;let n=(new Nt).setFromObject(t);this.layoutInfos[this.activeLayoutName]={homeViewExtent:n,extent:n},t.matrixAutoUpdate=!1,this.scene.add(t);let i=n.max.z;i>this.camera.position.z&&(this.camera.position.z=i,this.camera.updateProjectionMatrix()),this.flyToObject(t)}this.updateGroundPlane()}getDxfUnits(e){return!e&&this.loadedModels.length>0&&(e=this.loadedModels.find((e=>this.masterModelId===e.modelId))),e?e.getUnits():"Unitless"}handleOverlayDxf(e){let t=this.loadedModels.find((t=>e===t.modelId));if(!t)return void fe.warn(`[Viewer] Can't find model for modelId '${e}'!`);t.switchTransformMs(Ln.MODEL_LAYOUT_NAME);let n=t.getLayoutLevelObject(Ln.MODEL_LAYOUT_NAME);n&&n.traverse((e=>{t.addSpatialFilterSection(e,t.dxfData)})),t.showLayoutObjects(Ln.MODEL_LAYOUT_NAME)}setObjectHighlight(e){this.loadedModels.forEach((t=>t.highlightObject(e))),this.enableRender()}setObjectUnHighlight(e){this.loadedModels.forEach((t=>t.unHighlightObject(e))),this.enableRender()}clearHighlight(){this.loadedModels.forEach((e=>e.clearHighlight())),this.enableRender()}clearSelection(){this.selectedObject instanceof an&&(this.setObjectUnHighlight(this.selectedObject),this.selectedObject=void 0),this.selectedObject instanceof Wi&&(this.selectedObject.selected=!1)}updateGroundPlane(){let e=this.getActiveLayoutInfo();if(!e.homeViewExtent)return;let t=e.homeViewExtent.clone(),n=[],i=(e,t,i)=>{n.push(new k(e,t,i))},r=t.getSize(new k),a=t.getCenter(new k);if(i(-r.x/2,-r.y/2,0),i(r.x/2,-r.y/2,0),i(r.x/2,r.y/2,0),i(-r.x/2,r.y/2,0),this.groundPlane)this.groundPlane.position.set(a.x,a.y,-r.z),this.groundPlane.geometry.setFromPoints(n),this.groundPlane.geometry.computeBoundingSphere(),this.groundPlane.geometry.computeBoundingBox();else{let e=new Ot;e.setFromPoints(n),e.setIndex([0,3,2,0,2,1]);let t=new cn({color:"#888",side:hr});this.groundPlane=new St(e,t),this.groundPlane.visible=!1,this.groundPlane.position.set(a.x,a.y,-r.z),this.groundPlane.scale.set(1e5,1e5,1),this.groundPlane.name="groundPlane",this.groundPlane.renderOrder=-1e3,this.scene.add(this.groundPlane)}this.groundPlane.updateMatrix(),this.groundPlane.updateMatrixWorld(!0)}getRaycastableObjects(){var e,t,n;let i=[],r=Date.now();if(this.activeLayoutName===Ln.MODEL_LAYOUT_NAME){if(this.raycastableObjects)return this.raycastableObjects;if(null!=(e=this.renderer)&&e.renderLists){let e=null==(t=this.renderer)?void 0:t.renderLists.get(this.scene,0);e&&(e.opaque.forEach((e=>{e.object&&e.object.geometry&&i.push(e.object)})),e.transparent.forEach((e=>{e.object&&e.object.geometry&&i.push(e.object)})))}_ve.multiplyMatrices(this.camera.projectionMatrix,this.camera.matrixWorldInverse),Tve.setFromProjectionMatrix(_ve);for(let e of this.loadedModels){let t=e.getModelObject().children.find((e=>e.name===this.activeLayoutName));if(t){let e=t.children.find((e=>e.name===Ln.SNAP_GROUP_NAME));null==e||e.traverse((e=>{if(rr.isLeafObject(e)){if(T4.makeEmpty(),T4.expandByObject(e),!Tve.intersectsBox(T4))return;i.push(e)}}))}}this.groundPlane&&i.push(this.groundPlane),fe.debug("[Viewer] getRaycastableObjectsByMouse() from modelSpace"),this.raycastableObjects=i}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)&&(i.push(t),e.add(t))}))}let r=this.getViewportByPoint(this.pickManager.getRaycaster().ray.origin);r&&r.associatedLeafObjectSet?(null==(n=r.associatedLeafObjectSet)||n.forEach((t=>{!e.has(t)&&(t.visible||t.userData.isSnapObject)&&(i.push(t),e.add(t))})),fe.debug("[Viewer] getRaycastableObjectsByMouse() from inside of viewport:",r.viewportId)):fe.debug("[Viewer] getRaycastableObjectsByMouse() from out of viewport"),this.groundPlane&&i.push(this.groundPlane)}return fe.debug(`[Viewer] getRaycastableObjectsByMouse() costs ${(Date.now()-r)/1e3} s`),i}getViewportByPoint(e){if(0===this.activeLayoutName.length||this.activeLayoutName===Ln.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.loadedModels.find((e=>this.masterModelId===e.modelId));if(!i)return;let r=i.getFilteredViewports(t);for(let a=0,s=r.length;a<s;a++){let e=r[a];if(!n(e.psBBox))return e}}pickPosition(e){var t;return null==(t=this.pickManager.pickObject(new _e(e.x,e.y),this.groundPlane))?void 0:t.point}activateLayout(e=Ln.MODEL_LAYOUT_NAME){if(this.activeLayoutName===e||!this.masterModelId)return;let t=this.loadedModels.find((e=>this.masterModelId===e.modelId));if(!t)return;let n=t.getLayoutByName(e);if(!n)return;let i=this.getActiveLayoutInfo();if(this.groundPlane){let e=this.getCurrentViewExtent(),t=this.camera.position.z;i.lastViewExtent=new Nt(new k(e.min.x,e.min.y,0),new k(e.max.x,e.max.y,t))}let r=(e=>{let t=this.layoutInfos[e];return!(null==t||!t.lastViewExtent)})(e);null==t||t.activateLayout(e,r),this.activeLayoutName=e;let a=t.getFilteredViewports(n);if(fe.debug("[Viewer] Active layout:",e,", viewports:",a),!r){let e=this.camera.position.z,t=0;a.forEach((e=>{var n;let i=null==(n=null==e?void 0:e.msToPsMatrix)?void 0:n.elements[14];i&&i>t&&(t=i)}));let n=this.cameraManager.getPosition();if(t>n.z+e){let i=Math.ceil(t+e);n.z=i,fe.info(`[Viewer] Changing camera's z value from ${n.z} to ${i}`),this.cameraManager.setCameraPosition(n)}}let s=this.getActiveLayoutInfo();if(s.lastViewExtent)this.zoomToBBox(s.lastViewExtent);else{s.extent=this.getBBox();let e=this.getLayoutExtentEx(n);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)&&(fe.warn(`[Viewer] Got wired bbox, max: ${e.max.toArray()}, min: ${e.min.toArray()}, going to use the calculated one...`),e=s.extent)}else fe.warn("[Viewer] Failed to get layout extent, going to use the calculated one..."),e=s.extent;s.homeViewExtent=e,this.zoomToBBox(e)}let o=t.getLayoutLevelObject(e);o&&this.setLayoutHidableObjectArray(o),this.enableRender()}getLayoutExtentEx(e){let t=this.loadedModels.find((e=>this.masterModelId===e.modelId));if(t)return e.layoutName===Ln.MODEL_LAYOUT_NAME?t.getModelSpaceExtent():t.getLayoutExtent(e)}getActiveLayoutInfo(){return this.getLayoutInfo(this.activeLayoutName)}getLayoutByName(e){let t,n=this.loadedModels.find((e=>this.masterModelId===e.modelId));if(!n)return;let i=n.getLayouts();for(let r of i)if(r.layoutName===e){t=r;break}return t}getLayoutNames(){let e=[],t=this.loadedModels.find((e=>this.masterModelId===e.modelId));return((null==t?void 0:t.getLayouts())||[]).forEach((t=>{e.push(t.layoutName)})),e}getLayoutInfo(e){return this.layoutInfos[e]||(this.layoutInfos[e]={}),this.layoutInfos[e]}goToHomeView(){let e=this.getActiveLayoutInfo();e.homeViewExtent?this.zoomToBBox(e.homeViewExtent):fe.error(`[Viewer] Failed to find extent for ${this.activeLayoutName}`)}zoomToBBox(e){let t=e.getCenter(OP),n=e.max.x-e.min.x,i=e.max.y-e.min.y,r=this.camera.right-this.camera.left,a=this.camera.top-this.camera.bottom,s=Math.min(r/n,a/i);s/=1.1,this.cameraManager.cameraControls.moveTo(t.x,t.y,t.z),this.cameraManager.cameraControls.zoomTo(s)}getCurrentViewExtent(){return{min:this.getHitResultByNdcCoordinate({x:-1,y:-1}),max:this.getHitResultByNdcCoordinate({x:1,y:1})}}getHitResultByNdcCoordinate(e){var t;return null==(t=this.pickManager.pickObjectByNdc(e,this.groundPlane))?void 0:t.point}getHitResult(e){let t=this.viewerContainer,n=Sn.getScreenCoordinateByEvent(e,t),i=Sn.screen2Ndc(n,this.camera,t);return this.getHitResultByNdcCoordinate(i)}getMarkupManager(){return this.markupManager}activateMarkup(e){this.inputManager&&(this.markupManager||(this.markupManager=new Wb(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,t,n,i){var r;null==(r=this.markupManager)||r.setLineColor([e,t,n,i])}getMarkupLineColor(){var e;return null==(e=this.markupManager)?void 0:e.getLineColor()}setMarkupFillColor(e,t,n,i){var r;null==(r=this.markupManager)||r.setFillColor([e,t,n,i])}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 Wb(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()}getActiveLayoutName(){return this.activeLayoutName}zoomIn(e=.01){this.cameraManager.cameraControls.zoom(e)}zoomOut(e=.01){this.cameraManager.cameraControls.zoom(-e)}getLayers(){let e=[];if(this.masterModelId){let t=this.loadedModels.find((e=>this.masterModelId===e.modelId)),n=null==t?void 0:t.layers;n&&e.push({modelId:this.masterModelId,layers:n})}for(let t of this.loadedModels){let n=t.modelId;if(n===this.masterModelId)continue;let i=t.layers;i&&e.push({modelId:n,layers:i})}return e}setModelVisibility(e,t){let n=this.loadedModels.find((t=>e===t.modelId));if(!n)throw new Error(`Failed to find model by modelId '${e}'!`);n.setVisible(t),this.enableRender()}setLayerVisibility(e,t,n){let i=this.camera;n=n||this.masterModelId;let r=this.loadedModels.find((e=>n===e.modelId));if(!r)throw new Error(`Failed to find layer by modelId '${n}'!`);r.setLayerVisible(e,t,this.enableHideVisuallySmallObjects,i.zoom),this.raycastableObjects=void 0,this.enableRender()}setLayerOpacity(e,t,n){n=n||this.masterModelId;let i=this.loadedModels.find((e=>n===e.modelId));if(!i)throw new Error(`Failed to find layer by modelId '${n}'!`);i.setLayerOpacity(e,t),this.enableRender()}setLayerColor(e,t,n){n=n||this.masterModelId;let i=this.loadedModels.find((e=>n===e.modelId));if(!i)throw new Error(`Failed to find layer by modelId '${n}'!`);this.clearSelection(),i.setLayerColor(e,t),this.enableRender()}resetLayerColor(e,t){t=t||this.masterModelId;let n=this.loadedModels.find((e=>t===e.modelId));if(!n)throw new Error(`Failed to find model by modelId '${t}'!`);this.clearSelection(),n.resetLayerColor(e),this.enableRender()}getVisiblePixelSize(e){let t=6.5*Un.smoothstep(e,1e4,3e4)+.5;return fe.debug("[Viewer] 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.cameraManager.update(0);let a=t.zoom;this.lastCameraZoom=a;let s=1;e.traverse((e=>{if(e.userData.isSnapObject||!rr.isLeafObject(e))return;let t=e.geometry;t.boundingBox||t.computeBoundingBox();let n=t.boundingBox.clone();if(!n||!Pt.isBoxValid(n))return;n.applyMatrix4(e.matrixWorld),n.getSize(OP);let i=Math.max(OP.x,OP.y),a=s/i;a<1/0?r.push({visibleMinZoom:a,object:e}):e instanceof Di?r.push({visibleMinZoom:s,object:e}):fe.warn("[Viewer] The size of bbox is 0 ! ",e)})),s=this.getVisiblePixelSize(r.length);let o=0;r.forEach((e=>{let t=e.visibleMinZoom*s;e.visibleMinZoom=t,e.object.userData.visibleMinZoom=t,t>a&&(e.object.visible=!1,o++)})),r.sort(((e,t)=>e.visibleMinZoom-t.visibleMinZoom)),fe.debug(`[Viewer] setLayoutHidableObjectArray cost: ${(Date.now()-n)/1e3}s, ${o} objects changed to hidden`)}updateRaycasterThreshold(){let e=3*this.getPixelSizeInWorldCoord(),t=this.getRaycaster().params;t.Line?t.Line.threshold=e:t.Line={threshold:e},t.Points?t.Points.threshold=e:t.Points={threshold:e}}updateHidableObjectsVisibility(){let e=this.camera,t=Date.now();this.cameraManager.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,fe.debug(`[Viewer] updateHidableObjectsVisibility cost: ${(Date.now()-t)/1e3}s, ${l}(out of ${i.length}) objects changed to ${r?"visible":"hidden"}`)}updateCameraZoomUniform(e){Ln.cameraZoomUniform.value=e*this.container.height/50}},FP=class{constructor(e){this.jobCount=0,this.viewer=new jf(e);let t=document.getElementById(e.containerId);this.container=(null==t?void 0:t.parentElement)||document.body,this.loadingProgressBar=new jC(this.container),this.loader=new Ln(this.loadingManager,{ignorePaperSpace:!0}),this.initSpinner()}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 it(this,null,(function*(){let t=Date.now();this.fontManager||(this.fontManager=new zm),yield this.fontManager.loadFonts(e),fe.info(`[DxfCompareHelper] Font file(s) load time in ${(Date.now()-t)/1e3}s`)}))}compare(e,t,n,i){return it(this,null,(function*(){var r,a,s,o,l;let{src:h,modelId:u}=e,{src:c}=t;this.viewer.masterModelId=u||h;let d=Date.now();if(this.increaseJobCount(),!this.fontManager)return Promise.reject("[DxfCompareHelper] Should set font first!");this.loader.setFont(this.fontManager),yield this.fontManager.getFontFromIndexeddb();let p=h+c,f=rd.t("ProgressBar.Comparing"),m=e=>{var t;null==(t=this.loadingProgressBar)||t.updateProgress(p,f,e),i&&i(new ProgressEvent("CompareProgress",{loaded:e,total:100}))},g=(e,t,n)=>{var r;let a=100*e.loaded/e.total;a=a*(n-t)/100+t,null==(r=this.loadingProgressBar)||r.updateProgress(p,f,a),i&&i(new ProgressEvent("CompareProgress",{loaded:a,total:100}))};Pt.printMemory("Before comparing"),null==(r=this.loadingProgressBar)||r.addProgressItem(p),m(0);let v=Date.now(),y=yield this.loader.parse(h,(e=>g(e,0,15))),x=yield this.loader.parse(c,(e=>g(e,15,30))),[b,_]=yield Promise.allSettled([y,x]);if("rejected"===b.status)return Promise.reject(`[DxfCompareHelper] Failed to parse ${h}`);if("rejected"===_.status)return Promise.reject(`[DxfCompareHelper] Failed to parse ${c}`);if(fe.info(`[DxfCompareHelper] loadFiles in ${(Date.now()-v)/1e3}s`),Ln.abortJobs)return Promise.reject("[DxfCompareHelper] compare loadFile aborted");let w=b.value,S=_.value;v=Date.now();let M=yield new js(w,S,n).compare((e=>g(e,30,60)));if(fe.info(`[DxfCompareHelper] Compared in ${(Date.now()-v)/1e3}s`),fe.debug("[DxfCompareHelper] Compared results:",M),Ln.abortJobs)return Promise.reject("[DxfCompareHelper] compare change aborted");Pt.printMemory("After getting the comparison results"),v=Date.now(),yield this.loader.loadEntitiesForCompare(w,S,M,!0,(e=>g(e,60,95))),Pt.printMemory("After Creating threejs objects based on comparison result"),null==(a=this.fontManager)||a.releaseFontData(),this.changes=M,fe.info(`[DxfCompareHelper] Creates threejs objects based on comparison result in ${(Date.now()-v)/1e3}s`);let E=w,T=S;if(this.decreaseJobCount(),Object.keys(M).length||fe.info("[DxfCompareHelper] No change found"),0===(null==(s=E.threejsObject)?void 0:s.children.length)&&0===(null==(o=T.threejsObject)?void 0:o.children.length)){let e=`[DxfCompareHelper] Nothing was loaded from ${h} and ${c}`;return fe.warn(e),Promise.reject(e)}let A=E.threejsObject,C=T.threejsObject;return A.name=h,C.name=c,v=Date.now(),this.viewer.addModel(new jl({modelId:e.modelId||e.src,dxfData:E})),this.viewer.flyToObject(A),Pt.printMemory("After adding first loaded Model to scene"),m(95),this.viewer.addModel(new jl({modelId:t.modelId||t.src,dxfData:T})),Pt.printMemory("After adding second loaded Model to scene"),fe.info(`[DxfCompareHelper] Added compared objects to scene in ${(Date.now()-v)/1e3}s`),fe.info(`[DxfCompareHelper] The comparison between ${h}' and '${c}' is completed in ${(Date.now()-d)/1e3}s !`),m(100),null==(l=this.loadingProgressBar)||l.delayRemoveProgressItem(p),Promise.resolve()}))}getChanges(){return this.changes}zoomToChange(e){if(this.changes){let t=this.changes[e];if(!t)return;let n=t.box;n&&this.viewer.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)}},wve=class extends FP{constructor(e,t){super(e),this.syncCamera=!1,this.syncCameraControls=(e,t,n)=>{let i=new k,r=new k,a=new k;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),t.dispatchEvent({type:"control"})},this.viewer2=new jf(t),this.initSyncCameraEvent()}initSyncCameraEvent(){let e=this.viewer.getCameraManager().cameraControls,t=this.viewer2.getCameraManager().cameraControls,n=!1;e.addEventListener("control",(()=>{n=!1})),e.addEventListener("update",(()=>{!this.syncCamera||n||this.syncCameraControls(e,t,this.viewer.camera.zoom)})),t.addEventListener("control",(()=>{n=!0})),t.addEventListener("update",(()=>{!this.syncCamera||!n||this.syncCameraControls(t,e,this.viewer2.camera.zoom)}))}enableSyncCamera(e){if(this.syncCamera=e,e){let e=this.viewer.getCameraManager().cameraControls,t=this.viewer2.getCameraManager().cameraControls;this.syncCameraControls(e,t,this.viewer.camera.zoom)}}compare(e,t,n,i){return it(this,null,(function*(){var r,a,s,o,l;let{src:h,modelId:u}=e,{src:c,modelId:d}=t;this.viewer.masterModelId=u||h,this.viewer2.masterModelId=d||c;let p=Date.now();if(this.increaseJobCount(),!this.fontManager)return Promise.reject("[DxfCompareHelper] Should set font first!");this.loader.setFont(this.fontManager),yield this.fontManager.getFontFromIndexeddb();let f=h+c,m=rd.t("ProgressBar.Comparing"),g=e=>{var t;null==(t=this.loadingProgressBar)||t.updateProgress(f,m,e),i&&i(new ProgressEvent("CompareProgress",{loaded:e,total:100}))},v=(e,t,n)=>{var r;let a=100*e.loaded/e.total;a=a*(n-t)/100+t,null==(r=this.loadingProgressBar)||r.updateProgress(f,m,a),i&&i(new ProgressEvent("CompareProgress",{loaded:a,total:100}))};Pt.printMemory("Before comparing"),null==(r=this.loadingProgressBar)||r.addProgressItem(f),g(0);let y=Date.now(),x=yield this.loader.parse(h,(e=>v(e,0,15))),b=yield this.loader.parse(c,(e=>v(e,15,30))),[_,w]=yield Promise.allSettled([x,b]);if("rejected"===_.status)return Promise.reject(`[DxfCompareHelper] Failed to parse ${h}`);if("rejected"===w.status)return Promise.reject(`[DxfCompareHelper] Failed to parse ${c}`);if(fe.info(`[DxfCompareHelper] loadFiles in ${(Date.now()-y)/1e3}s`),Ln.abortJobs)return Promise.reject("[DxfCompareHelper] compare loadFile aborted");let S=_.value,M=w.value;y=Date.now();let E=yield new js(S,M,n).compare((e=>v(e,30,60)));if(fe.info(`[DxfCompareHelper] Compared in ${(Date.now()-y)/1e3}s`),fe.debug("Compared results:",E),Ln.abortJobs)return Promise.reject("[DxfCompareHelper] compare change aborted");Pt.printMemory("After getting the comparison results"),y=Date.now(),yield this.loader.loadEntitiesForCompare(S,M,E,!1,(e=>v(e,60,95))),Pt.printMemory("After Creating threejs objects based on comparison result"),null==(a=this.fontManager)||a.releaseFontData(),this.changes=E,fe.info(`[DxfCompareHelper] Creates threejs objects based on comparison result in ${(Date.now()-y)/1e3}s`);let T=S,A=M;if(this.decreaseJobCount(),Object.keys(E).length||fe.info("[DxfCompareHelper] No change found"),0===(null==(s=T.threejsObject)?void 0:s.children.length)&&0===(null==(o=A.threejsObject)?void 0:o.children.length)){let e=`[DxfCompareHelper] Nothing was loaded from ${h} and ${c}`;return fe.warn(e),Promise.reject(e)}let C=T.threejsObject,P=A.threejsObject;return C.name=h,P.name=c,y=Date.now(),this.viewer.addModel(new jl({modelId:e.modelId||e.src,dxfData:T})),Pt.printMemory("After adding first loaded Model to scene"),g(95),this.viewer2.addModel(new jl({modelId:t.modelId||t.src,dxfData:A})),Pt.printMemory("After adding second loaded Model to scene"),fe.info(`[DxfCompareHelper] Added compared objects to scene in ${(Date.now()-y)/1e3}s`),fe.info(`[DxfCompareHelper] The comparison between ${h}' and '${c}' is completed in ${(Date.now()-p)/1e3}s !`),g(100),null==(l=this.loadingProgressBar)||l.delayRemoveProgressItem(f),Promise.resolve()}))}zoomToChange(e){if(this.changes){let t=this.changes[e];if(!t)return;let n=t.box;n&&(this.viewer.zoomToBBox(n.clone().expandByScalar(1.2)),this.viewer2.zoomToBBox(n.clone().expandByScalar(1.2)))}}},Qm=ss(Sve(),1),ad=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 ad.offsetEdge(this.current,this.next,e,t)}inverseOffset(e,t){return ad.offsetEdge(this.next,this.current,e,t)}inverse(){return new ad(this.next,this.current)}static offsetEdge(e,t,n,i){return new ad([e[0]+n,e[1]+i],[t[0]+n,t[1]+i])}},n_=Array.isArray,Mve=(e,t)=>e[0]===t[0]&&e[1]===t[1],M4=e=>Array.isArray(e)&&e.length,Rve=(e,t=0,n=!1)=>{let i,r;if(M4(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++)Rve(e[i],t+1,i>0);if(0===t&&M4(e)&&M4(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},Ave=class{constructor(e,t=5){if(this.distance=0,this.arcSegments=t,!n_(e))throw new Error("Offset requires at least one coodinate to work with");this.edges=[],n_(e)&&"number"==typeof e[0]?this.vertices=e:(this.vertices=Rve(e),this.processContour(this.vertices,this.edges))}processContour(e,t){let n,i;if(n_(e[0])&&"number"==typeof e[0][0])for(i=e.length,Mve(e[0],e[i-1])&&(i-=1),n=0;n<i;n++)t.push(new ad(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 u=l>h?l-h:l+o-h,c=(s?-u:o-u)/a;e.push(i);for(let d=1;d<a;++d)u=l+c*d,e.push([t[0]+Math.cos(u)*n,t[1]+Math.sin(u)*n]);return e.push(r),e}setDistance(e){return this.distance=e,this}ensureLastPoint(e){return Mve(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,Qm.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,Qm.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(n_(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,Qm.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(n_(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,Qm.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,Qm.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)]]}},r_=new k,i_=new k,Cve=new In,NP=class extends zr{constructor(e,t=1,n=16711680){let i=new Ot,r=e.geometry.attributes.normal.count,a=new Bt(2*r*3,3);i.setAttribute("position",a),super(i,new zn({color:n,toneMapped:!1})),this.object=e,this.size=t,this.type="VertexNormalsHelper",this.matrixAutoUpdate=!1,this.update()}update(){this.object.updateMatrixWorld(!0),Cve.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++)r_.fromBufferAttribute(i,n).applyMatrix4(e),i_.fromBufferAttribute(r,n),i_.applyMatrix3(Cve).normalize().multiplyScalar(this.size).add(r_),t.setXYZ(a,r_.x,r_.y,r_.z),a+=1,t.setXYZ(a,i_.x,i_.y,i_.z),a+=1}t.needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}},xs=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(){}},wvt=new xi(-1,1,1,-1,0,1),A4=new Ot;A4.setAttribute("position",new Bt([-1,3,0,-1,-1,0,3,-1,0],3)),A4.setAttribute("uv",new Bt([0,2,0,0,2,0],2));var _a=class{constructor(e){this._mesh=new St(A4,e)}dispose(){this._mesh.geometry.dispose()}render(e){e.render(this._mesh,wvt)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}},R4={name:"ConvolutionShader",defines:{KERNEL_SIZE_FLOAT:"25.0",KERNEL_SIZE_INT:"25"},uniforms:{tDiffuse:{value:null},uImageIncrement:{value:new _e(.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]=Svt(a-n,e),r+=i[a];for(let a=0;a<t;++a)i[a]/=r;return i}};function Svt(e,t){return Math.exp(-e*e/(2*t*t))}var Yu=class extends xs{constructor(e=1,t=25,n=4){super(),this.renderTargetX=new er(1,1,{type:Tr}),this.renderTargetX.texture.name="BloomPass.x",this.renderTargetY=new er(1,1,{type:Tr}),this.renderTargetY.texture.name="BloomPass.y",this.combineUniforms=Ti.clone(BP.uniforms),this.combineUniforms.strength.value=e,this.materialCombine=new hn({name:BP.name,uniforms:this.combineUniforms,vertexShader:BP.vertexShader,fragmentShader:BP.fragmentShader,blending:_c,transparent:!0});let i=R4;this.convolutionUniforms=Ti.clone(i.uniforms),this.convolutionUniforms.uImageIncrement.value=Yu.blurX,this.convolutionUniforms.cKernel.value=R4.buildKernel(n),this.materialConvolution=new hn({name:i.name,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 _a(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=Yu.blurX,e.setRenderTarget(this.renderTargetX),e.clear(),this.fsQuad.render(e),this.convolutionUniforms.tDiffuse.value=this.renderTargetX.texture,this.convolutionUniforms.uImageIncrement.value=Yu.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()}},BP={name:"CombineShader",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}"};Yu.blurX=new _e(.001953125,0),Yu.blurY=new _e(0,.001953125);var Ta={name:"CopyShader",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\tvec4 texel = texture2D( tDiffuse, vUv );\n\t\t\tgl_FragColor = opacity * texel;\n\n\n\t\t}"},b1=class extends xs{constructor(e,t){super(),this.textureID=void 0!==t?t:"tDiffuse",e instanceof hn?(this.uniforms=e.uniforms,this.material=e):e&&(this.uniforms=Ti.clone(e.uniforms),this.material=new hn({name:void 0!==e.name?e.name:"unspecified",defines:Object.assign({},e.defines),uniforms:this.uniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader})),this.fsQuad=new _a(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()}},s_=class extends xs{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.color.setMask(!0),s.buffers.depth.setMask(!0),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)}},UP=class extends xs{constructor(){super(),this.needsSwap=!1}render(e){e.state.buffers.stencil.setLocked(!1),e.state.buffers.stencil.setTest(!1)}},HP=class{constructor(e,t){if(this.renderer=e,this._pixelRatio=e.getPixelRatio(),void 0===t){let n=e.getSize(new _e);this._width=n.width,this._height=n.height,(t=new er(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:Tr})).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 b1(Ta),this.copyPass.material.blending=Qr,this.clock=new Pl}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!==s_&&(t instanceof s_?n=!0:t instanceof UP&&(n=!1))}}this.renderer.setRenderTarget(t)}reset(e){if(void 0===e){let t=this.renderer.getSize(new _e);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()}},Wc=class extends xs{constructor(e,t,n,i){super(),this.renderScene=t,this.renderCamera=n,this.selectedObjects=void 0!==i?i:[],this.visibleEdgeColor=new ct(1,1,1),this.hiddenEdgeColor=new ct(.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 _e(e.x,e.y):new _e(256,256);let r=Math.round(this.resolution.x/this.downSampleRatio),a=Math.round(this.resolution.y/this.downSampleRatio);this.renderTargetMaskBuffer=new er(this.resolution.x,this.resolution.y),this.renderTargetMaskBuffer.texture.name="OutlinePass.mask",this.renderTargetMaskBuffer.texture.generateMipmaps=!1,this.depthMaterial=new wc,this.depthMaterial.side=hr,this.depthMaterial.depthPacking=vv,this.depthMaterial.blending=Qr,this.prepareMaskMaterial=this.getPrepareMaskMaterial(),this.prepareMaskMaterial.side=hr,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 er(this.resolution.x,this.resolution.y,{type:Tr}),this.renderTargetDepthBuffer.texture.name="OutlinePass.depth",this.renderTargetDepthBuffer.texture.generateMipmaps=!1,this.renderTargetMaskDownSampleBuffer=new er(r,a,{type:Tr}),this.renderTargetMaskDownSampleBuffer.texture.name="OutlinePass.depthDownSample",this.renderTargetMaskDownSampleBuffer.texture.generateMipmaps=!1,this.renderTargetBlurBuffer1=new er(r,a,{type:Tr}),this.renderTargetBlurBuffer1.texture.name="OutlinePass.blur1",this.renderTargetBlurBuffer1.texture.generateMipmaps=!1,this.renderTargetBlurBuffer2=new er(Math.round(r/2),Math.round(a/2),{type:Tr}),this.renderTargetBlurBuffer2.texture.name="OutlinePass.blur2",this.renderTargetBlurBuffer2.texture.generateMipmaps=!1,this.edgeDetectionMaterial=this.getEdgeDetectionMaterial(),this.renderTargetEdgeBuffer1=new er(r,a,{type:Tr}),this.renderTargetEdgeBuffer1.texture.name="OutlinePass.edge1",this.renderTargetEdgeBuffer1.texture.generateMipmaps=!1,this.renderTargetEdgeBuffer2=new er(Math.round(r/2),Math.round(a/2),{type:Tr}),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=Ta;this.copyUniforms=Ti.clone(s.uniforms),this.materialCopy=new hn({uniforms:this.copyUniforms,vertexShader:s.vertexShader,fragmentShader:s.fragmentShader,blending:Qr,depthTest:!1,depthWrite:!1}),this.enabled=!0,this.needsSwap=!1,this._oldClearColor=new ct,this.oldClearAlpha=1,this.fsQuad=new _a(null),this.tempPulseColor1=new ct,this.tempPulseColor2=new ct,this.textureMatrix=new ht}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=Wc.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=Wc.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=Wc.BlurDirectionX,e.setRenderTarget(this.renderTargetBlurBuffer2),e.clear(),this.fsQuad.render(e),this.separableBlurMaterial2.uniforms.colorTexture.value=this.renderTargetBlurBuffer2.texture,this.separableBlurMaterial2.uniforms.direction.value=Wc.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 hn({uniforms:{depthTexture:{value:null},cameraNearFar:{value:new _e(.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 hn({uniforms:{maskTexture:{value:null},texSize:{value:new _e(.5,.5)},visibleEdgeColor:{value:new k(1,1,1)},hiddenEdgeColor:{value:new k(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 hn({defines:{MAX_RADIUS:e},uniforms:{colorTexture:{value:null},texSize:{value:new _e(.5,.5)},direction:{value:new _e(.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 hn({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:_c,depthTest:!1,depthWrite:!1,transparent:!0})}};Wc.BlurDirectionX=new _e(1,0),Wc.BlurDirectionY=new _e(0,1);var VP=class extends xs{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 ct}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}},a_={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 _e(512,512)},cameraNear:{value:1},cameraFar:{value:100},cameraProjectionMatrix:{value:new ht},cameraInverseProjectionMatrix:{value:new ht},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}"},od={defines:{KERNEL_RADIUS:4,DEPTH_PACKING:1,PERSPECTIVE_CAMERA:1},uniforms:{tDiffuse:{value:null},size:{value:new _e(512,512)},sampleUvOffsets:{value:[new _e(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}"},o_={createSampleWeights:function(e,t){let n=[];for(let i=0;i<=e;i++)n.push(Mvt(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=o_.createSampleOffsets(t,i),e.uniforms.sampleWeights.value=o_.createSampleWeights(t,n),e.needsUpdate=!0}};function Mvt(e,t){return Math.exp(-e*e/(t*t*2))/(Math.sqrt(2*Math.PI)*t)}var zP={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}"},l_=class extends xs{constructor(e,t,n=!1,i=!1,r=new _e(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 ct,this._oldClearColor=new ct,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 _e(r.x,r.y),this.saoRenderTarget=new er(this.resolution.x,this.resolution.y,{type:Tr}),this.blurIntermediateRenderTarget=this.saoRenderTarget.clone(),this.beautyRenderTarget=this.saoRenderTarget.clone(),this.normalRenderTarget=new er(this.resolution.x,this.resolution.y,{minFilter:Jr,magFilter:Jr,type:Tr}),this.depthRenderTarget=this.normalRenderTarget.clone(),this.supportsDepthTextureExtension&&(a=new Qd,a.type=mv,this.beautyRenderTarget.depthTexture=a,this.beautyRenderTarget.depthBuffer=!0),this.depthMaterial=new wc,this.depthMaterial.depthPacking=vv,this.depthMaterial.blending=Qr,this.normalMaterial=new tf,this.normalMaterial.blending=Qr,this.saoMaterial=new hn({defines:Object.assign({},a_.defines),fragmentShader:a_.fragmentShader,vertexShader:a_.vertexShader,uniforms:Ti.clone(a_.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=Qr,this.vBlurMaterial=new hn({uniforms:Ti.clone(od.uniforms),defines:Object.assign({},od.defines),vertexShader:od.vertexShader,fragmentShader:od.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=Qr,this.hBlurMaterial=new hn({uniforms:Ti.clone(od.uniforms),defines:Object.assign({},od.defines),vertexShader:od.vertexShader,fragmentShader:od.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=Qr,this.materialCopy=new hn({uniforms:Ti.clone(Ta.uniforms),vertexShader:Ta.vertexShader,fragmentShader:Ta.fragmentShader,blending:Qr}),this.materialCopy.transparent=!0,this.materialCopy.depthTest=!1,this.materialCopy.depthWrite=!1,this.materialCopy.blending=xm,this.materialCopy.blendSrc=fv,this.materialCopy.blendDst=rf,this.materialCopy.blendEquation=Vo,this.materialCopy.blendSrcAlpha=dv,this.materialCopy.blendDstAlpha=rf,this.materialCopy.blendEquationAlpha=Vo,this.depthCopy=new hn({uniforms:Ti.clone(zP.uniforms),vertexShader:zP.vertexShader,fragmentShader:zP.fragmentShader,blending:Qr}),this.fsQuad=new _a(null)}render(e,t,n){if(this.renderToScreen&&(this.materialCopy.blending=Qr,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)&&(o_.configure(this.vBlurMaterial,this.params.saoBlurRadius,this.params.saoBlurStdDev,new _e(0,1)),o_.configure(this.hBlurMaterial,this.params.saoBlurRadius,this.params.saoBlurStdDev,new _e(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=xm:a.blending=Qr,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()}};l_.OUTPUT={Beauty:1,Default:0,SAO:2,Depth:3,Normal:4};var GP=class extends xs{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 ct;let r=Ta;this.copyUniforms=Ti.clone(r.uniforms),this.copyMaterial=new hn({uniforms:this.copyUniforms,vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,transparent:!0,depthTest:!1,depthWrite:!1,premultipliedAlpha:!0,blending:_c}),this.fsQuad=new _a(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 er(n.width,n.height,{type:Tr}),this.sampleRenderTarget.texture.name="SSAARenderPass.sample");let i=Avt[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)}},Avt=[[[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]]],qP=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),u=(3-Math.sqrt(3))/6,c=(l+h)*u,d=e-(l-c),p=t-(h-c);d>p?(a=1,s=0):(a=0,s=1);let f=d-a+u,m=p-s+u,g=d-1+2*u,v=p-1+2*u,y=255&l,x=255&h,b=this.perm[y+this.perm[x]]%12,_=this.perm[y+a+this.perm[x+s]]%12,w=this.perm[y+1+this.perm[x+1]]%12,S=.5-d*d-p*p;S<0?n=0:(S*=S,n=S*S*this.dot(this.grad3[b],d,p));let M=.5-f*f-m*m;M<0?i=0:(M*=M,i=M*M*this.dot(this.grad3[_],f,m));let E=.5-g*g-v*v;return E<0?r=0:(E*=E,r=E*E*this.dot(this.grad3[w],g,v)),70*(n+i+r)}noise3d(e,t,n){let i,r,a,s,o,l,h,u,c,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),b=t-(m-y),_=n-(g-y);x>=b?b>=_?(o=1,l=0,h=0,u=1,c=1,d=0):x>=_?(o=1,l=0,h=0,u=1,c=0,d=1):(o=0,l=0,h=1,u=1,c=0,d=1):b<_?(o=0,l=0,h=1,u=0,c=1,d=1):x<_?(o=0,l=1,h=0,u=0,c=1,d=1):(o=0,l=1,h=0,u=1,c=1,d=0);let w=x-o+v,S=b-l+v,M=_-h+v,E=x-u+2*v,T=b-c+2*v,A=_-d+2*v,C=x-1+.5,P=b-1+.5,R=_-1+.5,L=255&f,I=255&m,k=255&g,O=this.perm[L+this.perm[I+this.perm[k]]]%12,D=this.perm[L+o+this.perm[I+l+this.perm[k+h]]]%12,N=this.perm[L+u+this.perm[I+c+this.perm[k+d]]]%12,U=this.perm[L+1+this.perm[I+1+this.perm[k+1]]]%12,F=.6-x*x-b*b-_*_;F<0?i=0:(F*=F,i=F*F*this.dot3(this.grad3[O],x,b,_));let B=.6-w*w-S*S-M*M;B<0?r=0:(B*=B,r=B*B*this.dot3(this.grad3[D],w,S,M));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 H=.6-C*C-P*P-R*R;return H<0?s=0:(H*=H,s=H*H*this.dot3(this.grad3[U],C,P,R)),32*(i+r+a+s)}noise4d(e,t,n,i){let r,a,s,o,l,h=this.grad4,u=this.simplex,c=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,b=e-(m-x),_=t-(g-x),w=n-(v-x),S=i-(y-x),M=(b>_?32:0)+(b>w?16:0)+(_>w?8:0)+(b>S?4:0)+(_>S?2:0)+(w>S?1:0),E=u[M][0]>=3?1:0,T=u[M][1]>=3?1:0,A=u[M][2]>=3?1:0,C=u[M][3]>=3?1:0,P=u[M][0]>=2?1:0,R=u[M][1]>=2?1:0,L=u[M][2]>=2?1:0,I=u[M][3]>=2?1:0,k=u[M][0]>=1?1:0,O=u[M][1]>=1?1:0,D=u[M][2]>=1?1:0,N=u[M][3]>=1?1:0,U=b-E+p,F=_-T+p,B=w-A+p,z=S-C+p,H=b-P+2*p,V=_-R+2*p,j=w-L+2*p,G=S-I+2*p,W=b-k+3*p,X=_-O+3*p,Y=w-D+3*p,q=S-N+3*p,J=b-1+4*p,Z=_-1+4*p,K=w-1+4*p,$=S-1+4*p,Q=255&m,ee=255&g,te=255&v,ne=255&y,ie=c[Q+c[ee+c[te+c[ne]]]]%32,re=c[Q+E+c[ee+T+c[te+A+c[ne+C]]]]%32,ae=c[Q+P+c[ee+R+c[te+L+c[ne+I]]]]%32,se=c[Q+k+c[ee+O+c[te+D+c[ne+N]]]]%32,oe=c[Q+1+c[ee+1+c[te+1+c[ne+1]]]]%32,le=.6-b*b-_*_-w*w-S*S;le<0?r=0:(le*=le,r=le*le*this.dot4(h[ie],b,_,w,S));let he=.6-U*U-F*F-B*B-z*z;he<0?a=0:(he*=he,a=he*he*this.dot4(h[re],U,F,B,z));let ue=.6-H*H-V*V-j*j-G*G;ue<0?s=0:(ue*=ue,s=ue*ue*this.dot4(h[ae],H,V,j,G));let ce=.6-W*W-X*X-Y*Y-q*q;ce<0?o=0:(ce*=ce,o=ce*ce*this.dot4(h[se],W,X,Y,q));let de=.6-J*J-Z*Z-K*K-$*$;return de<0?l=0:(de*=de,l=de*de*this.dot4(h[oe],J,Z,K,$)),27*(r+a+s+o+l)}},c_={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 _e},cameraProjectionMatrix:{value:new ht},cameraInverseProjectionMatrix:{value:new ht},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}"},u_={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}"},h_={uniforms:{tDiffuse:{value:null},resolution:{value:new _e}},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}"},Jl=class extends xs{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 Qd;r.format=Nh,r.type=yu,this.beautyRenderTarget=new er(this.width,this.height,{type:Tr}),this.normalRenderTarget=new er(this.width,this.height,{minFilter:Jr,magFilter:Jr,type:Tr,depthTexture:r}),this.ssaoRenderTarget=new er(this.width,this.height,{type:Tr}),this.blurRenderTarget=this.ssaoRenderTarget.clone(),this.ssaoMaterial=new hn({defines:Object.assign({},c_.defines),uniforms:Ti.clone(c_.uniforms),vertexShader:c_.vertexShader,fragmentShader:c_.fragmentShader,blending:Qr}),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 tf,this.normalMaterial.blending=Qr,this.blurMaterial=new hn({defines:Object.assign({},h_.defines),uniforms:Ti.clone(h_.uniforms),vertexShader:h_.vertexShader,fragmentShader:h_.fragmentShader}),this.blurMaterial.uniforms.tDiffuse.value=this.ssaoRenderTarget.texture,this.blurMaterial.uniforms.resolution.value.set(this.width,this.height),this.depthRenderMaterial=new hn({defines:Object.assign({},u_.defines),uniforms:Ti.clone(u_.uniforms),vertexShader:u_.vertexShader,fragmentShader:u_.fragmentShader,blending:Qr}),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 hn({uniforms:Ti.clone(Ta.uniforms),vertexShader:Ta.vertexShader,fragmentShader:Ta.fragmentShader,transparent:!0,depthTest:!1,depthWrite:!1,blendSrc:fv,blendDst:rf,blendEquation:Vo,blendSrcAlpha:dv,blendDstAlpha:rf,blendEquationAlpha:Vo}),this.fsQuad=new _a(null),this.originalClearColor=new ct}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=OA),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 Jl.OUTPUT.SSAO:this.copyMaterial.uniforms.tDiffuse.value=this.ssaoRenderTarget.texture,this.copyMaterial.blending=Qr,this.renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case Jl.OUTPUT.Blur:this.copyMaterial.uniforms.tDiffuse.value=this.blurRenderTarget.texture,this.copyMaterial.blending=Qr,this.renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case Jl.OUTPUT.Beauty:this.copyMaterial.uniforms.tDiffuse.value=this.beautyRenderTarget.texture,this.copyMaterial.blending=Qr,this.renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case Jl.OUTPUT.Depth:this.renderPass(e,this.depthRenderMaterial,this.renderToScreen?null:t);break;case Jl.OUTPUT.Normal:this.copyMaterial.uniforms.tDiffuse.value=this.normalRenderTarget.texture,this.copyMaterial.blending=Qr,this.renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case Jl.OUTPUT.Default:this.copyMaterial.uniforms.tDiffuse.value=this.beautyRenderTarget.texture,this.copyMaterial.blending=Qr,this.renderPass(e,this.copyMaterial,this.renderToScreen?null:t),this.copyMaterial.uniforms.tDiffuse.value=this.blurRenderTarget.texture,this.copyMaterial.blending=xm,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 k;i.x=2*Math.random()-1,i.y=2*Math.random()-1,i.z=Math.random(),i.normalize();let r=n/e;r=Un.lerp(.1,1,r*r),i.multiplyScalar(r),t.push(i)}}generateRandomKernelRotations(){let e=new qP,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 _l(t,4,4,kA,pa),this.noiseTexture.wrapS=Ii,this.noiseTexture.wrapT=Ii,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()}};Jl.OUTPUT={Default:0,SSAO:1,Blur:2,Beauty:3,Depth:4,Normal:5};var Pve={shaderID:"luminosityHighPass",uniforms:{tDiffuse:{value:null},luminosityThreshold:{value:1},smoothWidth:{value:1},defaultColor:{value:new ct(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}"},ld=class extends xs{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 _e(e.x,e.y):new _e(256,256),this.clearColor=new ct(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 er(r,a,{type:Tr}),this.renderTargetBright.texture.name="UnrealBloomPass.bright",this.renderTargetBright.texture.generateMipmaps=!1;for(let h=0;h<this.nMips;h++){let e=new er(r,a,{type:Tr});e.texture.name="UnrealBloomPass.h"+h,e.texture.generateMipmaps=!1,this.renderTargetsHorizontal.push(e);let t=new er(r,a,{type:Tr});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=Pve;this.highPassUniforms=Ti.clone(s.uniforms),this.highPassUniforms.luminosityThreshold.value=i,this.highPassUniforms.smoothWidth.value=.01,this.materialHighPassFilter=new hn({uniforms:this.highPassUniforms,vertexShader:s.vertexShader,fragmentShader:s.fragmentShader}),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.invSize.value=new _e(1/r,1/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.uniforms.bloomFactors.value=[1,.8,.6,.4,.2],this.bloomTintColors=[new k(1,1,1),new k(1,1,1),new k(1,1,1),new k(1,1,1),new k(1,1,1)],this.compositeMaterial.uniforms.bloomTintColors.value=this.bloomTintColors;let l=Ta;this.copyUniforms=Ti.clone(l.uniforms),this.blendMaterial=new hn({uniforms:this.copyUniforms,vertexShader:l.vertexShader,fragmentShader:l.fragmentShader,blending:_c,depthTest:!1,depthWrite:!1,transparent:!0}),this.enabled=!0,this.needsSwap=!1,this._oldClearColor=new ct,this.oldClearAlpha=1,this.basic=new cn,this.fsQuad=new _a(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.blendMaterial.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.invSize.value=new _e(1/n,1/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=ld.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=ld.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.blendMaterial,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){let t=[];for(let n=0;n<e;n++)t.push(.39894*Math.exp(-.5*n*n/(e*e))/e);return new hn({defines:{KERNEL_RADIUS:e},uniforms:{colorTexture:{value:null},invSize:{value:new _e(.5,.5)},direction:{value:new _e(.5,.5)},gaussianCoefficients:{value:t}},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 invSize;\n\t\t\t\tuniform vec2 direction;\n\t\t\t\tuniform float gaussianCoefficients[KERNEL_RADIUS];\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tfloat weightSum = gaussianCoefficients[0];\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 = gaussianCoefficients[i];\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 hn({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}"})}};ld.BlurDirectionX=new _e(1,0),ld.BlurDirectionY=new _e(0,1);var Ive={uniforms:{tDiffuse:{value:null},resolution:{value:new _e(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"},WP=class{constructor(e){this.composerEnabled=!0,this.viewer=e,this.composer=new HP(this.viewer.renderer),this.viewer.addEventListener("AfterRender",(()=>this.render()))}get enabled(){return this.composerEnabled}set enabled(e){this.composerEnabled=e}get renderPassEnabled(){var e;return!(null==(e=this.renderPass)||!e.enabled)}set renderPassEnabled(e){let t=this.viewer.scene,n=this.viewer.camera,{width:i,height:r}=this.viewer.container;if(this.composer){if(e&&!this.renderPass){let e=new VP(t,n);e.setSize(i,r),this.composer.addPass(e),this.renderPass=e}this.renderPass&&(this.renderPass.enabled=e),this.viewer.enableRender()}}get fxaaPassEnabled(){var e;return!(null==(e=this.effectFxaaPass)||!e.enabled)}set fxaaPassEnabled(e){if(!this.composer)return;let{width:t,height:n}=this.viewer.container;if(e&&!this.effectFxaaPass){let e=new b1(Ive);e.uniforms.resolution.value.set(1/t,1/n),e.renderToScreen=!0,e.setSize(t,n),this.composer.addPass(e),this.effectFxaaPass=e}this.effectFxaaPass&&(this.effectFxaaPass.enabled=e),this.viewer.enableRender()}get saoPassEnabled(){var e;return!(null==(e=this.saoPass)||!e.enabled)}set saoPassEnabled(e){let{width:t,height:n}=this.viewer.container,i=this.viewer.scene,r=this.viewer.camera;if(this.composer){if(e&&!this.saoPass){let e=new l_(i,r,!1,!0,new _e(1/t,1/n));e.setSize(t,n),e.params.output=0,e.params.saoBias=.5,e.params.saoIntensity=3e-4,e.params.saoScale=8,e.params.saoKernelRadius=40,e.params.saoMinResolution=0,this.composer.addPass(e),this.saoPass=e}this.saoPass&&(this.saoPass.enabled=e),this.viewer.enableRender()}}get ssaoPassEnabled(){var e;return!(null==(e=this.ssaoPass)||!e.enabled)}set ssaoPassEnabled(e){let t=this.viewer.scene,n=this.viewer.camera,{width:i,height:r}=this.viewer.container;if(this.composer){if(e&&!this.ssaoPass){let e=new Jl(t,n,i,r);e.kernelRadius=16,e.minDistance=1e-4,e.maxDistance=.3,this.composer.addPass(e),this.ssaoPass=e}this.ssaoPass&&(this.ssaoPass.enabled=e),this.viewer.enableRender()}}get outlinePassEnabled(){var e;return!(null==(e=this.outlinePass)||!e.enabled)}set outlinePassEnabled(e){let t=this.viewer.scene,n=this.viewer.camera,{width:i,height:r}=this.viewer.container;if(this.composer){if(e&&!this.outlinePass){let e=new Wc(new _e(i,r),t,n);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.viewer.enableRender()}}get ssaaPassEnabled(){var e;return!(null==(e=this.ssaaRenderPass)||!e.enabled)}set ssaaPassEnabled(e){let t=this.viewer.scene,n=this.viewer.camera;if(this.composer){if(e&&!this.ssaaRenderPass){let e=new GP(t,n,16777215,0);this.composer.addPass(e),this.ssaaRenderPass=e,this.ssaaRenderPass=e}this.ssaaRenderPass&&(this.ssaaRenderPass.enabled=e),this.viewer.enableRender()}}get bloomPassEnabled(){var e;return!(null==(e=this.bloomPass)||!e.enabled)}set bloomPassEnabled(e){if(this.composer){if(e&&!this.bloomPass){let e=new Yu(1,25,4);e.renderToScreen=!0,this.composer.addPass(e),this.bloomPass=e}this.bloomPass&&(this.bloomPass.enabled=e),this.viewer.enableRender()}}get unrealBloomPassEnabled(){var e;return!(null==(e=this.unrealBloomPass)||!e.enabled)}set unrealBloomPassEnabled(e){let{width:t,height:n}=this.viewer.container;if(this.composer){if(e&&!this.unrealBloomPass){let e=new ld(new _e(t,n),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.viewer.enableRender()}}setOutlinePassSelectObjects(e){this.outlinePass&&(this.outlinePass.selectedObjects=e)}enableModelEdges(e){let t=this.viewer.loadedModels;for(let n=0;n<t.length;++n){let i=t[n];if(e&&!i.edges){let t=i.getModelObject();t&&(fe.debug(`[Viewer] Generating outlines for model '${t.id}'`),i.enableEdges(e))}else i.edges&&i.edges.forEach((t=>t.visible=e))}this.viewer.enableRender()}showVertexNormals(e,t=.1){e?(this.vertexNormalsHelpers||(this.vertexNormalsHelpers=new Bn),this.viewer.scene.traverseVisible((e=>{var n;if(e instanceof St&&!["SKYBOX","GROUND_GRID","GROUND_GRASS","BIM_VIEWER_BOX_HELPER"].includes(e.name)){if(!e.geometry.attributes.normal)return;let i=new NP(e,t,16711680);null==(n=this.vertexNormalsHelpers)||n.add(i)}})),this.viewer.scene.add(this.vertexNormalsHelpers)):this.vertexNormalsHelpers&&(this.viewer.scene.remove(this.vertexNormalsHelpers),this.vertexNormalsHelpers=void 0)}render(){!this.composer||!this.enabled||this.composer.render()}destroy(){var e,t,n,i,r,a,s,o,l;this.renderPass&&(null==(e=this.composer)||e.removePass(this.renderPass),this.renderPass.dispose(),this.renderPass=void 0),this.effectFxaaPass&&(null==(t=this.composer)||t.removePass(this.effectFxaaPass),this.effectFxaaPass.dispose(),this.effectFxaaPass=void 0),this.saoPass&&(null==(n=this.composer)||n.removePass(this.saoPass),this.saoPass.dispose(),this.saoPass=void 0),this.ssaoPass&&(null==(i=this.composer)||i.removePass(this.ssaoPass),this.ssaoPass.dispose(),this.ssaoPass=void 0),this.outlinePass&&(null==(r=this.composer)||r.removePass(this.outlinePass),this.outlinePass.dispose(),this.outlinePass=void 0),this.ssaaRenderPass&&(null==(a=this.composer)||a.removePass(this.ssaaRenderPass),this.ssaaRenderPass.dispose(),this.ssaaRenderPass=void 0),this.bloomPass&&(null==(s=this.composer)||s.removePass(this.bloomPass),this.bloomPass.dispose(),this.bloomPass=void 0),this.unrealBloomPass&&(null==(o=this.composer)||o.removePass(this.unrealBloomPass),this.unrealBloomPass.dispose(),this.unrealBloomPass=void 0),this.composer&&(null==(l=this.composer)||l.dispose(),this.composer=void 0)}},Lve=class extends Gf{constructor(e,t){super(e),this.name="BimViewer",this.loadedModels=[],this.distanceCullingFactor=150,this.enableSelection=!0,null!=e.enableSelection&&(this.enableSelection=e.enableSelection),this.effect=new WP(this),this.sceneManager.enableLights(!0),t&&(this.homeView=t,this.cameraManager.setCameraInfo(t)),this.cameraManager.setProjection(0),this.cameraManager.setNavigationMode(0),this.setupDefaultEvents(),this.setDefaultBackground()}setupDefaultEvents(){let e,t=!1,n=!1,i=0,r=0,a=0,s=e=>-1!==r&&-1!==a&&Math.abs(e.x-r)<5&&Math.abs(e.y-a)<5;this.inputManager.addEventListener("pointerdown",(i=>{n=!1,t=!0,e=this.pickModel({x:i.x,y:i.y}),0===i.button&&this.handleAnchorPoint(e)})),this.inputManager.addEventListener("pointermove",(e=>{t&&(n=!s(e),this.cameraManager.setOrbitPointVisible(!0))})),this.inputManager.addEventListener("pointerup",(o=>{if(t=!1,this.cameraManager.setOrbitPointVisible(!1),n)n=!1;else if(0===o.button){if(!this.enableSelection)return;this.selectedObject&&(this.selectedObject instanceof Wi?this.selectedObject.selected=!1:this.clearHighlight(),this.selectedObject=void 0),(e=>{let t=e.timestamp-i;return!!(0===e.button&&t<300&&s(e))})(o)?(null!=e&&e.object?this.flyToObject(null==e?void 0:e.object):this.viewFitAll(),i=0,r=-1,a=-1):(i=o.timestamp,r=o.x,a=o.y,null!=e&&e.object&&this.handleClickObject(null==e?void 0:e.object))}else o.button}))}setDefaultBackground(){this.sceneManager.setBackground(new ct(11119017)),this.sceneManager.setEnvironmentFromData()}handleAnchorPoint(e){let t=new k;this.selectedObject?(new Nt).setFromObject(this.selectedObject).getCenter(t):e&&e.point?t.copy(e.point):this.getBBox().getCenter(t),this.cameraManager.setOrbitPoint(t),this.cameraManager.update(0)}handleClickObject(e){let t=e=>!e.userData.modelId&&e.parent?t(e.parent):e.userData.modelId,n=t(e),i=this.loadedModels.find((e=>e.modelId===n));null==i||i.highlightObject(e),this.selectedObject=e,this.enableRender()}is3d(){return!0}loadLocalModel(e,t,n,i){return it(this,null,(function*(){this.spinner.increaseJobCount(),this.loaderHelper.setLoadManager(n);let r=yield this.loaderHelper.loadLocalModel(e,t.src,i);if(t.matrix&&16===t.matrix.length){let e=new ht;e.elements=t.matrix,r.applyMatrix4(e)}let a=this.getUniqueModelId(t.modelId||t.src),s=new XE({modelId:a,object:r});this.addModel(s);let o=s.getBBox();this.cameraManager.adjustCameraByBbox(o),this.homeView||(this.zoomToBBox(o),this.homeView=this.cameraManager.getCameraInfo());let l=new k;o.getCenter(l),this.cameraManager.setOrbitPoint(l),this.spinner.decreaseJobCount(),this.dispatchEvent("ModelLoaded")}))}loadModel(e,t){return it(this,null,(function*(){this.spinner.increaseJobCount();let n=yield this.loaderHelper.loadModel(e.src,e.fileFormat,t);if(e.matrix&&16===e.matrix.length){let t=new ht;t.elements=e.matrix,n.applyMatrix4(t)}let i=this.getUniqueModelId(e.modelId||e.src),r=new XE({modelId:i,object:n});this.addModel(r);let a=r.getBBox();this.cameraManager.adjustCameraByBbox(a);let s=new k;a.getCenter(s),this.cameraManager.setOrbitPoint(s),this.homeView||(this.zoomToBBox(a),this.homeView=this.cameraManager.getCameraInfo()),this.spinner.decreaseJobCount(),this.dispatchEvent("ModelLoaded")}))}setDistanceCullingFactor(e){this.distanceCullingFactor=e}getDistanceCullingFactor(){return this.distanceCullingFactor}setAllModelTransparent(e){this.loadedModels.forEach((t=>t.setOpacity(e))),this.enableRender()}clearAllModelTransparent(){this.loadedModels.forEach((e=>e.clearOpacity())),this.enableRender()}setObjectTransparent(e,t){this.loadedModels.forEach((n=>n.setObjectOpacity(e,t))),this.enableRender()}clearObjectTransparent(e){this.loadedModels.forEach((t=>t.clearObjectOpacity(e))),this.enableRender()}setOthersObjectTransparent(e){this.loadedModels.forEach((t=>{t.setOpacity(),t.clearObjectOpacity(e)})),this.enableRender()}setModelTransparent(e){let t=this.loadedModels.find((t=>t.modelId===e));null==t||t.setOpacity(),this.enableRender()}clearModelTransparent(e){let t=this.loadedModels.find((t=>t.modelId===e));null==t||t.clearOpacity(),this.enableRender()}setObjectVisible(e,t){this.loadedModels.forEach((n=>n.setObjectVisible(e,t))),this.enableRender()}hideOthersObject(e){this.loadedModels.forEach((t=>{t.setVisible(!1),t.setObjectVisible(e,!0)})),this.enableRender()}setModelVisible(e,t){let n=this.loadedModels.find((t=>t.modelId===e));null==n||n.setVisible(t),this.enableRender()}setAllModelVisible(e){this.loadedModels.forEach((t=>t.setVisible(e))),this.enableRender()}setObjectHighlight(e){this.loadedModels.forEach((t=>t.highlightObject(e))),this.enableRender()}clearHighlight(){this.loadedModels.forEach((e=>e.clearHighlight())),this.enableRender()}clearSelection(){this.clearHighlight()}enableSsao(e){this.effect.enabled=e,this.effect.renderPassEnabled=e,this.effect.ssaaPassEnabled=e,this.effect.ssaoPassEnabled=e}setEnvironmentData(e){return it(this,null,(function*(){yield this.sceneManager.setEnvironmentFromData(e),this.enableRender()}))}setEnvironment(e){return it(this,null,(function*(){yield this.sceneManager.setEnvironment(e),this.enableRender()}))}showVertexNormals(e,t=.1){this.effect.showVertexNormals(e,t)}getLights(){return{sun:this.sceneManager.directionLight,ambient:this.sceneManager.ambientLight,hemisphere:this.sceneManager.hemisphereLight}}debugLights(e){this.sceneManager.debugLights(e)}},jP=ss(Lc(),1);Wu.install({THREE:Vt});var E1=class extends Wu{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()}},Rvt=(e=>(e[e.Browser=0]="Browser",e[e.Browserless=1]="Browserless",e[e.Headless=2]="Headless",e))(Rvt||{}),Dve=class{constructor(e,t,n){if(this.scene=this.initScene(),this.selectedObject=void 0,this.loadedModels=[],this.clock=new Pl,this.viewerMode=0,this.raycaster=new Ac,this.savedMaterialsForOpacity=[],this.jobCount=0,this.bbox=new Nt,this.outlineMaterial=new zn({color:1118481}),this.outlineRoot=new Bn,this.transparentObjectIds=[],this.applyOptionsAndAddToScene=(e,t,n,i)=>it(this,null,(function*(){if(fe.info(`[Viewer] '${e}' is loaded, adding to scene...`),n.matrix&&16===n.matrix.length){let e=new ht;e.elements=n.matrix,t.applyMatrix4(e)}let r;t.traverse((e=>{e.geometry&&e.layers.enableAll(),e instanceof Cl&&(e.visible=!1)})),n.edges&&(r=yield rr.createOutlines(t,void 0,i));let a=n.modelId||n.src,s=e=>!!this.loadedModels.find((t=>t.modelId===e));if(s(a)){let e=1;for(;s(`${a}_${e}`);)e++;a=`${a}_${e}`,fe.warn(`[Viewer] Model '${a}' is loaded more than once!`)}let o={modelId:a,object:t,edges:r};this.addModel(o)})),this.getMeshes=e=>{let t=[];return e instanceof St?t.push(e):e.traverseVisible((e=>{e instanceof St&&t.push(e)})),t},this.containerOrCanvas=e,t&&(this.viewerMode=t),this.glContext=n,1===this.viewerMode&&(e instanceof HTMLDivElement||!n))throw new Error("[Viewer] Parameters don't match Browserless viewerMode !");this.increaseJobCount(),this.init(),this.decreaseJobCount(),fe.info("[Viewer] Initialized"),this.animate()}init(){this.initRenderer(),this.initCamera(),this.initControls(),this.initLights(),this.initPointerEvents(),this.scene.add(this.outlineRoot)}initScene(){let e=new Ji;return e.background=new ct(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 ga(e);if(t){let e=this.containerOrCanvas.width,t=this.containerOrCanvas.height;fe.info(`[Viewer] Render target size: ${e} x ${t}`),this.renderTarget=new er(e,t,{minFilter:Xr,magFilter:Jr,format:ea,type:Ec}),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=sn,n.toneMappingExposure=1,n.useLegacyLights=!1,n.setClearColor(11119017,1),n.shadowMap.enabled=!0,n.shadowMap.type=hv,this.renderer=n,t||(this.pmremGenerator=new Hh(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 Yr(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 E1(e,this.renderer.domElement);t.smoothTime=.05,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 va(e,.3);t.position.set(-2,2,4);let n=new mo(3158064),i=new Pu(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,this.loadedModels=[]}loadLocalModel(e,t,n){return it(this,null,(function*(){let i=yield(new ju).loadLocalModel(e,t.src,n);return i?(yield this.applyOptionsAndAddToScene(e,i,t),Promise.resolve()):Promise.reject()}))}loadModel(e,t){return it(this,null,(function*(){this.increaseJobCount();let n=yield(new ju).loadModel(e.src,e.fileFormat,t);return n?(yield this.applyOptionsAndAddToScene(e.src,n,e),Promise.resolve()):Promise.reject()}))}parseGltf(e,t,n,i){this.increaseJobCount(),(new ju).parseGltf(e,t.src,(e=>{this.applyOptionsAndAddToScene(t.src,e,t),n&&n(e)}),(e=>{i&&i(e)}))}addModel(e){if(!this.scene||!this.renderer)return;this.increaseJobCount();let t=(new Nt).setFromObject(e.object);e.bbox||(e.bbox=t),this.scene.add(e.object),this.loadedModels.push(e),this.computeBoundingBox(),1===this.loadedModels.length&&(this.tryAdjustCameraNearAndFar(),this.goToHomeView()),this.renderer.shadowMap.needsUpdate=!0,fe.info(`[Viewer] Added '${e.modelId}' to scene`),this.decreaseJobCount()}addOrRemoveObjectOpacity(e=!0,t=.3,n,i){if(this.savedMaterialsForOpacity||(this.savedMaterialsForOpacity=[]),!this.scene)return;let r=this.scene,a=[];this.loadedModels.forEach((s=>{if(e){this.savedMaterialsForOpacity&&this.savedMaterialsForOpacity.length>0&&rr.revertObjectOpacityById(r,s.object.id,this.savedMaterialsForOpacity);let e=rr.setObjectOpacityById(r,s.object.id,t,n,i);a.push(...e)}else this.savedMaterialsForOpacity&&rr.revertObjectOpacityById(r,s.object.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 _e;e&&(t=Sn.getScreenCoordinateByEvent(e,this.containerOrCanvas));let n=Sn.screen2Ndc(t,this.camera,this.containerOrCanvas);this.raycaster.setFromCamera(n,this.camera);let i=[];return this.loadedModels.forEach((e=>{let t=e.object;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&&t instanceof St})),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 Ar&&e.dispose()}this.selectedObject.material=e.originalMaterial,delete e.originalMaterial}this.selectedObject=void 0}if(!this.scene||!e)return;let t=Si.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 Nt;e.forEach((e=>{let n=Ol.getBoundingBox(e);t.union(n)}));let n=new $r;t.getBoundingSphere(n),this.controls.fitToSphere(n,!0)}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 k(e[0],e[1],e[2]):e,o=t=Array.isArray(t)?new k(t[0],t[1],t[2]):t;fe.info("[Viewer] flyTo: ",Pt.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(){let e=new $r;this.bbox.getBoundingSphere(e),this.controls.fitToSphere(e,!0)}setEnvironmentFromDataArray(e){xf.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=>Pt.numberToString(e);fe.info(`[Viewer] BBox's longest side is: ${t(o)}`),n>l&&(fe.warn(`[Viewer] camera.near(${t(n)}) shouldn't bigger than ${t(l)}, will change it!`),e.near=l),i<h&&(fe.warn(`[Viewer] 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 cn({color:16777215,transparent:!0,opacity:.1});this.loadedModels.forEach((e=>{rr.applyMaterialToObjectById(this.scene,e.object.id,i,n,t)})),this.outlineRoot.clear();let r=[];if(e.forEach((e=>{let t=e.modelId,n=this.loadedModels.find((e=>e.modelId===t)),i=null==n?void 0:n.object;i||(fe.warn(`[Viewer] The ModelId of ${t} has no corresponding model.`),i=this.scene),i.traverse((t=>{if((0,jP.includes)(e.id,(0,jP.get)(t.userData,"UniqueId"))){let e=this.getMeshes(t);r=r.concat(e)}}))})),r.length>0){r.forEach((e=>{let t=rr.createOutline(e.geometry,this.outlineMaterial);t.applyMatrix4(e.matrixWorld),this.outlineRoot.add(t),t.updateWorldMatrix(!0,!1)}));let e=r.map((e=>e.id));this.loadedModels.forEach((t=>{rr.revertAppliedMaterialToObjectById(this.scene,t.object.id,e)})),this.transparentObjectIds=e,this.flyToObjects(r)}else fe.warn(`[Viewer] No object found with uniqueIds: ${e.map((e=>e.id))}`);this.isBrowserMode()||this.animate()}increaseJobCount(){++this.jobCount}decreaseJobCount(){--this.jobCount}computeBoundingBox(){let e=new Nt;return this.loadedModels.forEach((t=>{t.bbox&&!t.bbox.isEmpty()&&e.union(t.bbox)})),this.bbox=e,e}getContext(){var e;return null==(e=this.renderer)?void 0:e.getContext()}getCameraDirection(){var e;let t=new k;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())}},Ove=ss(Lc(),1),$u=class extends Bn{constructor(e,t,n,i=10){super(),this.textureLoader=new ws,this.enableCache=!1,this.imageManager=e,this.images=t,this.thumbnailImages=n,this.size=i,this.mesh=new St}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/0,this.fadingInInterval=setInterval((()=>{var e;let i=1,r=this.getMaterials();this.materialEquals(t,r)||(t=r),t.length>0&&(i=Math.min(t[0].opacity+n,1),t.forEach((e=>e.opacity=i))),i>=1&&this.clearFading(),null==(e=this.render)||e.call(this)}),10)}materialEquals(e,t){return Ove.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.renderOrder=0,this.fadingOutInterval=setInterval((()=>{var e;let r=this.scale.x+i;this.scale.set(r,r,r);let a=0;t.length>0&&(a=Math.max(t[0].opacity-n,0),t.forEach((e=>e.opacity=a))),(a<=0||r>=3)&&(this.clearFading(),this.enableCache&&this.destroy()),null==(e=this.render)||e.call(this)}),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.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 it(this,null,(function*(){if(!this.thumbnailImages||6!=this.thumbnailImages.length)return;this.thumbnailMesh=new St(new ma(e,e,e)),this.thumbnailMesh.geometry.scale(1,1,-1);let t=(yield this.loadTexturesAsync(this.thumbnailImages,!1)).map((e=>new cn({map:e,side:hi,transparent:!0})));this.thumbnailMesh&&(this.thumbnailMesh.material=t,this.add(this.thumbnailMesh))}))}loadTexturesAsync(e,t=!0){return it(this,null,(function*(){return Promise.all(e.map((e=>it(this,null,(function*(){let n;if(t){let t=yield this.imageManager.get(e);n=new Hr(t),n.needsUpdate=!0}else n=yield this.textureLoader.loadAsync(e);return n.colorSpace=sn,n})))))}))}setCacheEnabled(e){this.enableCache=e}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.thumbnailImages=void 0,this.removeFromParent(),this.thumbnailMesh&&(this.destroyMesh(this.thumbnailMesh),this.thumbnailMesh=void 0),this.mesh&&(this.mesh instanceof St?this.destroyMesh(this.mesh):this.mesh.traverse((e=>{e instanceof St&&this.destroyMesh(e)})),this.mesh=void 0)}},XP=class{constructor(){this.enableCache=!0,this.loader=new Xh}setImageToInedxdb(e){return it(this,null,(function*(){try{yield Ef.instance().save(e),console.log(`[Image] Saved '${e.fileName}' to indexedDb`)}catch(t){console.log(`[Image ] Failed to save '${e.fileName}' to indexedDb! ${t}`)}}))}getImageFromIndexdb(e){return it(this,null,(function*(){let t=yield Ef.instance().query(e);if(!t)return null;let n=t.data,i=URL.createObjectURL(n),r=new Image;return r.src=i,yield new Promise((e=>{r.onload=()=>{e(r)}}))}))}removeImageFromIndexdb(e){return it(this,null,(function*(){yield Ef.instance().delete(e)}))}clearImageFromIndexdb(){return it(this,null,(function*(){yield Ef.instance().clearAll()}))}saveImageData(e,t){let n=document.createElement("canvas"),i=n.getContext("2d");return n.width=t.width,n.height=t.height,i.drawImage(t,0,0),new Promise((t=>{n.toBlob((n=>{let i={fileName:e,data:n};this.setImageToInedxdb(i),t(n)}))}))}get(e){return it(this,null,(function*(){let t;return this.enableCache?(t=yield this.getImageFromIndexdb(e),t||(t=yield this.loader.loadAsync(e),this.saveImageData(e,t))):t=yield this.loader.loadAsync(e),t}))}remove(e){return it(this,null,(function*(){yield this.removeImageFromIndexdb(e)}))}clear(){return it(this,null,(function*(){yield this.clearImageFromIndexdb()}))}static getFileName(e){let t=e.lastIndexOf("/");return e.substring(t+1)}destroy(){this.clear()}},YP=class extends $u{constructor(e,t,n,i=200){if(super(e,t,n,i),6!==t.length)throw new Error(`[VRCube] Wrong number of images! Expected 6, got ${t.length}`)}create(){return it(this,null,(function*(){yield this.createThumbnailMesh(this.size),this.thumbnailMesh?this.updateMesh():yield this.createMesh()}))}updateMesh(){let e=this.thumbnailMesh,t=this.thumbnailImages.length;this.images.forEach(((n,i)=>it(this,null,(function*(){var r;let a=yield this.loadTexturesAsync([n],!0);e.material[i].map=a[0],t--,0===t&&(this.thumbnailImages=void 0),null==(r=this.render)||r.call(this)})))),this.destroyMesh(this.mesh),this.mesh=void 0}createMesh(){return it(this,null,(function*(){var e;let t=this.mesh;t.geometry=new ma(this.size,this.size,this.size),t.geometry.scale(1,1,-1);let n=(yield this.loadTexturesAsync(this.images)).map((e=>new cn({map:e,side:hi,transparent:!0})));t.material=n,this.add(t),this.thumbnailMesh&&(this.destroyMesh(this.thumbnailMesh),this.thumbnailMesh=void 0,this.thumbnailImages=void 0),null==(e=this.render)||e.call(this)}))}},$P=class extends $u{constructor(e,t,n,i=200){if(super(e,t,n,i),24!==t.length)throw new Error(`[VRCube24Faces] Wrong number of images! Expected 24, got ${t.length}`);this.ratio=1,this.subPlaneWidth0=this.size*(this.ratio/(this.ratio+1)),this.subPlaneWidth1=this.size-this.subPlaneWidth0}create(){return it(this,null,(function*(){yield this.createThumbnailMesh(this.size+.1),this.thumbnailMesh?this.createMesh():yield this.createMesh()}))}createMesh(){return it(this,null,(function*(){var e,t,n,i;this.mesh=new Bn,this.mesh.scale.set(1,1,-1);let r=(yield this.loadTexturesAsync(this.images)).map((e=>new cn({map:e,side:Ki,transparent:!0})));if(24!==r.length)throw new Error(`[VRCube24Faces] Wrong number of materials! Expected 24, got ${r.length}`);let a=this.createPlaneOfAFace(r.slice(0,4));a.rotateOnAxis(new k(0,1,0),-Math.PI/2),a.position.set(this.size/2,0,0);let s=this.createPlaneOfAFace(r.slice(4,8));s.rotateOnAxis(new k(0,1,0),Math.PI/2),s.position.set(-this.size/2,0,0);let o=this.createPlaneOfAFace(r.slice(8,12));o.rotateOnAxis(new k(1,0,0),-Math.PI/2),o.rotateOnAxis(new k(0,0,1),Math.PI),o.rotateOnAxis(new k(1,0,0),Math.PI),o.position.set(0,this.size/2,0);let l=this.createPlaneOfAFace(r.slice(12,16));l.rotateOnAxis(new k(1,0,0),Math.PI/2),l.rotateOnAxis(new k(0,0,1),Math.PI),l.rotateOnAxis(new k(1,0,0),Math.PI),l.position.set(0,-this.size/2,0);let h=this.createPlaneOfAFace(r.slice(16,20));h.rotateOnAxis(new k(0,1,0),Math.PI),h.position.set(0,0,this.size/2),this.createPlaneOfAFace(r.slice(20,24)).position.set(0,0,-this.size/2),this.add(this.mesh),null==(e=this.mesh)||e.updateMatrix(),null==(t=this.mesh)||t.updateMatrixWorld(!0),this.thumbnailMesh&&(this.destroyMesh(this.thumbnailMesh),this.remove(this.thumbnailMesh),null==(n=this.thumbnailMesh)||n.clear(),this.thumbnailMesh=void 0),null==(i=this.render)||i.call(this)}))}createPlaneOfAFace(e){var t;let n=new Bn,i=new mi(this.subPlaneWidth0,this.subPlaneWidth0),r=new mi(this.subPlaneWidth1,this.subPlaneWidth0),a=new mi(this.subPlaneWidth0,this.subPlaneWidth1),s=new mi(this.subPlaneWidth1,this.subPlaneWidth1),o=new St(i,e[0]),l=new St(r,e[1]),h=new St(a,e[2]),u=new St(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),u.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),u.geometry.scale(-1,1,1),n.add(o,l,h,u),null==(t=this.mesh)||t.add(n),n}},ZP=class extends $u{constructor(e,t,n,i=100){if(super(e,t,n,i),1!==t.length)throw new Error(`[VRSphere] Wrong number of images! Expected 1, got ${t.length}`)}create(){return it(this,null,(function*(){yield this.createThumbnailMesh(this.size+.1),this.thumbnailMesh?this.createMesh():yield this.createMesh()}))}createMesh(){return it(this,null,(function*(){var e,t;let n=this.mesh;n.geometry=new Va(this.size,100,100),n.geometry.scale(-1,1,1);let i=(yield this.loadTexturesAsync(this.images)).map((e=>new cn({map:e,side:hi,transparent:!0})));n.material=i[0],this.add(n),this.thumbnailMesh&&(this.destroyMesh(this.thumbnailMesh),this.remove(this.thumbnailMesh),null==(e=this.thumbnailMesh)||e.clear(),this.thumbnailMesh=void 0),null==(t=this.render)||t.call(this)}))}},kve=class extends Gf{constructor(e){super(e),this.name="VRViewer",this.viewpoints=[],this.activeViewpointId="undefined",this.activePanoramaId="undefined",this.autoRotateSpeed=2,this.autoRotate=!0,this.enableAutoRotate=!0,this.enableCache=e.enableCache||!1,this.sceneManager.enableClipping(!1),this.cameraManager.setProjection(0),this.cameraManager.setNavigationMode(3),this.camera.fov=75,this.camera.updateProjectionMatrix(),this.imageManager=new XP,this.imageManager.enableCache=this.enableCache,this.setDefaultBackground(),this.setupDefaultEvents(),this.setupAutoRotateEvents(),this.enableAutoRotate&&this.delayAutoRotate()}setDefaultBackground(){this.setBackgroundColor(1,1,1)}setupDefaultEvents(){let e=!1,t=-1,n=-1;this.inputManager.addEventListener("keydown",(()=>{this.delayAutoRotate()})),this.inputManager.addEventListener("pointerdown",(i=>{var r;t=i.x,n=i.y,e=!1,this.autoRotate&&this.delayAutoRotate(),i.button===LA.LEFT&&(null==(r=i.originalEvent)?void 0:r.target)instanceof HTMLCanvasElement&&(this.renderer.domElement.style.cursor="move")})),this.inputManager.addEventListener("pointermove",(i=>{t>=0&&n>=0&&(Math.abs(i.x-t)>5||Math.abs(i.y-n)>5)&&(e=!0)})),this.inputManager.addEventListener("pointerup",(t=>{var n,i;this.autoRotate&&this.delayAutoRotate(),this.renderer.domElement.style.cursor="auto";let r=t.button;if(!e&&r===LA.LEFT&&null!=(n=t.originalEvent)&&n.target&&t.originalEvent.target instanceof HTMLElement){let e=pf.tryFindObjectId(t.originalEvent.target);if(e){let t=null==(i=this.scene)?void 0:i.getObjectById(e);t&&this.dispatchEvent("HotpointClicked",t.userData.hotpoint)}else{let e=this.getHitResult(t);if(e){let t=e.clone().sub(this.camera.position).normalize();fe.info(`[Viewer] Clicked at: ${Pt.vectorToString(e)},\n Camera position: ${Pt.vectorToString(this.camera.position)},\n Target direction: ${Pt.vectorToString(t)}`)}}}}))}setupAutoRotateEvents(){let e=this.cameraManager.cameraControls;this.addEventListener("OnAnimate",(()=>{this.autoRotate&&this.enableAutoRotate&&(e.azimuthAngle-=2*Math.PI/60/60*this.autoRotateSpeed)}))}delayAutoRotate(){clearInterval(this.delayAutoRotateTimeout),this.autoRotate=!1,this.delayAutoRotateTimeout=setTimeout((()=>{this.autoRotate=!0}),5e3)}createBoxByImageOrImages(e,t){return it(this,null,(function*(){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],fe.warn(`[Viewer] Failed to find panorama by id '${t}', will use the first one`)),i=n.images,r=n.thumbnails,t=n.id}if(!i)throw new Error("[Viewer] 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(`[Viewer] Wrong number of images! Expected 1/6/24, got ${i.length}`)}))}setVrMeshDefault(e){e.setCacheEnabled(this.enableCache),e.render=()=>this.enableRender()}createBoxByImage(e,t){return it(this,null,(function*(){let n=new ZP(this.imageManager,e,t);return this.setVrMeshDefault(n),yield n.create(),n}))}createBoxBy6Images(e,t){return it(this,null,(function*(){if(6!==e.length)throw new Error(`[VRCube] Wrong number of images! Expected 6, got ${e.length}`);let n=new YP(this.imageManager,e,t);return this.setVrMeshDefault(n),yield n.create(),n}))}createBoxBy24Images(e,t){return it(this,null,(function*(){if(24!==e.length)throw new Error(`[VRCube] Wrong number of images! Expected 24, got ${e.length}`);let n=new $P(this.imageManager,e,t);return this.setVrMeshDefault(n),yield n.create(),n}))}adjustCamera(e,t){let n=new k(0,0,0),i=new k(1,0,0),r=this.getCameraDirection();r&&i.set(r.x,r.y,r.z);let a=e.position;if(a&&3===a.length&&n.set(a[0],a[1],a[2]),t){let t=e.initialDirection;t&&3===t.length&&i.set(t[0],t[1],t[2])}this.setCameraPositionAndDirection(n.toArray(),i.toArray())}setCss2dObjectsVisible(e,t){e.traverse((e=>{e instanceof ff&&(e.visible=t)}))}relocateAnchorIfTooCloseToCamera(e,t,n){let i=this.camera;if(!i)return fe.error("[Viewer] 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)}loadModel(e,t){return it(this,null,(function*(){}))}getViewpoint(e){return this.viewpoints.find((t=>t.id===e))}setViewpoints(e){this.viewpoints.forEach((e=>{var t;let n=this.scene.getObjectByName(e.id);null==(t=e.panoramas)||t.forEach((e=>{let t=null==n?void 0:n.getObjectByName(e.id);null==t||t.destroy(),this.removeImageCache(e.images)})),null==n||n.clear(),null==n||n.removeFromParent(),e.imageOrImages&&this.removeImageCache(e.imageOrImages)})),this.activeViewpointId="undefined",this.activePanoramaId="undefined",this.viewpoints=e}activatePanoramaById(e,t,n=!0){return it(this,null,(function*(){if(e===this.activeViewpointId&&t===this.activePanoramaId)return;let i=this.getViewpoint(e);i&&(yield this.activatePanorama(i,t,n))}))}activatePanorama(e,t,n=!0){return it(this,null,(function*(){let i=this.scene.getObjectByName(this.activeViewpointId),r=this.scene.getObjectByName(e.id),a=null==i?void 0:i.getObjectByName(this.activePanoramaId);if(a){let e=null==i?void 0:i.getObjectByName("hotpoints");this.setCss2dObjectsVisible(e,!1),a.fadeOut(1e3)}let s=null==r?void 0:r.getObjectByName(t),o=null==r?void 0:r.getObjectByName("hotpoints");if(this.activeViewpointId=e.id,this.activePanoramaId=t,s)return null==s||s.fadeIn(500),this.setCss2dObjectsVisible(o,!0),void this.adjustCamera(e,n);r||(r=new Bn,r.name=e.id,this.scene.add(r));let l=yield this.createBoxByImageOrImages(e,t);if(this.activeViewpointId!==e.id||this.activePanoramaId!==t)return void l.destroy();l.name=t;let h=e.position;if(h&&3===h.length&&l.position.set(h[0],h[1],h[2]),l.fadeIn(500),this.adjustCamera(e,n),r.add(l),!e.hotpoints)return;let u=r.getObjectByName("hotpoints");u||(u=new Bn,u.name="hotpoints"),0===u.children.length?(e.hotpoints.forEach((e=>{let t=e.anchorPosition,n=pf.createHotpoint(e.html);n.visible=!1!==e.visible,n.userData.hotpoint=e;let i=new k(t[0],t[1],t[2]);this.relocateAnchorIfTooCloseToCamera(n,i,l.position),n.name=e.hotpointId,null==u||u.add(n),n.updateMatrix(),n.updateMatrixWorld(!0)})),r.add(u)):this.setCss2dObjectsVisible(o,!0)}))}addPanorama(e,t){let n=this.viewpoints.find((t=>t.id===e));if(!n)throw new Error(`[Viewer] 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))}addHotpoints(e){if(!this.activeViewpointId||!e)return;let t=this.viewpoints.find((e=>e.id===this.activeViewpointId)),n=this.scene.getObjectByName(this.activeViewpointId);if(!t||!n)return;t.hotpoints||(t.hotpoints=[]);let i=n.getObjectByName("hotpoints");i&&(i=new Bn,i.name="hotpoints"),e.forEach((e=>{var n;if(-1!==(null==(n=t.hotpoints)?void 0:n.findIndex((t=>t.hotpointId===e.hotpointId))))return void fe.warn(`[Viewer] Duplicated hotpointId: ${e.hotpointId}`);let r=t.position||[0,0,0],a=e.anchorPosition,s=pf.createHotpoint(e.html),o=new k(a[0],a[1],a[2]),l=new k(r[0],r[1],r[2]);this.relocateAnchorIfTooCloseToCamera(s,o,l),s.visible=!1!==e.visible,s.userData.hotpoint=e,s.name=e.hotpointId,null==i||i.add(s),t.hotpoints.push(e)}))}removeHotpoints(e){if(!this.activeViewpointId||!e)return;let t=this.viewpoints.find((e=>e.id===this.activeViewpointId)),n=this.scene.getObjectByName(this.activeViewpointId);!t||!n||e.forEach((e=>{if(t.hotpoints)for(let n=t.hotpoints.length-1;n>=0;--n)e===t.hotpoints[n].hotpointId&&t.hotpoints.splice(n,1);let i=n.getObjectByName("hotpoints"),r=null==i?void 0:i.getObjectByName(e);null==r||r.removeFromParent()}))}setHotpointsVisibility(e,t="",n=[]){if(t){let i=this.scene.getObjectByName(t),r=null==i?void 0:i.getObjectByName("hotpoints");n.forEach((t=>{let n=null==r?void 0:r.getObjectByName(t);n&&(n.visible=e)}))}else this.viewpoints.forEach((t=>{let n=this.scene.getObjectByName(t.id),i=null==n?void 0:n.getObjectByName("hotpoints");i&&this.setCss2dObjectsVisible(i,e)}))}clearImageCache(){return it(this,null,(function*(){yield this.imageManager.clear(),fe.info("[VRViewer] Image cache cleared")}))}removeImageCache(e){return it(this,null,(function*(){this.enableCache&&(e=Array.isArray(e)?e:[e]).forEach((e=>it(this,null,(function*(){yield this.imageManager.remove(e)}))))}))}setCameraPositionAndDirection(e,t){let n,i=new k(e[0],e[1],e[2]);n=t?new k(t[0],t[1],t[2]):this.getCameraDirection();let r=i.clone().addScaledVector(n,1e-5);this.cameraManager.flyTo(i,r)}getCameraPositionAndDirection(){let e=this.camera.position,t=this.cameraManager.getCameraDirection();return{position:[e.x,e.y,e.z],direction:[t.x,t.y,t.z]}}unlimitControlsAndShowPanorama(e=!0){this.cameraManager.enablePan(!0),this.scene.traverse((t=>{t instanceof $u&&(t.visible=!0),e&&"hotpoints"===t.name&&this.setCss2dObjectsVisible(t,!0)})),this.enableRender()}getHitResult(e){let t=new _e(e.x,e.y),n=this.pickManager.pickObject(t,this.scene);return null==n?void 0:n.point}lookToPosition(e){let t=this.camera.position,n=new k(e[0],e[1],e[2]).clone().sub(t);this.setCameraPositionAndDirection(t.toArray(),n.toArray())}setMinAndMaxZoom(e,t){this.cameraManager.cameraControls.minZoom=e,this.cameraManager.cameraControls.maxZoom=t}setZoom(e){this.cameraManager.cameraControls.zoomTo(e,!0)}getZoom(){return this.camera.zoom}setAutoRotateEnabled(e){this.enableAutoRotate=e}setAutoRotateSpeed(e){this.autoRotateSpeed=e}destroy(){super.destroy(),this.setViewpoints([]),this.imageManager.destroy()}},KP=class extends an{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 k(0,0,0),i=new k(1,0,0),r=new k(0,1,0),a=new Rc(i,n,this.AXIS_LENGTH,this.AXIS_COLOR_X,0,0),s=new Rc(r,n,this.AXIS_LENGTH,this.AXIS_COLOR_Y,0,0);if(this.add(a,s),!t){let e=new k(0,0,1),t=new Rc(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 ff(i)}},P4=class extends ar{constructor(e,t){super(e,{id:(null==t?void 0:t.id)||P4.DEFAULT_ID}),this.ignoreZAxis=!1,this.cfg=t||{},this.ignoreZAxis=!(null==t||!t.ignoreZAxis),this.hostCamera=e.camera,this.init()}init(){this.initRenderer(),this.initScene(),this.animate(),this.viewer.addEventListener("CameraChanged",(()=>{this.hostCamera=this.viewer.camera}))}initRenderer(){var e;let t,n=100,i=100;if(this.cfg.containerId&&(t=document.getElementById(this.cfg.containerId),t&&(n=t.clientWidth,i=t.clientHeight)),!t){let n="axisGizmo";t=document.createElement("div"),t.id=n,null==(e=this.viewer.widgetContainer)||e.appendChild(t)}this.renderer=new ga({antialias:!0,alpha:!0}),this.renderer.setSize(n,i),t.appendChild(this.renderer.domElement),this.css2dRenderer=new Lv,this.css2dRenderer.setSize(n,i),this.css2dRenderer.domElement.style.height="0",this.css2dRenderer.domElement.style.width="0",t.appendChild(this.css2dRenderer.domElement)}initScene(){this.scene=new Ji,this.camera=new xi(-1,1,1,-1,.1,100),this.scene.add(this.camera),this.coordinateAxes=new KP(!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 k;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}destroy(){var e,t;super.destroy(),this.scene&&this.camera&&this.coordinateAxes&&(this.scene.clear(),this.scene=void 0,this.css2dRenderer&&(null==(e=this.container)||e.removeChild(this.css2dRenderer.domElement),this.css2dRenderer=void 0),this.renderer&&(null==(t=this.container)||t.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)}},C4=P4;C4.DEFAULT_ID="AxisGizmoPlugin";var L4=ss(Lc(),1),Cvt="bottomBar",Fve=e=>{let t=document.createElement("span"),n=e.viewer.getRenderInfo(),i=(e,n)=>{t.innerHTML+=`<p><span>${e}:</span>${n}</p>`};t.innerHTML="<p>-- Renderer Info --</p>";let r=` (${(e=>{var t;let n=null==(t=e.renderer)?void 0:t.domElement;return null==n?void 0:n.dataset.engine})(e.viewer)})`;return i("Version",`${CE}${r}`),i("DrawCalls",n.drawCalls),i("Points",n.points),i("Lines",n.lines),i("Triangles",n.triangles),i("Materials",n.materials),i("Textures",n.textures),i("Geometries",n.geometries),t},Nve=e=>{let t=document.createElement("span"),n=e.viewer.getCameraInfo(),i=(e,n)=>{t.innerHTML+=`<p><span>${e}:</span>${n}</p>`};t.innerHTML="";let r=e=>Pt.numberToString(e),a=e=>Pt.vectorToString(e);return i("Camera near",r(n.near)),i("Camera far",r(n.far)),i("Camera up",a(n.up)),i("Camera position",a(n.eye)),i("Camera target",a(n.look)),t},Pvt={"gemini-viewer-threejs-statistics":{icon:{default:"icon-info",active:"icon-info-filled",iconFont:"gemini-viewer-icon"},mutexIds:["gemini-viewer-threejs-cameraInfo","gemini-viewer-threejs-tips"],onActive:e=>{let t=Fve(e);e.tooltip.setContent(t),e.tooltip.show()},onDeactive:e=>{e.tooltip.hide()},onUpdate:e=>{let t=Fve(e);e.tooltip.setContent(t)}},"gemini-viewer-threejs-cameraInfo":{icon:{default:"icon-view",active:"icon-view-filled",iconFont:"gemini-viewer-icon"},mutexIds:["gemini-viewer-threejs-statistics","gemini-viewer-threejs-tips"],onActive:e=>{let t=Nve(e);e.tooltip.setContent(t),e.tooltip.show()},onDeactive:e=>{e.tooltip.hide()},onUpdate:e=>{let t=Nve(e);e.tooltip.setContent(t)}},"gemini-viewer-threejs-tips":{icon:{default:"icon-more",iconFont:"gemini-viewer-icon"},mutexIds:["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()}}},Bve=class extends ar{constructor(e){super(e,{id:"BottomBarPlugin"}),this.itemList=new Map,this.init()}update(){this.itemList.forEach((e=>{e.update()}))}init(){var e;let t=document.createElement("div");t.id=Cvt,t.classList.add("bottom-bar"),(0,L4.forEach)(Pvt,((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),this.viewer.addEventListener("AfterRender",(()=>{this.update()}))}createItem(e,t,n){let i=new I4(e,this,t,n);return this.itemList.set(t,i),i}},I4=class{constructor(e,t,n,i){this.viewer=e,this.bottomBar=t,this.menuId=n,this.cfg=i,this.eventBus=x1(),this.active=!1,this.itemconfig=i,this.element=this.createButton(this.menuId,i),this.tooltip=new Zl(n+"-tooltip",null,{parentNode:e.widgetContainer}),this.eventBus.on("activeChange",(e=>{e?(this.element.classList.add("active"),(0,L4.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&&hR(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=fR}=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)}},d_=ss(Lc(),1),Jo=e=>()=>wr(`ContextMenu.${e}`),Hve=e=>{var t;let n=0;return null==(t=e.scene)||t.traverseVisible((e=>{e instanceof St&&n++})),n>0},Ivt=e=>{var t,n;let i=0;return null==(t=e.scene)||t.traverse((e=>{e instanceof St&&i++})),null==(n=e.scene)||n.traverseVisible((e=>{e instanceof St&&i--})),i>0},Uve=(e,t,n,i)=>{let r=e.selectedObject;return!(!r||!t||r.id!==t.id)},Lvt={getTitle:Jo("viewFitEntity"),getShown:({hit:e})=>e,doAction:({viewer:e,hit:t})=>{e.flyToObject(t)}},Dvt={getTitle:Jo("viewFitAll"),getEnabled:({viewer:e})=>Hve(e),doAction:({viewer:e})=>e.viewFitAll()},Ovt={getTitle:Jo("hideEntity"),getShown:({hit:e})=>e,doAction:({viewer:e,hit:t})=>{let n=e;n.clearSelection(),n.setObjectVisible(t,!1),n.enableRender()}},kvt={getTitle:Jo("hideOthers"),getShown:({hit:e})=>e,doAction:({viewer:e,hit:t})=>{let n=e;n.clearSelection(),n.hideOthersObject(t),n.enableRender()}},Fvt={getTitle:Jo("hideAll"),getEnabled:({viewer:e})=>Hve(e),doAction:({viewer:e})=>{let t=e;t.clearSelection(),t.setAllModelVisible(!1),t.enableRender()}},Nvt={getTitle:Jo("showAll"),getEnabled:({viewer:e})=>Ivt(e),doAction:({viewer:e})=>{let t=e;t.setAllModelVisible(!0),t.enableRender()}},Bvt={getTitle:({hit:e,viewer:t,instanceId:n,batchId:i})=>Uve(t,e,n,i)?Jo("deselect")():Jo("select")(),getShown:({hit:e,viewer:t})=>t.enableSelection&&e,doAction:({hit:e,viewer:t,instanceId:n,batchId:i})=>{let r=t;rr.isObjectSelectable(e)?Uve(r,e,n,i)?r.clearSelection():r.setObjectHighlight(e):fe.debug(`[ContextMenu] object(type: ${e.type}, name: ${e.name}) not selectable!`)}},Uvt={getTitle:Jo("selectNone"),getShown:({viewer:e})=>e.enableSelection,getEnabled:({viewer:e})=>!!e.selectedObject,doAction:({viewer:e})=>e.clearSelection()},_1=!1,Hvt={getTitle:Jo("xRayAll"),getShown:({viewer:e})=>!_1,doAction:({viewer:e})=>{let t=e;t.clearSelection(),t.setAllModelTransparent(.03),t.enableRender(),_1=!0}},Vvt={getTitle:Jo("xRayNone"),getEnabled:({viewer:e})=>_1,doAction:({viewer:e})=>{let t=e;t.clearSelection(),t.clearAllModelTransparent(),t.enableRender(),_1=!1}},zvt={getTitle:Jo("xRayEntity"),getShown:({hit:e})=>e,doAction:({viewer:e,hit:t})=>{let n=e;n.clearSelection(),n.setObjectTransparent(t,.03),_1=!0}},Gvt={getTitle:Jo("xRayOthers"),getShown:({hit:e})=>e,doAction:({viewer:e,hit:t})=>{let n=e;n.clearSelection(),n.setOthersObjectTransparent(t),n.enableRender(),_1=!0}},Vve=[[Lvt,Dvt],[Ovt,kvt,Fvt,Nvt],[zvt,Gvt,Hvt,Vvt],[Bvt,Uvt]],zve=class extends ar{constructor(e){super(e,{id:"ContextMenuPlugin"}),this.itemList=[],this.handleClick=()=>{this.hide()},this.container=e.widgetContainer||document.body,this.context={viewer:e},this.element=this.createMenuUI(Vve||[]),window.oncontextmenu=e=>e.preventDefault(),this.hide(),this.initEvents()}initEvents(){let e=this.viewer.getInputManager();if(!e)return;let t=!1,n=!1,i=0,r=0;e.addEventListener("pointerdown",(()=>{n=!1,t=!0,this.hide()})),e.addEventListener("pointermove",(e=>{t&&!n&&(n=!(e=>-1!==i&&-1!==r&&Math.abs(e.x-i)<5&&Math.abs(e.y-r)<5)(e))})),e.addEventListener("pointerup",(e=>{if(t=!1,n)return n=!1,void this.hide();i=e.x,r=e.y;let a=this.viewer.findPlugin(Jm.DEFAULT_ID);2!==e.button||null!=a&&a.isActive()?this.hide():this.showContextMenu(e)})),document.addEventListener("click",this.handleClick)}showContextMenu(e){let t=this.context,n=this.viewer;if(n.selectedObject){let e=n.selectedObject.userData.instanceId,i=n.selectedObject.userData.batchId;this.context=Ci(Ir({},t),{hit:n.selectedObject,instanceId:e,batchId:i})}else{let i=n.pickObjectsByMouse({x:e.x,y:e.y})[0];this.context=Ci(Ir({},t),{hit:null==i?void 0:i.object})}let{x:i,y:r}=e;this.show(i,r)}isEnabled(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,d_.map)(e,(e=>{let t=document.createElement("ul");return(0,d_.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.isEnabled(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,d_.forEach)(this.itemList,(([e,t])=>{this.isEnabled(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)}};function qvt(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 S1(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 u=e.hex.toString(16);u.length<6;)u="0"+u;return"#"+u}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 Gve=Array.prototype.forEach,f_=Array.prototype.slice,Ht={BREAK:{},extend:function(e){return this.each(f_.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(f_.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=f_.call(arguments);return function(){for(var t=f_.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(Gve&&e.forEach&&e.forEach===Gve)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():f_.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}},Wvt=[{litmus:Ht.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:S1},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:S1},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:S1},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:S1}}},{litmus:Ht.isNumber,conversions:{HEX:{read:function(e){return{space:"HEX",hex:e,conversionName:"HEX"}},write:function(e){return e.hex}}}},{litmus:Ht.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:Ht.isObject,conversions:{RGBA_OBJ:{read:function(e){return!!(Ht.isNumber(e.r)&&Ht.isNumber(e.g)&&Ht.isNumber(e.b)&&Ht.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!!(Ht.isNumber(e.r)&&Ht.isNumber(e.g)&&Ht.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!!(Ht.isNumber(e.h)&&Ht.isNumber(e.s)&&Ht.isNumber(e.v)&&Ht.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!!(Ht.isNumber(e.h)&&Ht.isNumber(e.s)&&Ht.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}}}}}],p_=void 0,JP=void 0,O4=function(){JP=!1;var e=arguments.length>1?Ht.toArray(arguments):arguments[0];return Ht.each(Wvt,(function(t){if(t.litmus(e))return Ht.each(t.conversions,(function(t,n){if(p_=t.read(e),!1===JP&&!1!==p_)return JP=p_,p_.conversionName=n,p_.conversion=t,Ht.BREAK})),Ht.BREAK})),JP},qve=void 0,e2={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<<(qve=8*t)|e&~(255<<qve)}},jvt="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},jc=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},Xc=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}}(),Xf=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)},Yf=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)},$f=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},$s=function(){function e(){if(jc(this,e),this.__state=O4.apply(this,arguments),!1===this.__state)throw new Error("Failed to interpret color arguments");this.__state.a=this.__state.a||1}return Xc(e,[{key:"toString",value:function(){return S1(this)}},{key:"toHexString",value:function(){return S1(this,!0)}},{key:"toOriginal",value:function(){return this.__state.conversion.write(this)}}]),e}();function H4(e,t,n){Object.defineProperty(e,t,{get:function(){return"RGB"===this.__state.space||$s.recalculateRGB(this,t,n),this.__state[t]},set:function(e){"RGB"!==this.__state.space&&($s.recalculateRGB(this,t,n),this.__state.space="RGB"),this.__state[t]=e}})}function V4(e,t){Object.defineProperty(e,t,{get:function(){return"HSV"===this.__state.space||$s.recalculateHSV(this),this.__state[t]},set:function(e){"HSV"!==this.__state.space&&($s.recalculateHSV(this),this.__state.space="HSV"),this.__state[t]=e}})}$s.recalculateRGB=function(e,t,n){if("HEX"===e.__state.space)e.__state[t]=e2.component_from_hex(e.__state.hex,n);else{if("HSV"!==e.__state.space)throw new Error("Corrupted color state");Ht.extend(e.__state,e2.hsv_to_rgb(e.__state.h,e.__state.s,e.__state.v))}},$s.recalculateHSV=function(e){var t=e2.rgb_to_hsv(e.r,e.g,e.b);Ht.extend(e.__state,{s:t.s,v:t.v}),Ht.isNaN(t.h)?Ht.isUndefined(e.__state.h)&&(e.__state.h=0):e.__state.h=t.h},$s.COMPONENTS=["r","g","b","h","s","v","hex","a"],H4($s.prototype,"r",2),H4($s.prototype,"g",1),H4($s.prototype,"b",0),V4($s.prototype,"h"),V4($s.prototype,"s"),V4($s.prototype,"v"),Object.defineProperty($s.prototype,"a",{get:function(){return this.__state.a},set:function(e){this.__state.a=e}}),Object.defineProperty($s.prototype,"hex",{get:function(){return"HEX"!==this.__state.space&&(this.__state.hex=e2.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 eg=function(){function e(t,n){jc(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 Xc(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}(),Xvt={HTMLEvents:["change"],MouseEvents:["click","mousemove","mousedown","mouseup","mouseover"],KeyboardEvents:["keydown"]},e1e={};Ht.each(Xvt,(function(e,t){Ht.each(e,(function(e){e1e[e]=t}))}));var Yvt=/(\d+(\.\d+)?)px/;function Zu(e){if("0"===e||Ht.isUndefined(e))return 0;var t=e.match(Yvt);return Ht.isNull(t)?0:parseFloat(t[1])}var yt={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;Ht.isUndefined(r)&&(r=!0),Ht.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=e1e[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;Ht.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)}Ht.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),yt},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),yt},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 yt},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 yt},hasClass:function(e,t){return new RegExp("(?:^|\\s+)"+t+"(?:\\s+|$)").test(e.className)||!1},getWidth:function(e){var t=getComputedStyle(e);return Zu(t["border-left-width"])+Zu(t["border-right-width"])+Zu(t["padding-left"])+Zu(t["padding-right"])+Zu(t.width)},getHeight:function(e){var t=getComputedStyle(e);return Zu(t["border-top-width"])+Zu(t["border-bottom-width"])+Zu(t["padding-top"])+Zu(t["padding-bottom"])+Zu(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)}},t1e=function(e){function t(e,n){jc(this,t);var i=$f(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"),yt.bind(i.__checkbox,"change",(function(){r.setValue(!r.__prev)}),!1),i.domElement.appendChild(i.__checkbox),i.updateDisplay(),i}return Yf(t,eg),Xc(t,[{key:"setValue",value:function(e){var n=Xf(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),Xf(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"updateDisplay",this).call(this)}}]),t}(),$vt=function(e){function t(e,n,i){jc(this,t);var r=$f(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n)),a=i,s=r;if(r.__select=document.createElement("select"),Ht.isArray(a)){var o={};Ht.each(a,(function(e){o[e]=e})),a=o}return Ht.each(a,(function(e,t){var n=document.createElement("option");n.innerHTML=t,n.setAttribute("value",e),s.__select.appendChild(n)})),r.updateDisplay(),yt.bind(r.__select,"change",(function(){var e=this.options[this.selectedIndex].value;s.setValue(e)})),r.domElement.appendChild(r.__select),r}return Yf(t,eg),Xc(t,[{key:"setValue",value:function(e){var n=Xf(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 yt.isActive(this.__select)?this:(this.__select.value=this.getValue(),Xf(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"updateDisplay",this).call(this))}}]),t}(),Zvt=function(e){function t(e,n){jc(this,t);var i=$f(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"),yt.bind(i.__input,"keyup",a),yt.bind(i.__input,"change",a),yt.bind(i.__input,"blur",(function(){r.__onFinishChange&&r.__onFinishChange.call(r,r.getValue())})),yt.bind(i.__input,"keydown",(function(e){13===e.keyCode&&this.blur()})),i.updateDisplay(),i.domElement.appendChild(i.__input),i}return Yf(t,eg),Xc(t,[{key:"updateDisplay",value:function(){return yt.isActive(this.__input)||(this.__input.value=this.getValue()),Xf(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"updateDisplay",this).call(this)}}]),t}();function Wve(e){var t=e.toString();return t.indexOf(".")>-1?t.length-t.indexOf(".")-1:0}var n1e=function(e){function t(e,n,i){jc(this,t);var r=$f(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,Ht.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=Wve(r.__impliedStep),r}return Yf(t,eg),Xc(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),Xf(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=Wve(e),this}}]),t}();function Kvt(e,t){var n=Math.pow(10,t);return Math.round(e*n)/n}var t2=function(e){function t(e,n,i){jc(this,t);var r=$f(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(){yt.unbind(window,"mousemove",l),yt.unbind(window,"mouseup",h),o()}return r.__input=document.createElement("input"),r.__input.setAttribute("type","text"),yt.bind(r.__input,"change",(function(){var e=parseFloat(a.__input.value);Ht.isNaN(e)||a.setValue(e)})),yt.bind(r.__input,"blur",(function(){o()})),yt.bind(r.__input,"mousedown",(function(e){yt.bind(window,"mousemove",l),yt.bind(window,"mouseup",h),s=e.clientY})),yt.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 Yf(t,n1e),Xc(t,[{key:"updateDisplay",value:function(){return this.__input.value=this.__truncationSuspended?this.getValue():Kvt(this.getValue(),this.__precision),Xf(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"updateDisplay",this).call(this)}}]),t}();function jve(e,t,n,i,r){return i+(e-t)/(n-t)*(r-i)}var k4=function(e){function t(e,n,i,r,a){jc(this,t);var s=$f(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(jve(e.clientX,t.left,t.right,o.__min,o.__max)),!1}function h(){yt.unbind(window,"mousemove",l),yt.unbind(window,"mouseup",h),o.__onFinishChange&&o.__onFinishChange.call(o,o.getValue())}function u(e){var t=e.touches[0].clientX,n=o.__background.getBoundingClientRect();o.setValue(jve(t,n.left,n.right,o.__min,o.__max))}function c(){yt.unbind(window,"touchmove",u),yt.unbind(window,"touchend",c),o.__onFinishChange&&o.__onFinishChange.call(o,o.getValue())}return s.__background=document.createElement("div"),s.__foreground=document.createElement("div"),yt.bind(s.__background,"mousedown",(function(e){document.activeElement.blur(),yt.bind(window,"mousemove",l),yt.bind(window,"mouseup",h),l(e)})),yt.bind(s.__background,"touchstart",(function(e){1===e.touches.length&&(yt.bind(window,"touchmove",u),yt.bind(window,"touchend",c),u(e))})),yt.addClass(s.__background,"slider"),yt.addClass(s.__foreground,"slider-fg"),s.updateDisplay(),s.__background.appendChild(s.__foreground),s.domElement.appendChild(s.__background),s}return Yf(t,n1e),Xc(t,[{key:"updateDisplay",value:function(){var e=(this.getValue()-this.__min)/(this.__max-this.__min);return this.__foreground.style.width=100*e+"%",Xf(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"updateDisplay",this).call(this)}}]),t}(),r1e=function(e){function t(e,n,i){jc(this,t);var r=$f(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,yt.bind(r.__button,"click",(function(e){return e.preventDefault(),a.fire(),!1})),yt.addClass(r.__button,"button"),r.domElement.appendChild(r.__button),r}return Yf(t,eg),Xc(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}(),F4=function(e){function t(e,n){jc(this,t);var i=$f(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n));i.__color=new $s(i.getValue()),i.__temp=new $s(0);var r=i;i.domElement=document.createElement("div"),yt.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 ",yt.bind(i.__input,"keydown",(function(e){13===e.keyCode&&u.call(this)})),yt.bind(i.__input,"blur",u),yt.bind(i.__selector,"mousedown",(function(){yt.addClass(this,"drag").bind(window,"mouseup",(function(){yt.removeClass(r.__selector,"drag")}))})),yt.bind(i.__selector,"touchstart",(function(){yt.addClass(this,"drag").bind(window,"touchend",(function(){yt.removeClass(r.__selector,"drag")}))}));var a=document.createElement("div");function s(e){d(e),yt.bind(window,"mousemove",d),yt.bind(window,"touchmove",d),yt.bind(window,"mouseup",l),yt.bind(window,"touchend",l)}function o(e){p(e),yt.bind(window,"mousemove",p),yt.bind(window,"touchmove",p),yt.bind(window,"mouseup",h),yt.bind(window,"touchend",h)}function l(){yt.unbind(window,"mousemove",d),yt.unbind(window,"touchmove",d),yt.unbind(window,"mouseup",l),yt.unbind(window,"touchend",l),c()}function h(){yt.unbind(window,"mousemove",p),yt.unbind(window,"touchmove",p),yt.unbind(window,"mouseup",h),yt.unbind(window,"touchend",h),c()}function u(){var e=O4(this.value);!1!==e?(r.__color.__state=e,r.setValue(r.__color.toOriginal())):this.value=r.__color.toString()}function c(){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 Ht.extend(i.__selector.style,{width:"122px",height:"102px",padding:"3px",backgroundColor:"#222",boxShadow:"0px 1px 3px rgba(0,0,0,0.3)"}),Ht.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}),Ht.extend(i.__hue_knob.style,{position:"absolute",width:"15px",height:"2px",borderRight:"4px solid #fff",zIndex:1}),Ht.extend(i.__saturation_field.style,{width:"100px",height:"100px",border:"1px solid #555",marginRight:"3px",display:"inline-block",cursor:"pointer"}),Ht.extend(a.style,{width:"100%",height:"100%",background:"none"}),Xve(a,"top","rgba(0,0,0,0)","#000"),Ht.extend(i.__hue_field.style,{width:"15px",height:"100px",border:"1px solid #555",cursor:"ns-resize",position:"absolute",top:"3px",right:"3px"}),Qvt(i.__hue_field),Ht.extend(i.__input.style,{outline:"none",textAlign:"center",color:"#fff",border:0,fontWeight:"bold",textShadow:i.__input_textShadow+"rgba(0,0,0,0.7)"}),yt.bind(i.__saturation_field,"mousedown",s),yt.bind(i.__saturation_field,"touchstart",s),yt.bind(i.__field_knob,"mousedown",s),yt.bind(i.__field_knob,"touchstart",s),yt.bind(i.__hue_field,"mousedown",o),yt.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 Yf(t,eg),Xc(t,[{key:"updateDisplay",value:function(){var e=O4(this.getValue());if(!1!==e){var t=!1;Ht.each($s.COMPONENTS,(function(n){if(!Ht.isUndefined(e[n])&&!Ht.isUndefined(this.__color.__state[n])&&e[n]!==this.__color.__state[n])return t=!0,{}}),this),t&&Ht.extend(this.__color.__state,e)}Ht.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;Ht.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,Xve(this.__saturation_field,"left","#fff",this.__temp.toHexString()),this.__input.value=this.__color.toString(),Ht.extend(this.__input.style,{backgroundColor:this.__color.toHexString(),color:"rgb("+n+","+n+","+n+")",textShadow:this.__input_textShadow+"rgba("+i+","+i+","+i+",.7)"})}}]),t}(),Jvt=["-moz-","-o-","-webkit-","-ms-",""];function Xve(e,t,n,i){e.style.background="",Ht.each(Jvt,(function(r){e.style.cssText+="background: "+r+"linear-gradient("+t+", "+n+" 0%, "+i+" 100%); "}))}function Qvt(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 e1t={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){}}},t1t='<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>',n1t=function(e,t){var n=e[t];return Ht.isArray(arguments[2])||Ht.isObject(arguments[2])?new $vt(e,t,arguments[2]):Ht.isNumber(n)?Ht.isNumber(arguments[2])&&Ht.isNumber(arguments[3])?Ht.isNumber(arguments[4])?new k4(e,t,arguments[2],arguments[3],arguments[4]):new k4(e,t,arguments[2],arguments[3]):Ht.isNumber(arguments[4])?new t2(e,t,{min:arguments[2],max:arguments[3],step:arguments[4]}):new t2(e,t,{min:arguments[2],max:arguments[3]}):Ht.isString(n)?new Zvt(e,t):Ht.isFunction(n)?new r1e(e,t,""):Ht.isBoolean(n)?new t1e(e,t):null};function r1t(e){setTimeout(e,1e3/60)}var i1t=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||r1t,s1t=function(){function e(){jc(this,e),this.backgroundElement=document.createElement("div"),Ht.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"}),yt.makeFullscreen(this.backgroundElement),this.backgroundElement.style.position="fixed",this.domElement=document.createElement("div"),Ht.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;yt.bind(this.backgroundElement,"click",(function(){t.hide()}))}return Xc(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(),Ht.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",yt.unbind(e.domElement,"webkitTransitionEnd",t),yt.unbind(e.domElement,"transitionend",t),yt.unbind(e.domElement,"oTransitionEnd",t)};yt.bind(this.domElement,"webkitTransitionEnd",t),yt.bind(this.domElement,"transitionend",t),yt.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-yt.getWidth(this.domElement)/2+"px",this.domElement.style.top=window.innerHeight/2-yt.getHeight(this.domElement)/2+"px"}}]),e}(),a1t=qvt(".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");e1t.inject(a1t);var Yve="dg",$ve=72,Zve=20,y_="Default",m_=function(){try{return!!window.localStorage}catch(e){return!1}}(),g_=void 0,Kve=!0,T1=void 0,D4=!1,i1e=[],Fi=function e(t){var n=this,i=t||{};this.domElement=document.createElement("div"),this.__ul=document.createElement("ul"),this.domElement.appendChild(this.__ul),yt.addClass(this.domElement,Yve),this.__folders={},this.__controllers=[],this.__rememberedObjects=[],this.__rememberedObjectIndecesToControllers=[],this.__listening=[],i=Ht.defaults(i,{closeOnTop:!1,autoPlace:!0,width:e.DEFAULT_WIDTH}),i=Ht.defaults(i,{resizable:i.autoPlace,hideable:i.autoPlace}),Ht.isUndefined(i.load)?i.load={preset:y_}:i.preset&&(i.load.preset=i.preset),Ht.isUndefined(i.parent)&&i.hideable&&i1e.push(this),i.resizable=Ht.isUndefined(i.parent)&&i.resizable,i.autoPlace&&Ht.isUndefined(i.scrollable)&&(i.scrollable=!0);var r,a=m_&&"true"===localStorage.getItem(w1(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,u1t(this),n.revert()}},width:{get:function(){return i.width},set:function(e){i.width=e,U4(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?yt.addClass(n.__ul,e.CLASS_CLOSED):yt.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){m_&&(a=e,e?yt.bind(window,"unload",s):yt.unbind(window,"unload",s),localStorage.setItem(w1(n,"isLocal"),e))}}}),Ht.isUndefined(i.parent)){if(this.closed=i.closed||!1,yt.addClass(this.domElement,e.CLASS_MAIN),yt.makeSelectable(this.domElement,!1),m_&&a){n.useLocalStorage=!0;var l=localStorage.getItem(w1(this,"gui"));l&&(i.load=JSON.parse(l))}this.__closeButton=document.createElement("div"),this.__closeButton.innerHTML=e.TEXT_CLOSED,yt.addClass(this.__closeButton,e.CLASS_CLOSE_BUTTON),i.closeOnTop?(yt.addClass(this.__closeButton,e.CLASS_CLOSE_TOP),this.domElement.insertBefore(this.__closeButton,this.domElement.childNodes[0])):(yt.addClass(this.__closeButton,e.CLASS_CLOSE_BOTTOM),this.domElement.appendChild(this.__closeButton)),yt.bind(this.__closeButton,"click",(function(){n.closed=!n.closed}))}else{void 0===i.closed&&(i.closed=!0);var h=document.createTextNode(i.name);yt.addClass(h,"controller-name"),o=z4(n,h),yt.addClass(this.__ul,e.CLASS_CLOSED),yt.addClass(o,"title"),yt.bind(o,"click",(function(e){return e.preventDefault(),n.closed=!n.closed,!1})),i.closed||(this.closed=!1)}i.autoPlace&&(Ht.isUndefined(i.parent)&&(Kve&&(T1=document.createElement("div"),yt.addClass(T1,Yve),yt.addClass(T1,e.CLASS_AUTO_PLACE_CONTAINER),document.body.appendChild(T1),Kve=!1),T1.appendChild(this.domElement),yt.addClass(this.domElement,e.CLASS_AUTO_PLACE)),this.parent||U4(n,i.width)),this.__resizeHandler=function(){n.onResizeDebounced()},yt.bind(window,"resize",this.__resizeHandler),yt.bind(this.__ul,"webkitTransitionEnd",this.__resizeHandler),yt.bind(this.__ul,"transitionend",this.__resizeHandler),yt.bind(this.__ul,"oTransitionEnd",this.__resizeHandler),this.onResize(),i.resizable&&c1t(this),s=function(){m_&&"true"===localStorage.getItem(w1(n,"isLocal"))&&localStorage.setItem(w1(n,"gui"),JSON.stringify(n.getSaveObject()))},this.saveToLocalStorageIfPossible=s,i.parent||((r=n.getRoot()).width+=1,Ht.defer((function(){r.width-=1})))};function z4(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 Jve(e){yt.unbind(window,"resize",e.__resizeHandler),e.saveToLocalStorageIfPossible&&yt.unbind(window,"unload",e.saveToLocalStorageIfPossible)}function N4(e,t){var n=e.__preset_select[e.__preset_select.selectedIndex];n.innerHTML=t?n.value+"*":n.value}function o1t(e,t,n){if(n.__li=t,n.__gui=e,Ht.extend(n,{options:function(t){if(arguments.length>1){var i=n.__li.nextElementSibling;return n.remove(),v_(e,n.object,n.property,{before:i,factoryArgs:[Ht.toArray(arguments)]})}if(Ht.isArray(t)||Ht.isObject(t)){var r=n.__li.nextElementSibling;return n.remove(),v_(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 k4){var i=new t2(n.object,n.property,{min:n.__min,max:n.__max,step:n.__step});Ht.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)}})),yt.addClass(t,"has-slider"),n.domElement.insertBefore(i.domElement,n.domElement.firstElementChild)}else if(n instanceof t2){var r=function(t){if(Ht.isNumber(n.__min)&&Ht.isNumber(n.__max)){var i=n.__li.firstElementChild.firstElementChild.innerHTML,r=n.__gui.__listening.indexOf(n)>-1;n.remove();var a=v_(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=Ht.compose(r,n.min),n.max=Ht.compose(r,n.max)}else n instanceof t1e?(yt.bind(t,"click",(function(){yt.fakeEvent(n.__checkbox,"click")})),yt.bind(n.__checkbox,"click",(function(e){e.stopPropagation()}))):n instanceof r1e?(yt.bind(t,"click",(function(){yt.fakeEvent(n.__button,"click")})),yt.bind(t,"mouseover",(function(){yt.addClass(n.__button,"hover")})),yt.bind(t,"mouseout",(function(){yt.removeClass(n.__button,"hover")}))):n instanceof F4&&(yt.addClass(t,"color"),n.updateDisplay=Ht.compose((function(e){return t.style.borderLeftColor=n.__color.toString(),e}),n.updateDisplay),n.updateDisplay());n.setValue=Ht.compose((function(t){return e.getRoot().__preset_select&&n.isModified()&&N4(e.getRoot(),!0),t}),n.setValue)}function s1e(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[y_])return;s=a[y_]}if(s[i]&&void 0!==s[i][t.property]){var o=s[i][t.property];t.initialValue=o,t.setValue(o)}}}}function v_(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 F4(t,n);else{var a=[t,n].concat(i.factoryArgs);r=n1t.apply(e,a)}i.before instanceof eg&&(i.before=i.before.__li),s1e(e,r),yt.addClass(r.domElement,"c");var s=document.createElement("span");yt.addClass(s,"property-name"),s.innerHTML=r.property;var o=document.createElement("div");o.appendChild(s),o.appendChild(r.domElement);var l=z4(e,o,i.before);return yt.addClass(l,Fi.CLASS_CONTROLLER_ROW),r instanceof F4?yt.addClass(l,"color"):yt.addClass(l,jvt(r.getValue())),o1t(e,l,r),e.__controllers.push(r),r}function w1(e,t){return document.location.href+"."+t}function B4(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 Qve(e,t){t.style.display=e.useLocalStorage?"block":"none"}function l1t(e){var t=e.__save_row=document.createElement("li");yt.addClass(e.domElement,"has-save"),e.__ul.insertBefore(t,e.__ul.firstChild),yt.addClass(t,"save-row");var n=document.createElement("span");n.innerHTML=" ",yt.addClass(n,"button gears");var i=document.createElement("span");i.innerHTML="Save",yt.addClass(i,"button"),yt.addClass(i,"save");var r=document.createElement("span");r.innerHTML="New",yt.addClass(r,"button"),yt.addClass(r,"save-as");var a=document.createElement("span");a.innerHTML="Revert",yt.addClass(a,"button"),yt.addClass(a,"revert");var s=e.__preset_select=document.createElement("select");if(e.load&&e.load.remembered?Ht.each(e.load.remembered,(function(t,n){B4(e,n,n===e.preset)})):B4(e,y_,!1),yt.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),m_){var o=document.getElementById("dg-local-explain"),l=document.getElementById("dg-local-storage");document.getElementById("dg-save-locally").style.display="block","true"===localStorage.getItem(w1(e,"isLocal"))&&l.setAttribute("checked","checked"),Qve(e,o),yt.bind(l,"change",(function(){e.useLocalStorage=!e.useLocalStorage,Qve(e,o)}))}var h=document.getElementById("dg-new-constructor");yt.bind(h,"keydown",(function(e){e.metaKey&&(67===e.which||67===e.keyCode)&&g_.hide()})),yt.bind(n,"click",(function(){h.innerHTML=JSON.stringify(e.getSaveObject(),void 0,2),g_.show(),h.focus(),h.select()})),yt.bind(i,"click",(function(){e.save()})),yt.bind(r,"click",(function(){var t=prompt("Enter a new preset name.");t&&e.saveAs(t)})),yt.bind(a,"click",(function(){e.revert()}))}function c1t(e){var t=void 0;function n(n){return n.preventDefault(),e.width+=t-n.clientX,e.onResize(),t=n.clientX,!1}function i(){yt.removeClass(e.__closeButton,Fi.CLASS_DRAG),yt.unbind(window,"mousemove",n),yt.unbind(window,"mouseup",i)}function r(r){return r.preventDefault(),t=r.clientX,yt.addClass(e.__closeButton,Fi.CLASS_DRAG),yt.bind(window,"mousemove",n),yt.bind(window,"mouseup",i),!1}e.__resize_handle=document.createElement("div"),Ht.extend(e.__resize_handle.style,{width:"6px",marginLeft:"-3px",height:"200px",cursor:"ew-resize",position:"absolute"}),yt.bind(e.__resize_handle,"mousedown",r),yt.bind(e.__closeButton,"mousedown",r),e.domElement.insertBefore(e.__resize_handle,e.domElement.firstElementChild)}function U4(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 QP(e,t){var n={};return Ht.each(e.__rememberedObjects,(function(i,r){var a={},s=e.__rememberedObjectIndecesToControllers[r];Ht.each(s,(function(e,n){a[n]=t?e.initialValue:e.getValue()})),n[r]=a})),n}function u1t(e){for(var t=0;t<e.__preset_select.length;t++)e.__preset_select[t].value===e.preset&&(e.__preset_select.selectedIndex=t)}function a1e(e){0!==e.length&&i1t.call(window,(function(){a1e(e)})),Ht.each(e,(function(e){e.updateDisplay()}))}Fi.toggleHide=function(){D4=!D4,Ht.each(i1e,(function(e){e.domElement.style.display=D4?"none":""}))},Fi.CLASS_AUTO_PLACE="a",Fi.CLASS_AUTO_PLACE_CONTAINER="ac",Fi.CLASS_MAIN="main",Fi.CLASS_CONTROLLER_ROW="cr",Fi.CLASS_TOO_TALL="taller-than-window",Fi.CLASS_CLOSED="closed",Fi.CLASS_CLOSE_BUTTON="close-button",Fi.CLASS_CLOSE_TOP="close-top",Fi.CLASS_CLOSE_BOTTOM="close-bottom",Fi.CLASS_DRAG="drag",Fi.DEFAULT_WIDTH=245,Fi.TEXT_CLOSED="Close Controls",Fi.TEXT_OPEN="Open Controls",Fi._keydownHandler=function(e){"text"!==document.activeElement.type&&(e.which===$ve||e.keyCode===$ve)&&Fi.toggleHide()},yt.bind(window,"keydown",Fi._keydownHandler,!1),Ht.extend(Fi.prototype,{add:function(e,t){return v_(this,e,t,{factoryArgs:Array.prototype.slice.call(arguments,2)})},addColor:function(e,t){return v_(this,e,t,{color:!0})},remove:function(e){this.__ul.removeChild(e.__li),this.__controllers.splice(this.__controllers.indexOf(e),1);var t=this;Ht.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&&T1.removeChild(this.domElement);var e=this;Ht.each(this.__folders,(function(t){e.removeFolder(t)})),yt.unbind(window,"keydown",Fi._keydownHandler,!1),Jve(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 Fi(t);this.__folders[e]=n;var i=z4(this,n.domElement);return yt.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],Jve(e);var t=this;Ht.each(e.__folders,(function(t){e.removeFolder(t)})),Ht.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=yt.getOffset(e.__ul).top,n=0;Ht.each(e.__ul.childNodes,(function(t){e.autoPlace&&t===e.__save_row||(n+=yt.getHeight(t))})),window.innerHeight-t-Zve<n?(yt.addClass(e.domElement,Fi.CLASS_TOO_TALL),e.__ul.style.height=window.innerHeight-t-Zve+"px"):(yt.removeClass(e.domElement,Fi.CLASS_TOO_TALL),e.__ul.style.height="auto")}e.__resize_handle&&Ht.defer((function(){e.__resize_handle.style.height=e.__ul.offsetHeight+"px"})),e.__closeButton&&(e.__closeButton.style.width=e.width+"px")},onResizeDebounced:Ht.debounce((function(){this.onResize()}),50),remember:function(){if(Ht.isUndefined(g_)&&((g_=new s1t).domElement.innerHTML=t1t),this.parent)throw new Error("You can only call remember on a top level GUI.");var e=this;Ht.each(Array.prototype.slice.call(arguments),(function(t){0===e.__rememberedObjects.length&&l1t(e),-1===e.__rememberedObjects.indexOf(t)&&e.__rememberedObjects.push(t)})),this.autoPlace&&U4(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]=QP(this)),e.folders={},Ht.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]=QP(this),N4(this,!1),this.saveToLocalStorageIfPossible()},saveAs:function(e){this.load.remembered||(this.load.remembered={},this.load.remembered[y_]=QP(this,!0)),this.load.remembered[e]=QP(this),this.preset=e,B4(this,e,!0),this.saveToLocalStorageIfPossible()},revert:function(e){Ht.each(this.__controllers,(function(t){this.getRoot().load.remembered?s1e(e||this.getRoot(),t):t.setValue(t.initialValue),t.__onFinishChange&&t.__onFinishChange.call(t,t.getValue())}),this),Ht.each(this.__folders,(function(e){e.revert(e)})),e||N4(this.getRoot(),!1)},listen:function(e){var t=0===this.__listening.length;this.__listening.push(e),t&&a1e(this.__listening)},updateDisplay:function(){Ht.each(this.__controllers,(function(e){e.updateDisplay()})),Ht.each(this.__folders,(function(e){e.updateDisplay()}))}});var o1e=Fi,l1e=[["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"]],cd=(()=>{if("undefined"==typeof document)return!1;let e=l1e[0],t={};for(let n of l1e)if((null==n?void 0:n[1])in document){for(let[i,r]of n.entries())t[e[i]]=r;return t}return!1})(),c1e={change:cd.fullscreenchange,error:cd.fullscreenerror},Qo={request:(e=document.documentElement,t)=>new Promise(((n,i)=>{let r=()=>{Qo.off("change",r),n()};Qo.on("change",r);let a=e[cd.requestFullscreen](t);a instanceof Promise&&a.then(r).catch(i)})),exit:()=>new Promise(((e,t)=>{if(!Qo.isFullscreen)return void e();let n=()=>{Qo.off("change",n),e()};Qo.on("change",n);let i=document[cd.exitFullscreen]();i instanceof Promise&&i.then(n).catch(t)})),toggle:(e,t)=>Qo.isFullscreen?Qo.exit():Qo.request(e,t),onchange(e){Qo.on("change",e)},onerror(e){Qo.on("error",e)},on(e,t){let n=c1e[e];n&&document.addEventListener(n,t,!1)},off(e,t){let n=c1e[e];n&&document.removeEventListener(n,t,!1)},raw:cd};Object.defineProperties(Qo,{isFullscreen:{get:()=>Boolean(document[cd.fullscreenElement])},element:{enumerable:!0,get:()=>{var e;return null!=(e=document[cd.fullscreenElement])?e:void 0}},isEnabled:{enumerable:!0,get:()=>Boolean(document[cd.fullscreenEnabled])}}),cd||(Qo={isEnabled:!1});var n2=Qo,r2=new k,i2=class{constructor(e,t,n=void 0){this.scale=1,this.explodeUp=!1,this.scene=e,this.objectId=t,t||fe.debug(`[EXP] Invalid objectId: ${t}`),n?this.explodeCenter=n:(this.explodeCenter=new k,this.getObjectCenter(this.explodeCenter));let i=this.scene.getObjectById(this.objectId);null==i||i.updateWorldMatrix(!0,!0)}explode(e){if(this.scale=e,!this.objectId||!this.explodeCenter||!this.scale)return void fe.debug(`[EXP] Invalid objectId: ${this.objectId}, or position: ${this.explodeCenter}, or this.power: ${this.scale}`);let t=this.scene.getObjectById(this.objectId);t&&t.children?(fe.debug(`[EXP] Exploding object '${t.name}'(id: ${t.id}) at: ${Pt.vectorToString(this.explodeCenter)}`),this.explodeObject(t)):fe.debug("[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){var t;let n=e;if(!n.geometry)return;n.userData.originalMatrixWorld||(n.userData.originalMatrixWorld=n.matrixWorld);let i=n.userData.originalMatrixWorld;n.userData.originalCenter||(n.geometry.boundingBox||n.geometry.computeBoundingBox(),r2.set(0,0,0),null==(t=n.geometry.boundingBox)||t.getCenter(r2),r2.applyMatrix4(n.matrixWorld),n.userData.originalCenter=r2.clone());let r=n.userData.originalCenter.clone();r.sub(this.explodeCenter),r.multiplyScalar(this.scale-1),this.explodeUp&&(r.setX(0),r.setZ(0));let a=new ht;a.setPosition(r),a.multiply(i),n.matrixWorld=a,n.children.length>0&&n.children.forEach((e=>e.updateMatrix()))}unexplode(){let e=this.scene.getObjectById(this.objectId);e&&e.children?(fe.debug(`[EXP] Unexploding '${e.name}'(id: ${e.id}) at: ${Pt.vectorToString(this.explodeCenter)}`),this.unexplodeObject(e)):fe.debug("[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.originalMatrixWorld;t&&(e.matrixWorld=t,e.children.length>0&&e.children.forEach((e=>e.updateMatrix())))}setExplodeUp(e){this.explodeUp=e}getObjectCenter(e){let t=new Nt;if(!this.objectId)return void fe.debug(`[EXP] Invalid objectId: ${this.objectId}`);let n=this.scene.getObjectById(this.objectId);n&&n.children?(n.traverse((e=>{t.expandByObject(e)})),t.getCenter(e)):fe.debug("[EXP] No children to explode!")}},G4=class extends ar{constructor(e,t){super(e,{id:(null==t?void 0:t.id)||G4.DEFAULT_ID}),this.exploders=[],this.onModelLoaded=()=>{this.init()},this.viewer=e,this.cfg=t||{},this.viewer.addEventListener("ModelLoaded",this.onModelLoaded)}get scene(){return this.viewer.scene}init(){this.viewer.loadedModels.forEach((e=>{if(this.hasExploderForModel(e.getModelObject().id))return;let t=new k;if(this.cfg.explodeCenter){let e=this.cfg.explodeCenter;t.set(e.x,e.y,e.z)}else!this.cfg.explodeCenter&&!e.getBBox().isEmpty()&&e.getBBox().getCenter(t);let n=new i2(this.scene,e.getModelObject().id,t);n.setExplodeUp(!!this.cfg.explodeUp),this.exploders.push(n)}))}explode(e){0===this.exploders.length&&this.init();for(let t of this.exploders)t.explode(e),this.viewer.enableRender()}unexplode(){for(let e of this.exploders)e.unexplode(),this.viewer.enableRender()}hasExploderForModel(e){return!!this.exploders.find((t=>t.objectId===e))}destroy(){super.destroy(),this.viewer.removeEventListener("ModelLoaded",this.onModelLoaded),this.unexplode()}},x_=G4;x_.DEFAULT_ID="ExplodePlugin";var q4=class extends ar{constructor(e,t){super(e,{id:(null==t?void 0:t.id)||q4.DEFAULT_ID}),this.NAME="GROUND_GRASS",this.DEFAULT_SIZE=1e3,this.DEFAULT_REPEAT=20,this.onModelLoaded=()=>{!1!==this.cfg.visible&&(this.init(),this.viewer.enableRender())},this.cfg=t||{},!1!==this.cfg.visible&&this.init(),this.viewer.addEventListener("ModelLoaded",this.onModelLoaded)}init(){var e;this.groundGrass&&(null==(e=this.viewer.scene)||e.remove(this.groundGrass),this.groundGrass=void 0);let t=this.cfg.texture||"images/terrain/grass.jpg",n=this.cfg.width||this.DEFAULT_SIZE,i=this.cfg.height||this.DEFAULT_SIZE,r=this.cfg.repeatX||this.DEFAULT_REPEAT,a=this.cfg.repeatY||this.DEFAULT_REPEAT,s=new k,o=this.viewer.getBBox();o&&o.getCenter(s),it(this,null,(function*(){var e;this.groundGrass=yield this.createGrassGround(t,n,i,r,a),null==(e=this.viewer.scene)||e.add(this.groundGrass),this.viewer.enableRender()}))}setVisible(e){e&&!this.groundGrass&&this.init(),this.groundGrass&&(this.groundGrass.visible=e),this.viewer.enableRender()}createGrassGround(e,t,n,i,r){return it(this,null,(function*(){return new Promise((a=>{(new ws).load(e,(e=>{e.wrapS=e.wrapT=Ii,e.repeat.set(i,r),e.anisotropy=16,e.encoding=xu;let s=new Ru({map:e});s.side=hi;let o=new St(new mi(t,n),s);return o.rotation.x=-Math.PI/2,o.position.y=0,o.receiveShadow=!0,o.name=this.NAME,o.layers.enableAll(),o.layers.disable(12),o.matrixAutoUpdate=!1,o.updateMatrix(),o.updateMatrixWorld(!0),a(o)}))}))}))}destroy(){super.destroy(),this.groundGrass&&(this.groundGrass.removeFromParent(),this.groundGrass.geometry.dispose(),this.groundGrass.clear(),this.groundGrass=void 0),this.viewer.removeEventListener("ModelLoaded",this.onModelLoaded)}},b_=q4;b_.DEFAULT_ID="GroundGrassPlugin";var W4=class extends ar{constructor(e,t){super(e,{id:(null==t?void 0:t.id)||W4.DEFAULT_ID}),this.NAME="GROUND_GRID",this.DEFAULT_SIZE=1e3,this.DEFAULT_DIVISIONS=100,this.DEFAULT_MAT_PARAMS={color:12829635,transparent:!0,opacity:.5,wireframeLinewidth:.5},this.onModelLoaded=()=>{!1!==this.cfg.visible&&(this.init(),this.viewer.enableRender())},this.cfg=t||{},!1!==this.cfg.visible&&this.init(),this.viewer.addEventListener("ModelLoaded",this.onModelLoaded)}init(){var e,t;this.gridHelper&&(null==(e=this.viewer.scene)||e.remove(this.gridHelper),this.gridHelper=void 0);let n=this.cfg.size,i=this.cfg.divisions,r=new k,a=this.viewer.getBBox();a&&a.getCenter(r),this.gridHelper=this.createGroundGrid(n,i,r),null==(t=this.viewer.scene)||t.add(this.gridHelper),this.viewer.enableRender()}setVisible(e){e&&!this.gridHelper&&this.init(),this.gridHelper&&(this.gridHelper.visible=e),this.viewer.enableRender()}createGroundGrid(e,t,n){e=e||this.DEFAULT_SIZE,t=t||this.DEFAULT_DIVISIONS;let i=new mb(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.NAME,i.layers.enableAll(),i.layers.disable(12),i.matrixAutoUpdate=!1,i.updateMatrix(),i}destroy(){super.destroy(),this.gridHelper&&(this.gridHelper.removeFromParent(),this.gridHelper.geometry.dispose(),this.gridHelper.clear(),this.gridHelper=void 0),this.viewer.removeEventListener("ModelLoaded",this.onModelLoaded)}},E_=W4;E_.DEFAULT_ID="GroundGridPlugin";var j4=class extends ar{constructor(e,t){super(e,{id:(null==t?void 0:t.id)||j4.DEFAULT_ID}),this.originalBackground=void 0,this.originalClearAlpha=1,this.cfg=t||{},this.cfg.type=this.cfg.type||"image/png",this.cfg.quality=this.cfg.quality||.8,this.cfg.setBackgroundTransparent=this.cfg.setBackgroundTransparent||!1}getScreenshot(){var e;let t=null==(e=this.viewer.renderer)?void 0:e.domElement;if(!t)return;this.setBackgroundTransparent();let n=t.toDataURL(this.cfg.type,this.cfg.quality);return this.recoverBackgroundTransparency(),n}getScreenshotByScreenBBox(e){return it(this,null,(function*(){let t=this.viewer.renderer.domElement,n=t.width,i=t.height,r=e.min.x,a=e.min.y,s=e.max.x,o=e.max.y;if(r=Math.max(r,0),r=Math.min(r,n),a=Math.max(a,0),a=Math.min(a,i),s=Math.min(s||n,n),s=Math.max(s,0),o=Math.min(o||i,i),o=Math.max(o,0),0===Math.abs(s-r)||0===Math.abs(o-a))return void fe.error(`[Screenshot] Invalid input, minX: ${r}, minY: ${a}, maxX: ${s}, maxY: ${o}`);let l=new _i;l.expandByPoint(new _e(r,a)),l.expandByPoint(new _e(s,o)),this.setBackgroundTransparent();let h=yield Pt.canvasToImage(t);this.recoverBackgroundTransparency();let u=document.createElement("canvas");u.width=t.width,u.height=t.height;let c=window.devicePixelRatio,d=u.getContext("2d");return d.drawImage(h,0,0,h.width/c,h.height/c),Pt.renderingContextToImage(d,l,this.cfg.type,this.cfg.quality)}))}getScreenshotByWorldBBox(e){return it(this,null,(function*(){let t=this.viewer.camera,n=this.viewer.container.viewerContainer,i=Sn.worldBBox2Screen(e,t,n);return this.getScreenshotByScreenBBox(i)}))}getScreenshotAsync(){return it(this,arguments,(function*(e="BoxSelection"){this.cancel();let t,n=this.viewer,i=n.renderer.domElement;if("PickMarkup"===e?(this.pickMarkupHelper||(this.pickMarkupHelper=new wP(n)),t=yield this.pickMarkupHelper.pick()):"BoxSelection"===e&&(this.boxSelectHelper||(this.boxSelectHelper=new zf(n)),t=yield this.boxSelectHelper.select()),"Default"!==e&&!t)return;this.setBackgroundTransparent();let r=yield Pt.canvasToImage(i);this.recoverBackgroundTransparency();let a=document.createElement("canvas"),s=window.devicePixelRatio;a.width=i.width/s,a.height=i.height/s;let o=a.getContext("2d");if(o.drawImage(r,0,0,r.width/s,r.height/s),n.overlayRender){let e=yield n.overlayRender.getImage((e=>e instanceof Fr||e instanceof ki));o.drawImage(e,0,0,e.width/s,e.height/s)}let l=this.cfg.type,h=this.cfg.quality,u=Pt.renderingContextToImage(o,t,l,h);return n instanceof jf?{base64Image:u,viewExtent:n.getCurrentViewExtent(),imageType:l}:{base64Image:u,imageType:l}}))}isActive(){var e,t;return(null==(e=this.boxSelectHelper)?void 0:e.isActive)||(null==(t=this.pickMarkupHelper)?void 0:t.isActive)}cancel(){var e,t;null!=(e=this.boxSelectHelper)&&e.isActive&&this.boxSelectHelper.deactivate(),null!=(t=this.pickMarkupHelper)&&t.isActive&&this.pickMarkupHelper.deactivate()}setBackgroundTransparent(){if(!this.cfg.setBackgroundTransparent)return;let e=this.viewer,t=e.scene,n=e.renderer,i=this.viewer.camera;this.originalBackground=t.background,this.originalClearAlpha=n.getClearAlpha(),t.background=null,n.setClearAlpha(0),n.render(t,i)}recoverBackgroundTransparency(){if(!this.cfg.setBackgroundTransparent)return;let e=this.viewer,t=e.scene,n=e.renderer,i=this.viewer.camera;t.background=this.originalBackground,n.setClearAlpha(this.originalClearAlpha),n.render(t,i),this.originalBackground=void 0,this.originalClearAlpha=1}},Zf=j4;Zf.DEFAULT_ID="ScreenshotPlugin";var $a=new k(1,0,0),Kf=new k(0,1,0),Jf=new k(0,0,1),u1e=new k(0,1,0),__=new ht,M1=2,So=class extends Bn{constructor(e=$a){super(),this.redMaterial=new cn({color:16711680,depthTest:!1}),this.greenMaterial=new cn({color:65280,depthTest:!1}),this.blueMaterial=new cn({color:255,depthTest:!1}),this.highlightMaterial=new cn({color:16776960,depthTest:!1}),this.pickableMaterial=new cn({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 _r;t.setFromUnitVectors($a,e),this.applyQuaternion(t)}initOrUpdateByAxis(e){this.clear(),[{actionType:"TranslateX",direction:$a,material:this.redMaterial},{actionType:"TranslateY",direction:Kf,material:this.greenMaterial},{actionType:"TranslateZ",direction:Jf,material:this.blueMaterial}].forEach((t=>{let{actionType:n,direction:i,material:r}=t,a=this.createTranslateGizmo(n,i,M1,0===i.angleTo(e)?r:this.pickableMaterial);this.add(a)})),[{actionType:"RotateX",direction:$a,material:this.redMaterial,degree:90},{actionType:"RotateY",direction:Kf,material:this.greenMaterial,degree:90},{actionType:"RotateZ",direction:Jf,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,M1,r,a);this.add(e)}})),this.createSphere(1,this.pickableMaterial),this.createSphere(1,this.pickableMaterial,new k(12*M1,0,0)),this.createSphere(1,this.pickableMaterial,new k(0,12*M1,0)),this.createSphere(1,this.pickableMaterial,new k(0,0,12*M1))}createTranslateGizmo(e,t,n,i){let r=t.angleTo(u1e),a=u1e.clone().cross(t);__.makeRotationAxis(a,r);let s=new Sc(n/5,n/5,20*n),o=10*n;s.translate(0,o,0),s.applyMatrix4(__);let l=new Sc(0,n,3*n),h=2*o;l.translate(0,h,0),l.applyMatrix4(__);let u=Oi([l,s]),c=new St(u,i);return c.layers.enable(12),c.userData.actionType=e,i===this.pickableMaterial&&c.layers.disable(12),c}createRotateGizmo(e,t,n,i,r){let a=new k(0,0,1),s=t.clone().cross(a),o=t.angleTo(a);__.makeRotationAxis(s,o);let l=new ef(12*n,n/5,24,36,Un.degToRad(r));l.applyMatrix4(__);let h=new St(l,i);return h.layers.enable(12),h.userData.actionType=e,h}createSphere(e,t,n=new k){let i=new Va(e,32,16),r=new St(i,t);r.position.copy(n),r.layers.disable(12),this.add(r)}setActiveAxis(e){this.initOrUpdateByAxis(e)}createHoverRotateObjectByAxis(e){let t=$a;switch(e){case"RotateX":t=$a;break;case"RotateY":t=Kf;break;case"RotateZ":t=Jf}return this.createRotateGizmo("",t,M1,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 k;this.getWorldPosition(t);let n=e.position,i=1;e instanceof xi?i=(e.top-e.bottom)/e.zoom:e instanceof Yr&&(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),this.updateWorldMatrix(!0,!0)}},Qf=class{constructor(e,t){this.raycaster=new Ac,this.sectionBox=new Nt,this.lastWorldPos=new k,this.mouseMoved=!1,this.dragStarted=!1,this.refrencePlane=new Ur,this.active=!1,this.showSectionPlane=!1,this.mousedown=e=>{if(0===e.button){if(!this.selectedObject){let t=this.getIntersections(e);if(!t)return;this.activateSelectedObject(!1),this.selectedObject=t.object}this.inputManager.setCursor("grabbing"),this.dragStarted=!0,this.setControlsEnabled(!1),this.onDragStart(e),this.viewer.enableRender()}},this.mousemove=e=>{if(this.dragStarted)this.updateRaycasterByMouse(e),this.onDragMove(e);else{this.activateSelectedObject(!1),this.selectedObject=void 0;let t=this.getIntersections(e),n="default";t&&(this.selectedObject=t.object,this.activateSelectedObject(!0),n="grab"),this.inputManager.setCursor(n)}this.viewer.enableRender()},this.mouseup=e=>{0===e.button&&(this.dragStarted&&(this.onDragEnd(e),this.setControlsEnabled(!0)),this.dragStarted=!1,this.activateSelectedObject(!1),this.selectedObject=void 0,this.inputManager.setCursor("default"))},this.keydown=e=>{"Escape"===e.code&&this.deactivate()},this.viewer=e,this.inputManager=t,this.scene=e.scene,this.renderer=e.renderer,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}setGlobalClippingEnabled(e){if(!this.clipPlanes)return;let t=e?this.clipPlanes:[];this.renderer.localClippingEnabled=e,this.renderer.clippingPlanes=t}setObjectClippingEnabled(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.setObjectClippingEnabled(!1),this.clippingObjetIds=[]}setClippingEnabled(e){var t;null!=(t=this.clippingObjetIds)&&t.length?(this.setGlobalClippingEnabled(!1),this.setObjectClippingEnabled(e)):this.setGlobalClippingEnabled(e)}activate(){if(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.sectionBox.isEmpty()){let e=this.viewer.getBBox();e&&this.sectionBox.copy(e)}this.active=!0}deactivate(e=!1){var t;this.inputManager.removeEventListener("pointerdown",this.mousedown),this.inputManager.removeEventListener("pointermove",this.mousemove),this.inputManager.removeEventListener("pointerup",this.mouseup),this.inputManager.removeEventListener("keydown",this.keydown),e||this.setClippingEnabled(!1),null==(t=this.selectedObject)||t.removeFromParent(),this.selectedObject=void 0,this.dragStarted=!1,this.active=!1,this.inputManager.setCursor("default"),this.setControlsEnabled(!0)}setControlsEnabled(e){this.viewer.enableRotate(e)}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 So))||t[0]}updateRaycasterByMouse(e){if(!this.raycaster)return;let t=new _e(e.x,e.y),n=Sn.screen2Ndc(t,this.camera,this.canvas);this.raycaster.setFromCamera(n,this.camera)}destroy(){this.deactivate()}},d1e=new Nt,f1e=new _r,s2=class extends St{constructor(e,t){super(),this.vertices=[],this.layers.enable(12),this.actionType=e,this.geometry=new Ot,this.vertices=t,this.geometry.setFromPoints(t),this.geometry.setIndex([0,1,2,0,2,3]),this.material=new cn({depthTest:!1,color:s2.normalPlaneColor,transparent:!0,opacity:.01,side:hr}),this.createIgnoreClipMaterials(this.material),this.geometry.computeVertexNormals(),this.edge=this.createEdge(t),this.add(this.edge)}createIgnoreClipMaterials(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 Ot;t.setFromPoints(e),t.setIndex([0,1,1,2,2,3,3,0]);let n=new zn({color:s2.normalLineColor});return this.createIgnoreClipMaterials(n),new Vr(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();f1e.setFromAxisAngle(e,t),this.vertices=this.vertices.map((e=>e.sub(n).applyQuaternion(f1e).add(n))),this.update(this.vertices)}setDirection(e){let t=new _r;t.setFromUnitVectors($a,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 k;return ni.getNormal(e,t,n,i),i}setActive(e){this.material.opacity=e?.1:.01}getPlaneCenter(){d1e.setFromPoints(this.vertices);let e=new k;return d1e.getCenter(e),e}},Ni=s2;Ni.normalPlaneColor=new ct(0,.855,.718),Ni.activePlaneColor=new ct(1,1,0),Ni.normalLineColor=16777215;var p1e=(e=>(e.X="X",e.Y="Y",e.Z="Z",e))(p1e||{}),a2=class extends Qf{constructor(e,t){super(e,t),this.activeAxis="X",this.mousedown=e=>{if(0===e.button){if(!this.selectedObject){let t=this.getIntersections(e);if(!t)return;this.activateSelectedObject(!1),this.selectedObject=t.object}this.selectedObject.parent instanceof So&&(this.inputManager.setCursor("grabbing"),this.dragStarted=!0,this.setControlsEnabled(!1),this.onDragStart(e),this.viewer.enableRender())}},this.mousemove=e=>{if(this.dragStarted)this.updateRaycasterByMouse(e),this.onDragMove(e);else{this.activateSelectedObject(!1),this.selectedObject=void 0;let t=this.getIntersections(e),n="default";t&&(this.selectedObject=t.object,this.activateSelectedObject(!0),this.selectedObject.parent instanceof So&&(n="grab")),this.inputManager.setCursor(n)}this.viewer.enableRender()},this.center=new k,this.axisInfoMap={X:{normal:new k(1,0,0)},Y:{normal:new k(0,1,0)},Z:{normal:new k(0,0,1)}},this.showSectionPlane=!0,this.viewer.addEventListener("BeforeRender",(()=>{var e,t;this.isActive&&(null==(e=this.gizmo)||e.adjustSize(this.camera),null==(t=this.planeMesh)||t.updateWorldMatrix(!0,!0))}))}activate(e="X",t){super.activate(),this.setActiveAxis(e,t)}deactivate(e=!1){var t,n;super.deactivate(e),null==(t=this.planeMesh)||t.removeFromParent(),null==(n=this.gizmo)||n.removeFromParent(),this.planeMesh=void 0,this.gizmo=void 0}reset(){var e,t;null==(e=this.planeMesh)||e.removeFromParent(),null==(t=this.gizmo)||t.removeFromParent(),this.setClippingEnabled(!1),this.planeMesh=void 0,this.gizmo=void 0,this.setActiveAxis(this.activeAxis)}setActiveAxis(e,t){this.activeAxis=e,this.sectionBox&&this.sectionBox.getCenter(this.center),this.clipPlaneConstant=t,this.initOrUpdateGizmo(),this.initOrUpdateSectionPlaneMeshes(),this.initOrUpdateClipPlanes(),this.setClippingEnabled(!0),this.clipPlaneConstant=void 0,this.viewer.enableRender()}setSectionPlaneVisible(e){this.gizmo&&this.planeMesh&&(this.gizmo.visible=e,this.planeMesh.visible=e),this.showSectionPlane=e,this.viewer.enableRender()}initOrUpdateClipPlanes(){switch(this.activeAxis){case"X":{let e=this.clipPlaneConstant||this.center.x;this.clipPlane=new Ur(new k(-1,0,0),e);break}case"Y":{let e=this.clipPlaneConstant||this.center.y;this.clipPlane=new Ur(new k(0,-1,0),e);break}case"Z":{let e=this.clipPlaneConstant||this.center.z;this.clipPlane=new Ur(new k(0,0,-1),e);break}}this.clipPlane&&(this.clipPlanes=[this.clipPlane])}initOrUpdateSectionPlaneMeshes(){var e;let t=new k;this.sectionBox.getSize(t);let n=t.length(),i=this.center.clone();this.adjustPositionByClipPlaneConstant(i);let r=(new Nt).setFromCenterAndSize(i,new k(n,n,n)),{min:a,max:s}=r;switch(null==(e=this.planeMesh)||e.removeFromParent(),this.activeAxis){case"X":this.planeMesh=new Ni("X",[new k(i.x,s.y,a.z),new k(i.x,s.y,s.z),new k(i.x,a.y,s.z),new k(i.x,a.y,a.z)]);break;case"Y":this.planeMesh=new Ni("Y",[new k(s.x,i.y,a.z),new k(a.x,i.y,a.z),new k(a.x,i.y,s.z),new k(s.x,i.y,s.z)]);break;case"Z":this.planeMesh=new Ni("Z",[new k(s.x,s.y,i.z),new k(a.x,s.y,i.z),new k(a.x,a.y,i.z),new k(s.x,a.y,i.z)])}this.planeMesh&&(this.planeMesh.visible=this.showSectionPlane,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,i=new So;i.setDirection(n),this.sectionBox.getCenter(i.position),this.adjustPositionByClipPlaneConstant(i.position),i.adjustSize(this.camera),i.visible=this.showSectionPlane,null==(t=this.scene)||t.add(i),this.gizmo=i}onDragStart(e){var t;if(this.selectedObject instanceof Ni)return;fe.info("[AxisPlaneSection] onDragStart:",e);let n=new k;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 Ni)return;let r=new k;null==(t=this.raycaster)||t.ray.intersectPlane(this.refrencePlane,r);let a=this.selectedObject.userData.actionType,s=(new k).subVectors(this.lastWorldPos,this.center).normalize(),o=(new k).subVectors(r,this.center).normalize(),l=(new k).subVectors(r,this.lastWorldPos).projectOnVector($a.clone().applyQuaternion(this.gizmo.quaternion)),h=s.angleTo(o),u=(new k).crossVectors(s,o),c=new k;this.sectionBox.getSize(c);let d,p=Math.max(c.x,c.y,c.z);switch(a){case"TranslateX":case"TranslateY":case"TranslateZ":d=(new k).addVectors(this.gizmo.position,l),this.sectionBox.clone().setFromCenterAndSize(this.center,new k(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=$a.clone().applyQuaternion(this.gizmo.quaternion);u.dot(e)<0&&(h=-h),this.gizmo.rotateX(h),this.planeMesh.rotatePlane(e,h)}break;case"RotateY":{let e=Kf.clone().applyQuaternion(this.gizmo.quaternion);u.dot(e)<0&&(h=-h),this.gizmo.rotateY(h),this.planeMesh.rotatePlane(e,h)}break;case"RotateZ":{let e=Jf.clone().applyQuaternion(this.gizmo.quaternion);u.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 Ni||fe.info("[AxisPlaneSection] onDragEnd:",e)}getIntersectObjects(){return this.planeMesh&&this.gizmo?[this.planeMesh,this.gizmo]:[]}activateSelectedObject(e){this.selectedObject&&(this.selectedObject instanceof Ni?this.selectedObject.setActive(e):this.selectedObject.parent instanceof So&&this.selectedObject.parent.setActive(e,this.selectedObject))}adjustPositionByClipPlaneConstant(e){null!=this.clipPlaneConstant&&("X"===this.activeAxis?e.setX(this.clipPlaneConstant):"Y"===this.activeAxis?e.setY(this.clipPlaneConstant):"Z"===this.activeAxis&&e.setZ(this.clipPlaneConstant))}},d1t=new k(1,0,0),f1t=new k(0,1,0),p1t=new k(0,0,1),o2=class extends Qf{constructor(e,t){super(e,t),this.sectionRange={}}activate(){super.activate();let e=this.viewer.getBBox();if(e){let{min:t,max:n}=e;this.sectionRange={x:[t.x,n.x],y:[t.y,n.y],z:[t.z,n.z]}}this.initOrUpdateClipPlanes(),this.initOrUpdateVertices(),this.initOrUpdateSectionPlaneMeshes(),this.setClippingEnabled(!0)}deactivate(e=!1){super.deactivate(e),this.planeMeshes&&this.scene.remove(...this.planeMeshes),this.planeMeshes=void 0}initOrUpdateVertices(){if(!this.sectionBox)return;let{min:e,max:t}=this.sectionBox;this.vertices=[new k(t.x,t.y,t.z),new k(e.x,t.y,t.z),new k(e.x,e.y,t.z),new k(t.x,e.y,t.z),new k(t.x,t.y,e.z),new k(e.x,t.y,e.z),new k(e.x,e.y,e.z),new k(t.x,e.y,e.z)]}initOrUpdateClipPlanes(){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 Ur(new k(-1,0,0),t.x),new Ur(new k(1,0,0),-e.x),new Ur(new k(0,-1,0),t.y),new Ur(new k(0,1,0),-e.y),new Ur(new k(0,0,-1),t.z),new Ur(new k(0,0,1),-e.z)]}initOrUpdateSectionPlaneMeshes(){let e=this.vertices;if(e){if(this.planeMeshes)this.planeMeshes[0].update([e[4],e[0],e[3],e[7]]),this.planeMeshes[1].update([e[1],e[5],e[6],e[2]]),this.planeMeshes[2].update([e[4],e[5],e[1],e[0]]),this.planeMeshes[3].update([e[6],e[7],e[3],e[2]]),this.planeMeshes[4].update([e[0],e[1],e[2],e[3]]),this.planeMeshes[5].update([e[5],e[4],e[7],e[6]]);else{let t=[new Ni("Right",[e[4],e[0],e[3],e[7]]),new Ni("Left",[e[1],e[5],e[6],e[2]]),new Ni("Top",[e[4],e[5],e[1],e[0]]),new Ni("Bottom",[e[6],e[7],e[3],e[2]]),new Ni("Front",[e[0],e[1],e[2],e[3]]),new Ni("Back",[e[5],e[4],e[7],e[6]])];this.planeMeshes=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&&(fe.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 k;null==(t=this.raycaster)||t.ray.intersectPlane(this.refrencePlane,n);let i=this.selectedObject.actionType;switch(i){case"Top":case"Bottom":this.dragTranslateSectionPlane(f1t,this.lastWorldPos,n,i);break;case"Left":case"Right":this.dragTranslateSectionPlane(d1t,this.lastWorldPos,n,i);break;case"Front":case"Back":this.dragTranslateSectionPlane(p1t,this.lastWorldPos,n,i)}this.lastWorldPos=n}onDragEnd(e){fe.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.initOrUpdateSectionPlaneMeshes(),this.initOrUpdateClipPlanes(),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.planeMeshes||[]}reset(){this.sectionBox=this.viewer.getBBox(),this.initOrUpdateVertices(),this.initOrUpdateSectionPlaneMeshes(),this.initOrUpdateClipPlanes(),this.viewer.enableRender()}setSectionPlaneVisible(e){var t;null==(t=this.planeMeshes)||t.forEach((t=>t.visible=e)),this.showSectionPlane=e,this.viewer.enableRender()}},l2=class extends Qf{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 In;e.applyNormalMatrix(i.getNormalMatrix(n.object.matrixWorld)),this.faceInfo={position:n.point,normal:e.normalize()},this.setSection(),null==(t=this.tooltip)||t.hide()}return}if(!this.selectedObject){let t=this.getIntersections(e);if(!t)return;this.activateSelectedObject(!1),this.selectedObject=t.object}this.selectedObject.parent instanceof So&&(this.inputManager.setCursor("grabbing"),this.dragStarted=!0,this.setControlsEnabled(!1),this.onDragStart(e),this.viewer.enableRender())}},this.mousemove=e=>{var t,n;if(this.faceInfo){if(this.dragStarted)this.updateRaycasterByMouse(e),this.onDragMove(e);else{this.activateSelectedObject(!1),this.selectedObject=void 0;let t=this.getIntersections(e),n="default";t&&(this.selectedObject=t.object,this.activateSelectedObject(!0),this.selectedObject.parent instanceof So&&(n="grab")),this.inputManager.setCursor(n)}this.viewer.enableRender()}else this.pickFace(e)?null==(t=this.tooltip)||t.show():null==(n=this.tooltip)||n.hide()},this.center=new k,this.viewer.addEventListener("BeforeRender",(()=>{var e,t;this.isActive&&(null==(e=this.gizmo)||e.adjustSize(this.camera),null==(t=this.planeMesh)||t.updateWorldMatrix(!0,!0))}))}activate(){super.activate(),this.sectionBox.getCenter(this.center),this.tooltip=new Zl("pick-section-plane",wr("Tooltip.section"),{parentNode:this.viewer.widgetContainer,followPointer:!0})}deactivate(e=!1){var t,n,i;super.deactivate(e),null==(t=this.planeMesh)||t.removeFromParent(),null==(n=this.gizmo)||n.removeFromParent(),this.planeMesh=void 0,this.gizmo=void 0,this.faceInfo=void 0,null==(i=this.tooltip)||i.destroy(),this.tooltip=void 0}setSection(){this.initOrUpdateGizmo(),this.initOrUpdateSectionPlaneMeshes(),this.initOrUpdateClipPlanes(),this.setClippingEnabled(!0),this.viewer.enableRender()}reset(){var e,t,n;null==(e=this.planeMesh)||e.removeFromParent(),null==(t=this.gizmo)||t.removeFromParent(),this.setClippingEnabled(!1),this.planeMesh=void 0,this.gizmo=void 0,this.faceInfo=void 0,null==(n=this.tooltip)||n.show(),this.viewer.enableRender()}setSectionPlaneVisible(e){this.gizmo&&this.planeMesh&&(this.gizmo.visible=e,this.planeMesh.visible=e),this.showSectionPlane=e,this.viewer.enableRender()}initOrUpdateClipPlanes(){if(!this.faceInfo)return;let{normal:e,position:t}=this.faceInfo;this.clipPlane=(new Ur).setFromNormalAndCoplanarPoint(e.clone().negate(),t),this.clipPlane&&(this.clipPlanes=[this.clipPlane])}initOrUpdateSectionPlaneMeshes(){var e;if(!this.faceInfo)return;let{normal:t,position:n}=this.faceInfo,i=new k;this.sectionBox.getSize(i);let r=i.length(),a=n,s=(new Nt).setFromCenterAndSize(a,new k(r,r,r)),{min:o,max:l}=s;null==(e=this.planeMesh)||e.removeFromParent(),this.planeMesh=new Ni("Plane",[new k(a.x,l.y,o.z),new k(a.x,l.y,l.z),new k(a.x,o.y,l.z),new k(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,r=new So;r.setDirection(n),r.position.copy(i),r.adjustSize(this.camera),null==(t=this.scene)||t.add(r),r.updateMatrix(),r.updateMatrixWorld(!0),this.gizmo=r}onDragStart(e){var t;if(!this.faceInfo||this.selectedObject instanceof Ni)return;fe.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 Ni)return;let r=new k;null==(t=this.raycaster)||t.ray.intersectPlane(this.refrencePlane,r);let a=this.selectedObject.userData.actionType,{position:s}=this.faceInfo,o=(new k).subVectors(this.lastWorldPos,s).normalize(),l=(new k).subVectors(r,s).normalize(),h=(new k).subVectors(r,this.lastWorldPos).projectOnVector($a.clone().applyQuaternion(this.gizmo.quaternion)),u=o.angleTo(l),c=(new k).crossVectors(o,l),d=new k;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 k).addVectors(this.gizmo.position,h),this.sectionBox.clone().setFromCenterAndSize(this.center,new k(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=$a.clone().applyQuaternion(this.gizmo.quaternion);c.dot(e)<0&&(u=-u),this.gizmo.rotateX(u),this.planeMesh.rotatePlane(e,u)}break;case"RotateY":{let e=Kf.clone().applyQuaternion(this.gizmo.quaternion);c.dot(e)<0&&(u=-u),this.gizmo.rotateY(u),this.planeMesh.rotatePlane(e,u)}break;case"RotateZ":{let e=Jf.clone().applyQuaternion(this.gizmo.quaternion);c.dot(e)<0&&(u=-u),this.gizmo.rotateZ(u),this.planeMesh.rotatePlane(e,u)}}this.clipPlane.setFromNormalAndCoplanarPoint(this.planeMesh.getPlaneNormal().negate(),this.gizmo.position),this.lastWorldPos=r}onDragEnd(e){this.selectedObject instanceof Ni||fe.info("[PickPlaneSection] onDragEnd:",e)}getIntersectObjects(){return this.planeMesh&&this.gizmo?[this.planeMesh,this.gizmo]:[]}activateSelectedObject(e){this.selectedObject&&(this.selectedObject instanceof Ni?this.selectedObject.setActive(e):this.selectedObject.parent instanceof So&&this.selectedObject.parent.setActive(e,this.selectedObject))}pickFace(e){return this.viewer.pickModel({x:e.x,y:e.y})}},X4=class extends ar{constructor(e){super(e,{id:X4.DEFAULT_ID}),this.sections={},this.viewer=e;let t=e.getInputManager();t&&(this.sections.ObjectsBoxSection=new o2(e,t),this.sections.AxisPlaneSection=new a2(e,t),this.sections.PickPlaneSection=new l2(e,t))}get raycaster(){return this.viewer.getRaycaster()}activate(e){this.activeSectionType&&this.deactivate(!1),this.activeSectionType=e,this.sections[e].activate()}deactivate(e=!1){let t=this.activeSectionType;t&&this.sections[t].deactivate(e),this.activeSectionType=void 0}reset(){let e=this.activeSectionType;e&&this.sections[e].reset()}setSectionPlaneVisible(e){let t=this.activeSectionType;t&&this.sections[t].setSectionPlaneVisible(e)}isActive(){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]}setClippingObjectIds(e){for(let t in this.sections)this.setClippingObjectIdsForType(t,e)}setClippingObjectIdsForType(e,t){this.sections[e].clearClippingObjectIds(),null!=t&&t.length&&(this.sections[e].clippingObjetIds=t,this.sections[e].setClippingEnabled(!0))}destroy(){super.destroy(),this.deactivate(!1),this.activeSectionType=void 0}},Yc=X4;Yc.DEFAULT_ID="SectionPlugin";var ep=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?fe.error("[Uploader] No files to be uploaded!"):this.uploadFiles(t)}}formats(){return fe.warn("[Uploader]: Should call derived class instead!"),[]}uploadFiles(e){fe.warn(`[Uploader]: Should call derived class instead! files: ${e}`)}openFileBrowserToUpload(){this.input.click()}},c2=class extends ep{constructor(e,t){super(t),this.defaultModelConfig={src:"",merge:!0},this.viewer=e}formats(){return["gltf","glb","dxf","obj","stl","fbx","ifc","dae","*"]}uploadFiles(e){let t=e.length;if(0===t)return;if(this.checkAllFilesWithTheSameFormat(e)){for(let n=0;n<t;n++){let t=e[n];this.uploadSingleFile(t)}return}let n,i,r,a=Ir({},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=na.extractUrlBase(n);i=new nf,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);fe.info(`[Uploader] Loading ${null==r?void 0:r.name}, ${t}%`)})).then((()=>{fe.info(`[Uploader] Loaded ${null==r?void 0:r.name}`),o.forEach(URL.revokeObjectURL)}))}checkAllFilesWithTheSameFormat(e){let t=e=>{let t=e.lastIndexOf(".");return e.substring(t+1).toLowerCase()},n=e.length,i=t(e[0].name);for(let r=0;r<n;r++)if(t(e[r].name)!==i)return!1;return!0}uploadSingleFile(e){let t=Ir({},this.defaultModelConfig),n=URL.createObjectURL(e);if(t.src=e.name,e.name.toLowerCase().endsWith(".stl")){let e=new ht,n=new k(0,0,0),i=new _r;i.setFromAxisAngle(new k(1,0,0),-Math.PI/2);let r=new k(.001,.001,.001);e.compose(n,i,r),t.matrix=e.elements}let i=new nf;this.viewer.loadLocalModel(n,t,i,(t=>{let n=Math.floor(100*t.loaded/t.total);fe.info(`[Uploader] Loading ${null==e?void 0:e.name}, ${n}%`)}))}},m1e=class extends ar{constructor(e){super(e,{id:"BimViewerDatGuiPlugin"}),this.controls={showGroundGrid:!1,showGroundGrass:!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..."),takeSnapshotForViewerBBox:()=>console.log("[DGH] Taking snapshot for objects..."),fullScreen:()=>console.log("[DGH] Full screen..."),webcam:!1,uploadFile:()=>console.log("[DGH] Upload file..."),showBimTree:!1,showPropertyPanel:!1,transparentMode:!1,showVertexNormals:!1,explode:1,sectionMode:["No section","Box section","Pick plane section","Axis 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,enableFastOperation:!1,distanceCullingFactor:100},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 o1e({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((t=>{let n=e.findPlugin("GroundGridPlugin");n?n.setVisible(t):n=new E_(e)})),i.add(n,"showGroundGrass").name("Show ground grass").onChange((t=>{let n=e.findPlugin("GroundGrassPlugin");n?n.setVisible(t):n=new b_(e)})),i.add(n,"environments",n.environments).name("Environments").onChange((n=>{let i="";"Default (City Streat 64x32)"!==n?("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,e.enableRender()):(i=`${window.location.origin}/images/envmap/${i}`,e.setEnvironment(i))):e.setEnvironmentData()})),i.add(n,"homeView").name("Go to home view").onChange((()=>{e.goToHomeView()})),i.add(n,"views",n.views).name("Views").onChange((t=>{let n=VR.getCameraDirectionByView(t);e.flyToDirection(n)})),i.add(n,"OrthographicCamera").name("Orth Camera").onChange((t=>{e.setCameraProjection(t?1:0)})),i.add(n,"takeSnapshot").name("Take snapshot").onChange((()=>{let t=e.findPlugin("ScreenshotPlugin");t||(t=new Zf(e));let n=t.getScreenshot(),i=document.createElement("a");i.href=n,i.download="",i.click()})),i.add(n,"takeSnapshotForViewerBBox").name("Take snapshot for viewer bbox").onChange((()=>{let t=e.findPlugin("ScreenshotPlugin");t||(t=new Zf(e)),(()=>{it(this,null,(function*(){let n=e.getBBox(),i=yield t.getScreenshotByWorldBBox(n),r=document.createElement("a");r.href=i,r.download="",r.click()}))})()})),i.add(n,"fullScreen").name("Full screen").onChange((()=>{n2&&n2.isEnabled&&n2.request(),e.enableRender()})),i.add(n,"uploadFile").name("Upload file").onChange((()=>{new c2(e).openFileBrowserToUpload()}));let r=this.gui.addFolder("Model operations");r.add(n,"transparentMode",n.transparentMode).name("Transparent mode").onChange((t=>{t?e.setAllModelTransparent(.03):e.clearAllModelTransparent(),e.enableRender()})),r.add(n,"showVertexNormals",n.showVertexNormals).name("Show Vertex Normals").onChange((t=>{e.showVertexNormals(t),e.enableRender()})),r.add(n,"explode",1,5).name("Explode tool").onChange((t=>{let n=e.findPlugin("ExplodePlugin");n||(n=new x_(e)),n.explode(t)})),r.add(n,"sectionMode",n.sectionMode).name("Section mode").onChange((t=>{let n=e.findPlugin("SectionPlugin");n||(n=new Yc(e)),"No section"===t?n.deactivate():"Box section"===t?n.activate("ObjectsBoxSection"):"Pick plane section"===t?n.activate("PickPlaneSection"):"Axis plane section"===t&&n.activate("AxisPlaneSection"),e.enableRender()}));let a=this.viewer.getLights().ambient,s=this.gui.addFolder("Ambient light");s.add(n,"alVisible",n.alVisible).name("visible").onChange((t=>{a&&(a.visible=t),e.enableRender()})),s.addColor(n,"alColor").name("color").onChange((t=>{a&&(a.color=new ct(t)),e.enableRender()})),s.add(n,"alIntensity",0,5).name("intensity").onChange((t=>{a&&(a.intensity=t),e.enableRender()}));let o=this.viewer.getLights().sun;if(o){let t=this.gui.addFolder("Directional light");t.add(o,"visible").name("visible").onChange((t=>{o&&(o.visible=t),e.enableRender()})),t.addColor(n,"dlColor").name("color").onChange((t=>{o&&(o.color=new ct(t)),e.enableRender()})),t.add(o,"intensity",0,5).name("intensity").onChange((t=>{o&&(o.intensity=t),e.enableRender()})),t.add(o,"castShadow").name("castShadow").onChange((t=>{o&&(o.castShadow=t),e.enableRender()})),t.add(n,"showDlHelper").name("showDlHelper").onChange((t=>{e.debugLights(t),e.enableRender()}))}let l=this.viewer.getLights().hemisphere,h=this.gui.addFolder("Hemisphere Light");h.add(n,"hlVisible",n.hlVisible).name("visible").onChange((t=>{l&&(l.visible=t),e.enableRender()})),h.add(n,"hlIntensity",0,5).name("intensity").onChange((t=>{l&&(l.intensity=t),e.enableRender()})),h.addColor(n,"hlColor").name("color").onChange((t=>{l&&(l.color=new ct(t)),e.enableRender()})),h.addColor(n,"hlGroundColor").name("groundColor").onChange((t=>{l&&(l.groundColor=new ct(t)),e.enableRender()}));let u=this.gui.addFolder("Fog");u.add(n,"fogEnabled",n.fogEnabled).name("Enabled").onChange((i=>{t.fog=i?new _u(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 _u(n.fogColor,i,n.fogFarDistance)),e.enableRender()})),u.add(n,"fogFarDistance",100,2e3).name("Far").onChange((i=>{n.fogEnabled&&t&&(t.fog=new _u(n.fogColor,n.fogNearDistance,i)),e.enableRender()})),this.gui.addFolder("Performance").add(n,"distanceCullingFactor",10,1e3).name("Distance Culling Factor").onChange((t=>{e.setDistanceCullingFactor(t),e.enableRender()})).setValue(e.getDistanceCullingFactor())}open(){this.gui&&this.gui.open()}close(){this.gui&&this.gui.close()}destroy(){super.destroy(),this.gui&&this.gui.destroy(),this.gui=void 0}},$4=class extends ar{constructor(e,t){super(e,{id:(null==t?void 0:t.id)||$4.DEFAULT_ID}),this.mouseDownPositionX=-1,this.mouseDownPositionY=-1,this.onPointerDown=e=>{let t=e.target;null!=t&&t.classList.contains("draggable")&&0===e.button&&(this.mouseDownPositionX=e.x,this.mouseDownPositionY=e.y,document.addEventListener("pointermove",this.onPointerMove),document.addEventListener("pointerup",this.onPointerUp))},this.onPointerMove=e=>{let t=this.layerMgrRoot,n=this.viewer.viewerContainer;if(!t||!n)return;let i=n.clientLeft+n.clientWidth,r=n.clientTop+n.clientHeight,a=e.x-this.mouseDownPositionX,s=e.y-this.mouseDownPositionY,o=t.offsetLeft+a,l=t.offsetTop+s;o<0&&(o=0),o>0&&o+t.clientWidth>i&&a>0&&(o=t.offsetLeft),l<0&&(l=0),l>0&&l+t.clientHeight>r&&s>0&&(l=t.offsetTop),t.style.left=`${o}px`,t.style.top=`${l}px`,this.mouseDownPositionX=e.x,this.mouseDownPositionY=e.y},this.onPointerUp=()=>{document.removeEventListener("pointermove",this.onPointerMove),document.removeEventListener("pointerup",this.onPointerUp)},this.cfg=t||{},!1!==this.cfg.visible&&this.init()}init(){let e=this.viewer;this.cfg.containerId&&(this.container=document.getElementById(this.cfg.containerId)),this.container||(this.container=e.widgetContainer),this.dxfLayersArray=e.getLayers(),this.buildPage(),this.addContent(),this.addEventHandlers()}setVisible(e){e&&!this.container&&this.init();let t=this.layerMgrRoot;"none"!==t.style.display!==e&&(e?(this.updatePage(),t.style.display=""):t.style.display="none",this.dispatchEvent("Visibilitychange",e))}show(){this.setVisible(!0)}hide(){this.setVisible(!1)}destroy(){var e,t,n;super.destroy(),null==(e=this.closeBtn)||e.removeEventListener("click",this.closePanel),null==(t=this.checkboxes)||t.forEach((e=>{e.removeEventListener("change",(()=>{this.checkboxHandler(e)}))})),null==(n=this.layerMgrRoot)||n.remove()}buildPage(){var e;this.layerMgrRoot=document.createElement("div"),this.layerMgrRoot.classList.add("layer-manager");let t=document.createElement("div");t.classList.add("header","draggable"),this.headerText=document.createElement("span"),this.headerText.innerHTML="Layers",this.headerText.classList.add("draggable"),this.closeBtn=document.createElement("span"),this.closeBtn.classList.add("close"),this.closeBtn.innerHTML="X",t.appendChild(this.headerText),t.appendChild(this.closeBtn),this.layerMgrRoot.appendChild(t),this.layerList=document.createElement("div"),this.layerList.classList.add("layer-list"),this.layerMgrRoot.appendChild(this.layerList),null==(e=this.container)||e.appendChild(this.layerMgrRoot),this.updateHeaderText()}addContent(){var e;let t='\n <div class="layer-list-item">\n <input type="checkbox" id="toggleAllLayers" checked class="checkbox"></input>\n <span class="popup-layer-color">Color</span>\n <span class="item-layer-name"> Layer name</span>\n </div>\n ';if(this.dxfLayersArray){let e=this.dxfLayersArray.length>1;for(let n=0;n<this.dxfLayersArray.length;++n){let i=this.dxfLayersArray[n].layers,r=Object.keys(i);r=r.sort(((e,t)=>{let n=/[a-zA-Z0-9]/,i=e.toString(),r=t.toString();return n.test(i[0])||n.test(r[0])?i>r?1:i<r?-1:0:i.localeCompare(r)}));for(let a of r){let r=i[a],s=e?`<${this.dxfLayersArray[n].modelId}> ${a}`:a,o=this.convertDecimalToHex(r.color);t+=this.generateListItem(s,r.visible,o)}}}this.layerList&&(this.layerList.innerHTML=t);let n=null==(e=this.layerMgrRoot)?void 0:e.querySelectorAll("input[type=checkbox]");this.checkboxes=[].slice.call(n,0),this.checkboxes.forEach((e=>{e.addEventListener("change",(()=>{this.checkboxHandler(e)}))}))}generateListItem(e,t,n){return`\n <div class="layer-list-item">\n <input type="checkbox" value="${e}" ${t?"checked":""} class="checkbox">\n <div class="item-color" style="${n?`background-color: ${n}`:"opacity: 0.1"}"></div>\n <span class="item-layer-name" title="${e}">${e}</span>\n </div>\n `}closePanel(){this.hide()}addEventHandlers(){var e,t;null==(e=this.closeBtn)||e.addEventListener("click",this.closePanel.bind(this)),null==(t=this.layerMgrRoot)||t.addEventListener("pointerdown",this.onPointerDown)}checkboxHandler(e){var t;if(!this.dxfLayersArray||!this.checkboxes)return;let n=this.viewer;if("toggleAllLayers"===e.id){for(let t=0;t<this.dxfLayersArray.length;++t){let i=this.dxfLayersArray[t].modelId,r=this.dxfLayersArray[t].layers;Object.keys(r).forEach((t=>{n.setLayerVisibility(t,e.checked,i)}))}return void(null==(t=this.checkboxes)||t.forEach((t=>t.checked=e.checked)))}let i="",r=e.value,a=r.indexOf(">");-1!==a&&(i=r.slice(1,a),r=r.slice(a+2)),i||(i=this.dxfLayersArray[0].modelId),n.setLayerVisibility(r,e.checked,i)}updatePage(){if(!this.dxfLayersArray)return;let e=this.viewer.getLayers();e.length!==this.dxfLayersArray.length&&(this.dxfLayersArray=e,this.addContent(),this.updateHeaderText())}updateHeaderText(){if(!this.dxfLayersArray||!this.headerText)return;let e=0;for(let t=0;t<this.dxfLayersArray.length;++t){let n=this.dxfLayersArray[t].layers;e+=Object.keys(n).length}this.headerText.innerHTML=`Layers (count: ${e})`}convertDecimalToHex(e){return void 0===e?void 0:`#${e.toString(16).padStart(6,"0")}`}},Y4=$4;Y4.DEFAULT_ID="LayerManagerPlugin";var g1e={name:"HorizontalBlurShader",uniforms:{tDiffuse:{value:null},h:{value:.001953125}},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 sampler2D tDiffuse;\n\t\tuniform float h;\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvec4 sum = vec4( 0.0 );\n\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x - 4.0 * h, vUv.y ) ) * 0.051;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x - 3.0 * h, vUv.y ) ) * 0.0918;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x - 2.0 * h, vUv.y ) ) * 0.12245;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x - 1.0 * h, vUv.y ) ) * 0.1531;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x, vUv.y ) ) * 0.1633;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x + 1.0 * h, vUv.y ) ) * 0.1531;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x + 2.0 * h, vUv.y ) ) * 0.12245;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x + 3.0 * h, vUv.y ) ) * 0.0918;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x + 4.0 * h, vUv.y ) ) * 0.051;\n\n\t\t\tgl_FragColor = sum;\n\n\t\t}"},v1e={name:"VerticalBlurShader",uniforms:{tDiffuse:{value:null},v:{value:.001953125}},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 sampler2D tDiffuse;\n\t\tuniform float v;\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvec4 sum = vec4( 0.0 );\n\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 4.0 * v ) ) * 0.051;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 3.0 * v ) ) * 0.0918;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 2.0 * v ) ) * 0.12245;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x, vUv.y - 1.0 * v ) ) * 0.1531;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x, vUv.y ) ) * 0.1633;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 1.0 * v ) ) * 0.1531;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 2.0 * v ) ) * 0.12245;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 3.0 * v ) ) * 0.0918;\n\t\t\tsum += texture2D( tDiffuse, vec2( vUv.x, vUv.y + 4.0 * v ) ) * 0.051;\n\n\t\t\tgl_FragColor = sum;\n\n\t\t}"},K4=class extends ar{constructor(e,t){let n=(null==t?void 0:t.id)||K4.DEFAULT_ID;super(e,{id:n}),this.shouldRender=!1,this.onModelLoaded=()=>{this.timeout&&clearTimeout(this.timeout),this.timeout=setTimeout((()=>{this.update()}),2e3)},this.onShadowRender=()=>{var e,t,n,i,r;this.shouldRender&&(this.render(),null==(e=this.shadowCamera)||e.removeFromParent(),this.shadowCamera=void 0,null==(t=this.blurPlane)||t.removeFromParent(),this.blurPlane=void 0,null==(n=this.depthMaterial)||n.dispose(),this.depthMaterial=void 0,null==(i=this.horizontalBlurMaterial)||i.dispose(),this.horizontalBlurMaterial=void 0,null==(r=this.verticalBlurMaterial)||r.dispose(),this.verticalBlurMaterial=void 0,this.shouldRender=!1)},this.cfg=t||{id:n},void 0===this.cfg.blur&&(this.cfg.blur=5),void 0===this.cfg.darkness&&(this.cfg.darkness=.8),this.viewer.addEventListener("ModelLoaded",this.onModelLoaded),this.viewer.addEventListener("BeforeRender",this.onShadowRender)}get scene(){return this.viewer.scene}get renderer(){return this.viewer.renderer}update(){this.initMaterial(),this.initRenderTarget(),this.updateGroundShadow(),this.shouldRender=!0,this.viewer.enableRender()}initMaterial(){this.depthMaterial=new wc,this.depthMaterial.userData.darkness={value:this.cfg.darkness},this.depthMaterial.onBeforeCompile=e=>{var t;e.uniforms.darkness=null==(t=this.depthMaterial)?void 0:t.userData.darkness,e.fragmentShader=`\n uniform float darkness;\n ${e.fragmentShader.replace("gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );","gl_FragColor = vec4( vec3( 0.0 ), ( 1.0 - fragCoordZ ) * darkness );")}\n `},this.depthMaterial.depthTest=!1,this.depthMaterial.depthWrite=!1,this.horizontalBlurMaterial=new hn(g1e),this.horizontalBlurMaterial.depthTest=!1,this.verticalBlurMaterial=new hn(v1e),this.verticalBlurMaterial.depthTest=!1}initRenderTarget(){this.renderTarget=new er(128,128),this.renderTarget.texture.generateMipmaps=!1,this.renderTargetBlur=new er(128,128),this.renderTargetBlur.texture.generateMipmaps=!1}updateGroundShadow(){var e,t,n;let i=this.viewer.getBBox(),r=new Bn;r.name="ground-shadow",rr.disableLayerChannels(r,[12,11]),null==(e=this.scene)||e.add(r);let{min:a,max:s}=i,o=new k;i.getSize(o),o.multiplyScalar(2);let l=new k;i.getCenter(l);let h=new mi(o.x,o.z).rotateX(Math.PI/2),u=new cn({map:null==(t=this.renderTarget)?void 0:t.texture,transparent:!0,depthWrite:!1}),c=new St(h,u);c.renderOrder=1,c.position.set(l.x,a.y,l.z),c.scale.y=-1,null==r||r.add(c),this.shadowCamera=new xi(-o.x/2,o.x/2,o.z/2,-o.z/2,-o.y/2,o.y),this.shadowCamera.position.set(l.x,a.y,l.z),this.shadowCamera.lookAt(l.x,s.y,l.z),this.shadowCamera.updateProjectionMatrix(),r.add(this.shadowCamera);let d=new St(h);d.position.set(l.x,a.y,l.z),d.visible=!1,r.add(d),this.blurPlane=d,null==(n=this.shadowGroup)||n.removeFromParent(),this.shadowGroup=r,this.shadowGroup.updateWorldMatrix(!0,!0)}blurShadow(e){this.renderer&&this.blurPlane&&this.renderTarget&&this.renderTargetBlur&&this.shadowCamera&&this.horizontalBlurMaterial&&this.verticalBlurMaterial&&(this.blurPlane.visible=!0,this.blurPlane.material=this.horizontalBlurMaterial,this.horizontalBlurMaterial.uniforms.tDiffuse.value=this.renderTarget.texture,this.horizontalBlurMaterial.uniforms.h.value=1*e/256,this.renderer.setRenderTarget(this.renderTargetBlur),this.renderer.render(this.blurPlane,this.shadowCamera),this.blurPlane.material=this.verticalBlurMaterial,this.verticalBlurMaterial.uniforms.tDiffuse.value=this.renderTargetBlur.texture,this.verticalBlurMaterial.uniforms.v.value=1*e/256,this.renderer.setRenderTarget(this.renderTarget),this.renderer.render(this.blurPlane,this.shadowCamera),this.blurPlane.visible=!1)}render(){if(!(this.renderer&&this.scene&&this.renderTarget&&this.shadowCamera&&this.depthMaterial))return;let e=this.scene.background;this.scene.background=null,this.scene.overrideMaterial=this.depthMaterial;let t=this.renderer.getClearAlpha();this.renderer.setClearAlpha(0),this.renderer.setRenderTarget(this.renderTarget),this.renderer.render(this.scene,this.shadowCamera),this.scene.overrideMaterial=null,this.blurShadow(this.cfg.blur),this.blurShadow(.4*this.cfg.blur),this.renderer.setRenderTarget(null),this.renderer.setClearAlpha(t),this.scene.background=e}destroy(){var e,t,n,i,r,a,s;super.destroy(),this.viewer.removeEventListener("ModelLoaded",this.onModelLoaded),this.viewer.removeEventListener("BeforeRender",this.onShadowRender),null==(e=this.shadowCamera)||e.removeFromParent(),this.shadowCamera=void 0,null==(t=this.blurPlane)||t.removeFromParent(),this.blurPlane=void 0,null==(n=this.depthMaterial)||n.dispose(),this.depthMaterial=void 0,null==(i=this.horizontalBlurMaterial)||i.dispose(),this.horizontalBlurMaterial=void 0,null==(r=this.verticalBlurMaterial)||r.dispose(),this.verticalBlurMaterial=void 0,null==(a=this.renderTarget)||a.dispose(),this.renderTarget=void 0,null==(s=this.renderTargetBlur)||s.dispose(),this.renderTargetBlur=void 0}},Z4=K4;Z4.DEFAULT_ID="GroundShadowPlugin";var y1e=class extends ar{constructor(e){super(e,{id:"HotpointPlugin"}),this.onAfterRender=()=>{var e;let t=this.viewer.scene,n=this.viewer.camera;!t||!n||!this.hotpointRoot||0===this.hotpointRoot.children.length||null==(e=this.css2dRenderer)||e.render(t,n)},this.css2dRenderer=this.viewer.css2dRenderer,this.viewer.addEventListener("AfterRender",this.onAfterRender)}add(e){var t;if(this.has(e.hotpointId))return void fe.warn(`[Hotpoint] Hotpoint with id '${e.hotpointId}' already exist!`);let n=e.anchorPosition,i=pf.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 Bn,this.hotpointRoot.matrixAutoUpdate=!1,this.hotpointRoot.matrixWorldAutoUpdate=!1,this.hotpointRoot.name="HotpointRoot",null==(t=this.viewer.scene)||t.add(this.hotpointRoot)),this.hotpointRoot.add(i),i.updateWorldMatrix(!1,!1),this.viewer.enableRender()}remove(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()}}clear(){var e;null==(e=this.hotpointRoot)||e.clear()}has(e){return!!this.findHotpointObject(e)}move(e,t){let n=this.findHotpointObject(e);if(n){let e=t.z||0;n.position.set(t.x,t.y,e),n.updateWorldMatrix(!1,!1),this.viewer.enableRender()}}setVisible(e,t){let n=this.findHotpointObject(e);n&&(n.visible=t)}findHotpointObject(e){var t;return((null==(t=this.hotpointRoot)?void 0:t.children)||[]).find((t=>{var n;return(null==(n=t.userData.hotpoint)?void 0:n.hotpointId)===e}))}flyToHotpoint(e,t=this.viewer.camera.zoom){let n=this.findHotpointObject(e);if(!n)return;n.updateWorldMatrix(!1,!1);let i=n.position,r=this.viewer.camera.position,a=new k(i.x,i.y,r.z),s=new k(i.x,i.y,0);this.viewer.flyTo(a,s,t)}destroy(){super.destroy(),this.clear()}},Ns=ss(x1e(),1),ii=ss(Q1e(),1),wV={Fill:"Fill",Stroke:"Stroke",Shading:"Shading"},ec={Fill:0,Stroke:1,FillStroke:2,Invisible:3,FillAddToPath:4,StrokeAddToPath:5,FillStrokeAddToPath:6,AddToPath:7,FillStrokeMask:3,AddToPathFlag:4},eye=16,tye=100,MV=[1,0,0,1,0,0],AV=[.001,0,0,.001,0,0],m1t={},nye={},rye=new ct,x2=new ht,SV=0,g1t=.01,RV=class extends xr{constructor(e){if(super(),this.contentVisible=!0,this.markedContentStack=[],this.stateStack=[],this.current=new b2(1,1),this.tempSMask=null,this.pendingEOFill=!1,this.activeLayoutName="Model",this.defaultLayerId="0",this.currentLayerId="0",this.layers={0:{name:"0",id:"0",index:"0",visible:!0}},this.loadedEntityCount=0,this.viewportScale=1,this.baseTransform=new ht,this.currentTransform=new ht,this.transformStack=[],this.clipType=Ns.PolyFillType.pftNonZero,this.paths=[],this.pointsMaterials={},this.lineBasicMaterials={},this.meshBasicMaterials={},this.lineWithWidthCount=0,void 0===ii)throw"[PdfLoader] need load pdf.js first";"3.8.162"!==ii.version&&fe.warn("[PdfLoader] The pdf.js version we are using now is 3.8.162,if not maybe wrong."),this.fontManager=e.font,ii.GlobalWorkerOptions.workerSrc=e.pdfWorker}load(e,t,n,i){this.loadAsync(e,n).then((e=>{t(e)})).catch((e=>{i(e)}))}loadAsync(e,t){return it(this,null,(function*(){var n,i,r;let a=Pt.getUpdateProgressFunc(t),s=Pt.getUpdateSubProgressFunc(0,10,t);a(0);let{src:o}=e;this.modelCfg=e;let l=e.modelId||o,h=Date.now(),u=ii.getDocument(o);u.onProgress=s;let c=yield u.promise;return this.pdf=c,fe.info(`[PdfLoader] Pdf document loaded in ${(Date.now()-h)/1e3}s`),h=Date.now(),fe.log(c),this.pdfDocumentGroup=new Bn,this.pdfDocumentGroup.name=`PdfDocument-${l}`,this.optionalContentConfig=yield c.getOptionalContentConfig(),yield null==(n=this.fontManager)?void 0:n.getFontFromIndexeddb(),fe.log("[PdfLoader] Font loaded."),c.numPages>1&&fe.info("[PdfLoader] Only the first page can be render others will be ignore."),yield this.loadPage(1,t),null!=(i=this.fontManager)&&i.missingFonts&&fe.warn("[PdfLoader] Missing fonts and reference count:",null==(r=this.fontManager)?void 0:r.missingFonts,", used other fonts instead."),this.lineWithWidthCount>0&&fe.warn(`[PdfLoader] Found ${this.lineWithWidthCount} line(s) with width, line width is not supported and was ignored.`),this.progressiveLoadCallback||(a(100),fe.info(`[PdfLoader] Loaded '${e.src}' in ${(Date.now()-h)/1e3}s, adding to scene...`)),{modelId:l,pdfData:{threejsObject:this.pdfDocumentGroup,layers:this.layers||[],layersAndThreejsObjects:this.layersAndThreejsObjects,loadedEntityCount:this.loadedEntityCount}}}))}loadPage(e,t){return it(this,null,(function*(){var n,i,r,a,s;if(!this.pdf||e>this.pdf.numPages)return Promise.reject("load pdf page failed");this.pdfPage&&this.pdfPageGroup&&(null==(n=this.pdfPageGroup)||n.removeFromParent(),null==(i=this.pdfPageGroup)||i.traverse((e=>{e.geometry&&e.geometry.dispose(),e.material&&e.material.dispose()})),null==(r=this.pdfPageGroup)||r.clear(),this.pdfPageGroup=void 0,this.tryCleanup(),this.pdfPage.objs.clear(),this.pdfPage.cleanup(),this.objs=void 0,this.pdfPage=void 0,null==(a=this.viewportMesh)||a.removeFromParent(),this.viewportMesh=void 0,this.layersAndThreejsObjects=void 0);let o=Pt.getUpdateProgressFunc(t),l=Pt.getUpdateSubProgressFunc(30,90,t),h=Date.now(),u=yield this.pdf.getPage(e);o(20),fe.info(`[PdfLoader] Pdf page loaded in ${(Date.now()-h)/1e3}s`),h=Date.now(),fe.log(u),this.pdfPage=u,this.pdfPageGroup=new Bn,this.pdfPageGroup.name=RV.MODEL_LAYOUT_NAME,null==(s=this.pdfDocumentGroup)||s.add(this.pdfPageGroup),this.commonObjs=this.pdf._transport.commonObjs,this.objs=u.objs;let c=u.view,d=8192/Math.max(c[2]-c[0],c[3]-c[1]),p=Math.min(300/72,d),f=u.getViewport({scale:p});this.beginDrawing(f),this.current=new b2(f.width,f.height),yield this.buildLayers(u),o(30),yield this.getOperatorList(l)}))}getPageCount(){if(this.pdf)return this.pdf.numPages}getOperatorList(e){return it(this,null,(function*(){let t=this.pdfPage;if(!t)return;let n,i=ii.AnnotationMode.ENABLE,r=t._transport.getRenderingIntent("display",i,null,!0),a=t._intentStates.get(r.cacheKey);return a||(a=Object.create(null),t._intentStates.set(r.cacheKey,a)),a.opListReadCapability||(n=Object.create(null),n.operatorListChanged=function(){a.operatorList.lastChunk&&(a.opListReadCapability.resolve(a.operatorList),a.renderTasks.delete(n))},a.opListReadCapability=new ii.PromiseCapability,(a.renderTasks||(a.renderTasks=new Set)).add(n),a.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null}),yield this._pumpOperatorList(r,e)}))}_pumpOperatorList(e,t){return it(this,null,(function*(){let n=this.pdfPage;if(!n)return;let{renderingIntent:i,cacheKey:r,annotationStorageSerializable:a}=e,{map:s,transfers:o}=a,l=n._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:n._pageIndex,intent:i,cacheKey:r,annotationStorage:s},o).getReader(),h=n._intentStates.get(r);h.streamReader=l;let u=h.operatorList.argsArray.length,c=u<3e3;fe.info(`[PdfLoader] Operation count: ${u}, isVerboseProgress: ${c}`);let d=0,p=Pt.getUpdateProgressFunc(t);p(0);let f=()=>it(this,null,(function*(){var e;try{let{value:i,done:r}=yield l.read();if(r)return h.streamReader=null,void(this.progressiveLoadCallback||p(100));if(n._transport.destroyed)return;let a=i,s=a.argsArray.length,o=100*d/u,m=100*(d+s)/u;if(c){let e=Pt.getUpdateSubProgressFunc(o,m,t);yield this.executeOperatorList(a,e)}else yield this.executeOperatorList(a),p(m);let g=this.progressiveLoadCallback,v=a.lastChunk;g?window.requestAnimationFrame((()=>{var e,t;null!=(e=this.modelCfg)&&e.merge&&this.mergePdfObjects(),g(SV,v),null==(t=this.pdfPageGroup)||t.updateMatrixWorld(!0)})):null!=(e=this.modelCfg)&&e.merge&&this.mergePdfObjects(),a.lastChunk&&this.endDrawing(),d+=s,g?f():yield f()}catch(e){if(h.streamReader=null,n._transport.destroyed)return;if(h.operatorList){h.operatorList.lastChunk=!0;for(let e of h.renderTasks)e.operatorListChanged();this.tryCleanup()}if(h.displayReadyCapability)h.displayReadyCapability.reject(e);else{if(!h.opListReadCapability)throw e;h.opListReadCapability.reject(e)}}}));yield f()}))}tryCleanup(){let e=this.pdfPage;e&&e._intentStates.clear()}mergePdfObjects(){for(let e in this.layersAndThreejsObjects){let t=this.layersAndThreejsObjects[e];if(t.length<=1)continue;let n=Mi.deepMerge(t,this.pdfPageGroup,!1,!1,!1),i=n.added,r=n.removed;r.forEach((e=>{var t,n;null==(t=this.pdfPageGroup)||t.remove(e);let i=e;i.geometry.dispose(),i.material.dispose(),null==(n=i.material.map)||n.dispose()})),i.forEach((e=>{var t;null==(t=this.pdfPageGroup)||t.add(e)}));let a=t.filter((e=>!r.includes(e)));a.push(...i),this.layersAndThreejsObjects[e]=a}}getPointsMaterial(e,t=1){return this.pointsMaterials[`${e}-${t}`]||(this.pointsMaterials[`${e}-${t}`]=new Li({color:e,transparent:!0,opacity:t})),this.pointsMaterials[`${e}-${t}`]}getLineBasicMaterial(e,t=1){return this.lineBasicMaterials[`${e}-${t}`]||(this.lineBasicMaterials[`${e}-${t}`]=new zn({color:e,transparent:!0,opacity:t})),this.lineBasicMaterials[`${e}-${t}`]}getMeshBasicMaterial(e,t=1){return this.meshBasicMaterials[`${e}-${t}`]||(this.meshBasicMaterials[`${e}-${t}`]=new cn({color:e,transparent:!0,opacity:t,side:hr})),this.meshBasicMaterials[`${e}-${t}`]}getTransformByMatrix4(e){return[e.elements[0],e.elements[1],e.elements[4],e.elements[5],e.elements[12],e.elements[13]]}getObject(e,t=null){return"string"==typeof e?e.startsWith("g_")?this.commonObjs.get(e):this.objs.get(e):t}beginDrawing(e){var t,n,i,r;fe.log("beginDrawing",e),this.viewportScale=e.scale;let[a,s,o,l,h,u]=e.transform;this.baseTransform.set(a,o,0,h,s,l,0,u,0,0,1,0,0,0,0,1),this.currentTransform.copy(this.baseTransform),null==(t=this.pdfPageGroup)||t.applyMatrix4(this.baseTransform),null==(n=this.pdfPageGroup)||n.rotateZ(Un.degToRad(-e.rotation)),null==(i=this.pdfPageGroup)||i.updateMatrix();let{width:c,height:d}=e,p=(new Ot).setFromPoints([new k(0,0,0),new k(c,0,0),new k(c,d,0),new k(0,0,0),new k(c,d,0),new k(0,d,0)]),f=new cn({color:16777215}),m=new St(p,f);m.name="PDF-viewport",m.renderOrder=-999,m.layers.disable(10),this.viewportMesh=m,null==(r=this.pdfPageGroup)||r.add(m)}endDrawing(){var e;null==(e=this.pdfPageGroup)||e.updateMatrixWorld(!0)}releaseData(){var e;null==(e=this.fontManager)||e.releaseFontData(),this.operatorList=void 0,this.optionalContentConfig=void 0,this.commonObjs=void 0,this.objs=void 0,this.pdfPage=void 0,this.pdf=void 0}buildLayers(e){return it(this,null,(function*(){if(!this.pdf)return;let t=yield e.getOperatorList(),n=t.fnArray,i=t.argsArray,r={},a=1;for(let e=0;n&&e<n.length;e++)if(n[e]===ii.OPS.beginMarkedContentProps&&i[e]&&"OC"==i[e][0]&&null!==i[e][1]){let t;t="object"==typeof i[e][1]?i[e][1].id:i[e][1],void 0===r[t]&&(r[t]=a++)}let s=this.optionalContentConfig,o={0:{name:"0",id:"0",index:"0",visible:!0}},l=1;for(let e in r){let t=s.getGroup(e);t?(l++,o[t.name]={name:t.name,id:e,index:r[e],visible:t.visible}):r[e]=0}return fe.log("buildLayers",o),this.layers=o,{layerCount:l,layersMap:o,layers:r}}))}addObjectToModel(e){var t,n;this.layersAndThreejsObjects||(this.layersAndThreejsObjects={});let i=this.layers[this.currentLayerId],r=(null==i?void 0:i.name)||this.defaultLayerId;this.layersAndThreejsObjects[r]||(this.layersAndThreejsObjects[r]=[]),e.userData.layerName=r,this.layersAndThreejsObjects[r].push(e),this.loadedEntityCount++,e.layers.enableAll();let a=e;a.geometry&&a.geometry.hasAttribute("normal")&&a.geometry.deleteAttribute("normal"),a.material&&!a.material.map&&a.geometry&&a.geometry.hasAttribute("uv")&&a.geometry.deleteAttribute("uv"),null!=(t=this.modelCfg)&&t.merge&&a.geometry&&(a.geometry.translate(0,0,SV),SV+=g1t),null==(n=this.pdfPageGroup)||n.add(e)}executeOperatorList(e,t){return it(this,null,(function*(){var n;let i=e.argsArray,r=e.fnArray,a=i.length,s=Pt.getUpdateProgressFuncForLoop(a,t),o=this.commonObjs,l=this.objs,h=0;for(;h<a;){let e=r[h];if(e!==ii.OPS.dependency)null==(n=this[e])||n.apply(this,i[h]);else for(let t of i[h])(t.startsWith("g_")?o:l).has(t)||console.warn("Why it runs here?!");h++,yield s(h)}}))}setLineWidth(e){this.current.lineWidth=e,e>1&&this.lineWithWidthCount++}setLineCap(e){this.current.lineCap=e}setLineJoin(e){this.current.lineJoin=e}setMiterLimit(e){this.current.miterLimit=e}setDash(e,t){}setRenderingIntent(e){}setFlatness(e){}setGState(e){for(let[t,n]of e)switch(t){case"LW":this.setLineWidth(n);break;case"LC":this.setLineCap(n);break;case"LJ":this.setLineJoin(n);break;case"ML":this.setMiterLimit(n);break;case"D":this.setDash(n[0],n[1]);break;case"RI":this.setRenderingIntent(n);break;case"FL":this.setFlatness(n);break;case"Font":this.setFont(n[0],n[1]);break;case"CA":this.current.strokeAlpha=n;break;case"ca":this.current.fillAlpha=n;break;case"BM":case"TR":break;case"SMask":this.current.activeSMask=n?this.tempSMask:null,this.tempSMask=null}}save(){let e=this.current;this.transformStack.push(this.currentTransform.clone()),this.stateStack.push(e),this.current=e.clone()}restore(){0!==this.stateStack.length&&(this.current=this.stateStack.pop()),0!==this.transformStack.length&&this.currentTransform.copy(this.transformStack.pop()),this.pendingClip=null,this.paths=[]}transform(e,t,n,i,r,a){let s=x2.set(e,n,0,r,t,i,0,a,0,0,1,0,0,0,0,1);this.currentTransform.multiply(s)}moveTo(){}lineTo(){}curveTo(){}curveTo2(){}curveTo3(){}closePath(){this.currentPath&&this.currentPath.curves.length>0&&(this.currentPath.closePath(),this.paths.push(this.currentPath.clone()),this.currentPath=void 0)}rectangle(){}stroke(e=!0){if(this.contentVisible){let e=this.current.strokeColor,t=this.current.strokeAlpha,n=[],i=[];for(let r=0;r<this.paths.length;r++){let e=this.paths[r],t=1===e.getPoints().length,a=(new Ot).setFromPoints(e.getPoints());a.applyMatrix4(this.currentTransform),t?n.push(a):i.push(a)}if(n.length>0){let i=Oi(n),r=new Di(i,this.getPointsMaterial(e,t));this.addObjectToModel(r)}if(i.length>0){let n=Oi(i),r=new Vr(n,this.getLineBasicMaterial(e,t));this.addObjectToModel(r)}}e&&this.consumePath(this.current.getClippedPathBoundingBox())}closeStroke(){this.closePath(),this.stroke()}fill(e=!0){if(0===this.paths.length)return;this.current.patternFill&&fe.warn("[PdfLoader] fill pattern not supported now.");let t=this.current.getClippedPathBoundingBox();if(this.contentVisible&&null!==t){let e,t=[];if(this.clipPaths){let e=new Ns.PolyTree,n=new Ns.Clipper,i=this.paths.map((e=>e.getPoints().map((e=>({X:e.x,Y:e.y}))))),r=this.clipPaths.map((e=>e.getPoints().map((e=>({X:e.x,Y:e.y}))))),a=100;Ns.JS.ScaleUpPaths(i,a),Ns.JS.ScaleUpPaths(r,a),n.AddPaths(i,Ns.PolyType.ptSubject,!0),n.AddPaths(r,Ns.PolyType.ptClip,!0),n.Execute(Ns.ClipType.ctIntersection,e,this.pendingEOFill?Ns.PolyFillType.pftEvenOdd:Ns.PolyFillType.pftNonZero,this.clipType);let s=Ns.JS.PolyTreeToExPolygons(e);for(let o=0;o<s.length;o++){let{outer:e,holes:n}=s[o],i=new Ts;i.setFromPoints(e.map((e=>new _e(e.X/a,e.Y/a)))),n.length>0&&n.forEach((e=>{let t=new Ts;t.setFromPoints(e.map((e=>new _e(e.X/a,e.Y/a)))),i.holes.push(t)})),t.push(i)}this.clipPaths=void 0}e=t.length>0?new Al(t):Oi(this.paths.map((e=>new Al(e)))),e.applyMatrix4(this.currentTransform);let n=this.current.fillColor,i=this.current.fillAlpha,r=new St(e,this.getMeshBasicMaterial(n,i));this.addObjectToModel(r),this.pendingEOFill=!1}e&&this.consumePath(t)}eoFill(){this.pendingEOFill=!0,this.fill()}fillStroke(){this.fill(!1),this.consumePath()}eoFillStroke(){this.pendingEOFill=!0,this.fillStroke()}closeFillStroke(){this.closePath(),this.fillStroke()}closeEOFillStroke(){this.pendingEOFill=!0,this.closePath(),this.fillStroke()}endPath(){this.consumePath()}clip(){this.pendingClip=m1t}eoClip(){this.pendingClip=nye}beginText(){this.current.textMatrix=MV,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}endText(){this.currentPath=new Ts}setCharSpacing(e){this.current.charSpacing=e}setWordSpacing(e){this.current.wordSpacing=e}setHScale(e){this.current.textHScale=e/100}setLeading(e){this.current.leading=-e}setFont(e,t){let n=this.commonObjs.get(e),i=this.current;if(!n)throw new Error(`Can't find font for ${e}`);if(i.fontMatrix=n.fontMatrix||AV,(0===i.fontMatrix[0]||0===i.fontMatrix[3])&&fe.warn("Invalid font matrix for font "+e),t<0?(t=-t,i.fontDirection=-1):i.fontDirection=1,this.current.font=n,this.current.fontSize=t,n.isType3Font)return;let r=t;t<eye?r=eye:t>tye&&(r=tye),this.current.fontSizeScale=t/r,this.current.browserFontSize=r}setTextRenderingMode(e){this.current.textRenderingMode=e}setTextRise(e){this.current.textRise=e}moveText(e,t){this.current.x=this.current.lineX+=e,this.current.y=this.current.lineY+=t}setLeadingMoveText(){}setTextMatrix(e,t,n,i,r,a){this.current.textMatrix=[e,t,n,i,r,a],this.current.textMatrixScale=Math.hypot(e,t),this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}nextLine(){this.moveText(0,this.current.leading)}paintChar(e,t,n){var i,r,a,s;let o,l,h=this.current,u=h.font,c=h.textRenderingMode,d=h.fontSize/h.fontSizeScale,p=c&ec.FillStrokeMask,f=!!(c&ec.AddToPathFlag),m=h.patternFill&&!u.missingFile;return(u.disableFontFace||f||m)&&(o=u.getPathGenerator(this.commonObjs,e)),u.disableFontFace||m?fe.log("paintChar path:",o,d,p):((p===ec.Fill||p===ec.FillStroke)&&(l=null==(r=this.fontManager)?void 0:r.getCharShape(e,null==(i=this.current.font)?void 0:i.name,.8*this.current.browserFontSize)),(p===ec.Stroke||p===ec.FillStroke)&&(l=null==(s=this.fontManager)?void 0:s.getCharShape(e,null==(a=this.current.font)?void 0:a.name,.8*this.current.browserFontSize))),l}showText(e){var t,n;let i=this.current,r=i.font;if(r.isType3Font)return this.showType3Text(e);let a=i.fontSize;if(0===a)return;let s=i.fontSizeScale,o=i.charSpacing,l=i.wordSpacing,h=i.fontDirection,u=i.textHScale*h,c=e.length,d=r.vertical,p=d?1:-1,f=r.defaultVMetrics,m=a*i.fontMatrix[0],g=i.textRenderingMode===ec.Fill&&!r.disableFontFace&&!i.patternFill,[v,y,x,b,_,w]=i.textMatrix,S=this.currentTransform.clone();S.multiply(x2.set(v,x,0,_,y,b,0,w,0,0,1,0,0,0,0,1)),S.multiply(x2.makeTranslation(i.x,i.y+i.textRise,0)),h>0?S.scale(new k(u,1,1)):S.scale(new k(u,-1,1));let M=i.lineWidth,E=i.textMatrixScale;0===E||0===M?(i.textRenderingMode&ec.FillStrokeMask)===ec.Stroke||ec.FillStroke:M/=E,1!==s&&(S.scale(new k(s,s,1)),M/=s);let T,A=0,C=[];for(T=0;T<c;++T){let i=e[T];if("number"==typeof i){A+=p*i*a/1e3;continue}let u,c,v,y=(i.isSpace?l:0)+o,x=i.unicode,b=i.accent,_=i.width;if(d){let e=i.vmetric||f,t=-(i.vmetric?e[1]:.5*_)*m,n=e[2]*m;_=e?-e[0]:_,u=t/s,c=(A+n)/s}else u=A/s,c=0;if(r.remeasure,this.contentVisible&&(i.isInFont||r.missingFile))if(g&&!b){let e=null==(n=this.fontManager)?void 0:n.getCharShape(x,null==(t=this.current.font)?void 0:t.name,this.current.browserFontSize);e&&(e.translate(u,c,0),e.applyMatrix4(S),C.push(e))}else{let e=this.paintChar(x,u,c);e&&(e.translate(u,c,0),e.applyMatrix4(S),C.push(e))}v=d?_*m-y*h:_*m+y*h,A+=v}if(C.length>0){let e=C.filter((e=>e instanceof Ws)),t=C.filter((e=>!(e instanceof Ws)));if(e.length>0){let t=e.length>1?Oi(e):e[0],n=new St(t,this.getMeshBasicMaterial(this.current.fillColor));this.addObjectToModel(n),n.layers.disable(11)}if(t.length>0){let e=t.length>1?Oi(t):t[0],n=new zr(e,this.getLineBasicMaterial(this.current.fillColor));this.addObjectToModel(n),n.layers.disable(11)}}d?i.y-=A:i.x+=A*u}showType3Text(e){}setCharWidth(e,t){}setCharWidthAndBounds(e,t,n,i,r,a){}setStrokeColor(){}setStrokeColorN(){}setFillColorN(){this.current.patternFill=!0}setStrokeRGBColor(e,t,n){this.current.strokeColor=rye.setRGB(e/255,t/255,n/255).convertSRGBToLinear().getHex()}setFillRGBColor(e,t,n){this.current.fillColor=rye.setRGB(e/255,t/255,n/255).convertSRGBToLinear().getHex(),this.current.patternFill=!1}shadingFill(){}beginInlineImage(){}beginImageData(){}markPoint(e){}markPointProps(e,t){}beginMarkedContent(e){fe.log("beginMarkedContent",e),this.markedContentStack.push({visible:!0})}beginMarkedContentProps(e,t){if("OC"===e){this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(t)});let e=this.optionalContentConfig.getGroup(null==t?void 0:t.id);this.currentLayerId=(null==e?void 0:e.name)||this.defaultLayerId}else this.markedContentStack.push({visible:!0});this.contentVisible=this.isContentVisible()}endMarkedContent(){this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(){}endCompat(){}consumePath(e){let t=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip,this.pendingClip&&(t||(this.pendingClip===nye?this.clipType=Ns.PolyFillType.pftEvenOdd:this.clipType=Ns.PolyFillType.pftNonZero,this.clipPaths=this.paths.slice()),this.pendingClip=null),this.current.startNewPathAndClipBox(this.current.clipBox),this.paths=[],this.currentPath=void 0}paintFormXObjectBegin(e,t){fe.log("paintFormXObjectBegin",e,t)}paintFormXObjectEnd(){}beginGroup(){}endGroup(){}beginAnnotation(){}endAnnotation(){}paintImageMaskXObject(){}paintImageMaskXObjectGroup(){}paintImageXObject(e){if(!this.contentVisible)return;let t=this.getObject(e);t?this.paintInlineImageXObject(t):fe.warn("Dependent image isn't ready yet")}paintInlineImageXObject(e){if(!this.contentVisible)return;fe.log("paintInlineImageXObject",e),this.save();let{bitmap:t,width:n,height:i}=e;this.currentTransform.multiply(x2.makeScale(1/n,-1/i,1));let r=new nb(t),a=new cn({map:r,transparent:!0}),s=new mi(n,i),o=new St(s,a);o.translateX(n/2),o.translateY(-i/2),o.applyMatrix4(this.currentTransform),this.addObjectToModel(o),this.restore()}paintInlineImageXObjectGroup(){}paintImageXObjectRepeat(){}paintImageMaskXObjectRepeat(){}paintSolidColorImageMask(){}_scaleImage(e,t){let n=e.width,i=e.height,r=Math.max(Math.hypot(t.elements[0],t.elements[4]),1),a=Math.max(Math.hypot(t.elements[1],t.elements[5]),1),s=n,o=i,l=s,h=o;for(;r>2&&s>1||a>2&&o>1;)r>2&&s>1&&(l=s>=16384?Math.floor(s/2)-1||1:Math.ceil(s/2),r/=s/l),a>2&&o>1&&(h=o>=16384?Math.floor(o/2)-1||1:Math.ceil(o)/2,a/=o/h),s=l,o=h;return{paintWidth:s,paintHeight:o}}constructPath(e,t,n){let i,r,a=this.current,s=a.x,o=a.y,l=[this.currentTransform.elements[0],this.currentTransform.elements[1],this.currentTransform.elements[4],this.currentTransform.elements[5],this.currentTransform.elements[12],this.currentTransform.elements[13]],h=0===l[0]&&0===l[3]||0===l[1]&&0===l[2],u=h?n.slice(0):null;for(let c=0,d=0,p=e.length;c<p;c++)switch(this.currentPath||(this.currentPath=new Ts),0|e[c]){case ii.OPS.rectangle:{s=t[d++],o=t[d++];let e=t[d++],n=t[d++],i=s+e,r=o+n;this.currentPath.moveTo(s,o),0===e||0===n?this.currentPath.lineTo(i,r):(this.currentPath.lineTo(i,o),this.currentPath.lineTo(i,r),this.currentPath.lineTo(s,r)),h||a.updateRectMinMax(l,[s,o,i,r]),this.currentPath.closePath(),this.paths.push(this.currentPath.clone()),this.currentPath=void 0}break;case ii.OPS.moveTo:s=t[d++],o=t[d++],this.currentPath.moveTo(s,o),h||a.updatePathMinMax(l,s,o);break;case ii.OPS.lineTo:s=t[d++],o=t[d++],this.currentPath.lineTo(s,o),h||a.updatePathMinMax(l,s,o);break;case ii.OPS.curveTo:i=s,r=o,s=t[d+4],o=t[d+5],this.currentPath.bezierCurveTo(t[d],t[d+1],t[d+2],t[d+3],s,o),a.updateCurvePathMinMax(l,i,r,t[d],t[d+1],t[d+2],t[d+3],s,o,u),d+=6;break;case ii.OPS.curveTo2:i=s,r=o,this.currentPath.bezierCurveTo(s,o,t[d],t[d+1],t[d+2],t[d+3]),a.updateCurvePathMinMax(l,i,r,s,o,t[d],t[d+1],t[d+2],t[d+3],u),s=t[d+2],o=t[d+3],d+=4;break;case ii.OPS.curveTo3:i=s,r=o,s=t[d+2],o=t[d+3],this.currentPath.bezierCurveTo(t[d],t[d+1],s,o,s,o),a.updateCurvePathMinMax(l,i,r,t[d],t[d+1],s,o,s,o,u),d+=4;break;case ii.OPS.closePath:this.paths.push(this.currentPath.clone()),this.currentPath=void 0}this.currentPath&&this.paths.push(this.currentPath.clone()),h&&a.updateScalingPathMinMax(l,u),this.current.setCurrentPoint(s,o)}isContentVisible(){for(let e=this.markedContentStack.length-1;e>=0;e--)if(!this.markedContentStack[e].visible)return!1;return!0}},tp=RV;tp.MODEL_LAYOUT_NAME="Model";for(let t in ii.OPS)void 0!==tp.prototype[t]&&(tp.prototype[ii.OPS[t]]=tp.prototype[t]);var b2=class{constructor(e,t){this.textMatrix=MV,this.fontMatrix=AV,this.textRenderingMode=ec.Fill,this.fillColor=0,this.strokeColor=0,this.activeSMask=null,this.lineCap=0,this.lineJoin=0,this.miterLimit=0,this.alphaIsShape=!1,this.fontSize=0,this.fontSizeScale=1,this.browserFontSize=1,this.textMatrix=MV,this.textMatrixScale=1,this.fontMatrix=AV,this.leading=0,this.x=0,this.y=0,this.lineX=0,this.lineY=0,this.charSpacing=0,this.wordSpacing=0,this.textHScale=1,this.textRenderingMode=ec.Fill,this.textRise=0,this.fillColor=0,this.strokeColor=0,this.patternFill=!1,this.fillAlpha=1,this.strokeAlpha=1,this.lineWidth=1,this.activeSMask=null,this.transferMaps="none",this.ctxMatrix=new In,this.clipBox=[0,0,e,t],this.minX=1/0,this.minY=1/0,this.maxX=0,this.maxY=0}clone(){return Object.create(this)}setCurrentPoint(e,t){this.x=e,this.y=t}startNewPathAndClipBox(e){this.clipBox=e,this.minX=1/0,this.minY=1/0,this.maxX=0,this.maxY=0}updatePathMinMax(e,t,n){[t,n]=ii.Util.applyTransform([t,n],e),this.minX=Math.min(this.minX,t),this.minY=Math.min(this.minY,n),this.maxX=Math.max(this.maxX,t),this.maxY=Math.max(this.maxY,n)}getPathBoundingBox(e=wV.Fill,t=null){let n=[this.minX,this.minY,this.maxX,this.maxY];if(e===wV.Stroke){if(!t)throw new Error("Stroke bounding box must include transform.");let e=ii.Util.singularValueDecompose2dScale(t),i=e[0]*this.lineWidth/2,r=e[1]*this.lineWidth/2;n[0]-=i,n[1]-=r,n[2]+=i,n[3]+=r}return n}updateRectMinMax(e,t){let n=ii.Util.applyTransform(t,e),i=ii.Util.applyTransform(t.slice(2),e);this.minX=Math.min(this.minX,n[0],i[0]),this.minY=Math.min(this.minY,n[1],i[1]),this.maxX=Math.max(this.maxX,n[0],i[0]),this.maxY=Math.max(this.maxY,n[1],i[1])}updateScalingPathMinMax(e,t){ii.Util.scaleMinMax(e,t),this.minX=Math.min(this.minX,t[0]),this.maxX=Math.max(this.maxX,t[1]),this.minY=Math.min(this.minY,t[2]),this.maxY=Math.max(this.maxY,t[3])}updateCurvePathMinMax(e,t,n,i,r,a,s,o,l,h){let u=ii.Util.bezierBoundingBox(t,n,i,r,a,s,o,l);if(h)return h[0]=Math.min(h[0],u[0],u[2]),h[1]=Math.max(h[1],u[0],u[2]),h[2]=Math.min(h[2],u[1],u[3]),void(h[3]=Math.max(h[3],u[1],u[3]));this.updateRectMinMax(e,u)}updateClipFromPath(){let e=ii.Util.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(e||[0,0,0,0])}isEmptyClip(){return this.minX===1/0}getClippedPathBoundingBox(e=wV.Fill,t=null){return ii.Util.intersect(this.clipBox,this.getPathBoundingBox(e,t))||[]}},CV=class extends ar{constructor(e,t){super(e,{id:(null==t?void 0:t.id)||CV.DEFAULT_ID}),this.cfg=t||{},null==this.cfg.enableProgressiveLoad&&(this.cfg.enableProgressiveLoad=!0)}loadAsync(e,t){return it(this,null,(function*(){let n=this.viewer;n.getSpinner().increaseJobCount();let i=Date.now(),r=n.getFontManager(),a=this.cfg.pdfWorker;this.loader||(this.loader=new tp({font:r,pdfWorker:a})),this.cfg.enableProgressiveLoad&&(this.loader.progressiveLoadCallback=(r,a)=>{let s=n.camera.position;r&&s.z<r&&n.getCameraManager().setCameraPosition(new k(s.x,s.y,r)),a&&(Pt.getUpdateProgressFunc(t)(100),fe.info(`[PdfLoader] Progressively loaded '${e.src}' in ${(Date.now()-i)/1e3}s`),n.getSpinner().decreaseJobCount()),n.enableRender()});let s=yield this.loader.loadAsync(e,t);return this.cfg.enableProgressiveLoad||n.getSpinner().decreaseJobCount(),new jl(s)}))}loadPage(e,t){return it(this,null,(function*(){var n;return null==(n=this.loader)?void 0:n.loadPage(e,t)}))}getPageCount(){var e;return null==(e=this.loader)?void 0:e.getPageCount()}getPdfViewport(){var e;let t=null==(e=this.loader)?void 0:e.viewportMesh;return t?(new Nt).setFromObject(t):void 0}worldPosition2PdfPoint(e){let t=this.getPdfViewport(),n=(null==t?void 0:t.min)||new k,i=new k;null==t||t.getSize(i);let r=i.x,a=i.y;return{x:(e.x-n.x)/r,y:(e.y-n.y)/a}}pdfPoint2WorldPosition(e){let t=this.getPdfViewport(),n=(null==t?void 0:t.min)||new k,i=new k;null==t||t.getSize(i);let r=i.x,a=i.y;return{x:e.x*r+n.x,y:e.y*a+n.y}}},R_=CV;R_.DEFAULT_ID="PdfLoaderPlugin";var iye=class extends ep{constructor(e,t){super(t),this.pdfWorker="",this.defaultModelConfig={src:"",merge:!0},this.viewer=e}setPdfWorker(e){this.pdfWorker=e}formats(){return["dxf","pdf"]}uploadFiles(e){for(let t=0;t<e.length;t++){let n=e[t];n.name.match(/\.(dxf)$/)?this.uploadSingleDxf(n):n.name.match(/\.(pdf)$/)&&this.uploadSinglePdf(n)}}uploadSingleDxf(e){return it(this,null,(function*(){let t=Ci(Ir({},this.defaultModelConfig),{src:URL.createObjectURL(e),modelId:e.name});yield this.viewer.loadModelAsync(t,(t=>{let n=Math.floor(100*t.loaded/t.total);fe.info(`[Uploader] Loading ${null==e?void 0:e.name}, ${n}%`)}))}))}uploadSinglePdf(e){return it(this,null,(function*(){let t=t=>{let n=Math.floor(100*t.loaded/t.total);fe.info(`[Uploader] Loading ${null==e?void 0:e.name}, ${n}%`)};try{let n=this.viewer,i={font:n.fontManager,pdfWorker:this.pdfWorker,enableProgressiveLoad:!0},r={merge:!0,src:URL.createObjectURL(e),modelId:e.name};new R_(n,i).loadAsync(r,t).then((e=>{this.viewer.addModel(e),this.onSuccess&&this.onSuccess({})}))}catch(e){fe.info(e)}}))}},sye=class extends ep{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 fe.warn(`[Uploader] Expected 1 or 6 file, bug got ${e.length}!`)}},aye=new k,v1t=new _r,oye=new k,ng=class extends an{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}},Ku=new ht,y1t=new ht,E2=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 u(e){return Math.abs(e)<1e-10?0:e}function c(e){let t=e.elements;return"matrix3d("+u(t[0])+","+u(-t[1])+","+u(t[2])+","+u(t[3])+","+u(t[4])+","+u(-t[5])+","+u(t[6])+","+u(t[7])+","+u(t[8])+","+u(-t[9])+","+u(t[10])+","+u(t[11])+","+u(t[12])+","+u(-t[13])+","+u(t[14])+","+u(t[15])+")"}function d(e){let t=e.elements;return"translate(-50%,-50%)matrix3d("+u(t[0])+","+u(t[1])+","+u(t[2])+","+u(t[3])+","+u(-t[4])+","+u(-t[5])+","+u(-t[6])+","+u(-t[7])+","+u(t[8])+","+u(t[9])+","+u(t[10])+","+u(t[11])+","+u(t[12])+","+u(t[13])+","+u(t[14])+","+u(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?(Ku.copy(n.matrixWorldInverse),Ku.transpose(),0!==e.rotation2D&&Ku.multiply(y1t.makeRotationZ(e.rotation2D)),e.matrixWorld.decompose(aye,v1t,oye),Ku.setPosition(aye),Ku.scale(oye),Ku.elements[3]=0,Ku.elements[7]=0,Ku.elements[11]=0,Ku.elements[15]=1,i=d(Ku)):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("+u(o)+"px,"+u(d)+"px)"+c(a.matrixWorldInverse):`scale( ${m} )translateZ(`+f+"px)"+c(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"}}},rg=ss(Lc(),1),lye="#2C7BE5",fi=Math.PI/2,Nr=Math.PI/4,Zs=([e,t,n],[i,r,a])=>({position:new k(e,t,n),rotation:new Xn(i,r,a)}),x1t={Front:Ci(Ir({},Zs([0,0,1],[0,0,0])),{label:"NavCube.front"}),Right:Ci(Ir({},Zs([1,0,0],[0,fi,0])),{label:"NavCube.right"}),Back:Ci(Ir({},Zs([0,0,-1],[0,Math.PI,0])),{label:"NavCube.back"}),Left:Ci(Ir({},Zs([-1,0,0],[0,-fi,0])),{label:"NavCube.left"}),Top:Ci(Ir({},Zs([0,1,0],[-fi,0,0])),{label:"NavCube.top"}),Bottom:Ci(Ir({},Zs([0,-1,0],[fi,0,0])),{label:"NavCube.bottom"})},b1t=[Zs([0,1,1],[-Nr,0,-fi]),Zs([0,1,-1],[-3*Nr,0,-fi]),Zs([0,-1,1],[Nr,0,-fi]),Zs([0,-1,-1],[3*Nr,0,-fi]),Zs([1,1,0],[-fi,Nr,0]),Zs([1,-1,0],[-fi,3*Nr,0]),Zs([-1,1,0],[-fi,-Nr,0]),Zs([-1,-1,0],[-fi,-3*Nr,0]),Zs([1,0,1],[0,Nr,0]),Zs([1,0,-1],[0,3*Nr,0]),Zs([-1,0,1],[0,-Nr,0]),Zs([-1,0,-1],[0,-3*Nr,0])],E1t=[{position:new k(1,1,1),rotation:[new Xn(-fi,fi,-Nr),new Xn(-fi,0,Nr),new Xn(0,0,3*Nr)]},{position:new k(1,1,-1),rotation:[new Xn(0,fi,3*Nr),new Xn(-fi,0,3*Nr),new Xn(0,Math.PI,-3*Nr)]},{position:new k(-1,1,-1),rotation:[new Xn(Math.PI,-fi,Nr),new Xn(-fi,0,-3*Nr),new Xn(0,Math.PI,3*Nr)]},{position:new k(-1,1,1),rotation:[new Xn(0,-fi,3*Nr),new Xn(-fi,0,-Nr),new Xn(0,0,-3*Nr)]},{position:new k(1,-1,1),rotation:[new Xn(0,fi,-Nr),new Xn(-fi,Math.PI,-Nr),new Xn(0,0,Nr)]},{position:new k(1,-1,-1),rotation:[new Xn(-fi,fi,3*Nr),new Xn(fi,0,Nr),new Xn(0,Math.PI,-Nr)]},{position:new k(-1,-1,1),rotation:[new Xn(0,-fi,Nr),new Xn(fi,0,-3*Nr),new Xn(0,0,-Nr)]},{position:new k(-1,-1,-1),rotation:[new Xn(0,-fi,-Nr),new Xn(fi,0,-Nr),new Xn(0,Math.PI,Nr)]}],_2=class extends an{constructor(e={}){super(),this.NAVCUBE_SIZE=100,this.clickHandler=e.onClick,(0,rg.forEach)(x1t,(e=>{this.createPlane(e)})),(0,rg.forEach)(b1t,(e=>{this.createEdge(e)})),(0,rg.forEach)(E1t,((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=wr(i),a.classList.add("navcube-plane"),a.classList.add("inner"),r.appendChild(a);let s=new ng(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=lye,n.classList.add("navcube-edge");let i=new ng(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 Xn)})),n.addEventListener("mouseenter",(()=>{let e=document.getElementsByClassName("group-"+t);(0,rg.forEach)(e,(e=>{e instanceof HTMLElement&&e.classList.add("highlight")}))})),n.addEventListener("mouseleave",(()=>{let e=document.getElementsByClassName("group-"+t);(0,rg.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 ng(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 Xn).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 ${lye}`,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 ng(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,rg.forEach)(e.rotation,((e,n)=>{l(e,t,n)})),n(r)}},IV=class extends ar{constructor(e,t){super(e,{id:(null==t?void 0:t.id)||IV.DEFAULT_ID}),this.cfg=t||{},this.init()}init(){this.initRenderer(),this.initScene(),this.animate()}initRenderer(){var e;let t,n=135,i=135;if(this.cfg.containerId&&(t=document.getElementById(this.cfg.containerId),t&&(n=t.clientWidth,i=t.clientHeight)),!t){let n="navCube";t=document.createElement("div"),t.id=n,null==(e=this.viewer.widgetContainer)||e.appendChild(t)}this.renderer=new E2,this.renderer.setSize(n,i),this.renderer.domElement.classList.add("css3d-navcube"),t.appendChild(this.renderer.domElement)}initScene(){this.scene=new Ji;let e=window.innerWidth/window.innerHeight;this.camera=new xi(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 _2({onClick:e=>this.viewer.flyToDirection(e)}),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()}update(){let e=this.viewer.camera;if(e){let t=new k;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)}destroy(){super.destroy(),this.scene&&this.camera&&this.navCube&&(this.scene.clear(),this.camera=void 0,this.navCube=void 0,this.scene=void 0)}},PV=IV;PV.DEFAULT_ID="NavCubePlugin";var C_=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 C_.Panel("FPS","#0ff","#002")),l=n(new C_.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var h=n(new C_.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}};C_.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,u=2*s,c=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,u),g.fillRect(c,d,p,f),g.fillStyle=n,g.globalAlpha=.9,g.fillRect(c,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,u),g.drawImage(m,c+s,d,p-s,f,c,d,p-s,f),g.fillRect(c+p-s,d,s,f),g.fillStyle=n,g.globalAlpha=.9,g.fillRect(c+p-s,d,s,a((1-l/v)*f))}}};var cye=C_,uye=class extends ar{constructor(e){super(e,{id:"StatsPlugin"}),this.init()}init(){var e;let t=new cye;t.setMode(0);let n=document.createElement("div");n.classList.add("statsOutput"),n.appendChild(t.domElement),null==(e=this.viewer.widgetContainer)||e.append(n),this.stats=t,this.viewer.addEventListener("OnAnimate",(()=>{var e;null==(e=this.stats)||e.update()}))}show(){var e;null==(e=this.stats)||e.showPanel(0)}hide(){var e;null==(e=this.stats)||e.showPanel(-1)}destroy(){super.destroy(),this.stats=void 0}},P_=class extends St{constructor(e,t,n,i=4e3,r=32,a=15,s=new k,o=new k(0,.7,.5)){super();let l={topColor:{value:e},skylineColor:{value:t},bottomColor:{value:n},offset:{value:400},exponent:{value:.9},skyCenter:{value:s||new k},sunDirection:{value:o.normalize()}};this.geometry=new Va(i,r,a),this.material=new hn({uniforms:l,vertexShader:P_.vertexShader,fragmentShader:P_.fragmentShader,side:Ki}),this.name=P_.NAME,this.matrixAutoUpdate=!1,this.layers.disable(12)}},el=P_;el.NAME="SKYBOX",el.MIN_SKY_RADIUS=4e3,el.MAX_SKY_RADIUS=2e4,el.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 }",el.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 }";var DV=class extends ar{constructor(e,t){let n=(null==t?void 0:t.id)||DV.DEFAULT_ID;super(e,{id:n}),null!=t&&t.color?this.setSkyboxByColor(t.color):this.setSkyboxByGradientColors(),e.addEventListener("ModelLoaded",(()=>{let t=e.getBBox(),n=this.viewer.cameraCfg;if(t){if(t=t.clone(),n&&n.eye&&n.look){let e=n&&Pt.arrayToVector3(n.eye),i=n&&Pt.arrayToVector3(n.look),r=new Nt;r.setFromPoints([e,i]),t.union(r)}this.updateGradientColorSkybox(t)}}))}setSkyboxByColor(e=[.92,.95,.96]){this.gradientColorSkybox&&(this.gradientColorSkybox.visible=!1),this.viewer.setBackground(this.rgb2Color(e)),this.viewer.enableRender()}setSkyboxByGradientColors(e=[.52,.71,.96],t=[1,1,1],n=[.6,.6,.6]){this.gradientColorSkybox&&(this.gradientColorSkybox.removeFromParent(),this.gradientColorSkybox=void 0);let i=this.rgb2Color(e),r=this.rgb2Color(t),a=this.rgb2Color(n);this.gradientColorSkybox=new el(i,r,a),this.viewer.scene.add(this.gradientColorSkybox),this.viewer.enableRender()}setSkyboxByCubeTexture(e){this.gradientColorSkybox&&(this.gradientColorSkybox.visible=!1);let t=new hb;this.viewer.setBackground(t.load(e)),this.viewer.enableRender()}updateGradientColorSkybox(e){if(!this.gradientColorSkybox)return;let t=2*(e.max.x-e.min.x+(e.max.y-e.min.y)+(e.max.z-e.min.z));t<el.MIN_SKY_RADIUS?t=el.MIN_SKY_RADIUS:t>el.MAX_SKY_RADIUS&&(t=el.MAX_SKY_RADIUS),this.gradientColorSkybox.geometry=new Va(t,32,15),this.viewer.enableRender()}destroy(){var e;super.destroy(),null==(e=this.gradientColorSkybox)||e.removeFromParent(),this.gradientColorSkybox=void 0,this.viewer.setBackground(null)}rgb2Color(e){let t=e[0]||0,n=e[1]||0,i=e[2]||0,r=new ct;return r.setRGB(t,n,i),r}},LV=DV;LV.DEFAULT_ID="SkyboxPlugin";var L_=ss(Lc(),1),fs=ss(Lc(),1),T2=(e=>(e[e.ClickEvent=1]="ClickEvent",e[e.Popup=2]="Popup",e[e.SubMenu=3]="SubMenu",e[e.Switch=4]="Switch",e))(T2||{}),OV=(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))(OV||{}),w2=[["HomeView","OrthoMode","FullScreen","ZoomToRectangle","GetScreenshot"],["Measure","Markup","MarkupVisibility","Section"],["BimTree","Viewpoint","Annotation","Property","Compared","QuitCompare","Layers"],["Settings"]],np=class{constructor(e,t,n=[]){this.visible=!0,this.menuList=new Map,this.keydown=e=>{var t;if(this.visible&&"Escape"===e.code){let e=this.viewer.findPlugin("MeasurementPlugin");if(null!=e&&e.isMeasuring()||null!=(t=this.viewer.getMarkupManager())&&t.isMarkupActive())return;this.clearActive()}},this.viewer=e,this.menuCfg=t,this.groupCfg=n,this.init(),window.addEventListener("keydown",this.keydown,!1)}init(){var e;let t=document.createElement("div");t.classList.add("toolbar");let n=this.menuCfg;this.groupCfg.forEach(((e,i)=>{let r=document.createElement("div");r.classList.add("toolbar-group");let a=document.createElement("div");a.classList.add("toolbar-group-division"),e.forEach((e=>{let t=(0,fs.get)(n,e);if(t&&!1!==t.visible){let n=this.createToolbarMenu(this.viewer,e,t);r.appendChild(n.element)}})),r.hasChildNodes()&&(i&&t.appendChild(a),t.appendChild(r))})),this.element=t,null==(e=this.viewer.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 kV(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,fs.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,fs.assign)(this.menuCfg[e],t),this.refresh()}updateMenus(e){(0,fs.forEach)(e,(({menuId:e,config:t})=>{(0,fs.assign)(this.menuCfg[e],t)})),this.refresh()}addMenu(e,t,n){if((0,fs.keys)(this.menuCfg).includes(e))fe.error("[Toolbar]",e,"exists.");else{if((0,fs.assign)(this.menuCfg,{[e]:t}),n){let[t,i]=n;if(t>this.groupCfg.length-1)this.groupCfg=(0,fs.concat)(this.groupCfg,[[e]]);else{let n=this.groupCfg[t];this.groupCfg[t]=i>n.length-1?(0,fs.concat)(n,e):(0,fs.concat)((0,fs.take)(n,i),e,(0,fs.takeRight)(n,n.length-i))}}else this.groupCfg=(0,fs.concat)(this.groupCfg,[[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)}},kV=class{constructor(e,t,n,i,r){this.eventBus=x1(),this.toolbar=t,this.menuId=n,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,fs.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&&hR(this.element.firstChild.classList,i.icon,this.active),r&&r.setActive(t)})),dr.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=fR}=n.icon;return i.innerHTML=`<div class="icon ${a} ${r}"></div>`,i.title=wr(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)}},hye={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=An.rgba2Color(e.getMarkupLineColor()),a.click(),a.oninput=t=>{let n=t.target.value;e.setMarkupLineColor(...An.color2rgba(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=wr(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=wr(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=>{fe.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=wr(n.menuName),i.innerHTML+=`<span>${i.title}</span>`,i},onClick:e=>{var t;null==(t=e.getMarkupManager())||t.deactivate(),e.dispatchEvent("MarkupDeactivated")},type:1,menuName:"Toolbar.quitMarkup"}},dye=[["Arrow","Rect","CloudRect","PolyLine","Ellipse","Circle","Text","StrokeStyle","FontSize","MarkupClear","MarkupQuit"]],S2=class extends np{constructor(e,t,n=[]){super(e,t,n),this.keydown=()=>{}}},L1=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(cH,this.start),i.addEventListener(lH,this.stop),document.body.addEventListener(mf,this.follow),this.container.appendChild(this.element)}destroy(){document.body.removeEventListener(mf,this.follow),this.element.removeEventListener(cH,this.start),this.element.removeEventListener(lH,this.stop),this.element.remove()}},M2=class extends L1{constructor(e){super("axis-section-pop-panel",wr("Toolbar.axisSection"),e.widgetContainer),this.axis="x",this.isVisible=!0,this.keydown=e=>{"Escape"===e.code&&this.destroy()};let t=e.findPlugin(Yc.DEFAULT_ID);this.section=t.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("gemini-viewer-icon"),n.classList.add(t),e.innerHTML="",e.appendChild(n)},t=wr("ContextMenu.hideSectionPlane"),n=wr("ContextMenu.showSectionPlane"),i=((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",t,"icon-hidesectionplane");i.onclick=()=>{this.isVisible=!this.isVisible,this.isVisible?(e(i,"icon-hidesectionplane"),i.setAttribute("title",t)):(e(i,"icon-showsectionplane"),i.setAttribute("title",n)),this.section.setSectionPlaneVisible(this.isVisible)},this.activeSelectNode&&this.activeSelectNode.appendChild(i)}},A2=class extends L1{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()};let t=e.findPlugin(Yc.DEFAULT_ID);this.section=t.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=wr("ContextMenu.hideSectionPlane"),i=wr("ContextMenu.showSectionPlane"),r=wr("PopPanel.reset"),a=t("visible",n,"icon-hidesectionplane");a.onclick=()=>{this.enabled&&(this.isVisible=!this.isVisible,this.isVisible?(e(a,"icon-hidesectionplane"),a.setAttribute("title",n)):(e(a,"icon-showsectionplane"),a.setAttribute("title",i)),this.section.setSectionPlaneVisible(this.isVisible))},this.activeSelectNode&&this.activeSelectNode.appendChild(a),this.visibleNode=a;let s=t("reset",r,"icon-reset");s.onclick=t=>{t.stopPropagation(),this.enabled&&(this.isVisible=!0,e(a,"icon-hidesectionplane"),a.setAttribute("title",n),this.section.reset())},this.activeSelectNode&&this.activeSelectNode.appendChild(s),this.resetNode=s}enable(){this.enabled=!0,this.visibleNode&&this.visibleNode.classList.remove("disable")}disable(){this.enabled=!1,this.visibleNode&&this.visibleNode.classList.add("disable")}},Za,Mo=e=>e.findPlugin(Jm.DEFAULT_ID),I_=e=>e.findPlugin(Yc.DEFAULT_ID),_1t=e=>e.findPlugin(Zf.DEFAULT_ID),R2=e=>t=>{let n=Mo(t),i=I_(t);null==i||i.deactivate(),null==n||n.activate(e)},C2=e=>{let t=Mo(e);null==t||t.deactivate()},FV=e=>{let t=Mo(e);t&&(t.deactivate(),t.getData().forEach((e=>t.setVisibleById(e.id,!1))))},NV=e=>{let t=Mo(e);t&&(t.deactivate(),t.getData().forEach((e=>t.setVisibleById(e.id,!0))));let n=I_(e);null==n||n.deactivate(!1),null==Za||Za.destroy(),Za=void 0,e.enableRender()},fye={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=>{fe.info("[Toolbar]","Enter OrthoMode"),e.setCameraProjection(1)},onDeactive:e=>{fe.info("[Toolbar]","Exit OrthoMode"),e.setCameraProjection(0)}},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:R2("Distance"),onDeactive:C2,type:4,mutexIds:["MeasureArea","MeasureAngle","MeasureCoordinate"]},MeasureArea:{icon:{default:"icon-measure-area-color"},onActive:R2("Area"),onDeactive:C2,type:4,menuName:"Toolbar.areaMeasurement",mutexIds:["MeasureDistance","MeasureAngle","MeasureCoordinate"]},MeasureAngle:{menuName:"Toolbar.angleMeasurement",icon:{default:"icon-angle-measure"},type:4,onActive:R2("Angle"),onDeactive:C2,mutexIds:["MeasureDistance","MeasureArea","MeasureCoordinate"]},MeasureCoordinate:{menuName:"Toolbar.coordinateMeasurement",icon:{default:"icon-distancemeasure",iconFont:"gemini-viewer-icon"},type:4,onActive:R2("Coordinate"),onDeactive:C2,mutexIds:["MeasureDistance","MeasureArea","MeasureAngle"]},MeasureClear:{icon:{default:"icon-clear",active:"icon-clear-filled",iconFont:"gemini-viewer-icon"},onClick:e=>{let t=Mo(e);null==t||t.deactivate(),null==t||t.clear()},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=>{FV(e);let t=I_(e);null==t||t.activate("AxisPlaneSection"),null==Za||Za.destroy(),Za=new M2(e)},onDeactive:NV,mutexIds:["SectionBox","SectionPlane"]},SectionPlane:{icon:{default:"icon-choosesectionplane",active:"icon-choosesectionplane-filled",iconFont:"gemini-viewer-icon"},menuName:"Toolbar.pickSectionPlane",type:4,onActive:e=>{FV(e);let t=I_(e);null==t||t.activate("PickPlaneSection"),null==Za||Za.destroy(),Za=new A2(e)},onDeactive:NV,mutexIds:["SectionAxis","SectionBox"]},SectionBox:{icon:{default:"icon-sectionbox",active:"icon-sectionbox-filled",iconFont:"gemini-viewer-icon"},menuName:"Toolbar.sectionBox",type:4,onActive:e=>{FV(e);let t=I_(e);null==t||t.activate("ObjectsBoxSection"),null==Za||Za.destroy()},onDeactive:NV,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:()=>{fe.info("[Toolbar]","Activate Bim Tree")},onDeactive:()=>{fe.info("[Toolbar]","Deactivate Bim Tree")},visible:!1},Viewpoint:{icon:{default:"icon-viewpoint",active:"icon-viewpoint-filled",iconFont:"gemini-viewer-icon"},menuName:"Toolbar.viewpoint",type:4,onActive:()=>{fe.info("[Toolbar]","Activate Viewpoint")},onDeactive:()=>{fe.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:()=>{fe.info("[Toolbar]","Activate Annotation")},onDeactive:()=>{fe.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:()=>{fe.info("[Toolbar]","Activate Property")},onDeactive:()=>{fe.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:()=>{fe.info("[Toolbar]","Activate Settings")},onDeactive:()=>{fe.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(Pt.isFullScreen())};Pt.isFullScreen()?(Pt.exitFullscreen(),window.removeEventListener("resize",i)):Pt.fullScreen(null==(n=e.viewerContainer)?void 0:n.parentElement),window.addEventListener("resize",i)}}},pye={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,t)=>{let n=e;n.removeEventListener("BoxSelectDeactivated"),n.addEventListener("BoxSelectDeactivated",(()=>{null==t||t.setActive("ZoomToRectangle",!1)})),n.zoomToRect()},mutexIds:["GetScreenshot"]},GetScreenshot:{icon:{default:"icon-frame-clipping",active:"icon-frame-clipping"},menuName:"Toolbar.screenshot",type:4,onClick:(e,t)=>{let n=e;n.removeEventListener("BoxSelectDeactivated"),n.addEventListener("BoxSelectDeactivated",(()=>{null==t||t.setActive("GetScreenshot",!1)}));let i=_1t(e);null==i||i.getScreenshotAsync().then((e=>{if(fe.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((e=>{fe.error("[Toolbar] Failed to get screenshot, reason:",e),null==t||t.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=>{let t=Mo(e);null==t||t.activate("Distance")},onDeactive:e=>{let t=Mo(e);null==t||t.deactivate()},type:4,mutexIds:["MeasureArea","MeasureAngle","MeasureCoordinate","ZoomToRectangle","GetScreenshot"]},MeasureArea:{icon:{default:"icon-measure-area-color"},onActive:e=>{let t=Mo(e);null==t||t.activate("Area")},onDeactive:e=>{let t=Mo(e);null==t||t.deactivate()},type:4,menuName:"Toolbar.areaMeasurement",mutexIds:["MeasureDistance","MeasureAngle","MeasureCoordinate","ZoomToRectangle","GetScreenshot"]},MeasureAngle:{menuName:"Toolbar.angleMeasurement",icon:{default:"icon-angle-measure"},type:4,onActive:e=>{let t=Mo(e);null==t||t.activate("Angle")},onDeactive:e=>{let t=Mo(e);null==t||t.deactivate()},mutexIds:["MeasureDistance","MeasureArea","MeasureCoordinate","ZoomToRectangle","GetScreenshot"]},MeasureCoordinate:{menuName:"Toolbar.coordinateMeasurement",icon:{default:"icon-distancemeasure",iconFont:"gemini-viewer-icon"},type:4,onActive:e=>{let t=Mo(e);null==t||t.activate("Coordinate")},onDeactive:e=>{let t=Mo(e);null==t||t.deactivate()},visible:!1,mutexIds:["MeasureDistance","MeasureArea","MeasureAngle","ZoomToRectangle","GetScreenshot"]},MeasureClear:{icon:{default:"icon-clear",active:"icon-clear-filled",iconFont:"gemini-viewer-icon"},onClick:e=>{let t=Mo(e);null==t||t.clear()},type:1,menuName:"Toolbar.clearMeasurement"}}},Markup:{icon:{default:"icon-annotation"},menuName:"Toolbar.markup",type:1,onClick:(e,t)=>{let n=e;null==t||t.updateMenu("Measure",{defaultActive:!1}),null==t||t.setActive("ZoomToRectangle",!1),n.getMarkups().forEach((e=>n.setMarkupVisibility(e.id,!0))),null==t||t.setActive("MarkupVisibility",!1),n.activateMarkup("CloudRectWithTextMarkup"),e.dispatchEvent("MarkupActivated")}},MarkupVisibility:{icon:{default:"icon-annotation-show",active:"icon-annotation-hide"},menuName:"Toolbar.markupVisibility",type:4,onActive:e=>{let t=e;t.getMarkups().forEach((e=>t.setMarkupVisibility(e.id,!1)))},onDeactive:e=>{let t=e;t.getMarkups().forEach((e=>t.setMarkupVisibility(e.id,!0)))},visible:!0},Settings:{icon:{default:"icon-settings",active:"icon-settings-filled",iconFont:"gemini-viewer-icon"},menuName:"Toolbar.settings",type:4,onActive:()=>{fe.info("[Toolbar]","Activate Settings")},onDeactive:()=>{fe.info("[Toolbar]","Deactivate Settings")},visible:!0},Compared:{icon:{default:"icon-compared"},menuName:"Toolbar.compared",type:4,onActive:()=>{fe.info("[Toolbar]","Activate Compare")},onDeactive:()=>{fe.info("[Toolbar]","Deactivate Compare")},visible:!1},QuitCompare:{icon:{default:"icon-compared"},menuName:"Toolbar.quitCompare",type:4,onActive:()=>{fe.info("[Toolbar]","Activate Compare")},onDeactive:()=>{fe.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(Pt.isFullScreen())};Pt.isFullScreen()?(Pt.exitFullscreen(),window.removeEventListener("resize",i)):Pt.fullScreen(null==(n=e.viewerContainer)?void 0:n.parentElement),window.addEventListener("resize",i)}}},UV=class extends ar{constructor(e,t){super(e,{id:(null==t?void 0:t.id)||UV.DEFAULT_ID}),this.onMarkupActivated=()=>{if(!this.markupToolbar){let e=(0,L_.merge)(this.cfg.markupMenuCfg||[],hye),t=(0,L_.merge)(this.cfg.markupGroupCfg||[],dye);this.markupToolbar=new S2(this.viewer,e,t),this.markupToolbar.hide()}this.toolbar.hide(),this.markupToolbar.show()},this.onMarkupDeactivated=()=>{var e;null==(e=this.markupToolbar)||e.hide(),this.toolbar.show()},this.cfg=t||{};let n=(0,L_.merge)({},pye,this.cfg.menuConfig),i=(0,L_.merge)(this.cfg.groupConfig||[],w2);this.toolbar=new np(e,n,i),this.viewer.addEventListener("MarkupActivated",this.onMarkupActivated),this.viewer.addEventListener("MarkupDeactivated",this.onMarkupDeactivated)}getToolbar(){return this.toolbar}getMarkupToolbar(){return this.markupToolbar}setActive(e,t){this.toolbar.setActive(e,t)}destroy(){var e;super.destroy(),null==(e=this.markupToolbar)||e.destroy(),this.toolbar.destroy()}},BV=UV;BV.DEFAULT_ID="DxfViewerToolbarPlugin";var VV=ss(Lc(),1),zV=class extends ar{constructor(e,t){super(e,{id:(null==t?void 0:t.id)||zV.DEFAULT_ID}),this.cfg=t||{};let n=(0,VV.merge)({},fye,this.cfg.menuConfig),i=(0,VV.merge)(this.cfg.groupConfig||[],w2);this.toolbar=new np(e,n,i)}getToolbar(){return this.toolbar}setActive(e,t){this.toolbar.setActive(e,t)}destroy(){super.destroy(),this.toolbar.destroy()}},HV=zV;function T1t(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}HV.DEFAULT_ID="BimViewerToolbarPlugin";var w1t=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}),P2=class extends Hr{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 k,t=new _e,n=new k,i=new k,r=new _e;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 u=n.distanceTo(e);if(o.isPerspectiveCamera&&(u*=2*Math.tan(Un.degToRad(o.fov)/2)),(o.isPerspectiveCamera||o.isOrthographicCamera)&&(u/=o.zoom),u){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/u*(t.x/r.x),i.y/u*(t.y/r.y)),e/r.x,e/r.y)}}return 0}},this.cfg=Ir(Ir({},w1t),e);let{text:n}=this.cfg;this.lines=n?n.split("\n"):[];let{fontFamily:i,fontSize:r,fontStyle:a,fontVariant:s,fontWeight:o}=this.cfg;this.font=T1t(i,r,a,s,o)}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 Un.ceilPowerOfTwo(this.width*this.pixelRatio)}getDrawingBufferHeight(){return Un.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=Ir(Ir({},this.cfg),e),this.needsRedraw=!0}};function GV(e,t,n){let i=new ct(e),r=new ct(t);return i.lerp(r,n).getHex()}var Cr=(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))(Cr||{}),Ju=new k(1,0,0),wa=new k(0,1,0),Rs=new k(0,0,1),mye={right:{text:"right",name:"RightFace",position:new k(50,0,0),rotation:{axis:wa,rad:Cr.Rotate90}},left:{text:"left",name:"LeftFace",position:new k(-50,0,0),rotation:{axis:wa,rad:Cr.Rotate270}},top:{text:"top",name:"TopFace",position:new k(0,50,0),rotation:{axis:Ju,rad:Cr.Rotate270}},bottom:{text:"bottom",name:"BottomFace",position:new k(0,-50,0),rotation:{axis:Ju,rad:Cr.Rotate90}},front:{text:"front",name:"FrontFace",position:new k(0,0,50),rotation:{axis:wa,rad:0}},back:{text:"back",name:"BackFace",position:new k(0,0,-50),rotation:{axis:wa,rad:Cr.Rotate180}}},I2=class extends an{constructor(e){super(),this.name="ViewCube",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.INNER_CUBE_WIDTH=76,this.OUTER_CUBE_WIDTH=100,this.CORNER_WIDTH=(this.OUTER_CUBE_WIDTH-this.INNER_CUBE_WIDTH)/2,this.AXIS_LENGTH=1.3*this.OUTER_CUBE_WIDTH,this.EDGE_COLOUR=13290452,this.EDGE_OPACITY=.1,this.EDGE_SIZE=new _e(this.INNER_CUBE_WIDTH,this.CORNER_WIDTH),this.CORNER_COLOR=13290452,this.CORNER_OPACITY=1,this.faces=[],this.dirty=!1,this.showAxes=(null==e?void 0:e.showAxes)||!1,this.lineColor=(null==e?void 0:e.lineColor)||9343125,this.init()}init(){this.showAxes&&this.add(this.createAxes()),this.add(this.createViewCubeFaces()),this.add(this.createViewCubeEdges()),this.add(this.createViewCubeCorners())}createAxes(){let e=this.OUTER_CUBE_WIDTH/2+1,t=new an,n=new k(-e,-e,-e),i=new k(1,0,0),r=new k(0,1,0),a=new k(0,0,1),s=this.AXIS_LENGTH/15,o=this.AXIS_LENGTH/20,l=new Rc(i,n,this.AXIS_LENGTH,this.AXIS_COLOR_X,s,o),h=new Rc(r,n,this.AXIS_LENGTH,this.AXIS_COLOR_Y,s,o),u=new Rc(a,n,this.AXIS_LENGTH,this.AXIS_COLOR_Z,s,o);return t.add(l,h,u),t}createViewCubeFaces(){let e=new an,t=[],n=new za({color:this.FACE_BACKGROUND_COLOR,opacity:0,transparent:!0});Object.keys(mye).forEach((e=>{let i=mye[e],r=wr(`NavCube.${i.text}`)||i.text,a=new P2({text:r,fontSize:18,color:"#333333",backgroundColor:this.FACE_BACKGROUND_COLOR,padding:.8,fontWeight:"bold"});a.redrew();let s=new za({color:this.FACE_BACKGROUND_COLOR,map:a,opacity:1,transparent:!0});t.push(s);let o=this.createViewCubeFace(i.name,n,i.position,i.rotation);o.layers.enableAll(),o.userData={material:s,tick:0,translateTick:0},this.faces.push(o)})),e.add(...this.faces);let i=new ma(this.INNER_CUBE_WIDTH,this.INNER_CUBE_WIDTH,this.INNER_CUBE_WIDTH),r=new St(i,t);this.innerViewCubeMesh=r,e.add(r);let a=new Au(new ma(this.OUTER_CUBE_WIDTH,this.OUTER_CUBE_WIDTH,this.OUTER_CUBE_WIDTH)),s=new cn({color:this.lineColor}),o=new zr(a,s);return e.add(o),e.position.set(0,0,0),e}createViewCubeFace(e,t,n,i){let r=new mi(this.INNER_CUBE_WIDTH,this.INNER_CUBE_WIDTH),a=new St(r,t);return a.name=e,a.rotateOnAxis(i.axis,i.rad),a.position.copy(n),a}createViewCubeEdges(){let e=new an,t=this.OUTER_CUBE_WIDTH/2+1,n=this.createEdge("TopFrontEdge",new k(0,t,t),[{axis:Rs,rad:Cr.Rotate180}]),i=this.createEdge("TopRightEdge",new k(t,t,0),[{axis:Ju,rad:Cr.Rotate180},{axis:wa,rad:Cr.Rotate90},{axis:Rs,rad:0}]),r=this.createEdge("TopBackEdge",new k(0,t,-t),[{axis:Rs,rad:Cr.Rotate180},{axis:wa,rad:Cr.Rotate180}]),a=this.createEdge("TopLeftEdge",new k(-t,t,0),[{axis:Ju,rad:Cr.Rotate90},{axis:wa,rad:Cr.Rotate180},{axis:Rs,rad:Cr.Rotate90}]),s=this.createEdge("BottomFrontEdge",new k(0,-t,t),[{axis:Rs,rad:0}]),o=this.createEdge("BottomRightEdge",new k(t,-t,0),[{axis:Ju,rad:Cr.Rotate90},{axis:wa,rad:0},{axis:Rs,rad:Cr.Rotate90}]),l=this.createEdge("BottomBackEdge",new k(0,-t,-t),[{axis:Rs,rad:0},{axis:wa,rad:Cr.Rotate180}]),h=this.createEdge("BottomLeftEdge",new k(-t,-t,0),[{axis:Ju,rad:Cr.Rotate90},{axis:wa,rad:Cr.Rotate270},{axis:Rs,rad:Cr.Rotate90}]),u=this.createEdge("FrontRightEdge",new k(t,0,t),[{axis:Rs,rad:Cr.Rotate90}]),c=this.createEdge("BackRightEdge",new k(t,0,-t),[{axis:Rs,rad:Cr.Rotate90},{axis:wa,rad:Cr.Rotate180}]),d=this.createEdge("BackLeftEdge",new k(-t,0,-t),[{axis:Rs,rad:Cr.Rotate270},{axis:wa,rad:Cr.Rotate180}]),p=this.createEdge("FrontLeftEdge",new k(-t,0,t),[{axis:Rs,rad:Cr.Rotate270}]);return 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(u),e.add(c),e.add(d),e.add(p),e}createEdge(e,t,n){let i=new an,r=new mi(this.EDGE_SIZE.x,this.EDGE_SIZE.y),a=new za({color:this.EDGE_COLOUR,opacity:this.EDGE_OPACITY,transparent:!0}),s={tick:0},o=new St(r,a);o.name=e,o.userData=s,o.position.setY(this.EDGE_SIZE.y/2),o.layers.enableAll();let l=new St(r,a);return l.name=e,l.userData=s,l.position.setZ(-this.EDGE_SIZE.y/2),l.rotateOnAxis(new k(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 an,t=this.OUTER_CUBE_WIDTH/2+1,n=this.createCorner("TopFrontLeftCorner",new k(-t,t,t),[{axis:Rs,rad:Cr.Rotate270}]),i=this.createCorner("TopFrontRightCorner",new k(t,t,t),[{axis:Rs,rad:Cr.Rotate180}]),r=this.createCorner("TopBackRightCorner",new k(t,t,-t),[{axis:Ju,rad:Cr.Rotate90},{axis:wa,rad:Cr.Rotate180},{axis:Rs,rad:0}]),a=this.createCorner("TopBackLeftCorner",new k(-t,t,-t),[{axis:Ju,rad:Cr.Rotate90},{axis:wa,rad:Cr.Rotate180},{axis:Rs,rad:Cr.Rotate90}]),s=this.createCorner("BottomFrontLeftCorner",new k(-t,-t,t),[{axis:Rs,rad:0}]),o=this.createCorner("BottomFrontRightCorner",new k(t,-t,t),[{axis:Rs,rad:Cr.Rotate90}]),l=this.createCorner("BottomBackRightCorner",new k(t,-t,-t),[{axis:Ju,rad:0},{axis:wa,rad:Cr.Rotate180},{axis:Rs,rad:0}]),h=this.createCorner("BottomBackLeftCorner",new k(-t,-t,-t),[{axis:Ju,rad:0},{axis:wa,rad:Cr.Rotate180},{axis:Rs,rad:Cr.Rotate90}]);return 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}createCorner(e,t,n){let i=new an,r=new mi(this.CORNER_WIDTH,this.CORNER_WIDTH),a=new za({color:this.CORNER_COLOR,opacity:this.CORNER_OPACITY,transparent:!0}),s={tick:0},o=new St(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 St(r,a);l.name=e,l.userData=s,l.position.set(this.CORNER_WIDTH/2,0,-this.CORNER_WIDTH/2),l.rotateOnAxis(new k(1,0,0),Math.PI/2),l.layers.enableAll();let h=new St(r,a);return h.name=e,h.userData=s,h.position.set(0,this.CORNER_WIDTH/2,-this.CORNER_WIDTH/2),h.rotateOnAxis(new k(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}getBBox(){let e=new Nt;return e.setFromObject(this),e}getDirectionByViewCubeName(e){let t;switch(e){case"TopFace":t=new k(0,1,0);break;case"BottomFace":t=new k(0,-1,0);break;case"FrontFace":t=new k(0,0,1);break;case"BackFace":t=new k(0,0,-1);break;case"LeftFace":t=new k(-1,0,0);break;case"RightFace":t=new k(1,0,0);break;case"TopFrontEdge":t=new k(0,1,1);break;case"TopRightEdge":t=new k(1,1,0);break;case"TopBackEdge":t=new k(0,1,-1);break;case"TopLeftEdge":t=new k(-1,1,0);break;case"BottomFrontEdge":t=new k(0,-1,1);break;case"BottomRightEdge":t=new k(1,-1,0);break;case"BottomBackEdge":t=new k(0,-1,-1);break;case"BottomLeftEdge":t=new k(-1,-1,0);break;case"FrontLeftEdge":t=new k(-1,0,1);break;case"FrontRightEdge":t=new k(1,0,1);break;case"BackRightEdge":t=new k(1,0,-1);break;case"BackLeftEdge":t=new k(-1,0,-1);break;case"TopFrontLeftCorner":t=new k(-1,1,1);break;case"TopFrontRightCorner":t=new k(1,1,1);break;case"TopBackRightCorner":t=new k(1,1,-1);break;case"TopBackLeftCorner":t=new k(-1,1,-1);break;case"BottomFrontLeftCorner":t=new k(-1,-1,1);break;case"BottomFrontRightCorner":t=new k(1,-1,1);break;case"BottomBackRightCorner":t=new k(1,-1,-1);break;case"BottomBackLeftCorner":t=new k(-1,-1,-1)}return t}update(){this.traverse((e=>{e instanceof St&&this.updateViewCube(e)}))}updateViewCube(e){this.updateMeshTick(e);let t=e.userData.tick;if(e.name.indexOf("Face")>-1){let n=e.userData.material;if(n){let e=GV(this.FACE_BACKGROUND_COLOR,this.FACE_HOVER_BACKGROUND_COLOR,t);t>0&&n.color.set(e)}if(this.innerViewCubeMesh){this.updateMeshTick(e,"translateTick",2);let t=e.position.clone().normalize(),n=Math.max(2*e.userData.translateTick-2,0);t.multiplyScalar(n*this.CORNER_WIDTH/2),n>0&&this.innerViewCubeMesh.position.copy(t)}}else if(e.name.indexOf("Edge")>-1){let n=e.material,i=GV(this.EDGE_COLOUR,this.FACE_HOVER_BACKGROUND_COLOR,t);n.color.set(i),n.opacity=Math.max(t,.1)}else if(e.name.indexOf("Corner")>-1){let n=e.material,i=GV(this.CORNER_COLOR,this.FACE_HOVER_BACKGROUND_COLOR,t);n.color.set(i);let r=1+.3*t;e.parent&&e.parent.scale.set(r,r,r)}}updateMeshTick(e,t="tick",n=1){let i=e.userData,r=i[t];void 0!==r&&(e.name===this.activateMeshName&&r<n?i[t]+=.05:e.name!==this.activateMeshName&&r>0&&(i[t]-=.05),i[t]>0&&i[t]<n&&(this.dirty=!0),i[t]=Math.min(Math.max(i[t],0),n))}},WV=class extends ar{constructor(e,t){var n;super(e,{id:(null==t?void 0:t.id)||WV.DEFAULT_ID}),this.width=0,this.height=0,this.renderEnabled=!1,this.onPointerDown=e=>{var t,n;if(null==(t=e.originalEvent)||t.stopPropagation(),!this.viewCube)return;let i=new _e(e.x,e.y),r=this.pickManager.pickObject(i,this.viewCube);if(!r)return;this.lastCoords=i;let a=r.object.name,s=null==(n=this.viewCube)?void 0:n.getDirectionByViewCubeName(a);s&&this.updateViewerCamera(s)},this.onPointerMove=e=>{var t;null==(t=e.originalEvent)||t.stopPropagation();let n=new _e(e.x,e.y);this.updateActivateMeshName(n),this.lastCoords=n},this.onPointerleave=e=>{var t,n;null==(t=e.originalEvent)||t.stopPropagation(),this.lastCoords=void 0,null!=(n=this.viewCube)&&n.activateMeshName&&(this.viewCube.activateMeshName=void 0)},this.onClick=e=>{var t;null==(t=e.originalEvent)||t.stopPropagation()},this.updateCameraAndMeshName=()=>{var e;if(null==(e=this.viewer)||!e.camera)return;let t=this.viewer.camera,n=new k;t.getWorldDirection(n);let i=t.up;this.updateCameraDirection(n,i),this.renderEnabled=!0,this.lastCoords&&this.updateActivateMeshName(this.lastCoords)},this.cfg=t||{};let i=this.cfg.containerId?document.getElementById(this.cfg.containerId):void 0;if(!i){let e="gemini-viewer-viewCube";i=document.createElement("div"),i.id=e,null==(n=this.viewer.widgetContainer)||n.appendChild(i),this.cfg.containerId=e}this.width=i.clientWidth,this.height=i.clientHeight,this.container=i,this.inputManager=new id(this.container),this.pickManager=new y1(this),this.init(),this.animate()}get viewerContainer(){return this.container}init(){this.initScene(),this.initRenderer(),this.initCamera(),this.initLights(),this.initViewCube(),this.initEvents()}initScene(){let e=new Ji;e.matrixAutoUpdate=!1,this.scene=e}initCamera(){if(!this.scene)return;let e=new xi(-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(){this.renderer=new ga({antialias:!0,preserveDrawingBuffer:!0}),this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setSize(this.width,this.height),this.renderer.setClearColor(11119017,0),this.container.appendChild(this.renderer.domElement)}initLights(){if(!this.scene)return;let e=16777215,t=new va(e,1.5);t.position.set(-100,80,0),t.name="sun",this.directionalLight=t;let n=new mo(e),i=new Pu(e,14540253,.5);this.scene.add(n),this.scene.add(i),this.scene.add(t),this.scene.add(t.target)}initViewCube(){if(!this.scene)return;let e=new I2(this.cfg);this.viewCube=e,this.scene.add(e),this.zoomToBBox(e.getBBox())}initEvents(){var e,t,n,i;null==(e=this.inputManager)||e.addEventListener("pointerdown",this.onPointerDown),null==(t=this.inputManager)||t.addEventListener("pointermove",this.onPointerMove),null==(n=this.inputManager)||n.addEventListener("pointerleave",this.onPointerleave),null==(i=this.inputManager)||i.addEventListener("click",this.onClick),this.viewer.addEventListener("AfterRender",this.updateCameraAndMeshName)}updateViewerCamera(e){e.normalize(),this.viewer.flyToDirection(e)}updateActivateMeshName(e){if(!this.viewCube)return;let t=this.pickManager.pickObject(e,this.viewCube);if(!t)return;this.viewCube.activateMeshName&&(this.viewCube.activateMeshName=void 0);let n=t.object;this.viewCube.activateMeshName=n.name}updateCameraDirection(e,t){this.camera&&e&&(e.normalize(),this.camera.position.set(200*-e.x+0,200*-e.y+0,200*-e.z+0),this.camera.lookAt(0,0,0),this.camera.up=t,this.camera.updateMatrixWorld())}animate(){var e,t;this.requestAnimationFrameHandle=requestAnimationFrame(this.animate.bind(this)),this.scene&&this.camera&&this.viewCube&&(this.renderEnabled||this.viewCube.dirty)&&(null==(e=this.renderer)||e.render(this.scene,this.camera),this.renderEnabled=!1,this.viewCube.dirty=!1),null==(t=this.viewCube)||t.update()}zoomToBBox(e){if(!this.camera)return;let t=this.camera.right-this.camera.left,n=this.camera.top-this.camera.bottom,i=new k;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()}destroy(){var e,t,n,i,r,a;super.destroy(),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.container.remove(),null==(e=this.scene)||e.clear(),this.scene=void 0,null==(t=this.directionalLight)||t.dispose(),this.directionalLight=void 0,null==(n=this.inputManager)||n.removeEventListener("pointerdown",this.onPointerDown),null==(i=this.inputManager)||i.removeEventListener("pointermove",this.onPointerMove),null==(r=this.inputManager)||r.removeEventListener("pointerleave",this.onPointerleave),null==(a=this.inputManager)||a.removeEventListener("click",this.onClick),this.viewer.removeEventListener("AfterRender",this.updateCameraAndMeshName)}},qV=WV;qV.DEFAULT_ID="ViewCubePlugin";var L2=class extends Wi{constructor(e,t){super(e),this.needsFrustumCulled=!1,this.image=t.image,this.min=t.min,this.max=t.max,this.radius=t.radius,this.renderOrder=t.renderOrder||-1e3}getClassType(){return"OverviewMapDrawable"}getImageScreenSize(e,t,n){let i=this.transToScreenCoord(e,n),r=this.transToScreenCoord(t,n);return{width:Math.floor(Math.abs(i.x-r.x)),height:Math.floor(Math.abs(i.y-r.y))}}draw(e,t){let n=this.getImageScreenSize(this.max,this.min,t),i=new k;i.addVectors(this.max,this.min).multiplyScalar(.5);let r=this.transToScreenCoord(i,t),a=this.transToScreenCoord(t.position,t);e.save(),e.beginPath(),this.radius&&(e.arc(a.x,a.y,this.radius/this.tolerance,0,2*Math.PI,!0),e.clip()),e.drawImage(this.image,r.x-this.width/2,r.y-this.height/2,this.width,this.height),e.closePath(),e.restore(),this.width=n.width,this.height=n.height}drawSelect(){}isPointInPath(){return!1}getBBox(){return new Nt(this.min,this.max)}},D_=class extends Wi{constructor(e,t){super(e),this.hover=!1,this.needsFrustumCulled=!1,this.image=t.image,this.hoverImage=t.hoverImage,this.translate=t.translate,this.scale=t.scale||1,this.position=t.position instanceof k?t.position:new k(t.position.x,t.position.y,t.position.z),this.direction=t.direction?t.direction instanceof k?t.direction:new k(t.direction.x,t.direction.y,t.direction.z):void 0,this.radius=t.radius,this.displayRadius=t.displayRadius||1/0,this.rotation=t.rotation,this.enabledHover=!!t.enabledHover,this.renderOrder=t.renderOrder||-997}direction2Rotation(e){return new _e(e.x,e.z).angle()+Math.PI}getRotation(){let e=this.direction?this.direction2Rotation(this.direction):0,t=this.rotation?this.rotation:0;return t+=e,t}drawImage(e,t,n){let i=new _e(1,1);this.translate&&i.set(this.translate.x,this.translate.y);let r=t.width*this.scale,a=t.height*this.scale,s=this.getRotation();s?(e.translate(n.x,n.y),e.rotate(s),e.drawImage(t,i.x*r,i.y*a,r,a),e.translate(-n.x,-n.y)):e.drawImage(t,n.x+i.x*r,n.y+i.y*a,r,a),this.width=r*this.tolerance,this.height=a*this.tolerance}draw(e,t){let n=this.position.clone(),i=!1;if(this.radius){let e=new _e(n.x,n.z),r=new _e(t.position.x,t.position.z),a=e.distanceTo(r);a>this.radius&&a<this.displayRadius?n.lerp(t.position,1-this.radius/a):i=!0}let r=this.transToScreenCoord(n,t),a=this.hover&&this.hoverImage?this.hoverImage:this.image;if(e.save(),e.beginPath(),this.radius&&i){let n=this.transToScreenCoord(t.position,t);e.arc(n.x,n.y,this.radius/this.tolerance,0,2*Math.PI,!0),e.clip()}this.drawImage(e,a,r),e.closePath(),e.restore()}drawSelect(){}getClassType(){return"ImageDrawable"}isPointInPath(e,t){var n,i;if(null==t||!t.camera||!this.ctx||!this.enabledHover)return!1;let r=this.transToScreenCoord(this.position,t.camera),a=this.transToScreenCoord(e,t.camera);this.ctx.save(),this.ctx.clearRect(0,0,null==(n=this.ctx)?void 0:n.canvas.width,null==(i=this.ctx)?void 0:i.canvas.height),this.drawImage(this.ctx,this.image,r);let s=Math.max(devicePixelRatio,1),o=this.ctx.getImageData(a.x*s,a.y*s,1,1);return this.ctx.restore(),!!(o&&o.data[3]>0)}getBBox(){let e=this.position,t=new _e(e.x,e.z),n=new Nt,i=new _e(1,1);this.translate&&i.set(this.translate.x,this.translate.y);let r=[],a=i.x*this.width,s=i.y*this.height,o=(t,n)=>r.push(new _e(e.x+t,e.z+n));o(a,s),o(a,s+this.height),o(a+this.width,s+this.height),o(a+this.width,s);let l=r.map((n=>{let i=this.getRotation();return i&&n.rotateAround(t,i),new k(n.x,e.y,n.y)}));return n.setFromPoints(l),n}},gye=class extends Wi{constructor(e,t){super(e),this.needsFrustumCulled=!1,this.positions=t.positions,this.lineWidth=t.lineWidth||1,this.lineColor=t.lineColor||[0,0,0,1],this.renderOrder=t.renderOrder||-999}draw(e,t){let n=this.positions.map((e=>{let n=new k(e.x,e.y,e.z);return this.transToScreenCoord(n,t)}));e.save(),e.beginPath(),e.lineWidth=this.lineWidth,e.strokeStyle=An.rgba2Color(this.lineColor),n.forEach(((t,n)=>{0===n?e.moveTo(t.x,t.y):e.lineTo(t.x,t.y)})),e.stroke(),e.restore()}drawSelect(){}getClassType(){return"LineDrawable"}isPointInPath(){return!1}getBBox(){let e=this.positions.map((e=>new k(e.x,e.y,e.z)));return(new Nt).setFromPoints(e)}},vye=class extends Wi{constructor(e,t){super(e),this.needsFrustumCulled=!1,this.text=t.text,this.position=t.position,this.offset=t.offset||{x:0,y:0},this.textStyle=t.textStyle||{},this.radius=t.radius,this.displayRadius=t.displayRadius||1/0,this.size=t.size||{width:0,height:0},this.renderOrder=t.renderOrder||-998}getFont(){let e=this.textStyle,t="";return t+=(e.fontSize?e.fontSize:12)+"px ",t+=e.fontWeight?e.fontWeight+" ":"",t+=e.fontFamily?e.fontFamily:"Arial",t}drawRoundRect(e,t,n,i,r,a,s){let o=this.textStyle,l=Math.min(o.borderRadius||0,i/2,r/2);e.save(),o.backgroundColor&&(e.fillStyle=o.backgroundColor),o.borderColor&&(e.strokeStyle=o.borderColor),o.borderWidth&&(e.lineWidth=o.borderWidth),this.radius&&s&&(e.beginPath(),e.arc(a.x,a.y,this.radius/this.tolerance,0,2*Math.PI,!0),e.clip(),e.closePath()),e.beginPath(),e.moveTo(t+l,n),e.arcTo(t+i,n,t+i,n+r,l),e.arcTo(t+i,n+r,t,n+r,l),e.arcTo(t,n+r,t,n,l),e.arcTo(t,n,t+i,n,l),o.borderWidth&&e.stroke(),o.backgroundColor&&e.fill(),e.closePath(),e.restore()}draw(e,t){let n=this.textStyle,i=new k(this.position.x,this.position.y,this.position.z),r=!1;if(this.radius){let e=new _e(i.x,i.z),n=new _e(t.position.x,t.position.z),a=e.distanceTo(n);a>this.radius&&a<this.displayRadius?i.lerp(t.position,1-this.radius/a):r=!0}let a=this.transToScreenCoord(i,t),s=this.getFont(),o=n.fontSize?n.fontSize:12;e.font=s,e.textAlign="center",e.textBaseline="middle";let l=e.measureText(this.text).width,h=o;n.outlineWidth&&(e.lineWidth=n.outlineWidth,e.strokeStyle=n.outlineColor||"black");let u=new _e(this.offset.x,this.offset.y),c=this.transToScreenCoord(t.position,t);(n.borderWidth||n.backgroundColor)&&(l=1.2*l<this.size.width?this.size.width:1.2*l,h=1.5*h<this.size.height?this.size.height:1.5*h,this.drawRoundRect(e,a.x+(u.x-.5)*l,a.y+(u.y-.5)*h,l,h,c,r)),e.save(),e.beginPath(),this.radius&&r&&(e.arc(c.x,c.y,this.radius/this.tolerance,0,2*Math.PI,!0),e.clip()),n.outlineWidth&&e.strokeText(this.text,a.x+u.x*l,a.y+u.y*h),e.fillStyle=n.fontColor||"white",e.fillText(this.text,a.x+u.x*l,a.y+u.y*h),e.restore(),this.width=l*this.tolerance,this.height=h*this.tolerance}drawSelect(){}getClassType(){return"TextMarker"}isPointInPath(){return!1}getBBox(){let e=new k(this.position.x,this.position.y,this.position.z),t=new Nt;return t.min.x=e.x+(this.offset.x-.5)*this.width,t.min.y=e.y,t.min.z=e.z+(this.offset.y-.5)*this.height,t.max.x=e.x+(this.offset.x+.5)*this.width,t.max.y=e.y,t.max.z=e.z+(this.offset.y+.5)*this.height,t}},yye="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFgAAABgCAMAAACuYkXGAAAAulBMVEUAAABJSV9pdntRWmdeaHZMW21ZYnJqcH9PV2dSWmtTXmtXX3Jka3tfZ3daY3NXYHBbZHNbZHJaYXNWX3D9/f5cZnT+/v6xs7zKzdKusbr6+vvs7e/Z29/s7e/09faPlaCVmaX6+vz6+vv5+fnw8fP3+Pjh4+Xu7/Da2+Dp6uz+/v719vjz9PX09PRfYXP///+vsLlpa3vDxMv19ffr6+7r6+2lprCHiJZ9fo1zdITNzdObnKeRkp9zdYQN9RLUAAAALnRSTlMAAwQICgYSBwsPDRUMDxcZHRsjH+Mg8TwvIMZ+UpGIMizVtqael3VrZ1zTuq2q+zBSvwAABtBJREFUaN7tmXlD00AQxSW7yeYsPaktKJcgeBRbbsHv/7V8b3ZjTOiRrfylTnoIpD+eb2dmD978j789dtzrjry8HrYWIL8u91Xx+HxgOYG88FHGK2gNbOxUb+7720It2BFNiAh4BXw66bjPMwlKA4gJTWiMUsrgUoZflrL9ra4sMCo0mlilldb4lxY6hQvbU7HDUipQiFjrPLYXvlKiXdAU7a03JCCWyNM8jfFM81znuRI0fmtovW7vr1ANpIGbpmmBSHglSZEiAIcr8JyOtLbDyoUarSGO2MnB/umn4RViOD3ZP0iKIi1yjQDY2EFsiUVwtHLITSaX072rWuydfIwgnG4rzWFsQxYsEkppcPGfn7wH9WUMT99Cth3HINysmQYzceECvU2IXRXv3yYp0YZFA3Abe0PYAG5xWWKvF3fPj/PZbPZ4f7e4KVV/TAr6oQwSb0PWkWsQzIVicuao3+5ntXgo2WcT2JHHSm3Q/Ct5NdI2efvJYam0GU8WPYQdcaxlBNc1DnIN0zcGd3jFAHZ5fHPkqKAbBK8mUzGqCeNWRJZ78zBbGT9unGaIps9rzEB5SmdIU8ddQO7qmH+v3IBm2ryKC3AIg4tiItxvFWSNHZ8mURLbQoGy5U6w3nRaJNGZ47Yin8HmnPnM/r3cYQMw8iz6yPu/z1rEgndeQnKs7AAuFwwfWMdi8M28DXh+Q5snEcbPlsnOipRQcV5E7ynjcdYqHqS6owRmhMsTQ+Y2ZAQyraXBlc17E9hMMwh+KTikExi5Uxoxaxvza5Ec5bDZvHRZ5mM6nBYZHX5qDXaSUSZQDEqzGUlXU2gRTAkK9pN8ic5PyS8Vsw2rGNzohCXnARbJ0wjj5yTXGzxTQhOcsQc/+IDv3fClOeoaAhsWg6vQfLIDPycY9OIgklxmw3jR4JWmE/ueTrjy288wnWhKRtSsMHboMlp85we+w0dOsyhx4GaHDy14irvu/cDP+MgxwbnSMvnVyxn9J0mizlDK2St+sF9kyAu2ZWj8XTPqmf0nirIrxMwv5vxMlqGsCa5lBZNCoeyiqOMLZpRgKnZeVE7I1BFlW4M7NFk18o1r0RDlUYLnW4B3Ac6RyBRcnz2M1N3WgwfFUcq5Lwga2YZZH2O3e4y7nv3ArOmpWKHZ7UVx1TSNyUXx1+0K5DPBhWazB7jeKix425ImmOlmalbYiTQnmE3o2g98yybkrDC1PHbpVhB8tOdb0w9sm71OmcdBo7sBzHTLelNOpb5OnAgYrb7RN6mYiYy06F3Qi7mnE+e9TOYQExqIrE9MRkki78ILL8lPzOIu6yPR0ukbM17AZTHBvXd+kin4C8GsD9PwGF64GSTr9Pwky7pw3KNigMEluV4hkm9Rp9el5KuHtuWMeNft2R7UXLKQLOCCXnSP2C9u2y0KacRwTCeK1K0461aUK0Ka3L24alt+sqg/7zonYhO8OHeBNdKRE3ox+OCz8P4w6O52skTWyA3BCPwq2X4kIvnouP1WYXjkBNvyaFj8a8mSsEZ6g/FQFvXrNzcL4Y4H4Eo962qD01wU0guRPLLk28c1LeLWcmkEBAOslu7WA9lDx1gCZB3aDPI6O+awwXEpmHs9dqA1WwWZ+KC578i3T0ux1/LD4/HICU4xQLUkbnY4DckkdwejQ+YG0YtGsdwTK/lwSL2Sw9wpALsCHMi+n82TZoz65xDt2Hf3j1T6+Hy3IFVsuOgPrF4Wh+aybcV+LJB2n8tEAnJ31B+julfE3rvD/qhLLo3gCtZW3XIwybG1mT4P+v3xl+FK7ACJ1ukIV8HgFVzaI6cKKpdZFT7TaLDPP+81qNMLwVZcdolVYGHLLh0tg/tpS4bTiIP9z1NRPjz+sn9wiO8MaK/4m3CRaeBwE9yskoAHFgBD9C7sABrsRozgbm/X+Ztq1Jw9ytpwOKboM8k0moMosivqgNiexRZJzoQwELzxEEt2qCQDDTbRZLsYIIC1XIDlWM9uzzeRgdaaI1iADD8QhDMGeBKKQetEkdgQIx/K7fkmdKioGXawCEs2ebwE6tSmItcm8MaTQueGNrKxLiy6YwNQJhipxNo0Y2W0PzWlaHEaqsXsKoSawIVcM89U24NvJzpkd1bidUG0C1KZClCLHyoFrPcBckgy0XGaJ0mBB4US6rxltTm5vkf0CkE20FCe5kVKKAtC8TIV1/OUHuMCWWTHuQZf57o8+scglNQd/7+DSLsj2GjrKJGa2NBiPeU6uKAlDM/5AeMbs8vIgUeD62kH4S4ok0IBbVC3RANUxU5FrcDbiy5pVMu3BnQ7dJl+AnZCeeHx5yE0C9us1R8uz//xD8RPQ80FqUsWMbIAAAAASUVORK5CYII=",xye="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKoAAACqCAMAAAAKqCSwAAAAh1BMVEUAAABfTP9eTP9fTP9eTP9fTP9fTP9fTf9fTf9fTP9fTP9fTP9fTf9fTP9eTf9eTP9fTP9fTP9eTP9eTP9eTP9fTf9fTf9fTf9fTf9fTf9fTf9eTP9fTf9cSP9dS/9eTP9fTf9fTf9fTP9fTf9cSv9fTf9fTf9fTf9fTf9fTf9fTf9fTf9fTf/hY9QXAAAALXRSTlMARjRhS0HMZ1M5PVgva1wrTyYbFyJwlnx0gaATeAUPH4mmjYUKm5Gvv7m0q8X/SpWnAAAGcklEQVR42tXcCXriMAwFYEFhBsqeQIEGB2jTjc79zzdmFaDEjgmyhU/wf6+yvIUCxxhE8CBj3Kw9iHXZbNYew7p81tSHsEbPe2pDvDVuH6nSrVkdqcMlCB6q2z6jtgRb1aB+pGrpsCXYOq4jdZuqXGtcR2ptl2qrI9Oadi+oO2unMwZ5Q43OqY0DVaR11L2kDvfUfl+cNRl0SQHsqU/CrNmAUlsHqiyrGg+KU316GoGcEY+M1L9yrOnojNo8dQCkirGq5ciSqhhrMkYq6at7aq8nwqrGhEoKQFsHEH5EudThOVVLe5Pw1nSJ1PbFduUy1Ulwq4o01TStkDoLbE1s1P6ROpvNuhBiYKj51GFOqrNFkFwxVHuqSF2EyzWLojK1itRpMGsckVSbeLbKo4ayZoRqTXU6D2NN4tidGsSaxXGMtWrcA5xT3+vgfaTxRQF0Tc0KqSGsKjmnDooKgKb6vvJtzZBarq8i1bc10VRDX20ZUl29ebVmSeLQASZXVK/WVEtdlgCk7qyf/qxqR7Wn2iepznepfn62wdPIMNXRsQO0Cw4sdFqtNPXFk1WlJNWucVrRVF88WbMtNTF2ALK1XpxNK2194bcilU4rWgB92qxOqb58eLCqLDVMK3oMLKKyWpGaklSte4Apob4+A/PITqlGBiqdVpTKbVUHqvPWmlKJlY8a3URdnVHXfFakJnkLK1LNBYDUdRPOh+ACWK8Zc1VFBeCwsL6dqNr6i7kyUXEPYE8Vm9X8ulY1Fa081L0Vqe7NCqlfJ6uQApjmU381Fa1M1Pg+02pL3aCVmWpP9WpnRaibGofUdQnoFXYALIANi7UClRbAWg8t1dSfnxprqsvbDtdb6yFVpGorF1Vbb6PSDnCgftfCpkoP1/nTaqOp2spCNd4EUuqisFlhqt/fDa5U3W5XpjmbQKzVzY76r8GUqlMBWPrqz56KVg8FQKeVvQAwVbT6KABaqxNDB8BmdaD+abBQ3Y+Bc9qsrqlo5acW7AGmZQrgrlZSq873q6vcJQBTRWtVae4xsGvtAJZUkYpW/iWAvgXQZkX7KlLR6nsJ6BmpNFW08lC7tpvAhW21QipaWVarrjFVWqufhlTvZdVSMq0sBUCalbkDoNX/gcWxA9zNqhhOrISK1oAdYJ5XAGRaoZX1wEKpDqlSayWq6dLS7Wz1YWhWaPW6tZ5cXa+ZlwBi5aTSFxaknlarDwsVrR7PVo4LK7VyUOm3K/bV6pfUKrXemdq+U1+l1q+IoQNYD9e0AOiBhUoZa1VL899YaQd4JVQq5TxcD7FWXU8BxLqJgJPqXqs4raiUmdqq3qzwrx+0r+LCSvcARHo36qh6ql+kVomUcwlwfws4UkmdyplWhIqZ+r8Ictta/yNS1mlF+ursQLWfWFHq89KyU+EYiNLKVHwOrlYAtAOglDXVpuGTsPKpolTc4ZrsV4k0yGo1t6a6k0qgYqpFZyuUVh7GWjVRp+WWACKtmmpa4lvrjvuVxVYq5XsAPFznp/qLUuZmVfUiCKX8BYCrFVLJC0vhErCO4TCE9tVTqlr6INR1LOrTBcMS8EqljFtrOq3+kmn1XrCwotRjquQxyH62QilvB3B/Y6UF8IFSP99ZNfN/c23fWaGUi7q8z2MQkxSwAGK6Wu1jHTo2qxci9bSzajhuAtmkANW2KzTVT5QyUqu/W11IxVCneZtAVilStdXxLYDeWrNKARy/te4ZvrN6S4B1ZOV+GmansktBOfw0zNhXVwlwD4dNoGm1eueUIlVbb0sVO4APKSjrtGrZfhuIUuZhP7BYC2DuRwrZjT8MwYXVlxSU6YWlYf/KAqX8w+k5mL6wTP1JIavw20BmKY21wv3qwqsUspuvLHxLAW7+txvepZA5XQUjdZaC76HofpW+W1FqAClAesu0moSQgnL7zGaxpXqWYqzOtdoLJAXl2qxCSDFWSj1KabP6m0K4UXoTqKWzoFJIS/+DiNBSgPIXQaGlkJ2oXfPvrZ5SCD3icqkKkIJa7qgD00WQDClAWuI1sC9CChBZP7ORIgV1ubDSJaAjRQqQmKeVICnAspgqTApqVExtZSBqpIU3gdKkAFF+qgKlAKPcL9iHAqWgclKVKQXI6C8uGzKlAPHVw6VcKcDysgBqcqUAg7MCkC0F1UWqbKm21o8F0BQuBcjae6p8KUCqqY8hBYg19fkhpFvro0gBEhbpfwjbOY5gXmpMAAAAAElFTkSuQmCC",bye="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFgAAABgCAMAAACuYkXGAAAAt1BMVEUAAABRUmRVYHFcZHBRWWZia3plb39aYnFeZnVYYXNZYnJPWGdZYnJRWWtZYnJZY3JWYG9eZnVcY3RXXnH+/v7+/v78/P2xs7zKzdKusbr6+vv4+frz9PXn6evs7e/09faPlaCVmaX6+vz09PX5+fns7fDa2+Dp6uzS1Nni4+X+/v7l5+rx8vL9/f1fTf////+vpv9pWP/DvP/19P9zY//r6f/r6P+lm/+Hef99bv/Nx/+bkP+RhP+tEDdkAAAALnRSTlMAAQMGCAsIDQ8UEgsXEB0gGhojJOLx5DwvIMa4m3CRiDIs1aymfWdcV03ShXjTY8FN1QAABtZJREFUaN7tmWlb2kAUhS1knSFAXFBArFtduoAgbtX//7t67gITEsCM+rFHwNZHXs9z5t6bybDzX376hi/5Bx5fxsSTeIBD8qPPUxUndP6f0+fITo0GngUs/ZEPMl0ADVAbKgf3J+siLaxWpOY1HV8yIQvQZlOeJeNedaJWHLhZlrJ94/imKkCjZhAEUYDXSMjCVtN14c4tM/GIAA3CILRhRPyo6HunJrhoVuwCGQIZxqF8t4TH3xK0rqEPmJiwZ4UXx7GN6ZX+AtwHTTYOMkf9DlkqV1MAFO9nZKLK8Iwh0C24hG7UQmv5arphBHcgJf3b35c/9yfQ/mD4+5bxFIx6hriZ6q0arVZsbZL1rwcHkxUdDEcZ0KFkzZ5JW/2qXc6B7fa/g1rV/uUR0FhGVCEHLdo6y5gb0YLFjN2k70dZHGNlIwl6KxdSbmCBTa4X2PvZ09t8Oh6P589Ps8eFawSCqB1586hecqPQIoVjpd49j1f0smAf9xEH6iMQ8nospaBlBm4cZ0c/FQunFb0Kev8oS6Q6dHBU2cAqOEC+KIYjlBek2KrulGyEvCVm4WoORrgPL+ONmj+qZ8QRcdWtn3WLhUOvLbkz2N2s6V8lI+dA04DWcRnM68bcOwfZEsefvkls4EbSGjD3G7oiM8fKrUU+NlR1FIakUSkJDSJOzGgC/R3X0GwCXWeJDXkgrUkCaOLS2JGCeJjWAU8fKea+iS1bXkvmimDD38nGfFxLL9zdJkPNsWWozG1C4KKCawbsYj7oI2Ys4DrLmjCCMJcUxLiupvdkOUXNWYArMS97LklSSvi1Nlgto02WA3SlKggcseGRGPazfG2SxFrpkp2y4ygirhlSy3mA2fLAGFh289MVW4OXDuCUZvCLD/hZlw9kBrsW4Qsdd12SpbeeSUCUxa0xMVfct6JjvoCKYfPDMwltvx8pli8ky4C5peMoaEyYlCJ+8gM/4S2Xqcli6mvFqnSuJYh4gN969gO/4S3nBI65rXcaxdEGLkfc2ud29tKc5kXL0CjSEVdYPFk7Y1oTaOyn6QRqpdzWAJf6GVw4VrCnFAzHq+NCRzFd6tJPgBGFXlRXJ0WEokgFPP0QOEVZVBZPGxqOex9dvJRaJGByybG1Bo7P8VtvHlTt6QE5FrBm7EZQzI4vPtYgw5Z0SECtt2pYo/hoSzvHxcVjMEYFGuSG9mt+YLqg3pBjrWOXBNzTdZQdnx349vQLjc2c6xjgJsAlyzyDWl0aFne+SQxzqmOOuNR6dC8TMviKsph6JjHqEjjWXYsrYwYHvHo5svCy/Ipf77UZHHKDAOjAHEVoMSta+Qlb9jJ80c6pPyw7Lu1X5MpEWfhY1n3hYQ5wRhu4BuSi0ClkefXyNlmevNRtZ+iEkjC8swC2UdmvhGy52z7r+W0Ke4ftnKdxZcuiyxdowbWvJnXbjzf1o3YuY94Cu7qvwFWvyWMoyQjc8dt4d6QmLDtGwkWw7oSk+fL22Xn9W4XeWbvbJcOxcNWwWz2qi8Dy8nXbhz3e1G+/uZkx9xB+5boUuYSd5M6cLbcQhpIf5ltGxKNwOQgj29gq190yUcoIowPytjimiMFxOeEI4DIZKWtbWw1jSX54XYu9n5DOwVXDga3eKrgmCSJYlvVrd06PJ4KelZrlGVjW8Sn8Sm9QETdk31YFO8uoOZA7I5hW9tPznJzO355moEoMV7sdCRhgWbl1jvGQlOXSx553D08mm3RwcrrLOWhv8Cnf+jMnhCyW44TJOci7hxe9TVji5i2pCHc2VKGS9OY/pphTJnc6u3uj4UGJOriCW2DbLeLKfSn8rgW7YzE6akuSTMjIY29vd+/m13DAznvnF79uTvEj4nYxIpZcvRXbdsKCyqA+UTK7hvacQAWWY0izLNFjIT30rapwhEUdyFWHpLk8CA4gqSNYVJnYxcKBSwkTY/OpMU+5gD0jjZTIXbINuqpNWOVyAUdR4eht8znh8tgtzhLDprtd2HbKc1AhYzgGq+eQ2w/tGYwGFNOJVAeUgw7lOR6gils5dVNuCbux6Li56QiSAhE4VXZLoIJN5CxIRwT0DlhLA2i4RhtCJmUByVAJwfIJtY40UY1TaTnpDijqhBJZSKkUQhDyialy3/9wwZ1383k5H54SHDgg8SpHpUrV02OttBrkRRNGajvGQxXGQo0W3KLbWqZ1EZWNpyX7eOGT/yVWPzurx5X+dlk3iQ4envRFlaBYpZa575aHsiMMPXoqdJmtygPr6oO19gMhNcxcL8NVdqMELcwzL8/uY4ay8DPH9ZW+UcQwkeAqHwT5w6va+aLPTPW1QJXTni+QYuW7gr9SHO5/eesfYdwFkua/O6kAAAAASUVORK5CYII=",Eye="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKoAAACqCAMAAAAKqCSwAAAB0VBMVEUAAAB5d55fTP9fTf9fTP9eTf9eTP9fTP9fTf5fTf9aYnFfTP9fTP9RV2hfTP9fTf9fTP9fTP9eTP9eTf9eTf9eTP9fTv5fTf9fTP9fTf9fTf9fTP9fTf9fTf9eTP9eTP9fTP9fTf9YX3BaYnRfTf9fTf9fTP9fTP9QVmZeTf9eTf9fTf9fTf9fTP9fTf9fTf9fTf9eTP9fTf9eTf9jantgTv1fTP9fTf9fTf9fTf9fTP9fTf9eTP9eTftfTf9fTf9eTf9fTP9fTf9fTf9gTvxfTf9aY3RaYnJfTf9fTf9fTf9eTf9aYnNZYXJeTP9fTf9eTuxbYnRfTv1cTuBfTvJfTf9eTP1fUPhfUuVcVsJbT91cT9tbWKtcWLFbXpNdVM5ZX3ReTvtcUsxbVMRcU8heUOb8/P5cWLlcVMheTPxZWZ79/v7+/v63ucpcXJvw8fSvs7r29vmVmarp6e7NztNWU7j7+/vR0eH7+/zh4uTy8/Tr7O2wsbr39/z3+Pj3+Pjl5+rKytSnptWpqsqKisD5+vro6PLs7PTa2ulfTf////9zY//r6P/19P9pWP/DvP+Hef+bkP/r6f+vpv/X0v+5sf/h3v/Nx/+lm/+RhP99bv89/FqOAAAAiXRSTlMABMw/RS9kbCdWB092BUIslzo8U180Ko9Zh5syI4RbNjh9DRBxaUd5CWdRrXNhXaNLSYpvCyBNgIGxjHtMG76UkqG6nh60JhnIqKbEExWqtyciFh4jwRkTIR0mGx0iISAdDycZFRjkKCQKGeLxOSeNP6ksby4QxVnUT5yAHsnJuF9HREI213iiZ4OOOrcAAA/ESURBVHja1NhPj5pAGAbwIYrr4gLVXf9lqavJFi3RZtHFblpJe/ATcIAzR7JNeuhemjTp3U/deWccRxjsSTLjYzTG0y9P3nkBURXpxehC4lj1EF1EAsuqX4Z1W6tZdde9AOu204FWfX+LFE/U7tQw1fX9jeLWrIupNdyq+7RpKW3V9DGlukD1AqRsNPuBUmFW1y3vVl2r02VU14dWvWtVrfF9l7f6BK1eK2pNdULlx6qFqQMVrVpTL7Ta8jB14CDl0tSPqO6BOvqknDWyCbW9p9IBINQ7xaxZj1L5rMKxuiXUhVJWzQFqYQBYq4tGE6mTuNmzbeFYsVYbClnTJqbqeeoG9iqjflTFqgWcyvfqGmaVUT8oYo2cIhVuAumsDvbUKyWsmiNQ6wfqiFGvekh+wgLVosdq7eWpK/nWNAjKWl23itRH2VYt5FTeqnu8Vxd76txGUpNsxVaBKrY6n99ItWrhNnDEDYCpa3YJuGuwVm+kWhNKFVsVNgChTnUkK1mMqUFJq/4GNkCx1en0qzRrFOap7fILK6dOJpKsWZRvtctaFQeAtTr5fI9kJGFUYa9SqnCsgPoiw5pFhHriwup5+3uARb7Vl/cSrGkUc6pd2KvlG2AC1IqtGrzJi/+URFF4guoL1Eeg0laHwy6qMsCEcG2WlA6AxfaqB9RR8VhBq8Mlt1ahNIGJvxw6TkQqf7Zie3VU2uryC7NWUadpsk+T9poxaumdFW2VD8Bqlaf2H1AFASIIDfIiZOCnSVRKtWir/OFaPFbD5bJfiZW2aRrG20/DMGmzCBkpH4CSVhl1dNzq9KjV/vfx+aEmxMB5/fGGrRCMT4EqbIDTDyz5AVhi6rfxuaEadc5mv3a7v7MZfAdt+r9WXfL/qjgAvFWgvmuf30qkf153u93v5+cZsWaEGpdT3dJba5H6j1Vz+00iCsJ4vDz4Um8x3qIxYdUYjalGaqJ4ibb1UkFbwQhCiwK1TcHUFrFatfEW4w5QWrHV+tc6c85ujzA7sCDzwusv337nm5lzQNYei0qgweAs/KjDa0RVrCWGymcApipDPdxbVg0aeAVQXq7AN2RF2GAp95hQ3SGQN1bKVSEBCPWyRkXWHgVqn/r6QSQNzEHNtjeg8D4QOBU8VSo9e5x7OImoQre6iA7gjTUUcsNKoSLr4N4eiYqkWtPAR6iWbdv+CbOWhbAlUpVQhxpQ93jNAGebDXDUGGBw8MbenoiqfEqklpWHuo21AoVXiBpA1Nwk1tWrA8LC0sarlzdRkbUHRaQIiqRF+GGrWoPXlqVIc48nUVU5AQiV71amW2mvDt7o79/WA1kJVZG+ysOqRl2uwlvLylFNEqqUAHKuEqo5Vqhq/8i2HpAqp1qWNQe/bKfqkA9bM0Sape8vtAC9BQiqGgPsVqqO3N3WC6cqo1JQ2W5V4F1kZmYml82RqkOCqsIW0JQAhx3U+zt7Ean4/cMUVLr0yZqfwcpOJpNJQdWmyeqERiVSMwMYAyDqmZ3/Q6qTKoikeKaMqBRYi0SazRLqkHysnNF6n6BqI6ph7fZUBUlUdaZMlQE+Sah8smpADXkcq36Nemnn/3x/R1Rs/obTCayURo1Gh3xNVuZYyahds24hqxIqBdWGwXQCayGVUqioasxzt8K+6qdbGQNcGh7e3jWrJrXoTDXVb3g+n0JSpWpMVLVVAhzgqg4/2N5tVOlOpYKqudZhNpVNtDCAeQ6WGytHvdmdrq5V30CdkarASiSS0WR0aCAWGxXerXyijjgGQNRuWGl7Uk21CNWVMq91mEslElFUNU4G2O+FeloMK1HVm9dOdmNVJWogD1ItJJLEGv/XAMfYDCCpyr06rFC7YHXOfzGv6rlHzSWUWQdadSt+FcznVST9F/XR+c7nP2KlBhC5/fTp2NjYLafGsJ5OTKTw+6eTJOpArAF1r2sAM6+ae4CQVlVIAI1671zn3x9RkTR8+zaxGlSqCWRNKK/G0QA7PEdrX8dqsMkAhHqvM111VhFqRKvawDqhUdPRNKLGRkfbvwbyIVBW9d6dc51d/ehNhb6/a4CvL1/Ob6Km0AHpdDoajcViXl41j+z7vK/XjKoc9c6VzkTto+9vRTTq/LulAlAtLS5o1nGSVanKDaA31u5VvbP1ov9DpRuAi7qwRJTVSqVKv/kikiLreFqjxvgLix6teViFzE2gV1g92ERlrHJX1VmlrTq/iJi11bKaVFZqFYDnL4mUDBAnVOZVWq5ZAvA18LpCRVKG2gErTYBoVYus+iIP1fqybWq1AoXvWtW4QkVSn+NKqH0L0KpiXfEpq5uqkcinAqw3zSvlGsDsOKFqVY/sN6iiAeRuNeKBylhlVHSq/v44rdaMpGZthaJinUZSMoD8xCajyqoqVp8e6NNZhah5vVZz1sKX8fHp6bg3aoOqZ8U7Kz1aC6oyXcVYRVH1skKa8qrBB0RF1iejox7HSj9biAnADWCO1SNC5azyAqBQww1zNVtaNCqy8ptAfr963MwA4hBowsqti+3XakJtvADgS8sHQn2iUXfxboVDIHtiI1U5qmQAzipvgOE8iSrL6qJSAnADiI9Bh5rWwLsc1T+rE1VvYd0Waw1mpzKOqgxVJwC/s/Kbq/5YTauyFmFNRl2BD1PTGUJFWduH1XF5ub7LjxVnlXcVGlXCr2FDRl2GwlQmk9Gouzz+ECIYwNe44p+VVEXUN/DHlqsKX6ccVO7V5o31gnC9JqByVpkUUfWpkqsCnxXqE6Oq2QLwhUXIVd5YDSozAGflBqBW1R41g4WkfAZgLyzcq/xYyagya5+zq7Q2AMCUqyrPVWe3OthqsrouG4CzSq//zq76t5oz/5EhCuJ4T4hr3UcciXMY1yJYZwhCTCJGXBnERGYdw65da9Z93yTNYtz8tar6Tc3r6W/XPNpMtpX1C798Ultdd72qX9NJf9FndVm0alCXLA61LP4is3Kj7tithYB6Wv2glbOq+Y8ElYeBOGSH1QXdVrEKQFK9BGTUe/6IjvrBfw2ocsIQGVyuwNWFFiGAWJFU/6wMav6u/xEQbe/6ua5VQZ2Hg0vMrLTA6ib1uLFmUIf8L7pSq5cJVUIAtte6lK41ahWdFZKqapVqdXjA/6ErVVBBq2QAzu6KAxVI9S4wOStWq5kCo9C4/Q2RXuHfv/WreMSEy0t6IwhQkRSFbFU6a1UeBKF89ysvL4e06t4IwhDgLliQFB1rowmYH74bw/r+i195ce0ao15BAzCoEq2c4+B9WhKIpCiCmuXOCrGOROz14zsmZdTz1lanYWptDQCc1U7HZ4WkurGaKpAbltxc+VQLgX7x/VdMyvUKpNaupiW2gvdpgRVJUSQISBvwRoVgP9RoJvCr9pX6QANDB68xap31ZAN1TthWuyJ+tVvRqqBCtHKTZpjVNFdZrWViZVgRAqXWZUAalIEnw1qd0XQcyqiLkjaCkFQfBBnXKi3rZw+ePK5UXj0ZunOQhEkF9SRWrDmpWPUqwJFaI6meBYpaiVUmAVaov8qopr92VJqWjrlVNwTWPWofAEgdxir+qhxhNQ12aa9RIwgKFj2wLv3TaIWkeieQm5YyCmBWS2pRSaBnNXMqNIJcVQB+VkDqrq+tWoX1WAO11GhaKmMLrK1WulBFq0iq+4AQqrCGx1YkJaPV2FZwzlYBLT2AZqtri3+5DMQW8PDmzUGW600yGEhjbAFazTVWF+bBCQOgYmB1k2LbgqfBqlQFVfEAYqvKhEX3AEeKyXYsbvNgBWXErwzawSUagCSBCfyqQuo01uy9+IT1nT9Ec0uaXKJW7asL2F2J3bNq7lkdAlKnVqVxVY2rWWp+pSRDVmV7LXQXsBpsVdWqQuqw1bpaHw5gKfj2nX9DULcog8uuuBDgHFxuKCZcCOoxu0vfYkpAnrGePasYgKQrjpYFFiwbjidaspB5AK2D/4AScJBQeXmFd1ccu9aOEBDOV/cRaWLWeuPifaSwqhrSs7wOoG0EMaq+ZwWfFaHu10jdxioF1m3/a+SbCpRqtHpasVVtxqr3V5ORZmTPKkivnzWPhOibOlcytkqs4WuLOTBi+4uu9QIHqXt2zZXA/bDD+uxXyv1MatYXTzt2AiEHUFAdpO702gyvh0MO6+2I/7RMrGdKsr0GBjBVdq1VZ4Wp9fSkpDJnk+z6Ac0vraPKl/sJtW6rFFhlywK6K4CqBtbkpOICBLVM63bWUeXzbAAXAls9razaKkuhSma1959ITbySQuAOOSwJ/mVC7S+ZVdtAq3FPGVjU2c7UWkiTokrZakpBcVjkqIbz+UI/CbEWT8C1haQreMaof1YJSbFoMYXAYPBlvSdHVTaoFwK1FpWlUO00LG5uNTcRKXYDpMI2XWE6CmDSw4cD0kvFS81anaPvBG5W/erOU225s2RUo1Z2WD/NN1UoHM5eZFb92iLnyletVhOTYoG1TFjJYVHwzwdKzd66GJww7FbPGNmvYisYndUmIE0YsEyB1fiy/IG6UpdlgyOWs0yK91birCBdwbHFfCBNHAWkxGa93qOVpUKBdZpd1sOkJKBVJbVW+qsLT7XzLtSwsg0Unlwl0EKWSXtuMSsfXOLJbWPE5spXgTS5mHu7VYaVd66eskYZla4DDWrLk1vX9tr2tpFmjF5XkbkaVgZllZJMmnTrFN2GFdmv6q8ugFabbFUhTewEmJXbLCQBJwufh07h1wGsreKQHSYs0XRlWxtIMRcUWCbtWUUq5TtxPg62L4SoBYt2GbS03aTm3ppIA9oeEjkPntLHatUOmR0b7G0ixQwrYxRLP/TXHF1nSPg6VD8N29pSqyuBtF32ynhMazQ6ie/uGw9EKI9EbW3lV9tEipkAsxKtEaKkH/vsBh4yu/dXJwNpu58ImGJISYwr65P3AVquhc8GrXb3eh2RDP8hMbyk4UDMf4EBwLK9bQVbZ9UBUnzPQlQq0otJoHsfYDmQtlOtQsuk8g8smegDETPw4jL6QgiRdliaEK1a40NADt9eEwMYD6SdACWRD0oko9iqbAXDazYdIkVelF5Exf6qrQJWdJYUYfGZOKwCcMTW3c2koyi9ylsWsGZDqKuJdDSlqLxlgQXLuFEm9fqU54y2hi/Z2VmtI9JRluNKdyViq7NHn9TLxNlqtL2WClL6stBWoWBZnwpSz9utPLthN4IWpYSU3rUVA1BCwLy0kHreqVa11ew0kXreAfAAoWg1MU2k9K49ttdEq7P6vFRJL+wDiK2mjZTia0wnkFHXpI7U8yZEcgBjAF0pJPUy02Ie4d+aRlLKW9Cv7konKZmroMr+6sa0knrelqY1m65cekk9bxqvL0ojaGyaSclcra2mm5RY54gBTE05KbEuMS2LMaknpQjLIeC/IKVSi7T6f5CSe5068z8hpUS7I6S/ARbzgdCIDH2vAAAAAElFTkSuQmCC",C1t=(e=>(e.ZoomChanged="ZoomChanged",e.SyncCamera="SyncCamera",e.CameraChanged="CameraChanged",e))(C1t||{}),XV=class extends ar{constructor(e,t){var n,i,r;super(e,{id:(null==t?void 0:t.id)||XV.DEFAULT_ID}),this.CAMERA_Z_POSITION=100,this.width=0,this.height=0,this.frustumSize=this.width,this.renderEnabled=!1,this.drawableList=new Xo("overviewMap"),this.clock=new Pl,this.raf=new p1,this.raycaster=new Ac,this.translateStart=new _e,this.rotateStart=new _e,this.markerRotateState=!1,this.markerTranslateState=!1,this.isMarkerRotating=!1,this.isMarkerTranslating=!1,this.isUpdateWhenPawnMove=!0,this.allMarkersBBox=new Nt,this.tolerance=5,this.enableLookToAllMarkers=!1,this.handlePointerDown=e=>{let t=this.cameraDrawable,n=this.cameraDirDrawable;if(!(t&&n&&this.viewerContainer&&this.camera&&this.controls))return;let i=this.getDrawableByEvent(e),r=Sn.getScreenCoordinateByEvent(e,this.viewerContainer),a=this.lockCameraInViewCenter?this.camera.position:Sn.world2Screen(t.position,this.camera,this.viewerContainer);i&&i===n&&(this.isMarkerRotating=!0,this.rotateStart.set(r.x-a.x,r.y-a.y),this.controls.enabled=!1),i&&i===t&&(this.isMarkerTranslating=!0,this.translateStart.set(r.x,r.y),this.controls.enabled=!1)},this.onCameraMove=e=>{var t,n;let i=this.cameraDrawable,r=this.cameraDirDrawable;if(!(i&&r&&this.camera&&this.viewerContainer))return;let a=Sn.getScreenCoordinateByEvent(e,this.viewerContainer),s=this.lockCameraInViewCenter?this.camera.position:Sn.world2Screen(i.position,this.camera,this.viewerContainer);if(this.isMarkerRotating){let e=new _e(a.x-s.x,a.y-s.y),n=(new _e).subVectors(e,this.rotateStart);if(Math.abs(n.x)>this.tolerance||Math.abs(n.y)>this.tolerance){let n=e.angle()-this.rotateStart.angle();n=(n+2*Math.PI)%(2*Math.PI),null==(t=r.direction)||t.applyAxisAngle(this.camera.up,-n),this.rotateStart.copy(e)}}if(this.isMarkerTranslating){let e=new _e(a.x,a.y),t=(new _e).subVectors(e,this.translateStart);if(Math.abs(t.x)>this.tolerance||Math.abs(t.y)>this.tolerance){let t=Sn.screen2World(this.translateStart,this.camera,this.viewerContainer),r=Sn.screen2World(e,this.camera,this.viewerContainer),a=(new k).subVectors(r,t);a.setY(0),this.lockCameraInViewCenter?null==(n=this.controls)||n.truck(a.x,a.z):i.position.add(a),this.translateStart.copy(e)}}if(this.isMarkerRotating||this.isMarkerTranslating){let e=this.lockCameraInViewCenter?this.camera.position.clone():i.position.clone(),t=r.direction.clone(),n=this.transformMatrix.clone().invert();e.applyMatrix4(n),t.applyMatrix4(n),this.syncCamera(e,t)}},this.handlePointerUp=()=>{this.isMarkerTranslating=!1,this.isMarkerRotating=!1,this.markerRotateState=!1,this.markerTranslateState=!1,this.controls.enabled=!0},this.handlePointerLeave=()=>{this.markerRotateState=this.isMarkerRotating,this.markerTranslateState=this.isMarkerTranslating,this.isMarkerTranslating=!1,this.isMarkerRotating=!1,this.controls.enabled=!0},this.handlePointerEnter=e=>{1&e.buttons?(this.isMarkerTranslating=this.markerTranslateState,this.isMarkerRotating=this.markerRotateState,this.controls.enabled=!1):(this.markerRotateState=!1,this.markerTranslateState=!1)},this.handleDblClick=e=>{var t;let n=this.cameraDrawable,i=this.cameraDirDrawable;if(this.animationId&&window.cancelAnimationFrame(this.animationId),!(n&&i&&this.camera&&this.viewerContainer))return;let r=Sn.getScreenCoordinateByEvent(e,this.viewerContainer),a=Sn.screen2World(r,this.camera,this.viewerContainer);this.lockCameraInViewCenter?(a.setY(this.camera.position.y),null==(t=this.controls)||t.setLookAt(a.x,a.y,a.z,a.x,0,a.z)):(a.setY(n.position.y),n.position.copy(a));let s=i.direction.clone(),o=this.transformMatrix.clone().invert();a.applyMatrix4(o),s.applyMatrix4(o),this.syncCamera(a,s)},this.handlePointerMove=e=>{this.onCameraHover(e),this.onCameraMove(e),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}),e))},this.isPointInBoundary=e=>{var t;if(null==(t=this.boundaries)||!t.size)return;let n,i=new _e(e.x,e.y);return this.boundaries.forEach((e=>{e.polygon.length<3||en.isPointInPolygon(i,e.polygon)&&(n={id:e.id,name:e.name})})),n},this.animate=()=>{var e,t,n;this.requestAnimationFrameHandle=requestAnimationFrame(this.animate);let i=this.clock.getDelta(),r=null==(e=this.controls)?void 0:e.update(i);if(this.scene&&this.camera){if(this.viewerContainer&&this.viewerContainer){let{width:e,height:t}=this.viewerContainer.getBoundingClientRect();(this.width!==e||this.height!==t)&&(r=!0,this.resize(e,t))}if(this.renderEnabled||r){if(null==(t=this.renderer)||t.render(this.scene,this.camera),!dr.isBrowser){let e=null==(n=this.renderer)?void 0:n.getContext();e&&e.endFrameEXP&&(e.flush(),e.endFrameEXP())}this.enableLookToAllMarkers&&this.lookToAllMarkers(),this.dispatchEvent("AfterRender")}}},this.cfg=t||{},this.transformMatrix=new ht,this.transformMatrix.elements=this.cfg.transformMatrix||[0,0,-1,0,1,0,0,0,0,1,0,0,0,0,0,1],this.enabled=null==(n=this.cfg.enabled)||n,this.lockCameraInViewCenter=!!this.cfg.lockCameraInViewCenter,this.radius=this.cfg.radius,this.size=this.cfg.size,this.minZoomFactor=null!=(i=this.cfg.minZoomFactor)?i:.3,this.maxZoomFactor=null!=(r=this.cfg.maxZoomFactor)?r:5,this.init(),this.animate(),this.enableRender()}get cameraDrawable(){return this.getMarker("cameraDrawable")}get cameraDirDrawable(){return this.getMarker("cameraDirDrawable")}get overviewMapDrawable(){return this.getMarker("overviewMap")}init(){dr.isBrowser&&!this.cfg.context&&this.initDom(),this.initScene(),this.initRenderer(),this.initCamera(),this.initInputManager(),this.initEvents(),this.initControls()}initDom(){let e=this.cfg.containerId?document.getElementById(this.cfg.containerId):void 0,t=document.createElement("div");if(e)t.style.cssText="width: 100%; height: 100%;display: inline-block;position: relative; overflow: hidden;",e.appendChild(t);else{let e="gemini-viewer-overview-map";t.id=e,this.cfg.containerId=e,document.body.appendChild(t)}this.width=t.clientWidth,this.height=t.clientHeight,this.viewerContainer=t}initInputManager(){this.viewerContainer&&(this.inputManager=new id(this.viewerContainer))}initScene(){let e=new Ji;e.background=null,e.matrixAutoUpdate=!1,e.matrixWorldAutoUpdate=!1,this.scene=e}initCamera(){if(!this.scene)return;let e=new xi(-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}initRenderer(){var e;let{context:t}=this.cfg,n={context:t,antialias:!0,preserveDrawingBuffer:!0,alpha:!1,stencil:!1};!dr.isBrowser&&t&&Object.assign(n,{context:t,canvas:dr.creatReactNativeCanvas(t)}),t&&(this.width=t.drawingBufferWidth,this.height=t.drawingBufferHeight),this.renderer=new ga(n),this.renderer.setClearColor(11119017,1),this.renderer.setClearAlpha(0),dr.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),this.overlayRender=new Gn(this),this.overlayRender.addDrawableList(this.drawableList)}initControls(){let e=this.camera;if(!this.inputManager||!e)return;let t=new E1(e,this.inputManager);t.enableRotate=!1,t.enabled=this.enabled,t.keyTruckSpeed=10,t.dollyToCursor=!0,t.dollySpeed=.1,t.truckSpeed=1,t.mouseButtons={left:Tt.TRUCK,middle:Tt.TRUCK,wheel:Tt.ZOOM,right:Tt.TRUCK},t.touches={one:Tt.TOUCH_TRUCK,two:Tt.TOUCH_ZOOM_TRUCK,three:Tt.NONE},t.update(0),this.controls=t,t.addEventListener("control",this.onControlsChange()),t.addEventListener("update",this.onControlsUpdate())}onControlsChange(){return()=>{this.enableRender()}}onControlsUpdate(){return()=>{if(!this.camera||!this.cameraZoom||!this.initialZoom)return;let e=this.camera.zoom;Zt.areNumbersEqual(e,this.cameraZoom)||(this.cameraZoom=e,this.dispatchEvent("ZoomChanged",(e/this.initialZoom).toFixed(2)))}}initEvents(){var e,t,n,i,r,a;!this.enabled||this.lockCameraInViewCenter||(null==(e=this.inputManager)||e.addEventListener("pointermove",this.handlePointerMove),null==(t=this.inputManager)||t.addEventListener("pointerdown",this.handlePointerDown),null==(n=this.inputManager)||n.addEventListener("pointerup",this.handlePointerUp),null==(i=this.inputManager)||i.addEventListener("dblclick",this.handleDblClick),null==(r=this.inputManager)||r.addEventListener("pointerleave",this.handlePointerLeave),null==(a=this.inputManager)||a.addEventListener("pointerenter",this.handlePointerEnter))}getDrawableByEvent(e){var t;if(!this.camera||!this.groundPlane||!this.viewerContainer)return;let n=this.raycaster;if(!n)return;let i=Sn.getScreenCoordinateByEvent(e,this.viewerContainer),r=Sn.screen2Ndc(i,this.camera,this.viewerContainer);n.setFromCamera(r,this.camera);let a=n.intersectObject(this.groundPlane);if(0===a.length||!a[0].point)return;let s=null==(t=this.overlayRender)?void 0:t.getDrawablesByPosition(a[0].point);return s&&s.length>0?s[0]:void 0}onCameraHover(e){let t=this.cameraDrawable,n=this.cameraDirDrawable;if(!t||!n)return;t.hover=!1,n.hover=!1;let i=this.getDrawableByEvent(e);i&&i===n&&(n.hover=!0),i&&i===t&&(t.hover=!0),this.enableRender()}syncCamera(e,t){this.timeout&&clearTimeout(this.timeout),this.isUpdateWhenPawnMove=!1,this.dispatchEvent("SyncCamera",{location:e,direction:t}),this.dispatchEvent("CameraChanged",e.applyMatrix4(this.transformMatrix)),this.timeout=setTimeout((()=>{this.timeout&&clearTimeout(this.timeout),this.isUpdateWhenPawnMove=!0}),500)}updateZoomFromRadius(){if(!this.camera||!this.radius||!this.controls)return;let e=this.controls;e.minZoom=0,e.maxZoom=1/0,e.update(0);let t=this.getContainerRadius(),n=this.camera.zoom*Number((t/this.radius).toFixed(2));this.controls.zoomTo(n)}getContainerRadius(){if(!this.viewerContainer)return;let e=this.viewerContainer,{width:t,height:n}=e.getBoundingClientRect();return this.size&&(t=this.size.width,n=this.size.height),this.screenDistance2WorldDistance(Math.min(t,n)/2)}screenDistance2WorldDistance(e){let t=this.camera,n=this.viewerContainer,i=Sn.screen2World(new _e(e,0),t,n),r=Sn.screen2World(new _e(0,0),t,n);return Math.abs(new _e(i.x,i.z).distanceTo(new _e(r.x,r.z)))}initGroundPlane(e){var t;Pt.expandBoxByScale(e,3);let n=e.min,i=e.max,r=i.x-n.x+i.y-n.y+i.z-n.z;Pt.expandBoxByMinSize(e,r);let a=[],s=(e,t,n)=>{a.push(new k(e,t,n))},o=e.getSize(new k),l=e.getCenter(new k);if(s(-o.x/2,0,-o.z/2),s(o.x/2,0,-o.z/2),s(o.x/2,0,o.z/2),s(-o.x/2,0,o.z/2),this.groundPlane)this.groundPlane.geometry.setFromPoints(a),this.groundPlane.geometry.computeBoundingSphere(),this.groundPlane.geometry.computeBoundingBox(),this.groundPlane.geometry.computeVertexNormals();else{let e=new Ot;e.setFromPoints(a),e.setIndex([0,3,2,0,2,1]),e.computeVertexNormals();let n=new cn({color:"#888",transparent:!0,opacity:0,side:hr});this.groundPlane=new St(e,n),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(),rr.disableLayerChannels(this.groundPlane,[12]),null==(t=this.scene)||t.add(this.groundPlane)}this.groundPlane.updateMatrixWorld()}initMaxAndMinZoom(){if(!this.controls)return;this.controls.update(0);let e=this.camera.zoom;this.controls.minZoom=e*this.minZoomFactor,this.controls.maxZoom=e*this.maxZoomFactor,this.initialZoom=e,this.cameraZoom=e}getImageElementFromUrl(e){let t=new Image;return t.src=e,new Promise(((e,n)=>{t.onload=()=>{e(t)},t.onerror=e=>{n(e)}}))}updateOverviewMap(e){return it(this,null,(function*(){let t=new k,n=new k;t.set(e.min.x,e.min.y,e.min.z),n.set(e.max.x,e.max.y,e.max.z),t.applyMatrix4(this.transformMatrix),n.applyMatrix4(this.transformMatrix);let i=yield this.getImageElementFromUrl(e.image),r=new k(Math.min(t.x,n.x),0,Math.min(t.z,n.z)),a=new k(Math.max(t.x,n.x),0,Math.max(t.z,n.z)),s=new Nt(r,a);this.initGroundPlane(s.clone());let o=this.overviewMapDrawable;o?(o.image=i,o.radius=this.radius,o.max.copy(n),o.min.copy(t)):(this.zoomToBBox(s),this.updateZoomFromRadius(),this.initMaxAndMinZoom(),this.addMarker(new L2("overviewMap",{image:i,min:t,max:n,radius:this.radius}))),this.imgBBox=s,this.enableRender()}))}createCameraMarkers(e,t){return it(this,null,(function*(){var n,i;if(!this.camera||!this.viewerContainer)return;let r=this.cameraDrawable,a=this.cameraDirDrawable;if(r)r.position.copy(e),null==(n=r.direction)||n.copy(t);else{let n=yield this.getImageElementFromUrl(xye),i=yield this.getImageElementFromUrl(Eye);this.addMarker(new D_("cameraDirDrawable",{image:n,hoverImage:i,translate:new _e(-1,-.5),scale:.25,position:e,direction:t,enabledHover:this.enabled}))}if(a)a.position.copy(e),null==(i=a.direction)||i.copy(t);else{let n=yield this.getImageElementFromUrl(yye),i=yield this.getImageElementFromUrl(bye);this.addMarker(new D_("cameraDrawable",{image:n,hoverImage:i,translate:new _e(-.5,-.5),scale:.25,position:e,direction:t,enabledHover:this.enabled,renderOrder:-996}))}this.enableRender()}))}initCameraMarkers(e,t){return it(this,null,(function*(){var n;let i=new k(e.x,e.y,e.z),r=new k(t.x,t.y,t.z);if(i.applyMatrix4(this.transformMatrix),r.applyMatrix4(this.transformMatrix),this.lockCameraInViewCenter){let e=this.camera;yield this.createCameraMarkers(e.position,r),i.setY(e.position.y),null==(n=this.controls)||n.setLookAt(i.x,i.y,i.z,i.x,0,i.z)}else yield this.createCameraMarkers(i,r)}))}updateOverviewMapCameraAnimation(){var e,t;let n=this.animationParam;if(!n)return void(this.animationId&&cancelAnimationFrame(this.animationId));let{startTime:i,positionStart:r,positionEnd:a,directionStart:s,directionEnd:o}=n,l=Math.min(1,(Date.now()-i)/500),h=r.lerp(a,l),u=null==s?void 0:s.lerp(o,l),c=this.cameraDrawable,d=this.cameraDirDrawable;if(u&&(null==(e=null==d?void 0:d.direction)||e.copy(u)),this.lockCameraInViewCenter?null==(t=this.controls)||t.setLookAt(h.x,h.y,h.z,h.x,0,h.z):(null==c||c.position.copy(h),null==d||d.position.copy(h)),this.enableRender(),1===l)return this.animationParam=void 0,void(this.animationId&&cancelAnimationFrame(this.animationId));this.animationId=requestAnimationFrame(this.updateOverviewMapCameraAnimation.bind(this))}updateOverviewMapCamera(e,t){var n;let i=this.cameraDrawable,r=this.cameraDirDrawable;if(!(this.camera&&this.viewerContainer&&i&&this.isUpdateWhenPawnMove))return;this.animationId&&cancelAnimationFrame(this.animationId);let a,s=new k(e.x,e.y,e.z),o=new k(t.x,t.y,t.z);s.applyMatrix4(this.transformMatrix),o.applyMatrix4(this.transformMatrix),this.lockCameraInViewCenter?(a=this.camera.position.clone(),s.setY(a.y)):a=i.position.clone();let l=Date.now(),h=null==(n=null==r?void 0:r.direction)?void 0:n.clone();this.animationParam={startTime:l,positionStart:a,positionEnd:s,directionStart:h,directionEnd:o},this.updateOverviewMapCameraAnimation(),this.dispatchEvent("CameraChanged",s)}zoomToBBox(e){if(!this.scene||!this.camera||!this.controls)return;let t=this.camera,n=e.max.x-e.min.x,i=e.max.z-e.min.z,r=t.right-t.left,a=t.top-t.bottom,s=Math.min(r/n,a/i);this.controls.zoomTo(s);let o=new k;e.getCenter(o);let l=o.clone().setY(e.max.y+2);l.equals(o)||this.controls.setLookAt(l.x,l.y,l.z,o.x,o.y,o.z)}addMarker(e){this.drawableList.addDrawable(e),this.enableRender()}getMarker(e){return this.drawableList.getDrawableById(e)}removeMarker(e){this.drawableList.removeDrawable(e),this.enableRender()}dollyIn(e=.2){let t=this.camera;if(!t||!this.controls||!this.initialZoom)return;let n=t.zoom,i=Math.min(n+e*this.initialZoom,this.controls.maxZoom);this.controls.zoomTo(i)}dollyOut(e=.2){let t=this.camera;if(!t||!this.controls||!this.initialZoom)return;let n=t.zoom,i=Math.max(n-e*this.initialZoom,this.controls.minZoom);this.controls.zoomTo(i)}goToHomeView(){this.imgBBox&&this.zoomToBBox(this.imgBBox)}setRadius(e){this.radius=e;let t=this.overviewMapDrawable;t&&(t.radius=e),this.updateZoomFromRadius()}registerBoundaries(e){this.boundaries||(this.boundaries=new Map),e.forEach((e=>{var t;let n=e.points.map((e=>new _e(e.x,e.y)));null==(t=this.boundaries)||t.set(e.id,{id:e.id,name:e.name,polygon:n})}))}screenShot(){return it(this,null,(function*(){var e;try{let t=yield null==(e=this.overlayRender)?void 0:e.getImage((()=>!0));return null==t?void 0:t.src}catch(e){return void fe.error(e)}}))}getViewConfig(){return this.cfg}is3d(){return!0}getRaycaster(){return this.raycaster}getPixelSizeInWorldCoord(){let e=this.camera,{clientWidth:t,clientHeight:n}=this.viewerContainer;return Math.max(e.right-e.left,e.top-e.bottom)/e.zoom/Math.max(t,n)}lookToAllMarkers(){var e,t;let n=new Nt;this.drawableList.getDrawables().forEach((e=>{if("overviewMap"===e.id||"cameraDrawable"===e.id||"cameraDirDrawable"===e.id||!this.camera||!this.viewerContainer)return;let t=e;n.union(t.getBBox())})),n.min.setY(0),n.max.setY(0);let i=n.min.distanceTo(n.max);n.expandByVector(new k(.01*i,0,.01*i)),Zt.areVector3sEqual(null==(e=this.allMarkersBBox)?void 0:e.min,n.min)&&Zt.areVector3sEqual(null==(t=this.allMarkersBBox)?void 0:t.max,n.max)?this.enableLookToAllMarkers=!1:(this.allMarkersBBox=n,this.zoomToBBox(n))}resize(e,t){let n=this.camera;if(n&&t>0){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.overlayRender&&this.overlayRender.setSize(e,t)}this.width=e,this.height=t,this.enableRender()}destroy(){var e,t,n;this.raycaster=void 0,null==(e=this.inputManager)||e.removeEventListener(),this.animationId&&(cancelAnimationFrame(this.animationId),this.animationId=void 0),this.timeout&&(clearTimeout(this.timeout),this.timeout=void 0),this.drawableList.clear(),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()}},jV=XV;jV.DEFAULT_ID="OverviewMapPlugin";export{pR as ANGLE_THRESHOLD_FOR_EDGE,$Lt as AXIS_SECTION_PLANE_CONTROL_ID,YLt as AXIS_SECTION_PLANE_ID,YH as ArrowMarkup,C4 as AxisGizmoPlugin,a2 as AxisPlaneSection,p1e as AxisType,Bv as BYBLOCK,Nv as BYLAYER,FP as BaseDxfCompareHelper,Fr as BaseMeasureDrawable,Xu as BaseMeasurement,Qf as BaseSection,$u as BaseVRMesh,Gf as BaseViewer,Lve as BimViewer,m1e as BimViewerDatGuiPlugin,HV as BimViewerToolbarPlugin,bf as BinaryReader,Bve as BottomBarPlugin,zf as BoxSelectHelper,pf as CSS2DObjectUtils,Rde as CancelablePromise,Gn as CanvasRender,$H as CircleMarkup,Ic as CloudLineMarkup,ZH as CloudRectMarkup,An as ColorUtils,Pt as CommonUtils,Im as CompareDrawable,zve as ContextMenuPlugin,Sn as CoordinateUtils,fye as DEFAULT_BIMVIEWER_TOOLBAR_CONFIG,ELt as DEFAULT_BIM_VIEWER_CONFIG,pye as DEFAULT_DXFVIEWER_TOOLBAR_CONFIG,hye as DEFAULT_MARKUP_TOOLBAR_CONFIG,dr as DeviceUtils,KH as DotMarkup,Wi as Drawable,Xo as DrawableList,p5 as DxfChangeType,js as DxfCompare,wve as DxfCompareHelper,b0e as DxfCompareMarkupManager,Ln as DxfLoader,km as DxfParser,ope as DxfRenderOrder,Dc as DxfUtils,jf as DxfViewer,BV as DxfViewerToolbarPlugin,XLt as ENTER_KEY,jLt as ESC_KEY,gR as EdgeUtils,JH as EllipseMarkup,Ms as Event,x_ as ExplodePlugin,gf as ExportUtils,zm as FontManager,Kde as FpsUtils,Nde as GROUND_PLANE_RENDER_ORDER,w2 as GROUP_CONFIG,vP as GenerateMeshBvhWorker,en as GeometryUtils,b_ as GroundGrassPlugin,E_ as GroundGridPlugin,Z4 as GroundShadowPlugin,y1e as HotpointPlugin,fR as ICON_FONT_CLASS,D_ as ImageDrawable,id as InputManager,j0e as InstantiateHelper,qLt as KEYDOWN_EVENT,WLt as KEYUP_EVENT,Y4 as LayerManagerPlugin,QH as LeaderLineMarkup,Vr as Line,gye as LineDrawable,aC as LinePatternShaders,ju as LoadingHelper,iye as LocalDxfUploader,sye as LocalImageUploader,c2 as LocalModelUploader,dye as MARKUP_GROUP_CONFIG,cH as MOUSEDOWN_EVENT,mf as MOUSEMOVE_EVENT,lH as MOUSEUP_EVENT,Wb as MarkupManager,S2 as MarkupToolbar,Wa as MarkupType,Si as MaterialUtils,Zt as MathUtils,Jm as MeasurementPlugin,Kl as MeasurementType,T2 as MenuTypeEnums,Mi as MergeUtils,St as Mesh,yP as MeshBvhHelper,AP as MobileTouchHelperDrawable,d1 as Model,jl as Model2d,XE as Model3d,PV as NavCubePlugin,Nf as NavigationModes,Lm as NestCompareTypes,TP as OSnapHelper,$fe as OSnapMarkerType,y4 as OSnapType,xve as ObjectPixelSizeHelper,rr as ObjectUtils,o2 as ObjectsBoxSection,Ave as Offset,ZC as OrbitControl,L2 as OverviewMapDrawable,jV as OverviewMapPlugin,C1t as OverviewMapPluginEvent,tp as PdfLoader,R_ as PdfLoaderPlugin,wP as PickMarkupHelper,l2 as PickPlaneSection,KC as PlanControl,ar as Plugin,Di as Points,Rm as PolygonUtils,e5 as PolylineMarkup,jC as ProgressBar,p1 as RafHelper,t5 as RectMarkup,JLt as SECTION_BOX_ID,KLt as SECTION_PLANE_CONTROL_ID,ZLt as SECTION_PLANE_ID,QLt as SECTION_PLANE_NAME,ROt as SNAP_ICON_SIZE,bde as SVGObject,Yfe as SVGObjectUtils,Ede as SVGRenderer,Ol as SceneUtils,Bde as ScreenshotMode,Zf as ScreenshotPlugin,Yc as SectionPlugin,mR as SectionType,ku as SectionUtils,$n as ShaderChunk,Dve as SimplifiedBimViewer,Xfe as SimplifyUtils,LV as SkyboxPlugin,As as SnapDrawable,uye as StatsPlugin,vye as TextDrawable,kl as TextMarkup,xf as TextureUtils,np as Toolbar,kV as ToolbarMenu,OV as ToolbarMenuId,cC as Units,JC as VRControl,YP as VRCube,$P as VRCube24Faces,ZP as VRSphere,kve as VRViewer,qV as ViewCubePlugin,VR as Viewer3DUtils,gi as ViewerEvent,Rvt as ViewerMode,Xm as ViewerName,XH as Views,n5 as XMarkup,MP as ZoomToRectHelper,P5 as bspline,Sme as checkIsNewVersion,mfe as cn,Vve as contextMenuItems,_me as createHatchPatternShaderMaterial,ydt as decodeDxfTextCharacterCodes,bdt as decodeDxfTextMbcsCharacterCodes,xdt as decodeDxfTextUnicodeCodePoints,pfe as en,FOt as getLengthValueByUnit,Hb as getUnitStr,Tdt as getVersionFromLocalStorage,dR as layerForHitableObjects,wi as layerForSelectableObjects,Ss as layerForSnapableObjects,fe as log,Qi as matrixAutoUpdate,oC as parseDxfMTextContent,lC as parseDxfTextContent,R5 as round10,GLt as sceneAutoUpdate,hR as setIcon,Ide as setLogLevel,wdt as setVersionToLocalStorage,Ou as showPrecisionValue,Zfe as unitConversionByMeter,cht as unitLabel,w8t as unitScaleConversion,Tme as unitScaleToMeter}; |