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;i1&&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{"use strict";function i(e,t){for(var i=0;i="0"&&r<="9"&&++i}return ithis._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{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{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+""},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{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{"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(c0;)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);g0&&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{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{"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;a0;)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{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;ns(i)?1:-1}}(e)),o=r(c),h=0;h{"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;gb-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{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{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<>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<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<>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;ur;)(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{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{"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{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{"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 co||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;o0?(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;or)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<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{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("(?b)","g");return"b"!==e.exec("b").groups.a||"bc"!=="b".replace(e,"$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{"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{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=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,"$")}))||!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{"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=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{"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,""")+'"'),h+">"+l+""}})),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{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{"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{"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{"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);h92||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});g1&&!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=55296&&r<=56319&&i=l&&rh((n-f)/_))throw o(s);for(f+=(b-l)*_,l=b,i=0;in)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{"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;r0?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;rt.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;r1?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;x65535)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;n1&&"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=P(256,5-t))return null}else if(s>255)return null;for(o=O(i),n=0;n1?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=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=0;--i){var r=this.tryEntries[i];if(r.tryLoc<=this.prev&&n.call(r,"finallyLoc")&&this.prev=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=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{"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=n?(r=u,(l+=1){"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{"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{"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=n?(r=u,(l+=1){"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{"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){"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{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{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{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;ne.length)&&(t=e.length);for(var i=0,n=Array(t);id.__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=0e||36this.length&&(i=this.length);for(var n=32767&e,r=e>>>15,a=0,s=t,o=0;o>>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>>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>>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>>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>>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>>=12;var u=h-12,p=12<=h?0:o<<20+h,f=20+h;for(0>>30-u,p=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=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<>=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;rd.__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(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(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>>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>>30),l.__setDigit(2,s>>>28),l.__trim()}},{key:"DataViewSetBigInt64",value:function(e,t,i){var n=3>>2,2t)r=-t-1;else{if(0===i)return-1;i--,n=e.__digit(i),r=29}var a=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<>>32-c,a=s<>>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=11073741824/o)return null;var h=new d(0|((o*s+l>>>d.__kBitsPerCharTableShift)+29)/30,!1),c=10>t?t:10,u=10>>0>>0>>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>>0>>l-(a-=30))}if(0!==r){if(n>=e.length)throw new Error("implementation bug");e.__setDigit(n++,r)}for(;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>>g,u=30-g;u>=r;)l[h--]=d.__kConversionChars[c&a],c>>>=r,u-=r}var 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.lengthn?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(1a?d.__absoluteGreater(n):st)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(lh)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<>>32-v,c=u<>>=0)>(f>>>=0))return d.__absoluteGreater(i);if(s>>2,c=c<<30|u>>>2,u<<=30):f=0;var x=e.__unsignedDigit(y);if(x>f)return d.__absoluteGreater(i);if(xi&&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?0t;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?et:3===i?e>=t:void 0}},{key:"__absoluteAdd",value:function(e,t,i){if(e.length>>30,a.__setDigit(o,1073741823&r);for(;o>>30,a.__setDigit(o,1073741823&l)}return o>>30,r.__setDigit(s,1073741823&n);for(;s>>30,r.__setDigit(s,1073741823&o)}return r.__trim()}},{key:"__absoluteAddOne",value:function(e,t){var i=2>>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>>30,r.__setDigit(s,1073741823&i);if(0!==a)throw new Error("implementation bug");for(var o=n;on?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>>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>>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>>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>>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>>30-t;return 0i)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>>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,m=i-a-1,g=0;g>>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(1d.__kMaxLengthBits?-1:t}},{key:"__toPrimitive",value:function(e){var t=1>>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>>30,s.__setDigit(o,1073741823&n);for(;o>>m)-h,u&=g-1}return s.__setDigit(l,u),s.__trim()}},{key:"__digitPow",value:function(e,t){for(var i=1;0>>=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<>>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-1}function Ct(e,t,i){for(var n=-1,r=null==e?0:e.length;++n-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({"&":"&","<":"<",">":">",'"':""","'":"'"});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",""":'"',"'":"'"}),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=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-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;++r0&&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&&nt}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=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-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&&++ar?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>>1,s=e[a];null!==s&&!ro(s)&&(i?s<=t:s=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=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&&e1?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-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;++a1&&y.reverse(),d&&cl))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-1&&e%1==0&&e1?"& ":"")+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;++n1?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=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);++n1),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));aa?0:a+n),(r=r===i||r>a?a:co(r))<0&&(r+=a),r=n>r?0:uo(r);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=-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&&nt){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);++rh)return[];var i=u,n=mi(e,u);t=ra(t),e-=u;for(var r=Wt(n,t);++i=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=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);p0;)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 et?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=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=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=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 et?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=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;la!=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;la!=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(uh==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);uh==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(;u0!=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;sn[0]&&(n=o),o[1]a[1]&&(a=o)}var l=[t,i,n,a],h=l.slice();for(s=0;s=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;cs||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=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;l0!=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)},pointsSameX:function(t,i){return Math.abs(t[0]-i[0])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{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{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{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;it?1:e0))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;a0){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.xt.x?1:e.yt.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=0&&l>=0?sh?-1:0:a<0&&l<0?sh?1:0:la?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(as&&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(so&&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(so)return 1;if(ra){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&&yx)return-1}return r>a?1:rh?1:e.idt.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:et?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.x0&&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;t0){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;o0))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;othis.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;tthis.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;tthis.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;t0&&(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;t1&&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;u0?(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;MB)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;C1?t-1:0),n=1;n1?t-1:0),n=1;n1?t-1:0),n=1;n1?t-1:0),n=1;n{!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<>>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<>=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>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):this[this.t-1]|=s<=this.DB&&(a-=this.DB))}8==i&&128&e[0]&&(this.s=-1,a>0&&(this[this.t-1]|=(1<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=0;--i)t[i+s+1]=this[i]>>r|o,o=(this[i]&a)<=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;for(var s=i+1;s>n;n>0&&(t[this.t-i-1]|=(this.s&a)<>=this.DB;if(e.t>=this.DB;n+=this.s}else{for(n+=this.s;i>=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=0;)e[i]=0;for(i=0;i=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.t0?(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<1?a[u-2]>>this.F2:0),f=this.FV/p,g=(1<=0&&(i[i.t++]=1,i.subTo(b,i)),o.ONE.dlShiftTo(u,b),b.subTo(a,a);a.t=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<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<0)for(o>o)>0&&(r=!0,a=d(i));s>=0;)o>(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=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<>=this.DB;if(e.t>=this.DB;n+=this.s}else{for(n+=this.s;i>=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=0;)i[n]=0;for(n=Math.max(t-this.t,0);n0)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>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>n)!=(this.s&this.DM)>>n&&(t[r++]=i|this.s<=0;)n<8?(i=(this[e]&(1<>(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?0!=this.s:0!=(this[t]&1<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<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<=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(r0&&(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;t0},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;r0?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;e0?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&&et.X==e.Xt.Y==e.Yt.X==e.Xt.Y==e.Yi.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.Xa.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.Dxe.X==t.Xe.Y==t.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.Ythis.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=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;t0&&this.ReversePolyPtLinks(e.Pts);for(this.JoinCommonEdges(),t=0,i=this.m_PolyOuts.length;t0&&0!==n.WindDelta)for(var s=0,o=this.m_GhostJoins.length;s=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.Xi.Clipper.TopX(t,e.Top.Y):t.Curr.X0;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.OutIdxt.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.Yt&&(r=e,e=t,t=r),i>n&&(r=i,i=n,n=r),e=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.Xn.Pt.Y?e:i.Pt.Yn.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=o.Top.X&&(h=null)}else{for(;null!==h.Next&&h.Next.X=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=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.Y2147483647?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)t.Top.Y)return n.Y=e.Top.Y,n.X=i.Clipper.TopX(t,e.Top.Y),n.Xe.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=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;tt.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;tr.right&&(r.right=e[t][a].X),e[t][a].Yr.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.Xn.right&&(n.right=e.Pt.X),e.Pt.Yn.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)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)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;a0&&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;eMath.abs(e.Y-t.Y)?e.X>t.X==e.Xe.X==t.Xt.Y==e.Ye.Y==t.Y0&&r&&n.push(e.m_polygon);for(var a=0,s=e.Childs(),o=s.length,l=s[a];a0&&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].Xh.Y||a.m_polygon[o].Y===h.Y&&a.m_polygon[o].X=0&&!i.Clipper.Orientation(this.m_polyNodes.Childs()[this.m_lowest.X].m_polygon))for(var e=0;e2?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;t0;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;h0;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;s0)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;l1?(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;a2&&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{})),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=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;it?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.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;ne.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{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{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),ue===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{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>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>>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>>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;a30)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;ny?h:8*e-7,a=-8&r,o=0,l=0;for(;n>=1}for(;i=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>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>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;v100&&(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;n0&&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;w0){let e=1e3*a.measureText(b).width/n*s;if(Mnew 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>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;r1e3)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>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;ln?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(Fy?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=Fy?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=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>>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>>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>3,d=7&r,p=e.length;i=new Uint32Array(i.buffer);let f=0;for(let n=0;n{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;n0?(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{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;s0){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;r0&&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{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{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=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>2]+n[(3&t)<<4|i>>4]+n[a+1>6:64]+n[a+2>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>>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>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>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{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;a0&&(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>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;e0&&(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=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 iMath.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;tthis.max.x||e.ythis.max.y||e.zthis.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.xthis.max.x||e.max.ythis.max.y||e.max.zthis.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;rthis.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=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=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<>>0}enable(e){this.mask|=1<1){for(let e=0;e1){for(let e=0;e0&&(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;i0&&(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;t0){n.children=[];for(let t=0;t0){n.animations=[];for(let t=0;t0&&(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;i0?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>-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;n0&&(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;n0&&(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;n0){let i=e[t[0]];if(void 0!==i){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=i.length;eDo(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;pi.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;s0?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;s0&&(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 \n\t\t\t\t\t#include \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 \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)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.version0?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=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;e0&&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.length0),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;e2?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;nhm&&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;xv-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;se-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;e2?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 \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 \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;it.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;t0)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":" "} ${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/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);a0&&(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;e0?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;i1&&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;e0&&(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=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 \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;lc||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=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;ln||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;t0&&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>=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>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;r0&&!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;n0&&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;n0){h.__webglFramebuffer[t]=[];for(let i=0;i0){h.__webglFramebuffer=[];for(let t=0;t0&&!1===H(t)){let n=d?o:[o];h.__webglMultisampledFramebuffer=e.createFramebuffer(),h.__webglColorRenderbuffer=[],i.bindFramebuffer(e.FRAMEBUFFER,h.__webglMultisampledFramebuffer);for(let i=0;i0)for(let n=0;n0)for(let i=0;i0&&!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;to+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=0&&(y[n]=null,v[n].disconnect(i))}for(let t=0;t=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;n0&&(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;t0&&(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;e0),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;t0&&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;l0&&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;r0?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;ne.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;i0){let i,n;for(i=1,n=t.length;i0){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=e))break;t[i-1].object.visible=!1,t[i].object.visible=!0}for(this._currentLevel=i-1;io)continue;u.applyMatrix4(this.matrixWorld);let r=e.ray.origin.distanceTo(u);re.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;mo)continue;u.applyMatrix4(this.matrixWorld);let i=e.ray.origin.distanceTo(u);ie.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;e0){let i=e[t[0]];if(void 0!==i){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=i.length;er.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)n;)r-=n;r0?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+2n.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){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;i1&&!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;t0){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;v0&&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.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;e80*i){n=a=e[0],r=s=e[1];for(let t=i;ta&&(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=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=ra?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=ol?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=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.x&&n.x>=h&&a!==n.x&&rv(si.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;t0||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=(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;a2&&e[t-1].equals(e[0])&&e.pop()}function rue(e,t){for(let i=0;iNumber.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=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=0;){let n=i,r=i-1;r<0&&(r=e.length-1);for(let e=0,i=d+2*y;e0)&&d.push(t,n,s),(g!==i-1||o0!=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=n)){o.push(e.times[a]);for(let i=0;ia.tracks[l].times[0]&&(o=a.tracks[l].times[0]);for(let l=0;l=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=r)break e;{let s=t[1];e=r)break t}a=i,i=0}}for(;i>>1;et;)--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;s0){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;s1){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{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{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{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{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;i0: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;i0){let n=new Lu(t);i=new Mm(n),i.setCrossOrigin(this.crossOrigin);for(let t=0,i=e.length;t0){t=new Mm(this.manager),t.setCrossOrigin(this.crossOrigin);for(let t=0,i=e.length;t0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e0&&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=.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=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],l0&&(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=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;tthis.max.x||e.ythis.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.xthis.max.x||e.max.ythis.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;a1)for(let h=0;h.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;aNumber.EPSILON){if(l<0&&(i=t[a],o=-o,s=t[r],l=-l),e.ys.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;m1){let e=!1,i=0;for(let t=0,n=d.length;t0&&!1===e&&(p=u)}for(let m=0,g=d.length;ma)return!1;let o=i.ray.origin.distanceTo(khe);return!(oi.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=1))return}else for(let n=Math.max(0,a.start),r=Math.min(l.count,a.start+a.count)-1;n=1))return}else{let i=this.userData.batches;if(i&&i.length>0&&i[0].boundingSphere)for(let r=0;r=1)return}else for(let n=Math.max(0,a.start),r=Math.min(h.count,a.start+a.count)-1;n=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]=nr?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;si[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;ee-t));for(let r=0;rl&&(l=r),v&&tf&&(f=t);let x=e[y+2],b=e[y+3],_=x-b,w=x+b;_h&&(h=w),v&&xm&&(m=x);let S=e[y+4],M=e[y+5],E=S-M,T=S+M;Ec&&(c=T),v&&Sg&&(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);co&&(o=t);let i=e[c+2];il&&(l=i);let n=e[c+4];nh&&(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;)s--;if(!(ae.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=a.candidate?zb(r,i,a.rightCacheBounds):(zb(r,i,a.leftCacheBounds),a.count++)}}for(let i=0;i=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;im&&(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,pt[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;cMath.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;rn?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;rn?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)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),s1-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||v0?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),nnew 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<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(ii.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=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),gr.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);inew 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;uu&&(u=i),nd&&(d=n),rp&&(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]=oc?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{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;gsH.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{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:e=>Wb.distanceToBox(e),intersectsBounds:(e,t,i)=>i{for(let s=3*e,b=3*(e+a);s(jb.copy(e).clamp(t.min,t.max),jb.distanceToSquared(e)),intersectsBounds:(e,t,i)=>i{t.closestPointToPoint(e,jb);let n=e.distanceToSquared(jb);return n{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;ii.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;en.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=1)return}else for(let c=Math.max(0,a.start),u=Math.min(l.count,a.start+a.count);c=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=-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;t0)for(let r=0;r0)for(let r=0;r0;)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;r1||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 \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#include \n\nvoid main() {\n\n\t#include \n\t#include \n\t#include \n\n #include \n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\tvViewPosition = - mvPosition.xyz;\n\n\t#include \n\t#include \n\t#include \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 \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#include \n\nvoid main() {\n\n\t#include \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 \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\t// accumulation\n\t#include \n\t#include \n\t#include \n\t#include \n\n\t// modulation\n\t#include \n\n\tvec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\tvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\n\t#include \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 \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n #include \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{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;ne.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;hy))&&(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;S0))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{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=0;){t=e[i];let n=h[t].inited?h[t].barycentricIndex+1:0;for(;ne(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;e4?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;re.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;i5e-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;r4?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;tr.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;y0){let i=[],n=[],r={};if(void 0!==e.morphTargetDictionary)for(let t in e.morphTargetDictionary)r[e.morphTargetDictionary[t]]=t;for(let a=0;a0&&(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;y0&&(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;o0){let t=[];for(let n=0,r=e.children.length;n0&&(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;a0&&(n.nodes=r),this.serializeUserData(e,n)}processObjects(e){let t=new Si;t.name="AuxScene";for(let i=0;i0&&this.processObjects(i);for(let n=0;n0&&(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;ee.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;ot){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{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;fa&&(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=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=ra?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=ol?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=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.x&&n.x>=c&&r!==n.x&&Zv(ai.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;t0||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=(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;a0&&(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;u0&&(d=(d=d.map((function(e){return e}))).reverse());for(var p=0,f=d.length-1;p0}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){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;or!=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;s0&&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{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;nVH||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;r2&&(a=t?2*r:2*r-2);let s=new n(a),o=0;for(let l=0;l0&&l{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;i1-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){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;r0){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;c0){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.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{(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;n0&&(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;h2?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.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;n0){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=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;t0&&i.push(a+o.array[t-1],a+e)}else for(let t=0;t0&&(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=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=e&&i<=n)return!0}else{let e=3*i;if(e>=t.positionStart&&e=e.indexStart&&t=e.positionStart&&t80*i){n=a=e[0],r=s=e[1];for(let t=i;ta&&(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=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=ra?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=ol?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=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.x&&n.x>=h&&a!==n.x&&Kv(si.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;t0||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=(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;ae.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;nbct)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{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-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=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;a0?(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=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&&oe.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(;n128;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.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{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;rt.id===e))}measureTextLength(e,t){let i=this.context,n=e.split("\n"),r=0;for(let a=0;ae.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{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;sthis.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;hs&&(s=i)}let o=this.padding/this.tolerance,l=new xe(n.x,n.y);for(let h=0;h[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;vc&&(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[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{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;nthis.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;ai.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;vc&&(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;ve.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[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;t0&&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;t0==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{},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{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:rt.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{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{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[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=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=0&&i.push({angle:e,origin:r,delta:a,dashPattern:o})}return i}function Yct(e,t){let i=[],n=t.next();for(;i.length0&&(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.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(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;c0&&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;i0&&(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{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;o255||(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;it?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>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;h0){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=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 \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 \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 \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 \n }\n `;return new cn({uniforms:r,vertexShader:"\n varying vec3 v_pos;\n\n #include \n void main() {\n //vec4 worldPosition = modelMatrix * vec4(position, 1.0);\n v_pos = position;\n\n #include \n #include \n #include \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\n\n vec2 getWorldScale() {\n return vec2(length(modelMatrix[0].xyz), length(modelMatrix[1].xyz));\n }\n\n void main() {\n\n #include \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 \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 \n }`;return new cn({uniforms:o,vertexShader:"\n attribute float lineDistance;\n varying float vLineDistance;\n\n #include \n\n void main() {\n vLineDistance = lineDistance;\n\n #include \n #include \n #include \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=n[o]&&e<=n[o+1]);o++);let u,d=[];for(let f=0;fo-t-1+f;i--){u=(e-n[i])/(n[i+t+1-f]-n[i]);for(let e=0;e{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=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;rwindow.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;n0&&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>>=1,t}function Xu(e,t,i){if(!t)return i;for(;e.bitcount<24;)e.tag|=e.source[e.sourceIndex++]<>>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++]<>>=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;s8;)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.destLenthis.x2&&(this.x2=e)),"number"==typeof t&&((isNaN(this.y1)||isNaN(this.y2))&&(this.y1=t,this.y2=t),tthis.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=0&&n>0&&(i+=" "),i+=t(r)}return i}e=void 0!==e?e:2;for(var n="",r=0;r"},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>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>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=-128&&e<=127}function tht(e,t,i){for(var n=0,r=e.length;t>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=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=-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>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;n0)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>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=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>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>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;I1&&!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=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=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=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=i.begin&&e=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=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;ot.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;n0)return e.glyphs.get(r).getMetrics()}return i}function bdt(e){for(var t=0,i=0;ig||void 0===t)&&g>0&&(t=g),h 123 are reserved for internal usage");p|=1<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>>1,a=e[r].tag;if(a===t)return r;a>>1,a=e[r];if(a===t)return r;a>>1,s=(i=e[a]).start;if(s===t)return i;s0)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;n0?(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;o0)for(var u=a.parseByte(),d=0;d0){var p,f=[];if(h>0){for(var m=0;m=0,f.push(p);for(var g=0,v=0;v0?(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;wt.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=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=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=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;n1,'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=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;s1?"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;d1?"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)",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(ni?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>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>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=0?1:-1,o=Math.abs(o),e&&(h=a.cvt[u],n&&Math.abs(o-h)":"_")+(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=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;n2)){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;l1))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=0&&e0&&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=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=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;r1&&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;r0;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;l0){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>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;i4294967295?((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;ae.length&&(i-=t);let n="";for(let r=0;re.length&&(i-=t);let n=new Uint8Array(i);for(let r=0;r1?(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&&tf);)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&&ev);)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,pf&&(p-=2*Math.PI);let g=p;for(;;){if(g+=m,!r&&gf)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;rnew 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>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;tft(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;ie.order-t.order));for(let t=0;t{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{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=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;te.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=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{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;ee.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{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{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;_{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{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(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{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.xr&&(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;s0){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;n0&&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;lnew D(e.x,e.y,e.z))),s=new D(r.x,r.y,r.z);for(let e=0;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;p0?(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;ms?(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;te.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;te.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;t0&&(e.colorIndex=n.DIMCLRD,e.color=Ym(e.colorIndex));let r=new bn;for(let s=0;s`,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`,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(te;r--){let o=n[r];if(Zt.areVector3sEqual(i,o)&&e+10)break;a.push(i)}if(s>0)for(let e=s+1;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{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;n2){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;s31&&(!(e=>{for(let t=1;t{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;g1?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;e0&&(c=!1),u+=Math.abs(t)}let d=c?.05:.005,p=[],f=[],m=0;f[0]=m;for(let e=0;eKn.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{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{t.children.forEach((t=>{this.buildHatchGeometry(e,t,i)}))}))}findIntersectHole(e,t){let i=t.length,n=[];for(let r=0;r{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.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;rMath.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;in.color===t&&n.patternAngle===e.patternAngle&&((e,t)=>{if(e.length!==t.length)return!1;for(let i=0;i{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{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;a15e3&&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;s15e3&&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{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;tt.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;ie.length)&&(t=e.length);for(var i=0,n=new Array(t);i1&&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;i1?t-1:0),n=1;n-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={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};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;t2&&void 0!==arguments[2]?arguments[2]:".";if(e){if(e[t])return e[t];for(var n=t.split(i),r=e,a=0;aa+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;t1&&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;F1&&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;t0&&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-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;t3&&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;t0&&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;r1?i-1:0),r=1;r0&&"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-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;l1&&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;n0&&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);in.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;s0||!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;rt-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>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;r0&&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=0;){let n=e[t];if(null!==n.value[i])return n;t--}return null}function w(e,t,i){for(;t>>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;t0?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;i0&&t0&&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(;t4)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=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;in.limits.max||t{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{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.lengtht._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{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<>>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>>l]=h}else for(s=new Zf(n),r=0;r>>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;it&&(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>>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<>>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<>>4;if(!B)throw"invalid distance";if(l+=15&B,L=egt[z],z>3&&(F=A0e[z],L+=F6(e,l)&(1<f){if(a)throw"unexpected EOF";break}r&&s(h+131072);for(var H=h+U;h>>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+1];)t=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=r0,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;n1?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;c1&&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;u1){let e=1,i=t[0];for(let n=1;n=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(;c1&&(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;u0?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=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=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=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=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;r0||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{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=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;s0&&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;n1?new er:1===t.length?t[0]:new on,s!==t[0])for(let e=0,i=t.length;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=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=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;e0){let e=t.split("/");n.push(e)}}let r=n[0];for(let e=1,a=n.length-1;e1){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;a0&&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;r1){for(let e=0,t=n.length;e0){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;le.name));function i(e){for(let i=0,n=e.length;i0&&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;re.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=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>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<>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<>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<>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=[];nr.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;n1023||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;s31||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{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>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;a0&&(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 nMath.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;ethis.max.x||t.ythis.max.y||t.zthis.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.xthis.max.x||t.max.ythis.max.y||t.max.zthis.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;rthis.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=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=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<>>0}enable(t){this.mask|=1<1){for(let e=0;e1){for(let n=0;n0&&(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;n0&&(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;l0){s.children=[];for(let o=0;o0){s.animations=[];for(let o=0;o0&&(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;n0?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+(s0&&(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;d0&&(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;u0){let s=e[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=s.length;r(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;ge.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;Z0?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;K0&&(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 \n\t\t\t\t\t#include \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 \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)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 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 \n\t#include \n}`,Ef=`varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \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 \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 \n\t#include \n}`,wf=`varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \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 \n\t#include \n}`,Rf=`#include \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvHighPrecisionZW = gl_Position.zw;\n}`,Cf=`#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \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 \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvWorldPosition = worldPosition.xyz;\n}`,Lf=`#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main () {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include \n\t#include \n\t#include \n\t#include \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 \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n}`,Uf=`uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV = equirectUv( direction );\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\t#include \n\t#include \n}`,Df=`uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvLineDistance = scale * lineDistance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}`,Nf=`uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \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 \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}`,Ff=`#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}`,Of=`uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \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 \n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}`,Bf=`#define LAMBERT\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n\t#include \n}`,zf=`#define LAMBERT\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \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 \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}`,Vf=`#define MATCAP\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n}`,kf=`#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \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 \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}`,Hf=`#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \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 \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \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 \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n\t#include \n}`,Xf=`#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \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 \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}`,qf=`#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n\tvarying vec3 vWorldPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \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 \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \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 \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\tvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\t#include \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 \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}`,Zf=`#define TOON\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n}`,Jf=`#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \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 \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}`,$f=`uniform float size;\nuniform float scale;\n#include \n#include \n#include \n#include \n#include \n#include \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 \n\t#include \n\t#include \n\t#include \n\t#include \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 \n\t#include \n\t#include \n\t#include \n}`,Kf=`uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}`,Qf=`#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}`,jf=`uniform vec3 color;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include \n\t#include \n\t#include \n}`,td=`uniform float rotation;\nuniform vec2 center;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \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 \n\t#include \n\t#include \n}`,ed=`uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \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=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;$=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;yt0&&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.length0){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;t2?_: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;sNn&&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_-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;ai-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;T2?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 \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 \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;ht.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;O0)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":" "} ${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/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);r0&&(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;Y0?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=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;z0&&(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 \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;Dh||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;K0||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=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;qtj||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=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>=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;k0&&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>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;Q0){V.__webglFramebuffer[et]=[];for(let H=0;H0){V.__webglFramebuffer=[];for(let et=0;et0&&Vt(R)===!1){let et=tt?M:[M];V.__webglMultisampledFramebuffer=i.createFramebuffer(),V.__webglColorRenderbuffer=[],e.bindFramebuffer(i.FRAMEBUFFER,V.__webglMultisampledFramebuffer);for(let H=0;H0)for(let H=0;H0)for(let H=0;H0&&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;mt0&&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=0&&(_[at]=null,v[at].disconnect(ot))}for(let Z=0;Z=_.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;at0&&(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;v0){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;X0?p=v[v.length-1]:p=null,f.pop(),f.length>0?x=f[f.length-1]:x=null};function Uo(E,N,X,U){if(E.visible===!1)return;if(E.layers.test(N.layers)){if(E.isGroup)X=E.renderOrder;else if(E.isLOD)E.autoUpdate===!0&&E.update(N);else if(E.isLight)p.pushLight(E),E.castShadow&&p.pushShadow(E);else if(E.isSprite){if(!E.frustumCulled||ot.intersectsSprite(E)){U&&zt.setFromMatrixPosition(E.matrixWorld).applyMatrix4(Et);let gt=M.update(E),Mt=E.material;Mt.visible&&x.push(E,gt,Mt,X,zt.z,null)}}else if((E.isMesh||E.isLine||E.isPoints)&&(!E.frustumCulled||ot.intersectsObject(E))){let gt=M.update(E),Mt=E.material;if(U&&(E.boundingSphere!==void 0?(E.boundingSphere===null&&E.computeBoundingSphere(),zt.copy(E.boundingSphere.center)):(gt.boundingSphere===null&>.computeBoundingSphere(),zt.copy(gt.boundingSphere.center)),zt.applyMatrix4(E.matrixWorld).applyMatrix4(Et)),Array.isArray(Mt)){let St=gt.groups;for(let Ut=0,vt=St.length;Ut0&&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;St0),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;tr0&&Lt.useMultisampledRTT(E)===!1?W=Ft.get(E).__webglMultisampledFramebuffer:Array.isArray(vt)?W=vt[X]:W=vt,w.copy(E.viewport),z.copy(E.scissor),Y=E.scissorTest}else w.copy(K).multiplyScalar(G).floor(),z.copy(B).multiplyScalar(G).floor(),Y=Z;if(bt.bindFramebuffer(F.FRAMEBUFFER,W)&&Tt.drawBuffers&&U&&bt.drawBuffers(E,W),bt.viewport(w),bt.scissor(z),bt.setScissorTest(Y),lt){let St=Ft.get(E.texture);F.framebufferTexture2D(F.FRAMEBUFFER,F.COLOR_ATTACHMENT0,F.TEXTURE_CUBE_MAP_POSITIVE_X+N,St.__webglTexture,X)}else if(gt){let St=Ft.get(E.texture),Ut=N||0;F.framebufferTextureLayer(F.FRAMEBUFFER,F.COLOR_ATTACHMENT0,St.__webglTexture,X||0,Ut)}L=-1},this.readRenderTargetPixels=function(E,N,X,U,W,lt,gt){if(!(E&&E.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Mt=Ft.get(E).__webglFramebuffer;if(E.isWebGLCubeRenderTarget&>!==void 0&&(Mt=Mt[gt]),Mt){bt.bindFramebuffer(F.FRAMEBUFFER,Mt);try{let St=E.texture,Ut=St.format,vt=St.type;if(Ut!==ke&&ht.convert(Ut)!==F.getParameter(F.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}let wt=vt===Gi&&(yt.has("EXT_color_buffer_half_float")||Tt.isWebGL2&&yt.has("EXT_color_buffer_float"));if(vt!==Sn&&ht.convert(vt)!==F.getParameter(F.IMPLEMENTATION_COLOR_READ_TYPE)&&!(vt===yn&&(Tt.isWebGL2||yt.has("OES_texture_float")||yt.has("WEBGL_color_buffer_float")))&&!wt){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}N>=0&&N<=E.width-U&&X>=0&&X<=E.height-W&&F.readPixels(N,X,U,W,ht.convert(Ut),ht.convert(vt),lt)}finally{let St=A!==null?Ft.get(A).__webglFramebuffer:null;bt.bindFramebuffer(F.FRAMEBUFFER,St)}}},this.copyFramebufferToTexture=function(E,N,X=0){let U=Math.pow(2,-X),W=Math.floor(N.image.width*U),lt=Math.floor(N.image.height*U);Lt.setTexture2D(N,0),F.copyTexSubImage2D(F.TEXTURE_2D,X,0,0,E.x,E.y,W,lt),bt.unbindTexture()},this.copyTextureToTexture=function(E,N,X,U=0){let W=N.image.width,lt=N.image.height,gt=ht.convert(X.format),Mt=ht.convert(X.type);Lt.setTexture2D(X,0),F.pixelStorei(F.UNPACK_FLIP_Y_WEBGL,X.flipY),F.pixelStorei(F.UNPACK_PREMULTIPLY_ALPHA_WEBGL,X.premultiplyAlpha),F.pixelStorei(F.UNPACK_ALIGNMENT,X.unpackAlignment),N.isDataTexture?F.texSubImage2D(F.TEXTURE_2D,U,E.x,E.y,W,lt,gt,Mt,N.image.data):N.isCompressedTexture?F.compressedTexSubImage2D(F.TEXTURE_2D,U,E.x,E.y,N.mipmaps[0].width,N.mipmaps[0].height,gt,N.mipmaps[0].data):F.texSubImage2D(F.TEXTURE_2D,U,E.x,E.y,gt,Mt,N.image),U===0&&X.generateMipmaps&&F.generateMipmap(F.TEXTURE_2D),bt.unbindTexture()},this.copyTextureToTexture3D=function(E,N,X,U,W=0){if(_.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}let lt=E.max.x-E.min.x+1,gt=E.max.y-E.min.y+1,Mt=E.max.z-E.min.z+1,St=ht.convert(U.format),Ut=ht.convert(U.type),vt;if(U.isData3DTexture)Lt.setTexture3D(U,0),vt=F.TEXTURE_3D;else if(U.isDataArrayTexture)Lt.setTexture2DArray(U,0),vt=F.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}F.pixelStorei(F.UNPACK_FLIP_Y_WEBGL,U.flipY),F.pixelStorei(F.UNPACK_PREMULTIPLY_ALPHA_WEBGL,U.premultiplyAlpha),F.pixelStorei(F.UNPACK_ALIGNMENT,U.unpackAlignment);let wt=F.getParameter(F.UNPACK_ROW_LENGTH),Yt=F.getParameter(F.UNPACK_IMAGE_HEIGHT),Zt=F.getParameter(F.UNPACK_SKIP_PIXELS),Pe=F.getParameter(F.UNPACK_SKIP_ROWS),Ke=F.getParameter(F.UNPACK_SKIP_IMAGES),$t=X.isCompressedTexture?X.mipmaps[0]:X.image;F.pixelStorei(F.UNPACK_ROW_LENGTH,$t.width),F.pixelStorei(F.UNPACK_IMAGE_HEIGHT,$t.height),F.pixelStorei(F.UNPACK_SKIP_PIXELS,E.min.x),F.pixelStorei(F.UNPACK_SKIP_ROWS,E.min.y),F.pixelStorei(F.UNPACK_SKIP_IMAGES,E.min.z),X.isDataTexture||X.isData3DTexture?F.texSubImage3D(vt,W,N.x,N.y,N.z,lt,gt,Mt,St,Ut,$t.data):X.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),F.compressedTexSubImage3D(vt,W,N.x,N.y,N.z,lt,gt,Mt,St,$t.data)):F.texSubImage3D(vt,W,N.x,N.y,N.z,lt,gt,Mt,St,Ut,$t),F.pixelStorei(F.UNPACK_ROW_LENGTH,wt),F.pixelStorei(F.UNPACK_IMAGE_HEIGHT,Yt),F.pixelStorei(F.UNPACK_SKIP_PIXELS,Zt),F.pixelStorei(F.UNPACK_SKIP_ROWS,Pe),F.pixelStorei(F.UNPACK_SKIP_IMAGES,Ke),W===0&&U.generateMipmaps&&F.generateMipmap(vt),bt.unbindTexture()},this.initTexture=function(E){E.isCubeTexture?Lt.setTextureCube(E,0):E.isData3DTexture?Lt.setTexture3D(E,0):E.isDataArrayTexture||E.isCompressedArrayTexture?Lt.setTexture2DArray(E,0):Lt.setTexture2D(E,0),bt.unbindTexture()},this.resetState=function(){S=0,T=0,A=null,bt.reset(),ut.reset()},typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return on}get physicallyCorrectLights(){return console.warn("THREE.WebGLRenderer: The property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),!this.useLegacyLights}set physicallyCorrectLights(t){console.warn("THREE.WebGLRenderer: The property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),this.useLegacyLights=!t}get outputEncoding(){return console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace===Rt?Bn:xc}set outputEncoding(t){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=t===Bn?Rt:Ze}get useLegacyLights(){return console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights}set useLegacyLights(t){console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights=t}},io=class extends no{};io.prototype.isWebGL1Renderer=!0;function _n(i,t,e){return Rc(i)?new i.constructor(i.subarray(t,e!==void 0?e:i.length)):i.slice(t,e)}function Ms(i,t,e){return!i||!e&&i.constructor===t?i:typeof t.BYTES_PER_ELEMENT=="number"?new t(i):Array.prototype.slice.call(i)}function Rc(i){return ArrayBuffer.isView(i)&&!(i instanceof DataView)}var Mi=class{constructor(t,e,n,s){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=s!==void 0?s:new e.constructor(n),this.sampleValues=e,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(t){let e=this.parameterPositions,n=this._cachedIndex,s=e[n],r=e[n-1];n:{t:{let a;e:{i:if(!(t=r)){let o=e[1];t=r)break t}a=n,n=0;break e}break n}for(;n>>1;te;)--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;o0){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;de&&(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]=ns?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;ae[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;rs-r);for(let s=0;sc&&(c=A),f&&bg&&(g=b);let L=i[v+2],y=i[v+3],w=L-y,z=L+y;wl&&(l=z),f&&Lx&&(x=L);let Y=i[v+4],I=i[v+5],D=Y-I,O=Y+I;Dh&&(h=O),f&&Yp&&(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;ho&&(o=u);let m=i[h+2];mc&&(c=m);let g=i[h+4];gl&&(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;)a--;if(ri.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=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=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;_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,St[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;hMath.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;rs?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;rs?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)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),h1-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=y0?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),unew 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<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=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),Ls.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;ynew 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;uT&&(T=Y),IA&&(A=I),DL&&(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]=$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{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;TLo.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{if(t.boundsTree)return t.boundsTree.shapecast({boundsTraverseOrder:A=>$i.distanceToBox(A),intersectsBounds:(A,L,y)=>y{for(let y=A*3,w=(A+L)*3;y(Ki.copy(t).clamp(h.min,h.max),Ki.distanceToSquared(t)),intersectsBounds:(h,d,u)=>u{h.closestPointToPoint(t,Ki);let u=t.distanceToSquared(Ki);return u{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{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=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{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;r65535?new Uint32Array(n):new Uint16Array(n);for(let i=0,r=n;i{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){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[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(an)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{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(rn)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;a0&&(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;tt.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-35e.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{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+=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;h2&&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{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;ii===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;cthis.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;n0),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.xt.max.x||e.yt.max.y,n=this.getFilteredViewports(t);for(let r=0,a=n.length;r{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);sr.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{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;hs)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;n0||i&&t<0)&&a.reverse()}else for(n=0,r=e.length;n0);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;ih?l-h:l+o-h,u=(s?-c:o-c)/a;e.push(n);for(let d=1;d0?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;s0&&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;n0&&(i=1===i.length?[i[0]]:(0,cg.union)(i[0],i.slice(1)))}else{let a=[];for(n=0,r=t.length;n0&&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;se.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{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;e0&&e.__depth+1>=a))return!0;let h=!1,c=e.children;for(let u=0,d=c.length;ue.__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{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{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=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{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;l1e-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;ls)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{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.length1e-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;ae.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;e25&&(t=25);let i=.5*(t-1),n=new Array(t),r=0;for(let a=0;a0){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 \n\t\t\t\t#include \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 \n\t\t\t\t\t#include \n\t\t\t\t\t#include \n\t\t\t\t\t#include \n\t\t\t\t\t#include \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 \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 \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 \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 \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 \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 \n\t\t#include \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 \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;hp?(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 \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 \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\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 ","").replace("#include ",""),e.vertexShader=e.vertexShader.replace("#include ","").replace("#include ","")}}))}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 ","").replace("#include ",""),e.vertexShader=e.vertexShader.replace("#include ","").replace("#include ","")}}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]&&et.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!!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;le.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;rt.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);ri.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||nSt.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"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||nSt.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),n0?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;r0))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(e0&&!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{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{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+=`

${e}:${i}

`};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+=`

${e}:${t}

`};i.innerHTML="

-- Renderer Info --

";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

Camera position:${a(s)}

\n

Camera target:${a(o)}

`,i instanceof Nr&&(t.innerHTML+=`\n

top: ${r(i.top)}, bottom: ${r(i.bottom)}, left: ${r(i.left)}, right: ${r(i.right)}

\n

zoom: ${r(i.zoom)}

`),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

W: Move forward

\n

A: Move backward

\n

S: Move left

\n

D: Move right

\n

Q: Rise up

\n

E: Lower down

\n

\u2191: Rotate up

\n

\u2193: Rotate down

\n

\u2190: Rotate to left

\n

\u2192: Rotate to right

\n ":"DxfViewer"===e.viewer.name?t.innerHTML="\n

\u2191: Move up

\n

\u2193: Move down

\n

\u2190: Move to left

\n

\u2192: Move to right

\n ":"VRViewer"===e.viewer.name?t.innerHTML="\n

\u2191: Rotate up

\n

\u2193: Rotate down

\n

\u2190: Rotate to left

\n

\u2192: Rotate to right

\n ":t.innerHTML="\n

Nothing to show

\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=`
`,n.title=Qu(i.menuName),n.innerHTML+=`${n.title}`,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+=`${n.title}`,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+=`${n.title}`,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+=`${n.title}`,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;r1?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<-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&&ithis.__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='
\n\n Here\'s the new load parameter for your GUI\'s constructor:\n\n \n\n
\n\n Automatically save\n values to localStorage on exit.\n\n
The values saved to localStorage will\n override those passed to dat.GUI\'s constructor. This makes it\n easier to work incrementally, but localStorage is fragile,\n and your friends may not see the same values you do.\n\n
\n\n
\n\n
',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=" ",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;t0&&(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{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{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
\n \n Color\n   Layer name\n
\n ';if(this.dxfLayersArray){let e=this.dxfLayersArray.length>1;for(let i=0;i{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{e.addEventListener("change",(()=>{this.checkboxHandler(e)}))}))}generateListItem(e,t,i){return`\n
\n \n
\n ${e}\n
\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{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.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{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&&e1&&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;r0){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;onew 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;ts1e&&(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;T0){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=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{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({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=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));trl.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]0&&(e.userData[t]-=.05),e.userData[t]>0&&e.userData[t]{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&&a0)}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(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};