Files
gemini-viewer-examples/demo/libs/gemini-viewer.esm.min.js
pattern-x f5ecfc9ab4 Merge pull request #115 from pattern-x/feature/dat.gui
Add dat.gui, and enable to update dxf elevation for bim_2_overlay_wit…
2023-09-18 01:15:14 +00:00

1 line
3.3 MiB

var Qwe=Object.create,y1=Object.defineProperty,eSe=Object.defineProperties,tSe=Object.getOwnPropertyDescriptor,nSe=Object.getOwnPropertyDescriptors,rSe=Object.getOwnPropertyNames,SG=Object.getOwnPropertySymbols,MG=Object.getPrototypeOf,RG=Object.prototype.hasOwnProperty,iSe=Object.prototype.propertyIsEnumerable,sSe=Reflect.get,Do=Math.pow,s3=(e,t,i)=>t in e?y1(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,Tr=(e,t)=>{for(var i in t||(t={}))RG.call(t,i)&&s3(e,i,t[i]);if(SG)for(var i of SG(t))iSe.call(t,i)&&s3(e,i,t[i]);return e},Ii=(e,t)=>eSe(e,nSe(t)),a3=(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')})),aSe=(e,t)=>()=>(e&&(t=e(e=0)),t),Q=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),zT=(e,t)=>{for(var i in t)y1(e,i,{get:t[i],enumerable:!0})},AG=(e,t,i,n)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let r of rSe(t))!RG.call(e,r)&&r!==i&&y1(e,r,{get:()=>t[r],enumerable:!(n=tSe(t,r))||n.enumerable});return e},Xi=(e,t,i)=>(i=null!=e?Qwe(MG(e)):{},AG(!t&&e&&e.__esModule?i:y1(i,"default",{value:e,enumerable:!0}),e)),oSe=e=>AG(y1({},"__esModule",{value:!0}),e),Yi=(e,t,i)=>(s3(e,"symbol"!=typeof t?t+"":t,i),i),o3=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)},ce=(e,t,i)=>(o3(e,t,"read from private field"),i?i.call(e):t.get(e)),Je=(e,t,i)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,i)},Mt=(e,t,i,n)=>(o3(e,t,"write to private field"),n?n.call(e,i):t.set(e,i),i),GT=(e,t,i,n)=>({set _(n){Mt(e,t,n,i)},get _(){return ce(e,t,n)}}),dt=(e,t,i)=>(o3(e,t,"access private method"),i),CG=(e,t,i)=>sSe(MG(e),i,t),ft=(e,t,i)=>new Promise(((n,r)=>{var a=e=>{try{o(i.next(e))}catch(e){r(e)}},s=e=>{try{o(i.throw(e))}catch(e){r(e)}},o=e=>e.done?n(e.value):Promise.resolve(e.value).then(a,s);o((i=i.apply(e,t)).next())})),LG={};function qT(e){return(qT="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 cSe(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function PG(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function uSe(e,t,i){return t&&PG(e.prototype,t),i&&PG(e,i),e}function pSe(e,t,i){var n=function(e){do{if(t(e))return e;e=e.replace(/-?[^-]*$/,"")}while(e);return null},r=function(e){for(var t=IG(e),i=0;i<t.length;++i){var r=n(t[i]);if(r)return r}return n(dSe())},a=function(){function a(i){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};cSe(this,a),this._locale=r(i),this._select=t(this._locale),this._type=fSe(n.type),this._nf=new e("en",n)}return uSe(a,[{key:"resolvedOptions",value:function(){var e=this._nf.resolvedOptions(),t=e.minimumIntegerDigits,n=e.minimumFractionDigits,r=e.maximumFractionDigits,a=e.minimumSignificantDigits,s=e.maximumSignificantDigits,o={locale:this._locale,minimumIntegerDigits:t,minimumFractionDigits:n,maximumFractionDigits:r,pluralCategories:i(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 a))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 IG(e).filter(n)}}]),a}();return Object.defineProperty(a,"prototype",{writable:!1}),a}zT(LG,{default:()=>pSe});var hSe,IG,dSe,fSe,DG=aSe((()=>{hSe=function(e){return e.split("-").every((function(e){return/[a-z0-9]+/i.test(e)}))},IG=function(e){if(!e)return[];Array.isArray(e)||(e=[e]);for(var t={},i=0;i<e.length;++i){var n=e[i];if(n&&"object"===qT(n)&&(n=String(n)),"string"!=typeof n){var r="Locales should be strings, ".concat(JSON.stringify(n)," isn't.");throw new TypeError(r)}if("*"!==n[0]){if(!hSe(n)){var a=JSON.stringify(n),s="The locale ".concat(a," is not a structurally valid BCP 47 language tag.");throw new RangeError(s)}t[n]=!0}}return Object.keys(t)},dSe=function(){return"undefined"!=typeof navigator&&navigator&&(navigator.userLanguage||navigator.language)||"en-US"},fSe=function(e){if(!e)return"cardinal";if("cardinal"===e||"ordinal"===e)return e;throw new RangeError("Not a valid plural type: "+JSON.stringify(e))}})),FG=Q(((e,t)=>{"use strict";function i(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var n=function(){function e(t,i){var n=i.minimumIntegerDigits,r=i.minimumFractionDigits,a=i.maximumFractionDigits,s=i.minimumSignificantDigits,o=i.maximumSignificantDigits;(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")})(this,e),this._minID="number"==typeof n?n: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,n){t&&i(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),i=0,n=0;n<t.length;++n){var r=t[n];r>="0"&&r<="9"&&++i}return i<this._minSD?e.toPrecision(this._minSD):i>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=n})),qG=Q(((e,t)=>{"use strict";var i=(DG(),oSe(LG)),n=FG();function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=r(i),s=r(n);function o(e){return(o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function l(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;var h,c,u,d,p,f,m,g,v={exports:{}};h=v,u=function(e,t){return t?"other":1==e?"one":"other"},d=function(e,t){return t?"other":0==e||1==e?"one":"other"},p=function(e,t){return t?"other":e>=0&&e<=1?"one":"other"},f=function(e,t){var i=!String(e).split(".")[1];return t?"other":1==e&&i?"one":"other"},g=function(e,t){return t?"other":1==e?"one":2==e?"two":"other"},c={_in:m=function(e,t){return"other"},af:u,ak:d,am:p,an:u,ar:function(e,t){var i=String(e).split("."),n=Number(i[0])==e&&i[0].slice(-2);return t?"other":0==e?"zero":1==e?"one":2==e?"two":n>=3&&n<=10?"few":n>=11&&n<=99?"many":"other"},ars:function(e,t){var i=String(e).split("."),n=Number(i[0])==e&&i[0].slice(-2);return t?"other":0==e?"zero":1==e?"one":2==e?"two":n>=3&&n<=10?"few":n>=11&&n<=99?"many":"other"},as:function(e,t){return t?1==e||5==e||7==e||8==e||9==e||10==e?"one":2==e||3==e?"two":4==e?"few":6==e?"many":"other":e>=0&&e<=1?"one":"other"},asa:u,ast:f,az:function(e,t){var i=String(e).split(".")[0],n=i.slice(-1),r=i.slice(-2),a=i.slice(-3);return t?1==n||2==n||5==n||7==n||8==n||20==r||50==r||70==r||80==r?"one":3==n||4==n||100==a||200==a||300==a||400==a||500==a||600==a||700==a||800==a||900==a?"few":0==i||6==n||40==r||60==r||90==r?"many":"other":1==e?"one":"other"},be:function(e,t){var i=String(e).split("."),n=Number(i[0])==e,r=n&&i[0].slice(-1),a=n&&i[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":n&&0==r||r>=5&&r<=9||a>=11&&a<=14?"many":"other"},bem:u,bez:u,bg:u,bho:d,bm:m,bn:function(e,t){return t?1==e||5==e||7==e||8==e||9==e||10==e?"one":2==e||3==e?"two":4==e?"few":6==e?"many":"other":e>=0&&e<=1?"one":"other"},bo:m,br:function(e,t){var i=String(e).split("."),n=Number(i[0])==e,r=n&&i[0].slice(-1),a=n&&i[0].slice(-2),s=n&&i[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&&n&&0==s?"many":"other"},brx:u,bs:function(e,t){var i=String(e).split("."),n=i[0],r=i[1]||"",a=!i[1],s=n.slice(-1),o=n.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 i=!String(e).split(".")[1];return t?1==e||3==e?"one":2==e?"two":4==e?"few":"other":1==e&&i?"one":"other"},ce:u,ceb:function(e,t){var i=String(e).split("."),n=i[0],r=i[1]||"",a=!i[1],s=n.slice(-1),o=r.slice(-1);return t?"other":a&&(1==n||2==n||3==n)||a&&4!=s&&6!=s&&9!=s||!a&&4!=o&&6!=o&&9!=o?"one":"other"},cgg:u,chr:u,ckb:u,cs:function(e,t){var i=String(e).split("."),n=i[0],r=!i[1];return t?"other":1==e&&r?"one":n>=2&&n<=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 i=String(e).split("."),n=i[0],r=Number(i[0])==e;return t||1!=e&&(r||0!=n&&1!=n)?"other":"one"},de:f,doi:p,dsb:function(e,t){var i=String(e).split("."),n=i[0],r=i[1]||"",a=!i[1],s=n.slice(-2),o=r.slice(-2);return t?"other":a&&1==s||1==o?"one":a&&2==s||2==o?"two":a&&(3==s||4==s)||3==o||4==o?"few":"other"},dv:u,dz:m,ee:u,el:u,en:function(e,t){var i=String(e).split("."),n=!i[1],r=Number(i[0])==e,a=r&&i[0].slice(-1),s=r&&i[0].slice(-2);return t?1==a&&11!=s?"one":2==a&&12!=s?"two":3==a&&13!=s?"few":"other":1==e&&n?"one":"other"},eo:u,es:u,et:f,eu:u,fa:p,ff:function(e,t){return t?"other":e>=0&&e<2?"one":"other"},fi:f,fil:function(e,t){var i=String(e).split("."),n=i[0],r=i[1]||"",a=!i[1],s=n.slice(-1),o=r.slice(-1);return t?1==e?"one":"other":a&&(1==n||2==n||3==n)||a&&4!=s&&6!=s&&9!=s||!a&&4!=o&&6!=o&&9!=o?"one":"other"},fo:u,fr:function(e,t){var i=String(e).split("."),n=i[0],r=!i[1],a=n.slice(-6);return t?1==e?"one":"other":e>=0&&e<2?"one":0!=n&&0==a&&r?"many":"other"},fur:u,fy:f,ga:function(e,t){var i=String(e).split("."),n=Number(i[0])==e;return t?1==e?"one":"other":1==e?"one":2==e?"two":n&&e>=3&&e<=6?"few":n&&e>=7&&e<=10?"many":"other"},gd:function(e,t){var i=String(e).split("."),n=Number(i[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":n&&e>=3&&e<=10||n&&e>=13&&e<=19?"few":"other"},gl:f,gsw:u,gu:function(e,t){return t?1==e?"one":2==e||3==e?"two":4==e?"few":6==e?"many":"other":e>=0&&e<=1?"one":"other"},guw:d,gv:function(e,t){var i=String(e).split("."),n=i[0],r=!i[1],a=n.slice(-1),s=n.slice(-2);return t?"other":r&&1==a?"one":r&&2==a?"two":!r||0!=s&&20!=s&&40!=s&&60!=s&&80!=s?r?"other":"many":"few"},ha:u,haw:u,he:function(e,t){var i=String(e).split("."),n=i[0],r=!i[1],a=Number(i[0])==e,s=a&&i[0].slice(-1);return t?"other":1==e&&r?"one":2==n&&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 i=String(e).split("."),n=i[0],r=i[1]||"",a=!i[1],s=n.slice(-1),o=n.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 i=String(e).split("."),n=i[0],r=i[1]||"",a=!i[1],s=n.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 i=String(e).split("."),n=i[0],r=Number(i[0])==e,a=n.slice(-1),s=n.slice(-2);return t?"other":r&&1==a&&11!=s||!r?"one":"other"},it:function(e,t){var i=!String(e).split(".")[1];return t?11==e||8==e||80==e||800==e?"many":"other":1==e&&i?"one":"other"},iu:g,iw:function(e,t){var i=String(e).split("."),n=i[0],r=!i[1],a=Number(i[0])==e,s=a&&i[0].slice(-1);return t?"other":1==e&&r?"one":2==n&&r?"two":r&&(e<0||e>10)&&a&&0==s?"many":"other"},ja:m,jbo:m,jgo:u,ji:f,jmc:u,jv:m,jw:m,ka:function(e,t){var i=String(e).split(".")[0],n=i.slice(-2);return t?1==i?"one":0==i||n>=2&&n<=20||40==n||60==n||80==n?"many":"other":1==e?"one":"other"},kab:function(e,t){return t?"other":e>=0&&e<2?"one":"other"},kaj:u,kcg:u,kde:m,kea:m,kk:function(e,t){var i=String(e).split("."),n=Number(i[0])==e,r=n&&i[0].slice(-1);return t?6==r||9==r||n&&0==r&&0!=e?"many":"other":1==e?"one":"other"},kkj:u,kl:u,km:m,kn:p,ko:m,ks:u,ksb:u,ksh:function(e,t){return t?"other":0==e?"zero":1==e?"one":"other"},ku:u,kw:function(e,t){var i=String(e).split("."),n=Number(i[0])==e,r=n&&i[0].slice(-2),a=n&&i[0].slice(-3),s=n&&i[0].slice(-5),o=n&&i[0].slice(-6);return t?n&&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||n&&0==a&&(s>=1e3&&s<=2e4||4e4==s||6e4==s||8e4==s)||0!=e&&1e5==o?"two":3==r||23==r||43==r||63==r||83==r?"few":1==e||1!=r&&21!=r&&41!=r&&61!=r&&81!=r?"other":"many"},ky:u,lag:function(e,t){var i=String(e).split(".")[0];return t?"other":0==e?"zero":0!=i&&1!=i||0==e?"other":"one"},lb:u,lg:u,lij:function(e,t){var i=String(e).split("."),n=!i[1],r=Number(i[0])==e;return t?11==e||8==e||r&&e>=80&&e<=89||r&&e>=800&&e<=899?"many":"other":1==e&&n?"one":"other"},lkt:m,ln:d,lo:function(e,t){return t&&1==e?"one":"other"},lt:function(e,t){var i=String(e).split("."),n=i[1]||"",r=Number(i[0])==e,a=r&&i[0].slice(-1),s=r&&i[0].slice(-2);return t?"other":1==a&&(s<11||s>19)?"one":a>=2&&a<=9&&(s<11||s>19)?"few":0!=n?"many":"other"},lv:function(e,t){var i=String(e).split("."),n=i[1]||"",r=n.length,a=Number(i[0])==e,s=a&&i[0].slice(-1),o=a&&i[0].slice(-2),l=n.slice(-2),h=n.slice(-1);return t?"other":a&&0==s||o>=11&&o<=19||2==r&&l>=11&&l<=19?"zero":1==s&&11!=o||2==r&&1==h&&11!=l||2!=r&&1==h?"one":"other"},mas:u,mg:d,mgo:u,mk:function(e,t){var i=String(e).split("."),n=i[0],r=i[1]||"",a=!i[1],s=n.slice(-1),o=n.slice(-2),l=r.slice(-1),h=r.slice(-2);return t?1==s&&11!=o?"one":2==s&&12!=o?"two":7!=s&&8!=s||17==o||18==o?"other":"many":a&&1==s&&11!=o||1==l&&11!=h?"one":"other"},ml:u,mn:u,mo:function(e,t){var i=String(e).split("."),n=!i[1],r=Number(i[0])==e&&i[0].slice(-2);return t?1==e?"one":"other":1==e&&n?"one":!n||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 i=String(e).split("."),n=Number(i[0])==e&&i[0].slice(-2);return t?"other":1==e?"one":0==e||n>=2&&n<=10?"few":n>=11&&n<=19?"many":"other"},my:m,nah:u,naq:g,nb:u,nd:u,ne:function(e,t){var i=String(e).split("."),n=Number(i[0])==e;return t?n&&e>=1&&e<=4?"one":"other":1==e?"one":"other"},nl:f,nn:u,nnh:u,no:u,nqo:m,nr:u,nso:d,ny:u,nyn:u,om:u,or:function(e,t){var i=String(e).split("."),n=Number(i[0])==e;return t?1==e||5==e||n&&e>=7&&e<=9?"one":2==e||3==e?"two":4==e?"few":6==e?"many":"other":1==e?"one":"other"},os:u,osa:m,pa:d,pap:u,pcm:p,pl:function(e,t){var i=String(e).split("."),n=i[0],r=!i[1],a=n.slice(-1),s=n.slice(-2);return t?"other":1==e&&r?"one":r&&a>=2&&a<=4&&(s<12||s>14)?"few":r&&1!=n&&(0==a||1==a)||r&&a>=5&&a<=9||r&&s>=12&&s<=14?"many":"other"},prg:function(e,t){var i=String(e).split("."),n=i[1]||"",r=n.length,a=Number(i[0])==e,s=a&&i[0].slice(-1),o=a&&i[0].slice(-2),l=n.slice(-2),h=n.slice(-1);return t?"other":a&&0==s||o>=11&&o<=19||2==r&&l>=11&&l<=19?"zero":1==s&&11!=o||2==r&&1==h&&11!=l||2!=r&&1==h?"one":"other"},ps:u,pt:function(e,t){var i=String(e).split(".")[0];return t?"other":0==i||1==i?"one":"other"},pt_PT:f,rm:u,ro:function(e,t){var i=String(e).split("."),n=!i[1],r=Number(i[0])==e&&i[0].slice(-2);return t?1==e?"one":"other":1==e&&n?"one":!n||0==e||r>=2&&r<=19?"few":"other"},rof:u,root:m,ru:function(e,t){var i=String(e).split("."),n=i[0],r=!i[1],a=n.slice(-1),s=n.slice(-2);return t?"other":r&&1==a&&11!=s?"one":r&&a>=2&&a<=4&&(s<12||s>14)?"few":r&&0==a||r&&a>=5&&a<=9||r&&s>=11&&s<=14?"many":"other"},rwk:u,sah:m,saq:u,sat:g,sc:function(e,t){var i=!String(e).split(".")[1];return t?11==e||8==e||80==e||800==e?"many":"other":1==e&&i?"one":"other"},scn:function(e,t){var i=!String(e).split(".")[1];return t?11==e||8==e||80==e||800==e?"many":"other":1==e&&i?"one":"other"},sd:u,sdh:u,se:g,seh:u,ses:m,sg:m,sh:function(e,t){var i=String(e).split("."),n=i[0],r=i[1]||"",a=!i[1],s=n.slice(-1),o=n.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 i=String(e).split("."),n=Number(i[0])==e;return t?"other":e>=0&&e<=1?"one":n&&e>=2&&e<=10?"few":"other"},si:function(e,t){var i=String(e).split("."),n=i[0],r=i[1]||"";return t?"other":0==e||1==e||0==n&&1==r?"one":"other"},sk:function(e,t){var i=String(e).split("."),n=i[0],r=!i[1];return t?"other":1==e&&r?"one":n>=2&&n<=4&&r?"few":r?"other":"many"},sl:function(e,t){var i=String(e).split("."),n=i[0],r=!i[1],a=n.slice(-2);return t?"other":r&&1==a?"one":r&&2==a?"two":r&&(3==a||4==a)||!r?"few":"other"},sma:g,smi:g,smj:g,smn:g,sms:g,sn:u,so:u,sq:function(e,t){var i=String(e).split("."),n=Number(i[0])==e,r=n&&i[0].slice(-1),a=n&&i[0].slice(-2);return t?1==e?"one":4==r&&14!=a?"many":"other":1==e?"one":"other"},sr:function(e,t){var i=String(e).split("."),n=i[0],r=i[1]||"",a=!i[1],s=n.slice(-1),o=n.slice(-2),l=r.slice(-1),h=r.slice(-2);return t?"other":a&&1==s&&11!=o||1==l&&11!=h?"one":a&&s>=2&&s<=4&&(o<12||o>14)||l>=2&&l<=4&&(h<12||h>14)?"few":"other"},ss:u,ssy:u,st:u,su:m,sv:function(e,t){var i=String(e).split("."),n=!i[1],r=Number(i[0])==e,a=r&&i[0].slice(-1),s=r&&i[0].slice(-2);return t?1!=a&&2!=a||11==s||12==s?"other":"one":1==e&&n?"one":"other"},sw:f,syr:u,ta:u,te:u,teo:u,th:m,ti:d,tig:u,tk:function(e,t){var i=String(e).split("."),n=Number(i[0])==e&&i[0].slice(-1);return t?6==n||9==n||10==e?"few":"other":1==e?"one":"other"},tl:function(e,t){var i=String(e).split("."),n=i[0],r=i[1]||"",a=!i[1],s=n.slice(-1),o=r.slice(-1);return t?1==e?"one":"other":a&&(1==n||2==n||3==n)||a&&4!=s&&6!=s&&9!=s||!a&&4!=o&&6!=o&&9!=o?"one":"other"},tn:u,to:m,tr:u,ts:u,tzm:function(e,t){var i=String(e).split("."),n=Number(i[0])==e;return t?"other":0==e||1==e||n&&e>=11&&e<=99?"one":"other"},ug:u,uk:function(e,t){var i=String(e).split("."),n=i[0],r=!i[1],a=Number(i[0])==e,s=a&&i[0].slice(-1),o=a&&i[0].slice(-2),l=n.slice(-1),h=n.slice(-2);return t?3==s&&13!=o?"few":"other":r&&1==l&&11!=h?"one":r&&l>=2&&l<=4&&(h<12||h>14)?"few":r&&0==l||r&&l>=5&&l<=9||r&&h>=11&&h<=14?"many":"other"},ur:f,uz:u,ve:u,vi:function(e,t){return t&&1==e?"one":"other"},vo:u,vun:u,wa:d,wae:u,wo:m,xh:u,xog:u,yi:f,yo:m,yue:m,zh:m,zu:p},Object.defineProperty(c,"__esModule",{value:!0}),h.exports=c;var y=l(v.exports),x=Object.freeze(Object.assign(Object.create(null),v.exports,{default:y})),b={exports:{}};!function(e,t){var i,n="zero",r="one",a="two",s="few",o="many",l="other",h={cardinal:[r,l],ordinal:[l]},c={cardinal:[l],ordinal:[l]},u={cardinal:[r,s,o,l],ordinal:[l]},d={cardinal:[r,l],ordinal:[r,l]},p={cardinal:[r,a,l],ordinal:[l]};i={_in:c,af:h,ak:h,am:h,an:h,ar:{cardinal:[n,r,a,s,o,l],ordinal:[l]},ars:{cardinal:[n,r,a,s,o,l],ordinal:[l]},as:{cardinal:[r,l],ordinal:[r,a,s,o,l]},asa:h,ast:h,az:{cardinal:[r,l],ordinal:[r,s,o,l]},be:{cardinal:[r,s,o,l],ordinal:[s,l]},bem:h,bez:h,bg:h,bho:h,bm:c,bn:{cardinal:[r,l],ordinal:[r,a,s,o,l]},bo:c,br:{cardinal:[r,a,s,o,l],ordinal:[l]},brx:h,bs:{cardinal:[r,s,l],ordinal:[l]},ca:{cardinal:[r,l],ordinal:[r,a,s,l]},ce:h,ceb:h,cgg:h,chr:h,ckb:h,cs:u,cy:{cardinal:[n,r,a,s,o,l],ordinal:[n,r,a,s,o,l]},da:h,de:h,doi:h,dsb:{cardinal:[r,a,s,l],ordinal:[l]},dv:h,dz:c,ee:h,el:h,en:{cardinal:[r,l],ordinal:[r,a,s,l]},eo:h,es:h,et:h,eu:h,fa:h,ff:h,fi:h,fil:d,fo:h,fr:{cardinal:[r,o,l],ordinal:[r,l]},fur:h,fy:h,ga:{cardinal:[r,a,s,o,l],ordinal:[r,l]},gd:{cardinal:[r,a,s,l],ordinal:[r,a,s,l]},gl:h,gsw:h,gu:{cardinal:[r,l],ordinal:[r,a,s,o,l]},guw:h,gv:{cardinal:[r,a,s,o,l],ordinal:[l]},ha:h,haw:h,he:{cardinal:[r,a,o,l],ordinal:[l]},hi:{cardinal:[r,l],ordinal:[r,a,s,o,l]},hr:{cardinal:[r,s,l],ordinal:[l]},hsb:{cardinal:[r,a,s,l],ordinal:[l]},hu:d,hy:d,ia:h,id:c,ig:c,ii:c,io:h,is:h,it:{cardinal:[r,l],ordinal:[o,l]},iu:p,iw:{cardinal:[r,a,o,l],ordinal:[l]},ja:c,jbo:c,jgo:h,ji:h,jmc:h,jv:c,jw:c,ka:{cardinal:[r,l],ordinal:[r,o,l]},kab:h,kaj:h,kcg:h,kde:c,kea:c,kk:{cardinal:[r,l],ordinal:[o,l]},kkj:h,kl:h,km:c,kn:h,ko:c,ks:h,ksb:h,ksh:{cardinal:[n,r,l],ordinal:[l]},ku:h,kw:{cardinal:[n,r,a,s,o,l],ordinal:[r,o,l]},ky:h,lag:{cardinal:[n,r,l],ordinal:[l]},lb:h,lg:h,lij:{cardinal:[r,l],ordinal:[o,l]},lkt:c,ln:h,lo:{cardinal:[l],ordinal:[r,l]},lt:u,lv:{cardinal:[n,r,l],ordinal:[l]},mas:h,mg:h,mgo:h,mk:{cardinal:[r,l],ordinal:[r,a,o,l]},ml:h,mn:h,mo:{cardinal:[r,s,l],ordinal:[r,l]},mr:{cardinal:[r,l],ordinal:[r,a,s,l]},ms:{cardinal:[l],ordinal:[r,l]},mt:u,my:c,nah:h,naq:p,nb:h,nd:h,ne:d,nl:h,nn:h,nnh:h,no:h,nqo:c,nr:h,nso:h,ny:h,nyn:h,om:h,or:{cardinal:[r,l],ordinal:[r,a,s,o,l]},os:h,osa:c,pa:h,pap:h,pcm:h,pl:u,prg:{cardinal:[n,r,l],ordinal:[l]},ps:h,pt:h,pt_PT:h,rm:h,ro:{cardinal:[r,s,l],ordinal:[r,l]},rof:h,root:c,ru:u,rwk:h,sah:c,saq:h,sat:p,sc:{cardinal:[r,l],ordinal:[o,l]},scn:{cardinal:[r,l],ordinal:[o,l]},sd:h,sdh:h,se:p,seh:h,ses:c,sg:c,sh:{cardinal:[r,s,l],ordinal:[l]},shi:{cardinal:[r,s,l],ordinal:[l]},si:h,sk:u,sl:{cardinal:[r,a,s,l],ordinal:[l]},sma:p,smi:p,smj:p,smn:p,sms:p,sn:h,so:h,sq:{cardinal:[r,l],ordinal:[r,o,l]},sr:{cardinal:[r,s,l],ordinal:[l]},ss:h,ssy:h,st:h,su:c,sv:d,sw:h,syr:h,ta:h,te:h,teo:h,th:c,ti:h,tig:h,tk:{cardinal:[r,l],ordinal:[s,l]},tl:d,tn:h,to:c,tr:h,ts:h,tzm:h,ug:h,uk:{cardinal:[r,s,o,l],ordinal:[s,l]},ur:h,uz:h,ve:h,vi:{cardinal:[l],ordinal:[r,l]},vo:h,vun:h,wa:h,wae:h,wo:c,xh:h,xog:h,yi:h,yo:c,yue:c,zh:c,zu:h},Object.defineProperty(i,"__esModule",{value:!0}),e.exports=i}(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})),XG=Q((e=>{"use strict";var t,i,n=(t=qG())&&"object"==typeof t&&"default"in t?t:{default:t};"undefined"==typeof Intl?("undefined"!=typeof global?global.Intl={PluralRules:n.default}:"undefined"!=typeof window?window.Intl={PluralRules:n.default}:e.Intl={PluralRules:n.default},n.default.polyfill=!0):Intl.PluralRules?(i=["en","es","ru","zh"],Intl.PluralRules.supportedLocalesOf(i).length<i.length&&(Intl.PluralRules=n.default,n.default.polyfill=!0)):(Intl.PluralRules=n.default,n.default.polyfill=!0)})),In=Q(((e,t)=>{var i=function(e){return e&&e.Math==Math&&e};t.exports=i("object"==typeof globalThis&&globalThis)||i("object"==typeof window&&window)||i("object"==typeof self&&self)||i("object"==typeof global&&global)||function(){return this}()||Function("return this")()})),Yt=Q(((e,t)=>{t.exports=function(e){try{return!!e()}catch(e){return!0}}})),rr=Q(((e,t)=>{var i=Yt();t.exports=!i((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]}))})),Pg=Q(((e,t)=>{var i=Yt();t.exports=!i((function(){var e=function(){}.bind();return"function"!=typeof e||e.hasOwnProperty("prototype")}))})),wr=Q(((e,t)=>{var i=Pg(),n=Function.prototype.call;t.exports=i?n.bind(n):function(){return n.apply(n,arguments)}})),x1=Q((e=>{"use strict";var t={}.propertyIsEnumerable,i=Object.getOwnPropertyDescriptor,n=i&&!t.call({1:2},1);e.f=n?function(e){var t=i(this,e);return!!t&&t.enumerable}:t})),Oo=Q(((e,t)=>{t.exports=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}}})),sn=Q(((e,t)=>{var i=Pg(),n=Function.prototype,r=n.call,a=i&&n.bind.bind(r,r);t.exports=i?a:function(e){return function(){return r.apply(e,arguments)}}})),Ra=Q(((e,t)=>{var i=sn(),n=i({}.toString),r=i("".slice);t.exports=function(e){return r(n(e),8,-1)}})),Mp=Q(((e,t)=>{var i=sn(),n=Yt(),r=Ra(),a=Object,s=i("".split);t.exports=n((function(){return!a("z").propertyIsEnumerable(0)}))?function(e){return"String"==r(e)?s(e,""):a(e)}:a})),Aa=Q(((e,t)=>{t.exports=function(e){return null==e}})),xs=Q(((e,t)=>{var i=Aa(),n=TypeError;t.exports=function(e){if(i(e))throw n("Can't call method on "+e);return e}})),Ca=Q(((e,t)=>{var i=Mp(),n=xs();t.exports=function(e){return i(n(e))}})),p3=Q(((e,t)=>{var i="object"==typeof document&&document.all,n=void 0===i&&void 0!==i;t.exports={all:i,IS_HTMLDDA:n}})),Vr=Q(((e,t)=>{var i=p3(),n=i.all;t.exports=i.IS_HTMLDDA?function(e){return"function"==typeof e||e===n}:function(e){return"function"==typeof e}})),Cr=Q(((e,t)=>{var i=Vr(),n=p3(),r=n.all;t.exports=n.IS_HTMLDDA?function(e){return"object"==typeof e?null!==e:i(e)||e===r}:function(e){return"object"==typeof e?null!==e:i(e)}})),qi=Q(((e,t)=>{var i=In(),n=Vr();t.exports=function(e,t){return arguments.length<2?function(e){return n(e)?e:void 0}(i[e]):i[e]&&i[e][t]}})),ko=Q(((e,t)=>{var i=sn();t.exports=i({}.isPrototypeOf)})),ru=Q(((e,t)=>{t.exports="undefined"!=typeof navigator&&String(navigator.userAgent)||""})),iu=Q(((e,t)=>{var i,n,r=In(),a=ru(),s=r.process,o=r.Deno,l=s&&s.versions||o&&o.version,h=l&&l.v8;h&&(n=(i=h.split("."))[0]>0&&i[0]<4?1:+(i[0]+i[1])),!n&&a&&(!(i=a.match(/Edge\/(\d+)/))||i[1]>=74)&&(i=a.match(/Chrome\/(\d+)/))&&(n=+i[1]),t.exports=n})),Rp=Q(((e,t)=>{var i=iu(),n=Yt();t.exports=!!Object.getOwnPropertySymbols&&!n((function(){var e=Symbol();return!String(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&i&&i<41}))})),v3=Q(((e,t)=>{var i=Rp();t.exports=i&&!Symbol.sham&&"symbol"==typeof Symbol.iterator})),Od=Q(((e,t)=>{var i=qi(),n=Vr(),r=ko(),a=v3(),s=Object;t.exports=a?function(e){return"symbol"==typeof e}:function(e){var t=i("Symbol");return n(t)&&r(t.prototype,s(e))}})),kd=Q(((e,t)=>{var i=String;t.exports=function(e){try{return i(e)}catch(e){return"Object"}}})),Ps=Q(((e,t)=>{var i=Vr(),n=kd(),r=TypeError;t.exports=function(e){if(i(e))return e;throw r(n(e)+" is not a function")}})),su=Q(((e,t)=>{var i=Ps(),n=Aa();t.exports=function(e,t){var r=e[t];return n(r)?void 0:i(r)}})),E3=Q(((e,t)=>{var i=wr(),n=Vr(),r=Cr(),a=TypeError;t.exports=function(e,t){var s,o;if("string"===t&&n(s=e.toString)&&!r(o=i(s,e))||n(s=e.valueOf)&&!r(o=i(s,e))||"string"!==t&&n(s=e.toString)&&!r(o=i(s,e)))return o;throw a("Can't convert object to primitive value")}})),ss=Q(((e,t)=>{t.exports=!1})),$T=Q(((e,t)=>{var i=In(),n=Object.defineProperty;t.exports=function(e,t){try{n(i,e,{value:t,configurable:!0,writable:!0})}catch(n){i[e]=t}return t}})),ZT=Q(((e,t)=>{var i=In(),n=$T(),r="__core-js_shared__",a=i[r]||n(r,{});t.exports=a})),Ap=Q(((e,t)=>{var i=ss(),n=ZT();(t.exports=function(e,t){return n[e]||(n[e]=void 0!==t?t:{})})("versions",[]).push({version:"3.27.2",mode:i?"pure":"global",copyright:"\xa9 2014-2023 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.27.2/LICENSE",source:"https://github.com/zloirock/core-js"})})),ci=Q(((e,t)=>{var i=xs(),n=Object;t.exports=function(e){return n(i(e))}})),Yr=Q(((e,t)=>{var i=sn(),n=ci(),r=i({}.hasOwnProperty);t.exports=Object.hasOwn||function(e,t){return r(n(e),t)}})),Cp=Q(((e,t)=>{var i=sn(),n=0,r=Math.random(),a=i(1..toString);t.exports=function(e){return"Symbol("+(void 0===e?"":e)+")_"+a(++n+r,36)}})),kr=Q(((e,t)=>{var i=In(),n=Ap(),r=Yr(),a=Cp(),s=Rp(),o=v3(),l=i.Symbol,h=n("wks"),c=o?l.for||l:l&&l.withoutSetter||a;t.exports=function(e){return r(h,e)||(h[e]=s&&r(l,e)?l[e]:c("Symbol."+e)),h[e]}})),b1=Q(((e,t)=>{var i=wr(),n=Cr(),r=Od(),a=su(),s=E3(),o=kr(),l=TypeError,h=o("toPrimitive");t.exports=function(e,t){if(!n(e)||r(e))return e;var o,c=a(e,h);if(c){if(void 0===t&&(t="default"),o=i(c,e,t),!n(o)||r(o))return o;throw l("Can't convert object to primitive value")}return void 0===t&&(t="number"),s(e,t)}})),gh=Q(((e,t)=>{var i=b1(),n=Od();t.exports=function(e){var t=i(e,"string");return n(t)?t:t+""}})),E1=Q(((e,t)=>{var i=In(),n=Cr(),r=i.document,a=n(r)&&n(r.createElement);t.exports=function(e){return a?r.createElement(e):{}}})),w3=Q(((e,t)=>{var i=rr(),n=Yt(),r=E1();t.exports=!i&&!n((function(){return 7!=Object.defineProperty(r("div"),"a",{get:function(){return 7}}).a}))})),Ks=Q((e=>{var t=rr(),i=wr(),n=x1(),r=Oo(),a=Ca(),s=gh(),o=Yr(),l=w3(),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(!i(n.f,e,t),e[t])}})),S3=Q(((e,t)=>{var i=rr(),n=Yt();t.exports=i&&n((function(){return 42!=Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype}))})),br=Q(((e,t)=>{var i=Cr(),n=String,r=TypeError;t.exports=function(e){if(i(e))return e;throw r(n(e)+" is not an object")}})),fi=Q((e=>{var t=rr(),i=w3(),n=S3(),r=br(),a=gh(),s=TypeError,o=Object.defineProperty,l=Object.getOwnPropertyDescriptor,h="enumerable",c="configurable",u="writable";e.f=t?n?function(e,t,i){if(r(e),t=a(t),r(i),"function"==typeof e&&"prototype"===t&&"value"in i&&u in i&&!i[u]){var n=l(e,t);n&&n[u]&&(e[t]=i.value,i={configurable:c in i?i[c]:n[c],enumerable:h in i?i[h]:n[h],writable:!1})}return o(e,t,i)}:o:function(e,t,n){if(r(e),t=a(t),r(n),i)try{return o(e,t,n)}catch(e){}if("get"in n||"set"in n)throw s("Accessors not supported");return"value"in n&&(e[t]=n.value),e}})),ca=Q(((e,t)=>{var i=rr(),n=fi(),r=Oo();t.exports=i?function(e,t,i){return n.f(e,t,r(1,i))}:function(e,t,i){return e[t]=i,e}})),Pp=Q(((e,t)=>{var i=rr(),n=Yr(),r=Function.prototype,a=i&&Object.getOwnPropertyDescriptor,s=n(r,"name"),o=s&&"something"===function(){}.name,l=s&&(!i||i&&a(r,"name").configurable);t.exports={EXISTS:s,PROPER:o,CONFIGURABLE:l}})),JT=Q(((e,t)=>{var i=sn(),n=Vr(),r=ZT(),a=i(Function.toString);n(r.inspectSource)||(r.inspectSource=function(e){return a(e)}),t.exports=r.inspectSource})),D3=Q(((e,t)=>{var i=In(),n=Vr(),r=i.WeakMap;t.exports=n(r)&&/native code/.test(String(r))})),_1=Q(((e,t)=>{var i=Ap(),n=Cp(),r=i("keys");t.exports=function(e){return r[e]||(r[e]=n(e))}})),Lg=Q(((e,t)=>{t.exports={}})),bs=Q(((e,t)=>{var i,n,r,a,s,o=D3(),l=In(),h=Cr(),c=ca(),u=Yr(),d=ZT(),p=_1(),f=Lg(),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,i=function(e,t){if(a.has(e))throw g(m);return t.facade=e,a.set(e,t),t},n=function(e){return a.get(e)||{}},r=function(e){return a.has(e)}):(f[s=p("state")]=!0,i=function(e,t){if(u(e,s))throw g(m);return t.facade=e,c(e,s,t),t},n=function(e){return u(e,s)?e[s]:{}},r=function(e){return u(e,s)}),t.exports={set:i,get:n,has:r,enforce:function(e){return r(e)?n(e):i(e,{})},getterFor:function(e){return function(t){var i;if(!h(t)||(i=n(t)).type!==e)throw g("Incompatible receiver, "+e+" required");return i}}}})),rw=Q(((e,t)=>{var i=sn(),n=Yt(),r=Vr(),a=Yr(),s=rr(),o=Pp().CONFIGURABLE,l=JT(),h=bs(),c=h.enforce,u=h.get,d=String,p=Object.defineProperty,f=i("".slice),m=i("".replace),g=i([].join),v=s&&!n((function(){return 8!==p((function(){}),"length",{value:8}).length})),y=String(String).split("String"),x=t.exports=function(e,t,i){"Symbol("===f(d(t),0,7)&&(t="["+m(d(t),/^Symbol\(([^)]*)\)/,"$1")+"]"),i&&i.getter&&(t="get "+t),i&&i.setter&&(t="set "+t),(!a(e,"name")||o&&e.name!==t)&&(s?p(e,"name",{value:t,configurable:!0}):e.name=t),v&&i&&a(i,"arity")&&e.length!==i.arity&&p(e,"length",{value:i.arity});try{i&&a(i,"constructor")&&i.constructor?s&&p(e,"prototype",{writable:!1}):e.prototype&&(e.prototype=void 0)}catch(e){}var n=c(e);return a(n,"source")||(n.source=g(y,"string"==typeof t?t:"")),e};Function.prototype.toString=x((function(){return r(this)&&u(this).source||l(this)}),"toString")})),$i=Q(((e,t)=>{var i=Vr(),n=fi(),r=rw(),a=$T();t.exports=function(e,t,s,o){o||(o={});var l=o.enumerable,h=void 0!==o.name?o.name:t;if(i(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:n.f(e,t,{value:s,enumerable:!1,configurable:!o.nonConfigurable,writable:!o.nonWritable})}return e}})),U3=Q(((e,t)=>{var i=Math.ceil,n=Math.floor;t.exports=Math.trunc||function(e){var t=+e;return(t>0?n:i)(t)}})),Is=Q(((e,t)=>{var i=U3();t.exports=function(e){var t=+e;return t!=t||0===t?0:i(t)}})),au=Q(((e,t)=>{var i=Is(),n=Math.max,r=Math.min;t.exports=function(e,t){var a=i(e);return a<0?n(a+t,0):r(a,t)}})),Qa=Q(((e,t)=>{var i=Is(),n=Math.min;t.exports=function(e){return e>0?n(i(e),9007199254740991):0}})),wi=Q(((e,t)=>{var i=Qa();t.exports=function(e){return i(e.length)}})),Dg=Q(((e,t)=>{var i=Ca(),n=au(),r=wi(),a=function(e){return function(t,a,s){var o,l=i(t),h=r(l),c=n(s,h);if(e&&a!=a){for(;h>c;)if((o=l[c++])!=o)return!0}else for(;h>c;c++)if((e||c in l)&&l[c]===a)return e||c||0;return!e&&-1}};t.exports={includes:a(!0),indexOf:a(!1)}})),V3=Q(((e,t)=>{var i=sn(),n=Yr(),r=Ca(),a=Dg().indexOf,s=Lg(),o=i([].push);t.exports=function(e,t){var i,l=r(e),h=0,c=[];for(i in l)!n(s,i)&&n(l,i)&&o(c,i);for(;t.length>h;)n(l,i=t[h++])&&(~a(c,i)||o(c,i));return c}})),iw=Q(((e,t)=>{t.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]})),vh=Q((e=>{var t=V3(),i=iw().concat("length","prototype");e.f=Object.getOwnPropertyNames||function(e){return t(e,i)}})),w1=Q((e=>{e.f=Object.getOwnPropertySymbols})),sw=Q(((e,t)=>{var i=qi(),n=sn(),r=vh(),a=w1(),s=br(),o=n([].concat);t.exports=i("Reflect","ownKeys")||function(e){var t=r.f(s(e)),i=a.f;return i?o(t,i(e)):t}})),S1=Q(((e,t)=>{var i=Yr(),n=sw(),r=Ks(),a=fi();t.exports=function(e,t,s){for(var o=n(t),l=a.f,h=r.f,c=0;c<o.length;c++){var u=o[c];!i(e,u)&&(!s||!i(s,u))&&l(e,u,h(t,u))}}})),Og=Q(((e,t)=>{var i=Yt(),n=Vr(),r=/#|\.prototype\./,a=function(e,t){var r=o[s(e)];return r==h||r!=l&&(n(t)?i(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})),rt=Q(((e,t)=>{var i=In(),n=Ks().f,r=ca(),a=$i(),s=$T(),o=S1(),l=Og();t.exports=function(e,t){var h,c,u,d,p,f=e.target,m=e.global,g=e.stat;if(h=m?i:g?i[f]||s(f,{}):(i[f]||{}).prototype)for(c in t){if(d=t[c],u=e.dontCallGetSet?(p=n(h,c))&&p.value:h[c],!l(m?c:f+(g?".":"#")+c,e.forced)&&void 0!==u){if(typeof d==typeof u)continue;o(d,u)}(e.sham||u&&u.sham)&&r(d,"sham",!0),a(h,c,d,e)}}})),aw=Q(((e,t)=>{var i={};i[kr()("toStringTag")]="z",t.exports="[object z]"===String(i)})),oc=Q(((e,t)=>{var i=aw(),n=Vr(),r=Ra(),a=kr()("toStringTag"),s=Object,o="Arguments"==r(function(){return arguments}());t.exports=i?r:function(e){var t,i,l;return void 0===e?"Undefined":null===e?"Null":"string"==typeof(i=function(e,t){try{return e[t]}catch(e){}}(t=s(e),a))?i:o?r(t):"Object"==(l=r(t))&&n(t.callee)?"Arguments":l}})),Fr=Q(((e,t)=>{var i=oc(),n=String;t.exports=function(e){if("Symbol"===i(e))throw TypeError("Cannot convert a Symbol value to a string");return n(e)}})),kg=Q(((e,t)=>{var i=V3(),n=iw();t.exports=Object.keys||function(e){return i(e,n)}})),lw=Q((e=>{var t=rr(),i=S3(),n=fi(),r=br(),a=Ca(),s=kg();e.f=t&&!i?Object.defineProperties:function(e,t){r(e);for(var i,o=a(t),l=s(t),h=l.length,c=0;h>c;)n.f(e,i=l[c++],o[i]);return e}})),G3=Q(((e,t)=>{var i=qi();t.exports=i("document","documentElement")})),eo=Q(((e,t)=>{var i,n=br(),r=lw(),a=iw(),s=Lg(),o=G3(),l=E1(),h=_1(),c="prototype",u="script",d=h("IE_PROTO"),p=function(){},f=function(e){return"<"+u+">"+e+"</"+u+">"},m=function(e){e.write(f("")),e.close();var t=e.parentWindow.Object;return e=null,t},g=function(){try{i=new ActiveXObject("htmlfile")}catch(e){}g="undefined"!=typeof document?document.domain&&i?m(i):function(){var e,t=l("iframe"),i="java"+u+":";return t.style.display="none",o.appendChild(t),t.src=String(i),(e=t.contentWindow.document).open(),e.write(f("document.F=Object")),e.close(),e.F}():m(i);for(var e=a.length;e--;)delete g[c][a[e]];return g()};s[d]=!0,t.exports=Object.create||function(e,t){var i;return null!==e?(p[c]=n(e),i=new p,p[c]=null,i[d]=e):i=g(),void 0===t?i:r.f(i,t)}})),ou=Q(((e,t)=>{"use strict";var i=gh(),n=fi(),r=Oo();t.exports=function(e,t,a){var s=i(t);s in e?n.f(e,s,r(0,a)):e[s]=a}})),Fg=Q(((e,t)=>{var i=au(),n=wi(),r=ou(),a=Array,s=Math.max;t.exports=function(e,t,o){for(var l=n(e),h=i(t,l),c=i(void 0===o?l:o,l),u=a(s(c-h,0)),d=0;h<c;h++,d++)r(u,d,e[h]);return u.length=d,u}})),hw=Q(((e,t)=>{var i=Ra(),n=Ca(),r=vh().f,a=Fg(),s="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[];t.exports.f=function(e){return s&&"Window"==i(e)?function(e){try{return r(e)}catch(e){return a(s)}}(e):r(n(e))}})),X3=Q((e=>{var t=kr();e.f=t})),dw=Q(((e,t)=>{var i=In();t.exports=i})),Pa=Q(((e,t)=>{var i=dw(),n=Yr(),r=X3(),a=fi().f;t.exports=function(e){var t=i.Symbol||(i.Symbol={});n(t,e)||a(t,e,{value:r.f(e)})}})),Y3=Q(((e,t)=>{var i=wr(),n=qi(),r=kr(),a=$i();t.exports=function(){var e=n("Symbol"),t=e&&e.prototype,s=t&&t.valueOf,o=r("toPrimitive");t&&!t[o]&&a(t,o,(function(e){return i(s,this)}),{arity:1})}})),to=Q(((e,t)=>{var i=fi().f,n=Yr(),r=kr()("toStringTag");t.exports=function(e,t,a){e&&!a&&(e=e.prototype),e&&!n(e,r)&&i(e,r,{configurable:!0,value:t})}})),yh=Q(((e,t)=>{var i=Ra(),n=sn();t.exports=function(e){if("Function"===i(e))return n(e)}})),dl=Q(((e,t)=>{var i=yh(),n=Ps(),r=Pg(),a=i(i.bind);t.exports=function(e,t){return n(e),void 0===t?e:r?a(e,t):function(){return e.apply(t,arguments)}}})),xh=Q(((e,t)=>{var i=Ra();t.exports=Array.isArray||function(e){return"Array"==i(e)}})),Lp=Q(((e,t)=>{var i=sn(),n=Yt(),r=Vr(),a=oc(),s=qi(),o=JT(),l=function(){},h=[],c=s("Reflect","construct"),u=/^\s*(?:class|function)\b/,d=i(u.exec),p=!u.exec(l),f=function(e){if(!r(e))return!1;try{return c(l,h,e),!0}catch(e){return!1}},m=function(e){if(!r(e))return!1;switch(a(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return p||!!d(u,o(e))}catch(e){return!0}};m.sham=!0,t.exports=!c||n((function(){var e;return f(f.call)||!f(Object)||!f((function(){e=!0}))||e}))?m:f})),wq=Q(((e,t)=>{var i=xh(),n=Lp(),r=Cr(),a=kr()("species"),s=Array;t.exports=function(e){var t;return i(e)&&(t=e.constructor,(n(t)&&(t===s||i(t.prototype))||r(t)&&null===(t=t[a]))&&(t=void 0)),void 0===t?s:t}})),Ng=Q(((e,t)=>{var i=wq();t.exports=function(e,t){return new(i(e))(0===t?0:t)}})),Us=Q(((e,t)=>{var i=dl(),n=sn(),r=Mp(),a=ci(),s=wi(),o=Ng(),l=n([].push),h=function(e){var t=1==e,n=2==e,h=3==e,c=4==e,u=6==e,d=7==e,p=5==e||u;return function(f,m,g,v){for(var y,x,b=a(f),_=r(b),w=i(m,g),S=s(_),M=0,E=v||o,T=t?E(f,S):n||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 u?-1:h||c?c:T}};t.exports={forEach:h(0),map:h(1),filter:h(2),some:h(3),every:h(4),find:h(5),findIndex:h(6),filterReject:h(7)}})),Gq=Q((()=>{"use strict";var e=rt(),t=In(),i=wr(),n=sn(),r=ss(),a=rr(),s=Rp(),o=Yt(),l=Yr(),h=ko(),c=br(),u=Ca(),d=gh(),p=Fr(),f=Oo(),m=eo(),g=kg(),v=vh(),y=hw(),x=w1(),b=Ks(),_=fi(),w=lw(),S=x1(),M=$i(),E=Ap(),T=_1(),A=Lg(),C=Cp(),P=kr(),R=X3(),D=Pa(),L=Y3(),I=to(),O=bs(),k=Us().forEach,N=T("hidden"),U="Symbol",F="prototype",B=O.set,z=O.getterFor(U),H=Object[F],V=t.Symbol,j=V&&V[F],G=t.TypeError,W=t.QObject,X=b.f,Y=_.f,q=y.f,Z=S.f,Q=n([].push),J=E("symbols"),K=E("op-symbols"),$=E("wks"),ee=!W||!W[F]||!W[F].findChild,te=a&&o((function(){return 7!=m(Y({},"a",{get:function(){return Y(this,"a",{value:7}).a}})).a}))?function(e,t,i){var n=X(H,t);n&&delete H[t],Y(e,t,i),n&&e!==H&&Y(H,t,n)}:Y,ie=function(e,t){var i=J[e]=m(j);return B(i,{type:U,tag:e,description:t}),a||(i.description=t),i},ne=function(e,t,i){e===H&&ne(K,t,i),c(e);var n=d(t);return c(i),l(J,n)?(i.enumerable?(l(e,N)&&e[N][n]&&(e[N][n]=!1),i=m(i,{enumerable:f(0,!1)})):(l(e,N)||Y(e,N,f(1,{})),e[N][n]=!0),te(e,n,i)):Y(e,n,i)},re=function(e,t){c(e);var n=u(t),r=g(n).concat(le(n));return k(r,(function(t){(!a||i(ae,n,t))&&ne(e,t,n[t])})),e},ae=function(e){var t=d(e),n=i(Z,this,t);return!(this===H&&l(J,t)&&!l(K,t))&&(!(n||!l(this,t)||!l(J,t)||l(this,N)&&this[N][t])||n)},se=function(e,t){var i=u(e),n=d(t);if(i!==H||!l(J,n)||l(K,n)){var r=X(i,n);return r&&l(J,n)&&!(l(i,N)&&i[N][n])&&(r.enumerable=!0),r}},oe=function(e){var t=q(u(e)),i=[];return k(t,(function(e){!l(J,e)&&!l(A,e)&&Q(i,e)})),i},le=function(e){var t=e===H,i=q(t?K:u(e)),n=[];return k(i,(function(e){l(J,e)&&(!t||l(H,e))&&Q(n,J[e])})),n};s||(M(j=(V=function(){if(h(j,this))throw G("Symbol is not a constructor");var e=arguments.length&&void 0!==arguments[0]?p(arguments[0]):void 0,t=C(e),n=function(e){this===H&&i(n,K,e),l(this,N)&&l(this[N],t)&&(this[N][t]=!1),te(this,t,f(1,e))};return a&&ee&&te(H,t,{configurable:!0,set:n}),ie(t,e)})[F],"toString",(function(){return z(this).tag})),M(V,"withoutSetter",(function(e){return ie(C(e),e)})),S.f=ae,_.f=ne,w.f=re,b.f=se,v.f=y.f=oe,x.f=le,R.f=function(e){return ie(P(e),e)},a&&(Y(j,"description",{configurable:!0,get:function(){return z(this).description}}),r||M(H,"propertyIsEnumerable",ae,{unsafe:!0}))),e({global:!0,constructor:!0,wrap:!0,forced:!s,sham:!s},{Symbol:V}),k(g($),(function(e){D(e)})),e({target:U,stat:!0,forced:!s},{useSetter:function(){ee=!0},useSimple:function(){ee=!1}}),e({target:"Object",stat:!0,forced:!s,sham:!a},{create:function(e,t){return void 0===t?m(e):re(m(e),t)},defineProperty:ne,defineProperties:re,getOwnPropertyDescriptor:se}),e({target:"Object",stat:!0,forced:!s},{getOwnPropertyNames:oe}),L(),I(V,U),A[N]=!0})),cL=Q(((e,t)=>{var i=Rp();t.exports=i&&!!Symbol.for&&!!Symbol.keyFor})),jq=Q((()=>{var e=rt(),t=qi(),i=Yr(),n=Fr(),r=Ap(),a=cL(),s=r("string-to-symbol-registry"),o=r("symbol-to-string-registry");e({target:"Symbol",stat:!0,forced:!a},{for:function(e){var r=n(e);if(i(s,r))return s[r];var a=t("Symbol")(r);return s[r]=a,o[a]=r,a}})})),Yq=Q((()=>{var e=rt(),t=Yr(),i=Od(),n=kd(),r=Ap(),a=cL(),s=r("symbol-to-string-registry");e({target:"Symbol",stat:!0,forced:!a},{keyFor:function(e){if(!i(e))throw TypeError(n(e)+" is not a symbol");if(t(s,e))return s[e]}})})),Fo=Q(((e,t)=>{var i=Pg(),n=Function.prototype,r=n.apply,a=n.call;t.exports="object"==typeof Reflect&&Reflect.apply||(i?a.bind(r):function(){return a.apply(r,arguments)})})),Bd=Q(((e,t)=>{var i=sn();t.exports=i([].slice)})),hL=Q((()=>{var e=rt(),t=qi(),i=Fo(),n=wr(),r=sn(),a=Yt(),s=xh(),o=Vr(),l=Cr(),h=Od(),c=Bd(),u=Rp(),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=c(arguments),a=t;if((l(t)||void 0!==e)&&!h(e))return s(t)||(t=function(e,t){if(o(a)&&(t=n(a,this,e,t)),!h(t))return t}),r[1]=t,i(d,null,r)},M=function(e,t,i){var n=f(i,t-1),r=f(i,t+1);return p(x,e)&&!p(b,r)||p(b,e)&&!p(x,n)?"\\u"+v(m(e,0),16):e};d&&e({target:"JSON",stat:!0,arity:3,forced:_||w},{stringify:function(e,t,n){var r=c(arguments),a=i(_?S:d,null,r);return w&&"string"==typeof a?g(a,y,M):a}})})),hW=Q((()=>{var e=rt(),t=Rp(),i=Yt(),n=w1(),r=ci();e({target:"Object",stat:!0,forced:!t||i((function(){n.f(1)}))},{getOwnPropertySymbols:function(e){var t=n.f;return t?t(r(e)):[]}})})),dW=Q((()=>{Gq(),jq(),Yq(),hL(),hW()})),xW=Q((()=>{"use strict";var e,t,i,n,r,a,s,o,l=rt(),h=rr(),c=In(),u=sn(),d=Yr(),p=Vr(),f=ko(),m=Fr(),g=fi().f,v=S1(),y=c.Symbol,x=y&&y.prototype;h&&p(y)&&(!("description"in x)||void 0!==y().description)&&(e={},v(t=function(){var t=arguments.length<1||void 0===arguments[0]?void 0:m(arguments[0]),i=f(x,this)?new y(t):void 0===t?y():y(t);return""===t&&(e[i]=!0),i},y),t.prototype=x,x.constructor=t,i="Symbol(test)"==String(y("test")),n=u(x.valueOf),r=u(x.toString),a=/^Symbol\((.*)\)[^)]+$/,s=u("".replace),o=u("".slice),g(x,"description",{configurable:!0,get:function(){var t=n(this);if(d(e,t))return"";var l=r(t),h=i?o(l,7,-1):s(l,a,"$1");return""===h?void 0:h}}),l({global:!0,constructor:!0,forced:!0},{Symbol:t}))})),bW=Q((()=>{Pa()("asyncIterator")})),EW=Q((()=>{Pa()("hasInstance")})),_W=Q((()=>{Pa()("isConcatSpreadable")})),TW=Q((()=>{Pa()("iterator")})),wW=Q((()=>{Pa()("match")})),SW=Q((()=>{Pa()("matchAll")})),MW=Q((()=>{Pa()("replace")})),RW=Q((()=>{Pa()("search")})),AW=Q((()=>{Pa()("species")})),CW=Q((()=>{Pa()("split")})),PW=Q((()=>{var e=Pa(),t=Y3();e("toPrimitive"),t()})),IW=Q((()=>{var e=qi(),t=Pa(),i=to();t("toStringTag"),i(e("Symbol"),"Symbol")})),LW=Q((()=>{Pa()("unscopables")})),fL=Q(((e,t)=>{var i=Vr(),n=String,r=TypeError;t.exports=function(e){if("object"==typeof e||i(e))return e;throw r("Can't set "+n(e)+" as a prototype")}})),lc=Q(((e,t)=>{var i=sn(),n=br(),r=fL();t.exports=Object.setPrototypeOf||("__proto__"in{}?function(){var e,t=!1,a={};try{(e=i(Object.getOwnPropertyDescriptor(Object.prototype,"__proto__").set))(a,[]),t=a instanceof Array}catch(e){}return function(i,a){return n(i),r(a),t?e(i,a):i.__proto__=a,i}}():void 0)})),pL=Q(((e,t)=>{var i=fi().f;t.exports=function(e,t,n){n in e||i(e,n,{configurable:!0,get:function(){return t[n]},set:function(e){t[n]=e}})}})),kp=Q(((e,t)=>{var i=Vr(),n=Cr(),r=lc();t.exports=function(e,t,a){var s,o;return r&&i(s=t.constructor)&&s!==a&&n(o=s.prototype)&&o!==a.prototype&&r(e,o),e}})),Hg=Q(((e,t)=>{var i=Fr();t.exports=function(e,t){return void 0===e?arguments.length<2?"":t:i(e)}})),mL=Q(((e,t)=>{var i=Cr(),n=ca();t.exports=function(e,t){i(t)&&"cause"in t&&n(e,"cause",t.cause)}})),bw=Q(((e,t)=>{var i=sn(),n=Error,r=i("".replace),a=String(n("zxcasd").stack),s=/\n\s*at [^:]*:[^\n]*/,o=s.test(a);t.exports=function(e,t){if(o&&"string"==typeof e&&!n.prepareStackTrace)for(;t--;)e=r(e,s,"");return e}})),gL=Q(((e,t)=>{var i=Yt(),n=Oo();t.exports=!i((function(){var e=Error("a");return!("stack"in e)||(Object.defineProperty(e,"stack",n(1,7)),7!==e.stack)}))})),vL=Q(((e,t)=>{var i=ca(),n=bw(),r=gL(),a=Error.captureStackTrace;t.exports=function(e,t,s,o){r&&(a?a(e,t):i(e,"stack",n(s,o)))}})),yL=Q(((e,t)=>{"use strict";var i=qi(),n=Yr(),r=ca(),a=ko(),s=lc(),o=S1(),l=pL(),h=kp(),c=Hg(),u=mL(),d=vL(),p=rr(),f=ss();t.exports=function(e,t,m,g){var v="stackTraceLimit",y=g?2:1,x=e.split("."),b=x[x.length-1],_=i.apply(null,x);if(_){var w=_.prototype;if(!f&&n(w,"cause")&&delete w.cause,!m)return _;var S=i("Error"),M=t((function(e,t){var i=c(g?t:e,void 0),n=g?new _(e):new _;return void 0!==i&&r(n,"message",i),d(n,M,n.stack,2),this&&a(w,this)&&h(n,this,M),arguments.length>y&&u(n,arguments[y]),n}));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}}})),nj=Q((()=>{var e=rt(),t=In(),i=Fo(),n=yL(),r="WebAssembly",a=t[r],s=7!==Error("e",{cause:7}).cause,o=function(t,i){var r={};r[t]=n(t,i,s),e({global:!0,constructor:!0,arity:1,forced:s},r)},l=function(t,i){if(a&&a[t]){var o={};o[t]=n(r+"."+t,i,s),e({target:r,stat:!0,constructor:!0,arity:1,forced:s},o)}};o("Error",(function(e){return function(t){return i(e,this,arguments)}})),o("EvalError",(function(e){return function(t){return i(e,this,arguments)}})),o("RangeError",(function(e){return function(t){return i(e,this,arguments)}})),o("ReferenceError",(function(e){return function(t){return i(e,this,arguments)}})),o("SyntaxError",(function(e){return function(t){return i(e,this,arguments)}})),o("TypeError",(function(e){return function(t){return i(e,this,arguments)}})),o("URIError",(function(e){return function(t){return i(e,this,arguments)}})),l("CompileError",(function(e){return function(t){return i(e,this,arguments)}})),l("LinkError",(function(e){return function(t){return i(e,this,arguments)}})),l("RuntimeError",(function(e){return function(t){return i(e,this,arguments)}}))})),EL=Q(((e,t)=>{"use strict";var i=rr(),n=Yt(),r=br(),a=eo(),s=Hg(),o=Error.prototype.toString,l=n((function(){if(i){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"),i=s(e.message);return t?i?t+": "+i:t:i}:o})),oj=Q((()=>{var e=$i(),t=EL(),i=Error.prototype;i.toString!==t&&e(i,"toString",t)})),Tw=Q(((e,t)=>{var i=Yt();t.exports=!i((function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype}))})),No=Q(((e,t)=>{var i=Yr(),n=Vr(),r=ci(),a=_1(),s=Tw(),o=a("IE_PROTO"),l=Object,h=l.prototype;t.exports=s?l.getPrototypeOf:function(e){var t=r(e);if(i(t,o))return t[o];var a=t.constructor;return n(a)&&t instanceof a?a.prototype:t instanceof l?h:null}})),Vg=Q(((e,t)=>{t.exports={}})),ww=Q(((e,t)=>{var i=kr(),n=Vg(),r=i("iterator"),a=Array.prototype;t.exports=function(e){return void 0!==e&&(n.Array===e||a[r]===e)}})),zg=Q(((e,t)=>{var i=oc(),n=su(),r=Aa(),a=Vg(),s=kr()("iterator");t.exports=function(e){if(!r(e))return n(e,s)||n(e,"@@iterator")||a[i(e)]}})),O1=Q(((e,t)=>{var i=wr(),n=Ps(),r=br(),a=kd(),s=zg(),o=TypeError;t.exports=function(e,t){var l=arguments.length<2?s(e):t;if(n(l))return r(i(l,e));throw o(a(e)+" is not iterable")}})),TL=Q(((e,t)=>{var i=wr(),n=br(),r=su();t.exports=function(e,t,a){var s,o;n(e);try{if(!(s=r(e,"return"))){if("throw"===t)throw a;return a}s=i(s,e)}catch(e){o=!0,s=e}if("throw"===t)throw a;if(o)throw s;return n(s),a}})),cc=Q(((e,t)=>{var i=dl(),n=wr(),r=br(),a=kd(),s=ww(),o=wi(),l=ko(),h=O1(),c=zg(),u=TL(),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=i(t,S),P=function(e){return g&&u(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=c(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=n(_,g)).done;){try{b=R(w.value)}catch(e){u(g,"throw",e)}if("object"==typeof b&&b&&l(f,b))return b}return new p(!1)}})),Tj=Q((()=>{"use strict";var e=rt(),t=ko(),i=No(),n=lc(),r=S1(),a=eo(),s=ca(),o=Oo(),l=mL(),h=vL(),c=cc(),u=Hg(),d=kr()("toStringTag"),p=Error,f=[].push,m=function(e,r){var o,v=t(g,this);n?o=n(p(),v?i(this):g):(o=v?this:a(g),s(o,d,"Error")),void 0!==r&&s(o,"message",u(r)),h(o,m,o.stack,1),arguments.length>2&&l(o,arguments[2]);var y=[];return c(e,f,{that:y}),s(o,"errors",y),o};n?n(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})})),wj=Q((()=>{Tj()})),Aj=Q((()=>{var e=rt(),t=qi(),i=Fo(),n=Yt(),r=yL(),a="AggregateError",s=t(a),o=!n((function(){return 1!==s([1]).errors[0]}))&&n((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,n){return i(e,this,arguments)}}),o,!0)})})),pl=Q(((e,t)=>{var i=kr(),n=eo(),r=fi().f,a=i("unscopables"),s=Array.prototype;null==s[a]&&r(s,a,{configurable:!0,value:n(null)}),t.exports=function(e){s[a][e]=!0}})),Pj=Q((()=>{"use strict";var e=rt(),t=ci(),i=wi(),n=Is(),r=pl();e({target:"Array",proto:!0},{at:function(e){var r=t(this),a=i(r),s=n(e),o=s>=0?s:a+s;return o<0||o>=a?void 0:r[o]}}),r("at")})),qg=Q(((e,t)=>{var i=TypeError;t.exports=function(e){if(e>9007199254740991)throw i("Maximum allowed index exceeded");return e}})),Wg=Q(((e,t)=>{var i=Yt(),n=kr(),r=iu(),a=n("species");t.exports=function(e){return r>=51||!i((function(){var t=[];return(t.constructor={})[a]=function(){return{foo:1}},1!==t[e](Boolean).foo}))}})),Fj=Q((()=>{"use strict";var e=rt(),t=Yt(),i=xh(),n=Cr(),r=ci(),a=wi(),s=qg(),o=ou(),l=Ng(),h=Wg(),c=kr(),u=iu(),d=c("isConcatSpreadable"),p=u>=51||!t((function(){var e=[];return e[d]=!1,e.concat()[0]!==e})),f=function(e){if(!n(e))return!1;var t=e[d];return void 0!==t?!!t:i(e)};e({target:"Array",proto:!0,arity:1,forced:!p||!h("concat")},{concat:function(e){var t,i,n,h,c,u=r(this),d=l(u,0),p=0;for(t=-1,n=arguments.length;t<n;t++)if(f(c=-1===t?u:arguments[t]))for(h=a(c),s(p+h),i=0;i<h;i++,p++)i in c&&o(d,p,c[i]);else s(p+1),o(d,p++,c);return d.length=p,d}})})),k1=Q(((e,t)=>{"use strict";var i=kd(),n=TypeError;t.exports=function(e,t){if(!delete e[t])throw n("Cannot delete property "+i(t)+" of "+i(e))}})),IL=Q(((e,t)=>{"use strict";var i=ci(),n=au(),r=wi(),a=k1(),s=Math.min;t.exports=[].copyWithin||function(e,t){var o=i(this),l=r(o),h=n(e,l),c=n(t,l),u=arguments.length>2?arguments[2]:void 0,d=s((void 0===u?l:n(u,l))-c,l-h),p=1;for(c<h&&h<c+d&&(p=-1,c+=d-1,h+=d-1);d-- >0;)c in o?o[h]=o[c]:a(o,h),h+=p,c+=p;return o}})),Hj=Q((()=>{var e=rt(),t=IL(),i=pl();e({target:"Array",proto:!0},{copyWithin:t}),i("copyWithin")})),cu=Q(((e,t)=>{"use strict";var i=Yt();t.exports=function(e,t){var n=[][e];return!!n&&i((function(){n.call(null,t||function(){return 1},1)}))}})),zj=Q((()=>{"use strict";var e=rt(),t=Us().every;e({target:"Array",proto:!0,forced:!cu()("every")},{every:function(e){return t(this,e,arguments.length>1?arguments[1]:void 0)}})})),Aw=Q(((e,t)=>{"use strict";var i=ci(),n=au(),r=wi();t.exports=function(e){for(var t=i(this),a=r(t),s=arguments.length,o=n(s>1?arguments[1]:void 0,a),l=s>2?arguments[2]:void 0,h=void 0===l?a:n(l,a);h>o;)t[o++]=e;return t}})),Wj=Q((()=>{var e=rt(),t=Aw(),i=pl();e({target:"Array",proto:!0},{fill:t}),i("fill")})),jj=Q((()=>{"use strict";var e=rt(),t=Us().filter;e({target:"Array",proto:!0,forced:!Wg()("filter")},{filter:function(e){return t(this,e,arguments.length>1?arguments[1]:void 0)}})})),Yj=Q((()=>{"use strict";var e=rt(),t=Us().find,i=pl(),n="find",r=!0;n in[]&&Array(1)[n]((function(){r=!1})),e({target:"Array",proto:!0,forced:r},{find:function(e){return t(this,e,arguments.length>1?arguments[1]:void 0)}}),i(n)})),Zj=Q((()=>{"use strict";var e=rt(),t=Us().findIndex,i=pl(),n="findIndex",r=!0;n in[]&&Array(1)[n]((function(){r=!1})),e({target:"Array",proto:!0,forced:r},{findIndex:function(e){return t(this,e,arguments.length>1?arguments[1]:void 0)}}),i(n)})),F1=Q(((e,t)=>{var i=dl(),n=Mp(),r=ci(),a=wi(),s=function(e){var t=1==e;return function(s,o,l){for(var h,c=r(s),u=n(c),d=i(o,l),p=a(u);p-- >0;)if(d(h=u[p],p,c))switch(e){case 0:return h;case 1:return p}return t?-1:void 0}};t.exports={findLast:s(0),findLastIndex:s(1)}})),Qj=Q((()=>{"use strict";var e=rt(),t=F1().findLast,i=pl();e({target:"Array",proto:!0},{findLast:function(e){return t(this,e,arguments.length>1?arguments[1]:void 0)}}),i("findLast")})),eX=Q((()=>{"use strict";var e=rt(),t=F1().findLastIndex,i=pl();e({target:"Array",proto:!0},{findLastIndex:function(e){return t(this,e,arguments.length>1?arguments[1]:void 0)}}),i("findLastIndex")})),OL=Q(((e,t)=>{"use strict";var i=xh(),n=wi(),r=qg(),a=dl(),s=function(e,t,o,l,h,c,u,d){for(var p,f,m=h,g=0,v=!!u&&a(u,d);g<l;)g in o&&(p=v?v(o[g],g,t):o[g],c>0&&i(p)?(f=n(p),m=s(e,t,p,f,m,c-1)-1):(r(m+1),e[m]=p),m++),g++;return m};t.exports=s})),rX=Q((()=>{"use strict";var e=rt(),t=OL(),i=ci(),n=wi(),r=Is(),a=Ng();e({target:"Array",proto:!0},{flat:function(){var e=arguments.length?arguments[0]:void 0,s=i(this),o=n(s),l=a(s,0);return l.length=t(l,s,s,o,0,void 0===e?1:r(e)),l}})})),iX=Q((()=>{"use strict";var e=rt(),t=OL(),i=Ps(),n=ci(),r=wi(),a=Ng();e({target:"Array",proto:!0},{flatMap:function(e){var s,o=n(this),l=r(o);return i(e),(s=a(o,0)).length=t(s,o,o,l,0,1,e,arguments.length>1?arguments[1]:void 0),s}})})),kL=Q(((e,t)=>{"use strict";var i=Us().forEach,n=cu()("forEach");t.exports=n?[].forEach:function(e){return i(this,e,arguments.length>1?arguments[1]:void 0)}})),oX=Q((()=>{"use strict";var e=rt(),t=kL();e({target:"Array",proto:!0,forced:[].forEach!=t},{forEach:t})})),cX=Q(((e,t)=>{var i=br(),n=TL();t.exports=function(e,t,r,a){try{return a?t(i(r)[0],r[1]):t(r)}catch(t){n(e,"throw",t)}}})),FL=Q(((e,t)=>{"use strict";var i=dl(),n=wr(),r=ci(),a=cX(),s=ww(),o=Lp(),l=wi(),h=ou(),c=O1(),u=zg(),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=i(m,f>2?arguments[2]:void 0));var v,y,x,b,_,w,S=u(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=c(t,S)).next,y=p?new this:[];!(x=n(_,b)).done;M++)w=g?a(b,m,[x.value,M],!0):x.value,h(y,M,w);return y.length=M,y}})),N1=Q(((e,t)=>{var i,n,r=kr()("iterator"),a=!1;try{i=0,(n={next:function(){return{done:!!i++}},return:function(){a=!0}})[r]=function(){return this},Array.from(n,(function(){throw 2}))}catch(e){}t.exports=function(e,t){if(!t&&!a)return!1;var i=!1;try{var n={};n[r]=function(){return{next:function(){return{done:i=!0}}}},e(n)}catch(e){}return i}})),vX=Q((()=>{var e=rt(),t=FL();e({target:"Array",stat:!0,forced:!N1()((function(e){Array.from(e)}))},{from:t})})),yX=Q((()=>{"use strict";var e=rt(),t=Dg().includes,i=Yt(),n=pl();e({target:"Array",proto:!0,forced:i((function(){return!Array(1).includes()}))},{includes:function(e){return t(this,e,arguments.length>1?arguments[1]:void 0)}}),n("includes")})),bX=Q((()=>{"use strict";var e=rt(),t=yh(),i=Dg().indexOf,n=cu(),r=t([].indexOf),a=!!r&&1/r([1],1,-0)<0;e({target:"Array",proto:!0,forced:a||!n("indexOf")},{indexOf:function(e){var t=arguments.length>1?arguments[1]:void 0;return a?r(this,e,t)||0:i(this,e,t)}})})),EX=Q((()=>{rt()({target:"Array",stat:!0},{isArray:xh()})})),zL=Q(((e,t)=>{"use strict";var i,n,r,a=Yt(),s=Vr(),o=Cr(),l=eo(),h=No(),c=$i(),u=kr(),d=ss(),p=u("iterator"),f=!1;[].keys&&("next"in(r=[].keys())?(n=h(h(r)))!==Object.prototype&&(i=n):f=!0),!o(i)||a((function(){var e={};return i[p].call(e)!==e}))?i={}:d&&(i=l(i)),s(i[p])||c(i,p,(function(){return this})),t.exports={IteratorPrototype:i,BUGGY_SAFARI_ITERATORS:f}})),Cw=Q(((e,t)=>{"use strict";var i=zL().IteratorPrototype,n=eo(),r=Oo(),a=to(),s=Vg(),o=function(){return this};t.exports=function(e,t,l,h){var c=t+" Iterator";return e.prototype=n(i,{next:r(+!h,l)}),a(e,c,!1,!0),s[c]=o,e}})),Lw=Q(((e,t)=>{"use strict";var i=rt(),n=wr(),r=ss(),a=Pp(),s=Vr(),o=Cw(),l=No(),h=lc(),c=to(),u=ca(),d=$i(),p=kr(),f=Vg(),m=zL(),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&&k)return k;if(!x&&e in I)return I[e];switch(e){case _:case w:case S:return function(){return new a(this,e)}}return function(){return new a(this)}},D=t+" Iterator",L=!1,I=e.prototype,O=I[b]||I["@@iterator"]||m&&I[m],k=!x&&O||R(m),N="Array"==t&&I.entries||O;if(N&&(A=l(N.call(new e)))!==Object.prototype&&A.next&&(!r&&l(A)!==y&&(h?h(A,y):s(A[b])||d(A,b,M)),c(A,D,!0,!0),r&&(f[D]=M)),g&&m==w&&O&&O.name!==w&&(!r&&v?u(I,"name",w):(L=!0,k=function(){return n(O,this)})),m)if(C={values:R(w),keys:E?k:R(_),entries:R(S)},T)for(P in C)(x||L||!(P in I))&&d(I,P,C[P]);else i({target:t,proto:!0,forced:x||L},C);return(!r||T)&&I[b]!==k&&d(I,b,k,{name:m}),f[t]=k,C}})),H1=Q(((e,t)=>{t.exports=function(e,t){return{value:e,done:t}}})),V1=Q(((e,t)=>{"use strict";var i=Ca(),n=pl(),r=Vg(),a=bs(),s=fi().f,o=Lw(),l=H1(),h=ss(),c=rr(),u="Array Iterator",d=a.set,p=a.getterFor(u);t.exports=o(Array,"Array",(function(e,t){d(this,{type:u,target:i(e),index:0,kind:t})}),(function(){var e=p(this),t=e.target,i=e.kind,n=e.index++;return!t||n>=t.length?(e.target=void 0,l(void 0,!0)):l("keys"==i?n:"values"==i?t[n]:[n,t[n]],!1)}),"values");var f=r.Arguments=r.Array;if(n("keys"),n("values"),n("entries"),!h&&c&&"values"!==f.name)try{s(f,"name",{value:"values"})}catch(e){}})),zX=Q((()=>{"use strict";var e=rt(),t=sn(),i=Mp(),n=Ca(),r=cu(),a=t([].join);e({target:"Array",proto:!0,forced:i!=Object||!r("join",",")},{join:function(e){return a(n(this),void 0===e?",":e)}})})),jL=Q(((e,t)=>{"use strict";var i=Fo(),n=Ca(),r=Is(),a=wi(),s=cu(),o=Math.min,l=[].lastIndexOf,h=!!l&&1/[1].lastIndexOf(1,-0)<0,c=s("lastIndexOf"),u=h||!c;t.exports=u?function(e){if(h)return i(l,this,arguments)||0;var t=n(this),s=a(t),c=s-1;for(arguments.length>1&&(c=o(c,r(arguments[1]))),c<0&&(c=s+c);c>=0;c--)if(c in t&&t[c]===e)return c||0;return-1}:l})),jX=Q((()=>{var e=rt(),t=jL();e({target:"Array",proto:!0,forced:t!==[].lastIndexOf},{lastIndexOf:t})})),XX=Q((()=>{"use strict";var e=rt(),t=Us().map;e({target:"Array",proto:!0,forced:!Wg()("map")},{map:function(e){return t(this,e,arguments.length>1?arguments[1]:void 0)}})})),$X=Q((()=>{"use strict";var e=rt(),t=Yt(),i=Lp(),n=ou(),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(i(this)?this:r)(t);t>e;)n(a,e,arguments[e++]);return a.length=t,a}})})),Ow=Q(((e,t)=>{"use strict";var i=rr(),n=xh(),r=TypeError,a=Object.getOwnPropertyDescriptor,s=i&&!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(n(e)&&!a(e,"length").writable)throw r("Cannot set read only .length");return e.length=t}:function(e,t){return e.length=t}})),KX=Q((()=>{"use strict";var e=rt(),t=ci(),i=wi(),n=Ow(),r=qg();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=i(a),o=arguments.length;r(s+o);for(var l=0;l<o;l++)a[s]=arguments[l],s++;return n(a,s),s}})})),z1=Q(((e,t)=>{var i=Ps(),n=ci(),r=Mp(),a=wi(),s=TypeError,o=function(e){return function(t,o,l,h){i(o);var c=n(t),u=r(c),d=a(c),p=e?d-1:0,f=e?-1:1;if(l<2)for(;;){if(p in u){h=u[p],p+=f;break}if(p+=f,e?p<0:d<=p)throw s("Reduce of empty array with no initial value")}for(;e?p>=0:d>p;p+=f)p in u&&(h=o(h,u[p],p,c));return h}};t.exports={left:o(!1),right:o(!0)}})),uu=Q(((e,t)=>{var i=Ra();t.exports="undefined"!=typeof process&&"process"==i(process)})),nY=Q((()=>{"use strict";var e=rt(),t=z1().left,i=cu(),n=iu();e({target:"Array",proto:!0,forced:!uu()&&n>79&&n<83||!i("reduce")},{reduce:function(e){var i=arguments.length;return t(this,e,i,i>1?arguments[1]:void 0)}})})),iY=Q((()=>{"use strict";var e=rt(),t=z1().right,i=cu(),n=iu();e({target:"Array",proto:!0,forced:!uu()&&n>79&&n<83||!i("reduceRight")},{reduceRight:function(e){return t(this,e,arguments.length,arguments.length>1?arguments[1]:void 0)}})})),aY=Q((()=>{"use strict";var e=rt(),t=sn(),i=xh(),n=t([].reverse),r=[1,2];e({target:"Array",proto:!0,forced:String(r)===String(r.reverse())},{reverse:function(){return i(this)&&(this.length=this.length),n(this)}})})),cY=Q((()=>{"use strict";var e=rt(),t=xh(),i=Lp(),n=Cr(),r=au(),a=wi(),s=Ca(),o=ou(),l=kr(),h=Wg(),c=Bd(),u=h("slice"),d=l("species"),p=Array,f=Math.max;e({target:"Array",proto:!0,forced:!u},{slice:function(e,l){var h,u,m,g=s(this),v=a(g),y=r(e,v),x=r(void 0===l?v:l,v);if(t(g)&&(h=g.constructor,(i(h)&&(h===p||t(h.prototype))||n(h)&&null===(h=h[d]))&&(h=void 0),h===p||void 0===h))return c(g,y,x);for(u=new(void 0===h?p:h)(f(x-y,0)),m=0;y<x;y++,m++)y in g&&o(u,m,g[y]);return u.length=m,u}})})),uY=Q((()=>{"use strict";var e=rt(),t=Us().some;e({target:"Array",proto:!0,forced:!cu()("some")},{some:function(e){return t(this,e,arguments.length>1?arguments[1]:void 0)}})})),kw=Q(((e,t)=>{var i=Fg(),n=Math.floor,r=function(e,t){var o=e.length,l=n(o/2);return o<8?a(e,t):s(e,r(i(e,0,l),t),r(i(e,l),t),t)},a=function(e,t){for(var i,n,r=e.length,a=1;a<r;){for(n=a,i=e[a];n&&t(e[n-1],i)>0;)e[n]=e[--n];n!==a++&&(e[n]=i)}return e},s=function(e,t,i,n){for(var r=t.length,a=i.length,s=0,o=0;s<r||o<a;)e[s+o]=s<r&&o<a?n(t[s],i[o])<=0?t[s++]:i[o++]:s<r?t[s++]:i[o++];return e};t.exports=r})),$L=Q(((e,t)=>{var i=ru().match(/firefox\/(\d+)/i);t.exports=!!i&&+i[1]})),ZL=Q(((e,t)=>{var i=ru();t.exports=/MSIE|Trident/.test(i)})),Fw=Q(((e,t)=>{var i=ru().match(/AppleWebKit\/(\d+)\./);t.exports=!!i&&+i[1]})),MY=Q((()=>{"use strict";var e=rt(),t=sn(),i=Ps(),n=ci(),r=wi(),a=k1(),s=Fr(),o=Yt(),l=kw(),h=cu(),c=$L(),u=ZL(),d=iu(),p=Fw(),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(!(c&&c>3)){if(u)return!0;if(p)return p<603;var e,t,i,n,r="";for(e=65;e<76;e++){switch(t=String.fromCharCode(e),e){case 66:case 69:case 70:case 72:i=3;break;case 68:case 71:i=4;break;default:i=2}for(n=0;n<47;n++)f.push({k:t+n,v:i})}for(f.sort((function(e,t){return t.v-e.v})),n=0;n<f.length;n++)t=f[n].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&&i(e);var t=n(this);if(b)return void 0===e?m(t):m(t,e);var o,h,c=[],u=r(t);for(h=0;h<u;h++)h in t&&g(c,t[h]);for(l(c,function(e){return function(t,i){return void 0===i?-1:void 0===t?1:void 0!==e?+e(t,i)||0:s(t)>s(i)?1:-1}}(e)),o=r(c),h=0;h<o;)t[h]=c[h++];for(;h<u;)a(t,h++);return t}})})),Np=Q(((e,t)=>{"use strict";var i=qi(),n=fi(),r=kr(),a=rr(),s=r("species");t.exports=function(e){var t=i(e),r=n.f;a&&t&&!t[s]&&r(t,s,{configurable:!0,get:function(){return this}})}})),CY=Q((()=>{Np()("Array")})),PY=Q((()=>{"use strict";var e=rt(),t=ci(),i=au(),n=Is(),r=wi(),a=Ow(),s=qg(),o=Ng(),l=ou(),h=k1(),c=Wg()("splice"),u=Math.max,d=Math.min;e({target:"Array",proto:!0,forced:!c},{splice:function(e,c){var p,f,m,g,v,y,x=t(this),b=r(x),_=i(e,b),w=arguments.length;for(0===w?p=f=0:1===w?(p=0,f=b-_):(p=w-2,f=d(u(n(c),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}})})),IY=Q((()=>{pl()("flat")})),LY=Q((()=>{pl()("flatMap")})),DY=Q((()=>{"use strict";var e=rt(),t=ci(),i=wi(),n=Ow(),r=k1(),a=qg();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=i(s),l=arguments.length;if(l){a(o+l);for(var h=o;h--;){var c=h+l;h in s?s[c]=s[h]:r(s,c)}for(var u=0;u<l;u++)s[u]=arguments[u]}return n(s,o+l)}})})),Nw=Q(((e,t)=>{t.exports="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof DataView})),jg=Q(((e,t)=>{var i=$i();t.exports=function(e,t,n){for(var r in t)i(e,r,t[r],n);return e}})),uc=Q(((e,t)=>{var i=ko(),n=TypeError;t.exports=function(e,t){if(i(t,e))return e;throw n("Incorrect invocation")}})),QL=Q(((e,t)=>{var i=Is(),n=Qa(),r=RangeError;t.exports=function(e){if(void 0===e)return 0;var t=i(e),a=n(t);if(t!==a)throw r("Wrong length or index");return a}})),UY=Q(((e,t)=>{var i=Array,n=Math.abs,r=Math.pow,a=Math.floor,s=Math.log,o=Math.LN2;t.exports={pack:function(e,t,l){var h,c,u,d=i(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=n(e))!=e||e===1/0?(c=e!=e?1:0,h=f):(h=a(s(e)/o),e*(u=r(2,-h))<1&&(h--,u*=2),(e+=h+m>=1?g/u:g*r(2,1-m))*u>=2&&(h++,u/=2),h+m>=f?(c=0,h=f):h+m>=1?(c=(e*u-1)*r(2,t),h+=m):(c=e*r(2,m-1)*r(2,t),h=0));t>=8;)d[y++]=255&c,c/=256,t-=8;for(h=h<<t|c,p+=t;p>0;)d[y++]=255&h,h/=256,p-=8;return d[--y]|=128*v,d},unpack:function(e,t){var i,n=e.length,a=8*n-t-1,s=(1<<a)-1,o=s>>1,l=a-7,h=n-1,c=e[h--],u=127&c;for(c>>=7;l>0;)u=256*u+e[h--],l-=8;for(i=u&(1<<-l)-1,u>>=-l,l+=t;l>0;)i=256*i+e[h--],l-=8;if(0===u)u=1-o;else{if(u===s)return i?NaN:c?-1/0:1/0;i+=r(2,t),u-=o}return(c?-1:1)*i*r(2,u-t)}}})),q1=Q(((e,t)=>{"use strict";var i,n,r,a,s,o,l=In(),h=sn(),c=rr(),u=Nw(),d=Pp(),p=ca(),f=jg(),m=Yt(),g=uc(),v=Is(),y=Qa(),x=QL(),b=UY(),_=No(),w=lc(),S=vh().f,M=fi().f,E=Aw(),T=Fg(),A=to(),C=bs(),P=d.PROPER,R=d.CONFIGURABLE,D=C.get,L=C.set,I="ArrayBuffer",O="DataView",k="prototype",N="Wrong index",U=l[I],F=U,B=F&&F[k],z=l[O],H=z&&z[k],V=Object.prototype,j=l.Array,G=l.RangeError,W=h(E),X=h([].reverse),Y=b.pack,q=b.unpack,Z=function(e){return[255&e]},Q=function(e){return[255&e,e>>8&255]},J=function(e){return[255&e,e>>8&255,e>>16&255,e>>24&255]},K=function(e){return e[3]<<24|e[2]<<16|e[1]<<8|e[0]},$=function(e){return Y(e,23,4)},ee=function(e){return Y(e,52,8)},te=function(e,t){M(e[k],t,{get:function(){return D(this)[t]}})},ie=function(e,t,i,n){var r=x(i),a=D(e);if(r+t>a.byteLength)throw G(N);var s=D(a.buffer).bytes,o=r+a.byteOffset,l=T(s,o,o+t);return n?l:X(l)},ne=function(e,t,i,n,r,a){var s=x(i),o=D(e);if(s+t>o.byteLength)throw G(N);for(var l=D(o.buffer).bytes,h=s+o.byteOffset,c=n(+r),u=0;u<t;u++)l[h+u]=c[a?u:t-u-1]};if(u){if(i=P&&U.name!==I,m((function(){U(1)}))&&m((function(){new U(-1)}))&&!m((function(){return new U,new U(1.5),new U(NaN),1!=U.length||i&&!R})))i&&R&&p(U,"name",I);else{for((F=function(e){return g(this,B),new U(x(e))})[k]=B,n=S(U),r=0;n.length>r;)(a=n[r++])in F||p(F,a,U[a]);B.constructor=F}w&&_(H)!==V&&w(H,V),s=new z(new F(2)),o=h(H.setInt8),s.setInt8(0,2147483648),s.setInt8(1,2147483649),(s.getInt8(0)||!s.getInt8(1))&&f(H,{setInt8:function(e,t){o(this,e,t<<24>>24)},setUint8:function(e,t){o(this,e,t<<24>>24)}},{unsafe:!0})}else B=(F=function(e){g(this,B);var t=x(e);L(this,{bytes:W(j(t),0),byteLength:t}),c||(this.byteLength=t)})[k],H=(z=function(e,t,i){g(this,H),g(e,B);var n=D(e).byteLength,r=v(t);if(r<0||r>n)throw G("Wrong offset");if(r+(i=void 0===i?n-r:y(i))>n)throw G("Wrong length");L(this,{buffer:e,byteLength:i,byteOffset:r}),c||(this.buffer=e,this.byteLength=i,this.byteOffset=r)})[k],c&&(te(F,"byteLength"),te(z,"buffer"),te(z,"byteLength"),te(z,"byteOffset")),f(H,{getInt8:function(e){return ie(this,1,e)[0]<<24>>24},getUint8:function(e){return ie(this,1,e)[0]},getInt16:function(e){var t=ie(this,2,e,arguments.length>1?arguments[1]:void 0);return(t[1]<<8|t[0])<<16>>16},getUint16:function(e){var t=ie(this,2,e,arguments.length>1?arguments[1]:void 0);return t[1]<<8|t[0]},getInt32:function(e){return K(ie(this,4,e,arguments.length>1?arguments[1]:void 0))},getUint32:function(e){return K(ie(this,4,e,arguments.length>1?arguments[1]:void 0))>>>0},getFloat32:function(e){return q(ie(this,4,e,arguments.length>1?arguments[1]:void 0),23)},getFloat64:function(e){return q(ie(this,8,e,arguments.length>1?arguments[1]:void 0),52)},setInt8:function(e,t){ne(this,1,e,Z,t)},setUint8:function(e,t){ne(this,1,e,Z,t)},setInt16:function(e,t){ne(this,2,e,Q,t,arguments.length>2?arguments[2]:void 0)},setUint16:function(e,t){ne(this,2,e,Q,t,arguments.length>2?arguments[2]:void 0)},setInt32:function(e,t){ne(this,4,e,J,t,arguments.length>2?arguments[2]:void 0)},setUint32:function(e,t){ne(this,4,e,J,t,arguments.length>2?arguments[2]:void 0)},setFloat32:function(e,t){ne(this,4,e,$,t,arguments.length>2?arguments[2]:void 0)},setFloat64:function(e,t){ne(this,8,e,ee,t,arguments.length>2?arguments[2]:void 0)}});A(F,I),A(z,O),t.exports={ArrayBuffer:F,DataView:z}})),a$=Q((()=>{"use strict";var e=rt(),t=In(),i=q1(),n=Np(),r="ArrayBuffer",a=i[r];e({global:!0,constructor:!0,forced:t[r]!==a},{ArrayBuffer:a}),n(r)})),$r=Q(((e,t)=>{"use strict";var i,n,r,a=Nw(),s=rr(),o=In(),l=Vr(),h=Cr(),c=Yr(),u=oc(),d=kd(),p=ca(),f=$i(),m=fi().f,g=ko(),v=No(),y=lc(),x=kr(),b=Cp(),_=bs(),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,D=o.TypeError,L=x("toStringTag"),I=b("TYPED_ARRAY_TAG"),O="TypedArrayConstructor",k=a&&!!y&&"Opera"!==u(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 i=S(t);return i&&c(i,O)?i[O]:B(t)}},z=function(e){if(!h(e))return!1;var t=u(e);return c(U,t)||c(F,t)};for(i in U)(r=(n=o[i])&&n.prototype)?w(r)[O]=n:k=!1;for(i in F)(r=(n=o[i])&&n.prototype)&&(w(r)[O]=n);if((!k||!l(C)||C===Function.prototype)&&(C=function(){throw D("Incorrect invocation")},k))for(i in U)o[i]&&y(o[i],C);if((!k||!P||P===R)&&(P=C.prototype,k))for(i in U)o[i]&&y(o[i].prototype,P);if(k&&v(A)!==P&&y(A,P),s&&!c(P,L))for(i in N=!0,m(P,L,{get:function(){return h(this)?this[I]:void 0}}),U)o[i]&&p(o[i],I,i);t.exports={NATIVE_ARRAY_BUFFER_VIEWS:k,TYPED_ARRAY_TAG:N&&I,aTypedArray:function(e){if(z(e))return e;throw D("Target is not a typed array")},aTypedArrayConstructor:function(e){if(l(e)&&(!y||g(C,e)))return e;throw D(d(e)+" is not a typed array constructor")},exportTypedArrayMethod:function(e,t,i,n){if(s){if(i)for(var r in U){var a=o[r];if(a&&c(a.prototype,e))try{delete a.prototype[e]}catch(i){try{a.prototype[e]=t}catch(e){}}}(!P[e]||i)&&f(P,e,i?t:k&&E[e]||t,n)}},exportTypedArrayStaticMethod:function(e,t,i){var n,r;if(s){if(y){if(i)for(n in U)if((r=o[n])&&c(r,e))try{delete r[e]}catch(e){}if(C[e]&&!i)return;try{return f(C,e,i?t:k&&C[e]||t)}catch(e){}}for(n in U)(r=o[n])&&(!r[e]||i)&&f(r,e,t)}},getTypedArrayConstructor:B,isView:function(e){if(!h(e))return!1;var t=u(e);return"DataView"===t||c(U,t)||c(F,t)},isTypedArray:z,TypedArray:C,TypedArrayPrototype:P}})),y$=Q((()=>{var e=rt(),t=$r();e({target:"ArrayBuffer",stat:!0,forced:!t.NATIVE_ARRAY_BUFFER_VIEWS},{isView:t.isView})})),$w=Q(((e,t)=>{var i=Lp(),n=kd(),r=TypeError;t.exports=function(e){if(i(e))return e;throw r(n(e)+" is not a constructor")}})),Up=Q(((e,t)=>{var i=br(),n=$w(),r=Aa(),a=kr()("species");t.exports=function(e,t){var s,o=i(e).constructor;return void 0===o||r(s=i(o)[a])?t:n(s)}})),R$=Q((()=>{"use strict";var e=rt(),t=yh(),i=Yt(),n=q1(),r=br(),a=au(),s=Qa(),o=Up(),l=n.ArrayBuffer,h=n.DataView,c=h.prototype,u=t(l.prototype.slice),d=t(c.getUint8),p=t(c.setUint8);e({target:"ArrayBuffer",proto:!0,unsafe:!0,forced:i((function(){return!new l(2).slice(1,void 0).byteLength}))},{slice:function(e,t){if(u&&void 0===t)return u(r(this),e);for(var i=r(this).byteLength,n=a(e,i),c=a(void 0===t?i:t,i),f=new(o(this,l))(s(c-n)),m=new h(this),g=new h(f),v=0;n<c;)p(g,v++,d(m,n++));return f}})})),A$=Q((()=>{var e=rt(),t=q1();e({global:!0,constructor:!0,forced:!Nw()},{DataView:t.DataView})})),C$=Q((()=>{A$()})),P$=Q((()=>{"use strict";var e=rt(),t=sn(),i=Yt()((function(){return 120!==new Date(16e11).getYear()})),n=t(Date.prototype.getFullYear);e({target:"Date",proto:!0,forced:i},{getYear:function(){return n(this)-1900}})})),L$=Q((()=>{var e=rt(),t=sn(),i=Date,n=t(i.prototype.getTime);e({target:"Date",stat:!0},{now:function(){return n(new i)}})})),k$=Q((()=>{"use strict";var e=rt(),t=sn(),i=Is(),n=Date.prototype,r=t(n.getTime),a=t(n.setFullYear);e({target:"Date",proto:!0},{setYear:function(e){r(this);var t=i(e);return a(this,0<=t&&t<=99?t+1900:t)}})})),F$=Q((()=>{rt()({target:"Date",proto:!0},{toGMTString:Date.prototype.toUTCString})})),W1=Q(((e,t)=>{"use strict";var i=Is(),n=Fr(),r=xs(),a=RangeError;t.exports=function(e){var t=n(r(this)),s="",o=i(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}})),Zw=Q(((e,t)=>{var i=sn(),n=Qa(),r=Fr(),a=W1(),s=xs(),o=i(a),l=i("".slice),h=Math.ceil,c=function(e){return function(t,i,a){var c,u,d=r(s(t)),p=n(i),f=d.length,m=void 0===a?" ":r(a);return p<=f||""==m?d:((u=o(m,h((c=p-f)/m.length))).length>c&&(u=l(u,0,c)),e?d+u:u+d)}};t.exports={start:c(!1),end:c(!0)}})),q$=Q(((e,t)=>{"use strict";var i=sn(),n=Yt(),r=Zw().start,a=RangeError,s=isFinite,o=Math.abs,l=Date.prototype,h=l.toISOString,c=i(l.getTime),u=i(l.getUTCDate),d=i(l.getUTCFullYear),p=i(l.getUTCHours),f=i(l.getUTCMilliseconds),m=i(l.getUTCMinutes),g=i(l.getUTCMonth),v=i(l.getUTCSeconds);t.exports=n((function(){return"0385-07-25T07:06:39.999Z"!=h.call(new Date(-50000000000001))}))||!n((function(){h.call(new Date(NaN))}))?function(){if(!s(c(this)))throw a("Invalid time value");var e=this,t=d(e),i=f(e),n=t<0?"-":t>9999?"+":"";return n+r(o(t),n?6:4,0)+"-"+r(g(e)+1,2,0)+"-"+r(u(e),2,0)+"T"+r(p(e),2,0)+":"+r(m(e),2,0)+":"+r(v(e),2,0)+"."+r(i,3,0)+"Z"}:h})),j$=Q((()=>{var e=rt(),t=q$();e({target:"Date",proto:!0,forced:Date.prototype.toISOString!==t},{toISOString:t})})),X$=Q((()=>{"use strict";var e=rt(),t=Yt(),i=ci(),n=b1();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=i(this),r=n(t,"number");return"number"!=typeof r||isFinite(r)?t.toISOString():null}})})),$$=Q(((e,t)=>{"use strict";var i=br(),n=E3(),r=TypeError;t.exports=function(e){if(i(this),"string"===e||"default"===e)e="string";else if("number"!==e)throw r("Incorrect hint");return n(this,e)}})),J$=Q((()=>{var e=Yr(),t=$i(),i=$$(),n=kr()("toPrimitive"),r=Date.prototype;e(r,n)||t(r,n,i)})),nZ=Q((()=>{var e=sn(),t=$i(),i=Date.prototype,n="Invalid Date",r="toString",a=e(i[r]),s=e(i.getTime);String(new Date(NaN))!=n&&t(i,r,(function(){var e=s(this);return e==e?a(this):n}))})),iZ=Q((()=>{"use strict";var e=rt(),t=sn(),i=Fr(),n=t("".charAt),r=t("".charCodeAt),a=t(/./.exec),s=t(1..toString),o=t("".toUpperCase),l=/[\w*+\-./@]/,h=function(e,t){for(var i=s(e,16);i.length<t;)i="0"+i;return i};e({global:!0},{escape:function(e){for(var t,s,c=i(e),u="",d=c.length,p=0;p<d;)t=n(c,p++),a(l,t)?u+=t:u+=(s=r(t,0))<256?"%"+h(s,2):"%u"+o(h(s,4));return u}})})),ED=Q(((e,t)=>{"use strict";var i=sn(),n=Ps(),r=Cr(),a=Yr(),s=Bd(),o=Pg(),l=Function,h=i([].concat),c=i([].join),u={},d=function(e,t,i){if(!a(u,t)){for(var n=[],r=0;r<t;r++)n[r]="a["+r+"]";u[t]=l("C,a","return new C("+c(n,",")+")")}return u[t](e,i)};t.exports=o?l.bind:function(e){var t=n(this),i=t.prototype,a=s(arguments,1),o=function(){var i=h(a,s(arguments));return this instanceof o?d(t,i.length,i):t.apply(e,i)};return r(i)&&(o.prototype=i),o}})),uZ=Q((()=>{var e=rt(),t=ED();e({target:"Function",proto:!0,forced:Function.bind!==t},{bind:t})})),fZ=Q((()=>{"use strict";var e=Vr(),t=Cr(),i=fi(),n=No(),r=kr(),a=rw(),s=r("hasInstance"),o=Function.prototype;s in o||i.f(o,s,{value:a((function(i){if(!e(this)||!t(i))return!1;var r=this.prototype;if(!t(r))return i instanceof this;for(;i=n(i);)if(r===i)return!0;return!1}),s)})})),vZ=Q((()=>{var e=rr(),t=Pp().EXISTS,i=sn(),n=fi().f,r=Function.prototype,a=i(r.toString),s=/function\b(?:\s|\/\*[\S\s]*?\*\/|\/\/[^\n\r]*[\n\r]+)*([^\s(/]*)/,o=i(s.exec);e&&!t&&n(r,"name",{configurable:!0,get:function(){try{return o(s,a(this))[1]}catch(e){return""}}})})),yZ=Q((()=>{var e=rt(),t=In();e({global:!0,forced:t.globalThis!==t},{globalThis:t})})),xZ=Q((()=>{var e=In();to()(e.JSON,"JSON",!0)})),Kw=Q(((e,t)=>{var i=Yt();t.exports=i((function(){if("function"==typeof ArrayBuffer){var e=new ArrayBuffer(8);Object.isExtensible(e)&&Object.defineProperty(e,"a",{value:8})}}))})),Qw=Q(((e,t)=>{var i=Yt(),n=Cr(),r=Ra(),a=Kw(),s=Object.isExtensible,o=i((function(){s(1)}));t.exports=o||a?function(e){return!(!n(e)||a&&"ArrayBuffer"==r(e))&&(!s||s(e))}:s})),Vp=Q(((e,t)=>{var i=Yt();t.exports=!i((function(){return Object.isExtensible(Object.preventExtensions({}))}))})),jd=Q(((e,t)=>{var i=rt(),n=sn(),r=Lg(),a=Cr(),s=Yr(),o=fi().f,l=vh(),h=hw(),c=Qw(),u=Cp(),d=Vp(),p=!1,f=u("meta"),m=0,g=function(e){o(e,f,{value:{objectID:"O"+m++,weakData:{}}})},v=t.exports={enable:function(){v.enable=function(){},p=!0;var e=l.f,t=n([].splice),r={};r[f]=1,e(r).length&&(l.f=function(i){for(var n=e(i),r=0,a=n.length;r<a;r++)if(n[r]===f){t(n,r,1);break}return n},i({target:"Object",stat:!0,forced:!0},{getOwnPropertyNames:h.f}))},fastKey:function(e,t){if(!a(e))return"symbol"==typeof e?e:("string"==typeof e?"S":"P")+e;if(!s(e,f)){if(!c(e))return"F";if(!t)return"E";g(e)}return e[f].objectID},getWeakData:function(e,t){if(!s(e,f)){if(!c(e))return!0;if(!t)return!1;g(e)}return e[f].weakData},onFreeze:function(e){return d&&p&&c(e)&&!s(e,f)&&g(e),e}};r[f]=!0})),X1=Q(((e,t)=>{"use strict";var i=rt(),n=In(),r=sn(),a=Og(),s=$i(),o=jd(),l=cc(),h=uc(),c=Vr(),u=Aa(),d=Cr(),p=Yt(),f=N1(),m=to(),g=kp();t.exports=function(e,t,v){var y=-1!==e.indexOf("Map"),x=-1!==e.indexOf("Weak"),b=y?"set":"add",_=n[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,i){return t(this,0===e?0:e,i),this})};if(a(e,!c(_)||!(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 i=g(new _,e,S);return u(t)||l(t,i[b],{that:i,AS_ENTRIES:y}),i}))).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,i({global:!0,constructor:!0,forced:S!=_},M),m(S,e),x||v.setStrong(S,e,y),S}})),PD=Q(((e,t)=>{"use strict";var i=fi().f,n=eo(),r=jg(),a=dl(),s=uc(),o=Aa(),l=cc(),h=Lw(),c=H1(),u=Np(),d=rr(),p=jd().fastKey,f=bs(),m=f.set,g=f.getterFor;t.exports={getConstructor:function(e,t,h,c){var u=e((function(e,i){s(e,f),m(e,{type:t,index:n(null),first:void 0,last:void 0,size:0}),d||(e.size=0),o(i)||l(i,e[c],{that:e,AS_ENTRIES:h})})),f=u.prototype,v=g(t),y=function(e,t,i){var n,r,a=v(e),s=x(e,t);return s?s.value=i:(a.last=s={index:r=p(t,!0),key:t,value:i,previous:n=a.last,next:void 0,removed:!1},a.first||(a.first=s),n&&(n.next=s),d?a.size++:e.size++,"F"!==r&&(a.index[r]=s)),e},x=function(e,t){var i,n=v(e),r=p(t);if("F"!==r)return n.index[r];for(i=n.first;i;i=i.next)if(i.key==t)return i};return r(f,{clear:function(){for(var e=v(this),t=e.index,i=e.first;i;)i.removed=!0,i.previous&&(i.previous=i.previous.next=void 0),delete t[i.index],i=i.next;e.first=e.last=void 0,d?e.size=0:this.size=0},delete:function(e){var t=this,i=v(t),n=x(t,e);if(n){var r=n.next,a=n.previous;delete i.index[n.index],n.removed=!0,a&&(a.next=r),r&&(r.previous=a),i.first==n&&(i.first=r),i.last==n&&(i.last=a),d?i.size--:t.size--}return!!n},forEach:function(e){for(var t,i=v(this),n=a(e,arguments.length>1?arguments[1]:void 0);t=t?t.next:i.first;)for(n(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",{get:function(){return v(this).size}}),u},setStrong:function(e,t,i){var n=t+" Iterator",r=g(t),a=g(n);h(e,t,(function(e,t){m(this,{type:n,target:e,state:r(e),kind:t,last:void 0})}),(function(){for(var e=a(this),t=e.kind,i=e.last;i&&i.removed;)i=i.previous;return e.target&&(e.last=i=i?i.next:e.state.first)?c("keys"==t?i.key:"values"==t?i.value:[i.key,i.value],!1):(e.target=void 0,c(void 0,!0))}),i?"entries":"values",!i,!0),u(t)}}})),OZ=Q((()=>{"use strict";X1()("Map",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),PD())})),kZ=Q((()=>{OZ()})),ID=Q(((e,t)=>{var i=Math.log;t.exports=Math.log1p||function(e){var t=+e;return t>-1e-8&&t<1e-8?t-t*t/2:i(1+t)}})),BZ=Q((()=>{var e=rt(),t=ID(),i=Math.acosh,n=Math.log,r=Math.sqrt,a=Math.LN2;e({target:"Math",stat:!0,forced:!i||710!=Math.floor(i(Number.MAX_VALUE))||i(1/0)!=1/0},{acosh:function(e){var i=+e;return i<1?NaN:i>94906265.62425156?n(i)+a:t(i-1+r(i-1)*r(i+1))}})})),VZ=Q((()=>{var e=rt(),t=Math.asinh,i=Math.log,n=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):i(r+n(r*r+1)):r}})})),GZ=Q((()=>{var e=rt(),t=Math.atanh,i=Math.log;e({target:"Math",stat:!0,forced:!(t&&1/t(-0)<0)},{atanh:function(e){var t=+e;return 0==t?t:i((1+t)/(1-t))/2}})})),tS=Q(((e,t)=>{t.exports=Math.sign||function(e){var t=+e;return 0==t||t!=t?t:t<0?-1:1}})),WZ=Q((()=>{var e=rt(),t=tS(),i=Math.abs,n=Math.pow;e({target:"Math",stat:!0},{cbrt:function(e){var r=+e;return t(r)*n(i(r),1/3)}})})),jZ=Q((()=>{var e=rt(),t=Math.floor,i=Math.log,n=Math.LOG2E;e({target:"Math",stat:!0},{clz32:function(e){var r=e>>>0;return r?31-t(i(r+.5)*n):32}})})),Z1=Q(((e,t)=>{var i=Math.expm1,n=Math.exp;t.exports=!i||i(10)>22025.465794806718||i(10)<22025.465794806718||-2e-17!=i(-2e-17)?function(e){var t=+e;return 0==t?t:t>-1e-6&&t<1e-6?t+t*t/2:n(t)-1}:i})),$Z=Q((()=>{var e=rt(),t=Z1(),i=Math.cosh,n=Math.abs,r=Math.E;e({target:"Math",stat:!0,forced:!i||i(710)===1/0},{cosh:function(e){var i=t(n(e)-1)+1;return(i+1/(i*r*r))*(r/2)}})})),KZ=Q((()=>{var e=rt(),t=Z1();e({target:"Math",stat:!0,forced:t!=Math.expm1},{expm1:t})})),QZ=Q(((e,t)=>{var i=tS(),n=Math.abs,r=Math.pow,a=r(2,-52),s=r(2,-23),o=r(2,127)*(2-s),l=r(2,-126);t.exports=Math.fround||function(e){var t,r,h=+e,c=n(h),u=i(h);return c<l?u*(c/l/s+1/a-1/a)*l*s:(r=(t=(1+s/a)*c)-(t-c))>o||r!=r?u*(1/0):u*r}})),eK=Q((()=>{rt()({target:"Math",stat:!0},{fround:QZ()})})),nK=Q((()=>{var e=rt(),t=Math.hypot,i=Math.abs,n=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=i(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*n(s)}})})),iK=Q((()=>{var e=rt(),t=Yt(),i=Math.imul;e({target:"Math",stat:!0,forced:t((function(){return-5!=i(4294967295,5)||2!=i.length}))},{imul:function(e,t){var i=65535,n=+e,r=+t,a=i&n,s=i&r;return 0|a*s+((i&n>>>16)*s+a*(i&r>>>16)<<16>>>0)}})})),FD=Q(((e,t)=>{var i=Math.log,n=Math.LOG10E;t.exports=Math.log10||function(e){return i(e)*n}})),aK=Q((()=>{rt()({target:"Math",stat:!0},{log10:FD()})})),oK=Q((()=>{rt()({target:"Math",stat:!0},{log1p:ID()})})),lK=Q((()=>{var e=rt(),t=Math.log,i=Math.LN2;e({target:"Math",stat:!0},{log2:function(e){return t(e)/i}})})),cK=Q((()=>{rt()({target:"Math",stat:!0},{sign:tS()})})),dK=Q((()=>{var e=rt(),t=Yt(),i=Z1(),n=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 n(t)<1?(i(t)-i(-t))/2:(r(t-1)-r(-t-1))*(a/2)}})})),mK=Q((()=>{var e=rt(),t=Z1(),i=Math.exp;e({target:"Math",stat:!0},{tanh:function(e){var n=+e,r=t(n),a=t(-n);return r==1/0?1:a==1/0?-1:(r-a)/(i(n)+i(-n))}})})),gK=Q((()=>{to()(Math,"Math",!0)})),vK=Q((()=>{rt()({target:"Math",stat:!0},{trunc:U3()})})),K1=Q(((e,t)=>{var i=sn();t.exports=i(1..valueOf)})),J1=Q(((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"})),zp=Q(((e,t)=>{var i=sn(),n=xs(),r=Fr(),a=J1(),s=i("".replace),o="["+a+"]",l=RegExp("^"+o+o+"*"),h=RegExp(o+o+"*$"),c=function(e){return function(t){var i=r(n(t));return 1&e&&(i=s(i,l,"")),2&e&&(i=s(i,h,"")),i}};t.exports={start:c(1),end:c(2),trim:c(3)}})),AK=Q((()=>{"use strict";var e=rt(),t=ss(),i=rr(),n=In(),r=dw(),a=sn(),s=Og(),o=Yr(),l=kp(),h=ko(),c=Od(),u=b1(),d=Yt(),p=vh().f,f=Ks().f,m=fi().f,g=K1(),v=zp().trim,y="Number",x=n[y],b=r[y],_=x.prototype,w=n.TypeError,S=a("".slice),M=a("".charCodeAt),E=function(e){var t,i,n,r,a,s,o,l,h=u(e,"number");if(c(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===(i=M(h,2))||120===i)return NaN}else if(48===t){switch(M(h,1)){case 66:case 98:n=2,r=49;break;case 79:case 111:n=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,n)}return+h},T=s(y,!x(" 0o1")||!x("0b1")||x("+0x1")),A=function(e){var t=arguments.length<1?0:x(function(e){var t=u(e,"number");return"bigint"==typeof t?t:E(t)}(e));return function(e){return h(_,e)&&d((function(){g(e)}))}(this)?l(Object(t),this,A):t};A.prototype=_,T&&!t&&(_.constructor=A),e({global:!0,constructor:!0,wrap:!0,forced:T},{Number:A});var C=function(e,t){for(var n,r=i?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,n=r[a])&&!o(e,n)&&m(e,n,f(t,n))};t&&b&&C(r[y],b),(T||t)&&C(r[y],x)})),CK=Q((()=>{rt()({target:"Number",stat:!0,nonConfigurable:!0,nonWritable:!0},{EPSILON:Math.pow(2,-52)})})),IK=Q(((e,t)=>{var i=In().isFinite;t.exports=Number.isFinite||function(e){return"number"==typeof e&&i(e)}})),LK=Q((()=>{rt()({target:"Number",stat:!0},{isFinite:IK()})})),oS=Q(((e,t)=>{var i=Cr(),n=Math.floor;t.exports=Number.isInteger||function(e){return!i(e)&&isFinite(e)&&n(e)===e}})),OK=Q((()=>{rt()({target:"Number",stat:!0},{isInteger:oS()})})),kK=Q((()=>{rt()({target:"Number",stat:!0},{isNaN:function(e){return e!=e}})})),FK=Q((()=>{var e=rt(),t=oS(),i=Math.abs;e({target:"Number",stat:!0},{isSafeInteger:function(e){return t(e)&&i(e)<=9007199254740991}})})),NK=Q((()=>{rt()({target:"Number",stat:!0,nonConfigurable:!0,nonWritable:!0},{MAX_SAFE_INTEGER:9007199254740991})})),BK=Q((()=>{rt()({target:"Number",stat:!0,nonConfigurable:!0,nonWritable:!0},{MIN_SAFE_INTEGER:-9007199254740991})})),zD=Q(((e,t)=>{var i=In(),n=Yt(),r=sn(),a=Fr(),s=zp().trim,o=J1(),l=r("".charAt),h=i.parseFloat,c=i.Symbol,u=c&&c.iterator,d=1/h(o+"-0")!=-1/0||u&&!n((function(){h(Object(u))}));t.exports=d?function(e){var t=s(a(e)),i=h(t);return 0===i&&"-"==l(t,0)?-0:i}:h})),qK=Q((()=>{var e=rt(),t=zD();e({target:"Number",stat:!0,forced:Number.parseFloat!=t},{parseFloat:t})})),GD=Q(((e,t)=>{var i=In(),n=Yt(),r=sn(),a=Fr(),s=zp().trim,o=J1(),l=i.parseInt,h=i.Symbol,c=h&&h.iterator,u=/^[+-]?0x/i,d=r(u.exec),p=8!==l(o+"08")||22!==l(o+"0x16")||c&&!n((function(){l(Object(c))}));t.exports=p?function(e,t){var i=s(a(e));return l(i,t>>>0||(d(u,i)?16:10))}:l})),JK=Q((()=>{var e=rt(),t=GD();e({target:"Number",stat:!0,forced:Number.parseInt!=t},{parseInt:t})})),rJ=Q((()=>{"use strict";var e=rt(),t=sn(),i=Is(),n=K1(),r=W1(),a=FD(),s=Yt(),o=RangeError,l=String,h=isFinite,c=Math.abs,u=Math.floor,d=Math.pow,p=Math.round,f=t(1..toExponential),m=t(r),g=t("".slice),v="-6.9000e-11"===f(-69e-12,4)&&"1.25e+0"===f(1.255,2)&&"1.235e+4"===f(12345,3)&&"3e+1"===f(25,0);e({target:"Number",proto:!0,forced:!v||!(s((function(){f(1,1/0)}))&&s((function(){f(1,-1/0)})))||!!s((function(){f(1/0,1/0),f(NaN,1/0)}))},{toExponential:function(e){var t=n(this);if(void 0===e)return f(t);var r=i(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=u(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(c(x))),s+(y+"e")+b+_}})})),cJ=Q((()=>{"use strict";var e=rt(),t=sn(),i=Is(),n=K1(),r=W1(),a=Yt(),s=RangeError,o=String,l=Math.floor,h=t(r),c=t("".slice),u=t(1..toFixed),d=function(e,t,i){return 0===t?i:t%2==1?d(e,t-1,i*e):d(e*e,t/2,i)},p=function(e,t,i){for(var n=-1,r=i;++n<6;)r+=t*e[n],e[n]=r%1e7,r=l(r/1e7)},f=function(e,t){for(var i=6,n=0;--i>=0;)n+=e[i],e[i]=l(n/t),n=n%t*1e7},m=function(e){for(var t=6,i="";--t>=0;)if(""!==i||0===t||0!==e[t]){var n=o(e[t]);i=""===i?n:i+h("0",7-n.length)+n}return i};e({target:"Number",proto:!0,forced:a((function(){return"0.000"!==u(8e-5,3)||"1"!==u(.9,0)||"1.25"!==u(1.255,2)||"1000000000000000128"!==u(0xde0b6b3a7640080,0)}))||!a((function(){u({})}))},{toFixed:function(e){var t,r,a,l,u=n(this),g=i(e),v=[0,0,0,0,0,0],y="",x="0";if(g<0||g>20)throw s("Incorrect fraction digits");if(u!=u)return"NaN";if(u<=-1e21||u>=1e21)return o(u);if(u<0&&(y="-",u=-u),u>1e-21)if(t=function(e){for(var t=0,i=e;i>=4096;)t+=12,i/=4096;for(;i>=2;)t+=1,i/=2;return t}(u*d(2,69,1))-69,r=t<0?u*d(2,-t,1):u/d(2,t,1),r*=4503599627370496,(t=52-t)>0){for(p(v,0,r),a=g;a>=7;)p(v,1e7,0),a-=7;for(p(v,d(10,a,1),0),a=t-1;a>=23;)f(v,1<<23),a-=23;f(v,1<<a),p(v,1,1),f(v,2),x=m(v)}else p(v,0,r),p(v,1<<-t,0),x=m(v)+h("0",g);return x=g>0?y+((l=x.length)<=g?"0."+h("0",g-l)+x:c(x,0,l-g)+"."+c(x,l-g)):y+x}})})),dJ=Q((()=>{"use strict";var e=rt(),t=sn(),i=Yt(),n=K1(),r=t(1..toPrecision);e({target:"Number",proto:!0,forced:i((function(){return"1"!==r(1,void 0)}))||!i((function(){r({})}))},{toPrecision:function(e){return void 0===e?r(n(this)):r(n(this),e)}})})),ZD=Q(((e,t)=>{"use strict";var i=rr(),n=sn(),r=wr(),a=Yt(),s=kg(),o=w1(),l=x1(),h=ci(),c=Mp(),u=Object.assign,d=Object.defineProperty,p=n([].concat);t.exports=!u||a((function(){if(i&&1!==u({b:1},u(d({},"a",{enumerable:!0,get:function(){d(this,"b",{value:3,enumerable:!1})}}),{b:2})).b)return!0;var e={},t={},n=Symbol(),r="abcdefghijklmnopqrst";return e[n]=7,r.split("").forEach((function(e){t[e]=e})),7!=u({},e)[n]||s(u({},t)).join("")!=r}))?function(e,t){for(var n=h(e),a=arguments.length,u=1,d=o.f,f=l.f;a>u;)for(var m,g=c(arguments[u++]),v=d?p(s(g),d(g)):s(g),y=v.length,x=0;y>x;)m=v[x++],(!i||r(f,g,m))&&(n[m]=g[m]);return n}:u})),vJ=Q((()=>{var e=rt(),t=ZD();e({target:"Object",stat:!0,arity:2,forced:Object.assign!==t},{assign:t})})),yJ=Q((()=>{rt()({target:"Object",stat:!0,sham:!rr()},{create:eo()})})),nx=Q(((e,t)=>{"use strict";var i=ss(),n=In(),r=Yt(),a=Fw();t.exports=i||!r((function(){if(!(a&&a<535)){var e=Math.random();__defineSetter__.call(null,e,(function(){})),delete n[e]}}))})),EJ=Q((()=>{"use strict";var e=rt(),t=rr(),i=nx(),n=Ps(),r=ci(),a=fi();t&&e({target:"Object",proto:!0,forced:i},{__defineGetter__:function(e,t){a.f(r(this),e,{get:n(t),enumerable:!0,configurable:!0})}})})),TJ=Q((()=>{var e=rt(),t=rr(),i=lw().f;e({target:"Object",stat:!0,forced:Object.defineProperties!==i,sham:!t},{defineProperties:i})})),SJ=Q((()=>{var e=rt(),t=rr(),i=fi().f;e({target:"Object",stat:!0,forced:Object.defineProperty!==i,sham:!t},{defineProperty:i})})),MJ=Q((()=>{"use strict";var e=rt(),t=rr(),i=nx(),n=Ps(),r=ci(),a=fi();t&&e({target:"Object",proto:!0,forced:i},{__defineSetter__:function(e,t){a.f(r(this),e,{set:n(t),enumerable:!0,configurable:!0})}})})),KD=Q(((e,t)=>{var i=rr(),n=sn(),r=kg(),a=Ca(),s=n(x1().f),o=n([].push),l=function(e){return function(t){for(var n,l=a(t),h=r(l),c=h.length,u=0,d=[];c>u;)n=h[u++],(!i||s(l,n))&&o(d,e?[n,l[n]]:l[n]);return d}};t.exports={entries:l(!0),values:l(!1)}})),PJ=Q((()=>{var e=rt(),t=KD().entries;e({target:"Object",stat:!0},{entries:function(e){return t(e)}})})),IJ=Q((()=>{var e=rt(),t=Vp(),i=Yt(),n=Cr(),r=jd().onFreeze,a=Object.freeze;e({target:"Object",stat:!0,forced:i((function(){a(1)})),sham:!t},{freeze:function(e){return a&&n(e)?a(r(e)):e}})})),LJ=Q((()=>{var e=rt(),t=cc(),i=ou();e({target:"Object",stat:!0},{fromEntries:function(e){var n={};return t(e,(function(e,t){i(n,e,t)}),{AS_ENTRIES:!0}),n}})})),kJ=Q((()=>{var e=rt(),t=Yt(),i=Ca(),n=Ks().f,r=rr();e({target:"Object",stat:!0,forced:!r||t((function(){n(1)})),sham:!r},{getOwnPropertyDescriptor:function(e,t){return n(i(e),t)}})})),FJ=Q((()=>{var e=rt(),t=rr(),i=sw(),n=Ca(),r=Ks(),a=ou();e({target:"Object",stat:!0,sham:!t},{getOwnPropertyDescriptors:function(e){for(var t,s,o=n(e),l=r.f,h=i(o),c={},u=0;h.length>u;)void 0!==(s=l(o,t=h[u++]))&&a(c,t,s);return c}})})),NJ=Q((()=>{var e=rt(),t=Yt(),i=hw().f;e({target:"Object",stat:!0,forced:t((function(){return!Object.getOwnPropertyNames(1)}))},{getOwnPropertyNames:i})})),UJ=Q((()=>{var e=rt(),t=Yt(),i=ci(),n=No(),r=Tw();e({target:"Object",stat:!0,forced:t((function(){n(1)})),sham:!r},{getPrototypeOf:function(e){return n(i(e))}})})),HJ=Q((()=>{rt()({target:"Object",stat:!0},{hasOwn:Yr()})})),QD=Q(((e,t)=>{t.exports=Object.is||function(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}})),zJ=Q((()=>{rt()({target:"Object",stat:!0},{is:QD()})})),qJ=Q((()=>{var e=rt(),t=Qw();e({target:"Object",stat:!0,forced:Object.isExtensible!==t},{isExtensible:t})})),jJ=Q((()=>{var e=rt(),t=Yt(),i=Cr(),n=Ra(),r=Kw(),a=Object.isFrozen;e({target:"Object",stat:!0,forced:r||t((function(){a(1)}))},{isFrozen:function(e){return!(i(e)&&(!r||"ArrayBuffer"!=n(e)))||!!a&&a(e)}})})),YJ=Q((()=>{var e=rt(),t=Yt(),i=Cr(),n=Ra(),r=Kw(),a=Object.isSealed;e({target:"Object",stat:!0,forced:r||t((function(){a(1)}))},{isSealed:function(e){return!(i(e)&&(!r||"ArrayBuffer"!=n(e)))||!!a&&a(e)}})})),ZJ=Q((()=>{var e=rt(),t=ci(),i=kg();e({target:"Object",stat:!0,forced:Yt()((function(){i(1)}))},{keys:function(e){return i(t(e))}})})),KJ=Q((()=>{"use strict";var e=rt(),t=rr(),i=nx(),n=ci(),r=gh(),a=No(),s=Ks().f;t&&e({target:"Object",proto:!0,forced:i},{__lookupGetter__:function(e){var t,i=n(this),o=r(e);do{if(t=s(i,o))return t.get}while(i=a(i))}})})),JJ=Q((()=>{"use strict";var e=rt(),t=rr(),i=nx(),n=ci(),r=gh(),a=No(),s=Ks().f;t&&e({target:"Object",proto:!0,forced:i},{__lookupSetter__:function(e){var t,i=n(this),o=r(e);do{if(t=s(i,o))return t.set}while(i=a(i))}})})),QJ=Q((()=>{var e=rt(),t=Cr(),i=jd().onFreeze,n=Vp(),r=Yt(),a=Object.preventExtensions;e({target:"Object",stat:!0,forced:r((function(){a(1)})),sham:!n},{preventExtensions:function(e){return a&&t(e)?a(i(e)):e}})})),Xd=Q(((e,t)=>{var i=rw(),n=fi();t.exports=function(e,t,r){return r.get&&i(r.get,t,{getter:!0}),r.set&&i(r.set,t,{setter:!0}),n.f(e,t,r)}})),oQ=Q((()=>{"use strict";var e=rr(),t=Xd(),i=Cr(),n=ci(),r=xs(),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(n(this))},set:function(e){var t=r(this);!i(e)&&null!==e||!i(t)||s(t,e)}})}catch(e){}})),lQ=Q((()=>{var e=rt(),t=Cr(),i=jd().onFreeze,n=Vp(),r=Yt(),a=Object.seal;e({target:"Object",stat:!0,forced:r((function(){a(1)})),sham:!n},{seal:function(e){return a&&t(e)?a(i(e)):e}})})),cQ=Q((()=>{rt()({target:"Object",stat:!0},{setPrototypeOf:lc()})})),hQ=Q(((e,t)=>{"use strict";var i=aw(),n=oc();t.exports=i?{}.toString:function(){return"[object "+n(this)+"]"}})),dQ=Q((()=>{var e=aw(),t=$i(),i=hQ();e||t(Object.prototype,"toString",i,{unsafe:!0})})),fQ=Q((()=>{var e=rt(),t=KD().values;e({target:"Object",stat:!0},{values:function(e){return t(e)}})})),mQ=Q((()=>{var e=rt(),t=zD();e({global:!0,forced:parseFloat!=t},{parseFloat:t})})),vQ=Q((()=>{var e=rt(),t=GD();e({global:!0,forced:parseInt!=t},{parseInt:t})})),Ah=Q(((e,t)=>{var i=TypeError;t.exports=function(e,t){if(e<t)throw i("Not enough arguments");return e}})),iO=Q(((e,t)=>{var i=ru();t.exports=/(?:ipad|iphone|ipod).*applewebkit/i.test(i)})),sx=Q(((e,t)=>{var i,n,r,a,s=In(),o=Fo(),l=dl(),h=Vr(),c=Yr(),u=Yt(),d=G3(),p=Bd(),f=E1(),m=Ah(),g=iO(),v=uu(),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";u((function(){i=s.location}));var C=function(e){if(c(T,e)){var t=T[e];delete T[e],t()}},P=function(e){return function(){C(e)}},R=function(e){C(e.data)},D=function(e){s.postMessage(M(e),i.protocol+"//"+i.host)};(!y||!x)&&(y=function(e){m(arguments.length,1);var t=h(e)?e:w(e),i=p(arguments,1);return T[++E]=function(){o(t,void 0,i)},n(E),E},x=function(e){delete T[e]},v?n=function(e){b.nextTick(P(e))}:_&&_.now?n=function(e){_.now(P(e))}:S&&!g?(a=(r=new S).port2,r.port1.onmessage=R,n=l(a.postMessage,a)):s.addEventListener&&h(s.postMessage)&&!s.importScripts&&i&&"file:"!==i.protocol&&!u(D)?(n=D,s.addEventListener("message",R,!1)):n=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}})),fO=Q(((e,t)=>{var i=function(){this.head=null,this.tail=null};i.prototype={add:function(e){var t={item:e,next:null},i=this.tail;i?i.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=i})),LQ=Q(((e,t)=>{var i=ru();t.exports=/ipad|iphone|ipod/i.test(i)&&"undefined"!=typeof Pebble})),OQ=Q(((e,t)=>{var i=ru();t.exports=/web0s(?!.*chrome)/i.test(i)})),xO=Q(((e,t)=>{var i,n,r,a,s,o,l,h=In(),c=dl(),u=Ks().f,d=sx().set,p=fO(),f=iO(),m=LQ(),g=OQ(),v=uu(),y=h.MutationObserver||h.WebKitMutationObserver,x=h.document,b=h.process,_=h.Promise,w=u(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&&i(),e}e&&e.enter()},f||v||g||!y||!x?!m&&_&&_.resolve?((a=_.resolve(void 0)).constructor=_,s=c(a.then,a),i=function(){s(l)}):v?i=function(){b.nextTick(l)}:(d=c(d,h),i=function(){d(l)}):(n=!0,r=x.createTextNode(""),new y(l).observe(r,{characterData:!0}),i=function(){r.data=n=!n}),S=function(e){o.head||i(),o.add(e)}),t.exports=S})),GQ=Q(((e,t)=>{t.exports=function(e,t){try{1==arguments.length?console.error(e):console.error(e,t)}catch(e){}}})),r0=Q(((e,t)=>{t.exports=function(e){try{return{error:!1,value:e()}}catch(e){return{error:!0,value:e}}}})),Wp=Q(((e,t)=>{var i=In();t.exports=i.Promise})),dS=Q(((e,t)=>{t.exports="object"==typeof Deno&&Deno&&"object"==typeof Deno.version})),bO=Q(((e,t)=>{var i=dS(),n=uu();t.exports=!i&&!n&&"object"==typeof window&&"object"==typeof document})),i0=Q(((e,t)=>{var i=In(),n=Wp(),r=Vr(),a=Og(),s=JT(),o=kr(),l=bO(),h=dS(),c=ss(),u=iu(),d=n&&n.prototype,p=o("species"),f=!1,m=r(i.PromiseRejectionEvent),g=a("Promise",(function(){var e=s(n),t=e!==String(n);if(!t&&66===u||c&&(!d.catch||!d.finally))return!0;if(!u||u<51||!/native code/.test(e)){var i=new n((function(e){e(1)})),r=function(e){e((function(){}),(function(){}))};if((i.constructor={})[p]=r,!(f=i.then((function(){}))instanceof r))return!0}return!t&&(l||h)&&!m}));t.exports={CONSTRUCTOR:g,REJECTION_EVENT:m,SUBCLASSING:f}})),Yd=Q(((e,t)=>{"use strict";var i=Ps(),n=TypeError,r=function(e){var t,r;this.promise=new e((function(e,i){if(void 0!==t||void 0!==r)throw n("Bad Promise constructor");t=e,r=i})),this.resolve=i(t),this.reject=i(r)};t.exports.f=function(e){return new r(e)}})),vee=Q((()=>{"use strict";var e,t,i,n=rt(),r=ss(),a=uu(),s=In(),o=wr(),l=$i(),h=lc(),c=to(),u=Np(),d=Ps(),p=Vr(),f=Cr(),m=uc(),g=Up(),v=sx().set,y=xO(),x=GQ(),b=r0(),_=fO(),w=bs(),S=Wp(),M=i0(),E=Yd(),T="Promise",A=M.CONSTRUCTOR,C=M.REJECTION_EVENT,P=M.SUBCLASSING,R=w.getterFor(T),D=w.set,L=S&&S.prototype,I=S,O=L,k=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 i,n,r,a=t.value,s=1==t.state,l=s?e.ok:e.fail,h=e.resolve,c=e.reject,u=e.domain;try{l?(s||(2===t.rejection&&q(t),t.rejection=1),!0===l?i=a:(u&&u.enter(),i=l(a),u&&(u.exit(),r=!0)),i===e.promise?c(k("Promise-chain cycle")):(n=V(i))?o(n,i,h,c):h(i)):c(a)}catch(e){u&&!r&&u.exit(),c(e)}},G=function(e,t){e.notified||(e.notified=!0,y((function(){for(var i,n=e.reactions;i=n.get();)j(i,e);e.notified=!1,t&&!e.rejection&&X(e)})))},W=function(e,t,i){var n,r;z?((n=N.createEvent("Event")).promise=t,n.reason=i,n.initEvent(e,!1,!0),s.dispatchEvent(n)):n={promise:t,reason:i},!C&&(r=s["on"+e])?r(n):e===H&&x("Unhandled promise rejection",i)},X=function(e){o(v,s,(function(){var t,i=e.facade,n=e.value;if(Y(e)&&(t=b((function(){a?U.emit("unhandledRejection",n,i):W(H,i,n)})),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)}))},Z=function(e,t,i){return function(n){e(t,n,i)}},Q=function(e,t,i){e.done||(e.done=!0,i&&(e=i),e.value=t,e.state=2,G(e,!0))},J=function(e,t,i){if(!e.done){e.done=!0,i&&(e=i);try{if(e.facade===t)throw k("Promise can't be resolved itself");var n=V(t);n?y((function(){var i={done:!1};try{o(n,t,Z(J,i,e),Z(Q,i,e))}catch(t){Q(i,t,e)}})):(e.value=t,e.state=1,G(e,!1))}catch(t){Q({done:!1},t,e)}}};if(A&&(O=(I=function(t){m(this,O),d(t),o(e,this);var i=R(this);try{t(Z(J,i),Z(Q,i))}catch(e){Q(i,e)}}).prototype,(e=function(e){D(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 i=R(this),n=F(g(this,I));return i.parent=!0,n.ok=!p(e)||e,n.fail=p(t)&&t,n.domain=a?U.domain:void 0,0==i.state?i.reactions.add(n):y((function(){j(n,i)})),n.promise})),t=function(){var t=new e,i=R(t);this.promise=t,this.resolve=Z(J,i),this.reject=Z(Q,i)},E.f=F=function(e){return e===I||void 0===e?new t(e):B(e)},!r&&p(S)&&L!==Object.prototype)){i=L.then,P||l(L,"then",(function(e,t){var n=this;return new I((function(e,t){o(i,n,e,t)})).then(e,t)}),{unsafe:!0});try{delete L.constructor}catch(e){}h&&h(L,O)}n({global:!0,constructor:!0,wrap:!0,forced:A},{Promise:I}),c(I,T,!1,!0),u(T)})),cx=Q(((e,t)=>{var i=Wp(),n=N1(),r=i0().CONSTRUCTOR;t.exports=r||!n((function(e){i.all(e).then(void 0,(function(){}))}))})),xee=Q((()=>{"use strict";var e=rt(),t=wr(),i=Ps(),n=Yd(),r=r0(),a=cc();e({target:"Promise",stat:!0,forced:cx()},{all:function(e){var s=this,o=n.f(s),l=o.resolve,h=o.reject,c=r((function(){var n=i(s.resolve),r=[],o=0,c=1;a(e,(function(e){var i=o++,a=!1;c++,t(n,s,e).then((function(e){a||(a=!0,r[i]=e,--c||l(r))}),h)})),--c||l(r)}));return c.error&&h(c.value),o.promise}})})),Eee=Q((()=>{"use strict";var e,t=rt(),i=ss(),n=i0().CONSTRUCTOR,r=Wp(),a=qi(),s=Vr(),o=$i(),l=r&&r.prototype;t({target:"Promise",proto:!0,forced:n,real:!0},{catch:function(e){return this.then(void 0,e)}}),!i&&s(r)&&(e=a("Promise").prototype.catch,l.catch!==e&&o(l,"catch",e,{unsafe:!0}))})),_ee=Q((()=>{"use strict";var e=rt(),t=wr(),i=Ps(),n=Yd(),r=r0(),a=cc();e({target:"Promise",stat:!0,forced:cx()},{race:function(e){var s=this,o=n.f(s),l=o.reject,h=r((function(){var n=i(s.resolve);a(e,(function(e){t(n,s,e).then(o.resolve,l)}))}));return h.error&&l(h.value),o.promise}})})),Tee=Q((()=>{"use strict";var e=rt(),t=wr(),i=Yd();e({target:"Promise",stat:!0,forced:i0().CONSTRUCTOR},{reject:function(e){var n=i.f(this);return t(n.reject,void 0,e),n.promise}})})),DO=Q(((e,t)=>{var i=br(),n=Cr(),r=Yd();t.exports=function(e,t){if(i(e),n(t)&&t.constructor===e)return t;var a=r.f(e);return(0,a.resolve)(t),a.promise}})),Ree=Q((()=>{"use strict";var e=rt(),t=qi(),i=ss(),n=Wp(),r=i0().CONSTRUCTOR,a=DO(),s=t("Promise"),o=i&&!r;e({target:"Promise",stat:!0,forced:i||r},{resolve:function(e){return a(o&&this===s?n:this,e)}})})),Aee=Q((()=>{vee(),xee(),Eee(),_ee(),Tee(),Ree()})),Cee=Q((()=>{"use strict";var e=rt(),t=wr(),i=Ps(),n=Yd(),r=r0(),a=cc();e({target:"Promise",stat:!0,forced:cx()},{allSettled:function(e){var s=this,o=n.f(s),l=o.resolve,h=o.reject,c=r((function(){var n=i(s.resolve),r=[],o=0,h=1;a(e,(function(e){var i=o++,a=!1;h++,t(n,s,e).then((function(e){a||(a=!0,r[i]={status:"fulfilled",value:e},--h||l(r))}),(function(e){a||(a=!0,r[i]={status:"rejected",reason:e},--h||l(r))}))})),--h||l(r)}));return c.error&&h(c.value),o.promise}})})),Iee=Q((()=>{"use strict";var e=rt(),t=wr(),i=Ps(),n=qi(),r=Yd(),a=r0(),s=cc(),o=cx(),l="No one promise resolved";e({target:"Promise",stat:!0,forced:o},{any:function(e){var o=this,h=n("AggregateError"),c=r.f(o),u=c.resolve,d=c.reject,p=a((function(){var n=i(o.resolve),r=[],a=0,c=1,p=!1;s(e,(function(e){var i=a++,s=!1;c++,t(n,o,e).then((function(e){s||p||(p=!0,u(e))}),(function(e){s||p||(s=!0,r[i]=e,--c||d(new h(r,l)))}))})),--c||d(new h(r,l))}));return p.error&&d(p.value),c.promise}})})),kee=Q((()=>{"use strict";var e,t=rt(),i=ss(),n=Wp(),r=Yt(),a=qi(),s=Vr(),o=Up(),l=DO(),h=$i(),c=n&&n.prototype;t({target:"Promise",proto:!0,real:!0,forced:!!n&&r((function(){c.finally.call({then:function(){}},(function(){}))}))},{finally:function(e){var t=o(this,a("Promise")),i=s(e);return this.then(i?function(i){return l(t,e()).then((function(){return i}))}:e,i?function(i){return l(t,e()).then((function(){throw i}))}:e)}}),!i&&s(n)&&(e=a("Promise").prototype.finally,c.finally!==e&&h(c,"finally",e,{unsafe:!0}))})),Fee=Q((()=>{var e=rt(),t=Fo(),i=Ps(),n=br();e({target:"Reflect",stat:!0,forced:!Yt()((function(){Reflect.apply((function(){}))}))},{apply:function(e,r,a){return t(i(e),r,n(a))}})})),Gee=Q((()=>{var e=rt(),t=qi(),i=Fo(),n=ED(),r=$w(),a=br(),s=Cr(),o=eo(),l=Yt(),h=t("Reflect","construct"),c=Object.prototype,u=[].push,d=l((function(){function e(){}return!(h((function(){}),[],e)instanceof e)})),p=!l((function(){h((function(){}))})),f=d||p;e({target:"Reflect",stat:!0,forced:f,sham:f},{construct:function(e,t){r(e),a(t);var l=arguments.length<3?e:r(arguments[2]);if(p&&!d)return h(e,t,l);if(e==l){switch(t.length){case 0:return new e;case 1:return new e(t[0]);case 2:return new e(t[0],t[1]);case 3:return new e(t[0],t[1],t[2]);case 4:return new e(t[0],t[1],t[2],t[3])}var f=[null];return i(u,f,t),new(i(n,e,f))}var m=l.prototype,g=o(s(m)?m:c),v=i(e,g,t);return s(v)?v:g}})})),jee=Q((()=>{var e=rt(),t=rr(),i=br(),n=gh(),r=fi();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){i(e);var s=n(t);i(a);try{return r.f(e,s,a),!0}catch(e){return!1}}})})),Xee=Q((()=>{var e=rt(),t=br(),i=Ks().f;e({target:"Reflect",stat:!0},{deleteProperty:function(e,n){var r=i(t(e),n);return!(r&&!r.configurable)&&delete e[n]}})})),BO=Q(((e,t)=>{var i=Yr();t.exports=function(e){return void 0!==e&&(i(e,"value")||i(e,"writable"))}})),Kee=Q((()=>{var e=rt(),t=wr(),i=Cr(),n=br(),r=BO(),a=Ks(),s=No();e({target:"Reflect",stat:!0},{get:function e(o,l){var h,c,u=arguments.length<3?o:arguments[2];return n(o)===u?o[l]:(h=a.f(o,l))?r(h)?h.value:void 0===h.get?void 0:t(h.get,u):i(c=s(o))?e(c,l,u):void 0}})})),Jee=Q((()=>{var e=rt(),t=rr(),i=br(),n=Ks();e({target:"Reflect",stat:!0,sham:!t},{getOwnPropertyDescriptor:function(e,t){return n.f(i(e),t)}})})),Qee=Q((()=>{var e=rt(),t=br(),i=No();e({target:"Reflect",stat:!0,sham:!Tw()},{getPrototypeOf:function(e){return i(t(e))}})})),ete=Q((()=>{rt()({target:"Reflect",stat:!0},{has:function(e,t){return t in e}})})),tte=Q((()=>{var e=rt(),t=br(),i=Qw();e({target:"Reflect",stat:!0},{isExtensible:function(e){return t(e),i(e)}})})),nte=Q((()=>{rt()({target:"Reflect",stat:!0},{ownKeys:sw()})})),rte=Q((()=>{var e=rt(),t=qi(),i=br();e({target:"Reflect",stat:!0,sham:!Vp()},{preventExtensions:function(e){i(e);try{var n=t("Object","preventExtensions");return n&&n(e),!0}catch(e){return!1}}})})),lte=Q((()=>{var e=rt(),t=wr(),i=br(),n=Cr(),r=BO(),a=Yt(),s=fi(),o=Ks(),l=No(),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,c,u){var d,p,f,m=arguments.length<4?a:arguments[3],g=o.f(i(a),c);if(!g){if(n(p=l(a)))return e(p,c,u,m);g=h(0)}if(r(g)){if(!1===g.writable||!n(m))return!1;if(d=o.f(m,c)){if(d.get||d.set||!1===d.writable)return!1;d.value=u,s.f(m,c,d)}else s.f(m,c,h(0,u))}else{if(void 0===(f=g.set))return!1;t(f,m,u)}return!0}})})),ute=Q((()=>{var e=rt(),t=br(),i=fL(),n=lc();n&&e({target:"Reflect",stat:!0},{setPrototypeOf:function(e,r){t(e),i(r);try{return n(e,r),!0}catch(e){return!1}}})})),hte=Q((()=>{var e=rt(),t=In(),i=to();e({global:!0},{Reflect:{}}),i(t.Reflect,"Reflect",!0)})),c0=Q(((e,t)=>{var i=Cr(),n=Ra(),r=kr()("match");t.exports=function(e){var t;return i(e)&&(void 0!==(t=e[r])?!!t:"RegExp"==n(e))}})),bS=Q(((e,t)=>{"use strict";var i=br();t.exports=function(){var e=i(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}})),u0=Q(((e,t)=>{var i=wr(),n=Yr(),r=ko(),a=bS(),s=RegExp.prototype;t.exports=function(e){var t=e.flags;return void 0!==t||"flags"in s||n(e,"flags")||!r(s,e)?t:i(a,e)}})),ux=Q(((e,t)=>{var i=Yt(),n=In().RegExp,r=i((function(){var e=n("a","y");return e.lastIndex=2,null!=e.exec("abcd")})),a=r||i((function(){return!n("a","y").sticky})),s=r||i((function(){var e=n("^r","gy");return e.lastIndex=2,null!=e.exec("str")}));t.exports={BROKEN_CARET:s,MISSED_STICKY:a,UNSUPPORTED_Y:r}})),ES=Q(((e,t)=>{var i=Yt(),n=In().RegExp;t.exports=i((function(){var e=n(".","s");return!(e.dotAll&&e.exec("\n")&&"s"===e.flags)}))})),GO=Q(((e,t)=>{var i=Yt(),n=In().RegExp;t.exports=i((function(){var e=n("(?<a>b)","g");return"b"!==e.exec("b").groups.a||"bc"!=="b".replace(e,"$<a>c")}))})),Rte=Q((()=>{var e,t,i,n=rr(),r=In(),a=sn(),s=Og(),o=kp(),l=ca(),h=vh().f,c=ko(),u=c0(),d=Fr(),p=u0(),f=ux(),m=pL(),g=$i(),v=Yt(),y=Yr(),x=bs().enforce,b=Np(),_=kr(),w=ES(),S=GO(),M=_("match"),E=r.RegExp,T=E.prototype,A=r.SyntaxError,C=a(T.exec),P=a("".charAt),R=a("".replace),D=a("".indexOf),L=a("".slice),I=/^\?<[^\s\d!#%&*+<=>@^][^\s!#%&*+<=>@^]*>/,O=/a/g,k=/a/g,N=new E(O)!==O,U=f.MISSED_STICKY,F=f.UNSUPPORTED_Y;if(s("RegExp",n&&(!N||U||w||S||v((function(){return k[M]=!1,E(O)!=O||E(k)==k||"/a/i"!=E(O,"i")}))))){for(e=function(t,i){var n,r,a,s,h,f,m=c(T,this),g=u(t),v=void 0===i,b=[],_=t;if(!m&&g&&v&&t.constructor===e)return t;if((g||c(T,t))&&(t=t.source,v&&(i=p(_))),t=void 0===t?"":d(t),i=void 0===i?"":d(i),_=t,w&&"dotAll"in O&&(r=!!i&&D(i,"s")>-1)&&(i=R(i,/s/g,"")),n=i,U&&"sticky"in O&&(a=!!i&&D(i,"y")>-1)&&F&&(i=R(i,/y/g,"")),S&&(s=function(e){for(var t,i=e.length,n=0,r="",a=[],s={},o=!1,l=!1,h=0,c="";n<=i;n++){if("\\"===(t=P(e,n)))t+=P(e,++n);else if("]"===t)o=!1;else if(!o)switch(!0){case"["===t:o=!0;break;case"("===t:C(I,L(e,n+1))&&(n+=2,l=!0),r+=t,h++;continue;case">"===t&&l:if(""===c||y(s,c))throw new A("Invalid capture group name");s[c]=!0,a[a.length]=[c,h],l=!1,c="";continue}l?c+=t:r+=t}return[r,a]}(t),t=s[0],b=s[1]),h=o(E(t,i),m?this:T,e),(r||a||b.length)&&(f=x(h),r&&(f.dotAll=!0,f.raw=e(function(e){for(var t,i=e.length,n=0,r="",a=!1;n<=i;n++)"\\"!==(t=P(e,n))?a||"."!==t?("["===t?a=!0:"]"===t&&(a=!1),r+=t):r+="[\\s\\S]":r+=t+P(e,++n);return r}(t),n)),a&&(f.sticky=!0),b.length&&(f.groups=b)),t!==_)try{l(h,"source",""===_?"(?:)":_)}catch(e){}return h},t=h(E),i=0;t.length>i;)m(e,E,t[i++]);T.constructor=e,e.prototype=T,g(r,"RegExp",e,{constructor:!0})}b("RegExp")})),Cte=Q((()=>{var e=rr(),t=ES(),i=Ra(),n=Xd(),r=bs().get,a=RegExp.prototype,s=TypeError;e&&t&&n(a,"dotAll",{configurable:!0,get:function(){if(this!==a){if("RegExp"===i(this))return!!r(this).dotAll;throw s("Incompatible receiver, RegExp required")}}})})),dx=Q(((e,t)=>{"use strict";var i,n,r=wr(),a=sn(),s=Fr(),o=bS(),l=ux(),h=Ap(),c=eo(),u=bs().get,d=ES(),p=GO(),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),_=(n=/b*/g,r(m,i=/a/,"a"),r(m,n,"a"),0!==i.lastIndex||0!==n.lastIndex),w=l.BROKEN_CARET,S=void 0!==/()??/.exec("")[1];(_||S||w||d||p)&&(g=function(e){var t,i,n,a,l,h,d,p=this,M=u(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,D=0,L=E;if(C&&(P=x(P,"y",""),-1===y(P,"g")&&(P+="g"),L=b(E,p.lastIndex),p.lastIndex>0&&(!p.multiline||p.multiline&&"\n"!==v(E,p.lastIndex-1))&&(R="(?: "+R+")",L=" "+L,D++),i=new RegExp("^(?:"+R+")",P)),S&&(i=new RegExp("^"+R+"$(?!\\s)",P)),_&&(n=p.lastIndex),a=r(m,C?i:p,L),C?a?(a.input=b(a.input,D),a[0]=b(a[0],D),a.index=p.lastIndex,p.lastIndex+=a[0].length):p.lastIndex=0:_&&a&&(p.lastIndex=p.global?a.index+a[0].length:n),S&&a&&a.length>1&&r(f,a[0],i,(function(){for(l=1;l<arguments.length-2;l++)void 0===arguments[l]&&(a[l]=void 0)})),a&&A)for(a.groups=h=c(null),l=0;l<A.length;l++)h[(d=A[l])[0]]=a[d[1]];return a}),t.exports=g})),SS=Q((()=>{"use strict";var e=rt(),t=dx();e({target:"RegExp",proto:!0,forced:/./.exec!==t},{exec:t})})),kte=Q((()=>{var e=In(),t=rr(),i=Xd(),n=bS(),r=Yt(),a=e.RegExp,s=a.prototype;t&&r((function(){var e=!0;try{a(".","d")}catch(t){e=!1}var t={},i="",n=e?"dgimsy":"gimsy",r=function(e,n){Object.defineProperty(t,e,{get:function(){return i+=n,!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)!==n||i!==n}))&&i(s,"flags",{configurable:!0,get:n})})),Nte=Q((()=>{var e=rr(),t=ux().MISSED_STICKY,i=Ra(),n=Xd(),r=bs().get,a=RegExp.prototype,s=TypeError;e&&t&&n(a,"sticky",{configurable:!0,get:function(){if(this!==a){if("RegExp"===i(this))return!!r(this).sticky;throw s("Incompatible receiver, RegExp required")}}})})),Hte=Q((()=>{"use strict";SS();var e,t,i=rt(),n=wr(),r=Vr(),a=br(),s=Fr(),o=(e=!1,(t=/[ac]/).exec=function(){return e=!0,/./.exec.apply(this,arguments)},!0===t.test("abc")&&e),l=/./.test;i({target:"RegExp",proto:!0,forced:!o},{test:function(e){var t=a(this),i=s(e),o=t.exec;if(!r(o))return n(l,t,i);var h=n(o,t,i);return null!==h&&(a(h),!0)}})})),Gte=Q((()=>{"use strict";var e=Pp().PROPER,t=$i(),i=br(),n=Fr(),r=Yt(),a=u0(),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=i(this);return"/"+n(e.source)+"/"+n(a(e))}),{unsafe:!0})})),qte=Q((()=>{"use strict";X1()("Set",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),PD())})),Wte=Q((()=>{qte()})),jte=Q((()=>{"use strict";var e=rt(),t=sn(),i=xs(),n=Is(),r=Fr(),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(i(this)),a=t.length,o=n(e),l=o>=0?o:a+o;return l<0||l>=a?void 0:s(t,l)}})})),fx=Q(((e,t)=>{var i=sn(),n=Is(),r=Fr(),a=xs(),s=i("".charAt),o=i("".charCodeAt),l=i("".slice),h=function(e){return function(t,i){var h,c,u=r(a(t)),d=n(i),p=u.length;return d<0||d>=p?e?"":void 0:(h=o(u,d))<55296||h>56319||d+1===p||(c=o(u,d+1))<56320||c>57343?e?s(u,d):h:e?l(u,d,d+2):c-56320+(h-55296<<10)+65536}};t.exports={codeAt:h(!1),charAt:h(!0)}})),Zte=Q((()=>{"use strict";var e=rt(),t=fx().codeAt;e({target:"String",proto:!0},{codePointAt:function(e){return t(this,e)}})})),MS=Q(((e,t)=>{var i=c0(),n=TypeError;t.exports=function(e){if(i(e))throw n("The method doesn't accept regular expressions");return e}})),RS=Q(((e,t)=>{var i=kr()("match");t.exports=function(e){var t=/./;try{"/./"[e](t)}catch(n){try{return t[i]=!1,"/./"[e](t)}catch(e){}}return!1}})),rne=Q((()=>{"use strict";var e,t=rt(),i=yh(),n=Ks().f,r=Qa(),a=Fr(),s=MS(),o=xs(),l=RS(),h=ss(),c=i("".endsWith),u=i("".slice),d=Math.min,p=l("endsWith");t({target:"String",proto:!0,forced:!(!h&&!p&&(e=n(String.prototype,"endsWith"),e&&!e.writable))&&!p},{endsWith:function(e){var t=a(o(this));s(e);var i=arguments.length>1?arguments[1]:void 0,n=t.length,l=void 0===i?n:d(r(i),n),h=a(e);return c?c(t,h,l):u(t,l-h.length,l)===h}})})),ane=Q((()=>{var e=rt(),t=sn(),i=au(),n=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++],i(t,1114111)!==t)throw n(t+" is not a valid code point");a[l]=t<65536?r(t):r(55296+((t-=65536)>>10),t%1024+56320)}return s(a,"")}})})),lne=Q((()=>{"use strict";var e=rt(),t=sn(),i=MS(),n=xs(),r=Fr(),a=RS(),s=t("".indexOf);e({target:"String",proto:!0,forced:!a("includes")},{includes:function(e){return!!~s(r(n(this)),r(i(e)),arguments.length>1?arguments[1]:void 0)}})})),ek=Q((()=>{"use strict";var e=fx().charAt,t=Fr(),i=bs(),n=Lw(),r=H1(),a="String Iterator",s=i.set,o=i.getterFor(a);n(String,"String",(function(e){s(this,{type:a,string:t(e),index:0})}),(function(){var t,i=o(this),n=i.string,a=i.index;return a>=n.length?r(void 0,!0):(t=e(n,a),i.index+=t.length,r(t,!1))}))})),px=Q(((e,t)=>{"use strict";SS();var i=yh(),n=$i(),r=dx(),a=Yt(),s=kr(),o=ca(),l=s("species"),h=RegExp.prototype;t.exports=function(e,t,c,u){var d=s(e),p=!a((function(){var t={};return t[d]=function(){return 7},7!=""[e](t)})),f=p&&!a((function(){var t=!1,i=/a/;return"split"===e&&((i={}).constructor={},i.constructor[l]=function(){return i},i.flags="",i[d]=/./[d]),i.exec=function(){return t=!0,null},i[d](""),!t}));if(!p||!f||c){var m=i(/./[d]),g=t(d,""[e],(function(e,t,n,a,s){var o=i(e),l=t.exec;return l===r||l===h.exec?p&&!s?{done:!0,value:m(t,n,a)}:{done:!0,value:o(n,t,a)}:{done:!1}}));n(String.prototype,e,g[0]),n(h,d,g[1])}u&&o(h[d],"sham",!0)}})),mx=Q(((e,t)=>{"use strict";var i=fx().charAt;t.exports=function(e,t,n){return t+(n?i(e,t).length:1)}})),f0=Q(((e,t)=>{var i=wr(),n=br(),r=Vr(),a=Ra(),s=dx(),o=TypeError;t.exports=function(e,t){var l=e.exec;if(r(l)){var h=i(l,e,t);return null!==h&&n(h),h}if("RegExp"===a(e))return i(s,e,t);throw o("RegExp#exec called on incompatible receiver")}})),Ene=Q((()=>{"use strict";var e=wr(),t=px(),i=br(),n=Aa(),r=Qa(),a=Fr(),s=xs(),o=su(),l=mx(),h=f0();t("match",(function(t,c,u){return[function(i){var r=s(this),l=n(i)?void 0:o(i,t);return l?e(l,i,r):new RegExp(i)[t](a(r))},function(e){var t=i(this),n=a(e),s=u(c,t,n);if(s.done)return s.value;if(!t.global)return h(t,n);var o=t.unicode;t.lastIndex=0;for(var d,p=[],f=0;null!==(d=h(t,n));){var m=a(d[0]);p[f]=m,""===m&&(t.lastIndex=l(n,r(t.lastIndex),o)),f++}return 0===f?null:p}]}))})),Ine=Q((()=>{"use strict";var e=rt(),t=wr(),i=yh(),n=Cw(),r=H1(),a=xs(),s=Qa(),o=Fr(),l=br(),h=Aa(),c=Ra(),u=c0(),d=u0(),p=su(),f=$i(),m=Yt(),g=kr(),v=Up(),y=mx(),x=f0(),b=bs(),_=ss(),w=g("matchAll"),S="RegExp String",M=S+" Iterator",E=b.set,T=b.getterFor(M),A=RegExp.prototype,C=TypeError,P=i("".indexOf),R=i("".matchAll),D=!!R&&!m((function(){R("a",/./)})),L=n((function(e,t,i,n){E(this,{type:M,regexp:e,string:t,global:i,unicode:n,done:!1})}),S,(function(){var e=T(this);if(e.done)return r(void 0,!0);var t=e.regexp,i=e.string,n=x(t,i);return null===n?(e.done=!0,r(void 0,!0)):e.global?(""===o(n[0])&&(t.lastIndex=y(i,s(t.lastIndex),e.unicode)),r(n,!1)):(e.done=!0,r(n,!1))})),I=function(e){var t,i,n,r=l(this),a=o(e),h=v(r,RegExp),c=o(d(r));return t=new h(h===RegExp?r.source:r,c),i=!!~P(c,"g"),n=!!~P(c,"u"),t.lastIndex=s(r.lastIndex),new L(t,a,i,n)};e({target:"String",proto:!0,forced:D},{matchAll:function(e){var i,n,r,s,l=a(this);if(h(e)){if(D)return R(l,e)}else{if(u(e)&&(i=o(a(d(e))),!~P(i,"g")))throw C("`.matchAll` does not allow non-global regexes");if(D)return R(l,e);if(void 0===(r=p(e,w))&&_&&"RegExp"==c(e)&&(r=I),r)return t(r,e,l)}return n=o(l),s=new RegExp(e,"g"),_?t(I,s,n):s[w](n)}}),_||w in A||f(A,w,I)})),ok=Q(((e,t)=>{var i=ru();t.exports=/Version\/10(?:\.\d+){1,2}(?: [\w./]+)?(?: Mobile\/\w+)? Safari\//.test(i)})),Dne=Q((()=>{"use strict";var e=rt(),t=Zw().end;e({target:"String",proto:!0,forced:ok()},{padEnd:function(e){return t(this,e,arguments.length>1?arguments[1]:void 0)}})})),One=Q((()=>{"use strict";var e=rt(),t=Zw().start;e({target:"String",proto:!0,forced:ok()},{padStart:function(e){return t(this,e,arguments.length>1?arguments[1]:void 0)}})})),Bne=Q((()=>{var e=rt(),t=sn(),i=Ca(),n=ci(),r=Fr(),a=wi(),s=t([].push),o=t([].join);e({target:"String",stat:!0},{raw:function(e){var t=i(n(e).raw),l=a(t);if(!l)return"";for(var h=arguments.length,c=[],u=0;;){if(s(c,r(t[u++])),u===l)return o(c,"");u<h&&s(c,r(arguments[u]))}}})})),Une=Q((()=>{rt()({target:"String",proto:!0},{repeat:W1()})})),hk=Q(((e,t)=>{var i=sn(),n=ci(),r=Math.floor,a=i("".charAt),s=i("".replace),o=i("".slice),l=/\$([$&'`]|\d{1,2}|<[^>]*>)/g,h=/\$([$&'`]|\d{1,2})/g;t.exports=function(e,t,i,c,u,d){var p=i+e.length,f=c.length,m=h;return void 0!==u&&(u=n(u),m=l),s(d,m,(function(n,s){var l;switch(a(s,0)){case"$":return"$";case"&":return e;case"`":return o(t,0,i);case"'":return o(t,p);case"<":l=u[o(s,1,-1)];break;default:var h=+s;if(0===h)return n;if(h>f){var d=r(h/10);return 0===d?n:d<=f?void 0===c[d-1]?a(s,1):c[d-1]+a(s,1):n}l=c[h-1]}return void 0===l?"":l}))}})),Wne=Q((()=>{"use strict";var e=Fo(),t=wr(),i=sn(),n=px(),r=Yt(),a=br(),s=Vr(),o=Aa(),l=Is(),h=Qa(),c=Fr(),u=xs(),d=mx(),p=su(),f=hk(),m=f0(),g=kr()("replace"),v=Math.max,y=Math.min,x=i([].concat),b=i([].push),_=i("".indexOf),w=i("".slice),S=function(e){return void 0===e?e:String(e)},M="$0"==="a".replace(/./,"$0"),E=!!/./[g]&&""===/./[g]("a","$0");n("replace",(function(i,n,r){var M=E?"$":"$0";return[function(e,i){var r=u(this),a=o(e)?void 0:p(e,g);return a?t(a,e,r,i):t(n,c(r),e,i)},function(t,i){var o=a(this),u=c(t);if("string"==typeof i&&-1===_(i,M)&&-1===_(i,"$<")){var p=r(n,o,u,i);if(p.done)return p.value}var g=s(i);g||(i=c(i));var E=o.global;if(E){var T=o.unicode;o.lastIndex=0}for(var A=[];;){var C=m(o,u);if(null===C||(b(A,C),!E))break;""===c(C[0])&&(o.lastIndex=d(u,h(o.lastIndex),T))}for(var P="",R=0,D=0;D<A.length;D++){for(var L=c((C=A[D])[0]),I=v(y(l(C.index),u.length),0),O=[],k=1;k<C.length;k++)b(O,S(C[k]));var N=C.groups;if(g){var U=x([L],O,I,u);void 0!==N&&b(U,N);var F=c(e(i,void 0,U))}else F=f(L,u,I,O,N,i);I>=R&&(P+=w(u,R,I)+F,R=I+L.length)}return P+w(u,R)}]}),!!r((function(){var e=/./;return e.exec=function(){var e=[];return e.groups={a:"7"},e},"7"!=="".replace(e,"$<a>")}))||!M||E)})),Zne=Q((()=>{"use strict";var e=rt(),t=wr(),i=sn(),n=xs(),r=Vr(),a=Aa(),s=c0(),o=Fr(),l=su(),h=u0(),c=hk(),u=kr(),d=ss(),p=u("replace"),f=TypeError,m=i("".indexOf),g=i("".replace),v=i("".slice),y=Math.max,x=function(e,t,i){return i>e.length?-1:""===t?i:m(e,t,i)};e({target:"String",proto:!0},{replaceAll:function(e,i){var u,b,_,w,S,M,E,T,A,C=n(this),P=0,R=0,D="";if(!a(e)){if((u=s(e))&&(b=o(n(h(e))),!~m(b,"g")))throw f("`.replaceAll` does not allow non-global regexes");if(_=l(e,p))return t(_,e,C,i);if(d&&u)return g(o(C),e,i)}for(w=o(C),S=o(e),(M=r(i))||(i=o(i)),E=S.length,T=y(1,E),P=x(w,S,0);-1!==P;)A=M?o(i(S,P,w)):c(S,w,P,[],void 0,i),D+=v(w,R,P)+A,R=P+E,P=x(w,S,P+T);return R<w.length&&(D+=v(w,R)),D}})})),Qne=Q((()=>{"use strict";var e=wr(),t=px(),i=br(),n=Aa(),r=xs(),a=QD(),s=Fr(),o=su(),l=f0();t("search",(function(t,h,c){return[function(i){var a=r(this),l=n(i)?void 0:o(i,t);return l?e(l,i,a):new RegExp(i)[t](s(a))},function(e){var t=i(this),n=s(e),r=c(h,t,n);if(r.done)return r.value;var o=t.lastIndex;a(o,0)||(t.lastIndex=0);var u=l(t,n);return a(t.lastIndex,o)||(t.lastIndex=o),null===u?-1:u.index}]}))})),sre=Q((()=>{"use strict";var e=Fo(),t=wr(),i=sn(),n=px(),r=br(),a=Aa(),s=c0(),o=xs(),l=Up(),h=mx(),c=Qa(),u=Fr(),d=su(),p=Fg(),f=f0(),m=dx(),g=ux(),v=Yt(),y=g.UNSUPPORTED_Y,x=4294967295,b=Math.min,_=[].push,w=i(/./.exec),S=i(_),M=i("".slice);n("split",(function(i,n,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(i,r){var a=u(o(this)),l=void 0===r?x:r>>>0;if(0===l)return[];if(void 0===i)return[a];if(!s(i))return t(n,a,i,l);for(var h,c,d,f=[],g=(i.ignoreCase?"i":"")+(i.multiline?"m":"")+(i.unicode?"u":"")+(i.sticky?"y":""),v=0,y=new RegExp(i.source,g+"g");(h=t(m,y,a))&&!((c=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=c,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,i){return void 0===e&&0===i?[]:t(n,this,e,i)}:n,[function(e,n){var r=o(this),s=a(e)?void 0:d(e,i);return s?t(s,e,r,n):t(v,u(r),e,n)},function(e,t){var i=r(this),a=u(e),s=g(v,i,a,t,v!==n);if(s.done)return s.value;var o=l(i,RegExp),d=i.unicode,p=(i.ignoreCase?"i":"")+(i.multiline?"m":"")+(i.unicode?"u":"")+(y?"g":"y"),m=new o(y?"^(?:"+i.source+")":i,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(c(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 i="ab".split(e);return 2!==i.length||"a"!==i[0]||"b"!==i[1]})),y)})),ure=Q((()=>{"use strict";var e,t=rt(),i=yh(),n=Ks().f,r=Qa(),a=Fr(),s=MS(),o=xs(),l=RS(),h=ss(),c=i("".startsWith),u=i("".slice),d=Math.min,p=l("startsWith");t({target:"String",proto:!0,forced:!(!h&&!p&&(e=n(String.prototype,"startsWith"),e&&!e.writable))&&!p},{startsWith:function(e){var t=a(o(this));s(e);var i=r(d(arguments.length>1?arguments[1]:void 0,t.length)),n=a(e);return c?c(t,n,i):u(t,i,i+n.length)===n}})})),dre=Q((()=>{"use strict";var e=rt(),t=sn(),i=xs(),n=Is(),r=Fr(),a=t("".slice),s=Math.max,o=Math.min;e({target:"String",proto:!0,forced:!"".substr||"b"!=="ab".substr(-1)},{substr:function(e,t){var l,h,c=r(i(this)),u=c.length,d=n(e);return d===1/0&&(d=0),d<0&&(d=s(u+d,0)),(l=void 0===t?u:n(t))<=0||l===1/0||d>=(h=o(d+l,u))?"":a(c,d,h)}})})),LS=Q(((e,t)=>{var i=Pp().PROPER,n=Yt(),r=J1();t.exports=function(e){return n((function(){return!!r[e]()||"\u200b\x85\u180e"!=="\u200b\x85\u180e"[e]()||i&&r[e].name!==e}))}})),gre=Q((()=>{"use strict";var e=rt(),t=zp().trim;e({target:"String",proto:!0,forced:LS()("trim")},{trim:function(){return t(this)}})})),vk=Q(((e,t)=>{"use strict";var i=zp().end,n=LS();t.exports=n("trimEnd")?function(){return i(this)}:"".trimEnd})),xre=Q((()=>{var e=rt(),t=vk();e({target:"String",proto:!0,name:"trimEnd",forced:"".trimRight!==t},{trimRight:t})})),Ere=Q((()=>{xre();var e=rt(),t=vk();e({target:"String",proto:!0,name:"trimEnd",forced:"".trimEnd!==t},{trimEnd:t})})),yk=Q(((e,t)=>{"use strict";var i=zp().start,n=LS();t.exports=n("trimStart")?function(){return i(this)}:"".trimStart})),wre=Q((()=>{var e=rt(),t=yk();e({target:"String",proto:!0,name:"trimStart",forced:"".trimLeft!==t},{trimLeft:t})})),Mre=Q((()=>{wre();var e=rt(),t=yk();e({target:"String",proto:!0,name:"trimStart",forced:"".trimStart!==t},{trimStart:t})})),io=Q(((e,t)=>{var i=sn(),n=xs(),r=Fr(),a=/"/g,s=i("".replace);t.exports=function(e,t,i,o){var l=r(n(e)),h="<"+t;return""!==i&&(h+=" "+i+'="'+s(r(o),a,"&quot;")+'"'),h+">"+l+"</"+t+">"}})),so=Q(((e,t)=>{var i=Yt();t.exports=function(e){return i((function(){var t=""[e]('"');return t!==t.toLowerCase()||t.split('"').length>3}))}})),Pre=Q((()=>{"use strict";var e=rt(),t=io();e({target:"String",proto:!0,forced:so()("anchor")},{anchor:function(e){return t(this,"a","name",e)}})})),Ire=Q((()=>{"use strict";var e=rt(),t=io();e({target:"String",proto:!0,forced:so()("big")},{big:function(){return t(this,"big","","")}})})),Lre=Q((()=>{"use strict";var e=rt(),t=io();e({target:"String",proto:!0,forced:so()("blink")},{blink:function(){return t(this,"blink","","")}})})),Dre=Q((()=>{"use strict";var e=rt(),t=io();e({target:"String",proto:!0,forced:so()("bold")},{bold:function(){return t(this,"b","","")}})})),Ore=Q((()=>{"use strict";var e=rt(),t=io();e({target:"String",proto:!0,forced:so()("fixed")},{fixed:function(){return t(this,"tt","","")}})})),kre=Q((()=>{"use strict";var e=rt(),t=io();e({target:"String",proto:!0,forced:so()("fontcolor")},{fontcolor:function(e){return t(this,"font","color",e)}})})),Fre=Q((()=>{"use strict";var e=rt(),t=io();e({target:"String",proto:!0,forced:so()("fontsize")},{fontsize:function(e){return t(this,"font","size",e)}})})),Nre=Q((()=>{"use strict";var e=rt(),t=io();e({target:"String",proto:!0,forced:so()("italics")},{italics:function(){return t(this,"i","","")}})})),Bre=Q((()=>{"use strict";var e=rt(),t=io();e({target:"String",proto:!0,forced:so()("link")},{link:function(e){return t(this,"a","href",e)}})})),Ure=Q((()=>{"use strict";var e=rt(),t=io();e({target:"String",proto:!0,forced:so()("small")},{small:function(){return t(this,"small","","")}})})),Hre=Q((()=>{"use strict";var e=rt(),t=io();e({target:"String",proto:!0,forced:so()("strike")},{strike:function(){return t(this,"strike","","")}})})),Vre=Q((()=>{"use strict";var e=rt(),t=io();e({target:"String",proto:!0,forced:so()("sub")},{sub:function(){return t(this,"sub","","")}})})),zre=Q((()=>{"use strict";var e=rt(),t=io();e({target:"String",proto:!0,forced:so()("sup")},{sup:function(){return t(this,"sup","","")}})})),DS=Q(((e,t)=>{var i=In(),n=Yt(),r=N1(),a=$r().NATIVE_ARRAY_BUFFER_VIEWS,s=i.ArrayBuffer,o=i.Int8Array;t.exports=!a||!n((function(){o(1)}))||!n((function(){new o(-1)}))||!r((function(e){new o,new o(null),new o(1.5),new o(e)}),!0)||n((function(){return 1!==new o(new s(2),1,void 0).length}))})),jre=Q(((e,t)=>{var i=Is(),n=RangeError;t.exports=function(e){var t=i(e);if(t<0)throw n("The argument can't be less than 0");return t}})),bk=Q(((e,t)=>{var i=jre(),n=RangeError;t.exports=function(e,t){var r=i(e);if(r%t)throw n("Wrong offset");return r}})),$re=Q(((e,t)=>{var i=oc();t.exports=function(e){var t=i(e);return"BigInt64Array"==t||"BigUint64Array"==t}})),Ek=Q(((e,t)=>{var i=b1(),n=TypeError;t.exports=function(e){var t=i(e,"number");if("number"==typeof t)throw n("Can't convert number to bigint");return BigInt(t)}})),_k=Q(((e,t)=>{var i=dl(),n=wr(),r=$w(),a=ci(),s=wi(),o=O1(),l=zg(),h=ww(),c=$re(),u=$r().aTypedArrayConstructor,d=Ek();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=n(x,y)).done;)_.push(v.value);for(M&&w>2&&(S=i(S,arguments[2])),p=s(_),f=new(u(b))(p),m=c(f),t=0;p>t;t++)g=M?S(_[t],t):_[t],f[t]=m?d(g):+g;return f}})),pu=Q(((e,t)=>{"use strict";var i=rt(),n=In(),r=wr(),a=rr(),s=DS(),o=$r(),l=q1(),h=uc(),c=Oo(),u=ca(),d=oS(),p=Qa(),f=QL(),m=bk(),g=gh(),v=Yr(),y=oc(),x=Cr(),b=Od(),_=eo(),w=ko(),S=lc(),M=vh().f,E=_k(),T=Us().forEach,A=Np(),C=fi(),P=Ks(),R=bs(),D=kp(),L=R.get,I=R.set,O=R.enforce,k=C.f,N=P.f,U=Math.round,F=n.RangeError,B=l.ArrayBuffer,z=B.prototype,H=l.DataView,V=o.NATIVE_ARRAY_BUFFER_VIEWS,j=o.TYPED_ARRAY_TAG,G=o.TypedArray,W=o.TypedArrayPrototype,X=o.aTypedArrayConstructor,Y=o.isTypedArray,q="BYTES_PER_ELEMENT",Z="Wrong length",Q=function(e,t){X(e);for(var i=0,n=t.length,r=new e(n);n>i;)r[i]=t[i++];return r},J=function(e,t){k(e,t,{get:function(){return L(this)[t]}})},K=function(e){var t;return w(z,e)||"ArrayBuffer"==(t=y(e))||"SharedArrayBuffer"==t},$=function(e,t){return Y(e)&&!b(t)&&t in e&&d(+t)&&t>=0},ee=function(e,t){return t=g(t),$(e,t)?c(2,e[t]):N(e,t)},te=function(e,t,i){return t=g(t),!($(e,t)&&x(i)&&v(i,"value"))||v(i,"get")||v(i,"set")||i.configurable||v(i,"writable")&&!i.writable||v(i,"enumerable")&&!i.enumerable?k(e,t,i):(e[t]=i.value,e)};a?(V||(P.f=ee,C.f=te,J(W,"buffer"),J(W,"byteOffset"),J(W,"byteLength"),J(W,"length")),i({target:"Object",stat:!0,forced:!V},{getOwnPropertyDescriptor:ee,defineProperty:te}),t.exports=function(e,t,a){var o=e.match(/\d+$/)[0]/8,l=e+(a?"Clamped":"")+"Array",c="get"+e,d="set"+e,g=n[l],v=g,y=v&&v.prototype,b={},w=function(e,t){k(e,t,{get:function(){return function(e,t){var i=L(e);return i.view[c](t*o+i.byteOffset,!0)}(this,t)},set:function(e){return function(e,t,i){var n=L(e);a&&(i=(i=U(i))<0?0:i>255?255:255&i),n.view[d](t*o+n.byteOffset,i,!0)}(this,t,e)},enumerable:!0})};V?s&&(v=t((function(e,t,i,n){return h(e,y),D(x(t)?K(t)?void 0!==n?new g(t,m(i,o),n):void 0!==i?new g(t,m(i,o)):new g(t):Y(t)?Q(v,t):r(E,v,t):new g(f(t)),e,v)})),S&&S(v,G),T(M(g),(function(e){e in v||u(v,e,g[e])})),v.prototype=y):(v=t((function(e,t,i,n){h(e,y);var a,s,l,c=0,u=0;if(x(t)){if(!K(t))return Y(t)?Q(v,t):r(E,v,t);a=t,u=m(i,o);var d=t.byteLength;if(void 0===n){if(d%o||(s=d-u)<0)throw F(Z)}else if((s=p(n)*o)+u>d)throw F(Z);l=s/o}else l=f(t),a=new B(s=l*o);for(I(e,{buffer:a,byteOffset:u,byteLength:s,length:l,view:new H(a)});c<l;)w(e,c++)})),S&&S(v,G),y=v.prototype=_(W)),y.constructor!==v&&u(y,"constructor",v),O(y).TypedArrayConstructor=v,j&&u(y,j,l);var C=v!=g;b[l]=v,i({global:!0,constructor:!0,forced:C,sham:!V},b),q in v||u(v,q,o),q in y||u(y,q,o),A(l)}):t.exports=function(){}})),gie=Q((()=>{pu()("Float32",(function(e){return function(t,i,n){return e(this,t,i,n)}}))})),vie=Q((()=>{pu()("Float64",(function(e){return function(t,i,n){return e(this,t,i,n)}}))})),yie=Q((()=>{pu()("Int8",(function(e){return function(t,i,n){return e(this,t,i,n)}}))})),xie=Q((()=>{pu()("Int16",(function(e){return function(t,i,n){return e(this,t,i,n)}}))})),bie=Q((()=>{pu()("Int32",(function(e){return function(t,i,n){return e(this,t,i,n)}}))})),Eie=Q((()=>{pu()("Uint8",(function(e){return function(t,i,n){return e(this,t,i,n)}}))})),_ie=Q((()=>{pu()("Uint8",(function(e){return function(t,i,n){return e(this,t,i,n)}}),!0)})),Tie=Q((()=>{pu()("Uint16",(function(e){return function(t,i,n){return e(this,t,i,n)}}))})),wie=Q((()=>{pu()("Uint32",(function(e){return function(t,i,n){return e(this,t,i,n)}}))})),Mie=Q((()=>{"use strict";var e=$r(),t=wi(),i=Is(),n=e.aTypedArray;(0,e.exportTypedArrayMethod)("at",(function(e){var r=n(this),a=t(r),s=i(e),o=s>=0?s:a+s;return o<0||o>=a?void 0:r[o]}))})),Aie=Q((()=>{"use strict";var e=sn(),t=$r(),i=e(IL()),n=t.aTypedArray;(0,t.exportTypedArrayMethod)("copyWithin",(function(e,t){return i(n(this),e,t,arguments.length>2?arguments[2]:void 0)}))})),Pie=Q((()=>{"use strict";var e=$r(),t=Us().every,i=e.aTypedArray;(0,e.exportTypedArrayMethod)("every",(function(e){return t(i(this),e,arguments.length>1?arguments[1]:void 0)}))})),Lie=Q((()=>{"use strict";var e=$r(),t=Aw(),i=Ek(),n=oc(),r=wr(),a=sn(),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(n(this),0,3)?i(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})))})),Oie=Q(((e,t)=>{var i=wi();t.exports=function(e,t){for(var n=0,r=i(t),a=new e(r);r>n;)a[n]=t[n++];return a}})),_x=Q(((e,t)=>{var i=$r(),n=Up(),r=i.aTypedArrayConstructor,a=i.getTypedArrayConstructor;t.exports=function(e){return r(n(e,a(e)))}})),Bie=Q(((e,t)=>{var i=Oie(),n=_x();t.exports=function(e,t){return i(n(e),t)}})),Hie=Q((()=>{"use strict";var e=$r(),t=Us().filter,i=Bie(),n=e.aTypedArray;(0,e.exportTypedArrayMethod)("filter",(function(e){var r=t(n(this),e,arguments.length>1?arguments[1]:void 0);return i(this,r)}))})),zie=Q((()=>{"use strict";var e=$r(),t=Us().find,i=e.aTypedArray;(0,e.exportTypedArrayMethod)("find",(function(e){return t(i(this),e,arguments.length>1?arguments[1]:void 0)}))})),qie=Q((()=>{"use strict";var e=$r(),t=Us().findIndex,i=e.aTypedArray;(0,e.exportTypedArrayMethod)("findIndex",(function(e){return t(i(this),e,arguments.length>1?arguments[1]:void 0)}))})),jie=Q((()=>{"use strict";var e=$r(),t=F1().findLast,i=e.aTypedArray;(0,e.exportTypedArrayMethod)("findLast",(function(e){return t(i(this),e,arguments.length>1?arguments[1]:void 0)}))})),Yie=Q((()=>{"use strict";var e=$r(),t=F1().findLastIndex,i=e.aTypedArray;(0,e.exportTypedArrayMethod)("findLastIndex",(function(e){return t(i(this),e,arguments.length>1?arguments[1]:void 0)}))})),Zie=Q((()=>{"use strict";var e=$r(),t=Us().forEach,i=e.aTypedArray;(0,e.exportTypedArrayMethod)("forEach",(function(e){t(i(this),e,arguments.length>1?arguments[1]:void 0)}))})),Kie=Q((()=>{"use strict";var e=DS();(0,$r().exportTypedArrayStaticMethod)("from",_k(),e)})),Qie=Q((()=>{"use strict";var e=$r(),t=Dg().includes,i=e.aTypedArray;(0,e.exportTypedArrayMethod)("includes",(function(e){return t(i(this),e,arguments.length>1?arguments[1]:void 0)}))})),tse=Q((()=>{"use strict";var e=$r(),t=Dg().indexOf,i=e.aTypedArray;(0,e.exportTypedArrayMethod)("indexOf",(function(e){return t(i(this),e,arguments.length>1?arguments[1]:void 0)}))})),ase=Q((()=>{"use strict";var e=In(),t=Yt(),i=sn(),n=$r(),r=V1(),a=kr()("iterator"),s=e.Uint8Array,o=i(r.values),l=i(r.keys),h=i(r.entries),c=n.aTypedArray,u=n.exportTypedArrayMethod,d=s&&s.prototype,p=!t((function(){d[a].call([1])})),f=!!d&&d.values&&d[a]===d.values&&"values"===d.values.name,m=function(){return o(c(this))};u("entries",(function(){return h(c(this))}),p),u("keys",(function(){return l(c(this))}),p),u("values",m,p||!f,{name:"values"}),u(a,m,p||!f,{name:"values"})})),lse=Q((()=>{"use strict";var e=$r(),t=sn(),i=e.aTypedArray,n=e.exportTypedArrayMethod,r=t([].join);n("join",(function(e){return r(i(this),e)}))})),use=Q((()=>{"use strict";var e=$r(),t=Fo(),i=jL(),n=e.aTypedArray;(0,e.exportTypedArrayMethod)("lastIndexOf",(function(e){var r=arguments.length;return t(i,n(this),r>1?[e,arguments[1]]:[e])}))})),dse=Q((()=>{"use strict";var e=$r(),t=Us().map,i=_x(),n=e.aTypedArray;(0,e.exportTypedArrayMethod)("map",(function(e){return t(n(this),e,arguments.length>1?arguments[1]:void 0,(function(e,t){return new(i(e))(t)}))}))})),pse=Q((()=>{"use strict";var e=$r(),t=DS(),i=e.aTypedArrayConstructor;(0,e.exportTypedArrayStaticMethod)("of",(function(){for(var e=0,t=arguments.length,n=new(i(this))(t);t>e;)n[e]=arguments[e++];return n}),t)})),gse=Q((()=>{"use strict";var e=$r(),t=z1().left,i=e.aTypedArray;(0,e.exportTypedArrayMethod)("reduce",(function(e){var n=arguments.length;return t(i(this),e,n,n>1?arguments[1]:void 0)}))})),yse=Q((()=>{"use strict";var e=$r(),t=z1().right,i=e.aTypedArray;(0,e.exportTypedArrayMethod)("reduceRight",(function(e){var n=arguments.length;return t(i(this),e,n,n>1?arguments[1]:void 0)}))})),bse=Q((()=>{"use strict";var e=$r(),t=e.aTypedArray,i=e.exportTypedArrayMethod,n=Math.floor;i("reverse",(function(){for(var e,i=this,r=t(i).length,a=n(r/2),s=0;s<a;)e=i[s],i[s++]=i[--r],i[r]=e;return i}))})),Mse=Q((()=>{"use strict";var e=In(),t=wr(),i=$r(),n=wi(),r=bk(),a=ci(),s=Yt(),o=e.RangeError,l=e.Int8Array,h=l&&l.prototype,c=h&&h.set,u=i.aTypedArray,d=i.exportTypedArrayMethod,p=!s((function(){var e=new Uint8ClampedArray(2);return t(c,e,{length:1,0:3},1),3!==e[1]})),f=p&&i.NATIVE_ARRAY_BUFFER_VIEWS&&s((function(){var e=new l(2);return e.set(1),e.set("2",1),0!==e[0]||2!==e[1]}));d("set",(function(e){u(this);var i=r(arguments.length>1?arguments[1]:void 0,1),s=a(e);if(p)return t(c,this,s,i);var l=this.length,h=n(s),d=0;if(h+i>l)throw o("Wrong length");for(;d<h;)this[i+d]=s[d++]}),!p||f)})),Ase=Q((()=>{"use strict";var e=$r(),t=_x(),i=Yt(),n=Bd(),r=e.aTypedArray;(0,e.exportTypedArrayMethod)("slice",(function(e,i){for(var a=n(r(this),e,i),s=t(this),o=0,l=a.length,h=new s(l);l>o;)h[o]=a[o++];return h}),i((function(){new Int8Array(1).slice()})))})),Pse=Q((()=>{"use strict";var e=$r(),t=Us().some,i=e.aTypedArray;(0,e.exportTypedArrayMethod)("some",(function(e){return t(i(this),e,arguments.length>1?arguments[1]:void 0)}))})),Fse=Q((()=>{"use strict";var e=In(),t=yh(),i=Yt(),n=Ps(),r=kw(),a=$r(),s=$L(),o=ZL(),l=iu(),h=Fw(),c=a.aTypedArray,u=a.exportTypedArrayMethod,d=e.Uint16Array,p=d&&t(d.prototype.sort),f=!(!p||i((function(){p(new d(2),null)}))&&i((function(){p(new d(2),{})}))),m=!!p&&!i((function(){if(l)return l<74;if(s)return s<67;if(o)return!0;if(h)return h<602;var e,t,i=new d(516),n=Array(516);for(e=0;e<516;e++)t=e%4,i[e]=515-e,n[e]=e-2*t+3;for(p(i,(function(e,t){return(e/4|0)-(t/4|0)})),e=0;e<516;e++)if(i[e]!==n[e])return!0}));u("sort",(function(e){return void 0!==e&&n(e),m?p(this,e):r(c(this),(t=e,function(e,i){return void 0!==t?+t(e,i)||0:i!=i?-1:e!=e?1:0===e&&0===i?1/e>0&&1/i<0?1:-1:e>i}));var t}),!m||f)})),Use=Q((()=>{"use strict";var e=$r(),t=Qa(),i=au(),n=_x(),r=e.aTypedArray;(0,e.exportTypedArrayMethod)("subarray",(function(e,a){var s=r(this),o=s.length,l=i(e,o);return new(n(s))(s.buffer,s.byteOffset+l*s.BYTES_PER_ELEMENT,t((void 0===a?o:i(a,o))-l))}))})),qse=Q((()=>{"use strict";var e=In(),t=Fo(),i=$r(),n=Yt(),r=Bd(),a=e.Int8Array,s=i.aTypedArray,o=i.exportTypedArrayMethod,l=[].toLocaleString,h=!!a&&n((function(){l.call(new a(1))}));o("toLocaleString",(function(){return t(l,h?r(s(this)):s(this),r(arguments))}),n((function(){return[1,2].toLocaleString()!=new a([1,2]).toLocaleString()}))||!n((function(){a.prototype.toLocaleString.call([1,2])})))})),jse=Q((()=>{"use strict";var e=$r().exportTypedArrayMethod,t=Yt(),i=In(),n=sn(),r=i.Uint8Array,a=r&&r.prototype||{},s=[].toString,o=n([].join);t((function(){s.call({})}))&&(s=function(){return o(this)});var l=a.toString!=s;e("toString",s,l)})),Kse=Q((()=>{"use strict";var e=rt(),t=sn(),i=Fr(),n=String.fromCharCode,r=t("".charAt),a=t(/./.exec),s=t("".slice),o=/^[\da-f]{2}$/i,l=/^[\da-f]{4}$/i;e({global:!0},{unescape:function(e){for(var t,h,c=i(e),u="",d=c.length,p=0;p<d;){if("%"===(t=r(c,p++)))if("u"===r(c,p)){if(h=s(c,p+1,p+5),a(l,h)){u+=n(parseInt(h,16)),p+=5;continue}}else if(h=s(c,p,p+2),a(o,h)){u+=n(parseInt(h,16)),p+=2;continue}u+=t}return u}})})),qk=Q(((e,t)=>{"use strict";var i=sn(),n=jg(),r=jd().getWeakData,a=uc(),s=br(),o=Aa(),l=Cr(),h=cc(),c=Us(),u=Yr(),d=bs(),p=d.set,f=d.getterFor,m=c.find,g=c.findIndex,v=i([].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 i=_(this,e);i?i[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,i,c){var d=e((function(e,n){a(e,m),p(e,{type:t,id:y++,frozen:void 0}),o(n)||h(n,e[c],{that:e,AS_ENTRIES:i})})),m=d.prototype,g=f(t),v=function(e,t,i){var n=g(e),a=r(s(t),!0);return!0===a?x(n).set(t,i):a[n.id]=i,e};return n(m,{delete:function(e){var t=g(this);if(!l(e))return!1;var i=r(e);return!0===i?x(t).delete(e):i&&u(i,t.id)&&delete i[t.id]},has:function(e){var t=g(this);if(!l(e))return!1;var i=r(e);return!0===i?x(t).has(e):i&&u(i,t.id)}}),n(m,i?{get:function(e){var t=g(this);if(l(e)){var i=r(e);return!0===i?x(t).get(e):i?i[t.id]:void 0}},set:function(e,t){return v(this,e,t)}}:{add:function(e){return v(this,e,!0)}}),d}}})),fae=Q((()=>{"use strict";var e,t,i,n,r=Vp(),a=In(),s=sn(),o=jg(),l=jd(),h=X1(),c=qk(),u=Cr(),d=bs().enforce,p=Yt(),f=D3(),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,c),A=T.prototype,C=s(A.set);f&&(M?(e=c.getConstructor(E,"WeakMap",!0),l.enable(),t=s(A.delete),i=s(A.has),n=s(A.get),o(A,{delete:function(i){if(u(i)&&!v(i)){var n=d(this);return n.frozen||(n.frozen=new e),t(this,i)||n.frozen.delete(i)}return t(this,i)},has:function(t){if(u(t)&&!v(t)){var n=d(this);return n.frozen||(n.frozen=new e),i(this,t)||n.frozen.has(t)}return i(this,t)},get:function(t){if(u(t)&&!v(t)){var r=d(this);return r.frozen||(r.frozen=new e),i(this,t)?n(this,t):r.frozen.get(t)}return n(this,t)},set:function(t,n){if(u(t)&&!v(t)){var r=d(this);r.frozen||(r.frozen=new e),i(this,t)?C(this,t,n):r.frozen.set(t,n)}else C(this,t,n);return this}})):r&&p((function(){var e=b([]);return C(new T,e,1),!y(e)}))&&o(A,{set:function(e,t){var i;return g(e)&&(y(e)?i=w:x(e)&&(i=S)),C(this,e,t),i==w&&b(e),i==S&&_(e),this}}))})),pae=Q((()=>{fae()})),mae=Q((()=>{"use strict";X1()("WeakSet",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),qk())})),gae=Q((()=>{mae()})),Xk=Q(((e,t)=>{var i,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",r={};for(i=0;i<66;i++)r[n.charAt(i)]=i;t.exports={itoc:n,ctoi:r}})),Sae=Q((()=>{var e=rt(),t=In(),i=qi(),n=sn(),r=wr(),a=Yt(),s=Fr(),o=Yr(),l=Ah(),h=Xk().ctoi,c=/[^\d+/a-z]/i,u=/[\t\n\f\r ]+/g,d=/[=]+$/,p=i("atob"),f=String.fromCharCode,m=n("".charAt),g=n("".replace),v=n(c.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 n,a,y=g(s(e),u,""),x="",w=0,S=0;if(y.length%4==0&&(y=g(y,d,"")),y.length%4==1||v(c,y))throw new(i("DOMException"))("The string is not correctly encoded","InvalidCharacterError");for(;n=m(y,w++);)o(h,n)&&(a=S%4?64*a+h[n]:h[n],S++%4&&(x+=f(255&a>>(-2*S&6))));return x}})})),Oae=Q((()=>{var e=rt(),t=In(),i=qi(),n=sn(),r=wr(),a=Yt(),s=Fr(),o=Ah(),l=Xk().itoc,h=i("btoa"),c=n("".charAt),u=n("".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 n,a,m=s(e),g="",v=0,y=l;c(m,v)||(y="=",v%1);){if((a=u(m,v+=3/4))>255)throw new(i("DOMException"))("The string contains characters outside of the Latin1 range","InvalidCharacterError");g+=c(y,63&(n=n<<8|a)>>8-v%1*8)}return g}})})),Qk=Q(((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}})),tF=Q(((e,t)=>{var i=E1()("span").classList,n=i&&i.constructor&&i.constructor.prototype;t.exports=n===Object.prototype?void 0:n})),Vae=Q((()=>{var e,t=In(),i=Qk(),n=tF(),r=kL(),a=ca(),s=function(e){if(e&&e.forEach!==r)try{a(e,"forEach",r)}catch(t){e.forEach=r}};for(e in i)i[e]&&s(t[e]&&t[e].prototype);s(n)})),Xae=Q((()=>{var e,t=In(),i=Qk(),n=tF(),r=V1(),a=ca(),s=kr(),o=s("iterator"),l=s("toStringTag"),h=r.values,c=function(e,t){if(e){if(e[o]!==h)try{a(e,o,h)}catch(t){e[o]=h}if(e[l]||a(e,l,t),i[t])for(var n in r)if(e[n]!==r[n])try{a(e,n,r[n])}catch(t){e[n]=r[n]}}};for(e in i)c(t[e]&&t[e].prototype,e);c(n,"DOMTokenList")})),$ae=Q(((e,t)=>{var i=uu();t.exports=function(e){try{if(i)return Function('return require("'+e+'")')()}catch(e){}}})),aF=Q(((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}}})),ooe=Q((()=>{"use strict";var e=rt(),t=$ae(),i=qi(),n=Yt(),r=eo(),a=Oo(),s=fi().f,o=$i(),l=Xd(),h=Yr(),c=uc(),u=br(),d=EL(),p=Hg(),f=aF(),m=bw(),g=bs(),v=rr(),y=ss(),x="DOMException",b="DATA_CLONE_ERR",_=i("Error"),w=i(x)||function(){try{(new(i("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(){c(this,R);var e=arguments.length,t=p(e<1?void 0:arguments[0]),i=p(e<2?void 0:arguments[1],"Error"),n=C(i);if(E(this,{type:x,name:i,message:t,code:n}),v||(this.name=i,this.message=t,this.code=n),A){var r=_(t);r.name=x,s(this,"stack",a(1,m(r.stack,1)))}},R=P.prototype=r(M),D=function(e){return{enumerable:!0,configurable:!0,get:e}},L=function(e){return D((function(){return T(this)[e]}))};v&&(l(R,"code",L("code")),l(R,"message",L("message")),l(R,"name",L("name"))),s(R,"constructor",a(1,P));var I=n((function(){return!(new w instanceof _)})),O=I||n((function(){return M.toString!==d||"2: 1"!==String(new w(1,2))})),k=I||n((function(){return 25!==new w(1,"DataCloneError").code})),N=I||25!==w[b]||25!==S[b],U=y?O||k||N:I;e({global:!0,constructor:!0,forced:U},{DOMException:U?P:w});var F,B,z,H,V=i(x),j=V.prototype;for(H in O&&(y||w===V)&&o(j,"toString",d),k&&v&&w===V&&l(j,"code",D((function(){return C(u(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))})),poe=Q((()=>{"use strict";var e=rt(),t=In(),i=qi(),n=Oo(),r=fi().f,a=Yr(),s=uc(),o=kp(),l=Hg(),h=aF(),c=bw(),u=rr(),d=ss(),p="DOMException",f=i("Error"),m=i(p),g=function(){s(this,v);var e=arguments.length,t=l(e<1?void 0:arguments[0]),i=l(e<2?void 0:arguments[1],"Error"),a=new m(t,i),h=f(t);return h.name=p,r(a,"stack",n(1,c(h.stack,1))),o(a,this,g),a},v=g.prototype=m.prototype,y="stack"in f(p),x="stack"in new m(1,2),b=m&&u&&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=i(p),A=T.prototype;if(A.constructor!==T)for(E in d||r(A,"constructor",n(1,T)),h)a(h,E)&&(a(T,M=(S=h[E]).s)||r(T,M,n(6,S.c)))})),goe=Q((()=>{var e=qi(),t="DOMException";to()(e(t),t)})),yoe=Q((()=>{var e=rt(),t=In(),i=sx().clear;e({global:!0,bind:!0,enumerable:!0,forced:t.clearImmediate!==i},{clearImmediate:i})})),boe=Q(((e,t)=>{t.exports="function"==typeof Bun&&Bun&&"string"==typeof Bun.version})),iM=Q(((e,t)=>{"use strict";var i,n=In(),r=Fo(),a=Vr(),s=boe(),o=ru(),l=Bd(),h=Ah(),c=n.Function,u=/MSIE .\./.test(o)||s&&((i=n.Bun.version.split(".")).length<3||0==i[0]&&(i[1]<3||3==i[1]&&0==i[2]));t.exports=function(e,t){var i=t?2:1;return u?function(n,s){var o=h(arguments.length,1)>i,u=a(n)?n:c(n),d=o?l(arguments,i):[],p=o?function(){r(u,this,d)}:u;return t?e(p,s):e(p)}:e}})),Moe=Q((()=>{var e=rt(),t=In(),i=sx().set,n=iM(),r=t.setImmediate?n(i,!1):i;e({global:!0,bind:!0,enumerable:!0,forced:t.setImmediate!==r},{setImmediate:r})})),Roe=Q((()=>{yoe(),Moe()})),Aoe=Q((()=>{var e=rt(),t=In(),i=xO(),n=Ps(),r=Ah(),a=uu(),s=t.process;e({global:!0,enumerable:!0,dontCallGetSet:!0},{queueMicrotask:function(e){r(arguments.length,1),n(e);var t=a&&s.domain;i(t?t.bind(e):e)}})})),Poe=Q((()=>{"use strict";var e,t=rt(),i=In(),n=Xd(),r=rr(),a=TypeError,s=Object.defineProperty,o=i.self!==i;try{r?(e=Object.getOwnPropertyDescriptor(i,"self"),(o||!e||!e.get||!e.enumerable)&&n(i,"self",{get:function(){return i},set:function(e){if(this!==i)throw a("Illegal invocation");s(i,"self",{value:e,writable:!0,configurable:!0,enumerable:!0})},configurable:!0,enumerable:!0})):t({global:!0,simple:!0,forced:o},{self:i})}catch(e){}})),Loe=Q(((e,t)=>{var i=sn(),n=Map.prototype;t.exports={Map:Map,set:i(n.set),get:i(n.get),has:i(n.has),remove:i(n.delete),proto:n}})),Ooe=Q(((e,t)=>{var i=sn(),n=Set.prototype;t.exports={Set:Set,add:i(n.add),has:i(n.has),remove:i(n.delete),proto:n,$has:n.has,$keys:n.keys}})),qoe=Q((()=>{var e,t=ss(),i=rt(),n=In(),r=qi(),a=sn(),s=Yt(),o=Cp(),l=Vr(),h=Lp(),c=Aa(),u=Cr(),d=Od(),p=cc(),f=br(),m=oc(),g=Yr(),v=ou(),y=ca(),x=wi(),b=Ah(),_=u0(),w=Loe(),S=Ooe(),M=gL(),E=iu(),T=bO(),A=dS(),C=uu(),P=n.Object,R=n.Array,D=n.Date,L=n.Error,I=n.EvalError,O=n.RangeError,k=n.ReferenceError,N=n.SyntaxError,U=n.TypeError,F=n.URIError,B=n.PerformanceMark,z=n.WebAssembly,H=z&&z.CompileError||L,V=z&&z.LinkError||L,j=z&&z.RuntimeError||L,G=r("DOMException"),W=w.Map,X=w.has,Y=w.get,q=w.set,Z=S.Set,Q=S.add,J=r("Object","keys"),K=a([].push),$=a((!0).valueOf),ee=a(1..valueOf),te=a("".valueOf),ie=a(D.prototype.getTime),ne=o("structuredClone"),re="DataCloneError",ae="Transferring",se=function(e){return!s((function(){var t=new n.Set([7]),i=e(t),r=e(P(7));return i==t||!i.has(7)||"object"!=typeof r||7!=r}))&&e},oe=function(e,t){return!s((function(){var i=new t,n=e({a:i,b:i});return!(n&&n.a===n.b&&n.a instanceof t&&n.a.stack===i.stack)}))},le=n.structuredClone,he=t||!oe(le,L)||!oe(le,G)||(e=le,!!s((function(){var t=e(new n.AggregateError([1],ne,{cause:3}));return"AggregateError"!=t.name||1!=t.errors[0]||t.message!=ne||3!=t.cause}))),ce=!le&&se((function(e){return new B(ne,{detail:e}).detail})),ue=se(le)||ce,de=function(e){throw new G("Uncloneable type: "+e,re)},pe=function(e,t){throw new G((t||"Cloning")+" of "+e+" cannot be properly polyfilled in this engine",re)},fe=function(e,t){if(d(e)&&de("Symbol"),!u(e))return e;if(t){if(X(t,e))return Y(t,e)}else t=new W;var i,a,s,o,h,c,p,f,b,w,S=m(e),E=!1;switch(S){case"Array":s=R(x(e)),E=!0;break;case"Object":s={},E=!0;break;case"Map":s=new W,E=!0;break;case"Set":s=new Z,E=!0;break;case"RegExp":s=new RegExp(e.source,_(e));break;case"Error":switch(a=e.name){case"AggregateError":s=r("AggregateError")([]);break;case"EvalError":s=I();break;case"RangeError":s=O();break;case"ReferenceError":s=k();break;case"SyntaxError":s=N();break;case"TypeError":s=U();break;case"URIError":s=F();break;case"CompileError":s=H();break;case"LinkError":s=V();break;case"RuntimeError":s=j();break;default:s=L()}E=!0;break;case"DOMException":s=new G(e.message,e.name),E=!0;break;case"DataView":case"Int8Array":case"Uint8Array":case"Uint8ClampedArray":case"Int16Array":case"Uint16Array":case"Int32Array":case"Uint32Array":case"Float32Array":case"Float64Array":case"BigInt64Array":case"BigUint64Array":i=n[S],u(i)||pe(S),s=new i(fe(e.buffer,t),e.byteOffset,"DataView"===S?e.byteLength:e.length);break;case"DOMQuad":try{s=new DOMQuad(fe(e.p1,t),fe(e.p2,t),fe(e.p3,t),fe(e.p4,t))}catch(t){ue?s=ue(e):pe(S)}break;case"FileList":if(o=function(){var e;try{e=new n.DataTransfer}catch(t){try{e=new n.ClipboardEvent("").clipboardData}catch(e){}}return e&&e.items&&e.files?e:null}(),o){for(h=0,c=x(e);h<c;h++)o.items.add(fe(e[h],t));s=o.files}else ue?s=ue(e):pe(S);break;case"ImageData":try{s=new ImageData(fe(e.data,t),e.width,e.height,{colorSpace:e.colorSpace})}catch(t){ue?s=ue(e):pe(S)}break;default:if(ue)s=ue(e);else switch(S){case"BigInt":s=P(e.valueOf());break;case"Boolean":s=P($(e));break;case"Number":s=P(ee(e));break;case"String":s=P(te(e));break;case"Date":s=new D(ie(e));break;case"ArrayBuffer":!(i=n.DataView)&&"function"!=typeof e.slice&&pe(S);try{if("function"==typeof e.slice)s=e.slice(0);else for(c=e.byteLength,s=new ArrayBuffer(c),b=new i(e),w=new i(s),h=0;h<c;h++)w.setUint8(h,b.getUint8(h))}catch(e){throw new G("ArrayBuffer is detached",re)}break;case"SharedArrayBuffer":s=e;break;case"Blob":try{s=e.slice(0,e.size,e.type)}catch(e){pe(S)}break;case"DOMPoint":case"DOMPointReadOnly":i=n[S];try{s=i.fromPoint?i.fromPoint(e):new i(e.x,e.y,e.z,e.w)}catch(e){pe(S)}break;case"DOMRect":case"DOMRectReadOnly":i=n[S];try{s=i.fromRect?i.fromRect(e):new i(e.x,e.y,e.width,e.height)}catch(e){pe(S)}break;case"DOMMatrix":case"DOMMatrixReadOnly":i=n[S];try{s=i.fromMatrix?i.fromMatrix(e):new i(e)}catch(e){pe(S)}break;case"AudioData":case"VideoFrame":l(e.clone)||pe(S);try{s=e.clone()}catch(e){de(S)}break;case"File":try{s=new File([e],e.name,e)}catch(e){pe(S)}break;case"CropTarget":case"CryptoKey":case"FileSystemDirectoryHandle":case"FileSystemFileHandle":case"FileSystemHandle":case"GPUCompilationInfo":case"GPUCompilationMessage":case"ImageBitmap":case"RTCCertificate":case"WebAssembly.Module":pe(S);default:de(S)}}if(q(t,e,s),E)switch(S){case"Array":case"Object":for(p=J(e),h=0,c=x(p);h<c;h++)f=p[h],v(s,f,fe(e[f],t));break;case"Map":e.forEach((function(e,i){q(s,fe(i,t),fe(e,t))}));break;case"Set":e.forEach((function(e){Q(s,fe(e,t))}));break;case"Error":y(s,"message",fe(e.message,t)),g(e,"cause")&&y(s,"cause",fe(e.cause,t)),"AggregateError"==a&&(s.errors=fe(e.errors,t));case"DOMException":M&&y(s,"stack",fe(e.stack,t))}return s},me=le&&!s((function(){if(A&&E>92||C&&E>94||T&&E>97)return!1;var e=new ArrayBuffer(8),t=le(e,{transfer:[e]});return 0!=e.byteLength||8!=t.byteLength})),ge=function(e,t){if(!u(e))throw U("Transfer option cannot be converted to a sequence");var i=[];p(e,(function(e){K(i,f(e))}));var r,a,s,o,c,d,g=0,v=x(i);if(me)for(o=le(i,{transfer:i});g<v;)q(t,i[g],o[g++]);else for(;g<v;){if(r=i[g++],X(t,r))throw new G("Duplicate transferable",re);switch(a=m(r)){case"ImageBitmap":s=n.OffscreenCanvas,h(s)||pe(a,ae);try{(d=new s(r.width,r.height)).getContext("bitmaprenderer").transferFromImageBitmap(r),c=d.transferToImageBitmap()}catch(e){}break;case"AudioData":case"VideoFrame":(!l(r.clone)||!l(r.close))&&pe(a,ae);try{c=r.clone(),r.close()}catch(e){}break;case"ArrayBuffer":case"MediaSourceHandle":case"MessagePort":case"OffscreenCanvas":case"ReadableStream":case"TransformStream":case"WritableStream":pe(a,ae)}if(void 0===c)throw new G("This object cannot be transferred: "+a,re);q(t,r,c)}};i({global:!0,enumerable:!0,sham:!me,forced:he},{structuredClone:function(e){var t,i=b(arguments.length,1)>1&&!c(arguments[1])?f(arguments[1]):void 0,n=i?i.transfer:void 0;return void 0!==n&&(t=new W,ge(n,t)),fe(e,t)}})})),Xoe=Q((()=>{var e=rt(),t=In(),i=iM()(t.setInterval,!0);e({global:!0,bind:!0,forced:t.setInterval!==i},{setInterval:i})})),Zoe=Q((()=>{var e=rt(),t=In(),i=iM()(t.setTimeout,!0);e({global:!0,bind:!0,forced:t.setTimeout!==i},{setTimeout:i})})),Koe=Q((()=>{Xoe(),Zoe()})),kF=Q(((e,t)=>{var i=Yt(),n=kr(),r=ss(),a=n("iterator");t.exports=!i((function(){var e=new URL("b?a=1&b=2&c=3","http://a"),t=e.searchParams,i="";return e.pathname="c%20d",t.forEach((function(e,n){t.delete("b"),i+=n+e})),r&&!e.toJSON||!t.sort||"http://a/c%20d?a=1&c=3"!==e.href||"3"!==t.get("c")||"a=1"!==String(new URLSearchParams("?a=1"))||!t[a]||"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}))})),ole=Q(((e,t)=>{var i=sn(),n=2147483647,r=/[^\0-\u007E]/,a=/[.\u3002\uFF0E\uFF61]/g,s="Overflow: input needs wider integers to process",o=RangeError,l=i(a.exec),h=Math.floor,c=String.fromCharCode,u=i("".charCodeAt),d=i([].join),p=i([].push),f=i("".replace),m=i("".split),g=i("".toLowerCase),v=function(e){return e+22+75*(e<26)},y=function(e,t,i){var n=0;for(e=i?h(e/700):e>>1,e+=h(e/t);e>455;)e=h(e/35),n+=36;return h(n+36*e/(e+38))},x=function(e){var t=[];e=function(e){for(var t=[],i=0,n=e.length;i<n;){var r=u(e,i++);if(r>=55296&&r<=56319&&i<n){var a=u(e,i++);56320==(64512&a)?p(t,((1023&r)<<10)+(1023&a)+65536):(p(t,r),i--)}else p(t,r)}return t}(e);var i,r,a=e.length,l=128,f=0,m=72;for(i=0;i<e.length;i++)(r=e[i])<128&&p(t,c(r));var g=t.length,x=g;for(g&&p(t,"-");x<a;){var b=n;for(i=0;i<e.length;i++)(r=e[i])>=l&&r<b&&(b=r);var _=x+1;if(b-l>h((n-f)/_))throw o(s);for(f+=(b-l)*_,l=b,i=0;i<e.length;i++){if((r=e[i])<l&&++f>n)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,c(v(M+E%T))),w=h(E/T),S+=36}p(t,c(v(w))),m=y(f,_,x==g),f=0,x++}}f++,l++}return d(t,"")};t.exports=function(e){var t,i,n=[],s=m(f(g(e),a,"."),".");for(t=0;t<s.length;t++)i=s[t],p(n,l(r,i)?"xn--"+x(i):i);return d(n,".")}})),$F=Q(((e,t)=>{"use strict";V1();var i=rt(),n=In(),r=wr(),a=sn(),s=rr(),o=kF(),l=$i(),h=jg(),c=to(),u=Cw(),d=bs(),p=uc(),f=Vr(),m=Yr(),g=dl(),v=oc(),y=br(),x=Cr(),b=Fr(),_=eo(),w=Oo(),S=O1(),M=zg(),E=Ah(),T=kr(),A=kw(),C=T("iterator"),P="URLSearchParams",R=P+"Iterator",D=d.set,L=d.getterFor(P),I=d.getterFor(R),O=Object.getOwnPropertyDescriptor,k=function(e){if(!s)return n[e];var t=O(n,e);return t&&t.value},N=k("fetch"),U=k("Request"),F=k("Headers"),B=U&&U.prototype,z=F&&F.prototype,H=n.RegExp,V=n.TypeError,j=n.decodeURIComponent,G=n.encodeURIComponent,W=a("".charAt),X=a([].join),Y=a([].push),q=a("".replace),Z=a([].shift),Q=a([].splice),J=a("".split),K=a("".slice),$=/\+/g,ee=Array(4),te=function(e){return ee[e-1]||(ee[e-1]=H("((?:%[\\da-f]{2}){"+e+"})","gi"))},ie=function(e){try{return j(e)}catch(t){return e}},ne=function(e){var t=q(e,$," "),i=4;try{return j(t)}catch(e){for(;i;)t=q(t,te(i--),ie);return t}},re=/[!'()~]|%20/g,ae={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},se=function(e){return ae[e]},oe=function(e){return q(G(e),re,se)},le=u((function(e,t){D(this,{type:R,iterator:S(L(e).entries),kind:t})}),"Iterator",(function(){var e=I(this),t=e.kind,i=e.iterator.next(),n=i.value;return i.done||(i.value="keys"===t?n.key:"values"===t?n.value:[n.key,n.value]),i}),!0),he=function(e){this.entries=[],this.url=null,void 0!==e&&(x(e)?this.parseObject(e):this.parseQuery("string"==typeof e?"?"===W(e,0)?K(e,1):e:b(e)))};he.prototype={type:P,bindURL:function(e){this.url=e,this.update()},parseObject:function(e){var t,i,n,a,s,o,l,h=M(e);if(h)for(i=(t=S(e,h)).next;!(n=r(i,t)).done;){if(s=(a=S(y(n.value))).next,(o=r(s,a)).done||(l=r(s,a)).done||!r(s,a).done)throw V("Expected sequence with length 2");Y(this.entries,{key:b(o.value),value:b(l.value)})}else for(var c in e)m(e,c)&&Y(this.entries,{key:c,value:b(e[c])})},parseQuery:function(e){if(e)for(var t,i,n=J(e,"&"),r=0;r<n.length;)(t=n[r++]).length&&(i=J(t,"="),Y(this.entries,{key:ne(Z(i)),value:ne(X(i,"="))}))},serialize:function(){for(var e,t=this.entries,i=[],n=0;n<t.length;)e=t[n++],Y(i,oe(e.key)+"="+oe(e.value));return X(i,"&")},update:function(){this.entries.length=0,this.parseQuery(this.url.query)},updateURL:function(){this.url&&this.url.update()}};var ce,ue,de,pe,fe=function(){p(this,me),D(this,new he(arguments.length>0?arguments[0]:void 0))},me=fe.prototype;h(me,{append:function(e,t){E(arguments.length,2);var i=L(this);Y(i.entries,{key:b(e),value:b(t)}),i.updateURL()},delete:function(e){E(arguments.length,1);for(var t=L(this),i=t.entries,n=b(e),r=0;r<i.length;)i[r].key===n?Q(i,r,1):r++;t.updateURL()},get:function(e){E(arguments.length,1);for(var t=L(this).entries,i=b(e),n=0;n<t.length;n++)if(t[n].key===i)return t[n].value;return null},getAll:function(e){E(arguments.length,1);for(var t=L(this).entries,i=b(e),n=[],r=0;r<t.length;r++)t[r].key===i&&Y(n,t[r].value);return n},has:function(e){E(arguments.length,1);for(var t=L(this).entries,i=b(e),n=0;n<t.length;)if(t[n++].key===i)return!0;return!1},set:function(e,t){E(arguments.length,1);for(var i,n=L(this),r=n.entries,a=!1,s=b(e),o=b(t),l=0;l<r.length;l++)(i=r[l]).key===s&&(a?Q(r,l--,1):(a=!0,i.value=o));a||Y(r,{key:s,value:o}),n.updateURL()},sort:function(){var e=L(this);A(e.entries,(function(e,t){return e.key>t.key?1:-1})),e.updateURL()},forEach:function(e){for(var t,i=L(this).entries,n=g(e,arguments.length>1?arguments[1]:void 0),r=0;r<i.length;)n((t=i[r++]).value,t.key,this)},keys:function(){return new le(this,"keys")},values:function(){return new le(this,"values")},entries:function(){return new le(this,"entries")}},{enumerable:!0}),l(me,C,me.entries,{name:"entries"}),l(me,"toString",(function(){return L(this).serialize()}),{enumerable:!0}),c(fe,P),i({global:!0,constructor:!0,forced:!o},{URLSearchParams:fe}),!o&&f(F)&&(ce=a(z.has),ue=a(z.set),de=function(e){if(x(e)){var t,i=e.body;if(v(i)===P)return t=e.headers?new F(e.headers):new F,ce(t,"content-type")||ue(t,"content-type","application/x-www-form-urlencoded;charset=UTF-8"),_(e,{body:w(0,b(i)),headers:w(0,t)})}return e},f(N)&&i({global:!0,enumerable:!0,dontCallGetSet:!0,forced:!0},{fetch:function(e){return N(e,arguments.length>1?de(arguments[1]):{})}}),f(U)&&(pe=function(e){return p(this,B),new U(e,arguments.length>1?de(arguments[1]):{})},B.constructor=pe,pe.prototype=B,i({global:!0,constructor:!0,dontCallGetSet:!0,forced:!0},{Request:pe}))),t.exports={URLSearchParams:fe,getState:L}})),jle=Q((()=>{"use strict";ek();var e,t=rt(),i=rr(),n=kF(),r=In(),a=dl(),s=sn(),o=$i(),l=Xd(),h=uc(),c=Yr(),u=ZD(),d=FL(),p=Fg(),f=fx().codeAt,m=ole(),g=Fr(),v=to(),y=Ah(),x=$F(),b=bs(),_=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),D=s(/./.exec),L=s([].join),I=s(1..toString),O=s([].pop),k=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,Z=/^[0-7]+$/,Q=/^\d+$/,J=/^[\da-f]+$/i,K=/[\0\t\n\r #%/:<>?@[\\\]^|]/,$=/[\0\t\n\r #/:<>?@[\\\]^|]/,ee=/^[\u0000-\u0020]+|[\u0000-\u0020]+$/g,te=/[\t\n\r]/g,ie=function(e){var t,i,n,r;if("number"==typeof e){for(t=[],i=0;i<4;i++)H(t,e%256),e=C(e/256);return L(t,".")}if("object"==typeof e){for(t="",n=function(e){for(var t=null,i=1,n=null,r=0,a=0;a<8;a++)0!==e[a]?(r>i&&(t=n,i=r),n=null,r=0):(null===n&&(n=a),++r);return r>i&&(t=n,i=r),t}(e),i=0;i<8;i++)r&&0===e[i]||(r&&(r=!1),n===i?(t+=i?":":"::",r=!0):(t+=I(e[i],16),i<7&&(t+=":")));return"["+t+"]"}return e},ne={},re=u({},ne,{" ":1,'"':1,"<":1,">":1,"`":1}),ae=u({},re,{"#":1,"?":1,"{":1,"}":1}),se=u({},ae,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),oe=function(e,t){var i=f(e,0);return i>32&&i<127&&!c(t,e)?e:encodeURIComponent(e)},le={ftp:21,file:null,http:80,https:443,ws:80,wss:443},he=function(e,t){var i;return 2==e.length&&D(W,R(e,0))&&(":"==(i=R(e,1))||!t&&"|"==i)},ce=function(e){var t;return e.length>1&&he(B(e,0,2))&&(2==e.length||"/"===(t=R(e,2))||"\\"===t||"?"===t||"#"===t)},ue=function(e){return"."===e||"%2e"===z(e)},de=function(e){return".."===(e=z(e))||"%2e."===e||".%2e"===e||"%2e%2e"===e},pe={},fe={},me={},ge={},ve={},ye={},xe={},be={},_e={},we={},Se={},Me={},Ee={},Te={},Ae={},Ce={},Pe={},Re={},De={},Le={},Ie={},Oe=function(e,t,i){var n,r,a,s=g(e);if(t){if(r=this.parse(s))throw T(r);this.searchParams=null}else{if(void 0!==i&&(n=new Oe(i,!0)),r=this.parse(s,null,n))throw T(r);(a=M(new S)).bindURL(this),this.searchParams=a}};Oe.prototype={type:"URL",parse:function(t,i,n){var r,a,s,o,l=this,h=i||pe,u=0,f="",m=!1,v=!1,y=!1;for(t=g(t),i||(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,""),r=d(t);u<=r.length;){switch(a=r[u],h){case pe:if(!a||!D(W,a)){if(i)return V;h=me;continue}f+=z(a),h=fe;break;case fe:if(a&&(D(X,a)||"+"==a||"-"==a||"."==a))f+=z(a);else{if(":"!=a){if(i)return V;f="",h=me,u=0;continue}if(i&&(l.isSpecial()!=c(le,f)||"file"==f&&(l.includesCredentials()||null!==l.port)||"file"==l.scheme&&!l.host))return;if(l.scheme=f,i)return void(l.isSpecial()&&le[l.scheme]==l.port&&(l.port=null));f="","file"==l.scheme?h=Te:l.isSpecial()&&n&&n.scheme==l.scheme?h=ge:l.isSpecial()?h=be:"/"==r[u+1]?(h=ve,u++):(l.cannotBeABaseURL=!0,k(l.path,""),h=De)}break;case me:if(!n||n.cannotBeABaseURL&&"#"!=a)return V;if(n.cannotBeABaseURL&&"#"==a){l.scheme=n.scheme,l.path=p(n.path),l.query=n.query,l.fragment="",l.cannotBeABaseURL=!0,h=Ie;break}h="file"==n.scheme?Te:ye;continue;case ge:if("/"!=a||"/"!=r[u+1]){h=ye;continue}h=_e,u++;break;case ve:if("/"==a){h=we;break}h=Re;continue;case ye:if(l.scheme=n.scheme,a==e)l.username=n.username,l.password=n.password,l.host=n.host,l.port=n.port,l.path=p(n.path),l.query=n.query;else if("/"==a||"\\"==a&&l.isSpecial())h=xe;else if("?"==a)l.username=n.username,l.password=n.password,l.host=n.host,l.port=n.port,l.path=p(n.path),l.query="",h=Le;else{if("#"!=a){l.username=n.username,l.password=n.password,l.host=n.host,l.port=n.port,l.path=p(n.path),l.path.length--,h=Re;continue}l.username=n.username,l.password=n.password,l.host=n.host,l.port=n.port,l.path=p(n.path),l.query=n.query,l.fragment="",h=Ie}break;case xe:if(!l.isSpecial()||"/"!=a&&"\\"!=a){if("/"!=a){l.username=n.username,l.password=n.password,l.host=n.host,l.port=n.port,h=Re;continue}h=we}else h=_e;break;case be:if(h=_e,"/"!=a||"/"!=R(f,u+1))continue;u++;break;case _e:if("/"!=a&&"\\"!=a){h=we;continue}break;case we: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 _=oe(b,se);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";u-=d(f).length+1,f="",h=Se}else f+=a;break;case Se:case Me:if(i&&"file"==l.scheme){h=Ce;continue}if(":"!=a||v){if(a==e||"/"==a||"?"==a||"#"==a||"\\"==a&&l.isSpecial()){if(l.isSpecial()&&""==f)return j;if(i&&""==f&&(l.includesCredentials()||null!==l.port))return;if(o=l.parseHost(f))return o;if(f="",h=Pe,i)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=Ee,i==Me)return}break;case Ee:if(!D(Y,a)){if(a==e||"/"==a||"?"==a||"#"==a||"\\"==a&&l.isSpecial()||i){if(""!=f){var w=A(f,10);if(w>65535)return G;l.port=l.isSpecial()&&w===le[l.scheme]?null:w,f=""}if(i)return;h=Pe;continue}return G}f+=a;break;case Te:if(l.scheme="file","/"==a||"\\"==a)h=Ae;else{if(!n||"file"!=n.scheme){h=Re;continue}if(a==e)l.host=n.host,l.path=p(n.path),l.query=n.query;else if("?"==a)l.host=n.host,l.path=p(n.path),l.query="",h=Le;else{if("#"!=a){ce(L(p(r,u),""))||(l.host=n.host,l.path=p(n.path),l.shortenPath()),h=Re;continue}l.host=n.host,l.path=p(n.path),l.query=n.query,l.fragment="",h=Ie}}break;case Ae:if("/"==a||"\\"==a){h=Ce;break}n&&"file"==n.scheme&&!ce(L(p(r,u),""))&&(he(n.path[0],!0)?k(l.path,n.path[0]):l.host=n.host),h=Re;continue;case Ce:if(a==e||"/"==a||"\\"==a||"?"==a||"#"==a){if(!i&&he(f))h=Re;else if(""==f){if(l.host="",i)return;h=Pe}else{if(o=l.parseHost(f))return o;if("localhost"==l.host&&(l.host=""),i)return;f="",h=Pe}continue}f+=a;break;case Pe:if(l.isSpecial()){if(h=Re,"/"!=a&&"\\"!=a)continue}else if(i||"?"!=a)if(i||"#"!=a){if(a!=e&&(h=Re,"/"!=a))continue}else l.fragment="",h=Ie;else l.query="",h=Le;break;case Re:if(a==e||"/"==a||"\\"==a&&l.isSpecial()||!i&&("?"==a||"#"==a)){if(de(f)?(l.shortenPath(),"/"!=a&&!("\\"==a&&l.isSpecial())&&k(l.path,"")):ue(f)?"/"!=a&&!("\\"==a&&l.isSpecial())&&k(l.path,""):("file"==l.scheme&&!l.path.length&&he(f)&&(l.host&&(l.host=""),f=R(f,0)+":"),k(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=Le):"#"==a&&(l.fragment="",h=Ie)}else f+=oe(a,ae);break;case De:"?"==a?(l.query="",h=Le):"#"==a?(l.fragment="",h=Ie):a!=e&&(l.path[0]+=oe(a,ne));break;case Le:i||"#"!=a?a!=e&&("'"==a&&l.isSpecial()?l.query+="%27":l.query+="#"==a?"%23":oe(a,ne)):(l.fragment="",h=Ie);break;case Ie:a!=e&&(l.fragment+=oe(a,re))}u++}},parseHost:function(e){var t,i,n;if("["==R(e,0)){if("]"!=R(e,e.length-1)||(t=function(e){var t,i,n,r,a,s,o,l=[0,0,0,0,0,0,0,0],h=0,c=null,u=0,d=function(){return R(e,u)};if(":"==d()){if(":"!=R(e,1))return;u+=2,c=++h}for(;d();){if(8==h)return;if(":"!=d()){for(t=i=0;i<4&&D(J,d());)t=16*t+A(d(),16),u++,i++;if("."==d()){if(0==i||(u-=i,h>6))return;for(n=0;d();){if(r=null,n>0){if(!("."==d()&&n<4))return;u++}if(!D(Y,d()))return;for(;D(Y,d());){if(a=A(d(),10),null===r)r=a;else{if(0==r)return;r=10*r+a}if(r>255)return;u++}l[h]=256*l[h]+r,(2==++n||4==n)&&h++}if(4!=n)return;break}if(":"==d()){if(u++,!d())return}else if(d())return;l[h++]=t}else{if(null!==c)return;u++,c=++h}}if(null!==c)for(s=h-c,h=7;0!=h&&s>0;)o=l[h],l[h--]=l[c+s-1],l[c+--s]=o;else if(8!=h)return;return l}(B(e,1,-1)),!t))return j;this.host=t}else if(this.isSpecial()){if(e=m(e),D(K,e)||(t=function(e){var t,i,n,r,a,s,o,l=F(e,".");if(l.length&&""==l[l.length-1]&&l.length--,(t=l.length)>4)return e;for(i=[],n=0;n<t;n++){if(""==(r=l[n]))return e;if(a=10,r.length>1&&"0"==R(r,0)&&(a=D(q,r)?16:8,r=B(r,8==a?1:2)),""===r)s=0;else{if(!D(10==a?Q:8==a?Z:J,r))return e;s=A(r,a)}k(i,s)}for(n=0;n<t;n++)if(s=i[n],n==t-1){if(s>=P(256,5-t))return null}else if(s>255)return null;for(o=O(i),n=0;n<i.length;n++)o+=i[n]*P(256,3-n);return o}(e),null===t))return j;this.host=t}else{if(D($,e))return j;for(t="",i=d(e),n=0;n<i.length;n++)t+=oe(i[n],ne);this.host=t}},cannotHaveUsernamePasswordPort:function(){return!this.host||this.cannotBeABaseURL||"file"==this.scheme},includesCredentials:function(){return""!=this.username||""!=this.password},isSpecial:function(){return c(le,this.scheme)},shortenPath:function(){var e=this.path,t=e.length;t&&("file"!=this.scheme||1!=t||!he(e[0],!0))&&e.length--},serialize:function(){var e=this,t=e.scheme,i=e.username,n=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+=i+(n?":"+n:"")+"@"),h+=ie(r),null!==a&&(h+=":"+a)):"file"==t&&(h+="//"),h+=e.cannotBeABaseURL?s[0]:s.length?"/"+L(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 Ue(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)+":",pe)},getUsername:function(){return this.username},setUsername:function(e){var t=d(g(e));if(!this.cannotHaveUsernamePasswordPort()){this.username="";for(var i=0;i<t.length;i++)this.username+=oe(t[i],se)}},getPassword:function(){return this.password},setPassword:function(e){var t=d(g(e));if(!this.cannotHaveUsernamePasswordPort()){this.password="";for(var i=0;i<t.length;i++)this.password+=oe(t[i],se)}},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,Se)},getHostname:function(){var e=this.host;return null===e?"":ie(e)},setHostname:function(e){this.cannotBeABaseURL||this.parse(e,Me)},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,Ee))},getPathname:function(){var e=this.path;return this.cannotBeABaseURL?e[0]:e.length?"/"+L(e,"/"):""},setPathname:function(e){this.cannotBeABaseURL||(this.path=[],this.parse(e,Pe))},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,Le)),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,Ie)):this.fragment=null},update:function(){this.query=this.searchParams.serialize()||null}};var ke,Ne,Ue=function(e){var t=h(this,Fe),n=y(arguments.length,1)>1?arguments[1]:void 0,r=_(t,new Oe(e,!1,n));i||(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())},Fe=Ue.prototype,Be=function(e,t){return{get:function(){return w(this)[e]()},set:t&&function(e){return w(this)[t](e)},configurable:!0,enumerable:!0}};i&&(l(Fe,"href",Be("serialize","setHref")),l(Fe,"origin",Be("getOrigin")),l(Fe,"protocol",Be("getProtocol","setProtocol")),l(Fe,"username",Be("getUsername","setUsername")),l(Fe,"password",Be("getPassword","setPassword")),l(Fe,"host",Be("getHost","setHost")),l(Fe,"hostname",Be("getHostname","setHostname")),l(Fe,"port",Be("getPort","setPort")),l(Fe,"pathname",Be("getPathname","setPathname")),l(Fe,"search",Be("getSearch","setSearch")),l(Fe,"searchParams",Be("getSearchParams")),l(Fe,"hash",Be("getHash","setHash"))),o(Fe,"toJSON",(function(){return w(this).serialize()}),{enumerable:!0}),o(Fe,"toString",(function(){return w(this).serialize()}),{enumerable:!0}),E&&(ke=E.createObjectURL,Ne=E.revokeObjectURL,ke&&o(Ue,"createObjectURL",a(ke,E)),Ne&&o(Ue,"revokeObjectURL",a(Ne,E))),v(Ue,"URL"),t({global:!0,constructor:!0,forced:!n,sham:!i},{URL:Ue})})),Xle=Q((()=>{jle()})),Yle=Q((()=>{"use strict";var e=rt(),t=wr();e({target:"URL",proto:!0,enumerable:!0},{toJSON:function(){return t(URL.prototype.toString,this)}})})),$le=Q((()=>{$F()})),Kle=Q(((e,t)=>{dW(),xW(),bW(),EW(),_W(),TW(),wW(),SW(),MW(),RW(),AW(),CW(),PW(),IW(),LW(),nj(),oj(),wj(),Aj(),Pj(),Fj(),Hj(),zj(),Wj(),jj(),Yj(),Zj(),Qj(),eX(),rX(),iX(),oX(),vX(),yX(),bX(),EX(),V1(),zX(),jX(),XX(),$X(),KX(),nY(),iY(),aY(),cY(),uY(),MY(),CY(),PY(),IY(),LY(),DY(),a$(),y$(),R$(),C$(),P$(),L$(),k$(),F$(),j$(),X$(),J$(),nZ(),iZ(),uZ(),fZ(),vZ(),yZ(),hL(),xZ(),kZ(),BZ(),VZ(),GZ(),WZ(),jZ(),$Z(),KZ(),eK(),nK(),iK(),aK(),oK(),lK(),cK(),dK(),mK(),gK(),vK(),AK(),CK(),LK(),OK(),kK(),FK(),NK(),BK(),qK(),JK(),rJ(),cJ(),dJ(),vJ(),yJ(),EJ(),TJ(),SJ(),MJ(),PJ(),IJ(),LJ(),kJ(),FJ(),NJ(),UJ(),HJ(),zJ(),qJ(),jJ(),YJ(),ZJ(),KJ(),JJ(),QJ(),oQ(),lQ(),cQ(),dQ(),fQ(),mQ(),vQ(),Aee(),Cee(),Iee(),kee(),Fee(),Gee(),jee(),Xee(),Kee(),Jee(),Qee(),ete(),tte(),nte(),rte(),lte(),ute(),hte(),Rte(),Cte(),SS(),kte(),Nte(),Hte(),Gte(),Wte(),jte(),Zte(),rne(),ane(),lne(),ek(),Ene(),Ine(),Dne(),One(),Bne(),Une(),Wne(),Zne(),Qne(),sre(),ure(),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(),Aie(),Pie(),Lie(),Hie(),zie(),qie(),jie(),Yie(),Zie(),Kie(),Qie(),tse(),ase(),lse(),use(),dse(),pse(),gse(),yse(),bse(),Mse(),Ase(),Pse(),Fse(),Use(),qse(),jse(),Kse(),pae(),gae(),Sae(),Oae(),Vae(),Xae(),ooe(),poe(),goe(),Roe(),Aoe(),Poe(),qoe(),Koe(),Xle(),Yle(),$le(),t.exports=dw()})),Jle=Q(((e,t)=>{var i=function(e){"use strict";var t,i=Object.prototype,n=i.hasOwnProperty,r=Object.defineProperty||function(e,t,i){e[t]=i.value},a="function"==typeof Symbol?Symbol:{},s=a.iterator||"@@iterator",o=a.asyncIterator||"@@asyncIterator",l=a.toStringTag||"@@toStringTag";function h(e,t,i){return Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{h({},"")}catch(e){h=function(e,t,i){return e[t]=i}}function c(e,t,i,n){var a=t&&t.prototype instanceof g?t:g,s=Object.create(a.prototype),o=new P(n||[]);return r(s,"_invoke",{value:E(e,i,o)}),s}function u(e,t,i){try{return{type:"normal",arg:e.call(t,i)}}catch(e){return{type:"throw",arg:e}}}e.wrap=c;var d="suspendedStart",p="executing",f="completed",m={};function g(){}function v(){}function y(){}var x={};h(x,s,(function(){return this}));var b=Object.getPrototypeOf,_=b&&b(b(R([])));_&&_!==i&&n.call(_,s)&&(x=_);var w=y.prototype=g.prototype=Object.create(x);function S(e){["next","throw","return"].forEach((function(t){h(e,t,(function(e){return this._invoke(t,e)}))}))}function M(e,t){function i(r,a,s,o){var l=u(e[r],e,a);if("throw"!==l.type){var h=l.arg,c=h.value;return c&&"object"==typeof c&&n.call(c,"__await")?t.resolve(c.__await).then((function(e){i("next",e,s,o)}),(function(e){i("throw",e,s,o)})):t.resolve(c).then((function(e){h.value=e,s(h)}),(function(e){return i("throw",e,s,o)}))}o(l.arg)}var a;r(this,"_invoke",{value:function(e,n){function r(){return new t((function(t,r){i(e,n,t,r)}))}return a=a?a.then(r,r):r()}})}function E(e,t,i){var n=d;return function(r,a){if(n===p)throw new Error("Generator is already running");if(n===f){if("throw"===r)throw a;return D()}for(i.method=r,i.arg=a;;){var s=i.delegate;if(s){var o=T(s,i);if(o){if(o===m)continue;return o}}if("next"===i.method)i.sent=i._sent=i.arg;else if("throw"===i.method){if(n===d)throw n=f,i.arg;i.dispatchException(i.arg)}else"return"===i.method&&i.abrupt("return",i.arg);n=p;var l=u(e,t,i);if("normal"===l.type){if(n=i.done?f:"suspendedYield",l.arg===m)continue;return{value:l.arg,done:i.done}}"throw"===l.type&&(n=f,i.method="throw",i.arg=l.arg)}}}function T(e,i){var n=i.method,r=e.iterator[n];if(r===t)return i.delegate=null,"throw"===n&&e.iterator.return&&(i.method="return",i.arg=t,T(e,i),"throw"===i.method)||"return"!==n&&(i.method="throw",i.arg=new TypeError("The iterator does not provide a '"+n+"' method")),m;var a=u(r,e.iterator,i.arg);if("throw"===a.type)return i.method="throw",i.arg=a.arg,i.delegate=null,m;var s=a.arg;return s?s.done?(i[e.resultName]=s.value,i.next=e.nextLoc,"return"!==i.method&&(i.method="next",i.arg=t),i.delegate=null,m):s:(i.method="throw",i.arg=new TypeError("iterator result is not an object"),i.delegate=null,m)}function A(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function C(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function P(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(A,this),this.reset(!0)}function R(e){if(e){var i=e[s];if(i)return i.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,a=function i(){for(;++r<e.length;)if(n.call(e,r))return i.value=e[r],i.done=!1,i;return i.value=t,i.done=!0,i};return a.next=a}}return{next:D}}function D(){return{value:t,done:!0}}return v.prototype=y,r(w,"constructor",{value:y,configurable:!0}),r(y,"constructor",{value:v,configurable:!0}),v.displayName=h(y,l,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===v||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,y):(e.__proto__=y,h(e,l,"GeneratorFunction")),e.prototype=Object.create(w),e},e.awrap=function(e){return{__await:e}},S(M.prototype),h(M.prototype,o,(function(){return this})),e.AsyncIterator=M,e.async=function(t,i,n,r,a){void 0===a&&(a=Promise);var s=new M(c(t,i,n,r),a);return e.isGeneratorFunction(i)?s:s.next().then((function(e){return e.done?e.value:s.next()}))},S(w),h(w,l,"Generator"),h(w,s,(function(){return this})),h(w,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),i=[];for(var n in t)i.push(n);return i.reverse(),function e(){for(;i.length;){var n=i.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},e.values=R,P.prototype={constructor:P,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(C),!e)for(var i in this)"t"===i.charAt(0)&&n.call(this,i)&&!isNaN(+i.slice(1))&&(this[i]=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 i=this;function r(n,r){return o.type="throw",o.arg=e,i.next=n,r&&(i.method="next",i.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=n.call(s,"catchLoc"),h=n.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 i=this.tryEntries.length-1;i>=0;--i){var r=this.tryEntries[i];if(r.tryLoc<=this.prev&&n.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,m):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),m},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var i=this.tryEntries[t];if(i.finallyLoc===e)return this.complete(i.completion,i.afterLoc),C(i),m}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var i=this.tryEntries[t];if(i.tryLoc===e){var n=i.completion;if("throw"===n.type){var r=n.arg;C(i)}return r}}throw new Error("illegal catch attempt")},delegateYield:function(e,i,n){return this.delegate={iterator:R(e),resultName:i,nextLoc:n},"next"===this.method&&(this.arg=t),m}},e}("object"==typeof t?t.exports:{});try{regeneratorRuntime=i}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=i:Function("r","regeneratorRuntime = r")(i)}})),ude=Q(((e,t)=>{!function(e,i){"use strict";"function"==typeof define&&define.amd?define(i):"object"==typeof t&&t.exports?t.exports=i():e.log=i()}(e,(function(){"use strict";var e=function(){},t="undefined",i=typeof window!==t&&typeof window.navigator!==t&&/Trident\/|MSIE /.test(window.navigator.userAgent),n=["trace","debug","info","warn","error"];function r(e,t){var i=e[t];if("function"==typeof i.bind)return i.bind(e);try{return Function.prototype.bind.call(i,e)}catch(t){return function(){return Function.prototype.apply.apply(i,[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(n){return"debug"===n&&(n="log"),typeof console!==t&&("trace"===n&&i?a:void 0!==console[n]?r(console,n):void 0!==console.log?r(console,"log"):e)}function o(t,i){for(var r=0;r<n.length;r++){var a=n[r];this[a]=r<t?e:this.methodFactory(a,t,i)}this.log=this.debug}function l(e,i,n){return function(){typeof console!==t&&(o.call(this,i,n),this[e].apply(this,arguments))}}function h(e,t,i){return s(e)||l.apply(this,arguments)}function c(e,i,r){var a,s=this;i=null==i?"WARN":i;var l="loglevel";function c(){var e;if(typeof window!==t&&l){try{e=window.localStorage[l]}catch(e){}if(typeof e===t)try{var i=window.document.cookie,n=i.indexOf(encodeURIComponent(l)+"=");-1!==n&&(e=/^([^;]+)/.exec(i.slice(n))[1])}catch(e){}return void 0===s.levels[e]&&(e=void 0),e}}"string"==typeof e?l+=":"+e:"symbol"==typeof e&&(l=void 0),s.name=e,s.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},s.methodFactory=r||h,s.getLevel=function(){return a},s.setLevel=function(i,r){if("string"==typeof i&&void 0!==s.levels[i.toUpperCase()]&&(i=s.levels[i.toUpperCase()]),!("number"==typeof i&&i>=0&&i<=s.levels.SILENT))throw"log.setLevel() called with invalid level: "+i;if(a=i,!1!==r&&function(e){var i=(n[e]||"silent").toUpperCase();if(typeof window!==t&&l){try{return void(window.localStorage[l]=i)}catch(e){}try{window.document.cookie=encodeURIComponent(l)+"="+i+";"}catch(e){}}}(i),o.call(s,i,e),typeof console===t&&i<s.levels.SILENT)return"No console available for logging"},s.setDefaultLevel=function(e){i=e,c()||s.setLevel(e,!1)},s.resetLevel=function(){s.setLevel(i,!1),function(){if(typeof window!==t&&l){try{return void window.localStorage.removeItem(l)}catch(e){}try{window.document.cookie=encodeURIComponent(l)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch(e){}}}()},s.enableAll=function(e){s.setLevel(s.levels.TRACE,e)},s.disableAll=function(e){s.setLevel(s.levels.SILENT,e)};var u=c();null==u&&(u=i),s.setLevel(u,!1)}var u=new c,d={};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=d[e];return t||(t=d[e]=new c(e,u.getLevel(),u.methodFactory)),t};var p=typeof window!==t?window.log:void 0;return u.noConflict=function(){return typeof window!==t&&window.log===u&&(window.log=p),u},u.getLoggers=function(){return d},u.default=u,u}))})),VA=Q(((e,t)=>{"use strict";t.exports=function(e,t,n){var r=e*t,a=i*e,s=a-(a-e),o=e-s,l=i*t,h=l-(l-t),c=t-h,u=o*c-(r-s*h-o*h-s*c);return n?(n[0]=u,n[1]=r,n):[u,r]};var i=+(Math.pow(2,27)+1)})),WH=Q(((e,t)=>{"use strict";t.exports=function(e,t){var i=0|e.length,n=0|t.length;if(1===i&&1===n)return function(e,t){var i=e+t,n=i-e,r=e-(i-n)+(t-n);return r?[r,i]:[i]}(e[0],t[0]);var r,a,s=new Array(i+n),o=0,l=0,h=0,c=Math.abs,u=e[l],d=c(u),p=t[h],f=c(p);d<f?(a=u,(l+=1)<i&&(d=c(u=e[l]))):(a=p,(h+=1)<n&&(f=c(p=t[h]))),l<i&&d<f||h>=n?(r=u,(l+=1)<i&&(d=c(u=e[l]))):(r=p,(h+=1)<n&&(f=c(p=t[h])));for(var m,g,v=r+a,y=v-r,x=a-y,b=x,_=v;l<i&&h<n;)d<f?(r=u,(l+=1)<i&&(d=c(u=e[l]))):(r=p,(h+=1)<n&&(f=c(p=t[h]))),(x=(a=b)-(y=(v=r+a)-r))&&(s[o++]=x),b=_-((m=_+v)-(g=m-_))+(v-g),_=m;for(;l<i;)(x=(a=b)-(y=(v=(r=u)+a)-r))&&(s[o++]=x),b=_-((m=_+v)-(g=m-_))+(v-g),_=m,(l+=1)<i&&(u=e[l]);for(;h<n;)(x=(a=b)-(y=(v=(r=p)+a)-r))&&(s[o++]=x),b=_-((m=_+v)-(g=m-_))+(v-g),_=m,(h+=1)<n&&(p=t[h]);return b&&(s[o++]=b),_&&(s[o++]=_),o||(s[o++]=0),s.length=o,s}})),tfe=Q(((e,t)=>{"use strict";t.exports=function(e,t,i){var n=e+t,r=n-e,a=t-r,s=e-(n-r);return i?(i[0]=s+a,i[1]=n,i):[s+a,n]}})),XH=Q(((e,t)=>{"use strict";var i=VA(),n=tfe();t.exports=function(e,t){var r=e.length;if(1===r){var a=i(e[0],t);return a[0]?a:[a[1]]}var s=new Array(2*r),o=[.1,.1],l=[.1,.1],h=0;i(e[0],t,o),o[0]&&(s[h++]=o[0]);for(var c=1;c<r;++c){i(e[c],t,l);var u=o[1];n(u,l[0],o),o[0]&&(s[h++]=o[0]);var d=l[1],p=o[1],f=d+p,m=p-(f-d);o[1]=f,m&&(s[h++]=m)}return o[1]&&(s[h++]=o[1]),0===h&&(s[h++]=0),s.length=h,s}})),ife=Q(((e,t)=>{"use strict";t.exports=function(e){for(var t=e.length,i=e[e.length-1],n=t,r=t-2;r>=0;--r){var a=i;(l=(o=e[r])-((i=a+o)-a))&&(e[--n]=i,i=l)}var s=0;for(r=n;r<t;++r){var o,l;(l=(o=i)-((i=(a=e[r])+o)-a))&&(e[s++]=l)}return e[s++]=i,e.length=s,e}})),afe=Q(((e,t)=>{"use strict";t.exports=function(e,t){var i=0|e.length,n=0|t.length;if(1===i&&1===n)return function(e,t){var i=e+t,n=i-e,r=e-(i-n)+(t-n);return r?[r,i]:[i]}(e[0],-t[0]);var r,a,s=new Array(i+n),o=0,l=0,h=0,c=Math.abs,u=e[l],d=c(u),p=-t[h],f=c(p);d<f?(a=u,(l+=1)<i&&(d=c(u=e[l]))):(a=p,(h+=1)<n&&(f=c(p=-t[h]))),l<i&&d<f||h>=n?(r=u,(l+=1)<i&&(d=c(u=e[l]))):(r=p,(h+=1)<n&&(f=c(p=-t[h])));for(var m,g,v=r+a,y=v-r,x=a-y,b=x,_=v;l<i&&h<n;)d<f?(r=u,(l+=1)<i&&(d=c(u=e[l]))):(r=p,(h+=1)<n&&(f=c(p=-t[h]))),(x=(a=b)-(y=(v=r+a)-r))&&(s[o++]=x),b=_-((m=_+v)-(g=m-_))+(v-g),_=m;for(;l<i;)(x=(a=b)-(y=(v=(r=u)+a)-r))&&(s[o++]=x),b=_-((m=_+v)-(g=m-_))+(v-g),_=m,(l+=1)<i&&(u=e[l]);for(;h<n;)(x=(a=b)-(y=(v=(r=p)+a)-r))&&(s[o++]=x),b=_-((m=_+v)-(g=m-_))+(v-g),_=m,(h+=1)<n&&(p=-t[h]);return b&&(s[o++]=b),_&&(s[o++]=_),o||(s[o++]=0),s.length=o,s}})),lfe=Q(((e,t)=>{"use strict";var i=VA(),n=WH(),r=XH(),a=afe();function s(e,t,i,n){return function(i,r,a){var s=e(e(t(r[1],a[0]),t(-a[1],r[0])),e(t(i[1],r[0]),t(-r[1],i[0]))),o=e(t(i[1],a[0]),t(-a[1],i[0])),l=n(s,o);return l[l.length-1]}}function o(e,t,i,n){return function(r,a,s,o){var l=e(e(i(e(t(s[1],o[0]),t(-o[1],s[0])),a[2]),e(i(e(t(a[1],o[0]),t(-o[1],a[0])),-s[2]),i(e(t(a[1],s[0]),t(-s[1],a[0])),o[2]))),e(i(e(t(a[1],o[0]),t(-o[1],a[0])),r[2]),e(i(e(t(r[1],o[0]),t(-o[1],r[0])),-a[2]),i(e(t(r[1],a[0]),t(-a[1],r[0])),o[2])))),h=e(e(i(e(t(s[1],o[0]),t(-o[1],s[0])),r[2]),e(i(e(t(r[1],o[0]),t(-o[1],r[0])),-s[2]),i(e(t(r[1],s[0]),t(-s[1],r[0])),o[2]))),e(i(e(t(a[1],s[0]),t(-s[1],a[0])),r[2]),e(i(e(t(r[1],s[0]),t(-s[1],r[0])),-a[2]),i(e(t(r[1],a[0]),t(-a[1],r[0])),s[2])))),c=n(l,h);return c[c.length-1]}}function l(e,t,i,n){return function(r,a,s,o,l){var h=e(e(e(i(e(i(e(t(o[1],l[0]),t(-l[1],o[0])),s[2]),e(i(e(t(s[1],l[0]),t(-l[1],s[0])),-o[2]),i(e(t(s[1],o[0]),t(-o[1],s[0])),l[2]))),a[3]),e(i(e(i(e(t(o[1],l[0]),t(-l[1],o[0])),a[2]),e(i(e(t(a[1],l[0]),t(-l[1],a[0])),-o[2]),i(e(t(a[1],o[0]),t(-o[1],a[0])),l[2]))),-s[3]),i(e(i(e(t(s[1],l[0]),t(-l[1],s[0])),a[2]),e(i(e(t(a[1],l[0]),t(-l[1],a[0])),-s[2]),i(e(t(a[1],s[0]),t(-s[1],a[0])),l[2]))),o[3]))),e(i(e(i(e(t(s[1],o[0]),t(-o[1],s[0])),a[2]),e(i(e(t(a[1],o[0]),t(-o[1],a[0])),-s[2]),i(e(t(a[1],s[0]),t(-s[1],a[0])),o[2]))),-l[3]),e(i(e(i(e(t(o[1],l[0]),t(-l[1],o[0])),a[2]),e(i(e(t(a[1],l[0]),t(-l[1],a[0])),-o[2]),i(e(t(a[1],o[0]),t(-o[1],a[0])),l[2]))),r[3]),i(e(i(e(t(o[1],l[0]),t(-l[1],o[0])),r[2]),e(i(e(t(r[1],l[0]),t(-l[1],r[0])),-o[2]),i(e(t(r[1],o[0]),t(-o[1],r[0])),l[2]))),-a[3])))),e(e(i(e(i(e(t(a[1],l[0]),t(-l[1],a[0])),r[2]),e(i(e(t(r[1],l[0]),t(-l[1],r[0])),-a[2]),i(e(t(r[1],a[0]),t(-a[1],r[0])),l[2]))),o[3]),e(i(e(i(e(t(a[1],o[0]),t(-o[1],a[0])),r[2]),e(i(e(t(r[1],o[0]),t(-o[1],r[0])),-a[2]),i(e(t(r[1],a[0]),t(-a[1],r[0])),o[2]))),-l[3]),i(e(i(e(t(s[1],o[0]),t(-o[1],s[0])),a[2]),e(i(e(t(a[1],o[0]),t(-o[1],a[0])),-s[2]),i(e(t(a[1],s[0]),t(-s[1],a[0])),o[2]))),r[3]))),e(i(e(i(e(t(s[1],o[0]),t(-o[1],s[0])),r[2]),e(i(e(t(r[1],o[0]),t(-o[1],r[0])),-s[2]),i(e(t(r[1],s[0]),t(-s[1],r[0])),o[2]))),-a[3]),e(i(e(i(e(t(a[1],o[0]),t(-o[1],a[0])),r[2]),e(i(e(t(r[1],o[0]),t(-o[1],r[0])),-a[2]),i(e(t(r[1],a[0]),t(-a[1],r[0])),o[2]))),s[3]),i(e(i(e(t(a[1],s[0]),t(-s[1],a[0])),r[2]),e(i(e(t(r[1],s[0]),t(-s[1],r[0])),-a[2]),i(e(t(r[1],a[0]),t(-a[1],r[0])),s[2]))),-o[3]))))),c=e(e(e(i(e(i(e(t(o[1],l[0]),t(-l[1],o[0])),s[2]),e(i(e(t(s[1],l[0]),t(-l[1],s[0])),-o[2]),i(e(t(s[1],o[0]),t(-o[1],s[0])),l[2]))),r[3]),i(e(i(e(t(o[1],l[0]),t(-l[1],o[0])),r[2]),e(i(e(t(r[1],l[0]),t(-l[1],r[0])),-o[2]),i(e(t(r[1],o[0]),t(-o[1],r[0])),l[2]))),-s[3])),e(i(e(i(e(t(s[1],l[0]),t(-l[1],s[0])),r[2]),e(i(e(t(r[1],l[0]),t(-l[1],r[0])),-s[2]),i(e(t(r[1],s[0]),t(-s[1],r[0])),l[2]))),o[3]),i(e(i(e(t(s[1],o[0]),t(-o[1],s[0])),r[2]),e(i(e(t(r[1],o[0]),t(-o[1],r[0])),-s[2]),i(e(t(r[1],s[0]),t(-s[1],r[0])),o[2]))),-l[3]))),e(e(i(e(i(e(t(s[1],l[0]),t(-l[1],s[0])),a[2]),e(i(e(t(a[1],l[0]),t(-l[1],a[0])),-s[2]),i(e(t(a[1],s[0]),t(-s[1],a[0])),l[2]))),r[3]),i(e(i(e(t(s[1],l[0]),t(-l[1],s[0])),r[2]),e(i(e(t(r[1],l[0]),t(-l[1],r[0])),-s[2]),i(e(t(r[1],s[0]),t(-s[1],r[0])),l[2]))),-a[3])),e(i(e(i(e(t(a[1],l[0]),t(-l[1],a[0])),r[2]),e(i(e(t(r[1],l[0]),t(-l[1],r[0])),-a[2]),i(e(t(r[1],a[0]),t(-a[1],r[0])),l[2]))),s[3]),i(e(i(e(t(a[1],s[0]),t(-s[1],a[0])),r[2]),e(i(e(t(r[1],s[0]),t(-s[1],r[0])),-a[2]),i(e(t(r[1],a[0]),t(-a[1],r[0])),s[2]))),-l[3])))),u=n(h,c);return u[u.length-1]}}function h(e){return(3===e?s:4===e?o:l)(n,i,r,a)}var c=h(3),u=h(4),d=[function(){return 0},function(){return 0},function(e,t){return t[0]-e[0]},function(e,t,i){var n,r=(e[1]-i[1])*(t[0]-i[0]),a=(e[0]-i[0])*(t[1]-i[1]),s=r-a;if(r>0){if(a<=0)return s;n=r+a}else{if(!(r<0))return s;if(a>=0)return s;n=-(r+a)}var o=33306690738754716e-32*n;return s>=o||s<=-o?s:c(e,t,i)},function(e,t,i,n){var r=e[0]-n[0],a=t[0]-n[0],s=i[0]-n[0],o=e[1]-n[1],l=t[1]-n[1],h=i[1]-n[1],c=e[2]-n[2],d=t[2]-n[2],p=i[2]-n[2],f=a*h,m=s*l,g=s*o,v=r*h,y=r*l,x=a*o,b=c*(f-m)+d*(g-v)+p*(y-x),_=7771561172376103e-31*((Math.abs(f)+Math.abs(m))*Math.abs(c)+(Math.abs(g)+Math.abs(v))*Math.abs(d)+(Math.abs(y)+Math.abs(x))*Math.abs(p));return b>_||-b>_?b:u(e,t,i,n)}];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,i,n,r,a,s){return function(t,i,o,l,h){switch(arguments.length){case 0:case 1:return 0;case 2:return n(t,i);case 3:return r(t,i,o);case 4:return a(t,i,o,l);case 5:return s(t,i,o,l,h)}for(var c=new Array(arguments.length),u=0;u<arguments.length;++u)c[u]=arguments[u];return e(c)}}!function(){for(;d.length<=5;)d.push(h(d.length));t.exports=f.apply(void 0,[p].concat(d));for(var e=0;e<=5;++e)t.exports[e]=d[e]}()})),ufe=Q(((e,t)=>{"use strict";t.exports=function(e,t,n,r){var a=i(e,n,r),s=i(t,n,r);if(a>0&&s>0||a<0&&s<0)return!1;var o=i(n,e,t),l=i(r,e,t);return!(o>0&&l>0||o<0&&l<0)&&(0!==a||0!==s||0!==o||0!==l||function(e,t,i,n){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=i[r],c=n[r],u=Math.min(h,c);if(Math.max(h,c)<o||l<u)return!1}return!0}(e,t,n,r))};var i=lfe()[3]})),dfe=Q(((e,t)=>{"use strict";t.exports=function(e,t,o,l){if(!s(e,t,o,l))return[[0],[0],[0]];var h=n([o[1]],[-l[1]]),c=n([-o[0]],[l[0]]),u=n(n(r(c,e[1]),r(c,-t[1])),n(r(h,e[0]),r(h,-t[0]))),d=n(i(-e[0],t[1]),i(e[1],t[0])),p=n(i(-o[0],l[1]),i(o[1],l[0])),f=n(n(r(p,e[0]),r(p,-t[0])),n(r(d,-o[0]),r(d,l[0]))),m=n(n(r(p,e[1]),r(p,-t[1])),n(r(d,-o[1]),r(d,l[1])));return[a(f),a(m),a(u)]};var i=VA(),n=WH(),r=XH(),a=ife(),s=ufe()})),pfe=Q(((e,t)=>{t.exports=function(e){var t=0,i=e.length;switch(i){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 n=0;n<i;n++)t+=e[n]}return t}})),gfe=Q(((e,t)=>{var i=dfe(),n=pfe();function r(e,t){return e[0]===t[0]&&e[1]===t[1]}t.exports=function(e,t){for(var c={},u=e.length,d=[],p=0;p<u;p++){var f=e[p],m=e[(p+1)%u];h(f,o),h(m,l);for(var g=0;g<u;g++)if(p!==g){var v=e[g],y=e[(g+1)%u];if(h(v,a),h(y,s),!(r(a,o)||r(a,l)||r(s,o)||r(s,l))){var x=i(o,l,a,s),b=x[2];if(1!==b.length||b[0]){var _=n(x[2]);if(x[0]=n(x[0])/_,x[1]=n(x[1])/_,x.pop(),!(r(x,o)||r(x,l)||r(x,a)||r(x,s))){var w=x+"",S=!c[w];S&&(c[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)}})),Yfe=Q(((e,t)=>{function i(e){if(e)return function(e){for(var t in i.prototype)e[t]=i.prototype[t];return e}(e)}t.exports=i,i.prototype.on=i.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks[e]=this._callbacks[e]||[]).push(t),this},i.prototype.once=function(e,t){var i=this;function n(){i.off(e,n),t.apply(this,arguments)}return this._callbacks=this._callbacks||{},n.fn=t,this.on(e,n),this},i.prototype.off=i.prototype.removeListener=i.prototype.removeAllListeners=i.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var i=this._callbacks[e];if(!i)return this;if(1==arguments.length)return delete this._callbacks[e],this;for(var n,r=0;r<i.length;r++)if((n=i[r])===t||n.fn===t){i.splice(r,1);break}return this},i.prototype.emit=function(e){this._callbacks=this._callbacks||{};var t=[].slice.call(arguments,1),i=this._callbacks[e];if(i)for(var n=0,r=(i=i.slice(0)).length;n<r;++n)i[n].apply(this,t);return this},i.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks[e]||[]},i.prototype.hasListeners=function(e){return!!this.listeners(e).length}})),Kfe=Q(((e,t)=>{var i=Yfe();function n(){i.call(this)}n.prototype=new i,t.exports=n,n.Stream=n,n.prototype.pipe=function(e,t){var i=this;function n(t){e.writable&&!1===e.write(t)&&i.pause&&i.pause()}function r(){i.readable&&i.resume&&i.resume()}i.on("data",n),e.on("drain",r),!e._isStdio&&(!t||!1!==t.end)&&(i.on("end",s),i.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(){i.off("data",n),e.off("drain",r),i.off("end",s),i.off("close",o),i.off("error",l),e.off("error",l),i.off("end",h),i.off("close",h),e.off("end",h),e.off("close",h)}return i.on("error",l),e.on("error",l),i.on("end",h),i.on("close",h),e.on("end",h),e.on("close",h),e.emit("pipe",i),e}})),Jfe=Q(((e,t)=>{var i,n;i=e,n=function(){"use strict";var e=Math.imul,t=Math.clz32;function i(e){return(i="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 n(e,t){for(var i,n=0;n<t.length;n++)(i=t[n]).enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}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,i){var n=[null];n.push.apply(n,t);var r=new(Function.bind.apply(e,n));return i&&a(r,i.prototype),r}).apply(null,arguments)}function l(e){var t="function"==typeof Map?new Map:void 0;return l=function(e){function i(){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,i)}return i.prototype=Object.create(e.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),a(i,e)},l(e)}function h(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function c(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var n,r,a=[],s=!0,o=!1;try{for(i=i.call(e);!(s=(n=i.next()).done)&&(a.push(n.value),!t||a.length!==t);s=!0);}catch(e){o=!0,r=e}finally{try{s||null==i.return||i.return()}finally{if(o)throw r}}return a}}(e,t)||u(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 u(e,t){if(e){if("string"==typeof e)return d(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?d(e,t):void 0}}function d(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=Array(t);i<t;i++)n[i]=e[i];return n}var p=function(e){var t=Math.abs,o=Math.max,l=Math.floor;function d(e,t){var i;if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,d),(i=p.call(this,e)).sign=t,Object.setPrototypeOf(h(i),d.prototype),e>d.__kMaxLength)throw new RangeError("Maximum BigInt size exceeded");return i}!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)}(d,e);var p=function(e){var t=s();return function(){var i,n=r(e);if(t){var a=r(this).constructor;i=Reflect.construct(n,arguments,a)}else i=n.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,i)}}(d);return function(e,t,i){t&&n(e.prototype,t),i&&n(e,i),Object.defineProperty(e,"prototype",{writable:!1})}(d,[{key:"toDebugString",value:function(){var e,t=["BigInt["],i=function(e,t){var i="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!i){if(Array.isArray(e)||(i=u(e))){i&&(e=i);var n=0,r=function(){};return{s:r,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},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(){i=i.call(e)},n:function(){var e=i.next();return s=e.done,e},e:function(e){o=!0,a=e},f:function(){try{s||null==i.return||i.return()}finally{if(o)throw a}}}}(this);try{for(i.s();!(e=i.n()).done;){var n=e.value;t.push((n&&(n>>>0).toString(16))+", ")}}catch(e){i.e(e)}finally{i.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?d.__toStringGeneric(this,e,!1):d.__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 d(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 d.__clz30(this.__digit(this.length-1))}},{key:"__inplaceMultiplyAdd",value:function(e,t,i){i>this.length&&(i=this.length);for(var n=32767&e,r=e>>>15,a=0,s=t,o=0;o<i;o++){var l=this.__digit(o),h=32767&l,c=l>>>15,u=d.__imul(h,n),p=d.__imul(h,r),f=d.__imul(c,n),m=s+u+a;a=m>>>30,m&=1073741823,a+=(m+=((32767&p)<<15)+((32767&f)<<15))>>>30,s=d.__imul(c,r)+(p>>>15)+(f>>>15),this.__setDigit(o,1073741823&m)}if(0!==a||0!==s)throw new Error("implementation bug")}},{key:"__inplaceAdd",value:function(e,t,i){for(var n,r=0,a=0;a<i;a++)r=(n=this.__halfDigit(t+a)+e.__halfDigit(a)+r)>>>15,this.__setHalfDigit(t+a,32767&n);return r}},{key:"__inplaceSub",value:function(e,t,i){var n=0;if(1&t){t>>=1;for(var r=this.__digit(t),a=32767&r,s=0;s<i-1>>>1;s++){var o=e.__digit(s),l=(r>>>15)-(32767&o)-n;n=1&l>>>15,this.__setDigit(t+s,(32767&l)<<15|32767&a),n=1&(a=(32767&(r=this.__digit(t+s+1)))-(o>>>15)-n)>>>15}var h=e.__digit(s),c=(r>>>15)-(32767&h)-n;if(n=1&c>>>15,this.__setDigit(t+s,(32767&c)<<15|32767&a),t+s+1>=this.length)throw new RangeError("out of bounds");!(1&i)&&(n=1&(a=(32767&(r=this.__digit(t+s+1)))-(h>>>15)-n)>>>15,this.__setDigit(t+e.length,1073709056&r|32767&a))}else{t>>=1;for(var u=0;u<e.length-1;u++){var d=this.__digit(t+u),p=e.__digit(u),f=(32767&d)-(32767&p)-n,m=(d>>>15)-(p>>>15)-(n=1&f>>>15);n=1&m>>>15,this.__setDigit(t+u,(32767&m)<<15|32767&f)}var g=this.__digit(t+u),v=e.__digit(u),y=(32767&g)-(32767&v)-n;n=1&y>>>15;var x=0;!(1&i)&&(n=1&(x=(g>>>15)-(v>>>15)-n)>>>15),this.__setDigit(t+u,(32767&x)<<15|32767&y)}return n}},{key:"__inplaceRightShift",value:function(e){if(0!==e){for(var t,i=this.__digit(0)>>>e,n=this.length-1,r=0;r<n;r++)t=this.__digit(r+1),this.__setDigit(r,1073741823&t<<30-e|i),i=t>>>e;this.__setDigit(n,i)}}},{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 i=e>>>1,n=this.__digit(i),r=1&e?32767&n|t<<15:1073709056&n|32767&t;this.__setDigit(i,r)}}],[{key:"BigInt",value:function(e){var t=Number.isFinite;if("number"==typeof e){if(0===e)return d.__zero();if(d.__isOneDigitInt(e))return 0>e?d.__oneDigit(-e,!0):d.__oneDigit(e,!1);if(!t(e)||l(e)!==e)throw new RangeError("The number "+e+" cannot be converted to BigInt because it is not an integer");return d.__fromDouble(e)}if("string"==typeof e){var n=d.__fromString(e);if(null===n)throw new SyntaxError("Cannot convert "+e+" to a BigInt");return n}if("boolean"==typeof e)return!0===e?d.__oneDigit(1,!1):d.__zero();if("object"===i(e)){if(e.constructor===d)return e;var r=d.__toPrimitive(e);return d.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 i=e.__unsignedDigit(0);return e.sign?-i:i}var n=e.__digit(t-1),r=d.__clz30(n),a=30*t-r;if(1024<a)return e.sign?-1/0:1/0;var s=a-1,o=n,l=t-1,h=r+3,c=32===h?0:o<<h;c>>>=12;var u=h-12,p=12<=h?0:o<<20+h,f=20+h;for(0<u&&0<l&&(l--,c|=(o=e.__digit(l))>>>30-u,p=o<<u+2,f=u+2);0<f&&0<l;)l--,o=e.__digit(l),p|=30<=f?o<<f-30:o>>>30-f,f-=30;var m=d.__decideRounding(e,f,l,o);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,d.__kBitConversionInts[1]=g|s|c,d.__kBitConversionInts[0]=p,d.__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?d.__absoluteSubOne(e).__trim():d.__absoluteAddOne(e,!0)}},{key:"exponentiate",value:function(e,t){if(t.sign)throw new RangeError("Exponent must be positive");if(0===t.length)return d.__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:d.unaryMinus(e);if(1<t.length)throw new RangeError("BigInt too big");var i=t.__unsignedDigit(0);if(1===i)return e;if(i>=d.__kMaxLengthBits)throw new RangeError("BigInt too big");if(1===e.length&&2===e.__digit(0)){var n=1+(0|i/30),r=new d(n,e.sign&&0!=(1&i));r.__initializeDigits();var a=1<<i%30;return r.__setDigit(n-1,a),r}var s=null,o=e;for(1&i&&(s=e),i>>=1;0!==i;i>>=1)o=d.multiply(o,o),1&i&&(s=null===s?o:d.multiply(s,o));return s}},{key:"multiply",value:function(e,t){if(0===e.length)return e;if(0===t.length)return t;var i=e.length+t.length;30<=e.__clzmsd()+t.__clzmsd()&&i--;var n=new d(i,e.sign!==t.sign);n.__initializeDigits();for(var r=0;r<e.length;r++)d.__multiplyAccumulate(t,e.__digit(r),n,r);return n.__trim()}},{key:"divide",value:function(e,t){if(0===t.length)throw new RangeError("Division by zero");if(0>d.__absoluteCompare(e,t))return d.__zero();var i,n=e.sign!==t.sign,r=t.__unsignedDigit(0);if(1===t.length&&32767>=r){if(1===r)return n===e.sign?e:d.unaryMinus(e);i=d.__absoluteDivSmall(e,r,null)}else i=d.__absoluteDivLarge(e,t,!0,!1);return i.sign=n,i.__trim()}},{key:"remainder",value:function(e,t){if(0===t.length)throw new RangeError("Division by zero");if(0>d.__absoluteCompare(e,t))return e;var i=t.__unsignedDigit(0);if(1===t.length&&32767>=i){if(1===i)return d.__zero();var n=d.__absoluteModSmall(e,i);return 0===n?d.__zero():d.__oneDigit(n,e.sign)}var r=d.__absoluteDivLarge(e,t,!1,!0);return r.sign=e.sign,r.__trim()}},{key:"add",value:function(e,t){var i=e.sign;return i===t.sign?d.__absoluteAdd(e,t,i):0<=d.__absoluteCompare(e,t)?d.__absoluteSub(e,t,i):d.__absoluteSub(t,e,!i)}},{key:"subtract",value:function(e,t){var i=e.sign;return i===t.sign?0<=d.__absoluteCompare(e,t)?d.__absoluteSub(e,t,i):d.__absoluteSub(t,e,!i):d.__absoluteAdd(e,t,i)}},{key:"leftShift",value:function(e,t){return 0===t.length||0===e.length?e:t.sign?d.__rightShiftByAbsolute(e,t):d.__leftShiftByAbsolute(e,t)}},{key:"signedRightShift",value:function(e,t){return 0===t.length||0===e.length?e:t.sign?d.__leftShiftByAbsolute(e,t):d.__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>d.__compareToBigInt(e,t)}},{key:"lessThanOrEqual",value:function(e,t){return 0>=d.__compareToBigInt(e,t)}},{key:"greaterThan",value:function(e,t){return 0<d.__compareToBigInt(e,t)}},{key:"greaterThanOrEqual",value:function(e,t){return 0<=d.__compareToBigInt(e,t)}},{key:"equal",value:function(e,t){if(e.sign!==t.sign||e.length!==t.length)return!1;for(var i=0;i<e.length;i++)if(e.__digit(i)!==t.__digit(i))return!1;return!0}},{key:"notEqual",value:function(e,t){return!d.equal(e,t)}},{key:"bitwiseAnd",value:function(e,t){if(!e.sign&&!t.sign)return d.__absoluteAnd(e,t).__trim();if(e.sign&&t.sign){var i=o(e.length,t.length)+1,n=d.__absoluteSubOne(e,i),r=d.__absoluteSubOne(t);return n=d.__absoluteOr(n,r,n),d.__absoluteAddOne(n,!0,n).__trim()}if(e.sign){var a=[t,e];e=a[0],t=a[1]}return d.__absoluteAndNot(e,d.__absoluteSubOne(t)).__trim()}},{key:"bitwiseXor",value:function(e,t){if(!e.sign&&!t.sign)return d.__absoluteXor(e,t).__trim();if(e.sign&&t.sign){var i=o(e.length,t.length),n=d.__absoluteSubOne(e,i),r=d.__absoluteSubOne(t);return d.__absoluteXor(n,r,n).__trim()}var a=o(e.length,t.length)+1;if(e.sign){var s=[t,e];e=s[0],t=s[1]}var l=d.__absoluteSubOne(t,a);return l=d.__absoluteXor(l,e,l),d.__absoluteAddOne(l,!0,l).__trim()}},{key:"bitwiseOr",value:function(e,t){var i=o(e.length,t.length);if(!e.sign&&!t.sign)return d.__absoluteOr(e,t).__trim();if(e.sign&&t.sign){var n=d.__absoluteSubOne(e,i),r=d.__absoluteSubOne(t);return n=d.__absoluteAnd(n,r,n),d.__absoluteAddOne(n,!0,n).__trim()}if(e.sign){var a=[t,e];e=a[0],t=a[1]}var s=d.__absoluteSubOne(t,i);return s=d.__absoluteAndNot(s,e,s),d.__absoluteAddOne(s,!0,s).__trim()}},{key:"asIntN",value:function(e,t){if(0===t.length)return t;if(0>(e=l(e)))throw new RangeError("Invalid value: not (convertible to) a safe integer");if(0===e)return d.__zero();if(e>=d.__kMaxLengthBits)return t;var i=0|(e+29)/30;if(t.length<i)return t;var n=t.__unsignedDigit(i-1),r=1<<(e-1)%30;if(t.length===i&&n<r)return t;if((n&r)!==r)return d.__truncateToNBits(e,t);if(!t.sign)return d.__truncateAndSubFromPowerOfTwo(e,t,!0);if(!(n&r-1)){for(var a=i-2;0<=a;a--)if(0!==t.__digit(a))return d.__truncateAndSubFromPowerOfTwo(e,t,!1);return t.length===i&&n===r?t:d.__truncateToNBits(e,t)}return d.__truncateAndSubFromPowerOfTwo(e,t,!1)}},{key:"asUintN",value:function(e,t){if(0===t.length)return t;if(0>(e=l(e)))throw new RangeError("Invalid value: not (convertible to) a safe integer");if(0===e)return d.__zero();if(t.sign){if(e>d.__kMaxLengthBits)throw new RangeError("BigInt too big");return d.__truncateAndSubFromPowerOfTwo(e,t,!1)}if(e>=d.__kMaxLengthBits)return t;var i=0|(e+29)/30;if(t.length<i)return t;var n=e%30;if(t.length==i){if(0===n)return t;if(!(t.__digit(i-1)>>>n))return t}return d.__truncateToNBits(e,t)}},{key:"ADD",value:function(e,t){if(e=d.__toPrimitive(e),t=d.__toPrimitive(t),"string"==typeof e)return"string"!=typeof t&&(t=t.toString()),e+t;if("string"==typeof t)return e.toString()+t;if(e=d.__toNumeric(e),t=d.__toNumeric(t),d.__isBigInt(e)&&d.__isBigInt(t))return d.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 d.__compare(e,t,0)}},{key:"LE",value:function(e,t){return d.__compare(e,t,1)}},{key:"GT",value:function(e,t){return d.__compare(e,t,2)}},{key:"GE",value:function(e,t){return d.__compare(e,t,3)}},{key:"EQ",value:function(e,t){for(;;){if(d.__isBigInt(e))return d.__isBigInt(t)?d.equal(e,t):d.EQ(t,e);if("number"==typeof e){if(d.__isBigInt(t))return d.__equalToNumber(t,e);if("object"!==i(t))return e==t;t=d.__toPrimitive(t)}else if("string"==typeof e){if(d.__isBigInt(t))return null!==(e=d.__fromString(e))&&d.equal(e,t);if("object"!==i(t))return e==t;t=d.__toPrimitive(t)}else if("boolean"==typeof e){if(d.__isBigInt(t))return d.__equalToNumber(t,+e);if("object"!==i(t))return e==t;t=d.__toPrimitive(t)}else if("symbol"===i(e)){if(d.__isBigInt(t))return!1;if("object"!==i(t))return e==t;t=d.__toPrimitive(t)}else{if("object"!==i(e))return e==t;if("object"===i(t)&&t.constructor!==d)return e==t;e=d.__toPrimitive(e)}}}},{key:"NE",value:function(e,t){return!d.EQ(e,t)}},{key:"DataViewGetBigInt64",value:function(e,t){var i=2<arguments.length&&void 0!==arguments[2]&&arguments[2];return d.asIntN(64,d.DataViewGetBigUint64(e,t,i))}},{key:"DataViewGetBigUint64",value:function(e,t){var i=2<arguments.length&&void 0!==arguments[2]&&arguments[2],n=c(i?[4,0]:[0,4],2),r=n[0],a=n[1],s=e.getUint32(t+r,i),o=e.getUint32(t+a,i),l=new d(3,!1);return l.__setDigit(0,1073741823&o),l.__setDigit(1,(268435455&s)<<2|o>>>30),l.__setDigit(2,s>>>28),l.__trim()}},{key:"DataViewSetBigInt64",value:function(e,t,i){var n=3<arguments.length&&void 0!==arguments[3]&&arguments[3];d.DataViewSetBigUint64(e,t,i,n)}},{key:"DataViewSetBigUint64",value:function(e,t,i){var n=3<arguments.length&&void 0!==arguments[3]&&arguments[3],r=0,a=0;if(0<(i=d.asUintN(64,i)).length&&(a=i.__digit(0),1<i.length)){var s=i.__digit(1);a|=s<<30,r=s>>>2,2<i.length&&(r|=i.__digit(2)<<28)}var o=c(n?[4,0]:[0,4],2),l=o[0],h=o[1];e.setUint32(t+l,r,n),e.setUint32(t+h,a,n)}},{key:"__zero",value:function(){return new d(0,!1)}},{key:"__oneDigit",value:function(e,t){var i=new d(1,t);return i.__setDigit(0,e),i}},{key:"__decideRounding",value:function(e,t,i,n){if(0<t)return-1;var r;if(0>t)r=-t-1;else{if(0===i)return-1;i--,n=e.__digit(i),r=29}var a=1<<r;if(!(n&a))return-1;if(0!=(n&(a-=1)))return 1;for(;0<i;)if(i--,0!==e.__digit(i))return 1;return 0}},{key:"__fromDouble",value:function(e){d.__kBitConversionDouble[0]=e;var t,i=(2047&d.__kBitConversionInts[1]>>>20)-1023,n=1+(0|i/30),r=new d(n,0>e),a=1048575&d.__kBitConversionInts[1]|1048576,s=d.__kBitConversionInts[0],o=i%30,l=0;if(o<20){var h=20-o;l=h+32,t=a>>>h,a=a<<32-h|s>>>h,s<<=32-h}else if(20===o)l=32,t=a,a=s,s=0;else{var c=o-20;l=32-c,t=a<<c|s>>>32-c,a=s<<c,s=0}r.__setDigit(n-1,t);for(var u=n-2;0<=u;u--)0<l?(l-=30,t=a>>>2,a=a<<30|s>>>2,s<<=30):t=0,r.__setDigit(u,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,i=0,n=e.length,r=0;if(r===n)return d.__zero();for(var a=e.charCodeAt(r);d.__isWhitespace(a);){if(++r===n)return d.__zero();a=e.charCodeAt(r)}if(43===a){if(++r===n)return null;a=e.charCodeAt(r),i=1}else if(45===a){if(++r===n)return null;a=e.charCodeAt(r),i=-1}if(0===t){if(t=10,48===a){if(++r===n)return d.__zero();if(88===(a=e.charCodeAt(r))||120===a){if(t=16,++r===n)return null;a=e.charCodeAt(r)}else if(79===a||111===a){if(t=8,++r===n)return null;a=e.charCodeAt(r)}else if(66===a||98===a){if(t=2,++r===n)return null;a=e.charCodeAt(r)}}}else if(16===t&&48===a){if(++r===n)return d.__zero();if(88===(a=e.charCodeAt(r))||120===a){if(++r===n)return null;a=e.charCodeAt(r)}}if(0!==i&&10!==t)return null;for(;48===a;){if(++r===n)return d.__zero();a=e.charCodeAt(r)}var s=n-r,o=d.__kMaxBitsPerChar[t],l=d.__kBitsPerCharTableMultiplier-1;if(s>1073741824/o)return null;var h=new d(0|((o*s+l>>>d.__kBitsPerCharTableShift)+29)/30,!1),c=10>t?t:10,u=10<t?t-10:0;if(t&t-1){h.__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<u)){p=!0;break}m=(32|a)-87}var y=v*t;if(1073741823<y)break;if(v=y,g=g*t+m,f++,++r===n){p=!0;break}a=e.charCodeAt(r)}var x=0|(o*f+(l=30*d.__kBitsPerCharTableMultiplier-1)>>>d.__kBitsPerCharTableShift)/30;h.__inplaceMultiplyAdd(v,g,x)}while(!p)}else{o>>=d.__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<u)){w=!0;break}S=(32|a)-87}if(E+=o,M=M<<o|S,++r===n){w=!0;break}if(a=e.charCodeAt(r),30<E+o)break}b.push(M),_.push(E)}while(!w);d.__fillFromParts(h,b,_)}if(r!==n){if(!d.__isWhitespace(a))return null;for(r++;r<n;r++)if(a=e.charCodeAt(r),!d.__isWhitespace(a))return null}return h.sign=-1===i,h.__trim()}},{key:"__fillFromParts",value:function(e,t,i){for(var n=0,r=0,a=0,s=t.length-1;0<=s;s--){var o=t[s],l=i[s];r|=o<<a,30===(a+=l)?(e.__setDigit(n++,r),a=0,r=0):30<a&&(e.__setDigit(n++,1073741823&r),r=o>>>l-(a-=30))}if(0!==r){if(n>=e.length)throw new Error("implementation bug");e.__setDigit(n++,r)}for(;n<e.length;n++)e.__setDigit(n,0)}},{key:"__toStringBasePowerOfTwo",value:function(e,t){var i=e.length,n=t-1,r=n=(15&(n=(51&(n=(85&n>>>1)+(85&n))>>>2)+(51&n))>>>4)+(15&n),a=t-1,s=e.__digit(i-1),o=0|(30*i-d.__clz30(s)+r-1)/r;if(e.sign&&o++,268435456<o)throw new Error("string too long");for(var l=Array(o),h=o-1,c=0,u=0,p=0;p<i-1;p++){var f=e.__digit(p),m=(c|f<<u)&a;l[h--]=d.__kConversionChars[m];var g=r-u;for(c=f>>>g,u=30-g;u>=r;)l[h--]=d.__kConversionChars[c&a],c>>>=r,u-=r}var v=(c|s<<u)&a;for(l[h--]=d.__kConversionChars[v],c=s>>>r-u;0!==c;)l[h--]=d.__kConversionChars[c&a],c>>>=r;if(e.sign&&(l[h--]="-"),-1!==h)throw new Error("implementation bug");return l.join("")}},{key:"__toStringGeneric",value:function(e,t,i){var n=e.length;if(0===n)return"";if(1===n){var r=e.__unsignedDigit(0).toString(t);return!1===i&&e.sign&&(r="-"+r),r}var a,s,o=30*n-d.__clz30(e.__digit(n-1)),l=d.__kMaxBitsPerChar[t]-1,h=o*d.__kBitsPerCharTableMultiplier,c=1+(h=0|(h+=l-1)/l)>>1,u=d.exponentiate(d.__oneDigit(t,!1),d.__oneDigit(c,!1)),p=u.__unsignedDigit(0);if(1===u.length&&32767>=p){(a=new d(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=d.__absoluteDivLarge(e,u,!0,!0);a=v.quotient;var y=v.remainder.__trim();s=d.__toStringGeneric(y,t,!0)}a.__trim();for(var x=d.__toStringGeneric(a,t,!0);s.length<c;)s="0"+s;return!1===i&&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 i=e.sign;if(i!==t.sign)return d.__unequalSign(i);var n=d.__absoluteCompare(e,t);return 0<n?d.__absoluteGreater(i):0>n?d.__absoluteLess(i):0}},{key:"__compareToNumber",value:function(e,i){if(d.__isOneDigitInt(i)){var n=e.sign,r=0>i;if(n!==r)return d.__unequalSign(n);if(0===e.length){if(r)throw new Error("implementation bug");return 0===i?0:-1}if(1<e.length)return d.__absoluteGreater(n);var a=t(i),s=e.__unsignedDigit(0);return s>a?d.__absoluteGreater(n):s<a?d.__absoluteLess(n):0}return d.__compareToDouble(e,i)}},{key:"__compareToDouble",value:function(e,t){if(t!=t)return t;if(t===1/0)return-1;if(t===-1/0)return 1;var i=e.sign;if(i!==0>t)return d.__unequalSign(i);if(0===t)throw new Error("implementation bug: should be handled elsewhere");if(0===e.length)return-1;d.__kBitConversionDouble[0]=t;var n=2047&d.__kBitConversionInts[1]>>>20;if(2047==n)throw new Error("implementation bug: handled elsewhere");var r=n-1023;if(0>r)return d.__absoluteGreater(i);var a=e.length,s=e.__digit(a-1),o=d.__clz30(s),l=30*a-o,h=r+1;if(l<h)return d.__absoluteLess(i);if(l>h)return d.__absoluteGreater(i);var c=1048576|1048575&d.__kBitConversionInts[1],u=d.__kBitConversionInts[0],p=29-o;if(p!==(0|(l-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|u>>>g,u<<=32-g}else if(20===p)m=32,f=c,c=u,u=0;else{var v=p-20;m=32-v,f=c<<v|u>>>32-v,c=u<<v,u=0}if((s>>>=0)>(f>>>=0))return d.__absoluteGreater(i);if(s<f)return d.__absoluteLess(i);for(var y=a-2;0<=y;y--){0<m?(m-=30,f=c>>>2,c=c<<30|u>>>2,u<<=30):f=0;var x=e.__unsignedDigit(y);if(x>f)return d.__absoluteGreater(i);if(x<f)return d.__absoluteLess(i)}if(0!==c||0!==u){if(0===m)throw new Error("implementation bug");return d.__absoluteLess(i)}return 0}},{key:"__equalToNumber",value:function(e,i){return d.__isOneDigitInt(i)?0===i?0===e.length:1===e.length&&e.sign===0>i&&e.__unsignedDigit(0)===t(i):0===d.__compareToDouble(e,i)}},{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,i){if(e=d.__toPrimitive(e),t=d.__toPrimitive(t),"string"==typeof e&&"string"==typeof t)switch(i){case 0:return e<t;case 1:return e<=t;case 2:return e>t;case 3:return e>=t}if(d.__isBigInt(e)&&"string"==typeof t)return null!==(t=d.__fromString(t))&&d.__comparisonResultToBool(d.__compareToBigInt(e,t),i);if("string"==typeof e&&d.__isBigInt(t))return null!==(e=d.__fromString(e))&&d.__comparisonResultToBool(d.__compareToBigInt(e,t),i);if(e=d.__toNumeric(e),t=d.__toNumeric(t),d.__isBigInt(e)){if(d.__isBigInt(t))return d.__comparisonResultToBool(d.__compareToBigInt(e,t),i);if("number"!=typeof t)throw new Error("implementation bug");return d.__comparisonResultToBool(d.__compareToNumber(e,t),i)}if("number"!=typeof e)throw new Error("implementation bug");if(d.__isBigInt(t))return d.__comparisonResultToBool(d.__compareToNumber(t,e),2^i);if("number"!=typeof t)throw new Error("implementation bug");return 0===i?e<t:1===i?e<=t:2===i?e>t:3===i?e>=t:void 0}},{key:"__absoluteAdd",value:function(e,t,i){if(e.length<t.length)return d.__absoluteAdd(t,e,i);if(0===e.length)return e;if(0===t.length)return e.sign===i?e:d.unaryMinus(e);var n=e.length;(0===e.__clzmsd()||t.length===e.length&&0===t.__clzmsd())&&n++;for(var r,a=new d(n,i),s=0,o=0;o<t.length;o++)s=(r=e.__digit(o)+t.__digit(o)+s)>>>30,a.__setDigit(o,1073741823&r);for(;o<e.length;o++){var l=e.__digit(o)+s;s=l>>>30,a.__setDigit(o,1073741823&l)}return o<a.length&&a.__setDigit(o,s),a.__trim()}},{key:"__absoluteSub",value:function(e,t,i){if(0===e.length)return e;if(0===t.length)return e.sign===i?e:d.unaryMinus(e);for(var n,r=new d(e.length,i),a=0,s=0;s<t.length;s++)a=1&(n=e.__digit(s)-t.__digit(s)-a)>>>30,r.__setDigit(s,1073741823&n);for(;s<e.length;s++){var o=e.__digit(s)-a;a=1&o>>>30,r.__setDigit(s,1073741823&o)}return r.__trim()}},{key:"__absoluteAddOne",value:function(e,t){var i=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null,n=e.length;null===i?i=new d(n,t):i.sign=t;for(var r,a=1,s=0;s<n;s++)a=(r=e.__digit(s)+a)>>>30,i.__setDigit(s,1073741823&r);return 0!==a&&i.__setDigitGrow(n,1),i}},{key:"__absoluteSubOne",value:function(e,t){for(var i,n=e.length,r=new d(t=t||n,!1),a=1,s=0;s<n;s++)a=1&(i=e.__digit(s)-a)>>>30,r.__setDigit(s,1073741823&i);if(0!==a)throw new Error("implementation bug");for(var o=n;o<t;o++)r.__setDigit(o,0);return r}},{key:"__absoluteAnd",value:function(e,t){var i=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null,n=e.length,r=t.length,a=r;if(n<r){a=n;var s=e,o=n;e=t,n=r,t=s,r=o}var l=a;null===i?i=new d(l,!1):l=i.length;for(var h=0;h<a;h++)i.__setDigit(h,e.__digit(h)&t.__digit(h));for(;h<l;h++)i.__setDigit(h,0);return i}},{key:"__absoluteAndNot",value:function(e,t){var i=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null,n=e.length,r=t.length,a=r;n<r&&(a=n);var s=n;null===i?i=new d(s,!1):s=i.length;for(var o=0;o<a;o++)i.__setDigit(o,e.__digit(o)&~t.__digit(o));for(;o<n;o++)i.__setDigit(o,e.__digit(o));for(;o<s;o++)i.__setDigit(o,0);return i}},{key:"__absoluteOr",value:function(e,t){var i=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null,n=e.length,r=t.length,a=r;if(n<r){a=n;var s=e,o=n;e=t,n=r,t=s,r=o}var l=n;null===i?i=new d(l,!1):l=i.length;for(var h=0;h<a;h++)i.__setDigit(h,e.__digit(h)|t.__digit(h));for(;h<n;h++)i.__setDigit(h,e.__digit(h));for(;h<l;h++)i.__setDigit(h,0);return i}},{key:"__absoluteXor",value:function(e,t){var i=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null,n=e.length,r=t.length,a=r;if(n<r){a=n;var s=e,o=n;e=t,n=r,t=s,r=o}var l=n;null===i?i=new d(l,!1):l=i.length;for(var h=0;h<a;h++)i.__setDigit(h,e.__digit(h)^t.__digit(h));for(;h<n;h++)i.__setDigit(h,e.__digit(h));for(;h<l;h++)i.__setDigit(h,0);return i}},{key:"__absoluteCompare",value:function(e,t){var i=e.length-t.length;if(0!=i)return i;for(var n=e.length-1;0<=n&&e.__digit(n)===t.__digit(n);)n--;return 0>n?0:e.__unsignedDigit(n)>t.__unsignedDigit(n)?1:-1}},{key:"__multiplyAccumulate",value:function(e,t,i,n){if(0!==t){for(var r=32767&t,a=t>>>15,s=0,o=0,l=0;l<e.length;l++,n++){var h=i.__digit(n),c=e.__digit(l),u=32767&c,p=c>>>15,f=d.__imul(u,r),m=d.__imul(u,a),g=d.__imul(p,r);s=(h+=o+f+s)>>>30,h&=1073741823,s+=(h+=((32767&m)<<15)+((32767&g)<<15))>>>30,o=d.__imul(p,a)+(m>>>15)+(g>>>15),i.__setDigit(n,1073741823&h)}for(;0!==s||0!==o;n++){var v=i.__digit(n);v+=s+o,o=0,s=v>>>30,i.__setDigit(n,1073741823&v)}}}},{key:"__internalMultiplyAdd",value:function(e,t,i,n,r){for(var a=i,s=0,o=0;o<n;o++){var l=e.__digit(o),h=d.__imul(32767&l,t),c=d.__imul(l>>>15,t),u=h+((32767&c)<<15)+s+a;a=u>>>30,s=c>>>15,r.__setDigit(o,1073741823&u)}if(r.length>n)for(r.__setDigit(n++,a+s);n<r.length;)r.__setDigit(n++,0);else if(a+s!==0)throw new Error("implementation bug")}},{key:"__absoluteDivSmall",value:function(e,t){var i=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null;null===i&&(i=new d(e.length,!1));for(var n=0,r=2*e.length-1;0<=r;r-=2){var a=(n<<15|e.__halfDigit(r))>>>0,s=0|a/t,o=0|(a=((n=0|a%t)<<15|e.__halfDigit(r-1))>>>0)/t;n=0|a%t,i.__setDigit(r>>>1,s<<15|o)}return i}},{key:"__absoluteModSmall",value:function(e,t){for(var i=0,n=2*e.length-1;0<=n;n--)i=0|((i<<15|e.__halfDigit(n))>>>0)%t;return i}},{key:"__absoluteDivLarge",value:function(e,t,i,n){var r=t.__halfDigitLength(),a=t.length,s=e.__halfDigitLength()-r,o=null;i&&(o=new d(s+2>>>1,!1)).__initializeDigits();var l=new d(r+2>>>1,!1);l.__initializeDigits();var h=d.__clz15(t.__halfDigit(r-1));0<h&&(t=d.__specialLeftShift(t,h,0));for(var c=d.__specialLeftShift(e,h,1),u=t.__halfDigit(r-1),p=0,f=s;0<=f;f--){var m=32767,g=c.__halfDigit(f+r);if(g!==u){var v=(g<<15|c.__halfDigit(f+r-1))>>>0;m=0|v/u;for(var y=0|v%u,x=t.__halfDigit(r-2),b=c.__halfDigit(f+r-2);d.__imul(m,x)>>>0>(y<<16|b)>>>0&&(m--,!(32767<(y+=u))););}d.__internalMultiplyAdd(t,m,0,a,l);var _=c.__inplaceSub(l,f,r+1);0!==_&&(_=c.__inplaceAdd(t,f,r),c.__setHalfDigit(f+r,32767&c.__halfDigit(f+r)+_),m--),i&&(1&f?p=m<<15:o.__setDigit(f>>>1,p|m))}if(n)return c.__inplaceRightShift(h),i?{quotient:o,remainder:c}:c;if(i)return o;throw new Error("unreachable")}},{key:"__clz15",value:function(e){return d.__clz30(e)-15}},{key:"__specialLeftShift",value:function(e,t,i){var n=e.length,r=new d(n+i,!1);if(0===t){for(var a=0;a<n;a++)r.__setDigit(a,e.__digit(a));return 0<i&&r.__setDigit(n,0),r}for(var s,o=0,l=0;l<n;l++)s=e.__digit(l),r.__setDigit(l,1073741823&s<<t|o),o=s>>>30-t;return 0<i&&r.__setDigit(n,o),r}},{key:"__leftShiftByAbsolute",value:function(e,t){var i=d.__toShiftAmount(t);if(0>i)throw new RangeError("BigInt too big");var n=0|i/30,r=i%30,a=e.length,s=0!==r&&e.__digit(a-1)>>>30-r!=0,o=a+n+(s?1:0),l=new d(o,e.sign);if(0===r){for(var h=0;h<n;h++)l.__setDigit(h,0);for(;h<o;h++)l.__setDigit(h,e.__digit(h-n))}else{for(var c=0,u=0;u<n;u++)l.__setDigit(u,0);for(var p,f=0;f<a;f++)p=e.__digit(f),l.__setDigit(f+n,1073741823&p<<r|c),c=p>>>30-r;if(s)l.__setDigit(a+n,c);else if(0!==c)throw new Error("implementation bug")}return l.__trim()}},{key:"__rightShiftByAbsolute",value:function(e,t){var i=e.length,n=e.sign,r=d.__toShiftAmount(t);if(0>r)return d.__rightShiftByMaximum(n);var a=0|r/30,s=r%30,o=i-a;if(0>=o)return d.__rightShiftByMaximum(n);var l=!1;if(n)if(e.__digit(a)&(1<<s)-1)l=!0;else for(var h=0;h<a;h++)if(0!==e.__digit(h)){l=!0;break}l&&0===s&&!~e.__digit(i-1)&&o++;var c=new d(o,n);if(0===s){c.__setDigit(o-1,0);for(var u=a;u<i;u++)c.__setDigit(u-a,e.__digit(u))}else{for(var p,f=e.__digit(a)>>>s,m=i-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 l&&(c=d.__absoluteAddOne(c,!0,c)),c.__trim()}},{key:"__rightShiftByMaximum",value:function(e){return e?d.__oneDigit(1,!0):d.__zero()}},{key:"__toShiftAmount",value:function(e){if(1<e.length)return-1;var t=e.__unsignedDigit(0);return t>d.__kMaxLengthBits?-1:t}},{key:"__toPrimitive",value:function(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"default";if("object"!==i(e)||e.constructor===d)return e;if("undefined"!=typeof Symbol&&"symbol"===i(Symbol.toPrimitive)){var n=e[Symbol.toPrimitive];if(n){var r=n(t);if("object"!==i(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"!==i(s))return s}var o=e.toString;if(o){var l=o.call(e);if("object"!==i(l))return l}throw new TypeError("Cannot convert object to primitive value")}},{key:"__toNumeric",value:function(e){return d.__isBigInt(e)?e:+e}},{key:"__isBigInt",value:function(e){return"object"===i(e)&&null!==e&&e.constructor===d}},{key:"__truncateToNBits",value:function(e,t){for(var i=0|(e+29)/30,n=new d(i,t.sign),r=i-1,a=0;a<r;a++)n.__setDigit(a,t.__digit(a));var s=t.__digit(r);if(e%30!=0){var o=32-e%30;s=s<<o>>>o}return n.__setDigit(r,s),n.__trim()}},{key:"__truncateAndSubFromPowerOfTwo",value:function(e,t,i){for(var n,r=Math.min,a=0|(e+29)/30,s=new d(a,i),o=0,l=a-1,h=0,c=r(l,t.length);o<c;o++)h=1&(n=0-t.__digit(o)-h)>>>30,s.__setDigit(o,1073741823&n);for(;o<l;o++)s.__setDigit(o,0|1073741823&-h);var u,p=l<t.length?t.__digit(l):0,f=e%30;if(0===f)u=0-p-h,u&=1073741823;else{var m=32-f,g=1<<32-m;u=g-(p=p<<m>>>m)-h,u&=g-1}return s.__setDigit(l,u),s.__trim()}},{key:"__digitPow",value:function(e,t){for(var i=1;0<t;)1&t&&(i*=e),t>>>=1,e*=e;return i}},{key:"__isOneDigitInt",value:function(e){return(1073741823&e)===e}}]),d}(l(Array));return p.__kMaxLength=33554432,p.__kMaxLengthBits=p.__kMaxLength<<5,p.__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],p.__kBitsPerCharTableShift=5,p.__kBitsPerCharTableMultiplier=1<<p.__kBitsPerCharTableShift,p.__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"],p.__kBitConversionBuffer=new ArrayBuffer(8),p.__kBitConversionDouble=new Float64Array(p.__kBitConversionBuffer),p.__kBitConversionInts=new Int32Array(p.__kBitConversionBuffer),p.__clz30=t?function(e){return t(e)-2}:function(e){var t=Math.LN2,i=Math.log;return 0===e?30:0|29-(0|i(e>>>0)/t)},p.__imul=e||function(e,t){return 0|e*t},p},"object"==typeof e&&void 0!==t?t.exports=n():"function"==typeof define&&define.amd?define(n):(i=i||self).JSBI=n()})),kl=Q(((e,t)=>{(function(){var i,n="Expected a function",r="__lodash_hash_undefined__",a="__lodash_placeholder__",s=32,o=128,l=1/0,h=9007199254740991,c=NaN,u=4294967295,d=[["ary",o],["bind",1],["bindKey",2],["curry",8],["curryRight",16],["flip",512],["partial",s],["partialRight",64],["rearg",256]],p="[object Arguments]",f="[object Array]",m="[object Boolean]",g="[object Date]",v="[object Error]",y="[object Function]",x="[object GeneratorFunction]",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]",D="[object Float32Array]",L="[object Float64Array]",I="[object Int8Array]",O="[object Int16Array]",k="[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,Z=/<%=([\s\S]+?)%>/g,Q=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,J=/^\w*$/,K=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,$=/[\\^$.*+?()[\]{}|]/g,ee=RegExp($.source),te=/^\s+/,ie=/\s/,ne=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,re=/\{\n\/\* \[wrapped with (.+)\] \*/,ae=/,? & /,se=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,oe=/[()=,{}\[\]\/\s]/,le=/\\(\\)?/g,he=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,ce=/\w*$/,ue=/^[-+]0x[0-9a-f]+$/i,de=/^0b[01]+$/i,pe=/^\[object .+?Constructor\]$/,fe=/^0o[0-7]+$/i,me=/^(?:0|[1-9]\d*)$/,ge=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,ve=/($^)/,ye=/['\n\r\u2028\u2029\\]/g,xe="\\ud800-\\udfff",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+"]",De="["+we+"]",Le="[^"+xe+Ee+Pe+_e+we+Se+"]",Ie="\\ud83c[\\udffb-\\udfff]",Oe="[^"+xe+"]",ke="(?:\\ud83c[\\udde6-\\uddff]){2}",Ne="[\\ud800-\\udbff][\\udc00-\\udfff]",Ue="["+Se+"]",Fe="\\u200d",Be="(?:"+De+"|"+Le+")",ze="(?:"+Ue+"|"+Le+")",He="(?:['\u2019](?:d|ll|m|re|s|t|ve))?",Ve="(?:['\u2019](?:D|LL|M|RE|S|T|VE))?",je="(?:"+Ce+"|"+Ie+")?",Ge="["+Me+"]?",We=Ge+je+"(?:"+Fe+"(?:"+[Oe,ke,Ne].join("|")+")"+Ge+je+")*",Xe="(?:"+[Re,ke,Ne].join("|")+")"+We,Ye="(?:"+[Oe+Ce+"?",Ce,ke,Ne,Te].join("|")+")",qe=RegExp("['\u2019]","g"),Ze=RegExp(Ce,"g"),Qe=RegExp(Ie+"(?="+Ie+")|"+Ye+We,"g"),Je=RegExp([Ue+"?"+De+"+"+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"),Ke=RegExp("["+Fe+xe+be+Me+"]"),$e=/[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,it={};it[D]=it[L]=it[I]=it[O]=it[k]=it[N]=it[U]=it[F]=it[B]=!0,it[p]=it[f]=it[P]=it[m]=it[R]=it[g]=it[v]=it[y]=it[b]=it[_]=it[w]=it[M]=it[E]=it[T]=it[C]=!1;var nt={};nt[p]=nt[f]=nt[P]=nt[R]=nt[m]=nt[g]=nt[D]=nt[L]=nt[I]=nt[O]=nt[k]=nt[b]=nt[_]=nt[w]=nt[M]=nt[E]=nt[T]=nt[A]=nt[N]=nt[U]=nt[F]=nt[B]=!0,nt[v]=nt[y]=nt[C]=!1;var rt={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},at=parseFloat,st=parseInt,ot="object"==typeof global&&global&&global.Object===Object&&global,lt="object"==typeof self&&self&&self.Object===Object&&self,ht=ot||lt||Function("return this")(),ct="object"==typeof e&&e&&!e.nodeType&&e,ut=ct&&"object"==typeof t&&t&&!t.nodeType&&t,dt=ut&&ut.exports===ct,pt=dt&&ot.process,ft=function(){try{return ut&&ut.require&&ut.require("util").types||pt&&pt.binding&&pt.binding("util")}catch(e){}}(),mt=ft&&ft.isArrayBuffer,gt=ft&&ft.isDate,vt=ft&&ft.isMap,yt=ft&&ft.isRegExp,xt=ft&&ft.isSet,bt=ft&&ft.isTypedArray;function _t(e,t,i){switch(i.length){case 0:return e.call(t);case 1:return e.call(t,i[0]);case 2:return e.call(t,i[0],i[1]);case 3:return e.call(t,i[0],i[1],i[2])}return e.apply(t,i)}function wt(e,t,i,n){for(var r=-1,a=null==e?0:e.length;++r<a;){var s=e[r];t(n,s,i(s),e)}return n}function St(e,t){for(var i=-1,n=null==e?0:e.length;++i<n&&!1!==t(e[i],i,e););return e}function Mt(e,t){for(var i=null==e?0:e.length;i--&&!1!==t(e[i],i,e););return e}function Et(e,t){for(var i=-1,n=null==e?0:e.length;++i<n;)if(!t(e[i],i,e))return!1;return!0}function Tt(e,t){for(var i=-1,n=null==e?0:e.length,r=0,a=[];++i<n;){var s=e[i];t(s,i,e)&&(a[r++]=s)}return a}function At(e,t){return!(null==e||!e.length)&&Ut(e,t,0)>-1}function Ct(e,t,i){for(var n=-1,r=null==e?0:e.length;++n<r;)if(i(t,e[n]))return!0;return!1}function Pt(e,t){for(var i=-1,n=null==e?0:e.length,r=Array(n);++i<n;)r[i]=t(e[i],i,e);return r}function Rt(e,t){for(var i=-1,n=t.length,r=e.length;++i<n;)e[r+i]=t[i];return e}function Dt(e,t,i,n){var r=-1,a=null==e?0:e.length;for(n&&a&&(i=e[++r]);++r<a;)i=t(i,e[r],r,e);return i}function Lt(e,t,i,n){var r=null==e?0:e.length;for(n&&r&&(i=e[--r]);r--;)i=t(i,e[r],r,e);return i}function It(e,t){for(var i=-1,n=null==e?0:e.length;++i<n;)if(t(e[i],i,e))return!0;return!1}var Ot=Ht("length");function kt(e,t,i){var n;return i(e,(function(e,i,r){if(t(e,i,r))return n=i,!1})),n}function Nt(e,t,i,n){for(var r=e.length,a=i+(n?1:-1);n?a--:++a<r;)if(t(e[a],a,e))return a;return-1}function Ut(e,t,i){return t==t?function(e,t,i){for(var n=i-1,r=e.length;++n<r;)if(e[n]===t)return n;return-1}(e,t,i):Nt(e,Bt,i)}function Ft(e,t,i,n){for(var r=i-1,a=e.length;++r<a;)if(n(e[r],t))return r;return-1}function Bt(e){return e!=e}function zt(e,t){var i=null==e?0:e.length;return i?Gt(e,t)/i:c}function Ht(e){return function(t){return null==t?i:t[e]}}function Vt(e){return function(t){return null==e?i:e[t]}}function jt(e,t,i,n,r){return r(e,(function(e,r,a){i=n?(n=!1,e):t(i,e,r,a)})),i}function Gt(e,t){for(var n,r=-1,a=e.length;++r<a;){var s=t(e[r]);s!==i&&(n=n===i?s:n+s)}return n}function Wt(e,t){for(var i=-1,n=Array(e);++i<e;)n[i]=t(i);return n}function Xt(e){return e&&e.slice(0,li(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 Zt(e,t){return e.has(t)}function Qt(e,t){for(var i=-1,n=e.length;++i<n&&Ut(t,e[i],0)>-1;);return i}function Jt(e,t){for(var i=e.length;i--&&Ut(t,e[i],0)>-1;);return i}var Kt=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"}),$t=Vt({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"});function ei(e){return"\\"+rt[e]}function ti(e){return Ke.test(e)}function ii(e){var t=-1,i=Array(e.size);return e.forEach((function(e,n){i[++t]=[n,e]})),i}function ni(e,t){return function(i){return e(t(i))}}function ri(e,t){for(var i=-1,n=e.length,r=0,s=[];++i<n;){var o=e[i];(o===t||o===a)&&(e[i]=a,s[r++]=i)}return s}function ai(e){var t=-1,i=Array(e.size);return e.forEach((function(e){i[++t]=e})),i}function si(e){return ti(e)?function(e){for(var t=Qe.lastIndex=0;Qe.test(e);)++t;return t}(e):Ot(e)}function oi(e){return ti(e)?function(e){return e.match(Qe)||[]}(e):function(e){return e.split("")}(e)}function li(e){for(var t=e.length;t--&&ie.test(e.charAt(t)););return t}var hi=Vt({"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'"}),ci=function e(t){var ie,xe=(t=null==t?ht:ci.defaults(ht.Object(),t,ci.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,De=t["__core-js_shared__"],Le=Pe.toString,Ie=Re.hasOwnProperty,Oe=0,ke=(ie=/[^.]+$/.exec(De&&De.keys&&De.keys.IE_PROTO||""))?"Symbol(src)_1."+ie:"",Ne=Re.toString,Ue=Le.call(Me),Fe=ht._,Be=Ee("^"+Le.call(Ie).replace($,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),ze=dt?t.Buffer:i,He=t.Symbol,Ve=t.Uint8Array,je=ze?ze.allocUnsafe:i,Ge=ni(Me.getPrototypeOf,Me),We=Me.create,Xe=Re.propertyIsEnumerable,Ye=Ce.splice,Qe=He?He.isConcatSpreadable:i,Ke=He?He.iterator:i,rt=He?He.toStringTag:i,ot=function(){try{var e=oa(Me,"defineProperty");return e({},"",{}),e}catch(e){}}(),lt=t.clearTimeout!==ht.clearTimeout&&t.clearTimeout,ct=be&&be.now!==ht.Date.now&&be.now,ut=t.setTimeout!==ht.setTimeout&&t.setTimeout,pt=Se.ceil,ft=Se.floor,Ot=Me.getOwnPropertySymbols,Vt=ze?ze.isBuffer:i,ui=t.isFinite,di=Ce.join,pi=ni(Me.keys,Me),fi=Se.max,mi=Se.min,gi=be.now,vi=t.parseInt,yi=Se.random,xi=Ce.reverse,bi=oa(t,"DataView"),_i=oa(t,"Map"),wi=oa(t,"Promise"),Si=oa(t,"Set"),Mi=oa(t,"WeakMap"),Ei=oa(Me,"create"),Ti=Mi&&new Mi,Ai={},Ci=Oa(bi),Pi=Oa(_i),Ri=Oa(wi),Di=Oa(Si),Li=Oa(Mi),Ii=He?He.prototype:i,Oi=Ii?Ii.valueOf:i,ki=Ii?Ii.toString:i;function Ni(e){if(Js(e)&&!zs(e)&&!(e instanceof zi)){if(e instanceof Bi)return e;if(Ie.call(e,"__wrapped__"))return ka(e)}return new Bi(e)}var Ui=function(){function e(){}return function(t){if(!Qs(t))return{};if(We)return We(t);e.prototype=t;var n=new e;return e.prototype=i,n}}();function Fi(){}function Bi(e,t){this.__wrapped__=e,this.__actions__=[],this.__chain__=!!t,this.__index__=0,this.__values__=i}function zi(e){this.__wrapped__=e,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=u,this.__views__=[]}function Hi(e){var t=-1,i=null==e?0:e.length;for(this.clear();++t<i;){var n=e[t];this.set(n[0],n[1])}}function Vi(e){var t=-1,i=null==e?0:e.length;for(this.clear();++t<i;){var n=e[t];this.set(n[0],n[1])}}function ji(e){var t=-1,i=null==e?0:e.length;for(this.clear();++t<i;){var n=e[t];this.set(n[0],n[1])}}function Gi(e){var t=-1,i=null==e?0:e.length;for(this.__data__=new ji;++t<i;)this.add(e[t])}function Wi(e){var t=this.__data__=new Vi(e);this.size=t.size}function Xi(e,t){var i=zs(e),n=!i&&Bs(e),r=!i&&!n&&Gs(e),a=!i&&!n&&!r&&ao(e),s=i||n||r||a,o=s?Wt(e.length,Te):[],l=o.length;for(var h in e)(t||Ie.call(e,h))&&(!s||!("length"==h||r&&("offset"==h||"parent"==h)||a&&("buffer"==h||"byteLength"==h||"byteOffset"==h)||fa(h,l)))&&o.push(h);return o}function Yi(e){var t=e.length;return t?e[Gn(0,t-1)]:i}function qi(e,t){return Da(Er(e),rn(t,0,e.length))}function Zi(e){return Da(Er(e))}function Qi(e,t,n){(n!==i&&!Ns(e[t],n)||n===i&&!(t in e))&&tn(e,t,n)}function Ji(e,t,n){var r=e[t];(!Ie.call(e,t)||!Ns(r,n)||n===i&&!(t in e))&&tn(e,t,n)}function Ki(e,t){for(var i=e.length;i--;)if(Ns(e[i][0],t))return i;return-1}function $i(e,t,i,n){return hn(e,(function(e,r,a){t(n,e,i(e),a)})),n}function en(e,t){return e&&Tr(t,Co(t),e)}function tn(e,t,i){"__proto__"==t&&ot?ot(e,t,{configurable:!0,enumerable:!0,value:i,writable:!0}):e[t]=i}function nn(e,t){for(var n=-1,r=t.length,a=xe(r),s=null==e;++n<r;)a[n]=s?i:So(e,t[n]);return a}function rn(e,t,n){return e==e&&(n!==i&&(e=e<=n?e:n),t!==i&&(e=e>=t?e:t)),e}function an(e,t,n,r,a,s){var o,l=1&t,h=2&t,c=4&t;if(n&&(o=a?n(e,r,a,s):n(e)),o!==i)return o;if(!Qs(e))return e;var u=zs(e);if(u){if(o=function(e){var t=e.length,i=new e.constructor(t);return t&&"string"==typeof e[0]&&Ie.call(e,"index")&&(i.index=e.index,i.input=e.input),i}(e),!l)return Er(e,o)}else{var d=ca(e),f=d==y||d==x;if(Gs(e))return xr(e,l);if(d==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,Po(t),e)}(o,e)):function(e,t){return Tr(e,la(e),t)}(e,en(o,e))}else{if(!nt[d])return a?e:{};o=function(e,t,i){var n=e.constructor;switch(t){case P:return br(e);case m:case g:return new n(+e);case R:return function(e,t){var i=t?br(e.buffer):e.buffer;return new e.constructor(i,e.byteOffset,e.byteLength)}(e,i);case D:case L:case I:case O:case k:case N:case U:case F:case B:return _r(e,i);case b:return new n;case _:case T:return new n(e);case M:return function(e){var t=new e.constructor(e.source,ce.exec(e));return t.lastIndex=e.lastIndex,t}(e);case E:return new n;case A:return function(e){return Oi?Me(Oi.call(e)):{}}(e)}}(e,d,l)}}s||(s=new Wi);var v=s.get(e);if(v)return v;s.set(e,o),io(e)?e.forEach((function(i){o.add(an(i,t,n,i,e,s))})):Ks(e)&&e.forEach((function(i,r){o.set(r,an(i,t,n,r,e,s))}));var S=u?i:(c?h?ea:$r:h?Po:Co)(e);return St(S||e,(function(i,r){S&&(i=e[r=i]),Ji(o,r,an(i,t,n,r,e,s))})),o}function sn(e,t,n){var r=n.length;if(null==e)return!r;for(e=Me(e);r--;){var a=n[r],s=t[a],o=e[a];if(o===i&&!(a in e)||!s(o))return!1}return!0}function on(e,t,r){if("function"!=typeof e)throw new Ae(n);return Aa((function(){e.apply(i,r)}),t)}function ln(e,t,i,n){var r=-1,a=At,s=!0,o=e.length,l=[],h=t.length;if(!o)return l;i&&(t=Pt(t,Yt(i))),n?(a=Ct,s=!1):t.length>=200&&(a=Zt,s=!1,t=new Gi(t));e:for(;++r<o;){var c=e[r],u=null==i?c:i(c);if(c=n||0!==c?c:0,s&&u==u){for(var d=h;d--;)if(t[d]===u)continue e;l.push(c)}else a(t,u,n)||l.push(c)}return l}Ni.templateSettings={escape:Y,evaluate:q,interpolate:Z,variable:"",imports:{_:Ni}},Ni.prototype=Fi.prototype,Ni.prototype.constructor=Ni,Bi.prototype=Ui(Fi.prototype),Bi.prototype.constructor=Bi,zi.prototype=Ui(Fi.prototype),zi.prototype.constructor=zi,Hi.prototype.clear=function(){this.__data__=Ei?Ei(null):{},this.size=0},Hi.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},Hi.prototype.get=function(e){var t=this.__data__;if(Ei){var n=t[e];return n===r?i:n}return Ie.call(t,e)?t[e]:i},Hi.prototype.has=function(e){var t=this.__data__;return Ei?t[e]!==i:Ie.call(t,e)},Hi.prototype.set=function(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=Ei&&t===i?r:t,this},Vi.prototype.clear=function(){this.__data__=[],this.size=0},Vi.prototype.delete=function(e){var t=this.__data__,i=Ki(t,e);return!(i<0)&&(i==t.length-1?t.pop():Ye.call(t,i,1),--this.size,!0)},Vi.prototype.get=function(e){var t=this.__data__,n=Ki(t,e);return n<0?i:t[n][1]},Vi.prototype.has=function(e){return Ki(this.__data__,e)>-1},Vi.prototype.set=function(e,t){var i=this.__data__,n=Ki(i,e);return n<0?(++this.size,i.push([e,t])):i[n][1]=t,this},ji.prototype.clear=function(){this.size=0,this.__data__={hash:new Hi,map:new(_i||Vi),string:new Hi}},ji.prototype.delete=function(e){var t=aa(this,e).delete(e);return this.size-=t?1:0,t},ji.prototype.get=function(e){return aa(this,e).get(e)},ji.prototype.has=function(e){return aa(this,e).has(e)},ji.prototype.set=function(e,t){var i=aa(this,e),n=i.size;return i.set(e,t),this.size+=i.size==n?0:1,this},Gi.prototype.add=Gi.prototype.push=function(e){return this.__data__.set(e,r),this},Gi.prototype.has=function(e){return this.__data__.has(e)},Wi.prototype.clear=function(){this.__data__=new Vi,this.size=0},Wi.prototype.delete=function(e){var t=this.__data__,i=t.delete(e);return this.size=t.size,i},Wi.prototype.get=function(e){return this.__data__.get(e)},Wi.prototype.has=function(e){return this.__data__.has(e)},Wi.prototype.set=function(e,t){var i=this.__data__;if(i instanceof Vi){var n=i.__data__;if(!_i||n.length<199)return n.push([e,t]),this.size=++i.size,this;i=this.__data__=new ji(n)}return i.set(e,t),this.size=i.size,this};var hn=Pr(vn),cn=Pr(yn,!0);function un(e,t){var i=!0;return hn(e,(function(e,n,r){return i=!!t(e,n,r)})),i}function dn(e,t,n){for(var r=-1,a=e.length;++r<a;){var s=e[r],o=t(s);if(null!=o&&(l===i?o==o&&!ro(o):n(o,l)))var l=o,h=s}return h}function pn(e,t){var i=[];return hn(e,(function(e,n,r){t(e,n,r)&&i.push(e)})),i}function fn(e,t,i,n,r){var a=-1,s=e.length;for(i||(i=pa),r||(r=[]);++a<s;){var o=e[a];t>0&&i(o)?t>1?fn(o,t-1,i,n,r):Rt(r,o):n||(r[r.length]=o)}return r}var mn=Rr(),gn=Rr(!0);function vn(e,t){return e&&mn(e,t,Co)}function yn(e,t){return e&&gn(e,t,Co)}function xn(e,t){return Tt(t,(function(t){return Ys(e[t])}))}function bn(e,t){for(var n=0,r=(t=mr(t,e)).length;null!=e&&n<r;)e=e[Ia(t[n++])];return n&&n==r?e:i}function _n(e,t,i){var n=t(e);return zs(e)?n:Rt(n,i(e))}function wn(e){return null==e?e===i?"[object Undefined]":"[object Null]":rt&&rt in Me(e)?function(e){var t=Ie.call(e,rt),n=e[rt];try{e[rt]=i;var r=!0}catch(e){}var a=Ne.call(e);return r&&(t?e[rt]=n:delete e[rt]),a}(e):function(e){return Ne.call(e)}(e)}function Sn(e,t){return e>t}function Mn(e,t){return null!=e&&Ie.call(e,t)}function En(e,t){return null!=e&&t in Me(e)}function Tn(e,t,n){for(var r=n?Ct:At,a=e[0].length,s=e.length,o=s,l=xe(s),h=1/0,c=[];o--;){var u=e[o];o&&t&&(u=Pt(u,Yt(t))),h=mi(u.length,h),l[o]=!n&&(t||a>=120&&u.length>=120)?new Gi(o&&u):i}u=e[0];var d=-1,p=l[0];e:for(;++d<a&&c.length<h;){var f=u[d],m=t?t(f):f;if(f=n||0!==f?f:0,!(p?Zt(p,m):r(c,m,n))){for(o=s;--o;){var g=l[o];if(!(g?Zt(g,m):r(e[o],m,n)))continue e}p&&p.push(m),c.push(f)}}return c}function An(e,t,n){var r=null==(e=Sa(e,t=mr(t,e)))?e:e[Ia(Xa(t))];return null==r?i:_t(r,e,n)}function Cn(e){return Js(e)&&wn(e)==p}function Pn(e,t,n,r,a){return e===t||(null==e||null==t||!Js(e)&&!Js(t)?e!=e&&t!=t:function(e,t,n,r,a,s){var o=zs(e),l=zs(t),h=o?f:ca(e),c=l?f:ca(t),u=(h=h==p?w:h)==w,d=(c=c==p?w:c)==w,y=h==c;if(y&&Gs(e)){if(!Gs(t))return!1;o=!0,u=!1}if(y&&!u)return s||(s=new Wi),o||ao(e)?Jr(e,t,n,r,a,s):function(e,t,i,n,r,a,s){switch(i){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 Ns(+e,+t);case v:return e.name==t.name&&e.message==t.message;case M:case T:return e==t+"";case b:var o=ii;case E:var l=1&n;if(o||(o=ai),e.size!=t.size&&!l)return!1;var h=s.get(e);if(h)return h==t;n|=2,s.set(e,t);var c=Jr(o(e),o(t),n,r,a,s);return s.delete(e),c;case A:if(Oi)return Oi.call(e)==Oi.call(t)}return!1}(e,t,h,n,r,a,s);if(!(1&n)){var x=u&&Ie.call(e,"__wrapped__"),S=d&&Ie.call(t,"__wrapped__");if(x||S){var C=x?e.value():e,D=S?t.value():t;return s||(s=new Wi),a(C,D,n,r,s)}}return!!y&&(s||(s=new Wi),function(e,t,n,r,a,s){var o=1&n,l=$r(e),h=l.length;if(h!=$r(t).length&&!o)return!1;for(var c=h;c--;){var u=l[c];if(!(o?u in t:Ie.call(t,u)))return!1}var d=s.get(e),p=s.get(t);if(d&&p)return d==t&&p==e;var f=!0;s.set(e,t),s.set(t,e);for(var m=o;++c<h;){var g=e[u=l[c]],v=t[u];if(r)var y=o?r(v,g,u,t,e,s):r(g,v,u,e,t,s);if(!(y===i?g===v||a(g,v,n,r,s):y)){f=!1;break}m||(m="constructor"==u)}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,n,r,a,s))}(e,t,n,r,Pn,a))}function Rn(e,t,n,r){var a=n.length,s=a,o=!r;if(null==e)return!s;for(e=Me(e);a--;){var l=n[a];if(o&&l[2]?l[1]!==e[l[0]]:!(l[0]in e))return!1}for(;++a<s;){var h=(l=n[a])[0],c=e[h],u=l[1];if(o&&l[2]){if(c===i&&!(h in e))return!1}else{var d=new Wi;if(r)var p=r(c,u,h,e,t,d);if(!(p===i?Pn(u,c,3,r,d):p))return!1}}return!0}function Dn(e){return!(!Qs(e)||function(e){return!!ke&&ke in e}(e))&&(Ys(e)?Be:pe).test(Oa(e))}function Ln(e){return"function"==typeof e?e:null==e?el:"object"==typeof e?zs(e)?Un(e[0],e[1]):Nn(e):hl(e)}function In(e){if(!xa(e))return pi(e);var t=[];for(var i in Me(e))Ie.call(e,i)&&"constructor"!=i&&t.push(i);return t}function On(e,t){return e<t}function kn(e,t){var i=-1,n=Vs(e)?xe(e.length):[];return hn(e,(function(e,r,a){n[++i]=t(e,r,a)})),n}function Nn(e){var t=sa(e);return 1==t.length&&t[0][2]?_a(t[0][0],t[0][1]):function(i){return i===e||Rn(i,e,t)}}function Un(e,t){return ga(e)&&ba(t)?_a(Ia(e),t):function(n){var r=So(n,e);return r===i&&r===t?Mo(n,e):Pn(t,r,3)}}function Fn(e,t,n,r,a){e!==t&&mn(t,(function(s,o){if(a||(a=new Wi),Qs(s))!function(e,t,n,r,a,s,o){var l=Ea(e,n),h=Ea(t,n),c=o.get(h);if(c)Qi(e,n,c);else{var u=s?s(l,h,n+"",e,t,o):i,d=u===i;if(d){var p=zs(h),f=!p&&Gs(h),m=!p&&!f&&ao(h);u=h,p||f||m?zs(l)?u=l:js(l)?u=Er(l):f?(d=!1,u=xr(h,!0)):m?(d=!1,u=_r(h,!0)):u=[]:eo(h)||Bs(h)?(u=l,Bs(l)?u=fo(l):(!Qs(l)||Ys(l))&&(u=da(h))):d=!1}d&&(o.set(h,u),a(u,h,r,s,o),o.delete(h)),Qi(e,n,u)}}(e,t,o,n,Fn,r,a);else{var l=r?r(Ea(e,o),s,o+"",e,t,a):i;l===i&&(l=s),Qi(e,o,l)}}),Po)}function Bn(e,t){var n=e.length;if(n)return fa(t+=t<0?n:0,n)?e[t]:i}function zn(e,t,i){t=t.length?Pt(t,(function(e){return zs(e)?function(t){return bn(t,1===e.length?e[0]:e)}:e})):[el];var n=-1;return t=Pt(t,Yt(ra())),function(e,t){var i=e.length;for(e.sort(t);i--;)e[i]=e[i].value;return e}(kn(e,(function(e,i,r){return{criteria:Pt(t,(function(t){return t(e)})),index:++n,value:e}})),(function(e,t){return function(e,t,i){for(var n=-1,r=e.criteria,a=t.criteria,s=r.length,o=i.length;++n<s;){var l=wr(r[n],a[n]);if(l)return n>=o?l:l*("desc"==i[n]?-1:1)}return e.index-t.index}(e,t,i)}))}function Hn(e,t,i){for(var n=-1,r=t.length,a={};++n<r;){var s=t[n],o=bn(e,s);i(o,s)&&Zn(a,mr(s,e),o)}return a}function Vn(e,t,i,n){var r=n?Ft:Ut,a=-1,s=t.length,o=e;for(e===t&&(t=Er(t)),i&&(o=Pt(e,Yt(i)));++a<s;)for(var l=0,h=t[a],c=i?i(h):h;(l=r(o,c,l,n))>-1;)o!==e&&Ye.call(o,l,1),Ye.call(e,l,1);return e}function jn(e,t){for(var i=e?t.length:0,n=i-1;i--;){var r=t[i];if(i==n||r!==a){var a=r;fa(r)?Ye.call(e,r,1):or(e,r)}}return e}function Gn(e,t){return e+ft(yi()*(t-e+1))}function Wn(e,t){var i="";if(!e||t<1||t>h)return i;do{t%2&&(i+=e),(t=ft(t/2))&&(e+=e)}while(t);return i}function Xn(e,t){return Ca(wa(e,t,el),e+"")}function Yn(e){return Yi(Uo(e))}function qn(e,t){var i=Uo(e);return Da(i,rn(t,0,i.length))}function Zn(e,t,n,r){if(!Qs(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]),c=n;if("__proto__"===h||"constructor"===h||"prototype"===h)return e;if(a!=o){var u=l[h];(c=r?r(u,h,l):i)===i&&(c=Qs(u)?u:fa(t[a+1])?[]:{})}Ji(l,h,c),l=l[h]}return e}var Qn=Ti?function(e,t){return Ti.set(e,t),e}:el,Jn=ot?function(e,t){return ot(e,"toString",{configurable:!0,enumerable:!1,value:Jo(t),writable:!0})}:el;function Kn(e){return Da(Uo(e))}function $n(e,t,i){var n=-1,r=e.length;t<0&&(t=-t>r?0:r+t),(i=i>r?r:i)<0&&(i+=r),r=t>i?0:i-t>>>0,t>>>=0;for(var a=xe(r);++n<r;)a[n]=e[n+t];return a}function er(e,t){var i;return hn(e,(function(e,n,r){return!(i=t(e,n,r))})),!!i}function tr(e,t,i){var n=0,r=null==e?n:e.length;if("number"==typeof t&&t==t&&r<=2147483647){for(;n<r;){var a=n+r>>>1,s=e[a];null!==s&&!ro(s)&&(i?s<=t:s<t)?n=a+1:r=a}return r}return ir(e,t,el,i)}function ir(e,t,n,r){var a=0,s=null==e?0:e.length;if(0===s)return 0;for(var o=(t=n(t))!=t,l=null===t,h=ro(t),c=t===i;a<s;){var u=ft((a+s)/2),d=n(e[u]),p=d!==i,f=null===d,m=d==d,g=ro(d);if(o)var v=r||m;else v=c?m&&(r||p):l?m&&p&&(r||!f):h?m&&p&&!f&&(r||!g):!f&&!g&&(r?d<=t:d<t);v?a=u+1:s=u}return mi(s,4294967294)}function nr(e,t){for(var i=-1,n=e.length,r=0,a=[];++i<n;){var s=e[i],o=t?t(s):s;if(!i||!Ns(o,l)){var l=o;a[r++]=0===s?0:s}}return a}function rr(e){return"number"==typeof e?e:ro(e)?c:+e}function ar(e){if("string"==typeof e)return e;if(zs(e))return Pt(e,ar)+"";if(ro(e))return ki?ki.call(e):"";var t=e+"";return"0"==t&&1/e==-l?"-0":t}function sr(e,t,i){var n=-1,r=At,a=e.length,s=!0,o=[],l=o;if(i)s=!1,r=Ct;else if(a>=200){var h=t?null:Wr(e);if(h)return ai(h);s=!1,r=Zt,l=new Gi}else l=t?[]:o;e:for(;++n<a;){var c=e[n],u=t?t(c):c;if(c=i||0!==c?c:0,s&&u==u){for(var d=l.length;d--;)if(l[d]===u)continue e;t&&l.push(u),o.push(c)}else r(l,u,i)||(l!==o&&l.push(u),o.push(c))}return o}function or(e,t){return null==(e=Sa(e,t=mr(t,e)))||delete e[Ia(Xa(t))]}function lr(e,t,i,n){return Zn(e,t,i(bn(e,t)),n)}function hr(e,t,i,n){for(var r=e.length,a=n?r:-1;(n?a--:++a<r)&&t(e[a],a,e););return i?$n(e,n?0:a,n?a+1:r):$n(e,n?a+1:0,n?r:a)}function cr(e,t){var i=e;return i instanceof zi&&(i=i.value()),Dt(t,(function(e,t){return t.func.apply(t.thisArg,Rt([e],t.args))}),i)}function ur(e,t,i){var n=e.length;if(n<2)return n?sr(e[0]):[];for(var r=-1,a=xe(n);++r<n;)for(var s=e[r],o=-1;++o<n;)o!=r&&(a[r]=ln(a[r]||s,e[o],t,i));return sr(fn(a,1),t,i)}function dr(e,t,n){for(var r=-1,a=e.length,s=t.length,o={};++r<a;){var l=r<s?t[r]:i;n(o,e[r],l)}return o}function pr(e){return js(e)?e:[]}function fr(e){return"function"==typeof e?e:el}function mr(e,t){return zs(e)?e:ga(e,t)?[e]:La(mo(e))}var gr=Xn;function vr(e,t,n){var r=e.length;return n=n===i?r:n,!t&&n>=r?e:$n(e,t,n)}var yr=lt||function(e){return ht.clearTimeout(e)};function xr(e,t){if(t)return e.slice();var i=e.length,n=je?je(i):new e.constructor(i);return e.copy(n),n}function br(e){var t=new e.constructor(e.byteLength);return new Ve(t).set(new Ve(e)),t}function _r(e,t){var i=t?br(e.buffer):e.buffer;return new e.constructor(i,e.byteOffset,e.length)}function wr(e,t){if(e!==t){var n=e!==i,r=null===e,a=e==e,s=ro(e),o=t!==i,l=null===t,h=t==t,c=ro(t);if(!l&&!c&&!s&&e>t||s&&o&&h&&!l&&!c||r&&o&&h||!n&&h||!a)return 1;if(!r&&!s&&!c&&e<t||c&&n&&a&&!r&&!s||l&&n&&a||!o&&a||!h)return-1}return 0}function Sr(e,t,i,n){for(var r=-1,a=e.length,s=i.length,o=-1,l=t.length,h=fi(a-s,0),c=xe(l+h),u=!n;++o<l;)c[o]=t[o];for(;++r<s;)(u||r<a)&&(c[i[r]]=e[r]);for(;h--;)c[o++]=e[r++];return c}function Mr(e,t,i,n){for(var r=-1,a=e.length,s=-1,o=i.length,l=-1,h=t.length,c=fi(a-o,0),u=xe(c+h),d=!n;++r<c;)u[r]=e[r];for(var p=r;++l<h;)u[p+l]=t[l];for(;++s<o;)(d||r<a)&&(u[p+i[s]]=e[r++]);return u}function Er(e,t){var i=-1,n=e.length;for(t||(t=xe(n));++i<n;)t[i]=e[i];return t}function Tr(e,t,n,r){var a=!n;n||(n={});for(var s=-1,o=t.length;++s<o;){var l=t[s],h=r?r(n[l],e[l],l,n,e):i;h===i&&(h=e[l]),a?tn(n,l,h):Ji(n,l,h)}return n}function Ar(e,t){return function(i,n){var r=zs(i)?wt:$i,a=t?t():{};return r(i,e,ra(n,2),a)}}function Cr(e){return Xn((function(t,n){var r=-1,a=n.length,s=a>1?n[a-1]:i,o=a>2?n[2]:i;for(s=e.length>3&&"function"==typeof s?(a--,s):i,o&&ma(n[0],n[1],o)&&(s=a<3?i:s,a=1),t=Me(t);++r<a;){var l=n[r];l&&e(t,l,r,s)}return t}))}function Pr(e,t){return function(i,n){if(null==i)return i;if(!Vs(i))return e(i,n);for(var r=i.length,a=t?r:-1,s=Me(i);(t?a--:++a<r)&&!1!==n(s[a],a,s););return i}}function Rr(e){return function(t,i,n){for(var r=-1,a=Me(t),s=n(t),o=s.length;o--;){var l=s[e?o:++r];if(!1===i(a[l],l,a))break}return t}}function Dr(e){return function(t){var n=ti(t=mo(t))?oi(t):i,r=n?n[0]:t.charAt(0),a=n?vr(n,1).join(""):t.slice(1);return r[e]()+a}}function Lr(e){return function(t){return Dt(qo(zo(t).replace(qe,"")),e,"")}}function Ir(e){return function(){var t=arguments;switch(t.length){case 0:return new e;case 1:return new e(t[0]);case 2:return new e(t[0],t[1]);case 3:return new e(t[0],t[1],t[2]);case 4:return new e(t[0],t[1],t[2],t[3]);case 5:return new e(t[0],t[1],t[2],t[3],t[4]);case 6:return new e(t[0],t[1],t[2],t[3],t[4],t[5]);case 7:return new e(t[0],t[1],t[2],t[3],t[4],t[5],t[6])}var i=Ui(e.prototype),n=e.apply(i,t);return Qs(n)?n:i}}function Or(e){return function(t,n,r){var a=Me(t);if(!Vs(t)){var s=ra(n,3);t=Co(t),n=function(e){return s(a[e],e,a)}}var o=e(t,n,r);return o>-1?a[s?t[o]:o]:i}}function kr(e){return Kr((function(t){var r=t.length,a=r,s=Bi.prototype.thru;for(e&&t.reverse();a--;){var o=t[a];if("function"!=typeof o)throw new Ae(n);if(s&&!l&&"wrapper"==ia(o))var l=new Bi([],!0)}for(a=l?a:r;++a<r;){var h=ia(o=t[a]),c="wrapper"==h?ta(o):i;l=c&&va(c[0])&&424==c[1]&&!c[4].length&&1==c[9]?l[ia(c[0])].apply(l,c[3]):1==o.length&&va(o)?l[h]():l.thru(o)}return function(){var e=arguments,i=e[0];if(l&&1==e.length&&zs(i))return l.plant(i).value();for(var n=0,a=r?t[n].apply(this,e):i;++n<r;)a=t[n].call(this,a);return a}}))}function Nr(e,t,n,r,a,s,l,h,c,u){var d=t&o,p=1&t,f=2&t,m=24&t,g=512&t,v=f?i:Ir(e);return function i(){for(var o=arguments.length,y=xe(o),x=o;x--;)y[x]=arguments[x];if(m)var b=na(i),_=function(e,t){for(var i=e.length,n=0;i--;)e[i]===t&&++n;return n}(y,b);if(r&&(y=Sr(y,r,a,m)),s&&(y=Mr(y,s,l,m)),o-=_,m&&o<u){var w=ri(y,b);return jr(e,t,Nr,i.placeholder,n,y,w,h,c,u-o)}var S=p?n:this,M=f?S[e]:e;return o=y.length,h?y=Ma(y,h):g&&o>1&&y.reverse(),d&&c<o&&(y.length=c),this&&this!==ht&&this instanceof i&&(M=v||Ir(M)),M.apply(S,y)}}function Ur(e,t){return function(i,n){return function(e,t,i,n){return vn(e,(function(e,r,a){t(n,i(e),r,a)})),n}(i,e,t(n),{})}}function Fr(e,t){return function(n,r){var a;if(n===i&&r===i)return t;if(n!==i&&(a=n),r!==i){if(a===i)return r;"string"==typeof n||"string"==typeof r?(n=ar(n),r=ar(r)):(n=rr(n),r=rr(r)),a=e(n,r)}return a}}function Br(e){return Kr((function(t){return t=Pt(t,Yt(ra())),Xn((function(i){var n=this;return e(t,(function(e){return _t(e,n,i)}))}))}))}function zr(e,t){var n=(t=t===i?" ":ar(t)).length;if(n<2)return n?Wn(t,e):t;var r=Wn(t,pt(e/si(t)));return ti(t)?vr(oi(r),0,e).join(""):r.slice(0,e)}function Hr(e){return function(t,n,r){return r&&"number"!=typeof r&&ma(t,n,r)&&(n=r=i),t=ho(t),n===i?(n=t,t=0):n=ho(n),function(e,t,i,n){for(var r=-1,a=fi(pt((t-e)/(i||1)),0),s=xe(a);a--;)s[n?a:++r]=e,e+=i;return s}(t,n,r=r===i?t<n?1:-1:ho(r),e)}}function Vr(e){return function(t,i){return"string"==typeof t&&"string"==typeof i||(t=po(t),i=po(i)),e(t,i)}}function jr(e,t,n,r,a,o,l,h,c,u){var d=8&t;t|=d?s:64,4&(t&=~(d?64:s))||(t&=-4);var p=[e,t,a,d?o:i,d?l:i,d?i:o,d?i:l,h,c,u],f=n.apply(i,p);return va(e)&&Ta(f,p),f.placeholder=r,Pa(f,e,t)}function Gr(e){var t=Se[e];return function(e,i){if(e=po(e),(i=null==i?0:mi(co(i),292))&&ui(e)){var n=(mo(e)+"e").split("e");return+((n=(mo(t(n[0]+"e"+(+n[1]+i)))+"e").split("e"))[0]+"e"+(+n[1]-i))}return t(e)}}var Wr=Si&&1/ai(new Si([,-0]))[1]==l?function(e){return new Si(e)}:al;function Xr(e){return function(t){var i=ca(t);return i==b?ii(t):i==E?function(e){var t=-1,i=Array(e.size);return e.forEach((function(e){i[++t]=[e,e]})),i}(t):function(e,t){return Pt(t,(function(t){return[t,e[t]]}))}(t,e(t))}}function Yr(e,t,r,l,h,c,u,d){var p=2&t;if(!p&&"function"!=typeof e)throw new Ae(n);var f=l?l.length:0;if(f||(t&=-97,l=h=i),u=u===i?u:fi(co(u),0),d=d===i?d:co(d),f-=h?h.length:0,64&t){var m=l,g=h;l=h=i}var v=p?i:ta(e),y=[e,t,r,l,h,m,g,c,u,d];if(v&&function(e,t){var i=e[1],n=t[1],r=i|n,s=r<131,l=n==o&&8==i||n==o&&256==i&&e[7].length<=t[8]||384==n&&t[7].length<=t[8]&&8==i;if(!s&&!l)return e;1&n&&(e[2]=t[2],r|=1&i?0:4);var h=t[3];if(h){var c=e[3];e[3]=c?Sr(c,h,t[4]):h,e[4]=c?ri(e[3],a):t[4]}(h=t[5])&&(c=e[5],e[5]=c?Mr(c,h,t[6]):h,e[6]=c?ri(e[5],a):t[6]),(h=t[7])&&(e[7]=h),n&o&&(e[8]=null==e[8]?t[8]:mi(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]===i?p?0:e.length:fi(y[9]-f,0))&&24&t&&(t&=-25),t&&1!=t)x=8==t||16==t?function(e,t,n){var r=Ir(e);return function a(){for(var s=arguments.length,o=xe(s),l=s,h=na(a);l--;)o[l]=arguments[l];var c=s<3&&o[0]!==h&&o[s-1]!==h?[]:ri(o,h);return(s-=c.length)<n?jr(e,t,Nr,a.placeholder,i,o,c,i,i,n-s):_t(this&&this!==ht&&this instanceof a?r:e,this,o)}}(e,t,d):t!=s&&33!=t||h.length?Nr.apply(i,y):function(e,t,i,n){var r=1&t,a=Ir(e);return function t(){for(var s=-1,o=arguments.length,l=-1,h=n.length,c=xe(h+o),u=this&&this!==ht&&this instanceof t?a:e;++l<h;)c[l]=n[l];for(;o--;)c[l++]=arguments[++s];return _t(u,r?i:this,c)}}(e,t,r,l);else var x=function(e,t,i){var n=1&t,r=Ir(e);return function t(){return(this&&this!==ht&&this instanceof t?r:e).apply(n?i:this,arguments)}}(e,t,r);return Pa((v?Qn:Ta)(x,y),e,t)}function qr(e,t,n,r){return e===i||Ns(e,Re[n])&&!Ie.call(r,n)?t:e}function Zr(e,t,n,r,a,s){return Qs(e)&&Qs(t)&&(s.set(t,e),Fn(e,t,i,Zr,s),s.delete(t)),e}function Qr(e){return eo(e)?i:e}function Jr(e,t,n,r,a,s){var o=1&n,l=e.length,h=t.length;if(l!=h&&!(o&&h>l))return!1;var c=s.get(e),u=s.get(t);if(c&&u)return c==t&&u==e;var d=-1,p=!0,f=2&n?new Gi:i;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!==i){if(v)continue;p=!1;break}if(f){if(!It(t,(function(e,t){if(!Zt(f,t)&&(m===e||a(m,e,n,r,s)))return f.push(t)}))){p=!1;break}}else if(m!==g&&!a(m,g,n,r,s)){p=!1;break}}return s.delete(e),s.delete(t),p}function Kr(e){return Ca(wa(e,i,Ha),e+"")}function $r(e){return _n(e,Co,la)}function ea(e){return _n(e,Po,ha)}var ta=Ti?function(e){return Ti.get(e)}:al;function ia(e){for(var t=e.name+"",i=Ai[t],n=Ie.call(Ai,t)?i.length:0;n--;){var r=i[n],a=r.func;if(null==a||a==e)return r.name}return t}function na(e){return(Ie.call(Ni,"placeholder")?Ni:e).placeholder}function ra(){var e=Ni.iteratee||tl;return e=e===tl?Ln:e,arguments.length?e(arguments[0],arguments[1]):e}function aa(e,t){var i=e.__data__;return function(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e}(t)?i["string"==typeof t?"string":"hash"]:i.map}function sa(e){for(var t=Co(e),i=t.length;i--;){var n=t[i],r=e[n];t[i]=[n,r,ba(r)]}return t}function oa(e,t){var n=function(e,t){return null==e?i:e[t]}(e,t);return Dn(n)?n:i}var la=Ot?function(e){return null==e?[]:(e=Me(e),Tt(Ot(e),(function(t){return Xe.call(e,t)})))}:dl,ha=Ot?function(e){for(var t=[];e;)Rt(t,la(e)),e=Ge(e);return t}:dl,ca=wn;function ua(e,t,i){for(var n=-1,r=(t=mr(t,e)).length,a=!1;++n<r;){var s=Ia(t[n]);if(!(a=null!=e&&i(e,s)))break;e=e[s]}return a||++n!=r?a:!!(r=null==e?0:e.length)&&Zs(r)&&fa(s,r)&&(zs(e)||Bs(e))}function da(e){return"function"!=typeof e.constructor||xa(e)?{}:Ui(Ge(e))}function pa(e){return zs(e)||Bs(e)||!!(Qe&&e&&e[Qe])}function fa(e,t){var i=typeof e;return!!(t=null==t?h:t)&&("number"==i||"symbol"!=i&&me.test(e))&&e>-1&&e%1==0&&e<t}function ma(e,t,i){if(!Qs(i))return!1;var n=typeof t;return!!("number"==n?Vs(i)&&fa(t,i.length):"string"==n&&t in i)&&Ns(i[t],e)}function ga(e,t){if(zs(e))return!1;var i=typeof e;return!("number"!=i&&"symbol"!=i&&"boolean"!=i&&null!=e&&!ro(e))||J.test(e)||!Q.test(e)||null!=t&&e in Me(t)}function va(e){var t=ia(e),i=Ni[t];if("function"!=typeof i||!(t in zi.prototype))return!1;if(e===i)return!0;var n=ta(i);return!!n&&e===n[0]}(bi&&ca(new bi(new ArrayBuffer(1)))!=R||_i&&ca(new _i)!=b||wi&&ca(wi.resolve())!=S||Si&&ca(new Si)!=E||Mi&&ca(new Mi)!=C)&&(ca=function(e){var t=wn(e),n=t==w?e.constructor:i,r=n?Oa(n):"";if(r)switch(r){case Ci:return R;case Pi:return b;case Ri:return S;case Di:return E;case Li:return C}return t});var ya=De?Ys:pl;function xa(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||Re)}function ba(e){return e==e&&!Qs(e)}function _a(e,t){return function(n){return null!=n&&n[e]===t&&(t!==i||e in Me(n))}}function wa(e,t,n){return t=fi(t===i?e.length-1:t,0),function(){for(var i=arguments,r=-1,a=fi(i.length-t,0),s=xe(a);++r<a;)s[r]=i[t+r];r=-1;for(var o=xe(t+1);++r<t;)o[r]=i[r];return o[t]=n(s),_t(e,this,o)}}function Sa(e,t){return t.length<2?e:bn(e,$n(t,0,-1))}function Ma(e,t){for(var n=e.length,r=mi(t.length,n),a=Er(e);r--;){var s=t[r];e[r]=fa(s,n)?a[s]:i}return e}function Ea(e,t){if(("constructor"!==t||"function"!=typeof e[t])&&"__proto__"!=t)return e[t]}var Ta=Ra(Qn),Aa=ut||function(e,t){return ht.setTimeout(e,t)},Ca=Ra(Jn);function Pa(e,t,i){var n=t+"";return Ca(e,function(e,t){var i=t.length;if(!i)return e;var n=i-1;return t[n]=(i>1?"& ":"")+t[n],t=t.join(i>2?", ":" "),e.replace(ne,"{\n/* [wrapped with "+t+"] */\n")}(n,function(e,t){return St(d,(function(i){var n="_."+i[0];t&i[1]&&!At(e,n)&&e.push(n)})),e.sort()}(function(e){var t=e.match(re);return t?t[1].split(ae):[]}(n),i)))}function Ra(e){var t=0,n=0;return function(){var r=gi(),a=16-(r-n);if(n=r,a>0){if(++t>=800)return arguments[0]}else t=0;return e.apply(i,arguments)}}function Da(e,t){var n=-1,r=e.length,a=r-1;for(t=t===i?r:t;++n<t;){var s=Gn(n,a),o=e[s];e[s]=e[n],e[n]=o}return e.length=t,e}var La=function(e){var t=Rs((function(e){var t=[];return 46===e.charCodeAt(0)&&t.push(""),e.replace(K,(function(e,i,n,r){t.push(n?r.replace(le,"$1"):i||e)})),t}),(function(e){return 500===i.size&&i.clear(),e})),i=t.cache;return t}();function Ia(e){if("string"==typeof e||ro(e))return e;var t=e+"";return"0"==t&&1/e==-l?"-0":t}function Oa(e){if(null!=e){try{return Le.call(e)}catch(e){}try{return e+""}catch(e){}}return""}function ka(e){if(e instanceof zi)return e.clone();var t=new Bi(e.__wrapped__,e.__chain__);return t.__actions__=Er(e.__actions__),t.__index__=e.__index__,t.__values__=e.__values__,t}var Na=Xn((function(e,t){return js(e)?ln(e,fn(t,1,js,!0)):[]})),Ua=Xn((function(e,t){var n=Xa(t);return js(n)&&(n=i),js(e)?ln(e,fn(t,1,js,!0),ra(n,2)):[]})),Fa=Xn((function(e,t){var n=Xa(t);return js(n)&&(n=i),js(e)?ln(e,fn(t,1,js,!0),i,n):[]}));function Ba(e,t,i){var n=null==e?0:e.length;if(!n)return-1;var r=null==i?0:co(i);return r<0&&(r=fi(n+r,0)),Nt(e,ra(t,3),r)}function za(e,t,n){var r=null==e?0:e.length;if(!r)return-1;var a=r-1;return n!==i&&(a=co(n),a=n<0?fi(r+a,0):mi(a,r-1)),Nt(e,ra(t,3),a,!0)}function Ha(e){return null!=e&&e.length?fn(e,1):[]}function Va(e){return e&&e.length?e[0]:i}var ja=Xn((function(e){var t=Pt(e,pr);return t.length&&t[0]===e[0]?Tn(t):[]})),Ga=Xn((function(e){var t=Xa(e),n=Pt(e,pr);return t===Xa(n)?t=i:n.pop(),n.length&&n[0]===e[0]?Tn(n,ra(t,2)):[]})),Wa=Xn((function(e){var t=Xa(e),n=Pt(e,pr);return(t="function"==typeof t?t:i)&&n.pop(),n.length&&n[0]===e[0]?Tn(n,i,t):[]}));function Xa(e){var t=null==e?0:e.length;return t?e[t-1]:i}var Ya=Xn(qa);function qa(e,t){return e&&e.length&&t&&t.length?Vn(e,t):e}var Za=Kr((function(e,t){var i=null==e?0:e.length,n=nn(e,t);return jn(e,Pt(t,(function(e){return fa(e,i)?+e:e})).sort(wr)),n}));function Qa(e){return null==e?e:xi.call(e)}var Ja=Xn((function(e){return sr(fn(e,1,js,!0))})),Ka=Xn((function(e){var t=Xa(e);return js(t)&&(t=i),sr(fn(e,1,js,!0),ra(t,2))})),$a=Xn((function(e){var t=Xa(e);return t="function"==typeof t?t:i,sr(fn(e,1,js,!0),i,t)}));function es(e){if(!e||!e.length)return[];var t=0;return e=Tt(e,(function(e){if(js(e))return t=fi(e.length,t),!0})),Wt(t,(function(t){return Pt(e,Ht(t))}))}function ts(e,t){if(!e||!e.length)return[];var n=es(e);return null==t?n:Pt(n,(function(e){return _t(t,i,e)}))}var is=Xn((function(e,t){return js(e)?ln(e,t):[]})),ns=Xn((function(e){return ur(Tt(e,js))})),rs=Xn((function(e){var t=Xa(e);return js(t)&&(t=i),ur(Tt(e,js),ra(t,2))})),as=Xn((function(e){var t=Xa(e);return t="function"==typeof t?t:i,ur(Tt(e,js),i,t)})),ss=Xn(es),os=Xn((function(e){var t=e.length,n=t>1?e[t-1]:i;return n="function"==typeof n?(e.pop(),n):i,ts(e,n)}));function ls(e){var t=Ni(e);return t.__chain__=!0,t}function hs(e,t){return t(e)}var cs=Kr((function(e){var t=e.length,n=t?e[0]:0,r=this.__wrapped__,a=function(t){return nn(t,e)};return!(t>1||this.__actions__.length)&&r instanceof zi&&fa(n)?((r=r.slice(n,+n+(t?1:0))).__actions__.push({func:hs,args:[a],thisArg:i}),new Bi(r,this.__chain__).thru((function(e){return t&&!e.length&&e.push(i),e}))):this.thru(a)})),us=Ar((function(e,t,i){Ie.call(e,i)?++e[i]:tn(e,i,1)})),ds=Or(Ba),ps=Or(za);function fs(e,t){return(zs(e)?St:hn)(e,ra(t,3))}function ms(e,t){return(zs(e)?Mt:cn)(e,ra(t,3))}var gs=Ar((function(e,t,i){Ie.call(e,i)?e[i].push(t):tn(e,i,[t])})),vs=Xn((function(e,t,i){var n=-1,r="function"==typeof t,a=Vs(e)?xe(e.length):[];return hn(e,(function(e){a[++n]=r?_t(t,e,i):An(e,t,i)})),a})),ys=Ar((function(e,t,i){tn(e,i,t)}));function xs(e,t){return(zs(e)?Pt:kn)(e,ra(t,3))}var bs=Ar((function(e,t,i){e[i?0:1].push(t)}),(function(){return[[],[]]})),_s=Xn((function(e,t){if(null==e)return[];var i=t.length;return i>1&&ma(e,t[0],t[1])?t=[]:i>2&&ma(t[0],t[1],t[2])&&(t=[t[0]]),zn(e,fn(t,1),[])})),ws=ct||function(){return ht.Date.now()};function Ss(e,t,n){return t=n?i:t,t=e&&null==t?e.length:t,Yr(e,o,i,i,i,i,t)}function Ms(e,t){var r;if("function"!=typeof t)throw new Ae(n);return e=co(e),function(){return--e>0&&(r=t.apply(this,arguments)),e<=1&&(t=i),r}}var Es=Xn((function(e,t,i){var n=1;if(i.length){var r=ri(i,na(Es));n|=s}return Yr(e,n,t,i,r)})),Ts=Xn((function(e,t,i){var n=3;if(i.length){var r=ri(i,na(Ts));n|=s}return Yr(t,n,e,i,r)}));function As(e,t,r){var a,s,o,l,h,c,u=0,d=!1,p=!1,f=!0;if("function"!=typeof e)throw new Ae(n);function m(t){var n=a,r=s;return a=s=i,u=t,l=e.apply(r,n)}function g(e){var n=e-c;return c===i||n>=t||n<0||p&&e-u>=o}function v(){var e=ws();if(g(e))return y(e);h=Aa(v,function(e){var i=t-(e-c);return p?mi(i,o-(e-u)):i}(e))}function y(e){return h=i,f&&a?m(e):(a=s=i,l)}function x(){var e=ws(),n=g(e);if(a=arguments,s=this,c=e,n){if(h===i)return function(e){return u=e,h=Aa(v,t),d?m(e):l}(c);if(p)return yr(h),h=Aa(v,t),m(c)}return h===i&&(h=Aa(v,t)),l}return t=po(t)||0,Qs(r)&&(d=!!r.leading,o=(p="maxWait"in r)?fi(po(r.maxWait)||0,t):o,f="trailing"in r?!!r.trailing:f),x.cancel=function(){h!==i&&yr(h),u=0,a=c=s=h=i},x.flush=function(){return h===i?l:y(ws())},x}var Cs=Xn((function(e,t){return on(e,1,t)})),Ps=Xn((function(e,t,i){return on(e,po(t)||0,i)}));function Rs(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw new Ae(n);var i=function(){var n=arguments,r=t?t.apply(this,n):n[0],a=i.cache;if(a.has(r))return a.get(r);var s=e.apply(this,n);return i.cache=a.set(r,s)||a,s};return i.cache=new(Rs.Cache||ji),i}function Ds(e){if("function"!=typeof e)throw new Ae(n);return function(){var t=arguments;switch(t.length){case 0:return!e.call(this);case 1:return!e.call(this,t[0]);case 2:return!e.call(this,t[0],t[1]);case 3:return!e.call(this,t[0],t[1],t[2])}return!e.apply(this,t)}}Rs.Cache=ji;var Ls=gr((function(e,t){var i=(t=1==t.length&&zs(t[0])?Pt(t[0],Yt(ra())):Pt(fn(t,1),Yt(ra()))).length;return Xn((function(n){for(var r=-1,a=mi(n.length,i);++r<a;)n[r]=t[r].call(this,n[r]);return _t(e,this,n)}))})),Is=Xn((function(e,t){var n=ri(t,na(Is));return Yr(e,s,i,t,n)})),Os=Xn((function(e,t){var n=ri(t,na(Os));return Yr(e,64,i,t,n)})),ks=Kr((function(e,t){return Yr(e,256,i,i,i,t)}));function Ns(e,t){return e===t||e!=e&&t!=t}var Us=Vr(Sn),Fs=Vr((function(e,t){return e>=t})),Bs=Cn(function(){return arguments}())?Cn:function(e){return Js(e)&&Ie.call(e,"callee")&&!Xe.call(e,"callee")},zs=xe.isArray,Hs=mt?Yt(mt):function(e){return Js(e)&&wn(e)==P};function Vs(e){return null!=e&&Zs(e.length)&&!Ys(e)}function js(e){return Js(e)&&Vs(e)}var Gs=Vt||pl,Ws=gt?Yt(gt):function(e){return Js(e)&&wn(e)==g};function Xs(e){if(!Js(e))return!1;var t=wn(e);return t==v||"[object DOMException]"==t||"string"==typeof e.message&&"string"==typeof e.name&&!eo(e)}function Ys(e){if(!Qs(e))return!1;var t=wn(e);return t==y||t==x||"[object AsyncFunction]"==t||"[object Proxy]"==t}function qs(e){return"number"==typeof e&&e==co(e)}function Zs(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=h}function Qs(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function Js(e){return null!=e&&"object"==typeof e}var Ks=vt?Yt(vt):function(e){return Js(e)&&ca(e)==b};function $s(e){return"number"==typeof e||Js(e)&&wn(e)==_}function eo(e){if(!Js(e)||wn(e)!=w)return!1;var t=Ge(e);if(null===t)return!0;var i=Ie.call(t,"constructor")&&t.constructor;return"function"==typeof i&&i instanceof i&&Le.call(i)==Ue}var to=yt?Yt(yt):function(e){return Js(e)&&wn(e)==M},io=xt?Yt(xt):function(e){return Js(e)&&ca(e)==E};function no(e){return"string"==typeof e||!zs(e)&&Js(e)&&wn(e)==T}function ro(e){return"symbol"==typeof e||Js(e)&&wn(e)==A}var ao=bt?Yt(bt):function(e){return Js(e)&&Zs(e.length)&&!!it[wn(e)]},so=Vr(On),oo=Vr((function(e,t){return e<=t}));function lo(e){if(!e)return[];if(Vs(e))return no(e)?oi(e):Er(e);if(Ke&&e[Ke])return function(e){for(var t,i=[];!(t=e.next()).done;)i.push(t.value);return i}(e[Ke]());var t=ca(e);return(t==b?ii:t==E?ai:Uo)(e)}function ho(e){return e?(e=po(e))===l||e===-l?17976931348623157e292*(e<0?-1:1):e==e?e:0:0===e?e:0}function co(e){var t=ho(e),i=t%1;return t==t?i?t-i:t:0}function uo(e){return e?rn(co(e),0,u):0}function po(e){if("number"==typeof e)return e;if(ro(e))return c;if(Qs(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=Qs(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=Xt(e);var i=de.test(e);return i||fe.test(e)?st(e.slice(2),i?2:8):ue.test(e)?c:+e}function fo(e){return Tr(e,Po(e))}function mo(e){return null==e?"":ar(e)}var go=Cr((function(e,t){if(xa(t)||Vs(t))Tr(t,Co(t),e);else for(var i in t)Ie.call(t,i)&&Ji(e,i,t[i])})),vo=Cr((function(e,t){Tr(t,Po(t),e)})),yo=Cr((function(e,t,i,n){Tr(t,Po(t),e,n)})),xo=Cr((function(e,t,i,n){Tr(t,Co(t),e,n)})),bo=Kr(nn),_o=Xn((function(e,t){e=Me(e);var n=-1,r=t.length,a=r>2?t[2]:i;for(a&&ma(t[0],t[1],a)&&(r=1);++n<r;)for(var s=t[n],o=Po(s),l=-1,h=o.length;++l<h;){var c=o[l],u=e[c];(u===i||Ns(u,Re[c])&&!Ie.call(e,c))&&(e[c]=s[c])}return e})),wo=Xn((function(e){return e.push(i,Zr),_t(Do,i,e)}));function So(e,t,n){var r=null==e?i:bn(e,t);return r===i?n:r}function Mo(e,t){return null!=e&&ua(e,t,En)}var Eo=Ur((function(e,t,i){null!=t&&"function"!=typeof t.toString&&(t=Ne.call(t)),e[t]=i}),Jo(el)),To=Ur((function(e,t,i){null!=t&&"function"!=typeof t.toString&&(t=Ne.call(t)),Ie.call(e,t)?e[t].push(i):e[t]=[i]}),ra),Ao=Xn(An);function Co(e){return Vs(e)?Xi(e):In(e)}function Po(e){return Vs(e)?Xi(e,!0):function(e){if(!Qs(e))return function(e){var t=[];if(null!=e)for(var i in Me(e))t.push(i);return t}(e);var t=xa(e),i=[];for(var n in e)"constructor"==n&&(t||!Ie.call(e,n))||i.push(n);return i}(e)}var Ro=Cr((function(e,t,i){Fn(e,t,i)})),Do=Cr((function(e,t,i,n){Fn(e,t,i,n)})),Lo=Kr((function(e,t){var i={};if(null==e)return i;var n=!1;t=Pt(t,(function(t){return t=mr(t,e),n||(n=t.length>1),t})),Tr(e,ea(e),i),n&&(i=an(i,7,Qr));for(var r=t.length;r--;)or(i,t[r]);return i})),Io=Kr((function(e,t){return null==e?{}:function(e,t){return Hn(e,t,(function(t,i){return Mo(e,i)}))}(e,t)}));function Oo(e,t){if(null==e)return{};var i=Pt(ea(e),(function(e){return[e]}));return t=ra(t),Hn(e,i,(function(e,i){return t(e,i[0])}))}var ko=Xr(Co),No=Xr(Po);function Uo(e){return null==e?[]:qt(e,Co(e))}var Fo=Lr((function(e,t,i){return t=t.toLowerCase(),e+(i?Bo(t):t)}));function Bo(e){return Yo(mo(e).toLowerCase())}function zo(e){return(e=mo(e))&&e.replace(ge,Kt).replace(Ze,"")}var Ho=Lr((function(e,t,i){return e+(i?"-":"")+t.toLowerCase()})),Vo=Lr((function(e,t,i){return e+(i?" ":"")+t.toLowerCase()})),jo=Dr("toLowerCase"),Go=Lr((function(e,t,i){return e+(i?"_":"")+t.toLowerCase()})),Wo=Lr((function(e,t,i){return e+(i?" ":"")+Yo(t)})),Xo=Lr((function(e,t,i){return e+(i?" ":"")+t.toUpperCase()})),Yo=Dr("toUpperCase");function qo(e,t,n){return e=mo(e),(t=n?i:t)===i?function(e){return $e.test(e)}(e)?function(e){return e.match(Je)||[]}(e):function(e){return e.match(se)||[]}(e):e.match(t)||[]}var Zo=Xn((function(e,t){try{return _t(e,i,t)}catch(e){return Xs(e)?e:new _e(e)}})),Qo=Kr((function(e,t){return St(t,(function(t){t=Ia(t),tn(e,t,Es(e[t],e))})),e}));function Jo(e){return function(){return e}}var Ko=kr(),$o=kr(!0);function el(e){return e}function tl(e){return Ln("function"==typeof e?e:an(e,1))}var il=Xn((function(e,t){return function(i){return An(i,e,t)}})),nl=Xn((function(e,t){return function(i){return An(e,i,t)}}));function rl(e,t,i){var n=Co(t),r=xn(t,n);null==i&&(!Qs(t)||!r.length&&n.length)&&(i=t,t=e,e=this,r=xn(t,Co(t)));var a=!(Qs(i)&&"chain"in i&&!i.chain),s=Ys(e);return St(r,(function(i){var n=t[i];e[i]=n,s&&(e.prototype[i]=function(){var t=this.__chain__;if(a||t){var i=e(this.__wrapped__);return(i.__actions__=Er(this.__actions__)).push({func:n,args:arguments,thisArg:e}),i.__chain__=t,i}return n.apply(e,Rt([this.value()],arguments))})})),e}function al(){}var sl=Br(Pt),ol=Br(Et),ll=Br(It);function hl(e){return ga(e)?Ht(Ia(e)):function(e){return function(t){return bn(t,e)}}(e)}var cl=Hr(),ul=Hr(!0);function dl(){return[]}function pl(){return!1}var fl=Fr((function(e,t){return e+t}),0),ml=Gr("ceil"),gl=Fr((function(e,t){return e/t}),1),vl=Gr("floor"),yl=Fr((function(e,t){return e*t}),1),xl=Gr("round"),bl=Fr((function(e,t){return e-t}),0);return Ni.after=function(e,t){if("function"!=typeof t)throw new Ae(n);return e=co(e),function(){if(--e<1)return t.apply(this,arguments)}},Ni.ary=Ss,Ni.assign=go,Ni.assignIn=vo,Ni.assignInWith=yo,Ni.assignWith=xo,Ni.at=bo,Ni.before=Ms,Ni.bind=Es,Ni.bindAll=Qo,Ni.bindKey=Ts,Ni.castArray=function(){if(!arguments.length)return[];var e=arguments[0];return zs(e)?e:[e]},Ni.chain=ls,Ni.chunk=function(e,t,n){t=(n?ma(e,t,n):t===i)?1:fi(co(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++]=$n(e,a,a+=t);return o},Ni.compact=function(e){for(var t=-1,i=null==e?0:e.length,n=0,r=[];++t<i;){var a=e[t];a&&(r[n++]=a)}return r},Ni.concat=function(){var e=arguments.length;if(!e)return[];for(var t=xe(e-1),i=arguments[0],n=e;n--;)t[n-1]=arguments[n];return Rt(zs(i)?Er(i):[i],fn(t,1))},Ni.cond=function(e){var t=null==e?0:e.length,i=ra();return e=t?Pt(e,(function(e){if("function"!=typeof e[1])throw new Ae(n);return[i(e[0]),e[1]]})):[],Xn((function(i){for(var n=-1;++n<t;){var r=e[n];if(_t(r[0],this,i))return _t(r[1],this,i)}}))},Ni.conforms=function(e){return function(e){var t=Co(e);return function(i){return sn(i,e,t)}}(an(e,1))},Ni.constant=Jo,Ni.countBy=us,Ni.create=function(e,t){var i=Ui(e);return null==t?i:en(i,t)},Ni.curry=function e(t,n,r){var a=Yr(t,8,i,i,i,i,i,n=r?i:n);return a.placeholder=e.placeholder,a},Ni.curryRight=function e(t,n,r){var a=Yr(t,16,i,i,i,i,i,n=r?i:n);return a.placeholder=e.placeholder,a},Ni.debounce=As,Ni.defaults=_o,Ni.defaultsDeep=wo,Ni.defer=Cs,Ni.delay=Ps,Ni.difference=Na,Ni.differenceBy=Ua,Ni.differenceWith=Fa,Ni.drop=function(e,t,n){var r=null==e?0:e.length;return r?$n(e,(t=n||t===i?1:co(t))<0?0:t,r):[]},Ni.dropRight=function(e,t,n){var r=null==e?0:e.length;return r?$n(e,0,(t=r-(t=n||t===i?1:co(t)))<0?0:t):[]},Ni.dropRightWhile=function(e,t){return e&&e.length?hr(e,ra(t,3),!0,!0):[]},Ni.dropWhile=function(e,t){return e&&e.length?hr(e,ra(t,3),!0):[]},Ni.fill=function(e,t,n,r){var a=null==e?0:e.length;return a?(n&&"number"!=typeof n&&ma(e,t,n)&&(n=0,r=a),function(e,t,n,r){var a=e.length;for((n=co(n))<0&&(n=-n>a?0:a+n),(r=r===i||r>a?a:co(r))<0&&(r+=a),r=n>r?0:uo(r);n<r;)e[n++]=t;return e}(e,t,n,r)):[]},Ni.filter=function(e,t){return(zs(e)?Tt:pn)(e,ra(t,3))},Ni.flatMap=function(e,t){return fn(xs(e,t),1)},Ni.flatMapDeep=function(e,t){return fn(xs(e,t),l)},Ni.flatMapDepth=function(e,t,n){return n=n===i?1:co(n),fn(xs(e,t),n)},Ni.flatten=Ha,Ni.flattenDeep=function(e){return null!=e&&e.length?fn(e,l):[]},Ni.flattenDepth=function(e,t){return null!=e&&e.length?fn(e,t=t===i?1:co(t)):[]},Ni.flip=function(e){return Yr(e,512)},Ni.flow=Ko,Ni.flowRight=$o,Ni.fromPairs=function(e){for(var t=-1,i=null==e?0:e.length,n={};++t<i;){var r=e[t];n[r[0]]=r[1]}return n},Ni.functions=function(e){return null==e?[]:xn(e,Co(e))},Ni.functionsIn=function(e){return null==e?[]:xn(e,Po(e))},Ni.groupBy=gs,Ni.initial=function(e){return null!=e&&e.length?$n(e,0,-1):[]},Ni.intersection=ja,Ni.intersectionBy=Ga,Ni.intersectionWith=Wa,Ni.invert=Eo,Ni.invertBy=To,Ni.invokeMap=vs,Ni.iteratee=tl,Ni.keyBy=ys,Ni.keys=Co,Ni.keysIn=Po,Ni.map=xs,Ni.mapKeys=function(e,t){var i={};return t=ra(t,3),vn(e,(function(e,n,r){tn(i,t(e,n,r),e)})),i},Ni.mapValues=function(e,t){var i={};return t=ra(t,3),vn(e,(function(e,n,r){tn(i,n,t(e,n,r))})),i},Ni.matches=function(e){return Nn(an(e,1))},Ni.matchesProperty=function(e,t){return Un(e,an(t,1))},Ni.memoize=Rs,Ni.merge=Ro,Ni.mergeWith=Do,Ni.method=il,Ni.methodOf=nl,Ni.mixin=rl,Ni.negate=Ds,Ni.nthArg=function(e){return e=co(e),Xn((function(t){return Bn(t,e)}))},Ni.omit=Lo,Ni.omitBy=function(e,t){return Oo(e,Ds(ra(t)))},Ni.once=function(e){return Ms(2,e)},Ni.orderBy=function(e,t,n,r){return null==e?[]:(zs(t)||(t=null==t?[]:[t]),zs(n=r?i:n)||(n=null==n?[]:[n]),zn(e,t,n))},Ni.over=sl,Ni.overArgs=Ls,Ni.overEvery=ol,Ni.overSome=ll,Ni.partial=Is,Ni.partialRight=Os,Ni.partition=bs,Ni.pick=Io,Ni.pickBy=Oo,Ni.property=hl,Ni.propertyOf=function(e){return function(t){return null==e?i:bn(e,t)}},Ni.pull=Ya,Ni.pullAll=qa,Ni.pullAllBy=function(e,t,i){return e&&e.length&&t&&t.length?Vn(e,t,ra(i,2)):e},Ni.pullAllWith=function(e,t,n){return e&&e.length&&t&&t.length?Vn(e,t,i,n):e},Ni.pullAt=Za,Ni.range=cl,Ni.rangeRight=ul,Ni.rearg=ks,Ni.reject=function(e,t){return(zs(e)?Tt:pn)(e,Ds(ra(t,3)))},Ni.remove=function(e,t){var i=[];if(!e||!e.length)return i;var n=-1,r=[],a=e.length;for(t=ra(t,3);++n<a;){var s=e[n];t(s,n,e)&&(i.push(s),r.push(n))}return jn(e,r),i},Ni.rest=function(e,t){if("function"!=typeof e)throw new Ae(n);return Xn(e,t=t===i?t:co(t))},Ni.reverse=Qa,Ni.sampleSize=function(e,t,n){return t=(n?ma(e,t,n):t===i)?1:co(t),(zs(e)?qi:qn)(e,t)},Ni.set=function(e,t,i){return null==e?e:Zn(e,t,i)},Ni.setWith=function(e,t,n,r){return r="function"==typeof r?r:i,null==e?e:Zn(e,t,n,r)},Ni.shuffle=function(e){return(zs(e)?Zi:Kn)(e)},Ni.slice=function(e,t,n){var r=null==e?0:e.length;return r?(n&&"number"!=typeof n&&ma(e,t,n)?(t=0,n=r):(t=null==t?0:co(t),n=n===i?r:co(n)),$n(e,t,n)):[]},Ni.sortBy=_s,Ni.sortedUniq=function(e){return e&&e.length?nr(e):[]},Ni.sortedUniqBy=function(e,t){return e&&e.length?nr(e,ra(t,2)):[]},Ni.split=function(e,t,n){return n&&"number"!=typeof n&&ma(e,t,n)&&(t=n=i),(n=n===i?u:n>>>0)?(e=mo(e))&&("string"==typeof t||null!=t&&!to(t))&&!(t=ar(t))&&ti(e)?vr(oi(e),0,n):e.split(t,n):[]},Ni.spread=function(e,t){if("function"!=typeof e)throw new Ae(n);return t=null==t?0:fi(co(t),0),Xn((function(i){var n=i[t],r=vr(i,0,t);return n&&Rt(r,n),_t(e,this,r)}))},Ni.tail=function(e){var t=null==e?0:e.length;return t?$n(e,1,t):[]},Ni.take=function(e,t,n){return e&&e.length?$n(e,0,(t=n||t===i?1:co(t))<0?0:t):[]},Ni.takeRight=function(e,t,n){var r=null==e?0:e.length;return r?$n(e,(t=r-(t=n||t===i?1:co(t)))<0?0:t,r):[]},Ni.takeRightWhile=function(e,t){return e&&e.length?hr(e,ra(t,3),!1,!0):[]},Ni.takeWhile=function(e,t){return e&&e.length?hr(e,ra(t,3)):[]},Ni.tap=function(e,t){return t(e),e},Ni.throttle=function(e,t,i){var r=!0,a=!0;if("function"!=typeof e)throw new Ae(n);return Qs(i)&&(r="leading"in i?!!i.leading:r,a="trailing"in i?!!i.trailing:a),As(e,t,{leading:r,maxWait:t,trailing:a})},Ni.thru=hs,Ni.toArray=lo,Ni.toPairs=ko,Ni.toPairsIn=No,Ni.toPath=function(e){return zs(e)?Pt(e,Ia):ro(e)?[e]:Er(La(mo(e)))},Ni.toPlainObject=fo,Ni.transform=function(e,t,i){var n=zs(e),r=n||Gs(e)||ao(e);if(t=ra(t,4),null==i){var a=e&&e.constructor;i=r?n?new a:[]:Qs(e)&&Ys(a)?Ui(Ge(e)):{}}return(r?St:vn)(e,(function(e,n,r){return t(i,e,n,r)})),i},Ni.unary=function(e){return Ss(e,1)},Ni.union=Ja,Ni.unionBy=Ka,Ni.unionWith=$a,Ni.uniq=function(e){return e&&e.length?sr(e):[]},Ni.uniqBy=function(e,t){return e&&e.length?sr(e,ra(t,2)):[]},Ni.uniqWith=function(e,t){return t="function"==typeof t?t:i,e&&e.length?sr(e,i,t):[]},Ni.unset=function(e,t){return null==e||or(e,t)},Ni.unzip=es,Ni.unzipWith=ts,Ni.update=function(e,t,i){return null==e?e:lr(e,t,fr(i))},Ni.updateWith=function(e,t,n,r){return r="function"==typeof r?r:i,null==e?e:lr(e,t,fr(n),r)},Ni.values=Uo,Ni.valuesIn=function(e){return null==e?[]:qt(e,Po(e))},Ni.without=is,Ni.words=qo,Ni.wrap=function(e,t){return Is(fr(t),e)},Ni.xor=ns,Ni.xorBy=rs,Ni.xorWith=as,Ni.zip=ss,Ni.zipObject=function(e,t){return dr(e||[],t||[],Ji)},Ni.zipObjectDeep=function(e,t){return dr(e||[],t||[],Zn)},Ni.zipWith=os,Ni.entries=ko,Ni.entriesIn=No,Ni.extend=vo,Ni.extendWith=yo,rl(Ni,Ni),Ni.add=fl,Ni.attempt=Zo,Ni.camelCase=Fo,Ni.capitalize=Bo,Ni.ceil=ml,Ni.clamp=function(e,t,n){return n===i&&(n=t,t=i),n!==i&&(n=(n=po(n))==n?n:0),t!==i&&(t=(t=po(t))==t?t:0),rn(po(e),t,n)},Ni.clone=function(e){return an(e,4)},Ni.cloneDeep=function(e){return an(e,5)},Ni.cloneDeepWith=function(e,t){return an(e,5,t="function"==typeof t?t:i)},Ni.cloneWith=function(e,t){return an(e,4,t="function"==typeof t?t:i)},Ni.conformsTo=function(e,t){return null==t||sn(e,t,Co(t))},Ni.deburr=zo,Ni.defaultTo=function(e,t){return null==e||e!=e?t:e},Ni.divide=gl,Ni.endsWith=function(e,t,n){e=mo(e),t=ar(t);var r=e.length,a=n=n===i?r:rn(co(n),0,r);return(n-=t.length)>=0&&e.slice(n,a)==t},Ni.eq=Ns,Ni.escape=function(e){return(e=mo(e))&&X.test(e)?e.replace(G,$t):e},Ni.escapeRegExp=function(e){return(e=mo(e))&&ee.test(e)?e.replace($,"\\$&"):e},Ni.every=function(e,t,n){var r=zs(e)?Et:un;return n&&ma(e,t,n)&&(t=i),r(e,ra(t,3))},Ni.find=ds,Ni.findIndex=Ba,Ni.findKey=function(e,t){return kt(e,ra(t,3),vn)},Ni.findLast=ps,Ni.findLastIndex=za,Ni.findLastKey=function(e,t){return kt(e,ra(t,3),yn)},Ni.floor=vl,Ni.forEach=fs,Ni.forEachRight=ms,Ni.forIn=function(e,t){return null==e?e:mn(e,ra(t,3),Po)},Ni.forInRight=function(e,t){return null==e?e:gn(e,ra(t,3),Po)},Ni.forOwn=function(e,t){return e&&vn(e,ra(t,3))},Ni.forOwnRight=function(e,t){return e&&yn(e,ra(t,3))},Ni.get=So,Ni.gt=Us,Ni.gte=Fs,Ni.has=function(e,t){return null!=e&&ua(e,t,Mn)},Ni.hasIn=Mo,Ni.head=Va,Ni.identity=el,Ni.includes=function(e,t,i,n){e=Vs(e)?e:Uo(e),i=i&&!n?co(i):0;var r=e.length;return i<0&&(i=fi(r+i,0)),no(e)?i<=r&&e.indexOf(t,i)>-1:!!r&&Ut(e,t,i)>-1},Ni.indexOf=function(e,t,i){var n=null==e?0:e.length;if(!n)return-1;var r=null==i?0:co(i);return r<0&&(r=fi(n+r,0)),Ut(e,t,r)},Ni.inRange=function(e,t,n){return t=ho(t),n===i?(n=t,t=0):n=ho(n),function(e,t,i){return e>=mi(t,i)&&e<fi(t,i)}(e=po(e),t,n)},Ni.invoke=Ao,Ni.isArguments=Bs,Ni.isArray=zs,Ni.isArrayBuffer=Hs,Ni.isArrayLike=Vs,Ni.isArrayLikeObject=js,Ni.isBoolean=function(e){return!0===e||!1===e||Js(e)&&wn(e)==m},Ni.isBuffer=Gs,Ni.isDate=Ws,Ni.isElement=function(e){return Js(e)&&1===e.nodeType&&!eo(e)},Ni.isEmpty=function(e){if(null==e)return!0;if(Vs(e)&&(zs(e)||"string"==typeof e||"function"==typeof e.splice||Gs(e)||ao(e)||Bs(e)))return!e.length;var t=ca(e);if(t==b||t==E)return!e.size;if(xa(e))return!In(e).length;for(var i in e)if(Ie.call(e,i))return!1;return!0},Ni.isEqual=function(e,t){return Pn(e,t)},Ni.isEqualWith=function(e,t,n){var r=(n="function"==typeof n?n:i)?n(e,t):i;return r===i?Pn(e,t,i,n):!!r},Ni.isError=Xs,Ni.isFinite=function(e){return"number"==typeof e&&ui(e)},Ni.isFunction=Ys,Ni.isInteger=qs,Ni.isLength=Zs,Ni.isMap=Ks,Ni.isMatch=function(e,t){return e===t||Rn(e,t,sa(t))},Ni.isMatchWith=function(e,t,n){return n="function"==typeof n?n:i,Rn(e,t,sa(t),n)},Ni.isNaN=function(e){return $s(e)&&e!=+e},Ni.isNative=function(e){if(ya(e))throw new _e("Unsupported core-js use. Try https://npms.io/search?q=ponyfill.");return Dn(e)},Ni.isNil=function(e){return null==e},Ni.isNull=function(e){return null===e},Ni.isNumber=$s,Ni.isObject=Qs,Ni.isObjectLike=Js,Ni.isPlainObject=eo,Ni.isRegExp=to,Ni.isSafeInteger=function(e){return qs(e)&&e>=-h&&e<=h},Ni.isSet=io,Ni.isString=no,Ni.isSymbol=ro,Ni.isTypedArray=ao,Ni.isUndefined=function(e){return e===i},Ni.isWeakMap=function(e){return Js(e)&&ca(e)==C},Ni.isWeakSet=function(e){return Js(e)&&"[object WeakSet]"==wn(e)},Ni.join=function(e,t){return null==e?"":di.call(e,t)},Ni.kebabCase=Ho,Ni.last=Xa,Ni.lastIndexOf=function(e,t,n){var r=null==e?0:e.length;if(!r)return-1;var a=r;return n!==i&&(a=(a=co(n))<0?fi(r+a,0):mi(a,r-1)),t==t?function(e,t,i){for(var n=i+1;n--;)if(e[n]===t)return n;return n}(e,t,a):Nt(e,Bt,a,!0)},Ni.lowerCase=Vo,Ni.lowerFirst=jo,Ni.lt=so,Ni.lte=oo,Ni.max=function(e){return e&&e.length?dn(e,el,Sn):i},Ni.maxBy=function(e,t){return e&&e.length?dn(e,ra(t,2),Sn):i},Ni.mean=function(e){return zt(e,el)},Ni.meanBy=function(e,t){return zt(e,ra(t,2))},Ni.min=function(e){return e&&e.length?dn(e,el,On):i},Ni.minBy=function(e,t){return e&&e.length?dn(e,ra(t,2),On):i},Ni.stubArray=dl,Ni.stubFalse=pl,Ni.stubObject=function(){return{}},Ni.stubString=function(){return""},Ni.stubTrue=function(){return!0},Ni.multiply=yl,Ni.nth=function(e,t){return e&&e.length?Bn(e,co(t)):i},Ni.noConflict=function(){return ht._===this&&(ht._=Fe),this},Ni.noop=al,Ni.now=ws,Ni.pad=function(e,t,i){e=mo(e);var n=(t=co(t))?si(e):0;if(!t||n>=t)return e;var r=(t-n)/2;return zr(ft(r),i)+e+zr(pt(r),i)},Ni.padEnd=function(e,t,i){e=mo(e);var n=(t=co(t))?si(e):0;return t&&n<t?e+zr(t-n,i):e},Ni.padStart=function(e,t,i){e=mo(e);var n=(t=co(t))?si(e):0;return t&&n<t?zr(t-n,i)+e:e},Ni.parseInt=function(e,t,i){return i||null==t?t=0:t&&(t=+t),vi(mo(e).replace(te,""),t||0)},Ni.random=function(e,t,n){if(n&&"boolean"!=typeof n&&ma(e,t,n)&&(t=n=i),n===i&&("boolean"==typeof t?(n=t,t=i):"boolean"==typeof e&&(n=e,e=i)),e===i&&t===i?(e=0,t=1):(e=ho(e),t===i?(t=e,e=0):t=ho(t)),e>t){var r=e;e=t,t=r}if(n||e%1||t%1){var a=yi();return mi(e+a*(t-e+at("1e-"+((a+"").length-1))),t)}return Gn(e,t)},Ni.reduce=function(e,t,i){var n=zs(e)?Dt:jt,r=arguments.length<3;return n(e,ra(t,4),i,r,hn)},Ni.reduceRight=function(e,t,i){var n=zs(e)?Lt:jt,r=arguments.length<3;return n(e,ra(t,4),i,r,cn)},Ni.repeat=function(e,t,n){return t=(n?ma(e,t,n):t===i)?1:co(t),Wn(mo(e),t)},Ni.replace=function(){var e=arguments,t=mo(e[0]);return e.length<3?t:t.replace(e[1],e[2])},Ni.result=function(e,t,n){var r=-1,a=(t=mr(t,e)).length;for(a||(a=1,e=i);++r<a;){var s=null==e?i:e[Ia(t[r])];s===i&&(r=a,s=n),e=Ys(s)?s.call(e):s}return e},Ni.round=xl,Ni.runInContext=e,Ni.sample=function(e){return(zs(e)?Yi:Yn)(e)},Ni.size=function(e){if(null==e)return 0;if(Vs(e))return no(e)?si(e):e.length;var t=ca(e);return t==b||t==E?e.size:In(e).length},Ni.snakeCase=Go,Ni.some=function(e,t,n){var r=zs(e)?It:er;return n&&ma(e,t,n)&&(t=i),r(e,ra(t,3))},Ni.sortedIndex=function(e,t){return tr(e,t)},Ni.sortedIndexBy=function(e,t,i){return ir(e,t,ra(i,2))},Ni.sortedIndexOf=function(e,t){var i=null==e?0:e.length;if(i){var n=tr(e,t);if(n<i&&Ns(e[n],t))return n}return-1},Ni.sortedLastIndex=function(e,t){return tr(e,t,!0)},Ni.sortedLastIndexBy=function(e,t,i){return ir(e,t,ra(i,2),!0)},Ni.sortedLastIndexOf=function(e,t){if(null!=e&&e.length){var i=tr(e,t,!0)-1;if(Ns(e[i],t))return i}return-1},Ni.startCase=Wo,Ni.startsWith=function(e,t,i){return e=mo(e),i=null==i?0:rn(co(i),0,e.length),t=ar(t),e.slice(i,i+t.length)==t},Ni.subtract=bl,Ni.sum=function(e){return e&&e.length?Gt(e,el):0},Ni.sumBy=function(e,t){return e&&e.length?Gt(e,ra(t,2)):0},Ni.template=function(e,t,n){var r=Ni.templateSettings;n&&ma(e,t,n)&&(t=i),e=mo(e),t=yo({},t,r,qr);var a,s,o=yo({},t.imports,r.imports,qr),l=Co(o),h=qt(o,l),c=0,u=t.interpolate||ve,d="__p += '",p=Ee((t.escape||ve).source+"|"+u.source+"|"+(u===Z?he:ve).source+"|"+(t.evaluate||ve).source+"|$","g"),f="//# sourceURL="+(Ie.call(t,"sourceURL")?(t.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++tt+"]")+"\n";e.replace(p,(function(t,i,n,r,o,l){return n||(n=r),d+=e.slice(c,l).replace(ye,ei),i&&(a=!0,d+="' +\n__e("+i+") +\n'"),o&&(s=!0,d+="';\n"+o+";\n__p += '"),n&&(d+="' +\n((__t = ("+n+")) == null ? '' : __t) +\n'"),c=l+t.length,t})),d+="';\n";var m=Ie.call(t,"variable")&&t.variable;if(m){if(oe.test(m))throw new _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=Zo((function(){return we(l,f+"return "+d).apply(i,h)}));if(g.source=d,Xs(g))throw g;return g},Ni.times=function(e,t){if((e=co(e))<1||e>h)return[];var i=u,n=mi(e,u);t=ra(t),e-=u;for(var r=Wt(n,t);++i<e;)t(i);return r},Ni.toFinite=ho,Ni.toInteger=co,Ni.toLength=uo,Ni.toLower=function(e){return mo(e).toLowerCase()},Ni.toNumber=po,Ni.toSafeInteger=function(e){return e?rn(co(e),-h,h):0===e?e:0},Ni.toString=mo,Ni.toUpper=function(e){return mo(e).toUpperCase()},Ni.trim=function(e,t,n){if((e=mo(e))&&(n||t===i))return Xt(e);if(!e||!(t=ar(t)))return e;var r=oi(e),a=oi(t);return vr(r,Qt(r,a),Jt(r,a)+1).join("")},Ni.trimEnd=function(e,t,n){if((e=mo(e))&&(n||t===i))return e.slice(0,li(e)+1);if(!e||!(t=ar(t)))return e;var r=oi(e);return vr(r,0,Jt(r,oi(t))+1).join("")},Ni.trimStart=function(e,t,n){if((e=mo(e))&&(n||t===i))return e.replace(te,"");if(!e||!(t=ar(t)))return e;var r=oi(e);return vr(r,Qt(r,oi(t))).join("")},Ni.truncate=function(e,t){var n=30,r="...";if(Qs(t)){var a="separator"in t?t.separator:a;n="length"in t?co(t.length):n,r="omission"in t?ar(t.omission):r}var s=(e=mo(e)).length;if(ti(e)){var o=oi(e);s=o.length}if(n>=s)return e;var l=n-si(r);if(l<1)return r;var h=o?vr(o,0,l).join(""):e.slice(0,l);if(a===i)return h+r;if(o&&(l+=h.length-l),to(a)){if(e.slice(l).search(a)){var c,u=h;for(a.global||(a=Ee(a.source,mo(ce.exec(a))+"g")),a.lastIndex=0;c=a.exec(u);)var d=c.index;h=h.slice(0,d===i?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},Ni.unescape=function(e){return(e=mo(e))&&W.test(e)?e.replace(j,hi):e},Ni.uniqueId=function(e){var t=++Oe;return mo(e)+t},Ni.upperCase=Xo,Ni.upperFirst=Yo,Ni.each=fs,Ni.eachRight=ms,Ni.first=Va,rl(Ni,function(){var e={};return vn(Ni,(function(t,i){Ie.call(Ni.prototype,i)||(e[i]=t)})),e}(),{chain:!1}),Ni.VERSION="4.17.21",St(["bind","bindKey","curry","curryRight","partial","partialRight"],(function(e){Ni[e].placeholder=Ni})),St(["drop","take"],(function(e,t){zi.prototype[e]=function(n){n=n===i?1:fi(co(n),0);var r=this.__filtered__&&!t?new zi(this):this.clone();return r.__filtered__?r.__takeCount__=mi(n,r.__takeCount__):r.__views__.push({size:mi(n,u),type:e+(r.__dir__<0?"Right":"")}),r},zi.prototype[e+"Right"]=function(t){return this.reverse()[e](t).reverse()}})),St(["filter","map","takeWhile"],(function(e,t){var i=t+1,n=1==i||3==i;zi.prototype[e]=function(e){var t=this.clone();return t.__iteratees__.push({iteratee:ra(e,3),type:i}),t.__filtered__=t.__filtered__||n,t}})),St(["head","last"],(function(e,t){var i="take"+(t?"Right":"");zi.prototype[e]=function(){return this[i](1).value()[0]}})),St(["initial","tail"],(function(e,t){var i="drop"+(t?"":"Right");zi.prototype[e]=function(){return this.__filtered__?new zi(this):this[i](1)}})),zi.prototype.compact=function(){return this.filter(el)},zi.prototype.find=function(e){return this.filter(e).head()},zi.prototype.findLast=function(e){return this.reverse().find(e)},zi.prototype.invokeMap=Xn((function(e,t){return"function"==typeof e?new zi(this):this.map((function(i){return An(i,e,t)}))})),zi.prototype.reject=function(e){return this.filter(Ds(ra(e)))},zi.prototype.slice=function(e,t){e=co(e);var n=this;return n.__filtered__&&(e>0||t<0)?new zi(n):(e<0?n=n.takeRight(-e):e&&(n=n.drop(e)),t!==i&&(n=(t=co(t))<0?n.dropRight(-t):n.take(t-e)),n)},zi.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},zi.prototype.toArray=function(){return this.take(u)},vn(zi.prototype,(function(e,t){var n=/^(?:filter|find|map|reject)|While$/.test(t),r=/^(?:head|last)$/.test(t),a=Ni[r?"take"+("last"==t?"Right":""):t],s=r||/^find/.test(t);a&&(Ni.prototype[t]=function(){var t=this.__wrapped__,o=r?[1]:arguments,l=t instanceof zi,h=o[0],c=l||zs(t),u=function(e){var t=a.apply(Ni,Rt([e],o));return r&&d?t[0]:t};c&&n&&"function"==typeof h&&1!=h.length&&(l=c=!1);var d=this.__chain__,p=!!this.__actions__.length,f=s&&!d,m=l&&!p;if(!s&&c){t=m?t:new zi(this);var g=e.apply(t,o);return g.__actions__.push({func:hs,args:[u],thisArg:i}),new Bi(g,d)}return f&&m?e.apply(this,o):(g=this.thru(u),f?r?g.value()[0]:g.value():g)})})),St(["pop","push","shift","sort","splice","unshift"],(function(e){var t=Ce[e],i=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",n=/^(?:pop|shift)$/.test(e);Ni.prototype[e]=function(){var e=arguments;if(n&&!this.__chain__){var r=this.value();return t.apply(zs(r)?r:[],e)}return this[i]((function(i){return t.apply(zs(i)?i:[],e)}))}})),vn(zi.prototype,(function(e,t){var i=Ni[t];if(i){var n=i.name+"";Ie.call(Ai,n)||(Ai[n]=[]),Ai[n].push({name:t,func:i})}})),Ai[Nr(i,2).name]=[{name:"wrapper",func:i}],zi.prototype.clone=function(){var e=new zi(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},zi.prototype.reverse=function(){if(this.__filtered__){var e=new zi(this);e.__dir__=-1,e.__filtered__=!0}else(e=this.clone()).__dir__*=-1;return e},zi.prototype.value=function(){var e=this.__wrapped__.value(),t=this.__dir__,i=zs(e),n=t<0,r=i?e.length:0,a=function(e,t,i){for(var n=-1,r=i.length;++n<r;){var a=i[n],s=a.size;switch(a.type){case"drop":e+=s;break;case"dropRight":t-=s;break;case"take":t=mi(t,e+s);break;case"takeRight":e=fi(e,t-s)}}return{start:e,end:t}}(0,r,this.__views__),s=a.start,o=a.end,l=o-s,h=n?o:s-1,c=this.__iteratees__,u=c.length,d=0,p=mi(l,this.__takeCount__);if(!i||!n&&r==l&&p==l)return cr(e,this.__actions__);var f=[];e:for(;l--&&d<p;){for(var m=-1,g=e[h+=t];++m<u;){var v=c[m],y=v.iteratee,x=v.type,b=y(g);if(2==x)g=b;else if(!b){if(1==x)continue e;break e}}f[d++]=g}return f},Ni.prototype.at=cs,Ni.prototype.chain=function(){return ls(this)},Ni.prototype.commit=function(){return new Bi(this.value(),this.__chain__)},Ni.prototype.next=function(){this.__values__===i&&(this.__values__=lo(this.value()));var e=this.__index__>=this.__values__.length;return{done:e,value:e?i:this.__values__[this.__index__++]}},Ni.prototype.plant=function(e){for(var t,n=this;n instanceof Fi;){var r=ka(n);r.__index__=0,r.__values__=i,t?a.__wrapped__=r:t=r;var a=r;n=n.__wrapped__}return a.__wrapped__=e,t},Ni.prototype.reverse=function(){var e=this.__wrapped__;if(e instanceof zi){var t=e;return this.__actions__.length&&(t=new zi(this)),(t=t.reverse()).__actions__.push({func:hs,args:[Qa],thisArg:i}),new Bi(t,this.__chain__)}return this.thru(Qa)},Ni.prototype.toJSON=Ni.prototype.valueOf=Ni.prototype.value=function(){return cr(this.__wrapped__,this.__actions__)},Ni.prototype.first=Ni.prototype.head,Ke&&(Ni.prototype[Ke]=function(){return this}),Ni}();"function"==typeof define&&"object"==typeof define.amd&&define.amd?(ht._=ci,define((function(){return ci}))):ut?((ut.exports=ci)._=ci,ct._=ci):ht._=ci}).call(e)})),ape=Q(((e,t)=>{var i,n;i=e,n=function(){"use strict";function e(e,n,r,a,s){!function e(i,n,r,a,s){for(;a>r;){if(a-r>600){var o=a-r+1,l=n-r+1,h=Math.log(o),c=.5*Math.exp(2*h/3),u=.5*Math.sqrt(h*c*(o-c)/o)*(l-o/2<0?-1:1);e(i,n,Math.max(r,Math.floor(n-l*c/o+u)),Math.min(a,Math.floor(n+(o-l)*c/o+u)),s)}var d=i[n],p=r,f=a;for(t(i,r,n),s(i[a],d)>0&&t(i,r,a);p<f;){for(t(i,p,f),p++,f--;s(i[p],d)<0;)p++;for(;s(i[f],d)>0;)f--}0===s(i[r],d)?t(i,r,f):t(i,++f,a),f<=n&&(r=f+1),n<=f&&(a=f-1)}}(e,n,r||0,a||e.length-1,s||i)}function t(e,t,i){var n=e[t];e[t]=e[i],e[i]=n}function i(e,t){return e<t?-1:e>t?1:0}var n=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,i){if(!i)return t.indexOf(e);for(var n=0;n<t.length;n++)if(i(e,t[n]))return n;return-1}function a(e,t){s(e,0,e.children.length,t,e)}function s(e,t,i,n,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<i;a++){var s=e.children[a];o(r,e.leaf?n(s):s)}return r}function o(e,t){return e.minX=Math.min(e.minX,t.minX),e.minY=Math.min(e.minY,t.minY),e.maxX=Math.max(e.maxX,t.maxX),e.maxY=Math.max(e.maxY,t.maxY),e}function l(e,t){return e.minX-t.minX}function h(e,t){return e.minY-t.minY}function c(e){return(e.maxX-e.minX)*(e.maxY-e.minY)}function u(e){return e.maxX-e.minX+(e.maxY-e.minY)}function d(e,t){return e.minX<=t.minX&&e.minY<=t.minY&&t.maxX<=e.maxX&&t.maxY<=e.maxY}function p(e,t){return t.minX<=e.maxX&&t.minY<=e.maxY&&t.maxX>=e.minX&&t.maxY>=e.minY}function f(e){return{children:e,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function m(t,i,n,r,a){for(var s=[i,n];s.length;)if(!((n=s.pop())-(i=s.pop())<=r)){var o=i+Math.ceil((n-i)/r/2)*r;e(t,o,i,n,a),s.push(i,o,o,n)}}return n.prototype.all=function(){return this._all(this.data,[])},n.prototype.search=function(e){var t=this.data,i=[];if(!p(e,t))return i;for(var n=this.toBBox,r=[];t;){for(var a=0;a<t.children.length;a++){var s=t.children[a],o=t.leaf?n(s):s;p(e,o)&&(t.leaf?i.push(s):d(e,o)?this._all(s,i):r.push(s))}t=r.pop()}return i},n.prototype.collides=function(e){var t=this.data;if(!p(e,t))return!1;for(var i=[];t;){for(var n=0;n<t.children.length;n++){var r=t.children[n],a=t.leaf?this.toBBox(r):r;if(p(e,a)){if(t.leaf||d(e,a))return!0;i.push(r)}}t=i.pop()}return!1},n.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 i=this._build(e.slice(),0,e.length-1,0);if(this.data.children.length)if(this.data.height===i.height)this._splitRoot(this.data,i);else{if(this.data.height<i.height){var n=this.data;this.data=i,i=n}this._insert(i,this.data.height-i.height-1,!0)}else this.data=i;return this},n.prototype.insert=function(e){return e&&this._insert(e,this.data.height-1),this},n.prototype.clear=function(){return this.data=f([]),this},n.prototype.remove=function(e,t){if(!e)return this;for(var i,n,a,s=this.data,o=this.toBBox(e),l=[],h=[];s||l.length;){if(s||(s=l.pop(),n=l[l.length-1],i=h.pop(),a=!0),s.leaf){var c=r(e,s.children,t);if(-1!==c)return s.children.splice(c,1),l.push(s),this._condense(l),this}a||s.leaf||!d(s,o)?n?(i++,s=n.children[i],a=!1):s=null:(l.push(s),h.push(i),i=0,n=s,s=s.children[0])}return this},n.prototype.toBBox=function(e){return e},n.prototype.compareMinX=function(e,t){return e.minX-t.minX},n.prototype.compareMinY=function(e,t){return e.minY-t.minY},n.prototype.toJSON=function(){return this.data},n.prototype.fromJSON=function(e){return this.data=e,this},n.prototype._all=function(e,t){for(var i=[];e;)e.leaf?t.push.apply(t,e.children):i.push.apply(i,e.children),e=i.pop();return t},n.prototype._build=function(e,t,i,n){var r,s=i-t+1,o=this._maxEntries;if(s<=o)return a(r=f(e.slice(t,i+1)),this.toBBox),r;n||(n=Math.ceil(Math.log(s)/Math.log(o)),o=Math.ceil(s/Math.pow(o,n-1))),(r=f([])).leaf=!1,r.height=n;var l=Math.ceil(s/o),h=l*Math.ceil(Math.sqrt(o));m(e,t,i,h,this.compareMinX);for(var c=t;c<=i;c+=h){var u=Math.min(c+h-1,i);m(e,c,u,l,this.compareMinY);for(var d=c;d<=u;d+=l){var p=Math.min(d+l-1,u);r.children.push(this._build(e,d,p,n-1))}}return a(r,this.toBBox),r},n.prototype._chooseSubtree=function(e,t,i,n){for(;n.push(t),!t.leaf&&n.length-1!==i;){for(var r=1/0,a=1/0,s=void 0,o=0;o<t.children.length;o++){var l=t.children[o],h=c(l),u=(d=e,p=l,(Math.max(p.maxX,d.maxX)-Math.min(p.minX,d.minX))*(Math.max(p.maxY,d.maxY)-Math.min(p.minY,d.minY))-h);u<a?(a=u,r=h<r?h:r,s=l):u===a&&h<r&&(r=h,s=l)}t=s||t.children[0]}var d,p;return t},n.prototype._insert=function(e,t,i){var n=i?e:this.toBBox(e),r=[],a=this._chooseSubtree(n,this.data,t,r);for(a.children.push(e),o(a,n);t>=0&&r[t].children.length>this._maxEntries;)this._split(r,t),t--;this._adjustParentBBoxes(n,r,t)},n.prototype._split=function(e,t){var i=e[t],n=i.children.length,r=this._minEntries;this._chooseSplitAxis(i,r,n);var s=this._chooseSplitIndex(i,r,n),o=f(i.children.splice(s,i.children.length-s));o.height=i.height,o.leaf=i.leaf,a(i,this.toBBox),a(o,this.toBBox),t?e[t-1].children.push(o):this._splitRoot(i,o)},n.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)},n.prototype._chooseSplitIndex=function(e,t,i){for(var n,r,a,o,l,h,u,d=1/0,p=1/0,f=t;f<=i-t;f++){var m=s(e,0,f,this.toBBox),g=s(e,f,i,this.toBBox),v=(r=m,a=g,o=Math.max(r.minX,a.minX),l=Math.max(r.minY,a.minY),h=Math.min(r.maxX,a.maxX),u=Math.min(r.maxY,a.maxY),Math.max(0,h-o)*Math.max(0,u-l)),y=c(m)+c(g);v<d?(d=v,n=f,p=y<p?y:p):v===d&&y<p&&(p=y,n=f)}return n||i-t},n.prototype._chooseSplitAxis=function(e,t,i){var n=e.leaf?this.compareMinX:l,r=e.leaf?this.compareMinY:h;this._allDistMargin(e,t,i,n)<this._allDistMargin(e,t,i,r)&&e.children.sort(n)},n.prototype._allDistMargin=function(e,t,i,n){e.children.sort(n);for(var r=this.toBBox,a=s(e,0,t,r),l=s(e,i-t,i,r),h=u(a)+u(l),c=t;c<i-t;c++){var d=e.children[c];o(a,e.leaf?r(d):d),h+=u(a)}for(var p=i-t-1;p>=t;p--){var f=e.children[p];o(l,e.leaf?r(f):f),h+=u(l)}return h},n.prototype._adjustParentBBoxes=function(e,t,i){for(var n=i;n>=0;n--)o(t[n],e)},n.prototype._condense=function(e){for(var t=e.length-1,i=void 0;t>=0;t--)0===e[t].children.length?t>0?(i=e[t-1].children).splice(i.indexOf(e[t]),1):this.clear():a(e[t],this.toBBox)},n},"object"==typeof e&&void 0!==t?t.exports=n():"function"==typeof define&&define.amd?define(n):(i=i||self).RBush=n()})),ope=Q(((e,t)=>{var i,n;i=e,n=function(){"use strict";var e=function(e,i){if(void 0===e&&(e=[]),void 0===i&&(i=t),this.data=e,this.length=this.data.length,this.compare=i,this.length>0)for(var n=(this.length>>1)-1;n>=0;n--)this._down(n)};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,i=this.compare,n=t[e];e>0;){var r=e-1>>1,a=t[r];if(i(n,a)>=0)break;t[e]=a,e=r}t[e]=n},e.prototype._down=function(e){for(var t=this.data,i=this.compare,n=this.length>>1,r=t[e];e<n;){var a=1+(e<<1),s=t[a],o=a+1;if(o<this.length&&i(t[o],s)<0&&(a=o,s=t[o]),i(s,r)>=0)break;t[e]=s,e=a}t[e]=r},e},"object"==typeof e&&void 0!==t?t.exports=n():"function"==typeof define&&define.amd?define(n):(i=i||self).TinyQueue=n()})),cpe=Q(((e,t)=>{t.exports=function(e,t,i,n){var r=e[0],a=e[1],s=!1;void 0===i&&(i=0),void 0===n&&(n=t.length);for(var o=(n-i)/2,l=0,h=o-1;l<o;h=l++){var c=t[i+2*l+0],u=t[i+2*l+1],d=t[i+2*h+0],p=t[i+2*h+1];u>a!=p>a&&r<(d-c)*(a-u)/(p-u)+c&&(s=!s)}return s}})),hpe=Q(((e,t)=>{t.exports=function(e,t,i,n){var r=e[0],a=e[1],s=!1;void 0===i&&(i=0),void 0===n&&(n=t.length);for(var o=n-i,l=0,h=o-1;l<o;h=l++){var c=t[l+i][0],u=t[l+i][1],d=t[h+i][0],p=t[h+i][1];u>a!=p>a&&r<(d-c)*(a-u)/(p-u)+c&&(s=!s)}return s}})),ppe=Q(((e,t)=>{var i=cpe(),n=hpe();t.exports=function(e,t,r,a){return t.length>0&&Array.isArray(t[0])?n(e,t,r,a):i(e,t,r,a)},t.exports.nested=n,t.exports.flat=i})),gpe=Q(((e,t)=>{var i,n;i=e,n=function(e){"use strict";function t(e,t,i,n,r){let a,s,o,l,h=t[0],c=n[0],u=0,d=0;c>h==c>-h?(a=h,h=t[++u]):(a=c,c=n[++d]);let p=0;if(u<e&&d<i)for(c>h==c>-h?(o=a-((s=h+a)-h),h=t[++u]):(o=a-((s=c+a)-c),c=n[++d]),a=s,0!==o&&(r[p++]=o);u<e&&d<i;)c>h==c>-h?(o=a-((s=a+h)-(l=s-a))+(h-l),h=t[++u]):(o=a-((s=a+c)-(l=s-a))+(c-l),c=n[++d]),a=s,0!==o&&(r[p++]=o);for(;u<e;)o=a-((s=a+h)-(l=s-a))+(h-l),h=t[++u],a=s,0!==o&&(r[p++]=o);for(;d<i;)o=a-((s=a+c)-(l=s-a))+(c-l),c=n[++d],a=s,0!==o&&(r[p++]=o);return 0===a&&0!==p||(r[p++]=a),p}function i(e){return new Float64Array(e)}let n=i(4),r=i(8),a=i(12),s=i(16),o=i(4);e.orient2d=function(e,i,l,h,c,u){let d=(i-u)*(l-c),p=(e-c)*(h-u),f=d-p;if(0===d||0===p||d>0!=p>0)return f;let m=Math.abs(d+p);return Math.abs(f)>=33306690738754716e-32*m?f:-function(e,i,l,h,c,u,d){let p,f,m,g,v,y,x,b,_,w,S,M,E,T,A,C,P,R,D=e-c,L=l-c,I=i-u,O=h-u;v=(A=(b=D-(x=(y=134217729*D)-(y-D)))*(w=O-(_=(y=134217729*O)-(y-O)))-((T=D*O)-x*_-b*_-x*w))-(S=A-(P=(b=I-(x=(y=134217729*I)-(y-I)))*(w=L-(_=(y=134217729*L)-(y-L)))-((C=I*L)-x*_-b*_-x*w))),n[0]=A-(S+v)+(v-P),v=(E=T-((M=T+S)-(v=M-T))+(S-v))-(S=E-C),n[1]=E-(S+v)+(v-C),v=(R=M+S)-M,n[2]=M-(R-v)+(S-v),n[3]=R;let k=function(e,t){let i=t[0];for(let n=1;n<4;n++)i+=t[n];return i}(0,n),N=22204460492503146e-32*d;if(k>=N||-k>=N||(p=e-(D+(v=e-D))+(v-c),m=l-(L+(v=l-L))+(v-c),f=i-(I+(v=i-I))+(v-u),g=h-(O+(v=h-O))+(v-u),0===p&&0===f&&0===m&&0===g)||(N=11093356479670487e-47*d+33306690738754706e-32*Math.abs(k),(k+=D*g+O*p-(I*m+L*f))>=N||-k>=N))return k;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=L-(_=(y=134217729*L)-(y-L)))-((C=f*L)-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,n,4,o,r);v=(A=(b=D-(x=(y=134217729*D)-(y-D)))*(w=g-(_=(y=134217729*g)-(y-g)))-((T=D*g)-x*_-b*_-x*w))-(S=A-(P=(b=I-(x=(y=134217729*I)-(y-I)))*(w=m-(_=(y=134217729*m)-(y-m)))-((C=I*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,i,l,h,c,u,m)},e.orient2dfast=function(e,t,i,n,r,a){return(t-a)*(i-r)-(e-r)*(n-a)},Object.defineProperty(e,"__esModule",{value:!0})},"object"==typeof e&&void 0!==t?n(e):"function"==typeof define&&define.amd?define(["exports"],n):n((i=i||self).predicates={})})),_pe=Q(((e,t)=>{"use strict";var i=ape(),n=ope(),r=ppe(),a=gpe().orient2d;function s(e,t,n){t=Math.max(0,void 0===t?2:t),n=n||0;var a=function(e){for(var t=e[0],i=e[0],n=e[0],a=e[0],s=0;s<e.length;s++){var o=e[s];o[0]<t[0]&&(t=o),o[0]>n[0]&&(n=o),o[1]<i[1]&&(i=o),o[1]>a[1]&&(a=o)}var l=[t,i,n,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=[],i=0;i<e.length;i++){for(;t.length>=2&&d(t[t.length-2],t[t.length-1],e[i])<=0;)t.pop();t.push(e[i])}for(var n=[],r=e.length-1;r>=0;r--){for(;n.length>=2&&d(n[n.length-2],n[n.length-1],e[r])<=0;)n.pop();n.push(e[r])}return n.pop(),t.pop(),t.concat(n)}(h)}(e),s=new i(16);s.toBBox=function(e){return{minX:e[0],minY:e[1],maxX:e[0],maxY:e[1]}},s.compareMinX=function(e,t){return e[0]-t[0]},s.compareMinY=function(e,t){return e[1]-t[1]},s.load(e);for(var l,h=[],c=0;c<a.length;c++){var u=a[c];s.remove(u),l=m(u,l),h.push(l)}var p=new i(16);for(c=0;c<h.length;c++)p.insert(f(h[c]));for(var v=t*t,y=n*n;h.length;){var b=h.shift(),_=b.p,w=b.next.p,S=g(_,w);if(!(S<y)){var M=S/v;(u=o(s,b.prev.p,_,w,b.next.next.p,M,p))&&Math.min(g(u,_),g(u,w))<=M&&(h.push(b),h.push(m(u,b)),s.remove(u),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,i,r,a,s,o){for(var c=new n([],l),d=e.data;d;){for(var p=0;p<d.children.length;p++){var f=d.children[p],m=d.leaf?v(f,i,r):h(i,r,f);m>s||c.push({node:f,dist:m})}for(;c.length&&!c.peek().node.children;){var g=c.pop(),y=g.node,x=v(y,t,i),b=v(y,r,a);if(g.dist<x&&g.dist<b&&u(i,y,o)&&u(r,y,o))return y}(d=c.pop())&&(d=d.node)}return null}function l(e,t){return e.dist-t.dist}function h(e,t,i){if(c(e,i)||c(t,i))return 0;var n=y(e[0],e[1],t[0],t[1],i.minX,i.minY,i.maxX,i.minY);if(0===n)return 0;var r=y(e[0],e[1],t[0],t[1],i.minX,i.minY,i.minX,i.maxY);if(0===r)return 0;var a=y(e[0],e[1],t[0],t[1],i.maxX,i.minY,i.maxX,i.maxY);if(0===a)return 0;var s=y(e[0],e[1],t[0],t[1],i.minX,i.maxY,i.maxX,i.maxY);return 0===s?0:Math.min(n,r,a,s)}function c(e,t){return e[0]>=t.minX&&e[0]<=t.maxX&&e[1]>=t.minY&&e[1]<=t.maxY}function u(e,t,i){for(var n=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=i.search({minX:n,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,i){return a(e[0],e[1],t[0],t[1],i[0],i[1])}function p(e,t,i,n){return e!==n&&t!==i&&d(e,t,i)>0!=d(e,t,n)>0&&d(i,n,e)>0!=d(i,n,t)>0}function f(e){var t=e.p,i=e.next.p;return e.minX=Math.min(t[0],i[0]),e.minY=Math.min(t[1],i[1]),e.maxX=Math.max(t[0],i[0]),e.maxY=Math.max(t[1],i[1]),e}function m(e,t){var i={p:e,prev:null,next:null,minX:0,minY:0,maxX:0,maxY:0};return t?(i.next=t.next,i.prev=t,t.next.prev=i,t.next=i):(i.prev=i,i.next=i),i}function g(e,t){var i=e[0]-t[0],n=e[1]-t[1];return i*i+n*n}function v(e,t,i){var n=t[0],r=t[1],a=i[0]-n,s=i[1]-r;if(0!==a||0!==s){var o=((e[0]-n)*a+(e[1]-r)*s)/(a*a+s*s);o>1?(n=i[0],r=i[1]):o>0&&(n+=a*o,r+=s*o)}return(a=e[0]-n)*a+(s=e[1]-r)*s}function y(e,t,i,n,r,a,s,o){var l,h,c,u,d=i-e,p=n-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,u=w,E=b):(u=y*w-x*_,(h=x*w-b*_)<0?(h=0,u=w,E=b):h>M&&(h=M,u=w+x,E=b)),u<0?(u=0,-_<0?h=0:-_>y?h=M:(h=-_,M=y)):u>E&&(u=E,-_+x<0?h=0:-_+x>y?h=M:(h=-_+x,M=y));var T=(1-(c=0===u?0:u/E))*r+c*s-((1-(l=0===h?0:h/M))*e+l*i),A=(1-c)*a+c*o-((1-l)*t+l*n);return T*T+A*A}function x(e,t){return e[0]===t[0]?e[1]-t[1]:e[0]-t[0]}n.default&&(n=n.default),t.exports=s,t.exports.default=s})),Gpe=Q(((e,t)=>{t.exports=function(){var e,t=0,i=!1;function n(t,i){return e.list.push({type:t,data:i?JSON.parse(JSON.stringify(i)):void 0}),e}return e={list:[],segmentId:function(){return t++},checkIntersection:function(e,t){return n("check",{seg1:e,seg2:t})},segmentChop:function(e,t){return n("div_seg",{seg:e,pt:t}),n("chop",{seg:e,pt:t})},statusRemove:function(e){return n("pop_seg",{seg:e})},segmentUpdate:function(e){return n("seg_update",{seg:e})},segmentNew:function(e,t){return n("new_seg",{seg:e,primary:t})},segmentRemove:function(e){return n("rem_seg",{seg:e})},tempStatus:function(e,t,i){return n("temp_status",{seg:e,above:t,below:i})},rewind:function(e){return n("rewind",{seg:e})},status:function(e,t,i){return n("status",{seg:e,above:t,below:i})},vert:function(t){return t===i?e:(i=t,n("vert",{x:t}))},log:function(e){return"string"!=typeof e&&(e=JSON.stringify(e,!1," ")),n("log",{txt:e})},reset:function(){return n("reset")},selected:function(e){return n("selected",{segs:e})},chainStart:function(e){return n("chain_start",{seg:e})},chainRemoveHead:function(e,t){return n("chain_rem_head",{index:e,pt:t})},chainRemoveTail:function(e,t){return n("chain_rem_tail",{index:e,pt:t})},chainNew:function(e,t){return n("chain_new",{pt1:e,pt2:t})},chainMatch:function(e){return n("chain_match",{index:e})},chainClose:function(e){return n("chain_close",{index:e})},chainAddHead:function(e,t){return n("chain_add_head",{index:e,pt:t})},chainAddTail:function(e,t){return n("chain_add_tail",{index:e,pt:t})},chainConnect:function(e,t){return n("chain_con",{index1:e,index2:t})},chainReverse:function(e){return n("chain_rev",{index:e})},chainJoin:function(e,t){return n("chain_join",{index1:e,index2:t})},done:function(){return n("done")}}}})),Wpe=Q(((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,i,n){var r=i[0],a=i[1],s=n[0],o=n[1],l=t[0];return(s-r)*(t[1]-a)-(o-a)*(l-r)>=-e},pointBetween:function(t,i,n){var r=t[1]-i[1],a=n[0]-i[0],s=t[0]-i[0],o=n[1]-i[1],l=s*a+r*o;return!(l<e)&&!(l-(a*a+o*o)>-e)},pointsSameX:function(t,i){return Math.abs(t[0]-i[0])<e},pointsSameY:function(t,i){return Math.abs(t[1]-i[1])<e},pointsSame:function(e,i){return t.pointsSameX(e,i)&&t.pointsSameY(e,i)},pointsCompare:function(e,i){return t.pointsSameX(e,i)?t.pointsSameY(e,i)?0:e[1]<i[1]?-1:1:e[0]<i[0]?-1:1},pointsCollinear:function(t,i,n){var r=t[0]-i[0],a=t[1]-i[1],s=i[0]-n[0],o=i[1]-n[1];return Math.abs(r*o-s*a)<e},linesIntersect:function(t,i,n,r){var a=i[0]-t[0],s=i[1]-t[1],o=r[0]-n[0],l=r[1]-n[1],h=a*l-s*o;if(Math.abs(h)<e)return!1;var c=t[0]-n[0],u=t[1]-n[1],d=(o*u-l*c)/h,p=(a*u-s*c)/h,f={alongA:0,alongB:0,pt:[t[0]+d*a,t[1]+d*s]};return f.alongA=d<=-e?-2:d<e?-1:d-1<=-e?0:d-1<e?1:2,f.alongB=p<=-e?-2:p<e?-1:p-1<=-e?0:p-1<e?1:2,f},pointInsideRegion:function(t,i){for(var n=t[0],r=t[1],a=i[i.length-1][0],s=i[i.length-1][1],o=!1,l=0;l<i.length;l++){var h=i[l][0],c=i[l][1];c-r>e!=s-r>e&&(a-h)*(r-c)/(s-c)+h-n>e&&(o=!o),a=h,s=c}return o}};return t}})),Xpe=Q(((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,i){for(var n=e.root,r=e.root.next;null!==r;){if(i(r))return t.prev=r.prev,t.next=r,r.prev.next=t,void(r.prev=t);n=r,r=r.next}n.next=t,t.prev=n,t.next=null},findTransition:function(t){for(var i=e.root,n=e.root.next;null!==n&&!t(n);)i=n,n=n.next;return{before:i===e.root?null:i,after:n,insert:function(e){return e.prev=i,e.next=n,i.next=e,null!==n&&(n.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}}})),$pe=Q(((e,t)=>{var i=Xpe();t.exports=function(e,t,n){function r(e,t){return{id:n?n.segmentId():-1,start:e,end:t,myFill:{above:null,below:null},otherFill:null}}function a(e,t,i){return{id:n?n.segmentId():-1,start:e,end:t,myFill:{above:i.myFill.above,below:i.myFill.below},otherFill:null}}var s=i.create();function o(e,i){s.insertBefore(e,(function(n){var r=function(e,i,n,r,a,s){var o=t.pointsCompare(i,a);return 0!==o?o:t.pointsSame(n,s)?0:e!==r?e?1:-1:t.pointAboveOrOnLine(n,r?a:s,r?s:a)?1:-1}(e.isStart,e.pt,i,n.isStart,n.pt,n.other.pt);return r<0}))}function l(e,t){var n=function(e,t){var n=i.node({isStart:!0,pt:e.start,seg:e,primary:t,other:null,status:null});return o(n,e.end),n}(e,t);return function(e,t,n){var r=i.node({isStart:!1,pt:t.end,seg:t,primary:n,other:e,status:null});e.other=r,o(r,e.pt)}(n,e,t),n}function h(e,t){var i=a(t,e.seg.end,e.seg);return function(e,t){n&&n.segmentChop(e.seg,t),e.other.remove(),e.seg.end=t,e.other.pt=t,o(e.other,e.pt)}(e,t),l(i,e.primary)}function c(r,a){var o=i.create();function l(e){return o.findTransition((function(i){var n=function(e,i){var n=e.seg.start,r=e.seg.end,a=i.seg.start,s=i.seg.end;return t.pointsCollinear(n,a,s)?t.pointsCollinear(r,a,s)||t.pointAboveOrOnLine(r,a,s)?1:-1:t.pointAboveOrOnLine(n,a,s)?1:-1}(e,i.ev);return n>0}))}function c(e,i){var r=e.seg,a=i.seg,s=r.start,o=r.end,l=a.start,c=a.end;n&&n.checkIntersection(r,a);var u=t.linesIntersect(s,o,l,c);if(!1===u){if(!t.pointsCollinear(s,o,l)||t.pointsSame(s,c)||t.pointsSame(o,l))return!1;var d=t.pointsSame(s,l),p=t.pointsSame(o,c);if(d&&p)return i;var f=!d&&t.pointBetween(s,l,c),m=!p&&t.pointBetween(o,l,c);if(d)return m?h(i,o):h(e,c),i;f&&(p||(m?h(i,o):h(e,c)),h(i,s))}else 0===u.alongA&&(-1===u.alongB?h(e,l):0===u.alongB?h(e,u.pt):1===u.alongB&&h(e,c)),0===u.alongB&&(-1===u.alongA?h(i,s):0===u.alongA?h(i,u.pt):1===u.alongA&&h(i,o));return!1}for(var u=[];!s.isEmpty();){var d=s.getHead();if(n&&n.vert(d.pt[0]),d.isStart){let t=function(){if(f){var e=c(d,f);if(e)return e}return!!m&&c(d,m)};n&&n.segmentNew(d.seg,d.primary);var p=l(d),f=p.before?p.before.ev:null,m=p.after?p.after.ev:null;n&&n.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,n&&n.segmentUpdate(v.seg),d.other.remove(),d.remove();if(s.getHead()!==d){n&&n.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}}n&&n.status(d.seg,!!f&&f.seg,!!m&&m.seg),d.other.status=p.insert(i.node({ev:d}))}else{var x=d.status;if(null===x)throw new Error("PolyBool: Zero-length segment detected; your epsilon is probably too small or too large");if(o.exists(x.prev)&&o.exists(x.next)&&c(x.prev.ev,x.next.ev),n&&n.statusRemove(x.ev.seg),x.remove(),!d.primary){var b=d.seg.myFill;d.seg.myFill=d.seg.otherFill,d.seg.otherFill=b}u.push(d.seg)}s.getHead().remove()}return n&&n.done(),u}return e?{addRegion:function(e){for(var i,n=e[e.length-1],a=0;a<e.length;a++){i=n,n=e[a];var s=t.pointsCompare(i,n);0!==s&&l(r(s<0?i:n,s<0?n:i),!0)}},calculate:function(e){return c(e,!1)}}:{calculate:function(e,t,i,n){return e.forEach((function(e){l(a(e.start,e.end,e),!0)})),i.forEach((function(e){l(a(e.start,e.end,e),!1)})),c(t,n)}}}})),Kpe=Q(((e,t)=>{t.exports=function(e,t,i){var n=[],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{i&&i.chainStart(e);for(var o={index:0,matches_head:!1,matches_pt1:!1},l={index:0,matches_head:!1,matches_pt1:!1},h=o,c=0;c<n.length;c++){var u=(g=n[c])[0],d=(g[1],g[g.length-1]);if(g[g.length-2],t.pointsSame(u,a)){if(M(c,!0,!0))break}else if(t.pointsSame(u,s)){if(M(c,!0,!1))break}else if(t.pointsSame(d,a)){if(M(c,!1,!0))break}else if(t.pointsSame(d,s)&&M(c,!1,!1))break}if(h===o)return n.push([a,s]),void(i&&i.chainNew(a,s));if(h===l){i&&i.chainMatch(o.index);var p=o.index,f=o.matches_pt1?s:a,m=o.matches_head,g=n[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?(i&&i.chainRemoveHead(o.index,f),g.shift()):(i&&i.chainRemoveTail(o.index,f),g.pop()),v=y),t.pointsSame(x,f)?(n.splice(p,1),t.pointsCollinear(b,x,v)&&(m?(i&&i.chainRemoveTail(o.index,v),g.pop()):(i&&i.chainRemoveHead(o.index,v),g.shift())),i&&i.chainClose(o.index),void r.push(g)):void(m?(i&&i.chainAddHead(o.index,f),g.unshift(f)):(i&&i.chainAddTail(o.index,f),g.push(f)))}var _=o.index,w=l.index;i&&i.chainConnect(_,w);var S=n[_].length<n[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,i){return h.index=e,h.matches_head=t,h.matches_pt1=i,h===o?(h=l,!1):(h=null,!0)}function E(e){i&&i.chainReverse(e),n[e].reverse()}function T(e,r){var a=n[e],s=n[r],o=a[a.length-1],l=a[a.length-2],h=s[0],c=s[1];t.pointsCollinear(l,o,h)&&(i&&i.chainRemoveTail(e,o),a.pop(),o=l),t.pointsCollinear(o,h,c)&&(i&&i.chainRemoveHead(r,h),s.shift()),i&&i.chainJoin(e,r),n[e]=a.concat(s),n.splice(r,1)}})),r}})),Qpe=Q(((e,t)=>{function i(e,t,i){var n=[];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]&&n.push({id:i?i.segmentId():-1,start:e.start,end:e.end,myFill:{above:1===t[r],below:2===t[r]},otherFill:null})})),i&&i.selected(n),n}var n={union:function(e,t){return i(e,[0,2,1,0,2,2,0,0,1,0,1,0,0,0,0,0],t)},intersect:function(e,t){return i(e,[0,0,0,0,0,2,0,2,0,0,1,1,0,2,1,0],t)},difference:function(e,t){return i(e,[0,0,0,0,2,0,2,0,1,1,0,0,0,1,2,0],t)},differenceRev:function(e,t){return i(e,[0,2,1,0,0,0,1,1,0,2,0,2,0,0,0,0],t)},xor:function(e,t){return i(e,[0,2,1,0,2,0,0,1,1,0,0,2,0,1,2,0],t)}};t.exports=n})),tme=Q(((e,t)=>{var i={toPolygon:function(e,t){function i(t){if(t.length<=0)return e.segments({inverted:!1,regions:[]});function i(t){var i=t.slice(0,t.length-1);return e.segments({inverted:!1,regions:[i]})}for(var n=i(t[0]),r=1;r<t.length;r++)n=e.selectDifference(e.combine(n,i(t[r])));return n}if("Polygon"===t.type)return e.polygon(i(t.coordinates));if("MultiPolygon"===t.type){for(var n=e.segments({inverted:!1,regions:[]}),r=0;r<t.coordinates.length;r++)n=e.selectUnion(e.combine(n,i(t.coordinates[r])));return e.polygon(n)}throw new Error("PolyBool: Cannot convert GeoJSON object to PolyBool polygon")},fromPolygon:function(e,t,i){function n(e,i){return t.pointInsideRegion([.5*(e[0][0]+e[1][0]),.5*(e[0][1]+e[1][1])],i)}function r(e){return{region:e,children:[]}}i=e.polygon(e.segments(i));var a=r(null);function s(e,t){for(var i=0;i<e.children.length;i++)if(n(t,(o=e.children[i]).region))return void s(o,t);var a=r(t);for(i=0;i<e.children.length;i++){var o;n((o=e.children[i]).region,t)&&(a.children.push(o),e.children.splice(i,1),i--)}e.children.push(a)}for(var o=0;o<i.regions.length;o++){var l=i.regions[o];l.length<3||s(a,l)}function h(e,t){for(var i=0,n=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]),i+=l*n-o*r,n=o,r=l}return i<0!==t&&a.reverse(),a.push([a[0][0],a[0][1]]),a}var c=[];function u(e){var t=[h(e.region,!1)];c.push(t);for(var i=0;i<e.children.length;i++)t.push(d(e.children[i]))}function d(e){for(var t=0;t<e.children.length;t++)u(e.children[t]);return h(e.region,!0)}for(o=0;o<a.children.length;o++)u(a.children[o]);return c.length<=0?{type:"Polygon",coordinates:[]}:1==c.length?{type:"Polygon",coordinates:c[0]}:{type:"MultiPolygon",coordinates:c}}};t.exports=i})),sme=Q(((e,t)=>{var i,n=Gpe(),r=Wpe(),a=$pe(),s=Kpe(),o=Qpe(),l=tme(),h=!1,c=r();function u(e,t,n){var r=i.segments(e),a=i.segments(t),s=n(i.combine(r,a));return i.polygon(s)}i={buildLog:function(e){return!0===e?h=n():!1===e&&(h=!1),!1!==h&&h.list},epsilon:function(e){return c.epsilon(e)},segments:function(e){var t=a(!0,c,h);return e.regions.forEach(t.addRegion),{segments:t.calculate(e.inverted),inverted:e.inverted}},combine:function(e,t){return{combined:a(!1,c,h).calculate(e.segments,e.inverted,t.segments,t.inverted),inverted1:e.inverted,inverted2:t.inverted}},selectUnion:function(e){return{segments:o.union(e.combined,h),inverted:e.inverted1||e.inverted2}},selectIntersect:function(e){return{segments:o.intersect(e.combined,h),inverted:e.inverted1&&e.inverted2}},selectDifference:function(e){return{segments:o.difference(e.combined,h),inverted:e.inverted1&&!e.inverted2}},selectDifferenceRev:function(e){return{segments:o.differenceRev(e.combined,h),inverted:!e.inverted1&&e.inverted2}},selectXor:function(e){return{segments:o.xor(e.combined,h),inverted:e.inverted1!==e.inverted2}},polygon:function(e){return{regions:s(e.segments,c,h),inverted:e.inverted}},polygonFromGeoJSON:function(e){return l.toPolygon(i,e)},polygonToGeoJSON:function(e){return l.fromPolygon(i,c,e)},union:function(e,t){return u(e,t,i.selectUnion)},intersect:function(e,t){return u(e,t,i.selectIntersect)},difference:function(e,t){return u(e,t,i.selectDifference)},differenceRev:function(e,t){return u(e,t,i.selectDifferenceRev)},xor:function(e,t){return u(e,t,i.selectXor)}},"object"==typeof window&&(window.PolyBool=i),t.exports=i})),PC=Q((()=>{})),ave=Q(((e,t)=>{var i,n;i=e,n=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 i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function i(e,i,n){return i&&t(e.prototype,i),n&&t(e,n),e}var n=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,i){for(var r=new n(null,null),a=r,s=r;;){var o=i(e,t.key);if(o<0){if(null===t.left)break;if(i(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(i(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,i,r){var s=new n(e,t);if(null===i)return s.left=s.right=null,s;var o=r(e,(i=a(e,i,r)).key);return o<0?(s.left=i.left,s.right=i,i.left=null):o>=0&&(s.right=i.right,s.left=i,i.right=null),s}function o(e,t,i){var n=null,r=null;if(t){var s=i((t=a(e,t,i)).key,e);0===s?(n=t.left,r=t.right):s<0?(r=t.right,t.right=null,n=t):(n=t.left,t.left=null,r=t)}return{left:n,right:r}}function l(e,t,i,n,r){if(e){n(t+(i?"\u2514\u2500\u2500 ":"\u251c\u2500\u2500 ")+r(e)+"\n");var a=t+(i?" ":"\u2502 ");e.left&&l(e.left,a,!1,n,r),e.right&&l(e.right,a,!0,n,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 i=new n(e,t);null===this._root&&(i.left=i.right=null,this._size++,this._root=i);var r=this._comparator,s=a(e,this._root,r),o=r(e,s.key);return 0===o?this._root=s:(o<0?(i.left=s.left,i.right=s,s.left=null):o>0&&(i.right=s.right,i.left=s,s.right=null),this._size++,this._root=i),this._root},e.prototype.remove=function(e){this._root=this._remove(e,this._root,this._comparator)},e.prototype._remove=function(e,t,i){var n;return null===t?null:0===i(e,(t=a(e,t,i)).key)?(null===t.left?n=t.right:(n=a(e,t.left,i)).right=t.right,this._size--,n):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,i=this._comparator;t;){var n=i(e,t.key);if(0===n)return t;t=n<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,i=this._comparator;t;){var n=i(e,t.key);if(0===n)return!0;t=n<0?t.left:t.right}return!1},e.prototype.forEach=function(e,t){for(var i=this._root,n=[],r=!1;!r;)null!==i?(n.push(i),i=i.left):0!==n.length?(i=n.pop(),e.call(t,i),i=i.right):r=!0;return this},e.prototype.range=function(e,t,i,n){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&&i.call(n,s))return this;s=s.right}return this},e.prototype.keys=function(){var e=[];return this.forEach((function(t){var i=t.key;return e.push(i)})),e},e.prototype.values=function(){var e=[];return this.forEach((function(t){var i=t.data;return e.push(i)})),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,i=!1,n=0,r=[];!i;)if(t)r.push(t),t=t.left;else if(r.length>0){if(t=r.pop(),n===e)return t;n++,t=t.right}else i=!0;return null},e.prototype.next=function(e){var t=this._root,i=null;if(e.right){for(i=e.right;i.left;)i=i.left;return i}for(var n=this._comparator;t;){var r=n(e.key,t.key);if(0===r)break;r<0?(i=t,t=t.left):t=t.right}return i},e.prototype.prev=function(e){var t=this._root,i=null;if(null!==e.left){for(i=e.left;i.right;)i=i.right;return i}for(var n=this._comparator;t;){var r=n(e.key,t.key);if(0===r)break;r<0?t=t.left:(i=t,t=t.right)}return i},e.prototype.clear=function(){return this._root=null,this._size=0,this},e.prototype.toList=function(){return function(e){for(var t=e,i=[],r=!1,a=new n(null,null),s=a;!r;)t?(i.push(t),t=t.left):i.length>0?t=(t=s=s.next=i.pop()).right:r=!0;return s.next=null,a.next}(this._root)},e.prototype.load=function(e,t,i){void 0===t&&(t=[]),void 0===i&&(i=!1);var r=e.length,a=this._comparator;if(i&&d(e,t,0,r-1,a),null===this._root)this._root=c(e,t,0,r),this._size=r;else{var s=function(e,t,i){for(var r=new n(null,null),a=r,s=e,o=t;null!==s&&null!==o;)i(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 i=new n(null,null),r=i,a=0;a<e.length;a++)r=r.next=new n(e[a],t[a]);return r.next=null,i.next}(e,t),a);r=this._size+r,this._root=u({head:s},0,r)}return this},e.prototype.isEmpty=function(){return null===this._root},Object.defineProperty(e.prototype,"size",{get:function(){return this._size},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"root",{get:function(){return this._root},enumerable:!0,configurable:!0}),e.prototype.toString=function(e){void 0===e&&(e=function(e){return String(e.key)});var t=[];return l(this._root,"",!0,(function(e){return t.push(e)}),e),t.join("")},e.prototype.update=function(e,t,i){var n=this._comparator,r=o(e,this._root,n),l=r.left,h=r.right;n(e,t)<0?h=s(t,i,h,n):l=s(t,i,l,n),this._root=function(e,t,i){return null===t?e:(null===e||((t=a(e.key,t,i)).left=e),t)}(l,h,n)},e.prototype.split=function(e){return o(e,this._root,this._comparator)},e}();function c(e,t,i,r){var a=r-i;if(a>0){var s=i+Math.floor(a/2),o=e[s],l=t[s],h=new n(o,l);return h.left=c(e,t,i,s),h.right=c(e,t,s+1,r),h}return null}function u(e,t,i){var n=i-t;if(n>0){var r=t+Math.floor(n/2),a=u(e,t,r),s=e.head;return s.left=a,e.head=e.head.next,s.right=u(e,r+1,i),s}return null}function d(e,t,i,n,r){if(!(i>=n)){for(var a=e[i+n>>1],s=i-1,o=n+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,i,o,r),d(e,t,o+1,n,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 i=e.ll.x<t.ll.x?t.ll.x:e.ll.x,n=e.ur.x<t.ur.x?e.ur.x:t.ur.x;return{ll:{x:i,y:e.ll.y<t.ll.y?t.ll.y:e.ll.y},ur:{x:n,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 i=e-t;return i*i<g*e*t?0:e<t?-1:1},y=function(){function t(){e(this,t),this.reset()}return i(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 i(t,[{key:"round",value:function(e){var t=this.tree.add(e),i=this.tree.prev(t);if(null!==i&&0===v(t.key,i.key))return this.tree.remove(e),i.key;var n=this.tree.next(t);return null!==n&&0===v(t.key,n.key)?(this.tree.remove(e),n.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,i){var n={x:t.x-e.x,y:t.y-e.y},r={x:i.x-e.x,y:i.y-e.y},a=_(n,r);return v(a,0)},M=function(e){return Math.sqrt(w(e,e))},E=function(e,t,i){var n={x:t.x-e.x,y:t.y-e.y},r={x:i.x-e.x,y:i.y-e.y};return _(r,n)/M(r)/M(n)},T=function(e,t,i){var n={x:t.x-e.x,y:t.y-e.y},r={x:i.x-e.x,y:i.y-e.y};return w(r,n)/M(r)/M(n)},A=function(e,t,i){return 0===t.y?null:{x:e.x+t.x/t.y*(i-e.y),y:i}},C=function(e,t,i){return 0===t.x?null:{x:i,y:e.y+t.y/t.x*(i-e.x)}},P=function(){function t(i,n){e(this,t),void 0===i.events?i.events=[this]:i.events.push(this),this.point=i,this.isLeft=n}return i(t,null,[{key:"compare",value:function(e,i){var n=t.comparePoints(e.point,i.point);return 0!==n?n:(e.point!==i.point&&e.link(i),e.isLeft!==i.isLeft?e.isLeft?1:-1:D.compare(e.segment,i.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}}]),i(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,i=0,n=t.length;i<n;i++){var r=t[i];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 i=this.point.events[t];if(void 0===i.segment.consumedBy)for(var n=t+1;n<e;n++){var r=this.point.events[n];void 0===r.consumedBy&&i.otherSE.point.events===r.otherSE.point.events&&i.segment.consume(r.segment)}}}},{key:"getAvailableLinkedEvents",value:function(){for(var e=[],t=0,i=this.point.events.length;t<i;t++){var n=this.point.events[t];n!==this&&!n.segment.ringOut&&n.segment.isInResult()&&e.push(n)}return e}},{key:"getLeftmostComparator",value:function(e){var t=this,i=new Map,n=function(n){var r=n.otherSE;i.set(n,{sine:E(t.point,e.point,r.point),cosine:T(t.point,e.point,r.point)})};return function(e,t){i.has(e)||n(e),i.has(t)||n(t);var r=i.get(e),a=r.sine,s=r.cosine,o=i.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,D=function(){function t(i,n,r,a){e(this,t),this.id=++R,this.leftSE=i,i.segment=this,i.otherSE=n,this.rightSE=n,n.segment=this,n.otherSE=i,this.rings=r,this.windings=a}return i(t,null,[{key:"compare",value:function(e,t){var i=e.leftSE.point.x,n=t.leftSE.point.x,r=e.rightSE.point.x,a=t.rightSE.point.x;if(a<i)return 1;if(r<n)return-1;var s=e.leftSE.point.y,o=t.leftSE.point.y,l=e.rightSE.point.y,h=t.rightSE.point.y;if(i<n){if(o<s&&o<l)return 1;if(o>s&&o>l)return-1;var c=e.comparePoint(t.leftSE.point);if(c<0)return 1;if(c>0)return-1;var u=t.comparePoint(e.rightSE.point);return 0!==u?u:-1}if(i>n){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-i,y=h-o,x=a-n;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}}]),i(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,i=this.rightSE.point,n=this.vector();if(t.x===i.x)return e.x===t.x?0:e.x<t.x?1:-1;var r=(e.y-t.y)/n.y,a=t.x+r*n.x;if(e.x===a)return 0;var s=(e.x-t.x)/n.x,o=t.y+s*n.y;return e.y===o?0:e.y<o?-1:1}},{key:"getIntersection",value:function(e){var t=this.bbox(),i=e.bbox(),n=f(t,i);if(null===n)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(i,r)&&0===e.comparePoint(r),c=p(t,o)&&0===this.comparePoint(o),u=p(i,a)&&0===e.comparePoint(a);if(h&&l)return u&&!c?a:!u&&c?o:null;if(h)return c&&r.x===o.x&&r.y===o.y?null:r;if(l)return u&&a.x===s.x&&a.y===s.y?null:s;if(u&&c)return null;if(u)return a;if(c)return o;var d=function(e,t,i,n){if(0===t.x)return C(i,n,e.x);if(0===n.x)return C(e,t,i.x);if(0===t.y)return A(i,n,e.y);if(0===n.y)return A(e,t,i.y);var r=_(t,n);if(0==r)return null;var a={x:i.x-e.x,y:i.y-e.y},s=_(a,t)/r,o=_(a,n)/r;return{x:(e.x+o*t.x+(i.x+s*n.x))/2,y:(e.y+o*t.y+(i.y+s*n.y))/2}}(r,this.vector(),s,e.vector());return null!==d&&p(n,d)?b.round(d.x,d.y):null}},{key:"split",value:function(e){var i=[],n=void 0!==e.events,r=new P(e,!0),a=new P(e,!1),s=this.rightSE;this.replaceRightSE(a),i.push(a),i.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(),n&&(r.checkForConsuming(),a.checkForConsuming()),i}},{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,i=this.windings.length;t<i;t++)this.windings[t]*=-1}},{key:"consume",value:function(e){for(var i=this,n=e;i.consumedBy;)i=i.consumedBy;for(;n.consumedBy;)n=n.consumedBy;var r=t.compare(i,n);if(0!==r){if(r>0){var a=i;i=n,n=a}if(i.prev===n){var s=i;i=n,n=s}for(var o=0,l=n.rings.length;o<l;o++){var h=n.rings[o],c=n.windings[o],u=i.rings.indexOf(h);-1===u?(i.rings.push(h),i.windings.push(c)):i.windings[u]+=c}n.rings=null,n.windings=null,n.consumedBy=i,n.leftSE.consumedBy=i.leftSE,n.rightSE.consumedBy=i.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,i=this._afterState.windings,n=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),i.push(o)):i[l]+=o}for(var h=[],c=[],u=0,d=t.length;u<d;u++)if(0!==i[u]){var p=t[u],f=p.poly;if(-1===c.indexOf(f))if(p.isExterior)h.push(f);else{-1===c.indexOf(f)&&c.push(f);var m=h.indexOf(p.poly);-1!==m&&h.splice(m,1)}}for(var g=0,v=h.length;g<v;g++){var y=h[g].multiPoly;-1===n.indexOf(y)&&n.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 i=0===e.length,n=0===t.length;this._isInResult=i!==n;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,i,n){var r,a,s,o=P.comparePoints(e,i);if(o<0)r=e,a=i,s=1;else{if(!(o>0))throw new Error("Tried to create degenerate segment at [".concat(e.x,", ").concat(e.y,"]"));r=i,a=e,s=-1}return new t(new P(r,!0),new P(a,!1),[n],[s])}}]),t}(),L=function(){function t(i,n,r){if(e(this,t),!Array.isArray(i)||0===i.length)throw new Error("Input geometry is not a valid Polygon or MultiPolygon");if(this.poly=n,this.isExterior=r,this.segments=[],"number"!=typeof i[0][0]||"number"!=typeof i[0][1])throw new Error("Input geometry is not a valid Polygon or MultiPolygon");var a=b.round(i[0][0],i[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=i.length;o<l;o++){if("number"!=typeof i[o][0]||"number"!=typeof i[o][1])throw new Error("Input geometry is not a valid Polygon or MultiPolygon");var h=b.round(i[o][0],i[o][1]);h.x===s.x&&h.y===s.y||(this.segments.push(D.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(D.fromRing(s,a,this))}return i(t,[{key:"getSweepEvents",value:function(){for(var e=[],t=0,i=this.segments.length;t<i;t++){var n=this.segments[t];e.push(n.leftSE),e.push(n.rightSE)}return e}}]),t}(),I=function(){function t(i,n){if(e(this,t),!Array.isArray(i))throw new Error("Input geometry is not a valid Polygon or MultiPolygon");this.exteriorRing=new L(i[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=i.length;r<a;r++){var s=new L(i[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=n}return i(t,[{key:"getSweepEvents",value:function(){for(var e=this.exteriorRing.getSweepEvents(),t=0,i=this.interiorRings.length;t<i;t++)for(var n=this.interiorRings[t].getSweepEvents(),r=0,a=n.length;r<a;r++)e.push(n[r]);return e}}]),t}(),O=function(){function t(i,n){if(e(this,t),!Array.isArray(i))throw new Error("Input geometry is not a valid Polygon or MultiPolygon");try{"number"==typeof i[0][0][0]&&(i=[i])}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=i.length;r<a;r++){var s=new I(i[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=n}return i(t,[{key:"getSweepEvents",value:function(){for(var e=[],t=0,i=this.polys.length;t<i;t++)for(var n=this.polys[t].getSweepEvents(),r=0,a=n.length;r<a;r++)e.push(n[r]);return e}}]),t}(),k=function(){function t(i){e(this,t),this.events=i;for(var n=0,r=i.length;n<r;n++)i[n].segment.ringOut=this;this.poly=null}return i(t,null,[{key:"factory",value:function(e){for(var i=[],n=0,r=e.length;n<r;n++){var a=e[n];if(a.isInResult()&&!a.ringOut){for(var s=null,o=a.leftSE,l=a.rightSE,h=[o],c=o.point,u=[];s=o,o=l,h.push(o),o.point!==c;)for(;;){var d=o.getAvailableLinkedEvents();if(0===d.length){var p=h[0].point,f=h[h.length-1].point;throw new Error("Unable to complete output ring starting at [".concat(p.x,",")+" ".concat(p.y,"]. Last matching segment found ends at")+" [".concat(f.x,", ").concat(f.y,"]."))}if(1===d.length){l=d[0].otherSE;break}for(var m=null,g=0,v=u.length;g<v;g++)if(u[g].point===o.point){m=g;break}if(null===m){u.push({index:h.length,point:o.point});var y=o.getLeftmostComparator(s);l=d.sort(y)[0].otherSE;break}var x=u.splice(m)[0],b=h.splice(x.index);b.unshift(b[0].otherSE),i.push(new t(b.reverse()))}i.push(new t(h))}}return i}}]),i(t,[{key:"getGeom",value:function(){for(var e=this.events[0].point,t=[e],i=1,n=this.events.length-1;i<n;i++){var r=this.events[i].point,a=this.events[i+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,c=this.isExteriorRing()?t.length:-1,u=[],d=h;d!=c;d+=l)u.push([t[d].x,t[d].y]);return u}},{key:"isExteriorRing",value:function(){if(void 0===this._isExteriorRing){var e=this.enclosingRing();this._isExteriorRing=!e||!e.isExteriorRing()}return this._isExteriorRing}},{key:"enclosingRing",value:function(){return void 0===this._enclosingRing&&(this._enclosingRing=this._calcEnclosingRing()),this._enclosingRing}},{key:"_calcEnclosingRing",value:function(){for(var e=this.events[0],t=1,i=this.events.length;t<i;t++){var n=this.events[t];P.compare(e,n)>0&&(e=n)}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(i){e(this,t),this.exteriorRing=i,i.poly=this,this.interiorRings=[]}return i(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,i=this.interiorRings.length;t<i;t++){var n=this.interiorRings[t].getGeom();null!==n&&e.push(n)}return e}}]),t}(),U=function(){function t(i){e(this,t),this.rings=i,this.polys=this._composePolys(i)}return i(t,[{key:"getGeom",value:function(){for(var e=[],t=0,i=this.polys.length;t<i;t++){var n=this.polys[t].getGeom();null!==n&&e.push(n)}return e}},{key:"_composePolys",value:function(e){for(var t=[],i=0,n=e.length;i<n;i++){var r=e[i];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(i){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:D.compare;e(this,t),this.queue=i,this.tree=new h(n),this.segments=[]}return i(t,[{key:"process",value:function(e){var t=e.segment,i=[];if(e.consumedBy)return e.isLeft?this.queue.remove(e.otherSE):this.tree.remove(t),i;var n=e.isLeft?this.tree.insert(t):this.tree.find(t);if(!n)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=n,a=n,s=void 0,o=void 0;void 0===s;)null===(r=this.tree.prev(r))?s=null:void 0===r.key.consumedBy&&(s=r.key);for(;void 0===o;)null===(a=this.tree.next(a))?o=null:void 0===a.key.consumedBy&&(o=a.key);if(e.isLeft){var l=null;if(s){var h=s.getIntersection(t);if(null!==h&&(t.isAnEndpoint(h)||(l=h),!s.isAnEndpoint(h)))for(var c=this._splitSafely(s,h),u=0,d=c.length;u<d;u++)i.push(c[u])}var p=null;if(o){var f=o.getIntersection(t);if(null!==f&&(t.isAnEndpoint(f)||(p=f),!o.isAnEndpoint(f)))for(var m=this._splitSafely(o,f),g=0,v=m.length;g<v;g++)i.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),i.push(t.rightSE);for(var x=t.split(y),b=0,_=x.length;b<_;b++)i.push(x[b])}i.length>0?(this.tree.remove(t),i.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++)i.push(S[M]);if(!o.isAnEndpoint(w))for(var T=this._splitSafely(o,w),A=0,C=T.length;A<C;A++)i.push(T[A])}}this.tree.remove(t)}return i}},{key:"_splitSafely",value:function(e,t){this.tree.remove(e);var i=e.rightSE;this.queue.remove(i);var n=e.split(t);return n.push(i),void 0===e.consumedBy&&this.tree.insert(e),n}}]),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 i(t,[{key:"run",value:function(e,t,i){H.type=e,b.reset();for(var n=[new O(t,!0)],r=0,a=i.length;r<a;r++)n.push(new O(i[r],!1));if(H.numMultiPolys=n.length,"difference"===H.type)for(var s=n[0],o=1;o<n.length;)null!==f(n[o].bbox,s.bbox)?o++:n.splice(o,1);if("intersection"===H.type)for(var l=0,c=n.length;l<c;l++)for(var u=n[l],d=l+1,p=n.length;d<p;d++)if(null===f(u.bbox,n[d].bbox))return[];for(var m=new h(P.compare),g=0,v=n.length;g<v;g++)for(var y=n[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 D=A[C];void 0===D.consumedBy&&m.insert(D)}S=m.size,M=m.pop()}b.reset();var L=k.factory(w.segments);return new U(L).getGeom()}}]),t}()),V={union:function(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),n=1;n<t;n++)i[n-1]=arguments[n];return H.run("union",e,i)},intersection:function(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),n=1;n<t;n++)i[n-1]=arguments[n];return H.run("intersection",e,i)},xor:function(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),n=1;n<t;n++)i[n-1]=arguments[n];return H.run("xor",e,i)},difference:function(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),n=1;n<t;n++)i[n-1]=arguments[n];return H.run("difference",e,i)}};return V},"object"==typeof e&&void 0!==t?t.exports=n():"function"==typeof define&&define.amd?define(n):(i="undefined"!=typeof globalThis?globalThis:i||self).polygonClipping=n()})),Tye=Q(((e,t)=>{!function(){"use strict";var e,i={version:"6.4.2.2",use_lines:!0,use_xyz:!1},n=!1;if(void 0!==t&&t.exports?(t.exports=i,n=!0):("function"==typeof define&&define.amd&&define(i),"undefined"!=typeof document?window.ClipperLib=i:self.ClipperLib=i),n){var r="chrome";e="Netscape"}else r=navigator.userAgent.toString().toLowerCase(),e=navigator.appName;var a,s={};function o(e,t,n){i.biginteger_used=1,null!=e&&("number"==typeof e&&void 0===t?this.fromInt(e):"number"==typeof e?this.fromNumber(e,t,n):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,i.biginteger_used=null,"Microsoft Internet Explorer"==e?(o.prototype.am=function(e,t,i,n,r,a){for(var s=32767&t,o=t>>15;--a>=0;){var l=32767&this[e],h=this[e++]>>15,c=o*l+h*s;r=((l=s*l+((32767&c)<<15)+i[n]+(1073741823&r))>>>30)+(c>>>15)+o*h+(r>>>30),i[n++]=1073741823&l}return r},a=30):"Netscape"!=e?(o.prototype.am=function(e,t,i,n,r,a){for(;--a>=0;){var s=t*this[e++]+i[n]+r;r=Math.floor(s/67108864),i[n++]=67108863&s}return r},a=26):(o.prototype.am=function(e,t,i,n,r,a){for(var s=16383&t,o=t>>14;--a>=0;){var l=16383&this[e],h=this[e++]>>14,c=o*l+h*s;r=((l=s*l+((16383&c)<<14)+i[n]+r)>>28)+(c>>14)+o*h,i[n++]=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,c,u=new Array;for(h="0".charCodeAt(0),c=0;c<=9;++c)u[h++]=c;for(h="a".charCodeAt(0),c=10;c<36;++c)u[h++]=c;for(h="A".charCodeAt(0),c=10;c<36;++c)u[h++]=c;function d(e){return"0123456789abcdefghijklmnopqrstuvwxyz".charAt(e)}function p(e,t){var i=u[e.charCodeAt(t)];return null==i?-1:i}function f(e){var t=l();return t.fromInt(e),t}function m(e){var t,i=1;return 0!=(t=e>>>16)&&(e=t,i+=16),0!=(t=e>>8)&&(e=t,i+=8),0!=(t=e>>4)&&(e=t,i+=4),0!=(t=e>>2)&&(e=t,i+=2),0!=(t=e>>1)&&(e=t,i+=1),i}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,i){e.multiplyTo(t,i),this.reduce(i)},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 i=32767&e[t],n=i*this.mpl+((i*this.mph+(e[t]>>15)*this.mpl&this.um)<<15)&e.DM;for(e[i=t+this.m.t]+=this.m.am(0,n,e,t,0,this.m.t);e[i]>=e.DV;)e[i]-=e.DV,e[++i]++}e.clamp(),e.drShiftTo(this.m.t,e),e.compareTo(this.m)>=0&&e.subTo(this.m,e)},v.prototype.mulTo=function(e,t,i){e.multiplyTo(t,i),this.reduce(i)},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 i;if(16==t)i=4;else if(8==t)i=3;else if(256==t)i=8;else if(2==t)i=1;else if(32==t)i=5;else{if(4!=t)return void this.fromRadix(e,t);i=2}this.t=0,this.s=0;for(var n=e.length,r=!1,a=0;--n>=0;){var s=8==i?255&e[n]:p(e,n);s<0?"-"==e.charAt(n)&&(r=!0):(r=!1,0==a?this[this.t++]=s:a+i>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+=i)>=this.DB&&(a-=this.DB))}8==i&&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 i;for(i=this.t-1;i>=0;--i)t[i+e]=this[i];for(i=e-1;i>=0;--i)t[i]=0;t.t=this.t+e,t.s=this.s},o.prototype.drShiftTo=function(e,t){for(var i=e;i<this.t;++i)t[i-e]=this[i];t.t=Math.max(this.t-e,0),t.s=this.s},o.prototype.lShiftTo=function(e,t){var i,n=e%this.DB,r=this.DB-n,a=(1<<r)-1,s=Math.floor(e/this.DB),o=this.s<<n&this.DM;for(i=this.t-1;i>=0;--i)t[i+s+1]=this[i]>>r|o,o=(this[i]&a)<<n;for(i=s-1;i>=0;--i)t[i]=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 i=Math.floor(e/this.DB);if(i>=this.t)t.t=0;else{var n=e%this.DB,r=this.DB-n,a=(1<<n)-1;t[0]=this[i]>>n;for(var s=i+1;s<this.t;++s)t[s-i-1]|=(this[s]&a)<<r,t[s-i]=this[s]>>n;n>0&&(t[this.t-i-1]|=(this.s&a)<<r),t.t=this.t-i,t.clamp()}},o.prototype.subTo=function(e,t){for(var i=0,n=0,r=Math.min(e.t,this.t);i<r;)n+=this[i]-e[i],t[i++]=n&this.DM,n>>=this.DB;if(e.t<this.t){for(n-=e.s;i<this.t;)n+=this[i],t[i++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;i<e.t;)n-=e[i],t[i++]=n&this.DM,n>>=this.DB;n-=e.s}t.s=n<0?-1:0,n<-1?t[i++]=this.DV+n:n>0&&(t[i++]=n),t.t=i,t.clamp()},o.prototype.multiplyTo=function(e,t){var i=this.abs(),n=e.abs(),r=i.t;for(t.t=r+n.t;--r>=0;)t[r]=0;for(r=0;r<n.t;++r)t[r+i.t]=i.am(0,n[r],t,r,0,i.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(),i=e.t=2*t.t;--i>=0;)e[i]=0;for(i=0;i<t.t-1;++i){var n=t.am(i,t[i],e,2*i,0,1);(e[i+t.t]+=t.am(i+1,2*t[i],e,2*i+1,n,t.t-i-1))>=t.DV&&(e[i+t.t]-=t.DV,e[i+t.t+1]=1)}e.t>0&&(e[e.t-1]+=t.am(i,t[i],e,2*i,0,1)),e.s=0,e.clamp()},o.prototype.divRemTo=function(e,t,i){var n=e.abs();if(!(n.t<=0)){var r=this.abs();if(r.t<n.t)return null!=t&&t.fromInt(0),void(null!=i&&this.copyTo(i));null==i&&(i=l());var a=l(),s=this.s,h=e.s,c=this.DB-m(n[n.t-1]);c>0?(n.lShiftTo(c,a),r.lShiftTo(c,i)):(n.copyTo(a),r.copyTo(i));var u=a.t,d=a[u-1];if(0!=d){var p=d*(1<<this.F1)+(u>1?a[u-2]>>this.F2:0),f=this.FV/p,g=(1<<this.F1)/p,v=1<<this.F2,y=i.t,x=y-u,b=null==t?l():t;for(a.dlShiftTo(x,b),i.compareTo(b)>=0&&(i[i.t++]=1,i.subTo(b,i)),o.ONE.dlShiftTo(u,b),b.subTo(a,a);a.t<u;)a[a.t++]=0;for(;--x>=0;){var _=i[--y]==d?this.DM:Math.floor(i[y]*f+(i[y-1]+v)*g);if((i[y]+=a.am(0,_,i,x,0,u))<_)for(a.dlShiftTo(x,b),i.subTo(b,i);i[y]<--_;)i.subTo(b,i)}null!=t&&(i.drShiftTo(u,t),s!=h&&o.ZERO.subTo(t,t)),i.t=u,i.clamp(),c>0&&i.rShiftTo(c,i),s<0&&o.ZERO.subTo(i,i)}}},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 i=l(),n=l(),r=t.convert(this),a=m(e)-1;for(r.copyTo(i);--a>=0;)if(t.sqrTo(i,n),(e&1<<a)>0)t.mulTo(n,r,i);else{var s=i;i=n,n=s}return t.revert(i)},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 i,n=(1<<t)-1,r=!1,a="",s=this.t,o=this.DB-s*this.DB%t;if(s-- >0)for(o<this.DB&&(i=this[s]>>o)>0&&(r=!0,a=d(i));s>=0;)o<t?(i=(this[s]&(1<<o)-1)<<t-o,i|=this[--s]>>(o+=this.DB-t)):(i=this[s]>>(o-=t)&n,o<=0&&(o+=this.DB,--s)),i>0&&(r=!0),r&&(a+=d(i));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 i=this.t;if(0!=(t=i-e.t))return this.s<0?-t:t;for(;--i>=0;)if(0!=(t=this[i]-e[i]))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 i;return i=e<256||t.isEven()?new g(t):new v(t),this.exp(e,i)},o.ZERO=f(0),o.ONE=f(1),M.prototype.convert=E,M.prototype.revert=E,M.prototype.mulTo=function(e,t,i){e.multiplyTo(t,i)},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,i){e.multiplyTo(t,i),this.reduce(i)},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),i=Math.pow(e,t),n=f(i),r=l(),a=l(),s="";for(this.divRemTo(n,r,a);r.signum()>0;)s=(i+a.intValue()).toString(e).substr(1)+s,r.divRemTo(n,r,a);return a.intValue().toString(e)+s},o.prototype.fromRadix=function(e,t){this.fromInt(0),null==t&&(t=10);for(var i=this.chunkSize(t),n=Math.pow(t,i),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>=i&&(this.dMultiply(n),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,i){if("number"==typeof t)if(e<2)this.fromInt(1);else for(this.fromNumber(e,i),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 n=new Array,r=7&e;n.length=1+(e>>3),t.nextBytes(n),r>0?n[0]&=(1<<r)-1:n[0]=0,this.fromString(n,256)}},o.prototype.bitwiseTo=function(e,t,i){var n,r,a=Math.min(e.t,this.t);for(n=0;n<a;++n)i[n]=t(this[n],e[n]);if(e.t<this.t){for(r=e.s&this.DM,n=a;n<this.t;++n)i[n]=t(this[n],r);i.t=this.t}else{for(r=this.s&this.DM,n=a;n<e.t;++n)i[n]=t(r,e[n]);i.t=e.t}i.s=t(this.s,e.s),i.clamp()},o.prototype.changeBit=function(e,t){var i=o.ONE.shiftLeft(e);return this.bitwiseTo(i,t,i),i},o.prototype.addTo=function(e,t){for(var i=0,n=0,r=Math.min(e.t,this.t);i<r;)n+=this[i]+e[i],t[i++]=n&this.DM,n>>=this.DB;if(e.t<this.t){for(n+=e.s;i<this.t;)n+=this[i],t[i++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;i<e.t;)n+=e[i],t[i++]=n&this.DM,n>>=this.DB;n+=e.s}t.s=n<0?-1:0,n>0?t[i++]=n:n<-1&&(t[i++]=this.DV+n),t.t=i,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,i){var n,r=Math.min(this.t+e.t,t);for(i.s=0,i.t=r;r>0;)i[--r]=0;for(n=i.t-this.t;r<n;++r)i[r+this.t]=this.am(0,e[r],i,r,0,this.t);for(n=Math.min(e.t,t);r<n;++r)this.am(0,e[r],i,r,0,t-r);i.clamp()},o.prototype.multiplyUpperTo=function(e,t,i){--t;var n=i.t=this.t+e.t-t;for(i.s=0;--n>=0;)i[n]=0;for(n=Math.max(t-this.t,0);n<e.t;++n)i[this.t+n-t]=this.am(t-n,e[n],i,0,0,this.t+n-t);i.clamp(),i.drShiftTo(1,i)},o.prototype.modInt=function(e){if(e<=0)return 0;var t=this.DV%e,i=this.s<0?e-1:0;if(this.t>0)if(0==t)i=this[0]%e;else for(var n=this.t-1;n>=0;--n)i=(t*i+this[n])%e;return i},o.prototype.millerRabin=function(e){var t=this.subtract(o.ONE),i=t.getLowestSetBit();if(i<=0)return!1;var n=t.shiftRight(i);(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(n,this);if(0!=s.compareTo(o.ONE)&&0!=s.compareTo(t)){for(var h=1;h++<i&&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 i,n=this.DB-e*this.DB%8,r=0;if(e-- >0)for(n<this.DB&&(i=this[e]>>n)!=(this.s&this.DM)>>n&&(t[r++]=i|this.s<<this.DB-n);e>=0;)n<8?(i=(this[e]&(1<<n)-1)<<8-n,i|=this[--e]>>(n+=this.DB-8)):(i=this[e]>>(n-=8)&255,n<=0&&(n+=this.DB,--e)),128&i&&(i|=-256),0==r&&(128&this.s)!=(128&i)&&++r,(r>0||i!=this.s)&&(t[r++]=i);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,i=0;i<this.t;++i)e+=S(this[i]^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(),i=l();return this.divRemTo(e,t,i),new Array(t,i)},o.prototype.modPow=function(e,t){var i,n,r=e.bitLength(),a=f(1);if(r<=0)return a;i=r<18?1:r<48?3:r<144?4:r<768?5:6,n=r<8?new g(t):t.isEven()?new T(t):new v(t);var s=new Array,o=3,h=i-1,c=(1<<i)-1;if(s[1]=n.convert(this),i>1){var u=l();for(n.sqrTo(s[1],u);o<=c;)s[o]=l(),n.mulTo(u,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&c:(d=(e[y]&(1<<r+1)-1)<<h-r,y>0&&(d|=e[y-1]>>this.DB+r-h)),o=i;!(1&d);)d>>=1,--o;if((r-=o)<0&&(r+=this.DB,--y),x)s[d].copyTo(a),x=!1;else{for(;o>1;)n.sqrTo(a,b),n.sqrTo(b,a),o-=2;o>0?n.sqrTo(a,b):(p=a,a=b,b=p),n.mulTo(b,s[d],a)}for(;y>=0&&!(e[y]&1<<r);)n.sqrTo(a,b),p=a,a=b,b=p,--r<0&&(r=this.DB-1,--y)}return n.revert(a)},o.prototype.modInverse=function(e){var t=e.isEven();if(this.isEven()&&t||0==e.signum())return o.ZERO;for(var i=e.clone(),n=this.clone(),r=f(1),a=f(0),s=f(0),l=f(1);0!=i.signum();){for(;i.isEven();)i.rShiftTo(1,i),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(;n.isEven();)n.rShiftTo(1,n),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);i.compareTo(n)>=0?(i.subTo(n,i),t&&r.subTo(s,r),a.subTo(l,a)):(n.subTo(i,n),t&&s.subTo(r,s),l.subTo(a,l))}return 0!=n.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(),i=e.s<0?e.negate():e.clone();if(t.compareTo(i)<0){var n=t;t=i,i=n}var r=t.getLowestSetBit(),a=i.getLowestSetBit();if(a<0)return t;for(r<a&&(a=r),a>0&&(t.rShiftTo(a,t),i.rShiftTo(a,i));t.signum()>0;)(r=t.getLowestSetBit())>0&&t.rShiftTo(r,t),(r=i.getLowestSetBit())>0&&i.rShiftTo(r,i),t.compareTo(i)>=0?(t.subTo(i,t),t.rShiftTo(1,t)):(i.subTo(t,i),i.rShiftTo(1,i));return a>0&&i.lShiftTo(a,i),i},o.prototype.isProbablePrime=function(e){var t,i=this.abs();if(1==i.t&&i[0]<=A[A.length-1]){for(t=0;t<A.length;++t)if(i[0]==A[t])return!0;return!1}if(i.isEven())return!1;for(t=1;t<A.length;){for(var n=A[t],r=t+1;r<A.length&&n<C;)n*=A[r++];for(n=i.modInt(n);t<r;)if(n%A[t++]==0)return!1}return i.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 i;if(void 0===Object.getOwnPropertyNames){for(i in t.prototype)(void 0===e.prototype[i]||e.prototype[i]===Object.prototype[i])&&(e.prototype[i]=t.prototype[i]);for(i in t)void 0===e[i]&&(e[i]=t[i]);e.$baseCtor=t}else{for(var n=Object.getOwnPropertyNames(t.prototype),r=0;r<n.length;r++)void 0===Object.getOwnPropertyDescriptor(e.prototype,n[r])&&Object.defineProperty(e.prototype,n[r],Object.getOwnPropertyDescriptor(t.prototype,n[r]));for(i in t)void 0===e[i]&&(e[i]=t[i]);e.$baseCtor=t}};i.Path=function(){return[]},i.Path.prototype.push=Array.prototype.push,i.Paths=function(){return[]},i.Paths.prototype.push=Array.prototype.push,i.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])},i.DoublePoint0=function(){this.X=0,this.Y=0},i.DoublePoint0.prototype=i.DoublePoint.prototype,i.DoublePoint1=function(e){this.X=e.X,this.Y=e.Y},i.DoublePoint1.prototype=i.DoublePoint.prototype,i.DoublePoint2=function(e,t){this.X=e,this.Y=t},i.DoublePoint2.prototype=i.DoublePoint.prototype,i.PolyNode=function(){this.m_Parent=null,this.m_polygon=new i.Path,this.m_Index=0,this.m_jointype=0,this.m_endtype=0,this.m_Childs=[],this.IsOpen=!1},i.PolyNode.prototype.IsHoleNode=function(){for(var e=!0,t=this.m_Parent;null!==t;)e=!e,t=t.m_Parent;return e},i.PolyNode.prototype.ChildCount=function(){return this.m_Childs.length},i.PolyNode.prototype.Contour=function(){return this.m_polygon},i.PolyNode.prototype.AddChild=function(e){var t=this.m_Childs.length;this.m_Childs.push(e),e.m_Parent=this,e.m_Index=t},i.PolyNode.prototype.GetNext=function(){return this.m_Childs.length>0?this.m_Childs[0]:this.GetNextSiblingUp()},i.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]},i.PolyNode.prototype.Childs=function(){return this.m_Childs},i.PolyNode.prototype.Parent=function(){return this.m_Parent},i.PolyNode.prototype.IsHole=function(){return this.IsHoleNode()},i.PolyTree=function(){this.m_AllPolys=[],i.PolyNode.call(this)},i.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},i.PolyTree.prototype.GetFirst=function(){return this.m_Childs.length>0?this.m_Childs[0]:null},i.PolyTree.prototype.Total=function(){var e=this.m_AllPolys.length;return e>0&&this.m_Childs[0]!==this.m_AllPolys[0]&&e--,e},R(i.PolyTree,i.PolyNode),i.Math_Abs_Int64=i.Math_Abs_Int32=i.Math_Abs_Double=function(e){return Math.abs(e)},i.Math_Max_Int32_Int32=function(e,t){return Math.max(e,t)},s.msie||s.opera||s.safari?i.Cast_Int32=function(e){return 0|e}:i.Cast_Int32=function(e){return~~e},void 0===Number.toInteger&&(Number.toInteger=null),s.chrome?i.Cast_Int64=function(e){return e<-2147483648||e>2147483647?e<0?Math.ceil(e):Math.floor(e):~~e}:s.firefox&&"function"==typeof Number.toInteger?i.Cast_Int64=function(e){return Number.toInteger(e)}:s.msie7||s.msie8?i.Cast_Int64=function(e){return parseInt(e,10)}:s.msie?i.Cast_Int64=function(e){return e<-2147483648||e>2147483647?e<0?Math.ceil(e):Math.floor(e):0|e}:i.Cast_Int64=function(e){return e<0?Math.ceil(e):Math.floor(e)},i.Clear=function(e){e.length=0},i.PI=3.141592653589793,i.PI2=6.283185307179586,i.IntPoint=function(){var e=arguments,t=e.length;if(this.X=0,this.Y=0,i.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 i.DoublePoint){var n=e[0];this.X=i.Clipper.Round(n.X),this.Y=i.Clipper.Round(n.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 i.DoublePoint)n=e[0],this.X=i.Clipper.Round(n.X),this.Y=i.Clipper.Round(n.Y);else{var r=e[0];this.X=r.X,this.Y=r.Y}else this.X=0,this.Y=0},i.IntPoint.op_Equality=function(e,t){return e.X===t.X&&e.Y===t.Y},i.IntPoint.op_Inequality=function(e,t){return e.X!==t.X||e.Y!==t.Y},i.IntPoint0=function(){this.X=0,this.Y=0,i.use_xyz&&(this.Z=0)},i.IntPoint0.prototype=i.IntPoint.prototype,i.IntPoint1=function(e){this.X=e.X,this.Y=e.Y,i.use_xyz&&(void 0===e.Z?this.Z=0:this.Z=e.Z)},i.IntPoint1.prototype=i.IntPoint.prototype,i.IntPoint1dp=function(e){this.X=i.Clipper.Round(e.X),this.Y=i.Clipper.Round(e.Y),i.use_xyz&&(this.Z=0)},i.IntPoint1dp.prototype=i.IntPoint.prototype,i.IntPoint2=function(e,t,n){this.X=e,this.Y=t,i.use_xyz&&(this.Z=void 0===n?0:n)},i.IntPoint2.prototype=i.IntPoint.prototype,i.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 i=e[0];this.left=i.left,this.top=i.top,this.right=i.right,this.bottom=i.bottom}else this.left=0,this.top=0,this.right=0,this.bottom=0},i.IntRect0=function(){this.left=0,this.top=0,this.right=0,this.bottom=0},i.IntRect0.prototype=i.IntRect.prototype,i.IntRect1=function(e){this.left=e.left,this.top=e.top,this.right=e.right,this.bottom=e.bottom},i.IntRect1.prototype=i.IntRect.prototype,i.IntRect4=function(e,t,i,n){this.left=e,this.top=t,this.right=i,this.bottom=n},i.IntRect4.prototype=i.IntRect.prototype,i.ClipType={ctIntersection:0,ctUnion:1,ctDifference:2,ctXor:3},i.PolyType={ptSubject:0,ptClip:1},i.PolyFillType={pftEvenOdd:0,pftNonZero:1,pftPositive:2,pftNegative:3},i.JoinType={jtSquare:0,jtRound:1,jtMiter:2},i.EndType={etOpenSquare:0,etOpenRound:1,etOpenButt:2,etClosedLine:3,etClosedPolygon:4},i.EdgeSide={esLeft:0,esRight:1},i.Direction={dRightToLeft:0,dLeftToRight:1},i.TEdge=function(){this.Bot=new i.IntPoint0,this.Curr=new i.IntPoint0,this.Top=new i.IntPoint0,this.Delta=new i.IntPoint0,this.Dx=0,this.PolyTyp=i.PolyType.ptSubject,this.Side=i.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},i.IntersectNode=function(){this.Edge1=null,this.Edge2=null,this.Pt=new i.IntPoint0},i.MyIntersectNodeSort=function(){},i.MyIntersectNodeSort.Compare=function(e,t){var i=t.Pt.Y-e.Pt.Y;return i>0?1:i<0?-1:0},i.LocalMinima=function(){this.Y=0,this.LeftBound=null,this.RightBound=null,this.Next=null},i.Scanbeam=function(){this.Y=0,this.Next=null},i.Maxima=function(){this.X=0,this.Next=null,this.Prev=null},i.OutRec=function(){this.Idx=0,this.IsHole=!1,this.IsOpen=!1,this.FirstLeft=null,this.Pts=null,this.BottomPt=null,this.PolyNode=null},i.OutPt=function(){this.Idx=0,this.Pt=new i.IntPoint0,this.Next=null,this.Prev=null},i.Join=function(){this.OutPt1=null,this.OutPt2=null,this.OffPt=new i.IntPoint0},i.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},i.ClipperBase.horizontal=-9007199254740992,i.ClipperBase.Skip=-2,i.ClipperBase.Unassigned=-1,i.ClipperBase.tolerance=1e-20,i.ClipperBase.loRange=47453132,i.ClipperBase.hiRange=0xfffffffffffff,i.ClipperBase.near_zero=function(e){return e>-i.ClipperBase.tolerance&&e<i.ClipperBase.tolerance},i.ClipperBase.IsHorizontal=function(e){return 0===e.Delta.Y},i.ClipperBase.prototype.PointIsVertex=function(e,t){var n=t;do{if(i.IntPoint.op_Equality(n.Pt,e))return!0;n=n.Next}while(n!==t);return!1},i.ClipperBase.prototype.PointOnLineSegment=function(e,t,i,n){return n?e.X===t.X&&e.Y===t.Y||e.X===i.X&&e.Y===i.Y||e.X>t.X==e.X<i.X&&e.Y>t.Y==e.Y<i.Y&&P.op_Equality(P.Int128Mul(e.X-t.X,i.Y-t.Y),P.Int128Mul(i.X-t.X,e.Y-t.Y)):e.X===t.X&&e.Y===t.Y||e.X===i.X&&e.Y===i.Y||e.X>t.X==e.X<i.X&&e.Y>t.Y==e.Y<i.Y&&(e.X-t.X)*(i.Y-t.Y)==(i.X-t.X)*(e.Y-t.Y)},i.ClipperBase.prototype.PointOnPolygon=function(e,t,i){for(var n=t;;){if(this.PointOnLineSegment(e,n.Pt,n.Next.Pt,i))return!0;if((n=n.Next)===t)break}return!1},i.ClipperBase.prototype.SlopesEqual=i.ClipperBase.SlopesEqual=function(){var e,t,n,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)):i.Cast_Int64(e.Delta.Y*t.Delta.X)===i.Cast_Int64(e.Delta.X*t.Delta.Y)):4===l?(n=o[0],r=o[1],a=o[2],o[3]?P.op_Equality(P.Int128Mul(n.Y-r.Y,r.X-a.X),P.Int128Mul(n.X-r.X,r.Y-a.Y)):i.Cast_Int64((n.Y-r.Y)*(r.X-a.X))-i.Cast_Int64((n.X-r.X)*(r.Y-a.Y))==0):(n=o[0],r=o[1],a=o[2],s=o[3],o[4]?P.op_Equality(P.Int128Mul(n.Y-r.Y,a.X-s.X),P.Int128Mul(n.X-r.X,a.Y-s.Y)):i.Cast_Int64((n.Y-r.Y)*(a.X-s.X))-i.Cast_Int64((n.X-r.X)*(a.Y-s.Y))==0)},i.ClipperBase.SlopesEqual3=function(e,t,n){return n?P.op_Equality(P.Int128Mul(e.Delta.Y,t.Delta.X),P.Int128Mul(e.Delta.X,t.Delta.Y)):i.Cast_Int64(e.Delta.Y*t.Delta.X)===i.Cast_Int64(e.Delta.X*t.Delta.Y)},i.ClipperBase.SlopesEqual4=function(e,t,n,r){return r?P.op_Equality(P.Int128Mul(e.Y-t.Y,t.X-n.X),P.Int128Mul(e.X-t.X,t.Y-n.Y)):i.Cast_Int64((e.Y-t.Y)*(t.X-n.X))-i.Cast_Int64((e.X-t.X)*(t.Y-n.Y))==0},i.ClipperBase.SlopesEqual5=function(e,t,n,r,a){return a?P.op_Equality(P.Int128Mul(e.Y-t.Y,n.X-r.X),P.Int128Mul(e.X-t.X,n.Y-r.Y)):i.Cast_Int64((e.Y-t.Y)*(n.X-r.X))-i.Cast_Int64((e.X-t.X)*(n.Y-r.Y))==0},i.ClipperBase.prototype.Clear=function(){this.DisposeLocalMinimaList();for(var e=0,t=this.m_edges.length;e<t;++e){for(var n=0,r=this.m_edges[e].length;n<r;++n)this.m_edges[e][n]=null;i.Clear(this.m_edges[e])}i.Clear(this.m_edges),this.m_UseFullRange=!1,this.m_HasOpenPaths=!1},i.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},i.ClipperBase.prototype.RangeTest=function(e,t){t.Value?(e.X>i.ClipperBase.hiRange||e.Y>i.ClipperBase.hiRange||-e.X>i.ClipperBase.hiRange||-e.Y>i.ClipperBase.hiRange)&&i.Error("Coordinate outside allowed range in RangeTest()."):(e.X>i.ClipperBase.loRange||e.Y>i.ClipperBase.loRange||-e.X>i.ClipperBase.loRange||-e.Y>i.ClipperBase.loRange)&&(t.Value=!0,this.RangeTest(e,t))},i.ClipperBase.prototype.InitEdge=function(e,t,n,r){e.Next=t,e.Prev=n,e.Curr.X=r.X,e.Curr.Y=r.Y,i.use_xyz&&(e.Curr.Z=r.Z),e.OutIdx=-1},i.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,i.use_xyz&&(e.Bot.Z=e.Curr.Z),e.Top.X=e.Next.Curr.X,e.Top.Y=e.Next.Curr.Y,i.use_xyz&&(e.Top.Z=e.Next.Curr.Z)):(e.Top.X=e.Curr.X,e.Top.Y=e.Curr.Y,i.use_xyz&&(e.Top.Z=e.Curr.Z),e.Bot.X=e.Next.Curr.X,e.Bot.Y=e.Next.Curr.Y,i.use_xyz&&(e.Bot.Z=e.Next.Curr.Z)),this.SetDx(e),e.PolyTyp=t},i.ClipperBase.prototype.FindNextLocMin=function(e){for(var t;;){for(;i.IntPoint.op_Inequality(e.Bot,e.Prev.Bot)||i.IntPoint.op_Equality(e.Curr,e.Top);)e=e.Next;if(e.Dx!==i.ClipperBase.horizontal&&e.Prev.Dx!==i.ClipperBase.horizontal)break;for(;e.Prev.Dx===i.ClipperBase.horizontal;)e=e.Prev;for(t=e;e.Dx===i.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},i.ClipperBase.prototype.ProcessBound=function(e,t){var n,r,a=e;if(a.OutIdx===i.ClipperBase.Skip){if(e=a,t){for(;e.Top.Y===e.Next.Bot.Y;)e=e.Next;for(;e!==a&&e.Dx===i.ClipperBase.horizontal;)e=e.Prev}else{for(;e.Top.Y===e.Prev.Bot.Y;)e=e.Prev;for(;e!==a&&e.Dx===i.ClipperBase.horizontal;)e=e.Next}if(e===a)a=t?e.Next:e.Prev;else{e=t?a.Next:a.Prev;var s=new i.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===i.ClipperBase.horizontal&&((n=t?e.Prev:e.Next).Dx===i.ClipperBase.horizontal?n.Bot.X!==e.Bot.X&&n.Top.X!==e.Bot.X&&this.ReverseHorizontal(e):n.Bot.X!==e.Bot.X&&this.ReverseHorizontal(e)),n=e,t){for(;a.Top.Y===a.Next.Bot.Y&&a.Next.OutIdx!==i.ClipperBase.Skip;)a=a.Next;if(a.Dx===i.ClipperBase.horizontal&&a.Next.OutIdx!==i.ClipperBase.Skip){for(r=a;r.Prev.Dx===i.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===i.ClipperBase.horizontal&&e!==n&&e.Bot.X!==e.Prev.Top.X&&this.ReverseHorizontal(e),e=e.Next;e.Dx===i.ClipperBase.horizontal&&e!==n&&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!==i.ClipperBase.Skip;)a=a.Prev;if(a.Dx===i.ClipperBase.horizontal&&a.Prev.OutIdx!==i.ClipperBase.Skip){for(r=a;r.Next.Dx===i.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===i.ClipperBase.horizontal&&e!==n&&e.Bot.X!==e.Next.Top.X&&this.ReverseHorizontal(e),e=e.Prev;e.Dx===i.ClipperBase.horizontal&&e!==n&&e.Bot.X!==e.Next.Top.X&&this.ReverseHorizontal(e),a=a.Prev}return a},i.ClipperBase.prototype.AddPath=function(e,t,n){i.use_lines?!n&&t===i.PolyType.ptClip&&i.Error("AddPath: Open paths must be subject."):n||i.Error("AddPath: Open paths have been disabled.");var r=e.length-1;if(n)for(;r>0&&i.IntPoint.op_Equality(e[r],e[0]);)--r;for(;r>0&&i.IntPoint.op_Equality(e[r],e[r-1]);)--r;if(n&&r<2||!n&&r<1)return!1;for(var a=new Array,s=0;s<=r;s++)a.push(new i.TEdge);var o=!0;a[1].Curr.X=e[1].X,a[1].Curr.Y=e[1].Y,i.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],c=h,u=h;;)if(c.Curr!==c.Next.Curr||!n&&c.Next===h){if(c.Prev===c.Next)break;if(!n||!i.ClipperBase.SlopesEqual4(c.Prev.Curr,c.Curr,c.Next.Curr,this.m_UseFullRange)||this.PreserveCollinear&&this.Pt2IsBetweenPt1AndPt3(c.Prev.Curr,c.Curr,c.Next.Curr)){if((c=c.Next)===u||!n&&c.Next===h)break}else c===h&&(h=c.Next),u=c=(c=this.RemoveEdge(c)).Prev}else{if(c===c.Next)break;c===h&&(h=c.Next),u=c=this.RemoveEdge(c)}if(!n&&c===c.Next||n&&c.Prev===c.Next)return!1;n||(this.m_HasOpenPaths=!0,h.Prev.OutIdx=i.ClipperBase.Skip),c=h;do{this.InitEdge2(c,t),c=c.Next,o&&c.Curr.Y!==h.Curr.Y&&(o=!1)}while(c!==h);if(o){if(n)return!1;for(c.Prev.OutIdx=i.ClipperBase.Skip,(f=new i.LocalMinima).Next=null,f.Y=c.Bot.Y,f.LeftBound=null,f.RightBound=c,f.RightBound.Side=i.EdgeSide.esRight,f.RightBound.WindDelta=0;c.Bot.X!==c.Prev.Top.X&&this.ReverseHorizontal(c),c.Next.OutIdx!==i.ClipperBase.Skip;)c.NextInLML=c.Next,c=c.Next;return this.InsertLocalMinima(f),this.m_edges.push(a),!0}this.m_edges.push(a);var d,p=null;for(i.IntPoint.op_Equality(c.Prev.Bot,c.Prev.Top)&&(c=c.Next);(c=this.FindNextLocMin(c))!==p;){var f;null===p&&(p=c),(f=new i.LocalMinima).Next=null,f.Y=c.Bot.Y,c.Dx<c.Prev.Dx?(f.LeftBound=c.Prev,f.RightBound=c,d=!1):(f.LeftBound=c,f.RightBound=c.Prev,d=!0),f.LeftBound.Side=i.EdgeSide.esLeft,f.RightBound.Side=i.EdgeSide.esRight,n?f.LeftBound.Next===f.RightBound?f.LeftBound.WindDelta=-1:f.LeftBound.WindDelta=1:f.LeftBound.WindDelta=0,f.RightBound.WindDelta=-f.LeftBound.WindDelta,(c=this.ProcessBound(f.LeftBound,d)).OutIdx===i.ClipperBase.Skip&&(c=this.ProcessBound(c,d));var m=this.ProcessBound(f.RightBound,!d);m.OutIdx===i.ClipperBase.Skip&&(m=this.ProcessBound(m,!d)),f.LeftBound.OutIdx===i.ClipperBase.Skip?f.LeftBound=null:f.RightBound.OutIdx===i.ClipperBase.Skip&&(f.RightBound=null),this.InsertLocalMinima(f),d||(c=m)}return!0},i.ClipperBase.prototype.AddPaths=function(e,t,i){for(var n=!1,r=0,a=e.length;r<a;++r)this.AddPath(e[r],t,i)&&(n=!0);return n},i.ClipperBase.prototype.Pt2IsBetweenPt1AndPt3=function(e,t,n){return!(i.IntPoint.op_Equality(e,n)||i.IntPoint.op_Equality(e,t)||i.IntPoint.op_Equality(n,t))&&(e.X!==n.X?t.X>e.X==t.X<n.X:t.Y>e.Y==t.Y<n.Y)},i.ClipperBase.prototype.RemoveEdge=function(e){e.Prev.Next=e.Next,e.Next.Prev=e.Prev;var t=e.Next;return e.Prev=null,t},i.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=i.ClipperBase.horizontal:e.Dx=e.Delta.X/e.Delta.Y},i.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}},i.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)},i.ClipperBase.prototype.ReverseHorizontal=function(e){var t=e.Top.X;e.Top.X=e.Bot.X,e.Bot.X=t,i.use_xyz&&(t=e.Top.Z,e.Top.Z=e.Bot.Z,e.Bot.Z=t)},i.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,i.use_xyz&&(t.Curr.Z=t.Bot.Z),t.OutIdx=i.ClipperBase.Unassigned),null!==(t=e.RightBound)&&(t.Curr.X=t.Bot.X,t.Curr.Y=t.Bot.Y,i.use_xyz&&(t.Curr.Z=t.Bot.Z),t.OutIdx=i.ClipperBase.Unassigned),e=e.Next}this.m_ActiveEdges=null}},i.ClipperBase.prototype.InsertScanbeam=function(e){if(null===this.m_Scanbeam)this.m_Scanbeam=new i.Scanbeam,this.m_Scanbeam.Next=null,this.m_Scanbeam.Y=e;else if(e>this.m_Scanbeam.Y){var t=new i.Scanbeam;t.Y=e,t.Next=this.m_Scanbeam,this.m_Scanbeam=t}else{for(var n=this.m_Scanbeam;null!==n.Next&&e<=n.Next.Y;)n=n.Next;if(e===n.Y)return;var r=new i.Scanbeam;r.Y=e,r.Next=n.Next,n.Next=r}},i.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)},i.ClipperBase.prototype.LocalMinimaPending=function(){return null!==this.m_CurrentLM},i.ClipperBase.prototype.CreateOutRec=function(){var e=new i.OutRec;return e.Idx=i.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},i.ClipperBase.prototype.DisposeOutRec=function(e){var t=this.m_PolyOuts[e];t.Pts=null,t=null,this.m_PolyOuts[e]=null},i.ClipperBase.prototype.UpdateEdgeIntoAEL=function(e){null===e.NextInLML&&i.Error("UpdateEdgeIntoAEL: invalid call");var t=e.PrevInAEL,n=e.NextInAEL;return e.NextInLML.OutIdx=e.OutIdx,null!==t?t.NextInAEL=e.NextInLML:this.m_ActiveEdges=e.NextInLML,null!==n&&(n.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=n,i.ClipperBase.IsHorizontal(e)||this.InsertScanbeam(e.Top.Y),e},i.ClipperBase.prototype.SwapPositionsInAEL=function(e,t){if(e.NextInAEL!==e.PrevInAEL&&t.NextInAEL!==t.PrevInAEL){if(e.NextInAEL===t){var i=t.NextInAEL;null!==i&&(i.PrevInAEL=e);var n=e.PrevInAEL;null!==n&&(n.NextInAEL=t),t.PrevInAEL=n,t.NextInAEL=e,e.PrevInAEL=t,e.NextInAEL=i}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)}},i.ClipperBase.prototype.DeleteFromAEL=function(e){var t=e.PrevInAEL,i=e.NextInAEL;null===t&&null===i&&e!==this.m_ActiveEdges||(null!==t?t.NextInAEL=i:this.m_ActiveEdges=i,null!==i&&(i.PrevInAEL=t),e.NextInAEL=null,e.PrevInAEL=null)},i.Clipper=function(e){void 0===e&&(e=0),this.m_PolyOuts=null,this.m_ClipType=i.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=i.PolyFillType.pftEvenOdd,this.m_SubjFillType=i.PolyFillType.pftEvenOdd,this.m_Joins=null,this.m_GhostJoins=null,this.m_UsingPolyTree=!1,this.ReverseSolution=!1,this.StrictlySimple=!1,i.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=i.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),i.use_xyz&&(this.ZFillFunction=null)},i.Clipper.ioReverseSolution=1,i.Clipper.ioStrictlySimple=2,i.Clipper.ioPreserveCollinear=4,i.Clipper.prototype.Clear=function(){0!==this.m_edges.length&&(this.DisposeAllPolyPts(),i.ClipperBase.prototype.Clear.call(this))},i.Clipper.prototype.InsertMaxima=function(e){var t=new i.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 n=this.m_Maxima;null!==n.Next&&e>=n.Next.X;)n=n.Next;if(e===n.X)return;t.Next=n.Next,t.Prev=n,null!==n.Next&&(n.Next.Prev=t),n.Next=t}},i.Clipper.prototype.Execute=function(){var e=arguments,t=e.length,n=e[1]instanceof i.PolyTree;if(4===t&&!n){var r=e[0],a=e[1],s=e[2],o=e[3];if(this.m_ExecuteLocked)return!1;this.m_HasOpenPaths&&i.Error("Error: PolyTree struct is needed for open path clipping."),this.m_ExecuteLocked=!0,i.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&&n){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||n?2===t&&n?(r=e[0],l=e[1],this.Execute(r,l,i.PolyFillType.pftEvenOdd,i.PolyFillType.pftEvenOdd)):void 0:(r=e[0],a=e[1],this.Execute(r,a,i.PolyFillType.pftEvenOdd,i.PolyFillType.pftEvenOdd))},i.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}},i.Clipper.prototype.ExecuteInternal=function(){try{this.Reset(),this.m_SortedEdges=null,this.m_Maxima=null;var e,t,i,n={},r={};if(!this.PopScanbeam(n))return!1;for(this.InsertLocalMinimaIntoAEL(n.v);this.PopScanbeam(r)||this.LocalMinimaPending();){if(this.ProcessHorizontals(),this.m_GhostJoins.length=0,!this.ProcessIntersections(r.v))return!1;this.ProcessEdgesAtTopOfScanbeam(r.v),n.v=r.v,this.InsertLocalMinimaIntoAEL(n.v)}for(t=0,i=this.m_PolyOuts.length;t<i;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,i=this.m_PolyOuts.length;t<i;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}},i.Clipper.prototype.DisposeAllPolyPts=function(){for(var e=0,t=this.m_PolyOuts.length;e<t;++e)this.DisposeOutRec(e);i.Clear(this.m_PolyOuts)},i.Clipper.prototype.AddJoin=function(e,t,n){var r=new i.Join;r.OutPt1=e,r.OutPt2=t,r.OffPt.X=n.X,r.OffPt.Y=n.Y,i.use_xyz&&(r.OffPt.Z=n.Z),this.m_Joins.push(r)},i.Clipper.prototype.AddGhostJoin=function(e,t){var n=new i.Join;n.OutPt1=e,n.OffPt.X=t.X,n.OffPt.Y=t.Y,i.use_xyz&&(n.OffPt.Z=t.Z),this.m_GhostJoins.push(n)},i.Clipper.prototype.SetZ=function(e,t,n){if(null!==this.ZFillFunction){if(0!==e.Z||null===this.ZFillFunction)return;i.IntPoint.op_Equality(e,t.Bot)?e.Z=t.Bot.Z:i.IntPoint.op_Equality(e,t.Top)?e.Z=t.Top.Z:i.IntPoint.op_Equality(e,n.Bot)?e.Z=n.Bot.Z:i.IntPoint.op_Equality(e,n.Top)?e.Z=n.Top.Z:this.ZFillFunction(t.Bot,t.Top,n.Bot,n.Top,e)}},i.Clipper.prototype.InsertLocalMinimaIntoAEL=function(e){for(var t,n,r={};this.PopLocalMinima(e,r);){t=r.v.LeftBound,n=r.v.RightBound;var a=null;if(null===t?(this.InsertEdgeIntoAEL(n,null),this.SetWindingCount(n),this.IsContributing(n)&&(a=this.AddOutPt(n,n.Bot))):null===n?(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(n,t),this.SetWindingCount(t),n.WindCnt=t.WindCnt,n.WindCnt2=t.WindCnt2,this.IsContributing(t)&&(a=this.AddLocalMinPoly(t,n,t.Bot)),this.InsertScanbeam(t.Top.Y)),null!==n&&(i.ClipperBase.IsHorizontal(n)?(null!==n.NextInLML&&this.InsertScanbeam(n.NextInLML.Top.Y),this.AddEdgeToSEL(n)):this.InsertScanbeam(n.Top.Y)),null!==t&&null!==n){if(null!==a&&i.ClipperBase.IsHorizontal(n)&&this.m_GhostJoins.length>0&&0!==n.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,n.Bot.X,n.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&&i.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!==n){n.OutIdx>=0&&n.PrevInAEL.OutIdx>=0&&i.ClipperBase.SlopesEqual5(n.PrevInAEL.Curr,n.PrevInAEL.Top,n.Curr,n.Top,this.m_UseFullRange)&&0!==n.WindDelta&&0!==n.PrevInAEL.WindDelta&&(h=this.AddOutPt(n.PrevInAEL,n.Bot),this.AddJoin(a,h,n.Top));var c=t.NextInAEL;if(null!==c)for(;c!==n;)this.IntersectEdges(n,c,t.Curr),c=c.NextInAEL}}}},i.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}},i.Clipper.prototype.E2InsertsBeforeE1=function(e,t){return t.Curr.X===e.Curr.X?t.Top.Y>e.Top.Y?t.Top.X<i.Clipper.TopX(e,t.Top.Y):e.Top.X>i.Clipper.TopX(t,e.Top.Y):t.Curr.X<e.Curr.X},i.Clipper.prototype.IsEvenOddFillType=function(e){return e.PolyTyp===i.PolyType.ptSubject?this.m_SubjFillType===i.PolyFillType.pftEvenOdd:this.m_ClipFillType===i.PolyFillType.pftEvenOdd},i.Clipper.prototype.IsEvenOddAltFillType=function(e){return e.PolyTyp===i.PolyType.ptSubject?this.m_ClipFillType===i.PolyFillType.pftEvenOdd:this.m_SubjFillType===i.PolyFillType.pftEvenOdd},i.Clipper.prototype.IsContributing=function(e){var t,n;switch(e.PolyTyp===i.PolyType.ptSubject?(t=this.m_SubjFillType,n=this.m_ClipFillType):(t=this.m_ClipFillType,n=this.m_SubjFillType),t){case i.PolyFillType.pftEvenOdd:if(0===e.WindDelta&&1!==e.WindCnt)return!1;break;case i.PolyFillType.pftNonZero:if(1!==Math.abs(e.WindCnt))return!1;break;case i.PolyFillType.pftPositive:if(1!==e.WindCnt)return!1;break;default:if(-1!==e.WindCnt)return!1}switch(this.m_ClipType){case i.ClipType.ctIntersection:switch(n){case i.PolyFillType.pftEvenOdd:case i.PolyFillType.pftNonZero:return 0!==e.WindCnt2;case i.PolyFillType.pftPositive:return e.WindCnt2>0;default:return e.WindCnt2<0}case i.ClipType.ctUnion:switch(n){case i.PolyFillType.pftEvenOdd:case i.PolyFillType.pftNonZero:return 0===e.WindCnt2;case i.PolyFillType.pftPositive:return e.WindCnt2<=0;default:return e.WindCnt2>=0}case i.ClipType.ctDifference:if(e.PolyTyp===i.PolyType.ptSubject)switch(n){case i.PolyFillType.pftEvenOdd:case i.PolyFillType.pftNonZero:return 0===e.WindCnt2;case i.PolyFillType.pftPositive:return e.WindCnt2<=0;default:return e.WindCnt2>=0}else switch(n){case i.PolyFillType.pftEvenOdd:case i.PolyFillType.pftNonZero:return 0!==e.WindCnt2;case i.PolyFillType.pftPositive:return e.WindCnt2>0;default:return e.WindCnt2<0}case i.ClipType.ctXor:if(0!==e.WindDelta)return!0;switch(n){case i.PolyFillType.pftEvenOdd:case i.PolyFillType.pftNonZero:return 0===e.WindCnt2;case i.PolyFillType.pftPositive:return e.WindCnt2<=0;default:return e.WindCnt2>=0}}return!0},i.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 n=e.PolyTyp===i.PolyType.ptSubject?this.m_SubjFillType:this.m_ClipFillType;0===e.WindDelta?e.WindCnt=n===i.PolyFillType.pftNegative?-1:1:e.WindCnt=e.WindDelta,e.WindCnt2=0,t=this.m_ActiveEdges}else if(0===e.WindDelta&&this.m_ClipType!==i.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},i.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)},i.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},i.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},i.Clipper.prototype.SwapPositionsInSEL=function(e,t){if(!(null===e.NextInSEL&&null===e.PrevInSEL||null===t.NextInSEL&&null===t.PrevInSEL)){if(e.NextInSEL===t)null!==(i=t.NextInSEL)&&(i.PrevInSEL=e),null!==(n=e.PrevInSEL)&&(n.NextInSEL=t),t.PrevInSEL=n,t.NextInSEL=e,e.PrevInSEL=t,e.NextInSEL=i;else if(t.NextInSEL===e)null!==(i=e.NextInSEL)&&(i.PrevInSEL=t),null!==(n=t.PrevInSEL)&&(n.NextInSEL=e),e.PrevInSEL=n,e.NextInSEL=t,t.PrevInSEL=e,t.NextInSEL=i;else{var i=e.NextInSEL,n=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=i,null!==t.NextInSEL&&(t.NextInSEL.PrevInSEL=t),t.PrevInSEL=n,null!==t.PrevInSEL&&(t.PrevInSEL.NextInSEL=t)}null===e.PrevInSEL?this.m_SortedEdges=e:null===t.PrevInSEL&&(this.m_SortedEdges=t)}},i.Clipper.prototype.AddLocalMaxPoly=function(e,t,i){this.AddOutPt(e,i),0===t.WindDelta&&this.AddOutPt(t,i),e.OutIdx===t.OutIdx?(e.OutIdx=-1,t.OutIdx=-1):e.OutIdx<t.OutIdx?this.AppendPolygon(e,t):this.AppendPolygon(t,e)},i.Clipper.prototype.AddLocalMinPoly=function(e,t,n){var r,a,s;if(i.ClipperBase.IsHorizontal(t)||e.Dx>t.Dx?(r=this.AddOutPt(e,n),t.OutIdx=e.OutIdx,e.Side=i.EdgeSide.esLeft,t.Side=i.EdgeSide.esRight,s=(a=e).PrevInAEL===t?t.PrevInAEL:a.PrevInAEL):(r=this.AddOutPt(t,n),e.OutIdx=t.OutIdx,e.Side=i.EdgeSide.esRight,t.Side=i.EdgeSide.esLeft,s=(a=t).PrevInAEL===e?e.PrevInAEL:a.PrevInAEL),null!==s&&s.OutIdx>=0&&s.Top.Y<n.Y&&a.Top.Y<n.Y){var o=i.Clipper.TopX(s,n.Y),l=i.Clipper.TopX(a,n.Y);if(o===l&&0!==a.WindDelta&&0!==s.WindDelta&&i.ClipperBase.SlopesEqual5(new i.IntPoint2(o,n.Y),s.Top,new i.IntPoint2(l,n.Y),a.Top,this.m_UseFullRange)){var h=this.AddOutPt(s,n);this.AddJoin(r,h,a.Top)}}return r},i.Clipper.prototype.AddOutPt=function(e,t){if(e.OutIdx<0){(r=this.CreateOutRec()).IsOpen=0===e.WindDelta;var n=new i.OutPt;return r.Pts=n,n.Idx=r.Idx,n.Pt.X=t.X,n.Pt.Y=t.Y,i.use_xyz&&(n.Pt.Z=t.Z),n.Next=n,n.Prev=n,r.IsOpen||this.SetHoleState(e,r),e.OutIdx=r.Idx,n}var r,a=(r=this.m_PolyOuts[e.OutIdx]).Pts,s=e.Side===i.EdgeSide.esLeft;return s&&i.IntPoint.op_Equality(t,a.Pt)?a:!s&&i.IntPoint.op_Equality(t,a.Prev.Pt)?a.Prev:((n=new i.OutPt).Idx=r.Idx,n.Pt.X=t.X,n.Pt.Y=t.Y,i.use_xyz&&(n.Pt.Z=t.Z),n.Next=a,n.Prev=a.Prev,n.Prev.Next=n,a.Prev=n,s&&(r.Pts=n),n)},i.Clipper.prototype.GetLastOutPt=function(e){var t=this.m_PolyOuts[e.OutIdx];return e.Side===i.EdgeSide.esLeft?t.Pts:t.Pts.Prev},i.Clipper.prototype.SwapPoints=function(e,t){var n=new i.IntPoint1(e.Value);e.Value.X=t.Value.X,e.Value.Y=t.Value.Y,i.use_xyz&&(e.Value.Z=t.Value.Z),t.Value.X=n.X,t.Value.Y=n.Y,i.use_xyz&&(t.Value.Z=n.Z)},i.Clipper.prototype.HorzSegmentsOverlap=function(e,t,i,n){var r;return e>t&&(r=e,e=t,t=r),i>n&&(r=i,i=n,n=r),e<n&&i<t},i.Clipper.prototype.SetHoleState=function(e,t){for(var i=e.PrevInAEL,n=null;null!==i;)i.OutIdx>=0&&0!==i.WindDelta&&(null===n?n=i:n.OutIdx===i.OutIdx&&(n=null)),i=i.PrevInAEL;null===n?(t.FirstLeft=null,t.IsHole=!1):(t.FirstLeft=this.m_PolyOuts[n.OutIdx],t.IsHole=!t.FirstLeft.IsHole)},i.Clipper.prototype.GetDx=function(e,t){return e.Y===t.Y?i.ClipperBase.horizontal:(t.X-e.X)/(t.Y-e.Y)},i.Clipper.prototype.FirstIsBottomPt=function(e,t){for(var n=e.Prev;i.IntPoint.op_Equality(n.Pt,e.Pt)&&n!==e;)n=n.Prev;var r=Math.abs(this.GetDx(e.Pt,n.Pt));for(n=e.Next;i.IntPoint.op_Equality(n.Pt,e.Pt)&&n!==e;)n=n.Next;var a=Math.abs(this.GetDx(e.Pt,n.Pt));for(n=t.Prev;i.IntPoint.op_Equality(n.Pt,t.Pt)&&n!==t;)n=n.Prev;var s=Math.abs(this.GetDx(t.Pt,n.Pt));for(n=t.Next;i.IntPoint.op_Equality(n.Pt,t.Pt)&&n!==t;)n=n.Next;var o=Math.abs(this.GetDx(t.Pt,n.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},i.Clipper.prototype.GetBottomPt=function(e){for(var t=null,n=e.Next;n!==e;)n.Pt.Y>e.Pt.Y?(e=n,t=null):n.Pt.Y===e.Pt.Y&&n.Pt.X<=e.Pt.X&&(n.Pt.X<e.Pt.X?(t=null,e=n):n.Next!==e&&n.Prev!==e&&(t=n)),n=n.Next;if(null!==t)for(;t!==n;)for(this.FirstIsBottomPt(n,t)||(e=t),t=t.Next;i.IntPoint.op_Inequality(t.Pt,e.Pt);)t=t.Next;return e},i.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 i=e.BottomPt,n=t.BottomPt;return i.Pt.Y>n.Pt.Y?e:i.Pt.Y<n.Pt.Y?t:i.Pt.X<n.Pt.X?e:i.Pt.X>n.Pt.X||i.Next===i?t:n.Next===n||this.FirstIsBottomPt(i,n)?e:t},i.Clipper.prototype.OutRec1RightOfOutRec2=function(e,t){do{if((e=e.FirstLeft)===t)return!0}while(null!==e);return!1},i.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},i.Clipper.prototype.AppendPolygon=function(e,t){var n,r=this.m_PolyOuts[e.OutIdx],a=this.m_PolyOuts[t.OutIdx];n=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===i.EdgeSide.esLeft?t.Side===i.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===i.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,n===a&&(a.FirstLeft!==r&&(r.FirstLeft=a.FirstLeft),r.IsHole=a.IsHole),a.Pts=null,a.BottomPt=null,a.FirstLeft=r;var c=e.OutIdx,u=t.OutIdx;e.OutIdx=-1,t.OutIdx=-1;for(var d=this.m_ActiveEdges;null!==d;){if(d.OutIdx===u){d.OutIdx=c,d.Side=e.Side;break}d=d.NextInAEL}a.Idx=r.Idx},i.Clipper.prototype.ReversePolyPtLinks=function(e){if(null!==e){var t,i;t=e;do{i=t.Next,t.Next=t.Prev,t.Prev=i,t=i}while(t!==e)}},i.Clipper.SwapSides=function(e,t){var i=e.Side;e.Side=t.Side,t.Side=i},i.Clipper.SwapPolyIndexes=function(e,t){var i=e.OutIdx;e.OutIdx=t.OutIdx,t.OutIdx=i},i.Clipper.prototype.IntersectEdges=function(e,t,n){var r=e.OutIdx>=0,a=t.OutIdx>=0;if(i.use_xyz&&this.SetZ(n,e,t),!i.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,c,u,d;switch(e.PolyTyp===i.PolyType.ptSubject?(o=this.m_SubjFillType,h=this.m_ClipFillType):(o=this.m_ClipFillType,h=this.m_SubjFillType),t.PolyTyp===i.PolyType.ptSubject?(l=this.m_SubjFillType,c=this.m_ClipFillType):(l=this.m_ClipFillType,c=this.m_SubjFillType),o){case i.PolyFillType.pftPositive:u=e.WindCnt;break;case i.PolyFillType.pftNegative:u=-e.WindCnt;break;default:u=Math.abs(e.WindCnt)}switch(l){case i.PolyFillType.pftPositive:d=t.WindCnt;break;case i.PolyFillType.pftNegative:d=-t.WindCnt;break;default:d=Math.abs(t.WindCnt)}if(r&&a)0!==u&&1!==u||0!==d&&1!==d||e.PolyTyp!==t.PolyTyp&&this.m_ClipType!==i.ClipType.ctXor?this.AddLocalMaxPoly(e,t,n):(this.AddOutPt(e,n),this.AddOutPt(t,n),i.Clipper.SwapSides(e,t),i.Clipper.SwapPolyIndexes(e,t));else if(r)(0===d||1===d)&&(this.AddOutPt(e,n),i.Clipper.SwapSides(e,t),i.Clipper.SwapPolyIndexes(e,t));else if(a)(0===u||1===u)&&(this.AddOutPt(t,n),i.Clipper.SwapSides(e,t),i.Clipper.SwapPolyIndexes(e,t));else if(!(0!==u&&1!==u||0!==d&&1!==d)){var p,f;switch(h){case i.PolyFillType.pftPositive:p=e.WindCnt2;break;case i.PolyFillType.pftNegative:p=-e.WindCnt2;break;default:p=Math.abs(e.WindCnt2)}switch(c){case i.PolyFillType.pftPositive:f=t.WindCnt2;break;case i.PolyFillType.pftNegative:f=-t.WindCnt2;break;default:f=Math.abs(t.WindCnt2)}if(e.PolyTyp!==t.PolyTyp)this.AddLocalMinPoly(e,t,n);else if(1===u&&1===d)switch(this.m_ClipType){case i.ClipType.ctIntersection:p>0&&f>0&&this.AddLocalMinPoly(e,t,n);break;case i.ClipType.ctUnion:p<=0&&f<=0&&this.AddLocalMinPoly(e,t,n);break;case i.ClipType.ctDifference:(e.PolyTyp===i.PolyType.ptClip&&p>0&&f>0||e.PolyTyp===i.PolyType.ptSubject&&p<=0&&f<=0)&&this.AddLocalMinPoly(e,t,n);break;case i.ClipType.ctXor:this.AddLocalMinPoly(e,t,n)}else i.Clipper.SwapSides(e,t)}}else{if(0===e.WindDelta&&0===t.WindDelta)return;e.PolyTyp===t.PolyTyp&&e.WindDelta!==t.WindDelta&&this.m_ClipType===i.ClipType.ctUnion?0===e.WindDelta?a&&(this.AddOutPt(e,n),r&&(e.OutIdx=-1)):r&&(this.AddOutPt(t,n),a&&(t.OutIdx=-1)):e.PolyTyp!==t.PolyTyp&&(0!==e.WindDelta||1!==Math.abs(t.WindCnt)||this.m_ClipType===i.ClipType.ctUnion&&0!==t.WindCnt2?0===t.WindDelta&&1===Math.abs(e.WindCnt)&&(this.m_ClipType!==i.ClipType.ctUnion||0===e.WindCnt2)&&(this.AddOutPt(t,n),a&&(t.OutIdx=-1)):(this.AddOutPt(e,n),r&&(e.OutIdx=-1)))}},i.Clipper.prototype.DeleteFromSEL=function(e){var t=e.PrevInSEL,i=e.NextInSEL;null===t&&null===i&&e!==this.m_SortedEdges||(null!==t?t.NextInSEL=i:this.m_SortedEdges=i,null!==i&&(i.PrevInSEL=t),e.NextInSEL=null,e.PrevInSEL=null)},i.Clipper.prototype.ProcessHorizontals=function(){for(var e={};this.PopEdgeFromSEL(e);)this.ProcessHorizontal(e.v)},i.Clipper.prototype.GetHorzDirection=function(e,t){e.Bot.X<e.Top.X?(t.Left=e.Bot.X,t.Right=e.Top.X,t.Dir=i.Direction.dLeftToRight):(t.Left=e.Top.X,t.Right=e.Bot.X,t.Dir=i.Direction.dRightToLeft)},i.Clipper.prototype.ProcessHorizontal=function(e){var t={Dir:null,Left:null,Right:null};this.GetHorzDirection(e,t);for(var n=t.Dir,r=t.Left,a=t.Right,s=0===e.WindDelta,o=e,l=null;null!==o.NextInLML&&i.ClipperBase.IsHorizontal(o.NextInLML);)o=o.NextInLML;null===o.NextInLML&&(l=this.GetMaximaPair(o));var h=this.m_Maxima;if(null!==h)if(n===i.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 c=null;;){for(var u=e===o,d=this.GetNextInAEL(e,n);null!==d;){if(null!==h)if(n===i.Direction.dLeftToRight)for(;null!==h&&h.X<d.Curr.X;)e.OutIdx>=0&&!s&&this.AddOutPt(e,new i.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 i.IntPoint2(h.X,e.Bot.Y)),h=h.Prev;if(n===i.Direction.dLeftToRight&&d.Curr.X>a||n===i.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){i.use_xyz&&(n===i.Direction.dLeftToRight?this.SetZ(d.Curr,e,d):this.SetZ(d.Curr,d,e)),c=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,c,p.Top)}p=p.NextInSEL}this.AddGhostJoin(c,e.Bot)}if(d===l&&u)return e.OutIdx>=0&&this.AddLocalMaxPoly(e,l,e.Top),this.DeleteFromAEL(e),void this.DeleteFromAEL(l);if(n===i.Direction.dLeftToRight){var m=new i.IntPoint2(d.Curr.X,e.Curr.Y);this.IntersectEdges(e,d,m)}else m=new i.IntPoint2(d.Curr.X,e.Curr.Y),this.IntersectEdges(d,e,m);var g=this.GetNextInAEL(d,n);this.SwapPositionsInAEL(e,d),d=g}if(null===e.NextInLML||!i.ClipperBase.IsHorizontal(e.NextInLML))break;(e=this.UpdateEdgeIntoAEL(e)).OutIdx>=0&&this.AddOutPt(e,e.Bot),t={Dir:n,Left:r,Right:a},this.GetHorzDirection(e,t),n=t.Dir,r=t.Left,a=t.Right}if(e.OutIdx>=0&&null===c){for(c=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,c,p.Top)),p=p.NextInSEL;this.AddGhostJoin(c,e.Top)}if(null!==e.NextInLML)if(e.OutIdx>=0){if(c=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&&i.ClipperBase.SlopesEqual3(e,v,this.m_UseFullRange)?(f=this.AddOutPt(v,e.Bot),this.AddJoin(c,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&&i.ClipperBase.SlopesEqual3(e,g,this.m_UseFullRange)&&(f=this.AddOutPt(g,e.Bot),this.AddJoin(c,f,e.Top))}else e=this.UpdateEdgeIntoAEL(e);else e.OutIdx>=0&&this.AddOutPt(e,e.Top),this.DeleteFromAEL(e)},i.Clipper.prototype.GetNextInAEL=function(e,t){return t===i.Direction.dLeftToRight?e.NextInAEL:e.PrevInAEL},i.Clipper.prototype.IsMinima=function(e){return null!==e&&e.Prev.NextInLML!==e&&e.Next.NextInLML!==e},i.Clipper.prototype.IsMaxima=function(e,t){return null!==e&&e.Top.Y===t&&null===e.NextInLML},i.Clipper.prototype.IsIntermediate=function(e,t){return e.Top.Y===t&&null!==e.NextInLML},i.Clipper.prototype.GetMaximaPair=function(e){return i.IntPoint.op_Equality(e.Next.Top,e.Top)&&null===e.Next.NextInLML?e.Next:i.IntPoint.op_Equality(e.Prev.Top,e.Top)&&null===e.Prev.NextInLML?e.Prev:null},i.Clipper.prototype.GetMaximaPairEx=function(e){var t=this.GetMaximaPair(e);return null===t||t.OutIdx===i.ClipperBase.Skip||t.NextInAEL===t.PrevInAEL&&!i.ClipperBase.IsHorizontal(t)?null:t},i.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,i.Error("ProcessIntersections error")}return this.m_SortedEdges=null,!0},i.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=i.Clipper.TopX(t,e),t=t.NextInAEL;for(var n=!0;n&&null!==this.m_SortedEdges;){for(n=!1,t=this.m_SortedEdges;null!==t.NextInSEL;){var r=t.NextInSEL,a=new i.IntPoint0;if(t.Curr.X>r.Curr.X){this.IntersectPoint(t,r,a),a.Y<e&&(a=new i.IntPoint2(i.Clipper.TopX(t,e),e));var s=new i.IntersectNode;s.Edge1=t,s.Edge2=r,s.Pt.X=a.X,s.Pt.Y=a.Y,i.use_xyz&&(s.Pt.Z=a.Z),this.m_IntersectList.push(s),this.SwapPositionsInSEL(t,r),n=!0}else t=r}if(null===t.PrevInSEL)break;t.PrevInSEL.NextInSEL=null}this.m_SortedEdges=null}},i.Clipper.prototype.EdgesAdjacent=function(e){return e.Edge1.NextInSEL===e.Edge2||e.Edge1.PrevInSEL===e.Edge2},i.Clipper.IntersectNodeSort=function(e,t){return t.Pt.Y-e.Pt.Y},i.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 i=t+1;i<e&&!this.EdgesAdjacent(this.m_IntersectList[i]);)i++;if(i===e)return!1;var n=this.m_IntersectList[t];this.m_IntersectList[t]=this.m_IntersectList[i],this.m_IntersectList[i]=n}this.SwapPositionsInSEL(this.m_IntersectList[t].Edge1,this.m_IntersectList[t].Edge2)}return!0},i.Clipper.prototype.ProcessIntersectList=function(){for(var e=0,t=this.m_IntersectList.length;e<t;e++){var i=this.m_IntersectList[e];this.IntersectEdges(i.Edge1,i.Edge2,i.Pt),this.SwapPositionsInAEL(i.Edge1,i.Edge2)}this.m_IntersectList.length=0},s.msie?i.Clipper.Round=function(e){return e<0?Math.ceil(e-.5):Math.round(e)}:s.chromium?i.Clipper.Round=function(e){return e<0?-Math.round(Math.abs(e)):Math.round(e)}:s.safari?i.Clipper.Round=function(e){return e<0?(e-=.5)<-2147483648?Math.ceil(e):0|e:(e+=.5)>2147483647?Math.floor(e):0|e}:i.Clipper.Round=function(e){return e<0?Math.ceil(e-.5):Math.floor(e+.5)},i.Clipper.TopX=function(e,t){return t===e.Top.Y?e.Top.X:e.Bot.X+i.Clipper.Round(e.Dx*(t-e.Bot.Y))},i.Clipper.prototype.IntersectPoint=function(e,t,n){var r,a;if(n.X=0,n.Y=0,e.Dx===t.Dx)return n.Y=e.Curr.Y,void(n.X=i.Clipper.TopX(e,n.Y));if(0===e.Delta.X)n.X=e.Bot.X,i.ClipperBase.IsHorizontal(t)?n.Y=t.Bot.Y:(a=t.Bot.Y-t.Bot.X/t.Dx,n.Y=i.Clipper.Round(n.X/t.Dx+a));else if(0===t.Delta.X)n.X=t.Bot.X,i.ClipperBase.IsHorizontal(e)?n.Y=e.Bot.Y:(r=e.Bot.Y-e.Bot.X/e.Dx,n.Y=i.Clipper.Round(n.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);n.Y=i.Clipper.Round(s),Math.abs(e.Dx)<Math.abs(t.Dx)?n.X=i.Clipper.Round(e.Dx*s+r):n.X=i.Clipper.Round(t.Dx*s+a)}if(n.Y<e.Top.Y||n.Y<t.Top.Y){if(e.Top.Y>t.Top.Y)return n.Y=e.Top.Y,n.X=i.Clipper.TopX(t,e.Top.Y),n.X<e.Top.X;n.Y=t.Top.Y,Math.abs(e.Dx)<Math.abs(t.Dx)?n.X=i.Clipper.TopX(e,n.Y):n.X=i.Clipper.TopX(t,n.Y)}n.Y>e.Curr.Y&&(n.Y=e.Curr.Y,Math.abs(e.Dx)>Math.abs(t.Dx)?n.X=i.Clipper.TopX(t,n.Y):n.X=i.Clipper.TopX(e,n.Y))},i.Clipper.prototype.ProcessEdgesAtTopOfScanbeam=function(e){for(var t=this.m_ActiveEdges;null!==t;){var n=this.IsMaxima(t,e);if(n){var r=this.GetMaximaPairEx(t);n=null===r||!i.ClipperBase.IsHorizontal(r)}if(n){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)&&i.ClipperBase.IsHorizontal(t.NextInLML)?((t=this.UpdateEdgeIntoAEL(t)).OutIdx>=0&&this.AddOutPt(t,t.Bot),this.AddEdgeToSEL(t)):(t.Curr.X=i.Clipper.TopX(t,e),t.Curr.Y=e),i.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 i.IntPoint1(t.Curr);i.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&&i.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&&i.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}},i.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 n=e.NextInAEL;null!==n&&n!==t;)this.IntersectEdges(e,n,e.Top),this.SwapPositionsInAEL(e,n),n=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)):i.use_lines&&0===e.WindDelta?(e.OutIdx>=0&&(this.AddOutPt(e,e.Top),e.OutIdx=i.ClipperBase.Unassigned),this.DeleteFromAEL(e),t.OutIdx>=0&&(this.AddOutPt(t,e.Top),t.OutIdx=i.ClipperBase.Unassigned),this.DeleteFromAEL(t)):i.Error("DoMaxima error")},i.Clipper.ReversePaths=function(e){for(var t=0,i=e.length;t<i;t++)e[t].reverse()},i.Clipper.Orientation=function(e){return i.Clipper.Area(e)>=0},i.Clipper.prototype.PointCount=function(e){if(null===e)return 0;var t=0,i=e;do{t++,i=i.Next}while(i!==e);return t},i.Clipper.prototype.BuildResult=function(e){i.Clear(e);for(var t=0,n=this.m_PolyOuts.length;t<n;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)}}}},i.Clipper.prototype.BuildResult2=function(e){e.Clear();for(var t=0,n=this.m_PolyOuts.length;t<n;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 i.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,n=this.m_PolyOuts.length;t<n;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))},i.Clipper.prototype.FixupOutPolyline=function(e){for(var t=e.Pts,n=t.Prev;t!==n;)if(t=t.Next,i.IntPoint.op_Equality(t.Pt,t.Prev.Pt)){t===n&&(n=t.Prev);var r=t.Prev;r.Next=t.Next,t.Next.Prev=r,t=r}t===t.Prev&&(e.Pts=null)},i.Clipper.prototype.FixupOutPolygon=function(e){var t=null;e.BottomPt=null;for(var n=e.Pts,r=this.PreserveCollinear||this.StrictlySimple;;){if(n.Prev===n||n.Prev===n.Next)return void(e.Pts=null);if(i.IntPoint.op_Equality(n.Pt,n.Next.Pt)||i.IntPoint.op_Equality(n.Pt,n.Prev.Pt)||i.ClipperBase.SlopesEqual4(n.Prev.Pt,n.Pt,n.Next.Pt,this.m_UseFullRange)&&(!r||!this.Pt2IsBetweenPt1AndPt3(n.Prev.Pt,n.Pt,n.Next.Pt)))t=null,n.Prev.Next=n.Next,n.Next.Prev=n.Prev,n=n.Prev;else{if(n===t)break;null===t&&(t=n),n=n.Next}}e.Pts=n},i.Clipper.prototype.DupOutPt=function(e,t){var n=new i.OutPt;return n.Pt.X=e.Pt.X,n.Pt.Y=e.Pt.Y,i.use_xyz&&(n.Pt.Z=e.Pt.Z),n.Idx=e.Idx,t?(n.Next=e.Next,n.Prev=e,e.Next.Prev=n,e.Next=n):(n.Prev=e.Prev,n.Next=e,e.Prev.Next=n,e.Prev=n),n},i.Clipper.prototype.GetOverlap=function(e,t,i,n,r){return e<t?i<n?(r.Left=Math.max(e,i),r.Right=Math.min(t,n)):(r.Left=Math.max(e,n),r.Right=Math.min(t,i)):i<n?(r.Left=Math.max(t,i),r.Right=Math.min(e,n)):(r.Left=Math.max(t,n),r.Right=Math.min(e,i)),r.Left<r.Right},i.Clipper.prototype.JoinHorz=function(e,t,n,r,a,s){var o=e.Pt.X>t.Pt.X?i.Direction.dRightToLeft:i.Direction.dLeftToRight,l=n.Pt.X>r.Pt.X?i.Direction.dRightToLeft:i.Direction.dLeftToRight;if(o===l)return!1;if(o===i.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),i.IntPoint.op_Inequality(t.Pt,a)&&((e=t).Pt.X=a.X,e.Pt.Y=a.Y,i.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),i.IntPoint.op_Inequality(t.Pt,a)&&((e=t).Pt.X=a.X,e.Pt.Y=a.Y,i.use_xyz&&(e.Pt.Z=a.Z),t=this.DupOutPt(e,s))}if(l===i.Direction.dLeftToRight){for(;n.Next.Pt.X<=a.X&&n.Next.Pt.X>=n.Pt.X&&n.Next.Pt.Y===a.Y;)n=n.Next;s&&n.Pt.X!==a.X&&(n=n.Next),r=this.DupOutPt(n,!s),i.IntPoint.op_Inequality(r.Pt,a)&&((n=r).Pt.X=a.X,n.Pt.Y=a.Y,i.use_xyz&&(n.Pt.Z=a.Z),r=this.DupOutPt(n,!s))}else{for(;n.Next.Pt.X>=a.X&&n.Next.Pt.X<=n.Pt.X&&n.Next.Pt.Y===a.Y;)n=n.Next;!s&&n.Pt.X!==a.X&&(n=n.Next),r=this.DupOutPt(n,s),i.IntPoint.op_Inequality(r.Pt,a)&&((n=r).Pt.X=a.X,n.Pt.Y=a.Y,i.use_xyz&&(n.Pt.Z=a.Z),r=this.DupOutPt(n,s))}return o===i.Direction.dLeftToRight===s?(e.Prev=n,n.Next=e,t.Next=r,r.Prev=t):(e.Next=n,n.Prev=e,t.Prev=r,r.Next=t),!0},i.Clipper.prototype.JoinPoints=function(e,t,n){var r=e.OutPt1,a=new i.OutPt,s=e.OutPt2,o=new i.OutPt,l=e.OutPt1.Pt.Y===e.OffPt.Y;if(l&&i.IntPoint.op_Equality(e.OffPt,e.OutPt1.Pt)&&i.IntPoint.op_Equality(e.OffPt,e.OutPt2.Pt)){if(t!==n)return!1;for(a=e.OutPt1.Next;a!==r&&i.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&&i.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 c={Left:null,Right:null};if(!this.GetOverlap(r.Pt.X,a.Pt.X,s.Pt.X,o.Pt.X,c))return!1;var u,d=c.Left,p=c.Right,f=new i.IntPoint0;return r.Pt.X>=d&&r.Pt.X<=p?(f.X=r.Pt.X,f.Y=r.Pt.Y,i.use_xyz&&(f.Z=r.Pt.Z),u=r.Pt.X>a.Pt.X):s.Pt.X>=d&&s.Pt.X<=p?(f.X=s.Pt.X,f.Y=s.Pt.Y,i.use_xyz&&(f.Z=s.Pt.Z),u=s.Pt.X>o.Pt.X):a.Pt.X>=d&&a.Pt.X<=p?(f.X=a.Pt.X,f.Y=a.Pt.Y,i.use_xyz&&(f.Z=a.Pt.Z),u=a.Pt.X>r.Pt.X):(f.X=o.Pt.X,f.Y=o.Pt.Y,i.use_xyz&&(f.Z=o.Pt.Z),u=o.Pt.X>s.Pt.X),e.OutPt1=r,e.OutPt2=s,this.JoinHorz(r,a,s,o,f,u)}for(a=r.Next;i.IntPoint.op_Equality(a.Pt,r.Pt)&&a!==r;)a=a.Next;var m=a.Pt.Y>r.Pt.Y||!i.ClipperBase.SlopesEqual4(r.Pt,a.Pt,e.OffPt,this.m_UseFullRange);if(m){for(a=r.Prev;i.IntPoint.op_Equality(a.Pt,r.Pt)&&a!==r;)a=a.Prev;if(a.Pt.Y>r.Pt.Y||!i.ClipperBase.SlopesEqual4(r.Pt,a.Pt,e.OffPt,this.m_UseFullRange))return!1}for(o=s.Next;i.IntPoint.op_Equality(o.Pt,s.Pt)&&o!==s;)o=o.Next;var g=o.Pt.Y>s.Pt.Y||!i.ClipperBase.SlopesEqual4(s.Pt,o.Pt,e.OffPt,this.m_UseFullRange);if(g){for(o=s.Prev;i.IntPoint.op_Equality(o.Pt,s.Pt)&&o!==s;)o=o.Prev;if(o.Pt.Y>s.Pt.Y||!i.ClipperBase.SlopesEqual4(s.Pt,o.Pt,e.OffPt,this.m_UseFullRange))return!1}return a!==r&&o!==s&&a!==o&&(t!==n||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))},i.Clipper.GetBounds=function(e){for(var t=0,n=e.length;t<n&&0===e[t].length;)t++;if(t===n)return new i.IntRect(0,0,0,0);var r=new i.IntRect;for(r.left=e[t][0].X,r.right=r.left,r.top=e[t][0].Y,r.bottom=r.top;t<n;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},i.Clipper.prototype.GetBounds2=function(e){var t=e,n=new i.IntRect;for(n.left=e.Pt.X,n.right=e.Pt.X,n.top=e.Pt.Y,n.bottom=e.Pt.Y,e=e.Next;e!==t;)e.Pt.X<n.left&&(n.left=e.Pt.X),e.Pt.X>n.right&&(n.right=e.Pt.X),e.Pt.Y<n.top&&(n.top=e.Pt.Y),e.Pt.Y>n.bottom&&(n.bottom=e.Pt.Y),e=e.Next;return n},i.Clipper.PointInPolygon=function(e,t){var i=0,n=t.length;if(n<3)return 0;for(var r=t[0],a=1;a<=n;++a){var s=a===n?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)i=1-i;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&&(i=1-i)}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&&(i=1-i)}r=s}return i},i.Clipper.prototype.PointInPolygon=function(e,t){var i=0,n=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)i=1-i;else{if(0===(c=(s-r)*(h-a)-(l-r)*(o-a)))return-1;c>0==h>o&&(i=1-i)}else if(l>r){var c;if(0===(c=(s-r)*(h-a)-(l-r)*(o-a)))return-1;c>0==h>o&&(i=1-i)}s=l,o=h}while(n!==t);return i},i.Clipper.prototype.Poly2ContainsPoly1=function(e,t){var i=e;do{var n=this.PointInPolygon(i.Pt,t);if(n>=0)return n>0;i=i.Next}while(i!==e);return!0},i.Clipper.prototype.FixupFirstLefts1=function(e,t){for(var n,r,a=0,s=this.m_PolyOuts.length;a<s;a++)n=this.m_PolyOuts[a],r=i.Clipper.ParseFirstLeft(n.FirstLeft),null!==n.Pts&&r===e&&this.Poly2ContainsPoly1(n.Pts,t.Pts)&&(n.FirstLeft=t)},i.Clipper.prototype.FixupFirstLefts2=function(e,t){for(var n,r,a=t.FirstLeft,s=0,o=this.m_PolyOuts.length;s<o;s++)null!==(n=this.m_PolyOuts[s]).Pts&&n!==t&&n!==e&&((r=i.Clipper.ParseFirstLeft(n.FirstLeft))===a||r===e||r===t)&&(this.Poly2ContainsPoly1(n.Pts,e.Pts)?n.FirstLeft=e:this.Poly2ContainsPoly1(n.Pts,t.Pts)?n.FirstLeft=t:(n.FirstLeft===e||n.FirstLeft===t)&&(n.FirstLeft=a))},i.Clipper.prototype.FixupFirstLefts3=function(e,t){for(var n,r,a=0,s=this.m_PolyOuts.length;a<s;a++)n=this.m_PolyOuts[a],r=i.Clipper.ParseFirstLeft(n.FirstLeft),null!==n.Pts&&r===e&&(n.FirstLeft=t)},i.Clipper.ParseFirstLeft=function(e){for(;null!==e&&null===e.Pts;)e=e.FirstLeft;return e},i.Clipper.prototype.JoinCommonEdges=function(){for(var e=0,t=this.m_Joins.length;e<t;e++){var i,n=this.m_Joins[e],r=this.GetOutRec(n.OutPt1.Idx),a=this.GetOutRec(n.OutPt2.Idx);null===r.Pts||null===a.Pts||r.IsOpen||a.IsOpen||(i=r===a?r:this.OutRec1RightOfOutRec2(r,a)?a:this.OutRec1RightOfOutRec2(a,r)?r:this.GetLowermostRec(r,a),this.JoinPoints(n,r,a)&&(r===a?(r.Pts=n.OutPt1,r.BottomPt=null,(a=this.CreateOutRec()).Pts=n.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=i.IsHole,i===a&&(r.FirstLeft=a.FirstLeft),a.FirstLeft=r,this.m_UsingPolyTree&&this.FixupFirstLefts3(a,r))))}},i.Clipper.prototype.UpdateOutPtIdxs=function(e){var t=e.Pts;do{t.Idx=e.Idx,t=t.Prev}while(t!==e.Pts)},i.Clipper.prototype.DoSimplePolygons=function(){for(var e=0;e<this.m_PolyOuts.length;){var t=this.m_PolyOuts[e++],n=t.Pts;if(null!==n&&!t.IsOpen)do{for(var r=n.Next;r!==t.Pts;){if(i.IntPoint.op_Equality(n.Pt,r.Pt)&&r.Next!==n&&r.Prev!==n){var a=n.Prev,s=r.Prev;n.Prev=s,s.Next=n,r.Prev=a,a.Next=r,t.Pts=n;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=n}r=r.Next}n=n.Next}while(n!==t.Pts)}},i.Clipper.Area=function(e){if(!Array.isArray(e))return 0;var t=e.length;if(t<3)return 0;for(var i=0,n=0,r=t-1;n<t;++n)i+=(e[r].X+e[n].X)*(e[r].Y-e[n].Y),r=n;return.5*-i},i.Clipper.prototype.Area=function(e){var t=e;if(null===e)return 0;var i=0;do{i+=(e.Prev.Pt.X+e.Pt.X)*(e.Prev.Pt.Y-e.Pt.Y),e=e.Next}while(e!==t);return.5*i},i.Clipper.prototype.Area$1=function(e){return this.Area(e.Pts)},i.Clipper.SimplifyPolygon=function(e,t){var n=new Array,r=new i.Clipper(0);return r.StrictlySimple=!0,r.AddPath(e,i.PolyType.ptSubject,!0),r.Execute(i.ClipType.ctUnion,n,t,t),n},i.Clipper.SimplifyPolygons=function(e,t){void 0===t&&(t=i.PolyFillType.pftEvenOdd);var n=new Array,r=new i.Clipper(0);return r.StrictlySimple=!0,r.AddPaths(e,i.PolyType.ptSubject,!0),r.Execute(i.ClipType.ctUnion,n,t,t),n},i.Clipper.DistanceSqrd=function(e,t){var i=e.X-t.X,n=e.Y-t.Y;return i*i+n*n},i.Clipper.DistanceFromLineSqrd=function(e,t,i){var n=t.Y-i.Y,r=i.X-t.X,a=n*t.X+r*t.Y;return(a=n*e.X+r*e.Y-a)*a/(n*n+r*r)},i.Clipper.SlopesNearCollinear=function(e,t,n,r){return Math.abs(e.X-t.X)>Math.abs(e.Y-t.Y)?e.X>t.X==e.X<n.X?i.Clipper.DistanceFromLineSqrd(e,t,n)<r:t.X>e.X==t.X<n.X?i.Clipper.DistanceFromLineSqrd(t,e,n)<r:i.Clipper.DistanceFromLineSqrd(n,e,t)<r:e.Y>t.Y==e.Y<n.Y?i.Clipper.DistanceFromLineSqrd(e,t,n)<r:t.Y>e.Y==t.Y<n.Y?i.Clipper.DistanceFromLineSqrd(t,e,n)<r:i.Clipper.DistanceFromLineSqrd(n,e,t)<r},i.Clipper.PointsAreClose=function(e,t,i){var n=e.X-t.X,r=e.Y-t.Y;return n*n+r*r<=i},i.Clipper.ExcludeOp=function(e){var t=e.Prev;return t.Next=e.Next,e.Next.Prev=t,t.Idx=0,t},i.Clipper.CleanPolygon=function(e,t){void 0===t&&(t=1.415);var n=e.length;if(0===n)return new Array;for(var r=new Array(n),a=0;a<n;++a)r[a]=new i.OutPt;for(a=0;a<n;++a)r[a].Pt=e[a],r[a].Next=r[(a+1)%n],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;)i.Clipper.PointsAreClose(o.Pt,o.Prev.Pt,s)?(o=i.Clipper.ExcludeOp(o),n--):i.Clipper.PointsAreClose(o.Prev.Pt,o.Next.Pt,s)?(i.Clipper.ExcludeOp(o.Next),o=i.Clipper.ExcludeOp(o),n-=2):i.Clipper.SlopesNearCollinear(o.Prev.Pt,o.Pt,o.Next.Pt,s)?(o=i.Clipper.ExcludeOp(o),n--):(o.Idx=1,o=o.Next);n<3&&(n=0);var l=new Array(n);for(a=0;a<n;++a)l[a]=new i.IntPoint1(o.Pt),o=o.Next;return r=null,l},i.Clipper.CleanPolygons=function(e,t){for(var n=new Array(e.length),r=0,a=e.length;r<a;r++)n[r]=i.Clipper.CleanPolygon(e[r],t);return n},i.Clipper.Minkowski=function(e,t,n,r){var a=r?1:0,s=e.length,o=t.length,l=new Array;if(n)for(var h=0;h<o;h++){for(var c=new Array(s),u=0,d=e.length,p=e[u];u<d;p=e[++u])c[u]=new i.IntPoint2(t[h].X+p.X,t[h].Y+p.Y);l.push(c)}else for(h=0;h<o;h++){for(c=new Array(s),u=0,d=e.length,p=e[u];u<d;p=e[++u])c[u]=new i.IntPoint2(t[h].X-p.X,t[h].Y-p.Y);l.push(c)}var f=new Array;for(h=0;h<o-1+a;h++)for(u=0;u<s;u++){var m=new Array;m.push(l[h%o][u%s]),m.push(l[(h+1)%o][u%s]),m.push(l[(h+1)%o][(u+1)%s]),m.push(l[h%o][(u+1)%s]),i.Clipper.Orientation(m)||m.reverse(),f.push(m)}return f},i.Clipper.MinkowskiSum=function(e,t,n){if(t[0]instanceof Array){for(var r=t,a=new i.Paths,s=new i.Clipper,o=0;o<r.length;++o){var l=i.Clipper.Minkowski(e,r[o],!0,n);if(s.AddPaths(l,i.PolyType.ptSubject,!0),n){var h=i.Clipper.TranslatePath(r[o],e[0]);s.AddPath(h,i.PolyType.ptClip,!0)}}return s.Execute(i.ClipType.ctUnion,a,i.PolyFillType.pftNonZero,i.PolyFillType.pftNonZero),a}return h=t,r=i.Clipper.Minkowski(e,h,!0,n),(s=new i.Clipper).AddPaths(r,i.PolyType.ptSubject,!0),s.Execute(i.ClipType.ctUnion,r,i.PolyFillType.pftNonZero,i.PolyFillType.pftNonZero),r},i.Clipper.TranslatePath=function(e,t){for(var n=new i.Path,r=0;r<e.length;r++)n.push(new i.IntPoint2(e[r].X+t.X,e[r].Y+t.Y));return n},i.Clipper.MinkowskiDiff=function(e,t){var n=i.Clipper.Minkowski(e,t,!1,!0),r=new i.Clipper;return r.AddPaths(n,i.PolyType.ptSubject,!0),r.Execute(i.ClipType.ctUnion,n,i.PolyFillType.pftNonZero,i.PolyFillType.pftNonZero),n},i.Clipper.PolyTreeToPaths=function(e){var t=new Array;return i.Clipper.AddPolyNodeToPaths(e,i.Clipper.NodeType.ntAny,t),t},i.Clipper.AddPolyNodeToPaths=function(e,t,n){var r=!0;switch(t){case i.Clipper.NodeType.ntOpen:return;case i.Clipper.NodeType.ntClosed:r=!e.IsOpen}e.m_polygon.length>0&&r&&n.push(e.m_polygon);for(var a=0,s=e.Childs(),o=s.length,l=s[a];a<o;l=s[++a])i.Clipper.AddPolyNodeToPaths(l,t,n)},i.Clipper.OpenPathsFromPolyTree=function(e){for(var t=new i.Paths,n=0,r=e.ChildCount();n<r;n++)e.Childs()[n].IsOpen&&t.push(e.Childs()[n].m_polygon);return t},i.Clipper.ClosedPathsFromPolyTree=function(e){var t=new i.Paths;return i.Clipper.AddPolyNodeToPaths(e,i.Clipper.NodeType.ntClosed,t),t},R(i.Clipper,i.ClipperBase),i.Clipper.NodeType={ntAny:0,ntOpen:1,ntClosed:2},i.ClipperOffset=function(e,t){void 0===e&&(e=2),void 0===t&&(t=i.ClipperOffset.def_arc_tolerance),this.m_destPolys=new i.Paths,this.m_srcPoly=new i.Path,this.m_destPoly=new i.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 i.IntPoint0,this.m_polyNodes=new i.PolyNode,this.MiterLimit=e,this.ArcTolerance=t,this.m_lowest.X=-1},i.ClipperOffset.two_pi=6.28318530717959,i.ClipperOffset.def_arc_tolerance=.25,i.ClipperOffset.prototype.Clear=function(){i.Clear(this.m_polyNodes.Childs()),this.m_lowest.X=-1},i.ClipperOffset.Round=i.Clipper.Round,i.ClipperOffset.prototype.AddPath=function(e,t,n){var r=e.length-1;if(!(r<0)){var a=new i.PolyNode;if(a.m_jointype=t,a.m_endtype=n,n===i.EndType.etClosedLine||n===i.EndType.etClosedPolygon)for(;r>0&&i.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++)i.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(!(n===i.EndType.etClosedPolygon&&s<2)&&(this.m_polyNodes.AddChild(a),n===i.EndType.etClosedPolygon))if(this.m_lowest.X<0)this.m_lowest=new i.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 i.IntPoint2(this.m_polyNodes.ChildCount()-1,o))}}},i.ClipperOffset.prototype.AddPaths=function(e,t,i){for(var n=0,r=e.length;n<r;n++)this.AddPath(e[n],t,i)},i.ClipperOffset.prototype.FixOrientations=function(){if(this.m_lowest.X>=0&&!i.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===i.EndType.etClosedPolygon||t.m_endtype===i.EndType.etClosedLine&&i.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===i.EndType.etClosedLine&&!i.Clipper.Orientation(t.m_polygon)&&t.m_polygon.reverse()}},i.ClipperOffset.GetUnitNormal=function(e,t){var n=t.X-e.X,r=t.Y-e.Y;if(0===n&&0===r)return new i.DoublePoint2(0,0);var a=1/Math.sqrt(n*n+r*r);return n*=a,r*=a,new i.DoublePoint2(r,-n)},i.ClipperOffset.prototype.DoOffset=function(e){if(this.m_destPolys=new Array,this.m_delta=e,i.ClipperBase.near_zero(e))for(var t=0;t<this.m_polyNodes.ChildCount();t++)(a=this.m_polyNodes.Childs()[t]).m_endtype===i.EndType.etClosedPolygon&&this.m_destPolys.push(a.m_polygon);else{var n;this.MiterLimit>2?this.m_miterLim=2/(this.MiterLimit*this.MiterLimit):this.m_miterLim=.5,n=this.ArcTolerance<=0?i.ClipperOffset.def_arc_tolerance:this.ArcTolerance>Math.abs(e)*i.ClipperOffset.def_arc_tolerance?Math.abs(e)*i.ClipperOffset.def_arc_tolerance:this.ArcTolerance;var r=3.14159265358979/Math.acos(1-n/Math.abs(e));for(this.m_sin=Math.sin(i.ClipperOffset.two_pi/r),this.m_cos=Math.cos(i.ClipperOffset.two_pi/r),this.m_StepsPerRad=r/i.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!==i.EndType.etClosedPolygon))){if(this.m_destPoly=new Array,1===s){if(a.m_jointype===i.JoinType.jtRound)for(var o=1,l=0,h=1;h<=r;h++){this.m_destPoly.push(new i.IntPoint2(i.ClipperOffset.Round(this.m_srcPoly[0].X+o*e),i.ClipperOffset.Round(this.m_srcPoly[0].Y+l*e)));var c=o;o=o*this.m_cos-this.m_sin*l,l=c*this.m_sin+l*this.m_cos}else for(o=-1,l=-1,h=0;h<4;++h)this.m_destPoly.push(new i.IntPoint2(i.ClipperOffset.Round(this.m_srcPoly[0].X+o*e),i.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(i.ClipperOffset.GetUnitNormal(this.m_srcPoly[h],this.m_srcPoly[h+1]));if(a.m_endtype===i.EndType.etClosedLine||a.m_endtype===i.EndType.etClosedPolygon?this.m_normals.push(i.ClipperOffset.GetUnitNormal(this.m_srcPoly[s-1],this.m_srcPoly[0])):this.m_normals.push(new i.DoublePoint1(this.m_normals[s-2])),a.m_endtype===i.EndType.etClosedPolygon){var u=s-1;for(h=0;h<s;h++)u=this.OffsetPoint(h,u,a.m_jointype);this.m_destPolys.push(this.m_destPoly)}else if(a.m_endtype===i.EndType.etClosedLine){for(u=s-1,h=0;h<s;h++)u=this.OffsetPoint(h,u,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 i.DoublePoint2(-this.m_normals[h-1].X,-this.m_normals[h-1].Y);for(this.m_normals[0]=new i.DoublePoint2(-d.X,-d.Y),u=0,h=s-1;h>=0;h--)u=this.OffsetPoint(h,u,a.m_jointype);this.m_destPolys.push(this.m_destPoly)}else{for(u=0,h=1;h<s-1;++h)u=this.OffsetPoint(h,u,a.m_jointype);var p;for(a.m_endtype===i.EndType.etOpenButt?(h=s-1,p=new i.IntPoint2(i.ClipperOffset.Round(this.m_srcPoly[h].X+this.m_normals[h].X*e),i.ClipperOffset.Round(this.m_srcPoly[h].Y+this.m_normals[h].Y*e)),this.m_destPoly.push(p),p=new i.IntPoint2(i.ClipperOffset.Round(this.m_srcPoly[h].X-this.m_normals[h].X*e),i.ClipperOffset.Round(this.m_srcPoly[h].Y-this.m_normals[h].Y*e)),this.m_destPoly.push(p)):(h=s-1,u=s-2,this.m_sinA=0,this.m_normals[h]=new i.DoublePoint2(-this.m_normals[h].X,-this.m_normals[h].Y),a.m_endtype===i.EndType.etOpenSquare?this.DoSquare(h,u):this.DoRound(h,u)),h=s-1;h>0;h--)this.m_normals[h]=new i.DoublePoint2(-this.m_normals[h-1].X,-this.m_normals[h-1].Y);for(this.m_normals[0]=new i.DoublePoint2(-this.m_normals[1].X,-this.m_normals[1].Y),h=(u=s-1)-1;h>0;--h)u=this.OffsetPoint(h,u,a.m_jointype);a.m_endtype===i.EndType.etOpenButt?(p=new i.IntPoint2(i.ClipperOffset.Round(this.m_srcPoly[0].X-this.m_normals[0].X*e),i.ClipperOffset.Round(this.m_srcPoly[0].Y-this.m_normals[0].Y*e)),this.m_destPoly.push(p),p=new i.IntPoint2(i.ClipperOffset.Round(this.m_srcPoly[0].X+this.m_normals[0].X*e),i.ClipperOffset.Round(this.m_srcPoly[0].Y+this.m_normals[0].Y*e)),this.m_destPoly.push(p)):(u=1,this.m_sinA=0,a.m_endtype===i.EndType.etOpenSquare?this.DoSquare(0,1):this.DoRound(0,1)),this.m_destPolys.push(this.m_destPoly)}}}}},i.ClipperOffset.prototype.Execute=function(){var e=arguments;if(e[0]instanceof i.PolyTree){var t=e[0],n=e[1];if(t.Clear(),this.FixOrientations(),this.DoOffset(n),(o=new i.Clipper(0)).AddPaths(this.m_destPolys,i.PolyType.ptSubject,!0),n>0)o.Execute(i.ClipType.ctUnion,t,i.PolyFillType.pftPositive,i.PolyFillType.pftPositive);else{var r=i.Clipper.GetBounds(this.m_destPolys);if((l=new i.Path).push(new i.IntPoint2(r.left-10,r.bottom+10)),l.push(new i.IntPoint2(r.right+10,r.bottom+10)),l.push(new i.IntPoint2(r.right+10,r.top-10)),l.push(new i.IntPoint2(r.left-10,r.top-10)),o.AddPath(l,i.PolyType.ptSubject,!0),o.ReverseSolution=!0,o.Execute(i.ClipType.ctUnion,t,i.PolyFillType.pftNegative,i.PolyFillType.pftNegative),1===t.ChildCount()&&t.Childs()[0].ChildCount()>0){var a=t.Childs()[0];t.Childs()[0]=a.Childs()[0],t.Childs()[0].m_Parent=t;for(var s=1;s<a.ChildCount();s++)t.AddChild(a.Childs()[s])}else t.Clear()}}else{var o,l;if(t=e[0],n=e[1],i.Clear(t),this.FixOrientations(),this.DoOffset(n),(o=new i.Clipper(0)).AddPaths(this.m_destPolys,i.PolyType.ptSubject,!0),n>0)o.Execute(i.ClipType.ctUnion,t,i.PolyFillType.pftPositive,i.PolyFillType.pftPositive);else r=i.Clipper.GetBounds(this.m_destPolys),(l=new i.Path).push(new i.IntPoint2(r.left-10,r.bottom+10)),l.push(new i.IntPoint2(r.right+10,r.bottom+10)),l.push(new i.IntPoint2(r.right+10,r.top-10)),l.push(new i.IntPoint2(r.left-10,r.top-10)),o.AddPath(l,i.PolyType.ptSubject,!0),o.ReverseSolution=!0,o.Execute(i.ClipType.ctUnion,t,i.PolyFillType.pftNegative,i.PolyFillType.pftNegative),t.length>0&&t.splice(0,1)}},i.ClipperOffset.prototype.OffsetPoint=function(e,t,n){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 i.IntPoint2(i.ClipperOffset.Round(this.m_srcPoly[e].X+this.m_normals[t].X*this.m_delta),i.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 i.IntPoint2(i.ClipperOffset.Round(this.m_srcPoly[e].X+this.m_normals[t].X*this.m_delta),i.ClipperOffset.Round(this.m_srcPoly[e].Y+this.m_normals[t].Y*this.m_delta))),this.m_destPoly.push(new i.IntPoint1(this.m_srcPoly[e])),this.m_destPoly.push(new i.IntPoint2(i.ClipperOffset.Round(this.m_srcPoly[e].X+this.m_normals[e].X*this.m_delta),i.ClipperOffset.Round(this.m_srcPoly[e].Y+this.m_normals[e].Y*this.m_delta)));else switch(n){case i.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 i.JoinType.jtSquare:this.DoSquare(e,t);break;case i.JoinType.jtRound:this.DoRound(e,t)}return e},i.ClipperOffset.prototype.DoSquare=function(e,t){var n=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 i.IntPoint2(i.ClipperOffset.Round(this.m_srcPoly[e].X+this.m_delta*(this.m_normals[t].X-this.m_normals[t].Y*n)),i.ClipperOffset.Round(this.m_srcPoly[e].Y+this.m_delta*(this.m_normals[t].Y+this.m_normals[t].X*n)))),this.m_destPoly.push(new i.IntPoint2(i.ClipperOffset.Round(this.m_srcPoly[e].X+this.m_delta*(this.m_normals[e].X+this.m_normals[e].Y*n)),i.ClipperOffset.Round(this.m_srcPoly[e].Y+this.m_delta*(this.m_normals[e].Y-this.m_normals[e].X*n))))},i.ClipperOffset.prototype.DoMiter=function(e,t,n){var r=this.m_delta/n;this.m_destPoly.push(new i.IntPoint2(i.ClipperOffset.Round(this.m_srcPoly[e].X+(this.m_normals[t].X+this.m_normals[e].X)*r),i.ClipperOffset.Round(this.m_srcPoly[e].Y+(this.m_normals[t].Y+this.m_normals[e].Y)*r)))},i.ClipperOffset.prototype.DoRound=function(e,t){for(var n,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(i.Cast_Int32(i.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 i.IntPoint2(i.ClipperOffset.Round(this.m_srcPoly[e].X+s*this.m_delta),i.ClipperOffset.Round(this.m_srcPoly[e].Y+o*this.m_delta))),n=s,s=s*this.m_cos-this.m_sin*o,o=n*this.m_sin+o*this.m_cos;this.m_destPoly.push(new i.IntPoint2(i.ClipperOffset.Round(this.m_srcPoly[e].X+this.m_normals[e].X*this.m_delta),i.ClipperOffset.Round(this.m_srcPoly[e].Y+this.m_normals[e].Y*this.m_delta)))},i.Error=function(e){try{throw new Error(e)}catch(e){alert(e.message)}},i.JS={},i.JS.AreaOfPolygon=function(e,t){return t||(t=1),i.Clipper.Area(e)/(t*t)},i.JS.AreaOfPolygons=function(e,t){t||(t=1);for(var n=0,r=0;r<e.length;r++)n+=i.Clipper.Area(e[r]);return n/(t*t)},i.JS.BoundsOfPath=function(e,t){return i.JS.BoundsOfPaths([e],t)},i.JS.BoundsOfPaths=function(e,t){t||(t=1);var n=i.Clipper.GetBounds(e);return n.left/=t,n.bottom/=t,n.right/=t,n.top/=t,n},i.JS.Clean=function(e,t){if(!(e instanceof Array))return[];var n=e[0]instanceof Array;if(e=i.JS.Clone(e),"number"!=typeof t||null===t)return i.Error("Delta is not a number in Clean()."),e;if(0===e.length||1===e.length&&0===e[0].length||t<0)return e;n||(e=[e]);for(var r,a,s,o,l,h,c,u=e.length,d=[],p=0;p<u;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,c=1;c<r;c++)(a[c].X-l.X)*(a[c].X-l.X)+(a[c].Y-l.Y)*(a[c].Y-l.Y)<=o||(s[h]=a[c],l=a[c],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!n&&d.length?d=d[0]:n||0!==d.length?n&&0===d.length&&(d=[[]]):d=[],d},i.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 i,n,r,a,s=e.length,o=new Array(s);for(n=0;n<s;n++){for(i=e[n].length,a=new Array(i),r=0;r<i;r++)a[r]={X:e[n][r].X,Y:e[n][r].Y};o[n]=a}return t||(o=o[0]),o},i.JS.Lighten=function(e,t){if(!(e instanceof Array))return[];if("number"!=typeof t||null===t)return i.Error("Tolerance is not a number in Lighten()."),i.JS.Clone(e);if(0===e.length||1===e.length&&0===e[0].length||t<0)return i.JS.Clone(e);var n=e[0]instanceof Array;n||(e=[e]);var r,a,s,o,l,h,c,u,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++)c=s[a],d=s[a+1],u=s[a+2],y=c.X,x=c.Y,m=u.X-y,g=u.Y-x,(0!==m||0!==g)&&((v=((d.X-y)*m+(d.Y-x)*g)/(m*m+g*g))>1?(y=u.X,x=u.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 n||(w=w[0]),void 0===w&&(w=[]),w},i.JS.PerimeterOfPath=function(e,t,i){if(void 0===e)return 0;var n,r,a=Math.sqrt,s=0,o=0,l=0,h=0,c=0,u=e.length;if(u<2)return 0;for(t&&(e[u]=e[0],u++);--u;)o=(n=e[u]).X,l=n.Y,s+=a((o-(h=(r=e[u-1]).X))*(o-h)+(l-(c=r.Y))*(l-c));return t&&e.pop(),s/i},i.JS.PerimeterOfPaths=function(e,t,n){n||(n=1);for(var r=0,a=0;a<e.length;a++)r+=i.JS.PerimeterOfPath(e[a],t,n);return r},i.JS.ScaleDownPath=function(e,t){var i,n;for(t||(t=1),i=e.length;i--;)(n=e[i]).X=n.X/t,n.Y=n.Y/t},i.JS.ScaleDownPaths=function(e,t){var i,n,r;for(t||(t=1),i=e.length;i--;)for(n=e[i].length;n--;)(r=e[i][n]).X=r.X/t,r.Y=r.Y/t},i.JS.ScaleUpPath=function(e,t){var i,n,r=Math.round;for(t||(t=1),i=e.length;i--;)(n=e[i]).X=r(n.X*t),n.Y=r(n.Y*t)},i.JS.ScaleUpPaths=function(e,t){var i,n,r,a=Math.round;for(t||(t=1),i=e.length;i--;)for(n=e[i].length;n--;)(r=e[i][n]).X=a(r.X*t),r.Y=a(r.Y*t)},i.ExPolygons=function(){return[]},i.ExPolygon=function(){this.outer=null,this.holes=null},i.JS.AddOuterPolyNodeToExPolygons=function(e,t){var n=new i.ExPolygon;n.outer=e.Contour();var r,a,s,o,l,h,c=e.Childs(),u=c.length;for(n.holes=new Array(u),s=0;s<u;s++)for(r=c[s],n.holes[s]=r.Contour(),o=0,h=(l=r.Childs()).length;o<h;o++)a=l[o],i.JS.AddOuterPolyNodeToExPolygons(a,t);t.push(n)},i.JS.ExPolygonsToPaths=function(e){var t,n,r,a,s=new i.Paths;for(t=0,r=e.length;t<r;t++)for(s.push(e[t].outer),n=0,a=e[t].holes.length;n<a;n++)s.push(e[t].holes[n]);return s},i.JS.PolyTreeToExPolygons=function(e){var t,n,r,a,s=new i.ExPolygons;for(n=0,a=(r=e.Childs()).length;n<a;n++)t=r[n],i.JS.AddOuterPolyNodeToExPolygons(t,s);return s}}()})),wye=Q((()=>{})),Sye=Q((()=>{})),Mye=Q((()=>{})),Rye=Q((()=>{})),Aye=Q((()=>{})),r1e=Q(((exports,module)=>{var t,e;t=globalThis,e=()=>(()=>{"use strict";var __webpack_modules__=[,(e,t)=>{var i;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,i=8192;if(t<i)return String.fromCharCode.apply(null,e);let n=[];for(let r=0;r<t;r+=i){let a=Math.min(r+i,t),s=e.subarray(r,a);n.push(String.fromCharCode.apply(null,s))}return n.join("")},t.createValidAbsoluteUrl=function(e,t=null,i=null){if(!e)return null;try{if(i&&"string"==typeof e){if(i.addDefaultProtocol&&e.startsWith("www.")){let t=e.match(/\./g);(null==t?void 0:t.length)>=2&&(e=`http://${e}`)}if(i.tryConvertEncoding)try{e=d(e)}catch(e){}}let n=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}}(n))return n}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>=n.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 i=0,n=e.length;i<n;i++)if(e[i]!==t[i])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,i)=>t?t.normalize("NFKC"):f.get(i)))},t.objectFromMap=function(e){let t=Object.create(null);for(let[i,n]of e)t[i]=n;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 i=new TextDecoder(t,{fatal:!0}),n=h(e);return i.decode(n)}catch(e){a(`stringToPDFString: "${e}".`)}}let t=[];for(let i=0,n=e.length;i<n;i++){let n=u[e.charCodeAt(i)];t.push(n?String.fromCharCode(n):e.charAt(i))}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 n={ERRORS:0,WARNINGS:1,INFOS:5};t.VerbosityLevel=n,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=n.WARNINGS;function a(e){r>=n.WARNINGS&&console.log(`Warning: ${e}`)}function s(e){throw new Error(e)}function o(e,t,i,n=!1){return Object.defineProperty(e,t,{value:i,enumerable:!n,configurable:!0,writable:!1}),i}let l=function(){function e(t,i){this.constructor===e&&s("Cannot initialize BaseException."),this.message=t,this.name=i}return e.prototype=new Error,e.constructor=e,e}();function h(e){"string"!=typeof e&&s("Invalid argument for stringToBytes");let t=e.length,i=new Uint8Array(t);for(let n=0;n<t;++n)i[n]=255&e.charCodeAt(n);return i}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 c=[...Array(256).keys()].map((e=>e.toString(16).padStart(2,"0")));t.Util=class{static makeHexColor(e,t,i){return`#${c[e]}${c[t]}${c[i]}`}static scaleMinMax(e,t){let i;e[0]?(e[0]<0&&(i=t[0],t[0]=t[1],t[1]=i),t[0]*=e[0],t[1]*=e[0],e[3]<0&&(i=t[2],t[2]=t[3],t[3]=i),t[2]*=e[3],t[3]*=e[3]):(i=t[0],t[0]=t[2],t[2]=i,i=t[1],t[1]=t[3],t[3]=i,e[1]<0&&(i=t[2],t[2]=t[3],t[3]=i),t[2]*=e[1],t[3]*=e[1],e[2]<0&&(i=t[0],t[0]=t[1],t[1]=i),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 i=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])/i,(-e[0]*t[1]+e[1]*t[0]+t[4]*t[1]-t[5]*t[0])/i]}static getAxialAlignedBoundingBox(e,t){let i=this.applyTransform(e,t),n=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(i[0],n[0],r[0],a[0]),Math.min(i[1],n[1],r[1],a[1]),Math.max(i[0],n[0],r[0],a[0]),Math.max(i[1],n[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]],i=e[0]*t[0]+e[1]*t[2],n=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=(i+a)/2,o=Math.sqrt(Do(i+a,2)-4*(i*a-r*n))/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 i=Math.max(Math.min(e[0],e[2]),Math.min(t[0],t[2])),n=Math.min(Math.max(e[0],e[2]),Math.max(t[0],t[2]));if(i>n)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:[i,r,n,a]}static bezierBoundingBox(e,t,i,n,r,a,s,o){let l,h,c,u,d,p,f,m,g=[],v=[[],[]];for(let _=0;_<2;++_)if(0===_?(h=6*e-12*i+6*r,l=-3*e+9*i-9*r+3*s,c=3*i-3*e):(h=6*t-12*n+6*a,l=-3*t+9*n-9*a+3*o,c=3*n-3*t),Math.abs(l)<1e-12){if(Math.abs(h)<1e-12)continue;u=-c/h,0<u&&u<1&&g.push(u)}else f=h*h-4*c*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--;)u=g[x],y=1-u,v[0][x]=y*y*y*e+3*y*y*u*i+3*y*u*u*r+u*u*u*s,v[1][x]=y*y*y*t+3*y*y*u*n+3*y*u*u*a+u*u*u*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 u=[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))}i=new WeakMap,t.PromiseCapability=class{constructor(){Je(this,i,!1),this.promise=new Promise(((e,t)=>{this.resolve=t=>{Mt(this,i,!0),e(t)},this.reject=e=>{Mt(this,i,!0),t(e)}}))}get settled(){return ce(this,i)}};let p=null,f=null},(__unused_webpack_module,exports,__w_pdfjs_require__)=>{var i,e,n,r,Jy,a,U2,l,c,u,h,d,f,p,g,IV,v,E,LV,_,R;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=i=>(0,_display_utils.isValidFetchUrl)(i.url)?new t(i):new e(i)}function getDocument(e){var t,i;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 n=new PDFDocumentLoadingTask,{docId:r}=n,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,c=e.range instanceof PDFDataRangeTransport?e.range:null,u=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,D=!0===e.disableAutoFetch,L=!0===e.pdfBug,I=c?c.length:null!=(i=e.length)?i:NaN,O="boolean"==typeof e.useSystemFonts?e.useSystemFonts:!_is_node.isNodeJS&&!E,k="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(k||(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),n._worker=d}let B={docId:r,apiVersion:"3.8.162",data:s,password:h,disableAutoFetch:D,rangeChunkSize:u,length:I,docBaseUrl:f,enableXfa:A,evaluatorOptions:{maxImageSize:_,disableFontFace:E,ignoreErrors:b,isEvalSupported:w,isOffscreenCanvasSupported:S,canvasMaxAreaInBytes:M,fontExtraProperties:T,useSystemFonts:O,cMapUrl:k?m:null,standardFontDataUrl:k?y:null}},z={ignoreErrors:b,isEvalSupported:w,disableFontFace:E,fontExtraProperties:T,enableXfa:A,ownerDocument:C,disableAutoFetch:D,pdfBug:L,styleElement:null};return d.promise.then((function(){if(n.destroyed)throw new Error("Loading aborted");let e=_fetchDocument(d,B),t=new Promise((function(e){let t;c?t=new _transport_stream.PDFDataTransportStream({length:I,initialData:c.initialData,progressiveDone:c.progressiveDone,contentDispositionFilename:c.contentDispositionFilename,disableRange:P,disableStream:R},c):s||(t=createPDFNetworkStream({url:a,length:I,httpHeaders:o,withCredentials:l,rangeChunkSize:u,disableRange:P,disableStream:R})),e(t)}));return Promise.all([e,t]).then((function([e,t]){if(n.destroyed)throw new Error("Loading aborted");let i=new _message_handler.MessageHandler(r,e,d.port),a=new WorkerTransport(i,n,t,z,F);n._transport=a,i.send("Ready",null)}))})).catch(n._capability.reject),n}function _fetchDocument(e,t){return ft(this,null,(function*(){if(e.destroyed)throw new Error("Worker was destroyed");let i=yield e.messageHandler.sendWithPromise("GetDocRequest",t,t.data?[t.data.buffer]:null);if(e.destroyed)throw new Error("Worker was destroyed");return i}))}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"+GT(t,i)._++,this.destroyed=!1,this.onPassword=null,this.onProgress=null}get promise(){return this._capability.promise}destroy(){return ft(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,i=!1,n=null){this.length=e,this.initialData=t,this.progressiveDone=i,this.contentDispositionFilename=n,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 i of this._rangeListeners)i(e,t)}onDataProgress(e,t){this._readyCapability.promise.then((()=>{for(let i of this._progressListeners)i(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:i=0,offsetY:n=0,dontFlip:r=!1}={}){return new _display_utils.PageViewport({viewBox:this.view,scale:e,rotation:t,offsetX:i,offsetY:n,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 ft(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:c=null,pageColors:u=null,printAnnotationStorage:d=null}){var p,f;null==(p=this._stats)||p.time("Overall");let m=this._transport.getRenderingIntent(i,s,d);Mt(this,n,!1),dt(this,a,U2).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)&&Mt(this,n,!0),dt(this,r,Jy).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:c,operatorList:g.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!v,pdfBug:this._pdfBug,pageColors:u});(g.renderTasks||(g.renderTasks=new Set)).add(x);let b=x.task;return Promise.all([g.displayReadyCapability.promise,h]).then((([e,t])=>{var i;this.destroyed?y():(null==(i=this._stats)||i.time("Rendering"),x.initializeGraphics({transparency:e,optionalContentConfig:t}),x.operatorListChanged())})).catch(y),b}getOperatorList({intent:e="display",annotationMode:t=_util.AnnotationMode.ENABLE,printAnnotationStorage:i=null}={}){var n;let r,a=this._transport.getRenderingIntent(e,t,i,!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==(n=this._stats)||n.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,i){let n=t.getReader(),r={items:[],styles:Object.create(null)};!function t(){n.read().then((function({value:i,done:n}){n?e(r):(Object.assign(r.styles,i.styles),r.items.push(...i.items),t())}),i)}()}))}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 i of t.renderTasks)e.push(i.completed),i.cancel();return this.objs.clear(),Mt(this,n,!1),dt(this,a,U2).call(this),Promise.all(e)}cleanup(e=!1){Mt(this,n,!0);let t=dt(this,r,Jy).call(this,!1);return e&&t&&this._stats&&(this._stats=new _display_utils.StatTimer),t}_startRenderPage(e,t){var i,n;let r=this._intentStates.get(t);r&&(null==(i=this._stats)||i.timeEnd("Page Request"),null==(n=r.displayReadyCapability)||n.resolve(e))}_renderPageChunk(e,t){for(let i=0,n=e.length;i<n;i++)t.operatorList.fnArray.push(e.fnArray[i]),t.operatorList.argsArray.push(e.argsArray[i]);t.operatorList.lastChunk=e.lastChunk,t.operatorList.separateAnnots=e.separateAnnots;for(let i of t.renderTasks)i.operatorListChanged();e.lastChunk&&dt(this,r,Jy).call(this,!0)}_pumpOperatorList({renderingIntent:e,cacheKey:t,annotationStorageSerializable:i}){let{map:n,transfers:a}=i,s=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:this._pageIndex,intent:e,cacheKey:t,annotationStorage:n},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();dt(this,r,Jy).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:i=!1}){if(e.streamReader){if(e.streamReaderCancelTimeout&&(clearTimeout(e.streamReaderCancelTimeout),e.streamReaderCancelTimeout=null),!i){if(e.renderTasks.size>0)return;if(t instanceof _display_utils.RenderingCancelledException){let i=RENDERING_CANCELLED_TIMEOUT;return t.extraDelay>0&&t.extraDelay<1e3&&(i+=t.extraDelay),void(e.streamReaderCancelTimeout=setTimeout((()=>{e.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:e,reason:t,force:!0})}),i))}}if(e.streamReader.cancel(new _util.AbortException(t.message)).catch((()=>{})),e.streamReader=null,!this._transport.destroyed){for(let[t,i]of this._intentStates)if(i===e){this._intentStates.delete(t);break}this.cleanup()}}}get stats(){return this._stats}}e=new WeakMap,n=new WeakMap,r=new WeakSet,Jy=function(t=!1){if(dt(this,a,U2).call(this),!ce(this,n)||this.destroyed)return!1;if(t)return Mt(this,e,setTimeout((()=>{Mt(this,e,null),dt(this,r,Jy).call(this,!1)}),DELAYED_CLEANUP_TIMEOUT)),!1;for(let{renderTasks:e,operatorList:i}of this._intentStates.values())if(e.size>0||!i.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),Mt(this,n,!1),!0},a=new WeakSet,U2=function(){ce(this,e)&&(clearTimeout(ce(this,e)),Mt(this,e,null))},exports.PDFPageProxy=PDFPageProxy;class LoopbackPort{constructor(){Je(this,l,new Set),Je(this,c,Promise.resolve())}postMessage(e,t){let i={data:structuredClone(e,t?{transfer:t}:null)};ce(this,c).then((()=>{for(let e of ce(this,l))e.call(this,i)}))}addEventListener(e,t){ce(this,l).add(t)}removeEventListener(e,t){ce(this,l).delete(t)}terminate(){ce(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 a3)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 i;try{if(i=new URL(e),!i.origin||"null"===i.origin)return!1}catch(e){return!1}let n=new URL(t,i);return i.origin===n.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:i=(0,_util.getVerbosityLevel)()}={}){if(t&&ce(_PDFWorker,h).has(t))throw new Error("Cannot use more than one PDFWorker per port.");if(this.name=e,this.destroyed=!1,this.verbosity=i,this._readyCapability=new _util.PromiseCapability,this._port=null,this._webWorker=null,this._messageHandler=null,t)return ce(_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),i=new _message_handler.MessageHandler("main","worker",e),n=()=>{e.removeEventListener("error",r),i.destroy(),e.terminate(),this.destroyed?this._readyCapability.reject(new Error("Worker was destroyed")):this._setupFakeWorker()},r=()=>{this._webWorker||n()};e.addEventListener("error",r),i.on("test",(t=>{e.removeEventListener("error",r),this.destroyed?n():t?(this._messageHandler=i,this._port=e,this._webWorker=e,this._readyCapability.resolve(),i.send("configure",{verbosity:this.verbosity})):(this._setupFakeWorker(),i.destroy(),e.terminate())})),i.on("ready",(t=>{if(e.removeEventListener("error",r),this.destroyed)n();else try{a()}catch(t){this._setupFakeWorker()}}));let a=()=>{let e=new Uint8Array;i.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 i="fake"+PDFWorkerUtil.fakeWorkerId++,n=new _message_handler.MessageHandler(i+"_worker",i,t);e.setup(n,t);let r=new _message_handler.MessageHandler(i,i+"_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),ce(_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 ce(this,h).has(e.port)?ce(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=()=>ft(this,null,(function*(){let mainWorkerMessageHandler=this._mainThreadWorkerMessageHandler;if(mainWorkerMessageHandler)return mainWorkerMessageHandler;if(_is_node.isNodeJS&&"function"==typeof a3){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,i,n,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:n.ownerDocument,styleElement:n.styleElement}),this._params=n,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=i,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,i=null,n=!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&&i instanceof _annotation_storage.PrintAnnotationStorage?i:this.annotationStorage).serializable;break;default:(0,_util.warn)(`getRenderingIntent - invalid annotationMode: ${t}`)}return n&&(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 i of ce(this,f).values())e.push(i._destroy());ce(this,f).clear(),ce(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(),ce(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:i}){i?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 i=new _util.PromiseCapability,n=this._fullReader;return n.headersReady.then((()=>{var e;(!n.isStreamingSupported||!n.isRangeSupported)&&(this._lastProgress&&(null==(e=t.onProgress)||e.call(t,this._lastProgress)),n.onProgress=e=>{var i;null==(i=t.onProgress)||i.call(t,{loaded:e.loaded,total:e.total})}),i.resolve({isStreamingSupported:n.isStreamingSupported,isRangeSupported:n.isRangeSupported,contentLength:n.contentLength})}),i.reject),i.promise})),e.on("GetRangeReader",((e,t)=>{(0,_util.assert)(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");let i=this._networkStream.getRangeReader(e.begin,e.end);i?(t.onPull=()=>{i.read().then((function({value:e,done:i}){i?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=>{i.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 i;switch(e.name){case"PasswordException":i=new _util.PasswordException(e.message,e.code);break;case"InvalidPDFException":i=new _util.InvalidPDFException(e.message);break;case"MissingPDFException":i=new _util.MissingPDFException(e.message);break;case"UnexpectedResponseException":i=new _util.UnexpectedResponseException(e.message,e.status);break;case"UnknownErrorException":i=new _util.UnknownErrorException(e.message,e.details);break;default:(0,_util.unreachable)("DocException - expected a valid Error.")}t._capability.reject(i)})),e.on("PasswordRequest",(e=>{if(this._passwordCapability=new _util.PromiseCapability,t.onPassword){let i=e=>{e instanceof Error?this._passwordCapability.reject(e):this._passwordCapability.resolve({password:e})};try{t.onPassword(i,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 i;null==(i=t.onProgress)||i.call(t,{loaded:e.length,total:e.length}),this.downloadInfoCapability.resolve(e)})),e.on("StartRenderPage",(e=>{this.destroyed||ce(this,f).get(e.pageIndex)._startRenderPage(e.transparency,e.cacheKey)})),e.on("commonobj",(([t,i,n])=>{var r;if(!this.destroyed&&!this.commonObjs.has(t))switch(i){case"Font":let a=this._params;if("error"in n){let e=n.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(n,{isEvalSupported:a.isEvalSupported,disableFontFace:a.disableFontFace,ignoreErrors:a.ignoreErrors,inspectFont:s});this.fontLoader.bind(o).catch((i=>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,n);break;default:throw new Error(`Got unknown common object type ${i}`)}})),e.on("obj",(([e,t,i,n])=>{var r;if(this.destroyed)return;let a=ce(this,f).get(t);if(!a.objs.has(e))switch(i){case"Image":if(a.objs.resolve(e,n),n){let e;if(n.bitmap){let{width:t,height:i}=n;e=t*i*4}else e=(null==(r=n.data)?void 0:r.length)||0;e>_util.MAX_IMAGE_SIZE_TO_CACHE&&(a._maybeCleanupAfterRender=!0)}break;case"Pattern":a.objs.resolve(e,n);break;default:throw new Error(`Got unknown object type ${i}`)}})),e.on("DocProgress",(e=>{var i;this.destroyed||null==(i=t.onProgress)||i.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:i,transfers:n}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:i,filename:null!=(t=null==(e=this._fullReader)?void 0:e.filename)?t:null},n).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,i=ce(this,p).get(t);if(i)return i;let n=this.messageHandler.sendWithPromise("GetPage",{pageIndex:t}).then((e=>{if(this.destroyed)throw new Error("Transport destroyed");let i=new PDFPageProxy(t,e,this,this._params.pdfBug);return ce(this,f).set(t,i),i}));return ce(this,p).set(t,n),n}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 dt(this,g,IV).call(this,"GetFieldObjects")}hasJSActions(){return dt(this,g,IV).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=ce(this,d).get(e);if(t)return t;let i=this.messageHandler.sendWithPromise(e,null).then((e=>{var t,i,n,r;return{info:e[0],metadata:e[1]?new _metadata.Metadata(e[1]):null,contentDispositionFilename:null!=(i=null==(t=this._fullReader)?void 0:t.filename)?i:null,contentLength:null!=(r=null==(n=this._fullReader)?void 0:n.contentLength)?r:null}}));return ce(this,d).set(e,i),i}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}startCleanup(e=!1){return ft(this,null,(function*(){if(!this.destroyed){yield this.messageHandler.sendWithPromise("Cleanup",null);for(let e of ce(this,f).values())if(!e.cleanup())throw new Error(`startCleanup: Page ${e.pageNumber} is currently rendering.`);this.commonObjs.clear(),e||this.fontLoader.clear(),ce(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,IV=function(e,t=null){let i=ce(this,d).get(e);if(i)return i;let n=this.messageHandler.sendWithPromise(e,t);return ce(this,d).set(e,n),n};class PDFObjects{constructor(){Je(this,E),Je(this,v,Object.create(null))}get(e,t=null){if(t){let i=dt(this,E,LV).call(this,e);return i.capability.promise.then((()=>t(i.data))),null}let i=ce(this,v)[e];if(null==i||!i.capability.settled)throw new Error(`Requesting object that isn't resolved yet ${e}.`);return i.data}has(e){let t=ce(this,v)[e];return(null==t?void 0:t.capability.settled)||!1}resolve(e,t=null){let i=dt(this,E,LV).call(this,e);i.data=t,i.capability.resolve()}clear(){var e;for(let t in ce(this,v)){let{data:i}=ce(this,v)[t];null==(e=null==i?void 0:i.bitmap)||e.close()}Mt(this,v,Object.create(null))}}v=new WeakMap,E=new WeakSet,LV=function(e){return ce(this,v)[e]||(ce(this,v)[e]={capability:new _util.PromiseCapability,data:null})};class RenderTask{constructor(e){Je(this,_,null),Mt(this,_,e),this.onContinue=null}get promise(){return ce(this,_).capability.promise}cancel(e=0){ce(this,_).cancel(null,e)}get separateAnnots(){let{separateAnnots:e}=ce(this,_).operatorList;if(!e)return!1;let{annotationCanvasMap:t}=ce(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:i,commonObjs:n,annotationCanvasMap:r,operatorList:a,pageIndex:s,canvasFactory:o,filterFactory:l,useRequestAnimationFrame:h=!1,pdfBug:c=!1,pageColors:u=null}){this.callback=e,this.params=t,this.objs=i,this.commonObjs=n,this.annotationCanvasMap=r,this.operatorListIdx=null,this.operatorList=a,this._pageIndex=s,this.canvasFactory=o,this.filterFactory=l,this._pdfBug=c,this.pageColors=u,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 i,n;if(this.cancelled)return;if(this._canvas){if(ce(M,R).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.");ce(M,R).add(this._canvas)}this._pdfBug&&null!=(i=globalThis.StepperManager)&&i.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==(n=this.graphicsReadyCallback)||n.call(this)}cancel(e=null,t=0){var i;this.running=!1,this.cancelled=!0,null==(i=this.gfx)||i.endDrawing(),this._canvas&&ce(M,R).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 ft(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&&ce(M,R).delete(this._canvas),this.callback())))}))}},InternalRenderTask=M;R=new WeakMap,Je(InternalRenderTask,R,new WeakSet);let version="3.8.162";exports.version=version;let build="2c74323e3";exports.build=build},(e,t,i)=>{var n,r,a,s,o;Object.defineProperty(t,"__esModule",{value:!0}),t.SerializableEmpty=t.PrintAnnotationStorage=t.AnnotationStorage=void 0;var l=i(1),h=i(4),c=i(8);let u=Object.freeze({map:null,hash:"",transfers:void 0});t.SerializableEmpty=u;class d{constructor(){Je(this,a),Je(this,n,!1),Je(this,r,new Map),this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(e,t){let i=ce(this,r).get(e);return void 0===i?t:Object.assign(t,i)}getRawValue(e){return ce(this,r).get(e)}remove(e){if(ce(this,r).delete(e),0===ce(this,r).size&&this.resetModified(),"function"==typeof this.onAnnotationEditor){for(let e of ce(this,r).values())if(e instanceof h.AnnotationEditor)return;this.onAnnotationEditor(null)}}setValue(e,t){let i=ce(this,r).get(e),n=!1;if(void 0!==i)for(let[r,a]of Object.entries(t))i[r]!==a&&(n=!0,i[r]=a);else n=!0,ce(this,r).set(e,t);n&&dt(this,a,s).call(this),t instanceof h.AnnotationEditor&&"function"==typeof this.onAnnotationEditor&&this.onAnnotationEditor(t.constructor._type)}has(e){return ce(this,r).has(e)}getAll(){return ce(this,r).size>0?(0,l.objectFromMap)(ce(this,r)):null}setAll(e){for(let[t,i]of Object.entries(e))this.setValue(t,i)}get size(){return ce(this,r).size}resetModified(){ce(this,n)&&(Mt(this,n,!1),"function"==typeof this.onResetModified&&this.onResetModified())}get print(){return new p(this)}get serializable(){if(0===ce(this,r).size)return u;let e=new Map,t=new c.MurmurHash3_64,i=[];for(let[n,a]of ce(this,r)){let r=a instanceof h.AnnotationEditor?a.serialize():a;r&&(e.set(n,r),t.update(`${n}:${JSON.stringify(r)}`),r.bitmap&&i.push(r.bitmap))}return e.size>0?{map:e,hash:t.hexdigest(),transfers:i}:u}}n=new WeakMap,r=new WeakMap,a=new WeakSet,s=function(){ce(this,n)||(Mt(this,n,!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:i,transfers:n}=e.serializable,r=structuredClone(t,n?{transfer:n}:null);Mt(this,o,{map:r,hash:i,transfers:n})}get print(){(0,l.unreachable)("Should not call PrintAnnotationStorage.print")}get serializable(){return ce(this,o)}}o=new WeakMap,t.PrintAnnotationStorage=p},(e,t,i)=>{var n,r,a,s,o,l;Object.defineProperty(t,"__esModule",{value:!0}),t.AnnotationEditor=void 0;var h=i(5),c=i(1);let u=class{constructor(e){Je(this,n,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,u._zIndex++),this.constructor===u&&(0,c.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:i,pageHeight:h,pageX:d,pageY:p}}=this.parent.viewport;this.rotation=t,this.pageRotation=(360+t-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[i,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,c.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=ce(this,l)}setParent(e){null!==e&&(this.pageIndex=e.pageIndex,this.pageDimensions=e.pageDimensions),this.parent=e}focusin(e){ce(this,a)?Mt(this,a,!1):this.parent.setSelected(this)}focusout(e){var t;if(!this.isAttachedToDOM)return;let i=e.relatedTarget;null!=i&&i.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,i,n){let[r,a]=this.parentDimensions;[i,n]=this.screenToPageTranslation(i,n),this.x=(e+i)/r,this.y=(t+n)/a,this.div.style.left=100*this.x+"%",this.div.style.top=100*this.y+"%"}translate(e,t){let[i,n]=this.parentDimensions;[e,t]=this.screenToPageTranslation(e,t),this.x+=e/i,this.y+=t/n,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,i]=this.pageDimensions;return[t*e,i*e]}setDims(e,t){let[i,n]=this.parentDimensions;this.div.style.width=100*e/i+"%",this.div.style.height=100*t/n+"%"}fixDims(){let{style:e}=this.div,{height:t,width:i}=e,n=i.endsWith("%"),r=t.endsWith("%");if(n&&r)return;let[a,s]=this.parentDimensions;n||(e.width=100*parseFloat(i)/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",ce(this,n)),this.div.addEventListener("focusout",ce(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}=c.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),Mt(this,a,!0))}getRect(e,t){let i=this.parentScale,[n,r]=this.pageDimensions,[a,s]=this.pageTranslation,o=e/i,l=t/i,h=this.x*n,c=this.y*r,u=this.width*n,d=this.height*r;switch(this.rotation){case 0:return[h+o+a,r-c-l-d+s,h+o+u+a,r-c-l+s];case 90:return[h+l+a,r-c+o+s,h+l+d+a,r-c+o+u+s];case 180:return[h-o-u+a,r-c+l+s,h-o+a,r-c+l+d+s];case 270:return[h-l-d+a,r-c-o-u+s,h-l+a,r-c-o+s];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(e,t){let[i,n,r,a]=e,s=r-i,o=a-n;switch(this.rotation){case 0:return[i,t-a,s,o];case 90:return[i,t-n,o,s];case 180:return[r,t-n,s,o];case 270:return[r,t-a,o,s];default:throw new Error("Invalid rotation")}}onceAdded(){}isEmpty(){return!1}enableEditMode(){Mt(this,o,!0)}disableEditMode(){Mt(this,o,!1)}isInEditMode(){return ce(this,o)}shouldGetKeyboardEvents(){return!1}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}rebuild(){var e,t;null==(e=this.div)||e.addEventListener("focusin",ce(this,n)),null==(t=this.div)||t.addEventListener("focusout",ce(this,r))}serialize(e=!1){(0,c.unreachable)("An editor must be serializable")}static deserialize(e,t,i){let n=new this.prototype.constructor({parent:t,id:t.getNextId(),uiManager:i});n.rotation=e.rotation;let[r,a]=n.pageDimensions,[s,o,l,h]=n.getRectInCurrentCoords(e.rect,a);return n.x=s/r,n.y=o/a,n.width=l/r,n.height=h/a,n}remove(){this.div.removeEventListener("focusin",ce(this,n)),this.div.removeEventListener("focusout",ce(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 ce(this,s)}set isEditing(e){Mt(this,s,e),e?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null)}},d=u;n=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,i)=>{var n,r,a,s,o,l,h,c,u,d,p,f,m,g,v,y,x,b,_,w,S,M,E,T,A,C,P,R,D,L,I,O,k,N,U,F,B,z,H,V,j,G,W,X,Y,q,Z,Q,J,K,$,ee,te;Object.defineProperty(t,"__esModule",{value:!0}),t.KeyboardManager=t.CommandManager=t.ColorManager=t.AnnotationEditorUIManager=void 0,t.bindEvents=function(e,t,i){for(let n of i)t.addEventListener(n,e[n].bind(e))},t.opacityToHex=function(e){return Math.round(Math.min(255,Math.max(1,255*e))).toString(16).padStart(2,"0")};var ie=i(1),ne=i(6);class re{constructor(){Je(this,n,0)}getId(){return`${ie.AnnotationEditorPrefix}${GT(this,n)._++}`}}n=new WeakMap;class ae{constructor(e=128){Je(this,r,[]),Je(this,a,!1),Je(this,s,void 0),Je(this,o,-1),Mt(this,s,e)}add({cmd:e,undo:t,mustExec:i,type:n=NaN,overwriteIfSameType:l=!1,keepUndo:h=!1}){if(i&&e(),ce(this,a))return;let c={cmd:e,undo:t,type:n};if(-1===ce(this,o))return ce(this,r).length>0&&(ce(this,r).length=0),Mt(this,o,0),void ce(this,r).push(c);if(l&&ce(this,r)[ce(this,o)].type===n)return h&&(c.undo=ce(this,r)[ce(this,o)].undo),void(ce(this,r)[ce(this,o)]=c);let u=ce(this,o)+1;u===ce(this,s)?ce(this,r).splice(0,1):(Mt(this,o,u),u<ce(this,r).length&&ce(this,r).splice(u)),ce(this,r).push(c)}undo(){-1!==ce(this,o)&&(Mt(this,a,!0),ce(this,r)[ce(this,o)].undo(),Mt(this,a,!1),Mt(this,o,ce(this,o)-1))}redo(){ce(this,o)<ce(this,r).length-1&&(Mt(this,o,ce(this,o)+1),Mt(this,a,!0),ce(this,r)[ce(this,o)].cmd(),Mt(this,a,!1))}hasSomethingToUndo(){return-1!==ce(this,o)}hasSomethingToRedo(){return ce(this,o)<ce(this,r).length-1}destroy(){Mt(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}=ie.FeatureTest.platform;for(let[i,n,r=!1]of e)for(let e of i){let i=e.startsWith("mac+");t&&i?(this.callbacks.set(e.slice(4),{callback:n,bubbles:r}),this.allKeys.add(e.split("+").at(-1))):!t&&!i&&(this.callbacks.set(e,{callback:n,bubbles:r}),this.allKeys.add(e.split("+").at(-1)))}}exec(e,t){if(!this.allKeys.has(t.key))return;let i=this.callbacks.get(dt(this,l,h).call(this,t));if(!i)return;let{callback:n,bubbles:r}=i;n.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,ne.getColorValues)(e),(0,ie.shadow)(this,"_colors",e)}convert(e){let t=(0,ne.getRGB)(e);if(!window.matchMedia("(forced-colors: active)").matches)return t;for(let[i,n]of this._colors)if(n.every(((e,i)=>e===t[i])))return oe._colorsMapping.get(i);return t}getHexCode(e){let t=this._colors.get(e);return t?ie.Util.makeHexColor(...t):e}},le=oe;Yi(le,"_colorsMapping",new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]])),t.ColorManager=le;let he=class{constructor(e,t,i){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,Q),Je(this,K),Je(this,ee),Je(this,c,null),Je(this,u,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,ie.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,D,this.onRotationChanging.bind(this)),Je(this,L,{isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1}),Je(this,I,null),Mt(this,I,e),Mt(this,x,t),ce(this,x)._on("editingaction",ce(this,C)),ce(this,x)._on("pagechanging",ce(this,P)),ce(this,x)._on("scalechanging",ce(this,R)),ce(this,x)._on("rotationchanging",ce(this,D)),Mt(this,p,i),this.viewParameters={realScale:ne.PixelsPerInch.PDF_TO_CSS_UNITS,rotation:0}}static get _keyboardManager(){return(0,ie.shadow)(this,"_keyboardManager",new se([[["ctrl+a","mac+meta+a"],he.prototype.selectAll],[["ctrl+z","mac+meta+z"],he.prototype.undo],[["ctrl+y","ctrl+shift+Z","mac+meta+shift+Z"],he.prototype.redo],[["Backspace","alt+Backspace","ctrl+Backspace","shift+Backspace","mac+Backspace","mac+alt+Backspace","mac+ctrl+Backspace","Delete","ctrl+Delete","shift+Delete"],he.prototype.delete],[["Escape","mac+Escape"],he.prototype.unselectAll]]))}destroy(){dt(this,N,U).call(this),ce(this,x)._off("editingaction",ce(this,C)),ce(this,x)._off("pagechanging",ce(this,P)),ce(this,x)._off("scalechanging",ce(this,R)),ce(this,x)._off("rotationchanging",ce(this,D));for(let e of ce(this,d).values())e.destroy();ce(this,d).clear(),ce(this,u).clear(),ce(this,y).clear(),Mt(this,c,null),ce(this,S).clear(),ce(this,f).destroy()}onPageChanging({pageNumber:e}){Mt(this,m,e-1)}focusMainContainer(){ce(this,I).focus()}addShouldRescale(e){ce(this,y).add(e)}removeShouldRescale(e){ce(this,y).delete(e)}onScaleChanging({scale:e}){this.commitOrRemove(),this.viewParameters.realScale=e*ne.PixelsPerInch.PDF_TO_CSS_UNITS;for(let t of ce(this,y))t.onScaleChanging()}onRotationChanging({pagesRotation:e}){this.commitOrRemove(),this.viewParameters.rotation=e}addToAnnotationStorage(e){!e.isEmpty()&&ce(this,p)&&!ce(this,p).has(e.id)&&ce(this,p).setValue(e.id,e)}copy(e){if(e.preventDefault(),ce(this,c)&&ce(this,c).commitOrRemove(),!this.hasSelection)return;let t=[];for(let i of ce(this,S)){let e=i.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,ie.warn)(`paste: "${e.message}".`)}if(!Array.isArray(t))return;this.unselectAll();let i=ce(this,d).get(ce(this,m));try{let e=[];for(let a of t){let t=i.deserialize(a);if(!t)return;e.push(t)}let n=()=>{for(let t of e)dt(this,Q,J).call(this,t);dt(this,ee,te).call(this,e)},r=()=>{for(let t of e)t.remove()};this.addCommands({cmd:n,undo:r,mustExec:!0})}catch(e){(0,ie.warn)(`paste: "${e.message}".`)}}keydown(e){var t;null!=(t=this.getActive())&&t.shouldGetKeyboardEvents()||he._keyboardManager.exec(this,e)}onEditingAction(e){["undo","redo","delete","selectAll"].includes(e.name)&&this[e.name]()}setEditingState(e){e?(dt(this,O,k).call(this),dt(this,F,B).call(this),dt(this,V,j).call(this,{isEditing:ce(this,w)!==ie.AnnotationEditorType.NONE,isEmpty:dt(this,K,$).call(this),hasSomethingToUndo:ce(this,f).hasSomethingToUndo(),hasSomethingToRedo:ce(this,f).hasSomethingToRedo(),hasSelectedEditor:!1})):(dt(this,N,U).call(this),dt(this,z,H).call(this),dt(this,V,j).call(this,{isEditing:!1}))}registerEditorTypes(e){if(!ce(this,v)){Mt(this,v,e);for(let e of ce(this,v))dt(this,G,W).call(this,e.defaultPropertiesToUpdate)}}getId(){return ce(this,b).getId()}get currentLayer(){return ce(this,d).get(ce(this,m))}get currentPageIndex(){return ce(this,m)}addLayer(e){ce(this,d).set(e.pageIndex,e),ce(this,_)?e.enable():e.disable()}removeLayer(e){ce(this,d).delete(e.pageIndex)}updateMode(e){if(Mt(this,w,e),e===ie.AnnotationEditorType.NONE)this.setEditingState(!1),dt(this,q,Z).call(this);else{this.setEditingState(!0),dt(this,X,Y).call(this);for(let t of ce(this,d).values())t.updateMode(e)}}updateToolbar(e){e!==ce(this,w)&&ce(this,x).dispatch("switchannotationeditormode",{source:this,mode:e})}updateParams(e,t){if(ce(this,v)){for(let i of ce(this,S))i.updateParams(e,t);for(let i of ce(this,v))i.updateDefaultParams(e,t)}}getEditors(e){let t=[];for(let i of ce(this,u).values())i.pageIndex===e&&t.push(i);return t}getEditor(e){return ce(this,u).get(e)}addEditor(e){ce(this,u).set(e.id,e)}removeEditor(e){var t;ce(this,u).delete(e.id),this.unselect(e),(!e.annotationElementId||!ce(this,g).has(e.annotationElementId))&&(null==(t=ce(this,p))||t.remove(e.id))}addDeletedAnnotationElement(e){ce(this,g).add(e.annotationElementId),e.deleted=!0}isDeletedAnnotationElement(e){return ce(this,g).has(e)}removeDeletedAnnotationElement(e){ce(this,g).delete(e.annotationElementId),e.deleted=!1}setActiveEditor(e){ce(this,c)!==e&&(Mt(this,c,e),e&&dt(this,G,W).call(this,e.propertiesToUpdate))}toggleSelected(e){if(ce(this,S).has(e))return ce(this,S).delete(e),e.unselect(),void dt(this,V,j).call(this,{hasSelectedEditor:this.hasSelection});ce(this,S).add(e),e.select(),dt(this,G,W).call(this,e.propertiesToUpdate),dt(this,V,j).call(this,{hasSelectedEditor:!0})}setSelected(e){for(let t of ce(this,S))t!==e&&t.unselect();ce(this,S).clear(),ce(this,S).add(e),e.select(),dt(this,G,W).call(this,e.propertiesToUpdate),dt(this,V,j).call(this,{hasSelectedEditor:!0})}isSelected(e){return ce(this,S).has(e)}unselect(e){e.unselect(),ce(this,S).delete(e),dt(this,V,j).call(this,{hasSelectedEditor:this.hasSelection})}get hasSelection(){return 0!==ce(this,S).size}undo(){ce(this,f).undo(),dt(this,V,j).call(this,{hasSomethingToUndo:ce(this,f).hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:dt(this,K,$).call(this)})}redo(){ce(this,f).redo(),dt(this,V,j).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:ce(this,f).hasSomethingToRedo(),isEmpty:dt(this,K,$).call(this)})}addCommands(e){ce(this,f).add(e),dt(this,V,j).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:dt(this,K,$).call(this)})}delete(){if(this.commitOrRemove(),!this.hasSelection)return;let e=[...ce(this,S)];this.addCommands({cmd:()=>{for(let t of e)t.remove()},undo:()=>{for(let t of e)dt(this,Q,J).call(this,t)},mustExec:!0})}commitOrRemove(){var e;null==(e=ce(this,c))||e.commitOrRemove()}selectAll(){for(let e of ce(this,S))e.commit();dt(this,ee,te).call(this,ce(this,u).values())}unselectAll(){if(ce(this,c))ce(this,c).commitOrRemove();else if(0!==ce(this,S).size){for(let e of ce(this,S))e.unselect();ce(this,S).clear(),dt(this,V,j).call(this,{hasSelectedEditor:!1})}}isActive(e){return ce(this,c)===e}getActive(){return ce(this,c)}getMode(){return ce(this,w)}},ue=he;c=new WeakMap,u=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,D=new WeakMap,L=new WeakMap,I=new WeakMap,O=new WeakSet,k=function(){ce(this,I).addEventListener("keydown",ce(this,A))},N=new WeakSet,U=function(){ce(this,I).removeEventListener("keydown",ce(this,A))},F=new WeakSet,B=function(){document.addEventListener("copy",ce(this,M)),document.addEventListener("cut",ce(this,E)),document.addEventListener("paste",ce(this,T))},z=new WeakSet,H=function(){document.removeEventListener("copy",ce(this,M)),document.removeEventListener("cut",ce(this,E)),document.removeEventListener("paste",ce(this,T))},V=new WeakSet,j=function(e){Object.entries(e).some((([e,t])=>ce(this,L)[e]!==t))&&ce(this,x).dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(ce(this,L),e)})},G=new WeakSet,W=function(e){ce(this,x).dispatch("annotationeditorparamschanged",{source:this,details:e})},X=new WeakSet,Y=function(){if(!ce(this,_)){Mt(this,_,!0);for(let e of ce(this,d).values())e.enable()}},q=new WeakSet,Z=function(){if(this.unselectAll(),ce(this,_)){Mt(this,_,!1);for(let e of ce(this,d).values())e.disable()}},Q=new WeakSet,J=function(e){let t=ce(this,d).get(e.pageIndex);t?t.addOrRebuild(e):this.addEditor(e)},K=new WeakSet,$=function(){if(0===ce(this,u).size)return!0;if(1===ce(this,u).size)for(let e of ce(this,u).values())return e.isEmpty();return!1},ee=new WeakSet,te=function(e){ce(this,S).clear();for(let t of e)t.isEmpty()||(ce(this,S).add(t),t.select());dt(this,V,j).call(this,{hasSelectedEditor:!0})},t.AnnotationEditorUIManager=ue},(e,t,i)=>{var n,r,a,s,o,l,h,c,u,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 i of e.keys()){t.style.color=i;let n=window.getComputedStyle(t).color;e.set(i,G(n))}t.remove()},t.getCurrentTransform=function(e){let{a:t,b:i,c:n,d:r,e:a,f:s}=e.getTransform();return[t,i,n,r,a,s]},t.getCurrentTransformInverse=function(e){let{a:t,b:i,c:n,d:r,e:a,f:s}=e.getTransform().invertSelf();return[t,i,n,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 i=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i,n=/^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/.exec(e),r=i.exec(n[1])||i.exec(n[2])||i.exec(n[3]);if(r&&(r=r[0],r.includes("%")))try{r=i.exec(decodeURIComponent(r))[0]}catch(e){}return r||t},t.getRGB=G,t.getXfaPageViewport=function(e,{scale:t=1,rotation:i=0}){let{width:n,height:r}=e.attributes.style,a=[0,0,parseInt(n),parseInt(r)];return new z({viewBox:a,scale:t,rotation:i})},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(((i,n)=>{let r=document.createElement("script");r.src=e,r.onload=function(e){t&&r.remove(),i(e)},r.onerror=function(){n(new Error(`Cannot load script at: ${r.src}`))},(document.head||document.documentElement).append(r)}))},t.setLayerDimensions=function(e,t,i=!1,n=!0){if(t instanceof z){let{pageWidth:n,pageHeight:r}=t.rawDims,{style:a}=e,s=`calc(var(--scale-factor) * ${n}px)`,o=`calc(var(--scale-factor) * ${r}px)`;i&&t.rotation%180!=0?(a.width=o,a.height=s):(a.width=s,a.height=o)}n&&e.setAttribute("data-main-rotation",t.rotation)};var C=i(7),P=i(1);let R="http://www.w3.org/2000/svg";t.AnnotationPrefix="pdfjs_internal_id_";let D,L=class{},I=L;Yi(I,"CSS",96),Yi(I,"PDF",72),Yi(I,"PDF_TO_CSS_UNITS",L.CSS/L.PDF),t.PixelsPerInch=I;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,n,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,c,void 0),Je(this,u,void 0),Je(this,d,void 0),Je(this,p,0),Mt(this,a,e),Mt(this,s,t)}addFilter(e){if(!e)return"none";let t,i,n,r,s=ce(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=i=n=s.join(",")}else{let[a,s,o]=e,l=new Array(256),h=new Array(256),c=new Array(256);for(let e=0;e<256;e++)l[e]=a[e]/255,h[e]=s[e]/255,c[e]=o[e]/255;t=l.join(","),i=h.join(","),n=c.join(","),r=`${t}${i}${n}`}if(s=ce(this,f,m).get(r),s)return ce(this,f,m).set(e,s),s;let o=`g_${ce(this,a)}_transfer_map_${GT(this,p)._++}`,l=`url(#${o})`;ce(this,f,m).set(e,l),ce(this,f,m).set(r,l);let h=dt(this,b,_).call(this,o);return dt(this,M,E).call(this,t,i,n,h),l}addHCMFilter(e,t){var i;let n=`${e}-${t}`;if(ce(this,l)===n)return ce(this,h);if(Mt(this,l,n),Mt(this,h,"none"),null==(i=ce(this,o))||i.remove(),!e||!t)return ce(this,h);let r=dt(this,T,A).call(this,e);e=P.Util.makeHexColor(...r);let s=dt(this,T,A).call(this,t);if(t=P.Util.makeHexColor(...s),ce(this,g,v).style.color="","#000000"===e&&"#ffffff"===t||e===t)return ce(this,h);let u=new Array(256);for(let a=0;a<=255;a++){let e=a/255;u[a]=e<=.03928?e/12.92:Do((e+.055)/1.055,2.4)}let d=u.join(","),p=`g_${ce(this,a)}_hcm_filter`,f=Mt(this,c,dt(this,b,_).call(this,p));dt(this,M,E).call(this,d,d,d,f),dt(this,y,x).call(this,f);let m=(e,t)=>{let i=r[e]/255,n=s[e]/255,a=new Array(t+1);for(let r=0;r<=t;r++)a[r]=i+r/t*(n-i);return a.join(",")};return dt(this,M,E).call(this,m(0,5),m(1,5),m(2,5),f),Mt(this,h,`url(#${p})`),ce(this,h)}addHighlightHCMFilter(e,t,i,n){var r;let s=`${e}-${t}-${i}-${n}`;if(ce(this,u)===s)return ce(this,d);if(Mt(this,u,s),Mt(this,d,"none"),null==(r=ce(this,c))||r.remove(),!e||!t)return ce(this,d);let[o,l]=[e,t].map(dt(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]=[i,n].map(dt(this,T,A).bind(this));p<h&&([h,p,f,m]=[p,h,m,f]),ce(this,g,v).style.color="";let w=(e,t,i)=>{let n=new Array(256),r=(p-h)/i,a=e/255,s=(t-e)/(255*i),o=0;for(let l=0;l<=i;l++){let e=Math.round(h+l*r),t=a+l*s;for(let i=o;i<=e;i++)n[i]=t;o=e+1}for(let l=o;l<256;l++)n[l]=n[o-1];return n.join(",")},S=`g_${ce(this,a)}_hcm_highlight_filter`,C=Mt(this,c,dt(this,b,_).call(this,S));return dt(this,y,x).call(this,C),dt(this,M,E).call(this,w(f[0],m[0],5),w(f[1],m[1],5),w(f[2],m[2],5),C),Mt(this,d,`url(#${S})`),ce(this,d)}destroy(e=!1){e&&(ce(this,h)||ce(this,d))||(ce(this,r)&&(ce(this,r).parentNode.parentNode.remove(),Mt(this,r,null)),ce(this,n)&&(ce(this,n).clear(),Mt(this,n,null)),Mt(this,p,0))}}n=new WeakMap,r=new WeakMap,a=new WeakMap,s=new WeakMap,o=new WeakMap,l=new WeakMap,h=new WeakMap,c=new WeakMap,u=new WeakMap,d=new WeakMap,p=new WeakMap,f=new WeakSet,m=function(){return ce(this,n)||Mt(this,n,new Map)},g=new WeakSet,v=function(){if(!ce(this,r)){let e=ce(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 i=ce(this,s).createElementNS(R,"svg");i.setAttribute("width",0),i.setAttribute("height",0),Mt(this,r,ce(this,s).createElementNS(R,"defs")),e.append(i),i.append(ce(this,r)),ce(this,s).body.append(e)}return ce(this,r)},y=new WeakSet,x=function(e){let t=ce(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=ce(this,s).createElementNS(R,"filter");return t.setAttribute("color-interpolation-filters","sRGB"),t.setAttribute("id",e),ce(this,g,v).append(t),t},w=new WeakSet,S=function(e,t,i){let n=ce(this,s).createElementNS(R,t);n.setAttribute("type","discrete"),n.setAttribute("tableValues",i),e.append(n)},M=new WeakSet,E=function(e,t,i,n){let r=ce(this,s).createElementNS(R,"feComponentTransfer");n.append(r),dt(this,w,S).call(this,r,"feFuncR",e),dt(this,w,S).call(this,r,"feFuncG",t),dt(this,w,S).call(this,r,"feFuncB",i)},T=new WeakSet,A=function(e){return ce(this,g,v).style.color=e,G(getComputedStyle(ce(this,g,v)).getPropertyValue("color"))},t.DOMFilterFactory=O;class k extends C.BaseCanvasFactory{constructor({ownerDocument:e=globalThis.document}={}){super(),this._document=e}_createCanvas(e,t){let i=this._document.createElement("canvas");return i.width=e,i.height=t,i}}function N(e,t=!1){return ft(this,null,(function*(){if(j(e,document.baseURI)){let i=yield fetch(e);if(!i.ok)throw new Error(i.statusText);return t?new Uint8Array(yield i.arrayBuffer()):(0,P.stringToBytes)(yield i.text())}return new Promise(((i,n)=>{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 i(e)}n(new Error(r.statusText))}},r.send(null)}))}))}t.DOMCanvasFactory=k;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:i,offsetX:n=0,offsetY:r=0,dontFlip:a=!1}){this.viewBox=e,this.scale=t,this.rotation=i,this.offsetX=n,this.offsetY=r;let s,o,l,h,c,u,d,p,f=(e[2]+e[0])/2,m=(e[3]+e[1])/2;switch((i%=360)<0&&(i+=360),i){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?(c=Math.abs(m-e[1])*t+n,u=Math.abs(f-e[0])*t+r,d=(e[3]-e[1])*t,p=(e[2]-e[0])*t):(c=Math.abs(f-e[0])*t+n,u=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,c-s*t*f-l*t*m,u-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:i=this.offsetX,offsetY:n=this.offsetY,dontFlip:r=!1}={}){return new z({viewBox:this.viewBox.slice(),scale:e,rotation:t,offsetX:i,offsetY:n,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),i=P.Util.applyTransform([e[2],e[3]],this.transform);return[t[0],t[1],i[0],i[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,i=0;for(;i<t&&""===e[i].trim();)i++;return"data:"===e.substring(i,i+5).toLowerCase()}function j(e,t){try{let{protocol:i}=t?new URL(e,t):new URL(e);return"http:"===i||"https:"===i}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:i}of this.times)t=Math.max(i.length,t);for(let{name:i,start:n,end:r}of this.times)e.push(`${i.padEnd(t)} ${r-n}ms\n`);return e.join("")}},t.PDFDateString=class{static toDateObject(e){if(!e||"string"!=typeof e)return null;D||(D=new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?"));let t=D.exec(e);if(!t)return null;let i=parseInt(t[1],10),n=parseInt(t[2],10);n=n>=1&&n<=12?n-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 c=parseInt(t[9],10)||0;return c=c>=0&&c<=59?c:0,"-"===l?(a+=h,s+=c):"+"===l&&(a-=h,s-=c),new Date(Date.UTC(i,n,r,a,s,o))}}},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BaseStandardFontDataFactory=t.BaseSVGFactory=t.BaseFilterFactory=t.BaseCanvasFactory=t.BaseCMapReaderFactory=void 0;var n=i(1);class r{constructor(){this.constructor===r&&(0,n.unreachable)("Cannot initialize BaseFilterFactory.")}addFilter(e){return"none"}addHCMFilter(e,t){return"none"}addHighlightHCMFilter(e,t,i,n){return"none"}destroy(e=!1){}}t.BaseFilterFactory=r;class a{constructor(){this.constructor===a&&(0,n.unreachable)("Cannot initialize BaseCanvasFactory.")}create(e,t){if(e<=0||t<=0)throw new Error("Invalid canvas size");let i=this._createCanvas(e,t);return{canvas:i,context:i.getContext("2d")}}reset(e,t,i){if(!e.canvas)throw new Error("Canvas is not specified");if(t<=0||i<=0)throw new Error("Invalid canvas size");e.canvas.width=t,e.canvas.height=i}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,n.unreachable)("Abstract method `_createCanvas` called.")}}t.BaseCanvasFactory=a;class s{constructor({baseUrl:e=null,isCompressed:t=!0}){this.constructor===s&&(0,n.unreachable)("Cannot initialize BaseCMapReaderFactory."),this.baseUrl=e,this.isCompressed=t}fetch(e){return ft(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":""),i=this.isCompressed?n.CMapCompressionType.BINARY:n.CMapCompressionType.NONE;return this._fetchData(t,i).catch((e=>{throw new Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${t}`)}))}))}_fetchData(e,t){(0,n.unreachable)("Abstract method `_fetchData` called.")}}t.BaseCMapReaderFactory=s;class o{constructor({baseUrl:e=null}){this.constructor===o&&(0,n.unreachable)("Cannot initialize BaseStandardFontDataFactory."),this.baseUrl=e}fetch(e){return ft(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,n.unreachable)("Abstract method `_fetchData` called.")}}t.BaseStandardFontDataFactory=o;class l{constructor(){this.constructor===l&&(0,n.unreachable)("Cannot initialize BaseSVGFactory.")}create(e,t,i=!1){if(e<=0||t<=0)throw new Error("Invalid SVG dimensions");let n=this._createSVG("svg:svg");return n.setAttribute("version","1.1"),i||(n.setAttribute("width",`${e}px`),n.setAttribute("height",`${t}px`)),n.setAttribute("preserveAspectRatio","none"),n.setAttribute("viewBox",`0 0 ${e} ${t}`),n}createElement(e){if("string"!=typeof e)throw new Error("Invalid SVG element type");return this._createSVG(e)}_createSVG(e){(0,n.unreachable)("Abstract method `_createSVG` called.")}}t.BaseSVGFactory=l},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.MurmurHash3_64=void 0;var n=i(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,i;if("string"==typeof e){t=new Uint8Array(2*e.length),i=0;for(let n=0,r=e.length;n<r;n++){let r=e.charCodeAt(n);r<=255?t[i++]=r:(t[i++]=r>>>8,t[i++]=255&r)}}else{if(!(0,n.isArrayBuffer)(e))throw new Error("Wrong data format in MurmurHash3_64_update. Input must be a string or array.");t=e.slice(),i=t.byteLength}let r=i>>2,o=i-4*r,l=new Uint32Array(t.buffer,0,r),h=0,c=0,u=this.h1,d=this.h2,p=3432918353,f=461845907,m=p&s,g=f&s;for(let n=0;n<r;n++)1&n?(h=l[n],h=h*p&a|h*m&s,h=h<<15|h>>>17,h=h*f&a|h*g&s,u^=h,u=u<<13|u>>>19,u=5*u+3864292196):(c=l[n],c=c*p&a|c*m&s,c=c<<15|c>>>17,c=c*f&a|c*g&s,d^=c,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?u^=h:d^=h}this.h1=u,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,i)=>{var n;Object.defineProperty(t,"__esModule",{value:!0}),t.FontLoader=t.FontFaceObject=void 0;var r=i(1),a=i(10);n=new WeakMap,t.FontLoader=class{constructor({ownerDocument:e=globalThis.document,styleElement:t=null}){Je(this,n,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(),ce(this,n).clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}loadSystemFont(e){return ft(this,null,(function*(){if(e&&!ce(this,n).has(e.loadedName)){if((0,r.assert)(!this.disableFontFace,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){let{loadedName:i,src:a,style:s}=e,o=new FontFace(i,a,s);this.addNativeFontFace(o);try{yield o.load(),ce(this,n).add(i)}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 ft(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(i){throw(0,r.warn)(`Failed to load font '${t.family}': '${i}'.`),e.disableFontFace=!0,i}}return}let t=e.createFontFaceRule();if(t){if(this.insertRule(t),this.isSyncFontLoadingSupported)return;yield new Promise((t=>{let i=this._queueLoadingCallback(t);this._prepareFontLoadEvent(e,i)}))}}))}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,i={done:!1,complete:function(){for((0,r.assert)(!i.done,"completeRequest() cannot be called twice."),i.done=!0;t.length>0&&t[0].done;){let e=t.shift();setTimeout(e.callback,0)}},callback:e};return t.push(i),i}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 i(e,t){return e.charCodeAt(t)<<24|e.charCodeAt(t+1)<<16|e.charCodeAt(t+2)<<8|255&e.charCodeAt(t+3)}function n(e,t,i,n){return e.substring(0,t)+n+e.substring(t+i)}let a,s,o=this._document.createElement("canvas");o.width=1,o.height=1;let l=o.getContext("2d"),h=0,c=`lt${Date.now()}${this.loadTestFontId++}`,u=this._loadTestFont;u=n(u,976,c.length,c);let d=1482184792,p=i(u,16);for(a=0,s=c.length-3;a<s;a+=4)p=p-d+i(c,a)|0;a<c.length&&(p=p-d+i(c+"XXX",a)|0),u=n(u,16,4,(0,r.string32)(p));let f=`@font-face {font-family:"${c}";src:url(data:font/opentype;base64,${btoa(u)});}`;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,c]){let e=this._document.createElement("span");e.textContent="Hi",e.style.fontFamily=r,m.append(e)}this._document.body.append(m),function e(t,i){if(++h>30)return(0,r.warn)("Load test font never loaded."),void i();l.font="30px "+t,l.fillText(".",0,20),l.getImageData(0,0,1,1).data[3]>0?i():setTimeout(e.bind(null,t,i))}(c,(()=>{m.remove(),t.complete()}))}},t.FontFaceObject=class{constructor(e,{isEvalSupported:t=!0,disableFontFace:i=!1,ignoreErrors:n=!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===i,this.ignoreErrors=!0===n,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,i=(0,r.bytesToString)(this.data),n=`url(data:${this.mimetype};base64,${btoa(i)});`;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:${n}}`}else t=`@font-face {font-family:"${this.loadedName}";src:${n}}`;return null==(e=this._inspectFont)||e.call(this,this,n),t}getPathGenerator(e,t){if(void 0!==this.compiledGlyphs[t])return this.compiledGlyphs[t];let i;try{i=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 i){let i=void 0!==t.args?t.args.join(","):"";e.push("c.",t.cmd,"(",i,");\n")}return this.compiledGlyphs[t]=new Function("c","size",e.join(""))}return this.compiledGlyphs[t]=function(e,t){for(let n of i)"scale"===n.cmd&&(n.args=[t,-t]),e[n.cmd].apply(e,n.args)}}}},(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isNodeJS=void 0;let i=!("object"!=typeof process||process+""!="[object process]"||process.versions.nw||process.versions.electron&&process.type&&"browser"!==process.type);t.isNodeJS=i},(e,t,i)=>{var n,r,a,s;Object.defineProperty(t,"__esModule",{value:!0}),t.CanvasGraphics=void 0;var o=i(1),l=i(6),h=i(12),c=i(13),u=i(10);let d=4096,p=16;class f{constructor(e){this.canvasFactory=e,this.cache=Object.create(null)}getCanvas(e,t,i){let n;return void 0!==this.cache[e]?(n=this.cache[e],this.canvasFactory.reset(n,t,i)):(n=this.canvasFactory.create(t,i),this.cache[e]=n),n}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,i,n,r,a,s,o,h,c){let[u,d,p,f,m,g]=(0,l.getCurrentTransform)(e);if(0===d&&0===p){let l=s*u+m,v=Math.round(l),y=o*f+g,x=Math.round(y),b=(s+h)*u+m,_=Math.abs(Math.round(b)-v)||1,w=(o+c)*f+g,S=Math.abs(Math.round(w)-x)||1;return e.setTransform(Math.sign(u),0,0,Math.sign(f),v,x),e.drawImage(t,i,n,r,a,0,0,_,S),e.setTransform(u,d,p,f,m,g),[_,S]}if(0===u&&0===f){let l=o*p+m,v=Math.round(l),y=s*d+g,x=Math.round(y),b=(o+c)*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,i,n,r,a,0,0,S,_),e.setTransform(u,d,p,f,m,g),[S,_]}return e.drawImage(t,i,n,r,a,s,o,h,c),[Math.hypot(u,d)*h,Math.hypot(p,f)*c]}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,i){[t,i]=o.Util.applyTransform([t,i],e),this.minX=Math.min(this.minX,t),this.minY=Math.min(this.minY,i),this.maxX=Math.max(this.maxX,t),this.maxY=Math.max(this.maxY,i)}updateRectMinMax(e,t){let i=o.Util.applyTransform(t,e),n=o.Util.applyTransform(t.slice(2),e);this.minX=Math.min(this.minX,i[0],n[0]),this.minY=Math.min(this.minY,i[1],n[1]),this.maxX=Math.max(this.maxX,i[0],n[0]),this.maxY=Math.max(this.maxY,i[1],n[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,i,n,r,a,s,l,h,c){let u=o.Util.bezierBoundingBox(t,i,n,r,a,s,l,h);if(c)return c[0]=Math.min(c[0],u[0],u[2]),c[1]=Math.max(c[1],u[0],u[2]),c[2]=Math.min(c[2],u[1],u[3]),void(c[3]=Math.max(c[3],u[1],u[3]));this.updateRectMinMax(e,u)}getPathBoundingBox(e=h.PathType.FILL,t=null){let i=[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),n=e[0]*this.lineWidth/2,r=e[1]*this.lineWidth/2;i[0]-=n,i[1]-=r,i[2]+=n,i[3]+=r}return i}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 i,n,r,a,s,l=t.height,h=t.width,c=l%p,u=(l-c)/p,d=0===c?u:u+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(n=0;n<d;n++){for(a=n<u?p:c,i=0,r=0;r<a;r++){let e=t-m,n=0,r=e>y?h:8*e-7,a=-8&r,o=0,l=0;for(;n<a;n+=8)l=g[m++],s[i++]=128&l?x:b,s[i++]=64&l?x:b,s[i++]=32&l?x:b,s[i++]=16&l?x:b,s[i++]=8&l?x:b,s[i++]=4&l?x:b,s[i++]=2&l?x:b,s[i++]=1&l?x:b;for(;n<r;n++)0===o&&(l=g[m++],o=128),s[i++]=l&o?x:b,o>>=1}for(;i<l;)s[i++]=0;e.putImageData(f,0,n*p)}}else if(t.kind===o.ImageKind.RGBA_32BPP){for(r=0,s=h*p*4,n=0;n<u;n++)v.set(g.subarray(m,m+s)),m+=s,e.putImageData(f,0,r),r+=p;n<d&&(s=h*c*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,n=0;n<d;n++){for(n>=u&&(a=c,s=h*a),i=0,r=s;r--;)v[i++]=g[m++],v[i++]=g[m++],v[i++]=g[m++],v[i++]=255;e.putImageData(f,0,n*p)}}}function y(e,t){if(t.bitmap)return void e.drawImage(t.bitmap,0,0);let i=t.height,n=t.width,r=i%p,a=(i-r)/p,s=0===r?a:a+1,o=e.createImageData(n,p),l=0,h=t.data,u=o.data;for(let d=0;d<s;d++){let t=d<a?p:r;({srcPos:l}=(0,c.convertBlackAndWhiteToRGBA)({src:h,srcPos:l,dest:u,width:n,height:t,nonBlackColor:0})),e.putImageData(o,0,d*p)}}function x(e,t){let i=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"];for(let n of i)void 0!==e[n]&&(t[n]=e[n]);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),u.isNodeJS||(e.filter="none")}function _(e,t,i,n){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]=i,e[a-1]=n;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+i*s>>8,e[a-1]=e[a-1]*r+n*s>>8}}}function w(e,t,i){let n=e.length;for(let r=3;r<n;r+=4){let n=i?i[e[r]]:e[r];t[r]=t[r]*n*.00392156862745098|0}}function S(e,t,i){let n=e.length;for(let r=3;r<n;r+=4){let n=77*e[r-3]+152*e[r-2]+28*e[r-1];t[r]=i?t[r]*i[n>>8]>>8:t[r]*n>>16}}function M(e,t){let i=o.Util.singularValueDecompose2dScale(e);i[0]=Math.fround(i[0]),i[1]=Math.fround(i[1]);let n=Math.fround((globalThis.devicePixelRatio||1)*l.PixelsPerInch.PDF_TO_CSS_UNITS);return void 0!==t?t:i[0]<=n||i[1]<=n}let E=["butt","round","square"],T=["miter","round","bevel"],A={},C={},P=class{constructor(e,t,i,r,s,{optionalContentConfig:o,markedContentStack:l=null},h,c){Je(this,n),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=i,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=c,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:i=!1,background:n=null}){let r=this.ctx.canvas.width,a=this.ctx.canvas.height,s=this.ctx.fillStyle;if(this.ctx.fillStyle=n||"#ffffff",this.ctx.fillRect(0,0,r,a),this.ctx.fillStyle=s,i){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,i,n){let r=e.argsArray,a=e.fnArray,s=t||0,l=r.length;if(l===s)return s;let h,c=l-s>10&&"function"==typeof i,u=c?Date.now()+15:0,d=0,p=this.commonObjs,f=this.objs;for(;;){if(void 0!==n&&s===n.nextBreakPoint)return n.breakIt(s,i),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,i),s}if(s++,s===l)return s;if(c&&++d>10){if(Date.now()>u)return i(),s;d=0}}}endDrawing(){dt(this,n,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(),dt(this,a,s).call(this)}_scaleImage(e,t){let i,n,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,c="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),i=this.cachedCanvases.getCanvas(c,t,r),n=i.context,n.clearRect(0,0,t,r),n.drawImage(e,0,0,l,h,0,0,t,r),e=i.canvas,l=t,h=r,c="prescale1"===c?"prescale2":"prescale1"}return{img:e,paintWidth:l,paintHeight:h}}_createMaskCanvas(e){let t,i,n,r,a=this.ctx,{width:s,height:c}=e,u=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;i=JSON.stringify(d?p:[p.slice(0,4),u]),t=this._cachedBitmapsMap.get(r),t||(t=new Map,this._cachedBitmapsMap.set(r,t));let a=t.get(i);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])};n=a}n||(r=this.cachedCanvases.getCanvas("maskCanvas",s,c),y(r.context,e));let f=o.Util.transform(p,[1/s,0,0,-1/c,0,0]);f=o.Util.transform(f,[1,0,0,1,0,-c]);let g=o.Util.applyTransform([0,0],f),v=o.Util.applyTransform([s,c],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),n||(n=this._scaleImage(r.canvas,(0,l.getCurrentTransformInverse)(S)),n=n.img,t&&d&&t.set(i,n)),S.imageSmoothingEnabled=M((0,l.getCurrentTransform)(S),e.interpolate),m(S,n,0,0,n.width,n.height,0,0,s,c),S.globalCompositeOperation="source-in";let A=o.Util.transform((0,l.getCurrentTransformInverse)(S),[1,0,0,1,-E,-T]);return S.fillStyle=d?u.getPattern(a,this,A,h.PathType.FILL):u,S.fillRect(0,0,s,c),t&&!d&&(this.cachedCanvases.delete("fillCanvas"),t.set(i,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 i=this.ctx;void 0!==i.setLineDash&&(i.setLineDash(e),i.lineDashOffset=t)}setRenderingIntent(e){}setFlatness(e){}setGState(e){for(let[t,i]of e)switch(t){case"LW":this.setLineWidth(i);break;case"LC":this.setLineCap(i);break;case"LJ":this.setLineJoin(i);break;case"ML":this.setMiterLimit(i);break;case"D":this.setDash(i[0],i[1]);break;case"RI":this.setRenderingIntent(i);break;case"FL":this.setFlatness(i);break;case"Font":this.setFont(i[0],i[1]);break;case"CA":this.current.strokeAlpha=i;break;case"ca":this.current.fillAlpha=i,this.ctx.globalAlpha=i;break;case"BM":this.ctx.globalCompositeOperation=i;break;case"SMask":this.current.activeSMask=i?this.tempSMask:null,this.tempSMask=null,this.checkSMaskState();break;case"TR":this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(i)}}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,i="smaskGroupAt"+this.groupLevel,n=this.cachedCanvases.getCanvas(i,e,t);this.suspendedCtx=this.ctx,this.ctx=n.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,i){t.translate(e,i),this.__originalTranslate(e,i)},e.scale=function(e,i){t.scale(e,i),this.__originalScale(e,i)},e.transform=function(e,i,n,r,a,s){t.transform(e,i,n,r,a,s),this.__originalTransform(e,i,n,r,a,s)},e.setTransform=function(e,i,n,r,a,s){t.setTransform(e,i,n,r,a,s),this.__originalSetTransform(e,i,n,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,i){t.moveTo(e,i),this.__originalMoveTo(e,i)},e.lineTo=function(e,i){t.lineTo(e,i),this.__originalLineTo(e,i)},e.bezierCurveTo=function(e,i,n,r,a,s){t.bezierCurveTo(e,i,n,r,a,s),this.__originalBezierCurveTo(e,i,n,r,a,s)},e.rect=function(e,i,n,r){t.rect(e,i,n,r),this.__originalRect(e,i,n,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,i,n){let r=n[0],a=n[1],s=n[2]-r,o=n[3]-a;0===s||0===o||(function(e,t,i,n,r,a,s,o,l,h,c){let u,d=!!a,p=d?a[0]:0,f=d?a[1]:0,m=d?a[2]:0;u="Luminosity"===r?S:w;let g=Math.min(n,Math.ceil(1048576/i));for(let v=0;v<n;v+=g){let r=Math.min(g,n-v),a=e.getImageData(o-h,v+(l-c),i,r),y=t.getImageData(o,v+l,i,r);d&&_(a.data,p,f,m),u(a.data,y.data,s),t.putImageData(y,o,v+l)}}(t.context,i,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(i.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,i,n,r,a){this.ctx.transform(e,t,i,n,r,a),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(e,t,i){let n,r,a=this.ctx,s=this.current,h=s.x,c=s.y,u=(0,l.getCurrentTransform)(a),d=0===u[0]&&0===u[3]||0===u[1]&&0===u[2],p=d?i.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++],c=t[f++];let e=t[f++],i=t[f++],l=h+e,m=c+i;a.moveTo(h,c),0===e||0===i?a.lineTo(l,m):(a.lineTo(l,c),a.lineTo(l,m),a.lineTo(h,m)),d||s.updateRectMinMax(u,[h,c,l,m]),a.closePath();break;case o.OPS.moveTo:h=t[f++],c=t[f++],a.moveTo(h,c),d||s.updatePathMinMax(u,h,c);break;case o.OPS.lineTo:h=t[f++],c=t[f++],a.lineTo(h,c),d||s.updatePathMinMax(u,h,c);break;case o.OPS.curveTo:n=h,r=c,h=t[f+4],c=t[f+5],a.bezierCurveTo(t[f],t[f+1],t[f+2],t[f+3],h,c),s.updateCurvePathMinMax(u,n,r,t[f],t[f+1],t[f+2],t[f+3],h,c,p),f+=6;break;case o.OPS.curveTo2:n=h,r=c,a.bezierCurveTo(h,c,t[f],t[f+1],t[f+2],t[f+3]),s.updateCurvePathMinMax(u,n,r,h,c,t[f],t[f+1],t[f+2],t[f+3],p),h=t[f+2],c=t[f+3],f+=4;break;case o.OPS.curveTo3:n=h,r=c,h=t[f+2],c=t[f+3],a.bezierCurveTo(t[f],t[f+1],h,c,h,c),s.updateCurvePathMinMax(u,n,r,t[f],t[f+1],h,c,h,c,p),f+=4;break;case o.OPS.closePath:a.closePath()}d&&s.updateScalingPathMinMax(u,p),s.setCurrentPoint(h,c)}closePath(){this.ctx.closePath()}stroke(e=!0){let t=this.ctx,i=this.current.strokeColor;t.globalAlpha=this.current.strokeAlpha,this.contentVisible&&("object"==typeof i&&null!=i&&i.getPattern?(t.save(),t.strokeStyle=i.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,i=this.current.fillColor,n=!1;this.current.patternFill&&(t.save(),t.fillStyle=i.getPattern(t,this,(0,l.getCurrentTransformInverse)(t),h.PathType.FILL),n=!0);let r=this.current.getClippedPathBoundingBox();this.contentVisible&&null!==r&&(this.pendingEOFill?(t.fill("evenodd"),this.pendingEOFill=!1):t.fill()),n&&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 i of e)t.setTransform(...i.transform),t.translate(i.x,i.y),i.addToPath(t,i.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 i;let n=this.commonObjs.get(e),r=this.current;if(!n)throw new Error(`Can't find font for ${e}`);if(r.fontMatrix=n.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=n,this.current.fontSize=t,n.isType3Font)return;let a=n.loadedName||"sans-serif",s=(null==(i=n.systemFontInfo)?void 0:i.css)||`"${a}", ${n.fallbackName}`,l="normal";n.black?l="900":n.bold&&(l="bold");let h=n.italic?"italic":"normal",c=t;t<16?c=16:t>100&&(c=100),this.current.fontSizeScale=t/c,this.ctx.font=`${h} ${l} ${c}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,i,n,r,a){this.current.textMatrix=[e,t,i,n,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,i,n){let r,a=this.ctx,s=this.current,h=s.font,c=s.textRenderingMode,u=s.fontSize/s.fontSizeScale,d=c&o.TextRenderingMode.FILL_STROKE_MASK,p=!!(c&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,i),a.beginPath(),r(a,u),n&&a.setTransform(...n),(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,i),(d===o.TextRenderingMode.STROKE||d===o.TextRenderingMode.FILL_STROKE)&&a.strokeText(e,t,i)),p&&(this.pendingTextPaths||(this.pendingTextPaths=[])).push({transform:(0,l.getCurrentTransform)(a),x:t,y:i,fontSize:u,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,i=!1;for(let n=3;n<t.length;n+=4)if(t[n]>0&&t[n]<255){i=!0;break}return(0,o.shadow)(this,"isFontSubpixelAAEnabled",i)}showText(e){let t=this.current,i=t.font;if(i.isType3Font)return this.showType3Text(e);let n=t.fontSize;if(0===n)return;let r,a=this.ctx,s=t.fontSizeScale,c=t.charSpacing,u=t.wordSpacing,d=t.fontDirection,p=t.textHScale*d,f=e.length,m=i.vertical,g=m?1:-1,v=i.defaultVMetrics,y=n*t.fontMatrix[0],x=t.textRenderingMode===o.TextRenderingMode.FILL&&!i.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,i.isInvalidPDFjsFont){let i=[],n=0;for(let t of e)i.push(t.unicode),n+=t.width;return a.fillText(i.join(""),0,0),t.x+=n*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*n/1e3;continue}let o,l,h,p=!1,f=(t.isSpace?u:0)+c,b=t.fontChar,_=t.accent,M=t.width;if(m){let e=t.vmetric||v,i=-(t.vmetric?e[1]:.5*M)*y,n=e[2]*y;M=e?-e[0]:M,o=i/s,l=(S+n)/s}else o=S/s,l=0;if(i.remeasure&&M>0){let e=1e3*a.measureText(b).width/n*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*n/s)}if(this.contentVisible&&(t.isInFont||i.missingFile))if(x&&!_)a.fillText(b,o,l);else if(this.paintChar(b,o,l,r),_){let e=o+n*_.offset.x/s,t=l-n*_.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,i,n,r,a=this.ctx,s=this.current,l=s.font,h=s.fontSize,c=s.fontDirection,u=l.vertical?1:-1,d=s.charSpacing,p=s.wordSpacing,f=s.textHScale*c,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,c),t=0;t<g;++t){if(i=e[t],"number"==typeof i){r=u*i*h/1e3,this.ctx.translate(r,0),s.x+=r*f;continue}let c=(i.isSpace?p:0)+d,g=l.charProcOperatorList[i.operatorListId];g?(this.contentVisible&&(this.processingType3=i,this.save(),a.scale(h,h),a.transform(...m),this.executeOperatorList(g),this.restore()),n=o.Util.applyTransform([i.width,0],m)[0]*h+c,a.translate(n,0),s.x+=n*f):(0,o.warn)(`Type3 character "${i.operatorListId}" is not available.`)}a.restore(),this.processingType3=null}}setCharWidth(e,t){}setCharWidthAndBounds(e,t,i,n,r,a){this.ctx.rect(i,n,r-i,a-n),this.ctx.clip(),this.endPath()}getColorN_Pattern(e){let t;if("TilingPattern"===e[0]){let i=e[1],n=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,i,this.ctx,r,n)}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,i){let n=o.Util.makeHexColor(e,t,i);this.ctx.strokeStyle=n,this.current.strokeColor=n}setFillRGBColor(e,t,i){let n=o.Util.makeHexColor(e,t,i);this.ctx.fillStyle=n,this.current.fillColor=n,this.current.patternFill=!1}_getPattern(e,t=null){let i;return this.cachedPatterns.has(e)?i=this.cachedPatterns.get(e):(i=(0,h.getShadingPattern)(this.getObject(e)),this.cachedPatterns.set(e,i)),t&&(i.matrix=t),i}shadingFill(e){if(!this.contentVisible)return;let t=this.ctx;this.save();let i=this._getPattern(e);t.fillStyle=i.getPattern(t,this,(0,l.getCurrentTransformInverse)(t),h.PathType.SHADING);let n=(0,l.getCurrentTransformInverse)(t);if(n){let{width:e,height:i}=t.canvas,[r,a,s,l]=o.Util.getAxialAlignedBoundingBox([0,0,e,i],n);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],i=t[3]-t[1];this.ctx.rect(t[0],t[1],e,i),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 i=(0,l.getCurrentTransform)(t);if(e.matrix&&t.transform(...e.matrix),!e.bbox)throw new Error("Bounding box is required.");let n=o.Util.getAxialAlignedBoundingBox(e.bbox,(0,l.getCurrentTransform)(t)),r=[0,0,t.canvas.width,t.canvas.height];n=o.Util.intersect(n,r)||[0,0,0,0];let a=Math.floor(n[0]),s=Math.floor(n[1]),h=Math.max(Math.ceil(n[2])-a,1),c=Math.max(Math.ceil(n[3])-s,1),u=1,p=1;h>d&&(u=h/d,h=d),c>d&&(p=c/d,c=d),this.current.startNewPathAndClipBox([0,0,h,c]);let f="groupAt"+this.groupLevel;e.smask&&(f+="_smask_"+this.smaskCounter++%2);let m=this.cachedCanvases.getCanvas(f,h,c),g=m.context;g.scale(1/u,1/p),g.translate(-a,-s),g.transform(...i),e.smask?this.smaskStack.push({canvas:m.canvas,context:g,offsetX:a,offsetY:s,scaleX:u,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(u,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,i=this.groupStack.pop();if(this.ctx=i,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 i=o.Util.getAxialAlignedBoundingBox([0,0,t.canvas.width,t.canvas.height],e);this.ctx.drawImage(t.canvas,0,0),this.ctx.restore(),this.compose(i)}}beginAnnotation(e,t,i,a,s){if(dt(this,n,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 n=t[2]-t[0],r=t[3]-t[1];if(s&&this.annotationCanvasMap){(i=i.slice())[4]-=t[0],i[5]-=t[1],(t=t.slice())[0]=t[1]=0,t[2]=n,t[3]=r;let[a,s]=o.Util.singularValueDecompose2dScale((0,l.getCurrentTransform)(this.ctx)),{viewportScale:h}=this,c=Math.ceil(n*this.outputScaleX*h),u=Math.ceil(r*this.outputScaleY*h);this.annotationCanvas=this.canvasFactory.create(c,u);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],n,r),this.ctx.clip(),this.endPath()}this.current=new g(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(...i),this.transform(...a)}endAnnotation(){this.annotationCanvas&&(this.ctx.restore(),dt(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 i=this.ctx,n=this.processingType3;if(n&&(void 0===n.compiled&&(n.compiled=function(e){let{width:t,height:i}=e;if(t>1e3||i>1e3)return null;let n,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*(i+1)),h=t+7&-8,c=new Uint8Array(h*i),u=0;for(let m of e.data){let e=128;for(;e>0;)c[u++]=m&e?0:255,e>>=1}let d=0;for(u=0,0!==c[u]&&(l[0]=1,++d),r=1;r<t;r++)c[u]!==c[u+1]&&(l[r]=c[u]?2:1,++d),u++;for(0!==c[u]&&(l[r]=2,++d),n=1;n<i;n++){u=n*h,a=n*o,c[u-h]!==c[u]&&(l[a]=c[u]?1:8,++d);let e=(c[u]?4:0)+(c[u-h]?8:0);for(r=1;r<t;r++)e=(e>>2)+(c[u+1]?4:0)+(c[u-h+1]?8:0),s[e]&&(l[a+r]=s[e],++d),u++;if(c[u-h]!==c[u]&&(l[a+r]=c[u]?2:4,++d),d>1e3)return null}for(u=h*(i-1),a=n*o,0!==c[u]&&(l[a]=8,++d),r=1;r<t;r++)c[u]!==c[u+1]&&(l[a+r]=c[u]?4:8,++d),u++;if(0!==c[u]&&(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(n=0;d&&n<=i;n++){let e=n*o,i=e+t;for(;e<i&&!l[e];)e++;if(e===i)continue;f.moveTo(e%o,n);let r=e,a=l[e];do{let t=p[a];do{e+=t}while(!l[e]);let i=l[e];5!==i&&10!==i?(a=i,l[e]=0):(a=i&51*a>>4,l[e]&=a>>2|a<<2),f.lineTo(e%o,e/o|0),l[e]||--d}while(r!==e);--n}return c=null,l=null,function(e){e.save(),e.scale(1/t,-1/i),e.translate(0,-i),e.fill(f),e.beginPath(),e.restore()}}(e)),n.compiled))return void n.compiled(i);let r=this._createMaskCanvas(e),a=r.canvas;i.save(),i.setTransform(1,0,0,1,0,0),i.drawImage(a,r.offsetX,r.offsetY),i.restore(),this.compose()}paintImageMaskXObjectRepeat(e,t,i=0,n=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,i,n,r,0,0);let c=this._createMaskCanvas(e);s.setTransform(1,0,0,1,c.offsetX-h[4],c.offsetY-h[5]);for(let l=0,u=a.length;l<u;l+=2){let e=o.Util.transform(h,[t,i,n,r,a[l],a[l+1]]),[u,d]=o.Util.applyTransform([0,0],e);s.drawImage(c.canvas,u,d)}s.restore(),this.compose()}paintImageMaskXObjectGroup(e){if(!this.contentVisible)return;let t=this.ctx,i=this.current.fillColor,n=this.current.patternFill;for(let r of e){let{data:e,width:a,height:s,transform:o}=r,c=this.cachedCanvases.getCanvas("maskCanvas",a,s),u=c.context;u.save(),y(u,this.getObject(e,r)),u.globalCompositeOperation="source-in",u.fillStyle=n?i.getPattern(u,this,(0,l.getCurrentTransformInverse)(t),h.PathType.FILL):i,u.fillRect(0,0,a,s),u.restore(),t.save(),t.transform(...o),t.scale(1,-1),m(t,c.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,i,n){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=n.length;o<h;o+=2)l.push({transform:[t,0,0,i,n[o],n[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:i,height:n}=e,r=this.cachedCanvases.getCanvas("inlineImage",i,n),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,i=e.width,n=e.height,r=this.ctx;if(this.save(),u.isNodeJS||(r.filter="none"),r.scale(1/i,-1/n),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",i,n).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,-n,i,n),this.compose(),this.restore()}paintInlineImageXObjectGroup(e,t){if(!this.contentVisible)return;let i,n=this.ctx;if(e.bitmap)i=e.bitmap;else{let t=e.width,n=e.height,r=this.cachedCanvases.getCanvas("inlineImage",t,n).context;v(r,e),i=this.applyTransferMapsToCanvas(r)}for(let r of t)n.save(),n.transform(...r.transform),n.scale(1,-1),m(n,i,r.x,r.y,r.w,r.h,0,-1,1,1),n.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 i=this.ctx;this.pendingClip&&(t||(this.pendingClip===C?i.clip("evenodd"):i.clip()),this.pendingClip=null),this.current.startNewPathAndClipBox(this.current.clipBox),i.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]),i=Math.hypot(e[0],e[2]),n=Math.hypot(e[1],e[3]);this._cachedGetSinglePixelWidth=Math.max(i,n)/t}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(-1===this._cachedScaleForStroking[0]){let e,t,{lineWidth:i}=this.current,{a:n,b:r,c:a,d:s}=this.ctx.getTransform();if(0===r&&0===a){let r=Math.abs(n),a=Math.abs(s);if(r===a)if(0===i)e=t=1/r;else{let n=r*i;e=t=n<1?1/n:1}else if(0===i)e=1/r,t=1/a;else{let n=r*i,s=a*i;e=n<1?1/n:1,t=s<1?1/s:1}}else{let o=Math.abs(n*s-r*a),l=Math.hypot(n,r),h=Math.hypot(a,s);if(0===i)e=h/o,t=l/o;else{let n=i*o;e=h>n?h/n:1,t=l>n?l/n:1}}this._cachedScaleForStroking[0]=e,this._cachedScaleForStroking[1]=t}return this._cachedScaleForStroking}rescaleAndStroke(e){let{ctx:t}=this,{lineWidth:i}=this.current,[n,r]=this.getScaleForStroking();if(t.lineWidth=i||1,1===n&&1===r)return void t.stroke();let a=t.getLineDash();if(e&&t.save(),t.scale(n,r),a.length>0){let e=Math.max(n,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;n=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 D in o.OPS)void 0!==R.prototype[D]&&(R.prototype[o.OPS[D]]=R.prototype[D])},(e,t,i)=>{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 u(e);case"Dummy":return new d}throw new Error(`Unknown IR type: ${e[0]}`)};var n=i(1),r=i(6);let a={FILL:"Fill",STROKE:"Stroke",SHADING:"Shading"};function s(e,t){if(!t)return;let i=t[2]-t[0],n=t[3]-t[1],r=new Path2D;r.rect(t[0],t[1],i,n),e.clip(r)}t.PathType=a;class o{constructor(){this.constructor===o&&(0,n.unreachable)("Cannot initialize BaseShadingPattern.")}getPattern(){(0,n.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 i of this._colorStops)t.addColorStop(i[0],i[1]);return t}getPattern(e,t,i,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,c=Math.ceil(a[3]-a[1])||1,u=t.cachedCanvases.getCanvas("pattern",h,c,!0),d=u.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]),i=n.Util.transform(i,[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(u.canvas,"no-repeat");let p=new DOMMatrix(i);l.setTransform(p)}else s(e,this._bbox),l=this._createGradient(e);return l}}function h(e,t,i,n,r,a,s,o){let l,h=t.coords,c=t.colors,u=e.data,d=4*e.width;h[i+1]>h[n+1]&&(l=i,i=n,n=l,l=a,a=s,s=l),h[n+1]>h[r+1]&&(l=n,n=r,r=l,l=s,s=o,o=l),h[i+1]>h[n+1]&&(l=i,i=n,n=l,l=a,a=s,s=l);let p=(h[i]+t.offsetX)*t.scaleX,f=(h[i+1]+t.offsetY)*t.scaleY,m=(h[n]+t.offsetX)*t.scaleX,g=(h[n+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=c[a],C=c[a+1],P=c[a+2],R=c[s],D=c[s+1],L=c[s+2],I=c[o],O=c[o+1],k=c[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-D)*e,w=P-(P-L)*e}else{let e;e=F>y?1:g===y?0:(g-F)/(g-y),x=m-(m-v)*e,b=R-(R-I)*e,_=D-(D-O)*e,w=L-(L-k)*e}let e;e=F<f?0:F>y?1:(f-F)/(f-y),S=p-(p-v)*e,M=A-(A-I)*e,E=C-(C-O)*e,T=P-(P-k)*e;let t=Math.round(Math.min(x,S)),i=Math.round(Math.max(x,S)),n=d*F+4*t;for(let r=t;r<=i;r++)e=(x-r)/(x-S),e<0?e=0:e>1&&(e=1),u[n++]=b-(b-M)*e|0,u[n++]=_-(_-E)*e|0,u[n++]=w-(w-T)*e|0,u[n++]=255}}function c(e,t,i){let n,r,a=t.coords,s=t.colors;switch(t.type){case"lattice":let o=t.verticesPerRow,l=Math.floor(a.length/o)-1,c=o-1;for(n=0;n<l;n++){let t=n*o;for(let n=0;n<c;n++,t++)h(e,i,a[t],a[t+1],a[t+o],s[t],s[t+1],s[t+o]),h(e,i,a[t+o+1],a[t+1],a[t+o],s[t+o+1],s[t+1],s[t+o])}break;case"triangles":for(n=0,r=a.length;n<r;n+=3)h(e,i,a[n],a[n+1],a[n+2],s[n],s[n+1],s[n+2]);break;default:throw new Error("illegal figure")}}class u 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,i){let n=Math.floor(this._bounds[0]),r=Math.floor(this._bounds[1]),a=Math.ceil(this._bounds[2])-n,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,u=s/l,d={coords:this._coords,colors:this._colors,offsetX:-n,offsetY:-r,scaleX:1/h,scaleY:1/u},p=o+4,f=l+4,m=i.getCanvas("mesh",p,f,!1),g=m.context,v=g.createImageData(o,l);if(t){let e=v.data;for(let i=0,n=e.length;i<n;i+=4)e[i]=t[0],e[i+1]=t[1],e[i+2]=t[2],e[i+3]=255}for(let y of this._figures)c(v,y,d);return g.putImageData(v,2,2),{canvas:m.canvas,offsetX:n-2*h,offsetY:r-2*u,scaleX:h,scaleY:u}}getPattern(e,t,i,o){let l;if(s(e,this._bbox),o===a.SHADING)l=n.Util.singularValueDecompose2dScale((0,r.getCurrentTransform)(e));else if(l=n.Util.singularValueDecompose2dScale(t.baseTransform),this.matrix){let e=n.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,i,n,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=i,this.canvasGraphicsFactory=n,this.baseTransform=r}createPatternCanvas(e){let t=this.operatorList,i=this.bbox,a=this.xstep,s=this.ystep,o=this.paintType,l=this.tilingType,h=this.color,c=this.canvasGraphicsFactory;(0,n.info)("TilingType: "+l);let u=i[0],d=i[1],p=i[2],f=i[3],m=n.Util.singularValueDecompose2dScale(this.matrix),g=n.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=c.createCanvasGraphics(_);w.groupLevel=e.groupLevel,this.setFillAndStrokeStyleToContext(w,o,h);let S=u,M=d,E=p,T=f;return u<0&&(S=0,E+=Math.abs(u)),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,i){e=Math.abs(e);let n=Math.max(p.MAX_PATTERN_SIZE,t),r=Math.ceil(e*i);return r>=n?r=n:i=r/e,{scale:i,size:r}}clipBbox(e,t,i,n,a){let s=n-t,o=a-i;e.ctx.rect(t,i,s,o),e.current.updateRectMinMax((0,r.getCurrentTransform)(e.ctx),[t,i,n,a]),e.clip(),e.endPath()}setFillAndStrokeStyleToContext(e,t,i){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=n.Util.makeHexColor(i[0],i[1],i[2]);r.fillStyle=s,r.strokeStyle=s,a.fillColor=s,a.strokeColor=s;break;default:throw new n.FormatError(`Unsupported paint type: ${t}`)}}getPattern(e,t,i,r){let s=i;r!==a.SHADING&&(s=n.Util.transform(s,t.baseTransform),this.matrix&&(s=n.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,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.convertBlackAndWhiteToRGBA=r,t.convertToRGBA=function(e){switch(e.kind){case n.ImageKind.GRAYSCALE_1BPP:return r(e);case n.ImageKind.RGB_24BPP:return function({src:e,srcPos:t=0,dest:i,destPos:r=0,width:a,height:s}){let o=0,l=e.length>>2,h=new Uint32Array(e.buffer,t,l);if(n.FeatureTest.isLittleEndian){for(;o<l-2;o+=3,r+=4){let e=h[o],t=h[o+1],n=h[o+2];i[r]=4278190080|e,i[r+1]=e>>>24|t<<8|4278190080,i[r+2]=t>>>16|n<<16|4278190080,i[r+3]=n>>>8|4278190080}for(let t=4*o,n=e.length;t<n;t+=3)i[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],n=h[o+2];i[r]=255|e,i[r+1]=e<<24|t>>>8|255,i[r+2]=t<<16|n>>>16|255,i[r+3]=n<<8|255}for(let t=4*o,n=e.length;t<n;t+=3)i[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(n.FeatureTest.isLittleEndian)for(let i=0,n=e.length;i<n;i++)t[i]=65793*e[i]|4278190080;else for(let i=0,n=e.length;i<n;i++)t[i]=16843008*e[i]|255};var n=i(1);function r({src:e,srcPos:t=0,dest:i,width:r,height:a,nonBlackColor:s=4294967295,inverseDecode:o=!1}){let l=n.FeatureTest.isLittleEndian?4278190080:255,[h,c]=o?[s,l]:[l,s],u=r>>3,d=7&r,p=e.length;i=new Uint32Array(i.buffer);let f=0;for(let n=0;n<a;n++){for(let r=t+u;t<r;t++){let n=t<p?e[t]:255;i[f++]=128&n?c:h,i[f++]=64&n?c:h,i[f++]=32&n?c:h,i[f++]=16&n?c:h,i[f++]=8&n?c:h,i[f++]=4&n?c:h,i[f++]=2&n?c:h,i[f++]=1&n?c:h}if(0===d)continue;let n=t<p?e[t++]:255;for(let e=0;e<d;e++)i[f++]=n&1<<7-e?c:h}return{srcPos:t,destPos:f}}},(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.GlobalWorkerOptions=void 0;let i=Object.create(null);t.GlobalWorkerOptions=i,i.workerPort=null,i.workerSrc=""},(e,t,i)=>{var n,r,a,s,o,l;Object.defineProperty(t,"__esModule",{value:!0}),t.MessageHandler=void 0;var h=i(1);function c(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())}}n=new WeakSet,r=function(e){let t=e.streamId,i=this.sourceName,n=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:i,targetName:n,stream:4,streamId:t,chunk:e},s)},close(){this.isCancelled||(this.isCancelled=!0,r.postMessage({sourceName:i,targetName:n,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:i,targetName:n,stream:5,streamId:t,reason:c(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:i,targetName:n,stream:8,streamId:t,success:!0})}),(function(e){r.postMessage({sourceName:i,targetName:n,stream:8,streamId:t,reason:c(e)})}))},a=new WeakSet,s=function(e){let t=e.streamId,i=this.sourceName,n=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(c(e.reason));break;case 7:e.success?a.pullCall.resolve():a.pullCall.reject(c(e.reason));break;case 6:if(!s){r.postMessage({sourceName:i,targetName:n,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:i,targetName:n,stream:7,streamId:t,success:!0})}),(function(e){r.postMessage({sourceName:i,targetName:n,stream:7,streamId:t,reason:c(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(),dt(this,o,l).call(this,a,t);break;case 5:(0,h.assert)(a,"error should have stream controller"),a.controller.error(c(e.reason)),dt(this,o,l).call(this,a,t);break;case 2:e.success?a.cancelCall.resolve():a.cancelCall.reject(c(e.reason)),dt(this,o,l).call(this,a,t);break;case 1:if(!s)break;new Promise((function(t){var i;t(null==(i=s.onCancel)?void 0:i.call(s,c(e.reason)))})).then((function(){r.postMessage({sourceName:i,targetName:n,stream:2,streamId:t,success:!0})}),(function(e){r.postMessage({sourceName:i,targetName:n,stream:2,streamId:t,reason:c(e)})})),s.sinkCapability.reject(c(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 ft(this,null,(function*(){var i,n,r;yield Promise.allSettled([null==(i=e.startCall)?void 0:i.promise,null==(n=e.pullCall)?void 0:n.promise,null==(r=e.cancelCall)?void 0:r.promise]),delete this.streamControllers[t]}))},t.MessageHandler=class{constructor(e,t,i){Je(this,n),Je(this,a),Je(this,o),this.sourceName=e,this.targetName=t,this.comObj=i,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 dt(this,a,s).call(this,t);if(t.callback){let e=t.callbackId,i=this.callbackCapabilities[e];if(!i)throw new Error(`Cannot resolve callback ${e}`);if(delete this.callbackCapabilities[e],1===t.callback)i.resolve(t.data);else{if(2!==t.callback)throw new Error("Unexpected callback case");i.reject(c(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,n=t.sourceName;new Promise((function(e){e(o(t.data))})).then((function(r){i.postMessage({sourceName:e,targetName:n,callback:1,callbackId:t.callbackId,data:r})}),(function(r){i.postMessage({sourceName:e,targetName:n,callback:2,callbackId:t.callbackId,reason:c(r)})}))}else t.streamId?dt(this,n,r).call(this,t):o(t.data)},i.addEventListener("message",this._onComObjOnMessage)}on(e,t){let i=this.actionHandler;if(i[e])throw new Error(`There is already an actionName called "${e}"`);i[e]=t}send(e,t,i){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:e,data:t},i)}sendWithPromise(e,t,i){let n=this.callbackId++,r=new h.PromiseCapability;this.callbackCapabilities[n]=r;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:e,callbackId:n,data:t},i)}catch(e){r.reject(e)}return r.promise}sendWithStream(e,t,i,n){let r=this.streamId++,a=this.sourceName,s=this.targetName,o=this.comObj;return new ReadableStream({start:i=>{let l=new h.PromiseCapability;return this.streamControllers[r]={controller:i,startCall:l,pullCall:null,cancelCall:null,isClosed:!1},o.postMessage({sourceName:a,targetName:s,action:e,streamId:r,data:t,desiredSize:i.desiredSize},n),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:c(e)}),t.promise}},i)}destroy(){this.comObj.removeEventListener("message",this._onComObjOnMessage)}}},(e,t,i)=>{var n,r;Object.defineProperty(t,"__esModule",{value:!0}),t.Metadata=void 0;var a=i(1);n=new WeakMap,r=new WeakMap,t.Metadata=class{constructor({parsedData:e,rawData:t}){Je(this,n,void 0),Je(this,r,void 0),Mt(this,n,e),Mt(this,r,t)}getRaw(){return ce(this,r)}get(e){var t;return null!=(t=ce(this,n).get(e))?t:null}getAll(){return(0,a.objectFromMap)(ce(this,n))}has(e){return ce(this,n).has(e)}}},(e,t,i)=>{var n,r,a,s,o,l,h;Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalContentConfig=void 0;var c=i(1),u=i(8);let d=Symbol("INTERNAL");class p{constructor(e,t){Je(this,n,!0),this.name=e,this.intent=t}get visible(){return ce(this,n)}_setVisible(e,t){e!==d&&(0,c.unreachable)("Internal method `_setVisible` called."),Mt(this,n,t)}}n=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 i=e[0];for(let n=1;n<t;n++){let t,r=e[n];if(Array.isArray(r))t=dt(this,l,h).call(this,r);else{if(!ce(this,a).has(r))return(0,c.warn)(`Optional content group not found: ${r}`),!0;t=ce(this,a).get(r).visible}switch(i){case"And":if(!t)return!1;break;case"Or":if(t)return!0;break;case"Not":return!t;default:return!0}}return"And"===i},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,Mt(this,o,e.order);for(let t of e.groups)ce(this,a).set(t.id,new p(t.name,t.intent));if("OFF"===e.baseState)for(let e of ce(this,a).values())e._setVisible(d,!1);for(let t of e.on)ce(this,a).get(t)._setVisible(d,!0);for(let t of e.off)ce(this,a).get(t)._setVisible(d,!1);Mt(this,s,this.getHash())}}isVisible(e){if(0===ce(this,a).size)return!0;if(!e)return(0,c.warn)("Optional content group not defined."),!0;if("OCG"===e.type)return ce(this,a).has(e.id)?ce(this,a).get(e.id).visible:((0,c.warn)(`Optional content group not found: ${e.id}`),!0);if("OCMD"===e.type){if(e.expression)return dt(this,l,h).call(this,e.expression);if(!e.policy||"AnyOn"===e.policy){for(let t of e.ids){if(!ce(this,a).has(t))return(0,c.warn)(`Optional content group not found: ${t}`),!0;if(ce(this,a).get(t).visible)return!0}return!1}if("AllOn"===e.policy){for(let t of e.ids){if(!ce(this,a).has(t))return(0,c.warn)(`Optional content group not found: ${t}`),!0;if(!ce(this,a).get(t).visible)return!1}return!0}if("AnyOff"===e.policy){for(let t of e.ids){if(!ce(this,a).has(t))return(0,c.warn)(`Optional content group not found: ${t}`),!0;if(!ce(this,a).get(t).visible)return!0}return!1}if("AllOff"===e.policy){for(let t of e.ids){if(!ce(this,a).has(t))return(0,c.warn)(`Optional content group not found: ${t}`),!0;if(ce(this,a).get(t).visible)return!1}return!0}return(0,c.warn)(`Unknown optional content policy ${e.policy}.`),!0}return(0,c.warn)(`Unknown group type ${e.type}.`),!0}setVisibility(e,t=!0){ce(this,a).has(e)?(ce(this,a).get(e)._setVisible(d,!!t),Mt(this,r,null)):(0,c.warn)(`Optional content group not found: ${e}`)}get hasInitialVisibility(){return this.getHash()===ce(this,s)}getOrder(){return ce(this,a).size?ce(this,o)?ce(this,o).slice():[...ce(this,a).keys()]:null}getGroups(){return ce(this,a).size>0?(0,c.objectFromMap)(ce(this,a)):null}getGroup(e){return ce(this,a).get(e)||null}getHash(){if(null!==ce(this,r))return ce(this,r);let e=new u.MurmurHash3_64;for(let[t,i]of ce(this,a))e.update(`${t}:${i.visible}`);return Mt(this,r,e.hexdigest())}}},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PDFDataTransportStream=void 0;var n=i(1),r=i(6);t.PDFDataTransportStream=class{constructor({length:e,initialData:t,progressiveDone:i=!1,contentDispositionFilename:r=null,disableRange:a=!1,disableStream:s=!1},o){if((0,n.assert)(o,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.'),this._queuedChunks=[],this._progressiveDone=i,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 i=t instanceof Uint8Array&&t.byteLength===t.buffer.byteLength?t.buffer:new Uint8Array(t).buffer;if(void 0===e)this._fullRequestReader?this._fullRequestReader._enqueue(i):this._queuedChunks.push(i);else{let t=this._rangeReaders.some((function(t){return t._begin===e&&(t._enqueue(i),!0)}));(0,n.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,i,n,r;void 0===e.total?null==(i=null==(t=this._rangeReaders[0])?void 0:t.onProgress)||i.call(t,{loaded:e.loaded}):null==(r=null==(n=this._fullRequestReader)?void 0:n.onProgress)||r.call(n,{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,n.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 i=new s(this,e,t);return this._pdfDataRangeTransport.requestDataRange(e,t),this._rangeReaders.push(i),i}cancelAllRequests(e){var t;null==(t=this._fullRequestReader)||t.cancel(e);for(let i of this._rangeReaders.slice(0))i.cancel(e);this._pdfDataRangeTransport.abort()}};class a{constructor(e,t,i=!1,n=null){this._stream=e,this._done=i||!1,this._filename=(0,r.isPdfFile)(n)?n: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 ft(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 n.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,i){this._stream=e,this._begin=t,this._end=i,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 ft(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 n.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 i{static textContent(e){let t=[],n={items:t,styles:Object.create(null)};return function e(n){var r;if(!n)return;let a=null,s=n.name;if("#text"===s)a=n.value;else{if(!i.shouldBuildText(s))return;null!=(r=null==n?void 0:n.attributes)&&r.textContent?a=n.attributes.textContent:n.value&&(a=n.value)}if(null!==a&&t.push({str:a}),n.children)for(let t of n.children)e(t)}(e),n}static shouldBuildText(e){return!("textarea"===e||"input"===e||"option"===e||"select"===e)}}t.XfaText=i},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.NodeStandardFontDataFactory=t.NodeFilterFactory=t.NodeCanvasFactory=t.NodeCMapReaderFactory=void 0;var n=i(7);let r=function(e){return new Promise(((t,i)=>{PC().readFile(e,((e,n)=>{!e&&n?t(new Uint8Array(n)):i(new Error(e))}))}))};class a extends n.BaseFilterFactory{}t.NodeFilterFactory=a;class s extends n.BaseCanvasFactory{_createCanvas(e,t){return wye().createCanvas(e,t)}}t.NodeCanvasFactory=s;class o extends n.BaseCMapReaderFactory{_fetchData(e,t){return r(e).then((e=>({cMapData:e,compressionType:t})))}}t.NodeCMapReaderFactory=o;class l extends n.BaseStandardFontDataFactory{_fetchData(e){return r(e)}}t.NodeStandardFontDataFactory=l},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PDFNodeStream=void 0;var n=i(1),r=i(22);let a=PC(),s=Sye(),o=Mye(),l=Rye(),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,n.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 i=this.isFsUrl?new g(this,e,t):new f(this,e,t);return this._rangeRequestReaders.push(i),i}cancelAllRequests(e){var t;null==(t=this._fullRequestReader)||t.cancel(e);for(let i of this._rangeRequestReaders.slice(0))i.cancel(e)}};class c{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 n.PromiseCapability,this._headersCapability=new n.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 ft(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 n.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 n.AbortException("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class u{constructor(e){this._url=e.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=new n.PromiseCapability;let t=e.source;this._isStreamingSupported=!t.disableStream}get isStreamingSupported(){return this._isStreamingSupported}read(){return ft(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 n.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 c{constructor(e){super(e);let t=t=>{if(404===t.statusCode){let e=new n.MissingPDFException(`Missing PDF "${this._url}".`);return this._storedError=e,void this._headersCapability.reject(e)}this._headersCapability.resolve(),this._setReadableStream(t);let i=e=>this._readableStream.headers[e.toLowerCase()],{allowRangeRequests:a,suggestedLength:s}=(0,r.validateRangeRequestCapabilities)({getResponseHeader:i,isHttp:e.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=a,this._contentLength=s||this._contentLength,this._filename=(0,r.extractFilenameFromHeader)(i)};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 u{constructor(e,t,i){super(e),this._httpHeaders={};for(let n in e.httpHeaders){let t=e.httpHeaders[n];void 0!==t&&(this._httpHeaders[n]=t)}this._httpHeaders.Range=`bytes=${t}-${i-1}`;let r=e=>{if(404!==e.statusCode)this._setReadableStream(e);else{let e=new n.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 c{constructor(e){super(e);let t=decodeURIComponent(this._url.path);h.test(this._url.href)&&(t=t.replace(/^\//,"")),a.lstat(t,((e,i)=>{if(e)return"ENOENT"===e.code&&(e=new n.MissingPDFException(`Missing PDF "${t}".`)),this._storedError=e,void this._headersCapability.reject(e);this._contentLength=i.size,this._setReadableStream(a.createReadStream(t)),this._headersCapability.resolve()}))}}class g extends u{constructor(e,t,i){super(e);let n=decodeURIComponent(this._url.path);h.test(this._url.href)&&(n=n.replace(/^\//,"")),this._setReadableStream(a.createReadStream(n,{start:t,end:i-1}))}}},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.createResponseStatusError=function(e,t){return 404===e||0===e&&t.startsWith("file:")?new n.MissingPDFException('Missing PDF "'+t+'".'):new n.UnexpectedResponseException(`Unexpected server response (${e}) while retrieving PDF "${t}".`,e)},t.extractFilenameFromHeader=function(e){let t=e("Content-Disposition");if(t){let i=(0,r.getFilenameFromContentDispositionHeader)(t);if(i.includes("%"))try{i=decodeURIComponent(i)}catch(e){}if((0,a.isPdfFile)(i))return i}return null},t.validateRangeRequestCapabilities=function({getResponseHeader:e,isHttp:t,rangeChunkSize:i,disableRange:n}){let r={allowRangeRequests:!1,suggestedLength:void 0},a=parseInt(e("Content-Length"),10);return!Number.isInteger(a)||(r.suggestedLength=a,a<=2*i)||n||!t||"bytes"!==e("Accept-Ranges")||"identity"!==(e("Content-Encoding")||"identity")||(r.allowRangeRequests=!0),r},t.validateResponseStatus=function(e){return 200===e||206===e};var n=i(1),r=i(23),a=i(6)},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getFilenameFromContentDispositionHeader=function(e){let t=!0,i=r("filename\\*","i").exec(e);if(i){i=i[1];let e=o(i);return e=unescape(e),e=l(e),e=h(e),s(e)}if(i=function(e){let t,i=[],n=r("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;null!==(t=n.exec(e));){let[,e,n,r]=t;if(e=parseInt(e,10),e in i){if(0===e)break}else i[e]=[n,r]}let a=[];for(let r=0;r<i.length&&r in i;++r){let[e,t]=i[r];t=o(t),e&&(t=unescape(t),0===r&&(t=l(t))),a.push(t)}return a.join("")}(e),i)return s(h(i));if(i=r("filename","i").exec(e),i){i=i[1];let e=o(i);return e=h(e),s(e)}function r(e,t){return new RegExp("(?:^|;)\\s*"+e+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',t)}function a(e,i){if(e){if(!/^[\x00-\xFF]+$/.test(i))return i;try{let r=new TextDecoder(e,{fatal:!0}),a=(0,n.stringToBytes)(i);i=r.decode(a),t=!1}catch(e){}}return i}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 i=t[e].indexOf('"');-1!==i&&(t[e]=t[e].slice(0,i),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,i,n){if("q"===i||"Q"===i)return a(t,n=(n=n.replaceAll("_"," ")).replaceAll(/=([0-9a-fA-F]{2})/g,(function(e,t){return String.fromCharCode(parseInt(t,16))})));try{n=atob(n)}catch(e){}return a(t,n)}))}return""};var n=i(1)},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PDFNetworkStream=void 0;var n=i(1),r=i(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,i){let n={begin:e,end:t};for(let r in i)n[r]=i[r];return this.request(n)}requestFull(e){return this.request(e)}request(e){let t=new XMLHttpRequest,i=this.currXhrId++,n=this.pendingRequests[i]={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}`),n.expectedStatus=206):n.expectedStatus=200,t.responseType="arraybuffer",e.onError&&(t.onerror=function(i){e.onError(t.status)}),t.onreadystatechange=this.onStateChange.bind(this,i),t.onprogress=this.onProgress.bind(this,i),n.onHeadersReceived=e.onHeadersReceived,n.onDone=e.onDone,n.onError=e.onError,n.onProgress=e.onProgress,t.send(null),i}onProgress(e,t){var i;let n=this.pendingRequests[e];n&&(null==(i=n.onProgress)||i.call(n,t))}onStateChange(e,t){var i,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==(i=s.onError)||i.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,n.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,n.assert)(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new s(this._manager,this._source),this._fullRequestReader}getRangeReader(e,t){let i=new o(this._manager,e,t);return i.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(i),i}cancelAllRequests(e){var t;null==(t=this._fullRequestReader)||t.cancel(e);for(let i of this._rangeRequestReaders.slice(0))i.cancel(e)}};class s{constructor(e,t){this._manager=e;let i={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(i),this._headersReceivedCapability=new n.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),i=e=>t.getResponseHeader(e),{allowRangeRequests:n,suggestedLength:a}=(0,r.validateRangeRequestCapabilities)({getResponseHeader:i,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});n&&(this._isRangeSupported=!0),this._contentLength=a||this._contentLength,this._filename=(0,r.extractFilenameFromHeader)(i),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 ft(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 n.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,i){this._manager=e;let n={onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)};this._url=e.url,this._requestId=e.requestRange(t,i,n),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 i of this._requests)i.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 ft(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 n.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,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PDFFetchStream=void 0;var n=i(1),r=i(22);function a(e,t,i){return{method:"GET",headers:e,signal:i.signal,mode:"cors",credentials:t?"include":"same-origin",redirect:"follow"}}function s(e){let t=new Headers;for(let i in e){let n=e[i];void 0!==n&&t.append(i,n)}return t}function o(e){return e instanceof Uint8Array?e.buffer:e instanceof ArrayBuffer?e:((0,n.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,n.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 i=new h(this,e,t);return this._rangeRequestReaders.push(i),i}cancelAllRequests(e){var t;null==(t=this._fullRequestReader)||t.cancel(e);for(let i of this._rangeRequestReaders.slice(0))i.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 n.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 i=t.url;fetch(i,a(this._headers,this._withCredentials,this._abortController)).then((e=>{if(!(0,r.validateResponseStatus)(e.status))throw(0,r.createResponseStatusError)(e.status,i);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 n.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 ft(this,null,(function*(){var e;yield this._headersCapability.promise;let{value:t,done:i}=yield this._reader.read();return i?{value:t,done:i}:(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,i){this._stream=e,this._reader=null,this._loaded=0;let o=e.source;this._withCredentials=o.withCredentials||!1,this._readCapability=new n.PromiseCapability,this._isStreamingSupported=!o.disableStream,this._abortController=new AbortController,this._headers=s(this._stream.httpHeaders),this._headers.append("Range",`bytes=${t}-${i-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 ft(this,null,(function*(){var e;yield this._readCapability.promise;let{value:t,done:i}=yield this._reader.read();return i?{value:t,done:i}:(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,i)=>{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:i}=e,n=getComputedStyle(t),a=n.getPropertyValue("visibility"),s=parseFloat(n.getPropertyValue("--scale-factor"));"visible"===a&&(!s||Math.abs(s-i.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 c(e);return o._render(),o},t.updateTextLayer=function({container:e,viewport:t,textDivs:i,textDivProperties:n,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 i)r.properties=n.get(t),r.div=t,h(r)}};var n=i(1),r=i(6);let a=30,s=new Map;function o(e,t){let i;if(t&&n.FeatureTest.isOffscreenCanvasSupported)i=new OffscreenCanvas(e,e).getContext("2d",{alpha:!1});else{let t=document.createElement("canvas");t.width=t.height=e,i=t.getContext("2d",{alpha:!1})}return i}function l(e,t,i){let r=document.createElement("span"),l={angle:0,canvasWidth:0,hasText:""!==t.str,hasEOL:t.hasEOL,fontSize:0};e._textDivs.push(r);let h=n.Util.transform(e._transform,t.transform),c=Math.atan2(h[1],h[0]),u=i[t.fontName];u.vertical&&(c+=Math.PI/2);let d,p,f=Math.hypot(h[2],h[3]),m=f*function(e,t){let i=s.get(e);if(i)return i;let n=o(a,t);n.font=`30px ${e}`;let r=n.measureText(""),l=r.fontBoundingBoxAscent,h=Math.abs(r.fontBoundingBoxDescent);if(l){let t=l/(l+h);return s.set(e,t),n.canvas.width=n.canvas.height=0,t}n.strokeStyle="red",n.clearRect(0,0,a,a),n.strokeText("g",0,0);let c=n.getImageData(0,0,a,a).data;h=0;for(let s=c.length-1-3;s>=0;s-=4)if(c[s]>0){h=Math.ceil(s/4/a);break}n.clearRect(0,0,a,a),n.strokeText("A",0,a),c=n.getImageData(0,0,a,a).data,l=0;for(let s=0,o=c.length;s<o;s+=4)if(c[s]>0){l=a-Math.floor(s/4/a);break}if(n.canvas.width=n.canvas.height=0,l){let t=l/(l+h);return s.set(e,t),t}return s.set(e,.8),.8}(u.fontFamily,e._isOffscreenCanvasSupported);0===c?(d=h[4],p=h[5]-m):(d=h[4]+m*Math.sin(c),p=h[5]-m*Math.cos(c));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=u.fontFamily,l.fontSize=f,r.setAttribute("role","presentation"),r.textContent=t.str,r.dir=t.dir,e._fontInspectorEnabled&&(r.dataset.fontName=t.fontName),0!==c&&(l.angle=c*(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]),i=Math.abs(t.transform[3]);e!==i&&Math.max(e,i)/Math.min(e,i)>1.5&&(y=!0)}y&&(l.canvasWidth=u.vertical?t.height:t.width),e._textDivProperties.set(r,l),e._isReadableStream&&e._layoutText(r)}function h(e){let{div:t,scale:i,properties:n,ctx:r,prevFontSize:a,prevFontFamily:s}=e,{style:o}=t,l="";if(0!==n.canvasWidth&&n.hasText){let{fontFamily:h}=o,{canvasWidth:c,fontSize:u}=n;(a!==u||s!==h)&&(r.font=`${u*i}px ${h}`,e.prevFontSize=u,e.prevFontFamily=h);let{width:d}=r.measureText(t.textContent);d>0&&(l=`scaleX(${c*i/d})`)}0!==n.angle&&(l=`rotate(${n.angle}deg) ${l}`),l.length>0&&(o.transform=l)}class c{constructor({textContentSource:e,container:t,viewport:i,textDivs:a,textDivProperties:s,textContentItemsStr:l,isOffscreenCanvasSupported:h}){var c;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==(c=globalThis.FontInspector)||!c.enabled),this._reader=null,this._textDivProperties=s||new WeakMap,this._canceled=!1,this._capability=new n.PromiseCapability,this._layoutTextParams={prevFontSize:null,prevFontFamily:null,div:null,scale:i.scale*(globalThis.devicePixelRatio||1),properties:null,ctx:o(0,h)};let{pageWidth:u,pageHeight:d,pageX:p,pageY:f}=i.rawDims;this._transform=[1,0,0,-1,-p,f+d],this._pageWidth=u,this._pageHeight=d,(0,r.setLayerDimensions)(t,i),this._capability.promise.finally((()=>{this._layoutTextParams=null})).catch((()=>{}))}get promise(){return this._capability.promise}cancel(){this._canceled=!0,this._reader&&(this._reader.cancel(new n.AbortException("TextLayer task cancelled.")).catch((()=>{})),this._reader=null),this._capability.reject(new n.AbortException("TextLayer task cancelled."))}_processItems(e,t){for(let i of e)if(void 0!==i.str)this._textContentItemsStr.push(i.str),l(this,i,t);else if("beginMarkedContentProps"===i.type||"beginMarkedContent"===i.type){let e=this._container;this._container=document.createElement("span"),this._container.classList.add("markedContent"),null!==i.id&&this._container.setAttribute("id",`${i.id}`),e.append(this._container)}else"endMarkedContent"===i.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 n.PromiseCapability,t=Object.create(null);if(this._isReadableStream){let i=()=>{this._reader.read().then((({value:n,done:r})=>{r?e.resolve():(Object.assign(t,n.styles),this._processItems(n.items,t),i())}),e.reject)};this._reader=this._textContentSource.getReader(),i()}else{if(!this._textContentSource)throw new Error('No "textContentSource" parameter specified.');{let{items:t,styles:i}=this._textContentSource;this._processItems(t,i),e.resolve()}}e.promise.then((()=>{t=null,function(e){if(e._canceled)return;let t=e._textDivs,i=e._capability;if(t.length>1e5)i.resolve();else{if(!e._isReadableStream)for(let i of t)e._layoutText(i);i.resolve()}}(this)}),this._capability.reject)}}t.TextLayerRenderTask=c},(e,t,i)=>{var n,r,a,s,o,l,h,c,u,d,p,f,m,g,v,y,x,b;Object.defineProperty(t,"__esModule",{value:!0}),t.AnnotationEditorLayer=void 0;var _=i(1),w=i(4),S=i(5),M=i(28),E=i(33),T=i(6);let A=class{constructor(e){Je(this,p),Je(this,m),Je(this,v),Je(this,x),Je(this,n,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,c,!1),Je(this,u,!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]),Mt(this,d,e.uiManager),this.pageIndex=e.pageIndex,this.div=e.div,Mt(this,n,e.accessibilityManager),Mt(this,a,e.annotationLayer),this.viewport=e.viewport,ce(this,d).addLayer(this)}get isEmpty(){return 0===ce(this,l).size}updateToolbar(e){ce(this,d).updateToolbar(e)}updateMode(e=ce(this,d).getMode()){dt(this,x,b).call(this),e===_.AnnotationEditorType.INK?(this.addInkEditorIfNeeded(!1),this.disableClick()):this.enableClick(),ce(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||ce(this,d).getMode()===_.AnnotationEditorType.INK){if(!e)for(let e of ce(this,l).values())if(e.isEmpty())return void e.setInBackground();dt(this,v,y).call(this,{offsetX:0,offsetY:0}).setInBackground()}}setEditingState(e){ce(this,d).setEditingState(e)}addCommands(e){ce(this,d).addCommands(e)}enable(){this.div.style.pointerEvents="auto";let e=new Set;for(let i of ce(this,l).values())i.enableEditing(),i.annotationElementId&&e.add(i.annotationElementId);if(!ce(this,a))return;let t=ce(this,a).getEditableAnnotations();for(let i of t){if(i.hide(),ce(this,d).isDeletedAnnotationElement(i.data.id)||e.has(i.data.id))continue;let t=this.deserialize(i);t&&(this.addOrRebuild(t),t.enableEditing())}}disable(){var e;Mt(this,u,!0),this.div.style.pointerEvents="none";let t=new Set;for(let i of ce(this,l).values())i.disableEditing(),i.annotationElementId&&null===i.serialize()?(null==(e=this.getEditableAnnotation(i.annotationElementId))||e.show(),i.remove()):t.add(i.annotationElementId);if(ce(this,a)){let e=ce(this,a).getEditableAnnotations();for(let i of e){let{id:e}=i.data;t.has(e)||ce(this,d).isDeletedAnnotationElement(e)||i.show()}}dt(this,x,b).call(this),this.isEmpty&&(this.div.hidden=!0),Mt(this,u,!1)}getEditableAnnotation(e){var t;return(null==(t=ce(this,a))?void 0:t.getEditableAnnotation(e))||null}setActiveEditor(e){ce(this,d).getActive()!==e&&ce(this,d).setActiveEditor(e)}enableClick(){this.div.addEventListener("pointerdown",ce(this,o)),this.div.addEventListener("pointerup",ce(this,s))}disableClick(){this.div.removeEventListener("pointerdown",ce(this,o)),this.div.removeEventListener("pointerup",ce(this,s))}attach(e){ce(this,l).set(e.id,e);let{annotationElementId:t}=e;t&&ce(this,d).isDeletedAnnotationElement(t)&&ce(this,d).removeDeletedAnnotationElement(e)}detach(e){var t;ce(this,l).delete(e.id),null==(t=ce(this,n))||t.removePointerInTextLayer(e.contentDiv),!ce(this,u)&&e.annotationElementId&&ce(this,d).addDeletedAnnotationElement(e)}remove(e){this.detach(e),ce(this,d).removeEditor(e),e.div.style.display="none",setTimeout((()=>{e.div.style.display="",e.div.remove(),e.isAttachedToDOM=!1,document.activeElement===document.body&&ce(this,d).focusMainContainer()}),0),ce(this,c)||this.addInkEditorIfNeeded(!1)}add(e){if(dt(this,p,f).call(this,e),ce(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(),ce(this,d).addToAnnotationStorage(e)}moveEditorInDOM(e){var t;null==(t=ce(this,n))||t.moveElementInDOM(this.div,e.div,e.contentDiv,!0)}addOrRebuild(e){e.needsToBeRebuilt()?e.rebuild():this.add(e)}getNextId(){return ce(this,d).getId()}deserialize(e){var t;switch(null!=(t=e.annotationType)?t:e.annotationEditorType){case _.AnnotationEditorType.FREETEXT:return M.FreeTextEditor.deserialize(e,this,ce(this,d));case _.AnnotationEditorType.INK:return E.InkEditor.deserialize(e,this,ce(this,d))}return null}setSelected(e){ce(this,d).setSelected(e)}toggleSelected(e){ce(this,d).toggleSelected(e)}isSelected(e){return ce(this,d).isSelected(e)}unselect(e){ce(this,d).unselect(e)}pointerup(e){let{isMac:t}=_.FeatureTest.platform;if(!(0!==e.button||e.ctrlKey&&t)&&e.target===this.div&&ce(this,h)){if(Mt(this,h,!1),!ce(this,r))return void Mt(this,r,!0);dt(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;Mt(this,h,!0);let i=ce(this,d).getActive();Mt(this,r,!i||i.isEmpty())}drop(e){let t=e.dataTransfer.getData("text/plain"),i=ce(this,d).getEditor(t);if(!i)return;e.preventDefault(),e.dataTransfer.dropEffect="move",dt(this,p,f).call(this,i);let n=this.div.getBoundingClientRect(),r=e.clientX-n.x,a=e.clientY-n.y;i.translate(r-i.startX,a-i.startY),this.moveEditorInDOM(i),i.div.focus()}dragover(e){e.preventDefault()}destroy(){var e,t;(null==(e=ce(this,d).getActive())?void 0:e.parent)===this&&ce(this,d).setActiveEditor(null);for(let i of ce(this,l).values())null==(t=ce(this,n))||t.removePointerInTextLayer(i.contentDiv),i.setParent(null),i.isAttachedToDOM=!1,i.div.remove();this.div=null,ce(this,l).clear(),ce(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 ce(this,d).getEditors(this.pageIndex))this.add(t);this.updateMode()}update({viewport:e}){ce(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;n=new WeakMap,r=new WeakMap,a=new WeakMap,s=new WeakMap,o=new WeakMap,l=new WeakMap,h=new WeakMap,c=new WeakMap,u=new WeakMap,d=new WeakMap,p=new WeakSet,f=function(e){var t;e.parent!==this&&(e.annotationElementId&&(ce(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(ce(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(),i=dt(this,m,g).call(this,{parent:this,id:t,x:e.offsetX,y:e.offsetY,uiManager:ce(this,d)});return i&&this.add(i),i},x=new WeakSet,b=function(){Mt(this,c,!0);for(let e of ce(this,l).values())e.isEmpty()&&e.remove();Mt(this,c,!1)},Yi(C,"_initialized",!1),t.AnnotationEditorLayer=C},(e,t,i)=>{var n,r,a,s,o,l,h,c,u,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=i(1),A=i(5),C=i(4),P=i(29);let R=class extends C.AnnotationEditor{constructor(e){super(Ii(Tr({},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,n,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,c,void 0),Je(this,u,null),Mt(this,o,e.color||R._defaultColor||C.AnnotationEditor._defaultLineColor),Mt(this,c,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:dt(this,d,p).call(this,t);break;case T.AnnotationEditorParamsType.FREETEXT_COLOR:dt(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,ce(this,c)],[T.AnnotationEditorParamsType.FREETEXT_COLOR,ce(this,o)]]}getInitialTranslation(){let e=this.parentScale;return[-R._internalPadding*e,-(R._internalPadding+ce(this,c))*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",ce(this,s)),this.editorDiv.addEventListener("focus",ce(this,r)),this.editorDiv.addEventListener("blur",ce(this,n)),this.editorDiv.addEventListener("input",ce(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",ce(this,h)),this.div.draggable=!0,this.editorDiv.removeEventListener("keydown",ce(this,s)),this.editorDiv.removeEventListener("focus",ce(this,r)),this.editorDiv.removeEventListener("blur",ce(this,n)),this.editorDiv.removeEventListener("input",ce(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?dt(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=ce(this,l),t=Mt(this,l,dt(this,g,v).call(this).trimEnd());if(e===t)return;let i=e=>{Mt(this,l,e),e?(dt(this,b,_).call(this),this.rebuild(),dt(this,y,x).call(this)):this.remove()};this.addCommands({cmd:()=>{i(t)},undo:()=>{i(e)},mustExec:!1}),dt(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",ce(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:i}=this.editorDiv;if(i.fontSize=`calc(${ce(this,c)}px * var(--scale-factor))`,i.color=ce(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[i,n]=this.parentDimensions;if(this.annotationElementId){let[r]=this.getInitialTranslation();this.setAt(e*i,t*n,r,r)}else this.setAt(e*i,t*n,this.width*i,this.height*n);dt(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,i){let n=null;if(e instanceof P.FreeTextAnnotationElement){let{data:{defaultAppearanceData:{fontSize:t,fontColor:i},rect:r,rotation:a,id:s},textContent:o,parent:{page:{pageNumber:l}}}=e;if(!o||0===o.length)return null;n=e={annotationType:T.AnnotationEditorType.FREETEXT,color:Array.from(i),fontSize:t,value:o.join("\n"),pageIndex:l-1,rect:r,rotation:a,id:s,deleted:!1}}let r=super.deserialize(e,t,i);return Mt(r,c,e.fontSize),Mt(r,o,T.Util.makeHexColor(...e.color)),Mt(r,l,e.value),r.annotationElementId=e.id||null,Mt(r,u,n),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,i=this.getRect(t,t),n=C.AnnotationEditor._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:ce(this,o)),r={annotationType:T.AnnotationEditorType.FREETEXT,color:n,fontSize:ce(this,c),value:ce(this,l),pageIndex:this.pageIndex,rect:i,rotation:this.rotation};return e?r:this.annotationElementId&&!dt(this,w,S).call(this,r)?null:(r.id=this.annotationElementId,r)}},D=R;n=new WeakMap,r=new WeakMap,a=new WeakMap,s=new WeakMap,o=new WeakMap,l=new WeakMap,h=new WeakMap,c=new WeakMap,u=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-ce(this,c))*this.parentScale),Mt(this,c,e),dt(this,y,x).call(this)},i=ce(this,c);this.addCommands({cmd:()=>{t(e)},undo:()=>{t(i)},mustExec:!0,type:T.AnnotationEditorParamsType.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})},f=new WeakSet,m=function(e){let t=ce(this,o);this.addCommands({cmd:()=>{Mt(this,o,this.editorDiv.style.color=e)},undo:()=>{Mt(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 i of e)t.push(i.innerText.replace(/\r\n?|\n/,""));return t.join("\n")},y=new WeakSet,x=function(){let e,[t,i]=this.parentDimensions;if(this.isAttachedToDOM)e=this.div.getBoundingClientRect();else{let{currentLayer:t,div:i}=this,n=i.style.display;i.style.display="hidden",t.div.append(this.div),e=i.getBoundingClientRect(),i.remove(),i.style.display=n}this.width=e.width/t,this.height=e.height/i},b=new WeakSet,_=function(){if(this.editorDiv.replaceChildren(),ce(this,l))for(let e of ce(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:i,color:n,rect:r,pageIndex:a}=ce(this,u);return e.value!==t||e.fontSize!==i||e.rect.some(((e,t)=>Math.abs(e-r[t])>=1))||e.color.some(((e,t)=>e!==n[t]))||e.pageIndex!==a},M=new WeakSet,E=function(e=!1){if(!this.annotationElementId)return;if(dt(this,y,x).call(this),!e&&(0===this.width||0===this.height))return void setTimeout((()=>dt(this,M,E).call(this,!0)),0);let t=R._internalPadding*this.parentScale;ce(this,u).rect=this.getRect(t,t)},Yi(D,"_freeTextDefaultContent",""),Yi(D,"_l10nPromise"),Yi(D,"_internalPadding",0),Yi(D,"_defaultColor",null),Yi(D,"_defaultFontSize",10),Yi(D,"_type","freetext"),t.FreeTextEditor=D},(e,t,i)=>{var n,r,a,s,o,l,h,c,u,d,p,f,m,g,v,y,x,b,_,w,S,M,E,T,A,C,P,R,D,L,I,O,k,N,U,F,B,z,H;Object.defineProperty(t,"__esModule",{value:!0}),t.InkAnnotationElement=t.FreeTextAnnotationElement=t.AnnotationLayer=void 0;var V=i(1),j=i(6),G=i(3),W=i(30),X=i(31);let Y=1e3,q=new WeakSet;function Z(e){return{width:e[2]-e[0],height:e[3]-e[1]}}class Q{static create(e){switch(e.data.annotationType){case V.AnnotationType.LINK:return new K(e);case V.AnnotationType.TEXT:return new $(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 ne(e):new ae(e);case"Ch":return new se(e);case"Sig":return new ie(e)}return new ee(e);case V.AnnotationType.POPUP:return new oe(e);case V.AnnotationType.FREETEXT:return new he(e);case V.AnnotationType.LINE:return new ue(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 J(e)}}}class J{constructor(e,{isRenderable:t=!1,ignoreBorder:i=!1,createQuadrilaterals:n=!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(i)),n&&(this.quadrilaterals=this._createQuadrilaterals(i))}_createContainer(e){let{data:t,parent:{page:i,viewport:n}}=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}=n.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:c}=Z(t.rect),u=V.Util.normalizeRect([t.rect[0],i.view[3]-t.rect[1]+i.view[1],t.rect[2],i.view[3]-t.rect[3]+i.view[1]]);if(!e&&t.borderStyle.width>0){r.style.borderWidth=`${t.borderStyle.width}px`;let e=t.borderStyle.horizontalCornerRadius,i=t.borderStyle.verticalCornerRadius;if(e>0||i>0){let t=`calc(${e}px * var(--scale-factor)) / calc(${i}px * var(--scale-factor))`;r.style.borderRadius=t}else if(this instanceof re){let e=`calc(${h}px * var(--scale-factor)) / calc(${c}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 n=t.borderColor||null;n?r.style.borderColor=V.Util.makeHexColor(0|n[0],0|n[1],0|n[2]):r.style.borderWidth=0}r.style.left=100*(u[0]-o)/a+"%",r.style.top=100*(u[1]-l)/s+"%";let{rotation:d}=t;return t.hasOwnCanvas||0===d?(r.style.width=100*h/a+"%",r.style.height=100*c/s+"%"):this.setRotation(d,r),r}setRotation(e,t=this.container){let i,n,{pageWidth:r,pageHeight:a}=this.parent.viewport.rawDims,{width:s,height:o}=Z(this.data.rect);e%180==0?(i=100*s/r,n=100*o/a):(i=100*o/r,n=100*s/a),t.style.width=`${i}%`,t.style.height=`${n}%`,t.setAttribute("data-main-rotation",(360-e)%360)}get _commonActions(){let e=(e,t,i)=>{let n=i.detail[e];i.target.style[t]=W.ColorConverters[`${n[0]}_HTML`](n.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 i=this._commonActions;for(let n of Object.keys(t.detail)){let r=e[n]||i[n];null==r||r(t)}}_setDefaultPropertiesFromJS(e){if(!this.enableScripting)return;let t=this.annotationStorage.getRawValue(this.data.id);if(!t)return;let i=this._commonActions;for(let[n,r]of Object.entries(t)){let a=i[n];a&&(a({detail:{[n]:r},target:e}),delete t[n])}}_createQuadrilaterals(e=!1){if(!this.data.quadPoints)return null;let t=[],i=this.data.rect,n=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)),n||(n=this.data.rect);return this.data.rect=i,this.firstQuadRect=n,t}_createPopup(){let{container:e,data:t}=this;e.setAttribute("aria-haspopup","dialog");let i=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(i.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 i=[];if(this._fieldObjects){let n=this._fieldObjects[e];if(n)for(let{page:e,id:r,exportValues:a}of n){if(-1===e||r===t)continue;let n="string"==typeof a?a:null,s=document.querySelector(`[data-element-id="${r}"]`);!s||q.has(s)?i.push({id:r,exportValue:n,domElement:s}):(0,V.warn)(`_getElementsByName - element not allowed: ${r}`)}return i}for(let n of document.getElementsByName(e)){let{exportValue:e}=n,r=n.getAttribute("data-element-id");r!==t&&q.has(n)&&i.push({id:r,exportValue:e,domElement:n})}return i}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 K extends J{constructor(e,t=null){super(e,{isRenderable:!0,ignoreBorder:!(null==t||!t.ignoreBorder),createQuadrilaterals:!0}),Je(this,n),Je(this,a),this.isTooltipOnly=e.data.isTooltipOnly}render(){let{data:e,linkService:t}=this,i=document.createElement("a");i.setAttribute("data-element-id",e.id);let n=!1;return e.url?(t.addLinkAttributes(i,e.url,e.newWindow),n=!0):e.action?(this._bindNamedAction(i,e.action),n=!0):e.attachment?(this._bindAttachment(i,e.attachment),n=!0):e.setOCGState?(dt(this,a,s).call(this,i,e.setOCGState),n=!0):e.dest?(this._bindLink(i,e.dest),n=!0):(e.actions&&(e.actions.Action||e.actions["Mouse Up"]||e.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(i,e),n=!0),e.resetForm?(this._bindResetFormAction(i,e.resetForm),n=!0):this.isTooltipOnly&&!n&&(this._bindLink(i,""),n=!0)),this.quadrilaterals?this._renderQuadrilaterals("linkAnnotation").map(((e,t)=>{let n=0===t?i:i.cloneNode();return e.append(n),e})):(this.container.classList.add("linkAnnotation"),n&&this.container.append(i),this.container)}_bindLink(e,t){e.href=this.linkService.getDestinationHash(t),e.onclick=()=>(t&&this.linkService.goToDestination(t),!1),(t||""===t)&&dt(this,n,r).call(this)}_bindNamedAction(e,t){e.href=this.linkService.getAnchorUrl(""),e.onclick=()=>(this.linkService.executeNamedAction(t),!1),dt(this,n,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},dt(this,n,r).call(this)}_bindJSAction(e,t){e.href=this.linkService.getAnchorUrl("");let i=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(let n of Object.keys(t.actions)){let r=i.get(n);r&&(e[r]=()=>{var e;return null==(e=this.linkService.eventBus)||e.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t.id,name:n}}),!1})}e.onclick||(e.onclick=()=>!1),dt(this,n,r).call(this)}_bindResetFormAction(e,t){let i=e.onclick;if(i||(e.href=this.linkService.getAnchorUrl("")),dt(this,n,r).call(this),!this._fieldObjects)return(0,V.warn)('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),void(i||(e.onclick=()=>!1));e.onclick=()=>{var e;null==i||i();let{fields:n,refs:r,include:a}=t,s=[];if(0!==n.length||0!==r.length){let e=new Set(r);for(let t of n){let i=this._fieldObjects[t]||[];for(let{id:t}of i)e.add(t)}for(let t of Object.values(this._fieldObjects))for(let i of t)e.has(i.id)===a&&s.push(i)}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 i=t.defaultValue||"";o.setValue(e,{value:i});break}case"checkbox":case"radiobutton":{let i=t.defaultValue===t.exportValues;o.setValue(e,{value:i});break}case"combobox":case"listbox":{let i=t.defaultValue||"";o.setValue(e,{value:i});break}default:continue}let i=document.querySelector(`[data-element-id="${e}"]`);i&&(q.has(i)?i.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}}}n=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),dt(this,n,r).call(this)};class $ extends J{constructor(e){var t,i,n;super(e,{isRenderable:!!(e.data.popupRef||null!=(t=e.data.titleObj)&&t.str||null!=(i=e.data.contentsObj)&&i.str||null!=(n=e.data.richText)&&n.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 J{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:i}=V.FeatureTest.platform;return t&&e.ctrlKey||i&&e.metaKey}_setEventListener(e,t,i,n){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:i,value:n(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:i,value:n(e)}})}))}_setEventListeners(e,t,i){var n;for(let[r,a]of t)("Action"===a||null!=(n=this.data.actions)&&n[a])&&this._setEventListener(e,r,a,i)}_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:i}=this.data.defaultAppearanceData,n=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),i=e/(Math.round(e/(V.LINE_FACTOR*n))||1);t=Math.min(n,a(i/V.LINE_FACTOR))}else{let e=Math.abs(this.data.rect[3]-this.data.rect[1]-2);t=Math.min(n,a(e/V.LINE_FACTOR))}r.fontSize=`calc(${t}px * var(--scale-factor))`,r.color=V.Util.makeHexColor(i[0],i[1],i[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,i,n){let r=this.annotationStorage;for(let a of this._getElementsByName(e.name,e.id))a.domElement&&(a.domElement[t]=i),r.setValue(a.id,{[n]:i})}render(){var e,t;let i=this.annotationStorage,n=this.data.id;this.container.classList.add("textWidgetAnnotation");let r=null;if(this.renderForms){let a=i.getValue(n,{value:this.data.fieldValue}),s=a.value||"",o=i.getValue(n,{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",n),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=>{i.setValue(n,{value:e.target.value}),this.setPropertyOnSiblings(r,"value",e.target.value,"value"),h.formattedValue=null})),r.addEventListener("resetform",(e=>{var t;let i=null!=(t=this.data.defaultFieldValue)?t:"";r.value=h.userValue=i,h.formattedValue=null}));let c=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:"",i.setValue(n,{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),i.setValue(n,{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,i.setValue(n,{value:s}),null==(t=this.linkService.eventBus)||t.dispatch("dispatcheventinsandbox",{source:this,detail:{id:n,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 i=-1;if("Escape"===e.key?i=0:"Enter"!==e.key||this.data.multiLine?"Tab"===e.key&&(h.commitKey=3):i=2,-1===i)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:n,name:"Keystroke",value:r,willCommit:!0,commitKey:i,selStart:e.target.selectionStart,selEnd:e.target.selectionEnd}}))}));let e=c;c=null,r.addEventListener("blur",(t=>{var i;if(!t.relatedTarget)return;let{value:r}=t.target;h.userValue=r,h.lastCommittedValue!==r&&(null==(i=this.linkService.eventBus)||i.dispatch("dispatcheventinsandbox",{source:this,detail:{id:n,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:i,target:r}=e,{value:a,selectionStart:s,selectionEnd:o}=r,l=s,c=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&&(c+=e[0].length);break}case"deleteContentBackward":s===o&&(l-=1);break;case"deleteContentForward":s===o&&(c+=1)}e.preventDefault(),null==(t=this.linkService.eventBus)||t.dispatch("dispatcheventinsandbox",{source:this,detail:{id:n,name:"Keystroke",value:a,change:i||"",willCommit:!1,selStart:l,selEnd:c}})})),this._setEventListeners(r,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(e=>e.target.value))}if(c&&r.addEventListener("blur",c),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 ie extends ee{constructor(e){super(e,{isRenderable:!!e.data.hasOwnCanvas})}}class ne extends ee{constructor(e){super(e,{isRenderable:e.renderForms})}render(){let e=this.annotationStorage,t=this.data,i=t.id,n=e.getValue(i,{value:t.exportValue===t.fieldValue}).value;"string"==typeof n&&(n="Off"!==n,e.setValue(i,{value:n})),this.container.classList.add("buttonWidgetAnnotation","checkBox");let r=document.createElement("input");return q.add(r),r.setAttribute("data-element-id",i),r.disabled=t.readOnly,this._setRequired(r,this.data.required),r.type="checkbox",r.name=t.baseFieldName||t.fieldName,n&&r.setAttribute("checked",!0),r.setAttribute("exportValue",t.exportValue),r.tabIndex=Y,r.addEventListener("change",(n=>{let{name:r,checked:a}=n.target;for(let s of this._getElementsByName(r,i)){let i=a&&s.exportValue===t.exportValue;s.domElement&&(s.domElement.checked=i),e.setValue(s.id,{value:i})}e.setValue(i,{value:a})})),r.addEventListener("resetform",(e=>{let i=t.defaultFieldValue||"Off";e.target.checked=i===t.exportValue})),this.enableScripting&&this.hasJSActions&&(r.addEventListener("updatefromsandbox",(t=>{let n={value(t){t.target.checked="Off"!==t.detail.value,e.setValue(i,{value:t.target.checked})}};this._dispatchEventFromSandbox(n,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,i=t.id,n=e.getValue(i,{value:t.fieldValue===t.buttonValue}).value;"string"==typeof n&&(n=n!==t.buttonValue,e.setValue(i,{value:n}));let r=document.createElement("input");if(q.add(r),r.setAttribute("data-element-id",i),r.disabled=t.readOnly,this._setRequired(r,this.data.required),r.type="radio",r.name=t.baseFieldName||t.fieldName,n&&r.setAttribute("checked",!0),r.tabIndex=Y,r.addEventListener("change",(t=>{let{name:n,checked:r}=t.target;for(let a of this._getElementsByName(n,i))e.setValue(a.id,{value:!1});e.setValue(i,{value:r})})),r.addEventListener("resetform",(e=>{let i=t.defaultFieldValue;e.target.checked=null!=i&&i===t.buttonValue})),this.enableScripting&&this.hasJSActions){let n=t.buttonValue;r.addEventListener("updatefromsandbox",(t=>{let r={value:t=>{let r=n===t.detail.value;for(let n of this._getElementsByName(t.target.name)){let t=r&&n.id===i;n.domElement&&(n.domElement.checked=t),e.setValue(n.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 K{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,i=e.getValue(t,{value:this.data.fieldValue}),n=document.createElement("select");q.add(n),n.setAttribute("data-element-id",t),n.disabled=this.data.readOnly,this._setRequired(n,this.data.required),n.name=this.data.baseFieldName||this.data.fieldName,n.tabIndex=Y;let r=this.data.combo&&this.data.options.length>0;this.data.combo||(n.size=this.data.options.length,this.data.multiSelect&&(n.multiple=!0)),n.addEventListener("resetform",(e=>{let t=this.data.defaultFieldValue;for(let i of n.options)i.selected=i.value===t}));for(let h of this.data.options){let e=document.createElement("option");e.textContent=h.displayValue,e.value=h.exportValue,i.value.includes(h.exportValue)&&(e.setAttribute("selected",!0),r=!1),n.append(e)}let a=null;if(r){let e=document.createElement("option");e.value=" ",e.setAttribute("hidden",!0),e.setAttribute("selected",!0),n.prepend(e),a=()=>{e.remove(),n.removeEventListener("input",a),a=null},n.addEventListener("input",a)}let s=e=>{let t=e?"value":"textContent",{options:i,multiple:r}=n;return r?Array.prototype.filter.call(i,(e=>e.selected)).map((e=>e[t])):-1===i.selectedIndex?null:i[i.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?(n.addEventListener("updatefromsandbox",(i=>{let r={value(i){null==a||a();let r=i.detail.value,l=new Set(Array.isArray(r)?r:[r]);for(let e of n.options)e.selected=l.has(e.value);e.setValue(t,{value:s(!0)}),o=s(!1)},multipleSelection(e){n.multiple=!0},remove(i){let r=n.options,a=i.detail.remove;r[a].selected=!1,n.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(i)}),o=s(!1)},clear(i){for(;0!==n.length;)n.remove(0);e.setValue(t,{value:null,items:[]}),o=s(!1)},insert(i){let{index:r,displayValue:a,exportValue:h}=i.detail.insert,c=n.children[r],u=document.createElement("option");u.textContent=a,u.value=h,c?c.before(u):n.append(u),e.setValue(t,{value:s(!0),items:l(i)}),o=s(!1)},items(i){let{items:r}=i.detail;for(;0!==n.length;)n.remove(0);for(let e of r){let{displayValue:t,exportValue:i}=e,r=document.createElement("option");r.textContent=t,r.value=i,n.append(r)}n.options.length>0&&(n.options[0].selected=!0),e.setValue(t,{value:s(!0),items:l(i)}),o=s(!1)},indices(i){let n=new Set(i.detail.indices);for(let e of i.target.options)e.selected=n.has(e.index);e.setValue(t,{value:s(!0)}),o=s(!1)},editable(e){e.target.disabled=!e.detail.editable}};this._dispatchEventFromSandbox(r,i)})),n.addEventListener("input",(i=>{var n;let r=s(!0);e.setValue(t,{value:r}),i.preventDefault(),null==(n=this.linkService.eventBus)||n.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:o,changeEx:r,willCommit:!1,commitKey:1,keyDown:!1}})})),this._setEventListeners(n,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"],["input","Action"],["input","Validate"]],(e=>e.target.value))):n.addEventListener("input",(function(i){e.setValue(t,{value:s(!0)})})),this.data.combo&&this._setTextStyle(n),this._setBackgroundColor(n),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}class oe extends J{constructor(e){var t,i,n;let{data:r,elements:a}=e;super(e,{isRenderable:!!(null!=(t=r.titleObj)&&t.str||null!=(i=r.contentsObj)&&i.str||null!=(n=r.richText)&&n.str)}),this.elements=a}render(){this.container.classList.add("popupAnnotation");let e=new le({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 i of this.elements)i.popup=e,t.push(i.data.id),i.addHighlightArea();return this.container.setAttribute("aria-controls",t.join(",")),this.container}}class le{constructor({container:e,color:t,elements:i,titleObj:n,modificationDate:r,contentsObj:a,richText:s,parent:P,rect:R,parentRect:D,open:L}){Je(this,S),Je(this,E),Je(this,A),Je(this,o,null),Je(this,l,dt(this,A,C).bind(this)),Je(this,h,dt(this,E,T).bind(this)),Je(this,c,dt(this,S,M).bind(this)),Je(this,u,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),Mt(this,d,e),Mt(this,_,n),Mt(this,p,a),Mt(this,b,s),Mt(this,m,P),Mt(this,u,t),Mt(this,x,R),Mt(this,g,D),Mt(this,f,i);let I=j.PDFDateString.toDateObject(r);I&&Mt(this,o,P.l10n.get("annotation_date_string",{date:I.toLocaleDateString(),time:I.toLocaleTimeString()})),this.trigger=i.flatMap((e=>e.getElementsToTriggerPopup()));for(let o of this.trigger)o.addEventListener("click",ce(this,c)),o.addEventListener("mouseenter",ce(this,h)),o.addEventListener("mouseleave",ce(this,l));ce(this,d).hidden=!0,L&&dt(this,S,M).call(this)}render(){if(ce(this,y))return;let{page:{view:e},viewport:{rawDims:{pageWidth:t,pageHeight:i,pageX:n,pageY:r}}}=ce(this,m),a=Mt(this,y,document.createElement("div"));if(a.className="popup",ce(this,u)){let e=a.style.outlineColor=V.Util.makeHexColor(...ce(this,u));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(...ce(this,u).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}=ce(this,_)),a.append(s),ce(this,o)){let e=document.createElement("span");e.classList.add("popupDate"),ce(this,o).then((t=>{e.textContent=t})),s.append(e)}let h=ce(this,p),c=ce(this,b);if(null==c||!c.str||null!=h&&h.str&&h.str!==c.str){let e=this._formatContents(h);a.append(e)}else X.XfaLayer.render({xfaHtml:c.html,intent:"richText",div:a}),a.lastChild.classList.add("richText","popupContent");let v=!!ce(this,g),w=ce(this,v?g:x);for(let o of ce(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}=ce(this,d);A.left=100*(E-n)/t+"%",A.top=100*(T-r)/i+"%",ce(this,d).append(a)}_formatContents({str:e,dir:t}){let i=document.createElement("p");i.classList.add("popupContent"),i.dir=t;let n=e.split(/(?:\r\n?|\n)/);for(let r=0,a=n.length;r<a;++r){let e=n[r];i.append(document.createTextNode(e)),r<a-1&&i.append(document.createElement("br"))}return i}forceHide(){Mt(this,w,this.isVisible),ce(this,w)&&(ce(this,d).hidden=!0)}maybeShow(){ce(this,w)&&(Mt(this,w,!1),ce(this,d).hidden=!1)}get isVisible(){return!1===ce(this,d).hidden}}o=new WeakMap,l=new WeakMap,h=new WeakMap,c=new WeakMap,u=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(){Mt(this,v,!ce(this,v)),ce(this,v)?(dt(this,E,T).call(this),ce(this,d).addEventListener("click",ce(this,c))):(dt(this,A,C).call(this),ce(this,d).removeEventListener("click",ce(this,c)))},E=new WeakSet,T=function(){ce(this,y)||this.render(),this.isVisible?ce(this,v)&&ce(this,d).classList.add("focused"):(ce(this,d).hidden=!1,ce(this,d).style.zIndex=parseInt(ce(this,d).style.zIndex)+1e3)},A=new WeakSet,C=function(){ce(this,d).classList.remove("focused"),!ce(this,v)&&(ce(this,d).hidden=!0,ce(this,d).style.zIndex=parseInt(ce(this,d).style.zIndex)-1e3)};class he extends J{constructor(e){var t,i,n;super(e,{isRenderable:!!(e.data.popupRef||null!=(t=e.data.titleObj)&&t.str||null!=(i=e.data.contentsObj)&&i.str||null!=(n=e.data.richText)&&n.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 i=document.createElement("span");i.textContent=t,e.append(i)}this.container.append(e)}return this.data.popupRef||this._createPopup(),this.container}}t.FreeTextAnnotationElement=he;class ue extends J{constructor(e){var t,i,n;super(e,{isRenderable:!!(e.data.popupRef||null!=(t=e.data.titleObj)&&t.str||null!=(i=e.data.contentsObj)&&i.str||null!=(n=e.data.richText)&&n.str),ignoreBorder:!0}),Je(this,P,null)}render(){this.container.classList.add("lineAnnotation");let e=this.data,{width:t,height:i}=Z(e.rect),n=this.svgFactory.create(t,i,!0),r=Mt(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"),n.append(r),this.container.append(n),e.popupRef||this._createPopup(),this.container}getElementsToTriggerPopup(){return ce(this,P)}addHighlightArea(){this.container.classList.add("highlightArea")}}P=new WeakMap;class de extends J{constructor(e){var t,i,n;super(e,{isRenderable:!!(e.data.popupRef||null!=(t=e.data.titleObj)&&t.str||null!=(i=e.data.contentsObj)&&i.str||null!=(n=e.data.richText)&&n.str),ignoreBorder:!0}),Je(this,R,null)}render(){this.container.classList.add("squareAnnotation");let e=this.data,{width:t,height:i}=Z(e.rect),n=this.svgFactory.create(t,i,!0),r=e.borderStyle.width,a=Mt(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",i-r),a.setAttribute("stroke-width",r||1),a.setAttribute("stroke","transparent"),a.setAttribute("fill","transparent"),n.append(a),this.container.append(n),e.popupRef||this._createPopup(),this.container}getElementsToTriggerPopup(){return ce(this,R)}addHighlightArea(){this.container.classList.add("highlightArea")}}R=new WeakMap;class pe extends J{constructor(e){var t,i,n;super(e,{isRenderable:!!(e.data.popupRef||null!=(t=e.data.titleObj)&&t.str||null!=(i=e.data.contentsObj)&&i.str||null!=(n=e.data.richText)&&n.str),ignoreBorder:!0}),Je(this,D,null)}render(){this.container.classList.add("circleAnnotation");let e=this.data,{width:t,height:i}=Z(e.rect),n=this.svgFactory.create(t,i,!0),r=e.borderStyle.width,a=Mt(this,D,this.svgFactory.createElement("svg:ellipse"));return a.setAttribute("cx",t/2),a.setAttribute("cy",i/2),a.setAttribute("rx",t/2-r/2),a.setAttribute("ry",i/2-r/2),a.setAttribute("stroke-width",r||1),a.setAttribute("stroke","transparent"),a.setAttribute("fill","transparent"),n.append(a),this.container.append(n),e.popupRef||this._createPopup(),this.container}getElementsToTriggerPopup(){return ce(this,D)}addHighlightArea(){this.container.classList.add("highlightArea")}}D=new WeakMap;class fe extends J{constructor(e){var t,i,n;super(e,{isRenderable:!!(e.data.popupRef||null!=(t=e.data.titleObj)&&t.str||null!=(i=e.data.contentsObj)&&i.str||null!=(n=e.data.richText)&&n.str),ignoreBorder:!0}),Je(this,L,null),this.containerClassName="polylineAnnotation",this.svgElementName="svg:polyline"}render(){this.container.classList.add(this.containerClassName);let e=this.data,{width:t,height:i}=Z(e.rect),n=this.svgFactory.create(t,i,!0),r=[];for(let s of e.vertices){let t=s.x-e.rect[0],i=e.rect[3]-s.y;r.push(t+","+i)}r=r.join(" ");let a=Mt(this,L,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"),n.append(a),this.container.append(n),e.popupRef||this._createPopup(a,e),this.container}getElementsToTriggerPopup(){return ce(this,L)}addHighlightArea(){this.container.classList.add("highlightArea")}}L=new WeakMap;class me extends fe{constructor(e){super(e),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class ge extends J{constructor(e){var t,i,n;super(e,{isRenderable:!!(e.data.popupRef||null!=(t=e.data.titleObj)&&t.str||null!=(i=e.data.contentsObj)&&i.str||null!=(n=e.data.richText)&&n.str),ignoreBorder:!0})}render(){return this.container.classList.add("caretAnnotation"),this.data.popupRef||this._createPopup(),this.container}}class ve extends J{constructor(e){var t,i,n;super(e,{isRenderable:!!(e.data.popupRef||null!=(t=e.data.titleObj)&&t.str||null!=(i=e.data.contentsObj)&&i.str||null!=(n=e.data.richText)&&n.str),ignoreBorder:!0}),Je(this,I,[]),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:i}=Z(e.rect),n=this.svgFactory.create(t,i,!0);for(let r of e.inkLists){let t=[];for(let n of r){let i=n.x-e.rect[0],r=e.rect[3]-n.y;t.push(`${i},${r}`)}t=t.join(" ");let i=this.svgFactory.createElement(this.svgElementName);ce(this,I).push(i),i.setAttribute("points",t),i.setAttribute("stroke-width",e.borderStyle.width||1),i.setAttribute("stroke","transparent"),i.setAttribute("fill","transparent"),e.popupRef||this._createPopup(i,e),n.append(i)}return this.container.append(n),this.container}getElementsToTriggerPopup(){return ce(this,I)}addHighlightArea(){this.container.classList.add("highlightArea")}}I=new WeakMap,t.InkAnnotationElement=ve;class ye extends J{constructor(e){var t,i,n;super(e,{isRenderable:!!(e.data.popupRef||null!=(t=e.data.titleObj)&&t.str||null!=(i=e.data.contentsObj)&&i.str||null!=(n=e.data.richText)&&n.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 J{constructor(e){var t,i,n;super(e,{isRenderable:!!(e.data.popupRef||null!=(t=e.data.titleObj)&&t.str||null!=(i=e.data.contentsObj)&&i.str||null!=(n=e.data.richText)&&n.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 J{constructor(e){var t,i,n;super(e,{isRenderable:!!(e.data.popupRef||null!=(t=e.data.titleObj)&&t.str||null!=(i=e.data.contentsObj)&&i.str||null!=(n=e.data.richText)&&n.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 J{constructor(e){var t,i,n;super(e,{isRenderable:!!(e.data.popupRef||null!=(t=e.data.titleObj)&&t.str||null!=(i=e.data.contentsObj)&&i.str||null!=(n=e.data.richText)&&n.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 J{constructor(e){var t,i,n;super(e,{isRenderable:!!(e.data.popupRef||null!=(t=e.data.titleObj)&&t.str||null!=(i=e.data.contentsObj)&&i.str||null!=(n=e.data.richText)&&n.str),ignoreBorder:!0})}render(){return this.container.classList.add("stampAnnotation"),this.data.popupRef||this._createPopup(),this.container}}class Se extends J{constructor(e){var t;super(e,{isRenderable:!0}),Je(this,O,null);let{filename:i,content:n}=this.data.file;this.filename=(0,j.getFilenameFromUrl)(i,!0),this.content=n,null==(t=this.linkService.eventBus)||t.dispatch("fileattachmentannotation",{source:this,filename:i,content:n})}render(){var e,t;let i;return this.container.classList.add("fileAttachmentAnnotation"),this.data.hasAppearance?i=document.createElement("div"):(i=document.createElement("img"),i.src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(this.data.name)?"paperclip":"pushpin"}.svg`),i.classList.add("popupTriggerArea"),i.addEventListener("dblclick",this._download.bind(this)),Mt(this,O,i),!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(i),this.container}getElementsToTriggerPopup(){return ce(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,k=new WeakMap,N=new WeakMap,U=new WeakMap,F=new WeakSet,B=function(e,t){var i;let n=e.firstChild||e;n.id=`${j.AnnotationPrefix}${t}`,this.div.append(e),null==(i=ce(this,k))||i.moveElementInDOM(this.div,e,n,!1)},z=new WeakSet,H=function(){if(!ce(this,N))return;let e=this.div;for(let[t,i]of ce(this,N)){let n=e.querySelector(`[data-annotation-id="${t}"]`);if(!n)continue;let{firstChild:r}=n;r?"CANVAS"===r.nodeName?r.replaceWith(i):r.before(i):n.append(i)}ce(this,N).clear()},t.AnnotationLayer=class{constructor({div:e,accessibilityManager:t,annotationCanvasMap:n,l10n:r,page:a,viewport:s}){Je(this,F),Je(this,z),Je(this,k,null),Je(this,N,null),Je(this,U,new Map),this.div=e,Mt(this,k,t),Mt(this,N,n),this.l10n=r,this.page=a,this.viewport=s,this.zIndex=0;let{NullL10n:o}=i(32);this.l10n||(this.l10n=o)}render(e){return ft(this,null,(function*(){let{annotations:t}=e,i=this.div;(0,j.setLayerDimensions)(i,this.viewport);let n=new Map,r={data:null,layer:i,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=n.get(e.id);if(!t)continue;r.elements=t}else{let{width:t,height:i}=Z(e.rect);if(t<=0||i<=0)continue}r.data=e;let i=Q.create(r);if(!i.isRenderable)continue;if(!t&&e.popupRef){let t=n.get(e.popupRef);t?t.push(i):n.set(e.popupRef,[i])}i.annotationEditorType>0&&ce(this,U).set(i.data.id,i);let a=i.render();if(e.hidden&&(a.style.visibility="hidden"),Array.isArray(a))for(let n of a)dt(this,F,B).call(this,n,e.id);else dt(this,F,B).call(this,a,e.id)}dt(this,z,H).call(this),yield this.l10n.translate(i)}))}update({viewport:e}){let t=this.div;this.viewport=e,(0,j.setLayerDimensions)(t,{rotation:e.rotation}),dt(this,z,H).call(this),t.hidden=!1}getEditableAnnotations(){return Array.from(ce(this,U).values())}getEditableAnnotation(e){return ce(this,U).get(e)}}},(e,t)=>{function i(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,i,n]){return["G",1-Math.min(1,.3*e+.59*i+.11*t+n)]}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=i(e);return`#${t}${t}${t}`}static RGB_G([e,t,i]){return["G",.3*e+.59*t+.11*i]}static RGB_HTML([e,t,n]){return`#${i(e)}${i(t)}${i(n)}`}static T_HTML(){return"#00000000"}static CMYK_RGB([e,t,i,n]){return["RGB",1-Math.min(1,e+n),1-Math.min(1,i+n),1-Math.min(1,t+n)]}static CMYK_HTML(e){let t=this.CMYK_RGB(e).slice(1);return this.RGB_HTML(t)}static RGB_CMYK([e,t,i]){let n=1-e,r=1-t,a=1-i;return["CMYK",n,r,a,Math.min(n,r,a)]}}},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.XfaLayer=void 0;var n=i(19);t.XfaLayer=class{static setupStorage(e,t,i,n,r){let a=n.getValue(t,{value:null});switch(i.name){case"textarea":if(null!==a.value&&(e.textContent=a.value),"print"===r)break;e.addEventListener("input",(e=>{n.setValue(t,{value:e.target.value})}));break;case"input":if("radio"===i.attributes.type||"checkbox"===i.attributes.type){if(a.value===i.attributes.xfaOn?e.setAttribute("checked",!0):a.value===i.attributes.xfaOff&&e.removeAttribute("checked"),"print"===r)break;e.addEventListener("change",(e=>{n.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=>{n.setValue(t,{value:e.target.value})}))}break;case"select":if(null!==a.value)for(let e of i.children)e.attributes.value===a.value&&(e.attributes.selected=!0);e.addEventListener("input",(e=>{let i=e.target.options,r=-1===i.selectedIndex?"":i[i.selectedIndex].value;n.setValue(t,{value:r})}))}}static setAttributes({html:e,element:t,storage:i=null,intent:n,linkService:r}){let{attributes:a}=t,s=e instanceof HTMLAnchorElement;"radio"===a.type&&(a.name=`${a.name}-${n}`);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),i&&a.dataId&&this.setupStorage(e,a.dataId,t,i)}static render(e){var t;let i=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 c=[];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 u,{name:d}=h;if("#text"!==d){if(u=null!=(t=null==h?void 0:h.attributes)&&t.xmlns?document.createElementNS(h.attributes.xmlns,d):document.createElement(d),o.append(u),h.attributes&&this.setAttributes({html:u,element:h,storage:i,intent:s,linkService:r}),h.children&&h.children.length>0)l.push([h,-1,u]);else if(h.value){let e=document.createTextNode(h.value);n.XfaText.shouldBuildText(d)&&c.push(e),u.append(e)}}else{let e=document.createTextNode(h.value);c.push(e),o.append(e)}}for(let n of h.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))n.setAttribute("readOnly",!0);return{textDivs:c}}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=n;let i={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 n(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 i[e]||""}i.print_progress_percent="{{progress}}%";let r={getLanguage(){return ft(this,null,(function*(){return"en-us"}))},getDirection(){return ft(this,null,(function*(){return"ltr"}))},get(e){return ft(this,arguments,(function*(e,t=null,i=n(e,t)){return function(e,t){return t?e.replaceAll(/\{\{\s*(\w+)\s*\}\}/g,((e,i)=>i in t?t[i]:"{{"+i+"}}")):e}(i,t)}))},translate(e){return ft(this,null,(function*(){}))}};t.NullL10n=r},(e,t,i)=>{var n,r,a,s,o,l,h,c,u,d,p,f,m,g,v,y,x,b,_,w,S,M,E,T,A,C,P,R,D,L,I,O,k,N,U,F,B,z,H,V,j,G,W,X,Y,q,Z,Q,J,K,$,ee,te,ie,ne,re,ae,se,oe,le,he,ue,de,pe,fe,me,ge,ve,ye,xe;Object.defineProperty(t,"__esModule",{value:!0}),t.InkEditor=void 0;var be=i(1),_e=i(4),we=i(29),Se=i(5);let Me=16,Ee=class extends _e.AnnotationEditor{constructor(e){super(Ii(Tr({},e),{name:"inkEditor"})),Je(this,x),Je(this,_),Je(this,S),Je(this,E),Je(this,A),Je(this,P),Je(this,D),Je(this,I),Je(this,k),Je(this,U),Je(this,B),Je(this,H),Je(this,j),Je(this,W),Je(this,Y),Je(this,Z),Je(this,J),Je(this,$),Je(this,te),Je(this,he),Je(this,de),Je(this,fe),Je(this,ge),Je(this,ye),Je(this,n,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,c,this.canvasPointerdown.bind(this)),Je(this,u,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:dt(this,x,b).call(this,t);break;case be.AnnotationEditorParamsType.INK_COLOR:dt(this,_,w).call(this,t);break;case be.AnnotationEditorParamsType.INK_OPACITY:dt(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||(dt(this,Y,q).call(this),dt(this,Z,Q).call(this)),this.isAttachedToDOM||(this.parent.add(this),dt(this,J,K).call(this)),dt(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,ce(this,m).disconnect(),Mt(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,i=this.width*e,n=this.height*t;this.setDimensions(i,n)}enableEditMode(){ce(this,d)||null===this.canvas||(super.enableEditMode(),this.div.draggable=!1,this.canvas.addEventListener("pointerdown",ce(this,c)))}disableEditMode(){!this.isInEditMode()||null===this.canvas||(super.disableEditMode(),this.div.draggable=!this.isEmpty(),this.div.classList.remove("editing"),this.canvas.removeEventListener("pointerdown",ce(this,c)))}onceAdded(){this.div.draggable=!this.isEmpty()}isEmpty(){return 0===this.paths.length||1===this.paths.length&&0===this.paths[0].length}commit(){ce(this,d)||(super.commit(),this.isEditing=!1,this.disableEditMode(),this.setInForeground(),Mt(this,d,!0),this.div.classList.add("disabled"),dt(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()||ce(this,d)||(this.setInForeground(),e.preventDefault(),"mouse"!==e.type&&this.div.focus(),dt(this,P,R).call(this,e.offsetX,e.offsetY))}canvasContextMenu(e){e.preventDefault()}canvasPointermove(e){e.preventDefault(),dt(this,D,L).call(this,e.offsetX,e.offsetY)}canvasPointerup(e){e.preventDefault(),dt(this,W,X).call(this,e)}canvasPointerleave(e){dt(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[i,n,r,a]=dt(this,E,T).call(this);if(this.setAt(i,n,0,0),this.setDims(r,a),dt(this,Y,q).call(this),this.width){let[i,n]=this.parentDimensions;this.setAt(e*i,t*n,this.width*i,this.height*n),Mt(this,f,!0),dt(this,J,K).call(this),this.setDims(this.width*i,this.height*n),dt(this,j,G).call(this),dt(this,ye,xe).call(this),this.div.classList.add("disabled")}else this.div.classList.add("editing"),this.enableEditMode();return dt(this,Z,Q).call(this),this.div}setDimensions(e,t){let i=Math.round(e),r=Math.round(t);if(ce(this,g)===i&&ce(this,v)===r)return;Mt(this,g,i),Mt(this,v,r),this.canvas.style.visibility="hidden",ce(this,n)&&Math.abs(ce(this,n)-e/t)>.01&&(t=Math.ceil(e/ce(this,n)),this.setDims(e,t));let[a,s]=this.parentDimensions;this.width=e/a,this.height=t/s,ce(this,d)&&dt(this,$,ee).call(this,e,t),dt(this,J,K).call(this),dt(this,j,G).call(this),this.canvas.style.visibility="visible",this.fixDims()}static deserialize(e,t,i){var s,o,l;if(e instanceof we.InkAnnotationElement)return null;let h=super.deserialize(e,t,i);h.thickness=e.thickness,h.color=be.Util.makeHexColor(...e.color),h.opacity=e.opacity;let[c,u]=h.pageDimensions,p=h.width*c,f=h.height*u,m=h.parentScale,y=e.thickness/2;Mt(h,n,p/f),Mt(h,d,!0),Mt(h,g,Math.round(p)),Mt(h,v,Math.round(f));let{paths:x,rect:b,rotation:_}=e;for(let{bezier:n}of x){n=dt(s=Ee,oe,le).call(s,n,b,_);let e=[];h.paths.push(e);let t=m*(n[0]-y),i=m*(n[1]-y);for(let a=2,s=n.length;a<s;a+=6){let r=m*(n[a]-y),s=m*(n[a+1]-y),o=m*(n[a+2]-y),l=m*(n[a+3]-y),h=m*(n[a+4]-y),c=m*(n[a+5]-y);e.push([[t,i],[r,s],[o,l],[h,c]]),t=h,i=c}let r=dt(this,ne,re).call(this,e);h.bezierPath2D.push(r)}let w=dt(o=h,de,pe).call(o);return Mt(h,a,Math.max(Me,w[2]-w[0])),Mt(h,r,Math.max(Me,w[3]-w[1])),dt(l=h,$,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:dt(this,he,ue).call(this,this.scaleFactor/this.parentScale,this.translationX,this.translationY,e),pageIndex:this.pageIndex,rect:e,rotation:this.rotation}}},Te=Ee;n=new WeakMap,r=new WeakMap,a=new WeakMap,s=new WeakMap,o=new WeakMap,l=new WeakMap,h=new WeakMap,c=new WeakMap,u=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,dt(this,ge,ve).call(this)},undo:()=>{this.thickness=t,dt(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,dt(this,j,G).call(this)},undo:()=>{this.color=t,dt(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,dt(this,j,G).call(this)},undo:()=>{this.opacity=t,dt(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,i]}=this;switch(e){case 90:return[0,i,i,t];case 180:return[t,i,t,i];case 270:return[t,0,i,t];default:return[0,0,t,i]}},A=new WeakSet,C=function(){let{ctx:e,color:t,opacity:i,thickness:n,parentScale:r,scaleFactor:a}=this;e.lineWidth=n*r/a,e.lineCap="round",e.lineJoin="round",e.miterLimit=10,e.strokeStyle=`${t}${(0,Se.opacityToHex)(i)}`},P=new WeakSet,R=function(e,t){this.canvas.addEventListener("contextmenu",ce(this,s)),this.canvas.addEventListener("pointerleave",ce(this,l)),this.canvas.addEventListener("pointermove",ce(this,o)),this.canvas.addEventListener("pointerup",ce(this,h)),this.canvas.removeEventListener("pointerdown",ce(this,c)),this.isEditing=!0,ce(this,f)||(Mt(this,f,!0),dt(this,J,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]),Mt(this,p,!1),dt(this,A,C).call(this),Mt(this,y,(()=>{dt(this,U,F).call(this),ce(this,y)&&window.requestAnimationFrame(ce(this,y))})),window.requestAnimationFrame(ce(this,y))},D=new WeakSet,L=function(e,t){let[i,n]=this.currentPath.at(-1);if(this.currentPath.length>1&&e===i&&t===n)return;let r=this.currentPath,a=ce(this,u);if(r.push([e,t]),Mt(this,p,!0),r.length<=2)return a.moveTo(...r[0]),void a.lineTo(e,t);3===r.length&&(Mt(this,u,a=new Path2D),a.moveTo(...r[0])),dt(this,B,z).call(this,a,...r.at(-3),...r.at(-2),e,t)},I=new WeakSet,O=function(){if(0===this.currentPath.length)return;let e=this.currentPath.at(-1);ce(this,u).lineTo(...e)},k=new WeakSet,N=function(e,t){let i;if(Mt(this,y,null),e=Math.min(Math.max(e,0),this.canvas.width),t=Math.min(Math.max(t,0),this.canvas.height),dt(this,D,L).call(this,e,t),dt(this,I,O).call(this),1!==this.currentPath.length)i=dt(this,H,V).call(this);else{let n=[e,t];i=[[n,n.slice(),n.slice(),n]]}let n=ce(this,u),r=this.currentPath;this.currentPath=[],Mt(this,u,new Path2D),this.addCommands({cmd:()=>{this.allRawPaths.push(r),this.paths.push(i),this.bezierPath2D.push(n),this.rebuild()},undo:()=>{this.allRawPaths.pop(),this.paths.pop(),this.bezierPath2D.pop(),0===this.paths.length?this.remove():(this.canvas||(dt(this,Y,q).call(this),dt(this,Z,Q).call(this)),dt(this,ge,ve).call(this))},mustExec:!0})},U=new WeakSet,F=function(){if(!ce(this,p))return;Mt(this,p,!1),Math.ceil(this.thickness*this.parentScale);let e=this.currentPath.slice(-3),t=e.map((e=>e[0])),i=e.map((e=>e[1])),{ctx:n}=(Math.min(...t),Math.max(...t),Math.min(...i),Math.max(...i),this);n.save(),n.clearRect(0,0,this.canvas.width,this.canvas.height);for(let r of this.bezierPath2D)n.stroke(r);n.stroke(ce(this,u)),n.restore()},B=new WeakSet,z=function(e,t,i,n,r,a,s){let o=(t+n)/2,l=(i+r)/2,h=(n+a)/2,c=(r+s)/2;e.bezierCurveTo(o+2*(n-o)/3,l+2*(r-l)/3,h+2*(n-h)/3,c+2*(r-c)/3,h,c)},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,i=[],[n,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,c=(s+l)/2,u=[n+2*(a-n)/3,r+2*(s-r)/3],d=[h+2*(a-h)/3,c+2*(s-c)/3];i.push([[n,r],u,d,[h,c]]),[n,r]=[h,c]}let[a,s]=e[t],[o,l]=e[t+1],h=[n+2*(a-n)/3,r+2*(s-r)/3],c=[o+2*(a-o)/3,l+2*(s-l)/3];return i.push([[n,r],h,c,[o,l]]),i},j=new WeakSet,G=function(){if(this.isEmpty())return void dt(this,te,ie).call(this);dt(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),dt(this,te,ie).call(this);for(let i of this.bezierPath2D)t.stroke(i)},W=new WeakSet,X=function(e){this.canvas.removeEventListener("pointerleave",ce(this,l)),this.canvas.removeEventListener("pointermove",ce(this,o)),this.canvas.removeEventListener("pointerup",ce(this,h)),this.canvas.addEventListener("pointerdown",ce(this,c)),setTimeout((()=>{this.canvas.removeEventListener("contextmenu",ce(this,s))}),10),dt(this,k,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")},Z=new WeakSet,Q=function(){Mt(this,m,new ResizeObserver((e=>{let t=e[0].contentRect;t.width&&t.height&&this.setDimensions(t.width,t.height)}))),ce(this,m).observe(this.div)},J=new WeakSet,K=function(){if(!ce(this,f))return;let[e,t]=this.parentDimensions;this.canvas.width=Math.ceil(this.width*e),this.canvas.height=Math.ceil(this.height*t),dt(this,te,ie).call(this)},$=new WeakSet,ee=function(e,t){let i=dt(this,fe,me).call(this),n=(e-i)/ce(this,a),s=(t-i)/ce(this,r);this.scaleFactor=Math.min(n,s)},te=new WeakSet,ie=function(){let e=dt(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)},ne=new WeakSet,re=function(e){let t=new Path2D;for(let i=0,n=e.length;i<n;i++){let[n,r,a,s]=e[i];0===i&&t.moveTo(...n),t.bezierCurveTo(r[0],r[1],a[0],a[1],s[0],s[1])}return t},ae=new WeakSet,se=function(e,t,i){let[n,r,a,s]=t;switch(i){case 0:for(let t=0,i=e.length;t<i;t+=2)e[t]+=n,e[t+1]=s-e[t+1];break;case 90:for(let t=0,i=e.length;t<i;t+=2){let i=e[t];e[t]=e[t+1]+n,e[t+1]=i+r}break;case 180:for(let t=0,i=e.length;t<i;t+=2)e[t]=a-e[t],e[t+1]+=r;break;case 270:for(let t=0,i=e.length;t<i;t+=2){let i=e[t];e[t]=a-e[t+1],e[t+1]=s-i}break;default:throw new Error("Invalid rotation")}return e},oe=new WeakSet,le=function(e,t,i){let[n,r,a,s]=t;switch(i){case 0:for(let t=0,i=e.length;t<i;t+=2)e[t]-=n,e[t+1]=s-e[t+1];break;case 90:for(let t=0,i=e.length;t<i;t+=2){let i=e[t];e[t]=e[t+1]-r,e[t+1]=i-n}break;case 180:for(let t=0,i=e.length;t<i;t+=2)e[t]=a-e[t],e[t+1]-=r;break;case 270:for(let t=0,i=e.length;t<i;t+=2){let i=e[t];e[t]=s-e[t+1],e[t+1]=a-i}break;default:throw new Error("Invalid rotation")}return e},he=new WeakSet,ue=function(e,t,i,n){var r,a;let s=[],o=this.thickness/2,l=e*t+o,h=e*i+o;for(let c of this.paths){let t=[],i=[];for(let n=0,r=c.length;n<r;n++){let[a,s,o,u]=c[n],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*u[0]+l,x=e*u[1]+h;0===n&&(t.push(d,p),i.push(d,p)),t.push(f,m,g,v,y,x),i.push(f,m),n===r-1&&i.push(y,x)}s.push({bezier:dt(r=Ee,ae,se).call(r,t,n,this.rotation),points:dt(a=Ee,ae,se).call(a,i,n,this.rotation)})}return s},de=new WeakSet,pe=function(){let e=1/0,t=-1/0,i=1/0,n=-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]),i=Math.min(i,r[1]),t=Math.max(t,r[2]),n=Math.max(n,r[3])}return[e,i,t,n]},fe=new WeakSet,me=function(){return ce(this,d)?Math.ceil(this.thickness*this.parentScale):0},ge=new WeakSet,ve=function(e=!1){if(this.isEmpty())return;if(!ce(this,d))return void dt(this,j,G).call(this);let t=dt(this,de,pe).call(this),i=dt(this,fe,me).call(this);Mt(this,a,Math.max(Me,t[2]-t[0])),Mt(this,r,Math.max(Me,t[3]-t[1]));let s=Math.ceil(i+ce(this,a)*this.scaleFactor),o=Math.ceil(i+ce(this,r)*this.scaleFactor),[l,h]=this.parentDimensions;this.width=s/l,this.height=o/h,Mt(this,n,s/o),dt(this,ye,xe).call(this);let c=this.translationX,u=this.translationY;this.translationX=-t[0],this.translationY=-t[1],dt(this,J,K).call(this),dt(this,j,G).call(this),Mt(this,g,s),Mt(this,v,o),this.setDims(s,o);let p=e?i/this.scaleFactor/2:0;this.translate(c-this.translationX-p,u-this.translationY-p)},ye=new WeakSet,xe=function(){let{style:e}=this.div;ce(this,n)>=1?(e.minHeight="16px",e.minWidth=`${Math.round(ce(this,n)*Me)}px`):(e.minWidth="16px",e.minHeight=`${Math.round(Me/ce(this,n))}px`)},Je(Te,ne),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,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SVGGraphics=void 0;var n=i(6),r=i(1),a=i(10);let s="normal",o="#000000",l=["butt","round","square"],h=["miter","round","bevel"],c=function(e,t="",i=!1){if(URL.createObjectURL&&"undefined"!=typeof Blob&&!i)return URL.createObjectURL(new Blob([e],{type:t}));let n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",r=`data:${t};base64,`;for(let a=0,s=e.length;a<s;a+=3){let t=255&e[a],i=255&e[a+1],o=255&e[a+2];r+=n[t>>2]+n[(3&t)<<4|i>>4]+n[a+1<s?(15&i)<<2|o>>6:64]+n[a+2<s?63&o:64]}return r},u=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 i(e,i,n,r){let a=r,s=i.length;n[a]=s>>24&255,n[a+1]=s>>16&255,n[a+2]=s>>8&255,n[a+3]=255&s,a+=4,n[a]=255&e.charCodeAt(0),n[a+1]=255&e.charCodeAt(1),n[a+2]=255&e.charCodeAt(2),n[a+3]=255&e.charCodeAt(3),a+=4,n.set(i,a),a+=i.length;let o=function(e,i,n){let r=-1;for(let a=i;a<n;a++){let i=255&(r^e[a]);r=r>>>8^t[i]}return-1^r}(n,r+4,a);n[a]=o>>24&255,n[a+1]=o>>16&255,n[a+2]=o>>8&255,n[a+3]=255&o}function n(e){let t=e.length,i=65535,n=Math.ceil(t/i),r=new Uint8Array(2+t+5*n+4),a=0;r[a++]=120,r[a++]=156;let s=0;for(;t>i;)r[a++]=0,r[a++]=255,r[a++]=255,r[a++]=0,r[a++]=0,r.set(e.subarray(s,s+i),a),a+=i,s+=i,t-=i;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,i){let n=1,r=0;for(let a=0;a<i;++a)n=(n+(255&e[a]))%65521,r=(r+n)%65521;return r<<16|n}(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,u,d,p=t.width,f=t.height,m=t.data;switch(s){case r.ImageKind.GRAYSCALE_1BPP:u=0,h=1,d=p+7>>3;break;case r.ImageKind.RGB_24BPP:u=2,h=8,d=3*p;break;case r.ImageKind.RGBA_32BPP:u=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,u,0,0,0]),b=function(e){if(!a.isNodeJS)return n(e);try{let t;t=parseInt(process.versions.node)>=8?e:Buffer.from(e);let i=Aye().deflateSync(t,{level:9});return i instanceof Uint8Array?i:new Uint8Array(i)}catch(e){(0,r.warn)("Not compressing PNG because zlib.deflateSync is unavailable: "+e)}return n(e)}(g),_=e.length+36+x.length+b.length,w=new Uint8Array(_),S=0;return w.set(e,S),S+=e.length,i("IHDR",x,w,S),S+=12+x.length,i("IDATA",b,w,S),S+=12+b.length,i("IEND",new Uint8Array(0),w,S),c(w,"image/png",o)}return function(e,t,i){return s(e,void 0===e.kind?r.ImageKind.GRAYSCALE_1BPP:e.kind,t,i)}}();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),i=t.length-1;if("0"!==t[i])return t;do{i--}while("0"===t[i]);return t.substring(0,"."===t[i]?i:i+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,i=!1){(0,n.deprecated)("The SVG back-end is no longer maintained and *may* be removed in the future."),this.svgFactory=new n.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=!!i,this._operatorIdMapping=[];for(let n in r.OPS)this._operatorIdMapping[r.OPS[n]]=n}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,i=e.argsArray;for(let n=0,a=t.length;n<a;n++)if(t[n]===r.OPS.dependency)for(let e of i[n]){let t=e.startsWith("g_")?this.commonObjs:this.objs,i=new Promise((i=>{t.get(e,i)}));this.current.dependencies.push(i)}return Promise.all(this.current.dependencies)}transform(e,t,i,n,a,s){let o=[e,t,i,n,a,s];this.transformMatrix=r.Util.transform(this.transformMatrix,o),this.tgrp=null}getSVG(e,t){this.viewport=t;let i=this._initialize(t);return this.loadDependencies(e).then((()=>(this.transformMatrix=r.IDENTITY_MATRIX,this.executeOpTree(this.convertOpList(e)),i)))}convertOpList(e){let t=this._operatorIdMapping,i=e.argsArray,n=e.fnArray,r=[];for(let a=0,s=n.length;a<s;a++){let e=n[a];r.push({fnId:e,fn:t[e],args:i[a]})}return function(e){let t=[],i=[];for(let n of e)"save"!==n.fn?"restore"===n.fn?t=i.pop():t.push(n):(t.push({fnId:92,fn:"group",items:[]}),i.push(t),t=t.at(-1).items);return t}(r)}executeOpTree(e){for(let t of e){let e=t.fn,i=t.fnId,n=t.args;switch(0|i){case r.OPS.beginText:this.beginText();break;case r.OPS.dependency:break;case r.OPS.setLeading:this.setLeading(n);break;case r.OPS.setLeadingMoveText:this.setLeadingMoveText(n[0],n[1]);break;case r.OPS.setFont:this.setFont(n);break;case r.OPS.showText:case r.OPS.showSpacedText:this.showText(n[0]);break;case r.OPS.endText:this.endText();break;case r.OPS.moveText:this.moveText(n[0],n[1]);break;case r.OPS.setCharSpacing:this.setCharSpacing(n[0]);break;case r.OPS.setWordSpacing:this.setWordSpacing(n[0]);break;case r.OPS.setHScale:this.setHScale(n[0]);break;case r.OPS.setTextMatrix:this.setTextMatrix(n[0],n[1],n[2],n[3],n[4],n[5]);break;case r.OPS.setTextRise:this.setTextRise(n[0]);break;case r.OPS.setTextRenderingMode:this.setTextRenderingMode(n[0]);break;case r.OPS.setLineWidth:this.setLineWidth(n[0]);break;case r.OPS.setLineJoin:this.setLineJoin(n[0]);break;case r.OPS.setLineCap:this.setLineCap(n[0]);break;case r.OPS.setMiterLimit:this.setMiterLimit(n[0]);break;case r.OPS.setFillRGBColor:this.setFillRGBColor(n[0],n[1],n[2]);break;case r.OPS.setStrokeRGBColor:this.setStrokeRGBColor(n[0],n[1],n[2]);break;case r.OPS.setStrokeColorN:this.setStrokeColorN(n);break;case r.OPS.setFillColorN:this.setFillColorN(n);break;case r.OPS.shadingFill:this.shadingFill(n[0]);break;case r.OPS.setDash:this.setDash(n[0],n[1]);break;case r.OPS.setRenderingIntent:this.setRenderingIntent(n[0]);break;case r.OPS.setFlatness:this.setFlatness(n[0]);break;case r.OPS.setGState:this.setGState(n[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(n[0]);break;case r.OPS.paintInlineImageXObject:this.paintInlineImageXObject(n[0]);break;case r.OPS.paintImageMaskXObject:this.paintImageMaskXObject(n[0]);break;case r.OPS.paintFormXObjectBegin:this.paintFormXObjectBegin(n[0],n[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(n[0],n[1],n[2],n[3],n[4],n[5]);break;case r.OPS.constructPath:this.constructPath(n[0],n[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,i,n,r,a){let s=this.current;s.textMatrix=s.lineMatrix=[e,t,i,n,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 i=this.current;i.x=i.lineX+=e,i.y=i.lineY+=t,i.xcoords=[],i.ycoords=[],i.tspan=this.svgFactory.createElement("svg:tspan"),i.tspan.setAttributeNS(null,"font-family",i.fontFamily),i.tspan.setAttributeNS(null,"font-size",`${p(i.fontSize)}px`),i.tspan.setAttributeNS(null,"y",p(-i.y))}showText(e){let t=this.current,i=t.font,n=t.fontSize;if(0===n)return;let a=t.fontSizeScale,l=t.charSpacing,h=t.wordSpacing,c=t.fontDirection,u=t.textHScale*c,d=i.vertical,m=d?1:-1,g=i.defaultVMetrics,v=n*t.fontMatrix[0],y=0;for(let r of e){if(null===r){y+=c*h;continue}if("number"==typeof r){y+=m*r*n/1e3;continue}let e,s,o,u=(r.isSpace?h:0)+l,p=r.fontChar,f=r.width;if(d){let t,i=r.vmetric||g;t=r.vmetric?i[1]:.5*f,t=-t*v;let n=i[2]*v;f=i?-i[0]:f,e=t/a,s=(y+n)/a}else e=y/a,s=0;(r.isInFont||i.missingFile)&&(t.xcoords.push(t.x+e),d&&t.ycoords.push(-t.y+s),t.tspan.textContent+=p),o=d?f*v-u*c:f*v+u*c,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*u,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(u)}, -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=c(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,i=this.commonObjs.get(e[0]),n=e[1];t.font=i,this.embedFonts&&!i.missingFile&&!this.embeddedFonts[i.loadedName]&&(this.addFontStyle(i),this.embeddedFonts[i.loadedName]=i),t.fontMatrix=i.fontMatrix||r.FONT_IDENTITY_MATRIX;let a="normal";i.black?a="900":i.bold&&(a="bold");let s=i.italic?"italic":"normal";n<0?(n=-n,t.fontDirection=-1):t.fontDirection=1,t.fontSize=n,t.fontFamily=i.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,i){this.current.strokeColor=r.Util.makeHexColor(e,t,i)}setFillAlpha(e){this.current.fillAlpha=e}setFillRGBColor(e,t,i){this.current.fillColor=r.Util.makeHexColor(e,t,i),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:i}=this.viewport,n=r.Util.inverseTransform(this.transformMatrix),[a,s,o,l]=r.Util.getAxialAlignedBoundingBox([0,0,t,i],n),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],i=e[2],n=e[3]||r.IDENTITY_MATRIX,[a,s,o,l]=e[4],h=e[5],c=e[6],u=e[7],d="shading"+v++,[p,f,m,g]=r.Util.normalizeRect([...r.Util.applyTransform([a,s],n),...r.Util.applyTransform([o,l],n)]),[y,x]=r.Util.singularValueDecompose2dScale(n),b=h*y,_=c*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=n,2===u){let e=r.Util.makeHexColor(...t);this.current.fillColor=e,this.current.strokeColor=e}return this.executeOpTree(this.convertOpList(i)),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,i="shading"+v++,n=e[3];switch(e[1]){case"axial":let n=e[4],r=e[5];t=this.svgFactory.createElement("svg:linearGradient"),t.setAttributeNS(null,"id",i),t.setAttributeNS(null,"gradientUnits","userSpaceOnUse"),t.setAttributeNS(null,"x1",n[0]),t.setAttributeNS(null,"y1",n[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",i),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 n){let i=this.svgFactory.createElement("svg:stop");i.setAttributeNS(null,"offset",e[0]),i.setAttributeNS(null,"stop-color",e[1]),t.append(i)}return this.defs.append(t),`url(#${i})`;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 i=this.current,n=i.x,a=i.y,s=[],o=0;for(let l of e)switch(0|l){case r.OPS.rectangle:n=t[o++],a=t[o++];let e=n+t[o++],i=a+t[o++];s.push("M",p(n),p(a),"L",p(e),p(a),"L",p(e),p(i),"L",p(n),p(i),"Z");break;case r.OPS.moveTo:n=t[o++],a=t[o++],s.push("M",p(n),p(a));break;case r.OPS.lineTo:n=t[o++],a=t[o++],s.push("L",p(n),p(a));break;case r.OPS.curveTo:n=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(n),p(a)),o+=6;break;case r.OPS.curveTo2:s.push("C",p(n),p(a),p(t[o]),p(t[o+1]),p(t[o+2]),p(t[o+3])),n=t[o+2],a=t[o+3],o+=4;break;case r.OPS.curveTo3:n=t[o+2],a=t[o+3],s.push("C",p(t[o]),p(t[o+1]),p(n),p(a),p(n),p(a)),o+=4;break;case r.OPS.closePath:s.push("Z")}s=s.join(" "),i.path&&e.length>0&&e[0]!==r.OPS.rectangle&&e[0]!==r.OPS.moveTo?s=i.path.getAttributeNS(null,"d")+s:(i.path=this.svgFactory.createElement("svg:path"),this._ensureTransformGroup().append(i.path)),i.path.setAttributeNS(null,"d",s),i.path.setAttributeNS(null,"fill","none"),i.element=i.path,i.setCurrentPoint(n,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++,i=this.svgFactory.createElement("svg:clipPath");i.setAttributeNS(null,"id",t),i.setAttributeNS(null,"transform",f(this.transformMatrix));let n=e.element.cloneNode(!0);if("evenodd"===this.pendingClip?n.setAttributeNS(null,"clip-rule","evenodd"):n.setAttributeNS(null,"clip-rule","nonzero"),this.pendingClip=null,i.append(n),this.defs.append(i),e.activeClipUrl){e.clipGroup=null;for(let e of this.extraStack)e.clipGroup=null;i.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,i]of e)switch(t){case"LW":this.setLineWidth(i);break;case"LC":this.setLineCap(i);break;case"LJ":this.setLineJoin(i);break;case"ML":this.setMiterLimit(i);break;case"D":this.setDash(i[0],i[1]);break;case"RI":this.setRenderingIntent(i);break;case"FL":this.setFlatness(i);break;case"Font":this.setFont(i);break;case"CA":this.setStrokeAlpha(i);break;case"ca":this.setFillAlpha(i);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 i=this.current,n=i.dashArray;1!==t&&n.length>0&&(n=n.map((function(e){return t*e}))),e.setAttributeNS(null,"stroke",i.strokeColor),e.setAttributeNS(null,"stroke-opacity",i.strokeAlpha),e.setAttributeNS(null,"stroke-miterlimit",p(i.miterLimit)),e.setAttributeNS(null,"stroke-linecap",i.lineCap),e.setAttributeNS(null,"stroke-linejoin",i.lineJoin),e.setAttributeNS(null,"stroke-width",p(t*i.lineWidth)+"px"),e.setAttributeNS(null,"stroke-dasharray",n.map(p).join(" ")),e.setAttributeNS(null,"stroke-dashoffset",p(t*i.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 i=e.width,n=e.height,r=u(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(i)),a.setAttributeNS(null,"height",p(n)),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(-n)),s.setAttributeNS(null,"width",p(i)+"px"),s.setAttributeNS(null,"height",p(n)+"px"),s.setAttributeNS(null,"transform",`scale(${p(1/i)} ${p(-1/n)})`),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 i=this.current,n=t.width,a=t.height,s=i.fillColor;i.maskId="mask"+g++;let o=this.svgFactory.createElement("svg:mask");o.setAttributeNS(null,"id",i.maskId);let l=this.svgFactory.createElement("svg:rect");l.setAttributeNS(null,"x","0"),l.setAttributeNS(null,"y","0"),l.setAttributeNS(null,"width",p(n)),l.setAttributeNS(null,"height",p(a)),l.setAttributeNS(null,"fill",s),l.setAttributeNS(null,"mask",`url(#${i.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],i=t[3]-t[1],n=this.svgFactory.createElement("svg:rect");n.setAttributeNS(null,"x",t[0]),n.setAttributeNS(null,"y",t[1]),n.setAttributeNS(null,"width",p(e)),n.setAttributeNS(null,"height",p(i)),this.current.element=n,this.clip("nonzero"),this.endPath()}}paintFormXObjectEnd(){}_initialize(e){let t=this.svgFactory.create(e.width,e.height),i=this.svgFactory.createElement("svg:defs");t.append(i),this.defs=i;let n=this.svgFactory.createElement("svg:g");return n.setAttributeNS(null,"transform",f(e.transform)),t.append(n),this.svg=n,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 i=__webpack_module_cache__[e]={exports:{}};return __webpack_modules__[e](i,i.exports,__w_pdfjs_require__),i.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 i.PDFDataRangeTransport}}),Object.defineProperty(e,"PDFDateString",{enumerable:!0,get:function(){return n.PDFDateString}}),Object.defineProperty(e,"PDFWorker",{enumerable:!0,get:function(){return i.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 n.PixelsPerInch}}),Object.defineProperty(e,"PromiseCapability",{enumerable:!0,get:function(){return t.PromiseCapability}}),Object.defineProperty(e,"RenderingCancelledException",{enumerable:!0,get:function(){return n.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 i.build}}),Object.defineProperty(e,"createValidAbsoluteUrl",{enumerable:!0,get:function(){return t.createValidAbsoluteUrl}}),Object.defineProperty(e,"getDocument",{enumerable:!0,get:function(){return i.getDocument}}),Object.defineProperty(e,"getFilenameFromUrl",{enumerable:!0,get:function(){return n.getFilenameFromUrl}}),Object.defineProperty(e,"getPdfFilenameFromUrl",{enumerable:!0,get:function(){return n.getPdfFilenameFromUrl}}),Object.defineProperty(e,"getXfaPageViewport",{enumerable:!0,get:function(){return n.getXfaPageViewport}}),Object.defineProperty(e,"isDataScheme",{enumerable:!0,get:function(){return n.isDataScheme}}),Object.defineProperty(e,"isPdfFile",{enumerable:!0,get:function(){return n.isPdfFile}}),Object.defineProperty(e,"loadScript",{enumerable:!0,get:function(){return n.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 n.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 i.version}});var t=__w_pdfjs_require__(1),i=__w_pdfjs_require__(2),n=__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 c=__w_pdfjs_require__(34).SVGGraphics;e.SVGGraphics=c})(),__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("f23e8d9905d90cb99a552605be098e1250909936ef3567ea1c2d73a5b06d4620")){var e=document.createElement("style");e.id="f23e8d9905d90cb99a552605be098e1250909936ef3567ea1c2d73a5b06d4620",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-threejs-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-threejs-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 lSe=fetch;window.fetch=(...e)=>Promise.resolve(lSe(...e));var Pon=Xi(XG(),1),Ion=Xi(Kle(),1),Lon=Xi(Jle(),1),Wt={};zT(Wt,{ACESFilmicToneMapping:()=>Xue,AddEquation:()=>Go,AddOperation:()=>Gue,AdditiveAnimationBlendMode:()=>kU,AdditiveBlending:()=>Ec,AlphaFormat:()=>Kue,AlwaysCompare:()=>mhe,AlwaysDepth:()=>Fue,AlwaysStencilFunc:()=>ohe,AmbientLight:()=>Cl,AmbientLightProbe:()=>iU,AnimationAction:()=>WR,AnimationClip:()=>uo,AnimationLoader:()=>ZB,AnimationMixer:()=>hU,AnimationObjectGroup:()=>uU,AnimationUtils:()=>tot,ArcCurve:()=>bm,ArrayCamera:()=>TR,ArrowHelper:()=>Sc,Audio:()=>GR,AudioAnalyser:()=>lU,AudioContext:()=>Fb,AudioListener:()=>aU,AudioLoader:()=>nU,AxesHelper:()=>SU,BackSide:()=>Ji,BasicDepthPacking:()=>she,BasicShadowMap:()=>Get,Bone:()=>Sl,BooleanKeyframeTrack:()=>Qh,Box2:()=>Mi,Box3:()=>Nt,Box3Helper:()=>TU,BoxGeometry:()=>pa,BoxHelper:()=>_U,BufferAttribute:()=>mn,BufferGeometry:()=>Dt,BufferGeometryLoader:()=>zR,ByteType:()=>$ue,Cache:()=>Sm,Camera:()=>Xh,CameraHelper:()=>Ub,CanvasTexture:()=>wb,CapsuleGeometry:()=>dv,CatmullRomCurve3:()=>RR,CineonToneMapping:()=>jue,CircleGeometry:()=>fv,ClampToEdgeWrapping:()=>Li,Clock:()=>ho,Color:()=>ct,ColorKeyframeTrack:()=>Lb,ColorManagement:()=>_l,CompressedArrayTexture:()=>qB,CompressedCubeTexture:()=>WB,CompressedTexture:()=>Su,CompressedTextureLoader:()=>KB,ConeGeometry:()=>pv,CubeCamera:()=>ER,CubeReflectionMapping:()=>Gh,CubeRefractionMapping:()=>uf,CubeTexture:()=>xm,CubeTextureLoader:()=>Db,CubeUVReflectionMapping:()=>Mv,CubicBezierCurve:()=>Sb,CubicBezierCurve3:()=>AR,CubicInterpolant:()=>FR,CullFaceBack:()=>$N,CullFaceFront:()=>Mue,CullFaceFrontBack:()=>zet,CullFaceNone:()=>Sue,Curve:()=>Ba,CurvePath:()=>PR,CustomBlending:()=>Pm,CustomToneMapping:()=>Yue,CylinderGeometry:()=>Tc,Cylindrical:()=>gU,Data3DTexture:()=>xb,DataArrayTexture:()=>ov,DataTexture:()=>wl,DataTextureLoader:()=>Rm,DataUtils:()=>Pv,DecrementStencilOp:()=>Jet,DecrementWrapStencilOp:()=>ett,DefaultLoadingManager:()=>fo,DepthFormat:()=>cf,DepthStencilFormat:()=>Wh,DepthTexture:()=>ff,DirectionalLight:()=>qs,DirectionalLightHelper:()=>Bb,DiscreteInterpolant:()=>NR,DisplayP3ColorSpace:()=>BU,DodecahedronGeometry:()=>mv,DoubleSide:()=>Sr,DstAlphaFactor:()=>wv,DstColorFactor:()=>Sv,DynamicCopyUsage:()=>mtt,DynamicDrawUsage:()=>ctt,DynamicReadUsage:()=>dtt,EdgesGeometry:()=>Au,EllipseCurve:()=>Kh,EqualCompare:()=>uhe,EqualDepth:()=>Bue,EqualStencilFunc:()=>itt,EquirectangularReflectionMapping:()=>vm,EquirectangularRefractionMapping:()=>fb,Euler:()=>Xn,EventDispatcher:()=>Wo,ExtrudeGeometry:()=>Qs,FileLoader:()=>Kr,Float16BufferAttribute:()=>LB,Float32BufferAttribute:()=>Bt,Float64BufferAttribute:()=>DB,FloatType:()=>fa,Fog:()=>Tu,FogExp2:()=>cv,FramebufferTexture:()=>GB,FrontSide:()=>pi,Frustum:()=>ma,GLBufferAttribute:()=>pU,GLSL1:()=>vtt,GLSL3:()=>TB,GreaterCompare:()=>dhe,GreaterDepth:()=>Hue,GreaterEqualCompare:()=>phe,GreaterEqualDepth:()=>Uue,GreaterEqualStencilFunc:()=>ltt,GreaterStencilFunc:()=>att,GridHelper:()=>Nb,Group:()=>er,HalfFloatType:()=>Mr,HemisphereLight:()=>Du,HemisphereLightHelper:()=>bU,HemisphereLightProbe:()=>rU,IcosahedronGeometry:()=>gv,ImageBitmapLoader:()=>kb,ImageLoader:()=>Mm,ImageUtils:()=>yb,IncrementStencilOp:()=>Ket,IncrementWrapStencilOp:()=>Qet,InstancedBufferAttribute:()=>Zh,InstancedBufferGeometry:()=>VR,InstancedInterleavedBuffer:()=>fU,InstancedMesh:()=>Oi,Int16BufferAttribute:()=>PB,Int32BufferAttribute:()=>IB,Int8BufferAttribute:()=>AB,IntType:()=>CU,InterleavedBuffer:()=>$h,InterleavedBufferAttribute:()=>co,Interpolant:()=>Jh,InterpolateDiscrete:()=>jh,InterpolateLinear:()=>_u,InterpolateSmooth:()=>mR,InvertStencilOp:()=>ttt,KeepStencilOp:()=>gR,KeyframeTrack:()=>Xo,LOD:()=>MR,LatheGeometry:()=>_m,Layers:()=>df,LessCompare:()=>che,LessDepth:()=>Nue,LessEqualCompare:()=>hhe,LessEqualDepth:()=>vR,LessEqualStencilFunc:()=>stt,LessStencilFunc:()=>rtt,Light:()=>Gs,LightProbe:()=>Ev,Line:()=>fr,Line3:()=>ra,LineBasicMaterial:()=>Gn,LineCurve:()=>hv,LineCurve3:()=>CR,LineDashedMaterial:()=>Iu,LineLoop:()=>uv,LineSegments:()=>qr,LinearEncoding:()=>NU,LinearFilter:()=>Pr,LinearInterpolant:()=>Ib,LinearMipMapLinearFilter:()=>Yet,LinearMipMapNearestFilter:()=>Xet,LinearMipmapLinearFilter:()=>Fa,LinearMipmapNearestFilter:()=>Im,LinearSRGBColorSpace:()=>Na,LinearToneMapping:()=>que,Loader:()=>Er,LoaderUtils:()=>ta,LoadingManager:()=>Lu,LoopOnce:()=>nhe,LoopPingPong:()=>ihe,LoopRepeat:()=>rhe,LuminanceAlphaFormat:()=>Jue,LuminanceFormat:()=>$R,MOUSE:()=>XR,Material:()=>yr,MaterialLoader:()=>_v,MathUtils:()=>Rn,Matrix3:()=>Ln,Matrix4:()=>et,MaxEquation:()=>QN,Mesh:()=>xt,MeshBasicMaterial:()=>ln,MeshDepthMaterial:()=>_c,MeshDistanceMaterial:()=>_b,MeshLambertMaterial:()=>Pu,MeshMatcapMaterial:()=>kR,MeshNormalMaterial:()=>mf,MeshPhongMaterial:()=>ea,MeshPhysicalMaterial:()=>jo,MeshStandardMaterial:()=>Cu,MeshToonMaterial:()=>OR,MinEquation:()=>JN,MirroredRepeatWrapping:()=>qh,MixOperation:()=>zue,MultiplyBlending:()=>KN,MultiplyOperation:()=>Hb,NearestFilter:()=>Jr,NearestMipMapLinearFilter:()=>jet,NearestMipMapNearestFilter:()=>Wet,NearestMipmapLinearFilter:()=>zh,NearestMipmapNearestFilter:()=>hf,NeverCompare:()=>lhe,NeverDepth:()=>kue,NeverStencilFunc:()=>ntt,NoBlending:()=>Qr,NoColorSpace:()=>Eu,NoToneMapping:()=>Vh,NormalAnimationBlendMode:()=>KR,NormalBlending:()=>mm,NotEqualCompare:()=>fhe,NotEqualDepth:()=>Vue,NotEqualStencilFunc:()=>ott,NumberKeyframeTrack:()=>Al,Object3D:()=>on,ObjectLoader:()=>tU,ObjectSpaceNormalMap:()=>ahe,OctahedronGeometry:()=>wm,OneFactor:()=>Cue,OneMinusDstAlphaFactor:()=>Lue,OneMinusDstColorFactor:()=>Due,OneMinusSrcAlphaFactor:()=>AU,OneMinusSrcColorFactor:()=>Iue,OrthographicCamera:()=>Nr,PCFShadowMap:()=>MU,PCFSoftShadowMap:()=>Tv,PMREMGenerator:()=>Yh,Path:()=>Mu,PerspectiveCamera:()=>hr,Plane:()=>zr,PlaneGeometry:()=>ui,PlaneHelper:()=>wU,PointLight:()=>wc,PointLightHelper:()=>xU,Points:()=>ii,PointsMaterial:()=>bi,PolarGridHelper:()=>EU,PolyhedronGeometry:()=>Ru,PositionalAudio:()=>oU,PropertyBinding:()=>Jn,PropertyMixer:()=>qR,QuadraticBezierCurve:()=>Mb,QuadraticBezierCurve3:()=>Rb,Quaternion:()=>dr,QuaternionKeyframeTrack:()=>Ha,QuaternionLinearInterpolant:()=>BR,RED_GREEN_RGTC2_Format:()=>EB,RED_RGTC1_Format:()=>the,REVISION:()=>jR,RGBADepthPacking:()=>Cv,RGBAFormat:()=>Js,RGBAIntegerFormat:()=>OU,RGBA_ASTC_10x10_Format:()=>vB,RGBA_ASTC_10x5_Format:()=>pB,RGBA_ASTC_10x6_Format:()=>mB,RGBA_ASTC_10x8_Format:()=>gB,RGBA_ASTC_12x10_Format:()=>yB,RGBA_ASTC_12x12_Format:()=>xB,RGBA_ASTC_4x4_Format:()=>aB,RGBA_ASTC_5x4_Format:()=>oB,RGBA_ASTC_5x5_Format:()=>lB,RGBA_ASTC_6x5_Format:()=>cB,RGBA_ASTC_6x6_Format:()=>uB,RGBA_ASTC_8x5_Format:()=>hB,RGBA_ASTC_8x6_Format:()=>dB,RGBA_ASTC_8x8_Format:()=>fB,RGBA_BPTC_Format:()=>pR,RGBA_ETC2_EAC_Format:()=>sB,RGBA_PVRTC_2BPPV1_Format:()=>rB,RGBA_PVRTC_4BPPV1_Format:()=>nB,RGBA_S3TC_DXT1_Format:()=>hR,RGBA_S3TC_DXT3_Format:()=>dR,RGBA_S3TC_DXT5_Format:()=>fR,RGB_ETC1_Format:()=>ehe,RGB_ETC2_Format:()=>iB,RGB_PVRTC_2BPPV1_Format:()=>tB,RGB_PVRTC_4BPPV1_Format:()=>eB,RGB_S3TC_DXT1_Format:()=>uR,RGFormat:()=>Que,RGIntegerFormat:()=>DU,RawShaderMaterial:()=>DR,Ray:()=>lo,Raycaster:()=>na,RectAreaLight:()=>UR,RedFormat:()=>ZR,RedIntegerFormat:()=>LU,ReinhardToneMapping:()=>Wue,RenderTarget:()=>bR,RepeatWrapping:()=>Di,ReplaceStencilOp:()=>Zet,ReverseSubtractEquation:()=>Aue,RingGeometry:()=>vv,SIGNED_RED_GREEN_RGTC2_Format:()=>_B,SIGNED_RED_RGTC1_Format:()=>bB,SRGBColorSpace:()=>en,Scene:()=>Si,ShaderChunk:()=>$n,ShaderLib:()=>yc,ShaderMaterial:()=>cn,ShadowMaterial:()=>LR,Shape:()=>_s,ShapeGeometry:()=>Rl,ShapePath:()=>Cm,ShapeUtils:()=>zs,ShortType:()=>Zue,Skeleton:()=>Ml,SkeletonHelper:()=>yU,SkinnedMesh:()=>wu,Source:()=>xc,Sphere:()=>vr,SphereGeometry:()=>Ua,Spherical:()=>gf,SphericalHarmonics3:()=>HR,SplineCurve:()=>Em,SpotLight:()=>Ou,SpotLightHelper:()=>vU,Sprite:()=>SR,SpriteMaterial:()=>Tb,SrcAlphaFactor:()=>RU,SrcAlphaSaturateFactor:()=>Oue,SrcColorFactor:()=>Pue,StaticCopyUsage:()=>ptt,StaticDrawUsage:()=>mb,StaticReadUsage:()=>htt,StereoCamera:()=>sU,StreamCopyUsage:()=>gtt,StreamDrawUsage:()=>utt,StreamReadUsage:()=>ftt,StringKeyframeTrack:()=>ed,SubtractEquation:()=>Rue,SubtractiveBlending:()=>ZN,TOUCH:()=>Vet,TangentSpaceNormalMap:()=>yf,TetrahedronGeometry:()=>yv,Texture:()=>Gr,TextureLoader:()=>ws,TorusGeometry:()=>pf,TorusKnotGeometry:()=>xv,Triangle:()=>Zr,TriangleFanDrawMode:()=>Av,TriangleStripDrawMode:()=>Vb,TrianglesDrawMode:()=>FU,TubeGeometry:()=>bv,TwoPassDoubleSide:()=>qet,UVMapping:()=>YR,Uint16BufferAttribute:()=>ym,Uint32BufferAttribute:()=>Eb,Uint8BufferAttribute:()=>bb,Uint8ClampedBufferAttribute:()=>CB,Uniform:()=>Am,UniformsGroup:()=>dU,UniformsLib:()=>Jt,UniformsUtils:()=>Ri,UnsignedByteType:()=>bc,UnsignedInt248Type:()=>xu,UnsignedIntType:()=>Hh,UnsignedShort4444Type:()=>PU,UnsignedShort5551Type:()=>IU,UnsignedShortType:()=>Rv,VSMShadowMap:()=>vu,Vector2:()=>xe,Vector3:()=>D,Vector4:()=>gr,VectorKeyframeTrack:()=>Va,VideoTexture:()=>zB,WebGL1Renderer:()=>wR,WebGL3DRenderTarget:()=>MB,WebGLArrayRenderTarget:()=>SB,WebGLCoordinateSystem:()=>yu,WebGLCubeRenderTarget:()=>_R,WebGLMultipleRenderTargets:()=>RB,WebGLRenderTarget:()=>sr,WebGLRenderer:()=>Ts,WebGLUtils:()=>She,WebGPUCoordinateSystem:()=>gb,WireframeGeometry:()=>IR,WrapAroundEnding:()=>pb,ZeroCurvatureEnding:()=>dm,ZeroFactor:()=>vf,ZeroSlopeEnding:()=>fm,ZeroStencilOp:()=>$et,_SRGBAFormat:()=>yR,sRGBEncoding:()=>bu});var jR="155",XR={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},Vet={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},Sue=0,$N=1,Mue=2,zet=3,Get=0,MU=1,Tv=2,vu=3,pi=0,Ji=1,Sr=2,qet=2,Qr=0,mm=1,Ec=2,ZN=3,KN=4,Pm=5,Go=100,Rue=101,Aue=102,JN=103,QN=104,vf=200,Cue=201,Pue=202,Iue=203,RU=204,AU=205,wv=206,Lue=207,Sv=208,Due=209,Oue=210,kue=0,Fue=1,Nue=2,vR=3,Bue=4,Uue=5,Hue=6,Vue=7,Hb=0,zue=1,Gue=2,Vh=0,que=1,Wue=2,jue=3,Xue=4,Yue=5,YR=300,Gh=301,uf=302,vm=303,fb=304,Mv=306,Di=1e3,Li=1001,qh=1002,Jr=1003,hf=1004,Wet=1004,zh=1005,jet=1005,Pr=1006,Im=1007,Xet=1007,Fa=1008,Yet=1008,bc=1009,$ue=1010,Zue=1011,Rv=1012,CU=1013,Hh=1014,fa=1015,Mr=1016,PU=1017,IU=1018,xu=1020,Kue=1021,Js=1023,$R=1024,Jue=1025,cf=1026,Wh=1027,ZR=1028,LU=1029,Que=1030,DU=1031,OU=1033,uR=33776,hR=33777,dR=33778,fR=33779,eB=35840,tB=35841,nB=35842,rB=35843,ehe=36196,iB=37492,sB=37496,aB=37808,oB=37809,lB=37810,cB=37811,uB=37812,hB=37813,dB=37814,fB=37815,pB=37816,mB=37817,gB=37818,vB=37819,yB=37820,xB=37821,pR=36492,the=36283,bB=36284,EB=36285,_B=36286,nhe=2200,rhe=2201,ihe=2202,jh=2300,_u=2301,mR=2302,dm=2400,fm=2401,pb=2402,KR=2500,kU=2501,FU=0,Vb=1,Av=2,NU=3e3,bu=3001,she=3200,Cv=3201,yf=0,ahe=1,Eu="",en="srgb",Na="srgb-linear",BU="display-p3",$et=0,gR=7680,Zet=7681,Ket=7682,Jet=7683,Qet=34055,ett=34056,ttt=5386,ntt=512,rtt=513,itt=514,stt=515,att=516,ott=517,ltt=518,ohe=519,lhe=512,che=513,uhe=514,hhe=515,dhe=516,fhe=517,phe=518,mhe=519,mb=35044,ctt=35048,utt=35040,htt=35045,dtt=35049,ftt=35041,ptt=35046,mtt=35050,gtt=35042,vtt="100",TB="300 es",yR=1035,yu=2e3,gb=2001,Wo=class{addEventListener(e,t){void 0===this._listeners&&(this._listeners={});let i=this._listeners;void 0===i[e]&&(i[e]=[]),-1===i[e].indexOf(t)&&i[e].push(t)}hasEventListener(e,t){if(void 0===this._listeners)return!1;let i=this._listeners;return void 0!==i[e]&&-1!==i[e].indexOf(t)}removeEventListener(e,t){if(void 0===this._listeners)return;let i=this._listeners[e];if(void 0!==i){let e=i.indexOf(t);-1!==e&&i.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 i=t.slice(0);for(let t=0,n=i.length;t<n;t++)i[t].call(this,e);e.target=null}}},ha=["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"],Qle=1234567,gm=Math.PI/180,av=180/Math.PI;function qo(){let e=4294967295*Math.random()|0,t=4294967295*Math.random()|0,i=4294967295*Math.random()|0,n=4294967295*Math.random()|0;return(ha[255&e]+ha[e>>8&255]+ha[e>>16&255]+ha[e>>24&255]+"-"+ha[255&t]+ha[t>>8&255]+"-"+ha[t>>16&15|64]+ha[t>>24&255]+"-"+ha[63&i|128]+ha[i>>8&255]+"-"+ha[i>>16&255]+ha[i>>24&255]+ha[255&n]+ha[n>>8&255]+ha[n>>16&255]+ha[n>>24&255]).toLowerCase()}function os(e,t,i){return Math.max(t,Math.min(i,e))}function UU(e,t){return(e%t+t)%t}function ytt(e,t,i,n,r){return n+(e-t)*(r-n)/(i-t)}function xtt(e,t,i){return e!==t?(i-e)/(t-e):0}function lb(e,t,i){return(1-i)*e+i*t}function btt(e,t,i,n){return lb(e,t,1-Math.exp(-i*n))}function Ett(e,t=1){return t-Math.abs(UU(e,2*t)-t)}function _tt(e,t,i){return e<=t?0:e>=i?1:(e=(e-t)/(i-t))*e*(3-2*e)}function Ttt(e,t,i){return e<=t?0:e>=i?1:(e=(e-t)/(i-t))*e*e*(e*(6*e-15)+10)}function wtt(e,t){return e+Math.floor(Math.random()*(t-e+1))}function Stt(e,t){return e+Math.random()*(t-e)}function Mtt(e){return e*(.5-Math.random())}function Rtt(e){void 0!==e&&(Qle=e);let t=Qle+=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 Att(e){return e*gm}function Ctt(e){return e*av}function wB(e){return 0==(e&e-1)&&0!==e}function ghe(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))}function xR(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}function Ptt(e,t,i,n,r){let a=Math.cos,s=Math.sin,o=a(i/2),l=s(i/2),h=a((t+n)/2),c=s((t+n)/2),u=a((t-n)/2),d=s((t-n)/2),p=a((n-t)/2),f=s((n-t)/2);switch(r){case"XYX":e.set(o*c,l*u,l*d,o*h);break;case"YZY":e.set(l*d,o*c,l*u,o*h);break;case"ZXZ":e.set(l*u,l*d,o*c,o*h);break;case"XZX":e.set(o*c,l*f,l*p,o*h);break;case"YXY":e.set(l*p,o*c,l*f,o*h);break;case"ZYZ":e.set(l*f,l*p,o*c,o*h);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function oo(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 mr(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 Rn={DEG2RAD:gm,RAD2DEG:av,generateUUID:qo,clamp:os,euclideanModulo:UU,mapLinear:ytt,inverseLerp:xtt,lerp:lb,damp:btt,pingpong:Ett,smoothstep:_tt,smootherstep:Ttt,randInt:wtt,randFloat:Stt,randFloatSpread:Mtt,seededRandom:Rtt,degToRad:Att,radToDeg:Ctt,isPowerOfTwo:wB,ceilPowerOfTwo:ghe,floorPowerOfTwo:xR,setQuaternionFromProperEuler:Ptt,normalize:mr,denormalize:oo},xe=class{constructor(e=0,t=0){xe.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,i=this.y,n=e.elements;return this.x=n[0]*t+n[3]*i+n[6],this.y=n[1]*t+n[4]*i+n[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 i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}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 i=this.dot(e)/t;return Math.acos(os(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,i=this.y-e.y;return t*t+i*i}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,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,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 i=Math.cos(t),n=Math.sin(t),r=this.x-e.x,a=this.y-e.y;return this.x=r*i-a*n+e.x,this.y=r*n+a*i+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},Ln=class{constructor(e,t,i,n,r,a,s,o,l){Ln.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],void 0!==e&&this.set(e,t,i,n,r,a,s,o,l)}set(e,t,i,n,r,a,s,o,l){let h=this.elements;return h[0]=e,h[1]=n,h[2]=s,h[3]=t,h[4]=r,h[5]=o,h[6]=i,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,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],this}extractBasis(e,t,i){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),i.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 i=e.elements,n=t.elements,r=this.elements,a=i[0],s=i[3],o=i[6],l=i[1],h=i[4],c=i[7],u=i[2],d=i[5],p=i[8],f=n[0],m=n[3],g=n[6],v=n[1],y=n[4],x=n[7],b=n[2],_=n[5],w=n[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+c*b,r[4]=l*m+h*y+c*_,r[7]=l*g+h*x+c*w,r[2]=u*f+d*v+p*b,r[5]=u*m+d*y+p*_,r[8]=u*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],i=e[1],n=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-i*r*h+i*s*o+n*r*l-n*a*o}invert(){let e=this.elements,t=e[0],i=e[1],n=e[2],r=e[3],a=e[4],s=e[5],o=e[6],l=e[7],h=e[8],c=h*a-s*l,u=s*o-h*r,d=l*r-a*o,p=t*c+i*u+n*d;if(0===p)return this.set(0,0,0,0,0,0,0,0,0);let f=1/p;return e[0]=c*f,e[1]=(n*l-h*i)*f,e[2]=(s*i-n*a)*f,e[3]=u*f,e[4]=(h*t-n*o)*f,e[5]=(n*r-s*t)*f,e[6]=d*f,e[7]=(i*o-l*t)*f,e[8]=(a*t-i*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,i,n,r,a,s){let o=Math.cos(r),l=Math.sin(r);return this.set(i*o,i*l,-i*(o*a+l*s)+a+e,-n*l,n*o,-n*(-l*a+o*s)+s+t,0,0,1),this}scale(e,t){return this.premultiply(vN.makeScale(e,t)),this}rotate(e){return this.premultiply(vN.makeRotation(-e)),this}translate(e,t){return this.premultiply(vN.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),i=Math.sin(e);return this.set(t,-i,0,i,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,i=e.elements;for(let n=0;n<9;n++)if(t[n]!==i[n])return!1;return!0}fromArray(e,t=0){for(let i=0;i<9;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){let i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e}clone(){return(new this.constructor).fromArray(this.elements)}},vN=new Ln;function vhe(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}var Itt={Int8Array:Int8Array,Uint8Array:Uint8Array,Uint8ClampedArray:Uint8ClampedArray,Int16Array:Int16Array,Uint16Array:Uint16Array,Int32Array:Int32Array,Uint32Array:Uint32Array,Float32Array:Float32Array,Float64Array:Float64Array};function tv(e,t){return new Itt[e](t)}function vb(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}var ece={};function cb(e){e in ece||(ece[e]=!0,console.warn(e))}function iv(e){return e<.04045?.0773993808*e:Math.pow(.9478672986*e+.0521327014,2.4)}function yN(e){return e<.0031308?12.92*e:1.055*Math.pow(e,.41666)-.055}var Ltt=(new Ln).fromArray([.8224621,.0331941,.0170827,.177538,.9668058,.0723974,-1e-7,1e-7,.9105199]),Dtt=(new Ln).fromArray([1.2249401,-.0420569,-.0196376,-.2249404,1.0420571,-.0786361,1e-7,0,1.0982735]);function Ott(e){return e.convertSRGBToLinear().applyMatrix3(Dtt)}function ktt(e){return e.applyMatrix3(Ltt).convertLinearToSRGB()}var Ftt={[Na]:e=>e,[en]:e=>e.convertSRGBToLinear(),[BU]:Ott},Ntt={[Na]:e=>e,[en]:e=>e.convertLinearToSRGB(),[BU]:ktt},_l={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 Na},set workingColorSpace(e){console.warn("THREE.ColorManagement: .workingColorSpace is readonly.")},convert:function(e,t,i){if(!1===this.enabled||t===i||!t||!i)return e;let n=Ftt[t],r=Ntt[i];if(void 0===n||void 0===r)throw new Error(`Unsupported color space conversion, "${t}" to "${i}".`);return r(n(e))},fromWorkingColorSpace:function(e,t){return this.convert(e,this.workingColorSpace,t)},toWorkingColorSpace:function(e,t){return this.convert(e,t,this.workingColorSpace)}},D0,yb=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===D0&&(D0=vb("canvas")),D0.width=e.width,D0.height=e.height;let i=D0.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),t=D0}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=vb("canvas");t.width=e.width,t.height=e.height;let i=t.getContext("2d");i.drawImage(e,0,0,e.width,e.height);let n=i.getImageData(0,0,e.width,e.height),r=n.data;for(let e=0;e<r.length;e++)r[e]=255*iv(r[e]/255);return i.putImageData(n,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*iv(t[e]/255)):t[e]=iv(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}},Btt=0,xc=class{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:Btt++}),this.uuid=qo(),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 i={uuid:this.uuid,url:""},n=this.data;if(null!==n){let e;if(Array.isArray(n)){e=[];for(let t=0,i=n.length;t<i;t++)n[t].isDataTexture?e.push(xN(n[t].image)):e.push(xN(n[t]))}else e=xN(n);i.url=e}return t||(e.images[this.uuid]=i),i}};function xN(e){return"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap?yb.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 Utt=0,Gr=class extends Wo{constructor(e=Gr.DEFAULT_IMAGE,t=Gr.DEFAULT_MAPPING,i=Li,n=Li,r=Pr,a=Fa,s=Js,o=bc,l=Gr.DEFAULT_ANISOTROPY,h=Eu){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Utt++}),this.uuid=qo(),this.name="",this.source=new xc(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=i,this.wrapT=n,this.magFilter=r,this.minFilter=a,this.anisotropy=l,this.format=s,this.internalFormat=null,this.type=o,this.offset=new xe(0,0),this.repeat=new xe(1,1),this.center=new xe(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Ln,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,"string"==typeof h?this.colorSpace=h:(cb("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=h===bu?en:Eu),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 i={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&&(i.userData=this.userData),t||(e.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==YR)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Di:e.x=e.x-Math.floor(e.x);break;case Li:e.x=e.x<0?0:1;break;case qh: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 Di:e.y=e.y-Math.floor(e.y);break;case Li:e.y=e.y<0?0:1;break;case qh: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 cb("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace===en?bu:NU}set encoding(e){cb("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=e===bu?en:Eu}};Gr.DEFAULT_IMAGE=null,Gr.DEFAULT_MAPPING=YR,Gr.DEFAULT_ANISOTROPY=1;var gr=class{constructor(e=0,t=0,i=0,n=1){gr.prototype.isVector4=!0,this.x=e,this.y=t,this.z=i,this.w=n}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,i,n){return this.x=e,this.y=t,this.z=i,this.w=n,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,i=this.y,n=this.z,r=this.w,a=e.elements;return this.x=a[0]*t+a[4]*i+a[8]*n+a[12]*r,this.y=a[1]*t+a[5]*i+a[9]*n+a[13]*r,this.z=a[2]*t+a[6]*i+a[10]*n+a[14]*r,this.w=a[3]*t+a[7]*i+a[11]*n+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,i,n,r,a=e.elements,s=a[0],o=a[4],l=a[8],h=a[1],c=a[5],u=a[9],d=a[2],p=a[6],f=a[10];if(Math.abs(o-h)<.01&&Math.abs(l-d)<.01&&Math.abs(u-p)<.01){if(Math.abs(o+h)<.1&&Math.abs(l+d)<.1&&Math.abs(u+p)<.1&&Math.abs(s+c+f-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;let e=(s+1)/2,a=(c+1)/2,m=(f+1)/2,g=(o+h)/4,v=(l+d)/4,y=(u+p)/4;return e>a&&e>m?e<.01?(i=0,n=.707106781,r=.707106781):(i=Math.sqrt(e),n=g/i,r=v/i):a>m?a<.01?(i=.707106781,n=0,r=.707106781):(n=Math.sqrt(a),i=g/n,r=y/n):m<.01?(i=.707106781,n=.707106781,r=0):(r=Math.sqrt(m),i=v/r,n=y/r),this.set(i,n,r,t),this}let m=Math.sqrt((p-u)*(p-u)+(l-d)*(l-d)+(h-o)*(h-o));return Math.abs(m)<.001&&(m=1),this.x=(p-u)/m,this.y=(l-d)/m,this.z=(h-o)/m,this.w=Math.acos((s+c+f-1)/2),this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this.w=Math.max(e.w,Math.min(t.w,this.w)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this.w=Math.max(e,Math.min(t,this.w)),this}clampLength(e,t){let i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}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,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this.w=e.w+(t.w-e.w)*i,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}},bR=class extends Wo{constructor(e=1,t=1,i={}){super(),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=1,this.scissor=new gr(0,0,e,t),this.scissorTest=!1,this.viewport=new gr(0,0,e,t);let n={width:e,height:t,depth:1};void 0!==i.encoding&&(cb("THREE.WebGLRenderTarget: option.encoding has been replaced by option.colorSpace."),i.colorSpace=i.encoding===bu?en:Eu),this.texture=new Gr(n,i.mapping,i.wrapS,i.wrapT,i.magFilter,i.minFilter,i.format,i.type,i.anisotropy,i.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.flipY=!1,this.texture.generateMipmaps=void 0!==i.generateMipmaps&&i.generateMipmaps,this.texture.internalFormat=void 0!==i.internalFormat?i.internalFormat:null,this.texture.minFilter=void 0!==i.minFilter?i.minFilter:Pr,this.depthBuffer=void 0===i.depthBuffer||i.depthBuffer,this.stencilBuffer=void 0!==i.stencilBuffer&&i.stencilBuffer,this.depthTexture=void 0!==i.depthTexture?i.depthTexture:null,this.samples=void 0!==i.samples?i.samples:0}setSize(e,t,i=1){(this.width!==e||this.height!==t||this.depth!==i)&&(this.width=e,this.height=t,this.depth=i,this.texture.image.width=e,this.texture.image.height=t,this.texture.image.depth=i,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 xc(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"})}},sr=class extends bR{constructor(e=1,t=1,i={}){super(e,t,i),this.isWebGLRenderTarget=!0}},ov=class extends Gr{constructor(e=null,t=1,i=1,n=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:i,depth:n},this.magFilter=Jr,this.minFilter=Jr,this.wrapR=Li,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},SB=class extends sr{constructor(e=1,t=1,i=1){super(e,t),this.isWebGLArrayRenderTarget=!0,this.depth=i,this.texture=new ov(null,e,t,i),this.texture.isRenderTargetTexture=!0}},xb=class extends Gr{constructor(e=null,t=1,i=1,n=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:i,depth:n},this.magFilter=Jr,this.minFilter=Jr,this.wrapR=Li,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},MB=class extends sr{constructor(e=1,t=1,i=1){super(e,t),this.isWebGL3DRenderTarget=!0,this.depth=i,this.texture=new xb(null,e,t,i),this.texture.isRenderTargetTexture=!0}},RB=class extends sr{constructor(e=1,t=1,i=1,n={}){super(e,t,n),this.isWebGLMultipleRenderTargets=!0;let r=this.texture;this.texture=[];for(let a=0;a<i;a++)this.texture[a]=r.clone(),this.texture[a].isRenderTargetTexture=!0}setSize(e,t,i=1){if(this.width!==e||this.height!==t||this.depth!==i){this.width=e,this.height=t,this.depth=i;for(let n=0,r=this.texture.length;n<r;n++)this.texture[n].image.width=e,this.texture[n].image.height=t,this.texture[n].image.depth=i;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,i=e.texture.length;t<i;t++)this.texture[t]=e.texture[t].clone(),this.texture[t].isRenderTargetTexture=!0;return this}},dr=class{constructor(e=0,t=0,i=0,n=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=i,this._w=n}static slerpFlat(e,t,i,n,r,a,s){let o=i[n+0],l=i[n+1],h=i[n+2],c=i[n+3],u=r[a+0],d=r[a+1],p=r[a+2],f=r[a+3];if(0===s)return e[t+0]=o,e[t+1]=l,e[t+2]=h,void(e[t+3]=c);if(1===s)return e[t+0]=u,e[t+1]=d,e[t+2]=p,void(e[t+3]=f);if(c!==f||o!==u||l!==d||h!==p){let e=1-s,t=o*u+l*d+h*p+c*f,i=t>=0?1:-1,n=1-t*t;if(n>Number.EPSILON){let r=Math.sqrt(n),a=Math.atan2(r,t*i);e=Math.sin(e*a)/r,s=Math.sin(s*a)/r}let r=s*i;if(o=o*e+u*r,l=l*e+d*r,h=h*e+p*r,c=c*e+f*r,e===1-s){let e=1/Math.sqrt(o*o+l*l+h*h+c*c);o*=e,l*=e,h*=e,c*=e}}e[t]=o,e[t+1]=l,e[t+2]=h,e[t+3]=c}static multiplyQuaternionsFlat(e,t,i,n,r,a){let s=i[n],o=i[n+1],l=i[n+2],h=i[n+3],c=r[a],u=r[a+1],d=r[a+2],p=r[a+3];return e[t]=s*p+h*c+o*d-l*u,e[t+1]=o*p+h*u+l*c-s*d,e[t+2]=l*p+h*d+s*u-o*c,e[t+3]=h*p-s*c-o*u-l*d,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,i,n){return this._x=e,this._y=t,this._z=i,this._w=n,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 i=e._x,n=e._y,r=e._z,a=e._order,s=Math.cos,o=Math.sin,l=s(i/2),h=s(n/2),c=s(r/2),u=o(i/2),d=o(n/2),p=o(r/2);switch(a){case"XYZ":this._x=u*h*c+l*d*p,this._y=l*d*c-u*h*p,this._z=l*h*p+u*d*c,this._w=l*h*c-u*d*p;break;case"YXZ":this._x=u*h*c+l*d*p,this._y=l*d*c-u*h*p,this._z=l*h*p-u*d*c,this._w=l*h*c+u*d*p;break;case"ZXY":this._x=u*h*c-l*d*p,this._y=l*d*c+u*h*p,this._z=l*h*p+u*d*c,this._w=l*h*c-u*d*p;break;case"ZYX":this._x=u*h*c-l*d*p,this._y=l*d*c+u*h*p,this._z=l*h*p-u*d*c,this._w=l*h*c+u*d*p;break;case"YZX":this._x=u*h*c+l*d*p,this._y=l*d*c+u*h*p,this._z=l*h*p-u*d*c,this._w=l*h*c-u*d*p;break;case"XZY":this._x=u*h*c-l*d*p,this._y=l*d*c-u*h*p,this._z=l*h*p+u*d*c,this._w=l*h*c+u*d*p;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return!1!==t&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let i=t/2,n=Math.sin(i);return this._x=e.x*n,this._y=e.y*n,this._z=e.z*n,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,i=t[0],n=t[4],r=t[8],a=t[1],s=t[5],o=t[9],l=t[2],h=t[6],c=t[10],u=i+s+c;if(u>0){let e=.5/Math.sqrt(u+1);this._w=.25/e,this._x=(h-o)*e,this._y=(r-l)*e,this._z=(a-n)*e}else if(i>s&&i>c){let e=2*Math.sqrt(1+i-s-c);this._w=(h-o)/e,this._x=.25*e,this._y=(n+a)/e,this._z=(r+l)/e}else if(s>c){let e=2*Math.sqrt(1+s-i-c);this._w=(r-l)/e,this._x=(n+a)/e,this._y=.25*e,this._z=(o+h)/e}else{let e=2*Math.sqrt(1+c-i-s);this._w=(a-n)/e,this._x=(r+l)/e,this._y=(o+h)/e,this._z=.25*e}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let i=e.dot(t)+1;return i<Number.EPSILON?(i=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=i):(this._x=0,this._y=-e.z,this._z=e.y,this._w=i)):(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=i),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(os(this.dot(e),-1,1)))}rotateTowards(e,t){let i=this.angleTo(e);if(0===i)return this;let n=Math.min(1,t/i);return this.slerp(e,n),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 i=e._x,n=e._y,r=e._z,a=e._w,s=t._x,o=t._y,l=t._z,h=t._w;return this._x=i*h+a*s+n*l-r*o,this._y=n*h+a*o+r*s-i*l,this._z=r*h+a*l+i*o-n*s,this._w=a*h-i*s-n*o-r*l,this._onChangeCallback(),this}slerp(e,t){if(0===t)return this;if(1===t)return this.copy(e);let i=this._x,n=this._y,r=this._z,a=this._w,s=a*e._w+i*e._x+n*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=i,this._y=n,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*i+t*this._x,this._y=e*n+t*this._y,this._z=e*r+t*this._z,this.normalize(),this._onChangeCallback(),this}let l=Math.sqrt(o),h=Math.atan2(l,s),c=Math.sin((1-t)*h)/l,u=Math.sin(t*h)/l;return this._w=a*c+this._w*u,this._x=i*c+this._x*u,this._y=n*c+this._y*u,this._z=r*c+this._z*u,this._onChangeCallback(),this}slerpQuaternions(e,t,i){return this.copy(e).slerp(t,i)}random(){let e=Math.random(),t=Math.sqrt(1-e),i=Math.sqrt(e),n=2*Math.PI*Math.random(),r=2*Math.PI*Math.random();return this.set(t*Math.cos(n),i*Math.sin(r),i*Math.cos(r),t*Math.sin(n))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},D=class{constructor(e=0,t=0,i=0){D.prototype.isVector3=!0,this.x=e,this.y=t,this.z=i}set(e,t,i){return void 0===i&&(i=this.z),this.x=e,this.y=t,this.z=i,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(tce.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(tce.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,i=this.y,n=this.z,r=e.elements;return this.x=r[0]*t+r[3]*i+r[6]*n,this.y=r[1]*t+r[4]*i+r[7]*n,this.z=r[2]*t+r[5]*i+r[8]*n,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,i=this.y,n=this.z,r=e.elements,a=1/(r[3]*t+r[7]*i+r[11]*n+r[15]);return this.x=(r[0]*t+r[4]*i+r[8]*n+r[12])*a,this.y=(r[1]*t+r[5]*i+r[9]*n+r[13])*a,this.z=(r[2]*t+r[6]*i+r[10]*n+r[14])*a,this}applyQuaternion(e){let t=this.x,i=this.y,n=this.z,r=e.x,a=e.y,s=e.z,o=e.w,l=o*t+a*n-s*i,h=o*i+s*t-r*n,c=o*n+r*i-a*t,u=-r*t-a*i-s*n;return this.x=l*o+u*-r+h*-s-c*-a,this.y=h*o+u*-a+c*-r-l*-s,this.z=c*o+u*-s+l*-a-h*-r,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,i=this.y,n=this.z,r=e.elements;return this.x=r[0]*t+r[4]*i+r[8]*n,this.y=r[1]*t+r[5]*i+r[9]*n,this.z=r[2]*t+r[6]*i+r[10]*n,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 i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}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,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let i=e.x,n=e.y,r=e.z,a=t.x,s=t.y,o=t.z;return this.x=n*o-r*s,this.y=r*a-i*o,this.z=i*s-n*a,this}projectOnVector(e){let t=e.lengthSq();if(0===t)return this.set(0,0,0);let i=e.dot(this)/t;return this.copy(e).multiplyScalar(i)}projectOnPlane(e){return bN.copy(this).projectOnVector(e),this.sub(bN)}reflect(e){return this.sub(bN.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 i=this.dot(e)/t;return Math.acos(os(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,i=this.y-e.y,n=this.z-e.z;return t*t+i*i+n*n}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,i){let n=Math.sin(t)*e;return this.x=n*Math.sin(i),this.y=Math.cos(t)*e,this.z=n*Math.cos(i),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,i){return this.x=e*Math.sin(t),this.y=i,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(),i=this.setFromMatrixColumn(e,1).length(),n=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=i,this.z=n,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,i=Math.sqrt(1-Do(e,2));return this.x=i*Math.cos(t),this.y=i*Math.sin(t),this.z=e,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}},bN=new D,tce=new dr,Nt=class{constructor(e=new D(1/0,1/0,1/0),t=new D(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t+=3)this.expandByPoint(Dh.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,i=e.count;t<i;t++)this.expandByPoint(Dh.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let i=Dh.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),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(),O0.copy(e.boundingBox),O0.applyMatrix4(e.matrixWorld),this.union(O0);else{let i=e.geometry;if(void 0!==i)if(t&&void 0!==i.attributes&&void 0!==i.attributes.position){let t=i.attributes.position;for(let i=0,n=t.count;i<n;i++)Dh.fromBufferAttribute(t,i).applyMatrix4(e.matrixWorld),this.expandByPoint(Dh)}else null===i.boundingBox&&i.computeBoundingBox(),O0.copy(i.boundingBox),O0.applyMatrix4(e.matrixWorld),this.union(O0)}let i=e.children;for(let n=0,r=i.length;n<r;n++)this.expandByObject(i[n],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,Dh),Dh.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,i;return e.normal.x>0?(t=e.normal.x*this.min.x,i=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,i=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),t<=-e.constant&&i>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Zx),TM.subVectors(this.max,Zx),k0.subVectors(e.a,Zx),F0.subVectors(e.b,Zx),N0.subVectors(e.c,Zx),rf.subVectors(F0,k0),sf.subVectors(N0,F0),tm.subVectors(k0,N0);let t=[0,-rf.z,rf.y,0,-sf.z,sf.y,0,-tm.z,tm.y,rf.z,0,-rf.x,sf.z,0,-sf.x,tm.z,0,-tm.x,-rf.y,rf.x,0,-sf.y,sf.x,0,-tm.y,tm.x,0];return!(!EN(t,k0,F0,N0,TM)||(t=[1,0,0,0,1,0,0,0,1],!EN(t,k0,F0,N0,TM)))&&(wM.crossVectors(rf,sf),t=[wM.x,wM.y,wM.z],EN(t,k0,F0,N0,TM))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Dh).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=.5*this.getSize(Dh).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()||(Lh[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Lh[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Lh[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Lh[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Lh[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Lh[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Lh[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Lh[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Lh)),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)}},Lh=[new D,new D,new D,new D,new D,new D,new D,new D],Dh=new D,O0=new Nt,k0=new D,F0=new D,N0=new D,rf=new D,sf=new D,tm=new D,Zx=new D,TM=new D,wM=new D,nm=new D;function EN(e,t,i,n,r){for(let a=0,s=e.length-3;a<=s;a+=3){nm.fromArray(e,a);let s=r.x*Math.abs(nm.x)+r.y*Math.abs(nm.y)+r.z*Math.abs(nm.z),o=t.dot(nm),l=i.dot(nm),h=n.dot(nm);if(Math.max(-Math.max(o,l,h),Math.min(o,l,h))>s)return!1}return!0}var Htt=new Nt,Kx=new D,_N=new D,vr=class{constructor(e=new D,t=-1){this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){let i=this.center;void 0!==t?i.copy(t):Htt.setFromPoints(e).getCenter(i);let n=0;for(let r=0,a=e.length;r<a;r++)n=Math.max(n,i.distanceToSquared(e[r]));return this.radius=Math.sqrt(n),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 i=this.center.distanceToSquared(e);return t.copy(e),i>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;Kx.subVectors(e,this.center);let t=Kx.lengthSq();if(t>this.radius*this.radius){let e=Math.sqrt(t),i=.5*(e-this.radius);this.center.addScaledVector(Kx,i/e),this.radius+=i}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):(_N.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Kx.copy(e.center).add(_N)),this.expandByPoint(Kx.copy(e.center).sub(_N))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return(new this.constructor).copy(this)}},Oh=new D,TN=new D,SM=new D,af=new D,wN=new D,MM=new D,SN=new D,lo=class{constructor(e=new D,t=new D(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,Oh)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let i=t.dot(this.direction);return i<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,i)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=Oh.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Oh.copy(this.origin).addScaledVector(this.direction,t),Oh.distanceToSquared(e))}distanceSqToSegment(e,t,i,n){TN.copy(e).add(t).multiplyScalar(.5),SM.copy(t).sub(e).normalize(),af.copy(this.origin).sub(TN);let r,a,s,o,l=.5*e.distanceTo(t),h=-this.direction.dot(SM),c=af.dot(this.direction),u=-af.dot(SM),d=af.lengthSq(),p=Math.abs(1-h*h);if(p>0)if(r=h*u-c,a=h*c-u,o=l*p,r>=0)if(a>=-o)if(a<=o){let e=1/p;r*=e,a*=e,s=r*(r+h*a+2*c)+a*(h*r+a+2*u)+d}else a=l,r=Math.max(0,-(h*a+c)),s=-r*r+a*(a+2*u)+d;else a=-l,r=Math.max(0,-(h*a+c)),s=-r*r+a*(a+2*u)+d;else a<=-o?(r=Math.max(0,-(-h*l+c)),a=r>0?-l:Math.min(Math.max(-l,-u),l),s=-r*r+a*(a+2*u)+d):a<=o?(r=0,a=Math.min(Math.max(-l,-u),l),s=a*(a+2*u)+d):(r=Math.max(0,-(h*l+c)),a=r>0?l:Math.min(Math.max(-l,-u),l),s=-r*r+a*(a+2*u)+d);else a=h>0?-l:l,r=Math.max(0,-(h*a+c)),s=-r*r+a*(a+2*u)+d;return i&&i.copy(this.origin).addScaledVector(this.direction,r),n&&n.copy(TN).addScaledVector(SM,a),s}intersectSphere(e,t){Oh.subVectors(e.center,this.origin);let i=Oh.dot(this.direction),n=Oh.dot(Oh)-i*i,r=e.radius*e.radius;if(n>r)return null;let a=Math.sqrt(r-n),s=i-a,o=i+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 i=-(this.origin.dot(e.normal)+e.constant)/t;return i>=0?i:null}intersectPlane(e,t){let i=this.distanceToPlane(e);return null===i?null:this.at(i,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);return 0===t||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let i,n,r,a,s,o,l=1/this.direction.x,h=1/this.direction.y,c=1/this.direction.z,u=this.origin;return l>=0?(i=(e.min.x-u.x)*l,n=(e.max.x-u.x)*l):(i=(e.max.x-u.x)*l,n=(e.min.x-u.x)*l),h>=0?(r=(e.min.y-u.y)*h,a=(e.max.y-u.y)*h):(r=(e.max.y-u.y)*h,a=(e.min.y-u.y)*h),i>a||r>n||((r>i||isNaN(i))&&(i=r),(a<n||isNaN(n))&&(n=a),c>=0?(s=(e.min.z-u.z)*c,o=(e.max.z-u.z)*c):(s=(e.max.z-u.z)*c,o=(e.min.z-u.z)*c),i>o||s>n)||((s>i||i!=i)&&(i=s),(o<n||n!=n)&&(n=o),n<0)?null:this.at(i>=0?i:n,t)}intersectsBox(e){return null!==this.intersectBox(e,Oh)}intersectTriangle(e,t,i,n,r){wN.subVectors(t,e),MM.subVectors(i,e),SN.crossVectors(wN,MM);let a,s=this.direction.dot(SN);if(s>0){if(n)return null;a=1}else{if(!(s<0))return null;a=-1,s=-s}af.subVectors(this.origin,e);let o=a*this.direction.dot(MM.crossVectors(af,MM));if(o<0)return null;let l=a*this.direction.dot(wN.cross(af));if(l<0||o+l>s)return null;let h=-a*af.dot(SN);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)}},et=class{constructor(e,t,i,n,r,a,s,o,l,h,c,u,d,p,f,m){et.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,i,n,r,a,s,o,l,h,c,u,d,p,f,m)}set(e,t,i,n,r,a,s,o,l,h,c,u,d,p,f,m){let g=this.elements;return g[0]=e,g[4]=t,g[8]=i,g[12]=n,g[1]=r,g[5]=a,g[9]=s,g[13]=o,g[2]=l,g[6]=h,g[10]=c,g[14]=u,g[3]=d,g[7]=p,g[11]=f,g[15]=m,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return(new et).fromArray(this.elements)}copy(e){let t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],t[9]=i[9],t[10]=i[10],t[11]=i[11],t[12]=i[12],t[13]=i[13],t[14]=i[14],t[15]=i[15],this}copyPosition(e){let t=this.elements,i=e.elements;return t[12]=i[12],t[13]=i[13],t[14]=i[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,i){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this}makeBasis(e,t,i){return this.set(e.x,t.x,i.x,0,e.y,t.y,i.y,0,e.z,t.z,i.z,0,0,0,0,1),this}extractRotation(e){let t=this.elements,i=e.elements,n=1/B0.setFromMatrixColumn(e,0).length(),r=1/B0.setFromMatrixColumn(e,1).length(),a=1/B0.setFromMatrixColumn(e,2).length();return t[0]=i[0]*n,t[1]=i[1]*n,t[2]=i[2]*n,t[3]=0,t[4]=i[4]*r,t[5]=i[5]*r,t[6]=i[6]*r,t[7]=0,t[8]=i[8]*a,t[9]=i[9]*a,t[10]=i[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,i=e.x,n=e.y,r=e.z,a=Math.cos(i),s=Math.sin(i),o=Math.cos(n),l=Math.sin(n),h=Math.cos(r),c=Math.sin(r);if("XYZ"===e.order){let e=a*h,i=a*c,n=s*h,r=s*c;t[0]=o*h,t[4]=-o*c,t[8]=l,t[1]=i+n*l,t[5]=e-r*l,t[9]=-s*o,t[2]=r-e*l,t[6]=n+i*l,t[10]=a*o}else if("YXZ"===e.order){let e=o*h,i=o*c,n=l*h,r=l*c;t[0]=e+r*s,t[4]=n*s-i,t[8]=a*l,t[1]=a*c,t[5]=a*h,t[9]=-s,t[2]=i*s-n,t[6]=r+e*s,t[10]=a*o}else if("ZXY"===e.order){let e=o*h,i=o*c,n=l*h,r=l*c;t[0]=e-r*s,t[4]=-a*c,t[8]=n+i*s,t[1]=i+n*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,i=a*c,n=s*h,r=s*c;t[0]=o*h,t[4]=n*l-i,t[8]=e*l+r,t[1]=o*c,t[5]=r*l+e,t[9]=i*l-n,t[2]=-l,t[6]=s*o,t[10]=a*o}else if("YZX"===e.order){let e=a*o,i=a*l,n=s*o,r=s*l;t[0]=o*h,t[4]=r-e*c,t[8]=n*c+i,t[1]=c,t[5]=a*h,t[9]=-s*h,t[2]=-l*h,t[6]=i*c+n,t[10]=e-r*c}else if("XZY"===e.order){let e=a*o,i=a*l,n=s*o,r=s*l;t[0]=o*h,t[4]=-c,t[8]=l*h,t[1]=e*c+r,t[5]=a*h,t[9]=i*c-n,t[2]=n*c-i,t[6]=s*h,t[10]=r*c+e}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(Vtt,e,ztt)}lookAt(e,t,i){let n=this.elements;return Vo.subVectors(e,t),0===Vo.lengthSq()&&(Vo.z=1),Vo.normalize(),of.crossVectors(i,Vo),0===of.lengthSq()&&(1===Math.abs(i.z)?Vo.x+=1e-4:Vo.z+=1e-4,Vo.normalize(),of.crossVectors(i,Vo)),of.normalize(),RM.crossVectors(Vo,of),n[0]=of.x,n[4]=RM.x,n[8]=Vo.x,n[1]=of.y,n[5]=RM.y,n[9]=Vo.y,n[2]=of.z,n[6]=RM.z,n[10]=Vo.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let i=e.elements,n=t.elements,r=this.elements,a=i[0],s=i[4],o=i[8],l=i[12],h=i[1],c=i[5],u=i[9],d=i[13],p=i[2],f=i[6],m=i[10],g=i[14],v=i[3],y=i[7],x=i[11],b=i[15],_=n[0],w=n[4],S=n[8],M=n[12],E=n[1],T=n[5],A=n[9],C=n[13],P=n[2],R=n[6],D=n[10],L=n[14],I=n[3],O=n[7],k=n[11],N=n[15];return r[0]=a*_+s*E+o*P+l*I,r[4]=a*w+s*T+o*R+l*O,r[8]=a*S+s*A+o*D+l*k,r[12]=a*M+s*C+o*L+l*N,r[1]=h*_+c*E+u*P+d*I,r[5]=h*w+c*T+u*R+d*O,r[9]=h*S+c*A+u*D+d*k,r[13]=h*M+c*C+u*L+d*N,r[2]=p*_+f*E+m*P+g*I,r[6]=p*w+f*T+m*R+g*O,r[10]=p*S+f*A+m*D+g*k,r[14]=p*M+f*C+m*L+g*N,r[3]=v*_+y*E+x*P+b*I,r[7]=v*w+y*T+x*R+b*O,r[11]=v*S+y*A+x*D+b*k,r[15]=v*M+y*C+x*L+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],i=e[4],n=e[8],r=e[12],a=e[1],s=e[5],o=e[9],l=e[13],h=e[2],c=e[6],u=e[10],d=e[14];return e[3]*(+r*o*c-n*l*c-r*s*u+i*l*u+n*s*d-i*o*d)+e[7]*(+t*o*d-t*l*u+r*a*u-n*a*d+n*l*h-r*o*h)+e[11]*(+t*l*c-t*s*d-r*a*c+i*a*d+r*s*h-i*l*h)+e[15]*(-n*s*h-t*o*c+t*s*u+n*a*c-i*a*u+i*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,i){let n=this.elements;return e.isVector3?(n[12]=e.x,n[13]=e.y,n[14]=e.z):(n[12]=e,n[13]=t,n[14]=i),this}invert(){let e=this.elements,t=e[0],i=e[1],n=e[2],r=e[3],a=e[4],s=e[5],o=e[6],l=e[7],h=e[8],c=e[9],u=e[10],d=e[11],p=e[12],f=e[13],m=e[14],g=e[15],v=c*m*l-f*u*l+f*o*d-s*m*d-c*o*g+s*u*g,y=p*u*l-h*m*l-p*o*d+a*m*d+h*o*g-a*u*g,x=h*f*l-p*c*l+p*s*d-a*f*d-h*s*g+a*c*g,b=p*c*o-h*f*o-p*s*u+a*f*u+h*s*m-a*c*m,_=t*v+i*y+n*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*u*r-c*m*r-f*n*d+i*m*d+c*n*g-i*u*g)*w,e[2]=(s*m*r-f*o*r+f*n*l-i*m*l-s*n*g+i*o*g)*w,e[3]=(c*o*r-s*u*r-c*n*l+i*u*l+s*n*d-i*o*d)*w,e[4]=y*w,e[5]=(h*m*r-p*u*r+p*n*d-t*m*d-h*n*g+t*u*g)*w,e[6]=(p*o*r-a*m*r-p*n*l+t*m*l+a*n*g-t*o*g)*w,e[7]=(a*u*r-h*o*r+h*n*l-t*u*l-a*n*d+t*o*d)*w,e[8]=x*w,e[9]=(p*c*r-h*f*r-p*i*d+t*f*d+h*i*g-t*c*g)*w,e[10]=(a*f*r-p*s*r+p*i*l-t*f*l-a*i*g+t*s*g)*w,e[11]=(h*s*r-a*c*r-h*i*l+t*c*l+a*i*d-t*s*d)*w,e[12]=b*w,e[13]=(h*f*n-p*c*n+p*i*u-t*f*u-h*i*m+t*c*m)*w,e[14]=(p*s*n-a*f*n-p*i*o+t*f*o+a*i*m-t*s*m)*w,e[15]=(a*c*n-h*s*n+h*i*o-t*c*o-a*i*u+t*s*u)*w,this}scale(e){let t=this.elements,i=e.x,n=e.y,r=e.z;return t[0]*=i,t[4]*=n,t[8]*=r,t[1]*=i,t[5]*=n,t[9]*=r,t[2]*=i,t[6]*=n,t[10]*=r,t[3]*=i,t[7]*=n,t[11]*=r,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],i=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],n=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,i,n))}makeTranslation(e,t,i){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,i,0,0,0,1),this}makeRotationX(e){let t=Math.cos(e),i=Math.sin(e);return this.set(1,0,0,0,0,t,-i,0,0,i,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),i=Math.sin(e);return this.set(t,0,i,0,0,1,0,0,-i,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,0,i,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let i=Math.cos(t),n=Math.sin(t),r=1-i,a=e.x,s=e.y,o=e.z,l=r*a,h=r*s;return this.set(l*a+i,l*s-n*o,l*o+n*s,0,l*s+n*o,h*s+i,h*o-n*a,0,l*o-n*s,h*o+n*a,r*o*o+i,0,0,0,0,1),this}makeScale(e,t,i){return this.set(e,0,0,0,0,t,0,0,0,0,i,0,0,0,0,1),this}makeShear(e,t,i,n,r,a){return this.set(1,i,r,0,e,1,a,0,t,n,1,0,0,0,0,1),this}compose(e,t,i){let n=this.elements,r=t._x,a=t._y,s=t._z,o=t._w,l=r+r,h=a+a,c=s+s,u=r*l,d=r*h,p=r*c,f=a*h,m=a*c,g=s*c,v=o*l,y=o*h,x=o*c,b=i.x,_=i.y,w=i.z;return n[0]=(1-(f+g))*b,n[1]=(d+x)*b,n[2]=(p-y)*b,n[3]=0,n[4]=(d-x)*_,n[5]=(1-(u+g))*_,n[6]=(m+v)*_,n[7]=0,n[8]=(p+y)*w,n[9]=(m-v)*w,n[10]=(1-(u+f))*w,n[11]=0,n[12]=e.x,n[13]=e.y,n[14]=e.z,n[15]=1,this}decompose(e,t,i){let n=this.elements,r=B0.set(n[0],n[1],n[2]).length(),a=B0.set(n[4],n[5],n[6]).length(),s=B0.set(n[8],n[9],n[10]).length();this.determinant()<0&&(r=-r),e.x=n[12],e.y=n[13],e.z=n[14],mc.copy(this);let o=1/r,l=1/a,h=1/s;return mc.elements[0]*=o,mc.elements[1]*=o,mc.elements[2]*=o,mc.elements[4]*=l,mc.elements[5]*=l,mc.elements[6]*=l,mc.elements[8]*=h,mc.elements[9]*=h,mc.elements[10]*=h,t.setFromRotationMatrix(mc),i.x=r,i.y=a,i.z=s,this}makePerspective(e,t,i,n,r,a,s=yu){let o,l,h=this.elements,c=2*r/(t-e),u=2*r/(i-n),d=(t+e)/(t-e),p=(i+n)/(i-n);if(s===yu)o=-(a+r)/(a-r),l=-2*a*r/(a-r);else{if(s!==gb)throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+s);o=-a/(a-r),l=-a*r/(a-r)}return h[0]=c,h[4]=0,h[8]=d,h[12]=0,h[1]=0,h[5]=u,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,i,n,r,a,s=yu){let o,l,h=this.elements,c=1/(t-e),u=1/(i-n),d=1/(a-r),p=(t+e)*c,f=(i+n)*u;if(s===yu)o=(a+r)*d,l=-2*d;else{if(s!==gb)throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+s);o=r*d,l=-1*d}return h[0]=2*c,h[4]=0,h[8]=0,h[12]=-p,h[1]=0,h[5]=2*u,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,i=e.elements;for(let n=0;n<16;n++)if(t[n]!==i[n])return!1;return!0}fromArray(e,t=0){for(let i=0;i<16;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){let i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e[t+9]=i[9],e[t+10]=i[10],e[t+11]=i[11],e[t+12]=i[12],e[t+13]=i[13],e[t+14]=i[14],e[t+15]=i[15],e}},B0=new D,mc=new et,Vtt=new D(0,0,0),ztt=new D(1,1,1),of=new D,RM=new D,Vo=new D,nce=new et,rce=new dr,Xn=class{constructor(e=0,t=0,i=0,n=Xn.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=i,this._order=n}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,i,n=this._order){return this._x=e,this._y=t,this._z=i,this._order=n,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,i=!0){let n=e.elements,r=n[0],a=n[4],s=n[8],o=n[1],l=n[5],h=n[9],c=n[2],u=n[6],d=n[10];switch(t){case"XYZ":this._y=Math.asin(os(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(-h,d),this._z=Math.atan2(-a,r)):(this._x=Math.atan2(u,l),this._z=0);break;case"YXZ":this._x=Math.asin(-os(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(s,d),this._z=Math.atan2(o,l)):(this._y=Math.atan2(-c,r),this._z=0);break;case"ZXY":this._x=Math.asin(os(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(-c,d),this._z=Math.atan2(-a,l)):(this._y=0,this._z=Math.atan2(o,r));break;case"ZYX":this._y=Math.asin(-os(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(u,d),this._z=Math.atan2(o,r)):(this._x=0,this._z=Math.atan2(-a,l));break;case"YZX":this._z=Math.asin(os(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,l),this._y=Math.atan2(-c,r)):(this._x=0,this._y=Math.atan2(s,d));break;case"XZY":this._z=Math.asin(-os(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(u,l),this._y=Math.atan2(s,r)):(this._x=Math.atan2(-h,d),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,!0===i&&this._onChangeCallback(),this}setFromQuaternion(e,t,i){return nce.makeRotationFromQuaternion(e),this.setFromRotationMatrix(nce,t,i)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return rce.setFromEuler(this),this.setFromQuaternion(rce,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 df=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))}},Gtt=0,ice=new D,U0=new dr,kh=new et,AM=new D,Jx=new D,qtt=new D,Wtt=new dr,sce=new D(1,0,0),ace=new D(0,1,0),oce=new D(0,0,1),jtt={type:"added"},lce={type:"removed"},on=class extends Wo{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Gtt++}),this.uuid=qo(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=on.DEFAULT_UP.clone();let e=new D,t=new Xn,i=new dr,n=new D(1,1,1);t._onChange((function(){i.setFromEuler(t,!1)})),i._onChange((function(){t.setFromQuaternion(i,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:i},scale:{configurable:!0,enumerable:!0,value:n},modelViewMatrix:{value:new et},normalMatrix:{value:new Ln}}),this.matrix=new et,this.matrixWorld=new et,this.matrixAutoUpdate=on.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.matrixWorldAutoUpdate=on.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.layers=new df,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 U0.setFromAxisAngle(e,t),this.quaternion.multiply(U0),this}rotateOnWorldAxis(e,t){return U0.setFromAxisAngle(e,t),this.quaternion.premultiply(U0),this}rotateX(e){return this.rotateOnAxis(sce,e)}rotateY(e){return this.rotateOnAxis(ace,e)}rotateZ(e){return this.rotateOnAxis(oce,e)}translateOnAxis(e,t){return ice.copy(e).applyQuaternion(this.quaternion),this.position.add(ice.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(sce,e)}translateY(e){return this.translateOnAxis(ace,e)}translateZ(e){return this.translateOnAxis(oce,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(kh.copy(this.matrixWorld).invert())}lookAt(e,t,i){e.isVector3?AM.copy(e):AM.set(e,t,i);let n=this.parent;this.updateWorldMatrix(!0,!1),Jx.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?kh.lookAt(Jx,AM,this.up):kh.lookAt(AM,Jx,this.up),this.quaternion.setFromRotationMatrix(kh),n&&(kh.extractRotation(n.matrixWorld),U0.setFromRotationMatrix(kh),this.quaternion.premultiply(U0.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(jtt)):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(lce)),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(lce)}return this.children.length=0,this}attach(e){return this.updateWorldMatrix(!0,!1),kh.copy(this.matrixWorld).invert(),null!==e.parent&&(e.parent.updateWorldMatrix(!0,!1),kh.multiply(e.parent.matrixWorld)),e.applyMatrix4(kh),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 i=0,n=this.children.length;i<n;i++){let n=this.children[i].getObjectByProperty(e,t);if(void 0!==n)return n}}getObjectsByProperty(e,t){let i=[];this[e]===t&&i.push(this);for(let n=0,r=this.children.length;n<r;n++){let r=this.children[n].getObjectsByProperty(e,t);r.length>0&&(i=i.concat(r))}return i}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Jx,e,qtt),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Jx,Wtt,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 i=0,n=t.length;i<n;i++)t[i].traverse(e)}traverseVisible(e){if(!1===this.visible)return;e(this);let t=this.children;for(let i=0,n=t.length;i<n;i++)t[i].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 i=0,n=t.length;i<n;i++){let n=t[i];(!0===n.matrixWorldAutoUpdate||!0===e)&&n.updateMatrixWorld(e)}}updateWorldMatrix(e,t){let i=this.parent;if(!0===e&&null!==i&&!0===i.matrixWorldAutoUpdate&&i.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,i=e.length;t<i;t++){let i=e[t];!0===i.matrixWorldAutoUpdate&&i.updateWorldMatrix(!1,!0)}}}toJSON(e){let t=void 0===e||"string"==typeof e,i={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},i.metadata={version:4.6,type:"Object",generator:"Object3D.toJSON"});let n={};function r(t,i){return void 0===t[i.uuid]&&(t[i.uuid]=i.toJSON(e)),i.uuid}if(n.uuid=this.uuid,n.type=this.type,""!==this.name&&(n.name=this.name),!0===this.castShadow&&(n.castShadow=!0),!0===this.receiveShadow&&(n.receiveShadow=!0),!1===this.visible&&(n.visible=!1),!1===this.frustumCulled&&(n.frustumCulled=!1),0!==this.renderOrder&&(n.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(n.userData=this.userData),n.layers=this.layers.mask,n.matrix=this.matrix.toArray(),n.up=this.up.toArray(),!1===this.matrixAutoUpdate&&(n.matrixAutoUpdate=!1),this.isInstancedMesh&&(n.type="InstancedMesh",n.count=this.count,n.instanceMatrix=this.instanceMatrix.toJSON(),null!==this.instanceColor&&(n.instanceColor=this.instanceColor.toJSON())),this.isScene)this.background&&(this.background.isColor?n.background=this.background.toJSON():this.background.isTexture&&(n.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&!0!==this.environment.isRenderTargetTexture&&(n.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){n.geometry=r(e.geometries,this.geometry);let t=this.geometry.parameters;if(void 0!==t&&void 0!==t.shapes){let i=t.shapes;if(Array.isArray(i))for(let t=0,n=i.length;t<n;t++){let n=i[t];r(e.shapes,n)}else r(e.shapes,i)}}if(this.isSkinnedMesh&&(n.bindMode=this.bindMode,n.bindMatrix=this.bindMatrix.toArray(),void 0!==this.skeleton&&(r(e.skeletons,this.skeleton),n.skeleton=this.skeleton.uuid)),void 0!==this.material)if(Array.isArray(this.material)){let t=[];for(let i=0,n=this.material.length;i<n;i++)t.push(r(e.materials,this.material[i]));n.material=t}else n.material=r(e.materials,this.material);if(this.children.length>0){n.children=[];for(let t=0;t<this.children.length;t++)n.children.push(this.children[t].toJSON(e).object)}if(this.animations.length>0){n.animations=[];for(let t=0;t<this.animations.length;t++){let i=this.animations[t];n.animations.push(r(e.animations,i))}}if(t){let t=a(e.geometries),n=a(e.materials),r=a(e.textures),s=a(e.images),o=a(e.shapes),l=a(e.skeletons),h=a(e.animations),c=a(e.nodes);t.length>0&&(i.geometries=t),n.length>0&&(i.materials=n),r.length>0&&(i.textures=r),s.length>0&&(i.images=s),o.length>0&&(i.shapes=o),l.length>0&&(i.skeletons=l),h.length>0&&(i.animations=h),c.length>0&&(i.nodes=c)}return i.object=n,i;function a(e){let t=[];for(let i in e){let n=e[i];delete n.metadata,t.push(n)}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 i=0;i<e.children.length;i++){let t=e.children[i];this.add(t.clone())}return this}};on.DEFAULT_UP=new D(0,1,0),on.DEFAULT_MATRIX_AUTO_UPDATE=!0,on.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;var gc=new D,Fh=new D,MN=new D,Nh=new D,H0=new D,V0=new D,cce=new D,RN=new D,AN=new D,CN=new D,CM=!1,Zr=class{constructor(e=new D,t=new D,i=new D){this.a=e,this.b=t,this.c=i}static getNormal(e,t,i,n){n.subVectors(i,t),gc.subVectors(e,t),n.cross(gc);let r=n.lengthSq();return r>0?n.multiplyScalar(1/Math.sqrt(r)):n.set(0,0,0)}static getBarycoord(e,t,i,n,r){gc.subVectors(n,t),Fh.subVectors(i,t),MN.subVectors(e,t);let a=gc.dot(gc),s=gc.dot(Fh),o=gc.dot(MN),l=Fh.dot(Fh),h=Fh.dot(MN),c=a*l-s*s;if(0===c)return r.set(-2,-1,-1);let u=1/c,d=(l*o-s*h)*u,p=(a*h-s*o)*u;return r.set(1-d-p,p,d)}static containsPoint(e,t,i,n){return this.getBarycoord(e,t,i,n,Nh),Nh.x>=0&&Nh.y>=0&&Nh.x+Nh.y<=1}static getUV(e,t,i,n,r,a,s,o){return!1===CM&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),CM=!0),this.getInterpolation(e,t,i,n,r,a,s,o)}static getInterpolation(e,t,i,n,r,a,s,o){return this.getBarycoord(e,t,i,n,Nh),o.setScalar(0),o.addScaledVector(r,Nh.x),o.addScaledVector(a,Nh.y),o.addScaledVector(s,Nh.z),o}static isFrontFacing(e,t,i,n){return gc.subVectors(i,t),Fh.subVectors(e,t),gc.cross(Fh).dot(n)<0}set(e,t,i){return this.a.copy(e),this.b.copy(t),this.c.copy(i),this}setFromPointsAndIndices(e,t,i,n){return this.a.copy(e[t]),this.b.copy(e[i]),this.c.copy(e[n]),this}setFromAttributeAndIndices(e,t,i,n){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,i),this.c.fromBufferAttribute(e,n),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 gc.subVectors(this.c,this.b),Fh.subVectors(this.a,this.b),.5*gc.cross(Fh).length()}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Zr.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Zr.getBarycoord(e,this.a,this.b,this.c,t)}getUV(e,t,i,n,r){return!1===CM&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),CM=!0),Zr.getInterpolation(e,this.a,this.b,this.c,t,i,n,r)}getInterpolation(e,t,i,n,r){return Zr.getInterpolation(e,this.a,this.b,this.c,t,i,n,r)}containsPoint(e){return Zr.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Zr.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let i,n,r=this.a,a=this.b,s=this.c;H0.subVectors(a,r),V0.subVectors(s,r),RN.subVectors(e,r);let o=H0.dot(RN),l=V0.dot(RN);if(o<=0&&l<=0)return t.copy(r);AN.subVectors(e,a);let h=H0.dot(AN),c=V0.dot(AN);if(h>=0&&c<=h)return t.copy(a);let u=o*c-h*l;if(u<=0&&o>=0&&h<=0)return i=o/(o-h),t.copy(r).addScaledVector(H0,i);CN.subVectors(e,s);let d=H0.dot(CN),p=V0.dot(CN);if(p>=0&&d<=p)return t.copy(s);let f=d*l-o*p;if(f<=0&&l>=0&&p<=0)return n=l/(l-p),t.copy(r).addScaledVector(V0,n);let m=h*p-d*c;if(m<=0&&c-h>=0&&d-p>=0)return cce.subVectors(s,a),n=(c-h)/(c-h+(d-p)),t.copy(a).addScaledVector(cce,n);let g=1/(m+f+u);return i=f*g,n=u*g,t.copy(r).addScaledVector(H0,i).addScaledVector(V0,n)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},Xtt=0,yr=class extends Wo{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Xtt++}),this.uuid=qo(),this.name="",this.type="Material",this.blending=mm,this.side=pi,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=RU,this.blendDst=AU,this.blendEquation=Go,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=vR,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=ohe,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=gR,this.stencilZFail=gR,this.stencilZPass=gR,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 i=e[t];if(void 0===i){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}let n=this[t];void 0!==n?n&&n.isColor?n.set(i):n&&n.isVector3&&i&&i.isVector3?n.copy(i):this[t]=i: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 i={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};function n(e){let t=[];for(let i in e){let n=e[i];delete n.metadata,t.push(n)}return t}if(i.uuid=this.uuid,i.type=this.type,""!==this.name&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),void 0!==this.roughness&&(i.roughness=this.roughness),void 0!==this.metalness&&(i.metalness=this.metalness),void 0!==this.sheen&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),void 0!==this.sheenRoughness&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity&&1!==this.emissiveIntensity&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),void 0!==this.specularIntensity&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),void 0!==this.shininess&&(i.shininess=this.shininess),void 0!==this.clearcoat&&(i.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),void 0!==this.iridescence&&(i.iridescence=this.iridescence),void 0!==this.iridescenceIOR&&(i.iridescenceIOR=this.iridescenceIOR),void 0!==this.iridescenceThicknessRange&&(i.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(i.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),void 0!==this.anisotropy&&(i.anisotropy=this.anisotropy),void 0!==this.anisotropyRotation&&(i.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(i.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(e).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(e).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(e).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(e).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(e).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(e).uuid,void 0!==this.combine&&(i.combine=this.combine)),void 0!==this.envMapIntensity&&(i.envMapIntensity=this.envMapIntensity),void 0!==this.reflectivity&&(i.reflectivity=this.reflectivity),void 0!==this.refractionRatio&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(e).uuid),void 0!==this.transmission&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(e).uuid),void 0!==this.thickness&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(e).uuid),void 0!==this.attenuationDistance&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),void 0!==this.attenuationColor&&(i.attenuationColor=this.attenuationColor.getHex()),void 0!==this.size&&(i.size=this.size),null!==this.shadowSide&&(i.shadowSide=this.shadowSide),void 0!==this.sizeAttenuation&&(i.sizeAttenuation=this.sizeAttenuation),this.blending!==mm&&(i.blending=this.blending),this.side!==pi&&(i.side=this.side),this.vertexColors&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),!0===this.transparent&&(i.transparent=this.transparent),i.depthFunc=this.depthFunc,i.depthTest=this.depthTest,i.depthWrite=this.depthWrite,i.colorWrite=this.colorWrite,i.stencilWrite=this.stencilWrite,i.stencilWriteMask=this.stencilWriteMask,i.stencilFunc=this.stencilFunc,i.stencilRef=this.stencilRef,i.stencilFuncMask=this.stencilFuncMask,i.stencilFail=this.stencilFail,i.stencilZFail=this.stencilZFail,i.stencilZPass=this.stencilZPass,void 0!==this.rotation&&0!==this.rotation&&(i.rotation=this.rotation),!0===this.polygonOffset&&(i.polygonOffset=!0),0!==this.polygonOffsetFactor&&(i.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(i.polygonOffsetUnits=this.polygonOffsetUnits),void 0!==this.linewidth&&1!==this.linewidth&&(i.linewidth=this.linewidth),void 0!==this.dashSize&&(i.dashSize=this.dashSize),void 0!==this.gapSize&&(i.gapSize=this.gapSize),void 0!==this.scale&&(i.scale=this.scale),!0===this.dithering&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),!0===this.alphaHash&&(i.alphaHash=this.alphaHash),!0===this.alphaToCoverage&&(i.alphaToCoverage=this.alphaToCoverage),!0===this.premultipliedAlpha&&(i.premultipliedAlpha=this.premultipliedAlpha),!0===this.forceSinglePass&&(i.forceSinglePass=this.forceSinglePass),!0===this.wireframe&&(i.wireframe=this.wireframe),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(i.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(i.wireframeLinejoin=this.wireframeLinejoin),!0===this.flatShading&&(i.flatShading=this.flatShading),!1===this.visible&&(i.visible=!1),!1===this.toneMapped&&(i.toneMapped=!1),!1===this.fog&&(i.fog=!1),Object.keys(this.userData).length>0&&(i.userData=this.userData),t){let t=n(e.textures),r=n(e.images);t.length>0&&(i.textures=t),r.length>0&&(i.images=r)}return i}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,i=null;if(null!==t){let e=t.length;i=new Array(e);for(let n=0;n!==e;++n)i[n]=t[n].clone()}return this.clippingPlanes=i,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++}},yhe={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},vc={h:0,s:0,l:0},PM={h:0,s:0,l:0};function PN(e,t,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?e+6*(t-e)*i:i<.5?t:i<2/3?e+6*(t-e)*(2/3-i):e}var ct=class{constructor(e,t,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,i)}set(e,t,i){if(void 0===t&&void 0===i){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,i);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=en){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(255&e)/255,_l.toWorkingColorSpace(this,t),this}setRGB(e,t,i,n=_l.workingColorSpace){return this.r=e,this.g=t,this.b=i,_l.toWorkingColorSpace(this,n),this}setHSL(e,t,i,n=_l.workingColorSpace){if(e=UU(e,1),t=os(t,0,1),i=os(i,0,1),0===t)this.r=this.g=this.b=i;else{let n=i<=.5?i*(1+t):i+t-i*t,r=2*i-n;this.r=PN(r,n,e+1/3),this.g=PN(r,n,e),this.b=PN(r,n,e-1/3)}return _l.toWorkingColorSpace(this,n),this}setStyle(e,t=en){function i(t){void 0!==t&&parseFloat(t)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let n;if(n=/^(\w+)\(([^\)]*)\)/.exec(e)){let r,a=n[1],s=n[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 i(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 i(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 i(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(n=/^\#([A-Fa-f\d]+)$/.exec(e)){let i=n[1],r=i.length;if(3===r)return this.setRGB(parseInt(i.charAt(0),16)/15,parseInt(i.charAt(1),16)/15,parseInt(i.charAt(2),16)/15,t);if(6===r)return this.setHex(parseInt(i,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=en){let i=yhe[e.toLowerCase()];return void 0!==i?this.setHex(i,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=iv(e.r),this.g=iv(e.g),this.b=iv(e.b),this}copyLinearToSRGB(e){return this.r=yN(e.r),this.g=yN(e.g),this.b=yN(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=en){return _l.fromWorkingColorSpace(da.copy(this),e),65536*Math.round(os(255*da.r,0,255))+256*Math.round(os(255*da.g,0,255))+Math.round(os(255*da.b,0,255))}getHexString(e=en){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=_l.workingColorSpace){_l.fromWorkingColorSpace(da.copy(this),t);let i,n,r=da.r,a=da.g,s=da.b,o=Math.max(r,a,s),l=Math.min(r,a,s),h=(l+o)/2;if(l===o)i=0,n=0;else{let e=o-l;switch(n=h<=.5?e/(o+l):e/(2-o-l),o){case r:i=(a-s)/e+(a<s?6:0);break;case a:i=(s-r)/e+2;break;case s:i=(r-a)/e+4}i/=6}return e.h=i,e.s=n,e.l=h,e}getRGB(e,t=_l.workingColorSpace){return _l.fromWorkingColorSpace(da.copy(this),t),e.r=da.r,e.g=da.g,e.b=da.b,e}getStyle(e=en){_l.fromWorkingColorSpace(da.copy(this),e);let t=da.r,i=da.g,n=da.b;return e!==en?`color(${e} ${t.toFixed(3)} ${i.toFixed(3)} ${n.toFixed(3)})`:`rgb(${Math.round(255*t)},${Math.round(255*i)},${Math.round(255*n)})`}offsetHSL(e,t,i){return this.getHSL(vc),vc.h+=e,vc.s+=t,vc.l+=i,this.setHSL(vc.h,vc.s,vc.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,i){return this.r=e.r+(t.r-e.r)*i,this.g=e.g+(t.g-e.g)*i,this.b=e.b+(t.b-e.b)*i,this}lerpHSL(e,t){this.getHSL(vc),e.getHSL(PM);let i=lb(vc.h,PM.h,t),n=lb(vc.s,PM.s,t),r=lb(vc.l,PM.l,t);return this.setHSL(i,n,r),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){let t=this.r,i=this.g,n=this.b,r=e.elements;return this.r=r[0]*t+r[3]*i+r[6]*n,this.g=r[1]*t+r[4]*i+r[7]*n,this.b=r[2]*t+r[5]*i+r[8]*n,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}},da=new ct;ct.NAMES=yhe;var ln=class extends yr{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=Hb,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}},Uh=Ytt();function Ytt(){let e=new ArrayBuffer(4),t=new Float32Array(e),i=new Uint32Array(e),n=new Uint32Array(512),r=new Uint32Array(512);for(let l=0;l<256;++l){let e=l-127;e<-27?(n[l]=0,n[256|l]=32768,r[l]=24,r[256|l]=24):e<-14?(n[l]=1024>>-e-14,n[256|l]=1024>>-e-14|32768,r[l]=-e-1,r[256|l]=-e-1):e<=15?(n[l]=e+15<<10,n[256|l]=e+15<<10|32768,r[l]=13,r[256|l]=13):e<128?(n[l]=31744,n[256|l]=64512,r[l]=24,r[256|l]=24):(n[l]=31744,n[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:i,baseTable:n,shiftTable:r,mantissaTable:a,exponentTable:s,offsetTable:o}}function ao(e){Math.abs(e)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),e=os(e,-65504,65504),Uh.floatView[0]=e;let t=Uh.uint32View[0],i=t>>23&511;return Uh.baseTable[i]+((8388607&t)>>Uh.shiftTable[i])}function ab(e){let t=e>>10;return Uh.uint32View[0]=Uh.mantissaTable[Uh.offsetTable[t]+(1023&e)]+Uh.exponentTable[t],Uh.floatView[0]}var Pv={toHalfFloat:ao,fromHalfFloat:ab},Es=new D,IM=new xe,mn=class{constructor(e,t,i=!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=i,this.usage=mb,this.updateRange={offset:0,count:-1},this.gpuType=fa,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,i){e*=this.itemSize,i*=t.itemSize;for(let n=0,r=this.itemSize;n<r;n++)this.array[e+n]=t.array[i+n];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(2===this.itemSize)for(let t=0,i=this.count;t<i;t++)IM.fromBufferAttribute(this,t),IM.applyMatrix3(e),this.setXY(t,IM.x,IM.y);else if(3===this.itemSize)for(let t=0,i=this.count;t<i;t++)Es.fromBufferAttribute(this,t),Es.applyMatrix3(e),this.setXYZ(t,Es.x,Es.y,Es.z);return this}applyMatrix4(e){for(let t=0,i=this.count;t<i;t++)Es.fromBufferAttribute(this,t),Es.applyMatrix4(e),this.setXYZ(t,Es.x,Es.y,Es.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)Es.fromBufferAttribute(this,t),Es.applyNormalMatrix(e),this.setXYZ(t,Es.x,Es.y,Es.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)Es.fromBufferAttribute(this,t),Es.transformDirection(e),this.setXYZ(t,Es.x,Es.y,Es.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let i=this.array[e*this.itemSize+t];return this.normalized&&(i=oo(i,this.array)),i}setComponent(e,t,i){return this.normalized&&(i=mr(i,this.array)),this.array[e*this.itemSize+t]=i,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=oo(t,this.array)),t}setX(e,t){return this.normalized&&(t=mr(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=oo(t,this.array)),t}setY(e,t){return this.normalized&&(t=mr(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=oo(t,this.array)),t}setZ(e,t){return this.normalized&&(t=mr(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=oo(t,this.array)),t}setW(e,t){return this.normalized&&(t=mr(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,i){return e*=this.itemSize,this.normalized&&(t=mr(t,this.array),i=mr(i,this.array)),this.array[e+0]=t,this.array[e+1]=i,this}setXYZ(e,t,i,n){return e*=this.itemSize,this.normalized&&(t=mr(t,this.array),i=mr(i,this.array),n=mr(n,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=n,this}setXYZW(e,t,i,n,r){return e*=this.itemSize,this.normalized&&(t=mr(t,this.array),i=mr(i,this.array),n=mr(n,this.array),r=mr(r,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=n,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!==mb&&(e.usage=this.usage),(0!==this.updateRange.offset||-1!==this.updateRange.count)&&(e.updateRange=this.updateRange),e}},AB=class extends mn{constructor(e,t,i){super(new Int8Array(e),t,i)}},bb=class extends mn{constructor(e,t,i){super(new Uint8Array(e),t,i)}},CB=class extends mn{constructor(e,t,i){super(new Uint8ClampedArray(e),t,i)}},PB=class extends mn{constructor(e,t,i){super(new Int16Array(e),t,i)}},ym=class extends mn{constructor(e,t,i){super(new Uint16Array(e),t,i)}},IB=class extends mn{constructor(e,t,i){super(new Int32Array(e),t,i)}},Eb=class extends mn{constructor(e,t,i){super(new Uint32Array(e),t,i)}},LB=class extends mn{constructor(e,t,i){super(new Uint16Array(e),t,i),this.isFloat16BufferAttribute=!0}getX(e){let t=ab(this.array[e*this.itemSize]);return this.normalized&&(t=oo(t,this.array)),t}setX(e,t){return this.normalized&&(t=mr(t,this.array)),this.array[e*this.itemSize]=ao(t),this}getY(e){let t=ab(this.array[e*this.itemSize+1]);return this.normalized&&(t=oo(t,this.array)),t}setY(e,t){return this.normalized&&(t=mr(t,this.array)),this.array[e*this.itemSize+1]=ao(t),this}getZ(e){let t=ab(this.array[e*this.itemSize+2]);return this.normalized&&(t=oo(t,this.array)),t}setZ(e,t){return this.normalized&&(t=mr(t,this.array)),this.array[e*this.itemSize+2]=ao(t),this}getW(e){let t=ab(this.array[e*this.itemSize+3]);return this.normalized&&(t=oo(t,this.array)),t}setW(e,t){return this.normalized&&(t=mr(t,this.array)),this.array[e*this.itemSize+3]=ao(t),this}setXY(e,t,i){return e*=this.itemSize,this.normalized&&(t=mr(t,this.array),i=mr(i,this.array)),this.array[e+0]=ao(t),this.array[e+1]=ao(i),this}setXYZ(e,t,i,n){return e*=this.itemSize,this.normalized&&(t=mr(t,this.array),i=mr(i,this.array),n=mr(n,this.array)),this.array[e+0]=ao(t),this.array[e+1]=ao(i),this.array[e+2]=ao(n),this}setXYZW(e,t,i,n,r){return e*=this.itemSize,this.normalized&&(t=mr(t,this.array),i=mr(i,this.array),n=mr(n,this.array),r=mr(r,this.array)),this.array[e+0]=ao(t),this.array[e+1]=ao(i),this.array[e+2]=ao(n),this.array[e+3]=ao(r),this}},Bt=class extends mn{constructor(e,t,i){super(new Float32Array(e),t,i)}},DB=class extends mn{constructor(e,t,i){super(new Float64Array(e),t,i)}},$tt=0,El=new et,IN=new on,z0=new D,zo=new Nt,Qx=new Nt,Vs=new D,Dt=class extends Wo{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:$tt++}),this.uuid=qo(),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(vhe(e)?Eb:ym)(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,i=0){this.groups.push({start:e,count:t,materialIndex:i})}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 i=this.attributes.normal;if(void 0!==i){let t=(new Ln).getNormalMatrix(e);i.applyNormalMatrix(t),i.needsUpdate=!0}let n=this.attributes.tangent;return void 0!==n&&(n.transformDirection(e),n.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this}applyQuaternion(e){return El.makeRotationFromQuaternion(e),this.applyMatrix4(El),this}rotateX(e){return El.makeRotationX(e),this.applyMatrix4(El),this}rotateY(e){return El.makeRotationY(e),this.applyMatrix4(El),this}rotateZ(e){return El.makeRotationZ(e),this.applyMatrix4(El),this}translate(e,t,i){return El.makeTranslation(e,t,i),this.applyMatrix4(El),this}scale(e,t,i){return El.makeScale(e,t,i),this.applyMatrix4(El),this}lookAt(e){return IN.lookAt(e),IN.updateMatrix(),this.applyMatrix4(IN.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(z0).negate(),this.translate(z0.x,z0.y,z0.z),this}setFromPoints(e){let t=[];for(let i=0,n=e.length;i<n;i++){let n=e[i];t.push(n.x,n.y,n.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 D(-1/0,-1/0,-1/0),new D(1/0,1/0,1/0));if(void 0!==e){if(this.boundingBox.setFromBufferAttribute(e),t)for(let i=0,n=t.length;i<n;i++){let e=t[i];zo.setFromBufferAttribute(e),this.morphTargetsRelative?(Vs.addVectors(this.boundingBox.min,zo.min),this.boundingBox.expandByPoint(Vs),Vs.addVectors(this.boundingBox.max,zo.max),this.boundingBox.expandByPoint(Vs)):(this.boundingBox.expandByPoint(zo.min),this.boundingBox.expandByPoint(zo.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 vr);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 D,1/0);if(e){let i=this.boundingSphere.center;if(zo.setFromBufferAttribute(e),t)for(let e=0,r=t.length;e<r;e++){let i=t[e];Qx.setFromBufferAttribute(i),this.morphTargetsRelative?(Vs.addVectors(zo.min,Qx.min),zo.expandByPoint(Vs),Vs.addVectors(zo.max,Qx.max),zo.expandByPoint(Vs)):(zo.expandByPoint(Qx.min),zo.expandByPoint(Qx.max))}zo.getCenter(i);let n=0;for(let t=0,r=e.count;t<r;t++)Vs.fromBufferAttribute(e,t),n=Math.max(n,i.distanceToSquared(Vs));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++)Vs.fromBufferAttribute(a,t),s&&(z0.fromBufferAttribute(e,t),Vs.add(z0)),n=Math.max(n,i.distanceToSquared(Vs))}this.boundingSphere.radius=Math.sqrt(n),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 i=e.array,n=t.position.array,r=t.normal.array,a=t.uv.array,s=n.length/3;!1===this.hasAttribute("tangent")&&this.setAttribute("tangent",new mn(new Float32Array(4*s),4));let o=this.getAttribute("tangent").array,l=[],h=[];for(let E=0;E<s;E++)l[E]=new D,h[E]=new D;let c=new D,u=new D,d=new D,p=new xe,f=new xe,m=new xe,g=new D,v=new D;function y(e,t,i){c.fromArray(n,3*e),u.fromArray(n,3*t),d.fromArray(n,3*i),p.fromArray(a,2*e),f.fromArray(a,2*t),m.fromArray(a,2*i),u.sub(c),d.sub(c),f.sub(p),m.sub(p);let r=1/(f.x*m.y-m.x*f.y);isFinite(r)&&(g.copy(u).multiplyScalar(m.y).addScaledVector(d,-f.y).multiplyScalar(r),v.copy(d).multiplyScalar(f.x).addScaledVector(u,-m.x).multiplyScalar(r),l[e].add(g),l[t].add(g),l[i].add(g),h[e].add(v),h[t].add(v),h[i].add(v))}let x=this.groups;0===x.length&&(x=[{start:0,count:i.length}]);for(let E=0,T=x.length;E<T;++E){let e=x[E],t=e.start;for(let n=t,r=t+e.count;n<r;n+=3)y(i[n+0],i[n+1],i[n+2])}let b=new D,_=new D,w=new D,S=new D;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 i=_.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]=i}for(let E=0,T=x.length;E<T;++E){let e=x[E],t=e.start;for(let n=t,r=t+e.count;n<r;n+=3)M(i[n+0]),M(i[n+1]),M(i[n+2])}}computeVertexNormals(){let e=this.index,t=this.getAttribute("position");if(void 0!==t){let i=this.getAttribute("normal");if(void 0===i)i=new mn(new Float32Array(3*t.count),3),this.setAttribute("normal",i);else for(let e=0,t=i.count;e<t;e++)i.setXYZ(e,0,0,0);let n=new D,r=new D,a=new D,s=new D,o=new D,l=new D,h=new D,c=new D;if(e)for(let u=0,d=e.count;u<d;u+=3){let d=e.getX(u+0),p=e.getX(u+1),f=e.getX(u+2);n.fromBufferAttribute(t,d),r.fromBufferAttribute(t,p),a.fromBufferAttribute(t,f),h.subVectors(a,r),c.subVectors(n,r),h.cross(c),s.fromBufferAttribute(i,d),o.fromBufferAttribute(i,p),l.fromBufferAttribute(i,f),s.add(h),o.add(h),l.add(h),i.setXYZ(d,s.x,s.y,s.z),i.setXYZ(p,o.x,o.y,o.z),i.setXYZ(f,l.x,l.y,l.z)}else for(let e=0,u=t.count;e<u;e+=3)n.fromBufferAttribute(t,e+0),r.fromBufferAttribute(t,e+1),a.fromBufferAttribute(t,e+2),h.subVectors(a,r),c.subVectors(n,r),h.cross(c),i.setXYZ(e+0,h.x,h.y,h.z),i.setXYZ(e+1,h.x,h.y,h.z),i.setXYZ(e+2,h.x,h.y,h.z);this.normalizeNormals(),i.needsUpdate=!0}}normalizeNormals(){let e=this.attributes.normal;for(let t=0,i=e.count;t<i;t++)Vs.fromBufferAttribute(e,t),Vs.normalize(),e.setXYZ(t,Vs.x,Vs.y,Vs.z)}toNonIndexed(){function e(e,t){let i=e.array,n=e.itemSize,r=e.normalized,a=new i.constructor(t.length*n),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]*n;for(let e=0;e<n;e++)a[o++]=i[s++]}return new mn(a,n,r)}if(null===this.index)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;let t=new Dt,i=this.index.array,n=this.attributes;for(let s in n){let r=e(n[s],i);t.setAttribute(s,r)}let r=this.morphAttributes;for(let s in r){let n=[],a=r[s];for(let t=0,r=a.length;t<r;t++){let r=e(a[t],i);n.push(r)}t.morphAttributes[s]=n}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 i in t)void 0!==t[i]&&(e[i]=t[i]);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 i=this.attributes;for(let o in i){let t=i[o];e.data.attributes[o]=t.toJSON(e.data)}let n={},r=!1;for(let o in this.morphAttributes){let t=this.morphAttributes[o],i=[];for(let n=0,r=t.length;n<r;n++){let r=t[n];i.push(r.toJSON(e.data))}i.length>0&&(n[o]=i,r=!0)}r&&(e.data.morphAttributes=n,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 i=e.index;null!==i&&this.setIndex(i.clone(t));let n=e.attributes;for(let l in n){let e=n[l];this.setAttribute(l,e.clone(t))}let r=e.morphAttributes;for(let l in r){let e=[],i=r[l];for(let n=0,r=i.length;n<r;n++)e.push(i[n].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"})}},uce=new et,rm=new lo,LM=new vr,hce=new D,G0=new D,q0=new D,W0=new D,LN=new D,DM=new D,OM=new xe,kM=new xe,FM=new xe,dce=new D,fce=new D,pce=new D,NM=new D,BM=new D,xt=class extends on{constructor(e=new Dt,t=new ln){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 i=e[t[0]];if(void 0!==i){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=i.length;e<t;e++){let t=i[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}getVertexPosition(e,t){let i=this.geometry,n=i.attributes.position,r=i.morphAttributes.position,a=i.morphTargetsRelative;t.fromBufferAttribute(n,e);let s=this.morphTargetInfluences;if(r&&s){DM.set(0,0,0);for(let i=0,n=r.length;i<n;i++){let n=s[i],o=r[i];0!==n&&(LN.fromBufferAttribute(o,e),a?DM.addScaledVector(LN,n):DM.addScaledVector(LN.sub(t),n))}t.add(DM)}return t}raycast(e,t){let i=this.geometry,n=this.material,r=this.matrixWorld;void 0!==n&&(null===i.boundingSphere&&i.computeBoundingSphere(),LM.copy(i.boundingSphere),LM.applyMatrix4(r),rm.copy(e.ray).recast(e.near),(!1!==LM.containsPoint(rm.origin)||!(null===rm.intersectSphere(LM,hce)||rm.origin.distanceToSquared(hce)>Do(e.far-e.near,2)))&&(uce.copy(r).invert(),rm.copy(e.ray).applyMatrix4(uce),(null===i.boundingBox||!1!==rm.intersectsBox(i.boundingBox))&&this._computeIntersections(e,t,rm)))}_computeIntersections(e,t,i){let n,r=this.geometry,a=this.material,s=r.index,o=r.attributes.position,l=r.attributes.uv,h=r.attributes.uv1,c=r.attributes.normal,u=r.groups,d=r.drawRange;if(null!==s)if(Array.isArray(a))for(let p=0,f=u.length;p<f;p++){let r=u[p],o=a[r.materialIndex];for(let a=Math.max(r.start,d.start),u=Math.min(s.count,Math.min(r.start+r.count,d.start+d.count));a<u;a+=3)n=UM(this,o,e,i,l,h,c,s.getX(a),s.getX(a+1),s.getX(a+2)),n&&(n.faceIndex=Math.floor(a/3),n.face.materialIndex=r.materialIndex,t.push(n))}else for(let p=Math.max(0,d.start),f=Math.min(s.count,d.start+d.count);p<f;p+=3)n=UM(this,a,e,i,l,h,c,s.getX(p),s.getX(p+1),s.getX(p+2)),n&&(n.faceIndex=Math.floor(p/3),t.push(n));else if(void 0!==o)if(Array.isArray(a))for(let p=0,f=u.length;p<f;p++){let r=u[p],s=a[r.materialIndex];for(let a=Math.max(r.start,d.start),u=Math.min(o.count,Math.min(r.start+r.count,d.start+d.count));a<u;a+=3)n=UM(this,s,e,i,l,h,c,a,a+1,a+2),n&&(n.faceIndex=Math.floor(a/3),n.face.materialIndex=r.materialIndex,t.push(n))}else for(let p=Math.max(0,d.start),f=Math.min(o.count,d.start+d.count);p<f;p+=3)n=UM(this,a,e,i,l,h,c,p,p+1,p+2),n&&(n.faceIndex=Math.floor(p/3),t.push(n))}};function Ztt(e,t,i,n,r,a,s,o){let l;if(l=t.side===Ji?n.intersectTriangle(s,a,r,!0,o):n.intersectTriangle(r,a,s,t.side===pi,o),null===l)return null;BM.copy(o),BM.applyMatrix4(e.matrixWorld);let h=i.ray.origin.distanceTo(BM);return h<i.near||h>i.far?null:{distance:h,point:BM.clone(),object:e}}function UM(e,t,i,n,r,a,s,o,l,h){e.getVertexPosition(o,G0),e.getVertexPosition(l,q0),e.getVertexPosition(h,W0);let c=Ztt(e,t,i,n,G0,q0,W0,NM);if(c){r&&(OM.fromBufferAttribute(r,o),kM.fromBufferAttribute(r,l),FM.fromBufferAttribute(r,h),c.uv=Zr.getInterpolation(NM,G0,q0,W0,OM,kM,FM,new xe)),a&&(OM.fromBufferAttribute(a,o),kM.fromBufferAttribute(a,l),FM.fromBufferAttribute(a,h),c.uv1=Zr.getInterpolation(NM,G0,q0,W0,OM,kM,FM,new xe),c.uv2=c.uv1),s&&(dce.fromBufferAttribute(s,o),fce.fromBufferAttribute(s,l),pce.fromBufferAttribute(s,h),c.normal=Zr.getInterpolation(NM,G0,q0,W0,dce,fce,pce,new D),c.normal.dot(n.direction)>0&&c.normal.multiplyScalar(-1));let e={a:o,b:l,c:h,normal:new D,materialIndex:0};Zr.getNormal(G0,q0,W0,e.normal),c.face=e}return c}var pa=class extends Dt{constructor(e=1,t=1,i=1,n=1,r=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:i,widthSegments:n,heightSegments:r,depthSegments:a};let s=this;n=Math.floor(n),r=Math.floor(r),a=Math.floor(a);let o=[],l=[],h=[],c=[],u=0,d=0;function p(e,t,i,n,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 D;for(let s=0;s<M;s++){let a=s*x-_;for(let o=0;o<S;o++){let u=o*y-b;A[e]=u*n,A[t]=a*r,A[i]=w,l.push(A.x,A.y,A.z),A[e]=0,A[t]=0,A[i]=f>0?1:-1,h.push(A.x,A.y,A.z),c.push(o/m),c.push(1-s/g),E+=1}}for(let s=0;s<g;s++)for(let e=0;e<m;e++){let t=u+e+S*s,i=u+e+S*(s+1),n=u+(e+1)+S*(s+1),r=u+(e+1)+S*s;o.push(t,i,r),o.push(i,n,r),T+=6}s.addGroup(d,T,v),d+=T,u+=E}p("z","y","x",-1,-1,i,t,e,a,r,0),p("z","y","x",1,-1,i,t,-e,a,r,1),p("x","z","y",1,1,e,i,t,n,a,2),p("x","z","y",1,-1,e,i,-t,n,a,3),p("x","y","z",1,-1,e,t,i,n,r,4),p("x","y","z",-1,-1,e,t,-i,n,r,5),this.setIndex(o),this.setAttribute("position",new Bt(l,3)),this.setAttribute("normal",new Bt(h,3)),this.setAttribute("uv",new Bt(c,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new pa(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}};function lv(e){let t={};for(let i in e){t[i]={};for(let n in e[i]){let r=e[i][n];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[i][n]=null):t[i][n]=r.clone():Array.isArray(r)?t[i][n]=r.slice():t[i][n]=r}}return t}function ka(e){let t={};for(let i=0;i<e.length;i++){let n=lv(e[i]);for(let e in n)t[e]=n[e]}return t}function Ktt(e){let t=[];for(let i=0;i<e.length;i++)t.push(e[i].clone());return t}function xhe(e){return null===e.getRenderTarget()?e.outputColorSpace:Na}var Ri={clone:lv,merge:ka},Jtt="void main() {\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",Qtt="void main() {\n\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}",cn=class extends yr{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=Jtt,this.fragmentShader=Qtt,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=lv(e.uniforms),this.uniformsGroups=Ktt(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 n in this.uniforms){let i=this.uniforms[n].value;i&&i.isTexture?t.uniforms[n]={type:"t",value:i.toJSON(e).uuid}:i&&i.isColor?t.uniforms[n]={type:"c",value:i.getHex()}:i&&i.isVector2?t.uniforms[n]={type:"v2",value:i.toArray()}:i&&i.isVector3?t.uniforms[n]={type:"v3",value:i.toArray()}:i&&i.isVector4?t.uniforms[n]={type:"v4",value:i.toArray()}:i&&i.isMatrix3?t.uniforms[n]={type:"m3",value:i.toArray()}:i&&i.isMatrix4?t.uniforms[n]={type:"m4",value:i.toArray()}:t.uniforms[n]={value:i}}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 i={};for(let n in this.extensions)!0===this.extensions[n]&&(i[n]=!0);return Object.keys(i).length>0&&(t.extensions=i),t}},Xh=class extends on{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new et,this.projectionMatrix=new et,this.projectionMatrixInverse=new et,this.coordinateSystem=yu}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)}},hr=class extends Xh{constructor(e=50,t=1,i=.1,n=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=i,this.far=n,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*av*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(.5*gm*this.fov);return.5*this.getFilmHeight()/e}getEffectiveFOV(){return 2*av*Math.atan(Math.tan(.5*gm*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,i,n,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=i,this.view.offsetY=n,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*gm*this.fov)/this.zoom,i=2*t,n=this.aspect*i,r=-.5*n,a=this.view;if(null!==this.view&&this.view.enabled){let e=a.fullWidth,s=a.fullHeight;r+=a.offsetX*n/e,t-=a.offsetY*i/s,n*=a.width/e,i*=a.height/s}let s=this.filmOffset;0!==s&&(r+=e*s/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+n,t,t-i,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}},j0=-90,X0=1,ER=class extends on{constructor(e,t,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null;let n=new hr(j0,X0,e,t);n.layers=this.layers,this.add(n);let r=new hr(j0,X0,e,t);r.layers=this.layers,this.add(r);let a=new hr(j0,X0,e,t);a.layers=this.layers,this.add(a);let s=new hr(j0,X0,e,t);s.layers=this.layers,this.add(s);let o=new hr(j0,X0,e,t);o.layers=this.layers,this.add(o);let l=new hr(j0,X0,e,t);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){let e=this.coordinateSystem,t=this.children.concat(),[i,n,r,a,s,o]=t;for(let l of t)this.remove(l);if(e===yu)i.up.set(0,1,0),i.lookAt(1,0,0),n.up.set(0,1,0),n.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!==gb)throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);i.up.set(0,-1,0),i.lookAt(-1,0,0),n.up.set(0,-1,0),n.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 i=this.renderTarget;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());let[n,r,a,s,o,l]=this.children,h=e.getRenderTarget(),c=e.xr.enabled;e.xr.enabled=!1;let u=i.texture.generateMipmaps;i.texture.generateMipmaps=!1,e.setRenderTarget(i,0),e.render(t,n),e.setRenderTarget(i,1),e.render(t,r),e.setRenderTarget(i,2),e.render(t,a),e.setRenderTarget(i,3),e.render(t,s),e.setRenderTarget(i,4),e.render(t,o),i.texture.generateMipmaps=u,e.setRenderTarget(i,5),e.render(t,l),e.setRenderTarget(h),e.xr.enabled=c,i.texture.needsPMREMUpdate=!0}},xm=class extends Gr{constructor(e,t,i,n,r,a,s,o,l,h){super(e=void 0!==e?e:[],t=void 0!==t?t:Gh,i,n,r,a,s,o,l,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},_R=class extends sr{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;let i={width:e,height:e,depth:1},n=[i,i,i,i,i,i];void 0!==t.encoding&&(cb("THREE.WebGLCubeRenderTarget: option.encoding has been replaced by option.colorSpace."),t.colorSpace=t.encoding===bu?en:Eu),this.texture=new xm(n,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:Pr}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 i={tEquirect:{value:null}},n="\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 pa(5,5,5),s=new cn({name:"CubemapFromEquirect",uniforms:lv(i),vertexShader:n,fragmentShader:r,side:Ji,blending:Qr});s.uniforms.tEquirect.value=t;let o=new xt(a,s),l=t.minFilter;return t.minFilter===Fa&&(t.minFilter=Pr),new ER(1,10,this).update(e,o),t.minFilter=l,o.geometry.dispose(),o.material.dispose(),this}clear(e,t,i,n){let r=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,i,n);e.setRenderTarget(r)}},DN=new D,ent=new D,tnt=new Ln,zr=class{constructor(e=new D(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,i,n){return this.normal.set(e,t,i),this.constant=n,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,i){let n=DN.subVectors(i,t).cross(ent.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(n,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 i=e.delta(DN),n=this.normal.dot(i);if(0===n)return 0===this.distanceToPoint(e.start)?t.copy(e.start):null;let r=-(e.start.dot(this.normal)+this.constant)/n;return r<0||r>1?null:t.copy(e.start).addScaledVector(i,r)}intersectsLine(e){let t=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return t<0&&i>0||i<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 i=t||tnt.getNormalMatrix(e),n=this.coplanarPoint(DN).applyMatrix4(e),r=this.normal.applyMatrix3(i).normalize();return this.constant=-n.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)}},im=new vr,HM=new D,ma=class{constructor(e=new zr,t=new zr,i=new zr,n=new zr,r=new zr,a=new zr){this.planes=[e,t,i,n,r,a]}set(e,t,i,n,r,a){let s=this.planes;return s[0].copy(e),s[1].copy(t),s[2].copy(i),s[3].copy(n),s[4].copy(r),s[5].copy(a),this}copy(e){let t=this.planes;for(let i=0;i<6;i++)t[i].copy(e.planes[i]);return this}setFromProjectionMatrix(e,t=yu){let i=this.planes,n=e.elements,r=n[0],a=n[1],s=n[2],o=n[3],l=n[4],h=n[5],c=n[6],u=n[7],d=n[8],p=n[9],f=n[10],m=n[11],g=n[12],v=n[13],y=n[14],x=n[15];if(i[0].setComponents(o-r,u-l,m-d,x-g).normalize(),i[1].setComponents(o+r,u+l,m+d,x+g).normalize(),i[2].setComponents(o+a,u+h,m+p,x+v).normalize(),i[3].setComponents(o-a,u-h,m-p,x-v).normalize(),i[4].setComponents(o-s,u-c,m-f,x-y).normalize(),t===yu)i[5].setComponents(o+s,u+c,m+f,x+y).normalize();else{if(t!==gb)throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);i[5].setComponents(s,c,f,y).normalize()}return this}intersectsObject(e){if(void 0!==e.boundingSphere)null===e.boundingSphere&&e.computeBoundingSphere(),im.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{let t=e.geometry;null===t.boundingSphere&&t.computeBoundingSphere(),im.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(im)}intersectsSprite(e){return im.center.set(0,0,0),im.radius=.7071067811865476,im.applyMatrix4(e.matrixWorld),this.intersectsSphere(im)}intersectsSphere(e){let t=this.planes,i=e.center,n=-e.radius;for(let r=0;r<6;r++)if(t[r].distanceToPoint(i)<n)return!1;return!0}intersectsBox(e){let t=this.planes;for(let i=0;i<6;i++){let n=t[i];if(HM.x=n.normal.x>0?e.max.x:e.min.x,HM.y=n.normal.y>0?e.max.y:e.min.y,HM.z=n.normal.z>0?e.max.z:e.min.z,n.distanceToPoint(HM)<0)return!1}return!0}containsPoint(e){let t=this.planes;for(let i=0;i<6;i++)if(t[i].distanceToPoint(e)<0)return!1;return!0}clone(){return(new this.constructor).copy(this)}};function bhe(){let e=null,t=!1,i=null,n=null;function r(t,a){i(t,a),n=e.requestAnimationFrame(r)}return{start:function(){!0!==t&&null!==i&&(n=e.requestAnimationFrame(r),t=!0)},stop:function(){e.cancelAnimationFrame(n),t=!1},setAnimationLoop:function(e){i=e},setContext:function(t){e=t}}}function nnt(e,t){let i=t.isWebGL2,n=new WeakMap;return{get:function(e){return e.isInterleavedBufferAttribute&&(e=e.data),n.get(e)},remove:function(t){t.isInterleavedBufferAttribute&&(t=t.data);let i=n.get(t);i&&(e.deleteBuffer(i.buffer),n.delete(t))},update:function(t,r){if(t.isGLBufferAttribute){let e=n.get(t);return void((!e||e.version<t.version)&&n.set(t,{buffer:t.buffer,type:t.type,bytesPerElement:t.elementSize,version:t.version}))}t.isInterleavedBufferAttribute&&(t=t.data);let a=n.get(t);void 0===a?n.set(t,function(t,n){let r,a=t.array,s=t.usage,o=e.createBuffer();if(e.bindBuffer(n,o),e.bufferData(n,a,s),t.onUploadCallback(),a instanceof Float32Array)r=e.FLOAT;else if(a instanceof Uint16Array)if(t.isFloat16BufferAttribute){if(!i)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,n,r){let a=n.array,s=n.updateRange;e.bindBuffer(r,t),-1===s.count?e.bufferSubData(r,0,a):(i?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),n.onUploadCallback()}(a.buffer,t,r),a.version=t.version)}}}var ui=class extends Dt{constructor(e=1,t=1,i=1,n=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:i,heightSegments:n};let r=e/2,a=t/2,s=Math.floor(i),o=Math.floor(n),l=s+1,h=o+1,c=e/s,u=t/o,d=[],p=[],f=[],m=[];for(let g=0;g<h;g++){let e=g*u-a;for(let t=0;t<l;t++){let i=t*c-r;p.push(i,-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,i=e+l*(g+1),n=e+1+l*(g+1),r=e+1+l*g;d.push(t,i,r),d.push(i,n,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 ui(e.width,e.height,e.widthSegments,e.heightSegments)}},rnt="#ifdef USE_ALPHAHASH\n\tif ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;\n#endif",int="#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",snt="#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;\n#endif",ant="#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",ont="#ifdef USE_ALPHATEST\n\tif ( diffuseColor.a < alphaTest ) discard;\n#endif",lnt="#ifdef USE_ALPHATEST\n\tuniform float alphaTest;\n#endif",cnt="#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",unt="#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif",hnt="vec3 transformed = vec3( position );\n#ifdef USE_ALPHAHASH\n\tvPosition = vec3( position );\n#endif",dnt="vec3 objectNormal = vec3( normal );\n#ifdef USE_TANGENT\n\tvec3 objectTangent = vec3( tangent.xyz );\n#endif",fnt="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",pnt="#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",mnt="#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",gnt="#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",vnt="#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",ynt="#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n#endif",xnt="#if NUM_CLIPPING_PLANES > 0\n\tvClipPosition = - mvPosition.xyz;\n#endif",bnt="#if defined( USE_COLOR_ALPHA )\n\tdiffuseColor *= vColor;\n#elif defined( USE_COLOR )\n\tdiffuseColor.rgb *= vColor;\n#endif",Ent="#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR )\n\tvarying vec3 vColor;\n#endif",_nt="#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvarying vec3 vColor;\n#endif",Tnt="#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",wnt="#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",Snt="#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",Mnt="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",Rnt="#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif",Ant="#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );\n#endif",Cnt="#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif",Pnt="#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif",Int="gl_FragColor = linearToOutputTexel( gl_FragColor );",Lnt="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}",Dnt="#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",Ont="#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",knt="#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",Fnt="#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",Nnt="#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",Bnt="#ifdef USE_FOG\n\tvFogDepth = - mvPosition.z;\n#endif",Unt="#ifdef USE_FOG\n\tvarying float vFogDepth;\n#endif",Hnt="#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",Vnt="#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",znt="#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}",Gnt="#ifdef USE_LIGHTMAP\n\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\treflectedLight.indirectDiffuse += lightMapIrradiance;\n#endif",qnt="#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",Wnt="LambertMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularStrength = specularStrength;",jnt="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",Xnt="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",Ynt="#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",$nt="ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;",Znt="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",Knt="BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",Jnt="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",Qnt="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",ert="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}",trt="\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",nrt="#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",rrt="#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",irt="#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",srt="#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",art="#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",ort="#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",lrt="#ifdef USE_MAP\n\tdiffuseColor *= texture2D( map, vMapUv );\n#endif",crt="#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif",urt="#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",hrt="#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",drt="float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif",frt="#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",prt="#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",mrt="#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",grt="#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",vrt="#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",yrt="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;",xrt="#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",brt="#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",Ert="#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",_rt="#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",Trt="#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",wrt="#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal = geometryNormal;\n#endif",Srt="#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",Mrt="#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",Rrt="#ifdef USE_IRIDESCENCEMAP\n\tuniform sampler2D iridescenceMap;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform sampler2D iridescenceThicknessMap;\n#endif",Art="#ifdef OPAQUE\ndiffuseColor.a = 1.0;\n#endif\n#ifdef USE_TRANSMISSION\ndiffuseColor.a *= material.transmissionAlpha;\n#endif\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );",Crt="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}",Prt="#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif",Irt="vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;",Lrt="#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif",Drt="#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",Ort="float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );\n\troughnessFactor *= texelRoughness.g;\n#endif",krt="#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",Frt="#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",Nrt="#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",Brt="#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",Urt="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}",Hrt="#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",Vrt="#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",zrt="#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",Grt="#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",qrt="float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",Wrt="#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",jrt="#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif",Xrt="#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; }",Yrt="#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",$rt="#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",Zrt="#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",Krt="#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",Jrt="#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",Qrt="#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",eit="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}",tit="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}",nit="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}",rit="#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}",iit="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}",sit="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}",ait="#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}",oit="#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}",lit="#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}",cit="#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}",uit="varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n}",hit="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}",dit="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}",fit="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}",pit="#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}",mit="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}",git="#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}",vit="#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}",yit="#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}",xit="#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}",bit="#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}",Eit="#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}",_it="#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}",Tit="#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}",wit="#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}",Sit="#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}",Mit="#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}",Rit="#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}",Ait="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}",Cit="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}",Pit="#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}",Iit="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}",Lit="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}",Dit="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:rnt,alphahash_pars_fragment:int,alphamap_fragment:snt,alphamap_pars_fragment:ant,alphatest_fragment:ont,alphatest_pars_fragment:lnt,aomap_fragment:cnt,aomap_pars_fragment:unt,begin_vertex:hnt,beginnormal_vertex:dnt,bsdfs:fnt,iridescence_fragment:pnt,bumpmap_pars_fragment:mnt,clipping_planes_fragment:gnt,clipping_planes_pars_fragment:vnt,clipping_planes_pars_vertex:ynt,clipping_planes_vertex:xnt,color_fragment:bnt,color_pars_fragment:Ent,color_pars_vertex:_nt,color_vertex:Tnt,common:wnt,cube_uv_reflection_fragment:Snt,defaultnormal_vertex:Mnt,displacementmap_pars_vertex:Rnt,displacementmap_vertex:Ant,emissivemap_fragment:Cnt,emissivemap_pars_fragment:Pnt,colorspace_fragment:Int,colorspace_pars_fragment:Lnt,envmap_fragment:Dnt,envmap_common_pars_fragment:Ont,envmap_pars_fragment:knt,envmap_pars_vertex:Fnt,envmap_physical_pars_fragment:Ynt,envmap_vertex:Nnt,fog_vertex:Bnt,fog_pars_vertex:Unt,fog_fragment:Hnt,fog_pars_fragment:Vnt,gradientmap_pars_fragment:znt,lightmap_fragment:Gnt,lightmap_pars_fragment:qnt,lights_lambert_fragment:Wnt,lights_lambert_pars_fragment:jnt,lights_pars_begin:Xnt,lights_toon_fragment:$nt,lights_toon_pars_fragment:Znt,lights_phong_fragment:Knt,lights_phong_pars_fragment:Jnt,lights_physical_fragment:Qnt,lights_physical_pars_fragment:ert,lights_fragment_begin:trt,lights_fragment_maps:nrt,lights_fragment_end:rrt,logdepthbuf_fragment:irt,logdepthbuf_pars_fragment:srt,logdepthbuf_pars_vertex:art,logdepthbuf_vertex:ort,map_fragment:lrt,map_pars_fragment:crt,map_particle_fragment:urt,map_particle_pars_fragment:hrt,metalnessmap_fragment:drt,metalnessmap_pars_fragment:frt,morphcolor_vertex:prt,morphnormal_vertex:mrt,morphtarget_pars_vertex:grt,morphtarget_vertex:vrt,normal_fragment_begin:yrt,normal_fragment_maps:xrt,normal_pars_fragment:brt,normal_pars_vertex:Ert,normal_vertex:_rt,normalmap_pars_fragment:Trt,clearcoat_normal_fragment_begin:wrt,clearcoat_normal_fragment_maps:Srt,clearcoat_pars_fragment:Mrt,iridescence_pars_fragment:Rrt,opaque_fragment:Art,packing:Crt,premultiplied_alpha_fragment:Prt,project_vertex:Irt,dithering_fragment:Lrt,dithering_pars_fragment:Drt,roughnessmap_fragment:Ort,roughnessmap_pars_fragment:krt,shadowmap_pars_fragment:Frt,shadowmap_pars_vertex:Nrt,shadowmap_vertex:Brt,shadowmask_pars_fragment:Urt,skinbase_vertex:Hrt,skinning_pars_vertex:Vrt,skinning_vertex:zrt,skinnormal_vertex:Grt,specularmap_fragment:qrt,specularmap_pars_fragment:Wrt,tonemapping_fragment:jrt,tonemapping_pars_fragment:Xrt,transmission_fragment:Yrt,transmission_pars_fragment:$rt,uv_pars_fragment:Zrt,uv_pars_vertex:Krt,uv_vertex:Jrt,worldpos_vertex:Qrt,background_vert:eit,background_frag:tit,backgroundCube_vert:nit,backgroundCube_frag:rit,cube_vert:iit,cube_frag:sit,depth_vert:ait,depth_frag:oit,distanceRGBA_vert:lit,distanceRGBA_frag:cit,equirect_vert:uit,equirect_frag:hit,linedashed_vert:dit,linedashed_frag:fit,meshbasic_vert:pit,meshbasic_frag:mit,meshlambert_vert:git,meshlambert_frag:vit,meshmatcap_vert:yit,meshmatcap_frag:xit,meshnormal_vert:bit,meshnormal_frag:Eit,meshphong_vert:_it,meshphong_frag:Tit,meshphysical_vert:wit,meshphysical_frag:Sit,meshtoon_vert:Mit,meshtoon_frag:Rit,points_vert:Ait,points_frag:Cit,shadow_vert:Pit,shadow_frag:Iit,sprite_vert:Lit,sprite_frag:Dit},Jt={common:{diffuse:{value:new ct(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Ln},alphaMap:{value:null},alphaMapTransform:{value:new Ln},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Ln}},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 Ln}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Ln}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Ln},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Ln},normalScale:{value:new xe(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Ln},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Ln}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Ln}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Ln}},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 Ln},alphaTest:{value:0},uvTransform:{value:new Ln}},sprite:{diffuse:{value:new ct(16777215)},opacity:{value:1},center:{value:new xe(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Ln},alphaMap:{value:null},alphaMapTransform:{value:new Ln},alphaTest:{value:0}}},yc={basic:{uniforms:ka([Jt.common,Jt.specularmap,Jt.envmap,Jt.aomap,Jt.lightmap,Jt.fog]),vertexShader:$n.meshbasic_vert,fragmentShader:$n.meshbasic_frag},lambert:{uniforms:ka([Jt.common,Jt.specularmap,Jt.envmap,Jt.aomap,Jt.lightmap,Jt.emissivemap,Jt.bumpmap,Jt.normalmap,Jt.displacementmap,Jt.fog,Jt.lights,{emissive:{value:new ct(0)}}]),vertexShader:$n.meshlambert_vert,fragmentShader:$n.meshlambert_frag},phong:{uniforms:ka([Jt.common,Jt.specularmap,Jt.envmap,Jt.aomap,Jt.lightmap,Jt.emissivemap,Jt.bumpmap,Jt.normalmap,Jt.displacementmap,Jt.fog,Jt.lights,{emissive:{value:new ct(0)},specular:{value:new ct(1118481)},shininess:{value:30}}]),vertexShader:$n.meshphong_vert,fragmentShader:$n.meshphong_frag},standard:{uniforms:ka([Jt.common,Jt.envmap,Jt.aomap,Jt.lightmap,Jt.emissivemap,Jt.bumpmap,Jt.normalmap,Jt.displacementmap,Jt.roughnessmap,Jt.metalnessmap,Jt.fog,Jt.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:ka([Jt.common,Jt.aomap,Jt.lightmap,Jt.emissivemap,Jt.bumpmap,Jt.normalmap,Jt.displacementmap,Jt.gradientmap,Jt.fog,Jt.lights,{emissive:{value:new ct(0)}}]),vertexShader:$n.meshtoon_vert,fragmentShader:$n.meshtoon_frag},matcap:{uniforms:ka([Jt.common,Jt.bumpmap,Jt.normalmap,Jt.displacementmap,Jt.fog,{matcap:{value:null}}]),vertexShader:$n.meshmatcap_vert,fragmentShader:$n.meshmatcap_frag},points:{uniforms:ka([Jt.points,Jt.fog]),vertexShader:$n.points_vert,fragmentShader:$n.points_frag},dashed:{uniforms:ka([Jt.common,Jt.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:$n.linedashed_vert,fragmentShader:$n.linedashed_frag},depth:{uniforms:ka([Jt.common,Jt.displacementmap]),vertexShader:$n.depth_vert,fragmentShader:$n.depth_frag},normal:{uniforms:ka([Jt.common,Jt.bumpmap,Jt.normalmap,Jt.displacementmap,{opacity:{value:1}}]),vertexShader:$n.meshnormal_vert,fragmentShader:$n.meshnormal_frag},sprite:{uniforms:ka([Jt.sprite,Jt.fog]),vertexShader:$n.sprite_vert,fragmentShader:$n.sprite_frag},background:{uniforms:{uvTransform:{value:new Ln},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:ka([Jt.common,Jt.displacementmap,{referencePosition:{value:new D},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:$n.distanceRGBA_vert,fragmentShader:$n.distanceRGBA_frag},shadow:{uniforms:ka([Jt.lights,Jt.fog,{color:{value:new ct(0)},opacity:{value:1}}]),vertexShader:$n.shadow_vert,fragmentShader:$n.shadow_frag}};yc.physical={uniforms:ka([yc.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Ln},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Ln},clearcoatNormalScale:{value:new xe(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Ln},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Ln},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Ln},sheen:{value:0},sheenColor:{value:new ct(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Ln},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Ln},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Ln},transmissionSamplerSize:{value:new xe},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Ln},attenuationDistance:{value:0},attenuationColor:{value:new ct(0)},specularColor:{value:new ct(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Ln},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Ln},anisotropyVector:{value:new xe},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Ln}}]),vertexShader:$n.meshphysical_vert,fragmentShader:$n.meshphysical_frag};var VM={r:0,b:0,g:0};function Oit(e,t,i,n,r,a,s){let o,l,h=new ct(0),c=!0===a?0:1,u=null,d=0,p=null;function f(t,i){t.getRGB(VM,xhe(e)),n.buffers.color.setClear(VM.r,VM.g,VM.b,i,s)}return{getClearColor:function(){return h},setClearColor:function(e,t=1){h.set(e),c=t,f(h,c)},getClearAlpha:function(){return c},setClearAlpha:function(e){c=e,f(h,c)},render:function(a,m){let g=!1,v=!0===m.isScene?m.background:null;switch(v&&v.isTexture&&(v=(m.backgroundBlurriness>0?i:t).get(v)),null===v?f(h,c):v&&v.isColor&&(f(v,1),g=!0),e.xr.getEnvironmentBlendMode()){case"opaque":g=!0;break;case"additive":n.buffers.color.setClear(0,0,0,1,s),g=!0;break;case"alpha-blend":n.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===Mv)?(void 0===l&&(l=new xt(new pa(1,1,1),new cn({name:"BackgroundCubeMaterial",uniforms:lv(yc.backgroundCube.uniforms),vertexShader:yc.backgroundCube.vertexShader,fragmentShader:yc.backgroundCube.fragmentShader,side:Ji,depthTest:!1,depthWrite:!1,fog:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(e,t,i){this.matrixWorld.copyPosition(i.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!==en,(u!==v||d!==v.version||p!==e.toneMapping)&&(l.material.needsUpdate=!0,u=v,d=v.version,p=e.toneMapping),l.layers.enableAll(),a.unshift(l,l.geometry,l.material,0,0,null)):v&&v.isTexture&&(void 0===o&&(o=new xt(new ui(2,2),new cn({name:"BackgroundMaterial",uniforms:lv(yc.background.uniforms),vertexShader:yc.background.vertexShader,fragmentShader:yc.background.fragmentShader,side:pi,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!==en,!0===v.matrixAutoUpdate&&v.updateMatrix(),o.material.uniforms.uvTransform.value.copy(v.matrix),(u!==v||d!==v.version||p!==e.toneMapping)&&(o.material.needsUpdate=!0,u=v,d=v.version,p=e.toneMapping),o.layers.enableAll(),a.unshift(o,o.geometry,o.material,0,0,null))}}}function kit(e,t,i,n){let r=e.getParameter(e.MAX_VERTEX_ATTRIBS),a=n.isWebGL2?null:t.get("OES_vertex_array_object"),s=n.isWebGL2||null!==a,o={},l=p(null),h=l,c=!1;function u(t){return n.isWebGL2?e.bindVertexArray(t):a.bindVertexArrayOES(t)}function d(t){return n.isWebGL2?e.deleteVertexArray(t):a.deleteVertexArrayOES(t)}function p(e){let t=[],i=[],n=[];for(let a=0;a<r;a++)t[a]=0,i[a]=0,n[a]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:t,enabledAttributes:i,attributeDivisors:n,object:e,attributes:{},index:null}}function f(){let e=h.newAttributes;for(let t=0,i=e.length;t<i;t++)e[t]=0}function m(e){g(e,0)}function g(i,r){let a=h.newAttributes,s=h.enabledAttributes,o=h.attributeDivisors;a[i]=1,0===s[i]&&(e.enableVertexAttribArray(i),s[i]=1),o[i]!==r&&((n.isWebGL2?e:t.get("ANGLE_instanced_arrays"))[n.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](i,r),o[i]=r)}function v(){let t=h.newAttributes,i=h.enabledAttributes;for(let n=0,r=i.length;n<r;n++)i[n]!==t[n]&&(e.disableVertexAttribArray(n),i[n]=0)}function y(t,i,n,r,a,s,o){!0===o?e.vertexAttribIPointer(t,i,n,a,s):e.vertexAttribPointer(t,i,n,r,a,s)}function x(){b(),c=!0,h!==l&&(h=l,u(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,i,r){let s=!0===r.wireframe,l=o[t.id];void 0===l&&(l={},o[t.id]=l);let h=l[i.id];void 0===h&&(h={},l[i.id]=h);let c=h[s];return void 0===c&&(c=p(n.isWebGL2?e.createVertexArray():a.createVertexArrayOES()),h[s]=c),c}(x,d,l);h!==t&&(h=t,u(h.object)),_=function(e,t,i,n){let r=h.attributes,a=t.attributes,s=0,o=i.getAttributes();for(let l in o)if(o[l].location>=0){let t=r[l],i=a[l];if(void 0===i&&("instanceMatrix"===l&&e.instanceMatrix&&(i=e.instanceMatrix),"instanceColor"===l&&e.instanceColor&&(i=e.instanceColor)),void 0===t||t.attribute!==i||i&&t.data!==i.data)return!0;s++}return h.attributesNum!==s||h.index!==n}(r,x,d,b),_&&function(e,t,i,n){let r={},a=t.attributes,s=0,o=i.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 i={};i.attribute=t,t&&t.data&&(i.data=t.data),r[l]=i,s++}h.attributes=r,h.attributesNum=s,h.index=n}(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&&i.update(b,e.ELEMENT_ARRAY_BUFFER),(_||c)&&(c=!1,function(r,a,s,o){if(!1===n.isWebGL2&&(r.isInstancedMesh||o.isInstancedBufferGeometry)&&null===t.get("ANGLE_instanced_arrays"))return;f();let l=o.attributes,h=s.getAttributes(),c=a.defaultAttributeValues;for(let t in h){let 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=i.get(s);if(void 0===h)continue;let c=h.buffer,u=h.type,d=h.bytesPerElement,p=!0===n.isWebGL2&&(u===e.INT||u===e.UNSIGNED_INT||s.gpuType===CU);if(s.isInterleavedBufferAttribute){let i=s.data,n=i.stride,h=s.offset;if(i.isInstancedInterleavedBuffer){for(let e=0;e<a.locationSize;e++)g(a.location+e,i.meshPerAttribute);!0!==r.isInstancedMesh&&void 0===o._maxInstanceCount&&(o._maxInstanceCount=i.meshPerAttribute*i.count)}else for(let e=0;e<a.locationSize;e++)m(a.location+e);e.bindBuffer(e.ARRAY_BUFFER,c);for(let e=0;e<a.locationSize;e++)y(a.location+e,l/a.locationSize,u,t,n*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,c);for(let e=0;e<a.locationSize;e++)y(a.location+e,l/a.locationSize,u,t,l*d,l/a.locationSize*e*d,p)}}else if(void 0!==c){let i=c[t];if(void 0!==i)switch(i.length){case 2:e.vertexAttrib2fv(a.location,i);break;case 3:e.vertexAttrib3fv(a.location,i);break;case 4:e.vertexAttrib4fv(a.location,i);break;default:e.vertexAttrib1fv(a.location,i)}}}}v()}(r,l,d,x),null!==b&&e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,i.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 i=t[e];for(let e in i)d(i[e].object),delete i[e];delete t[e]}delete o[e]}},releaseStatesOfGeometry:function(e){if(void 0===o[e.id])return;let t=o[e.id];for(let i in t){let e=t[i];for(let t in e)d(e[t].object),delete e[t];delete t[i]}delete o[e.id]},releaseStatesOfProgram:function(e){for(let t in o){let i=o[t];if(void 0===i[e.id])continue;let n=i[e.id];for(let e in n)d(n[e].object),delete n[e];delete i[e.id]}},initAttributes:f,enableAttribute:m,disableUnusedAttributes:v}}function Fit(e,t,i,n){let r,a=n.isWebGL2;this.setMode=function(e){r=e},this.render=function(t,n){e.drawArrays(r,t,n),i.update(n,r,1)},this.renderInstances=function(n,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,n,s,o),i.update(s,r,o)}}function Nit(e,t,i){let n;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!==i.precision?i.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===i.logarithmicDepthBuffer,c=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),u=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),d=e.getParameter(e.MAX_TEXTURE_SIZE),p=e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),f=e.getParameter(e.MAX_VERTEX_ATTRIBS),m=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),g=e.getParameter(e.MAX_VARYING_VECTORS),v=e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),y=u>0,x=a||t.has("OES_texture_float");return{isWebGL2:a,drawBuffers:l,getMaxAnisotropy:function(){if(void 0!==n)return n;if(!0===t.has("EXT_texture_filter_anisotropic")){let i=t.get("EXT_texture_filter_anisotropic");n=e.getParameter(i.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else n=0;return n},getMaxPrecision:r,precision:s,logarithmicDepthBuffer:h,maxTextures:c,maxVertexTextures:u,maxTextureSize:d,maxCubemapSize:p,maxAttributes:f,maxVertexUniforms:m,maxVaryings:g,maxFragmentUniforms:v,vertexTextures:y,floatFragmentTextures:x,floatVertexTextures:y&&x,maxSamples:a?e.getParameter(e.MAX_SAMPLES):0}}function Bit(e){let t=this,i=null,n=0,r=!1,a=!1,s=new zr,o=new Ln,l={value:null,needsUpdate:!1};function h(e,i,n,r){let a=null!==e?e.length:0,h=null;if(0!==a){if(h=l.value,!0!==r||null===h){let t=n+4*a,r=i.matrixWorldInverse;o.getNormalMatrix(r),(null===h||h.length<t)&&(h=new Float32Array(t));for(let i=0,l=n;i!==a;++i,l+=4)s.copy(e[i]).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 i=0!==e.length||t||0!==n||r;return r=t,n=e.length,i},this.beginShadows=function(){a=!0,h(null)},this.endShadows=function(){a=!1},this.setGlobalState=function(e,t){i=h(e,t,0)},this.setState=function(s,o,c){let u=s.clippingPlanes,d=s.clipIntersection,p=s.clipShadows,f=e.get(s);if(!r||null===u||0===u.length||a&&!p)a?h(null):(l.value!==i&&(l.value=i,l.needsUpdate=n>0),t.numPlanes=n,t.numIntersection=0);else{let e=a?0:n,t=4*e,r=f.clippingState||null;l.value=r,r=h(u,o,t,c);for(let n=0;n!==t;++n)r[n]=i[n];f.clippingState=r,this.numIntersection=d?this.numPlanes:0,this.numPlanes+=e}}}function Uit(e){let t=new WeakMap;function i(e,t){return t===vm?e.mapping=Gh:t===fb&&(e.mapping=uf),e}function n(e){let i=e.target;i.removeEventListener("dispose",n);let r=t.get(i);void 0!==r&&(t.delete(i),r.dispose())}return{get:function(r){if(r&&r.isTexture&&!1===r.isRenderTargetTexture){let a=r.mapping;if(a===vm||a===fb){if(t.has(r))return i(t.get(r).texture,r.mapping);{let a=r.image;if(a&&a.height>0){let s=new _R(a.height/2);return s.fromEquirectangularTexture(e,r),t.set(r,s),r.addEventListener("dispose",n),i(s.texture,r.mapping)}return null}}}return r},dispose:function(){t=new WeakMap}}}var Nr=class extends Xh{constructor(e=-1,t=1,i=1,n=-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=i,this.bottom=n,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,i,n,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=i,this.view.offsetY=n,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),i=(this.right+this.left)/2,n=(this.top+this.bottom)/2,r=i-e,a=i+e,s=n+t,o=n-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}},nv=4,mce=[.125,.215,.35,.446,.526,.582],hm=20,ON=new Nr,gce=new ct,kN=null,um=(1+Math.sqrt(5))/2,Y0=1/um,vce=[new D(1,1,1),new D(-1,1,1),new D(1,1,-1),new D(-1,1,-1),new D(0,um,Y0),new D(0,um,-Y0),new D(Y0,0,um),new D(-Y0,0,um),new D(um,Y0,0),new D(-um,Y0,0)],Yh=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,i=.1,n=100){kN=this._renderer.getRenderTarget(),this._setSize(256);let r=this._allocateTargets();return r.depthBuffer=!0,this._sceneToCubeUV(e,i,n,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=bce(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=xce(),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(kN),e.scissorTest=!1,zM(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===Gh||e.mapping===uf?this._setSize(0===e.image.length?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),kN=this._renderer.getRenderTarget();let i=t||this._allocateTargets();return this._textureToCubeUV(e,i),this._applyPMREM(i),this._cleanup(i),i}_allocateTargets(){let e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,i={magFilter:Pr,minFilter:Pr,generateMipmaps:!1,type:Mr,format:Js,colorSpace:Na,depthBuffer:!1},n=yce(e,t,i);if(null===this._pingPongRenderTarget||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){null!==this._pingPongRenderTarget&&this._dispose(),this._pingPongRenderTarget=yce(e,t,i);let{_lodMax:n}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=Hit(n)),this._blurMaterial=Vit(n,e,t)}return n}_compileMaterial(e){let t=new xt(this._lodPlanes[0],e);this._renderer.compile(t,ON)}_sceneToCubeUV(e,t,i,n){let r=new hr(90,1,t,i),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(gce),o.toneMapping=Vh,o.autoClear=!1;let c=new ln({name:"PMREM.Background",side:Ji,depthWrite:!1,depthTest:!1}),u=new xt(new pa,c),d=!1,p=e.background;p?p.isColor&&(c.color.copy(p),e.background=null,d=!0):(c.color.copy(gce),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 i=this._cubeSize;zM(n,t*i,f>2?i:0,i,i),o.setRenderTarget(n),d&&o.render(u,r),o.render(e,r)}u.geometry.dispose(),u.material.dispose(),o.toneMapping=h,o.autoClear=l,e.background=p}_textureToCubeUV(e,t){let i=this._renderer,n=e.mapping===Gh||e.mapping===uf;n?(null===this._cubemapMaterial&&(this._cubemapMaterial=bce()),this._cubemapMaterial.uniforms.flipEnvMap.value=!1===e.isRenderTargetTexture?-1:1):null===this._equirectMaterial&&(this._equirectMaterial=xce());let r=n?this._cubemapMaterial:this._equirectMaterial,a=new xt(this._lodPlanes[0],r);r.uniforms.envMap.value=e;let s=this._cubeSize;zM(t,0,0,3*s,2*s),i.setRenderTarget(t),i.render(a,ON)}_applyPMREM(e){let t=this._renderer,i=t.autoClear;t.autoClear=!1;for(let n=1;n<this._lodPlanes.length;n++){let t=Math.sqrt(this._sigmas[n]*this._sigmas[n]-this._sigmas[n-1]*this._sigmas[n-1]),i=vce[(n-1)%vce.length];this._blur(e,n-1,n,t,i)}t.autoClear=i}_blur(e,t,i,n,r){let a=this._pingPongRenderTarget;this._halfBlur(e,a,t,i,n,"latitudinal",r),this._halfBlur(a,e,i,i,n,"longitudinal",r)}_halfBlur(e,t,i,n,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 xt(this._lodPlanes[n],l),c=l.uniforms,u=this._sizeLods[i]-1,d=isFinite(r)?Math.PI/(2*u):2*Math.PI/(2*hm-1),p=r/d,f=isFinite(r)?1+Math.floor(3*p):hm;f>hm&&console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${f} samples when the maximum is set to ${hm}`);let m=[],g=0;for(let x=0;x<hm;++x){let e=x/p,t=Math.exp(-e*e/2);m.push(t),0===x?g+=t:x<f&&(g+=2*t)}for(let x=0;x<m.length;x++)m[x]=m[x]/g;c.envMap.value=e.texture,c.samples.value=f,c.weights.value=m,c.latitudinal.value="latitudinal"===a,s&&(c.poleAxis.value=s);let{_lodMax:v}=this;c.dTheta.value=d,c.mipInt.value=v-i;let y=this._sizeLods[n];zM(t,3*y*(n>v-nv?n-v+nv:0),4*(this._cubeSize-y),3*y,2*y),o.setRenderTarget(t),o.render(h,ON)}};function Hit(e){let t=[],i=[],n=[],r=e,a=e-nv+1+mce.length;for(let s=0;s<a;s++){let a=Math.pow(2,r);i.push(a);let o=1/a;s>e-nv?o=mce[s-e+nv-1]:0===s&&(o=0),n.push(o);let l=1/(a-2),h=-l,c=1+l,u=[h,h,c,h,c,c,h,h,c,c,h,c],d=6,p=6,f=3,m=2,g=1,v=new Float32Array(f*p*d),y=new Float32Array(m*p*d),x=new Float32Array(g*p*d);for(let e=0;e<d;e++){let t=e%3*2/3-1,i=e>2?0:-1,n=[t,i,0,t+2/3,i,0,t+2/3,i+1,0,t,i,0,t+2/3,i+1,0,t,i+1,0];v.set(n,f*p*e),y.set(u,m*p*e);let r=[e,e,e,e,e,e];x.set(r,g*p*e)}let b=new Dt;b.setAttribute("position",new mn(v,f)),b.setAttribute("uv",new mn(y,m)),b.setAttribute("faceIndex",new mn(x,g)),t.push(b),r>nv&&r--}return{lodPlanes:t,sizeLods:i,sigmas:n}}function yce(e,t,i){let n=new sr(e,t,i);return n.texture.mapping=Mv,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function zM(e,t,i,n,r){e.viewport.set(t,i,n,r),e.scissor.set(t,i,n,r)}function Vit(e,t,i){let n=new Float32Array(hm),r=new D(0,1,0);return new cn({name:"SphericalGaussianBlur",defines:{n:hm,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/i,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:HU(),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 xce(){return new cn({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:HU(),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 bce(){return new cn({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:HU(),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 HU(){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 zit(e){let t=new WeakMap,i=null;function n(e){let i=e.target;i.removeEventListener("dispose",n);let r=t.get(i);void 0!==r&&(t.delete(i),r.dispose())}return{get:function(r){if(r&&r.isTexture){let a=r.mapping,s=a===vm||a===fb,o=a===Gh||a===uf;if(s||o){if(r.isRenderTargetTexture&&!0===r.needsPMREMUpdate){r.needsPMREMUpdate=!1;let n=t.get(r);return null===i&&(i=new Yh(e)),n=s?i.fromEquirectangular(r,n):i.fromCubemap(r,n),t.set(r,n),n.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 i=0;i<6;i++)void 0!==e[i]&&t++;return 6===t}(a)){null===i&&(i=new Yh(e));let a=s?i.fromEquirectangular(r):i.fromCubemap(r);return t.set(r,a),r.addEventListener("dispose",n),a.texture}return null}}}return r},dispose:function(){t=new WeakMap,null!==i&&(i.dispose(),i=null)}}}function Git(e){let t={};function i(i){if(void 0!==t[i])return t[i];let n;switch(i){case"WEBGL_depth_texture":n=e.getExtension("WEBGL_depth_texture")||e.getExtension("MOZ_WEBGL_depth_texture")||e.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":n=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":n=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":n=e.getExtension("WEBGL_compressed_texture_pvrtc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:n=e.getExtension(i)}return t[i]=n,n}return{has:function(e){return null!==i(e)},init:function(e){e.isWebGL2?i("EXT_color_buffer_float"):(i("WEBGL_depth_texture"),i("OES_texture_float"),i("OES_texture_half_float"),i("OES_texture_half_float_linear"),i("OES_standard_derivatives"),i("OES_element_index_uint"),i("OES_vertex_array_object"),i("ANGLE_instanced_arrays")),i("OES_texture_float_linear"),i("EXT_color_buffer_half_float"),i("WEBGL_multisampled_render_to_texture")},get:function(e){let t=i(e);return null===t&&console.warn("THREE.WebGLRenderer: "+e+" extension not supported."),t}}}function qit(e,t,i,n){let r={},a=new WeakMap;function s(e){let o=e.target;null!==o.index&&t.remove(o.index);for(let i in o.attributes)t.remove(o.attributes[i]);for(let i in o.morphAttributes){let e=o.morphAttributes[i];for(let i=0,n=e.length;i<n;i++)t.remove(e[i])}o.removeEventListener("dispose",s),delete r[o.id];let l=a.get(o);l&&(t.remove(l),a.delete(o)),n.releaseStatesOfGeometry(o),!0===o.isInstancedBufferGeometry&&delete o._maxInstanceCount,i.memory.geometries--}function o(e){let i=[],n=e.index,r=e.attributes.position,s=0;if(null!==n){let e=n.array;s=n.version;for(let t=0,n=e.length;t<n;t+=3){let n=e[t+0],r=e[t+1],a=e[t+2];i.push(n,r,r,a,a,n)}}else{if(void 0===r)return;{let e=r.array;s=r.version;for(let t=0,n=e.length/3-1;t<n;t+=3){let e=t+0,n=t+1,r=t+2;i.push(e,n,n,r,r,e)}}}let o=new(vhe(i)?Eb:ym)(i,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,i.memory.geometries++),t},update:function(i){let n=i.attributes;for(let a in n)t.update(n[a],e.ARRAY_BUFFER);let r=i.morphAttributes;for(let a in r){let i=r[a];for(let n=0,r=i.length;n<r;n++)t.update(i[n],e.ARRAY_BUFFER)}},getWireframeAttribute:function(e){let t=a.get(e);if(t){let i=e.index;null!==i&&t.version<i.version&&o(e)}else o(e);return a.get(e)}}}function Wit(e,t,i,n){let r,a,s,o=n.isWebGL2;this.setMode=function(e){r=e},this.setIndex=function(e){a=e.type,s=e.bytesPerElement},this.render=function(t,n){e.drawElements(r,n,a,t*s),i.update(n,r,1)},this.renderInstances=function(n,l,h){if(0===h)return;let c,u;if(o)c=e,u="drawElementsInstanced";else if(c=t.get("ANGLE_instanced_arrays"),u="drawElementsInstancedANGLE",null===c)return void console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");c[u](r,l,a,n*s,h),i.update(l,r,h)}}function jit(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(i,n,r){switch(t.calls++,n){case e.TRIANGLES:t.triangles+=r*(i/3);break;case e.LINES:t.lines+=r*(i/2);break;case e.LINE_STRIP:t.lines+=r*(i-1);break;case e.LINE_LOOP:t.lines+=r*i;break;case e.POINTS:t.points+=r*i;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",n)}}}}function Xit(e,t){return e[0]-t[0]}function Yit(e,t){return Math.abs(t[1])-Math.abs(e[1])}function $it(e,t,i){let n={},r=new Float32Array(8),a=new WeakMap,s=new gr,o=[];for(let l=0;l<8;l++)o[l]=[l,0];return{update:function(l,h,c){let u=l.morphTargetInfluences;if(!0===t.isWebGL2){let n=h.morphAttributes.position||h.morphAttributes.normal||h.morphAttributes.color,r=void 0!==n?n.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 i=void 0!==h.morphAttributes.position,n=void 0!==h.morphAttributes.normal,l=void 0!==h.morphAttributes.color,c=h.morphAttributes.position||[],u=h.morphAttributes.normal||[],d=h.morphAttributes.color||[],p=0;!0===i&&(p=1),!0===n&&(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 ov(g,f,m,r);v.type=fa,v.needsUpdate=!0;let y=4*p;for(let t=0;t<r;t++){let e=c[t],r=u[t],a=d[t],o=f*m*4*t;for(let t=0;t<e.count;t++){let h=t*y;!0===i&&(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===n&&(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 xe(f,m)},a.set(h,o),h.addEventListener("dispose",e)}let l=0;for(let e=0;e<u.length;e++)l+=u[e];let d=h.morphTargetsRelative?1:1-l;c.getUniforms().setValue(e,"morphTargetBaseInfluence",d),c.getUniforms().setValue(e,"morphTargetInfluences",u),c.getUniforms().setValue(e,"morphTargetsTexture",o.texture,i),c.getUniforms().setValue(e,"morphTargetsTextureSize",o.size)}else{let t=void 0===u?0:u.length,i=n[h.id];if(void 0===i||i.length!==t){i=[];for(let e=0;e<t;e++)i[e]=[e,0];n[h.id]=i}for(let e=0;e<t;e++){let t=i[e];t[0]=e,t[1]=u[e]}i.sort(Yit);for(let e=0;e<8;e++)e<t&&i[e][1]?(o[e][0]=i[e][0],o[e][1]=i[e][1]):(o[e][0]=Number.MAX_SAFE_INTEGER,o[e][1]=0);o.sort(Xit);let a=h.morphAttributes.position,s=h.morphAttributes.normal,l=0;for(let e=0;e<8;e++){let t=o[e],i=t[0],n=t[1];i!==Number.MAX_SAFE_INTEGER&&n?(a&&h.getAttribute("morphTarget"+e)!==a[i]&&h.setAttribute("morphTarget"+e,a[i]),s&&h.getAttribute("morphNormal"+e)!==s[i]&&h.setAttribute("morphNormal"+e,s[i]),r[e]=n,l+=n):(a&&!0===h.hasAttribute("morphTarget"+e)&&h.deleteAttribute("morphTarget"+e),s&&!0===h.hasAttribute("morphNormal"+e)&&h.deleteAttribute("morphNormal"+e),r[e]=0)}let d=h.morphTargetsRelative?1:1-l;c.getUniforms().setValue(e,"morphTargetBaseInfluence",d),c.getUniforms().setValue(e,"morphTargetInfluences",r)}}}}function Zit(e,t,i,n){let r=new WeakMap;function a(e){let t=e.target;t.removeEventListener("dispose",a),i.remove(t.instanceMatrix),null!==t.instanceColor&&i.remove(t.instanceColor)}return{update:function(s){let o=n.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&&(i.update(s.instanceMatrix,e.ARRAY_BUFFER),null!==s.instanceColor&&i.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 Ehe=new Gr,_he=new ov,The=new xb,whe=new xm,Ece=[],_ce=[],Tce=new Float32Array(16),wce=new Float32Array(9),Sce=new Float32Array(4);function Iv(e,t,i){let n=e[0];if(n<=0||n>0)return e;let r=t*i,a=Ece[r];if(void 0===a&&(a=new Float32Array(r),Ece[r]=a),0!==t){n.toArray(a,0);for(let n=1,r=0;n!==t;++n)r+=i,e[n].toArray(a,r)}return a}function Ls(e,t){if(e.length!==t.length)return!1;for(let i=0,n=e.length;i<n;i++)if(e[i]!==t[i])return!1;return!0}function Ds(e,t){for(let i=0,n=t.length;i<n;i++)e[i]=t[i]}function JR(e,t){let i=_ce[t];void 0===i&&(i=new Int32Array(t),_ce[t]=i);for(let n=0;n!==t;++n)i[n]=e.allocateTextureUnit();return i}function Kit(e,t){let i=this.cache;i[0]!==t&&(e.uniform1f(this.addr,t),i[0]=t)}function Jit(e,t){let i=this.cache;if(void 0!==t.x)(i[0]!==t.x||i[1]!==t.y)&&(e.uniform2f(this.addr,t.x,t.y),i[0]=t.x,i[1]=t.y);else{if(Ls(i,t))return;e.uniform2fv(this.addr,t),Ds(i,t)}}function Qit(e,t){let i=this.cache;if(void 0!==t.x)(i[0]!==t.x||i[1]!==t.y||i[2]!==t.z)&&(e.uniform3f(this.addr,t.x,t.y,t.z),i[0]=t.x,i[1]=t.y,i[2]=t.z);else if(void 0!==t.r)(i[0]!==t.r||i[1]!==t.g||i[2]!==t.b)&&(e.uniform3f(this.addr,t.r,t.g,t.b),i[0]=t.r,i[1]=t.g,i[2]=t.b);else{if(Ls(i,t))return;e.uniform3fv(this.addr,t),Ds(i,t)}}function est(e,t){let i=this.cache;if(void 0!==t.x)(i[0]!==t.x||i[1]!==t.y||i[2]!==t.z||i[3]!==t.w)&&(e.uniform4f(this.addr,t.x,t.y,t.z,t.w),i[0]=t.x,i[1]=t.y,i[2]=t.z,i[3]=t.w);else{if(Ls(i,t))return;e.uniform4fv(this.addr,t),Ds(i,t)}}function tst(e,t){let i=this.cache,n=t.elements;if(void 0===n){if(Ls(i,t))return;e.uniformMatrix2fv(this.addr,!1,t),Ds(i,t)}else{if(Ls(i,n))return;Sce.set(n),e.uniformMatrix2fv(this.addr,!1,Sce),Ds(i,n)}}function nst(e,t){let i=this.cache,n=t.elements;if(void 0===n){if(Ls(i,t))return;e.uniformMatrix3fv(this.addr,!1,t),Ds(i,t)}else{if(Ls(i,n))return;wce.set(n),e.uniformMatrix3fv(this.addr,!1,wce),Ds(i,n)}}function rst(e,t){let i=this.cache,n=t.elements;if(void 0===n){if(Ls(i,t))return;e.uniformMatrix4fv(this.addr,!1,t),Ds(i,t)}else{if(Ls(i,n))return;Tce.set(n),e.uniformMatrix4fv(this.addr,!1,Tce),Ds(i,n)}}function ist(e,t){let i=this.cache;i[0]!==t&&(e.uniform1i(this.addr,t),i[0]=t)}function sst(e,t){let i=this.cache;if(void 0!==t.x)(i[0]!==t.x||i[1]!==t.y)&&(e.uniform2i(this.addr,t.x,t.y),i[0]=t.x,i[1]=t.y);else{if(Ls(i,t))return;e.uniform2iv(this.addr,t),Ds(i,t)}}function ast(e,t){let i=this.cache;if(void 0!==t.x)(i[0]!==t.x||i[1]!==t.y||i[2]!==t.z)&&(e.uniform3i(this.addr,t.x,t.y,t.z),i[0]=t.x,i[1]=t.y,i[2]=t.z);else{if(Ls(i,t))return;e.uniform3iv(this.addr,t),Ds(i,t)}}function ost(e,t){let i=this.cache;if(void 0!==t.x)(i[0]!==t.x||i[1]!==t.y||i[2]!==t.z||i[3]!==t.w)&&(e.uniform4i(this.addr,t.x,t.y,t.z,t.w),i[0]=t.x,i[1]=t.y,i[2]=t.z,i[3]=t.w);else{if(Ls(i,t))return;e.uniform4iv(this.addr,t),Ds(i,t)}}function lst(e,t){let i=this.cache;i[0]!==t&&(e.uniform1ui(this.addr,t),i[0]=t)}function cst(e,t){let i=this.cache;if(void 0!==t.x)(i[0]!==t.x||i[1]!==t.y)&&(e.uniform2ui(this.addr,t.x,t.y),i[0]=t.x,i[1]=t.y);else{if(Ls(i,t))return;e.uniform2uiv(this.addr,t),Ds(i,t)}}function ust(e,t){let i=this.cache;if(void 0!==t.x)(i[0]!==t.x||i[1]!==t.y||i[2]!==t.z)&&(e.uniform3ui(this.addr,t.x,t.y,t.z),i[0]=t.x,i[1]=t.y,i[2]=t.z);else{if(Ls(i,t))return;e.uniform3uiv(this.addr,t),Ds(i,t)}}function hst(e,t){let i=this.cache;if(void 0!==t.x)(i[0]!==t.x||i[1]!==t.y||i[2]!==t.z||i[3]!==t.w)&&(e.uniform4ui(this.addr,t.x,t.y,t.z,t.w),i[0]=t.x,i[1]=t.y,i[2]=t.z,i[3]=t.w);else{if(Ls(i,t))return;e.uniform4uiv(this.addr,t),Ds(i,t)}}function dst(e,t,i){let n=this.cache,r=i.allocateTextureUnit();n[0]!==r&&(e.uniform1i(this.addr,r),n[0]=r),i.setTexture2D(t||Ehe,r)}function fst(e,t,i){let n=this.cache,r=i.allocateTextureUnit();n[0]!==r&&(e.uniform1i(this.addr,r),n[0]=r),i.setTexture3D(t||The,r)}function pst(e,t,i){let n=this.cache,r=i.allocateTextureUnit();n[0]!==r&&(e.uniform1i(this.addr,r),n[0]=r),i.setTextureCube(t||whe,r)}function mst(e,t,i){let n=this.cache,r=i.allocateTextureUnit();n[0]!==r&&(e.uniform1i(this.addr,r),n[0]=r),i.setTexture2DArray(t||_he,r)}function gst(e){switch(e){case 5126:return Kit;case 35664:return Jit;case 35665:return Qit;case 35666:return est;case 35674:return tst;case 35675:return nst;case 35676:return rst;case 5124:case 35670:return ist;case 35667:case 35671:return sst;case 35668:case 35672:return ast;case 35669:case 35673:return ost;case 5125:return lst;case 36294:return cst;case 36295:return ust;case 36296:return hst;case 35678:case 36198:case 36298:case 36306:case 35682:return dst;case 35679:case 36299:case 36307:return fst;case 35680:case 36300:case 36308:case 36293:return pst;case 36289:case 36303:case 36311:case 36292:return mst}}function vst(e,t){e.uniform1fv(this.addr,t)}function yst(e,t){let i=Iv(t,this.size,2);e.uniform2fv(this.addr,i)}function xst(e,t){let i=Iv(t,this.size,3);e.uniform3fv(this.addr,i)}function bst(e,t){let i=Iv(t,this.size,4);e.uniform4fv(this.addr,i)}function Est(e,t){let i=Iv(t,this.size,4);e.uniformMatrix2fv(this.addr,!1,i)}function _st(e,t){let i=Iv(t,this.size,9);e.uniformMatrix3fv(this.addr,!1,i)}function Tst(e,t){let i=Iv(t,this.size,16);e.uniformMatrix4fv(this.addr,!1,i)}function wst(e,t){e.uniform1iv(this.addr,t)}function Sst(e,t){e.uniform2iv(this.addr,t)}function Mst(e,t){e.uniform3iv(this.addr,t)}function Rst(e,t){e.uniform4iv(this.addr,t)}function Ast(e,t){e.uniform1uiv(this.addr,t)}function Cst(e,t){e.uniform2uiv(this.addr,t)}function Pst(e,t){e.uniform3uiv(this.addr,t)}function Ist(e,t){e.uniform4uiv(this.addr,t)}function Lst(e,t,i){let n=this.cache,r=t.length,a=JR(i,r);Ls(n,a)||(e.uniform1iv(this.addr,a),Ds(n,a));for(let s=0;s!==r;++s)i.setTexture2D(t[s]||Ehe,a[s])}function Dst(e,t,i){let n=this.cache,r=t.length,a=JR(i,r);Ls(n,a)||(e.uniform1iv(this.addr,a),Ds(n,a));for(let s=0;s!==r;++s)i.setTexture3D(t[s]||The,a[s])}function Ost(e,t,i){let n=this.cache,r=t.length,a=JR(i,r);Ls(n,a)||(e.uniform1iv(this.addr,a),Ds(n,a));for(let s=0;s!==r;++s)i.setTextureCube(t[s]||whe,a[s])}function kst(e,t,i){let n=this.cache,r=t.length,a=JR(i,r);Ls(n,a)||(e.uniform1iv(this.addr,a),Ds(n,a));for(let s=0;s!==r;++s)i.setTexture2DArray(t[s]||_he,a[s])}function Fst(e){switch(e){case 5126:return vst;case 35664:return yst;case 35665:return xst;case 35666:return bst;case 35674:return Est;case 35675:return _st;case 35676:return Tst;case 5124:case 35670:return wst;case 35667:case 35671:return Sst;case 35668:case 35672:return Mst;case 35669:case 35673:return Rst;case 5125:return Ast;case 36294:return Cst;case 36295:return Pst;case 36296:return Ist;case 35678:case 36198:case 36298:case 36306:case 35682:return Lst;case 35679:case 36299:case 36307:return Dst;case 35680:case 36300:case 36308:case 36293:return Ost;case 36289:case 36303:case 36311:case 36292:return kst}}var OB=class{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.setValue=gst(t.type)}},kB=class{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.size=t.size,this.setValue=Fst(t.type)}},FB=class{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,i){let n=this.seq;for(let r=0,a=n.length;r!==a;++r){let a=n[r];a.setValue(e,t[a.id],i)}}},FN=/(\w+)(\])?(\[|\.)?/g;function Mce(e,t){e.seq.push(t),e.map[t.id]=t}function Nst(e,t,i){let n=e.name,r=n.length;for(FN.lastIndex=0;;){let a=FN.exec(n),s=FN.lastIndex,o=a[1],l="]"===a[2],h=a[3];if(l&&(o|=0),void 0===h||"["===h&&s+2===r){Mce(i,void 0===h?new OB(o,e,t):new kB(o,e,t));break}{let e=i.map[o];void 0===e&&(e=new FB(o),Mce(i,e)),i=e}}}var sv=class{constructor(e,t){this.seq=[],this.map={};let i=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let n=0;n<i;++n){let i=e.getActiveUniform(t,n);Nst(i,e.getUniformLocation(t,i.name),this)}}setValue(e,t,i,n){let r=this.map[t];void 0!==r&&r.setValue(e,i,n)}setOptional(e,t,i){let n=t[i];void 0!==n&&this.setValue(e,i,n)}static upload(e,t,i,n){for(let r=0,a=t.length;r!==a;++r){let a=t[r],s=i[a.id];!1!==s.needsUpdate&&a.setValue(e,s.value,n)}}static seqWithValue(e,t){let i=[];for(let n=0,r=e.length;n!==r;++n){let r=e[n];r.id in t&&i.push(r)}return i}};function Rce(e,t,i){let n=e.createShader(t);return e.shaderSource(n,i),e.compileShader(n),n}var Bst=0;function Ust(e,t){let i=e.split("\n"),n=[],r=Math.max(t-6,0),a=Math.min(t+6,i.length);for(let s=r;s<a;s++){let e=s+1;n.push(`${e===t?">":" "} ${e}: ${i[s]}`)}return n.join("\n")}function Hst(e){switch(e){case Na:return["Linear","( value )"];case en:return["sRGB","( value )"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",e),["Linear","( value )"]}}function Ace(e,t,i){let n=e.getShaderParameter(t,e.COMPILE_STATUS),r=e.getShaderInfoLog(t).trim();if(n&&""===r)return"";let a=/ERROR: 0:(\d+)/.exec(r);if(a){let n=parseInt(a[1]);return i.toUpperCase()+"\n\n"+r+"\n\n"+Ust(e.getShaderSource(t),n)}return r}function Vst(e,t){let i=Hst(t);return"vec4 "+e+"( vec4 value ) { return LinearTo"+i[0]+i[1]+"; }"}function zst(e,t){let i;switch(t){case que:i="Linear";break;case Wue:i="Reinhard";break;case jue:i="OptimizedCineon";break;case Xue:i="ACESFilmic";break;case Yue:i="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",t),i="Linear"}return"vec3 "+e+"( vec3 color ) { return "+i+"ToneMapping( color ); }"}function Gst(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(ob).join("\n")}function qst(e){let t=[];for(let i in e){let n=e[i];!1!==n&&t.push("#define "+i+" "+n)}return t.join("\n")}function Wst(e,t){let i={},n=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let r=0;r<n;r++){let n=e.getActiveAttrib(t,r),a=n.name,s=1;n.type===e.FLOAT_MAT2&&(s=2),n.type===e.FLOAT_MAT3&&(s=3),n.type===e.FLOAT_MAT4&&(s=4),i[a]={type:n.type,location:e.getAttribLocation(t,a),locationSize:s}}return i}function ob(e){return""!==e}function Cce(e,t){let i=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,i).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 Pce(e,t){return e.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}var jst=/^[ \t]*#include +<([\w\d./]+)>/gm;function NB(e){return e.replace(jst,Yst)}var Xst=new Map([["encodings_fragment","colorspace_fragment"],["encodings_pars_fragment","colorspace_pars_fragment"],["output_fragment","opaque_fragment"]]);function Yst(e,t){let i=$n[t];if(void 0===i){let e=Xst.get(t);if(void 0===e)throw new Error("Can not resolve #include <"+t+">");i=$n[e],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,e)}return NB(i)}var $st=/#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 Ice(e){return e.replace($st,Zst)}function Zst(e,t,i,n){let r="";for(let a=parseInt(t);a<parseInt(i);a++)r+=n.replace(/\[\s*i\s*\]/g,"[ "+a+" ]").replace(/UNROLLED_LOOP_INDEX/g,a);return r}function Lce(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 Kst(e){let t="SHADOWMAP_TYPE_BASIC";return e.shadowMapType===MU?t="SHADOWMAP_TYPE_PCF":e.shadowMapType===Tv?t="SHADOWMAP_TYPE_PCF_SOFT":e.shadowMapType===vu&&(t="SHADOWMAP_TYPE_VSM"),t}function Jst(e){let t="ENVMAP_TYPE_CUBE";if(e.envMap)switch(e.envMapMode){case Gh:case uf:t="ENVMAP_TYPE_CUBE";break;case Mv:t="ENVMAP_TYPE_CUBE_UV"}return t}function Qst(e){let t="ENVMAP_MODE_REFLECTION";return e.envMap&&e.envMapMode===uf&&(t="ENVMAP_MODE_REFRACTION"),t}function eat(e){let t="ENVMAP_BLENDING_NONE";if(e.envMap)switch(e.combine){case Hb:t="ENVMAP_BLENDING_MULTIPLY";break;case zue:t="ENVMAP_BLENDING_MIX";break;case Gue:t="ENVMAP_BLENDING_ADD"}return t}function tat(e){let t=e.envMapCubeUVHeight;if(null===t)return null;let i=Math.log2(t)-2,n=1/t;return{texelWidth:1/(3*Math.max(Math.pow(2,i),112)),texelHeight:n,maxMip:i}}function nat(e,t,i,n){let r,a,s=e.getContext(),o=i.defines,l=i.vertexShader,h=i.fragmentShader,c=Kst(i),u=Jst(i),d=Qst(i),p=eat(i),f=tat(i),m=i.isWebGL2?"":Gst(i),g=qst(o),v=s.createProgram(),y=i.glslVersion?"#version "+i.glslVersion+"\n":"";i.isRawShaderMaterial?(r=["#define SHADER_TYPE "+i.shaderType,"#define SHADER_NAME "+i.shaderName,g].filter(ob).join("\n"),r.length>0&&(r+="\n"),a=[m,"#define SHADER_TYPE "+i.shaderType,"#define SHADER_NAME "+i.shaderName,g].filter(ob).join("\n"),a.length>0&&(a+="\n")):(r=[Lce(i),"#define SHADER_TYPE "+i.shaderType,"#define SHADER_NAME "+i.shaderName,g,i.instancing?"#define USE_INSTANCING":"",i.instancingColor?"#define USE_INSTANCING_COLOR":"",i.useFog&&i.fog?"#define USE_FOG":"",i.useFog&&i.fogExp2?"#define FOG_EXP2":"",i.map?"#define USE_MAP":"",i.envMap?"#define USE_ENVMAP":"",i.envMap?"#define "+d:"",i.lightMap?"#define USE_LIGHTMAP":"",i.aoMap?"#define USE_AOMAP":"",i.bumpMap?"#define USE_BUMPMAP":"",i.normalMap?"#define USE_NORMALMAP":"",i.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",i.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",i.displacementMap?"#define USE_DISPLACEMENTMAP":"",i.emissiveMap?"#define USE_EMISSIVEMAP":"",i.anisotropyMap?"#define USE_ANISOTROPYMAP":"",i.clearcoatMap?"#define USE_CLEARCOATMAP":"",i.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",i.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",i.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",i.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",i.specularMap?"#define USE_SPECULARMAP":"",i.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",i.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",i.roughnessMap?"#define USE_ROUGHNESSMAP":"",i.metalnessMap?"#define USE_METALNESSMAP":"",i.alphaMap?"#define USE_ALPHAMAP":"",i.alphaHash?"#define USE_ALPHAHASH":"",i.transmission?"#define USE_TRANSMISSION":"",i.transmissionMap?"#define USE_TRANSMISSIONMAP":"",i.thicknessMap?"#define USE_THICKNESSMAP":"",i.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",i.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",i.mapUv?"#define MAP_UV "+i.mapUv:"",i.alphaMapUv?"#define ALPHAMAP_UV "+i.alphaMapUv:"",i.lightMapUv?"#define LIGHTMAP_UV "+i.lightMapUv:"",i.aoMapUv?"#define AOMAP_UV "+i.aoMapUv:"",i.emissiveMapUv?"#define EMISSIVEMAP_UV "+i.emissiveMapUv:"",i.bumpMapUv?"#define BUMPMAP_UV "+i.bumpMapUv:"",i.normalMapUv?"#define NORMALMAP_UV "+i.normalMapUv:"",i.displacementMapUv?"#define DISPLACEMENTMAP_UV "+i.displacementMapUv:"",i.metalnessMapUv?"#define METALNESSMAP_UV "+i.metalnessMapUv:"",i.roughnessMapUv?"#define ROUGHNESSMAP_UV "+i.roughnessMapUv:"",i.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+i.anisotropyMapUv:"",i.clearcoatMapUv?"#define CLEARCOATMAP_UV "+i.clearcoatMapUv:"",i.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+i.clearcoatNormalMapUv:"",i.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+i.clearcoatRoughnessMapUv:"",i.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+i.iridescenceMapUv:"",i.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+i.iridescenceThicknessMapUv:"",i.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+i.sheenColorMapUv:"",i.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+i.sheenRoughnessMapUv:"",i.specularMapUv?"#define SPECULARMAP_UV "+i.specularMapUv:"",i.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+i.specularColorMapUv:"",i.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+i.specularIntensityMapUv:"",i.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+i.transmissionMapUv:"",i.thicknessMapUv?"#define THICKNESSMAP_UV "+i.thicknessMapUv:"",i.vertexTangents&&!1===i.flatShading?"#define USE_TANGENT":"",i.vertexColors?"#define USE_COLOR":"",i.vertexAlphas?"#define USE_COLOR_ALPHA":"",i.vertexUv1s?"#define USE_UV1":"",i.vertexUv2s?"#define USE_UV2":"",i.vertexUv3s?"#define USE_UV3":"",i.pointsUvs?"#define USE_POINTS_UV":"",i.flatShading?"#define FLAT_SHADED":"",i.skinning?"#define USE_SKINNING":"",i.morphTargets?"#define USE_MORPHTARGETS":"",i.morphNormals&&!1===i.flatShading?"#define USE_MORPHNORMALS":"",i.morphColors&&i.isWebGL2?"#define USE_MORPHCOLORS":"",i.morphTargetsCount>0&&i.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",i.morphTargetsCount>0&&i.isWebGL2?"#define MORPHTARGETS_TEXTURE_STRIDE "+i.morphTextureStride:"",i.morphTargetsCount>0&&i.isWebGL2?"#define MORPHTARGETS_COUNT "+i.morphTargetsCount:"",i.doubleSided?"#define DOUBLE_SIDED":"",i.flipSided?"#define FLIP_SIDED":"",i.shadowMapEnabled?"#define USE_SHADOWMAP":"",i.shadowMapEnabled?"#define "+c:"",i.sizeAttenuation?"#define USE_SIZEATTENUATION":"",i.useLegacyLights?"#define LEGACY_LIGHTS":"",i.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",i.logarithmicDepthBuffer&&i.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(ob).join("\n"),a=[m,Lce(i),"#define SHADER_TYPE "+i.shaderType,"#define SHADER_NAME "+i.shaderName,g,i.useFog&&i.fog?"#define USE_FOG":"",i.useFog&&i.fogExp2?"#define FOG_EXP2":"",i.map?"#define USE_MAP":"",i.matcap?"#define USE_MATCAP":"",i.envMap?"#define USE_ENVMAP":"",i.envMap?"#define "+u:"",i.envMap?"#define "+d:"",i.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":"",i.lightMap?"#define USE_LIGHTMAP":"",i.aoMap?"#define USE_AOMAP":"",i.bumpMap?"#define USE_BUMPMAP":"",i.normalMap?"#define USE_NORMALMAP":"",i.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",i.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",i.emissiveMap?"#define USE_EMISSIVEMAP":"",i.anisotropy?"#define USE_ANISOTROPY":"",i.anisotropyMap?"#define USE_ANISOTROPYMAP":"",i.clearcoat?"#define USE_CLEARCOAT":"",i.clearcoatMap?"#define USE_CLEARCOATMAP":"",i.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",i.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",i.iridescence?"#define USE_IRIDESCENCE":"",i.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",i.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",i.specularMap?"#define USE_SPECULARMAP":"",i.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",i.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",i.roughnessMap?"#define USE_ROUGHNESSMAP":"",i.metalnessMap?"#define USE_METALNESSMAP":"",i.alphaMap?"#define USE_ALPHAMAP":"",i.alphaTest?"#define USE_ALPHATEST":"",i.alphaHash?"#define USE_ALPHAHASH":"",i.sheen?"#define USE_SHEEN":"",i.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",i.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",i.transmission?"#define USE_TRANSMISSION":"",i.transmissionMap?"#define USE_TRANSMISSIONMAP":"",i.thicknessMap?"#define USE_THICKNESSMAP":"",i.vertexTangents&&!1===i.flatShading?"#define USE_TANGENT":"",i.vertexColors||i.instancingColor?"#define USE_COLOR":"",i.vertexAlphas?"#define USE_COLOR_ALPHA":"",i.vertexUv1s?"#define USE_UV1":"",i.vertexUv2s?"#define USE_UV2":"",i.vertexUv3s?"#define USE_UV3":"",i.pointsUvs?"#define USE_POINTS_UV":"",i.gradientMap?"#define USE_GRADIENTMAP":"",i.flatShading?"#define FLAT_SHADED":"",i.doubleSided?"#define DOUBLE_SIDED":"",i.flipSided?"#define FLIP_SIDED":"",i.shadowMapEnabled?"#define USE_SHADOWMAP":"",i.shadowMapEnabled?"#define "+c:"",i.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",i.useLegacyLights?"#define LEGACY_LIGHTS":"",i.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",i.logarithmicDepthBuffer&&i.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",i.toneMapping!==Vh?"#define TONE_MAPPING":"",i.toneMapping!==Vh?$n.tonemapping_pars_fragment:"",i.toneMapping!==Vh?zst("toneMapping",i.toneMapping):"",i.dithering?"#define DITHERING":"",i.opaque?"#define OPAQUE":"",$n.colorspace_pars_fragment,Vst("linearToOutputTexel",i.outputColorSpace),i.useDepthPacking?"#define DEPTH_PACKING "+i.depthPacking:"","\n"].filter(ob).join("\n")),l=NB(l),l=Cce(l,i),l=Pce(l,i),h=NB(h),h=Cce(h,i),h=Pce(h,i),l=Ice(l),h=Ice(h),i.isWebGL2&&!0!==i.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",i.glslVersion===TB?"":"layout(location = 0) out highp vec4 pc_fragColor;",i.glslVersion===TB?"":"#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=Rce(s,s.VERTEX_SHADER,_),M=Rce(s,s.FRAGMENT_SHADER,w);if(s.attachShader(v,S),s.attachShader(v,M),void 0!==i.index0AttributeName?s.bindAttribLocation(v,0,i.index0AttributeName):!0===i.morphTargets&&s.bindAttribLocation(v,0,"position"),s.linkProgram(v),e.debug.checkShaderErrors){let t=s.getProgramInfoLog(v).trim(),i=s.getShaderInfoLog(S).trim(),n=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=Ace(s,S,"vertex"),i=Ace(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"+i)}else""!==t?console.warn("THREE.WebGLProgram: Program Info Log:",t):(""===i||""===n)&&(l=!1);l&&(this.diagnostics={runnable:o,programLog:t,vertexShader:{log:i,prefix:r},fragmentShader:{log:n,prefix:a}})}return s.deleteShader(S),s.deleteShader(M),this.getUniforms=function(){return void 0===x&&(x=new sv(s,v)),x},this.getAttributes=function(){return void 0===b&&(b=Wst(s,v)),b},this.destroy=function(){n.releaseStatesOfProgram(this),s.deleteProgram(v),this.program=void 0},this.type=i.shaderType,this.name=i.shaderName,this.id=Bst++,this.cacheKey=t,this.usedTimes=1,this.program=v,this.vertexShader=S,this.fragmentShader=M,this}var rat=0,BB=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){let t=e.vertexShader,i=e.fragmentShader,n=this._getShaderStage(t),r=this._getShaderStage(i),a=this._getShaderCacheForMaterial(e);return!1===a.has(n)&&(a.add(n),n.usedTimes++),!1===a.has(r)&&(a.add(r),r.usedTimes++),this}remove(e){let t=this.materialCache.get(e);for(let i of t)i.usedTimes--,0===i.usedTimes&&this.shaderCache.delete(i.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,i=t.get(e);return void 0===i&&(i=new Set,t.set(e,i)),i}_getShaderStage(e){let t=this.shaderCache,i=t.get(e);return void 0===i&&(i=new UB(e),t.set(e,i)),i}},UB=class{constructor(e){this.id=rat++,this.code=e,this.usedTimes=0}};function iat(e,t,i,n,r,a,s){let o=new df,l=new BB,h=[],c=r.isWebGL2,u=r.logarithmicDepthBuffer,d=r.vertexTextures,p=r.precision,f={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function m(e){return 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?i:t).get(a.envMap||b),w=_&&_.mapping===Mv?_.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=yc[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 D=e.getRenderTarget(),L=!0===v.isInstancedMesh,I=!!a.map,O=!!a.matcap,k=!!_,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,Z=G&&!!a.anisotropyMap,Q=W&&!!a.clearcoatMap,J=W&&!!a.clearcoatNormalMap,K=W&&!!a.clearcoatRoughnessMap,$=X&&!!a.iridescenceMap,ee=X&&!!a.iridescenceThicknessMap,te=Y&&!!a.sheenColorMap,ie=Y&&!!a.sheenRoughnessMap,ne=!!a.specularMap,re=!!a.specularColorMap,ae=!!a.specularIntensityMap,se=q&&!!a.transmissionMap,oe=q&&!!a.thicknessMap,le=!!a.gradientMap,he=!!a.alphaMap,ce=a.alphaTest>0,ue=!!a.alphaHash,de=!!a.extensions,pe=!!x.attributes.uv1,fe=!!x.attributes.uv2,me=!!x.attributes.uv3,ge=Vh;return a.toneMapped&&(null===D||!0===D.isXRRenderTarget)&&(ge=e.toneMapping),{isWebGL2:c,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:L,instancingColor:L&&null!==v.instanceColor,supportsVertexTextures:d,outputColorSpace:null===D?e.outputColorSpace:!0===D.isXRRenderTarget?D.texture.colorSpace:Na,map:I,matcap:O,envMap:k,envMapMode:k&&_.mapping,envMapCubeUVHeight:w,aoMap:N,lightMap:U,bumpMap:F,normalMap:B,displacementMap:d&&z,emissiveMap:H,normalMapObjectSpace:B&&a.normalMapType===ahe,normalMapTangentSpace:B&&a.normalMapType===yf,metalnessMap:V,roughnessMap:j,anisotropy:G,anisotropyMap:Z,clearcoat:W,clearcoatMap:Q,clearcoatNormalMap:J,clearcoatRoughnessMap:K,iridescence:X,iridescenceMap:$,iridescenceThicknessMap:ee,sheen:Y,sheenColorMap:te,sheenRoughnessMap:ie,specularMap:ne,specularColorMap:re,specularIntensityMap:ae,transmission:q,transmissionMap:se,thicknessMap:oe,gradientMap:le,opaque:!1===a.transparent&&a.blending===mm,alphaMap:he,alphaTest:ce,alphaHash:ue,combine:a.combine,mapUv:I&&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:Z&&m(a.anisotropyMap.channel),clearcoatMapUv:Q&&m(a.clearcoatMap.channel),clearcoatNormalMapUv:J&&m(a.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:K&&m(a.clearcoatRoughnessMap.channel),iridescenceMapUv:$&&m(a.iridescenceMap.channel),iridescenceThicknessMapUv:ee&&m(a.iridescenceThicknessMap.channel),sheenColorMapUv:te&&m(a.sheenColorMap.channel),sheenRoughnessMapUv:ie&&m(a.sheenRoughnessMap.channel),specularMapUv:ne&&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&&(I||he),fog:!!y,useFog:!0===a.fog,fogExp2:y&&y.isFogExp2,flatShading:!0===a.flatShading,sizeAttenuation:!0===a.sizeAttenuation,logarithmicDepthBuffer:u,skinning:!0===v.isSkinnedMesh,morphTargets:void 0!==x.morphAttributes.position,morphNormals:void 0!==x.morphAttributes.normal,morphColors:void 0!==x.morphAttributes.color,morphTargetsCount: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===Sr,flipSided:a.side===Ji,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:c||n.has("EXT_frag_depth"),rendererExtensionDrawBuffers:c||n.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:c||n.has("EXT_shader_texture_lod"),customProgramCacheKey:a.customProgramCacheKey()}},getProgramCacheKey:function(t){let i=[];if(t.shaderID?i.push(t.shaderID):(i.push(t.customVertexShaderID),i.push(t.customFragmentShaderID)),void 0!==t.defines)for(let e in t.defines)i.push(e),i.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)}(i,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)}(i,t),i.push(e.outputColorSpace)),i.push(t.customProgramCacheKey),i.join()},getUniforms:function(e){let t,i=f[e.type];if(i){let e=yc[i];t=Ri.clone(e.uniforms)}else t=e.uniforms;return t},acquireProgram:function(t,i){let n;for(let e=0,r=h.length;e<r;e++){let t=h[e];if(t.cacheKey===i){n=t,++n.usedTimes;break}}return void 0===n&&(n=new nat(e,i,t,a),h.push(n)),n},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 sat(){let e=new WeakMap;return{get:function(t){let i=e.get(t);return void 0===i&&(i={},e.set(t,i)),i},remove:function(t){e.delete(t)},update:function(t,i,n){e.get(t)[i]=n},dispose:function(){e=new WeakMap}}}function aat(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 Dce(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 Oce(){let e=[],t=0,i=[],n=[],r=[];function a(i,n,r,a,s,o){let l=e[t];return void 0===l?(l={id:i.id,object:i,geometry:n,material:r,groupOrder:a,renderOrder:i.renderOrder,z:s,group:o},e[t]=l):(l.id=i.id,l.object=i,l.geometry=n,l.material=r,l.groupOrder=a,l.renderOrder=i.renderOrder,l.z=s,l.group=o),t++,l}return{opaque:i,transmissive:n,transparent:r,init:function(){t=0,i.length=0,n.length=0,r.length=0},push:function(e,t,s,o,l,h){let c=a(e,t,s,o,l,h);s.transmission>0?n.push(c):!0===s.transparent?r.push(c):i.push(c)},unshift:function(e,t,s,o,l,h){let c=a(e,t,s,o,l,h);s.transmission>0?n.unshift(c):!0===s.transparent?r.unshift(c):i.unshift(c)},finish:function(){for(let i=t,n=e.length;i<n;i++){let t=e[i];if(null===t.id)break;t.id=null,t.object=null,t.geometry=null,t.material=null,t.group=null}},sort:function(e,t){i.length>1&&i.sort(e||aat),n.length>1&&n.sort(t||Dce),r.length>1&&r.sort(t||Dce)}}}function oat(){let e=new WeakMap;return{get:function(t,i){let n,r=e.get(t);return void 0===r?(n=new Oce,e.set(t,[n])):i>=r.length?(n=new Oce,r.push(n)):n=r[i],n},dispose:function(){e=new WeakMap}}}function lat(){let e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];let i;switch(t.type){case"DirectionalLight":i={direction:new D,color:new ct};break;case"SpotLight":i={position:new D,direction:new D,color:new ct,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":i={position:new D,color:new ct,distance:0,decay:0};break;case"HemisphereLight":i={direction:new D,skyColor:new ct,groundColor:new ct};break;case"RectAreaLight":i={color:new ct,position:new D,halfWidth:new D,halfHeight:new D}}return e[t.id]=i,i}}}function cat(){let e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];let i;switch(t.type){case"DirectionalLight":case"SpotLight":i={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new xe};break;case"PointLight":i={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new xe,shadowCameraNear:1,shadowCameraFar:1e3}}return e[t.id]=i,i}}}var uat=0;function hat(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+(t.map?1:0)-(e.map?1:0)}function dat(e,t){let i=new lat,n=cat(),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 D);let a=new D,s=new et,o=new et;return{setup:function(a,s){let o=0,l=0,h=0;for(let e=0;e<9;e++)r.probe[e].set(0,0,0);let c=0,u=0,d=0,p=0,f=0,m=0,g=0,v=0,y=0,x=0;a.sort(hat);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=i.get(t);if(e.color.copy(t.color).multiplyScalar(t.intensity*b),t.castShadow){let e=t.shadow,i=n.get(t);i.shadowBias=e.bias,i.shadowNormalBias=e.normalBias,i.shadowRadius=e.radius,i.shadowMapSize=e.mapSize,r.directionalShadow[c]=i,r.directionalShadowMap[c]=S,r.directionalShadowMatrix[c]=t.shadow.matrix,m++}r.directional[c]=e,c++}else if(t.isSpotLight){let e=i.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=n.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=i.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=i.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,i=n.get(t);i.shadowBias=e.bias,i.shadowNormalBias=e.normalBias,i.shadowRadius=e.radius,i.shadowMapSize=e.mapSize,i.shadowCameraNear=e.camera.near,i.shadowCameraFar=e.camera.far,r.pointShadow[u]=i,r.pointShadowMap[u]=S,r.pointShadowMatrix[u]=t.shadow.matrix,g++}r.point[u]=e,u++}else if(t.isHemisphereLight){let e=i.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=Jt.LTC_FLOAT_1,r.rectAreaLTC2=Jt.LTC_FLOAT_2):!0===e.has("OES_texture_half_float_linear")?(r.rectAreaLTC1=Jt.LTC_HALF_1,r.rectAreaLTC2=Jt.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!==c||_.pointLength!==u||_.spotLength!==d||_.rectAreaLength!==p||_.hemiLength!==f||_.numDirectionalShadows!==m||_.numPointShadows!==g||_.numSpotShadows!==v||_.numSpotMaps!==y)&&(r.directional.length=c,r.spot.length=d,r.rectArea.length=p,r.point.length=u,r.hemi.length=f,r.directionalShadow.length=m,r.directionalShadowMap.length=m,r.pointShadow.length=g,r.pointShadowMap.length=g,r.spotShadow.length=v,r.spotShadowMap.length=v,r.directionalShadowMatrix.length=m,r.pointShadowMatrix.length=g,r.spotLightMatrix.length=v+y-x,r.spotLightMap.length=y,r.numSpotLightShadowsWithMaps=x,_.directionalLength=c,_.pointLength=u,_.spotLength=d,_.rectAreaLength=p,_.hemiLength=f,_.numDirectionalShadows=m,_.numPointShadows=g,_.numSpotShadows=v,_.numSpotMaps=y,r.version=uat++)},setupView:function(e,t){let i=0,n=0,l=0,h=0,c=0,u=t.matrixWorldInverse;for(let d=0,p=e.length;d<p;d++){let t=e[d];if(t.isDirectionalLight){let e=r.directional[i];e.direction.setFromMatrixPosition(t.matrixWorld),a.setFromMatrixPosition(t.target.matrixWorld),e.direction.sub(a),e.direction.transformDirection(u),i++}else if(t.isSpotLight){let e=r.spot[l];e.position.setFromMatrixPosition(t.matrixWorld),e.position.applyMatrix4(u),e.direction.setFromMatrixPosition(t.matrixWorld),a.setFromMatrixPosition(t.target.matrixWorld),e.direction.sub(a),e.direction.transformDirection(u),l++}else if(t.isRectAreaLight){let e=r.rectArea[h];e.position.setFromMatrixPosition(t.matrixWorld),e.position.applyMatrix4(u),o.identity(),s.copy(t.matrixWorld),s.premultiply(u),o.extractRotation(s),e.halfWidth.set(.5*t.width,0,0),e.halfHeight.set(0,.5*t.height,0),e.halfWidth.applyMatrix4(o),e.halfHeight.applyMatrix4(o),h++}else if(t.isPointLight){let e=r.point[n];e.position.setFromMatrixPosition(t.matrixWorld),e.position.applyMatrix4(u),n++}else if(t.isHemisphereLight){let e=r.hemi[c];e.direction.setFromMatrixPosition(t.matrixWorld),e.direction.transformDirection(u),c++}}},state:r}}function kce(e,t){let i=new dat(e,t),n=[],r=[];return{init:function(){n.length=0,r.length=0},state:{lightsArray:n,shadowsArray:r,lights:i},setupLights:function(e){i.setup(n,e)},setupLightsView:function(e){i.setupView(n,e)},pushLight:function(e){n.push(e)},pushShadow:function(e){r.push(e)}}}function fat(e,t){let i=new WeakMap;return{get:function(n,r=0){let a,s=i.get(n);return void 0===s?(a=new kce(e,t),i.set(n,[a])):r>=s.length?(a=new kce(e,t),s.push(a)):a=s[r],a},dispose:function(){i=new WeakMap}}}var _c=class extends yr{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}},_b=class extends yr{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}},pat="void main() {\n\tgl_Position = vec4( position, 1.0 );\n}",mat="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 gat(e,t,i){let n=new ma,r=new xe,a=new xe,s=new gr,o=new _c({depthPacking:Cv}),l=new _b,h={},c=i.maxTextureSize,u={[pi]:Ji,[Ji]:pi,[Sr]:Sr},d=new cn({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new xe},radius:{value:4}},vertexShader:pat,fragmentShader:mat}),p=d.clone();p.defines.HORIZONTAL_PASS=1;let f=new Dt;f.setAttribute("position",new mn(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let m=new xt(f,d),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=MU;let v=this.type;function y(i,n){let a=t.update(m);d.defines.VSM_SAMPLES!==i.blurSamples&&(d.defines.VSM_SAMPLES=i.blurSamples,p.defines.VSM_SAMPLES=i.blurSamples,d.needsUpdate=!0,p.needsUpdate=!0),null===i.mapPass&&(i.mapPass=new sr(r.x,r.y)),d.uniforms.shadow_pass.value=i.map.texture,d.uniforms.resolution.value=i.mapSize,d.uniforms.radius.value=i.radius,e.setRenderTarget(i.mapPass),e.clear(),e.renderBufferDirect(n,null,a,d,m,null),p.uniforms.shadow_pass.value=i.mapPass.texture,p.uniforms.resolution.value=i.mapSize,p.uniforms.radius.value=i.radius,e.setRenderTarget(i.map),e.clear(),e.renderBufferDirect(n,null,a,p,m,null)}function x(t,i,n,r){let a=null,s=!0===n.isPointLight?t.customDistanceMaterial:t.customDepthMaterial;if(void 0!==s)a=s;else if(a=!0===n.isPointLight?l:o,e.localClippingEnabled&&!0===i.clipShadows&&Array.isArray(i.clippingPlanes)&&0!==i.clippingPlanes.length||i.displacementMap&&0!==i.displacementScale||i.alphaMap&&i.alphaTest>0||i.map&&i.alphaTest>0){let e=a.uuid,t=i.uuid,n=h[e];void 0===n&&(n={},h[e]=n);let r=n[t];void 0===r&&(r=a.clone(),n[t]=r),a=r}return a.visible=i.visible,a.wireframe=i.wireframe,a.side=r===vu?null!==i.shadowSide?i.shadowSide:i.side:null!==i.shadowSide?i.shadowSide:u[i.side],a.alphaMap=i.alphaMap,a.alphaTest=i.alphaTest,a.map=i.map,a.clipShadows=i.clipShadows,a.clippingPlanes=i.clippingPlanes,a.clipIntersection=i.clipIntersection,a.displacementMap=i.displacementMap,a.displacementScale=i.displacementScale,a.displacementBias=i.displacementBias,a.wireframeLinewidth=i.wireframeLinewidth,a.linewidth=i.linewidth,!0===n.isPointLight&&!0===a.isMeshDistanceMaterial&&(e.properties.get(a).light=n),a}function b(i,r,a,s,o){if(!1===i.visible)return;if(i.layers.test(r.layers)&&(i.isMesh||i.isLine||i.isPoints)&&(i.castShadow||i.receiveShadow&&o===vu)&&(!i.frustumCulled||n.intersectsObject(i))){i.modelViewMatrix.multiplyMatrices(a.matrixWorldInverse,i.matrixWorld);let n=t.update(i),r=i.material;if(Array.isArray(r)){let t=n.groups;for(let l=0,h=t.length;l<h;l++){let h=t[l],c=r[h.materialIndex];if(c&&c.visible){let t=x(i,c,s,o);e.renderBufferDirect(a,null,n,t,i,h)}}}else if(r.visible){let t=x(i,r,s,o);e.renderBufferDirect(a,null,n,t,i,null)}}let l=i.children;for(let e=0,t=l.length;e<t;e++)b(l[e],r,a,s,o)}this.render=function(t,i,o){if(!1===g.enabled||!1===g.autoUpdate&&!1===g.needsUpdate||0===t.length)return;let l=e.getRenderTarget(),h=e.getActiveCubeFace(),u=e.getActiveMipmapLevel(),d=e.state;d.setBlending(Qr),d.buffers.color.setClear(1,1,1,1),d.buffers.depth.setTest(!0),d.setScissorTest(!1);let p=v!==vu&&this.type===vu,f=v===vu&&this.type!==vu;for(let m=0,g=t.length;m<g;m++){let l=t[m],h=l.shadow;if(void 0===h){console.warn("THREE.WebGLShadowMap:",l,"has no shadow.");continue}if(!1===h.autoUpdate&&!1===h.needsUpdate)continue;r.copy(h.mapSize);let u=h.getFrameExtents();if(r.multiply(u),a.copy(h.mapSize),(r.x>c||r.y>c)&&(r.x>c&&(a.x=Math.floor(c/u.x),r.x=a.x*u.x,h.mapSize.x=a.x),r.y>c&&(a.y=Math.floor(c/u.y),r.y=a.y*u.y,h.mapSize.y=a.y)),null===h.map||!0===p||!0===f){let e=this.type!==vu?{minFilter:Jr,magFilter:Jr}:{};null!==h.map&&h.map.dispose(),h.map=new sr(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),n=h.getFrustum(),b(i,o,h.camera,l,this.type)}!0!==h.isPointLightShadow&&this.type===vu&&y(h,o),h.needsUpdate=!1}v=this.type,g.needsUpdate=!1,e.setRenderTarget(l,h,u)}}function vat(e,t,i){let n=i.isWebGL2,r=new function(){let t=!1,i=new gr,n=null,r=new gr(0,0,0,0);return{setMask:function(i){n!==i&&!t&&(e.colorMask(i,i,i,i),n=i)},setLocked:function(e){t=e},setClear:function(t,n,a,s,o){!0===o&&(t*=s,n*=s,a*=s),i.set(t,n,a,s),!1===r.equals(i)&&(e.clearColor(t,n,a,s),r.copy(i))},reset:function(){t=!1,n=null,r.set(-1,0,0,0)}}},a=new function(){let t=!1,i=null,n=null,r=null;return{setTest:function(t){t?z(e.DEPTH_TEST):H(e.DEPTH_TEST)},setMask:function(n){i!==n&&!t&&(e.depthMask(n),i=n)},setFunc:function(t){if(n!==t){switch(t){case kue:e.depthFunc(e.NEVER);break;case Fue:e.depthFunc(e.ALWAYS);break;case Nue:e.depthFunc(e.LESS);break;case vR:e.depthFunc(e.LEQUAL);break;case Bue:e.depthFunc(e.EQUAL);break;case Uue:e.depthFunc(e.GEQUAL);break;case Hue:e.depthFunc(e.GREATER);break;case Vue:e.depthFunc(e.NOTEQUAL);break;default:e.depthFunc(e.LEQUAL)}n=t}},setLocked:function(e){t=e},setClear:function(t){r!==t&&(e.clearDepth(t),r=t)},reset:function(){t=!1,i=null,n=null,r=null}}},s=new function(){let t=!1,i=null,n=null,r=null,a=null,s=null,o=null,l=null,h=null;return{setTest:function(i){t||(i?z(e.STENCIL_TEST):H(e.STENCIL_TEST))},setMask:function(n){i!==n&&!t&&(e.stencilMask(n),i=n)},setFunc:function(t,i,s){(n!==t||r!==i||a!==s)&&(e.stencilFunc(t,i,s),n=t,r=i,a=s)},setOp:function(t,i,n){(s!==t||o!==i||l!==n)&&(e.stencilOp(t,i,n),s=t,o=i,l=n)},setLocked:function(e){t=e},setClear:function(t){h!==t&&(e.clearStencil(t),h=t)},reset:function(){t=!1,i=null,n=null,r=null,a=null,s=null,o=null,l=null,h=null}}},o=new WeakMap,l=new WeakMap,h={},c={},u=new WeakMap,d=[],p=null,f=!1,m=null,g=null,v=null,y=null,x=null,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,D=e.getParameter(e.VERSION);-1!==D.indexOf("WebGL")?(R=parseFloat(/^WebGL (\d)/.exec(D)[1]),P=R>=1):-1!==D.indexOf("OpenGL ES")&&(R=parseFloat(/^OpenGL ES (\d)/.exec(D)[1]),P=R>=2);let L=null,I={},O=e.getParameter(e.SCISSOR_BOX),k=e.getParameter(e.VIEWPORT),N=(new gr).fromArray(O),U=(new gr).fromArray(k);function F(t,i,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++)!n||t!==e.TEXTURE_3D&&t!==e.TEXTURE_2D_ARRAY?e.texImage2D(i+l,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,s):e.texImage3D(i,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),n&&(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(vR),W(!1),X($N),z(e.CULL_FACE),G(Qr);let V={[Go]:e.FUNC_ADD,[Rue]:e.FUNC_SUBTRACT,[Aue]:e.FUNC_REVERSE_SUBTRACT};if(n)V[JN]=e.MIN,V[QN]=e.MAX;else{let e=t.get("EXT_blend_minmax");null!==e&&(V[JN]=e.MIN_EXT,V[QN]=e.MAX_EXT)}let j={[vf]:e.ZERO,[Cue]:e.ONE,[Pue]:e.SRC_COLOR,[RU]:e.SRC_ALPHA,[Oue]:e.SRC_ALPHA_SATURATE,[Sv]:e.DST_COLOR,[wv]:e.DST_ALPHA,[Iue]:e.ONE_MINUS_SRC_COLOR,[AU]:e.ONE_MINUS_SRC_ALPHA,[Due]:e.ONE_MINUS_DST_COLOR,[Lue]:e.ONE_MINUS_DST_ALPHA};function G(t,i,n,r,a,s,o,l){if(t!==Qr){if(!1===f&&(z(e.BLEND),f=!0),t===Pm)a=a||i,s=s||n,o=o||r,(i!==g||a!==x)&&(e.blendEquationSeparate(V[i],V[a]),g=i,x=a),(n!==v||r!==y||s!==b||o!==_)&&(e.blendFuncSeparate(j[n],j[r],j[s],j[o]),v=n,y=r,b=s,_=o),m=t,w=!1;else if(t!==m||l!==w){if((g!==Go||x!==Go)&&(e.blendEquation(e.FUNC_ADD),g=Go,x=Go),l)switch(t){case mm:e.blendFuncSeparate(e.ONE,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case Ec:e.blendFunc(e.ONE,e.ONE);break;case ZN:e.blendFuncSeparate(e.ZERO,e.ONE_MINUS_SRC_COLOR,e.ZERO,e.ONE);break;case KN: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 mm:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case Ec: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 KN: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!==Sue?(z(e.CULL_FACE),t!==M&&(t===$N?e.cullFace(e.BACK):t===Mue?e.cullFace(e.FRONT):e.cullFace(e.FRONT_AND_BACK))):H(e.CULL_FACE),M=t}function Y(t,i,n){t?(z(e.POLYGON_OFFSET_FILL),(T!==i||A!==n)&&(e.polygonOffset(i,n),T=i,A=n)):H(e.POLYGON_OFFSET_FILL)}return{buffers:{color:r,depth:a,stencil:s},enable:z,disable:H,bindFramebuffer:function(t,i){return c[t]!==i&&(e.bindFramebuffer(t,i),c[t]=i,n&&(t===e.DRAW_FRAMEBUFFER&&(c[e.FRAMEBUFFER]=i),t===e.FRAMEBUFFER&&(c[e.DRAW_FRAMEBUFFER]=i)),!0)},drawBuffers:function(n,r){let a=d,s=!1;if(n)if(a=u.get(r),void 0===a&&(a=[],u.set(r,a)),n.isWebGLMultipleRenderTargets){let t=n.texture;if(a.length!==t.length||a[0]!==e.COLOR_ATTACHMENT0){for(let i=0,n=t.length;i<n;i++)a[i]=e.COLOR_ATTACHMENT0+i;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&&(i.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,i){t.side===Sr?H(e.CULL_FACE):z(e.CULL_FACE);let n=t.side===Ji;i&&(n=!n),W(n),t.blending===mm&&!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),L!==t&&(e.activeTexture(t),L=t)},bindTexture:function(t,i,n){void 0===n&&(n=null===L?e.TEXTURE0+C-1:L);let r=I[n];void 0===r&&(r={type:void 0,texture:void 0},I[n]=r),(r.type!==t||r.texture!==i)&&(L!==n&&(e.activeTexture(n),L=n),e.bindTexture(t,i||B[t]),r.type=t,r.texture=i)},unbindTexture:function(){let t=I[L];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,i){let n=l.get(i);void 0===n&&(n=new WeakMap,l.set(i,n));let r=n.get(t);void 0===r&&(r=e.getUniformBlockIndex(i,t.name),n.set(t,r))},uniformBlockBinding:function(t,i){let n=l.get(i).get(t);o.get(i)!==n&&(e.uniformBlockBinding(i,n,t.__bindingPointIndex),o.set(i,n))},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===n&&(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={},L=null,I={},c={},u=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 yat(e,t,i,n,r,a,s){let o,l=r.isWebGL2,h=r.maxTextures,c=r.maxCubemapSize,u=r.maxTextureSize,d=r.maxSamples,p=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,f="undefined"!=typeof navigator&&/OculusBrowser/g.test(navigator.userAgent),m=new WeakMap,g=new WeakMap,v=!1;try{v="undefined"!=typeof OffscreenCanvas&&null!==new OffscreenCanvas(1,1).getContext("2d")}catch(e){}function y(e,t){return v?new OffscreenCanvas(e,t):vb("canvas")}function x(e,t,i,n){let r=1;if((e.width>n||e.height>n)&&(r=n/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 n=t?xR:Math.floor,a=n(r*e.width),s=n(r*e.height);void 0===o&&(o=y(a,s));let l=i?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 wB(e.width)&&wB(e.height)}function _(e,t){return e.generateMipmaps&&t&&e.minFilter!==Jr&&e.minFilter!==Pr}function w(t){e.generateMipmap(t)}function S(i,n,r,a,s=!1){if(!1===l)return n;if(null!==i){if(void 0!==e[i])return e[i];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+i+"'")}let o=n;return n===e.RED&&(r===e.FLOAT&&(o=e.R32F),r===e.HALF_FLOAT&&(o=e.R16F),r===e.UNSIGNED_BYTE&&(o=e.R8)),n===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)),n===e.RG&&(r===e.FLOAT&&(o=e.RG32F),r===e.HALF_FLOAT&&(o=e.RG16F),r===e.UNSIGNED_BYTE&&(o=e.RG8)),n===e.RGBA&&(r===e.FLOAT&&(o=e.RGBA32F),r===e.HALF_FLOAT&&(o=e.RGBA16F),r===e.UNSIGNED_BYTE&&(o=a===en&&!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,i){return!0===_(e,i)||e.isFramebufferTexture&&e.minFilter!==Jr&&e.minFilter!==Pr?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===hf||t===zh?e.NEAREST:e.LINEAR}function T(e){let t=e.target;t.removeEventListener("dispose",T),function(e){let t=n.get(e);if(void 0===t.__webglInit)return;let i=e.source,r=g.get(i);if(r){let n=r[t.__cacheKey];n.usedTimes--,0===n.usedTimes&&C(e),0===Object.keys(r).length&&g.delete(i)}n.remove(e)}(t),t.isVideoTexture&&m.delete(t)}function A(t){let i=t.target;i.removeEventListener("dispose",A),function(t){let i=t.texture,r=n.get(t),a=n.get(i);if(void 0!==a.__webglTexture&&(e.deleteTexture(a.__webglTexture),s.memory.textures--),t.depthTexture&&t.depthTexture.dispose(),t.isWebGLCubeRenderTarget)for(let n=0;n<6;n++){if(Array.isArray(r.__webglFramebuffer[n]))for(let t=0;t<r.__webglFramebuffer[n].length;t++)e.deleteFramebuffer(r.__webglFramebuffer[n][t]);else e.deleteFramebuffer(r.__webglFramebuffer[n]);r.__webglDepthbuffer&&e.deleteRenderbuffer(r.__webglDepthbuffer[n])}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=i.length;o<l;o++){let t=n.get(i[o]);t.__webglTexture&&(e.deleteTexture(t.__webglTexture),s.memory.textures--),n.remove(i[o])}n.remove(i),n.remove(t)}(i)}function C(t){let i=n.get(t);e.deleteTexture(i.__webglTexture);let r=t.source;delete g.get(r)[i.__cacheKey],s.memory.textures--}let P=0;function R(t,r){let a=n.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")}}i.bindTexture(e.TEXTURE_2D,a.__webglTexture,e.TEXTURE0+r)}let D={[Di]:e.REPEAT,[Li]:e.CLAMP_TO_EDGE,[qh]:e.MIRRORED_REPEAT},L={[Jr]:e.NEAREST,[hf]:e.NEAREST_MIPMAP_NEAREST,[zh]:e.NEAREST_MIPMAP_LINEAR,[Pr]:e.LINEAR,[Im]:e.LINEAR_MIPMAP_NEAREST,[Fa]:e.LINEAR_MIPMAP_LINEAR},I={[lhe]:e.NEVER,[mhe]:e.ALWAYS,[che]:e.LESS,[hhe]:e.LEQUAL,[uhe]:e.EQUAL,[phe]:e.GEQUAL,[dhe]:e.GREATER,[fhe]:e.NOTEQUAL};function O(i,a,s){if(s?(e.texParameteri(i,e.TEXTURE_WRAP_S,D[a.wrapS]),e.texParameteri(i,e.TEXTURE_WRAP_T,D[a.wrapT]),(i===e.TEXTURE_3D||i===e.TEXTURE_2D_ARRAY)&&e.texParameteri(i,e.TEXTURE_WRAP_R,D[a.wrapR]),e.texParameteri(i,e.TEXTURE_MAG_FILTER,L[a.magFilter]),e.texParameteri(i,e.TEXTURE_MIN_FILTER,L[a.minFilter])):(e.texParameteri(i,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(i,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),(i===e.TEXTURE_3D||i===e.TEXTURE_2D_ARRAY)&&e.texParameteri(i,e.TEXTURE_WRAP_R,e.CLAMP_TO_EDGE),(a.wrapS!==Li||a.wrapT!==Li)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),e.texParameteri(i,e.TEXTURE_MAG_FILTER,E(a.magFilter)),e.texParameteri(i,e.TEXTURE_MIN_FILTER,E(a.minFilter)),a.minFilter!==Jr&&a.minFilter!==Pr&&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(i,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE),e.texParameteri(i,e.TEXTURE_COMPARE_FUNC,I[a.compareFunction])),!0===t.has("EXT_texture_filter_anisotropic")){let s=t.get("EXT_texture_filter_anisotropic");if(a.magFilter===Jr||a.minFilter!==zh&&a.minFilter!==Fa||a.type===fa&&!1===t.has("OES_texture_float_linear")||!1===l&&a.type===Mr&&!1===t.has("OES_texture_half_float_linear"))return;(a.anisotropy>1||n.get(a).__currentAnisotropy)&&(e.texParameterf(i,s.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(a.anisotropy,r.getMaxAnisotropy())),n.get(a).__currentAnisotropy=a.anisotropy)}}function k(t,i){let n=!1;void 0===t.__webglInit&&(t.__webglInit=!0,i.addEventListener("dispose",T));let r=i.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()}(i);if(o!==t.__cacheKey){void 0===a[o]&&(a[o]={texture:e.createTexture(),usedTimes:0},s.memory.textures++,n=!0),a[o].usedTimes++;let r=a[t.__cacheKey];void 0!==r&&(a[t.__cacheKey].usedTimes--,0===r.usedTimes&&C(i)),t.__cacheKey=o,t.__webglTexture=a[o].texture}return n}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=k(t,r),c=r.source;i.bindTexture(o,t.__webglTexture,e.TEXTURE0+s);let d=n.get(c);if(c.version!==d.__version||!0===h){i.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!==Li||e.wrapT!==Li||e.minFilter!==Jr&&e.minFilter!==Pr)}(r)&&!1===b(r.image),n=x(r.image,t,!1,u);n=V(r,n);let p=b(n)||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,n,p);if(r.isDepthTexture)g=e.DEPTH_COMPONENT,l?g=r.type===fa?e.DEPTH_COMPONENT32F:r.type===Hh?e.DEPTH_COMPONENT24:r.type===xu?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT16:r.type===fa&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),r.format===cf&&g===e.DEPTH_COMPONENT&&r.type!==Rv&&r.type!==Hh&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),r.type=Hh,m=a.convert(r.type)),r.format===Wh&&g===e.DEPTH_COMPONENT&&(g=e.DEPTH_STENCIL,r.type!==xu&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),r.type=xu,m=a.convert(r.type))),T&&(E?i.texStorage2D(e.TEXTURE_2D,1,g,n.width,n.height):i.texImage2D(e.TEXTURE_2D,0,g,n.width,n.height,0,f,m,null));else if(r.isDataTexture)if(y.length>0&&p){E&&T&&i.texStorage2D(e.TEXTURE_2D,A,g,y[0].width,y[0].height);for(let t=0,n=y.length;t<n;t++)v=y[t],E?i.texSubImage2D(e.TEXTURE_2D,t,0,0,v.width,v.height,f,m,v.data):i.texImage2D(e.TEXTURE_2D,t,g,v.width,v.height,0,f,m,v.data);r.generateMipmaps=!1}else E?(T&&i.texStorage2D(e.TEXTURE_2D,A,g,n.width,n.height),i.texSubImage2D(e.TEXTURE_2D,0,0,0,n.width,n.height,f,m,n.data)):i.texImage2D(e.TEXTURE_2D,0,g,n.width,n.height,0,f,m,n.data);else if(r.isCompressedTexture)if(r.isCompressedArrayTexture){E&&T&&i.texStorage3D(e.TEXTURE_2D_ARRAY,A,g,y[0].width,y[0].height,n.depth);for(let t=0,a=y.length;t<a;t++)v=y[t],r.format!==Js?null!==f?E?i.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,t,0,0,0,v.width,v.height,n.depth,f,v.data,0,0):i.compressedTexImage3D(e.TEXTURE_2D_ARRAY,t,g,v.width,v.height,n.depth,0,v.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):E?i.texSubImage3D(e.TEXTURE_2D_ARRAY,t,0,0,0,v.width,v.height,n.depth,f,m,v.data):i.texImage3D(e.TEXTURE_2D_ARRAY,t,g,v.width,v.height,n.depth,0,f,m,v.data)}else{E&&T&&i.texStorage2D(e.TEXTURE_2D,A,g,y[0].width,y[0].height);for(let t=0,n=y.length;t<n;t++)v=y[t],r.format!==Js?null!==f?E?i.compressedTexSubImage2D(e.TEXTURE_2D,t,0,0,v.width,v.height,f,v.data):i.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?i.texSubImage2D(e.TEXTURE_2D,t,0,0,v.width,v.height,f,m,v.data):i.texImage2D(e.TEXTURE_2D,t,g,v.width,v.height,0,f,m,v.data)}else if(r.isDataArrayTexture)E?(T&&i.texStorage3D(e.TEXTURE_2D_ARRAY,A,g,n.width,n.height,n.depth),i.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,0,n.width,n.height,n.depth,f,m,n.data)):i.texImage3D(e.TEXTURE_2D_ARRAY,0,g,n.width,n.height,n.depth,0,f,m,n.data);else if(r.isData3DTexture)E?(T&&i.texStorage3D(e.TEXTURE_3D,A,g,n.width,n.height,n.depth),i.texSubImage3D(e.TEXTURE_3D,0,0,0,0,n.width,n.height,n.depth,f,m,n.data)):i.texImage3D(e.TEXTURE_3D,0,g,n.width,n.height,n.depth,0,f,m,n.data);else if(r.isFramebufferTexture){if(T)if(E)i.texStorage2D(e.TEXTURE_2D,A,g,n.width,n.height);else{let t=n.width,r=n.height;for(let n=0;n<A;n++)i.texImage2D(e.TEXTURE_2D,n,g,t,r,0,f,m,null),t>>=1,r>>=1}}else if(y.length>0&&p){E&&T&&i.texStorage2D(e.TEXTURE_2D,A,g,y[0].width,y[0].height);for(let t=0,n=y.length;t<n;t++)v=y[t],E?i.texSubImage2D(e.TEXTURE_2D,t,0,0,f,m,v):i.texImage2D(e.TEXTURE_2D,t,g,f,m,v);r.generateMipmaps=!1}else E?(T&&i.texStorage2D(e.TEXTURE_2D,A,g,n.width,n.height),i.texSubImage2D(e.TEXTURE_2D,0,0,0,f,m,n)):i.texImage2D(e.TEXTURE_2D,0,g,f,m,n);_(r,p)&&w(o),d.__version=c.version,r.onUpdate&&r.onUpdate(r)}t.__version=r.version}function U(t,r,s,o,l,h){let c=a.convert(s.format,s.colorSpace),u=a.convert(s.type),d=S(s.internalFormat,c,u,s.colorSpace);if(!n.get(r).__hasExternalTextures){let t=Math.max(1,r.width>>h),n=Math.max(1,r.height>>h);l===e.TEXTURE_3D||l===e.TEXTURE_2D_ARRAY?i.texImage3D(l,h,d,t,n,r.depth,0,c,u,null):i.texImage2D(l,h,d,t,n,0,c,u,null)}i.bindFramebuffer(e.FRAMEBUFFER,t),H(r)?p.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,o,l,n.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,n.get(s).__webglTexture,h),i.bindFramebuffer(e.FRAMEBUFFER,null)}function F(t,i,n){if(e.bindRenderbuffer(e.RENDERBUFFER,t),i.depthBuffer&&!i.stencilBuffer){let r=e.DEPTH_COMPONENT16;if(n||H(i)){let t=i.depthTexture;t&&t.isDepthTexture&&(t.type===fa?r=e.DEPTH_COMPONENT32F:t.type===Hh&&(r=e.DEPTH_COMPONENT24));let n=z(i);H(i)?p.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,n,r,i.width,i.height):e.renderbufferStorageMultisample(e.RENDERBUFFER,n,r,i.width,i.height)}else e.renderbufferStorage(e.RENDERBUFFER,r,i.width,i.height);e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.RENDERBUFFER,t)}else if(i.depthBuffer&&i.stencilBuffer){let r=z(i);n&&!1===H(i)?e.renderbufferStorageMultisample(e.RENDERBUFFER,r,e.DEPTH24_STENCIL8,i.width,i.height):H(i)?p.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,r,e.DEPTH24_STENCIL8,i.width,i.height):e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_STENCIL,i.width,i.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.RENDERBUFFER,t)}else{let t=!0===i.isWebGLMultipleRenderTargets?i.texture:[i.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),c=z(i);n&&!1===H(i)?e.renderbufferStorageMultisample(e.RENDERBUFFER,c,h,i.width,i.height):H(i)?p.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,c,h,i.width,i.height):e.renderbufferStorage(e.RENDERBUFFER,h,i.width,i.height)}}e.bindRenderbuffer(e.RENDERBUFFER,null)}function B(t){let r=n.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(i.bindFramebuffer(e.FRAMEBUFFER,t),!r.depthTexture||!r.depthTexture.isDepthTexture)throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!n.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=n.get(r.depthTexture).__webglTexture,s=z(r);if(r.depthTexture.format===cf)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!==Wh)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 n=0;n<6;n++)i.bindFramebuffer(e.FRAMEBUFFER,r.__webglFramebuffer[n]),r.__webglDepthbuffer[n]=e.createRenderbuffer(),F(r.__webglDepthbuffer[n],t,!1)}else i.bindFramebuffer(e.FRAMEBUFFER,r.__webglFramebuffer),r.__webglDepthbuffer=e.createRenderbuffer(),F(r.__webglDepthbuffer,t,!1);i.bindFramebuffer(e.FRAMEBUFFER,null)}function z(e){return Math.min(d,e.samples)}function H(e){let i=n.get(e);return l&&e.samples>0&&!0===t.has("WEBGL_multisampled_render_to_texture")&&!1!==i.__useRenderToTexture}function V(e,i){let n=e.colorSpace,r=e.format,a=e.type;return!0===e.isCompressedTexture||e.format===yR||n!==Na&&n!==Eu&&(n===en?!1===l?!0===t.has("EXT_sRGB")&&r===Js?(e.format=yR,e.minFilter=Pr,e.generateMipmaps=!1):i=yb.sRGBToLinear(i):(r!==Js||a!==bc)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",n)),i}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=n.get(t);t.version>0&&a.__version!==t.version?N(a,t,r):i.bindTexture(e.TEXTURE_2D_ARRAY,a.__webglTexture,e.TEXTURE0+r)},this.setTexture3D=function(t,r){let a=n.get(t);t.version>0&&a.__version!==t.version?N(a,t,r):i.bindTexture(e.TEXTURE_3D,a.__webglTexture,e.TEXTURE0+r)},this.setTextureCube=function(t,r){let s=n.get(t);t.version>0&&s.__version!==t.version?function(t,r,s){if(6!==r.image.length)return;let o=k(t,r),h=r.source;i.bindTexture(e.TEXTURE_CUBE_MAP,t.__webglTexture,e.TEXTURE0+s);let u=n.get(h);if(h.version!==u.__version||!0===o){i.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,n=r.image[0]&&r.image[0].isDataTexture,d=[];for(let e=0;e<6;e++)d[e]=t||n?n?r.image[e].image:r.image[e]:x(r.image[e],!1,!0,c),d[e]=V(r,d[e]);let p,f=d[0],m=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===u.__version||!0===o,A=M(r,f,m);if(O(e.TEXTURE_CUBE_MAP,r,m),t){E&&T&&i.texStorage2D(e.TEXTURE_CUBE_MAP,A,y,f.width,f.height);for(let t=0;t<6;t++){p=d[t].mipmaps;for(let n=0;n<p.length;n++){let a=p[n];r.format!==Js?null!==g?E?i.compressedTexSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,n,0,0,a.width,a.height,g,a.data):i.compressedTexImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,n,y,a.width,a.height,0,a.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):E?i.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,n,0,0,a.width,a.height,g,v,a.data):i.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,n,y,a.width,a.height,0,g,v,a.data)}}}else{p=r.mipmaps,E&&T&&(p.length>0&&A++,i.texStorage2D(e.TEXTURE_CUBE_MAP,A,y,d[0].width,d[0].height));for(let t=0;t<6;t++)if(n){E?i.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,0,0,d[t].width,d[t].height,g,v,d[t].data):i.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,y,d[t].width,d[t].height,0,g,v,d[t].data);for(let n=0;n<p.length;n++){let r=p[n].image[t].image;E?i.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,n+1,0,0,r.width,r.height,g,v,r.data):i.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,n+1,y,r.width,r.height,0,g,v,r.data)}}else{E?i.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,0,0,g,v,d[t]):i.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,y,g,v,d[t]);for(let n=0;n<p.length;n++){let r=p[n];E?i.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,n+1,0,0,g,v,r.image[t]):i.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,n+1,y,g,v,r.image[t])}}}_(r,m)&&w(e.TEXTURE_CUBE_MAP),u.__version=h.version,r.onUpdate&&r.onUpdate(r)}t.__version=r.version}(s,t,r):i.bindTexture(e.TEXTURE_CUBE_MAP,s.__webglTexture,e.TEXTURE0+r)},this.rebindTextures=function(t,i,r){let a=n.get(t);void 0!==i&&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=n.get(t),c=n.get(o);t.addEventListener("dispose",A),!0!==t.isWebGLMultipleRenderTargets&&(void 0===c.__webglTexture&&(c.__webglTexture=e.createTexture()),c.__version=o.version,s.memory.textures++);let u=!0===t.isWebGLCubeRenderTarget,d=!0===t.isWebGLMultipleRenderTargets,p=b(t)||l;if(u){h.__webglFramebuffer=[];for(let t=0;t<6;t++)if(l&&o.mipmaps&&o.mipmaps.length>0){h.__webglFramebuffer[t]=[];for(let i=0;i<o.mipmaps.length;i++)h.__webglFramebuffer[t][i]=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 i=t.texture;for(let t=0,r=i.length;t<r;t++){let r=n.get(i[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 n=d?o:[o];h.__webglMultisampledFramebuffer=e.createFramebuffer(),h.__webglColorRenderbuffer=[],i.bindFramebuffer(e.FRAMEBUFFER,h.__webglMultisampledFramebuffer);for(let i=0;i<n.length;i++){let r=n[i];h.__webglColorRenderbuffer[i]=e.createRenderbuffer(),e.bindRenderbuffer(e.RENDERBUFFER,h.__webglColorRenderbuffer[i]);let s=a.convert(r.format,r.colorSpace),o=a.convert(r.type),l=S(r.internalFormat,s,o,r.colorSpace,!0===t.isXRRenderTarget),c=z(t);e.renderbufferStorageMultisample(e.RENDERBUFFER,c,l,t.width,t.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+i,e.RENDERBUFFER,h.__webglColorRenderbuffer[i])}e.bindRenderbuffer(e.RENDERBUFFER,null),t.depthBuffer&&(h.__webglDepthRenderbuffer=e.createRenderbuffer(),F(h.__webglDepthRenderbuffer,t,!0)),i.bindFramebuffer(e.FRAMEBUFFER,null)}}if(u){i.bindTexture(e.TEXTURE_CUBE_MAP,c.__webglTexture),O(e.TEXTURE_CUBE_MAP,o,p);for(let i=0;i<6;i++)if(l&&o.mipmaps&&o.mipmaps.length>0)for(let n=0;n<o.mipmaps.length;n++)U(h.__webglFramebuffer[i][n],t,o,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+i,n);else U(h.__webglFramebuffer[i],t,o,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+i,0);_(o,p)&&w(e.TEXTURE_CUBE_MAP),i.unbindTexture()}else if(d){let r=t.texture;for(let a=0,s=r.length;a<s;a++){let s=r[a],o=n.get(s);i.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)}i.unbindTexture()}else{let n=e.TEXTURE_2D;if((t.isWebGL3DRenderTarget||t.isWebGLArrayRenderTarget)&&(l?n=t.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),i.bindTexture(n,c.__webglTexture),O(n,o,p),l&&o.mipmaps&&o.mipmaps.length>0)for(let i=0;i<o.mipmaps.length;i++)U(h.__webglFramebuffer[i],t,o,e.COLOR_ATTACHMENT0,n,i);else U(h.__webglFramebuffer,t,o,e.COLOR_ATTACHMENT0,n,0);_(o,p)&&w(n),i.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=n.get(o).__webglTexture;i.bindTexture(r,a),w(r),i.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,c=n.get(t),u=!0===t.isWebGLMultipleRenderTargets;if(u)for(let t=0;t<r.length;t++)i.bindFramebuffer(e.FRAMEBUFFER,c.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.RENDERBUFFER,null),i.bindFramebuffer(e.FRAMEBUFFER,c.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.TEXTURE_2D,null,0);i.bindFramebuffer(e.READ_FRAMEBUFFER,c.__webglMultisampledFramebuffer),i.bindFramebuffer(e.DRAW_FRAMEBUFFER,c.__webglFramebuffer);for(let i=0;i<r.length;i++){l.push(e.COLOR_ATTACHMENT0+i),t.depthBuffer&&l.push(h);let d=void 0!==c.__ignoreDepthValues&&c.__ignoreDepthValues;if(!1===d&&(t.depthBuffer&&(o|=e.DEPTH_BUFFER_BIT),t.stencilBuffer&&(o|=e.STENCIL_BUFFER_BIT)),u&&e.framebufferRenderbuffer(e.READ_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.RENDERBUFFER,c.__webglColorRenderbuffer[i]),!0===d&&(e.invalidateFramebuffer(e.READ_FRAMEBUFFER,[h]),e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,[h])),u){let t=n.get(r[i]).__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(i.bindFramebuffer(e.READ_FRAMEBUFFER,null),i.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),u)for(let t=0;t<r.length;t++){i.bindFramebuffer(e.FRAMEBUFFER,c.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.RENDERBUFFER,c.__webglColorRenderbuffer[t]);let a=n.get(r[t]).__webglTexture;i.bindFramebuffer(e.FRAMEBUFFER,c.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.TEXTURE_2D,a,0)}i.bindFramebuffer(e.DRAW_FRAMEBUFFER,c.__webglMultisampledFramebuffer)}},this.setupDepthRenderbuffer=B,this.setupFrameBufferTexture=U,this.useMultisampledRTT=H}function She(e,t,i){let n=i.isWebGL2;return{convert:function(i,r=Eu){let a;if(i===bc)return e.UNSIGNED_BYTE;if(i===PU)return e.UNSIGNED_SHORT_4_4_4_4;if(i===IU)return e.UNSIGNED_SHORT_5_5_5_1;if(i===$ue)return e.BYTE;if(i===Zue)return e.SHORT;if(i===Rv)return e.UNSIGNED_SHORT;if(i===CU)return e.INT;if(i===Hh)return e.UNSIGNED_INT;if(i===fa)return e.FLOAT;if(i===Mr)return n?e.HALF_FLOAT:(a=t.get("OES_texture_half_float"),null!==a?a.HALF_FLOAT_OES:null);if(i===Kue)return e.ALPHA;if(i===Js)return e.RGBA;if(i===$R)return e.LUMINANCE;if(i===Jue)return e.LUMINANCE_ALPHA;if(i===cf)return e.DEPTH_COMPONENT;if(i===Wh)return e.DEPTH_STENCIL;if(i===yR)return a=t.get("EXT_sRGB"),null!==a?a.SRGB_ALPHA_EXT:null;if(i===ZR)return e.RED;if(i===LU)return e.RED_INTEGER;if(i===Que)return e.RG;if(i===DU)return e.RG_INTEGER;if(i===OU)return e.RGBA_INTEGER;if(i===uR||i===hR||i===dR||i===fR)if(r===en){if(a=t.get("WEBGL_compressed_texture_s3tc_srgb"),null===a)return null;if(i===uR)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===hR)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===dR)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===fR)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else{if(a=t.get("WEBGL_compressed_texture_s3tc"),null===a)return null;if(i===uR)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===hR)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===dR)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===fR)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(i===eB||i===tB||i===nB||i===rB){if(a=t.get("WEBGL_compressed_texture_pvrtc"),null===a)return null;if(i===eB)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===tB)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===nB)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===rB)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(i===ehe)return a=t.get("WEBGL_compressed_texture_etc1"),null!==a?a.COMPRESSED_RGB_ETC1_WEBGL:null;if(i===iB||i===sB){if(a=t.get("WEBGL_compressed_texture_etc"),null===a)return null;if(i===iB)return r===en?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(i===sB)return r===en?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC}if(i===aB||i===oB||i===lB||i===cB||i===uB||i===hB||i===dB||i===fB||i===pB||i===mB||i===gB||i===vB||i===yB||i===xB){if(a=t.get("WEBGL_compressed_texture_astc"),null===a)return null;if(i===aB)return r===en?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===oB)return r===en?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===lB)return r===en?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===cB)return r===en?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===uB)return r===en?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===hB)return r===en?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===dB)return r===en?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===fB)return r===en?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===pB)return r===en?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===mB)return r===en?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===gB)return r===en?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===vB)return r===en?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===yB)return r===en?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===xB)return r===en?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}if(i===pR){if(a=t.get("EXT_texture_compression_bptc"),null===a)return null;if(i===pR)return r===en?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT}if(i===the||i===bB||i===EB||i===_B){if(a=t.get("EXT_texture_compression_rgtc"),null===a)return null;if(i===pR)return a.COMPRESSED_RED_RGTC1_EXT;if(i===bB)return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===EB)return a.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===_B)return a.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}return i===xu?n?e.UNSIGNED_INT_24_8:(a=t.get("WEBGL_depth_texture"),null!==a?a.UNSIGNED_INT_24_8_WEBGL:null):void 0!==e[i]?e[i]:null}}}var TR=class extends hr{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}},er=class extends on{constructor(){super(),this.isGroup=!0,this.type="Group"}},xat={type:"move"},ub=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return null===this._hand&&(this._hand=new er,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 er,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new D,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new D),this._targetRay}getGripSpace(){return null===this._grip&&(this._grip=new er,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new D,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new D),this._grip}dispatchEvent(e){return 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 i of e.hand.values())this._getHandJoint(t,i)}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,i){let n=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,i),n=this._getHandJoint(l,a);null!==e&&(n.matrix.fromArray(e.transform.matrix),n.matrix.decompose(n.position,n.rotation,n.scale),n.matrixWorldNeedsUpdate=!0,n.jointRadius=e.radius),n.visible=null!==e}let n=l.joints["index-finger-tip"],r=l.joints["thumb-tip"],s=n.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,i),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&&(n=t.getPose(e.targetRaySpace,i),null===n&&null!==r&&(n=r),null!==n&&(s.matrix.fromArray(n.transform.matrix),s.matrix.decompose(s.position,s.rotation,s.scale),s.matrixWorldNeedsUpdate=!0,n.linearVelocity?(s.hasLinearVelocity=!0,s.linearVelocity.copy(n.linearVelocity)):s.hasLinearVelocity=!1,n.angularVelocity?(s.hasAngularVelocity=!0,s.angularVelocity.copy(n.angularVelocity)):s.hasAngularVelocity=!1,this.dispatchEvent(xat)))}return null!==s&&(s.visible=null!==n),null!==o&&(o.visible=null!==r),null!==l&&(l.visible=null!==a),this}_getHandJoint(e,t){if(void 0===e.joints[t.jointName]){let i=new er;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}},ff=class extends Gr{constructor(e,t,i,n,r,a,s,o,l,h){if((h=void 0!==h?h:cf)!==cf&&h!==Wh)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===i&&h===cf&&(i=Hh),void 0===i&&h===Wh&&(i=xu),super(null,n,r,a,s,o,h,i,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}},HB=class extends Wo{constructor(e,t){super();let i=this,n=null,r=1,a=null,s="local-floor",o=1,l=null,h=null,c=null,u=null,d=null,p=null,f=t.getContextAttributes(),m=null,g=null,v=[],y=[],x=new hr;x.layers.enable(1),x.viewport=new gr;let b=new hr;b.layers.enable(2),b.viewport=new gr;let _=[x,b],w=new TR;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 i=v[t];void 0!==i&&(i.update(e.inputSource,e.frame,l||a),i.dispatchEvent({type:e.type,data:e.inputSource}))}function T(){n.removeEventListener("select",E),n.removeEventListener("selectstart",E),n.removeEventListener("selectend",E),n.removeEventListener("squeeze",E),n.removeEventListener("squeezestart",E),n.removeEventListener("squeezeend",E),n.removeEventListener("end",T),n.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,u=null,c=null,n=null,g=null,I.stop(),i.isPresenting=!1,i.dispatchEvent({type:"sessionend"})}function A(e){for(let t=0;t<e.removed.length;t++){let i=e.removed[t],n=y.indexOf(i);n>=0&&(y[n]=null,v[n].disconnect(i))}for(let t=0;t<e.added.length;t++){let i=e.added[t],n=y.indexOf(i);if(-1===n){for(let e=0;e<v.length;e++){if(e>=y.length){y.push(i),n=e;break}if(null===y[e]){y[e]=i,n=e;break}}if(-1===n)break}let r=v[n];r&&r.connect(i)}}this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(e){let t=v[e];return void 0===t&&(t=new ub,v[e]=t),t.getTargetRaySpace()},this.getControllerGrip=function(e){let t=v[e];return void 0===t&&(t=new ub,v[e]=t),t.getGripSpace()},this.getHand=function(e){let t=v[e];return void 0===t&&(t=new ub,v[e]=t),t.getHandSpace()},this.setFramebufferScaleFactor=function(e){r=e,!0===i.isPresenting&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(e){s=e,!0===i.isPresenting&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||a},this.setReferenceSpace=function(e){l=e},this.getBaseLayer=function(){return null!==u?u:d},this.getBinding=function(){return c},this.getFrame=function(){return p},this.getSession=function(){return n},this.setSession=function(h){return ft(this,null,(function*(){if(n=h,null!==n){if(m=e.getRenderTarget(),n.addEventListener("select",E),n.addEventListener("selectstart",E),n.addEventListener("selectend",E),n.addEventListener("squeeze",E),n.addEventListener("squeezestart",E),n.addEventListener("squeezeend",E),n.addEventListener("end",T),n.addEventListener("inputsourceschange",A),!0!==f.xrCompatible&&(yield t.makeXRCompatible()),void 0===n.renderState.layers||!1===e.capabilities.isWebGL2){let i={antialias:void 0!==n.renderState.layers||f.antialias,alpha:!0,depth:f.depth,stencil:f.stencil,framebufferScaleFactor:r};d=new XRWebGLLayer(n,t,i),n.updateRenderState({baseLayer:d}),g=new sr(d.framebufferWidth,d.framebufferHeight,{format:Js,type:bc,colorSpace:e.outputColorSpace,stencilBuffer:f.stencil})}else{let i=null,a=null,s=null;f.depth&&(s=f.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,i=f.stencil?Wh:cf,a=f.stencil?xu:Hh);let o={colorFormat:t.RGBA8,depthFormat:s,scaleFactor:r};c=new XRWebGLBinding(n,t),u=c.createProjectionLayer(o),n.updateRenderState({layers:[u]}),g=new sr(u.textureWidth,u.textureHeight,{format:Js,type:bc,depthTexture:new ff(u.textureWidth,u.textureHeight,a,void 0,void 0,void 0,void 0,void 0,void 0,i),stencilBuffer:f.stencil,colorSpace:e.outputColorSpace,samples:f.antialias?4:0}),e.properties.get(g).__ignoreDepthValues=u.ignoreDepthValues}g.isXRRenderTarget=!0,this.setFoveation(o),l=null,a=yield n.requestReferenceSpace(s),I.setContext(n),I.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}}))},this.getEnvironmentBlendMode=function(){if(null!==n)return n.environmentBlendMode};let C=new D,P=new D;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===n)return;w.near=b.near=x.near=e.near,w.far=b.far=x.far=e.far,(S!==w.near||M!==w.far)&&(n.updateRenderState({depthNear:w.near,depthFar:w.far}),S=w.near,M=w.far);let t=e.parent,i=w.cameras;R(w,t);for(let n=0;n<i.length;n++)R(i[n],t);2===i.length?function(e,t,i){C.setFromMatrixPosition(t.matrixWorld),P.setFromMatrixPosition(i.matrixWorld);let n=C.distanceTo(P),r=t.projectionMatrix.elements,a=i.projectionMatrix.elements,s=r[14]/(r[10]-1),o=r[14]/(r[10]+1),l=(r[9]+1)/r[5],h=(r[9]-1)/r[5],c=(r[8]-1)/r[0],u=(a[8]+1)/a[0],d=s*c,p=s*u,f=n/(-c+u),m=f*-c;t.matrixWorld.decompose(e.position,e.quaternion,e.scale),e.translateX(m),e.translateZ(f),e.matrixWorld.compose(e.position,e.quaternion,e.scale),e.matrixWorldInverse.copy(e.matrixWorld).invert();let g=s+f,v=o+f,y=d-m,x=p+(n-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,i){null===i?e.matrix.copy(t.matrixWorld):(e.matrix.copy(i.matrixWorld),e.matrix.invert(),e.matrix.multiply(t.matrixWorld)),e.matrix.decompose(e.position,e.quaternion,e.scale),e.updateMatrixWorld(!0);let n=e.children;for(let r=0,a=n.length;r<a;r++)n[r].updateMatrixWorld(!0);e.projectionMatrix.copy(t.projectionMatrix),e.projectionMatrixInverse.copy(t.projectionMatrixInverse),e.isPerspectiveCamera&&(e.fov=2*av*Math.atan(1/e.projectionMatrix.elements[5]),e.zoom=1)}(e,w,t)},this.getCamera=function(){return w},this.getFoveation=function(){if(null!==u||null!==d)return o},this.setFoveation=function(e){o=e,null!==u&&(u.fixedFoveation=e),null!==d&&void 0!==d.fixedFoveation&&(d.fixedFoveation=e)};let L=null,I=new bhe;I.setAnimationLoop((function(t,n){if(h=n.getViewerPose(l||a),p=n,null!==h){let t=h.views;null!==d&&(e.setRenderTargetFramebuffer(g,d.framebuffer),e.setRenderTarget(g));let i=!1;t.length!==w.cameras.length&&(w.cameras.length=0,i=!0);for(let n=0;n<t.length;n++){let r=t[n],a=null;if(null!==d)a=d.getViewport(r);else{let t=c.getViewSubImage(u,r);a=t.viewport,0===n&&(e.setRenderTargetTextures(g,t.colorTexture,u.ignoreDepthValues?void 0:t.depthStencilTexture),e.setRenderTarget(g))}let s=_[n];void 0===s&&(s=new hr,s.layers.enable(n),s.viewport=new gr,_[n]=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===n&&(w.matrix.copy(s.matrix),w.matrix.decompose(w.position,w.quaternion,w.scale)),!0===i&&w.cameras.push(s)}}for(let e=0;e<v.length;e++){let t=y[e],i=v[e];null!==t&&void 0!==i&&i.update(t,n,l||a)}L&&L(t,n),n.detectedPlanes&&i.dispatchEvent({type:"planesdetected",data:n}),p=null})),this.setAnimationLoop=function(e){L=e},this.dispose=function(){}}};function bat(e,t){function i(e,t){!0===e.matrixAutoUpdate&&e.updateMatrix(),t.value.copy(e.matrix)}function n(n,r){n.opacity.value=r.opacity,r.color&&n.diffuse.value.copy(r.color),r.emissive&&n.emissive.value.copy(r.emissive).multiplyScalar(r.emissiveIntensity),r.map&&(n.map.value=r.map,i(r.map,n.mapTransform)),r.alphaMap&&(n.alphaMap.value=r.alphaMap,i(r.alphaMap,n.alphaMapTransform)),r.bumpMap&&(n.bumpMap.value=r.bumpMap,i(r.bumpMap,n.bumpMapTransform),n.bumpScale.value=r.bumpScale,r.side===Ji&&(n.bumpScale.value*=-1)),r.normalMap&&(n.normalMap.value=r.normalMap,i(r.normalMap,n.normalMapTransform),n.normalScale.value.copy(r.normalScale),r.side===Ji&&n.normalScale.value.negate()),r.displacementMap&&(n.displacementMap.value=r.displacementMap,i(r.displacementMap,n.displacementMapTransform),n.displacementScale.value=r.displacementScale,n.displacementBias.value=r.displacementBias),r.emissiveMap&&(n.emissiveMap.value=r.emissiveMap,i(r.emissiveMap,n.emissiveMapTransform)),r.specularMap&&(n.specularMap.value=r.specularMap,i(r.specularMap,n.specularMapTransform)),r.alphaTest>0&&(n.alphaTest.value=r.alphaTest);let a=t.get(r).envMap;if(a&&(n.envMap.value=a,n.flipEnvMap.value=a.isCubeTexture&&!1===a.isRenderTargetTexture?-1:1,n.reflectivity.value=r.reflectivity,n.ior.value=r.ior,n.refractionRatio.value=r.refractionRatio),r.lightMap){n.lightMap.value=r.lightMap;let t=!0===e._useLegacyLights?Math.PI:1;n.lightMapIntensity.value=r.lightMapIntensity*t,i(r.lightMap,n.lightMapTransform)}r.aoMap&&(n.aoMap.value=r.aoMap,n.aoMapIntensity.value=r.aoMapIntensity,i(r.aoMap,n.aoMapTransform))}return{refreshFogUniforms:function(t,i){i.color.getRGB(t.fogColor.value,xhe(e)),i.isFog?(t.fogNear.value=i.near,t.fogFar.value=i.far):i.isFogExp2&&(t.fogDensity.value=i.density)},refreshMaterialUniforms:function(e,r,a,s,o){r.isMeshBasicMaterial||r.isMeshLambertMaterial?n(e,r):r.isMeshToonMaterial?(n(e,r),function(e,t){t.gradientMap&&(e.gradientMap.value=t.gradientMap)}(e,r)):r.isMeshPhongMaterial?(n(e,r),function(e,t){e.specular.value.copy(t.specular),e.shininess.value=Math.max(t.shininess,1e-4)}(e,r)):r.isMeshStandardMaterial?(n(e,r),function(e,n){e.metalness.value=n.metalness,n.metalnessMap&&(e.metalnessMap.value=n.metalnessMap,i(n.metalnessMap,e.metalnessMapTransform)),e.roughness.value=n.roughness,n.roughnessMap&&(e.roughnessMap.value=n.roughnessMap,i(n.roughnessMap,e.roughnessMapTransform)),t.get(n).envMap&&(e.envMapIntensity.value=n.envMapIntensity)}(e,r),r.isMeshPhysicalMaterial&&function(e,t,n){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,i(t.sheenColorMap,e.sheenColorMapTransform)),t.sheenRoughnessMap&&(e.sheenRoughnessMap.value=t.sheenRoughnessMap,i(t.sheenRoughnessMap,e.sheenRoughnessMapTransform))),t.clearcoat>0&&(e.clearcoat.value=t.clearcoat,e.clearcoatRoughness.value=t.clearcoatRoughness,t.clearcoatMap&&(e.clearcoatMap.value=t.clearcoatMap,i(t.clearcoatMap,e.clearcoatMapTransform)),t.clearcoatRoughnessMap&&(e.clearcoatRoughnessMap.value=t.clearcoatRoughnessMap,i(t.clearcoatRoughnessMap,e.clearcoatRoughnessMapTransform)),t.clearcoatNormalMap&&(e.clearcoatNormalMap.value=t.clearcoatNormalMap,i(t.clearcoatNormalMap,e.clearcoatNormalMapTransform),e.clearcoatNormalScale.value.copy(t.clearcoatNormalScale),t.side===Ji&&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,i(t.iridescenceMap,e.iridescenceMapTransform)),t.iridescenceThicknessMap&&(e.iridescenceThicknessMap.value=t.iridescenceThicknessMap,i(t.iridescenceThicknessMap,e.iridescenceThicknessMapTransform))),t.transmission>0&&(e.transmission.value=t.transmission,e.transmissionSamplerMap.value=n.texture,e.transmissionSamplerSize.value.set(n.width,n.height),t.transmissionMap&&(e.transmissionMap.value=t.transmissionMap,i(t.transmissionMap,e.transmissionMapTransform)),e.thickness.value=t.thickness,t.thicknessMap&&(e.thicknessMap.value=t.thicknessMap,i(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,i(t.anisotropyMap,e.anisotropyMapTransform))),e.specularIntensity.value=t.specularIntensity,e.specularColor.value.copy(t.specularColor),t.specularColorMap&&(e.specularColorMap.value=t.specularColorMap,i(t.specularColorMap,e.specularColorMapTransform)),t.specularIntensityMap&&(e.specularIntensityMap.value=t.specularIntensityMap,i(t.specularIntensityMap,e.specularIntensityMapTransform))}(e,r,o)):r.isMeshMatcapMaterial?(n(e,r),function(e,t){t.matcap&&(e.matcap.value=t.matcap)}(e,r)):r.isMeshDepthMaterial?n(e,r):r.isMeshDistanceMaterial?(n(e,r),function(e,i){let n=t.get(i).light;e.referencePosition.value.setFromMatrixPosition(n.matrixWorld),e.nearDistance.value=n.shadow.camera.near,e.farDistance.value=n.shadow.camera.far}(e,r)):r.isMeshNormalMaterial?n(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,i(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,n,r){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.size.value=t.size*n,e.scale.value=.5*r,t.map&&(e.map.value=t.map,i(t.map,e.uvTransform)),t.alphaMap&&(e.alphaMap.value=t.alphaMap,i(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,i(t.map,e.mapTransform)),t.alphaMap&&(e.alphaMap.value=t.alphaMap,i(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 Eat(e,t,i,n){let r={},a={},s=[],o=i.isWebGL2?e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS):0;function l(e,t,i){let n=e.value;if(void 0===i[t]){if("number"==typeof n)i[t]=n;else{let e=Array.isArray(n)?n:[n],r=[];for(let t=0;t<e.length;t++)r.push(e[t].clone());i[t]=r}return!0}if("number"==typeof n){if(i[t]!==n)return i[t]=n,!0}else{let e=Array.isArray(i[t])?i[t]:[i[t]],r=Array.isArray(n)?n:[n];for(let t=0;t<e.length;t++){let i=e[t];if(!1===i.equals(r[t]))return i.copy(r[t]),!0}}return!1}function h(e){let t={boundary:0,storage:0};return"number"==typeof e?(t.boundary=4,t.storage=4):e.isVector2?(t.boundary=8,t.storage=8):e.isVector3||e.isColor?(t.boundary=16,t.storage=12):e.isVector4?(t.boundary=16,t.storage=16):e.isMatrix3?(t.boundary=48,t.storage=48):e.isMatrix4?(t.boundary=64,t.storage=64):e.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",e),t}function c(t){let i=t.target;i.removeEventListener("dispose",c);let n=s.indexOf(i.__bindingPointIndex);s.splice(n,1),e.deleteBuffer(r[i.id]),delete r[i.id],delete a[i.id]}return{bind:function(e,t){let i=t.program;n.uniformBlockBinding(e,i)},update:function(i,u){let d=r[i.id];void 0===d&&(function(e){let t=e.uniforms,i=0,n=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,i=s.length;t<i;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=i,r>0&&(n=i%16,0!==n&&16-n-a.boundary<0&&(i+=16-n,e.__offset=i)),i+=a.storage}n=i%16,n>0&&(i+=16-n),e.__size=i,e.__cache={}}(i),d=function(t){let i=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=i;let n=e.createBuffer(),r=t.__size,a=t.usage;return e.bindBuffer(e.UNIFORM_BUFFER,n),e.bufferData(e.UNIFORM_BUFFER,r,a),e.bindBuffer(e.UNIFORM_BUFFER,null),e.bindBufferBase(e.UNIFORM_BUFFER,i,n),n}(i),r[i.id]=d,i.addEventListener("dispose",c));let p=u.program;n.updateUBOMapping(i,p);let f=t.render.frame;a[i.id]!==f&&(function(t){let i=r[t.id],n=t.uniforms,a=t.__cache;e.bindBuffer(e.UNIFORM_BUFFER,i);for(let r=0,s=n.length;r<s;r++){let t=n[r];if(!0===l(t,r,a)){let i=t.__offset,n=Array.isArray(t.value)?t.value:[t.value],r=0;for(let a=0;a<n.length;a++){let s=n[a],o=h(s);"number"==typeof s?(t.__data[0]=s,e.bufferSubData(e.UNIFORM_BUFFER,i+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,i,t.__data)}}e.bindBuffer(e.UNIFORM_BUFFER,null)}(i),a[i.id]=f)},dispose:function(){for(let t in r)e.deleteBuffer(r[t]);s=[],r={},a={}}}}function _at(){let e=vb("canvas");return e.style.display="block",e}var Ts=class{constructor(e={}){let t,{canvas:i=_at(),context:n=null,depth:r=!0,stencil:a=!0,alpha:s=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:h=!1,powerPreference:c="default",failIfMajorPerformanceCaveat:u=!1}=e;this.isWebGLRenderer=!0,t=null!==n?n.getContextAttributes().alpha:s;let d=new Uint32Array(4),p=new Int32Array(4),f=null,m=null,g=[],v=[];this.domElement=i,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=en,this._useLegacyLights=!1,this.toneMapping=Vh,this.toneMappingExposure=1;let y=this,x=!1,b=0,_=0,w=null,S=-1,M=null,E=new gr,T=new gr,A=null,C=new ct(0),P=0,R=i.width,L=i.height,I=1,O=null,k=null,N=new gr(0,0,R,L),U=new gr(0,0,R,L),F=!1,B=new ma,z=!1,H=!1,V=null,j=new et,G=new xe,W=new D,X={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function Y(){return null===w?I:1}let q,Z,Q,J,K,$,ee,te,ie,ne,re,ae,se,oe,le,he,ce,ue,de,pe,fe,me,ge,ve,ye=n;function be(e,t){for(let n=0;n<e.length;n++){let r=e[n],a=i.getContext(r,t);if(null!==a)return a}return null}try{let e={alpha:!0,depth:r,stencil:a,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:h,powerPreference:c,failIfMajorPerformanceCaveat:u};if("setAttribute"in i&&i.setAttribute("data-engine",`three.js r${jR}`),i.addEventListener("webglcontextlost",Se,!1),i.addEventListener("webglcontextrestored",Me,!1),i.addEventListener("webglcontextcreationerror",Ee,!1),null===ye){let t=["webgl2","webgl","experimental-webgl"];if(!0===y.isWebGL1Renderer&&t.shift(),ye=be(t,e),null===ye)throw be(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 _e(){q=new Git(ye),Z=new Nit(ye,q,e),q.init(Z),me=new She(ye,q,Z),Q=new vat(ye,q,Z),J=new jit(ye),K=new sat,$=new yat(ye,q,Q,K,Z,me,J),ee=new Uit(y),te=new zit(y),ie=new nnt(ye,Z),ge=new kit(ye,q,ie,Z),ne=new qit(ye,ie,J,ge),re=new Zit(ye,ne,ie,J),de=new $it(ye,Z,$),he=new Bit(K),ae=new iat(y,ee,te,q,Z,ge,he),se=new bat(y,K),oe=new oat,le=new fat(q,Z),ue=new Oit(y,ee,te,Q,re,t,l),ce=new gat(y,re,Z),ve=new Eat(ye,J,Z,Q),pe=new Fit(ye,q,J,Z),fe=new Wit(ye,q,J,Z),J.programs=ae.programs,y.capabilities=Z,y.extensions=q,y.properties=K,y.renderLists=oe,y.shadowMap=ce,y.state=Q,y.info=J}_e();let we=new HB(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=J.autoReset,t=ce.enabled,i=ce.autoUpdate,n=ce.needsUpdate,r=ce.type;_e(),J.autoReset=e,ce.enabled=t,ce.autoUpdate=i,ce.needsUpdate=n,ce.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=K.get(e).programs;void 0!==t&&(t.forEach((function(e){ae.releaseProgram(e)})),e.isShaderMaterial&&ae.releaseShaderCache(e))})(e),K.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,n=!0){we.isPresenting?console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting."):(R=e,L=t,i.width=Math.floor(e*I),i.height=Math.floor(t*I),!0===n&&(i.style.width=e+"px",i.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,n){R=e,L=t,I=n,i.width=Math.floor(e*n),i.height=Math.floor(t*n),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,i,n){e.isVector4?N.set(e.x,e.y,e.z,e.w):N.set(e,t,i,n),Q.viewport(E.copy(N).multiplyScalar(I).floor())},this.getScissor=function(e){return e.copy(U)},this.setScissor=function(e,t,i,n){e.isVector4?U.set(e.x,e.y,e.z,e.w):U.set(e,t,i,n),Q.scissor(T.copy(U).multiplyScalar(I).floor())},this.getScissorTest=function(){return F},this.setScissorTest=function(e){Q.setScissorTest(F=e)},this.setOpaqueSort=function(e){O=e},this.setTransparentSort=function(e){k=e},this.getClearColor=function(e){return e.copy(ue.getClearColor())},this.setClearColor=function(){ue.setClearColor.apply(ue,arguments)},this.getClearAlpha=function(){return ue.getClearAlpha()},this.setClearAlpha=function(){ue.setClearAlpha.apply(ue,arguments)},this.clear=function(e=!0,t=!0,i=!0){let n=0;if(e){let e=!1;if(null!==w){let t=w.texture.format;e=t===OU||t===DU||t===LU}if(e){let e=w.texture.type,t=e===bc||e===Hh||e===Rv||e===xu||e===PU||e===IU,i=ue.getClearColor(),n=ue.getClearAlpha(),r=i.r,a=i.g,s=i.b;t?(d[0]=r,d[1]=a,d[2]=s,d[3]=n,ye.clearBufferuiv(ye.COLOR,0,d)):(p[0]=r,p[1]=a,p[2]=s,p[3]=n,ye.clearBufferiv(ye.COLOR,0,p))}else n|=ye.COLOR_BUFFER_BIT}t&&(n|=ye.DEPTH_BUFFER_BIT),i&&(n|=ye.STENCIL_BUFFER_BIT),ye.clear(n)},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(){i.removeEventListener("webglcontextlost",Se,!1),i.removeEventListener("webglcontextrestored",Me,!1),i.removeEventListener("webglcontextcreationerror",Ee,!1),oe.dispose(),le.dispose(),K.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,i,n,r,a){null===t&&(t=X);let s=r.isMesh&&r.matrixWorld.determinant()<0,o=function(e,t,i,n,r){!0!==t.isScene&&(t=X),$.resetTextureUnits();let a=t.fog,s=n.isMeshStandardMaterial?t.environment:null,o=null===w?y.outputColorSpace:!0===w.isXRRenderTarget?w.texture.colorSpace:Na,l=(n.isMeshStandardMaterial?te:ee).get(n.envMap||s),h=!0===n.vertexColors&&!!i.attributes.color&&4===i.attributes.color.itemSize,c=!!i.attributes.tangent&&(!!n.normalMap||n.anisotropy>0),u=!!i.morphAttributes.position,d=!!i.morphAttributes.normal,p=!!i.morphAttributes.color,f=Vh;n.toneMapped&&(null===w||!0===w.isXRRenderTarget)&&(f=y.toneMapping);let g=i.morphAttributes.position||i.morphAttributes.normal||i.morphAttributes.color,v=void 0!==g?g.length:0,x=K.get(n),b=m.state.lights;if(!0===z&&(!0===H||e!==M)){let t=e===M&&n.id===S;he.setState(n,e,t)}let _=!1;n.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===n.fog&&x.fog!==a||void 0!==x.numClippingPlanes&&(x.numClippingPlanes!==he.numPlanes||x.numIntersection!==he.numIntersection)||x.vertexAlphas!==h||x.vertexTangents!==c||x.morphTargets!==u||x.morphNormals!==d||x.morphColors!==p||x.toneMapping!==f||!0===Z.isWebGL2&&x.morphTargetsCount!==v)&&(_=!0):(_=!0,x.__version=n.version);let E=x.currentProgram;!0===_&&(E=ke(n,t,r));let T=!1,A=!1,C=!1,P=E.getUniforms(),R=x.uniforms;if(Q.useProgram(E.program)&&(T=!0,A=!0,C=!0),n.id!==S&&(S=n.id,A=!0),T||M!==e){if(P.setValue(ye,"projectionMatrix",e.projectionMatrix),Z.logarithmicDepthBuffer&&P.setValue(ye,"logDepthBufFC",2/(Math.log(e.far+1)/Math.LN2)),M!==e&&(M=e,A=!0,C=!0),n.isShaderMaterial||n.isMeshPhongMaterial||n.isMeshToonMaterial||n.isMeshStandardMaterial||n.envMap){let t=P.map.cameraPosition;void 0!==t&&t.setValue(ye,W.setFromMatrixPosition(e.matrixWorld))}(n.isMeshPhongMaterial||n.isMeshToonMaterial||n.isMeshLambertMaterial||n.isMeshBasicMaterial||n.isMeshStandardMaterial||n.isShaderMaterial)&&P.setValue(ye,"isOrthographic",!0===e.isOrthographicCamera),(n.isMeshPhongMaterial||n.isMeshToonMaterial||n.isMeshLambertMaterial||n.isMeshBasicMaterial||n.isMeshStandardMaterial||n.isShaderMaterial||n.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&&(Z.floatVertexTextures?(null===e.boneTexture&&e.computeBoneTexture(),P.setValue(ye,"boneTexture",e.boneTexture,$),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 D=i.morphAttributes;if((void 0!==D.position||void 0!==D.normal||void 0!==D.color&&!0===Z.isWebGL2)&&de.update(r,i,E),(A||x.receiveShadow!==r.receiveShadow)&&(x.receiveShadow=r.receiveShadow,P.setValue(ye,"receiveShadow",r.receiveShadow)),n.isMeshGouraudMaterial&&null!==n.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===n.fog&&se.refreshFogUniforms(R,a),se.refreshMaterialUniforms(R,n,I,L,V),sv.upload(ye,x.uniformsList,R,$)),n.isShaderMaterial&&!0===n.uniformsNeedUpdate&&(sv.upload(ye,x.uniformsList,R,$),n.uniformsNeedUpdate=!1),n.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),n.isShaderMaterial||n.isRawShaderMaterial){let e=n.uniformsGroups;for(let t=0,i=e.length;t<i;t++)if(Z.isWebGL2){let i=e[t];ve.update(i,E),ve.bind(i,E)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return E}(e,t,i,n,r);Q.setMaterial(n,s);let l=i.index,h=1;if(!0===n.wireframe){if(l=ne.getWireframeAttribute(i),void 0===l)return;h=2}let c=i.drawRange,u=i.attributes.position,d=c.start*h,p=(c.start+c.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!=u&&(d=Math.max(d,0),p=Math.min(p,u.count));let f=p-d;if(f<0||f===1/0)return;ge.setup(r,n,o,i,l);let g,v=pe;if(null!==l&&(g=ie.get(l),v=fe,v.setIndex(g)),r.isMesh)!0===n.wireframe?(Q.setLineWidth(n.wireframeLinewidth*Y()),v.setMode(ye.LINES)):v.setMode(ye.TRIANGLES);else if(r.isLine){let e=n.linewidth;void 0===e&&(e=1),Q.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(i.isInstancedBufferGeometry){let e=void 0!==i._maxInstanceCount?i._maxInstanceCount:1/0,t=Math.min(i.instanceCount,e);v.renderInstances(d,f,t)}else v.render(d,f)},this.compile=function(e,t){function i(e,t,i){!0===e.transparent&&e.side===Sr&&!1===e.forceSinglePass?(e.side=Ji,e.needsUpdate=!0,ke(e,t,i),e.side=pi,e.needsUpdate=!0,ke(e,t,i),e.side=Sr):ke(e,t,i)}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 n=t.material;if(n)if(Array.isArray(n))for(let r=0;r<n.length;r++)i(n[r],e,t);else i(n,e,t)})),v.pop(),m=null};let Ae=null;function Ce(){Re.stop()}function Pe(){Re.start()}let Re=new bhe;function De(e,t,i,n){if(!1===e.visible)return;if(e.layers.test(t.layers))if(e.isGroup)i=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)){n&&W.setFromMatrixPosition(e.matrixWorld).applyMatrix4(j);let t=re.update(e),r=e.material;r.visible&&f.push(e,t,r,i,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(n&&(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 n=t.groups;for(let a=0,s=n.length;a<s;a++){let s=n[a],o=r[s.materialIndex];o&&o.visible&&f.push(e,t,o,i,W.z,s)}}else r.visible&&f.push(e,t,r,i,W.z,null)}let r=e.children;for(let a=0,s=r.length;a<s;a++)De(r[a],t,i,n)}function Le(e,t,i,n){let r=e.opaque,a=e.transmissive,s=e.transparent;m.setupLightsView(i),!0===z&&he.setGlobalState(y.clippingPlanes,i),a.length>0&&function(e,t,i,n){let r=Z.isWebGL2;null===V&&(V=new sr(1,1,{generateMipmaps:!0,type:q.has("EXT_color_buffer_half_float")?Mr:bc,minFilter:Fa,samples:r?4:0})),y.getDrawingBufferSize(G),r?V.setSize(G.x,G.y):V.setSize(xR(G.x),xR(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=Vh,Ie(e,i,n),$.updateMultisampleRenderTarget(V),$.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===Sr&&r.layers.test(n.layers)){let e=s.side;s.side=Ji,s.needsUpdate=!0,Oe(r,i,n,a,s,h),s.side=e,s.needsUpdate=!0,o=!0}}!0===o&&($.updateMultisampleRenderTarget(V),$.updateRenderTargetMipmap(V)),y.setRenderTarget(a),y.setClearColor(C,P),y.toneMapping=s}(r,a,t,i),n&&Q.viewport(E.copy(n)),r.length>0&&Ie(r,t,i),a.length>0&&Ie(a,t,i),s.length>0&&Ie(s,t,i),Q.buffers.depth.setTest(!0),Q.buffers.depth.setMask(!0),Q.buffers.color.setMask(!0),Q.setPolygonOffset(!1)}function Ie(e,t,i){let n=!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===n?a.material:n,h=a.group;s.layers.test(i.layers)&&Oe(s,t,i,o,l,h)}}function Oe(e,t,i,n,r,a){e.onBeforeRender(y,t,i,n,r,a),e.modelViewMatrix.multiplyMatrices(i.matrixWorldInverse,e.matrixWorld),e.normalMatrix.getNormalMatrix(e.modelViewMatrix),r.onBeforeRender(y,t,i,n,e,a),!0===r.transparent&&r.side===Sr&&!1===r.forceSinglePass?(r.side=Ji,r.needsUpdate=!0,y.renderBufferDirect(i,t,n,r,e,a),r.side=pi,r.needsUpdate=!0,y.renderBufferDirect(i,t,n,r,e,a),r.side=Sr):y.renderBufferDirect(i,t,n,r,e,a),e.onAfterRender(y,t,i,n,r,a)}function ke(e,t,i){!0!==t.isScene&&(t=X);let n=K.get(e),r=m.state.lights,a=m.state.shadowsArray,s=r.state.version,o=ae.getParameters(e,r.state,a,t,i),l=ae.getProgramCacheKey(o),h=n.programs;n.environment=e.isMeshStandardMaterial?t.environment:null,n.fog=t.fog,n.envMap=(e.isMeshStandardMaterial?te:ee).get(e.envMap||n.environment),void 0===h&&(e.addEventListener("dispose",Te),h=new Map,n.programs=h);let c=h.get(l);if(void 0!==c){if(n.currentProgram===c&&n.lightsStateVersion===s)return Ne(e,o),c}else o.uniforms=ae.getUniforms(e),e.onBuild(i,o,y),e.onBeforeCompile(o,y),c=ae.acquireProgram(o,l),h.set(l,c),n.uniforms=o.uniforms;let u=n.uniforms;(!e.isShaderMaterial&&!e.isRawShaderMaterial||!0===e.clipping)&&(u.clippingPlanes=he.uniform),Ne(e,o),n.needsLights=function(e){return e.isMeshLambertMaterial||e.isMeshToonMaterial||e.isMeshPhongMaterial||e.isMeshStandardMaterial||e.isShadowMaterial||e.isShaderMaterial&&!0===e.lights}(e),n.lightsStateVersion=s,n.needsLights&&(u.ambientLightColor.value=r.state.ambient,u.lightProbe.value=r.state.probe,u.directionalLights.value=r.state.directional,u.directionalLightShadows.value=r.state.directionalShadow,u.spotLights.value=r.state.spot,u.spotLightShadows.value=r.state.spotShadow,u.rectAreaLights.value=r.state.rectArea,u.ltc_1.value=r.state.rectAreaLTC1,u.ltc_2.value=r.state.rectAreaLTC2,u.pointLights.value=r.state.point,u.pointLightShadows.value=r.state.pointShadow,u.hemisphereLights.value=r.state.hemi,u.directionalShadowMap.value=r.state.directionalShadowMap,u.directionalShadowMatrix.value=r.state.directionalShadowMatrix,u.spotShadowMap.value=r.state.spotShadowMap,u.spotLightMatrix.value=r.state.spotLightMatrix,u.spotLightMap.value=r.state.spotLightMap,u.pointShadowMap.value=r.state.pointShadowMap,u.pointShadowMatrix.value=r.state.pointShadowMatrix);let d=c.getUniforms(),p=sv.seqWithValue(d.seq,u);return n.currentProgram=c,n.uniformsList=p,c}function Ne(e,t){let i=K.get(e);i.outputColorSpace=t.outputColorSpace,i.instancing=t.instancing,i.instancingColor=t.instancingColor,i.skinning=t.skinning,i.morphTargets=t.morphTargets,i.morphNormals=t.morphNormals,i.morphColors=t.morphColors,i.morphTargetsCount=t.morphTargetsCount,i.numClippingPlanes=t.numClippingPlanes,i.numIntersection=t.numClipIntersection,i.vertexAlphas=t.vertexAlphas,i.vertexTangents=t.vertexTangents,i.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),De(e,t,0,y.sortObjects),f.finish(),!0===y.sortObjects&&f.sort(O,k),this.info.render.frame++,!0===z&&he.beginShadows();let i=m.state.shadowsArray;if(ce.render(i,e,t),!0===z&&he.endShadows(),!0===this.info.autoReset&&this.info.reset(),ue.render(f,e),m.setupLights(y._useLegacyLights),t.isArrayCamera){let i=t.cameras;for(let t=0,n=i.length;t<n;t++){let n=i[t];Le(f,e,n,n.viewport)}}else Le(f,e,t);null!==w&&($.updateMultisampleRenderTarget(w),$.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,i){K.get(e.texture).__webglTexture=t,K.get(e.depthTexture).__webglTexture=i;let n=K.get(e);n.__hasExternalTextures=!0,n.__hasExternalTextures&&(n.__autoAllocateDepthBuffer=void 0===i,n.__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"),n.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(e,t){let i=K.get(e);i.__webglFramebuffer=t,i.__useDefaultFramebuffer=void 0===t},this.setRenderTarget=function(e,t=0,i=0){w=e,b=t,_=i;let n=!0,r=null,a=!1,s=!1;if(e){let o=K.get(e);void 0!==o.__useDefaultFramebuffer?(Q.bindFramebuffer(ye.FRAMEBUFFER,null),n=!1):void 0===o.__webglFramebuffer?$.setupRenderTarget(e):o.__hasExternalTextures&&$.rebindTextures(e,K.get(e.texture).__webglTexture,K.get(e.depthTexture).__webglTexture);let l=e.texture;(l.isData3DTexture||l.isDataArrayTexture||l.isCompressedArrayTexture)&&(s=!0);let h=K.get(e).__webglFramebuffer;e.isWebGLCubeRenderTarget?(r=Array.isArray(h[t])?h[t][i]:h[t],a=!0):r=Z.isWebGL2&&e.samples>0&&!1===$.useMultisampledRTT(e)?K.get(e).__webglMultisampledFramebuffer:Array.isArray(h)?h[i]: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(Q.bindFramebuffer(ye.FRAMEBUFFER,r)&&Z.drawBuffers&&n&&Q.drawBuffers(e,r),Q.viewport(E),Q.scissor(T),Q.setScissorTest(A),a){let n=K.get(e.texture);ye.framebufferTexture2D(ye.FRAMEBUFFER,ye.COLOR_ATTACHMENT0,ye.TEXTURE_CUBE_MAP_POSITIVE_X+t,n.__webglTexture,i)}else if(s){let n=K.get(e.texture),r=t||0;ye.framebufferTextureLayer(ye.FRAMEBUFFER,ye.COLOR_ATTACHMENT0,n.__webglTexture,i||0,r)}S=-1},this.readRenderTargetPixels=function(e,t,i,n,r,a,s){if(!e||!e.isWebGLRenderTarget)return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let o=K.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&void 0!==s&&(o=o[s]),o){Q.bindFramebuffer(ye.FRAMEBUFFER,o);try{let s=e.texture,o=s.format,l=s.type;if(o!==Js&&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===Mr&&(q.has("EXT_color_buffer_half_float")||Z.isWebGL2&&q.has("EXT_color_buffer_float"));if(!(l===bc||me.convert(l)===ye.getParameter(ye.IMPLEMENTATION_COLOR_READ_TYPE)||l===fa&&(Z.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-n&&i>=0&&i<=e.height-r&&ye.readPixels(t,i,n,r,me.convert(o),me.convert(l),a)}finally{let e=null!==w?K.get(w).__webglFramebuffer:null;Q.bindFramebuffer(ye.FRAMEBUFFER,e)}}},this.copyFramebufferToTexture=function(e,t,i=0){let n=Math.pow(2,-i),r=Math.floor(t.image.width*n),a=Math.floor(t.image.height*n);$.setTexture2D(t,0),ye.copyTexSubImage2D(ye.TEXTURE_2D,i,0,0,e.x,e.y,r,a),Q.unbindTexture()},this.copyTextureToTexture=function(e,t,i,n=0){let r=t.image.width,a=t.image.height,s=me.convert(i.format),o=me.convert(i.type);$.setTexture2D(i,0),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),t.isDataTexture?ye.texSubImage2D(ye.TEXTURE_2D,n,e.x,e.y,r,a,s,o,t.image.data):t.isCompressedTexture?ye.compressedTexSubImage2D(ye.TEXTURE_2D,n,e.x,e.y,t.mipmaps[0].width,t.mipmaps[0].height,s,t.mipmaps[0].data):ye.texSubImage2D(ye.TEXTURE_2D,n,e.x,e.y,s,o,t.image),0===n&&i.generateMipmaps&&ye.generateMipmap(ye.TEXTURE_2D),Q.unbindTexture()},this.copyTextureToTexture3D=function(e,t,i,n,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(n.format),c=me.convert(n.type);if(n.isData3DTexture)$.setTexture3D(n,0),a=ye.TEXTURE_3D;else{if(!n.isDataArrayTexture)return void console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");$.setTexture2DArray(n,0),a=ye.TEXTURE_2D_ARRAY}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);let u=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=i.isCompressedTexture?i.mipmaps[0]:i.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),i.isDataTexture||i.isData3DTexture?ye.texSubImage3D(a,r,t.x,t.y,t.z,s,o,l,h,c,g.data):i.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,c,g),ye.pixelStorei(ye.UNPACK_ROW_LENGTH,u),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&&n.generateMipmaps&&ye.generateMipmap(a),Q.unbindTexture()},this.initTexture=function(e){e.isCubeTexture?$.setTextureCube(e,0):e.isData3DTexture?$.setTexture3D(e,0):e.isDataArrayTexture||e.isCompressedArrayTexture?$.setTexture2DArray(e,0):$.setTexture2D(e,0),Q.unbindTexture()},this.resetState=function(){b=0,_=0,w=null,Q.reset(),ge.reset()},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return yu}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===en?bu:NU}set outputEncoding(e){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=e===bu?en:Na}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}},wR=class extends Ts{};wR.prototype.isWebGL1Renderer=!0;var cv=class{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new ct(e),this.density=t}clone(){return new cv(this.color,this.density)}toJSON(){return{type:"FogExp2",color:this.color.getHex(),density:this.density}}},Tu=class{constructor(e,t=1,i=1e3){this.isFog=!0,this.name="",this.color=new ct(e),this.near=t,this.far=i}clone(){return new Tu(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}},Si=class extends on{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}},$h=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=void 0!==e?e.length/t:0,this.usage=mb,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=qo()}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,i){e*=this.stride,i*=t.stride;for(let n=0,r=this.stride;n<r;n++)this.array[e+n]=t.array[i+n];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=qo()),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]),i=new this.constructor(t,this.stride);return i.setUsage(this.usage),i}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=qo()),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}}},Oa=new D,co=class{constructor(e,t,i,n=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=i,this.normalized=n}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,i=this.data.count;t<i;t++)Oa.fromBufferAttribute(this,t),Oa.applyMatrix4(e),this.setXYZ(t,Oa.x,Oa.y,Oa.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)Oa.fromBufferAttribute(this,t),Oa.applyNormalMatrix(e),this.setXYZ(t,Oa.x,Oa.y,Oa.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)Oa.fromBufferAttribute(this,t),Oa.transformDirection(e),this.setXYZ(t,Oa.x,Oa.y,Oa.z);return this}setX(e,t){return this.normalized&&(t=mr(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=mr(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=mr(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=mr(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=oo(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=oo(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=oo(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=oo(t,this.array)),t}setXY(e,t,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=mr(t,this.array),i=mr(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this}setXYZ(e,t,i,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=mr(t,this.array),i=mr(i,this.array),n=mr(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=n,this}setXYZW(e,t,i,n,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=mr(t,this.array),i=mr(i,this.array),n=mr(n,this.array),r=mr(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=n,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 i=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[i+t])}return new mn(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 co(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 i=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[i+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 yr{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}},$0,eb=new D,Z0=new D,K0=new D,J0=new xe,tb=new xe,Mhe=new et,GM=new D,nb=new D,qM=new D,Fce=new xe,NN=new xe,Nce=new xe,SR=class extends on{constructor(e){if(super(),this.isSprite=!0,this.type="Sprite",void 0===$0){$0=new Dt;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 $h(e,5);$0.setIndex([0,1,2,0,2,3]),$0.setAttribute("position",new co(t,3,0,!1)),$0.setAttribute("uv",new co(t,2,3,!1))}this.geometry=$0,this.material=void 0!==e?e:new Tb,this.center=new xe(.5,.5)}raycast(e,t){null===e.camera&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),Z0.setFromMatrixScale(this.matrixWorld),Mhe.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),K0.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&!1===this.material.sizeAttenuation&&Z0.multiplyScalar(-K0.z);let i,n,r=this.material.rotation;0!==r&&(n=Math.cos(r),i=Math.sin(r));let a=this.center;WM(GM.set(-.5,-.5,0),K0,a,Z0,i,n),WM(nb.set(.5,-.5,0),K0,a,Z0,i,n),WM(qM.set(.5,.5,0),K0,a,Z0,i,n),Fce.set(0,0),NN.set(1,0),Nce.set(1,1);let s=e.ray.intersectTriangle(GM,nb,qM,!1,eb);if(null===s&&(WM(nb.set(-.5,.5,0),K0,a,Z0,i,n),NN.set(0,1),s=e.ray.intersectTriangle(GM,qM,nb,!1,eb),null===s))return;let o=e.ray.origin.distanceTo(eb);o<e.near||o>e.far||t.push({distance:o,point:eb.clone(),uv:Zr.getInterpolation(eb,GM,nb,qM,Fce,NN,Nce,new xe),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 WM(e,t,i,n,r,a){J0.subVectors(e,i).addScalar(.5).multiply(n),void 0!==r?(tb.x=a*J0.x-r*J0.y,tb.y=r*J0.x+a*J0.y):tb.copy(J0),e.copy(t),e.x+=tb.x,e.y+=tb.y,e.applyMatrix4(Mhe)}var jM=new D,Bce=new D,MR=class extends on{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 i=0,n=t.length;i<n;i++){let e=t[i];this.addLevel(e.object.clone(),e.distance,e.hysteresis)}return this.autoUpdate=e.autoUpdate,this}addLevel(e,t=0,i=0){t=Math.abs(t);let n,r=this.levels;for(n=0;n<r.length&&!(t<r[n].distance);n++);return r.splice(n,0,{distance:t,hysteresis:i,object:e}),this.add(e),this}getCurrentLevel(){return this._currentLevel}getObjectForDistance(e){let t=this.levels;if(t.length>0){let i,n;for(i=1,n=t.length;i<n;i++){let n=t[i].distance;if(t[i].object.visible&&(n-=n*t[i].hysteresis),e<n)break}return t[i-1].object}return null}raycast(e,t){if(this.levels.length>0){jM.setFromMatrixPosition(this.matrixWorld);let i=e.ray.origin.distanceTo(jM);this.getObjectForDistance(i).raycast(e,t)}}update(e){let t=this.levels;if(t.length>1){jM.setFromMatrixPosition(e.matrixWorld),Bce.setFromMatrixPosition(this.matrixWorld);let i,n,r=jM.distanceTo(Bce)/e.zoom;for(t[0].object.visible=!0,i=1,n=t.length;i<n;i++){let e=t[i].distance;if(t[i].object.visible&&(e-=e*t[i].hysteresis),!(r>=e))break;t[i-1].object.visible=!1,t[i].object.visible=!0}for(this._currentLevel=i-1;i<n;i++)t[i].object.visible=!1}}toJSON(e){let t=super.toJSON(e);!1===this.autoUpdate&&(t.object.autoUpdate=!1),t.object.levels=[];let i=this.levels;for(let n=0,r=i.length;n<r;n++){let e=i[n];t.object.levels.push({object:e.object.uuid,distance:e.distance,hysteresis:e.hysteresis})}return t}},Uce=new D,Hce=new gr,Vce=new gr,Tat=new D,zce=new et,Q0=new D,BN=new vr,Gce=new et,UN=new lo,wu=class extends xt{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new et,this.bindMatrixInverse=new et,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 i=0;i<t.count;i++)Q0.fromBufferAttribute(t,i),this.applyBoneTransform(i,Q0),this.boundingBox.expandByPoint(Q0)}computeBoundingSphere(){let e=this.geometry;null===this.boundingSphere&&(this.boundingSphere=new vr),this.boundingSphere.makeEmpty();let t=e.getAttribute("position");for(let i=0;i<t.count;i++)Q0.fromBufferAttribute(t,i),this.applyBoneTransform(i,Q0),this.boundingSphere.expandByPoint(Q0)}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 i=this.material,n=this.matrixWorld;void 0!==i&&(null===this.boundingSphere&&this.computeBoundingSphere(),BN.copy(this.boundingSphere),BN.applyMatrix4(n),!1!==e.ray.intersectsSphere(BN)&&(Gce.copy(n).invert(),UN.copy(e.ray).applyMatrix4(Gce),(null===this.boundingBox||!1!==UN.intersectsBox(this.boundingBox))&&this._computeIntersections(e,t,UN)))}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 gr,t=this.geometry.attributes.skinWeight;for(let i=0,n=t.count;i<n;i++){e.fromBufferAttribute(t,i);let n=1/e.manhattanLength();n!==1/0?e.multiplyScalar(n):e.set(1,0,0,0),t.setXYZW(i,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 i=this.skeleton,n=this.geometry;Hce.fromBufferAttribute(n.attributes.skinIndex,e),Vce.fromBufferAttribute(n.attributes.skinWeight,e),Uce.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let r=0;r<4;r++){let e=Vce.getComponent(r);if(0!==e){let n=Hce.getComponent(r);zce.multiplyMatrices(i.bones[n].matrixWorld,i.boneInverses[n]),t.addScaledVector(Tat.copy(Uce).applyMatrix4(zce),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 on{constructor(){super(),this.isBone=!0,this.type="Bone"}},wl=class extends Gr{constructor(e=null,t=1,i=1,n,r,a,s,o,l=Jr,h=Jr,c,u){super(null,a,s,o,l,h,n,r,c,u),this.isDataTexture=!0,this.image={data:e,width:t,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},qce=new et,wat=new et,Ml=class{constructor(e=[],t=[]){this.uuid=qo(),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 et)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){let t=new et;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,i=this.boneMatrices,n=this.boneTexture;for(let r=0,a=e.length;r<a;r++){let n=e[r]?e[r].matrixWorld:wat;qce.multiplyMatrices(n,t[r]),qce.toArray(i,16*r)}null!==n&&(n.needsUpdate=!0)}clone(){return new Ml(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(4*this.bones.length);e=ghe(e),e=Math.max(e,4);let t=new Float32Array(e*e*4);t.set(this.boneMatrices);let i=new wl(t,e,e,Js,fa);return i.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=i,this.boneTextureSize=e,this}getBoneByName(e){for(let t=0,i=this.bones.length;t<i;t++){let i=this.bones[t];if(i.name===e)return i}}dispose(){null!==this.boneTexture&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let i=0,n=e.bones.length;i<n;i++){let n=e.bones[i],r=t[n];void 0===r&&(console.warn("THREE.Skeleton: No bone found with UUID:",n),r=new Sl),this.bones.push(r),this.boneInverses.push((new et).fromArray(e.boneInverses[i]))}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,i=this.boneInverses;for(let n=0,r=t.length;n<r;n++){let r=t[n];e.bones.push(r.uuid);let a=i[n];e.boneInverses.push(a.toArray())}return e}},Zh=class extends mn{constructor(e,t,i,n=1){super(e,t,i),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=n}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}},ev=new et,Wce=new et,XM=[],jce=new Nt,Sat=new et,rb=new xt,ib=new vr,Oi=class extends xt{constructor(e,t,i){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new Zh(new Float32Array(16*i),16),this.instanceColor=null,this.count=i,this.boundingBox=null,this.boundingSphere=null;for(let n=0;n<i;n++)this.setMatrixAt(n,Sat)}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 i=0;i<t;i++)this.getMatrixAt(i,ev),jce.copy(e.boundingBox).applyMatrix4(ev),this.boundingBox.union(jce)}computeBoundingSphere(){let e=this.geometry,t=this.count;null===this.boundingSphere&&(this.boundingSphere=new vr),null===e.boundingSphere&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,ev),ib.copy(e.boundingSphere).applyMatrix4(ev),this.boundingSphere.union(ib)}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 i=this.matrixWorld,n=this.count;if(rb.geometry=this.geometry,rb.material=this.material,void 0!==rb.material&&(null===this.boundingSphere&&this.computeBoundingSphere(),ib.copy(this.boundingSphere),ib.applyMatrix4(i),!1!==e.ray.intersectsSphere(ib)))for(let r=0;r<n;r++){this.getMatrixAt(r,ev),Wce.multiplyMatrices(i,ev),rb.matrixWorld=Wce,rb.raycast(e,XM);for(let e=0,i=XM.length;e<i;e++){let i=XM[e];i.instanceId=r,i.object=this,t.push(i)}XM.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"})}},Gn=class extends yr{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}},Xce=new D,Yce=new D,$ce=new et,HN=new lo,YM=new vr,fr=class extends on{constructor(e=new Dt,t=new Gn){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,i=[0];for(let e=1,n=t.count;e<n;e++)Xce.fromBufferAttribute(t,e-1),Yce.fromBufferAttribute(t,e),i[e]=i[e-1],i[e]+=Xce.distanceTo(Yce);e.setAttribute("lineDistance",new Bt(i,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){let i=this.geometry,n=this.matrixWorld,r=e.params.Line.threshold,a=i.drawRange;if(null===i.boundingSphere&&i.computeBoundingSphere(),YM.copy(i.boundingSphere),YM.applyMatrix4(n),YM.radius+=r,!1===e.ray.intersectsSphere(YM))return;$ce.copy(n).invert(),HN.copy(e.ray).applyMatrix4($ce);let s=r/((this.scale.x+this.scale.y+this.scale.z)/3),o=s*s,l=new D,h=new D,c=new D,u=new D,d=this.isLineSegments?2:1,p=i.index,f=i.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 i=p.getX(m),n=p.getX(m+1);if(l.fromBufferAttribute(f,i),h.fromBufferAttribute(f,n),HN.distanceSqToSegment(l,h,u,c)>o)continue;u.applyMatrix4(this.matrixWorld);let r=e.ray.origin.distanceTo(u);r<e.near||r>e.far||t.push({distance:r,point:c.clone().applyMatrix4(this.matrixWorld),index:m,face:null,faceIndex:null,object:this})}else for(let m=Math.max(0,a.start),g=Math.min(f.count,a.start+a.count)-1;m<g;m+=d){if(l.fromBufferAttribute(f,m),h.fromBufferAttribute(f,m+1),HN.distanceSqToSegment(l,h,u,c)>o)continue;u.applyMatrix4(this.matrixWorld);let i=e.ray.origin.distanceTo(u);i<e.near||i>e.far||t.push({distance:i,point:c.clone().applyMatrix4(this.matrixWorld),index:m,face:null,faceIndex:null,object:this})}}updateMorphTargets(){let e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){let i=e[t[0]];if(void 0!==i){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=i.length;e<t;e++){let t=i[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}},Zce=new D,Kce=new D,qr=class extends fr{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,i=[];for(let e=0,n=t.count;e<n;e+=2)Zce.fromBufferAttribute(t,e),Kce.fromBufferAttribute(t,e+1),i[e]=0===e?0:i[e-1],i[e+1]=i[e]+Zce.distanceTo(Kce);e.setAttribute("lineDistance",new Bt(i,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}},uv=class extends fr{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}},bi=class extends yr{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}},Jce=new et,VB=new lo,$M=new vr,ZM=new D,ii=class extends on{constructor(e=new Dt,t=new bi){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 i=this.geometry,n=this.matrixWorld,r=e.params.Points.threshold,a=i.drawRange;if(null===i.boundingSphere&&i.computeBoundingSphere(),$M.copy(i.boundingSphere),$M.applyMatrix4(n),$M.radius+=r,!1===e.ray.intersectsSphere($M))return;Jce.copy(n).invert(),VB.copy(e.ray).applyMatrix4(Jce);let s=r/((this.scale.x+this.scale.y+this.scale.z)/3),o=s*s,l=i.index,h=i.attributes.position;if(null!==l)for(let c=Math.max(0,a.start),u=Math.min(l.count,a.start+a.count);c<u;c++){let i=l.getX(c);ZM.fromBufferAttribute(h,i),Qce(ZM,i,o,n,e,t,this)}else for(let c=Math.max(0,a.start),u=Math.min(h.count,a.start+a.count);c<u;c++)ZM.fromBufferAttribute(h,c),Qce(ZM,c,o,n,e,t,this)}updateMorphTargets(){let e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){let i=e[t[0]];if(void 0!==i){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=i.length;e<t;e++){let t=i[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}};function Qce(e,t,i,n,r,a,s){let o=VB.distanceSqToPoint(e);if(o<i){let i=new D;VB.closestPointToPoint(e,i),i.applyMatrix4(n);let l=r.ray.origin.distanceTo(i);if(l<r.near||l>r.far)return;a.push({distance:l,distanceToRay:Math.sqrt(o),point:i,index:t,face:null,object:s})}}var zB=class extends Gr{constructor(e,t,i,n,r,a,s,o,l){super(e,t,i,n,r,a,s,o,l),this.isVideoTexture=!0,this.minFilter=void 0!==a?a:Pr,this.magFilter=void 0!==r?r:Pr,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)}},GB=class extends Gr{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=Jr,this.minFilter=Jr,this.generateMipmaps=!1,this.needsUpdate=!0}},Su=class extends Gr{constructor(e,t,i,n,r,a,s,o,l,h,c,u){super(null,a,s,o,l,h,n,r,c,u),this.isCompressedTexture=!0,this.image={width:t,height:i},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}},qB=class extends Su{constructor(e,t,i,n,r,a){super(e,t,i,r,a),this.isCompressedArrayTexture=!0,this.image.depth=n,this.wrapR=Li}},WB=class extends Su{constructor(e,t,i){super(void 0,e[0].width,e[0].height,t,i,Gh),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=e}},wb=class extends Gr{constructor(e,t,i,n,r,a,s,o,l){super(e,t,i,n,r,a,s,o,l),this.isCanvasTexture=!0,this.needsUpdate=!0}},Ba=class{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){let i=this.getUtoTmapping(e);return this.getPoint(i,t)}getPoints(e=5){let t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return t}getSpacedPoints(e=5){let t=[];for(let i=0;i<=e;i++)t.push(this.getPointAt(i/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,i=[],n=this.getPoint(0),r=0;i.push(0);for(let a=1;a<=e;a++)t=this.getPoint(a/e),r+=t.distanceTo(n),i.push(r),n=t;return this.cacheArcLengths=i,i}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){let i,n=this.getLengths(),r=0,a=n.length;i=t||e*n[a-1];let s,o=0,l=a-1;for(;o<=l;)if(r=Math.floor(o+(l-o)/2),s=n[r]-i,s<0)o=r+1;else{if(!(s>0)){l=r;break}l=r-1}if(r=l,n[r]===i)return r/(a-1);let h=n[r];return(r+(i-h)/(n[r+1]-h))/(a-1)}getTangent(e,t){let i=e-1e-4,n=e+1e-4;i<0&&(i=0),n>1&&(n=1);let r=this.getPoint(i),a=this.getPoint(n),s=t||(r.isVector2?new xe:new D);return s.copy(a).sub(r).normalize(),s}getTangentAt(e,t){let i=this.getUtoTmapping(e);return this.getTangent(i,t)}computeFrenetFrames(e,t){let i=new D,n=[],r=[],a=[],s=new D,o=new et;for(let d=0;d<=e;d++){let t=d/e;n[d]=this.getTangentAt(t,new D)}r[0]=new D,a[0]=new D;let l=Number.MAX_VALUE,h=Math.abs(n[0].x),c=Math.abs(n[0].y),u=Math.abs(n[0].z);h<=l&&(l=h,i.set(1,0,0)),c<=l&&(l=c,i.set(0,1,0)),u<=l&&i.set(0,0,1),s.crossVectors(n[0],i).normalize(),r[0].crossVectors(n[0],s),a[0].crossVectors(n[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(n[d-1],n[d]),s.length()>Number.EPSILON){s.normalize();let e=Math.acos(os(n[d-1].dot(n[d]),-1,1));r[d].applyMatrix4(o.makeRotationAxis(s,e))}a[d].crossVectors(n[d],r[d])}if(!0===t){let t=Math.acos(os(r[0].dot(r[e]),-1,1));t/=e,n[0].dot(s.crossVectors(r[0],r[e]))>0&&(t=-t);for(let i=1;i<=e;i++)r[i].applyMatrix4(o.makeRotationAxis(n[i],t*i)),a[i].crossVectors(n[i],r[i])}return{tangents:n,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}},Kh=class extends Ba{constructor(e=0,t=0,i=1,n=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=i,this.yRadius=n,this.aStartAngle=r,this.aEndAngle=a,this.aClockwise=s,this.aRotation=o}getPoint(e,t){let i=t||new xe,n=2*Math.PI,r=this.aEndAngle-this.aStartAngle,a=Math.abs(r)<Number.EPSILON;for(;r<0;)r+=n;for(;r>n;)r-=n;r<Number.EPSILON&&(r=a?0:n),!0===this.aClockwise&&!a&&(r===n?r=-n:r-=n);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),i=o-this.aX,n=l-this.aY;o=i*e-n*t+this.aX,l=i*t+n*e+this.aY}return i.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}},bm=class extends Kh{constructor(e,t,i,n,r,a){super(e,t,i,i,n,r,a),this.isArcCurve=!0,this.type="ArcCurve"}};function VU(){let e=0,t=0,i=0,n=0;function r(r,a,s,o){e=r,t=s,i=-3*r+3*a-2*s-o,n=2*r-2*a+s+o}return{initCatmullRom:function(e,t,i,n,a){r(t,i,a*(i-e),a*(n-t))},initNonuniformCatmullRom:function(e,t,i,n,a,s,o){let l=(t-e)/a-(i-e)/(a+s)+(i-t)/s,h=(i-t)/s-(n-t)/(s+o)+(n-i)/o;l*=s,h*=s,r(t,i,l,h)},calc:function(r){let a=r*r;return e+t*r+i*a+n*(a*r)}}}var KM=new D,VN=new VU,zN=new VU,GN=new VU,RR=class extends Ba{constructor(e=[],t=!1,i="centripetal",n=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=i,this.tension=n}getPoint(e,t=new D){let i,n,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?i=a[(l-1)%s]:(KM.subVectors(a[0],a[1]).add(a[0]),i=KM);let c=a[l%s],u=a[(l+1)%s];if(this.closed||l+2<s?n=a[(l+2)%s]:(KM.subVectors(a[s-1],a[s-2]).add(a[s-1]),n=KM),"centripetal"===this.curveType||"chordal"===this.curveType){let e="chordal"===this.curveType?.5:.25,t=Math.pow(i.distanceToSquared(c),e),r=Math.pow(c.distanceToSquared(u),e),a=Math.pow(u.distanceToSquared(n),e);r<1e-4&&(r=1),t<1e-4&&(t=r),a<1e-4&&(a=r),VN.initNonuniformCatmullRom(i.x,c.x,u.x,n.x,t,r,a),zN.initNonuniformCatmullRom(i.y,c.y,u.y,n.y,t,r,a),GN.initNonuniformCatmullRom(i.z,c.z,u.z,n.z,t,r,a)}else"catmullrom"===this.curveType&&(VN.initCatmullRom(i.x,c.x,u.x,n.x,this.tension),zN.initCatmullRom(i.y,c.y,u.y,n.y,this.tension),GN.initCatmullRom(i.z,c.z,u.z,n.z,this.tension));return r.set(VN.calc(h),zN.calc(h),GN.calc(h)),r}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let i=e.points[t];this.points.push(i.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,i=this.points.length;t<i;t++){let i=this.points[t];e.points.push(i.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,i=e.points.length;t<i;t++){let i=e.points[t];this.points.push((new D).fromArray(i))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}};function eue(e,t,i,n,r){let a=.5*(n-t),s=.5*(r-i),o=e*e;return(2*i-2*n+a+s)*(e*o)+(-3*i+3*n-2*a-s)*o+a*e+i}function Mat(e,t){let i=1-e;return i*i*t}function Rat(e,t){return 2*(1-e)*e*t}function Aat(e,t){return e*e*t}function hb(e,t,i,n){return Mat(e,t)+Rat(e,i)+Aat(e,n)}function Cat(e,t){let i=1-e;return i*i*i*t}function Pat(e,t){let i=1-e;return 3*i*i*e*t}function Iat(e,t){return 3*(1-e)*e*e*t}function Lat(e,t){return e*e*e*t}function db(e,t,i,n,r){return Cat(e,t)+Pat(e,i)+Iat(e,n)+Lat(e,r)}var Sb=class extends Ba{constructor(e=new xe,t=new xe,i=new xe,n=new xe){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=i,this.v3=n}getPoint(e,t=new xe){let i=t,n=this.v0,r=this.v1,a=this.v2,s=this.v3;return i.set(db(e,n.x,r.x,a.x,s.x),db(e,n.y,r.y,a.y,s.y)),i}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}},AR=class extends Ba{constructor(e=new D,t=new D,i=new D,n=new D){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=i,this.v3=n}getPoint(e,t=new D){let i=t,n=this.v0,r=this.v1,a=this.v2,s=this.v3;return i.set(db(e,n.x,r.x,a.x,s.x),db(e,n.y,r.y,a.y,s.y),db(e,n.z,r.z,a.z,s.z)),i}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}},hv=class extends Ba{constructor(e=new xe,t=new xe){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new xe){let i=t;return 1===e?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new xe){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}},CR=class extends Ba{constructor(e=new D,t=new D){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new D){let i=t;return 1===e?i.copy(this.v2):(i.copy(this.v2).sub(this.v1),i.multiplyScalar(e).add(this.v1)),i}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new D){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}},Mb=class extends Ba{constructor(e=new xe,t=new xe,i=new xe){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new xe){let i=t,n=this.v0,r=this.v1,a=this.v2;return i.set(hb(e,n.x,r.x,a.x),hb(e,n.y,r.y,a.y)),i}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}},Rb=class extends Ba{constructor(e=new D,t=new D,i=new D){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new D){let i=t,n=this.v0,r=this.v1,a=this.v2;return i.set(hb(e,n.x,r.x,a.x),hb(e,n.y,r.y,a.y),hb(e,n.z,r.z,a.z)),i}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}},Em=class extends Ba{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new xe){let i=t,n=this.points,r=(n.length-1)*e,a=Math.floor(r),s=r-a,o=n[0===a?a:a-1],l=n[a],h=n[a>n.length-2?n.length-1:a+1],c=n[a>n.length-3?n.length-1:a+2];return i.set(eue(s,o.x,l.x,h.x,c.x),eue(s,o.y,l.y,h.y,c.y)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let i=e.points[t];this.points.push(i.clone())}return this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,i=this.points.length;t<i;t++){let i=this.points[t];e.points.push(i.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,i=e.points.length;t<i;t++){let i=e.points[t];this.points.push((new xe).fromArray(i))}return this}},zU=Object.freeze({__proto__:null,ArcCurve:bm,CatmullRomCurve3:RR,CubicBezierCurve:Sb,CubicBezierCurve3:AR,EllipseCurve:Kh,LineCurve:hv,LineCurve3:CR,QuadraticBezierCurve:Mb,QuadraticBezierCurve3:Rb,SplineCurve:Em}),PR=class extends Ba{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 hv(t,e))}getPoint(e,t){let i=e*this.getLength(),n=this.getCurveLengths(),r=0;for(;r<n.length;){if(n[r]>=i){let e=n[r]-i,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 i=0,n=this.curves.length;i<n;i++)t+=this.curves[i].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){let t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){let t,i=[];for(let n=0,r=this.curves;n<r.length;n++){let a=r[n],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 n=o[e];t&&t.equals(n)||(i.push(n),t=n)}}return this.autoClose&&i.length>1&&!i[i.length-1].equals(i[0])&&i.push(i[0]),i}copy(e){super.copy(e),this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){let i=e.curves[t];this.curves.push(i.clone())}return this.autoClose=e.autoClose,this}toJSON(){let e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,i=this.curves.length;t<i;t++){let i=this.curves[t];e.curves.push(i.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,i=e.curves.length;t<i;t++){let i=e.curves[t];this.curves.push((new zU[i.type]).fromJSON(i))}return this}},Mu=class extends PR{constructor(e){super(),this.type="Path",this.currentPoint=new xe,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,i=e.length;t<i;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 i=new hv(this.currentPoint.clone(),new xe(e,t));return this.curves.push(i),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,i,n){let r=new Mb(this.currentPoint.clone(),new xe(e,t),new xe(i,n));return this.curves.push(r),this.currentPoint.set(i,n),this}bezierCurveTo(e,t,i,n,r,a){let s=new Sb(this.currentPoint.clone(),new xe(e,t),new xe(i,n),new xe(r,a));return this.curves.push(s),this.currentPoint.set(r,a),this}splineThru(e){let t=[this.currentPoint.clone()].concat(e),i=new Em(t);return this.curves.push(i),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,i,n,r,a){let s=this.currentPoint.x,o=this.currentPoint.y;return this.absarc(e+s,t+o,i,n,r,a),this}absarc(e,t,i,n,r,a){return this.absellipse(e,t,i,i,n,r,a),this}ellipse(e,t,i,n,r,a,s,o){let l=this.currentPoint.x,h=this.currentPoint.y;return this.absellipse(e+l,t+h,i,n,r,a,s,o),this}absellipse(e,t,i,n,r,a,s,o){let l=new Kh(e,t,i,n,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}},_m=class extends Dt{constructor(e=[new xe(0,-.5),new xe(.5,0),new xe(0,.5)],t=12,i=0,n=2*Math.PI){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:i,phiLength:n},t=Math.floor(t),n=os(n,0,2*Math.PI);let r=[],a=[],s=[],o=[],l=[],h=1/t,c=new D,u=new xe,d=new D,p=new D,f=new D,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=i+v*h*n,d=Math.sin(r),p=Math.cos(r);for(let i=0;i<=e.length-1;i++){c.x=e[i].x*d,c.y=e[i].y,c.z=e[i].x*p,a.push(c.x,c.y,c.z),u.x=v/t,u.y=i/(e.length-1),s.push(u.x,u.y);let n=o[3*i+0]*d,r=o[3*i+1],h=o[3*i+0]*p;l.push(n,r,h)}}for(let v=0;v<t;v++)for(let t=0;t<e.length-1;t++){let i=t+v*e.length,n=i,a=i+e.length,s=i+e.length+1,o=i+1;r.push(n,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 _m(e.points,e.segments,e.phiStart,e.phiLength)}},dv=class extends _m{constructor(e=1,t=1,i=4,n=8){let r=new Mu;r.absarc(0,-t/2,e,1.5*Math.PI,0),r.absarc(0,t/2,e,0,.5*Math.PI),super(r.getPoints(i),n),this.type="CapsuleGeometry",this.parameters={radius:e,length:t,capSegments:i,radialSegments:n}}static fromJSON(e){return new dv(e.radius,e.length,e.capSegments,e.radialSegments)}},fv=class extends Dt{constructor(e=1,t=32,i=0,n=2*Math.PI){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:i,thetaLength:n},t=Math.max(3,t);let r=[],a=[],s=[],o=[],l=new D,h=new xe;a.push(0,0,0),s.push(0,0,1),o.push(.5,.5);for(let c=0,u=3;c<=t;c++,u+=3){let r=i+c/t*n;l.x=e*Math.cos(r),l.y=e*Math.sin(r),a.push(l.x,l.y,l.z),s.push(0,0,1),h.x=(a[u]/e+1)/2,h.y=(a[u+1]/e+1)/2,o.push(h.x,h.y)}for(let c=1;c<=t;c++)r.push(c,c+1,0);this.setIndex(r),this.setAttribute("position",new 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 fv(e.radius,e.segments,e.thetaStart,e.thetaLength)}},Tc=class extends Dt{constructor(e=1,t=1,i=1,n=32,r=1,a=!1,s=0,o=2*Math.PI){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:i,radialSegments:n,heightSegments:r,openEnded:a,thetaStart:s,thetaLength:o};let l=this;n=Math.floor(n),r=Math.floor(r);let h=[],c=[],u=[],d=[],p=0,f=[],m=i/2,g=0;function v(i){let r=p,a=new xe,f=new D,v=0,y=!0===i?e:t,x=!0===i?1:-1;for(let e=1;e<=n;e++)c.push(0,m*x,0),u.push(0,x,0),d.push(.5,.5),p++;let b=p;for(let e=0;e<=n;e++){let t=e/n*o+s,i=Math.cos(t),r=Math.sin(t);f.x=y*r,f.y=m*x,f.z=y*i,c.push(f.x,f.y,f.z),u.push(0,x,0),a.x=.5*i+.5,a.y=.5*r*x+.5,d.push(a.x,a.y),p++}for(let e=0;e<n;e++){let t=r+e,n=b+e;!0===i?h.push(n,n+1,t):h.push(n+1,n,t),v+=3}l.addGroup(g,v,!0===i?1:2),g+=v}(function(){let a=new D,v=new D,y=0,x=(t-e)/i;for(let l=0;l<=r;l++){let h=[],g=l/r,y=g*(t-e)+e;for(let e=0;e<=n;e++){let t=e/n,r=t*o+s,l=Math.sin(r),f=Math.cos(r);v.x=y*l,v.y=-g*i+m,v.z=y*f,c.push(v.x,v.y,v.z),a.set(l,x,f).normalize(),u.push(a.x,a.y,a.z),d.push(t,1-g),h.push(p++)}f.push(h)}for(let e=0;e<n;e++)for(let t=0;t<r;t++){let i=f[t][e],n=f[t+1][e],r=f[t+1][e+1],a=f[t][e+1];h.push(i,n,a),h.push(n,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(c,3)),this.setAttribute("normal",new Bt(u,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 Tc(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},pv=class extends Tc{constructor(e=1,t=1,i=32,n=1,r=!1,a=0,s=2*Math.PI){super(0,e,t,i,n,r,a,s),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:i,heightSegments:n,openEnded:r,thetaStart:a,thetaLength:s}}static fromJSON(e){return new pv(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},Ru=class extends Dt{constructor(e=[],t=[],i=1,n=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:i,detail:n};let r=[],a=[];function s(e,t,i,n){let r=n+1,a=[];for(let s=0;s<=r;s++){a[s]=[];let n=e.clone().lerp(i,s/r),o=t.clone().lerp(i,s/r),l=r-s;for(let e=0;e<=l;e++)a[s][e]=0===e&&s===r?n:n.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,i){let n=3*t;i.x=e[n+0],i.y=e[n+1],i.z=e[n+2]}function h(e,t,i,n){n<0&&1===e.x&&(a[t]=e.x-1),0===i.x&&0===i.z&&(a[t]=n/2/Math.PI+.5)}function c(e){return Math.atan2(e.z,-e.x)}function u(e){return Math.atan2(-e.y,Math.sqrt(e.x*e.x+e.z*e.z))}(function(e){let i=new D,n=new D,r=new D;for(let a=0;a<t.length;a+=3)l(t[a+0],i),l(t[a+1],n),l(t[a+2],r),s(i,n,r,e)})(n),function(e){let t=new D;for(let i=0;i<r.length;i+=3)t.x=r[i+0],t.y=r[i+1],t.z=r[i+2],t.normalize().multiplyScalar(e),r[i+0]=t.x,r[i+1]=t.y,r[i+2]=t.z}(i),function(){let e=new D;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 i=c(e)/2/Math.PI+.5,n=u(e)/Math.PI+.5;a.push(i,1-n)}(function(){let e=new D,t=new D,i=new D,n=new D,s=new xe,o=new xe,l=new xe;for(let u=0,d=0;u<r.length;u+=9,d+=6){e.set(r[u+0],r[u+1],r[u+2]),t.set(r[u+3],r[u+4],r[u+5]),i.set(r[u+6],r[u+7],r[u+8]),s.set(a[d+0],a[d+1]),o.set(a[d+2],a[d+3]),l.set(a[d+4],a[d+5]),n.copy(e).add(t).add(i).divideScalar(3);let p=c(n);h(s,d+0,e,p),h(o,d+2,t,p),h(l,d+4,i,p)}})(),function(){for(let e=0;e<a.length;e+=6){let t=a[e+0],i=a[e+2],n=a[e+4],r=Math.max(t,i,n),s=Math.min(t,i,n);r>.9&&s<.1&&(t<.2&&(a[e+0]+=1),i<.2&&(a[e+2]+=1),n<.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===n?this.computeVertexNormals():this.normalizeNormals()}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Ru(e.vertices,e.indices,e.radius,e.details)}},mv=class extends Ru{constructor(e=1,t=0){let i=(1+Math.sqrt(5))/2,n=1/i;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,-n,-i,0,-n,i,0,n,-i,0,n,i,-n,-i,0,-n,i,0,n,-i,0,n,i,0,-i,0,-n,i,0,-n,-i,0,n,i,0,n],[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 mv(e.radius,e.detail)}},JM=new D,QM=new D,qN=new D,eR=new Zr,Au=class extends Dt{constructor(e=null,t=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:e,thresholdAngle:t},null!==e){let i=Math.pow(10,4),n=Math.cos(gm*t),r=e.getIndex(),a=e.getAttribute("position"),s=r?r.count:a.count,o=[0,0,0],l=["a","b","c"],h=new Array(3),c={},u=[];for(let e=0;e<s;e+=3){r?(o[0]=r.getX(e),o[1]=r.getX(e+1),o[2]=r.getX(e+2)):(o[0]=e,o[1]=e+1,o[2]=e+2);let{a:t,b:s,c:d}=eR;if(t.fromBufferAttribute(a,o[0]),s.fromBufferAttribute(a,o[1]),d.fromBufferAttribute(a,o[2]),eR.getNormal(qN),h[0]=`${Math.round(t.x*i)},${Math.round(t.y*i)},${Math.round(t.z*i)}`,h[1]=`${Math.round(s.x*i)},${Math.round(s.y*i)},${Math.round(s.z*i)}`,h[2]=`${Math.round(d.x*i)},${Math.round(d.y*i)},${Math.round(d.z*i)}`,h[0]!==h[1]&&h[1]!==h[2]&&h[2]!==h[0])for(let e=0;e<3;e++){let t=(e+1)%3,i=h[e],r=h[t],a=eR[l[e]],s=eR[l[t]],d=`${i}_${r}`,p=`${r}_${i}`;p in c&&c[p]?(qN.dot(c[p].normal)<=n&&(u.push(a.x,a.y,a.z),u.push(s.x,s.y,s.z)),c[p]=null):d in c||(c[d]={index0:o[e],index1:o[t],normal:qN.clone()})}}for(let e in c)if(c[e]){let{index0:t,index1:i}=c[e];JM.fromBufferAttribute(a,t),QM.fromBufferAttribute(a,i),u.push(JM.x,JM.y,JM.z),u.push(QM.x,QM.y,QM.z)}this.setAttribute("position",new Bt(u,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}},_s=class extends Mu{constructor(e){super(e),this.uuid=qo(),this.type="Shape",this.holes=[]}getPointsHoles(e){let t=[];for(let i=0,n=this.holes.length;i<n;i++)t[i]=this.holes[i].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,i=e.holes.length;t<i;t++){let i=e.holes[t];this.holes.push(i.clone())}return this}toJSON(){let e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,i=this.holes.length;t<i;t++){let i=this.holes[t];e.holes.push(i.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,i=e.holes.length;t<i;t++){let i=e.holes[t];this.holes.push((new Mu).fromJSON(i))}return this}},Dat={triangulate:function(e,t,i=2){let n,r,a,s,o,l,h,c=t&&t.length,u=c?t[0]*i:e.length,d=Rhe(e,0,u,i,!0),p=[];if(!d||d.next===d.prev)return p;if(c&&(d=Bat(e,t,d,i)),e.length>80*i){n=a=e[0],r=s=e[1];for(let t=i;t<u;t+=i)o=e[t],l=e[t+1],o<n&&(n=o),l<r&&(r=l),o>a&&(a=o),l>s&&(s=l);h=Math.max(a-n,s-r),h=0!==h?32767/h:0}return Ab(d,p,i,n,r,h,0),p}};function Rhe(e,t,i,n,r){let a,s;if(r===$at(e,t,i,n)>0)for(a=t;a<i;a+=n)s=tue(a,e[a],e[a+1],s);else for(a=i-n;a>=t;a-=n)s=tue(a,e[a],e[a+1],s);return s&&QR(s,s.next)&&(Pb(s),s=s.next),s}function Tm(e,t){if(!e)return e;t||(t=e);let i,n=e;do{if(i=!1,n.steiner||!QR(n,n.next)&&0!==Ki(n.prev,n,n.next))n=n.next;else{if(Pb(n),n=t=n.prev,n===n.next)break;i=!0}}while(i||n!==t);return t}function Ab(e,t,i,n,r,a,s){if(!e)return;!s&&a&&Gat(e,n,r,a);let o,l,h=e;for(;e.prev!==e.next;)if(o=e.prev,l=e.next,a?kat(e,n,r,a):Oat(e))t.push(o.i/i|0),t.push(e.i/i|0),t.push(l.i/i|0),Pb(e),e=l.next,h=l.next;else if((e=l)===h){s?1===s?Ab(e=Fat(Tm(e),t,i),t,i,n,r,a,2):2===s&&Nat(e,t,i,n,r,a):Ab(Tm(e),t,i,n,r,a,1);break}}function Oat(e){let t=e.prev,i=e,n=e.next;if(Ki(t,i,n)>=0)return!1;let r=t.x,a=i.x,s=n.x,o=t.y,l=i.y,h=n.y,c=r<a?r<s?r:s:a<s?a:s,u=o<l?o<h?o:h:l<h?l:h,d=r>a?r>s?r:s:a>s?a:s,p=o>l?o>h?o:h:l>h?l:h,f=n.next;for(;f!==t;){if(f.x>=c&&f.x<=d&&f.y>=u&&f.y<=p&&rv(r,o,a,l,s,h,f.x,f.y)&&Ki(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function kat(e,t,i,n){let r=e.prev,a=e,s=e.next;if(Ki(r,a,s)>=0)return!1;let o=r.x,l=a.x,h=s.x,c=r.y,u=a.y,d=s.y,p=o<l?o<h?o:h:l<h?l:h,f=c<u?c<d?c:d:u<d?u:d,m=o>l?o>h?o:h:l>h?l:h,g=c>u?c>d?c:d:u>d?u:d,v=jB(p,f,t,i,n),y=jB(m,g,t,i,n),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&&rv(o,c,l,u,h,d,x.x,x.y)&&Ki(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&&rv(o,c,l,u,h,d,b.x,b.y)&&Ki(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&&rv(o,c,l,u,h,d,x.x,x.y)&&Ki(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&&rv(o,c,l,u,h,d,b.x,b.y)&&Ki(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function Fat(e,t,i){let n=e;do{let r=n.prev,a=n.next.next;!QR(r,a)&&Ahe(r,n,n.next,a)&&Cb(r,a)&&Cb(a,r)&&(t.push(r.i/i|0),t.push(n.i/i|0),t.push(a.i/i|0),Pb(n),Pb(n.next),n=e=a),n=n.next}while(n!==e);return Tm(n)}function Nat(e,t,i,n,r,a){let s=e;do{let e=s.next.next;for(;e!==s.prev;){if(s.i!==e.i&&jat(s,e)){let o=Che(s,e);return s=Tm(s,s.next),o=Tm(o,o.next),Ab(s,t,i,n,r,a,0),void Ab(o,t,i,n,r,a,0)}e=e.next}s=s.next}while(s!==e)}function Bat(e,t,i,n){let r,a,s,o,l,h=[];for(r=0,a=t.length;r<a;r++)s=t[r]*n,o=r<a-1?t[r+1]*n:e.length,l=Rhe(e,s,o,n,!1),l===l.next&&(l.steiner=!0),h.push(Wat(l));for(h.sort(Uat),r=0;r<h.length;r++)i=Hat(h[r],i);return i}function Uat(e,t){return e.x-t.x}function Hat(e,t){let i=Vat(e,t);if(!i)return t;let n=Che(i,e);return Tm(n,n.next),Tm(i,i.next)}function Vat(e,t){let i,n=t,r=-1/0,a=e.x,s=e.y;do{if(s<=n.y&&s>=n.next.y&&n.next.y!==n.y){let e=n.x+(s-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(e<=a&&e>r&&(r=e,i=n.x<n.next.x?n:n.next,e===a))return i}n=n.next}while(n!==t);if(!i)return null;let o,l=i,h=i.x,c=i.y,u=1/0;n=i;do{a>=n.x&&n.x>=h&&a!==n.x&&rv(s<c?a:r,s,h,c,s<c?r:a,s,n.x,n.y)&&(o=Math.abs(s-n.y)/(a-n.x),Cb(n,e)&&(o<u||o===u&&(n.x>i.x||n.x===i.x&&zat(i,n)))&&(i=n,u=o)),n=n.next}while(n!==l);return i}function zat(e,t){return Ki(e.prev,e,t.prev)<0&&Ki(t.next,e,e.next)<0}function Gat(e,t,i,n){let r=e;do{0===r.z&&(r.z=jB(r.x,r.y,t,i,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==e);r.prevZ.nextZ=null,r.prevZ=null,qat(r)}function qat(e){let t,i,n,r,a,s,o,l,h=1;do{for(i=e,e=null,a=null,s=0;i;){for(s++,n=i,o=0,t=0;t<h&&(o++,n=n.nextZ,n);t++);for(l=h;o>0||l>0&&n;)0!==o&&(0===l||!n||i.z<=n.z)?(r=i,i=i.nextZ,o--):(r=n,n=n.nextZ,l--),a?a.nextZ=r:e=r,r.prevZ=a,a=r;i=n}a.nextZ=null,h*=2}while(s>1);return e}function jB(e,t,i,n,r){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-i)*r|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-n)*r|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function Wat(e){let t=e,i=e;do{(t.x<i.x||t.x===i.x&&t.y<i.y)&&(i=t),t=t.next}while(t!==e);return i}function rv(e,t,i,n,r,a,s,o){return(r-s)*(t-o)>=(e-s)*(a-o)&&(e-s)*(n-o)>=(i-s)*(t-o)&&(i-s)*(a-o)>=(r-s)*(n-o)}function jat(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!Xat(e,t)&&(Cb(e,t)&&Cb(t,e)&&Yat(e,t)&&(Ki(e.prev,e,t.prev)||Ki(e,t.prev,t))||QR(e,t)&&Ki(e.prev,e,e.next)>0&&Ki(t.prev,t,t.next)>0)}function Ki(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function QR(e,t){return e.x===t.x&&e.y===t.y}function Ahe(e,t,i,n){let r=nR(Ki(e,t,i)),a=nR(Ki(e,t,n)),s=nR(Ki(i,n,e)),o=nR(Ki(i,n,t));return!!(r!==a&&s!==o||0===r&&tR(e,i,t)||0===a&&tR(e,n,t)||0===s&&tR(i,e,n)||0===o&&tR(i,t,n))}function tR(e,t,i){return t.x<=Math.max(e.x,i.x)&&t.x>=Math.min(e.x,i.x)&&t.y<=Math.max(e.y,i.y)&&t.y>=Math.min(e.y,i.y)}function nR(e){return e>0?1:e<0?-1:0}function Xat(e,t){let i=e;do{if(i.i!==e.i&&i.next.i!==e.i&&i.i!==t.i&&i.next.i!==t.i&&Ahe(i,i.next,e,t))return!0;i=i.next}while(i!==e);return!1}function Cb(e,t){return Ki(e.prev,e,e.next)<0?Ki(e,t,e.next)>=0&&Ki(e,e.prev,t)>=0:Ki(e,t,e.prev)<0||Ki(e,e.next,t)<0}function Yat(e,t){let i=e,n=!1,r=(e.x+t.x)/2,a=(e.y+t.y)/2;do{i.y>a!=i.next.y>a&&i.next.y!==i.y&&r<(i.next.x-i.x)*(a-i.y)/(i.next.y-i.y)+i.x&&(n=!n),i=i.next}while(i!==e);return n}function Che(e,t){let i=new XB(e.i,e.x,e.y),n=new XB(t.i,t.x,t.y),r=e.next,a=t.prev;return e.next=t,t.prev=e,i.next=r,r.prev=i,n.next=i,i.prev=n,a.next=n,n.prev=a,n}function tue(e,t,i,n){let r=new XB(e,t,i);return n?(r.next=n.next,r.prev=n,n.next.prev=r,n.next=r):(r.prev=r,r.next=r),r}function Pb(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 XB(e,t,i){this.i=e,this.x=t,this.y=i,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function $at(e,t,i,n){let r=0;for(let a=t,s=i-n;a<i;a+=n)r+=(e[s]-e[a])*(e[a+1]+e[s+1]),s=a;return r}var zs=class{static area(e){let t=e.length,i=0;for(let n=t-1,r=0;r<t;n=r++)i+=e[n].x*e[r].y-e[r].x*e[n].y;return.5*i}static isClockWise(e){return zs.area(e)<0}static triangulateShape(e,t){let i=[],n=[],r=[];nue(e),rue(i,e);let a=e.length;t.forEach(nue);for(let o=0;o<t.length;o++)n.push(a),a+=t[o].length,rue(i,t[o]);let s=Dat.triangulate(i,n);for(let o=0;o<s.length;o+=3)r.push(s.slice(o,o+3));return r}};function nue(e){let t=e.length;t>2&&e[t-1].equals(e[0])&&e.pop()}function rue(e,t){for(let i=0;i<t.length;i++)e.push(t[i].x),e.push(t[i].y)}var Qs=class extends Dt{constructor(e=new _s([new xe(.5,.5),new xe(-.5,.5),new xe(-.5,-.5),new xe(.5,-.5)]),t={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];let i=this,n=[],r=[];for(let s=0,o=e.length;s<o;s++)a(e[s]);function a(e){let a,s,o,l,h,c=[],u=void 0!==t.curveSegments?t.curveSegments:12,d=void 0!==t.steps?t.steps:1,p=void 0!==t.depth?t.depth:1,f=void 0===t.bevelEnabled||t.bevelEnabled,m=void 0!==t.bevelThickness?t.bevelThickness:.2,g=void 0!==t.bevelSize?t.bevelSize:m-.1,v=void 0!==t.bevelOffset?t.bevelOffset:0,y=void 0!==t.bevelSegments?t.bevelSegments:3,x=t.extrudePath,b=void 0!==t.UVGenerator?t.UVGenerator:Zat,_=!1;x&&(a=x.getSpacedPoints(d),_=!0,f=!1,s=x.computeFrenetFrames(d,!1),o=new D,l=new D,h=new D),f||(y=0,m=0,g=0,v=0);let w=e.extractPoints(u),S=w.shape,M=w.holes;if(!zs.isClockWise(S)){S=S.reverse();for(let e=0,t=M.length;e<t;e++){let t=M[e];zs.isClockWise(t)&&(M[e]=t.reverse())}}let E=zs.triangulateShape(S,M),T=S;for(let t=0,i=M.length;t<i;t++){let e=M[t];S=S.concat(e)}function A(e,t,i){return t||console.error("THREE.ExtrudeGeometry: vec does not exist"),e.clone().addScaledVector(t,i)}let C=S.length,P=E.length;function R(e,t,i){let n,r,a,s=e.x-t.x,o=e.y-t.y,l=i.x-e.x,h=i.y-e.y,c=s*s+o*o,u=s*h-o*l;if(Math.abs(u)>Number.EPSILON){let u=Math.sqrt(c),d=Math.sqrt(l*l+h*h),p=t.x-o/u,f=t.y+s/u,m=((i.x-h/d-p)*h-(i.y+l/d-f)*l)/(s*h-o*l);n=p+s*m-e.x,r=f+o*m-e.y;let g=n*n+r*r;if(g<=2)return new xe(n,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?(n=-o,r=s,a=Math.sqrt(c)):(n=s,r=o,a=Math.sqrt(c/2))}return new xe(n/a,r/a)}let L=[];for(let t=0,i=T.length,n=i-1,r=t+1;t<i;t++,n++,r++)n===i&&(n=0),r===i&&(r=0),L[t]=R(T[t],T[n],T[r]);let I,O=[],k=L.concat();for(let t=0,i=M.length;t<i;t++){let e=M[t];I=[];for(let t=0,i=e.length,n=i-1,r=t+1;t<i;t++,n++,r++)n===i&&(n=0),r===i&&(r=0),I[t]=R(e[t],e[n],e[r]);O.push(I),k=k.concat(I)}for(let t=0;t<y;t++){let e=t/y,i=m*Math.cos(e*Math.PI/2),n=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],n);F(e.x,e.y,-i)}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],n);F(r.x,r.y,-i)}}}let N=g+v;for(let t=0;t<C;t++){let e=f?A(S[t],k[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 i=f?A(S[e],k[e],N):S[e];_?(l.copy(s.normals[t]).multiplyScalar(i.x),o.copy(s.binormals[t]).multiplyScalar(i.y),h.copy(a[t]).add(l).add(o),F(h.x,h.y,h.z)):F(i.x,i.y,p/d*t)}for(let t=y-1;t>=0;t--){let e=t/y,i=m*Math.cos(e*Math.PI/2),n=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],n);F(e.x,e.y,p+i)}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],n);_?F(r.x,r.y+a[d-1].y,a[d-1].x+i):F(r.x,r.y,p+i)}}}function U(e,t){let i=e.length;for(;--i>=0;){let n=i,r=i-1;r<0&&(r=e.length-1);for(let e=0,i=d+2*y;e<i;e++){let i=C*e,a=C*(e+1);z(t+n+i,t+r+i,t+r+a,t+n+a)}}}function F(e,t,i){c.push(e),c.push(t),c.push(i)}function B(e,t,r){H(e),H(t),H(r);let a=n.length/3,s=b.generateTopUV(i,n,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=n.length/3,o=b.generateSideWallUV(i,n,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){n.push(c[3*e+0]),n.push(c[3*e+1]),n.push(c[3*e+2])}function V(e){r.push(e.x),r.push(e.y)}(function(){let e=n.length/3;if(f){let e=0,t=C*e;for(let i=0;i<P;i++){let e=E[i];B(e[2]+t,e[1]+t,e[0]+t)}e=d+2*y,t=C*e;for(let i=0;i<P;i++){let e=E[i];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)}}i.addGroup(e,n.length/3-e,0)})(),function(){let e=n.length/3,t=0;U(T,t),t+=T.length;for(let i=0,n=M.length;i<n;i++){let e=M[i];U(e,t),t+=e.length}i.addGroup(e,n.length/3-e,1)}()}this.setAttribute("position",new Bt(n,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 Kat(this.parameters.shapes,this.parameters.options,e)}static fromJSON(e,t){let i=[];for(let r=0,a=e.shapes.length;r<a;r++){let n=t[e.shapes[r]];i.push(n)}let n=e.options.extrudePath;return void 0!==n&&(e.options.extrudePath=(new zU[n.type]).fromJSON(n)),new Qs(i,e.options)}},Zat={generateTopUV:function(e,t,i,n,r){let a=t[3*i],s=t[3*i+1],o=t[3*n],l=t[3*n+1],h=t[3*r],c=t[3*r+1];return[new xe(a,s),new xe(o,l),new xe(h,c)]},generateSideWallUV:function(e,t,i,n,r,a){let s=t[3*i],o=t[3*i+1],l=t[3*i+2],h=t[3*n],c=t[3*n+1],u=t[3*n+2],d=t[3*r],p=t[3*r+1],f=t[3*r+2],m=t[3*a],g=t[3*a+1],v=t[3*a+2];return Math.abs(o-c)<Math.abs(s-h)?[new xe(s,1-l),new xe(h,1-u),new xe(d,1-f),new xe(m,1-v)]:[new xe(o,1-l),new xe(c,1-u),new xe(p,1-f),new xe(g,1-v)]}};function Kat(e,t,i){if(i.shapes=[],Array.isArray(e))for(let n=0,r=e.length;n<r;n++){let t=e[n];i.shapes.push(t.uuid)}else i.shapes.push(e.uuid);return i.options=Object.assign({},t),void 0!==t.extrudePath&&(i.options.extrudePath=t.extrudePath.toJSON()),i}var gv=class extends Ru{constructor(e=1,t=0){let i=(1+Math.sqrt(5))/2;super([-1,i,0,1,i,0,-1,-i,0,1,-i,0,0,-1,i,0,1,i,0,-1,-i,0,1,-i,i,0,-1,i,0,1,-i,0,-1,-i,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 gv(e.radius,e.detail)}},wm=class extends Ru{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 wm(e.radius,e.detail)}},vv=class extends Dt{constructor(e=.5,t=1,i=32,n=1,r=0,a=2*Math.PI){super(),this.type="RingGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:i,phiSegments:n,thetaStart:r,thetaLength:a},i=Math.max(3,i);let s=[],o=[],l=[],h=[],c=e,u=(t-e)/(n=Math.max(1,n)),d=new D,p=new xe;for(let f=0;f<=n;f++){for(let e=0;e<=i;e++){let n=r+e/i*a;d.x=c*Math.cos(n),d.y=c*Math.sin(n),o.push(d.x,d.y,d.z),l.push(0,0,1),p.x=(d.x/t+1)/2,p.y=(d.y/t+1)/2,h.push(p.x,p.y)}c+=u}for(let f=0;f<n;f++){let e=f*(i+1);for(let t=0;t<i;t++){let n=t+e,r=n,a=n+i+1,o=n+i+2,l=n+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 vv(e.innerRadius,e.outerRadius,e.thetaSegments,e.phiSegments,e.thetaStart,e.thetaLength)}},Rl=class extends Dt{constructor(e=new _s([new xe(0,.5),new xe(-.5,-.5),new xe(.5,-.5)]),t=12){super(),this.type="ShapeGeometry",this.parameters={shapes:e,curveSegments:t};let i=[],n=[],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=n.length/3,l=e.extractPoints(t),h=l.shape,c=l.holes;!1===zs.isClockWise(h)&&(h=h.reverse());for(let t=0,i=c.length;t<i;t++){let e=c[t];!0===zs.isClockWise(e)&&(c[t]=e.reverse())}let u=zs.triangulateShape(h,c);for(let t=0,i=c.length;t<i;t++){let e=c[t];h=h.concat(e)}for(let t=0,i=h.length;t<i;t++){let e=h[t];n.push(e.x,e.y,0),r.push(0,0,1),a.push(e.x,e.y)}for(let t=0,n=u.length;t<n;t++){let e=u[t],n=e[0]+s,r=e[1]+s,a=e[2]+s;i.push(n,r,a),o+=3}}this.setIndex(i),this.setAttribute("position",new Bt(n,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 Jat(this.parameters.shapes,e)}static fromJSON(e,t){let i=[];for(let n=0,r=e.shapes.length;n<r;n++){let r=t[e.shapes[n]];i.push(r)}return new Rl(i,e.curveSegments)}};function Jat(e,t){if(t.shapes=[],Array.isArray(e))for(let i=0,n=e.length;i<n;i++){let n=e[i];t.shapes.push(n.uuid)}else t.shapes.push(e.uuid);return t}var Ua=class extends Dt{constructor(e=1,t=32,i=16,n=0,r=2*Math.PI,a=0,s=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:i,phiStart:n,phiLength:r,thetaStart:a,thetaLength:s},t=Math.max(3,Math.floor(t)),i=Math.max(2,Math.floor(i));let o=Math.min(a+s,Math.PI),l=0,h=[],c=new D,u=new D,d=[],p=[],f=[],m=[];for(let g=0;g<=i;g++){let d=[],v=g/i,y=0;0===g&&0===a?y=.5/t:g===i&&o===Math.PI&&(y=-.5/t);for(let i=0;i<=t;i++){let o=i/t;c.x=-e*Math.cos(n+o*r)*Math.sin(a+v*s),c.y=e*Math.cos(a+v*s),c.z=e*Math.sin(n+o*r)*Math.sin(a+v*s),p.push(c.x,c.y,c.z),u.copy(c).normalize(),f.push(u.x,u.y,u.z),m.push(o+y,1-v),d.push(l++)}h.push(d)}for(let g=0;g<i;g++)for(let e=0;e<t;e++){let t=h[g][e+1],n=h[g][e],r=h[g+1][e],s=h[g+1][e+1];(0!==g||a>0)&&d.push(t,n,s),(g!==i-1||o<Math.PI)&&d.push(n,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 Ua(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}},yv=class extends Ru{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 yv(e.radius,e.detail)}},pf=class extends Dt{constructor(e=1,t=.4,i=12,n=48,r=2*Math.PI){super(),this.type="TorusGeometry",this.parameters={radius:e,tube:t,radialSegments:i,tubularSegments:n,arc:r},i=Math.floor(i),n=Math.floor(n);let a=[],s=[],o=[],l=[],h=new D,c=new D,u=new D;for(let d=0;d<=i;d++)for(let a=0;a<=n;a++){let p=a/n*r,f=d/i*Math.PI*2;c.x=(e+t*Math.cos(f))*Math.cos(p),c.y=(e+t*Math.cos(f))*Math.sin(p),c.z=t*Math.sin(f),s.push(c.x,c.y,c.z),h.x=e*Math.cos(p),h.y=e*Math.sin(p),u.subVectors(c,h).normalize(),o.push(u.x,u.y,u.z),l.push(a/n),l.push(d/i)}for(let d=1;d<=i;d++)for(let e=1;e<=n;e++){let t=(n+1)*d+e-1,i=(n+1)*(d-1)+e-1,r=(n+1)*(d-1)+e,s=(n+1)*d+e;a.push(t,i,s),a.push(i,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 pf(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}},xv=class extends Dt{constructor(e=1,t=.4,i=64,n=8,r=2,a=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,tubularSegments:i,radialSegments:n,p:r,q:a},i=Math.floor(i),n=Math.floor(n);let s=[],o=[],l=[],h=[],c=new D,u=new D,d=new D,p=new D,f=new D,m=new D,g=new D;for(let y=0;y<=i;++y){let s=y/i*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<=n;++e){let r=e/n*Math.PI*2,a=-t*Math.cos(r),s=t*Math.sin(r);c.x=d.x+(a*g.x+s*f.x),c.y=d.y+(a*g.y+s*f.y),c.z=d.z+(a*g.z+s*f.z),o.push(c.x,c.y,c.z),u.subVectors(c,d).normalize(),l.push(u.x,u.y,u.z),h.push(y/i),h.push(e/n)}}for(let y=1;y<=i;y++)for(let e=1;e<=n;e++){let t=(n+1)*(y-1)+(e-1),i=(n+1)*y+(e-1),r=(n+1)*y+e,a=(n+1)*(y-1)+e;s.push(t,i,a),s.push(i,r,a)}function v(e,t,i,n,r){let a=Math.cos(e),s=Math.sin(e),o=i/t*e,l=Math.cos(o);r.x=n*(2+l)*.5*a,r.y=n*(2+l)*s*.5,r.z=n*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 xv(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}},bv=class extends Dt{constructor(e=new Rb(new D(-1,-1,0),new D(-1,1,0),new D(1,1,0)),t=64,i=1,n=8,r=!1){super(),this.type="TubeGeometry",this.parameters={path:e,tubularSegments:t,radius:i,radialSegments:n,closed:r};let a=e.computeFrenetFrames(t,r);this.tangents=a.tangents,this.normals=a.normals,this.binormals=a.binormals;let s=new D,o=new D,l=new xe,h=new D,c=[],u=[],d=[],p=[];function f(r){h=e.getPointAt(r/t,h);let l=a.normals[r],d=a.binormals[r];for(let e=0;e<=n;e++){let t=e/n*Math.PI*2,r=Math.sin(t),a=-Math.cos(t);o.x=a*l.x+r*d.x,o.y=a*l.y+r*d.y,o.z=a*l.z+r*d.z,o.normalize(),u.push(o.x,o.y,o.z),s.x=h.x+i*o.x,s.y=h.y+i*o.y,s.z=h.z+i*o.z,c.push(s.x,s.y,s.z)}}(function(){for(let e=0;e<t;e++)f(e);f(!1===r?t:0),function(){for(let e=0;e<=t;e++)for(let i=0;i<=n;i++)l.x=e/t,l.y=i/n,d.push(l.x,l.y)}(),function(){for(let e=1;e<=t;e++)for(let t=1;t<=n;t++){let i=(n+1)*(e-1)+(t-1),r=(n+1)*e+(t-1),a=(n+1)*e+t,s=(n+1)*(e-1)+t;p.push(i,r,s),p.push(r,a,s)}}()})(),this.setIndex(p),this.setAttribute("position",new Bt(c,3)),this.setAttribute("normal",new Bt(u,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 bv((new zU[e.path.type]).fromJSON(e.path),e.tubularSegments,e.radius,e.radialSegments,e.closed)}},IR=class extends Dt{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},null!==e){let t=[],i=new Set,n=new D,r=new D;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);n.fromBufferAttribute(a,o),r.fromBufferAttribute(a,h),!0===iue(n,r,i)&&(t.push(n.x,n.y,n.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;n.fromBufferAttribute(a,s),r.fromBufferAttribute(a,l),!0===iue(n,r,i)&&(t.push(n.x,n.y,n.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 iue(e,t,i){let n=`${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!==i.has(n)&&!0!==i.has(r)&&(i.add(n),i.add(r),!0)}var sue=Object.freeze({__proto__:null,BoxGeometry:pa,CapsuleGeometry:dv,CircleGeometry:fv,ConeGeometry:pv,CylinderGeometry:Tc,DodecahedronGeometry:mv,EdgesGeometry:Au,ExtrudeGeometry:Qs,IcosahedronGeometry:gv,LatheGeometry:_m,OctahedronGeometry:wm,PlaneGeometry:ui,PolyhedronGeometry:Ru,RingGeometry:vv,ShapeGeometry:Rl,SphereGeometry:Ua,TetrahedronGeometry:yv,TorusGeometry:pf,TorusKnotGeometry:xv,TubeGeometry:bv,WireframeGeometry:IR}),LR=class extends yr{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}},DR=class extends cn{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}},Cu=class extends yr{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=yf,this.normalScale=new xe(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}},jo=class extends Cu{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 xe(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return os(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}},ea=class extends yr{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=yf,this.normalScale=new xe(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=Hb,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}},OR=class extends yr{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=yf,this.normalScale=new xe(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}},mf=class extends yr{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=yf,this.normalScale=new xe(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}},Pu=class extends yr{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=yf,this.normalScale=new xe(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=Hb,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}},kR=class extends yr{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=yf,this.normalScale=new xe(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}},Iu=class extends Gn{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 Tl(e,t,i){return GU(e)?new e.constructor(e.subarray(t,void 0!==i?i:e.length)):e.slice(t,i)}function pm(e,t,i){return!e||!i&&e.constructor===t?e:"number"==typeof t.BYTES_PER_ELEMENT?new t(e):Array.prototype.slice.call(e)}function GU(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Phe(e){let t=e.length,i=new Array(t);for(let n=0;n!==t;++n)i[n]=n;return i.sort((function(t,i){return e[t]-e[i]})),i}function YB(e,t,i){let n=e.length,r=new e.constructor(n);for(let a=0,s=0;s!==n;++a){let n=i[a]*t;for(let i=0;i!==t;++i)r[s++]=e[n+i]}return r}function qU(e,t,i,n){let r=1,a=e[0];for(;void 0!==a&&void 0===a[n];)a=e[r++];if(void 0===a)return;let s=a[n];if(void 0!==s)if(Array.isArray(s))do{s=a[n],void 0!==s&&(t.push(a.time),i.push.apply(i,s)),a=e[r++]}while(void 0!==a);else if(void 0!==s.toArray)do{s=a[n],void 0!==s&&(t.push(a.time),s.toArray(i,i.length)),a=e[r++]}while(void 0!==a);else do{s=a[n],void 0!==s&&(t.push(a.time),i.push(s)),a=e[r++]}while(void 0!==a)}function Qat(e,t,i,n,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<i||s>=n)){o.push(e.times[a]);for(let i=0;i<t;++i)h.push(e.values[a*t+i])}}0!==o.length&&(e.times=pm(o,e.times.constructor),e.values=pm(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 eot(e,t=0,i=e,n=30){n<=0&&(n=30);let r=i.tracks.length,a=t/n;for(let s=0;s<r;++s){let t=i.tracks[s],n=t.ValueTypeName;if("bool"===n||"string"===n)continue;let r=e.tracks.find((function(e){return e.name===t.name&&e.ValueTypeName===n}));if(void 0===r)continue;let o=0,l=t.getValueSize();t.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(o=l/3);let h=0,c=r.getValueSize();r.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(h=c/3);let u,d=t.times.length-1;if(a<=t.times[0]){let e=o,i=l-o;u=Tl(t.values,e,i)}else if(a>=t.times[d]){let e=d*l+o,i=e+l-o;u=Tl(t.values,e,i)}else{let e=t.createInterpolant(),i=o,n=l-o;e.evaluate(a),u=Tl(e.resultBuffer,i,n)}"quaternion"===n&&(new dr).fromArray(u).normalize().conjugate().toArray(u);let p=r.times.length;for(let e=0;e<p;++e){let t=e*c+h;if("quaternion"===n)dr.multiplyQuaternionsFlat(r.values,t,u,0,r.values,t);else{let e=c-2*h;for(let i=0;i<e;++i)r.values[t+i]-=u[i]}}}return e.blendMode=kU,e}var tot={arraySlice:Tl,convertArray:pm,isTypedArray:GU,getKeyframeOrder:Phe,sortedArray:YB,flattenJSON:qU,subclip:Qat,makeClipAdditive:eot},Jh=class{constructor(e,t,i,n){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=void 0!==n?n:new t.constructor(i),this.sampleValues=t,this.valueSize=i,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,i=this._cachedIndex,n=t[i],r=t[i-1];e:{t:{let a;i:{n:if(!(e<n)){for(let a=i+2;;){if(void 0===n){if(e<r)break n;return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}if(i===a)break;if(r=n,n=t[++i],e<n)break t}a=t.length;break i}if(e>=r)break e;{let s=t[1];e<s&&(i=2,r=s);for(let a=i-2;;){if(void 0===r)return this._cachedIndex=0,this.copySampleValue_(0);if(i===a)break;if(n=r,r=t[--i-1],e>=r)break t}a=i,i=0}}for(;i<a;){let n=i+a>>>1;e<t[n]?a=n:i=n+1}if(n=t[i],r=t[i-1],void 0===r)return this._cachedIndex=0,this.copySampleValue_(0);if(void 0===n)return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}this._cachedIndex=i,this.intervalChanged_(i,r,n)}return this.interpolate_(i,r,e,n)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){let t=this.resultBuffer,i=this.sampleValues,n=this.valueSize,r=e*n;for(let a=0;a!==n;++a)t[a]=i[r+a];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}},FR=class extends Jh{constructor(e,t,i,n){super(e,t,i,n),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:dm,endingEnd:dm}}intervalChanged_(e,t,i){let n=this.parameterPositions,r=e-2,a=e+1,s=n[r],o=n[a];if(void 0===s)switch(this.getSettings_().endingStart){case fm:r=e,s=2*t-i;break;case pb:r=n.length-2,s=t+n[r]-n[r+1];break;default:r=e,s=i}if(void 0===o)switch(this.getSettings_().endingEnd){case fm:a=e,o=2*i-t;break;case pb:a=1,o=i+n[1]-n[0];break;default:a=e-1,o=t}let l=.5*(i-t),h=this.valueSize;this._weightPrev=l/(t-s),this._weightNext=l/(o-i),this._offsetPrev=r*h,this._offsetNext=a*h}interpolate_(e,t,i,n){let r=this.resultBuffer,a=this.sampleValues,s=this.valueSize,o=e*s,l=o-s,h=this._offsetPrev,c=this._offsetNext,u=this._weightPrev,d=this._weightNext,p=(i-t)/(n-t),f=p*p,m=f*p,g=-u*m+2*u*f-u*p,v=(1+u)*m+(-1.5-2*u)*f+(-.5+u)*p+1,y=(-1-d)*m+(1.5+d)*f+.5*p,x=d*m-d*f;for(let b=0;b!==s;++b)r[b]=g*a[h+b]+v*a[l+b]+y*a[o+b]+x*a[c+b];return r}},Ib=class extends Jh{constructor(e,t,i,n){super(e,t,i,n)}interpolate_(e,t,i,n){let r=this.resultBuffer,a=this.sampleValues,s=this.valueSize,o=e*s,l=o-s,h=(i-t)/(n-t),c=1-h;for(let u=0;u!==s;++u)r[u]=a[l+u]*c+a[o+u]*h;return r}},NR=class extends Jh{constructor(e,t,i,n){super(e,t,i,n)}interpolate_(e){return this.copySampleValue_(e-1)}},Xo=class{constructor(e,t,i,n){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=pm(t,this.TimeBufferType),this.values=pm(i,this.ValueBufferType),this.setInterpolation(n||this.DefaultInterpolation)}static toJSON(e){let t,i=e.constructor;if(i.toJSON!==this.toJSON)t=i.toJSON(e);else{t={name:e.name,times:pm(e.times,Array),values:pm(e.values,Array)};let i=e.getInterpolation();i!==e.DefaultInterpolation&&(t.interpolation=i)}return t.type=e.ValueTypeName,t}InterpolantFactoryMethodDiscrete(e){return new NR(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new Ib(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new FR(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case jh:t=this.InterpolantFactoryMethodDiscrete;break;case _u:t=this.InterpolantFactoryMethodLinear;break;case mR: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 jh;case this.InterpolantFactoryMethodLinear:return _u;case this.InterpolantFactoryMethodSmooth:return mR}}getValueSize(){return this.values.length/this.times.length}shift(e){if(0!==e){let t=this.times;for(let i=0,n=t.length;i!==n;++i)t[i]+=e}return this}scale(e){if(1!==e){let t=this.times;for(let i=0,n=t.length;i!==n;++i)t[i]*=e}return this}trim(e,t){let i=this.times,n=i.length,r=0,a=n-1;for(;r!==n&&i[r]<e;)++r;for(;-1!==a&&i[a]>t;)--a;if(++a,0!==r||a!==n){r>=a&&(a=Math.max(a,1),r=a-1);let e=this.getValueSize();this.times=Tl(i,r,a),this.values=Tl(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 i=this.times,n=this.values,r=i.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=i[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!==n&&GU(n))for(let s=0,o=n.length;s!==o;++s){let t=n[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=Tl(this.times),t=Tl(this.values),i=this.getValueSize(),n=this.getInterpolation()===mR,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(n)r=!0;else{let e=s*i,n=e-i,a=e+i;for(let s=0;s!==i;++s){let i=t[e+s];if(i!==t[n+s]||i!==t[a+s]){r=!0;break}}}if(r){if(s!==a){e[a]=e[s];let n=s*i,r=a*i;for(let e=0;e!==i;++e)t[r+e]=t[n+e]}++a}}if(r>0){e[a]=e[r];for(let e=r*i,n=a*i,s=0;s!==i;++s)t[n+s]=t[e+s];++a}return a!==e.length?(this.times=Tl(e,0,a),this.values=Tl(t,0,a*i)):(this.times=e,this.values=t),this}clone(){let e=Tl(this.times,0),t=Tl(this.values,0),i=new(0,this.constructor)(this.name,e,t);return i.createInterpolant=this.createInterpolant,i}};Xo.prototype.TimeBufferType=Float32Array,Xo.prototype.ValueBufferType=Float32Array,Xo.prototype.DefaultInterpolation=_u;var Qh=class extends Xo{};Qh.prototype.ValueTypeName="bool",Qh.prototype.ValueBufferType=Array,Qh.prototype.DefaultInterpolation=jh,Qh.prototype.InterpolantFactoryMethodLinear=void 0,Qh.prototype.InterpolantFactoryMethodSmooth=void 0;var Lb=class extends Xo{};Lb.prototype.ValueTypeName="color";var Al=class extends Xo{};Al.prototype.ValueTypeName="number";var BR=class extends Jh{constructor(e,t,i,n){super(e,t,i,n)}interpolate_(e,t,i,n){let r=this.resultBuffer,a=this.sampleValues,s=this.valueSize,o=(i-t)/(n-t),l=e*s;for(let h=l+s;l!==h;l+=4)dr.slerpFlat(r,0,a,l-s,a,l,o);return r}},Ha=class extends Xo{InterpolantFactoryMethodLinear(e){return new BR(this.times,this.values,this.getValueSize(),e)}};Ha.prototype.ValueTypeName="quaternion",Ha.prototype.DefaultInterpolation=_u,Ha.prototype.InterpolantFactoryMethodSmooth=void 0;var ed=class extends Xo{};ed.prototype.ValueTypeName="string",ed.prototype.ValueBufferType=Array,ed.prototype.DefaultInterpolation=jh,ed.prototype.InterpolantFactoryMethodLinear=void 0,ed.prototype.InterpolantFactoryMethodSmooth=void 0;var Va=class extends Xo{};Va.prototype.ValueTypeName="vector";var uo=class{constructor(e,t=-1,i,n=KR){this.name=e,this.tracks=i,this.duration=t,this.blendMode=n,this.uuid=qo(),this.duration<0&&this.resetDuration()}static parse(e){let t=[],i=e.tracks,n=1/(e.fps||1);for(let a=0,s=i.length;a!==s;++a)t.push(rot(i[a]).scale(n));let r=new this(e.name,e.duration,t,e.blendMode);return r.uuid=e.uuid,r}static toJSON(e){let t=[],i=e.tracks,n={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let r=0,a=i.length;r!==a;++r)t.push(Xo.toJSON(i[r]));return n}static CreateFromMorphTargetSequence(e,t,i,n){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=Phe(e);e=YB(e,1,l),o=YB(o,1,l),!n&&0===e[0]&&(e.push(r),o.push(o[0])),a.push(new Al(".morphTargetInfluences["+t[s].name+"]",e,o).scale(1/i))}return new this(e,-1,a)}static findByName(e,t){let i=e;if(!Array.isArray(e)){let t=e;i=t.geometry&&t.geometry.animations||t.animations}for(let n=0;n<i.length;n++)if(i[n].name===t)return i[n];return null}static CreateClipsFromMorphTargetSequences(e,t,i){let n={},r=/^([\w-]*?)([\d]+)$/;for(let s=0,o=e.length;s<o;s++){let t=e[s],i=t.name.match(r);if(i&&i.length>1){let e=i[1],r=n[e];r||(n[e]=r=[]),r.push(t)}}let a=[];for(let s in n)a.push(this.CreateFromMorphTargetSequence(s,n[s],t,i));return a}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;let i=function(e,t,i,n,r){if(0!==i.length){let a=[],s=[];qU(i,a,s,n),0!==a.length&&r.push(new e(t,a,s))}},n=[],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,i={};for(t=0;t<e.length;t++)if(e[t].morphTargets)for(let n=0;n<e[t].morphTargets.length;n++)i[e[t].morphTargets[n]]=-1;for(let r in i){let i=[],a=[];for(let n=0;n!==e[t].morphTargets.length;++n){let n=e[t];i.push(n.time),a.push(n.morphTarget===r?1:0)}n.push(new Al(".morphTargetInfluence["+r+"]",i,a))}o=i.length*a}else{let r=".bones["+t[h].name+"]";i(Va,r+".position",e,"pos",n),i(Ha,r+".quaternion",e,"rot",n),i(Va,r+".scale",e,"scl",n)}}return 0===n.length?null:new this(r,o,n,s)}resetDuration(){let e=0;for(let t=0,i=this.tracks.length;t!==i;++t){let i=this.tracks[t];e=Math.max(e,i.times[i.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 not(e){switch(e.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Al;case"vector":case"vector2":case"vector3":case"vector4":return Va;case"color":return Lb;case"quaternion":return Ha;case"bool":case"boolean":return Qh;case"string":return ed}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+e)}function rot(e){if(void 0===e.type)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");let t=not(e.type);if(void 0===e.times){let t=[],i=[];qU(e.keys,t,i,"value"),e.times=t,e.values=i}return void 0!==t.parse?t.parse(e):new t(e.name,e.times,e.values,e.interpolation)}var Sm={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={}}},Lu=class{constructor(e,t,i){let n,r=this,a=!1,s=0,o=0,l=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=i,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 n?n(e):e},this.setURLModifier=function(e){return n=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,i=l.length;t<i;t+=2){let i=l[t],n=l[t+1];if(i.global&&(i.lastIndex=0),i.test(e))return n}return null}}},fo=new Lu,Er=class{constructor(e){this.manager=void 0!==e?e:fo,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){let i=this;return new Promise((function(n,r){i.load(e,n,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}};Er.DEFAULT_MATERIAL_NAME="__DEFAULT";var Bh={},$B=class extends Error{constructor(e,t){super(e),this.response=t}},Kr=class extends Er{constructor(e){super(e)}load(e,t,i,n){void 0===e&&(e=""),void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);let r=Sm.get(e);if(void 0!==r)return this.manager.itemStart(e),setTimeout((()=>{t&&t(r),this.manager.itemEnd(e)}),0),r;if(void 0!==Bh[e])return void Bh[e].push({onLoad:t,onProgress:i,onError:n});Bh[e]=[],Bh[e].push({onLoad:t,onProgress:i,onError:n});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 i=Bh[e],n=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(){n.read().then((({done:n,value:r})=>{if(n)e.close();else{o+=r.byteLength;let n=new ProgressEvent("progress",{lengthComputable:s,loaded:o,total:a});for(let e=0,t=i.length;e<t;e++){let t=i[e];t.onProgress&&t.onProgress(n)}e.enqueue(r),t()}}))}()}});return new Response(l)}throw new $B(`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),i=t&&t[1]?t[1].toLowerCase():void 0,n=new TextDecoder(i);return e.arrayBuffer().then((e=>n.decode(e)))}}})).then((t=>{Sm.add(e,t);let i=Bh[e];delete Bh[e];for(let e=0,n=i.length;e<n;e++){let n=i[e];n.onLoad&&n.onLoad(t)}})).catch((t=>{let i=Bh[e];if(void 0===i)throw this.manager.itemError(e),t;delete Bh[e];for(let e=0,n=i.length;e<n;e++){let n=i[e];n.onError&&n.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 Er{constructor(e){super(e)}load(e,t,i,n){let r=this,a=new Kr(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,(function(i){try{t(r.parse(JSON.parse(i)))}catch(t){n?n(t):console.error(t),r.manager.itemError(e)}}),i,n)}parse(e){let t=[];for(let i=0;i<e.length;i++){let n=uo.parse(e[i]);t.push(n)}return t}},KB=class extends Er{constructor(e){super(e)}load(e,t,i,n){let r=this,a=[],s=new Su,o=new Kr(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 i=r.parse(e,!0);a[h]={width:i.width,height:i.height,format:i.format,mipmaps:i.mipmaps},l+=1,6===l&&(1===i.mipmapCount&&(s.minFilter=Pr),s.image=a,s.format=i.format,s.needsUpdate=!0,t&&t(s))}),i,n)}if(Array.isArray(e))for(let c=0,u=e.length;c<u;++c)h(c);else o.load(e,(function(e){let i=r.parse(e,!0);if(i.isCubemap){let e=i.mipmaps.length/i.mipmapCount;for(let t=0;t<e;t++){a[t]={mipmaps:[]};for(let e=0;e<i.mipmapCount;e++)a[t].mipmaps.push(i.mipmaps[t*i.mipmapCount+e]),a[t].format=i.format,a[t].width=i.width,a[t].height=i.height}s.image=a}else s.image.width=i.width,s.image.height=i.height,s.mipmaps=i.mipmaps;1===i.mipmapCount&&(s.minFilter=Pr),s.format=i.format,s.needsUpdate=!0,t&&t(s)}),i,n);return s}},Mm=class extends Er{constructor(e){super(e)}load(e,t,i,n){void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);let r=this,a=Sm.get(e);if(void 0!==a)return r.manager.itemStart(e),setTimeout((function(){t&&t(a),r.manager.itemEnd(e)}),0),a;let s=vb("img");function o(){h(),Sm.add(e,this),t&&t(this),r.manager.itemEnd(e)}function l(t){h(),n&&n(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}},Db=class extends Er{constructor(e){super(e)}load(e,t,i,n){let r=new xm;r.colorSpace=en;let a=new Mm(this.manager);a.setCrossOrigin(this.crossOrigin),a.setPath(this.path);let s=0;function o(i){a.load(e[i],(function(e){r.images[i]=e,s++,6===s&&(r.needsUpdate=!0,t&&t(r))}),void 0,n)}for(let l=0;l<e.length;++l)o(l);return r}},Rm=class extends Er{constructor(e){super(e)}load(e,t,i,n){let r=this,a=new wl,s=new Kr(this.manager);return s.setResponseType("arraybuffer"),s.setRequestHeader(this.requestHeader),s.setPath(this.path),s.setWithCredentials(r.withCredentials),s.load(e,(function(e){let i;try{i=r.parse(e)}catch(e){if(void 0===n)return void console.error(e);n(e)}if(!i)return n();void 0!==i.image?a.image=i.image:void 0!==i.data&&(a.image.width=i.width,a.image.height=i.height,a.image.data=i.data),a.wrapS=void 0!==i.wrapS?i.wrapS:Li,a.wrapT=void 0!==i.wrapT?i.wrapT:Li,a.magFilter=void 0!==i.magFilter?i.magFilter:Pr,a.minFilter=void 0!==i.minFilter?i.minFilter:Pr,a.anisotropy=void 0!==i.anisotropy?i.anisotropy:1,void 0!==i.colorSpace?a.colorSpace=i.colorSpace:void 0!==i.encoding&&(a.encoding=i.encoding),void 0!==i.flipY&&(a.flipY=i.flipY),void 0!==i.format&&(a.format=i.format),void 0!==i.type&&(a.type=i.type),void 0!==i.mipmaps&&(a.mipmaps=i.mipmaps,a.minFilter=Fa),1===i.mipmapCount&&(a.minFilter=Pr),void 0!==i.generateMipmaps&&(a.generateMipmaps=i.generateMipmaps),a.needsUpdate=!0,t&&t(a,i)}),i,n),a}},ws=class extends Er{constructor(e){super(e)}load(e,t,i,n){let r=new Gr,a=new Mm(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)}),i,n),r}},Gs=class extends on{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}},Du=class extends Gs{constructor(e,t,i){super(e,i),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(on.DEFAULT_UP),this.updateMatrix(),this.groundColor=new ct(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}},WN=new et,aue=new D,oue=new D,Ob=class{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new xe(512,512),this.map=null,this.mapPass=null,this.matrix=new et,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new ma,this._frameExtents=new xe(1,1),this._viewportCount=1,this._viewports=[new gr(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera,i=this.matrix;aue.setFromMatrixPosition(e.matrixWorld),t.position.copy(aue),oue.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(oue),t.updateMatrixWorld(),WN.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(WN),i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(WN)}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}},JB=class extends Ob{constructor(){super(new hr(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){let t=this.camera,i=2*av*e.angle*this.focus,n=this.mapSize.width/this.mapSize.height,r=e.distance||t.far;(i!==t.fov||n!==t.aspect||r!==t.far)&&(t.fov=i,t.aspect=n,t.far=r,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}},Ou=class extends Gs{constructor(e,t,i=0,n=Math.PI/3,r=0,a=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(on.DEFAULT_UP),this.updateMatrix(),this.target=new on,this.distance=i,this.angle=n,this.penumbra=r,this.decay=a,this.map=null,this.shadow=new JB}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}},lue=new et,sb=new D,jN=new D,QB=class extends Ob{constructor(){super(new hr(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new xe(4,2),this._viewportCount=6,this._viewports=[new gr(2,1,1,1),new gr(0,1,1,1),new gr(3,1,1,1),new gr(1,1,1,1),new gr(3,0,1,1),new gr(1,0,1,1)],this._cubeDirections=[new D(1,0,0),new D(-1,0,0),new D(0,0,1),new D(0,0,-1),new D(0,1,0),new D(0,-1,0)],this._cubeUps=[new D(0,1,0),new D(0,1,0),new D(0,1,0),new D(0,1,0),new D(0,0,1),new D(0,0,-1)]}updateMatrices(e,t=0){let i=this.camera,n=this.matrix,r=e.distance||i.far;r!==i.far&&(i.far=r,i.updateProjectionMatrix()),sb.setFromMatrixPosition(e.matrixWorld),i.position.copy(sb),jN.copy(i.position),jN.add(this._cubeDirections[t]),i.up.copy(this._cubeUps[t]),i.lookAt(jN),i.updateMatrixWorld(),n.makeTranslation(-sb.x,-sb.y,-sb.z),lue.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),this._frustum.setFromProjectionMatrix(lue)}},wc=class extends Gs{constructor(e,t,i=0,n=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=i,this.decay=n,this.shadow=new QB}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}},eU=class extends Ob{constructor(){super(new Nr(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},qs=class extends Gs{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(on.DEFAULT_UP),this.updateMatrix(),this.target=new on,this.shadow=new eU}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}},Cl=class extends Gs{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}},UR=class extends Gs{constructor(e,t,i=10,n=10){super(e,t),this.isRectAreaLight=!0,this.type="RectAreaLight",this.width=i,this.height=n}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}},HR=class{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new D)}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 i=e.x,n=e.y,r=e.z,a=this.coefficients;return t.copy(a[0]).multiplyScalar(.282095),t.addScaledVector(a[1],.488603*n),t.addScaledVector(a[2],.488603*r),t.addScaledVector(a[3],.488603*i),t.addScaledVector(a[4],i*n*1.092548),t.addScaledVector(a[5],n*r*1.092548),t.addScaledVector(a[6],.315392*(3*r*r-1)),t.addScaledVector(a[7],i*r*1.092548),t.addScaledVector(a[8],.546274*(i*i-n*n)),t}getIrradianceAt(e,t){let i=e.x,n=e.y,r=e.z,a=this.coefficients;return t.copy(a[0]).multiplyScalar(.886227),t.addScaledVector(a[1],1.023328*n),t.addScaledVector(a[2],1.023328*r),t.addScaledVector(a[3],1.023328*i),t.addScaledVector(a[4],.858086*i*n),t.addScaledVector(a[5],.858086*n*r),t.addScaledVector(a[6],.743125*r*r-.247708),t.addScaledVector(a[7],.858086*i*r),t.addScaledVector(a[8],.429043*(i*i-n*n)),t}add(e){for(let t=0;t<9;t++)this.coefficients[t].add(e.coefficients[t]);return this}addScaledSH(e,t){for(let i=0;i<9;i++)this.coefficients[i].addScaledVector(e.coefficients[i],t);return this}scale(e){for(let t=0;t<9;t++)this.coefficients[t].multiplyScalar(e);return this}lerp(e,t){for(let i=0;i<9;i++)this.coefficients[i].lerp(e.coefficients[i],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 i=this.coefficients;for(let n=0;n<9;n++)i[n].fromArray(e,t+3*n);return this}toArray(e=[],t=0){let i=this.coefficients;for(let n=0;n<9;n++)i[n].toArray(e,t+3*n);return e}static getBasisAt(e,t){let i=e.x,n=e.y,r=e.z;t[0]=.282095,t[1]=.488603*n,t[2]=.488603*r,t[3]=.488603*i,t[4]=1.092548*i*n,t[5]=1.092548*n*r,t[6]=.315392*(3*r*r-1),t[7]=1.092548*i*r,t[8]=.546274*(i*i-n*n)}},Ev=class extends Gs{constructor(e=new HR,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}},_v=class extends Er{constructor(e){super(e),this.textures={}}load(e,t,i,n){let r=this,a=new Kr(r.manager);a.setPath(r.path),a.setRequestHeader(r.requestHeader),a.setWithCredentials(r.withCredentials),a.load(e,(function(i){try{t(r.parse(JSON.parse(i)))}catch(t){n?n(t):console.error(t),r.manager.itemError(e)}}),i,n)}parse(e){let t=this.textures;function i(e){return void 0===t[e]&&console.warn("THREE.MaterialLoader: Undefined texture",e),t[e]}let n=_v.createMaterialFromType(e.type);if(void 0!==e.uuid&&(n.uuid=e.uuid),void 0!==e.name&&(n.name=e.name),void 0!==e.color&&void 0!==n.color&&n.color.setHex(e.color),void 0!==e.roughness&&(n.roughness=e.roughness),void 0!==e.metalness&&(n.metalness=e.metalness),void 0!==e.sheen&&(n.sheen=e.sheen),void 0!==e.sheenColor&&(n.sheenColor=(new ct).setHex(e.sheenColor)),void 0!==e.sheenRoughness&&(n.sheenRoughness=e.sheenRoughness),void 0!==e.emissive&&void 0!==n.emissive&&n.emissive.setHex(e.emissive),void 0!==e.specular&&void 0!==n.specular&&n.specular.setHex(e.specular),void 0!==e.specularIntensity&&(n.specularIntensity=e.specularIntensity),void 0!==e.specularColor&&void 0!==n.specularColor&&n.specularColor.setHex(e.specularColor),void 0!==e.shininess&&(n.shininess=e.shininess),void 0!==e.clearcoat&&(n.clearcoat=e.clearcoat),void 0!==e.clearcoatRoughness&&(n.clearcoatRoughness=e.clearcoatRoughness),void 0!==e.iridescence&&(n.iridescence=e.iridescence),void 0!==e.iridescenceIOR&&(n.iridescenceIOR=e.iridescenceIOR),void 0!==e.iridescenceThicknessRange&&(n.iridescenceThicknessRange=e.iridescenceThicknessRange),void 0!==e.transmission&&(n.transmission=e.transmission),void 0!==e.thickness&&(n.thickness=e.thickness),void 0!==e.attenuationDistance&&(n.attenuationDistance=e.attenuationDistance),void 0!==e.attenuationColor&&void 0!==n.attenuationColor&&n.attenuationColor.setHex(e.attenuationColor),void 0!==e.anisotropy&&(n.anisotropy=e.anisotropy),void 0!==e.anisotropyRotation&&(n.anisotropyRotation=e.anisotropyRotation),void 0!==e.fog&&(n.fog=e.fog),void 0!==e.flatShading&&(n.flatShading=e.flatShading),void 0!==e.blending&&(n.blending=e.blending),void 0!==e.combine&&(n.combine=e.combine),void 0!==e.side&&(n.side=e.side),void 0!==e.shadowSide&&(n.shadowSide=e.shadowSide),void 0!==e.opacity&&(n.opacity=e.opacity),void 0!==e.transparent&&(n.transparent=e.transparent),void 0!==e.alphaTest&&(n.alphaTest=e.alphaTest),void 0!==e.alphaHash&&(n.alphaHash=e.alphaHash),void 0!==e.depthTest&&(n.depthTest=e.depthTest),void 0!==e.depthWrite&&(n.depthWrite=e.depthWrite),void 0!==e.colorWrite&&(n.colorWrite=e.colorWrite),void 0!==e.stencilWrite&&(n.stencilWrite=e.stencilWrite),void 0!==e.stencilWriteMask&&(n.stencilWriteMask=e.stencilWriteMask),void 0!==e.stencilFunc&&(n.stencilFunc=e.stencilFunc),void 0!==e.stencilRef&&(n.stencilRef=e.stencilRef),void 0!==e.stencilFuncMask&&(n.stencilFuncMask=e.stencilFuncMask),void 0!==e.stencilFail&&(n.stencilFail=e.stencilFail),void 0!==e.stencilZFail&&(n.stencilZFail=e.stencilZFail),void 0!==e.stencilZPass&&(n.stencilZPass=e.stencilZPass),void 0!==e.wireframe&&(n.wireframe=e.wireframe),void 0!==e.wireframeLinewidth&&(n.wireframeLinewidth=e.wireframeLinewidth),void 0!==e.wireframeLinecap&&(n.wireframeLinecap=e.wireframeLinecap),void 0!==e.wireframeLinejoin&&(n.wireframeLinejoin=e.wireframeLinejoin),void 0!==e.rotation&&(n.rotation=e.rotation),1!==e.linewidth&&(n.linewidth=e.linewidth),void 0!==e.dashSize&&(n.dashSize=e.dashSize),void 0!==e.gapSize&&(n.gapSize=e.gapSize),void 0!==e.scale&&(n.scale=e.scale),void 0!==e.polygonOffset&&(n.polygonOffset=e.polygonOffset),void 0!==e.polygonOffsetFactor&&(n.polygonOffsetFactor=e.polygonOffsetFactor),void 0!==e.polygonOffsetUnits&&(n.polygonOffsetUnits=e.polygonOffsetUnits),void 0!==e.dithering&&(n.dithering=e.dithering),void 0!==e.alphaToCoverage&&(n.alphaToCoverage=e.alphaToCoverage),void 0!==e.premultipliedAlpha&&(n.premultipliedAlpha=e.premultipliedAlpha),void 0!==e.forceSinglePass&&(n.forceSinglePass=e.forceSinglePass),void 0!==e.visible&&(n.visible=e.visible),void 0!==e.toneMapped&&(n.toneMapped=e.toneMapped),void 0!==e.userData&&(n.userData=e.userData),void 0!==e.vertexColors&&("number"==typeof e.vertexColors?n.vertexColors=e.vertexColors>0:n.vertexColors=e.vertexColors),void 0!==e.uniforms)for(let r in e.uniforms){let t=e.uniforms[r];switch(n.uniforms[r]={},t.type){case"t":n.uniforms[r].value=i(t.value);break;case"c":n.uniforms[r].value=(new ct).setHex(t.value);break;case"v2":n.uniforms[r].value=(new xe).fromArray(t.value);break;case"v3":n.uniforms[r].value=(new D).fromArray(t.value);break;case"v4":n.uniforms[r].value=(new gr).fromArray(t.value);break;case"m3":n.uniforms[r].value=(new Ln).fromArray(t.value);break;case"m4":n.uniforms[r].value=(new et).fromArray(t.value);break;default:n.uniforms[r].value=t.value}}if(void 0!==e.defines&&(n.defines=e.defines),void 0!==e.vertexShader&&(n.vertexShader=e.vertexShader),void 0!==e.fragmentShader&&(n.fragmentShader=e.fragmentShader),void 0!==e.glslVersion&&(n.glslVersion=e.glslVersion),void 0!==e.extensions)for(let r in e.extensions)n.extensions[r]=e.extensions[r];if(void 0!==e.lights&&(n.lights=e.lights),void 0!==e.clipping&&(n.clipping=e.clipping),void 0!==e.size&&(n.size=e.size),void 0!==e.sizeAttenuation&&(n.sizeAttenuation=e.sizeAttenuation),void 0!==e.map&&(n.map=i(e.map)),void 0!==e.matcap&&(n.matcap=i(e.matcap)),void 0!==e.alphaMap&&(n.alphaMap=i(e.alphaMap)),void 0!==e.bumpMap&&(n.bumpMap=i(e.bumpMap)),void 0!==e.bumpScale&&(n.bumpScale=e.bumpScale),void 0!==e.normalMap&&(n.normalMap=i(e.normalMap)),void 0!==e.normalMapType&&(n.normalMapType=e.normalMapType),void 0!==e.normalScale){let t=e.normalScale;!1===Array.isArray(t)&&(t=[t,t]),n.normalScale=(new xe).fromArray(t)}return void 0!==e.displacementMap&&(n.displacementMap=i(e.displacementMap)),void 0!==e.displacementScale&&(n.displacementScale=e.displacementScale),void 0!==e.displacementBias&&(n.displacementBias=e.displacementBias),void 0!==e.roughnessMap&&(n.roughnessMap=i(e.roughnessMap)),void 0!==e.metalnessMap&&(n.metalnessMap=i(e.metalnessMap)),void 0!==e.emissiveMap&&(n.emissiveMap=i(e.emissiveMap)),void 0!==e.emissiveIntensity&&(n.emissiveIntensity=e.emissiveIntensity),void 0!==e.specularMap&&(n.specularMap=i(e.specularMap)),void 0!==e.specularIntensityMap&&(n.specularIntensityMap=i(e.specularIntensityMap)),void 0!==e.specularColorMap&&(n.specularColorMap=i(e.specularColorMap)),void 0!==e.envMap&&(n.envMap=i(e.envMap)),void 0!==e.envMapIntensity&&(n.envMapIntensity=e.envMapIntensity),void 0!==e.reflectivity&&(n.reflectivity=e.reflectivity),void 0!==e.refractionRatio&&(n.refractionRatio=e.refractionRatio),void 0!==e.lightMap&&(n.lightMap=i(e.lightMap)),void 0!==e.lightMapIntensity&&(n.lightMapIntensity=e.lightMapIntensity),void 0!==e.aoMap&&(n.aoMap=i(e.aoMap)),void 0!==e.aoMapIntensity&&(n.aoMapIntensity=e.aoMapIntensity),void 0!==e.gradientMap&&(n.gradientMap=i(e.gradientMap)),void 0!==e.clearcoatMap&&(n.clearcoatMap=i(e.clearcoatMap)),void 0!==e.clearcoatRoughnessMap&&(n.clearcoatRoughnessMap=i(e.clearcoatRoughnessMap)),void 0!==e.clearcoatNormalMap&&(n.clearcoatNormalMap=i(e.clearcoatNormalMap)),void 0!==e.clearcoatNormalScale&&(n.clearcoatNormalScale=(new xe).fromArray(e.clearcoatNormalScale)),void 0!==e.iridescenceMap&&(n.iridescenceMap=i(e.iridescenceMap)),void 0!==e.iridescenceThicknessMap&&(n.iridescenceThicknessMap=i(e.iridescenceThicknessMap)),void 0!==e.transmissionMap&&(n.transmissionMap=i(e.transmissionMap)),void 0!==e.thicknessMap&&(n.thicknessMap=i(e.thicknessMap)),void 0!==e.anisotropyMap&&(n.anisotropyMap=i(e.anisotropyMap)),void 0!==e.sheenColorMap&&(n.sheenColorMap=i(e.sheenColorMap)),void 0!==e.sheenRoughnessMap&&(n.sheenRoughnessMap=i(e.sheenRoughnessMap)),n}setTextures(e){return this.textures=e,this}static createMaterialFromType(e){return new{ShadowMaterial:LR,SpriteMaterial:Tb,RawShaderMaterial:DR,ShaderMaterial:cn,PointsMaterial:bi,MeshPhysicalMaterial:jo,MeshStandardMaterial:Cu,MeshPhongMaterial:ea,MeshToonMaterial:OR,MeshNormalMaterial:mf,MeshLambertMaterial:Pu,MeshDepthMaterial:_c,MeshDistanceMaterial:_b,MeshBasicMaterial:ln,MeshMatcapMaterial:kR,LineDashedMaterial:Iu,LineBasicMaterial:Gn,Material:yr}[e]}},ta=class{static decodeText(e){if("undefined"!=typeof TextDecoder)return(new TextDecoder).decode(e);let t="";for(let i=0,n=e.length;i<n;i++)t+=String.fromCharCode(e[i]);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)}},VR=class extends Dt{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}},zR=class extends Er{constructor(e){super(e)}load(e,t,i,n){let r=this,a=new Kr(r.manager);a.setPath(r.path),a.setRequestHeader(r.requestHeader),a.setWithCredentials(r.withCredentials),a.load(e,(function(i){try{t(r.parse(JSON.parse(i)))}catch(t){n?n(t):console.error(t),r.manager.itemError(e)}}),i,n)}parse(e){let t={},i={};function n(e,n){if(void 0!==t[n])return t[n];let r=e.interleavedBuffers[n],a=function(e,t){if(void 0!==i[t])return i[t];let n=e.arrayBuffers[t],r=new Uint32Array(n).buffer;return i[t]=r,r}(e,r.buffer),s=tv(r.type,a),o=new $h(s,r.stride);return o.uuid=r.uuid,t[n]=o,o}let r=e.isInstancedBufferGeometry?new VR:new Dt,a=e.data.index;if(void 0!==a){let e=tv(a.type,a.array);r.setIndex(new mn(e,1))}let s=e.data.attributes;for(let c in s){let t,i=s[c];if(i.isInterleavedBufferAttribute){let r=n(e.data,i.data);t=new co(r,i.itemSize,i.offset,i.normalized)}else{let e=tv(i.type,i.array);t=new(i.isInstancedBufferAttribute?Zh:mn)(e,i.itemSize,i.normalized)}void 0!==i.name&&(t.name=i.name),void 0!==i.usage&&t.setUsage(i.usage),void 0!==i.updateRange&&(t.updateRange.offset=i.updateRange.offset,t.updateRange.count=i.updateRange.count),r.setAttribute(c,t)}let o=e.data.morphAttributes;if(o)for(let c in o){let t=o[c],i=[];for(let r=0,a=t.length;r<a;r++){let a,s=t[r];if(s.isInterleavedBufferAttribute){let t=n(e.data,s.data);a=new co(t,s.itemSize,s.offset,s.normalized)}else{let e=tv(s.type,s.array);a=new mn(e,s.itemSize,s.normalized)}void 0!==s.name&&(a.name=s.name),i.push(a)}r.morphAttributes[c]=i}e.data.morphTargetsRelative&&(r.morphTargetsRelative=!0);let l=e.data.groups||e.data.drawcalls||e.data.offsets;if(void 0!==l)for(let c=0,u=l.length;c!==u;++c){let e=l[c];r.addGroup(e.start,e.count,e.materialIndex)}let h=e.data.boundingSphere;if(void 0!==h){let e=new D;void 0!==h.center&&e.fromArray(h.center),r.boundingSphere=new vr(e,h.radius)}return e.name&&(r.name=e.name),e.userData&&(r.userData=e.userData),r}},tU=class extends Er{constructor(e){super(e)}load(e,t,i,n){let r=this,a=""===this.path?ta.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||a;let s=new Kr(this.manager);s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,(function(i){let a=null;try{a=JSON.parse(i)}catch(t){return void 0!==n&&n(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!==n&&n(new Error("THREE.ObjectLoader: Can't load "+e)),void console.error("THREE.ObjectLoader: Can't load "+e);r.parse(a,t)}),i,n)}loadAsync(e,t){return ft(this,null,(function*(){let i=""===this.path?ta.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||i;let n=new Kr(this.manager);n.setPath(this.path),n.setRequestHeader(this.requestHeader),n.setWithCredentials(this.withCredentials);let r=yield n.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 i=this.parseAnimations(e.animations),n=this.parseShapes(e.shapes),r=this.parseGeometries(e.geometries,n),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,i),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 ft(this,null,(function*(){let t=this.parseAnimations(e.animations),i=this.parseShapes(e.shapes),n=this.parseGeometries(e.geometries,i),r=yield this.parseImagesAsync(e.images),a=this.parseTextures(e.textures,r),s=this.parseMaterials(e.materials,a),o=this.parseObject(e.object,n,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 i=0,n=e.length;i<n;i++){let n=(new _s).fromJSON(e[i]);t[n.uuid]=n}return t}parseSkeletons(e,t){let i={},n={};if(t.traverse((function(e){e.isBone&&(n[e.uuid]=e)})),void 0!==e)for(let r=0,a=e.length;r<a;r++){let t=(new Ml).fromJSON(e[r],n);i[t.uuid]=t}return i}parseGeometries(e,t){let i={};if(void 0!==e){let n=new zR;for(let r=0,a=e.length;r<a;r++){let a,s=e[r];switch(s.type){case"BufferGeometry":case"InstancedBufferGeometry":a=n.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),i[s.uuid]=a}}return i}parseMaterials(e,t){let i={},n={};if(void 0!==e){let r=new _v;r.setTextures(t);for(let t=0,a=e.length;t<a;t++){let a=e[t];void 0===i[a.uuid]&&(i[a.uuid]=r.parse(a)),n[a.uuid]=i[a.uuid]}}return n}parseAnimations(e){let t={};if(void 0!==e)for(let i=0;i<e.length;i++){let n=e[i],r=uo.parse(n);t[r.uuid]=r}return t}parseImages(e,t){let i,n=this,r={};function a(e){if("string"==typeof e){let t=e;return function(e){return n.manager.itemStart(e),i.load(e,(function(){n.manager.itemEnd(e)}),void 0,(function(){n.manager.itemError(e),n.manager.itemEnd(e)}))}(/^(\/\/)|([a-z]+:(\/\/)?)/i.test(t)?t:n.resourcePath+t)}return e.data?{data:tv(e.type,e.data),width:e.width,height:e.height}:null}if(void 0!==e&&e.length>0){let n=new Lu(t);i=new Mm(n),i.setCrossOrigin(this.crossOrigin);for(let t=0,i=e.length;t<i;t++){let i=e[t],n=i.url;if(Array.isArray(n)){let e=[];for(let t=0,i=n.length;t<i;t++){let i=a(n[t]);null!==i&&(i instanceof HTMLImageElement?e.push(i):e.push(new wl(i.data,i.width,i.height)))}r[i.uuid]=new xc(e)}else{let e=a(i.url);r[i.uuid]=new xc(e)}}}return r}parseImagesAsync(e){return ft(this,null,(function*(){let t,i=this,n={};function r(e){return ft(this,null,(function*(){if("string"==typeof e){let n=e,r=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(n)?n:i.resourcePath+n;return yield t.loadAsync(r)}return e.data?{data:tv(e.type,e.data),width:e.width,height:e.height}:null}))}if(void 0!==e&&e.length>0){t=new Mm(this.manager),t.setCrossOrigin(this.crossOrigin);for(let t=0,i=e.length;t<i;t++){let i=e[t],a=i.url;if(Array.isArray(a)){let e=[];for(let t=0,i=a.length;t<i;t++){let i=a[t],n=yield r(i);null!==n&&(n instanceof HTMLImageElement?e.push(n):e.push(new wl(n.data,n.width,n.height)))}n[i.uuid]=new xc(e)}else{let e=yield r(i.url);n[i.uuid]=new xc(e)}}}return n}))}parseTextures(e,t){function i(e,t){return"number"==typeof e?e:(console.warn("THREE.ObjectLoader.parseTexture: Constant should be in numeric form.",e),t[e])}let n={};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 xm,6===l.length&&(s.needsUpdate=!0)):(s=l&&l.data?new wl:new Gr,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=i(a.mapping,iot)),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=i(a.wrap[0],cue),s.wrapT=i(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=i(a.minFilter,uue)),void 0!==a.magFilter&&(s.magFilter=i(a.magFilter,uue)),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),n[a.uuid]=s}return n}parseObject(e,t,i,n,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 n=0,r=e.length;n<r;n++){let r=e[n];void 0===i[r]&&console.warn("THREE.ObjectLoader: Undefined material",r),t.push(i[r])}return t}return void 0===i[e]&&console.warn("THREE.ObjectLoader: Undefined material",e),i[e]}}function c(e){return void 0===n[e]&&console.warn("THREE.ObjectLoader: Undefined texture",e),n[e]}switch(e.type){case"Scene":a=new Si,void 0!==e.background&&(Number.isInteger(e.background)?a.background=new ct(e.background):a.background=c(e.background)),void 0!==e.environment&&(a.environment=c(e.environment)),void 0!==e.fog&&("Fog"===e.fog.type?a.fog=new Tu(e.fog.color,e.fog.near,e.fog.far):"FogExp2"===e.fog.type&&(a.fog=new cv(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 hr(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 Nr(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 Cl(e.color,e.intensity);break;case"DirectionalLight":a=new qs(e.color,e.intensity);break;case"PointLight":a=new wc(e.color,e.intensity,e.distance,e.decay);break;case"RectAreaLight":a=new UR(e.color,e.intensity,e.width,e.height);break;case"SpotLight":a=new Ou(e.color,e.intensity,e.distance,e.angle,e.penumbra,e.decay);break;case"HemisphereLight":a=new Du(e.color,e.groundColor,e.intensity);break;case"LightProbe":a=(new Ev).fromJSON(e);break;case"SkinnedMesh":s=l(e.geometry),o=h(e.material),a=new wu(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 xt(s,o);break;case"InstancedMesh":s=l(e.geometry),o=h(e.material);let t=e.count,i=e.instanceMatrix,n=e.instanceColor;a=new Oi(s,o,t),a.instanceMatrix=new Zh(new Float32Array(i.array),16),void 0!==n&&(a.instanceColor=new Zh(new Float32Array(n.array),n.itemSize));break;case"LOD":a=new MR;break;case"Line":a=new fr(l(e.geometry),h(e.material));break;case"LineLoop":a=new uv(l(e.geometry),h(e.material));break;case"LineSegments":a=new qr(l(e.geometry),h(e.material));break;case"PointCloud":case"Points":a=new ii(l(e.geometry),h(e.material));break;case"Sprite":a=new SR(h(e.material));break;case"Group":a=new er;break;case"Bone":a=new Sl;break;default:a=new on}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,i,n,r))}if(void 0!==e.animations){let t=e.animations;for(let e=0;e<t.length;e++){let i=t[e];a.animations.push(r[i])}}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 i=t[e],n=a.getObjectByProperty("uuid",i.object);void 0!==n&&a.addLevel(n,i.distance,i.hysteresis)}}return a}bindSkeletons(e,t){0!==Object.keys(t).length&&e.traverse((function(e){if(!0===e.isSkinnedMesh&&void 0!==e.skeleton){let i=t[e.skeleton];void 0===i?console.warn("THREE.ObjectLoader: No skeleton found with UUID:",e.skeleton):e.bind(i,e.bindMatrix)}}))}},iot={UVMapping:YR,CubeReflectionMapping:Gh,CubeRefractionMapping:uf,EquirectangularReflectionMapping:vm,EquirectangularRefractionMapping:fb,CubeUVReflectionMapping:Mv},cue={RepeatWrapping:Di,ClampToEdgeWrapping:Li,MirroredRepeatWrapping:qh},uue={NearestFilter:Jr,NearestMipmapNearestFilter:hf,NearestMipmapLinearFilter:zh,LinearFilter:Pr,LinearMipmapNearestFilter:Im,LinearMipmapLinearFilter:Fa},kb=class extends Er{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,i,n){void 0===e&&(e=""),void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);let r=this,a=Sm.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(i){Sm.add(e,i),t&&t(i),r.manager.itemEnd(e)})).catch((function(t){n&&n(t),r.manager.itemError(e),r.manager.itemEnd(e)})),r.manager.itemStart(e)}},rR,Fb=class{static getContext(){return void 0===rR&&(rR=new(window.AudioContext||window.webkitAudioContext)),rR}static setContext(e){rR=e}},nU=class extends Er{constructor(e){super(e)}load(e,t,i,n){let r=this,a=new Kr(this.manager);function s(t){n?n(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 i=e.slice(0);Fb.getContext().decodeAudioData(i,(function(e){t(e)}),s)}catch(e){s(e)}}),i,n)}},rU=class extends Ev{constructor(e,t,i=1){super(void 0,i),this.isHemisphereLightProbe=!0;let n=(new ct).set(e),r=(new ct).set(t),a=new D(n.r,n.g,n.b),s=new D(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)}},iU=class extends Ev{constructor(e,t=1){super(void 0,t),this.isAmbientLightProbe=!0;let i=(new ct).set(e);this.sh.coefficients[0].set(i.r,i.g,i.b).multiplyScalar(2*Math.sqrt(Math.PI))}},hue=new et,due=new et,sm=new et,sU=class{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new hr,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new hr,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,sm.copy(e.projectionMatrix);let i,n,r=t.eyeSep/2,a=r*t.near/t.focus,s=t.near*Math.tan(gm*t.fov*.5)/t.zoom;due.elements[12]=-r,hue.elements[12]=r,i=-s*t.aspect+a,n=s*t.aspect+a,sm.elements[0]=2*t.near/(n-i),sm.elements[8]=(n+i)/(n-i),this.cameraL.projectionMatrix.copy(sm),i=-s*t.aspect-a,n=s*t.aspect-a,sm.elements[0]=2*t.near/(n-i),sm.elements[8]=(n+i)/(n-i),this.cameraR.projectionMatrix.copy(sm)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(due),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(hue)}},ho=class{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=fue(),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=fue();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}};function fue(){return("undefined"==typeof performance?Date:performance).now()}var am=new D,pue=new dr,sot=new D,om=new D,aU=class extends on{constructor(){super(),this.type="AudioListener",this.context=Fb.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new ho}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,i=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(am,pue,sot),om.set(0,0,-1).applyQuaternion(pue),t.positionX){let e=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(am.x,e),t.positionY.linearRampToValueAtTime(am.y,e),t.positionZ.linearRampToValueAtTime(am.z,e),t.forwardX.linearRampToValueAtTime(om.x,e),t.forwardY.linearRampToValueAtTime(om.y,e),t.forwardZ.linearRampToValueAtTime(om.z,e),t.upX.linearRampToValueAtTime(i.x,e),t.upY.linearRampToValueAtTime(i.y,e),t.upZ.linearRampToValueAtTime(i.z,e)}else t.setPosition(am.x,am.y,am.z),t.setOrientation(om.x,om.y,om.z,i.x,i.y,i.z)}},GR=class extends on{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}},lm=new D,mue=new dr,aot=new D,cm=new D,oU=class extends GR{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,i){return this.panner.coneInnerAngle=e,this.panner.coneOuterAngle=t,this.panner.coneOuterGain=i,this}updateMatrixWorld(e){if(super.updateMatrixWorld(e),!0===this.hasPlaybackControl&&!1===this.isPlaying)return;this.matrixWorld.decompose(lm,mue,aot),cm.set(0,0,1).applyQuaternion(mue);let t=this.panner;if(t.positionX){let e=this.context.currentTime+this.listener.timeDelta;t.positionX.linearRampToValueAtTime(lm.x,e),t.positionY.linearRampToValueAtTime(lm.y,e),t.positionZ.linearRampToValueAtTime(lm.z,e),t.orientationX.linearRampToValueAtTime(cm.x,e),t.orientationY.linearRampToValueAtTime(cm.y,e),t.orientationZ.linearRampToValueAtTime(cm.z,e)}else t.setPosition(lm.x,lm.y,lm.z),t.setOrientation(cm.x,cm.y,cm.z)}},lU=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 i=0;i<t.length;i++)e+=t[i];return e/t.length}},qR=class{constructor(e,t,i){let n,r,a;switch(this.binding=e,this.valueSize=i,t){case"quaternion":n=this._slerp,r=this._slerpAdditive,a=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(6*i),this._workIndex=5;break;case"string":case"bool":n=this._select,r=this._select,a=this._setAdditiveIdentityOther,this.buffer=new Array(5*i);break;default:n=this._lerp,r=this._lerpAdditive,a=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(5*i)}this._mixBufferRegion=n,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 i=this.buffer,n=this.valueSize,r=e*n+n,a=this.cumulativeWeight;if(0===a){for(let e=0;e!==n;++e)i[r+e]=i[e];a=t}else{a+=t;let e=t/a;this._mixBufferRegion(i,r,0,e,n)}this.cumulativeWeight=a}accumulateAdditive(e){let t=this.buffer,i=this.valueSize,n=i*this._addIndex;0===this.cumulativeWeightAdditive&&this._setIdentity(),this._mixBufferRegionAdditive(t,n,0,e,i),this.cumulativeWeightAdditive+=e}apply(e){let t=this.valueSize,i=this.buffer,n=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(i,n,e,1-r,t)}a>0&&this._mixBufferRegionAdditive(i,n,this._addIndex*t,1,t);for(let o=t,l=t+t;o!==l;++o)if(i[o]!==i[o+t]){s.setValue(i,n);break}}saveOriginalState(){let e=this.binding,t=this.buffer,i=this.valueSize,n=i*this._origIndex;e.getValue(t,n);for(let r=i,a=n;r!==a;++r)t[r]=t[n+r%i];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 i=e;i<t;i++)this.buffer[i]=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 i=0;i<this.valueSize;i++)this.buffer[t+i]=this.buffer[e+i]}_select(e,t,i,n,r){if(n>=.5)for(let a=0;a!==r;++a)e[t+a]=e[i+a]}_slerp(e,t,i,n){dr.slerpFlat(e,t,e,t,e,i,n)}_slerpAdditive(e,t,i,n,r){let a=this._workIndex*r;dr.multiplyQuaternionsFlat(e,a,e,t,e,i),dr.slerpFlat(e,t,e,t,e,a,n)}_lerp(e,t,i,n,r){let a=1-n;for(let s=0;s!==r;++s){let r=t+s;e[r]=e[r]*a+e[i+s]*n}}_lerpAdditive(e,t,i,n,r){for(let a=0;a!==r;++a){let r=t+a;e[r]=e[r]+e[i+a]*n}}},WU="\\[\\]\\.:\\/",oot=new RegExp("["+WU+"]","g"),jU="[^"+WU+"]",lot="[^"+WU.replace("\\.","")+"]",cot=/((?:WC+[\/:])*)/.source.replace("WC",jU),uot=/(WCOD+)?/.source.replace("WCOD",lot),hot=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",jU),dot=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",jU),fot=new RegExp("^"+cot+uot+hot+dot+"$"),pot=["material","materials","bones","map"],cU=class{constructor(e,t,i){let n=i||Jn.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,n)}getValue(e,t){this.bind();let i=this._targetGroup.nCachedObjects_,n=this._bindings[i];void 0!==n&&n.getValue(e,t)}setValue(e,t){let i=this._bindings;for(let n=this._targetGroup.nCachedObjects_,r=i.length;n!==r;++n)i[n].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].unbind()}},Jn=class{constructor(e,t,i){this.path=t,this.parsedPath=i||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,i){return e&&e.isAnimationObjectGroup?new Jn.Composite(e,t,i):new Jn(e,t,i)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(oot,"")}static parseTrackName(e){let t=fot.exec(e);if(null===t)throw new Error("PropertyBinding: Cannot parse trackName: "+e);let i={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},n=i.nodeName&&i.nodeName.lastIndexOf(".");if(void 0!==n&&-1!==n){let e=i.nodeName.substring(n+1);-1!==pot.indexOf(e)&&(i.nodeName=i.nodeName.substring(0,n),i.objectName=e)}if(null===i.propertyName||0===i.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return i}static findNode(e,t){if(void 0===t||""===t||"."===t||-1===t||t===e.name||t===e.uuid)return e;if(e.skeleton){let i=e.skeleton.getBoneByName(t);if(void 0!==i)return i}if(e.children){let i=function(e){for(let n=0;n<e.length;n++){let r=e[n];if(r.name===t||r.uuid===t)return r;let a=i(r.children);if(a)return a}return null},n=i(e.children);if(n)return n}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){let i=this.resolvedProperty;for(let n=0,r=i.length;n!==r;++n)e[t++]=i[n]}_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 i=this.resolvedProperty;for(let n=0,r=i.length;n!==r;++n)i[n]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let i=this.resolvedProperty;for(let n=0,r=i.length;n!==r;++n)i[n]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){let i=this.resolvedProperty;for(let n=0,r=i.length;n!==r;++n)i[n]=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,i=t.objectName,n=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(i){let n=t.objectIndex;switch(i){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===n){n=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[i])return void console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);e=e[i]}if(void 0!==n){if(void 0===e[n])return void console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);e=e[n]}}let a=e[n];if(void 0===a){let i=t.nodeName;return void console.error("THREE.PropertyBinding: Trying to update property for track: "+i+"."+n+" 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"===n){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=n;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=cU,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 uU=class{constructor(){this.isAnimationObjectGroup=!0,this.uuid=qo(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;let e={};this._indicesByUUID=e;for(let i=0,n=arguments.length;i!==n;++i)e[arguments[i].uuid]=i;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,i=this._indicesByUUID,n=this._paths,r=this._parsedPaths,a=this._bindings,s=a.length,o=t.length,l=this.nCachedObjects_;for(let h=0,c=arguments.length;h!==c;++h){let c=arguments[h],u=c.uuid,d=i[u];if(void 0===d){d=o++,i[u]=d,t.push(c);for(let e=0,t=s;e!==t;++e)a[e].push(new Jn(c,n[e],r[e]))}else if(d<l){e=t[d];let o=--l,h=t[o];i[h.uuid]=d,t[d]=h,i[u]=o,t[o]=c;for(let e=0,t=s;e!==t;++e){let t=a[e],i=t[o],s=t[d];t[d]=i,void 0===s&&(s=new Jn(c,n[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,i=this._bindings,n=i.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=n;e!==t;++e){let t=i[e],n=t[a],r=t[l];t[l]=n,t[a]=r}}}this.nCachedObjects_=r}uncache(){let e=this._objects,t=this._indicesByUUID,i=this._bindings,n=i.length,r=this.nCachedObjects_,a=e.length;for(let s=0,o=arguments.length;s!==o;++s){let o=arguments[s].uuid,l=t[o];if(void 0!==l)if(delete t[o],l<r){let s=--r,o=e[s],h=--a,c=e[h];t[o.uuid]=l,e[l]=o,t[c.uuid]=s,e[s]=c,e.pop();for(let e=0,t=n;e!==t;++e){let t=i[e],n=t[s],r=t[h];t[l]=n,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=n;e!==t;++e){let t=i[e];t[l]=t[r],t.pop()}}}this.nCachedObjects_=r}subscribe_(e,t){let i=this._bindingsIndicesByPath,n=i[e],r=this._bindings;if(void 0!==n)return r[n];let a=this._paths,s=this._parsedPaths,o=this._objects,l=o.length,h=this.nCachedObjects_,c=new Array(l);n=r.length,i[e]=n,a.push(e),s.push(t),r.push(c);for(let u=h,d=o.length;u!==d;++u){let i=o[u];c[u]=new Jn(i,e,t)}return c}unsubscribe_(e){let t=this._bindingsIndicesByPath,i=t[e];if(void 0!==i){let n=this._paths,r=this._parsedPaths,a=this._bindings,s=a.length-1,o=a[s];t[e[s]]=i,a[i]=o,a.pop(),r[i]=r[s],r.pop(),n[i]=n[s],n.pop()}}},WR=class{constructor(e,t,i=null,n=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=i,this.blendMode=n;let r=t.tracks,a=r.length,s=new Array(a),o={endingStart:dm,endingEnd:dm};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=rhe,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,i){if(e.fadeOut(t),this.fadeIn(t),i){let i=this._clip.duration,n=e._clip.duration,r=n/i,a=i/n;e.warp(1,r,t),this.warp(a,1,t)}return this}crossFadeTo(e,t,i){return e.crossFadeFrom(this,t,i)}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,i){let n=this._mixer,r=n.time,a=this.timeScale,s=this._timeScaleInterpolant;null===s&&(s=n._lendControlInterpolant(),this._timeScaleInterpolant=s);let o=s.parameterPositions,l=s.sampleValues;return o[0]=r,o[1]=r+i,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,i,n){if(!this.enabled)return void this._updateWeight(e);let r=this._startTime;if(null!==r){let n=(e-r)*i;n<0||0===i?t=0:(this._startTime=null,t=i*n)}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===kU)for(let i=0,n=e.length;i!==n;++i)e[i].evaluate(a),t[i].accumulateAdditive(s);else for(let i=0,r=e.length;i!==r;++i)e[i].evaluate(a),t[i].accumulate(n,s)}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;let i=this._weightInterpolant;if(null!==i){let n=i.evaluate(e)[0];t*=n,e>i.parameterPositions[1]&&(this.stopFading(),0===n&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;let i=this._timeScaleInterpolant;null!==i&&(t*=i.evaluate(e)[0],e>i.parameterPositions[1]&&(this.stopWarping(),0===t?this.paused=!0:this.timeScale=t))}return this._effectiveTimeScale=t,t}_updateTime(e){let t=this._clip.duration,i=this.loop,n=this.time+e,r=this._loopCount,a=i===ihe;if(0===e)return-1===r?n:a&&1==(1&r)?t-n:n;if(i===nhe){-1===r&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(n>=t)n=t;else{if(!(n<0)){this.time=n;break e}n=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=n,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)),n>=t||n<0){let i=Math.floor(n/t);n-=t*i,r+=Math.abs(i);let s=this.repetitions-r;if(s<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,n=e>0?t:0,this.time=n,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=n,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:i})}}else this.time=n;if(a&&1==(1&r))return t-n}return n}_setEndings(e,t,i){let n=this._interpolantSettings;i?(n.endingStart=fm,n.endingEnd=fm):(n.endingStart=e?this.zeroSlopeAtStart?fm:dm:pb,n.endingEnd=t?this.zeroSlopeAtEnd?fm:dm:pb)}_scheduleFading(e,t,i){let n=this._mixer,r=n.time,a=this._weightInterpolant;null===a&&(a=n._lendControlInterpolant(),this._weightInterpolant=a);let s=a.parameterPositions,o=a.sampleValues;return s[0]=r,o[0]=t,s[1]=r+e,o[1]=i,this}},mot=new Float32Array(1),hU=class extends Wo{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){let i=e._localRoot||this._root,n=e._clip.tracks,r=n.length,a=e._propertyBindings,s=e._interpolants,o=i.uuid,l=this._bindingsByRootAndName,h=l[o];void 0===h&&(h={},l[o]=h);for(let c=0;c!==r;++c){let e=n[c],r=e.name,l=h[r];if(void 0!==l)++l.referenceCount,a[c]=l;else{if(l=a[c],void 0!==l){null===l._cacheIndex&&(++l.referenceCount,this._addInactiveBinding(l,o,r));continue}let n=t&&t._propertyBindings[c].binding.parsedPath;l=new qR(Jn.create(i,r,n),e.ValueTypeName,e.getValueSize()),++l.referenceCount,this._addInactiveBinding(l,o,r),a[c]=l}s[c].resultBuffer=l.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(null===e._cacheIndex){let t=(e._localRoot||this._root).uuid,i=e._clip.uuid,n=this._actionsByClip[i];this._bindAction(e,n&&n.knownActions[0]),this._addInactiveAction(e,i,t)}let t=e._propertyBindings;for(let e=0,i=t.length;e!==i;++e){let i=t[e];0==i.useCount++&&(this._lendBinding(i),i.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){let t=e._propertyBindings;for(let e=0,i=t.length;e!==i;++e){let i=t[e];0==--i.useCount&&(i.restoreOriginalState(),this._takeBackBinding(i))}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,i){let n=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=n.length,n.push(e),a.actionByRoot[i]=e}_removeInactiveAction(e){let t=this._actions,i=t[t.length-1],n=e._cacheIndex;i._cacheIndex=n,t[n]=i,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 i=0,n=t.length;i!==n;++i){let e=t[i];0==--e.referenceCount&&this._removeInactiveBinding(e)}}_lendAction(e){let t=this._actions,i=e._cacheIndex,n=this._nActiveActions++,r=t[n];e._cacheIndex=n,t[n]=e,r._cacheIndex=i,t[i]=r}_takeBackAction(e){let t=this._actions,i=e._cacheIndex,n=--this._nActiveActions,r=t[n];e._cacheIndex=n,t[n]=e,r._cacheIndex=i,t[i]=r}_addInactiveBinding(e,t,i){let n=this._bindingsByRootAndName,r=this._bindings,a=n[t];void 0===a&&(a={},n[t]=a),a[i]=e,e._cacheIndex=r.length,r.push(e)}_removeInactiveBinding(e){let t=this._bindings,i=e.binding,n=i.rootNode.uuid,r=i.path,a=this._bindingsByRootAndName,s=a[n],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[n]}_lendBinding(e){let t=this._bindings,i=e._cacheIndex,n=this._nActiveBindings++,r=t[n];e._cacheIndex=n,t[n]=e,r._cacheIndex=i,t[i]=r}_takeBackBinding(e){let t=this._bindings,i=e._cacheIndex,n=--this._nActiveBindings,r=t[n];e._cacheIndex=n,t[n]=e,r._cacheIndex=i,t[i]=r}_lendControlInterpolant(){let e=this._controlInterpolants,t=this._nActiveControlInterpolants++,i=e[t];return void 0===i&&(i=new Ib(new Float32Array(2),new Float32Array(2),1,mot),i.__cacheIndex=t,e[t]=i),i}_takeBackControlInterpolant(e){let t=this._controlInterpolants,i=e.__cacheIndex,n=--this._nActiveControlInterpolants,r=t[n];e.__cacheIndex=n,t[n]=e,r.__cacheIndex=i,t[i]=r}clipAction(e,t,i){let n=t||this._root,r=n.uuid,a="string"==typeof e?uo.findByName(n,e):e,s=null!==a?a.uuid:e,o=this._actionsByClip[s],l=null;if(void 0===i&&(i=null!==a?a.blendMode:KR),void 0!==o){let e=o.actionByRoot[r];if(void 0!==e&&e.blendMode===i)return e;l=o.knownActions[0],null===a&&(a=l._clip)}if(null===a)return null;let h=new WR(this,a,t,i);return this._bindAction(h,l),this._addInactiveAction(h,s,r),h}existingAction(e,t){let i=t||this._root,n=i.uuid,r="string"==typeof e?uo.findByName(i,e):e,a=r?r.uuid:e,s=this._actionsByClip[a];return void 0!==s&&s.actionByRoot[n]||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,i=this._nActiveActions,n=this.time+=e,r=Math.sign(e),a=this._accuIndex^=1;for(let l=0;l!==i;++l)t[l]._update(n,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,i=e.uuid,n=this._actionsByClip,r=n[i];if(void 0!==r){let e=r.knownActions;for(let i=0,n=e.length;i!==n;++i){let n=e[i];this._deactivateAction(n);let r=n._cacheIndex,a=t[t.length-1];n._cacheIndex=null,n._byClipCacheIndex=null,a._cacheIndex=r,t[r]=a,t.pop(),this._removeInactiveBindingsForAction(n)}delete n[i]}}uncacheRoot(e){let t=e.uuid,i=this._actionsByClip;for(let r in i){let e=i[r].actionByRoot[t];void 0!==e&&(this._deactivateAction(e),this._removeInactiveAction(e))}let n=this._bindingsByRootAndName[t];if(void 0!==n)for(let r in n){let e=n[r];e.restoreOriginalState(),this._removeInactiveBinding(e)}}uncacheAction(e,t){let i=this.existingAction(e,t);null!==i&&(this._deactivateAction(i),this._removeInactiveAction(i))}},Am=class{constructor(e){this.value=e}clone(){return new Am(void 0===this.value.clone?this.value:this.value.clone())}},got=0,dU=class extends Wo{constructor(){super(),this.isUniformsGroup=!0,Object.defineProperty(this,"id",{value:got++}),this.name="",this.usage=mb,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 i=0,n=t.length;i<n;i++)this.uniforms.push(t[i].clone());return this}clone(){return(new this.constructor).copy(this)}},fU=class extends $h{constructor(e,t,i=1){super(e,t),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=i}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}},pU=class{constructor(e,t,i,n,r){this.isGLBufferAttribute=!0,this.name="",this.buffer=e,this.type=t,this.itemSize=i,this.elementSize=n,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}},na=class{constructor(e,t,i=0,n=1/0){this.ray=new lo(e,t),this.near=i,this.far=n,this.camera=null,this.layers=new df,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,i=[]){return mU(e,this,i,t),i.sort(gue),i}intersectObjects(e,t=!0,i=[]){for(let n=0,r=e.length;n<r;n++)mU(e[n],this,i,t);return i.sort(gue),i}};function gue(e,t){return e.distance-t.distance}function mU(e,t,i,n){if(e.layers.test(t.layers)&&e.raycast(t,i),!0===n){let n=e.children;for(let e=0,r=n.length;e<r;e++)mU(n[e],t,i,!0)}}var gf=class{constructor(e=1,t=0,i=0){return this.radius=e,this.phi=t,this.theta=i,this}set(e,t,i){return this.radius=e,this.phi=t,this.theta=i,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,i){return this.radius=Math.sqrt(e*e+t*t+i*i),0===this.radius?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,i),this.phi=Math.acos(os(t/this.radius,-1,1))),this}clone(){return(new this.constructor).copy(this)}},gU=class{constructor(e=1,t=0,i=0){return this.radius=e,this.theta=t,this.y=i,this}set(e,t,i){return this.radius=e,this.theta=t,this.y=i,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,i){return this.radius=Math.sqrt(e*e+i*i),this.theta=Math.atan2(e,i),this.y=t,this}clone(){return(new this.constructor).copy(this)}},vue=new xe,Mi=class{constructor(e=new xe(1/0,1/0),t=new xe(-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,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let i=vue.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),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,vue).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)}},yue=new D,iR=new D,ra=class{constructor(e=new D,t=new D){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){yue.subVectors(e,this.start),iR.subVectors(this.end,this.start);let i=iR.dot(iR),n=iR.dot(yue)/i;return t&&(n=os(n,0,1)),n}closestPointToPoint(e,t,i){let n=this.closestPointToPointParameter(e,t);return this.delta(i).multiplyScalar(n).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)}},xue=new D,vU=class extends on{constructor(e,t){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";let i=new Dt,n=[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;n.push(Math.cos(e),Math.sin(e),1,Math.cos(t),Math.sin(t),1)}i.setAttribute("position",new Bt(n,3));let r=new Gn({fog:!1,toneMapped:!1});this.cone=new qr(i,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),xue.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(xue),void 0!==this.color?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}},lf=new D,sR=new et,XN=new et,yU=class extends qr{constructor(e){let t=Ihe(e),i=new Dt,n=[],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&&(n.push(0,0,0),n.push(0,0,0),r.push(a.r,a.g,a.b),r.push(s.r,s.g,s.b))}i.setAttribute("position",new Bt(n,3)),i.setAttribute("color",new Bt(r,3)),super(i,new Gn({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,i=this.geometry,n=i.getAttribute("position");XN.copy(this.root.matrixWorld).invert();for(let r=0,a=0;r<t.length;r++){let e=t[r];e.parent&&e.parent.isBone&&(sR.multiplyMatrices(XN,e.matrixWorld),lf.setFromMatrixPosition(sR),n.setXYZ(a,lf.x,lf.y,lf.z),sR.multiplyMatrices(XN,e.parent.matrixWorld),lf.setFromMatrixPosition(sR),n.setXYZ(a+1,lf.x,lf.y,lf.z),a+=2)}i.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(e)}dispose(){this.geometry.dispose(),this.material.dispose()}};function Ihe(e){let t=[];!0===e.isBone&&t.push(e);for(let i=0;i<e.children.length;i++)t.push.apply(t,Ihe(e.children[i]));return t}var xU=class extends xt{constructor(e,t,i){super(new Ua(t,4,2),new ln({wireframe:!0,fog:!1,toneMapped:!1})),this.light=e,this.color=i,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)}},vot=new D,bue=new ct,Eue=new ct,bU=class extends on{constructor(e,t,i){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,this.type="HemisphereLightHelper";let n=new wm(t);n.rotateY(.5*Math.PI),this.material=new ln({wireframe:!0,fog:!1,toneMapped:!1}),void 0===this.color&&(this.material.vertexColors=!0);let r=n.getAttribute("position"),a=new Float32Array(3*r.count);n.setAttribute("color",new mn(a,3)),this.add(new xt(n,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");bue.copy(this.light.color),Eue.copy(this.light.groundColor);for(let e=0,i=t.count;e<i;e++){let n=e<i/2?bue:Eue;t.setXYZ(e,n.r,n.g,n.b)}t.needsUpdate=!0}this.light.updateWorldMatrix(!0,!1),e.lookAt(vot.setFromMatrixPosition(this.light.matrixWorld).negate())}},Nb=class extends qr{constructor(e=10,t=10,i=4473924,n=8947848){i=new ct(i),n=new ct(n);let r=t/2,a=e/t,s=e/2,o=[],l=[];for(let c=0,u=0,d=-s;c<=t;c++,d+=a){o.push(-s,0,d,s,0,d),o.push(d,0,-s,d,0,s);let e=c===r?i:n;e.toArray(l,u),u+=3,e.toArray(l,u),u+=3,e.toArray(l,u),u+=3,e.toArray(l,u),u+=3}let h=new Dt;h.setAttribute("position",new Bt(o,3)),h.setAttribute("color",new Bt(l,3)),super(h,new Gn({vertexColors:!0,toneMapped:!1})),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}},EU=class extends qr{constructor(e=10,t=16,i=8,n=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 i=h/t*(2*Math.PI),n=Math.sin(i)*e,l=Math.cos(i)*e;s.push(0,0,0),s.push(n,0,l);let c=1&h?r:a;o.push(c.r,c.g,c.b),o.push(c.r,c.g,c.b)}for(let h=0;h<i;h++){let t=1&h?r:a,l=e-e/i*h;for(let e=0;e<n;e++){let i=e/n*(2*Math.PI),r=Math.sin(i)*l,a=Math.cos(i)*l;s.push(r,0,a),o.push(t.r,t.g,t.b),i=(e+1)/n*(2*Math.PI),r=Math.sin(i)*l,a=Math.cos(i)*l,s.push(r,0,a),o.push(t.r,t.g,t.b)}}let l=new Dt;l.setAttribute("position",new Bt(s,3)),l.setAttribute("color",new Bt(o,3)),super(l,new Gn({vertexColors:!0,toneMapped:!1})),this.type="PolarGridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}},_ue=new D,aR=new D,Tue=new D,Bb=class extends on{constructor(e,t,i){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,this.type="DirectionalLightHelper",void 0===t&&(t=1);let n=new Dt;n.setAttribute("position",new Bt([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));let r=new Gn({fog:!1,toneMapped:!1});this.lightPlane=new fr(n,r),this.add(this.lightPlane),n=new Dt,n.setAttribute("position",new Bt([0,0,0,0,0,1],3)),this.targetLine=new fr(n,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),_ue.setFromMatrixPosition(this.light.matrixWorld),aR.setFromMatrixPosition(this.light.target.matrixWorld),Tue.subVectors(aR,_ue),this.lightPlane.lookAt(aR),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(aR),this.targetLine.scale.z=Tue.length()}},oR=new D,as=new Xh,Ub=class extends qr{constructor(e){let t=new Dt,i=new Gn({color:16777215,vertexColors:!0,toneMapped:!1}),n=[],r=[],a={};function s(e,t){o(e),o(t)}function o(e){n.push(0,0,0),r.push(0,0,0),void 0===a[e]&&(a[e]=[]),a[e].push(n.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(n,3)),t.setAttribute("color",new Bt(r,3)),super(t,i),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),c=new ct(43775),u=new ct(16777215),d=new ct(3355443);this.setColors(l,h,c,u,d)}setColors(e,t,i,n,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,i.r,i.g,i.b),a.setXYZ(33,i.r,i.g,i.b),a.setXYZ(34,i.r,i.g,i.b),a.setXYZ(35,i.r,i.g,i.b),a.setXYZ(36,i.r,i.g,i.b),a.setXYZ(37,i.r,i.g,i.b),a.setXYZ(38,n.r,n.g,n.b),a.setXYZ(39,n.r,n.g,n.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;as.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),fs("c",t,e,as,0,0,-1),fs("t",t,e,as,0,0,1),fs("n1",t,e,as,-1,-1,-1),fs("n2",t,e,as,1,-1,-1),fs("n3",t,e,as,-1,1,-1),fs("n4",t,e,as,1,1,-1),fs("f1",t,e,as,-1,-1,1),fs("f2",t,e,as,1,-1,1),fs("f3",t,e,as,-1,1,1),fs("f4",t,e,as,1,1,1),fs("u1",t,e,as,.7,1.1,-1),fs("u2",t,e,as,-.7,1.1,-1),fs("u3",t,e,as,0,2,-1),fs("cf1",t,e,as,-1,0,1),fs("cf2",t,e,as,1,0,1),fs("cf3",t,e,as,0,-1,1),fs("cf4",t,e,as,0,1,1),fs("cn1",t,e,as,-1,0,-1),fs("cn2",t,e,as,1,0,-1),fs("cn3",t,e,as,0,-1,-1),fs("cn4",t,e,as,0,1,-1),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function fs(e,t,i,n,r,a,s){oR.set(r,a,s).unproject(n);let o=t[e];if(void 0!==o){let e=i.getAttribute("position");for(let t=0,i=o.length;t<i;t++)e.setXYZ(o[t],oR.x,oR.y,oR.z)}}var lR=new Nt,_U=class extends qr{constructor(e,t=16776960){let i=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]),n=new Float32Array(24),r=new Dt;r.setIndex(new mn(i,1)),r.setAttribute("position",new mn(n,3)),super(r,new Gn({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&&lR.setFromObject(this.object),lR.isEmpty())return;let t=lR.min,i=lR.max,n=this.geometry.attributes.position,r=n.array;r[0]=i.x,r[1]=i.y,r[2]=i.z,r[3]=t.x,r[4]=i.y,r[5]=i.z,r[6]=t.x,r[7]=t.y,r[8]=i.z,r[9]=i.x,r[10]=t.y,r[11]=i.z,r[12]=i.x,r[13]=i.y,r[14]=t.z,r[15]=t.x,r[16]=i.y,r[17]=t.z,r[18]=t.x,r[19]=t.y,r[20]=t.z,r[21]=i.x,r[22]=t.y,r[23]=t.z,n.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()}},TU=class extends qr{constructor(e,t=16776960){let i=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]),n=new Dt;n.setIndex(new mn(i,1)),n.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(n,new Gn({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()}},wU=class extends fr{constructor(e,t=1,i=16776960){let n=i,r=new Dt;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 Gn({color:n,toneMapped:!1})),this.type="PlaneHelper",this.plane=e,this.size=t;let a=new Dt;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 xt(a,new ln({color:n,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()}},wue=new D,cR,YN,Sc=class extends on{constructor(e=new D(0,0,1),t=new D(0,0,0),i=1,n=16776960,r=.2*i,a=.2*r){super(),this.type="ArrowHelper",void 0===cR&&((cR=new Dt).setAttribute("position",new Bt([0,0,0,0,1,0],3)),(YN=new Tc(0,.5,1,5,1)).translate(0,-.5,0)),this.position.copy(t),this.line=new fr(cR,new Gn({color:n,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new xt(YN,new ln({color:n,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(e),this.setLength(i,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{wue.set(e.z,0,-e.x).normalize();let t=Math.acos(e.y);this.quaternion.setFromAxisAngle(wue,t)}}setLength(e,t=.2*e,i=.2*t){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(i,t,i),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()}},SU=class extends qr{constructor(e=1){let t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],i=new Dt;i.setAttribute("position",new Bt(t,3)),i.setAttribute("color",new Bt([1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],3)),super(i,new Gn({vertexColors:!0,toneMapped:!1})),this.type="AxesHelper"}setColors(e,t,i){let n=new ct,r=this.geometry.attributes.color.array;return n.set(e),n.toArray(r,0),n.toArray(r,3),n.set(t),n.toArray(r,6),n.toArray(r,9),n.set(i),n.toArray(r,12),n.toArray(r,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}},Cm=class{constructor(){this.type="ShapePath",this.color=new ct,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new Mu,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,i,n){return this.currentPath.quadraticCurveTo(e,t,i,n),this}bezierCurveTo(e,t,i,n,r,a){return this.currentPath.bezierCurveTo(e,t,i,n,r,a),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e){function t(e,t){let i=t.length,n=!1;for(let r=i-1,a=0;a<i;r=a++){let i=t[r],s=t[a],o=s.x-i.x,l=s.y-i.y;if(Math.abs(l)>Number.EPSILON){if(l<0&&(i=t[a],o=-o,s=t[r],l=-l),e.y<i.y||e.y>s.y)continue;if(e.y===i.y){if(e.x===i.x)return!0}else{let t=l*(e.x-i.x)-o*(e.y-i.y);if(0===t)return!0;if(t<0)continue;n=!n}}else{if(e.y!==i.y)continue;if(s.x<=e.x&&e.x<=i.x||i.x<=e.x&&e.x<=s.x)return!0}}return n}let i=zs.isClockWise,n=this.subPaths;if(0===n.length)return[];let r,a,s,o=[];if(1===n.length)return a=n[0],s=new _s,s.curves=a.curves,o.push(s),o;let l=!i(n[0].getPoints());l=e?!l:l;let h,c,u=[],d=[],p=[],f=0;d[f]=void 0,p[f]=[];for(let m=0,g=n.length;m<g;m++)a=n[m],h=a.getPoints(),r=i(h),r=e?!r:r,r?(!l&&d[f]&&f++,d[f]={s:new _s,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 i=0,n=e.length;i<n;i++){let n=e[i],r=new _s;r.curves=n.curves,t.push(r)}return t}(n);if(d.length>1){let e=!1,i=0;for(let t=0,n=d.length;t<n;t++)u[t]=[];for(let n=0,r=d.length;n<r;n++){let r=p[n];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)&&(n!==r&&i++,o?(o=!1,u[r].push(s)):e=!0);o&&u[n].push(s)}}i>0&&!1===e&&(p=u)}for(let m=0,g=d.length;m<g;m++){s=d[m].s,o.push(s),c=p[m];for(let e=0,t=c.length;e<t;e++)s.holes.push(c[e].h)}return o}};"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:jR}})),"undefined"!=typeof window&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=jR);var ku=new vr,Lhe=new D,Dhe=new D,Ohe=new D,khe=new D;function eA(e,t,i,n,r,a,s){if(Lhe.fromBufferAttribute(t,n).applyMatrix4(e.matrixWorld),Dhe.fromBufferAttribute(t,r).applyMatrix4(e.matrixWorld),i.ray.distanceSqToSegment(Lhe,Dhe,khe,Ohe)>a)return!1;let o=i.ray.origin.distanceTo(khe);return!(o<i.near||o>i.far)&&(s.push({distance:o,point:Ohe.clone(),index:n,object:e}),!0)}fr.prototype.raycast=function(e,t){let i=this.geometry,n=this.matrixWorld,r=e.params.Line.threshold,a=i.drawRange;if(null===i.boundingSphere&&i.computeBoundingSphere(),ku.copy(i.boundingSphere),ku.applyMatrix4(n),ku.radius+=r,!1===e.ray.intersectsSphere(ku))return;let s=r*r,o=this.isLineSegments?2:1,l=i.index,h=i.attributes.position,c=t.length;if(null!==l){let i=this.userData.batches;if(i&&i.length>0&&i[0].boundingSphere)for(let r=0;r<i.length;r++){let a=i[r];if(ku.copy(a.boundingSphere),ku.applyMatrix4(n),!1!==e.ray.intersectsSphere(ku))for(let i=a.indexStart,n=a.indexStart+a.indexCount-1;i<n;i+=o)if(eA(this,h,e,l.getX(i),l.getX(i+1),s,t)&&(t[t.length-1].index=i,t.length-c>=1))return}else for(let n=Math.max(0,a.start),r=Math.min(l.count,a.start+a.count)-1;n<r;n+=o)if(eA(this,h,e,l.getX(n),l.getX(n+1),s,t)&&(t[t.length-1].index=n,t.length-c>=1))return}else{let i=this.userData.batches;if(i&&i.length>0&&i[0].boundingSphere)for(let r=0;r<i.length;r++){let a=i[r];if(ku.copy(a.boundingSphere),ku.applyMatrix4(n),!1!==e.ray.intersectsSphere(ku))for(let i=a.positionStart,n=a.positionStart+a.positionCount-1;i<n;i+=o)if(eA(this,h,e,i,i+1,s,t)&&t.length-c>=1)return}else for(let n=Math.max(0,a.start),r=Math.min(h.count,a.start+a.count)-1;n<r;n+=o)if(eA(this,h,e,n,n+1,s,t)&&t.length-c>=1)return}};var Fhe=Math.pow(2,-24),Dm=class{constructor(){}};function Pl(e,t,i){return i.min.x=t[e],i.min.y=t[e+1],i.min.z=t[e+2],i.max.x=t[e+3],i.max.y=t[e+4],i.max.z=t[e+5],i}function XU(e){let t=-1,i=-1/0;for(let n=0;n<3;n++){let r=e[n+3]-e[n];r>i&&(i=r,t=n)}return t}function YU(e,t){t.set(e)}function $U(e,t,i){let n,r;for(let a=0;a<3;a++){let s=a+3;n=e[a],r=t[a],i[a]=n<r?n:r,n=e[s],r=t[s],i[s]=n>r?n:r}}function zb(e,t,i){for(let n=0;n<3;n++){let r=t[e+2*n],a=t[e+2*n+1],s=r-a,o=r+a;s<i[n]&&(i[n]=s),o>i[n+3]&&(i[n+3]=o)}}function Lv(e){let t=e[3]-e[0],i=e[4]-e[1],n=e[5]-e[2];return 2*(t*i+i*n+n*t)}function bot(e,t){if(!e.index){let i,n=e.attributes.position.count,r=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;i=n>65535?new Uint32Array(new r(4*n)):new Uint16Array(new r(2*n)),e.setIndex(new mn(i,1));for(let e=0;e<n;e++)i[e]=e}}function Eot(e){if(!e.groups||!e.groups.length)return[{offset:0,count:e.index.count/3}];let t=[],i=new Set;for(let r of e.groups)i.add(r.start),i.add(r.start+r.count);let n=Array.from(i.values()).sort(((e,t)=>e-t));for(let r=0;r<n.length-1;r++){let e=n[r],i=n[r+1];t.push({offset:e/3,count:(i-e)/3})}return t}function KU(e,t,i,n,r=null){let a=1/0,s=1/0,o=1/0,l=-1/0,h=-1/0,c=-1/0,u=1/0,d=1/0,p=1/0,f=-1/0,m=-1/0,g=-1/0,v=null!==r;for(let y=6*t,x=6*(t+i);y<x;y+=6){let t=e[y+0],i=e[y+1],n=t-i,r=t+i;n<a&&(a=n),r>l&&(l=r),v&&t<u&&(u=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>c&&(c=T),v&&S<p&&(p=S),v&&S>g&&(g=S)}n[0]=a,n[1]=s,n[2]=o,n[3]=l,n[4]=h,n[5]=c,v&&(r[0]=u,r[1]=d,r[2]=p,r[3]=f,r[4]=m,r[5]=g)}function _ot(e,t,i,n){let r=1/0,a=1/0,s=1/0,o=-1/0,l=-1/0,h=-1/0;for(let c=6*t,u=6*(t+i);c<u;c+=6){let t=e[c+0];t<r&&(r=t),t>o&&(o=t);let i=e[c+2];i<a&&(a=i),i>l&&(l=i);let n=e[c+4];n<s&&(s=n),n>h&&(h=n)}n[0]=r,n[1]=a,n[2]=s,n[3]=o,n[4]=l,n[5]=h}function Tot(e,t,i,n,r){let a=i,s=i+n-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 i=0;i<3;i++){let n=e[3*a+i];e[3*a+i]=e[3*s+i],e[3*s+i]=n;let r=t[6*a+2*i+0];t[6*a+2*i+0]=t[6*s+2*i+0],t[6*s+2*i+0]=r;let o=t[6*a+2*i+1];t[6*a+2*i+1]=t[6*s+2*i+1],t[6*s+2*i+1]=o}a++,s--}}var td=32,wot=(e,t)=>e.candidate-t.candidate,xf=new Array(td).fill().map((()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0}))),tA=new Float32Array(6);function Sot(e,t,i,n,r,a){let s=-1,o=0;if(0===a)s=XU(t),-1!==s&&(o=(t[s]+t[s+3])/2);else if(1===a)s=XU(e),-1!==s&&(o=Mot(i,n,r,s));else if(2===a){let a=Lv(e),l=1.25*r,h=6*n,c=6*(n+r);for(let e=0;e<3;e++){let n=t[e],u=(t[e+3]-n)/td;if(r<td/4){let t=[...xf];t.length=r;let n=0;for(let r=h;r<c;r+=6,n++){let a=t[n];a.candidate=i[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;zb(r,i,s)}t.sort(wot);let u=r;for(let e=0;e<u;e++){let i=t[e];for(;e+1<u&&t[e+1].candidate===i.candidate;)t.splice(e+1,1),u--}for(let r=h;r<c;r+=6){let n=i[r+2*e];for(let e=0;e<u;e++){let a=t[e];n>=a.candidate?zb(r,i,a.rightCacheBounds):(zb(r,i,a.leftCacheBounds),a.count++)}}for(let i=0;i<u;i++){let n=t[i],h=n.count,c=r-n.count,u=n.leftCacheBounds,d=n.rightCacheBounds,p=0;0!==h&&(p=Lv(u)/a);let f=0;0!==c&&(f=Lv(d)/a);let m=1+1.25*(p*h+f*c);m<l&&(s=e,l=m,o=n.candidate)}}else{for(let e=0;e<td;e++){let t=xf[e];t.count=0,t.candidate=n+u+e*u;let i=t.bounds;for(let e=0;e<3;e++)i[e]=1/0,i[e+3]=-1/0}for(let r=h;r<c;r+=6){let t=~~((i[r+2*e]-n)/u);t>=td&&(t=td-1);let a=xf[t];a.count++,zb(r,i,a.bounds)}let t=xf[td-1];YU(t.bounds,t.rightCacheBounds);for(let e=td-2;e>=0;e--){let t=xf[e],i=xf[e+1];$U(t.bounds,i.rightCacheBounds,t.rightCacheBounds)}let d=0;for(let i=0;i<td-1;i++){let t=xf[i],n=t.count,h=t.bounds,c=xf[i+1].rightCacheBounds;0!==n&&(0===d?YU(h,tA):$U(h,tA,tA)),d+=n;let u=0,p=0;0!==d&&(u=Lv(tA)/a);let f=r-d;0!==f&&(p=Lv(c)/a);let m=1+1.25*(u*d+p*f);m<l&&(s=e,l=m,o=t.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${a} used.`);return{axis:s,pos:o}}function Mot(e,t,i,n){let r=0;for(let a=t,s=t+i;a<s;a++)r+=e[6*a+2*n];return r/i}function Rot(e,t){let i=e.attributes.position,n=e.index.array,r=n.length/3,a=new Float32Array(6*r),s=i.normalized,o=i.array,l=i.offset||0,h=3;i.isInterleavedBufferAttribute&&(h=i.data.stride);let c=["getX","getY","getZ"];for(let u=0;u<r;u++){let e,r,d,p=3*u,f=6*u;s?(e=n[p+0],r=n[p+1],d=n[p+2]):(e=n[p+0]*h+l,r=n[p+1]*h+l,d=n[p+2]*h+l);for(let n=0;n<3;n++){let l,h,u;s?(l=i[c[n]](e),h=i[c[n]](r),u=i[c[n]](d)):(l=o[e+n],h=o[r+n],u=o[d+n]);let p=l;h<p&&(p=h),u<p&&(p=u);let m=l;h>m&&(m=h),u>m&&(m=u);let g=(m-p)/2,v=2*n;a[f+v+0]=p+g,a[f+v+1]=g+(Math.abs(p)+g)*Fhe,p<t[n]&&(t[n]=p),m>t[n+3]&&(t[n+3]=m)}}return a}function Aot(e,t){function i(e){d&&d(e/p)}function n(t,r,d,p=null,m=0){if(!f&&m>=l&&(f=!0,h&&(console.warn(`MeshBVH: Max depth of ${l} reached when generating BVH. Consider increasing maxDepth.`),console.warn(e))),d<=c||m>=l)return i(r+d),t.offset=r,t.count=d,t;let g=Sot(t.boundingData,p,s,r,d,u);if(-1===g.axis)return i(r+d),t.offset=r,t.count=d,t;let v=Tot(o,s,r,d,g);if(v===r||v===r+d)i(r+d),t.offset=r,t.count=d;else{t.splitAxis=g.axis;let e=new Dm,i=r,o=v-r;t.left=e,e.boundingData=new Float32Array(6),KU(s,i,o,e.boundingData,a),n(e,i,o,a,m+1);let l=new Dm,h=v,c=d-o;t.right=l,l.boundingData=new Float32Array(6),KU(s,h,c,l.boundingData,a),n(l,h,c,a,m+1)}return t}bot(e,t);let r=new Float32Array(6),a=new Float32Array(6),s=Rot(e,r),o=e.index.array,l=t.maxDepth,h=t.verbose,c=t.maxLeafTris,u=t.strategy,d=t.onProgress,p=e.index.count/3,f=!1,m=[],g=Eot(e);if(1===g.length){let e=g[0],t=new Dm;t.boundingData=r,_ot(s,e.offset,e.count,a),n(t,e.offset,e.count,a),m.push(t)}else for(let v of g){let e=new Dm;e.boundingData=new Float32Array(6),KU(s,v.offset,v.count,e.boundingData,a),n(e,v.offset,v.count,a),m.push(e)}return m}function Uhe(e,t){let i,n,r,a=Aot(e,t),s=[],o=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;for(let c=0;c<a.length;c++){let e=a[c],t=new o(32*l(e));i=new Float32Array(t),n=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 n=0;n<6;n++)i[a+n]=l[n];if(o){let i=t.offset,o=t.count;return n[a+6]=i,r[s+14]=o,r[s+15]=65535,e+32}{let i,r=t.left,s=t.right,o=t.splitAxis;if(i=h(e+32,r),i/4>Math.pow(2,32))throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return n[a+6]=i/4,i=h(i,s),n[a+7]=o,i}}}var po=class{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(e,t){let i=1/0,n=-1/0;for(let r=0,a=e.length;r<a;r++){let a=e[r][t];i=a<i?a:i,n=a>n?a:n}this.min=i,this.max=n}setFromPoints(e,t){let i=1/0,n=-1/0;for(let r=0,a=t.length;r<a;r++){let a=t[r],s=e.dot(a);i=s<i?s:i,n=s>n?s:n}this.min=i,this.max=n}isSeparated(e){return this.min>e.max||e.min>this.max}};po.prototype.setFromBox=function(){let e=new D;return function(t,i){let n=i.min,r=i.max,a=1/0,s=-1/0;for(let o=0;o<=1;o++)for(let i=0;i<=1;i++)for(let l=0;l<=1;l++){e.x=n.x*o+r.x*(1-o),e.y=n.y*i+r.y*(1-i),e.z=n.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 jPt=function(){let e=new po;return function(t,i){let n=t.points,r=t.satAxes,a=t.satBounds,s=i.points,o=i.satAxes,l=i.satBounds;for(let h=0;h<3;h++){let t=a[h],i=r[h];if(e.setFromPoints(i,s),t.isSeparated(e))return!1}for(let h=0;h<3;h++){let t=l[h],i=o[h];if(e.setFromPoints(i,n),t.isSeparated(e))return!1}}}(),Cot=function(){let e=new D,t=new D,i=new D;return function(n,r,a){let s=n.start,o=e,l=r.start,h=t;i.subVectors(s,l),e.subVectors(n.end,n.start),t.subVectors(r.end,r.start);let c,u,d=i.dot(h),p=h.dot(o),f=h.dot(h),m=i.dot(o),g=o.dot(o)*f-p*p;c=0!==g?(d*p-m*f)/g:0,u=(d+c*p)/f,a.x=c,a.y=u}}(),Gb=function(){let e=new xe,t=new D,i=new D;return function(n,r,a,s){Cot(n,r,e);let o=e.x,l=e.y;if(o>=0&&o<=1&&l>=0&&l<=1)return n.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 n.closestPointToPoint(s,!0,a);if(l>=0&&l<=1)return o<0?n.at(0,a):n.at(1,a),void r.closestPointToPoint(a,!0,s);{let e,h;e=o<0?n.start:n.end,h=l<0?r.start:r.end;let c=t,u=i;return n.closestPointToPoint(h,!0,t),r.closestPointToPoint(e,!0,i),c.distanceToSquared(h)<=u.distanceToSquared(e)?(a.copy(c),void s.copy(h)):(a.copy(e),void s.copy(u))}}}(),Hhe=function(){let e=new D,t=new D,i=new zr,n=new ra;return function(r,a){let{radius:s,center:o}=r,{a:l,b:h,c:c}=a;if(n.start=l,n.end=h,n.closestPointToPoint(o,!0,e).distanceTo(o)<=s||(n.start=l,n.end=c,n.closestPointToPoint(o,!0,e).distanceTo(o)<=s)||(n.start=h,n.end=c,n.closestPointToPoint(o,!0,e).distanceTo(o)<=s))return!0;let u=a.getPlane(i);if(Math.abs(u.distanceToPoint(o))<=s){let e=u.projectPoint(o,t);if(a.containsPoint(e))return!0}return!1}}(),Pot=1e-15;function Dv(e){return Math.abs(e)<Pot}var mo=class extends Zr{constructor(...e){super(...e),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map((()=>new D)),this.satBounds=new Array(4).fill().map((()=>new po)),this.points=[this.a,this.b,this.c],this.sphere=new vr,this.plane=new zr,this.needsUpdate=!0}intersectsSphere(e){return Hhe(e,this)}update(){let e=this.a,t=this.b,i=this.c,n=this.points,r=this.satAxes,a=this.satBounds,s=r[0],o=a[0];this.getNormal(s),o.setFromPoints(s,n);let l=r[1],h=a[1];l.subVectors(e,t),h.setFromPoints(l,n);let c=r[2],u=a[2];c.subVectors(t,i),u.setFromPoints(c,n);let d=r[3],p=a[3];d.subVectors(i,e),p.setFromPoints(d,n),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(s,e),this.needsUpdate=!1}};mo.prototype.closestPointToSegment=function(){let e=new D,t=new D,i=new ra;return function(n,r=null,a=null){let s,{start:o,end:l}=n,h=this.points,c=1/0;for(let u=0;u<3;u++){let o=(u+1)%3;i.start.copy(h[u]),i.end.copy(h[o]),Gb(i,n,e,t),s=e.distanceToSquared(t),s<c&&(c=s,r&&r.copy(e),a&&a.copy(t))}return this.closestPointToPoint(o,e),s=o.distanceToSquared(e),s<c&&(c=s,r&&r.copy(e),a&&a.copy(o)),this.closestPointToPoint(l,e),s=l.distanceToSquared(e),s<c&&(c=s,r&&r.copy(e),a&&a.copy(l)),Math.sqrt(c)}}(),mo.prototype.intersectsTriangle=function(){let e=new mo,t=new Array(3),i=new Array(3),n=new po,r=new po,a=new D,s=new D,o=new D,l=new D,h=new ra,c=new ra,u=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;i[0]=d.a,i[1]=d.b,i[2]=d.c;for(let t=0;t<4;t++){let r=e[t],a=s[t];if(n.setFromPoints(a,i),r.isSeparated(n))return!1}let o=d.satBounds,l=d.satAxes;t[0]=this.a,t[1]=this.b,t[2]=this.c;for(let i=0;i<4;i++){let e=o[i],r=l[i];if(n.setFromPoints(r,t),e.isSeparated(n))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),n.setFromPoints(a,t),r.setFromPoints(a,i),n.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,i=0;for(let o=0;o<3;o++){let n=e[o],r=e[(o+1)%3];h.start.copy(n),h.end.copy(r),h.delta(s);let a=t?c.start:c.end,l=Dv(g.distanceToPoint(n));if(Dv(g.normal.dot(s))&&l){c.copy(h),i=2;break}if((g.intersectLine(h,a)||l)&&!Dv(a.distanceTo(r))){if(i++,t)break;t=!0}}if(1===i&&d.containsPoint(c.end))return p&&(p.start.copy(c.end),p.end.copy(c.end)),!0;if(2!==i)return!1;let n=d.points,r=!1,a=0;for(let s=0;s<3;s++){let e=n[s],t=n[(s+1)%3];h.start.copy(e),h.end.copy(t),h.delta(o);let i=r?u.start:u.end,l=Dv(m.distanceToPoint(e));if(Dv(m.normal.dot(o))&&l){u.copy(h),a=2;break}if((m.intersectLine(h,i)||l)&&!Dv(i.distanceTo(t))){if(a++,r)break;r=!0}}if(1===a&&this.containsPoint(u.end))return p&&(p.start.copy(u.end),p.end.copy(u.end)),!0;if(2!==a)return!1;if(c.delta(s),u.delta(o),s.dot(o)<0){let e=u.start;u.start=u.end,u.end=e}let f=c.start.dot(s),v=c.end.dot(s),y=u.start.dot(s),x=u.end.dot(s);return(f===x||y===v||v<y!==f<x)&&(p&&(l.subVectors(c.start,u.start),l.dot(s)>0?p.start.copy(c.start):p.start.copy(u.start),l.subVectors(c.end,u.end),l.dot(s)<0?p.end.copy(c.end):p.end.copy(u.end)),!0)}}}(),mo.prototype.distanceToPoint=function(){let e=new D;return function(t){return this.closestPointToPoint(t,e),t.distanceTo(e)}}(),mo.prototype.distanceToTriangle=function(){let e=new D,t=new D,i=["a","b","c"],n=new ra,r=new ra;return function(a,s=null,o=null){let l=s||o?n: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 n,r=i[t],l=a[r];this.closestPointToPoint(l,e),n=l.distanceToSquared(e),n<h&&(h=n,s&&s.copy(e),o&&o.copy(l));let c=this[r];a.closestPointToPoint(c,e),n=c.distanceToSquared(e),n<h&&(h=n,s&&s.copy(c),o&&o.copy(e))}for(let c=0;c<3;c++){let l=i[c],u=i[(c+1)%3];n.set(this[l],this[u]);for(let c=0;c<3;c++){let l=i[c],u=i[(c+1)%3];r.set(a[l],a[u]),Gb(n,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 go=class{constructor(e,t,i){this.isOrientedBox=!0,this.min=new D,this.max=new D,this.matrix=new et,this.invMatrix=new et,this.points=new Array(8).fill().map((()=>new D)),this.satAxes=new Array(3).fill().map((()=>new D)),this.satBounds=new Array(3).fill().map((()=>new po)),this.alignedSatBounds=new Array(3).fill().map((()=>new po)),this.needsUpdate=!1,e&&this.min.copy(e),t&&this.max.copy(t),i&&this.matrix.copy(i)}set(e,t,i){this.min.copy(e),this.max.copy(t),this.matrix.copy(i),this.needsUpdate=!0}copy(e){this.min.copy(e.min),this.max.copy(e.max),this.matrix.copy(e.matrix),this.needsUpdate=!0}};go.prototype.update=function(){let e=this.matrix,t=this.min,i=this.max,n=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=n[1*l|2*r|4*a];s.x=l?i.x:t.x,s.y=r?i.y:t.y,s.z=a?i.z:t.z,s.applyMatrix4(e)}let r=this.satBounds,a=this.satAxes,s=n[0];for(let l=0;l<3;l++){let e=a[l],t=r[l],i=n[1<<l];e.subVectors(s,i),t.setFromPoints(e,n)}let o=this.alignedSatBounds;o[0].setFromPointsField(n,"x"),o[1].setFromPointsField(n,"y"),o[2].setFromPointsField(n,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1},go.prototype.intersectsBox=function(){let e=new po;return function(t){this.needsUpdate&&this.update();let i=t.min,n=t.max,r=this.satBounds,a=this.satAxes,s=this.alignedSatBounds;if(e.min=i.x,e.max=n.x,s[0].isSeparated(e)||(e.min=i.y,e.max=n.y,s[1].isSeparated(e))||(e.min=i.z,e.max=n.z,s[2].isSeparated(e)))return!1;for(let o=0;o<3;o++){let i=a[o],n=r[o];if(e.setFromBox(i,t),n.isSeparated(e))return!1}return!0}}(),go.prototype.intersectsTriangle=function(){let e=new mo,t=new Array(3),i=new po,n=new po,r=new D;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 n=s[e],r=o[e];if(i.setFromPoints(r,t),n.isSeparated(i))return!1}let l=a.satBounds,h=a.satAxes,c=this.points;for(let e=0;e<3;e++){let t=l[e],n=h[e];if(i.setFromPoints(n,c),t.isSeparated(i))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),i.setFromPoints(r,t),n.setFromPoints(r,c),i.isSeparated(n))return!1}}return!0}}(),go.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},go.prototype.distanceToPoint=function(){let e=new D;return function(t){return this.closestPointToPoint(t,e),t.distanceTo(e)}}(),go.prototype.distanceToBox=function(){let e=["x","y","z"],t=new Array(12).fill().map((()=>new ra)),i=new Array(12).fill().map((()=>new ra)),n=new D,r=new D;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,n),a.closestPointToPoint(n,r),o&&o.copy(n),l&&l.copy(r)),0;let h=s*s,c=a.min,u=a.max,d=this.points,p=1/0;for(let e=0;e<8;e++){let t=d[e];r.copy(t).clamp(c,u);let i=t.distanceToSquared(r);if(i<p&&(p=i,o&&o.copy(t),l&&l.copy(r),i<h))return Math.sqrt(i)}let f=0;for(let n=0;n<3;n++)for(let r=0;r<=1;r++)for(let a=0;a<=1;a++){let s=(n+1)%3,o=(n+2)%3,l=1<<n|r<<s|a<<o,h=d[r<<s|a<<o],p=d[l];t[f].set(h,p);let m=e[n],g=e[s],v=e[o],y=i[f],x=y.start,b=y.end;x[m]=c[m],x[g]=r?c[g]:u[g],x[v]=a?c[v]:u[g],b[m]=u[m],b[g]=r?c[g]:u[g],b[v]=a?c[v]:u[g],f++}for(let e=0;e<=1;e++)for(let t=0;t<=1;t++)for(let i=0;i<=1;i++){r.x=e?u.x:c.x,r.y=t?u.y:c.y,r.z=i?u.z:c.z,this.closestPointToPoint(r,n);let a=r.distanceToSquared(n);if(a<p&&(p=a,o&&o.copy(n),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=i[e];Gb(a,t,n,r);let s=n.distanceToSquared(r);if(s<p&&(p=s,o&&o.copy(n),l&&l.copy(r),s<h))return Math.sqrt(s)}}return Math.sqrt(p)}}();var rA=new D,iA=new D,sA=new D,Vhe=new xe,zhe=new xe,Ghe=new xe,qhe=new D;function Iot(e,t,i,n,r,a){let s;return s=a===Ji?e.intersectTriangle(n,i,t,!0,r):e.intersectTriangle(t,i,n,a!==Sr,r),null===s?null:{distance:e.origin.distanceTo(r),point:r.clone()}}function Lot(e,t,i,n,r,a,s){rA.fromBufferAttribute(t,n),iA.fromBufferAttribute(t,r),sA.fromBufferAttribute(t,a);let o=Iot(e,rA,iA,sA,qhe,s);if(o){i&&(Vhe.fromBufferAttribute(i,n),zhe.fromBufferAttribute(i,r),Ghe.fromBufferAttribute(i,a),o.uv=Zr.getUV(qhe,rA,iA,sA,Vhe,zhe,Ghe,new xe));let e={a:n,b:r,c:a,normal:new D,materialIndex:0};Zr.getNormal(rA,iA,sA,e.normal),o.face=e,o.faceIndex=n}return o}function QU(e,t,i,n,r){let a=3*n,s=e.index.getX(a),o=e.index.getX(a+1),l=e.index.getX(a+2),h=Lot(i,e.attributes.position,e.attributes.uv,s,o,l,t);return h?(h.faceIndex=n,r&&r.push(h),h):null}function Whe(e,t,i,n,r,a){for(let s=n,o=n+r;s<o;s++)QU(e,t,i,s,a)}function jhe(e,t,i,n,r){let a=1/0,s=null;for(let o=n,l=n+r;o<l;o++){let n=QU(e,t,i,o);n&&n.distance<a&&(s=n,a=n.distance)}return s}function eH(e,t,i){return null===e||(e.point.applyMatrix4(t.matrixWorld),e.distance=e.point.distanceTo(i.ray.origin),e.object=t,e.distance<i.near||e.distance>i.far)?null:e}function Il(e,t,i,n){let r=e.a,a=e.b,s=e.c,o=t,l=t+1,h=t+2;i&&(o=i.getX(t),l=i.getX(t+1),h=i.getX(t+2)),r.x=n.getX(o),r.y=n.getY(o),r.z=n.getZ(o),a.x=n.getX(l),a.y=n.getY(l),a.z=n.getZ(l),s.x=n.getX(h),s.y=n.getY(h),s.z=n.getZ(h)}function tH(e,t,i,n,r,a,s){let o=i.index,l=i.attributes.position;for(let h=e,c=t+e;h<c;h++)if(Il(s,3*h,o,l),s.needsUpdate=!0,n(s,h,r,a))return!0;return!1}var Ov=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 nd(e,t){return 65535===t[e+15]}function Om(e,t){return t[e+6]}function kv(e,t){return t[e+14]}function Fv(e){return e+8}function Nv(e,t){return t[e+6]}function Xhe(e,t){return t[e+7]}var Bv=new Nt,oA=new D,Oot=["x","y","z"];function lA(e,t,i,n,r){let a=2*e,s=Uv,o=bf,l=Ef;if(nd(a,o))Whe(t,i,n,Om(e,l),kv(a,o),r);else{let a=Fv(e);uA(a,s,n,oA)&&lA(a,t,i,n,r);let o=Nv(e,l);uA(o,s,n,oA)&&lA(o,t,i,n,r)}}function cA(e,t,i,n){let r=2*e,a=Uv,s=bf,o=Ef;if(nd(r,s))return jhe(t,i,n,Om(e,o),kv(r,s));{let r,s,l=Xhe(e,o),h=Oot[l],c=n.direction[h]>=0;c?(r=Fv(e),s=Nv(e,o)):(r=Nv(e,o),s=Fv(e));let u=uA(r,a,n,oA)?cA(r,t,i,n):null;if(u){let e=u.point[h];if(c?e<=a[s+l]:e>=a[s+l+3])return u}let d=uA(s,a,n,oA)?cA(s,t,i,n):null;return u&&d?u.distance<=d.distance?u:d:u||d||null}}var Yhe=function(){let e,t,i=[],n=new Ov((()=>new Nt));return function(...a){e=n.getPrimitive(),t=n.getPrimitive(),i.push(e,t);let s=r(...a);n.releasePrimitive(e),n.releasePrimitive(t),i.pop(),i.pop();let o=i.length;return o>0&&(t=i[o-1],e=i[o-2]),s};function r(i,n,a,s,o=null,l=0,h=0){function c(e){let t=2*e,i=bf,n=Ef;for(;!nd(t,i);)t=2*(e=Fv(e));return Om(e,n)}function u(e){let t=2*e,i=bf,n=Ef;for(;!nd(t,i);)t=2*(e=Nv(e,n));return Om(e,n)+kv(t,i)}let d=2*i,p=Uv,f=bf,m=Ef;if(nd(d,f)){let t=Om(i,m),n=kv(d,f);return Pl(i,p,e),s(t,n,!1,h,l+i,e)}{let d,g,v,y,x=Fv(i),b=Nv(i,m),_=x,w=b;if(o&&(v=e,y=t,Pl(_,p,v),Pl(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,Pl(_,p,v));let S,M=a(v,nd(2*_,f),d,h+1,l+_);if(2===M){let e=c(_);S=s(e,u(_)-e,!0,h+1,l+_,v)}else S=M&&r(_,n,a,s,o,l,h+1);if(S)return!0;y=t,Pl(w,p,y);let E,T=a(y,nd(2*w,f),g,h+1,l+w);if(2===T){let e=c(w);E=s(e,u(w)-e,!0,h+1,l+w,y)}else E=T&&r(w,n,a,s,o,l,h+1);return!!E}}}(),$he=function(){let e=new mo,t=new mo,i=new et,n=new go,r=new go;return function a(s,o,l,h,c=null){let u=2*s,d=Uv,p=bf,f=Ef;if(null===c&&(l.boundingBox||l.computeBoundingBox(),n.set(l.boundingBox.min,l.boundingBox.max,h),c=n),!nd(u,p)){let e=s+8,t=f[s+6];return Pl(e,d,Bv),!!(c.intersectsBox(Bv)&&a(e,o,l,h,c)||(Pl(t,d,Bv),c.intersectsBox(Bv)&&a(t,o,l,h,c)))}{let n=o,a=n.index,c=n.attributes.position,m=l.index,g=l.attributes.position,v=Om(s,f),y=kv(u,p);if(i.copy(h).invert(),l.boundsTree)return Pl(s,d,r),r.matrix.copy(i),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 i=3*v,n=3*(y+v);i<n;i+=3)if(Il(t,i,a,c),t.needsUpdate=!0,e.intersectsTriangle(t))return!0;return!1}});for(let r=3*v,s=y+3*v;r<s;r+=3){Il(e,r,a,c),e.a.applyMatrix4(i),e.b.applyMatrix4(i),e.c.applyMatrix4(i),e.needsUpdate=!0;for(let i=0,n=m.count;i<n;i+=3)if(Il(t,i,m,g),t.needsUpdate=!0,e.intersectsTriangle(t))return!0}}}}();function uA(e,t,i,n){return Pl(e,t,Bv),i.intersectBox(Bv,n)}var nH=[],aA,Uv,bf,Ef;function Hv(e){aA&&nH.push(aA),aA=e,Uv=new Float32Array(e),bf=new Uint16Array(e),Ef=new Uint32Array(e)}function qb(){aA=null,Uv=null,bf=null,Ef=null,nH.length&&Hv(nH.pop())}var rH=Symbol("skip tree generation"),iH=new Nt,sH=new Nt,Vv=new et,km=new go,Wb=new go,jb=new D,hA=new D,kot=new D,Fot=new D,Not=new D,Zhe=new Nt,Fu=new Ov((()=>new mo)),Mc=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."),Mc.serialize(arguments[0],{cloneBuffers:void 0===arguments[2]||arguments[2]});t=Tr({cloneBuffers:!0},t);let i,n=e.geometry,r=e._roots,a=n.getIndex();return i=t.cloneBuffers?{roots:r.map((e=>e.slice())),index:a.array.slice()}:{roots:r,index:a.array},i}static deserialize(e,t,i={}){if("boolean"==typeof i)return console.warn("MeshBVH.deserialize: The arguments for the function have changed. See documentation for new signature."),Mc.deserialize(arguments[0],arguments[1],{setIndex:void 0===arguments[2]||arguments[2]});i=Tr({setIndex:!0},i);let{index:n,roots:r}=e,a=new Mc(t,Ii(Tr({},i),{[rH]:!0}));if(a._roots=r,i.setIndex){let i=t.getIndex();if(null===i){let i=new mn(e.index,1,!1);t.setIndex(i)}else i.array!==n&&(i.array.set(n),i.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,[rH]:!1},t)).useSharedArrayBuffer&&"undefined"==typeof SharedArrayBuffer)throw new Error("MeshBVH: SharedArrayBuffer is not available.");this._roots=null,t[rH]||(this._roots=Uhe(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,i,n,r,a=this.geometry,s=a.index.array,o=a.attributes.position,l=0,h=this._roots;for(let u=0,d=h.length;u<d;u++)t=h[u],i=new Uint32Array(t),n=new Uint16Array(t),r=new Float32Array(t),c(0,l),l+=t.byteLength;function c(t,a,l=!1){let h=2*t;if(65535===n[h+15]){let e=i[t+6],a=1/0,l=1/0,c=1/0,u=-1/0,d=-1/0,p=-1/0;for(let t=3*e,i=3*(e+n[h+14]);t<i;t++){let e=s[t],i=o.getX(e),n=o.getY(e),r=o.getZ(e);i<a&&(a=i),i>u&&(u=i),n<l&&(l=n),n>d&&(d=n),r<c&&(c=r),r>p&&(p=r)}return(r[t+0]!==a||r[t+1]!==l||r[t+2]!==c||r[t+3]!==u||r[t+4]!==d||r[t+5]!==p)&&(r[t+0]=a,r[t+1]=l,r[t+2]=c,r[t+3]=u,r[t+4]=d,r[t+5]=p,!0)}{let n=t+8,s=i[t+6],o=n+a,h=s+a,u=l,d=!1,p=!1;e?u||(d=e.has(o),p=e.has(h),u=!d&&!p):(d=!0,p=!0);let f=u||p,m=!1;(u||d)&&(m=c(n,a,u));let g=!1;f&&(g=c(s,a,u));let v=m||g;if(v)for(let e=0;e<3;e++){let i=n+e,a=s+e,o=r[i],l=r[i+3],h=r[a],c=r[a+3];r[t+e]=o<h?o:h,r[t+e+3]=l>c?l:c}return v}}}traverse(e,t=0){let i=this._roots[t],n=new Uint32Array(i),r=new Uint16Array(i);!function t(a,s=0){let o=2*a,l=65535===r[o+15];if(l){let t=n[a+6],h=r[o+14];e(s,l,new Float32Array(i,4*a,6),t,h)}else{let r=a+8,o=n[a+6],h=n[a+7];e(s,l,new Float32Array(i,4*a,6),h)||(t(r,s+1),t(o,s+1))}}(0)}raycast(e,t=pi){let i=this._roots,n=this.geometry,r=[],a=t.isMaterial,s=Array.isArray(t),o=n.groups,l=a?t.side:t;for(let h=0,c=i.length;h<c;h++){let a=s?t[o[h].materialIndex].side:l,c=r.length;if(Hv(i[h]),lA(0,n,a,e,r),qb(),s){let e=o[h].materialIndex;for(let t=c,i=r.length;t<i;t++)r[t].face.materialIndex=e}}return r}raycastFirst(e,t=pi){let i=this._roots,n=this.geometry,r=t.isMaterial,a=Array.isArray(t),s=null,o=n.groups,l=r?t.side:t;for(let h=0,c=i.length;h<c;h++){let r=a?t[o[h].materialIndex].side:l;Hv(i[h]);let c=cA(0,n,r,e);qb(),null!=c&&(null==s||c.distance<s.distance)&&(s=c,a&&(c.face.materialIndex=o[h].materialIndex))}return s}intersectsGeometry(e,t){let i=this.geometry,n=!1;for(let r of this._roots)if(Hv(r),n=$he(0,i,e,t),qb(),n)break;return n}shapecast(e,t,i){let n=this.geometry;if(e instanceof Function){if(t){let e=t;t=(t,i,n,r)=>{let a=3*i;return e(t,a,a+1,a+2,n,r)}}e={boundsTraverseOrder:i,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=Fu.getPrimitive(),{boundsTraverseOrder:a,intersectsBounds:s,intersectsRange:o,intersectsTriangle:l}=e;if(o&&l){let e=o;o=(t,i,a,s,o)=>!!e(t,i,a,s,o)||tH(t,i,n,l,a,s,r)}else o||(o=l?(e,t,i,a)=>tH(e,t,n,l,i,a,r):(e,t,i)=>i);let h=!1,c=0;for(let u of this._roots){if(Hv(u),h=Yhe(0,n,s,o,a,c),qb(),h)break;c+=u.byteLength}return Fu.releasePrimitive(r),h}bvhcast(e,t,i){let{intersectsRanges:n,intersectsTriangles:r}=i,a=this.geometry.index,s=this.geometry.attributes.position,o=e.geometry.index,l=e.geometry.attributes.position;Vv.copy(t).invert();let h=Fu.getPrimitive(),c=Fu.getPrimitive();if(r){let e=function(e,i,n,u,d,p,f,m){for(let g=n,v=n+u;g<v;g++){Il(c,3*g,o,l),c.a.applyMatrix4(t),c.b.applyMatrix4(t),c.c.applyMatrix4(t),c.needsUpdate=!0;for(let t=e,n=e+i;t<n;t++)if(Il(h,3*t,a,s),h.needsUpdate=!0,r(h,c,t,g,d,p,f,m))return!0}return!1};if(n){let t=n;n=function(i,n,r,a,s,o,l,h){return!!t(i,n,r,a,s,o,l,h)||e(i,n,r,a,s,o,l,h)}}else n=e}e.getBoundingBox(sH),sH.applyMatrix4(t);let u=this.shapecast({intersectsBounds:e=>sH.intersectsBox(e),intersectsRange:(t,i,r,a,s,o)=>(iH.copy(o),iH.applyMatrix4(Vv),e.shapecast({intersectsBounds:e=>iH.intersectsBox(e),intersectsRange:(e,r,o,l,h)=>n(t,i,e,r,a,s,l,h)}))});return Fu.releasePrimitive(h),Fu.releasePrimitive(c),u}intersectsBox(e,t){return km.set(e.min,e.max,t),km.needsUpdate=!0,this.shapecast({intersectsBounds:e=>km.intersectsBox(e),intersectsTriangle:e=>km.intersectsTriangle(e)})}intersectsSphere(e){return this.shapecast({intersectsBounds:t=>e.intersectsBox(t),intersectsTriangle:t=>t.intersectsSphere(e)})}closestPointToGeometry(e,t,i={},n={},r=0,a=1/0){e.boundingBox||e.computeBoundingBox(),km.set(e.boundingBox.min,e.boundingBox.max,t),km.needsUpdate=!0;let s=this.geometry,o=s.attributes.position,l=s.index,h=e.attributes.position,c=e.index,u=Fu.getPrimitive(),d=Fu.getPrimitive(),p=hA,f=kot,m=null,g=null;n&&(m=Fot,g=Not);let v=1/0,y=null,x=null;return Vv.copy(t).invert(),Wb.matrix.copy(Vv),this.shapecast({boundsTraverseOrder:e=>km.distanceToBox(e),intersectsBounds:(e,t,i)=>i<v&&i<a&&(t&&(Wb.min.copy(e.min),Wb.max.copy(e.max),Wb.needsUpdate=!0),!0),intersectsRange:(i,n)=>{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:e=>Wb.distanceToBox(e),intersectsBounds:(e,t,i)=>i<v&&i<a,intersectsRange:(e,a)=>{for(let s=3*e,b=3*(e+a);s<b;s+=3){Il(d,s,c,h),d.a.applyMatrix4(t),d.b.applyMatrix4(t),d.c.applyMatrix4(t),d.needsUpdate=!0;for(let e=3*i,t=3*(i+n);e<t;e+=3){Il(u,e,l,o),u.needsUpdate=!0;let t=u.distanceToTriangle(d,p,m);if(t<v&&(f.copy(p),g&&g.copy(m),v=t,y=e/3,x=s/3),t<r)return!0}}}});for(let e=0,a=c?c.count:h.count;e<a;e+=3){Il(d,e,c,h),d.a.applyMatrix4(t),d.b.applyMatrix4(t),d.c.applyMatrix4(t),d.needsUpdate=!0;for(let t=3*i,a=3*(i+n);t<a;t+=3){Il(u,t,l,o),u.needsUpdate=!0;let i=u.distanceToTriangle(d,p,m);if(i<v&&(f.copy(p),g&&g.copy(m),v=i,y=t/3,x=e/3),i<r)return!0}}}}),Fu.releasePrimitive(u),Fu.releasePrimitive(d),v===1/0?null:(i.point?i.point.copy(f):i.point=f.clone(),i.distance=v,i.faceIndex=y,n&&(n.point?n.point.copy(g):n.point=g.clone(),n.point.applyMatrix4(Vv),f.applyMatrix4(Vv),n.distance=f.sub(n.point).length(),n.faceIndex=x),i)}closestPointToPoint(e,t={},i=0,n=1/0){let r=i*i,a=n*n,s=1/0,o=null;if(this.shapecast({boundsTraverseOrder:t=>(jb.copy(e).clamp(t.min,t.max),jb.distanceToSquared(e)),intersectsBounds:(e,t,i)=>i<s&&i<a,intersectsTriangle:(t,i)=>{t.closestPointToPoint(e,jb);let n=e.distanceToSquared(jb);return n<s&&(hA.copy(jb),s=n,o=i),n<r}}),s===1/0)return null;let l=Math.sqrt(s);return t.point?t.point.copy(hA):t.point=hA.clone(),t.distance=l,t.faceIndex=o,t}getBoundingBox(e){return e.makeEmpty(),this._roots.forEach((t=>{Pl(0,new Float32Array(t),Zhe),e.union(Zhe)})),e}},aH=new lo,Khe=new et,Bot=xt.prototype.raycast;function oH(e,t){if(this.geometry.boundsTree){if(void 0===this.material)return;Khe.copy(this.matrixWorld).invert(),aH.copy(e.ray).applyMatrix4(Khe);let i=this.geometry.boundsTree;if(!0===e.firstHitOnly){let n=eH(i.raycastFirst(aH,this.material),this,e);n&&t.push(n)}else{let n=i.raycast(aH,this.material);for(let i=0,r=n.length;i<r;i++){let r=eH(n[i],this,e);r&&t.push(r)}}}else Bot.call(this,e,t)}var Jhe=new et,zv=new lo,lH=new vr,_f=new D,Tf=new D,wf=new D,cH=new D,uH=new D,hH=new D,dA=new D,fA=new D,pA=new D,mA=new xe,gA=new xe,vA=new xe,dH=new D,yA=new D;function Uot(e,t,i,n,r,a,s,o){let l;if(l=t.side===Ji?n.intersectTriangle(s,a,r,!0,o):n.intersectTriangle(r,a,s,t.side!==Sr,o),null===l)return null;yA.copy(o),yA.applyMatrix4(e.matrixWorld);let h=i.ray.origin.distanceTo(yA);return h<i.near||h>i.far?null:{distance:h,point:yA.clone(),object:e}}function xA(e,t,i,n,r,a,s,o,l,h,c,u){_f.fromBufferAttribute(r,h),Tf.fromBufferAttribute(r,c),wf.fromBufferAttribute(r,u);let d=e.morphTargetInfluences;if(a&&d){dA.set(0,0,0),fA.set(0,0,0),pA.set(0,0,0);for(let e=0,t=a.length;e<t;e++){let t=d[e],i=a[e];0!==t&&(cH.fromBufferAttribute(i,h),uH.fromBufferAttribute(i,c),hH.fromBufferAttribute(i,u),s?(dA.addScaledVector(cH,t),fA.addScaledVector(uH,t),pA.addScaledVector(hH,t)):(dA.addScaledVector(cH.sub(_f),t),fA.addScaledVector(uH.sub(Tf),t),pA.addScaledVector(hH.sub(wf),t)))}_f.add(dA),Tf.add(fA),wf.add(pA)}e.isSkinnedMesh&&(e.boneTransform(h,_f),e.boneTransform(c,Tf),e.boneTransform(u,wf));let p=Uot(e,t,i,n,_f,Tf,wf,dH);if(p){o&&(mA.fromBufferAttribute(o,h),gA.fromBufferAttribute(o,c),vA.fromBufferAttribute(o,u),p.uv=Zr.getUV(dH,_f,Tf,wf,mA,gA,vA,new xe)),l&&(mA.fromBufferAttribute(l,h),gA.fromBufferAttribute(l,c),vA.fromBufferAttribute(l,u),p.uv2=Zr.getUV(dH,_f,Tf,wf,mA,gA,vA,new xe));let e={a:h,b:c,c:u,normal:new D,materialIndex:0};Zr.getNormal(_f,Tf,wf,e.normal),p.face=e}return p}xt.prototype.raycast=function(e,t){let i=this.geometry,n=this.material,r=this.matrixWorld;if(void 0===n||(null===i.boundingSphere&&i.computeBoundingSphere(),lH.copy(i.boundingSphere),lH.applyMatrix4(r),!1===e.ray.intersectsSphere(lH))||(Jhe.copy(r).invert(),zv.copy(e.ray).applyMatrix4(Jhe),null!==i.boundingBox&&!1===zv.intersectsBox(i.boundingBox)))return;let a,s=i.index,o=i.attributes.position,l=i.morphAttributes.position,h=i.morphTargetsRelative,c=i.attributes.uv,u=i.attributes.uv2,d=i.groups,p=i.drawRange;if(null!==s)if(Array.isArray(n))for(let f=0,m=d.length;f<m;f++){let i=d[f],r=n[i.materialIndex];for(let n=Math.max(i.start,p.start),d=Math.min(s.count,Math.min(i.start+i.count,p.start+p.count));n<d;n+=3){let d=s.getX(n),p=s.getX(n+1),f=s.getX(n+2);a=xA(this,r,e,zv,o,l,h,c,u,d,p,f),a&&(a.faceIndex=Math.floor(n/3),a.face.materialIndex=i.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 i=s.getX(f),r=s.getX(f+1),d=s.getX(f+2);a=xA(this,n,e,zv,o,l,h,c,u,i,r,d),a&&(a.faceIndex=Math.floor(f/3),t.push(a))}else if(void 0!==o)if(Array.isArray(n))for(let f=0,m=d.length;f<m;f++){let i=d[f],r=n[i.materialIndex];for(let n=Math.max(i.start,p.start),s=Math.min(o.count,Math.min(i.start+i.count,p.start+p.count));n<s;n+=3)a=xA(this,r,e,zv,o,l,h,c,u,n,n+1,n+2),a&&(a.faceIndex=Math.floor(n/3),a.face.materialIndex=i.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=xA(this,n,e,zv,o,l,h,c,u,f,f+1,f+2),a&&(a.faceIndex=Math.floor(f/3),t.push(a))},xt.prototype.raycast=oH;var bA=new vr,EA=new D;function Qhe(e,t,i,n,r,a){let s=n.ray.distanceSqToPoint(e);if(s<i){let i=new D;n.ray.closestPointToPoint(e,i);let o=n.ray.origin.distanceTo(i);if(o<n.near||o>n.far)return;r.push({distance:o,distanceToRay:Math.sqrt(s),point:i,index:t,face:null,object:a})}}ii.prototype.raycast=function(e,t){let i=this.geometry,n=this.matrixWorld,r=e.params.Points.threshold,a=i.drawRange;if(null===i.boundingSphere&&i.computeBoundingSphere(),bA.copy(i.boundingSphere),bA.applyMatrix4(n),bA.radius+=r,!1===e.ray.intersectsSphere(bA))return;let s=r*r,o=i.index,l=i.attributes.position,h=t.length;if(null!==o)for(let c=Math.max(0,a.start),u=Math.min(o.count,a.start+a.count);c<u;c++){let i=o.getX(c);if(EA.fromBufferAttribute(l,i).applyMatrix4(n),Qhe(EA,i,s,e,t,this),t.length-h>=1)return}else for(let c=Math.max(0,a.start),u=Math.min(l.count,a.start+a.count);c<u;c++)if(EA.fromBufferAttribute(l,c).applyMatrix4(n),Qhe(EA,c,s,e,t,this),t.length-h>=1)return};var fH=class{constructor(){this.id=0,this.object=null,this.z=0,this.renderOrder=0}},Xb=class{constructor(){this.id=0,this.v1=new Sf,this.v2=new Sf,this.v3=new Sf,this.normalModel=new D,this.vertexNormalsModel=[new D,new D,new D],this.vertexNormalsLength=0,this.color=new ct,this.material=null,this.uvs=[new xe,new xe,new xe],this.z=0,this.renderOrder=0}},Sf=class{constructor(){this.position=new D,this.positionWorld=new D,this.positionScreen=new gr,this.visible=!0}copy(e){this.positionWorld.copy(e.positionWorld),this.positionScreen.copy(e.positionScreen)}},Yb=class{constructor(){this.id=0,this.v1=new Sf,this.v2=new Sf,this.vertexColors=[new ct,new ct],this.material=null,this.z=0,this.renderOrder=0}},$b=class{constructor(){this.id=0,this.object=null,this.x=0,this.y=0,this.z=0,this.rotation=0,this.scale=new xe,this.material=null,this.renderOrder=0}},_A=class{constructor(){let e,t,i,n,r,a,s,o,l,h,c,u=0,d=0,p=0,f=0,m=0,g={objects:[],lights:[],elements:[]},v=new D,y=new gr,x=new Nt(new D(-1,-1,-1),new D(1,1,1)),b=new Nt,_=new Array(3),w=new et,S=new et,M=new et,E=new ma,T=[],A=[],C=[],P=[],R=[],L=new function(){let e=[],t=[],a=[],l=null,h=new Ln;function u(e){let t=e.position,i=e.positionWorld,n=e.positionScreen;i.copy(t).applyMatrix4(c),n.copy(i).applyMatrix4(S);let r=1/n.w;n.x*=r,n.y*=r,n.z*=r,e.visible=n.x>=-1&&n.x<=1&&n.y>=-1&&n.y<=1&&n.z>=-1&&n.z<=1}function p(e,t,i){return!0===e.visible||!0===t.visible||!0===i.visible||(_[0]=e.positionScreen,_[1]=t.positionScreen,_[2]=i.positionScreen,x.intersectsBox(b.setFromPoints(_)))}function m(e,t,i){return(i.positionScreen.x-e.positionScreen.x)*(t.positionScreen.y-e.positionScreen.y)-(i.positionScreen.y-e.positionScreen.y)*(t.positionScreen.x-e.positionScreen.x)<0}return{setObject:function(i){l=i,h.getNormalMatrix(l.matrixWorld),e.length=0,t.length=0,a.length=0},projectVertex:u,checkTriangleVisibility:p,checkBackfaceCulling:m,pushVertex:function(e,t,r){i=function(){if(n===d){let e=new Sf;return A.push(e),d++,n++,e}return A[n++]}(),i.position.set(e,t,r),u(i)},pushNormal:function(t,i,n){e.push(t,i,n)},pushColor:function(e,i,n){t.push(e,i,n)},pushUv:function(e,t){a.push(e,t)},pushLine:function(e,i){let n=A[e],r=A[i];n.positionScreen.copy(n.position).applyMatrix4(M),r.positionScreen.copy(r.position).applyMatrix4(M),!0===function(e,t){let i=0,n=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?i=Math.max(i,r/(r-a)):a<0&&(n=Math.min(n,r/(r-a))),s<0?i=Math.max(i,s/(s-o)):o<0&&(n=Math.min(n,s/(s-o))),!(n<i)&&(e.lerp(t,i),t.lerp(e,1-n),!0))}(n.positionScreen,r.positionScreen)&&(n.positionScreen.multiplyScalar(1/n.positionScreen.w),r.positionScreen.multiplyScalar(1/r.positionScreen.w),s=function(){if(o===f){let e=new Yb;return P.push(e),f++,o++,e}return P[o++]}(),s.id=l.id,s.v1.copy(n),s.v2.copy(r),s.z=Math.max(n.positionScreen.z,r.positionScreen.z),s.renderOrder=l.renderOrder,s.material=l.material,l.material.vertexColors&&(s.vertexColors[0].fromArray(t,3*e),s.vertexColors[1].fromArray(t,3*i)),g.elements.push(s))},pushTriangle:function(i,n,s,o){let c=A[i],u=A[n],d=A[s];if(!1!==p(c,u,d)&&(o.side===Sr||!0===m(c,u,d))){r=N(),r.id=l.id,r.v1.copy(c),r.v2.copy(u),r.v3.copy(d),r.z=(c.positionScreen.z+u.positionScreen.z+d.positionScreen.z)/3,r.renderOrder=l.renderOrder,v.subVectors(d.position,u.position),y.subVectors(c.position,u.position),v.cross(y),r.normalModel.copy(v),r.normalModel.applyMatrix3(h).normalize();for(let t=0;t<3;t++){let i=r.vertexNormalsModel[t];i.fromArray(e,3*arguments[t]),i.applyMatrix3(h).normalize(),r.uvs[t].fromArray(a,2*arguments[t])}r.vertexNormalsLength=3,r.material=o,o.vertexColors&&r.color.fromArray(t,3*i),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 i=0,n=t.length;i<n;i++)I(t[i])}function O(i){e=function(){if(t===u){let e=new fH;return T.push(e),u++,t++,e}return T[t++]}(),e.id=i.id,e.object=i,v.setFromMatrixPosition(i.matrixWorld),v.applyMatrix4(S),e.z=v.z,e.renderOrder=i.renderOrder,g.objects.push(e)}function k(e,t,i){let n=1/e.w;e.z*=n,e.z>=-1&&e.z<=1&&(l=function(){if(h===m){let e=new $b;return R.push(e),m++,h++,e}return R[h++]}(),l.id=t.id,l.x=e.x*n,l.y=e.y*n,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+i.projectionMatrix.elements[0])/(e.w+i.projectionMatrix.elements[12])),l.scale.y=t.scale.y*Math.abs(l.y-(e.y+i.projectionMatrix.elements[5])/(e.w+i.projectionMatrix.elements[13])),l.material=t.material,g.elements.push(l))}function N(){if(a===p){let e=new Xb;return C.push(e),p++,a++,e}return C[a++]}function U(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,i,r,s){a=0,o=0,h=0,g.elements.length=0,!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),null===i.parent&&!0===i.matrixWorldAutoUpdate&&i.updateMatrixWorld(),w.copy(i.matrixWorldInverse),S.multiplyMatrices(i.projectionMatrix,w),E.setFromProjectionMatrix(S),t=0,g.objects.length=0,g.lights.length=0,I(e),!0===r&&g.objects.sort(U);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),c=e.matrixWorld,n=0,e.isMesh){let t=e.material,i=Array.isArray(t),n=r.attributes,a=r.groups;if(void 0===n.position)continue;let s=n.position.array;for(let o=0,l=s.length;o<l;o+=3){let t=s[o],i=s[o+1],n=s[o+2],a=r.morphAttributes.position;if(void 0!==a){let l=r.morphTargetsRelative,h=e.morphTargetInfluences;for(let e=0,r=a.length;e<r;e++){let r=h[e];if(0===r)continue;let c=a[e];l?(t+=c.getX(o/3)*r,i+=c.getY(o/3)*r,n+=c.getZ(o/3)*r):(t+=(c.getX(o/3)-s[o])*r,i+=(c.getY(o/3)-s[o+1])*r,n+=(c.getZ(o/3)-s[o+2])*r)}}L.pushVertex(t,i,n)}if(void 0!==n.normal){let e=n.normal.array;for(let t=0,i=e.length;t<i;t+=3)L.pushNormal(e[t],e[t+1],e[t+2])}if(void 0!==n.color){let e=n.color.array;for(let t=0,i=e.length;t<i;t+=3)L.pushColor(e[t],e[t+1],e[t+2])}if(void 0!==n.uv){let e=n.uv.array;for(let t=0,i=e.length;t<i;t+=2)L.pushUv(e[t],e[t+1])}if(null!==r.index){let n=r.index.array;if(a.length>0)for(let r=0;r<a.length;r++){let s=a[r];if(t=!0===i?e.material[s.materialIndex]:e.material,void 0!==t)for(let e=s.start,i=s.start+s.count;e<i;e+=3)L.pushTriangle(n[e],n[e+1],n[e+2],t)}else for(let e=0,i=n.length;e<i;e+=3)L.pushTriangle(n[e],n[e+1],n[e+2],t)}else if(a.length>0)for(let r=0;r<a.length;r++){let n=a[r];if(t=!0===i?e.material[n.materialIndex]:e.material,void 0!==t)for(let e=n.start,i=n.start+n.count;e<i;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,c);let t=r.attributes;if(void 0!==t.position){let i=t.position.array;for(let e=0,t=i.length;e<t;e+=3)L.pushVertex(i[e],i[e+1],i[e+2]);if(void 0!==t.color){let e=t.color.array;for(let t=0,i=e.length;t<i;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,i=e.length;t<i;t+=2)L.pushLine(e[t],e[t+1])}else{let t=e.isLineSegments?2:1;for(let e=0,n=i.length/3-1;e<n;e+=t)L.pushLine(e,e+1)}}}else if(e.isPoints){M.multiplyMatrices(S,c);let t=r.attributes;if(void 0!==t.position){let n=t.position.array;for(let t=0,r=n.length;t<r;t+=3)y.set(n[t],n[t+1],n[t+2],1),y.applyMatrix4(M),k(y,e,i)}}else e.isSprite&&(e.modelViewMatrix.multiplyMatrices(i.matrixWorldInverse,e.matrixWorld),y.set(c.elements[12],c.elements[13],c.elements[14],1),y.applyMatrix4(S),k(y,e,i))}return!0===s&&g.elements.sort(U),g}}},ede=class extends on{constructor(e){super(),this.isSVGObject=!0,this.node=e}},tde=class{constructor(){let e,t,i,n,r,a,s,o,l,h,c,u,d,p,f,m=0,g=null,v=1,y=this,x=new Mi,b=new Mi,_=new ct,w=new ct,S=new ct,M=new ct,E=new ct,T=new D,A=new D,C=new D,P=new Ln,R=new et,L=new et,I=[],O=new _A,k=document.createElementNS("http://www.w3.org/2000/svg","svg");function N(){for(m=0;k.childNodes.length>0;)k.removeChild(k.childNodes[0])}function U(e){return null!==g?e.toFixed(g):e}function F(e,t,i){let n=t.scale.x*a,r=t.scale.y*s;i.isPointsMaterial&&(n*=i.size,r*=i.size);let o="M"+U(e.x-.5*n)+","+U(e.y-.5*r)+"h"+U(n)+"v"+U(r)+"h"+U(-n)+"z",l="";(i.isSpriteMaterial||i.isPointsMaterial)&&(l="fill:"+i.color.getStyle()+";fill-opacity:"+i.opacity),V(l,o)}function B(e,t,i){let n="M"+U(e.positionScreen.x)+","+U(e.positionScreen.y)+"L"+U(t.positionScreen.x)+","+U(t.positionScreen.y);if(i.isLineBasicMaterial){let e="fill:none;stroke:"+i.color.getStyle()+";stroke-opacity:"+i.opacity+";stroke-width:"+i.linewidth+";stroke-linecap:"+i.linecap;i.isLineDashedMaterial&&(e=e+";stroke-dasharray:"+i.dashSize+","+i.gapSize),V(e,n)}}function z(e,t,n,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(n.positionScreen.x)+","+U(n.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(n.positionWorld).divideScalar(3),function(e,t,i,n){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=i.dot(e);if(t<=0)continue;t*=a.intensity,n.r+=s.r*t,n.g+=s.g*t,n.b+=s.b*t}else if(a.isPointLight){let e=T.setFromMatrixPosition(a.matrixWorld),r=i.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,n.r+=s.r*r,n.g+=s.g*r,n.b+=s.b*r}}}(i,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,i){let n=t.x-e.x,r=t.y-e.y,a=n*n+r*r;if(0===a)return;let s=i/Math.sqrt(a);n*=s,r*=s,t.x+=n,t.y+=r,e.x-=n,e.y-=r}function V(e,t){d===e?u+=t:(j(),d=e,u=t)}function j(){var e;u&&(e=m++,null==I[e]&&(I[e]=document.createElementNS("http://www.w3.org/2000/svg","path"),0==v&&I[e].setAttribute("shape-rendering","crispEdges")),c=I[e],c.setAttribute("d",u),c.setAttribute("style",d),k.appendChild(c)),u="",d=""}this.domElement=k,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){n=e,r=t,a=n/2,s=r/2,k.setAttribute("viewBox",-a+" "+-s+" "+n+" "+r),k.setAttribute("width",n),k.setAttribute("height",r),x.min.set(-a,-s),x.max.set(a,s)},this.getSize=function(){return{width:n,height:r}},this.setPrecision=function(e){g=e},this.clear=function(){if(N(),"number"==typeof p){let e=Hot(p);k.style.backgroundColor=`rgba(${e.r}, ${e.g}, ${e.b}, ${f})`}else k.style.backgroundColor=p.getStyle()},this.render=function(n,r){if(!(r instanceof Xh))return void console.error("THREE.SVGRenderer.render: camera is not an instance of Camera.");let c=n.background;c&&c.isColor?(N(),k.style.backgroundColor=c.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(n,r,this.sortObjects,this.sortElements),t=e.elements,i=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,i=e.length;t<i;t++){let i=e[t],n=i.color;i.isAmbientLight?(S.r+=n.r,S.g+=n.g,S.b+=n.b):i.isDirectionalLight?(M.r+=n.r,M.g+=n.g,M.b+=n.b):i.isPointLight&&(E.r+=n.r,E.g+=n.g,E.b+=n.b)}}(i),u="",d="";for(let e=0,i=t.length;e<i;e++){let i=t[e],n=i.material;if(void 0!==n&&0!==n.opacity)if(b.makeEmpty(),i instanceof $b)o=i,o.x*=a,o.y*=-s,F(o,i,n);else if(i instanceof Yb)o=i.v1,l=i.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,n);else if(i instanceof Xb){if(o=i.v1,l=i.v2,h=i.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,i,n)}}j(),n.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,i=-T.y*s,n=e.node;n.setAttribute("transform",`translate(${t}, ${i}) rotate(${e.rotation.z})`),k.appendChild(n)}}))}}};function Hot(e){let t={};return t.r=(e>>16&255)/255,t.g=(e>>8&255)/255,t.b=(255&e)/255,t}var nde="\n #if defined(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",rde="\n #if defined(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",ide="\n #if defined(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",ade="\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",ode="\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=nde,$n.outline_bc_fragment=rde,$n.outline_bc_pars_fragment=ide,$n.outline_bc_pars_vertex=sde,$n.gemini_standard_vertex=ade,$n.gemini_standard_fragment=ode;var TA=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"})}},lde={enableSpinner:!0,containerId:"myCanvas",units:"meters"},zot=Xi(ude(),1),se=zot;se.setLevel("warn");var hde=e=>{try{se.setLevel(e)}catch(e){se.setLevel("error"),se.error(e)}},pH=class{static isTouchScreenDevice(){return"ontouchstart"in window}static printDeviceInfo(){let e=navigator.userAgent,t=/(?:Android)/.test(e),i=/(?:Firefox)/.test(e),n=/(?:Chrome|CriOS)/.test(e),r=/(?:iPad|PlayBook)/.test(e)||t&&!/(?:Mobile)/.test(e)||i&&/(?:Tablet)/.test(e),a=/(?:iPhone)/.test(e)&&!r,s=!a&&!t,o=pH.isTouchScreenDevice();t&&se.debug("[DI] is android"),i&&se.debug("[DI] is fireFox"),n&&se.debug("[DI] is chrome"),r&&se.debug("[DI] is tablet"),a&&se.debug("[DI] is iPhone"),s&&se.debug("[DI] is PC"),o&&se.debug("[DI] is touch device")}static creatReactNativeCanvas(e){let t=e.drawingBufferWidth||e.width||0,i=e.drawingBufferHeight||e.height||0;return{style:{},width:t,height:i,clientWidth:Math.ceil(t/(window.devicePixelRatio||1)),clientHeight:Math.ceil(i/(window.devicePixelRatio||1)),addEventListener:()=>{},removeEventListener:()=>{}}}},Fn=pH;Fn.isMobile=/mobile/i.test(navigator.userAgent),Fn.isBrowser="undefined"!=typeof document,Fn.isNode="undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process);var SA=class{static isFullScreen(){return!(!document.fullscreenElement&&!document.mozFullScreenElement)}static fullScreen(e=document.documentElement){(e.requestFullscreen||e.mozRequestFullScreen||e.webkitRequestFullscreen||e.msRequestFullscreen).call(e)}static exitFullscreen(){(document.exitFullscreen||document.mozCancelFullscreen||document.webkitExitFullscreen||document.msExitFullscreen).call(document)}static joinStrings(...e){return e.join("")}static numberToString(e){let t=2;return Math.abs(e)<1e-6?t=2:Math.abs(e)<1e-5?t=7:Math.abs(e)<1e-4?t=6:Math.abs(e)<.001?t=5:Math.abs(e)<.01?t=4:Math.abs(e)<.1&&(t=3),e.toFixed(t)}static hexToBase64(e){return btoa((e.match(/\w{2}/g)||[]).map((function(e){return String.fromCharCode(parseInt(e,16))})).join(""))}static vectorToString(e){return e instanceof D?`(${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 xe?e:Array.isArray(e)&&e.length>=2?new xe(e[0],e[1]):void 0:e}static arrayToVector3(e){return e?e instanceof D?e:Array.isArray(e)&&e.length>=2?new D(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 D)return e;if(e instanceof xe)return new D(e.x,e.y,0);if(Array.isArray(e)&&e.length>=2)return new D(e[0],e[1],e[2]||0);let t=e;return null!=t.x&&null!=t.y?new D(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 D&&(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 i=0;i<16;++i){let e=t[i];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 i=new D;e.getCenter(i);let n=(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 D(i.x-n/2,i.y-r/2,i.z-a/2),o=new D(i.x+n/2,i.y+r/2,i.z+a/2);e.set(s,o)}static expandBoxByMinSize(e,t){let i=new D;e.getCenter(i);let n=e.max.x-e.min.x,r=e.max.y-e.min.y,a=e.max.z-e.min.z;n<t&&(e.min.setX(i.x-t/2),e.max.setX(i.x+t/2)),r<t&&(e.min.setY(i.y-t/2),e.max.setY(i.y+t/2)),a<t&&(e.min.setZ(i.z-t/2),e.max.setZ(i.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(),i=new Image;return i.src=t,new Promise((e=>{i.onload=function(){e(i)}}))}static renderingContextToImage(e,t,i="image/png",n=.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(i,n)}return e.canvas.toDataURL(i,n)}static printMemory(e){if(Fn.isBrowser){let t=performance.memory;if(!t)return void se.warn("[CommonUtils] performance.memory is not available in this browser");let i=(t.jsHeapSizeLimit/1048576).toFixed(2),n=(t.totalJSHeapSize/1048576).toFixed(2),r=(t.usedJSHeapSize/1048576).toFixed(2);se.info(`[CommonUtils] ${e}. jsHeapSizeLimit: ${i}M , totalJSHeapSize: ${n}M , usedJSHeapSize: ${r}M `)}}static printGpuInfo(e){if(Fn.isBrowser){let t=e.getExtension("webgl_debug_renderer_info"),i=e.getParameter(t.UNMASKED_RENDERER_WEBGL);se.info("[CommonUtils] gpu:",i)}}static sleep(e){return ft(this,null,(function*(){let t;return new Promise((i=>{t=setTimeout((()=>{i("")}),e)})).then((()=>{clearTimeout(t)}))}))}static twinkle(e,t=500){return ft(this,null,(function*(){let i=this.twinklingObjectIds;i[e.id]||(i[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 i[e.id])}))}static getUpdateProgressFunc(e){return t=>{e&&e(new ProgressEvent("",{loaded:t,total:100}))}}static getUpdateProgressFuncAsync(e){let t=Date.now();return i=>ft(this,null,(function*(){if(e){e(new ProgressEvent("",{loaded:i,total:100}));let n=500,r=Date.now();r-t>n&&(yield SA.sleep(0),t=r)}}))}static getUpdateProgressFuncForLoop(e,t){let i=Math.round(Math.pow(e,.5)),n=Date.now();return r=>ft(this,null,(function*(){if(t&&(r%i==0||r===e-1)){t(new ProgressEvent("",{loaded:r+1,total:e}));let i=500,a=Date.now();(a-n>i||r===e-1)&&(yield SA.sleep(0),n=a)}}))}static getUpdateSubProgressFunc(e,t,i){let n=!1;return r=>{let a=100*r.loaded/r.total;a=a*(t-e)/100+e,a>t&&(n||(se.warn("[Progress] Invalid ProgressEvent:",r),n=!0),a=t),i&&i(new ProgressEvent(r.type,{loaded:a,total:100}))}}},St=SA;St.twinklingObjectIds={};var MA=(e,t,i)=>{let{default:n,active:r}=t;i?(e.remove(n),e.add(r||n)):(r&&e.remove(r),e.add(n))},An=class{static color2rgba(e){let t,i=[0,0,0,1];if(t=/^(\w+)\(([^)]*)\)/.exec(e)){let n,r=t[1],a=t[2];switch(r){case"rgb":case"rgba":(n=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))&&(i=[Math.min(255,parseInt(n[1],10))/255,Math.min(255,parseInt(n[2],10))/255,Math.min(255,parseInt(n[3],10))/255,Number(n[4]||1)]),(n=/^\s*(\d+)%\s*,\s*(\d+)%\s*,\s*(\d+)%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))&&(i=[Math.min(100,parseInt(n[1],10))/100,Math.min(100,parseInt(n[2],10))/100,Math.min(100,parseInt(n[3],10))/100,Number(n[4]||1)]);break;case"hsl":case"hsla":(n=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)%\s*,\s*(\d*\.?\d+)%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))&&(i=[parseFloat(n[1])/360,parseFloat(n[2])/100,parseFloat(n[3])/100,Number(n[4]||1)]);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(t=/^#([A-Fa-f\d]+)$/.exec(e)){let n=t[1],r=n.length;if(3===r)i=[parseInt(n.charAt(0),16)/15,parseInt(n.charAt(1),16)/15,parseInt(n.charAt(2),16)/15,1];else if(6===r){let e=parseInt(n,16);i=[(e>>16&255)/255,(e>>8&255)/255,(255&e)/255,1]}else console.warn("THREE.Color: Invalid hex color "+e)}return i}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 i=t.split(","),n=[];return n.push(this.to1(parseInt(i[0]))),n.push(this.to1(parseInt(i[1]))),n.push(this.to1(parseInt(i[2]))),null!=i[3]&&n.push(parseFloat(i[3])),n}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}},an=class{static getScreenCoordinateByEvent(e,t){let i=new xe,{left:n,top:r}=t.getBoundingClientRect();return i.x=e.clientX-n,i.y=e.clientY-r,i}static getScreenCoordinateByTouchEvent(e,t){let i=new xe,{left:n,top:r}=t.getBoundingClientRect();return i.x=e.touches[0].clientX-n,i.y=e.touches[0].clientY-r,i}static world2Screen(e,t,i){let{clientWidth:n,clientHeight:r}=i,a=e.clone(),s=new xe;return a.project(t),s.x=Math.round((.5+a.x/2)*n),s.y=Math.round((.5-a.y/2)*r),s}static worldBBox2Screen(e,t,i){let n=new Mi,r=e.min,a=e.max,s=(e,r,a)=>{let s=new D(e,r,a),o=this.world2Screen(s,t,i);n.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),n}static screen2World(e,t,i){let n=an.screen2Ndc(e,t,i);return new D(n.x,n.y,1).unproject(t)}static screen2Ndc(e,t,i){let{clientWidth:n,clientHeight:r}=i,a=new xe;return a.x=e.x/n*2-1,a.y=-e.y/r*2+1,a}static world2NormalizedScreen(e,t,i){let n=new D,r=e instanceof xe?0:e.z;n.set(e.x,e.y,r);let a=an.world2Screen(n,t,i);return a.x/=i.clientWidth,a.y/=i.clientHeight,a}},qv=class extends on{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 xe(.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}},Gv=new D,dde=new et,fde=new et,pde=new D,mde=new D,Nu=class{constructor(e={}){let t,i,n,r,a=this,s={objects:new WeakMap},o=void 0!==e.element?e.element:document.createElement("div");function l(e,t,i){if(e.isCSS2DObject){Gv.setFromMatrixPosition(e.matrixWorld),Gv.applyMatrix4(fde);let l=!0===e.visible&&Gv.z>=-1&&Gv.z<=1&&!0===e.layers.test(i.layers);if(e.element.style.display=!0===l?"":"none",!0===l){e.onBeforeRender(a,t,i);let s=e.element;s.style.transform="translate("+-100*e.center.x+"%,"+-100*e.center.y+"%)translate("+(Gv.x*n+n)+"px,"+(-Gv.y*r+r)+"px)",s.parentNode!==o&&o.appendChild(s),e.onAfterRender(a,t,i)}let c={distanceToCameraSquared:h(i,e)};s.objects.set(e,c)}for(let n=0,r=e.children.length;n<r;n++)l(e.children[n],t,i)}function h(e,t){return pde.setFromMatrixPosition(e.matrixWorld),mde.setFromMatrixPosition(t.matrixWorld),pde.distanceToSquared(mde)}o.style.overflow="hidden",this.domElement=o,this.getSize=function(){return{width:t,height:i}},this.render=function(e,t){!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),null===t.parent&&!0===t.matrixWorldAutoUpdate&&t.updateMatrixWorld(),dde.copy(t.matrixWorldInverse),fde.multiplyMatrices(t.projectionMatrix,dde),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})),i=t.length;for(let n=0,r=t.length;n<r;n++)t[n].element.style.zIndex=i-n}(e)},this.setSize=function(e,a){t=e,i=a,n=t/2,r=i/2,o.style.width=e+"px",o.style.height=a+"px"}}},Mf=class{static createCSS2DObject(e){let t=new qv(e);return e.dataset.objectId=t.id.toString(),t}static createDefaultHotpoint(e=12){let t=document.createElement("div"),i=t.style;return i.width=`${e}px`,i.height=`${e}px`,i.opacity="0.8",i.cursor="pointer",i.top=-e/2+"px",i.left=-e/2+"px",i.backgroundColor="#ffffff",i.border="2px solid #00DAB7",i.borderRadius="50%",this.createCSS2DObject(t)}static createHotpoint(e){if(e){let t=document.createElement("div"),i=t.style;return i.top="0px",i.left="0px",t.innerHTML=e,this.createCSS2DObject(t)}return this.createDefaultHotpoint()}static createLabel(e,t=""){let i=document.createElement("div");if(i.innerHTML=e,t)i.classList.add(t);else{let e=i.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(i)}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)}},Wv={unit:"file",decimalPrecision:99,camera:{near:.1,far:3e4},mouse:{sensitivity:3},keyboard:{sensitivity:3}},gde={"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},Bu=(e,t)=>e.toFixed(t===gde["Precision from file"]?2:t),si=!1,VIt=!1,Uu=10,ps=11,ei=12,jv="gemini-viewer-iconfont",zIt="keydown",GIt="keyup",Rf="mousemove",mH="mouseup",gH="mousedown",qIt="Escape",WIt="Enter",jIt="axis-section-plane",XIt="axis-section-plane-control",YIt="section-plane",$It="section-plane-control",ZIt="section-box",vH="plane-section-boxface",vde=-1e3,RA=10,Xv=(e=>(e.ObjectsBoxSection="ObjectsBoxSection",e.PickPlaneSection="PickPlaneSection",e.AxisPlaneSection="AxisPlaneSection",e))(Xv||{}),yde=(e=>(e.Default="Default",e.BoxSelection="BoxSelection",e.PickMarkup="PickMarkup",e))(yde||{}),xde=new D,bde=new D,Ede=new D,Zb=new D,rd=new D,_de=new Zr;function Got(e,t,i,n,r){let a,s,o,l,h,c,u=[],d={},p=Math.pow(10,4),f=0;for(h=0,c=e.length;h<c;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,i[f++]=a,i[f++]=s,i[f++]=o),u[h/3]=d[l];for(h=0,c=t.length;h<c;h++)r[h]=u[t[h]],n[r[h]]=t[h]}function qot(e,t,i,n){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];xde.set(i[e],i[e+1],i[e+2]),bde.set(i[a],i[a+1],i[a+2]),Ede.set(i[s],i[s+1],i[s+2]),Zr.getNormal(xde,bde,Ede,Zb),n.push({normal:Zb.clone()})}}var yH=[new D(1,0,0),new D(0,1,0),new D(0,0,1),new D(1,1,0),new D(0,1,1),new D(1,0,1),new D(1,1,1),new D(0,0,0)];function Wot(e,t){return rd.addVectors(e,t),0===rd.x||0===rd.y||0===rd.z}var AA=class{static buildEdge(e,t,i=10){let n=[],r=[],a=[];Got(e,t,n,r,a);let s=[];qot(t.length,a,n,s);let o,l,h,c,u,d,p,f,m,g,v=[],y=Math.cos(Rn.DEG2RAD*i),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),c=Math.max(o,l),u=h+","+c,void 0===x[u]?x[u]={index1:h,index2:c,face1:e,face2:void 0}:x[u].face2=e}for(u in x)d=x[u],!(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 i=Math.pow(10,4),n=Math.cos(20*Rn.DEG2RAD),r=e.getIndex(),a=r?r.count:t.count,s=[0,0,0],o=new Array(3),l=yH.length,h=[];for(let S=0;S<t.count;S++)h.push({point:new D(1,1,1),inited:!1,barycentricIndex:-1});let c={},u={},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}=_de;if(e.fromBufferAttribute(t,s[0]),a.fromBufferAttribute(t,s[1]),l.fromBufferAttribute(t,s[2]),_de.getNormal(Zb),d[s[0]]?o[0]=d[s[0]]:(o[0]=`${Math.round(e.x*i)},${Math.round(e.y*i)},${Math.round(e.z*i)}`,d[s[0]]=o[0]),d[s[1]]?o[1]=d[s[1]]:(o[1]=`${Math.round(a.x*i)},${Math.round(a.y*i)},${Math.round(a.z*i)}`,d[s[1]]=o[1]),d[s[2]]?o[2]=d[s[2]]:(o[2]=`${Math.round(l.x*i)},${Math.round(l.y*i)},${Math.round(l.z*i)}`,d[s[2]]=o[2]),o[0]===o[1]||o[1]===o[2]||o[2]===o[0]){se.warn(" skip degenerate triangles in geometry !");continue}let h={a:s[0],b:s[1],c:s[2]};u[s[0]]||(u[s[0]]=[]),u[s[0]].push(h),u[s[1]]||(u[s[1]]=[]),u[s[1]].push(h),u[s[2]]||(u[s[2]]=[]),u[s[2]].push(h);for(let t=0;t<3;t++){let e=(t+1)%3,i=o[t],r=o[e],a=s[t],l=s[e];c[a]||(c[a]=new Set),c[a].add(l),c[l]||(c[l]=new Set),c[l].add(a);let h=`${i}_${r}`,u=`${r}_${i}`;if(u in p&&p[u]){if(p[u].outer){se.warn(`edge: ${u} is already outer !`);continue}Zb.dot(p[u].normal)<=n?p[u].outer=!0:p[u].find=!0}else h in p?se.warn(`${h} has existed in geometry !`):p[h]={startIndex:a,endIndex:l,normal:Zb.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 u)m.push(u[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 i of m[t])if(g.has(i.a)||g.has(i.b)||g.has(i.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)?se.warn(`${e} is already in positionIndexSet !`):y.add(e)}));let x=(e,t)=>{let i=!1,n=d[e];if(!n)return console.warn(`${e} is not in positionIndexHash !`),i;let r=d[t];if(!r)return console.warn(`${t} is not in positionIndexHash !`),i;let a=`${n}_${r}`;if(p[a])i=p[a].outer;else{let e=`${r}_${n}`;p[e]&&(i=p[e].outer)}return i},b=(e,t,i)=>{let n=[];return n.push(x(e,t)),n.push(x(t,i)),n.push(x(i,e)),n.filter((e=>!0===e)).length>=2},_=(e,t)=>{if(!c[e])return se.warn(`${e} position isn't used !`),!0;let i=c[e];for(let r of i){let i=x(e,r),n=h[r];if(!n.inited)continue;let a=Wot(t,n.point);if(i&&!a||!i&&a)return!1}let n=u[e];for(let r of n){let i=t,n=h[r.b],a=h[r.c];if(r.b===e?n=h[r.a]:r.c===e&&(a=h[r.a]),b(r.a,r.b,r.c)&&(n.inited&&i.equals(n.point)||a.inited&&i.equals(a.point)))return!1;if(n.inited&&a.inited&&(rd.addVectors(i,n.point),rd.add(a.point),rd.x+rd.y+rd.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,i=0;for(;i>=0;){t=e[i];let n=h[t].inited?h[t].barycentricIndex+1:0;for(;n<l&&!_(t,yH[n]);n++);if(n<l){if(h[t].inited=!0,h[t].barycentricIndex=n,h[t].point.copy(yH[n]),i==e.length-1){w=!0,se.debug(h);break}i++}else h[t].inited=!1,i--}if(!w){se.warn(`no result: ${e} !`);break}}if(w){let t=[];for(let e=0;e<h.length;e++){h[e].inited||se.warn(`${e} is not initialized !`);let i=0;i|=h[e].point.x,i|=h[e].point.y<<1,i|=h[e].point.z<<2,t.push(i)}let i=new bb(t,1,!1);e.setAttribute("barycentric",i)}else se.warn("No suitable barycentric found !");return w}},Ss=class{constructor(){this.map=new Map}addEventListener(e,t){let i=this.map.get(e);i||(i=new Set,this.map.set(e,i)),i.add(t)}dispatchEvent(e,t={}){let i=this.map.get(e);i&&[...i].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 i=this.map.get(e);i&&i.delete(t)}},ga=class{parse(e,t={}){if(t=Object.assign({decodeSpeed:5,encodeSpeed:5,encoderMethod:ga.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 i,n,r=e.geometry,a=DracoEncoderModule(),s=new a.Encoder;if(!0===e.isMesh){i=new a.MeshBuilder,n=new a.Mesh;let e=r.getAttribute("position");i.AddFloatAttributeToMesh(n,a.POSITION,e.count,e.itemSize,e.array);let s=r.getIndex();if(null!==s)i.AddFacesToMesh(n,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;i.AddFacesToMesh(n,e.count,t)}if(!0===t.exportNormals){let e=r.getAttribute("normal");void 0!==e&&i.AddFloatAttributeToMesh(n,a.NORMAL,e.count,e.itemSize,e.array)}if(!0===t.exportUvs){let e=r.getAttribute("uv");void 0!==e&&i.AddFloatAttributeToMesh(n,a.TEX_COORD,e.count,e.itemSize,e.array)}if(!0===t.exportColor){let e=r.getAttribute("color");if(void 0!==e){let t=Tde(e);i.AddFloatAttributeToMesh(n,a.COLOR,e.count,e.itemSize,t)}}}else{if(!0!==e.isPoints)throw new Error("DRACOExporter: Unsupported object type.");{i=new a.PointCloudBuilder,n=new a.PointCloud;let e=r.getAttribute("position");if(i.AddFloatAttribute(n,a.POSITION,e.count,e.itemSize,e.array),!0===t.exportColor){let e=r.getAttribute("color");if(void 0!==e){let t=Tde(e);i.AddFloatAttribute(n,a.COLOR,e.count,e.itemSize,t)}}}}let o,l=new a.DracoInt8Array,h=void 0!==t.encodeSpeed?t.encodeSpeed:5,c=void 0!==t.decodeSpeed?t.decodeSpeed:5;if(s.SetSpeedOptions(h,c),void 0!==t.encoderMethod&&s.SetEncodingMethod(t.encoderMethod),void 0!==t.quantization)for(let d=0;d<5;d++)void 0!==t.quantization[d]&&s.SetAttributeQuantization(d,t.quantization[d]);if(o=!0===e.isMesh?s.EncodeMeshToDracoBuffer(n,l):s.EncodePointCloudToDracoBuffer(n,!0,l),a.destroy(n),0===o)throw new Error("THREE.DRACOExporter: Draco encoding failed.");let u=new Int8Array(new ArrayBuffer(o));for(let d=0;d<o;d++)u[d]=l.GetValue(d);return a.destroy(l),a.destroy(s),a.destroy(i),u}},CA,xH,Yv,PA;function Tde(e){let t=new ct,i=e.count,n=e.itemSize,r=new Float32Array(i*n);for(let a=0,s=i;a<s;a++)t.fromBufferAttribute(e,a).convertLinearToSRGB(),r[a*n]=t.r,r[a*n+1]=t.g,r[a*n+2]=t.b,4===n&&(r[a*n+3]=e.getW(a));return r}function IA(e,t=1/0,i=null){xH||(xH=new ui(2,2,1,1)),Yv||(Yv=new cn({uniforms:{blitTexture:new Am(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 }"})),Yv.uniforms.blitTexture.value=e,Yv.defines.IS_SRGB=e.colorSpace==en,Yv.needsUpdate=!0,PA||((PA=new xt(xH,Yv)).frustrumCulled=!1);let n=new hr,r=new Si;r.add(PA),i||(i=CA=new Ts({antialias:!1})),i.setSize(Math.min(e.image.width,t),Math.min(e.image.height,t)),i.clear(),i.render(r,n);let a=new Gr(i.domElement);return a.minFilter=e.minFilter,a.magFilter=e.magFilter,a.wrapS=e.wrapS,a.wrapT=e.wrapT,a.name=e.name,CA&&(CA.dispose(),CA=null),a}ga.MESH_EDGEBREAKER_ENCODING=1,ga.MESH_SEQUENTIAL_ENCODING=0,ga.POINT_CLOUD=0,ga.TRIANGULAR_MESH=1,ga.INVALID=-1,ga.POSITION=0,ga.NORMAL=1,ga.COLOR=2,ga.TEX_COORD=3,ga.GENERIC=4;var wde={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"]},$v=class{constructor(){this.pluginCallbacks=[],this.register((function(e){return new TH(e)})),this.register((function(e){return new wH(e)})),this.register((function(e){return new RH(e)})),this.register((function(e){return new AH(e)})),this.register((function(e){return new CH(e)})),this.register((function(e){return new PH(e)})),this.register((function(e){return new SH(e)})),this.register((function(e){return new MH(e)})),this.register((function(e){return new IH(e)})),this.register((function(e){return new LH(e)})),this.register((function(e){return new DH(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,i,n){let r=new _H,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,n).catch(i)}parseAsync(e,t){let i=this;return new Promise((function(n,r){i.parse(e,n,r,t)}))}},Br={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},bH="KHR_mesh_quantization",Yo={};Yo[Jr]=Br.NEAREST,Yo[hf]=Br.NEAREST_MIPMAP_NEAREST,Yo[zh]=Br.NEAREST_MIPMAP_LINEAR,Yo[Pr]=Br.LINEAR,Yo[Im]=Br.LINEAR_MIPMAP_NEAREST,Yo[Fa]=Br.LINEAR_MIPMAP_LINEAR,Yo[Li]=Br.CLAMP_TO_EDGE,Yo[Di]=Br.REPEAT,Yo[qh]=Br.MIRRORED_REPEAT;var Sde={scale:"scale",position:"translation",quaternion:"rotation",morphTargetInfluences:"weights"},jot=new ct,Mde=12,Xot=1179937895,Yot=2,Rde=8,$ot=1313821514,Zot=5130562;function Kb(e,t){return e.length===t.length&&e.every((function(e,i){return e===t[i]}))}function Kot(e){return(new TextEncoder).encode(e).buffer}function Jot(e){return Kb(e.elements,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}function Qot(e,t,i){let n={min:new Array(e.itemSize).fill(Number.POSITIVE_INFINITY),max:new Array(e.itemSize).fill(Number.NEGATIVE_INFINITY)};for(let r=t;r<t+i;r++)for(let t=0;t<e.itemSize;t++){let i;e.itemSize>4?i=e.array[r*e.itemSize+t]:(0===t?i=e.getX(r):1===t?i=e.getY(r):2===t?i=e.getZ(r):3===t&&(i=e.getW(r)),!0===e.normalized&&(i=Rn.normalize(i,e.array))),n.min[t]=Math.min(n.min[t],i),n.max[t]=Math.max(n.max[t],i)}return n}function Pde(e){return 4*Math.ceil(e/4)}function EH(e,t=0){let i=Pde(e.byteLength);if(i!==e.byteLength){let n=new Uint8Array(i);if(n.set(new Uint8Array(e)),0!==t)for(let r=e.byteLength;r<i;r++)n[r]=t;return n.buffer}return e}function Ade(){return"undefined"==typeof document&&"undefined"!=typeof OffscreenCanvas?new OffscreenCanvas(1,1):document.createElement("canvas")}function Cde(e,t){if(void 0!==e.toBlob)return new Promise((i=>e.toBlob(i,t)));let i;return"image/jpeg"===t?i=.92:"image/webp"===t&&(i=.8),e.convertToBlob({type:t,quality:i})}var _H=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 ft(this,arguments,(function*(e,t,i={}){this.options=Object.assign({binary:!1,trs:!1,onlyVisible:!0,maxTextureSize:1/0,animations:[],includeCustomExtensions:!1},i),this.options.animations.length>0&&(this.options.trs=!0),this.processInput(e),yield Promise.all(this.pending);let n=this,r=n.buffers,a=n.json;i=n.options;let s=n.extensionsUsed,o=n.extensionsRequired,l=new Blob(r,{type:"application/octet-stream"}),h=Object.keys(s),c=Object.keys(o);if(h.length>0&&(a.extensionsUsed=h),c.length>0&&(a.extensionsRequired=c),a.buffers&&a.buffers.length>0&&(a.buffers[0].byteLength=l.size),!0===i.binary){let e=new FileReader;e.readAsArrayBuffer(l),e.onloadend=function(){let i=EH(e.result),n=new DataView(new ArrayBuffer(Rde));n.setUint32(0,i.byteLength,!0),n.setUint32(4,Zot,!0);let r=EH(Kot(JSON.stringify(a)),32),s=new DataView(new ArrayBuffer(Rde));s.setUint32(0,r.byteLength,!0),s.setUint32(4,$ot,!0);let o=new ArrayBuffer(Mde),l=new DataView(o);l.setUint32(0,Xot,!0),l.setUint32(4,Yot,!0);let h=Mde+s.byteLength+r.byteLength+n.byteLength+i.byteLength;l.setUint32(8,h,!0);let c=new Blob([o,s,r,n,i],{type:"application/octet-stream"}),u=new FileReader;u.readAsArrayBuffer(c),u.onloadend=function(){t(u.result)}}}else if(a.buffers&&a.buffers.length>0){let e=new FileReader;e.readAsDataURL(l),e.onloadend=function(){let i=e.result;a.buffers[0].uri=i,t(a)}}else t(a)}))}serializeUserData(e,t){if(0===Object.keys(e.userData).length)return;let i=this.options,n=this.extensionsUsed;try{let r=JSON.parse(JSON.stringify(e.userData));if(i.includeCustomExtensions&&r.gltfExtensions){void 0===t.extensions&&(t.extensions={});for(let e in r.gltfExtensions)t.extensions[e]=r.gltfExtensions[e],n[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 D;for(let i=0,n=e.count;i<n;i++)if(Math.abs(t.fromBufferAttribute(e,i).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 i=e.clone(),n=new D;for(let r=0,a=i.count;r<a;r++)n.fromBufferAttribute(i,r),0===n.x&&0===n.y&&0===n.z?n.setX(1):n.normalize(),i.setXYZ(r,n.x,n.y,n.z);return t.attributesNormalized.set(e,i),i}applyTextureTransform(e,t){let i=!1,n={};(0!==t.offset.x||0!==t.offset.y)&&(n.offset=t.offset.toArray(),i=!0),0!==t.rotation&&(n.rotation=t.rotation,i=!0),(1!==t.repeat.x||1!==t.repeat.y)&&(n.scale=t.repeat.toArray(),i=!0),i&&(e.extensions=e.extensions||{},e.extensions.KHR_texture_transform=n,this.extensionsUsed.KHR_texture_transform=!0)}buildMetalRoughTexture(e,t){if(e===t)return e;function i(e){return e.colorSpace===en?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 Su&&(e=IA(e)),t instanceof Su&&(t=IA(t));let n=e?e.image:null,r=t?t.image:null,a=Math.max(n?n.width:0,r?r.width:0),s=Math.max(n?n.height:0,r?r.height:0),o=Ade();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(n){l.drawImage(n,0,0,a,s);let t=i(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=i(t),n=l.getImageData(0,0,a,s).data;for(let t=1;t<n.length;t+=4)h.data[t]=256*e(n[t]/256)}l.putImageData(h,0,0);let c=(e||t).clone();return c.source=new xc(o),c.colorSpace=Eu,c.channel=(e||t).channel,e&&t&&e.channel!==t.channel&&console.warn("THREE.GLTFExporter: UV channels for metalnessMap and roughnessMap textures must match."),c}processBuffer(e){let t=this.json,i=this.buffers;return t.buffers||(t.buffers=[{byteLength:0}]),i.push(e),0}processBufferView(e,t,i,n,r){let a,s=this.json;switch(s.bufferViews||(s.bufferViews=[]),t){case Br.BYTE:case Br.UNSIGNED_BYTE:a=1;break;case Br.SHORT:case Br.UNSIGNED_SHORT:a=2;break;default:a=4}let o=Pde(n*e.itemSize*a),l=new DataView(new ArrayBuffer(o)),h=0;for(let u=i;u<i+n;u++)for(let i=0;i<e.itemSize;i++){let n;e.itemSize>4?n=e.array[u*e.itemSize+i]:(0===i?n=e.getX(u):1===i?n=e.getY(u):2===i?n=e.getZ(u):3===i&&(n=e.getW(u)),!0===e.normalized&&(n=Rn.normalize(n,e.array))),t===Br.FLOAT?l.setFloat32(h,n,!0):t===Br.INT?l.setInt32(h,n,!0):t===Br.UNSIGNED_INT?l.setUint32(h,n,!0):t===Br.SHORT?l.setInt16(h,n,!0):t===Br.UNSIGNED_SHORT?l.setUint16(h,n,!0):t===Br.BYTE?l.setInt8(h,n):t===Br.UNSIGNED_BYTE&&l.setUint8(h,n),h+=a}let c={buffer:this.processBuffer(l.buffer),byteOffset:this.byteOffset,byteLength:o};return void 0!==r&&(c.target=r),r===Br.ARRAY_BUFFER&&(c.byteStride=e.itemSize*a),this.byteOffset+=o,s.bufferViews.push(c),{id:s.bufferViews.length-1,byteLength:0}}processBufferViewImage(e){let t=this,i=t.json;return i.bufferViews||(i.bufferViews=[]),new Promise((function(n){let r=new FileReader;r.readAsArrayBuffer(e),r.onloadend=function(){let e=EH(r.result),a={buffer:t.processBuffer(e),byteOffset:t.byteOffset,byteLength:e.byteLength};t.byteOffset+=e.byteLength,n(i.bufferViews.push(a)-1)}}))}processAccessor(e,t,i,n){let r,a=this.json;if(e.array.constructor===Float32Array)r=Br.FLOAT;else if(e.array.constructor===Int32Array)r=Br.INT;else if(e.array.constructor===Uint32Array)r=Br.UNSIGNED_INT;else if(e.array.constructor===Int16Array)r=Br.SHORT;else if(e.array.constructor===Uint16Array)r=Br.UNSIGNED_SHORT;else if(e.array.constructor===Int8Array)r=Br.BYTE;else{if(e.array.constructor!==Uint8Array)throw new Error("THREE.GLTFExporter: Unsupported bufferAttribute component type: "+e.array.constructor.name);r=Br.UNSIGNED_BYTE}if(void 0===i&&(i=0),void 0===n&&(n=e.count),0===n)return null;let s,o=Qot(e,i,n);void 0!==t&&(s=e===t.index?Br.ELEMENT_ARRAY_BUFFER:Br.ARRAY_BUFFER);let l=this.processBufferView(e,r,i,n,s),h={bufferView:l.id,byteOffset:l.byteOffset,componentType:r,count:n,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,i,n="image/png"){if(null!==e){let r=this,a=r.cache,s=r.json,o=r.options,l=r.pending;a.images.has(e)||a.images.set(e,{});let h=a.images.get(e),c=n+":flipY/"+i.toString();if(void 0!==h[c])return h[c];s.images||(s.images=[]);let u={mimeType:n},d=Ade();d.width=Math.min(e.width,o.maxTextureSize),d.height=Math.min(e.height,o.maxTextureSize);let p=d.getContext("2d");if(!0===i&&(p.translate(0,d.height),p.scale(1,-1)),void 0!==e.data){t!==Js&&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 i=new Uint8ClampedArray(e.height*e.width*4);for(let t=0;t<i.length;t+=4)i[t+0]=e.data[t+0],i[t+1]=e.data[t+1],i[t+2]=e.data[t+2],i[t+3]=e.data[t+3];p.putImageData(new ImageData(i,e.width,e.height),0,0)}else p.drawImage(e,0,0,d.width,d.height);!0===o.binary?l.push(Cde(d,n).then((e=>r.processBufferViewImage(e))).then((e=>{u.bufferView=e}))):void 0!==d.toDataURL?u.uri=d.toDataURL(n):l.push(Cde(d,n).then((e=>(new FileReader).readAsDataURL(e))).then((e=>{u.uri=e})));let f=s.images.push(u)-1;return h[c]=f,f}throw new Error("THREE.GLTFExporter: No valid image data found. Unable to process texture.")}processSampler(e){let t=this.json;t.samplers||(t.samplers=[]);let i={magFilter:Yo[e.magFilter],minFilter:Yo[e.minFilter],wrapS:Yo[e.wrapS],wrapT:Yo[e.wrapT]};return t.samplers.push(i)-1}processTexture(e){let t=this.options,i=this.cache,n=this.json;if(i.textures.has(e))return i.textures.get(e);n.textures||(n.textures=[]),e instanceof Su&&(e=IA(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=n.textures.push(a)-1;return i.textures.set(e,s),s}processMaterial(e){let t=this.cache,i=this.json;if(t.materials.has(e))return t.materials.get(e);if(e.isShaderMaterial)return console.warn("GLTFExporter: THREE.ShaderMaterial not supported."),null;i.materials||(i.materials=[]);let n={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(Kb(r,[1,1,1,1])||(n.pbrMetallicRoughness.baseColorFactor=r),e.isMeshStandardMaterial?(n.pbrMetallicRoughness.metallicFactor=e.metalness,n.pbrMetallicRoughness.roughnessFactor=e.roughness):(n.pbrMetallicRoughness.metallicFactor=.5,n.pbrMetallicRoughness.roughnessFactor=.5),e.metalnessMap||e.roughnessMap){let t=this.buildMetalRoughTexture(e.metalnessMap,e.roughnessMap),i={index:this.processTexture(t),channel:t.channel};this.applyTextureTransform(i,t),n.pbrMetallicRoughness.metallicRoughnessTexture=i}if(e.map){let t={index:this.processTexture(e.map),texCoord:e.map.channel};this.applyTextureTransform(t,e.map),n.pbrMetallicRoughness.baseColorTexture=t}if(e.emissive){let t=e.emissive;if(Math.max(t.r,t.g,t.b)>0&&(n.emissiveFactor=e.emissive.toArray()),e.emissiveMap){let t={index:this.processTexture(e.emissiveMap),texCoord:e.emissiveMap.channel};this.applyTextureTransform(t,e.emissiveMap),n.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),n.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),n.occlusionTexture=t}e.transparent?n.alphaMode="BLEND":e.alphaTest>0&&(n.alphaMode="MASK",n.alphaCutoff=e.alphaTest),e.side===Sr&&(n.doubleSided=!0),""!==e.name&&(n.name=e.name),this.serializeUserData(e,n),this._invokeAll((function(t){t.writeMaterial&&t.writeMaterial(e,n)}));let a=i.materials.push(n)-1;return t.materials.set(e,a),a}processMesh(e){let t=this.cache,i=this.json,n=[e.geometry.uuid];if(Array.isArray(e.material))for(let y=0,x=e.material.length;y<x;y++)n.push(e.material[y].uuid);else n.push(e.material.uuid);let r=n.join(":");if(t.meshes.has(r))return t.meshes.get(r);let a,s=e.geometry;a=e.isLineSegments?Br.LINES:e.isLineLoop?Br.LINE_LOOP:e.isLine?Br.LINE_STRIP:e.isPoints?Br.POINTS:e.material.wireframe?Br.LINES:Br.TRIANGLES;let o={},l={},h=[],c=[],u={uv:"TEXCOORD_0",uv1:"TEXCOORD_1",color:"COLOR_0",skinWeight:"WEIGHTS_0",skinIndex:"JOINTS_0"},d=s.getAttribute("normal");void 0!==d&&!this.isNormalizedNormalAttribute(d)&&(console.warn("THREE.GLTFExporter: Creating normalized normal attribute from the non-normalized one."),s.setAttribute("normal",this.createNormalizedNormalAttribute(d)));let p=null;for(let y in s.attributes){if("morph"===y.slice(0,5))continue;let e=s.attributes[y];if(y=u[y]||y.toUpperCase(),/^(POSITION|NORMAL|TANGENT|TEXCOORD_\d+|COLOR_\d+|JOINTS_\d+|WEIGHTS_\d+)$/.test(y)||(y="_"+y),t.attributes.has(this.getUID(e))){l[y]=t.attributes.get(this.getUID(e));continue}p=null;let i=e.array;"JOINTS_0"===y&&!(i instanceof Uint16Array)&&!(i instanceof Uint8Array)&&(console.warn('GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.'),p=new mn(new Uint16Array(i),e.itemSize,e.normalized));let n=this.processAccessor(p||e,s);null!==n&&(y.startsWith("_")||this.detectMeshQuantization(y,e),l[y]=n,t.attributes.set(this.getUID(e),n))}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 i=[],n=[],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 i=s.morphAttributes[e][a],n=e.toUpperCase(),r=s.attributes[e];if(t.attributes.has(this.getUID(i,!0))){o[n]=t.attributes.get(this.getUID(i,!0));continue}let h=i.clone();if(!s.morphTargetsRelative)for(let e=0,t=i.count;e<t;e++)for(let n=0;n<i.itemSize;n++)0===n&&h.setX(e,i.getX(e)-r.getX(e)),1===n&&h.setY(e,i.getY(e)-r.getY(e)),2===n&&h.setZ(e,i.getZ(e)-r.getZ(e)),3===n&&h.setW(e,i.getW(e)-r.getW(e));o[n]=this.processAccessor(h,s),t.attributes.set(this.getUID(r,!0),o[n])}c.push(o),i.push(e.morphTargetInfluences[a]),void 0!==e.morphTargetDictionary&&n.push(r[a])}o.weights=i,n.length>0&&(o.extras={},o.extras.targetNames=n)}let f=Array.isArray(e.material);if(f&&0===s.groups.length)return null;let m=f?e.material:[e.material],g=f?s.groups:[{materialIndex:0,start:void 0,count:void 0}];for(let y=0,x=g.length;y<x;y++){let e={mode:a,attributes:l};if(this.serializeUserData(s,e),c.length>0&&(e.targets=c),null!==s.index){let i=this.getUID(s.index);(void 0!==g[y].start||void 0!==g[y].count)&&(i+=":"+g[y].start+":"+g[y].count),t.attributes.has(i)?e.indices=t.attributes.get(i):(e.indices=this.processAccessor(s.index,s,g[y].start,g[y].count),t.attributes.set(i,e.indices)),null===e.indices&&delete e.indices}let i=this.processMaterial(m[g[y].materialIndex]);null!==i&&(e.material=i),h.push(e)}o.primitives=h,i.meshes||(i.meshes=[]),this._invokeAll((function(t){t.writeMesh&&t.writeMesh(e,o)}));let v=i.meshes.push(o)-1;return t.meshes.set(r,v),v}detectMeshQuantization(e,t){if(this.extensionsUsed[bH])return;let i;switch(t.array.constructor){case Int8Array:i="byte";break;case Uint8Array:i="unsigned byte";break;case Int16Array:i="short";break;case Uint16Array:i="unsigned short";break;default:return}t.normalized&&(i+=" normalized");let n=e.split("_",1)[0];wde[n]&&wde[n].includes(i)&&(this.extensionsUsed[bH]=!0,this.extensionsRequired[bH]=!0)}processCamera(e){let t=this.json;t.cameras||(t.cameras=[]);let i=e.isOrthographicCamera,n={type:i?"orthographic":"perspective"};return i?n.orthographic={xmag:2*e.right,ymag:2*e.top,zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near}:n.perspective={aspectRatio:e.aspect,yfov:Rn.degToRad(e.fov),zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near},""!==e.name&&(n.name=e.type),t.cameras.push(n)-1}processAnimation(e,t){let i=this.json,n=this.nodeMap;i.animations||(i.animations=[]);let r=(e=$v.Utils.mergeMorphTargetTracks(e.clone(),t)).tracks,a=[],s=[];for(let o=0;o<r.length;++o){let e=r[o],i=Jn.parseTrackName(e.name),l=Jn.findNode(t,i.nodeName),h=Sde[i.propertyName];if("bones"===i.objectName&&(l=!0===l.isSkinnedMesh?l.skeleton.getBoneByName(i.objectIndex):void 0),!l||!h)return console.warn('THREE.GLTFExporter: Could not export animation track "%s".',e.name),null;let c,u=1,d=e.values.length/e.times.length;h===Sde.morphTargetInfluences&&(d/=l.morphTargetInfluences.length),!0===e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline?(c="CUBICSPLINE",d/=3):c=e.getInterpolation()===jh?"STEP":"LINEAR",s.push({input:this.processAccessor(new mn(e.times,u)),output:this.processAccessor(new mn(e.values,d)),interpolation:c}),a.push({sampler:s.length-1,target:{node:n.get(l),path:h}})}return i.animations.push({name:e.name||"clip_"+i.animations.length,samplers:s,channels:a}),i.animations.length-1}processSkin(e){let t=this.json,i=this.nodeMap,n=t.nodes[i.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 et;for(let h=0;h<r.bones.length;++h)s.push(i.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 mn(o,16)),joints:s,skeleton:i.get(a)}),n.skin=t.skins.length-1}processNode(e){let t=this.json,i=this.options,n=this.nodeMap;t.nodes||(t.nodes=[]);let r={};if(i.trs){let t=e.quaternion.toArray(),i=e.position.toArray(),n=e.scale.toArray();Kb(t,[0,0,0,1])||(r.rotation=t),Kb(i,[0,0,0])||(r.translation=i),Kb(n,[1,1,1])||(r.scale=n)}else e.matrixAutoUpdate&&e.updateMatrix(),!1===Jot(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 n=0,r=e.children.length;n<r;n++){let r=e.children[n];if(r.visible||!1===i.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 n.set(e,a),a}processScene(e){let t=this.json,i=this.options;t.scenes||(t.scenes=[],t.scene=0);let n={};""!==e.name&&(n.name=e.name),t.scenes.push(n);let r=[];for(let a=0,s=e.children.length;a<s;a++){let t=e.children[a];if(t.visible||!1===i.onlyVisible){let e=this.processNode(t);null!==e&&r.push(e)}}r.length>0&&(n.nodes=r),this.serializeUserData(e,n)}processObjects(e){let t=new Si;t.name="AuxScene";for(let i=0;i<e.length;i++)t.children.push(e[i]);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 i=[];for(let n=0;n<e.length;n++)e[n]instanceof Si?this.processScene(e[n]):i.push(e[n]);i.length>0&&this.processObjects(i);for(let n=0;n<this.skins.length;++n)this.processSkin(this.skins[n]);for(let n=0;n<t.animations.length;++n)this.processAnimation(t.animations[n],e[0]);this._invokeAll((function(t){t.afterParse&&t.afterParse(e)}))}_invokeAll(e){for(let t=0,i=this.plugins.length;t<i;t++)e(this.plugins[t])}},TH=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 i=this.writer,n=i.json,r=i.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]||(n.extensions=n.extensions||{},n.extensions[this.name]={lights:[]},r[this.name]=!0);let s=n.extensions[this.name].lights;s.push(a),t.extensions=t.extensions||{},t.extensions[this.name]={light:s.length-1}}},wH=class{constructor(e){this.writer=e,this.name="KHR_materials_unlit"}writeMaterial(e,t){if(!e.isMeshBasicMaterial)return;let i=this.writer.extensionsUsed;t.extensions=t.extensions||{},t.extensions[this.name]={},i[this.name]=!0,t.pbrMetallicRoughness.metallicFactor=0,t.pbrMetallicRoughness.roughnessFactor=.9}},SH=class{constructor(e){this.writer=e,this.name="KHR_materials_clearcoat"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0===e.clearcoat)return;let i=this.writer,n=i.extensionsUsed,r={};if(r.clearcoatFactor=e.clearcoat,e.clearcoatMap){let t={index:i.processTexture(e.clearcoatMap),texCoord:e.clearcoatMap.channel};i.applyTextureTransform(t,e.clearcoatMap),r.clearcoatTexture=t}if(r.clearcoatRoughnessFactor=e.clearcoatRoughness,e.clearcoatRoughnessMap){let t={index:i.processTexture(e.clearcoatRoughnessMap),texCoord:e.clearcoatRoughnessMap.channel};i.applyTextureTransform(t,e.clearcoatRoughnessMap),r.clearcoatRoughnessTexture=t}if(e.clearcoatNormalMap){let t={index:i.processTexture(e.clearcoatNormalMap),texCoord:e.clearcoatNormalMap.channel};i.applyTextureTransform(t,e.clearcoatNormalMap),r.clearcoatNormalTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=r,n[this.name]=!0}},MH=class{constructor(e){this.writer=e,this.name="KHR_materials_iridescence"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0===e.iridescence)return;let i=this.writer,n=i.extensionsUsed,r={};if(r.iridescenceFactor=e.iridescence,e.iridescenceMap){let t={index:i.processTexture(e.iridescenceMap),texCoord:e.iridescenceMap.channel};i.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:i.processTexture(e.iridescenceThicknessMap),texCoord:e.iridescenceThicknessMap.channel};i.applyTextureTransform(t,e.iridescenceThicknessMap),r.iridescenceThicknessTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=r,n[this.name]=!0}},RH=class{constructor(e){this.writer=e,this.name="KHR_materials_transmission"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0===e.transmission)return;let i=this.writer,n=i.extensionsUsed,r={};if(r.transmissionFactor=e.transmission,e.transmissionMap){let t={index:i.processTexture(e.transmissionMap),texCoord:e.transmissionMap.channel};i.applyTextureTransform(t,e.transmissionMap),r.transmissionTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=r,n[this.name]=!0}},AH=class{constructor(e){this.writer=e,this.name="KHR_materials_volume"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0===e.transmission)return;let i=this.writer,n=i.extensionsUsed,r={};if(r.thicknessFactor=e.thickness,e.thicknessMap){let t={index:i.processTexture(e.thicknessMap),texCoord:e.thicknessMap.channel};i.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,n[this.name]=!0}},CH=class{constructor(e){this.writer=e,this.name="KHR_materials_ior"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||1.5===e.ior)return;let i=this.writer.extensionsUsed,n={};n.ior=e.ior,t.extensions=t.extensions||{},t.extensions[this.name]=n,i[this.name]=!0}},PH=class{constructor(e){this.writer=e,this.name="KHR_materials_specular"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||1===e.specularIntensity&&e.specularColor.equals(jot)&&!e.specularIntensityMap&&!e.specularColorTexture)return;let i=this.writer,n=i.extensionsUsed,r={};if(e.specularIntensityMap){let t={index:i.processTexture(e.specularIntensityMap),texCoord:e.specularIntensityMap.channel};i.applyTextureTransform(t,e.specularIntensityMap),r.specularTexture=t}if(e.specularColorMap){let t={index:i.processTexture(e.specularColorMap),texCoord:e.specularColorMap.channel};i.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,n[this.name]=!0}},IH=class{constructor(e){this.writer=e,this.name="KHR_materials_sheen"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0==e.sheen)return;let i=this.writer,n=i.extensionsUsed,r={};if(e.sheenRoughnessMap){let t={index:i.processTexture(e.sheenRoughnessMap),texCoord:e.sheenRoughnessMap.channel};i.applyTextureTransform(t,e.sheenRoughnessMap),r.sheenRoughnessTexture=t}if(e.sheenColorMap){let t={index:i.processTexture(e.sheenColorMap),texCoord:e.sheenColorMap.channel};i.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,n[this.name]=!0}},LH=class{constructor(e){this.writer=e,this.name="KHR_materials_anisotropy"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0==e.anisotropy)return;let i=this.writer,n=i.extensionsUsed,r={};if(e.anisotropyMap){let t={index:i.processTexture(e.anisotropyMap)};i.applyTextureTransform(t,e.anisotropyMap),r.anisotropyTexture=t}r.anisotropyStrength=e.anisotropy,r.anisotropyRotation=e.anisotropyRotation,t.extensions=t.extensions||{},t.extensions[this.name]=r,n[this.name]=!0}},DH=class{constructor(e){this.writer=e,this.name="KHR_materials_emissive_strength"}writeMaterial(e,t){if(!e.isMeshStandardMaterial||1===e.emissiveIntensity)return;let i=this.writer.extensionsUsed,n={};n.emissiveStrength=e.emissiveIntensity,t.extensions=t.extensions||{},t.extensions[this.name]=n,i[this.name]=!0}};$v.Utils={insertKeyframe:function(e,t){let i,n=e.getValueSize(),r=new e.TimeBufferType(e.times.length+1),a=new e.ValueBufferType(e.values.length+n),s=e.createInterpolant(new e.ValueBufferType(n));if(0===e.times.length){r[0]=t;for(let e=0;e<n;e++)a[e]=0;i=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,n),i=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),i=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)*n),0),a.set(s.evaluate(t),(o+1)*n),a.set(e.values.slice((o+1)*n),(o+2)*n),i=o+1;break}}return e.times=r,e.values=a,i},mergeMorphTargetTracks:function(e,t){let i=[],n={},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){i.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(_u)}let l,h=o.morphTargetInfluences.length,c=o.morphTargetDictionary[s.propertyIndex];if(void 0===c)throw new Error("THREE.GLTFExporter: Morph target name not found: "+s.propertyIndex);if(void 0===n[o.uuid]){l=e.clone();let t=new l.ValueBufferType(h*l.times.length);for(let e=0;e<l.times.length;e++)t[e*h+c]=l.values[e];l.name=(s.nodeName||"")+".morphTargetInfluences",l.values=t,n[o.uuid]=l,i.push(l);continue}let u=e.createInterpolant(new e.ValueBufferType(1));l=n[o.uuid];for(let t=0;t<l.times.length;t++)l.values[t*h+c]=u.evaluate(l.times[t]);for(let t=0;t<e.times.length;t++){let i=this.insertKeyframe(l,e.times[t]);l.values[i*h+c]=e.values[t]}}return e.tracks=i,e}};var LA=class{parse(e){let t="",i=0,n=0,r=0,a=new D,s=new ct,o=new D,l=new xe,h=[];return e.traverse((function(e){!0===e.isMesh&&function(e){let s=0,c=0,u=0,d=e.geometry,p=new Ln,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 i=0,n=f.count;i<n;i++,s++)a.fromBufferAttribute(f,i),a.applyMatrix4(e.matrixWorld),t+="v "+a.x+" "+a.y+" "+a.z+"\n";if(void 0!==g)for(let i=0,n=g.count;i<n;i++,u++)l.fromBufferAttribute(g,i),t+="vt "+l.x+" "+l.y+"\n";if(void 0!==m){p.getNormalMatrix(e.matrixWorld);for(let e=0,i=m.count;e<i;e++,c++)o.fromBufferAttribute(m,e),o.applyMatrix3(p).normalize(),t+="vn "+o.x+" "+o.y+" "+o.z+"\n"}if(null!==v)for(let a=0,o=v.count;a<o;a+=3){for(let e=0;e<3;e++){let t=v.getX(a+e)+1;h[e]=i+t+(m||g?"/"+(g?n+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]=i+t+(m||g?"/"+(g?n+t:"")+(m?"/"+(r+t):""):"")}t+="f "+h.join(" ")+"\n"}i+=s,n+=u,r+=c}(e),!0===e.isLine&&function(e){let n=0,r=e.geometry,s=e.type,o=r.getAttribute("position");if(t+="o "+e.name+"\n",void 0!==o)for(let i=0,l=o.count;i<l;i++,n++)a.fromBufferAttribute(o,i),a.applyMatrix4(e.matrixWorld),t+="v "+a.x+" "+a.y+" "+a.z+"\n";if("Line"===s){t+="l ";for(let e=1,n=o.count;e<=n;e++)t+=i+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 "+(i+a)+" "+(i+l)+"\n";i+=n}(e),!0===e.isPoints&&function(e){let n=0,r=e.geometry,o=r.getAttribute("position"),l=r.getAttribute("color");if(t+="o "+e.name+"\n",void 0!==o){for(let i=0,r=o.count;i<r;i++,n++)a.fromBufferAttribute(o,i),a.applyMatrix4(e.matrixWorld),t+="v "+a.x+" "+a.y+" "+a.z,void 0!==l&&(s.fromBufferAttribute(l,i).convertLinearToSRGB(),t+=" "+s.r+" "+s.g+" "+s.b),t+="\n";t+="p ";for(let e=1,n=o.count;e<=n;e++)t+=i+e+" ";t+="\n"}i+=n}(e)})),t}},DA=class{parse(e,t={}){let i=(t=Object.assign({binary:!1},t)).binary,n=[],r=0;e.traverse((function(e){if(e.isMesh){let t=e.geometry,i=t.index,a=t.getAttribute("position");r+=null!==i?i.count/3:a.count/3,n.push({object3d:e,geometry:t})}}));let a,s=80;if(!0===i){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 D,l=new D,h=new D,c=new D,u=new D,d=new D;for(let m=0,g=n.length;m<g;m++){let e=n[m].object3d,t=n[m].geometry,i=t.index,r=t.getAttribute("position");if(null!==i)for(let n=0;n<i.count;n+=3)p(i.getX(n+0),i.getX(n+1),i.getX(n+2),r,e);else for(let n=0;n<r.count;n+=3)p(n+0,n+1,n+2,r,e)}return!1===i&&(a+="endsolid exported\n"),a;function p(e,t,n,r,p){o.fromBufferAttribute(r,e),l.fromBufferAttribute(r,t),h.fromBufferAttribute(r,n),!0===p.isSkinnedMesh&&(p.applyBoneTransform(e,o),p.applyBoneTransform(t,l),p.applyBoneTransform(n,h)),o.applyMatrix4(p.matrixWorld),l.applyMatrix4(p.matrixWorld),h.applyMatrix4(p.matrixWorld),function(e,t,n){c.subVectors(n,t),u.subVectors(e,t),c.cross(u).normalize(),d.copy(c).normalize(),!0===i?(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===i?(a.setUint16(s,0,!0),s+=2):(a+="\t\tendloop\n",a+="\tendfacet\n")}function f(e){!0===i?(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"}}},mi=class{static exportToGltf(e,t){mi.exportToGltfOrGlb(e,t,{binary:!1})}static exportToGlb(e,t){mi.exportToGltfOrGlb(e,t,{binary:!0})}static exportToGltfOrGlb(e,t,i={}){if(!e||!t)throw new Error("Invalid input or filename!");let n=new $v;i=Object.assign({},{binary:!0,onlyVisible:!1,includeCustomExtensions:!1},i),n.parse(e,(e=>{if(i.binary){t=mi.addExtention(t,mi.EXTENSION_GLB);let i=e;mi.saveArrayBuffer(i,t)}else t=mi.addExtention(t,mi.EXTENSION_GLTF),mi.saveJson(e,t)}),(e=>console.log(e)),i)}static exportToObj(e,t){if(!e||!t)throw new Error("Invalid input or filename!");t=mi.addExtention(t,mi.EXTENSION_OBJ);let i=(new LA).parse(e);mi.saveString(i,t)}static exportToDraco(e,t,i={}){if(!e||!t)throw new Error("Invalid input or filename!");t=mi.addExtention(t,mi.EXTENSION_DRACO);let n=new ga;i=Object.assign({},{encodeSpeed:5},i);let r=n.parse(e,i);mi.saveArrayBuffer(r,t)}static exportToStl(e,t,i=!1){if(!e||!t)throw new Error("Invalid input or filename!");t=mi.addExtention(t,mi.EXTENSION_STL);let n=new DA;if(i){let i={binary:!0},r=n.parse(e,i);mi.saveDataView(r,t)}else{let i=n.parse(e);mi.saveString(i,t)}}static exportToThreeJsJson(e,t){let i=e.toJSON();t.toLowerCase().endsWith(mi.EXTENSION_JSON)||(t+=mi.EXTENSION_JSON),mi.saveJson(i,t)}static save(e,t){let i=mi.downloadLink;i||(i=document.createElement("a"),i.style.display="none",document.body.appendChild(i),mi.downloadLink=i),i.href=URL.createObjectURL(e),i.download=t,i.click()}static saveArrayBuffer(e,t){mi.save(new Blob([e],{type:"application/octet-stream"}),t)}static saveJson(e,t){mi.saveJsonString(JSON.stringify(e),t)}static saveJsonString(e,t){mi.save(new Blob([e],{type:"application/json"}),t)}static saveString(e,t){mi.save(new Blob([e],{type:"text/plain"}),t)}static saveDataView(e,t){mi.save(new Blob([e],{type:"application/octet-stream"}),t)}static addExtention(e,t){return e.toLowerCase().endsWith(t.toLowerCase())||(e+=t),e}},Af=mi;Af.EXTENSION_GLTF=".gltf",Af.EXTENSION_GLB=".glb",Af.EXTENSION_OBJ=".obj",Af.EXTENSION_DRACO=".drc",Af.EXTENSION_JSON=".json",Af.EXTENSION_STL=".stl";var OA=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()}},UH={exports:{}};function NA(e,t,i){i=i||2;var n,r,a,s,o,l,h,c=t&&t.length,u=c?t[0]*i:e.length,d=Fde(e,0,u,i,!0),p=[];if(!d||d.next===d.prev)return p;if(c&&(d=ilt(e,t,d,i)),e.length>80*i){n=a=e[0],r=s=e[1];for(var f=i;f<u;f+=i)(o=e[f])<n&&(n=o),(l=e[f+1])<r&&(r=l),o>a&&(a=o),l>s&&(s=l);h=0!==(h=Math.max(a-n,s-r))?32767/h:0}return Jb(d,p,i,n,r,h,0),p}function Fde(e,t,i,n,r){var a,s;if(r===BH(e,t,i,n)>0)for(a=t;a<i;a+=n)s=Ide(a,e[a],e[a+1],s);else for(a=i-n;a>=t;a-=n)s=Ide(a,e[a],e[a+1],s);return s&&BA(s,s.next)&&(eE(s),s=s.next),s}function Fm(e,t){if(!e)return e;t||(t=e);var i,n=e;do{if(i=!1,n.steiner||!BA(n,n.next)&&0!==Qi(n.prev,n,n.next))n=n.next;else{if(eE(n),(n=t=n.prev)===n.next)break;i=!0}}while(i||n!==t);return t}function Jb(e,t,i,n,r,a,s){if(e){!s&&a&&clt(e,n,r,a);for(var o,l,h=e;e.prev!==e.next;)if(o=e.prev,l=e.next,a?tlt(e,n,r,a):elt(e))t.push(o.i/i|0),t.push(e.i/i|0),t.push(l.i/i|0),eE(e),e=l.next,h=l.next;else if((e=l)===h){s?1===s?Jb(e=nlt(Fm(e),t,i),t,i,n,r,a,2):2===s&&rlt(e,t,i,n,r,a):Jb(Fm(e),t,i,n,r,a,1);break}}}function elt(e){var t=e.prev,i=e,n=e.next;if(Qi(t,i,n)>=0)return!1;for(var r=t.x,a=i.x,s=n.x,o=t.y,l=i.y,h=n.y,c=r<a?r<s?r:s:a<s?a:s,u=o<l?o<h?o:h:l<h?l:h,d=r>a?r>s?r:s:a>s?a:s,p=o>l?o>h?o:h:l>h?l:h,f=n.next;f!==t;){if(f.x>=c&&f.x<=d&&f.y>=u&&f.y<=p&&Zv(r,o,a,l,s,h,f.x,f.y)&&Qi(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function tlt(e,t,i,n){var r=e.prev,a=e,s=e.next;if(Qi(r,a,s)>=0)return!1;for(var o=r.x,l=a.x,h=s.x,c=r.y,u=a.y,d=s.y,p=o<l?o<h?o:h:l<h?l:h,f=c<u?c<d?c:d:u<d?u:d,m=o>l?o>h?o:h:l>h?l:h,g=c>u?c>d?c:d:u>d?u:d,v=FH(p,f,t,i,n),y=FH(m,g,t,i,n),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&&Zv(o,c,l,u,h,d,x.x,x.y)&&Qi(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&&Zv(o,c,l,u,h,d,b.x,b.y)&&Qi(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&&Zv(o,c,l,u,h,d,x.x,x.y)&&Qi(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&&Zv(o,c,l,u,h,d,b.x,b.y)&&Qi(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function nlt(e,t,i){var n=e;do{var r=n.prev,a=n.next.next;!BA(r,a)&&Nde(r,n,n.next,a)&&Qb(r,a)&&Qb(a,r)&&(t.push(r.i/i|0),t.push(n.i/i|0),t.push(a.i/i|0),eE(n),eE(n.next),n=e=a),n=n.next}while(n!==e);return Fm(n)}function rlt(e,t,i,n,r,a){var s=e;do{for(var o=s.next.next;o!==s.prev;){if(s.i!==o.i&&dlt(s,o)){var l=Bde(s,o);return s=Fm(s,s.next),l=Fm(l,l.next),Jb(s,t,i,n,r,a,0),void Jb(l,t,i,n,r,a,0)}o=o.next}s=s.next}while(s!==e)}function ilt(e,t,i,n){var r,a,s,o=[];for(r=0,a=t.length;r<a;r++)(s=Fde(e,t[r]*n,r<a-1?t[r+1]*n:e.length,n,!1))===s.next&&(s.steiner=!0),o.push(hlt(s));for(o.sort(slt),r=0;r<o.length;r++)i=alt(o[r],i);return i}function slt(e,t){return e.x-t.x}function alt(e,t){var i=olt(e,t);if(!i)return t;var n=Bde(i,e);return Fm(n,n.next),Fm(i,i.next)}function olt(e,t){var i,n=t,r=e.x,a=e.y,s=-1/0;do{if(a<=n.y&&a>=n.next.y&&n.next.y!==n.y){var o=n.x+(a-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(o<=r&&o>s&&(s=o,i=n.x<n.next.x?n:n.next,o===r))return i}n=n.next}while(n!==t);if(!i)return null;var l,h=i,c=i.x,u=i.y,d=1/0;n=i;do{r>=n.x&&n.x>=c&&r!==n.x&&Zv(a<u?r:s,a,c,u,a<u?s:r,a,n.x,n.y)&&(l=Math.abs(a-n.y)/(r-n.x),Qb(n,e)&&(l<d||l===d&&(n.x>i.x||n.x===i.x&&llt(i,n)))&&(i=n,d=l)),n=n.next}while(n!==h);return i}function llt(e,t){return Qi(e.prev,e,t.prev)<0&&Qi(t.next,e,e.next)<0}function clt(e,t,i,n){var r=e;do{0===r.z&&(r.z=FH(r.x,r.y,t,i,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==e);r.prevZ.nextZ=null,r.prevZ=null,ult(r)}function ult(e){var t,i,n,r,a,s,o,l,h=1;do{for(i=e,e=null,a=null,s=0;i;){for(s++,n=i,o=0,t=0;t<h&&(o++,n=n.nextZ);t++);for(l=h;o>0||l>0&&n;)0!==o&&(0===l||!n||i.z<=n.z)?(r=i,i=i.nextZ,o--):(r=n,n=n.nextZ,l--),a?a.nextZ=r:e=r,r.prevZ=a,a=r;i=n}a.nextZ=null,h*=2}while(s>1);return e}function FH(e,t,i,n,r){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-i)*r|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-n)*r|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function hlt(e){var t=e,i=e;do{(t.x<i.x||t.x===i.x&&t.y<i.y)&&(i=t),t=t.next}while(t!==e);return i}function Zv(e,t,i,n,r,a,s,o){return(r-s)*(t-o)>=(e-s)*(a-o)&&(e-s)*(n-o)>=(i-s)*(t-o)&&(i-s)*(a-o)>=(r-s)*(n-o)}function dlt(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!flt(e,t)&&(Qb(e,t)&&Qb(t,e)&&plt(e,t)&&(Qi(e.prev,e,t.prev)||Qi(e,t.prev,t))||BA(e,t)&&Qi(e.prev,e,e.next)>0&&Qi(t.prev,t,t.next)>0)}function Qi(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function BA(e,t){return e.x===t.x&&e.y===t.y}function Nde(e,t,i,n){var r=FA(Qi(e,t,i)),a=FA(Qi(e,t,n)),s=FA(Qi(i,n,e)),o=FA(Qi(i,n,t));return!!(r!==a&&s!==o||0===r&&kA(e,i,t)||0===a&&kA(e,n,t)||0===s&&kA(i,e,n)||0===o&&kA(i,t,n))}function kA(e,t,i){return t.x<=Math.max(e.x,i.x)&&t.x>=Math.min(e.x,i.x)&&t.y<=Math.max(e.y,i.y)&&t.y>=Math.min(e.y,i.y)}function FA(e){return e>0?1:e<0?-1:0}function flt(e,t){var i=e;do{if(i.i!==e.i&&i.next.i!==e.i&&i.i!==t.i&&i.next.i!==t.i&&Nde(i,i.next,e,t))return!0;i=i.next}while(i!==e);return!1}function Qb(e,t){return Qi(e.prev,e,e.next)<0?Qi(e,t,e.next)>=0&&Qi(e,e.prev,t)>=0:Qi(e,t,e.prev)<0||Qi(e,e.next,t)<0}function plt(e,t){var i=e,n=!1,r=(e.x+t.x)/2,a=(e.y+t.y)/2;do{i.y>a!=i.next.y>a&&i.next.y!==i.y&&r<(i.next.x-i.x)*(a-i.y)/(i.next.y-i.y)+i.x&&(n=!n),i=i.next}while(i!==e);return n}function Bde(e,t){var i=new NH(e.i,e.x,e.y),n=new NH(t.i,t.x,t.y),r=e.next,a=t.prev;return e.next=t,t.prev=e,i.next=r,r.prev=i,n.next=i,i.prev=n,a.next=n,n.prev=a,n}function Ide(e,t,i,n){var r=new NH(e,t,i);return n?(r.next=n.next,r.prev=n,n.next.prev=r,n.next=r):(r.prev=r,r.next=r),r}function eE(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function NH(e,t,i){this.i=e,this.x=t,this.y=i,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function BH(e,t,i,n){for(var r=0,a=t,s=i-n;a<i;a+=n)r+=(e[s]-e[a])*(e[a+1]+e[s+1]),s=a;return r}UH.exports=NA,UH.exports.default=NA,NA.deviation=function(e,t,i,n){var r=t&&t.length,a=r?t[0]*i:e.length,s=Math.abs(BH(e,0,a,i));if(r)for(var o=0,l=t.length;o<l;o++){var h=t[o]*i,c=o<l-1?t[o+1]*i:e.length;s-=Math.abs(BH(e,h,c,i))}var u=0;for(o=0;o<n.length;o+=3){var d=n[o]*i,p=n[o+1]*i,f=n[o+2]*i;u+=Math.abs((e[d]-e[f])*(e[p+1]-e[d+1])-(e[d]-e[p])*(e[f+1]-e[d+1]))}return 0===s&&0===u?0:Math.abs((u-s)/s)},NA.flatten=function(e){for(var t=e[0][0].length,i={vertices:[],holes:[],dimensions:t},n=0,r=0;r<e.length;r++){for(var a=0;a<e[r].length;a++)for(var s=0;s<t;s++)i.vertices.push(e[r][a][s]);r>0&&(n+=e[r-1].length,i.holes.push(n))}return i};var E3t=UH.exports;function Lde(e,t,i){return e[0]=t[0]-i[0],e[1]=t[1]-i[1],e[2]=t[2]-i[2],e}function mlt(e,t){var i=t[0],n=t[1],r=t[2],a=Math.sqrt(i*i+n*n+r*r)||1;return e[0]=i/a,e[1]=n/a,e[2]=r/a,e}function glt(e,t,i){var n=t[0],r=t[1],a=t[2],s=i[0],o=i[1],l=i[2];return e[0]=r*l-a*o,e[1]=a*s-n*l,e[2]=n*o-r*s,e}function vlt(e,t){function i(e,t,i,n){e[0]=t,e[1]=i,e[2]=n}for(var n=[],r=[],a=[],s=[],o=[],l=[],h=e.length,c=new Float32Array(t.length),u=0;u<h;){var d=3*e[u],p=3*e[u+1],f=3*e[u+2];i(n,t[d],t[d+1],t[d+2]),i(r,t[p],t[p+1],t[p+2]),i(a,t[f],t[f+1],t[f+2]),Lde(o,a,r),Lde(s,n,r),glt(l,o,s);for(var m=0;m<3;m++)c[d+m]+=l[m],c[p+m]+=l[m],c[f+m]+=l[m];u+=3}for(var g=0,v=c.length;g<v;)i(l,c[g],c[g+1],c[g+2]),mlt(l,l),c[g]=l[0]||0,c[g+1]=l[1]||0,c[g+2]=l[2]||0,g+=3;return c}function ylt(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,i=0,n=0,r=e.length;n<r;n++){var a=e[n],s=a.position,o=a.indices;t+=s.length,i+=o.length}for(var l={position:new Float32Array(t),normal:new Float32Array(t),uv:new Float32Array(t/3*2),indices:new Uint32Array(i),results:e},h=0,c=0,u=0,d=0,p=0,f=e.length;p<f;p++){var m=e[p],g=m.position,v=m.indices,y=m.normal,x=m.uv;l.position.set(g,h),l.normal.set(y,h),l.uv.set(x,d);for(var b=0,_=v.length;b<_;){var w=v[b]+c;l.indices[u]=w,u++,b++}d+=x.length,h+=g.length,c+=g.length/3}return l}function xlt(e){return 180*e/Math.PI}function Dde(e){return e/180*Math.PI}function blt(e,t,i,n,r,a){var s=3*i,o=3*n,l=3*r,h=3*a,c=t[s],u=t[s+1],d=t[s+2],p=t[o],f=t[o+1],m=t[o+2],g=t[l],v=t[l+1],y=t[l+2],x=t[h],b=t[h+1],_=t[h+2];Math.abs(u-f)<Math.abs(c-p)?(e.push(c,1-d),e.push(p,1-m),e.push(g,1-y),e.push(x,1-_)):(e.push(u,1-d),e.push(f,1-m),e.push(v,1-y),e.push(b,1-_))}function Ude(e,t){t=Object.assign({},{depth:2,lineWidth:1},t);var i=ylt(e.map((function(e){var i=Tlt(e,t);return i.line=e,Elt(i,t),_lt(i,t),i.position=new Float32Array(i.points),i.indices=new Uint32Array(i.index),i.uv=new Float32Array(i.uvs),i.normal=vlt(i.indices,i.position),i})));return i.lines=e,i}function Elt(e,t){for(var i=t.depth,n=[],r=[],a=[],s=e.leftPoints,o=e.rightPoints,l=0,h=s.length;l<h;){var c=3*l,u=s[l],d=u[0],p=u[1],f=u[2];n[c]=d,n[c+1]=p,n[c+2]=i+f;var m=o[l],g=m[0],v=m[1],y=m[2],x=3*h+c;n[x]=g,n[x+1]=v,n[x+2]=i+y;var b=2*h*3+c;n[b]=d,n[b+1]=p,n[b+2]=f;var _=2*h*3+3*h+c;n[_]=g,n[_+1]=v,n[_+2]=y,l++}for(l=0,h=n.length;l<h;){var w=n[l],S=n[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,D=P+h;r.push(C,R,P),r.push(R,D,P),l++}e.index=r,e.points=n,e.uvs=a}function _lt(e,t){var i=e.points,n=e.index,r=e.leftPoints,a=e.rightPoints,s=e.uvs,o=t.depth,l=[r,a];function h(e,t){var r=i.length/3;i.push(e[0],e[1],o+e[2],t[0],t[1],o+t[2],e[0],e[1],e[2],t[0],t[1],t[2]);var a=r+2,l=r+3,h=r,c=r+1;n.push(a,h,l,h,c,l),blt(s,i,a,l,h,c)}for(var c=0,u=l.length;c<u;c++){var d=l[c];c>0&&(d=(d=d.map((function(e){return e}))).reverse());for(var p=0,f=d.length-1;p<f;)h(d[p],d[p+1]),p++}for(var m=r.length,g=[a[0],r[0],r[m-1],a[m-1]],v=0;v<g.length;v+=2)h(g[v],g[v+1])}var OH={x:0,y:0},kH={x:0,y:0};function Tlt(e,t){for(var i=0,n=t.lineWidth/2,r=[],a=[],s=[],o=e.length,l=0;l<o-1;){var h=e[l],c=e[l+1],u=c[1]-h[1],d=c[0]-h[0],p=0,f=xlt(Math.atan(u/d));if(i=f,0===l)p=f,p-=90;else{var m=e[l-1];OH.x=m[0]-h[0],OH.y=m[1]-h[1],kH.x=c[0]-h[0],kH.y=c[1]-h[1],p=f-wlt(OH,kH)/2}var g=Ode(Dde(p),n,h),v=g[0],y=g[1];r.push(v,y),kde(v,h,c)?(a.push(v),s.push(y)):(a.push(y),s.push(v)),l++}var x=i,b=Dde(x-=90),_=e[o-2],w=e[o-1],S=Ode(b,n,w),M=S[0],E=S[1];return r.push(M,E),kde(M,_,w)?(a.push(M),s.push(E)):(a.push(E),s.push(M)),{offsetPoints:r,leftPoints:a,rightPoints:s}}function Ode(e,t,i){var n=i[0],r=i[1],a=i[2]||0,s=[n+Math.cos(e)*t,r+Math.sin(e)*t,a],o=e+=Math.PI;return[s,[n+Math.cos(o)*t,r+Math.sin(o)*t,a]]}var wlt=function(e,t){var i=e.x,n=e.y,r=t.x,a=t.y,s=i*r+n*a,o=i*a-n*r;return(Math.atan2(o,s)/Math.PI*180+360)%360};function kde(e,t,i){var n=t[0],r=t[1],a=i[0],s=i[1];return(r-s)*e[0]+(a-n)*e[1]+n*s-a*r>0}var HH=1e-15,Hde=(new et).set(0,0,-1,0,1,0,0,0,0,1,0,0,0,0,0,1),Vde=(new et).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,i=1e-7){return Math.abs(e-t)<i*Math.max(1,Math.abs(e),Math.abs(t))}static areVector2sEqual(e,t,i=1e-7){return Zt.areNumbersEqual(e.x,t.x,i)&&Zt.areNumbersEqual(e.y,t.y,i)}static areVector3sEqual(e,t,i=1e-7){return Zt.areNumbersEqual(e.x,t.x,i)&&Zt.areNumbersEqual(e.y,t.y,i)&&Zt.areNumbersEqual(e.z,t.z,i)}static areNumbersClose(e,t,i=1e-9,n=1e-12){return Math.abs(e-t)<=Math.max(i*Math.max(Math.abs(e),Math.abs(t)),n)}static areVector2sClose(e,t,i=1e-9,n=1e-12){return this.areNumbersClose(e.x,t.x,i,n)&&this.areNumbersClose(e.y,t.y,i,n)}static areVectorsClose(e,t,i=1e-9,n=1e-12){return this.areNumbersClose(e.x,t.x,i,n)&&this.areNumbersClose(e.y,t.y,i,n)&&this.areNumbersClose(e.z,t.z,i,n)}static getArcAngleSpanInRadian(e,t){let i=2*Math.PI;return Zt.areNumbersClose(e,t,HH)?0:(e%=i,Zt.areNumbersClose(e,t%i,HH)?i:(Zt.areNumbersClose(t,i,HH)&&(t%=i),t<e&&(t+=i),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 i=Zt.getIntegerPartLength(e);return Math.max(Math.pow(10,i)*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 i=(new xe).subVectors(t,e),n=i.angle(),r=i.length(),a=Rn.degToRad(45),s=r/2/Math.cos(a);return new xe(e.x+s*Math.cos(a-n),e.y-s*Math.sin(a-n))}static convertPointFromUEToGltf(e){let t=new D(e.x,e.y,e.z);return t.applyMatrix4(Hde.clone().invert()),{x:t.x,y:t.y,z:t.z}}static convertPointFromGltfToUE(e){let t=new D(e.x,e.y,e.z);return t.applyMatrix4(Hde),{x:t.x,y:t.y,z:t.z}}static convertPointFromUEToRevit(e){let t=new D(e.x,e.y,e.z);return t.applyMatrix4(Vde.clone().invert()),{x:t.x,y:t.y,z:t.z}}static convertPointFromRevitToUE(e){let t=new D(e.x,e.y,e.z);return t.applyMatrix4(Vde),{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 D(e[0],e[1],e[2]),i=new D(e[3],e[4],e[5]),n=(new D).addVectors(t,i).multiplyScalar(.5);return{x:n.x,y:n.y,z:n.z}}static convertBoxFromGltfToUE(e){let t=Zt.convertPointFromGltfToUE({x:e[0],y:e[1],z:e[2]}),i=Zt.convertPointFromGltfToUE({x:e[3],y:e[4],z:e[5]});return Zt.getBox(t,i)}static convertBoxFromUEToGltf(e){let t=Zt.convertPointFromUEToGltf({x:e[0],y:e[1],z:e[2]}),i=Zt.convertPointFromUEToGltf({x:e[3],y:e[4],z:e[5]});return Zt.getBox(t,i)}static convertBoxFromRevitToUE(e){let t=Zt.convertPointFromRevitToUE({x:e[0],y:e[1],z:e[2]}),i=Zt.convertPointFromRevitToUE({x:e[3],y:e[4],z:e[5]});return Zt.getBox(t,i)}static convertBoxFromUEToRevit(e){let t=Zt.convertPointFromUEToRevit({x:e[0],y:e[1],z:e[2]}),i=Zt.convertPointFromUEToRevit({x:e[3],y:e[4],z:e[5]});return Zt.getBox(t,i)}static clamp(e,t,i){return Math.max(t,Math.min(i,e))}static getLookAtMatrix(e,t,i){let n=new et,r=new D(e.x,e.y,e.z),a=new D(t.x,t.y,t.z),s=new D(i.x,i.y,i.z);n.lookAt(r,a,s),n.transpose();let o=[];return n.toArray(o),o}static getLocationFromMatrix(e){let t=new D;return t.setFromMatrixPosition((new et).fromArray(e)),{x:t.x,y:t.y,z:t.z}}static toDegrees(e){return Rn.radToDeg(e)}static toRadians(e){return Rn.degToRad(e)}},VH=1e7,zde=new Mi,Gde=new Mi,qde=new D,Wde=new D,jde=new D,Cf=new Zr,Qt=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 i=Object.keys(e).sort(),n=Object.keys(t).sort();if(i.length!==n.length)return!1;for(let r=0;r<i.length;++r){if(i[r]!==n[r])return!1;let a=e[i[r]],s=t[n[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 i=0;i<e.array.length;++i)if(e.array[i]!==t.array[i])return!1}else if(e.array||t.array)return!1;let i=e.data,n=t.data;if(i&&n){if(i.length!==n.length)return!1;for(let e=0;e<i.length;++e)if(i[e]!==n[e])return!1}else if(i||n)return!1;return!0}static tryConvertInterleavedBufferAttributes(e){!e||!e.attributes||Object.keys(e.attributes).forEach((t=>{let i=e.attributes[t];if(i instanceof co){let n=i.clone();e.attributes[t]=n}}))}static isPointInPolygon(e,t,i=!1){let n=e.x,r=e.y,a=!1,s=t.length;for(let o=0,l=s-1;o<s;l=o++){let e=t[o].x,s=t[o].y,h=t[l].x,c=t[l].y,u=s>r!=c>r;i&&(u=s>=r!=c>=r),u&&n<(h-e)*(r-s)/(c-s)+e&&(a=!a)}return a}static caculateGeometryCenter(e){if(!e.hasAttribute("position"))return null;let t=e.getAttribute("position");if(0===t.count)return null;let i=new D,n=t.itemSize,r=t.array,a=[0,0,0];for(let s=0;s<t.count;s++)for(let e=0;e<n;e++)a[e]+=r[s*n+e];for(let s=0;s<n;s++)i.setComponent(s,a[s]/t.count);return i}static isConvex(e){let t=e.length,i=0,n=0,r=new xe,a=new xe;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),n=r.cross(a),0!=n){if(n>0&&i<0||n<0&&i>0)return!1;i=n}}return!0}static areLineSegmentsIntersecting(e,t){let{start:i,end:n}=e,{start:r,end:a}=t,s=r.clone().sub(i),o=n.clone().sub(i),l=a.clone().sub(i),h=s.cross(o).dot(l.cross(o)),c=i.clone().sub(r),u=a.clone().sub(r),d=n.clone().sub(r),p=c.cross(u).dot(d.cross(u));return h<0&&p<0}static getLineSegmentsIntersectingPoint(e,t){let{start:i,end:n}=e,{start:r,end:a}=t,s=qde.subVectors(n,i).normalize(),o=Wde.subVectors(a,r).normalize();if(1===s.dot(o))return null;let l=jde.subVectors(r,i),h=s.clone().cross(o),c=l.clone().cross(o),u=l.clone().dot(h);if(u>=1e-5||u<=-1e-5)return null;let d=h.lengthSq();if(Zt.areNumbersEqual(0,d))return;let p=c.clone().dot(h)/d,f=i.clone().add(s.multiplyScalar(p));return f.equals(i)||f.equals(n)?null:f}static isPointOnLineSegment(e,t,i=.001){let{start:n,end:r}=t,a=qde.subVectors(n,r).length(),s=Wde.subVectors(e,n).length(),o=jde.subVectors(e,r).length();return Math.abs(a-(s+o))<=i}static isPointOnLineSegments(e,t,i=.001){let n=!1;for(let r=0;r<t.length-1;r+=2){let a=t[r],s=t[r+1];if(n=this.isPointOnLineSegment(e,{start:a,end:s},i),n)break}return n}static checkAndRebasePositionsOnRTC(e,t){if(0===e.length)return!1;let i=e[0]instanceof D;e.forEach((e=>{i?t.add(e):(t.x+=e.x,t.y+=e.y)})),t.divideScalar(e.length);let n=!1;if(Qt.shouldRebasePositionOnRTC(t)){n=!0;for(let n=0;n<e.length;n++){let r=e[n].x-t.x,a=e[n].y-t.y;e[n]=i?new D(r,a,e[n].z-t.z):new xe(r,a)}}else t.setScalar(0);return n}static shouldRebasePositionOnRTC(e){return Math.abs(e.x)>VH||Math.abs(e.y)>VH||e instanceof D&&Math.abs(e.z)>VH}static calculateSurfaceArea(e){let t=0,i=e.getAttribute("position"),n=e.index;if(n)for(let r=0;r<n.count;r+=3)Cf.a.fromBufferAttribute(i,n.getX(r)),Cf.b.fromBufferAttribute(i,n.getX(r+1)),Cf.c.fromBufferAttribute(i,n.getX(r+2)),t+=Cf.getArea();else for(let r=0;r<i.count;r+=3)Cf.a.fromBufferAttribute(i,r),Cf.b.fromBufferAttribute(i,r+1),Cf.c.fromBufferAttribute(i,r+2),t+=Cf.getArea();return t}static convertLineStripToLine(e,t=!1){let i=e.getIndex();if(!i)return;let n=i.array.constructor,r=i.count,a=r;r>2&&(a=t?2*r:2*r-2);let s=new n(a),o=0;for(let l=0;l<r;l++){let e=i.getX(l);s[o++]=e,l>0&&l<r-1&&(s[o++]=e)}t&&(s[o++]=i.getX(r-1),s[o++]=i.getX(0)),e.setIndex(s)}static convertGeometryWithIndexedToNonIndexed(e){if(!e.index)return e;let t=new Dt,i=e.index;for(let n in e.attributes)t.setAttribute(n,Qt.createGeometryAttributeByIndex(e.attributes[n],i));return t}static createGeometryAttributeByIndex(e,t){let i=t.count,n=e.itemSize,r=new(0,e.array.constructor)(i*n);for(let a=0;a<i;a++){let i=t.getX(a)*n;for(let t=0;t<n;t++)r[a*n+t]=e.array[i+t]}return new mn(r,n,e.normalized)}static getLineEndPointsByIndex(e,t){var i,n,r;let a=t=>{let i=e.geometry.attributes.position.array;return e.localToWorld(new D(i[3*t],i[3*t+1],i[3*t+2]))};e.updateWorldMatrix(!0,!1);let s=(null==(i=e.geometry.getIndex())?void 0:i.array)||[],o=null!=(n=s[t])?n: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||(zde.setFromPoints(e),Gde.setFromPoints(t),!zde.intersectsBox(Gde)))return!1;for(let i=0;i<e.length;){if(this.isPointInPolygon(e[i],t,!0))return!0;i<e.length-1&&Zt.areVector2sEqual(e[i+1],e[i])&&++i,++i}return!1}static getLineLineIntersectionPoint(e,t,i,n,r=.001){let a=t.clone().sub(e).normalize(),s=n.clone().sub(i).normalize();if(Math.abs(a.dot(s))>1-r)return;let o=t.y-e.y,l=e.x-t.x,h=o*e.x+l*e.y,c=n.y-i.y,u=i.x-n.x,d=c*i.x+u*i.y,p=o*u-c*l;return Math.abs(p)<r?void 0:new xe((u*h-l*d)/p,(o*d-c*h)/p)}static getOffsetPoint(e,t,i){let n=t.x-e.x,r=t.y-e.y,a=i/Math.sqrt(n*n+r*r);return new xe(-a*r,a*n)}static convertSimpleWidthLineToMeshGeometry(e,t){let i,n,r,a=!1,s=!1,o=[],l=[],h=new xe,c=new xe,u=new xe,d=new xe,p=[],f=t/2;for(let y=0,x=e.length-1;y<x;y++)a=!y,s=y===e.length-2,i=this.getOffsetPoint(e[y],e[y+1],f),h=new xe(e[y].x+i.x,e[y].y+i.y),c=new xe(e[y+1].x+i.x,e[y+1].y+i.y),u=new xe(e[y].x-i.x,e[y].y-i.y),d=new xe(e[y+1].x-i.x,e[y+1].y-i.y),a||(n=this.getLineLineIntersectionPoint(o[0],o[1],h,c),void 0!==n?p.unshift(n):p.unshift(h),r=this.getLineLineIntersectionPoint(l[0],l[1],u,d),void 0!==r?p.push(r):p.push(u)),a&&(p.unshift(h),p.push(u)),s&&(p.unshift(c),p.push(d)),s||(o=[h,c],l=[u,d]);if(p.length<3)return;let m=zs.triangulateShape(p,[]),g=[];for(let y=0;y<m.length;y++)g.push(...m[y]);let v=(new Dt).setFromPoints(p);return v.setIndex(g),v}static convertWidthLineToMeshGeometry(e,t){if(e.length<2)return;let i=[];e.forEach((e=>{i.push([e.x,e.y])}));try{let{indices:e,position:n}=Ude([i],{lineWidth:t,depth:1}),r=new Dt;return r.setAttribute("position",new Bt(n,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 i=[],n=e.length;for(let r=0;r<n-1;r++)Zt.areVector3sEqual(e[r],e[r+1],t)||i.push(e[r]);return i.push(e[n-1]),i}static mergeBBoxes(e){let t=[...e];if(t.length<2)return t;let i=[],n=[];for(let r=0;r<t.length;r++){let e=t[r];if(!n.includes(r)){for(let i=0;i<t.length;i++){let r=t[i];e.equals(r)||e.intersectsBox(r)&&(e.union(r),n.push(i))}i.push(e)}}return i}},Xde={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"}},Yde={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"}},es=class{static materialEquals(e,t){if(e===t)return!0;if(e.type!==t.type)return!1;if(e instanceof yr&&t instanceof yr){let i=e,n=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(i.color,n.color)&&this.colorEquals(i.emissive,n.emissive)&&i.roughness===n.roughness&&i.metalness===n.metalness&&i.alphaMap===n.alphaMap&&i.uniforms===n.uniforms&&i.defines===n.defines&&i.vertexShader===n.vertexShader&&i.fragmentShader===n.fragmentShader&&i.clippingPlanes===n.clippingPlanes&&i.map===n.map&&i.clipIntersection===n.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 i=0;i<e.length;++i)if(!this.materialEquals(e[i],t[i]))return!1;return!0}return e instanceof yr&&t instanceof yr&&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 i=e.material;if(Array.isArray(i)&&i.length>0){let e=[];return i.forEach((i=>{e.push(this.clonedHighlightMaterial(i,t))})),e}if(i instanceof yr)return this.clonedHighlightMaterial(i,t);console.warn(`[MaterialUtils] Invalid material: ${i}`)}static clonedHighlightMaterial(e,t={}){let{depthTest:i,highlightColor:n=new ct(583902),opacity:r=.7}=t,a=e.clone();return this.setMaterialColor(a,n),a.opacity=r,a.transparent=!0,void 0!==i&&(a.depthTest=i,a.side=Sr),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 bi||e instanceof Gn||e instanceof ln?t=e.color:e instanceof cn&&e.uniforms.u_color&&(t=e.uniforms.u_color.value),t}static setMaterialColor(e,t){var i,n,r;let a=e;null==(i=a.color)||i.set(t),null==(n=a.emissive)||n.set(t),null!=(r=a.uniforms)&&r.u_color&&a.uniforms.u_color.value.set(t)}static cloneMaterials(e){let t=new Map;e.traverse((e=>{e.material&&(e.material=(e=>{let i;return Array.isArray(e)?(i=[],e.forEach((e=>{if(t.has(e))i.push(t.get(e));else{let n=e.clone();t.set(e,n),i.push(n)}}))):e&&(t.has(e)?i=t.get(e):(i=e.clone(),t.set(e,i))),i})(e.material))}))}};function Ui(e,t=!1){let i=null!==e[0].index,n=new Set(Object.keys(e[0].attributes)),r=new Set(Object.keys(e[0].morphAttributes)),a={},s={},o=e[0].morphTargetsRelative,l=new Dt,h=0;for(let c=0;c<e.length;++c){let u=e[c],d=0;if(i!==(null!==u.index))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(let e in u.attributes){if(!n.has(e))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+'. All geometries must have compatible attributes; make sure "'+e+'" attribute exists among all geometries, or in none of them.'),null;void 0===a[e]&&(a[e]=[]),a[e].push(u.attributes[e]),d++}if(d!==n.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". Make sure all geometries have the same number of attributes."),null;if(o!==u.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(let e in u.morphAttributes){if(!r.has(e))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". .morphAttributes must be consistent throughout all geometries."),null;void 0===s[e]&&(s[e]=[]),s[e].push(u.morphAttributes[e])}if(t){let e;if(i)e=u.index.count;else{if(void 0===u.attributes.position)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". The geometry must have either an index or a position attribute"),null;e=u.attributes.position.count}l.addGroup(h,e,c),h+=e}}if(i){let t=0,i=[];for(let n=0;n<e.length;++n){let r=e[n].index;for(let e=0;e<r.count;++e)i.push(r.getX(e)+t);t+=e[n].attributes.position.count}l.setIndex(i)}for(let c in a){let e=$de(a[c]);if(!e)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+c+" attribute."),null;l.setAttribute(c,e)}for(let c in s){let e=s[c][0].length;if(0===e)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[c]=[];for(let t=0;t<e;++t){let e=[];for(let n=0;n<s[c].length;++n)e.push(s[c][n][t]);let i=$de(e);if(!i)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+c+" morphAttribute."),null;l.morphAttributes[c].push(i)}}return l}function $de(e){let t,i,n,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===i&&(i=s.itemSize),i!==s.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(void 0===n&&(n=s.normalized),n!==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 mn(s,i,n);return void 0!==r&&(l.gpuType=r),l}function Zde(e,t=1e-4){t=Math.max(t,Number.EPSILON);let i={},n=e.getIndex(),r=e.getAttribute("position"),a=n?n.count:r.count,s=0,o=Object.keys(e.attributes),l={},h={},c=[],u=["getX","getY","getZ","getW"],d=["setX","setY","setZ","setW"];for(let g=0,v=o.length;g<v;g++){let t=o[g],i=e.attributes[t];l[t]=new mn(new i.array.constructor(i.count*i.itemSize),i.itemSize,i.normalized);let n=e.morphAttributes[t];n&&(h[t]=new mn(new n.array.constructor(n.count*n.itemSize),n.itemSize,n.normalized))}let p=Math.log10(1/t),f=Math.pow(10,p);for(let g=0;g<a;g++){let t=n?n.getX(g):g,r="";for(let i=0,n=o.length;i<n;i++){let n=o[i],a=e.getAttribute(n),s=a.itemSize;for(let e=0;e<s;e++)r+=~~(a[u[e]](t)*f)+","}if(r in i)c.push(i[r]);else{for(let i=0,n=o.length;i<n;i++){let n=o[i],r=e.getAttribute(n),a=e.morphAttributes[n],c=r.itemSize,p=l[n],f=h[n];for(let e=0;e<c;e++){let i=u[e],n=d[e];if(p[n](s,r[i](t)),a)for(let e=0,r=a.length;e<r;e++)f[e][n](s,a[e][i](t))}}i[r]=s,c.push(s),s++}}let m=e.clone();for(let g in e.attributes){let e=l[g];if(m.setAttribute(g,new mn(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 mn(e.array.slice(0,s*e.itemSize),e.itemSize,e.normalized)}}return m.setIndex(c),m}function zH(e,t){if(t===FU)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),e;if(t===Av||t===Vb){let i=e.getIndex();if(null===i){let t=[],n=e.getAttribute("position");if(void 0===n)return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),e;for(let e=0;e<n.count;e++)t.push(e);e.setIndex(t),i=e.getIndex()}let n=i.count-2,r=[];if(t===Av)for(let e=1;e<=n;e++)r.push(i.getX(0)),r.push(i.getX(e)),r.push(i.getX(e+1));else for(let e=0;e<n;e++)e%2==0?(r.push(i.getX(e)),r.push(i.getX(e+1)),r.push(i.getX(e+2))):(r.push(i.getX(e+2)),r.push(i.getX(e+1)),r.push(i.getX(e)));r.length/3!==n&&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 GH=new Nt,qH=new et,bn=class{constructor(e=0){this.name="",this.type=0,this.matrix=new et,this.children=[],this.layers=new df,this.renderOrder=0,this.userData={},this.type=e}add(e,...t){for(let i=0;i<t.length;i++)this.add(t[i]);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 n=0;n<t.length;n++)this.remove(t[n]);let i=this.children.indexOf(e);return-1!==i&&(e.parent=void 0,this.children.splice(i,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 i=0,n=t.length;i<n;i++)t[i].traverse(e)}clone(e=!0){return(new bn).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 i=0;i<e.children.length;i++){let t=e.children[i];this.add(t.clone())}return this}convertToThreejsObject(e=!0){let t;switch(this.type){case 0:t=new on;break;case 1:if(!this.geometry)return;t=new ii(this.geometry,this.material);break;case 2:if(!this.geometry)return;t=new fr(this.geometry,this.material);break;case 3:if(!this.geometry)return;t=new qr(this.geometry,this.material);break;case 4:if(!this.geometry)return;t=new xt(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 i=0;i<this.children.length;i++){let n=this.children[i].convertToThreejsObject(e);n&&t.add(n)}return t}}static getBox(e,t,i){if(e.geometry)e.geometry.boundingBox||e.geometry.computeBoundingBox(),qH.copy(e.matrix),i&&qH.premultiply(i),GH.copy(e.geometry.boundingBox),GH.applyMatrix4(qH),t.union(GH);else if(e.children.length>0){e.matrixWorld||(e.matrixWorld=new et),e.matrixWorld.copy(e.matrix),i&&e.matrixWorld.premultiply(i);let n=e.children;for(let i=0,r=n.length;i<r;i++)this.getBox(n[i],t,e.matrixWorld)}return t}},Mlt=new D(0,1,0),Rc=class{static resetObjectStyle(e){this.revertWireframeMode(e),this.revertObjectOpacity(e,[]),this.revertAppliedMaterialToObject(e),this.revertVisibleForFloors(e)}static resetObjectStyleById(e,t){let i=this.getObjectById(e,t);this.resetObjectStyle(i)}static setObjectOpacity(e,t=.3,i,n){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=Sr)},s=e=>{let i=r.find((t=>t.id===e.id));if(!i){let i=e.clone();return r.push({id:e.id,opacity:e.opacity,transparent:e.transparent,side:e.side,material:e,clonedMaterial:i}),i.opacity*=t,i.transparent=!0,i}return i.clonedMaterial};return e.traverse((e=>{if((!n||-1===n.indexOf(e.id))&&(!i||-1!==i.indexOf(e.id))&&e instanceof xt){let t=e;if(i||n){if(Array.isArray(t.material)){let e=[];t.material.forEach((t=>{let i=s(t);i&&e.push(i)})),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,i,n){let r=new Set,a=e=>{if(!e||null==e.id||r.has(e.id))return;r.add(e.id);let i=t.find((t=>t.id===e.id));i&&(e.opacity=i.opacity,e.transparent=i.transparent,e.side=i.side,0===e.opacity&&se.warn(`[ObjectUtils] Material '${e.name}'s opacity is 0, you may not be able to see your objects!`))},s=e=>{let i=t.find((t=>t.clonedMaterial&&t.clonedMaterial.id===e.id));if(i)return i.material};e.traverse((e=>{if((!n||-1===n.indexOf(e.id))&&(!i||-1!==i.indexOf(e.id))&&e instanceof xt)if(Array.isArray(e.material)){let t=[];e.material.forEach((e=>{let i=s(e);i?t.push(i):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,i=.3,n,r){let a=e.getObjectById(t);if(!a)throw new Error(`Failed to find object by id: ${t}`);return Rc.setObjectOpacity(a,i,n,r)}static revertObjectOpacityById(e,t,i,n,r){let a=e.getObjectById(t);if(!a)throw new Error(`Failed to find object by id: ${t}`);Rc.revertObjectOpacity(a,i,n,r)}static applyMaterialToObject(e,t,i,n){e.traverse((e=>{n&&-1!==n.indexOf(e.id)||i&&-1===i.indexOf(e.id)||e instanceof xt&&(e.userData.originalMaterial||(e.userData.originalMaterial=e.material),e.material=t)}))}static revertAppliedMaterialToObject(e,t,i){e.traverse((e=>{i&&-1!==i.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,i,n,r){let a=e.getObjectById(t);if(!a)throw new Error(`Failed to find object by id: ${t}`);this.applyMaterialToObject(a,i,n,r)}static revertAppliedMaterialToObjectById(e,t,i,n){let r=e.getObjectById(t);if(!r)throw new Error(`Failed to find object by id: ${t}`);this.revertAppliedMaterialToObject(r,i,n)}static applyOpacityMaterialToObject(e,t,i){let n=new ln({color:0,transparent:!0,opacity:.05});this.applyMaterialToObject(e,n,t,i)}static setWireframeMode(e){let t=new ln({color:16732160,wireframe:!0,transparent:!0,opacity:.8});e.traverseVisible((e=>{if(e instanceof xt){let i=e;i.userData.materialForWireframe=i.material,i.material=t}}))}static setWireframeModeById(e,t){let i=e.getObjectById(t);if(!i)throw new Error(`Failed to find object by id: ${t}`);Rc.setWireframeMode(i)}static revertWireframeMode(e){e.traverseVisible((e=>{e instanceof xt&&e.userData.materialForWireframe&&(e.material=e.userData.materialForWireframe,e.userData.materialForWireframe=void 0)}))}static revertWireframeModeById(e,t){let i=e.getObjectById(t);if(!i)throw new Error(`Failed to find object by id: ${t}`);Rc.revertWireframeMode(i)}static findInner(e,t,i=[],n=!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,i=t.objectId&&t.objectId.Value||t.elementId&&t.elementId.Value;if(i&&-1!==i.toLowerCase().indexOf(r))return!0}return!1};if(i.length>0)for(let h=0;h<i.length;++h){let t=i[h],r=e.getObjectById(t);if(r&&r.traverse((e=>{(s(e.name)||o(e.id)||l(e.userData))&&a.push(e)})),n&&a.length>0)return[a[0]]}else if(e.traverse((e=>{(s(e.name)||o(e.id)||l(e.userData))&&a.push(e)})),n&&a.length>0)return[a[0]];return a}static find(e,t,i=[],n=!1){return this.findInner(e,t,i,n)}static findFirst(e,t,i=[],n=!1){let r=this.findInner(e,t,i,n);if(r.length>0)return r[0]}static getFloorsFromString(e){let t=[],i=new RegExp(/(?:-?(?:\d+(?:\.5)?)F)(?=\W|$)/,"g").exec(e);return i&&i.length>0&&i.forEach((e=>{if(e){let i=e.replace("F",""),n=Number(i);n?t.push(n):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 i=[],n=e=>{this.getFloorsFromString(e).forEach((e=>{i[e]=!0}))};return t.forEach((t=>{let i=e.getObjectById(t);i&&i.traverse((e=>{if(n(e.name),e.userData.gltfExtensions){let t=e.userData.gltfExtensions;t.level&&t.level.Value&&n(t.level.Value)}}))})),Object.keys(i).sort()}static traverseObjectByFloors(e,t,i,n,r){let a=e.getObjectById(t);if(!a)return[];a.traverse((e=>{let t=this.matchFloors(e.name,i);if(!t&&e.userData&&e.userData.gltfExtensions){let n=e.userData.gltfExtensions;n.level&&n.level.Value&&(t=this.matchFloors(n.level.Value,i))}t&&n&&n(e),!t&&r&&r(e)}))}static setVisibleForFloors(e,t,i,n=!0){this.traverseObjectByFloors(e,t,i,(e=>{let t=e;for(;t;)t.visible=!0,t=t.parent||void 0}),(e=>{n&&(e.visible=!1)}))}static revertVisibleForFloors(e){e.traverse((e=>{e.visible=!0}))}static revertVisibleForFloorsById(e,t){let i=this.getObjectById(e,t);this.revertVisibleForFloors(i)}static getObjectById(e,t){let i=e.getObjectById(t);if(!i)throw new Error(`Failed to find object by id: ${t}`);return i}static createOutlines(e){return ft(this,arguments,(function*(e,t={onlyVisible:!0,meshOnly:!0},i){if(!e)return[];if(0===e.children.length&&(t.onlyVisible&&!e.visible||t.meshOnly&&!(e instanceof xt)))return[];let n=[],r=e,a=r.children.length,s=Math.round(Math.pow(a,.5)),o=St.getUpdateProgressFuncAsync(i);for(let l=a-1;l>=0;--l){let e,o=a-l-1;if(i&&(o%s==0||0===o||o===a-1)){let t=90*o/a,n=90*(o+1)/a;e=St.getUpdateSubProgressFunc(t,n,i)}let h=r.children[l],c=yield this.createOutlines(h,t,e);n.push(...c)}if(!r.geometry)return yield o(100),n;if(r instanceof xt&&!this.hasOutline(r,!1)){yield o(50);let e=this.createOutline(r.geometry);r.add(e),e.updateWorldMatrix(!0,!1),n.push(e)}return yield o(100),n}))}static removeOutlines(e){if(e&&Array.isArray(e.children))for(let t=e.children.length-1;t>=0;--t){let i=e.children[t];i.children.length>0&&this.removeOutlines(i),i.userData.isOutline&&e.remove(i)}}static hasOutline(e,t=!0){let i=!1;for(let n=0;n<e.children.length;++n){let r=e.children[n];if(r.userData.isOutline){i=!0;break}if(t&&r.children.length>0&&(i=this.hasOutline(r),i))break}return i}static setOutlinesVisibility(e,t){e.traverse((e=>{e.userData.isOutline&&(e.visible=t)}))}static createOutline(e,t=this.OUTLINE_MATERIAL,i){let n=new Au(e,10),r=new qr(n,t);return r.layers.enableAll(),Rc.disableLayerChannels(r,[12,11]),r.userData.isOutline=!0,r.matrixAutoUpdate=!1,i&&r.applyMatrix4(i),r}static cloneObject(e,t=!0){let i=e.clone();return t&&i.traverse((e=>{(e instanceof xt||e instanceof fr)&&(e.material=es.cloneMaterial(e.material))})),i}static createBox(e,t,i,n=Rc.BOX_FACE_MATERIAL,r=!0){let a=[],s=(e,t,i)=>{a.push(new D(e,t,i))};s(0,0,0),s(e,0,0),s(e,t,0),s(0,t,0),s(0,0,i),s(e,0,i),s(e,t,i),s(0,t,i);let o=new Dt;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 xt(o,n)}static rebaseObjectOnRTC(e){let t=e;if(!((t.isMesh||t.isLine||t.isPoints)&&t.geometry&&t.geometry instanceof Dt))return e;let i=t.geometry;if(!i.hasAttribute("position"))return e;let n=i.getAttribute("position");if(0===n.count)return e;let r=n.itemSize,a=n.array,s=[];for(let h=0;h<r;h++)s.push(a[h]);for(let h=0;h<n.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=Mlt;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 xt||e instanceof fr||e instanceof ii)&&!!e.geometry}static enableLayerChannels(e,t,i=!0){for(let n=0,r=t.length;n<r;n++)e.layers.enable(t[n]);if(i){let i=e.children;for(let e=0,n=i.length;e<n;e++)Rc.enableLayerChannels(i[e],t,!0)}}static disableLayerChannels(e,t,i=!0){for(let n=0,r=t.length;n<r;n++)e.layers.disable(t[n]);if(i){let i=e.children;for(let e=0,n=i.length;e<n;e++)Rc.disableLayerChannels(i[e],t,!0)}}static setLayerChannels(e,t,i=!0){e.layers.disableAll();for(let n=0,r=t.length;n<r;n++)e.layers.enable(t[n]);if(i){let i=e.children;for(let e=0,n=i.length;e<n;e++)Rc.setLayerChannels(i[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)}},Hn=Rc;Hn.OUTLINE_MATERIAL=new Gn({name:"outline",color:0,transparent:!0,opacity:.2}),Hn.BOX_FACE_MATERIAL=new ea({color:11648971,transparent:!0,opacity:.3,side:pi});var UA=new et,Rlt=new et,HA=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 i=Date.now();this.mergeInner(e,t),this.mergeInfo.elapsedTime+=Date.now()-i}static mergeInner(e,t=!0){if(!e.children||e.children.length<1)return;let i=e.children.length,n={},r=[];for(let h=0;h<i;++h){let i=e.children[h];if(i.children.length>0){this.mergeInner(i,t);continue}if(i.isInstancedMesh||!i.geometry||!(i.geometry instanceof Dt))continue;let a=!1,s=Object.values(n);for(let t=s.length-1;t>=0;--t){let i=s[t].indexes[0];if(a=this.tryHandleMergeableObjects(e,h,i,n,r),a)break}for(let t=r.length-1;!a&&t>=0;--t){let i=r[t];if(a=this.tryHandleMergeableObjects(e,h,i,n,r),a)break}a||r.push(h)}if(Object.keys(n).length<=0)return;let a=[],s=[],o=[],l=[];Object.values(n).forEach((i=>{let n,r=i.indexes,h=e.children[r[0]],c=[],u=0,d=0,p=0,f=[];if(r.forEach((i=>{var n,r,a;let s=e.children[i],o=s.geometry.clone();if(o.applyMatrix4(s.matrix),Qt.tryConvertInterleavedBufferAttributes(o),o.userData.isLineSegments=!0===s.isLineSegments,c.push(o),t){let e=s.name,t=null==(r=null==(n=o.attributes)?void 0:n.position)?void 0:r.count,i=(null==(a=o.index)?void 0:a.count)||0,l={batchId:u,name:e,positionStart:d,positionCount:t,indexStart:p,indexCount:i};0!==Object.keys(s.userData).length&&(l.userData=s.userData),f.push(l),d+=t,p+=i,u++}})),0!==c.length){if(h.isMesh){let e=Ui(c);if(!e)return;e.userData={},n=new xt(e,h.material),a.push(n)}else if(h.isLine){let e=this.mergeLineGeometries(c,t,h.material instanceof Iu||h.material instanceof cn,f);if(!e)return;n=new qr(e,h.material),s.push(n)}else if(h.isPoints){let e=Ui(c);if(!e)return;e.userData={},n=new ii(e,h.material),o.push(n)}n&&(t?n.userData.batches=f:(n.userData=h.userData,n.userData.batches=void 0),n.userData.layerName=h.userData.layerName,n.name=`[Merged] ${h.name}`,n.matrixAutoUpdate=!1,n.renderOrder=h.renderOrder,n.layers.mask=h.layers.mask,n.visible=h.visible,l.push(...r)),c.forEach((e=>{e.dispose(),Qt.releaseGeometryManually(e)})),c=[]}})),l.sort(((e,t)=>t-e)),l.forEach((t=>{let i=e.children[t];e.remove(i)})),[...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,i,n,r){let a=!1,s=Array.isArray(e),o=s?e.length:e.children.length;if(t===i||t>=o||i>=o)return a;let l=s?e[t]:e.children[t],h=s?e[i]:e.children[i];return this.areObjectsMergeable(l,h)&&this.areGeometriesMergeable(l.geometry,h.geometry)&&es.materialsEquals(l.material,h.material)&&(n[i]||(n[i]={indexes:[i]},this.removeFromArray(r,i)),n[i].indexes.push(t),a=!0),a}static deepMerge(e,t,i=!0,n=!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 Dt))continue;let i=!1,n=Object.values(o);for(let r=n.length-1;r>=0;--r){let t=n[r].indexes[0];if(i=this.tryHandleMergeableObjects(e,m,t,o,l),i)break}for(let r=l.length-1;!i&&r>=0;--r){let t=l[r];if(i=this.tryHandleMergeableObjects(e,m,t,o,l),i)break}i||l.push(m)}if(Object.keys(o).length<=0)return a;se.debug(`[Merge] Built merged indexes for ${e.length} objects in ${(Date.now()-s)/1e3}s`),s=Date.now();let h=[],c=[],u=[],d=[];Object.values(o).forEach((i=>{let n=i.indexes;if(n.length<2)return;let a,s=e[n[0]],o=[],l=0,p=0,f=0,m=[];if(n.forEach((i=>{var n,a,h;let c=e[i],u=c.geometry.clone();if(s.material instanceof Gn&&u.deleteAttribute("lineDistance"),this.applyMatrix(u,c,t),u.userData.isLineSegments=!0===c.isLineSegments,o.push(u),r){let e,t=c.name,i=null==(a=null==(n=u.attributes)?void 0:n.position)?void 0:a.count,r=(null==(h=u.index)?void 0:h.count)||0;s.isLine&&(u.boundingSphere||u.computeBoundingSphere(),e=u.boundingSphere.clone());let o={batchId:l,name:t,positionStart:p,positionCount:i,indexStart:f,indexCount:r,boundingSphere:e};0!==Object.keys(c.userData).length&&(o.userData=c.userData),m.push(o),p+=i,f+=r,l++}})),0!==o.length){if(s.isMesh){let e=Ui(o);if(!e)return;e.userData={},a=new xt(e,s.material),h.push(a)}else if(s.isLine){let e=this.mergeLineGeometries(o,r,s.material instanceof Iu||s.material instanceof cn,m);if(!e)return;a=new qr(e,s.material),c.push(a)}else if(s.isPoints){let e=Ui(o);if(!e)return;e.userData={},a=new ii(e,s.material),u.push(a)}a&&(r?a.userData.batches=m:(a.userData=s.userData,a.userData.batches=void 0),a.userData.layerName=s.userData.layerName,a.name=`[Merged] ${s.name}`,a.matrixAutoUpdate=!1,a.renderOrder=s.renderOrder,a.layers.mask=s.layers.mask,a.visible=s.visible,n.forEach((e=>d.push(e)))),o.forEach((e=>{e.dispose(),Qt.releaseGeometryManually(e)})),o=[]}})),se.debug(`[Merge] Ran deepMerge() in ${(Date.now()-s)/1e3}s`);let p=a.removed;d.forEach((t=>{let n=e[t];p.push(n),i&&n.removeFromParent()}));let f=a.added;return[...h,...c,...u].forEach((e=>{f.push(e),i&&t&&(t.add(e),e.updateWorldMatrix(!1,!1))})),this.mergeInfo.removedObjects+=d.length,this.mergeInfo.mergedMeshes+=h.length,this.mergeInfo.mergedLines+=c.length,this.mergeInfo.mergedPoints+=u.length,n&&t&&Hn.removeEmptyObjects(t),a}static applyMatrix(e,t,i){let n=t;for(UA.identity();n&&n!==i&&(UA.premultiply(n.matrix),n.parent);)n=n.parent;return UA.equals(Rlt)?e:e.applyMatrix4(UA)}static mergeLineGeometries(e,t,i,n){let r;if(i)r=HA.mergeBufferGeometriesWithLinesToLineSegments(e,t,n);else{if(r=Ui(e),!r)return;r.userData={};let i=[],a=0;e.forEach(((e,r)=>{let s=e.attributes.position;if(!s)return;let o=e.index,l=!0===e.userData.isLineSegments,h=i.length;if(o)for(let t=0;t<o.count;t++){let e=o.array[t];l?i.push(a+e):t>0&&i.push(a+o.array[t-1],a+e)}else for(let t=0;t<s.count;t++)t>0&&(l?t%2==1&&i.push(a+t-1,a+t):i.push(a+t-1,a+t));a+=s.count,t&&n&&(n[r].indexStart=h,n[r].indexCount=i.length-h)})),r.setIndex(i)}return r}static mergeBufferGeometriesWithLinesToLineSegments(e,t,i){let n=new Set(Object.keys(e[0].attributes)),r={},a=new Dt,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&&(se.debug(`[Merge] Geometry '${l}' contains index buffer, going to convert it to non-indexed.`),a=Qt.convertGeometryWithIndexedToNonIndexed(a));let c=0;for(let e in a.attributes){if(!n.has(e))return void se.error(`[Merge] mergeGeometries() failed with geometry at index ${l}. All geometries must have compatible attributes; make sure ${e} attribute exists among all geometries, or in none of them`);r[e]||(r[e]=[]),r[e].push(a.attributes[e]),c++}if(c!==n.size)return void se.error(`[Merge] mergeGeometries() failed with geometry at index ${l}. Make sure all geometries have the same number of attributes.`);if(t&&i){let e=a.attributes.position;i[l].indexStart=0,i[l].indexCount=0;let t=h?e.count:2*e.count-2;i[l].positionStart=o,i[l].positionCount=t,o+=t}}for(let l in r){let e=HA.mergeBufferAttributesWithLinesToLineSegments(r[l],s);if(!e)return void se.error(`[Merge] mergeGeometries() failed while trying to merge the ${l} attribute.`);a.setAttribute(l,e)}return a}static mergeBufferAttributesWithLinesToLineSegments(e,t){let i,n,r,a=0;for(let l=0;l<e.length;++l){let s=e[l];if(void 0===i&&(i=s.array.constructor),i!==s.array.constructor)return void se.error("[Merge] mergeBufferAttributes() failed. THREE.BufferAttribute.array must be of consistent array types across matching attributes.");if(void 0===n&&(n=s.itemSize),n!==s.itemSize)return void se.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 se.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)*n}let s=new i(a),o=0;for(let l=0;l<e.length;++l){let n=t[l],r=e[l],a=n?0:r.count-2,h=r.count+a,c=r.itemSize,u=new i(h*c),d=0;for(let e=0;e<r.count;e++){let t=e*c,i=0!==e&&e!==r.count-1&&!n;for(let e=0;e<c;e++)u[d+e]=r.array[t+e],i&&(u[d+c+e]=r.array[t+e]);d+=i?2*c:c}s.set(u,o),o+=h*c}return new mn(s,n,r)}static removeFromArray(e,t){for(let i=e.length-1;i>=0;--i)if(e[i]===t)return void e.splice(i,1)}static removeObjectFromArray(e,t){for(let i=e.length-1;i>=0;--i)if(e[i]===t)return void e.splice(i,1)}static areGeometriesMergeable(e,t){if(!e||!t||"InstancedBufferGeometry"===e.type||"InstancedBufferGeometry"===t.type||!!e.index!=!!t.index)return!1;let i=Object.keys(e.attributes);if(i.length!==Object.keys(t.attributes).length)return!1;for(let n of i)if(!t.attributes[n])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 i=e,n=t;return i.isMesh&&n.isMesh||i.isLine&&n.isLine||i.isPoints&&n.isPoints}static isMergedMesh(e){return!(!e||!e.userData.batches)}static isFaceIndexInBatch(e,t,i){if(e.boundsTree){let n=e.index.getX(3*i);if(n>=t.positionStart&&n<t.positionStart+t.positionCount)return!0}else if(e.index){let e=t.indexStart/3,n=(t.indexStart+t.indexCount)/3-1;if(i>=e&&i<=n)return!0}else{let e=3*i;if(e>=t.positionStart&&e<t.positionStart+t.positionCount)return!0}return!1}static getBatchByFaceIndex(e,t){if(t<0)return void se.error(`[Merge]: Invalid faceIndex: ${t}`);let i=e&&e.geometry&&e.userData.batches;if(i)for(let n=0;n<i.length;++n){let r=i[n];if(this.isFaceIndexInBatch(e.geometry,r,t))return r}}static getBatchByLineIndex(e,t){if(t<0)return void se.error(`[Merge]: Invalid index: ${t}`);let i=e&&e.geometry&&e.userData.batches;if(!i)return;let n=e.geometry.index;for(let r=0;r<i.length;++r){let e=i[r];if(n){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 i=this.getBatchByFaceIndex(e,t);return i?i.batchId:-1}static getBatchByBatchId(e,t){let i=e&&e.geometry&&e.userData.batches;if(i)for(let n=0;n<i.length;++n){let e=i[n];if(e.batchId===t)return e}}static cloneGeometryForBatch(e,t){var i;let n=e&&e.geometry;if(!n)return;let r=n.attributes.position,a=null==r?void 0:r.array,s=null==(i=n.index)?void 0:i.array;if(!a||!s)return void se.warn(`[Merge]: Unexpected position: ${a}, or index: ${s}!`);let o=new Dt,l=t.positionStart,h=t.positionStart+t.positionCount,c=n.attributes;for(let m in c){let e=c[m],t=e.itemSize,i=e.array.slice(l*t,h*t);o.setAttribute(m,new mn(i,t,e.normalized))}if(n.boundsTree&&(s=n.userData.originalIndex,!s))return void se.warn("[Merge] After building bvh, the original index data is not preserved !");let u=t.indexStart,d=t.indexStart+t.indexCount,p=[],f=0;for(let m=u;m<d&&m<s.length;++m)p[f++]=s[m]-t.positionStart;return o.setIndex(p),n.boundingBox&&o.computeBoundingBox(),n.boundingSphere&&o.computeBoundingSphere(),o}},Rr=HA;Rr.mergeInfo={removedObjects:0,mergedMeshes:0,mergedLines:0,mergedPoints:0,mergedUnknownTypeObjects:0,elapsedTime:0};var _fe=Xi(gfe(),1),yfe={triangulate:function(e,t,i=2){let n,r,a,s,o,l,h,c=t&&t.length,u=c?t[0]*i:e.length,d=xfe(e,0,u,i,!0),p=[];if(!d||d.next===d.prev)return p;if(c&&(d=lct(e,t,d,i)),e.length>80*i){n=a=e[0],r=s=e[1];for(let t=i;t<u;t+=i)o=e[t],l=e[t+1],o<n&&(n=o),l<r&&(r=l),o>a&&(a=o),l>s&&(s=l);h=Math.max(a-n,s-r),h=0!==h?32767/h:0}return sE(d,p,i,n,r,h,0),p}};function xfe(e,t,i,n,r){let a,s;if(r===xct(e,t,i,n)>0)for(a=t;a<i;a+=n)s=vfe(a,e[a],e[a+1],s);else for(a=i-n;a>=t;a-=n)s=vfe(a,e[a],e[a+1],s);return s&&$A(s,s.next)&&(oE(s),s=s.next),s}function Bm(e,t){if(!e)return e;t||(t=e);let i,n=e;do{if(i=!1,n.steiner||!$A(n,n.next)&&0!==ts(n.prev,n,n.next))n=n.next;else{if(oE(n),n=t=n.prev,n===n.next)break;i=!0}}while(i||n!==t);return t}function sE(e,t,i,n,r,a,s){if(!e)return;!s&&a&&fct(e,n,r,a);let o,l,h=e;for(;e.prev!==e.next;)if(o=e.prev,l=e.next,a?sct(e,n,r,a):ict(e))t.push(o.i/i|0),t.push(e.i/i|0),t.push(l.i/i|0),oE(e),e=l.next,h=l.next;else if((e=l)===h){s?1===s?sE(e=act(Bm(e),t,i),t,i,n,r,a,2):2===s&&oct(e,t,i,n,r,a):sE(Bm(e),t,i,n,r,a,1);break}}function ict(e){let t=e.prev,i=e,n=e.next;if(ts(t,i,n)>=0)return!1;let r=t.x,a=i.x,s=n.x,o=t.y,l=i.y,h=n.y,c=r<a?r<s?r:s:a<s?a:s,u=o<l?o<h?o:h:l<h?l:h,d=r>a?r>s?r:s:a>s?a:s,p=o>l?o>h?o:h:l>h?l:h,f=n.next;for(;f!==t;){if(f.x>=c&&f.x<=d&&f.y>=u&&f.y<=p&&Kv(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 sct(e,t,i,n){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,c=r.y,u=a.y,d=s.y,p=o<l?o<h?o:h:l<h?l:h,f=c<u?c<d?c:d:u<d?u:d,m=o>l?o>h?o:h:l>h?l:h,g=c>u?c>d?c:d:u>d?u:d,v=KH(p,f,t,i,n),y=KH(m,g,t,i,n),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&&Kv(o,c,l,u,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&&Kv(o,c,l,u,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&&Kv(o,c,l,u,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&&Kv(o,c,l,u,h,d,b.x,b.y)&&ts(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function act(e,t,i){let n=e;do{let r=n.prev,a=n.next.next;!$A(r,a)&&bfe(r,n,n.next,a)&&aE(r,a)&&aE(a,r)&&(t.push(r.i/i|0),t.push(n.i/i|0),t.push(a.i/i|0),oE(n),oE(n.next),n=e=a),n=n.next}while(n!==e);return Bm(n)}function oct(e,t,i,n,r,a){let s=e;do{let e=s.next.next;for(;e!==s.prev;){if(s.i!==e.i&&gct(s,e)){let o=Efe(s,e);return s=Bm(s,s.next),o=Bm(o,o.next),sE(s,t,i,n,r,a,0),void sE(o,t,i,n,r,a,0)}e=e.next}s=s.next}while(s!==e)}function lct(e,t,i,n){let r,a,s,o,l,h=[];for(r=0,a=t.length;r<a;r++)s=t[r]*n,o=r<a-1?t[r+1]*n:e.length,l=xfe(e,s,o,n,!1),l===l.next&&(l.steiner=!0),h.push(mct(l));for(h.sort(cct),r=0;r<h.length;r++)i=uct(h[r],i);return i}function cct(e,t){return e.x-t.x}function uct(e,t){let i=hct(e,t);if(!i)return t;let n=Efe(i,e);return Bm(n,n.next),Bm(i,i.next)}function hct(e,t){let i,n=t,r=-1/0,a=e.x,s=e.y;do{if(s<=n.y&&s>=n.next.y&&n.next.y!==n.y){let e=n.x+(s-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(e<=a&&e>r&&(r=e,i=n.x<n.next.x?n:n.next,e===a))return i}n=n.next}while(n!==t);if(!i)return null;let o,l=i,h=i.x,c=i.y,u=1/0;n=i;do{a>=n.x&&n.x>=h&&a!==n.x&&Kv(s<c?a:r,s,h,c,s<c?r:a,s,n.x,n.y)&&(o=Math.abs(s-n.y)/(a-n.x),aE(n,e)&&(o<u||o===u&&(n.x>i.x||n.x===i.x&&dct(i,n)))&&(i=n,u=o)),n=n.next}while(n!==l);return i}function dct(e,t){return ts(e.prev,e,t.prev)<0&&ts(t.next,e,e.next)<0}function fct(e,t,i,n){let r=e;do{0===r.z&&(r.z=KH(r.x,r.y,t,i,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==e);r.prevZ.nextZ=null,r.prevZ=null,pct(r)}function pct(e){let t,i,n,r,a,s,o,l,h=1;do{for(i=e,e=null,a=null,s=0;i;){for(s++,n=i,o=0,t=0;t<h&&(o++,n=n.nextZ,n);t++);for(l=h;o>0||l>0&&n;)0!==o&&(0===l||!n||i.z<=n.z)?(r=i,i=i.nextZ,o--):(r=n,n=n.nextZ,l--),a?a.nextZ=r:e=r,r.prevZ=a,a=r;i=n}a.nextZ=null,h*=2}while(s>1);return e}function KH(e,t,i,n,r){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-i)*r|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-n)*r|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function mct(e){let t=e,i=e;do{(t.x<i.x||t.x===i.x&&t.y<i.y)&&(i=t),t=t.next}while(t!==e);return i}function Kv(e,t,i,n,r,a,s,o){return(r-s)*(t-o)>=(e-s)*(a-o)&&(e-s)*(n-o)>=(i-s)*(t-o)&&(i-s)*(a-o)>=(r-s)*(n-o)}function gct(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!vct(e,t)&&(aE(e,t)&&aE(t,e)&&yct(e,t)&&(ts(e.prev,e,t.prev)||ts(e,t.prev,t))||$A(e,t)&&ts(e.prev,e,e.next)>0&&ts(t.prev,t,t.next)>0)}function ts(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function $A(e,t){return e.x===t.x&&e.y===t.y}function bfe(e,t,i,n){let r=YA(ts(e,t,i)),a=YA(ts(e,t,n)),s=YA(ts(i,n,e)),o=YA(ts(i,n,t));return!!(r!==a&&s!==o||0===r&&XA(e,i,t)||0===a&&XA(e,n,t)||0===s&&XA(i,e,n)||0===o&&XA(i,t,n))}function XA(e,t,i){return t.x<=Math.max(e.x,i.x)&&t.x>=Math.min(e.x,i.x)&&t.y<=Math.max(e.y,i.y)&&t.y>=Math.min(e.y,i.y)}function YA(e){return e>0?1:e<0?-1:0}function vct(e,t){let i=e;do{if(i.i!==e.i&&i.next.i!==e.i&&i.i!==t.i&&i.next.i!==t.i&&bfe(i,i.next,e,t))return!0;i=i.next}while(i!==e);return!1}function aE(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 yct(e,t){let i=e,n=!1,r=(e.x+t.x)/2,a=(e.y+t.y)/2;do{i.y>a!=i.next.y>a&&i.next.y!==i.y&&r<(i.next.x-i.x)*(a-i.y)/(i.next.y-i.y)+i.x&&(n=!n),i=i.next}while(i!==e);return n}function Efe(e,t){let i=new JH(e.i,e.x,e.y),n=new JH(t.i,t.x,t.y),r=e.next,a=t.prev;return e.next=t,t.prev=e,i.next=r,r.prev=i,n.next=i,i.prev=n,a.next=n,n.prev=a,n}function vfe(e,t,i,n){let r=new JH(e,t,i);return n?(r.next=n.next,r.prev=n,n.next.prev=r,n.next=r):(r.prev=r,r.next=r),r}function oE(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 JH(e,t,i){this.i=e,this.x=t,this.y=i,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function xct(e,t,i,n){let r=0;for(let a=t,s=i-n;a<i;a+=n)r+=(e[s]-e[a])*(e[a+1]+e[s+1]),s=a;return r}var bct=.01,Um=class{static getFaces(e){let t=e.map((e=>e.toArray())).reduce(((e,t)=>(e.push(...t),e)),[]),i=[];return yfe.triangulate(t,[],3).forEach((e=>i.push(e))),i}static arePointsCoplanar(e){if(e.length<4)return!0;let t=e[1].clone().sub(e[0]),i=e[2].clone().sub(e[0]).cross(t).normalize();for(let n=3;n<e.length;n++)if(e[n].clone().sub(e[0]).projectOnVector(i).length()>bct)return!1;return!0}static isSelfIntersecting(e){let t=e.map((e=>e.toArray().slice(0,-1)));return(0,_fe.default)(t).length>0}},Os=class{static getVisibleObjectBoundingBox(e){let t=new Nt;return e.traverse((e=>{e.visible&&(e instanceof xt||e instanceof fr)&&Hn.isObjectSelectable(e)&&t.expandByObject(e)})),t}static getObjectsBoundingBox(e,t,i){let n=new Nt;return t.forEach((t=>{let r=e.getObjectById(t);if(r){let e=Os.getBoundingBox(r,i);e.isEmpty()||n.union(e)}})),n}static getBoundingBox(e,t=!0){let i=new Nt;if(e instanceof Oi)return Os.getInstancedMeshBoundingBox(e);if(0===e.children.length)return i.expandByObject(e),i;let n=e.children.length,r=1;n>20&&(r=3),n>100&&(r=5),n>200&&(r=10),n>1e3&&(r=100),e.updateMatrixWorld(!1);for(let a=0;a<n;++a){let n=e.children[a];if(!t||a%r==0)if(n.updateMatrix(),n instanceof Oi){let e=Os.getInstancedMeshBoundingBox(n);e.isEmpty()||i.union(e)}else if(St.isMatrixValid(n.matrixWorld)){let e=Os.getBoundingBox(n);e.isEmpty()||i.union(e)}else console.warn(`[SceneUtils] Found object(${n.type}) with invalid matrix: ${n.matrixWorld.elements}`)}return e.geometry&&i.expandByObject(e),i}static getInstancedMeshBoundingBox(e){let t=new Nt,i=new et;for(let n=0;n<e.count;++n){e.getMatrixAt(n,i);let r=e.geometry.clone();if(r.boundingBox){let e=r.boundingBox.applyMatrix4(i);!e.isEmpty()&&St.isBoxValid(e)&&t.union(e)}}return t.applyMatrix4(e.matrixWorld),t}static getObjectCenter(e,t){let i=Os.getBoundingBox(e);i.getCenter(t),t.y=i.min.y}},Hu=class{static setMaterialSection(e,t,i=!1,n=!1){let r=i&&e.clippingPlanes?e.clippingPlanes:[];r.push(...t),e.clippingPlanes=r,e.clipIntersection=n}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,i=!1,n=!1){e&&e.traverse((e=>{let r=e.material;Array.isArray(r)?r.forEach((e=>{Hu.setMaterialSection(e,t,i,n)})):r&&Hu.setMaterialSection(r,t,i,n)}))}static generateSectionPlanesByBox(e){let t=e.min,i=e.max;return[new zr(new D(0,-1,0),i.y),new zr(new D(0,1,0),-t.y),new zr(new D(1,0,0),-t.x),new zr(new D(-1,0,0),i.x)]}static generateSectionPlanesByPoints(e,t=!0){let i=e.length;if(i<2)return;let n=[];for(let r=0;r<i-1;r++){let a=e[r],s=e[(r+1)%i],o=new zr;o.setFromCoplanarPoints(new D(a.x,a.y,-1),new D(a.x,a.y,0),new D(s.x,s.y,0)),t||o.negate(),n.push(o)}return n}},QH=new D,Tfe=new D,ZA=class{modify(e,t){let i=(e=e.clone()).attributes;for(let u in i)"position"!==u&&e.deleteAttribute(u);let n=[],r=[],a=(e=Zde(e)).getAttribute("position");for(let u=0;u<a.count;u++){let e=(new D).fromBufferAttribute(a,u),t=new e5(e);n.push(t)}let s=e.getIndex();if(null!==s)for(let u=0;u<s.count;u+=3){let e=s.getX(u),t=s.getX(u+1),i=s.getX(u+2),a=new KA(n[e],n[t],n[i],e,t,i);r.push(a)}else for(let u=0;u<a.count;u+=3){let e=u,t=u+1,i=u+2,a=new KA(n[e],n[t],n[i],e,t,i);r.push(a)}for(let u=0,d=n.length;u<d;u++)Sfe(n[u]);let o,l=t;for(;l--;){if(o=Sct(n),!o){console.log("THREE.SimplifyModifier: No next vertex");break}wct(n,r,o,o.collapseNeighbor)}let h=new Dt,c=[];s=[];for(let u=0;u<n.length;u++){let e=n[u].position;c.push(e.x,e.y,e.z),n[u].id=u}for(let u=0;u<r.length;u++){let e=r[u];s.push(e.v1.id,e.v2.id,e.v3.id)}return h.setAttribute("position",new Bt(c,3)),h.setIndex(s),h}};function Ect(e,t){-1===e.indexOf(t)&&e.push(t)}function Hm(e,t){let i=e.indexOf(t);i>-1&&e.splice(i,1)}function _ct(e,t){let i=t.position.distanceTo(e.position),n=0,r=[];for(let a=0,s=e.faces.length;a<s;a++){let i=e.faces[a];i.hasVertex(t)&&r.push(i)}for(let a=0,s=e.faces.length;a<s;a++){let t=1,i=e.faces[a];for(let e=0;e<r.length;e++){let n=r[e],a=i.normal.dot(n.normal);t=Math.min(t,(1.001-a)/2)}n=Math.max(n,t)}return r.length<2&&(n=1),i*n+0}function Sfe(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 i=_ct(e,e.neighbors[t]);e.collapseNeighbor||(e.collapseNeighbor=e.neighbors[t],e.collapseCost=i,e.minCost=i,e.totalCost=0,e.costCount=0),e.costCount++,e.totalCost+=i,i<e.minCost&&(e.collapseNeighbor=e.neighbors[t],e.minCost=i)}e.collapseCost=e.totalCost/e.costCount}function wfe(e,t){for(console.assert(0===e.faces.length);e.neighbors.length;)Hm(e.neighbors.pop().neighbors,e);Hm(t,e)}function Tct(e,t){Hm(t,e),e.v1&&Hm(e.v1.faces,e),e.v2&&Hm(e.v2.faces,e),e.v3&&Hm(e.v3.faces,e);let i=[e.v1,e.v2,e.v3];for(let n=0;n<3;n++){let e=i[n],t=i[(n+1)%3];!e||!t||(e.removeIfNonNeighbor(t),t.removeIfNonNeighbor(e))}}function wct(e,t,i,n){if(!n)return void wfe(i,e);let r=[];for(let a=0;a<i.neighbors.length;a++)r.push(i.neighbors[a]);for(let a=i.faces.length-1;a>=0;a--)i.faces[a]&&i.faces[a].hasVertex(n)&&Tct(i.faces[a],t);for(let a=i.faces.length-1;a>=0;a--)i.faces[a].replaceVertex(i,n);wfe(i,e);for(let a=0;a<r.length;a++)Sfe(r[a])}function Sct(e){let t=e[0];for(let i=0;i<e.length;i++)e[i].collapseCost<t.collapseCost&&(t=e[i]);return t}var KA=class{constructor(e,t,i,n,r,a){this.a=n,this.b=r,this.c=a,this.v1=e,this.v2=t,this.v3=i,this.normal=new D,this.computeNormal(),e.faces.push(this),e.addUniqueNeighbor(t),e.addUniqueNeighbor(i),t.faces.push(this),t.addUniqueNeighbor(e),t.addUniqueNeighbor(i),i.faces.push(this),i.addUniqueNeighbor(e),i.addUniqueNeighbor(t)}computeNormal(){let e=this.v1.position,t=this.v2.position,i=this.v3.position;QH.subVectors(i,t),Tfe.subVectors(e,t),QH.cross(Tfe).normalize(),this.normal.copy(QH)}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),Hm(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()}},e5=class{constructor(e){this.position=e,this.id=-1,this.faces=[],this.neighbors=[],this.collapseCost=0,this.collapseNeighbor=null}addUniqueNeighbor(e){Ect(this.neighbors,e)}removeIfNonNeighbor(e){let t=this.neighbors,i=this.faces,n=t.indexOf(e);if(-1!==n){for(let t=0;t<i.length;t++)if(i[t].hasVertex(e))return;t.splice(n,1)}}},Mfe=class{static simplifyGeometry(e,t){let i=this.getNumberOfVerticesToRemove(e,t);return i>0?(new ZA).modify(e,i):e}static getNumberOfVerticesToRemove(e,t){let i=0;e instanceof Dt&&e.index&&(i=e.attributes.position.count);let n=Math.floor(i*t);return i<20?0:n}},JA=class extends on{constructor(e){super(),this.isSVGObject=!0,this.node=e}},SLt=10,Afe=(e=>(e.TripleCross="TripleCross",e.Square="Square",e.Triangle="Triangle",e.CircleWithCross="CircleWithCross",e.Cross="Cross",e.Perpendicular="Perpendicular",e))(Afe||{}),Rfe=class{static createSVGObject(e){return new JA(e)}},QA=class extends Rm{constructor(e){super(e),this.type=Mr}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},i=function(e,t,i){t=t||1024;let n=e.pos,r=-1,a=0,s="",o=String.fromCharCode.apply(null,new Uint16Array(e.subarray(n,n+128)));for(;0>(r=o.indexOf("\n"))&&a<t&&n<e.byteLength;)s+=o,a+=o.length,n+=128,o+=String.fromCharCode.apply(null,new Uint16Array(e.subarray(n,n+128)));return-1<r&&(!1!==i&&(e.pos+=a+r+1),s+o.slice(0,r))},n=function(e,t,i,n){let r=e[t+3],a=Math.pow(2,r-128)/255;i[n+0]=e[t+0]*a,i[n+1]=e[t+1]*a,i[n+2]=e[t+2]*a,i[n+3]=1},r=function(e,t,i,n){let r=e[t+3],a=Math.pow(2,r-128)/255;i[n+0]=Pv.toHalfFloat(Math.min(e[t+0]*a,65504)),i[n+1]=Pv.toHalfFloat(Math.min(e[t+1]*a,65504)),i[n+2]=Pv.toHalfFloat(Math.min(e[t+2]*a,65504)),i[n+3]=Pv.toHalfFloat(1)},a=new Uint8Array(e);a.pos=0;let s=function(e){let n,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||!(n=i(e)))return t(1,"no header found");if(!(r=n.match(/^#\?(\S+)/)))return t(3,"bad initial token");for(h.valid|=1,h.programtype=r[1],h.string+=n+"\n";n=i(e),!1!==n;)if(h.string+=n+"\n","#"!==n.charAt(0)){if((r=n.match(a))&&(h.gamma=parseFloat(r[1])),(r=n.match(s))&&(h.exposure=parseFloat(r[1])),(r=n.match(o))&&(h.valid|=2,h.format=r[1]),(r=n.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+=n+"\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,i=s.height,o=function(e,i,n){let r=i;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*i*n);if(!a.length)return t(4,"unable to allocate buffer space");let s=0,o=0,l=4*r,h=new Uint8Array(4),c=new Uint8Array(l),u=n;for(;u>0&&o<e.byteLength;){if(o+4>e.byteLength)return t(1);if(h[0]=e[o++],h[1]=e[o++],h[2]=e[o++],h[3]=e[o++],2!=h[0]||2!=h[1]||(h[2]<<8|h[3])!=r)return t(3,"bad rgbe scanline format");let i,n=0;for(;n<l&&o<e.byteLength;){i=e[o++];let r=i>128;if(r&&(i-=128),0===i||n+i>l)return t(3,"bad scanline data");if(r){let t=e[o++];for(let e=0;e<i;e++)c[n++]=t}else c.set(e.subarray(o,o+i),n),n+=i,o+=i}let d=r;for(let e=0;e<d;e++){let t=0;a[s]=c[e+t],t+=r,a[s+1]=c[e+t],t+=r,a[s+2]=c[e+t],t+=r,a[s+3]=c[e+t],s+=4}u--}return a}(a.subarray(a.pos),e,i);if(-1!==o){let t,a,l;switch(this.type){case fa:l=o.length/4;let e=new Float32Array(4*l);for(let t=0;t<l;t++)n(o,4*t,e,4*t);t=e,a=fa;break;case Mr:l=o.length/4;let i=new Uint16Array(4*l);for(let t=0;t<l;t++)r(o,4*t,i,4*t);t=i,a=Mr;break;default:console.error("THREE.RGBELoader: unsupported type: ",this.type)}return{width:e,height:i,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,i,n){return super.load(e,(function(e,i){switch(e.type){case fa:case Mr:e.colorSpace=Na,e.minFilter=Pr,e.magFilter=Pr,e.generateMipmaps=!1,e.flipY=!0}t&&t(e,i)}),i,n)}},Ac=class{static createEnvTexture(e,t){return ft(this,null,(function*(){let i=new QA;return new Promise((n=>{i.load(t,(t=>{if(e){let i=e.fromEquirectangular(t).texture;e.dispose(),n(i)}}))}))}))}static createEnvTextureFromDataArray(e){return ft(this,arguments,(function*(e,t=this.HDR_CITY_STREET_64x32,i=64,n=32){if(e){let r=new wl(t,i,n);r.flipY=!0,r.magFilter=Pr,r.minFilter=Pr,r.type=Mr,r.version=1;let a=e.fromEquirectangular(r).texture;return e.dispose(),Promise.resolve(a)}return Promise.reject("Invalid pmremGenerator!")}))}};function Mct(){if(Fn.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}Ac.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 Cfe={file:1,m:1,mm:.001,cm:.01,ft:.3048,in:.0254,pt:Mct()},Rct={file:"m",m:"m",mm:"mm",cm:"cm",ft:"ft",in:"in",pt:"pt"},Pfe=e=>2===e?"\xb2":3===e?"\xb3":"",lE=(e,t=1)=>Rct[e]+Pfe(t),DLt=(e,t,i,n=1)=>(null==i&&(i=t),i===t?{value:e,unit:lE(i)}:{value:e*Math.pow(Cfe[t]/Cfe[i],n),unit:lE(i)+Pfe(n)}),t5=(e=>(e.Top="Top",e.Bottom="Bottom",e.Front="Front",e.Back="Back",e.Left="Left",e.Right="Right",e))(t5||{}),cE=class{static getCameraPositionByBBoxAndDirection(e,t,i,n,r){if(e.isEmpty()||!n)return;let a=new D,s=new D,o=new D(0,1,0);e.getSize(s),e.getCenter(a);let l,h,c=(s.x+s.y+s.z)/3*1.5;if(!r||null!=r&&r.equals(new D))l=new D(a.x+c,a.y+c/1.5,a.z+c),h=l.clone().sub(a);else{let e=new D(c,c/1.5,c).length();h=new D(-r.x,-r.y,-r.z).normalize().multiplyScalar(e),l=h.clone().add(a)}c=h.length(),h=h.normalize();let u=new et;u.lookAt(l,a,o);let d=new et;d.makeTranslation(-l.x,-l.y,-l.z);let p=e.clone().applyMatrix4(d).applyMatrix4(u.invert()).applyMatrix4(n),f=Math.max(Math.abs(p.max.x),Math.abs(p.min.x)),m=Math.max(Math.abs(p.max.y),Math.abs(p.min.y));c*=1.1*Math.sqrt(Math.pow(f,2)+Math.pow(m,2)),l=h.multiplyScalar(c).add(a),i.set(a.x,a.y,a.z),t.set(l.x,l.y,l.z)}static getCameraDirectionByView(e){let t=new D(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}},Act=!1,Hi=class extends Ss{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 et,this.id=e||St.guid()}setTolerance(e){this.tolerance=e}render(e,t){this.ctx=e,this.draw(e,t),this.selected&&this.drawSelect(e,t),Act&&(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 D(this.x,this.y,0),new D(this.x+this.width,this.y,0),new D(this.x+this.width,this.y-this.height,0),new D(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 D)}transToScreenCoord(e,t){return this.ctx?an.world2Screen(e,t,this.ctx.canvas):new xe}drawBounds(e,t){let{min:i,max:n}=this.getBounds(),r=[],a=(e,t,i)=>r.push(new D(e,t,i));a(n.x,n.y,n.z),a(i.x,n.y,n.z),a(i.x,i.y,n.z),a(n.x,i.y,n.z),a(n.x,n.y,i.z),a(i.x,n.y,i.z),a(i.x,i.y,i.z),a(n.x,i.y,i.z),a(i.x,n.y,n.z),a(i.x,i.y,n.z),a(n.x,n.y,n.z),a(n.x,i.y,n.z),a(n.x,n.y,i.z),a(n.x,i.y,i.z),a(i.x,n.y,i.z),a(i.x,i.y,i.z),a(i.x,n.y,n.z),a(i.x,n.y,i.z),a(n.x,n.y,n.z),a(n.x,n.y,i.z),a(i.x,i.y,n.z),a(i.x,i.y,i.z),a(n.x,i.y,n.z),a(n.x,i.y,i.z),e.save(),e.strokeStyle="yellow",e.beginPath(),r.forEach(((i,n)=>{let r=this.transToScreenCoord(i,t);n%2==0?e.moveTo(r.x,r.y):e.lineTo(r.x,r.y)})),e.closePath(),e.stroke(),e.restore()}drawCenter(e,t){let i=this.transToScreenCoord(this.getCenter(),t);e.save(),e.fillStyle="yellow",e.beginPath(),e.arc(i.x,i.y,5,0,2*Math.PI),e.closePath(),e.fill(),e.restore()}getBounds(){let e=this.getVertexes();return(new Nt).setFromPoints(e)}},ki=(e=>(e.MouseClicked="MouseClicked",e.LayoutChanged="LayoutChanged",e.ModelLoaded="ModelLoaded",e.BeforeRender="BeforeRender",e.AfterRender="AfterRender",e.OnAnimate="OnAnimate",e.CameraChanged="CameraChanged",e.BoxSelectActivated="BoxSelectActivated",e.BoxSelectDeactivated="BoxSelectDeactivated",e.PickMarkupActivated="PickMarkupActivated",e.PickMarkupDeactivated="PickMarkupDeactivated",e.MarkupActivated="MarkupActivated",e.MarkupDeactivated="MarkupDeactivated",e.MarkupAdded="MarkupAdded",e.MarkupUpdated="MarkupUpdated",e.MarkupRemoved="MarkupRemoved",e.BeforeRemoveMarkup="BeforeRemoveMarkup",e.MeasurementActivated="MeasurementActivated",e.MeasurementDeactivated="MeasurementDeactivated",e.MeasurementAdded="MeasurementAdded",e.MeasurementRemoved="MeasurementRemoved",e))(ki||{}),Ife={},Un=class extends Ss{constructor(e){super(),this.drawableLists=[],this.frustum=new ma,this.projScreenMatrix=new et,this.viewer=e,this.init()}static _registerDrawableClass(e){Ife[e.prototype.getClassType()]=e}static createDrawable(e){let t=Ife[e.type];if(!t)throw new Error(`Invalid drawable type: ${t}`);let i=e.points.map((e=>new D(e[0],e[1],e[2]||0))),n=new t(e.id,i);return n.setData(e),n}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(Fn.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:i,clientHeight:n}=t;this.setSize(i,n)}else e.context2d&&(this.context=e.context2d,this.canvas=Fn.creatReactNativeCanvas(this.context),this.context.canvas||(this.context.canvas=this.canvas))}toHighDpr(e,t,i){let n=Math.max(window.devicePixelRatio||1,1),r=this.canvas;return r.width=t*n,r.height=i*n,e.scale(n,n),r.style.width=`${t}px`,r.style.height=`${i}px`,e}clearCanvas(){var e,t,i;null==(i=this.context)||i.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 vr,i=this.viewer.getPixelSizeInWorldCoord();for(let n=0;n<e.length;n++){let r=e[n];r.setTolerance(i),r.visible&&(r.getBounds().getBoundingSphere(t),!r.needsFrustumCulled||this.frustum.intersectsSphere(t))&&r.render(this.context,this.camera)}}setSize(e,t){let i=this.canvas;i.width=e,i.height=t,i.style.width=`${e}px`,i.style.height=`${t}px`,this.toHighDpr(this.context,e,t)}getSortedDrawables(e=!1){let t=[];return this.drawableLists.forEach((i=>{let n=Array.from(i.getDrawables().values());e&&(n=n.filter((e=>e.visible))),n.length>0&&t.push(...n)})),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}getDrawablesByPosition(e,t){this.is3d||(e.z=0);let i=this.getSortedDrawables(),n=[];for(let r=0;r<i.length;r++){let a=i[r];a.isPointInPath(e,t)&&n.push(a)}return n}getDrawableById(e){return this.getSortedDrawables().find((t=>t.id===e))}measureTextLength(e,t){let i=this.context,n=e.split("\n"),r=0;for(let a=0;a<n.length;a++){let e=n[a];i.save(),i.font=t;let s=i.measureText(e).width;i.restore(),r=Math.max(r,s)}return r}screenshot(){return ft(this,arguments,(function*(e={type:"image/png",quality:.8}){var t,i,n;if(!this.canvas)return;let r=yield St.canvasToImage(this.canvas),a=yield St.canvasToImage(null==(t=this.viewer.renderer)?void 0:t.domElement);return this.clearCanvas(),null==(i=this.context)||i.drawImage(a,0,0,a.width/window.devicePixelRatio,a.height/window.devicePixelRatio),null==(n=this.context)||n.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 i=0;i<t.length;i++){let n=t[i];e(n)&&n.render(this.context,this.camera)}return St.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)}},Zo=class extends Ss{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 i=e[t],n=Un.createDrawable(i);this.addDrawable(n)}}getDrawableByPosition(e,t){let i;for(let[n,r]of this.drawableMap)if(r.visible&&r.isPointInPath(e,t)){i=r;break}return i}},Cct=new Nt,Ai=class extends Hi{constructor(e){super(e),this.editPointSize=3,this.editPointFillColor="#ffffff",this.editPointStrokeColor="#939ea4",this.id=e||St.guid()}isSelected(){return this.selected}drawSelect(e,t){let i=this.getVertexes();this.drawPoints(e,t,i)}drawPoints(e,t,i){e.save(),e.fillStyle=this.editPointFillColor,e.strokeStyle=this.editPointStrokeColor,e.beginPath(),i.forEach((i=>{let n=this.transToScreenCoord(i,t);e.moveTo(n.x,n.y),e.arc(n.x,n.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 D)}isPointInPath(e){let t=this.getVertexes().map((e=>new xe(e.x,e.y)));return Qt.isPointInPolygon(new xe(e.x,e.y),t,!0)}setData(e){super.setData(e),this.update(e.points.map((e=>new D(e[0],e[1],0))))}setParent(e){this.parent=e}setLeaderText(e){this.leaderText=e,e.setParent(this)}update(e){let{min:t,max:i}=Cct.setFromPoints(e);return this.x=t.x,this.y=i.y,this.width=Math.abs(i.x-t.x),this.height=Math.abs(i.y-t.y),this.points=e,this}translate(e,t){let i=new D(e,t,0);return this.points.forEach((e=>e.add(i))),this.update(this.points),this}rotate(){return this}scale(){return this}},za=(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))(za||{}),n5=class extends Ai{constructor(e,t){super(e),this.type="ArrowMarkup",this.update(t)}draw(e,t){let i=this.points.map((e=>this.transToScreenCoord(e,t))),[n,r]=this.points,a=(new D).subVectors(n,r).length()/10/this.tolerance;this.drawArrowLine(e,i,a),this.drawArrowHead(e,i[0],i[1],10,a)}drawArrowLine(e,t,i){e.save(),e.lineWidth=this.lineWidth,e.strokeStyle=An.rgba2Color(this.lineColor);let[n,r]=t,a=(new xe).subVectors(r,n).normalize();e.beginPath(),e.moveTo(n.x,n.y);let s=r.clone().sub(a.multiplyScalar(i));e.lineTo(s.x,s.y),e.closePath(),e.stroke(),e.restore()}drawArrowHead(e,t,i,n,r){let a=180*Math.atan2(t.y-i.y,t.x-i.x)/Math.PI,s=(a+n)*Math.PI/180,o=(a-n)*Math.PI/180,l=r*Math.cos(s),h=r*Math.sin(s),c=r*Math.cos(o),u=r*Math.sin(o),d=new xe(i.x+l,i.y+h),p=new xe(i.x+c,i.y+u);e.save(),e.fillStyle=An.rgba2Color(this.lineColor),e.beginPath(),e.moveTo(i.x,i.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,i]=e;return this.points=e,this.x=Math.min(t.x,i.x),this.y=Math.max(t.y,i.y),this.width=Math.abs(i.x-t.x),this.height=Math.abs(i.y-t.y),this}isPointInPath(e){return Qt.isPointOnLineSegments(e,this.points,this.tolerance)}getClassType(){return"ArrowMarkup"}};Un._registerDrawableClass(n5);var Pct=new xe,Lfe=new D,r5=class extends Ai{constructor(e,t){super(e),this.radius=1,this.type="CircleMarkup",this.update(t)}draw(e,t){let[i,n]=this.points.map((e=>this.transToScreenCoord(e,t)));this.radius=Pct.subVectors(n,i).length(),e.save(),e.lineWidth=this.lineWidth,e.strokeStyle=An.rgba2Color(this.lineColor),e.fillStyle=An.rgba2Color(this.fillColor),e.beginPath(),e.arc(i.x,i.y,this.radius,0,2*Math.PI),e.closePath(),e.stroke(),e.restore()}update(e){let[t,i]=e,n=Lfe.subVectors(i,t).length();return this.width=2*n,this.height=2*n,this.x=t.x-this.width/2,this.y=t.y+this.height/2,this.points=e,this}isPointInPath(e){let[t,i]=this.points,n=Lfe.subVectors(t,i).length();return Math.abs(e.distanceTo(t)-n)<=2*this.tolerance}getClassType(){return"CircleMarkup"}};Un._registerDrawableClass(r5);var Dfe=new Nt,Cc=class extends Ai{constructor(e,t){super(e),this.type="CloudLineMarkup",this.update(t)}draw(e,t){let i=this.points,n=[];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<i.length-1;s++){let r=this.transToScreenCoord(i[s],t),a=this.transToScreenCoord(i[s+1],t),o=Cc.getControlPointByTwoPoints(r,a);0===s&&e.moveTo(r.x,r.y),e.quadraticCurveTo(o.x,o.y,a.x,a.y),n.push(i[s],i[s+1],an.screen2World(o,t,this.ctx.canvas))}e.stroke(),e.restore(),Dfe.setFromPoints(n);let{min:r,max:a}=Dfe;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 i=(new xe).subVectors(t,e),n=i.angle(),r=i.length(),a=Rn.degToRad(45),s=r/2/Math.cos(a);return new xe(e.x+s*Math.cos(a-n),e.y-s*Math.sin(a-n))}getClassType(){return"CloudLineMarkup"}};Un._registerDrawableClass(Cc);var i5=class extends Ai{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 i=this.getVertexes();i.push(i[0]);let n,r=[],a=new D;for(let s=0;s<i.length-1;s++){let e=i[s],t=i[s+1];a.subVectors(t,e),n||(n=a.length()/10);let o=a.length(),l=a.normalize(),h=Math.round(o/n);for(let i=0;i<h;i++)r.push(e.clone().add(l.clone().multiplyScalar(n*i)))}r.push(r[0]),this.vertexes=[];for(let s=0;s<r.length-1;s++){let i=r[s],n=r[s+1],a=this.transToScreenCoord(i,t),o=this.transToScreenCoord(n,t),l=Cc.getControlPointByTwoPoints(a,o);this.vertexes.push(i,n,an.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(),i=[];for(let n=0;n<t.length;n++){let e=t[n],r=t[n+1]||t[0];i.push(e,r)}return Qt.isPointOnLineSegments(e,i,3*this.tolerance)}getClassType(){return"CloudRectMarkup"}};Un._registerDrawableClass(i5);var s5=class extends Ai{constructor(e,t){super(e),this.radius=8,this.update(t)}draw(e,t){let i=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(i.x,i.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"}};Un._registerDrawableClass(s5);var a5=class extends Ai{constructor(e,t){super(e),this.radiusX=1,this.radiusY=1,this.type="EllipseMarkup",this.update(t)}draw(e,t){let[i,n]=this.points.map((e=>this.transToScreenCoord(e,t))),r=(new xe).lerpVectors(i,n,.5);this.radiusX=Math.abs(n.x-i.x)/2,this.radiusY=Math.abs(n.y-i.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,i]=this.points,n=(new D).lerpVectors(t,i,.5),r=Math.pow(e.x-n.x,2),a=Math.pow(e.y-n.y,2),s=2*this.tolerance,o=Math.abs(i.x-t.x)/2-s,l=Math.abs(i.y-t.y)/2-s,h=r/(o*o),c=a/(l*l),u=Math.abs(i.x-t.x)/2+s,d=Math.abs(i.y-t.y)/2+s;return h+c>=1&&r/(u*u)+a/(d*d)<=1}getClassType(){return"EllipseMarkup"}};Un._registerDrawableClass(a5);var uE=class extends Ai{constructor(e,t,i){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,i=(null==(e=this.manager.overlayRender)?void 0:e.measureTextLength(t,this.fontSize/this.tolerance+"px Arial"))||0;i>uE.DEFAULT_INPUT_WIDTH&&(this.textInput.style.width=`${Math.round(i+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,i=(null==(e=this.manager.overlayRender)?void 0:e.measureTextLength(t,this.fontSize/this.tolerance+"px Arial"))||0;i>uE.DEFAULT_INPUT_WIDTH&&(this.textInput.style.width=`${Math.round(i+this.padding/this.tolerance*2)}px`),this.text=t,this.inputStatus="CHAR_TYPING"},this.handleBlur=()=>{this.exitEditing()},this.handleFoucs=()=>{},this.update(t),this.text=i}draw(e,t){this.isEditing||this.drawText(e,t,this.text)}drawText(e,t,i){let n=this.transToScreenCoord(new D(this.x,this.y,0),t),r=i.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],i=e.measureText(t).width;i>s&&(s=i)}let o=this.padding/this.tolerance,l=new xe(n.x,n.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,i){var n;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==(n=e.viewerCanvas.parentElement)||n.appendChild(this.textInput),this.addInputEvents()),this.manager=e,this.enterEditing(),this.textInput.style.left=`${t}px`,this.textInput.style.top=`${i}px`,this.textInput.style.width=`${uE.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,i,n,r,a,s;null==(e=this.textInput)||e.addEventListener("click",this.handleClick),null==(t=this.textInput)||t.addEventListener("blur",this.handleBlur),null==(i=this.textInput)||i.addEventListener("foucs",this.handleFoucs),null==(n=this.textInput)||n.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,i,n,r,a,s,o;null==(e=this.textInput)||e.removeEventListener("click",this.handleClick),null==(t=this.textInput)||t.removeEventListener("blur",this.handleBlur),null==(i=this.textInput)||i.removeEventListener("foucs",this.handleFoucs),null==(n=this.textInput)||n.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")}},Dl=uE;Dl.DEFAULT_INPUT_WIDTH=50,Un._registerDrawableClass(Dl);var Ofe=new xe,kfe=new xe(1,0),Ffe=new xe(0,-1),o5=class extends Dl{constructor(e,t,i){super(e,t,i),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 i=this.points.map((e=>this.transToScreenCoord(e,t))),[n,r]=this.points,a=(new D).subVectors(n,r).length()/10/this.tolerance;this.drawArrowLine(e,i,a),this.drawArrowHead(e,i[1],i[0],10,a),!this.isEditing&&this.text.length>0&&this.drawText(e,t,this.text)}drawArrowHead(e,t,i,n,r){let a=180*Math.atan2(t.y-i.y,t.x-i.x)/Math.PI,s=(a+n)*Math.PI/180,o=(a-n)*Math.PI/180,l=r*Math.cos(s),h=r*Math.sin(s),c=r*Math.cos(o),u=r*Math.sin(o),d=new xe(i.x+l,i.y+h),p=new xe(i.x+c,i.y+u);e.save(),e.fillStyle=An.rgba2Color(this.lineColor),e.beginPath(),e.moveTo(i.x,i.y),e.lineTo(d.x,d.y),e.lineTo(p.x,p.y),e.closePath(),e.fill(),e.restore()}drawArrowLine(e,t,i){e.save(),e.lineWidth=this.lineWidth,e.strokeStyle=An.rgba2Color(this.lineColor);let[n,r]=t,a=(new xe).subVectors(n,r).normalize();e.beginPath(),e.moveTo(r.x,r.y);let s=n.clone().sub(a.multiplyScalar(i));e.lineTo(s.x,s.y),e.closePath(),e.stroke(),e.restore()}drawText(e,t,i){let[n,r]=this.points.map((e=>this.transToScreenCoord(e,t))),a=(new xe).subVectors(r,n).normalize(),s=a.cross(Ffe)<0,o=a.cross(kfe)<0,l=i.split("\n"),h=this.fontSize/this.tolerance,c=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],i=e.measureText(t).width;i>c&&(c=i)}let u=this.padding/this.tolerance,d=u+h/2,p=l.length*h+2*u,f=new xe(s?r.x:r.x-c-2*u,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+u,f.y+u+v*h,c+2*u)}e.strokeRect(f.x,f.y,c+2*u,l.length*h+2*u),e.restore();let m=an.screen2World(Ofe.set(f.x,f.y),t,this.ctx.canvas);m.z=0;let g=an.screen2World(Ofe.set(f.x+c+2*u,f.y+p),t,this.ctx.canvas);g.z=0,this.textBounds.setFromPoints([m,g])}getVertexes(){return this.points}update(e){let[t,i]=e;return this.points=e,this.x=Math.min(t.x,i.x),this.y=Math.max(t.y,i.y),this.width=Math.abs(i.x-t.x),this.height=Math.abs(i.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 Qt.isPointOnLineSegments(e,this.points,this.tolerance)||this.textBounds.containsPoint(e)}updateText(e){this.text=e}getClassType(){return"LeaderLineMarkup"}addInput(e,t,i){let[n,r]=this.points.map((t=>an.world2Screen(t,e.camera,e.viewerCanvas))),a=(new xe).subVectors(r,n).normalize(),s=a.cross(Ffe)<0,o=a.cross(kfe)<0,l=this.fontSize/this.tolerance,h=this.padding/this.tolerance,c=h+l/2,u=Dl.DEFAULT_INPUT_WIDTH,d=l;super.addInput(e,s?t:t-u-2*h,o?i-c:i-d+(d-c))}calcuTextInputPositionByText(e){var t;if(!this.textInput||!this.manager)return;let i=(null==(t=this.manager.overlayRender)?void 0:t.measureTextLength(e,this.fontSize/this.tolerance+"px Arial"))||0;if(i>Dl.DEFAULT_INPUT_WIDTH){let e=this.points[1],t=an.world2Screen(this.points[0],this.manager.camera,this.manager.viewerCanvas),n=an.world2Screen(e,this.manager.camera,this.manager.viewerCanvas).clone().sub(t).normalize().cross(new xe(0,-1))<0,r=an.world2Screen(e,this.manager.camera,this.manager.viewerCanvas);n||(this.textInput.style.left=r.x-i-this.padding/this.tolerance*2+"px"),this.textInput.style.width=`${Math.round(i)}px`}}};Un._registerDrawableClass(o5);var l5=class extends Ai{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 i=this.points;e.beginPath(),i.forEach(((i,n)=>{let r=this.transToScreenCoord(i,t);0===n?e.moveTo(r.x,r.y):e.lineTo(r.x,r.y)})),e.stroke(),e.restore()}isPointInPath(e){let t=this.points,i=[];for(let n=0;n<t.length-1;n++)i.push(t[n],t[n+1]);return Qt.isPointOnLineSegments(e,i,1*this.tolerance)}getVertexes(){return this.points}getClassType(){return"PolylineMarkup"}};Un._registerDrawableClass(l5);var c5=class extends Ai{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(((i,n)=>{let r=this.transToScreenCoord(i,t);0===n?e.moveTo(r.x,r.y):e.lineTo(r.x,r.y)})),e.closePath(),e.stroke(),e.restore()}isPointInPath(e){let t=this.getVertexes(),i=[];for(let n=0;n<t.length;n++){let e=t[n],r=t[n+1]||t[0];i.push(e,r)}return Qt.isPointOnLineSegments(e,i,2*this.tolerance)}getClassType(){return"RectMarkup"}};Un._registerDrawableClass(c5);var u5=class extends Ai{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[i,n,r,a]=this.getVertexes().map((e=>this.transToScreenCoord(e,t)));e.moveTo(i.x,i.y),e.lineTo(r.x,r.y),e.moveTo(n.x,n.y),e.lineTo(a.x,a.y),e.closePath(),e.stroke(),e.restore()}isPointInPath(e){let[t,i,n,r]=this.getVertexes();return Qt.isPointOnLineSegments(e,[t,n,i,r],.1)}getClassType(){return"XMarkup"}};Un._registerDrawableClass(u5);var Nfe=new Nt,h5=new D,d5=new xe,Ict=new xe(1,0),Lct=new xe(0,-1),f5=class extends Dl{constructor(e,t,i=""){super(e,t,i),this.type="CloudRectWithTextMarkup",this.textPosition=new D,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 i=this.getCloudPoints();i.push(i[0]);let n,r=[];for(let a=0;a<i.length-1;a++){let e=i[a],t=i[a+1],s=h5.subVectors(t,e);n||(n=s.length()/10);let o=s.length(),l=s.normalize(),h=Math.round(o/n);for(let i=0;i<h;i++)r.push(e.clone().add(l.clone().multiplyScalar(n*i)))}r.push(r[0]),this.controlPoints=[],this.vertexes=[];for(let a=0;a<r.length-1;a++){let i=r[a],n=r[a+1],s=this.transToScreenCoord(i,t),o=this.transToScreenCoord(n,t),l=Cc.getControlPointByTwoPoints(s,o);this.controlPoints.push(s,o),this.vertexes.push(i,n,an.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 i=this.transToScreenCoord(this.textPosition,t);this.controlPoints.sort(((e,t)=>i.distanceTo(e)-i.distanceTo(t)));let n=this.controlPoints[0];e.save(),e.lineWidth=f5.LEADER_LINE_WIDTH,e.strokeStyle=An.rgba2Color(this.lineColor),e.beginPath(),e.moveTo(n.x,n.y),e.lineTo(i.x,i.y),e.closePath(),e.stroke(),e.restore()}drawText(e,t,i){let n=this.transToScreenCoord(this.points[0],t),r=this.transToScreenCoord(this.textPosition,t),a=d5.subVectors(r,n).normalize(),s=a.cross(Ict)<0,o=a.cross(Lct)<0,l=i.split("\n"),h=this.fontSize/this.tolerance,c=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],i=e.measureText(t).width;i>c&&(c=i)}let u=this.padding/this.tolerance,d=u+h/2,p=l.length*h+2*u,f=new xe(o?r.x:r.x-c-2*u,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+u,f.y+u+v*h,c+2*u)}e.strokeRect(f.x,f.y,c+2*u,l.length*h+2*u),e.restore();let m=an.screen2World(d5.set(f.x,f.y),t,this.ctx.canvas);m.z=0;let g=an.screen2World(d5.set(f.x+c+2*u,f.y+p),t,this.ctx.canvas);g.z=0,this.textBounds.setFromPoints([m,g])}translate(e,t){let i=h5.set(e,t,0);this.points.forEach((e=>e.add(i))),this.textPosition.add(i);let[n,r]=this.points;return this.x=Math.min(n.x,r.x),this.y=Math.max(n.y,r.y),this.width=Math.abs(r.x-n.x),this.height=Math.abs(r.y-n.y),this}update(e){let[t,i]=e;return this.points=e,this.x=Math.min(t.x,i.x),this.y=Math.max(t.y,i.y),this.width=Math.abs(i.x-t.x),this.height=Math.abs(i.y-t.y),this.textPosition||(this.textPosition=new D),this.textPosition.set(Math.max(t.x,i.x),Math.max(t.y,i.y),0),this}getCloudPoints(){return[new D(this.x,this.y,0),new D(this.x+this.width,this.y,0),new D(this.x+this.width,this.y-this.height,0),new D(this.x,this.y-this.height,0)]}getBounds(){return Nfe.setFromPoints([...this.points,...this.vertexes||[]]),Nfe.union(this.textBounds)}getVertexes(){let e=this.getBounds(),t=e.min,i=e.getSize(h5);return[new D(t.x,t.y,0),new D(t.x+i.x,t.y,0),new D(t.x+i.x,t.y+i.y,0),new D(t.x,t.y+i.y,0)]}isLeaderTextSelected(e){return this.textBounds.containsPoint(e)}translateLeaderText(e,t){let i=new D(e,t,0);return this.textPosition.add(i),this}isPointInPath(e){let t=this.getCloudPoints(),i=[];for(let n=0;n<t.length;n++){let e=t[n],r=t[(n+1)%t.length];i.push(e,r)}return Qt.isPointOnLineSegments(e,i,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,i){let n=this.padding/this.tolerance+this.fontSize/this.tolerance/2;super.addInput(e,t,i-n)}updateInputPosition(e,t){var i;if(!this.manager||!this.textInput)return;let n=t.clone().sub(e).normalize().cross(new xe(0,-1))<0,r=this.textInput.value,a=(null==(i=this.manager.overlayRender)?void 0:i.measureTextLength(r,this.fontSize/this.tolerance+"px Arial"))||Dl.DEFAULT_INPUT_WIDTH,s=this.padding/this.tolerance+this.fontSize/this.tolerance/2;this.textInput.style.left=`${n?t.x:t.x-this.padding/this.tolerance*2-a}px`,this.textInput.style.top=t.y-s+"px",this.textPosition.copy(an.screen2World(t,this.manager.camera,this.manager.viewerCanvas))}calcInputPositionByText(e){var t;if(!this.textInput||!this.manager)return;let i=(null==(t=this.manager.overlayRender)?void 0:t.measureTextLength(e,this.fontSize/this.tolerance+"px Arial"))||0;if(i>Dl.DEFAULT_INPUT_WIDTH){let e=an.world2Screen(this.points[0],this.manager.camera,this.manager.viewerCanvas),t=an.world2Screen(this.textPosition,this.manager.camera,this.manager.viewerCanvas).clone().sub(e).normalize().cross(new xe(0,-1))<0,n=an.world2Screen(this.textPosition,this.manager.camera,this.manager.viewerCanvas);t||(this.textInput.style.left=n.x-i-this.padding/this.tolerance*2+"px"),this.textInput.style.width=`${Math.round(i)}px`}}},Vm=f5;Vm.LEADER_LINE_WIDTH=1,Un._registerDrawableClass(Vm);var tr={LEFT:1,RIGHT:2,MIDDLE:4},yt=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 If(e){return e.isPerspectiveCamera}function Vu(e){return e.isOrthographicCamera}var Dct=(e=>(e[e.NONE=-1]="NONE",e[e.ROTATE=0]="ROTATE",e[e.DOLLY=1]="DOLLY",e[e.PAN=2]="PAN",e[e.TOUCH_ROTATE=3]="TOUCH_ROTATE",e[e.TOUCH_DOLLY=4]="TOUCH_DOLLY",e))(Dct||{}),Oct=(e=>(e.LEFT="ArrowLeft",e.UP="ArrowUp",e.RIGHT="ArrowRight",e.BOTTOM="ArrowDown",e))(Oct||{});function Jv(e){return{type:e}}var zu={movable:!1,startDistBetweenFingers:0,scale:1},Qv=2*Math.PI,Bfe=1e-6,eC=class extends Wo{constructor(e,t,i=!1){super(),this.enabled=!0,this.target=new D,this.enableZoom=!1,this.enablePan=!1,this.enableRotate=!0,this.state=-1,this.rotateSpeed=1,this.zoomSpeed=1,this.panSpeed=1,this.scale=1,this.minZoom=0,this.maxZoom=1/0,this.screenSpacePanning=!0,this.autoRotate=!0,this.autoRotateSpeed=2,this.enableDamping=!1,this.dampingFactor=.05,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minDistance=0,this.maxDistance=1/0,this.keyPanSpeed=7,this.minFov=50,this.maxFov=95,this.zoomChanged=!1,this.panOffset=new D,this.pointerPositions={},this.rotateStart=new xe,this.rotateEnd=new xe,this.rotateDelta=new xe,this.dollyStart=new xe,this.dollyEnd=new xe,this.dollyDelta=new xe,this.panStart=new xe,this.panEnd=new xe,this.panDelta=new xe,this.pointers=[],this.spherical=new gf,this.sphericalDelta=new gf,this.update=function(e){let t=new D,i=new D,n=new dr;return function(){let r=e.quat,a=r.clone().invert(),s=e.object.position;t.copy(s).sub(e.target),t.applyQuaternion(r),e.spherical.setFromVector3(t),e.autoRotate&&-1===e.state&&(e.isVRMode?e.sphericalDelta.theta+=Qv/60/60*e.autoRotateSpeed:e.sphericalDelta.theta-=Qv/60/60*e.autoRotateSpeed),e.enableDamping?(e.spherical.theta+=e.sphericalDelta.theta*e.dampingFactor,e.spherical.phi+=e.sphericalDelta.phi*e.dampingFactor):(e.spherical.theta+=e.sphericalDelta.theta,e.spherical.phi+=e.sphericalDelta.phi);let o=e.minAzimuthAngle,l=e.maxAzimuthAngle;return isFinite(o)&&isFinite(l)&&(o<-Math.PI?o+=Qv:o>Math.PI&&(o-=Qv),l<-Math.PI?l+=Qv:l>Math.PI&&(l-=Qv),e.spherical.theta=o<=l?Math.max(o,Math.min(l,e.spherical.theta)):e.spherical.theta>(o+l)/2?Math.max(o,e.spherical.theta):Math.min(l,e.spherical.theta)),e.spherical.phi=Math.max(e.minPolarAngle,Math.min(e.maxPolarAngle,e.spherical.phi)),e.spherical.makeSafe(),e.spherical.radius*=e.scale,e.spherical.radius=Math.max(e.minDistance,Math.min(e.maxDistance,e.spherical.radius)),!0===e.enableDamping?e.target.addScaledVector(e.panOffset,e.dampingFactor):e.target.add(e.panOffset),t.setFromSpherical(e.spherical),t.applyQuaternion(a),s.copy(e.target).add(t),e.object.lookAt(e.target),!0===e.enableDamping?(e.sphericalDelta.theta*=1-e.dampingFactor,e.sphericalDelta.phi*=1-e.dampingFactor,e.panOffset.multiplyScalar(1-e.dampingFactor)):(e.sphericalDelta.set(0,0,0),e.panOffset.set(0,0,0)),e.scale=1,!!(e.zoomChanged||i.distanceToSquared(e.object.position)>Bfe||8*(1-n.dot(e.object.quaternion))>Bfe)&&(e.dispatchEvent(Jv("change")),i.copy(e.object.position),n.copy(e.object.quaternion),e.zoomChanged=!1,!0)}}(this),this.onContextMenu=function(e){return t=>{!1!==e.enabled&&t.preventDefault()}}(this),this.onPointerDown=function(e){return t=>{!1!==e.enabled&&(0===e.pointers.length&&(e.domElement.setPointerCapture(t.pointerId),e.domElement.addEventListener("pointermove",e.onPointerMove),e.domElement.addEventListener("pointerup",e.onPointerUp)),e.addPointer(t),"touch"===t.pointerType?e.onTouchStart(t):e.onMouseDown(t))}}(this),this.onPointerMove=function(e){return t=>{!1!==e.enabled&&("touch"===t.pointerType?e.onTouchMove(t):e.onMouseMove(t))}}(this),this.onPointerUp=function(e){return t=>{e.removePointer(t),0===e.pointers.length&&(e.domElement.releasePointerCapture(t.pointerId),e.domElement.removeEventListener("pointermove",e.onPointerMove),e.domElement.removeEventListener("pointerup",e.onPointerUp)),"touch"===t.pointerType&&e.handlerTouchEnd(t),e.dispatchEvent(Jv("end")),e.state=-1}}(this),this.onPointerCancel=function(e){return t=>{e.removePointer(t),e.handlerTouchEnd(t)}}(this),this.onMouseWheel=function(e){return t=>{!1===e.enabled||!1===e.enableZoom||-1!==e.state||(t.preventDefault(),t.stopPropagation(),e.dispatchEvent(Jv("start")),e.handleMouseWheel(t),e.dispatchEvent(Jv("end")))}}(this),this.pan=function(e){let t=new D;return function(i,n){let r=e.domElement;if(e.object instanceof hr){let a=e.object.position;t.copy(a).sub(e.target);let s=t.length();s*=Math.tan(e.object.fov/2*Math.PI/180),e.panLeft(2*i*s/r.clientHeight,e.object.matrix),e.panUp(2*n*s/r.clientHeight,e.object.matrix)}else console.warn("WARNING: VRControls.js encountered an unknown camera type - pan disabled."),e.enablePan=!1}}(this),this.panLeft=function(e){let t=new D;return function(i,n){t.setFromMatrixColumn(n,0),t.multiplyScalar(-i),e.panOffset.add(t)}}(this),this.panUp=function(e){let t=new D;return function(i,n){!0===e.screenSpacePanning?t.setFromMatrixColumn(n,1):(t.setFromMatrixColumn(n,0),t.crossVectors(e.object.up,t)),t.multiplyScalar(i),e.panOffset.add(t)}}(this),this.onKeyDown=e=>{!1===this.enabled||!1===this.enablePan||this.handleKeyDown(e)},this.object=e,this.domElement=t,this.isVRMode=i,this.quat=(new dr).setFromUnitVectors(this.object.up,new D(0,1,0)),this.domElement&&this.domElement.style&&(this.domElement.style.touchAction="none"),this.domElement.addEventListener("contextmenu",this.onContextMenu),this.domElement.addEventListener("pointerdown",this.onPointerDown),this.domElement.addEventListener("pointercancel",this.onPointerCancel),this.domElement.addEventListener("wheel",this.onMouseWheel,{passive:!1}),this.update()}dispose(){this.domElement.removeEventListener("contextmenu",this.onContextMenu),this.domElement.removeEventListener("pointerdown",this.onPointerDown),this.domElement.removeEventListener("pointercancel",this.onPointerCancel),this.domElement.removeEventListener("wheel",this.onMouseWheel),this.domElement.removeEventListener("pointermove",this.onPointerMove),this.domElement.removeEventListener("pointerup",this.onPointerUp),this.domElementKeyEvents&&this.domElementKeyEvents.removeEventListener("keydown",this.onKeyDown)}addPointer(e){this.pointers.push(e)}removePointer(e){delete this.pointerPositions[e.pointerId];for(let t=0;t<this.pointers.length;t++)if(this.pointers[t].pointerId==e.pointerId)return void this.pointers.splice(t,1)}getDist(e,t){return Math.hypot(t[0]-e[0],t[1]-e[1])}trackPointer(e){let t=this.pointerPositions[e.pointerId];void 0===t&&(t=new xe,this.pointerPositions[e.pointerId]=t),t.set(e.pageX,e.pageY)}onTouchStart(e){switch(this.trackPointer(e),this.pointers.length){case 1:if(!1===this.enableRotate)return;this.handleTouchStartRotate(),this.state=3;break;case 2:this.handleTouchStartDolly(this.pointers),this.state=4;break;default:this.state=-1}-1!==this.state&&this.dispatchEvent(Jv("start"))}onMouseDown(e){switch(e.button){case 0:if(!1===this.enableRotate)return;this.handleMouseDownRotate(e),this.state=0;break;case 1:if(!1===this.enableZoom)return;this.handleMouseDownDolly(e),this.state=1;break;case 2:if(e.ctrlKey||e.metaKey||e.shiftKey){if(!1===this.enablePan)return;this.handleMouseDownPan(e),this.state=2}else{if(!1===this.enableRotate)return;this.handleMouseDownRotate(e),this.state=0}break;default:this.state=-1}-1!==this.state&&this.dispatchEvent(Jv("start"))}onTouchMove(e){switch(this.trackPointer(e),this.state){case 3:if(!1===this.enableRotate)return;this.handleTouchMoveRotate(e);break;case 4:this.handleTouchMoveDolly(e)}}onMouseMove(e){if(!1!==this.enabled)switch(this.state){case 0:if(!1===this.enableRotate)return;this.handleMouseMoveRotate(e);break;case 1:if(!1===this.enableZoom)return;this.handleMouseMoveDolly(e);break;case 2:if(!1===this.enablePan)return;this.handleMouseMovePan(e)}}handlerTouchEnd(e){zu.movable=!1,zu.scale=1}handleMouseWheel(e){let t=Math.pow(.95,this.zoomSpeed);e.deltaY<0?this.dollyIn(t):e.deltaY>0&&this.dollyOut(t),this.update()}handleMouseDownRotate(e){this.rotateStart.set(e.clientX,e.clientY)}handleMouseDownDolly(e){this.dollyStart.set(e.clientX,e.clientY)}handleMouseDownPan(e){this.panStart.set(e.clientX,e.clientY)}handleTouchStartRotate(){if(1===this.pointers.length)this.rotateStart.set(this.pointers[0].pageX,this.pointers[0].pageY);else{let e=.5*(this.pointers[0].pageX+this.pointers[1].pageX),t=.5*(this.pointers[0].pageY+this.pointers[1].pageY);this.rotateStart.set(e,t)}}handleTouchStartDolly(e){if(e.length<2)return;let t=e[0],i=e[1];zu.startDistBetweenFingers=this.getDist([t.pageX,t.pageY],[i.pageX,i.pageY]),zu.movable=!0,zu.scale=1}updateRotate(){let e=this.isVRMode,t=this.sphericalDelta;this.rotateDelta.subVectors(this.rotateEnd,this.rotateStart).multiplyScalar(this.rotateSpeed);let i=this.domElement;e?(t.theta+=2*Math.PI*this.rotateDelta.x/i.clientHeight,t.phi+=2*Math.PI*this.rotateDelta.y/i.clientHeight):(t.theta-=2*Math.PI*this.rotateDelta.x/i.clientHeight,t.phi-=2*Math.PI*this.rotateDelta.y/i.clientHeight),this.rotateStart.copy(this.rotateEnd)}handleMouseMoveRotate(e){this.rotateEnd.set(e.clientX,e.clientY),this.updateRotate()}dollyOut(e){this.object instanceof hr?this.scale/=e:(console.warn("WARNING: VRControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}dollyIn(e){this.object instanceof hr?this.scale*=e:(console.warn("WARNING: VRControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}handleMouseMoveDolly(e){this.dollyEnd.set(e.clientX,e.clientY),this.dollyDelta.subVectors(this.dollyEnd,this.dollyStart);let t=Math.pow(.95,this.zoomSpeed);this.dollyDelta.y>0?this.dollyOut(t):this.dollyIn(t),this.dollyStart.copy(this.dollyEnd)}handleMouseMovePan(e){this.panEnd.set(e.clientX,e.clientY),this.panDelta.subVectors(this.panEnd,this.panStart).multiplyScalar(this.panSpeed),this.pan(this.panDelta.x,this.panDelta.y),this.panStart.copy(this.panEnd)}getSecondPointerPosition(e){let t=e.pointerId===this.pointers[0].pointerId?this.pointers[1]:this.pointers[0];return this.pointerPositions[t.pointerId]}handleTouchMoveRotate(e){if(1==this.pointers.length)this.rotateEnd.set(e.pageX,e.pageY);else{let t=this.getSecondPointerPosition(e),i=.5*(e.pageX+t.x),n=.5*(e.pageY+t.y);this.rotateEnd.set(i,n)}this.updateRotate()}updateFov(e){var t;let i=this.object;if(!(i&&i instanceof hr))return void console.warn("WARNING: VRControls.js encountered an unknown camera type - updateFov disabled.");let n=this.minFov,r=this.maxFov,a=e=>{let t=i.fov+e;t=Math.min(t,r),t=Math.max(t,n),i.fov!==t&&(i.fov=t,i.updateProjectionMatrix(),this.dispatchEvent({type:"change"}))},s=e/20;for(let o=0;o<20;++o)setTimeout((()=>a(s)),5*o);this.autoRotate&&(null==(t=this.controlsHelper)||t.delayAutoRotate())}handleTouchMoveDolly(e){if(!zu.movable||this.pointers.length<2)return;let t=this.getSecondPointerPosition(e),i=[e.pageX,e.pageY],n=[t.x,t.y],r=zu.startDistBetweenFingers,a=this.getDist(i,n);if(!r||!a||Math.abs(r-a)<10)return;let s=a/r;console.log(s),s=Math.min(s,3),s=Math.max(s,1/3);let o=s-zu.scale;if(Math.abs(o)<.05)return;let l=0;l=o>0?10*-o:10*(zu.scale/s-1),this.updateFov(l),zu.scale=s}handleKeyDown(e){let t=!1;switch(e.code){case"ArrowUp":this.pan(0,this.keyPanSpeed),t=!0;break;case"ArrowDown":this.pan(0,-this.keyPanSpeed),t=!0;break;case"ArrowLeft":this.pan(this.keyPanSpeed,0),t=!0;break;case"ArrowRight":this.pan(-this.keyPanSpeed,0),t=!0}t&&(e.preventDefault(),this.update())}listenToKeyEvents(e){e.addEventListener("keydown",this.onKeyDown),this.domElementKeyEvents=e}},Ko=class extends Ss{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,tC(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,tC(e,"pointerId")){t.pointerType=e.pointerType,t.buttons=e.buttons,t.pageX=e.pageX,t.pageY=e.pageY,t.pointerId=e.pointerId;let i=an.getScreenCoordinateByEvent(e,this.element);t.x=i.x,t.y=i.y,t.movementX=e.movementX,t.movementY=e.movementY}else tC(e,"deltaX")&&(t.deltaMode=e.deltaMode,t.deltaX=e.deltaX,t.deltaY=e.deltaY);else tC(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 tC(e,t){return void 0!==e[t]}var zm=2*Math.PI,p5=Math.PI/2,ey=Math.PI/180;function Gm(e,t,i){return Math.max(t,Math.min(i,e))}function Vi(e,t=1e-5){return Math.abs(e)<t}function zi(e,t,i=1e-5){return Vi(e-t,i)}function m5(e,t){return Math.round(e/t)*t}function ty(e){return isFinite(e)?e:e<0?-Number.MAX_VALUE:Number.MAX_VALUE}function ny(e){return Math.abs(e)<Number.MAX_VALUE?e:e*(1/0)}function hE(e,t,i,n,r=1/0,a){let s=2/(n=Math.max(1e-4,n)),o=s*a,l=1/(1+o+.48*o*o+.235*o*o*o),h=e-t,c=t,u=r*n;h=Gm(h,-u,u),t=e-h;let d=(i.value+s*h)*a;i.value=(i.value-s*d)*l;let p=t+(h+d)*l;return c-e>0==p>c&&(p=c,i.value=(p-c)/a),p}function g5(e,t,i,n,r=1/0,a,s){let o=2/(n=Math.max(1e-4,n)),l=o*a,h=1/(1+l+.48*l*l+.235*l*l*l),c=t.x,u=t.y,d=t.z,p=e.x-c,f=e.y-u,m=e.z-d,g=c,v=u,y=d,x=r*n,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}c=e.x-p,u=e.y-f,d=e.z-m;let _=(i.x+o*p)*a,w=(i.y+o*f)*a,S=(i.z+o*m)*a;i.x=(i.x-o*_)*h,i.y=(i.y-o*w)*h,i.z=(i.z-o*S)*h,s.x=c+(p+_)*h,s.y=u+(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,i.x=(s.x-g)/a,i.y=(s.y-v)/a,i.z=(s.z-y)/a),s}function nC(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 rC(e,t){return!!Vu(e)&&(console.warn(`${t} is not supported in OrthographicCamera`),!0)}var iC=class{constructor(){this._listeners={}}addEventListener(e,t){let i=this._listeners;void 0===i[e]&&(i[e]=[]),-1===i[e].indexOf(t)&&i[e].push(t)}hasEventListener(e,t){let i=this._listeners;return void 0!==i[e]&&-1!==i[e].indexOf(t)}removeEventListener(e,t){let i=this._listeners[e];if(void 0!==i){let e=i.indexOf(t);-1!==e&&i.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 i=t.slice(0);for(let t=0,n=i.length;t<n;t++)i[t].call(this,e)}}},sC=1/8,kct=Fn.isBrowser&&/Mac/.test(navigator.platform),Fct=!(Fn.isBrowser&&"PointerEvent"in window),nr,Ufe,aC,v5,vo,ar,Ei,ry,Gu,qu,qm,Hfe,Vfe,Pc,dE,iy,zfe,y5,Gfe,x5,b5,oC,Lf=class extends iC{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=yt.NONE,this._viewport=null,this._dollyControlAmount=0,this._hasRested=!0,this._boundaryEnclosesCamera=!1,this._needsUpdate=!0,this._updatedLastTime=!1,this._elementRect=Fn.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,i)=>{if(If(this._camera)){let n=ar.copy(this._camera.position).sub(this._target),r=this._camera.getEffectiveFOV()*ey,a=n.length()*Math.tan(.5*r),s=this.truckSpeed*e*a/this._elementRect.height,o=this.truckSpeed*t*a/this._elementRect.height;this.verticalDragToForward?(i?this.setFocalOffset(this._focalOffsetEnd.x+s,this._focalOffsetEnd.y,this._focalOffsetEnd.z,!0):this.truck(s,0,!0),this.forward(-o,!0)):i?this.setFocalOffset(this._focalOffsetEnd.x+s,this._focalOffsetEnd.y+o,this._focalOffsetEnd.z,!0):this.truck(s,o,!0)}else if(Vu(this._camera)){let n=this._camera,r=e*(n.right-n.left)/n.zoom/this._elementRect.width,a=t*(n.top-n.bottom)/n.zoom/this._elementRect.height;i?this.setFocalOffset(this._focalOffsetEnd.x+r,this._focalOffsetEnd.y+a,this._focalOffsetEnd.z,!0):this.truck(r,a,!0)}},this._rotateInternal=(e,t)=>{let i=zm*this.azimuthRotateSpeed*e/this._elementRect.height,n=zm*this.polarRotateSpeed*t/this._elementRect.height;this.rotate(i,n,!0)},this._dollyInternal=(e,t,i)=>{let n=Math.pow(.95,-e*this.dollySpeed),r=this._sphericalEnd.radius*n,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(ar),this._targetEnd.add(ar.normalize().multiplyScalar(s)),this._target.add(ar.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,i))},this._zoomInternal=(e,t,i)=>{let n=Math.pow(.95,e*this.dollySpeed),r=this._zoomEnd;this.zoomTo(this._zoom*n),this.dollyToCursor&&(this._dollyControlAmount+=this._zoomEnd-r,this._dollyControlCoord.set(t,i))},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,aC),this._yAxisUpSpaceInverse=this._yAxisUpSpace.clone().invert(),this._state=yt.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(ar.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:yt.ROTATE,middle:yt.DOLLY,right:yt.TRUCK,wheel:If(this._camera)?yt.DOLLY:Vu(this._camera)?yt.ZOOM:yt.NONE},this.touches={one:yt.TOUCH_ROTATE,two:If(this._camera)?yt.TOUCH_DOLLY_TRUCK:Vu(this._camera)?yt.TOUCH_ZOOM_TRUCK:yt.NONE,three:yt.TOUCH_TRUCK};let i=new nr.Vector2,n=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 i={pointerId:e.pointerId,clientX:e.clientX,clientY:e.clientY,deltaX:0,deltaY:0,mouseButton:t};this._activePointers.push(i),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 i={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(i),this._domElement.removeEventListener("mousemove",l),this._domElement.removeEventListener("mouseup",c),this._domElement.addEventListener("mousemove",l),this._domElement.addEventListener("mouseup",c),f(e)},o=e=>{let t=e.pointerId,i=this._findPointerById(t);if(i){if(i.clientX=e.clientX,i.clientY=e.clientY,i.deltaX=e.movementX,i.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,i=this._findPointerById(t);if(i&&this._activePointers.splice(this._activePointers.indexOf(i),1),"touch"===e.pointerType)switch(this._activePointers.length){case 0:this._state=yt.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=yt.NONE;g()},c=()=>{let e=this._findPointerById(0);e&&this._activePointers.splice(this._activePointers.indexOf(e),1),this._state=yt.NONE,g()},u=-1,d=e=>{if(!this._enabled||this.mouseButtons.wheel===yt.NONE)return;if(this.dollyToCursor||this.mouseButtons.wheel===yt.ROTATE||this.mouseButtons.wheel===yt.TRUCK){let e=performance.now();u-e<1e3&&this._getClientRect(this._elementRect),u=e}let t=kct?-1:-3,i=1===e.deltaMode?e.deltaY/t:e.deltaY/(10*t),n=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 yt.ROTATE:this._rotateInternal(e.deltaX,e.deltaY),this._isUserControllingRotate=!0;break;case yt.TRUCK:this._truckInternal(e.deltaX,e.deltaY,!1),this._isUserControllingTruck=!0;break;case yt.OFFSET:this._truckInternal(e.deltaX,e.deltaY,!0),this._isUserControllingOffset=!0;break;case yt.DOLLY:this._dollyInternal(-i,n,r),this._isUserControllingDolly=!0;break;case yt.ZOOM:this._zoomInternal(-i,n,r),this._isUserControllingZoom=!0}this.dispatchEvent({type:"control"})},p=e=>{if(this._domElement&&this._enabled&&this.mouseButtons.right===Lf.ACTION.NONE){let t=e instanceof PointerEvent?e.pointerId:(MouseEvent,0),i=this._findPointerById(t);return i&&this._activePointers.splice(this._activePointers.indexOf(i),1),this._domElement.removeEventListener("pointermove",o),this._domElement.removeEventListener("pointerup",h),this._domElement.removeEventListener("mousemove",l),void this._domElement.removeEventListener("mouseup",c)}},f=e=>{if(this._enabled){if(nC(this._activePointers,vo),this._getClientRect(this._elementRect),i.copy(vo),n.copy(vo),this._activePointers.length>=2){let e=vo.x-this._activePointers[1].clientX,t=vo.y-this._activePointers[1].clientY,i=Math.sqrt(e*e+t*t);r.set(0,i);let a=.5*(this._activePointers[0].clientX+this._activePointers[1].clientX),s=.5*(this._activePointers[0].clientY+this._activePointers[1].clientY);n.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&yt.ROTATE)===yt.ROTATE||(this._state&yt.TOUCH_ROTATE)===yt.TOUCH_ROTATE||(this._state&yt.TOUCH_DOLLY_ROTATE)===yt.TOUCH_DOLLY_ROTATE||(this._state&yt.TOUCH_ZOOM_ROTATE)===yt.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&yt.TRUCK)===yt.TRUCK||(this._state&yt.TOUCH_TRUCK)===yt.TOUCH_TRUCK||(this._state&yt.TOUCH_DOLLY_TRUCK)===yt.TOUCH_DOLLY_TRUCK||(this._state&yt.TOUCH_ZOOM_TRUCK)===yt.TOUCH_ZOOM_TRUCK)&&(this._targetEnd.copy(this._target),this._targetVelocity.set(0,0,0)),((this._state&yt.DOLLY)===yt.DOLLY||(this._state&yt.TOUCH_DOLLY)===yt.TOUCH_DOLLY||(this._state&yt.TOUCH_DOLLY_TRUCK)===yt.TOUCH_DOLLY_TRUCK||(this._state&yt.TOUCH_DOLLY_OFFSET)===yt.TOUCH_DOLLY_OFFSET||(this._state&yt.TOUCH_DOLLY_ROTATE)===yt.TOUCH_DOLLY_ROTATE)&&(this._sphericalEnd.radius=this._spherical.radius,this._radiusVelocity.value=0),((this._state&yt.ZOOM)===yt.ZOOM||(this._state&yt.TOUCH_ZOOM)===yt.TOUCH_ZOOM||(this._state&yt.TOUCH_ZOOM_TRUCK)===yt.TOUCH_ZOOM_TRUCK||(this._state&yt.TOUCH_ZOOM_OFFSET)===yt.TOUCH_ZOOM_OFFSET||(this._state&yt.TOUCH_ZOOM_ROTATE)===yt.TOUCH_ZOOM_ROTATE)&&(this._zoomEnd=this._zoom,this._zoomVelocity.value=0),((this._state&yt.OFFSET)===yt.OFFSET||(this._state&yt.TOUCH_OFFSET)===yt.TOUCH_OFFSET||(this._state&yt.TOUCH_DOLLY_OFFSET)===yt.TOUCH_DOLLY_OFFSET||(this._state&yt.TOUCH_ZOOM_OFFSET)===yt.TOUCH_ZOOM_OFFSET)&&(this._focalOffsetEnd.copy(this._focalOffset),this._focalOffsetVelocity.set(0,0,0)),this.dispatchEvent({type:"controlstart"})}},m=()=>{if(!this._enabled)return;nC(this._activePointers,vo);let e=!!Fn.isBrowser&&this._domElement&&document.pointerLockElement===this._domElement,t=e?-this._activePointers[0].deltaX:n.x-vo.x,a=e?-this._activePointers[0].deltaY:n.y-vo.y;if(n.copy(vo),((this._state&yt.ROTATE)===yt.ROTATE||(this._state&yt.TOUCH_ROTATE)===yt.TOUCH_ROTATE||(this._state&yt.TOUCH_DOLLY_ROTATE)===yt.TOUCH_DOLLY_ROTATE||(this._state&yt.TOUCH_ZOOM_ROTATE)===yt.TOUCH_ZOOM_ROTATE)&&(this._rotateInternal(t,a),this._isUserControllingRotate=!0),(this._state&yt.DOLLY)===yt.DOLLY||(this._state&yt.ZOOM)===yt.ZOOM){let e=this.dollyToCursor?(i.x-this._elementRect.x)/this._elementRect.width*2-1:0,t=this.dollyToCursor?(i.y-this._elementRect.y)/this._elementRect.height*-2+1:0;(this._state&yt.DOLLY)===yt.DOLLY?(this._dollyInternal(a*sC,e,t),this._isUserControllingDolly=!0):(this._zoomInternal(a*sC,e,t),this._isUserControllingZoom=!0)}if((this._state&yt.TOUCH_DOLLY)===yt.TOUCH_DOLLY||(this._state&yt.TOUCH_ZOOM)===yt.TOUCH_ZOOM||(this._state&yt.TOUCH_DOLLY_TRUCK)===yt.TOUCH_DOLLY_TRUCK||(this._state&yt.TOUCH_ZOOM_TRUCK)===yt.TOUCH_ZOOM_TRUCK||(this._state&yt.TOUCH_DOLLY_OFFSET)===yt.TOUCH_DOLLY_OFFSET||(this._state&yt.TOUCH_ZOOM_OFFSET)===yt.TOUCH_ZOOM_OFFSET||(this._state&yt.TOUCH_DOLLY_ROTATE)===yt.TOUCH_DOLLY_ROTATE||(this._state&yt.TOUCH_ZOOM_ROTATE)===yt.TOUCH_ZOOM_ROTATE){let e=vo.x-this._activePointers[1].clientX,t=vo.y-this._activePointers[1].clientY,i=Math.sqrt(e*e+t*t),a=r.y-i;r.set(0,i);let s=this.dollyToCursor?(n.x-this._elementRect.x)/this._elementRect.width*2-1:0,o=this.dollyToCursor?(n.y-this._elementRect.y)/this._elementRect.height*-2+1:0;(this._state&yt.TOUCH_DOLLY)===yt.TOUCH_DOLLY||(this._state&yt.TOUCH_DOLLY_ROTATE)===yt.TOUCH_DOLLY_ROTATE||(this._state&yt.TOUCH_DOLLY_TRUCK)===yt.TOUCH_DOLLY_TRUCK||(this._state&yt.TOUCH_DOLLY_OFFSET)===yt.TOUCH_DOLLY_OFFSET?(this._dollyInternal(a*sC,s,o),this._isUserControllingDolly=!0):(this._zoomInternal(a*sC,s,o),this._isUserControllingZoom=!0)}((this._state&yt.TRUCK)===yt.TRUCK||(this._state&yt.TOUCH_TRUCK)===yt.TOUCH_TRUCK||(this._state&yt.TOUCH_DOLLY_TRUCK)===yt.TOUCH_DOLLY_TRUCK||(this._state&yt.TOUCH_ZOOM_TRUCK)===yt.TOUCH_ZOOM_TRUCK)&&(this._truckInternal(t,a,!1),this._isUserControllingTruck=!0),((this._state&yt.OFFSET)===yt.OFFSET||(this._state&yt.TOUCH_OFFSET)===yt.TOUCH_OFFSET||(this._state&yt.TOUCH_DOLLY_OFFSET)===yt.TOUCH_DOLLY_OFFSET||(this._state&yt.TOUCH_ZOOM_OFFSET)===yt.TOUCH_ZOOM_OFFSET)&&(this._truckInternal(t,a,!0),this._isUserControllingOffset=!0),this.dispatchEvent({type:"control"})},g=()=>{nC(this._activePointers,vo),n.copy(vo),0===this._activePointers.length&&this._domElement&&(this._domElement.removeEventListener("pointermove",o),this._domElement.removeEventListener("mousemove",l),this._domElement.removeEventListener("pointerup",h),this._domElement.removeEventListener("mouseup",c),this.dispatchEvent({type:"controlend"}))};this._addAllEventListeners=e=>{this._domElement=e,this._domElement.style.touchAction="none",this._domElement.style.userSelect="none",this._domElement.style.webkitUserSelect="none",this._domElement.addEventListener("pointerdown",a),Fct&&this._domElement.addEventListener("mousedown",s),this._domElement.addEventListener("pointercancel",h),this._domElement.addEventListener("wheel",d),this._domElement.addEventListener("contextmenu",p)},this._removeAllEventListeners=()=>{this._domElement&&(this._domElement.style.touchAction="",this._domElement.style.userSelect="",this._domElement.style.webkitUserSelect="",this._domElement.removeEventListener("pointerdown",a),this._domElement.removeEventListener("mousedown",s),this._domElement.removeEventListener("pointercancel",h),this._domElement.removeEventListener("wheel",d),this._domElement.removeEventListener("contextmenu",p),this._domElement.removeEventListener("pointermove",o),this._domElement.removeEventListener("mousemove",l),this._domElement.removeEventListener("pointerup",h),this._domElement.removeEventListener("mouseup",c))},this.cancel=()=>{this._state!==yt.NONE&&(this._state=yt.NONE,this._activePointers.length=0,g())},t&&this.connect(t),this.update(0)}static install(e){nr=e.THREE,Ufe=Object.freeze(new nr.Vector3(0,0,0)),aC=Object.freeze(new nr.Vector3(0,1,0)),v5=Object.freeze(new nr.Vector3(0,0,1)),vo=new nr.Vector2,ar=new nr.Vector3,Ei=new nr.Vector3,ry=new nr.Vector3,Gu=new nr.Vector3,qu=new nr.Vector3,qm=new nr.Vector3,Hfe=new nr.Vector3,Vfe=new nr.Vector3,Pc=new nr.Spherical,dE=new nr.Spherical,iy=new nr.Box3,zfe=new nr.Box3,y5=new nr.Sphere,Gfe=new nr.Quaternion,x5=new nr.Quaternion,b5=new nr.Matrix4,oC=new nr.Raycaster}static get ACTION(){return yt}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,i=!1){return this.rotateTo(this._sphericalEnd.theta+e,this._sphericalEnd.phi+t,i)}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,i=!1){this._isUserControllingRotate=!1;let n=Gm(e,this.minAzimuthAngle,this.maxAzimuthAngle),r=Gm(t,this.minPolarAngle,this.maxPolarAngle);this._sphericalEnd.theta=n,this._sphericalEnd.phi=r,this._sphericalEnd.makeSafe(),this._needsUpdate=!0,i||(this._spherical.theta=this._sphericalEnd.theta,this._spherical.phi=this._sphericalEnd.phi);let a=!i||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 i=this._sphericalEnd.radius,n=Gm(e,this.minDistance,this.maxDistance);if(this.colliderMeshes.length>=1){let e=this._collisionTest(),t=zi(e,this._spherical.radius);if(!(i>n)&&t)return Promise.resolve();this._sphericalEnd.radius=Math.min(n,e)}else this._sphericalEnd.radius=n;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=Gm(e,this.minZoom,this.maxZoom),this._needsUpdate=!0,t||(this._zoom=this._zoomEnd);let i=!t||zi(this._zoom,this._zoomEnd,this.restThreshold);return this._createOnRestPromise(i)}pan(e,t,i=!1){return console.warn("`pan` has been renamed to `truck`"),this.truck(e,t,i)}truck(e,t,i=!1){this._camera.updateMatrix(),Gu.setFromMatrixColumn(this._camera.matrix,0),qu.setFromMatrixColumn(this._camera.matrix,1),Gu.multiplyScalar(e),qu.multiplyScalar(-t);let n=ar.copy(Gu).add(qu),r=Ei.copy(this._targetEnd).add(n);return this.moveTo(r.x,r.y,r.z,i)}forward(e,t=!1){ar.setFromMatrixColumn(this._camera.matrix,0),ar.crossVectors(this._camera.up,ar),ar.multiplyScalar(e);let i=Ei.copy(this._targetEnd).add(ar);return this.moveTo(i.x,i.y,i.z,t)}elevate(e,t=!1){return ar.copy(this._camera.up).multiplyScalar(e),this.moveTo(this._targetEnd.x+ar.x,this._targetEnd.y+ar.y,this._targetEnd.z+ar.z,t)}moveTo(e,t,i,n=!1){this._isUserControllingTruck=!1;let r=ar.set(e,t,i).sub(this._targetEnd);this._encloseToBoundary(this._targetEnd,r,this.boundaryFriction),this._needsUpdate=!0,n||this._target.copy(this._targetEnd);let a=!n||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,i,n=!1){let r=ar.set(e,t,i).sub(this._targetEnd).normalize().multiplyScalar(-this._sphericalEnd.radius);return this.setPosition(r.x,r.y,r.z,n)}fitToBox(e,t,{cover:i=!1,paddingLeft:n=0,paddingRight:r=0,paddingBottom:a=0,paddingTop:s=0}={}){let o=[],l=e.isBox3?iy.copy(e):iy.setFromObject(e);l.isEmpty()&&(console.warn("camera-controls: fitTo() cannot be used with an empty box. Aborting"),Promise.resolve());let h=m5(this._sphericalEnd.theta,p5),c=m5(this._sphericalEnd.phi,p5);o.push(this.rotateTo(h,c,t));let u=ar.setFromSpherical(this._sphericalEnd).normalize(),d=Gfe.setFromUnitVectors(u,v5),p=zi(Math.abs(u.y),1);p&&d.multiply(x5.setFromAxisAngle(aC,h)),d.multiply(this._yAxisUpSpaceInverse);let f=zfe.makeEmpty();Ei.copy(l.min).applyQuaternion(d),f.expandByPoint(Ei),Ei.copy(l.min).setX(l.max.x).applyQuaternion(d),f.expandByPoint(Ei),Ei.copy(l.min).setY(l.max.y).applyQuaternion(d),f.expandByPoint(Ei),Ei.copy(l.max).setZ(l.min.z).applyQuaternion(d),f.expandByPoint(Ei),Ei.copy(l.min).setZ(l.max.z).applyQuaternion(d),f.expandByPoint(Ei),Ei.copy(l.max).setY(l.min.y).applyQuaternion(d),f.expandByPoint(Ei),Ei.copy(l.max).setX(l.min.x).applyQuaternion(d),f.expandByPoint(Ei),Ei.copy(l.max).applyQuaternion(d),f.expandByPoint(Ei),f.min.x-=n,f.min.y-=a,f.max.x+=r,f.max.y+=s,d.setFromUnitVectors(v5,u),p&&d.premultiply(x5.invert()),d.premultiply(this._yAxisUpSpace);let m=f.getSize(ar),g=f.getCenter(Ei).applyQuaternion(d);if(If(this._camera)){let e=this.getDistanceToFitBox(m.x,m.y,m.z,i);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(Vu(this._camera)){let e=this._camera,n=e.right-e.left,r=e.top-e.bottom,a=i?Math.max(n/m.x,r/m.y):Math.min(n/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 i=[],n=e instanceof nr.Sphere?y5.copy(e):Lf.createBoundingSphere(e,y5);if(i.push(this.moveTo(n.center.x,n.center.y,n.center.z,t)),If(this._camera)){let e=this.getDistanceToFitSphere(n.radius);i.push(this.dollyTo(e,t))}else if(Vu(this._camera)){let e=this._camera.right-this._camera.left,r=this._camera.top-this._camera.bottom,a=2*n.radius,s=Math.min(e/a,r/a);i.push(this.zoomTo(s,t))}return i.push(this.setFocalOffset(0,0,0,t)),Promise.all(i)}setLookAt(e,t,i,n,r,a,s=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1;let o=Ei.set(n,r,a),l=ar.set(e,t,i);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,i,n,r,a,s,o,l,h,c,u,d,p=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1;let f=ar.set(n,r,a),m=Ei.set(e,t,i);Pc.setFromVector3(m.sub(f).applyQuaternion(this._yAxisUpSpace));let g=ry.set(h,c,u),v=Ei.set(s,o,l);dE.setFromVector3(v.sub(g).applyQuaternion(this._yAxisUpSpace)),this._targetEnd.copy(f.lerp(g,d));let y=dE.theta-Pc.theta,x=dE.phi-Pc.phi,b=dE.radius-Pc.radius;this._sphericalEnd.set(Pc.radius+b*d,Pc.phi+x*d,Pc.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,i,n=!1){return this.setLookAt(e,t,i,this._targetEnd.x,this._targetEnd.y,this._targetEnd.z,n)}setTarget(e,t,i,n=!1){let r=this.getPosition(ar),a=this.setLookAt(r.x,r.y,r.z,e,t,i,n);return this._sphericalEnd.phi=Gm(this.polarAngle,this.minPolarAngle,this.maxPolarAngle),a}setFocalOffset(e,t,i,n=!1){this._isUserControllingOffset=!1,this._focalOffsetEnd.set(e,t,i),this._needsUpdate=!0,n||this._focalOffset.copy(this._focalOffsetEnd);let r=!n||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,i){this._camera.updateMatrixWorld(),Gu.setFromMatrixColumn(this._camera.matrixWorldInverse,0),qu.setFromMatrixColumn(this._camera.matrixWorldInverse,1),qm.setFromMatrixColumn(this._camera.matrixWorldInverse,2);let n=ar.set(e,t,i),r=n.distanceTo(this._camera.position),a=n.sub(this._camera.position);Gu.multiplyScalar(a.x),qu.multiplyScalar(a.y),qm.multiplyScalar(a.z),ar.copy(Gu).add(qu).add(qm),ar.z=ar.z+r,this.dollyTo(r,!1),this.setFocalOffset(-ar.x,ar.y,-ar.z,!1),this.moveTo(e,t,i,!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,i,n){null!==e?(this._viewport=this._viewport||new nr.Vector4,"number"==typeof e?this._viewport.set(e,t,i,n):this._viewport.copy(e)):this._viewport=null}getDistanceToFitBox(e,t,i,n=!1){if(rC(this._camera,"getDistanceToFitBox"))return this._spherical.radius;let r=e/t,a=this._camera.getEffectiveFOV()*ey,s=this._camera.aspect;return.5*((n?r>s:r<s)?t:e/s)/Math.tan(.5*a)+.5*i}getDistanceToFitSphere(e){if(rC(this._camera,"getDistanceToFitSphere"))return this._spherical.radius;let t=this._camera.getEffectiveFOV()*ey,i=2*Math.atan(Math.tan(.5*t)*this._camera.aspect),n=1<this._camera.aspect?t:i;return e/Math.sin(.5*n)}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%zm,this._sphericalEnd.theta<0&&(this._sphericalEnd.theta+=zm),this._spherical.theta+=zm*Math.round((this._sphericalEnd.theta-this._spherical.theta)/zm)}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,aC),this._yAxisUpSpaceInverse.copy(this._yAxisUpSpace).invert}update(e){let t=this._sphericalEnd.theta-this._spherical.theta,i=this._sphericalEnd.phi-this._spherical.phi,n=this._sphericalEnd.radius-this._spherical.radius,r=Hfe.subVectors(this._targetEnd,this._target),a=Vfe.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=hE(this._spherical.theta,this._sphericalEnd.theta,this._thetaVelocity,t,1/0,e),this._needsUpdate=!0}if(Vi(i))this._phiVelocity.value=0,this._spherical.phi=this._sphericalEnd.phi;else{let t=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.phi=hE(this._spherical.phi,this._sphericalEnd.phi,this._phiVelocity,t,1/0,e),this._needsUpdate=!0}if(Vi(n))this._radiusVelocity.value=0,this._spherical.radius=this._sphericalEnd.radius;else{let t=this._isUserControllingDolly?this.draggingSmoothTime:this.smoothTime;this._spherical.radius=hE(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;g5(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;g5(this._focalOffset,this._focalOffsetEnd,this._focalOffsetVelocity,t,this.maxSpeed,e,this._focalOffset),this._needsUpdate=!0}if(0!==this._dollyControlAmount){if(If(this._camera)){let e=this._camera,t=ar.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).normalize().negate(),i=Ei.copy(t).cross(e.up).normalize();0===i.lengthSq()&&(i.x=1);let n=ry.crossVectors(i,t),r=this._sphericalEnd.radius*Math.tan(e.getEffectiveFOV()*ey*.5),a=(this._sphericalEnd.radius-this._dollyControlAmount-this._sphericalEnd.radius)/this._sphericalEnd.radius,s=ar.copy(this._targetEnd).add(i.multiplyScalar(this._dollyControlCoord.x*r*e.aspect)).add(n.multiplyScalar(this._dollyControlCoord.y*r));this._targetEnd.lerp(s,a)}else if(Vu(this._camera)){let e=this._camera,t=ar.set(this._dollyControlCoord.x,this._dollyControlCoord.y,(e.near+e.far)/(e.near-e.far)).unproject(e),i=Ei.set(0,0,-1).applyQuaternion(e.quaternion),n=ry.copy(t).add(i.multiplyScalar(-t.dot(e.up))),r=-(this._zoom-this._dollyControlAmount-this._zoomEnd)/this._zoom,a=ar.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).normalize().negate(),s=this._targetEnd.dot(a);this._targetEnd.lerp(n,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=hE(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),qm.setFromMatrixColumn(this._camera.matrix,2),Gu.multiplyScalar(this._focalOffset.x),qu.multiplyScalar(-this._focalOffset.y),qm.multiplyScalar(this._focalOffset.z),ar.copy(Gu).add(qu).add(qm),this._camera.position.add(ar)),this._boundaryEnclosesCamera&&this._encloseToBoundary(this._camera.position.copy(this._target),ar.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(i,this.restThreshold)&&Vi(n,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:ty(this.maxDistance),minZoom:this.minZoom,maxZoom:ty(this.maxZoom),minPolarAngle:this.minPolarAngle,maxPolarAngle:ty(this.maxPolarAngle),minAzimuthAngle:ty(this.minAzimuthAngle),maxAzimuthAngle:ty(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:ar.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 i=JSON.parse(e),n=ar.fromArray(i.position);this.enabled=i.enabled,this.minDistance=i.minDistance,this.maxDistance=ny(i.maxDistance),this.minZoom=i.minZoom,this.maxZoom=ny(i.maxZoom),this.minPolarAngle=i.minPolarAngle,this.maxPolarAngle=ny(i.maxPolarAngle),this.minAzimuthAngle=ny(i.minAzimuthAngle),this.maxAzimuthAngle=ny(i.maxAzimuthAngle),this.smoothTime=i.smoothTime,this.draggingSmoothTime=i.draggingSmoothTime,this.dollySpeed=i.dollySpeed,this.truckSpeed=i.truckSpeed,this.dollyToCursor=i.dollyToCursor,this.verticalDragToForward=i.verticalDragToForward,this._target0.fromArray(i.target0),this._position0.fromArray(i.position0),this._zoom0=i.zoom0,this._focalOffset0.fromArray(i.focalOffset0),this.moveTo(i.target[0],i.target[1],i.target[2],t),Pc.setFromVector3(n.sub(this._targetEnd).applyQuaternion(this._yAxisUpSpace)),this.rotateTo(Pc.theta,Pc.phi,t),this.zoomTo(i.zoom,t),this.setFocalOffset(i.focalOffset[0],i.focalOffset[1],i.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,i){let n=t.lengthSq();if(0===n)return e;let r=Ei.copy(t).add(e),a=this._boundary.clampPoint(r,ry).sub(r),s=a.lengthSq();if(0===s)return e.add(t);if(s===n)return e;if(0===i)return e.add(t).add(a);{let n=1+i*s/t.dot(a);return e.add(Ei.copy(t).multiplyScalar(n)).add(a.multiplyScalar(1-i))}}_updateNearPlaneCorners(){if(If(this._camera)){let e=this._camera,t=e.near,i=e.getEffectiveFOV()*ey,n=Math.tan(.5*i)*t,r=n*e.aspect;this._nearPlaneCorners[0].set(-r,-n,0),this._nearPlaneCorners[1].set(r,-n,0),this._nearPlaneCorners[2].set(r,n,0),this._nearPlaneCorners[3].set(-r,n,0)}else if(Vu(this._camera)){let e=this._camera,t=1/e.zoom,i=e.left*t,n=e.right*t,r=e.top*t,a=e.bottom*t;this._nearPlaneCorners[0].set(i,r,0),this._nearPlaneCorners[1].set(n,r,0),this._nearPlaneCorners[2].set(n,a,0),this._nearPlaneCorners[3].set(i,a,0)}}_collisionTest(){let e=1/0;if(!(this.colliderMeshes.length>=1)||rC(this._camera,"_collisionTest"))return e;let t=ar.setFromSpherical(this._spherical).divideScalar(this._spherical.radius);b5.lookAt(Ufe,t,this._camera.up);for(let i=0;i<4;i++){let n=Ei.copy(this._nearPlaneCorners[i]);n.applyMatrix4(b5);let r=ry.addVectors(this._target,n);oC.set(r,t),oC.far=this._spherical.radius+1;let a=oC.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 i=t,n=i.center;iy.makeEmpty(),e.traverseVisible((e=>{e.isMesh&&iy.expandByObject(e)})),iy.getCenter(n);let r=0;return e.traverseVisible((e=>{if(!e.isMesh)return;let t=e,i=t.geometry.clone();if(i.applyMatrix4(t.matrixWorld),i.isBufferGeometry){let e=i.attributes.position;for(let t=0,i=e.count;t<i;t++)ar.fromBufferAttribute(e,t),r=Math.max(r,n.distanceToSquared(ar))}else{let e=i.attributes.position;for(let t=0,i=e.count;t<i;t++)ar.fromBufferAttribute(e,t),r=Math.max(r,n.distanceToSquared(ar))}})),i.radius=Math.sqrt(r),i}};Lf.install({THREE:Wt});var va=class extends Lf{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()}},Ol=class{constructor(e){this.name=e}},lC=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}},fE=class extends Ol{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)}},cC=class extends Ol{constructor(e,t,i){super("UpdateMarkup"),this.manager=e,this.oldData=t,this.newData=i}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)}},Wm=class extends Ol{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)}},pE=class extends Ol{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)}},sy=class extends Ol{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)}},qfe=new D,mE=class extends Ss{constructor(e,t){var i;super(),this.drawableList=new Zo("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=an.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 i=this.pickThreejsPositionByMouse(e);if(i){if(i.z=0,this.mouseDownPositionX=i.x,this.mouseDownPositionY=i.y,this.mousedownPoint=new xe(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(i);e&&(this.selectedShape=e,e.selected=!0,e instanceof Vm&&(this.isSelectLeaderText=e.isLeaderTextSelected(i)),this.render())}if(this.isCreateTextMode()&&this.mouseDown&&!this.selectedShape){this.creatingShape||(this.creatingShape=this.drawText(i,""));let t=this.creatingShape;0===t.text.length?(t.setTolerance(this.viewer.getPixelSizeInWorldCoord()),t.update([i]),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(qfe.subVectors(e,i).length()<5*this.viewer.getPixelSizeInWorldCoord())return i=this.tempPoints[0].clone(),this.tempPoints.push(i),void this.endDraw(this.creatingShape)}if(this.isDrawing=!0,this.tempPoints.push(i),!this.creatingShape){let e=this.creatingShape=this.drawLine([...this.tempPoints,i]);e&&this.addMarkup(e,!1)}this.creatingShape&&(this.creatingShape.update([...this.tempPoints,i]),this.render()),this.dispatchEvent("StartDraw",this.creatingShape)}if(this.isCreateDotMode()&&this.mouseDown&&!this.selectedShape){if(!this.creatingShape){let e=this.creatingShape=this.drawShape(i);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,i=t.y-this.mouseDownPositionY;this.selectedShape instanceof Vm&&this.isSelectLeaderText?this.selectedShape.translateLeaderText(e,i):this.selectedShape.translate(e,i),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 D(this.mouseDownPositionX,this.mouseDownPositionY,0);if(!this.creatingShape){let i=this.creatingShape=this.drawShape(e,t);i&&this.addMarkup(i,!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];qfe.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=>{var t;"Delete"===e.code?this.selectedShape&&(this.viewer.hasEventListener("BeforeRemoveMarkup")?this.viewer.dispatchEvent("BeforeRemoveMarkup",this.confirmToRemove.bind(this)):(this.removeMarkup(this.selectedShape),null==(t=this.viewer.undoRedoManager)||t.addCommand(new Wm(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.overlayRender,null==(i=this.overlayRender)||i.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 i=this.drawableList.getDrawables().get(e);return!!i&&(i.visible!==t&&(i.visible=t,this.render()),!0)}setMarkupsVisibility(e){let t=!1;this.drawableList.getDrawables().forEach((i=>{i.visible!==e&&(i.visible=e,t=!0)})),t&&this.render()}clearAll(){this.drawableList.clear(),this.isDrawing&&this.reset(),this.render()}isMarkupActive(){return this.activated}createMobileExitButton(){let e=this.viewer.widgetContainer,t=document.createElement("button");return t.innerText="X",t.style.cssText="position: absolute;right: 5%; top: 5%;background-color: #000000;color: #ffffff;padding: 3px 10px;font-weight: bolder;",null==e||e.appendChild(t),this.exitButton=t,this.exitButton.style.display="none",t.addEventListener("touchstart",(()=>{this.isDrawing&&this.endDraw(this.creatingShape),this.exitButton&&(this.exitButton.style.display="none")})),this.addEventListener("StartDraw",(()=>{this.exitButton&&(this.exitButton.style.display="inline")})),this.addEventListener("EndDraw",(()=>{this.exitButton&&(this.exitButton.style.display="none")})),this.exitButton}activate(){this.activated=!0,Fn.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);let e=this.viewer.controls;this.tempKey=e.mouseButtons.left,e.mouseButtons.left=yt.NONE,this.tempTouch=e.touches.one,e.touches.one=yt.NONE,this.tempArrowKeys=e.keys,e.keys={},this.render()}deactivate(){this.activated=!1,Fn.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.controls.mouseButtons.left=this.tempKey,this.viewer.controls.keys=this.tempArrowKeys,this.viewer.controls.touches.one=this.tempTouch,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,i=an.screen2Ndc(e,this.camera,this.viewerCanvas);this.raycaster.layers.set(10),this.raycaster.setFromCamera(i,this.camera);let n=this.viewer.scene,r=this.raycaster.intersectObject(this.viewer.groundPlane||n)||[];return r.length>0&&(t=r[0].point,t.z=0),t}pickThreejsPositionByMouse(e){return this.pickPositionByScreenPoint(new xe(e.x,e.y))}confirmToRemove(e){var t;this.selectedShape&&e&&(this.removeMarkup(this.selectedShape),null==(t=this.viewer.undoRedoManager)||t.addCommand(new Wm(this,this.selectedShape.getData())),this.selectedShape=void 0)}isEditing(){return!!this.initialDataForEditing}endEdit(e){var t;if(!this.initialDataForEditing)return;let i=e.getData();this.viewer.dispatchEvent("MarkupUpdated",{oldData:this.initialDataForEditing,newData:i}),this.dispatchEvent("EndEdit",e),null==(t=this.viewer.undoRedoManager)||t.addCommand(new cC(this,this.initialDataForEditing,i)),this.initialDataForEditing=void 0,this.isSelectLeaderText=!1}endDraw(e){var t;if("PolylineMarkup"===this.type&&this.creatingShape&&(this.tempPoints.length<2?(this.removeMarkup(this.creatingShape,!1),this.creatingShape=void 0):this.creatingShape.update(this.tempPoints)),e){let i=e.getData();this.viewer.dispatchEvent("MarkupAdded",i),null==(t=this.viewer.undoRedoManager)||t.addCommand(new fE(this,i))}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,i=!0){this.drawableList.updateDrawable(e,t),this.render(),i&&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 Un.createDrawable(e)}getMarkupById(e){return this.drawableList.getDrawableById(e)}getMarkupData(){return this.drawableList.getDrawableDatas()}setMarkupData(e){var t,i;null==(t=this.viewer.undoRedoManager)||t.startTransaction(),e.forEach((e=>{var t;this.addMarkup(this.createMarkup(e)),null==(t=this.viewer.undoRedoManager)||t.addCommand(new fE(this,e))})),null==(i=this.viewer.undoRedoManager)||i.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 i=[[e.x,e.y]];return t&&i.push([t.x,t.y]),Un.createDrawable({id:St.guid(),lineWidth:this.lineWidth,lineColor:this.lineColor,fillColor:this.fillColor,type:this.type,points:i})}drawLine(e){return Un.createDrawable({id:St.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 Un.createDrawable({id:St.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()}},Wfe=new D,jm=class extends Hi{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 i=0;i<e.length;i++){let n=e[i],r=[new D(n.min.x,n.min.y),new D(n.max.x,n.min.y),new D(n.max.x,n.max.y),new D(n.min.x,n.max.y),new D(n.min.x,n.min.y)],a=Wfe.subVectors(r[0],r[2]).length()/10||1e-4,s=[];for(let e=0;e<r.length-1;e++){let t=r[e],i=r[e+1],n=Wfe.subVectors(i,t),o=n.length(),l=n.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 i=0;i<this.lineSegments.length;i++){let n=this.lineSegments[i];this.drawBox(e,t,n)}}drawBox(e,t,i){e.beginPath();for(let n=0;n<i.length-1;n++){let r=this.transToScreenCoord(i[n],t),a=this.transToScreenCoord(i[n+1],t),s=Cc.getControlPointByTwoPoints(a,r);0===n&&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 i=this.boxes[t];e.union(i)}return e}getClassType(){return"CompareDrawable"}};Un._registerDrawableClass(jm);var ay="BYLAYER",oy="BYBLOCK",jfe=(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))(jfe||{}),Xm=["INSERT","DIMENSION"],r6t=Xi(Kfe(),1),uC=[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],ly=class{constructor(){this.pointer=0,this.eof=!1}},T5=Xi(Jfe(),1),Df=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 i=0;i<e;i++)t+=String.fromCharCode(this.data.getInt8(this.position+i));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 i=0;i<e;i++)t[i]=this.data.getUint8(this.position+i);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=T5.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=T5.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}},Qfe=1e3,vE=class extends ly{constructor(e){super(),this.int8Array=new Int8Array(Qfe),this.caches=new Map,this.reader=new Df(e);let t=this.reader.readBytes(22),i="";for(let n=0;n<18;n++)i+=String.fromCharCode(t[n]);if("AutoCAD Binary DXF"!=i)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 epe(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?epe(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 se.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,i=this.reader.readInt8();for(;0!==i;)this.int8Array[t++]=i,i=this.reader.readInt8();if(0===t)return"";if(t>Qfe)return se.warn(`[DxfBinReader] Failed to read string! The number of bytes is ${t} !`),"";let n=this.int8Array.subarray(0,t),r=n.toString();if(this.caches.get(r))return this.caches.get(r);let a=null==(e=this.decoder)?void 0:e.decode(n);return this.caches.set(r,a),a}ReadBinaryData(){let e=this.reader.readUint8();return this.reader.readBytes(e)}};function epe(e){return Array.prototype.map.call(e,(e=>("00"+e.toString(16)).slice(-2))).join("")}var cy=class extends ly{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=Bct(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 Bct(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?Uct(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):(se.info("WARNING: Group code does not have a defined type: %j",{code:e,value:t}),t)}function Uct(e){if("0"===e)return!1;if("1"===e)return!0;throw TypeError("String '"+e+"' cannot be cast to Boolean type")}var rpe=Xi(kl(),1),Hct="OriginalHandle",Vct="OriginalType",zct="Outlines",tpe=["PROXY","REGION","INSERT","HATCH"];function Ym(e){return uC[e]}function kt(e){let t={},i=e.lastReadGroup,n=i.code;if(t.x=i.value,n+=10,i=e.next(),i.code!=n)throw new Error(`Expected code for point value to be ${n} but got ${i.code}`);return t.y=i.value,n+=10,i=e.next(),i.code!=n||(t.z=i.value,e.next()),t}function npe(e,t){let i=e.lastReadGroup,n=[];for(let r=0;r<16;r++){if(i.code!==t)throw new Error(`Expected code for matrix value to be ${t} but got ${i.code}`);n.push(i.value),i=e.next()}return n}function Nn(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&&se.warn("[DxfParser] a negative value of colorIndex indicates that the layer is turned off"),e.color=Ym(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(Hct)){let i=t.value.split(":").map((e=>e.trim()));e.extendedData||(e.extendedData={}),e.extendedData.originalHandle=i[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(zct)&&(e.extendedData||(e.extendedData={}),e.extendedData.outlines=[]),t.value&&t.value.includes(Vct)){let i=t.value.split(":").map((e=>e.trim()));e.extendedData||(e.extendedData={}),e.extendedData.originalType=i[1]}break;default:return!1}return!0}function Fl(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 xE=class{constructor(){this.ForEntityName="3DFACE"}parseEntity(e,t){let i={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;i.vertices.splice(e,1)}t=e.next();break;case 10:i.vertices=Gct(e,t),t=e.lastReadGroup;break;case 101:for(;0!=t.code;)t=e.next();break;default:Nn(i,t),t=e.next()}return i}};function Gct(e,t){let i=[],n=!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(n){r=!0;continue}a.x=t.value,n=!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 i}t=e.next()}(0,rpe.isEmpty)(a)||i.push(a),n=!1,r=!1}return i}var bE=class{constructor(){this.ForEntityName="ARC"}parseEntity(e,t){let i={type:t.value};for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 10:i.center=kt(e),t=e.lastReadGroup;break;case 40:i.radius=t.value,t=e.next();break;case 50:i.startAngle=Math.PI/180*t.value,t=e.next();break;case 51:i.endAngle=Math.PI/180*t.value,i.angleLength=i.endAngle-i.startAngle,t=e.next();break;case 210:i.extrusionDirectionX=t.value,t=e.next();break;case 220:i.extrusionDirectionY=t.value,t=e.next();break;case 230:i.extrusionDirectionZ=t.value,t=e.next();break;case 101:for(;0!=t.code;)t=e.next();break;default:Nn(i,t),t=e.next()}return i}},EE=class{constructor(){this.ForEntityName="ATTDEF"}parseEntity(e,t){let i={type:t.value,xScale:1,textStyle:"STANDARD"};for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 1:i.text=t.value,t=e.next();break;case 2:i.tag=t.value,t=e.next();break;case 3:i.prompt=t.value,t=e.next();break;case 7:i.textStyle=t.value,t=e.next();break;case 10:i.startPoint=kt(e),t=e.lastReadGroup;break;case 11:i.endPoint=kt(e),t=e.lastReadGroup;break;case 39:i.thickness=t.value,t=e.next();break;case 40:i.textHeight=t.value,t=e.next();break;case 41:i.xScale=t.value,t=e.next();break;case 50:i.rotation=t.value,t=e.next();break;case 51:i.obliqueAngle=t.value,t=e.next();break;case 70:i.invisible=!!(1&t.value),i.constant=!!(2&t.value),i.verificationRequired=!!(4&t.value),i.preset=!!(8&t.value),t=e.next();break;case 71:i.backwards=!!(2&t.value),i.mirrored=!!(4&t.value),t=e.next();break;case 72:i.horizontalJustification=t.value,t=e.next();break;case 73:i.fieldLength=t.value,t=e.next();break;case 74:i.verticalJustification=t.value,t=e.next();break;case 100:t=e.next();break;case 210:i.extrusionDirectionX=t.value,t=e.next();break;case 220:i.extrusionDirectionY=t.value,t=e.next();break;case 230:i.extrusionDirectionZ=t.value,t=e.next();break;case 101:for(;0!=t.code;)t=e.next();break;default:Nn(i,t),t=e.next()}return i}},_E=class{constructor(){this.ForEntityName="ATTRIB"}parseEntity(e,t){let i={type:t.value,xScale:1,textStyle:"STANDARD"};for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 1:i.text=t.value,t=e.next();break;case 2:i.tag=t.value,t=e.next();break;case 3:i.prompt=t.value,t=e.next();break;case 7:i.textStyle=t.value,t=e.next();break;case 10:i.startPoint=kt(e),t=e.lastReadGroup;break;case 11:i.endPoint=kt(e),t=e.lastReadGroup;break;case 39:i.thickness=t.value,t=e.next();break;case 40:i.textHeight=t.value,t=e.next();break;case 41:i.xScale=t.value,t=e.next();break;case 50:i.rotation=t.value,t=e.next();break;case 51:i.obliqueAngle=t.value,t=e.next();break;case 70:i.invisible=!!(1&t.value),i.constant=!!(2&t.value),i.verificationRequired=!!(4&t.value),i.preset=!!(8&t.value),t=e.next();break;case 71:i.backwards=!!(2&t.value),i.mirrored=!!(4&t.value),t=e.next();break;case 72:i.horizontalJustification=t.value,t=e.next();break;case 73:i.fieldLength=t.value,t=e.next();break;case 74:i.verticalJustification=t.value,t=e.next();break;case 100:t=e.next();break;case 210:i.extrusionDirectionX=t.value,t=e.next();break;case 220:i.extrusionDirectionY=t.value,t=e.next();break;case 230:i.extrusionDirectionZ=t.value,t=e.next();break;case 101:for(;0!=t.code;)t=e.next();break;default:Nn(i,t),t=e.next()}return i}},TE=class{constructor(){this.ForEntityName="CIRCLE"}parseEntity(e,t){let i={type:t.value};for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 10:i.center=kt(e),t=e.lastReadGroup;break;case 40:i.radius=t.value,t=e.next();break;case 50:i.startAngle=Math.PI/180*t.value,t=e.next();break;case 51:let n=Math.PI/180*t.value;n<i.startAngle?i.angleLength=n+2*Math.PI-i.startAngle:i.angleLength=n-i.startAngle,i.endAngle=n,t=e.next();break;case 101:for(;0!=t.code;)t=e.next();break;default:Nn(i,t),t=e.next()}return i}},wE=class{constructor(){this.ForEntityName="DIMENSION"}parseEntity(e,t){let i={type:t.value};for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 2:i.block=t.value,t=e.next();break;case 3:i.dimStyleName=t.value,t=e.next();break;case 10:i.anchorPoint=kt(e),t=e.lastReadGroup;break;case 11:i.middleOfText=kt(e),t=e.lastReadGroup;break;case 12:i.insertionPoint=kt(e),t=e.lastReadGroup;break;case 13:i.linearOrAngularPoint1=kt(e),t=e.lastReadGroup;break;case 14:i.linearOrAngularPoint2=kt(e),t=e.lastReadGroup;break;case 15:i.diameterOrRadiusPoint=kt(e),t=e.lastReadGroup;break;case 16:i.arcPoint=kt(e),t=e.lastReadGroup;break;case 70:i.dimensionType=t.value,t=e.next();break;case 71:i.attachmentPoint=t.value,t=e.next();break;case 42:i.actualMeasurement=t.value,t=e.next();break;case 1:i.text=t.value,t=e.next();break;case 50:i.angle=t.value,t=e.next();break;case 101:for(;0!=t.code;)t=e.next();break;default:Nn(i,t),t=e.next()}return i}},SE=class{constructor(){this.ForEntityName="ELLIPSE"}parseEntity(e,t){let i={type:t.value};for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 10:i.center=kt(e),t=e.lastReadGroup;break;case 11:i.majorAxisEndPoint=kt(e),t=e.lastReadGroup;break;case 40:i.axisRatio=t.value,t=e.next();break;case 41:i.startAngle=t.value,t=e.next();break;case 42:i.endAngle=t.value,t=e.next();break;case 210:i.extrusionDirection=kt(e),t=e.lastReadGroup;break;case 2:i.name=t.value,t=e.next();break;default:Nn(i,t),t=e.next()}return i}},$m=class{constructor(e){this.type=e}},w5=class extends $m{constructor(){super(0),this.points=[],this.isClosed=!0}},S5=class extends $m{constructor(){super(1),this.startPoint={x:0,y:0,z:0},this.endPoint={x:0,y:0,z:0}}},M5=class extends $m{constructor(){super(2),this.center={x:0,y:0,z:0},this.radius=0,this.startAngle=0,this.endAngle=0,this.bCounterclockwise=!1}},R5=class extends $m{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}},A5=class extends $m{constructor(){super(4),this.controlPoints=[],this.numControlPoints=0,this.knotValues=[],this.numKnots=0,this.bPeriodic=!1,this.bRational=!1,this.degreeOfSplineCurve=0}},ME=class{constructor(){this.ForEntityName="HATCH"}parseEntity(e,t){let i={type:t.value,boundaryPaths:[]};for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 2:i.patternName=t.value,t=e.next();break;case 10:i.elevationX=t.value,t=e.next();break;case 20:i.elevationY=t.value,t=e.next();break;case 30:i.elevationZ=t.value,t=e.next();break;case 41:i.patternScale=t.value,t=e.next();break;case 47:i.pixelSize=t.value,t=e.next();break;case 52:i.patternAngle=t.value,t=e.next();break;case 63:i.patternFillColor=t.value,t=e.next();break;case 70:i.solidFill=0!=(1&t.value),t=e.next();break;case 71:i.associativity=0!=(1&t.value),t=e.next();break;case 73:i.annotatedBoundary=0!=(1&t.value),t=e.next();break;case 75:i.style=t.value,t=e.next();break;case 76:i.patternType=t.value,t=e.next();break;case 78:i.patternLines=Xct(t.value,e),t=e.lastReadGroup;break;case 91:i.boundaryPathsCount=t.value,i.boundaryPaths=jct(i.boundaryPathsCount,e),t=e.lastReadGroup;break;case 98:i.seedPointsCount=t.value,t=e.next();break;case 210:i.extrusionDirectionX=t.value,t=e.next();break;case 220:i.extrusionDirectionY=t.value,t=e.next();break;case 230:i.extrusionDirectionZ=t.value,t=e.next();break;case 450:i.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:i.gradientColorCount=t.value,i.gradientColors=Yct(i.gradientColorCount,e),t=e.next();break;case 101:for(;0!=t.code;)t=e.next();break;default:Nn(i,t),t=e.next()}return i}};function qct(e){let t=new w5,i=e.next(),n=0!==i.value;i=e.next(),t.isClosed=0!==i.value,i=e.next();let r=i.value;i=e.next();for(let s=0;s<r;s++){let r=kt(e);i=e.lastReadGroup,n&&(r.bulge=i.value,i=e.next()),t.points.push(r)}i=e.lastReadGroup,console.assert(97===i.code,"The reference count code 97 was expected.");let a=i.value;i=e.next();for(let s=0;s<a;s++)console.assert(330===i.code,"The reference handle code 330 was expected."),i=e.next();return{edges:[t],pathTypeFlag:-1}}function Wct(e,t){let i=[],n=t.next();for(;i.length<e;)if(72===n.code)switch(n.value){case 1:{n=t.next();let e=new S5;e.startPoint=kt(t),e.endPoint=kt(t),n=t.lastReadGroup,i.push(e);break}case 2:{n=t.next();let e=new M5;e.center=kt(t),n=t.lastReadGroup,e.radius=n.value,n=t.next(),e.startAngle=n.value,n=t.next(),e.endAngle=n.value,n=t.next(),e.bCounterclockwise=0!==n.value,n=t.next(),i.push(e);break}case 3:{n=t.next();let e=new R5;e.center=kt(t),e.majorAxisEndPoint=kt(t),n=t.lastReadGroup,e.minorRatio=n.value,n=t.next(),e.startAngle=n.value,n=t.next(),e.endAngle=n.value,n=t.next(),e.bCounterclockwise=0!==n.value,n=t.next(),i.push(e);break}case 4:{n=t.next();let e=new A5;e.degreeOfSplineCurve=n.value,n=t.next(),e.bRational=0!==n.value,n=t.next(),e.bPeriodic=0!==n.value,n=t.next(),e.numKnots=n.value,n=t.next(),e.numControlPoints=n.value,n=t.next();for(let i=0;i<e.numKnots;i++)e.knotValues.push(n.value),n=t.next();for(let i=0;i<e.numControlPoints;i++){let i=n.value;n=t.next();let r=n.value,a=1;n=t.next(),42===n.code&&(a=n.value,n=t.next()),e.controlPoints.push({x:i,y:r,z:a})}i.push(e);break}default:n=t.next()}else n=t.next();n=t.lastReadGroup,console.assert(97===n.code,"The reference count code 97 was expected.");let r=n.value;n=t.next();for(let a=0;a<r;a++)console.assert(330===n.code,"The reference handle code 330 was expected."),n=t.next();return{edges:i,pathTypeFlag:-1}}function jct(e,t){let i=[],n=-1,r=t.next();for(;i.length<e;){let e;switch(r.code){case 92:if(n=r.value,2&n){if(e=qct(t),!e)throw new Error("[Hatch] Failed to parse hatch polyline boundary path !");e.pathTypeFlag=n,i.push(e),r=t.lastReadGroup}else r=t.next();break;case 93:e=Wct(r.value,t),e.pathTypeFlag=n,i.push(e),r=t.lastReadGroup;break;default:r=t.next()}}return i}function Xct(e,t){if(e<=0)return void t.next();let i=[],n=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!==n.code;){let i=!1;switch(n.code){case 53:e=n.value;break;case 43:r.x=n.value;break;case 44:r.y=n.value;break;case 45:a.x=n.value;break;case 46:a.y=n.value;break;case 79:s=n.value;break;case 49:o.push(n.value);break;default:i=!0}if(n=t.next(),i||o.length===s)break}s>=0&&i.push({angle:e,origin:r,delta:a,dashPattern:o})}return i}function Yct(e,t){let i=[],n=t.next();for(;i.length<e;)switch(n.code){case 63:default:n=t.next();break;case 421:i.push(n.value),n=t.next()}return i}var RE=class{constructor(){this.ForEntityName="IMAGE"}parseEntity(e,t){let i={type:t.value,clippingBoundaryPath:[]};for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 10:i.position=kt(e),t=e.lastReadGroup;break;case 11:i.uPixel=kt(e),t=e.lastReadGroup;break;case 12:i.vPixel=kt(e),t=e.lastReadGroup;break;case 13:i.imageSize=kt(e),t=e.lastReadGroup;break;case 340:i.imageDefHandle=t.value,t=e.next();break;case 70:i.flags=t.value,t=e.next();break;case 280:i.clipping=t.value,t=e.next();break;case 281:i.brightness=t.value,t=e.next();break;case 282:i.contrast=t.value,t=e.next();break;case 283:i.fade=t.value,t=e.next();break;case 360:i.imageDefReactorHandle=t.value,t=e.next();break;case 71:i.clippingBoundaryType=t.value,t=e.next();break;case 91:i.countBoundaryPoints=t.value,t=e.next();break;case 14:i.clippingBoundaryPath.push(kt(e)),t=e.lastReadGroup;break;case 290:i.clipMode=t.value,t=e.next();default:Nn(i,t),t=e.next()}return i}},AE=class{constructor(){this.ForEntityName="INSERT"}parseEntity(e,t){let i={type:t.value};for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 2:i.block=t.value,t=e.next();break;case 66:i.attributesFollow=0!=t.value,t=e.next();break;case 41:i.xScale=t.value,t=e.next();break;case 42:i.yScale=t.value,t=e.next();break;case 43:i.zScale=t.value,t=e.next();break;case 10:i.position=kt(e),t=e.lastReadGroup;break;case 50:i.rotation=t.value,t=e.next();break;case 70:i.columnCount=t.value,t=e.next();break;case 71:i.rowCount=t.value,t=e.next();break;case 44:i.columnSpacing=t.value,t=e.next();break;case 45:i.rowSpacing=t.value,t=e.next();break;case 210:i.extrusionDirection=kt(e),t=e.lastReadGroup;break;case 101:for(;0!=t.code;)t=e.next();break;default:Nn(i,t),t=e.next()}return i}},CE=class{constructor(){this.ForEntityName="LEADER"}parseEntity(e,t){let i={type:t.value,arrowFlag:1,vertices:[]};t=e.next();let n=!1;for(;!e.isEOF()&&0!==t.code;)switch(t.code){case 10:i.vertices.push(kt(e)),t=e.lastReadGroup;break;case 3:i.dimensionStyle=t.value,t=e.next();break;case 40:i.textHeight=t.value,t=e.next();break;case 41:i.textWidth=t.value,t=e.next();break;case 71:i.arrowFlag=t.value,t=e.next();break;case 72:i.pathType=t.value,t=e.next();break;case 73:i.creationFlag=t.value,t=e.next();break;case 74:i.direction=t.value,t=e.next();break;case 75:i.hasHookline=1===t.value,t=e.next();break;case 1001:n="ACAD"===t.value,t=e.next();break;case 1070:if(n){let n=$ct(t.value);n&&(1005==(t=e.next()).code||1040==t.code||1070==t.code)&&("DIMLDRBLK"===n&&(i.arrowHeadBlockHandle=t.value),"DIMASZ"===n&&(i.arrowHeight=t.value),"DIMSCALE"===n&&(i.arrowHeadScale=t.value),"DIMCLRD"===n&&t.value>0&&(i.colorIndex=t.value,i.color=Ym(Math.abs(t.value))))}t=e.next();break;default:Nn(i,t),t=e.next()}return i}};function $ct(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 PE=class{constructor(){this.ForEntityName="LINE"}parseEntity(e,t){let i={type:t.value,vertices:[]};for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 10:i.vertices.unshift(kt(e)),t=e.lastReadGroup;break;case 11:i.vertices.push(kt(e)),t=e.lastReadGroup;break;case 210:i.extrusionDirection=kt(e),t=e.lastReadGroup;break;case 100:t=e.next();break;case 101:for(;0!=t.code;)t=e.next();break;default:Nn(i,t),t=e.next()}return i}},IE=class{constructor(){this.ForEntityName="LWPOLYLINE"}parseEntity(e,t){let i={type:t.value,vertices:[]},n=0;for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 38:i.elevation=t.value,t=e.next();break;case 39:i.thickness=t.value,t=e.next();break;case 70:i.shape=1==(1&t.value),i.hasContinuousLinetypePattern=128==(128&t.value),t=e.next();break;case 90:n=t.value,t=e.next();break;case 10:i.vertices.push(...Zct(n,e)),t=e.lastReadGroup;break;case 43:0!==t.value&&(i.constantWidth=t.value),t=e.next();break;case 210:i.extrusionDirectionX=t.value,t=e.next();break;case 220:i.extrusionDirectionY=t.value,t=e.next();break;case 230:i.extrusionDirectionZ=t.value,t=e.next();break;case 101:for(;0!=t.code;)t=e.next();break;default:Nn(i,t),t=e.next()}return i}};function Zct(e,t){if(!e||e<=0)throw Error("n must be greater than 0 verticies");let i=[],n=!1,r=!1,a=t.lastReadGroup,s={};for(;!t.isEOF()&&0!==a.code&&!r;)switch(a.code){case 10:if(n){r=!0;continue}s.x=a.value,n=!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 n&&i.push(s),i}return i.push(s),n=!1,r=!1,i}var LE=class{constructor(){this.ForEntityName="MULTILEADER"}parseEntity(e,t){let i={type:t.value};function n(){for(;!e.isEOF();)switch(t.code){case 40:i.contextData.contentScale=t.value,t=e.next();break;case 10:i.contextData.contentBasePosition=kt(e),t=e.lastReadGroup;break;case 145:i.contextData.landingGap=t.value,t=e.next();break;case 290:i.contextData.hasMText=t.value,t=e.next();break;case 304:i.contextData.defaultTextContents=t.value,t=e.next();break;case 11:i.contextData.textNormalDirection=kt(e),t=e.lastReadGroup;break;case 12:i.contextData.textLocation=kt(e),t=e.lastReadGroup;break;case 13:i.contextData.textDirection=kt(e),t=e.lastReadGroup;break;case 140:i.contextData.arrowHeadSize=t.value,t=e.next();break;case 41:i.contextData.textHeight=t.value,t=e.next();break;case 42:i.contextData.textRotation=t.value,t=e.next();break;case 43:i.contextData.textWidth=t.value,t=e.next();break;case 44:default:t=e.next();break;case 45:i.contextData.textLineSpacingFactor=t.value,t=e.next();break;case 90:i.contextData.textColor=t.value,t=e.next();break;case 170:i.contextData.textLineSpacingStyle=t.value,t=e.next();break;case 171:i.contextData.textAttachment=t.value,t=e.next();break;case 172:i.contextData.textFlowDirection=t.value,t=e.next();break;case 141:i.contextData.textBackgroundScaleFactor=t.value,t=e.next();break;case 92:i.contextData.textBackgroundTransparency=t.value,t=e.next();break;case 291:i.contextData.textBackgroundColorOn=t.value,t=e.next();break;case 292:i.contextData.textBackgroundFillOn=t.value,t=e.next();break;case 293:i.contextData.textUseAutoHeight=t.value,t=e.next();break;case 173:i.contextData.textColumnType=t.value,t=e.next();break;case 142:i.contextData.textColumnWidth=t.value,t=e.next();break;case 143:i.contextData.textColumnGutterWidth=t.value,t=e.next();break;case 144:i.contextData.textColumnHeight=t.value,t=e.next();break;case 295:i.contextData.textUseWordBreak=t.value,t=e.next();break;case 296:i.contextData.hasBlock=t.value,t=e.next();break;case 341:i.contextData.blockContentId=t.value,t=e.next();break;case 14:i.contextData.blockContentNormalDirection=kt(e),t=e.lastReadGroup;break;case 15:i.contextData.blockContentPosition=kt(e),t=e.lastReadGroup;break;case 16:i.contextData.blockContentScale=t.value,t=e.next();break;case 46:i.contextData.blockContentRotation=t.value,t=e.next();break;case 93:i.contextData.blockContentColor=t.value,t=e.next();break;case 47:i.contextData.blockTransformationMatrix=npe(e,47),t=e.lastReadGroup;break;case 110:i.contextData.planeOriginPoint=kt(e),t=e.lastReadGroup;break;case 111:i.contextData.planeXAxisDirection=kt(e),t=e.lastReadGroup;break;case 112:i.contextData.planeYAxisDirection=kt(e),t=e.lastReadGroup;break;case 297:i.contextData.planeNormalReversed=t.value,t=e.next();break;case 301:return;case 302:r(),t=e.lastReadGroup}}function r(){let n={leaderLines:[]};for(i.contextData.leaders.push(n);!e.isEOF();)switch(t.code){case 290:n.hasSetLastLeaderLinePoint=t.value,t=e.next();break;case 291:n.hasSetDoglegVector=t.value,t=e.next();break;case 10:n.lastLeaderLinePoint=kt(e),t=e.lastReadGroup;break;case 11:n.doglegVector=kt(e),t=e.lastReadGroup;break;case 90:n.leaderBranchIndex=t.value,t=e.next();break;case 40:n.doglegLength=t.value,t=e.next();break;case 303:return;case 304:a(),t=e.lastReadGroup;break;default:t=e.next()}}function a(){let n={vertices:[[]]};for(i.contextData.leaders[i.contextData.leaders.length-1].leaderLines.push(n);!e.isEOF();)switch(t.code){case 10:n.vertices[0].push(kt(e)),t=e.lastReadGroup;break;case 305:return;default:t=e.next()}}return i.contextData={leaders:[]},t=e.next(),function(){for(;!e.isEOF();)switch(t.code){case 0:return;case 340:i.leaderStyleId=t.value,t=e.next();break;case 170:i.leaderLineType=t.value,t=e.next();break;case 91:i.leaderLineColor=t.value,t=e.next();break;case 341:i.leaderLineTypeId=t.value,t=e.next();break;case 171:i.leaderLineWeight=t.value,t=e.next();break;case 41:i.doglegLength=t.value,t=e.next();break;case 290:i.enableLanding=t.value,t=e.next();break;case 291:i.enableDogLeg=t.value,t=e.next();break;case 342:i.arrowHeadId=t.value,t=e.next();break;case 42:i.arrowHeadSize=t.value,t=e.next();break;case 172:i.contentType=t.value,t=e.next();break;case 173:case 95:i.textLeftAttachmentType=t.value,t=e.next();break;case 174:i.textAngleType=t.value,t=e.next();break;case 175:i.textAlignmentType=t.value,t=e.next();break;case 343:i.textStyleId=t.value,t=e.next();break;case 92:i.textColor=t.value,t=e.next();break;case 292:i.enableFrameText=t.value,t=e.next();break;case 344:i.blockContentId=t.value,t=e.next();break;case 93:i.blockContentColor=t.value,t=e.next();break;case 10:i.blockContentScale=kt(e),t=e.lastReadGroup;break;case 43:i.blockContentRotation=t.value,t=e.next();break;case 176:i.blockContentConnectionType=t.value,t=e.next();break;case 293:i.enableAnotationScale=t.value,t=e.next();break;case 94:i.arrowHeadIndex=t.value,t=e.next();break;case 177:i.blockAttributeIndex=t.value,t=e.next();break;case 44:i.blockAttributeWidth=t.value,t=e.next();break;case 302:i.blockAttributeTextString=t.value,t=e.next();break;case 294:i.textDirectionNegative=t.value,t=e.next();break;case 178:i.textAlignInIPE=t.value,t=e.next();break;case 179:i.textAttachmentPoint=t.value,t=e.next();break;case 271:i.textAttachmentDirectionMText=t.value,t=e.next();break;case 272:i.textAttachmentDirectionBottom=t.value,t=e.next();break;case 273:i.textAttachmentDirectionTop=t.value,t=e.next();break;case 300:n(),t=e.lastReadGroup;break;case 101:for(;0!=t.code;)t=e.next();break;default:Nn(i,t),t=e.next()}}(),i}},DE=class{constructor(){this.ForEntityName="MTEXT"}parseEntity(e,t){let i={type:t.value};for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 3:case 1:i.text?i.text+=t.value:i.text=t.value,t=e.next();break;case 10:i.position=kt(e),t=e.lastReadGroup;break;case 7:i.textStyle=t.value,t=e.next();break;case 44:i.lineSpaceFactor=t.value,t=e.next();break;case 11:i.directionVector=kt(e),i.rotation=void 0,t=e.lastReadGroup;break;case 40:i.height=t.value,t=e.next();break;case 41:i.width=t.value,t=e.next();break;case 50:i.rotation=t.value,i.directionVector=void 0,t=e.next();break;case 71:i.attachmentPoint=t.value,t=e.next();break;case 72:i.drawingDirection=t.value,t=e.next();break;case 101:for(;0!=t.code;)t=e.next();break;default:Nn(i,t),t=e.next()}return i}},OE=class{constructor(){this.ForEntityName="OLE2FRAME"}parseEntity(e,t){let i={type:t.value,binaryData:""};for(t=e.next();"OLE"!==t.value&&0!==t.code;)switch(t.code){case 3:i.documentType=t.value,t=e.next();break;case 70:i.version=t.value,t=e.next();break;case 10:i.leftUpX=t.value,t=e.next();break;case 20:i.leftUpY=t.value,t=e.next();break;case 30:i.leftUpZ=t.value,t=e.next();break;case 11:i.rightDownX=t.value,t=e.next();break;case 21:i.rightDownY=t.value,t=e.next();break;case 31:i.rightDownZ=t.value,t=e.next();break;case 90:i.lengthOfBinaryData=t.value,t=e.next();break;case 310:i.binaryData+=t.value,t=e.next();break;case 101:for(;0!=t.code;)t=e.next();break;default:Nn(i,t),t=e.next()}return i}},kE=class{constructor(){this.ForEntityName="POINT"}parseEntity(e,t){let i={type:t.value};for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 10:i.position=kt(e),t=e.lastReadGroup;break;case 39:i.thickness=t.value,t=e.next();break;case 210:i.extrusionDirection=kt(e),t=e.lastReadGroup;break;case 100:t=e.next();break;case 101:for(;0!=t.code;)t=e.next();break;default:Nn(i,t),t=e.next()}return i}},FE=class{constructor(){this.ForEntityName="VERTEX"}parseEntity(e,t){var i={type:t.value};for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 10:i.x=t.value,t=e.next();break;case 20:i.y=t.value,t=e.next();break;case 30:i.z=t.value,t=e.next();break;case 40:case 41:case 50:t=e.next();break;case 42:0!=t.value&&(i.bulge=t.value),t=e.next();break;case 70:i.curveFittingVertex=0!=(1&t.value),i.curveFitTangent=0!=(2&t.value),i.splineVertex=0!=(8&t.value),i.splineControlPoint=0!=(16&t.value),i.threeDPolylineVertex=0!=(32&t.value),i.threeDPolylineMesh=0!=(64&t.value),i.polyfaceMeshVertex=0!=(128&t.value),t=e.next();break;case 71:i.faceA=t.value,t=e.next();break;case 72:i.faceB=t.value,t=e.next();break;case 73:i.faceC=t.value,t=e.next();break;case 74:i.faceD=t.value,t=e.next();break;case 101:for(;0!=t.code;)t=e.next();break;default:Nn(i,t),t=e.next()}return i}},NE=class{constructor(){this.ForEntityName="POLYLINE"}parseEntity(e,t){var i={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(),i.thickness=t.value;break;case 70:i.shape=0!=(1&t.value),i.includesCurveFitVertices=0!=(2&t.value),i.includesSplineFitVertices=0!=(4&t.value),i.is3dPolyline=0!=(8&t.value),i.is3dPolygonMesh=0!=(16&t.value),i.is3dPolygonMeshClosed=0!=(32&t.value),i.isPolyfaceMesh=0!=(64&t.value),i.hasContinuousLinetypePattern=0!=(128&t.value),t=e.next();break;case 210:i.extrusionDirection=kt(e),t=e.lastReadGroup;break;case 101:for(;0!=t.code;)t=e.next();break;default:Nn(i,t),t=e.next()}return i.vertices=Kct(e,t),i}};function Kct(e,t){let i=new FE,n=[];for(;!e.isEOF();)if(0===t.code)if("VERTEX"===t.value)n.push(i.parseEntity(e,t)),t=e.lastReadGroup;else if("SEQEND"===t.value){Jct(e,t);break}return n}function Jct(e,t){let i={type:t.value};for(t=e.next();!e.isEOF()&&0!==t.code;)if(101===t.code)for(;0!=t.code;)t=e.next();else Nn(i,t),t=e.next();return i}var BE=class{constructor(){this.ForEntityName="RAY"}parseEntity(e,t){let i={type:t.value,vertices:[]};for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 10:i.vertices.unshift(kt(e)),t=e.lastReadGroup;break;case 11:i.directionVector=kt(e),t=e.lastReadGroup;break;case 100:t=e.next();break;case 101:for(;0!=t.code;)t=e.next();break;default:Nn(i,t),t=e.next()}return i}},UE=class{constructor(){this.ForEntityName="REGION"}parseEntity(e,t){let i={type:t.value};for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 70:i.modelerVersion=t.value,t=e.next();break;case 1:i.proprietaryData=t.value,t=e.next();break;case 3:i.proprietaryData+=t.value,t=e.next();break;case 101:for(;0!=t.code;)t=e.next();break;default:Nn(i,t),t=e.next()}return i}},HE=class{constructor(){this.ForEntityName="SEQEND"}parseEntity(e,t){let i={type:t.value};for(t=e.next();!e.isEOF()&&0!==t.code;)-2===t.code||(Nn(i,t),t=e.next());return i}},VE=class{constructor(){this.ForEntityName="SOLID"}parseEntity(e,t){let i={type:t.value,points:[]};for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 10:i.points[0]=kt(e),t=e.lastReadGroup;break;case 11:i.points[1]=kt(e),t=e.lastReadGroup;break;case 12:i.points[2]=kt(e),t=e.lastReadGroup;break;case 13:i.points[3]=kt(e),t=e.lastReadGroup;break;case 210:i.extrusionDirection=kt(e),t=e.lastReadGroup;break;case 101:for(;0!=t.code;)t=e.next();break;default:Nn(i,t),t=e.next()}return i}},zE=class{constructor(){this.ForEntityName="SPLINE"}parseEntity(e,t){let i={type:t.value};for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 10:i.controlPoints||(i.controlPoints=[]),i.controlPoints.push(kt(e)),t=e.lastReadGroup;break;case 11:i.fitPoints||(i.fitPoints=[]),i.fitPoints.push(kt(e)),t=e.lastReadGroup;break;case 12:i.startTangent=kt(e),t=e.lastReadGroup;break;case 13:i.endTangent=kt(e),t=e.lastReadGroup;break;case 40:i.knotValues||(i.knotValues=[]),i.knotValues.push(t.value),t=e.next();break;case 70:1&t.value&&(i.closed=!0),2&t.value&&(i.periodic=!0),4&t.value&&(i.rational=!0),8&t.value&&(i.planar=!0),16&t.value&&(i.planar=!0,i.linear=!0),t=e.next();break;case 71:i.degreeOfSplineCurve=t.value,t=e.next();break;case 72:i.numberOfKnots=t.value,t=e.next();break;case 73:i.numberOfControlPoints=t.value,t=e.next();break;case 74:i.numberOfFitPoints=t.value,t=e.next();break;case 210:i.normalVector=kt(e),t=e.lastReadGroup;break;case 101:for(;0!=t.code;)t=e.next();break;default:Nn(i,t),t=e.next()}return i}},GE=class{constructor(){this.ForEntityName="TEXT"}parseEntity(e,t){let i={type:t.value};for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 10:i.startPoint=kt(e),t=e.lastReadGroup;break;case 11:i.endPoint=kt(e),t=e.lastReadGroup;break;case 40:i.textHeight=t.value,t=e.next();break;case 41:i.xScale=t.value,t=e.next();break;case 50:i.rotation=t.value,t=e.next();break;case 1:i.text=t.value,t=e.next();break;case 72:i.halign=t.value,t=e.next();break;case 73:i.valign=t.value,t=e.next();break;case 7:i.textStyle=t.value,t=e.next();break;case 71:i.mirrored=t.value,t=e.next();break;case 101:for(;0!=t.code;)t=e.next();break;default:Nn(i,t),t=e.next()}return i}},qE=class{constructor(){this.ForEntityName="VIEWPORT"}parseEntity(e,t){let i={type:t.value};for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 68:i.viewportStatus=t.value,t=e.next();break;case 40:i.width_paperSpace=t.value,t=e.next();break;case 41:i.height_paperSpace=t.value,t=e.next();break;case 69:i.viewportId=t.value,t=e.next();break;case 10:i.centerPoint=kt(e),t=e.lastReadGroup;break;case 12:i.centerPoint_dcs=kt(e),t=e.lastReadGroup;break;case 13:i.snapBasePoint_dcs=kt(e),t=e.lastReadGroup;break;case 14:i.snapSpacing_dcs=kt(e),t=e.lastReadGroup;break;case 15:i.gridSpacing_dcs=kt(e),t=e.lastReadGroup;break;case 16:i.viewDirection=kt(e),t=e.lastReadGroup;break;case 17:i.viewTarget=kt(e),t=e.lastReadGroup;break;case 42:i.perspectiveLens=t.value,t=e.next();break;case 43:i.frontClippingPlaneZ=t.value,t=e.next();break;case 44:i.backClippingPlaneZ=t.value,t=e.next();break;case 45:i.viewHeight=t.value,t=e.next();break;case 50:i.snapAngle=t.value,t=e.next();break;case 51:i.viewTwistAngle=t.value,t=e.next();break;case 72:i.circleZoomPercent=t.value,t=e.next();break;case 331:i.frozenLayerHandles=i.frozenLayerHandles||[],i.frozenLayerHandles.push(t.value),t=e.next();break;case 90:i.viewportStatusFlags=t.value,t=e.next();break;case 340:i.viewportClippingBoundaryhandleId=t.value,t=e.next();break;case 1:i.plotStyleSheetName=t.value,t=e.next();break;case 281:i.renderMode=t.value,t=e.next();break;case 71:i.viewportFlag_ucs=t.value,t=e.next();break;case 74:i.ucsIcon=t.value,t=e.next();break;case 110:i.ucsOrigin=kt(e),t=e.lastReadGroup;break;case 111:i.ucsXAxis=kt(e),t=e.lastReadGroup;break;case 112:i.ucsYAxis=kt(e),t=e.lastReadGroup;break;case 345:i.ucsTableRecordHandle=t.value,t=e.next();break;case 346:i.baseUcsTableRecordHandle=t.value,t=e.next();break;case 79:i.orthographicType=t.value,t=e.next();break;case 146:i.elevation=t.value,t=e.next();break;case 170:i.shadePlotMode=t.value,t=e.next();break;case 61:i.frequency=t.value,t=e.next();break;case 292:i.lightingFlag=t.value,t=e.next();break;case 282:i.lightingType=t.value,t=e.next();break;case 141:i.viewBrightness=t.value,t=e.next();break;case 142:i.viewContrast=t.value,t=e.next();break;case 101:for(;0!=t.code;)t=e.next();break;default:Nn(i,t),t=e.next()}return i}},WE=class{constructor(){this.ForEntityName="XLINE"}parseEntity(e,t){let i={type:t.value,vertices:[]};for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 10:i.vertices.unshift(kt(e)),t=e.lastReadGroup;break;case 11:i.directionVector=kt(e),t=e.lastReadGroup;break;case 100:t=e.next();break;case 101:for(;0!=t.code;)t=e.next();break;default:Nn(i,t),t=e.next()}return i}},hC=class{constructor(){this.ForObjectName="DICTIONARY"}parseObject(e,t){let i={type:t.value},n=[],r=[];for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 280:i.isHardOwner=1===t.value,t=e.next();break;case 281:i.cloningFlag=t.value,t=e.next();break;case 3:n.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:Fl(i,t),t=e.next()}if(n.length!==r.length)throw new Error("The number of Dictionary entries does not match !");return i.entries={},n.forEach(((e,t)=>{i.entries[r[t]]=e})),i}},dC=class{constructor(){this.ForObjectName="IMAGEDEF"}parseObject(e,t){let i={type:t.value};for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 90:i.classVersion=t.value,t=e.next();break;case 1:i.filename=t.value,t=e.next();break;case 10:i.imageSize=kt(e),t=e.next();break;case 11:i.pixelSize=kt(e),t=e.next();break;case 280:i.loaded=t.value,t=e.next();break;case 281:i.resolutionUnits=t.value,t=e.next();break;default:Fl(i,t),t=e.next()}return i}},fC=class{constructor(){this.ForObjectName="LAYOUT"}parseObject(e,t){let i={type:t.value};for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 100:t=e.next();break;case 1:i.layoutName=t.value,t=e.next();break;case 70:i.flag=t.value,t=e.next();break;case 71:i.tabOrder=t.value,t=e.next();break;case 76:i.orthographicType=t.value,t=e.next();break;case 10:i.minLimit=kt(e),t=e.lastReadGroup;break;case 11:i.maxLimit=kt(e),t=e.lastReadGroup;break;case 12:i.basePoint=kt(e),t=e.lastReadGroup;break;case 13:i.origin=kt(e),t=e.lastReadGroup;break;case 14:i.minExtent=kt(e),t=e.lastReadGroup;break;case 15:i.maxExtent=kt(e),t=e.lastReadGroup;break;case 16:i.XAxis=kt(e),t=e.lastReadGroup;break;case 17:i.YAxis=kt(e),t=e.lastReadGroup;break;case 146:i.elevation=t.value,t=e.next();break;case 331:i.viewportHandle=t.value,t=e.next();break;default:Fl(i,t),t=e.next()}return i.blockTableHandle=i.ownerHandle,i}},pC=class{constructor(){this.ForObjectName="SORTENTSTABLE"}parseObject(e,t){let i={type:t.value},n=!1;i.sortEntsObject={},i.sortEntsObject.entityHandles=[];let r=[];for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 5:n?(r.push(t.value),i.sortEntsObject.entityHandles.push(r),r=[]):i.handle=t.value,t=e.next();break;case 100:t=e.next(),n=!0;break;case 102:t=e.next();break;case 330:n?i.sortEntsObject.ownerHandle=t.value:i.ownerHandle=t.value,t=e.next();break;case 331:r.push(t.value),t=e.next();break;default:Fl(i,t),t=e.next()}return i}},mC=class{constructor(){this.ForObjectName="SPATIAL_FILTER"}parseObject(e,t){let i,n,r={type:t.value,vertices:[]};for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 11:r.origin=kt(e),t=e.lastReadGroup;break;case 70:r.numberOfPointsOnClipBoundary=t.value,2===r.numberOfPointsOnClipBoundary?(t=e.next(),i=kt(e),t=e.lastReadGroup,n=kt(e),t=e.lastReadGroup,r.vertices.push(i,{x:n.x,y:i.y},n,{x:i.x,y:n.y},i)):r.numberOfPointsOnClipBoundary>2?(r.vertices=Qct(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=ipe(e,40),r.matrix=ipe(e,40),t=e.lastReadGroup;break;default:Fl(r,t),t=e.next()}return r}};function Qct(e,t){t.next();let i=[];for(;i.length<e;)i.push(kt(t));return i}function ipe(e,t){let i=e.lastReadGroup,n=[];for(let r=0;r<12;r++){if(i.code!==t)throw new Error(`Expected code for matrix value to be ${t} but got ${i.code}`);n.push(i.value),i=e.next()}return n}var gC=class{constructor(){this.ForObjectName="XRECORD"}parseObject(e,t){let i={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:i.cloningFlag=t.value,t=e.next();break;case 310:i.binaryData+=t.value,t=e.next();break;default:Fl(i,t),t=e.next()}return i}};function eut(e){e.registerEntityHandler(xE),e.registerEntityHandler(bE),e.registerEntityHandler(EE),e.registerEntityHandler(_E),e.registerEntityHandler(TE),e.registerEntityHandler(wE),e.registerEntityHandler(LE),e.registerEntityHandler(SE),e.registerEntityHandler(ME),e.registerEntityHandler(RE),e.registerEntityHandler(AE),e.registerEntityHandler(CE),e.registerEntityHandler(PE),e.registerEntityHandler(IE),e.registerEntityHandler(DE),e.registerEntityHandler(OE),e.registerEntityHandler(kE),e.registerEntityHandler(NE),e.registerEntityHandler(UE),e.registerEntityHandler(BE),e.registerEntityHandler(HE),e.registerEntityHandler(VE),e.registerEntityHandler(zE),e.registerEntityHandler(GE),e.registerEntityHandler(qE),e.registerEntityHandler(WE)}function tut(e){e.registerObjectHandler(hC),e.registerObjectHandler(dC),e.registerObjectHandler(fC),e.registerObjectHandler(pC),e.registerObjectHandler(mC),e.registerObjectHandler(gC)}function nut(e){let t=new Df(e).readBytes(22),i="";for(let n=0;n<18;n++)i+=String.fromCharCode(t[n]);return"AutoCAD Binary DXF"===i}var Zm=class{constructor(e){this._entityHandlers={},this._objectHandlers={},this._layoutBlocks={},this.unhandledSections={},this.unhandledObjects={},this.unhandledEntities={},this.unsupportedLineTypes={},this.encoding=e,eut(this),tut(this)}parse(e){if("string"==typeof e){let t=this.splitByLineSeparator(e),i=new cy(t);return this._parse(i)}{let t;if(nut(e))t=new vE(e);else{let i=new TextDecoder(this.encoding).decode(e),n=Date.now(),r=this.splitByLineSeparator(i);se.info(`[DxfParser] string.split costed ${(Date.now()-n)/1e3}s, it is avoidable by using dxf in binary.`),t=new cy(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="",i=this;return new Promise(((n,r)=>{e.on("data",(e=>{t+=e})),e.on("end",(()=>{try{n(i.parse(t))}catch(e){r(e)}})),e.on("error",(e=>{r(e)}))}))}_parse(e){let t={},i=0;if(!e.hasNext())throw Error("Empty file");let n,r=this;function a(){let t=null,i=null,r={};for(n=e.next();;){if(Qo(n,0,"ENDSEC")){t&&(r[t]=i);break}9===n.code?(t&&(r[t]=i),t=n.value):10===n.code?i={x:n.value}:20===n.code?i.y=n.value:30===n.code?i.z=n.value:i=n.value,n=e.next()}return n=e.next(),r}function s(){let t={};for(n=e.next();"EOF"!==n.value&&!Qo(n,0,"ENDSEC");)if(Qo(n,0,"BLOCK")){se.trace("block {");let e=o();se.trace("}"),m(e),e.name?t[e.name]=e:se.error(`[DxfParser] Block with handle '${e.handle}' is missing a name, ignored!`)}else id(n),n=e.next();return t}function o(){let t={};for(n=e.next();"EOF"!==n.value;){switch(n.code){case 1:t.xrefPath=n.value,n=e.next();break;case 2:t.name=n.value,n=e.next();break;case 3:t.name2=n.value,n=e.next();break;case 4:t.description=n.value,n=e.next();break;case 5:t.handle=n.value,n=e.next();break;case 8:t.layer=n.value,n=e.next();break;case 10:t.position=f(n),n=e.lastReadGroup;break;case 67:t.paperSpace=!(!n.value||1!==n.value),n=e.next();break;case 70:t.blockType=n.value,n=e.next();break;case 100:n=e.next();break;case 330:t.ownerHandle=n.value,n=e.next();break;case 0:if("ENDBLK"==n.value)break;t.entities=d(!0);break;default:id(n),n=e.next()}if(Qo(n,0,"ENDBLK")){n=e.next();break}}return t}function l(){let t={};for(n=e.next();"EOF"!==n.value&&!Qo(n,0,"ENDSEC");)Qo(n,0,"TABLE")?(n=e.next(),u[n.value]?(se.trace(n.value+" Table {"),t[u[n.value].tableName]=c(n),se.trace("}")):se.trace("Unhandled Table "+n.value)):n=e.next();return n=e.next(),t}let h="ENDTAB";function c(t){let i=u[t.value],r={},a=0;for(n=e.next();!Qo(n,0,h);)switch(n.code){case 5:r.handle=n.value,n=e.next();break;case 330:r.ownerHandle=n.value,n=e.next();break;case 100:"AcDbSymbolTable"===n.value||id(n),n=e.next();break;case 70:a=n.value,n=e.next();break;case 0:n.value===i.dxfSymbolName?r[i.tableRecordsProperty]=i.parseTableRecords():(id(n),n=e.next());break;default:id(n),n=e.next()}let s=r[i.tableRecordsProperty];if(s){let e=s.constructor===Array?s.length:"object"==typeof s?Object.keys(s).length:void 0;a!==e&&se.warn(`[DxfParser] Parsed ${e} ${i.dxfSymbolName}s but expected ${a}`)}return n=e.next(),r}let u={VPORT:{tableRecordsProperty:"viewports",tableName:"viewport",dxfSymbolName:"VPORT",parseTableRecords:function(){let t=[],i={};for(se.trace("Viewport {"),n=e.next();!Qo(n,0,h);)switch(n.code){case 2:i.name=n.value,n=e.next();break;case 10:i.lowerLeftCorner=f(n),n=e.lastReadGroup;break;case 11:i.upperRightCorner=f(n),n=e.lastReadGroup;break;case 12:i.center=f(n),n=e.lastReadGroup;break;case 13:i.snapBasePoint=f(n),n=e.lastReadGroup;break;case 14:i.snapSpacing=f(n),n=e.lastReadGroup;break;case 15:i.gridSpacing=f(n),n=e.lastReadGroup;break;case 16:i.viewDirectionFromTarget=f(n),n=e.lastReadGroup;break;case 17:i.viewTarget=f(n),n=e.lastReadGroup;break;case 40:case 45:i.viewHeight=n.value,n=e.next();break;case 41:i.aspectRatio=n.value,n=e.next();break;case 42:i.lensLength=n.value,n=e.next();break;case 43:i.frontClippingPlane=n.value,n=e.next();break;case 44:i.backClippingPlane=n.value,n=e.next();break;case 50:i.snapRotationAngle=n.value,n=e.next();break;case 51:i.viewTwistAngle=n.value,n=e.next();break;case 79:i.orthographicType=n.value,n=e.next();break;case 110:i.ucsOrigin=f(n),n=e.lastReadGroup;break;case 111:i.ucsXAxis=f(n),n=e.lastReadGroup;break;case 112:i.ucsYAxis=f(n),n=e.lastReadGroup;break;case 281:i.renderMode=n.value,n=e.next();break;case 282:i.defaultLightingType=n.value,n=e.next();break;case 292:i.defaultLightingOn=n.value,n=e.next();break;case 330:i.ownerHandle=n.value,n=e.next();break;case 63:case 421:case 431:i.ambientColor=n.value,n=e.next();break;case 0:"VPORT"===n.value&&(se.trace("}"),t.push(i),se.trace("Viewport {"),i={},n=e.next());break;default:id(n),n=e.next()}return se.trace("}"),t.push(i),t}},LTYPE:{tableRecordsProperty:"lineTypes",tableName:"lineType",dxfSymbolName:"LTYPE",parseTableRecords:function(){let t={},i={},a=0,s="",o=!1;for(se.trace("LType {"),n=e.next();!Qo(n,0,"ENDTAB");)switch(n.code){case 2:i.name=n.value.toUpperCase(),s=i.name,n=e.next();break;case 3:i.description=n.value,n=e.next();break;case 9:case 44:case 45:case 46:case 70:case 75:default:n=e.next();break;case 40:i.patternLength=n.value,n=e.next();break;case 49:let l=n.value;o&&(l=Math.abs(l),o=!1),i.pattern.push(l),n=e.next();break;case 73:a=n.value,a>0&&(i.pattern=[]),n=e.next();break;case 74:0!==n.value&&(o=!0,r.unsupportedLineTypes[i.name]?r.unsupportedLineTypes[i.name]++:r.unsupportedLineTypes[i.name]=1),n=e.next();break;case 0:se.trace("}"),a>0&&a!==i.pattern.length&&se.warn("[DxfParser] lengths do not match on LTYPE pattern"),t[s]=i,i={},se.trace("LType {"),n=e.next()}return se.trace("}"),t[s]=i,t}},LAYER:{tableRecordsProperty:"layers",tableName:"layer",dxfSymbolName:"LAYER",parseTableRecords:function(){let t,i={},r={};for(se.trace("Layer {"),n=e.next();!Qo(n,0,"ENDTAB");)switch(n.code){case 2:r.name=n.value,t=n.value,n=e.next();break;case 5:r.handle=n.value,n=e.next();break;case 62:r.visible=n.value>=0,r.colorIndex=Math.abs(n.value),r.color=rut(r.colorIndex),n=e.next();break;case 70:r.flag=n.value,r.frozen=(1&r.flag)>0,n=e.next();break;case 420:r.color=Math.abs(n.value),n=e.next();break;case 6:r.lineType=n.value.toUpperCase(),n=e.next();break;case 370:r.lineweight=n.value,n=e.next();break;case 0:"LAYER"===n.value&&(se.trace("}"),t&&(i[t]=r),se.trace("Layer {"),r={},t=void 0,n=e.next());break;default:id(n),n=e.next()}return se.trace("}"),t&&(i[t]=r),i}},BLOCK_RECORD:{tableRecordsProperty:"blockRecords",tableName:"blockRecord",dxfSymbolName:"BLOCK_RECORD",parseTableRecords:function(){let t,i={},a={};for(se.trace("BlockRecord {"),n=e.next();!Qo(n,0,"ENDTAB");)switch(n.code){case 5:a.handle=n.value,n=e.next();break;case 330:a.ownerHandle=n.value,n=e.next();break;case 2:a.blockName=n.value,t=a.blockName,n=e.next();break;case 340:a.layoutHandle=n.value,n=e.next();break;case 70:a.blockInsertUnits=n.value,n=e.next();break;case 280:a.blockExplodability=n.value,n=e.next();break;case 281:a.blockScalability=n.value,n=e.next();break;case 310:a.bitmap=n.value,n=e.next();break;case 0:if("BLOCK_RECORD"===n.value){se.trace("}"),t&&(i[t]=a);let s=a.layoutHandle;t&&s&&s.length>0&&"0"!==s&&(r._layoutBlocks[s]=a),se.trace("BlockRecord {"),a={},t=void 0,n=e.next()}else id(n),n=e.next();break;default:id(n),n=e.next()}se.trace("}"),t&&(i[t]=a);let s=a.layoutHandle;return t&&s&&s.length>0&&"0"!==s&&(r._layoutBlocks[s]=a),i}},STYLE:{tableRecordsProperty:"styles",tableName:"style",dxfSymbolName:"STYLE",parseTableRecords:function(){let t,i={},r={};for(se.trace("Style {"),n=e.next();!Qo(n,0,"ENDTAB");)switch(n.code){case 2:r.styleName=n.value,t=n.value,n=e.next();break;case 3:r.fontFile=n.value,n=e.next();break;case 4:r.bigFontFile=n.value,n=e.next();break;case 5:r.handle=n.value,n=e.next();break;case 40:r.textHeight=n.value,n=e.next();break;case 41:r.xScale=n.value,n=e.next();break;case 42:r.priorTextHeight=n.value,n=e.next();break;case 50:r.rotation=n.value,n=e.next();break;case 70:default:n=e.next();break;case 71:r.mirrorType=n.value,n=e.next();break;case 330:r.ownerHandle=n.value,n=e.next();break;case 0:"STYLE"===n.value&&(se.trace("}"),t&&(i[t]=r),se.trace("Style {"),r={},t=void 0,n=e.next())}return se.trace("}"),t&&(i[t]=r),i}},DIMSTYLE:{tableRecordsProperty:"dimStyles",tableName:"dimStyle",dxfSymbolName:"DIMSTYLE",parseTableRecords:function(){let t,i={},r={};for(se.trace("DimStyle {"),n=e.next();!Qo(n,0,"ENDTAB");)switch(n.code){case 2:r.styleName=n.value,t=n.value,n=e.next();break;case 40:r.DIMSCALE=n.value,n=e.next();break;case 41:r.DIMASZ=n.value,n=e.next();break;case 42:r.DIMEXO=n.value,n=e.next();break;case 44:r.DIMEXE=n.value,n=e.next();break;case 75:r.DIMSE1=n.value,n=e.next();break;case 76:r.DIMSE2=n.value,n=e.next();break;case 77:r.DIMTAD=n.value,n=e.next();break;case 140:r.DIMTXT=n.value,n=e.next();break;case 144:r.DIMLFAC=n.value,n=e.next();break;case 147:r.DIMGAP=n.value,n=e.next();break;case 176:r.DIMCLRD=n.value,n=e.next();break;case 178:r.DIMCLRT=n.value,n=e.next();break;case 271:r.DIMDEC=n.value,n=e.next();break;case 341:r.DIMLDRBLK=n.value,n=e.next();break;case 70:default:n=e.next();break;case 0:"DIMSTYLE"===n.value&&(se.trace("}"),t&&(i[t]=r),se.trace("DimStyle {"),r={},t=void 0,n=e.next())}return se.trace("}"),t&&(i[t]=r),i}}};function d(t){let i=[],a=t?"ENDBLK":"ENDSEC";for(t||(n=e.next());;)if(0===n.code){if(n.value===a)break;let t=r._entityHandlers[n.value];if(null==t){let t=n.value;r.unhandledEntities[t]||(r.unhandledEntities[t]=0),r.unhandledEntities[t]++,n=e.next();continue}{se.trace(n.value+" {");let r=t.parseEntity(e,n);r&&(r.layer||(r.layer="0"),void 0===r.colorIndex&&(r.colorIndex=256),r.lineType||(r.lineType=ay)),n=e.lastReadGroup,se.trace("}"),m(r),i.push(r)}}else n=e.next();return"ENDSEC"==a&&(n=e.next()),i}function p(){let t={};for(n=e.next();"EOF"!==n.value;)if(0===n.code){if("ENDSEC"===n.value)break;let i=r._objectHandlers[n.value];if(null==i){let t=n.value;r.unhandledObjects[t]||(r.unhandledObjects[t]=0),r.unhandledObjects[t]++,n=e.next();continue}{se.trace(n.value+" {");let r=i.parseObject(e,n),a=n.value;n=e.lastReadGroup,se.trace("}"),m(r),t[a]||(t[a]=[]),t[a].push(r)}}else n=e.next();return n=e.next(),t.LAYOUT&&(Object.keys(r._layoutBlocks).length!==t.LAYOUT.length&&se.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 i={},n=t.code;if(i.x=t.value,n+=10,(t=e.next()).code!=n)throw new Error(`Expected code for point value to be ${n} but got ${t.code}.`);return i.y=t.value,n+=10,(t=e.next()).code!=n||(i.z=t.value,t=e.next()),i}function m(e){if(!e)throw new TypeError("entity cannot be undefined or null");e.handle||(e.handle=(i++).toString())}return function(){for(n=e.next();999===n.code;)n=e.next();for(;!e.isEOF();)if(0===n.code&&"SECTION"===n.value){if(n=e.next(),2!==n.code){se.error("Unexpected code %s after 0:SECTION",spe(n)),n=e.next();continue}if("HEADER"===n.value)se.trace("> HEADER"),t.header=a(),se.trace("<");else if("TABLES"===n.value)se.trace("> TABLES"),t.tables=l(),se.trace("<");else if("BLOCKS"===n.value)se.trace("> BLOCKS"),t.blocks=s(),se.trace("<");else if("ENTITIES"===n.value)se.trace("> ENTITIES"),t.entities=d(!1),se.trace("<");else if("OBJECTS"===n.value)se.trace("> OBJECTS"),t.objects=p(),se.trace("<");else if("EOF"===n.value)se.trace("EOF");else{let e=n.value;r.unhandledSections[e]?r.unhandledSections[e]++:r.unhandledSections[e]=1}}else n=e.next();r.unhandledSections={},r.unhandledEntities={},r.unhandledObjects={},r.unsupportedLineTypes={}}(),t}splitByLineSeparator(e){let t=[],i=0;for(let n=0,r=e.length;n<r;++n){let r=e[n];if("\r"===r||"\n"===r){let a=e.substring(i,n);t.push(a),"\r"===r&&"\n"===e[n+1]&&n++,i=n+1}}return t.push(e.substring(i,e.length)),t}};function Qo(e,t,i){return e.code===t&&e.value===i}function id(e){se.trace("unhandled group "+spe(e))}function spe(e){return e.code+":"+e.value}function rut(e){return uC[e]}var C5=(e=>(e.Added="Added",e.Removed="Removed",e.Modified="Modified",e.NoChange="NoChange",e))(C5||{}),Ga=1,vC=class{constructor(e,t,i){if(this.changes={},this.comparedBlocks=new Map,this.isComparingBlock=!1,this.isComparingDimension=!1,this.enableDetailComparision=!0,this.dxf1=e,this.dxf2=t,this.enableDetailComparision=!i||(null==i?void 0:i.enableDetailComparision),!e||!t)throw new Error("Invalid dxf data to compare!")}getLayerFrozen(e,t){var i,n,r;let a=null==(n=null==(i=e.tables)?void 0:i.layer)?void 0:n.layers;return a&&(null==(r=a[t.layer])?void 0:r.frozen)}compare(e){return ft(this,null,(function*(){this.changes={};let t=[],i=new Map;return this.dxf1.entities.forEach((e=>{if(!0!==e.inPaperSpace){let i=!0===this.getLayerFrozen(this.dxf1,e);!vC.ignoreEntityTypes.includes(e.type)&&!i&&t.push(e)}})),this.dxf2.entities.forEach((e=>{if(!0!==e.inPaperSpace){let t=!0===this.getLayerFrozen(this.dxf2,e);!vC.ignoreEntityTypes.includes(e.type)&&!t&&i.set(e.handle,e)}})),yield this.compareEntities(t,i,e),Promise.resolve(this.changes)}))}isDimensionBlock(e){return e.includes("*D")}compareInsertOrDemensionEntities(e,t,i,n){if(!e.block||!t.block)return;let r,a=e.block;if(this.isComparingBlock=!0,this.isDimensionBlock(a)){let i=this.dxf1.blocks[e.block],n=this.dxf2.blocks[t.block],s=Date.now();this.isComparingDimension=!0,r=this.compareBlock(e,t,i,n),this.isComparingDimension=!1,se.debug(`[DxfCompare] compare block: ${a} cost ${(Date.now()-s)/1e3}s`)}else{if(!this.comparedBlocks.has(a)){let i=this.dxf1.blocks[a],n=this.dxf2.blocks[a],r=Date.now(),s=this.compareBlock(e,t,i,n);this.comparedBlocks.set(a,s),se.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=[]),i&&n)"Added"===t.type?t.parentHandles.push(n):"Removed"===t.type&&t.parentHandles.push(i);else{let i=[...t.parentHandles,e.handle];("Added"===t.type||"Removed"===t.type)&&(this.changes[Ga]=Ii(Tr({id:Ga},t),{parentHandles:i})),Ga++}})),!i&&!n&&(this.isComparingBlock=!1),r}compareBlock(e,t,i,n){var r,a;let s=[],o=[];null==(r=null==i?void 0:i.entities)||r.forEach((e=>{"ATTDEF"!==e.type&&!this.bIgnoreChildEntitiesOriginalType(e)&&s.push(e)})),null==(a=null==n?void 0:n.entities)||a.forEach((e=>{"ATTDEF"!==e.type&&!this.bIgnoreChildEntitiesOriginalType(e)&&o.push(e)}));let l=[],h=[];for(let c=0;c<s.length;c++){let i=s[c],n=!1;0===o.length&&(n=!0),this.isComparingDimension||(this.isComparingDimension="DIMENSION"===i.type);for(let r=0;r<o.length;r++){let a=o[r];if(this.entitiesEqual(i,a,e,t)){if("INSERT"===i.type&&"INSERT"===a.type||"DIMENSION"===i.type&&"DIMENSION"===a.type){let e=this.compareInsertOrDemensionEntities(i,a,i.handle,a.handle);e&&e.length>0&&l.push(...e),n=!1,o.splice(r--,1);break}n=!1,o.splice(r--,1);break}n=!0}n&&(l.push({type:"Removed",handle:i.handle}),h.push(i.handle))}return o.forEach((e=>{h.includes(e.handle)||l.push({type:"Added",handle:e.handle})})),l}compareEntities(e,t,i){return ft(this,null,(function*(){var n,r;let a=St.getUpdateProgressFuncForLoop(e.length,i);for(let i=0;i<e.length;i++){let s=e[i].handle;if(t.has(s)){let a=e[i],o=t.get(s),l={};if(this.entitiesEqual(a,o,void 0,void 0,l)){if(Xm.includes(a.type)){if(this.bIgnoreChildEntitiesOriginalType(a)){t.delete(s),se.warn(`[DxfCompare] We cannot compare insert (handle '${a.handle}') yet, ignored!`);continue}this.compareInsertOrDemensionEntities(a,o)}}else{if(null!=(n=a.extendedData)&&n.originalType&&null!=(r=o.extendedData)&&r.originalType&&a.block!==o.block){t.delete(s);continue}this.changes[Ga]={id:Ga,type:"Modified",handle:s},this.enableDetailComparision&&Object.keys(l).length>0&&(this.changes[Ga].detailChanges=l),Ga++}t.delete(s)}else this.changes[Ga]={id:Ga,type:"Removed",handle:s},Ga++;yield a(i)}for(let e of t){let t=e[0];this.changes[Ga]={id:Ga,type:"Added",handle:t},Ga++}}))}bIgnoreChildEntitiesOriginalType(e){var t;return tpe.includes(null==(t=e.extendedData)?void 0:t.originalType)}entitiesEqual(e,t,i,n,r){if(!this.baseEntitiesEqual(e,t,i,n,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,i){var n,r,a,s,o,l;if(e.isTrueColor||e.colorIndex>0&&e.colorIndex<256)return e.color;if(0===e.colorIndex)return i?this.getColor(i,t):null==(r=null==(n=t.tables)?void 0:n.layer)?void 0:r.layers[0].color;let h=0;if(256===e.colorIndex){let n=null==(s=null==(a=t.tables)?void 0:a.layer)?void 0:s.layers,r=n&&n[e.layer],c=n&&i&&n[i.layer];h=r&&"0"!==r.name?r.color:c?c.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,i){var n,r;if(i&&"DIMENSION"===i.type)return this.getLineType(i,t);if(e.lineType!==ay&&e.lineType!==oy)return e.lineType;if(e.lineType===oy)return i?this.getLineType(i,t):e.lineType;let a=null==(r=null==(n=t.tables)?void 0:n.layer)?void 0:r.layers;if("0"!==e.layer){let t=a&&a[e.layer];if(t)return t.lineType}else if(i){let e=a&&a[i.layer];if(e)return e.lineType}return"CONTINUOUS"}addModificationItem(e,t,i,n){n&&(n[i]={old:e,new:t})}baseEntitiesEqual(e,t,i,n,r){var a,s;let o=!0,l=this.getColor(e,this.dxf1,i),h=this.getColor(t,this.dxf2,n);if(l!==h){if(o=!1,!this.enableDetailComparision)return o;this.addModificationItem(l,h,"color",r)}let c=this.getLineType(e,this.dxf1,i),u=this.getLineType(t,this.dxf2,n);return c!==u?(o=!1,this.enableDetailComparision?(this.addModificationItem(c,u,"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,i){let n=!0,r=e.constantWidth,a=t.constantWidth;if(r!==a){if(n=!1,!this.enableDetailComparision)return!1;this.addModificationItem(r||0,a||0,"constantWidth",i)}return!(!this.verticesEqual(e.vertices,t.vertices)||e.shape!==t.shape)&&n}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 i=e,n=t;return!!(this.numberEqual(i.elevationX,n.elevationX)&&this.numberEqual(i.elevationY,n.elevationY)&&this.numberEqual(i.elevationZ,n.elevationZ)&&this.hatchBoundaryPathArraysEqual(i.boundaryPaths,n.boundaryPaths))}viewportsEqual(e,t){let i=e,n=t;return!!(this.pointsEqual(i.centerPoint,n.centerPoint)&&this.pointsEqual(i.centerPoint_dcs,n.centerPoint_dcs)&&this.pointsEqual(i.viewDirection,n.viewDirection)&&this.numberEqual(i.viewHeight,n.viewHeight)&&i.width_paperSpace===n.width_paperSpace&&i.height_paperSpace===n.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 i,n,r,a;return"INSERT"===(null==(i=e.extendedData)?void 0:i.originalType)&&"INSERT"===(null==(n=t.extendedData)?void 0:n.originalType)?(se.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 se.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 i=0;i<e.length;++i)if(!this.numberEqual(e[i],t[i]))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 i=0;i<e.length;++i)if(!this.vectorsEqual(e[i],t[i]))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 i=0;i<e.length;++i)if(!this.pointsEqual(e[i],t[i]))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 i=0;i<e.length;++i)if(!this.verticesEqual(e[i],t[i]))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 i=0;i<e.length;++i)if(!this.vertexEntityEqual(e[i],t[i]))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 i=0;i<e.length;++i)if(!this.hatchEdgesEqual(e[i],t[i]))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 i=0;i<e.length;++i)if(!this.hatchBoundaryPathsEqual(e[i],t[i]))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 i=0;i<e.length;++i)if(!this.mleaderLineEqual(e[i],t[i]))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 i=0;i<e.length;++i)if(!this.mleaderLeaderEqual(e[i],t[i]))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)}},ls=vC;ls.ENTITY_COLOR_ADDED=65280,ls.ENTITY_COLOR_REMOVED=16711680,ls.ENTITY_COLOR_NO_CHANGE=10066329,ls.ENTITY_COLOR_MARKUP=16744231,ls.ignoreEntityTypes=["ATTRIB","SEQEND"];var r0e=Xi(_pe(),1),Ape="3.7.2",fut=Ape,put="function"==typeof atob,mut="function"==typeof btoa,fy="function"==typeof Buffer,Tpe="function"==typeof TextDecoder?new TextDecoder:void 0,wpe="function"==typeof TextEncoder?new TextEncoder:void 0,gut="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",jE=Array.prototype.slice.call(gut),_C=(e=>{let t={};return jE.forEach(((e,i)=>t[e]=i)),t})(),vut=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,ia=String.fromCharCode.bind(String),Spe="function"==typeof Uint8Array.from?Uint8Array.from.bind(Uint8Array):(e,t=(e=>e))=>new Uint8Array(Array.prototype.slice.call(e,0).map(t)),Cpe=e=>e.replace(/=/g,"").replace(/[+\/]/g,(e=>"+"==e?"-":"_")),Ppe=e=>e.replace(/[^A-Za-z0-9\+\/]/g,""),Ipe=e=>{let t,i,n,r,a="",s=e.length%3;for(let o=0;o<e.length;){if((i=e.charCodeAt(o++))>255||(n=e.charCodeAt(o++))>255||(r=e.charCodeAt(o++))>255)throw new TypeError("invalid character found");t=i<<16|n<<8|r,a+=jE[t>>18&63]+jE[t>>12&63]+jE[t>>6&63]+jE[63&t]}return s?a.slice(0,s-3)+"===".substring(s):a},H5=mut?e=>btoa(e):fy?e=>Buffer.from(e,"binary").toString("base64"):Ipe,B5=fy?e=>Buffer.from(e).toString("base64"):e=>{let t=[];for(let i=0,n=e.length;i<n;i+=4096)t.push(ia.apply(null,e.subarray(i,i+4096)));return H5(t.join(""))},TC=(e,t=!1)=>t?Cpe(B5(e)):B5(e),yut=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)},xut=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,Lpe=e=>e.replace(xut,yut),Mpe=fy?e=>Buffer.from(e,"utf8").toString("base64"):wpe?e=>B5(wpe.encode(e)):e=>H5(Lpe(e)),dy=(e,t=!1)=>t?Cpe(Mpe(e)):Mpe(e),Rpe=e=>dy(e,!0),but=/[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g,Eut=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))}},Dpe=e=>e.replace(but,Eut),Ope=e=>{if(e=e.replace(/\s+/g,""),!vut.test(e))throw new TypeError("malformed base64.");e+="==".slice(2-(3&e.length));let t,i,n,r="";for(let a=0;a<e.length;)t=_C[e.charAt(a++)]<<18|_C[e.charAt(a++)]<<12|(i=_C[e.charAt(a++)])<<6|(n=_C[e.charAt(a++)]),r+=64===i?ia(t>>16&255):64===n?ia(t>>16&255,t>>8&255):ia(t>>16&255,t>>8&255,255&t);return r},V5=put?e=>atob(Ppe(e)):fy?e=>Buffer.from(e,"base64").toString("binary"):Ope,kpe=fy?e=>Spe(Buffer.from(e,"base64")):e=>Spe(V5(e),(e=>e.charCodeAt(0))),Fpe=e=>kpe(Npe(e)),_ut=fy?e=>Buffer.from(e,"base64").toString("utf8"):Tpe?e=>Tpe.decode(kpe(e)):e=>Dpe(V5(e)),Npe=e=>Ppe(e.replace(/[-_]/g,(e=>"-"==e?"+":"/"))),U5=e=>_ut(Npe(e)),Tut=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)},Bpe=e=>({value:e,enumerable:!1,writable:!0,configurable:!0}),Upe=function(){let e=(e,t)=>Object.defineProperty(String.prototype,e,Bpe(t));e("fromBase64",(function(){return U5(this)})),e("toBase64",(function(e){return dy(this,e)})),e("toBase64URI",(function(){return dy(this,!0)})),e("toBase64URL",(function(){return dy(this,!0)})),e("toUint8Array",(function(){return Fpe(this)}))},Hpe=function(){let e=(e,t)=>Object.defineProperty(Uint8Array.prototype,e,Bpe(t));e("toBase64",(function(e){return TC(this,e)})),e("toBase64URI",(function(){return TC(this,!0)})),e("toBase64URL",(function(){return TC(this,!0)}))},wut=()=>{Upe(),Hpe()},Vpe={version:Ape,VERSION:fut,atob:V5,atobPolyfill:Ope,btoa:H5,btoaPolyfill:Ipe,fromBase64:U5,toBase64:dy,encode:dy,encodeURI:Rpe,encodeURL:Rpe,utob:Lpe,btou:Dpe,decode:U5,isValid:Tut,fromUint8Array:TC,toUint8Array:Fpe,extendString:Upe,extendUint8Array:Hpe,extendBuiltins:wut},Hl=Xi(sme(),1),wC=new et,Fut=new et,Ic=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 i=Date.now();this.mergeInner(e,t),this.mergeInfo.elapsedTime+=Date.now()-i}static mergeInner(e,t=!0){if(!e.children||e.children.length<1)return;let i=e.children.length,n={},r=[];for(let h=0;h<i;++h){let i=e.children[h];if(i.children.length>0){this.mergeInner(i,t);continue}if(i.userData.relativeToCenter||!i.geometry)continue;let a=!1,s=Object.values(n);for(let t=s.length-1;t>=0;--t){let i=s[t].indexes[0];if(a=this.tryHandleMergeableObjects(e,h,i,n,r),a)break}for(let t=r.length-1;!a&&t>=0;--t){let i=r[t];if(a=this.tryHandleMergeableObjects(e,h,i,n,r),a)break}a||r.push(h)}if(Object.keys(n).length<=0)return;let a=[],s=[],o=[],l=[];Object.values(n).forEach((i=>{let n,r=i.indexes,h=e.children[r[0]],c=[],u=0,d=0,p=0,f=[];if(r.forEach((i=>{var n,r,a,s;let o=e.children[i],l=null==(n=o.geometry)?void 0:n.clone();if(l.applyMatrix4(o.matrix),l.userData.isLineSegments=3===o.type,c.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:u,positionStart:d,positionCount:e,indexStart:p,indexCount:t}),d+=e,p+=t,u++}})),0!==c.length){if(4===h.type){let e=Ui(c);if(!e)return;e.userData={},n=new bn(h.type),n.geometry=e,n.material=h.material,a.push(n)}else if(2===h.type||3===h.type){let e=Rr.mergeLineGeometries(c,t,h.material instanceof Iu||h.material instanceof cn,f);if(!e)return;n=new bn(3),n.geometry=e,n.material=h.material,s.push(n)}else if(1===h.type){let e=Ui(c);if(!e)return;e.userData={},n=new bn(h.type),n.geometry=e,n.material=h.material,o.push(n)}n&&(t?n.userData.batches=f:(n.userData=h.userData,n.userData.batches=void 0),n.userData.layerName=h.userData.layerName,n.name=`[Merged] ${h.name}`,n.renderOrder=h.renderOrder,n.layers.mask=h.layers.mask,l.push(...r)),c.forEach((e=>{e.dispose(),Qt.releaseGeometryManually(e)})),c=[]}})),l.sort(((e,t)=>t-e)),l.forEach((t=>{let i=e.children[t];e.remove(i)})),[...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,i,n,r){let a=!1,s=Array.isArray(e),o=s?e.length:e.children.length;if(t===i||t>=o||i>=o)return a;let l=s?e[t]:e.children[t],h=s?e[i]:e.children[i];return this.areObjectsMergeable(l,h)&&Rr.areGeometriesMergeable(l.geometry,h.geometry)&&es.materialsEquals(l.material,h.material)&&(n[i]||(n[i]={indexes:[i]},this.removeFromArray(r,i)),n[i].indexes.push(t),a=!0),a}static isFilteredByOtherFactors(e,t){let i=e;if(4===i.type&&i.material&&i.material.isShaderMaterial)return!0;let n=!1,r=e;for(;r&&r!==t;){let e=r.userData;if(e.relativeToCenter||e.spatialFilterHandle){n=!0;break}r=r.parent}return n}static deepMerge(e,t,i=!0,n=!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 i=!1,n=Object.values(o);for(let t=n.length-1;t>=0;--t){let r=n[t].indexes[0];if(i=this.tryHandleMergeableObjects(e,m,r,o,l),i)break}for(let t=l.length-1;!i&&t>=0;--t){let n=l[t];if(i=this.tryHandleMergeableObjects(e,m,n,o,l),i)break}i||l.push(m)}if(Object.keys(o).length<=0)return a;se.debug(`[Merge] Built merged indexes for ${e.length} objects in ${(Date.now()-s)/1e3}s`),s=Date.now();let h=[],c=[],u=[],d=[];Object.values(o).forEach((i=>{let n=i.indexes;if(n.length<2)return;let a,s=e[n[0]],o=[],l=0,p=0,f=0,m=[];if(n.forEach((i=>{var n,a,h,c,u;let d=e[i],g=null==(n=d.geometry)?void 0:n.clone();if(s.material instanceof Gn&&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,i=(null==(c=g.index)?void 0:c.count)||0;(2===s.type||3===s.type)&&(g.boundingSphere||g.computeBoundingSphere(),e=null==(u=g.boundingSphere)?void 0:u.clone()),m.push({batchId:l,positionStart:p,positionCount:t,indexStart:f,indexCount:i,boundingSphere:e}),p+=t,f+=i,l++}})),0!==o.length){if(4===s.type){let e=Ui(o);if(!e)return;e.userData={},a=new bn(s.type),a.geometry=e,a.material=s.material,h.push(a)}else if(2===s.type||3===s.type){let e=Rr.mergeLineGeometries(o,r,s.material instanceof Iu||s.material instanceof cn,m);if(!e)return;a=new bn(3),a.geometry=e,a.material=s.material,c.push(a)}else if(1===s.type){let e=Ui(o);if(!e)return;e.userData={},a=new bn(s.type),a.geometry=e,a.material=s.material,u.push(a)}a&&(r?a.userData.batches=m:(a.userData=s.userData,a.userData.batches=void 0),a.userData.layerName=s.userData.layerName,a.name=`[Merged] ${s.name}`,a.renderOrder=s.renderOrder,a.layers.mask=s.layers.mask,n.forEach((e=>d.push(e)))),o.forEach((e=>{e.dispose(),Qt.releaseGeometryManually(e)})),o=[]}})),se.debug(`[Merge] Ran deepMerge() in ${(Date.now()-s)/1e3}s`);let p=a.removed;d.forEach((t=>{let n=e[t];p.push(n),i&&n.removeFromParent()}));let f=a.added;return[...h,...c,...u].forEach((e=>{f.push(e),i&&t&&t.add(e)})),this.mergeInfo.removedObjects+=d.length,this.mergeInfo.mergedMeshes+=h.length,this.mergeInfo.mergedLines+=c.length,this.mergeInfo.mergedPoints+=u.length,n&&t&&Hn.removeEmptyObjects(t),a}static applyMatrix(e,t,i){let n=t;for(wC.identity();n&&n!==i&&(wC.premultiply(n.matrix),n.parent);)n=n.parent;return wC.equals(Fut)?e:e.applyMatrix4(wC)}static removeFromArray(e,t){for(let i=e.length-1;i>=0;--i)if(e[i]===t)return void e.splice(i,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 ame(e,t,i,n){let r={u_cameraZoom:i,u_patternLines:{value:e},u_patternAngle:{value:t},u_color:{value:n}},a=`\n uniform mat4 modelMatrix;\n uniform float u_cameraZoom;\n uniform vec3 u_color;\n varying vec3 v_pos;\n\n struct PatternLine {\n vec2 origin;\n vec2 delta;\n float angle;\n float pattern[MAX_PATTERN_SEGMENT_COUNT];\n float patternSum[MAX_PATTERN_SEGMENT_COUNT+1];\n float patternLength;\n };\n\n uniform PatternLine u_patternLines[${e.length}];\n uniform float u_patternAngle;\n\n #include <clipping_planes_pars_fragment>\n\n // Clamp [0..1] range\n #define saturate(a) clamp(a, 0.0, 1.0)\n\n const float EPS = 1000.0;\n\n vec2 getWorldScale() {\n return vec2(length(modelMatrix[0].xyz), length(modelMatrix[1].xyz));\n }\n\n vec2 rotate(vec2 st, float rotation) {\n const float PI = 3.1415926;\n float angle = rotation * PI/180.0;\n float sine = sin(angle), cosine = cos(angle);\n return vec2(cosine * st.x - sine * st.y, cosine * st.y + sine * st.x);\n }\n\n vec2 translate(vec2 samplePosition, vec2 offset) {\n //move sample point in the opposite direction that we want to move shapes in\n return samplePosition - offset;\n }\n\n vec2 scale(vec2 samplePosition, float scale) {\n return samplePosition / scale;\n }\n\n float sdfLine(vec2 st, vec2 a, vec2 b) {\n vec2 ap = st - a;\n vec2 ab = b - a;\n return abs(((ap.x * ab.y) - (ab.x * ap.y))) / length(ab);\n }\n\n float drawSpaceLine(vec2 st, float distanceBetweenLines, float thick) {\n float dist = sdfLine(st , vec2(0.0, 0.0) , vec2(1.0, 0.0));\n \n //vec2 tt = dFdy(st);\n //float scale = (abs(tt.x)+abs(tt.y))/2.0;\n //float scale = length(fwidth(st)) * 0.5;\n // close to a pixel\n //float thick = 2.0;\n //thick = (thick * 0.5 - 0.5) * scale;\n\n float lineDistance = abs(fract(dist / distanceBetweenLines + 0.5) - 0.5) * distanceBetweenLines;\n //float lineDistance = fract(dist / distanceBetweenLines);\n //float distanceChange = fwidth(dist) * 0.5;\n //float threshold = smoothstep(thick - distanceChange, thick + distanceChange, lineDistance);\n //float threshold = step(thick,lineDistance);\n // remove gradient\n //float threshold = step(0.001,lineDistance);\n float threshold = step(thick,lineDistance);\n\n return threshold;\n }\n\n float drawSolidLine(PatternLine patternLine, float thick) {\n vec2 origin = patternLine.origin;\n vec2 delta = patternLine.delta;\n float distanceBetweenLines = length(delta);\n\n origin = rotate(origin,u_patternAngle);\n vec2 st = rotate(v_pos.xy - origin, -(patternLine.angle + u_patternAngle));\n\n return drawSpaceLine(st, distanceBetweenLines , thick);\n }\n\n int getPatternIndex(PatternLine patternLine, float u, out float distance ) {\n //u = mod(u, patternLine.patternLength);\n float y = floor(u/patternLine.patternLength);\n u = u - patternLine.patternLength * y;\n //float distance = 0.0;\n\n #pragma unroll_loop_start\n for(int i = 1; i < patternLine.patternSum.length(); i++){\n if(u <= patternLine.patternSum[i]) {\n distance = u - patternLine.patternSum[i-1];\n return i - 1;\n }\n }\n #pragma unroll_loop_end\n\n return -1;\n }\n\n float drawDashedLine(PatternLine patternLine, float thick){\n float threshold = 1.0;\n vec2 origin = patternLine.origin;\n vec2 delta = patternLine.delta; \n float distanceBetweenLines = abs(delta.y);\n\n origin = rotate(origin, u_patternAngle);\n vec2 st = rotate(v_pos.xy - origin, -(patternLine.angle + u_patternAngle));\n\n float offsetX = st.y * delta.x/delta.y;\n float u = st.x - offsetX;\n float distance = 0.0;\n int index = getPatternIndex(patternLine, u, distance);\n if(index < 0) {\n return threshold;\n }\n\n float size = patternLine.pattern[index];\n if(size >= 0.0) {\n threshold = drawSpaceLine(st, distanceBetweenLines , thick);\n // Try to solve the problem caused by the precision after zooming out by drawing a part of the dashed line\n } else if (distance < thick) {\n //threshold = 0.8;\n threshold = drawSpaceLine(st, distanceBetweenLines , thick);\n }\n \n return threshold;\n }\n\n float drawLine(PatternLine patternLine, float thick) {\n float t = 0.0;\n if(patternLine.patternLength > 0.0) {\n t = drawDashedLine(patternLine, thick);\n } else {\n t = drawSolidLine(patternLine, thick);\n }\n return t;\n }\n\n void main() {\n #include <clipping_planes_fragment>\n \n vec2 worldScale = getWorldScale();\n float averageScale = (abs(worldScale.x) + abs(worldScale.y))/2.0;\n // possible size of a pixel \n float thick = (0.7 / averageScale) / u_cameraZoom;\n\n if(thick > EPS) {\n gl_FragColor = vec4(u_color, 1.0);\n #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 cn({uniforms:r,vertexShader:"\n varying vec3 v_pos;\n\n #include <clipping_planes_pars_vertex>\n void main() {\n //vec4 worldPosition = modelMatrix * vec4(position, 1.0);\n v_pos = position;\n\n #include <begin_vertex>\n #include <project_vertex>\n #include <clipping_planes_vertex>\n }",fragmentShader:a,clipping:!0})}Ic.mergeInfo={removedObjects:0,mergedMeshes:0,mergedLines:0,mergedPoints:0,mergedUnknownTypeObjects:0,elapsedTime:0};var SC=class{static createLineShaderMaterial(e,t,i,n,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]*=i,a+=Math.abs(s[h]);let o=Ri.merge([Jt.common,{pattern:{type:"fv1",value:s},patternLength:{type:"f",value:a},u_color:{value:new ct(t)}}]);o.u_viewportScale=n,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 cn({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})}},W5={};zT(W5,{default:()=>q5});var G5={};zT(G5,{default:()=>z5});var z5=(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)))),q5=(e,t,i,n,r)=>{let a=i.length,s=i[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(n){if(n.length!==a+t+1)throw new Error("bad knot vector length")}else{n=[];for(let e=0;e<a+t+1;e++)n[e]=e}let o,l=[t,n.length-1-t],h=n[l[0]],c=n[l[1]];for(e=e*(c-h)+h,e=Math.max(e,h),e=Math.min(e,c),o=l[0];o<l[1]&&!(e>=n[o]&&e<=n[o+1]);o++);let u,d=[];for(let f=0;f<a;f++){d[f]=[];let e=r?r[f]:1;for(let t=0;t<s;t++)d[f][t]=i[f][t]*e;d[f][s]=e}for(let f=1;f<=t+1;f++)for(let i=o;i>o-t-1+f;i--){u=(e-n[i])/(n[i+t+1-f]-n[i]);for(let e=0;e<s+1;e++)d[i][e]=(1-u)*d[i-1][e]+u*d[i][e]}let p=[];for(let f=0;f<s;f++)p[f]=z5(d[o][f]/d[o][s],-9);return p},Nut={d:"\xb0",c:"\u2300",p:"\xb1"},MC=(e,t)=>{if(!e)return[];e=e.replace(/%%(.)/g,((e,t)=>Nut[t]||t)).replace(/\^I/g," ");let i,n=null==t?void 0:t.encoding,r=n instanceof TextDecoder?n:void 0,a="",s=[],o=e=>{a&&(s.push(a),a=""),s.push(e)};for(let l=0;l<e.length;l++)switch(i=e[l]){default:a+=i;break;case"\\":switch(i=e[++l]){default:a+=i;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(;i=e[++l];){if(";"===i){o({f:t});break}if("|"===i){let i={f:t},n=e.indexOf(";",++l);for(let t of e.slice(l,n).split("|"))i[t[0]]=+t.slice(1);l=n,o(i);break}t+="\\"===i?e[++l]:i}break}case"S":{let t,n="",r="";for(;i=e[++l];){if(";"===i){t&&o("/"===t||"#"===t?n+"/"+r:n+r);break}"\\"===i?t?r+=e[++l]:n+=e[++l]:t?r+=i:"^"===i||"/"===i||"#"===i?t=i:n+=i}break}case"H":case"W":{let t=++l,[,n,r]=e.slice(t,l=e.indexOf(";",l)).match(/^(\d*(?:\.\d+)?)(\D*)$/);o({[i]:[+n,r]})}break;case"Q":case"A":case"C":case"c":case"T":{let t=++l;o({[i]:+e.slice(t,l=e.indexOf(";",l))});break}case"L":case"O":case"K":o({[i]:1});break;case"l":case"o":case"k":o({[i.toUpperCase()]:0});break;case"U":case"u":"+"===e[l+1]?(a+=String.fromCodePoint(parseInt(e.substr(l+2,4),16)),l+=5):a+=i;break;case"M":case"m":n?"+"!==e[l+1]||"0"!==e[l+2]&&"1"!==e[l+2]?a+=i:(a+=(r=r||new TextDecoder(n)).decode(new Uint8Array([parseInt(e.substr(l+3,2),16),parseInt(e.substr(l+5,2),16)])),l+=6):a+="\\"+i}break;case"{":{let t=1,n=l;for(;i=e[++l];)if("{"===i)t++;else if("}"===i){if(0==--t){o(MC(e.slice(n+1,l)));break}}else"\\"===i&&l++;break}}return a&&s.push(a),s},But={d:"\xb0",c:"\u2300",p:"\xb1"},Uut=(e,t)=>(e=Hut(e),t?Vut(e,t):e),Hut=e=>e.replace(/\\[uU]\+([0-9a-fA-F]{4})/g,((e,t)=>String.fromCodePoint(parseInt(t,16)))),Vut=(e,t)=>{let i=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,n,r)=>(i=i||new TextDecoder(t)).decode(new Uint8Array([parseInt(n,16),parseInt(r,16)]))))},RC=(e,t)=>{let i=0,n={text:""},r=[n],a=(e=Uut(e,null==t?void 0:t.encoding)).matchAll(/%%(\d\d\d|.)/g);for(let s of a){n.text+=e.slice(i,s.index);let t=s[1].toLowerCase(),a=But[t];a?n.text+=a:3===t.length?n.text+=String.fromCodePoint(+t):"k"===t||"o"===t||"u"===t?(n=Ii(Tr({},n),{text:""}),n[t]?delete n[t]:n[t]=1,r.push(n)):n.text+=t,i=s.index+s[0].length}return n.text+=e.slice(i),r.filter((e=>e.text))},j5=(e=>(e.Unitless="Unitless",e.Inches="Inches",e.Feet="Feet",e.Millimeters="Millimeters",e.Centimeters="Centimeters",e.Meters="Meters",e))(j5||{}),ome=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),lme=(e,t)=>ome(e)/ome(t),AC=class extends Qs{constructor(e,t={}){let i=t.font;if(void 0===i)super();else{let n=i.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(n,t)}this.type="TextGeometry"}},CC=class{constructor(e){this.isFont=!0,this.type="Font",this.data=e}generateShapes(e,t=100){let i=[],n=zut(e,t,this.data);for(let r=0,a=n.length;r<a;r++)i.push(...n[r].toShapes());return i}};function zut(e,t,i){let n=Array.from(e),r=t/i.resolution,a=(i.boundingBox.yMax-i.boundingBox.yMin+i.underlineThickness)*r,s=[],o=0,l=0;for(let h=0;h<n.length;h++){let e=n[h];if("\n"===e)o=0,l-=a;else{let t=Gut(e,r,o,l,i);o+=t.offsetX,s.push(t.path)}}return s}function Gut(e,t,i,n,r){let a=r.glyphs[e]||r.glyphs["?"];if(!a)return void console.error('THREE.Font: character "'+e+'" does not exists in font family '+r.familyName+".");let s,o,l,h,c,u,d,p,f=new Cm;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+i,o=e[r++]*t+n,f.moveTo(s,o);break;case"l":s=e[r++]*t+i,o=e[r++]*t+n,f.lineTo(s,o);break;case"q":l=e[r++]*t+i,h=e[r++]*t+n,c=e[r++]*t+i,u=e[r++]*t+n,f.quadraticCurveTo(c,u,l,h);break;case"b":l=e[r++]*t+i,h=e[r++]*t+n,c=e[r++]*t+i,u=e[r++]*t+n,d=e[r++]*t+i,p=e[r++]*t+n,f.bezierCurveTo(c,u,d,p,l,h)}}return{offsetX:a.ha*t,path:f}}var JE="0.2.61",cme="VERSION",qut=()=>window.localStorage.getItem(cme),Wut=()=>{window.localStorage.setItem(cme,JE)},ume=()=>qut()!==JE&&(Wut(),!0),py=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:[]}],this.db=void 0}static instance(){return py._instance||(py._instance=new py),py._instance}getDatabase(){return ft(this,null,(function*(){let e=yield this.getDB(this.DATABASE_NAME);return this.db||(e.close(),ume()&&(yield this.deleteDataBase(this.DATABASE_NAME)),e=yield this.getUpgradedDB(e)),e.onclose=()=>{this.db=void 0,se.debug(`[DB] Db ${e.name} is closed.`)},e.onerror=t=>{this.db=void 0,se.debug(`[DB] Db ${e.name} encountered error.`,t)},e.onabort=t=>{this.db=void 0,se.debug(`[DB] Db ${e.name} aborted.`,t)},e.onversionchange=e=>{se.debug("onversionchange",e)},this.db=e,Promise.resolve(this.db)}))}closeDatabase(){this.db&&this.db.close()}deleteDataBase(e){return new Promise(((t,i)=>{let n=window.indexedDB.deleteDatabase(e);n.onerror=e=>{se.debug(e),i(e)},n.onsuccess=i=>{let n=i.target;se.debug(`[DB] Db ${e} delete old version ${i.oldVersion}.`),t(n)}}))}getDB(e){return ft(this,null,(function*(){return new Promise(((t,i)=>{let n=window.indexedDB.open(e);n.onerror=i,n.onsuccess=e=>{let i=e.target.result;se.debug(`[DB] Db ${i.name} opened (version ${i.version}).`),t(i)}}))}))}getUpgradedDB(e){return ft(this,null,(function*(){return new Promise(((t,i)=>{se.debug(`[DB] Upgrading db ${e.name} (version ${e.version})`);let n=window.indexedDB.open(e.name,e.version+1);n.onerror=i,n.onblocked=e=>{se.debug("onblocked",e)},n.onupgradeneeded=e=>{e.target.transaction.oncomplete=()=>{se.debug(`[DB] Upgrade is done (new version: ${t.version}).`)};let t=e.target.result,i=[];for(let n=0;n<this.TABLES.length;++n){let e=this.TABLES[n];if(!t.objectStoreNames.contains(e.name)){se.debug(`[DB] Creating table ${e.name}...`);let n=this.createTable(t,e.name,e.options,e.indexArray);i.push(n)}}i.length>0&&Promise.all(i).then((()=>{se.debug(`[DB] All(${i.length}) tables created.`)}))},n.onsuccess=e=>{let i=e.target.result;se.debug(`[DB] Db ${i.name} opened (version ${i.version}).`),t(i)}}))}))}createTable(e,t,i,n){return ft(this,null,(function*(){return new Promise((r=>{let a=e.createObjectStore(t,i);n&&n.forEach((e=>{a.createIndex(e.name,e.fields,{unique:e.unique})})),se.debug(`[DB] Table ${t} created.`),r(e)}))}))}},ns=py;ns._instance=void 0;var Wu=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,i){let n=this.tableName();ns.instance().getDatabase().then((r=>{let a=r.transaction([n],"readwrite").objectStore(n).add(e);a.onsuccess=t,a.onerror=i})).finally((()=>{ns.instance().closeDatabase()})).catch((e=>{i&&i(e)}))}save(e,t,i){let n=this.tableName();ns.instance().getDatabase().then((r=>{let a=r.transaction([n],"readwrite").objectStore(n).put(e);a.onsuccess=t,a.onerror=i})).finally((()=>{ns.instance().closeDatabase()}))}delete(e,t,i){let n=this.tableName();ns.instance().getDatabase().then((r=>{let a=r.transaction([n],"readwrite").objectStore(n).delete(e);a.onsuccess=t,a.onerror=i})).finally((()=>{ns.instance().closeDatabase()}))}update(){ns.instance().getDatabase().then((()=>{}))}query(e,t){let i=this.tableName();ns.instance().getDatabase().then((n=>{let r=n.transaction([i],"readonly").objectStore(i).openCursor();r.onsuccess=t=>{let i=t.target.result;i&&i.continue(),e&&e(i)},r.onerror=t})).finally((()=>{ns.instance().closeDatabase()}))}queryByIndex(e,t,i,n){let r=this.tableName();ns.instance().getDatabase().then((a=>{let s=a.transaction([r],"readonly").objectStore(r).index(e).get(t);s.onerror=n,s.onsuccess=function(e){var t;let n=null==(t=e.target)?void 0:t.result;i&&i(n)}})).finally((()=>{ns.instance().closeDatabase()}))}queryAll(e,t){let i=this.tableName();ns.instance().getDatabase().then((n=>{let r=n.transaction([i],"readonly").objectStore(i).getAll();r.onsuccess=t=>{e&&e(r.result)},r.onerror=t})).finally((()=>{ns.instance().closeDatabase()}))}clearAll(e,t){let i=this.tableName();ns.instance().getDatabase().then((n=>{let r=n.transaction([i],"readwrite").objectStore(i).clear();r.onsuccess=t=>{e&&e(t)},r.onerror=e=>{t&&t(e)}})).finally((()=>{ns.instance().closeDatabase()}))}},my=class extends Wu{tableName(){return"annotation"}static instance(){return my._instance||(my._instance=new my),my._instance}query(e,t,i){let n=[];super.query((i=>{i?!i.value||i.value.projectId!==e||n.push(i.value):t&&t(n)}),(e=>{console.log(e)}))}},X5=my;X5._instance=void 0;var gy=class extends Wu{tableName(){return"viewpoint"}static instance(){return gy._instance||(gy._instance=new gy),gy._instance}query(e,t,i){let n=[];super.query((i=>{i?!i.value||i.value.projectId!==e||n.push(i.value):t&&t(n)}),(e=>{i&&i(),console.log(e)}))}},Y5=gy;Y5._instance=void 0;var vy=class extends Wu{tableName(){return"dxfdata"}static instance(){return vy._instance||(vy._instance=new vy),vy._instance}query(e,t,i){let n=[],r=this.tableName();ns.instance().getDatabase().then((a=>{let s=a.transaction([r],"readonly").objectStore(r).get(e);s.onerror=e=>{i&&i(e),se.info("[DxfDataTable] Failed to query !",e)},s.onsuccess=()=>{s.result&&n.push(s.result),t&&t(n)}})).finally((()=>{ns.instance().closeDatabase()}))}},yy=vy;yy._instance=void 0;var Km=class extends Wu{tableName(){return"fontdata"}static instance(){return Km._instance||(Km._instance=new Km),Km._instance}query(e){let t;return new Promise(((i,n)=>{super.query((n=>{n?!n.value||n.value.fileName!==e||(t=n.value):i(t)}),(e=>{n(e)}))}))}queryAll(){return ft(this,null,(function*(){return new Promise(((e,t)=>{CG(Km.prototype,this,"queryAll").call(this,(t=>{e(t)}),(e=>{t(e)}))}))}))}},sd=Km;sd._instance=void 0;var xy=class extends CC{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 ft(this,null,(function*(){let e=this.getFontFile();return new Promise(((t,i)=>{sd.instance().save(e,(()=>{console.log(`[FontFile] Saved '${this.fileName}' (${this.fileHeader}) to indexedDb`),t()}),(e=>i(`[FontFile] Failed to save '${this.fileName}' (${this.fileHeader}) to indexedDb! ${e}`)))}))}))}getFontDataByIndexedDb(){return ft(this,null,(function*(){return sd.instance().query(this.fileName)}))}releaseFontData(){this.data={}}};String.prototype.codePointAt||function(){var e=function(){try{var e={},t=Object.defineProperty,i=t(e,e,e)&&t}catch(e){}return i}(),t=function(e){if(null==this)throw TypeError();var t=String(this),i=t.length,n=e?Number(e):0;if(n!=n&&(n=0),!(n<0||n>=i)){var r,a=t.charCodeAt(n);return a>=55296&&a<=56319&&i>n+1&&(r=t.charCodeAt(n+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 f6=0,Zme=-3;function t_(){this.table=new Uint16Array(16),this.trans=new Uint16Array(288)}function jut(e,t){this.source=e,this.sourceIndex=0,this.tag=0,this.bitcount=0,this.dest=t,this.destLen=0,this.ltree=new t_,this.dtree=new t_}var Kme=new t_,Jme=new t_,p6=new Uint8Array(30),m6=new Uint16Array(30),Qme=new Uint8Array(30),ege=new Uint16Array(30),Xut=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),hme=new t_,ju=new Uint8Array(320);function tge(e,t,i,n){var r,a;for(r=0;r<i;++r)e[r]=0;for(r=0;r<30-i;++r)e[r+i]=r/i|0;for(a=n,r=0;r<30;++r)t[r]=a,a+=1<<e[r]}function Yut(e,t){var i;for(i=0;i<7;++i)e.table[i]=0;for(e.table[7]=24,e.table[8]=152,e.table[9]=112,i=0;i<24;++i)e.trans[i]=256+i;for(i=0;i<144;++i)e.trans[24+i]=i;for(i=0;i<8;++i)e.trans[168+i]=280+i;for(i=0;i<112;++i)e.trans[176+i]=144+i;for(i=0;i<5;++i)t.table[i]=0;for(t.table[5]=32,i=0;i<32;++i)t.trans[i]=i}var dme=new Uint16Array(16);function $5(e,t,i,n){var r,a;for(r=0;r<16;++r)e.table[r]=0;for(r=0;r<n;++r)e.table[t[i+r]]++;for(e.table[0]=0,a=0,r=0;r<16;++r)dme[r]=a,a+=e.table[r];for(r=0;r<n;++r)t[i+r]&&(e.trans[dme[t[i+r]]++]=r)}function $ut(e){e.bitcount--||(e.tag=e.source[e.sourceIndex++],e.bitcount=7);var t=1&e.tag;return e.tag>>>=1,t}function Xu(e,t,i){if(!t)return i;for(;e.bitcount<24;)e.tag|=e.source[e.sourceIndex++]<<e.bitcount,e.bitcount+=8;var n=e.tag&65535>>>16-t;return e.tag>>>=t,e.bitcount-=t,n+i}function i6(e,t){for(;e.bitcount<24;)e.tag|=e.source[e.sourceIndex++]<<e.bitcount,e.bitcount+=8;var i=0,n=0,r=0,a=e.tag;do{n=2*n+(1&a),a>>>=1,++r,i+=t.table[r],n-=t.table[r]}while(n>=0);return e.tag=a,e.bitcount-=r,t.trans[i+n]}function Zut(e,t,i){var n,r,a,s,o,l;for(n=Xu(e,5,257),r=Xu(e,5,1),a=Xu(e,4,4),s=0;s<19;++s)ju[s]=0;for(s=0;s<a;++s){var h=Xu(e,3,0);ju[Xut[s]]=h}for($5(hme,ju,0,19),o=0;o<n+r;){var c=i6(e,hme);switch(c){case 16:var u=ju[o-1];for(l=Xu(e,2,3);l;--l)ju[o++]=u;break;case 17:for(l=Xu(e,3,3);l;--l)ju[o++]=0;break;case 18:for(l=Xu(e,7,11);l;--l)ju[o++]=0;break;default:ju[o++]=c}}$5(t,ju,0,n),$5(i,ju,n,r)}function fme(e,t,i){for(;;){var n,r,a,s,o=i6(e,t);if(256===o)return f6;if(o<256)e.dest[e.destLen++]=o;else for(n=Xu(e,p6[o-=257],m6[o]),r=i6(e,i),s=a=e.destLen-Xu(e,Qme[r],ege[r]);s<a+n;++s)e.dest[e.destLen++]=e.dest[s]}}function Kut(e){for(var t,i;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 Zme;for(e.sourceIndex+=4,i=t;i;--i)e.dest[e.destLen++]=e.source[e.sourceIndex++];return e.bitcount=0,f6}function Jut(e,t){var i,n,r=new jut(e,t);do{switch(i=$ut(r),Xu(r,2,0)){case 0:n=Kut(r);break;case 1:n=fme(r,Kme,Jme);break;case 2:Zut(r,r.ltree,r.dtree),n=fme(r,r.ltree,r.dtree);break;default:n=Zme}if(n!==f6)throw new Error("Data error")}while(!i);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}Yut(Kme,Jme),tge(p6,m6,4,3),tge(Qme,ege,2,1),p6[28]=0,m6[28]=258;var Qut=Jut;function by(e,t,i,n,r){return Math.pow(1-r,3)*e+3*Math.pow(1-r,2)*r*t+3*(1-r)*Math.pow(r,2)*i+Math.pow(r,3)*n}function Hf(){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 nge(e){throw new Error(e)}function pme(e,t){e||nge(t)}Hf.prototype.isEmpty=function(){return isNaN(this.x1)||isNaN(this.y1)||isNaN(this.x2)||isNaN(this.y2)},Hf.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))},Hf.prototype.addX=function(e){this.addPoint(e,null)},Hf.prototype.addY=function(e){this.addPoint(null,e)},Hf.prototype.addBezier=function(e,t,i,n,r,a,s,o){var l=[e,t],h=[i,n],c=[r,a],u=[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*c[d],f=-3*l[d]+9*h[d]-9*c[d]+3*u[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(by(l[d],h[d],c[d],u[d],v)),1===d&&this.addY(by(l[d],h[d],c[d],u[d],v)));var y=(-p-Math.sqrt(g))/(2*f);0<y&&y<1&&(0===d&&this.addX(by(l[d],h[d],c[d],u[d],y)),1===d&&this.addY(by(l[d],h[d],c[d],u[d],y)))}}else{if(0===p)continue;var x=-m/p;0<x&&x<1&&(0===d&&this.addX(by(l[d],h[d],c[d],u[d],x)),1===d&&this.addY(by(l[d],h[d],c[d],u[d],x)))}}},Hf.prototype.addQuad=function(e,t,i,n,r,a){var s=e+.6666666666666666*(i-e),o=t+2/3*(n-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,i,n,r,a){this.commands.push({type:"C",x1:e,y1:t,x2:i,y2:n,x:r,y:a})},ks.prototype.quadTo=ks.prototype.quadraticCurveTo=function(e,t,i,n){this.commands.push({type:"Q",x1:e,y1:t,x:i,y:n})},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 Hf){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 Hf,t=0,i=0,n=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=n=s.x,i=r=s.y;break;case"L":e.addPoint(s.x,s.y),n=s.x,r=s.y;break;case"Q":e.addQuad(n,r,s.x1,s.y1,s.x,s.y),n=s.x,r=s.y;break;case"C":e.addBezier(n,r,s.x1,s.y1,s.x2,s.y2,s.x,s.y),n=s.x,r=s.y;break;case"Z":n=t,r=i;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 i=this.commands[t];"M"===i.type?e.moveTo(i.x,i.y):"L"===i.type?e.lineTo(i.x,i.y):"C"===i.type?e.bezierCurveTo(i.x1,i.y1,i.x2,i.y2,i.x,i.y):"Q"===i.type?e.quadraticCurveTo(i.x1,i.y1,i.x,i.y):"Z"===i.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 i(){for(var e=arguments,i="",n=0;n<arguments.length;n+=1){var r=e[n];r>=0&&n>0&&(i+=" "),i+=t(r)}return i}e=void 0!==e?e:2;for(var n="",r=0;r<this.commands.length;r+=1){var a=this.commands[r];"M"===a.type?n+="M"+i(a.x,a.y):"L"===a.type?n+="L"+i(a.x,a.y):"C"===a.type?n+="C"+i(a.x1,a.y1,a.x2,a.y2,a.x,a.y):"Q"===a.type?n+="Q"+i(a.x1,a.y1,a.x,a.y):"Z"===a.type&&(n+="Z")}return n},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),i=document.createElementNS("http://www.w3.org/2000/svg","path");return i.setAttribute("d",t),i};var Yn={fail:nge,argument:pme,assert:pme},mme=32768,gme=2147483648,_y={},tn={},Qn={};function kc(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=kc(1),tn.CHAR=function(e){return[e.charCodeAt(0)]},Qn.CHAR=kc(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=[],i=0;i<e.length;i+=1)t[i]=e.charCodeAt(i);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=kc(2),tn.SHORT=function(e){return e>=mme&&(e=-(2*mme-e)),[e>>8&255,255&e]},Qn.SHORT=kc(2),tn.UINT24=function(e){return[e>>16&255,e>>8&255,255&e]},Qn.UINT24=kc(3),tn.ULONG=function(e){return[e>>24&255,e>>16&255,e>>8&255,255&e]},Qn.ULONG=kc(4),tn.LONG=function(e){return e>=gme&&(e=-(2*gme-e)),[e>>24&255,e>>16&255,e>>8&255,255&e]},Qn.LONG=kc(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=kc(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=kc(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=kc(3),tn.NUMBER32=function(e){return[29,e>>24&255,e>>16&255,e>>8&255,255&e]},Qn.NUMBER32=kc(5),tn.REAL=function(e){var t=e.toString(),i=/\.(\d*?)(?:9{5,20}|0{5,20})\d{0,2}(?:e(.+)|$)/.exec(t);if(i){var n=parseFloat("1e"+((i[2]?+i[2]:0)+i[1].length));t=(Math.round(e*n)/n).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,c=(r+=1&r.length?"f":"ff").length;h<c;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,_y.UTF8=function(e,t,i){for(var n=[],r=i,a=0;a<r;a++,t+=1)n[a]=e.getUint8(t);return String.fromCharCode.apply(null,n)},_y.UTF16=function(e,t,i){for(var n=[],r=i/2,a=0;a<r;a++,t+=2)n[a]=e.getUint16(t);return String.fromCharCode.apply(null,n)},tn.UTF16=function(e){for(var t=[],i=0;i<e.length;i+=1){var n=e.charCodeAt(i);t[t.length]=n>>8&255,t[t.length]=255&n}return t},Qn.UTF16=function(e){return 2*e.length};var s6={"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"};_y.MACSTRING=function(e,t,i,n){var r=s6[n];if(void 0!==r){for(var a="",s=0;s<i;s++){var o=e.getUint8(t+s);a+=o<=127?String.fromCharCode(o):r[127&o]}return a}};var IC="function"==typeof WeakMap&&new WeakMap,LC,eht=function(e){if(!LC)for(var t in LC={},s6)LC[t]=new String(t);var i=LC[e];if(void 0!==i){if(IC){var n=IC.get(i);if(void 0!==n)return n}var r=s6[e];if(void 0!==r){for(var a={},s=0;s<r.length;s++)a[r.charCodeAt(s)]=s+128;return IC&&IC.set(i,a),a}}};function a6(e){return e>=-128&&e<=127}function tht(e,t,i){for(var n=0,r=e.length;t<r&&n<64&&0===e[t];)++t,++n;return i.push(128|n-1),t}function nht(e,t,i){for(var n=0,r=e.length,a=t;a<r&&n<64;){var s=e[a];if(!a6(s)||0===s&&a+1<r&&0===e[a+1])break;++a,++n}i.push(n-1);for(var o=t;o<a;++o)i.push(e[o]+256&255);return a}function rht(e,t,i){for(var n=0,r=e.length,a=t;a<r&&n<64;){var s=e[a];if(0===s||a6(s)&&a+1<r&&a6(e[a+1]))break;++a,++n}i.push(64|n-1);for(var o=t;o<a;++o){var l=e[o];i.push(l+65536>>8&255,l+256&255)}return a}tn.MACSTRING=function(e,t){var i=eht(t);if(void 0!==i){for(var n=[],r=0;r<e.length;r++){var a=e.charCodeAt(r);if(a>=128&&void 0===(a=i[a]))return;n[r]=a}return n}},Qn.MACSTRING=function(e,t){var i=tn.MACSTRING(e,t);return void 0!==i?i.length:0},tn.VARDELTAS=function(e){for(var t=0,i=[];t<e.length;){var n=e[t];t=0===n?tht(e,t,i):n>=-128&&n<=127?nht(e,t,i):rht(e,t,i)}return i},tn.INDEX=function(e){for(var t=1,i=[t],n=[],r=0;r<e.length;r+=1){var a=tn.OBJECT(e[r]);Array.prototype.push.apply(n,a),t+=a.length,i.push(t)}if(0===n.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<i.length;h+=1){var c=l(i[h]);Array.prototype.push.apply(s,c)}return Array.prototype.concat(tn.Card16(e.length),tn.OffSize(o),s,n)},Qn.INDEX=function(e){return tn.INDEX(e).length},tn.DICT=function(e){for(var t=[],i=Object.keys(e),n=i.length,r=0;r<n;r+=1){var a=parseInt(i[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 i=[];if(Array.isArray(t))for(var n=0;n<t.length;n+=1)Yn.argument(e.length===t.length,"Not enough arguments given for type"+t),i=i.concat(tn.OPERAND(e[n],t[n]));else if("SID"===t)i=i.concat(tn.NUMBER(e));else if("offset"===t)i=i.concat(tn.NUMBER32(e));else if("number"===t)i=i.concat(tn.NUMBER(e));else{if("real"!==t)throw new Error("Unknown operand type "+t);i=i.concat(tn.REAL(e))}return i},tn.OP=tn.BYTE,Qn.OP=Qn.BYTE;var DC="function"==typeof WeakMap&&new WeakMap;function Ws(e,t,i){if(t.length&&("coverageFormat"!==t[0].name||1===t[0].value))for(var n=0;n<t.length;n+=1){var r=t[n];this[r.name]=r.value}if(this.tableName=e,this.fields=t,i)for(var a=Object.keys(i),s=0;s<a.length;s+=1){var o=a[s],l=i[o];void 0!==this[o]&&(this[o]=l)}}function n_(e,t,i){void 0===i&&(i=t.length);var n=new Array(t.length+1);n[0]={name:e+"Count",type:"USHORT",value:i};for(var r=0;r<t.length;r++)n[r+1]={name:e+r,type:"USHORT",value:t[r]};return n}function o6(e,t,i){var n=t.length,r=new Array(n+1);r[0]={name:e+"Count",type:"USHORT",value:n};for(var a=0;a<n;a++)r[a+1]={name:e+a,type:"TABLE",value:i(t[a],a)};return r}function r_(e,t,i){var n=t.length,r=[];r[0]={name:e+"Count",type:"USHORT",value:n};for(var a=0;a<n;a++)r=r.concat(i(t[a],a));return r}function BC(e){1===e.format?Ws.call(this,"coverageTable",[{name:"coverageFormat",type:"USHORT",value:1}].concat(n_("glyph",e.glyphs))):2===e.format?Ws.call(this,"coverageTable",[{name:"coverageFormat",type:"USHORT",value:2}].concat(r_("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 UC(e){Ws.call(this,"scriptListTable",r_("scriptRecord",e,(function(e,t){var i=e.script,n=i.defaultLangSys;return Yn.assert(!!n,"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 Ws("scriptTable",[{name:"defaultLangSys",type:"TABLE",value:new Ws("defaultLangSys",[{name:"lookupOrder",type:"USHORT",value:0},{name:"reqFeatureIndex",type:"USHORT",value:n.reqFeatureIndex}].concat(n_("featureIndex",n.featureIndexes)))}].concat(r_("langSys",i.langSysRecords,(function(e,t){var i=e.langSys;return[{name:"langSysTag"+t,type:"TAG",value:e.tag},{name:"langSys"+t,type:"TABLE",value:new Ws("langSys",[{name:"lookupOrder",type:"USHORT",value:0},{name:"reqFeatureIndex",type:"USHORT",value:i.reqFeatureIndex}].concat(n_("featureIndex",i.featureIndexes)))}]}))))}]})))}function HC(e){Ws.call(this,"featureListTable",r_("featureRecord",e,(function(e,t){var i=e.feature;return[{name:"featureTag"+t,type:"TAG",value:e.tag},{name:"feature"+t,type:"TABLE",value:new Ws("featureTable",[{name:"featureParams",type:"USHORT",value:i.featureParams}].concat(n_("lookupListIndex",i.lookupListIndexes)))}]})))}function VC(e,t){Ws.call(this,"lookupListTable",o6("lookup",e,(function(e){var i=t[e.lookupType];return Yn.assert(!!i,"Unable to write GSUB lookup type "+e.lookupType+" tables."),new Ws("lookupTable",[{name:"lookupType",type:"USHORT",value:e.lookupType},{name:"lookupFlag",type:"USHORT",value:e.lookupFlag}].concat(o6("subtable",e.subtables,i)))})))}tn.CHARSTRING=function(e){if(DC){var t=DC.get(e);if(void 0!==t)return t}for(var i=[],n=e.length,r=0;r<n;r+=1){var a=e[r];i=i.concat(tn[a.type](a.value))}return DC&&DC.set(e,i),i},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=[],i=e.fields.length,n=[],r=[],a=0;a<i;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]),n.push(h)):t=t.concat(h)}for(var c=0;c<n.length;c+=1){var u=r[c],d=t.length;Yn.argument(d<65536,"Table "+e.tableName+" too big."),t[u]=d>>8,t[u+1]=255&d,t=t.concat(n[c])}return t},Qn.TABLE=function(e){for(var t=0,i=e.fields.length,n=0;n<i;n+=1){var r=e.fields[n],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},Ws.prototype.encode=function(){return tn.TABLE(this)},Ws.prototype.sizeOf=function(){return Qn.TABLE(this)},BC.prototype=Object.create(Ws.prototype),BC.prototype.constructor=BC,UC.prototype=Object.create(Ws.prototype),UC.prototype.constructor=UC,HC.prototype=Object.create(Ws.prototype),HC.prototype.constructor=HC,VC.prototype=Object.create(Ws.prototype),VC.prototype.constructor=VC;var fn={Table:Ws,Record:Ws,Coverage:BC,ScriptList:UC,FeatureList:HC,LookupList:VC,ushortList:n_,tableList:o6,recordList:r_};function vme(e,t){return e.getUint8(t)}function zC(e,t){return e.getUint16(t,!1)}function iht(e,t){return e.getInt16(t,!1)}function g6(e,t){return e.getUint32(t,!1)}function rge(e,t){return e.getInt16(t,!1)+e.getUint16(t+2,!1)/65535}function sht(e,t){for(var i="",n=t;n<t+4;n+=1)i+=String.fromCharCode(e.getInt8(n));return i}function aht(e,t,i){for(var n=0,r=0;r<i;r+=1)n<<=8,n+=e.getUint8(t+r);return n}function oht(e,t,i){for(var n=[],r=t;r<i;r+=1)n.push(e.getUint8(r));return n}function lht(e){for(var t="",i=0;i<e.length;i+=1)t+=String.fromCharCode(e[i]);return t}var cht={byte:1,uShort:2,short:2,uLong:4,fixed:4,longDateTime:8,tag:4};function Tt(e,t){this.data=e,this.offset=t,this.relativeOffset=0}Tt.prototype.parseByte=function(){var e=this.data.getUint8(this.offset+this.relativeOffset);return this.relativeOffset+=1,e},Tt.prototype.parseChar=function(){var e=this.data.getInt8(this.offset+this.relativeOffset);return this.relativeOffset+=1,e},Tt.prototype.parseCard8=Tt.prototype.parseByte,Tt.prototype.parseUShort=function(){var e=this.data.getUint16(this.offset+this.relativeOffset);return this.relativeOffset+=2,e},Tt.prototype.parseCard16=Tt.prototype.parseUShort,Tt.prototype.parseSID=Tt.prototype.parseUShort,Tt.prototype.parseOffset16=Tt.prototype.parseUShort,Tt.prototype.parseShort=function(){var e=this.data.getInt16(this.offset+this.relativeOffset);return this.relativeOffset+=2,e},Tt.prototype.parseF2Dot14=function(){var e=this.data.getInt16(this.offset+this.relativeOffset)/16384;return this.relativeOffset+=2,e},Tt.prototype.parseULong=function(){var e=g6(this.data,this.offset+this.relativeOffset);return this.relativeOffset+=4,e},Tt.prototype.parseOffset32=Tt.prototype.parseULong,Tt.prototype.parseFixed=function(){var e=rge(this.data,this.offset+this.relativeOffset);return this.relativeOffset+=4,e},Tt.prototype.parseString=function(e){var t=this.data,i=this.offset+this.relativeOffset,n="";this.relativeOffset+=e;for(var r=0;r<e;r++)n+=String.fromCharCode(t.getUint8(i+r));return n},Tt.prototype.parseTag=function(){return this.parseString(4)},Tt.prototype.parseLongDateTime=function(){var e=g6(this.data,this.offset+this.relativeOffset+4);return e-=2082844800,this.relativeOffset+=8,e},Tt.prototype.parseVersion=function(e){var t=zC(this.data,this.offset+this.relativeOffset),i=zC(this.data,this.offset+this.relativeOffset+2);return this.relativeOffset+=4,void 0===e&&(e=4096),t+i/e/10},Tt.prototype.skip=function(e,t){void 0===t&&(t=1),this.relativeOffset+=cht[e]*t},Tt.prototype.parseULongList=function(e){void 0===e&&(e=this.parseULong());for(var t=new Array(e),i=this.data,n=this.offset+this.relativeOffset,r=0;r<e;r++)t[r]=i.getUint32(n),n+=4;return this.relativeOffset+=4*e,t},Tt.prototype.parseOffset16List=Tt.prototype.parseUShortList=function(e){void 0===e&&(e=this.parseUShort());for(var t=new Array(e),i=this.data,n=this.offset+this.relativeOffset,r=0;r<e;r++)t[r]=i.getUint16(n),n+=2;return this.relativeOffset+=2*e,t},Tt.prototype.parseShortList=function(e){for(var t=new Array(e),i=this.data,n=this.offset+this.relativeOffset,r=0;r<e;r++)t[r]=i.getInt16(n),n+=2;return this.relativeOffset+=2*e,t},Tt.prototype.parseByteList=function(e){for(var t=new Array(e),i=this.data,n=this.offset+this.relativeOffset,r=0;r<e;r++)t[r]=i.getUint8(n++);return this.relativeOffset+=e,t},Tt.prototype.parseList=function(e,t){t||(t=e,e=this.parseUShort());for(var i=new Array(e),n=0;n<e;n++)i[n]=t.call(this);return i},Tt.prototype.parseList32=function(e,t){t||(t=e,e=this.parseULong());for(var i=new Array(e),n=0;n<e;n++)i[n]=t.call(this);return i},Tt.prototype.parseRecordList=function(e,t){t||(t=e,e=this.parseUShort());for(var i=new Array(e),n=Object.keys(t),r=0;r<e;r++){for(var a={},s=0;s<n.length;s++){var o=n[s],l=t[o];a[o]=l.call(this)}i[r]=a}return i},Tt.prototype.parseRecordList32=function(e,t){t||(t=e,e=this.parseULong());for(var i=new Array(e),n=Object.keys(t),r=0;r<e;r++){for(var a={},s=0;s<n.length;s++){var o=n[s],l=t[o];a[o]=l.call(this)}i[r]=a}return i},Tt.prototype.parseStruct=function(e){if("function"==typeof e)return e.call(this);for(var t=Object.keys(e),i={},n=0;n<t.length;n++){var r=t[n],a=e[r];i[r]=a.call(this)}return i},Tt.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}},Tt.prototype.parseValueRecordList=function(){for(var e=this.parseUShort(),t=this.parseUShort(),i=new Array(t),n=0;n<t;n++)i[n]=this.parseValueRecord(e);return i},Tt.prototype.parsePointer=function(e){var t=this.parseOffset16();if(t>0)return new Tt(this.data,this.offset+t).parseStruct(e)},Tt.prototype.parsePointer32=function(e){var t=this.parseOffset32();if(t>0)return new Tt(this.data,this.offset+t).parseStruct(e)},Tt.prototype.parseListOfLists=function(e){for(var t=this.parseOffset16List(),i=t.length,n=this.relativeOffset,r=new Array(i),a=0;a<i;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=n,r},Tt.prototype.parseCoverage=function(){var e=this.offset+this.relativeOffset,t=this.parseUShort(),i=this.parseUShort();if(1===t)return{format:1,glyphs:this.parseUShortList(i)};if(2===t){for(var n=new Array(i),r=0;r<i;r++)n[r]={start:this.parseUShort(),end:this.parseUShort(),index:this.parseUShort()};return{format:2,ranges:n}}throw new Error("0x"+e.toString(16)+": Coverage format must be 1 or 2.")},Tt.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:Tt.uShort,end:Tt.uShort,classId:Tt.uShort})};throw new Error("0x"+e.toString(16)+": ClassDef format must be 1 or 2.")},Tt.list=function(e,t){return function(){return this.parseList(e,t)}},Tt.list32=function(e,t){return function(){return this.parseList32(e,t)}},Tt.recordList=function(e,t){return function(){return this.parseRecordList(e,t)}},Tt.recordList32=function(e,t){return function(){return this.parseRecordList32(e,t)}},Tt.pointer=function(e){return function(){return this.parsePointer(e)}},Tt.pointer32=function(e){return function(){return this.parsePointer32(e)}},Tt.tag=Tt.prototype.parseTag,Tt.byte=Tt.prototype.parseByte,Tt.uShort=Tt.offset16=Tt.prototype.parseUShort,Tt.uShortList=Tt.prototype.parseUShortList,Tt.uLong=Tt.offset32=Tt.prototype.parseULong,Tt.uLongList=Tt.prototype.parseULongList,Tt.struct=Tt.prototype.parseStruct,Tt.coverage=Tt.prototype.parseCoverage,Tt.classDef=Tt.prototype.parseClassDef;var yme={reserved:Tt.uShort,reqFeatureIndex:Tt.uShort,featureIndexes:Tt.uShortList};Tt.prototype.parseScriptList=function(){return this.parsePointer(Tt.recordList({tag:Tt.tag,script:Tt.pointer({defaultLangSys:Tt.pointer(yme),langSysRecords:Tt.recordList({tag:Tt.tag,langSys:Tt.pointer(yme)})})}))||[]},Tt.prototype.parseFeatureList=function(){return this.parsePointer(Tt.recordList({tag:Tt.tag,feature:Tt.pointer({featureParams:Tt.offset16,lookupListIndexes:Tt.uShortList})}))||[]},Tt.prototype.parseLookupList=function(e){return this.parsePointer(Tt.list(Tt.pointer((function(){var t=this.parseUShort();Yn.argument(1<=t&&t<=9,"GPOS/GSUB lookup type "+t+" unknown.");var i=this.parseUShort(),n=16&i;return{lookupType:t,lookupFlag:i,subtables:this.parseList(Tt.pointer(e[t])),markFilteringSet:n?this.parseUShort():void 0}}))))||[]},Tt.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:Tt.offset32,featureTableSubstitutionOffset:Tt.offset32})}))||[]};var wn={getByte:vme,getCard8:vme,getUShort:zC,getCard16:zC,getShort:iht,getULong:g6,getFixed:rge,getTag:sht,getOffset:aht,getBytes:oht,bytesToString:lht,Parser:Tt};function uht(e,t){var i;t.parseUShort(),e.length=t.parseULong(),e.language=t.parseULong(),e.groupCount=i=t.parseULong(),e.glyphIndexMap={};for(var n=0;n<i;n+=1)for(var r=t.parseULong(),a=t.parseULong(),s=t.parseULong(),o=r;o<=a;o+=1)e.glyphIndexMap[o]=s,s++}function hht(e,t,i,n,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 wn.Parser(i,n+r+14),o=new wn.Parser(i,n+r+16+2*a),l=new wn.Parser(i,n+r+16+4*a),h=new wn.Parser(i,n+r+16+6*a),c=n+r+16+8*a,u=0;u<a-1;u+=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?(c=h.offset+h.relativeOffset-2,c+=g,c+=2*(v-f),0!==(d=wn.getUShort(i,c))&&(d=d+m&65535)):d=v+m&65535,e.glyphIndexMap[v]=d}function dht(e,t){var i={};i.version=wn.getUShort(e,t),Yn.argument(0===i.version,"cmap table version should be 0."),i.numTables=wn.getUShort(e,t+2);for(var n=-1,r=i.numTables-1;r>=0;r-=1){var a=wn.getUShort(e,t+4+8*r),s=wn.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)){n=wn.getULong(e,t+4+8*r+4);break}}if(-1===n)throw new Error("No valid cmap sub-tables found.");var o=new wn.Parser(e,t+n);if(i.format=o.parseUShort(),12===i.format)uht(i,o);else{if(4!==i.format)throw new Error("Only format 4 and 12 cmap tables are supported (found format "+i.format+").");hht(i,o,e,t,n)}return i}function fht(e,t,i){e.segments.push({end:t,start:t,delta:-(t-i),offset:0,glyphIndex:i})}function pht(e){e.segments.push({end:65535,start:65535,delta:1,offset:0})}function mht(e){var t,i=!0;for(t=e.length-1;t>0;t-=1)if(e.get(t).unicode>65535){console.log("Adding CMAP format 12 (needed!)"),i=!1;break}var n=[{name:"version",type:"USHORT",value:0},{name:"numTables",type:"USHORT",value:i?1:2},{name:"platformID",type:"USHORT",value:3},{name:"encodingID",type:"USHORT",value:1},{name:"offset",type:"ULONG",value:i?12:20}];i||(n=n.concat([{name:"cmap12PlatformID",type:"USHORT",value:3},{name:"cmap12EncodingID",type:"USHORT",value:10},{name:"cmap12Offset",type:"ULONG",value:0}])),n=n.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 fn.Table("cmap",n);for(r.segments=[],t=0;t<e.length;t+=1){for(var a=e.get(t),s=0;s<a.unicodes.length;s+=1)fht(r,a.unicodes[s],t);r.segments=r.segments.sort((function(e,t){return e.start-t.start}))}pht(r);var o=r.segments.length,l=0,h=[],c=[],u=[],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}),c=c.concat({name:"start_"+t,type:"USHORT",value:m.start}),u=u.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,!i&&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(c),r.fields=r.fields.concat(u),r.fields=r.fields.concat(d),r.fields=r.fields.concat(p),r.cmap4Length=14+2*h.length+2+2*c.length+2*u.length+2*d.length+2*p.length,!i){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 ige={parse:dht,make:mht},FC=[".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"],ght=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","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"],vht=["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","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"],Qm=[".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 sge(e){this.font=e}function age(e){this.cmap=e}function GC(e,t){this.encoding=e,this.charset=t}function v6(e){switch(e.version){case 1:this.names=Qm.slice();break;case 2:this.names=new Array(e.numberOfGlyphs);for(var t=0;t<e.numberOfGlyphs;t++)e.glyphNameIndex[t]<Qm.length?this.names[t]=Qm[e.glyphNameIndex[t]]:this.names[t]=e.names[e.glyphNameIndex[t]-Qm.length];break;case 2.5:this.names=new Array(e.numberOfGlyphs);for(var i=0;i<e.numberOfGlyphs;i++)this.names[i]=Qm[i+e.glyphNameIndex[i]];break;default:this.names=[]}}function yht(e){for(var t,i=e.tables.cmap.glyphIndexMap,n=Object.keys(i),r=0;r<n.length;r+=1){var a=n[r],s=i[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 xht(e){e._IndexToUnicodeMap={};for(var t=e.tables.cmap.glyphIndexMap,i=Object.keys(t),n=0;n<i.length;n+=1){var r=i[n],a=t[r];void 0===e._IndexToUnicodeMap[a]?e._IndexToUnicodeMap[a]={unicodes:[parseInt(r)]}:e._IndexToUnicodeMap[a].unicodes.push(parseInt(r))}}function bht(e,t){t.lowMemory?xht(e):yht(e)}function Eht(e,t,i,n,r){e.beginPath(),e.moveTo(t,i),e.lineTo(n,r),e.stroke()}sge.prototype.charToGlyphIndex=function(e){var t=e.codePointAt(0),i=this.font.glyphs;if(i)for(var n=0;n<i.length;n+=1)for(var r=i.get(n),a=0;a<r.unicodes.length;a+=1)if(r.unicodes[a]===t)return n;return null},age.prototype.charToGlyphIndex=function(e){return this.cmap.glyphIndexMap[e.codePointAt(0)]||0},GC.prototype.charToGlyphIndex=function(e){var t=e.codePointAt(0),i=this.encoding[t];return this.charset.indexOf(i)},v6.prototype.nameToGlyphIndex=function(e){return this.names.indexOf(e)},v6.prototype.glyphIndexToName=function(e){return this.names[e]};var Jm={line:Eht};function _ht(e,t){var i=t||new ks;return{configurable:!0,get:function(){return"function"==typeof i&&(i=i()),i},set:function(e){i=e}}}function Bl(e){this.bindConstructorValues(e)}function OC(e,t,i){Object.defineProperty(e,t,{get:function(){return e.path,e[i]},set:function(t){e[i]=t},enumerable:!0,configurable:!0})}function y6(e,t){if(this.font=e,this.glyphs={},Array.isArray(t))for(var i=0;i<t.length;i++){var n=t[i];n.path.unitsPerEm=e.unitsPerEm,this.glyphs[i]=n}this.length=t&&t.length||0}function Tht(e,t){return new Bl({index:t,font:e})}function wht(e,t,i,n,r,a){return function(){var s=new Bl({index:t,font:e});return s.path=function(){i(s,n,r);var t=a(e.glyphs,s);return t.unitsPerEm=e.unitsPerEm,t},OC(s,"xMin","_xMin"),OC(s,"xMax","_xMax"),OC(s,"yMin","_yMin"),OC(s,"yMax","_yMax"),s}}function Sht(e,t,i,n){return function(){var r=new Bl({index:t,font:e});return r.path=function(){var t=i(e,r,n);return t.unitsPerEm=e.unitsPerEm,t},r}}Bl.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",_ht(this,e.path))},Bl.prototype.addUnicode=function(e){0===this.unicodes.length&&(this.unicode=e),this.unicodes.push(e)},Bl.prototype.getBoundingBox=function(){return this.path.getBoundingBox()},Bl.prototype.getPath=function(e,t,i,n,r){var a,s;e=void 0!==e?e:0,t=void 0!==t?t:0,i=void 0!==i?i:72,n||(n={});var o=n.xScale,l=n.yScale;if(n.hinting&&r&&r.hinting&&(s=this.path&&r.hinting.exec(this,i)),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)*i;void 0===o&&(o=h),void 0===l&&(l=h)}for(var c=new ks,u=0;u<a.length;u+=1){var d=a[u];"M"===d.type?c.moveTo(e+d.x*o,t+-d.y*l):"L"===d.type?c.lineTo(e+d.x*o,t+-d.y*l):"Q"===d.type?c.quadraticCurveTo(e+d.x1*o,t+-d.y1*l,e+d.x*o,t+-d.y*l):"C"===d.type?c.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&&c.closePath()}return c},Bl.prototype.getContours=function(){if(void 0===this.points)return[];for(var e=[],t=[],i=0;i<this.points.length;i+=1){var n=this.points[i];t.push(n),n.lastPointOfContour&&(e.push(t),t=[])}return Yn.argument(0===t.length,"There are still points left in the current contour."),e},Bl.prototype.getMetrics=function(){for(var e=this.path.commands,t=[],i=[],n=0;n<e.length;n+=1){var r=e[n];"Z"!==r.type&&(t.push(r.x),i.push(r.y)),("Q"===r.type||"C"===r.type)&&(t.push(r.x1),i.push(r.y1)),"C"===r.type&&(t.push(r.x2),i.push(r.y2))}var a={xMin:Math.min.apply(null,t),yMin:Math.min.apply(null,i),xMax:Math.max.apply(null,t),yMax:Math.max.apply(null,i),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},Bl.prototype.draw=function(e,t,i,n,r){this.getPath(t,i,n,r).draw(e)},Bl.prototype.drawPoints=function(e,t,i,n){function r(t,i,n,r){e.beginPath();for(var a=0;a<t.length;a+=1)e.moveTo(i+t[a].x*r,n+t[a].y*r),e.arc(i+t[a].x*r,n+t[a].y*r,2,0,2*Math.PI,!1);e.closePath(),e.fill()}t=void 0!==t?t:0,i=void 0!==i?i:0,n=void 0!==n?n:24;for(var a=1/this.path.unitsPerEm*n,s=[],o=[],l=this.path,h=0;h<l.commands.length;h+=1){var c=l.commands[h];void 0!==c.x&&s.push({x:c.x,y:-c.y}),void 0!==c.x1&&o.push({x:c.x1,y:-c.y1}),void 0!==c.x2&&o.push({x:c.x2,y:-c.y2})}e.fillStyle="blue",r(s,t,i,a),e.fillStyle="red",r(o,t,i,a)},Bl.prototype.drawMetrics=function(e,t,i,n){var r;t=void 0!==t?t:0,i=void 0!==i?i:0,n=void 0!==n?n:24,r=1/this.path.unitsPerEm*n,e.lineWidth=1,e.strokeStyle="black",Jm.line(e,t,-1e4,t,1e4),Jm.line(e,-1e4,i,1e4,i);var a=this.xMin||0,s=this.yMin||0,o=this.xMax||0,l=this.yMax||0,h=this.advanceWidth||0;e.strokeStyle="blue",Jm.line(e,t+a*r,-1e4,t+a*r,1e4),Jm.line(e,t+o*r,-1e4,t+o*r,1e4),Jm.line(e,-1e4,i+-s*r,1e4,i+-s*r),Jm.line(e,-1e4,i+-l*r,1e4,i+-l*r),e.strokeStyle="green",Jm.line(e,t+h*r,-1e4,t+h*r,1e4)},y6.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],i=this.font._IndexToUnicodeMap[e];if(i)for(var n=0;n<i.unicodes.length;n++)t.addUnicode(i.unicodes[n]);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]},y6.prototype.push=function(e,t){this.glyphs[e]=t,this.length++};var $u={GlyphSet:y6,glyphLoader:Tht,ttfGlyphLoader:wht,cffGlyphLoader:Sht};function oge(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(var i=0;i<e.length;i+=1)if(!oge(e[i],t[i]))return!1;return!0}return!1}function l6(e){return e.length<1240?107:e.length<33900?1131:32768}function Ff(e,t,i){var n,r,a=[],s=[],o=wn.getCard16(e,t);if(0!==o){var l=wn.getByte(e,t+2);n=t+(o+1)*l+2;for(var h=t+3,c=0;c<o+1;c+=1)a.push(wn.getOffset(e,h,l)),h+=l;r=n+a[o]}else r=t+2;for(var u=0;u<a.length-1;u+=1){var d=wn.getBytes(e,n+a[u],n+a[u+1]);i&&(d=i(d)),s.push(d)}return{objects:s,startOffset:t,endOffset:r}}function Mht(e,t){var i,n,r=[],a=wn.getCard16(e,t);if(0!==a){var s=wn.getByte(e,t+2);i=t+(a+1)*s+2;for(var o=t+3,l=0;l<a+1;l+=1)r.push(wn.getOffset(e,o,s)),o+=s;n=i+r[a]}else n=t+2;return{offsets:r,startOffset:t,endOffset:n}}function Rht(e,t,i,n,r){var a=wn.getCard16(i,n),s=0;0!==a&&(s=n+(a+1)*wn.getByte(i,n+2)+2);var o=wn.getBytes(i,s+t[e],s+t[e+1]);return r&&(o=r(o)),o}function Aht(e){for(var t="",i=["0","1","2","3","4","5","6","7","8","9",".","E","E-",null,"-"];;){var n=e.parseByte(),r=n>>4,a=15&n;if(15===r||(t+=i[r],15===a))break;t+=i[a]}return parseFloat(t)}function Cht(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 Aht(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 Pht(e){for(var t={},i=0;i<e.length;i+=1){var n,r=e[i][0],a=e[i][1];if(n=1===a.length?a[0]:a,t.hasOwnProperty(r)&&!isNaN(t[r]))throw new Error("Object "+t+" already has key "+r);t[r]=n}return t}function lge(e,t,i){t=void 0!==t?t:0;var n=new wn.Parser(e,t),r=[],a=[];for(i=void 0!==i?i:e.length;n.relativeOffset<i;){var s=n.parseByte();s<=21?(12===s&&(s=1200+n.parseByte()),r.push([s,a]),a=[]):a.push(Cht(n,s))}return Pht(r)}function e_(e,t){return t<=390?FC[t]:e[t-391]}function cge(e,t,i){for(var n,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===(n=void 0!==e[s.op]?e[s.op][l]:void 0)&&(n=void 0!==s.value&&void 0!==s.value[l]?s.value[l]:null),"SID"===s.type[l]&&(n=e_(i,n)),o[l]=n;r[s.name]=o}else void 0===(n=e[s.op])&&(n=void 0!==s.value?s.value:null),"SID"===s.type&&(n=e_(i,n)),r[s.name]=n}return r}function Iht(e,t){var i={};return i.formatMajor=wn.getCard8(e,t),i.formatMinor=wn.getCard8(e,t+1),i.size=wn.getCard8(e,t+2),i.offsetSize=wn.getCard8(e,t+3),i.startOffset=t,i.endOffset=t+4,i}var uge=[{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"}],hge=[{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 Lht(e,t){return cge(lge(e,0,e.byteLength),uge,t)}function dge(e,t,i,n){return cge(lge(e,t,i),hge,n)}function xme(e,t,i,n){for(var r=[],a=0;a<i.length;a+=1){var s=Lht(new DataView(new Uint8Array(i[a]).buffer),n);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=dge(e,l+t,o,n);if(s._defaultWidthX=h.defaultWidthX,s._nominalWidthX=h.nominalWidthX,0!==h.subrs){var c=Ff(e,l+h.subrs+t);s._subrs=c.objects,s._subrsBias=l6(s._subrs)}s._privateDict=h}r.push(s)}return r}function Dht(e,t,i,n){var r,a,s=new wn.Parser(e,t);i-=1;var o=[".notdef"],l=s.parseCard8();if(0===l)for(var h=0;h<i;h+=1)r=s.parseSID(),o.push(e_(n,r));else if(1===l)for(;o.length<=i;){r=s.parseSID(),a=s.parseCard8();for(var c=0;c<=a;c+=1)o.push(e_(n,r)),r+=1}else{if(2!==l)throw new Error("Unknown charset format "+l);for(;o.length<=i;){r=s.parseSID(),a=s.parseCard16();for(var u=0;u<=a;u+=1)o.push(e_(n,r)),r+=1}}return o}function Oht(e,t,i){var n,r={},a=new wn.Parser(e,t),s=a.parseCard8();if(0===s)for(var o=a.parseCard8(),l=0;l<o;l+=1)r[n=a.parseCard8()]=l;else{if(1!==s)throw new Error("Unknown encoding format "+s);var h=a.parseCard8();n=1;for(var c=0;c<h;c+=1)for(var u=a.parseCard8(),d=a.parseCard8(),p=u;p<=u+d;p+=1)r[p]=n,n+=1}return new GC(r,i)}function bme(e,t,i){var n,r,a,s,o,l,h,c,u=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,c=x._nominalWidthX}else o=e.tables.cff.topDict._subrs,l=e.tables.cff.topDict._subrsBias,h=e.tables.cff.topDict._defaultWidthX,c=e.tables.cff.topDict._nominalWidthX;var b=h;function _(e,t){m&&u.closePath(),u.moveTo(e,t),m=!0}function w(){d.length%2!=0&&!f&&(b=d.shift()+c),p+=d.length>>1,d.length=0,f=!0}return function i(h){for(var y,x,S,M,E,T,A,C,P,R,D,L,I=0;I<h.length;){var O=h[I];switch(I+=1,O){case 1:case 3:case 18:case 23:w();break;case 4:d.length>1&&!f&&(b=d.shift()+c,f=!0),v+=d.pop(),_(g,v);break;case 5:for(;d.length>0;)g+=d.shift(),v+=d.shift(),u.lineTo(g,v);break;case 6:for(;d.length>0&&(g+=d.shift(),u.lineTo(g,v),0!==d.length);)v+=d.shift(),u.lineTo(g,v);break;case 7:for(;d.length>0&&(v+=d.shift(),u.lineTo(g,v),0!==d.length);)g+=d.shift(),u.lineTo(g,v);break;case 8:for(;d.length>0;)n=g+d.shift(),r=v+d.shift(),a=n+d.shift(),s=r+d.shift(),g=a+d.shift(),v=s+d.shift(),u.curveTo(n,r,a,s,g,v);break;case 10:E=d.pop()+l,(T=o[E])&&i(T);break;case 11:return;case 12:switch(O=h[I],I+=1,O){case 35:n=g+d.shift(),r=v+d.shift(),a=n+d.shift(),s=r+d.shift(),A=a+d.shift(),C=s+d.shift(),P=A+d.shift(),R=C+d.shift(),D=P+d.shift(),L=R+d.shift(),g=D+d.shift(),v=L+d.shift(),d.shift(),u.curveTo(n,r,a,s,A,C),u.curveTo(P,R,D,L,g,v);break;case 34:n=g+d.shift(),r=v,a=n+d.shift(),s=r+d.shift(),A=a+d.shift(),C=s,P=A+d.shift(),R=s,D=P+d.shift(),L=v,g=D+d.shift(),u.curveTo(n,r,a,s,A,C),u.curveTo(P,R,D,L,g,v);break;case 36:n=g+d.shift(),r=v+d.shift(),a=n+d.shift(),s=r+d.shift(),A=a+d.shift(),C=s,P=A+d.shift(),R=s,D=P+d.shift(),L=R+d.shift(),g=D+d.shift(),u.curveTo(n,r,a,s,A,C),u.curveTo(P,R,D,L,g,v);break;case 37:n=g+d.shift(),r=v+d.shift(),a=n+d.shift(),s=r+d.shift(),A=a+d.shift(),C=s+d.shift(),P=A+d.shift(),R=C+d.shift(),D=P+d.shift(),L=R+d.shift(),Math.abs(D-g)>Math.abs(L-v)?g=D+d.shift():v=L+d.shift(),u.curveTo(n,r,a,s,A,C),u.curveTo(P,R,D,L,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()+c,f=!0),m&&(u.closePath(),m=!1);break;case 19:case 20:w(),I+=p+7>>3;break;case 21:d.length>2&&!f&&(b=d.shift()+c,f=!0),v+=d.pop(),_(g+=d.pop(),v);break;case 22:d.length>1&&!f&&(b=d.shift()+c,f=!0),_(g+=d.pop(),v);break;case 24:for(;d.length>2;)n=g+d.shift(),r=v+d.shift(),a=n+d.shift(),s=r+d.shift(),g=a+d.shift(),v=s+d.shift(),u.curveTo(n,r,a,s,g,v);g+=d.shift(),v+=d.shift(),u.lineTo(g,v);break;case 25:for(;d.length>6;)g+=d.shift(),v+=d.shift(),u.lineTo(g,v);n=g+d.shift(),r=v+d.shift(),a=n+d.shift(),s=r+d.shift(),g=a+d.shift(),v=s+d.shift(),u.curveTo(n,r,a,s,g,v);break;case 26:for(d.length%2&&(g+=d.shift());d.length>0;)n=g,r=v+d.shift(),a=n+d.shift(),s=r+d.shift(),g=a,v=s+d.shift(),u.curveTo(n,r,a,s,g,v);break;case 27:for(d.length%2&&(v+=d.shift());d.length>0;)n=g+d.shift(),r=v,a=n+d.shift(),s=r+d.shift(),g=a+d.shift(),v=s,u.curveTo(n,r,a,s,g,v);break;case 28:y=h[I],x=h[I+1],d.push((y<<24|x<<16)>>16),I+=2;break;case 29:E=d.pop()+e.gsubrsBias,(T=e.gsubrs[E])&&i(T);break;case 30:for(;d.length>0&&(n=g,r=v+d.shift(),a=n+d.shift(),s=r+d.shift(),g=a+d.shift(),v=s+(1===d.length?d.shift():0),u.curveTo(n,r,a,s,g,v),0!==d.length);)n=g+d.shift(),r=v,a=n+d.shift(),s=r+d.shift(),v=s+d.shift(),g=a+(1===d.length?d.shift():0),u.curveTo(n,r,a,s,g,v);break;case 31:for(;d.length>0&&(n=g+d.shift(),r=v,a=n+d.shift(),s=r+d.shift(),v=s+d.shift(),g=a+(1===d.length?d.shift():0),u.curveTo(n,r,a,s,g,v),0!==d.length);)n=g,r=v+d.shift(),a=n+d.shift(),s=r+d.shift(),g=a+d.shift(),v=s+(1===d.length?d.shift():0),u.curveTo(n,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[I],I+=1,d.push(256*(O-247)+y+108)):O<255?(y=h[I],I+=1,d.push(256*-(O-251)-y-108)):(y=h[I],x=h[I+1],S=h[I+2],M=h[I+3],I+=4,d.push((y<<24|x<<16|S<<8|M)/65536))}}}(i),t.advanceWidth=b,u}function kht(e,t,i,n){var r,a=[],s=new wn.Parser(e,t),o=s.parseCard8();if(0===o)for(var l=0;l<i;l++){if((r=s.parseCard8())>=n)throw new Error("CFF table CID Font FDSelect has bad FD index value "+r+" (FD count "+n+")");a.push(r)}else{if(3!==o)throw new Error("CFF Table CID Font FDSelect table has unsupported format "+o);var h=s.parseCard16(),c=s.parseCard16();if(0!==c)throw new Error("CFF Table CID Font FDSelect format 3 range has bad initial GID "+c);for(var u,d=0;d<h;d++){if(r=s.parseCard8(),u=s.parseCard16(),r>=n)throw new Error("CFF table CID Font FDSelect has bad FD index value "+r+" (FD count "+n+")");if(u>i)throw new Error("CFF Table CID Font FDSelect format 3 range has bad GID "+u);for(;c<u;c++)a.push(r);c=u}if(u!==i)throw new Error("CFF Table CID Font FDSelect format 3 range has bad final GID "+u)}return a}function Fht(e,t,i,n){i.tables.cff={};var r=Iht(e,t),a=Ff(e,r.endOffset,wn.bytesToString),s=Ff(e,a.endOffset),o=Ff(e,s.endOffset,wn.bytesToString),l=Ff(e,o.endOffset);i.gsubrs=l.objects,i.gsubrsBias=l6(i.gsubrs);var h=xme(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 c=h[0];if(i.tables.cff.topDict=c,c._privateDict&&(i.defaultWidthX=c._privateDict.defaultWidthX,i.nominalWidthX=c._privateDict.nominalWidthX),void 0!==c.ros[0]&&void 0!==c.ros[1]&&(i.isCIDFont=!0),i.isCIDFont){var u=c.fdArray,d=c.fdSelect;if(0===u||0===d)throw new Error("Font is marked as a CID font, but FDArray and/or FDSelect information is missing");var p=Ff(e,u+=t),f=xme(e,t,p.objects,o.objects);c._fdArray=f,d+=t,c._fdSelect=kht(e,d,i.numGlyphs,f.length)}var m,g=t+c.private[1],v=dge(e,g,c.private[0],o.objects);if(i.defaultWidthX=v.defaultWidthX,i.nominalWidthX=v.nominalWidthX,0!==v.subrs){var y=g+v.subrs,x=Ff(e,y);i.subrs=x.objects,i.subrsBias=l6(i.subrs)}else i.subrs=[],i.subrsBias=0;n.lowMemory?(m=Mht(e,t+c.charStrings),i.nGlyphs=m.offsets.length):(m=Ff(e,t+c.charStrings),i.nGlyphs=m.objects.length);var b=Dht(e,t+c.charset,i.nGlyphs,o.objects);if(0===c.encoding?i.cffEncoding=new GC(ght,b):1===c.encoding?i.cffEncoding=new GC(vht,b):i.cffEncoding=Oht(e,t+c.encoding,b),i.encoding=i.encoding||i.cffEncoding,i.glyphs=new $u.GlyphSet(i),n.lowMemory)i._push=function(n){var r=Rht(n,m.offsets,e,t+c.charStrings);i.glyphs.push(n,$u.cffGlyphLoader(i,n,bme,r))};else for(var _=0;_<i.nGlyphs;_+=1){var w=m.objects[_];i.glyphs.push(_,$u.cffGlyphLoader(i,_,bme,w))}}function fge(e,t){var i,n=FC.indexOf(e);return n>=0&&(i=n),(n=t.indexOf(e))>=0?i=n+FC.length:(i=FC.length+t.length,t.push(e)),i}function Nht(){return new fn.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 Bht(e){var t=new fn.Record("Name INDEX",[{name:"names",type:"INDEX",value:[]}]);t.names=[];for(var i=0;i<e.length;i+=1)t.names.push({name:"name_"+i,type:"NAME",value:e[i]});return t}function pge(e,t,i){for(var n={},r=0;r<e.length;r+=1){var a=e[r],s=t[a.name];void 0!==s&&!oge(s,a.value)&&("SID"===a.type&&(s=fge(s,i)),n[a.op]={name:a.name,type:a.type,value:s})}return n}function Eme(e,t){var i=new fn.Record("Top DICT",[{name:"dict",type:"DICT",value:{}}]);return i.dict=pge(uge,e,t),i}function _me(e){var t=new fn.Record("Top DICT INDEX",[{name:"topDicts",type:"INDEX",value:[]}]);return t.topDicts=[{name:"topDict_0",type:"TABLE",value:e}],t}function Uht(e){var t=new fn.Record("String INDEX",[{name:"strings",type:"INDEX",value:[]}]);t.strings=[];for(var i=0;i<e.length;i+=1)t.strings.push({name:"string_"+i,type:"STRING",value:e[i]});return t}function Hht(){return new fn.Record("Global Subr INDEX",[{name:"subrs",type:"INDEX",value:[]}])}function Vht(e,t){for(var i=new fn.Record("Charsets",[{name:"format",type:"Card8",value:0}]),n=0;n<e.length;n+=1){var r=fge(e[n],t);i.fields.push({name:"glyph_"+n,type:"SID",value:r})}return i}function zht(e){var t=[],i=e.path;t.push({name:"width",type:"NUMBER",value:e.advanceWidth});for(var n=0,r=0,a=0;a<i.commands.length;a+=1){var s=void 0,o=void 0,l=i.commands[a];if("Q"===l.type){var h=.3333333333333333,c=2/3;l={type:"C",x:l.x,y:l.y,x1:Math.round(h*n+c*l.x1),y1:Math.round(h*r+c*l.y1),x2:Math.round(h*l.x+c*l.x1),y2:Math.round(h*l.y+c*l.y1)}}if("M"===l.type)s=Math.round(l.x-n),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}),n=Math.round(l.x),r=Math.round(l.y);else if("L"===l.type)s=Math.round(l.x-n),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}),n=Math.round(l.x),r=Math.round(l.y);else if("C"===l.type){var u=Math.round(l.x1-n),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:u}),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}),n=Math.round(l.x),r=Math.round(l.y)}}return t.push({name:"endchar",type:"OP",value:14}),t}function Ght(e){for(var t=new fn.Record("CharStrings INDEX",[{name:"charStrings",type:"INDEX",value:[]}]),i=0;i<e.length;i+=1){var n=e.get(i),r=zht(n);t.charStrings.push({name:n.name,type:"CHARSTRING",value:r})}return t}function qht(e,t){var i=new fn.Record("Private DICT",[{name:"dict",type:"DICT",value:{}}]);return i.dict=pge(hge,e,t),i}function Wht(e,t){for(var i,n=new fn.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)i=e.get(o),s.push(i.name);var l=[];n.header=Nht(),n.nameIndex=Bht([t.postScriptName]);var h=Eme(a,l);n.topDictIndex=_me(h),n.globalSubrIndex=Hht(),n.charsets=Vht(s,l),n.charStringsIndex=Ght(e),n.privateDict=qht({},l),n.stringIndex=Uht(l);var c=n.header.sizeOf()+n.nameIndex.sizeOf()+n.topDictIndex.sizeOf()+n.stringIndex.sizeOf()+n.globalSubrIndex.sizeOf();return a.charset=c,a.encoding=0,a.charStrings=a.charset+n.charsets.sizeOf(),a.private[1]=a.charStrings+n.charStringsIndex.sizeOf(),h=Eme(a,l),n.topDictIndex=_me(h),n}var mge={parse:Fht,make:Wht};function jht(e,t){var i={},n=new wn.Parser(e,t);return i.version=n.parseVersion(),i.fontRevision=Math.round(1e3*n.parseFixed())/1e3,i.checkSumAdjustment=n.parseULong(),i.magicNumber=n.parseULong(),Yn.argument(1594834165===i.magicNumber,"Font header has wrong magic number."),i.flags=n.parseUShort(),i.unitsPerEm=n.parseUShort(),i.created=n.parseLongDateTime(),i.modified=n.parseLongDateTime(),i.xMin=n.parseShort(),i.yMin=n.parseShort(),i.xMax=n.parseShort(),i.yMax=n.parseShort(),i.macStyle=n.parseUShort(),i.lowestRecPPEM=n.parseUShort(),i.fontDirectionHint=n.parseShort(),i.indexToLocFormat=n.parseShort(),i.glyphDataFormat=n.parseShort(),i}function Xht(e){var t=Math.round((new Date).getTime()/1e3)+2082844800,i=t;return e.createdTimestamp&&(i=e.createdTimestamp+2082844800),new fn.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:i},{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 gge={parse:jht,make:Xht};function Yht(e,t){var i={},n=new wn.Parser(e,t);return i.version=n.parseVersion(),i.ascender=n.parseShort(),i.descender=n.parseShort(),i.lineGap=n.parseShort(),i.advanceWidthMax=n.parseUShort(),i.minLeftSideBearing=n.parseShort(),i.minRightSideBearing=n.parseShort(),i.xMaxExtent=n.parseShort(),i.caretSlopeRise=n.parseShort(),i.caretSlopeRun=n.parseShort(),i.caretOffset=n.parseShort(),n.relativeOffset+=8,i.metricDataFormat=n.parseShort(),i.numberOfHMetrics=n.parseUShort(),i}function $ht(e){return new fn.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 vge={parse:Yht,make:$ht};function Zht(e,t,i,n,r){for(var a,s,o=new wn.Parser(e,t),l=0;l<n;l+=1){l<i&&(a=o.parseUShort(),s=o.parseShort());var h=r.get(l);h.advanceWidth=a,h.leftSideBearing=s}}function Kht(e,t,i,n,r){e._hmtxTableData={};for(var a,s,o=new wn.Parser(t,i),l=0;l<r;l+=1)l<n&&(a=o.parseUShort(),s=o.parseShort()),e._hmtxTableData[l]={advanceWidth:a,leftSideBearing:s}}function Jht(e,t,i,n,r,a,s){s.lowMemory?Kht(e,t,i,n,r):Zht(t,i,n,r,a)}function Qht(e){for(var t=new fn.Table("hmtx",[]),i=0;i<e.length;i+=1){var n=e.get(i),r=n.advanceWidth||0,a=n.leftSideBearing||0;t.fields.push({name:"advanceWidth_"+i,type:"USHORT",value:r}),t.fields.push({name:"leftSideBearing_"+i,type:"SHORT",value:a})}return t}var yge={parse:Jht,make:Qht};function edt(e){for(var t=new fn.Table("ltag",[{name:"version",type:"ULONG",value:1},{name:"flags",type:"ULONG",value:0},{name:"numTags",type:"ULONG",value:e.length}]),i="",n=12+4*e.length,r=0;r<e.length;++r){var a=i.indexOf(e[r]);a<0&&(a=i.length,i+=e[r]),t.fields.push({name:"offset "+r,type:"USHORT",value:n+a}),t.fields.push({name:"length "+r,type:"USHORT",value:e[r].length})}return t.fields.push({name:"stringPool",type:"CHARARRAY",value:i}),t}function tdt(e,t){var i=new wn.Parser(e,t),n=i.parseULong();Yn.argument(1===n,"Unsupported ltag table version."),i.skip("uLong",1);for(var r=i.parseULong(),a=[],s=0;s<r;s++){for(var o="",l=t+i.parseUShort(),h=i.parseUShort(),c=l;c<l+h;++c)o+=String.fromCharCode(e.getInt8(c));a.push(o)}return a}var xge={make:edt,parse:tdt};function ndt(e,t){var i={},n=new wn.Parser(e,t);return i.version=n.parseVersion(),i.numGlyphs=n.parseUShort(),1===i.version&&(i.maxPoints=n.parseUShort(),i.maxContours=n.parseUShort(),i.maxCompositePoints=n.parseUShort(),i.maxCompositeContours=n.parseUShort(),i.maxZones=n.parseUShort(),i.maxTwilightPoints=n.parseUShort(),i.maxStorage=n.parseUShort(),i.maxFunctionDefs=n.parseUShort(),i.maxInstructionDefs=n.parseUShort(),i.maxStackElements=n.parseUShort(),i.maxSizeOfInstructions=n.parseUShort(),i.maxComponentElements=n.parseUShort(),i.maxComponentDepth=n.parseUShort()),i}function rdt(e){return new fn.Table("maxp",[{name:"version",type:"FIXED",value:20480},{name:"numGlyphs",type:"USHORT",value:e}])}var bge={parse:ndt,make:rdt},Ege=["copyright","fontFamily","fontSubfamily","uniqueID","fullName","version","postScriptName","trademark","manufacturer","designer","description","manufacturerURL","designerURL","license","licenseURL","reserved","preferredFamily","preferredSubfamily","compatibleFullName","sampleText","postScriptFindFontName","wwsFamily","wwsSubfamily"],_ge={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"},idt={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},Tge={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 sdt(e,t,i){switch(e){case 0:if(65535===t)return"und";if(i)return i[t];break;case 1:return _ge[t];case 3:return Tge[t]}}var c6="utf-16",adt={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"},odt={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 wge(e,t,i){switch(e){case 0:return c6;case 1:return odt[i]||adt[t];case 3:if(1===t||10===t)return c6}}function ldt(e,t,i){for(var n={},r=new wn.Parser(e,t),a=r.parseUShort(),s=r.parseUShort(),o=r.offset+r.parseUShort(),l=0;l<s;l++){var h=r.parseUShort(),c=r.parseUShort(),u=r.parseUShort(),d=r.parseUShort(),p=Ege[d]||d,f=r.parseUShort(),m=r.parseUShort(),g=sdt(h,u,i),v=wge(h,c,u);if(void 0!==v&&void 0!==g){var y;if(y=v===c6?_y.UTF16(e,o+m,f):_y.MACSTRING(e,o+m,f,v)){var x=n[p];void 0===x&&(x=n[p]={}),x[g]=y}}}return 1===a&&r.parseUShort(),n}function Z5(e){var t={};for(var i in e)t[e[i]]=parseInt(i);return t}function Tme(e,t,i,n,r,a){return new fn.Record("NameRecord",[{name:"platformID",type:"USHORT",value:e},{name:"encodingID",type:"USHORT",value:t},{name:"languageID",type:"USHORT",value:i},{name:"nameID",type:"USHORT",value:n},{name:"length",type:"USHORT",value:r},{name:"offset",type:"USHORT",value:a}])}function cdt(e,t){var i=e.length,n=t.length-i+1;e:for(var r=0;r<n;r++)for(;r<n;r++){for(var a=0;a<i;a++)if(t[r+a]!==e[a])continue e;return r}return-1}function wme(e,t){var i=cdt(e,t);if(i<0){i=t.length;for(var n=0,r=e.length;n<r;++n)t.push(e[n])}return i}function udt(e,t){var i,n=[],r={},a=Z5(Ege);for(var s in e){var o=a[s];if(void 0===o&&(o=s),i=parseInt(o),isNaN(i))throw new Error('Name table entry "'+s+'" does not exist, see nameTableNames for complete list.');r[i]=e[s],n.push(i)}for(var l=Z5(_ge),h=Z5(Tge),c=[],u=[],d=0;d<n.length;d++){var p=r[i=n[d]];for(var f in p){var m=p[f],g=1,v=l[f],y=idt[v],x=wge(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 _=wme(b,u);c.push(Tme(g,y,v,i,b.length,_));var w=h[f];if(void 0!==w){var S=tn.UTF16(m),M=wme(S,u);c.push(Tme(3,1,w,i,S.length,M))}}}c.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 fn.Table("name",[{name:"format",type:"USHORT",value:0},{name:"count",type:"USHORT",value:c.length},{name:"stringOffset",type:"USHORT",value:6+12*c.length}]),T=0;T<c.length;T++)E.fields.push({name:"record_"+T,type:"RECORD",value:c[T]});return E.fields.push({name:"strings",type:"LITERAL",value:u}),E}var Sge={parse:ldt,make:udt},u6=[{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 hdt(e){for(var t=0;t<u6.length;t+=1){var i=u6[t];if(e>=i.begin&&e<i.end)return t}return-1}function ddt(e,t){var i={},n=new wn.Parser(e,t);i.version=n.parseUShort(),i.xAvgCharWidth=n.parseShort(),i.usWeightClass=n.parseUShort(),i.usWidthClass=n.parseUShort(),i.fsType=n.parseUShort(),i.ySubscriptXSize=n.parseShort(),i.ySubscriptYSize=n.parseShort(),i.ySubscriptXOffset=n.parseShort(),i.ySubscriptYOffset=n.parseShort(),i.ySuperscriptXSize=n.parseShort(),i.ySuperscriptYSize=n.parseShort(),i.ySuperscriptXOffset=n.parseShort(),i.ySuperscriptYOffset=n.parseShort(),i.yStrikeoutSize=n.parseShort(),i.yStrikeoutPosition=n.parseShort(),i.sFamilyClass=n.parseShort(),i.panose=[];for(var r=0;r<10;r++)i.panose[r]=n.parseByte();return i.ulUnicodeRange1=n.parseULong(),i.ulUnicodeRange2=n.parseULong(),i.ulUnicodeRange3=n.parseULong(),i.ulUnicodeRange4=n.parseULong(),i.achVendID=String.fromCharCode(n.parseByte(),n.parseByte(),n.parseByte(),n.parseByte()),i.fsSelection=n.parseUShort(),i.usFirstCharIndex=n.parseUShort(),i.usLastCharIndex=n.parseUShort(),i.sTypoAscender=n.parseShort(),i.sTypoDescender=n.parseShort(),i.sTypoLineGap=n.parseShort(),i.usWinAscent=n.parseUShort(),i.usWinDescent=n.parseUShort(),i.version>=1&&(i.ulCodePageRange1=n.parseULong(),i.ulCodePageRange2=n.parseULong()),i.version>=2&&(i.sxHeight=n.parseShort(),i.sCapHeight=n.parseShort(),i.usDefaultChar=n.parseUShort(),i.usBreakChar=n.parseUShort(),i.usMaxContent=n.parseUShort()),i}function fdt(e){return new fn.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 h6={parse:ddt,make:fdt,unicodeRanges:u6,getUnicodeRange:hdt};function pdt(e,t){var i={},n=new wn.Parser(e,t);switch(i.version=n.parseVersion(),i.italicAngle=n.parseFixed(),i.underlinePosition=n.parseShort(),i.underlineThickness=n.parseShort(),i.isFixedPitch=n.parseULong(),i.minMemType42=n.parseULong(),i.maxMemType42=n.parseULong(),i.minMemType1=n.parseULong(),i.maxMemType1=n.parseULong(),i.version){case 1:i.names=Qm.slice();break;case 2:i.numberOfGlyphs=n.parseUShort(),i.glyphNameIndex=new Array(i.numberOfGlyphs);for(var r=0;r<i.numberOfGlyphs;r++)i.glyphNameIndex[r]=n.parseUShort();i.names=[];for(var a=0;a<i.numberOfGlyphs;a++)if(i.glyphNameIndex[a]>=Qm.length){var s=n.parseChar();i.names.push(n.parseString(s))}break;case 2.5:i.numberOfGlyphs=n.parseUShort(),i.offset=new Array(i.numberOfGlyphs);for(var o=0;o<i.numberOfGlyphs;o++)i.offset[o]=n.parseChar()}return i}function mdt(){return new fn.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 Mge={parse:pdt,make:mdt},Lc=new Array(9);Lc[1]=function(){var e=this.offset+this.relativeOffset,t=this.parseUShort();return 1===t?{substFormat:1,coverage:this.parsePointer(Tt.coverage),deltaGlyphId:this.parseUShort()}:2===t?{substFormat:2,coverage:this.parsePointer(Tt.coverage),substitute:this.parseOffset16List()}:void Yn.assert(!1,"0x"+e.toString(16)+": lookup type 1 format must be 1 or 2.")},Lc[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(Tt.coverage),sequences:this.parseListOfLists()}},Lc[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(Tt.coverage),alternateSets:this.parseListOfLists()}},Lc[4]=function(){var e=this.parseUShort();return Yn.argument(1===e,"GSUB ligature table identifier-format must be 1"),{substFormat:e,coverage:this.parsePointer(Tt.coverage),ligatureSets:this.parseListOfLists((function(){return{ligGlyph:this.parseUShort(),components:this.parseUShortList(this.parseUShort()-1)}}))}};var Ey={sequenceIndex:Tt.uShort,lookupListIndex:Tt.uShort};function gdt(e,t){var i=new Tt(e,t=t||0),n=i.parseVersion(1);return Yn.argument(1===n||1.1===n,"Unsupported GSUB table version."),1===n?{version:n,scripts:i.parseScriptList(),features:i.parseFeatureList(),lookups:i.parseLookupList(Lc)}:{version:n,scripts:i.parseScriptList(),features:i.parseFeatureList(),lookups:i.parseLookupList(Lc),variations:i.parseFeatureVariationsList()}}Lc[5]=function(){var e=this.offset+this.relativeOffset,t=this.parseUShort();if(1===t)return{substFormat:t,coverage:this.parsePointer(Tt.coverage),ruleSets:this.parseListOfLists((function(){var e=this.parseUShort(),t=this.parseUShort();return{input:this.parseUShortList(e-1),lookupRecords:this.parseRecordList(t,Ey)}}))};if(2===t)return{substFormat:t,coverage:this.parsePointer(Tt.coverage),classDef:this.parsePointer(Tt.classDef),classSets:this.parseListOfLists((function(){var e=this.parseUShort(),t=this.parseUShort();return{classes:this.parseUShortList(e-1),lookupRecords:this.parseRecordList(t,Ey)}}))};if(3===t){var i=this.parseUShort(),n=this.parseUShort();return{substFormat:t,coverages:this.parseList(i,Tt.pointer(Tt.coverage)),lookupRecords:this.parseRecordList(n,Ey)}}Yn.assert(!1,"0x"+e.toString(16)+": lookup type 5 format must be 1, 2 or 3.")},Lc[6]=function(){var e=this.offset+this.relativeOffset,t=this.parseUShort();return 1===t?{substFormat:1,coverage:this.parsePointer(Tt.coverage),chainRuleSets:this.parseListOfLists((function(){return{backtrack:this.parseUShortList(),input:this.parseUShortList(this.parseShort()-1),lookahead:this.parseUShortList(),lookupRecords:this.parseRecordList(Ey)}}))}:2===t?{substFormat:2,coverage:this.parsePointer(Tt.coverage),backtrackClassDef:this.parsePointer(Tt.classDef),inputClassDef:this.parsePointer(Tt.classDef),lookaheadClassDef:this.parsePointer(Tt.classDef),chainClassSet:this.parseListOfLists((function(){return{backtrack:this.parseUShortList(),input:this.parseUShortList(this.parseShort()-1),lookahead:this.parseUShortList(),lookupRecords:this.parseRecordList(Ey)}}))}:3===t?{substFormat:3,backtrackCoverage:this.parseList(Tt.pointer(Tt.coverage)),inputCoverage:this.parseList(Tt.pointer(Tt.coverage)),lookaheadCoverage:this.parseList(Tt.pointer(Tt.coverage)),lookupRecords:this.parseRecordList(Ey)}:void Yn.assert(!1,"0x"+e.toString(16)+": lookup type 6 format must be 1, 2 or 3.")},Lc[7]=function(){var e=this.parseUShort();Yn.argument(1===e,"GSUB Extension Substitution subtable identifier-format must be 1");var t=this.parseUShort(),i=new Tt(this.data,this.offset+this.parseULong());return{substFormat:1,lookupType:t,extension:Lc[t].call(i)}},Lc[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(Tt.coverage),backtrackCoverage:this.parseList(Tt.pointer(Tt.coverage)),lookaheadCoverage:this.parseList(Tt.pointer(Tt.coverage)),substitutes:this.parseUShortList()}};var Ty=new Array(9);function vdt(e){return new fn.Table("GSUB",[{name:"version",type:"ULONG",value:65536},{name:"scripts",type:"TABLE",value:new fn.ScriptList(e.scripts)},{name:"features",type:"TABLE",value:new fn.FeatureList(e.features)},{name:"lookups",type:"TABLE",value:new fn.LookupList(e.lookups,Ty)}])}Ty[1]=function(e){return 1===e.substFormat?new fn.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new fn.Coverage(e.coverage)},{name:"deltaGlyphID",type:"USHORT",value:e.deltaGlyphId}]):new fn.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:2},{name:"coverage",type:"TABLE",value:new fn.Coverage(e.coverage)}].concat(fn.ushortList("substitute",e.substitute)))},Ty[2]=function(e){return Yn.assert(1===e.substFormat,"Lookup type 2 substFormat must be 1."),new fn.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new fn.Coverage(e.coverage)}].concat(fn.tableList("seqSet",e.sequences,(function(e){return new fn.Table("sequenceSetTable",fn.ushortList("sequence",e))}))))},Ty[3]=function(e){return Yn.assert(1===e.substFormat,"Lookup type 3 substFormat must be 1."),new fn.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new fn.Coverage(e.coverage)}].concat(fn.tableList("altSet",e.alternateSets,(function(e){return new fn.Table("alternateSetTable",fn.ushortList("alternate",e))}))))},Ty[4]=function(e){return Yn.assert(1===e.substFormat,"Lookup type 4 substFormat must be 1."),new fn.Table("substitutionTable",[{name:"substFormat",type:"USHORT",value:1},{name:"coverage",type:"TABLE",value:new fn.Coverage(e.coverage)}].concat(fn.tableList("ligSet",e.ligatureSets,(function(e){return new fn.Table("ligatureSetTable",fn.tableList("ligature",e,(function(e){return new fn.Table("ligatureTable",[{name:"ligGlyph",type:"USHORT",value:e.ligGlyph}].concat(fn.ushortList("component",e.components,e.components.length+1)))})))}))))},Ty[6]=function(e){if(1===e.substFormat)return new fn.Table("chainContextTable",[{name:"substFormat",type:"USHORT",value:e.substFormat},{name:"coverage",type:"TABLE",value:new fn.Coverage(e.coverage)}].concat(fn.tableList("chainRuleSet",e.chainRuleSets,(function(e){return new fn.Table("chainRuleSetTable",fn.tableList("chainRule",e,(function(e){var t=fn.ushortList("backtrackGlyph",e.backtrack,e.backtrack.length).concat(fn.ushortList("inputGlyph",e.input,e.input.length+1)).concat(fn.ushortList("lookaheadGlyph",e.lookahead,e.lookahead.length)).concat(fn.ushortList("substitution",[],e.lookupRecords.length));return e.lookupRecords.forEach((function(e,i){t=t.concat({name:"sequenceIndex"+i,type:"USHORT",value:e.sequenceIndex}).concat({name:"lookupListIndex"+i,type:"USHORT",value:e.lookupListIndex})})),new fn.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,i){t.push({name:"backtrackCoverage"+i,type:"TABLE",value:new fn.Coverage(e)})})),t.push({name:"inputGlyphCount",type:"USHORT",value:e.inputCoverage.length}),e.inputCoverage.forEach((function(e,i){t.push({name:"inputCoverage"+i,type:"TABLE",value:new fn.Coverage(e)})})),t.push({name:"lookaheadGlyphCount",type:"USHORT",value:e.lookaheadCoverage.length}),e.lookaheadCoverage.forEach((function(e,i){t.push({name:"lookaheadCoverage"+i,type:"TABLE",value:new fn.Coverage(e)})})),t.push({name:"substitutionCount",type:"USHORT",value:e.lookupRecords.length}),e.lookupRecords.forEach((function(e,i){t=t.concat({name:"sequenceIndex"+i,type:"USHORT",value:e.sequenceIndex}).concat({name:"lookupListIndex"+i,type:"USHORT",value:e.lookupListIndex})})),new fn.Table("chainContextTable",t)}Yn.assert(!1,"lookup type 6 format must be 1, 2 or 3.")};var Rge={parse:gdt,make:vdt};function ydt(e,t){var i=new wn.Parser(e,t),n=i.parseULong();Yn.argument(1===n,"Unsupported META table version."),i.parseULong(),i.parseULong();for(var r=i.parseULong(),a={},s=0;s<r;s++){var o=i.parseTag(),l=i.parseULong(),h=i.parseULong(),c=_y.UTF8(e,t+l,h);a[o]=c}return a}function xdt(e){var t=Object.keys(e).length,i="",n=16+12*t,r=new fn.Table("meta",[{name:"version",type:"ULONG",value:1},{name:"flags",type:"ULONG",value:0},{name:"offset",type:"ULONG",value:n},{name:"numTags",type:"ULONG",value:t}]);for(var a in e){var s=i.length;i+=e[a],r.fields.push({name:"tag "+a,type:"TAG",value:a}),r.fields.push({name:"offset "+a,type:"ULONG",value:n+s}),r.fields.push({name:"length "+a,type:"ULONG",value:e[a].length})}return r.fields.push({name:"stringPool",type:"CHARARRAY",value:i}),r}var Age={parse:ydt,make:xdt};function Sme(e){return Math.log(e)/Math.log(2)|0}function x6(e){for(;e.length%4!=0;)e.push(0);for(var t=0,i=0;i<e.length;i+=4)t+=(e[i]<<24)+(e[i+1]<<16)+(e[i+2]<<8)+e[i+3];return t%Math.pow(2,32)}function Mme(e,t,i,n){return new fn.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!==i?i:0},{name:"length",type:"ULONG",value:void 0!==n?n:0}])}function Cge(e){var t=new fn.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 i=Math.pow(2,Sme(t.numTables));t.searchRange=16*i,t.entrySelector=Sme(i),t.rangeShift=16*t.numTables-t.searchRange;for(var n=[],r=[],a=t.sizeOf()+Mme().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=Mme(o.tableName,x6(o.encode()),a,l);for(n.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 n.sort((function(e,t){return e.value.tag>t.value.tag?1:-1})),t.fields=t.fields.concat(n),t.fields=t.fields.concat(r),t}function Rme(e,t,i){for(var n=0;n<t.length;n+=1){var r=e.charToGlyphIndex(t[n]);if(r>0)return e.glyphs.get(r).getMetrics()}return i}function bdt(e){for(var t=0,i=0;i<e.length;i+=1)t+=e[i];return t/e.length}function Edt(e){for(var t,i=[],n=[],r=[],a=[],s=[],o=[],l=[],h=0,c=0,u=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=h6.getUnicodeRange(g);if(v<32)c|=1<<v;else if(v<64)u|=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();i.push(y.xMin),n.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,i),yMin:Math.min.apply(null,n),xMax:Math.max.apply(null,r),yMax:Math.max.apply(null,a),advanceWidthMax:Math.max.apply(null,s),advanceWidthAvg:bdt(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=gge.make({flags:3,unitsPerEm:e.unitsPerEm,xMin:x.xMin,yMin:x.yMin,xMax:x.xMax,yMax:x.yMax,lowestRecPPEM:3,createdTimestamp:e.createdTimestamp}),_=vge.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=bge.make(e.glyphs.length),S=h6.make(Object.assign({xAvgCharWidth:Math.round(x.advanceWidthAvg),usFirstCharIndex:t,usLastCharIndex:h,ulUnicodeRange1:c,ulUnicodeRange2:u,ulUnicodeRange3:d,ulUnicodeRange4:p,sTypoAscender:x.ascender,sTypoDescender:x.descender,sTypoLineGap:0,usWinAscent:x.yMax,usWinDescent:Math.abs(x.yMin),ulCodePageRange1:1,sxHeight:Rme(e,"xyvw",{yMax:Math.round(x.ascender/2)}).yMax,sCapHeight:Rme(e,"HIKLEFJMNTZBDPRAGOQSUVWXY",x).yMax,usDefaultChar:e.hasChar(" ")?32:0,usBreakChar:e.hasChar(" ")?32:0},e.tables.os2)),M=yge.make(e.glyphs),E=ige.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 D in e.names)R[D]=e.names[D];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 L=[],I=Sge.make(R,L),O=L.length>0?xge.make(L):void 0,k=Mge.make(),N=mge.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?Age.make(e.metas):void 0,F=[b,_,w,S,I,E,k,N,M];O&&F.push(O),e.tables.gsub&&F.push(Rge.make(e.tables.gsub)),U&&F.push(U);for(var B=Cge(F),z=x6(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 _dt={make:Cge,fontToTable:Edt,computeCheckSum:x6};function K5(e,t){for(var i=0,n=e.length-1;i<=n;){var r=i+n>>>1,a=e[r].tag;if(a===t)return r;a<t?i=r+1:n=r-1}return-i-1}function Ame(e,t){for(var i=0,n=e.length-1;i<=n;){var r=i+n>>>1,a=e[r];if(a===t)return r;a<t?i=r+1:n=r-1}return-i-1}function Cme(e,t){for(var i,n=0,r=e.length-1;n<=r;){var a=n+r>>>1,s=(i=e[a]).start;if(s===t)return i;s<t?n=a+1:r=a-1}if(n>0)return t>(i=e[n-1]).end?0:i}function s_(e,t){this.font=e,this.tableName=t}function a_(e){s_.call(this,e,"gpos")}function el(e){s_.call(this,e,"gsub")}function Tdt(e,t){var i=e.length;if(i!==t.length)return!1;for(var n=0;n<i;n++)if(e[n]!==t[n])return!1;return!0}function b6(e,t,i){for(var n=e.subtables,r=0;r<n.length;r++){var a=n[r];if(a.substFormat===t)return a}if(i)return n.push(i),i}function wdt(){return"undefined"!=typeof window}function Sdt(e){for(var t=new Buffer(e.byteLength),i=new Uint8Array(e),n=0;n<t.length;++n)t[n]=i[n];return t}function QE(e,t){if(!e)throw t}function Pme(e,t,i,n,r){var a;return(t&n)>0?(a=e.parseByte(),t&r||(a=-a),a=i+a):a=(t&r)>0?i:i+e.parseShort(),a}function Pge(e,t,i){var n,r,a=new wn.Parser(t,i);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;n=[];for(var c=0;c<h;c+=1)if(r=a.parseByte(),n.push(r),(8&r)>0)for(var u=a.parseByte(),d=0;d<u;d+=1)n.push(r),c+=1;if(Yn.argument(n.length===h,"Bad flags."),s.length>0){var p,f=[];if(h>0){for(var m=0;m<h;m+=1)r=n[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=n[v],(p=f[v]).x=Pme(a,r,g,2,16),g=p.x;for(var y=0,x=0;x<h;x+=1)r=n[x],(p=f[x]).y=Pme(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;){n=a.parseUShort();var _={glyphIndex:a.parseUShort(),xScale:1,scale01:0,scale10:0,yScale:1,dx:0,dy:0};(1&n)>0?(2&n)>0?(_.dx=a.parseShort(),_.dy=a.parseShort()):_.matchedPoints=[a.parseUShort(),a.parseUShort()]:(2&n)>0?(_.dx=a.parseChar(),_.dy=a.parseChar()):_.matchedPoints=[a.parseByte(),a.parseByte()],(8&n)>0?_.xScale=_.yScale=a.parseF2Dot14():(64&n)>0?(_.xScale=a.parseF2Dot14(),_.yScale=a.parseF2Dot14()):(128&n)>0&&(_.xScale=a.parseF2Dot14(),_.scale01=a.parseF2Dot14(),_.scale10=a.parseF2Dot14(),_.yScale=a.parseF2Dot14()),e.components.push(_),b=!!(32&n)}if(256&n){e.instructionLength=a.parseUShort(),e.instructions=[];for(var w=0;w<e.instructionLength;w+=1)e.instructions.push(a.parseByte())}}}function J5(e,t){for(var i=[],n=0;n<e.length;n+=1){var r=e[n],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};i.push(a)}return i}function Mdt(e){for(var t=[],i=[],n=0;n<e.length;n+=1){var r=e[n];i.push(r),r.lastPointOfContour&&(t.push(i),i=[])}return Yn.argument(0===i.length,"There are still points left in the current contour."),t}function Ige(e){var t=new ks;if(!e)return t;for(var i=Mdt(e),n=0;n<i.length;++n){var r=i[n],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 c=o;a.onCurve||(s.x,a.x,s.y,a.y),o.onCurve||(c={x:.5*(s.x+o.x),y:.5*(s.y+o.y)}),t.quadraticCurveTo(s.x,s.y,c.x,c.y)}t.closePath()}return t}function Lge(e,t){if(t.isComposite)for(var i=0;i<t.components.length;i+=1){var n=t.components[i],r=e.get(n.glyphIndex);if(r.getPath(),r.points){var a=void 0;if(void 0===n.matchedPoints)a=J5(r.points,n);else{if(n.matchedPoints[0]>t.points.length-1||n.matchedPoints[1]>r.points.length-1)throw Error("Matched points out of range in "+t.name);var s=t.points[n.matchedPoints[0]],o=r.points[n.matchedPoints[1]],l={xScale:n.xScale,scale01:n.scale01,scale10:n.scale10,yScale:n.yScale,dx:0,dy:0};o=J5([o],l)[0],l.dx=s.x-o.x,l.dy=s.y-o.y,a=J5(r.points,l)}t.points=t.points.concat(a)}}return Ige(t.points)}function Rdt(e,t,i,n){for(var r=new $u.GlyphSet(n),a=0;a<i.length-1;a+=1){var s=i[a];s!==i[a+1]?r.push(a,$u.ttfGlyphLoader(n,a,Pge,e,t+s,Lge)):r.push(a,$u.glyphLoader(n,a))}return r}function Adt(e,t,i,n){var r=new $u.GlyphSet(n);return n._push=function(a){var s=i[a];s!==i[a+1]?r.push(a,$u.ttfGlyphLoader(n,a,Pge,e,t+s,Lge)):r.push(a,$u.glyphLoader(n,a))},r}function Cdt(e,t,i,n,r){return r.lowMemory?Adt(e,t,i,n):Rdt(e,t,i,n)}s_.prototype={searchTag:K5,binSearch:Ame,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,i=0;i<e.scripts.length;i++){var n=e.scripts[i].tag;if("DFLT"===n)return n;"latn"===n&&(t=!0)}if(t)return"latn"}},getScriptTable:function(e,t){var i=this.getTable(t);if(i){e=e||"DFLT";var n=i.scripts,r=K5(i.scripts,e);if(r>=0)return n[r].script;if(t){var a={tag:e,script:{defaultLangSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]},langSysRecords:[]}};return n.splice(-1-r,0,a),a.script}}},getLangSysTable:function(e,t,i){var n=this.getScriptTable(e,i);if(n){if(!t||"dflt"===t||"DFLT"===t)return n.defaultLangSys;var r=K5(n.langSysRecords,t);if(r>=0)return n.langSysRecords[r].langSys;if(i){var a={tag:t,langSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]}};return n.langSysRecords.splice(-1-r,0,a),a.langSys}}},getFeatureTable:function(e,t,i,n){var r=this.getLangSysTable(e,t,n);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===i)return a.feature;if(n){var h=o.length;return Yn.assert(0===h||i>=o[h-1].tag,"Features must be added in alphabetical order."),a={tag:i,feature:{params:0,lookupListIndexes:[]}},o.push(a),s.push(h),a.feature}}},getLookupTables:function(e,t,i,n,r){var a=this.getFeatureTable(e,t,i,r),s=[];if(a){for(var o,l=a.lookupListIndexes,h=this.font.tables[this.tableName].lookups,c=0;c<l.length;c++)(o=h[l[c]]).lookupType===n&&s.push(o);if(0===s.length&&r){o={lookupType:n,lookupFlag:0,subtables:[],markFilteringSet:void 0};var u=h.length;return h.push(o),l.push(u),[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 i=Cme(e.ranges,t);return i?i.classId:0}},getCoverageIndex:function(e,t){switch(e.format){case 1:var i=Ame(e.glyphs,t);return i>=0?i:-1;case 2:var n=Cme(e.ranges,t);return n?n.index+t-n.start:-1}},expandCoverage:function(e){if(1===e.format)return e.glyphs;for(var t=[],i=e.ranges,n=0;n<i.length;n++)for(var r=i[n],a=r.start,s=r.end,o=a;o<=s;o++)t.push(o);return t}},a_.prototype=s_.prototype,a_.prototype.init=function(){var e=this.getDefaultScriptName();this.defaultKerningTables=this.getKerningTables(e)},a_.prototype.getKerningValue=function(e,t,i){for(var n=0;n<e.length;n++)for(var r=e[n].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 c=l[h];if(c.secondGlyph===i)return c.value1&&c.value1.xAdvance||0}break;case 2:var u=this.getGlyphClass(s.classDef1,t),d=this.getGlyphClass(s.classDef2,i),p=s.classRecords[u][d];return p.value1&&p.value1.xAdvance||0}}return 0},a_.prototype.getKerningTables=function(e,t){if(this.font.tables.gpos)return this.getLookupTables(e,t,"kern",2)},el.prototype=s_.prototype,el.prototype.createDefaultTable=function(){return{version:1,scripts:[{tag:"DFLT",script:{defaultLangSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]},langSysRecords:[]}}],features:[],lookups:[]}},el.prototype.getSingle=function(e,t,i){for(var n=[],r=this.getLookupTables(t,i,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),c=void 0;if(1===l.substFormat){var u=l.deltaGlyphId;for(c=0;c<h.length;c++){var d=h[c];n.push({sub:d,by:d+u})}}else{var p=l.substitute;for(c=0;c<h.length;c++)n.push({sub:h[c],by:p[c]})}}return n},el.prototype.getMultiple=function(e,t,i){for(var n=[],r=this.getLookupTables(t,i,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),c=void 0;for(c=0;c<h.length;c++){var u=h[c],d=l.sequences[c];n.push({sub:u,by:d})}}return n},el.prototype.getAlternates=function(e,t,i){for(var n=[],r=this.getLookupTables(t,i,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),c=l.alternateSets,u=0;u<h.length;u++)n.push({sub:h[u],by:c[u]});return n},el.prototype.getLigatures=function(e,t,i){for(var n=[],r=this.getLookupTables(t,i,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),c=l.ligatureSets,u=0;u<h.length;u++)for(var d=h[u],p=c[u],f=0;f<p.length;f++){var m=p[f];n.push({sub:[d].concat(m.components),by:m.ligGlyph})}return n},el.prototype.addSingle=function(e,t,i,n){var r=b6(this.getLookupTables(i,n,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},el.prototype.addMultiple=function(e,t,i,n){Yn.assert(t.by instanceof Array&&t.by.length>1,'Multiple: "by" must be an array of two or more ids');var r=b6(this.getLookupTables(i,n,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},el.prototype.addAlternate=function(e,t,i,n){var r=b6(this.getLookupTables(i,n,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},el.prototype.addLigature=function(e,t,i,n){var r=this.getLookupTables(i,n,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 c=a.ligatureSets[h],u=0;u<c.length;u++)if(Tdt(c[u].components,o))return;c.push(l)}else h=-1-h,a.coverage.glyphs.splice(h,0,s),a.ligatureSets.splice(h,0,[l])},el.prototype.getFeature=function(e,t,i){if(/ss\d\d/.test(e))return this.getSingle(e,t,i);switch(e){case"aalt":case"salt":return this.getSingle(e,t,i).concat(this.getAlternates(e,t,i));case"dlig":case"liga":case"rlig":return this.getLigatures(e,t,i);case"ccmp":return this.getMultiple(e,t,i).concat(this.getLigatures(e,t,i));case"stch":return this.getMultiple(e,t,i)}},el.prototype.add=function(e,t,i,n){if(/ss\d\d/.test(e))return this.addSingle(e,t,i,n);switch(e){case"aalt":case"salt":return"number"==typeof t.by?this.addSingle(e,t,i,n):this.addAlternate(e,t,i,n);case"dlig":case"liga":case"rlig":return this.addLigature(e,t,i,n);case"ccmp":return t.by instanceof Array?this.addMultiple(e,t,i,n):this.addLigature(e,t,i,n)}};var Dge={getPath:Ige,parse:Cdt},Oge,tg,kge,d6;function Fge(e){this.font=e,this.getCommands=function(e){return Dge.getPath(e).commands},this._fpgmState=this._prepState=void 0,this._errorState=0}function Pdt(e){return e}function Nge(e){return Math.sign(e)*Math.round(Math.abs(e))}function Idt(e){return Math.sign(e)*Math.round(Math.abs(2*e))/2}function Ldt(e){return Math.sign(e)*(Math.round(Math.abs(e)+.5)-.5)}function Ddt(e){return Math.sign(e)*Math.ceil(Math.abs(e))}function Odt(e){return Math.sign(e)*Math.floor(Math.abs(e))}var Bge=function(e){var t=this.srPeriod,i=this.srPhase,n=1;return e<0&&(e=-e,n=-1),e+=this.srThreshold-i,e=Math.trunc(e/t)*t,(e+=i)<0?i*n:e*n},Yu={x:1,y:0,axis:"x",distance:function(e,t,i,n){return(i?e.xo:e.x)-(n?t.xo:t.x)},interpolate:function(e,t,i,n){var r,a,s,o,l,h,c;if(!n||n===this)return r=e.xo-t.xo,a=e.xo-i.xo,l=t.x-t.xo,h=i.x-i.xo,0===(c=(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)/c);r=n.distance(e,t,!0,!0),a=n.distance(e,i,!0,!0),l=n.distance(t,t,!1,!0),h=n.distance(i,i,!1,!0),0!==(c=(s=Math.abs(r))+(o=Math.abs(a)))?Yu.setRelative(e,e,(l*o+h*s)/c,n,!0):Yu.setRelative(e,e,(l+h)/2,n,!0)},normalSlope:Number.NEGATIVE_INFINITY,setRelative:function(e,t,i,n,r){if(n&&n!==this){var a=r?t.xo:t.x,s=r?t.yo:t.y,o=a+i*n.x,l=s+i*n.y;e.x=o+(e.y-l)/n.normalSlope}else e.x=(r?t.xo:t.x)+i},slope:0,touch:function(e){e.xTouched=!0},touched:function(e){return e.xTouched},untouch:function(e){e.xTouched=!1}},ad={x:0,y:1,axis:"y",distance:function(e,t,i,n){return(i?e.yo:e.y)-(n?t.yo:t.y)},interpolate:function(e,t,i,n){var r,a,s,o,l,h,c;if(!n||n===this)return r=e.yo-t.yo,a=e.yo-i.yo,l=t.y-t.yo,h=i.y-i.yo,0===(c=(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)/c);r=n.distance(e,t,!0,!0),a=n.distance(e,i,!0,!0),l=n.distance(t,t,!1,!0),h=n.distance(i,i,!1,!0),0!==(c=(s=Math.abs(r))+(o=Math.abs(a)))?ad.setRelative(e,e,(l*o+h*s)/c,n,!0):ad.setRelative(e,e,(l+h)/2,n,!0)},normalSlope:0,setRelative:function(e,t,i,n,r){if(n&&n!==this){var a=r?t.xo:t.x,s=r?t.yo:t.y,o=a+i*n.x,l=s+i*n.y;e.y=l+n.normalSlope*(e.x-o)}else e.y=(r?t.yo:t.y)+i},slope:Number.POSITIVE_INFINITY,touch:function(e){e.yTouched=!0},touched:function(e){return e.yTouched},untouch:function(e){e.yTouched=!1}};function o_(e,t){this.x=e,this.y=t,this.axis=void 0,this.slope=t/e,this.normalSlope=-e/t,Object.freeze(this)}function l_(e,t){var i=Math.sqrt(e*e+t*t);return t/=i,1===(e/=i)&&0===t?Yu:0===e&&1===t?ad:new o_(e,t)}function od(e,t,i,n){this.x=this.xo=Math.round(64*e)/64,this.y=this.yo=Math.round(64*t)/64,this.lastPointOfContour=i,this.onCurve=n,this.prevPointOnContour=void 0,this.nextPointOnContour=void 0,this.xTouched=!1,this.yTouched=!1,Object.preventExtensions(this)}Object.freeze(Yu),Object.freeze(ad),o_.prototype.distance=function(e,t,i,n){return this.x*Yu.distance(e,t,i,n)+this.y*ad.distance(e,t,i,n)},o_.prototype.interpolate=function(e,t,i,n){var r,a,s,o,l,h,c;s=n.distance(e,t,!0,!0),o=n.distance(e,i,!0,!0),r=n.distance(t,t,!1,!0),a=n.distance(i,i,!1,!0),0!==(c=(l=Math.abs(s))+(h=Math.abs(o)))?this.setRelative(e,e,(r*h+a*l)/c,n,!0):this.setRelative(e,e,(r+a)/2,n,!0)},o_.prototype.setRelative=function(e,t,i,n,r){n=n||this;var a=r?t.xo:t.x,s=r?t.yo:t.y,o=a+i*n.x,l=s+i*n.y,h=n.normalSlope,c=this.slope,u=e.x,d=e.y;e.x=(c*u-h*o+l-d)/(c-h),e.y=c*(e.x-u)+d},o_.prototype.touch=function(e){e.xTouched=!0,e.yTouched=!0},od.prototype.nextTouched=function(e){for(var t=this.nextPointOnContour;!e.touched(t)&&t!==this;)t=t.nextPointOnContour;return t},od.prototype.prevTouched=function(e){for(var t=this.prevPointOnContour;!e.touched(t)&&t!==this;)t=t.prevPointOnContour;return t};var i_=Object.freeze(new od(0,0)),kdt={cvCutIn:17/16,deltaBase:9,deltaShift:.125,loop:1,minDis:1,autoFlip:!0};function Nf(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=Yu,this.round=Nge}}function qC(e){for(var t=e.tZone=new Array(e.gZone.length),i=0;i<t.length;i++)t[i]=new od(0,0)}function Uge(e,t){var i,n=e.prog,r=e.ip,a=1;do{if(88===(i=n[++r]))a++;else if(89===i)a--;else if(64===i)r+=n[r+1]+1;else if(65===i)r+=2*n[r+1]+1;else if(i>=176&&i<=183)r+=i-176+1;else if(i>=184&&i<=191)r+=2*(i-184+1);else if(t&&1===a&&27===i)break}while(a>0);e.ip=r}function Ime(e,t){exports.DEBUG&&console.log(t.step,"SVTCA["+e.axis+"]"),t.fv=t.pv=t.dpv=e}function Lme(e,t){exports.DEBUG&&console.log(t.step,"SPVTCA["+e.axis+"]"),t.pv=t.dpv=e}function Dme(e,t){exports.DEBUG&&console.log(t.step,"SFVTCA["+e.axis+"]"),t.fv=e}function Ome(e,t){var i,n,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?(i=o.y-l.y,n=l.x-o.x):(i=l.x-o.x,n=l.y-o.y),t.pv=t.dpv=l_(i,n)}function kme(e,t){var i,n,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?(i=o.y-l.y,n=l.x-o.x):(i=l.x-o.x,n=l.y-o.y),t.fv=l_(i,n)}function Fdt(e){var t=e.stack,i=t.pop(),n=t.pop();exports.DEBUG&&console.log(e.step,"SPVFS[]",i,n),e.pv=e.dpv=l_(n,i)}function Ndt(e){var t=e.stack,i=t.pop(),n=t.pop();exports.DEBUG&&console.log(e.step,"SPVFS[]",i,n),e.fv=l_(n,i)}function Bdt(e){var t=e.stack,i=e.pv;exports.DEBUG&&console.log(e.step,"GPV[]"),t.push(16384*i.x),t.push(16384*i.y)}function Udt(e){var t=e.stack,i=e.fv;exports.DEBUG&&console.log(e.step,"GFV[]"),t.push(16384*i.x),t.push(16384*i.y)}function Hdt(e){e.fv=e.pv,exports.DEBUG&&console.log(e.step,"SFVTPV[]")}function Vdt(e){var t=e.stack,i=t.pop(),n=t.pop(),r=t.pop(),a=t.pop(),s=t.pop(),o=e.z0,l=e.z1,h=o[i],c=o[n],u=l[r],d=l[a],p=e.z2[s];exports.DEBUG&&console.log("ISECT[], ",i,n,r,a,s);var f=h.x,m=h.y,g=c.x,v=c.y,y=u.x,x=u.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 zdt(e){e.rp0=e.stack.pop(),exports.DEBUG&&console.log(e.step,"SRP0[]",e.rp0)}function Gdt(e){e.rp1=e.stack.pop(),exports.DEBUG&&console.log(e.step,"SRP1[]",e.rp1)}function qdt(e){e.rp2=e.stack.pop(),exports.DEBUG&&console.log(e.step,"SRP2[]",e.rp2)}function Wdt(e){var t=e.stack.pop();switch(exports.DEBUG&&console.log(e.step,"SZP0[]",t),e.zp0=t,t){case 0:e.tZone||qC(e),e.z0=e.tZone;break;case 1:e.z0=e.gZone;break;default:throw new Error("Invalid zone pointer")}}function jdt(e){var t=e.stack.pop();switch(exports.DEBUG&&console.log(e.step,"SZP1[]",t),e.zp1=t,t){case 0:e.tZone||qC(e),e.z1=e.tZone;break;case 1:e.z1=e.gZone;break;default:throw new Error("Invalid zone pointer")}}function Xdt(e){var t=e.stack.pop();switch(exports.DEBUG&&console.log(e.step,"SZP2[]",t),e.zp2=t,t){case 0:e.tZone||qC(e),e.z2=e.tZone;break;case 1:e.z2=e.gZone;break;default:throw new Error("Invalid zone pointer")}}function Ydt(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||qC(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 $dt(e){e.loop=e.stack.pop(),exports.DEBUG&&console.log(e.step,"SLOOP[]",e.loop)}function Zdt(e){exports.DEBUG&&console.log(e.step,"RTG[]"),e.round=Nge}function Kdt(e){exports.DEBUG&&console.log(e.step,"RTHG[]"),e.round=Ldt}function Jdt(e){var t=e.stack.pop();exports.DEBUG&&console.log(e.step,"SMD[]",t),e.minDis=t/64}function Qdt(e){exports.DEBUG&&console.log(e.step,"ELSE[]"),Uge(e,!1)}function eft(e){var t=e.stack.pop();exports.DEBUG&&console.log(e.step,"JMPR[]",t),e.ip+=t-1}function tft(e){var t=e.stack.pop();exports.DEBUG&&console.log(e.step,"SCVTCI[]",t),e.cvCutIn=t/64}function nft(e){var t=e.stack;exports.DEBUG&&console.log(e.step,"DUP[]"),t.push(t[t.length-1])}function Q5(e){exports.DEBUG&&console.log(e.step,"POP[]"),e.stack.pop()}function rft(e){exports.DEBUG&&console.log(e.step,"CLEAR[]"),e.stack.length=0}function ift(e){var t=e.stack,i=t.pop(),n=t.pop();exports.DEBUG&&console.log(e.step,"SWAP[]"),t.push(i),t.push(n)}function sft(e){var t=e.stack;exports.DEBUG&&console.log(e.step,"DEPTH[]"),t.push(t.length)}function aft(e){var t=e.stack,i=t.pop(),n=t.pop();exports.DEBUG&&console.log(e.step,"LOOPCALL[]",i,n);var r=e.ip,a=e.prog;e.prog=e.funcs[i];for(var s=0;s<n;s++)tg(e),exports.DEBUG&&console.log(++e.step,s+1<n?"next loopcall":"done loopcall",s);e.ip=r,e.prog=a}function oft(e){var t=e.stack.pop();exports.DEBUG&&console.log(e.step,"CALL[]",t);var i=e.ip,n=e.prog;e.prog=e.funcs[t],tg(e),e.ip=i,e.prog=n,exports.DEBUG&&console.log(++e.step,"returning from",t)}function lft(e){var t=e.stack,i=t.pop();exports.DEBUG&&console.log(e.step,"CINDEX[]",i),t.push(t[t.length-i])}function cft(e){var t=e.stack,i=t.pop();exports.DEBUG&&console.log(e.step,"MINDEX[]",i),t.push(t.splice(t.length-i,1)[0])}function uft(e){if("fpgm"!==e.env)throw new Error("FDEF not allowed here");var t=e.stack,i=e.prog,n=e.ip,r=t.pop(),a=n;for(exports.DEBUG&&console.log(e.step,"FDEF[]",r);45!==i[++n];);e.ip=n,e.funcs[r]=i.slice(a+1,n)}function Fme(e,t){var i=t.stack.pop(),n=t.z0[i],r=t.fv,a=t.pv;exports.DEBUG&&console.log(t.step,"MDAP["+e+"]",i);var s=a.distance(n,i_);e&&(s=t.round(s)),r.setRelative(n,i_,s,a),r.touch(n),t.rp0=t.rp1=i}function Nme(e,t){var i,n,r,a=t.z2,s=a.length-2;exports.DEBUG&&console.log(t.step,"IUP["+e.axis+"]");for(var o=0;o<s;o++)i=a[o],!e.touched(i)&&(n=i.prevTouched(e))!==i&&(n===(r=i.nextTouched(e))&&e.setRelative(i,i,e.distance(n,n,!1,!0),e,!0),e.interpolate(i,n,r,e))}function Bme(e,t){for(var i=t.stack,n=e?t.rp1:t.rp2,r=(e?t.z0:t.z1)[n],a=t.fv,s=t.pv,o=t.loop,l=t.z2;o--;){var h=i.pop(),c=l[h],u=s.distance(r,r,!1,!0);a.setRelative(c,c,u,s),a.touch(c),exports.DEBUG&&console.log(t.step,(t.loop>1?"loop "+(t.loop-o)+": ":"")+"SHP["+(e?"rp1":"rp2")+"]",h)}t.loop=1}function Ume(e,t){var i=t.stack,n=e?t.rp1:t.rp2,r=(e?t.z0:t.z1)[n],a=t.fv,s=t.pv,o=i.pop(),l=t.z2[t.contours[o]],h=l;exports.DEBUG&&console.log(t.step,"SHC["+e+"]",o);var c=s.distance(r,r,!1,!0);do{h!==r&&a.setRelative(h,h,c,s),h=h.nextPointOnContour}while(h!==l)}function Hme(e,t){var i,n=t.stack,r=e?t.rp1:t.rp2,a=(e?t.z0:t.z1)[r],s=t.fv,o=t.pv,l=n.pop();switch(exports.DEBUG&&console.log(t.step,"SHZ["+e+"]",l),l){case 0:i=t.tZone;break;case 1:i=t.gZone;break;default:throw new Error("Invalid zone")}for(var h,c=o.distance(a,a,!1,!0),u=i.length-2,d=0;d<u;d++)h=i[d],s.setRelative(h,h,c,o)}function hft(e){for(var t=e.stack,i=e.loop,n=e.fv,r=t.pop()/64,a=e.z2;i--;){var s=t.pop(),o=a[s];exports.DEBUG&&console.log(e.step,(e.loop>1?"loop "+(e.loop-i)+": ":"")+"SHPIX[]",s,r),n.setRelative(o,o,r),n.touch(o)}e.loop=1}function dft(e){for(var t=e.stack,i=e.rp1,n=e.rp2,r=e.loop,a=e.z0[i],s=e.z1[n],o=e.fv,l=e.dpv,h=e.z2;r--;){var c=t.pop(),u=h[c];exports.DEBUG&&console.log(e.step,(e.loop>1?"loop "+(e.loop-r)+": ":"")+"IP[]",c,i,"<->",n),o.interpolate(u,a,s,l),o.touch(u)}e.loop=1}function Vme(e,t){var i=t.stack,n=i.pop()/64,r=i.pop(),a=t.z1[r],s=t.z0[t.rp0],o=t.fv,l=t.pv;o.setRelative(a,s,n,l),o.touch(a),exports.DEBUG&&console.log(t.step,"MSIRP["+e+"]",n,r),t.rp1=t.rp0,t.rp2=r,e&&(t.rp0=r)}function fft(e){for(var t=e.stack,i=e.rp0,n=e.z0[i],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,n,0,s),a.touch(h)}e.loop=1}function pft(e){exports.DEBUG&&console.log(e.step,"RTDG[]"),e.round=Idt}function zme(e,t){var i=t.stack,n=i.pop(),r=i.pop(),a=t.z0[r],s=t.fv,o=t.pv,l=t.cvt[n];exports.DEBUG&&console.log(t.step,"MIAP["+e+"]",n,"(",l,")",r);var h=o.distance(a,i_);e&&(Math.abs(h-l)<t.cvCutIn&&(h=l),h=t.round(h)),s.setRelative(a,i_,h,o),0===t.zp0&&(a.xo=a.x,a.yo=a.y),s.touch(a),t.rp0=t.rp1=r}function mft(e){var t=e.prog,i=e.ip,n=e.stack,r=t[++i];exports.DEBUG&&console.log(e.step,"NPUSHB[]",r);for(var a=0;a<r;a++)n.push(t[++i]);e.ip=i}function gft(e){var t=e.ip,i=e.prog,n=e.stack,r=i[++t];exports.DEBUG&&console.log(e.step,"NPUSHW[]",r);for(var a=0;a<r;a++){var s=i[++t]<<8|i[++t];32768&s&&(s=-(1+(65535^s))),n.push(s)}e.ip=t}function vft(e){var t=e.stack,i=e.store;i||(i=e.store=[]);var n=t.pop(),r=t.pop();exports.DEBUG&&console.log(e.step,"WS",n,r),i[r]=n}function yft(e){var t=e.stack,i=e.store,n=t.pop();exports.DEBUG&&console.log(e.step,"RS",n);var r=i&&i[n]||0;t.push(r)}function xft(e){var t=e.stack,i=t.pop(),n=t.pop();exports.DEBUG&&console.log(e.step,"WCVTP",i,n),e.cvt[n]=i/64}function bft(e){var t=e.stack,i=t.pop();exports.DEBUG&&console.log(e.step,"RCVT",i),t.push(64*e.cvt[i])}function Gme(e,t){var i=t.stack,n=i.pop(),r=t.z2[n];exports.DEBUG&&console.log(t.step,"GC["+e+"]",n),i.push(64*t.dpv.distance(r,i_,e,!1))}function qme(e,t){var i=t.stack,n=i.pop(),r=i.pop(),a=t.z1[n],s=t.z0[r],o=t.dpv.distance(s,a,e,e);exports.DEBUG&&console.log(t.step,"MD["+e+"]",n,r,"->",o),t.stack.push(Math.round(64*o))}function Eft(e){exports.DEBUG&&console.log(e.step,"MPPEM[]"),e.stack.push(e.ppem)}function _ft(e){exports.DEBUG&&console.log(e.step,"FLIPON[]"),e.autoFlip=!0}function Tft(e){var t=e.stack,i=t.pop(),n=t.pop();exports.DEBUG&&console.log(e.step,"LT[]",i,n),t.push(n<i?1:0)}function wft(e){var t=e.stack,i=t.pop(),n=t.pop();exports.DEBUG&&console.log(e.step,"LTEQ[]",i,n),t.push(n<=i?1:0)}function Sft(e){var t=e.stack,i=t.pop(),n=t.pop();exports.DEBUG&&console.log(e.step,"GT[]",i,n),t.push(n>i?1:0)}function Mft(e){var t=e.stack,i=t.pop(),n=t.pop();exports.DEBUG&&console.log(e.step,"GTEQ[]",i,n),t.push(n>=i?1:0)}function Rft(e){var t=e.stack,i=t.pop(),n=t.pop();exports.DEBUG&&console.log(e.step,"EQ[]",i,n),t.push(i===n?1:0)}function Aft(e){var t=e.stack,i=t.pop(),n=t.pop();exports.DEBUG&&console.log(e.step,"NEQ[]",i,n),t.push(i!==n?1:0)}function Cft(e){var t=e.stack,i=t.pop();exports.DEBUG&&console.log(e.step,"ODD[]",i),t.push(Math.trunc(i)%2?1:0)}function Pft(e){var t=e.stack,i=t.pop();exports.DEBUG&&console.log(e.step,"EVEN[]",i),t.push(Math.trunc(i)%2?0:1)}function Ift(e){var t=e.stack.pop();exports.DEBUG&&console.log(e.step,"IF[]",t),t||(Uge(e,!0),exports.DEBUG&&console.log(e.step,"EIF[]"))}function Lft(e){exports.DEBUG&&console.log(e.step,"EIF[]")}function Dft(e){var t=e.stack,i=t.pop(),n=t.pop();exports.DEBUG&&console.log(e.step,"AND[]",i,n),t.push(i&&n?1:0)}function Oft(e){var t=e.stack,i=t.pop(),n=t.pop();exports.DEBUG&&console.log(e.step,"OR[]",i,n),t.push(i||n?1:0)}function kft(e){var t=e.stack,i=t.pop();exports.DEBUG&&console.log(e.step,"NOT[]",i),t.push(i?0:1)}function e6(e,t){var i=t.stack,n=i.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+"]",n,i);for(var c=0;c<n;c++){var u=i.pop(),d=i.pop();if(o+((240&d)>>4)===s){var p=(15&d)-8;p>=0&&p++,exports.DEBUG&&console.log(t.step,"DELTAPFIX",u,"by",p*l);var f=h[u];r.setRelative(f,f,p*l,a)}}}function Fft(e){var t=e.stack.pop();exports.DEBUG&&console.log(e.step,"SDB[]",t),e.deltaBase=t}function Nft(e){var t=e.stack.pop();exports.DEBUG&&console.log(e.step,"SDS[]",t),e.deltaShift=Math.pow(.5,t)}function Bft(e){var t=e.stack,i=t.pop(),n=t.pop();exports.DEBUG&&console.log(e.step,"ADD[]",i,n),t.push(n+i)}function Uft(e){var t=e.stack,i=t.pop(),n=t.pop();exports.DEBUG&&console.log(e.step,"SUB[]",i,n),t.push(n-i)}function Hft(e){var t=e.stack,i=t.pop(),n=t.pop();exports.DEBUG&&console.log(e.step,"DIV[]",i,n),t.push(64*n/i)}function Vft(e){var t=e.stack,i=t.pop(),n=t.pop();exports.DEBUG&&console.log(e.step,"MUL[]",i,n),t.push(n*i/64)}function zft(e){var t=e.stack,i=t.pop();exports.DEBUG&&console.log(e.step,"ABS[]",i),t.push(Math.abs(i))}function Gft(e){var t=e.stack,i=t.pop();exports.DEBUG&&console.log(e.step,"NEG[]",i),t.push(-i)}function qft(e){var t=e.stack,i=t.pop();exports.DEBUG&&console.log(e.step,"FLOOR[]",i),t.push(64*Math.floor(i/64))}function Wft(e){var t=e.stack,i=t.pop();exports.DEBUG&&console.log(e.step,"CEILING[]",i),t.push(64*Math.ceil(i/64))}function kC(e,t){var i=t.stack,n=i.pop();exports.DEBUG&&console.log(t.step,"ROUND[]"),i.push(64*t.round(n/64))}function jft(e){var t=e.stack,i=t.pop(),n=t.pop();exports.DEBUG&&console.log(e.step,"WCVTF[]",i,n),e.cvt[n]=i*e.ppem/e.font.unitsPerEm}function t6(e,t){var i=t.stack,n=i.pop(),r=t.ppem,a=t.deltaBase+16*(e-1),s=t.deltaShift;exports.DEBUG&&console.log(t.step,"DELTAC["+e+"]",n,i);for(var o=0;o<n;o++){var l=i.pop(),h=i.pop();if(a+((240&h)>>4)===r){var c=(15&h)-8;c>=0&&c++;var u=c*s;exports.DEBUG&&console.log(t.step,"DELTACFIX",l,"by",u),t.cvt[l]+=u}}}function Xft(e){var t,i=e.stack.pop();switch(exports.DEBUG&&console.log(e.step,"SROUND[]",i),e.round=Bge,192&i){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&i){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")}i&=15,e.srThreshold=0===i?0:(i/8-.5)*t}function Yft(e){var t,i=e.stack.pop();switch(exports.DEBUG&&console.log(e.step,"S45ROUND[]",i),e.round=Bge,192&i){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&i){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")}i&=15,e.srThreshold=0===i?0:(i/8-.5)*t}function $ft(e){exports.DEBUG&&console.log(e.step,"ROFF[]"),e.round=Pdt}function Zft(e){exports.DEBUG&&console.log(e.step,"RUTG[]"),e.round=Ddt}function Kft(e){exports.DEBUG&&console.log(e.step,"RDTG[]"),e.round=Odt}function Jft(e){var t=e.stack.pop();exports.DEBUG&&console.log(e.step,"SCANCTRL[]",t)}function Wme(e,t){var i,n,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?(i=o.y-l.y,n=l.x-o.x):(i=l.x-o.x,n=l.y-o.y),t.dpv=l_(i,n)}function Qft(e){var t=e.stack,i=t.pop(),n=0;exports.DEBUG&&console.log(e.step,"GETINFO[]",i),1&i&&(n=35),32&i&&(n|=4096),t.push(n)}function ept(e){var t=e.stack,i=t.pop(),n=t.pop(),r=t.pop();exports.DEBUG&&console.log(e.step,"ROLL[]"),t.push(n),t.push(i),t.push(r)}function tpt(e){var t=e.stack,i=t.pop(),n=t.pop();exports.DEBUG&&console.log(e.step,"MAX[]",i,n),t.push(Math.max(n,i))}function npt(e){var t=e.stack,i=t.pop(),n=t.pop();exports.DEBUG&&console.log(e.step,"MIN[]",i,n),t.push(Math.min(n,i))}function rpt(e){var t=e.stack.pop();exports.DEBUG&&console.log(e.step,"SCANTYPE[]",t)}function ipt(e){var t=e.stack.pop(),i=e.stack.pop();switch(exports.DEBUG&&console.log(e.step,"INSTCTRL[]",t,i),t){case 1:return void(e.inhibitGridFit=!!i);case 2:return void(e.ignoreCvt=!!i);default:throw new Error("invalid INSTCTRL[] selector")}}function Of(e,t){var i=t.stack,n=t.prog,r=t.ip;exports.DEBUG&&console.log(t.step,"PUSHB["+e+"]");for(var a=0;a<e;a++)i.push(n[++r]);t.ip=r}function kf(e,t){var i=t.ip,n=t.prog,r=t.stack;exports.DEBUG&&console.log(t.ip,"PUSHW["+e+"]");for(var a=0;a<e;a++){var s=n[++i]<<8|n[++i];32768&s&&(s=-(1+(65535^s))),r.push(s)}t.ip=i}function En(e,t,i,n,r,a){var s,o,l,h,c=a.stack,u=e&&c.pop(),d=c.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[u],n&&Math.abs(o-h)<a.cvCutIn&&(o=h)),i&&o<g&&(o=g),n&&(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")+(i?">":"_")+(n?"R":"_")+(0===r?"Gr":1===r?"Bl":2===r?"Wh":"")+"]",e?u+"("+a.cvt[u]+","+h+")":"",d,"(d =",s,"->",l*o,")"),a.rp1=a.rp0,a.rp2=d,t&&(a.rp0=d)}function wy(e){this.char=e,this.state={},this.activeState=null}function E6(e,t,i){this.contextName=i,this.startIndex=e,this.endOffset=t}function spt(e,t,i){this.contextName=e,this.openRange=null,this.ranges=[],this.checkStart=t,this.checkEnd=i}function Dc(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 WC(e){this.eventId=e,this.subscribers=[]}function apt(e){var t=this,i=["start","end","next","newToken","contextStart","contextEnd","insertToken","removeToken","removeRange","replaceToken","replaceRange","composeRUD","updateContextsRanges"];i.forEach((function(e){Object.defineProperty(t.events,e,{value:new WC(e)})})),e&&i.forEach((function(i){var n=e[i];"function"==typeof n&&t.events[i].subscribe(n)})),["insertToken","removeToken","removeRange","replaceToken","replaceRange","composeRUD"].forEach((function(e){t.events[e].subscribe(t.updateContextsRanges)}))}function cs(e){this.tokens=[],this.registeredContexts={},this.contextCheckers=[],this.events={},this.registeredModifiers=[],apt.call(this,e)}function Bf(e){return/[\u0600-\u065F\u066A-\u06D2\u06FA-\u06FF]/.test(e)}function Hge(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 Uf(e){return/[\u0600-\u0605\u060C-\u060E\u0610-\u061B\u061E\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED]/.test(e)}function NC(e){return/[A-z]/.test(e)}function opt(e){return/\s/.test(e)}function tl(e){this.font=e,this.features={}}function eg(e){this.id=e.id,this.tag=e.tag,this.substitution=e.substitution}function c_(e,t){if(!e)return-1;switch(t.format){case 1:return t.glyphs.indexOf(e);case 2:for(var i=t.ranges,n=0;n<i.length;n++){var r=i[n];if(e>=r.start&&e<=r.end){var a=e-r.start;return r.index+a}}break;default:return-1}return-1}function lpt(e,t){return-1===c_(e,t.coverage)?null:e+t.deltaGlyphId}function cpt(e,t){var i=c_(e,t.coverage);return-1===i?null:t.substitute[i]}function n6(e,t){for(var i=[],n=0;n<e.length;n++){var r=e[n],a=t.current,s=c_(a=Array.isArray(a)?a[0]:a,r);-1!==s&&i.push(s)}return i.length!==e.length?-1:i}function upt(e,t){var i=t.inputCoverage.length+t.lookaheadCoverage.length+t.backtrackCoverage.length;if(e.context.length<i)return[];var n=n6(t.inputCoverage,e);if(-1===n)return[];var r=t.inputCoverage.length-1;if(e.lookahead.length<t.lookaheadCoverage.length)return[];for(var a=e.lookahead.slice(r);a.length&&Uf(a[0].char);)a.shift();var s=new Dc(a,0),o=n6(t.lookaheadCoverage,s),l=[].concat(e.backtrack);for(l.reverse();l.length&&Uf(l[0].char);)l.shift();if(l.length<t.backtrackCoverage.length)return[];var h=new Dc(l,0),c=n6(t.backtrackCoverage,h),u=[];if(n.length===t.inputCoverage.length&&o.length===t.lookaheadCoverage.length&&c.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<n.length;y++){var x=v(e.get(y));x&&u.push(x)}}return u}function hpt(e,t){var i=c_(e.current,t.coverage);if(-1===i)return null;for(var n,r=t.ligatureSets[i],a=0;a<r.length;a++){n=r[a];for(var s=0;s<n.components.length&&e.lookahead[s]===n.components[s];s++)if(s===n.components.length-1)return n}return null}function dpt(e,t){var i=c_(e,t.coverage);return-1===i?null:t.sequences[i]}function fpt(e){var t=e.current,i=e.get(-1);return null===i&&Bf(t)||!Bf(i)&&Bf(t)}function ppt(e){var t=e.get(1);return null===t||!Bf(t)}Fge.prototype.exec=function(e,t){if("number"!=typeof t)throw new Error("Point size is not a number!");if(!(this._errorState>2)){var i=this.font,n=this._prepState;if(!n||n.ppem!==t){var r=this._fpgmState;if(!r){Nf.prototype=kdt,(r=this._fpgmState=new Nf("fpgm",i.tables.fpgm)).funcs=[],r.font=i,exports.DEBUG&&(console.log("---EXEC FPGM---"),r.step=-1);try{tg(r)}catch(e){return console.log("Hinting error in FPGM:"+e),void(this._errorState=3)}}Nf.prototype=r,(n=this._prepState=new Nf("prep",i.tables.prep)).ppem=t;var a=i.tables.cvt;if(a)for(var s=n.cvt=new Array(a.length),o=t/i.unitsPerEm,l=0;l<a.length;l++)s[l]=a[l]*o;else n.cvt=[];exports.DEBUG&&(console.log("---EXEC PREP---"),n.step=-1);try{tg(n)}catch(e){this._errorState<2&&console.log("Hinting error in PREP:"+e),this._errorState=2}}if(!(this._errorState>1))try{return kge(e,n)}catch(e){return this._errorState<1&&(console.log("Hinting error:"+e),console.log("Note: further hinting errors are silenced")),void(this._errorState=1)}}},kge=function(e,t){var i,n,r,a=t.ppem/t.font.unitsPerEm,s=a,o=e.components;if(Nf.prototype=t,o){var l=t.font;n=[],i=[];for(var h=0;h<o.length;h++){var c=o[h],u=l.glyphs.get(c.glyphIndex);r=new Nf("glyf",u.instructions),exports.DEBUG&&(console.log("---EXEC COMP "+h+"---"),r.step=-1),d6(u,r,a,s);for(var d=Math.round(c.dx*a),p=Math.round(c.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=n.length;n.push.apply(n,f);for(var x=0;x<m.length;x++)i.push(m[x]+y)}e.instructions&&!r.inhibitGridFit&&((r=new Nf("glyf",e.instructions)).gZone=r.z0=r.z1=r.z2=n,r.contours=i,n.push(new od(0,0),new od(Math.round(e.advanceWidth*a),0)),exports.DEBUG&&(console.log("---EXEC COMPOSITE---"),r.step=-1),tg(r),n.length-=2)}else r=new Nf("glyf",e.instructions),exports.DEBUG&&(console.log("---EXEC GLYPH---"),r.step=-1),d6(e,r,a,s),n=r.gZone;return n},d6=function(e,t,i,n){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 od(r.x*i,r.y*n,r.lastPointOfContour,r.onCurve);for(var c,u,d=0;d<s;d++)r=o[d],c||(c=r,l.push(d)),r.lastPointOfContour?(r.nextPointOnContour=c,c.prevPointOnContour=r,c=void 0):(u=o[d+1],r.nextPointOnContour=u,u.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 od(0,0),new od(Math.round(e.advanceWidth*i),0)),tg(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)}}},tg=function(e){var t=e.prog;if(t){var i,n=t.length;for(e.ip=0;e.ip<n;e.ip++){if(exports.DEBUG&&e.step++,!(i=Oge[t[e.ip]]))throw new Error("unknown instruction: 0x"+Number(t[e.ip]).toString(16));i(e)}}},Oge=[Ime.bind(void 0,ad),Ime.bind(void 0,Yu),Lme.bind(void 0,ad),Lme.bind(void 0,Yu),Dme.bind(void 0,ad),Dme.bind(void 0,Yu),Ome.bind(void 0,0),Ome.bind(void 0,1),kme.bind(void 0,0),kme.bind(void 0,1),Fdt,Ndt,Bdt,Udt,Hdt,Vdt,zdt,Gdt,qdt,Wdt,jdt,Xdt,Ydt,$dt,Zdt,Kdt,Jdt,Qdt,eft,tft,void 0,void 0,nft,Q5,rft,ift,sft,lft,cft,void 0,void 0,void 0,aft,oft,uft,void 0,Fme.bind(void 0,0),Fme.bind(void 0,1),Nme.bind(void 0,ad),Nme.bind(void 0,Yu),Bme.bind(void 0,0),Bme.bind(void 0,1),Ume.bind(void 0,0),Ume.bind(void 0,1),Hme.bind(void 0,0),Hme.bind(void 0,1),hft,dft,Vme.bind(void 0,0),Vme.bind(void 0,1),fft,pft,zme.bind(void 0,0),zme.bind(void 0,1),mft,gft,vft,yft,xft,bft,Gme.bind(void 0,0),Gme.bind(void 0,1),void 0,qme.bind(void 0,0),qme.bind(void 0,1),Eft,void 0,_ft,void 0,void 0,Tft,wft,Sft,Mft,Rft,Aft,Cft,Pft,Ift,Lft,Dft,Oft,kft,e6.bind(void 0,1),Fft,Nft,Bft,Uft,Hft,Vft,zft,Gft,qft,Wft,kC.bind(void 0,0),kC.bind(void 0,1),kC.bind(void 0,2),kC.bind(void 0,3),void 0,void 0,void 0,void 0,jft,e6.bind(void 0,2),e6.bind(void 0,3),t6.bind(void 0,1),t6.bind(void 0,2),t6.bind(void 0,3),Xft,Yft,void 0,void 0,$ft,void 0,Zft,Kft,Q5,Q5,void 0,void 0,void 0,void 0,void 0,Jft,Wme.bind(void 0,0),Wme.bind(void 0,1),Qft,void 0,ept,tpt,npt,rpt,ipt,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,Of.bind(void 0,1),Of.bind(void 0,2),Of.bind(void 0,3),Of.bind(void 0,4),Of.bind(void 0,5),Of.bind(void 0,6),Of.bind(void 0,7),Of.bind(void 0,8),kf.bind(void 0,1),kf.bind(void 0,2),kf.bind(void 0,3),kf.bind(void 0,4),kf.bind(void 0,5),kf.bind(void 0,6),kf.bind(void 0,7),kf.bind(void 0,8),En.bind(void 0,0,0,0,0,0),En.bind(void 0,0,0,0,0,1),En.bind(void 0,0,0,0,0,2),En.bind(void 0,0,0,0,0,3),En.bind(void 0,0,0,0,1,0),En.bind(void 0,0,0,0,1,1),En.bind(void 0,0,0,0,1,2),En.bind(void 0,0,0,0,1,3),En.bind(void 0,0,0,1,0,0),En.bind(void 0,0,0,1,0,1),En.bind(void 0,0,0,1,0,2),En.bind(void 0,0,0,1,0,3),En.bind(void 0,0,0,1,1,0),En.bind(void 0,0,0,1,1,1),En.bind(void 0,0,0,1,1,2),En.bind(void 0,0,0,1,1,3),En.bind(void 0,0,1,0,0,0),En.bind(void 0,0,1,0,0,1),En.bind(void 0,0,1,0,0,2),En.bind(void 0,0,1,0,0,3),En.bind(void 0,0,1,0,1,0),En.bind(void 0,0,1,0,1,1),En.bind(void 0,0,1,0,1,2),En.bind(void 0,0,1,0,1,3),En.bind(void 0,0,1,1,0,0),En.bind(void 0,0,1,1,0,1),En.bind(void 0,0,1,1,0,2),En.bind(void 0,0,1,1,0,3),En.bind(void 0,0,1,1,1,0),En.bind(void 0,0,1,1,1,1),En.bind(void 0,0,1,1,1,2),En.bind(void 0,0,1,1,1,3),En.bind(void 0,1,0,0,0,0),En.bind(void 0,1,0,0,0,1),En.bind(void 0,1,0,0,0,2),En.bind(void 0,1,0,0,0,3),En.bind(void 0,1,0,0,1,0),En.bind(void 0,1,0,0,1,1),En.bind(void 0,1,0,0,1,2),En.bind(void 0,1,0,0,1,3),En.bind(void 0,1,0,1,0,0),En.bind(void 0,1,0,1,0,1),En.bind(void 0,1,0,1,0,2),En.bind(void 0,1,0,1,0,3),En.bind(void 0,1,0,1,1,0),En.bind(void 0,1,0,1,1,1),En.bind(void 0,1,0,1,1,2),En.bind(void 0,1,0,1,1,3),En.bind(void 0,1,1,0,0,0),En.bind(void 0,1,1,0,0,1),En.bind(void 0,1,1,0,0,2),En.bind(void 0,1,1,0,0,3),En.bind(void 0,1,1,0,1,0),En.bind(void 0,1,1,0,1,1),En.bind(void 0,1,1,0,1,2),En.bind(void 0,1,1,0,1,3),En.bind(void 0,1,1,1,0,0),En.bind(void 0,1,1,1,0,1),En.bind(void 0,1,1,1,0,2),En.bind(void 0,1,1,1,0,3),En.bind(void 0,1,1,1,1,0),En.bind(void 0,1,1,1,1,1),En.bind(void 0,1,1,1,1,2),En.bind(void 0,1,1,1,1,3)],wy.prototype.setState=function(e,t){return this.state[e]=t,this.activeState={key:e,value:this.state[e]},this.activeState},wy.prototype.getState=function(e){return this.state[e]||null},cs.prototype.inboundIndex=function(e){return e>=0&&e<this.tokens.length},cs.prototype.composeRUD=function(e){var t=this,i=e.map((function(e){return t[e[0]].apply(t,e.slice(1).concat(!0))})),n=function(e){return"object"==typeof e&&e.hasOwnProperty("FAIL")};if(i.every(n))return{FAIL:"composeRUD: one or more operations hasn't completed successfully",report:i.filter(n)};this.dispatch("composeRUD",[i.filter((function(e){return!n(e)}))])},cs.prototype.replaceRange=function(e,t,i,n){t=null!==t?t:this.tokens.length;var r=i.every((function(e){return e instanceof wy}));if(!isNaN(e)&&this.inboundIndex(e)&&r){var a=this.tokens.splice.apply(this.tokens,[e,t].concat(i));return n||this.dispatch("replaceToken",[e,t,i]),[a,i]}return{FAIL:"replaceRange: invalid tokens or startIndex."}},cs.prototype.replaceToken=function(e,t,i){if(!isNaN(e)&&this.inboundIndex(e)&&t instanceof wy){var n=this.tokens.splice(e,1,t);return i||this.dispatch("replaceToken",[e,t]),[n[0],t]}return{FAIL:"replaceToken: invalid token or index."}},cs.prototype.removeRange=function(e,t,i){t=isNaN(t)?this.tokens.length:t;var n=this.tokens.splice(e,t);return i||this.dispatch("removeRange",[n,e,t]),n},cs.prototype.removeToken=function(e,t){if(!isNaN(e)&&this.inboundIndex(e)){var i=this.tokens.splice(e,1);return t||this.dispatch("removeToken",[i,e]),i}return{FAIL:"removeToken: invalid token index."}},cs.prototype.insertToken=function(e,t,i){return e.every((function(e){return e instanceof wy}))?(this.tokens.splice.apply(this.tokens,[t,0].concat(e)),i||this.dispatch("insertToken",[e,t]),e):{FAIL:"insertToken: invalid token(s)."}},cs.prototype.registerModifier=function(e,t,i){this.events.newToken.subscribe((function(n,r){var a=[n,r],s=[n,r];if(null===t||!0===t.apply(this,a)){var o=i.apply(this,s);n.setState(e,o)}})),this.registeredModifiers.push(e)},WC.prototype.subscribe=function(e){return"function"==typeof e?this.subscribers.push(e)-1:{FAIL:"invalid '"+this.eventId+"' event handler"}},WC.prototype.unsubscribe=function(e){this.subscribers.splice(e,1)},Dc.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)},Dc.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}},cs.prototype.rangeToText=function(e){if(e instanceof E6)return this.getRangeTokens(e).map((function(e){return e.char})).join("")},cs.prototype.getText=function(){return this.tokens.map((function(e){return e.char})).join("")},cs.prototype.getContext=function(e){return this.registeredContexts[e]||null},cs.prototype.on=function(e,t){var i=this.events[e];return i?i.subscribe(t):null},cs.prototype.dispatch=function(e,t){var i=this,n=this.events[e];n instanceof WC&&n.subscribers.forEach((function(e){e.apply(i,t||[])}))},cs.prototype.registerContextChecker=function(e,t,i){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 i)return{FAIL:"missing context end check."};var n=new spt(e,t,i);return this.registeredContexts[e]=n,this.contextCheckers.push(n),n},cs.prototype.getRangeTokens=function(e){var t=e.startIndex+e.endOffset;return[].concat(this.tokens.slice(e.startIndex,t))},cs.prototype.getContextRanges=function(e){var t=this.getContext(e);return t?t.ranges:{FAIL:"context checker '"+e+"' is not registered."}},cs.prototype.resetContextsRanges=function(){var e=this.registeredContexts;for(var t in e)e.hasOwnProperty(t)&&(e[t].ranges=[])},cs.prototype.updateContextsRanges=function(){this.resetContextsRanges();for(var e=this.tokens.map((function(e){return e.char})),t=0;t<e.length;t++){var i=new Dc(e,t);this.runContextCheck(i)}this.dispatch("updateContextsRanges",[this.registeredContexts])},cs.prototype.setEndOffset=function(e,t){var i=new E6(this.getContext(t).openRange.startIndex,e,t),n=this.getContext(t).ranges;return i.rangeId=t+"."+n.length,n.push(i),this.getContext(t).openRange=null,i},cs.prototype.runContextCheck=function(e){var t=this,i=e.index;this.contextCheckers.forEach((function(n){var r=n.contextName,a=t.getContext(r).openRange;if(!a&&n.checkStart(e)&&(a=new E6(i,null,r),t.getContext(r).openRange=a,t.dispatch("contextStart",[r,i])),a&&n.checkEnd(e)){var s=i-a.startIndex+1,o=t.setEndOffset(s,r);t.dispatch("contextEnd",[r,o])}}))},cs.prototype.tokenize=function(e){this.tokens=[],this.resetContextsRanges();var t=Array.from(e);this.dispatch("start");for(var i=0;i<t.length;i++){var n=t[i],r=new Dc(t,i);this.dispatch("next",[r]),this.runContextCheck(r);var a=new wy(n);this.tokens.push(a),this.dispatch("newToken",[a,r])}return this.dispatch("end",[this.tokens]),this.tokens},tl.prototype.getDefaultScriptFeaturesIndexes=function(){for(var e=this.font.tables.gsub.scripts,t=0;t<e.length;t++){var i=e[t];if("DFLT"===i.tag)return i.script.defaultLangSys.featureIndexes}return[]},tl.prototype.getScriptFeaturesIndexes=function(e){if(!this.font.tables.gsub)return[];if(!e)return this.getDefaultScriptFeaturesIndexes();for(var t=this.font.tables.gsub.scripts,i=0;i<t.length;i++){var n=t[i];if(n.tag===e&&n.script.defaultLangSys)return n.script.defaultLangSys.featureIndexes;var r=n.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()},tl.prototype.mapTagsToFeatures=function(e,t){for(var i={},n=0;n<e.length;n++){var r=e[n].tag,a=e[n].feature;i[r]=a}this.features[t].tags=i},tl.prototype.getScriptFeatures=function(e){var t=this.features[e];if(this.features.hasOwnProperty(e))return t;var i=this.getScriptFeaturesIndexes(e);if(!i)return null;var n=this.font.tables.gsub;return t=i.map((function(e){return n.features[e]})),this.features[e]=t,this.mapTagsToFeatures(t,e),t},tl.prototype.getSubstitutionType=function(e,t){return e.lookupType.toString()+t.substFormat.toString()},tl.prototype.getLookupMethod=function(e,t){var i=this;switch(this.getSubstitutionType(e,t)){case"11":return function(e){return lpt.apply(i,[e,t])};case"12":return function(e){return cpt.apply(i,[e,t])};case"63":return function(e){return upt.apply(i,[e,t])};case"41":return function(e){return hpt.apply(i,[e,t])};case"21":return function(e){return dpt.apply(i,[e,t])};default:throw new Error("lookupType: "+e.lookupType+" - substFormat: "+t.substFormat+" is not yet supported")}},tl.prototype.lookupFeature=function(e){var t=e.contextParams,i=t.index,n=this.getFeature({tag:e.tag,script:e.script});if(!n)return new Error("font '"+this.font.names.fullName.en+"' doesn't support feature '"+e.tag+"' for script '"+e.script+"'.");for(var r=this.getFeatureLookups(n),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 c=l[h],u=this.getSubstitutionType(o,c),d=this.getLookupMethod(o,c),p=void 0;switch(u){case"11":(p=d(t.current))&&a.splice(i,1,new eg({id:11,tag:e.tag,substitution:p}));break;case"12":(p=d(t.current))&&a.splice(i,1,new eg({id:12,tag:e.tag,substitution:p}));break;case"63":p=d(t),Array.isArray(p)&&p.length&&a.splice(i,1,new eg({id:63,tag:e.tag,substitution:p}));break;case"41":(p=d(t))&&a.splice(i,1,new eg({id:41,tag:e.tag,substitution:p}));break;case"21":(p=d(t.current))&&a.splice(i,1,new eg({id:21,tag:e.tag,substitution:p}))}t=new Dc(a,i),(!Array.isArray(p)||p.length)&&(p=null)}return a.length?a:null},tl.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 i=this.features[e.script].some((function(t){return t.tag===e.tag}));return t&&i},tl.prototype.getLookupSubtables=function(e){return e.subtables||null},tl.prototype.getLookupByIndex=function(e){return this.font.tables.gsub.lookups[e]||null},tl.prototype.getFeatureLookups=function(e){return e.lookupListIndexes.map(this.getLookupByIndex.bind(this))},tl.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 mpt={startCheck:fpt,endCheck:ppt};function gpt(e){var t=e.current,i=e.get(-1);return(Bf(t)||Uf(t))&&!Bf(i)}function vpt(e){var t=e.get(1);switch(!0){case null===t:return!0;case!Bf(t)&&!Uf(t):var i=opt(t);if(!i)return!0;if(i&&!e.lookahead.some((function(e){return Bf(e)||Uf(e)})))return!0;break;default:return!1}}var ypt={startCheck:gpt,endCheck:vpt};function xpt(e,t,i){t[i].setState(e.tag,e.substitution)}function bpt(e,t,i){t[i].setState(e.tag,e.substitution)}function Ept(e,t,i){e.substitution.forEach((function(n,r){t[i+r].setState(e.tag,n)}))}function _pt(e,t,i){var n=t[i];n.setState(e.tag,e.substitution.ligGlyph);for(var r=e.substitution.components.length,a=0;a<r;a++)(n=t[i+a+1]).setState("deleted",!0)}var jme={11:xpt,12:bpt,63:Ept,41:_pt};function _6(e,t,i){e instanceof eg&&jme[e.id]&&jme[e.id](e,t,i)}function Tpt(e){for(var t=[].concat(e.backtrack),i=t.length-1;i>=0;i--){var n=t[i],r=Hge(n),a=Uf(n);if(!r&&!a)return!0;if(r)return!1}return!1}function wpt(e){if(Hge(e.current))return!1;for(var t=0;t<e.lookahead.length;t++)if(!Uf(e.lookahead[t]))return!0;return!1}function Spt(e){var t=this,i="arab",n=this.featuresTags[i],r=this.tokenizer.getRangeTokens(e);if(1!==r.length){var a=new Dc(r.map((function(e){return e.getState("glyphIndex")})),0),s=new Dc(r.map((function(e){return e.char})),0);r.forEach((function(e,o){if(!Uf(e.char)){a.setCurrentIndex(o),s.setCurrentIndex(o);var l,h=0;switch(Tpt(s)&&(h|=1),wpt(s)&&(h|=2),h){case 1:l="fina";break;case 2:l="init";break;case 3:l="medi"}if(-1!==n.indexOf(l)){var c=t.query.lookupFeature({tag:l,script:i,contextParams:a});if(c instanceof Error)return console.info(c.message);c.forEach((function(e,t){e instanceof eg&&(_6(e,r,t),a.context[t]=e.substitution)}))}}}))}}function Xme(e,t){return new Dc(e.map((function(e){return e.activeState.value})),t||0)}function Mpt(e){var t=this,i=this.tokenizer.getRangeTokens(e),n=Xme(i);n.context.forEach((function(e,r){n.setCurrentIndex(r);var a=t.query.lookupFeature({tag:"rlig",script:"arab",contextParams:n});a.length&&(a.forEach((function(e){return _6(e,i,r)})),n=Xme(i))}))}function Rpt(e){var t=e.current,i=e.get(-1);return null===i&&NC(t)||!NC(i)&&NC(t)}function Apt(e){var t=e.get(1);return null===t||!NC(t)}var Cpt={startCheck:Rpt,endCheck:Apt};function Yme(e,t){return new Dc(e.map((function(e){return e.activeState.value})),t||0)}function Ppt(e){var t=this,i=this.tokenizer.getRangeTokens(e),n=Yme(i);n.context.forEach((function(e,r){n.setCurrentIndex(r);var a=t.query.lookupFeature({tag:"liga",script:"latn",contextParams:n});a.length&&(a.forEach((function(e){return _6(e,i,r)})),n=Yme(i))}))}function Fc(e){this.baseDir=e||"ltr",this.tokenizer=new cs,this.featuresTags={}}function r6(e){var t=this.contextChecks[e+"Check"];return this.tokenizer.registerContextChecker(e,t.startCheck,t.endCheck)}function Ipt(){return r6.call(this,"latinWord"),r6.call(this,"arabicWord"),r6.call(this,"arabicSentence"),this.tokenizer.tokenize(this.text)}function Lpt(){var e=this;this.tokenizer.getContextRanges("arabicSentence").forEach((function(t){var i=e.tokenizer.getRangeTokens(t);e.tokenizer.replaceRange(t.startIndex,t.endOffset,i.reverse())}))}function T6(){if(-1===this.tokenizer.registeredModifiers.indexOf("glyphIndex"))throw new Error("glyphIndex modifier is required to apply arabic presentation features.")}function Dpt(){var e=this;this.featuresTags.hasOwnProperty("arab")&&(T6.call(this),this.tokenizer.getContextRanges("arabicWord").forEach((function(t){Spt.call(e,t)})))}function Opt(){var e=this,t="arab";this.featuresTags.hasOwnProperty(t)&&-1!==this.featuresTags[t].indexOf("rlig")&&(T6.call(this),this.tokenizer.getContextRanges("arabicWord").forEach((function(t){Mpt.call(e,t)})))}function kpt(){var e=this,t="latn";this.featuresTags.hasOwnProperty(t)&&-1!==this.featuresTags[t].indexOf("liga")&&(T6.call(this),this.tokenizer.getContextRanges("latinWord").forEach((function(t){Ppt.call(e,t)})))}function Ci(e){(e=e||{}).tables=e.tables||{},e.empty||(QE(e.familyName,"When creating a new Font object, familyName is required."),QE(e.styleName,"When creating a new Font object, styleName is required."),QE(e.unitsPerEm,"When creating a new Font object, unitsPerEm is required."),QE(e.ascender,"When creating a new Font object, ascender is required."),QE(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 $u.GlyphSet(this,e.glyphs||[]),this.encoding=new sge(this),this.position=new a_(this),this.substitution=new el(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 Fge(this):void 0}})}function Vge(e,t){var i=JSON.stringify(e),n=256;for(var r in t){var a=parseInt(r);if(a&&!(a<256)){if(JSON.stringify(t[r])===i)return a;n<=a&&(n=a+1)}}return t[n]=e,n}function Fpt(e,t,i){var n=Vge(t.name,i);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:n}]}function Npt(e,t,i){var n={},r=new wn.Parser(e,t);return n.tag=r.parseTag(),n.minValue=r.parseFixed(),n.defaultValue=r.parseFixed(),n.maxValue=r.parseFixed(),r.skip("uShort",1),n.name=i[r.parseUShort()]||{},n}function Bpt(e,t,i,n){for(var r=[{name:"nameID_"+e,type:"USHORT",value:Vge(t.name,n)},{name:"flags_"+e,type:"USHORT",value:0}],a=0;a<i.length;++a){var s=i[a].tag;r.push({name:"axis_"+e+" "+s,type:"FIXED",value:t.coordinates[s]<<16})}return r}function Upt(e,t,i,n){var r={},a=new wn.Parser(e,t);r.name=n[a.parseUShort()]||{},a.skip("uShort",1),r.coordinates={};for(var s=0;s<i.length;++s)r.coordinates[i[s].tag]=a.parseFixed();return r}function Hpt(e,t){var i=new fn.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}]);i.offsetToData=i.sizeOf();for(var n=0;n<e.axes.length;n++)i.fields=i.fields.concat(Fpt(n,e.axes[n],t));for(var r=0;r<e.instances.length;r++)i.fields=i.fields.concat(Bpt(r,e.instances[r],e.axes,t));return i}function Vpt(e,t,i){var n=new wn.Parser(e,t),r=n.parseULong();Yn.argument(65536===r,"Unsupported fvar table version.");var a=n.parseOffset16();n.skip("uShort",1);for(var s=n.parseUShort(),o=n.parseUShort(),l=n.parseUShort(),h=n.parseUShort(),c=[],u=0;u<s;u++)c.push(Npt(e,t+a+u*o,i));for(var d=[],p=t+a+s*o,f=0;f<l;f++)d.push(Upt(e,p+f*h,c,i));return{axes:c,instances:d}}Fc.prototype.setText=function(e){this.text=e},Fc.prototype.contextChecks={latinWordCheck:Cpt,arabicWordCheck:mpt,arabicSentenceCheck:ypt},Fc.prototype.registerFeatures=function(e,t){var i=this,n=t.filter((function(t){return i.query.supports({script:e,tag:t})}));this.featuresTags.hasOwnProperty(e)?this.featuresTags[e]=this.featuresTags[e].concat(n):this.featuresTags[e]=n},Fc.prototype.applyFeatures=function(e,t){if(!e)throw new Error("No valid font was provided to apply features");this.query||(this.query=new tl(e));for(var i=0;i<t.length;i++){var n=t[i];this.query.supports({script:n.script})&&this.registerFeatures(n.script,n.tags)}},Fc.prototype.registerModifier=function(e,t,i){this.tokenizer.registerModifier(e,t,i)},Fc.prototype.checkContextReady=function(e){return!!this.tokenizer.getContext(e)},Fc.prototype.applyFeaturesToContexts=function(){this.checkContextReady("arabicWord")&&(Dpt.call(this),Opt.call(this)),this.checkContextReady("latinWord")&&kpt.call(this),this.checkContextReady("arabicSentence")&&Lpt.call(this)},Fc.prototype.processText=function(e){(!this.text||this.text!==e)&&(this.setText(e),Ipt.call(this),this.applyFeaturesToContexts())},Fc.prototype.getBidiText=function(e){return this.processText(e),this.tokenizer.getText()},Fc.prototype.getTextGlyphs=function(e){this.processText(e);for(var t=[],i=0;i<this.tokenizer.tokens.length;i++){var n=this.tokenizer.tokens[i];if(!n.state.deleted){var r=n.activeState.value;t.push(Array.isArray(r)?r[0]:r)}}return t},Ci.prototype.hasChar=function(e){return null!==this.encoding.charToGlyphIndex(e)},Ci.prototype.charToGlyphIndex=function(e){return this.encoding.charToGlyphIndex(e)},Ci.prototype.charToGlyph=function(e){var t=this.charToGlyphIndex(e),i=this.glyphs.get(t);return i||(i=this.glyphs.get(0)),i},Ci.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}))},Ci.prototype.stringToGlyphs=function(e,t){var i=this,n=new Fc;n.registerModifier("glyphIndex",null,(function(e){return i.charToGlyphIndex(e.char)}));var r=t?this.updateFeatures(t.features):this.defaultRenderOptions.features;n.applyFeatures(this,r);for(var a=n.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},Ci.prototype.nameToGlyphIndex=function(e){return this.glyphNames.nameToGlyphIndex(e)},Ci.prototype.nameToGlyph=function(e){var t=this.nameToGlyphIndex(e),i=this.glyphs.get(t);return i||(i=this.glyphs.get(0)),i},Ci.prototype.glyphIndexToName=function(e){return this.glyphNames.glyphIndexToName?this.glyphNames.glyphIndexToName(e):""},Ci.prototype.getKerningValue=function(e,t){e=e.index||e,t=t.index||t;var i=this.position.defaultKerningTables;return i?this.position.getKerningValue(i,e,t):this.kerningPairs[e+","+t]||0},Ci.prototype.defaultRenderOptions={kerning:!0,features:[{script:"arab",tags:["init","medi","fina","rlig"]},{script:"latn",tags:["liga","rlig"]}]},Ci.prototype.forEachGlyph=function(e,t,i,n,r,a){t=void 0!==t?t:0,i=void 0!==i?i:0,n=void 0!==n?n:72,r=Object.assign({},this.defaultRenderOptions,r);var s,o=1/this.unitsPerEm*n,l=this.stringToGlyphs(e,r);if(r.kerning){var h=r.script||this.position.getDefaultScriptName();s=this.position.getKerningTables(h,r.language)}for(var c=0;c<l.length;c+=1){var u=l[c];a.call(this,u,t,i,n,r),u.advanceWidth&&(t+=u.advanceWidth*o),r.kerning&&c<l.length-1&&(t+=(s?this.position.getKerningValue(s,u.index,l[c+1].index):this.getKerningValue(u,l[c+1]))*o),r.letterSpacing?t+=r.letterSpacing*n:r.tracking&&(t+=r.tracking/1e3*n)}return t},Ci.prototype.getPath=function(e,t,i,n,r){var a=new ks;return this.forEachGlyph(e,t,i,n,r,(function(e,t,i,n){var s=e.getPath(t,i,n,r,this);a.extend(s)})),a},Ci.prototype.getPaths=function(e,t,i,n,r){var a=[];return this.forEachGlyph(e,t,i,n,r,(function(e,t,i,n){var s=e.getPath(t,i,n,r,this);a.push(s)})),a},Ci.prototype.getAdvanceWidth=function(e,t,i){return this.forEachGlyph(e,0,0,t,i,(function(){}))},Ci.prototype.draw=function(e,t,i,n,r,a){this.getPath(t,i,n,r,a).draw(e)},Ci.prototype.drawPoints=function(e,t,i,n,r,a){this.forEachGlyph(t,i,n,r,a,(function(t,i,n,r){t.drawPoints(e,i,n,r)}))},Ci.prototype.drawMetrics=function(e,t,i,n,r,a){this.forEachGlyph(t,i,n,r,a,(function(t,i,n,r){t.drawMetrics(e,i,n,r)}))},Ci.prototype.getEnglishName=function(e){var t=this.names[e];if(t)return t.en},Ci.prototype.validate=function(){var e=this;function t(t){var i=e.getEnglishName(t);i&&i.trim().length}t("fontFamily"),t("weightName"),t("manufacturer"),t("copyright"),t("version"),this.unitsPerEm},Ci.prototype.toTables=function(){return _dt.fontToTable(this)},Ci.prototype.toBuffer=function(){return console.warn("Font.toBuffer is deprecated. Use Font.toArrayBuffer instead."),this.toArrayBuffer()},Ci.prototype.toArrayBuffer=function(){for(var e=this.toTables().encode(),t=new ArrayBuffer(e.length),i=new Uint8Array(t),n=0;n<e.length;n++)i[n]=e[n];return t},Ci.prototype.download=function(e){var t=this.getEnglishName("fontFamily"),i=this.getEnglishName("fontSubfamily");e=e||t.replace(/\s/g,"")+"-"+i+".otf";var n=this.toArrayBuffer();if(wdt())if(window.URL=window.URL||window.webkitURL,window.URL){var r=new DataView(n),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=PC(),h=Sdt(n);l.writeFileSync(e,h)}},Ci.prototype.fsSelectionValues={ITALIC:1,UNDERSCORE:2,NEGATIVE:4,OUTLINED:8,STRIKEOUT:16,BOLD:32,REGULAR:64,USER_TYPO_METRICS:128,WWS:256,OBLIQUE:512},Ci.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},Ci.prototype.usWeightClasses={THIN:100,EXTRA_LIGHT:200,LIGHT:300,NORMAL:400,MEDIUM:500,SEMI_BOLD:600,BOLD:700,EXTRA_BOLD:800,BLACK:900};var zpt={make:Hpt,parse:Vpt},Gpt=function(){return{coverage:this.parsePointer(Tt.coverage),attachPoints:this.parseList(Tt.pointer(Tt.uShortList))}},qpt=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},Wpt=function(){return this.parseList(Tt.pointer(qpt))},jpt=function(){return{coverage:this.parsePointer(Tt.coverage),ligGlyphs:this.parseList(Tt.pointer(Wpt))}},Xpt=function(){return this.parseUShort(),this.parseList(Tt.pointer(Tt.coverage))};function Ypt(e,t){var i=new Tt(e,t=t||0),n=i.parseVersion(1);Yn.argument(1===n||1.2===n||1.3===n,"Unsupported GDEF table version.");var r={version:n,classDef:i.parsePointer(Tt.classDef),attachList:i.parsePointer(Gpt),ligCaretList:i.parsePointer(jpt),markAttachClassDef:i.parsePointer(Tt.classDef)};return n>=1.2&&(r.markGlyphSets=i.parsePointer(Xpt)),r}var $pt={parse:Ypt},Oc=new Array(10);function Zpt(e,t){var i=new Tt(e,t=t||0),n=i.parseVersion(1);return Yn.argument(1===n||1.1===n,"Unsupported GPOS table version "+n),1===n?{version:n,scripts:i.parseScriptList(),features:i.parseFeatureList(),lookups:i.parseLookupList(Oc)}:{version:n,scripts:i.parseScriptList(),features:i.parseFeatureList(),lookups:i.parseLookupList(Oc),variations:i.parseFeatureVariationsList()}}Oc[1]=function(){var e=this.offset+this.relativeOffset,t=this.parseUShort();return 1===t?{posFormat:1,coverage:this.parsePointer(Tt.coverage),value:this.parseValueRecord()}:2===t?{posFormat:2,coverage:this.parsePointer(Tt.coverage),values:this.parseValueRecordList()}:void Yn.assert(!1,"0x"+e.toString(16)+": GPOS lookup type 1 format must be 1 or 2.")},Oc[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 i=this.parsePointer(Tt.coverage),n=this.parseUShort(),r=this.parseUShort();if(1===t)return{posFormat:t,coverage:i,valueFormat1:n,valueFormat2:r,pairSets:this.parseList(Tt.pointer(Tt.list((function(){return{secondGlyph:this.parseUShort(),value1:this.parseValueRecord(n),value2:this.parseValueRecord(r)}}))))};if(2===t){var a=this.parsePointer(Tt.classDef),s=this.parsePointer(Tt.classDef),o=this.parseUShort(),l=this.parseUShort();return{posFormat:t,coverage:i,valueFormat1:n,valueFormat2:r,classDef1:a,classDef2:s,class1Count:o,class2Count:l,classRecords:this.parseList(o,Tt.list(l,(function(){return{value1:this.parseValueRecord(n),value2:this.parseValueRecord(r)}})))}}},Oc[3]=function(){return{error:"GPOS Lookup 3 not supported"}},Oc[4]=function(){return{error:"GPOS Lookup 4 not supported"}},Oc[5]=function(){return{error:"GPOS Lookup 5 not supported"}},Oc[6]=function(){return{error:"GPOS Lookup 6 not supported"}},Oc[7]=function(){return{error:"GPOS Lookup 7 not supported"}},Oc[8]=function(){return{error:"GPOS Lookup 8 not supported"}},Oc[9]=function(){return{error:"GPOS Lookup 9 not supported"}};var Kpt=new Array(10);function Jpt(e){return new fn.Table("GPOS",[{name:"version",type:"ULONG",value:65536},{name:"scripts",type:"TABLE",value:new fn.ScriptList(e.scripts)},{name:"features",type:"TABLE",value:new fn.FeatureList(e.features)},{name:"lookups",type:"TABLE",value:new fn.LookupList(e.lookups,Kpt)}])}var Qpt={parse:Zpt,make:Jpt};function emt(e){var t={};e.skip("uShort");var i=e.parseUShort();Yn.argument(0===i,"Unsupported kern sub-table version."),e.skip("uShort",2);var n=e.parseUShort();e.skip("uShort",3);for(var r=0;r<n;r+=1){var a=e.parseUShort(),s=e.parseUShort(),o=e.parseShort();t[a+","+s]=o}return t}function tmt(e){var t={};e.skip("uShort"),e.parseULong()>1&&console.warn("Only the first kern subtable is supported."),e.skip("uLong");var i=255&e.parseUShort();if(e.skip("uShort"),0===i){var n=e.parseUShort();e.skip("uShort",3);for(var r=0;r<n;r+=1){var a=e.parseUShort(),s=e.parseUShort(),o=e.parseShort();t[a+","+s]=o}}return t}function nmt(e,t){var i=new wn.Parser(e,t),n=i.parseUShort();if(0===n)return emt(i);if(1===n)return tmt(i);throw new Error("Unsupported kern table version ("+n+").")}var rmt={parse:nmt};function imt(e,t,i,n){for(var r=new wn.Parser(e,t),a=n?r.parseUShort:r.parseULong,s=[],o=0;o<i+1;o+=1){var l=a.call(r);n&&(l*=2),s.push(l)}return s}var smt={parse:imt};function $me(e,t){for(var i=[],n=12,r=0;r<t;r+=1){var a=wn.getTag(e,n),s=wn.getULong(e,n+4),o=wn.getULong(e,n+8),l=wn.getULong(e,n+12);i.push({tag:a,checksum:s,offset:o,length:l,compression:!1}),n+=16}return i}function amt(e,t){for(var i=[],n=44,r=0;r<t;r+=1){var a,s=wn.getTag(e,n),o=wn.getULong(e,n+4),l=wn.getULong(e,n+8),h=wn.getULong(e,n+12);a=l<h&&"WOFF",i.push({tag:s,offset:o,compression:a,compressedLength:l,length:h}),n+=20}return i}function ms(e,t){if("WOFF"===t.compression){var i=new Uint8Array(e.buffer,t.offset+2,t.compressedLength-2),n=new Uint8Array(t.length);if(Qut(i,n),n.byteLength!==t.length)throw new Error("Decompression error: "+t.tag+" decompressed length doesn't match recorded length");return{data:new DataView(n.buffer,0),offset:0}}return{data:e,offset:t.offset}}function zge(e,t){t=null==t?{}:t;var i,n,r,a=new Ci({empty:!0}),s=new DataView(e,0),o=[],l=wn.getTag(s,0);if(l===String.fromCharCode(0,1,0,0)||"true"===l||"typ1"===l)a.outlinesFormat="truetype",o=$me(s,r=wn.getUShort(s,4));else if("OTTO"===l)a.outlinesFormat="cff",o=$me(s,r=wn.getUShort(s,4));else{if("wOFF"!==l)throw new Error("Unsupported OpenType signature "+l);var h=wn.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=amt(s,r=wn.getUShort(s,12))}for(var c,u,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=ms(s,S),a.tables.cmap=ige.parse(M.data,M.offset),a.encoding=new age(a.tables.cmap);break;case"cvt ":M=ms(s,S),_=new wn.Parser(M.data,M.offset),a.tables.cvt=_.parseShortList(S.length/2);break;case"fvar":u=S;break;case"fpgm":M=ms(s,S),_=new wn.Parser(M.data,M.offset),a.tables.fpgm=_.parseByteList(S.length);break;case"head":M=ms(s,S),a.tables.head=gge.parse(M.data,M.offset),a.unitsPerEm=a.tables.head.unitsPerEm,i=a.tables.head.indexToLocFormat;break;case"hhea":M=ms(s,S),a.tables.hhea=vge.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=ms(s,S),n=xge.parse(M.data,M.offset);break;case"maxp":M=ms(s,S),a.tables.maxp=bge.parse(M.data,M.offset),a.numGlyphs=a.tables.maxp.numGlyphs;break;case"name":x=S;break;case"OS/2":M=ms(s,S),a.tables.os2=h6.parse(M.data,M.offset);break;case"post":M=ms(s,S),a.tables.post=Mge.parse(M.data,M.offset),a.glyphNames=new v6(a.tables.post);break;case"prep":M=ms(s,S),_=new wn.Parser(M.data,M.offset),a.tables.prep=_.parseByteList(S.length);break;case"glyf":d=S;break;case"loca":y=S;break;case"CFF ":c=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=ms(s,x);if(a.tables.name=Sge.parse(E.data,E.offset,n),a.names=a.tables.name,d&&y){var T=0===i,A=ms(s,y),C=smt.parse(A.data,A.offset,a.numGlyphs,T),P=ms(s,d);a.glyphs=Dge.parse(P.data,P.offset,C,a,t)}else{if(!c)throw new Error("Font doesn't contain TrueType or CFF outlines.");var R=ms(s,c);mge.parse(R.data,R.offset,a,t)}var D=ms(s,g);if(yge.parse(a,D.data,D.offset,a.numberOfHMetrics,a.numGlyphs,a.glyphs,t),bht(a,t),v){var L=ms(s,v);a.kerningPairs=rmt.parse(L.data,L.offset)}else a.kerningPairs={};if(p){var I=ms(s,p);a.tables.gdef=$pt.parse(I.data,I.offset)}if(f){var O=ms(s,f);a.tables.gpos=Qpt.parse(O.data,O.offset),a.position.init()}if(m){var k=ms(s,m);a.tables.gsub=Rge.parse(k.data,k.offset)}if(u){var N=ms(s,u);a.tables.fvar=zpt.parse(N.data,N.offset,a.names)}if(b){var U=ms(s,b);a.tables.meta=Age.parse(U.data,U.offset),a.metas=a.tables.meta}return a}var Vf=class extends xy{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 i;let n=null==(i=Gge(e,t,0,0,this.data))?void 0:i.path;return n||this.addUnsupportedChar(e),n}getNotFoundTextShape(e){var t;return null==(t=Gge("?",e,0,0,this.data))?void 0:t.path}parseTTF(e){function t(e){let t,i=[];e.forEach((function(e){"m"===e.type.toLowerCase()?(t=[e],i.push(t)):"z"!==e.type.toLowerCase()&&t.push(e)}));let n=[];return i.forEach((function(e){let t={type:"m",x:e[e.length-1].x,y:e[e.length-1].y};n.push(t);for(let i=e.length-1;i>0;i--){let t=e[i],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[i-1].x,r.y=e[i-1].y,n.push(r)}})),n}return function(e,i){let n=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],c=e.glyphs.glyphs[s[h]];if(void 0!==h){let e={ha:n(c.advanceWidth*a),x_min:n(c.xMin*a),x_max:n(c.xMax*a),o:""};i&&(c.path.commands=t(c.path.commands)),c.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+=n(t.x*a)+" "+n(t.y*a)+" "),void 0!==t.x1&&void 0!==t.y1&&(e.o+=n(t.x1*a)+" "+n(t.y1*a)+" "),void 0!==t.x2&&void 0!==t.y2&&(e.o+=n(t.x2*a)+" "+n(t.y2*a)+" ")})),r[String.fromCodePoint(c.unicode)]=e}}return{glyphs:r,familyName:e.getEnglishName("fullName"),ascender:n(e.ascender*a),descender:n(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}}(zge(e),this.reversed)}};function Gge(e,t,i,n,r){let a=r.glyphs[e];if(!a)return;let s,o,l,h,c,u,d,p,f=new Cm;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+i,o=e[r++]*t+n,f.moveTo(s,o);break;case"l":s=e[r++]*t+i,o=e[r++]*t+n,f.lineTo(s,o);break;case"q":l=e[r++]*t+i,h=e[r++]*t+n,c=e[r++]*t+i,u=e[r++]*t+n,f.quadraticCurveTo(c,u,l,h);break;case"b":l=e[r++]*t+i,h=e[r++]*t+n,c=e[r++]*t+i,u=e[r++]*t+n,d=e[r++]*t+i,p=e[r++]*t+n,f.bezierCurveTo(c,u,d,p,l,h)}}return{offsetX:a.ha*t,path:f}}var jC={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]]]},omt=!1,lmt=new xe,ld=class extends _s{constructor(e,t){super(),this.width=0,this.bounds=new Mi,this.lastPoint=e,this.polylines=t,this.width=this.calcWidth(t)}offset(e){let t=[];for(let i=0;i<this.polylines.length;i++){let n=this.polylines[i],r=[];for(let t=0;t<n.length;t++){let i=n[t];r.push(i.clone().add(e))}t.push(r)}return new ld(this.lastPoint,t)}transform(e){let t=[];for(let i=0;i<this.polylines.length;i++){let n=this.polylines[i],r=[];for(let t=0;t<n.length;t++){let i=n[t];r.push(i.clone().applyMatrix3(e))}t.push(r)}return new ld(this.lastPoint.clone().applyMatrix3(e),t)}calcWidth(e){let t=this.bounds;for(let n=0;n<e.length;n++){let i=e[n];for(let e=0;e<i.length;e++){let n=i[e];t.expandByPoint(n)}}let i=t.min.x||0;return(t.max.x||0)-i}toThreeGeometry(){let e=this.polylines;if(omt&&e.length>0){let t=this.bounds.min,i=this.bounds.getSize(lmt),n=new xe(t.x,t.y),r=new xe(t.x+i.width,t.y),a=new xe(t.x+i.width,t.y+i.height),s=new xe(t.x,t.y+i.height);e.push([n,r],[r,a],[a,s],[s,n])}let t=[],i=[],n=0,r=new Dt;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||i.push(n,n+1),n++}}return r.setAttribute("position",new Bt(t,3)),r.setIndex(i),r}},XC;function cmt(){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),i=0;for(let[r,a,s,o]of e)for(let e=s;e<=o;e++)if(127!==e)for(let n=r;n<=a;n++)t[i++]=e<<8|n;let n=new TextDecoder("gbk").decode(t);for(XC=new Uint16Array(65536),i=0;i<n.length;i++)XC[n.charCodeAt(i)]=t[i]}function qge(e){XC||cmt();let t=new Uint8Array(2*e.length),i=0;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);if(r<128)t[i++]=r;else{let e=XC[r];t[i++]=255&e,t[i++]=e>>8}}return t.subarray(0,i)}var umt="\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",Wge="\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 jge(e){return umt.charAt(Wge.indexOf(e.charAt(0)))}var KVt=new RegExp("[\u4e00-\u9fa5]+");function Xge(e){return Wge.includes(e)}var Wr=class{static GetBytes(e){switch(typeof e){case"string":{let t=new Uint16Array(e.length);for(let i=0;i<e.length;i++)t[i]=e.charCodeAt(i);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(Wr.GetBytes(e[a]));let i=0;for(let e=0;e<t.length;e++)i+=t[e].length;let n=new Uint8Array(i),r=0;for(let e=0;e<t.length;e++)for(let i=0;i<t[e].length;i++)n[r++]=t[e][i];return n}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 i=0;for(let e=0;e<t.length;e++)i+=t[e].length;let n=new Uint8Array(i),r=0;for(let e=0;e<t.length;e++)for(let i=0;i<t[e].length;i++)n[r++]=t[e][i];return n}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 i=e.slice(t,t+2);return new Int16Array(i.buffer,0,1)[0]}static ToInt32(e,t){t=t||0;let i=e.slice(t,t+4);return new Int32Array(i.buffer,0,1)[0]}static ToUInt16(e,t){t=t||0;let i=e.slice(t,t+2);return new Uint16Array(i.buffer,0,1)[0]}static ToUInt32(e,t){t=t||0;let i=e.slice(t,t+4);return new Uint32Array(i.buffer,0,1)[0]}static ToChar(e,t){t=t||0;let i=e.slice(t,t+2);return String.fromCharCode(new Uint16Array(i.buffer,0,1)[0])}static ToAscii(e,t){return t=t||0,String.fromCharCode(e[t])}static ToAsciiString(e,t,i){t=t||0,(i=i||e.length)+t>e.length&&(i-=t);let n="";for(let r=0;r<i;r++)n+=String.fromCharCode(e[t+r]||0);return n}static ToUTF16String(e,t,i){t=t||0,(i=i||e.length)+t>e.length&&(i-=t);let n=new Uint8Array(i);for(let r=0;r<i;r++)n[r]=e[t+r]||0;return String.fromCharCode.apply(null,Array.from(new Uint16Array(n.buffer,0,i/2)))}static ToFloat32(e,t){t=t||0;let i=e.slice(t,t+4);return new Float32Array(i.buffer,0,1)[0]}static ToFloat64(e,t){t=t||0;let i=e.slice(t,t+8);return new Float64Array(i.buffer,0,1)[0]}},zf=class{static parserHeader(e,t){let i="",n=!1,r=0;for(;;){let a=e.readInt8(),s=String.fromCharCode(a);if(n)s===t[r]?r++:(n=!1,r=0);else{if(s===t[r]){n=!0,r++;continue}i+=s}if(n&&r===t.length)break}return i}static getCode(e){let t=qge(e);return t.length<2?t[0]:t.length<4?Wr.ToUInt16(t,0):Wr.ToUInt32(t,0)}static parserCode(e,t,i){let n=new xe,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(n.clone());break;case 2:o=!1,a.length>1?(r.push(a.slice()),a=[]):n.set(0,0);break;case 3:l++,i/=t[l];break;case 4:l++,i*=t[l];break;case 5:if(4===s.length)throw"The position stack is only four locations deep";s.push(n);break;case 6:n=s.pop(),a.length>1&&(r.push(a.slice()),a=[]),o&&a.push(n.clone());break;case 7:{let s,o=0,h=i*e.baseUp,c=n.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=Wr.ToUInt16(new Uint8Array([t[l++],t[l++]]),0),c.x=t[l++]*i,c.y=t[l++]*i,h=t[l]*i);break;case 2:l+=2,o=Wr.ToUInt16(new Uint8Array([t[l-1],t[l]]),0)}0!==o&&(s=e.getGraphicDataByCodeWithOffset(o,h,c),s&&(r.push(...s.polylines.slice()),n=s.lastPoint.clone()))}break;case 8:{let e=new xe;e.x=Wr.byteTosbyte(t[++l]),e.y=Wr.byteTosbyte(t[++l]),n.add(e.multiplyScalar(i)),o&&a.push(n.clone())}break;case 9:for(;;){let e=new xe;if(e.x=Wr.byteTosbyte(t[++l]),e.y=Wr.byteTosbyte(t[++l]),0==e.x&&0==e.y)break;n.add(e.multiplyScalar(i)),o&&a.push(n.clone())}break;case 10:{let e=t[++l]*i,r=Wr.byteTosbyte(t[++l]),s=(112&r)>>4,h=7&r;0==h&&(h=8);let c=Math.PI/4,u=c*h,d=zf.CIRCLE_SPAN;r<0&&(d=-d,u=-u);let p=c*s,f=p+u,m=n.clone().sub(new xe(Math.cos(p)*e,Math.sin(p)*e));if(n=m.clone().add(new xe(Math.cos(f)*e,Math.sin(f)*e)),o){let t=p,i=!0;for(;i&&(t+=d,r>=0&&t<f||r<0&&t>f);)a.push(m.clone().add(new xe(e*Math.cos(t),e*Math.sin(t))));a.push(n.clone())}}break;case 11:{let e=t[++l],r=t[++l],s=(255*t[++l]+t[++l])*i,h=Wr.byteTosbyte(t[++l]),c=(112&h)>>4,u=7&h;0==u&&(u=8),0!=r&&u--;let d=Math.PI/4,p=d*u,f=zf.CIRCLE_SPAN,m=1;h<0&&(f=-f,p=-p,m=-1);let g=d*c,v=g+p;g+=d*e/256*m,v+=d*r/256*m;let y=n.clone().sub(new xe(s*Math.cos(g),s*Math.sin(g)));if(n=y.clone().add(new xe(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 xe(s*Math.cos(e),s*Math.sin(e))));a.push(n.clone())}}break;case 12:{let e=new xe;e.x=Wr.byteTosbyte(t[++l])*i,e.y=Wr.byteTosbyte(t[++l])*i;let r=Wr.byteTosbyte(t[++l]);r<-127&&(r=-127),o&&(0==r?a.push(n.clone().add(e)):a.push(zf.generateArcPoints(n,e,r/127))),n.add(e)}break;case 13:for(;;){let e=new xe;if(e.x=Wr.byteTosbyte(t[++l])*i,e.y=Wr.byteTosbyte(t[++l])*i,0==e.x&&0==e.y)break;let r=Wr.byteTosbyte(t[++l]);r<-127&&(r=-127),o&&(0==r?a.push(n.clone().add(e)):a.push(zf.generateArcPoints(n.clone(),e,r/127))),n.add(e)}break;case 14:l=zf.skipCode(e,t,++l);break;default:if(h>15){let e=(240&h)>>4,t=15&h,r=new xe;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}n.add(r.multiplyScalar(e*i)),o&&a.push(n.clone())}}}return new ld(n,r)}static skipCode(e,t,i){switch(t[i]){case 0:case 1:case 2:case 5:case 6:case 14:default:break;case 3:case 4:i++;break;case 7:switch(e.fontType){case 0:i++;break;case 1:0==t[++i]&&(i+=6);break;case 2:i+=2}break;case 8:case 10:i+=2;break;case 9:for(;;){let e=t[++i],n=t[++i];if(0==e&&0==n)break}break;case 11:i+=5;break;case 12:i+=3;break;case 13:for(;;){let e=t[++i],n=t[++i];if(0==e&&0==n)break;t[++i]}}return i}static generateArcPoints(e,t,i){let n=e.clone().add(t),r=i<0;i=Math.abs(i);let a=t.length()/2,s=a*i,o=2*Math.atan(1/i),l=new xe(t.y,-t.x);l.normalize(),l.multiplyScalar(s);let h=Math.abs(a/Math.sin(o/2)),c=e.add(t.divideScalar(2));!1!==r?c.add(l):c.sub(l);let u=e.sub(c),d=n.sub(c),p=Math.atan2(u.y,u.x),f=Math.atan2(d.y,d.x),m=zf.CIRCLE_SPAN;r?(m=-m,p<f&&(p+=2*Math.PI)):p>f&&(p-=2*Math.PI);let g=p;for(;;){if(g+=m,!r&&g<f||r&&g>f)return c.add(new xe(h*Math.cos(g),h*Math.sin(g)));break}return n}},Nc=zf;Nc.FILE_STOP_FLAG=["\r","\n","\x1a"],Nc.CIRCLE_SPAN=Math.PI/18;var Yge=new Ln,YC=class extends xy{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 Df(t),i=Nc.parserHeader(e,Nc.FILE_STOP_FLAG).split(" ");switch(i[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=i[0],this.fileVersion=i[2]}else this.setFontFile(t)}generateShapes(e,t){let i=[],n=0;for(let r=0;r<e.length;r++){let a=e[r];if(" "===a){n+=t;continue}let s=this.getCharShape(a,t);s?(i.push(s.offset(new xe(n,0))),n+=s.width):(n+=t,this.addUnsupportedChar(a))}return i}getCharShape(e,t){Xge(e)&&(e=jge(e));let i=Nc.getCode(e);0===i&&(i=e.charCodeAt(0));let n=this.getGraphicDataByCode(i,t);return n&&0===n.polylines.length&&(n.width=t),n}getGraphicDataByCode(e,t){let i=`${e}_${t}`;if(this.textShapesCache.has(i))return this.textShapesCache.get(i);if(0===e)return;let n,r=this.data;if(!this.graphicData.has(e))if(r[e]){let t=r[e],i=YC.DEFAULT_SIZE/this.baseUp;n=Nc.parserCode(this,t,i),this.graphicData.set(e,n)}else if(jC[e]){let t=[];for(let i=0;i<jC[e].length;i++)t.push(jC[e][i].map((e=>new xe(e[0],e[1]))));n=new ld(new xe,t),this.graphicData.set(e,n)}if(this.graphicData.has(e)){let i=t/YC.DEFAULT_SIZE;Yge.identity().scale(i,i),n=this.graphicData.get(e).transform(Yge)}return n}getGraphicDataByCodeWithOffset(e,t,i){var n;return null==(n=this.getGraphicDataByCode(e,t))?void 0:n.offset(i)}parseBigFont(e){Wr.ToInt16(e.readBytes(2),0);let t=Wr.ToInt16(e.readBytes(2),0),i=Wr.ToInt16(e.readBytes(2),0);for(let o=0;o<i;o++)e.readBytes(2),e.readBytes(2);let n=[];for(let o=0;o<t;o++){let t=e.readBytes(8),i=Wr.ToUInt16(new Uint8Array([t[1],t[0]]),0),r=Wr.ToUInt16(t,2),a=Wr.ToUInt32(t,4);0===i&&0===r&&0===a||n.push({code:i,length:r,offset:a})}let r={};for(let o of n)e.setPosition(o.offset),r[o.code]=e.readBytes(o.length);let a=r[0],s=(this.info=dmt(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=Wr.ToInt32(e.readBytes(4),0),i=Wr.ToInt16(e.readBytes(2),0),n=e.readBytes(i),r=(this.info=(new TextDecoder).decode(n)).indexOf("\0");this.baseUp=n[++r],this.baseDown=n[++r],this.orientation=n[++r],this.isUniCode=0==n[++r],this.isEmbedded=0==n[++r];let a={};for(let s=0;s<t-1;s++){let t=Wr.ToUInt16(e.readBytes(2),0),i=Wr.ToUInt16(e.readBytes(2),0);a[t]=e.readBytes(i)}this.data=a}parseShapeFont(e){e.readBytes(2),e.readBytes(2);let t=Wr.ToInt16(e.readBytes(2),0),i=[];for(let s=0;s<t;s++){let t=Wr.ToUInt16(e.readBytes(2),0),n=Wr.ToUInt16(e.readBytes(2),0);i.push({code:t,length:n})}let n={};for(let s of i)n[s.code]=e.readBytes(s.length);let r=n[0],a=(this.info=(new TextDecoder).decode(r)).indexOf("\0");this.baseUp=r[++a],this.baseDown=r[++a],this.orientation=r[++a],this.data=n}getNotFoundTextShape(e){let t=0;return 1===this.fontType&&(t=Nc.getCode("\uff1f")),2===this.fontType&&(t=Nc.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()}},cd=YC;function dmt(e){let t,i,n,r,a;t="";let s=e.length;for(i=0;i<s;)switch(n=e[i++],n>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:t+=String.fromCharCode(n);break;case 12:case 13:r=e[i++],t+=String.fromCharCode((31&n)<<6|63&r);break;case 14:r=e[i++],a=e[i++],t+=String.fromCharCode((15&n)<<12|(63&r)<<6|(63&a)<<0)}return t}cd.DEFAULT_SIZE=12;var Ul=class{constructor(){this.fontMap=new Map,this.unsupportedChars={},this.missingFonts={},this.loader=new Kr}loadFonts(e){return ft(this,null,(function*(){if(e=Array.isArray(e)?e:[e],this.fileNames=e.map((e=>Ul.getFileName(e.toLowerCase()))),!(yield this.checkAllFontsLoaded(e))){for(let t=0;t<e.length;t++){let i,n=e[t],r=Ul.getFileName(n).toLowerCase();if(Ul.isJsonFile(n)){this.loader.setResponseType("json");let e=yield this.loader.loadAsync(n);i=new Vf(r,e)}else if(Ul.isShxFile(n)){this.loader.setResponseType("arraybuffer");let e=yield this.loader.loadAsync(n);i=new cd(r,e)}else if(Ul.isTtfFile(n)){this.loader.setResponseType("arraybuffer");let e=yield this.loader.loadAsync(n);i=new Vf(r,e)}i&&(i.order=t+1,this.fontMap.set(r,i))}Ul.enableFontCache&&Fn.isBrowser&&(this.fontMap.forEach((e=>ft(this,null,(function*(){yield e.setFontDataToIndexedDb()})))),this.releaseFontData())}}))}getTextShape(e,t,i){if(0===this.fontMap.size)return void se.warn("[FontManager] no font loaded.");let n=this.fontMap.get(t.toLowerCase());return n||(n=this.fontMap.get(this.fontMap.keys().next().value),this.missingFonts[t]||(this.missingFonts[t]=0),this.missingFonts[t]++),null==n?void 0:n.generateShapes(e,i)}getCharShape(e,t,i){if(0===this.fontMap.size)return void se.warn("[FontManager] no font loaded.");null==t&&(t="");let n=this.fontMap.get(t.toLowerCase());if(!n){this.missingFonts[t]||(this.missingFonts[t]=0),this.missingFonts[t]++;for(let[t,r]of this.fontMap)if(r.getCharShape(e,i)){n=r;break}}let r=null==n?void 0:n.getCharShape(e,i);if(r){if(n instanceof cd)return r.toThreeGeometry();if(n instanceof Vf)return new AC(e,{font:n,height:0,size:i||12,curveSegments:3,bevelSegments:3})}}getNotFoundTextShape(e){let t,i;for(let[n,r]of this.fontMap){let n=r.getNotFoundTextShape(e);if(n){t=n,i=r;break}}return i instanceof cd?t.toThreeGeometry():i instanceof Vf?new Qs(t.toShapes(!1),{curveSegments:3,bevelSegments:3}):void 0}checkAllFontsLoaded(e){return ft(this,null,(function*(){if(!Fn.isBrowser)return!1;let t=!1;for(let i=0;i<e.length;i++){let n=e[i],r=Ul.getFileName(n.toLowerCase()),a=yield sd.instance().query(r);if(!a){t=!1;break}if(t=!0,void 0!==a.codes){t=!1;break}}return t}))}getFontFromIndexeddb(){return ft(this,null,(function*(){if(0!==this.fontMap.size)return;let e=(yield sd.instance().queryAll()).sort(((e,t)=>e.order-t.order));for(let t=0;t<e.length;t++){let i,n=e[t],{fileName:r,fontType:a}=n;this.fileNames&&!this.fileNames.includes(r)||(i=a?new cd(r,n):new Vf(r,n),this.fontMap.set(r,i))}se.debug("[FontManager] Loaded font data from cache.")}))}isShxFont(e){if(0===this.fontMap.size)return void se.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 cd}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"===Ul.getExtension(e)}static isTtfFile(e){return["WOFF","OTF","TTF"].includes(Ul.getExtension(e).toUpperCase())}static isJsonFile(e){return"json"===Ul.getExtension(e)}static getFileName(e){let t=e.lastIndexOf("/");return e.substring(t+1)}static getExtension(e){return e.substring(e.lastIndexOf(".")+1)}},ud=Ul;ud.enableFontCache=!0;var Bc=new D(1,0,0),w6=new D(0,1,0),Sy=new D(0,0,1),$ge=new D(0,0,0),Wf=16777215,fmt="CONTINUOUS",$C=new bi({color:Wf}),ya=new Gn({color:Wf}),My=new ln({color:Wf}),Zge=(new Dt).setFromPoints([new D]),Kge=new et,Gf=new et,js=new et,Zn=new D,_i=new D,Ry=new D,u_=new xe,xo=new dr,ZC=new on,qf=new Nt,Jge=new bi({color:65280,size:5,depthTest:!1}),Qge=new bi({color:65280,depthTest:!1}),e0e=new bi({color:65280,depthTest:!1}),pmt=e=>void 0!==e.viewDirectionFromTarget,mmt=e=>{if(e){let t=e.match(/data:([a-zA-Z0-9]+\/[a-zA-Z0-9-.+]+).*,.*/);if(t&&t.length>0){let i=t[1],n=e.replace("data:"+i+";","").split(",");if(n&&2===n.length&&"base64"===n[0]){let e=n[1];return Vpe.decode(e)}}}return null},t0e=(e,t)=>{let i=new xe(e.x,e.y),n=new xe(t.x,t.y);return n.sub(i),n.normalize(),n.y<0?-Math.acos(n.x):Math.acos(n.x)},n0e=(e,t,i)=>({x:e.x+t*Math.cos(i),y:e.y+t*Math.sin(i)}),gmt=(e,t,i,n)=>{let r=e?new xe(e.x,e.y):new xe(0,0),a=t?new xe(t.x,t.y):new xe(1,0);i=i||1;let s=4*Math.atan(i),o=r.distanceTo(a)/2/Math.sin(s/2),l=n0e(e,o,t0e(r,a)+(Math.PI/2-s/2));n=n||Math.max(Math.abs(Math.ceil(s/(Math.PI/18))),6);let h=t0e(l,r),c=s/n,u=[];u.push(new D(r.x,r.y,0));for(let d=1;d<=n-1;d++){let e=n0e(l,Math.abs(o),h+c*d);u.push(new D(e.x,e.y,0))}return u},vmt=(e,t,i,n=2*e.length,r)=>{let a=[],s=e.map((e=>[e.x,e.y]));for(let o=0;o<1;o+=1/n){let e=q5(o,t,s,i,r);a.push(new D(e[0],e[1],0))}return a},S6=(e,t=!1)=>{let i=[],n=e.length;for(let r=0;r<n;r++){let a=e[r];if(a.bulge&&(r!==n-1||t)){let t=a.bulge,s=r+1<n?e[r+1]:i[0],o=gmt(a,s,t);i.push(...o)}else i.push(new D(a.x,a.y,0))}return i},ymt=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},xmt=e=>{let t=[],i=[];e.forEach((e=>{e.polyfaceMeshVertex&&(e.threeDPolylineMesh?t.push(new D(e.x,e.y,e.z)):i.push(ymt(e)))}));let n=[];for(let r=0;r<i.length;r++){let e=i[r];if(0===e.length)continue;let a=[],s=!0;for(let i=0;i<e.length;i++){let n=e[i]-1;if(n>=t.length||n<0){s=!1;break}a.push(t[n])}!s||0===a.length||(a.push(a[0]),n.push(a))}return n},Kn=class extends Er{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 i=e;t[e.ownerHandle].push(i)}},Kn.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))),this.pointsMaterials[Wf]=$C,this.lineBasicMaterials[Wf]=ya,this.meshBasicMaterials[Wf]=My}setFont(e){this.font=e}download(e,t){return ft(this,null,(function*(){let i=mmt(e);if(!i){let n=Date.now(),r=new Kr(this.manager);r.setResponseType("arraybuffer"),r.setPath(this.path),i=yield r.loadAsync(e,t),se.info(`[DxfLoader] ${e} dxf file downloaded in ${(Date.now()-n)/1e3}s`)}return i}))}load(e,t,i){return ft(this,null,(function*(){return this.enableLocalCache&&t&&(t=t.trim()).length>0&&(this.dxfDataId=t),this.loadAsync(e,i)}))}loadAsync(e,t){return ft(this,null,(function*(){let i=St.getUpdateSubProgressFunc(0,50,t),n=St.getUpdateSubProgressFunc(50,100,t),r=St.getUpdateSubProgressFunc(10,100,t);if(Fn.isBrowser&&this.enableLocalCache&&this.dxfDataId){let t;try{if(this.timer=Date.now(),t=yield this.getDxfDataFromIndexedDb(this.dxfDataId),t){this.tryFixDxfData(t),se.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){se.warn("[DxfLoader] Failed to parse data from indexedDb",e)}}let a=yield this.parse(e,i);return this.tryFixDxfData(a),yield this.loadEntities(a,n)}))}parse(e,t){return ft(this,null,(function*(){let i=St.getUpdateProgressFunc(t),n=St.getUpdateSubProgressFunc(0,40,t),r=yield this.download(e,n);if(!r)return Promise.reject(`[DxfLoader] Failed to download ${e}`);if(Kn.abortJobs)return Promise.reject("[DxfLoader] Job aborted");this.timer=Date.now(),se.info("[DxfLoader] Start parsing...");let a=new Zm(this.encoding).parseSync(r);if(this.tryFixDxfData(a),i(80),se.info(`[DxfLoader] Parsed in ${(Date.now()-this.timer)/1e3}s, creating entities...`),Kn.abortJobs)return Promise.reject("[DxfLoader] Job aborted");if(a&&Fn.isBrowser&&this.enableLocalCache&&this.dxfDataId){let t=Date.now();try{yield this.setDxfDataToIndexedDb(this.dxfDataId,a),se.info(`[DxfLoader] Saved to indexedDb in ${(Date.now()-t)/1e3}s`)}catch(e){se.warn(`[DxfLoader] Failed to save '${this.dxfDataId}' to indexedDb!`,e)}}return i(100),a}))}parseHeader(e){if(!e)return void se.error("[DxfLoader]: Invalid header!");this.header=e;let t=e.$ACADVER.toString();"AC1032"!==t&&se.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||(se.warn("[DxfLoader] No objects found, Will add one."),e.objects={}),e.objects.LAYOUT||(se.warn("[DxfLoader] No layout defined! Will add a default 'Model' layout!"),e.objects.LAYOUT=[{layoutName:Kn.MODEL_LAYOUT_NAME}]),e.tables||(se.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 ft(this,null,(function*(){let i=Date.now();this.parseHeader(e.header),this.enableRenderOrder&&(this.initRenderOrderInfo(e),this.enableMerge=!1),this.getFontFilesFromDxf(e);let n=0,r=e.entities.length;this.entityCount=r,Object.keys(e.blocks).forEach((t=>{var i;this.entityCount+=(null==(i=e.blocks[t].entities)?void 0:i.length)||0}));let a=St.getUpdateProgressFuncForLoop(r,t),s={},o=e=>{let t=e.userData.layerName,i=s[t];i||(i=[],s[t]=i),i.push(e)},l={},h={},c=new bn;for(let t=0;t<r&&!Kn.abortJobs;t++){let i=e.entities[t];this.addViewport(i,l);let r=this.drawEntity(i,e);if(r||(yield a(t)),!r)continue;let s=this.getLayout(e,i).layoutName,u=c.children.find((e=>e.name===s));if(u||(u=new bn,u.name=s,u.userData.isLayoutLevelObject=!0,c.add(u)),r.traverse((e=>{e.userData.isSnapObject&&(this.layoutsSnapObjectsMap[s]||(this.layoutsSnapObjectsMap[s]=[]),this.layoutsSnapObjectsMap[s].push(e))})),this.enableMerge){Ic.merge(r,!1),h[s]||(h[s]={object:u,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&&(u.add(r),r.traverse((e=>{e.geometry&&o(e)})))}else u.add(r),r.traverse((e=>{e.geometry&&o(e)}));n++,yield a(t)}e.objects.LAYOUT.forEach((t=>{let i=t,n=i.layoutName;if(this.ignorePaperSpace&&n!==Kn.MODEL_LAYOUT_NAME)return;let r=i.associatedBlockName,a=e.blocks[r];a&&this.drawLayout(a,e,i,c,s,l)})),se.debug(`[DxfLoader] Drew entities in ${(Date.now()-i)/1e3}s`);for(let t in this.layoutsSnapObjectsMap){let i=c.children.find((e=>e.name===t)),n=new bn;n.name=Kn.SNAP_GROUP_NAME,n.userData.isSnapGroup=!0,i.add(n);let r=this.layoutsSnapObjectsMap[t];for(let t=0;t<r.length;t++){let i=r[t],a=i.userData.layerName;!1===this.getLayerVisible(e,a)&&i.layers.disable(11),Kn.SHOW_SNAP_OBJECT&&(i.layers.enableAll(),i.material instanceof bi?i.material=Jge:i.material instanceof Gn?i.material=Qge:i.material instanceof ln&&(i.material=e0e));let s=i,o=js.identity();for(;s&&!0!==s.userData.isLayoutLevelObject;)o.premultiply(s.matrix),s=s.parent;i.matrix.copy(o),n.add(i)}}if(this.enableMerge)for(let e in h){let t=h[e],i=t.object;for(let e in t.layerObjects){let n=t.layerObjects[e],r=Ic.deepMerge(n,void 0,!1,!1,!0),a=r.added,s=r.removed;if(s.length!==n.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=n.length;r<a;r++){let e=n[r];t(e)||(i.add(e),o(e))}}for(let e=0;e<a.length;e++){let t=a[e];i.add(t),o(t)}t.layerObjects[e]=[]}}this.printStatsInfo(),this.enableReleaseData&&(this.releaseCachedData(),this.releaseDxfData(e)),this.enableMerge&&Kn.mergeDxfObjects({root:c,layersAndObjects:s});let u=c.convertToThreejsObject();c.clear(),s={};let d={};e.objects.LAYOUT.forEach((e=>{let t=e;d[t.layoutName]=t}));let p={};u.children.forEach((t=>{if(Hn.setSharedVariablesOfObject(t),!t.userData.isLayoutLevelObject)return;let i,n=t.name;if(n!==Kn.MODEL_LAYOUT_NAME){let e=d[n];e.directAssociatedLeafObjectSet||(e.directAssociatedLeafObjectSet=new Set),i=e.directAssociatedLeafObjectSet}t.traverse((t=>{if(Hn.setSharedVariablesOfObject(t),t.userData.isSnapGroup&&(t.visible=Kn.SHOW_SNAP_OBJECT),t.geometry){let n=t.userData.layerName;!1===this.getLayerVisible(e,n)&&(t.visible=!1,t.userData.layerVisible=!1),(e=>{let t=e.userData.layerName,i=p[t];i||(i=[],p[t]=i),i.push(e)})(t),i&&i.add(t)}}))})),se.info(`[DxfLoader] loadEntities() done in ${(Date.now()-i)/1e3}s`);let f=Ii(Tr({},e),{threejsObject:u,layersAndThreejsObjects:p,loadedEntityCount:n,layoutViewportsMap:l});return Promise.resolve(f)}))}getFontFilesFromDxf(e){let t=new Set;if(e.tables.style.styles){let i=e.tables.style.styles;for(let e in i){let n=i[e],r=n.fontFile,a=n.bigFontFile;r&&t.add(r),a&&t.add(a)}}se.info(`[DxfLoader] These are fonts used by dxf: ${Array.from(t).join()}`)}loadEntitiesForCompare(e,t,i,n=!0,r){return ft(this,null,(function*(){let a=e.entities.length,s=t.entities.length,o=()=>ft(this,null,(function*(){var o;let l=this.compareContext,h=l.isTheFirstFile,c=h?e:t,u=new bn,d=h?a:s,p=c.entities.length;this.entityCount=p,Object.keys(c.blocks).forEach((e=>{var t;this.entityCount+=(null==(t=c.blocks[e].entities)?void 0:t.length)||0}));let f=Math.round(Math.pow(d,.5)),m=Date.now(),g=e=>ft(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 i=500,n=Date.now();(n-m>i||e===d-1)&&(yield St.sleep(0),m=n)}}));this.parseHeader(c.header);let v={};for(let e=0;e<d;e++){if(Kn.abortJobs)return;let t=c.entities[e],i=this.getLayout(c,t);if(i.layoutName!==Kn.MODEL_LAYOUT_NAME){yield g(e);continue}let n=this.drawEntity(t,c);if(!n){yield g(e);continue}let r=u.children.find((e=>e.name===Kn.MODEL_LAYOUT_NAME));r||(r=new bn,r.name=Kn.MODEL_LAYOUT_NAME,r.userData.isLayoutLevelObject=!0,u.add(r)),r.add(n),n.traverse((e=>{if(e.geometry){let t=e.userData.layerName,r=this.getLayerVisible(c,t);e.userData.isSnapObject&&(this.layoutsSnapObjectsMap[i.layoutName]||(this.layoutsSnapObjectsMap[i.layoutName]=[]),this.layoutsSnapObjectsMap[i.layoutName].push(e),!1===r&&n.layers.disable(11));let a=v[t];a||(a=[],v[t]=a),a.push(e)}})),yield g(e)}n&&h&&(l.preservedHandles||(l.preservedHandles=new Set));for(let e in i){let t=i[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 n=this.entityThreejsCache&&this.entityThreejsCache[t.handle];if(t.parentHandles&&(n=this.entityThreejsCache&&this.entityThreejsCache[t.parentHandles[t.parentHandles.length-1]]),n){if(n.parent&&n.parent.userData.originalType){this.setObjectColorByChange(n,{type:"NoChange"});continue}n=this.setObjectColorByChange(n,t)}if("NoChange"!==t.type&&n){let e=n.parent,i=js.identity();for(;e&&!0!==e.userData.isLayoutLevelObject;)i.premultiply(e.matrix),e=e.parent;qf.makeEmpty();let r=bn.getBox(n,qf);r.applyMatrix4(i),"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=u.children.find((t=>t.name===e)),i=new bn;i.name=Kn.SNAP_GROUP_NAME,t.add(i);let n=this.layoutsSnapObjectsMap[e];for(let e=0;e<n.length;e++){let t=n[e];Kn.SHOW_SNAP_OBJECT&&(t.layers.enableAll(),t.material instanceof bi?t.material=Jge:t.material instanceof Gn?t.material=Qge:t.material instanceof ln&&(t.material=e0e));let r=t,a=js.identity();for(;r&&!0!==r.userData.isLayoutLevelObject;)a.premultiply(r.matrix),r=r.parent;t.matrix.copy(a),i.add(t)}}this.enableMerge&&Kn.mergeDxfObjects({root:u,layersAndObjects:v});let y=u.convertToThreejsObject();u.clear(),v={};let x={};y.children.forEach((e=>{Hn.setSharedVariablesOfObject(e),e.userData.isLayoutLevelObject&&e.traverse((e=>{if(Hn.setSharedVariablesOfObject(e),e.userData.isSnapGroup&&(e.visible=Kn.SHOW_SNAP_OBJECT),e.geometry){let t=e.userData.layerName;!1===this.getLayerVisible(c,t)&&(e.visible=!1,e.userData.layerVisible=!1),(e=>{let t=e.userData.layerName,i=x[t];i||(i=[],x[t]=i),i.push(e)})(e)}}))}));let b=c;b.threejsObject=y,b.layersAndThreejsObjects=x,b.layoutViewportsMap={}})),l=Date.now();this.compareContext={changes:i,isTheFirstFile:!0},St.printMemory("Before loading entities for first dxf"),yield o(),se.info(`[DxfLoader] loadEntities for first dxf in ${(Date.now()-l)/1e3}s`),St.printMemory("After loading entities for first dxf"),this.releaseCachedData(!1),this.releaseDxfData(e),St.printMemory("Before loading entities for second dxf"),l=Date.now(),this.compareContext.isTheFirstFile=!1,yield o(),se.info(`[DxfLoader] loadEntities for second dxf in ${(Date.now()-l)/1e3}s`),this.printStatsInfo();for(let e of Object.values(i))e.box||delete i[e.id];this.compareContext.preservedHandles=void 0,this.enableReleaseData&&(this.releaseCachedData(),this.releaseDxfData(t)),St.printMemory("After loading entities for second dxf")}))}setObjectColorByChange(e,t){let i=(e,t)=>{e.traverse((e=>{if(e.material)if(e.material instanceof Gn)e.material=this.getLineBasicMaterial(t);else if(e.material instanceof ln)e.material=this.getMeshBasicMaterial(t);else if(e.material instanceof bi)e.material=this.getPointsMaterial(t);else if(e.material instanceof cn){let i=e.material.clone();Kn.updateMaterialUniforms(i),i.uniforms.u_color.value.set(t),e.material=i}}))},n=(e=>{var t;let i=ls.ENTITY_COLOR_NO_CHANGE;return"Added"===e.type?i=ls.ENTITY_COLOR_ADDED:"Removed"===e.type?i=ls.ENTITY_COLOR_REMOVED:"Modified"===e.type&&(i=null!=(t=this.compareContext)&&t.isTheFirstFile?ls.ENTITY_COLOR_REMOVED:ls.ENTITY_COLOR_ADDED),i})(t);return e.traverse((r=>{t.parentHandles?r.userData&&r.userData.handle&&r.userData.handle===t.handle&&(i(r,n),e=r):i(r,n)})),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,i,n=!1){if(this.compareContext&&this.compareContext.preservedHandles&&this.compareContext.preservedHandles.has(e.handle)&&Xm.includes(e.type)&&(n=!0),!n&&this.compareContext&&this.compareContext.preservedHandles&&!Xm.includes(e.type)&&!this.compareContext.preservedHandles.has(e.handle)&&(!i||i&&!this.compareContext.preservedHandles.has(i.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,i);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,i);else if("3DFACE"===e.type)r=this.draw3DFace(e);else if("TEXT"===e.type)r=this.drawText(e,t,i);else if("SOLID"===e.type)r=this.drawSolid(e,t,i);else if("POINT"===e.type)r=this.drawPoint(e,t,i);else if("IMAGE"===e.type)r=this.drawImage(e,t,i);else if("INSERT"===e.type)r=this.drawInsert(e,t,n);else if("SPLINE"===e.type)r=this.drawSpline(e,i);else if("MTEXT"===e.type)r=this.drawMText(e,t,i);else if("ELLIPSE"===e.type)r=this.drawEllipse(e,t,i);else if("DIMENSION"===e.type)r=this.drawDimension(e,t);else if("REGION"!==e.type)if("ATTDEF"===e.type)r=this.drawAttDef(e,t,i);else if("ATTRIB"===e.type){if(!i)for(let n=0;n<t.entities.length;n++){let r=t.entities[n];if(e.ownerHandle===r.handle&&(i=r).attributesFollow)break}r=this.drawAttrib(e,t,i)}else"HATCH"===e.type?r=this.drawHatch(e,t,i):"VIEWPORT"===e.type?r=this.drawViewport(e,t,i):"LEADER"===e.type?r=this.drawLeader(e,t,i):"MULTILEADER"===e.type?r=this.drawMLeader(e,t,i):"OLE2FRAME"===e.type&&(r=this.drawOle2frame(e,t));r&&(this.entityThreejsCache[e.handle]=r),this.enableReleaseData&&!this.compareContext&&this.releaseEntity(e)}if(r){let n=this.getLayerName(e,t,i);r.userData.handle=e.handle,"INSERT"!==e.type&&"DIMENSION"!==e.type&&r.traverse((r=>{r.geometry&&(r.userData.layerName=n,this.setMaterial(r,e,t,i))})),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 Xm.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,Xm.includes(e.type)||(this.statsInfo.unsupportedEntity[e.handle]?this.statsInfo.unsupportedEntity[e.handle]++:this.statsInfo.unsupportedEntity[e.handle]=1)),r}drawEllipse(e,t,i){if(!e.majorAxisEndPoint||!e.center||void 0===e.axisRatio||void 0===e.startAngle||void 0===e.endAngle)return;let n=e.startAngle,r=e.endAngle;if(e.extrusionDirection&&e.extrusionDirection.z<0&&(n=2*Math.PI-e.endAngle,r=2*Math.PI-e.startAngle),Zt.areNumbersEqual(n,r,1e-5))return void se.warn("[DxfLoader] Ellipse entity (handle '%s') contains the same start and end angle, ignored!",e.handle);let a=r-n;for(;a>2*Math.PI;)a-=2*Math.PI;Math.abs(a)<=1e-5&&(r=Zt.floorNumber(n+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 Kh(e.center.x,e.center.y,s,o,n,r,!1,l),c=1,u=i;null!=u&&u.xScale&&null!=u&&u.yScale&&(c=Math.max(Math.abs(u.xScale),Math.abs(u.yScale)));let d=this.getDivision(n,r,Math.max(s,o)*c),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 se.warn("[DxfLoader] Ellipse entity (handle '%s') contains less than 2 points, ignored!",e.handle);let g=new D,v=!1;this.enableRTC&&(v=Qt.checkAndRebasePositionsOnRTC(f,g));let y=(new Dt).setFromPoints(f),x=new bn(2);x.geometry=y,x.material=ya;let b=new bn(1);return b.geometry=Zge,b.material=$C,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,i){if(!e.text)return;if(!this.font)return void se.info("[DxfLoader] Font file not set, ignoring text entity.");let n=this.getTextStyle(t,e),r=MC(e.text,{encoding:this.getTextEncoding(n)}),a=this.getMTextGroup(r,e,n,t,i),s=a&&a.object;if(!s)return;s.matrix.decompose(_i,xo,Ry),e.position&&(_i.x+=e.position.x,_i.y+=e.position.y,s.matrix.compose(_i,xo,Ry)),qf.makeEmpty();let o=bn.getBox(s,qf).getSize(Zn),l=o.x,h=o.y,c=0,u=0;switch(e.attachmentPoint){case 1:c=0,u=0;break;case 2:c-=l/2,u=0;break;case 3:c-=l,u=0;break;case 4:c=0,u+=h/2;break;case 5:c-=l/2,u+=h/2;break;case 6:c-=l,u+=h/2;break;case 7:c=0,u+=h;break;case 8:c-=l/2,u+=h;break;case 9:c-=l,u+=h;break;default:return}s.traverse((e=>{e.geometry&&e.geometry.translate(c,u,0),e.layers.enableAll()}));let d=0;if(e.rotation&&(d=e.rotation*Math.PI/180),e.directionVector){let t=e.directionVector,i=new D(t.x,t.y,t.z),n=i.clone().cross(Bc),r=Bc.angleTo(i);d=n.z>0?-r:r}Qt.shouldRebasePositionOnRTC(_i)&&this.setRTCUserData(s),s.matrix.compose(_i,xo,Ry);let p=e.position?_i.clone().sub(e.position):_i;return Gf.makeTranslation(-p.x,-p.y,0),js.makeRotationZ(d),s.matrix.multiply(Gf),s.matrix.multiply(js),s.matrix.multiply(Gf.invert()),s}getMTextGroup(e,t,i,n,r,a=0,s=0,o=[]){var l,h,c,u;if(0===e.length)return;let d=t.height||t.contextData&&t.contextData.textHeight||0;if(t.textStyle){if(i&&i.fontFile&&i.fontFile.endsWith(".shx")){let e=`${i.fontFile}_${i.styleName}`;this.statsInfo.unsupportedTextStyles[e]||(this.statsInfo.unsupportedTextStyles[e]=0),this.statsInfo.unsupportedTextStyles[e]++}d=d||i.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 bn,y=i.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,i)=>{e.boundingBox||e.computeBoundingBox(),0===i?t=e.boundingBox:t.union(e.boundingBox)})),t){let i=t.getSize(Zn);switch(f){case"Left":default:break;case"Center":e.forEach((e=>e.translate((g-i.x)/2,0,0)));break;case"Right":e.forEach((e=>e.translate(g-i.x,0,0)))}}M.push(...e)};for(let t=0;t<E.length;t++){let n=E[t];if("\n"!==n)if(w=p*d*.3,S=w+d,e=null==(l=this.font)?void 0:l.getCharShape(n,y,d),i.bigFontFile&&!e&&(e=null==(h=this.font)?void 0:h.getCharShape(n,i.bigFontFile,d)),e||(e=null==(c=this.font)?void 0:c.getCharShape(n,"",d)),e||(e=null==(u=this.font)?void 0:u.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(Zn).x;" "===n&&(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 bn;if(M.length>0){m||(m=t.colorIndex),void 0!==_&&256!==_?(t.color=Ym(_),t.colorIndex=_):t.colorIndex=m;let e=this.getColor(t,n,r),i=M.filter((e=>e instanceof Qs)),a=M.filter((e=>!(e instanceof Qs)));if(i.length>0){let t=new bn(4);t.geometry=Ui(i),t.material=this.getMeshBasicMaterial(e),A.add(t)}if(a.length>0){let t=new bn(3);t.geometry=Ui(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,i,n,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")&&se.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?(Ic.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 i={horizontalAlignment:"",textHeight:t.height||t.contextData&&t.contextData.textHeight},n={},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")?i.horizontalAlignment="center":-1!==o.indexOf("l")?i.horizontalAlignment="left":-1!==o.indexOf("r")?i.horizontalAlignment="right":-1!==o.indexOf("j")&&(i.horizontalAlignment="justify");else if(!o.startsWith("pi")&&!o.startsWith("pxt")&&!o.startsWith("pt")){let e=this.getTextLineNum(o);a.push({font:n.f,colorIndex:n.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?n.C=o.C:void 0!==o.W?n.W=o.W:void 0!==o.H?n.H=o.H:void 0!==o.f&&(n.f=o.f)}return{text:a,lineLength:r,style:i}}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 se.warn("[DxfLoader] Entity is missing vertices:",e.handle);let t=e.vertices.map((e=>new D(e.x,e.y,e.z)));if(0===t.length)return;Zt.areVector3sEqual(t[0],t[t.length-1])||t.push(t[0]);let i=new D,n=!1;this.enableRTC&&(n=Qt.checkAndRebasePositionsOnRTC(t,i));let r=(new Dt).setFromPoints(t),a=new bn(2);return a.geometry=r,a.material=ya,n&&(this.setRTCUserData(a),a.matrix.setPosition(i.x,i.y,0)),a.layers.enableAll(),a}drawSpline(e,t){if(!e.controlPoints||!e.degreeOfSplineCurve||!e.knotValues)return;let i=1/0,n=1/0,r=-1/0,a=-1/0;for(let g of e.controlPoints)g.x<i&&(i=g.x),g.y<n&&(n=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-i,a-n),h=this.getBSplineInterpolationsPerSplineSegment(e.controlPoints.length,l*s),c=vmt(e.controlPoints,e.degreeOfSplineCurve,e.knotValues,h),u=new D,d=!1;this.enableRTC&&(d=Qt.checkAndRebasePositionsOnRTC(c,u));let p=Qt.getAdjacentNonRepeatPoints(c);if(p.length<2)return void se.warn("[DxfLoader] Spline entity (handle '%s') contains less than 2 points, ignored!",e.handle);let f=(new Dt).setFromPoints(p),m=new bn(2);return m.geometry=f,m.material=ya,d&&(this.setRTCUserData(m),m.matrix.setPosition(u.x,u.y,0)),m.layers.enableAll(),m}drawXLine(e){if(!e.vertices||0===e.vertices.length)return void se.warn("[DxfLoader] Entity is missing vertices:",e.handle);let t=St.arrayOrObjectToVector3(e.directionVector),i=new D(e.vertices[0].x,e.vertices[0].y,0),n=[];if(n.push(t.clone().multiplyScalar(-1e6).add(i)),n.push(t.clone().multiplyScalar(1e6).add(i)),0===n.length)return;let r=new D,a=!1;this.enableRTC&&(a=Qt.checkAndRebasePositionsOnRTC(n,r));let s=(new Dt).setFromPoints(n),o=new bn(2);return o.geometry=s,o.material=ya,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 se.warn("[DxfLoader] Entity is missing vertices:",e.handle);let t=St.arrayOrObjectToVector3(e.directionVector),i=e.vertices.map((e=>new D(e.x,e.y,0)));if(i.push(t.multiplyScalar(1e6).add(i[0])),0===i.length)return;let n=new D,r=!1;this.enableRTC&&(r=Qt.checkAndRebasePositionsOnRTC(i,n));let a=(new Dt).setFromPoints(i),s=new bn(2);return s.geometry=a,s.material=ya,r&&(this.setRTCUserData(s),s.matrix.setPosition(n.x,n.y,0)),s.layers.enableAll(),s}drawLine(e){if(!e.vertices||0===e.vertices.length)return void se.warn("[DxfLoader] Entity is missing vertices:",e.handle);let t=[];if(e.isPolyfaceMesh)t=xmt(e.vertices);else{let i=S6(e.vertices,e.shape);e.shape&&i.length>0&&i.push(i[0]),i.length>0&&(t=[i])}if(0===t.length)return;let i=[];for(let s=0;s<t.length;){let[e,n]=t[s];Zt.areVector3sEqual(e,n)&&t[s].length<=2?(i.push(e),t.splice(s,1)):s++}let n,r=new D,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=Qt.shouldRebasePositionOnRTC(r)}let e=[],i=[],s=0,o=0,l=0,h=0;t.forEach((t=>{for(let n=0;n<t.length;n++)a?(o=t[n].x-r.x,l=t[n].y-r.y,h=t[n].z-r.z,e.push(new D(o,l,h))):e.push(t[n]),n>0&&i.push(s+n-1,s+n);s=t.length}));let c=(new Dt).setFromPoints(e);c.setIndex(i),n=new bn(3),n.geometry=c,n.material=ya}if(i.length>0){this.enableRTC&&(a=Qt.checkAndRebasePositionsOnRTC(i,r));let e=(new Dt).setFromPoints(i);n=new bn(1),n.geometry=e,n.material=$C}return n?(a&&(this.setRTCUserData(n),n.matrix.setPosition(r.x,r.y,0)),n.layers.enableAll(),n):void 0}drawLWPolyline(e,t,i){var n,r,a;if(!e.vertices||e.vertices.length<2)return void se.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){Zn.set(s.extrusionDirectionX,s.extrusionDirectionY,s.extrusionDirectionZ);let e=Kn.getOcsMatrix(Zn).invert(),t=0;void 0!==s.elevation&&s.elevation>0&&(t=s.elevation),s.vertices.forEach((i=>{let n=Zn.set(i.x,i.y,t).applyMatrix4(e);i.x=n.x,i.y=n.y}))}let o=S6(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 se.warn("[DxfLoader] Invalid LWPolyline entity (handle '%s'), ignored!",e.handle);let l=new bn;if(null!=(n=e.extendedData)&&n.outlines){let t=e.extendedData.outlines,i=[];t.forEach((e=>{let t=new _s;e.forEach(((e,i)=>{0===i?t.moveTo(e[0],e[1]):t.lineTo(e[0],e[1])})),t.closePath(),i.push(new Rl(t))}));let n=Ui(i),r=new bn(4);r.geometry=n,r.material=My,r.layers.enableAll(),l.add(r)}let h=new D,c=!1;this.enableRTC&&(c=Qt.checkAndRebasePositionsOnRTC(o,h));let u=Qt.getAdjacentNonRepeatPoints(o);if(u.length<2)return void se.warn("[DxfLoader] Invalid LWPolyline entity (handle '%s'), ignored!",e.handle);if(this.enablePlineWidth&&void 0!==s.constantWidth&&s.constantWidth>0){let n=null==(a=null==(r=t.tables)?void 0:r.lineType)?void 0:a.lineTypes,o=n&&n[this.getLineType(e,t,i)];if(!o||!o.pattern||0===o.pattern.length){this.statsInfo.unsupportedPolylineCount++;let t=Qt.convertWidthLineToMeshGeometry(u,s.constantWidth);if(t){let e=new bn(4);e.geometry=t,e.material=My,e.layers.enableAll(),e.layers.disable(11),l.add(e);let i=Hn.createOutline(t,ya,e.matrix),n=new bn(3);n.geometry=i.geometry,n.material=i.material,n.matrix=i.matrix,n.layers.enableAll(),n.layers.disable(11),l.add(n)}else se.warn("[DxfLoader] Failed to convert line with width to mesh geometry: %s",e.handle)}}let d=new bn(2);return d.geometry=(new Dt).setFromPoints(u),d.material=ya,d.layers.enableAll(),l.children.length>0?l.add(d):l=d,c&&(this.setRTCUserData(l),l.matrix.setPosition(h)),l}drawMLeader(e,t,i){var n,r,a,s,o,l,h;let c=t.tables.dimStyle.dimStyles[e.dimensionStyle]||this.getDefaultDimensionStyle(t),u=null==(n=e.contextData)?void 0:n.defaultTextContents;if(!u)return;let d=new bn,p=MC(u),f=this.getTextStyle(t,e),m=this.getMTextGroup(p,e,f,t,i),g=m&&m.object;if(g){g.matrix.decompose(_i,xo,Ry),null!=(r=e.contextData)&&r.textLocation&&(_i.x+=e.contextData.textLocation.x,_i.y+=e.contextData.textLocation.y,g.matrix.compose(_i,xo,Ry)),qf.makeEmpty();let t=bn.getBox(g,qf).getSize(Zn),i=t.x,n=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-=i/2,h=0;break;case 3:l-=i,h=0;break;case 4:l=0,h+=n/2;break;case 5:l-=i/2,h+=n/2;break;case 6:l-=i,h+=n/2;break;case 7:l=0,h+=n;break;case 8:l-=i/2,h+=n;break;case 9:l-=i,h+=n;break;default:return}g.traverse((e=>{e.geometry&&e.geometry.translate(l,h,0)}));let c=0;if(null!=(s=e.contextData)&&s.textRotation&&(c=e.contextData.textRotation*Math.PI/180),null!=(o=e.contextData)&&o.textDirection){let t=e.contextData.textDirection,i=new D(t.x,t.y,t.z),n=i.clone().cross(Bc),r=Bc.angleTo(i);c+=n.z>0?-r:r}Qt.shouldRebasePositionOnRTC(_i)&&this.setRTCUserData(g),g.matrix.compose(_i,xo,Ry),e.contextData.textLocation?Zn.set(e.contextData.textLocation.x,e.contextData.textLocation.y,0):Zn.set(0,0,0);let u=_i.clone().sub(Zn);Gf.makeTranslation(-u.x,-u.y,0),js.makeRotationZ(c),g.matrix.multiply(Gf),g.matrix.multiply(js),g.matrix.multiply(Gf.invert()),g.renderOrder=5,d.add(g)}if(0===e.leaderLineType)return null==g||g.traverse((e=>{e.layers.enableAll()})),g;{let i=[],n=null==(l=e.contextData)?void 0:l.leaders[0];if(!n)return d;let r=n.lastLeaderLinePoint;if(e.enableDogLeg){let e=new D(r.x,r.y,r.z),t=n.doglegLength,a=new D(n.doglegVector.x,n.doglegVector.y,n.doglegVector.z).multiplyScalar(t),s=e.clone().add(a);i.push(s,e)}let a=(null==(h=e.contextData)?void 0:h.leaders[0].leaderLines)||[];for(let l=0;l<a.length;l++){let n=a[l].vertices[0].reverse().map((e=>new D(e.x,e.y,e.z))),s=new D(r.x,r.y,r.z);for(let e=0;e<n.length;e++)i.push(s,n[e]),s=n[e];let o=Zn.subVectors(i[0],i[1]).length(),h=(e.arrowHeadSize||c.DIMASZ||2.5)*(e.arrowHeadScale||c.DIMSCALE||1);e.leaderLineType;let u="";if(e.arrowHeadId?u=e.arrowHeadId:c&&c.DIMLDRBLK&&(u=c.DIMLDRBLK),u){let n=this.getBlockByHandle(t.blocks,u);if(n&&n.entities)for(let r=0;r<n.entities.length;r++){let a=this.drawEntity(n.entities[r],t,e);if(a){let e=new D(i[i.length-1].x,i[i.length-1].y,i[i.length-1].z),t=new D(i[i.length-2].x,i[i.length-2].y,i[i.length-2].z),n=Math.atan2(e.y-t.y,e.x-t.x);Zn.copy(e),_i.setScalar(h),xo.setFromAxisAngle(Sy,n),a.matrix.compose(Zn,xo,_i),d.add(a)}}}else this.drawDefaultLeadArrow(i[i.length-2],i[i.length-1],o/2e3,i)}let s=new D,o=!1;this.enableRTC&&(o=Qt.checkAndRebasePositionsOnRTC(i,s));let u=(new Dt).setFromPoints(i),p=new bn(3);p.geometry=u,p.material=ya,p.renderOrder=2,o&&(this.setRTCUserData(p),p.matrix.setPosition(s.x,s.y,0)),d.add(p)}return Ic.merge(d,!1),d.traverse((e=>{e.layers.enableAll()})),1===d.children.length?d.children[0]:d}drawLeader(e,t,i){let n=[];if(!e.vertices)return void se.warn("[DxfLoader] Entity is missing vertices:",e.handle);if(e.vertices.length<2)return void se.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 Em(e.vertices).getPoints(50)),e.textWidth){let t=e.textWidth,i=new D(a[a.length-1].x,a[a.length-1].y,a[a.length-1].z);if(0===e.direction){let e=new D(1,0,0).multiplyScalar(t);a.push(e.add(i))}else{let e=new D(-1,0,0).multiplyScalar(t);a.push(e.add(i))}}for(let p=0;p<a.length-1;p++){let e=a[p],t=a[p+1];n.push(e,t)}let s=Zn.subVectors(n[0],n[1]).setZ(0).length(),o=(e.arrowHeight||r.DIMASZ||2.5)*(e.arrowHeadScale||r.DIMSCALE||1),l=new bn;if(1===e.arrowFlag){let i="";e.arrowHeadBlockHandle?i=e.arrowHeadBlockHandle:r&&r.DIMLDRBLK&&(i=r.DIMLDRBLK);let a=this.getBlockByHandle(t.blocks,i);if(a&&a.entities){r&&(e.colorIndex=r.DIMCLRD||256,e.color=Ym(e.colorIndex));for(let i=0;i<a.entities.length;i++){let r=this.drawEntity(a.entities[i],t,e);if(r){let e=new D(n[0].x,n[0].y,n[0].z),t=new D(n[1].x,n[1].y,n[1].z),i=Math.atan2(e.y-t.y,e.x-t.x);Zn.copy(e),_i.setScalar(o),xo.setFromAxisAngle(Sy,i),r.matrix.compose(Zn,xo,_i),l.add(r)}}}else this.drawDefaultLeadArrow(n[1],n[0],o/s/2,n)}if(0===n.length)return;let h=new D,c=!1;this.enableRTC&&(c=Qt.checkAndRebasePositionsOnRTC(n,h));let u=(new Dt).setFromPoints(n),d=new bn(2);return d.geometry=u,d.material=ya,d.renderOrder=2,c&&(this.setRTCUserData(d),d.matrix.setPosition(h.x,h.y,0)),l.children.length>0?(l.add(d),Ic.merge(l,!1),l.traverse((e=>{e.layers.enableAll()})),1===l.children.length?l.children[0]:l):(d.layers.enableAll(),d)}drawDefaultLeadArrow(e,t,i,n){let r=i*(e.x-t.x),a=i*(e.y-t.y),s=a,o=-r,l=new D(t.x+r+s/6,t.y+a+o/6,0),h=new D(t.x+r-s/6,t.y+a-o/6,0);n.push(t,l),n.push(t,h),n.push(l,h)}getBlockByHandle(e,t){if(!this.blocksCache){this.blocksCache={};for(let t in e){let i=e[t];this.blocksCache[i.ownerHandle]||(this.blocksCache[i.ownerHandle]=i)}}return this.blocksCache[t]}static updateMaterialUniforms(e){e instanceof cn&&(e.uniforms.u_cameraZoom&&(e.uniforms.u_cameraZoom=Kn.cameraZoomUniform),e.uniforms.u_viewportScale&&(e.uniforms.u_viewportScale=Kn.viewportScaleUniform))}static transformAngleByOcsMatrix(e,t){let i=Zn.set(1*Math.cos(t),1*Math.sin(t),0).applyMatrix4(e);return Math.atan2(i.y,i.x)}static getArcAnglesByOcsMatrix(e,t,i){let n,r=Zt.getArcAngleSpanInRadian(t,i),a=Kn.transformAngleByOcsMatrix(e,t),s=Kn.transformAngleByOcsMatrix(e,i);if(Zt.areNumbersClose(r,Math.PI)){r=1;let i=Kn.transformAngleByOcsMatrix(e,t+r);n=Zt.getArcAngleSpanInRadian(a,i)}else{if(Zt.areNumbersClose(r,2*Math.PI))return[a,a+2*Math.PI];n=Zt.getArcAngleSpanInRadian(a,s)}return Zt.areNumbersClose(r,n,1e-5)?[a,s]:[s,a]}drawArc(e,t,i){var n,r,a;if(!e.radius||e.radius<.001)return void se.warn(`[DxfLoader] The radius of arc (handle '${e.handle}') is undefined, ignored!`);if(!e.radius||e.radius<.001)return void se.warn(`[DxfLoader] The radius of arc (handle '${e.handle}') is too small, ignored!`);let s=new D(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=Kn.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=Kn.getArcAnglesByOcsMatrix(h,o,l);o=e[0],l=e[1]}}let c=new bm(0,0,e.radius,o,l,0!==this.angBase),u=1,d=i;null!=d&&d.xScale&&null!=d&&d.yScale&&(u=Math.max(Math.abs(d.xScale),Math.abs(d.yScale)));let p=this.getDivision(o,l,e.radius*u),f=c.getPoints(p),m=new D,g=!1;this.enableRTC&&(g=Qt.checkAndRebasePositionsOnRTC(f,m));let v=(new Dt).setFromPoints(f),y=new bn(2);y.geometry=v,y.material=ya;let x=new D;e.center&&(x.x=e.center.x,x.y=e.center.y);let b=new D(null==(n=e.center)?void 0:n.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 bn(1);return w.geometry=Zge,w.material=$C,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):Qt.shouldRebasePositionOnRTC(_)&&this.setRTCUserData(y),y.matrix.setPosition(_),y.layers.enableAll(),y}addTriangleFacingCamera(e,t,i,n){let r=new D,a=new D;r.subVectors(i,t),a.subVectors(n,t),r.cross(a);let s=new D(t.x,t.y,t.z),o=new D(i.x,i.y,i.z),l=new D(n.x,n.y,n.z);r.z<0?e.push(l,o,s):e.push(s,o,l)}drawSolid(e,t,i){let n=e.points;if(!n||n.length<4)return;if(e.extrusionDirection&&e.extrusionDirection.z){Zn.set(0,0,e.extrusionDirection.z);let t=Kn.getOcsMatrix(Zn).invert();n.forEach((e=>{let i=Zn.set(e.x,e.y,0).applyMatrix4(t);e.x=i.x,e.y=i.y}))}let r=[],a=[];this.addTriangleFacingCamera(r,n[0],n[1],n[2]),a.push(0,1,2),this.addTriangleFacingCamera(r,n[1],n[2],n[3]),a.push(3,4,5);let s=new D,o=!1;this.enableRTC&&(o=Qt.checkAndRebasePositionsOnRTC(r,s));let l=(new Dt).setFromPoints(r);l.setIndex(a);let h=new bn(4);return h.geometry=l,h.material=My,o&&(this.setRTCUserData(h),h.matrix.setPosition(s.x,s.y,0)),h.layers.enableAll(),h}getTextStyle(e,t){var i,n;let r=null==(n=null==(i=e.tables)?void 0:i.style)?void 0:n.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,i,n){if(!e)return;let r=(null==i?void 0:i.styleName)||"";if(i&&i.fontFile&&i.fontFile.endsWith(".shx")){let e=`${i.fontFile}_${i.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]),n.xScale&&(a*=n.xScale),r&&(a*=(null==i?void 0:i.xScale)||1,t=t||(null==i?void 0:i.textHeight)||0),0===t&&(t=r?1:.2);let o=this.createTextMeshByText(e,i,t,0,t/8);return o.traverse((e=>{e.geometry&&e.geometry.scale(a,1,1)})),o}createTextMeshByText(e,t,i=12,n=0,r=0,a=1,s=1/0){var o,l,h;let c=new bn,u=[],d=0,p=0,f=n+i;for(let m=0;m<e.length;m++){let n=e[m];if(" "===n){d+=i;continue}if("\n"===n){d=0,p-=f;continue}let c=null==(o=this.font)?void 0:o.getCharShape(n,t.fontFile,i);t.bigFontFile&&!c&&(c=null==(l=this.font)?void 0:l.getCharShape(n,t.bigFontFile,i)),c||(c=null==(h=this.font)?void 0:h.getNotFoundTextShape(i)),c&&(c.translate(d,p,0),c.scale(a,1,1),d>s?(d=0,p-=f):(c.boundingBox||c.computeBoundingBox(),d+=c.boundingBox.getSize(Zn).x+r),u.push(c))}if(u.length>0){let e=u.filter((e=>e instanceof Qs)),t=u.filter((e=>!(e instanceof Qs)));if(e.length>0){let t=new bn(4);t.geometry=Ui(e),t.material=My,c.add(t)}if(t.length>0){let e=new bn(3);e.geometry=Ui(t),e.material=ya,c.add(e)}}return c}transformTextMesh(e,t){qf.makeEmpty();let i=bn.getBox(t,qf).getSize(Zn),{halign:n,valign:r}=e;t.matrix.decompose(ZC.position,ZC.quaternion,ZC.scale);let a=ZC,s=e.width||e.textWidth||i.x,o=e.height||e.textHeight||i.y;if(void 0===n&&void 0===r&&e.startPoint||[3,5].includes(n)&&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!==n&&5!==n){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(n){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 D(e.startPoint.x,e.startPoint.y,e.startPoint.z),i=new D(e.endPoint.x,e.endPoint.y,e.endPoint.z),n=(new D).subVectors(t,i),r=n.length()/s;a.scale.multiplyScalar(r);let o=n.clone().cross(Bc),l=n.angleTo(Bc);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 D(e.startPoint.x,e.startPoint.y,e.startPoint.z),i=new D(e.endPoint.x,e.endPoint.y,e.endPoint.z),n=(new D).subVectors(t,i),r=n.length()/s;a.scale.setX(r);let o=n.clone().cross(Bc),l=n.angleTo(Bc);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,i){let n=e.text;if(!n)return;if(!this.font)return void se.info("[DxfLoader] Font file not set, ignoring text entity.");let r=this.getTextStyle(t,e);n=RC(n,{encoding:this.getTextEncoding(r)}).map((e=>e.text)).join("");let a=this.getTextMesh(n,e.textHeight,r,e);if(!a||0===a.children.length)return;this.transformTextMesh(e,a),Zn.set(a.matrix.elements[12],a.matrix.elements[13],a.matrix.elements[14]);let s=Qt.shouldRebasePositionOnRTC(Zn);return s&&this.setRTCUserData(a),a.traverse((e=>{let t=e.geometry;if(t){if(e instanceof xt&&!t.getIndex()){let e=t.getAttribute("position"),i=[];for(let t=0;t<e.count;t+=3)i.push(t,t+1,t+2);t.setIndex(i)}if(t.hasAttribute("uv")&&t.deleteAttribute("uv"),t.hasAttribute("normal")&&t.deleteAttribute("normal"),!s){let i=Qt.caculateGeometryCenter(t);i&&Qt.shouldRebasePositionOnRTC(i)&&this.setRTCUserData(e)}}})),a.layers.enableAll(),a}drawAttDef(e,t,i){let n=e.tag||e.text||e.prompt;if(!n||!this.font)return;let r=this.getTextStyle(t,e);n=RC(n).map((e=>e.text)).join();let a=this.getTextMesh(n,e.textHeight,r,e);if(!a||0===a.children.length)return;this.transformTextMesh(e,a),Zn.set(a.matrix.elements[12],a.matrix.elements[13],a.matrix.elements[14]);let s=Qt.shouldRebasePositionOnRTC(Zn);return s&&this.setRTCUserData(a),a.traverse((e=>{let t=e.geometry;if(t){if(e instanceof xt&&!t.getIndex()){let e=t.getAttribute("position"),i=[];for(let t=0;t<e.count;t+=3)i.push(t,t+1,t+2);t.setIndex(i)}if(t.hasAttribute("uv")&&t.deleteAttribute("uv"),t.hasAttribute("normal")&&t.deleteAttribute("normal"),!s){let i=Qt.caculateGeometryCenter(t);i&&Qt.shouldRebasePositionOnRTC(i)&&this.setRTCUserData(e)}}})),a.layers.enableAll(),a}drawAttrib(e,t,i){let n=e.text;if(!n||!this.font)return;let r=this.getTextStyle(t,e);n=RC(n).map((e=>e.text)).join();let a=this.getTextMesh(n,e.textHeight,r,e);if(!a||0===a.children.length)return;this.transformTextMesh(e,a),Zn.set(a.matrix.elements[12],a.matrix.elements[13],a.matrix.elements[14]);let s=Qt.shouldRebasePositionOnRTC(Zn);return s&&this.setRTCUserData(a),a.traverse((e=>{let t=e.geometry;if(t){if(e instanceof xt&&!t.getIndex()){let e=t.getAttribute("position"),i=[];for(let t=0;t<e.count;t+=3)i.push(t,t+1,t+2);t.setIndex(i)}if(t.hasAttribute("uv")&&t.deleteAttribute("uv"),t.hasAttribute("normal")&&t.deleteAttribute("normal"),!s){let i=Qt.caculateGeometryCenter(t);i&&Qt.shouldRebasePositionOnRTC(i)&&this.setRTCUserData(e)}}})),a.layers.enableAll(),a}drawPoint(e,t,i){if(!e.position)return;let n=new Dt,r=[new D(e.position.x,e.position.y,e.position.z)];Zn.set(0,0,0);let a=Zn,s=!1;this.enableRTC&&(s=Qt.checkAndRebasePositionsOnRTC(r,a)),n.setFromPoints(r);let o=new bn(1);return o.geometry=n,o.material=ya,s&&(this.setRTCUserData(o),o.matrix.setPosition(a.x,a.y,0)),o.layers.enableAll(),o}drawDimension(e,t){if(!e.block)return;let i=t.blocks[e.block];if(!i||!i.entities)return;let n=t.tables.dimStyle.dimStyles[e.dimStyleName]||this.getDefaultDimensionStyle(t);n&&n.DIMCLRD>0&&(e.colorIndex=n.DIMCLRD,e.color=Ym(e.colorIndex));let r=new bn;for(let s=0;s<i.entities.length;s++){let n=this.drawEntity(i.entities[s],t,e);n&&r.add(n)}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}<${i.name}>`,r.userData.entityType=e.type;let a=null==e?void 0:e.insertionPoint;return Zn.set(0,0,0),a&&Zn.set(a.x,a.y,0),Qt.shouldRebasePositionOnRTC(Zn)&&this.setRTCUserData(r),r.matrix.setPosition(Zn),r}drawImage(e,t,i){var n;if(!e.imageSize||null==(n=t.objects.IMAGEDEF)||!n.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 bn,l=!1;2===e.flags||4===e.flags||8===e.flags||(l=!0);let h=new ui(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=en;let t=new ln({transparent:!0,side:pi,map:e}),i=new bn(4);i.geometry=h,i.material=t,o.add(i)}let c=new Au(h),u=this.getColor(e,t,i),d=new bn(2);d.geometry=c,d.material=this.getLineBasicMaterial(u);let p=e.uPixel?new D(e.uPixel.x,e.uPixel.y,e.uPixel.z):new D(r.pixelSize.x,0,0),f=e.vPixel?new D(e.vPixel.x,e.vPixel.y,e.vPixel.z):new D(r.pixelSize.y,0,0);if(o.add(d),_i.set(p.x,f.y,1),Zn.set(0,0,0),e.position){let t=new D(e.position.x,e.position.y,e.position.z);t.add(p.multiplyScalar(a/2)).add(f.multiplyScalar(s/2)),Zn.copy(t)}return Qt.shouldRebasePositionOnRTC(Zn)&&this.setRTCUserData(o),xo.identity(),o.matrix.compose(Zn,xo,_i),o}drawInsert(e,t,i=!1){var n,r;if(!e.block)return;let a=t.blocks[e.block];if(!a.entities)return;e.blockPosition=a.position;let s=new bn;for(let u=0;u<a.entities.length;u++){if("ATTDEF"===a.entities[u].type)continue;let n=this.drawEntity(a.entities[u],t,e,i);n&&s.add(n)}if(0===s.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++,s.name=`${e.type}<${a.name}>`,s.userData.entityType=e.type,null!=(n=e.extendedData)&&n.originalType&&(s.userData.originalType=null==(r=e.extendedData)?void 0:r.originalType),null!=e&&e.blockPosition&&s.matrix.setPosition(-e.blockPosition.x,-e.blockPosition.y,0);let o=Zn.set(1,1,1);e.xScale&&(o.x=e.xScale),e.yScale&&(o.y=e.yScale);let l=new Xn;e.rotation&&(l.z=e.rotation*Math.PI/180),xo.setFromEuler(l,!1);let h=_i.set(0,0,0);e.position&&(h.x=e.position.x,h.y=e.position.y),js.compose(h,xo,o),e.extrusionDirection&&e.extrusionDirection.z<0&&js.premultiply(Kge.identity().makeScale(-1,1,1)),Gf.copy(s.matrix),s.matrix.premultiply(js),_i.set(s.matrix.elements[12],s.matrix.elements[13],s.matrix.elements[14]),Qt.shouldRebasePositionOnRTC(_i)&&this.setRTCUserData(s);let c=this.findSpatialFilterByHandle(e.handle,t);if(c){this.drawSpatialFilter(c);let t=c;t&&t.clipPolylines&&t.clipPolylines.length>0&&(s.userData.spatialFilterHandle=c.handle,this.cloneMaterialsForSpatialFilter(s),se.debug("[DxfLoader] Spatial filter:",e.associatedSpatialFilter))}return s}drawSpatialFilter(e){let t=e;if(t.threejsObject)return t.threejsObject.clone();let i=e.invertBlockMatrix;js.set(i[0],i[1],i[2],i[3],i[4],i[5],i[6],i[7],i[8],i[9],i[10],i[11],0,0,0,1);let n=[];e.vertices.forEach((e=>{n.push(new D(e.x,e.y,0))}));let r={polyline:[],bConcave:!1,bReversed:!1};if(2===e.numberOfPointsOnClipBoundary)r.polyline=n;else{let t=e.numberOfPointsOnClipBoundary,i=3;if(t<i)return void se.warn(`[DxfLoader] Invalid clipBoundary: ${e.handle} !`);let a=[],s=-1;for(let e=0;e<t;e++){let i=n[e];for(let r=t-1;r>e;r--){let o=n[r];if(Zt.areVector3sEqual(i,o)&&e+1<r-1&&e+1<t-1&&Zt.areVector3sEqual(n[e+1],n[r-1])){a.push(i),s=r;break}}if(s>0)break;a.push(i)}if(s>0)for(let e=s+1;e<t;e++)a.push(n[e]);if(a.length<i)return void se.warn(`[DxfLoader] Invalid clipBoundary: ${e.handle}!`);let o=[],l=[];if(a.forEach((e=>{o.push(new xe(e.x,e.y)),l.push([e.x,e.y])})),!Qt.isConvex(o)){se.warn(`[DxfLoader] Concave polygon is not supported for spatial filter (handle '${e.handle}'), converting to convex polygon!`);let t=(0,r0e.default)(l,1/0);a=[],t.forEach((e=>{a.push(new D(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=js.clone(),t.clipPolylines=[],void t.clipPolylines.push(r)}drawLayout(e,t,i,n,r,a){if(!e.entities)return;let s=new bn;for(let h=0;h<e.entities.length;h++){let n=e.entities[h];this.addViewport(n,a);let o=this.drawEntity(n,t);o&&(this.enableMerge&&Ic.merge(o,!1),s.add(o),o.traverse((e=>{if(e.geometry){let t=e.userData.layerName,n=r[t];n||(n=[],r[t]=n),n.push(e),e.userData.isSnapObject&&(this.layoutsSnapObjectsMap[i.layoutName]||(this.layoutsSnapObjectsMap[i.layoutName]=[]),this.layoutsSnapObjectsMap[i.layoutName].push(e))}})))}if(0===s.children.length)return;s.userData.layerName=e.layer;let o=i.layoutName,l=n.children.find((e=>e.name===o));l||(l=new bn,l.name=o,l.userData.isLayoutLevelObject=!0,n.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 i=e;t.push(new xe(i.startPoint.x,i.startPoint.y)),t.push(new xe(i.endPoint.x,i.endPoint.y));break}case 2:{let i=e,n=i.startAngle*Rn.DEG2RAD,r=i.endAngle*Rn.DEG2RAD;i.bCounterclockwise||(n=2*Math.PI-n,r=2*Math.PI-r);let a=new bm(i.center.x,i.center.y,i.radius,n,r,!i.bCounterclockwise),s=this.getDivision(n,r,i.radius);t.push(...a.getPoints(s));break}case 3:{let i=e,n=Math.sqrt(Math.pow(i.majorAxisEndPoint.x,2)+Math.pow(i.majorAxisEndPoint.y,2)),r=n*i.minorRatio,a=Math.atan2(i.majorAxisEndPoint.y,i.majorAxisEndPoint.x),s=i.startAngle*Rn.DEG2RAD,o=i.endAngle*Rn.DEG2RAD;i.bCounterclockwise||(s=2*Math.PI-s,o=2*Math.PI-o);let l=new Kh(i.center.x,i.center.y,n,r,s,o,!i.bCounterclockwise,a),h=this.getDivision(s,o,Math.max(n,r));t.push(...l.getPoints(h));break}case 4:{let i=e;t.push(...i.controlPoints);break}case 0:{let i=e;t.push(...S6(i.points,i.isClosed));break}}return t}drawHatch(e,t,i){var n,r;let a=e;if(0==a.boundaryPaths.length)return;if(!(a.solidFill||null!=(n=a.patternLines)&&n.length))return void se.warn(`[DxfLoader] Hatch entity(handle: '${a.handle}') doesn't have solid fill, nor patternLines, ignored!`);let s=[],o=[],l=[],h=e=>{let t=[],i=[];i.push(...this.convertEdgeToPoints(e[0]));for(let n=1;n<e.length;n++){let r=this.convertEdgeToPoints(e[n]);if(i.push(...r),i.length>2){let a=this.convertEdgeToPoints(e[n-1]);Zt.areVector2sEqual(a[a.length-1],r[0])?Zt.areVector2sEqual(i[0],r[r.length-1],1e-5)&&(t.push(i),i=[]):Zt.areVector2sEqual(a[0],r[r.length-1])?Zt.areVector2sEqual(i[1],r[0],1e-5)&&(t.push(i),i=[]):i=[]}}return t};if(a.boundaryPaths.forEach(((e,t)=>{let i=[];if(this.IsfilteredByPathTypeFlag(e.pathTypeFlag)){let i="[DxfLoader] The %d path type flag is filtered at the %dth boundrayPath (hatch handle '%s')";return void se.info(i,e.pathTypeFlag,t,a.handle)}let n=e.edges;if(0===n.length)return;let r=[];for(let s=0;s<n.length;s++){let e=this.convertEdgeToPoints(n[s]);if(e.length<2){let e="[DxfLoader] The %dth edge of the %dth boundaryPath (hatch handle '%s') has less than 2 points, ignored!";se.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!";se.warn(e,t,a.handle)}else if(i.push(r),e.pathTypeFlag>31&&(!(e=>{for(let t=1;t<e.length;++t){let i=e[t-1].endPoint,n=e[t].startPoint;if(!i||!n||!Zt.areVector2sEqual(i,n))return!1}return!0})(e.edges)||!a.associativity)&&(i=h(n),i.length<2)){let e="[DxfLoader] The %dth boundaryPath (hatch handle '%s') has unknown path, ignored!";se.warn(e,t,a.handle)}else i.forEach((e=>{Zt.areVector2sEqual(e[0],e[e.length-1])||e.push(e[0]);let t=e.map((e=>new xe(St.roundNumber(e.x,7),St.roundNumber(e.y,7))));if((null==t?void 0:t.length)>0){s.push(t);let e=(new Mi).setFromPoints(t);o.push(e);let i=e.getSize(u_),n=i.x*i.y;l.push({area:n,index:s.length-1})}}))})),0===s.length)return;let c=new xe,u=this.checkAndRebasePolygonsOnRTC(s,c);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=Ui(m)),!p||!p.getIndex()||0===(null==(r=p.getIndex())?void 0:r.count))return void se.warn("[DxfLoader] Failed to convert hatch boundaries!");let g=new bn(4);g.geometry=p,g.material=My,this.setHatchMaterial(g,a,t,c,i);let v=g;return u&&(this.setRTCUserData(v),v.matrix.setPosition(c.x,c.y,0)),v.traverse((e=>{e.layers.enableAll(),e.layers.disable(11)})),v}drawOle2frame(e,t){let{leftUpX:i,leftUpY:n,rightDownX:r,rightDownY:a}=e;if(!(i&&n&&r&&a))return;let s=[new xe(i,n),new xe(i,a),new xe(r,a),new xe(r,n),new xe(i,n)],o=new D,l=!1;this.enableRTC&&(l=Qt.checkAndRebasePositionsOnRTC(s,o));let h=(new Dt).setFromPoints(s),c=this.getLineBasicMaterial(16777215),u=new bn(2);u.geometry=h,u.material=c,u.layers.enableAll(),l&&(this.setRTCUserData(u),u.matrix.setPosition(o.x,o.y,0));let d=new bn;d.add(u);let p,f,m=t.objects.DICTIONARY;for(let g of m){let t=g;for(let i in t.entries)if(t.entries[i]===e.handle){p=i;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,i="data:image/jpg;base64,"+St.hexToBase64(t),n=new ws(this.manager).load(i);n.colorSpace=en;let r=new ln({transparent:!0,map:n});this.meshTextureMaterials[p]=r,f=r;break}}if(f){let e=(new Mi).setFromPoints(s),t=e.getSize(u_),i=new ui(t.x,t.y),n=new bn(4);n.geometry=i,n.material=f;let r=e.getCenter(u_);Zn.set(r.x,r.y,0),l&&(this.setRTCUserData(n),Zn.x+=o.x,Zn.y+=o.y),n.matrix.setPosition(Zn),n.layers.enableAll(),d.add(n)}return d.children.length>1?d:u}static getOcsMatrix(e){let t=Bc,i=w6,n=Sy,r=new D(0,1,0),a=new D(0,0,1);return Zt.areVectorsClose(e,a)?js.identity():(n=e.clone().normalize(),Zt.areVectorsClose(n,a)||(t=Math.abs(n.x)<1/64&&Math.abs(n.y)<1/64?r.cross(n).normalize():a.cross(n).normalize(),i=n.clone().cross(t).normalize()),js.set(t.x,t.y,t.z,0,i.x,i.y,i.z,0,n.x,n.y,n.z,0,0,0,0,1))}static getDcs2WcsMatrix(e,t){let i;i=pmt(e)?e.viewDirectionFromTarget:e.viewDirection;let n,r,a,s=new D(Zt.roundNumber(i.x,7),Zt.roundNumber(i.y,7),i.z),o=new D(e.viewTarget.x,e.viewTarget.y,e.viewTarget.z),l=e.viewTwistAngle||0;a=s.clone().normalize(),n=Sy.clone().cross(s),n.length()>0?(n.normalize(),r=a.clone().cross(n)):a.z<0?(n=Bc.clone().negate(),r=w6,a=Sy.clone().negate()):(n=Bc,r=w6,a=Sy);let h=new et,c=js.identity();return c.makeBasis(n,r,a),h.premultiply(c),h.premultiply(js.identity().compose(o.clone(),(new dr).setFromAxisAngle(new D(0,0,1),Rn.degToRad(t?l:-l)),new D(1,1,1))),h}getViewportMsToPsMatrix(e){let t=new D(e.centerPoint_dcs.x,e.centerPoint_dcs.y,0),i=new D(e.centerPoint.x,e.centerPoint.y,e.centerPoint.z),n=e.viewHeight/e.height_paperSpace,r=Kn.getDcs2WcsMatrix(e,this.angDir),a=new et;a.setPosition($ge.clone().sub(i));let s=Kge.identity();s.scale(Zn.set(n,n,n));let o=Gf.identity().setPosition($ge.clone().sub(i));s.premultiply(o.clone().invert()).multiply(o),a.multiply(s);let l=js.identity();l.setPosition(t),r.multiply(l);let h=js.identity();return a.invert().multiply(h).multiply(r.invert())}drawViewport(e,t,i){let n=e;if("1"==n.viewportId)return e.psBBox=new Nt,void(e.msToPsMatrix=new et);let r=[],a=n.centerPoint,s=n.width_paperSpace/2,o=n.height_paperSpace/2;r.push(new D(a.x-s,a.y-o,0)),r.push(new D(a.x-s,a.y+o,0)),r.push(new D(a.x+s,a.y+o,0)),r.push(new D(a.x+s,a.y-o,0)),r.push(r[0]),e.psBBox=new Nt(r[0],r[2]),e.msToPsMatrix=this.getViewportMsToPsMatrix(n);let l=new D,h=!1;this.enableRTC&&(h=Qt.checkAndRebasePositionsOnRTC(r,l));let c=(new Dt).setFromPoints(r),u=new bn(2);u.geometry=c,u.material=ya,h&&(this.setRTCUserData(u),u.matrix.setPosition(l.x,l.y,0)),u.userData.entityType=e.type,u.layers.enableAll();let d=new bn;d.add(u);let p=e.psBBox.clone();p.applyMatrix4(e.msToPsMatrix.clone().invert()),p.min.z=0,p.max.z=0;let f=[];f.push(p.min),f.push(new D(p.min.x,p.max.y,0)),f.push(p.max),f.push(new D(p.max.x,p.min.y,0)),f.push(f[0]);let m=new D,g=!1;this.enableRTC&&(g=Qt.checkAndRebasePositionsOnRTC(f,m));let v=(new Dt).setFromPoints(f),y=new bn(2);return y.geometry=v,y.material=ya,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),u}getColor(e,t,i){var n,r,a,s;if(this.compareContext)return ls.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!`;se.warn(t)}return t[0]}}if(e.isTrueColor||e.colorIndex>0&&e.colorIndex<256)return e.color;if(0===e.colorIndex)return i?this.getColor(i,t):null==(r=null==(n=t.tables)?void 0:n.layer)?void 0:r.layers[0].color;if(256===e.colorIndex){let n=null==(s=null==(a=t.tables)?void 0:a.layer)?void 0:s.layers,r=n&&n[e.layer],o=n&&i&&n[i.layer],l=Wf;return r&&"0"!==r.name?l=r.color:o?l=o.color:r?l=r.color:n&&n[0].color&&(l=n[0].color),l}return se.warn("[DxfLoader] Unknown colorIndex"),Wf}getLineType(e,t,i){var n,r;if(i&&"DIMENSION"===i.type)return this.getLineType(i,t);if(e.lineType!==ay&&e.lineType!==oy)return e.lineType;if(e.lineType===oy)return i?this.getLineType(i,t):e.lineType;let a=null==(r=null==(n=t.tables)?void 0:n.layer)?void 0:r.layers,s=fmt;if("0"!==e.layer){let t=a&&a[e.layer];if(t)return t.lineType}else if(i){let e=a&&a[i.layer];if(e)return e.lineType}return s}getLayerName(e,t,i){var n,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==(n=t.tables)?void 0:n.layer)?void 0:r.layers;a(e.layer);let o=s&&s[e.layer];a(null==i?void 0:i.layer);let l=s&&i&&s[i.layer],h=(null==o?void 0:o.name)||"";return o&&"0"===o.name&&l&&(h=l.name),h}setMaterial(e,t,i,n){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 u_.set(0,0),void this.setHatchMaterial(e,t,i,u_,n);if("IMAGE"===t.type)return;let o,l=this.getColor(t,i,n);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 bi)return o=this.getPointsMaterial(l),void(s.material=o);let h=null==(a=null==(r=i.tables)?void 0:r.lineType)?void 0:a.lineTypes,c=h&&h[this.getLineType(t,i,n)];if(c&&c.pattern&&0!==c.pattern.length){let i=t.lineTypeScale||1;o=this.getLineShaderMaterial(c,l,i),e.renderOrder=3}else o=this.getLineBasicMaterial(l)}s.material=o}}setHatchMaterial(e,t,i,n,r){let a=e;if(!a.geometry)return;let s=this.getColor(t,i,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 cn){o=a.material;let e=new ct(s);a.material.uniforms.u_color.value.equals(e)||(o=a.material.clone(),Kn.updateMaterialUniforms(o),o.uniforms.u_color.value.set(s))}else o=this.getHatchShaderMaterial(t,s,n);l=0}o||(o=this.getMeshBasicMaterial(s),l=-1),a.material=o,a.renderOrder=l}setRenderOrderByObjectType(e){let t=e,i=0;t.isMesh?i=-1:t.isLine?i=2:t.isPoints&&(i=4),e.renderOrder=i}getPointsMaterial(e){return this.pointsMaterials[e]||(this.pointsMaterials[e]=new bi({size:.2,color:e})),this.pointsMaterials[e]}getLineBasicMaterial(e){return this.lineBasicMaterials[e]||(this.lineBasicMaterials[e]=new Gn({color:e})),this.lineBasicMaterials[e]}getLineShaderMaterial(e,t,i){let n=`${e.name}_${t}_${i}`;if(!this.lineShaderMaterials[n]){let r=this.getLineTypeScales(),a=r.ltScale*r.celtScale*i;this.lineShaderMaterials[n]=SC.createLineShaderMaterial(e.pattern,t,a,Kn.viewportScaleUniform,Kn.cameraZoomUniform)}return this.lineShaderMaterials[n]}getMeshBasicMaterial(e){return this.meshBasicMaterials[e]||(this.meshBasicMaterials[e]=new ln({color:e})),this.meshBasicMaterials[e]}getHatchShaderMaterial(e,t,i){if(!e.patternLines||e.patternLines.length<1)return;let n=this.findMatchedHatchShaderMaterial(e,t);if(n)return n;let r=2;e.patternLines.forEach((e=>{r=Math.max(e.dashPattern.length,r)}));let a=0,s=[],o=new xe;for(let h of e.patternLines){let t=new xe(h.origin.x,h.origin.y).sub(i).rotateAround(o,-Rn.degToRad(e.patternAngle)),n=new xe(h.delta.x,h.delta.y).rotateAround(o,-Rn.degToRad(h.angle));if(0===n.y)return void se.warn("[DxfLoader] delta.y is equal to zero !");let l=h.dashPattern.length,c=!0,u=0;for(let e=0;e<l;++e){let t=h.dashPattern[e];t>0&&(c=!1),u+=Math.abs(t)}let d=c?.05:.005,p=[],f=[],m=0;f[0]=m;for(let e=0;e<l;++e)p[e]=h.dashPattern[e],0===p[e]&&(p[e]=d*u),m+=Math.abs(p[e]),f[e+1]=m;for(let e=l;e<r;++e)p[e]=0;for(let e=f.length;e<r+1;++e)f[e]=m;let g={origin:t,delta:n,angle:h.angle-e.patternAngle,pattern:p,patternSum:f,patternLength:m};if(a+=4,a+=r,a+=r+1,a>Kn.maxFragmentUniforms){se.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=ame(s,e.patternAngle,Kn.cameraZoomUniform,new ct(t));return l.defines={MAX_PATTERN_SEGMENT_COUNT:r},this.hatchShaderMaterials.push({patternLines:e.patternLines,patternAngle:e.patternAngle,color:t,material:l}),l}getDivision(e,t,i){let n=Math.round(5e4/this.entityCount);n=Math.max(n,2),n=Math.min(n,10);let r=5*n,a=2*n;this.averageCurveSize&&(a*=Math.pow(i/this.averageCurveSize,.5),a=Math.max(a,n),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+i)/(this.curveCount+1),this.curveCount++,Math.max(a,12)}getBSplineInterpolationsPerSplineSegment(e,t){let i=1;this.averageCurveSize&&(i=Math.pow(t/this.averageCurveSize,.5),i=Math.max(i,.5),i=Math.min(i,2)),this.averageCurveSize=(this.averageCurveSize*this.curveCount+t)/(this.curveCount+1),this.curveCount++;let n=2*e*i;return e>20&&(n/=Math.log10(e)),n}setDxfDataToIndexedDb(e,t){return ft(this,null,(function*(){let i={dxfDataId:e,dxf:t};return new Promise(((t,n)=>{yy.instance().add(i,(()=>{se.info(`[DxfLoader] Saved '${e}' to indexedDb`),t()}),(e=>{n(e)}))}))}))}getDxfDataFromIndexedDb(e){return ft(this,null,(function*(){return new Promise(((t,i)=>{yy.instance().query(e,(e=>{e&&e.length>0&&t(e[0].dxf),t(void 0)}),(()=>i()))}))}))}buildContainHierarchyTree(e,t,i){var n;let r=new Map,a=i.length;for(let o=0;o<a;o++)r.set(i[o],{index:i[o],children:[]});let s={index:-1,children:[]};for(let o=0;o<a;o++){let l=i[o],h=e[l],c=t[l],u=o+1;for(;u<a;u++){let a=i[u],s=e[a];if(t[a].containsBox(c)&&Qt.isPointInPolygon(h[St.generateRandomInt(0,h.length-1)],s)){null==(n=r.get(a))||n.children.push(r.get(l));break}}u===a&&s.children.push(r.get(l))}return s}buildHatchGeometry(e,t,i){if(0===t.children.length)return;let n=[],r=new Map;t.children.forEach((e=>{0===e.children.length?n.push(e.index):r.set(e.index,e.children.map((e=>e.index)))}));let a=e=>{try{let t=new Rl(e);t.hasAttribute("uv")&&t.deleteAttribute("uv"),t.hasAttribute("normal")&&t.deleteAttribute("normal"),i.push(t)}catch(t){se.warn(`[DxfLoader] triangulate shape error: ${e.getPoints().map((e=>e.toArray())).toString()}`)}};n.forEach((t=>{let i=e[t];if(0===i.length)return;let n=new _s(i);a(n)}));let s=e=>e.map((e=>e.toArray()));for(let o of r){let t=new _s(e[o[0]]),i={regions:[],inverted:!1},n=this.findIntersectHole(e,o[1]);n.forEach((n=>{let r={regions:[],inverted:!1};try{n.forEach(((n,a)=>{if(Hl.epsilon(Zt.getVector2RelativeEps(e[n][0]),1e-6),0===a)r=Hl.segments({regions:[s(e[n])],inverted:!1});else{let a=Hl.segments({regions:[s(e[n])],inverted:!1}),o=Hl.combine(r,a);i=Hl.polygon(Hl.selectUnion(o)),i.regions.length>0?i.regions.forEach((e=>{if(0===e.length)return;let i=e.map((e=>new xe(e[0],e[1])));t.holes.push(new Mu(i))})):se.warn("[DxfLoader] mergedHoles.regions is empty")}}))}catch(e){se.warn(`[DxfLoader] polybooljs has error: ${e}, epsilon is ${Hl.epsilon()}`)}}));let r=n.flat(2);for(let a=0;a<o[1].length;a++){let i=o[1][a];r.includes(i)||t.holes.push(new Mu(e[i]))}a(t)}t.children.forEach((t=>{t.children.forEach((t=>{this.buildHatchGeometry(e,t,i)}))}))}findIntersectHole(e,t){let i=t.length,n=[];for(let r=0;r<i;r++){let a=e[t[r]],s=!1,o=[];for(let n=r+1;n<i;n++){let i=e[t[n]];Qt.arePolygonsIntersect(a,i)&&(s=!0,o.push(t[n]))}s&&(o.push(t[r]),n.push(o))}return n}checkAndRebasePolygonsOnRTC(e,t){if(!this.enableRTC||0===e.length)return!1;let i=0;e.forEach((e=>{e.forEach((e=>{t.add(e),i++}))})),t.divideScalar(i);let n=!1;if(this.enableRTC&&Qt.shouldRebasePositionOnRTC(t)){n=!0;for(let i=0;i<e.length;i++){let n=e[i];for(let e=0;e<n.length;e++){let i=n[e].x-t.x,r=n[e].y-t.y;n[e]=new xe(i,r)}}}else t.set(0,0);return n}setRTCUserData(e){e.userData.relativeToCenter=!0,this.statsInfo.rebasedEntityCount++}IsfilteredByPathTypeFlag(e){return e<0}findSpatialFilterByHandle(e,t){let i=t.objects.DICTIONARY;if(!i)return;if(!this.dictionaryOwnerHandleAndSpatialFilterHandlesCache){this.dictionaryOwnerHandleAndSpatialFilterHandlesCache={};for(let e of i){let t=e,i="";for(let e in t.entries)if("ACAD_FILTER"===t.entries[e]){i=e;break}i&&(this.dictionaryOwnerHandleAndSpatialFilterHandlesCache[e.ownerHandle]&&se.warn("[DxfLoader] Why this.dictionaryObjectsCache[obj.ownerHandle] already exist?",e.ownerHandle),this.dictionaryOwnerHandleAndSpatialFilterHandlesCache[e.ownerHandle]=i)}}let n=this.dictionaryOwnerHandleAndSpatialFilterHandlesCache[e];if(n){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]&&se.warn("[DxfLoader] Why this.spatialFiltersCache[spatialFilterObj.ownerHandle] already exist?",n),this.spatialFiltersCache[e.ownerHandle]=e)}}return this.spatialFiltersCache[n]}}initRenderOrderInfo(e){let t=new Set,i=e.objects.DICTIONARY;for(let r of i){let e=r;Object.keys(e.entries).forEach((i=>{e.entries[i]&&"ACAD_SORTENTS"===e.entries[i]&&t.add(i)}))}if(0===t.size)return;let n=e.objects.SORTENTSTABLE;if(n)for(let r=0;r<n.length;++r){let e=n[r];if(t.has(e.handle)){for(let t=0;t<e.sortEntsObject.entityHandles.length;++t){let i=e.sortEntsObject.entityHandles[t];2!==i.length||this.entityHandlesWithRenderOrder[i[0]]?se.warn(`[DxfLoader] Failed to handle sortEntsTable: ${e.handle}.`):this.entityHandlesWithRenderOrder[i[0]]=i[1]}break}}}findMatchedHatchShaderMaterial(e,t){let i=e.patternLines;if(!i||i.length<1)return;let n=(e,t)=>Math.abs(e-t)<1e-5,r=(e,t)=>n(e.angle,t.angle)&&n(e.delta.x,t.delta.x)&&n(e.delta.y,t.delta.y)&&n(e.origin.x,t.origin.x)&&n(e.origin.y,t.origin.y)&&((e,t)=>{if(e.length!==t.length)return!1;for(let i=0;i<e.length;++i)if(!n(e[i],t[i]))return!1;return!0})(e.dashPattern,t.dashPattern),a=this.hatchShaderMaterials.find((n=>n.color===t&&n.patternAngle===e.patternAngle&&((e,t)=>{if(e.length!==t.length)return!1;for(let i=0;i<e.length;++i)if(!r(e[i],t[i]))return!1;return!0})(n.patternLines,i)));return null==a?void 0:a.material}getLayout(e,t){var i,n;if(!this.blockRecordsCache){this.blockRecordsCache={};let t=this.blockRecordsCache,r=null==(n=null==(i=e.tables)?void 0:i.blockRecord)?void 0:n.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):(se.warn("[DxfLoader] Failed to find layout name for entity:",t),e.objects.LAYOUT.find((e=>e.layoutName===Kn.MODEL_LAYOUT_NAME)))}getLayerVisible(e,t){var i,n,r;let a=null==(n=null==(i=e.tables)?void 0:i.layer)?void 0:n.layers;return a&&(null==(r=a[t])?void 0:r.visible)}getLayerFrozen(e,t){var i,n,r;let a=null==(n=null==(i=e.tables)?void 0:i.layer)?void 0:n.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 i;return Array.isArray(e)?(i=[],e.forEach((e=>{if(t.has(e.id))i.push(t.get(e.id));else{let n=e.clone();Kn.updateMaterialUniforms(n),t.set(e.id,n),i.push(n)}}))):e&&(t.has(e.id)?i=t.get(e.id):(i=e.clone(),Kn.updateMaterialUniforms(i),t.set(e.id,i))),i})(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:se.warn(`[DxfLoader] Unsupported $INSUNITS '${e}'`)}return"Unitless"}static computeLineDistance(e){let t=!0===e.isLineSegments,i=e.geometry,n=e.matrixWorld;if(i.index&&(se.debug(`[DxfLoader] Line with id '${e.id}' contains index buffer, going to convert it to non-indexed.`),i=Qt.convertGeometryWithIndexedToNonIndexed(i),e.userData.batches&&e.userData.batches.length>0)){se.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===i.index){let r=i.attributes.position;if(!r||0===r.count)return;let a=[];if(t)for(let e=0,t=r.count;e<t;e+=2)Zn.fromBufferAttribute(r,e).applyMatrix4(n),_i.fromBufferAttribute(r,e+1).applyMatrix4(n),a[e]=0===e?0:a[e-1],a[e+1]=a[e]+Zn.distanceTo(_i);else{a[0]=0;for(let e=1,t=r.count;e<t;e++)Zn.fromBufferAttribute(r,e-1).applyMatrix4(n),_i.fromBufferAttribute(r,e).applyMatrix4(n),a[e]=a[e-1],a[e]+=Zn.distanceTo(_i)}i.setAttribute("lineDistance",new Bt(a,1)),e.geometry=i}else se.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 cn&&Kn.computeLineDistance(t)})),se.debug(`[DxfLoader] Computed line distances in ${(Date.now()-t)/1e3}s`)}static mergeDxfObjects(e){let t=Date.now(),i={},n={},r=0,a=0,s=()=>{let e=Date.now();for(let t in i){let e=i[t];Kn.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={},c=[];for(let e of t){if(e.userData.isSnapObject){c.push(e);continue}let t,i=e;for(;i;){if(i.userData.isLayoutLevelObject){t=i;break}i=i.parent}if(!t)continue;let n=t.name;h[n]||(h[n]={object:t,children:[]}),h[n].children.push(e)}for(let e in h){let t=h[e],o=Ic.deepMerge(t.children,t.object,!1,!1,!0),l=o.added,u=o.removed;i[e]||(i[e]={object:t.object,children:[]}),n[e]||(n[e]={object:t.object,children:[]});let d=u.length>15e3;if(d){let e=Date.now();Kn.removeEmptyObjectsFromRemovingMarkedObjects2(u,t.object),a+=Date.now()-e}else r+=u.length;if(u.length===t.children.length)d||u.forEach((t=>{i[e].children.push(t)}));else{let n=u;u.length>=100&&(n=new Set(u));let r=e=>Array.isArray(n)?n.indexOf(e)>=0:n.has(e);for(let a=0;a<t.children.length;a++){let n=t.children[a];r(n)?d||i[e].children.push(n):c.push(n)}}for(let i=0;i<l.length;i++){let t=l[i];c.push(t),n[e].children.push(t)}r>15e3&&s()}e.layersAndObjects[l]=c,se.debug(`[DxfLoader] Merged layer '${l}' in ${(Date.now()-o)/1e3}s`)}r>0&&s();for(let l in n){let t=n[l];e.root.children.find((e=>e.name===l))||e.root.add(t.object),t.children.forEach((e=>{t.object.add(e)})),t.children=[]}se.debug(`[DxfLoader] MergeUtils.deepMerge costed ${Rr.mergeInfo.elapsedTime/1e3}s`),se.debug(`[DxfLoader] The remove operation of deep merge costed ${a/1e3}s`),se.debug(`[DxfLoader] Deep merge totally costed ${(Date.now()-t)/1e3}s`);let o=Rr.mergeInfo;se.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 ft(this,null,(function*(){let i=St.getUpdateProgressFuncAsync(t),n={};e.objects.LAYOUT.forEach((e=>{var t;let i=e;n[i.layoutName]=i,null==(t=i.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];Kn.removeEmptyObjectsFromRemovingMarkedObjects(e.children,e.object),e.children=[]}o=0,l+=Date.now()-e},c=Object.keys(e.layersAndThreejsObjects).length,u=0;for(let t in e.layersAndThreejsObjects){let r=e.layersAndThreejsObjects[t];if(r.length<=1){yield i(++u/c*100);continue}let d=Date.now(),p={},f=[];for(let e of r){if(e.userData.isSnapObject){f.push(e);continue}let t,i=e;for(;i;){if(i.userData.isLayoutLevelObject){t=i;break}i=i.parent}if(!t)continue;let n=t.name;p[n]||(p[n]={object:t,children:[]}),p[n].children.push(e)}let m=Object.keys(p).length,g=0;for(let e in p){let t;if(e!==Kn.MODEL_LAYOUT_NAME){let i=n[e];i.directAssociatedLeafObjectSet||(i.directAssociatedLeafObjectSet=new Set),t=i.directAssociatedLeafObjectSet}let r=p[e],d=Rr.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();Kn.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 i=y;y.length>=100&&(i=new Set(y));let n=e=>Array.isArray(i)?i.indexOf(e)>=0:i.has(e);for(let s=0;s<r.children.length;s++){let i=r.children[s];n(i)?x||a[e].children.push(i):(f.push(i),t&&t.add(i))}}for(let i=0;i<v.length;i++){let n=v[i];Hn.setSharedVariablesOfObject(n),f.push(n),s[e].children.push(n),t&&t.add(n)}o>15e3&&h(),yield i((u+ ++g/m)/c*100)}yield i(++u/c*100),e.layersAndThreejsObjects[t]=f,se.debug(`[DxfLoader] Merged layer '${t}' in ${(Date.now()-d)/1e3}s`)}o>0&&h();for(let t in s){let i=s[t],r=e.threejsObject.children.find((e=>e.name===t));if(r){let e=r.children.find((e=>e.name===Kn.SNAP_GROUP_NAME));if(e&&t!==Kn.MODEL_LAYOUT_NAME){let i=n[t];i.directAssociatedLeafObjectSet||(i.directAssociatedLeafObjectSet=new Set),e.children.forEach((e=>{var t;return null==(t=i.directAssociatedLeafObjectSet)?void 0:t.add(e)}))}}r||e.threejsObject.add(i.object),i.children.forEach((e=>{e.visible||(e.userData.layerVisible=!1),i.object.add(e),e.updateWorldMatrix(!1,!1)})),i.children=[]}se.debug(`[DxfLoader] MergeUtils.deepMerge costed ${Rr.mergeInfo.elapsedTime/1e3}s`),se.debug(`[DxfLoader] The remove operation of deep merge costed ${l/1e3}s`),se.debug(`[DxfLoader] Deep merge totally costed ${(Date.now()-r)/1e3}s`);let d=Rr.mergeInfo;se.debug(`[DxfLoader] Totally merged ${d.removedObjects} objects to ${d.mergedMeshes} meshes, ${d.mergedLines} lines, ${d.mergedPoints} points, ${d.mergedUnknownTypeObjects?d.mergedUnknownTypeObjects+" unknown type,":""} `),i(100)}))}printStatsInfo(){for(let i in this.entityTypesAndTimes)this.entityTypesAndTimes[i].averageTime=this.entityTypesAndTimes[i].totalTime/this.entityTypesAndTimes[i].createCount;se.debug("[DxfLoader] Entity types and cost times in ms:",this.entityTypesAndTimes),se.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&&se.debug(`[DxfLoader] Totally rebased ${this.statsInfo.rebasedEntityCount}(out of ${e}) entities`),this.enableMerge){let e=Rr.mergeInfo;se.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,...i)=>{Object.keys(t).length};t(0,this.statsInfo.unsupportedEntityTypes),t(0,this.statsInfo.unsupportedTextStyles),t(0,this.statsInfo.unsupportedHatchPatterns),this.statsInfo.unsupportedPolylineCount&&se.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,i=0;for(let a in e.layersAndThreejsObjects)e.layersAndThreejsObjects[a].forEach((e=>{e.geometry&&(i++,t.has(e)?console.warn(e):t.add(e))}));let n=new WeakSet,r=0;if(e.threejsObject.traverse((e=>{e.geometry&&(r++,n.has(e)?console.warn(e):n.add(e))})),i!=r)for(let a in e.layersAndThreejsObjects)e.layersAndThreejsObjects[a].forEach((e=>{e.geometry&&(n.has(e)||console.warn(e))}));se.info(`[DxfLoader] The count of layer objects is ${i},The count of layout objects is ${r} `)}static removeEmptyObjectsFromRemovingMarkedObjects(e,t){if(0===e.length)return;let i=e=>{let n=[];for(let i of e){i.userData.validCount=0;let e=i.parent;e&&e!==t&&(void 0===e.userData.validCount&&(e.userData.validCount=e.children.length),0==--e.userData.validCount&&n.push(e))}n.length>0&&i(n)};i(e),this.removeEmptyObjectsFromMark(t)}static removeEmptyObjectsFromMark(e){if(0===e.userData.validCount||Hn.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 i=e=>{let n=[];for(let i of e){i.userData.validCount=0;let e=i.parent;e&&e!==t&&(void 0===e.userData.validCount&&(e.userData.validCount=e.children.length),0==--e.userData.validCount&&n.push(e))}n.length>0&&i(n)};i(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}},gn=Kn;gn.MODEL_LAYOUT_NAME="Model",gn.SNAP_GROUP_NAME="InvisibleObjectGroupForOSnap",gn.SHOW_SNAP_OBJECT=!1,gn.cameraZoomUniform={value:1},gn.viewportScaleUniform={value:1},gn.transformMatrixUniform={value:new et},gn.resolutionUniform={value:new xe},gn.maxFragmentUniforms=1024,gn.abortJobs=!1;var i0e=class extends Ss{constructor(e){var t;super(),this.drawableList=new Zo("compare"),this.viewer=e,this.overlayRender=this.viewer.overlayRender,null==(t=this.overlayRender)||t.addDrawableList(this.drawableList)}drawCompareDrawable(e){let t=[],i=[],n=[];for(let o of Object.values(e)){let e=o.box;e&&("Added"===o.type?t.push(e):"Removed"===o.type?i.push(e):n.push(e))}let r=Qt.mergeBBoxes(t),a=Qt.mergeBBoxes(i),s=Qt.mergeBBoxes(n);this.drawableList.addDrawable(new jm(St.guid(),r)),this.drawableList.addDrawable(new jm(St.guid(),a)),this.drawableList.addDrawable(new jm(St.guid(),s)),this.viewer.enableRender()}setCompareDrawableVisible(e){this.drawableList.getDrawables().forEach((t=>t.visible=e)),this.viewer.enableRender()}};function Uc(e){return(Uc="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 Vl(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function s0e(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function zl(e,t,i){return t&&s0e(e.prototype,t),i&&s0e(e,i),Object.defineProperty(e,"prototype",{writable:!1}),e}function Hc(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function h_(e,t){return(h_=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function Ay(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&&h_(e,t)}function ng(e,t){if(t&&("object"===Uc(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return Hc(e)}function Gl(e){return(Gl=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function Zu(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function M6(e){if(Array.isArray(e))return e}function R6(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function KC(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);i<t;i++)n[i]=e[i];return n}function A6(e,t){if(e){if("string"==typeof e)return KC(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);if("Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i)return Array.from(e);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return KC(e,t)}}function C6(){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 P6(e){return M6(e)||R6(e)||A6(e)||C6()}function a0e(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function o0e(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?a0e(Object(i),!0).forEach((function(t){Zu(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):a0e(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}var bmt={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)}},Emt=function(){function e(t){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Vl(this,e),this.init(t,i)}return zl(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||bmt,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),i=0;i<e;i++)t[i]=arguments[i];return this.forward(t,"log","",!0)}},{key:"warn",value:function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return this.forward(t,"warn","",!0)}},{key:"error",value:function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return this.forward(t,"error","")}},{key:"deprecate",value:function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return this.forward(t,"warn","WARNING DEPRECATED: ",!0)}},{key:"forward",value:function(e,t,i,n){return n&&!this.debug?null:("string"==typeof e[0]&&(e[0]="".concat(i).concat(this.prefix," ").concat(e[0])),this.logger[t](e))}},{key:"create",value:function(t){return new e(this.logger,o0e(o0e({},{prefix:"".concat(this.prefix,":").concat(t,":")}),this.options))}}]),e}(),Ju=new Emt,Xf=function(){function e(){Vl(this,e),this.observers={}}return zl(e,[{key:"on",value:function(e,t){var i=this;return e.split(" ").forEach((function(e){i.observers[e]=i.observers[e]||[],i.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,i=new Array(t>1?t-1:0),n=1;n<t;n++)i[n-1]=arguments[n];this.observers[e]&&[].concat(this.observers[e]).forEach((function(e){e.apply(void 0,i)}));this.observers["*"]&&[].concat(this.observers["*"]).forEach((function(t){t.apply(t,[e].concat(i))}))}}]),e}();function d_(){var e,t,i=new Promise((function(i,n){e=i,t=n}));return i.resolve=e,i.reject=t,i}function l0e(e){return null==e?"":""+e}function _mt(e,t,i){e.forEach((function(e){t[e]&&(i[e]=t[e])}))}function L6(e,t,i){function n(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=n(a.shift());!e[s]&&i&&(e[s]=new i),e=Object.prototype.hasOwnProperty.call(e,s)?e[s]:{}}return r()?{}:{obj:e,k:n(a.shift())}}function c0e(e,t,i){var n=L6(e,t,Object);n.obj[n.k]=i}function Tmt(e,t,i,n){var r=L6(e,t,Object),a=r.obj,s=r.k;a[s]=a[s]||[],n&&(a[s]=a[s].concat(i)),n||a[s].push(i)}function eP(e,t){var i=L6(e,t),n=i.obj,r=i.k;if(n)return n[r]}function u0e(e,t,i){var n=eP(e,i);return void 0!==n?n:eP(t,i)}function _0e(e,t,i){for(var n in t)"__proto__"!==n&&"constructor"!==n&&(n in e?"string"==typeof e[n]||e[n]instanceof String||"string"==typeof t[n]||t[n]instanceof String?i&&(e[n]=t[n]):_0e(e[n],t[n],i):e[n]=t[n]);return e}function Cy(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")}var wmt={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};function Smt(e){return"string"==typeof e?e.replace(/[&<>"'\/]/g,(function(e){return wmt[e]})):e}var nP="undefined"!=typeof window&&window.navigator&&window.navigator.userAgent&&window.navigator.userAgent.indexOf("MSIE")>-1,Mmt=[" ",",","?","!",";"];function Rmt(e,t,i){t=t||"",i=i||"";var n=Mmt.filter((function(e){return t.indexOf(e)<0&&i.indexOf(e)<0}));if(0===n.length)return!0;var r=new RegExp("(".concat(n.map((function(e){return"?"===e?"\\?":e})).join("|"),")")),a=!r.test(e);if(!a){var s=e.indexOf(i);s>0&&!r.test(e.substring(0,s))&&(a=!0)}return a}function h0e(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function JC(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?h0e(Object(i),!0).forEach((function(t){Zu(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):h0e(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}function Amt(e){var t=Cmt();return function(){var i,n=Gl(e);if(t){var r=Gl(this).constructor;i=Reflect.construct(n,arguments,r)}else i=n.apply(this,arguments);return ng(this,i)}}function Cmt(){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 T0e(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:".";if(e){if(e[t])return e[t];for(var n=t.split(i),r=e,a=0;a<n.length;++a){if(!r||"string"==typeof r[n[a]]&&a+1<n.length)return;if(void 0===r[n[a]]){for(var s=2,o=n.slice(a,a+s).join(i),l=r[o];void 0===l&&n.length>a+s;)s++,l=r[o=n.slice(a,a+s).join(i)];if(void 0===l)return;if(t.endsWith(o)){if("string"==typeof l)return l;if(o&&"string"==typeof l[o])return l[o]}var h=n.slice(a+s).join(i);return h?T0e(l,h,i):void 0}r=r[n[a]]}return r}}var Pmt=function(e){Ay(i,Xf);var t=Amt(i);function i(e){var n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{ns:["translation"],defaultNS:"translation"};return Vl(this,i),n=t.call(this),nP&&Xf.call(Hc(n)),n.data=e||{},n.options=r,void 0===n.options.keySeparator&&(n.options.keySeparator="."),void 0===n.options.ignoreJSONStructure&&(n.options.ignoreJSONStructure=!0),n}return zl(i,[{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,i){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},r=void 0!==n.keySeparator?n.keySeparator:this.options.keySeparator,a=void 0!==n.ignoreJSONStructure?n.ignoreJSONStructure:this.options.ignoreJSONStructure,s=[e,t];i&&"string"!=typeof i&&(s=s.concat(i)),i&&"string"==typeof i&&(s=s.concat(r?i.split(r):i)),e.indexOf(".")>-1&&(s=e.split("."));var o=eP(this.data,s);return o||!a||"string"!=typeof i?o:T0e(this.data&&this.data[e]&&this.data[e][t],i,r)}},{key:"addResource",value:function(e,t,i,n){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];i&&(s=s.concat(a?i.split(a):i)),e.indexOf(".")>-1&&(n=t,t=(s=e.split("."))[1]),this.addNamespaces(t),c0e(this.data,s,n),r.silent||this.emit("added",e,t,i,n)}},{key:"addResources",value:function(e,t,i){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{silent:!1};for(var r in i)("string"==typeof i[r]||"[object Array]"===Object.prototype.toString.apply(i[r]))&&this.addResource(e,t,r,i[r],{silent:!0});n.silent||this.emit("added",e,t,i)}},{key:"addResourceBundle",value:function(e,t,i,n,r){var a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{silent:!1},s=[e,t];e.indexOf(".")>-1&&(n=i,i=t,t=(s=e.split("."))[1]),this.addNamespaces(t);var o=eP(this.data,s)||{};n?_0e(o,i,r):o=JC(JC({},o),i),c0e(this.data,s,o),a.silent||this.emit("added",e,t,i)}},{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?JC(JC({},{}),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}}]),i}(),w0e={processors:{},addPostProcessor:function(e){this.processors[e.name]=e},handle:function(e,t,i,n,r){var a=this;return e.forEach((function(e){a.processors[e]&&(t=a.processors[e].process(t,i,n,r))})),t}};function d0e(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function qa(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?d0e(Object(i),!0).forEach((function(t){Zu(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):d0e(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}function Imt(e){var t=Lmt();return function(){var i,n=Gl(e);if(t){var r=Gl(this).constructor;i=Reflect.construct(n,arguments,r)}else i=n.apply(this,arguments);return ng(this,i)}}function Lmt(){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 f0e={},p0e=function(e){Ay(i,Xf);var t=Imt(i);function i(e){var n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return Vl(this,i),n=t.call(this),nP&&Xf.call(Hc(n)),_mt(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,Hc(n)),n.options=r,void 0===n.options.keySeparator&&(n.options.keySeparator="."),n.logger=Ju.create("translator"),n}return zl(i,[{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 i=this.resolve(e,t);return i&&void 0!==i.res}},{key:"extractFromKey",value:function(e,t){var i=void 0!==t.nsSeparator?t.nsSeparator:this.options.nsSeparator;void 0===i&&(i=":");var n=void 0!==t.keySeparator?t.keySeparator:this.options.keySeparator,r=t.ns||this.options.defaultNS||[],a=i&&e.indexOf(i)>-1,s=!(this.options.userDefinedKeySeparator||t.keySeparator||this.options.userDefinedNsSeparator||t.nsSeparator||Rmt(e,i,n));if(a&&!s){var o=e.match(this.interpolator.nestingRegexp);if(o&&o.length>0)return{key:e,namespaces:r};var l=e.split(i);(i!==n||i===n&&this.options.ns.indexOf(l[0])>-1)&&(r=l.shift()),e=l.join(n)}return"string"==typeof r&&(r=[r]),{key:e,namespaces:r}}},{key:"translate",value:function(e,t,n){var r=this;if("object"!==Uc(t)&&this.options.overloadTranslationOptionHandler&&(t=this.options.overloadTranslationOptionHandler(arguments)),t||(t={}),null==e)return"";Array.isArray(e)||(e=[String(e)]);var a=void 0!==t.returnDetails?t.returnDetails:this.options.returnDetails,s=void 0!==t.keySeparator?t.keySeparator:this.options.keySeparator,o=this.extractFromKey(e[e.length-1],t),l=o.key,h=o.namespaces,c=h[h.length-1],u=t.lng||this.language,d=t.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(u&&"cimode"===u.toLowerCase()){if(d){var p=t.nsSeparator||this.options.nsSeparator;return a?(f.res="".concat(c).concat(p).concat(l),f):"".concat(c).concat(p).concat(l)}return a?(f.res=l,f):l}var f=this.resolve(e,t),m=f&&f.res,g=f&&f.usedKey||l,v=f&&f.exactUsedKey||l,y=Object.prototype.toString.apply(m),x=void 0!==t.joinArrays?t.joinArrays:this.options.joinArrays,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,qa(qa({},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,qa(qa({},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,n));else{var A=!1,C=!1,P=void 0!==t.count&&"string"!=typeof t.count,R=i.hasDefaultValue(t),D=P?this.pluralResolver.getSuffix(u,t.count,t):"",L=t["defaultValue".concat(D)]||t.defaultValue;!this.isValidLookup(m)&&R&&(A=!0,m=L),this.isValidLookup(m)||(C=!0,m=l);var I=(t.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&C?void 0:m,O=R&&L!==m&&this.options.updateMissing;if(C||A||O){if(this.logger.log(O?"updateKey":"missingKey",u,c,l,O?L:m),s){var k=this.resolve(l,qa(qa({},t),{},{keySeparator:!1}));k&&k.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,i,n){var a=R&&n!==m?n:I;r.options.missingKeyHandler?r.options.missingKeyHandler(e,c,i,a,O,t):r.backendConnector&&r.backendConnector.saveMissing&&r.backendConnector.saveMissing(e,c,i,a,O,t),r.emit("missingKey",e,c,i,m)};this.options.saveMissing&&(this.options.saveMissingPlurals&&P?N.forEach((function(e){r.pluralResolver.getSuffixes(e,t).forEach((function(i){B([e],l+i,t["defaultValue".concat(i)]||L)}))})):B(N,l,L))}m=this.extendTranslation(m,e,t,f,n),C&&m===l&&this.options.appendNamespaceToMissingKey&&(m="".concat(c,":").concat(l)),(C||A)&&this.options.parseMissingKeyHandler&&(m="v1"!==this.options.compatibilityAPI?this.options.parseMissingKeyHandler(l,A?m:void 0):this.options.parseMissingKeyHandler(m))}return a?(f.res=m,f):m}},{key:"extendTranslation",value:function(e,t,i,n,r){var a=this;if(this.i18nFormat&&this.i18nFormat.parse)e=this.i18nFormat.parse(e,qa(qa({},this.options.interpolation.defaultVariables),i),n.usedLng,n.usedNS,n.usedKey,{resolved:n});else if(!i.skipInterpolation){i.interpolation&&this.interpolator.init(qa(qa({},i),{interpolation:qa(qa({},this.options.interpolation),i.interpolation)}));var s,o="string"==typeof e&&(i&&i.interpolation&&void 0!==i.interpolation.skipOnVariables?i.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);if(o){var l=e.match(this.interpolator.nestingRegexp);s=l&&l.length}var h=i.replace&&"string"!=typeof i.replace?i.replace:i;if(this.options.interpolation.defaultVariables&&(h=qa(qa({},this.options.interpolation.defaultVariables),h)),e=this.interpolator.interpolate(e,h,i.lng||this.language,i),o){var c=e.match(this.interpolator.nestingRegexp);s<(c&&c.length)&&(i.nest=!1)}!1!==i.nest&&(e=this.interpolator.nest(e,(function(){for(var e=arguments.length,n=new Array(e),s=0;s<e;s++)n[s]=arguments[s];return r&&r[0]===n[0]&&!i.context?(a.logger.warn("It seems you are nesting recursively key: ".concat(n[0]," in key: ").concat(t[0])),null):a.translate.apply(a,n.concat([t]))}),i)),i.interpolation&&this.interpolator.reset()}var u=i.postProcess||this.options.postProcess,d="string"==typeof u?[u]:u;return null!=e&&d&&d.length&&!1!==i.applyPostProcessor&&(e=w0e.handle(d,e,t,this.options&&this.options.postProcessPassResolved?qa({i18nResolved:n},i):i,this)),e}},{key:"resolve",value:function(e){var t,i,n,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;i=h;var c=l.namespaces;s.options.fallbackNS&&(c=c.concat(s.options.fallbackNS));var u=void 0!==o.count&&"string"!=typeof o.count,d=u&&!o.ordinal&&0===o.count&&s.pluralResolver.shouldUseIntlApi(),p=void 0!==o.context&&("string"==typeof o.context||"number"==typeof o.context)&&""!==o.context,f=o.lngs?o.lngs:s.languageUtils.toResolveHierarchy(o.lng||s.language,o.fallbackLng);c.forEach((function(e){s.isValidLookup(t)||(a=e,!f0e["".concat(f[0],"-").concat(e)]&&s.utils&&s.utils.hasLoadedNamespace&&!s.utils.hasLoadedNamespace(a)&&(f0e["".concat(f[0],"-").concat(e)]=!0,s.logger.warn('key "'.concat(i,'" 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(i){if(!s.isValidLookup(t)){r=i;var a,l=[h];if(s.i18nFormat&&s.i18nFormat.addLookupKeys)s.i18nFormat.addLookupKeys(l,h,i,e,o);else{var c;u&&(c=s.pluralResolver.getSuffix(i,o.count,o));var f="_zero";if(u&&(l.push(h+c),d&&l.push(h+f)),p){var m="".concat(h).concat(s.options.contextSeparator).concat(o.context);l.push(m),u&&(l.push(m+c),d&&l.push(m+f))}}for(;a=l.pop();)s.isValidLookup(t)||(n=a,t=s.getResource(i,e,a,o))}})))}))}})),{res:t,usedKey:i,exactUsedKey:n,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,i){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return this.i18nFormat&&this.i18nFormat.getResource?this.i18nFormat.getResource(e,t,i,n):this.resourceStore.getResource(e,t,i,n)}}],[{key:"hasDefaultValue",value:function(e){var t="defaultValue";for(var i in e)if(Object.prototype.hasOwnProperty.call(e,i)&&t===i.substring(0,12)&&void 0!==e[i])return!0;return!1}}]),i}();function I6(e){return e.charAt(0).toUpperCase()+e.slice(1)}var Dmt=function(){function e(t){Vl(this,e),this.options=t,this.supportedLngs=this.options.supportedLngs||!1,this.logger=Ju.create("languageUtils")}return zl(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"],i=e.split("-");return this.options.lowerCaseLng?i=i.map((function(e){return e.toLowerCase()})):2===i.length?(i[0]=i[0].toLowerCase(),i[1]=i[1].toUpperCase(),t.indexOf(i[1].toLowerCase())>-1&&(i[1]=I6(i[1].toLowerCase()))):3===i.length&&(i[0]=i[0].toLowerCase(),2===i[1].length&&(i[1]=i[1].toUpperCase()),"sgn"!==i[0]&&2===i[2].length&&(i[2]=i[2].toUpperCase()),t.indexOf(i[1].toLowerCase())>-1&&(i[1]=I6(i[1].toLowerCase())),t.indexOf(i[2].toLowerCase())>-1&&(i[2]=I6(i[2].toLowerCase()))),i.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,i=this;return e?(e.forEach((function(e){if(!t){var n=i.formatLanguageCode(e);(!i.options.supportedLngs||i.isSupportedCode(n))&&(t=n)}})),!t&&this.options.supportedLngs&&e.forEach((function(e){if(!t){var n=i.getLanguagePartFromCode(e);if(i.isSupportedCode(n))return t=n;t=i.options.supportedLngs.find((function(e){if(0===e.indexOf(n))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 i=e[t];return i||(i=e[this.getScriptPartFromCode(t)]),i||(i=e[this.formatLanguageCode(t)]),i||(i=e[this.getLanguagePartFromCode(t)]),i||(i=e.default),i||[]}},{key:"toResolveHierarchy",value:function(e,t){var i=this,n=this.getFallbackCodes(t||this.options.fallbackLng||[],e),r=[],a=function(e){e&&(i.isSupportedCode(e)?r.push(e):i.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)),n.forEach((function(e){r.indexOf(e)<0&&a(i.formatLanguageCode(e))})),r}}]),e}(),Omt=[{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}],kmt={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)}},Fmt=["v1","v2","v3"],m0e={zero:0,one:1,two:2,few:3,many:4,other:5};function Nmt(){var e={};return Omt.forEach((function(t){t.lngs.forEach((function(i){e[i]={numbers:t.nr,plurals:kmt[t.fc]}}))})),e}var Bmt=function(){function e(t){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Vl(this,e),this.languageUtils=t,this.options=i,this.logger=Ju.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=Nmt()}return zl(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]:{},i=this.getRule(e,t);return this.shouldUseIntlApi()?i&&i.resolvedOptions().pluralCategories.length>1:i&&i.numbers.length>1}},{key:"getPluralFormsOfKey",value:function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.getSuffixes(e,i).map((function(e){return"".concat(t).concat(e)}))}},{key:"getSuffixes",value:function(e){var t=this,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=this.getRule(e,i);return n?this.shouldUseIntlApi()?n.resolvedOptions().pluralCategories.sort((function(e,t){return m0e[e]-m0e[t]})).map((function(e){return"".concat(t.options.prepend).concat(e)})):n.numbers.map((function(n){return t.getSuffix(e,n,i)})):[]}},{key:"getSuffix",value:function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=this.getRule(e,i);return n?this.shouldUseIntlApi()?"".concat(this.options.prepend).concat(n.select(t)):this.getSuffixRetroCompatible(n,t):(this.logger.warn("no plural rule found for: ".concat(e)),"")}},{key:"getSuffixRetroCompatible",value:function(e,t){var i=this,n=e.noAbs?e.plurals(t):e.plurals(Math.abs(t)),r=e.numbers[n];this.options.simplifyPluralSuffix&&2===e.numbers.length&&1===e.numbers[0]&&(2===r?r="plural":1===r&&(r=""));var a=function(){return i.options.prepend&&r.toString()?i.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&&n.toString()?this.options.prepend+n.toString():n.toString()}},{key:"shouldUseIntlApi",value:function(){return!Fmt.includes(this.options.compatibilityJSON)}}]),e}();function g0e(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function Vc(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?g0e(Object(i),!0).forEach((function(t){Zu(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):g0e(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}var Umt=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Vl(this,e),this.logger=Ju.create("interpolator"),this.options=t,this.format=t.interpolation&&t.interpolation.format||function(e){return e},this.init(t)}return zl(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:Smt,this.escapeValue=void 0===t.escapeValue||t.escapeValue,this.useRawValueToEscape=void 0!==t.useRawValueToEscape&&t.useRawValueToEscape,this.prefix=t.prefix?Cy(t.prefix):t.prefixEscaped||"{{",this.suffix=t.suffix?Cy(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?Cy(t.nestingPrefix):t.nestingPrefixEscaped||Cy("$t("),this.nestingSuffix=t.nestingSuffix?Cy(t.nestingSuffix):t.nestingSuffixEscaped||Cy(")"),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 i="".concat(this.nestingPrefix,"(.+?)").concat(this.nestingSuffix);this.nestingRegexp=new RegExp(i,"g")}},{key:"interpolate",value:function(e,t,i,n){var r,a,s,o=this,l=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{};function h(e){return e.replace(/\$/g,"$$$$")}var c=function(e){if(e.indexOf(o.formatSeparator)<0){var r=u0e(t,l,e);return o.alwaysFormat?o.format(r,void 0,i,Vc(Vc(Vc({},n),t),{},{interpolationkey:e})):r}var a=e.split(o.formatSeparator),s=a.shift().trim(),h=a.join(o.formatSeparator).trim();return o.format(u0e(t,l,s),h,i,Vc(Vc(Vc({},n),t),{},{interpolationkey:s}))};this.resetRegExp();var u=n&&n.missingInterpolationHandler||this.options.missingInterpolationHandler,d=n&&n.interpolation&&void 0!==n.interpolation.skipOnVariables?n.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 i=r[1].trim();if(void 0===(a=c(i)))if("function"==typeof u){var l=u(e,r,n);a="string"==typeof l?l:""}else if(n&&n.hasOwnProperty(i))a="";else{if(d){a=r[0];continue}o.logger.warn("missed to pass in variable ".concat(i," for interpolating ").concat(e)),a=""}else"string"!=typeof a&&!o.useRawValueToEscape&&(a=l0e(a));var h=t.safeValue(a);if(e=e.replace(r[0],h),d?(t.regex.lastIndex+=h.length,t.regex.lastIndex-=r[0].length):t.regex.lastIndex=0,++s>=o.maxReplaces)break}})),e}},{key:"nest",value:function(e,t){var i,n,r=this,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},s=Vc({},a);function o(e,t){var i=this.nestingOptionsSeparator;if(e.indexOf(i)<0)return e;var n=e.split(new RegExp("".concat(i,"[ ]*{"))),r="{".concat(n[1]);e=n[0],r=(r=this.interpolate(r,s)).replace(/'/g,'"');try{s=JSON.parse(r),t&&(s=Vc(Vc({},t),s))}catch(t){return this.logger.warn("failed parsing options string in nesting for key ".concat(e),t),"".concat(e).concat(i).concat(r)}return delete s.defaultValue,e}for(s.applyPostProcessor=!1,delete s.defaultValue;i=this.nestingRegexp.exec(e);){var l=[],h=!1;if(-1!==i[0].indexOf(this.formatSeparator)&&!/{.*}/.test(i[1])){var c=i[1].split(this.formatSeparator).map((function(e){return e.trim()}));i[1]=c.shift(),l=c,h=!0}if((n=t(o.call(this,i[1].trim(),s),s))&&i[0]===e&&"string"!=typeof n)return n;"string"!=typeof n&&(n=l0e(n)),n||(this.logger.warn("missed to resolve ".concat(i[1]," for nesting ").concat(e)),n=""),h&&(n=l.reduce((function(e,t){return r.format(e,t,a.lng,Vc(Vc({},a),{},{interpolationkey:i[1].trim()}))}),n.trim())),e=e.replace(i[0],n),this.regexp.lastIndex=0}return e}}]),e}();function v0e(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function jf(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?v0e(Object(i),!0).forEach((function(t){Zu(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):v0e(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}function Hmt(e){var t=e.toLowerCase().trim(),i={};if(e.indexOf("(")>-1){var n=e.split("(");t=n[0].toLowerCase().trim();var r=n[1].substring(0,n[1].length-1);"currency"===t&&r.indexOf(":")<0?i.currency||(i.currency=r.trim()):"relativetime"===t&&r.indexOf(":")<0?i.range||(i.range=r.trim()):r.split(";").forEach((function(e){if(e){var t=P6(e.split(":")),n=t[0],r=t.slice(1).join(":");i[n.trim()]||(i[n.trim()]=r.trim()),"false"===r.trim()&&(i[n.trim()]=!1),"true"===r.trim()&&(i[n.trim()]=!0),isNaN(r.trim())||(i[n.trim()]=parseInt(r.trim(),10))}}))}return{formatName:t,formatOptions:i}}var Vmt=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Vl(this,e),this.logger=Ju.create("formatter"),this.options=t,this.formats={number:function(e,t,i){return new Intl.NumberFormat(t,i).format(e)},currency:function(e,t,i){return new Intl.NumberFormat(t,jf(jf({},i),{},{style:"currency"})).format(e)},datetime:function(e,t,i){return new Intl.DateTimeFormat(t,jf({},i)).format(e)},relativetime:function(e,t,i){return new Intl.RelativeTimeFormat(t,jf({},i)).format(e,i.range||"day")},list:function(e,t,i){return new Intl.ListFormat(t,jf({},i)).format(e)}},this.init(t)}return zl(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:"format",value:function(e,t,i,n){var r=this;return t.split(this.formatSeparator).reduce((function(e,t){var a=Hmt(t),s=a.formatName,o=a.formatOptions;if(r.formats[s]){var l=e;try{var h=n&&n.formatParams&&n.formatParams[n.interpolationkey]||{},c=h.locale||h.lng||n.locale||n.lng||i;l=r.formats[s](e,c,jf(jf(jf({},o),n),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 y0e(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function x0e(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?y0e(Object(i),!0).forEach((function(t){Zu(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):y0e(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}function zmt(e){var t=Gmt();return function(){var i,n=Gl(e);if(t){var r=Gl(this).constructor;i=Reflect.construct(n,arguments,r)}else i=n.apply(this,arguments);return ng(this,i)}}function Gmt(){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 qmt(e,t){delete e.pending[t],e.pendingCount--}var Wmt=function(e){Ay(i,Xf);var t=zmt(i);function i(e,n,r){var a,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return Vl(this,i),a=t.call(this),nP&&Xf.call(Hc(a)),a.backend=e,a.store=n,a.services=r,a.languageUtils=r.languageUtils,a.options=s,a.logger=Ju.create("backendConnector"),a.waitingReads=[],a.maxParallelReads=s.maxParallelReads||10,a.readingCalls=0,a.state={},a.queue=[],a.backend&&a.backend.init&&a.backend.init(r,s.backend,s),a}return zl(i,[{key:"queueLoad",value:function(e,t,i,n){var r=this,a={},s={},o={},l={};return e.forEach((function(e){var n=!0;t.forEach((function(t){var o="".concat(e,"|").concat(t);!i.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,n=!1,void 0===s[o]&&(s[o]=!0),void 0===a[o]&&(a[o]=!0),void 0===l[t]&&(l[t]=!0)))})),n||(o[e]=!0)})),(Object.keys(a).length||Object.keys(s).length)&&this.queue.push({pending:s,pendingCount:Object.keys(s).length,loaded:{},errors:[],callback:n}),{toLoad:Object.keys(a),pending:Object.keys(s),toLoadLanguages:Object.keys(o),toLoadNamespaces:Object.keys(l)}}},{key:"loaded",value:function(e,t,i){var n=e.split("|"),r=n[0],a=n[1];t&&this.emit("failedLoading",r,a,t),i&&this.store.addResourceBundle(r,a,i),this.state[e]=t?-1:2;var s={};this.queue.forEach((function(i){Tmt(i.loaded,[r],a),qmt(i,e),t&&i.errors.push(t),0===i.pendingCount&&!i.done&&(Object.keys(i.loaded).forEach((function(e){s[e]||(s[e]={});var t=Object.keys(s[e]);t.length&&t.forEach((function(i){void 0!==t[i]&&(s[e][i]=!0)}))})),i.done=!0,i.errors.length?i.callback(i.errors):i.callback())})),this.emit("loaded",s),this.queue=this.queue.filter((function(e){return!e.done}))}},{key:"read",value:function(e,t,i){var n=this,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:350,s=arguments.length>5?arguments[5]:void 0;return e.length?this.readingCalls>=this.maxParallelReads?void this.waitingReads.push({lng:e,ns:t,fcName:i,tried:r,wait:a,callback:s}):(this.readingCalls++,this.backend[i](e,t,(function(o,l){if(o&&l&&r<5)setTimeout((function(){n.read.call(n,e,t,i,r+1,2*a,s)}),a);else{if(n.readingCalls--,n.waitingReads.length>0){var h=n.waitingReads.shift();n.read(h.lng,h.ns,h.fcName,h.tried,h.wait,h.callback)}s(o,l)}}))):s(null,{})}},{key:"prepareLoading",value:function(e,t){var i=this,n=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,n,r);if(!a.toLoad.length)return a.pending.length||r(),null;a.toLoad.forEach((function(e){i.loadOne(e)}))}},{key:"load",value:function(e,t,i){this.prepareLoading(e,t,{},i)}},{key:"reload",value:function(e,t,i){this.prepareLoading(e,t,{reload:!0},i)}},{key:"loadOne",value:function(e){var t=this,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=e.split("|"),r=n[0],a=n[1];this.read(r,a,"read",void 0,void 0,(function(n,s){n&&t.logger.warn("".concat(i,"loading namespace ").concat(a," for language ").concat(r," failed"),n),!n&&s&&t.logger.log("".concat(i,"loaded namespace ").concat(a," for language ").concat(r),s),t.loaded(e,n,s)}))}},{key:"saveMissing",value:function(e,t,i,n,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(i,'" 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==i||""===i||(this.backend&&this.backend.create&&this.backend.create(e,t,i,n,null,x0e(x0e({},a),{},{isUpdate:r})),e&&e[0]&&this.store.addResource(e[0],t,i,n))}}]),i}();function jmt(){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"===Uc(e[1])&&(t=e[1]),"string"==typeof e[1]&&(t.defaultValue=e[1]),"string"==typeof e[2]&&(t.tDescription=e[2]),"object"===Uc(e[2])||"object"===Uc(e[3])){var i=e[3]||e[2];Object.keys(i).forEach((function(e){t[e]=i[e]}))}return t},interpolation:{escapeValue:!0,format:function(e,t,i,n){return e},prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0}}}function b0e(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 E0e(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}function Ku(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?E0e(Object(i),!0).forEach((function(t){Zu(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):E0e(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}function Xmt(e){var t=Ymt();return function(){var i,n=Gl(e);if(t){var r=Gl(this).constructor;i=Reflect.construct(n,arguments,r)}else i=n.apply(this,arguments);return ng(this,i)}}function Ymt(){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 QC(){}function $mt(e){Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach((function(t){"function"==typeof e[t]&&(e[t]=e[t].bind(e))}))}var tP=function(e){Ay(i,Xf);var t=Xmt(i);function i(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0;if(Vl(this,i),e=t.call(this),nP&&Xf.call(Hc(e)),e.options=b0e(n),e.services={},e.logger=Ju,e.modules={external:[]},$mt(Hc(e)),r&&!e.isInitialized&&!n.isClone){if(!e.options.initImmediate)return e.init(n,r),ng(e,Hc(e));setTimeout((function(){e.init(n,r)}),0)}return e}return zl(i,[{key:"init",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=arguments.length>1?arguments[1]:void 0;"function"==typeof t&&(i=t,t={}),!t.defaultNS&&t.ns&&("string"==typeof t.ns?t.defaultNS=t.ns:t.ns.indexOf("translation")<0&&(t.defaultNS=t.ns[0]));var n=jmt();function r(e){return e?"function"==typeof e?new e:e:null}if(this.options=Ku(Ku(Ku({},n),this.options),b0e(t)),"v1"!==this.options.compatibilityAPI&&(this.options.interpolation=Ku(Ku({},n.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?Ju.init(r(this.modules.logger),this.options):Ju.init(null,this.options),this.modules.formatter?a=this.modules.formatter:"undefined"!=typeof Intl&&(a=Vmt);var s=new Dmt(this.options);this.store=new Pmt(this.options.resources,this.options);var o=this.services;o.logger=Ju,o.resourceStore=this.store,o.languageUtils=s,o.pluralResolver=new Bmt(s,{prepend:this.options.pluralSeparator,compatibilityJSON:this.options.compatibilityJSON,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),a&&(!this.options.interpolation.format||this.options.interpolation.format===n.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 Umt(this.options),o.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},o.backendConnector=new Wmt(r(this.modules.backend),o.resourceStore,o,this.options),o.backendConnector.on("*",(function(t){for(var i=arguments.length,n=new Array(i>1?i-1:0),r=1;r<i;r++)n[r-1]=arguments[r];e.emit.apply(e,[t].concat(n))})),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 i=arguments.length,n=new Array(i>1?i-1:0),r=1;r<i;r++)n[r-1]=arguments[r];e.emit.apply(e,[t].concat(n))})),this.modules.external.forEach((function(t){t.init&&t.init(e)}))}if(this.format=this.options.interpolation.format,i||(i=QC),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 i;return(i=e.store)[t].apply(i,arguments)}}));["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach((function(t){e[t]=function(){var i;return(i=e.store)[t].apply(i,arguments),e}}));var h=d_(),c=function(){var t=function(t,n){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(n),i(t,n)};if(e.languages&&"v1"!==e.options.compatibilityAPI&&!e.isInitialized)return t(null,e.t.bind(e));e.changeLanguage(e.options.lng,t)};return this.options.resources||!this.options.initImmediate?c():setTimeout(c,0),h}},{key:"loadResources",value:function(e){var t=this,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:QC,n="string"==typeof e?e:this.language;if("function"==typeof e&&(i=e),!this.options.resources||this.options.partialBundledLanguages){if(n&&"cimode"===n.toLowerCase())return i();var r=[],a=function(e){e&&t.services.languageUtils.toResolveHierarchy(e).forEach((function(e){r.indexOf(e)<0&&r.push(e)}))};if(n)a(n);else 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),i(e)}))}else i(null)}},{key:"reloadResources",value:function(e,t,i){var n=d_();return e||(e=this.languages),t||(t=this.options.ns),i||(i=QC),this.services.backendConnector.reload(e,t,(function(e){n.resolve(),i(e)})),n}},{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&&w0e.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 i=this.languages[t];if(!(["cimode","dev"].indexOf(i)>-1)&&this.store.hasLanguageSomeTranslations(i)){this.resolvedLanguage=i;break}}}},{key:"changeLanguage",value:function(e,t){var i=this;this.isLanguageChangingTo=e;var n=d_();this.emit("languageChanging",e);var r=function(e){i.language=e,i.languages=i.services.languageUtils.toResolveHierarchy(e),i.resolvedLanguage=void 0,i.setResolvedLanguage(e)},a=function(a){!e&&!a&&i.services.languageDetector&&(a=[]);var s="string"==typeof a?a:i.services.languageUtils.getBestMatchFromCodes(a);s&&(i.language||r(s),i.translator.language||i.translator.changeLanguage(s),i.services.languageDetector&&i.services.languageDetector.cacheUserLanguage(s)),i.loadResources(s,(function(e){!function(e,a){a?(r(a),i.translator.changeLanguage(a),i.isLanguageChangingTo=void 0,i.emit("languageChanged",a),i.logger.log("languageChanged",a)):i.isLanguageChangingTo=void 0,n.resolve((function(){return i.t.apply(i,arguments)})),t&&t(e,(function(){return i.t.apply(i,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()),n}},{key:"getFixedT",value:function(e,t,i){var n=this,r=function e(t,r){var a;if("object"!==Uc(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=n.options.overloadTranslationOptionHandler([t,r].concat(o))}else a=Ku({},r);a.lng=a.lng||e.lng,a.lngs=a.lngs||e.lngs,a.ns=a.ns||e.ns;var h=n.options.keySeparator||".",c=i?"".concat(i).concat(h).concat(t):t;return n.t(c,a)};return"string"==typeof e?r.lng=e:r.lngs=e,r.ns=t,r.keyPrefix=i,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,i=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 n=this.resolvedLanguage||this.languages[0],r=!!this.options&&this.options.fallbackLng,a=this.languages[this.languages.length-1];if("cimode"===n.toLowerCase())return!0;var s=function(e,i){var n=t.services.backendConnector.state["".concat(e,"|").concat(i)];return-1===n||2===n};if(i.precheck){var o=i.precheck(this,s);if(void 0!==o)return o}return!!(this.hasResourceBundle(n,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||s(n,e)&&(!r||s(a,e)))}},{key:"loadNamespaces",value:function(e,t){var i=this,n=d_();return this.options.ns?("string"==typeof e&&(e=[e]),e.forEach((function(e){i.options.ns.indexOf(e)<0&&i.options.ns.push(e)})),this.loadResources((function(e){n.resolve(),t&&t(e)})),n):(t&&t(),Promise.resolve())}},{key:"loadLanguages",value:function(e,t){var i=d_();"string"==typeof e&&(e=[e]);var n=this.options.preload||[],r=e.filter((function(e){return n.indexOf(e)<0}));return r.length?(this.options.preload=n.concat(r),this.loadResources((function(e){i.resolve(),t&&t(e)})),i):(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]:{},n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:QC,r=Ku(Ku(Ku({},this.options),t),{isClone:!0}),a=new i(r);return["store","services","language"].forEach((function(t){a[t]=e[t]})),a.services=Ku({},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,i=new Array(t>1?t-1:0),n=1;n<t;n++)i[n-1]=arguments[n];a.emit.apply(a,[e].concat(i))})),a.init(r,n),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}}}]),i}();Zu(tP,"createInstance",(function(){return new tP(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},arguments.length>1?arguments[1]:void 0)}));var Wa=tP.createInstance();Wa.createInstance=tP.createInstance;var NGt=Wa.createInstance,BGt=Wa.init,UGt=Wa.loadResources,HGt=Wa.reloadResources,VGt=Wa.use,zGt=Wa.changeLanguage,GGt=Wa.getFixedT,Qu=Wa.t,qGt=Wa.exists,WGt=Wa.setDefaultNamespace,jGt=Wa.hasLoadedNamespace,XGt=Wa.loadNamespaces,YGt=Wa.loadLanguages,rg=Wa,Yf=class{constructor(e){this.progresseItems=[],this.element=document.createElement("div"),this.element.classList.add("progress-bar"),e.appendChild(this.element)}setVisibility(e){this.element&&(e?this.element.classList.remove("hidden"):this.element.classList.add("hidden"))}addProgressItem(e,t){let i=this.progresseItems.find((t=>t.id===e));if(!i){let n=document.createElement("div");n.classList.add("progress-bar-item"),n.innerHTML=t||"",this.element.append(n),i={id:e,div:n},this.progresseItems.push(i)}this.setVisibility(!0)}updateProgress(e,t,i){let n=this.progresseItems.find((t=>t.id===e));if(!n)return;let r=t?`${t}`:"";t&&null!=i&&(r+=": "),null!=i&&(i<0||i>100?(console.warn(`[ProgressBar] Invalid progress value: ${i}`),r+="--%"):r+=`${i.toFixed(2)}%`),n.div.innerHTML=r}removeProgressItem(e){let t=this.progresseItems.find((t=>t.id===e));t&&t.div.remove(),0===this.progresseItems.length&&this.setVisibility(!1)}delayRemoveProgressItem(e,t=3e3){setTimeout((()=>{this.removeProgressItem(e)}),t)}};function Py(e){return{all:e=e||new Map,on:function(t,i){var n=e.get(t);n?n.push(i):e.set(t,[i])},off:function(t,i){var n=e.get(t);n&&(i?n.splice(n.indexOf(i)>>>0,1):e.set(t,[]))},emit:function(t,i){var n=e.get(t);n&&n.slice().map((function(e){e(i)})),(n=e.get("*"))&&n.slice().map((function(e){e(t,i)}))}}}var rP=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 i=document.createElement("div");i.classList.add("model-layout-switch-bar-content"),i.addEventListener("wheel",this.handleMouseWheel),this.viewer.getLayoutNames().forEach(((e,t)=>{let n=this.createItem(e,t);this.itemList[e]=n,n.resetActivate=()=>{for(let e in this.itemList)this.itemList[e].resetActive()},null==i||i.appendChild(n.element)})),this.element=t,this.content=i,this.element.appendChild(this.content),null==(e=this.viewer.widgetContainer)||e.appendChild(this.element)}createItem(e,t){let i=new D6(this.viewer,e);return 0===t&&i.setActive(!0),i}destroy(){var e,t;for(let i in this.itemList){let t=this.itemList[i];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")}},D6=class{constructor(e,t){this.viewer=e,this.eventBus=Py(),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"),i=document.createElement("span");return t.classList.add("model-layout-switch-item"),t.onclick=()=>{this.active=!this.active,this.eventBus.emit("activechange",this.active)},i.innerText=e,t.appendChild(i),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")}},iP=class{constructor(e,t){this.flyDuration=500,this.autoRotateRemainingTime=0,this.automaticallyAdjustCameraPosition=!0,this.rotateIntervalStartTime=0,this.camera=e,this.controls=t}flyTo(e,t,i){let n=this.camera,r=this.controls;if(!n||!r)return;if(e.equals(t))return void console.error("[Controls] camera position and lookAt cannot be the same!");if(isNaN(e.x)||isNaN(e.y)||isNaN(e.z)||isNaN(t.x)||isNaN(t.y)||isNaN(t.z))return void console.error("[Controls] invalid position or lookAt!");if(this.automaticallyAdjustCameraPosition){let i=e.distanceTo(t);i<n.near?(e=e.clone().sub(t).normalize().multiplyScalar(1.1*n.near),console.warn("[Controls] camera could be too close to see the object!")):i>n.far&&(e=e.clone().sub(t).normalize().multiplyScalar(.9*n.far),console.warn("[Controls] camera could be too far to see the object!"))}let a=n.position.clone(),s=r.target.clone(),o=this.flyDuration,l=Date.now();this.cameraUpdateInterval&&clearInterval(this.cameraUpdateInterval),this.cameraUpdateInterval=setInterval((()=>{let h=Date.now()-l;h>o&&(h=o);let c=(e,t,i)=>{let n=e.x+(t.x-e.x)*i,r=e.y+(t.y-e.y)*i,a=e.z+(t.z-e.z)*i;return new D(n,r,a)};((e,t)=>{n.lookAt(t),n.position.set(e.x,e.y,e.z),r.target.set(t.x,t.y,t.z),r.update()})(c(a,e,h/o),c(s,t,h/o)),h>=o&&(clearInterval(this.cameraUpdateInterval),this.cameraUpdateInterval=void 0,i&&i())}),10)}lookTo(e){let t=this.camera,i=this.controls;if(!t||!i)return;let n=t.position,r=i.target.distanceTo(n),a=e.normalize().multiplyScalar(r),s=new D(n.x+a.x,n.y+a.y,n.z+a.z);this.flyTo(n,s)}startAutoRotate(){let e=this.camera,t=this.controls;if(!e||!t)return;t.autoRotate=!0;let i=new D;e.getWorldPosition(i);let n=t.target;if(n.y===i.y)return;let r=(n.y-i.y)/50;for(let a=0;a<50;++a)setTimeout((()=>{let e=t.target.y-r;t.target.setY(e),t.update()}),30*a)}delayAutoRotate(){this.autoRotateRemainingTime=5e3,this.controls&&(this.controls.autoRotate=!1)}startToRotate(e){let t=Date.now()-this.rotateIntervalStartTime;this.rotateIntervalStartTime=Date.now(),!(this.rotateInterval&&t<100)&&(this.rotateInterval&&clearInterval(this.rotateInterval),this.rotateInterval=setInterval((()=>{if(Date.now()-this.rotateIntervalStartTime>=100)return clearInterval(this.rotateInterval),void(this.rotateInterval=void 0);"ArrowLeft"===e.code||"ArrowRight"===e.code?this.rotateLeftOrRight(.3,"ArrowLeft"===e.code):("ArrowUp"===e.code||"ArrowDown"===e.code)&&this.rotateUpOrDown(.3,"ArrowUp"===e.code)}),1))}rotateLeftOrRight(e,t=!0){let i=this.controls;if(!this.camera||!i)return;let n=this.camera.position,r=i.target,a=r.clone(),s=Math.PI*e/180;t&&(s=-s),a.x=(r.x-n.x)*Math.cos(s)-(r.z-n.z)*Math.sin(s)+n.x,a.z=(r.z-n.z)*Math.cos(s)+(r.x-n.x)*Math.sin(s)+n.z,this.camera.lookAt(a),i.target=a,i.update()}rotateUpOrDown(e,t=!0){let i=this.controls;if(!this.camera||!i)return;let n=this.camera.position,r=i.target,a=r.clone(),s=Math.PI*e/180,o=new D(r.x-n.x,r.y-n.y,r.z-n.z).length(),l=r.y-n.y;t||(s=-s);let h=Math.asin(l/o)+s;if(h<-Math.PI/2||h>Math.PI/2)return;let c=Math.sin(h)*o;a.y=r.y+(c-l),i.target=a,i.update()}},S0e=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,i={},n=[];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(i);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)&&es.materialsEquals(t.material,h.material)){i[l]||(i[l]={indexes:[l]},this.removeFromArray(n,l)),i[l].indexes.push(s),r=!0;break}}for(let o=n.length-1;!r&&o>=0;--o){let a=n[o],l=e.children[a];if(this.geometryEquals(t.geometry,l.geometry)&&es.materialsEquals(t.material,l.material)){i[a]||(i[a]={indexes:[a]},this.removeFromArray(n,a)),i[a].indexes.push(s),r=!0;break}}r||n.push(s)}if(Object.keys(i).length<=0)return;let r=[],a=[];Object.values(i).forEach((t=>{let i=t.indexes;a.push(...i);let n=e.children[i[0]],s=n.material;if(s instanceof yr)s=s.clone();else if(Array.isArray(s)){let e=[];s.forEach((t=>e.push(t.clone()))),s=e}let o=new Oi(n.geometry,s,i.length);o.name=`[Instanced] ${n.name}`;for(let r=0;r<i.length;++r){let t=i[r],n=e.children[t];n.updateMatrix(),o.setMatrixAt(r,n.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 i=e.length-1;i>=0;--i)if(e[i]===t)return void e.splice(i,1)}geometryEquals(e,t){return Qt.geometryEquals(e,t)}},$f=class{constructor(){this.TIMEOUT="timeout",this.INTERVAL="interval",this.timeoutMap={},this.intervalMap={}}run(e=this.INTERVAL,t,i=16.7){let n=Date.now,r=n(),a=r,s=Symbol(""),o=()=>{this.setIdMap(s,e,o),a=n(),a-r>=i&&(e===this.intervalMap&&(r=n(),a=r),t(),e===this.TIMEOUT&&this.clearTimeout(s))};return this.setIdMap(s,e,o),s}setIdMap(e,t,i){let n=requestAnimationFrame(i);t===this.INTERVAL?this.intervalMap[e]=n:t===this.TIMEOUT&&(this.timeoutMap[e]=n)}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])}},f_=class extends Rm{constructor(e){super(e)}parse(e){if(e.length<19)throw new Error("THREE.TGALoader: Not enough data to contain header.");let t=0,i=new Uint8Array(e),n={id_length:i[t++],colormap_type:i[t++],image_type:i[t++],colormap_index:i[t++]|i[t++]<<8,colormap_length:i[t++]|i[t++]<<8,colormap_size:i[t++],origin:[i[t++]|i[t++]<<8,i[t++]|i[t++]<<8],width:i[t++]|i[t++]<<8,height:i[t++]|i[t++]<<8,pixel_size:i[t++],flags:i[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)}(n),n.id_length+t>e.length)throw new Error("THREE.TGALoader: No data.");t+=n.id_length;let r=!1,a=!1,s=!1;switch(n.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(n.width*n.height*4),l=function(e,t,i,n,r){let a,s,o=i.pixel_size>>3,l=i.width*i.height*o;if(t&&(s=r.subarray(n,n+=i.colormap_length*(i.colormap_size>>3))),e){a=new Uint8Array(l);let e,t,i,s=0,h=new Uint8Array(o);for(;s<l;)if(e=r[n++],t=1+(127&e),128&e){for(i=0;i<o;++i)h[i]=r[n++];for(i=0;i<t;++i)a.set(h,s+i*o);s+=o*t}else{for(t*=o,i=0;i<t;++i)a[s+i]=r[n++];s+=t}}else a=r.subarray(n,n+=t?i.width*i.height:l);return{pixel_data:a,palettes:s}}(r,a,n,t,i);return function(e,t,i,r,a){let o,l,h,c,u,d;switch((48&n.flags)>>4){default:case 2:o=0,h=1,u=t,l=0,c=1,d=i;break;case 0:o=0,h=1,u=t,l=i-1,c=-1,d=-1;break;case 3:o=t-1,h=-1,u=-1,l=0,c=1,d=i;break;case 1:o=t-1,h=-1,u=-1,l=i-1,c=-1,d=-1}if(s)switch(n.pixel_size){case 8:!function(e,t,i,r,a,s,o,l){let h,c,u,d=0,p=n.width;for(u=t;u!==r;u+=i)for(c=a;c!==o;c+=s,d++)h=l[d],e[4*(c+p*u)+0]=h,e[4*(c+p*u)+1]=h,e[4*(c+p*u)+2]=h,e[4*(c+p*u)+3]=255}(e,l,c,d,o,h,u,r);break;case 16:!function(e,t,i,r,a,s,o,l){let h,c,u=0,d=n.width;for(c=t;c!==r;c+=i)for(h=a;h!==o;h+=s,u+=2)e[4*(h+d*c)+0]=l[u+0],e[4*(h+d*c)+1]=l[u+0],e[4*(h+d*c)+2]=l[u+0],e[4*(h+d*c)+3]=l[u+1]}(e,l,c,d,o,h,u,r);break;default:throw new Error("THREE.TGALoader: Format not supported.")}else switch(n.pixel_size){case 8:!function(e,t,i,r,a,s,o,l,h){let c,u,d,p=h,f=0,m=n.width;for(d=t;d!==r;d+=i)for(u=a;u!==o;u+=s,f++)c=l[f],e[4*(u+m*d)+3]=255,e[4*(u+m*d)+2]=p[3*c+0],e[4*(u+m*d)+1]=p[3*c+1],e[4*(u+m*d)+0]=p[3*c+2]}(e,l,c,d,o,h,u,r,a);break;case 16:!function(e,t,i,r,a,s,o,l){let h,c,u,d=0,p=n.width;for(u=t;u!==r;u+=i)for(c=a;c!==o;c+=s,d+=2)h=l[d+0]+(l[d+1]<<8),e[4*(c+p*u)+0]=(31744&h)>>7,e[4*(c+p*u)+1]=(992&h)>>2,e[4*(c+p*u)+2]=(31&h)<<3,e[4*(c+p*u)+3]=32768&h?0:255}(e,l,c,d,o,h,u,r);break;case 24:!function(e,t,i,r,a,s,o,l){let h,c,u=0,d=n.width;for(c=t;c!==r;c+=i)for(h=a;h!==o;h+=s,u+=3)e[4*(h+d*c)+3]=255,e[4*(h+d*c)+2]=l[u+0],e[4*(h+d*c)+1]=l[u+1],e[4*(h+d*c)+0]=l[u+2]}(e,l,c,d,o,h,u,r);break;case 32:!function(e,t,i,r,a,s,o,l){let h,c,u=0,d=n.width;for(c=t;c!==r;c+=i)for(h=a;h!==o;h+=s,u+=4)e[4*(h+d*c)+2]=l[u+0],e[4*(h+d*c)+1]=l[u+1],e[4*(h+d*c)+0]=l[u+2],e[4*(h+d*c)+3]=l[u+3]}(e,l,c,d,o,h,u,r);break;default:throw new Error("THREE.TGALoader: Format not supported.")}}(o,n.width,n.height,l.pixel_data,l.palettes),{data:o,width:n.width,height:n.height,flipY:!0,generateMipmaps:!0,minFilter:Fa}}},sP=class extends Er{constructor(e){super(e)}load(e,t,i,n){let r=this,a=""===r.path?ta.extractUrlBase(e):r.path,s=new Kr(r.manager);s.setPath(r.path),s.setRequestHeader(r.requestHeader),s.setWithCredentials(r.withCredentials),s.load(e,(function(i){try{t(r.parse(i,a))}catch(t){n?n(t):console.error(t),r.manager.itemError(e)}}),i,n)}parse(e,t){function i(e,t){let i=[],n=e.childNodes;for(let r=0,a=n.length;r<a;r++){let e=n[r];e.nodeName===t&&i.push(e)}return i}function n(e){if(0===e.length)return[];let t=e.trim().split(/\s+/),i=new Array(t.length);for(let n=0,r=t.length;n<r;n++)i[n]=t[n];return i}function r(e){if(0===e.length)return[];let t=e.trim().split(/\s+/),i=new Array(t.length);for(let n=0,r=t.length;n<r;n++)i[n]=parseFloat(t[n]);return i}function a(e){if(0===e.length)return[];let t=e.trim().split(/\s+/),i=new Array(t.length);for(let n=0,r=t.length;n<r;n++)i[n]=parseInt(t[n]);return i}function s(e){return e.substring(1)}function o(e){return 0===Object.keys(e).length}function l(e,t,n,r){let a=i(e,t)[0];if(void 0!==a){let e=i(a,n);for(let t=0;t<e.length;t++)r(e[t])}}function h(e,t){for(let i in e)e[i].build=t(e[i])}function c(e,t){return void 0!==e.build||(e.build=t(e)),e.build}function u(e){let t={inputs:{}};for(let i=0,n=e.childNodes.length;i<n;i++){let n=e.childNodes[i];if(1===n.nodeType&&"input"===n.nodeName){let e=s(n.getAttribute("source")),i=n.getAttribute("semantic");t.inputs[i]=e}}return t}function d(e){let t={},i=e.getAttribute("target").split("/"),n=i.shift(),r=i.shift(),a=-1!==r.indexOf("("),o=-1!==r.indexOf(".");if(o)i=r.split("."),r=i.shift(),t.member=i.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=n,t.sid=r,t.arraySyntax=a,t.memberSyntax=o,t.sampler=s(e.getAttribute("source")),t}function p(e){let t=[],i=e.channels,n=e.samplers,r=e.sources;for(let a in i)if(i.hasOwnProperty(a)){let e=i[a],s=n[e.sampler],o=s.inputs.INPUT,l=s.inputs.OUTPUT;x(m(e,r[o],r[l]),t)}return t}function f(e){return c($e.animations[e],p)}function m(e,t,i){let n,r,a,s,o,l,h=$e.nodes[e.id],c=Ue(h.id),u=h.transforms[e.sid],d=h.matrix.clone().transpose(),p={};switch(u){case"matrix":for(a=0,s=t.array.length;a<s;a++)if(n=t.array[a],r=a*i.stride,void 0===p[n]&&(p[n]={}),!0===e.arraySyntax){let t=i.array[r],a=e.indices[0]+4*e.indices[1];p[n][a]=t}else for(o=0,l=i.stride;o<l;o++)p[n][o]=i.array[r+o];break;case"translate":case"rotate":case"scale":console.warn('THREE.ColladaLoader: Animation transform type "%s" not yet implemented.',u)}let f=function(e,t){let i=[];for(let n in e)i.push({time:parseFloat(n),value:e[n]});i.sort((function(e,t){return e.time-t.time}));for(let n=0;n<16;n++)b(i,n,t.elements[n]);return i}(p,d);return{name:c.uuid,keyframes:f}}let g=new D,v=new D,y=new dr;function x(e,t){let i=e.keyframes,n=e.name,r=[],a=[],s=[],o=[];for(let l=0,h=i.length;l<h;l++){let e=i[l],t=e.time,n=e.value;Te.fromArray(n).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 Va(n+".position",r,a)),s.length>0&&t.push(new Ha(n+".quaternion",r,s)),o.length>0&&t.push(new Va(n+".scale",r,o)),t}function b(e,t,i){let n,r,a,s=!0;for(r=0,a=e.length;r<a;r++)n=e[r],void 0===n.value[t]?n.value[t]=null:s=!1;if(!0===s)for(r=0,a=e.length;r<a;r++)n=e[r],n.value[t]=i;else!function(e,t){let i,n;for(let r=0,a=e.length;r<a;r++){let a=e[r];if(null===a.value[t]){if(i=_(e,r,t),n=w(e,r,t),null===i){a.value[t]=n.value[t];continue}if(null===n){a.value[t]=i.value[t];continue}S(a,i,n,t)}}}(e,t)}function _(e,t,i){for(;t>=0;){let n=e[t];if(null!==n.value[i])return n;t--}return null}function w(e,t,i){for(;t<e.length;){let n=e[t];if(null!==n.value[i])return n;t++}return null}function S(e,t,i,n){i.time-t.time!=0?e.value[n]=(e.time-t.time)*(i.value[n]-t.value[n])/(i.time-t.time)+t.value[n]:e.value[n]=t.value[n]}function M(e){let t=[],i=e.name,n=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 i=0,n=e.length;i<n;i++)t.push(e[i])}return new uo(i,n,t)}function E(e){return c($e.clips[e],M)}function T(e){let t={sources:{}};for(let i=0,n=e.childNodes.length;i<n;i++){let n=e.childNodes[i];if(1===n.nodeType)switch(n.nodeName){case"bind_shape_matrix":t.bindShapeMatrix=r(n.textContent);break;case"source":let e=n.getAttribute("id");t.sources[e]=ae(n);break;case"joints":t.joints=A(n);break;case"vertex_weights":t.vertexWeights=C(n)}}return t}function A(e){let t={inputs:{}};for(let i=0,n=e.childNodes.length;i<n;i++){let n=e.childNodes[i];if(1===n.nodeType&&"input"===n.nodeName){let e=n.getAttribute("semantic"),i=s(n.getAttribute("source"));t.inputs[e]=i}}return t}function C(e){let t={inputs:{}};for(let i=0,n=e.childNodes.length;i<n;i++){let n=e.childNodes[i];if(1===n.nodeType)switch(n.nodeName){case"input":let e=n.getAttribute("semantic"),i=s(n.getAttribute("source")),r=parseInt(n.getAttribute("offset"));t.inputs[e]={id:i,offset:r};break;case"vcount":t.vcount=a(n.textContent);break;case"v":t.v=a(n.textContent)}}return t}function P(e){let t={id:e.id},i=$e.geometries[t.id];return void 0!==e.skin&&(t.skin=function(e){let t,i,n,r={joints:[],indices:{array:[],stride:4},weights:{array:[],stride:4}},a=e.sources,s=e.vertexWeights,o=s.vcount,l=s.v,h=s.inputs.JOINT.offset,c=s.inputs.WEIGHT.offset,u=e.sources[e.joints.inputs.JOINT],d=e.sources[e.joints.inputs.INV_BIND_MATRIX],p=a[s.inputs.WEIGHT.id].array,f=0;for(t=0,n=o.length;t<n;t++){let e=o[t],n=[];for(i=0;i<e;i++){let e=l[f+h],t=p[l[f+c]];n.push({index:e,weight:t}),f+=2}for(n.sort(m),i=0;i<4;i++){let e=n[i];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 et).fromArray(e.bindShapeMatrix).transpose():r.bindMatrix=(new et).identity(),t=0,n=u.array.length;t<n;t++){let e=u.array[t],i=(new et).fromArray(d.array,t*d.stride).transpose();r.joints.push({name:e,boneInverse:i})}return r;function m(e,t){return t.weight-e.weight}}(e.skin),i.sources.skinIndices=t.skin.indices,i.sources.skinWeights=t.skin.weights),t}function R(e){return c($e.controllers[e],P)}function L(e){return void 0!==e.build?e.build:e.init_from}function I(e){let t=$e.images[e];return void 0!==t?c(t,L):(console.warn("THREE.ColladaLoader: Couldn't find image with ID:",e),null)}function O(e){let t={surfaces:{},samplers:{}};for(let i=0,n=e.childNodes.length;i<n;i++){let n=e.childNodes[i];if(1===n.nodeType)switch(n.nodeName){case"newparam":k(n,t);break;case"technique":t.technique=F(n);break;case"extra":t.extra=G(n)}}return t}function k(e,t){let i=e.getAttribute("sid");for(let n=0,r=e.childNodes.length;n<r;n++){let r=e.childNodes[n];if(1===r.nodeType)switch(r.nodeName){case"surface":t.surfaces[i]=N(r);break;case"sampler2D":t.samplers[i]=U(r)}}}function N(e){let t={};for(let i=0,n=e.childNodes.length;i<n;i++){let n=e.childNodes[i];1===n.nodeType&&"init_from"===n.nodeName&&(t.init_from=n.textContent)}return t}function U(e){let t={};for(let i=0,n=e.childNodes.length;i<n;i++){let n=e.childNodes[i];1===n.nodeType&&"source"===n.nodeName&&(t.source=n.textContent)}return t}function F(e){let t={};for(let i=0,n=e.childNodes.length;i<n;i++){let n=e.childNodes[i];if(1===n.nodeType)switch(n.nodeName){case"constant":case"lambert":case"blinn":case"phong":t.type=n.nodeName,t.parameters=B(n);break;case"extra":t.extra=G(n)}}return t}function B(e){let t={};for(let i=0,n=e.childNodes.length;i<n;i++){let n=e.childNodes[i];if(1===n.nodeType)switch(n.nodeName){case"emission":case"diffuse":case"specular":case"bump":case"ambient":case"shininess":case"transparency":t[n.nodeName]=z(n);break;case"transparent":t[n.nodeName]={opaque:n.hasAttribute("opaque")?n.getAttribute("opaque"):"A_ONE",data:z(n)}}}return t}function z(e){let t={};for(let i=0,n=e.childNodes.length;i<n;i++){let n=e.childNodes[i];if(1===n.nodeType)switch(n.nodeName){case"color":t[n.nodeName]=r(n.textContent);break;case"float":t[n.nodeName]=parseFloat(n.textContent);break;case"texture":t[n.nodeName]={id:n.getAttribute("texture"),extra:H(n)}}}return t}function H(e){let t={technique:{}};for(let i=0,n=e.childNodes.length;i<n;i++){let n=e.childNodes[i];1===n.nodeType&&"extra"===n.nodeName&&V(n,t)}return t}function V(e,t){for(let i=0,n=e.childNodes.length;i<n;i++){let n=e.childNodes[i];1===n.nodeType&&"technique"===n.nodeName&&j(n,t)}}function j(e,t){for(let i=0,n=e.childNodes.length;i<n;i++){let n=e.childNodes[i];if(1===n.nodeType)switch(n.nodeName){case"repeatU":case"repeatV":case"offsetU":case"offsetV":t.technique[n.nodeName]=parseFloat(n.textContent);break;case"wrapU":case"wrapV":"TRUE"===n.textContent.toUpperCase()?t.technique[n.nodeName]=1:"FALSE"===n.textContent.toUpperCase()?t.technique[n.nodeName]=0:t.technique[n.nodeName]=parseInt(n.textContent);break;case"bump":t[n.nodeName]=X(n)}}}function G(e){let t={};for(let i=0,n=e.childNodes.length;i<n;i++){let n=e.childNodes[i];1===n.nodeType&&"technique"===n.nodeName&&(t.technique=W(n))}return t}function W(e){let t={};for(let i=0,n=e.childNodes.length;i<n;i++){let n=e.childNodes[i];if(1===n.nodeType)switch(n.nodeName){case"double_sided":t[n.nodeName]=parseInt(n.textContent);break;case"bump":t[n.nodeName]=X(n)}}return t}function X(e){let t={};for(let i=0,n=e.childNodes.length;i<n;i++){let n=e.childNodes[i];1===n.nodeType&&"texture"===n.nodeName&&(t[n.nodeName]={id:n.getAttribute("texture"),texcoord:n.getAttribute("texcoord"),extra:H(n)})}return t}function Y(e){return e}function q(e){let t,i=function(e){return c($e.effects[e],Y)}(e.url),n=i.profile.technique;switch(n.type){case"phong":case"blinn":t=new ea;break;case"lambert":t=new Pu;break;default:t=new ln}function r(e,t=null){let n=i.profile.samplers[e.id],r=null;if(void 0!==n?r=I(i.profile.surfaces[n.source].init_from):(console.warn("THREE.ColladaLoader: Undefined sampler. Access image directly (see #12530)."),r=I(e.id)),null!==r){let i=function(e){let t,i=e.slice(2+(e.lastIndexOf(".")-1>>>0));return t="tga"===(i=i.toLowerCase(),i)?qe:Xe,t}(r);if(void 0!==i){let n=i.load(r),a=e.extra;if(void 0!==a&&void 0!==a.technique&&!1===o(a.technique)){let e=a.technique;n.wrapS=e.wrapU?Di:Li,n.wrapT=e.wrapV?Di:Li,n.offset.set(e.offsetU||0,e.offsetV||0),n.repeat.set(e.repeatU||1,e.repeatV||1)}else n.wrapS=Di,n.wrapT=Di;return null!==t&&(n.colorSpace=t),n}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=n.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,en));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,en));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,en))}}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!==n.extra&&void 0!==n.extra.technique){let e=n.extra.technique;for(let i in e){let n=e[i];switch(i){case"double_sided":t.side=1===n?Sr:pi;break;case"bump":t.normalMap=r(n.texture),t.normalScale=new xe(1,1)}}}return t}function Z(e){return c($e.materials[e],q)}function Q(e){for(let t=0;t<e.childNodes.length;t++){let i=e.childNodes[t];if("technique_common"===i.nodeName)return J(i)}return{}}function J(e){let t={};for(let i=0;i<e.childNodes.length;i++){let n=e.childNodes[i];switch(n.nodeName){case"perspective":case"orthographic":t.technique=n.nodeName,t.parameters=K(n)}}return t}function K(e){let t={};for(let i=0;i<e.childNodes.length;i++){let n=e.childNodes[i];switch(n.nodeName){case"xfov":case"yfov":case"xmag":case"ymag":case"znear":case"zfar":case"aspect_ratio":t[n.nodeName]=parseFloat(n.textContent)}}return t}function $(e){let t;switch(e.optics.technique){case"perspective":t=new hr(e.optics.parameters.yfov,e.optics.parameters.aspect_ratio,e.optics.parameters.znear,e.optics.parameters.zfar);break;case"orthographic":let i=e.optics.parameters.ymag,n=e.optics.parameters.xmag,r=e.optics.parameters.aspect_ratio;n=void 0===n?i*r:n,i=void 0===i?n/r:i,n*=.5,i*=.5,t=new Nr(-n,n,i,-i,e.optics.parameters.znear,e.optics.parameters.zfar);break;default:t=new hr}return t.name=e.name||"",t}function ee(e){let t=$e.cameras[e];return void 0!==t?c(t,$):(console.warn("THREE.ColladaLoader: Couldn't find camera with ID:",e),null)}function te(e){let t={};for(let i=0,n=e.childNodes.length;i<n;i++){let n=e.childNodes[i];if(1===n.nodeType)switch(n.nodeName){case"directional":case"point":case"spot":case"ambient":t.technique=n.nodeName,t.parameters=ie(n)}}return t}function ie(e){let t={};for(let i=0,n=e.childNodes.length;i<n;i++){let n=e.childNodes[i];if(1===n.nodeType)switch(n.nodeName){case"color":let e=r(n.textContent);t.color=(new ct).fromArray(e).convertSRGBToLinear();break;case"falloff_angle":t.falloffAngle=parseFloat(n.textContent);break;case"quadratic_attenuation":let i=parseFloat(n.textContent);t.distance=i?Math.sqrt(1/i):0}}return t}function ne(e){let t;switch(e.technique){case"directional":t=new qs;break;case"point":t=new wc;break;case"spot":t=new Ou;break;case"ambient":t=new Cl}return e.parameters.color&&t.color.copy(e.parameters.color),e.parameters.distance&&(t.distance=e.parameters.distance),t}function re(e){let t=$e.lights[e];return void 0!==t?c(t,ne):(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=n(s.textContent);break;case"technique_common":let e=i(s,"accessor")[0];void 0!==e&&(t.stride=parseInt(e.getAttribute("stride")))}}return t}function se(e){let t={};for(let i=0;i<e.childNodes.length;i++){let n=e.childNodes[i];1===n.nodeType&&(t[n.getAttribute("semantic")]=s(n.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 i=0,n=e.childNodes.length;i<n;i++){let n=e.childNodes[i];if(1===n.nodeType)switch(n.nodeName){case"input":let e=s(n.getAttribute("source")),i=n.getAttribute("semantic"),r=parseInt(n.getAttribute("offset")),o=parseInt(n.getAttribute("set")),l=o>0?i+o:i;t.inputs[l]={id:e,offset:r},t.stride=Math.max(t.stride,r+1),"TEXCOORD"===i&&(t.hasUV=!0);break;case"vcount":t.vcount=a(n.textContent);break;case"p":t.p=a(n.textContent)}}return t}function le(e){let t=0;for(let i=0,n=e.length;i<n;i++)!0===e[i].hasUV&&t++;t>0&&t<e.length&&(e.uvsNeedsFix=!0)}function he(e){let t={},i=e.sources,n=e.vertices,r=e.primitives;if(0===r.length)return{};let a=function(e){let t={};for(let i=0;i<e.length;i++){let n=e[i];void 0===t[n.type]&&(t[n.type]=[]),t[n.type].push(n)}return t}(r);for(let s in a){let e=a[s];le(e),t[s]=ce(e,i,n)}return t}function ce(e,t,i){let n={},r={array:[],stride:0},a={array:[],stride:0},s={array:[],stride:0},o={array:[],stride:0},l={array:[],stride:0},h=[],c=[],u=new Dt,d=[],p=0;for(let f=0;f<e.length;f++){let n=e[f],m=n.inputs,g=0;switch(n.type){case"lines":case"linestrips":g=2*n.count;break;case"triangles":g=3*n.count;break;case"polylist":for(let e=0;e<n.count;e++){let t=n.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:",n.type)}u.addGroup(p,g,f),p+=g,n.material&&d.push(n.material);for(let u in m){let d=m[u];switch(u){case"VERTEX":for(let u in i){let p=i[u];switch(u){case"POSITION":let i=r.array.length;if(ue(n,t[p],d.offset,r.array),r.stride=t[p].stride,t.skinWeights&&t.skinIndices&&(ue(n,t.skinIndices,d.offset,h),ue(n,t.skinWeights,d.offset,c)),!1===n.hasUV&&!0===e.uvsNeedsFix){let e=(r.array.length-i)/r.stride;for(let t=0;t<e;t++)s.array.push(0,0)}break;case"NORMAL":ue(n,t[p],d.offset,a.array),a.stride=t[p].stride;break;case"COLOR":ue(n,t[p],d.offset,l.array),l.stride=t[p].stride;break;case"TEXCOORD":ue(n,t[p],d.offset,s.array),s.stride=t[p].stride;break;case"TEXCOORD1":ue(n,t[p],d.offset,o.array),s.stride=t[p].stride;break;default:console.warn('THREE.ColladaLoader: Semantic "%s" not handled in geometry build process.',u)}}break;case"NORMAL":ue(n,t[d.id],d.offset,a.array),a.stride=t[d.id].stride;break;case"COLOR":ue(n,t[d.id],d.offset,l.array,!0),l.stride=t[d.id].stride;break;case"TEXCOORD":ue(n,t[d.id],d.offset,s.array),s.stride=t[d.id].stride;break;case"TEXCOORD1":ue(n,t[d.id],d.offset,o.array),o.stride=t[d.id].stride}}}return r.array.length>0&&u.setAttribute("position",new Bt(r.array,r.stride)),a.array.length>0&&u.setAttribute("normal",new Bt(a.array,a.stride)),l.array.length>0&&u.setAttribute("color",new Bt(l.array,l.stride)),s.array.length>0&&u.setAttribute("uv",new Bt(s.array,s.stride)),o.array.length>0&&u.setAttribute("uv1",new Bt(o.array,o.stride)),h.length>0&&u.setAttribute("skinIndex",new Bt(h,4)),c.length>0&&u.setAttribute("skinWeight",new Bt(c,4)),n.data=u,n.type=e[0].type,n.materialKeys=d,n}function ue(e,t,i,n,r=!1){let a=e.p,s=e.stride,o=e.vcount;function l(e){let t=a[e+i]*c,s=t+c;for(;t<s;t++)n.push(h[t]);if(r){let e=n.length-c-1;Ze.setRGB(n[e+0],n[e+1],n[e+2]).convertSRGBToLinear(),n[e+0]=Ze.r,n[e+1]=Ze.g,n[e+2]=Ze.b}}let h=t.array,c=t.stride;if(void 0!==e.vcount){let e=0;for(let t=0,i=o.length;t<i;t++){let i=o[t];if(4===i){let t=e+1*s,i=e+2*s,n=e+3*s;l(e+0*s),l(t),l(n),l(t),l(i),l(n)}else if(3===i){let t=e+1*s,i=e+2*s;l(e+0*s),l(t),l(i)}else if(i>4)for(let t=1,n=i-2;t<=n;t++){let i=e+s*t,n=e+s*(t+1);l(e+0*s),l(i),l(n)}e+=s*i}}else for(let u=0,d=a.length;u<d;u+=s)l(u)}function de(e){return c($e.geometries[e],he)}function pe(e){return void 0!==e.build?e.build:e}function fe(e,t){for(let i=0;i<e.childNodes.length;i++){let n=e.childNodes[i];if(1===n.nodeType)switch(n.nodeName){case"joint":t.joints[n.getAttribute("sid")]=me(n);break;case"link":t.links.push(ve(n))}}}function me(e){let t;for(let i=0;i<e.childNodes.length;i++){let n=e.childNodes[i];if(1===n.nodeType)switch(n.nodeName){case"prismatic":case"revolute":t=ge(n)}}return t}function ge(e){let t={sid:e.getAttribute("sid"),name:e.getAttribute("name")||"",axis:new D,limits:{min:0,max:0},type:e.nodeName,static:!1,zeroPosition:0,middlePosition:0};for(let i=0;i<e.childNodes.length;i++){let n=e.childNodes[i];if(1===n.nodeType)switch(n.nodeName){case"axis":let e=r(n.textContent);t.axis.fromArray(e);break;case"limits":let i=n.getElementsByTagName("max")[0],a=n.getElementsByTagName("min")[0];t.limits.max=parseFloat(i.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 i=0;i<e.childNodes.length;i++){let n=e.childNodes[i];if(1===n.nodeType)switch(n.nodeName){case"attachment_full":t.attachments.push(ye(n));break;case"matrix":case"translate":case"rotate":t.transforms.push(be(n))}}return t}function ye(e){let t={joint:e.getAttribute("joint").split("/").pop(),transforms:[],links:[]};for(let i=0;i<e.childNodes.length;i++){let n=e.childNodes[i];if(1===n.nodeType)switch(n.nodeName){case"link":t.links.push(ve(n));break;case"matrix":case"translate":case"rotate":t.transforms.push(be(n))}}return t}function be(e){let t={type:e.nodeName},i=r(e.textContent);switch(t.type){case"matrix":t.obj=new et,t.obj.fromArray(i).transpose();break;case"translate":t.obj=new D,t.obj.fromArray(i);break;case"rotate":t.obj=new D,t.obj.fromArray(i),t.angle=Rn.degToRad(i[3])}return t}function _e(e,t){for(let i=0;i<e.childNodes.length;i++){let n=e.childNodes[i];1===n.nodeType&&"technique_common"===n.nodeName&&we(n,t)}}function we(e,t){for(let i=0;i<e.childNodes.length;i++){let n=e.childNodes[i];if(1===n.nodeType)switch(n.nodeName){case"inertia":t.inertia=r(n.textContent);break;case"mass":t.mass=r(n.textContent)[0]}}}function Se(e){let t={target:e.getAttribute("target").split("/").pop()};for(let i=0;i<e.childNodes.length;i++){let n=e.childNodes[i];if(1===n.nodeType&&"axis"===n.nodeName){let e=n.getElementsByTagName("param")[0];t.axis=e.textContent;let i=t.axis.split("inst_").pop().split("axis")[0];t.jointIndex=i.substring(0,i.length-1)}}return t}function Me(e){return void 0!==e.build?e.build:e}function Ee(e){let t=[],i=Ve.querySelector('[id="'+e.id+'"]');for(let n=0;n<i.childNodes.length;n++){let e,a,s=i.childNodes[n];if(1===s.nodeType)switch(s.nodeName){case"matrix":e=r(s.textContent);let i=(new et).fromArray(e).transpose();t.push({sid:s.getAttribute("sid"),type:s.nodeName,obj:i});break;case"translate":case"scale":e=r(s.textContent),a=(new D).fromArray(e),t.push({sid:s.getAttribute("sid"),type:s.nodeName,obj:a});break;case"rotate":e=r(s.textContent),a=(new D).fromArray(e);let n=Rn.degToRad(e[3]);t.push({sid:s.getAttribute("sid"),type:s.nodeName,obj:a,angle:n})}}return t}let Te=new et,Ae=new D;function Ce(e){let t={name:e.getAttribute("name")||"",type:e.getAttribute("type"),id:e.getAttribute("id"),sid:e.getAttribute("sid"),matrix:new et,nodes:[],instanceCameras:[],instanceControllers:[],instanceLights:[],instanceGeometries:[],instanceNodes:[],transforms:{}};for(let i=0;i<e.childNodes.length;i++){let n,a=e.childNodes[i];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":n=r(a.textContent),t.matrix.multiply(Te.fromArray(n).transpose()),t.transforms[a.getAttribute("sid")]=a.nodeName;break;case"translate":n=r(a.textContent),Ae.fromArray(n),t.matrix.multiply(Te.makeTranslation(Ae.x,Ae.y,Ae.z)),t.transforms[a.getAttribute("sid")]=a.nodeName;break;case"rotate":n=r(a.textContent);let e=Rn.degToRad(n[3]);t.matrix.multiply(Te.makeRotationAxis(Ae.fromArray(n),e)),t.transforms[a.getAttribute("sid")]=a.nodeName;break;case"scale":n=r(a.textContent),t.matrix.scale(Ae.fromArray(n)),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):$e.nodes[t.id]=t,t}function Pe(e){let t={id:s(e.getAttribute("url")),materials:{},skeletons:[]};for(let i=0;i<e.childNodes.length;i++){let n=e.childNodes[i];switch(n.nodeName){case"bind_material":let e=n.getElementsByTagName("instance_material");for(let i=0;i<e.length;i++){let n=e[i],r=n.getAttribute("symbol"),a=n.getAttribute("target");t.materials[r]=s(a)}break;case"skeleton":t.skeletons.push(s(n.textContent))}}return t}function Re(e,t){let i,n,r,a=[],s=[];for(i=0;i<e.length;i++){let n,r=e[i];if(Ne(r))n=Ue(r),De(n,t,a);else if(Be(r)){let e=$e.visualScenes[r].children;for(let i=0;i<e.length;i++){let n=e[i];"JOINT"===n.type&&De(Ue(n.id),t,a)}}else console.error("THREE.ColladaLoader: Unable to find root bone of skeleton with ID:",r)}for(i=0;i<t.length;i++)for(n=0;n<a.length;n++)if(r=a[n],r.bone.name===t[i].name){s[i]=r,r.processed=!0;break}for(i=0;i<a.length;i++)r=a[i],!1===r.processed&&(s.push(r),r.processed=!0);let o=[],l=[];for(i=0;i<s.length;i++)r=s[i],o.push(r.bone),l.push(r.boneInverse);return new Ml(o,l)}function De(e,t,i){e.traverse((function(e){if(!0===e.isBone){let n;for(let i=0;i<t.length;i++){let r=t[i];if(r.name===e.name){n=r.boneInverse;break}}void 0===n&&(n=new et),i.push({bone:e,boneInverse:n,processed:!1})}}))}function Le(e){let t,i=[],n=e.matrix,r=e.nodes,a=e.type,s=e.instanceCameras,o=e.instanceControllers,l=e.instanceLights,h=e.instanceGeometries,c=e.instanceNodes;for(let u=0,d=r.length;u<d;u++)i.push(Ue(r[u]));for(let u=0,d=s.length;u<d;u++){let e=ee(s[u]);null!==e&&i.push(e.clone())}for(let u=0,d=o.length;u<d;u++){let e=o[u],t=R(e.id),n=ke(de(t.id),e.materials),r=Re(e.skeletons,t.skin.joints);for(let a=0,s=n.length;a<s;a++){let e=n[a];e.isSkinnedMesh&&(e.bind(r,t.skin.bindMatrix),e.normalizeSkinWeights()),i.push(e)}}for(let u=0,d=l.length;u<d;u++){let e=re(l[u]);null!==e&&i.push(e.clone())}for(let u=0,d=h.length;u<d;u++){let e=h[u],t=ke(de(e.id),e.materials);for(let n=0,r=t.length;n<r;n++)i.push(t[n])}for(let u=0,d=c.length;u<d;u++)i.push(Ue(c[u]).clone());if(0===r.length&&1===i.length)t=i[0];else{t="JOINT"===a?new Sl:new er;for(let e=0;e<i.length;e++)t.add(i[e])}return t.name="JOINT"===a?e.sid:e.name,t.matrix.copy(n),t.matrix.decompose(t.position,t.quaternion,t.scale),t}let Ie=new ln({name:Er.DEFAULT_MATERIAL_NAME,color:16711935});function Oe(e,t){let i=[];for(let n=0,r=e.length;n<r;n++){let r=t[e[n]];void 0===r?(console.warn("THREE.ColladaLoader: Material with key %s not found. Apply fallback material.",e[n]),i.push(Ie)):i.push(Z(r))}return i}function ke(e,t){let i=[];for(let n in e){let r=e[n],a=Oe(r.materialKeys,t);if(0===a.length&&("lines"===n||"linestrips"===n?a.push(new Gn):a.push(new ea)),"lines"===n||"linestrips"===n)for(let e=0,t=a.length;e<t;e++){let t=a[e];if(!0===t.isMeshPhongMaterial||!0===t.isMeshLambertMaterial){let i=new Gn;i.color.copy(t.color),i.opacity=t.opacity,i.transparent=t.transparent,a[e]=i}}let s,o=void 0!==r.data.attributes.skinIndex,l=1===a.length?a[0]:a;switch(n){case"lines":s=new qr(r.data,l);break;case"linestrips":s=new fr(r.data,l);break;case"triangles":case"polylist":s=o?new wu(r.data,l):new xt(r.data,l)}i.push(s)}return i}function Ne(e){return void 0!==$e.nodes[e]}function Ue(e){return c($e.nodes[e],Le)}function Fe(e){let t=new er;t.name=e.name;let i=e.children;for(let n=0;n<i.length;n++){let e=i[n];t.add(Ue(e.id))}return t}function Be(e){return void 0!==$e.visualScenes[e]}function ze(e){return c($e.visualScenes[e],Fe)}if(0===e.length)return{scene:new Si};let He=(new DOMParser).parseFromString(e,"application/xml"),Ve=i(He,"COLLADA")[0],je=He.getElementsByTagName("parsererror")[0];if(void 0!==je){let e,t=i(je,"div")[0];return e=t?t.textContent:function(e){let t="",i=[e];for(;i.length;){let e=i.shift();e.nodeType===Node.TEXT_NODE?t+=e.textContent:(t+="\n",i.push.apply(i,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=i(Ve,"asset")[0],{unit:function(e){return void 0!==e&&!0===e.hasAttribute("meter")?parseFloat(e.getAttribute("meter")):1}(i(Ye,"unit")[0]),upAxis:function(e){return void 0!==e?e.textContent:"Y_UP"}(i(Ye,"up_axis")[0])}),Xe=new ws(this.manager);var Ye;let qe;Xe.setPath(this.resourcePath||t).setCrossOrigin(this.crossOrigin),f_&&(qe=new f_(this.manager),qe.setPath(this.resourcePath||t));let Ze=new ct,Qe=[],Je={},Ke=0,$e={animations:{},clips:{},controllers:{},images:{},effects:{},materials:{},cameras:{},lights:{},geometries:{},nodes:{},visualScenes:{},kinematicsModels:{},physicsModels:{},kinematicsScenes:{}};l(Ve,"library_animations","animation",(function e(t){let i={sources:{},samplers:{},channels:{}},n=!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"),i.sources[a]=ae(s);break;case"sampler":a=s.getAttribute("id"),i.samplers[a]=u(s);break;case"channel":a=s.getAttribute("target"),i.channels[a]=d(s);break;case"animation":e(s),n=!0;break;default:console.log(s)}}!1===n&&($e.animations[t.getAttribute("id")||Rn.generateUUID()]=i)})),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 i=0,n=e.childNodes.length;i<n;i++){let n=e.childNodes[i];1===n.nodeType&&"instance_animation"===n.nodeName&&t.animations.push(s(n.getAttribute("url")))}$e.clips[e.getAttribute("id")]=t})),l(Ve,"library_controllers","controller",(function(e){let t={};for(let i=0,n=e.childNodes.length;i<n;i++){let n=e.childNodes[i];if(1===n.nodeType)switch(n.nodeName){case"skin":t.id=s(n.getAttribute("source")),t.skin=T(n);break;case"morph":t.id=s(n.getAttribute("source")),console.warn("THREE.ColladaLoader: Morph target animation not supported yet.")}}$e.controllers[e.getAttribute("id")]=t})),l(Ve,"library_images","image",(function(e){let t={init_from:i(e,"init_from")[0].textContent};$e.images[e.getAttribute("id")]=t})),l(Ve,"library_effects","effect",(function(e){let t={};for(let i=0,n=e.childNodes.length;i<n;i++){let n=e.childNodes[i];1===n.nodeType&&"profile_COMMON"===n.nodeName&&(t.profile=O(n))}$e.effects[e.getAttribute("id")]=t})),l(Ve,"library_materials","material",(function(e){let t={name:e.getAttribute("name")};for(let i=0,n=e.childNodes.length;i<n;i++){let n=e.childNodes[i];1===n.nodeType&&"instance_effect"===n.nodeName&&(t.url=s(n.getAttribute("url")))}$e.materials[e.getAttribute("id")]=t})),l(Ve,"library_cameras","camera",(function(e){let t={name:e.getAttribute("name")};for(let i=0,n=e.childNodes.length;i<n;i++){let n=e.childNodes[i];1===n.nodeType&&"optics"===n.nodeName&&(t.optics=Q(n))}$e.cameras[e.getAttribute("id")]=t})),l(Ve,"library_lights","light",(function(e){let t={};for(let i=0,n=e.childNodes.length;i<n;i++){let n=e.childNodes[i];1===n.nodeType&&"technique_common"===n.nodeName&&(t=te(n))}$e.lights[e.getAttribute("id")]=t})),l(Ve,"library_geometries","geometry",(function(e){let t={name:e.getAttribute("name"),sources:{},vertices:{},primitives:[]},n=i(e,"mesh")[0];if(void 0!==n){for(let e=0;e<n.childNodes.length;e++){let i=n.childNodes[e];if(1!==i.nodeType)continue;let r=i.getAttribute("id");switch(i.nodeName){case"source":t.sources[r]=ae(i);break;case"vertices":t.vertices=se(i);break;case"polygons":console.warn("THREE.ColladaLoader: Unsupported primitive type: ",i.nodeName);break;case"lines":case"linestrips":case"polylist":case"triangles":t.primitives.push(oe(i));break;default:console.log(i)}}$e.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 i=0;i<t.length;i++){let e=t[i];!1===e.hasAttribute("id")&&e.setAttribute("id","three_default_"+Ke++)}}(e);let n=i(e,"node");for(let i=0;i<n.length;i++)t.children.push(Ce(n[i]));$e.visualScenes[e.getAttribute("id")]=t})),l(Ve,"library_kinematics_models","kinematics_model",(function(e){let t={name:e.getAttribute("name")||"",joints:{},links:[]};for(let i=0;i<e.childNodes.length;i++){let n=e.childNodes[i];1===n.nodeType&&"technique_common"===n.nodeName&&fe(n,t)}$e.kinematicsModels[e.getAttribute("id")]=t})),l(Ve,"library_physics_models","physics_model",(function(e){let t={name:e.getAttribute("name")||"",rigidBodies:{}};for(let i=0;i<e.childNodes.length;i++){let n=e.childNodes[i];1===n.nodeType&&"rigid_body"===n.nodeName&&(t.rigidBodies[n.getAttribute("name")]={},_e(n,t.rigidBodies[n.getAttribute("name")]))}$e.physicsModels[e.getAttribute("id")]=t})),l(Ve,"scene","instance_kinematics_scene",(function(e){let t={bindJointAxis:[]};for(let i=0;i<e.childNodes.length;i++){let n=e.childNodes[i];1===n.nodeType&&"bind_joint_axis"===n.nodeName&&t.bindJointAxis.push(Se(n))}$e.kinematicsScenes[s(e.getAttribute("url"))]=t})),h($e.animations,p),h($e.clips,M),h($e.controllers,P),h($e.images,L),h($e.effects,Y),h($e.materials,q),h($e.cameras,$),h($e.lights,ne),h($e.geometries,he),h($e.visualScenes,Fe),function(){let e=$e.clips;if(!0===o(e)){if(!1===o($e.animations)){let e=[];for(let t in $e.animations){let i=f(t);for(let t=0,n=i.length;t<n;t++)e.push(i[t])}Qe.push(new uo("default",-1,e))}}else for(let t in e)Qe.push(E(t))}(),function(){let e=Object.keys($e.kinematicsModels)[0],t=Object.keys($e.kinematicsScenes)[0],i=Object.keys($e.visualScenes)[0];if(void 0===e||void 0===t)return;let n=function(e){return c($e.kinematicsModels[e],pe)}(e),r=function(e){return c($e.kinematicsScenes[e],Me)}(t),a=ze(i),s=r.bindJointAxis,o={};for(let c=0,u=s.length;c<u;c++){let e=s[c],t=Ve.querySelector('[sid="'+e.target+'"]');if(t){let i=t.parentElement;l(e.jointIndex,i)}}function l(e,t){let i=t.getAttribute("name"),r=n.joints[e];a.traverse((function(n){n.name===i&&(o[e]={object:n,transforms:Ee(t),joint:r,position:r.zeroPosition})}))}let h=new et;Je={joints:n&&n.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 i=o[e];if(i){let n=i.joint;if(t>n.limits.max||t<n.limits.min)console.warn("THREE.ColladaLoader: Joint "+e+" value "+t+" outside of limits (min: "+n.limits.min+", max: "+n.limits.max+").");else if(n.static)console.warn("THREE.ColladaLoader: Joint "+e+" is static.");else{let r=i.object,a=n.axis,s=i.transforms;Te.identity();for(let i=0;i<s.length;i++){let r=s[i];if(r.sid&&-1!==r.sid.indexOf(e))switch(n.type){case"revolute":Te.multiply(h.makeRotationAxis(a,Rn.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: "+n.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 tt=function(e){return ze(s(i(e,"instance_visual_scene")[0].getAttribute("url")))}(i(Ve,"scene")[0]);return tt.animations=Qe,"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."),tt.rotation.set(-Math.PI/2,0,0)),tt.scale.multiplyScalar(We.unit),{get animations(){return console.warn("THREE.ColladaLoader: Please access animations over scene.animations now."),Qe},kinematics:Je,library:$e,scene:tt}}},O6=new WeakMap,aP=class extends Er{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,i,n){let r=new Kr(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,n)}),i,n)}parse(e,t,i){this.decodeDracoFile(e,t,null,null,en).catch(i)}decodeDracoFile(e,t,i,n,r=Na){let a={attributeIDs:i||this.defaultAttributeIDs,attributeTypes:n||this.defaultAttributeTypes,useUniqueIDs:!!i,vertexColorSpace:r};return this.decodeGeometry(e,a).then(t)}decodeGeometry(e,t){let i=JSON.stringify(t);if(O6.has(e)){let t=O6.get(e);if(t.key===i)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 n,r=this.workerNextTaskID++,a=e.byteLength,s=this._getWorker(r,a).then((i=>(n=i,new Promise(((i,a)=>{n._callbacks[r]={resolve:i,reject:a},n.postMessage({type:"decode",id:r,taskConfig:t,buffer:e},[e])}))))).then((e=>this._createGeometry(e.geometry)));return s.catch((()=>!0)).then((()=>{n&&r&&this._releaseTask(n,r)})),O6.set(e,{key:i,promise:s}),s}_createGeometry(e){let t=new Dt;e.index&&t.setIndex(new mn(e.index.array,1));for(let i=0;i<e.attributes.length;i++){let n=e.attributes[i],r=n.name,a=n.array,s=n.itemSize,o=new mn(a,s);"color"===r&&(this._assignVertexColorSpace(o,n.vertexColorSpace),o.normalized=!(a instanceof Float32Array)),t.setAttribute(r,o)}return t}_assignVertexColorSpace(e,t){if(t!==en)return;let i=new ct;for(let n=0,r=e.count;n<r;n++)i.fromBufferAttribute(e,n).convertSRGBToLinear(),e.setXYZ(n,i.r,i.g,i.b)}_loadLibrary(e,t){let i=new Kr(this.manager);return i.setPath(this.decoderPath),i.setResponseType(t),i.setWithCredentials(this.withCredentials),new Promise(((t,n)=>{i.load(e,t,void 0,n)}))}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 i=t[0];e||(this.decoderConfig.wasmBinary=t[1]);let n=Zmt.toString(),r=["/* draco decoder */",i,"","/* worker */",n.substring(n.indexOf("{")+1,n.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 i=t.data;switch(i.type){case"decode":e._callbacks[i.id].resolve(i);break;case"error":e._callbacks[i.id].reject(i);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+i.type+'"')}},this.workerPool.push(e)}else this.workerPool.sort((function(e,t){return e._taskLoad>t._taskLoad?-1:1}));let i=this.workerPool[this.workerPool.length-1];return i._taskCosts[e]=t,i._taskLoad+=t,i}))}_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 Zmt(){let e,t;function i(e,t,i,n,r,a){let s=a.num_components(),o=i.num_points()*s,l=o*r.BYTES_PER_ELEMENT,h=function(e,t){switch(t){case Float32Array:return e.DT_FLOAT32;case Int8Array:return e.DT_INT8;case Int16Array:return e.DT_INT16;case Int32Array:return e.DT_INT32;case Uint8Array:return e.DT_UINT8;case Uint16Array:return e.DT_UINT16;case Uint32Array:return e.DT_UINT32}}(e,r),c=e._malloc(l);t.GetAttributeDataArrayForAllPoints(i,a,h,l,c);let u=new r(e.HEAPF32.buffer,c,o).slice();return e._free(c),{name:n,array:u,itemSize:s}}onmessage=function(n){let r=n.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 n=r.buffer,a=r.taskConfig;t.then((e=>{let t=e.draco,s=new t.Decoder;try{let e=function(e,t,n,r){let a,s,o=r.attributeIDs,l=r.attributeTypes,h=t.GetEncodedGeometryType(n);if(h===e.TRIANGULAR_MESH)a=new e.Mesh,s=t.DecodeArrayToMesh(n,n.byteLength,a);else{if(h!==e.POINT_CLOUD)throw new Error("THREE.DRACOLoader: Unexpected geometry type.");a=new e.PointCloud,s=t.DecodeArrayToPointCloud(n,n.byteLength,a)}if(!s.ok()||0===a.ptr)throw new Error("THREE.DRACOLoader: Decoding failed: "+s.error_msg());let c={index:null,attributes:[]};for(let u in o){let n,s,h=self[l[u]];if(r.useUniqueIDs)s=o[u],n=t.GetAttributeByUniqueId(a,s);else{if(s=t.GetAttributeId(a,e[o[u]]),-1===s)continue;n=t.GetAttribute(a,s)}let d=i(e,t,a,u,h,n);"color"===u&&(d.vertexColorSpace=r.vertexColorSpace),c.attributes.push(d)}return h===e.TRIANGULAR_MESH&&(c.index=function(e,t,i){let n=3*i.num_faces(),r=4*n,a=e._malloc(r);t.GetTrianglesUInt32Array(i,r,a);let s=new Uint32Array(e.HEAPF32.buffer,a,n).slice();return e._free(a),{array:s,itemSize:1}}(e,t,a)),e.destroy(a),c}(t,s,new Int8Array(n),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 M0e=function(e){return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))},Kmt=function(e){return new Worker(e)};try{URL.revokeObjectURL(M0e(""))}catch(e){M0e=function(e){return"data:application/javascript;charset=UTF-8,"+encodeURI(e)},Kmt=function(e){return new Worker(e,{type:"module"})}}var ql=Uint8Array,Zf=Uint16Array,N6=Uint32Array,R0e=new ql([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]),A0e=new ql([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]),Jmt=new ql([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),C0e=function(e,t){for(var i=new Zf(31),n=0;n<31;++n)i[n]=t+=1<<e[n-1];var r=new N6(i[30]);for(n=1;n<30;++n)for(var a=i[n];a<i[n+1];++a)r[a]=a-i[n]<<5|n;return[i,r]},P0e=C0e(R0e,2),I0e=P0e[0],Qmt=P0e[1];I0e[28]=258,Qmt[258]=28;var L0e=C0e(A0e,0),egt=L0e[0],y7t=L0e[1],B6=new Zf(32768);for(hi=0;hi<32768;++hi)hd=(43690&hi)>>>1|(21845&hi)<<1,hd=(52428&hd)>>>2|(13107&hd)<<2,hd=(61680&hd)>>>4|(3855&hd)<<4,B6[hi]=((65280&hd)>>>8|(255&hd)<<8)>>>1;var hd,hi,p_=function(e,t,i){for(var n=e.length,r=0,a=new Zf(t);r<n;++r)++a[e[r]-1];var s,o=new Zf(t);for(r=0;r<t;++r)o[r]=o[r-1]+a[r-1]<<1;if(i){s=new Zf(1<<t);var l=15-t;for(r=0;r<n;++r)if(e[r])for(var h=r<<4|e[r],c=t-e[r],u=o[e[r]-1]++<<c,d=u|(1<<c)-1;u<=d;++u)s[B6[u]>>>l]=h}else for(s=new Zf(n),r=0;r<n;++r)e[r]&&(s[r]=B6[o[e[r]-1]++]>>>15-e[r]);return s},m_=new ql(288),hi,hi,hi;for(hi=0;hi<144;++hi)m_[hi]=8;for(hi=144;hi<256;++hi)m_[hi]=9;for(hi=256;hi<280;++hi)m_[hi]=7;for(hi=280;hi<288;++hi)m_[hi]=8;var hi,D0e=new ql(32),hi;for(hi=0;hi<32;++hi)D0e[hi]=5;var tgt=p_(m_,9,1),ngt=p_(D0e,5,1),k6=function(e){for(var t=e[0],i=1;i<e.length;++i)e[i]>t&&(t=e[i]);return t},zc=function(e,t,i){var n=t/8|0;return(e[n]|e[n+1]<<8)>>(7&t)&i},F6=function(e,t){var i=t/8|0;return(e[i]|e[i+1]<<8|e[i+2]<<16)>>(7&t)},rgt=function(e){return(e/8|0)+(7&e&&1)},igt=function(e,t,i){(null==t||t<0)&&(t=0),(null==i||i>e.length)&&(i=e.length);var n=new(e instanceof Zf?Zf:e instanceof N6?N6:ql)(i-t);return n.set(e.subarray(t,i)),n},sgt=function(e,t,i){var n=e.length;if(!n||i&&!i.l&&n<5)return t||new ql(0);var r=!t||i,a=!i||i.i;i||(i={}),t||(t=new ql(3*n));var s=function(e){var i=t.length;if(e>i){var n=new ql(Math.max(2*i,e));n.set(t),t=n}},o=i.f||0,l=i.p||0,h=i.b||0,c=i.l,u=i.d,d=i.m,p=i.n,f=8*n;do{if(!c){i.f=o=zc(e,l,1);var m=zc(e,l+1,3);if(l+=3,!m){var g=e[(A=rgt(l)+4)-4]|e[A-3]<<8,v=A+g;if(v>n){if(a)throw"unexpected EOF";break}r&&s(h+g),t.set(e.subarray(A,v),h),i.b=h+=g,i.p=l=8*v;continue}if(1==m)c=tgt,u=ngt,d=9,p=5;else{if(2!=m)throw"invalid block type";var y=zc(e,l,31)+257,x=zc(e,l+10,15)+4,b=y+zc(e,l+5,31)+1;l+=14;for(var _=new ql(b),w=new ql(19),S=0;S<x;++S)w[Jmt[S]]=zc(e,l+3*S,7);l+=3*x;var M=k6(w),E=(1<<M)-1,T=p_(w,M,1);for(S=0;S<b;){var A,C=T[zc(e,l,E)];if(l+=15&C,(A=C>>>4)<16)_[S++]=A;else{var P=0,R=0;for(16==A?(R=3+zc(e,l,3),l+=2,P=_[S-1]):17==A?(R=3+zc(e,l,7),l+=3):18==A&&(R=11+zc(e,l,127),l+=7);R--;)_[S++]=P}}var D=_.subarray(0,y),L=_.subarray(y);d=k6(D),p=k6(L),c=p_(D,d,1),u=p_(L,p,1)}if(l>f){if(a)throw"unexpected EOF";break}}r&&s(h+131072);for(var I=(1<<d)-1,O=(1<<p)-1,k=l;;k=l){var N=(P=c[F6(e,l)&I])>>>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){k=l,c=null;break}var U=N-254;if(N>264){var F=R0e[S=N-257];U=zc(e,l,(1<<F)-1)+I0e[S],l+=F}var B=u[F6(e,l)&O],z=B>>>4;if(!B)throw"invalid distance";if(l+=15&B,L=egt[z],z>3&&(F=A0e[z],L+=F6(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-L],t[h+1]=t[h+1-L],t[h+2]=t[h+2-L],t[h+3]=t[h+3-L];h=H}}i.l=c,i.p=k,i.b=h,c&&(o=1,i.m=d,i.d=u,i.n=p)}while(!o);return h==t.length?t:igt(t,0,h)},agt=new ql(0),ogt=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 O0e(e,t){return sgt((ogt(e),e.subarray(2,-4)),t)}var lgt="undefined"!=typeof TextDecoder&&new TextDecoder,cgt=0;try{lgt.decode(agt,{stream:!0}),cgt=1}catch(e){}function k0e(e,t,i){let n=i.length-e-1;if(t>=i[n])return n-1;if(t<=i[e])return e;let r=e,a=n,s=Math.floor((r+a)/2);for(;t<i[s]||t>=i[s+1];)t<i[s]?a=s:r=s,s=Math.floor((r+a)/2);return s}function hgt(e,t,i,n){let r=[],a=[],s=[];r[0]=1;for(let o=1;o<=i;++o){a[o]=t-n[e+1-o],s[o]=n[e+o]-t;let i=0;for(let e=0;e<o;++e){let t=s[e+1],n=a[o-e],l=r[e]/(t+n);r[e]=i+t*l,i=n*l}r[o]=i}return r}function F0e(e,t,i,n){let r=k0e(e,n,t),a=hgt(r,n,e,t),s=new gr(0,0,0,0);for(let o=0;o<=e;++o){let t=i[r-e+o],n=a[o],l=t.w*n;s.x+=t.x*l,s.y+=t.y*l,s.z+=t.z*l,s.w+=t.w*n}return s}function dgt(e,t,i,n,r){let a=[];for(let u=0;u<=i;++u)a[u]=0;let s=[];for(let u=0;u<=n;++u)s[u]=a.slice(0);let o=[];for(let u=0;u<=i;++u)o[u]=a.slice(0);o[0][0]=1;let l=a.slice(0),h=a.slice(0);for(let u=1;u<=i;++u){l[u]=t-r[e+1-u],h[u]=r[e+u]-t;let i=0;for(let e=0;e<u;++e){let t=h[e+1],n=l[u-e];o[u][e]=t+n;let r=o[e][u-1]/o[u][e];o[e][u]=i+t*r,i=n*r}o[u][u]=i}for(let u=0;u<=i;++u)s[0][u]=o[u][i];for(let u=0;u<=i;++u){let e=0,t=1,r=[];for(let n=0;n<=i;++n)r[n]=a.slice(0);r[0][0]=1;for(let a=1;a<=n;++a){let n=0,l=u-a,h=i-a;u>=a&&(r[t][0]=r[e][0]/o[h+1][l],n=r[t][0]*o[l][h]);let c=u-1<=h?a-1:i-u;for(let i=l>=-1?1:-l;i<=c;++i)r[t][i]=(r[e][i]-r[e][i-1])/o[h+1][l+i],n+=r[t][i]*o[l+i][h];u<=h&&(r[t][a]=-r[e][a-1]/o[h+1][u],n+=r[t][a]*o[u][h]),s[a][u]=n;let d=e;e=t,t=d}}let c=i;for(let u=1;u<=n;++u){for(let e=0;e<=i;++e)s[u][e]*=c;c*=i-u}return s}function fgt(e,t,i,n,r){let a=r<e?r:e,s=[],o=k0e(e,n,t),l=dgt(o,n,e,a,t),h=[];for(let c=0;c<i.length;++c){let e=i[c].clone(),t=e.w;e.x*=t,e.y*=t,e.z*=t,h[c]=e}for(let c=0;c<=a;++c){let t=h[o-e].clone().multiplyScalar(l[c][0]);for(let i=1;i<=e;++i)t.add(h[o-e+i].clone().multiplyScalar(l[c][i]));s[c]=t}for(let c=a+1;c<=r+1;++c)s[c]=new gr(0,0,0);return s}function pgt(e,t){let i=1;for(let r=2;r<=e;++r)i*=r;let n=1;for(let r=2;r<=t;++r)n*=r;for(let r=2;r<=e-t;++r)n*=r;return i/n}function mgt(e){let t=e.length,i=[],n=[];for(let a=0;a<t;++a){let t=e[a];i[a]=new D(t.x,t.y,t.z),n[a]=t.w}let r=[];for(let a=0;a<t;++a){let e=i[a].clone();for(let t=1;t<=a;++t)e.sub(r[a-t].clone().multiplyScalar(pgt(a,t)*n[t]));r[a]=e.divideScalar(n[0])}return r}function N0e(e,t,i,n,r){return mgt(fgt(e,t,i,n,r))}var oP=class extends Ba{constructor(e,t,i,n,r){super(),this.degree=e,this.knots=t,this.controlPoints=[],this.startKnot=n||0,this.endKnot=r||this.knots.length-1;for(let a=0;a<i.length;++a){let e=i[a];this.controlPoints[a]=new gr(e.x,e.y,e.z,e.w)}}getPoint(e,t=new D){let i=t,n=this.knots[this.startKnot]+e*(this.knots[this.endKnot]-this.knots[this.startKnot]),r=F0e(this.degree,this.knots,this.controlPoints,n);return 1!==r.w&&r.divideScalar(r.w),i.set(r.x,r.y,r.z)}getTangent(e,t=new D){let i=t,n=this.knots[0]+e*(this.knots[this.knots.length-1]-this.knots[0]),r=N0e(this.degree,this.knots,this.controlPoints,n,1);return i.copy(r[1]).normalize(),i}},Ir,gs,bo,cP=class extends Er{constructor(e){super(e)}load(e,t,i,n){let r=this,a=""===r.path?ta.extractUrlBase(e):r.path,s=new Kr(this.manager);s.setPath(r.path),s.setResponseType("arraybuffer"),s.setRequestHeader(r.requestHeader),s.setWithCredentials(r.withCredentials),s.load(e,(function(i){try{t(r.parse(i,a))}catch(t){n?n(t):console.error(t),r.manager.itemError(e)}}),i,n)}parse(e,t){if(vgt(e))Ir=(new W6).parse(e);else{let t=z0e(e);if(!ygt(t))throw new Error("THREE.FBXLoader: Unknown format.");if(B0e(t)<7e3)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+B0e(t));Ir=(new q6).parse(t)}let i=new ws(this.manager).setPath(this.resourcePath||t).setCrossOrigin(this.crossOrigin);return new V6(i,this.manager).parse(Ir)}},V6=class{constructor(e,t){this.textureLoader=e,this.manager=t}parse(){gs=this.parseConnections();let e=this.parseImages(),t=this.parseTextures(e),i=this.parseMaterials(t),n=this.parseDeformers(),r=(new z6).parse(n);return this.parseScene(n,r,i),bo}parseConnections(){let e=new Map;return"Connections"in Ir&&Ir.Connections.connections.forEach((function(t){let i=t[0],n=t[1],r=t[2];e.has(i)||e.set(i,{parents:[],children:[]});let a={ID:n,relationship:r};e.get(i).parents.push(a),e.has(n)||e.set(n,{parents:[],children:[]});let s={ID:i,relationship:r};e.get(n).children.push(s)})),e}parseImages(){let e={},t={};if("Video"in Ir.Objects){let i=Ir.Objects.Video;for(let n in i){let r=i[n];if(e[parseInt(n)]=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(i[n]);t[r.RelativeFilename||r.Filename]=e}}}}for(let i in e){let n=e[i];void 0!==t[n]?e[i]=t[n]:e[i]=e[i].split("\\").pop()}return e}parseImage(e){let t,i=e.Content,n=e.RelativeFilename||e.Filename,r=n.slice(n.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 ",n),t="image/tga";break;default:return void console.warn('FBXLoader: Image type "'+r+'" is not supported.')}if("string"==typeof i)return"data:"+t+";base64,"+i;{let e=new Uint8Array(i);return window.URL.createObjectURL(new Blob([e],{type:t}))}}parseTextures(e){let t=new Map;if("Texture"in Ir.Objects){let i=Ir.Objects.Texture;for(let n in i){let r=this.parseTexture(i[n],e);t.set(parseInt(n),r)}}return t}parseTexture(e,t){let i=this.loadTexture(e,t);i.ID=e.id,i.name=e.attrName;let n=e.WrapModeU,r=e.WrapModeV,a=void 0!==n?n.value:0,s=void 0!==r?r.value:0;if(i.wrapS=0===a?Di:Li,i.wrapT=0===s?Di:Li,"Scaling"in e){let t=e.Scaling.value;i.repeat.x=t[0],i.repeat.y=t[1]}if("Translation"in e){let t=e.Translation.value;i.offset.x=t[0],i.offset.y=t[1]}return i}loadTexture(e,t){let i,n=this.textureLoader.path,r=gs.get(e.id).children;void 0!==r&&r.length>0&&void 0!==t[r[0].ID]&&(i=t[r[0].ID],(0===i.indexOf("blob:")||0===i.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 Gr):(t.setPath(this.textureLoader.path),a=t.load(i))}else"psd"===s?(console.warn("FBXLoader: PSD textures are not supported, creating placeholder texture for",e.RelativeFilename),a=new Gr):a=this.textureLoader.load(i);return this.textureLoader.setPath(n),a}parseMaterials(e){let t=new Map;if("Material"in Ir.Objects){let i=Ir.Objects.Material;for(let n in i){let r=this.parseMaterial(i[n],e);null!==r&&t.set(parseInt(n),r)}}return t}parseMaterial(e,t){let i=e.id,n=e.attrName,r=e.ShadingModel;if("object"==typeof r&&(r=r.value),!gs.has(i))return null;let a,s=this.parseParameters(e,t,i);switch(r.toLowerCase()){case"phong":a=new ea;break;case"lambert":a=new Pu;break;default:console.warn('THREE.FBXLoader: unknown material type "%s". Defaulting to MeshPhongMaterial.',r),a=new ea}return a.setValues(s),a.name=n,a}parseParameters(e,t,i){let n={};e.BumpFactor&&(n.bumpScale=e.BumpFactor.value),e.Diffuse?n.color=(new ct).fromArray(e.Diffuse.value).convertSRGBToLinear():e.DiffuseColor&&("Color"===e.DiffuseColor.type||"ColorRGB"===e.DiffuseColor.type)&&(n.color=(new ct).fromArray(e.DiffuseColor.value).convertSRGBToLinear()),e.DisplacementFactor&&(n.displacementScale=e.DisplacementFactor.value),e.Emissive?n.emissive=(new ct).fromArray(e.Emissive.value).convertSRGBToLinear():e.EmissiveColor&&("Color"===e.EmissiveColor.type||"ColorRGB"===e.EmissiveColor.type)&&(n.emissive=(new ct).fromArray(e.EmissiveColor.value).convertSRGBToLinear()),e.EmissiveFactor&&(n.emissiveIntensity=parseFloat(e.EmissiveFactor.value)),e.Opacity&&(n.opacity=parseFloat(e.Opacity.value)),n.opacity<1&&(n.transparent=!0),e.ReflectionFactor&&(n.reflectivity=e.ReflectionFactor.value),e.Shininess&&(n.shininess=e.Shininess.value),e.Specular?n.specular=(new ct).fromArray(e.Specular.value).convertSRGBToLinear():e.SpecularColor&&"Color"===e.SpecularColor.type&&(n.specular=(new ct).fromArray(e.SpecularColor.value).convertSRGBToLinear());let r=this;return gs.get(i).children.forEach((function(e){let i=e.relationship;switch(i){case"Bump":n.bumpMap=r.getTexture(t,e.ID);break;case"Maya|TEX_ao_map":n.aoMap=r.getTexture(t,e.ID);break;case"DiffuseColor":case"Maya|TEX_color_map":n.map=r.getTexture(t,e.ID),void 0!==n.map&&(n.map.colorSpace=en);break;case"DisplacementColor":n.displacementMap=r.getTexture(t,e.ID);break;case"EmissiveColor":n.emissiveMap=r.getTexture(t,e.ID),void 0!==n.emissiveMap&&(n.emissiveMap.colorSpace=en);break;case"NormalMap":case"Maya|TEX_normal_map":n.normalMap=r.getTexture(t,e.ID);break;case"ReflectionColor":n.envMap=r.getTexture(t,e.ID),void 0!==n.envMap&&(n.envMap.mapping=vm,n.envMap.colorSpace=en);break;case"SpecularColor":n.specularMap=r.getTexture(t,e.ID),void 0!==n.specularMap&&(n.specularMap.colorSpace=en);break;case"TransparentColor":case"TransparencyFactor":n.alphaMap=r.getTexture(t,e.ID),n.transparent=!0;break;default:console.warn("THREE.FBXLoader: %s map is not supported in three.js, skipping texture.",i)}})),n}getTexture(e,t){return"LayeredTexture"in Ir.Objects&&t in Ir.Objects.LayeredTexture&&(console.warn("THREE.FBXLoader: layered textures are not supported in three.js. Discarding all but first layer."),t=gs.get(t).children[0].ID),e.get(t)}parseDeformers(){let e={},t={};if("Deformer"in Ir.Objects){let i=Ir.Objects.Deformer;for(let n in i){let r=i[n],a=gs.get(parseInt(n));if("Skin"===r.attrType){let t=this.parseSkeleton(a,i);t.ID=n,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[n]=t}else if("BlendShape"===r.attrType){let e={id:n};e.rawTargets=this.parseMorphTargets(a,i),e.id=n,a.parents.length>1&&console.warn("THREE.FBXLoader: morph target attached to more than one geometry is not supported."),t[n]=e}}}return{skeletons:e,morphTargets:t}}parseSkeleton(e,t){let i=[];return e.children.forEach((function(e){let n=t[e.ID];if("Cluster"!==n.attrType)return;let r={ID:e.ID,indices:[],weights:[],transformLink:(new et).fromArray(n.TransformLink.a)};"Indexes"in n&&(r.indices=n.Indexes.a,r.weights=n.Weights.a),i.push(r)})),{rawBones:i,bones:[]}}parseMorphTargets(e,t){let i=[];for(let n=0;n<e.children.length;n++){let r=e.children[n],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=gs.get(parseInt(r.ID)).children.filter((function(e){return void 0===e.relationship}))[0].ID,i.push(s)}return i}parseScene(e,t,i){bo=new er;let n=this.parseModels(e.skeletons,t,i),r=Ir.Objects.Model,a=this;n.forEach((function(e){let t=r[e.ID];a.setLookAtProperties(e,t),gs.get(e.ID).parents.forEach((function(t){let i=n.get(t.ID);void 0!==i&&i.add(e)})),null===e.parent&&bo.add(e)})),this.bindSkeleton(e.skeletons,t,n),this.createAmbientLight(),bo.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=H0e(e.userData.transformData);e.applyMatrix4(t),e.updateWorldMatrix()}}));let s=(new G6).parse();1===bo.children.length&&bo.children[0].isGroup&&(bo.children[0].animations=s,bo=bo.children[0]),bo.animations=s}parseModels(e,t,i){let n=new Map,r=Ir.Objects.Model;for(let a in r){let s=parseInt(a),o=r[a],l=gs.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,i);break;case"NurbsCurve":h=this.createCurve(l,t);break;case"LimbNode":case"Root":h=new Sl;break;default:h=new er}h.name=o.attrName?Jn.sanitizeNodeName(o.attrName):"",h.ID=s}this.getTransformData(h,o),n.set(s,h)}return n}buildSkeleton(e,t,i,n){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=n?Jn.sanitizeNodeName(n):"",r.ID=i,s.bones[a]=r,null!==e&&r.add(e)}}))}})),r}createCamera(e){let t,i;if(e.children.forEach((function(e){let t=Ir.Objects.NodeAttribute[e.ID];void 0!==t&&(i=t)})),void 0===i)t=new on;else{let e=0;void 0!==i.CameraProjectionType&&1===i.CameraProjectionType.value&&(e=1);let n=1;void 0!==i.NearPlane&&(n=i.NearPlane.value/1e3);let r=1e3;void 0!==i.FarPlane&&(r=i.FarPlane.value/1e3);let a=window.innerWidth,s=window.innerHeight;void 0!==i.AspectWidth&&void 0!==i.AspectHeight&&(a=i.AspectWidth.value,s=i.AspectHeight.value);let o=a/s,l=45;void 0!==i.FieldOfView&&(l=i.FieldOfView.value);let h=i.FocalLength?i.FocalLength.value:null;switch(e){case 0:t=new hr(l,o,n,r),null!==h&&t.setFocalLength(h);break;case 1:t=new Nr(-a/2,a/2,s/2,-s/2,n,r);break;default:console.warn("THREE.FBXLoader: Unknown camera type "+e+"."),t=new on}}return t}createLight(e){let t,i;if(e.children.forEach((function(e){let t=Ir.Objects.NodeAttribute[e.ID];void 0!==t&&(i=t)})),void 0===i)t=new on;else{let e;e=void 0===i.LightType?0:i.LightType.value;let n=16777215;void 0!==i.Color&&(n=(new ct).fromArray(i.Color.value).convertSRGBToLinear());let r=void 0===i.Intensity?1:i.Intensity.value/100;void 0!==i.CastLightOnObject&&0===i.CastLightOnObject.value&&(r=0);let a=0;void 0!==i.FarAttenuationEnd&&(a=void 0!==i.EnableFarAttenuation&&0===i.EnableFarAttenuation.value?0:i.FarAttenuationEnd.value);let s=1;switch(e){case 0:t=new wc(n,r,a,s);break;case 1:t=new qs(n,r);break;case 2:let e=Math.PI/3;void 0!==i.InnerAngle&&(e=Rn.degToRad(i.InnerAngle.value));let o=0;void 0!==i.OuterAngle&&(o=Rn.degToRad(i.OuterAngle.value),o=Math.max(o,1)),t=new Ou(n,r,a,e,o,s);break;default:console.warn("THREE.FBXLoader: Unknown light type "+i.LightType.value+", defaulting to a PointLight."),t=new wc(n,r)}void 0!==i.CastShadows&&1===i.CastShadows.value&&(t.castShadow=!0)}return t}createMesh(e,t,i){let n,r=null,a=null,s=[];return e.children.forEach((function(e){t.has(e.ID)&&(r=t.get(e.ID)),i.has(e.ID)&&s.push(i.get(e.ID))})),s.length>1?a=s:s.length>0?a=s[0]:(a=new ea({name:Er.DEFAULT_MATERIAL_NAME,color:13421772}),s.push(a)),"color"in r.attributes&&s.forEach((function(e){e.vertexColors=!0})),r.FBX_Deformer?(n=new wu(r,a),n.normalizeSkinWeights()):n=new xt(r,a),n}createCurve(e,t){let i=e.children.reduce((function(e,i){return t.has(i.ID)&&(e=t.get(i.ID)),e}),null),n=new Gn({name:Er.DEFAULT_MATERIAL_NAME,color:3342591,linewidth:1});return new fr(i,n)}getTransformData(e,t){let i={};"InheritType"in t&&(i.inheritType=parseInt(t.InheritType.value)),i.eulerOrder="RotationOrder"in t?V0e(t.RotationOrder.value):"ZYX","Lcl_Translation"in t&&(i.translation=t.Lcl_Translation.value),"PreRotation"in t&&(i.preRotation=t.PreRotation.value),"Lcl_Rotation"in t&&(i.rotation=t.Lcl_Rotation.value),"PostRotation"in t&&(i.postRotation=t.PostRotation.value),"Lcl_Scaling"in t&&(i.scale=t.Lcl_Scaling.value),"ScalingOffset"in t&&(i.scalingOffset=t.ScalingOffset.value),"ScalingPivot"in t&&(i.scalingPivot=t.ScalingPivot.value),"RotationOffset"in t&&(i.rotationOffset=t.RotationOffset.value),"RotationPivot"in t&&(i.rotationPivot=t.RotationPivot.value),e.userData.transformData=i}setLookAtProperties(e,t){"LookAtProperty"in t&&gs.get(e.ID).children.forEach((function(t){if("LookAtProperty"===t.relationship){let i=Ir.Objects.Model[t.ID];if("Lcl_Translation"in i){let t=i.Lcl_Translation.value;void 0!==e.target?(e.target.position.fromArray(t),bo.add(e.target)):e.lookAt((new D).fromArray(t))}}}))}bindSkeleton(e,t,i){let n=this.parsePoseNodes();for(let r in e){let a=e[r];gs.get(parseInt(a.ID)).parents.forEach((function(e){if(t.has(e.ID)){let t=e.ID;gs.get(t).parents.forEach((function(e){i.has(e.ID)&&i.get(e.ID).bind(new Ml(a.bones),n[e.ID])}))}}))}}parsePoseNodes(){let e={};if("Pose"in Ir.Objects){let t=Ir.Objects.Pose;for(let i in t)if("BindPose"===t[i].attrType&&t[i].NbPoseNodes>0){let n=t[i].PoseNode;Array.isArray(n)?n.forEach((function(t){e[t.Node]=(new et).fromArray(t.Matrix.a)})):e[n.Node]=(new et).fromArray(n.Matrix.a)}}return e}createAmbientLight(){if("GlobalSettings"in Ir&&"AmbientColor"in Ir.GlobalSettings){let e=Ir.GlobalSettings.AmbientColor.value,t=e[0],i=e[1],n=e[2];if(0!==t||0!==i||0!==n){let e=new ct(t,i,n).convertSRGBToLinear();bo.add(new Cl(e,1))}}}},z6=class{constructor(){this.negativeMaterialIndices=!1}parse(e){let t=new Map;if("Geometry"in Ir.Objects){let i=Ir.Objects.Geometry;for(let n in i){let r=gs.get(parseInt(n)),a=this.parseGeometry(r,i[n],e);t.set(parseInt(n),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,i){switch(t.attrType){case"Mesh":return this.parseMeshGeometry(e,t,i);case"NurbsCurve":return this.parseNurbsGeometry(t)}}parseMeshGeometry(e,t,i){let n=i.skeletons,r=[],a=e.parents.map((function(e){return Ir.Objects.Model[e.ID]}));if(0===a.length)return;let s=e.children.reduce((function(e,t){return void 0!==n[t.ID]&&(e=n[t.ID]),e}),null);e.children.forEach((function(e){void 0!==i.morphTargets[e.ID]&&r.push(i.morphTargets[e.ID])}));let o=a[0],l={};"RotationOrder"in o&&(l.eulerOrder=V0e(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=H0e(l);return this.genGeometry(t,s,r,h)}genGeometry(e,t,i,n){let r=new Dt;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(n),r.setAttribute("position",o),s.colors.length>0&&r.setAttribute("color",new Bt(s.colors,3)),t&&(r.setAttribute("skinIndex",new ym(s.weightsIndices,4)),r.setAttribute("skinWeight",new Bt(s.vertexWeights,4)),r.FBX_Deformer=t),s.normal.length>0){let e=(new Ln).getNormalMatrix(n),t=new Bt(s.normal,3);t.applyNormalMatrix(e),r.setAttribute("normal",t)}if(s.uvs.forEach((function(e,t){let i=0===t?"uv":`uv${t}`;r.setAttribute(i,new Bt(s.uvs[t],2))})),a.material&&"AllSame"!==a.material.mappingType){let e=s.materialIndex[0],t=0;if(s.materialIndex.forEach((function(i,n){i!==e&&(r.addGroup(t,n-t,e),e=i,t=n)})),r.groups.length>0){let t=r.groups[r.groups.length-1],i=t.start+t.count;i!==s.materialIndex.length&&r.addGroup(i,s.materialIndex.length-i,e)}0===r.groups.length&&r.addGroup(0,s.materialIndex.length,s.materialIndex[0])}return this.addMorphTargets(r,e,i,n),r}parseGeoNode(e,t){let i={};if(i.vertexPositions=void 0!==e.Vertices?e.Vertices.a:[],i.vertexIndices=void 0!==e.PolygonVertexIndex?e.PolygonVertexIndex.a:[],e.LayerElementColor&&(i.color=this.parseVertexColors(e.LayerElementColor[0])),e.LayerElementMaterial&&(i.material=this.parseMaterialIndices(e.LayerElementMaterial[0])),e.LayerElementNormal&&(i.normal=this.parseNormals(e.LayerElementNormal[0])),e.LayerElementUV){i.uv=[];let t=0;for(;e.LayerElementUV[t];)e.LayerElementUV[t].UV&&i.uv.push(this.parseUVs(e.LayerElementUV[t])),t++}return i.weightTable={},null!==t&&(i.skeleton=t,t.rawBones.forEach((function(e,t){e.indices.forEach((function(n,r){void 0===i.weightTable[n]&&(i.weightTable[n]=[]),i.weightTable[n].push({id:t,weight:e.weights[r]})}))}))),i}genBuffers(e){let t={vertex:[],normal:[],colors:[],uvs:[],materialIndex:[],vertexWeights:[],weightsIndices:[]},i=0,n=0,r=!1,a=[],s=[],o=[],l=[],h=[],c=[],u=this;return e.vertexIndices.forEach((function(d,p){let f,m=!1;d<0&&(d^=-1,m=!0);let g=[],v=[];if(a.push(3*d,3*d+1,3*d+2),e.color){let t=lP(p,i,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(i,n){let r=i,a=g[n];t.forEach((function(t,i,n){if(r>t){n[i]=r,r=t;let s=e[i];e[i]=a,a=s}}))})),g=e,v=t}for(;v.length<4;)v.push(0),g.push(0);for(let e=0;e<4;++e)h.push(v[e]),c.push(g[e])}if(e.normal){let t=lP(p,i,d,e.normal);s.push(t[0],t[1],t[2])}e.material&&"AllSame"!==e.material.mappingType&&(f=lP(p,i,d,e.material)[0],f<0&&(u.negativeMaterialIndices=!0,f=0)),e.uv&&e.uv.forEach((function(e,t){let n=lP(p,i,d,e);void 0===l[t]&&(l[t]=[]),l[t].push(n[0]),l[t].push(n[1])})),n++,m&&(n>4&&console.warn("THREE.FBXLoader: Polygons with more than four sides are not supported. Make sure to triangulate the geometry during export."),u.genFace(t,e,a,f,s,o,l,h,c,n),i++,n=0,a=[],s=[],o=[],l=[],h=[],c=[])})),t}genFace(e,t,i,n,r,a,s,o,l,h){for(let c=2;c<h;c++)e.vertex.push(t.vertexPositions[i[0]]),e.vertex.push(t.vertexPositions[i[1]]),e.vertex.push(t.vertexPositions[i[2]]),e.vertex.push(t.vertexPositions[i[3*(c-1)]]),e.vertex.push(t.vertexPositions[i[3*(c-1)+1]]),e.vertex.push(t.vertexPositions[i[3*(c-1)+2]]),e.vertex.push(t.vertexPositions[i[3*c]]),e.vertex.push(t.vertexPositions[i[3*c+1]]),e.vertex.push(t.vertexPositions[i[3*c+2]]),t.skeleton&&(e.vertexWeights.push(o[0]),e.vertexWeights.push(o[1]),e.vertexWeights.push(o[2]),e.vertexWeights.push(o[3]),e.vertexWeights.push(o[4*(c-1)]),e.vertexWeights.push(o[4*(c-1)+1]),e.vertexWeights.push(o[4*(c-1)+2]),e.vertexWeights.push(o[4*(c-1)+3]),e.vertexWeights.push(o[4*c]),e.vertexWeights.push(o[4*c+1]),e.vertexWeights.push(o[4*c+2]),e.vertexWeights.push(o[4*c+3]),e.weightsIndices.push(l[0]),e.weightsIndices.push(l[1]),e.weightsIndices.push(l[2]),e.weightsIndices.push(l[3]),e.weightsIndices.push(l[4*(c-1)]),e.weightsIndices.push(l[4*(c-1)+1]),e.weightsIndices.push(l[4*(c-1)+2]),e.weightsIndices.push(l[4*(c-1)+3]),e.weightsIndices.push(l[4*c]),e.weightsIndices.push(l[4*c+1]),e.weightsIndices.push(l[4*c+2]),e.weightsIndices.push(l[4*c+3])),t.color&&(e.colors.push(a[0]),e.colors.push(a[1]),e.colors.push(a[2]),e.colors.push(a[3*(c-1)]),e.colors.push(a[3*(c-1)+1]),e.colors.push(a[3*(c-1)+2]),e.colors.push(a[3*c]),e.colors.push(a[3*c+1]),e.colors.push(a[3*c+2])),t.material&&"AllSame"!==t.material.mappingType&&(e.materialIndex.push(n),e.materialIndex.push(n),e.materialIndex.push(n)),t.normal&&(e.normal.push(r[0]),e.normal.push(r[1]),e.normal.push(r[2]),e.normal.push(r[3*(c-1)]),e.normal.push(r[3*(c-1)+1]),e.normal.push(r[3*(c-1)+2]),e.normal.push(r[3*c]),e.normal.push(r[3*c+1]),e.normal.push(r[3*c+2])),t.uv&&t.uv.forEach((function(t,i){void 0===e.uvs[i]&&(e.uvs[i]=[]),e.uvs[i].push(s[i][0]),e.uvs[i].push(s[i][1]),e.uvs[i].push(s[i][2*(c-1)]),e.uvs[i].push(s[i][2*(c-1)+1]),e.uvs[i].push(s[i][2*c]),e.uvs[i].push(s[i][2*c+1])}))}addMorphTargets(e,t,i,n){if(0===i.length)return;e.morphTargetsRelative=!0,e.morphAttributes.position=[];let r=this;i.forEach((function(i){i.rawTargets.forEach((function(i){let a=Ir.Objects.Geometry[i.geoID];void 0!==a&&r.genMorphGeometry(e,t,a,n,i.name)}))}))}genMorphGeometry(e,t,i,n,r){let a=void 0!==t.PolygonVertexIndex?t.PolygonVertexIndex.a:[],s=void 0!==i.Vertices?i.Vertices.a:[],o=void 0!==i.Indexes?i.Indexes.a:[],l=3*e.attributes.position.count,h=new Float32Array(l);for(let p=0;p<o.length;p++){let e=3*o[p];h[e]=s[3*p],h[e+1]=s[3*p+1],h[e+2]=s[3*p+2]}let c={vertexIndices:a,vertexPositions:h},u=this.genBuffers(c),d=new Bt(u.vertex,3);d.name=r||i.attrName,d.applyMatrix4(n),e.morphAttributes.position.push(d)}parseNormals(e){let t=e.MappingInformationType,i=e.ReferenceInformationType,n=e.Normals.a,r=[];return"IndexToDirect"===i&&("NormalIndex"in e?r=e.NormalIndex.a:"NormalsIndex"in e&&(r=e.NormalsIndex.a)),{dataSize:3,buffer:n,indices:r,mappingType:t,referenceType:i}}parseUVs(e){let t=e.MappingInformationType,i=e.ReferenceInformationType,n=e.UV.a,r=[];return"IndexToDirect"===i&&(r=e.UVIndex.a),{dataSize:2,buffer:n,indices:r,mappingType:t,referenceType:i}}parseVertexColors(e){let t=e.MappingInformationType,i=e.ReferenceInformationType,n=e.Colors.a,r=[];"IndexToDirect"===i&&(r=e.ColorIndex.a);for(let a=0,s=new ct;a<n.length;a+=4)s.fromArray(n,a).convertSRGBToLinear().toArray(n,a);return{dataSize:4,buffer:n,indices:r,mappingType:t,referenceType:i}}parseMaterialIndices(e){let t=e.MappingInformationType,i=e.ReferenceInformationType;if("NoMappingInformation"===t)return{dataSize:1,buffer:[0],indices:[0],mappingType:"AllSame",referenceType:i};let n=e.Materials.a,r=[];for(let a=0;a<n.length;++a)r.push(a);return{dataSize:1,buffer:n,indices:r,mappingType:t,referenceType:i}}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 Dt;let i,n,r=t-1,a=e.KnotVector.a,s=[],o=e.Points.a;for(let h=0,c=o.length;h<c;h+=4)s.push((new gr).fromArray(o,h));if("Closed"===e.Form)s.push(s[0]);else if("Periodic"===e.Form){i=r,n=a.length-1-i;for(let e=0;e<r;++e)s.push(s[e])}let l=new oP(r,a,s,i,n).getPoints(12*s.length);return(new Dt).setFromPoints(l)}},G6=class{parse(){let e=[],t=this.parseClips();if(void 0!==t)for(let i in t){let n=t[i],r=this.addClip(n);e.push(r)}return e}parseClips(){if(void 0===Ir.Objects.AnimationCurve)return;let e=this.parseAnimationCurveNodes();this.parseAnimationCurves(e);let t=this.parseAnimationLayers(e);return this.parseAnimStacks(t)}parseAnimationCurveNodes(){let e=Ir.Objects.AnimationCurveNode,t=new Map;for(let i in e){let n=e[i];if(null!==n.attrName.match(/S|R|T|DeformPercent/)){let e={id:n.id,attr:n.attrName,curves:{}};t.set(e.id,e)}}return t}parseAnimationCurves(e){let t=Ir.Objects.AnimationCurve;for(let i in t){let n={id:t[i].id,times:t[i].KeyTime.a.map(xgt),values:t[i].KeyValueFloat.a},r=gs.get(n.id);if(void 0!==r){let t=r.parents[0].ID,i=r.parents[0].relationship;i.match(/X/)?e.get(t).curves.x=n:i.match(/Y/)?e.get(t).curves.y=n:i.match(/Z/)?e.get(t).curves.z=n:i.match(/DeformPercent/)&&e.has(t)&&(e.get(t).curves.morph=n)}}}parseAnimationLayers(e){let t=Ir.Objects.AnimationLayer,i=new Map;for(let n in t){let t=[],r=gs.get(parseInt(n));void 0!==r&&(r.children.forEach((function(i,n){if(e.has(i.ID)){let r=e.get(i.ID);if(void 0!==r.curves.x||void 0!==r.curves.y||void 0!==r.curves.z){if(void 0===t[n]){let e=gs.get(i.ID).parents.filter((function(e){return void 0!==e.relationship}))[0].ID;if(void 0!==e){let r=Ir.Objects.Model[e.toString()];if(void 0===r)return void console.warn("THREE.FBXLoader: Encountered a unused curve.",i);let a={modelName:r.attrName?Jn.sanitizeNodeName(r.attrName):"",ID:r.id,initialPosition:[0,0,0],initialRotation:[0,0,0],initialScale:[1,1,1]};bo.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 et),"PreRotation"in r&&(a.preRotation=r.PreRotation.value),"PostRotation"in r&&(a.postRotation=r.PostRotation.value),t[n]=a}}t[n]&&(t[n][r.attr]=r)}else if(void 0!==r.curves.morph){if(void 0===t[n]){let e=gs.get(i.ID).parents.filter((function(e){return void 0!==e.relationship}))[0].ID,r=gs.get(e).parents[0].ID,a=gs.get(r).parents[0].ID,s=gs.get(a).parents[0].ID,o=Ir.Objects.Model[s],l={modelName:o.attrName?Jn.sanitizeNodeName(o.attrName):"",morphName:Ir.Objects.Deformer[e].attrName};t[n]=l}t[n][r.attr]=r}}})),i.set(parseInt(n),t))}return i}parseAnimStacks(e){let t=Ir.Objects.AnimationStack,i={};for(let n in t){let r=gs.get(parseInt(n)).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);i[n]={name:t[n].attrName,layer:a}}return i}addClip(e){let t=[],i=this;return e.layer.forEach((function(e){t=t.concat(i.generateTracks(e))})),new uo(e.name,-1,t)}generateTracks(e){let t=[],i=new D,n=new dr,r=new D;if(e.transform&&e.transform.decompose(i,n,r),i=i.toArray(),n=(new Xn).setFromQuaternion(n,e.eulerOrder).toArray(),r=r.toArray(),void 0!==e.T&&Object.keys(e.T.curves).length>0){let n=this.generateVectorTrack(e.modelName,e.T.curves,i,"position");void 0!==n&&t.push(n)}if(void 0!==e.R&&Object.keys(e.R.curves).length>0){let i=this.generateRotationTrack(e.modelName,e.R.curves,n,e.preRotation,e.postRotation,e.eulerOrder);void 0!==i&&t.push(i)}if(void 0!==e.S&&Object.keys(e.S.curves).length>0){let i=this.generateVectorTrack(e.modelName,e.S.curves,r,"scale");void 0!==i&&t.push(i)}if(void 0!==e.DeformPercent){let i=this.generateMorphTrack(e);void 0!==i&&t.push(i)}return t}generateVectorTrack(e,t,i,n){let r=this.getTimesForAllAxes(t),a=this.getKeyframeTrackValues(r,t,i);return new Va(e+"."+n,r,a)}generateRotationTrack(e,t,i,n,r,a){void 0!==t.x&&(this.interpolateRotations(t.x),t.x.values=t.x.values.map(Rn.degToRad)),void 0!==t.y&&(this.interpolateRotations(t.y),t.y.values=t.y.values.map(Rn.degToRad)),void 0!==t.z&&(this.interpolateRotations(t.z),t.z.values=t.z.values.map(Rn.degToRad));let s=this.getTimesForAllAxes(t),o=this.getKeyframeTrackValues(s,t,i);void 0!==n&&((n=n.map(Rn.degToRad)).push(a),n=(new Xn).fromArray(n),n=(new dr).setFromEuler(n)),void 0!==r&&((r=r.map(Rn.degToRad)).push(a),r=(new Xn).fromArray(r),r=(new dr).setFromEuler(r).invert());let l=new dr,h=new Xn,c=[];for(let u=0;u<o.length;u+=3)h.set(o[u],o[u+1],o[u+2],a),l.setFromEuler(h),void 0!==n&&l.premultiply(n),void 0!==r&&l.multiply(r),l.toArray(c,u/3*4);return new Ha(e+".quaternion",s,c)}generateMorphTrack(e){let t=e.DeformPercent.curves.morph,i=t.values.map((function(e){return e/100})),n=bo.getObjectByName(e.modelName).morphTargetDictionary[e.morphName];return new Al(e.modelName+".morphTargetInfluences["+n+"]",t.times,i)}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,i=t[0];for(let n=1;n<t.length;n++){let r=t[n];r!==i&&(t[e]=r,i=r,e++)}t=t.slice(0,e)}return t}getKeyframeTrackValues(e,t,i){let n=i,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),n[0]=e}else r.push(n[0]);if(-1!==s){let e=t.y.values[s];r.push(e),n[1]=e}else r.push(n[1]);if(-1!==o){let e=t.z.values[o];r.push(e),n[2]=e}else r.push(n[2])})),r}interpolateRotations(e){for(let t=1;t<e.values.length;t++){let i=e.values[t-1],n=e.values[t]-i,r=Math.abs(n);if(r>=180){let a=r/180,s=n/a,o=i+s,l=e.times[t-1],h=(e.times[t]-l)/a,c=l+h,u=[],d=[];for(;c<e.times[t];)u.push(c),c+=h,d.push(o),o+=s;e.times=U0e(e.times,t,u),e.values=U0e(e.values,t,d)}}}},q6=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 hP,this.nodeStack=[],this.currentProp=[],this.currentPropName="";let t=this,i=e.split(/[\r\n]+/);return i.forEach((function(e,n){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,i[++n]):l?t.popStack():e.match(/^[^\s\t}]/)&&t.parseNodePropertyContinued(e)})),this.allNodes}parseNodeBegin(e,t){let i=t[1].trim().replace(/^"/,"").replace(/"$/,""),n=t[2].split(",").map((function(e){return e.trim().replace(/^"/,"").replace(/"$/,"")})),r={name:i},a=this.parseNodeAttr(n),s=this.getCurrentNode();0===this.currentIndent?this.allNodes.add(i,r):i in s?("PoseNode"===i?s.PoseNode.push(r):void 0!==s[i].id&&(s[i]={},s[i][s[i].id]=s[i]),""!==a.id&&(s[i][a.id]=r)):"number"==typeof a.id?(s[i]={},s[i][a.id]=r):"Properties70"!==i&&(s[i]="PoseNode"===i?[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 i="",n="";return e.length>1&&(i=e[1].replace(/^(\w+)::/,""),n=e[2]),{id:t,name:i,type:n}}parseNodeProperty(e,t,i){let n=t[1].replace(/^"/,"").replace(/"$/,"").trim(),r=t[2].replace(/^"/,"").replace(/"$/,"").trim();"Content"===n&&","===r&&(r=i.replace(/"/g,"").replace(/,$/,"").trim());let a=this.getCurrentNode();if("Properties70"!==a.name){if("C"===n){let e=r.split(",").slice(1),t=parseInt(e[0]),i=parseInt(e[1]),s=r.split(",").slice(3);s=s.map((function(e){return e.trim().replace(/^"/,"")})),n="connections",r=[t,i],Egt(r,s),void 0===a[n]&&(a[n]=[])}"Node"===n&&(a.id=r),n in a&&Array.isArray(a[n])?a[n].push(r):"a"!==n?a[n]=r:a.a=r,this.setCurrentProp(a,n),"a"===n&&","!==r.slice(-1)&&(a.a=H6(r))}else this.parseNodeSpecialProperty(e,n,r)}parseNodePropertyContinued(e){let t=this.getCurrentNode();t.a+=e,","!==e.slice(-1)&&(t.a=H6(t.a))}parseNodeSpecialProperty(e,t,i){let n=i.split('",').map((function(e){return e.trim().replace(/^\"/,"").replace(/\s/,"_")})),r=n[0],a=n[1],s=n[2],o=n[3],l=n[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=H6(l)}this.getPrevNode()[r]={type:a,type2:s,flag:o,value:l},this.setCurrentProp(this.getPrevNode(),r)}},W6=class{parse(e){let t=new uP(e);t.skip(23);let i=t.getUint32();if(i<6400)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+i);let n=new hP;for(;!this.endOfContent(t);){let e=this.parseNode(t,i);null!==e&&n.add(e.name,e)}return n}endOfContent(e){return e.size()%16==0?(e.getOffset()+160+16&-16)>=e.size():e.getOffset()+160+16>=e.size()}parseNode(e,t){let i={},n=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===n)return null;let o=[];for(let u=0;u<r;u++)o.push(this.parseProperty(e));let l=o.length>0?o[0]:"",h=o.length>1?o[1]:"",c=o.length>2?o[2]:"";for(i.singleProperty=1===r&&e.getOffset()===n;n>e.getOffset();){let n=this.parseNode(e,t);null!==n&&this.parseSubNode(s,i,n)}return i.propertyList=o,"number"==typeof l&&(i.id=l),""!==h&&(i.attrName=h),""!==c&&(i.attrType=c),""!==s&&(i.name=s),i}parseSubNode(e,t,i){if(!0===i.singleProperty){let e=i.propertyList[0];Array.isArray(e)?(t[i.name]=i,i.a=e):t[i.name]=e}else if("Connections"===e&&"C"===i.name){let e=[];i.propertyList.forEach((function(t,i){0!==i&&e.push(t)})),void 0===t.connections&&(t.connections=[]),t.connections.push(e)}else if("Properties70"===i.name)Object.keys(i).forEach((function(e){t[e]=i[e]}));else if("Properties70"===e&&"P"===i.name){let e,n=i.propertyList[0],r=i.propertyList[1],a=i.propertyList[2],s=i.propertyList[3];0===n.indexOf("Lcl ")&&(n=n.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_")?[i.propertyList[4],i.propertyList[5],i.propertyList[6]]:i.propertyList[4],t[n]={type:r,type2:a,flag:s,value:e}}else void 0===t[i.name]?"number"==typeof i.id?(t[i.name]={},t[i.name][i.id]=i):t[i.name]=i:"PoseNode"===i.name?(Array.isArray(t[i.name])||(t[i.name]=[t[i.name]]),t[i.name].push(i)):void 0===t[i.name][i.id]&&(t[i.name][i.id]=i)}parseProperty(e){let t,i=e.getString(1);switch(i){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 n=e.getUint32(),r=e.getUint32(),a=e.getUint32();if(0===r)switch(i){case"b":case"c":return e.getBooleanArray(n);case"d":return e.getFloat64Array(n);case"f":return e.getFloat32Array(n);case"i":return e.getInt32Array(n);case"l":return e.getInt64Array(n)}let s=O0e(new Uint8Array(e.getArrayBuffer(a))),o=new uP(s.buffer);switch(i){case"b":case"c":return o.getBooleanArray(n);case"d":return o.getFloat64Array(n);case"f":return o.getFloat32Array(n);case"i":return o.getInt32Array(n);case"l":return o.getInt64Array(n)}break;default:throw new Error("THREE.FBXLoader: Unknown property type "+i)}}},uP=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 i=0;i<e;i++)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 i=0;i<e;i++)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 i=0;i<e;i++)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 i=0;i<e;i++)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 i=0;i<e;i++)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,i=new Uint8Array(this.dv.buffer,t,e);this.skip(e);let n=i.indexOf(0);return n>=0&&(i=new Uint8Array(this.dv.buffer,t,n)),this._textDecoder.decode(i)}},hP=class{add(e,t){this[e]=t}};function vgt(e){let t="Kaydara FBX Binary \0";return e.byteLength>=21&&t===z0e(e,0,21)}function ygt(e){let t=["K","a","y","d","a","r","a","\\","F","B","X","\\","B","i","n","a","r","y","\\","\\"],i=0;function n(t){let n=e[t-1];return e=e.slice(i+t),i++,n}for(let r=0;r<t.length;++r)if(n(1)===t[r])return!1;return!0}function B0e(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 xgt(e){return e/46186158e3}var bgt=[];function lP(e,t,i,n){let r;switch(n.mappingType){case"ByPolygonVertex":r=e;break;case"ByPolygon":r=t;break;case"ByVertice":r=i;break;case"AllSame":r=n.indices[0];break;default:console.warn("THREE.FBXLoader: unknown attribute mapping type "+n.mappingType)}"IndexToDirect"===n.referenceType&&(r=n.indices[r]);let a=r*n.dataSize,s=a+n.dataSize;return _gt(bgt,n.buffer,a,s)}var U6=new Xn,Iy=new D;function H0e(e){let t=new et,i=new et,n=new et,r=new et,a=new et,s=new et,o=new et,l=new et,h=new et,c=new et,u=new et,d=new et,p=e.inheritType?e.inheritType:0;if(e.translation&&t.setPosition(Iy.fromArray(e.translation)),e.preRotation){let t=e.preRotation.map(Rn.degToRad);t.push(e.eulerOrder||Xn.DEFAULT_ORDER),i.makeRotationFromEuler(U6.fromArray(t))}if(e.rotation){let t=e.rotation.map(Rn.degToRad);t.push(e.eulerOrder||Xn.DEFAULT_ORDER),n.makeRotationFromEuler(U6.fromArray(t))}if(e.postRotation){let t=e.postRotation.map(Rn.degToRad);t.push(e.eulerOrder||Xn.DEFAULT_ORDER),r.makeRotationFromEuler(U6.fromArray(t)),r.invert()}e.scale&&a.scale(Iy.fromArray(e.scale)),e.scalingOffset&&o.setPosition(Iy.fromArray(e.scalingOffset)),e.scalingPivot&&s.setPosition(Iy.fromArray(e.scalingPivot)),e.rotationOffset&&l.setPosition(Iy.fromArray(e.rotationOffset)),e.rotationPivot&&h.setPosition(Iy.fromArray(e.rotationPivot)),e.parentMatrixWorld&&(u.copy(e.parentMatrix),c.copy(e.parentMatrixWorld));let f=i.clone().multiply(n).multiply(r),m=new et;m.extractRotation(c);let g=new et;g.copyPosition(c);let v=g.clone().invert().multiply(c),y=m.clone().invert().multiply(v),x=a,b=new et;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 et).scale((new D).setFromMatrixScale(u)).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(i).multiply(n).multiply(r).multiply(_).multiply(o).multiply(s).multiply(a).multiply(w),M=(new et).copyPosition(S),E=c.clone().multiply(M);return d.copyPosition(E),S=d.clone().multiply(b),S.premultiply(c.invert()),S}function V0e(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 H6(e){return e.split(",").map((function(e){return parseFloat(e)}))}function z0e(e,t,i){return void 0===t&&(t=0),void 0===i&&(i=e.byteLength),(new TextDecoder).decode(new Uint8Array(e,t,i))}function Egt(e,t){for(let i=0,n=e.length,r=t.length;i<r;i++,n++)e[n]=t[i]}function _gt(e,t,i,n){for(let r=i,a=0;r<n;r++,a++)e[a]=t[r];return e}function U0e(e,t,i){return e.slice(0,t).concat(i).concat(e.slice(t))}var eh=class extends Er{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register((function(e){return new J6(e)})),this.register((function(e){return new a4(e)})),this.register((function(e){return new o4(e)})),this.register((function(e){return new l4(e)})),this.register((function(e){return new e4(e)})),this.register((function(e){return new t4(e)})),this.register((function(e){return new n4(e)})),this.register((function(e){return new r4(e)})),this.register((function(e){return new K6(e)})),this.register((function(e){return new i4(e)})),this.register((function(e){return new Q6(e)})),this.register((function(e){return new s4(e)})),this.register((function(e){return new $6(e)})),this.register((function(e){return new c4(e)})),this.register((function(e){return new u4(e)}))}load(e,t,i,n){let r,a=this;r=""!==this.resourcePath?this.resourcePath:""!==this.path?this.path:ta.extractUrlBase(e),this.manager.itemStart(e);let s=function(t){n?n(t):console.error(t),a.manager.itemError(e),a.manager.itemEnd(e)},o=new Kr(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,(function(i){try{a.parse(i,r,(function(i){t(i),a.manager.itemEnd(e)}),s)}catch(e){s(e)}}),i,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,i,n){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))===X0e){try{a[jr.KHR_BINARY_GLTF]=new h4(e)}catch(e){return void(n&&n(e))}r=JSON.parse(a[jr.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(n&&n(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.")));let l=new y4(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 jr.KHR_MATERIALS_UNLIT:a[e]=new Z6;break;case jr.KHR_DRACO_MESH_COMPRESSION:a[e]=new d4(r,this.dracoLoader);break;case jr.KHR_TEXTURE_TRANSFORM:a[e]=new f4;break;case jr.KHR_MESH_QUANTIZATION:a[e]=new p4;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(i,n)}parseAsync(e,t){let i=this;return new Promise((function(n,r){i.parse(e,t,n,r)}))}};function Tgt(){let e={};return{get:function(t){return e[t]},add:function(t,i){e[t]=i},remove:function(t){delete e[t]},removeAll:function(){e={}}}}var jr={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"},$6=class{constructor(e){this.parser=e,this.name=jr.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){let e=this.parser,t=this.parser.json.nodes||[];for(let i=0,n=t.length;i<n;i++){let n=t[i];n.extensions&&n.extensions[this.name]&&void 0!==n.extensions[this.name].light&&e._addNodeRef(this.cache,n.extensions[this.name].light)}}_loadLight(e){let t=this.parser,i="light:"+e,n=t.cache.get(i);if(n)return n;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 qs(o),r.target.position.set(0,0,-1),r.add(r.target);break;case"point":r=new wc(o),r.distance=l;break;case"spot":r=new Ou(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,Jf(r,s),void 0!==s.intensity&&(r.intensity=s.intensity),r.name=t.createUniqueName(s.name||"light_"+e),n=Promise.resolve(r),t.cache.add(i,n),n}getDependency(e,t){if("light"===e)return this._loadLight(t)}createNodeAttachment(e){let t=this,i=this.parser,n=i.json.nodes[e],r=(n.extensions&&n.extensions[this.name]||{}).light;return void 0===r?null:this._loadLight(r).then((function(e){return i._getNodeRef(t.cache,r,e)}))}},Z6=class{constructor(){this.name=jr.KHR_MATERIALS_UNLIT}getMaterialType(){return ln}extendParams(e,t,i){let n=[];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&&n.push(i.assignTexture(e,"map",r.baseColorTexture,en))}return Promise.all(n)}},K6=class{constructor(e){this.parser=e,this.name=jr.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){let i=this.parser.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();let n=i.extensions[this.name].emissiveStrength;return void 0!==n&&(t.emissiveIntensity=n),Promise.resolve()}},J6=class{constructor(e){this.parser=e,this.name=jr.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){let t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?jo:null}extendMaterialParams(e,t){let i=this.parser,n=i.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();let r=[],a=n.extensions[this.name];if(void 0!==a.clearcoatFactor&&(t.clearcoat=a.clearcoatFactor),void 0!==a.clearcoatTexture&&r.push(i.assignTexture(t,"clearcoatMap",a.clearcoatTexture)),void 0!==a.clearcoatRoughnessFactor&&(t.clearcoatRoughness=a.clearcoatRoughnessFactor),void 0!==a.clearcoatRoughnessTexture&&r.push(i.assignTexture(t,"clearcoatRoughnessMap",a.clearcoatRoughnessTexture)),void 0!==a.clearcoatNormalTexture&&(r.push(i.assignTexture(t,"clearcoatNormalMap",a.clearcoatNormalTexture)),void 0!==a.clearcoatNormalTexture.scale)){let e=a.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new xe(e,e)}return Promise.all(r)}},Q6=class{constructor(e){this.parser=e,this.name=jr.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){let t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?jo:null}extendMaterialParams(e,t){let i=this.parser,n=i.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();let r=[],a=n.extensions[this.name];return void 0!==a.iridescenceFactor&&(t.iridescence=a.iridescenceFactor),void 0!==a.iridescenceTexture&&r.push(i.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(i.assignTexture(t,"iridescenceThicknessMap",a.iridescenceThicknessTexture)),Promise.all(r)}},e4=class{constructor(e){this.parser=e,this.name=jr.KHR_MATERIALS_SHEEN}getMaterialType(e){let t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?jo:null}extendMaterialParams(e,t){let i=this.parser,n=i.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();let r=[];t.sheenColor=new ct(0,0,0),t.sheenRoughness=0,t.sheen=1;let a=n.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(i.assignTexture(t,"sheenColorMap",a.sheenColorTexture,en)),void 0!==a.sheenRoughnessTexture&&r.push(i.assignTexture(t,"sheenRoughnessMap",a.sheenRoughnessTexture)),Promise.all(r)}},t4=class{constructor(e){this.parser=e,this.name=jr.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){let t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?jo:null}extendMaterialParams(e,t){let i=this.parser,n=i.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();let r=[],a=n.extensions[this.name];return void 0!==a.transmissionFactor&&(t.transmission=a.transmissionFactor),void 0!==a.transmissionTexture&&r.push(i.assignTexture(t,"transmissionMap",a.transmissionTexture)),Promise.all(r)}},n4=class{constructor(e){this.parser=e,this.name=jr.KHR_MATERIALS_VOLUME}getMaterialType(e){let t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?jo:null}extendMaterialParams(e,t){let i=this.parser,n=i.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();let r=[],a=n.extensions[this.name];t.thickness=void 0!==a.thicknessFactor?a.thicknessFactor:0,void 0!==a.thicknessTexture&&r.push(i.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)}},r4=class{constructor(e){this.parser=e,this.name=jr.KHR_MATERIALS_IOR}getMaterialType(e){let t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?jo:null}extendMaterialParams(e,t){let i=this.parser.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();let n=i.extensions[this.name];return t.ior=void 0!==n.ior?n.ior:1.5,Promise.resolve()}},i4=class{constructor(e){this.parser=e,this.name=jr.KHR_MATERIALS_SPECULAR}getMaterialType(e){let t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?jo:null}extendMaterialParams(e,t){let i=this.parser,n=i.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();let r=[],a=n.extensions[this.name];t.specularIntensity=void 0!==a.specularFactor?a.specularFactor:1,void 0!==a.specularTexture&&r.push(i.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(i.assignTexture(t,"specularColorMap",a.specularColorTexture,en)),Promise.all(r)}},s4=class{constructor(e){this.parser=e,this.name=jr.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){let t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?jo:null}extendMaterialParams(e,t){let i=this.parser,n=i.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();let r=[],a=n.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(i.assignTexture(t,"anisotropyMap",a.anisotropyTexture)),Promise.all(r)}},a4=class{constructor(e){this.parser=e,this.name=jr.KHR_TEXTURE_BASISU}loadTexture(e){let t=this.parser,i=t.json,n=i.textures[e];if(!n.extensions||!n.extensions[this.name])return null;let r=n.extensions[this.name],a=t.options.ktx2Loader;if(!a){if(i.extensionsRequired&&i.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)}},o4=class{constructor(e){this.parser=e,this.name=jr.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){let t=this.name,i=this.parser,n=i.json,r=n.textures[e];if(!r.extensions||!r.extensions[t])return null;let a=r.extensions[t],s=n.images[a.source],o=i.textureLoader;if(s.uri){let e=i.options.manager.getHandler(s.uri);null!==e&&(o=e)}return this.detectSupport().then((function(r){if(r)return i.loadTextureImage(e,a.source,o);if(n.extensionsRequired&&n.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return i.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}},l4=class{constructor(e){this.parser=e,this.name=jr.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){let t=this.name,i=this.parser,n=i.json,r=n.textures[e];if(!r.extensions||!r.extensions[t])return null;let a=r.extensions[t],s=n.images[a.source],o=i.textureLoader;if(s.uri){let e=i.options.manager.getHandler(s.uri);null!==e&&(o=e)}return this.detectSupport().then((function(r){if(r)return i.loadTextureImage(e,a.source,o);if(n.extensionsRequired&&n.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return i.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}},c4=class{constructor(e){this.name=jr.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){let t=this.parser.json,i=t.bufferViews[e];if(i.extensions&&i.extensions[this.name]){let e=i.extensions[this.name],n=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 n.then((function(t){let i=e.byteOffset||0,n=e.byteLength||0,a=e.count,s=e.byteStride,o=new Uint8Array(t,i,n);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}},u4=class{constructor(e){this.name=jr.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){let t=this.parser.json,i=t.nodes[e];if(!i.extensions||!i.extensions[this.name]||void 0===i.mesh)return null;let n=t.meshes[i.mesh];for(let o of n.primitives)if(o.mode!==Wl.TRIANGLES&&o.mode!==Wl.TRIANGLE_STRIP&&o.mode!==Wl.TRIANGLE_FAN&&void 0!==o.mode)return null;let r=i.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(),i=t.isGroup?t.children:[t],n=e[0].count,r=[];for(let a of i){let e=new et,t=new D,i=new dr,o=new D(1,1,1),l=new Oi(a.geometry,a.material,n);for(let r=0;r<n;r++)s.TRANSLATION&&t.fromBufferAttribute(s.TRANSLATION,r),s.ROTATION&&i.fromBufferAttribute(s.ROTATION,r),s.SCALE&&o.fromBufferAttribute(s.SCALE,r),l.setMatrixAt(r,e.compose(t,i,o));for(let n in s)"TRANSLATION"!==n&&"ROTATION"!==n&&"SCALE"!==n&&a.geometry.setAttribute(n,s[n]);on.prototype.copy.call(l,a),this.parser.assignFinalMaterial(l),r.push(l)}return t.isGroup?(t.clear(),t.add(...r),t):r[0]})))}},X0e="glTF",g_=12,G0e={JSON:1313821514,BIN:5130562},h4=class{constructor(e){this.name=jr.KHR_BINARY_GLTF,this.content=null,this.body=null;let t=new DataView(e,0,g_),i=new TextDecoder;if(this.header={magic:i.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==X0e)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");let n=this.header.length-g_,r=new DataView(e,g_),a=0;for(;a<n;){let t=r.getUint32(a,!0);a+=4;let n=r.getUint32(a,!0);if(a+=4,n===G0e.JSON){let n=new Uint8Array(e,g_+a,t);this.content=i.decode(n)}else if(n===G0e.BIN){let i=g_+a;this.body=e.slice(i,i+t)}a+=t}if(null===this.content)throw new Error("THREE.GLTFLoader: JSON content not found.")}},d4=class{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=jr.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){let i=this.json,n=this.dracoLoader,r=e.extensions[this.name].bufferView,a=e.extensions[this.name].attributes,s={},o={},l={};for(let h in a){let e=g4[h]||h.toLowerCase();s[e]=a[h]}for(let h in e.attributes){let t=g4[h]||h.toLowerCase();if(void 0!==a[h]){let n=i.accessors[e.attributes[h]],r=Ly[n.componentType];l[t]=r.name,o[t]=!0===n.normalized}}return t.getDependency("bufferView",r).then((function(e){return new Promise((function(t){n.decodeDracoFile(e,(function(e){for(let t in e.attributes){let i=e.attributes[t],n=o[t];void 0!==n&&(i.normalized=n)}t(e)}),s,l)}))}))}},f4=class{constructor(){this.name=jr.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}},p4=class{constructor(){this.name=jr.KHR_MESH_QUANTIZATION}},dP=class extends Jh{constructor(e,t,i,n){super(e,t,i,n)}copySampleValue_(e){let t=this.resultBuffer,i=this.sampleValues,n=this.valueSize,r=e*n*3+n;for(let a=0;a!==n;a++)t[a]=i[r+a];return t}interpolate_(e,t,i,n){let r=this.resultBuffer,a=this.sampleValues,s=this.valueSize,o=2*s,l=3*s,h=n-t,c=(i-t)/h,u=c*c,d=u*c,p=e*l,f=p-l,m=-2*d+3*u,g=d-u,v=1-m,y=g-u+c;for(let x=0;x!==s;x++){let e=a[f+x+s],t=a[f+x+o]*h,i=a[p+x+s],n=a[p+x]*h;r[x]=v*e+y*t+m*i+g*n}return r}},wgt=new dr,m4=class extends dP{interpolate_(e,t,i,n){let r=super.interpolate_(e,t,i,n);return wgt.fromArray(r).normalize().toArray(r),r}},Wl={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},Ly={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},q0e={9728:Jr,9729:Pr,9984:hf,9985:Im,9986:zh,9987:Fa},W0e={33071:Li,33648:qh,10497:Di},j6={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},g4={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"},Kf={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},Sgt={CUBICSPLINE:void 0,LINEAR:_u,STEP:jh},X6={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function Mgt(e){return void 0===e.DefaultMaterial&&(e.DefaultMaterial=new Cu({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:pi})),e.DefaultMaterial}function ig(e,t,i){for(let n in i.extensions)void 0===e[n]&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[n]=i.extensions[n])}function Jf(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 Rgt(e,t,i){let n=!1,r=!1,a=!1;for(let h=0,c=t.length;h<c;h++){let e=t[h];if(void 0!==e.POSITION&&(n=!0),void 0!==e.NORMAL&&(r=!0),void 0!==e.COLOR_0&&(a=!0),n&&r&&a)break}if(!n&&!r&&!a)return Promise.resolve(e);let s=[],o=[],l=[];for(let h=0,c=t.length;h<c;h++){let c=t[h];if(n){let t=void 0!==c.POSITION?i.getDependency("accessor",c.POSITION):e.attributes.position;s.push(t)}if(r){let t=void 0!==c.NORMAL?i.getDependency("accessor",c.NORMAL):e.attributes.normal;o.push(t)}if(a){let t=void 0!==c.COLOR_0?i.getDependency("accessor",c.COLOR_0):e.attributes.color;l.push(t)}}return Promise.all([Promise.all(s),Promise.all(o),Promise.all(l)]).then((function(t){let i=t[0],s=t[1],o=t[2];return n&&(e.morphAttributes.position=i),r&&(e.morphAttributes.normal=s),a&&(e.morphAttributes.color=o),e.morphTargetsRelative=!0,e}))}function Agt(e,t){if(e.updateMorphTargets(),void 0!==t.weights)for(let i=0,n=t.weights.length;i<n;i++)e.morphTargetInfluences[i]=t.weights[i];if(t.extras&&Array.isArray(t.extras.targetNames)){let i=t.extras.targetNames;if(e.morphTargetInfluences.length===i.length){e.morphTargetDictionary={};for(let t=0,n=i.length;t<n;t++)e.morphTargetDictionary[i[t]]=t}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function Cgt(e){let t,i=e.extensions&&e.extensions[jr.KHR_DRACO_MESH_COMPRESSION];if(t=i?"draco:"+i.bufferView+":"+i.indices+":"+Y6(i.attributes):e.indices+":"+Y6(e.attributes)+":"+e.mode,void 0!==e.targets)for(let n=0,r=e.targets.length;n<r;n++)t+=":"+Y6(e.targets[n]);return t}function Y6(e){let t="",i=Object.keys(e).sort();for(let n=0,r=i.length;n<r;n++)t+=i[n]+":"+e[i[n]]+";";return t}function v4(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 Pgt(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 Igt=new et,y4=class{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new Tgt,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 i=!1,n=!1,r=-1;"undefined"!=typeof navigator&&(i=!0===/^((?!chrome|android).)*safari/i.test(navigator.userAgent),n=navigator.userAgent.indexOf("Firefox")>-1,r=n?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),"undefined"==typeof createImageBitmap||i||n&&r<98?this.textureLoader=new ws(this.options.manager):this.textureLoader=new kb(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new Kr(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 i=this,n=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([i.getDependencies("scene"),i.getDependencies("animation"),i.getDependencies("camera")])})).then((function(t){let a={scene:t[0][n.scene||0],scenes:t[0],animations:t[1],cameras:t[2],asset:n.asset,parser:i,userData:{}};ig(r,a,n),Jf(a,n),Promise.all(i._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||[],i=this.json.meshes||[];for(let n=0,r=t.length;n<r;n++){let i=t[n].joints;for(let t=0,n=i.length;t<n;t++)e[i[t]].isBone=!0}for(let n=0,r=e.length;n<r;n++){let t=e[n];void 0!==t.mesh&&(this._addNodeRef(this.meshCache,t.mesh),void 0!==t.skin&&(i[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,i){if(e.refs[t]<=1)return i;let n=i.clone(),r=(e,t)=>{let i=this.associations.get(e);null!=i&&this.associations.set(t,i);for(let[n,a]of e.children.entries())r(a,t.children[n])};return r(i,n),n.name+="_instance_"+e.uses[t]++,n}_invokeOne(e){let t=Object.values(this.plugins);t.push(this);for(let i=0;i<t.length;i++){let n=e(t[i]);if(n)return n}return null}_invokeAll(e){let t=Object.values(this.plugins);t.unshift(this);let i=[];for(let n=0;n<t.length;n++){let r=e(t[n]);r&&i.push(r)}return i}getDependency(e,t){let i=e+":"+t,n=this.cache.get(i);if(!n){switch(e){case"scene":n=this.loadScene(t);break;case"node":n=this._invokeOne((function(e){return e.loadNode&&e.loadNode(t)}));break;case"mesh":n=this._invokeOne((function(e){return e.loadMesh&&e.loadMesh(t)}));break;case"accessor":n=this.loadAccessor(t);break;case"bufferView":n=this._invokeOne((function(e){return e.loadBufferView&&e.loadBufferView(t)}));break;case"buffer":n=this.loadBuffer(t);break;case"material":n=this._invokeOne((function(e){return e.loadMaterial&&e.loadMaterial(t)}));break;case"texture":n=this._invokeOne((function(e){return e.loadTexture&&e.loadTexture(t)}));break;case"skin":n=this.loadSkin(t);break;case"animation":n=this._invokeOne((function(e){return e.loadAnimation&&e.loadAnimation(t)}));break;case"camera":n=this.loadCamera(t);break;default:if(n=this._invokeOne((function(i){return i!=this&&i.getDependency&&i.getDependency(e,t)})),!n)throw new Error("Unknown type: "+e)}this.cache.add(i,n)}return n}getDependencies(e){let t=this.cache.get(e);if(!t){let i=this,n=this.json[e+("mesh"===e?"es":"s")]||[];t=Promise.all(n.map((function(t,n){return i.getDependency(e,n)}))),this.cache.add(e,t)}return t}loadBuffer(e){let t=this.json.buffers[e],i=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[jr.KHR_BINARY_GLTF].body);let n=this.options;return new Promise((function(e,r){i.load(ta.resolveURL(t.uri,n.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 i=t.byteLength||0,n=t.byteOffset||0;return e.slice(n,n+i)}))}loadAccessor(e){let t=this,i=this.json,n=this.json.accessors[e];if(void 0===n.bufferView&&void 0===n.sparse){let e=j6[n.type],t=Ly[n.componentType],i=!0===n.normalized,r=new t(n.count*e);return Promise.resolve(new mn(r,e,i))}let r=[];return void 0!==n.bufferView?r.push(this.getDependency("bufferView",n.bufferView)):r.push(null),void 0!==n.sparse&&(r.push(this.getDependency("bufferView",n.sparse.indices.bufferView)),r.push(this.getDependency("bufferView",n.sparse.values.bufferView))),Promise.all(r).then((function(e){let r,a,s=e[0],o=j6[n.type],l=Ly[n.componentType],h=l.BYTES_PER_ELEMENT,c=h*o,u=n.byteOffset||0,d=void 0!==n.bufferView?i.bufferViews[n.bufferView].byteStride:void 0,p=!0===n.normalized;if(d&&d!==c){let e=Math.floor(u/d),i="InterleavedBuffer:"+n.bufferView+":"+n.componentType+":"+e+":"+n.count,c=t.cache.get(i);c||(r=new l(s,e*d,n.count*d/h),c=new $h(r,d/h),t.cache.add(i,c)),a=new co(c,o,u%d/h,p)}else r=null===s?new l(n.count*o):new l(s,u,n.count*o),a=new mn(r,o,p);if(void 0!==n.sparse){let t=j6.SCALAR,i=Ly[n.sparse.indices.componentType],r=n.sparse.indices.byteOffset||0,h=n.sparse.values.byteOffset||0,c=new i(e[1],r,n.sparse.count*t),u=new l(e[2],h,n.sparse.count*o);null!==s&&(a=new mn(a.array.slice(),a.itemSize,a.normalized));for(let e=0,n=c.length;e<n;e++){let t=c[e];if(a.setX(t,u[e*o]),o>=2&&a.setY(t,u[e*o+1]),o>=3&&a.setZ(t,u[e*o+2]),o>=4&&a.setW(t,u[e*o+3]),o>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return a}))}loadTexture(e){let t=this.json,i=this.options,n=t.textures[e].source,r=t.images[n],a=this.textureLoader;if(r.uri){let e=i.manager.getHandler(r.uri);null!==e&&(a=e)}return this.loadTextureImage(e,n,a)}loadTextureImage(e,t,i){let n=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,i).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 i=(r.samplers||{})[a.sampler]||{};return t.magFilter=q0e[i.magFilter]||Pr,t.minFilter=q0e[i.minFilter]||Fa,t.wrapS=W0e[i.wrapS]||Di,t.wrapT=W0e[i.wrapT]||Di,n.associations.set(t,{textures:e}),t})).catch((function(){return null}));return this.textureCache[o]=l,l}loadImageSource(e,t){let i=this.json,n=this.options;if(void 0!==this.sourceCache[e])return this.sourceCache[e].then((e=>e.clone()));let r=i.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(i,r){let a=i;!0===t.isImageBitmapLoader&&(a=function(e){let t=new Gr(e);t.needsUpdate=!0,i(t)}),t.load(ta.resolveURL(e,n.path),a,void 0,r)}))})).then((function(e){return!0===o&&a.revokeObjectURL(s),e.userData.mimeType=r.mimeType||Pgt(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,i,n){let r=this;return this.getDependency("texture",i.index).then((function(a){if(!a)return null;if(void 0!==i.texCoord&&i.texCoord>0&&((a=a.clone()).channel=i.texCoord),r.extensions[jr.KHR_TEXTURE_TRANSFORM]){let e=void 0!==i.extensions?i.extensions[jr.KHR_TEXTURE_TRANSFORM]:void 0;if(e){let t=r.associations.get(a);a=r.extensions[jr.KHR_TEXTURE_TRANSFORM].extendTexture(a,e),r.associations.set(a,t)}}return void 0!==n&&(a.colorSpace=n),e[t]=a,a}))}assignFinalMaterial(e){let t=e.geometry,i=e.material,n=void 0===t.attributes.tangent,r=void 0!==t.attributes.color,a=void 0===t.attributes.normal;if(e.isPoints){let e="PointsMaterial:"+i.uuid,t=this.cache.get(e);t||(t=new bi,yr.prototype.copy.call(t,i),t.color.copy(i.color),t.map=i.map,t.sizeAttenuation=!1,this.cache.add(e,t)),i=t}else if(e.isLine){let e="LineBasicMaterial:"+i.uuid,t=this.cache.get(e);t||(t=new Gn,yr.prototype.copy.call(t,i),t.color.copy(i.color),t.map=i.map,this.cache.add(e,t)),i=t}if(n||r||a){let e="ClonedMaterial:"+i.uuid+":";n&&(e+="derivative-tangents:"),r&&(e+="vertex-colors:"),a&&(e+="flat-shading:");let t=this.cache.get(e);t||(t=i.clone(),r&&(t.vertexColors=!0),a&&(t.flatShading=!0),n&&(t.normalScale&&(t.normalScale.y*=-1),t.clearcoatNormalScale&&(t.clearcoatNormalScale.y*=-1)),this.cache.add(e,t),this.associations.set(t,this.associations.get(i))),i=t}e.material=i}getMaterialType(){return Cu}loadMaterial(e){let t,i=this,n=this.json,r=this.extensions,a=n.materials[e],s={},o=[];if((a.extensions||{})[jr.KHR_MATERIALS_UNLIT]){let e=r[jr.KHR_MATERIALS_UNLIT];t=e.getMaterialType(),o.push(e.extendParams(s,a,i))}else{let n=a.pbrMetallicRoughness||{};if(s.color=new ct(1,1,1),s.opacity=1,Array.isArray(n.baseColorFactor)){let e=n.baseColorFactor;s.color.fromArray(e),s.opacity=e[3]}void 0!==n.baseColorTexture&&o.push(i.assignTexture(s,"map",n.baseColorTexture,en)),s.metalness=void 0!==n.metallicFactor?n.metallicFactor:1,s.roughness=void 0!==n.roughnessFactor?n.roughnessFactor:1,void 0!==n.metallicRoughnessTexture&&(o.push(i.assignTexture(s,"metalnessMap",n.metallicRoughnessTexture)),o.push(i.assignTexture(s,"roughnessMap",n.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=Sr);let l=a.alphaMode||X6.OPAQUE;if(l===X6.BLEND?(s.transparent=!0,s.depthWrite=!1):(s.transparent=!1,l===X6.MASK&&(s.alphaTest=void 0!==a.alphaCutoff?a.alphaCutoff:.5)),void 0!==a.normalTexture&&t!==ln&&(o.push(i.assignTexture(s,"normalMap",a.normalTexture)),s.normalScale=new xe(1,1),void 0!==a.normalTexture.scale)){let e=a.normalTexture.scale;s.normalScale.set(e,e)}return void 0!==a.occlusionTexture&&t!==ln&&(o.push(i.assignTexture(s,"aoMap",a.occlusionTexture)),void 0!==a.occlusionTexture.strength&&(s.aoMapIntensity=a.occlusionTexture.strength)),void 0!==a.emissiveFactor&&t!==ln&&(s.emissive=(new ct).fromArray(a.emissiveFactor)),void 0!==a.emissiveTexture&&t!==ln&&o.push(i.assignTexture(s,"emissiveMap",a.emissiveTexture,en)),Promise.all(o).then((function(){let n=new t(s);return a.name&&(n.name=a.name),Jf(n,a),i.associations.set(n,{materials:e}),a.extensions&&ig(r,n,a),n}))}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,i=this.extensions,n=this.primitiveCache;function r(e){return i[jr.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then((function(i){return j0e(i,e,t)}))}let a=[];for(let s=0,o=e.length;s<o;s++){let i=e[s],o=Cgt(i),l=n[o];if(l)a.push(l.promise);else{let e;e=i.extensions&&i.extensions[jr.KHR_DRACO_MESH_COMPRESSION]?r(i):j0e(new Dt,i,t),n[o]={primitive:i,promise:e},a.push(e)}}return Promise.all(a)}loadMesh(e){let t=this,i=this.json,n=this.extensions,r=i.meshes[e],a=r.primitives,s=[];for(let o=0,l=a.length;o<l;o++){let e=void 0===a[o].material?Mgt(this.cache):this.getDependency("material",a[o].material);s.push(e)}return s.push(t.loadGeometries(a)),Promise.all(s).then((function(i){let s=i.slice(0,i.length-1),o=i[i.length-1],l=[];for(let c=0,u=o.length;c<u;c++){let i,h=o[c],u=a[c],d=s[c];if(u.mode===Wl.TRIANGLES||u.mode===Wl.TRIANGLE_STRIP||u.mode===Wl.TRIANGLE_FAN||void 0===u.mode)i=!0===r.isSkinnedMesh?new wu(h,d):new xt(h,d),!0===i.isSkinnedMesh&&i.normalizeSkinWeights(),u.mode===Wl.TRIANGLE_STRIP?i.geometry=zH(i.geometry,Vb):u.mode===Wl.TRIANGLE_FAN&&(i.geometry=zH(i.geometry,Av));else if(u.mode===Wl.LINES)i=new qr(h,d);else if(u.mode===Wl.LINE_STRIP)i=new fr(h,d);else if(u.mode===Wl.LINE_LOOP)i=new uv(h,d);else{if(u.mode!==Wl.POINTS)throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+u.mode);i=new ii(h,d)}Object.keys(i.geometry.morphAttributes).length>0&&Agt(i,r),i.name=t.createUniqueName(r.name||"mesh_"+e),Jf(i,r),u.extensions&&ig(n,i,u),t.assignFinalMaterial(i),l.push(i)}for(let n=0,r=l.length;n<r;n++)t.associations.set(l[n],{meshes:e,primitives:n});if(1===l.length)return r.extensions&&ig(n,l[0],r),l[0];let h=new er;r.extensions&&ig(n,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,i=this.json.cameras[e],n=i[i.type];if(n)return"perspective"===i.type?t=new hr(Rn.radToDeg(n.yfov),n.aspectRatio||1,n.znear||1,n.zfar||2e6):"orthographic"===i.type&&(t=new Nr(-n.xmag,n.xmag,n.ymag,-n.ymag,n.znear,n.zfar)),i.name&&(t.name=this.createUniqueName(i.name)),Jf(t,i),Promise.resolve(t);console.warn("THREE.GLTFLoader: Missing camera parameters.")}loadSkin(e){let t=this.json.skins[e],i=[];for(let n=0,r=t.joints.length;n<r;n++)i.push(this._loadNodeShallow(t.joints[n]));return void 0!==t.inverseBindMatrices?i.push(this.getDependency("accessor",t.inverseBindMatrices)):i.push(null),Promise.all(i).then((function(e){let i=e.pop(),n=e,r=[],a=[];for(let s=0,o=n.length;s<o;s++){let e=n[s];if(e){r.push(e);let t=new et;null!==i&&t.fromArray(i.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,i=this,n=t.animations[e],r=n.name?n.name:"animation_"+e,a=[],s=[],o=[],l=[],h=[];for(let c=0,u=n.channels.length;c<u;c++){let e=n.channels[c],t=n.samplers[e.sampler],i=e.target,r=i.node,u=void 0!==n.parameters?n.parameters[t.input]:t.input,d=void 0!==n.parameters?n.parameters[t.output]:t.output;void 0!==i.node&&(a.push(this.getDependency("node",r)),s.push(this.getDependency("accessor",u)),o.push(this.getDependency("accessor",d)),l.push(t),h.push(i))}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],n=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=n[r],c=a[r],u=s[r],d=o[r];if(void 0===e)continue;e.updateMatrix&&e.updateMatrix();let p=i._createAnimationTracks(e,h,c,u,d);if(p)for(let t=0;t<p.length;t++)l.push(p[t])}return new uo(r,void 0,l)}))}createNodeMesh(e){let t=this.json,i=this,n=t.nodes[e];return void 0===n.mesh?null:i.getDependency("mesh",n.mesh).then((function(e){let t=i._getNodeRef(i.meshCache,n.mesh,e);return void 0!==n.weights&&t.traverse((function(e){if(e.isMesh)for(let t=0,i=n.weights.length;t<i;t++)e.morphTargetInfluences[t]=n.weights[t]})),t}))}loadNode(e){let t=this,i=this.json.nodes[e],n=t._loadNodeShallow(e),r=[],a=i.children||[];for(let o=0,l=a.length;o<l;o++)r.push(t.getDependency("node",a[o]));let s=void 0===i.skin?Promise.resolve(null):t.getDependency("skin",i.skin);return Promise.all([n,Promise.all(r),s]).then((function(e){let t=e[0],i=e[1],n=e[2];null!==n&&t.traverse((function(e){e.isSkinnedMesh&&e.bind(n,Igt)}));for(let r=0,a=i.length;r<a;r++)t.add(i[r]);return t}))}_loadNodeShallow(e){let t=this.json,i=this.extensions,n=this;if(void 0!==this.nodeCache[e])return this.nodeCache[e];let r=t.nodes[e],a=r.name?n.createUniqueName(r.name):"",s=[],o=n._invokeOne((function(t){return t.createNodeMesh&&t.createNodeMesh(e)}));return o&&s.push(o),void 0!==r.camera&&s.push(n.getDependency("camera",r.camera).then((function(e){return n._getNodeRef(n.cameraCache,r.camera,e)}))),n._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 er:1===t.length?t[0]:new on,s!==t[0])for(let e=0,i=t.length;e<i;e++)s.add(t[e]);if(r.name&&(s.userData.name=r.name,s.name=a),Jf(s,r),r.extensions&&ig(i,s,r),void 0!==r.matrix){let e=new et;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 n.associations.has(s)||n.associations.set(s,{}),n.associations.get(s).nodes=e,s})),this.nodeCache[e]}loadScene(e){let t=this.extensions,i=this.json.scenes[e],n=this,r=new er;i.name&&(r.name=n.createUniqueName(i.name)),Jf(r,i),i.extensions&&ig(t,r,i);let a=i.nodes||[],s=[];for(let o=0,l=a.length;o<l;o++)s.push(n.getDependency("node",a[o]));return Promise.all(s).then((function(e){for(let t=0,i=e.length;t<i;t++)r.add(e[t]);return n.associations=(e=>{let t=new Map;for(let[i,r]of n.associations)(i instanceof yr||i instanceof Gr)&&t.set(i,r);return e.traverse((e=>{let i=n.associations.get(e);null!=i&&t.set(e,i)})),t})(r),r}))}_createAnimationTracks(e,t,i,n,r){let a,s=[],o=e.name?e.name:e.uuid,l=[];switch(Kf[r.path]===Kf.weights?e.traverse((function(e){e.morphTargetInfluences&&l.push(e.name?e.name:e.uuid)})):l.push(o),Kf[r.path]){case Kf.weights:a=Al;break;case Kf.rotation:a=Ha;break;case Kf.position:case Kf.scale:a=Va;break;default:a=1===i.itemSize?Al:Va}let h=void 0!==n.interpolation?Sgt[n.interpolation]:_u,c=this._getArrayFromAccessor(i);for(let u=0,d=l.length;u<d;u++){let e=new a(l[u]+"."+Kf[r.path],t.array,c,h);"CUBICSPLINE"===n.interpolation&&this._createCubicSplineTrackInterpolant(e),s.push(e)}return s}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){let e=v4(t.constructor),i=new Float32Array(t.length);for(let n=0,r=t.length;n<r;n++)i[n]=t[n]*e;t=i}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(e){return new(this instanceof Ha?m4:dP)(this.times,this.values,this.getValueSize()/3,e)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}};function Lgt(e,t,i){let n=t.attributes,r=new Nt;if(void 0===n.POSITION)return;{let e=i.json.accessors[n.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 D(t[0],t[1],t[2]),new D(a[0],a[1],a[2])),e.normalized){let t=v4(Ly[e.componentType]);r.min.multiplyScalar(t),r.max.multiplyScalar(t)}}let a=t.targets;if(void 0!==a){let e=new D,t=new D;for(let n=0,r=a.length;n<r;n++){let r=a[n];if(void 0!==r.POSITION){let n=i.json.accessors[r.POSITION],a=n.min,s=n.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]))),n.normalized){let e=v4(Ly[n.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 vr;r.getCenter(s.center),s.radius=r.min.distanceTo(r.max)/2,e.boundingSphere=s}function j0e(e,t,i){let n=t.attributes,r=[];function a(t,n){return i.getDependency("accessor",t).then((function(t){e.setAttribute(n,t)}))}for(let s in n){let t=g4[s]||s.toLowerCase();t in e.attributes||r.push(a(n[s],t))}if(void 0!==t.indices&&!e.index){let n=i.getDependency("accessor",t.indices).then((function(t){e.setIndex(t)}));r.push(n)}return Jf(e,t),Lgt(e,t,i),Promise.all(r).then((function(){return void 0!==t.targets?Rgt(e,t.targets,i):e}))}var fP=class extends Er{constructor(e){super(e)}load(e,t,i,n){let r=this,a=""===this.path?ta.extractUrlBase(e):this.path,s=new Kr(this.manager);s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,(function(i){try{t(r.parse(i,a))}catch(t){n?n(t):console.error(t),r.manager.itemError(e)}}),i,n)}setMaterialOptions(e){return this.materialOptions=e,this}parse(e,t){let i=e.split("\n"),n={},r=/\s+/,a={};for(let o=0;o<i.length;o++){let e=i[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)n={name:l},a[l]=n;else if("ka"===s||"kd"===s||"ks"===s||"ke"===s){let e=l.split(r,3);n[s]=[parseFloat(e[0]),parseFloat(e[1]),parseFloat(e[2])]}else n[s]=l}let s=new x4(this.resourcePath||t,this.materialOptions);return s.setCrossOrigin(this.crossOrigin),s.setManager(this.manager),s.setMaterials(a),s}},x4=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:pi,this.wrap=void 0!==this.options.wrap?this.options.wrap:Di}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 i in e){let n=e[i],r={};t[i]=r;for(let e in n){let t=!0,i=n[e],a=e.toLowerCase();switch(a){case"kd":case"ka":case"ks":this.options&&this.options.normalizeRGB&&(i=[i[0]/255,i[1]/255,i[2]/255]),this.options&&this.options.ignoreZeroRGBs&&0===i[0]&&0===i[1]&&0===i[2]&&(t=!1)}t&&(r[a]=i)}}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,i=this.materialsInfo[e],n={name:e,side:this.side};function r(e,i){if(n[e])return;let r=t.getTextureParams(i,n),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=en),n[e]=a}for(let a in i){let e,t=i[a];if(""!==t)switch(a.toLowerCase()){case"kd":n.color=(new ct).fromArray(t).convertSRGBToLinear();break;case"ks":n.specular=(new ct).fromArray(t).convertSRGBToLinear();break;case"ke":n.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),n.transparent=!0;break;case"ns":n.shininess=parseFloat(t);break;case"d":e=parseFloat(t),e<1&&(n.opacity=e,n.transparent=!0);break;case"tr":e=parseFloat(t),this.options&&this.options.invertTrProperty&&(e=1-e),e>0&&(n.opacity=1-e,n.transparent=!0)}}return this.materials[e]=new ea(n),this.materials[e]}getTextureParams(e,t){let i,n={scale:new xe(1,1),offset:new xe(0,0)},r=e.split(/\s+/);return i=r.indexOf("-bm"),i>=0&&(t.bumpScale=parseFloat(r[i+1]),r.splice(i,2)),i=r.indexOf("-s"),i>=0&&(n.scale.set(parseFloat(r[i+1]),parseFloat(r[i+2])),r.splice(i,4)),i=r.indexOf("-o"),i>=0&&(n.offset.set(parseFloat(r[i+1]),parseFloat(r[i+2])),r.splice(i,4)),n.url=r.join(" ").trim(),n}loadTexture(e,t,i,n,r){let a=void 0!==this.manager?this.manager:fo,s=a.getHandler(e);null===s&&(s=new ws(a)),s.setCrossOrigin&&s.setCrossOrigin(this.crossOrigin);let o=s.load(e,i,n,r);return void 0!==t&&(o.mapping=t),o}},Dgt=/^[og]\s*(.+)?/,Ogt=/^mtllib /,kgt=/^usemtl /,Fgt=/^usemap /,Y0e=/\s+/,$0e=new D,b4=new D,Z0e=new D,K0e=new D,jl=new D,pP=new ct;function Ngt(){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 i=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 i=this._finalize(!1);i&&(i.inherited||i.groupCount<=0)&&this.materials.splice(i.index,1);let n={index:this.materials.length,name:e||"",mtllib:Array.isArray(t)&&t.length>0?t[t.length-1]:"",smooth:void 0!==i?i.smooth:this.smooth,groupStart:void 0!==i?i.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(n),n},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 i=this.materials.length-1;i>=0;i--)this.materials[i].groupCount<=0&&this.materials.splice(i,1);return e&&0===this.materials.length&&this.materials.push({name:"",smooth:this.smooth}),t}},i&&i.name&&"function"==typeof i.clone){let e=i.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 i=parseInt(e,10);return 3*(i>=0?i-1:i+t/3)},parseNormalIndex:function(e,t){let i=parseInt(e,10);return 3*(i>=0?i-1:i+t/3)},parseUVIndex:function(e,t){let i=parseInt(e,10);return 2*(i>=0?i-1:i+t/2)},addVertex:function(e,t,i){let n=this.vertices,r=this.object.geometry.vertices;r.push(n[e+0],n[e+1],n[e+2]),r.push(n[t+0],n[t+1],n[t+2]),r.push(n[i+0],n[i+1],n[i+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,i){let n=this.normals,r=this.object.geometry.normals;r.push(n[e+0],n[e+1],n[e+2]),r.push(n[t+0],n[t+1],n[t+2]),r.push(n[i+0],n[i+1],n[i+2])},addFaceNormal:function(e,t,i){let n=this.vertices,r=this.object.geometry.normals;$0e.fromArray(n,e),b4.fromArray(n,t),Z0e.fromArray(n,i),jl.subVectors(Z0e,b4),K0e.subVectors($0e,b4),jl.cross(K0e),jl.normalize(),r.push(jl.x,jl.y,jl.z),r.push(jl.x,jl.y,jl.z),r.push(jl.x,jl.y,jl.z)},addColor:function(e,t,i){let n=this.colors,r=this.object.geometry.colors;void 0!==n[e]&&r.push(n[e+0],n[e+1],n[e+2]),void 0!==n[t]&&r.push(n[t+0],n[t+1],n[t+2]),void 0!==n[i]&&r.push(n[i+0],n[i+1],n[i+2])},addUV:function(e,t,i){let n=this.uvs,r=this.object.geometry.uvs;r.push(n[e+0],n[e+1]),r.push(n[t+0],n[t+1]),r.push(n[i+0],n[i+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,i,n,r,a,s,o,l){let h=this.vertices.length,c=this.parseVertexIndex(e,h),u=this.parseVertexIndex(t,h),d=this.parseVertexIndex(i,h);if(this.addVertex(c,u,d),this.addColor(c,u,d),void 0!==s&&""!==s){let e=this.normals.length;c=this.parseNormalIndex(s,e),u=this.parseNormalIndex(o,e),d=this.parseNormalIndex(l,e),this.addNormal(c,u,d)}else this.addFaceNormal(c,u,d);if(void 0!==n&&""!==n){let e=this.uvs.length;c=this.parseUVIndex(n,e),u=this.parseUVIndex(r,e),d=this.parseUVIndex(a,e),this.addUV(c,u,d),this.object.geometry.hasUVIndices=!0}else this.addDefaultUV()},addPointGeometry:function(e){this.object.geometry.type="Points";let t=this.vertices.length;for(let i=0,n=e.length;i<n;i++){let n=this.parseVertexIndex(e[i],t);this.addVertexPoint(n),this.addColor(n)}},addLineGeometry:function(e,t){this.object.geometry.type="Line";let i=this.vertices.length,n=this.uvs.length;for(let r=0,a=e.length;r<a;r++)this.addVertexLine(this.parseVertexIndex(e[r],i));for(let r=0,a=t.length;r<a;r++)this.addUVLine(this.parseUVIndex(t[r],n))}};return e.startObject("",!1),e}var mP=class extends Er{constructor(e){super(e),this.materials=null}load(e,t,i,n){let r=this,a=new Kr(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,(function(i){try{t(r.parse(i))}catch(t){n?n(t):console.error(t),r.manager.itemError(e)}}),i,n)}setMaterials(e){return this.materials=e,this}parse(e){let t=new Ngt;-1!==e.indexOf("\r\n")&&(e=e.replace(/\r\n/g,"\n")),-1!==e.indexOf("\\\n")&&(e=e.replace(/\\\n/g,""));let i=e.split("\n"),n=[];for(let a=0,s=i.length;a<s;a++){let e=i[a].trimStart();if(0===e.length)continue;let r=e.charAt(0);if("#"!==r)if("v"===r){let i=e.split(Y0e);switch(i[0]){case"v":t.vertices.push(parseFloat(i[1]),parseFloat(i[2]),parseFloat(i[3])),i.length>=7?(pP.setRGB(parseFloat(i[4]),parseFloat(i[5]),parseFloat(i[6])).convertSRGBToLinear(),t.colors.push(pP.r,pP.g,pP.b)):t.colors.push(void 0,void 0,void 0);break;case"vn":t.normals.push(parseFloat(i[1]),parseFloat(i[2]),parseFloat(i[3]));break;case"vt":t.uvs.push(parseFloat(i[1]),parseFloat(i[2]))}}else if("f"===r){let i=e.slice(1).trim().split(Y0e),n=[];for(let e=0,t=i.length;e<t;e++){let t=i[e];if(t.length>0){let e=t.split("/");n.push(e)}}let r=n[0];for(let e=1,a=n.length-1;e<a;e++){let i=n[e],a=n[e+1];t.addFace(r[0],i[0],a[0],r[1],i[1],a[1],r[2],i[2],a[2])}}else if("l"===r){let i=e.substring(1).trim().split(" "),n=[],r=[];if(-1===e.indexOf("/"))n=i;else for(let e=0,t=i.length;e<t;e++){let t=i[e].split("/");""!==t[0]&&n.push(t[0]),""!==t[1]&&r.push(t[1])}t.addLineGeometry(n,r)}else if("p"===r){let i=e.slice(1).trim().split(" ");t.addPointGeometry(i)}else if(null!==(n=Dgt.exec(e))){let e=(" "+n[0].slice(1).trim()).slice(1);t.startObject(e)}else if(kgt.test(e))t.object.startMaterial(e.substring(7).trim(),t.materialLibraries);else if(Ogt.test(e))t.materialLibraries.push(e.substring(7).trim());else if(Fgt.test(e))console.warn('THREE.OBJLoader: Rendering identifier "usemap" not supported. Textures must be defined in MTL files.');else if("s"===r){if(n=e.split(" "),n.length>1){let e=n[1].trim().toLowerCase();t.object.smooth="0"!==e&&"off"!==e}else t.object.smooth=!0;let i=t.object.currentMaterial();i&&(i.smooth=t.object.smooth)}else{if("\0"===e)continue;console.warn('THREE.OBJLoader: Unexpected line: "'+e+'"')}}t.finalize();let r=new er;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],i=e.geometry,n=e.materials,s="Line"===i.type,o="Points"===i.type,l=!1;if(0===i.vertices.length)continue;let h=new Dt;h.setAttribute("position",new Bt(i.vertices,3)),i.normals.length>0&&h.setAttribute("normal",new Bt(i.normals,3)),i.colors.length>0&&(l=!0,h.setAttribute("color",new Bt(i.colors,3))),!0===i.hasUVIndices&&h.setAttribute("uv",new Bt(i.uvs,2));let c,u=[];for(let r=0,a=n.length;r<a;r++){let e=n[r],i=e.name+"_"+e.smooth+"_"+l,a=t.materials[i];if(null!==this.materials)if(a=this.materials.create(e.name),!s||!a||a instanceof Gn){if(o&&a&&!(a instanceof bi)){let e=new bi({size:10,sizeAttenuation:!1});yr.prototype.copy.call(e,a),e.color.copy(a.color),e.map=a.map,a=e}}else{let e=new Gn;yr.prototype.copy.call(e,a),e.color.copy(a.color),a=e}void 0===a&&(a=s?new Gn:o?new bi({size:1,sizeAttenuation:!1}):new ea,a.name=e.name,a.flatShading=!e.smooth,a.vertexColors=l,t.materials[i]=a),u.push(a)}if(u.length>1){for(let e=0,t=n.length;e<t;e++){let t=n[e];h.addGroup(t.groupStart,t.groupCount,e)}c=s?new qr(h,u):o?new ii(h,u):new xt(h,u)}else c=s?new qr(h,u[0]):o?new ii(h,u[0]):new xt(h,u[0]);c.name=e.name,r.add(c)}else if(t.vertices.length>0){let e=new bi({size:1,sizeAttenuation:!1}),i=new Dt;i.setAttribute("position",new Bt(t.vertices,3)),t.colors.length>0&&void 0!==t.colors[0]&&(i.setAttribute("color",new Bt(t.colors,3)),e.vertexColors=!0);let n=new ii(i,e);r.add(n)}return r}},Eo=new ct,gP=class extends Er{constructor(e){super(e),this.propertyNameMapping={},this.customPropertyMapping={}}load(e,t,i,n){let r=this,a=new Kr(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,(function(i){try{t(r.parse(i))}catch(t){n?n(t):console.error(t),r.manager.itemError(e)}}),i,n)}setPropertyNameMapping(e){this.propertyNameMapping=e}setCustomPropertyNameMapping(e){this.customPropertyMapping=e}parse(e){function t(e,t=0){let i="",n=/^ply([\s\S]*)end_header(\r\n|\r|\n)/.exec(e);null!==n&&(i=n[1]);let r,a={comments:[],elements:[],headerLength:t,objInfo:""},s=i.split(/\r\n|\r|\n/);function o(e,t){let i={type:e[0]};return"list"===i.type?(i.name=e[3],i.countType=e[1],i.itemType=e[2]):i.name=e[1],i.name in t&&(i.name=t[i.name]),i}for(let l=0;l<s.length;l++){let e=s[l];if(e=e.trim(),""===e)continue;let t=e.split(/\s+/),i=t.shift();switch(e=t.join(" "),i){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",i,t)}}return void 0!==r&&a.elements.push(r),a}function i(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 n(e,t){let n={};for(let r=0;r<e.length;r++){if(t.empty())return null;if("list"===e[r].type){let a=[],s=i(t.next(),e[r].countType);for(let n=0;n<s;n++){if(t.empty())return null;a.push(i(t.next(),e[r].itemType))}n[e[r].name]=a}else n[e[r].name]=i(t.next(),e[r].type)}return n}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 i(e){for(let i=0,n=e.length;i<n;i++){let n=e[i];if(t.includes(n))return n}return null}return{attrX:i(["x","px","posx"])||"x",attrY:i(["y","py","posy"])||"y",attrZ:i(["z","pz","posz"])||"z",attrNX:i(["nx","normalx"]),attrNY:i(["ny","normaly"]),attrNZ:i(["nz","normalz"]),attrS:i(["s","u","texture_u","tx"]),attrT:i(["t","v","texture_v","ty"]),attrR:i(["red","diffuse_red","r","diffuse_r"]),attrG:i(["green","diffuse_green","g","diffuse_g"]),attrB:i(["blue","diffuse_blue","b","diffuse_b"])}}function s(e,t){let i,s,h=r();i=null!==(s=/end_header\s+(\S[\s\S]*\S|\S)\s*$/.exec(e))?s[1].split(/\s+/):[];let c=new E4(i);e:for(let r=0;r<t.elements.length;r++){let e=t.elements[r],i=a(e.properties);for(let t=0;t<e.count;t++){let t=n(e.properties,c);if(!t)break e;l(h,e.name,t,i)}}return o(h)}function o(e){let t=new Dt;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 i of Object.keys(d.customPropertyMapping))e[i].length>0&&t.setAttribute(i,new Bt(e[i],d.customPropertyMapping[i].length));return t.computeBoundingSphere(),t}function l(e,t,i,n){if("vertex"===t){e.vertices.push(i[n.attrX],i[n.attrY],i[n.attrZ]),null!==n.attrNX&&null!==n.attrNY&&null!==n.attrNZ&&e.normals.push(i[n.attrNX],i[n.attrNY],i[n.attrNZ]),null!==n.attrS&&null!==n.attrT&&e.uvs.push(i[n.attrS],i[n.attrT]),null!==n.attrR&&null!==n.attrG&&null!==n.attrB&&(Eo.setRGB(i[n.attrR]/255,i[n.attrG]/255,i[n.attrB]/255).convertSRGBToLinear(),e.colors.push(Eo.r,Eo.g,Eo.b));for(let t of Object.keys(d.customPropertyMapping))for(let n of d.customPropertyMapping[t])e[t].push(i[n])}else if("face"===t){let t=i.vertex_indices||i.vertex_index,r=i.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!==n.attrR&&null!==n.attrG&&null!==n.attrB&&(Eo.setRGB(i[n.attrR]/255,i[n.attrG]/255,i[n.attrB]/255).convertSRGBToLinear(),e.faceVertexColors.push(Eo.r,Eo.g,Eo.b),e.faceVertexColors.push(Eo.r,Eo.g,Eo.b),e.faceVertexColors.push(Eo.r,Eo.g,Eo.b))}}function h(e,t){let i={},n=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+n);n+=a.countReader.size;for(let i=0;i<r;i++)t.push(s.read(e+n)),n+=s.size;i[a.name]=t}else i[a.name]=s.read(e+n),n+=s.size}return[i,n]}function c(e,t,i){function n(e,t,i){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,i),size:2};case"uint16":case"ushort":return{read:t=>e.getUint16(t,i),size:2};case"int32":case"int":return{read:t=>e.getInt32(t,i),size:4};case"uint32":case"uint":return{read:t=>e.getUint32(t,i),size:4};case"float32":case"float":return{read:t=>e.getFloat32(t,i),size:4};case"float64":case"double":return{read:t=>e.getFloat64(t,i),size:8}}}for(let r=0,a=e.length;r<a;r++){let a=e[r];"list"===a.type?(a.countReader=n(t,a.countType,i),a.valueReader=n(t,a.itemType,i)):a.valueReader=n(t,a.type,i)}}let u,d=this;if(e instanceof ArrayBuffer){let i=new Uint8Array(e),{headerText:n,headerLength:d}=function(e){let t=0,i=!0,n="",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?n+=a:("end_header"===n&&(i=!1),""!==n&&(r.push(n),n=""))}while(i&&t<e.length);return!0===s&&t++,{headerText:r.join("\r")+"\r",headerLength:t}}(i),p=t(n,d);u="ascii"===p.format?s((new TextDecoder).decode(i),p):function(e,t){let i,n=r(),s="binary_little_endian"===t.format,u=new DataView(e,t.headerLength),d=0;for(let r=0;r<t.elements.length;r++){let e=t.elements[r],o=e.properties,p=a(o);c(o,u,s);for(let t=0;t<e.count;t++){i=h(d,o),d+=i[1];let t=i[0];l(n,e.name,t,p)}}return o(n)}(e,p)}else u=s(e,t(e));return u}},E4=class{constructor(e){this.arr=e,this.i=0}empty(){return this.i>=this.arr.length}next(){return this.arr[this.i++]}},vP=class extends Er{constructor(e){super(e)}load(e,t,i,n){let r=this,a=new Kr(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,(function(i){try{t(r.parse(i))}catch(t){n?n(t):console.error(t),r.manager.itemError(e)}}),i,n)}parse(e){function t(e,t,i){for(let n=0,r=e.length;n<r;n++)if(e[n]!==t.getUint8(i+n))return!1;return!0}let i=function(e){if("string"==typeof e){let t=new Uint8Array(e.length);for(let i=0;i<e.length;i++)t[i]=255&e.charCodeAt(i);return t.buffer||t}return e}(e);return function(e){let i=new DataView(e);if(84+50*i.getUint32(80,!0)===i.byteLength)return!0;let n=[115,111,108,105,100];for(let r=0;r<5;r++)if(t(n,i,r))return!1;return!0}(i)?function(e){let t,i,n,r,a,s,o,l,h=new DataView(e),c=h.getUint32(80,!0),u=!1;for(let g=0;g<70;g++)1129270351==h.getUint32(g,!1)&&82==h.getUint8(g+4)&&61==h.getUint8(g+5)&&(u=!0,r=new Float32Array(3*c*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 Dt,p=new Float32Array(3*c*3),f=new Float32Array(3*c*3),m=new ct;for(let g=0;g<c;g++){let e=84+50*g,l=h.getFloat32(e,!0),c=h.getFloat32(e+4,!0),d=h.getFloat32(e+8,!0);if(u){let r=h.getUint16(e+48,!0);32768&r?(t=a,i=s,n=o):(t=(31&r)/31,i=(r>>5&31)/31,n=(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]=c,f[o+2]=d,u&&(m.set(t,i,n).convertSRGBToLinear(),r[o]=m.r,r[o+1]=m.g,r[o+2]=m.b)}}return d.setAttribute("position",new mn(p,3)),d.setAttribute("normal",new mn(f,3)),u&&(d.setAttribute("color",new mn(r,3)),d.hasColors=!0,d.alpha=l),d}(i):function(e){let t,i=new Dt,n=/solid([\s\S]*?)endsolid/g,r=/facet([\s\S]*?)endfacet/g,a=0,s=/[\s]+([+-]?(?:\d*)(?:\.\d*)?(?:[eE][+-]?\d+)?)/.source,o=new RegExp("vertex"+s+s+s,"g"),l=new RegExp("normal"+s+s+s,"g"),h=[],c=[],u=new D,d=0,p=0,f=0;for(;null!==(t=n.exec(e));){p=f;let e=t[0];for(;null!==(t=r.exec(e));){let e=0,i=0,n=t[0];for(;null!==(t=l.exec(n));)u.x=parseFloat(t[1]),u.y=parseFloat(t[2]),u.z=parseFloat(t[3]),i++;for(;null!==(t=o.exec(n));)h.push(parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3])),c.push(u.x,u.y,u.z),e++,f++;1!==i&&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 n=p,s=f-p;i.addGroup(n,s,d),d++}return i.setAttribute("position",new Bt(h,3)),i.setAttribute("normal",new Bt(c,3)),i}("string"!=typeof(n=e)?(new TextDecoder).decode(n):n);var n}},sg=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 i=e>>3,n=this.u8[i],r=7&e;this.u8[i]=t?n|128>>r:n&~(128>>r)}getInt12(e){var t=e/8|0,i=this.u8[t],n=this.u8[t+1],r=this.u8[t+2],a=e%8,s=8-a,o=Math.min(12-s,8);return(((i&=~(255<<s))<<16)+((n&=255<<8-o)<<8)+(r&=255<<8-Math.max(12-s-o,0))>>12-a)-2048}setInt12(e,t){var i=e/8|0,n=e%8,r=(t+=2048)<<12-n,a=(16711680&r)>>16,s=(65280&r)>>8,o=255&r,l=8-n,h=Math.min(12-l,8),c=Math.max(12-l-h,0),u=255<<l;this.u8[i]=(this.u8[i]&u)+a;var d=~(255<<8-h);this.u8[i+1]=(this.u8[i+1]&d)+s;var p=~(255<<8-c);this.u8[i+2]=(this.u8[i+2]&p)+o}getInt6(e){var t=e/8|0,i=this.u8[t],n=this.u8[t+1],r=e%8,a=8-r;return(((i&=~((255<<a)+(255>>8-(2-r))))<<8)+(n&=255<<8-Math.max(6-a,0))>>10-r)-32}setInt6(e,t){var i=e/8|0,n=e%8,r=(t+=32)<<10-n,a=(65280&r)>>8,s=255&r,o=8-n,l=Math.max(6-o,0),h=(255<<o)+(255>>8-(2-n));this.u8[i]=(this.u8[i]&h)+a;var c=~(255<<8-l);this.u8[i+1]=(this.u8[i+1]&c)+s}test(){var e,t,i=new ArrayBuffer(3),n=new sg(i);for(t=0;t<12;t++)for(e=-2048;e<2048;e++)if(n.setInt12(t,e),n.getInt12(t)!=e){console.log("12-bit prob at",t,e),console.log("expected",e,"got",n.getInt12(t));break}for(t=0;t<18;t++)for(e=-32;e<32;e++)if(n.setInt6(t,e),n.getInt6(t)!=e){console.log("6-bit prob at",t,e),console.log("expected",e,"got",n.getInt6(t));break}return n}},J0e=(e=>(e[e.NULL=0]="NULL",e[e.POINT=1]="POINT",e[e.POLYLINE=3]="POLYLINE",e[e.POLYGON=5]="POLYGON",e))(J0e||{}),yP=class{parse(e){var t={},i=new DataView(e),n=0;if(t.fileCode=i.getInt32(n,!1),9994!=t.fileCode)throw new Error("Unknown file code: "+t.fileCode);for(n+=24,t.wordLength=i.getInt32(n,!1),t.byteLength=2*t.wordLength,n+=4,t.version=i.getInt32(n,!0),n+=4,t.shapeType=i.getInt32(n,!0),n+=4,t.minX=i.getFloat64(n,!0),t.minY=i.getFloat64(n+8,!0),t.maxX=i.getFloat64(n+16,!0),t.maxY=i.getFloat64(n+24,!0),t.minZ=i.getFloat64(n+32,!0),t.maxZ=i.getFloat64(n+40,!0),t.minM=i.getFloat64(n+48,!0),t.maxM=i.getFloat64(n+56,!0),n+=64,t.records=[];n<t.byteLength;){var r={};r.number=i.getInt32(n,!1),n+=4,r.length=i.getInt32(n,!1),n+=4;try{r.shape=this.parseShape(i,n,r.length)}catch(e){console.log(e,r)}n+=2*r.length,t.records.push(r)}return t}parseShape(e,t,i){var n=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,n=0;n<r.parts.length;n++)r.parts[n]=e.getInt32(t,!0),t+=4;for(n=0;n<r.points.length;n++)r.points[n]=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}},xP=class{constructor(){this.LINE_MATERIAL=new Gn({color:0,linewidth:2,opacity:.8,transparent:!0}),this.MESH_MATERIAL=new ln({color:1926655,opacity:.8,transparent:!0})}createModel(e){for(var t=[],i=[],n=0;n<e.records.length;n++){var r=e.records[n].shape;if(3===r.type||5===r.type)for(var a=r.content.points,s=r.content.parts,o=0;o<s.length;o++){let e=[];for(var l=s[o],h=s[o+1]||a.length/2;l<h;l++){var c=a[2*l],u=a[2*l+1];e.push(new D(c,u,0))}if(5===r.type){let n=zs.triangulateShape(e,[]),r=[];n.forEach((e=>r.push(...e)));let a=new Dt;a.setFromPoints(e),a.setIndex(r),t.push(a);let s=new Dt;e.length>2&&!e[0].equals(e[e.length-1])&&e.push(e[0]),s.setFromPoints(e),i.push(s)}else{let t=new Dt;t.setFromPoints(e),i.push(t)}}}var d=new on;for(n=0;n<i.length;n++)d.add(new fr(i[n],this.LINE_MATERIAL));for(n=0;n<t.length;n++)d.add(new xt(t[n],this.MESH_MATERIAL));return console.log("parsed",t.length,i.length),d}loadCompressed(e){for(var t=this.deltaDecode6(e),i=[],n=[],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 D(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 Dt;t.setFromPoints(o),i.push(t),e=[]}}var h=new on;for(r=0;r<n.length;r++)h.add(new fr(n[r],this.LINE_MATERIAL));for(r=0;r<i.length;r++)h.add(new xt(i[r],this.MESH_MATERIAL));return console.log("parsed compressed",i.length,n.length),h}compress(e){for(var t=[],i=0;i<e.records.length;i++){var n=e.records[i].shape;if(5===n.type)for(var r=n.content.points,a=n.content.parts,s=0;s<a.length;s++){for(var o=a[s],l=a[s+1]||r.length/2;o<l;o++){var h=r[2*o],c=r[2*o+1];t.push(h/180*32767,c/180*32767)}t.push(-32768)}}var u=new Int16Array(t);console.log("16-bit quantized byteLength",u.buffer.byteLength);var d=this.deltaEncode6(u);return console.log("delta-encoded byteLength",d.byteLength),d}deltaEncode(e){for(var t=[],i=[],n=[],r=0,a=0,s=0,o=0;o<e.length;o++)-32768!=e[o]?0==n.length?(r=e[o],a=e[o+1],n.push(r,a),s+=4,o++):Math.abs(r-e[o])>1023||Math.abs(a-e[o+1])>1023?(i.push(n),s+=1,n=[],r=e[o],a=e[o+1],n.push(r,a),s+=4,o++):(n.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++):(i.push(n),t.push(i),i=[],n=[],s+=3);return this.storeDeltas(s,t)}deltaEncode6(e){var t=[],i=[],n=[],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==n.length?(r=e[s],a=e[s+1],n.push(r,a),o+=4,s++):Math.abs(r-e[s])>31||Math.abs(a-e[s+1])>31?(i.push(n),o+=1,n=[],r=e[s],a=e[s+1],n.push(r,a),o+=4,s++):(n.push(e[s]-r,e[s+1]-a),r+=e[s]-r,a+=e[s+1]-a,o+=2,s++):(i.push(n),t.push(i),i=[],n=[],o+=3);return this.storeDeltas6(o,t)}storeDeltas(e,t){for(var i=new ArrayBuffer(e),n=new DataView(i),r=0,a=0;a<t.length;a++){for(var s=t[a],o=0;o<s.length;o++){var l=s[o];n.setInt16(r,l[0]),r+=2,n.setInt16(r,l[1]),r+=2;for(var h=2;h<l.length;h++)n.setInt8(r++,l[h]);n.setInt8(r,-128),r+=1}n.setInt16(r,-32768),r+=2}return i}deltaDecode(e){for(var t=new DataView(e),i=0,n=[];i<e.byteLength;){var r=t.getInt16(i);if(i+=2,-32768!==r){var a=t.getInt16(i);for(i+=2,n.push(r,a);i<e.byteLength;){var s=t.getInt8(i);if(i++,-128==s)break;var o=t.getInt8(i);i++,r+=8*s,a+=8*o,n.push(r,a)}}else n.push(-32768)}return n}storeDeltas6(e,t){for(var i=new ArrayBuffer(Math.ceil(.75*e)+4),n=new sg(i),r=32,a=0;a<t.length;a++){for(var s=t[a],o=0;o<s.length;o++){var l=s[o];n.setInt12(r,l[0]),r+=12,n.setInt12(r,l[1]),r+=12;for(var h=2;h<l.length;h++)n.setInt6(r,l[h]),r+=6;n.setInt6(r,-32),r+=6}n.setInt12(r,-2048),r+=12}return new DataView(i).setUint32(0,r),i}deltaDecode6(e){for(var t=new DataView(e).getUint32(0),i=new sg(e),n=32,r=[];n<t;){var a=i.getInt12(n);if(n+=12,-2048!==a){var s=i.getInt12(n);for(n+=12,r.push(a,s);n<t;){var o=i.getInt6(n);if(n+=6,-32===o)break;var l=i.getInt6(n);n+=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}},bP=class{load(e,t,i,n){return ft(this,null,(function*(){this.updateProgress(i,0);let r=new XMLHttpRequest;r.responseType="arraybuffer",r.onload=()=>{this.updateProgress(i,50);let e=(new yP).parse(r.response),n=(new xP).createModel(e);this.updateProgress(i,99),t(n)},r.onerror=n,r.open("GET",e),r.send(null)}))}updateProgress(e,t){e&&e(new ProgressEvent("progress",{lengthComputable:!0,loaded:t,total:100}))}},_4=class{constructor(e){this.manager=e}loadLocalModel(e,t,i){return ft(this,null,(function*(){let n=t.toLowerCase();return n.endsWith("fbx")?this.loadFbx(e,i):n.endsWith("obj")?this.loadObj(e,i):n.endsWith("stl")?this.loadStl(e,i):n.endsWith("ifc")?(se.warn("[LoadingHelper] IFC is not supported directly since three.js r150!"),Promise.reject("Not supported!")):n.endsWith("shp")?this.loadShp(e,i):n.endsWith("dae")?this.loadDae(e,i):n.endsWith("dxf")?this.loadDxf(e,i):n.endsWith("jpg")||n.endsWith("jpeg")||n.endsWith("png")?this.loadImage(e,i):this.loadGltf(e,i)}))}loadModel(e,t,i){return ft(this,null,(function*(){let n=e;if(!n)return Promise.resolve();let r=(null==t?void 0:t.toLowerCase())||"";if(!r){let e=n.split("?")[0].toLowerCase();if(e){let t=e.lastIndexOf(".");-1!==t&&(r=e.slice(t+1))}}return r.endsWith("fbx")?this.loadFbx(n,i):r.endsWith("obj")?this.loadObj(n,i):r.endsWith("stl")?this.loadStl(n,i):r.endsWith("ifc")?void se.warn("[LoadingHelper] IFC is not supported directly since three.js r150!"):r.endsWith("shp")?this.loadShp(n,i):r.endsWith("dae")?this.loadDae(n,i):r.endsWith("dxf")?this.loadDxf(n,i):r.endsWith("jpg")||r.endsWith("jpeg")||r.endsWith("png")?this.loadImage(n,i):this.loadGltf(n,i)}))}loadGltf(e,t){return ft(this,null,(function*(){let i=this.getGltfLoader();-1!==e.indexOf("#")&&console.warn(`[LoadingHelper] '#' is not allowed in filename ${e}`),e=e.replace(/#/g,encodeURIComponent("#"));let n=yield i.loadAsync(e,(e=>{0===e.total&&e.loaded>0||t&&t(e)}));return Promise.resolve(n.scene)}))}parseGltf(e,t,i,n){return this.getGltfLoader().parse(e,t,(e=>i(e.scene)),n)}loadFbx(e,t){return ft(this,null,(function*(){let i=yield new cP(this.manager).loadAsync(e,t);return Promise.resolve(i)}))}loadObj(e,t){return ft(this,null,(function*(){let i=new mP(this.manager),n=new fP(this.manager),r=e.replace(".obj",".mtl"),a=yield n.loadAsync(r,t);a.preload(),i.setMaterials(a);let s=yield i.loadAsync(e,t);return Promise.resolve(s)}))}loadStl(e,t){return ft(this,null,(function*(){let i=yield new vP(this.manager).loadAsync(e,t),n=new Cu({color:11184810,metalness:.1,roughness:.8}),r=new xt(i,n);return Promise.resolve(r)}))}loadShp(e,t){return ft(this,null,(function*(){let i=new bP;return new Promise(((n,r)=>{i.load(e,(e=>{n(e)}),t,(e=>{r(e)}))}))}))}loadDae(e,t){return ft(this,null,(function*(){let i=yield new sP(this.manager).loadAsync(e,t);return Promise.resolve(i.scene)}))}loadDxf(e,t){return ft(this,null,(function*(){var i;this.font||console.warn("[LoadingHelper] Should set font first!");let n=new gn(this.manager,{ignorePaperSpace:!0,enableLocalCache:!1});n.setFont(this.font),yield null==(i=this.font)?void 0:i.getFontFromIndexeddb();try{let i=yield n.loadAsync(e,t);return Promise.resolve(i.threejsObject)}catch(e){let i=new ErrorEvent("");return Promise.reject(i)}}))}loadPly(e,t){return ft(this,null,(function*(){let i=yield new gP(this.manager).loadAsync(e,t);return Promise.resolve(new xt(i))}))}loadImage(e,t){return ft(this,null,(function*(){let i=yield new ws(this.manager).loadAsync(e,t);if(!i)return Promise.reject("Failed to load image!");let n=i.image,r=n&&n.height||10,a=n&&n.width||10;r*=10/a,a=10;let s=new ln({map:i,side:Sr,transparent:!0}),o=new ui(a,r),l=new xt(o,s);return Promise.resolve(l)}))}loadDxfData(e,t,i,n,r){return ft(this,null,(function*(){var a;this.font||console.warn("[LoadingHelper] Should set font first!");let s=new gn(this.manager,r);return s.setFont(this.font),yield null==(a=this.font)?void 0:a.getFontFromIndexeddb(),s.manager.onLoad=()=>{n&&n()},s.load(e,t,i)}))}setFont(e){this.font=e}static setDracoDecoderPath(e){this.decoderPath=e}getGltfLoader(){if(!this.gltfLoader){this.gltfLoader=new eh(this.manager);let e=new aP(this.manager);e.setDecoderPath(_4.decoderPath),this.gltfLoader.setDRACOLoader(e)}return this.gltfLoader}},ja=_4;function T4(e){let t=new Blob([e],{type:"text/javascript"}),i=URL.createObjectURL(t),n=new Worker(i);return URL.revokeObjectURL(i),n}function w4(){return T4('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&&gt.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&&gt!==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')}ja.decoderPath="libs/draco/gltf/";var EP=class{constructor(){this.running=!1,this.worker=new w4,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 se.warn("[GenerateMeshBVHWorker] Already running job.");if(!this.worker)return void se.warn("[GenerateMeshBVHWorker] Worker has been disposed.");let{worker:i}=this;this.running=!0;let n=new Map;e.forEach((e=>{n.set(e.id,e)}));let r=0;return new Promise(((e,a)=>{let s=()=>{++r===n.size&&(this.running=!1,i.onmessage=null,e())};i.onerror=e=>{se.warn(`[GenerateMeshBVHWorker] ${e.message}`),a(new Error(`[GenerateMeshBVHWorker] ${e.message}`)),this.running=!1},i.onmessage=e=>{this.running=!1;let{data:i}=e;if(i.error)se.warn(i.error),s();else if(i.serialized){let{serialized:e,position:r,id:a}=i,o=n.get(a),l=Mc.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),se.debug("before update, index:",o.index.array),o.index.array=e.index;else{let t=new mn(e.index,1,!1);o.setIndex(t)}o.index&&(se.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(i.progress)};for(let r of n){let e=r[0],n=r[1],a=n.index?n.index.array:void 0,o=n.attributes.position,l=o.array;if(o.isInterleavedBufferAttribute||a&&a.isInterleavedBufferAttribute){se.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&&(n.userData.originalIndex=a.slice()))),i.postMessage({id:e,index:a,position:l,options:Ii(Tr({},t),{onProgress:null,includedProgressCallback:Boolean(t.onProgress),groups:[...n.groups]})},h.length>0?h.map((e=>e.buffer)):[])}}))}dispose(){this.worker.terminate(),this.worker=void 0}},Qf=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 i=0;i<t;i++)this.workers[i]=new EP}isRunning(){return this.running}generate(e){return ft(this,arguments,(function*(e,t={}){if(this.running)se.warn("[BVHHelper] Already running job.");else{if(0!==this.workers.length)return this.running=!0,new Promise((i=>{let n=this.workers.length,r=e.length,a=[],s=Math.floor(r/n),o=r%n,l=0,h=0;for(let c=0;c<n;c++){let i=this.workers[c];if(c<o?(l=c*s+c,h=l+s+1):(l=c*s+o,h=l+s),l=Math.min(l,r),h=Math.min(h,r),l>=h)break;se.debug("startIndex: "+l+" endIndex: "+h),a.push(i.generate(e.slice(l,h),t))}Promise.allSettled(a).then((()=>{this.running=!1,i()}))}));se.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 i=new Set;e.forEach((e=>{e.traverse((e=>{let n=e;if(n.isMesh&&n.geometry&&Rr.isMergedMesh(n)&&!(n instanceof Oi)){if(i.has(n.geometry.id))return;n.geometry.index&&t.saveOriginalIndex&&(n.geometry.userData.originalIndex=n.geometry.index.array.slice()),n.geometry.boundsTree=new Mc(n.geometry,t),i.add(n.geometry.id)}}))}))}static createMeshBvhAsync(e,t={}){let i=new Set,n=[];e.forEach((e=>{e.traverse((e=>{let t=e;if(t.isMesh&&t.geometry&&Rr.isMergedMesh(t)&&!(t instanceof Oi)){if(i.has(t.geometry.id))return;n.push(t.geometry),i.add(t.geometry.id)}}))}));let r=new Qf;r.generate(n,t).then((()=>{r.dispose()}))}},Q0e=class{constructor(e,t,i,n,r){this.targetPixelHeight=100,this.canvasHeight=800,this.camera=e,this.object=i,this.targetPixelHeight=n,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,i=this.camera.position.distanceTo(this.object.position),n=Bgt(t,i,this.canvasHeight);if(Math.abs(n-this.targetPixelHeight)<5)return;let r=this.object.scale.x;r*=this.targetPixelHeight/n,this.object.scale.set(r,r,r),this.object.updateMatrix()}},Bgt=(e,t,i=800,n=45)=>{let r=n*(Math.PI/180);return i*(e/(2*Math.tan(r/2)*t))},_P,TP=new xe,wP=new xe,SP=new xe,eve=new xe,Ugt=new xe,Hgt=new xe,_o=class extends Hi{constructor(e){super(St.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=_o.FILL_COLOR_NONE,e.strokeStyle=_o.lineColor,e.lineWidth=_o.lineWidth,e.beginPath(),this.drawSnapFunctions[this.snapType](e,t),_P&&this.drawDebug(e,t),e.closePath(),e.fill(),e.stroke(),e.restore())}drawDebug(e,t){null==_P||_P.forEach((i=>{let n=this.transToScreenCoord(i.start,t),r=this.transToScreenCoord(i.end,t);e.moveTo(n.x,n.y),e.lineTo(r.x,r.y)}))}drawSelect(e,t){}isPointInPath(e){return!1}drawSnapLine(e,t){e.save(),e.strokeStyle=_o.SNAP_LINE_COLOR,e.lineWidth=_o.lineWidth;let i=this.osnapInfo.line;if(!i)return;let n=this.transToScreenCoord(i.start,t),r=this.transToScreenCoord(i.end,t);e.moveTo(n.x,n.y),e.lineTo(r.x,r.y),e.stroke(),e.restore()}drawTripleCorss(e,t){let i=this.transToScreenCoord(this.osnapInfo.point,t),n=_o.iconSize/1.6,r=TP.set(i.x,i.y-n),a=wP.set(i.x-.87*n,i.y+n/1.4),s=SP.set(i.x+.87*n,i.y+n/1.4);e.moveTo(i.x,i.y),e.lineTo(r.x,r.y),e.moveTo(i.x,i.y),e.lineTo(a.x,a.y),e.moveTo(i.x,i.y),e.lineTo(s.x,s.y)}drawSquare(e,t){let i=this.transToScreenCoord(this.osnapInfo.point,t),n=_o.iconSize,r=_o.iconSize;e.rect(i.x-n/2,i.y-r/2,n,r)}drawTriangle(e,t){let i=this.transToScreenCoord(this.osnapInfo.point,t),n=_o.iconSize/1.6,r=TP.set(i.x,i.y-n),a=wP.set(i.x-.87*n,i.y+n/2),s=SP.set(i.x+.87*n,i.y+n/2);e.moveTo(r.x,r.y),e.lineTo(a.x,a.y),e.lineTo(s.x,s.y)}drawCircleWithCross(e,t){let i=this.transToScreenCoord(this.osnapInfo.point,t),n=_o.iconSize/2;e.arc(i.x,i.y,n,0,2*Math.PI),e.moveTo(i.x-n/1.8,i.y),e.lineTo(i.x+n/1.8,i.y),e.moveTo(i.x,i.y-n/1.8),e.lineTo(i.x,i.y+n/1.8)}drawCross(e,t){let i=this.transToScreenCoord(this.osnapInfo.point,t),n=_o.iconSize/2,r=TP.set(i.x-n,i.y-n),a=wP.set(i.x+n,i.y+n),s=SP.set(i.x+n,i.y-n),o=eve.set(i.x-n,i.y+n);e.moveTo(r.x,r.y),e.lineTo(a.x,a.y),e.moveTo(s.x,s.y),e.lineTo(o.x,o.y)}drawPerpendicular(e,t){let i=this.transToScreenCoord(this.osnapInfo.point,t),n=_o.iconSize/2,r=TP.set(i.x,i.y),a=wP.set(i.x-n,i.y),s=SP.set(i.x,i.y+n),o=eve.set(i.x-n,i.y-n),l=Ugt.set(i.x-n,i.y+n),h=Hgt.set(i.x+n,i.y+n);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"}},Ms=_o;Ms.lineColor="rgba(255, 119, 0, 1)",Ms.FILL_COLOR_NONE="rgba(0, 0, 0, 0)",Ms.SNAP_LINE_COLOR="rgba(255, 240, 0, 0.3)",Ms.lineWidth=2,Ms.iconSize=14,Un._registerDrawableClass(Ms);var S4=(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))(S4||{}),Vgt=1e-5,Wi=new D,sa=new D,Dy=new D,v_=new D,ag=new et,y_=new ra;function zgt(e,t){let i=Number.MAX_VALUE,n=0;for(let r=0;r<e.vertices.length;r++){let a=t.distanceTo(e.vertices[r]);a<i&&(n=r,i=a)}return{vertex:e.vertices[n],distance:i}}function Ggt(e){if(!(e.object instanceof xt&&e.face))return;let t=e.object,i=t.geometry.attributes.position,n=t.geometry.index;if(i.count<3)return;let r=Rr.getBatchByFaceIndex(t,e.faceIndex);t.geometry.boundsTree&&(n=new mn(t.geometry.userData.originalIndex,1,!1)),ag.identity(),t instanceof Oi&&void 0!==e.instanceId&&t.getMatrixAt(e.instanceId,ag),ag.premultiply(t.matrixWorld);let a,s=t.geometry.drawRange,o=i.array;if(n){let e=Math.max(0,s.start),t=Math.min(n.count,s.start+s.count);if(a=n.array,r){e=Math.max(e,r.indexStart),t=Math.min(t,r.indexStart+r.indexCount),a=n.array.slice(e,t),o=i.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!==n.count)&&(a=n.array.slice(e,t))}else{let e=Math.max(0,s.start),t=Math.min(i.count,s.start+s.count);r?(e=Math.max(e,r.positionStart),t=Math.min(t,r.positionStart+r.positionCount),o=i.array.slice(3*r.positionStart,3*(r.positionStart+r.positionCount))):(0!==e||t!==i.count)&&(o=i.array.slice(3*e,3*t));let n=o.length/3;a=n>65535?new Uint32Array(n):new Uint16Array(n);for(let i=0,r=n;i<r;i++)a[i]=i}let l=AA.buildEdge(o,a,20),h=Number.MAX_VALUE,c=0;for(let p=0;p<l.length;p+=2){let t=l[p],i=l[p+1];Wi.set(o[3*t],o[3*t+1],o[3*t+2]),Wi.applyMatrix4(ag),sa.set(o[3*i],o[3*i+1],o[3*i+2]),sa.applyMatrix4(ag),y_.set(Wi,sa),y_.closestPointToPoint(e.point,!0,Dy);let n=e.point.distanceTo(Dy);n<h&&(c=p,h=n,v_.copy(Dy))}let u=l[c],d=l[c+1];return Wi.set(o[3*u],o[3*u+1],o[3*u+2]),Wi.applyMatrix4(ag),sa.set(o[3*d],o[3*d+1],o[3*d+2]),sa.applyMatrix4(ag),{vertices:[Wi.clone(),sa.clone()],vertex:v_.clone(),distance:h}}var MP=class{constructor(e){var t;this.drawableList=new Zo("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 Ms("TripleCross"),t=new Ms("Square"),i=new Ms("Triangle"),n=new Ms("CircleWithCross"),r=new Ms("Cross"),a=new Ms("Perpendicular");this.markers[1]=t,this.markers[2]=i,this.markers[4]=e,this.markers[32]=r,this.markers[64]=n,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(Ms.lineColor)}setMarkerLineColor(e){Ms.lineColor=An.rgba2Color(e)}getMarkerLineWidth(){return Ms.lineWidth}setMarkerLineWidth(e){Ms.lineWidth=e}getMarkerIconSize(){return Ms.iconSize}setMarkerIconSize(e){Ms.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,i){if(!e||e.length<1)return void this.deactivate();se.debug("[OSnap] intersections before handleSnap:",e);let n,r=[],a=!1;for(let o of e)o.object instanceof xt?(n||(n=o.point),!a&&"groundPlane"!==o.object.name&&(r.push(o),a=!0)):r.push(o);if(!t&&n){n.setZ(0);for(let t of r)t.point.z=0,t.distance=t.point.distanceTo(n);let e=e=>e instanceof ii?0:e instanceof qr?2:e instanceof fr?1:3;r.sort(((t,i)=>{let n=e(t.object),r=e(i.object);return n!==r?n-r:t.distance-i.distance}))}n||(se.warn("[OSnap] Potential to produce erroneous snap results"),n=r[0].point),se.debug("[OSnap] intersections:",r),se.debug("[OSnap] mousePosition:",n);let s=this.getSnapPointAndUpdateMarker(n,r,t,i);return(null==s?void 0:s.clone())||n}getSnapPointAndUpdateMarker(e,t,i,n){if(!t.length)return void this.activateMarker(0);let r=this.getSnapInfo(e,t,i,n);if(r&&0!==r.type)return this.activateMarker(r.type,r),r.point;this.activateMarker(0)}activateMarker(e,t){var i;this.activeOSnapType&&(this.markers[this.activeOSnapType].visible=!1),this.activeOSnapType=e;let n=this.markers[e];n&&t&&(n.update(t),n.visible=!0),null==(i=this.overlayRender)||i.render()}getFootOfPerpendicular(e,t,i=Vgt){let{start:n,end:r}=t,a=n.x-r.x,s=n.y-r.y,o=n.z-r.z;if(n.distanceTo(r)<i)return n.clone();let l=(e.x-n.x)*(n.x-r.x)+(e.y-n.y)*(n.y-r.y)+(e.z-n.z)*(n.z-r.z);return l/=a*a+s*s+o*o,new D(n.x+l*a,n.y+l*s,n.z+l*o)}getSnapInfo(e,t,i,n){let r=2*this.snapToleranceInWorldCoord;se.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,c=t[l],u=c.object;u instanceof xt?h=this.getOsnapInfoListFromMesh(e,c,r,o):u instanceof fr?h=this.getOsnapInfoListFromLine(e,c,i,r,s,o,n):u instanceof ii&&(h=this.getOsnapInfoListFromPoint(e,c,i,r,o)),h&&(o=this.osnapTypePriorities[h.type],a.push(h))}if(0!==a.length)return a.sort(((e,t)=>{let i=this.osnapTypePriorities[e.type],n=this.osnapTypePriorities[t.type];return i!==n?i-n:e.distance-t.distance})),a[0]}getOsnapInfoListFromMesh(e,t,i,n){if(n<this.osnapTypePriorities[1])return;let r=Date.now(),a=Ggt(t);if(!a)return void se.warn("[OSnap] Failed to get edge !");let s=Date.now();se.debug(`[OSnap] getEdgeSnappingInfo costs ${(s-r)/1e3}s `),se.debug("[OSnap] edge:",a);let o=zgt(a,e);if(se.debug("[OSnap] vertex:",o),o.distance<=i&&this.isOSnapTypeEnabled(1))return{distance:o.distance,type:1,point:o.vertex};if(a.distance<=i){if(this.isOSnapTypeEnabled(2)&&n<this.osnapTypePriorities[2])return;Wi.copy(a.vertices[0]),Wi.add(a.vertices[1]),Wi.divideScalar(2);let t=Wi.distanceTo(e);return t<=i&&this.isOSnapTypeEnabled(2)?{distance:t,type:2,point:Wi.clone()}:!this.isOSnapTypeEnabled(4)||n<this.osnapTypePriorities[4]?void 0:{distance:a.distance,type:4,point:a.vertex,line:{start:a.vertices[0],end:a.vertices[1]}}}se.debug("[OSnap] Face")}getOsnapInfoFromSegment(e,t,i,n,r,a,s){let o={start:t,end:i};if(s&&a>=this.osnapTypePriorities[16]&&this.isOSnapTypeEnabled(16)){let t=this.getFootOfPerpendicular(s,o,n),i=e.distanceTo(t);if(i<=n)return{distance:Zt.floorNumber(i,7),type:16,point:t.clone()}}if(a<this.osnapTypePriorities[1])return;y_.set(t,i),y_.closestPointToPoint(e,!0,Dy);let l=e.distanceTo(Dy);if(l>n)return;let h=e.distanceTo(t),c=e.distanceTo(i);if(Math.min(h,c)<=n&&this.isOSnapTypeEnabled(1)){let e=h,n=t;return c<h&&(e=c,n=i),{distance:Zt.floorNumber(e,7),type:1,point:n.clone()}}if(a<this.osnapTypePriorities[2])return;y_.getCenter(v_);let u=e.distanceTo(v_);if(u<n&&this.isOSnapTypeEnabled(2))return{point:v_.clone(),distance:Zt.floorNumber(u,7),type:2};if(!(a<this.osnapTypePriorities[4])){if(r.line&&this.isOSnapTypeEnabled(32)){let t=Qt.getLineSegmentsIntersectingPoint(r.line,o);if(!t)return;let i=e.distanceTo(t)/2;return i<n?(r.line=void 0,{point:t.clone(),distance:Zt.floorNumber(i,7),type:32}):void 0}if(this.isOSnapTypeEnabled(4))return r.line={start:t.clone(),end:i.clone()},{point:Dy.clone(),distance:Zt.floorNumber(l,7),type:4,line:{start:t.clone(),end:i.clone()}}}}getOsnapInfoListFromLine(e,t,i,n,r,a,s){let o=[],l=t.object,h=l instanceof qr?2:1,c=l.geometry.index,u=l.geometry.attributes.position,d=l.geometry.drawRange,p=Rr.getBatchByLineIndex(l,t.index);if(c){let t=Math.max(0,d.start),f=Math.min(c.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=c.getX(d),h=c.getX(d+1);Wi.fromBufferAttribute(u,t),sa.fromBufferAttribute(u,h),Wi.applyMatrix4(l.matrixWorld),sa.applyMatrix4(l.matrixWorld),i||(Wi.setZ(0),sa.setZ(0));let p=this.getOsnapInfoFromSegment(e,Wi,sa,n,r,a,s);p&&(a=this.osnapTypePriorities[p.type],o.push(p))}}else{let t=Math.max(0,d.start),c=Math.min(u.count,d.start+d.count);p&&(t=Math.max(t,p.positionStart),c=Math.min(c,p.positionStart+p.positionCount));for(let d=t,p=c;d<p-1;d+=h){Wi.fromBufferAttribute(u,d),sa.fromBufferAttribute(u,d+1),Wi.applyMatrix4(l.matrixWorld),sa.applyMatrix4(l.matrixWorld),i||(Wi.setZ(0),sa.setZ(0));let t=this.getOsnapInfoFromSegment(e,Wi,sa,n,r,a,s);t&&(a=this.osnapTypePriorities[t.type],o.push(t))}}if(0!==o.length)return o.sort(((e,t)=>{let i=this.osnapTypePriorities[e.type],n=this.osnapTypePriorities[t.type];return i!==n?i-n:e.distance-t.distance})),o[0]}getOsnapInfoListFromPoint(e,t,i,n,r){if(r<this.osnapTypePriorities[1])return;let a=t.object,s=a.geometry.getAttribute("position");Wi.fromBufferAttribute(s,t.index),Wi.applyMatrix4(a.matrixWorld),sa.copy(e),i||(Wi.setZ(0),sa.setZ(0));let o=sa.distanceTo(Wi);if(o>n)return;let l={distance:o,point:Wi.clone(),type:1};if("CircleCenter"===a.userData.type){if(!this.isOSnapTypeEnabled(64))return;l.type=64}else if(se.debug("[OSnap] Other types of vertices !"),!this.isOSnapTypeEnabled(1))return;return l}getIntersectsIncludeOutline(e,t){let i=e.slice(),n=[];for(let a=0;a<e.length&&a<this.intersectionLimit;a++){let t=e[a].object;if(t.updateWorldMatrix(!0,!1),t instanceof xt&&!Hn.hasOutline(t,!1)){let e=Hn.createOutline(t.geometry);e.visible=!1,t.add(e),e.updateWorldMatrix(!0,!1),n.push(e)}}let r=[];return n.length>0&&(r=t.intersectObjects(n)||[],se.debug("[OSnap] Intersected with newly created edges: ",r),r.length>0&&i.push(...r)),i.sort(((e,t)=>e.distance-t.distance)),i}},M4=Xi(kl(),1),Xl=class{constructor(e,t,i){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(Rf,this.follow):document.removeEventListener(Rf,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==i?void 0:i.target,this.parentNode=(null==i?void 0:i.parentNode)||document.body,null!=i&&i.followPointer&&(this.node.classList.add("follow-tooltip"),this.target?this.target.addEventListener(Rf,this.follow):document.addEventListener(Rf,this.follow)),this.parentNode.appendChild(this.node),(null==i||!i.showOnCreate)&&this.node.setAttribute("hidden","")}setContent(e){this.node.textContent&&(this.node.textContent=null),(0,M4.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,M4.forEach)(this.childNode.children,(e=>{this.childNode.removeChild(e)})),this.childNode.append(e)}},RP=class{constructor(e){this.active=!1,this.isResolvedOrRejected=!1,this.mouseClicked=e=>{var t;if(e.markupData){let i=e.markupData.id,n=null==(t=this.viewer.overlayRender)?void 0:t.getDrawableById(i);if(n){let e=n.getBounds();e=e.clone().expandByScalar(20*this.viewer.getPixelSizeInWorldCoord());let t=an.world2NormalizedScreen(e.min,this.camera,this.viewerContainer),i=an.world2NormalizedScreen(e.max,this.camera,this.viewerContainer),r=new Mi(new xe(Math.min(t.x,i.x),Math.min(t.y,i.y)),new xe(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);let i=this.viewer.translate;if(i){this.tooltip=new Xl("pick-markup-tooltip",i("Tooltip.pickMarkup"),{followPointer:!0,showOnCreate:!0,parentNode:this.viewer.widgetContainer,target:this.viewerContainer});let e=document.getElementById("pick-markup-tooltip");e&&(e.style.pointerEvents="none");let n=i("Tooltip.pickMarkup");n&&this.tooltip&&(null==(t=this.tooltip)||t.setContent(n))}this.viewer.dispatchEvent("PickMarkupActivated")}deactivate(){var e,t,i;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==(i=this.tooltip)||i.destroy(),this.tooltip=void 0,this.viewer.dispatchEvent("PickMarkupDeactivated"),this.resolve&&!this.isResolvedOrRejected&&(this.resolve(void 0),this.isResolvedOrRejected=!0)}pick(){return ft(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!")}},AP=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,i;if(0===e.button){this.mouseDown=!0;let n=new xe(e.x,e.y);this.mouseDownPositionX=n.x,this.mouseDownPositionY=n.y,null==(t=this.tooltip)||t.hide(),null==(i=this.tooltip)||i.destroy(),this.tooltip=void 0}},this.mousemove=e=>{if(!this.mouseDown)return;let t=new xe(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 xe(Math.min(this.mouseDownPositionX,t.x),Math.min(this.mouseDownPositionY,t.y)),i=new xe(Math.max(this.mouseDownPositionX,t.x),Math.max(this.mouseDownPositionY,t.y));this.drawRect(e,i)}},this.mouseup=e=>{if(this.mouseDown&&this.mouseMove){let t=new xe(e.x,e.y),i=new xe(Math.min(this.mouseDownPositionX,t.x),Math.min(this.mouseDownPositionY,t.y)),n=new xe(Math.max(this.mouseDownPositionX,t.x),Math.max(this.mouseDownPositionY,t.y)),r=new Mi(i,n);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);let t=this.viewer.controls;this.tempKey=t.mouseButtons.left,this.tempEnableRotate=t.enableRotate,t.mouseButtons.left=yt.NONE,this.tempTouch=t.touches.one,t.touches.one=yt.NONE,t.enableRotate=!1;let i=this.viewer.translate;if(i){this.tooltip=new Xl("box-select-tooltip",i("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=i("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.controls.mouseButtons.left=this.tempKey,this.viewer.controls.enableRotate=this.tempEnableRotate,this.viewer.controls.touches.one=this.tempTouch,this.viewer.dispatchEvent("BoxSelectDeactivated"),this.resolve&&!this.isResolvedOrRejected&&(this.resolve(void 0),this.isResolvedOrRejected=!0)}drawRect(e,t){this.rectDom||(this.rectDom=document.createElement("div"),this.rectDom.style.cssText=`position: absolute;border: ${AP.BORDER_WIDTH} solid ${AP.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 i=Math.abs(t.x-e.x),n=Math.abs(t.y-e.y);this.rectDom.style.width=`${i}px`,this.rectDom.style.height=`${n}px`}setRectDomVisible(e){this.rectDom&&(this.rectDom.style.display=e?"inline-block":"none")}select(){return ft(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!")}},ep=AP;ep.BORDER_COLOR="#fff000",ep.BORDER_WIDTH="2px";var or=class extends Ss{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)}},Oy=(e=>(e.BaseViewer="BaseViewer",e.BimViewer="BimViewer",e.DxfViewer="DxfViewer",e.VRViewer="VRViewer",e))(Oy||{}),tp=class extends Ss{constructor(e){super(),this.name="BaseViewer",this.translate=this.initLocalization(),this.height=0,this.width=0,this.jobCount=0,this.enableOverlayRenderer=!0,this.frustumSize=this.width,this.lastFrameExecuteTime=Date.now(),this.minFrameInterval=10,this.plugins=[],this.viewerCfg=e,this.undoRedoManager=new lC,this.initLogLevel(),this.initLocalization(),Fn.isBrowser&&!e.context&&(this.initContainer(),this.initViewerContainer(),this.initWidgetContainer())}initLogLevel(){let e=this.viewerCfg.logLevel;e&&hde(e)}initLocalization(){var e;let t=(null==(e=this.viewerCfg)?void 0:e.language)||"cn";return rg.init({lng:t,debug:!1,resources:{en:{translation:Xde},cn:{translation:Yde}}}),rg.t}initContainer(){let e=document.getElementById(this.viewerCfg.containerId);e||(se.error("[Viewer] containerId:",this.viewerCfg.containerId,"is not found in dom tree! will append to document body"),e=document.body);let t=document.createElement("div");t.classList.add("gemini-container"),t.style.cssText="width: 100%; height: 100%; position: relative;",e.appendChild(t),this.container=t}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.width=e.clientWidth,this.height=e.clientHeight,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}initSpinner(){var e;if(!this.viewerCfg.enableSpinner)return;let t=document.createElement("div");t.classList.add("gemini-spinner"),t.appendChild(document.createElement("span")),t.appendChild(document.createElement("span")),t.appendChild(document.createElement("span")),t.appendChild(document.createElement("span")),null==(e=this.viewerContainer)||e.appendChild(t),this.spinner=t,this.setSpinnerVisibility(this.jobCount>0)}setSpinnerVisibility(e){this.spinner&&(e?this.spinner.classList.remove("hidden"):this.spinner.classList.add("hidden"))}increaseJobCount(){this.setSpinnerVisibility(++this.jobCount>0)}decreaseJobCount(){this.jobCount<=0?se.warn("[Viewer] jobCount should be at least 1 here!"):this.setSpinnerVisibility(--this.jobCount>0)}resize(e,t){let i=this.camera;if(i&&t>0){if(i instanceof hr)i.aspect=e/t;else if(i instanceof Nr){let n=e/t;i.left=-this.frustumSize/2,i.right=this.frustumSize/2,i.top=this.frustumSize/n/2,i.bottom=-this.frustumSize/n/2}i.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,i,n,r;this.clearPlugins(),null==(e=this.widgetContainer)||e.remove(),this.widgetContainer=void 0,null==(t=this.viewerContainer)||t.remove(),this.viewerContainer=void 0,null==(i=this.container)||i.remove(),this.container=void 0,null==(n=this.scene)||n.clear(),this.scene=void 0,this.requestAnimationFrameHandle&&(cancelAnimationFrame(this.requestAnimationFrameHandle),this.requestAnimationFrameHandle=void 0),this.renderer&&(this.renderer.domElement.remove(),this.renderer.clear(),this.renderer.dispose(),this.renderer.forceContextLoss(),this.renderer=void 0),this.overlayRender&&(this.overlayRender.destroy(),this.overlayRender=void 0),this.camera=void 0,this.controls&&(this.controls.dispose(),this.controls=void 0),this.groundPlane&&(this.groundPlane.geometry.dispose(),this.groundPlane.clear(),this.groundPlane=void 0),this.removeEventListener(),null==(r=this.undoRedoManager)||r.destroy(),this.spinner&&(this.spinner.remove(),this.spinner=void 0)}getInputManager(){return this.inputManager}getViewConfig(){return this.viewerCfg}enableRender(){}getRaycaster(){}getRaycastableObjectsByMouse(e){return[]}getBBox(){}getActiveSection(){}flyTo(e,t){}is3d(){return!0}get measurePlugin(){}getMarkupManager(){}deactivateMeasurement(){}setMeasurementVisibility(e,t){return!1}screenshot(e){return ft(this,null,(function*(){}))}getPixelSizeInWorldCoord(){let e=this.camera,{clientWidth:t,clientHeight:i}=this.viewerContainer,n=1;if("OrthographicCamera"===e.type){let r=e;n=Math.max(r.right-r.left,r.top-r.bottom)/r.zoom/Math.max(t,i)}else if("PerspectiveCamera"===e.type){let t=e,r=new D;e.getWorldPosition(r);let a=new D,s=this.controls;s.getTarget?s.getTarget(a):s.target&&(a=s.target),r&&a&&(n=r.distanceTo(a)*Math.tan(t.fov/2*Math.PI/180)*2/i)}return n}getUniqueModelId(e){let t=e,i=e=>!!this.loadedModels.find((t=>t.modelId===e));if(i(t)){let e=1;for(;i(`${t}_${e}`);)e++;t=`${t}_${e}`,se.warn(`[Viewer] Model '${t}' is loaded more than once!`)}return t}addPlugin(e){this.plugins.find((t=>t.id===e.id))?se.warn(`[Viewer] Plugin already exist: ${e.id}`):(this.plugins.push(e),se.debug(`[Viewer] Added plugin: ${e.id}`))}removePlugin(e){for(let t=0,i=this.plugins.length;t<i;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))}},ky=class{constructor(e){this.active=!1,this.viewer=e,this.boxSelectHelper=new ep(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){let t=an.screen2Ndc(e,this.camera,this.viewerContainer);this.raycaster.layers.set(10),this.raycaster.setFromCamera(t,this.camera);let i=[];"BimViewer"===this.viewer.name?i=this.viewer.getRaycastableObjectsByMouse({x:e.x,y:e.y}):"DxfViewer"===this.viewer.name&&(i=[this.viewer.groundPlane]);let n=this.raycaster.intersectObjects(i)||[];if(n.length>0)return n[0].point}handleZoomToRect(e,t){let i=this.pickPositionByScreenPoint(e),n=this.pickPositionByScreenPoint(t);if(i&&n){let e=new D(Math.min(i.x,n.x),Math.min(i.y,n.y),Math.min(i.z,n.z)),t=new D(Math.max(i.x,n.x),Math.max(i.y,n.y),Math.max(i.z,n.z)),r=new Nt(e,t);this.viewer.zoomToBBox(r)}}destroy(){var e;null==(e=this.boxSelectHelper)||e.destroy(),this.boxSelectHelper=void 0}},CP=class extends Hi{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:i}=this.position;e.save(),e.fillStyle="rgba(137, 137, 138, 0.8)",e.beginPath(),e.arc(t,i,25,0,2*Math.PI),e.closePath(),e.fill(),e.restore()}drawOuterRing(e){let{x:t,y:i}=this.position;e.save(),e.strokeStyle="rgba(17, 17, 19, 0.8)",e.lineWidth=10,e.beginPath(),e.arc(t,i,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,i,35,0,2*Math.PI),e.closePath(),e.stroke(),e.restore()}drawSnapTriangle(e){let{x:t,y:i}=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,i-35),e.lineTo(t-35+12,i-35),e.lineTo(t-35,i-35+12),e.closePath(),e.fill(),e.stroke(),e.restore()}translate(e,t){this.position.add(new xe(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"}},Yl=(e=>(e.Distance="Distance",e.Area="Area",e.Angle="Angle",e.Coordinate="Coordinate",e))(Yl||{}),th=class extends Ss{constructor(e,t,i,n,r){super(),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.controls&&(this.viewer.controls.enabled=!1),this.touchDowned=!0,this.mouseDownPositionX=e.x,this.mouseDownPositionY=e.y)},this.touchmove=e=>{if(e.pointers&&e.pointers.length>1)return;let{width:t,height:i}=this.canvas.getBoundingClientRect();if(!(e.x>t-15||e.x<35||e.y<15||e.y>i-35)&&this.touchDowned&&this.mobileTouchHelper){let t=e.x-this.mouseDownPositionX,i=e.y-this.mouseDownPositionY;this.mobileTouchHelper.translate(t,i),this.mouseDownPositionX=e.x,this.mouseDownPositionY=e.y;let n=this.mobileTouchHelper.getTouchPoint(),r=this.getIntersections(n);if(!r.length)return void this.osnapHelper.deactivate();let a=Date.now();if(this.snapPoint=this.osnapHelper.handleSnap(r,this.viewer.is3d(),this.lastMouseDownPosition),se.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.controls&&(this.viewer.controls.enabled=!0),!(e.pointers&&e.pointers.length>1)){if(this.touchDowned){this.touchDowned=!1;let e=null==(t=this.mobileTouchHelper)?void 0:t.getTouchPoint();this.onMouseClick(e)}else this.selectMeasurementByEvent(e);Fn.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 i=Date.now();this.snapPoint=this.osnapHelper.handleSnap(t,this.viewer.is3d(),this.lastMouseDownPosition),se.debug(`[BaseMeasurement] this.handleSnap costs ${(Date.now()-i)/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=()=>{se.info("[Measure] Double clicked")},this.keydown=e=>{if("Enter"===e.code){let e={x:0,y:0,pageX:0,pageY:0,clientX:0,clientY:0,deltaX:0,deltaY:0,button:2,movementX:0,movementY:0,deltaMode:0,pointerId:0,timestamp:0,buttons:0,pointerType:"mouse",altKey:!1,ctrlKey:!1,shiftKey:!1,metaKey:!1};this.onMouseClick(e)}else"Escape"===e.code&&this.cancel()},this.getIntersections=e=>{if(!this.raycaster)return[];this.raycaster.layers.set(11);let t=this.viewer.getRaycastableObjectsByMouse(e);se.debug(`[BaseMeasurement] The count of raycastable object is ${t.length}`,t);let i=Date.now(),n=this.raycaster.intersectObjects(t,!0)||[];return se.debug(`[BaseMeasurement] this.raycaster.intersectObjects costs ${(Date.now()-i)/1e3}s`),this.renderer.clippingPlanes.length>0&&(n=n.filter((e=>this.renderer.clippingPlanes.every((function(t){return t.distanceToPoint(e.point)>0}))))),n},this.type=e,this.viewer=t,this.inputManager=i,this.drawList=n,this.osnapHelper=r}get canvas(){var e;return null==(e=this.viewer.renderer)?void 0:e.domElement}get camera(){return this.viewer.camera}get renderer(){return this.viewer.renderer}get isActive(){return!!this.raycaster}get isMeasuring(){return!1===this.completed}setTouchHelper(e){this.mobileTouchHelper=e}createMobileExitButton(){let e=this.viewer.widgetContainer,t=document.createElement("button");return t.innerText="X",t.style.cssText="position: absolute;right: 5%; top: 5%;background-color: #000000;color: #ffffff;padding: 3px 10px;font-weight: bolder;",null==e||e.appendChild(t),this.exitButton=t,this.exitButton.style.display="none",t.addEventListener("touchstart",(()=>{this.exitDrawing(),this.exitButton&&(this.exitButton.style.display="none")})),this.addEventListener("FirstPointPicked",this.firstPickedListener=()=>{this.exitButton&&(this.exitButton.style.display="inline-block")}),this.addEventListener("Completed",this.completedListener=()=>{this.exitButton&&(this.exitButton.style.display="none")}),this.exitButton}activate(){if(Fn.isMobile)this.inputManager.addEventListener("touchstart",this.touchstart),this.inputManager.addEventListener("touchmove",this.touchmove),this.inputManager.addEventListener("touchend",this.touchend);else{this.inputManager.addEventListener("pointerdown",this.mousedown),this.inputManager.addEventListener("pointermove",this.mousemove),this.inputManager.addEventListener("pointerup",this.mouseup);let e=this.viewer.translate;if(e){this.tooltip=new Xl("measure-tooltip",e("Tooltip.measure"),{followPointer:!0,showOnCreate:!0,parentNode:this.viewer.widgetContainer,target:this.viewer.viewerContainer});let t=document.getElementById("measure-tooltip");t&&(t.style.pointerEvents="none")}this.setTooltipContent()}this.inputManager.addEventListener("dblclick",this.dblclick),this.inputManager.addEventListener("keydown",this.keydown),this.raycaster=this.viewer.getRaycaster()}deactivate(){var e,t;Fn.isMobile?(this.inputManager.removeEventListener("touchstart",this.touchstart),this.inputManager.removeEventListener("touchmove",this.touchmove),this.inputManager.removeEventListener("touchend",this.touchend)):(this.inputManager.removeEventListener("pointerdown",this.mousedown),this.inputManager.removeEventListener("pointermove",this.mousemove),this.inputManager.removeEventListener("pointerup",this.mouseup)),this.inputManager.removeEventListener("dblclick",this.dblclick),this.inputManager.removeEventListener("keydown",this.keydown),null==(e=this.tooltip)||e.hide(),null==(t=this.tooltip)||t.destroy(),this.tooltip=void 0,this.raycaster=void 0,this.currentMeasureDrawable&&this.removeDrawable(this.currentMeasureDrawable),this.osnapHelper.deactivate(),this.drawingPoints=void 0,this.currentMeasureDrawable=void 0,this.lastMouseDownPosition=void 0}removeDrawable(e){this.dispatchEvent("WillBeRemoved",e)}clearClickedDrawable(){this.clickedOnMeasurementDrawable&&(this.clickedOnMeasurementDrawable.selected=!1,this.clickedOnMeasurementDrawable=void 0)}onMouseClick(e){if(Fn.isMobile)return;let t=Date.now();this.lastClickTime&&t-this.lastClickTime<500||(this.lastClickTime=t,this.selectMeasurementByEvent(e))}selectMeasurementByEvent(e){if(this.clickedOnMeasurementDrawable&&(this.clickedOnMeasurementDrawable.selected=!1,this.clickedOnMeasurementDrawable=void 0),null==this.completed||!0===this.completed){let t=this.getIntersections(e)[0];if(t){let e=this.drawList.getDrawableByPosition(t.point,this.raycaster);e&&(this.dispatchEvent("ClickedOnMeasurement",e),this.clickedOnMeasurementDrawable=e)}}}onMouseMove(e){this.createOrUpdateMeasureDrawable(e)}createOrUpdateMeasureDrawable(e){if(!this.drawingPoints||this.drawingPoints&&this.drawingPoints.length<1)return;let t=[...this.drawingPoints];if(!this.currentMeasureDrawable)return this.currentMeasureDrawable=this.createMeasureDrawable(),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")}},xa=class extends Hi{constructor(e,t){super(e),this.type="Distance",this.labelBounds=new Mi,this.drawing=!1,this.update(t)}setDrawingState(e){this.drawing=e}drawSelect(e,t){let i=this.getVertexes();this.drawPoints(e,t,i)}drawPoints(e,t,i){e.save(),e.fillStyle=xa.MAJOR_COLOR,e.strokeStyle=xa.MINOR_COLOR,e.lineWidth=xa.LINE_WIDTH,e.beginPath(),(this.drawing?i.slice(0,i.length-1):i).forEach((i=>{let n=this.transToScreenCoord(i,t);e.moveTo(n.x+xa.POINT_RADIUS,n.y),e.arc(n.x,n.y,xa.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=`${xa.LABEL_FONT_SIZE}px Arial`;let i=1.2*e.measureText(this.label).width,n=1.5*xa.LABEL_FONT_SIZE;this.labelBounds.setFromCenterAndSize(this.labelPositon,new xe(i,n)),this.drawRoundRect(e,this.labelPositon.x-i/2,this.labelPositon.y-n/2,i,n,4),e.save(),e.fillStyle=xa.MINOR_COLOR,e.textBaseline="middle",e.textAlign="center",e.fillText(this.label,this.labelPositon.x,this.labelPositon.y),e.restore()}drawRoundRect(e,t,i,n,r,a){n<2*a&&(a=n/2),r<2*a&&(a=r/2),e.save(),e.fillStyle=xa.MAJOR_COLOR,e.strokeStyle=xa.MINOR_COLOR,e.lineWidth=xa.LINE_WIDTH,e.beginPath(),e.moveTo(t+a,i),e.arcTo(t+n,i,t+n,i+r,a),e.arcTo(t+n,i+r,t,i+r,a),e.arcTo(t,i+r,t,i,a),e.arcTo(t,i,t+n,i,a),e.closePath(),e.fill(),this.selected&&e.stroke(),e.restore()}getVertexes(){return this.points}update(e){let{min:t,max:i}=(new Nt).setFromPoints(e);return this.x=t.x,this.y=t.y,this.width=Math.abs(i.x-t.x),this.height=Math.abs(i.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(xa.MAJOR_COLOR)),this.setFillColor(An.colorStr2Rgba(xa.AREA_FILL_COLOR)),this.setLineWidth(xa.LINE_WIDTH)}isPointInPath(e,t){let i=null==t?void 0:t.ray;if(!i)return!1;let n=3*this.tolerance,r=this.transToScreenCoord(e,t.camera);if(this.labelBounds.containsPoint(r))return!0;let a=new D,s=new D,o=this.points;for(let l=0;l<o.length-1;l++){let e=o[l],t=o[l+1]||o[0];if(i.distanceSqToSegment(e,t,s,a)<n*n)return!0}return!1}getUnitString(){return"Distance"===this.type?lE("mm"):"Area"===this.type?`${lE("m",2)}`:"Angle"===this.type?"\xb0":""}},Lr=xa;Lr.MAJOR_COLOR="rgba(249, 157, 11, 0.9)",Lr.MINOR_COLOR="rgb(255, 255, 255)",Lr.AREA_FILL_COLOR="rgba(249, 157, 11, 0.3)",Lr.LINE_WIDTH=2,Lr.POINT_RADIUS=5,Lr.LABEL_FONT_SIZE=14;var x_=class extends Lr{constructor(e,t){super(e,t),this.type="Angle",this.update(t)}draw(e,t){e.save(),e.lineWidth=Lr.LINE_WIDTH,e.strokeStyle=Lr.MAJOR_COLOR;let i=this.points;if(e.beginPath(),i.forEach(((i,n)=>{let r=this.transToScreenCoord(i,t);0===n?e.moveTo(r.x,r.y):e.lineTo(r.x,r.y)})),3===this.points.length){let[i,n,r]=this.points.map((e=>this.transToScreenCoord(e,t))),a=(new xe).subVectors(i,n).normalize(),s=(new xe).subVectors(r,n).normalize(),o=Math.min(i.distanceTo(n),r.distanceTo(n)),l=a.angle(),h=s.angle();e.moveTo(n.x,n.y),e.arc(n.x,n.y,o/5,l,h,a.cross(s)<0)}if(e.stroke(),e.restore(),this.drawing){let i=1===this.points.length?this.points:this.points.slice(0,this.points.length-1);this.drawPoints(e,t,i)}this.drawText(e,t)}drawText(e,t){if(this.points.length<3)return;let[i,n,r]=this.points,a=this.getAngleBisector(i,n,r),s=this.calculateAngle(i,n,r);this.label=`${Bu(s,2)} ${this.getUnitString()}`;let o=.3*Math.min(i.distanceTo(n),r.distanceTo(n));this.labelPositon=this.transToScreenCoord(n.clone().add(new D(a.x*o,a.y*o,a.z*o)),t),super.drawText(e,t)}getAngleBisector(e,t,i){let n=e,r=t,a=i,s=new D(n.x-r.x,n.y-r.y,n.z-r.z).normalize(),o=new D(a.x-r.x,a.y-r.y,a.z-r.z).normalize();return new D(s.x+o.x,s.y+o.y,s.z+o.z).normalize()}calculateAngle(e,t,i){let n=e,r=t,a=i,s=new D(n.x-r.x,n.y-r.y,n.z-r.z),o=new D(a.x-r.x,a.y-r.y,a.z-r.z);return 180*s.angleTo(o)/Math.PI}getClassType(){return"Angle"}};Un._registerDrawableClass(x_);var PP=class extends th{constructor(e,t,i,n){super("Angle",e,t,i,n)}createMeasureDrawable(){if(this.drawingPoints)return new x_(St.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 i=this.getIntersections(e)[0];if(!i)return;let n=null!=(t=this.snapPoint)?t:null==i?void 0:i.point;if(this.drawingPoints[0]&&Zt.areVector3sEqual(this.drawingPoints[0],n))return;let r=this.drawingPoints;r.push(n),this.lastMouseDownPosition=n,1===r.length&&(this.dispatchEvent("FirstPointPicked"),this.completed=!1),this.createOrUpdateMeasureDrawable(),r.length>=3&&this.complete()}exitDrawing(){this.drawingPoints=void 0,this.currentMeasureDrawable&&(this.removeDrawable(this.currentMeasureDrawable),this.currentMeasureDrawable=void 0),this.completed=void 0,this.lastMouseDownPosition=void 0}complete(){var e;!0!==this.completed&&(null==(e=this.currentMeasureDrawable)||e.setDrawingState(!1),this.dispatchEvent("Completed",this.currentMeasureDrawable),this.completed=!0,this.currentMeasureDrawable=void 0,this.drawingPoints=void 0,this.lastMouseDownPosition=void 0)}cancel(){let e=this.drawingPoints;if(e&&e.length>0&&(e.pop(),0===e.length&&(this.currentMeasureDrawable&&(this.removeDrawable(this.currentMeasureDrawable),this.currentMeasureDrawable=void 0),this.completed=!0),this.lastMoveEvent)){let e=this.getIntersections(this.lastMoveEvent)[0];e&&this.onMouseMove(e.point)}this.osnapHelper.deactivate(),this.lastMouseDownPosition=void 0}deactivate(){super.deactivate(),this.currentMeasureDrawable&&this.removeDrawable(this.currentMeasureDrawable)}setTooltipContent(){var e;let t=this.viewer.translate;if(!t)return;let i=t("Tooltip.measure");i&&this.tooltip&&(null==(e=this.tooltip)||e.setContent(i))}},rp=class extends Lr{constructor(e,t,i){super(e,t),this.type="Area",this.scale=i,this.update(t)}draw(e,t){let i=this.points;if(e.save(),e.lineWidth=Lr.LINE_WIDTH,e.strokeStyle=Lr.MAJOR_COLOR,e.fillStyle=Lr.AREA_FILL_COLOR,e.beginPath(),i.forEach(((i,n)=>{let r=this.transToScreenCoord(i,t);0===n?e.moveTo(r.x,r.y):e.lineTo(r.x,r.y)})),e.closePath(),e.fill(),e.stroke(),e.restore(),this.drawing){let i=1===this.points.length?this.points:this.points.slice(0,this.points.length-1);this.drawPoints(e,t,i)}this.drawText(e,t)}drawText(e,t){if(this.points.length<3)return;let i=this.points,n=this.calculateArea(i);this.scale&&(n*=Math.pow(this.scale,2)),this.label=`${Bu(n,2)}`,this.labelPositon=this.transToScreenCoord(this.getBarycenter(i),t),super.drawText(e,t)}calculateArea(e){let t=0,i=Um.getFaces(e);for(let n=0;n<i.length/3;n++){let r=e[i[3*n]],a=e[i[3*n+1]],s=e[i[3*n+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,i=0,n=0,r=0;return e.forEach((e=>{i+=e.x,n+=e.y,r+=e.z})),new D(i/t,n/t,r/t)}isPointInPath(e,t){let i=null==t?void 0:t.ray;if(!i)return!1;let n=this.transToScreenCoord(e,t.camera);if(this.labelBounds.containsPoint(n))return!0;let r=3*this.tolerance,a=new D,s=new D,o=this.points;for(let h=0;h<o.length;h++){let e=o[h],t=o[h+1]||o[0];if(i.distanceSqToSegment(e,t,s,a)<r*r)return!0}let l=Um.getFaces(this.points);for(let h=0;h<l.length/3;h++){let t=this.points[l[3*h]],n=this.points[l[3*h+1]],r=this.points[l[3*h+2]];if(i.intersectTriangle(t,n,r,!1,e))return!0}return!1}getClassType(){return"Area"}};Un._registerDrawableClass(rp);var tve=new D,IP=class extends th{constructor(e,t,i,n){super("Area",e,t,i,n)}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 rp(St.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];tve.subVectors(e,t).length()<3*this.viewer.getPixelSizeInWorldCoord()&&(this.osnapHelper.activateMarker(1,{point:t,type:1,distance:0}),se.info("[AreaMeasurement] auto close area measurement."))}}onMouseClick(e){var t,i;if(super.onMouseClick(e),this.clickedOnMeasurementDrawable)return;this.drawingPoints||(this.drawingPoints=[]);let n=this.drawingPoints;if(2===e.button)return void this.exitDrawing();let r=this.getIntersections(e)[0];if(!r)return void se.warn("[Measure] No intersection found!");let a=null!=(i=null==(t=this.snapPoint)?void 0:t.clone())?i:null==r?void 0:r.point.clone();if(this.drawingPoints&&this.drawingPoints.length>2&&this.drawingPoints[0]){let e=this.drawingPoints[0];if(tve.subVectors(a,e).length()<3*this.viewer.getPixelSizeInWorldCoord())return se.info("[AreaMeasurement] auto close area measurement."),this.touchDowned=!1,void this.exitDrawing()}this.drawingPoints[0]&&Zt.areVector3sEqual(this.drawingPoints[0],a)||(n.push(a),this.lastMouseDownPosition=a,1===n.length&&(this.dispatchEvent("FirstPointPicked"),this.completed=!1),this.createOrUpdateMeasureDrawable())}exitDrawing(){let e=this.drawingPoints||[],t=!0;if(e.length<3&&(se.warn("[Measure] If the number of points is less than 3, the measurement area cannot be formed !"),t=!1),t&&Um.isSelfIntersecting(e)&&(se.warn("[Measure] The area formed by these points intersects itself, so the correct measurement cannot be obtained !"),t=!1),!t)return this.drawingPoints=void 0,this.currentMeasureDrawable&&(this.removeDrawable(this.currentMeasureDrawable),this.currentMeasureDrawable=void 0),this.completed=void 0,void(this.lastMouseDownPosition=void 0);this.createOrUpdateMeasureDrawable(),this.complete()}complete(){var e;!0!==this.completed&&(null==(e=this.currentMeasureDrawable)||e.setDrawingState(!1),this.dispatchEvent("Completed",this.currentMeasureDrawable),this.completed=!0,this.drawingPoints=void 0,this.currentMeasureDrawable=void 0,this.lastMouseDownPosition=void 0)}cancel(){let e=this.drawingPoints;if(e&&e.length>0&&(e.pop(),0===e.length&&(this.currentMeasureDrawable&&(this.removeDrawable(this.currentMeasureDrawable),this.currentMeasureDrawable=void 0),this.completed=!0),this.lastMoveEvent)){let e=this.getIntersections(this.lastMoveEvent)[0];e&&this.onMouseMove(e.point)}this.osnapHelper.deactivate(),this.lastMouseDownPosition=void 0}setTooltipContent(){var e;let t=this.viewer.translate;if(t){let i=t("Tooltip.areaMeasurement");i&&this.tooltip&&(null==(e=this.tooltip)||e.setContent(i))}}getScale(){return this.scale}setScale(e){this.scale=e;let t=this.drawList.getDrawables();for(let i of t){let t=i[1];t instanceof rp&&(t.scale=e)}}},b_=class extends Lr{constructor(e,t){super(e,t),this.type="Coordinate",this.update(t)}draw(e,t){this.drawText(e,t),e.save(),e.lineWidth=Lr.LINE_WIDTH,e.strokeStyle=Lr.MAJOR_COLOR,e.fillStyle=Lr.AREA_FILL_COLOR;let i=this.points;e.beginPath(),i.forEach((i=>{let n=this.transToScreenCoord(i,t);e.arc(n.x,n.y,Lr.POINT_RADIUS,0,2*Math.PI)})),e.fill(),e.stroke(),e.restore()}drawText(e,t){let i=this.points[0];Zt.areNumbersEqual(i.x,0);let n=Zt.areNumbersEqual(i.x,0)?0:i.x,r=Zt.areNumbersEqual(i.y,0)?0:i.y,a=Zt.areNumbersEqual(i.z,0)?0:i.z;this.label=`${Bu(n,2)}, ${Bu(r,2)}, ${Bu(a,2)}`,e.font=`${Lr.LABEL_FONT_SIZE}px Arial`;let s=1.2*e.measureText(this.label).width,o=1.5*Lr.LABEL_FONT_SIZE;this.labelPositon=this.transToScreenCoord(i,t),this.labelPositon.y-=o/2,this.labelBounds.setFromCenterAndSize(this.labelPositon,new xe(s,o)),this.drawRoundRect(e,this.labelPositon.x-s/2,this.labelPositon.y-o/2,s,o,4),e.save(),e.fillStyle=Lr.MINOR_COLOR,e.textBaseline="middle",e.textAlign="center",e.fillText(this.label,this.labelPositon.x,this.labelPositon.y),e.restore()}getClassType(){return"Coordinate"}};Un._registerDrawableClass(b_);var LP=class extends th{constructor(e,t,i,n){super("Coordinate",e,t,i,n)}createMeasureDrawable(){if(this.drawingPoints)return new b_(St.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 i=this.getIntersections(e)[0];if(!i)return;let n=null!=(t=this.snapPoint)?t:null==i?void 0:i.point,r=this.drawingPoints;r.push(n),this.lastMouseDownPosition=n,1===r.length&&(this.dispatchEvent("FirstPointPicked"),this.completed=!1),this.createOrUpdateMeasureDrawable(n),r.length>=1&&this.complete()}exitDrawing(){this.drawingPoints=void 0,this.currentMeasureDrawable&&(this.removeDrawable(this.currentMeasureDrawable),this.currentMeasureDrawable=void 0),this.completed=void 0,this.lastMouseDownPosition=void 0}complete(){!0!==this.completed&&(this.dispatchEvent("Completed",this.currentMeasureDrawable),this.completed=!0,this.drawingPoints=void 0,this.currentMeasureDrawable=void 0,this.lastMouseDownPosition=void 0)}cancel(){let e=this.drawingPoints;if(e&&e.length>0&&(e.pop(),0===e.length&&(this.completed=!0),this.lastMoveEvent)){let e=this.getIntersections(this.lastMoveEvent)[0];e&&this.onMouseMove(e.point)}this.osnapHelper.deactivate(),this.drawingPoints=void 0,this.currentMeasureDrawable=void 0,this.lastMouseDownPosition=void 0}setTooltipContent(){var e;let t=this.viewer.translate;if(t){let i=t("Tooltip.measure");i&&this.tooltip&&(null==(e=this.tooltip)||e.setContent(i))}}},R4=class extends Lr{constructor(e,t,i){super(e,t),this.type="Distance",this.scale=i,this.update(t)}draw(e,t){let i=this.points;if(e.save(),e.lineWidth=Lr.LINE_WIDTH,e.strokeStyle=Lr.MAJOR_COLOR,e.beginPath(),i.forEach(((i,n)=>{let r=this.transToScreenCoord(i,t);0===n?e.moveTo(r.x,r.y):e.lineTo(r.x,r.y)})),e.closePath(),e.stroke(),e.restore(),this.drawing){let i=1===this.points.length?this.points:this.points.slice(0,this.points.length-1);this.drawPoints(e,t,i)}else this.selected||this.drawVerticalLine(e,t);this.drawText(e,t)}drawText(e,t){if(this.points.length<2)return;let[i,n]=this.points,r=i.distanceTo(n);this.scale&&(r*=this.scale),this.label=`${Bu(r,2)}`,this.labelPositon=this.transToScreenCoord((new D).lerpVectors(i,n,.5),t),super.drawText(e,t)}drawVerticalLine(e,t){if(this.points.length<2)return;let[i,n]=this.points.map((e=>this.transToScreenCoord(e,t))),[r,a]=this.getShortLineBySegments(i,n),[s,o]=this.getShortLineBySegments(n,i);e.save(),e.lineWidth=Lr.LINE_WIDTH,e.strokeStyle=Lr.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 i=(new xe).subVectors(t,e).normalize(),n=R4.SHORT_LINE_LENGTH/2,r=Math.PI/2;return[i.clone().rotateAround(new xe,r).normalize().multiplyScalar(n).add(e),i.clone().rotateAround(new xe,-r).normalize().multiplyScalar(n).add(e)]}getClassType(){return"Distance"}setScale(e){this.scale=e}},og=R4;og.SHORT_LINE_LENGTH=12,Un._registerDrawableClass(og);var DP=class extends th{constructor(e,t,i,n){super("Distance",e,t,i,n)}createMeasureDrawable(){if(this.drawingPoints)return new og(St.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 i=this.getIntersections(e)[0];if(!i)return;let n=null!=(t=this.snapPoint)?t:null==i?void 0:i.point;if(this.drawingPoints[0]&&Zt.areVector3sEqual(this.drawingPoints[0],n))return;let r=this.drawingPoints;r.length<2&&r.push(n),this.lastMouseDownPosition=n,1===r.length&&(this.dispatchEvent("FirstPointPicked"),this.completed=!1),this.createOrUpdateMeasureDrawable(),r.length>=2&&this.complete()}exitDrawing(){this.drawingPoints=void 0,this.currentMeasureDrawable&&(this.removeDrawable(this.currentMeasureDrawable),this.currentMeasureDrawable=void 0),this.completed=void 0,this.lastMouseDownPosition=void 0}complete(){var e;!0!==this.completed&&(null==(e=this.currentMeasureDrawable)||e.setDrawingState(!1),this.dispatchEvent("Completed",this.currentMeasureDrawable),this.completed=!0,this.drawingPoints=void 0,this.currentMeasureDrawable=void 0,this.lastMouseDownPosition=void 0)}cancel(){let e=this.drawingPoints;e&&e.length>0&&(e.pop(),0===e.length&&(this.completed=!0),this.currentMeasureDrawable&&this.removeDrawable(this.currentMeasureDrawable)),this.osnapHelper.deactivate(),this.drawingPoints=void 0,this.currentMeasureDrawable=void 0,this.lastMouseDownPosition=void 0}deactivate(){super.deactivate(),this.currentMeasureDrawable&&this.removeDrawable(this.currentMeasureDrawable)}setTooltipContent(){var e;let t=this.viewer.translate;if(t){let i=t("Tooltip.measure");i&&this.tooltip&&(null==(e=this.tooltip)||e.setContent(i))}}getScale(){return this.scale}setScale(e){this.scale=e;let t=this.drawList.getDrawables();for(let i of t){let t=i[1];(t instanceof og||t instanceof rp)&&(t.scale=e)}}},A4=class extends or{constructor(e){var t,i;super(e,{id:A4.DEFAULT_ID}),this.selectedDrawable=void 0,this.drawableList=new Zo("measure"),this.drawableHelperList=new Zo("touchHelper"),this.snapToleranceInPixel=3,this.measurements={},this.activeMeasurementType=void 0,this.keydown=e=>{var t;let i,n=this.getActiveMeasurementType();n&&(i=this.measurements[n]);let r=this.selectedDrawable;r&&"Delete"===e.code&&(this.remove(r),null==(t=this.viewer.undoRedoManager)||t.addCommand(new sy(this,r.getData())),this.activeMeasurementType&&this.measurements[this.activeMeasurementType].clearClickedDrawable()),e.ctrlKey&&"KeyZ"===e.code&&null!=i&&i.isMeasuring&&i.cancel(),e.ctrlKey&&"KeyY"===e.code&&null!=i&&i.isMeasuring};let n=e.getInputManager();if(!n)throw"InputManager init error";this.inputManager=n,this.overlayRender=this.viewer.overlayRender,null==(t=this.overlayRender)||t.addDrawableList(this.drawableHelperList),null==(i=this.overlayRender)||i.addDrawableList(this.drawableList);let r=new MP(this.overlayRender);e.is3d()&&(r.setOSnapTypeEnabled(32,!1),r.setOSnapTypeEnabled(64,!1)),this.measurements.Distance=new DP(e,n,this.drawableList,r),this.measurements.Area=new IP(e,n,this.drawableList,r),this.measurements.Angle=new PP(e,n,this.drawableList,r),this.measurements.Coordinate=new LP(e,n,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 pE(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 Un.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,se.error("[Measure] Failed to activate measurement, type:",e));let{width:t,height:i}=this.canvas.getBoundingClientRect();Fn.isMobile&&this.canvas&&!this.mobileTouchHelper&&(this.mobileTouchHelper=new CP(new xe(t/2,i/2)),this.drawableHelperList.addDrawable(this.mobileTouchHelper)),this.mobileTouchHelper&&(this.mobileTouchHelper.setPosition(new xe(t/2,i/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,i;null==(t=this.viewer.undoRedoManager)||t.startTransaction(),e.forEach((e=>{var t;this.measurements[e.type]?e.points.length>=2?(this.add(Un.createDrawable(e)),null==(t=this.viewer.undoRedoManager)||t.addCommand(new pE(this,e))):se.info("[Measure] Invalid points found in MeasurementData:",e):se.warn("[Measure] Failed to add measurement data for",e)})),null==(i=this.viewer.undoRedoManager)||i.endTransaction()}setVisibilityById(e,t){let i=this.drawableList.getDrawables().get(e);return!!i&&(i.visible!==t&&(i.visible=t,this.render()),!0)}setVisibilities(e){let t=!1;this.drawableList.getDrawables().forEach((i=>{i.visible!==e&&(i.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):se.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 se.error("[Measure] Invalid scale value:",e);let t=this.measurements.Distance,i=this.measurements.Area;t.setScale(e),i.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()}},lg=A4;lg.DEFAULT_ID="MeasurementPlugin";var Fy=new et,nve=new et,rve=new ma,C4=new D,Ny=new Nt,ive=new ct,ip=class extends tp{constructor(e){super(e),this.name="DxfViewer",this.CAMERA_Z_POSITION=100,this.CAMERA_MIN_ZOOM=1e-6,this.timer=Date.now(),this.loadedModels=[],this.masterModelId="",this.raycaster=new na,this.selected=!0,this.raf=new $f,this.clock=new ho,this.renderEnabled=!1,this.enableHideVisuallySmallObjects=!0,this.sortedHidableObjects={},this.lastCameraZoom=1/0,this.lastFrame=-1,this.activeLayoutName="",this.layoutInfos={},this.units=void 0,this.fpsUtils=new OA,this.onResize=()=>{this.viewerContainer&&this.viewerContainer&&this.resize(this.viewerContainer.clientWidth,this.viewerContainer.clientHeight)},this.enableRender=(e=1e3)=>{this.renderEnabled=!0,this.raf&&(this.timeoutSymbol&&this.raf.clearTimeout(this.timeoutSymbol),this.timeoutSymbol=this.raf.setTimeout((()=>{this.renderEnabled=!1}),e))},this.loadingDxfCount=0,this.compareMode=!1,this.viewerCfg=e,this.increaseJobCount(),this.init(),this.animate(),this.enableRender(),this.decreaseJobCount(),se.info(`[Viewer] Initialized in ${(Date.now()-this.timer)/1e3}s`)}init(){let e=this.viewerCfg;this.initThree(),Fn.isBrowser&&!e.context&&this.initDom(),this.initInputManager(),this.initEvents(),this.initControls(),this.initOthers(),this.enableSelection=e.enableSelection}initInputManager(){this.viewerContainer&&(this.inputManager=new Ko(this.viewerContainer))}initThree(){this.initScene(),this.initRenderer(),this.initCamera()}initDom(){let e=this.viewerCfg;this.initSpinner(),this.initCSS2DRenderer(),!0===e.enableAxisGizmo&&console.warn("[Viewer] enableAxisGizmo is deprecated, use AxisGizmoPlugin instead!"),!0===e.enableStats&&console.warn("[Viewer] enableStats is deprecated, use StatsPlugin instead!"),e.enableToolbar&&console.warn("[Viewer] enableToolbar is deprecated, use ToolbarPlugin instead!"),e.enableBottomBar&&console.warn("[Viewer] enableBottomBar is deprecated, use BottomBarPlugin instead!"),e.enableProgressBar&&(this.loadingProgressBar=this.initLoadingProgressBar()),e.enableLayoutBar&&(this.dxfLayoutBar=new rP(this))}initScene(){let e=new Si;e.background=new ct(2172976),e.matrixAutoUpdate=!1,e.matrixWorldAutoUpdate=!1,this.scene=e}initRenderer(){var e;let{context:t}=this.viewerCfg,i={context:t,antialias:!0,preserveDrawingBuffer:!0,alpha:!1,stencil:!1};!Fn.isBrowser&&t&&Object.assign(i,{context:t,canvas:Fn.creatReactNativeCanvas(t)}),t&&(this.width=t.drawingBufferWidth,this.height=t.drawingBufferHeight),this.renderer=new Ts(i),this.renderer.setClearColor(11119017,1),this.renderer.localClippingEnabled=!0,Fn.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),St.printGpuInfo(this.renderer.getContext()),gn.maxFragmentUniforms=this.renderer.capabilities.maxFragmentUniforms-20,this.enableOverlayRenderer&&(this.overlayRender=new Un(this))}initCSS2DRenderer(){var e;let t=new Nu;t.setSize(this.width,this.height),t.domElement.style.height="0",t.domElement.style.width="0",t.domElement.style.position="absolute",t.domElement.style.top="0",t.domElement.style.left="0",t.domElement.style.overflow="visible",t.domElement.classList.add("css2d-renderer"),null==(e=this.viewerContainer)||e.appendChild(t.domElement),this.css2dRenderer=t}initCamera(){if(!this.scene)return;let e=new Nr(-this.width/2,this.width/2,this.height/2,-this.height/2,.1,1e5);e.position.set(0,0,this.CAMERA_Z_POSITION),e.zoom=10,e.updateProjectionMatrix(),this.scene.add(e),this.camera=e,this.frustumSize=this.width}initControls(){let e=this.camera;if(!this.inputManager||!e)return;let t=new va(e,this.inputManager);t.enableRotate=!1,t.enabled=!0,t.keyTruckSpeed=10,t.dollyToCursor=!0,t.dollySpeed=.5,t.truckSpeed=1,t.mouseButtons={left:yt.TRUCK,middle:yt.TRUCK,wheel:yt.ZOOM,right:yt.TRUCK},t.touches={one:yt.TOUCH_TRUCK,two:yt.TOUCH_ZOOM_TRUCK,three:yt.NONE},t.listenToKeyEvents(),t.update(0),this.controls=t,t.addEventListener("control",this.onControlsChange(this))}onControlsChange(e){return()=>{this.updateHidableObjectsVisibility(),e.enableRender()}}initEvents(){if(!this.inputManager||!this.renderer)return;let e=!1,t=!1;this.inputManager.addEventListener("pointerdown",(i=>{var n;t=!1,e=!0,1===i.button&&(null==(n=this.inputManager)||n.setCursor("move"))})),this.inputManager.addEventListener("pointermove",(()=>{var i;e&&(t=!0,null==(i=this.inputManager)||i.setCursor("move"))})),this.inputManager.addEventListener("pointerup",(i=>{var n;if(e=!1,null==(n=this.inputManager)||n.setCursor("default"),t)return void(t=!1);this.handleMouseClick(i);let r={evt:i};if(this.selectedObject&&this.selectedObject instanceof Ai&&(r.markupData=this.selectedObject.getData()),this.selectedObject&&this.selectedObject instanceof Lr&&(r.measureData=this.selectedObject.getData()),this.selectedObject&&this.selectedObject instanceof on){let e=t=>t.parent&&!t.parent.isScene?e(t.parent):t.name;r.entityData={modelId:e(this.selectedObject),layerName:this.selectedObject.userData.layerName}}this.dispatchEvent("MouseClicked",r)})),this.inputManager.addEventListener("keydown",(e=>{var t,i,n,r,a;if(e.altKey&&"KeyR"===e.code)this.flyToRandomObject();else if(e.ctrlKey&&"KeyZ"===e.code){if(this.measurePlugin&&this.measurePlugin.isMeasuring())return;null==(t=this.undoRedoManager)||t.undo()}else if(e.ctrlKey&&"KeyY"===e.code){if(this.measurePlugin&&this.measurePlugin.isMeasuring())return;null==(i=this.undoRedoManager)||i.redo()}else"Delete"===e.code&&this.selectedObject&&(this.markupManager&&this.selectedObject instanceof Ai&&(this.markupManager.removeMarkup(this.selectedObject),null==(n=this.undoRedoManager)||n.addCommand(new Wm(this.markupManager,this.selectedObject.getData()))),this.measurePlugin&&this.selectedObject instanceof Lr&&(null==(r=this.measurePlugin)||r.remove(this.selectedObject),null==(a=this.undoRedoManager)||a.addCommand(new sy(this.measurePlugin,this.selectedObject.getData()))))}))}initOthers(){!this.scene||!this.renderer||!this.camera||(this.renderer.domElement.style.outlineWidth="0")}initLoadingProgressBar(){return new Yf(this.widgetContainer)}showLayoutBar(){var e;null==(e=this.dxfLayoutBar)||e.show()}hideLayoutBar(){var e;null==(e=this.dxfLayoutBar)||e.hide()}animate(){var e,t,i;if(this.minFrameInterval>0&&Date.now()-this.lastFrameExecuteTime<this.minFrameInterval)return void(this.requestAnimationFrameHandle=requestAnimationFrame(this.animate.bind(this)));let n=this.clock.getDelta(),r=null==(e=this.controls)?void 0:e.update(n);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(this.updateRaycasterThreshold(),this.updateCameraZoomUniform(this.camera.zoom),gn.resolutionUniform.value.set(this.width,this.height),null==(t=this.renderer)||t.render(this.scene,this.camera),!Fn.isBrowser){let e=null==(i=this.renderer)?void 0:i.getContext();e&&e.endFrameEXP&&(e.flush(),e.endFrameEXP())}this.dispatchEvent("AfterRender")}}this.fpsUtils.update(),this.requestAnimationFrameHandle=requestAnimationFrame(this.animate.bind(this)),this.lastFrameExecuteTime=Date.now(),this.dispatchEvent("OnAnimate")}getFps(){return this.fpsUtils.fps}is3d(){return!1}destroy(){var e,t,i,n,r;gn.abortJobs=!0,this.dxfLayoutBar&&(this.dxfLayoutBar.destroy(),this.dxfLayoutBar=void 0),null==(e=this.markupManager)||e.destroy(),this.markupManager=void 0,null==(t=this.zoomToRectHelper)||t.destroy(),this.zoomToRectHelper=void 0,this.sortedHidableObjects={},this.layoutInfos={},this.raycastableObjects=void 0,this.changes={},this.loadedModels=[],this.css2dRenderer&&(null==(i=this.viewerContainer)||i.removeChild(this.css2dRenderer.domElement),this.css2dRenderer=void 0),this.raycaster=void 0,this.selectedObject=void 0,this.raf&&(this.timeoutSymbol&&this.raf.clearTimeout(this.timeoutSymbol),this.raf=void 0),null==(n=this.fontManager)||n.destroy(),this.fontManager=void 0,null==(r=this.inputManager)||r.removeEventListener(),super.destroy()}loadModelAsync(e,t){return ft(this,null,(function*(){var i,n;this.loadingDxfCount++,this.timer=Date.now(),this.increaseJobCount();let r=e.modelId||e.src;this.masterModelId||(this.masterModelId=r);let a=e.ignorePaperSpace||this.masterModelId!==r;!1===e.ignorePaperSpace&&a&&se.warn(`[Viewer] Paper space will be ignored for '${r}' although 'ignorePaperSpace' is false!`),St.printMemory("Before loadModelAsync");let s=new ja(this.loadingManager);s.setFont(this.fontManager);let o=r,l=this.translate("ProgressBar.Loading"),h=e=>{var i;null==(i=this.loadingProgressBar)||i.updateProgress(o,l,e),t&&t(new ProgressEvent("LoadProgress",{loaded:e,total:100}))},c=(e,i,n)=>{var r;let a=100*e.loaded/e.total;a=a*(n-i)/100+i,null==(r=this.loadingProgressBar)||r.updateProgress(o,l,a),t&&t(new ProgressEvent("LoadProgress",{loaded:a,total:100}))};null==(i=this.loadingProgressBar)||i.addProgressItem(o),h(0);let u={ignorePaperSpace:a,enableLocalCache:this.viewerCfg.enableLocalCache,enableMerge:e.merge,encoding:e.encoding,overrideColor:e.overrideColor},d=yield s.loadDxfData(e.src,e.modelId,(e=>c(e,0,90)),void 0,u).finally((()=>{this.loadingDxfCount--,0===this.loadingDxfCount&&this.fontManager&&this.fontManager.releaseFontData()}));if(se.info(`[Viewer] Loaded '${e.src}' in ${(Date.now()-this.timer)/1e3}s, adding to scene...`),gn.abortJobs&&Promise.reject("[Viewer] abort load dxf"),0===d.threejsObject.children.length){let t=`[Viewer] Nothing was loaded from ${e.src}`;return se.warn(t),this.decreaseJobCount(),Promise.reject(t)}let p=d.threejsObject;p.name=r;let f=this.getDxfUnits(d);if(this.masterModelId===e.modelId&&(this.units=f),se.info(`[Viewer] Units of '${e.src}' is '${f}'`),e.matrix&&16===e.matrix.length){let t=new et;t.elements=e.matrix,p.applyMatrix4(t)}return this.addModel({modelId:r,dxfData:d}),St.printMemory("After addModel()"),se.info(`[Viewer] Added '${e.src}' to scene in ${(Date.now()-this.timer)/1e3}s`),this.decreaseJobCount(),h(100),null==(n=this.loadingProgressBar)||n.delayRemoveProgressItem(o),this.dispatchEvent("ModelLoaded"),Promise.resolve()}))}unloadDxf(){throw new Error("Not implemented yet!")}addModel(e){if(!this.scene||!this.camera)return;let{dxfData:t,pdfData:i}=e,n=this.getUniqueModelId(e.modelId);if(this.masterModelId||(this.masterModelId=n),t){let e=t.threejsObject;e.name=n;let i={modelId:n,dxfData:t};this.loadedModels.push(i),e.matrixAutoUpdate=!1,e.updateMatrix(),e.updateMatrixWorld(!0),gn.computeLineDistances(e),this.getMsTransformMatrix(n),this.masterModelId===n?this.activateLayout(gn.MODEL_LAYOUT_NAME):this.handleOverlayDxf(n),se.debug("[Viewer] dxfData:",t),this.scene.add(e);let r=null==t?void 0:t.threejsObject.children.find((e=>e.name===gn.MODEL_LAYOUT_NAME));r&&this.setLayoutHidableObjectArray(r),this.updateGroundPlane(),this.raycastableObjects=void 0,this.masterModelId===n||this.enableRender()}else if(i){let t=i.threejsObject;this.activeLayoutName=gn.MODEL_LAYOUT_NAME;let n=(new Nt).setFromObject(t);this.layoutInfos[this.activeLayoutName]={homeViewExtent:n,extent:n},this.loadedModels.push(e),t.matrixAutoUpdate=!1,this.scene.add(t);let r=n.max.z;r>this.camera.position.z&&(this.camera.position.z=r,this.camera.updateProjectionMatrix()),this.updateGroundPlane(),this.flyToObject(t)}}isCompareMode(){return this.compareMode}compare(e,t,i,n){return ft(this,null,(function*(){var r,a,s,o;let{src:l,modelId:h}=e,{src:c}=t;if(this.compareMode)return Promise.reject("[Viewer] It is already under comparing mode!");if(this.masterModelId||this.loadedModels.length>0)return Promise.reject("[Viewer] Shouldn't load anything else before compare!");if(this.compareMode=!0,this.timer=Date.now(),this.increaseJobCount(),!this.fontManager)return Promise.reject("[Viewer] Should set font first!");let u={ignorePaperSpace:!0,encoding:e.encoding},d=new gn(this.loadingManager,u);d.setFont(this.fontManager);let p=l+c,f=this.translate("ProgressBar.Comparing"),m=e=>{var t;null==(t=this.loadingProgressBar)||t.updateProgress(p,f,e),n&&n(new ProgressEvent("CompareProgress",{loaded:e,total:100}))},g=(e,t,i)=>{var r;let a=100*e.loaded/e.total;a=a*(i-t)/100+t,null==(r=this.loadingProgressBar)||r.updateProgress(p,f,a),n&&n(new ProgressEvent("CompareProgress",{loaded:a,total:100}))};St.printMemory("Before comparing"),this.masterModelId=h||l,this.loadingDxfCount+=2,null==(r=this.loadingProgressBar)||r.addProgressItem(p),m(0);let v=Date.now(),y=yield d.parse(l,(e=>g(e,0,15))),x=yield d.parse(c,(e=>g(e,15,30))),[b,_]=yield Promise.allSettled([y,x]);if("rejected"===b.status)return Promise.reject(`[Viewer] Failed to parse ${l}`);if("rejected"===_.status)return Promise.reject(`[Viewer] Failed to parse ${c}`);if(se.info(`[Viewer] loadFiles in ${(Date.now()-v)/1e3}s`),gn.abortJobs)return Promise.reject("[Viewer] compare loadFile aborted");let w=b.value,S=_.value;v=Date.now();let M=yield new ls(w,S,i).compare((e=>g(e,30,60)));if(se.info(`[Viewer] Compared in ${(Date.now()-v)/1e3}s`),se.debug("[Viewer] Compared results:",M),gn.abortJobs)return Promise.reject("[Viewer] compare change aborted");St.printMemory("After getting the comparison results"),v=Date.now(),yield d.loadEntitiesForCompare(w,S,M,!0,(e=>g(e,60,95))),St.printMemory("After Creating threejs objects based on comparison result"),this.fontManager.releaseFontData(),this.changes=M,se.info(`[Viewer] Creates threejs objects based on comparison result in ${(Date.now()-v)/1e3}s`);let E=w,T=S;if(this.loadingDxfCount-=2,this.decreaseJobCount(),Object.keys(M).length||se.info("[Viewer] No change found"),0===(null==(a=E.threejsObject)?void 0:a.children.length)&&0===(null==(s=T.threejsObject)?void 0:s.children.length)){let e=`[Viewer] Nothing was loaded from ${l} and ${c}`;return se.warn(e),Promise.reject(e)}let A=E.threejsObject,C=T.threejsObject;return A.name=l,C.name=c,v=Date.now(),this.addModel({modelId:e.modelId||e.src,dxfData:E}),St.printMemory("After adding first loaded Model to scene"),m(95),this.addModel({modelId:t.modelId||t.src,dxfData:T}),St.printMemory("After adding second loaded Model to scene"),se.info(`[Viewer] Added compared objects to scene in ${(Date.now()-v)/1e3}s`),se.info(`[Viewer] The comparison between ${l}' and '${c}' is completed in ${(Date.now()-this.timer)/1e3}s !`),m(100),null==(o=this.loadingProgressBar)||o.delayRemoveProgressItem(p),Promise.resolve()}))}getEntitiesCount(){let e=0;return this.loadedModels.forEach((t=>{var i,n;e+=(null==(i=t.dxfData)?void 0:i.loadedEntityCount)||(null==(n=t.pdfData)?void 0:n.loadedEntityCount)||0})),e}getLoadedDxfModelIds(){return this.loadedModels.map((e=>e.modelId))}getLayoutNames(){let e=[];return this.getLayouts().forEach((t=>{e.push(t.layoutName)})),e}getLayouts(){let e=[],t=this.loadedModels.find((e=>this.masterModelId===e.modelId));if(t){let i=t.dxfData,n=null==i?void 0:i.objects.LAYOUT;null==n||n.forEach((t=>{e.push(t)}))}return e}handleOverlayDxf(e){var t;let i=this.loadedModels.find((t=>e===t.modelId));if(!i)return void se.warn(`[Viewer] Can't find model for modelId '${e}'!`);this.increaseJobCount(),this.switchTransformMs(gn.MODEL_LAYOUT_NAME,e);let n=null==(t=i.dxfData)?void 0:t.threejsObject,r=null==n?void 0:n.children.find((e=>e.name===gn.MODEL_LAYOUT_NAME));r&&r.traverse((e=>{this.addSpatialFilterSection(e,i.dxfData)})),this.showLayoutObjects(this.activeLayoutName),this.decreaseJobCount()}activateLayout(e){var t,i,n,r;if(this.increaseJobCount(),0==e.length)return se.warn("[Viewer] layout name is empty !"),void this.decreaseJobCount();if(e===this.activeLayoutName)return void this.decreaseJobCount();let a=Date.now(),s=this.camera,o=this.getLayoutByName(e);if(!o)return se.warn(`[Viewer] Can't find layout of ${e} !`),void this.decreaseJobCount();let l=this.loadedModels.find((e=>this.masterModelId===e.modelId));if(!l)return se.warn(`[Viewer] Can't find master model for modelId '${this.masterModelId}'!`),void this.decreaseJobCount();if(this.raycastableObjects=void 0,this.activeLayoutName){let e=this.getActiveLayoutInfo();e.lastCameraPosition||(e.lastCameraPosition=new D),null==(t=this.camera)||t.getWorldPosition(e.lastCameraPosition),this.controls.update(0),e.lastCameraZoom=s.zoom}if(!(e=>{let t=this.layoutInfos[e];return!(null==t||!t.lastCameraZoom)})(e)){this.switchTransformMs(e,this.masterModelId);let t=this.getLayoutViewports(o),r=[];t.length>0&&(r=t[0].frozenLayerHandles);let a=e!==gn.MODEL_LAYOUT_NAME,s=null==(i=l.dxfData)?void 0:i.threejsObject,h=null==s?void 0:s.children.find((t=>t.name===e));if(h){let t=[],i=null==(n=l.dxfData)?void 0:n.layersAndThreejsObjects;h.traverse((n=>{this.addSpatialFilterSection(n,l.dxfData);let s=n;if(a&&s.material&&s.geometry){let n=s.userData.layerName;if(!this.isLayerFrozenForViewport(l.dxfData,n,r))return;t.push(s);let a=-1;i&&i[n]&&(a=i[n].indexOf(s),a>=0&&i[n].splice(a,1)),a<0&&se.warn(`[Viewer] Failed to find object for modelId '${this.masterModelId}', layer '${n}', layout '${e}'`)}})),t.forEach((e=>{e.removeFromParent()}))}let c=this.getFilteredViewports(o);se.debug("[Viewer] Active layout:",e,", viewports:",c);let u=Date.now(),d=this.CAMERA_Z_POSITION/10,p=0;c.forEach((t=>{var i;this.generateObjectsByViewport(e,t,l.dxfData);let n=null==(i=null==t?void 0:t.msToPsMatrix)?void 0:i.elements[14];n&&n>p&&(p=n)}));let f=this.controls,m=f.getPosition(new D);if(p>m.z+d){let e=Math.ceil(p+d);se.info(`[Viewer] Changing camera's z value from ${m.z} to ${e}`);let t=f.getTarget(new D);m.setZ(e),f.setLookAt(m.x,m.y,m.z,t.x,t.y,t.z)}se.info(`[Viewer] generateObjectsByViewport in ${(Date.now()-u)/1e3}s`),e!==gn.MODEL_LAYOUT_NAME&&this.switchTransformMs(gn.MODEL_LAYOUT_NAME,this.masterModelId),e!==gn.MODEL_LAYOUT_NAME&&h&&this.setLayoutHidableObjectArray(h)}this.measurePlugin&&this.clearMeasurements(),this.markupManager&&this.clearMarkups(),null==(r=this.undoRedoManager)||r.clear(),this.showLayoutObjects(e),this.activeLayoutName=e;let h=this.getActiveLayoutInfo();if(h.lastCameraPosition)this.goTo(h.lastCameraPosition,h.lastCameraZoom,!1);else{h.extent=this.computeBoundingBox();let e=this.getLayoutExtentEx(o);if(e){let t=e.max.x-e.min.x,i=e.max.y-e.min.y;(t<1e-16||i<1e-16||t>1e16||i>1e16)&&(se.warn(`[Viewer] Got wired bbox, max: ${e.max.toArray()}, min: ${e.min.toArray()}, going to use the calculated one...`),e=h.extent)}else se.warn("[Viewer] Failed to get layout extent, going to use the calculated one..."),e=h.extent;h.homeViewExtent=e,this.zoomToBBox(e)}this.updateGroundPlane(),this.dispatchEvent("LayoutChanged"),St.printMemory(`After activated layout '${this.activeLayoutName}'`),this.enableRender(),this.decreaseJobCount(),se.info(`[Viewer] Activated layout '${e}' in ${(Date.now()-a)/1e3}s`)}cancelAllOperations(){var e,t,i,n,r,a;null!=(e=this.measurePlugin)&&e.isActive()&&(null==(t=this.measurePlugin)||t.deactivate()),null!=(i=this.markupManager)&&i.isMarkupActive()&&(null==(n=this.markupManager)||n.deactivate()),null!=(r=this.zoomToRectHelper)&&r.isActive()&&(null==(a=this.zoomToRectHelper)||a.deactivate())}getActiveLayoutName(){return this.activeLayoutName}getLayers(){var e,t,i,n,r,a;let s=[];if(this.masterModelId){let n=this.loadedModels.find((e=>this.masterModelId===e.modelId)),r=(null==(t=null==(e=null==n?void 0:n.dxfData)?void 0:e.tables)?void 0:t.layer.layers)||(null==(i=null==n?void 0:n.pdfData)?void 0:i.layers);r&&s.push({modelId:this.masterModelId,layers:r})}for(let o of this.loadedModels){let e=o.modelId;if(e===this.masterModelId)continue;let t=(null==(r=null==(n=null==o?void 0:o.dxfData)?void 0:n.tables)?void 0:r.layer.layers)||(null==(a=o.pdfData)?void 0:a.layers);t&&s.push({modelId:e,layers:t})}return s}setModelVisibility(e,t){let i=this.loadedModels.find((t=>e===t.modelId)),n=(null==i?void 0:i.dxfData)||(null==i?void 0:i.pdfData);if(!i||!n)throw new Error(`Failed to find model by modelId '${e}'!`);n.threejsObject.visible=t,this.enableRender()}setLayerVisibility(e,t,i){var n;let r=this.camera;i=i||this.masterModelId;let a=this.loadedModels.find((e=>i===e.modelId));if(!a)throw new Error(`Failed to find layer by modelId '${i}'!`);let s=a.dxfData||a.pdfData,o=(null==(n=s.tables)?void 0:n.layer.layers[e])||s.layers[e];o?o.visible=t:se.warn(`[Viewer] Layer '${e}' not found from modelData!`);let l=(null==s?void 0:s.layersAndThreejsObjects)&&(null==s?void 0:s.layersAndThreejsObjects[e]);if(l){let e=r.zoom;for(let i=0;i<l.length;i++){let n=l[i];this.enableHideVisuallySmallObjects&&t&&e&&n.userData.visibleMinZoom&&e<n.userData.visibleMinZoom||(n.visible=t),(!1===t||null!=n.userData.layerVisible)&&(n.userData.layerVisible=t),n.userData.isSnapObject&&(n.visible?gn.SHOW_SNAP_OBJECT?n.layers.enableAll():n.layers.set(11):gn.SHOW_SNAP_OBJECT?n.layers.disableAll():n.layers.disable(11))}}else se.info(`[Viewer] No object found for layer '${e}'`);this.raycastableObjects=void 0,this.enableRender()}setLayerOpacity(){throw new Error("Not implemented yet!")}setLayerColor(e,t,i){var n;i=i||this.masterModelId;let r=this.loadedModels.find((e=>i===e.modelId));if(!r)throw new Error(`Failed to find layer by modelId '${i}'!`);let a=r.dxfData||r.pdfData;if(!(null==(n=a.tables)?void 0:n.layer.layers[e])&&!a.layers[e])throw new Error(`Failed to find layer by layerName '${e}'!`);this.clearSelection();let s=(null==a?void 0:a.layersAndThreejsObjects)&&(null==a?void 0:a.layersAndThreejsObjects[e]);s?s.forEach((e=>{let i=e;if(i.material){i.userData.originalMaterial||(i.userData.originalMaterial=es.cloneMaterial(i.material));let e=es.cloneMaterial(i.material);es.setMaterialColor(e,new ct(t)),gn.updateMaterialUniforms(e),i.material=e}})):se.info(`[Viewer] No object found for layer '${e}'`),this.enableRender()}resetLayerColor(e,t){var i;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}'!`);let r=n.dxfData||n.pdfData;if(!(null==(i=r.tables)?void 0:i.layer.layers[e])&&!r.layers[e])throw new Error(`Failed to find layer by layerName '${e}'!`);this.clearSelection();let a=(null==r?void 0:r.layersAndThreejsObjects)&&(null==r?void 0:r.layersAndThreejsObjects[e]);a?a.forEach((e=>{let t=e;t.material&&t.userData.originalMaterial&&(t.material.dispose(),t.material=t.userData.originalMaterial,delete t.userData.originalMaterial)})):se.info(`[Viewer] No object found for layer '${e}'`),this.enableRender()}setFont(e){return ft(this,null,(function*(){this.increaseJobCount();let t=Date.now();this.fontManager||(this.fontManager=new ud),yield this.fontManager.loadFonts(e),this.decreaseJobCount(),se.info(`[Viewer] Font file(s) load time in ${(Date.now()-t)/1e3}s`)}))}getFont(){return this.fontManager}setLoadingManager(e){this.loadingManager=e}setDisplayLengthUnits(){throw new Error("Not implemented yet!")}setDisplayAreaUnits(){throw new Error("Not implemented yet!")}setDisplayPrecision(){throw new Error("Not implemented yet!")}getCurrentViewExtent(){return{min:this.getHitResultByNdcCoordinate({x:-1,y:-1}),max:this.getHitResultByNdcCoordinate({x:1,y:1})}}get measurePlugin(){return this.plugins.find((e=>"MeasurementPlugin"===e.id))}activateMeasurement(e){this.cancelAllOperations();let t=this.measurePlugin;t?(t.activate(e),this.clearSelection(),this.dispatchEvent("MeasurementActivated")):se.warn("[Viewer] MeasurementPlugin doesn't seem to be installed!")}deactivateMeasurement(){var e;null==(e=this.measurePlugin)||e.deactivate(),this.dispatchEvent("MeasurementDeactivated")}getActiveMeasurementType(){var e;return null==(e=this.measurePlugin)?void 0:e.getActiveMeasurementType()}getMeasurements(){var e;return(null==(e=this.measurePlugin)?void 0:e.getData())||[]}cancelMeasurement(){var e;null==(e=this.measurePlugin)||e.cancel()}setMeasurements(e){let t=this.measurePlugin;t&&(this.clearMeasurements(),t.setData(e))}selectMeasurement(e){var t;null==(t=this.measurePlugin)||t.selectById(e)}unselectMeasurement(){var e;null==(e=this.measurePlugin)||e.unselect()}removeMeasurement(e){var t;null==(t=this.measurePlugin)||t.removeById(e)}setMeasurementVisibility(e,t){let i=this.measurePlugin;return!!i&&i.setVisibilityById(e,t)}clearMeasurements(){var e;null==(e=this.measurePlugin)||e.clear()}getMarkupManager(){return this.markupManager}activateMarkup(e){this.cancelAllOperations(),this.inputManager&&(this.markupManager||(this.markupManager=new mE(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,i,n){var r;null==(r=this.markupManager)||r.setLineColor([e,t,i,n])}getMarkupLineColor(){var e;return null==(e=this.markupManager)?void 0:e.getLineColor()}setMarkupFillColor(e,t,i,n){var r;null==(r=this.markupManager)||r.setFillColor([e,t,i,n])}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 mE(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,i=this.markupManager,n=i.getMarkupById(e.id);return n&&(i.updateMarkup(n,e),t=!0),t}removeMarkup(e){return!(!this.inputManager||!this.markupManager)&&this.markupManager.removeMarkupById(e)}clearMarkups(){var e;null==(e=this.markupManager)||e.clearAll()}getHitResult(e){let t=this.viewerContainer;if(!this.camera||!this.raycaster||!this.groundPlane)return;let i=an.getScreenCoordinateByEvent(e,t),n=an.screen2Ndc(i,this.camera,t);return this.getHitResultByNdcCoordinate(n)}getHitResultByNdcCoordinate(e){if(!this.camera||!this.raycaster||!this.groundPlane)return;this.raycaster.setFromCamera(e,this.camera),this.raycaster.layers.set(10);let t=this.raycaster.intersectObject(this.groundPlane,!0);return t&&t.length>0?t[0].point:void 0}zoomToRect(){this.cancelAllOperations(),this.zoomToRectHelper||(this.zoomToRectHelper=new ky(this)),this.zoomToRectHelper.activate()}deactivateZoomRect(){var e;null==(e=this.zoomToRectHelper)||e.deactivate()}getLayoutByName(e){let t,i=this.getLayouts();for(let n of i)if(n.layoutName===e){t=n;break}return t}getActiveLayoutInfo(){return this.getLayoutInfo(this.activeLayoutName)}getMsTransformMatrix(e){var t,i;let n=this.loadedModels.find((t=>e===t.modelId)),r=null==(t=null==n?void 0:n.dxfData)?void 0:t.header;if(!r)return;let a=r.$ANGDIR,s=this.getDxfUnits(n.dxfData),o=null==(i=n.dxfData)?void 0:i.tables.viewport.viewports.filter((e=>"*ACTIVE"===e.name.toLocaleUpperCase()));if(!o)return;let l=new et,h=gn.getDcs2WcsMatrix(o[0],a),c=new D(o[0].center.x,o[0].center.y,0).applyMatrix4(h),u=1;this.units&&s!==this.units&&(u=lme(s,this.units)),c.multiplyScalar(u),l.makeTranslation(c.x,c.y,0);let d=o[0].viewTwistAngle;null!=d&&l.multiply((new et).makeRotationZ(Rn.degToRad(d))),l.multiply((new et).makeTranslation(-c.x,-c.y,0)),n.msTransformMatrix=l}switchTransformMs(e,t){var i;let n=this.loadedModels.find((e=>t===e.modelId));if(!n)return void se.warn(`[Viewer] Can't find model whose modelId is ${t}`);let r=n.msTransformMatrix;if(Fy.identity(),!r||!St.isMatrixValid(r)||r.equals(Fy))return;let a=null==(i=n.dxfData)?void 0:i.threejsObject,s=null==a?void 0:a.children.find((e=>e.name===gn.MODEL_LAYOUT_NAME));s&&(e===gn.MODEL_LAYOUT_NAME?s.applyMatrix4(r):s.applyMatrix4(r.clone().invert()),s.updateMatrixWorld(!0))}getLayoutExtentEx(e){return e.layoutName===gn.MODEL_LAYOUT_NAME?this.getModelSpaceExtent():this.getLayoutExtent(e)}getModelSpaceExtent(){var e,t;let i=this.loadedModels.find((e=>this.masterModelId===e.modelId));if(!i)return;let n=null==(e=i.dxfData)?void 0:e.header,r=new D,a=new D;if(!n)return void se.error(`Header is undefined in ${this.masterModelId}!`);let s=null==(t=i.dxfData)?void 0:t.tables.viewport.viewports,o=n.$EXTMIN,l=n.$EXTMAX,h=n.$ANGDIR;if(s&&s.length>0)for(let c=0;c<s.length;c++){let e=s[c];if("*ACTIVE"===e.name.toLocaleUpperCase()){let{center:t,viewHeight:i,aspectRatio:n}=e,r=i*n,a=gn.getDcs2WcsMatrix(e,h),s=new D(t.x,t.y,0);s.applyMatrix4(a),o={x:s.x-r/2,y:s.y-i/2,z:0},l={x:s.x+r/2,y:s.y+i/2,z:0};break}}return r.set(o.x,o.y,o.z),a.set(l.x,l.y,l.z),new Nt(r,a)}getLayoutExtent(e){var t;let i=this.loadedModels.find((e=>this.masterModelId===e.modelId));if(!i)return;let n=null==(t=i.dxfData)?void 0:t.header,r=new D,a=new D;if(!n)throw new Error(`Header is undefined in ${this.masterModelId}!`);let s=this.getLayoutViewports(e),o=n.$PEXTMIN,l=n.$PEXTMAX,h=n.$ANGDIR;if(s&&s.length>0){let e,t=s.filter((e=>1===parseInt(e.viewportId)));e=t.length>0?t[0]:s[0];let{centerPoint:i,width_paperSpace:n,height_paperSpace:r}=e,a=gn.getDcs2WcsMatrix(e,h),c=new D(i.x,i.y,0);c.applyMatrix4(a),o={x:c.x-n/2,y:c.y-r/2,z:0},l={x:c.x+n/2,y:c.y+r/2,z:0}}return r.set(o.x,o.y,o.z),a.set(l.x,l.y,l.z),new Nt(r,a)}showLayoutObjects(e){this.loadedModels.forEach((t=>{var i;let n=0,r=0,a=null==(i=t.dxfData)?void 0:i.threejsObject;null==a||a.children.forEach((t=>{let i=t.name===e;t.visible=i,i?n++:r++})),se.debug(`[Viewer] showLayoutObjects('${e}') sets ${n} layout level object(s) to visible and ${r} to hidden for model '${null==a?void 0:a.name}'`)}))}getLayoutViewports(e){var t;let i=this.loadedModels.find((e=>this.masterModelId===e.modelId));if(!i)return[];let n=e.ownerHandle;return(null==(t=i.dxfData)?void 0:t.layoutViewportsMap[n])||[]}setMaterialUniforms(e,t){e instanceof cn&&(e.uniforms.u_cameraZoom&&(e.uniforms.u_cameraZoom=gn.cameraZoomUniform),e.uniforms.u_viewportScale&&1===(null==t?void 0:t.header.$PSLTSCALE)&&(e.uniforms.u_viewportScale=gn.viewportScaleUniform))}isLayerFrozenForViewport(e,t,i){if(!e||!t)return!1;let n=e.tables.layer.layers[t];return!!(n&&(1&n.flag)>0)||!(!i||i.length<=0)&&n&&i.indexOf(n.handle)>=0}getFilteredViewports(e){let t=this.getLayoutViewports(e),i=t.filter((e=>"1"!==e.viewportId));return i.length===t.length&&(i=t.filter(((e,t)=>0!==t))),i}generateObjectsByViewport(e,t,i,n=[]){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!");gn.transformMatrixUniform={value:r.msToPsMatrix},gn.viewportScaleUniform={value:t.viewHeight/t.height_paperSpace};let a=r.psBBox.clone();a.applyMatrix4(r.msToPsMatrix.clone().invert()),a.min.setZ(-1),a.max.setZ(1);let s=this.getObjectsByBoundingBox(a);if(0===s.length)return;let o,l=r.psBBox.min,h=r.psBBox.max,c=new Mi(new xe(l.x,l.y),new xe(h.x,h.y)),u=Hu.generateSectionPlanesByBox(c),d=[],p=e=>(d[e.id]||(d[e.id]=e.clone(),this.setMaterialUniforms(d[e.id],i),Hu.setMaterialSection(d[e.id],u)),d[e.id]),f=[...n,...t.frozenLayerHandles||[]];if(e!==gn.MODEL_LAYOUT_NAME){let e=t;e.associatedLeafObjectSet||(e.associatedLeafObjectSet=new Set),o=e.associatedLeafObjectSet}let m=new er;m.name=t.viewportId;let g=null==i?void 0:i.layersAndThreejsObjects,v=[];if(s.forEach((t=>{let n=t.clone();n.traverse((t=>{if(t.material&&t.geometry){let n=t.userData.layerName;if(this.isLayerFrozenForViewport(i,n,f))return void v.push(t);!1!==t.userData.layerVisible&&(t.visible=!0),t.material=(e=>{if(Array.isArray(e)){let t=[];return e.forEach((e=>{let i=p(e);t.push(i)})),t}return p(e)})(t.material),null==o||o.add(t),g&&g[n]?g[n].push(t):se.warn(`[Viewer] Failed to find object for modelId '${this.masterModelId}', layer '${n}', layout '${e}'`)}})),m.add(n)})),o&&0===o.size)return;let y=null==i?void 0:i.threejsObject,x=null==y?void 0:y.children.find((t=>t.name===e));x||(x=new er,Hn.setSharedVariablesOfObject(x),x.name=e,null==y||y.add(x)),x.add(m),m.applyMatrix4(r.msToPsMatrix),m.updateMatrixWorld(!0);let b=x.children.find((e=>e.name===gn.SNAP_GROUP_NAME));b||(b=new er,b.visible=gn.SHOW_SNAP_OBJECT,b.name=gn.SNAP_GROUP_NAME,x.add(b));let _=null==y?void 0:y.children.find((e=>e.name===gn.MODEL_LAYOUT_NAME)),w=null==_?void 0:_.children.find((e=>e.name===gn.SNAP_GROUP_NAME));w&&w.traverse((e=>{if(!e.geometry)return;let t=e.userData.layerName;if(this.isLayerFrozenForViewport(i,t,f)||(Ny.makeEmpty(),Ny.expandByObject(e),!a.intersectsBox(Ny)))return;let n=e.clone();Hn.setSharedVariablesOfObject(n);let s=n.parent,l=Fy.identity();for(;s&&!0!==s.userData.isLayoutLevelObject;)l.premultiply(s.matrix),s=s.parent;l.premultiply(r.msToPsMatrix),n.applyMatrix4(l),null==b||b.add(n),null==o||o.add(n),g&&g[t]&&g[t].push(n)})),v.length>0&&Hn.removeEmptyObjectsFromRemovingObjects(v,m),m.traverse((e=>{Hn.setSharedVariablesOfObject(e),this.addSpatialFilterSection(e,i,!0)}))}findSpatialFilter(e,t){let i,n=t.objects.SPATIAL_FILTER;if(n){for(let t of n)if(t.handle===e){i=t;break}return i}}getAnyMaterial(e){let t,i=e;if(i.material)return Array.isArray(i.material)?i.material[0]:i.material;for(let n=0;n<e.children.length&&(t=this.getAnyMaterial(e.children[n]),!t);n++);return t}addSpatialFilterSection(e,t,i=!1){if("INSERT"!==e.userData.entityType||!e.userData.spatialFilterHandle)return;let n=this.findSpatialFilter(e.userData.spatialFilterHandle,t);if(n){let t=i,r=!1,a=this.getAnyMaterial(e);if(a&&(a.clippingPlanes&&(t=a.clippingPlanes.length>0),r=a.clipIntersection),t&&r!==n.clipPolylines[0].bReversed)return void se.warn("[Viewer] Material cannot set clipIntersection to different values at the same time. clipIntersection needs to be set to true here!");r=n.clipPolylines[0].bReversed;let s=this.generateSectionsBySpatialFilter(n,e.matrixWorld);if(s){let i=e=>{let t=0;return e.clippingPlanes&&(t=e.clippingPlanes.length),t+s.length>gn.maxFragmentUniforms},n=new Set,a=e=>{n.has(e.id)||(n.add(e.id),i(e)||Hu.setMaterialSection(e,s,t,r))};e.traverse((e=>{let t=e.material;Array.isArray(t)?t.forEach((e=>{a(e)})):t&&a(t)}))}}}getObjectsByBoundingBox(e){var t;let i=[];if(e.isEmpty())return se.warn("[Viewer] bbox is empty !"),i;let n=null==(t=this.loadedModels.find((e=>this.masterModelId===e.modelId)).dxfData)?void 0:t.threejsObject,r=null==n?void 0:n.children.find((e=>e.name===gn.MODEL_LAYOUT_NAME));return r&&r.children.forEach((t=>{t.name!==gn.SNAP_GROUP_NAME&&(t=>{let n=Os.getBoundingBox(t,!1);e.intersectsBox(n)&&i.push(t)})(t)})),i}getDxfUnits(e){if(!e&&this.loadedModels.length>0){let t=this.loadedModels.find((e=>this.masterModelId===e.modelId));e=null==t?void 0:t.dxfData}if(!e)return"Unitless";let t=null==e?void 0:e.header;if(!t)return se.warn("DxfData or its header is undefined!"),"Unitless";let i=t.$INSUNITS;return gn.getDxfUnits(i)}generateSectionsBySpatialFilter(e,t){let i=e.clipPolylines[0];if(i.bConcave)return void se.warn("[Viewer] clipPolyline.bConcave = true is not supported yet in spatialFilter !");Fy.copy(t),e.localMatrix&&Fy.multiply(e.localMatrix);let n=i.polyline,r=[];n.forEach((e=>{let t=e.clone().applyMatrix4(Fy);r.push(new xe(t.x,t.y))}));let a=zs.isClockWise(r),s=!a&&!i.bReversed||a&&i.bReversed;return Hu.generateSectionPlanesByPoints(r,s)}resize(e,t){super.resize(e,t),t>0&&(this.css2dRenderer&&(this.css2dRenderer.setSize(e,t),this.css2dRenderer.domElement.style.width="0",this.css2dRenderer.domElement.style.height="0"),this.overlayRender&&this.overlayRender.setSize(e,t)),this.enableRender()}getRaycaster(){return this.raycaster}getRaycastableObjects(){var e;if(this.raycastableObjects)return this.raycastableObjects;let t=Date.now(),i=[];for(let n of this.loadedModels){let t=null==(e=n.dxfData)?void 0:e.threejsObject,r=t&&t.children.find((e=>e.name===this.activeLayoutName));r&&r.traverse((e=>{(e.visible||e.userData.isSnapObject)&&Hn.isLeafObject(e)&&i.push(e)}))}return this.groundPlane&&i.push(this.groundPlane),this.raycastableObjects=i,se.debug(`[Viewer] getRaycastableObjects() finds ${i.length} objects`),se.debug(`[Viewer] getRaycastableObjects() costs ${(Date.now()-t)/1e3} s`),i}getViewportByPoint(e){if(0===this.activeLayoutName.length||this.activeLayoutName===gn.MODEL_LAYOUT_NAME)return;let t=this.getLayoutByName(this.activeLayoutName);if(!t)return;let i=t=>e.x<t.min.x||e.x>t.max.x||e.y<t.min.y||e.y>t.max.y,n=this.getFilteredViewports(t);for(let r=0,a=n.length;r<a;r++){let e=n[r];if(!i(e.psBBox))return e}}getRaycastableObjectsByMouse(e){var t,i,n,r,a,s;let o=[],l=this.viewerContainer;if(!(this.raycaster&&this.camera&&this.scene&&e))return o;let h=Date.now(),c=new xe(e.x,e.y),u=an.screen2Ndc(c,this.camera,l);if(this.raycaster.setFromCamera(u,this.camera),se.debug("[Viewer] Space coordinates corresponding to the mouse position:",this.raycaster.ray.origin),this.activeLayoutName===gn.MODEL_LAYOUT_NAME){if((null==(t=this.renderer)?void 0:t.info.render.frame)===this.lastFrame&&this.raycastableObjects)return this.raycastableObjects;if(null!=(i=this.renderer)&&i.renderLists){let e=null==(n=this.renderer)?void 0:n.renderLists.get(this.scene,0);e&&(e.opaque.forEach((e=>{e.object&&e.object.geometry&&o.push(e.object)})),e.transparent.forEach((e=>{e.object&&e.object.geometry&&o.push(e.object)})))}nve.multiplyMatrices(this.camera.projectionMatrix,this.camera.matrixWorldInverse),rve.setFromProjectionMatrix(nve);for(let e of this.loadedModels){let t=null==(r=e.dxfData)?void 0:r.threejsObject,i=t&&t.children.find((e=>e.name===this.activeLayoutName));if(i){let e=i.children.find((e=>e.name===gn.SNAP_GROUP_NAME));null==e||e.traverse((e=>{if(Hn.isLeafObject(e)){if(Ny.makeEmpty(),Ny.expandByObject(e),!rve.intersectsBox(Ny))return;o.push(e)}}))}}this.groundPlane&&o.push(this.groundPlane),se.debug("[Viewer] getRaycastableObjectsByMouse() from modelSpace"),this.lastFrame=(null==(a=this.renderer)?void 0:a.info.render.frame)||0,this.raycastableObjects=o}else{let e=new WeakSet,t=this.getLayoutByName(this.activeLayoutName);if(t){let i=t.directAssociatedLeafObjectSet;i&&i.forEach((t=>{t.visible&&!e.has(t)&&(o.push(t),e.add(t))}))}let i=this.getViewportByPoint(this.raycaster.ray.origin);i&&i.associatedLeafObjectSet?(null==(s=i.associatedLeafObjectSet)||s.forEach((t=>{!e.has(t)&&(t.visible||t.userData.isSnapObject)&&(o.push(t),e.add(t))})),se.debug("[Viewer] getRaycastableObjectsByMouse() from inside of viewport:",i.viewportId)):se.debug("[Viewer] getRaycastableObjectsByMouse() from out of viewport"),this.groundPlane&&o.push(this.groundPlane)}return se.debug(`[Viewer] getRaycastableObjectsByMouse() costs ${(Date.now()-h)/1e3} s`),o}getIntersections(e){let t=this.getRaycastableObjectsByMouse(e);return this.raycaster&&this.raycaster.intersectObjects(t,!0)||[]}handleMouseClick(e){var t,i;if(null!=(t=this.measurePlugin)&&t.isActive()||null!=(i=this.markupManager)&&i.isMarkupActive()||(this.selectDrawableByEvent(e),this.selectedObject)||!this.enableSelection)return;this.raycaster&&this.raycaster.layers.set(12);let n=this.getIntersections(e);if(n.length>0){let e=e=>St.vectorToString(e);se.debug(`[Viewer] Clicked at: ${e(n[0].point)}`)}let r=n.find((e=>e.object.visible)),a=r&&r.object||void 0;this.selectedObject&&this.clearSelection(),a&&this.selectedObject&&this.selectedObject.id===a.id&&(a=void 0),a?this.selectObject(a):this.clearSelection()}selectDrawableByEvent(e){var t,i;this.clearSelection();let n=this.getHitResult(e);if(!n)return;let r=null==(t=this.overlayRender)?void 0:t.getDrawablesByPosition(n,this.raycaster);r&&r.length>0&&(r[0].selected=!0,this.selectedObject=r[0],null==(i=this.overlayRender)||i.render())}selectObject(e,t=!1){if(!this.enableSelection)return;let i=e=>{if(e.children.length>0&&e.children.forEach((e=>i(e))),e instanceof xt||e instanceof fr||e instanceof ii){let i=es.clonedHighlightMaterials(e,{depthTest:t});i&&(e.userData.originalMaterial=e.material,e.material=i)}},n=e=>{if(e.children.length>0&&e.children.forEach((e=>n(e))),(e instanceof xt||e instanceof fr||e instanceof ii)&&e.userData.originalMaterial){let t=e.material;e.material=e.userData.originalMaterial,delete e.userData.originalMaterial,Array.isArray(t)?t.forEach((e=>e.dispose())):t instanceof yr&&t.dispose()}},r=!1;this.selectedObject&&(n(this.selectedObject),this.selectedObject=void 0,r=!0),e&&(i(e),this.selectedObject=e,e.userData.dxfEntity?se.info("[Viewer] Selected entity:",e.userData.dxfEntity):se.info("[Viewer] Selected object:",e),r=!0),r&&this.enableRender()}clearSelection(){var e;this.selectedObject&&this.selectedObject instanceof Hi?(this.selectedObject.selected=!1,null==(e=this.overlayRender)||e.render()):this.selectObject(),this.selectedObject=void 0}flyToObjects(e){if(!e||0===e.length||!this.camera)return;let t=new Nt;e.forEach((e=>{let i=Os.getBoundingBox(e);i.isEmpty()||t.union(i)})),this.zoomToBBox(t)}flyToObject(e){this.flyToObjects([e])}flyToSelectedObject(){if(!this.selectedObject)return;let e=this.selectedObject;(e instanceof Oi&&e.userData.clonedMesh||e instanceof xt&&Rr.isMergedMesh(e)&&e.userData.clonedMesh)&&(e=e.userData.clonedMesh),this.flyToObject(e)}flyToRandomObject(){var e;let t=this.scene,i=[];for(let c of this.loadedModels){let t=null==(e=c.dxfData)?void 0:e.threejsObject;t&&i.push(t.id)}let n=i.length;if(n<=0)return;let r=i[Math.floor(Math.random()*n)],a=t.getObjectById(r);if(!a)return;let s=this.getActiveLayoutName();if(!a.children.find((e=>e.name===s)))return;let o=[];if(t.traverseVisible((e=>{(e instanceof xt||e instanceof fr)&&!["SKYBOX","GROUND_GRID","GROUND_GRASS","BIM_VIEWER_BOX_HELPER"].includes(e.name)&&o.push(e.id)})),o.length<1)return;let l=Math.floor(Math.random()*o.length),h=t.getObjectById(o[l]);h&&(se.info(`[Viewer] Flying to random object: ${h.name}, type: ${h.type}`),this.selectObject(h,void 0),this.flyToObject(h))}flyTo(e,t,i,n){let r=this.camera,a=this.controls;if(!r||!a)return;if(i&&(i=this.checkAndGetLimitedCameraZoom(i)),e.equals(t))return void se.error("[Viewer] Camera position and lookAt cannot be the same!");if(!St.isVectorValid(e)||!St.isVectorValid(t))return void se.error("[Viewer] Invalid position or lookAt!",e,t);let s=e.distanceTo(t);s<r.near?(e=e.clone().sub(t).normalize().multiplyScalar(1.1*r.near),se.warn("[Viewer] Camera could be too close to see the object!")):s>r.far&&(e=e.clone().sub(t).normalize().multiplyScalar(.9*r.far),se.warn("[Viewer] Camera could be too far to see the object!"));let o=(e,t,i)=>{i&&Number.isFinite(i)&&a.zoomTo(i),a.setLookAt(e.x,e.y,e.z,t.x,t.y,t.z),this.updateHidableObjectsVisibility(),this.enableRender()};if(!1===n)return this.cameraUpdateInterval&&clearInterval(this.cameraUpdateInterval),void o(e,t,i);let l=r.position.clone(),h=a.getTarget(new D),c=r.zoom,u=300,d=Date.now();this.cameraUpdateInterval&&clearInterval(this.cameraUpdateInterval),this.cameraUpdateInterval=setInterval((()=>{let n=Date.now()-d;n>u&&(n=u);let r,a=(e,t,i)=>{let n=e.x+(t.x-e.x)*i,r=e.y+(t.y-e.y)*i,a=e.z+(t.z-e.z)*i;return new D(n,r,a)},s=a(l,e,n/u),p=a(h,t,n/u);i&&(r=c+(i-c)*n/u),o(s,p,r),n>=u&&(clearInterval(this.cameraUpdateInterval),this.cameraUpdateInterval=void 0)}),10)}goTo(e,t,i){let n=this.camera,r=this.controls;if(!n||!r)return;let a=new D(e.x,e.y,n.position.z),s=r.getTarget(new D),o=new D(e.x,e.y,s.z);this.flyTo(a,o,t,i)}goToHomeView(){let e=this.getActiveLayoutInfo();e.homeViewExtent?this.zoomToBBox(e.homeViewExtent):se.error(`[Viewer] Failed to find extent for ${this.activeLayoutName}`)}zoomToBBox(e){let t=this.camera;if(!t)return;let i=e.max.x-e.min.x,n=e.max.y-e.min.y,r=t.right-t.left,a=t.top-t.bottom,s=Math.min(r/i,a/n);s/=1.1;let o=new Nt(new D(e.min.x,e.min.y,0),new D(e.max.x,e.max.y,0)),l=new D;o.getCenter(l),l.z=0;let h=l.clone().setZ(Math.max(t.position.z,this.CAMERA_Z_POSITION));h.equals(l)||this.flyTo(h,l,s,!1)}zoomToExtent(){let e=this.getActiveLayoutInfo();e.extent?this.zoomToBBox(e.extent):(console.error("[Viewer] Failed to find extent of current layout! Will go to home view."),this.goToHomeView())}zoomToCompareChange(e){if(this.changes){let t=this.changes[e];if(!t)return;let i=t.box;i&&this.zoomToBBox(i.clone().expandByScalar(1.2))}}getCompareChanges(){return this.changes}setBackgroundColor(e,t,i){!this.scene||!this.renderer||(ive.setRGB(e,t,i,this.renderer.outputColorSpace),(!this.scene.background||!(this.scene.background instanceof ct))&&(this.scene.background=new ct(e,t,i)),this.scene.background.copy(ive),this.enableRender())}getLayoutInfo(e){return this.layoutInfos[e]||(this.layoutInfos[e]={}),this.layoutInfos[e]}updateGroundPlane(){if(!this.scene)return;let e=this.getActiveLayoutInfo();if(!e.homeViewExtent)return;let t=e.homeViewExtent.clone();St.expandBoxByScale(t,3);let i=t.min,n=t.max,r=n.x-i.x+n.y-i.y+n.z-i.z;St.expandBoxByMinSize(t,r);let a=[],s=(e,t,i)=>{a.push(new D(e,t,i))},o=t.getSize(new D),l=t.getCenter(new D);if(s(-o.x/2,-o.y/2,0),s(o.x/2,-o.y/2,0),s(o.x/2,o.y/2,0),s(-o.x/2,o.y/2,0),this.groundPlane)this.groundPlane.position.set(l.x,l.y,-o.z),this.groundPlane.geometry.setFromPoints(a),this.groundPlane.geometry.computeBoundingSphere(),this.groundPlane.geometry.computeBoundingBox();else{let e=new Dt;e.setFromPoints(a),e.setIndex([0,3,2,0,2,1]);let t=new ln({color:"#888",transparent:!0,opacity:0,side:Sr});this.groundPlane=new xt(e,t),this.groundPlane.visible=!0,this.groundPlane.frustumCulled=!1,this.groundPlane.position.set(l.x,l.y,-o.z),this.groundPlane.scale.set(1e5,1e5,1),this.groundPlane.name="groundPlane",this.groundPlane.renderOrder=-1e3,this.groundPlane.layers.enableAll(),Hn.disableLayerChannels(this.groundPlane,[12]),this.scene.add(this.groundPlane)}this.groundPlane.updateMatrixWorld()}computeBoundingBox(){var e;let t=new Nt;for(let i of this.loadedModels){let n=null==(e=i.dxfData)?void 0:e.threejsObject;for(let e=0;n&&e<n.children.length;++e){let i=n.children[e];if(i.name===this.activeLayoutName){let e=Os.getBoundingBox(i,!1);e.isEmpty()||t.union(e)}}}return t.min.z=0,t.max.z=0,se.info(`[Viewer] computeBoundingBox(), BBox's max: ${t.max.toArray()}, min: ${t.min.toArray()}`),t}checkAndGetLimitedCameraZoom(e){if(!e)return 1;let t=e;return e<this.CAMERA_MIN_ZOOM&&(se.warn(`[Viewer] Attampting to set camera's zoom value to ${e}, will use ${this.CAMERA_MIN_ZOOM}`),t=this.CAMERA_MIN_ZOOM),t}getVisiblePixelSize(e){let t=6.5*Rn.smoothstep(e,1e4,3e4)+.5;return se.debug("[Viewer] visiblePixelSize:",t),t}setLayoutHidableObjectArray(e){let t=this.camera;if(!this.enableHideVisuallySmallObjects||!t)return;let i=Date.now(),n=e.name;this.sortedHidableObjects[n]||(this.sortedHidableObjects[n]=[]);let r=this.sortedHidableObjects[n];this.controls.update(0);let a=t.zoom;this.lastCameraZoom=a;let s=e=>{if(!this.isCompareMode()||!e.material)return!1;let t;return t=e.material instanceof cn?e.material.uniforms.u_color.value:e.material.color,t.equals(new ct(ls.ENTITY_COLOR_ADDED))||t.equals(new ct(ls.ENTITY_COLOR_REMOVED))},o=1;e.traverse((e=>{if(this.isCompareMode()&&s(e)||e.userData.isSnapObject||!Hn.isLeafObject(e))return;let t=e.geometry;t.boundingBox||t.computeBoundingBox();let i=t.boundingBox.clone();if(!i||!St.isBoxValid(i))return;i.applyMatrix4(e.matrixWorld),i.getSize(C4);let n=Math.max(C4.x,C4.y),a=o/n;a<1/0?r.push({visibleMinZoom:a,object:e}):e instanceof ii?r.push({visibleMinZoom:o,object:e}):se.warn("[Viewer] The size of bbox is 0 ! ",e)})),o=this.getVisiblePixelSize(r.length);let l=0;r.forEach((e=>{let t=e.visibleMinZoom*o;e.visibleMinZoom=t,e.object.userData.visibleMinZoom=t,t>a&&(e.object.visible=!1,l++)})),r.sort(((e,t)=>e.visibleMinZoom-t.visibleMinZoom)),se.debug(`[Viewer] setLayoutHidableObjectArray cost: ${(Date.now()-i)/1e3}s, ${l} objects changed to hidden`)}statObjects(e){let t=this.sortedHidableObjects[this.activeLayoutName],i=t.length,n={},r=0;t.forEach((t=>{let i=t.object;if(i.geometry&&i.material){r++;let i=(t=>{let i=0,n=t;for(;n&&(i++,n!==e);)n=n.parent;return i})(t.object);n[i]||(n[i]=0),n[i]++}}));let a=0;e.traverse((e=>{let t=e;t.geometry&&t.material&&a++})),se.info(`[Viewer] hidableObjects count:${i}, real count:${r}, layout count: ${a}, level:`,n),se.info("[Viewer] scene:",this.scene)}updateHidableObjectsVisibility(){let e=this.camera;if(!e)return;let t=Date.now();this.controls.update(0);let i=e.zoom;if(Math.abs(i-this.lastCameraZoom)<1e-5||(this.updateRaycasterThreshold(),this.updateCameraZoomUniform(i),this.raycastableObjects=void 0,!this.sortedHidableObjects[this.activeLayoutName]))return;let n=this.sortedHidableObjects[this.activeLayoutName];if(0===n.length)return;let r=i>this.lastCameraZoom,a=Math.min(i,this.lastCameraZoom),s=Math.max(i,this.lastCameraZoom),o=[],l=0;for(let h=0;h<n.length;++h)if(!1!==n[h].object.userData.layerVisible){if(n[h].visibleMinZoom<a){o.push(n[h].object);continue}if(n[h].visibleMinZoom>s)break;n[h].object.visible=r,r&&o.push(n[h].object),l++}this.lastCameraZoom=i,se.debug(`[Viewer] updateHidableObjectsVisibility cost: ${(Date.now()-t)/1e3}s, ${l}(out of ${n.length}) objects changed to ${r?"visible":"hidden"}`)}updateRaycasterThreshold(){if(!this.camera||!this.raycaster)return;let e=3*this.getPixelSizeInWorldCoord(),t=this.raycaster.params;t.Line?t.Line.threshold=e:t.Line={threshold:e},t.Points?t.Points.threshold=e:t.Points={threshold:e}}updateCameraZoomUniform(e){gn.cameraZoomUniform.value=e}},OP=class{constructor(e){this.jobCount=0,this.viewer=new ip(e);let t=document.getElementById(e.containerId);this.container=(null==t?void 0:t.parentElement)||document.body,this.loadingProgressBar=new Yf(this.container),this.loader=new gn(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 ft(this,null,(function*(){let t=Date.now();this.fontManager||(this.fontManager=new ud),yield this.fontManager.loadFonts(e),se.info(`[DxfCompareHelper] Font file(s) load time in ${(Date.now()-t)/1e3}s`)}))}compare(e,t,i,n){return ft(this,null,(function*(){var r,a,s,o,l;let{src:h,modelId:c}=e,{src:u}=t;this.viewer.masterModelId=c||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+u,f=rg.t("ProgressBar.Comparing"),m=e=>{var t;null==(t=this.loadingProgressBar)||t.updateProgress(p,f,e),n&&n(new ProgressEvent("CompareProgress",{loaded:e,total:100}))},g=(e,t,i)=>{var r;let a=100*e.loaded/e.total;a=a*(i-t)/100+t,null==(r=this.loadingProgressBar)||r.updateProgress(p,f,a),n&&n(new ProgressEvent("CompareProgress",{loaded:a,total:100}))};St.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(u,(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 ${u}`);if(se.info(`[DxfCompareHelper] loadFiles in ${(Date.now()-v)/1e3}s`),gn.abortJobs)return Promise.reject("[DxfCompareHelper] compare loadFile aborted");let w=b.value,S=_.value;v=Date.now();let M=yield new ls(w,S,i).compare((e=>g(e,30,60)));if(se.info(`[DxfCompareHelper] Compared in ${(Date.now()-v)/1e3}s`),se.debug("[DxfCompareHelper] Compared results:",M),gn.abortJobs)return Promise.reject("[DxfCompareHelper] compare change aborted");St.printMemory("After getting the comparison results"),v=Date.now(),yield this.loader.loadEntitiesForCompare(w,S,M,!0,(e=>g(e,60,95))),St.printMemory("After Creating threejs objects based on comparison result"),null==(a=this.fontManager)||a.releaseFontData(),this.changes=M,se.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||se.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 ${u}`;return se.warn(e),Promise.reject(e)}let A=E.threejsObject,C=T.threejsObject;return A.name=h,C.name=u,v=Date.now(),this.viewer.addModel({modelId:e.modelId||e.src,dxfData:E}),St.printMemory("After adding first loaded Model to scene"),m(95),this.viewer.addModel({modelId:t.modelId||t.src,dxfData:T}),St.printMemory("After adding second loaded Model to scene"),se.info(`[DxfCompareHelper] Added compared objects to scene in ${(Date.now()-v)/1e3}s`),se.info(`[DxfCompareHelper] The comparison between ${h}' and '${u}' 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 i=t.box;i&&this.viewer.zoomToBBox(i.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)}},sve=class extends OP{constructor(e,t){super(e),this.syncCamera=!1,this.syncCameraControls=(e,t,i)=>{let n=new D,r=new D,a=new D;e.getPosition(r),e.getTarget(a),e.getFocalOffset(n),t.setLookAt(r.x,r.y,r.z,a.x,a.y,a.z),t.zoomTo(i),t.dispatchEvent({type:"control"})},this.viewer2=new ip(t),this.initSyncCameraEvent()}initSyncCameraEvent(){let e=this.viewer.controls,t=this.viewer2.controls,i=!1;e.addEventListener("control",(()=>{i=!1})),e.addEventListener("update",(()=>{!this.syncCamera||i||this.syncCameraControls(e,t,this.viewer.camera.zoom)})),t.addEventListener("control",(()=>{i=!0})),t.addEventListener("update",(()=>{!this.syncCamera||!i||this.syncCameraControls(t,e,this.viewer2.camera.zoom)}))}enableSyncCamera(e){if(this.syncCamera=e,e){let e=this.viewer.controls,t=this.viewer2.controls;this.syncCameraControls(e,t,this.viewer.camera.zoom)}}compare(e,t,i,n){return ft(this,null,(function*(){var r,a,s,o,l;let{src:h,modelId:c}=e,{src:u,modelId:d}=t;this.viewer.masterModelId=c||h,this.viewer2.masterModelId=d||u;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+u,m=rg.t("ProgressBar.Comparing"),g=e=>{var t;null==(t=this.loadingProgressBar)||t.updateProgress(f,m,e),n&&n(new ProgressEvent("CompareProgress",{loaded:e,total:100}))},v=(e,t,i)=>{var r;let a=100*e.loaded/e.total;a=a*(i-t)/100+t,null==(r=this.loadingProgressBar)||r.updateProgress(f,m,a),n&&n(new ProgressEvent("CompareProgress",{loaded:a,total:100}))};St.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(u,(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 ${u}`);if(se.info(`[DxfCompareHelper] loadFiles in ${(Date.now()-y)/1e3}s`),gn.abortJobs)return Promise.reject("[DxfCompareHelper] compare loadFile aborted");let S=_.value,M=w.value;y=Date.now();let E=yield new ls(S,M,i).compare((e=>v(e,30,60)));if(se.info(`[DxfCompareHelper] Compared in ${(Date.now()-y)/1e3}s`),se.debug("Compared results:",E),gn.abortJobs)return Promise.reject("[DxfCompareHelper] compare change aborted");St.printMemory("After getting the comparison results"),y=Date.now(),yield this.loader.loadEntitiesForCompare(S,M,E,!1,(e=>v(e,60,95))),St.printMemory("After Creating threejs objects based on comparison result"),null==(a=this.fontManager)||a.releaseFontData(),this.changes=E,se.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||se.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 ${u}`;return se.warn(e),Promise.reject(e)}let C=T.threejsObject,P=A.threejsObject;return C.name=h,P.name=u,y=Date.now(),this.viewer.addModel({modelId:e.modelId||e.src,dxfData:T}),St.printMemory("After adding first loaded Model to scene"),g(95),this.viewer2.addModel({modelId:t.modelId||t.src,dxfData:A}),St.printMemory("After adding second loaded Model to scene"),se.info(`[DxfCompareHelper] Added compared objects to scene in ${(Date.now()-y)/1e3}s`),se.info(`[DxfCompareHelper] The comparison between ${h}' and '${u}' 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 i=t.box;i&&(this.viewer.zoomToBBox(i.clone().expandByScalar(1.2)),this.viewer2.zoomToBBox(i.clone().expandByScalar(1.2)))}}},cg=Xi(ave(),1),dd=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],i=Math.sqrt(e*e+t*t);if(0===i)throw new Error("Vertices overlap");return[-t/i,e/i]}offset(e,t){return dd.offsetEdge(this.current,this.next,e,t)}inverseOffset(e,t){return dd.offsetEdge(this.next,this.current,e,t)}inverse(){return new dd(this.next,this.current)}static offsetEdge(e,t,i,n){return new dd([e[0]+i,e[1]+n],[t[0]+i,t[1]+n])}},E_=Array.isArray,ove=(e,t)=>e[0]===t[0]&&e[1]===t[1],L4=e=>Array.isArray(e)&&e.length,cve=(e,t=0,i=!1)=>{let n,r;if(L4(e)&&"number"==typeof e[0][0]){let t=0,a=e;for(n=0,r=a.length;n<r;n++){let e=a[n],i=a[(n+1)%r];t+=e[0]*i[1],t-=i[0]*e[1]}(!i&&t>0||i&&t<0)&&a.reverse()}else for(n=0,r=e.length;n<r;n++)cve(e[n],t+1,n>0);if(0===t&&L4(e)&&L4(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},lve=class{constructor(e,t=5){if(this.distance=0,this.arcSegments=t,!E_(e))throw new Error("Offset requires at least one coodinate to work with");this.edges=[],E_(e)&&"number"==typeof e[0]?this.vertices=e:(this.vertices=cve(e),this.processContour(this.vertices,this.edges))}processContour(e,t){let i,n;if(E_(e[0])&&"number"==typeof e[0][0])for(n=e.length,ove(e[0],e[n-1])&&(n-=1),i=0;i<n;i++)t.push(new dd(e[i],e[(i+1)%n]));else for(i=0,n=e.length;i<n;i++)t.push([]),this.processContour(e[i],t[t.length-1])}setArcSegments(e){return this.arcSegments=e,this}createArc(e,t,i,n,r,a,s){let o=2*Math.PI,l=Math.atan2(n[1]-t[1],n[0]-t[0]),h=Math.atan2(r[1]-t[1],r[0]-t[0]);a%2==0&&(a-=1),l<0&&(l+=o),h<0&&(h+=o);let c=l>h?l-h:l+o-h,u=(s?-c:o-c)/a;e.push(n);for(let d=1;d<a;++d)c=l+u*d,e.push([t[0]+Math.cos(c)*i,t[1]+Math.sin(c)*i]);return e.push(r),e}setDistance(e){return this.distance=e,this}ensureLastPoint(e){return ove(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,i,n){let r=[i.offset(i.inNormal[0]*n,i.inNormal[1]*n),i.inverseOffset(i.outNormal[0]*n,i.outNormal[1]*n)],a=[];for(let s=0,o=2;s<o;s++){let i=r[s],l=r[(s+o-1)%o];this.createArc(a,0===s?e:t,n,l.next,i.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,cg.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,cg.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(E_(this.vertices[0])&&"number"!=typeof this.vertices[0][0]){let e=[];for(let t=0,i=this.edges.length;t<i;t++){let i=this.offsetContour(this.vertices[t],this.edges[t]);i.length>0&&e.push(i)}e.length>0&&(t=1===e.length?e[0]:(0,cg.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 i=[],n=0,r=0;if(E_(e[0])&&"number"==typeof e[0][0]){for(n=0,r=e.length-1;n<r;n++){let r=[this.ensureLastPoint(this.offsetSegment(e[n],e[n+1],t[n],this.distance))];i.push(r)}i.length>0&&(i=1===i.length?[i[0]]:(0,cg.union)(i[0],i.slice(1)))}else{let a=[];for(n=0,r=t.length;n<r;n++){let i=this.offsetContour(e[n],t[n]);i.length>0&&a.push(i)}a.length>0&&(i=1===a.length?a[0]:(0,cg.union)(a[0],...a.slice(1)))}return i}offsetPoint(e){this.setDistance(e);let t=2*this.arcSegments,i=[],n=this.vertices,r=this.distance,a=0;t%2==0&&t++;for(let s=0;s<t;s++)a+=2*Math.PI/t,i.push([n[0]+r*Math.cos(a),n[1]+r*Math.sin(a)]);return[[this.ensureLastPoint(i)]]}};function D4(e){let t;try{t=new URL(e,"http://fakehost.com/")}catch(e){return null}let i=t.pathname.split("/").pop(),n=i.lastIndexOf(".");return-1===n||n===i.length-1?null:i.substring(n+1)}function qgt(e){Promise.resolve().then(e)}var kP=class{constructor(){this.maxSize=800,this.minSize=600,this.unloadPercent=.05,this.itemSet=new Map,this.itemList=[],this.usedSet=new Set,this.callbacks=new Map,this.unloadPriorityCallback=null;let e=this.itemSet;this.defaultPriorityCallback=t=>e.get(t)}isFull(){return this.itemSet.size>=this.maxSize}add(e,t){let i=this.itemSet;if(i.has(e)||this.isFull())return!1;let n=this.usedSet,r=this.itemList,a=this.callbacks;return r.push(e),n.add(e),i.set(e,Date.now()),a.set(e,t),!0}remove(e){let t=this.usedSet,i=this.itemSet,n=this.itemList,r=this.callbacks;if(i.has(e)){r.get(e)(e);let a=n.indexOf(e);return n.splice(a,1),t.delete(e),i.delete(e),r.delete(e),!0}return!1}markUsed(e){let t=this.itemSet,i=this.usedSet;t.has(e)&&!i.has(e)&&(t.set(e,Date.now()),i.add(e))}markAllUnused(){this.usedSet.clear()}unloadUnusedContent(){let e=this.unloadPercent,t=this.minSize,i=this.itemList,n=this.itemSet,r=this.usedSet,a=this.callbacks,s=i.length-r.size,o=i.length-t,l=this.unloadPriorityCallback||this.defaultPriorityCallback;if(o>0&&s>0){i.sort(((e,t)=>{let i=r.has(e),n=r.has(t);return i&&n?0:i||n?i?1:-1:l(t)-l(e)}));let h=Math.min(o,s),c=Math.max(t*e,h*e),u=Math.min(c,s);u=Math.ceil(u);let d=i.splice(0,u);for(let e=0,t=d.length;e<t;e++){let t=d[e];a.get(t)(t),n.delete(t),a.delete(t)}}}scheduleUnload(e=!0){this.scheduled||(this.scheduled=!0,qgt((()=>{this.scheduled=!1,this.unloadUnusedContent(),e&&this.markAllUnused()})))}},__=class{constructor(){this.maxJobs=6,this.items=[],this.callbacks=new Map,this.currJobs=0,this.scheduled=!1,this.autoUpdate=!0,this.priorityCallback=()=>{throw new Error("PriorityQueue: PriorityCallback function not defined.")},this.schedulingCallback=e=>{requestAnimationFrame(e)},this._runjobs=()=>{this.tryRunJobs(),this.scheduled=!1}}sort(){let e=this.priorityCallback;this.items.sort(e)}add(e,t){return new Promise(((i,n)=>{let r=this.items,a=this.callbacks;r.push(e),a.set(e,((...e)=>t(...e).then(i).catch(n))),this.autoUpdate&&this.scheduleJobRun()}))}remove(e){let t=this.items,i=this.callbacks,n=t.indexOf(e);-1!==n&&(t.splice(n,1),i.delete(e))}tryRunJobs(){this.sort();let e=this.items,t=this.callbacks,i=this.maxJobs,n=this.currJobs;for(;i>n&&e.length>0;){n++;let i=e.pop(),r=t.get(i);t.delete(i),r(i).then((()=>{this.currJobs--,this.autoUpdate&&this.scheduleJobRun()})).catch((()=>{this.currJobs--,this.autoUpdate&&this.scheduleJobRun()}))}this.currJobs=n}scheduleJobRun(){this.scheduled||(this.schedulingCallback(this._runjobs),this.scheduled=!0)}},Wgt=.0033528106647474805,uve=-(6378137*Wgt-6378137);function k4(e){return 3===e||4===e}function ug(e,t){return e.__lastFrameVisited===t&&e.__used}function hve(e,t){e.__lastFrameVisited!==t&&(e.__lastFrameVisited=t,e.__used=!1,e.__inFrustum=!1,e.__isLeaf=!1,e.__visible=!1,e.__active=!1,e.__error=1/0,e.__distanceFromCamera=1/0,e.__childrenWereVisible=!1,e.__allChildrenLoaded=!1)}function dve(e,t,i){if(hve(e,t),e.__used=!0,i.markUsed(e),e.__contentEmpty){let n=e.children;for(let e=0,r=n.length;e<r;e++)dve(n[e],t,i)}}function fve(e,t,i){if(!e.__contentEmpty||e.__externalTileSet&&!k4(e.__loadingState))i.requestTileContents(e);else{let n=e.children;for(let e=0,r=n.length;e<r;e++){let r=n[e];r.__depthFromRenderedParent=t,fve(r,t,i)}}}function NP(e,t=null,i=null,n=null,r=0){if(t&&t(e,n,r))return void(i&&i(e,n,r));let a=e.children;for(let s=0,o=a.length;s<o;s++)NP(a[s],t,i,e,r+1);i&&i(e,n,r)}function F4(e,t){let i=t.stats,n=t.frameCount,r=t.errorTarget,a=t.maxDepth,s=t.loadSiblings,o=t.lruCache,l=t.stopAtEmptyTiles;if(hve(e,n),!1===t.tileInView(e))return!1;if(e.__used=!0,o.markUsed(e),e.__inFrustum=!0,i.inFrustum++,(l||!e.__contentEmpty)&&!e.__externalTileSet&&(t.calculateError(e),e.__error<=r||t.maxDepth>0&&e.__depth+1>=a))return!0;let h=!1,c=e.children;for(let u=0,d=c.length;u<d;u++){let e=F4(c[u],t);h=h||e}if(h&&s)for(let u=0,d=c.length;u<d;u++)dve(c[u],n,o);return!0}function N4(e,t){let i=t.stats,n=t.frameCount;if(!ug(e,n))return;i.used++;let r=e.children,a=!1;for(let s=0,o=r.length;s<o;s++){let e=r[s];a=a||ug(e,n)}if(a){let i=!1,a=!0;for(let e=0,s=r.length;e<s;e++){let s=r[e];if(N4(s,t),i=i||s.__wasSetVisible||s.__childrenWereVisible,ug(s,n)){let e=s.__allChildrenLoaded||!s.__contentEmpty&&k4(s.__loadingState)||s.__externalTileSet&&4===s.__loadingState;a=a&&e}}e.__childrenWereVisible=i,e.__allChildrenLoaded=a}else e.__isLeaf=!0}function B4(e,t){let i=t.stats,n=t.frameCount;if(!ug(e,n))return;let r=e.parent,a=r?r.__depthFromRenderedParent:-1;e.__depthFromRenderedParent=a;let s=t.lruCache;if(e.__isLeaf)return e.__depthFromRenderedParent++,void(3===e.__loadingState?(e.__inFrustum&&(e.__visible=!0,i.visible++),e.__active=!0,i.active++):!s.isFull()&&(!e.__contentEmpty||e.__externalTileSet)&&t.requestTileContents(e));let o=(t.errorTarget+1)*t.errorThreshold,l=e.__error<=o,h=l||"ADD"===e.refine,c=!e.__contentEmpty,u=c||e.__externalTileSet,d=k4(e.__loadingState)&&u,p=e.__childrenWereVisible,f=e.children,m=e.__allChildrenLoaded;if(h&&c&&e.__depthFromRenderedParent++,h&&!d&&!s.isFull()&&u&&t.requestTileContents(e),(l&&!m&&!p&&d||"ADD"===e.refine&&d)&&(e.__inFrustum&&(e.__visible=!0,i.visible++),e.__active=!0,i.active++),"ADD"!==e.refine&&l&&!m&&d)for(let g=0,v=f.length;g<v;g++){let i=f[g];ug(i,n)&&!s.isFull()&&(i.__depthFromRenderedParent=e.__depthFromRenderedParent+1,fve(i,i.__depthFromRenderedParent,t))}else for(let g=0,v=f.length;g<v;g++){let e=f[g];ug(e,n)&&B4(e,t)}}function U4(e,t){let i=ug(e,t.frameCount);if(i||e.__usedLastFrame){let n=!1,r=!1;i&&(n=e.__active,r=t.displayActiveTiles&&e.__active||e.__visible),!e.__contentEmpty&&3===e.__loadingState&&(e.__wasSetActive!==n&&t.setTileActive(e,n),e.__wasSetVisible!==r&&t.setTileVisible(e,r)),e.__wasSetActive=n,e.__wasSetVisible=r,e.__usedLastFrame=i;let a=e.children;for(let e=0,i=a.length;e<i;e++)U4(a[e],t)}}var mve=(e,t)=>e.__depth!==t.__depth?e.__depth>t.__depth?-1:1:e.__inFrustum!==t.__inFrustum?e.__inFrustum?1:-1:e.__used!==t.__used?e.__used?1:-1:e.__error!==t.__error?e.__error>t.__error?1:-1:e.__distanceFromCamera!==t.__distanceFromCamera?e.__distanceFromCamera>t.__distanceFromCamera?-1:1:0,jgt=e=>1/(e.__depthFromRenderedParent+1),BP=class{get rootTileSet(){let e=this.tileSets[this.rootURL];return!e||e instanceof Promise?null:e}get root(){let e=this.rootTileSet;return e?e.root:null}constructor(e){this.tileSets={},this.rootURL=e,this.fetchOptions={},this.preprocessURL=null;let t=new kP;t.unloadPriorityCallback=jgt;let i=new __;i.maxJobs=4,i.priorityCallback=mve;let n=new __;n.maxJobs=1,n.priorityCallback=mve,this.lruCache=t,this.downloadQueue=i,this.parseQueue=n,this.stats={parsing:0,downloading:0,failed:0,inFrustum:0,used:0,active:0,visible:0},this.frameCount=0,this.errorTarget=6,this.errorThreshold=1/0,this.loadSiblings=!0,this.displayActiveTiles=!1,this.maxDepth=1/0,this.stopAtEmptyTiles=!0}traverse(e,t){let i=this.tileSets[this.rootURL];!i||!i.root||NP(i.root,e,t)}update(){let e=this.stats,t=this.lruCache,i=this.tileSets,n=i[this.rootURL];if(!(this.rootURL in i))return void this.loadRootTileSet(this.rootURL);if(!n||!n.root)return;let r=n.root;e.inFrustum=0,e.used=0,e.active=0,e.visible=0,this.frameCount++,F4(r,this),N4(r,this),B4(r,this),U4(r,this),t.scheduleUnload()}parseTile(e,t,i){return null}disposeTile(e){}preprocessNode(e,t,i){if(e.content&&(!("uri"in e.content)&&"url"in e.content&&(e.content.uri=e.content.url,delete e.content.url),e.content.uri&&(e.content.uri=new URL(e.content.uri,i+"/").toString()),e.content.boundingVolume&&!("box"in e.content.boundingVolume||"sphere"in e.content.boundingVolume||"region"in e.content.boundingVolume)&&delete e.content.boundingVolume),e.parent=t,e.children=e.children||[],e.content&&e.content.uri){let t=D4(e.content.uri),i=Boolean(t&&"json"===t.toLowerCase());e.__externalTileSet=i,e.__contentEmpty=i}else e.__externalTileSet=!1,e.__contentEmpty=!0;e.__distanceFromCamera=1/0,e.__error=1/0,e.__inFrustum=!1,e.__isLeaf=!1,e.__usedLastFrame=!1,e.__used=!1,e.__wasSetVisible=!1,e.__visible=!1,e.__childrenWereVisible=!1,e.__allChildrenLoaded=!1,e.__wasSetActive=!1,e.__active=!1,e.__loadingState=0,e.__loadIndex=0,e.__loadAbort=null,e.__depthFromRenderedParent=-1,null===t?(e.__depth=0,e.refine=e.refine||"REPLACE"):(e.__depth=t.__depth+1,e.refine=e.refine||t.refine)}setTileActive(e,t){}setTileVisible(e,t){}calculateError(e){return 0}tileInView(e){return!0}resetFailedTiles(){let e=this.stats;0!==e.failed&&(this.traverse((e=>{4===e.__loadingState&&(e.__loadingState=0)})),e.failed=0)}fetchTileSet(e,t,i=null){return fetch(e,t).then((t=>{if(t.ok)return t.json();throw new Error(`TilesRenderer: Failed to load tileset "${e}" with status ${t.status} : ${t.statusText}`)})).then((t=>{let n=t.asset.version;console.assert("1.0"===n||"0.0"===n,'asset.version is expected to be a string of "1.0" or "0.0"');let r=e.replace(/\/[^\/]*\/?$/,"");return r=new URL(r,window.location.href).toString(),NP(t.root,((e,t)=>this.preprocessNode(e,t,r)),null,i,i?i.__depth:0),t}))}loadRootTileSet(e){let t=this.tileSets;if(e in t)return t[e]instanceof Error?Promise.reject(t[e]):Promise.resolve(t[e]);{let i=this.fetchTileSet(this.preprocessURL?this.preprocessURL(e):e,this.fetchOptions).then((i=>{t[e]=i}));return i.catch((i=>{console.error(i),t[e]=i})),t[e]=i,i}}requestTileContents(e){if(0!==e.__loadingState)return;let t=this.stats,i=this.lruCache,n=this.downloadQueue,r=this.parseQueue,a=e.__externalTileSet;i.add(e,(e=>{1===e.__loadingState?(e.__loadAbort.abort(),e.__loadAbort=null):a?e.children.length=0:this.disposeTile(e),1===e.__loadingState?t.downloading--:2===e.__loadingState&&t.parsing--,e.__loadingState=0,e.__loadIndex++,r.remove(e),n.remove(e)})),e.__loadIndex++;let s=e.__loadIndex,o=new AbortController,l=o.signal;t.downloading++,e.__loadAbort=o,e.__loadingState=1;let h=a=>{e.__loadIndex===s&&("AbortError"!==a.name?(r.remove(e),n.remove(e),2===e.__loadingState?t.parsing--:1===e.__loadingState&&t.downloading--,t.failed++,console.error(`TilesRenderer : Failed to load tile at url "${e.content.uri}".`),console.error(a),e.__loadingState=4):i.remove(e))};a?n.add(e,(e=>{if(e.__loadIndex!==s)return Promise.resolve();let t=this.preprocessURL?this.preprocessURL(e.content.uri):e.content.uri;return this.fetchTileSet(t,Object.assign({signal:l},this.fetchOptions),e)})).then((i=>{e.__loadIndex===s&&(t.downloading--,e.__loadAbort=null,e.__loadingState=3,e.children.push(i.root))})).catch(h):n.add(e,(e=>{if(e.__loadIndex!==s)return Promise.resolve();let t=this.preprocessURL?this.preprocessURL(e.content.uri):e.content.uri;return fetch(t,Object.assign({signal:l},this.fetchOptions))})).then((t=>{if(e.__loadIndex===s){if(t.ok)return t.arrayBuffer();throw new Error(`Failed to load model with error code ${t.status}`)}})).then((i=>{if(e.__loadIndex===s)return t.downloading--,t.parsing++,e.__loadAbort=null,e.__loadingState=2,r.add(e,(e=>{if(e.__loadIndex!==s)return Promise.resolve();let t=D4(e.content.uri);return this.parseTile(i,e,t)}))})).then((()=>{e.__loadIndex===s&&(t.parsing--,e.__loadingState=3,e.__wasSetVisible&&this.setTileVisible(e,!0),e.__wasSetActive&&this.setTileActive(e,!0))})).catch(h)}dispose(){let e=this.lruCache;this.traverse((t=>{e.remove(t)})),this.stats={parsing:0,downloading:0,failed:0,inFrustum:0,used:0,active:0,visible:0},this.frameCount=0}};function UP(e){return(new TextDecoder).decode(e)}var fd=class{constructor(e,t,i,n){this.buffer=e,this.binOffset=t+i,this.binLength=n;let r=null;if(0!==i){let n=new Uint8Array(e,t,i);r=JSON.parse(UP(n))}else r={};this.header=r}getKeys(){return Object.keys(this.header)}getData(e,t,i=null,n=null){let r=this.header;if(!(e in r))return null;let a=r[e];if(a instanceof Object){if(Array.isArray(a))return a;{let r,{buffer:s,binOffset:o,binLength:l}=this,h=a.byteOffset||0,c=a.type||n,u=a.componentType||i;if("type"in a&&n&&a.type!==n)throw new Error("FeatureTable: Specified type does not match expected type.");switch(c){case"SCALAR":r=1;break;case"VEC2":r=2;break;case"VEC3":r=3;break;case"VEC4":r=4;break;default:throw new Error(`FeatureTable : Feature type not provided for "${e}".`)}let d,p=o+h,f=t*r;switch(u){case"BYTE":d=new Int8Array(s,p,f);break;case"UNSIGNED_BYTE":d=new Uint8Array(s,p,f);break;case"SHORT":d=new Int16Array(s,p,f);break;case"UNSIGNED_SHORT":d=new Uint16Array(s,p,f);break;case"INT":d=new Int32Array(s,p,f);break;case"UNSIGNED_INT":d=new Uint32Array(s,p,f);break;case"FLOAT":d=new Float32Array(s,p,f);break;case"DOUBLE":d=new Float64Array(s,p,f);break;default:throw new Error(`FeatureTable : Feature component type not provided for "${e}".`)}if(p+f*d.BYTES_PER_ELEMENT>o+l)throw new Error("FeatureTable: Feature data read outside binary body length.");return d}}return a}},sp=class extends fd{constructor(e,t,i,n,r){super(e,i,n,r),this.batchSize=t}getData(e,t=null,i=null){return super.getData(e,this.batchSize,t,i)}},$l=class{constructor(){this.fetchOptions={},this.workingPath=""}load(e){return fetch(e,this.fetchOptions).then((t=>{if(!t.ok)throw new Error(`Failed to load file "${e}" with status ${t.status} : ${t.statusText}`);return t.arrayBuffer()})).then((t=>(""===this.workingPath&&(this.workingPath=this.workingPathForURL(e)),this.parse(t))))}resolveExternalURL(e){return/^[^\\/]/.test(e)?this.workingPath+"/"+e:e}workingPathForURL(e){let t=e.split(/[\\/]/g);return t.pop(),t.join("/")+"/"}parse(e){throw new Error("LoaderBase: Parse not implemented.")}};function Gc(e){let t;if(t=e instanceof DataView?e:new DataView(e),"{"===String.fromCharCode(t.getUint8(0)))return null;let i="";for(let n=0;n<4;n++)i+=String.fromCharCode(t.getUint8(n));return i}var HP=class extends $l{parse(e){let t=new DataView(e),i=Gc(t);console.assert("b3dm"===i);let n=t.getUint32(4,!0);console.assert(1===n);let r=t.getUint32(8,!0);console.assert(r===e.byteLength);let a=t.getUint32(12,!0),s=t.getUint32(16,!0),o=t.getUint32(20,!0),l=t.getUint32(24,!0),h=e.slice(28,28+a+s),c=new fd(h,0,a,s),u=28+a+s,d=e.slice(u,u+o+l),p=new sp(d,c.getData("BATCH_LENGTH"),0,o,l),f=u+o+l;return{version:n,featureTable:c,batchTable:p,glbBytes:new Uint8Array(e,f,r-f)}}},By=class extends HP{constructor(e=fo){super(),this.manager=e,this.adjustmentTransform=new et}parse(e){let t=super.parse(e),i=t.glbBytes.slice().buffer;return new Promise(((e,n)=>{let r=this.manager,a=this.fetchOptions,s=r.getHandler("path.gltf")||new eh(r);"include"===a.credentials&&"cors"===a.mode&&s.setCrossOrigin("use-credentials"),"credentials"in a&&s.setWithCredentials("include"===a.credentials),a.headers&&s.setRequestHeader(a.headers);let o=this.workingPath;!/[\\/]$/.test(o)&&o.length&&(o+="/");let l=this.adjustmentTransform;s.parse(i,o,(i=>{let{batchTable:n,featureTable:r}=t,{scene:a}=i,s=r.getData("RTC_CENTER");s&&(a.position.x+=s[0],a.position.y+=s[1],a.position.z+=s[2]),i.scene.updateMatrix(),i.scene.matrix.multiply(l),i.scene.matrix.decompose(i.scene.position,i.scene.quaternion,i.scene.scale),i.batchTable=n,i.featureTable=r,a.batchTable=n,a.featureTable=r,e(i)}),n)}))}},VP=class extends $l{parse(e){let t=new DataView(e),i=Gc(t);console.assert("pnts"===i);let n=t.getUint32(4,!0);console.assert(1===n);let r=t.getUint32(8,!0);console.assert(r===e.byteLength);let a=t.getUint32(12,!0),s=t.getUint32(16,!0),o=t.getUint32(20,!0),l=t.getUint32(24,!0),h=e.slice(28,28+a+s),c=new fd(h,0,a,s),u=28+a+s,d=e.slice(u,u+o+l),p=new sp(d,c.getData("BATCH_LENGTH")||c.getData("POINTS_LENGTH"),0,o,l);return Promise.resolve({version:n,featureTable:c,batchTable:p})}},Uy=class extends VP{constructor(e=fo){super(),this.manager=e}parse(e){return super.parse(e).then((e=>{let{featureTable:t}=e,i=t.getData("POINTS_LENGTH"),n=t.getData("POSITION",i,"FLOAT","VEC3"),r=t.getData("RGB",i,"UNSIGNED_BYTE","VEC3");["QUANTIZED_VOLUME_OFFSET","QUANTIZED_VOLUME_SCALE","CONSTANT_RGBA","BATCH_LENGTH","POSITION_QUANTIZED","RGBA","RGB565","NORMAL","NORMAL_OCT16P"].forEach((e=>{e in t.header&&console.warn(`PNTSLoader: Unsupported FeatureTable feature "${e}" detected.`)}));let a=new Dt;a.setAttribute("position",new mn(n,3,!1));let s=new bi;s.size=2,s.sizeAttenuation=!1,null!==r&&(a.setAttribute("color",new mn(r,3,!0)),s.vertexColors=!0);let o=new ii(a,s);e.scene=o,e.scene.featureTable=t;let l=t.getData("RTC_CENTER");return l&&(e.scene.position.x+=l[0],e.scene.position.y+=l[1],e.scene.position.z+=l[2]),e}))}},zP=class extends $l{parse(e){let t=new DataView(e),i=Gc(t);console.assert("i3dm"===i);let n=t.getUint32(4,!0);console.assert(1===n);let r=t.getUint32(8,!0);console.assert(r===e.byteLength);let a=t.getUint32(12,!0),s=t.getUint32(16,!0),o=t.getUint32(20,!0),l=t.getUint32(24,!0),h=t.getUint32(28,!0),c=e.slice(32,32+a+s),u=new fd(c,0,a,s),d=32+a+s,p=e.slice(d,d+o+l),f=new sp(p,u.getData("INSTANCES_LENGTH"),0,o,l),m=d+o+l,g=new Uint8Array(e,m,r-m),v=null,y=null;if(h)v=g,y=Promise.resolve();else{let e=this.resolveExternalURL(UP(g));y=fetch(e,this.fetchOptions).then((t=>{if(!t.ok)throw new Error(`I3DMLoaderBase : Failed to load file "${e}" with status ${t.status} : ${t.statusText}`);return t.arrayBuffer()})).then((e=>{v=new Uint8Array(e)}))}return y.then((()=>({version:n,featureTable:u,batchTable:f,glbBytes:v})))}},gve=new D,z4=new D,G4=new D,vve=new D,q4=new dr,GP=new D,qP=new et,Hy=class extends zP{constructor(e=fo){super(),this.manager=e,this.adjustmentTransform=new et}resolveExternalURL(e){return this.manager.resolveURL(super.resolveExternalURL(e))}parse(e){return super.parse(e).then((e=>{let{featureTable:t,batchTable:i}=e,n=e.glbBytes.slice().buffer;return new Promise(((e,r)=>{let a=this.fetchOptions,s=this.manager,o=s.getHandler("path.gltf")||new eh(s);"include"===a.credentials&&"cors"===a.mode&&o.setCrossOrigin("use-credentials"),"credentials"in a&&o.setWithCredentials("include"===a.credentials),a.headers&&o.setRequestHeader(a.headers);let l=this.workingPath;/[\\/]$/.test(l)||(l+="/");let h=this.adjustmentTransform;o.parse(n,l,(n=>{let r=t.getData("INSTANCES_LENGTH"),a=t.getData("POSITION",r,"FLOAT","VEC3"),s=t.getData("NORMAL_UP",r,"FLOAT","VEC3"),o=t.getData("NORMAL_RIGHT",r,"FLOAT","VEC3"),l=t.getData("SCALE_NON_UNIFORM",r,"FLOAT","VEC3"),c=t.getData("SCALE",r,"FLOAT","SCALAR");["RTC_CENTER","QUANTIZED_VOLUME_OFFSET","QUANTIZED_VOLUME_SCALE","EAST_NORTH_UP","POSITION_QUANTIZED","NORMAL_UP_OCT32P","NORMAL_RIGHT_OCT32P"].forEach((e=>{e in t.header&&console.warn(`I3DMLoader: Unsupported FeatureTable feature "${e}" detected.`)}));let u=new Map,d=[];n.scene.traverse((e=>{if(e.isMesh){let{geometry:t,material:i}=e,n=new Oi(t,i,r);n.position.copy(e.position),n.rotation.copy(e.rotation),n.scale.copy(e.scale),d.push(n),u.set(e,n)}}));let p=new D;for(let e=0;e<r;e++)p.x+=a[3*e+0]/r,p.y+=a[3*e+1]/r,p.z+=a[3*e+2]/r;u.forEach(((e,t)=>{let i=t.parent;i&&(i.remove(t),i.add(e),e.updateMatrixWorld(),e.position.copy(p).applyMatrix4(e.matrixWorld))}));for(let e=0;e<r;e++){vve.set(a[3*e+0]-p.x,a[3*e+1]-p.y,a[3*e+2]-p.z),s?(z4.set(s[3*e+0],s[3*e+1],s[3*e+2]),G4.set(o[3*e+0],o[3*e+1],o[3*e+2]),gve.crossVectors(G4,z4).normalize(),qP.makeBasis(G4,z4,gve),q4.setFromRotationMatrix(qP)):q4.set(0,0,0,1),c?GP.setScalar(c[e]):l?GP.set(l[3*e+0],l[3*e+1],l[3*e+2]):GP.set(1,1,1),qP.compose(vve,q4,GP).multiply(h);for(let t=0,i=d.length;t<i;t++)d[t].setMatrixAt(e,qP)}n.batchTable=i,n.featureTable=t,n.scene.batchTable=i,n.scene.featureTable=t,e(n)}),r)}))}))}},WP=class extends $l{parse(e){let t=new DataView(e),i=Gc(t);console.assert("cmpt"===i,'CMPTLoader: The magic bytes equal "cmpt".');let n=t.getUint32(4,!0);console.assert(1===n,'CMPTLoader: The version listed in the header is "1".');let r=t.getUint32(8,!0);console.assert(r===e.byteLength,"CMPTLoader: The contents buffer length listed in the header matches the file.");let a=t.getUint32(12,!0),s=[],o=16;for(let l=0;l<a;l++){let t=new DataView(e,o,12),i=Gc(t),n=t.getUint32(4,!0),r=t.getUint32(8,!0),a=new Uint8Array(e,o,r);s.push({type:i,buffer:a,version:n}),o+=r}return{version:n,tiles:s}}},jP=class extends WP{constructor(e=fo){super(),this.manager=e,this.adjustmentTransform=new et}parse(e){let t=super.parse(e),i=this.manager,n=this.adjustmentTransform,r=[];for(let a in t.tiles){let{type:e,buffer:s}=t.tiles[a];switch(e){case"b3dm":{let e=s.slice(),t=new By(i);t.workingPath=this.workingPath,t.fetchOptions=this.fetchOptions,t.adjustmentTransform.copy(n);let a=t.parse(e.buffer);r.push(a);break}case"pnts":{let e=s.slice(),t=new Uy(i);t.workingPath=this.workingPath,t.fetchOptions=this.fetchOptions;let n=t.parse(e.buffer);r.push(n);break}case"i3dm":{let e=s.slice(),t=new Hy(i);t.workingPath=this.workingPath,t.fetchOptions=this.fetchOptions,t.adjustmentTransform.copy(n);let a=t.parse(e.buffer);r.push(a);break}}}return Promise.all(r).then((e=>{let t=new er;return e.forEach((e=>{t.add(e.scene)})),{tiles:e,scene:t}}))}},XP=class{constructor(){this.name="CESIUM_RTC"}afterRoot(e){if(e.parser.json.extensions&&e.parser.json.extensions.CESIUM_RTC){let{center:t}=e.parser.json.extensions.CESIUM_RTC;t&&(e.scene.position.x+=t[0],e.scene.position.y+=t[1],e.scene.position.z+=t[2])}}},YP=class extends $l{constructor(e=fo){super(),this.manager=e}parse(e){return new Promise(((t,i)=>{let n=this.manager,r=this.fetchOptions,a=n.getHandler("path.gltf")||n.getHandler("path.glb");a||(a=new eh(n),a.register((()=>new XP)),"include"===r.credentials&&"cors"===r.mode&&a.setCrossOrigin("use-credentials"),"credentials"in r&&a.setWithCredentials("include"===r.credentials),r.headers&&a.setRequestHeader(r.headers));let s=a.resourcePath||a.path||this.workingPath;!/[\\/]$/.test(s)&&s.length&&(s+="/"),a.parse(e,s,(e=>{t(e)}),i)}))}},$P=new et,ZP=class extends er{constructor(e){super(),this.name="TilesRenderer.TilesGroup",this.tilesRenderer=e}raycast(e,t){this.tilesRenderer.optimizeRaycast&&this.tilesRenderer.raycast(e,t)}updateMatrixWorld(e){if(this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldNeedsUpdate||e){null===this.parent?$P.copy(this.matrix):$P.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1;let e=$P.elements,t=this.matrixWorld.elements,i=!1;for(let n=0;n<16;n++){let r=e[n],a=t[n];if(Math.abs(r-a)>Number.EPSILON){i=!0;break}}if(i){this.matrixWorld.copy($P);let e=this.children;for(let t=0,i=e.length;t<i;t++)e[t].updateMatrixWorld()}}}};function yve(e){let{x:t,y:i,z:n}=e;e.x=n,e.y=t,e.z=i}function Xgt(e){return-e+Math.PI/2}var KP=new gf,T_=new D,hg=new D,JP=class{constructor(e=1,t=1,i=1){this.radius=new D(e,t,i)}getCartographicToPosition(e,t,i,n){let r=this.radius;KP.set(1,Xgt(e),t),T_.setFromSpherical(KP).normalize(),yve(T_),hg.copy(T_),hg.x*=Do(r.x,2),hg.y*=Do(r.y,2),hg.z*=Do(r.z,2);let a=Math.sqrt(T_.dot(hg));return hg.divideScalar(a),n.copy(hg).addScaledVector(T_,i)}getCartographicToNormal(e,t,i){return KP.set(1,-e+Math.PI/2,t),i.setFromSpherical(KP).normalize(),yve(i),i}getPositionToNormal(e,t){let i=this.radius;return t.copy(e),t.x/=Do(i.x,2),t.y/=Do(i.y,2),t.z/=Do(i.z,2),t.normalize(),t}},ap=Math.PI,QP=ap/2,w_=new D,Vy=new D,zy=new D,xve=new et,S_=0,W4=[];function Ygt(e=!1){return e?(W4[S_]||(W4[S_]=new D),S_++,W4[S_-1]):new D}function bve(){S_=0}var e2=class extends JP{constructor(e,t,i,n=-QP,r=QP,a=0,s=2*ap,o=0,l=0){super(e,t,i),this.latStart=n,this.latEnd=r,this.lonStart=a,this.lonEnd=s,this.heightStart=o,this.heightEnd=l}_getPoints(e=!1){let{latStart:t,latEnd:i,lonStart:n,lonEnd:r,heightStart:a,heightEnd:s}=this,o=Rn.mapLinear(.5,0,1,t,i),l=Rn.mapLinear(.5,0,1,n,r),h=Math.floor(n/QP)*QP,c=[[-ap/2,0],[ap/2,0],[0,h],[0,h+ap/2],[0,h+ap],[0,h+3*ap/2],[t,r],[i,r],[t,n],[i,n],[0,n],[0,r],[o,l],[t,l],[i,l],[o,n],[o,r]],u=[],d=c.length;for(let p=0;p<=1;p++){let o=Rn.mapLinear(p,0,1,a,s);for(let a=0,s=d;a<s;a++){let[s,l]=c[a];if(s>=t&&s<=i&&l>=n&&l<=r){let t=Ygt(e);u.push(t),this.getCartographicToPosition(s,l,o,t)}}}return u}getBoundingBox(e,t){bve();let{latStart:i,latEnd:n,lonStart:r,lonEnd:a}=this;if(n-i<ap/2){let e=Rn.mapLinear(.5,0,1,i,n),s=Rn.mapLinear(.5,0,1,r,a);this.getCartographicToNormal(e,s,zy),Vy.set(0,0,1),w_.crossVectors(Vy,zy),Vy.crossVectors(w_,zy),t.makeBasis(w_,Vy,zy)}else w_.set(1,0,0),Vy.set(0,1,0),zy.set(0,0,1),t.makeBasis(w_,Vy,zy);xve.copy(t).invert();let s=this._getPoints(!0);for(let o=0,l=s.length;o<l;o++)s[o].applyMatrix4(xve);e.makeEmpty(),e.setFromPoints(s)}getBoundingSphere(e,t){bve();let i=this._getPoints(!0);e.makeEmpty(),e.setFromPoints(i,t)}},Wy=new vr,pd=new et,Eve=new D,Gy=new D,qy=new lo,Zl=[];function j4(e,t){return e.distance-t.distance}function X4(e,t,i){e.traverse((e=>{Object.getPrototypeOf(e).raycast.call(e,t,i)}))}function Y4(e,t,i,n){if(i.has(e)){if(X4(e.cached.scene,n,Zl),Zl.length>0){Zl.length>1&&Zl.sort(j4);let e=Zl[0];return Zl.length=0,e}return null}let r=[],a=e.children;for(let l=0,h=a.length;l<h;l++){let e=a[l],i=e.cached,s=t.matrixWorld;pd.copy(s);let o=i.sphere;if(o&&(Wy.copy(o),Wy.applyMatrix4(pd),!n.ray.intersectsSphere(Wy)))continue;let h=i.box,c=i.boxTransform;if(h){if(pd.multiply(c).invert(),qy.copy(n.ray),qy.applyMatrix4(pd),!qy.intersectBox(h,Eve))continue;{Gy.setFromMatrixScale(pd);let t=Gy.x;Math.abs(Math.max(Gy.x-Gy.y,Gy.x-Gy.z))>1e-6&&console.warn("ThreeTilesRenderer : Non uniform scale used for tile which may cause issues when raycasting.");let i={distance:1/0,tile:null};r.push(i),i.distance=Eve.distanceToSquared(qy.origin)*t*t,i.tile=e}}}r.sort(j4);let s=1/0,o=null;for(let l=0,h=r.length;l<h;l++){let e=r[l];if(e.distance>s)break;{let r=e.tile,a=r.cached.scene,l=null;if(i.has(r)?(X4(a,n,Zl),Zl.length>0&&(Zl.length>1&&Zl.sort(j4),l=Zl[0])):l=Y4(r,t,i,n),l){let e=l.distance*l.distance;e<s&&(s=e,o=l),Zl.length=0}}}return o}function $4(e,t,i,n,r){let a=e.cached,s=t.matrixWorld;pd.copy(s);let o=a.sphere;if(o&&(Wy.copy(o),Wy.applyMatrix4(pd),!n.ray.intersectsSphere(Wy)))return;let l=a.box,h=a.boxTransform;if(l&&(pd.multiply(h).invert(),qy.copy(n.ray).applyMatrix4(pd),!qy.intersectsBox(l)))return;let c=a.scene;if(i.has(e))return void X4(c,n,r);let u=e.children;for(let d=0,p=u.length;d<p;d++)$4(u[d],t,i,n,r)}var wve=Symbol("INITIAL_FRUSTUM_CULLED"),qc=new et,Z4=new et,Wc=new D,md=new D,gd=new D,vd=new D,$gt=new D(1,0,0),Zgt=new D(0,1,0);function Tve(e,t){e.traverse((e=>{e.frustumCulled=e[wve]&&t}))}var M_=class extends BP{get autoDisableRendererCulling(){return this._autoDisableRendererCulling}set autoDisableRendererCulling(e){this._autoDisableRendererCulling!==e&&(super._autoDisableRendererCulling=e,this.forEachLoadedModel((t=>{Tve(t,!e)})))}constructor(...e){super(...e),this.group=new ZP(this),this.cameras=[],this.cameraMap=new Map,this.cameraInfo=[],this.activeTiles=new Set,this.visibleTiles=new Set,this._autoDisableRendererCulling=!0,this.optimizeRaycast=!0,this.onLoadTileSet=null,this.onLoadModel=null,this.onDisposeModel=null,this.onTileVisibilityChange=null;let t=new Lu;t.setURLModifier((e=>this.preprocessURL?this.preprocessURL(e):e)),this.manager=t;let i=this;this._overridenRaycast=function(e,t){i.optimizeRaycast||Object.getPrototypeOf(this).raycast.call(this,e,t)}}getBounds(e){if(!this.root)return!1;let t=this.root.cached,i=t.box,n=t.boxTransform;return!!i&&(e.copy(i),e.applyMatrix4(n),!0)}getOrientedBounds(e,t){if(!this.root)return!1;let i=this.root.cached,n=i.box,r=i.boxTransform;return!!n&&(e.copy(n),t.copy(r),!0)}getBoundingSphere(e){if(!this.root)return!1;let t=this.root.cached.sphere;return!!t&&(e.copy(t),!0)}forEachLoadedModel(e){this.traverse((t=>{let i=t.cached.scene;i&&e(i,t)}))}raycast(e,t){if(this.root)if(e.firstHitOnly){let i=Y4(this.root,this.group,this.activeTiles,e);i&&t.push(i)}else $4(this.root,this.group,this.activeTiles,e,t)}hasCamera(e){return this.cameraMap.has(e)}setCamera(e){let t=this.cameras,i=this.cameraMap;return!i.has(e)&&(i.set(e,new xe),t.push(e),!0)}setResolution(e,t,i){let n=this.cameraMap;return!!n.has(e)&&(t instanceof xe?n.get(e).copy(t):n.get(e).set(t,i),!0)}setResolutionFromRenderer(e,t){let i=this.cameraMap;if(!i.has(e))return!1;let n=i.get(e);return t.getSize(n),n.multiplyScalar(t.getPixelRatio()),!0}deleteCamera(e){let t=this.cameras,i=this.cameraMap;if(i.has(e)){let n=t.indexOf(e);return t.splice(n,1),i.delete(e),!0}return!1}fetchTileSet(e,...t){let i=super.fetchTileSet(e,...t);return i.then((t=>{this.onLoadTileSet&&Promise.resolve().then((()=>{this.onLoadTileSet(t,e)}))})),i}update(){let e=this.group,t=this.cameras,i=this.cameraMap,n=this.cameraInfo;if(0===t.length)return void console.warn("TilesRenderer: no cameras defined. Cannot update 3d tiles.");for(;n.length>t.length;)n.pop();for(;n.length<t.length;)n.push({frustum:new ma,isOrthographic:!1,sseDenominator:-1,position:new D,invScale:-1,pixelSize:0});Z4.copy(e.matrixWorld).invert(),Wc.setFromMatrixScale(Z4);let r=Wc.x;Math.abs(Math.max(Wc.x-Wc.y,Wc.x-Wc.z))>1e-6&&console.warn("ThreeTilesRenderer : Non uniform scale used for tile which may cause issues when calculating screen space error.");for(let a=0,s=n.length;a<s;a++){let s=t[a],o=n[a],l=o.frustum,h=o.position,c=i.get(s);(0===c.width||0===c.height)&&console.warn("TilesRenderer: resolution for camera error calculation is not set.");let u=s.projectionMatrix.elements;if(o.isOrthographic=1===u[15],o.isOrthographic){let e=2/u[0],t=2/u[5];o.pixelSize=Math.max(t/c.height,e/c.width)}else o.sseDenominator=2/u[5]/c.height;o.invScale=r,qc.copy(e.matrixWorld),qc.premultiply(s.matrixWorldInverse),qc.premultiply(s.projectionMatrix),l.setFromProjectionMatrix(qc),h.set(0,0,0),h.applyMatrix4(s.matrixWorld),h.applyMatrix4(Z4)}super.update()}preprocessNode(e,t,i){super.preprocessNode(e,t,i);let n=new et;if(e.transform){let t=e.transform;for(let e=0;e<16;e++)n.elements[e]=t[e]}else n.identity();t&&n.premultiply(t.cached.transform);let r=(new et).copy(n).invert(),a=null,s=null,o=null;if("box"in e.boundingVolume){let t=e.boundingVolume.box;a=new Nt,s=new et,o=new et,md.set(t[3],t[4],t[5]),gd.set(t[6],t[7],t[8]),vd.set(t[9],t[10],t[11]);let i=md.length(),r=gd.length(),l=vd.length();md.normalize(),gd.normalize(),vd.normalize(),0===i&&md.crossVectors(gd,vd),0===r&&gd.crossVectors(md,vd),0===l&&vd.crossVectors(md,gd),s.set(md.x,gd.x,vd.x,t[0],md.y,gd.y,vd.y,t[1],md.z,gd.z,vd.z,t[2],0,0,0,1),s.premultiply(n),o.copy(s).invert(),a.min.set(-i,-r,-l),a.max.set(i,r,l)}let l=null;if("sphere"in e.boundingVolume){let t=e.boundingVolume.sphere;l=new vr,l.center.set(t[0],t[1],t[2]),l.radius=t[3],l.applyMatrix4(n)}else if("box"in e.boundingVolume){let t=e.boundingVolume.box;l=new vr,a.getBoundingSphere(l),l.center.set(t[0],t[1],t[2]),l.applyMatrix4(n)}let h=null;if("region"in e.boundingVolume){let t=e.boundingVolume.region,[i,n,r,c,u,d]=t;h=new e2(6378137,6378137,uve,n,c,i,r,u,d),null===l&&(l=new vr,h.getBoundingSphere(l)),null===a&&(a=new Nt,s=new et,o=new et,h.getBoundingBox(a,s),o.copy(s).invert())}e.cached={loadIndex:0,transform:n,transformInverse:r,active:!1,inFrustum:[],box:a,boxTransform:s,boxTransformInverse:o,sphere:l,region:h,scene:null,geometry:null,material:null}}parseTile(e,t,i){t._loadIndex=t._loadIndex||0,t._loadIndex++;let n=t.content.uri.split(/[\\\/]/g);n.pop();let r=n.join("/"),a=this.fetchOptions,s=this.manager,o=t._loadIndex,l=null,h=this.rootTileSet.asset&&this.rootTileSet.asset.gltfUpAxis||"y",c=t.cached,u=c.transform;switch(h.toLowerCase()){case"x":qc.makeRotationAxis(Zgt,-Math.PI/2);break;case"y":qc.makeRotationAxis($gt,Math.PI/2);break;case"z":qc.identity()}let d=Gc(e)||i;switch(d){case"b3dm":{let t=new By(s);t.workingPath=r,t.fetchOptions=a,t.adjustmentTransform.copy(qc),l=t.parse(e).then((e=>e.scene));break}case"pnts":{let t=new Uy(s);t.workingPath=r,t.fetchOptions=a,l=t.parse(e).then((e=>e.scene));break}case"i3dm":{let t=new Hy(s);t.workingPath=r,t.fetchOptions=a,t.adjustmentTransform.copy(qc),l=t.parse(e).then((e=>e.scene));break}case"cmpt":{let t=new jP(s);t.workingPath=r,t.fetchOptions=a,t.adjustmentTransform.copy(qc),l=t.parse(e).then((e=>e.scene));break}case"gltf":case"glb":let t=new YP(s);t.workingPath=r,t.fetchOptions=a,l=t.parse(e).then((e=>e.scene));break;default:console.warn(`TilesRenderer: Content type "${d}" not supported.`),l=Promise.resolve(null)}return l.then((e=>{if(t._loadIndex!==o)return;e.updateMatrix(),("glb"===d||"gltf"===d)&&e.matrix.multiply(qc),e.matrix.premultiply(u),e.matrix.decompose(e.position,e.quaternion,e.scale),e.traverse((e=>{e[wve]=e.frustumCulled})),Tve(e,!this.autoDisableRendererCulling),c.scene=e,e.traverse((e=>{e.raycast=this._overridenRaycast}));let i=[],n=[],r=[];e.traverse((e=>{if(e.geometry&&n.push(e.geometry),e.material){let t=e.material;i.push(e.material);for(let e in t){let i=t[e];i&&i.isTexture&&r.push(i)}}})),c.materials=i,c.geometry=n,c.textures=r,this.onLoadModel&&this.onLoadModel(e,t)}))}disposeTile(e){let t=e.cached;if(t.scene){let i=t.materials,n=t.geometry,r=t.textures,a=t.scene.parent;for(let e=0,t=n.length;e<t;e++)n[e].dispose();for(let e=0,t=i.length;e<t;e++)i[e].dispose();for(let e=0,t=r.length;e<t;e++)r[e].dispose();a&&a.remove(t.scene),this.onDisposeModel&&this.onDisposeModel(t.scene,e),t.scene=null,t.materials=null,t.textures=null,t.geometry=null}this.activeTiles.delete(e),this.visibleTiles.delete(e),e._loadIndex++}setTileVisible(e,t){let i=e.cached.scene,n=this.visibleTiles,r=this.group;t?(r.add(i),n.add(e),i.updateMatrixWorld(!0)):(r.remove(i),n.delete(e)),this.onTileVisibilityChange&&this.onTileVisibilityChange(i,e,t)}setTileActive(e,t){let i=this.activeTiles;t?i.add(e):i.delete(e)}calculateError(e){let t=e.cached,i=t.inFrustum,n=this.cameras,r=this.cameraInfo,a=t.sphere,s=t.box,o=t.boxTransformInverse,l=t.transformInverse,h=s&&o,c=-1/0,u=1/0;for(let d=0,p=n.length;d<p;d++){if(!i[d])continue;let t,n=r[d],p=n.invScale;if(n.isOrthographic){let i=n.pixelSize;t=e.geometricError/(i*p)}else{let i;Wc.copy(n.position),h?(Wc.applyMatrix4(o),i=s.distanceToPoint(Wc)):(Wc.applyMatrix4(l),i=Math.max(a.distanceToPoint(Wc),0));let r=i*p,c=n.sseDenominator;t=e.geometricError/(r*c),u=Math.min(u,r)}c=Math.max(c,t)}e.__distanceFromCamera=u,e.__error=c}tileInView(e){let t=e.cached,i=t.sphere,n=t.inFrustum;if(i){let e=this.cameraInfo,t=!1;for(let r=0,a=e.length;r<a;r++)e[r].frustum.intersectsSphere(i)?(t=!0,n[r]=!0):n[r]=!1;return t}return!0}},p2=Xi(kl(),1),R_=new D,A_=new D,Sve=new Ln,t2=class extends qr{constructor(e,t=1,i=16711680){let n=new Dt,r=e.geometry.attributes.normal.count,a=new Bt(2*r*3,3);n.setAttribute("position",a),super(n,new Gn({color:i,toneMapped:!1})),this.object=e,this.size=t,this.type="VertexNormalsHelper",this.matrixAutoUpdate=!1,this.update()}update(){this.object.updateMatrixWorld(!0),Sve.getNormalMatrix(this.object.matrixWorld);let e=this.object.matrixWorld,t=this.geometry.attributes.position,i=this.object.geometry;if(i){let n=i.attributes.position,r=i.attributes.normal,a=0;for(let i=0,s=n.count;i<s;i++)R_.fromBufferAttribute(n,i).applyMatrix4(e),A_.fromBufferAttribute(r,i),A_.applyMatrix3(Sve).normalize().multiplyScalar(this.size).add(R_),t.setXYZ(a,R_.x,R_.y,R_.z),a+=1,t.setXYZ(a,A_.x,A_.y,A_.z),a+=1}t.needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}},vs=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(){}},Kgt=new Nr(-1,1,1,-1,0,1),K4=new Dt;K4.setAttribute("position",new Bt([-1,3,0,-1,-1,0,3,-1,0],3)),K4.setAttribute("uv",new Bt([0,2,0,0,2,0],2));var ba=class{constructor(e){this._mesh=new xt(K4,e)}dispose(){this._mesh.geometry.dispose()}render(e){e.render(this._mesh,Kgt)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}},J4={name:"ConvolutionShader",defines:{KERNEL_SIZE_FLOAT:"25.0",KERNEL_SIZE_INT:"25"},uniforms:{tDiffuse:{value:null},uImageIncrement:{value:new xe(.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 i=.5*(t-1),n=new Array(t),r=0;for(let a=0;a<t;++a)n[a]=Jgt(a-i,e),r+=n[a];for(let a=0;a<t;++a)n[a]/=r;return n}};function Jgt(e,t){return Math.exp(-e*e/(2*t*t))}var nh=class extends vs{constructor(e=1,t=25,i=4){super(),this.renderTargetX=new sr(1,1,{type:Mr}),this.renderTargetX.texture.name="BloomPass.x",this.renderTargetY=new sr(1,1,{type:Mr}),this.renderTargetY.texture.name="BloomPass.y",this.combineUniforms=Ri.clone(n2.uniforms),this.combineUniforms.strength.value=e,this.materialCombine=new cn({name:n2.name,uniforms:this.combineUniforms,vertexShader:n2.vertexShader,fragmentShader:n2.fragmentShader,blending:Ec,transparent:!0});let n=J4;this.convolutionUniforms=Ri.clone(n.uniforms),this.convolutionUniforms.uImageIncrement.value=nh.blurX,this.convolutionUniforms.cKernel.value=J4.buildKernel(i),this.materialConvolution=new cn({name:n.name,uniforms:this.convolutionUniforms,vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,defines:{KERNEL_SIZE_FLOAT:t.toFixed(1),KERNEL_SIZE_INT:t.toFixed(0)}}),this.needsSwap=!1,this.fsQuad=new ba(null)}render(e,t,i,n,r){r&&e.state.buffers.stencil.setTest(!1),this.fsQuad.material=this.materialConvolution,this.convolutionUniforms.tDiffuse.value=i.texture,this.convolutionUniforms.uImageIncrement.value=nh.blurX,e.setRenderTarget(this.renderTargetX),e.clear(),this.fsQuad.render(e),this.convolutionUniforms.tDiffuse.value=this.renderTargetX.texture,this.convolutionUniforms.uImageIncrement.value=nh.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(i),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()}},n2={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}"};nh.blurX=new xe(.001953125,0),nh.blurY=new xe(0,.001953125);var Ea={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}"},jy=class extends vs{constructor(e,t){super(),this.textureID=void 0!==t?t:"tDiffuse",e instanceof cn?(this.uniforms=e.uniforms,this.material=e):e&&(this.uniforms=Ri.clone(e.uniforms),this.material=new cn({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 ba(this.material)}render(e,t,i){this.uniforms[this.textureID]&&(this.uniforms[this.textureID].value=i.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()}},C_=class extends vs{constructor(e,t){super(),this.scene=e,this.camera=t,this.clear=!0,this.needsSwap=!1,this.inverse=!1}render(e,t,i){let n,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?(n=0,r=1):(n=1,r=0),s.buffers.stencil.setTest(!0),s.buffers.stencil.setOp(a.REPLACE,a.REPLACE,a.REPLACE),s.buffers.stencil.setFunc(a.ALWAYS,n,4294967295),s.buffers.stencil.setClear(r),s.buffers.stencil.setLocked(!0),e.setRenderTarget(i),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)}},r2=class extends vs{constructor(){super(),this.needsSwap=!1}render(e){e.state.buffers.stencil.setLocked(!1),e.state.buffers.stencil.setTest(!1)}},i2=class{constructor(e,t){if(this.renderer=e,this._pixelRatio=e.getPixelRatio(),void 0===t){let i=e.getSize(new xe);this._width=i.width,this._height=i.height,(t=new sr(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:Mr})).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 jy(Ea),this.copyPass.material.blending=Qr,this.clock=new ho}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(),i=!1;for(let n=0,r=this.passes.length;n<r;n++){let t=this.passes[n];if(!1!==t.enabled){if(t.renderToScreen=this.renderToScreen&&this.isLastEnabledPass(n),t.render(this.renderer,this.writeBuffer,this.readBuffer,e,i),t.needsSwap){if(i){let t=this.renderer.getContext(),i=this.renderer.state.buffers.stencil;i.setFunc(t.NOTEQUAL,1,4294967295),this.copyPass.render(this.renderer,this.writeBuffer,this.readBuffer,e),i.setFunc(t.EQUAL,1,4294967295)}this.swapBuffers()}void 0!==C_&&(t instanceof C_?i=!0:t instanceof r2&&(i=!1))}}this.renderer.setRenderTarget(t)}reset(e){if(void 0===e){let t=this.renderer.getSize(new xe);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 i=this._width*this._pixelRatio,n=this._height*this._pixelRatio;this.renderTarget1.setSize(i,n),this.renderTarget2.setSize(i,n);for(let r=0;r<this.passes.length;r++)this.passes[r].setSize(i,n)}setPixelRatio(e){this._pixelRatio=e,this.setSize(this._width,this._height)}dispose(){this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.copyPass.dispose()}},jc=class extends vs{constructor(e,t,i,n){super(),this.renderScene=t,this.renderCamera=i,this.selectedObjects=void 0!==n?n:[],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 xe(e.x,e.y):new xe(256,256);let r=Math.round(this.resolution.x/this.downSampleRatio),a=Math.round(this.resolution.y/this.downSampleRatio);this.renderTargetMaskBuffer=new sr(this.resolution.x,this.resolution.y),this.renderTargetMaskBuffer.texture.name="OutlinePass.mask",this.renderTargetMaskBuffer.texture.generateMipmaps=!1,this.depthMaterial=new _c,this.depthMaterial.side=Sr,this.depthMaterial.depthPacking=Cv,this.depthMaterial.blending=Qr,this.prepareMaskMaterial=this.getPrepareMaskMaterial(),this.prepareMaskMaterial.side=Sr,this.prepareMaskMaterial.fragmentShader=function(e,t){let i=t.isPerspectiveCamera?"perspective":"orthographic";return e.replace(/DEPTH_TO_VIEW_Z/g,i+"DepthToViewZ")}(this.prepareMaskMaterial.fragmentShader,this.renderCamera),this.renderTargetDepthBuffer=new sr(this.resolution.x,this.resolution.y,{type:Mr}),this.renderTargetDepthBuffer.texture.name="OutlinePass.depth",this.renderTargetDepthBuffer.texture.generateMipmaps=!1,this.renderTargetMaskDownSampleBuffer=new sr(r,a,{type:Mr}),this.renderTargetMaskDownSampleBuffer.texture.name="OutlinePass.depthDownSample",this.renderTargetMaskDownSampleBuffer.texture.generateMipmaps=!1,this.renderTargetBlurBuffer1=new sr(r,a,{type:Mr}),this.renderTargetBlurBuffer1.texture.name="OutlinePass.blur1",this.renderTargetBlurBuffer1.texture.generateMipmaps=!1,this.renderTargetBlurBuffer2=new sr(Math.round(r/2),Math.round(a/2),{type:Mr}),this.renderTargetBlurBuffer2.texture.name="OutlinePass.blur2",this.renderTargetBlurBuffer2.texture.generateMipmaps=!1,this.edgeDetectionMaterial=this.getEdgeDetectionMaterial(),this.renderTargetEdgeBuffer1=new sr(r,a,{type:Mr}),this.renderTargetEdgeBuffer1.texture.name="OutlinePass.edge1",this.renderTargetEdgeBuffer1.texture.generateMipmaps=!1,this.renderTargetEdgeBuffer2=new sr(Math.round(r/2),Math.round(a/2),{type:Mr}),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=Ea;this.copyUniforms=Ri.clone(s.uniforms),this.materialCopy=new cn({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 ba(null),this.tempPulseColor1=new ct,this.tempPulseColor2=new ct,this.textureMatrix=new et}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 i=Math.round(e/this.downSampleRatio),n=Math.round(t/this.downSampleRatio);this.renderTargetMaskDownSampleBuffer.setSize(i,n),this.renderTargetBlurBuffer1.setSize(i,n),this.renderTargetEdgeBuffer1.setSize(i,n),this.separableBlurMaterial1.uniforms.texSize.value.set(i,n),i=Math.round(i/2),n=Math.round(n/2),this.renderTargetBlurBuffer2.setSize(i,n),this.renderTargetEdgeBuffer2.setSize(i,n),this.separableBlurMaterial2.uniforms.texSize.value.set(i,n)}changeVisibilityOfSelectedObjects(e){let t=this._visibilityCache;function i(i){i.isMesh&&(!0===e?i.visible=t.get(i):(t.set(i,i.visible),i.visible=e))}for(let n=0;n<this.selectedObjects.length;n++)this.selectedObjects[n].traverse(i)}changeVisibilityOfNonSelectedObjects(e){let t=this._visibilityCache,i=[];function n(e){e.isMesh&&i.push(e)}for(let r=0;r<this.selectedObjects.length;r++)this.selectedObjects[r].traverse(n);this.renderScene.traverse((function(n){if(n.isMesh||n.isSprite){let r=!1;for(let e=0;e<i.length;e++)if(i[e].id===n.id){r=!0;break}if(!1===r){let i=n.visible;(!1===e||!0===t.get(n))&&(n.visible=e),t.set(n,i)}}else(n.isPoints||n.isLine)&&(!0===e?n.visible=t.get(n):(t.set(n,n.visible),n.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,i,n,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 n=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=n,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=jc.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=jc.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=jc.BlurDirectionX,e.setRenderTarget(this.renderTargetBlurBuffer2),e.clear(),this.fsQuad.render(e),this.separableBlurMaterial2.uniforms.colorTexture.value=this.renderTargetBlurBuffer2.texture,this.separableBlurMaterial2.uniforms.direction.value=jc.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(i),this.fsQuad.render(e),e.setClearColor(this._oldClearColor,this.oldClearAlpha),e.autoClear=t}this.renderToScreen&&(this.fsQuad.material=this.materialCopy,this.copyUniforms.tDiffuse.value=i.texture,e.setRenderTarget(null),this.fsQuad.render(e))}getPrepareMaskMaterial(){return new cn({uniforms:{depthTexture:{value:null},cameraNearFar:{value:new xe(.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 cn({uniforms:{maskTexture:{value:null},texSize:{value:new xe(.5,.5)},visibleEdgeColor:{value:new D(1,1,1)},hiddenEdgeColor:{value:new D(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 cn({defines:{MAX_RADIUS:e},uniforms:{colorTexture:{value:null},texSize:{value:new xe(.5,.5)},direction:{value:new xe(.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 cn({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:Ec,depthTest:!1,depthWrite:!1,transparent:!0})}};jc.BlurDirectionX=new xe(1,0),jc.BlurDirectionY=new xe(0,1);var s2=class extends vs{constructor(e,t,i,n,r){super(),this.scene=e,this.camera=t,this.overrideMaterial=i,this.clearColor=n,this.clearAlpha=void 0!==r?r:0,this.clear=!0,this.clearDepth=!1,this.needsSwap=!1,this._oldClearColor=new ct}render(e,t,i){let n,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),n=e.getClearAlpha(),e.setClearColor(this.clearColor,this.clearAlpha)),this.clearDepth&&e.clearDepth(),e.setRenderTarget(this.renderToScreen?null:i),this.clear&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),e.render(this.scene,this.camera),this.clearColor&&e.setClearColor(this._oldClearColor,n),void 0!==this.overrideMaterial&&(this.scene.overrideMaterial=r),e.autoClear=a}},P_={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 xe(512,512)},cameraNear:{value:1},cameraFar:{value:100},cameraProjectionMatrix:{value:new et},cameraInverseProjectionMatrix:{value:new et},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}"},yd={defines:{KERNEL_RADIUS:4,DEPTH_PACKING:1,PERSPECTIVE_CAMERA:1},uniforms:{tDiffuse:{value:null},size:{value:new xe(512,512)},sampleUvOffsets:{value:[new xe(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}"},I_={createSampleWeights:function(e,t){let i=[];for(let n=0;n<=e;n++)i.push(Qgt(n,t));return i},createSampleOffsets:function(e,t){let i=[];for(let n=0;n<=e;n++)i.push(t.clone().multiplyScalar(n));return i},configure:function(e,t,i,n){e.defines.KERNEL_RADIUS=t,e.uniforms.sampleUvOffsets.value=I_.createSampleOffsets(t,n),e.uniforms.sampleWeights.value=I_.createSampleWeights(t,i),e.needsUpdate=!0}};function Qgt(e,t){return Math.exp(-e*e/(t*t*2))/(Math.sqrt(2*Math.PI)*t)}var a2={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 vs{constructor(e,t,i=!1,n=!1,r=new xe(256,256)){let a;super(),this.scene=e,this.camera=t,this.clear=!0,this.needsSwap=!1,this.supportsDepthTextureExtension=i,this.supportsNormalTexture=n,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 xe(r.x,r.y),this.saoRenderTarget=new sr(this.resolution.x,this.resolution.y,{type:Mr}),this.blurIntermediateRenderTarget=this.saoRenderTarget.clone(),this.beautyRenderTarget=this.saoRenderTarget.clone(),this.normalRenderTarget=new sr(this.resolution.x,this.resolution.y,{minFilter:Jr,magFilter:Jr,type:Mr}),this.depthRenderTarget=this.normalRenderTarget.clone(),this.supportsDepthTextureExtension&&(a=new ff,a.type=Rv,this.beautyRenderTarget.depthTexture=a,this.beautyRenderTarget.depthBuffer=!0),this.depthMaterial=new _c,this.depthMaterial.depthPacking=Cv,this.depthMaterial.blending=Qr,this.normalMaterial=new mf,this.normalMaterial.blending=Qr,this.saoMaterial=new cn({defines:Object.assign({},P_.defines),fragmentShader:P_.fragmentShader,vertexShader:P_.vertexShader,uniforms:Ri.clone(P_.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 cn({uniforms:Ri.clone(yd.uniforms),defines:Object.assign({},yd.defines),vertexShader:yd.vertexShader,fragmentShader:yd.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 cn({uniforms:Ri.clone(yd.uniforms),defines:Object.assign({},yd.defines),vertexShader:yd.vertexShader,fragmentShader:yd.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 cn({uniforms:Ri.clone(Ea.uniforms),vertexShader:Ea.vertexShader,fragmentShader:Ea.fragmentShader,blending:Qr}),this.materialCopy.transparent=!0,this.materialCopy.depthTest=!1,this.materialCopy.depthWrite=!1,this.materialCopy.blending=Pm,this.materialCopy.blendSrc=Sv,this.materialCopy.blendDst=vf,this.materialCopy.blendEquation=Go,this.materialCopy.blendSrcAlpha=wv,this.materialCopy.blendDstAlpha=vf,this.materialCopy.blendEquationAlpha=Go,this.depthCopy=new cn({uniforms:Ri.clone(a2.uniforms),vertexShader:a2.vertexShader,fragmentShader:a2.fragmentShader,blending:Qr}),this.fsQuad=new ba(null)}render(e,t,i){if(this.renderToScreen&&(this.materialCopy.blending=Qr,this.materialCopy.uniforms.tDiffuse.value=i.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 n=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)&&(I_.configure(this.vBlurMaterial,this.params.saoBlurRadius,this.params.saoBlurStdDev,new xe(0,1)),I_.configure(this.hBlurMaterial,this.params.saoBlurRadius,this.params.saoBlurStdDev,new xe(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=Pm:a.blending=Qr,this.renderPass(e,a,this.renderToScreen?null:i),e.setClearColor(this._oldClearColor,this.oldClearAlpha),e.autoClear=n}renderPass(e,t,i,n,r){e.getClearColor(this.originalClearColor);let a=e.getClearAlpha(),s=e.autoClear;e.setRenderTarget(i),e.autoClear=!1,null!=n&&(e.setClearColor(n),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,i,n,r){e.getClearColor(this.originalClearColor);let a=e.getClearAlpha(),s=e.autoClear;e.setRenderTarget(i),e.autoClear=!1,n=t.clearColor||n,r=t.clearAlpha||r,null!=n&&(e.setClearColor(n),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 o2=class extends vs{constructor(e,t,i,n){super(),this.scene=e,this.camera=t,this.sampleLevel=4,this.unbiased=!0,this.clearColor=void 0!==i?i:0,this.clearAlpha=void 0!==n?n:0,this._oldClearColor=new ct;let r=Ea;this.copyUniforms=Ri.clone(r.uniforms),this.copyMaterial=new cn({uniforms:this.copyUniforms,vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,transparent:!0,depthTest:!1,depthWrite:!1,premultipliedAlpha:!0,blending:Ec}),this.fsQuad=new ba(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,i){this.sampleRenderTarget||(this.sampleRenderTarget=new sr(i.width,i.height,{type:Mr}),this.sampleRenderTarget.texture.name="SSAARenderPass.sample");let n=e0t[Math.max(0,Math.min(this.sampleLevel,5))],r=e.autoClear;e.autoClear=!1,e.getClearColor(this._oldClearColor);let a=e.getClearAlpha(),s=1/n.length;this.copyUniforms.tDiffuse.value=this.sampleRenderTarget.texture;let o={fullWidth:i.width,fullHeight:i.height,offsetX:0,offsetY:0,width:i.width,height:i.height},l=Object.assign({},this.camera.view);l.enabled&&Object.assign(o,l);for(let h=0;h<n.length;h++){let i=n[h];this.camera.setViewOffset&&this.camera.setViewOffset(o.fullWidth,o.fullHeight,o.offsetX+.0625*i[0],o.offsetY+.0625*i[1],o.width,o.height);let r=s;this.unbiased&&(r+=.03125*((h+.5)/n.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)}},e0t=[[[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]]],l2=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,i){return e[0]*t+e[1]*i}dot3(e,t,i,n){return e[0]*t+e[1]*i+e[2]*n}dot4(e,t,i,n,r){return e[0]*t+e[1]*i+e[2]*n+e[3]*r}noise(e,t){let i,n,r,a,s,o=(e+t)*(.5*(Math.sqrt(3)-1)),l=Math.floor(e+o),h=Math.floor(t+o),c=(3-Math.sqrt(3))/6,u=(l+h)*c,d=e-(l-u),p=t-(h-u);d>p?(a=1,s=0):(a=0,s=1);let f=d-a+c,m=p-s+c,g=d-1+2*c,v=p-1+2*c,y=255&l,x=255&h,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?i=0:(S*=S,i=S*S*this.dot(this.grad3[b],d,p));let M=.5-f*f-m*m;M<0?n=0:(M*=M,n=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*(i+n+r)}noise3d(e,t,i){let n,r,a,s,o,l,h,c,u,d,p=.3333333333333333*(e+t+i),f=Math.floor(e+p),m=Math.floor(t+p),g=Math.floor(i+p),v=1/6,y=(f+m+g)*v,x=e-(f-y),b=t-(m-y),_=i-(g-y);x>=b?b>=_?(o=1,l=0,h=0,c=1,u=1,d=0):x>=_?(o=1,l=0,h=0,c=1,u=0,d=1):(o=0,l=0,h=1,c=1,u=0,d=1):b<_?(o=0,l=0,h=1,c=0,u=1,d=1):x<_?(o=0,l=1,h=0,c=0,u=1,d=1):(o=0,l=1,h=0,c=1,u=1,d=0);let w=x-o+v,S=b-l+v,M=_-h+v,E=x-c+2*v,T=b-u+2*v,A=_-d+2*v,C=x-1+.5,P=b-1+.5,R=_-1+.5,D=255&f,L=255&m,I=255&g,O=this.perm[D+this.perm[L+this.perm[I]]]%12,k=this.perm[D+o+this.perm[L+l+this.perm[I+h]]]%12,N=this.perm[D+c+this.perm[L+u+this.perm[I+d]]]%12,U=this.perm[D+1+this.perm[L+1+this.perm[I+1]]]%12,F=.6-x*x-b*b-_*_;F<0?n=0:(F*=F,n=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[k],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*(n+r+a+s)}noise4d(e,t,i,n){let r,a,s,o,l,h=this.grad4,c=this.simplex,u=this.perm,d=(Math.sqrt(5)-1)/4,p=(5-Math.sqrt(5))/20,f=(e+t+i+n)*d,m=Math.floor(e+f),g=Math.floor(t+f),v=Math.floor(i+f),y=Math.floor(n+f),x=(m+g+v+y)*p,b=e-(m-x),_=t-(g-x),w=i-(v-x),S=n-(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=c[M][0]>=3?1:0,T=c[M][1]>=3?1:0,A=c[M][2]>=3?1:0,C=c[M][3]>=3?1:0,P=c[M][0]>=2?1:0,R=c[M][1]>=2?1:0,D=c[M][2]>=2?1:0,L=c[M][3]>=2?1:0,I=c[M][0]>=1?1:0,O=c[M][1]>=1?1:0,k=c[M][2]>=1?1:0,N=c[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-D+2*p,G=S-L+2*p,W=b-I+3*p,X=_-O+3*p,Y=w-k+3*p,q=S-N+3*p,Z=b-1+4*p,Q=_-1+4*p,J=w-1+4*p,K=S-1+4*p,$=255&m,ee=255&g,te=255&v,ie=255&y,ne=u[$+u[ee+u[te+u[ie]]]]%32,re=u[$+E+u[ee+T+u[te+A+u[ie+C]]]]%32,ae=u[$+P+u[ee+R+u[te+D+u[ie+L]]]]%32,se=u[$+I+u[ee+O+u[te+k+u[ie+N]]]]%32,oe=u[$+1+u[ee+1+u[te+1+u[ie+1]]]]%32,le=.6-b*b-_*_-w*w-S*S;le<0?r=0:(le*=le,r=le*le*this.dot4(h[ne],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 ce=.6-H*H-V*V-j*j-G*G;ce<0?s=0:(ce*=ce,s=ce*ce*this.dot4(h[ae],H,V,j,G));let ue=.6-W*W-X*X-Y*Y-q*q;ue<0?o=0:(ue*=ue,o=ue*ue*this.dot4(h[se],W,X,Y,q));let de=.6-Z*Z-Q*Q-J*J-K*K;return de<0?l=0:(de*=de,l=de*de*this.dot4(h[oe],Z,Q,J,K)),27*(r+a+s+o+l)}},D_={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 xe},cameraProjectionMatrix:{value:new et},cameraInverseProjectionMatrix:{value:new et},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}"},O_={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}"},k_={uniforms:{tDiffuse:{value:null},resolution:{value:new xe}},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}"},Kl=class extends vs{constructor(e,t,i,n){super(),this.width=void 0!==i?i:512,this.height=void 0!==n?n: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 ff;r.format=Wh,r.type=xu,this.beautyRenderTarget=new sr(this.width,this.height,{type:Mr}),this.normalRenderTarget=new sr(this.width,this.height,{minFilter:Jr,magFilter:Jr,type:Mr,depthTexture:r}),this.ssaoRenderTarget=new sr(this.width,this.height,{type:Mr}),this.blurRenderTarget=this.ssaoRenderTarget.clone(),this.ssaoMaterial=new cn({defines:Object.assign({},D_.defines),uniforms:Ri.clone(D_.uniforms),vertexShader:D_.vertexShader,fragmentShader:D_.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 mf,this.normalMaterial.blending=Qr,this.blurMaterial=new cn({defines:Object.assign({},k_.defines),uniforms:Ri.clone(k_.uniforms),vertexShader:k_.vertexShader,fragmentShader:k_.fragmentShader}),this.blurMaterial.uniforms.tDiffuse.value=this.ssaoRenderTarget.texture,this.blurMaterial.uniforms.resolution.value.set(this.width,this.height),this.depthRenderMaterial=new cn({defines:Object.assign({},O_.defines),uniforms:Ri.clone(O_.uniforms),vertexShader:O_.vertexShader,fragmentShader:O_.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 cn({uniforms:Ri.clone(Ea.uniforms),vertexShader:Ea.vertexShader,fragmentShader:Ea.fragmentShader,transparent:!0,depthTest:!1,depthWrite:!1,blendSrc:Sv,blendDst:vf,blendEquation:Go,blendSrcAlpha:wv,blendDstAlpha:vf,blendEquationAlpha:Go}),this.fsQuad=new ba(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=$R),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 Kl.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 Kl.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 Kl.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 Kl.OUTPUT.Depth:this.renderPass(e,this.depthRenderMaterial,this.renderToScreen?null:t);break;case Kl.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 Kl.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=Pm,this.renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;default:console.warn("THREE.SSAOPass: Unknown output type.")}}renderPass(e,t,i,n,r){e.getClearColor(this.originalClearColor);let a=e.getClearAlpha(),s=e.autoClear;e.setRenderTarget(i),e.autoClear=!1,null!=n&&(e.setClearColor(n),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,i,n,r){e.getClearColor(this.originalClearColor);let a=e.getClearAlpha(),s=e.autoClear;e.setRenderTarget(i),e.autoClear=!1,n=t.clearColor||n,r=t.clearAlpha||r,null!=n&&(e.setClearColor(n),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 i=0;i<e;i++){let n=new D;n.x=2*Math.random()-1,n.y=2*Math.random()-1,n.z=Math.random(),n.normalize();let r=i/e;r=Rn.lerp(.1,1,r*r),n.multiplyScalar(r),t.push(n)}}generateRandomKernelRotations(){let e=new l2,t=new Float32Array(16);for(let i=0;i<16;i++){let n=2*Math.random()-1,r=2*Math.random()-1,a=0;t[i]=e.noise3d(n,r,a)}this.noiseTexture=new wl(t,4,4,ZR,fa),this.noiseTexture.wrapS=Di,this.noiseTexture.wrapT=Di,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 i=t.get(e);e.visible=i})),t.clear()}};Kl.OUTPUT={Default:0,SSAO:1,Blur:2,Beauty:3,Depth:4,Normal:5};var Mve={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}"},xd=class extends vs{constructor(e,t,i,n){super(),this.strength=void 0!==t?t:1,this.radius=i,this.threshold=n,this.resolution=void 0!==e?new xe(e.x,e.y):new xe(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 sr(r,a,{type:Mr}),this.renderTargetBright.texture.name="UnrealBloomPass.bright",this.renderTargetBright.texture.generateMipmaps=!1;for(let h=0;h<this.nMips;h++){let e=new sr(r,a,{type:Mr});e.texture.name="UnrealBloomPass.h"+h,e.texture.generateMipmaps=!1,this.renderTargetsHorizontal.push(e);let t=new sr(r,a,{type:Mr});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=Mve;this.highPassUniforms=Ri.clone(s.uniforms),this.highPassUniforms.luminosityThreshold.value=n,this.highPassUniforms.smoothWidth.value=.01,this.materialHighPassFilter=new cn({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 xe(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 D(1,1,1),new D(1,1,1),new D(1,1,1),new D(1,1,1),new D(1,1,1)],this.compositeMaterial.uniforms.bloomTintColors.value=this.bloomTintColors;let l=Ea;this.copyUniforms=Ri.clone(l.uniforms),this.blendMaterial=new cn({uniforms:this.copyUniforms,vertexShader:l.vertexShader,fragmentShader:l.fragmentShader,blending:Ec,depthTest:!1,depthWrite:!1,transparent:!0}),this.enabled=!0,this.needsSwap=!1,this._oldClearColor=new ct,this.oldClearAlpha=1,this.basic=new ln,this.fsQuad=new ba(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 i=Math.round(e/2),n=Math.round(t/2);this.renderTargetBright.setSize(i,n);for(let r=0;r<this.nMips;r++)this.renderTargetsHorizontal[r].setSize(i,n),this.renderTargetsVertical[r].setSize(i,n),this.separableBlurMaterials[r].uniforms.invSize.value=new xe(1/i,1/n),i=Math.round(i/2),n=Math.round(n/2)}render(e,t,i,n,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=i.texture,e.setRenderTarget(null),e.clear(),this.fsQuad.render(e)),this.highPassUniforms.tDiffuse.value=i.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=xd.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=xd.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(i),this.fsQuad.render(e)),e.setClearColor(this._oldClearColor,this.oldClearAlpha),e.autoClear=a}getSeperableBlurMaterial(e){let t=[];for(let i=0;i<e;i++)t.push(.39894*Math.exp(-.5*i*i/(e*e))/e);return new cn({defines:{KERNEL_RADIUS:e},uniforms:{colorTexture:{value:null},invSize:{value:new xe(.5,.5)},direction:{value:new xe(.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 cn({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}"})}};xd.BlurDirectionX=new xe(1,0),xd.BlurDirectionY=new xe(0,1);var Rve={uniforms:{tDiffuse:{value:null},resolution:{value:new xe(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"},c2=class{constructor(){this.vertexShader="\n varying vec2 vUv;\n void main( void ) {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position,1.0);\n }",this.fragmentShader="\n uniform vec3 keyColor;\n uniform float similarity;\n uniform float smoothness;\n varying vec2 vUv;\n uniform sampler2D map;\n void main() {\n vec4 videoColor = texture2D(map, vUv);\n\n float Y1 = 0.299 * keyColor.r + 0.587 * keyColor.g + 0.114 * keyColor.b;\n float Cr1 = keyColor.r - Y1;\n float Cb1 = keyColor.b - Y1;\n \n float Y2 = 0.299 * videoColor.r + 0.587 * videoColor.g + 0.114 * videoColor.b;\n float Cr2 = videoColor.r - Y2; \n float Cb2 = videoColor.b - Y2; \n \n float blend = smoothstep(similarity, similarity + smoothness, distance(vec2(Cr2, Cb2), vec2(Cr1, Cb1)));\n gl_FragColor = vec4(videoColor.rgb, videoColor.a * blend); \n }";let e=document.createElement("video");this.webcam=e,navigator.mediaDevices.getUserMedia({video:{width:600,height:400}}).then((t=>{e.srcObject=t,e.onloadedmetadata=()=>{e.setAttribute("autoplay","true"),e.setAttribute("playsinline","true"),e.play()}})).catch((function(e){alert(e.name+": "+e.message)})),this.webcamCanvas=document.createElement("canvas");let t=this.webcamCanvas.getContext("2d");this.canvasCtx=t,t.fillStyle="#000000",t.fillRect(0,0,this.webcamCanvas.width,this.webcamCanvas.height);let i=new Gr(this.webcamCanvas);this.webcamTexture=i,i.minFilter=Pr,i.magFilter=Pr,this.shaderMaterial=new cn({transparent:!0,uniforms:{map:{value:i},keyColor:{value:[0,1,0]},similarity:{value:.3},smoothness:{value:0}},vertexShader:this.vertexShader,fragmentShader:this.fragmentShader})}getShaderMaterial(){return this.shaderMaterial}createWebCamPlane(e=5,t=4){let i=new ui(e,t);return new xt(i,this.shaderMaterial)}animate(){this.webcam.readyState===this.webcam.HAVE_ENOUGH_DATA&&(this.canvasCtx.drawImage(this.webcam,0,0,this.webcamCanvas.width,this.webcamCanvas.height),this.webcamTexture.needsUpdate=!0)}},Xa=new D(1,0,0),op=new D(0,1,0),lp=new D(0,0,1),Ave=new D(0,1,0),F_=new et,Xy=2,To=class extends er{constructor(e=Xa){super(),this.redMaterial=new ln({color:16711680,depthTest:!1}),this.greenMaterial=new ln({color:65280,depthTest:!1}),this.blueMaterial=new ln({color:255,depthTest:!1}),this.highlightMaterial=new ln({color:16776960,depthTest:!1}),this.pickableMaterial=new ln({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 dr;t.setFromUnitVectors(Xa,e),this.applyQuaternion(t)}initOrUpdateByAxis(e){this.clear(),[{actionType:"TranslateX",direction:Xa,material:this.redMaterial},{actionType:"TranslateY",direction:op,material:this.greenMaterial},{actionType:"TranslateZ",direction:lp,material:this.blueMaterial}].forEach((t=>{let{actionType:i,direction:n,material:r}=t,a=this.createTranslateGizmo(i,n,Xy,0===n.angleTo(e)?r:this.pickableMaterial);this.add(a)})),[{actionType:"RotateX",direction:Xa,material:this.redMaterial,degree:90},{actionType:"RotateY",direction:op,material:this.greenMaterial,degree:90},{actionType:"RotateZ",direction:lp,material:this.blueMaterial,degree:90}].forEach((t=>{let{actionType:i,direction:n,material:r,degree:a}=t;if(0!==n.angleTo(e)){let e=this.createRotateGizmo(i,n,Xy,r,a);this.add(e)}})),this.createSphere(1,this.pickableMaterial),this.createSphere(1,this.pickableMaterial,new D(12*Xy,0,0)),this.createSphere(1,this.pickableMaterial,new D(0,12*Xy,0)),this.createSphere(1,this.pickableMaterial,new D(0,0,12*Xy))}createTranslateGizmo(e,t,i,n){let r=t.angleTo(Ave),a=Ave.clone().cross(t);F_.makeRotationAxis(a,r);let s=new Tc(i/5,i/5,20*i),o=10*i;s.translate(0,o,0),s.applyMatrix4(F_);let l=new Tc(0,i,3*i),h=2*o;l.translate(0,h,0),l.applyMatrix4(F_);let c=Ui([l,s]),u=new xt(c,n);return u.layers.enable(12),u.userData.actionType=e,n===this.pickableMaterial&&u.layers.disable(12),u}createRotateGizmo(e,t,i,n,r){let a=new D(0,0,1),s=t.clone().cross(a),o=t.angleTo(a);F_.makeRotationAxis(s,o);let l=new pf(12*i,i/5,24,36,Rn.degToRad(r));l.applyMatrix4(F_);let h=new xt(l,n);return h.layers.enable(12),h.userData.actionType=e,h}createSphere(e,t,i=new D){let n=new Ua(e,32,16),r=new xt(n,t);r.position.copy(i),r.layers.disable(12),this.add(r)}setActiveAxis(e){this.initOrUpdateByAxis(e)}createHoverRotateObjectByAxis(e){let t=Xa;switch(e){case"RotateX":t=Xa;break;case"RotateY":t=op;break;case"RotateZ":t=lp}return this.createRotateGizmo("",t,Xy,this.highlightMaterial,360)}setActive(e,t){var i;let n=t.userData.actionType;["RotateX","RotateY","RotateZ"].includes(n)?e?(this.hoverObject=this.createHoverRotateObjectByAxis(n),this.add(this.hoverObject),t.visible=!1):(null==(i=this.hoverObject)||i.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 D;this.getWorldPosition(t);let i=e.position,n=1;e instanceof Nr?n=(e.top-e.bottom)/e.zoom:e instanceof hr&&(n=t.distanceTo(i)*Math.min(1.9*Math.tan(Math.PI*e.fov/360)/e.zoom,7)),this.scale.set(1,1,1).multiplyScalar(n/180)}},cp=class{constructor(e,t){if(this.raycaster=new na,this.sectionBox=new Nt,this.lastWorldPos=new D,this.mouseMoved=!1,this.dragStarted=!1,this.refrencePlane=new zr,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),i="default";t&&(this.selectedObject=t.object,this.activateSelectedObject(!0),i="grab"),this.inputManager.setCursor(i)}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()},!(e.camera&&e.renderer&&e.controls&&e.scene))throw new Error("Invalid bimViewer!");this.viewer=e,this.inputManager=t,this.scene=e.scene,this.renderer=e.renderer,this.raycaster.layers.set(12)}get canvas(){var e;return null==(e=this.viewer.renderer)?void 0:e.domElement}get isActive(){return!!this.active}get camera(){return this.viewer.camera}get controls(){return this.viewer.controls}setGlobalClippingEnabled(e){if(!this.clipPlanes)return;let t=e?this.clipPlanes:[];this.renderer.localClippingEnabled=e,this.renderer.clippingPlanes=t}setObjectClippingEnabled(e){var t,i;if(!this.clipPlanes||null==(t=this.clippingObjetIds)||!t.length)return;this.renderer.localClippingEnabled=e;let n=e?this.clipPlanes:[];null==(i=this.clippingObjetIds)||i.forEach((e=>{let t=this.scene.getObjectById(e);t&&t.traverse((e=>{e.material&&(Array.isArray(e.material)?e.material.forEach((e=>{e.clippingPlanes=n,e.clipIntersection=!1})):e.material&&(e.material.clippingPlanes=n,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(){var e;this.inputManager.removeEventListener("pointerdown",this.mousedown),this.inputManager.removeEventListener("pointermove",this.mousemove),this.inputManager.removeEventListener("pointerup",this.mouseup),this.inputManager.removeEventListener("keydown",this.keydown),null==(e=this.selectedObject)||e.removeFromParent(),this.selectedObject=void 0,this.dragStarted=!1,this.active=!1,this.inputManager.setCursor("default"),this.setControlsEnabled(!0)}setControlsEnabled(e){this.controls.enableRotate=e,this.controls.azimuthRotateSpeed=Number(e),this.controls.polarRotateSpeed=Number(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 To))||t[0]}updateRaycasterByMouse(e){if(!this.raycaster)return;let t=new xe(e.x,e.y),i=an.screen2Ndc(t,this.camera,this.canvas);this.raycaster.setFromCamera(i,this.camera)}destroy(){this.deactivate()}},Pve=new Nt,Ive=new dr,u2=class extends xt{constructor(e,t){super(),this.vertices=[],this.layers.enable(12),this.actionType=e,this.geometry=new Dt,this.vertices=t,this.geometry.setFromPoints(t),this.geometry.setIndex([0,1,2,0,2,3]),this.material=new ln({depthTest:!1,color:u2.normalPlaneColor,transparent:!0,opacity:.01,side:Sr}),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 Dt;t.setFromPoints(e),t.setIndex([0,1,1,2,2,3,3,0]);let i=new Gn({color:u2.normalLineColor});return this.createIgnoreClipMaterials(i),new fr(t,i)}update(e){this.geometry.setFromPoints(e),this.geometry.computeBoundingSphere(),this.geometry.computeVertexNormals(),this.edge.geometry.setFromPoints(e),this.vertices=e}rotatePlane(e,t){let i=this.getPlaneCenter();Ive.setFromAxisAngle(e,t),this.vertices=this.vertices.map((e=>e.sub(i).applyQuaternion(Ive).add(i))),this.update(this.vertices)}setDirection(e){let t=new dr;t.setFromUnitVectors(Xa,e);let i=this.getPlaneCenter();this.vertices=this.vertices.map((e=>e.sub(i).applyQuaternion(t).add(i))),this.update(this.vertices)}getPlaneNormal(){let[e,t,i]=this.vertices,n=new D;return Zr.getNormal(e,t,i,n),n}setActive(e){this.material.opacity=e?.1:.01}getPlaneCenter(){Pve.setFromPoints(this.vertices);let e=new D;return Pve.getCenter(e),e}},Fi=u2;Fi.normalPlaneColor=new ct(0,.855,.718),Fi.activePlaneColor=new ct(1,1,0),Fi.normalLineColor=16777215;var Lve=(e=>(e.X="X",e.Y="Y",e.Z="Z",e))(Lve||{}),h2=class extends cp{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 To&&(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),i="default";t&&(this.selectedObject=t.object,this.activateSelectedObject(!0),this.selectedObject.parent instanceof To&&(i="grab")),this.inputManager.setCursor(i)}this.viewer.enableRender()},this.center=new D,this.axisInfoMap={X:{normal:new D(1,0,0)},Y:{normal:new D(0,1,0)},Z:{normal:new D(0,0,1)}},this.viewer.addEventListener("BeforeRender",(()=>{var e;this.isActive&&(null==(e=this.gizmo)||e.adjustSize(this.camera))}))}activate(){super.activate(),this.sectionBox&&this.sectionBox.getCenter(this.center),this.setActiveAxis("X")}deactivate(){var e,t;super.deactivate(),null==(e=this.planeMesh)||e.removeFromParent(),null==(t=this.gizmo)||t.removeFromParent(),this.planeMesh=void 0,this.gizmo=void 0}resetSection(){var e,t;null==(e=this.planeMesh)||e.removeFromParent(),null==(t=this.gizmo)||t.removeFromParent(),this.setClippingEnabled(!1),this.planeMesh=void 0,this.gizmo=void 0,this.setActiveAxis("X")}setActiveAxis(e){this.activeAxis=e,this.initOrUpdateGizmo(),this.initOrUpdateSectionPlaneMeshes(),this.initOrUpdateClipPlanes(),this.setClippingEnabled(!0),this.viewer.enableRender()}setSectionPlaneMeshVisible(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":this.clipPlane=new zr(new D(-1,0,0),this.center.x);break;case"Y":this.clipPlane=new zr(new D(0,-1,0),this.center.y);break;case"Z":this.clipPlane=new zr(new D(0,0,-1),this.center.z)}this.clipPlane&&(this.clipPlanes=[this.clipPlane])}initOrUpdateSectionPlaneMeshes(){var e;let t=new D;this.sectionBox.getSize(t);let i=t.length(),n=this.center,r=(new Nt).setFromCenterAndSize(n,new D(i,i,i)),{min:a,max:s}=r;switch(null==(e=this.planeMesh)||e.removeFromParent(),this.activeAxis){case"X":this.planeMesh=new Fi("X",[new D(n.x,s.y,a.z),new D(n.x,s.y,s.z),new D(n.x,a.y,s.z),new D(n.x,a.y,a.z)]);break;case"Y":this.planeMesh=new Fi("Y",[new D(s.x,n.y,a.z),new D(a.x,n.y,a.z),new D(a.x,n.y,s.z),new D(s.x,n.y,s.z)]);break;case"Z":this.planeMesh=new Fi("Z",[new D(s.x,s.y,n.z),new D(a.x,s.y,n.z),new D(a.x,a.y,n.z),new D(s.x,a.y,n.z)])}this.planeMesh&&this.scene.add(this.planeMesh),this.viewer.enableRender()}initOrUpdateGizmo(){var e,t;null==(e=this.gizmo)||e.removeFromParent();let i=this.axisInfoMap[this.activeAxis].normal,n=new To;n.setDirection(i),this.sectionBox.getCenter(n.position),n.adjustSize(this.camera),null==(t=this.scene)||t.add(n),this.gizmo=n}onDragStart(e){var t;if(this.selectedObject instanceof Fi)return;se.info("[AxisPlaneSection] onDragStart:",e);let i=new D;this.sectionBox.getCenter(i),this.refrencePlane.setFromNormalAndCoplanarPoint(this.camera.getWorldDirection(this.refrencePlane.normal),i),null==(t=this.raycaster)||t.ray.intersectPlane(this.refrencePlane,this.lastWorldPos)}onDragMove(e){var t,i,n;if(!this.lastWorldPos||!this.selectedObject||!this.clipPlane||!this.planeMesh||!this.gizmo||this.selectedObject&&this.selectedObject instanceof Fi)return;let r=new D;null==(t=this.raycaster)||t.ray.intersectPlane(this.refrencePlane,r);let a=this.selectedObject.userData.actionType,s=(new D).subVectors(this.lastWorldPos,this.center).normalize(),o=(new D).subVectors(r,this.center).normalize(),l=(new D).subVectors(r,this.lastWorldPos).projectOnVector(Xa.clone().applyQuaternion(this.gizmo.quaternion)),h=s.angleTo(o),c=(new D).crossVectors(s,o),u=new D;this.sectionBox.getSize(u);let d,p=Math.max(u.x,u.y,u.z);switch(a){case"TranslateX":case"TranslateY":case"TranslateZ":d=(new D).addVectors(this.gizmo.position,l),this.sectionBox.clone().setFromCenterAndSize(this.center,new D(p,p,p)).containsPoint(d)&&(null==(i=this.gizmo)||i.position.add(l),null==(n=this.planeMesh)||n.position.add(l));break;case"RotateX":{let e=Xa.clone().applyQuaternion(this.gizmo.quaternion);c.dot(e)<0&&(h=-h),this.gizmo.rotateX(h),this.planeMesh.rotatePlane(e,h)}break;case"RotateY":{let e=op.clone().applyQuaternion(this.gizmo.quaternion);c.dot(e)<0&&(h=-h),this.gizmo.rotateY(h),this.planeMesh.rotatePlane(e,h)}break;case"RotateZ":{let e=lp.clone().applyQuaternion(this.gizmo.quaternion);c.dot(e)<0&&(h=-h),this.gizmo.rotateZ(h),this.planeMesh.rotatePlane(e,h)}}this.clipPlane.setFromNormalAndCoplanarPoint(this.planeMesh.getPlaneNormal().negate(),this.gizmo.position),this.lastWorldPos=r}onDragEnd(e){this.selectedObject instanceof Fi||se.info("[AxisPlaneSection] onDragEnd:",e)}getIntersectObjects(){return this.planeMesh&&this.gizmo?[this.planeMesh,this.gizmo]:[]}activateSelectedObject(e){this.selectedObject&&(this.selectedObject instanceof Fi?this.selectedObject.setActive(e):this.selectedObject.parent instanceof To&&this.selectedObject.parent.setActive(e,this.selectedObject))}},t0t=new D(1,0,0),n0t=new D(0,1,0),r0t=new D(0,0,1),d2=class extends cp{constructor(e,t){super(e,t),this.sectionRange={}}activate(){super.activate();let e=this.viewer.getBBox();if(e){let{min:t,max:i}=e;this.sectionRange={x:[t.x,i.x],y:[t.y,i.y],z:[t.z,i.z]}}this.initOrUpdateClipPlanes(),this.initOrUpdateVertices(),this.initOrUpdateSectionPlaneMeshes(),this.setClippingEnabled(!0)}deactivate(){super.deactivate(),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 D(t.x,t.y,t.z),new D(e.x,t.y,t.z),new D(e.x,e.y,t.z),new D(t.x,e.y,t.z),new D(t.x,t.y,e.z),new D(e.x,t.y,e.z),new D(e.x,e.y,e.z),new D(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 zr(new D(-1,0,0),t.x),new zr(new D(1,0,0),-e.x),new zr(new D(0,-1,0),t.y),new zr(new D(0,1,0),-e.y),new zr(new D(0,0,-1),t.z),new zr(new D(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 Fi("Right",[e[4],e[0],e[3],e[7]]),new Fi("Left",[e[1],e[5],e[6],e[2]]),new Fi("Top",[e[4],e[5],e[1],e[0]]),new Fi("Bottom",[e[6],e[7],e[3],e[2]]),new Fi("Front",[e[0],e[1],e[2],e[3]]),new Fi("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&&(se.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 i=new D;null==(t=this.raycaster)||t.ray.intersectPlane(this.refrencePlane,i);let n=this.selectedObject.actionType;switch(n){case"Top":case"Bottom":this.dragTranslateSectionPlane(n0t,this.lastWorldPos,i,n);break;case"Left":case"Right":this.dragTranslateSectionPlane(t0t,this.lastWorldPos,i,n);break;case"Front":case"Back":this.dragTranslateSectionPlane(r0t,this.lastWorldPos,i,n)}this.lastWorldPos=i}onDragEnd(e){se.info("[ObjectsBoxSection] onDragEnd:",e)}dragTranslateSectionPlane(e,t,i,n){let r,{min:a,max:s}=this.sectionBox,o=i.clone().sub(t).projectOnVector(e);switch(n){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||[]}resetSection(){this.sectionBox=this.viewer.getBBox(),this.initOrUpdateVertices(),this.initOrUpdateSectionPlaneMeshes(),this.initOrUpdateClipPlanes(),this.viewer.enableRender()}setSectionPlaneMeshVisible(e){var t;null==(t=this.planeMeshes)||t.forEach((t=>t.visible=e)),this.showSectionPlane=e,this.viewer.enableRender()}},f2=class extends cp{constructor(e,t){super(e,t),this.mousedown=e=>{var t;if(0===e.button){if(!this.faceInfo){let i=this.pickFace(e);if(i&&i.face){let e=i.face.normal,n=new Ln;e.applyNormalMatrix(n.getNormalMatrix(i.object.matrixWorld)),this.faceInfo={position:i.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 To&&(this.inputManager.setCursor("grabbing"),this.dragStarted=!0,this.setControlsEnabled(!1),this.onDragStart(e),this.viewer.enableRender())}},this.mousemove=e=>{var t,i;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),i="default";t&&(this.selectedObject=t.object,this.activateSelectedObject(!0),this.selectedObject.parent instanceof To&&(i="grab")),this.inputManager.setCursor(i)}this.viewer.enableRender()}else this.pickFace(e)?null==(t=this.tooltip)||t.show():null==(i=this.tooltip)||i.hide()},this.center=new D,this.viewer.addEventListener("BeforeRender",(()=>{var e;this.isActive&&(null==(e=this.gizmo)||e.adjustSize(this.camera))}))}activate(){super.activate(),this.sectionBox.getCenter(this.center),this.tooltip=new Xl("pick-section-plane",Qu("Tooltip.section"),{parentNode:this.viewer.widgetContainer,followPointer:!0})}deactivate(){var e,t,i;super.deactivate(),null==(e=this.planeMesh)||e.removeFromParent(),null==(t=this.gizmo)||t.removeFromParent(),this.planeMesh=void 0,this.gizmo=void 0,this.faceInfo=void 0,null==(i=this.tooltip)||i.destroy(),this.tooltip=void 0}setSection(){this.initOrUpdateGizmo(),this.initOrUpdateSectionPlaneMeshes(),this.initOrUpdateClipPlanes(),this.setClippingEnabled(!0),this.viewer.enableRender()}resetSection(){var e,t,i;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==(i=this.tooltip)||i.show(),this.viewer.enableRender()}setSectionPlaneMeshVisible(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 zr).setFromNormalAndCoplanarPoint(e.clone().negate(),t),this.clipPlane&&(this.clipPlanes=[this.clipPlane])}initOrUpdateSectionPlaneMeshes(){var e;if(!this.faceInfo)return;let{normal:t,position:i}=this.faceInfo,n=new D;this.sectionBox.getSize(n);let r=n.length(),a=i,s=(new Nt).setFromCenterAndSize(a,new D(r,r,r)),{min:o,max:l}=s;null==(e=this.planeMesh)||e.removeFromParent(),this.planeMesh=new Fi("Plane",[new D(a.x,l.y,o.z),new D(a.x,l.y,l.z),new D(a.x,o.y,l.z),new D(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:i,position:n}=this.faceInfo,r=new To;r.setDirection(i),r.position.copy(n),r.adjustSize(this.camera),null==(t=this.scene)||t.add(r),this.gizmo=r}onDragStart(e){var t;if(!this.faceInfo||this.selectedObject instanceof Fi)return;se.info("[PickPlaneSection] onDragStart:",e);let{position:i}=this.faceInfo;this.refrencePlane.setFromNormalAndCoplanarPoint(this.camera.getWorldDirection(this.refrencePlane.normal),i),null==(t=this.raycaster)||t.ray.intersectPlane(this.refrencePlane,this.lastWorldPos)}onDragMove(e){var t,i,n;if(!this.lastWorldPos||!this.selectedObject||!this.clipPlane||!this.planeMesh||!this.gizmo||!this.faceInfo||this.selectedObject&&this.selectedObject instanceof Fi)return;let r=new D;null==(t=this.raycaster)||t.ray.intersectPlane(this.refrencePlane,r);let a=this.selectedObject.userData.actionType,{position:s}=this.faceInfo,o=(new D).subVectors(this.lastWorldPos,s).normalize(),l=(new D).subVectors(r,s).normalize(),h=(new D).subVectors(r,this.lastWorldPos).projectOnVector(Xa.clone().applyQuaternion(this.gizmo.quaternion)),c=o.angleTo(l),u=(new D).crossVectors(o,l),d=new D;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 D).addVectors(this.gizmo.position,h),this.sectionBox.clone().setFromCenterAndSize(this.center,new D(f,f,f)).containsPoint(p)&&(null==(i=this.gizmo)||i.position.add(h),null==(n=this.planeMesh)||n.position.add(h));break;case"RotateX":{let e=Xa.clone().applyQuaternion(this.gizmo.quaternion);u.dot(e)<0&&(c=-c),this.gizmo.rotateX(c),this.planeMesh.rotatePlane(e,c)}break;case"RotateY":{let e=op.clone().applyQuaternion(this.gizmo.quaternion);u.dot(e)<0&&(c=-c),this.gizmo.rotateY(c),this.planeMesh.rotatePlane(e,c)}break;case"RotateZ":{let e=lp.clone().applyQuaternion(this.gizmo.quaternion);u.dot(e)<0&&(c=-c),this.gizmo.rotateZ(c),this.planeMesh.rotatePlane(e,c)}}this.clipPlane.setFromNormalAndCoplanarPoint(this.planeMesh.getPlaneNormal().negate(),this.gizmo.position),this.lastWorldPos=r}onDragEnd(e){this.selectedObject instanceof Fi||se.info("[PickPlaneSection] onDragEnd:",e)}getIntersectObjects(){return this.planeMesh&&this.gizmo?[this.planeMesh,this.gizmo]:[]}activateSelectedObject(e){this.selectedObject&&(this.selectedObject instanceof Fi?this.selectedObject.setActive(e):this.selectedObject.parent instanceof To&&this.selectedObject.parent.setActive(e,this.selectedObject))}pickFace(e){if(!this.raycaster)return;let t=new xe(e.x,e.y),i=an.screen2Ndc(t,this.camera,this.canvas);this.raycaster.setFromCamera(i,this.camera);let n=[];return this.viewer.loadedModels.forEach((e=>{let t=e.object;t&&t.visible&&n.push(t)})),(this.raycaster.intersectObjects(this.viewer.getRaycastableObjectsByMouse(e))||[]).find((e=>{let t=e.object;return t.visible&&t instanceof xt}))}},Q4=class extends or{constructor(e){super(e,{id:Q4.DEFAULT_ID}),this.sections={},this.viewer=e;let t=e.getInputManager();t&&(this.sections.ObjectsBoxSection=new d2(e,t),this.sections.AxisPlaneSection=new h2(e,t),this.sections.PickPlaneSection=new f2(e,t))}get raycaster(){return this.viewer.getRaycaster()}activate(e){this.activeSectionType&&this.deactivate(),this.activeSectionType=e,this.sections[e].activate()}deactivate(){let e=this.activeSectionType;e&&this.sections[e].deactivate(),this.activeSectionType=void 0}resetSection(){}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(),this.activeSectionType=void 0}},dg=Q4;dg.DEFAULT_ID="SectionPlugin";var Dve=new D,Ove=new vr,kve=class extends tp{constructor(e,t){var i;super(e),this.name="BimViewer",this.timer=Date.now(),this.enableSelection=!0,this.selectedObject=void 0,this.loadedModels=[],this.composerRenderEnabled=!0,this.composerEnabled=!1,this.savedMaterialsForOpacity=[],this.raf=new $f,this.clock=new ho,this.renderEnabled=!0,this.enableModelLevelFrustumCulling=!0,this.isFrustumInsectChecking=!1,this.settings=Wv,this.twoDModelCount=0,this.enableFastOperation=!0,this.edgesVisible=!0,this.distanceCullingFactor=150,this.operationTimeoutMs=500,this.bbox=new Nt,this.onResize=()=>{this.viewerContainer&&this.viewerContainer.parentElement&&this.resize(this.viewerContainer.parentElement.clientWidth,this.viewerContainer.parentElement.clientHeight)},this.onKeyDown=e=>{let t=this.camera,i=this.controls;if(!t||!i)return;let n=this.settings.keyboard.sensitivity||3,r=i.getPosition(new D),a=i.getTarget(new D),s=a.clone();if("ArrowLeft"===e.code||"ArrowRight"===e.code){let t=Math.PI*n/180;"ArrowLeft"===e.code&&(t=-t),s.x=(a.x-r.x)*Math.cos(t)-(a.z-r.z)*Math.sin(t)+r.x,s.z=(a.z-r.z)*Math.cos(t)+(a.x-r.x)*Math.sin(t)+r.z,i.setLookAt(r.x,r.y,r.z,s.x,s.y,s.z,!0)}else if("ArrowUp"===e.code||"ArrowDown"===e.code){let t=Math.PI*n/180,o=new D(a.x-r.x,a.y-r.y,a.z-r.z).length(),l=a.y-r.y;"ArrowDown"===e.code&&(t=-t);let h=Math.asin(l/o)+t;if(h<-Math.PI/2||h>Math.PI/2)return;let c=Math.sin(h)*o;s.y=a.y+(c-l),i.setLookAt(r.x,r.y,r.z,s.x,s.y,s.z,!0)}else if("KeyW"===e.code){let e=.01*n,s=r.distanceTo(a);if(s<10*t.near){let e=i.getTarget(new D).lerp(r,-t.near/s);i.setTarget(e.x,e.y,e.z)}r.lerp(a,e),i.setLookAt(r.x,r.y,r.z,a.x,a.y,a.z)}else if("KeyS"===e.code){let e=.01*n;r.lerp(a,-e),i.setLookAt(r.x,r.y,r.z,a.x,a.y,a.z,!1)}else"KeyF"===e.code?this.flyToSelectedObject():"KeyY"===e.code?this.flyTo(r,a.clone().setY(r.y)):"KeyR"===e.code&&this.flyToRandomObject();this.enableRender()},this.enableRender=(e=1e3)=>{this.renderEnabled=!0,this.raf&&(this.timeoutSymbol&&this.raf.clearTimeout(this.timeoutSymbol),this.timeoutSymbol=this.raf.setTimeout((()=>{this.renderEnabled=!1,this.composerRenderEnabled=!0}),e))},this.applyOptionsAndAddToScene=(e,t,i,n)=>ft(this,null,(function*(){let r=St.getUpdateProgressFunc(n),a=St.getUpdateSubProgressFunc(70,90,n);r(0),se.info(`[Viewer] '${e}' is loaded in ${(Date.now()-this.timer)/1e3}s, adding to scene...`),this.timer=Date.now();let s,o=i.src&&i.src.toLowerCase();if(o&&o.endsWith("dxf")&&this.twoDModelCount++,i.matrix&&16===i.matrix.length){let e=new et;e.elements=i.matrix,t.applyMatrix4(e)}if(t.matrixAutoUpdate=!1,t.updateMatrix(),t.traverse((e=>{e.matrixAutoUpdate&&(e.matrixAutoUpdate=!1,e.updateMatrix())})),i.merge&&this.merge(t),r(50),i.merge){let e=Date.now();Qf.createMeshBvhAsync([t],{saveOriginalIndex:!0}),se.info(`[Viewer] Creates mesh bvh cost ${(Date.now()-e)/1e3}s`)}r(60),t.traverse((e=>{e.isMesh&&(e.castShadow=!0,e.receiveShadow=!0,e.userData.surfaceArea=this.calculateMeshSurfaceArea(e)),e.geometry&&e.layers.enableAll(),e instanceof Gs&&(e.visible=!1)})),r(70),i.edges&&(s=yield Hn.createOutlines(t,void 0,a)),r(90);let l={modelId:this.getUniqueModelId(i.modelId||i.src),object:t,edges:s};this.addModel(l),r(100)})),this.onAnchorPointerDown=e=>{var t,i;null==(t=this.controls)||!t.enableRotate||!this.renderer||null!=(i=this.sectionPlugin)&&i.isActive()||this.setOrbitPoint(e)},this.onAnchorPointerUp=()=>{this.anchor&&(this.anchor.className="anchor"),!this.viewerContainer||!this.camera||this.controls},this.onOperation=()=>{let e=this.renderer;if(!this.enableFastOperation||!e)return;let t=e=>{let t=this.renderer;void 0!==t.distanceCullingFactor&&(t.distanceCullingFactor=e)},i=e=>{this.loadedModels.forEach((t=>{t.edges&&t.edges.forEach((t=>t.visible=e))})),this.edgesVisible=e},n=e=>{let t=this.directionalLight;t&&(t.castShadow=e)};t(this.distanceCullingFactor),this.edgesVisible&&i(!1),n(!1),this.operationTimeout&&clearTimeout(this.operationTimeout),this.operationTimeout=setTimeout((()=>{this.operationTimeout=void 0,n(!0),i(!0),t(0),this.enableRender()}),this.operationTimeoutMs)},this.viewerCfg=Tr(Tr({},lde),e),se.info("[Viewer]","viewerCfg:",this.viewerCfg),this.settings=Wv,this.cameraCfg=t,this.cameraCfg&&this.cameraCfg.near&&(this.settings.camera.near=this.cameraCfg.near),this.cameraCfg&&this.cameraCfg.far&&(this.settings.camera.far=this.cameraCfg.far),this.increaseJobCount(),this.init(),this.animate(),this.renderer&&(null==(i=this.viewerContainer)||i.append(this.renderer.domElement)),this.decreaseJobCount(),se.info(`[Viewer] Initialized in ${(Date.now()-this.timer)/1e3}s`)}init(){let e=this.viewerCfg;this.initThree(),Fn.isBrowser&&!e.context&&this.initDom(),this.initEvents(),this.initControls()}initThree(){this.initScene(),this.initRenderer(),this.initCamera(),this.initLights()}initDom(){let e=this.viewerCfg;this.initSpinner(),this.initCSS2DRenderer(),this.initOthers(),!0===e.enableAxisGizmo&&se.warn("[Viewer] enableAxisGizmo is deprecated, use AxisGizmoPlugin instead!"),!0===e.enableStats&&se.warn("[Viewer] enableStats is deprecated, use StatsPlugin instead!"),e.enableToolbar&&se.warn("[Viewer] enableToolbar is deprecated, use ToolbarPlugin instead!"),e.enableBottomBar&&se.warn("[Viewer] enableBottomBar is deprecated, use BottomBarPlugin instead!"),e.enableNavCube&&se.warn("[Viewer] enableNavCube is deprecated, use NavCubePlugin instead!"),e.enableProgressBar&&(this.loadingProgressBar=this.initLoadingProgressBar()),e.enableContextMenu&&se.warn("[Viewer] enableContextMenu is deprecated, use ContextMenuPlugin instead!"),null!=e.enableSelection&&(this.enableSelection=e.enableSelection)}initScene(){this.scene=new Si,this.scene.matrixAutoUpdate=!1}initRenderer(){this.renderer=new Ts({antialias:!0,preserveDrawingBuffer:!0}),this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setSize(this.width,this.height),this.renderer.outputColorSpace=en,this.renderer.toneMappingExposure=1,this.renderer.useLegacyLights=!1,this.renderer.setClearColor(11119017,1),this.renderer.shadowMap.enabled=!0,this.renderer.shadowMap.type=Tv,this.renderer.shadowMap.autoUpdate=!1,St.printGpuInfo(this.renderer.getContext()),this.pmremGenerator=new Yh(this.renderer),this.pmremGenerator.compileEquirectangularShader(),this.enableOverlayRenderer&&(this.overlayRender=new Un(this)),this.setEnvironmentFromDataArray()}initCSS2DRenderer(){var e;let t=new Nu;t.setSize(this.width,this.height),t.domElement.style.height="0",t.domElement.style.width="0",t.domElement.style.position="absolute",t.domElement.style.top="0",t.domElement.style.left="0",t.domElement.style.overflow="visible",t.domElement.classList.add("css2d-renderer"),null==(e=this.viewerContainer)||e.appendChild(t.domElement),this.css2dRenderer=t}initCamera(){this.scene&&(this.perspectiveCamera=new hr(45,this.width/this.height,this.settings.camera.near,this.settings.camera.far),this.perspectiveCamera.position.set(0,100,0),this.scene.add(this.perspectiveCamera),this.camera=this.perspectiveCamera)}initControls(e=!1){if(!this.renderer)return;Fn.printDeviceInfo();let t,i=e?this.orthoCamera:this.perspectiveCamera;i&&this.inputManager&&((!this.perspectiveCameraControls||!this.orthoCameraConrols)&&(t=new va(i,this.inputManager),t.dollySpeed=.3,t.dollyToCursor=!0,t.infinityDolly=!0,t.enabled=!0,t.keyTruckSpeed=10,t.restThreshold=0,t.smoothTime=.05,t.keys={left:"KeyD",up:"KeyE",right:"KeyA",bottom:"KeyQ"},t.listenToKeyEvents(),t.update(0)),t&&(e?(this.orthoCameraConrols=t,t.minZoom=3):(this.perspectiveCameraControls=t,this.bbox&&(t.minDistance=.1,t.maxDistance=10*this.bbox.getSize(new D).length())),this.controls=t,this.enableFastOperation&&t.addEventListener("control",this.onOperation)))}initRotateToCursor(){this.anchor=this.createAnchor()}initLights(){if(!this.scene)return;let e=16777215,t=new qs(e,1.5);t.name="sun",t.castShadow=!0,t.position.set(-2,2,4),t.shadow.autoUpdate=!1,t.shadow.mapSize.width=1024,t.shadow.mapSize.height=1024,this.directionalLight=t,this.scene.add(t),this.scene.add(t.target),this.directionalLightHelper=new Bb(this.directionalLight),this.directionalLightHelper.visible=!1,this.scene.add(this.directionalLightHelper),this.shadowCameraHelper=new Ub(this.directionalLight.shadow.camera),this.shadowCameraHelper.visible=!1,this.scene.add(this.shadowCameraHelper),this.ambientLight=new Cl(e),this.hemisphereLight=new Du(e,14540253,.2),this.hemisphereLight.position.set(0,300,0),this.scene.add(this.ambientLight),this.scene.add(this.hemisphereLight)}initEvents(){if(!this.renderer||!this.viewerContainer)return;let e=new Ko(this.viewerContainer);this.inputManager=e;let t=!1,i=!1,n=0,r=0,a=0,s=e=>-1!==r&&-1!==a&&Math.abs(e.x-r)<5&&Math.abs(e.y-a)<5;e.addEventListener("pointerdown",(e=>{i=!1,t=!0,0===e.button&&this.onAnchorPointerDown(e)})),e.addEventListener("pointermove",(e=>{t&&(i=!s(e))})),e.addEventListener("pointerup",(e=>{if(t=!1,i)return i=!1,void this.onAnchorPointerUp();if(0===e.button)if((e=>{let t=e.timestamp-n;return!!(0===e.button&&t<300&&s(e))})(e)){let t=this.getClickedObject(e);t?this.flyToObject(t):this.viewFitAll(),n=0,r=-1,a=-1}else n=e.timestamp,r=e.x,a=e.y,this.handleMouseClick(e);else e.button;this.onAnchorPointerUp()})),e.addEventListener("keydown",(e=>{this.onKeyDown(e)})),this.initRotateToCursor(),this.raycaster=new na}initOthers(){!this.scene||!this.renderer||!this.camera||(this.renderer.domElement.style.outlineWidth="0")}initLoadingProgressBar(){return new Yf(this.widgetContainer)}sycnCameraAndControls(e){let t=e?this.orthoCamera:this.perspectiveCamera,i=e?this.perspectiveCameraControls:this.orthoCameraConrols,n=e?this.orthoCameraConrols:this.perspectiveCameraControls,r=new D;i.getPosition(r),n.setPosition(r.x,r.y,r.z);let a=i.getTarget(new D);if(n.setTarget(a.x,a.y,a.z),e){let e=t;e.zoom=10,e.updateProjectionMatrix()}}setToOrthographicCamera(e=!1){var t;if(!this.scene||!this.controls)return;let i=this.perspectiveCamera,n=this.perspectiveCameraControls,r=this.orthoCamera,a=this.orthoCameraConrols;e?(r||(r=new Nr(-this.width/2,this.width/2,this.height/2,-this.height/2,this.settings.camera.near,this.settings.camera.far),r.position.set(0,100,0),r.zoom=10,r.updateProjectionMatrix(),this.scene.add(r),this.orthoCamera=r,this.frustumSize=this.width),a||(this.initControls(!0),a=this.orthoCameraConrols),this.camera=r,this.controls=a):(this.camera=i,this.controls=n),this.sycnCameraAndControls(e),this.resize(this.width,this.height),null==(t=this.composer)||t.passes.forEach((e=>{e.camera&&(e.camera=this.camera)})),this.dispatchEvent("CameraChanged")}animate(){var e,t,i;if(this.minFrameInterval>0&&Date.now()-this.lastFrameExecuteTime<this.minFrameInterval)return void(this.requestAnimationFrameHandle=requestAnimationFrame(this.animate.bind(this)));let n=this.clock.getDelta(),r=null==(e=this.controls)?void 0:e.update(n);if(null==(t=this.webcam)||t.animate(),this.scene&&this.camera){if(this.viewerContainer){let{width:e,height:t}=this.viewerContainer.getBoundingClientRect();(this.width!==e||this.height!==t)&&this.resize(e,t)}(this.renderEnabled||r)&&(this.dispatchEvent("BeforeRender"),this.frustumCullingByModelBBox(),this.update3dTiles(),null==(i=this.renderer)||i.render(this.scene,this.camera),this.dispatchEvent("AfterRender"))}(this.composerRenderEnabled||r)&&this.composer&&this.composerEnabled&&(this.composer.render(),this.composerRenderEnabled=!1),this.requestAnimationFrameHandle=requestAnimationFrame(this.animate.bind(this)),this.lastFrameExecuteTime=Date.now(),this.dispatchEvent("OnAnimate")}update3dTiles(){if(!this.camera)return;let e=this.loadedModels.filter((e=>!!e.tilesRenderer));0!==e.length&&(this.camera.updateMatrixWorld(),e.forEach((e=>{e.tilesRenderer.update()})))}frustumCullingByModelBBox(){if(!this.enableModelLevelFrustumCulling)return;let e=this.camera,t=this.scene;if(!e||!t)return;e.updateMatrixWorld();let i=new et;i.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse);let n=new ma;n.setFromProjectionMatrix(i);let r=(e,t)=>{if(e&&t&&(void 0===e.userData._visible&&(e.userData._visible=!0,Object.defineProperties(e,{visible:{set:t=>{e.userData._visible=t,this.isFrustumInsectChecking||(e.userData.userConfigVisibility=!0)},get:()=>e.userData._visible}})),void 0===e.userData.userConfigVisibility)){let i=n.intersectsBox(t);e.visible!==i&&(e.visible=i,se.debug(`[Viewer] frustumCullingByModelBBox() set model (id ${e.id})'s visible to:`,i))}};this.isFrustumInsectChecking=!0,this.loadedModels.forEach((e=>{if(e.tilesRenderer){let t=e.tilesRenderer.group;r(t,e.bbox)}else r(e.object,e.bbox)})),this.isFrustumInsectChecking=!1}destroy(){var e,t,i,n;null==(e=this.inputManager)||e.removeEventListener();let r=this.webcamPlane;this.scene&&r&&(this.scene.remove(r),r.geometry.dispose(),r.material.dispose(),this.webcamPlane=void 0),this.webcam=void 0,this.composer=void 0,this.renderPass=void 0,this.effectFxaaPass=void 0,this.saoPass=void 0,this.ssaoPass=void 0,this.outlinePass=void 0,this.ambientLight=void 0,this.directionalLight=void 0,this.hemisphereLight=void 0,this.directionalLightHelper&&(this.directionalLightHelper.dispose(),this.directionalLightHelper=void 0),this.controls&&(this.disposeRotateToCursor(),this.controls.dispose(),this.controls=void 0),this.perspectiveCameraControls&&(this.perspectiveCameraControls.dispose(),this.perspectiveCameraControls=void 0),this.shadowCameraHelper&&(this.shadowCameraHelper.dispose(),this.shadowCameraHelper=void 0),this.css2dRenderer&&(null==(t=this.viewerContainer)||t.removeChild(this.css2dRenderer.domElement),this.css2dRenderer=void 0),this.raycaster=void 0,this.selectedObject=void 0,this.savedMaterialsForOpacity=void 0,this.section=void 0,this.sectionType=void 0,this.loadedModels.forEach((e=>{e.tilesRenderer&&e.tilesRenderer.dispose()})),this.loadedModels=[],this.perspectiveCamera=void 0,this.perspectiveCameraControls=void 0,this.raf&&(this.timeoutSymbol&&this.raf.clearTimeout(this.timeoutSymbol),this.raf=void 0),null==(i=this.fontManager)||i.destroy(),this.fontManager=void 0,this.pmremGenerator&&(this.pmremGenerator.dispose(),this.pmremGenerator=void 0),null==(n=this.zoomToRectHelper)||n.destroy(),this.zoomToRectHelper=void 0,super.destroy()}loadLocalModel(e,t,i,n){return ft(this,null,(function*(){var r,a;this.timer=Date.now(),this.increaseJobCount();let s=t.modelId||t.src,o=this.translate("ProgressBar.Loading"),l=e=>{var t;null==(t=this.loadingProgressBar)||t.updateProgress(s,o,e),n&&n(new ProgressEvent("LoadProgress",{loaded:e,total:100}))},h=!1,c=(e,t,i)=>{var r;let a=100*e.loaded/e.total;a=a*(i-t)/100+t,a>i&&(h||(se.warn("[Progress] Invalid ProgressEvent:",e),h=!0),a=i),null==(r=this.loadingProgressBar)||r.updateProgress(s,o,a),n&&n(new ProgressEvent("LoadProgress",{loaded:a,total:100}))},u=e=>c(e,0,50),d=e=>c(e,50,99);null==(r=this.loadingProgressBar)||r.addProgressItem(s),l(0);try{let n=new ja(i);this.fontManager&&n.setFont(this.fontManager);let r=yield n.loadLocalModel(e,t.src,u);if(r)return yield this.applyOptionsAndAddToScene(e,r,t,d),Promise.resolve()}catch(e){let n=`Error loading ${t.src}`;return se.error(n,e),Promise.reject(n)}finally{this.decreaseJobCount(),l(100),null==(a=this.loadingProgressBar)||a.delayRemoveProgressItem(s)}return Promise.reject()}))}loadModel(e,t){return ft(this,null,(function*(){var i,n;this.timer=Date.now(),this.increaseJobCount();let r=e.modelId||e.src,a=this.translate("ProgressBar.Loading"),s=e=>{var i;null==(i=this.loadingProgressBar)||i.updateProgress(r,a,e),t&&t(new ProgressEvent("LoadProgress",{loaded:e,total:100}))},o=!1,l=(e,i,n)=>{var s;let l=100*e.loaded/e.total;l=l*(n-i)/100+i,l>n&&(o||(se.warn("[Progress] Invalid ProgressEvent:",e),o=!0),l=n),null==(s=this.loadingProgressBar)||s.updateProgress(r,a,l),t&&t(new ProgressEvent("LoadProgress",{loaded:l,total:100}))},h=e=>l(e,0,50),c=e=>l(e,50,99);null==(i=this.loadingProgressBar)||i.addProgressItem(r),s(0);try{let t=new ja;this.fontManager&&t.setFont(this.fontManager);let i=yield t.loadModel(e.src,e.fileFormat,h);if(i)return yield this.applyOptionsAndAddToScene(e.src,i,e,c),Promise.resolve()}catch(t){let n=`Error loading ${e.src}`;return se.error(n,t),Promise.reject(n)}finally{this.decreaseJobCount(),s(100),null==(n=this.loadingProgressBar)||n.delayRemoveProgressItem(r)}return Promise.reject()}))}load3dTiles(e){return ft(this,null,(function*(){var t;this.timer=Date.now(),this.increaseJobCount();let i=new M_(e.src),n=new Nt,r=yield new Promise(((t,r)=>{i.onLoadTileSet=()=>{i.getBounds(n)||(i.getBoundingSphere(Ove)?Ove.getBoundingBox(n):(se.warn(`[Viewer] Can't get the correct bounding box of 3dTiles '${e.src}'!`),r())),se.debug(n),i.onLoadTileSet=null;let a=i.group;se.debug(a),t(a)},i.onLoadModel=e=>{e.traverse((e=>{e.matrixAutoUpdate&&(e.matrixAutoUpdate=!1,e.updateMatrix()),e.isMesh&&(e.castShadow=!0,e.receiveShadow=!0),e.geometry&&e.layers.enableAll()})),e.updateWorldMatrix(!1,!0),this.updateDirectionalLightShadow(),this.enableRender()},i.setCamera(this.camera),i.setResolutionFromRenderer(this.camera,this.renderer),i.update()}));if(r){let a=Date.now(),s={modelId:this.getUniqueModelId(e.modelId||e.src),object:r,bbox:n,tilesRenderer:i};if(this.loadedModels.push(s),e.matrix&&16===e.matrix.length){let t=new et;t.elements=e.matrix,r.applyMatrix4(t)}return r.matrixAutoUpdate=!1,r.updateMatrix(),r.updateMatrixWorld(!0),null==(t=this.scene)||t.add(r),n.applyMatrix4(r.matrix),this.computeBoundingBox(),this.tryAdjustDirectionalLight(),1===this.loadedModels.length&&(this.tryAdjustCameraNearAndFar(),this.goToHomeView()),se.info(`[Viewer] Added 3dTiles '${e.src}' to scene in ${(Date.now()-a)/1e3}s`),this.enableRender(),this.decreaseJobCount(),this.dispatchEvent("ModelLoaded"),Promise.resolve()}return this.decreaseJobCount(),this.dispatchEvent("ModelLoaded"),Promise.reject()}))}setFont(e){return ft(this,null,(function*(){let t=Date.now();this.fontManager||(this.fontManager=new ud),yield this.fontManager.loadFonts(e),se.info(`[Viewer] Font file(s) load time in ${(Date.now()-t)/1e3}s`)}))}setDracoDecoderPath(e){ja.setDracoDecoderPath(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(),this.tryAdjustDirectionalLight(),1===this.loadedModels.length&&(this.tryAdjustCameraNearAndFar(),this.goToHomeView()),se.info(`[Viewer] Added '${e.modelId}' to scene in ${(Date.now()-this.timer)/1e3}s`),this.renderer.shadowMap.needsUpdate=!0,this.enableRender(),this.dispatchEvent("ModelLoaded",{modelId:e.modelId,bbox:t}),this.decreaseJobCount()}calculateMeshSurfaceArea(e){let t=new Zr,i=[0,0,0],n=e.geometry,r=n.getAttribute("position"),a=n.getIndex(),s=a?a.count:r.count,o=0;for(let l=0;l<s;l+=3){a?(i[0]=a.getX(l),i[1]=a.getX(l+1),i[2]=a.getX(l+2)):(i[0]=l,i[1]=l+1,i[2]=l+2);let{a:e,b:n,c:s}=t;e.fromBufferAttribute(r,i[0]),n.fromBufferAttribute(r,i[1]),s.fromBufferAttribute(r,i[2]),o+=t.getArea()}return o}addOrRemoveObjectOpacity(e=!0,t=.3,i,n){if(this.savedMaterialsForOpacity||(this.savedMaterialsForOpacity=[]),!this.scene)return;let r=this.scene,a=[];this.loadedModels.map((e=>e.object.id)).forEach((s=>{if(e){this.savedMaterialsForOpacity&&this.savedMaterialsForOpacity.length>0&&Hn.revertObjectOpacityById(r,s,this.savedMaterialsForOpacity);let e=Hn.setObjectOpacityById(r,s,t,i,n);a.push(...e)}else this.savedMaterialsForOpacity&&Hn.revertObjectOpacityById(r,s,this.savedMaterialsForOpacity)})),this.savedMaterialsForOpacity=e?a:[],this.enableRender()}hasTransparentObject(){return!!(this.savedMaterialsForOpacity&&this.savedMaterialsForOpacity.length>0)}showVertexNormals(e,t=.1){var i,n,r;e?(this.vertexNormalsHelpers||(this.vertexNormalsHelpers=new er),null==(i=this.scene)||i.traverseVisible((e=>{var i;if(e instanceof xt&&!["SKYBOX","GROUND_GRID","GROUND_GRASS","BIM_VIEWER_BOX_HELPER"].includes(e.name)){if(!e.geometry.attributes.normal)return;let n=new t2(e,t,16711680);null==(i=this.vertexNormalsHelpers)||i.add(n)}})),null==(n=this.scene)||n.add(this.vertexNormalsHelpers)):this.vertexNormalsHelpers&&(null==(r=this.scene)||r.remove(this.vertexNormalsHelpers),this.vertexNormalsHelpers=void 0)}resize(e,t){super.resize(e,t),t>0&&(this.composer&&this.composer.setSize(e,t),this.effectFxaaPass&&this.effectFxaaPass.uniforms.resolution.value.set(1/e,1/t),this.css2dRenderer&&(this.css2dRenderer.setSize(e,t),this.css2dRenderer.domElement.style.height="0",this.css2dRenderer.domElement.style.width="0")),this.enableRender()}getRaycaster(){return this.raycaster}getRaycastableObjectsByMouse(e){let t=[];if(!(this.raycaster&&this.camera&&this.scene&&e&&this.viewerContainer))return t;let i=new xe(e.x,e.y),n=an.screen2Ndc(i,this.camera,this.viewerContainer);return this.camera.updateMatrixWorld(),this.raycaster.setFromCamera(n,this.camera),t=this.getRaycastableObjects(),t}getRaycastableObjects(){let e=[];return this.loadedModels.forEach((t=>{let i=t.object;i&&i.visible&&e.push(i)})),e}getIntersections(e){let t=this.getRaycastableObjectsByMouse(e),i=this.raycaster&&this.raycaster.intersectObjects(t,!0)||[];return this.renderer&&this.renderer.clippingPlanes.length>0&&(i=i.filter((e=>{var t;return null==(t=this.renderer)?void 0:t.clippingPlanes.every((function(t){return t.distanceToPoint(e.point)>0}))}))),i}getAllIntersections(e){if(!(this.raycaster&&this.camera&&this.scene&&this.viewerContainer))return[];let t=new xe(null==e?void 0:e.x,null==e?void 0:e.y),i=an.screen2Ndc(t,this.camera,this.viewerContainer);this.raycaster.setFromCamera(i,this.camera);let n=this.scene.children,r=this.raycaster.intersectObjects(n,!0)||[];return this.renderer&&this.renderer.clippingPlanes.length>0&&(r=r.filter((e=>{var t;return null==(t=this.renderer)?void 0:t.clippingPlanes.every((function(t){return t.distanceToPoint(e.point)>0}))}))),r}getClickedObject(e){if(!this.raycaster)return;let t=Date.now();this.raycaster.layers.set(12);let i=this.getIntersections(e);se.debug(`[Viewer] getIntersections costs ${(Date.now()-t)/1e3}s`);let n=i.find((e=>{let t=e.object;return t.visible&&t instanceof xt}));return null==n?void 0:n.object}handleMouseClick(e){var t,i,n;if(null!=(t=this.measurePlugin)&&t.isActive()||null!=(i=this.sectionPlugin)&&i.isActive()||!this.raycaster)return;let r=Date.now();this.raycaster.layers.set(12);let a=this.getIntersections(e);se.debug(`[Viewer] getIntersections costs ${(Date.now()-r)/1e3}s`);let s,o,l=a.find((e=>{let t=e.object;return t.visible&&t instanceof xt})),h=l&&l.object||void 0;if(h)if(h instanceof Oi)s=l.instanceId,this.selectedObject&&this.selectedObject.id===h.id&&this.selectedObject.userData.instanceId===s&&(h=void 0);else if(Rr.isMergedMesh(h)){let e=l&&l.faceIndex||-1;e>=0?(o=Rr.getBatchIdByFaceIndex(h,e),this.selectedObject&&this.selectedObject.id===h.id&&this.selectedObject.userData.batchId===o&&(h=void 0)):h=void 0}else this.selectedObject&&this.selectedObject.id===h.id&&(h=void 0);if(a.length>0&&a[0].point){let e=null==(n=this.overlayRender)?void 0:n.getDrawablesByPosition(a[0].point,this.raycaster);e&&e.length>0?h=e[0]:this.enableSelection||(h=void 0)}this.selectedObject&&this.clearSelection(),h?this.selectObject(h,s,o):this.clearSelection()}selectObject(e,t,i,n){if(e instanceof Hi)return this.selectedObject=e,this.selectedObject.selected=!0,void this.enableRender();if(this.selectedObject){let t=this.selectedObject.userData;if(null!=t.instanceId&&t.originalMatrix&&t.clonedMesh){this.scene&&this.scene.remove(t.clonedMesh);let i=this.selectedObject;if(i.setMatrixAt(t.instanceId,t.originalMatrix),i.instanceMatrix.needsUpdate=!0,i.updateMatrix(),delete t.instanceId,delete t.originalMatrix,e===t.clonedMesh)return t.clonedMesh.geometry.dispose(),delete t.clonedMesh,this.selectedObject=void 0,void(this.outlinePass&&(this.outlinePass.selectedObjects=[]));t.clonedMesh.geometry.dispose(),delete t.clonedMesh}else if(null!=t.batchId&&t.clonedMesh){if(this.scene&&this.scene.remove(t.clonedMesh),delete t.batchId,e===t.clonedMesh)return t.clonedMesh.geometry.dispose(),delete t.clonedMesh,this.selectedObject=void 0,void(this.outlinePass&&(this.outlinePass.selectedObjects=[]));t.clonedMesh.geometry.dispose(),delete t.clonedMesh}else if(t.originalMaterial){if(this.selectedObject.material){let e=this.selectedObject.material;Array.isArray(e)?e.forEach((e=>e.dispose())):e instanceof yr&&e.dispose()}this.selectedObject.material=t.originalMaterial,delete t.originalMaterial}this.selectedObject=void 0,this.outlinePass&&(this.outlinePass.selectedObjects=[])}if(this.scene&&e){if(e instanceof Oi&&null!=t){let i=e,r=new et,a=new et;a.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),i.getMatrixAt(t,r),this.selectedObject=e,this.outlinePass&&(this.outlinePass.selectedObjects=[e]);let s=es.clonedHighlightMaterials(e,{depthTest:n});if(s){let n=new xt(i.geometry.clone(),s);n.applyMatrix4(e.matrixWorld.multiply(r)),n.matrixWorldNeedsUpdate=!0,n.name="Cloned mesh for highlighting",n.layers.enableAll();let o=r.clone();o.multiplyMatrices(r,a),i.setMatrixAt(t,o),i.instanceMatrix.needsUpdate=!0,i.updateMatrix(),this.selectedObject.userData.instanceId=t,this.selectedObject.userData.originalMatrix=r,this.selectedObject.userData.clonedMesh=n,this.scene.add(n)}}else if(Rr.isMergedMesh(e)&&null!=i){let t=Rr.getBatchByBatchId(e,i),r=`[Viewer] Clicked on merged mesh(id: ${e.id}).`;r+=` batchId: ${i}, object name before merge: ${null==t?void 0:t.name}`,null!=t&&t.userData&&(r+=`, userData before merge: ${JSON.stringify(t.userData)}`),se.info(r);let a=es.clonedHighlightMaterials(e,{depthTest:n}),s=Rr.cloneGeometryForBatch(e,t);if(a&&s){let t=new xt(s,a);t.applyMatrix4(e.matrixWorld),t.matrixWorldNeedsUpdate=!0,t.name="Cloned mesh for highlighting",t.layers.enableAll(),this.selectedObject=e,this.selectedObject.userData.batchId=i,this.selectedObject.userData.clonedMesh=t,this.scene.add(t)}}else{let t=es.clonedHighlightMaterials(e,{depthTest:n});t&&(this.selectedObject=e,this.selectedObject.userData.originalMaterial=this.selectedObject.material,this.selectedObject.material=t,this.outlinePass&&(this.outlinePass.selectedObjects=[e]))}this.enableRender()}else this.enableRender()}clearSelection(){this.selectedObject&&this.selectedObject instanceof Hi?this.selectedObject.selected=!1:this.selectObject(),this.selectedObject=void 0}getBBox(){return this.bbox}enableModelEdges(e,t){return ft(this,null,(function*(){let i=St.getUpdateProgressFunc(t);i(0),this.increaseJobCount();let n=this.loadedModels.length;for(let r=0;r<n;++r){let i=this.loadedModels[r];if(e&&!i.edges){let e=i.object;if(e){se.debug(`[Viewer] Generating outlines for model '${i.object.id}'`);let a=90*r/n,s=90*(r+1)/n,o=St.getUpdateSubProgressFunc(a,s,t);i.edges=yield Hn.createOutlines(e,void 0,o)}}else i.edges&&i.edges.forEach((t=>t.visible=e))}this.decreaseJobCount(),i(100),this.enableRender()}))}flyToObjects(e){if(!e||0===e.length||!this.camera)return;let t=new Nt;e.forEach((e=>{let i=Os.getBoundingBox(e);t.union(i)}));let i=new vr;t.getBoundingSphere(i),this.controls.fitToSphere(i,!0)}flyToObject(e){this.flyToObjects([e])}flyToSelectedObject(){if(!this.selectedObject)return;let e=this.selectedObject;(e instanceof Oi&&e.userData.clonedMesh||Rr.isMergedMesh(e)&&e.userData.clonedMesh)&&(e=e.userData.clonedMesh),this.flyToObject(e)}flyToRandomObject(){var e,t,i;let n=this.loadedModels.map((e=>e.object.id)),r=n.length;if(r<=0)return;let a=n[Math.floor(Math.random()*r)];if(!(null==(e=this.scene)?void 0:e.getObjectById(a)))return;let s=[];if(null==(t=this.scene)||t.traverseVisible((e=>{(e instanceof xt||e instanceof fr)&&!["SKYBOX","GROUND_GRID","GROUND_GRASS","BIM_VIEWER_BOX_HELPER"].includes(e.name)&&s.push(e.id)})),s.length<1)return;let o=Math.floor(Math.random()*s.length),l=null==(i=this.scene)?void 0:i.getObjectById(s[o]);l&&(se.info(`[Viewer] Flying to random object: ${l.name}, type: ${l.type}`),this.selectObject(l,void 0,void 0,!1),this.flyToObject(l))}flyTo(e,t){let i=this.camera,n=this.controls;if(!i||!n)return;if(e.equals(t))return void se.error("[Viewer] camera position and lookAt cannot be the same!");if(!St.isVectorValid(e)||!St.isVectorValid(t))return void se.error("[Viewer] invalid position or lookAt!");let r=e.distanceTo(t);r<i.near?(e=e.clone().sub(t).normalize().multiplyScalar(1.1*i.near),se.warn("[Viewer] camera could be too close to see the object!")):r>i.far&&(e=e.clone().sub(t).normalize().multiplyScalar(.9*i.far),se.warn("[Viewer] camera could be too far to see the object!")),n.setLookAt(e.x,e.y,e.z,t.x,t.y,t.z,!0),n.setFocalOffset(0,0,0,!0)}viewFitAll(){if(!this.scene||!this.camera||!this.controls)return;let e=Os.getVisibleObjectBoundingBox(this.scene),t=new vr;e.getBoundingSphere(t),this.controls.fitToSphere(t,!0)}goToHomeView(){if(!this.scene)return;let e=this.camera,t=this.cameraCfg,i=t&&St.arrayToVector3(t.eye),n=t&&St.arrayToVector3(t.look);if(i&&n){let e=this.controls;e.setLookAt(i.x,i.y,i.z,n.x,n.y,n.z,!0),e.setFocalOffset(0,0,0,!0)}else{let t=new D,i=new D,n=new D(-1,-.5,-1);this.bbox.getCenter(i),t.subVectors(i,n);let r=new vr;this.bbox.getBoundingSphere(r);let a=this.controls;if(a.setLookAt(t.x,t.y,t.z,i.x,i.y,i.z,!0),a.fitToSphere(r,!0),a.getPosition(t),(!this.cameraCfg||this.cameraCfg&&(!this.cameraCfg.eye||!this.cameraCfg.look))&&(this.cameraCfg={eye:t.toArray(),look:i.toArray()}),e instanceof Nr){let t=this.bbox,i=t.max.x-t.min.x,n=t.max.z-t.min.z,r=e.right-e.left,a=e.top-e.bottom;e.zoom=Math.max(r,a)/Math.max(i,n),e.zoom/=2,e.updateProjectionMatrix()}t.equals(i)||this.flyTo(t,i)}}zoomToBBox(e){if(!this.controls)return;let t=new vr;e.getBoundingSphere(t),this.controls.fitToSphere(t,!0)}tryAdjustCameraNearAndFar(){let e=this.camera;if(!this.scene||!e)return;let t=this.bbox,i=e.near,n=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(i>l||n<h){let t=e=>St.numberToString(e);se.info(`[Viewer] BBox's longest side is: ${t(o)}`),i>l&&(se.warn(`[Viewer] camera.near(${t(i)}) shouldn't bigger than ${t(l)}, will change it!`),e.near=l),n<h&&(se.warn(`[Viewer] camera.far(${t(n)}) shouldn't smaller than ${t(h)}, will change it!`),e.far=h)}if(e instanceof Nr){let t=e.right-e.left,i=e.top-e.bottom;e.zoom=Math.max(t,i)/Math.max(r,s),e.zoom/=2}e.updateProjectionMatrix()}tryAdjustDirectionalLight(){if(!this.directionalLight)return;let e=this.bbox,t=new vr;e.getBoundingSphere(t);let i=t.center,n=t.radius,r=this.directionalLight.shadow.camera;r.zoom=1,r.top=n,r.bottom=-n,r.right=n,r.left=-n,r.near=.1,r.far=2*n,r.updateProjectionMatrix();let a=new D(-1,-.5,1);a.normalize().multiplyScalar(n),this.directionalLight.position.copy(i).addScaledVector(a,-1),this.directionalLight.target.position.copy(i),se.debug("[Viewer] this.directionalLight.position",this.directionalLight.position),se.debug("[Viewer] this.directionalLight.target.position",this.directionalLight.target.position),this.updateDirectionalLight(),this.enableRender()}updateDirectionalLight(){var e,t;if(this.directionalLight&&(this.directionalLight.updateMatrixWorld(),this.directionalLight.target.updateMatrixWorld(),this.directionalLightHelper&&(this.directionalLightHelper.update(),!(null!=(e=this.scene)&&e.matrixAutoUpdate)&&this.directionalLightHelper.updateWorldMatrix(!1,!0)),this.directionalLight.shadow.needsUpdate=!0,this.directionalLight.shadow.camera.updateProjectionMatrix(),this.shadowCameraHelper&&(this.shadowCameraHelper.update(),null==(t=this.scene)||!t.matrixAutoUpdate))){let e=this.directionalLight.shadow.camera;e.position.setFromMatrixPosition(this.directionalLight.matrixWorld),Dve.setFromMatrixPosition(this.directionalLight.target.matrixWorld),e.lookAt(Dve),e.updateMatrixWorld(),this.shadowCameraHelper.updateWorldMatrix(!1,!0)}}updateDirectionalLightShadow(){this.directionalLight&&(this.directionalLight.shadow.needsUpdate=!0)}showDirectionalLightHelper(e){this.directionalLightHelper&&(this.directionalLightHelper.visible=e),this.shadowCameraHelper&&(this.shadowCameraHelper.visible=e)}setOrbitPoint(e){let t=this.controls;if(!(this.camera&&this.renderer&&this.controls&&this.scene&&this.raycaster&&this.viewerContainer))return;let i=new D;if(this.selectedObject&&this.selectedObject instanceof on){(new Nt).setFromObject(this.selectedObject).getCenter(i),null==t||t.setOrbitPoint(i.x,i.y,i.z);let e=an.world2Screen(i,this.camera,this.viewerContainer);this.setAnchorPosition(e)}else{this.raycaster&&this.raycaster.layers.set(12);let n=this.getIntersections(e),r=new xe(e.x,e.y);if(n&&0!==n.length){let e=n[0].point;null==t||t.setOrbitPoint(e.x,e.y,e.z),this.setAnchorPosition(r)}else{this.bbox.getCenter(i),t.setOrbitPoint(i.x,i.y,i.z);let e=an.world2Screen(i,this.camera,this.viewerContainer);this.setAnchorPosition(e)}}}setAnchorPosition(e){this.anchor&&(this.anchor.className="anchor active",this.anchor.style.left=`${e.x}px`,this.anchor.style.top=`${e.y}px`)}createAnchor(){var e;let t=document.createElement("div");return t.className="anchor",null==(e=this.viewerContainer)||e.appendChild(t),t}disposeAnchor(){var e;this.anchor&&(null==(e=this.viewerContainer)||e.removeChild(this.anchor),this.anchor=void 0)}disposeRotateToCursor(){this.disposeAnchor()}enableComposer(e){!this.scene||!this.camera||!this.renderer||(this.composerEnabled=e,e&&!this.composer&&(this.composer=new i2(this.renderer)),this.enableRender())}enableRenderPass(e){if(this.scene&&this.camera&&this.renderer&&this.composer){if(e&&!this.renderPass){let e=new s2(this.scene,this.camera);e.setSize(this.width,this.height),this.composer.addPass(e),this.renderPass=e}this.renderPass&&(this.renderPass.enabled=e),this.enableRender()}}enableFxaaPass(e){if(this.scene&&this.camera&&this.renderer&&this.composer){if(e&&!this.effectFxaaPass){let e=new jy(Rve);e.uniforms.resolution.value.set(1/this.width,1/this.height),e.setSize(this.width,this.height),e.renderToScreen=!0,this.composer.addPass(e),this.effectFxaaPass=e}this.effectFxaaPass&&(this.effectFxaaPass.enabled=e),this.enableRender()}}enableSaoPass(e){if(this.scene&&this.camera&&this.renderer&&this.composer){if(e&&!this.saoPass){let e=new L_(this.scene,this.camera,!1,!0,new xe(1/this.width,1/this.height));e.setSize(this.width,this.height),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.enableRender()}}enableSsaoPass(e){if(this.scene&&this.camera&&this.renderer&&this.composer){if(e&&!this.ssaoPass){let e=new Kl(this.scene,this.camera,this.width,this.height);e.kernelRadius=16,e.minDistance=1e-4,e.maxDistance=.3,this.composer.addPass(e),this.ssaoPass=e}this.ssaoPass&&(this.ssaoPass.enabled=e),this.enableRender()}}enableOutlinePass(e){if(this.scene&&this.camera&&this.renderer&&this.composer){if(e&&!this.outlinePass){let e=new jc(new xe(this.width,this.height),this.scene,this.camera);e.edgeStrength=3,e.edgeGlow=0,e.edgeThickness=2,e.pulsePeriod=0,e.visibleEdgeColor.set(16711680),e.hiddenEdgeColor.set(16752768),this.composer.addPass(e),this.outlinePass=e}this.outlinePass&&(this.outlinePass.enabled=e),this.enableRender()}}enableSsaaPass(e){if(this.scene&&this.camera&&this.renderer&&this.composer){if(e&&!this.ssaaRenderPass){let e=new o2(this.scene,this.camera,16777215,0);this.composer.addPass(e),this.ssaaRenderPass=e}this.ssaaRenderPass&&(this.ssaaRenderPass.enabled=e),this.enableRender()}}enableBloomPass(e){if(this.scene&&this.camera&&this.renderer&&this.composer){if(e&&!this.bloomPass){let e=new nh(1,25,4);e.renderToScreen=!0,this.composer.addPass(e),this.bloomPass=e}this.bloomPass&&(this.bloomPass.enabled=e),this.enableRender()}}enableUnrealBloomPass(e){if(this.scene&&this.camera&&this.renderer&&this.composer){if(e&&!this.unrealBloomPass){let e=new xd(new xe(this.width,this.height),1,0,0);e.threshold=0,e.strength=.5,e.radius=0,this.composer.addPass(e),this.unrealBloomPass=e}this.unrealBloomPass&&(this.unrealBloomPass.enabled=e),this.enableRender()}}get sectionPlugin(){return this.plugins.find((e=>"SectionPlugin"===e.id))}activateSection(e="ObjectsBoxSection"){var t,i;!this.inputManager||null!=(t=this.sectionPlugin)&&t.isActive()?this.sectionPlugin||se.warn("[Viewer] SectionPlugin doesn't seem to be installed!"):(this.sectionType=e,this.clearSelection(),null==(i=this.sectionPlugin)||i.activate(e),this.enableRender())}deactivateSection(){var e;null==(e=this.sectionPlugin)||e.deactivate(),this.enableRender()}getActiveSection(){var e;return null==(e=this.sectionPlugin)?void 0:e.getActiveSection()}get measurePlugin(){return this.plugins.find((e=>"MeasurementPlugin"===e.id))}getMeasurements(){let e=this.measurePlugin;return e?e.getData():[]}activateMeasurement(e){let t=this.measurePlugin;t?(t.activate(e),this.clearSelection()):se.warn("[Viewer] MeasurementPlugin doesn't seem to be installed!")}deactivateMeasurement(){var e;null==(e=this.measurePlugin)||e.deactivate()}setMeasurementVisibility(e,t){let i=this.measurePlugin;return!!i&&i.setVisibilityById(e,t)}clearMeasurements(){var e;null==(e=this.measurePlugin)||e.clear()}zoomToRect(){this.zoomToRectHelper||(this.zoomToRectHelper=new ky(this)),this.zoomToRectHelper.activate()}deactivateZoomRect(){var e;null==(e=this.zoomToRectHelper)||e.deactivate()}enableWebCam(){this.scene&&(this.webcam||(this.webcam=new c2),this.webcamPlane||(this.webcamPlane=this.webcam.createWebCamPlane(),this.webcamPlane.position.set(10,2,0)),this.scene.add(this.webcamPlane))}disableWebCam(){this.scene&&this.webcamPlane&&(this.webcamPlane.geometry.dispose(),this.webcamPlane.material.dispose(),this.scene.remove(this.webcamPlane))}setEnvironment(e){Ac.createEnvTexture(this.pmremGenerator,e).then((e=>{this.scene&&(this.scene.environment&&this.scene.environment.dispose(),this.scene.environment=e,this.enableRender())}))}setEnvironmentFromDataArray(e){Ac.createEnvTextureFromDataArray(this.pmremGenerator,e).then((e=>{this.scene&&(this.scene.environment=e,this.enableRender())}))}takeObjectsScreenshot(e){return ft(this,null,(function*(){return new Promise(((t,i)=>{var n;this.renderer||i("renderer is undefined"),null==(n=this.scene)||n.traverse((t=>{t instanceof xt&&((0,p2.includes)(e,(0,p2.get)(t.userData,"UniqueId"))?t.visible=!0:t.visible=!1)})),this.enableRender(),setTimeout((()=>{var e;t(null==(e=this.renderer)?void 0:e.domElement.toDataURL("image/png"))}),1e3)}))}))}setObjectColor(e,t){this.clearSelection();let i={};e.traverse((e=>{let t=e.material;t&&(Array.isArray(t)?t.forEach((e=>{i[e.id]=e})):i[t.id]=t)}));for(let n in i)es.setMaterialColor(i[n],new ct(t));this.enableRender()}updateRaycasterThreshold(){let e=this.camera;if(!e||!this.raycaster)return;let t=12/e.zoom,i=this.raycaster.params;i.Line?i.Line.threshold=t:i.Line={threshold:t},i.Points?i.Points.threshold=t:i.Points={threshold:t}}merge(e){this.increaseJobCount();try{let t=[];e.traverse((e=>{e.geometry&&e.material&&t.push(e)})),Rr.deepMerge(t,e)}finally{this.decreaseJobCount()}}updateProjectSettings(e){this.settings=e;let t=(e,t)=>{e&&t&&(e.near=t.near,e.far=t.far,e.updateProjectionMatrix())};t(this.perspectiveCamera,this.settings.camera),t(this.orthoCamera,this.settings.camera),this.enableRender(10)}computeBoundingBox(){let e=new Nt;return this.loadedModels.forEach((t=>{t.bbox&&!t.bbox.isEmpty()&&e.union(t.bbox)})),this.bbox=e,this.controls&&(this.controls.minDistance=.1,this.controls.maxDistance=10*this.bbox.getSize(new D).length()),e}setDistanceCullingFactor(e){this.distanceCullingFactor=e}getDistanceCullingFactor(){return this.distanceCullingFactor}getCameraPositionAndDirection(){let e=this.camera;if(!e)return;let t=e.position,i=new D;return e.getWorldDirection(i),{position:{x:t.x,y:t.y,z:t.z},direction:{x:i.x,y:i.y,z:i.z}}}},m2=Xi(kl(),1),i0t=(e=>(e[e.Browser=0]="Browser",e[e.Browserless=1]="Browserless",e[e.Headless=2]="Headless",e))(i0t||{}),Fve=class{constructor(e,t,i){if(this.scene=this.initScene(),this.selectedObject=void 0,this.loadedModels=[],this.clock=new ho,this.viewerMode=0,this.raycaster=new na,this.savedMaterialsForOpacity=[],this.jobCount=0,this.bbox=new Nt,this.outlineMaterial=new Gn({color:1118481}),this.outlineRoot=new er,this.transparentObjectIds=[],this.applyOptionsAndAddToScene=(e,t,i,n)=>ft(this,null,(function*(){if(se.info(`[Viewer] '${e}' is loaded, adding to scene...`),i.matrix&&16===i.matrix.length){let e=new et;e.elements=i.matrix,t.applyMatrix4(e)}let r;t.traverse((e=>{e.geometry&&e.layers.enableAll(),e instanceof Gs&&(e.visible=!1)})),i.edges&&(r=yield Hn.createOutlines(t,void 0,n));let a=i.modelId||i.src,s=e=>!!this.loadedModels.find((t=>t.modelId===e));if(s(a)){let e=1;for(;s(`${a}_${e}`);)e++;a=`${a}_${e}`,se.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 xt?t.push(e):e.traverseVisible((e=>{e instanceof xt&&t.push(e)})),t},this.containerOrCanvas=e,t&&(this.viewerMode=t),this.glContext=i,1===this.viewerMode&&(e instanceof HTMLDivElement||!i))throw new Error("[Viewer] Parameters don't match Browserless viewerMode !");this.increaseJobCount(),this.init(),this.decreaseJobCount(),se.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 Si;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 i=new Ts(e);if(t){let e=this.containerOrCanvas.width,t=this.containerOrCanvas.height;se.info(`[Viewer] Render target size: ${e} x ${t}`),this.renderTarget=new sr(e,t,{minFilter:Pr,magFilter:Jr,format:Js,type:bc}),i.setRenderTarget(this.renderTarget)}else{let e=this.containerOrCanvas.clientWidth,t=this.containerOrCanvas.clientHeight;this.containerOrCanvas.append(i.domElement),i.setPixelRatio(window.devicePixelRatio),i.setSize(e,t)}i.outputColorSpace=en,i.toneMappingExposure=1,i.useLegacyLights=!1,i.setClearColor(11119017,1),i.shadowMap.enabled=!0,i.shadowMap.type=Tv,this.renderer=i,t||(this.pmremGenerator=new Yh(i),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,i=1;e&&t&&(i=e/t),this.camera=new hr(68,i,.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 va(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 qs(e,.3);t.position.set(-2,2,4);let i=new Cl(3158064),n=new Du(e,14540253,3);n.position.set(0,300,0),this.scene.add(t),this.scene.add(i),this.scene.add(n)}initPointerEvents(){if(!this.renderer||!this.camera||!this.controls)return;let e=!1,t=!1,i=-1,n=-1;this.renderer.domElement.addEventListener("pointerdown",(t=>{i=t.x,n=t.y,e=!1})),this.renderer.domElement.addEventListener("pointermove",(t=>{i>=0&&n>=0&&(Math.abs(t.x-i)>5||Math.abs(t.y-n)>5)&&(e=!0)})),this.renderer.domElement.addEventListener("pointerup",(()=>{t&&setTimeout((()=>{t=!1}),200),i=-1,n=-1})),this.renderer.domElement.addEventListener("dblclick",(i=>{t=!0,e||(this.handleMouseClick(i),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,i){return ft(this,null,(function*(){let n=yield(new ja).loadLocalModel(e,t.src,i);return n?(yield this.applyOptionsAndAddToScene(e,n,t),Promise.resolve()):Promise.reject()}))}loadModel(e,t){return ft(this,null,(function*(){this.increaseJobCount();let i=yield(new ja).loadModel(e.src,e.fileFormat,t);return i?(yield this.applyOptionsAndAddToScene(e.src,i,e),Promise.resolve()):Promise.reject()}))}parseGltf(e,t,i,n){this.increaseJobCount(),(new ja).parseGltf(e,t.src,(e=>{this.applyOptionsAndAddToScene(t.src,e,t),i&&i(e)}),(e=>{n&&n(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,se.info(`[Viewer] Added '${e.modelId}' to scene`),this.decreaseJobCount()}addOrRemoveObjectOpacity(e=!0,t=.3,i,n){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&&Hn.revertObjectOpacityById(r,s.object.id,this.savedMaterialsForOpacity);let e=Hn.setObjectOpacityById(r,s.object.id,t,i,n);a.push(...e)}else this.savedMaterialsForOpacity&&Hn.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 xe;e&&(t=an.getScreenCoordinateByEvent(e,this.containerOrCanvas));let i=an.screen2Ndc(t,this.camera,this.containerOrCanvas);this.raycaster.setFromCamera(i,this.camera);let n=[];return this.loadedModels.forEach((e=>{let t=e.object;t&&t.visible&&n.push(t)})),this.raycaster.intersectObjects(n,!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 xt})),i=t&&t.object||void 0;i&&this.selectedObject&&this.selectedObject.id===i.id&&(i=void 0),i?this.selectObject(i):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 yr&&e.dispose()}this.selectedObject.material=e.originalMaterial,delete e.originalMaterial}this.selectedObject=void 0}if(!this.scene||!e)return;let t=es.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 i=Os.getBoundingBox(e);t.union(i)}));let i=new vr;t.getBoundingSphere(i),this.controls.fitToSphere(i,!0)}flyToObject(e){this.flyToObjects([e])}flyToSelectedObject(){this.selectedObject&&this.flyToObject(this.selectedObject)}flyTo(e,t,i){var n;let r=this.camera,a=this.controls;if(!r||!a)return;let s=e=Array.isArray(e)?new D(e[0],e[1],e[2]):e,o=t=Array.isArray(t)?new D(t[0],t[1],t[2]):t;se.info("[Viewer] flyTo: ",St.vectorToString(s)),a.setPosition(s.x,s.y,s.z),a.setTarget(o.x,o.y,o.z),this.isBrowserMode()||null==(n=this.renderer)||n.render(this.scene,r),i&&i()}goToHomeView(){let e=new vr;this.bbox.getBoundingSphere(e),this.controls.fitToSphere(e,!0)}setEnvironmentFromDataArray(e){Ac.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,i=e.near,n=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(i>l||n<h){let t=e=>St.numberToString(e);se.info(`[Viewer] BBox's longest side is: ${t(o)}`),i>l&&(se.warn(`[Viewer] camera.near(${t(i)}) shouldn't bigger than ${t(l)}, will change it!`),e.near=l),n<h&&(se.warn(`[Viewer] camera.far(${t(n)}) 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,i=this.transparentObjectIds.length>0?this.transparentObjectIds:void 0,n=new ln({color:16777215,transparent:!0,opacity:.1});this.loadedModels.forEach((e=>{Hn.applyMaterialToObjectById(this.scene,e.object.id,n,i,t)})),this.outlineRoot.clear();let r=[];if(e.forEach((e=>{let t=e.modelId,i=this.loadedModels.find((e=>e.modelId===t)),n=null==i?void 0:i.object;n||(se.warn(`[Viewer] The ModelId of ${t} has no corresponding model.`),n=this.scene),n.traverse((t=>{if((0,m2.includes)(e.id,(0,m2.get)(t.userData,"UniqueId"))){let e=this.getMeshes(t);r=r.concat(e)}}))})),r.length>0){r.forEach((e=>{let t=Hn.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=>{Hn.revertAppliedMaterialToObjectById(this.scene,t.object.id,e)})),this.transparentObjectIds=e,this.flyToObjects(r)}else se.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 D;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())}},Nve=new D,s0t=new dr,Bve=new D,fg=class extends on{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}},rh=new et,a0t=new et,g2=class{constructor(e={}){let t,i,n,r,a=this,s={camera:{fov:0,style:""},objects:new WeakMap},o=void 0!==e.element?e.element:document.createElement("div");o.style.overflow="hidden",this.domElement=o;let l=document.createElement("div");l.style.transformOrigin="0 0",l.style.pointerEvents="none",o.appendChild(l);let h=document.createElement("div");function c(e){return Math.abs(e)<1e-10?0:e}function u(e){let t=e.elements;return"matrix3d("+c(t[0])+","+c(-t[1])+","+c(t[2])+","+c(t[3])+","+c(t[4])+","+c(-t[5])+","+c(t[6])+","+c(t[7])+","+c(t[8])+","+c(-t[9])+","+c(t[10])+","+c(t[11])+","+c(t[12])+","+c(-t[13])+","+c(t[14])+","+c(t[15])+")"}function d(e){let t=e.elements;return"translate(-50%,-50%)matrix3d("+c(t[0])+","+c(t[1])+","+c(t[2])+","+c(t[3])+","+c(-t[4])+","+c(-t[5])+","+c(-t[6])+","+c(-t[7])+","+c(t[8])+","+c(t[9])+","+c(t[10])+","+c(t[11])+","+c(t[12])+","+c(t[13])+","+c(t[14])+","+c(t[15])+")"}function p(e,t,i,n){if(e.isCSS3DObject){let n=!0===e.visible&&!0===e.layers.test(i.layers);if(e.element.style.display=!0===n?"":"none",!0===n){let n;e.onBeforeRender(a,t,i),e.isCSS3DSprite?(rh.copy(i.matrixWorldInverse),rh.transpose(),0!==e.rotation2D&&rh.multiply(a0t.makeRotationZ(e.rotation2D)),e.matrixWorld.decompose(Nve,s0t,Bve),rh.setPosition(Nve),rh.scale(Bve),rh.elements[3]=0,rh.elements[7]=0,rh.elements[11]=0,rh.elements[15]=1,n=d(rh)):n=d(e.matrixWorld);let r=e.element,o=s.objects.get(e);if(void 0===o||o.style!==n){r.style.transform=n;let t={style:n};s.objects.set(e,t)}r.parentNode!==h&&h.appendChild(r),e.onAfterRender(a,t,i)}}for(let r=0,a=e.children.length;r<a;r++)p(e.children[r],t,i,n)}h.style.transformStyle="preserve-3d",l.appendChild(h),this.getSize=function(){return{width:t,height:i}},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*(i/a.view.height)}px )`,l.style.transform+=`scale( ${a.view.fullWidth/a.view.width}, ${a.view.fullHeight/a.view.height} )`):l.style.transform="",!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),null===a.parent&&!0===a.matrixWorldAutoUpdate&&a.updateMatrixWorld(),a.isOrthographicCamera&&(o=-(a.right+a.left)/2,d=(a.top+a.bottom)/2);let m=a.view&&a.view.enabled?a.view.height/a.view.fullHeight:1,g=a.isOrthographicCamera?`scale( ${m} )scale(`+f+")translate("+c(o)+"px,"+c(d)+"px)"+u(a.matrixWorldInverse):`scale( ${m} )translateZ(`+f+"px)"+u(a.matrixWorldInverse),v=g+"translate("+n+"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,i=a,n=t/2,r=i/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"}}},Uve=Xi(kl(),1),up=class extends er{constructor(e,t,i=10){super(),this.images=e,this.thumbnailImages=t,this.size=i,this.textureLoader=new ws,this.mesh=new xt}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 i=1/(e/10);this.visible=!0,this.clearFading(),this.renderOrder+=1,this.fadingInInterval=setInterval((()=>{let e=1,n=this.getMaterials();this.materialEquals(t,n)||(t=n),t.length>0&&(e=Math.min(t[0].opacity+i,1),t.forEach((t=>t.opacity=e))),e>=1&&this.clearFading()}),10)}materialEquals(e,t){return Uve.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(),i=1/(e/10),n=1/(e/10);this.clearFading(),this.scale.set(2,2,2),this.fadingOutInterval=setInterval((()=>{let e=this.scale.x+n;this.scale.set(e,e,e);let r=0;t.length>0&&(r=Math.max(t[0].opacity-i,0),t.forEach((e=>e.opacity=r))),(r<=0||e>=3)&&this.clearFading()}),10)}clearFading(){let e=this.getMaterials();this.fadingInInterval&&(clearInterval(this.fadingInInterval),this.fadingInInterval=void 0,this.visible=!0,e.forEach((e=>e.opacity=1)),this.renderOrder-=1),this.fadingOutInterval&&(clearInterval(this.fadingOutInterval),this.fadingOutInterval=void 0,this.visible=!1,e.forEach((e=>e.opacity=1)),this.scale.set(1,1,1))}getMaterials(){let e=this.thumbnailMesh;e||(e=this.mesh);let t=[];return Array.isArray(e.material)?t.push(...e.material):e.material&&t.push(e.material),t}create(){}createThumbnailMesh(e){return ft(this,null,(function*(){if(!this.thumbnailImages||6!=this.thumbnailImages.length)return;this.thumbnailMesh=new xt(new pa(e,e,e)),this.thumbnailMesh.geometry.scale(1,1,-1);let t=(yield this.loadTexturesAsync(this.thumbnailImages)).map((e=>new ln({map:e,side:pi,transparent:!0})));this.thumbnailMesh&&(this.thumbnailMesh.material=t,this.add(this.thumbnailMesh))}))}loadTextures(e){return e.map((e=>{let t=this.textureLoader.load(e);return t.colorSpace=en,t}))}loadTexturesAsync(e){return ft(this,null,(function*(){let t=e.map((e=>this.textureLoader.loadAsync(e))),i=yield Promise.all(t);return i.forEach((e=>e.colorSpace=en)),i}))}destroyMesh(e){var t;this.remove(e),e.clear(),e.geometry.dispose(),Array.isArray(e.material)?e.material.forEach((e=>{var t;null==(t=e.map)||t.dispose(),e.dispose()})):(null==(t=e.material.map)||t.dispose(),e.material.dispose())}destroy(){this.clearFading(),this.images=[],this.mesh&&(this.mesh instanceof xt?this.destroyMesh(this.mesh):this.mesh.traverse((e=>{e instanceof xt&&this.destroyMesh(e)})),this.mesh=void 0)}},v2=class extends up{constructor(e,t,i=200){if(super(e,t,i),6!==e.length)throw new Error(`[VRCube] Wrong number of images! Expected 6, got ${e.length}`)}create(){return ft(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(((i,n)=>ft(this,null,(function*(){let r=yield this.loadTexturesAsync([i]);e.material[n].map=r[0],t--,0===t&&(this.thumbnailImages=void 0)})))),this.destroyMesh(this.mesh),this.mesh=void 0}createMesh(){return ft(this,null,(function*(){let e=this.mesh;e.geometry=new pa(this.size,this.size,this.size),e.geometry.scale(1,1,-1);let t=(yield this.loadTexturesAsync(this.images)).map((e=>new ln({map:e,side:pi,transparent:!0})));e.material=t,this.add(e),this.thumbnailMesh&&(this.destroyMesh(this.thumbnailMesh),this.thumbnailMesh=void 0,this.thumbnailImages=void 0)}))}},y2=class extends up{constructor(e,t,i=200){if(super(e,t,i),24!==e.length)throw new Error(`[VRCube24Faces] Wrong number of images! Expected 24, got ${e.length}`);this.ratio=1,this.subPlaneWidth0=this.size*(this.ratio/(this.ratio+1)),this.subPlaneWidth1=this.size-this.subPlaneWidth0}create(){return ft(this,null,(function*(){yield this.createThumbnailMesh(this.size+.1),this.thumbnailMesh?this.createMesh():yield this.createMesh()}))}createMesh(){return ft(this,null,(function*(){var e;this.mesh=new er,this.mesh.scale.set(1,1,-1);let t=(yield this.loadTexturesAsync(this.images)).map((e=>new ln({map:e,side:Ji,transparent:!0})));if(24!==t.length)throw new Error(`[VRCube24Faces] Wrong number of materials! Expected 24, got ${t.length}`);let i=this.createPlaneOfAFace(t.slice(0,4));i.rotateOnAxis(new D(0,1,0),-Math.PI/2),i.position.set(this.size/2,0,0);let n=this.createPlaneOfAFace(t.slice(4,8));n.rotateOnAxis(new D(0,1,0),Math.PI/2),n.position.set(-this.size/2,0,0);let r=this.createPlaneOfAFace(t.slice(8,12));r.rotateOnAxis(new D(1,0,0),-Math.PI/2),r.rotateOnAxis(new D(0,0,1),Math.PI),r.rotateOnAxis(new D(1,0,0),Math.PI),r.position.set(0,this.size/2,0);let a=this.createPlaneOfAFace(t.slice(12,16));a.rotateOnAxis(new D(1,0,0),Math.PI/2),a.rotateOnAxis(new D(0,0,1),Math.PI),a.rotateOnAxis(new D(1,0,0),Math.PI),a.position.set(0,-this.size/2,0);let s=this.createPlaneOfAFace(t.slice(16,20));s.rotateOnAxis(new D(0,1,0),Math.PI),s.position.set(0,0,this.size/2),this.createPlaneOfAFace(t.slice(20,24)).position.set(0,0,-this.size/2),this.add(this.mesh),this.thumbnailMesh&&(this.destroyMesh(this.thumbnailMesh),this.remove(this.thumbnailMesh),null==(e=this.thumbnailMesh)||e.clear(),this.thumbnailMesh=void 0)}))}createPlaneOfAFace(e){var t;let i=new er,n=new ui(this.subPlaneWidth0,this.subPlaneWidth0),r=new ui(this.subPlaneWidth1,this.subPlaneWidth0),a=new ui(this.subPlaneWidth0,this.subPlaneWidth1),s=new ui(this.subPlaneWidth1,this.subPlaneWidth1),o=new xt(n,e[0]),l=new xt(r,e[1]),h=new xt(a,e[2]),c=new xt(s,e[3]);return o.position.set(this.subPlaneWidth1/2,this.subPlaneWidth1/2,0),l.position.set(-this.subPlaneWidth0/2,this.subPlaneWidth1/2,0),h.position.set(this.subPlaneWidth1/2,-this.subPlaneWidth0/2,0),c.position.set(-this.subPlaneWidth0/2,-this.subPlaneWidth0/2,0),o.geometry.scale(-1,1,1),l.geometry.scale(-1,1,1),h.geometry.scale(-1,1,1),c.geometry.scale(-1,1,1),i.add(o,l,h,c),null==(t=this.mesh)||t.add(i),i}},x2=class extends up{constructor(e,t,i=100){if(super(e,t,i),1!==e.length)throw new Error(`[VRSphere] Wrong number of images! Expected 1, got ${e.length}`)}create(){return ft(this,null,(function*(){yield this.createThumbnailMesh(this.size+.1),this.thumbnailMesh?this.createMesh():yield this.createMesh()}))}createMesh(){return ft(this,null,(function*(){var e;let t=this.mesh;t.geometry=new Ua(this.size,100,100),t.geometry.scale(-1,1,1);let i=(yield this.loadTexturesAsync(this.images)).map((e=>new ln({map:e,side:pi,transparent:!0})));t.material=i[0],this.add(t),this.thumbnailMesh&&(this.destroyMesh(this.thumbnailMesh),this.remove(this.thumbnailMesh),null==(e=this.thumbnailMesh)||e.clear(),this.thumbnailMesh=void 0)}))}},Hve=class extends tp{constructor(e,t){super(e),this.name="VRViewer",this.timer=Date.now(),this.loadedModels=[],this.minFov=50,this.maxFov=95,this.raycaster=new na,this.autoRotate=!0,this.events=[],this.isMousePressing=!1,this.settings=Wv,this.viewpoints=[],this.activeViewpointId="",this.activePanoramaId="",this.viewpointAssetsMap=new Map,this.loadingPanos=[],this.onResize=()=>{this.viewerContainer&&this.viewerContainer.parentElement&&this.resize(this.viewerContainer.parentElement.clientWidth,this.viewerContainer.parentElement.clientHeight)},this.onMouseWheel=e=>{let t=e.deltaY<0?-5:5;this.updateFov(t)},this.applyOptionsAndAddToScene=(e,t,i,n)=>ft(this,null,(function*(){let r,a=St.getUpdateProgressFunc(n),s=St.getUpdateSubProgressFunc(70,90,n);if(a(0),se.info(`[Viewer] '${e}' is loaded in ${(Date.now()-this.timer)/1e3}s, adding to scene...`),this.timer=Date.now(),i.matrix&&16===i.matrix.length){let e=new et;e.elements=i.matrix,t.applyMatrix4(e)}if(t.matrixAutoUpdate=!1,t.updateMatrix(),t.traverse((e=>{e.matrixAutoUpdate&&(e.matrixAutoUpdate=!1,e.updateMatrix())})),i.merge&&this.merge(t),a(50),i.merge){let e=Date.now();Qf.createMeshBvhAsync([t],{saveOriginalIndex:!0}),se.info(`[Viewer] Creates mesh bvh cost ${(Date.now()-e)/1e3}s`)}a(60),t.traverse((e=>{e.geometry&&e.layers.enableAll(),e instanceof Gs&&(e.visible=!1)})),a(70),i.edges&&(r=yield Hn.createOutlines(t,void 0,s)),a(90);let o={modelId:this.getUniqueModelId(i.modelId||i.src),object:t,edges:r};this.addModel(o),a(100)})),this.viewerCfg=e,this.cameraCfg=t||{eye:[0,0,0],look:[0,0,0]},this.settings=Wv,this.cameraCfg.near&&(this.settings.camera.near=this.cameraCfg.near),this.cameraCfg.far&&(this.settings.camera.far=this.cameraCfg.far),this.setSpinnerVisibility(++this.jobCount>0),this.init(),this.animate(),this.setSpinnerVisibility(--this.jobCount>0)}init(){this.initSpinner(),this.initScene(),this.initRenderer(),this.initCamera(),this.initControls(),this.initLights(),this.initInputManager(),this.initEvents(),this.initOthers()}initScene(){let e=new Si;e.background=new ct(16777215),e.matrixAutoUpdate=!0,this.scene=e}initRenderer(){var e,t;this.renderer=new Ts({antialias:!0,preserveDrawingBuffer:!1}),this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setSize(this.width,this.height),this.renderer.useLegacyLights=!1,this.css2dRenderer=new Nu,this.css2dRenderer.setSize(this.width,this.height),this.css2dRenderer.domElement.style.height="0",this.css2dRenderer.domElement.style.width="0",null==(e=this.viewerContainer)||e.appendChild(this.renderer.domElement),null==(t=this.viewerContainer)||t.appendChild(this.css2dRenderer.domElement)}initCamera(){this.scene&&(this.camera=new hr(75,this.width/this.height,this.settings.camera.near,this.settings.camera.far),this.scene.add(this.camera))}initControls(){if(!this.renderer||!this.camera)return;let e=this.camera,t=this.viewerCfg,i=new eC(e,this.renderer.domElement,!0);i.enabled=!0,i.autoRotate=this.autoRotate,i.autoRotateSpeed=t.autoRotateSpeed||-2,i.enablePan=!1,i.enableZoom=!1,i.enableRotate=!0,i.rotateSpeed=.3,i.minPolarAngle=.05*Math.PI,i.maxPolarAngle=.95*Math.PI,i.listenToKeyEvents(document.body),i.update(),this.controls=i,this.controlsHelper=new iP(e,i),this.controls.controlsHelper=this.controlsHelper,this.autoRotate&&this.controlsHelper.delayAutoRotate(),this.controlsHelper.automaticallyAdjustCameraPosition=!1,this.controls.addEventListener("end",(()=>{this.handleDragEnd&&this.handleDragEnd()}));let n=new D(0,0,0),r=new D(10,0,0);this.setCameraPositionAndDirection(n,r)}onKeyDown(e){return t=>{var i,n;let r=e.camera,a=e.controls;!r||!a||(("ArrowLeft"===t.code||"ArrowRight"===t.code||"ArrowUp"===t.code||"ArrowDown"===t.code)&&(null==(i=this.controlsHelper)||i.startToRotate(t)),null==(n=this.controlsHelper)||n.delayAutoRotate())}}initLights(){if(!this.scene)return;let e=new qs(16777215,.3);e.position.set(-2,2,4),this.scene.add(e);let t=new Du(16777215,14540253,2);t.position.set(0,300,0),this.scene.add(t)}initInputManager(){this.viewerContainer&&(this.inputManager=new Ko(this.viewerContainer))}initEvents(){let e=this.renderer,t=this.camera;if(!e||!t)return;let i=!1,n=-1,r=-1;this.addEvent("keydown",this.onKeyDown(this)),this.addEvent("wheel",this.onMouseWheel),this.addEvent("pointerdown",(t=>{var a,s;n=t.x,r=t.y,i=!1,this.isMousePressing=!0,this.autoRotate&&(null==(a=this.controlsHelper)||a.delayAutoRotate()),t.button===XR.LEFT&&(null==(s=t.originalEvent)?void 0:s.target)instanceof HTMLCanvasElement&&(e.domElement.style.cursor="move")})),this.addEvent("pointermove",(e=>{n>=0&&r>=0&&(Math.abs(e.x-n)>5||Math.abs(e.y-r)>5)&&(i=!0)})),this.addEvent("pointerup",(n=>{var r,a,s;this.isMousePressing=!1,this.autoRotate&&(null==(r=this.controlsHelper)||r.delayAutoRotate()),e.domElement.style.cursor="auto";let o=n.button;if(!i&&o===XR.LEFT)if(null!=(a=n.originalEvent)&&a.target&&n.originalEvent.target instanceof HTMLDivElement){let e=Mf.tryFindObjectId(n.originalEvent.target);if(e){let t=null==(s=this.scene)?void 0:s.getObjectById(e);if(t){let e=t.userData.hotpoint;e&&(se.info("[Viewer] Clicked on hotpoint: ",e.hotpointId||e),this.onHotpointClicked&&this.onHotpointClicked(e))}}}else{let e=this.getIntersection(n);if(e){let i=e=>St.vectorToString(e),n=e.point,r=n.clone().sub(t.position).normalize();se.info(`[Viewer] Clicked at: ${i(n)},\n Camera position: ${i(t.position)},\n Target direction: ${i(r)}`)}}}))}initOthers(){!this.controls||!this.renderer||!this.camera||(this.renderer.domElement.style.outlineWidth="0")}animate(){var e,t,i;if(this.requestAnimationFrameHandle=requestAnimationFrame(this.animate.bind(this)),this.minFrameInterval>0){let e=Date.now()-this.lastFrameExecuteTime;if(e<this.minFrameInterval)return;if(this.lastFrameExecuteTime=Date.now(),this.autoRotate){let t=this.controlsHelper;t&&t.autoRotateRemainingTime>0&&!this.isMousePressing&&(t.autoRotateRemainingTime-=e,t.autoRotateRemainingTime<=0&&this.controls&&t.startAutoRotate())}}if(this.viewerContainer&&this.viewerContainer){let{width:e,height:t}=this.viewerContainer.getBoundingClientRect();(this.width!==e||this.height!==t)&&this.resize(e,t)}this.controls&&this.controls.update(),this.scene&&this.camera&&(this.dispatchEvent("BeforeRender"),null==(e=this.renderer)||e.render(this.scene,this.camera),null==(t=this.css2dRenderer)||t.render(this.scene,this.camera),null==(i=this.css3dRenderer)||i.render(this.scene,this.camera),this.dispatchEvent("AfterRender")),this.dispatchEvent("OnAnimate")}clearAllCachedPanoramas(){this.handleCameraUpdateInterval(),this.loadingPanos.forEach((e=>{e.creationPromise&&(e.creationPromise.cancel(),e.creationPromise=void 0)})),this.viewpointAssetsMap.forEach((e=>{var t;let i=e.panoramas;for(let n=i.length-1;n>=0;--n){let e=i[n];e.box.destroy(),null==(t=this.scene)||t.remove(e.box)}})),this.loadingPanos=[],this.viewpointAssetsMap.clear(),this.activePanoramaId="",this.activePanoramaId=""}destroy(){var e;this.events.forEach((e=>{var t;return null==(t=this.inputManager)?void 0:t.removeEventListener(e.type,e.func)})),this.events=[],this.clearAllCachedPanoramas(),this.css2dRenderer&&(null==(e=this.viewerContainer)||e.removeChild(this.css2dRenderer.domElement)),super.destroy()}updateFov(e){var t;let i=this.camera;if(!i)return;let n=this.minFov,r=this.maxFov,a=e=>{let t=i.fov+e;t=Math.min(t,r),t=Math.max(t,n),i.fov!==t&&(i.fov=t,i.updateProjectionMatrix())},s=e/20;for(let o=0;o<20;++o)setTimeout((()=>a(s)),5*o);this.autoRotate&&(null==(t=this.controlsHelper)||t.delayAutoRotate())}setMinAndMaxFov(e,t){let i=this.controls;i&&(this.minFov=e,this.maxFov=t,i.minFov=e,i.maxFov=t)}resize(e,t){super.resize(e,t),t>0&&(this.css2dRenderer&&(this.css2dRenderer.setSize(e,t),this.css2dRenderer.domElement.style.height="0",this.css2dRenderer.domElement.style.width="0"),this.css3dRenderer&&this.css3dRenderer.setSize(e,t))}enableAutoRotate(e){this.controls&&(this.autoRotate=e,this.controls.autoRotate=e)}setAutoRotateSpeed(e=1){this.controls&&(this.controls.autoRotateSpeed=e)}setCameraFov(e=75){let t=this.camera;t&&(t.fov=e,t.updateProjectionMatrix())}addEvent(e,t){var i;null==(i=this.inputManager)||i.addEventListener(e,t),this.events.push({type:e,func:t})}setCameraPositionAndDirection(e,t,i){let n,r,a=this.camera,s=this.controls;if(!a||!s)return;n=t?Array.isArray(t)?new D(t[0],t[1],t[2]):new D(t.x,t.y,t.z):s.target.clone().sub(a.position),n.normalize(),r=Array.isArray(e)?new D(e[0],e[1],e[2]):new D(e.x,e.y,e.z);let o=r.clone().addScaledVector(n,.01);this.fianlCameraPosition=r,this.finalCameraTarget=o;let l=(e,t)=>{a.position.set(e.x,e.y,e.z),s.target.set(t.x,t.y,t.z),s.update()};if(!1===i)return this.cameraUpdateInterval&&clearInterval(this.cameraUpdateInterval),void l(r,o);let h=a.position.clone(),c=s.target.clone(),u=500,d=Date.now();this.cameraUpdateInterval&&clearInterval(this.cameraUpdateInterval),this.cameraUpdateInterval=setInterval((()=>{let e=Date.now()-d;e>u&&(e=u);let t=(e,t,i)=>{let n=e.x+(t.x-e.x)*i,r=e.y+(t.y-e.y)*i,a=e.z+(t.z-e.z)*i;return new D(n,r,a)},i=t(h,r,e/u),n=t(c,o,e/u);l(i,n),e>=u&&(clearInterval(this.cameraUpdateInterval),this.cameraUpdateInterval=void 0)}),10)}getCameraPositionAndDirection(){let e=this.camera;if(!e)return;let t=e.position,i=new D;return e.getWorldDirection(i),{position:{x:t.x,y:t.y,z:t.z},direction:{x:i.x,y:i.y,z:i.z}}}getCameraFov(){let e=this.camera;if(e)return e.fov}setViewpoints(e){this.handleCameraUpdateInterval(),this.viewpointAssetsMap.size>0&&(this.viewpointAssetsMap.forEach((e=>{let t=e.panoramas,i=e.css2dObjects;t.forEach((e=>{var t;e.box.destroy(),null==(t=this.scene)||t.remove(e.box)})),i.forEach((e=>{var t;null==(t=this.scene)||t.remove(e)}))})),this.viewpointAssetsMap.clear()),this.loadingPanos.forEach((e=>{e.creationPromise&&(e.creationPromise.cancel(),e.creationPromise=void 0)})),this.loadingPanos=[],this.activeViewpointId="",this.activePanoramaId="",this.viewpoints=e}loadModel(e,t){return ft(this,null,(function*(){var i,n;this.timer=Date.now(),this.increaseJobCount();let r=e.modelId||e.src,a=this.translate("ProgressBar.Loading"),s=e=>{var i;null==(i=this.loadingProgressBar)||i.updateProgress(r,a,e),t&&t(new ProgressEvent("LoadProgress",{loaded:e,total:100}))},o=(e,i,n)=>{var s;let o=100*e.loaded/e.total;o=o*(n-i)/100+i,null==(s=this.loadingProgressBar)||s.updateProgress(r,a,o),t&&t(new ProgressEvent("LoadProgress",{loaded:o,total:100}))},l=e=>o(e,0,50),h=e=>o(e,50,99);null==(i=this.loadingProgressBar)||i.addProgressItem(r),s(0);try{let t=yield(new ja).loadModel(e.src,e.fileFormat,l);if(t)return yield this.applyOptionsAndAddToScene(e.src,t,e,h),Promise.resolve()}catch(t){let n=`Error loading ${e.src}`;return se.error(n,t),Promise.reject(n)}finally{this.decreaseJobCount(),s(100),null==(n=this.loadingProgressBar)||n.delayRemoveProgressItem(r)}return Promise.reject()}))}setModelVisibility(e,t){let i=this.loadedModels.find((t=>t.modelId===e)),n=i&&i.object;if(!n)throw new Error(`Failed to find model by modelId '${e}'!`);n.visible=t,this.enableRender()}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),se.info(`[Viewer] Added '${e.modelId}' to scene in ${(Date.now()-this.timer)/1e3}s`),this.renderer.shadowMap.needsUpdate=!0,this.enableRender(),this.dispatchEvent("ModelLoaded",{modelId:e.modelId,bbox:t}),this.decreaseJobCount()}addPanorama(e,t){let i=this.viewpoints.find((t=>t.id===e));if(!i)throw new Error(`[Viewer] Failed to find viewpoint by id '${e}'`);i.panoramas||(i.panoramas=[]),i.panoramas.push(t)}findPanorama(e,t){let i=this.viewpoints.find((t=>t.id===e));if(i&&i.panoramas)return i.panoramas.find((e=>e.id===t))}setHotpointsVisibility(e,t="",i=[]){if(!this.viewpoints)return;let n=t=>{var n;let r=this.viewpointAssetsMap.get(t.id),a=(null==r?void 0:r.css2dObjects)||[];null==(n=t.hotpoints)||n.forEach((n=>{if(i&&i.length>0){if(-1===i.findIndex((e=>e===n.hotpointId)))return;if(n.visible=e,this.activeViewpointId===t.id){let t=a.find((e=>e.userData.hotpoint.hotpointId===n.hotpointId));t&&(t.visible=e)}}else n.visible=e,this.activeViewpointId===t.id&&a.forEach((t=>t.visible=e))}))};if(t){let e=this.viewpoints.find((e=>e.id===t));e&&n(e)}else this.viewpoints.forEach((e=>n(e)))}addHotpoints(e){if(!this.activeViewpointId||!e)return;let t=this.viewpoints.find((e=>e.id===this.activeViewpointId)),i=this.viewpointAssetsMap.get(this.activeViewpointId);!t||!i||(t.hotpoints||(t.hotpoints=[]),e.forEach((e=>{var n,r;if(-1!==(null==(n=t.hotpoints)?void 0:n.findIndex((t=>t.hotpointId===e.hotpointId))))return void se.warn(`[Viewer] Duplicated hotpointId: ${e.hotpointId}`);let a=t.position||[0,0,0],s=e.anchorPosition,o=Mf.createHotpoint(e.html),l=new D(s[0],s[1],s[2]),h=new D(a[0],a[1],a[2]);this.relocateAnchorIfTooCloseToCamera(o,l,h),o.visible=!1!==e.visible,o.userData.hotpoint=e,i.css2dObjects.push(o),null==(r=this.scene)||r.add(o),t.hotpoints.push(e)})))}removeHotpoints(e){if(!this.activeViewpointId||!e)return;let t=this.viewpoints.find((e=>e.id===this.activeViewpointId)),i=this.viewpointAssetsMap.get(this.activeViewpointId);!t||!i||e.forEach((e=>{var n,r;if(t.hotpoints)for(let i=t.hotpoints.length-1;i>=0;--i)e===t.hotpoints[i].hotpointId&&t.hotpoints.splice(i,1);for(let t=i.css2dObjects.length-1;t>=0;--t){let a=i.css2dObjects[t];e===(null==(n=a.userData.hotpoint)?void 0:n.hotpointId)&&(i.css2dObjects.splice(t,1),null==(r=this.scene)||r.remove(a))}}))}activeViewpointById(e,t,i,n){this.activatePanoramaById(e,"",!0,t,i,n)}activatePanoramaById(e,t,i=!0,n,r,a){if(e===this.activeViewpointId&&t===this.activePanoramaId)return;let s=this.viewpoints.find((t=>t.id===e));s&&this.activatePanorama(s,t,i,n,r,a)}removeCachedPanoramas(e={}){this.viewpointAssetsMap.forEach(((t,i)=>{var n;let r=t.panoramas;for(let a=r.length-1;a>=0;--a){let t=r[a];if(i===this.activeViewpointId&&t.id===this.activePanoramaId||e[i]&&e[i].includes(t.id))return;t.box.destroy(),null==(n=this.scene)||n.remove(t.box),r.splice(a,1)}}))}unlimitControlsAndShowAssets(e=!1){if(this.controls){let e=this.controls;e.enablePan=!0,e.enableZoom=!0}this.viewpointAssetsMap.forEach((t=>{t.panoramas.forEach((e=>{e.box.visible=!0})),e&&t.css2dObjects.forEach((e=>{e.visible=!0}))}))}relocateAnchorIfTooCloseToCamera(e,t,i){let n=this.camera;if(!n)return se.error("[Viewer] Camera is not initialized"),void e.position.set(t.x,t.y,t.z);let r,a=Math.abs(t.distanceTo(i));if(a<n.near){let e=t.clone().sub(i).normalize();r=i.clone().add(e.multiplyScalar(a+1))}else r=t;e.position.set(r.x,r.y,r.z)}activatePanorama(e,t,i=!0,n,r,a){return ft(this,null,(function*(){var s,o,l;let h=(e,t,i)=>{let n=e.panoramas.find((e=>e.id===t)),r=null==n?void 0:n.box;r&&(i?this.fadeIn(r):this.fadeOut(r))},c=(e,t)=>{e.css2dObjects.forEach((e=>{t?!1!==e.userData.hotpoint.visible&&(e.visible=t):e.visible=t}))},u=()=>{var t;let r=new D(0,0,0),a=new D(1,0,0),s=null==(t=this.getCameraPositionAndDirection())?void 0:t.direction;s&&a.set(s.x,s.y,s.z);let o=e.position;if(o&&3===o.length&&r.set(o[0],o[1],o[2]),i){let t=e.initialDirection;t&&3===t.length&&a.set(t[0],t[1],t[2])}this.setCameraPositionAndDirection(r,a,n)};!t&&(null==(s=e.panoramas)?void 0:s.length)>0&&(t=e.panoramas[0].id||""),this.handleCameraUpdateInterval();let d=this.viewpointAssetsMap.get(this.activeViewpointId),p=this.viewpointAssetsMap.get(e.id);if(this.activeViewpointId&&d&&(this.activeViewpointId!==e.id&&c(d,!1),h(d,this.activePanoramaId,!1)),p&&p.panoramas.find((e=>e.id===t)))return h(p,t,!0),this.activeViewpointId!==e.id&&c(p,!0),this.activeViewpointId!==e.id&&u(),this.activeViewpointId=e.id,this.activePanoramaId=t,void(r&&r(e));this.activeViewpointId=e.id,this.activePanoramaId=t;try{if(this.loadingPanos.some((i=>i.viewpointId===e.id&&i.panoramaId===t)))return void se.warn(`[Viewer] Panorama with viewpointId=${e.id} and panoramaId=${t} is being created`);let i=new TA(this.createBoxByImageOrImages(e,t));this.loadingPanos.push({viewpointId:e.id,panoramaId:t,creationPromise:i});let n=yield i.promise;this.loadingPanos=this.loadingPanos.filter((i=>i.viewpointId!==e.id||i.panoramaId!==t));let a=e.position;a&&3===a.length&&n.position.set(a[0],a[1],a[2]),this.activeViewpointId===e.id&&this.activePanoramaId===t?(this.fadeIn(n),null==(o=this.scene)||o.add(n),u()):(n.visible=!1,null==(l=this.scene)||l.add(n));let s={id:t,box:n},h=this.viewpointAssetsMap.get(e.id);if(h)h.panoramas.push(s),c(h,!0);else{let i=[];e.hotpoints&&e.hotpoints.forEach((r=>{let a=r.anchorPosition,s=Mf.createHotpoint(r.html);s.visible=!1!==r.visible,s.userData.hotpoint=r;let o=new D(a[0],a[1],a[2]);this.relocateAnchorIfTooCloseToCamera(s,o,n.position),(this.activeViewpointId!==e.id||this.activePanoramaId!==t)&&(s.visible=!1),i.push(s)}));let r={panoramas:[s],css2dObjects:i};this.viewpointAssetsMap.set(e.id,r),i.forEach((e=>{var t;return null==(t=this.scene)?void 0:t.add(e)}))}r&&r(e)}catch(e){"cancel"!==e.type&&a&&a(e)}}))}createBoxByImageOrImages(e,t){var i;let n=e.imageOrImages,r=e.thumbnailImages;if((null==(i=e.panoramas)?void 0:i.length)>0){let i=this.findPanorama(e.id,t);i||(i=e.panoramas[0],se.warn(`[Viewer] Failed to find panorama by id '${t}', will use the first one`)),n=i.images,r=i.thumbnails}if(!n)throw new Error("[Viewer] Invalid images!");if(Array.isArray(n)||(n=[n]),1===n.length)return this.createBoxByImage(n,r);if(6===n.length)return this.createBoxBy6Images(n,r);if(24===n.length)return this.createBoxBy24Images(n,r);throw new Error(`[Viewer] Wrong number of images! Expected 1/6/24, got ${n.length}`)}createBoxByImage(e,t){return ft(this,null,(function*(){let i=new x2(e,t);return yield i.create(),i}))}createBoxBy6Images(e,t){return ft(this,null,(function*(){if(6!==e.length)throw new Error(`[VRCube] Wrong number of images! Expected 6, got ${e.length}`);let i=new v2(e,t);return yield i.create(),i}))}createBoxBy24Images(e,t){return ft(this,null,(function*(){if(24!==e.length)throw new Error(`[VRCube] Wrong number of images! Expected 24, got ${e.length}`);let i=new y2(e,t);return yield i.create(),i}))}getIntersection(e){if(!this.camera||!this.scene)return;let t=this.viewpointAssetsMap.get(this.activeViewpointId);if(!t)return;let i=t.panoramas.find((e=>e.id===this.activePanoramaId));if(!i)return;let n=i.box,r=this.viewerContainer,a=new xe;e&&(a=an.getScreenCoordinateByEvent(e,r));let s=an.screen2Ndc(a,this.camera,r);this.raycaster.setFromCamera(s,this.camera);let o=[n],l=this.raycaster.intersectObjects(o,!0)||[];return l.length>0?l.find((e=>{let t=e.object;return t.visible&&t instanceof xt})):void 0}fadeIn(e,t=500){e.fadeIn(t)}fadeOut(e,t=1e3){e.fadeOut(t)}handleCameraUpdateInterval(){if(this.cameraUpdateInterval){clearInterval(this.cameraUpdateInterval);let e=this.fianlCameraPosition,t=this.finalCameraTarget;if(e&&t&&this.controls&&this.camera){this.camera.position.set(e.x,e.y,e.z);let i=this.controls;i.target.set(t.x,t.y,t.z),i.update()}this.cameraUpdateInterval=void 0}this.fianlCameraPosition=void 0,this.finalCameraTarget=void 0}getHitResult(e){let t={location:null};if(!this.camera)return t;let i=this.getIntersection(e);return t.location=i?{x:i.point.x,y:i.point.y,z:i.point.z}:null,t}lookToPosition(e){var t;if(!this.camera)return;this.handleCameraUpdateInterval();let i=new D(e[0],e[1],e[2]).clone().sub(this.camera.position);null==(t=this.controlsHelper)||t.lookTo(i)}merge(e){this.increaseJobCount();try{let t=[];e.traverse((e=>{e.geometry&&e.material&&t.push(e)})),Rr.deepMerge(t,e)}finally{this.decreaseJobCount()}}},b2=class extends on{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 i=new D(0,0,0),n=new D(1,0,0),r=new D(0,1,0),a=new Sc(n,i,this.AXIS_LENGTH,this.AXIS_COLOR_X,0,0),s=new Sc(r,i,this.AXIS_LENGTH,this.AXIS_COLOR_Y,0,0);if(this.add(a,s),!t){let e=new D(0,0,1),t=new Sc(e,i,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"),i=this.createText("Y","#00ff00");if(t.position.set(this.AXIS_LENGTH+.1,0,0),i.position.set(.1,this.AXIS_LENGTH,.1),this.add(t,i),!e){let e=this.createText("Z","#0000ff");e.position.set(0,0,this.AXIS_LENGTH+.1),this.add(e)}}createText(e,t,i=14){let n=document.createElement("div");n.innerHTML=e;let r=n.style;return r.color=t,r.width=`${i}px`,r.height=`${i}px`,r.textAlign="center",r.top="0px",r.left="0px",new qv(n)}},tV=class extends or{constructor(e,t){super(e,{id:(null==t?void 0:t.id)||tV.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,i=100,n=100;if(this.cfg.containerId&&(t=document.getElementById(this.cfg.containerId),t&&(i=t.clientWidth,n=t.clientHeight)),!t){let i="axisGizmo";t=document.createElement("div"),t.id=i,null==(e=this.viewer.widgetContainer)||e.appendChild(t)}this.renderer=new Ts({antialias:!0,alpha:!0}),this.renderer.setSize(i,n),t.appendChild(this.renderer.domElement),this.css2dRenderer=new Nu,this.css2dRenderer.setSize(i,n),this.css2dRenderer.domElement.style.height="0",this.css2dRenderer.domElement.style.width="0",t.appendChild(this.css2dRenderer.domElement)}initScene(){this.scene=new Si,this.camera=new Nr(-1,1,1,-1,.1,100),this.scene.add(this.camera),this.coordinateAxes=new b2(!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 D;e.getWorldDirection(t);let i=e.up;this.updateCameraDirection(t,i)}}updateCameraDirection(e,t){if(!this.camera||!e)return;e.normalize();let i=.3;this.camera.position.set(2*-e.x+i,2*-e.y+i,2*-e.z+i),this.camera.lookAt(i,i,i),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)}},eV=tV;eV.DEFAULT_ID="AxisGizmoPlugin";var rV=Xi(kl(),1),o0t="bottomBar",l0t={"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=document.createElement("span");if(!e.viewer.scene)return void(t.textContent="Failed!");t.textContent="Comupting...";let i={components:{},points:0,faces:0,materials:{},lights:{}},n=["SKYBOX","GROUND_GRID","GROUND_GRASS","BIM_VIEWER_BOX_HELPER"];e.viewer.scene.traverse((e=>{(e instanceof xt||e instanceof fr||e instanceof ii)&&!n.includes(e.name)?((e,t)=>{if(t.components[e.type]?t.components[e.type]++:t.components[e.type]=1,e.geometry){let i=e.geometry;if(e instanceof xt)if(i.index&&i.index.count){let n=Math.round(i.index.count/3);e instanceof Oi&&(n*=e.count),t.faces+=n}else if(i.groups.length>0)for(let e=0;e<i.groups.length;++e)t.faces+=i.groups[e].count/3;if(i.attributes.position){let e=i.attributes.position;e.count&&e.itemSize&&(t.points+=e.count)}}let i=e=>{t.materials[e]?t.materials[e]++:t.materials[e]=1},n=e.material;n instanceof yr?i(n.id):Array.isArray(n)&&n.forEach((e=>i(e.id)))})(e,i):e instanceof Gs&&(i.lights[e.type]?i.lights[e.type]++:i.lights[e.type]=1)}));let r=(e,i)=>{t.innerHTML+=`<p><span>${e}:</span>${i}</p>`};t.innerHTML="";let a=` (${(e=>{var t;let i=null==(t=e.renderer)?void 0:t.domElement;return null==i?void 0:i.dataset.engine})(e.viewer)})`;r("Version",`${JE}${a}`),r("Components",JSON.stringify(i.components)),r("Points",i.points),r("Faces",i.faces),r("Materials",Object.keys(i.materials).length),r("Lights",JSON.stringify(i.lights)),"DxfViewer"===e.viewer.name&&r("Entities",e.viewer.getEntitiesCount()),e.tooltip.setContent(t),e.tooltip.show()},onDeactive:e=>{e.tooltip.hide()},onUpdate:e=>{let t=e.viewer.renderer,i=document.createElement("span"),n=(e,t)=>{i.innerHTML+=`<p><span>${e}:</span>${t}</p>`};i.innerHTML="<p>-- Renderer Info --</p>";let r=null==t?void 0:t.info;n("Drawcalls",JSON.stringify(null==r?void 0:r.render.calls)),n("Points",JSON.stringify(null==r?void 0:r.render.points)),n("Lines",JSON.stringify(null==r?void 0:r.render.lines)),n("Triangles",JSON.stringify(null==r?void 0:r.render.triangles)),n("Geometries",JSON.stringify(null==r?void 0:r.memory.geometries)),n("Textures",JSON.stringify(null==r?void 0:r.memory.textures)),e.tooltip.updateChildContent(i)}},"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=()=>{if(!e.viewer||!e.viewer.camera||!e.viewer.controls)return;let i=e.viewer.camera,n=e.viewer.controls,r=e=>St.numberToString(e),a=e=>St.vectorToString(e),s=i.position,o=n instanceof va?n.getTarget(new D):n.target;if(s){let t=document.createElement("span");t.innerHTML=`\n <p><span>Camera position:</span>${a(s)}</p>\n <p><span>Camera target:</span>${a(o)}</p>`,i instanceof Nr&&(t.innerHTML+=`\n <p>top: ${r(i.top)}, bottom: ${r(i.bottom)}, left: ${r(i.left)}, right: ${r(i.right)}</p>\n <p>zoom: ${r(i.zoom)}</p>`),e.tooltip.setContent(t)}e.active||window.removeEventListener("mouseup",t)};if(t(),window.addEventListener("mouseup",t),"BimViewer"===e.viewer.name){let i=e.viewer.controls;null==i||i.addEventListener("update",t)}else e.viewer.controls.addEventListener("change",t);e.tooltip.show()},onDeactive:e=>{e.tooltip.hide()}},"gemini-viewer-threejs-tips":{icon:{default:"icon-more",iconFont:"gemini-viewer-icon"},mutexIds:["gemini-viewer-threejs-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()}}},Vve=class extends or{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=o0t,t.classList.add("bottom-bar"),(0,rV.forEach)(l0t,((e,i)=>{let n=this.createItem(this.viewer,i,e);t.appendChild(n.element)})),this.element=t,null==(e=this.viewer.widgetContainer)||e.appendChild(this.element),this.viewer.addEventListener("AfterRender",(()=>{this.update()}))}createItem(e,t,i){let n=new nV(e,this,t,i);return this.itemList.set(t,n),n}},nV=class{constructor(e,t,i,n){this.viewer=e,this.bottomBar=t,this.menuId=i,this.cfg=n,this.eventBus=Py(),this.active=!1,this.itemconfig=n,this.element=this.createButton(this.menuId,n),this.tooltip=new Xl(i+"-tooltip",null,{parentNode:e.widgetContainer}),this.eventBus.on("activeChange",(e=>{e?(this.element.classList.add("active"),(0,rV.forEach)(n.mutexIds,(e=>{var t;let i=null==(t=this.bottomBar)?void 0:t.itemList.get(e);i&&i.active&&i.setActive(!1)})),n.onActive&&n.onActive(this)):(this.element.classList.remove("active"),n.onDeactive&&n.onDeactive(this)),this.element instanceof HTMLElement&&MA(this.element.classList,n.icon,this.active)}))}createButton(e,t){let i=document.createElement("i");i.id=e;let{default:n="icon-new",iconFont:r=jv}=t.icon;return i.classList.add("icon"),i.classList.add(r),i.classList.add(n),i.onclick=()=>{this.active=!this.active,t.onClick&&t.onClick(this),this.eventBus.emit("activeChange",this.active)},i}setActive(e){this.active=e,this.eventBus.emit("activeChange",this.active)}update(){this.active&&this.itemconfig.onUpdate&&this.itemconfig.onUpdate(this)}},pg=Xi(kl(),1),B_=Xi(kl(),1),us=Xi(kl(),1),E2=(e=>(e[e.ClickEvent=1]="ClickEvent",e[e.Popup=2]="Popup",e[e.SubMenu=3]="SubMenu",e[e.Switch=4]="Switch",e))(E2||{}),_2=(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))(_2||{}),T2=[["HomeView","OrthoMode","FullScreen","ZoomToRectangle","GetScreenshot"],["Measure","Markup","MarkupVisibility","Section"],["BimTree","Viewpoint","Annotation","Property","Compared","QuitCompare","Layers"],["Settings"]],hp=class{constructor(e,t,i=[]){this.visible=!0,this.menuList=new Map,this.keydown=e=>{var t,i;if(this.visible&&"Escape"===e.code){if(null!=(t=this.viewer.measurePlugin)&&t.isMeasuring()||null!=(i=this.viewer.getMarkupManager())&&i.isMarkupActive())return;this.clearActive()}},this.viewer=e,this.menuCfg=t,this.groupCfg=i,this.init(),window.addEventListener("keydown",this.keydown,!1)}init(){var e;let t=document.createElement("div");t.classList.add("toolbar");let i=this.menuCfg;this.groupCfg.forEach(((e,n)=>{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,us.get)(i,e);if(t&&!1!==t.visible){let i=this.createToolbarMenu(this.viewer,e,t);r.appendChild(i.element)}})),r.hasChildNodes()&&(n&&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 i=this.menuList.get(e);null==i||i.setActive(t),this.activateMenuId=t?e:void 0}createToolbarMenu(e,t,i,n){let r=new iV(e,this,t,i,n);if(this.menuList.set(t,r),i.children){let t=document.createElement("div");t.classList.add("toolbar-sub-menu");let n=document.createElement("div");n.classList.add("toolbar-sub-menu-list"),t.appendChild(n),(0,us.forIn)(i.children,((t,i)=>{if(t&&!1!==t.visible){let a=this.createToolbarMenu(e,i,t,r);n.appendChild(a.element)}})),r.element.appendChild(t)}return r}updateMenu(e,t){(0,us.assign)(this.menuCfg[e],t),this.refresh()}updateMenus(e){(0,us.forEach)(e,(({menuId:e,config:t})=>{(0,us.assign)(this.menuCfg[e],t)})),this.refresh()}addMenu(e,t,i){if((0,us.keys)(this.menuCfg).includes(e))se.error("[Toolbar]",e,"exists.");else{if((0,us.assign)(this.menuCfg,{[e]:t}),i){let[t,n]=i;if(t>this.groupCfg.length-1)this.groupCfg=(0,us.concat)(this.groupCfg,[[e]]);else{let i=this.groupCfg[t];this.groupCfg[t]=n>i.length-1?(0,us.concat)(i,e):(0,us.concat)((0,us.take)(i,n),e,(0,us.takeRight)(i,i.length-n))}}else this.groupCfg=(0,us.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)}},iV=class{constructor(e,t,i,n,r){this.eventBus=Py(),this.toolbar=t,this.menuId=i,this.active=n.defaultActive||!1,this.element=n.customElement&&n.customElement(e,this.menuId,n)||this.createButton(e,this.menuId,n),this.eventBus.on("activeChange",(t=>{t?(this.element.classList.add("active"),(0,us.forEach)(n.mutexIds,(e=>{var t;let i=null==(t=this.toolbar)?void 0:t.menuList.get(e);i&&i.active&&i.setActive(!1)})),n.onActive&&n.onActive(e)):(this.element.classList.remove("active"),n.onDeactive&&n.onDeactive(e)),this.element.firstChild instanceof HTMLElement&&MA(this.element.firstChild.classList,n.icon,this.active),r&&r.setActive(t)})),Fn.isMobile?(this.element.ontouchstart=t=>{switch(this.element.classList.toggle("toolbar-parent-menu-active"),this.element.classList.toggle("toolbar-menu-active"),t.stopPropagation(),n.type){case 1:n.onClick&&n.onClick(e,this.toolbar,t);break;case 4:n.onClick&&n.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(),n.type){case 1:n.onClick&&n.onClick(e,this.toolbar,t);break;case 4:n.onClick&&n.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,i){let n=document.createElement("div");n.id=t,n.classList.add("toolbar-menu"),i.defaultActive&&n.classList.add("active"),i.children&&n.classList.add("toolbar-parent-menu");let{default:r="icon-new",iconFont:a=jv}=i.icon;return n.innerHTML=`<div class="icon ${a} ${r}"></div>`,n.title=Qu(i.menuName),n.innerHTML+=`<span>${n.title}</span>`,n}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)}},zve={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,i)=>{let n=i.target.parentElement,r=null==n?void 0:n.firstElementChild,a=document.createElement("input");a.setAttribute("type","color"),a.value=An.rgba2Color(e.getMarkupLineColor()),a.click(),a.oninput=t=>{let i=t.target.value;e.setMarkupLineColor(...An.color2rgba(i)),r.style.color=i}}},LineWidth:{menuName:"Toolbar.markupLineWidth",icon:{default:"icon-line"},customElement(e,t,i){let n=document.createElement("div");return n.id=t,n.classList.add("toolbar-menu"),i.children&&n.classList.add("toolbar-parent-menu"),n.title=Qu(i.menuName),n.innerHTML+=`<span>${n.title}</span>`,n},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,i){let n=document.createElement("div");return n.id=t,n.classList.add("toolbar-menu"),i.children&&n.classList.add("toolbar-parent-menu"),n.title=Qu(i.menuName),n.innerHTML+=`<span>${n.title}</span>`,n},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=>{se.info("[Toolbar]","Clear Markup",e),e.clearMarkups()},type:1,menuName:"Toolbar.clearMarkup"},MarkupQuit:{icon:{default:""},customElement(e,t,i){let n=document.createElement("div");return n.id=t,n.classList.add("toolbar-menu"),i.children&&n.classList.add("toolbar-parent-menu"),n.title=Qu(i.menuName),n.innerHTML+=`<span>${n.title}</span>`,n},onClick:e=>{var t;null==(t=e.getMarkupManager())||t.deactivate(),e.dispatchEvent("MarkupDeactivated")},type:1,menuName:"Toolbar.quitMarkup"}},Gve=[["Arrow","Rect","CloudRect","PolyLine","Ellipse","Circle","Text","StrokeStyle","FontSize","MarkupClear","MarkupQuit"]],w2=class extends hp{constructor(e,t,i=[]){super(e,t,i),this.keydown=()=>{}}},sV=class extends or{constructor(e,t){super(e,{id:(null==t?void 0:t.id)||sV.DEFAULT_ID}),this.cfg=t||{},this.cfg.type=this.cfg.type||"image/png",this.cfg.quality=this.cfg.quality||.8}getScreenshot(){var e;let t=null==(e=this.viewer.renderer)?void 0:e.domElement;if(t)return t.toDataURL(this.cfg.type,this.cfg.quality)}getScreenshotByScreenBBox(e){return ft(this,null,(function*(){var t;let i=null==(t=this.viewer.renderer)?void 0:t.domElement;if(!i)return;let n=i.width,r=i.height,a=e.min.x,s=e.min.y,o=e.max.x,l=e.max.y;if(a=Math.max(a,0),a=Math.min(a,n),s=Math.max(s,0),s=Math.min(s,r),o=Math.min(o||n,n),o=Math.max(o,0),l=Math.min(l||r,r),l=Math.max(l,0),0===Math.abs(o-a)||0===Math.abs(l-s))return void se.error(`[Screenshot] Invalid input, minX: ${a}, minY: ${s}, maxX: ${o}, maxY: ${l}`);let h=new Mi;h.expandByPoint(new xe(a,s)),h.expandByPoint(new xe(o,l));let c=yield St.canvasToImage(i),u=document.createElement("canvas");u.width=i.width,u.height=i.height;let d=window.devicePixelRatio,p=u.getContext("2d");return p.drawImage(c,0,0,c.width/d,c.height/d),St.renderingContextToImage(p,h,this.cfg.type,this.cfg.quality)}))}getScreenshotByWorldBBox(e){return ft(this,null,(function*(){let t=this.viewer.camera,i=this.viewer.container,n=an.worldBBox2Screen(e,t,i);return this.getScreenshotByScreenBBox(n)}))}getScreenshotAsync(){return ft(this,arguments,(function*(e="BoxSelection"){var t;this.cancel();let i,n=this.viewer,r=null==(t=n.renderer)?void 0:t.domElement;if(!r||!n.viewerContainer||!n.camera)return;if("PickMarkup"===e?(this.pickMarkupHelper||(this.pickMarkupHelper=new RP(n)),i=yield this.pickMarkupHelper.pick()):"BoxSelection"===e&&(this.boxSelectHelper||(this.boxSelectHelper=new ep(n)),i=yield this.boxSelectHelper.select()),"Default"!==e&&!i)return;let a=yield St.canvasToImage(r),s=document.createElement("canvas");s.width=r.width,s.height=r.height;let o=window.devicePixelRatio,l=s.getContext("2d");if(l.drawImage(a,0,0,a.width/o,a.height/o),n.overlayRender){let e=yield n.overlayRender.getImage((e=>e instanceof Lr||e instanceof Ai));l.drawImage(e,0,0,e.width/o,e.height/o)}let h=this.cfg.type,c=this.cfg.quality,u=St.renderingContextToImage(l,i,h,c);return n instanceof ip?{base64Image:u,viewExtent:n.getCurrentViewExtent(),imageType:h}:{base64Image:u,imageType:h}}))}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()}},dp=sV;dp.DEFAULT_ID="ScreenshotPlugin";var Yy=class{constructor(e,t,i=document.body){this.container=i,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,i=e.clientY-this.diffY;this.element.style.left=t+"px",this.element.style.top=i+"px"},this.element=document.createElement("div"),this.element.id=e,this.element.classList.add("pop-panel");let n=document.createElement("div");n.classList.add("pop-panel-header"),n.append(t),this.element.appendChild(n),this.header=n;let r=document.createElement("div");r.classList.add("pop-panel-body"),this.element.appendChild(r),this.body=r,n.addEventListener(gH,this.start),n.addEventListener(mH,this.stop),document.body.addEventListener(Rf,this.follow),this.container.appendChild(this.element)}destroy(){document.body.removeEventListener(Rf,this.follow),this.element.removeEventListener(gH,this.start),this.element.removeEventListener(mH,this.stop),this.element.remove()}},S2=class extends Yy{constructor(e){super("axis-section-pop-panel","\u8f74\u5411\u5256\u5207",e.widgetContainer),this.axis="x",this.isVisible=!0,this.keydown=e=>{"Escape"===e.code&&this.destroy()},this.section=e.getActiveSection(),this.createGroupSelectLayout(),this.addGroupSelectItems(),this.createActiveSelectLayout(),this.addActiveItems(),window.addEventListener("keydown",this.keydown)}destroy(){super.destroy(),window.removeEventListener("keydown",this.keydown)}createGroupSelectLayout(){let e=document.createElement("div");e.classList.add("pop-panel-group-select"),this.body.appendChild(e),this.groupSelectNode=e}addGroupSelectItems(){let e=(e,t,i=!1)=>{let n=document.createElement("div");return n.classList.add("pop-panel-item"),n.setAttribute("itemName",e),n.append(t),i&&n.classList.add("active"),this.groupSelectNode&&this.groupSelectNode.appendChild(n),n},t=(e,t)=>a=>{a.stopPropagation(),this.activeItem!==e&&(i.classList.remove("active"),n.classList.remove("active"),r.classList.remove("active"),this.activeItem=e,t.classList.add("active"),this.section.setActiveAxis(e))},i=e("X","X",!0);i.onclick=t("X",i);let n=e("Y","Y");n.onclick=t("Y",n);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 i=document.createElement("i");i.classList.add(jv),i.classList.add(t),e.innerHTML="",e.appendChild(i)},t=((t,i,n="")=>{let r=document.createElement("div");return r.classList.add("pop-panel-item"),i&&r.setAttribute("title",i),r.setAttribute("itemName",t),r.setAttribute("isActive","false"),e(r,n),r})("visible","\u9690\u85cf\u5256\u5207\u9762","icon-hidesectionplane");t.onclick=()=>{this.isVisible=!this.isVisible,this.isVisible?(e(t,"icon-hidesectionplane"),t.setAttribute("title","\u9690\u85cf\u5256\u5207\u9762")):(e(t,"icon-showsectionplane"),t.setAttribute("title","\u663e\u793a\u5256\u5207\u9762")),this.section.setSectionPlaneMeshVisible(this.isVisible)}}},M2=class extends Yy{constructor(e){super("pick-section-pop-panel","\u62fe\u53d6\u9762\u5256\u5207",e.widgetContainer),this.isVisible=!0,this.enabled=!0,this.keydown=e=>{"Escape"===e.code&&this.destroy()},this.section=e.getActiveSection(),this.createActiveSelectLayout(),this.addActiveItems(),window.addEventListener("keydown",this.keydown)}destroy(){super.destroy(),window.removeEventListener("keydown",this.keydown)}createActiveSelectLayout(){let e=document.createElement("div");e.classList.add("pop-panel-active-select"),this.body.appendChild(e),this.activeSelectNode=e}addActiveItems(){let e=(e,t)=>{let i=document.createElement("i");i.classList.add("gemini-viewer-icon"),i.classList.add(t),e.innerHTML="",e.appendChild(i)},t=(t,i,n="")=>{let r=document.createElement("div");return r.classList.add("pop-panel-item"),i&&r.setAttribute("title",i),r.setAttribute("itemName",t),r.setAttribute("isActive","false"),e(r,n),r},i=t("visible","\u9690\u85cf\u5256\u5207\u9762","icon-hidesectionplane");i.onclick=()=>{this.enabled&&(this.isVisible=!this.isVisible,this.isVisible?(e(i,"icon-hidesectionplane"),i.setAttribute("title","\u9690\u85cf\u5256\u5207\u9762")):(e(i,"icon-showsectionplane"),i.setAttribute("title","\u663e\u793a\u5256\u5207\u9762")),this.section.setSectionPlaneMeshVisible(this.isVisible))},this.activeSelectNode&&this.activeSelectNode.appendChild(i),this.visibleNode=i;let n=t("reset","\u91cd\u7f6e","icon-reset");n.onclick=t=>{t.stopPropagation(),this.enabled&&(this.isVisible=!0,e(i,"icon-hidesectionplane"),i.setAttribute("title","\u9690\u85cf\u5256\u5207\u9762"),this.section.resetSection())},this.activeSelectNode&&this.activeSelectNode.appendChild(n),this.resetNode=n}enable(){this.enabled=!0,this.visibleNode&&this.visibleNode.classList.remove("disable")}disable(){this.enabled=!1,this.visibleNode&&this.visibleNode.classList.add("disable")}},Ya,wo=e=>e.findPlugin(lg.DEFAULT_ID),N_=e=>e.findPlugin(dg.DEFAULT_ID),c0t=e=>e.findPlugin(dp.DEFAULT_ID),R2=e=>t=>{let i=wo(t),n=N_(t);null==n||n.deactivate(),null==i||i.activate(e)},A2=e=>{let t=wo(e);null==t||t.deactivate()},aV=e=>{let t=wo(e);t&&(t.deactivate(),t.getData().forEach((e=>t.setVisibilityById(e.id,!1))))},oV=e=>{let t=wo(e);t&&(t.deactivate(),t.getData().forEach((e=>t.setVisibilityById(e.id,!0))));let i=N_(e);null==i||i.deactivate(),null==Ya||Ya.destroy(),Ya=void 0},qve={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=>{se.info("[Toolbar]","Enter OrthoMode"),e.setToOrthographicCamera(!0)},onDeactive:e=>{se.info("[Toolbar]","Exit OrthoMode"),e.setToOrthographicCamera(!1)}},Measure:{icon:{default:"icon-measure",active:"icon-measure-filled",iconFont:"gemini-viewer-icon"},menuName:"Toolbar.measurement",type:3,children:{MeasureDistance:{icon:{default:"icon-measure-distance"},menuName:"Toolbar.distanceMeasurement",onActive:R2("Distance"),onDeactive:A2,type:4,mutexIds:["MeasureArea","MeasureAngle","MeasureCoordinate"]},MeasureArea:{icon:{default:"icon-measure-area-color"},onActive:R2("Area"),onDeactive:A2,type:4,menuName:"Toolbar.areaMeasurement",mutexIds:["MeasureDistance","MeasureAngle","MeasureCoordinate"]},MeasureAngle:{menuName:"Toolbar.angleMeasurement",icon:{default:"icon-angle-measure"},type:4,onActive:R2("Angle"),onDeactive:A2,mutexIds:["MeasureDistance","MeasureArea","MeasureCoordinate"]},MeasureCoordinate:{menuName:"Toolbar.coordinateMeasurement",icon:{default:"icon-distancemeasure",iconFont:"gemini-viewer-icon"},type:4,onActive:R2("Coordinate"),onDeactive:A2,mutexIds:["MeasureDistance","MeasureArea","MeasureAngle"]},MeasureClear:{icon:{default:"icon-clear",active:"icon-clear-filled",iconFont:"gemini-viewer-icon"},onClick:e=>{let t=wo(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=>{aV(e);let t=N_(e);null==t||t.activate("AxisPlaneSection"),null==Ya||Ya.destroy(),Ya=new S2(e)},onDeactive:oV,mutexIds:["SectionBox","SectionPlane"]},SectionPlane:{icon:{default:"icon-choosesectionplane",active:"icon-choosesectionplane-filled",iconFont:"gemini-viewer-icon"},menuName:"Toolbar.pickSectionPlane",type:4,onActive:e=>{aV(e);let t=N_(e);null==t||t.activate("PickPlaneSection"),null==Ya||Ya.destroy(),Ya=new M2(e)},onDeactive:oV,mutexIds:["SectionAxis","SectionBox"]},SectionBox:{icon:{default:"icon-sectionbox",active:"icon-sectionbox-filled",iconFont:"gemini-viewer-icon"},menuName:"Toolbar.sectionBox",type:4,onActive:e=>{aV(e);let t=N_(e);null==t||t.activate("ObjectsBoxSection"),null==Ya||Ya.destroy()},onDeactive:oV,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:()=>{se.info("[Toolbar]","Activate Bim Tree")},onDeactive:()=>{se.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:()=>{se.info("[Toolbar]","Activate Viewpoint")},onDeactive:()=>{se.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:()=>{se.info("[Toolbar]","Activate Annotation")},onDeactive:()=>{se.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:()=>{se.info("[Toolbar]","Activate Property")},onDeactive:()=>{se.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:()=>{se.info("[Toolbar]","Activate Settings")},onDeactive:()=>{se.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 i;let n=()=>{let e=null==t?void 0:t.menuList.get("FullScreen");e&&e.setActive(St.isFullScreen())};St.isFullScreen()?(St.exitFullscreen(),window.removeEventListener("resize",n)):St.fullScreen(null==(i=e.viewerContainer)?void 0:i.parentElement),window.addEventListener("resize",n)}}},Wve={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 i=e;i.removeEventListener("BoxSelectDeactivated"),i.addEventListener("BoxSelectDeactivated",(()=>{null==t||t.setActive("ZoomToRectangle",!1)})),i.zoomToRect()},mutexIds:["GetScreenshot"]},GetScreenshot:{icon:{default:"icon-frame-clipping",active:"icon-frame-clipping"},menuName:"Toolbar.screenshot",type:4,onClick:(e,t)=>{let i=e;i.removeEventListener("BoxSelectDeactivated"),i.addEventListener("BoxSelectDeactivated",(()=>{null==t||t.setActive("GetScreenshot",!1)}));let n=c0t(e);null==n||n.getScreenshotAsync().then((e=>{if(se.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=>{se.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=wo(e);null==t||t.activate("Distance")},onDeactive:e=>{let t=wo(e);null==t||t.deactivate()},type:4,mutexIds:["MeasureArea","MeasureAngle","MeasureCoordinate","ZoomToRectangle","GetScreenshot"]},MeasureArea:{icon:{default:"icon-measure-area-color"},onActive:e=>{let t=wo(e);null==t||t.activate("Area")},onDeactive:e=>{let t=wo(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=wo(e);null==t||t.activate("Angle")},onDeactive:e=>{let t=wo(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=wo(e);null==t||t.activate("Coordinate")},onDeactive:e=>{let t=wo(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=wo(e);null==t||t.clear()},type:1,menuName:"Toolbar.clearMeasurement"}}},Markup:{icon:{default:"icon-annotation"},menuName:"Toolbar.markup",type:1,onClick:(e,t)=>{let i=e;null==t||t.updateMenu("Measure",{defaultActive:!1}),null==t||t.setActive("ZoomToRectangle",!1),i.getMarkups().forEach((e=>i.setMarkupVisibility(e.id,!0))),null==t||t.setActive("MarkupVisibility",!1),i.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:()=>{se.info("[Toolbar]","Activate Settings")},onDeactive:()=>{se.info("[Toolbar]","Deactivate Settings")},visible:!0},Compared:{icon:{default:"icon-compared"},menuName:"Toolbar.compared",type:4,onActive:()=>{se.info("[Toolbar]","Activate Compare")},onDeactive:()=>{se.info("[Toolbar]","Deactivate Compare")},visible:!1},QuitCompare:{icon:{default:"icon-compared"},menuName:"Toolbar.quitCompare",type:4,onActive:()=>{se.info("[Toolbar]","Activate Compare")},onDeactive:()=>{se.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 i;let n=()=>{let e=null==t?void 0:t.menuList.get("FullScreen");e&&e.setActive(St.isFullScreen())};St.isFullScreen()?(St.exitFullscreen(),window.removeEventListener("resize",n)):St.fullScreen(null==(i=e.viewerContainer)?void 0:i.parentElement),window.addEventListener("resize",n)}}},cV=class extends or{constructor(e,t){super(e,{id:(null==t?void 0:t.id)||cV.DEFAULT_ID}),this.onMarkupActivated=()=>{if(!this.markupToolbar){let e=(0,B_.merge)(this.cfg.markupMenuCfg||[],zve),t=(0,B_.merge)(this.cfg.markupGroupCfg||[],Gve);this.markupToolbar=new w2(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 i=(0,B_.merge)({},Wve,this.cfg.menuConfig),n=(0,B_.merge)(this.cfg.groupConfig||[],T2);this.toolbar=new hp(e,i,n),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()}},lV=cV;lV.DEFAULT_ID="DxfViewerToolbarPlugin";var hV=Xi(kl(),1),dV=class extends or{constructor(e,t){super(e,{id:(null==t?void 0:t.id)||dV.DEFAULT_ID}),this.cfg=t||{};let i=(0,hV.merge)({},qve,this.cfg.menuConfig),n=(0,hV.merge)(this.cfg.groupConfig||[],T2);this.toolbar=new hp(e,i,n)}getToolbar(){return this.toolbar}setActive(e,t){this.toolbar.setActive(e,t)}destroy(){super.destroy(),this.toolbar.destroy()}},uV=dV;uV.DEFAULT_ID="BimViewerToolbarPlugin";var So=e=>({viewer:t})=>t.translate(`ContextMenu.${e}`),Xve=e=>{var t;let i=0;return null==(t=e.scene)||t.traverseVisible((e=>{e instanceof xt&&i++})),i>0},u0t=e=>{var t,i;let n=0;return null==(t=e.scene)||t.traverse((e=>{e instanceof xt&&n++})),null==(i=e.scene)||i.traverseVisible((e=>{e instanceof xt&&n--})),n>0},fV=e=>e.hasTransparentObject(),C2=e=>Hn.isObjectSelectable(e),jve=(e,t,i,n)=>{let r=e.selectedObject;return!(!r||!t||r.id!==t.id)&&(null!=i&&r.isInstancedMesh?i===r.userData.instanceId:null==n||!Rr.isMergedMesh(r)||n===r.userData.batchId)},h0t={getTitle:So("viewFitEntity"),getShown:({hit:e})=>e,doAction:({viewer:e,hit:t})=>{e.flyToObject(t)}},d0t={getTitle:So("viewFitAll"),getEnabled:({viewer:e})=>Xve(e),doAction:({viewer:e})=>e.viewFitAll()},f0t={getTitle:So("hideEntity"),getShown:({hit:e})=>e,doAction:({viewer:e,hit:t})=>{let i=e;C2(t)&&(i.clearSelection(),t.visible=!1,i.enableRender())}},p0t={getTitle:So("hideOthers"),getShown:({hit:e})=>e,doAction:({viewer:e,hit:t})=>{var i;let n=e;n.clearSelection(),null==(i=n.scene)||i.traverse((e=>{e instanceof xt&&C2(e)&&(e.visible=!1)})),t.visible=!0,n.enableRender()}},m0t={getTitle:So("hideAll"),getEnabled:({viewer:e})=>Xve(e),doAction:({viewer:e})=>{var t;let i=e;i.clearSelection(),null==(t=i.scene)||t.traverse((e=>{e instanceof xt&&C2(e)&&(e.visible=!1)})),i.enableRender()}},g0t={getTitle:So("showAll"),getEnabled:({viewer:e})=>u0t(e),doAction:({viewer:e})=>{var t;let i=e;null==(t=i.scene)||t.traverse((e=>{e instanceof xt&&C2(e)&&(e.visible=!0)})),i.enableRender()}},v0t={getTitle:({hit:e,viewer:t,instanceId:i,batchId:n})=>jve(t,e,i,n)?So("deselect")({viewer:t}):So("select")({viewer:t}),getShown:({hit:e,viewer:t})=>t.enableSelection&&e,doAction:({hit:e,viewer:t,instanceId:i,batchId:n})=>{let r=t;Hn.isObjectSelectable(e)?jve(r,e,i,n)?r.clearSelection():r.selectObject(e,e.instanceId,n):se.debug(`[ContextMenu] object(type: ${e.type}, name: ${e.name}) not selectable!`)}},y0t={getTitle:So("selectNone"),getShown:({viewer:e})=>e.enableSelection,getEnabled:({viewer:e})=>e.selectedObject,doAction:({viewer:e})=>e.clearSelection()},x0t={getTitle:So("xRayAll"),getShown:({viewer:e})=>!fV(e),doAction:({viewer:e})=>{let t=e;t.clearSelection(),t.addOrRemoveObjectOpacity(!0),t.enableRender()}},b0t={getTitle:So("xRayNone"),getEnabled:({viewer:e})=>fV(e),doAction:({viewer:e})=>{let t=e;t.clearSelection(),fV(t)&&(t.addOrRemoveObjectOpacity(!1),t.enableRender())}},E0t={getTitle:So("xRayEntity"),getShown:({hit:e})=>e,doAction:({viewer:e,hit:t})=>{let i=e;i.clearSelection(),i.addOrRemoveObjectOpacity(!0,void 0,[t.id],void 0)}},_0t={getTitle:So("xRayOthers"),getShown:({hit:e})=>e,doAction:({viewer:e,hit:t})=>{let i=e;i.clearSelection(),i.addOrRemoveObjectOpacity(!0,.1,void 0,[t.id]),i.enableRender()}},T0t={getTitle:({viewer:e})=>{let t=e,i="";switch(t.sectionType){case"PickPlaneSection":i="*showSectionPlane";break;case"AxisPlaneSection":i="showAxisSection";break;case"ObjectsBoxSection":i="*showSectionBox"}return t.translate(`ContextMenu.${i}`)},getShown:({viewer:e,section:t})=>{let i=e;return("PickPlaneSection"===i.sectionType||"AxisPlaneSection"===i.sectionType)&&!!t&&!t.showSectionPlane},doAction:({viewer:e,section:t})=>{let i=e;("PickPlaneSection"===i.sectionType||"AxisPlaneSection"===i.sectionType)&&(null==t||t.setSectionPlaneMeshVisible(!0))}},w0t={getTitle:({viewer:e})=>{let t=e,i="";switch(t.sectionType){case"PickPlaneSection":i="hideSectionPlane";break;case"AxisPlaneSection":i="hideAxisSection";break;case"ObjectsBoxSection":i="hideSectionBox"}return t.translate(`ContextMenu.${i}`)},getShown:e=>Yve(e),doAction:({viewer:e,section:t})=>{let i=e;("PickPlaneSection"===i.sectionType||"AxisPlaneSection"===i.sectionType)&&(null==t||t.setSectionPlaneMeshVisible(!1))}},S0t={getTitle:So("undoSection"),getShown:e=>Yve(e),doAction:({viewer:e,toolbar:t})=>{let i=e;if("PickPlaneSection"===i.sectionType){let e=null==t?void 0:t.menuList.get("SectionPlane");null==e||e.setActive(!1)}else if("AxisPlaneSection"===i.sectionType){let e=null==t?void 0:t.menuList.get("SectionAxis");null==e||e.setActive(!1)}else if("ObjectsBoxSection"===i.sectionType){let e=null==t?void 0:t.menuList.get("SectionBox");null==e||e.setActive(!1)}}},Yve=({viewer:e,hit:t,section:i})=>{let n=e;return("PickPlaneSection"===n.sectionType||"AxisPlaneSection"===n.sectionType)&&!!i&&i.showSectionPlane&&(null==t?void 0:t.name)===vH},$ve=[[T0t],[w0t,S0t],[h0t,d0t],[f0t,p0t,m0t,g0t],[E0t,_0t,x0t,b0t],[v0t,y0t]],Zve=class extends or{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($ve||[]),window.oncontextmenu=e=>e.preventDefault(),this.hide(),this.initEvents()}initEvents(){let e=this.viewer.getInputManager();if(!e)return;let t=!1,i=!1,n=0,r=0;e.addEventListener("pointerdown",(()=>{i=!1,t=!0,this.hide()})),e.addEventListener("pointermove",(e=>{t&&!i&&(i=!(e=>-1!==n&&-1!==r&&Math.abs(e.x-n)<5&&Math.abs(e.y-r)<5)(e))})),e.addEventListener("pointerup",(e=>{if(t=!1,i)return i=!1,void this.hide();n=e.x,r=e.y;let a=this.viewer.findPlugin(lg.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,i=this.viewer;if(i.selectedObject){let e=i.selectedObject.userData.instanceId,n=i.selectedObject.userData.batchId;this.context=Ii(Tr({},t),{hit:i.selectedObject,instanceId:e,batchId:n})}else{let n=i.getRaycaster();n&&n.layers.set(10);let r=i.getAllIntersections(e);se.debug("[Viewer] showContextMenu intersections = ",r);let a,s=(0,pg.find)(r,(e=>{let t=e.object;return t instanceof xt&&t.visible})),o=null==s?void 0:s.instanceId,l=null==s?void 0:s.faceIndex;l&&(a=Rr.getBatchIdByFaceIndex(null==s?void 0:s.object,l)),this.context=Ii(Tr({},t),{hit:null==s?void 0:s.object,instanceId:o,batchId:a})}let{x:n,y:r}=e;this.show(n,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 i=this.createMenuGroup(e);return t.append(...i),this.container.appendChild(t),t}createMenuGroup(e){return(0,pg.map)(e,(e=>{let t=document.createElement("ul");return(0,pg.forEach)(e,(e=>{let i=this.createMenuItem(e);t.append(i)})),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,pg.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 i=this.element.offsetHeight,n=this.element.offsetWidth;t+i>window.innerHeight&&(t=window.innerHeight-i-5),e+n>window.innerWidth&&(e=window.innerWidth-n-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 M0t(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 Ky(e,t){var i=e.__state.conversionName.toString(),n=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"===i||"SIX_CHAR_HEX"===i){for(var c=e.hex.toString(16);c.length<6;)c="0"+c;return"#"+c}return"CSS_RGB"===i?"rgb("+n+","+r+","+a+")":"CSS_RGBA"===i?"rgba("+n+","+r+","+a+","+s+")":"HEX"===i?"0x"+e.hex.toString(16):"RGB_ARRAY"===i?"["+n+","+r+","+a+"]":"RGBA_ARRAY"===i?"["+n+","+r+","+a+","+s+"]":"RGB_OBJ"===i?"{r:"+n+",g:"+r+",b:"+a+"}":"RGBA_OBJ"===i?"{r:"+n+",g:"+r+",b:"+a+",a:"+s+"}":"HSV_OBJ"===i?"{h:"+o+",s:"+l+",v:"+h+"}":"HSVA_OBJ"===i?"{h:"+o+",s:"+l+",v:"+h+",a:"+s+"}":"unknown format"}var Kve=Array.prototype.forEach,U_=Array.prototype.slice,Ht={BREAK:{},extend:function(e){return this.each(U_.call(arguments,1),(function(t){(this.isObject(t)?Object.keys(t):[]).forEach(function(i){this.isUndefined(t[i])||(e[i]=t[i])}.bind(this))}),this),e},defaults:function(e){return this.each(U_.call(arguments,1),(function(t){(this.isObject(t)?Object.keys(t):[]).forEach(function(i){this.isUndefined(e[i])&&(e[i]=t[i])}.bind(this))}),this),e},compose:function(){var e=U_.call(arguments);return function(){for(var t=U_.call(arguments),i=e.length-1;i>=0;i--)t=[e[i].apply(this,t)];return t[0]}},each:function(e,t,i){if(e)if(Kve&&e.forEach&&e.forEach===Kve)e.forEach(t,i);else if(e.length===e.length+0){var n,r=void 0;for(r=0,n=e.length;r<n;r++)if(r in e&&t.call(i,e[r],r)===this.BREAK)return}else for(var a in e)if(t.call(i,e[a],a)===this.BREAK)return},defer:function(e){setTimeout(e,0)},debounce:function(e,t,i){var n=void 0;return function(){var r=this,a=arguments;var s=i||!n;clearTimeout(n),n=setTimeout((function(){n=null,i||e.apply(r,a)}),t),s&&e.apply(r,a)}},toArray:function(e){return e.toArray?e.toArray():U_.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}},R0t=[{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:Ky},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:Ky},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:Ky},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:Ky}}},{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}}}}}],H_=void 0,P2=void 0,mV=function(){P2=!1;var e=arguments.length>1?Ht.toArray(arguments):arguments[0];return Ht.each(R0t,(function(t){if(t.litmus(e))return Ht.each(t.conversions,(function(t,i){if(H_=t.read(e),!1===P2&&!1!==H_)return P2=H_,H_.conversionName=i,H_.conversion=t,Ht.BREAK})),Ht.BREAK})),P2},Jve=void 0,L2={hsv_to_rgb:function(e,t,i){var n=Math.floor(e/60)%6,r=e/60-Math.floor(e/60),a=i*(1-t),s=i*(1-r*t),o=i*(1-(1-r)*t),l=[[i,o,a],[s,i,a],[a,i,o],[a,s,i],[o,a,i],[i,a,s]][n];return{r:255*l[0],g:255*l[1],b:255*l[2]}},rgb_to_hsv:function(e,t,i){var n=Math.min(e,t,i),r=Math.max(e,t,i),a=r-n,s=void 0;return 0===r?{h:NaN,s:0,v:0}:(s=e===r?(t-i)/a:t===r?2+(i-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,i){var n=this.hex_with_component(0,2,e);return n=this.hex_with_component(n,1,t),this.hex_with_component(n,0,i)},component_from_hex:function(e,t){return e>>8*t&255},hex_with_component:function(e,t,i){return i<<(Jve=8*t)|e&~(255<<Jve)}},A0t="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},Xc=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},Yc=function(){function e(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,i,n){return i&&e(t.prototype,i),n&&e(t,n),t}}(),fp=function e(t,i,n){null===t&&(t=Function.prototype);var r=Object.getOwnPropertyDescriptor(t,i);if(void 0===r){var a=Object.getPrototypeOf(t);return null===a?void 0:e(a,i,n)}if("value"in r)return r.value;var s=r.get;return void 0===s?void 0:s.call(n)},pp=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)},mp=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},Xs=function(){function e(){if(Xc(this,e),this.__state=mV.apply(this,arguments),!1===this.__state)throw new Error("Failed to interpret color arguments");this.__state.a=this.__state.a||1}return Yc(e,[{key:"toString",value:function(){return Ky(this)}},{key:"toHexString",value:function(){return Ky(this,!0)}},{key:"toOriginal",value:function(){return this.__state.conversion.write(this)}}]),e}();function EV(e,t,i){Object.defineProperty(e,t,{get:function(){return"RGB"===this.__state.space||Xs.recalculateRGB(this,t,i),this.__state[t]},set:function(e){"RGB"!==this.__state.space&&(Xs.recalculateRGB(this,t,i),this.__state.space="RGB"),this.__state[t]=e}})}function _V(e,t){Object.defineProperty(e,t,{get:function(){return"HSV"===this.__state.space||Xs.recalculateHSV(this),this.__state[t]},set:function(e){"HSV"!==this.__state.space&&(Xs.recalculateHSV(this),this.__state.space="HSV"),this.__state[t]=e}})}Xs.recalculateRGB=function(e,t,i){if("HEX"===e.__state.space)e.__state[t]=L2.component_from_hex(e.__state.hex,i);else{if("HSV"!==e.__state.space)throw new Error("Corrupted color state");Ht.extend(e.__state,L2.hsv_to_rgb(e.__state.h,e.__state.s,e.__state.v))}},Xs.recalculateHSV=function(e){var t=L2.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},Xs.COMPONENTS=["r","g","b","h","s","v","hex","a"],EV(Xs.prototype,"r",2),EV(Xs.prototype,"g",1),EV(Xs.prototype,"b",0),_V(Xs.prototype,"h"),_V(Xs.prototype,"s"),_V(Xs.prototype,"v"),Object.defineProperty(Xs.prototype,"a",{get:function(){return this.__state.a},set:function(e){this.__state.a=e}}),Object.defineProperty(Xs.prototype,"hex",{get:function(){return"HEX"!==this.__state.space&&(this.__state.hex=L2.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 mg=function(){function e(t,i){Xc(this,e),this.initialValue=t[i],this.domElement=document.createElement("div"),this.object=t,this.property=i,this.__onChange=void 0,this.__onFinishChange=void 0}return Yc(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}(),C0t={HTMLEvents:["change"],MouseEvents:["click","mousemove","mousedown","mouseup","mouseover"],KeyboardEvents:["keydown"]},lye={};Ht.each(C0t,(function(e,t){Ht.each(e,(function(e){lye[e]=t}))}));var P0t=/(\d+(\.\d+)?)px/;function ih(e){if("0"===e||Ht.isUndefined(e))return 0;var t=e.match(P0t);return Ht.isNull(t)?0:parseFloat(t[1])}var bt={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,i){var n=i,r=t;Ht.isUndefined(r)&&(r=!0),Ht.isUndefined(n)&&(n=!0),e.style.position="absolute",r&&(e.style.left=0,e.style.right=0),n&&(e.style.top=0,e.style.bottom=0)},fakeEvent:function(e,t,i,n){var r=i||{},a=lye[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,n),e.dispatchEvent(s)},bind:function(e,t,i,n){var r=n||!1;return e.addEventListener?e.addEventListener(t,i,r):e.attachEvent&&e.attachEvent("on"+t,i),bt},unbind:function(e,t,i,n){var r=n||!1;return e.removeEventListener?e.removeEventListener(t,i,r):e.detachEvent&&e.detachEvent("on"+t,i),bt},addClass:function(e,t){if(void 0===e.className)e.className=t;else if(e.className!==t){var i=e.className.split(/ +/);-1===i.indexOf(t)&&(i.push(t),e.className=i.join(" ").replace(/^\s+/,"").replace(/\s+$/,""))}return bt},removeClass:function(e,t){if(t)if(e.className===t)e.removeAttribute("class");else{var i=e.className.split(/ +/),n=i.indexOf(t);-1!==n&&(i.splice(n,1),e.className=i.join(" "))}else e.className=void 0;return bt},hasClass:function(e,t){return new RegExp("(?:^|\\s+)"+t+"(?:\\s+|$)").test(e.className)||!1},getWidth:function(e){var t=getComputedStyle(e);return ih(t["border-left-width"])+ih(t["border-right-width"])+ih(t["padding-left"])+ih(t["padding-right"])+ih(t.width)},getHeight:function(e){var t=getComputedStyle(e);return ih(t["border-top-width"])+ih(t["border-bottom-width"])+ih(t["padding-top"])+ih(t["padding-bottom"])+ih(t.height)},getOffset:function(e){var t=e,i={left:0,top:0};if(t.offsetParent)do{i.left+=t.offsetLeft,i.top+=t.offsetTop,t=t.offsetParent}while(t);return i},isActive:function(e){return e===document.activeElement&&(e.type||e.href)}},cye=function(e){function t(e,i){Xc(this,t);var n=mp(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,i)),r=n;return n.__prev=n.getValue(),n.__checkbox=document.createElement("input"),n.__checkbox.setAttribute("type","checkbox"),bt.bind(n.__checkbox,"change",(function(){r.setValue(!r.__prev)}),!1),n.domElement.appendChild(n.__checkbox),n.updateDisplay(),n}return pp(t,mg),Yc(t,[{key:"setValue",value:function(e){var i=fp(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(),i}},{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),fp(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"updateDisplay",this).call(this)}}]),t}(),I0t=function(e){function t(e,i,n){Xc(this,t);var r=mp(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,i)),a=n,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 i=document.createElement("option");i.innerHTML=t,i.setAttribute("value",e),s.__select.appendChild(i)})),r.updateDisplay(),bt.bind(r.__select,"change",(function(){var e=this.options[this.selectedIndex].value;s.setValue(e)})),r.domElement.appendChild(r.__select),r}return pp(t,mg),Yc(t,[{key:"setValue",value:function(e){var i=fp(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"setValue",this).call(this,e);return this.__onFinishChange&&this.__onFinishChange.call(this,this.getValue()),i}},{key:"updateDisplay",value:function(){return bt.isActive(this.__select)?this:(this.__select.value=this.getValue(),fp(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"updateDisplay",this).call(this))}}]),t}(),L0t=function(e){function t(e,i){Xc(this,t);var n=mp(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,i)),r=n;function a(){r.setValue(r.__input.value)}return n.__input=document.createElement("input"),n.__input.setAttribute("type","text"),bt.bind(n.__input,"keyup",a),bt.bind(n.__input,"change",a),bt.bind(n.__input,"blur",(function(){r.__onFinishChange&&r.__onFinishChange.call(r,r.getValue())})),bt.bind(n.__input,"keydown",(function(e){13===e.keyCode&&this.blur()})),n.updateDisplay(),n.domElement.appendChild(n.__input),n}return pp(t,mg),Yc(t,[{key:"updateDisplay",value:function(){return bt.isActive(this.__input)||(this.__input.value=this.getValue()),fp(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"updateDisplay",this).call(this)}}]),t}();function Qve(e){var t=e.toString();return t.indexOf(".")>-1?t.length-t.indexOf(".")-1:0}var uye=function(e){function t(e,i,n){Xc(this,t);var r=mp(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,i)),a=n||{};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=Qve(r.__impliedStep),r}return pp(t,mg),Yc(t,[{key:"setValue",value:function(e){var i=e;return void 0!==this.__min&&i<this.__min?i=this.__min:void 0!==this.__max&&i>this.__max&&(i=this.__max),void 0!==this.__step&&i%this.__step!=0&&(i=Math.round(i/this.__step)*this.__step),fp(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"setValue",this).call(this,i)}},{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=Qve(e),this}}]),t}();function D0t(e,t){var i=Math.pow(10,t);return Math.round(e*i)/i}var D2=function(e){function t(e,i,n){Xc(this,t);var r=mp(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,i,n));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(){bt.unbind(window,"mousemove",l),bt.unbind(window,"mouseup",h),o()}return r.__input=document.createElement("input"),r.__input.setAttribute("type","text"),bt.bind(r.__input,"change",(function(){var e=parseFloat(a.__input.value);Ht.isNaN(e)||a.setValue(e)})),bt.bind(r.__input,"blur",(function(){o()})),bt.bind(r.__input,"mousedown",(function(e){bt.bind(window,"mousemove",l),bt.bind(window,"mouseup",h),s=e.clientY})),bt.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 pp(t,uye),Yc(t,[{key:"updateDisplay",value:function(){return this.__input.value=this.__truncationSuspended?this.getValue():D0t(this.getValue(),this.__precision),fp(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"updateDisplay",this).call(this)}}]),t}();function eye(e,t,i,n,r){return n+(e-t)/(i-t)*(r-n)}var gV=function(e){function t(e,i,n,r,a){Xc(this,t);var s=mp(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,i,{min:n,max:r,step:a})),o=s;function l(e){e.preventDefault();var t=o.__background.getBoundingClientRect();return o.setValue(eye(e.clientX,t.left,t.right,o.__min,o.__max)),!1}function h(){bt.unbind(window,"mousemove",l),bt.unbind(window,"mouseup",h),o.__onFinishChange&&o.__onFinishChange.call(o,o.getValue())}function c(e){var t=e.touches[0].clientX,i=o.__background.getBoundingClientRect();o.setValue(eye(t,i.left,i.right,o.__min,o.__max))}function u(){bt.unbind(window,"touchmove",c),bt.unbind(window,"touchend",u),o.__onFinishChange&&o.__onFinishChange.call(o,o.getValue())}return s.__background=document.createElement("div"),s.__foreground=document.createElement("div"),bt.bind(s.__background,"mousedown",(function(e){document.activeElement.blur(),bt.bind(window,"mousemove",l),bt.bind(window,"mouseup",h),l(e)})),bt.bind(s.__background,"touchstart",(function(e){1===e.touches.length&&(bt.bind(window,"touchmove",c),bt.bind(window,"touchend",u),c(e))})),bt.addClass(s.__background,"slider"),bt.addClass(s.__foreground,"slider-fg"),s.updateDisplay(),s.__background.appendChild(s.__foreground),s.domElement.appendChild(s.__background),s}return pp(t,uye),Yc(t,[{key:"updateDisplay",value:function(){var e=(this.getValue()-this.__min)/(this.__max-this.__min);return this.__foreground.style.width=100*e+"%",fp(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"updateDisplay",this).call(this)}}]),t}(),hye=function(e){function t(e,i,n){Xc(this,t);var r=mp(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,i)),a=r;return r.__button=document.createElement("div"),r.__button.innerHTML=void 0===n?"Fire":n,bt.bind(r.__button,"click",(function(e){return e.preventDefault(),a.fire(),!1})),bt.addClass(r.__button,"button"),r.domElement.appendChild(r.__button),r}return pp(t,mg),Yc(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}(),vV=function(e){function t(e,i){Xc(this,t);var n=mp(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,i));n.__color=new Xs(n.getValue()),n.__temp=new Xs(0);var r=n;n.domElement=document.createElement("div"),bt.makeSelectable(n.domElement,!1),n.__selector=document.createElement("div"),n.__selector.className="selector",n.__saturation_field=document.createElement("div"),n.__saturation_field.className="saturation-field",n.__field_knob=document.createElement("div"),n.__field_knob.className="field-knob",n.__field_knob_border="2px solid ",n.__hue_knob=document.createElement("div"),n.__hue_knob.className="hue-knob",n.__hue_field=document.createElement("div"),n.__hue_field.className="hue-field",n.__input=document.createElement("input"),n.__input.type="text",n.__input_textShadow="0 1px 1px ",bt.bind(n.__input,"keydown",(function(e){13===e.keyCode&&c.call(this)})),bt.bind(n.__input,"blur",c),bt.bind(n.__selector,"mousedown",(function(){bt.addClass(this,"drag").bind(window,"mouseup",(function(){bt.removeClass(r.__selector,"drag")}))})),bt.bind(n.__selector,"touchstart",(function(){bt.addClass(this,"drag").bind(window,"touchend",(function(){bt.removeClass(r.__selector,"drag")}))}));var a=document.createElement("div");function s(e){d(e),bt.bind(window,"mousemove",d),bt.bind(window,"touchmove",d),bt.bind(window,"mouseup",l),bt.bind(window,"touchend",l)}function o(e){p(e),bt.bind(window,"mousemove",p),bt.bind(window,"touchmove",p),bt.bind(window,"mouseup",h),bt.bind(window,"touchend",h)}function l(){bt.unbind(window,"mousemove",d),bt.unbind(window,"touchmove",d),bt.unbind(window,"mouseup",l),bt.unbind(window,"touchend",l),u()}function h(){bt.unbind(window,"mousemove",p),bt.unbind(window,"touchmove",p),bt.unbind(window,"mouseup",h),bt.unbind(window,"touchend",h),u()}function c(){var e=mV(this.value);!1!==e?(r.__color.__state=e,r.setValue(r.__color.toOriginal())):this.value=r.__color.toString()}function u(){r.__onFinishChange&&r.__onFinishChange.call(r,r.__color.toOriginal())}function d(e){-1===e.type.indexOf("touch")&&e.preventDefault();var t=r.__saturation_field.getBoundingClientRect(),i=e.touches&&e.touches[0]||e,n=i.clientX,a=i.clientY,s=(n-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(),i=1-((e.touches&&e.touches[0]||e).clientY-t.top)/(t.bottom-t.top);return i>1?i=1:i<0&&(i=0),r.__color.h=360*i,r.setValue(r.__color.toOriginal()),!1}return Ht.extend(n.__selector.style,{width:"122px",height:"102px",padding:"3px",backgroundColor:"#222",boxShadow:"0px 1px 3px rgba(0,0,0,0.3)"}),Ht.extend(n.__field_knob.style,{position:"absolute",width:"12px",height:"12px",border:n.__field_knob_border+(n.__color.v<.5?"#fff":"#000"),boxShadow:"0px 1px 3px rgba(0,0,0,0.5)",borderRadius:"12px",zIndex:1}),Ht.extend(n.__hue_knob.style,{position:"absolute",width:"15px",height:"2px",borderRight:"4px solid #fff",zIndex:1}),Ht.extend(n.__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"}),tye(a,"top","rgba(0,0,0,0)","#000"),Ht.extend(n.__hue_field.style,{width:"15px",height:"100px",border:"1px solid #555",cursor:"ns-resize",position:"absolute",top:"3px",right:"3px"}),k0t(n.__hue_field),Ht.extend(n.__input.style,{outline:"none",textAlign:"center",color:"#fff",border:0,fontWeight:"bold",textShadow:n.__input_textShadow+"rgba(0,0,0,0.7)"}),bt.bind(n.__saturation_field,"mousedown",s),bt.bind(n.__saturation_field,"touchstart",s),bt.bind(n.__field_knob,"mousedown",s),bt.bind(n.__field_knob,"touchstart",s),bt.bind(n.__hue_field,"mousedown",o),bt.bind(n.__hue_field,"touchstart",o),n.__saturation_field.appendChild(a),n.__selector.appendChild(n.__field_knob),n.__selector.appendChild(n.__saturation_field),n.__selector.appendChild(n.__hue_field),n.__hue_field.appendChild(n.__hue_knob),n.domElement.appendChild(n.__input),n.domElement.appendChild(n.__selector),n.updateDisplay(),n}return pp(t,mg),Yc(t,[{key:"updateDisplay",value:function(){var e=mV(this.getValue());if(!1!==e){var t=!1;Ht.each(Xs.COMPONENTS,(function(i){if(!Ht.isUndefined(e[i])&&!Ht.isUndefined(this.__color.__state[i])&&e[i]!==this.__color.__state[i])return t=!0,{}}),this),t&&Ht.extend(this.__color.__state,e)}Ht.extend(this.__temp.__state,this.__color.__state),this.__temp.a=1;var i=this.__color.v<.5||this.__color.s>.5?255:0,n=255-i;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("+i+","+i+","+i+")"}),this.__hue_knob.style.marginTop=100*(1-this.__color.h/360)+"px",this.__temp.s=1,this.__temp.v=1,tye(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("+i+","+i+","+i+")",textShadow:this.__input_textShadow+"rgba("+n+","+n+","+n+",.7)"})}}]),t}(),O0t=["-moz-","-o-","-webkit-","-ms-",""];function tye(e,t,i,n){e.style.background="",Ht.each(O0t,(function(r){e.style.cssText+="background: "+r+"linear-gradient("+t+", "+i+" 0%, "+n+" 100%); "}))}function k0t(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 F0t={load:function(e,t){var i=t||document,n=i.createElement("link");n.type="text/css",n.rel="stylesheet",n.href=e,i.getElementsByTagName("head")[0].appendChild(n)},inject:function(e,t){var i=t||document,n=document.createElement("style");n.type="text/css",n.innerHTML=e;var r=i.getElementsByTagName("head")[0];try{r.appendChild(n)}catch(e){}}},N0t='<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>',B0t=function(e,t){var i=e[t];return Ht.isArray(arguments[2])||Ht.isObject(arguments[2])?new I0t(e,t,arguments[2]):Ht.isNumber(i)?Ht.isNumber(arguments[2])&&Ht.isNumber(arguments[3])?Ht.isNumber(arguments[4])?new gV(e,t,arguments[2],arguments[3],arguments[4]):new gV(e,t,arguments[2],arguments[3]):Ht.isNumber(arguments[4])?new D2(e,t,{min:arguments[2],max:arguments[3],step:arguments[4]}):new D2(e,t,{min:arguments[2],max:arguments[3]}):Ht.isString(i)?new L0t(e,t):Ht.isFunction(i)?new hye(e,t,""):Ht.isBoolean(i)?new cye(e,t):null};function U0t(e){setTimeout(e,1e3/60)}var H0t=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||U0t,V0t=function(){function e(){Xc(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"}),bt.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;bt.bind(this.backgroundElement,"click",(function(){t.hide()}))}return Yc(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",bt.unbind(e.domElement,"webkitTransitionEnd",t),bt.unbind(e.domElement,"transitionend",t),bt.unbind(e.domElement,"oTransitionEnd",t)};bt.bind(this.domElement,"webkitTransitionEnd",t),bt.bind(this.domElement,"transitionend",t),bt.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-bt.getWidth(this.domElement)/2+"px",this.domElement.style.top=window.innerHeight/2-bt.getHeight(this.domElement)/2+"px"}}]),e}(),z0t=M0t(".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");F0t.inject(z0t);var nye="dg",rye=72,iye=20,q_="Default",V_=function(){try{return!!window.localStorage}catch(e){return!1}}(),z_=void 0,sye=!0,$y=void 0,pV=!1,dye=[],Ni=function e(t){var i=this,n=t||{};this.domElement=document.createElement("div"),this.__ul=document.createElement("ul"),this.domElement.appendChild(this.__ul),bt.addClass(this.domElement,nye),this.__folders={},this.__controllers=[],this.__rememberedObjects=[],this.__rememberedObjectIndecesToControllers=[],this.__listening=[],n=Ht.defaults(n,{closeOnTop:!1,autoPlace:!0,width:e.DEFAULT_WIDTH}),n=Ht.defaults(n,{resizable:n.autoPlace,hideable:n.autoPlace}),Ht.isUndefined(n.load)?n.load={preset:q_}:n.preset&&(n.load.preset=n.preset),Ht.isUndefined(n.parent)&&n.hideable&&dye.push(this),n.resizable=Ht.isUndefined(n.parent)&&n.resizable,n.autoPlace&&Ht.isUndefined(n.scrollable)&&(n.scrollable=!0);var r,a=V_&&"true"===localStorage.getItem(Zy(this,"isLocal")),s=void 0,o=void 0;if(Object.defineProperties(this,{parent:{get:function(){return n.parent}},scrollable:{get:function(){return n.scrollable}},autoPlace:{get:function(){return n.autoPlace}},closeOnTop:{get:function(){return n.closeOnTop}},preset:{get:function(){return i.parent?i.getRoot().preset:n.load.preset},set:function(e){i.parent?i.getRoot().preset=e:n.load.preset=e,j0t(this),i.revert()}},width:{get:function(){return n.width},set:function(e){n.width=e,bV(i,e)}},name:{get:function(){return n.name},set:function(e){n.name=e,o&&(o.innerHTML=n.name)}},closed:{get:function(){return n.closed},set:function(t){n.closed=t,n.closed?bt.addClass(i.__ul,e.CLASS_CLOSED):bt.removeClass(i.__ul,e.CLASS_CLOSED),this.onResize(),i.__closeButton&&(i.__closeButton.innerHTML=t?e.TEXT_OPEN:e.TEXT_CLOSED)}},load:{get:function(){return n.load}},useLocalStorage:{get:function(){return a},set:function(e){V_&&(a=e,e?bt.bind(window,"unload",s):bt.unbind(window,"unload",s),localStorage.setItem(Zy(i,"isLocal"),e))}}}),Ht.isUndefined(n.parent)){if(this.closed=n.closed||!1,bt.addClass(this.domElement,e.CLASS_MAIN),bt.makeSelectable(this.domElement,!1),V_&&a){i.useLocalStorage=!0;var l=localStorage.getItem(Zy(this,"gui"));l&&(n.load=JSON.parse(l))}this.__closeButton=document.createElement("div"),this.__closeButton.innerHTML=e.TEXT_CLOSED,bt.addClass(this.__closeButton,e.CLASS_CLOSE_BUTTON),n.closeOnTop?(bt.addClass(this.__closeButton,e.CLASS_CLOSE_TOP),this.domElement.insertBefore(this.__closeButton,this.domElement.childNodes[0])):(bt.addClass(this.__closeButton,e.CLASS_CLOSE_BOTTOM),this.domElement.appendChild(this.__closeButton)),bt.bind(this.__closeButton,"click",(function(){i.closed=!i.closed}))}else{void 0===n.closed&&(n.closed=!0);var h=document.createTextNode(n.name);bt.addClass(h,"controller-name"),o=TV(i,h),bt.addClass(this.__ul,e.CLASS_CLOSED),bt.addClass(o,"title"),bt.bind(o,"click",(function(e){return e.preventDefault(),i.closed=!i.closed,!1})),n.closed||(this.closed=!1)}n.autoPlace&&(Ht.isUndefined(n.parent)&&(sye&&($y=document.createElement("div"),bt.addClass($y,nye),bt.addClass($y,e.CLASS_AUTO_PLACE_CONTAINER),document.body.appendChild($y),sye=!1),$y.appendChild(this.domElement),bt.addClass(this.domElement,e.CLASS_AUTO_PLACE)),this.parent||bV(i,n.width)),this.__resizeHandler=function(){i.onResizeDebounced()},bt.bind(window,"resize",this.__resizeHandler),bt.bind(this.__ul,"webkitTransitionEnd",this.__resizeHandler),bt.bind(this.__ul,"transitionend",this.__resizeHandler),bt.bind(this.__ul,"oTransitionEnd",this.__resizeHandler),this.onResize(),n.resizable&&W0t(this),s=function(){V_&&"true"===localStorage.getItem(Zy(i,"isLocal"))&&localStorage.setItem(Zy(i,"gui"),JSON.stringify(i.getSaveObject()))},this.saveToLocalStorageIfPossible=s,n.parent||((r=i.getRoot()).width+=1,Ht.defer((function(){r.width-=1})))};function TV(e,t,i){var n=document.createElement("li");return t&&n.appendChild(t),i?e.__ul.insertBefore(n,i):e.__ul.appendChild(n),e.onResize(),n}function aye(e){bt.unbind(window,"resize",e.__resizeHandler),e.saveToLocalStorageIfPossible&&bt.unbind(window,"unload",e.saveToLocalStorageIfPossible)}function yV(e,t){var i=e.__preset_select[e.__preset_select.selectedIndex];i.innerHTML=t?i.value+"*":i.value}function G0t(e,t,i){if(i.__li=t,i.__gui=e,Ht.extend(i,{options:function(t){if(arguments.length>1){var n=i.__li.nextElementSibling;return i.remove(),G_(e,i.object,i.property,{before:n,factoryArgs:[Ht.toArray(arguments)]})}if(Ht.isArray(t)||Ht.isObject(t)){var r=i.__li.nextElementSibling;return i.remove(),G_(e,i.object,i.property,{before:r,factoryArgs:[t]})}},name:function(e){return i.__li.firstElementChild.firstElementChild.innerHTML=e,i},listen:function(){return i.__gui.listen(i),i},remove:function(){return i.__gui.remove(i),i}}),i instanceof gV){var n=new D2(i.object,i.property,{min:i.__min,max:i.__max,step:i.__step});Ht.each(["updateDisplay","onChange","onFinishChange","step","min","max"],(function(e){var t=i[e],r=n[e];i[e]=n[e]=function(){var e=Array.prototype.slice.call(arguments);return r.apply(n,e),t.apply(i,e)}})),bt.addClass(t,"has-slider"),i.domElement.insertBefore(n.domElement,i.domElement.firstElementChild)}else if(i instanceof D2){var r=function(t){if(Ht.isNumber(i.__min)&&Ht.isNumber(i.__max)){var n=i.__li.firstElementChild.firstElementChild.innerHTML,r=i.__gui.__listening.indexOf(i)>-1;i.remove();var a=G_(e,i.object,i.property,{before:i.__li.nextElementSibling,factoryArgs:[i.__min,i.__max,i.__step]});return a.name(n),r&&a.listen(),a}return t};i.min=Ht.compose(r,i.min),i.max=Ht.compose(r,i.max)}else i instanceof cye?(bt.bind(t,"click",(function(){bt.fakeEvent(i.__checkbox,"click")})),bt.bind(i.__checkbox,"click",(function(e){e.stopPropagation()}))):i instanceof hye?(bt.bind(t,"click",(function(){bt.fakeEvent(i.__button,"click")})),bt.bind(t,"mouseover",(function(){bt.addClass(i.__button,"hover")})),bt.bind(t,"mouseout",(function(){bt.removeClass(i.__button,"hover")}))):i instanceof vV&&(bt.addClass(t,"color"),i.updateDisplay=Ht.compose((function(e){return t.style.borderLeftColor=i.__color.toString(),e}),i.updateDisplay),i.updateDisplay());i.setValue=Ht.compose((function(t){return e.getRoot().__preset_select&&i.isModified()&&yV(e.getRoot(),!0),t}),i.setValue)}function fye(e,t){var i=e.getRoot(),n=i.__rememberedObjects.indexOf(t.object);if(-1!==n){var r=i.__rememberedObjectIndecesToControllers[n];if(void 0===r&&(r={},i.__rememberedObjectIndecesToControllers[n]=r),r[t.property]=t,i.load&&i.load.remembered){var a=i.load.remembered,s=void 0;if(a[e.preset])s=a[e.preset];else{if(!a[q_])return;s=a[q_]}if(s[n]&&void 0!==s[n][t.property]){var o=s[n][t.property];t.initialValue=o,t.setValue(o)}}}}function G_(e,t,i,n){if(void 0===t[i])throw new Error('Object "'+t+'" has no property "'+i+'"');var r=void 0;if(n.color)r=new vV(t,i);else{var a=[t,i].concat(n.factoryArgs);r=B0t.apply(e,a)}n.before instanceof mg&&(n.before=n.before.__li),fye(e,r),bt.addClass(r.domElement,"c");var s=document.createElement("span");bt.addClass(s,"property-name"),s.innerHTML=r.property;var o=document.createElement("div");o.appendChild(s),o.appendChild(r.domElement);var l=TV(e,o,n.before);return bt.addClass(l,Ni.CLASS_CONTROLLER_ROW),r instanceof vV?bt.addClass(l,"color"):bt.addClass(l,A0t(r.getValue())),G0t(e,l,r),e.__controllers.push(r),r}function Zy(e,t){return document.location.href+"."+t}function xV(e,t,i){var n=document.createElement("option");n.innerHTML=t,n.value=t,e.__preset_select.appendChild(n),i&&(e.__preset_select.selectedIndex=e.__preset_select.length-1)}function oye(e,t){t.style.display=e.useLocalStorage?"block":"none"}function q0t(e){var t=e.__save_row=document.createElement("li");bt.addClass(e.domElement,"has-save"),e.__ul.insertBefore(t,e.__ul.firstChild),bt.addClass(t,"save-row");var i=document.createElement("span");i.innerHTML="&nbsp;",bt.addClass(i,"button gears");var n=document.createElement("span");n.innerHTML="Save",bt.addClass(n,"button"),bt.addClass(n,"save");var r=document.createElement("span");r.innerHTML="New",bt.addClass(r,"button"),bt.addClass(r,"save-as");var a=document.createElement("span");a.innerHTML="Revert",bt.addClass(a,"button"),bt.addClass(a,"revert");var s=e.__preset_select=document.createElement("select");if(e.load&&e.load.remembered?Ht.each(e.load.remembered,(function(t,i){xV(e,i,i===e.preset)})):xV(e,q_,!1),bt.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(i),t.appendChild(n),t.appendChild(r),t.appendChild(a),V_){var o=document.getElementById("dg-local-explain"),l=document.getElementById("dg-local-storage");document.getElementById("dg-save-locally").style.display="block","true"===localStorage.getItem(Zy(e,"isLocal"))&&l.setAttribute("checked","checked"),oye(e,o),bt.bind(l,"change",(function(){e.useLocalStorage=!e.useLocalStorage,oye(e,o)}))}var h=document.getElementById("dg-new-constructor");bt.bind(h,"keydown",(function(e){e.metaKey&&(67===e.which||67===e.keyCode)&&z_.hide()})),bt.bind(i,"click",(function(){h.innerHTML=JSON.stringify(e.getSaveObject(),void 0,2),z_.show(),h.focus(),h.select()})),bt.bind(n,"click",(function(){e.save()})),bt.bind(r,"click",(function(){var t=prompt("Enter a new preset name.");t&&e.saveAs(t)})),bt.bind(a,"click",(function(){e.revert()}))}function W0t(e){var t=void 0;function i(i){return i.preventDefault(),e.width+=t-i.clientX,e.onResize(),t=i.clientX,!1}function n(){bt.removeClass(e.__closeButton,Ni.CLASS_DRAG),bt.unbind(window,"mousemove",i),bt.unbind(window,"mouseup",n)}function r(r){return r.preventDefault(),t=r.clientX,bt.addClass(e.__closeButton,Ni.CLASS_DRAG),bt.bind(window,"mousemove",i),bt.bind(window,"mouseup",n),!1}e.__resize_handle=document.createElement("div"),Ht.extend(e.__resize_handle.style,{width:"6px",marginLeft:"-3px",height:"200px",cursor:"ew-resize",position:"absolute"}),bt.bind(e.__resize_handle,"mousedown",r),bt.bind(e.__closeButton,"mousedown",r),e.domElement.insertBefore(e.__resize_handle,e.domElement.firstElementChild)}function bV(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 I2(e,t){var i={};return Ht.each(e.__rememberedObjects,(function(n,r){var a={},s=e.__rememberedObjectIndecesToControllers[r];Ht.each(s,(function(e,i){a[i]=t?e.initialValue:e.getValue()})),i[r]=a})),i}function j0t(e){for(var t=0;t<e.__preset_select.length;t++)e.__preset_select[t].value===e.preset&&(e.__preset_select.selectedIndex=t)}function pye(e){0!==e.length&&H0t.call(window,(function(){pye(e)})),Ht.each(e,(function(e){e.updateDisplay()}))}Ni.toggleHide=function(){pV=!pV,Ht.each(dye,(function(e){e.domElement.style.display=pV?"none":""}))},Ni.CLASS_AUTO_PLACE="a",Ni.CLASS_AUTO_PLACE_CONTAINER="ac",Ni.CLASS_MAIN="main",Ni.CLASS_CONTROLLER_ROW="cr",Ni.CLASS_TOO_TALL="taller-than-window",Ni.CLASS_CLOSED="closed",Ni.CLASS_CLOSE_BUTTON="close-button",Ni.CLASS_CLOSE_TOP="close-top",Ni.CLASS_CLOSE_BOTTOM="close-bottom",Ni.CLASS_DRAG="drag",Ni.DEFAULT_WIDTH=245,Ni.TEXT_CLOSED="Close Controls",Ni.TEXT_OPEN="Open Controls",Ni._keydownHandler=function(e){"text"!==document.activeElement.type&&(e.which===rye||e.keyCode===rye)&&Ni.toggleHide()},bt.bind(window,"keydown",Ni._keydownHandler,!1),Ht.extend(Ni.prototype,{add:function(e,t){return G_(this,e,t,{factoryArgs:Array.prototype.slice.call(arguments,2)})},addColor:function(e,t){return G_(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&&$y.removeChild(this.domElement);var e=this;Ht.each(this.__folders,(function(t){e.removeFolder(t)})),bt.unbind(window,"keydown",Ni._keydownHandler,!1),aye(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 i=new Ni(t);this.__folders[e]=i;var n=TV(this,i.domElement);return bt.addClass(n,"folder"),i},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],aye(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=bt.getOffset(e.__ul).top,i=0;Ht.each(e.__ul.childNodes,(function(t){e.autoPlace&&t===e.__save_row||(i+=bt.getHeight(t))})),window.innerHeight-t-iye<i?(bt.addClass(e.domElement,Ni.CLASS_TOO_TALL),e.__ul.style.height=window.innerHeight-t-iye+"px"):(bt.removeClass(e.domElement,Ni.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(z_)&&((z_=new V0t).domElement.innerHTML=N0t),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&&q0t(e),-1===e.__rememberedObjects.indexOf(t)&&e.__rememberedObjects.push(t)})),this.autoPlace&&bV(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]=I2(this)),e.folders={},Ht.each(this.__folders,(function(t,i){e.folders[i]=t.getSaveObject()})),e},save:function(){this.load.remembered||(this.load.remembered={}),this.load.remembered[this.preset]=I2(this),yV(this,!1),this.saveToLocalStorageIfPossible()},saveAs:function(e){this.load.remembered||(this.load.remembered={},this.load.remembered[q_]=I2(this,!0)),this.load.remembered[e]=I2(this),this.preset=e,xV(this,e,!0),this.saveToLocalStorageIfPossible()},revert:function(e){Ht.each(this.__controllers,(function(t){this.getRoot().load.remembered?fye(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||yV(this.getRoot(),!1)},listen:function(e){var t=0===this.__listening.length;this.__listening.push(e),t&&pye(this.__listening)},updateDisplay:function(){Ht.each(this.__controllers,(function(e){e.updateDisplay()})),Ht.each(this.__folders,(function(e){e.updateDisplay()}))}});var mye=Ni,gye=[["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"]],bd=(()=>{let e=gye[0],t={};for(let i of gye)if((null==i?void 0:i[1])in document){for(let[n,r]of i.entries())t[e[n]]=r;return t}return!1})(),vye={change:bd.fullscreenchange,error:bd.fullscreenerror},nl={request:(e=document.documentElement,t)=>new Promise(((i,n)=>{let r=()=>{nl.off("change",r),i()};nl.on("change",r);let a=e[bd.requestFullscreen](t);a instanceof Promise&&a.then(r).catch(n)})),exit:()=>new Promise(((e,t)=>{if(!nl.isFullscreen)return void e();let i=()=>{nl.off("change",i),e()};nl.on("change",i);let n=document[bd.exitFullscreen]();n instanceof Promise&&n.then(i).catch(t)})),toggle:(e,t)=>nl.isFullscreen?nl.exit():nl.request(e,t),onchange(e){nl.on("change",e)},onerror(e){nl.on("error",e)},on(e,t){let i=vye[e];i&&document.addEventListener(i,t,!1)},off(e,t){let i=vye[e];i&&document.removeEventListener(i,t,!1)},raw:bd};Object.defineProperties(nl,{isFullscreen:{get:()=>Boolean(document[bd.fullscreenElement])},element:{enumerable:!0,get:()=>{var e;return null!=(e=document[bd.fullscreenElement])?e:void 0}},isEnabled:{enumerable:!0,get:()=>Boolean(document[bd.fullscreenEnabled])}}),bd||(nl={isEnabled:!1});var O2=nl,k2=new D,F2=class{constructor(e,t,i){this.scale=1,this.explodeUp=!1,this.scene=e,this.objectId=t,t||se.debug(`[EXP] Invalid objectId: ${t}`),i?this.explodeCenter=i:(this.explodeCenter=new D,this.getObjectCenter(this.explodeCenter));let n=this.scene.getObjectById(this.objectId);null==n||n.updateWorldMatrix(!0,!0)}explode(e){if(this.scale=e,!this.objectId||!this.explodeCenter||!this.scale)return void se.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?(se.debug(`[EXP] Exploding object '${t.name}'(id: ${t.id}) at: ${St.vectorToString(this.explodeCenter)}`),this.explodeObject(t)):se.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 i=e;if(!i.geometry)return;i.userData.originalMatrixWorld||(i.userData.originalMatrixWorld=i.matrixWorld);let n=i.userData.originalMatrixWorld;i.userData.originalCenter||(i.geometry.boundingBox||i.geometry.computeBoundingBox(),k2.set(0,0,0),null==(t=i.geometry.boundingBox)||t.getCenter(k2),k2.applyMatrix4(i.matrixWorld),i.userData.originalCenter=k2.clone());let r=i.userData.originalCenter.clone();r.sub(this.explodeCenter),r.multiplyScalar(this.scale-1),this.explodeUp&&(r.setX(0),r.setZ(0));let a=new et;a.setPosition(r),a.multiply(n),i.matrixWorld=a,i.children.length>0&&i.children.forEach((e=>e.updateMatrix()))}unexplode(){let e=this.scene.getObjectById(this.objectId);e&&e.children?(se.debug(`[EXP] Unexploding '${e.name}'(id: ${e.id}) at: ${St.vectorToString(this.explodeCenter)}`),this.unexplodeObject(e)):se.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 se.debug(`[EXP] Invalid objectId: ${this.objectId}`);let i=this.scene.getObjectById(this.objectId);i&&i.children?(i.traverse((e=>{t.expandByObject(e)})),t.getCenter(e)):se.debug("[EXP] No children to explode!")}},wV=class extends or{constructor(e,t){super(e,{id:(null==t?void 0:t.id)||wV.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.object.id))return;let t=new D;if(this.cfg.explodeCenter){let e=this.cfg.explodeCenter;t.set(e.x,e.y,e.z)}else!this.cfg.explodeCenter&&e.bbox&&e.bbox.getCenter(t);let i=new F2(this.scene,e.object.id,t);i.setExplodeUp(!!this.cfg.explodeUp),this.exploders.push(i)}))}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()}},W_=wV;W_.DEFAULT_ID="ExplodePlugin";var SV=class extends or{constructor(e,t){super(e,{id:(null==t?void 0:t.id)||SV.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",i=this.cfg.width||this.DEFAULT_SIZE,n=this.cfg.height||this.DEFAULT_SIZE,r=this.cfg.repeatX||this.DEFAULT_REPEAT,a=this.cfg.repeatY||this.DEFAULT_REPEAT,s=new D,o=this.viewer.getBBox();o&&o.getCenter(s),ft(this,null,(function*(){var e;this.groundGrass=yield this.createGrassGround(t,i,n,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,i,n,r){return ft(this,null,(function*(){return new Promise((a=>{(new ws).load(e,(e=>{e.wrapS=e.wrapT=Di,e.repeat.set(n,r),e.anisotropy=16,e.encoding=bu;let s=new Pu({map:e});s.side=pi;let o=new xt(new ui(t,i),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(),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)}},j_=SV;j_.DEFAULT_ID="GroundGrassPlugin";var MV=class extends or{constructor(e,t){super(e,{id:(null==t?void 0:t.id)||MV.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 i=this.cfg.size,n=this.cfg.divisions,r=new D,a=this.viewer.getBBox();a&&a.getCenter(r),this.gridHelper=this.createGroundGrid(i,n,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,i){e=e||this.DEFAULT_SIZE,t=t||this.DEFAULT_DIVISIONS;let n=new Nb(e,t);i?n.position.set(i.x,i.y,i.z):n.position.y=0;let r=n.material;return Array.isArray(r)||(r.opacity=this.DEFAULT_MAT_PARAMS.opacity,r.transparent=this.DEFAULT_MAT_PARAMS.transparent),n.name=this.NAME,n.layers.enableAll(),n.layers.disable(12),n.matrixAutoUpdate=!1,n.updateMatrix(),n}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)}},X_=MV;X_.DEFAULT_ID="GroundGridPlugin";var gp=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?se.error("[Uploader] No files to be uploaded!"):this.uploadFiles(t)}}formats(){return se.warn("[Uploader]: Should call derived class instead!"),[]}uploadFiles(e){se.warn(`[Uploader]: Should call derived class instead! files: ${e}`)}openFileBrowserToUpload(){this.input.click()}},N2=class extends gp{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 i=0;i<t;i++){let t=e[i];this.uploadSingleFile(t)}return}let i,n,r,a=Tr({},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&&(i=URL.createObjectURL(r),o.push(i),a.src=r.name)};if(r){l();let e=ta.extractUrlBase(i);n=new Lu,n.setURLModifier((t=>{let i=decodeURI(t).replace(e,"").replace(/^(\.?\/)/,"");if(s.has(i)){let e=s.get(i),t=URL.createObjectURL(e);return o.push(t),t}return t}))}else r=e[0],l();this.viewer.loadLocalModel(i,a,n,(e=>{let t=Math.floor(100*e.loaded/e.total);se.info(`[Uploader] Loading ${null==r?void 0:r.name}, ${t}%`)})).then((()=>{se.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()},i=e.length,n=t(e[0].name);for(let r=0;r<i;r++)if(t(e[r].name)!==n)return!1;return!0}uploadSingleFile(e){let t=Tr({},this.defaultModelConfig),i=URL.createObjectURL(e);if(t.src=e.name,e.name.toLowerCase().endsWith(".stl")){let e=new et,i=new D(0,0,0),n=new dr;n.setFromAxisAngle(new D(1,0,0),-Math.PI/2);let r=new D(.001,.001,.001);e.compose(i,n,r),t.matrix=e.elements}let n=new Lu;this.viewer.loadLocalModel(i,t,n,(t=>{let i=Math.floor(100*t.loaded/t.total);se.info(`[Uploader] Loading ${null==e?void 0:e.name}, ${i}%`)}))}};function yye(e,t,i,n,r,a,s){let o=e.addFolder(t);o.add(i,"x",r,a,s).onChange(n),o.add(i,"y",r,a,s).onChange(n),o.add(i,"z",r,a,s).onChange(n)}var xye=class extends or{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,i=this.controls;this.gui=new mye({name:"controls",autoPlace:!0,width:300,closed:!0}),this.gui.domElement.style.opacity="0.6";let n=this.gui.addFolder("Common settings");n.add(i,"showGroundGrid").name("Show ground grid").onChange((t=>{let i=e.findPlugin("GroundGridPlugin");i?i.setVisible(t):i=new X_(e)})),n.add(i,"showGroundGrass").name("Show ground grass").onChange((t=>{let i=e.findPlugin("GroundGrassPlugin");i?i.setVisible(t):i=new j_(e)})),n.add(i,"environments",i.environments).name("Environments").onChange((i=>{let n="";if("Default (City Streat 64x32)"===i){if(e.pmremGenerator)return Ac.createEnvTextureFromDataArray(e.pmremGenerator).then((e=>{t.environment=e})),void e.enableRender()}else"Venice Sunset"===i?n="venice_sunset_1k.hdr":"Footprint Court (HDR Labs)"===i?n="footprint_court_2k.hdr":"City Street"===i&&(n="city_street_256.hdr");""===n?t.environment=null:(n=`${window.location.origin}/images/envmap/${n}`,Ac.createEnvTexture(e.pmremGenerator,n).then((e=>{t.environment=e}))),e.enableRender()})),n.add(i,"homeView").name("Go to home view").onChange((()=>{e.goToHomeView()})),n.add(i,"views",i.views).name("Views").onChange((i=>{var n;let r=new D,a=new D,s=Os.getVisibleObjectBoundingBox(t),o=cE.getCameraDirectionByView(i);cE.getCameraPositionByBBoxAndDirection(s,r,a,null==(n=e.camera)?void 0:n.projectionMatrix,o),e.flyTo(r,a)})),n.add(i,"OrthographicCamera").name("Orth Camera").onChange((t=>{e.setToOrthographicCamera(t)})),n.add(i,"takeSnapshot").name("Take snapshot").onChange((()=>{let t=e.findPlugin("ScreenshotPlugin");t||(t=new dp(e));let i=t.getScreenshot(),n=document.createElement("a");n.href=i,n.download="",n.click()})),n.add(i,"takeSnapshotForViewerBBox").name("Take snapshot for viewer bbox").onChange((()=>{let t=e.findPlugin("ScreenshotPlugin");t||(t=new dp(e)),(()=>{ft(this,null,(function*(){let i=e.getBBox(),n=yield t.getScreenshotByWorldBBox(i),r=document.createElement("a");r.href=n,r.download="",r.click()}))})()})),n.add(i,"fullScreen").name("Full screen").onChange((()=>{O2&&O2.isEnabled&&O2.request(),e.enableRender()})),n.add(i,"uploadFile").name("Upload file").onChange((()=>{new N2(e).openFileBrowserToUpload()}));let r=this.gui.addFolder("Model operations");r.add(i,"transparentMode",i.transparentMode).name("Transparent mode").onChange((t=>{e.addOrRemoveObjectOpacity(t),e.enableRender()})),r.add(i,"showVertexNormals",i.showVertexNormals).name("Show Vertex Normals").onChange((t=>{e.showVertexNormals(t),e.enableRender()})),r.add(i,"explode",1,5).name("Explode tool").onChange((t=>{let i=e.findPlugin("ExplodePlugin");i||(i=new W_(e)),i.explode(t)})),r.add(i,"sectionMode",i.sectionMode).name("Section mode").onChange((t=>{let i=e.findPlugin("SectionPlugin");i||(i=new dg(e)),"No section"===t?i.deactivate():"Box section"===t?i.activate("ObjectsBoxSection"):"Pick plane section"===t?i.activate("PickPlaneSection"):"Axis plane section"===t&&i.activate("AxisPlaneSection"),e.enableRender()}));let a=this.viewer.ambientLight,s=this.gui.addFolder("Ambient light");s.add(i,"alVisible",i.alVisible).name("visible").onChange((t=>{a&&(a.visible=t),e.enableRender()})),s.addColor(i,"alColor").name("color").onChange((t=>{a&&(a.color=new ct(t)),e.enableRender()})),s.add(i,"alIntensity",0,5).name("intensity").onChange((t=>{a&&(a.intensity=t),e.enableRender()}));let o=this.viewer.directionalLight;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(i,"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(i,"showDlHelper").name("showDlHelper").onChange((t=>{e.showDirectionalLightHelper(t),e.enableRender()}));let n=()=>{e.updateDirectionalLight(),e.enableRender()};yye(t,"position",o.position,n),yye(t,"target",o.target.position,n);let r=t.addFolder("shadow");r.add(o.shadow.camera,"near").name("near").onChange(n),r.add(o.shadow.camera,"far").name("far").onChange(n),r.add(o.shadow.camera,"zoom").name("zoom").onChange(n)}let l=this.viewer.hemisphereLight,h=this.gui.addFolder("Hemisphere Light");h.add(i,"hlVisible",i.hlVisible).name("visible").onChange((t=>{l&&(l.visible=t),e.enableRender()})),h.add(i,"hlIntensity",0,5).name("intensity").onChange((t=>{l&&(l.intensity=t),e.enableRender()})),h.addColor(i,"hlColor").name("color").onChange((t=>{l&&(l.color=new ct(t)),e.enableRender()})),h.addColor(i,"hlGroundColor").name("groundColor").onChange((t=>{l&&(l.groundColor=new ct(t)),e.enableRender()}));let c=this.gui.addFolder("Fog");c.add(i,"fogEnabled",i.fogEnabled).name("Enabled").onChange((n=>{t.fog=n?new Tu(i.fogColor,i.fogNearDistance,i.fogFarDistance):null,e.enableRender()})),c.add(i,"fogNearDistance",0,100).name("Near").onChange((n=>{i.fogEnabled&&t&&(t.fog=new Tu(i.fogColor,n,i.fogFarDistance)),e.enableRender()})),c.add(i,"fogFarDistance",100,2e3).name("Far").onChange((n=>{i.fogEnabled&&t&&(t.fog=new Tu(i.fogColor,i.fogNearDistance,n)),e.enableRender()}));let u=this.gui.addFolder("Composer");u.add(i,"composerEnabled",i.composerEnabled).name("Composer Enabled").onChange((t=>{e.enableComposer(t)})),u.add(i,"renderPassEnabled",i.renderPassEnabled).name("RenderPass Enabled").onChange((t=>{e.enableRenderPass(t)})),u.add(i,"fxaaEnabled",i.fxaaEnabled).name("Effect FXAA Enabled").onChange((t=>{e.enableFxaaPass(t)})),u.add(i,"saoEnabled",i.saoEnabled).name("SAO Enabled").onChange((t=>{e.enableSaoPass(t)})),u.add(i,"ssaoEnabled",i.ssaoEnabled).name("SSAO Enabled").onChange((t=>{e.enableSsaoPass(t)})),u.add(i,"outlineEnabled",i.outlineEnabled).name("OutlinePass Enabled").onChange((t=>{e.enableOutlinePass(t)})),u.add(i,"ssaaEnabled",i.ssaaEnabled).name("SSAA Enabled").onChange((t=>{e.enableSsaaPass(t)})),u.add(i,"bloomEnabled",i.bloomEnabled).name("Bloom Enabled").onChange((t=>{e.enableBloomPass(t)})),u.add(i,"unrealBloomEnabled",i.unrealBloomEnabled).name("Unreal Bloom Enabled").onChange((t=>{e.enableUnrealBloomPass(t)}));let d=this.gui.addFolder("Performance");d.add(i,"enableFastOperation",i.enableFastOperation).name("Enable Fast Operation").onChange((t=>{e.enableFastOperation=t,e.enableRender()})).setValue(e.enableFastOperation),d.add(i,"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}},AV=class extends or{constructor(e,t){super(e,{id:(null==t?void 0:t.id)||AV.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,i=this.viewer.viewerContainer;if(!t||!i)return;let n=i.clientLeft+i.clientWidth,r=i.clientTop+i.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>n&&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,i;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==(i=this.layerMgrRoot)||i.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">&nbsp;&nbsp;Layer name</span>\n </div>\n ';if(this.dxfLayersArray){let e=this.dxfLayersArray.length>1;for(let i=0;i<this.dxfLayersArray.length;++i){let n=this.dxfLayersArray[i].layers,r=Object.keys(n);r=r.sort(((e,t)=>{let i=/[a-zA-Z0-9]/,n=e.toString(),r=t.toString();return i.test(n[0])||i.test(r[0])?n>r?1:n<r?-1:0:n.localeCompare(r)}));for(let a of r){let r=n[a],s=e?`&lt;${this.dxfLayersArray[i].modelId}&gt; ${a}`:a,o=this.convertDecimalToHex(r.color);t+=this.generateListItem(s,r.visible,o)}}}this.layerList&&(this.layerList.innerHTML=t);let i=null==(e=this.layerMgrRoot)?void 0:e.querySelectorAll("input[type=checkbox]");this.checkboxes=[].slice.call(i,0),this.checkboxes.forEach((e=>{e.addEventListener("change",(()=>{this.checkboxHandler(e)}))}))}generateListItem(e,t,i){return`\n <div class="layer-list-item">\n <input type="checkbox" value="${e}" ${t?"checked":""} class="checkbox">\n <div class="item-color" style="${i?`background-color: ${i}`:"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 i=this.viewer;if("toggleAllLayers"===e.id){for(let t=0;t<this.dxfLayersArray.length;++t){let n=this.dxfLayersArray[t].modelId,r=this.dxfLayersArray[t].layers;Object.keys(r).forEach((t=>{i.setLayerVisibility(t,e.checked,n)}))}return void(null==(t=this.checkboxes)||t.forEach((t=>t.checked=e.checked)))}let n="",r=e.value,a=r.indexOf(">");-1!==a&&(n=r.slice(1,a),r=r.slice(a+2)),n||(n=this.dxfLayersArray[0].modelId),i.setLayerVisibility(r,e.checked,n)}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 i=this.dxfLayersArray[t].layers;e+=Object.keys(i).length}this.headerText.innerHTML=`Layers (count: ${e})`}convertDecimalToHex(e){return void 0===e?void 0:`#${e.toString(16).padStart(6,"0")}`}},RV=AV;RV.DEFAULT_ID="LayerManagerPlugin";var bye={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}"},Eye={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}"},PV=class extends or{constructor(e,t){let i=(null==t?void 0:t.id)||PV.DEFAULT_ID;super(e,{id:i}),this.shouldRender=!1,this.onModelLoaded=()=>{this.timeout&&clearTimeout(this.timeout),this.timeout=setTimeout((()=>{this.update()}),2e3)},this.onShadowRender=()=>{var e,t,i,n,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==(i=this.depthMaterial)||i.dispose(),this.depthMaterial=void 0,null==(n=this.horizontalBlurMaterial)||n.dispose(),this.horizontalBlurMaterial=void 0,null==(r=this.verticalBlurMaterial)||r.dispose(),this.verticalBlurMaterial=void 0,this.shouldRender=!1)},this.cfg=t||{id:i},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 _c,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 cn(bye),this.horizontalBlurMaterial.depthTest=!1,this.verticalBlurMaterial=new cn(Eye),this.verticalBlurMaterial.depthTest=!1}initRenderTarget(){this.renderTarget=new sr(128,128),this.renderTarget.texture.generateMipmaps=!1,this.renderTargetBlur=new sr(128,128),this.renderTargetBlur.texture.generateMipmaps=!1}updateGroundShadow(){var e,t,i;let n=this.viewer.getBBox(),r=new er;r.name="ground-shadow",Hn.disableLayerChannels(r,[12,11]),null==(e=this.scene)||e.add(r);let{min:a,max:s}=n,o=new D;n.getSize(o),o.multiplyScalar(2);let l=new D;n.getCenter(l);let h=new ui(o.x,o.z).rotateX(Math.PI/2),c=new ln({map:null==(t=this.renderTarget)?void 0:t.texture,transparent:!0,depthWrite:!1}),u=new xt(h,c);u.renderOrder=1,u.position.set(l.x,a.y,l.z),u.scale.y=-1,null==r||r.add(u),this.shadowCamera=new Nr(-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),r.add(this.shadowCamera);let d=new xt(h);d.position.set(l.x,a.y,l.z),d.visible=!1,r.add(d),this.blurPlane=d,null==(i=this.shadowGroup)||i.removeFromParent(),this.shadowGroup=r}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,i,n,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==(i=this.depthMaterial)||i.dispose(),this.depthMaterial=void 0,null==(n=this.horizontalBlurMaterial)||n.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}},CV=PV;CV.DEFAULT_ID="GroundShadowPlugin";var _ye=class extends or{constructor(e){super(e,{id:"HotpointPlugin"}),this.onAfterRender=()=>{var e;let t=this.viewer.scene,i=this.viewer.camera;!t||!i||!this.hotpointRoot||0===this.hotpointRoot.children.length||null==(e=this.css2dRenderer)||e.render(t,i)},this.css2dRenderer=this.viewer.css2dRenderer,this.viewer.addEventListener("AfterRender",this.onAfterRender)}add(e){var t;if(this.has(e.hotpointId))return void se.warn(`[Hotpoint] Hotpoint with id '${e.hotpointId}' already exist!`);let i=e.anchorPosition,n=Mf.createHotpoint(e.html);n.position.set(i[0]||0,i[1]||0,i[2]||0),n.visible=!1!==e.visible,n.userData.hotpoint=e,this.hotpointRoot||(this.hotpointRoot=new er,this.hotpointRoot.matrixAutoUpdate=!1,this.hotpointRoot.matrixWorldAutoUpdate=!1,this.hotpointRoot.name="HotpointRoot",null==(t=this.viewer.scene)||t.add(this.hotpointRoot)),this.hotpointRoot.add(n),n.updateWorldMatrix(!1,!1),this.viewer.enableRender()}remove(e){var t,i;let n=(null==(t=this.hotpointRoot)?void 0:t.children)||[];for(let r=0;r<n.length;++r){let t=n[r];(null==(i=t.userData.hotpoint)?void 0:i.hotpointId)===e&&t.removeFromParent()}}clear(){var e;null==(e=this.hotpointRoot)||e.clear()}has(e){return!!this.findHotpointObject(e)}move(e,t){let i=this.findHotpointObject(e);if(i){let e=t.z||0;i.position.set(t.x,t.y,e),i.updateWorldMatrix(!1,!1),this.viewer.enableRender()}}setVisible(e,t){let i=this.findHotpointObject(e);i&&(i.visible=t)}findHotpointObject(e){var t;return((null==(t=this.hotpointRoot)?void 0:t.children)||[]).find((t=>{var i;return(null==(i=t.userData.hotpoint)?void 0:i.hotpointId)===e}))}},Fs=Xi(Tye(),1),ai=Xi(r1e(),1),r8={Fill:"Fill",Stroke:"Stroke",Shading:"Shading"},Ql={Fill:0,Stroke:1,FillStroke:2,Invisible:3,FillAddToPath:4,StrokeAddToPath:5,FillStrokeAddToPath:6,AddToPath:7,FillStrokeMask:3,AddToPathFlag:4},i1e=16,s1e=100,i8=[1,0,0,1,0,0],s8=[.001,0,0,.001,0,0],Y0t={},a1e={},o1e=new ct,X2=new et,l1e=0,$0t=.01,a8=class extends Er{constructor(e){if(super(),this.contentVisible=!0,this.markedContentStack=[],this.stateStack=[],this.current=new Y2(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 et,this.currentTransform=new et,this.transformStack=[],this.clipType=Fs.PolyFillType.pftNonZero,this.paths=[],this.pointsMaterials={},this.lineBasicMaterials={},this.meshBasicMaterials={},this.lineWithWidthCount=0,void 0===ai)throw"[PdfLoader] need load pdf.js first";"3.8.162"!==ai.version&&se.warn("[PdfLoader] The pdf.js version we are using now is 3.8.162,if not maybe wrong."),this.fontManager=e.font,ai.GlobalWorkerOptions.workerSrc=e.pdfWorker}load(e,t,i,n){this.loadAsync(e,i).then((e=>{t(e)})).catch((e=>{n(e)}))}loadAsync(e,t){return ft(this,null,(function*(){var i,n,r;let a=St.getUpdateProgressFunc(t),s=St.getUpdateSubProgressFunc(0,10,t),o=St.getUpdateSubProgressFunc(30,90,t);a(0);let{src:l}=e;this.modelCfg=e;let h=e.modelId||l,c=Date.now(),u=ai.getDocument(l);u.onProgress=s;let d=yield u.promise;this.pdf=d,se.info(`[PdfLoader] Pdf document loaded in ${(Date.now()-c)/1e3}s`),c=Date.now(),se.log(d),this.pdfDocumentGroup=new er,this.pdfDocumentGroup.name=`PdfDocument-${h}`,this.optionalContentConfig=yield d.getOptionalContentConfig(),d.numPages>1&&se.info("[PdfLoader] Only the first page can be render others will be ignore.");let p=yield d.getPage(1);a(20),se.info(`[PdfLoader] Pdf page loaded in ${(Date.now()-c)/1e3}s`),c=Date.now(),se.log(p),this.pdfPage=p,this.pdfPageGroup=new er,this.pdfPageGroup.name=a8.MODEL_LAYOUT_NAME,this.pdfDocumentGroup.add(this.pdfPageGroup),this.commonObjs=d._transport.commonObjs,this.objs=p.objs,yield null==(i=this.fontManager)?void 0:i.getFontFromIndexeddb(),se.log("[PdfLoader] Font loaded.");let f=p.view,m=8192/Math.max(f[2]-f[0],f[3]-f[1]),g=Math.min(300/72,m),v=p.getViewport({scale:g});return this.beginDrawing(v),this.current=new Y2(v.width,v.height),yield this.buildLayers(p),a(30),yield this.getOperatorList(o),null!=(n=this.fontManager)&&n.missingFonts&&se.warn("[PdfLoader] Missing fonts and reference count:",null==(r=this.fontManager)?void 0:r.missingFonts,", used other fonts instead."),this.lineWithWidthCount>0&&se.warn(`[PdfLoader] Found ${this.lineWithWidthCount} line(s) with width, line width is not supported and was ignored.`),a(100),se.info(`[PdfLoader] Loaded '${e.src}' in ${(Date.now()-c)/1e3}s, adding to scene...`),{modelId:h,pdfData:{threejsObject:this.pdfDocumentGroup,layers:this.layers||[],layersAndThreejsObjects:this.layersAndThreejsObjects,loadedEntityCount:this.loadedEntityCount}}}))}getOperatorList(e){return ft(this,null,(function*(){let t=this.pdfPage;if(!t)return;let i,n=ai.AnnotationMode.ENABLE,r=t._transport.getRenderingIntent("display",n,null,!0),a=t._intentStates.get(r.cacheKey);return a||(a=Object.create(null),t._intentStates.set(r.cacheKey,a)),a.opListReadCapability||(i=Object.create(null),i.operatorListChanged=function(){a.operatorList.lastChunk&&(a.opListReadCapability.resolve(a.operatorList),a.renderTasks.delete(i))},a.opListReadCapability=new ai.PromiseCapability,(a.renderTasks||(a.renderTasks=new Set)).add(i),a.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null}),yield this._pumpOperatorList(r,e)}))}_pumpOperatorList(e,t){return ft(this,null,(function*(){var i,n;let r=this.pdfPage;if(!r)return;let{renderingIntent:a,cacheKey:s,annotationStorageSerializable:o}=e,{map:l,transfers:h}=o,c=r._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:r._pageIndex,intent:a,cacheKey:s,annotationStorage:l},h).getReader(),u=r._intentStates.get(s);u.streamReader=c;let d=u.operatorList.argsArray.length,p=d<3e3;se.info(`[PdfLoader] Operation count: ${d}, isVerboseProgress: ${p}`);let f=0,m=St.getUpdateProgressFunc(t);for(m(0);;)try{let{value:e,done:a}=yield c.read();if(a)return u.streamReader=null,void m(100);if(r._transport.destroyed)return;let s=e,o=s.argsArray.length,l=100*f/d,h=100*(f+o)/d;if(p){let e=St.getUpdateSubProgressFunc(l,h,t);yield this.executeOperatorList(s,e)}else yield this.executeOperatorList(s),m(h);null==(i=this.pdfPageGroup)||i.updateMatrixWorld(!0),null!=(n=this.modelCfg)&&n.merge&&this.mergePdfObjects(),s.lastChunk&&this.endDrawing(),f+=o}catch(e){if(u.streamReader=null,r._transport.destroyed)return;if(u.operatorList){u.operatorList.lastChunk=!0;for(let e of u.renderTasks)e.operatorListChanged();this.tryCleanup()}if(u.displayReadyCapability)u.displayReadyCapability.reject(e);else{if(!u.opListReadCapability)throw e;u.opListReadCapability.reject(e)}}}))}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 i=Rr.deepMerge(t,this.pdfPageGroup,!1,!1,!1),n=i.added,r=i.removed;r.forEach((e=>{var t,i;null==(t=this.pdfPageGroup)||t.remove(e);let n=e;n.geometry.dispose(),n.material.dispose(),null==(i=n.material.map)||i.dispose()})),n.forEach((e=>{var t;null==(t=this.pdfPageGroup)||t.add(e)}));let a=t.filter((e=>!r.includes(e)));a.push(...n),this.layersAndThreejsObjects[e]=a}}getPointsMaterial(e,t=1){return this.pointsMaterials[`${e}-${t}`]||(this.pointsMaterials[`${e}-${t}`]=new bi({color:e,transparent:!0,opacity:t})),this.pointsMaterials[`${e}-${t}`]}getLineBasicMaterial(e,t=1){return this.lineBasicMaterials[`${e}-${t}`]||(this.lineBasicMaterials[`${e}-${t}`]=new Gn({color:e,transparent:!0,opacity:t})),this.lineBasicMaterials[`${e}-${t}`]}getMeshBasicMaterial(e,t=1){return this.meshBasicMaterials[`${e}-${t}`]||(this.meshBasicMaterials[`${e}-${t}`]=new ln({color:e,transparent:!0,opacity:t,side:Sr})),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,i,n;se.log("beginDrawing",e),this.viewportScale=e.scale;let[r,a,s,o,l,h]=e.transform;this.baseTransform.set(r,s,0,l,a,o,0,h,0,0,1,0,0,0,0,1),this.currentTransform.copy(this.baseTransform),null==(t=this.pdfDocumentGroup)||t.applyMatrix4(this.baseTransform),null==(i=this.pdfDocumentGroup)||i.rotateZ(Rn.degToRad(-e.rotation));let{width:c,height:u}=e,d=(new Dt).setFromPoints([new D(0,0,0),new D(c,0,0),new D(c,u,0),new D(0,0,0),new D(c,u,0),new D(0,u,0)]),p=new ln({color:16777215}),f=new xt(d,p);f.renderOrder=-999,null==(n=this.pdfDocumentGroup)||n.add(f)}endDrawing(){var e;null==(e=this.pdfPageGroup)||e.updateMatrixWorld(!0),this.tryCleanup(),this.releaseData()}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 ft(this,null,(function*(){if(!this.pdf)return;let t=yield e.getOperatorList(),i=t.fnArray,n=t.argsArray,r={},a=1;for(let e=0;i&&e<i.length;e++)if(i[e]===ai.OPS.beginMarkedContentProps&&n[e]&&"OC"==n[e][0]&&null!==n[e][1]){let t;t="object"==typeof n[e][1]?n[e][1].id:n[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 se.log("buildLayers",o),this.layers=o,{layerCount:l,layersMap:o,layers:r}}))}addObjectToModel(e){var t,i;this.layersAndThreejsObjects||(this.layersAndThreejsObjects={});let n=this.layers[this.currentLayerId],r=(null==n?void 0:n.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,l1e),l1e+=$0t),null==(i=this.pdfPageGroup)||i.add(e)}executeOperatorList(e,t){return ft(this,null,(function*(){var i;let n=e.argsArray,r=e.fnArray,a=n.length,s=St.getUpdateProgressFuncForLoop(a,t),o=this.commonObjs,l=this.objs,h=0;for(;h<a;){let e=r[h];if(e!==ai.OPS.dependency)null==(i=this[e])||i.apply(this,n[h]);else for(let t of n[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,i]of e)switch(t){case"LW":this.setLineWidth(i);break;case"LC":this.setLineCap(i);break;case"LJ":this.setLineJoin(i);break;case"ML":this.setMiterLimit(i);break;case"D":this.setDash(i[0],i[1]);break;case"RI":this.setRenderingIntent(i);break;case"FL":this.setFlatness(i);break;case"Font":this.setFont(i[0],i[1]);break;case"CA":this.current.strokeAlpha=i;break;case"ca":this.current.fillAlpha=i;break;case"BM":case"TR":break;case"SMask":this.current.activeSMask=i?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,i,n,r,a){let s=X2.set(e,i,0,r,t,n,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,i=[],n=[];for(let r=0;r<this.paths.length;r++){let e=this.paths[r],t=1===e.getPoints().length,a=(new Dt).setFromPoints(e.getPoints());a.applyMatrix4(this.currentTransform),t?i.push(a):n.push(a)}if(i.length>0){let n=Ui(i),r=new ii(n,this.getPointsMaterial(e,t));this.addObjectToModel(r)}if(n.length>0){let i=Ui(n),r=new fr(i,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&&se.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 Fs.PolyTree,i=new Fs.Clipper,n=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;Fs.JS.ScaleUpPaths(n,a),Fs.JS.ScaleUpPaths(r,a),i.AddPaths(n,Fs.PolyType.ptSubject,!0),i.AddPaths(r,Fs.PolyType.ptClip,!0),i.Execute(Fs.ClipType.ctIntersection,e,this.pendingEOFill?Fs.PolyFillType.pftEvenOdd:Fs.PolyFillType.pftNonZero,this.clipType);let s=Fs.JS.PolyTreeToExPolygons(e);for(let o=0;o<s.length;o++){let{outer:e,holes:i}=s[o],n=new _s;n.setFromPoints(e.map((e=>new xe(e.X/a,e.Y/a)))),i.length>0&&i.forEach((e=>{let t=new _s;t.setFromPoints(e.map((e=>new xe(e.X/a,e.Y/a)))),n.holes.push(t)})),t.push(n)}this.clipPaths=void 0}e=t.length>0?new Rl(t):Ui(this.paths.map((e=>new Rl(e)))),e.applyMatrix4(this.currentTransform);let i=this.current.fillColor,n=this.current.fillAlpha,r=new xt(e,this.getMeshBasicMaterial(i,n));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=Y0t}eoClip(){this.pendingClip=a1e}beginText(){this.current.textMatrix=i8,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}endText(){this.currentPath=new _s}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 i=this.commonObjs.get(e),n=this.current;if(!i)throw new Error(`Can't find font for ${e}`);if(n.fontMatrix=i.fontMatrix||s8,(0===n.fontMatrix[0]||0===n.fontMatrix[3])&&se.warn("Invalid font matrix for font "+e),t<0?(t=-t,n.fontDirection=-1):n.fontDirection=1,this.current.font=i,this.current.fontSize=t,i.isType3Font)return;let r=t;t<i1e?r=i1e:t>s1e&&(r=s1e),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,i,n,r,a){this.current.textMatrix=[e,t,i,n,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,i){var n,r,a,s;se.log("paintChar",e,t,i);let o,l,h=this.current,c=h.font,u=h.textRenderingMode,d=h.fontSize/h.fontSizeScale,p=u&Ql.FillStrokeMask,f=!!(u&Ql.AddToPathFlag),m=h.patternFill&&!c.missingFile;return(c.disableFontFace||f||m)&&(o=c.getPathGenerator(this.commonObjs,e)),c.disableFontFace||m?se.log("paintChar path:",o,d,p):((p===Ql.Fill||p===Ql.FillStroke)&&(l=null==(r=this.fontManager)?void 0:r.getCharShape(e,null==(n=this.current.font)?void 0:n.name,.8*this.current.browserFontSize)),(p===Ql.Stroke||p===Ql.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,i;let n=this.current,r=n.font;if(r.isType3Font)return this.showType3Text(e);let a=n.fontSize;if(0===a)return;let s=n.fontSizeScale,o=n.charSpacing,l=n.wordSpacing,h=n.fontDirection,c=n.textHScale*h,u=e.length,d=r.vertical,p=d?1:-1,f=r.defaultVMetrics,m=a*n.fontMatrix[0],g=n.textRenderingMode===Ql.Fill&&!r.disableFontFace&&!n.patternFill,[v,y,x,b,_,w]=n.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(n.x,n.y+n.textRise,0)),h>0?S.scale(new D(c,1,1)):S.scale(new D(c,-1,1));let M=n.lineWidth,E=n.textMatrixScale;0===E||0===M?(n.textRenderingMode&Ql.FillStrokeMask)===Ql.Stroke||Ql.FillStroke:M/=E,1!==s&&(S.scale(new D(s,s,1)),M/=s);let T,A=0,C=[];for(T=0;T<u;++T){let n=e[T];if("number"==typeof n){A+=p*n*a/1e3;continue}let c,u,v,y=(n.isSpace?l:0)+o,x=n.unicode,b=n.accent,_=n.width;if(d){let e=n.vmetric||f,t=-(n.vmetric?e[1]:.5*_)*m,i=e[2]*m;_=e?-e[0]:_,c=t/s,u=(A+i)/s}else c=A/s,u=0;if(r.remeasure,this.contentVisible&&(n.isInFont||r.missingFile))if(g&&!b){let e=null==(i=this.fontManager)?void 0:i.getCharShape(x,null==(t=this.current.font)?void 0:t.name,.8*this.current.browserFontSize);e&&(e.translate(c,u,0),e.applyMatrix4(S),C.push(e))}else{let e=this.paintChar(x,c,u);e&&(e.translate(c,u,0),e.applyMatrix4(S),C.push(e))}v=d?_*m-y*h:_*m+y*h,A+=v}if(C.length>0){let e,t=C[0]instanceof Qs,i=Ui(C);e=t?new xt(i,this.getMeshBasicMaterial(this.current.fillColor)):new qr(i,this.getLineBasicMaterial(this.current.fillColor)),e&&(this.addObjectToModel(e),e.layers.disable(11))}d?n.y-=A:n.x+=A*c}showType3Text(e){}setCharWidth(e,t){}setCharWidthAndBounds(e,t,i,n,r,a){}setStrokeColor(){}setStrokeColorN(){}setFillColorN(){this.current.patternFill=!0}setStrokeRGBColor(e,t,i){this.current.strokeColor=o1e.setRGB(e/255,t/255,i/255).convertSRGBToLinear().getHex()}setFillRGBColor(e,t,i){this.current.fillColor=o1e.setRGB(e/255,t/255,i/255).convertSRGBToLinear().getHex(),this.current.patternFill=!1}shadingFill(){}beginInlineImage(){}beginImageData(){}markPoint(e){}markPointProps(e,t){}beginMarkedContent(e){se.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===a1e?this.clipType=Fs.PolyFillType.pftEvenOdd:this.clipType=Fs.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){se.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):se.warn("Dependent image isn't ready yet")}paintInlineImageXObject(e){if(!this.contentVisible)return;se.log("paintInlineImageXObject",e),this.save();let{bitmap:t,width:i,height:n}=e;this.currentTransform.multiply(X2.makeScale(1/i,-1/n,1));let r=new wb(t),a=new ln({map:r,transparent:!0}),s=new ui(i,n),o=new xt(s,a);o.translateX(i/2),o.translateY(-n/2),o.applyMatrix4(this.currentTransform),this.addObjectToModel(o),this.restore()}paintInlineImageXObjectGroup(){}paintImageXObjectRepeat(){}paintImageMaskXObjectRepeat(){}paintSolidColorImageMask(){}_scaleImage(e,t){let i=e.width,n=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=i,o=n,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,i){let n,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],c=h?i.slice(0):null;for(let u=0,d=0,p=e.length;u<p;u++)switch(this.currentPath||(this.currentPath=new _s),0|e[u]){case ai.OPS.rectangle:{s=t[d++],o=t[d++];let e=t[d++],i=t[d++],n=s+e,r=o+i;this.currentPath.moveTo(s,o),0===e||0===i?this.currentPath.lineTo(n,r):(this.currentPath.lineTo(n,o),this.currentPath.lineTo(n,r),this.currentPath.lineTo(s,r)),h||a.updateRectMinMax(l,[s,o,n,r]),this.currentPath.closePath(),this.paths.push(this.currentPath.clone()),this.currentPath=void 0}break;case ai.OPS.moveTo:s=t[d++],o=t[d++],this.currentPath.moveTo(s,o),h||a.updatePathMinMax(l,s,o);break;case ai.OPS.lineTo:s=t[d++],o=t[d++],this.currentPath.lineTo(s,o),h||a.updatePathMinMax(l,s,o);break;case ai.OPS.curveTo:n=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,n,r,t[d],t[d+1],t[d+2],t[d+3],s,o,c),d+=6;break;case ai.OPS.curveTo2:n=s,r=o,this.currentPath.bezierCurveTo(s,o,t[d],t[d+1],t[d+2],t[d+3]),a.updateCurvePathMinMax(l,n,r,s,o,t[d],t[d+1],t[d+2],t[d+3],c),s=t[d+2],o=t[d+3],d+=4;break;case ai.OPS.curveTo3:n=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,n,r,t[d],t[d+1],s,o,s,o,c),d+=4;break;case ai.OPS.closePath:this.paths.push(this.currentPath.clone()),this.currentPath=void 0}this.currentPath&&this.paths.push(this.currentPath.clone()),h&&a.updateScalingPathMinMax(l,c),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}},sh=a8;sh.MODEL_LAYOUT_NAME="Model";for(let t in ai.OPS)void 0!==sh.prototype[t]&&(sh.prototype[ai.OPS[t]]=sh.prototype[t]);var Y2=class{constructor(e,t){this.textMatrix=i8,this.fontMatrix=s8,this.textRenderingMode=Ql.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=i8,this.textMatrixScale=1,this.fontMatrix=s8,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=Ql.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 Ln,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,i){[t,i]=ai.Util.applyTransform([t,i],e),this.minX=Math.min(this.minX,t),this.minY=Math.min(this.minY,i),this.maxX=Math.max(this.maxX,t),this.maxY=Math.max(this.maxY,i)}getPathBoundingBox(e=r8.Fill,t=null){let i=[this.minX,this.minY,this.maxX,this.maxY];if(e===r8.Stroke){if(!t)throw new Error("Stroke bounding box must include transform.");let e=ai.Util.singularValueDecompose2dScale(t),n=e[0]*this.lineWidth/2,r=e[1]*this.lineWidth/2;i[0]-=n,i[1]-=r,i[2]+=n,i[3]+=r}return i}updateRectMinMax(e,t){let i=ai.Util.applyTransform(t,e),n=ai.Util.applyTransform(t.slice(2),e);this.minX=Math.min(this.minX,i[0],n[0]),this.minY=Math.min(this.minY,i[1],n[1]),this.maxX=Math.max(this.maxX,i[0],n[0]),this.maxY=Math.max(this.maxY,i[1],n[1])}updateScalingPathMinMax(e,t){ai.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,i,n,r,a,s,o,l,h){let c=ai.Util.bezierBoundingBox(t,i,n,r,a,s,o,l);if(h)return h[0]=Math.min(h[0],c[0],c[2]),h[1]=Math.max(h[1],c[0],c[2]),h[2]=Math.min(h[2],c[1],c[3]),void(h[3]=Math.max(h[3],c[1],c[3]));this.updateRectMinMax(e,c)}updateClipFromPath(){let e=ai.Util.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(e||[0,0,0,0])}isEmptyClip(){return this.minX===1/0}getClippedPathBoundingBox(e=r8.Fill,t=null){return ai.Util.intersect(this.clipBox,this.getPathBoundingBox(e,t))||[]}},l8=class extends or{constructor(e,t){super(e,{id:(null==t?void 0:t.id)||l8.DEFAULT_ID}),this.cfg=t||{}}loadAsync(e,t){return ft(this,null,(function*(){let i=this.viewer;i.increaseJobCount();let n=this.cfg.font,r=this.cfg.pdfWorker,a=yield new sh({font:n,pdfWorker:r}).loadAsync(e,t);return i.decreaseJobCount(),a}))}},o8=l8;o8.DEFAULT_ID="PdfLoaderPlugin";var c1e=class extends gp{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 i=e[t];i.name.match(/\.(dxf)$/)?this.uploadSingleDxf(i):i.name.match(/\.(pdf)$/)&&this.uploadSinglePdf(i)}}uploadSingleDxf(e){return ft(this,null,(function*(){let t=Ii(Tr({},this.defaultModelConfig),{src:URL.createObjectURL(e),modelId:e.name});yield this.viewer.loadModelAsync(t,(t=>{let i=Math.floor(100*t.loaded/t.total);se.info(`[Uploader] Loading ${null==e?void 0:e.name}, ${i}%`)}))}))}uploadSinglePdf(e){return ft(this,null,(function*(){let t=t=>{let i=Math.floor(100*t.loaded/t.total);se.info(`[Uploader] Loading ${null==e?void 0:e.name}, ${i}%`)};try{let i=this.viewer;i.increaseJobCount();let n={font:i.fontManager,pdfWorker:this.pdfWorker},r={merge:!0,src:URL.createObjectURL(e),modelId:e.name};new sh(n).loadAsync(r,t).then((e=>{this.viewer.addModel(e),this.onSuccess&&this.onSuccess({}),i.decreaseJobCount(),se.info(`[Uploader] Loaded model '${r.src}'`)}))}catch(e){se.info(e)}}))}},u1e=class extends gp{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 i=[];i.push(URL.createObjectURL(e[0])),t.panoramas.push({id:"panorama_1",images:i}),this.viewer.setViewpoints([t]),this.viewer.activatePanoramaById(t.id,t.panoramas[0].id)}else if(6===e.length){let i=t=>{let i="";for(let n=0;n<e.length;++n){let r=e[n].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){i=URL.createObjectURL(e[n]);break}}return i},n=[i(["right","r"]),i(["left","l"]),i(["up","top","u"]),i(["down","bottom","d"]),i(["front","f"]),i(["back","b"])];t.panoramas.push({id:"panorama_1",images:n}),this.viewer.setViewpoints([t]),this.viewer.activatePanoramaById(t.id,t.panoramas[0].id)}else se.warn(`[Uploader] Expected 1 or 6 file, bug got ${e.length}!`)}},vg=Xi(kl(),1),h1e="#2C7BE5",gi=Math.PI/2,Ur=Math.PI/4,Ys=([e,t,i],[n,r,a])=>({position:new D(e,t,i),rotation:new Xn(n,r,a)}),Z0t={Front:Ii(Tr({},Ys([0,0,1],[0,0,0])),{label:"NavCube.front"}),Right:Ii(Tr({},Ys([1,0,0],[0,gi,0])),{label:"NavCube.right"}),Back:Ii(Tr({},Ys([0,0,-1],[0,Math.PI,0])),{label:"NavCube.back"}),Left:Ii(Tr({},Ys([-1,0,0],[0,-gi,0])),{label:"NavCube.left"}),Top:Ii(Tr({},Ys([0,1,0],[-gi,0,0])),{label:"NavCube.top"}),Bottom:Ii(Tr({},Ys([0,-1,0],[gi,0,0])),{label:"NavCube.bottom"})},K0t=[Ys([0,1,1],[-Ur,0,-gi]),Ys([0,1,-1],[-3*Ur,0,-gi]),Ys([0,-1,1],[Ur,0,-gi]),Ys([0,-1,-1],[3*Ur,0,-gi]),Ys([1,1,0],[-gi,Ur,0]),Ys([1,-1,0],[-gi,3*Ur,0]),Ys([-1,1,0],[-gi,-Ur,0]),Ys([-1,-1,0],[-gi,-3*Ur,0]),Ys([1,0,1],[0,Ur,0]),Ys([1,0,-1],[0,3*Ur,0]),Ys([-1,0,1],[0,-Ur,0]),Ys([-1,0,-1],[0,-3*Ur,0])],J0t=[{position:new D(1,1,1),rotation:[new Xn(-gi,gi,-Ur),new Xn(-gi,0,Ur),new Xn(0,0,3*Ur)]},{position:new D(1,1,-1),rotation:[new Xn(0,gi,3*Ur),new Xn(-gi,0,3*Ur),new Xn(0,Math.PI,-3*Ur)]},{position:new D(-1,1,-1),rotation:[new Xn(Math.PI,-gi,Ur),new Xn(-gi,0,-3*Ur),new Xn(0,Math.PI,3*Ur)]},{position:new D(-1,1,1),rotation:[new Xn(0,-gi,3*Ur),new Xn(-gi,0,-Ur),new Xn(0,0,-3*Ur)]},{position:new D(1,-1,1),rotation:[new Xn(0,gi,-Ur),new Xn(-gi,Math.PI,-Ur),new Xn(0,0,Ur)]},{position:new D(1,-1,-1),rotation:[new Xn(-gi,gi,3*Ur),new Xn(gi,0,Ur),new Xn(0,Math.PI,-Ur)]},{position:new D(-1,-1,1),rotation:[new Xn(0,-gi,Ur),new Xn(gi,0,-3*Ur),new Xn(0,0,-Ur)]},{position:new D(-1,-1,-1),rotation:[new Xn(0,-gi,-Ur),new Xn(gi,0,-Ur),new Xn(0,Math.PI,Ur)]}],$2=class extends on{constructor(e={}){super(),this.NAVCUBE_SIZE=100,this.clickHandler=e.onClick,(0,vg.forEach)(Z0t,(e=>{this.createPlane(e)})),(0,vg.forEach)(K0t,(e=>{this.createEdge(e)})),(0,vg.forEach)(J0t,((e,t)=>{this.createCorner(e,t)}))}createPlane(e){let t=e.position.clone().multiplyScalar(this.NAVCUBE_SIZE/2),{rotation:i,label:n}=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=Qu(n),a.classList.add("navcube-plane"),a.classList.add("inner"),r.appendChild(a);let s=new fg(r);s.position.copy(t),s.rotation.copy(i),this.add(s),r.addEventListener("click",(()=>{this.clickHandler&&this.clickHandler(t.clone().normalize(),i)}))}createEdge(e){let t=e.position.clone().multiplyScalar(this.NAVCUBE_SIZE/2),i=document.createElement("div");i.style.width="4px",i.style.height=this.NAVCUBE_SIZE-40+"px",i.style.background=h1e,i.classList.add("navcube-edge");let n=new fg(i);n.position.copy(t),n.rotation.copy(e.rotation),this.add(n),i.addEventListener("click",(()=>{this.clickHandler&&this.clickHandler(t.clone().normalize(),e.rotation)}))}createCorner(e,t){let i=i=>{i.addEventListener("click",(()=>{this.clickHandler&&this.clickHandler(e.position.clone().normalize(),new Xn)})),i.addEventListener("mouseenter",(()=>{let e=document.getElementsByClassName("group-"+t);(0,vg.forEach)(e,(e=>{e instanceof HTMLElement&&e.classList.add("highlight")}))})),i.addEventListener("mouseleave",(()=>{let e=document.getElementsByClassName("group-"+t);(0,vg.forEach)(e,(e=>{e instanceof HTMLElement&&e.classList.remove("highlight")}))}))},n=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 fg(r);a.position.copy(n).lerp(e.position,.14);let s=Math.atan2(n.z,n.x);a.rotateY(n.z*n.x<0?Math.PI+s:s);let o=(new Xn).setFromVector3(n.clone().normalize());a.rotateX(-o.y),n.y<0&&a.rotateZ(Math.PI),this.add(a);let l=(t,r,a)=>{let s=document.createElement("div");s.style.borderTop=`13px solid ${h1e}`,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 fg(s),l=e.position.clone();l.setComponent(a,0),o.position.copy(n).sub(l),o.rotateX(t.x),o.rotateY(t.y),o.rotateZ(t.z),this.add(o),i(s)};(0,vg.forEach)(e.rotation,((e,i)=>{l(e,t,i)})),i(r)}},u8=class extends or{constructor(e,t){super(e,{id:(null==t?void 0:t.id)||u8.DEFAULT_ID}),this.cfg=t||{},this.init()}init(){this.initRenderer(),this.initScene(),this.animate()}initRenderer(){var e;let t,i=135,n=135;if(this.cfg.containerId&&(t=document.getElementById(this.cfg.containerId),t&&(i=t.clientWidth,n=t.clientHeight)),!t){let i="navCube";t=document.createElement("div"),t.id=i,null==(e=this.viewer.widgetContainer)||e.appendChild(t)}this.renderer=new g2,this.renderer.setSize(i,n),this.renderer.domElement.classList.add("css3d-navcube"),t.appendChild(this.renderer.domElement)}initScene(){this.scene=new Si;let e=window.innerWidth/window.innerHeight;this.camera=new Nr(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=>{let t=this.viewer.controls;if(!(this.camera&&e&&this.viewer.camera&&t))return;let i=t instanceof va?t.getTarget(new D):t.target,n=this.viewer.camera.position.distanceTo(i);this.viewer.flyTo(i.clone().add(e.clone().multiplyScalar(n)),i)}}),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(){if(!this.viewer||!this.viewer.camera)return;let e=this.viewer.camera;if(e){let t=new D;e.getWorldDirection(t);let i=e.up;this.updateCameraDirection(t,i)}}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)}},c8=u8;c8.DEFAULT_ID="NavCubePlugin";var Q_=function(){var e=0,t=document.createElement("div");function i(e){return t.appendChild(e.dom),e}function n(i){for(var n=0;n<t.children.length;n++)t.children[n].style.display=n===i?"block":"none";e=i}t.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",t.addEventListener("click",(function(i){i.preventDefault(),n(++e%t.children.length)}),!1);var r=(performance||Date).now(),a=r,s=0,o=i(new Q_.Panel("FPS","#0ff","#002")),l=i(new Q_.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var h=i(new Q_.Panel("MB","#f08","#201"));return n(0),{REVISION:16,dom:t,addPanel:i,showPanel:n,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:n}};Q_.Panel=function(e,t,i){var n=1/0,r=0,a=Math.round,s=a(window.devicePixelRatio||1),o=80*s,l=48*s,h=3*s,c=2*s,u=3*s,d=15*s,p=74*s,f=30*s,m=document.createElement("canvas");m.width=o,m.height=l,m.style.cssText="width:80px;height:48px";var g=m.getContext("2d");return g.font="bold "+9*s+"px Helvetica,Arial,sans-serif",g.textBaseline="top",g.fillStyle=i,g.fillRect(0,0,o,l),g.fillStyle=t,g.fillText(e,h,c),g.fillRect(u,d,p,f),g.fillStyle=i,g.globalAlpha=.9,g.fillRect(u,d,p,f),{dom:m,update:function(l,v){n=Math.min(n,l),r=Math.max(r,l),g.fillStyle=i,g.globalAlpha=1,g.fillRect(0,0,o,d),g.fillStyle=t,g.fillText(a(l)+" "+e+" ("+a(n)+"-"+a(r)+")",h,c),g.drawImage(m,u+s,d,p-s,f,u,d,p-s,f),g.fillRect(u+p-s,d,s,f),g.fillStyle=i,g.globalAlpha=.9,g.fillRect(u+p-s,d,s,a((1-l/v)*f))}}};var d1e=Q_,f1e=class extends or{constructor(e){super(e,{id:"StatsPlugin"}),this.init()}init(){var e;let t=new d1e;t.setMode(0);let i=document.createElement("div");i.classList.add("statsOutput"),i.appendChild(t.domElement),null==(e=this.viewer.widgetContainer)||e.append(i),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}},eT=class extends xt{constructor(e,t,i,n=4e3,r=32,a=15,s=new D,o=new D(0,.7,.5)){super();let l={topColor:{value:e},skylineColor:{value:t},bottomColor:{value:i},offset:{value:400},exponent:{value:.9},skyCenter:{value:s||new D},sunDirection:{value:o.normalize()}};this.geometry=new Ua(n,r,a),this.material=new cn({uniforms:l,vertexShader:eT.vertexShader,fragmentShader:eT.fragmentShader,side:Ji}),this.name=eT.NAME,this.matrixAutoUpdate=!1,this.layers.disable(12)}},rl=eT;rl.NAME="SKYBOX",rl.MIN_SKY_RADIUS=4e3,rl.MAX_SKY_RADIUS=2e4,rl.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 }",rl.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 d8=class extends or{constructor(e,t){let i=(null==t?void 0:t.id)||d8.DEFAULT_ID;super(e,{id:i}),null!=t&&t.color?this.setSkyboxByColor(t.color):this.setSkyboxByGradientColors(),e.addEventListener("ModelLoaded",(()=>{let t=e.getBBox(),i=this.viewer.cameraCfg;if(t){if(t=t.clone(),i&&i.eye&&i.look){let e=i&&St.arrayToVector3(i.eye),n=i&&St.arrayToVector3(i.look),r=new Nt;r.setFromPoints([e,n]),t.union(r)}this.updateGradientColorSkybox(t)}}))}setSkyboxByColor(e=[.92,.95,.96]){let t=this.viewer;!t||!t.scene||(this.gradientColorSkybox&&(this.gradientColorSkybox.visible=!1),t.scene.background=this.rgb2Color(e),t.enableRender())}setSkyboxByGradientColors(e=[.52,.71,.96],t=[1,1,1],i=[.6,.6,.6]){var n;this.gradientColorSkybox&&(this.gradientColorSkybox.removeFromParent(),this.gradientColorSkybox=void 0);let r=this.rgb2Color(e),a=this.rgb2Color(t),s=this.rgb2Color(i);this.gradientColorSkybox=new rl(r,a,s),null==(n=this.viewer.scene)||n.add(this.gradientColorSkybox),this.viewer.enableRender()}setSkyboxByCubeTexture(e){let t=this.viewer;if(!t||!t.scene)return;this.gradientColorSkybox&&(this.gradientColorSkybox.visible=!1);let i=new Db;t.scene.background=i.load(e),t.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<rl.MIN_SKY_RADIUS?t=rl.MIN_SKY_RADIUS:t>rl.MAX_SKY_RADIUS&&(t=rl.MAX_SKY_RADIUS),this.gradientColorSkybox.geometry=new Ua(t,32,15),this.viewer.enableRender()}destroy(){var e;super.destroy(),null==(e=this.gradientColorSkybox)||e.removeFromParent(),this.gradientColorSkybox=void 0,this.viewer.scene&&(this.viewer.scene.background=null)}rgb2Color(e){let t=e[0]||0,i=e[1]||0,n=e[2]||0,r=new ct;return r.setRGB(t,i,n),r}},h8=d8;function Q0t(e,t,i,n,r){let a=document.createElement("span");return a.style.font="1px serif",a.style.fontFamily=e,a.style.fontSize=`${t}px`,a.style.fontStyle=i,a.style.fontVariant=n,a.style.fontWeight=r,a.style.font}h8.DEFAULT_ID="SkyboxPlugin";var evt=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}),Z2=class extends Gr{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 D,t=new xe,i=new D,n=new D,r=new xe;return(a,s,o)=>{var l,h;if(r.set(this.width,this.height),r.x&&r.y){a.getWorldPosition(i),o.getWorldPosition(e);let c=i.distanceTo(e);if(o.isPerspectiveCamera&&(c*=2*Math.tan(Rn.degToRad(o.fov)/2)),(o.isPerspectiveCamera||o.isOrthographicCamera)&&(c/=o.zoom),c){a.getWorldScale(n);let e=null!=(h=null==(l=s.capabilities)?void 0:l.maxTextureSize)?h:1/0;return s.getDrawingBufferSize(t),Math.min(Math.max(n.x/c*(t.x/r.x),n.y/c*(t.y/r.y)),e/r.x,e/r.y)}}return 0}},this.cfg=Tr(Tr({},evt),e)}get lines(){let{text:e}=this.cfg;return e?e.split("\n"):[]}get font(){let{fontFamily:e,fontSize:t,fontStyle:i,fontVariant:n,fontWeight:r}=this.cfg;return Q0t(e,t,i,n,r)}getContentWidth(){let{font:e,lines:t}=this,i=document.createElement("canvas").getContext("2d");return i.font=e,Math.max(...t.map((e=>i.measureText(e).width)))}initDraw(){let{lineGap:e,padding:t,strokeWidth:i}=this.cfg;t*=this.cfg.fontSize,e*=this.cfg.fontSize,i*=this.cfg.fontSize;let n=this.lines.length,r=this.cfg.fontSize+e,a=t+i/2,s=(n?this.getContentWidth():0)+2*a,o=(n?this.cfg.fontSize+r*(n-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:i,color:n,strokeColor:r,strokeWidth:a}=this.cfg;e.fillStyle="#"+i.toString(16),e.fillRect(0,0,e.canvas.width,e.canvas.height),Object.assign(e,{fillStyle:n,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 Rn.ceilPowerOfTwo(this.width*this.pixelRatio)}getDrawingBufferHeight(){return Rn.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(),i=this.getDrawingBufferHeight();this.pixelRatio=e;let n=this.getDrawingBufferWidth(),r=this.getDrawingBufferHeight();(n!==t||r!==i)&&(this.needsRedraw=!0)}}setOptimalPixelRatio(e,t,i){let n=this.computeOptimalPixelRatio();this.setPixelRatio(n(e,t,i))}updateConfig(e){this.cfg=Tr(Tr({},this.cfg),e),this.needsRedraw=!0}};function f8(e,t,i){let n=new ct(e),r=new ct(t);return n.lerp(r,i).getHex()}var Dr=(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))(Dr||{}),ah=new D(1,0,0),_a=new D(0,1,0),Rs=new D(0,0,1),p1e={right:{text:"\u53f3",name:"RightFace",position:new D(50,0,0),rotation:{axis:_a,rad:Dr.Rotate90}},left:{text:"\u5de6",name:"LeftFace",position:new D(-50,0,0),rotation:{axis:_a,rad:Dr.Rotate270}},top:{text:"\u4e0a",name:"TopFace",position:new D(0,50,0),rotation:{axis:ah,rad:Dr.Rotate270}},bottom:{text:"\u4e0b",name:"BottomFace",position:new D(0,-50,0),rotation:{axis:ah,rad:Dr.Rotate90}},front:{text:"\u524d",name:"FrontFace",position:new D(0,0,50),rotation:{axis:_a,rad:0}},back:{text:"\u540e",name:"BackFace",position:new D(0,0,-50),rotation:{axis:_a,rad:Dr.Rotate180}}},K2=class extends on{constructor(e){super(),this.name="ViewCube",this.AXIS_LENGTH=130,this.AXIS_COLOR_X=16711680,this.AXIS_COLOR_Y=65280,this.AXIS_COLOR_Z=255,this.FACE_BACKGROUND_COLOR=16777215,this.FACE_HOVER_BACKGROUND_COLOR=8618481,this.EDGE_COLOUR=13290452,this.EDGE_OPACITY=.1,this.EDGE_SIZE=new xe(70,12),this.CORNER_WIDTH=12,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=new on,t=new D(-50,-50,-50),i=new D(1,0,0),n=new D(0,1,0),r=new D(0,0,1),a=this.AXIS_LENGTH/15,s=this.AXIS_LENGTH/20,o=new Sc(i,t,this.AXIS_LENGTH,this.AXIS_COLOR_X,a,s),l=new Sc(n,t,this.AXIS_LENGTH,this.AXIS_COLOR_Y,a,s),h=new Sc(r,t,this.AXIS_LENGTH,this.AXIS_COLOR_Z,a,s);return e.add(o,l,h),e}createViewCubeFaces(){let e=new on,t=[],i=new ln({color:this.FACE_BACKGROUND_COLOR,opacity:0,transparent:!0});Object.keys(p1e).forEach((e=>{let n=p1e[e],r=new Z2({text:n.text,fontSize:100,color:"#cccccc",backgroundColor:this.FACE_BACKGROUND_COLOR,padding:.8,fontWeight:"bold"});r.redrew();let a=new ln({map:r,opacity:1,transparent:!0});t.push(a);let s=this.createViewCubeFace(n.name,i,n.position,n.rotation);s.layers.enableAll(),s.userData={textTexture:r,tick:0,translateTick:0},this.faces.push(s)})),e.add(...this.faces);let n=new pa(76,76,76),r=new xt(n,t);this.innerViewCubeMesh=r,e.add(r);let a=new Au(new pa(100,100,100)),s=new ln({color:this.lineColor}),o=new qr(a,s);return e.add(o),e.position.set(0,0,0),e}createViewCubeFace(e,t,i,n){let r=new ui(76,76),a=new xt(r,t);return a.name=e,a.rotateOnAxis(n.axis,n.rad),a.position.copy(i),a}createViewCubeEdges(){let e=new on,t=this.createEdge("TopFrontEdge",new D(0,51,51),[{axis:Rs,rad:Dr.Rotate180}]),i=this.createEdge("TopRightEdge",new D(51,51,0),[{axis:ah,rad:Dr.Rotate180},{axis:_a,rad:Dr.Rotate90},{axis:Rs,rad:0}]),n=this.createEdge("TopBackEdge",new D(0,51,-51),[{axis:Rs,rad:Dr.Rotate180},{axis:_a,rad:Dr.Rotate180}]),r=this.createEdge("TopLeftEdge",new D(-51,51,0),[{axis:ah,rad:Dr.Rotate90},{axis:_a,rad:Dr.Rotate180},{axis:Rs,rad:Dr.Rotate90}]),a=this.createEdge("BottomFrontEdge",new D(0,-51,51),[{axis:Rs,rad:0}]),s=this.createEdge("BottomRightEdge",new D(51,-51,0),[{axis:ah,rad:Dr.Rotate90},{axis:_a,rad:0},{axis:Rs,rad:Dr.Rotate90}]),o=this.createEdge("BottomBackEdge",new D(0,-51,-51),[{axis:Rs,rad:0},{axis:_a,rad:Dr.Rotate180}]),l=this.createEdge("BottomLeftEdge",new D(-51,-51,0),[{axis:ah,rad:Dr.Rotate90},{axis:_a,rad:Dr.Rotate270},{axis:Rs,rad:Dr.Rotate90}]),h=this.createEdge("FrontRightEdge",new D(51,0,51),[{axis:Rs,rad:Dr.Rotate90}]),c=this.createEdge("BackRightEdge",new D(51,0,-51),[{axis:Rs,rad:Dr.Rotate90},{axis:_a,rad:Dr.Rotate180}]),u=this.createEdge("BackLeftEdge",new D(-51,0,-51),[{axis:Rs,rad:Dr.Rotate270},{axis:_a,rad:Dr.Rotate180}]),d=this.createEdge("FrontLeftEdge",new D(-51,0,51),[{axis:Rs,rad:Dr.Rotate270}]);return e.add(t),e.add(i),e.add(n),e.add(r),e.add(a),e.add(s),e.add(o),e.add(l),e.add(h),e.add(c),e.add(u),e.add(d),e}createEdge(e,t,i){let n=new on,r=new ui(this.EDGE_SIZE.x,this.EDGE_SIZE.y),a=new ln({color:this.EDGE_COLOUR,opacity:this.EDGE_OPACITY,transparent:!0}),s={tick:0},o=new xt(r,a);o.name=e,o.userData=s,o.position.setY(this.EDGE_SIZE.y/2),o.layers.enableAll();let l=new xt(r,a);return l.name=e,l.userData=s,l.position.setZ(-this.EDGE_SIZE.y/2),l.rotateOnAxis(new D(1,0,0),Math.PI/2),l.layers.enableAll(),n.add(o),n.add(l),n.position.copy(t),i.forEach((e=>{n.rotateOnAxis(e.axis,e.rad)})),n}createViewCubeCorners(){let e=new on,t=this.createCorner("TopFrontLeftCorner",new D(-51,51,51),[{axis:Rs,rad:Dr.Rotate270}]),i=this.createCorner("TopFrontRightCorner",new D(51,51,51),[{axis:Rs,rad:Dr.Rotate180}]),n=this.createCorner("TopBackRightCorner",new D(51,51,-51),[{axis:ah,rad:Dr.Rotate90},{axis:_a,rad:Dr.Rotate180},{axis:Rs,rad:0}]),r=this.createCorner("TopBackLeftCorner",new D(-51,51,-51),[{axis:ah,rad:Dr.Rotate90},{axis:_a,rad:Dr.Rotate180},{axis:Rs,rad:Dr.Rotate90}]),a=this.createCorner("BottomFrontLeftCorner",new D(-51,-51,51),[{axis:Rs,rad:0}]),s=this.createCorner("BottomFrontRightCorner",new D(51,-51,51),[{axis:Rs,rad:Dr.Rotate90}]),o=this.createCorner("BottomBackRightCorner",new D(51,-51,-51),[{axis:ah,rad:0},{axis:_a,rad:Dr.Rotate180},{axis:Rs,rad:0}]),l=this.createCorner("BottomBackLeftCorner",new D(-51,-51,-51),[{axis:ah,rad:0},{axis:_a,rad:Dr.Rotate180},{axis:Rs,rad:Dr.Rotate90}]);return e.add(t),e.add(i),e.add(n),e.add(r),e.add(a),e.add(s),e.add(o),e.add(l),e}createCorner(e,t,i){let n=new on,r=new ui(this.CORNER_WIDTH,this.CORNER_WIDTH),a=new ln({color:this.CORNER_COLOR,opacity:this.CORNER_OPACITY,transparent:!0}),s={tick:0},o=new xt(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 xt(r,a);l.name=e,l.userData=s,l.position.set(this.CORNER_WIDTH/2,0,-this.CORNER_WIDTH/2),l.rotateOnAxis(new D(1,0,0),Math.PI/2),l.layers.enableAll();let h=new xt(r,a);return h.name=e,h.userData=s,h.position.set(0,this.CORNER_WIDTH/2,-this.CORNER_WIDTH/2),h.rotateOnAxis(new D(0,1,0),-Math.PI/2),h.layers.enableAll(),n.add(o),n.add(l),n.add(h),n.position.copy(t),i.forEach((e=>{n.rotateOnAxis(e.axis,e.rad)})),n}getBBox(){let e=new Nt;return e.setFromObject(this),e}getDirectionByViewCubeName(e){let t;switch(e){case"TopFace":t=new D(0,1,0);break;case"BottomFace":t=new D(0,-1,0);break;case"FrontFace":t=new D(0,0,1);break;case"BackFace":t=new D(0,0,-1);break;case"LeftFace":t=new D(-1,0,0);break;case"RightFace":t=new D(1,0,0);break;case"TopFrontEdge":t=new D(0,1,1);break;case"TopRightEdge":t=new D(1,1,0);break;case"TopBackEdge":t=new D(0,1,-1);break;case"TopLeftEdge":t=new D(-1,1,0);break;case"BottomFrontEdge":t=new D(0,-1,1);break;case"BottomRightEdge":t=new D(1,-1,0);break;case"BottomBackEdge":t=new D(0,-1,-1);break;case"BottomLeftEdge":t=new D(-1,-1,0);break;case"FrontLeftEdge":t=new D(-1,0,1);break;case"FrontRightEdge":t=new D(1,0,1);break;case"BackRightEdge":t=new D(1,0,-1);break;case"BackLeftEdge":t=new D(-1,0,-1);break;case"TopFrontLeftCorner":t=new D(-1,1,1);break;case"TopFrontRightCorner":t=new D(1,1,1);break;case"TopBackRightCorner":t=new D(1,1,-1);break;case"TopBackLeftCorner":t=new D(-1,1,-1);break;case"BottomFrontLeftCorner":t=new D(-1,-1,1);break;case"BottomFrontRightCorner":t=new D(1,-1,1);break;case"BottomBackRightCorner":t=new D(1,-1,-1);break;case"BottomBackLeftCorner":t=new D(-1,-1,-1)}return t}update(){this.traverse((e=>{e instanceof xt&&this.updateViewCube(e)}))}updateViewCube(e){if(this.updateMeshTick(e),e.name.indexOf("Face")>-1){let t=e.userData.textTexture;if(t){let i=f8(this.FACE_BACKGROUND_COLOR,this.FACE_HOVER_BACKGROUND_COLOR,e.userData.tick);t.updateConfig({backgroundColor:i}),e.userData.tick>0&&t.redrew()}if(this.innerViewCubeMesh){this.updateMeshTick(e,"translateTick",2);let t=e.position.clone().normalize(),i=Math.max(2*e.userData.translateTick-2,0);t.multiplyScalar(7*i),i>0&&this.innerViewCubeMesh.position.copy(t)}}else if(e.name.indexOf("Edge")>-1){let t=e.material,i=f8(this.EDGE_COLOUR,this.FACE_HOVER_BACKGROUND_COLOR,e.userData.tick);t.color.set(i),t.opacity=e.userData.tick}else if(e.name.indexOf("Corner")>-1){let t=e.material,i=f8(this.CORNER_COLOR,this.FACE_HOVER_BACKGROUND_COLOR,e.userData.tick);t.color.set(i);let n=1+.3*e.userData.tick;e.parent&&e.parent.scale.set(n,n,n)}}updateMeshTick(e,t="tick",i=1){void 0!==e.userData[t]&&(e.name===this.activateMeshName&&e.userData[t]<i?e.userData[t]+=.05:e.name!==this.activateMeshName&&e.userData[t]>0&&(e.userData[t]-=.05),e.userData[t]>0&&e.userData[t]<i&&(this.dirty=!0),e.userData[t]=Math.min(Math.max(e.userData[t],0),i))}},m8=class extends or{constructor(e,t){super(e,{id:(null==t?void 0:t.id)||m8.DEFAULT_ID}),this.width=0,this.height=0,this.raycaster=new na,this.renderEnabled=!1,this.onPointerDown=e=>{var t,i;let n=this.getNdcPointByEvent(e);if(!n)return;null==(t=e.originalEvent)||t.stopPropagation();let r=this.getIntersects(n);if(this.lastCoords=n,!r||0===r.length)return;let a=r[0].object.name,s=null==(i=this.viewCube)?void 0:i.getDirectionByViewCubeName(a);s&&this.updateViewerCamera(s)},this.onPointerMove=e=>{var t;let i=this.getNdcPointByEvent(e);i&&(null==(t=e.originalEvent)||t.stopPropagation(),this.updateActivateMeshName(i),this.lastCoords=i)},this.onPointerleave=e=>{var t,i;null==(t=e.originalEvent)||t.stopPropagation(),this.lastCoords=void 0,null!=(i=this.viewCube)&&i.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,i=new D;t.getWorldDirection(i);let n=t.up;this.updateCameraDirection(i,n),this.renderEnabled=!0,this.lastCoords&&this.updateActivateMeshName(this.lastCoords)},this.cfg=t||{},this.init(),this.animate()}init(){Fn.isBrowser&&!this.cfg.context&&this.initDom(),this.initInputManager(),this.initScene(),this.initRenderer(),this.initCamera(),this.initLights(),this.initViewCube(),this.initEvents()}initDom(){var e;let t;if(this.cfg.containerId&&(t=document.getElementById(this.cfg.containerId)),!t){let i="gemini-viewer-threejs-viewCube";t=document.createElement("div"),t.id=i,null==(e=this.viewer.widgetContainer)||e.appendChild(t),this.cfg.containerId=i}this.width=t.clientWidth,this.height=t.clientHeight,this.container=t}initInputManager(){this.container&&(this.inputManager=new Ko(this.container))}initScene(){let e=new Si;e.matrixAutoUpdate=!1,this.scene=e}initCamera(){if(!this.scene)return;let e=new Nr(-this.width/2,this.width/2,this.height/2,-this.height/2,.1,1e5);e.position.set(300,300,300),e.lookAt(0,0,0),e.zoom=10,e.updateProjectionMatrix(),this.scene.add(e),this.camera=e}initRenderer(){var e;this.renderer=new Ts({antialias:!0,preserveDrawingBuffer:!0}),this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setSize(this.width,this.height),this.renderer.setClearColor(11119017,0),null==(e=this.container)||e.appendChild(this.renderer.domElement)}initLights(){if(!this.scene)return;let e=new qs(16777215,1.5);e.name="sun",this.directionalLight=e,this.scene.add(e),this.scene.add(e.target)}initViewCube(){if(!this.scene)return;let e=new K2(this.cfg);this.viewCube=e,this.scene.add(e),this.zoomToBBox(e.getBBox())}initEvents(){var e,t,i,n;null==(e=this.inputManager)||e.addEventListener("pointerdown",this.onPointerDown),null==(t=this.inputManager)||t.addEventListener("pointermove",this.onPointerMove),null==(i=this.inputManager)||i.addEventListener("pointerleave",this.onPointerleave),null==(n=this.inputManager)||n.addEventListener("click",this.onClick),this.viewer.addEventListener("AfterRender",this.updateCameraAndMeshName)}updateViewerCamera(e){var t,i;if(null==(t=this.viewer)||!t.camera||null==(i=this.viewer)||!i.controls)return;e.normalize();let n=this.viewer.controls instanceof va?this.viewer.getBBox().getCenter(new D):this.viewer.controls.target,r=this.viewer.camera.position.distanceTo(n);this.viewer.flyTo(n.clone().add(e.clone().multiplyScalar(r)),n)}updateActivateMeshName(e){if(!this.viewCube)return;let t=this.getIntersects(e);if(this.viewCube.activateMeshName&&(this.viewCube.activateMeshName=void 0),!t||0===t.length)return;let i=t[0].object;this.viewCube.activateMeshName=i.name}getNdcPointByEvent(e){if(!this.container||!this.camera)return;let t=an.getScreenCoordinateByEvent(e,this.container);return an.screen2Ndc(t,this.camera,this.container)}getIntersects(e){return this.scene&&this.camera&&this.viewCube?(this.camera.updateMatrixWorld(),this.raycaster.layers.set(12),this.raycaster.setFromCamera(e,this.camera),this.raycaster&&this.raycaster.intersectObjects(this.viewCube.children,!0)||[]):void 0}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,i=this.camera.top-this.camera.bottom,n=new D;e.getSize(n);let r=Math.sqrt(Math.pow(n.x,2)+Math.pow(n.y,2)+Math.pow(n.z,2)),a=Math.min(t/r,i/r);this.camera.position.set(n.x/2,n.y/2,n.z/2),this.camera.zoom=a,this.camera.updateProjectionMatrix()}destroy(){var e,t,i,n,r,a,s;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),null==(e=this.container)||e.remove(),this.container=void 0,null==(t=this.scene)||t.clear(),this.scene=void 0,null==(i=this.directionalLight)||i.dispose(),this.directionalLight=void 0,null==(n=this.inputManager)||n.removeEventListener("pointerdown",this.onPointerDown),null==(r=this.inputManager)||r.removeEventListener("pointermove",this.onPointerMove),null==(a=this.inputManager)||a.removeEventListener("pointerleave",this.onPointerleave),null==(s=this.inputManager)||s.removeEventListener("click",this.onClick),this.viewer.removeEventListener("AfterRender",this.updateCameraAndMeshName)}},p8=m8;p8.DEFAULT_ID="ViewCubePlugin";var J2=class extends Hi{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,i){let n=this.transToScreenCoord(e,i),r=this.transToScreenCoord(t,i);return{width:Math.floor(Math.abs(n.x-r.x)),height:Math.floor(Math.abs(n.y-r.y))}}draw(e,t){let i=this.getImageScreenSize(this.max,this.min,t),n=new D;n.addVectors(this.max,this.min).multiplyScalar(.5);let r=this.transToScreenCoord(n,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=i.width,this.height=i.height}drawSelect(){}isPointInPath(){return!1}getBBox(){return new Nt(this.min,this.max)}},tT=class extends Hi{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 D?t.position:new D(t.position.x,t.position.y,t.position.z),this.direction=t.direction?t.direction instanceof D?t.direction:new D(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 xe(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,i){let n=new xe(1,1);this.translate&&n.set(this.translate.x,this.translate.y);let r=t.width*this.scale,a=t.height*this.scale,s=this.getRotation();s?(e.translate(i.x,i.y),e.rotate(s),e.drawImage(t,n.x*r,n.y*a,r,a),e.translate(-i.x,-i.y)):e.drawImage(t,i.x+n.x*r,i.y+n.y*a,r,a),this.width=r*this.tolerance,this.height=a*this.tolerance}draw(e,t){let i=this.position.clone(),n=!1;if(this.radius){let e=new xe(i.x,i.z),r=new xe(t.position.x,t.position.z),a=e.distanceTo(r);a>this.radius&&a<this.displayRadius?i.lerp(t.position,1-this.radius/a):n=!0}let r=this.transToScreenCoord(i,t),a=this.hover&&this.hoverImage?this.hoverImage:this.image;if(e.save(),e.beginPath(),this.radius&&n){let i=this.transToScreenCoord(t.position,t);e.arc(i.x,i.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 i,n;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==(i=this.ctx)?void 0:i.canvas.width,null==(n=this.ctx)?void 0:n.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 xe(e.x,e.z),i=new Nt,n=new xe(1,1);this.translate&&n.set(this.translate.x,this.translate.y);let r=[],a=n.x*this.width,s=n.y*this.height,o=(t,i)=>r.push(new xe(e.x+t,e.z+i));o(a,s),o(a,s+this.height),o(a+this.width,s+this.height),o(a+this.width,s);let l=r.map((i=>{let n=this.getRotation();return n&&i.rotateAround(t,n),new D(i.x,e.y,i.y)}));return i.setFromPoints(l),i}},m1e=class extends Hi{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 i=this.positions.map((e=>{let i=new D(e.x,e.y,e.z);return this.transToScreenCoord(i,t)}));e.save(),e.beginPath(),e.lineWidth=this.lineWidth,e.strokeStyle=An.rgba2Color(this.lineColor),i.forEach(((t,i)=>{0===i?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 D(e.x,e.y,e.z)));return(new Nt).setFromPoints(e)}},g1e=class extends Hi{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,i,n,r,a,s){let o=this.textStyle,l=Math.min(o.borderRadius||0,n/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,i),e.arcTo(t+n,i,t+n,i+r,l),e.arcTo(t+n,i+r,t,i+r,l),e.arcTo(t,i+r,t,i,l),e.arcTo(t,i,t+n,i,l),o.borderWidth&&e.stroke(),o.backgroundColor&&e.fill(),e.closePath(),e.restore()}draw(e,t){let i=this.textStyle,n=new D(this.position.x,this.position.y,this.position.z),r=!1;if(this.radius){let e=new xe(n.x,n.z),i=new xe(t.position.x,t.position.z),a=e.distanceTo(i);a>this.radius&&a<this.displayRadius?n.lerp(t.position,1-this.radius/a):r=!0}let a=this.transToScreenCoord(n,t),s=this.getFont(),o=i.fontSize?i.fontSize:12;e.font=s,e.textAlign="center",e.textBaseline="middle";let l=e.measureText(this.text).width,h=o;i.outlineWidth&&(e.lineWidth=i.outlineWidth,e.strokeStyle=i.outlineColor||"black");let c=new xe(this.offset.x,this.offset.y),u=this.transToScreenCoord(t.position,t);(i.borderWidth||i.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+(c.x-.5)*l,a.y+(c.y-.5)*h,l,h,u,r)),e.save(),e.beginPath(),this.radius&&r&&(e.arc(u.x,u.y,this.radius/this.tolerance,0,2*Math.PI,!0),e.clip()),i.outlineWidth&&e.strokeText(this.text,a.x+c.x*l,a.y+c.y*h),e.fillStyle=i.fontColor||"white",e.fillText(this.text,a.x+c.x*l,a.y+c.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 D(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}},v1e="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=",y1e="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",x1e="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=",b1e="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",svt=(e=>(e.ZoomChanged="ZoomChanged",e.SyncCamera="SyncCamera",e.CameraChanged="CameraChanged",e))(svt||{}),v8=class extends or{constructor(e,t){var i,n,r;super(e,{id:(null==t?void 0:t.id)||v8.DEFAULT_ID}),this.CAMERA_Z_POSITION=100,this.width=0,this.height=0,this.frustumSize=this.width,this.renderEnabled=!1,this.drawableList=new Zo("overviewMap"),this.clock=new ho,this.raf=new $f,this.raycaster=new na,this.translateStart=new xe,this.rotateStart=new xe,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,i=this.cameraDirDrawable;if(!(t&&i&&this.viewerContainer&&this.camera&&this.controls))return;let n=this.getDrawableByEvent(e),r=an.getScreenCoordinateByEvent(e,this.viewerContainer),a=this.lockCameraInViewCenter?this.camera.position:an.world2Screen(t.position,this.camera,this.viewerContainer);n&&n===i&&(this.isMarkerRotating=!0,this.rotateStart.set(r.x-a.x,r.y-a.y),this.controls.enabled=!1),n&&n===t&&(this.isMarkerTranslating=!0,this.translateStart.set(r.x,r.y),this.controls.enabled=!1)},this.onCameraMove=e=>{var t,i;let n=this.cameraDrawable,r=this.cameraDirDrawable;if(!(n&&r&&this.camera&&this.viewerContainer))return;let a=an.getScreenCoordinateByEvent(e,this.viewerContainer),s=this.lockCameraInViewCenter?this.camera.position:an.world2Screen(n.position,this.camera,this.viewerContainer);if(this.isMarkerRotating){let e=new xe(a.x-s.x,a.y-s.y),i=(new xe).subVectors(e,this.rotateStart);if(Math.abs(i.x)>this.tolerance||Math.abs(i.y)>this.tolerance){let i=e.angle()-this.rotateStart.angle();i=(i+2*Math.PI)%(2*Math.PI),null==(t=r.direction)||t.applyAxisAngle(this.camera.up,-i),this.rotateStart.copy(e)}}if(this.isMarkerTranslating){let e=new xe(a.x,a.y),t=(new xe).subVectors(e,this.translateStart);if(Math.abs(t.x)>this.tolerance||Math.abs(t.y)>this.tolerance){let t=an.screen2World(this.translateStart,this.camera,this.viewerContainer),r=an.screen2World(e,this.camera,this.viewerContainer),a=(new D).subVectors(r,t);a.setY(0),this.lockCameraInViewCenter?null==(i=this.controls)||i.truck(a.x,a.z):n.position.add(a),this.translateStart.copy(e)}}if(this.isMarkerRotating||this.isMarkerTranslating){let e=this.lockCameraInViewCenter?this.camera.position.clone():n.position.clone(),t=r.direction.clone(),i=this.transformMatrix.clone().invert();e.applyMatrix4(i),t.applyMatrix4(i),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 i=this.cameraDrawable,n=this.cameraDirDrawable;if(this.animationId&&window.cancelAnimationFrame(this.animationId),!(i&&n&&this.camera&&this.viewerContainer))return;let r=an.getScreenCoordinateByEvent(e,this.viewerContainer),a=an.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(i.position.y),i.position.copy(a));let s=n.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 i,n=new xe(e.x,e.y);return this.boundaries.forEach((e=>{e.polygon.length<3||Qt.isPointInPolygon(n,e.polygon)&&(i={id:e.id,name:e.name})})),i},this.animate=()=>{var e,t,i;this.requestAnimationFrameHandle=requestAnimationFrame(this.animate);let n=this.clock.getDelta(),r=null==(e=this.controls)?void 0:e.update(n);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),!Fn.isBrowser){let e=null==(i=this.renderer)?void 0:i.getContext();e&&e.endFrameEXP&&(e.flush(),e.endFrameEXP())}this.enableLookToAllMarkers&&this.lookToAllMarkers(),this.dispatchEvent("AfterRender")}}},this.cfg=t||{},this.transformMatrix=new et,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==(i=this.cfg.enabled)||i,this.lockCameraInViewCenter=!!this.cfg.lockCameraInViewCenter,this.radius=this.cfg.radius,this.size=this.cfg.size,this.minZoomFactor=null!=(n=this.cfg.minZoomFactor)?n:.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(){Fn.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-threejs-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 Ko(this.viewerContainer))}initScene(){let e=new Si;e.background=null,e.matrixAutoUpdate=!1,e.matrixWorldAutoUpdate=!1,this.scene=e}initCamera(){if(!this.scene)return;let e=new Nr(-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,i={context:t,antialias:!0,preserveDrawingBuffer:!0,alpha:!1,stencil:!1};!Fn.isBrowser&&t&&Object.assign(i,{context:t,canvas:Fn.creatReactNativeCanvas(t)}),t&&(this.width=t.drawingBufferWidth,this.height=t.drawingBufferHeight),this.renderer=new Ts(i),this.renderer.setClearColor(11119017,1),this.renderer.setClearAlpha(0),Fn.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 Un(this),this.overlayRender.addDrawableList(this.drawableList)}initControls(){let e=this.camera;if(!this.inputManager||!e)return;let t=new va(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:yt.TRUCK,middle:yt.TRUCK,wheel:yt.ZOOM,right:yt.TRUCK},t.touches={one:yt.TOUCH_TRUCK,two:yt.TOUCH_ZOOM_TRUCK,three:yt.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,i,n,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==(i=this.inputManager)||i.addEventListener("pointerup",this.handlePointerUp),null==(n=this.inputManager)||n.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 i=this.raycaster;if(!i)return;let n=an.getScreenCoordinateByEvent(e,this.viewerContainer),r=an.screen2Ndc(n,this.camera,this.viewerContainer);i.setFromCamera(r,this.camera);let a=i.intersectObject(this.groundPlane);if(0===a.length||!a[0].point)return;let s=null==(t=this.overlayRender)?void 0:t.getDrawablesByPosition(a[0].point,i);return s&&s.length>0?s[0]:void 0}onCameraHover(e){let t=this.cameraDrawable,i=this.cameraDirDrawable;if(!t||!i)return;t.hover=!1,i.hover=!1;let n=this.getDrawableByEvent(e);n&&n===i&&(i.hover=!0),n&&n===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(),i=this.camera.zoom*Number((t/this.radius).toFixed(2));this.controls.zoomTo(i)}getContainerRadius(){if(!this.viewerContainer)return;let e=this.viewerContainer,{width:t,height:i}=e.getBoundingClientRect();return this.size&&(t=this.size.width,i=this.size.height),this.screenDistance2WorldDistance(Math.min(t,i)/2)}screenDistance2WorldDistance(e){let t=this.camera,i=this.viewerContainer,n=an.screen2World(new xe(e,0),t,i),r=an.screen2World(new xe(0,0),t,i);return Math.abs(new xe(n.x,n.z).distanceTo(new xe(r.x,r.z)))}initGroundPlane(e){var t;St.expandBoxByScale(e,3);let i=e.min,n=e.max,r=n.x-i.x+n.y-i.y+n.z-i.z;St.expandBoxByMinSize(e,r);let a=[],s=(e,t,i)=>{a.push(new D(e,t,i))},o=e.getSize(new D),l=e.getCenter(new D);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 Dt;e.setFromPoints(a),e.setIndex([0,3,2,0,2,1]),e.computeVertexNormals();let i=new ln({color:"#888",transparent:!0,opacity:0,side:Sr});this.groundPlane=new xt(e,i),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(),Hn.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,i)=>{t.onload=()=>{e(t)},t.onerror=e=>{i(e)}}))}updateOverviewMap(e){return ft(this,null,(function*(){let t=new D,i=new D;t.set(e.min.x,e.min.y,e.min.z),i.set(e.max.x,e.max.y,e.max.z),t.applyMatrix4(this.transformMatrix),i.applyMatrix4(this.transformMatrix);let n=yield this.getImageElementFromUrl(e.image),r=new D(Math.min(t.x,i.x),0,Math.min(t.z,i.z)),a=new D(Math.max(t.x,i.x),0,Math.max(t.z,i.z)),s=new Nt(r,a);this.initGroundPlane(s.clone());let o=this.overviewMapDrawable;o?(o.image=n,o.radius=this.radius,o.max.copy(i),o.min.copy(t)):(this.zoomToBBox(s),this.updateZoomFromRadius(),this.initMaxAndMinZoom(),this.addMarker(new J2("overviewMap",{image:n,min:t,max:i,radius:this.radius}))),this.imgBBox=s,this.enableRender()}))}createCameraMarkers(e,t){return ft(this,null,(function*(){var i,n;if(!this.camera||!this.viewerContainer)return;let r=this.cameraDrawable,a=this.cameraDirDrawable;if(r)r.position.copy(e),null==(i=r.direction)||i.copy(t);else{let i=yield this.getImageElementFromUrl(y1e),n=yield this.getImageElementFromUrl(b1e);this.addMarker(new tT("cameraDirDrawable",{image:i,hoverImage:n,translate:new xe(-1,-.5),scale:.25,position:e,direction:t,enabledHover:this.enabled}))}if(a)a.position.copy(e),null==(n=a.direction)||n.copy(t);else{let i=yield this.getImageElementFromUrl(v1e),n=yield this.getImageElementFromUrl(x1e);this.addMarker(new tT("cameraDrawable",{image:i,hoverImage:n,translate:new xe(-.5,-.5),scale:.25,position:e,direction:t,enabledHover:this.enabled,renderOrder:-996}))}this.enableRender()}))}initCameraMarkers(e,t){return ft(this,null,(function*(){var i;let n=new D(e.x,e.y,e.z),r=new D(t.x,t.y,t.z);if(n.applyMatrix4(this.transformMatrix),r.applyMatrix4(this.transformMatrix),this.lockCameraInViewCenter){let e=this.camera;yield this.createCameraMarkers(e.position,r),n.setY(e.position.y),null==(i=this.controls)||i.setLookAt(n.x,n.y,n.z,n.x,0,n.z)}else yield this.createCameraMarkers(n,r)}))}updateOverviewMapCameraAnimation(){var e,t;let i=this.animationParam;if(!i)return void(this.animationId&&cancelAnimationFrame(this.animationId));let{startTime:n,positionStart:r,positionEnd:a,directionStart:s,directionEnd:o}=i,l=Math.min(1,(Date.now()-n)/500),h=r.lerp(a,l),c=null==s?void 0:s.lerp(o,l),u=this.cameraDrawable,d=this.cameraDirDrawable;if(c&&(null==(e=null==d?void 0:d.direction)||e.copy(c)),this.lockCameraInViewCenter?null==(t=this.controls)||t.setLookAt(h.x,h.y,h.z,h.x,0,h.z):(null==u||u.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 i;let n=this.cameraDrawable,r=this.cameraDirDrawable;if(!(this.camera&&this.viewerContainer&&n&&this.isUpdateWhenPawnMove))return;this.animationId&&cancelAnimationFrame(this.animationId);let a,s=new D(e.x,e.y,e.z),o=new D(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=n.position.clone();let l=Date.now(),h=null==(i=null==r?void 0:r.direction)?void 0:i.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,i=e.max.x-e.min.x,n=e.max.z-e.min.z,r=t.right-t.left,a=t.top-t.bottom,s=Math.min(r/i,a/n);this.controls.zoomTo(s);let o=new D;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 i=t.zoom,n=Math.min(i+e*this.initialZoom,this.controls.maxZoom);this.controls.zoomTo(n)}dollyOut(e=.2){let t=this.camera;if(!t||!this.controls||!this.initialZoom)return;let i=t.zoom,n=Math.max(i-e*this.initialZoom,this.controls.minZoom);this.controls.zoomTo(n)}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 i=e.points.map((e=>new xe(e.x,e.y)));null==(t=this.boundaries)||t.set(e.id,{id:e.id,name:e.name,polygon:i})}))}screenShot(){return ft(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 se.error(e)}}))}getViewConfig(){return this.cfg}is3d(){return!0}getPixelSizeInWorldCoord(){let e=this.camera,{clientWidth:t,clientHeight:i}=this.viewerContainer;return Math.max(e.right-e.left,e.top-e.bottom)/e.zoom/Math.max(t,i)}lookToAllMarkers(){var e,t;let i=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;i.union(t.getBBox())})),i.min.setY(0),i.max.setY(0);let n=i.min.distanceTo(i.max);i.expandByVector(new D(.01*n,0,.01*n)),Zt.areVector3sEqual(null==(e=this.allMarkersBBox)?void 0:e.min,i.min)&&Zt.areVector3sEqual(null==(t=this.allMarkersBBox)?void 0:t.max,i.max)?this.enableLookToAllMarkers=!1:(this.allMarkersBBox=i,this.zoomToBBox(i))}resize(e,t){let i=this.camera;if(i&&t>0){let n=e/t;i.left=-this.frustumSize/2,i.right=this.frustumSize/2,i.top=this.frustumSize/n/2,i.bottom=-this.frustumSize/n/2,i.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,i;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==(i=this.scene)||i.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()}},g8=v8;g8.DEFAULT_ID="OverviewMapPlugin";export{RA as ANGLE_THRESHOLD_FOR_EDGE,XIt as AXIS_SECTION_PLANE_CONTROL_ID,jIt as AXIS_SECTION_PLANE_ID,X5 as AnnotationTable,n5 as ArrowMarkup,eV as AxisGizmoPlugin,h2 as AxisPlaneSection,Lve as AxisType,oy as BYBLOCK,ay as BYLAYER,OP as BaseDxfCompareHelper,Lr as BaseMeasureDrawable,th as BaseMeasurement,cp as BaseSection,Wu as BaseTable,up as BaseVRMesh,tp as BaseViewer,kve as BimViewer,xye as BimViewerDatGuiPlugin,uV as BimViewerToolbarPlugin,Df as BinaryReader,sg as BitView,Vve as BottomBarPlugin,ep as BoxSelectHelper,Mf as CSS2DObjectUtils,va as CameraControlsEx,TA as CancelablePromise,Un as CanvasRender,r5 as CircleMarkup,Cc as CloudLineMarkup,i5 as CloudRectMarkup,An as ColorUtils,St as CommonUtils,jm as CompareDrawable,Zve as ContextMenuPlugin,iP as ControlsHelper,an as CoordinateUtils,qve as DEFAULT_BIMVIEWER_TOOLBAR_CONFIG,lde as DEFAULT_BIM_VIEWER_CONFIG,Wve as DEFAULT_DXFVIEWER_TOOLBAR_CONFIG,zve as DEFAULT_MARKUP_TOOLBAR_CONFIG,Fn as DeviceUtils,s5 as DotMarkup,Hi as Drawable,Zo as DrawableList,C5 as DxfChangeType,ls as DxfCompare,sve as DxfCompareHelper,i0e as DxfCompareMarkupManager,yy as DxfDataTable,gn as DxfLoader,Zm as DxfParser,jfe as DxfRenderOrder,Ic as DxfUtils,ip as DxfViewer,lV as DxfViewerToolbarPlugin,WIt as ENTER_KEY,qIt as ESC_KEY,AA as EdgeUtils,a5 as EllipseMarkup,Ss as Event,W_ as ExplodePlugin,Af as ExportUtils,sd as FontDataTable,ud as FontManager,OA as FpsUtils,vde as GROUND_PLANE_RENDER_ORDER,T2 as GROUP_CONFIG,EP as GenerateMeshBvhWorker,Qt as GeometryUtils,j_ as GroundGrassPlugin,X_ as GroundGridPlugin,CV as GroundShadowPlugin,_ye as HotpointPlugin,jv as ICON_FONT_CLASS,tT as ImageDrawable,ns as IndexedDbManager,Ko as InputManager,S0e as InstantiateHelper,zIt as KEYDOWN_EVENT,GIt as KEYUP_EVENT,Oct as Keys,RV as LayerManagerPlugin,o5 as LeaderLineMarkup,fr as Line,m1e as LineDrawable,SC as LinePatternShaders,ja as LoadingHelper,c1e as LocalDxfUploader,u1e as LocalImageUploader,N2 as LocalModelUploader,Gve as MARKUP_GROUP_CONFIG,gH as MOUSEDOWN_EVENT,Rf as MOUSEMOVE_EVENT,mH as MOUSEUP_EVENT,mE as MarkupManager,w2 as MarkupToolbar,za as MarkupType,es as MaterialUtils,Zt as MathUtils,lg as MeasurementPlugin,Yl as MeasurementType,E2 as MenuTypeEnums,Rr as MergeUtils,xt as Mesh,Qf as MeshBvhHelper,CP as MobileTouchHelperDrawable,c8 as NavCubePlugin,Xm as NestCompareTypes,MP as OSnapHelper,Afe as OSnapMarkerType,S4 as OSnapType,Q0e as ObjectPixelSizeHelper,Hn as ObjectUtils,d2 as ObjectsBoxSection,lve as Offset,J2 as OverviewMapDrawable,g8 as OverviewMapPlugin,svt as OverviewMapPluginEvent,sh as PdfLoader,o8 as PdfLoaderPlugin,RP as PickMarkupHelper,f2 as PickPlaneSection,or as Plugin,ii as Points,Um as PolygonUtils,l5 as PolylineMarkup,Yf as ProgressBar,$f as RafHelper,c5 as RectMarkup,ZIt as SECTION_BOX_ID,$It as SECTION_PLANE_CONTROL_ID,YIt as SECTION_PLANE_ID,vH as SECTION_PLANE_NAME,J0e as SHP,bP as SHPLoader,yP as SHPParser,SLt as SNAP_ICON_SIZE,Dct as STATE,ede as SVGObject,Rfe as SVGObjectUtils,tde as SVGRenderer,Os as SceneUtils,yde as ScreenshotMode,dp as ScreenshotPlugin,dg as SectionPlugin,Xv as SectionType,Hu as SectionUtils,$n as ShaderChunk,xP as ShpThree,Fve as SimplifiedBimViewer,Mfe as SimplifyUtils,h8 as SkyboxPlugin,Ms as SnapDrawable,f1e as StatsPlugin,g1e as TextDrawable,Dl as TextMarkup,Ac as TextureUtils,hp as Toolbar,iV as ToolbarMenu,_2 as ToolbarMenuId,j5 as Units,eC as VRControls,v2 as VRCube,y2 as VRCube24Faces,x2 as VRSphere,Hve as VRViewer,p8 as ViewCubePlugin,cE as Viewer3DUtils,ki as ViewerEvent,i0t as ViewerMode,Oy as ViewerName,Y5 as ViewpointTable,t5 as Views,c2 as WebCam,u5 as XMarkup,ky as ZoomToRectHelper,W5 as bspline,ume as checkIsNewVersion,Yde as cn,$ve as contextMenuItems,ame as createHatchPatternShaderMaterial,Uut as decodeDxfTextCharacterCodes,Vut as decodeDxfTextMbcsCharacterCodes,Hut as decodeDxfTextUnicodeCodePoints,Xde as en,DLt as getLengthValueByUnit,lE as getUnitStr,qut as getVersionFromLocalStorage,Uu as layerForHitableObjects,ei as layerForSelectableObjects,ps as layerForSnapableObjects,se as log,si as matrixAutoUpdate,MC as parseDxfMTextContent,RC as parseDxfTextContent,G5 as round10,VIt as sceneAutoUpdate,MA as setIcon,hde as setLogLevel,Wut as setVersionToLocalStorage,Bu as showPrecisionValue,Cfe as unitConversionByMeter,Rct as unitLabel,lme as unitScaleConversion,ome as unitScaleToMeter};