From 3d88d070c9f608881ea4f0fd85fc1fba4b136b1c Mon Sep 17 00:00:00 2001 From: pattern-x Date: Sat, 12 Aug 2023 08:08:34 +0000 Subject: [PATCH] Merge pull request #111 from pattern-x/feature/fix-camera Fix incorrect camera position --- asset-manifest.json | 24 +++++++------- demo/libs/gemini-viewer.esm.min.js | 2 +- demo/libs/types/core/Configs.d.ts | 6 ++++ demo/libs/types/core/canvas/CanvasRender.d.ts | 2 +- demo/libs/types/core/helpers/OSnapHelper.d.ts | 32 +++++++++++++++++-- demo/libs/types/core/input/InputManager.d.ts | 8 +++-- demo/libs/types/core/viewers/BimViewer.d.ts | 1 + demo/libs/types/core/viewers/VRViewer.d.ts | 19 ++++++++--- demo/libs/types/core/vr/VRCube.d.ts | 1 + .../plugins/measure/AreaMeasureDrawable.d.ts | 3 +- .../plugins/measure/AreaMeasurement.d.ts | 12 +++++++ .../measure/DistanceMeasureDrawable.d.ts | 4 ++- .../plugins/measure/DistanceMeasurement.d.ts | 12 +++++++ .../plugins/measure/MeasurementPlugin.d.ts | 11 +++++++ .../overview-map/OverviewMapPlugin.d.ts | 4 +++ demo/libs/types/plugins/pdf/PdfLoader.d.ts | 17 ++++++++-- index.html | 2 +- static/js/main.7de1cc52.js | 2 -- static/js/main.7de1cc52.js.map | 1 - static/js/main.9121734f.js | 2 ++ static/js/main.9121734f.js.map | 1 + 21 files changed, 134 insertions(+), 32 deletions(-) delete mode 100644 static/js/main.7de1cc52.js delete mode 100644 static/js/main.7de1cc52.js.map create mode 100644 static/js/main.9121734f.js create mode 100644 static/js/main.9121734f.js.map diff --git a/asset-manifest.json b/asset-manifest.json index 6b2fc8a..3de15e7 100644 --- a/asset-manifest.json +++ b/asset-manifest.json @@ -1,7 +1,7 @@ { "files": { "main.css": "./static/css/main.c73119e9.css", - "main.js": "./static/js/main.7de1cc52.js", + "main.js": "./static/js/main.9121734f.js", "static/js/787.cf5efa72.chunk.js": "./static/js/787.cf5efa72.chunk.js", "demo/libs/gemini-viewer.esm.min.js": "./demo/libs/gemini-viewer.esm.min.js", "static/media/dwg_background.png": "./static/media/dwg_background.f630e7cda68e19172eec.png", @@ -11,25 +11,25 @@ "demo/libs/types/core/viewers/BimViewer.d.ts": "./demo/libs/types/core/viewers/BimViewer.d.ts", "demo/libs/types/core/Configs.d.ts": "./demo/libs/types/core/Configs.d.ts", "demo/libs/types/core/utils/ObjectUtils.d.ts": "./demo/libs/types/core/utils/ObjectUtils.d.ts", - "demo/libs/types/core/dxf-parser/DxfParser.d.ts": "./demo/libs/types/core/dxf-parser/DxfParser.d.ts", "demo/libs/types/plugins/pdf/PdfLoader.d.ts": "./demo/libs/types/plugins/pdf/PdfLoader.d.ts", + "demo/libs/types/core/dxf-parser/DxfParser.d.ts": "./demo/libs/types/core/dxf-parser/DxfParser.d.ts", "demo/libs/types/core/viewers/VRViewer.d.ts": "./demo/libs/types/core/viewers/VRViewer.d.ts", "demo/libs/types/core/viewers/BaseViewer.d.ts": "./demo/libs/types/core/viewers/BaseViewer.d.ts", "demo/libs/types/plugins/sections/BasePlaneSection.d.ts": "./demo/libs/types/plugins/sections/BasePlaneSection.d.ts", "demo/libs/types/plugins/overview-map/OverviewMapPlugin.d.ts": "./demo/libs/types/plugins/overview-map/OverviewMapPlugin.d.ts", + "demo/libs/types/core/helpers/OSnapHelper.d.ts": "./demo/libs/types/core/helpers/OSnapHelper.d.ts", "demo/libs/types/core/utils/Locale.d.ts": "./demo/libs/types/core/utils/Locale.d.ts", "demo/libs/types/plugins/sections/BaseBoxSection.d.ts": "./demo/libs/types/plugins/sections/BaseBoxSection.d.ts", "demo/libs/types/core/viewers/SimplifiedBimViewer.d.ts": "./demo/libs/types/core/viewers/SimplifiedBimViewer.d.ts", "demo/libs/types/core/dxf/DxfCompare.d.ts": "./demo/libs/types/core/dxf/DxfCompare.d.ts", "demo/libs/types/core/utils/CommonUtils.d.ts": "./demo/libs/types/core/utils/CommonUtils.d.ts", "demo/libs/types/core/utils/MergeUtils.d.ts": "./demo/libs/types/core/utils/MergeUtils.d.ts", - "demo/libs/types/core/helpers/OSnapHelper.d.ts": "./demo/libs/types/core/helpers/OSnapHelper.d.ts", "demo/libs/types/plugins/measure/BaseMeasurement.d.ts": "./demo/libs/types/plugins/measure/BaseMeasurement.d.ts", + "demo/libs/types/plugins/measure/MeasurementPlugin.d.ts": "./demo/libs/types/plugins/measure/MeasurementPlugin.d.ts", "demo/libs/types/core/controls/VRControls.d.ts": "./demo/libs/types/core/controls/VRControls.d.ts", + "demo/libs/types/core/input/InputManager.d.ts": "./demo/libs/types/core/input/InputManager.d.ts", "demo/libs/types/core/Constants.d.ts": "./demo/libs/types/core/Constants.d.ts", - "demo/libs/types/plugins/measure/MeasurementPlugin.d.ts": "./demo/libs/types/plugins/measure/MeasurementPlugin.d.ts", "demo/libs/types/core/compare/BaseDxfCompareHelper.d.ts": "./demo/libs/types/core/compare/BaseDxfCompareHelper.d.ts", - "demo/libs/types/core/input/InputManager.d.ts": "./demo/libs/types/core/input/InputManager.d.ts", "demo/libs/types/core/utils/GeometryUtils.d.ts": "./demo/libs/types/core/utils/GeometryUtils.d.ts", "demo/libs/types/components/toolbar/Toolbar.d.ts": "./demo/libs/types/components/toolbar/Toolbar.d.ts", "demo/libs/types/core/camera-controls/types.d.ts": "./demo/libs/types/core/camera-controls/types.d.ts", @@ -89,6 +89,7 @@ "demo/libs/types/core/helpers/ControlsHelper.d.ts": "./demo/libs/types/core/helpers/ControlsHelper.d.ts", "demo/libs/types/core/camera-controls/EventDispatcher.d.ts": "./demo/libs/types/core/camera-controls/EventDispatcher.d.ts", "demo/libs/types/plugins/overview-map/TextDrawable.d.ts": "./demo/libs/types/plugins/overview-map/TextDrawable.d.ts", + "demo/libs/types/plugins/measure/AreaMeasurement.d.ts": "./demo/libs/types/plugins/measure/AreaMeasurement.d.ts", "demo/libs/types/core/shx-parser/util/BitConverter.d.ts": "./demo/libs/types/core/shx-parser/util/BitConverter.d.ts", "demo/libs/types/components/context-menu/ContextMenu.d.ts": "./demo/libs/types/components/context-menu/ContextMenu.d.ts", "demo/libs/types/core/markup/BaseMarkup.d.ts": "./demo/libs/types/core/markup/BaseMarkup.d.ts", @@ -97,6 +98,7 @@ "demo/libs/types/core/controls/CameraControlsEx.d.ts": "./demo/libs/types/core/controls/CameraControlsEx.d.ts", "demo/libs/types/core/utils/SceneUtils.d.ts": "./demo/libs/types/core/utils/SceneUtils.d.ts", "demo/libs/types/core/dxf/DxfObject.d.ts": "./demo/libs/types/core/dxf/DxfObject.d.ts", + "demo/libs/types/plugins/measure/DistanceMeasurement.d.ts": "./demo/libs/types/plugins/measure/DistanceMeasurement.d.ts", "demo/libs/types/core/dxf-parser/DxfTextReader.d.ts": "./demo/libs/types/core/dxf-parser/DxfTextReader.d.ts", "demo/libs/types/core/canvas/DrawableList.d.ts": "./demo/libs/types/core/canvas/DrawableList.d.ts", "demo/libs/types/core/dxf-parser/entities/image.d.ts": "./demo/libs/types/core/dxf-parser/entities/image.d.ts", @@ -112,14 +114,12 @@ "demo/libs/types/core/dxf-parser/entities/attrib.d.ts": "./demo/libs/types/core/dxf-parser/entities/attrib.d.ts", "demo/libs/types/core/indexeddb/FontDataTable.d.ts": "./demo/libs/types/core/indexeddb/FontDataTable.d.ts", "demo/libs/types/core/dxf-parser/objects/common.d.ts": "./demo/libs/types/core/dxf-parser/objects/common.d.ts", - "demo/libs/types/plugins/measure/AreaMeasurement.d.ts": "./demo/libs/types/plugins/measure/AreaMeasurement.d.ts", "demo/libs/types/core/viewers/Plugin.d.ts": "./demo/libs/types/core/viewers/Plugin.d.ts", "demo/libs/types/core/shp-js/ShpThree.d.ts": "./demo/libs/types/core/shp-js/ShpThree.d.ts", "demo/libs/types/core/dxf-parser/objects/spatialfilter.d.ts": "./demo/libs/types/core/dxf-parser/objects/spatialfilter.d.ts", "demo/libs/types/core/utils/index.d.ts": "./demo/libs/types/core/utils/index.d.ts", "demo/libs/types/plugins/sections/SectionPlane.d.ts": "./demo/libs/types/plugins/sections/SectionPlane.d.ts", "demo/libs/types/core/dxf-parser/objects/layout.d.ts": "./demo/libs/types/core/dxf-parser/objects/layout.d.ts", - "demo/libs/types/plugins/measure/DistanceMeasurement.d.ts": "./demo/libs/types/plugins/measure/DistanceMeasurement.d.ts", "demo/libs/types/plugins/measure/AngleMeasurement.d.ts": "./demo/libs/types/plugins/measure/AngleMeasurement.d.ts", "demo/libs/types/plugins/sections/GlobalPlaneSection.d.ts": "./demo/libs/types/plugins/sections/GlobalPlaneSection.d.ts", "demo/libs/types/plugins/measure/CoordinateMeasurement.d.ts": "./demo/libs/types/plugins/measure/CoordinateMeasurement.d.ts", @@ -142,10 +142,11 @@ "demo/libs/types/core/helpers/ZoomToRectHelper.d.ts": "./demo/libs/types/core/helpers/ZoomToRectHelper.d.ts", "demo/libs/types/core/dxf-parser/entities/leader.d.ts": "./demo/libs/types/core/dxf-parser/entities/leader.d.ts", "demo/libs/types/plugins/measure/AngleMeasureDrawable.d.ts": "./demo/libs/types/plugins/measure/AngleMeasureDrawable.d.ts", + "demo/libs/types/plugins/measure/AreaMeasureDrawable.d.ts": "./demo/libs/types/plugins/measure/AreaMeasureDrawable.d.ts", "demo/libs/types/core/helpers/BinaryReader.d.ts": "./demo/libs/types/core/helpers/BinaryReader.d.ts", "demo/libs/types/components/pop-panel/PickSectionPopPanel.d.ts": "./demo/libs/types/components/pop-panel/PickSectionPopPanel.d.ts", "demo/libs/types/core/shx-parser/ShxParser.d.ts": "./demo/libs/types/core/shx-parser/ShxParser.d.ts", - "demo/libs/types/plugins/measure/AreaMeasureDrawable.d.ts": "./demo/libs/types/plugins/measure/AreaMeasureDrawable.d.ts", + "demo/libs/types/plugins/measure/DistanceMeasureDrawable.d.ts": "./demo/libs/types/plugins/measure/DistanceMeasureDrawable.d.ts", "demo/libs/types/plugins/overview-map/LineDrawable.d.ts": "./demo/libs/types/plugins/overview-map/LineDrawable.d.ts", "demo/libs/types/core/utils/ColorUtils.d.ts": "./demo/libs/types/core/utils/ColorUtils.d.ts", "demo/libs/types/core/dxf-parser/entities/vertex.d.ts": "./demo/libs/types/core/dxf-parser/entities/vertex.d.ts", @@ -163,7 +164,6 @@ "demo/libs/types/core/utils/UnitConversionUtils.d.ts": "./demo/libs/types/core/utils/UnitConversionUtils.d.ts", "demo/libs/types/core/helpers/RafHelper.d.ts": "./demo/libs/types/core/helpers/RafHelper.d.ts", "demo/libs/types/plugins/local-model-uploader/LocalDxfUploader.d.ts": "./demo/libs/types/plugins/local-model-uploader/LocalDxfUploader.d.ts", - "demo/libs/types/plugins/measure/DistanceMeasureDrawable.d.ts": "./demo/libs/types/plugins/measure/DistanceMeasureDrawable.d.ts", "demo/libs/types/core/compare/CompareDrawable.d.ts": "./demo/libs/types/core/compare/CompareDrawable.d.ts", "demo/libs/types/core/utils/CSS2DObjectUtils.d.ts": "./demo/libs/types/core/utils/CSS2DObjectUtils.d.ts", "demo/libs/types/plugins/index.d.ts": "./demo/libs/types/plugins/index.d.ts", @@ -189,11 +189,11 @@ "demo/libs/types/core/dxf-parser/objects/sortentstable.d.ts": "./demo/libs/types/core/dxf-parser/objects/sortentstable.d.ts", "demo/libs/types/core/Units.d.ts": "./demo/libs/types/core/Units.d.ts", "demo/libs/types/core/markup/PolylineMarkup.d.ts": "./demo/libs/types/core/markup/PolylineMarkup.d.ts", + "demo/libs/types/core/vr/VRCube.d.ts": "./demo/libs/types/core/vr/VRCube.d.ts", "demo/libs/types/core/helpers/ObjectPixelSizeHelper.d.ts": "./demo/libs/types/core/helpers/ObjectPixelSizeHelper.d.ts", "demo/libs/types/core/markup/CloudRectMarkup.d.ts": "./demo/libs/types/core/markup/CloudRectMarkup.d.ts", "demo/libs/types/core/dxf-parser/objects/xrecord.d.ts": "./demo/libs/types/core/dxf-parser/objects/xrecord.d.ts", "demo/libs/types/components/toolbar/Toolbar.config.d.ts": "./demo/libs/types/components/toolbar/Toolbar.config.d.ts", - "demo/libs/types/core/vr/VRCube.d.ts": "./demo/libs/types/core/vr/VRCube.d.ts", "demo/libs/types/core/utils/SimplifyUtils.d.ts": "./demo/libs/types/core/utils/SimplifyUtils.d.ts", "demo/libs/types/core/dxf-parser/entities/circle.d.ts": "./demo/libs/types/core/dxf-parser/entities/circle.d.ts", "demo/libs/types/core/dxf/LinePatternShaders.d.ts": "./demo/libs/types/core/dxf/LinePatternShaders.d.ts", @@ -302,11 +302,11 @@ "demo/libs/types/core/webcam/index.d.ts": "./demo/libs/types/core/webcam/index.d.ts", "demo/libs/types/core/workers/CreateMeshBvh.worker.d.ts": "./demo/libs/types/core/workers/CreateMeshBvh.worker.d.ts", "main.c73119e9.css.map": "./static/css/main.c73119e9.css.map", - "main.7de1cc52.js.map": "./static/js/main.7de1cc52.js.map", + "main.9121734f.js.map": "./static/js/main.9121734f.js.map", "787.cf5efa72.chunk.js.map": "./static/js/787.cf5efa72.chunk.js.map" }, "entrypoints": [ "static/css/main.c73119e9.css", - "static/js/main.7de1cc52.js" + "static/js/main.9121734f.js" ] } \ No newline at end of file diff --git a/demo/libs/gemini-viewer.esm.min.js b/demo/libs/gemini-viewer.esm.min.js index 45f921a..3676b1d 100644 --- a/demo/libs/gemini-viewer.esm.min.js +++ b/demo/libs/gemini-viewer.esm.min.js @@ -1 +1 @@ -var wEe=Object.create,x1=Object.defineProperty,SEe=Object.defineProperties,MEe=Object.getOwnPropertyDescriptor,REe=Object.getOwnPropertyDescriptors,AEe=Object.getOwnPropertyNames,iz=Object.getOwnPropertySymbols,sz=Object.getPrototypeOf,az=Object.prototype.hasOwnProperty,CEe=Object.prototype.propertyIsEnumerable,PEe=Reflect.get,ao=Math.pow,LP=(e,t,i)=>t in e?x1(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,qn=(e,t)=>{for(var i in t||(t={}))az.call(t,i)&&LP(e,i,t[i]);if(iz)for(var i of iz(t))CEe.call(t,i)&&LP(e,i,t[i]);return e},ai=(e,t)=>SEe(e,REe(t)),OP=(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')})),IEe=(e,t)=>()=>(e&&(t=e(e=0)),t),W=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),O_=(e,t)=>{for(var i in t)x1(e,i,{get:t[i],enumerable:!0})},oz=(e,t,i,n)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let r of AEe(t))!az.call(e,r)&&r!==i&&x1(e,r,{get:()=>t[r],enumerable:!(n=MEe(t,r))||n.enumerable});return e},Xi=(e,t,i)=>(i=null!=e?wEe(sz(e)):{},oz(!t&&e&&e.__esModule?i:x1(i,"default",{value:e,enumerable:!0}),e)),DEe=e=>oz(x1({},"__esModule",{value:!0}),e),Si=(e,t,i)=>(LP(e,"symbol"!=typeof t?t+"":t,i),i),kP=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)},ne=(e,t,i)=>(kP(e,t,"read from private field"),i?i.call(e):t.get(e)),ze=(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)},pt=(e,t,i,n)=>(kP(e,t,"write to private field"),n?n.call(e,i):t.set(e,i),i),k_=(e,t,i,n)=>({set _(n){pt(e,t,n,i)},get _(){return ne(e,t,n)}}),rt=(e,t,i)=>(kP(e,t,"access private method"),i),lz=(e,t,i)=>PEe(sz(e),i,t),nt=(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())})),hz={};function F_(e){return(F_="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 OEe(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function cz(e,t){for(var i=0;i1&&void 0!==arguments[1]?arguments[1]:{};OEe(this,r),this._locale=function(e){for(var t=uz(e),i=0;iHEe});var FEe,uz,NEe,BEe,dz=IEe((()=>{FEe=function(e){return e.split("-").every((function(e){return/[a-z0-9]+/i.test(e)}))},uz=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})),Tz=W(((e,t)=>{"use strict";var i=(dz(),DEe(hz)),n=mz();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:_})),M=y||x,S=_||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 M[T(e)]}),(function(e,t){return S[T(e)][t?"ordinal":"cardinal"]}));t.exports=A})),Mz=W((e=>{"use strict";var t,i,n=(t=Tz())&&"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}()||e||Function("return this")()})),Ft=W(((e,t)=>{t.exports=function(e){try{return!!e()}catch(e){return!0}}})),kn=W(((e,t)=>{var i=Ft();t.exports=!i((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]}))})),Lm=W(((e,t)=>{var i=Ft();t.exports=!i((function(){var e=function(){}.bind();return"function"!=typeof e||e.hasOwnProperty("prototype")}))})),ar=W(((e,t)=>{var i=Lm(),n=Function.prototype.call;t.exports=i?n.bind(n):function(){return n.apply(n,arguments)}})),b1=W((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=W(((e,t)=>{t.exports=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}}})),Vt=W(((e,t)=>{var i=Lm(),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)}}})),Ns=W(((e,t)=>{var i=Vt(),n=i({}.toString),r=i("".slice);t.exports=function(e){return r(n(e),8,-1)}})),Lf=W(((e,t)=>{var i=Vt(),n=Ft(),r=Ns(),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})),na=W(((e,t)=>{t.exports=function(e){return null==e}})),Qi=W(((e,t)=>{var i=na(),n=TypeError;t.exports=function(e){if(i(e))throw n("Can't call method on "+e);return e}})),cs=W(((e,t)=>{var i=Lf(),n=Qi();t.exports=function(e){return i(n(e))}})),zP=W(((e,t)=>{var i="object"==typeof document&&document.all,n=void 0===i&&void 0!==i;t.exports={all:i,IS_HTMLDDA:n}})),yr=W(((e,t)=>{var i=zP(),n=i.all;t.exports=i.IS_HTMLDDA?function(e){return"function"==typeof e||e===n}:function(e){return"function"==typeof e}})),xr=W(((e,t)=>{var i=yr(),n=zP(),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)}})),fi=W(((e,t)=>{var i=sn(),n=yr();t.exports=function(e,t){return arguments.length<2?function(e){return n(e)?e:void 0}(i[e]):i[e]&&i[e][t]}})),lo=W(((e,t)=>{var i=Vt();t.exports=i({}.isPrototypeOf)})),Tc=W(((e,t)=>{t.exports="undefined"!=typeof navigator&&String(navigator.userAgent)||""})),wc=W(((e,t)=>{var i,n,r=sn(),a=Tc(),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})),Of=W(((e,t)=>{var i=wc(),n=Ft(),r=sn().String;t.exports=!!Object.getOwnPropertySymbols&&!n((function(){var e=Symbol();return!r(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&i&&i<41}))})),jP=W(((e,t)=>{var i=Of();t.exports=i&&!Symbol.sham&&"symbol"==typeof Symbol.iterator})),Jh=W(((e,t)=>{var i=fi(),n=yr(),r=lo(),a=jP(),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))}})),Qh=W(((e,t)=>{var i=String;t.exports=function(e){try{return i(e)}catch(e){return"Object"}}})),Ni=W(((e,t)=>{var i=yr(),n=Qh(),r=TypeError;t.exports=function(e){if(i(e))return e;throw r(n(e)+" is not a function")}})),Sc=W(((e,t)=>{var i=Ni(),n=na();t.exports=function(e,t){var r=e[t];return n(r)?void 0:i(r)}})),$P=W(((e,t)=>{var i=ar(),n=yr(),r=xr(),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")}})),Bi=W(((e,t)=>{t.exports=!1})),V_=W(((e,t)=>{var i=sn(),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}})),z_=W(((e,t)=>{var i=sn(),n=V_(),r="__core-js_shared__",a=i[r]||n(r,{});t.exports=a})),kf=W(((e,t)=>{var i=Bi(),n=z_();(t.exports=function(e,t){return n[e]||(n[e]=void 0!==t?t:{})})("versions",[]).push({version:"3.30.2",mode:i?"pure":"global",copyright:"\xa9 2014-2023 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.30.2/LICENSE",source:"https://github.com/zloirock/core-js"})})),Ur=W(((e,t)=>{var i=Qi(),n=Object;t.exports=function(e){return n(i(e))}})),Lr=W(((e,t)=>{var i=Vt(),n=Ur(),r=i({}.hasOwnProperty);t.exports=Object.hasOwn||function(e,t){return r(n(e),t)}})),Ff=W(((e,t)=>{var i=Vt(),n=0,r=Math.random(),a=i(1..toString);t.exports=function(e){return"Symbol("+(void 0===e?"":e)+")_"+a(++n+r,36)}})),br=W(((e,t)=>{var i=sn(),n=kf(),r=Lr(),a=Ff(),s=Of(),o=jP(),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]}})),E1=W(((e,t)=>{var i=ar(),n=xr(),r=Jh(),a=Sc(),s=$P(),o=br(),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)}})),ku=W(((e,t)=>{var i=E1(),n=Jh();t.exports=function(e){var t=i(e,"string");return n(t)?t:t+""}})),_1=W(((e,t)=>{var i=sn(),n=xr(),r=i.document,a=n(r)&&n(r.createElement);t.exports=function(e){return a?r.createElement(e):{}}})),JP=W(((e,t)=>{var i=kn(),n=Ft(),r=_1();t.exports=!i&&!n((function(){return 7!=Object.defineProperty(r("div"),"a",{get:function(){return 7}}).a}))})),Rs=W((e=>{var t=kn(),i=ar(),n=b1(),r=oo(),a=cs(),s=ku(),o=Lr(),l=JP(),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])}})),QP=W(((e,t)=>{var i=kn(),n=Ft();t.exports=i&&n((function(){return 42!=Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype}))})),nr=W(((e,t)=>{var i=xr(),n=String,r=TypeError;t.exports=function(e){if(i(e))return e;throw r(n(e)+" is not an object")}})),Ei=W((e=>{var t=kn(),i=JP(),n=QP(),r=nr(),a=ku(),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}})),Bs=W(((e,t)=>{var i=kn(),n=Ei(),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}})),Nf=W(((e,t)=>{var i=kn(),n=Lr(),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}})),q_=W(((e,t)=>{var i=Vt(),n=yr(),r=z_(),a=i(Function.toString);n(r.inspectSource)||(r.inspectSource=function(e){return a(e)}),t.exports=r.inspectSource})),o3=W(((e,t)=>{var i=sn(),n=yr(),r=i.WeakMap;t.exports=n(r)&&/native code/.test(String(r))})),T1=W(((e,t)=>{var i=kf(),n=Ff(),r=i("keys");t.exports=function(e){return r[e]||(r[e]=n(e))}})),km=W(((e,t)=>{t.exports={}})),es=W(((e,t)=>{var i,n,r,a,s,o=o3(),l=sn(),h=xr(),c=Bs(),u=Lr(),d=z_(),p=T1(),f=km(),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}}}})),$_=W(((e,t)=>{var i=Vt(),n=Ft(),r=yr(),a=Lr(),s=kn(),o=Nf().CONFIGURABLE,l=q_(),h=es(),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")})),Mi=W(((e,t)=>{var i=yr(),n=Ei(),r=$_(),a=V_();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}})),f3=W(((e,t)=>{var i=Math.ceil,n=Math.floor;t.exports=Math.trunc||function(e){var t=+e;return(t>0?n:i)(t)}})),Hi=W(((e,t)=>{var i=f3();t.exports=function(e){var t=+e;return t!=t||0===t?0:i(t)}})),kl=W(((e,t)=>{var i=Hi(),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)}})),Ma=W(((e,t)=>{var i=Hi(),n=Math.min;t.exports=function(e){return e>0?n(i(e),9007199254740991):0}})),Wr=W(((e,t)=>{var i=Ma();t.exports=function(e){return i(e.length)}})),Fm=W(((e,t)=>{var i=cs(),n=kl(),r=Wr(),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)}})),m3=W(((e,t)=>{var i=Vt(),n=Lr(),r=cs(),a=Fm().indexOf,s=km(),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}})),K_=W(((e,t)=>{t.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]})),Fu=W((e=>{var t=m3(),i=K_().concat("length","prototype");e.f=Object.getOwnPropertyNames||function(e){return t(e,i)}})),S1=W((e=>{e.f=Object.getOwnPropertySymbols})),Z_=W(((e,t)=>{var i=fi(),n=Vt(),r=Fu(),a=S1(),s=nr(),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}})),M1=W(((e,t)=>{var i=Lr(),n=Z_(),r=Rs(),a=Ei();t.exports=function(e,t,s){for(var o=n(t),l=a.f,h=r.f,c=0;c{var i=Ft(),n=yr(),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})),We=W(((e,t)=>{var i=sn(),n=Rs().f,r=Bs(),a=Mi(),s=V_(),o=M1(),l=Nm();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)}}})),J_=W(((e,t)=>{var i={};i[br()("toStringTag")]="z",t.exports="[object z]"===String(i)})),Fl=W(((e,t)=>{var i=J_(),n=yr(),r=Ns(),a=br()("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}})),lr=W(((e,t)=>{var i=Fl(),n=String;t.exports=function(e){if("Symbol"===i(e))throw TypeError("Cannot convert a Symbol value to a string");return n(e)}})),Bm=W(((e,t)=>{var i=m3(),n=K_();t.exports=Object.keys||function(e){return i(e,n)}})),eT=W((e=>{var t=kn(),i=QP(),n=Ei(),r=nr(),a=cs(),s=Bm();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}})),v3=W(((e,t)=>{var i=fi();t.exports=i("document","documentElement")})),Ra=W(((e,t)=>{var i,n=nr(),r=eT(),a=K_(),s=km(),o=v3(),l=_1(),h=T1(),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)}})),Mc=W(((e,t)=>{"use strict";var i=ku(),n=Ei(),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}})),Hm=W(((e,t)=>{var i=kl(),n=Wr(),r=Mc(),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=Ns(),n=cs(),r=Fu().f,a=Hm(),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))}})),vs=W(((e,t)=>{var i=$_(),n=Ei();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)}})),E3=W((e=>{var t=br();e.f=t})),iT=W(((e,t)=>{var i=sn();t.exports=i})),ra=W(((e,t)=>{var i=iT(),n=Lr(),r=E3(),a=Ei().f;t.exports=function(e){var t=i.Symbol||(i.Symbol={});n(t,e)||a(t,e,{value:r.f(e)})}})),_3=W(((e,t)=>{var i=ar(),n=fi(),r=br(),a=Mi();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})}})),Aa=W(((e,t)=>{var i=Ei().f,n=Lr(),r=br()("toStringTag");t.exports=function(e,t,a){e&&!a&&(e=e.prototype),e&&!n(e,r)&&i(e,r,{configurable:!0,value:t})}})),Nu=W(((e,t)=>{var i=Ns(),n=Vt();t.exports=function(e){if("Function"===i(e))return n(e)}})),zo=W(((e,t)=>{var i=Nu(),n=Ni(),r=Lm(),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)}}})),Bu=W(((e,t)=>{var i=Ns();t.exports=Array.isArray||function(e){return"Array"==i(e)}})),Hf=W(((e,t)=>{var i=Vt(),n=Ft(),r=yr(),a=Fl(),s=fi(),o=q_(),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})),a7=W(((e,t)=>{var i=Bu(),n=Hf(),r=xr(),a=br()("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}})),Um=W(((e,t)=>{var i=a7();t.exports=function(e,t){return new(i(e))(0===t?0:t)}})),ys=W(((e,t)=>{var i=zo(),n=Vt(),r=Lf(),a=Ur(),s=Wr(),o=Um(),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),M=s(_),S=0,E=v||o,T=t?E(f,M):n||d?E(f,0):void 0;M>S;S++)if((p||S in _)&&(x=w(y=_[S],S,b),e))if(t)T[S]=x;else if(x)switch(e){case 3:return!0;case 5:return y;case 6:return S;case 2:l(T,y)}else switch(e){case 4:return!1;case 7:l(T,y)}return u?-1:h||c?c:T}};t.exports={forEach:h(0),map:h(1),filter:h(2),some:h(3),every:h(4),find:h(5),findIndex:h(6),filterReject:h(7)}})),S7=W((()=>{"use strict";var e=We(),t=sn(),i=ar(),n=Vt(),r=Bi(),a=kn(),s=Of(),o=Ft(),l=Lr(),h=lo(),c=nr(),u=cs(),d=ku(),p=lr(),f=oo(),m=Ra(),g=Bm(),v=Fu(),y=rT(),x=S1(),b=Rs(),_=Ei(),w=eT(),M=b1(),S=Mi(),E=vs(),T=kf(),A=T1(),C=km(),P=Ff(),R=br(),L=E3(),D=ra(),I=_3(),O=Aa(),k=es(),N=ys().forEach,F=A("hidden"),U="Symbol",B="prototype",z=k.set,H=k.getterFor(U),V=Object[B],W=t.Symbol,j=W&&W[B],G=t.TypeError,X=t.QObject,q=b.f,Y=_.f,J=y.f,Z=M.f,K=n([].push),$=T("symbols"),Q=T("op-symbols"),ee=T("wks"),te=!X||!X[B]||!X[B].findChild,ie=a&&o((function(){return 7!=m(Y({},"a",{get:function(){return Y(this,"a",{value:7}).a}})).a}))?function(e,t,i){var n=q(V,t);n&&delete V[t],Y(e,t,i),n&&e!==V&&Y(V,t,n)}:Y,ne=function(e,t){var i=$[e]=m(j);return z(i,{type:U,tag:e,description:t}),a||(i.description=t),i},re=function(e,t,i){e===V&&re(Q,t,i),c(e);var n=d(t);return c(i),l($,n)?(i.enumerable?(l(e,F)&&e[F][n]&&(e[F][n]=!1),i=m(i,{enumerable:f(0,!1)})):(l(e,F)||Y(e,F,f(1,{})),e[F][n]=!0),ie(e,n,i)):Y(e,n,i)},ae=function(e,t){c(e);var n=u(t),r=g(n).concat(he(n));return N(r,(function(t){(!a||i(se,n,t))&&re(e,t,n[t])})),e},se=function(e){var t=d(e),n=i(Z,this,t);return!(this===V&&l($,t)&&!l(Q,t))&&(!(n||!l(this,t)||!l($,t)||l(this,F)&&this[F][t])||n)},oe=function(e,t){var i=u(e),n=d(t);if(i!==V||!l($,n)||l(Q,n)){var r=q(i,n);return r&&l($,n)&&!(l(i,F)&&i[F][n])&&(r.enumerable=!0),r}},le=function(e){var t=J(u(e)),i=[];return N(t,(function(e){!l($,e)&&!l(C,e)&&K(i,e)})),i},he=function(e){var t=e===V,i=J(t?Q:u(e)),n=[];return N(i,(function(e){l($,e)&&(!t||l(V,e))&&K(n,$[e])})),n};s||(S(j=(W=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=P(e),n=function(e){this===V&&i(n,Q,e),l(this,F)&&l(this[F],t)&&(this[F][t]=!1),ie(this,t,f(1,e))};return a&&te&&ie(V,t,{configurable:!0,set:n}),ne(t,e)})[B],"toString",(function(){return H(this).tag})),S(W,"withoutSetter",(function(e){return ne(P(e),e)})),M.f=se,_.f=re,w.f=ae,b.f=oe,v.f=y.f=le,x.f=he,L.f=function(e){return ne(R(e),e)},a&&(E(j,"description",{configurable:!0,get:function(){return H(this).description}}),r||S(V,"propertyIsEnumerable",se,{unsafe:!0}))),e({global:!0,constructor:!0,wrap:!0,forced:!s,sham:!s},{Symbol:W}),N(g(ee),(function(e){D(e)})),e({target:U,stat:!0,forced:!s},{useSetter:function(){te=!0},useSimple:function(){te=!1}}),e({target:"Object",stat:!0,forced:!s,sham:!a},{create:function(e,t){return void 0===t?m(e):ae(m(e),t)},defineProperty:re,defineProperties:ae,getOwnPropertyDescriptor:oe}),e({target:"Object",stat:!0,forced:!s},{getOwnPropertyNames:le}),I(),O(W,U),C[F]=!0})),N3=W(((e,t)=>{var i=Of();t.exports=i&&!!Symbol.for&&!!Symbol.keyFor})),A7=W((()=>{var e=We(),t=fi(),i=Lr(),n=lr(),r=kf(),a=N3(),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}})})),P7=W((()=>{var e=We(),t=Lr(),i=Jh(),n=Qh(),r=kf(),a=N3(),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]}})})),co=W(((e,t)=>{var i=Lm(),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)})})),td=W(((e,t)=>{var i=Vt();t.exports=i([].slice)})),U7=W(((e,t)=>{var i=Vt(),n=Bu(),r=yr(),a=Ns(),s=lr(),o=i([].push);t.exports=function(e){if(r(e))return e;if(n(e)){for(var t=e.length,i=[],l=0;l{var e=We(),t=fi(),i=co(),n=ar(),r=Vt(),a=Ft(),s=yr(),o=Jh(),l=td(),h=U7(),c=Of(),u=String,d=t("JSON","stringify"),p=r(/./.exec),f=r("".charAt),m=r("".charCodeAt),g=r("".replace),v=r(1..toString),y=/[\uD800-\uDFFF]/g,x=/^[\uD800-\uDBFF]$/,b=/^[\uDC00-\uDFFF]$/,_=!c||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")})),M=function(e,t){var r=l(arguments),a=h(t);if(s(a)||void 0!==e&&!o(e))return r[1]=function(e,t){if(s(a)&&(t=n(a,this,u(e),t)),!o(t))return t},i(d,null,r)},S=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=l(arguments),a=i(_?M:d,null,r);return w&&"string"==typeof a?g(a,y,S):a}})})),Q7=W((()=>{var e=We(),t=Of(),i=Ft(),n=S1(),r=Ur();e({target:"Object",stat:!0,forced:!t||i((function(){n.f(1)}))},{getOwnPropertySymbols:function(e){var t=n.f;return t?t(r(e)):[]}})})),eq=W((()=>{S7(),A7(),P7(),H3(),Q7()})),oq=W((()=>{"use strict";var e,t,i,n,r,a,s,o,l=We(),h=kn(),c=sn(),u=Vt(),d=Lr(),p=yr(),f=lo(),m=lr(),g=vs(),v=M1(),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}))})),lq=W((()=>{ra()("asyncIterator")})),cq=W((()=>{ra()("hasInstance")})),uq=W((()=>{ra()("isConcatSpreadable")})),hq=W((()=>{ra()("iterator")})),dq=W((()=>{ra()("match")})),fq=W((()=>{ra()("matchAll")})),pq=W((()=>{ra()("replace")})),mq=W((()=>{ra()("search")})),gq=W((()=>{ra()("species")})),vq=W((()=>{ra()("split")})),yq=W((()=>{var e=ra(),t=_3();e("toPrimitive"),t()})),xq=W((()=>{var e=fi(),t=ra(),i=Aa();t("toStringTag"),i(e("Symbol"),"Symbol")})),bq=W((()=>{ra()("unscopables")})),_q=W(((e,t)=>{var i=Vt(),n=Ni();t.exports=function(e,t,r){try{return i(n(Object.getOwnPropertyDescriptor(e,t)[r]))}catch(e){}}})),V3=W(((e,t)=>{var i=yr(),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")}})),Nl=W(((e,t)=>{var i=_q(),n=nr(),r=V3();t.exports=Object.setPrototypeOf||("__proto__"in{}?function(){var e,t=!1,a={};try{(e=i(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)})),z3=W(((e,t)=>{var i=Ei().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}})}})),Gf=W(((e,t)=>{var i=yr(),n=xr(),r=Nl();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}})),Gm=W(((e,t)=>{var i=lr();t.exports=function(e,t){return void 0===e?arguments.length<2?"":t:i(e)}})),G3=W(((e,t)=>{var i=xr(),n=Bs();t.exports=function(e,t){i(t)&&"cause"in t&&n(e,"cause",t.cause)}})),dT=W(((e,t)=>{var i=Vt(),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}})),q3=W(((e,t)=>{var i=Ft(),n=oo();t.exports=!i((function(){var e=Error("a");return!("stack"in e)||(Object.defineProperty(e,"stack",n(1,7)),7!==e.stack)}))})),j3=W(((e,t)=>{var i=Bs(),n=dT(),r=q3(),a=Error.captureStackTrace;t.exports=function(e,t,s,o){r&&(a?a(e,t):i(e,"stack",n(s,o)))}})),W3=W(((e,t)=>{"use strict";var i=fi(),n=Lr(),r=Bs(),a=lo(),s=Nl(),o=M1(),l=z3(),h=Gf(),c=Gm(),u=G3(),d=j3(),p=kn(),f=Bi();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 M=i("Error"),S=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,S,n.stack,2),this&&a(w,this)&&h(n,this,S),arguments.length>y&&u(n,arguments[y]),n}));if(S.prototype=w,"Error"!==b?s?s(S,M):o(S,M,{name:!0}):p&&v in _&&(l(S,_,v),l(S,_,"prepareStackTrace")),o(S,_),!f)try{w.name!==b&&r(w,"name",b),w.constructor=S}catch(e){}return S}}})),Wq=W((()=>{var e=We(),t=sn(),i=co(),n=W3(),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)}}))})),$3=W(((e,t)=>{"use strict";var i=kn(),n=Ft(),r=nr(),a=Ra(),s=Gm(),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})),Zq=W((()=>{var e=Mi(),t=$3(),i=Error.prototype;i.toString!==t&&e(i,"toString",t)})),mT=W(((e,t)=>{var i=Ft();t.exports=!i((function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype}))})),uo=W(((e,t)=>{var i=Lr(),n=yr(),r=Ur(),a=T1(),s=mT(),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}})),qm=W(((e,t)=>{t.exports={}})),gT=W(((e,t)=>{var i=br(),n=qm(),r=i("iterator"),a=Array.prototype;t.exports=function(e){return void 0!==e&&(n.Array===e||a[r]===e)}})),jm=W(((e,t)=>{var i=Fl(),n=Sc(),r=na(),a=qm(),s=br()("iterator");t.exports=function(e){if(!r(e))return n(e,s)||n(e,"@@iterator")||a[i(e)]}})),k1=W(((e,t)=>{var i=ar(),n=Ni(),r=nr(),a=Qh(),s=jm(),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")}})),Z3=W(((e,t)=>{var i=ar(),n=nr(),r=Sc();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}})),Bl=W(((e,t)=>{var i=zo(),n=ar(),r=nr(),a=Qh(),s=gT(),o=Wr(),l=lo(),h=k1(),c=jm(),u=Z3(),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,M=m&&m.that,S=!(!m||!m.AS_ENTRIES),E=!(!m||!m.IS_RECORD),T=!(!m||!m.IS_ITERATOR),A=!(!m||!m.INTERRUPTED),C=i(t,M),P=function(e){return g&&u(g,"normal",e),new p(!0,e)},R=function(e){return S?(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)}})),f9=W((()=>{"use strict";var e=We(),t=lo(),i=uo(),n=Nl(),r=M1(),a=Ra(),s=Bs(),o=oo(),l=G3(),h=j3(),c=Bl(),u=Gm(),d=br()("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})})),p9=W((()=>{f9()})),y9=W((()=>{var e=We(),t=fi(),i=co(),n=Ft(),r=W3(),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)})})),ia=W(((e,t)=>{var i=br(),n=Ra(),r=Ei().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}})),b9=W((()=>{"use strict";var e=We(),t=Ur(),i=Wr(),n=Hi(),r=ia();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")})),jf=W(((e,t)=>{var i=TypeError;t.exports=function(e){if(e>9007199254740991)throw i("Maximum allowed index exceeded");return e}})),Xm=W(((e,t)=>{var i=Ft(),n=br(),r=wc(),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}))}})),M9=W((()=>{"use strict";var e=We(),t=Ft(),i=Bu(),n=xr(),r=Ur(),a=Wr(),s=jf(),o=Mc(),l=Um(),h=Xm(),c=br(),u=wc(),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=Qh(),n=TypeError;t.exports=function(e,t){if(!delete e[t])throw n("Cannot delete property "+i(t)+" of "+i(e))}})),sI=W(((e,t)=>{"use strict";var i=Ur(),n=kl(),r=Wr(),a=F1(),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}})),P9=W((()=>{var e=We(),t=sI(),i=ia();e({target:"Array",proto:!0},{copyWithin:t}),i("copyWithin")})),Ac=W(((e,t)=>{"use strict";var i=Ft();t.exports=function(e,t){var n=[][e];return!!n&&i((function(){n.call(null,t||function(){return 1},1)}))}})),D9=W((()=>{"use strict";var e=We(),t=ys().every;e({target:"Array",proto:!0,forced:!Ac()("every")},{every:function(e){return t(this,e,arguments.length>1?arguments[1]:void 0)}})})),bT=W(((e,t)=>{"use strict";var i=Ur(),n=kl(),r=Wr();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}})),k9=W((()=>{var e=We(),t=bT(),i=ia();e({target:"Array",proto:!0},{fill:t}),i("fill")})),F9=W((()=>{"use strict";var e=We(),t=ys().filter;e({target:"Array",proto:!0,forced:!Xm()("filter")},{filter:function(e){return t(this,e,arguments.length>1?arguments[1]:void 0)}})})),B9=W((()=>{"use strict";var e=We(),t=ys().find,i=ia(),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)})),U9=W((()=>{"use strict";var e=We(),t=ys().findIndex,i=ia(),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)})),N1=W(((e,t)=>{var i=zo(),n=Lf(),r=Ur(),a=Wr(),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)}})),G9=W((()=>{"use strict";var e=We(),t=N1().findLast,i=ia();e({target:"Array",proto:!0},{findLast:function(e){return t(this,e,arguments.length>1?arguments[1]:void 0)}}),i("findLast")})),q9=W((()=>{"use strict";var e=We(),t=N1().findLastIndex,i=ia();e({target:"Array",proto:!0},{findLastIndex:function(e){return t(this,e,arguments.length>1?arguments[1]:void 0)}}),i("findLastIndex")})),lI=W(((e,t)=>{"use strict";var i=Bu(),n=Wr(),r=jf(),a=zo(),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})),X9=W((()=>{"use strict";var e=We(),t=lI(),i=Ur(),n=Wr(),r=Hi(),a=Um();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}})})),Y9=W((()=>{"use strict";var e=We(),t=lI(),i=Ni(),n=Ur(),r=Wr(),a=Um();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}})})),cI=W(((e,t)=>{"use strict";var i=ys().forEach,n=Ac()("forEach");t.exports=n?[].forEach:function(e){return i(this,e,arguments.length>1?arguments[1]:void 0)}})),Z9=W((()=>{"use strict";var e=We(),t=cI();e({target:"Array",proto:!0,forced:[].forEach!=t},{forEach:t})})),Q9=W(((e,t)=>{var i=nr(),n=Z3();t.exports=function(e,t,r,a){try{return a?t(i(r)[0],r[1]):t(r)}catch(t){n(e,"throw",t)}}})),uI=W(((e,t)=>{"use strict";var i=zo(),n=ar(),r=Ur(),a=Q9(),s=gT(),o=Hf(),l=Wr(),h=Mc(),c=k1(),u=jm(),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,M=u(t),S=0;if(!M||this===d&&s(M))for(v=l(t),y=p?new this(v):d(v);v>S;S++)w=g?m(t[S],S):t[S],h(y,S,w);else for(_=(b=c(t,M)).next,y=p?new this:[];!(x=n(_,b)).done;S++)w=g?a(b,m,[x.value,S],!0):x.value,h(y,S,w);return y.length=S,y}})),B1=W(((e,t)=>{var i,n,r=br()("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}})),oj=W((()=>{var e=We(),t=uI();e({target:"Array",stat:!0,forced:!B1()((function(e){Array.from(e)}))},{from:t})})),lj=W((()=>{"use strict";var e=We(),t=Fm().includes,i=Ft(),n=ia();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")})),uj=W((()=>{"use strict";var e=We(),t=Nu(),i=Fm().indexOf,n=Ac(),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)}})})),hj=W((()=>{We()({target:"Array",stat:!0},{isArray:Bu()})})),gI=W(((e,t)=>{"use strict";var i,n,r,a=Ft(),s=yr(),o=xr(),l=Ra(),h=uo(),c=Mi(),u=br(),d=Bi(),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}})),ET=W(((e,t)=>{"use strict";var i=gI().IteratorPrototype,n=Ra(),r=oo(),a=Aa(),s=qm(),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}})),wT=W(((e,t)=>{"use strict";var i=We(),n=ar(),r=Bi(),a=Nf(),s=yr(),o=ET(),l=uo(),h=Nl(),c=Aa(),u=Bs(),d=Mi(),p=br(),f=qm(),m=gI(),g=a.PROPER,v=a.CONFIGURABLE,y=m.IteratorPrototype,x=m.BUGGY_SAFARI_ITERATORS,b=p("iterator"),_="keys",w="values",M="entries",S=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 M:return function(){return new a(this,e)}}return function(){return new a(this)}},L=t+" Iterator",D=!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,S)),c(A,L,!0,!0),r&&(f[L]=S)),g&&m==w&&O&&O.name!==w&&(!r&&v?u(I,"name",w):(D=!0,k=function(){return n(O,this)})),m)if(C={values:R(w),keys:E?k:R(_),entries:R(M)},T)for(P in C)(x||D||!(P in I))&&d(I,P,C[P]);else i({target:t,proto:!0,forced:x||D},C);return(!r||T)&&I[b]!==k&&d(I,b,k,{name:m}),f[t]=k,C}})),V1=W(((e,t)=>{t.exports=function(e,t){return{value:e,done:t}}})),z1=W(((e,t)=>{"use strict";var i=cs(),n=ia(),r=qm(),a=es(),s=Ei().f,o=wT(),l=V1(),h=Bi(),c=kn(),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){}})),Dj=W((()=>{"use strict";var e=We(),t=Vt(),i=Lf(),n=cs(),r=Ac(),a=t([].join);e({target:"Array",proto:!0,forced:i!=Object||!r("join",",")},{join:function(e){return a(n(this),void 0===e?",":e)}})})),bI=W(((e,t)=>{"use strict";var i=co(),n=cs(),r=Hi(),a=Wr(),s=Ac(),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})),Fj=W((()=>{var e=We(),t=bI();e({target:"Array",proto:!0,forced:t!==[].lastIndexOf},{lastIndexOf:t})})),Nj=W((()=>{"use strict";var e=We(),t=ys().map;e({target:"Array",proto:!0,forced:!Xm()("map")},{map:function(e){return t(this,e,arguments.length>1?arguments[1]:void 0)}})})),Hj=W((()=>{"use strict";var e=We(),t=Ft(),i=Hf(),n=Mc(),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}})})),MT=W(((e,t)=>{"use strict";var i=kn(),n=Bu(),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}})),Vj=W((()=>{"use strict";var e=We(),t=Ur(),i=Wr(),n=MT(),r=jf();e({target:"Array",proto:!0,arity:1,forced:Ft()((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=Ni(),n=Ur(),r=Lf(),a=Wr(),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)}})),Cc=W(((e,t)=>{var i=Ns();t.exports="undefined"!=typeof process&&"process"==i(process)})),Wj=W((()=>{"use strict";var e=We(),t=G1().left,i=Ac(),n=wc();e({target:"Array",proto:!0,forced:!Cc()&&n>79&&n<83||!i("reduce")},{reduce:function(e){var i=arguments.length;return t(this,e,i,i>1?arguments[1]:void 0)}})})),Yj=W((()=>{"use strict";var e=We(),t=G1().right,i=Ac(),n=wc();e({target:"Array",proto:!0,forced:!Cc()&&n>79&&n<83||!i("reduceRight")},{reduceRight:function(e){return t(this,e,arguments.length,arguments.length>1?arguments[1]:void 0)}})})),Kj=W((()=>{"use strict";var e=We(),t=Vt(),i=Bu(),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)}})})),Qj=W((()=>{"use strict";var e=We(),t=Bu(),i=Hf(),n=xr(),r=kl(),a=Wr(),s=cs(),o=Mc(),l=br(),h=Xm(),c=td(),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=We(),t=ys().some;e({target:"Array",proto:!0,forced:!Ac()("some")},{some:function(e){return t(this,e,arguments.length>1?arguments[1]:void 0)}})})),RT=W(((e,t)=>{var i=Hm(),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=Tc().match(/firefox\/(\d+)/i);t.exports=!!i&&+i[1]})),wI=W(((e,t)=>{var i=Tc();t.exports=/MSIE|Trident/.test(i)})),AT=W(((e,t)=>{var i=Tc().match(/AppleWebKit\/(\d+)\./);t.exports=!!i&&+i[1]})),gW=W((()=>{"use strict";var e=We(),t=Vt(),i=Ni(),n=Ur(),r=Wr(),a=F1(),s=lr(),o=Ft(),l=RT(),h=Ac(),c=TI(),u=wI(),d=wc(),p=AT(),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=fi(),n=vs(),r=br(),a=kn(),s=r("species");t.exports=function(e){var t=i(e);a&&t&&!t[s]&&n(t,s,{configurable:!0,get:function(){return this}})}})),xW=W((()=>{Wf()("Array")})),bW=W((()=>{"use strict";var e=We(),t=Ur(),i=kl(),n=Hi(),r=Wr(),a=MT(),s=jf(),o=Um(),l=Mc(),h=F1(),c=Xm()("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{var i=Wr();t.exports=function(e,t){for(var n=i(e),r=new t(n),a=0;a{"use strict";var e=We(),t=RI(),i=cs(),n=ia(),r=Array;e({target:"Array",proto:!0},{toReversed:function(){return t(i(this),r)}}),n("toReversed")})),CT=W(((e,t)=>{var i=Wr();t.exports=function(e,t){for(var n=0,r=i(t),a=new e(r);r>n;)a[n]=t[n++];return a}})),SW=W(((e,t)=>{var i=sn();t.exports=function(e){return i[e].prototype}})),MW=W((()=>{"use strict";var e=We(),t=Vt(),i=Ni(),n=cs(),r=CT(),a=SW(),s=ia(),o=Array,l=t(a("Array").sort);e({target:"Array",proto:!0},{toSorted:function(e){void 0!==e&&i(e);var t=n(this),a=r(o,t);return l(a,e)}}),s("toSorted")})),RW=W((()=>{"use strict";var e=We(),t=ia(),i=jf(),n=Wr(),r=kl(),a=cs(),s=Hi(),o=Array,l=Math.max,h=Math.min;e({target:"Array",proto:!0},{toSpliced:function(e,t){var c,u,d,p,f=a(this),m=n(f),g=r(e,m),v=arguments.length,y=0;for(0===v?c=u=0:1===v?(c=0,u=m-g):(c=v-2,u=h(l(s(t),0),m-g)),d=i(m+c-u),p=o(d);y{ia()("flat")})),CW=W((()=>{ia()("flatMap")})),PW=W((()=>{"use strict";var e=We(),t=Ur(),i=Wr(),n=MT(),r=F1(),a=jf();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{var i=Wr(),n=Hi(),r=RangeError;t.exports=function(e,t,a,s){var o=i(e),l=n(a),h=l<0?o+l:l;if(h>=o||h<0)throw r("Incorrect index");for(var c=new t(o),u=0;u{"use strict";var e=We(),t=AI(),i=cs(),n=Array;e({target:"Array",proto:!0},{with:function(e,r){return t(i(this),n,e,r)}})})),PT=W(((e,t)=>{t.exports="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof DataView})),Ym=W(((e,t)=>{var i=Mi();t.exports=function(e,t,n){for(var r in t)i(e,r,t[r],n);return e}})),Hl=W(((e,t)=>{var i=lo(),n=TypeError;t.exports=function(e,t){if(i(t,e))return e;throw n("Incorrect invocation")}})),CI=W(((e,t)=>{var i=Hi(),n=Ma(),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}})),BW=W(((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)}}})),W1=W(((e,t)=>{"use strict";var i,n,r,a,s,o,l=sn(),h=Vt(),c=kn(),u=PT(),d=Nf(),p=Bs(),f=vs(),m=Ym(),g=Ft(),v=Hl(),y=Hi(),x=Ma(),b=CI(),_=BW(),w=uo(),M=Nl(),S=Fu().f,E=bT(),T=Hm(),A=Aa(),C=es(),P=d.PROPER,R=d.CONFIGURABLE,L="ArrayBuffer",D="DataView",I="prototype",O="Wrong index",k=C.getterFor(L),N=C.getterFor(D),F=C.set,U=l[L],B=U,z=B&&B[I],H=l[D],V=H&&H[I],W=Object.prototype,j=l.Array,G=l.RangeError,X=h(E),q=h([].reverse),Y=_.pack,J=_.unpack,Z=function(e){return[255&e]},K=function(e){return[255&e,e>>8&255]},$=function(e){return[255&e,e>>8&255,e>>16&255,e>>24&255]},Q=function(e){return e[3]<<24|e[2]<<16|e[1]<<8|e[0]},ee=function(e){return Y(e,23,4)},te=function(e){return Y(e,52,8)},ie=function(e,t,i){f(e[I],t,{configurable:!0,get:function(){return i(this)[t]}})},ne=function(e,t,i,n){var r=b(i),a=N(e);if(r+t>a.byteLength)throw G(O);var s=a.bytes,o=r+a.byteOffset,l=T(s,o,o+t);return n?l:q(l)},re=function(e,t,i,n,r,a){var s=b(i),o=N(e);if(s+t>o.byteLength)throw G(O);for(var l=o.bytes,h=s+o.byteOffset,c=n(+r),u=0;ur;)(a=n[r++])in B||p(B,a,U[a]);z.constructor=B}M&&w(V)!==W&&M(V,W),s=new H(new B(2)),o=h(V.setInt8),s.setInt8(0,2147483648),s.setInt8(1,2147483649),(s.getInt8(0)||!s.getInt8(1))&&m(V,{setInt8:function(e,t){o(this,e,t<<24>>24)},setUint8:function(e,t){o(this,e,t<<24>>24)}},{unsafe:!0})}else z=(B=function(e){v(this,z);var t=b(e);F(this,{type:L,bytes:X(j(t),0),byteLength:t}),c||(this.byteLength=t,this.detached=!1)})[I],V=(H=function(e,t,i){v(this,V),v(e,z);var n=k(e),r=n.byteLength,a=y(t);if(a<0||a>r)throw G("Wrong offset");if(a+(i=void 0===i?r-a:x(i))>r)throw G("Wrong length");F(this,{type:D,buffer:e,byteLength:i,byteOffset:a,bytes:n.bytes}),c||(this.buffer=e,this.byteLength=i,this.byteOffset=a)})[I],c&&(ie(B,"byteLength",k),ie(H,"buffer",N),ie(H,"byteLength",N),ie(H,"byteOffset",N)),m(V,{getInt8:function(e){return ne(this,1,e)[0]<<24>>24},getUint8:function(e){return ne(this,1,e)[0]},getInt16:function(e){var t=ne(this,2,e,arguments.length>1?arguments[1]:void 0);return(t[1]<<8|t[0])<<16>>16},getUint16:function(e){var t=ne(this,2,e,arguments.length>1?arguments[1]:void 0);return t[1]<<8|t[0]},getInt32:function(e){return Q(ne(this,4,e,arguments.length>1?arguments[1]:void 0))},getUint32:function(e){return Q(ne(this,4,e,arguments.length>1?arguments[1]:void 0))>>>0},getFloat32:function(e){return J(ne(this,4,e,arguments.length>1?arguments[1]:void 0),23)},getFloat64:function(e){return J(ne(this,8,e,arguments.length>1?arguments[1]:void 0),52)},setInt8:function(e,t){re(this,1,e,Z,t)},setUint8:function(e,t){re(this,1,e,Z,t)},setInt16:function(e,t){re(this,2,e,K,t,arguments.length>2?arguments[2]:void 0)},setUint16:function(e,t){re(this,2,e,K,t,arguments.length>2?arguments[2]:void 0)},setInt32:function(e,t){re(this,4,e,$,t,arguments.length>2?arguments[2]:void 0)},setUint32:function(e,t){re(this,4,e,$,t,arguments.length>2?arguments[2]:void 0)},setFloat32:function(e,t){re(this,4,e,ee,t,arguments.length>2?arguments[2]:void 0)},setFloat64:function(e,t){re(this,8,e,te,t,arguments.length>2?arguments[2]:void 0)}});A(B,L),A(H,D),t.exports={ArrayBuffer:B,DataView:H}})),iX=W((()=>{"use strict";var e=We(),t=sn(),i=W1(),n=Wf(),r="ArrayBuffer",a=i[r];e({global:!0,constructor:!0,forced:t[r]!==a},{ArrayBuffer:a}),n(r)})),hr=W(((e,t)=>{"use strict";var i,n,r,a=PT(),s=kn(),o=sn(),l=yr(),h=xr(),c=Lr(),u=Fl(),d=Qh(),p=Bs(),f=Mi(),m=vs(),g=lo(),v=uo(),y=Nl(),x=br(),b=Ff(),_=es(),w=_.enforce,M=_.get,S=o.Int8Array,E=S&&S.prototype,T=o.Uint8ClampedArray,A=T&&T.prototype,C=S&&v(S),P=E&&v(E),R=Object.prototype,L=o.TypeError,D=x("toStringTag"),I=b("TYPED_ARRAY_TAG"),O="TypedArrayConstructor",k=a&&!!y&&"Opera"!==u(o.opera),N=!1,F={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8},U={BigInt64Array:8,BigUint64Array:8},B=function(e){var t=v(e);if(h(t)){var i=M(t);return i&&c(i,O)?i[O]:B(t)}},z=function(e){if(!h(e))return!1;var t=u(e);return c(F,t)||c(U,t)};for(i in F)(r=(n=o[i])&&n.prototype)?w(r)[O]=n:k=!1;for(i in U)(r=(n=o[i])&&n.prototype)&&(w(r)[O]=n);if((!k||!l(C)||C===Function.prototype)&&(C=function(){throw L("Incorrect invocation")},k))for(i in F)o[i]&&y(o[i],C);if((!k||!P||P===R)&&(P=C.prototype,k))for(i in F)o[i]&&y(o[i].prototype,P);if(k&&v(A)!==P&&y(A,P),s&&!c(P,D))for(i in N=!0,m(P,D,{configurable:!0,get:function(){return h(this)?this[I]:void 0}}),F)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 L("Target is not a typed array")},aTypedArrayConstructor:function(e){if(l(e)&&(!y||g(C,e)))return e;throw L(d(e)+" is not a typed array constructor")},exportTypedArrayMethod:function(e,t,i,n){if(s){if(i)for(var r in F){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 F)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 F)(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(F,t)||c(U,t)},isTypedArray:z,TypedArray:C,TypedArrayPrototype:P}})),gX=W((()=>{var e=We(),t=hr();e({target:"ArrayBuffer",stat:!0,forced:!t.NATIVE_ARRAY_BUFFER_VIEWS},{isView:t.isView})})),zT=W(((e,t)=>{var i=Hf(),n=Qh(),r=TypeError;t.exports=function(e){if(i(e))return e;throw r(n(e)+" is not a constructor")}})),Yf=W(((e,t)=>{var i=nr(),n=zT(),r=na(),a=br()("species");t.exports=function(e,t){var s,o=i(e).constructor;return void 0===o||r(s=i(o)[a])?t:n(s)}})),SX=W((()=>{"use strict";var e=We(),t=Nu(),i=Ft(),n=W1(),r=nr(),a=kl(),s=Ma(),o=Yf(),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=We(),t=W1();e({global:!0,constructor:!0,forced:!PT()},{DataView:t.DataView})})),RX=W((()=>{MX()})),AX=W((()=>{"use strict";var e=We(),t=Vt(),i=Ft()((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}})})),PX=W((()=>{var e=We(),t=Vt(),i=Date,n=t(i.prototype.getTime);e({target:"Date",stat:!0},{now:function(){return n(new i)}})})),LX=W((()=>{"use strict";var e=We(),t=Vt(),i=Hi(),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)}})})),OX=W((()=>{We()({target:"Date",proto:!0},{toGMTString:Date.prototype.toUTCString})})),X1=W(((e,t)=>{"use strict";var i=Hi(),n=lr(),r=Qi(),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}})),GT=W(((e,t)=>{var i=Vt(),n=Ma(),r=lr(),a=X1(),s=Qi(),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)}})),zX=W(((e,t)=>{"use strict";var i=Vt(),n=Ft(),r=GT().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})),qX=W((()=>{var e=We(),t=zX();e({target:"Date",proto:!0,forced:Date.prototype.toISOString!==t},{toISOString:t})})),jX=W((()=>{"use strict";var e=We(),t=Ft(),i=Ur(),n=E1();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}})})),XX=W(((e,t)=>{"use strict";var i=nr(),n=$P(),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)}})),KX=W((()=>{var e=Lr(),t=Mi(),i=XX(),n=br()("toPrimitive"),r=Date.prototype;e(r,n)||t(r,n,i)})),eY=W((()=>{var e=Vt(),t=Mi(),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}))})),nY=W((()=>{"use strict";var e=We(),t=Vt(),i=lr(),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=Vt(),n=Ni(),r=xr(),a=Lr(),s=td(),o=Lm(),l=Function,h=i([].concat),c=i([].join),u={};t.exports=o?l.bind:function(e){var t=n(this),i=t.prototype,o=s(arguments,1),d=function(){var i=h(o,s(arguments));return this instanceof d?function(e,t,i){if(!a(u,t)){for(var n=[],r=0;r{var e=We(),t=JI();e({target:"Function",proto:!0,forced:Function.bind!==t},{bind:t})})),hY=W((()=>{"use strict";var e=yr(),t=xr(),i=Ei(),n=uo(),r=br(),a=$_(),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)})})),mY=W((()=>{var e=kn(),t=Nf().EXISTS,i=Vt(),n=vs(),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""}}})})),gY=W((()=>{var e=We(),t=sn();e({global:!0,forced:t.globalThis!==t},{globalThis:t})})),vY=W((()=>{var e=sn();Aa()(e.JSON,"JSON",!0)})),qT=W(((e,t)=>{var i=Ft();t.exports=i((function(){if("function"==typeof ArrayBuffer){var e=new ArrayBuffer(8);Object.isExtensible(e)&&Object.defineProperty(e,"a",{value:8})}}))})),WT=W(((e,t)=>{var i=Ft(),n=xr(),r=Ns(),a=qT(),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})),Kf=W(((e,t)=>{var i=Ft();t.exports=!i((function(){return Object.isExtensible(Object.preventExtensions({}))}))})),cd=W(((e,t)=>{var i=We(),n=Vt(),r=km(),a=xr(),s=Lr(),o=Ei().f,l=Fu(),h=rT(),c=WT(),u=Ff(),d=Kf(),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=We(),n=sn(),r=Vt(),a=Nm(),s=Mi(),o=cd(),l=Bl(),h=Hl(),c=yr(),u=na(),d=xr(),p=Ft(),f=B1(),m=Aa(),g=Gf();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,M=_,S={},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()})))))M=v.getConstructor(t,e,y,b),o.enable();else if(a(e,!0)){var T=new M,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||((M=t((function(e,t){h(e,w);var i=g(new _,e,M);return u(t)||l(t,i[b],{that:i,AS_ENTRIES:y}),i}))).prototype=w,w.constructor=M),(C||R)&&(E("delete"),E("has"),y&&E("get")),(R||A)&&E(b),x&&w.clear&&delete w.clear}return S[e]=M,i({global:!0,constructor:!0,forced:M!=_},S),m(M,e),x||v.setStrong(M,e,y),M}})),oD=W(((e,t)=>{"use strict";var i=Ra(),n=vs(),r=Ym(),a=zo(),s=Hl(),o=na(),l=Bl(),h=wT(),c=V1(),u=Wf(),d=kn(),p=cd().fastKey,f=es(),m=f.set,g=f.getterFor;t.exports={getConstructor:function(e,t,h,c){var u=e((function(e,n){s(e,f),m(e,{type:t,index:i(null),first:void 0,last:void 0,size:0}),d||(e.size=0),o(n)||l(n,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&&n(f,"size",{configurable:!0,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)}}})),DY=W((()=>{"use strict";$1()("Map",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),oD())})),LY=W((()=>{DY()})),lD=W(((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)}})),FY=W((()=>{var e=We(),t=lD(),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))}})})),HY=W((()=>{var e=We(),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}})})),VY=W((()=>{var e=We(),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}})})),YT=W(((e,t)=>{t.exports=Math.sign||function(e){var t=+e;return 0==t||t!=t?t:t<0?-1:1}})),GY=W((()=>{var e=We(),t=YT(),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)}})})),qY=W((()=>{var e=We(),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}})})),J1=W(((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})),XY=W((()=>{var e=We(),t=J1(),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)}})})),$Y=W((()=>{var e=We(),t=J1();e({target:"Math",stat:!0,forced:t!=Math.expm1},{expm1:t})})),ZY=W(((e,t)=>{var i=YT(),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}})),JY=W((()=>{We()({target:"Math",stat:!0},{fround:ZY()})})),e$=W((()=>{var e=We(),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)}})})),n$=W((()=>{var e=We(),t=Ft(),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=W(((e,t)=>{var i=Math.log,n=Math.LOG10E;t.exports=Math.log10||function(e){return i(e)*n}})),i$=W((()=>{We()({target:"Math",stat:!0},{log10:fD()})})),s$=W((()=>{We()({target:"Math",stat:!0},{log1p:lD()})})),a$=W((()=>{var e=We(),t=Math.log,i=Math.LN2;e({target:"Math",stat:!0},{log2:function(e){return t(e)/i}})})),o$=W((()=>{We()({target:"Math",stat:!0},{sign:YT()})})),u$=W((()=>{var e=We(),t=Ft(),i=J1(),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)}})})),f$=W((()=>{var e=We(),t=J1(),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))}})})),p$=W((()=>{Aa()(Math,"Math",!0)})),m$=W((()=>{We()({target:"Math",stat:!0},{trunc:f3()})})),Q1=W(((e,t)=>{var i=Vt();t.exports=i(1..valueOf)})),ey=W(((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"})),Zf=W(((e,t)=>{var i=Vt(),n=Qi(),r=lr(),a=ey(),s=i("".replace),o=RegExp("^["+a+"]+"),l=RegExp("(^|[^"+a+"])["+a+"]+$"),h=function(e){return function(t){var i=r(n(t));return 1&e&&(i=s(i,o,"")),2&e&&(i=s(i,l,"$1")),i}};t.exports={start:h(1),end:h(2),trim:h(3)}})),M$=W((()=>{"use strict";var e=We(),t=Bi(),i=kn(),n=sn(),r=iT(),a=Vt(),s=Nm(),o=Lr(),l=Gf(),h=lo(),c=Jh(),u=E1(),d=Ft(),p=Fu().f,f=Rs().f,m=Ei().f,g=Q1(),v=Zf().trim,y="Number",x=n[y],b=r[y],_=x.prototype,w=n.TypeError,M=a("".slice),S=a("".charCodeAt),E=s(y,!x(" 0o1")||!x("0b1")||x("+0x1")),T=function(e){var t,i=arguments.length<1?0:x(function(e){var t=u(e,"number");return"bigint"==typeof t?t: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=S(h,0))||45===t){if(88===(i=S(h,2))||120===i)return NaN}else if(48===t){switch(S(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=M(h,2)).length,o=0;or)return NaN;return parseInt(a,n)}return+h}(t)}(e));return h(_,t=this)&&d((function(){g(t)}))?l(Object(i),this,T):i};T.prototype=_,E&&!t&&(_.constructor=T),e({global:!0,constructor:!0,wrap:!0,forced:E},{Number:T});var A=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&&A(r[y],b),(E||t)&&A(r[y],x)})),R$=W((()=>{We()({target:"Number",stat:!0,nonConfigurable:!0,nonWritable:!0},{EPSILON:Math.pow(2,-52)})})),C$=W(((e,t)=>{var i=sn().isFinite;t.exports=Number.isFinite||function(e){return"number"==typeof e&&i(e)}})),P$=W((()=>{We()({target:"Number",stat:!0},{isFinite:C$()})})),QT=W(((e,t)=>{var i=xr(),n=Math.floor;t.exports=Number.isInteger||function(e){return!i(e)&&isFinite(e)&&n(e)===e}})),D$=W((()=>{We()({target:"Number",stat:!0},{isInteger:QT()})})),L$=W((()=>{We()({target:"Number",stat:!0},{isNaN:function(e){return e!=e}})})),O$=W((()=>{var e=We(),t=QT(),i=Math.abs;e({target:"Number",stat:!0},{isSafeInteger:function(e){return t(e)&&i(e)<=9007199254740991}})})),k$=W((()=>{We()({target:"Number",stat:!0,nonConfigurable:!0,nonWritable:!0},{MAX_SAFE_INTEGER:9007199254740991})})),F$=W((()=>{We()({target:"Number",stat:!0,nonConfigurable:!0,nonWritable:!0},{MIN_SAFE_INTEGER:-9007199254740991})})),bD=W(((e,t)=>{var i=sn(),n=Ft(),r=Vt(),a=lr(),s=Zf().trim,o=ey(),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})),z$=W((()=>{var e=We(),t=bD();e({target:"Number",stat:!0,forced:Number.parseFloat!=t},{parseFloat:t})})),ED=W(((e,t)=>{var i=sn(),n=Ft(),r=Vt(),a=lr(),s=Zf().trim,o=ey(),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})),K$=W((()=>{var e=We(),t=ED();e({target:"Number",stat:!0,forced:Number.parseInt!=t},{parseInt:t})})),tK=W((()=>{"use strict";var e=We(),t=Vt(),i=Hi(),n=Q1(),r=X1(),a=fD(),s=Ft(),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 M=0,S=d(10,x-r);2*t>=(2*(M=p(t/S))+1)*S&&(M+=1),M>=d(10,r+1)&&(M/=10,x+=1),y=l(M)}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+_}})})),oK=W((()=>{"use strict";var e=We(),t=Vt(),i=Hi(),n=Q1(),r=X1(),a=Ft(),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}})})),uK=W((()=>{"use strict";var e=We(),t=Vt(),i=Ft(),n=Q1(),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)}})})),AD=W(((e,t)=>{"use strict";var i=kn(),n=Vt(),r=ar(),a=Ft(),s=Bm(),o=S1(),l=b1(),h=Ur(),c=Lf(),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})),mK=W((()=>{var e=We(),t=AD();e({target:"Object",stat:!0,arity:2,forced:Object.assign!==t},{assign:t})})),gK=W((()=>{We()({target:"Object",stat:!0,sham:!kn()},{create:Ra()})})),iy=W(((e,t)=>{"use strict";var i=Bi(),n=sn(),r=Ft(),a=AT();t.exports=i||!r((function(){if(!(a&&a<535)){var e=Math.random();__defineSetter__.call(null,e,(function(){})),delete n[e]}}))})),xK=W((()=>{"use strict";var e=We(),t=kn(),i=iy(),n=Ni(),r=Ur(),a=Ei();t&&e({target:"Object",proto:!0,forced:i},{__defineGetter__:function(e,t){a.f(r(this),e,{get:n(t),enumerable:!0,configurable:!0})}})})),EK=W((()=>{var e=We(),t=kn(),i=eT().f;e({target:"Object",stat:!0,forced:Object.defineProperties!==i,sham:!t},{defineProperties:i})})),TK=W((()=>{var e=We(),t=kn(),i=Ei().f;e({target:"Object",stat:!0,forced:Object.defineProperty!==i,sham:!t},{defineProperty:i})})),wK=W((()=>{"use strict";var e=We(),t=kn(),i=iy(),n=Ni(),r=Ur(),a=Ei();t&&e({target:"Object",proto:!0,forced:i},{__defineSetter__:function(e,t){a.f(r(this),e,{set:n(t),enumerable:!0,configurable:!0})}})})),CD=W(((e,t)=>{var i=kn(),n=Vt(),r=Bm(),a=cs(),s=n(b1().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)}})),AK=W((()=>{var e=We(),t=CD().entries;e({target:"Object",stat:!0},{entries:function(e){return t(e)}})})),CK=W((()=>{var e=We(),t=Kf(),i=Ft(),n=xr(),r=cd().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}})})),PK=W((()=>{var e=We(),t=Bl(),i=Mc();e({target:"Object",stat:!0},{fromEntries:function(e){var n={};return t(e,(function(e,t){i(n,e,t)}),{AS_ENTRIES:!0}),n}})})),LK=W((()=>{var e=We(),t=Ft(),i=cs(),n=Rs().f,r=kn();e({target:"Object",stat:!0,forced:!r||t((function(){n(1)})),sham:!r},{getOwnPropertyDescriptor:function(e,t){return n(i(e),t)}})})),OK=W((()=>{var e=We(),t=kn(),i=Z_(),n=cs(),r=Rs(),a=Mc();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}})})),kK=W((()=>{var e=We(),t=Ft(),i=rT().f;e({target:"Object",stat:!0,forced:t((function(){return!Object.getOwnPropertyNames(1)}))},{getOwnPropertyNames:i})})),NK=W((()=>{var e=We(),t=Ft(),i=Ur(),n=uo(),r=mT();e({target:"Object",stat:!0,forced:t((function(){n(1)})),sham:!r},{getPrototypeOf:function(e){return n(i(e))}})})),BK=W((()=>{We()({target:"Object",stat:!0},{hasOwn:Lr()})})),ID=W(((e,t)=>{t.exports=Object.is||function(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}})),UK=W((()=>{We()({target:"Object",stat:!0},{is:ID()})})),zK=W((()=>{var e=We(),t=WT();e({target:"Object",stat:!0,forced:Object.isExtensible!==t},{isExtensible:t})})),qK=W((()=>{var e=We(),t=Ft(),i=xr(),n=Ns(),r=qT(),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)}})})),WK=W((()=>{var e=We(),t=Ft(),i=xr(),n=Ns(),r=qT(),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)}})})),YK=W((()=>{var e=We(),t=Ur(),i=Bm();e({target:"Object",stat:!0,forced:Ft()((function(){i(1)}))},{keys:function(e){return i(t(e))}})})),$K=W((()=>{"use strict";var e=We(),t=kn(),i=iy(),n=Ur(),r=ku(),a=uo(),s=Rs().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))}})})),KK=W((()=>{"use strict";var e=We(),t=kn(),i=iy(),n=Ur(),r=ku(),a=uo(),s=Rs().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))}})})),ZK=W((()=>{var e=We(),t=xr(),i=cd().onFreeze,n=Kf(),r=Ft(),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}})})),rZ=W((()=>{"use strict";var e=kn(),t=vs(),i=xr(),n=Ur(),r=Qi(),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){}})),iZ=W((()=>{var e=We(),t=xr(),i=cd().onFreeze,n=Kf(),r=Ft(),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}})})),sZ=W((()=>{We()({target:"Object",stat:!0},{setPrototypeOf:Nl()})})),oZ=W(((e,t)=>{"use strict";var i=J_(),n=Fl();t.exports=i?{}.toString:function(){return"[object "+n(this)+"]"}})),lZ=W((()=>{var e=J_(),t=Mi(),i=oZ();e||t(Object.prototype,"toString",i,{unsafe:!0})})),cZ=W((()=>{var e=We(),t=CD().values;e({target:"Object",stat:!0},{values:function(e){return t(e)}})})),hZ=W((()=>{var e=We(),t=bD();e({global:!0,forced:parseFloat!=t},{parseFloat:t})})),fZ=W((()=>{var e=We(),t=ED();e({global:!0,forced:parseInt!=t},{parseInt:t})})),Lc=W(((e,t)=>{var i=TypeError;t.exports=function(e,t){if(e{var i=Tc();t.exports=/(?:ipad|iphone|ipod).*applewebkit/i.test(i)})),oy=W(((e,t)=>{var i,n,r,a,s=sn(),o=co(),l=zo(),h=yr(),c=Lr(),u=Ft(),d=v3(),p=td(),f=_1(),m=Lc(),g=FD(),v=Cc(),y=s.setImmediate,x=s.clearImmediate,b=s.process,_=s.Dispatch,w=s.Function,M=s.MessageChannel,S=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)},L=function(e){s.postMessage(S(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))}:M&&!g?(a=(r=new M).port2,r.port1.onmessage=R,n=l(a.postMessage,a)):s.addEventListener&&h(s.postMessage)&&!s.importScripts&&i&&"file:"!==i.protocol&&!u(L)?(n=L,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}})),jD=W(((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})),AZ=W(((e,t)=>{var i=Tc();t.exports=/ipad|iphone|ipod/i.test(i)&&"undefined"!=typeof Pebble})),PZ=W(((e,t)=>{var i=Tc();t.exports=/web0s(?!.*chrome)/i.test(i)})),ZD=W(((e,t)=>{var i,n,r,a,s,o,l,h=sn(),c=zo(),u=Rs().f,d=oy().set,p=jD(),f=FD(),m=AZ(),g=PZ(),v=Cc(),y=h.MutationObserver||h.WebKitMutationObserver,x=h.document,b=h.process,_=h.Promise,w=u(h,"queueMicrotask"),M=w&&w.value;M||(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}),M=function(e){o.head||i(),o.add(e)}),t.exports=M})),HZ=W(((e,t)=>{t.exports=function(e,t){try{1==arguments.length?console.error(e):console.error(e,t)}catch(e){}}})),sg=W(((e,t)=>{t.exports=function(e){try{return{error:!1,value:e()}}catch(e){return{error:!0,value:e}}}})),ep=W(((e,t)=>{var i=sn();t.exports=i.Promise})),iw=W(((e,t)=>{t.exports="object"==typeof Deno&&Deno&&"object"==typeof Deno.version})),JD=W(((e,t)=>{var i=iw(),n=Cc();t.exports=!i&&!n&&"object"==typeof window&&"object"==typeof document})),ag=W(((e,t)=>{var i=sn(),n=ep(),r=yr(),a=Nm(),s=q_(),o=br(),l=JD(),h=iw(),c=Bi(),u=wc(),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}})),ud=W(((e,t)=>{"use strict";var i=Ni(),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)}})),fJ=W((()=>{"use strict";var e,t,i,n=We(),r=Bi(),a=Cc(),s=sn(),o=ar(),l=Mi(),h=Nl(),c=Aa(),u=Wf(),d=Ni(),p=yr(),f=xr(),m=Hl(),g=Yf(),v=oy().set,y=ZD(),x=HZ(),b=sg(),_=jD(),w=es(),M=ep(),S=ag(),E=ud(),T="Promise",A=S.CONSTRUCTOR,C=S.REJECTION_EVENT,P=S.SUBCLASSING,R=w.getterFor(T),L=w.set,D=M&&M.prototype,I=M,O=D,k=s.TypeError,N=s.document,F=s.process,U=E.f,B=U,z=!!(N&&N.createEvent&&s.dispatchEvent),H="unhandledrejection",V=function(e){var t;return!(!f(e)||!p(t=e.then))&&t},W=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&&Y(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)}},j=function(e,t){e.notified||(e.notified=!0,y((function(){for(var i,n=e.reactions;i=n.get();)W(i,e);e.notified=!1,t&&!e.rejection&&X(e)})))},G=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(q(e)&&(t=b((function(){a?F.emit("unhandledRejection",n,i):G(H,i,n)})),e.rejection=a||q(e)?2:1,t.error))throw t.value}))},q=function(e){return 1!==e.rejection&&!e.parent},Y=function(e){o(v,s,(function(){var t=e.facade;a?F.emit("rejectionHandled",t):G("rejectionhandled",t,e.value)}))},J=function(e,t,i){return function(n){e(t,n,i)}},Z=function(e,t,i){e.done||(e.done=!0,i&&(e=i),e.value=t,e.state=2,j(e,!0))},K=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,J(K,i,e),J(Z,i,e))}catch(t){Z(i,t,e)}})):(e.value=t,e.state=1,j(e,!1))}catch(t){Z({done:!1},t,e)}}};if(A&&(O=(I=function(t){m(this,O),d(t),o(e,this);var i=R(this);try{t(J(K,i),J(Z,i))}catch(e){Z(i,e)}}).prototype,(e=function(e){L(this,{type:T,done:!1,notified:!1,parent:!1,reactions:new _,rejection:!1,state:0,value:void 0})}).prototype=l(O,"then",(function(e,t){var i=R(this),n=U(g(this,I));return i.parent=!0,n.ok=!p(e)||e,n.fail=p(t)&&t,n.domain=a?F.domain:void 0,0==i.state?i.reactions.add(n):y((function(){W(n,i)})),n.promise})),t=function(){var t=new e,i=R(t);this.promise=t,this.resolve=J(K,i),this.reject=J(Z,i)},E.f=U=function(e){return e===I||void 0===e?new t(e):B(e)},!r&&p(M)&&D!==Object.prototype)){i=D.then,P||l(D,"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 D.constructor}catch(e){}h&&h(D,O)}n({global:!0,constructor:!0,wrap:!0,forced:A},{Promise:I}),c(I,T,!1,!0),u(T)})),hy=W(((e,t)=>{var i=ep(),n=B1(),r=ag().CONSTRUCTOR;t.exports=r||!n((function(e){i.all(e).then(void 0,(function(){}))}))})),mJ=W((()=>{"use strict";var e=We(),t=ar(),i=Ni(),n=ud(),r=sg(),a=Bl();e({target:"Promise",stat:!0,forced:hy()},{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}})})),vJ=W((()=>{"use strict";var e,t=We(),i=Bi(),n=ag().CONSTRUCTOR,r=ep(),a=fi(),s=yr(),o=Mi(),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}))})),yJ=W((()=>{"use strict";var e=We(),t=ar(),i=Ni(),n=ud(),r=sg(),a=Bl();e({target:"Promise",stat:!0,forced:hy()},{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}})})),xJ=W((()=>{"use strict";var e=We(),t=ar(),i=ud();e({target:"Promise",stat:!0,forced:ag().CONSTRUCTOR},{reject:function(e){var n=i.f(this);return t(n.reject,void 0,e),n.promise}})})),hL=W(((e,t)=>{var i=nr(),n=xr(),r=ud();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}})),TJ=W((()=>{"use strict";var e=We(),t=fi(),i=Bi(),n=ep(),r=ag().CONSTRUCTOR,a=hL(),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)}})})),wJ=W((()=>{fJ(),mJ(),vJ(),yJ(),xJ(),TJ()})),SJ=W((()=>{"use strict";var e=We(),t=ar(),i=Ni(),n=ud(),r=sg(),a=Bl();e({target:"Promise",stat:!0,forced:hy()},{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}})})),RJ=W((()=>{"use strict";var e=We(),t=ar(),i=Ni(),n=fi(),r=ud(),a=sg(),s=Bl(),o=hy(),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}})})),IJ=W((()=>{"use strict";var e,t=We(),i=Bi(),n=ep(),r=Ft(),a=fi(),s=yr(),o=Yf(),l=hL(),h=Mi(),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}))})),DJ=W((()=>{var e=We(),t=co(),i=Ni(),n=nr();e({target:"Reflect",stat:!0,forced:!Ft()((function(){Reflect.apply((function(){}))}))},{apply:function(e,r,a){return t(i(e),r,n(a))}})})),HJ=W((()=>{var e=We(),t=fi(),i=co(),n=JI(),r=zT(),a=nr(),s=xr(),o=Ra(),l=Ft(),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}})})),zJ=W((()=>{var e=We(),t=kn(),i=nr(),n=ku(),r=Ei();e({target:"Reflect",stat:!0,forced:Ft()((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}}})})),GJ=W((()=>{var e=We(),t=nr(),i=Rs().f;e({target:"Reflect",stat:!0},{deleteProperty:function(e,n){var r=i(t(e),n);return!(r&&!r.configurable)&&delete e[n]}})})),gL=W(((e,t)=>{var i=Lr();t.exports=function(e){return void 0!==e&&(i(e,"value")||i(e,"writable"))}})),XJ=W((()=>{var e=We(),t=ar(),i=xr(),n=nr(),r=gL(),a=Rs(),s=uo();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}})})),YJ=W((()=>{var e=We(),t=kn(),i=nr(),n=Rs();e({target:"Reflect",stat:!0,sham:!t},{getOwnPropertyDescriptor:function(e,t){return n.f(i(e),t)}})})),$J=W((()=>{var e=We(),t=nr(),i=uo();e({target:"Reflect",stat:!0,sham:!mT()},{getPrototypeOf:function(e){return i(t(e))}})})),KJ=W((()=>{We()({target:"Reflect",stat:!0},{has:function(e,t){return t in e}})})),ZJ=W((()=>{var e=We(),t=nr(),i=WT();e({target:"Reflect",stat:!0},{isExtensible:function(e){return t(e),i(e)}})})),JJ=W((()=>{We()({target:"Reflect",stat:!0},{ownKeys:Z_()})})),QJ=W((()=>{var e=We(),t=fi(),i=nr();e({target:"Reflect",stat:!0,sham:!Kf()},{preventExtensions:function(e){i(e);try{var n=t("Object","preventExtensions");return n&&n(e),!0}catch(e){return!1}}})})),iQ=W((()=>{var e=We(),t=ar(),i=nr(),n=xr(),r=gL(),a=Ft(),s=Ei(),o=Rs(),l=uo(),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}})})),aQ=W((()=>{var e=We(),t=nr(),i=V3(),n=Nl();n&&e({target:"Reflect",stat:!0},{setPrototypeOf:function(e,r){t(e),i(r);try{return n(e,r),!0}catch(e){return!1}}})})),oQ=W((()=>{var e=We(),t=sn(),i=Aa();e({global:!0},{Reflect:{}}),i(t.Reflect,"Reflect",!0)})),hg=W(((e,t)=>{var i=xr(),n=Ns(),r=br()("match");t.exports=function(e){var t;return i(e)&&(void 0!==(t=e[r])?!!t:"RegExp"==n(e))}})),dw=W(((e,t)=>{"use strict";var i=nr();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}})),dg=W(((e,t)=>{var i=ar(),n=Lr(),r=lo(),a=dw(),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)}})),dy=W(((e,t)=>{var i=Ft(),n=sn().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}})),fw=W(((e,t)=>{var i=Ft(),n=sn().RegExp;t.exports=i((function(){var e=n(".","s");return!(e.dotAll&&e.exec("\n")&&"s"===e.flags)}))})),EL=W(((e,t)=>{var i=Ft(),n=sn().RegExp;t.exports=i((function(){var e=n("(?b)","g");return"b"!==e.exec("b").groups.a||"bc"!=="b".replace(e,"$c")}))})),TQ=W((()=>{var e,t,i,n=kn(),r=sn(),a=Vt(),s=Nm(),o=Gf(),l=Bs(),h=Fu().f,c=lo(),u=hg(),d=lr(),p=dg(),f=dy(),m=z3(),g=Mi(),v=Ft(),y=Lr(),x=es().enforce,b=Wf(),_=br(),w=fw(),M=EL(),S=_("match"),E=r.RegExp,T=E.prototype,A=r.SyntaxError,C=a(T.exec),P=a("".charAt),R=a("".replace),L=a("".indexOf),D=a("".slice),I=/^\?<[^\s\d!#%&*+<=>@^][^\s!#%&*+<=>@^]*>/,O=/a/g,k=/a/g,N=new E(O)!==O,F=f.MISSED_STICKY,U=f.UNSUPPORTED_Y;if(s("RegExp",n&&(!N||F||w||M||v((function(){return k[S]=!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&&L(i,"s")>-1)&&(i=R(i,/s/g,"")),n=i,F&&"sticky"in O&&(a=!!i&&L(i,"y")>-1)&&U&&(i=R(i,/y/g,"")),M&&(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,D(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")})),SQ=W((()=>{var e=kn(),t=fw(),i=Ns(),n=vs(),r=es().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")}}})})),py=W(((e,t)=>{"use strict";var i,n,r=ar(),a=Vt(),s=lr(),o=dw(),l=dy(),h=kf(),c=Ra(),u=es().get,d=fw(),p=EL(),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,M=void 0!==/()??/.exec("")[1];(_||M||w||d||p)&&(g=function(e){var t,i,n,a,l,h,d,p=this,S=u(p),E=s(e),T=S.raw;if(T)return T.lastIndex=p.lastIndex,t=r(g,T,E),p.lastIndex=T.lastIndex,t;var A=S.groups,C=w&&p.sticky,P=r(o,p),R=p.source,L=0,D=E;if(C&&(P=x(P,"y",""),-1===y(P,"g")&&(P+="g"),D=b(E,p.lastIndex),p.lastIndex>0&&(!p.multiline||p.multiline&&"\n"!==v(E,p.lastIndex-1))&&(R="(?: "+R+")",D=" "+D,L++),i=new RegExp("^(?:"+R+")",P)),M&&(i=new RegExp("^"+R+"$(?!\\s)",P)),_&&(n=p.lastIndex),a=r(m,C?i:p,D),C?a?(a.input=b(a.input,L),a[0]=b(a[0],L),a.index=p.lastIndex,p.lastIndex+=a[0].length):p.lastIndex=0:_&&a&&(p.lastIndex=p.global?a.index+a[0].length:n),M&&a&&a.length>1&&r(f,a[0],i,(function(){for(l=1;l{"use strict";var e=We(),t=py();e({target:"RegExp",proto:!0,forced:/./.exec!==t},{exec:t})})),IQ=W((()=>{var e=sn(),t=kn(),i=vs(),n=dw(),r=Ft(),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})})),LQ=W((()=>{var e=kn(),t=dy().MISSED_STICKY,i=Ns(),n=vs(),r=es().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")}}})})),FQ=W((()=>{"use strict";vw();var e,t,i=We(),n=ar(),r=yr(),a=nr(),s=lr(),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)}})})),HQ=W((()=>{"use strict";var e=Nf().PROPER,t=Mi(),i=nr(),n=lr(),r=Ft(),a=dg(),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})})),UQ=W((()=>{"use strict";$1()("Set",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),oD())})),VQ=W((()=>{UQ()})),zQ=W((()=>{"use strict";var e=We(),t=Vt(),i=Qi(),n=Hi(),r=lr(),a=Ft(),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)}})})),my=W(((e,t)=>{var i=Vt(),n=Hi(),r=lr(),a=Qi(),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)}})),WQ=W((()=>{"use strict";var e=We(),t=my().codeAt;e({target:"String",proto:!0},{codePointAt:function(e){return t(this,e)}})})),yw=W(((e,t)=>{var i=hg(),n=TypeError;t.exports=function(e){if(i(e))throw n("The method doesn't accept regular expressions");return e}})),xw=W(((e,t)=>{var i=br()("match");t.exports=function(e){var t=/./;try{"/./"[e](t)}catch(n){try{return t[i]=!1,"/./"[e](t)}catch(e){}}return!1}})),QQ=W((()=>{"use strict";var e,t=We(),i=Nu(),n=Rs().f,r=Ma(),a=lr(),s=yw(),o=Qi(),l=xw(),h=Bi(),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}})})),nee=W((()=>{var e=We(),t=Vt(),i=kl(),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,"")}})})),iee=W((()=>{"use strict";var e=We(),t=Vt(),i=yw(),n=Qi(),r=lr(),a=xw(),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)}})})),DL=W((()=>{"use strict";var e=my().charAt,t=lr(),i=es(),n=wT(),r=V1(),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))}))})),gy=W(((e,t)=>{"use strict";vw();var i=Nu(),n=Mi(),r=py(),a=Ft(),s=br(),o=Bs(),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)}})),vy=W(((e,t)=>{"use strict";var i=my().charAt;t.exports=function(e,t,n){return t+(n?i(e,t).length:1)}})),mg=W(((e,t)=>{var i=ar(),n=nr(),r=yr(),a=Ns(),s=py(),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")}})),vee=W((()=>{"use strict";var e=ar(),t=gy(),i=nr(),n=na(),r=Ma(),a=lr(),s=Qi(),o=Sc(),l=vy(),h=mg();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}]}))})),Ree=W((()=>{"use strict";var e=We(),t=ar(),i=Nu(),n=ET(),r=V1(),a=Qi(),s=Ma(),o=lr(),l=nr(),h=na(),c=Ns(),u=hg(),d=dg(),p=Sc(),f=Mi(),m=Ft(),g=br(),v=Yf(),y=vy(),x=mg(),b=es(),_=Bi(),w=g("matchAll"),M="RegExp String",S=M+" Iterator",E=b.set,T=b.getterFor(S),A=RegExp.prototype,C=TypeError,P=i("".indexOf),R=i("".matchAll),L=!!R&&!m((function(){R("a",/./)})),D=n((function(e,t,i,n){E(this,{type:S,regexp:e,string:t,global:i,unicode:n,done:!1})}),M,(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 D(t,a,i,n)};e({target:"String",proto:!0,forced:L},{matchAll:function(e){var i,n,r,s,l=a(this);if(h(e)){if(L)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(L)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)})),HL=W(((e,t)=>{var i=Tc();t.exports=/Version\/10(?:\.\d+){1,2}(?: [\w./]+)?(?: Mobile\/\w+)? Safari\//.test(i)})),Cee=W((()=>{"use strict";var e=We(),t=GT().end;e({target:"String",proto:!0,forced:HL()},{padEnd:function(e){return t(this,e,arguments.length>1?arguments[1]:void 0)}})})),Pee=W((()=>{"use strict";var e=We(),t=GT().start;e({target:"String",proto:!0,forced:HL()},{padStart:function(e){return t(this,e,arguments.length>1?arguments[1]:void 0)}})})),Oee=W((()=>{var e=We(),t=Vt(),i=cs(),n=Ur(),r=lr(),a=Wr(),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{We()({target:"String",proto:!0},{repeat:X1()})})),GL=W(((e,t)=>{var i=Vt(),n=Ur(),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}))}})),Vee=W((()=>{"use strict";var e=co(),t=ar(),i=Vt(),n=gy(),r=Ft(),a=nr(),s=yr(),o=na(),l=Hi(),h=Ma(),c=lr(),u=Qi(),d=vy(),p=Sc(),f=GL(),m=mg(),g=br()("replace"),v=Math.max,y=Math.min,x=i([].concat),b=i([].push),_=i("".indexOf),w=i("".slice),M=function(e){return void 0===e?e:String(e)},S="$0"==="a".replace(/./,"$0"),E=!!/./[g]&&""===/./[g]("a","$0");n("replace",(function(i,n,r){var S=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,S)&&-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,L=0;L=R&&(P+=w(u,R,I)+U,R=I+D.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,"$")}))||!S||E)})),Wee=W((()=>{"use strict";var e=We(),t=ar(),i=Vt(),n=Qi(),r=yr(),a=na(),s=hg(),o=lr(),l=Sc(),h=dg(),c=GL(),u=br(),d=Bi(),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,M,S,E,T,A,C=n(this),P=0,R=0,L="";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),M=o(e),(S=r(i))||(i=o(i)),E=M.length,T=y(1,E),P=x(w,M,0);-1!==P;)A=S?o(i(M,P,w)):c(M,w,P,[],void 0,i),L+=v(w,R,P)+A,R=P+E,P=x(w,M,P+T);return R{"use strict";var e=ar(),t=gy(),i=nr(),n=na(),r=Qi(),a=ID(),s=lr(),o=Sc(),l=mg();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}]}))})),tte=W((()=>{"use strict";var e=co(),t=ar(),i=Vt(),n=gy(),r=nr(),a=na(),s=hg(),o=Qi(),l=Yf(),h=vy(),c=Ma(),u=lr(),d=Sc(),p=Hm(),f=mg(),m=py(),g=dy(),v=Ft(),y=g.UNSUPPORTED_Y,x=4294967295,b=Math.min,_=[].push,w=i(/./.exec),M=i(_),S=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&&(M(f,S(a,v,h.index)),h.length>1&&h.index=l));)y.lastIndex===h.index&&y.lastIndex++;return v===a.length?(d||!w(y,""))&&M(f,""):M(f,S(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=We(),i=Nu(),n=Rs().f,r=Ma(),a=lr(),s=yw(),o=Qi(),l=xw(),h=Bi(),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}})})),lte=W((()=>{"use strict";var e=We(),t=Vt(),i=Qi(),n=Hi(),r=lr(),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)}})})),ww=W(((e,t)=>{var i=Nf().PROPER,n=Ft(),r=ey();t.exports=function(e){return n((function(){return!!r[e]()||"\u200b\x85\u180e"!=="\u200b\x85\u180e"[e]()||i&&r[e].name!==e}))}})),dte=W((()=>{"use strict";var e=We(),t=Zf().trim;e({target:"String",proto:!0,forced:ww()("trim")},{trim:function(){return t(this)}})})),$L=W(((e,t)=>{"use strict";var i=Zf().end,n=ww();t.exports=n("trimEnd")?function(){return i(this)}:"".trimEnd})),mte=W((()=>{var e=We(),t=$L();e({target:"String",proto:!0,name:"trimEnd",forced:"".trimRight!==t},{trimRight:t})})),vte=W((()=>{mte();var e=We(),t=$L();e({target:"String",proto:!0,name:"trimEnd",forced:"".trimEnd!==t},{trimEnd:t})})),KL=W(((e,t)=>{"use strict";var i=Zf().start,n=ww();t.exports=n("trimStart")?function(){return i(this)}:"".trimStart})),bte=W((()=>{var e=We(),t=KL();e({target:"String",proto:!0,name:"trimStart",forced:"".trimLeft!==t},{trimLeft:t})})),_te=W((()=>{bte();var e=We(),t=KL();e({target:"String",proto:!0,name:"trimStart",forced:"".trimStart!==t},{trimStart:t})})),Ia=W(((e,t)=>{var i=Vt(),n=Qi(),r=lr(),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+""}})),Da=W(((e,t)=>{var i=Ft();t.exports=function(e){return i((function(){var t=""[e]('"');return t!==t.toLowerCase()||t.split('"').length>3}))}})),Mte=W((()=>{"use strict";var e=We(),t=Ia();e({target:"String",proto:!0,forced:Da()("anchor")},{anchor:function(e){return t(this,"a","name",e)}})})),Rte=W((()=>{"use strict";var e=We(),t=Ia();e({target:"String",proto:!0,forced:Da()("big")},{big:function(){return t(this,"big","","")}})})),Ate=W((()=>{"use strict";var e=We(),t=Ia();e({target:"String",proto:!0,forced:Da()("blink")},{blink:function(){return t(this,"blink","","")}})})),Cte=W((()=>{"use strict";var e=We(),t=Ia();e({target:"String",proto:!0,forced:Da()("bold")},{bold:function(){return t(this,"b","","")}})})),Pte=W((()=>{"use strict";var e=We(),t=Ia();e({target:"String",proto:!0,forced:Da()("fixed")},{fixed:function(){return t(this,"tt","","")}})})),Ite=W((()=>{"use strict";var e=We(),t=Ia();e({target:"String",proto:!0,forced:Da()("fontcolor")},{fontcolor:function(e){return t(this,"font","color",e)}})})),Dte=W((()=>{"use strict";var e=We(),t=Ia();e({target:"String",proto:!0,forced:Da()("fontsize")},{fontsize:function(e){return t(this,"font","size",e)}})})),Lte=W((()=>{"use strict";var e=We(),t=Ia();e({target:"String",proto:!0,forced:Da()("italics")},{italics:function(){return t(this,"i","","")}})})),Ote=W((()=>{"use strict";var e=We(),t=Ia();e({target:"String",proto:!0,forced:Da()("link")},{link:function(e){return t(this,"a","href",e)}})})),kte=W((()=>{"use strict";var e=We(),t=Ia();e({target:"String",proto:!0,forced:Da()("small")},{small:function(){return t(this,"small","","")}})})),Fte=W((()=>{"use strict";var e=We(),t=Ia();e({target:"String",proto:!0,forced:Da()("strike")},{strike:function(){return t(this,"strike","","")}})})),Nte=W((()=>{"use strict";var e=We(),t=Ia();e({target:"String",proto:!0,forced:Da()("sub")},{sub:function(){return t(this,"sub","","")}})})),Bte=W((()=>{"use strict";var e=We(),t=Ia();e({target:"String",proto:!0,forced:Da()("sup")},{sup:function(){return t(this,"sup","","")}})})),Sw=W(((e,t)=>{var i=sn(),n=Ft(),r=B1(),a=hr().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}))})),zte=W(((e,t)=>{var i=Hi(),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}})),JL=W(((e,t)=>{var i=zte(),n=RangeError;t.exports=function(e,t){var r=i(e);if(r%t)throw n("Wrong offset");return r}})),QL=W(((e,t)=>{var i=Fl();t.exports=function(e){var t=i(e);return"BigInt64Array"==t||"BigUint64Array"==t}})),Mw=W(((e,t)=>{var i=E1(),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)}})),eO=W(((e,t)=>{var i=zo(),n=ar(),r=zT(),a=Ur(),s=Wr(),o=k1(),l=jm(),h=gT(),c=QL(),u=hr().aTypedArrayConstructor,d=Mw();t.exports=function(e){var t,p,f,m,g,v,y,x,b=r(this),_=a(e),w=arguments.length,M=w>1?arguments[1]:void 0,S=void 0!==M,E=l(_);if(E&&!h(E))for(x=(y=o(_,E)).next,_=[];!(v=n(x,y)).done;)_.push(v.value);for(S&&w>2&&(M=i(M,arguments[2])),p=s(_),f=new(u(b))(p),m=c(f),t=0;p>t;t++)g=S?M(_[t],t):_[t],f[t]=m?d(g):+g;return f}})),Oc=W(((e,t)=>{"use strict";var i=We(),n=sn(),r=ar(),a=kn(),s=Sw(),o=hr(),l=W1(),h=Hl(),c=oo(),u=Bs(),d=QT(),p=Ma(),f=CI(),m=JL(),g=ku(),v=Lr(),y=Fl(),x=xr(),b=Jh(),_=Ra(),w=lo(),M=Nl(),S=Fu().f,E=eO(),T=ys().forEach,A=Wf(),C=vs(),P=Ei(),R=Rs(),L=es(),D=Gf(),I=L.get,O=L.set,k=L.enforce,N=P.f,F=R.f,U=Math.round,B=n.RangeError,z=l.ArrayBuffer,H=z.prototype,V=l.DataView,W=o.NATIVE_ARRAY_BUFFER_VIEWS,j=o.TYPED_ARRAY_TAG,G=o.TypedArray,X=o.TypedArrayPrototype,q=o.aTypedArrayConstructor,Y=o.isTypedArray,J="BYTES_PER_ELEMENT",Z="Wrong length",K=function(e,t){q(e);for(var i=0,n=t.length,r=new e(n);n>i;)r[i]=t[i++];return r},$=function(e,t){C(e,t,{configurable:!0,get:function(){return I(this)[t]}})},Q=function(e){var t;return w(H,e)||"ArrayBuffer"==(t=y(e))||"SharedArrayBuffer"==t},ee=function(e,t){return Y(e)&&!b(t)&&t in e&&d(+t)&&t>=0},te=function(e,t){return t=g(t),ee(e,t)?c(2,e[t]):F(e,t)},ie=function(e,t,i){return t=g(t),!(ee(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?N(e,t,i):(e[t]=i.value,e)};a?(W||(R.f=te,P.f=ie,$(X,"buffer"),$(X,"byteOffset"),$(X,"byteLength"),$(X,"length")),i({target:"Object",stat:!0,forced:!W},{getOwnPropertyDescriptor:te,defineProperty:ie}),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){N(e,t,{get:function(){return function(e,t){var i=I(e);return i.view[c](t*o+i.byteOffset,!0)}(this,t)},set:function(e){return function(e,t,i){var n=I(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})};W?s&&(v=t((function(e,t,i,n){return h(e,y),D(x(t)?Q(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)?K(v,t):r(E,v,t):new g(f(t)),e,v)})),M&&M(v,G),T(S(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(!Q(t))return Y(t)?K(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 B(Z)}else if((s=p(n)*o)+u>d)throw B(Z);l=s/o}else l=f(t),a=new z(s=l*o);for(O(e,{buffer:a,byteOffset:u,byteLength:s,length:l,view:new V(a)});c{Oc()("Float32",(function(e){return function(t,i,n){return e(this,t,i,n)}}))})),fne=W((()=>{Oc()("Float64",(function(e){return function(t,i,n){return e(this,t,i,n)}}))})),pne=W((()=>{Oc()("Int8",(function(e){return function(t,i,n){return e(this,t,i,n)}}))})),mne=W((()=>{Oc()("Int16",(function(e){return function(t,i,n){return e(this,t,i,n)}}))})),gne=W((()=>{Oc()("Int32",(function(e){return function(t,i,n){return e(this,t,i,n)}}))})),vne=W((()=>{Oc()("Uint8",(function(e){return function(t,i,n){return e(this,t,i,n)}}))})),yne=W((()=>{Oc()("Uint8",(function(e){return function(t,i,n){return e(this,t,i,n)}}),!0)})),xne=W((()=>{Oc()("Uint16",(function(e){return function(t,i,n){return e(this,t,i,n)}}))})),bne=W((()=>{Oc()("Uint32",(function(e){return function(t,i,n){return e(this,t,i,n)}}))})),_ne=W((()=>{"use strict";var e=hr(),t=Wr(),i=Hi(),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]}))})),wne=W((()=>{"use strict";var e=Vt(),t=hr(),i=e(sI()),n=t.aTypedArray;(0,t.exportTypedArrayMethod)("copyWithin",(function(e,t){return i(n(this),e,t,arguments.length>2?arguments[2]:void 0)}))})),Mne=W((()=>{"use strict";var e=hr(),t=ys().every,i=e.aTypedArray;(0,e.exportTypedArrayMethod)("every",(function(e){return t(i(this),e,arguments.length>1?arguments[1]:void 0)}))})),Ane=W((()=>{"use strict";var e=hr(),t=bT(),i=Mw(),n=Fl(),r=ar(),a=Vt(),s=Ft(),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})))})),wy=W(((e,t)=>{var i=hr(),n=Yf(),r=i.aTypedArrayConstructor,a=i.getTypedArrayConstructor;t.exports=function(e){return r(n(e,a(e)))}})),Dne=W(((e,t)=>{var i=CT(),n=wy();t.exports=function(e,t){return i(n(e),t)}})),One=W((()=>{"use strict";var e=hr(),t=ys().filter,i=Dne(),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)}))})),Fne=W((()=>{"use strict";var e=hr(),t=ys().find,i=e.aTypedArray;(0,e.exportTypedArrayMethod)("find",(function(e){return t(i(this),e,arguments.length>1?arguments[1]:void 0)}))})),Bne=W((()=>{"use strict";var e=hr(),t=ys().findIndex,i=e.aTypedArray;(0,e.exportTypedArrayMethod)("findIndex",(function(e){return t(i(this),e,arguments.length>1?arguments[1]:void 0)}))})),Une=W((()=>{"use strict";var e=hr(),t=N1().findLast,i=e.aTypedArray;(0,e.exportTypedArrayMethod)("findLast",(function(e){return t(i(this),e,arguments.length>1?arguments[1]:void 0)}))})),zne=W((()=>{"use strict";var e=hr(),t=N1().findLastIndex,i=e.aTypedArray;(0,e.exportTypedArrayMethod)("findLastIndex",(function(e){return t(i(this),e,arguments.length>1?arguments[1]:void 0)}))})),qne=W((()=>{"use strict";var e=hr(),t=ys().forEach,i=e.aTypedArray;(0,e.exportTypedArrayMethod)("forEach",(function(e){t(i(this),e,arguments.length>1?arguments[1]:void 0)}))})),jne=W((()=>{"use strict";var e=Sw();(0,hr().exportTypedArrayStaticMethod)("from",eO(),e)})),Xne=W((()=>{"use strict";var e=hr(),t=Fm().includes,i=e.aTypedArray;(0,e.exportTypedArrayMethod)("includes",(function(e){return t(i(this),e,arguments.length>1?arguments[1]:void 0)}))})),$ne=W((()=>{"use strict";var e=hr(),t=Fm().indexOf,i=e.aTypedArray;(0,e.exportTypedArrayMethod)("indexOf",(function(e){return t(i(this),e,arguments.length>1?arguments[1]:void 0)}))})),ere=W((()=>{"use strict";var e=sn(),t=Ft(),i=Vt(),n=hr(),r=z1(),a=br()("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"})})),nre=W((()=>{"use strict";var e=hr(),t=Vt(),i=e.aTypedArray,n=e.exportTypedArrayMethod,r=t([].join);n("join",(function(e){return r(i(this),e)}))})),ire=W((()=>{"use strict";var e=hr(),t=co(),i=bI(),n=e.aTypedArray;(0,e.exportTypedArrayMethod)("lastIndexOf",(function(e){var r=arguments.length;return t(i,n(this),r>1?[e,arguments[1]]:[e])}))})),are=W((()=>{"use strict";var e=hr(),t=ys().map,i=wy(),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)}))}))})),lre=W((()=>{"use strict";var e=hr(),t=Sw(),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)})),ure=W((()=>{"use strict";var e=hr(),t=G1().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)}))})),dre=W((()=>{"use strict";var e=hr(),t=G1().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)}))})),pre=W((()=>{"use strict";var e=hr(),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=sn(),t=ar(),i=hr(),n=Wr(),r=JL(),a=Ur(),s=Ft(),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=hr(),t=wy(),i=Ft(),n=td(),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()})))})),wre=W((()=>{"use strict";var e=hr(),t=ys().some,i=e.aTypedArray;(0,e.exportTypedArrayMethod)("some",(function(e){return t(i(this),e,arguments.length>1?arguments[1]:void 0)}))})),Pre=W((()=>{"use strict";var e=sn(),t=Nu(),i=Ft(),n=Ni(),r=RT(),a=hr(),s=TI(),o=wI(),l=wc(),h=AT(),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)})),Lre=W((()=>{"use strict";var e=hr(),t=Ma(),i=kl(),n=wy(),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))}))})),Bre=W((()=>{"use strict";var e=sn(),t=co(),i=hr(),n=Ft(),r=td(),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])})))})),Hre=W((()=>{"use strict";var e=RI(),t=hr(),i=t.aTypedArray,n=t.exportTypedArrayMethod,r=t.getTypedArrayConstructor;n("toReversed",(function(){return e(i(this),r(this))}))})),Ure=W((()=>{"use strict";var e=hr(),t=Vt(),i=Ni(),n=CT(),r=e.aTypedArray,a=e.getTypedArrayConstructor,s=e.exportTypedArrayMethod,o=t(e.TypedArrayPrototype.sort);s("toSorted",(function(e){void 0!==e&&i(e);var t=r(this),s=n(a(t),t);return o(s,e)}))})),zre=W((()=>{"use strict";var e=hr().exportTypedArrayMethod,t=Ft(),i=sn(),n=Vt(),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)})),Gre=W((()=>{"use strict";var e=AI(),t=hr(),i=QL(),n=Hi(),r=Mw(),a=t.aTypedArray,s=t.getTypedArrayConstructor;(0,t.exportTypedArrayMethod)("with",(function(t,o){var l=a(this),h=n(t),c=i(l)?r(o):+o;return e(l,s(l),h,c)}),!function(){try{new Int8Array(1).with(2,{valueOf:function(){throw 8}})}catch(e){return 8===e}}())})),Yre=W((()=>{"use strict";var e=We(),t=Vt(),i=lr(),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=Vt(),n=Ym(),r=cd().getWeakData,a=Hl(),s=nr(),o=na(),l=xr(),h=Bl(),c=ys(),u=Lr(),d=es(),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}}})),uie=W((()=>{"use strict";var e,t,i,n,r=Kf(),a=sn(),s=Vt(),o=Ym(),l=cd(),h=$1(),c=TO(),u=xr(),d=es().enforce,p=Ft(),f=o3(),m=Object,g=Array.isArray,v=m.isExtensible,y=m.isFrozen,x=m.isSealed,b=m.freeze,_=m.seal,w={},M={},S=!a.ActiveXObject&&"ActiveXObject"in a,E=function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}},T=h("WeakMap",E,c),A=T.prototype,C=s(A.set);f&&(S?(e=c.getConstructor(E,"WeakMap",!0),l.enable(),t=s(A.delete),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=M)),C(this,e,t),i==w&&b(e),i==M&&_(e),this}}))})),hie=W((()=>{uie()})),die=W((()=>{"use strict";$1()("WeakSet",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),TO())})),fie=W((()=>{die()})),MO=W(((e,t)=>{var i,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",r={};for(i=0;i<66;i++)r[n.charAt(i)]=i;t.exports={itoc:n,ctoi:r}})),_ie=W((()=>{var e=We(),t=sn(),i=fi(),n=Vt(),r=ar(),a=Ft(),s=lr(),o=Lr(),l=Lc(),h=MO().ctoi,c=/[^\d+/a-z]/i,u=/[\t\n\f\r ]+/g,d=/[=]{1,2}$/,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,M=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=M%4?64*a+h[n]:h[n],M++%4&&(x+=f(255&a>>(-2*M&6))));return x}})})),Iie=W((()=>{var e=We(),t=sn(),i=fi(),n=Vt(),r=ar(),a=Ft(),s=lr(),o=Lc(),l=MO().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}})})),DO=W(((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}})),OO=W(((e,t)=>{var i=_1()("span").classList,n=i&&i.constructor&&i.constructor.prototype;t.exports=n===Object.prototype?void 0:n})),Bie=W((()=>{var e,t=sn(),i=DO(),n=OO(),r=cI(),a=Bs(),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)})),qie=W((()=>{var e,t=sn(),i=DO(),n=OO(),r=z1(),a=Bs(),s=br(),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")})),Wie=W(((e,t)=>{var i=Cc();t.exports=function(e){try{if(i)return Function('return require("'+e+'")')()}catch(e){}}})),HO=W(((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}}})),ise=W((()=>{"use strict";var e=We(),t=Wie(),i=fi(),n=Ft(),r=Ra(),a=oo(),s=Ei().f,o=Mi(),l=vs(),h=Lr(),c=Hl(),u=nr(),d=$3(),p=Gm(),f=HO(),m=dT(),g=es(),v=kn(),y=Bi(),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}}(),M=w&&w.prototype,S=_.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(S),L=function(e){return{enumerable:!0,configurable:!0,get:e}},D=function(e){return L((function(){return T(this)[e]}))};v&&(l(R,"code",D("code")),l(R,"message",D("message")),l(R,"name",D("name"))),s(R,"constructor",a(1,P));var I=n((function(){return!(new w instanceof _)})),O=I||n((function(){return S.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!==M[b],F=y?O||k||N:I;e({global:!0,constructor:!0,forced:F},{DOMException:F?P:w});var U,B,z,H,V=i(x),W=V.prototype;for(H in O&&(y||w===V)&&o(W,"toString",d),k&&v&&w===V&&l(W,"code",L((function(){return C(u(this).name)}))),f)h(f,H)&&(B=(U=f[H]).s,z=a(6,U.c),h(V,B)||s(V,B,z),h(W,B)||s(W,B,z))})),hse=W((()=>{"use strict";var e=We(),t=sn(),i=fi(),n=oo(),r=Ei().f,a=Lr(),s=Hl(),o=Gf(),l=Gm(),h=HO(),c=dT(),u=kn(),d=Bi(),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 M,S,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,S=(M=h[E]).s)||r(T,S,n(6,M.c)))})),fse=W((()=>{var e=fi(),t="DOMException";Aa()(e(t),t)})),mse=W((()=>{var e=We(),t=sn(),i=oy().clear;e({global:!0,bind:!0,enumerable:!0,forced:t.clearImmediate!==i},{clearImmediate:i})})),vse=W(((e,t)=>{t.exports="function"==typeof Bun&&Bun&&"string"==typeof Bun.version})),Jw=W(((e,t)=>{"use strict";var i,n=sn(),r=co(),a=yr(),s=vse(),o=Tc(),l=td(),h=Lc(),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}})),Tse=W((()=>{var e=We(),t=sn(),i=oy().set,n=Jw(),r=t.setImmediate?n(i,!1):i;e({global:!0,bind:!0,enumerable:!0,forced:t.setImmediate!==r},{setImmediate:r})})),wse=W((()=>{mse(),Tse()})),Sse=W((()=>{var e=We(),t=sn(),i=ZD(),n=Ni(),r=Lc(),a=Cc(),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)}})})),Rse=W((()=>{"use strict";var e,t=We(),i=sn(),n=vs(),r=kn(),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){}})),Cse=W(((e,t)=>{var i=Vt(),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}})),Ise=W(((e,t)=>{var i=Vt(),n=Set.prototype;t.exports={Set:Set,add:i(n.add),has:i(n.has),remove:i(n.delete),proto:n}})),Ose=W(((e,t)=>{var i=sn(),n=Ft(),r=wc(),a=JD(),s=iw(),o=Cc(),l=i.structuredClone;t.exports=!!l&&!n((function(){if(s&&r>92||o&&r>94||a&&r>97)return!1;var e=new ArrayBuffer(8),t=l(e,{transfer:[e]});return 0!=e.byteLength||8!=t.byteLength}))})),Gse=W((()=>{var e,t=Bi(),i=We(),n=sn(),r=fi(),a=Vt(),s=Ft(),o=Ff(),l=yr(),h=Hf(),c=na(),u=xr(),d=Jh(),p=Bl(),f=nr(),m=Fl(),g=Lr(),v=Mc(),y=Bs(),x=Wr(),b=Lc(),_=dg(),w=Cse(),M=Ise(),S=q3(),E=Ose(),T=n.Object,A=n.Array,C=n.Date,P=n.Error,R=n.EvalError,L=n.RangeError,D=n.ReferenceError,I=n.SyntaxError,O=n.TypeError,k=n.URIError,N=n.PerformanceMark,F=n.WebAssembly,U=F&&F.CompileError||P,B=F&&F.LinkError||P,z=F&&F.RuntimeError||P,H=r("DOMException"),V=w.Map,W=w.has,j=w.get,G=w.set,X=M.Set,q=M.add,Y=r("Object","keys"),J=a([].push),Z=a((!0).valueOf),K=a(1..valueOf),$=a("".valueOf),Q=a(C.prototype.getTime),ee=o("structuredClone"),te="DataCloneError",ie="Transferring",ne=function(e){return!s((function(){var t=new n.Set([7]),i=e(t),r=e(T(7));return i==t||!i.has(7)||"object"!=typeof r||7!=r}))&&e},re=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)}))},ae=n.structuredClone,se=t||!re(ae,P)||!re(ae,H)||(e=ae,!!s((function(){var t=e(new n.AggregateError([1],ee,{cause:3}));return"AggregateError"!=t.name||1!=t.errors[0]||t.message!=ee||3!=t.cause}))),oe=!ae&&ne((function(e){return new N(ee,{detail:e}).detail})),le=ne(ae)||oe,he=function(e){throw new H("Uncloneable type: "+e,te)},ce=function(e,t){throw new H((t||"Cloning")+" of "+e+" cannot be properly polyfilled in this engine",te)},ue=function(e,t){return le||ce(t),le(e)},de=function(e,t){if(d(e)&&he("Symbol"),!u(e))return e;if(t){if(W(t,e))return j(t,e)}else t=new V;var i,a,s,o,h,c,p,f,b,w,M,E=m(e),N=!1;switch(E){case"Array":s=A(x(e)),N=!0;break;case"Object":s={},N=!0;break;case"Map":s=new V,N=!0;break;case"Set":s=new X,N=!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=R();break;case"RangeError":s=L();break;case"ReferenceError":s=D();break;case"SyntaxError":s=I();break;case"TypeError":s=O();break;case"URIError":s=k();break;case"CompileError":s=U();break;case"LinkError":s=B();break;case"RuntimeError":s=z();break;default:s=P()}N=!0;break;case"DOMException":s=new H(e.message,e.name),N=!0;break;case"DataView":case"Int8Array":case"Uint8Array":case"Uint8ClampedArray":case"Int16Array":case"Uint16Array":case"Int32Array":case"Uint32Array":case"Float32Array":case"Float64Array":case"BigInt64Array":case"BigUint64Array":i=n[E],u(i)||ce(E),s=new i(de(e.buffer,t),e.byteOffset,"DataView"===E?e.byteLength:e.length);break;case"DOMQuad":try{s=new DOMQuad(de(e.p1,t),de(e.p2,t),de(e.p3,t),de(e.p4,t))}catch(t){s=ue(e,E)}break;case"File":if(le)try{s=le(e),m(s)!==E&&(s=void 0)}catch(e){}if(!s)try{s=new File([e],e.name,e)}catch(e){}s||ce(E);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);h1&&!c(arguments[1])?f(arguments[1]):void 0,r=i?i.transfer:void 0;return void 0!==r&&function(e,t){if(!u(e))throw O("Transfer option cannot be converted to a sequence");var i=[];p(e,(function(e){J(i,f(e))}));var r,a,s,o,c,d,g=0,v=x(i);if(E)for(o=ae(i,{transfer:i});g{var e=We(),t=sn(),i=Jw()(t.setInterval,!0);e({global:!0,bind:!0,forced:t.setInterval!==i},{setInterval:i})})),$se=W((()=>{var e=We(),t=sn(),i=Jw()(t.setTimeout,!0);e({global:!0,bind:!0,forced:t.setTimeout!==i},{setTimeout:i})})),Kse=W((()=>{Wse(),$se()})),oS=W(((e,t)=>{var i=Ft(),n=br(),r=kn(),a=Bi(),s=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})),a&&!e.toJSON||!t.size&&(a||!r)||!t.sort||"http://a/c%20d?a=1&c=3"!==e.href||"3"!==t.get("c")||"a=1"!==String(new URLSearchParams("?a=1"))||!t[s]||"a"!==new URL("https://a@b").username||"b"!==new URLSearchParams(new URLSearchParams("a=b")).get("a")||"xn--e1aybc"!==new URL("http://\u0442\u0435\u0441\u0442").host||"#%D0%B1"!==new URL("http://a#\u0431").hash||"a1c3"!==i||"x"!==new URL("http://x",void 0).host}))})),oae=W(((e,t)=>{var i=Vt(),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,M=36;;){var S=M<=m?1:M>=m+26?26:M-m;if(w{"use strict";z1();var i=We(),n=sn(),r=ar(),a=Vt(),s=kn(),o=oS(),l=Mi(),h=vs(),c=Ym(),u=Aa(),d=ET(),p=es(),f=Hl(),m=yr(),g=Lr(),v=zo(),y=Fl(),x=nr(),b=xr(),_=lr(),w=Ra(),M=oo(),S=k1(),E=jm(),T=Lc(),A=br(),C=RT(),P=A("iterator"),R="URLSearchParams",L=R+"Iterator",D=p.set,I=p.getterFor(R),O=p.getterFor(L),k=Object.getOwnPropertyDescriptor,N=function(e){if(!s)return n[e];var t=k(n,e);return t&&t.value},F=N("fetch"),U=N("Request"),B=N("Headers"),z=U&&U.prototype,H=B&&B.prototype,V=n.RegExp,W=n.TypeError,j=n.decodeURIComponent,G=n.encodeURIComponent,X=a("".charAt),q=a([].join),Y=a([].push),J=a("".replace),Z=a([].shift),K=a([].splice),$=a("".split),Q=a("".slice),ee=/\+/g,te=Array(4),ie=function(e){return te[e-1]||(te[e-1]=V("((?:%[\\da-f]{2}){"+e+"})","gi"))},ne=function(e){try{return j(e)}catch(t){return e}},re=function(e){var t=J(e,ee," "),i=4;try{return j(t)}catch(e){for(;i;)t=J(t,ie(i--),ne);return t}},ae=/[!'()~]|%20/g,se={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},oe=function(e){return se[e]},le=function(e){return J(G(e),ae,oe)},he=d((function(e,t){D(this,{type:L,iterator:S(I(e).entries),kind:t})}),"Iterator",(function(){var e=O(this),t=e.kind,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),ce=function(e){this.entries=[],this.url=null,void 0!==e&&(b(e)?this.parseObject(e):this.parseQuery("string"==typeof e?"?"===X(e,0)?Q(e,1):e:_(e)))};ce.prototype={type:R,bindURL:function(e){this.url=e,this.update()},parseObject:function(e){var t,i,n,a,s,o,l,h=E(e);if(h)for(i=(t=S(e,h)).next;!(n=r(i,t)).done;){if(s=(a=S(x(n.value))).next,(o=r(s,a)).done||(l=r(s,a)).done||!r(s,a).done)throw W("Expected sequence with length 2");Y(this.entries,{key:_(o.value),value:_(l.value)})}else for(var c in e)g(e,c)&&Y(this.entries,{key:c,value:_(e[c])})},parseQuery:function(e){if(e)for(var t,i,n=$(e,"&"),r=0;r0?arguments[0]:void 0));s||(this.length=e.entries.length)},ge=me.prototype;c(ge,{append:function(e,t){T(arguments.length,2);var i=I(this);Y(i.entries,{key:_(e),value:_(t)}),s||this.length++,i.updateURL()},delete:function(e){T(arguments.length,1);for(var t=I(this),i=t.entries,n=_(e),r=0;rt.key?1:-1})),e.updateURL()},forEach:function(e){for(var t,i=I(this).entries,n=v(e,arguments.length>1?arguments[1]:void 0),r=0;r1?pe(arguments[1]):{})}}),m(U)&&(fe=function(e){return f(this,z),new U(e,arguments.length>1?pe(arguments[1]):{})},z.constructor=fe,fe.prototype=z,i({global:!0,constructor:!0,dontCallGetSet:!0,forced:!0},{Request:fe}))),t.exports={URLSearchParams:me,getState:I}})),jae=W((()=>{"use strict";DL();var e,t=We(),i=kn(),n=oS(),r=sn(),a=zo(),s=Vt(),o=Mi(),l=vs(),h=Hl(),c=Lr(),u=AD(),d=uI(),p=Hm(),f=my().codeAt,m=oae(),g=lr(),v=Aa(),y=Lc(),x=Ak(),b=es(),_=b.set,w=b.getterFor("URL"),M=x.URLSearchParams,S=x.getState,E=r.URL,T=r.TypeError,A=r.parseInt,C=Math.floor,P=Math.pow,R=s("".charAt),L=s(/./.exec),D=s([].join),I=s(1..toString),O=s([].pop),k=s([].push),N=s("".replace),F=s([].shift),U=s("".split),B=s("".slice),z=s("".toLowerCase),H=s([].unshift),V="Invalid scheme",W="Invalid host",j="Invalid port",G=/[a-z]/i,X=/[\d+-.a-z]/i,q=/\d/,Y=/^0x/i,J=/^[0-7]+$/,Z=/^\d+$/,K=/^[\da-f]+$/i,$=/[\0\t\n\r #%/:<>?@[\\\]^|]/,Q=/[\0\t\n\r #/:<>?@[\\\]^|]/,ee=/^[\u0000-\u0020]+/,te=/(^|[^\u0000-\u0020])[\u0000-\u0020]+$/,ie=/[\t\n\r]/g,ne=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 D(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},re={},ae=u({},re,{" ":1,'"':1,"<":1,">":1,"`":1}),se=u({},ae,{"#":1,"?":1,"{":1,"}":1}),oe=u({},se,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),le=function(e,t){var i=f(e,0);return i>32&&i<127&&!c(t,e)?e:encodeURIComponent(e)},he={ftp:21,file:null,http:80,https:443,ws:80,wss:443},ce=function(e,t){var i;return 2==e.length&&L(G,R(e,0))&&(":"==(i=R(e,1))||!t&&"|"==i)},ue=function(e){var t;return e.length>1&&ce(B(e,0,2))&&(2==e.length||"/"===(t=R(e,2))||"\\"===t||"?"===t||"#"===t)},de=function(e){return"."===e||"%2e"===z(e)},pe=function(e){return".."===(e=z(e))||"%2e."===e||".%2e"===e||"%2e%2e"===e},fe={},me={},ge={},ve={},ye={},xe={},be={},_e={},we={},Me={},Se={},Ee={},Te={},Ae={},Ce={},Pe={},Re={},Le={},De={},Ie={},Oe={},ke=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 ke(i,!0)),r=this.parse(s,null,n))throw T(r);(a=S(new M)).bindURL(this),this.searchParams=a}};ke.prototype={type:"URL",parse:function(t,i,n){var r,a,s,o,l=this,h=i||fe,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,"$1")),t=N(t,ie,""),r=d(t);u<=r.length;){switch(a=r[u],h){case fe:if(!a||!L(G,a)){if(i)return V;h=ge;continue}f+=z(a),h=me;break;case me:if(a&&(L(X,a)||"+"==a||"-"==a||"."==a))f+=z(a);else{if(":"!=a){if(i)return V;f="",h=ge,u=0;continue}if(i&&(l.isSpecial()!=c(he,f)||"file"==f&&(l.includesCredentials()||null!==l.port)||"file"==l.scheme&&!l.host))return;if(l.scheme=f,i)return void(l.isSpecial()&&he[l.scheme]==l.port&&(l.port=null));f="","file"==l.scheme?h=Ae:l.isSpecial()&&n&&n.scheme==l.scheme?h=ve:l.isSpecial()?h=_e:"/"==r[u+1]?(h=ye,u++):(l.cannotBeABaseURL=!0,k(l.path,""),h=De)}break;case ge: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=Oe;break}h="file"==n.scheme?Ae:xe;continue;case ve:if("/"!=a||"/"!=r[u+1]){h=xe;continue}h=we,u++;break;case ye:if("/"==a){h=Me;break}h=Le;continue;case xe: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=be;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=Ie;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=Le;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=Oe}break;case be:if(!l.isSpecial()||"/"!=a&&"\\"!=a){if("/"!=a){l.username=n.username,l.password=n.password,l.host=n.host,l.port=n.port,h=Le;continue}h=Me}else h=we;break;case _e:if(h=we,"/"!=a||"/"!=R(f,u+1))continue;u++;break;case we:if("/"!=a&&"\\"!=a){h=Me;continue}break;case Me:if("@"==a){m&&(f="%40"+f),m=!0,s=d(f);for(var x=0;x65535)return j;l.port=l.isSpecial()&&w===he[l.scheme]?null:w,f=""}if(i)return;h=Re;continue}return j}f+=a;break;case Ae:if(l.scheme="file","/"==a||"\\"==a)h=Ce;else{if(!n||"file"!=n.scheme){h=Le;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=Ie;else{if("#"!=a){ue(D(p(r,u),""))||(l.host=n.host,l.path=p(n.path),l.shortenPath()),h=Le;continue}l.host=n.host,l.path=p(n.path),l.query=n.query,l.fragment="",h=Oe}}break;case Ce:if("/"==a||"\\"==a){h=Pe;break}n&&"file"==n.scheme&&!ue(D(p(r,u),""))&&(ce(n.path[0],!0)?k(l.path,n.path[0]):l.host=n.host),h=Le;continue;case Pe:if(a==e||"/"==a||"\\"==a||"?"==a||"#"==a){if(!i&&ce(f))h=Le;else if(""==f){if(l.host="",i)return;h=Re}else{if(o=l.parseHost(f))return o;if("localhost"==l.host&&(l.host=""),i)return;f="",h=Re}continue}f+=a;break;case Re:if(l.isSpecial()){if(h=Le,"/"!=a&&"\\"!=a)continue}else if(i||"?"!=a)if(i||"#"!=a){if(a!=e&&(h=Le,"/"!=a))continue}else l.fragment="",h=Oe;else l.query="",h=Ie;break;case Le:if(a==e||"/"==a||"\\"==a&&l.isSpecial()||!i&&("?"==a||"#"==a)){if(pe(f)?(l.shortenPath(),"/"!=a&&!("\\"==a&&l.isSpecial())&&k(l.path,"")):de(f)?"/"!=a&&!("\\"==a&&l.isSpecial())&&k(l.path,""):("file"==l.scheme&&!l.path.length&&ce(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];)F(l.path);"?"==a?(l.query="",h=Ie):"#"==a&&(l.fragment="",h=Oe)}else f+=le(a,se);break;case De:"?"==a?(l.query="",h=Ie):"#"==a?(l.fragment="",h=Oe):a!=e&&(l.path[0]+=le(a,re));break;case Ie:i||"#"!=a?a!=e&&("'"==a&&l.isSpecial()?l.query+="%27":l.query+="#"==a?"%23":le(a,re)):(l.fragment="",h=Oe);break;case Oe:a!=e&&(l.fragment+=le(a,ae))}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&&L(K,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(!L(q,d()))return;for(;L(q,d());){if(a=A(d(),10),null===r)r=a;else{if(0==r)return;r=10*r+a}if(r>255)return;u++}l[h]=256*l[h]+r,(2==++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 W;this.host=t}else if(this.isSpecial()){if(e=m(e),L($,e)||(t=function(e){var t,i,n,r,a,s,o,l=U(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=L(Y,r)?16:8,r=B(r,8==a?1:2)),""===r)s=0;else{if(!L(10==a?Z:8==a?J:K,r))return e;s=A(r,a)}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 ke(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())},Be=Ue.prototype,ze=function(e,t){return{get:function(){return w(this)[e]()},set:t&&function(e){return w(this)[t](e)},configurable:!0,enumerable:!0}};i&&(l(Be,"href",ze("serialize","setHref")),l(Be,"origin",ze("getOrigin")),l(Be,"protocol",ze("getProtocol","setProtocol")),l(Be,"username",ze("getUsername","setUsername")),l(Be,"password",ze("getPassword","setPassword")),l(Be,"host",ze("getHost","setHost")),l(Be,"hostname",ze("getHostname","setHostname")),l(Be,"port",ze("getPort","setPort")),l(Be,"pathname",ze("getPathname","setPathname")),l(Be,"search",ze("getSearch","setSearch")),l(Be,"searchParams",ze("getSearchParams")),l(Be,"hash",ze("getHash","setHash"))),o(Be,"toJSON",(function(){return w(this).serialize()}),{enumerable:!0}),o(Be,"toString",(function(){return w(this).serialize()}),{enumerable:!0}),E&&(Ne=E.createObjectURL,Fe=E.revokeObjectURL,Ne&&o(Ue,"createObjectURL",a(Ne,E)),Fe&&o(Ue,"revokeObjectURL",a(Fe,E))),v(Ue,"URL"),t({global:!0,constructor:!0,forced:!n,sham:!i},{URL:Ue})})),Wae=W((()=>{jae()})),$ae=W((()=>{var e=We(),t=fi(),i=Ft(),n=Lc(),r=lr(),a=oS(),s=t("URL");e({target:"URL",stat:!0,forced:!(a&&i((function(){s.canParse()})))},{canParse:function(e){var t=n(arguments.length,1),i=r(e),a=t<2||void 0===arguments[1]?void 0:r(arguments[1]);try{return!!new s(i,a)}catch(e){return!1}}})})),Kae=W((()=>{"use strict";var e=We(),t=ar();e({target:"URL",proto:!0,enumerable:!0},{toJSON:function(){return t(URL.prototype.toString,this)}})})),Zae=W((()=>{Ak()})),Jae=W((()=>{"use strict";var e=kn(),t=Vt(),i=vs(),n=URLSearchParams.prototype,r=t(n.forEach);e&&!("size"in n)&&i(n,"size",{get:function(){var e=0;return r(this,(function(){e++})),e},configurable:!0,enumerable:!0})})),eoe=W(((e,t)=>{eq(),oq(),lq(),cq(),uq(),hq(),dq(),fq(),pq(),mq(),gq(),vq(),yq(),xq(),bq(),Wq(),Zq(),p9(),y9(),b9(),M9(),P9(),D9(),k9(),F9(),B9(),U9(),G9(),q9(),X9(),Y9(),Z9(),oj(),lj(),uj(),hj(),z1(),Dj(),Fj(),Nj(),Hj(),Vj(),Wj(),Yj(),Kj(),Qj(),eW(),gW(),xW(),bW(),_W(),MW(),RW(),AW(),CW(),PW(),DW(),iX(),gX(),SX(),RX(),AX(),PX(),LX(),OX(),qX(),jX(),KX(),eY(),nY(),lY(),hY(),mY(),gY(),H3(),vY(),LY(),FY(),HY(),VY(),GY(),qY(),XY(),$Y(),JY(),e$(),n$(),i$(),s$(),a$(),o$(),u$(),f$(),p$(),m$(),M$(),R$(),P$(),D$(),L$(),O$(),k$(),F$(),z$(),K$(),tK(),oK(),uK(),mK(),gK(),xK(),EK(),TK(),wK(),AK(),CK(),PK(),LK(),OK(),kK(),NK(),BK(),UK(),zK(),qK(),WK(),YK(),$K(),KK(),ZK(),rZ(),iZ(),sZ(),lZ(),cZ(),hZ(),fZ(),wJ(),SJ(),RJ(),IJ(),DJ(),HJ(),zJ(),GJ(),XJ(),YJ(),$J(),KJ(),ZJ(),JJ(),QJ(),iQ(),aQ(),oQ(),TQ(),SQ(),vw(),IQ(),LQ(),FQ(),HQ(),VQ(),zQ(),WQ(),QQ(),nee(),iee(),DL(),vee(),Ree(),Cee(),Pee(),Oee(),kee(),Vee(),Wee(),$ee(),tte(),ate(),lte(),dte(),vte(),_te(),Mte(),Rte(),Ate(),Cte(),Pte(),Ite(),Dte(),Lte(),Ote(),kte(),Fte(),Nte(),Bte(),dne(),fne(),pne(),mne(),gne(),vne(),yne(),xne(),bne(),_ne(),wne(),Mne(),Ane(),One(),Fne(),Bne(),Une(),zne(),qne(),jne(),Xne(),$ne(),ere(),nre(),ire(),are(),lre(),ure(),dre(),pre(),bre(),_re(),wre(),Pre(),Lre(),Bre(),Hre(),Ure(),zre(),Gre(),Yre(),hie(),fie(),_ie(),Iie(),Bie(),qie(),ise(),hse(),fse(),wse(),Sse(),Rse(),Gse(),Kse(),Wae(),$ae(),Kae(),Zae(),Jae(),t.exports=iT()})),toe=W(((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 v?t:v,s=Object.create(a.prototype),o=new R(n||[]);return r(s,"_invoke",{value:T(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="suspendedYield",f="executing",m="completed",g={};function v(){}function y(){}function x(){}var b={};h(b,s,(function(){return this}));var _=Object.getPrototypeOf,w=_&&_(_(L([])));w&&w!==i&&n.call(w,s)&&(b=w);var M=x.prototype=v.prototype=Object.create(b);function S(e){["next","throw","return"].forEach((function(t){h(e,t,(function(e){return this._invoke(t,e)}))}))}function E(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 T(e,t,i){var n=d;return function(r,a){if(n===f)throw new Error("Generator is already running");if(n===m){if("throw"===r)throw a;return D()}for(i.method=r,i.arg=a;;){var s=i.delegate;if(s){var o=A(s,i);if(o){if(o===g)continue;return o}}if("next"===i.method)i.sent=i._sent=i.arg;else if("throw"===i.method){if(n===d)throw n=m,i.arg;i.dispatchException(i.arg)}else"return"===i.method&&i.abrupt("return",i.arg);n=f;var l=u(e,t,i);if("normal"===l.type){if(n=i.done?m:p,l.arg===g)continue;return{value:l.arg,done:i.done}}"throw"===l.type&&(n=m,i.method="throw",i.arg=l.arg)}}}function A(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,A(e,i),"throw"===i.method)||"return"!==n&&(i.method="throw",i.arg=new TypeError("The iterator does not provide a '"+n+"' method")),g;var a=u(r,e.iterator,i.arg);if("throw"===a.type)return i.method="throw",i.arg=a.arg,i.delegate=null,g;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,g):s:(i.method="throw",i.arg=new TypeError("iterator result is not an object"),i.delegate=null,g)}function C(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function P(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function R(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(C,this),this.reset(!0)}function L(e){if(e){var 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),P(i),g}},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;P(i)}return r}}throw new Error("illegal catch attempt")},delegateYield:function(e,i,n){return this.delegate={iterator:L(e),resultName:i,nextLoc:n},"next"===this.method&&(this.arg=t),g}},e}("object"==typeof t?t.exports:{});try{regeneratorRuntime=i}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=i:Function("r","regeneratorRuntime = r")(i)}})),aue=W(((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(t,i){for(var r=0;r=0&&i<=o.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&&h){try{return void(window.localStorage[h]=i)}catch(e){}try{window.document.cookie=encodeURIComponent(h)+"="+i+";"}catch(e){}}}(i),s.call(o,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)})),M5=W(((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]}})),A5=W(((e,t)=>{"use strict";var i=OR(),n=Wue();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=OR(),n=M5(),r=A5(),a=Zue();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=OR(),n=M5(),r=A5(),a=$ue(),s=the()})),she=W(((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=rhe(),n=she();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=Hhe();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}})),Ghe=W(((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);io.__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)}(o,e);var l=c(o);return function(e,t,i){t&&n(e.prototype,t),i&&n(e,i),Object.defineProperty(e,"prototype",{writable:!1})}(o,[{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=d(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,l=0;l>>15,d=o.__imul(c,n),p=o.__imul(c,r),f=o.__imul(u,n),m=s+d+a;a=m>>>30,m&=1073741823,a+=(m+=((32767&p)<<15)+((32767&f)<<15))>>>30,s=o.__imul(u,r)+(p>>>15)+(f>>>15),this.__setDigit(l,1073741823&m)}if(0!==a||0!==s)throw new Error("implementation bug")}},{key:"__inplaceAdd",value:function(e,t,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 o.__zero();if(o.__isOneDigitInt(e))return 0>e?o.__oneDigit(-e,!0):o.__oneDigit(e,!1);if(!t(e)||s(e)!==e)throw new RangeError("The number "+e+" cannot be converted to BigInt because it is not an integer");return o.__fromDouble(e)}if("string"==typeof e){var n=o.__fromString(e);if(null===n)throw new SyntaxError("Cannot convert "+e+" to a BigInt");return n}if("boolean"==typeof e)return!0===e?o.__oneDigit(1,!1):o.__zero();if("object"===i(e)){if(e.constructor===o)return e;var r=o.__toPrimitive(e);return o.BigInt(r)}throw new TypeError("Cannot convert "+e+" to a BigInt")}},{key:"toNumber",value:function(e){var t=e.length;if(0===t)return 0;if(1===t){var i=e.__unsignedDigit(0);return e.sign?-i:i}var n=e.__digit(t-1),r=o.__clz30(n),a=30*t-r;if(1024>>=12;var d=c-12,p=12<=c?0:l<<20+c,f=20+c;for(0>>30-d,p=l<>>30-f,f-=30;var m=o.__decideRounding(e,f,h,l);if((1===m||0===m&&1==(1&p))&&0==(p=p+1>>>0)&&++u>>>20!=0&&(u=0,1023<++s))return e.sign?-1/0:1/0;var g=e.sign?-2147483648:0;return s=s+1023<<20,o.__kBitConversionInts[1]=g|s|u,o.__kBitConversionInts[0]=p,o.__kBitConversionDouble[0]}},{key:"unaryMinus",value:function(e){if(0===e.length)return e;var t=e.__copy();return t.sign=!e.sign,t}},{key:"bitwiseNot",value:function(e){return e.sign?o.__absoluteSubOne(e).__trim():o.__absoluteAddOne(e,!0)}},{key:"exponentiate",value:function(e,t){if(t.sign)throw new RangeError("Exponent must be positive");if(0===t.length)return o.__oneDigit(1,!1);if(0===e.length)return e;if(1===e.length&&1===e.__digit(0))return!e.sign||1&t.__digit(0)?e:o.unaryMinus(e);if(1=o.__kMaxLengthBits)throw new RangeError("BigInt too big");if(1===e.length&&2===e.__digit(0)){var n=1+(0|i/30),r=new o(n,e.sign&&0!=(1&i));r.__initializeDigits();var a=1<>=1;0!==i;i>>=1)l=o.multiply(l,l),1&i&&(s=null===s?l:o.multiply(s,l));return s}},{key:"multiply",value:function(e,t){if(0===e.length)return e;if(0===t.length)return t;var i=e.length+t.length;30<=e.__clzmsd()+t.__clzmsd()&&i--;var n=new o(i,e.sign!==t.sign);n.__initializeDigits();for(var r=0;ro.__absoluteCompare(e,t))return o.__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:o.unaryMinus(e);i=o.__absoluteDivSmall(e,r,null)}else i=o.__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>o.__absoluteCompare(e,t))return e;var i=t.__unsignedDigit(0);if(1===t.length&&32767>=i){if(1===i)return o.__zero();var n=o.__absoluteModSmall(e,i);return 0===n?o.__zero():o.__oneDigit(n,e.sign)}var r=o.__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?o.__absoluteAdd(e,t,i):0<=o.__absoluteCompare(e,t)?o.__absoluteSub(e,t,i):o.__absoluteSub(t,e,!i)}},{key:"subtract",value:function(e,t){var i=e.sign;return i===t.sign?0<=o.__absoluteCompare(e,t)?o.__absoluteSub(e,t,i):o.__absoluteSub(t,e,!i):o.__absoluteAdd(e,t,i)}},{key:"leftShift",value:function(e,t){return 0===t.length||0===e.length?e:t.sign?o.__rightShiftByAbsolute(e,t):o.__leftShiftByAbsolute(e,t)}},{key:"signedRightShift",value:function(e,t){return 0===t.length||0===e.length?e:t.sign?o.__leftShiftByAbsolute(e,t):o.__rightShiftByAbsolute(e,t)}},{key:"unsignedRightShift",value:function(){throw new TypeError("BigInts have no unsigned right shift; use >> instead")}},{key:"lessThan",value:function(e,t){return 0>o.__compareToBigInt(e,t)}},{key:"lessThanOrEqual",value:function(e,t){return 0>=o.__compareToBigInt(e,t)}},{key:"greaterThan",value:function(e,t){return 0(e=s(e)))throw new RangeError("Invalid value: not (convertible to) a safe integer");if(0===e)return o.__zero();if(e>=o.__kMaxLengthBits)return t;var i=0|(e+29)/30;if(t.length(e=s(e)))throw new RangeError("Invalid value: not (convertible to) a safe integer");if(0===e)return o.__zero();if(t.sign){if(e>o.__kMaxLengthBits)throw new RangeError("BigInt too big");return o.__truncateAndSubFromPowerOfTwo(e,t,!1)}if(e>=o.__kMaxLengthBits)return t;var i=0|(e+29)/30;if(t.length>>n))return t}return o.__truncateToNBits(e,t)}},{key:"ADD",value:function(e,t){if(e=o.__toPrimitive(e),t=o.__toPrimitive(t),"string"==typeof e)return"string"!=typeof t&&(t=t.toString()),e+t;if("string"==typeof t)return e.toString()+t;if(e=o.__toNumeric(e),t=o.__toNumeric(t),o.__isBigInt(e)&&o.__isBigInt(t))return o.add(e,t);if("number"==typeof e&&"number"==typeof t)return e+t;throw new TypeError("Cannot mix BigInt and other types, use explicit conversions")}},{key:"LT",value:function(e,t){return o.__compare(e,t,0)}},{key:"LE",value:function(e,t){return o.__compare(e,t,1)}},{key:"GT",value:function(e,t){return o.__compare(e,t,2)}},{key:"GE",value:function(e,t){return o.__compare(e,t,3)}},{key:"EQ",value:function(e,t){for(;;){if(o.__isBigInt(e))return o.__isBigInt(t)?o.equal(e,t):o.EQ(t,e);if("number"==typeof e){if(o.__isBigInt(t))return o.__equalToNumber(t,e);if("object"!==i(t))return e==t;t=o.__toPrimitive(t)}else if("string"==typeof e){if(o.__isBigInt(t))return null!==(e=o.__fromString(e))&&o.equal(e,t);if("object"!==i(t))return e==t;t=o.__toPrimitive(t)}else if("boolean"==typeof e){if(o.__isBigInt(t))return o.__equalToNumber(t,+e);if("object"!==i(t))return e==t;t=o.__toPrimitive(t)}else if("symbol"===i(e)){if(o.__isBigInt(t))return!1;if("object"!==i(t))return e==t;t=o.__toPrimitive(t)}else{if("object"!==i(e))return e==t;if("object"===i(t)&&t.constructor!==o)return e==t;e=o.__toPrimitive(e)}}}},{key:"NE",value:function(e,t){return!o.EQ(e,t)}},{key:"DataViewGetBigInt64",value:function(e,t){var i=2>>30),h.__setDigit(2,s>>>28),h.__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 o(n,0>e),a=1048575&o.__kBitConversionInts[1]|1048576,s=o.__kBitConversionInts[0],l=i%30,h=0;if(l<20){var c=20-l;h=c+32,t=a>>>c,a=a<<32-c|s>>>c,s<<=32-c}else if(20===l)h=32,t=a,a=s,s=0;else{var u=l-20;h=32-u,t=a<>>32-u,a=s<>>2,a=a<<30|s>>>2,s<<=30):t=0,r.__setDigit(d,t);return r.__trim()}},{key:"__isWhitespace",value:function(e){return 13>=e&&9<=e||(159>=e?32==e:131071>=e?160==e||5760==e:196607>=e?10>=(e&=131071)||40==e||41==e||47==e||95==e||4096==e:65279==e)}},{key:"__fromString",value:function(e){var t=11073741824/l)return null;var c=new o(0|(29+(l*s+h>>>o.__kBitsPerCharTableShift))/30,!1),u=10>t?t:10,d=10>>0>>0>>o.__kBitsPerCharTableShift)/30;c.__inplaceMultiplyAdd(v,g,x)}while(!p)}else{l>>=o.__kBitsPerCharTableShift;var b=[],_=[],w=!1;do{for(var M,S=0,E=0;;){if(M=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),l=0|(30*i-o.__clz30(s)+r-1)/r;if(e.sign&&l++,268435456>>g,d=30-g;d>=r;)h[c--]=o.__kConversionChars[u&a],u>>>=r,d-=r}var v=(u|s<>>r-d;0!==u;)h[c--]=o.__kConversionChars[u&a],u>>>=r;if(e.sign&&(h[c--]="-"),-1!==c)throw new Error("implementation bug");return h.join("")}},{key:"__toStringGeneric",value:function(e,t,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,l=30*n-o.__clz30(e.__digit(n-1)),h=o.__kMaxBitsPerChar[t]-1,c=l*o.__kBitsPerCharTableMultiplier,u=1+(c=0|(c+=h-1)/h)>>1,d=o.exponentiate(o.__oneDigit(t,!1),o.__oneDigit(u,!1)),p=d.__unsignedDigit(0);if(1===d.length&&32767>=p){(a=new o(e.length,!1)).__initializeDigits();for(var f,m=0,g=2*e.length-1;0<=g;g--)f=m<<15|e.__halfDigit(g),a.__setHalfDigit(g,0|f/p),m=0|f%p;s=m.toString(t)}else{var v=o.__absoluteDivLarge(e,d,!0,!0);a=v.quotient;var y=v.remainder.__trim();s=o.__toStringGeneric(y,t,!0)}a.__trim();for(var x=o.__toStringGeneric(a,t,!0);s.lengthn?o.__absoluteLess(i):0}},{key:"__compareToNumber",value:function(e,i){if(o.__isOneDigitInt(i)){var n=e.sign,r=0>i;if(n!==r)return o.__unequalSign(n);if(0===e.length){if(r)throw new Error("implementation bug");return 0===i?0:-1}if(1a?o.__absoluteGreater(n):st)return o.__unequalSign(i);if(0===t)throw new Error("implementation bug: should be handled elsewhere");if(0===e.length)return-1;o.__kBitConversionDouble[0]=t;var n=2047&o.__kBitConversionInts[1]>>>20;if(2047==n)throw new Error("implementation bug: handled elsewhere");var r=n-1023;if(0>r)return o.__absoluteGreater(i);var a=e.length,s=e.__digit(a-1),l=o.__clz30(s),h=30*a-l,c=r+1;if(hc)return o.__absoluteGreater(i);var u=1048576|1048575&o.__kBitConversionInts[1],d=o.__kBitConversionInts[0],p=29-l;if(p!==(0|(h-1)%30))throw new Error("implementation bug");var f,m=0;if(p<20){var g=20-p;m=g+32,f=u>>>g,u=u<<32-g|d>>>g,d<<=32-g}else if(20===p)m=32,f=u,u=d,d=0;else{var v=p-20;m=32-v,f=u<>>32-v,u=d<>>=0)>(f>>>=0))return o.__absoluteGreater(i);if(s>>2,u=u<<30|d>>>2,d<<=30):f=0;var x=e.__unsignedDigit(y);if(x>f)return o.__absoluteGreater(i);if(xi&&e.__unsignedDigit(0)===t(i):0===o.__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(o.__isBigInt(e)&&"string"==typeof t)return null!==(t=o.__fromString(t))&&o.__comparisonResultToBool(o.__compareToBigInt(e,t),i);if("string"==typeof e&&o.__isBigInt(t))return null!==(e=o.__fromString(e))&&o.__comparisonResultToBool(o.__compareToBigInt(e,t),i);if(e=o.__toNumeric(e),t=o.__toNumeric(t),o.__isBigInt(e)){if(o.__isBigInt(t))return o.__comparisonResultToBool(o.__compareToBigInt(e,t),i);if("number"!=typeof t)throw new Error("implementation bug");return o.__comparisonResultToBool(o.__compareToNumber(e,t),i)}if("number"!=typeof e)throw new Error("implementation bug");if(o.__isBigInt(t))return o.__comparisonResultToBool(o.__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(l,1073741823&r);for(;l>>30,a.__setDigit(l,1073741823&h)}return l>>30,r.__setDigit(s,1073741823&n);for(;s>>30,r.__setDigit(s,1073741823&l)}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 o(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 l=n;ln?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,l=0,h=0;h>>15,f=o.__imul(d,r),m=o.__imul(d,a),g=o.__imul(p,r);s=(c+=l+f+s)>>>30,c&=1073741823,s+=(c+=((32767&m)<<15)+((32767&g)<<15))>>>30,l=o.__imul(p,a)+(m>>>15)+(g>>>15),i.__setDigit(n,1073741823&c)}for(;0!==s||0!==l;n++){var v=i.__digit(n);v+=s+l,l=0,s=v>>>30,i.__setDigit(n,1073741823&v)}}}},{key:"__internalMultiplyAdd",value:function(e,t,i,n,r){for(var a=i,s=0,l=0;l>>15,t),d=c+((32767&u)<<15)+s+a;a=d>>>30,s=u>>>15,r.__setDigit(l,1073741823&d)}if(r.length>n)for(r.__setDigit(n++,a+s);n>>0,s=0|a/t,l=0|(a=((n=0|a%t)<<15|e.__halfDigit(r-1))>>>0)/t;n=0|a%t,i.__setDigit(r>>>1,s<<15|l)}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,l=null;i&&(l=new o(s+2>>>1,!1)).__initializeDigits();var h=new o(r+2>>>1,!1);h.__initializeDigits();var c=o.__clz15(t.__halfDigit(r-1));0>>0;m=0|v/d;for(var y=0|v%d,x=t.__halfDigit(r-2),b=u.__halfDigit(f+r-2);o.__imul(m,x)>>>0>(y<<16|b)>>>0&&(m--,!(32767<(y+=d))););}o.__internalMultiplyAdd(t,m,0,a,h);var _=u.__inplaceSub(h,f,r+1);0!==_&&(_=u.__inplaceAdd(t,f,r),u.__setHalfDigit(f+r,32767&u.__halfDigit(f+r)+_),m--),i&&(1&f?p=m<<15:l.__setDigit(f>>>1,p|m))}if(n)return u.__inplaceRightShift(c),i?{quotient:l,remainder:u}:u;if(i)return l;throw new Error("unreachable")}},{key:"__clz15",value:function(e){return o.__clz30(e)-15}},{key:"__specialLeftShift",value:function(e,t,i){var n=e.length,r=new o(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,l=a+n+(s?1:0),h=new o(l,e.sign);if(0===r){for(var c=0;c>>30-r;if(s)h.__setDigit(a+n,u);else if(0!==u)throw new Error("implementation bug")}return h.__trim()}},{key:"__rightShiftByAbsolute",value:function(e,t){var i=e.length,n=e.sign,r=o.__toShiftAmount(t);if(0>r)return o.__rightShiftByMaximum(n);var a=0|r/30,s=r%30,l=i-a;if(0>=l)return o.__rightShiftByMaximum(n);var h=!1;if(n)if(e.__digit(a)&(1<>>s,m=i-a-1,g=0;g>>s;u.__setDigit(m,f)}return h&&(u=o.__absoluteAddOne(u,!0,u)),u.__trim()}},{key:"__rightShiftByMaximum",value:function(e){return e?o.__oneDigit(1,!0):o.__zero()}},{key:"__toShiftAmount",value:function(e){if(1o.__kMaxLengthBits?-1:t}},{key:"__toPrimitive",value:function(e){var t=1>>l}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 o(a,i),l=0,h=a-1,c=0,u=r(h,t.length);l>>30,s.__setDigit(l,1073741823&n);for(;l>>m)-c,d&=g-1}return s.__setDigit(h,d),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}}]),o}(l(Array));return f.__kMaxLength=33554432,f.__kMaxLengthBits=f.__kMaxLength<<5,f.__kMaxBitsPerChar=[0,0,32,51,64,75,83,90,96,102,107,111,115,119,122,126,128,131,134,136,139,141,143,145,147,149,151,153,154,156,158,159,160,162,163,165,166],f.__kBitsPerCharTableShift=5,f.__kBitsPerCharTableMultiplier=1<>>0)/t)},f.__imul=e||function(e,t){return 0|e*t},f},"object"==typeof e&&void 0!==t?t.exports=n():"function"==typeof define&&define.amd?define(n):(i=i||self).JSBI=n()})),ac=W(((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]",M="[object Promise]",S="[object RegExp]",E="[object Set]",T="[object String]",A="[object Symbol]",C="[object WeakMap]",P="[object ArrayBuffer]",R="[object DataView]",L="[object Float32Array]",D="[object Float64Array]",I="[object Int8Array]",O="[object Int16Array]",k="[object Int32Array]",N="[object Uint8Array]",F="[object Uint8ClampedArray]",U="[object Uint16Array]",B="[object Uint32Array]",z=/\b__p \+= '';/g,H=/\b(__p \+=) '' \+/g,V=/(__e\(.*?\)|\b__t\)) \+\n'';/g,W=/&(?:amp|lt|gt|quot|#39);/g,j=/[&<>"']/g,G=RegExp(W.source),X=RegExp(j.source),q=/<%-([\s\S]+?)%>/g,Y=/<%([\s\S]+?)%>/g,J=/<%=([\s\S]+?)%>/g,Z=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,K=/^\w*$/,$=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Q=/[\\^$.*+?()[\]{}|]/g,ee=RegExp(Q.source),te=/^\s+/,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",Me="A-Z\\xc0-\\xd6\\xd8-\\xde",Se="\\ufe0e\\ufe0f",Ee="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",Te="["+xe+"]",Ae="["+Ee+"]",Ce="["+be+"]",Pe="\\d+",Re="["+_e+"]",Le="["+we+"]",De="[^"+xe+Ee+Pe+_e+we+Me+"]",Ie="\\ud83c[\\udffb-\\udfff]",Oe="[^"+xe+"]",ke="(?:\\ud83c[\\udde6-\\uddff]){2}",Ne="[\\ud800-\\udbff][\\udc00-\\udfff]",Fe="["+Me+"]",Ue="\\u200d",Be="(?:"+Le+"|"+De+")",ze="(?:"+Fe+"|"+De+")",He="(?:['\u2019](?:d|ll|m|re|s|t|ve))?",Ve="(?:['\u2019](?:D|LL|M|RE|S|T|VE))?",We="(?:"+Ce+"|"+Ie+")?",je="["+Se+"]?",Ge=je+We+"(?:"+Ue+"(?:"+[Oe,ke,Ne].join("|")+")"+je+We+")*",Xe="(?:"+[Re,ke,Ne].join("|")+")"+Ge,qe="(?:"+[Oe+Ce+"?",Ce,ke,Ne,Te].join("|")+")",Ye=RegExp("['\u2019]","g"),Je=RegExp(Ce,"g"),Ze=RegExp(Ie+"(?="+Ie+")|"+qe+Ge,"g"),Ke=RegExp([Fe+"?"+Le+"+"+He+"(?="+[Ae,Fe,"$"].join("|")+")",ze+"+"+Ve+"(?="+[Ae,Fe+Be,"$"].join("|")+")",Fe+"?"+Be+"+"+He,Fe+"+"+Ve,"\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Pe,Xe].join("|"),"g"),$e=RegExp("["+Ue+xe+be+Se+"]"),Qe=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,et=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],tt=-1,it={};it[L]=it[D]=it[I]=it[O]=it[k]=it[N]=it[F]=it[U]=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[S]=it[E]=it[T]=it[C]=!1;var nt={};nt[p]=nt[f]=nt[P]=nt[R]=nt[m]=nt[g]=nt[L]=nt[D]=nt[I]=nt[O]=nt[k]=nt[b]=nt[_]=nt[w]=nt[S]=nt[E]=nt[T]=nt[A]=nt[N]=nt[F]=nt[U]=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 Kt(e,t){for(var i=e.length;i--&&Ft(t,e[i],0)>-1;);return i}var $t=Vt({"\xc0":"A","\xc1":"A","\xc2":"A","\xc3":"A","\xc4":"A","\xc5":"A","\xe0":"a","\xe1":"a","\xe2":"a","\xe3":"a","\xe4":"a","\xe5":"a","\xc7":"C","\xe7":"c","\xd0":"D","\xf0":"d","\xc8":"E","\xc9":"E","\xca":"E","\xcb":"E","\xe8":"e","\xe9":"e","\xea":"e","\xeb":"e","\xcc":"I","\xcd":"I","\xce":"I","\xcf":"I","\xec":"i","\xed":"i","\xee":"i","\xef":"i","\xd1":"N","\xf1":"n","\xd2":"O","\xd3":"O","\xd4":"O","\xd5":"O","\xd6":"O","\xd8":"O","\xf2":"o","\xf3":"o","\xf4":"o","\xf5":"o","\xf6":"o","\xf8":"o","\xd9":"U","\xda":"U","\xdb":"U","\xdc":"U","\xf9":"u","\xfa":"u","\xfb":"u","\xfc":"u","\xdd":"Y","\xfd":"y","\xff":"y","\xc6":"Ae","\xe6":"ae","\xde":"Th","\xfe":"th","\xdf":"ss","\u0100":"A","\u0102":"A","\u0104":"A","\u0101":"a","\u0103":"a","\u0105":"a","\u0106":"C","\u0108":"C","\u010a":"C","\u010c":"C","\u0107":"c","\u0109":"c","\u010b":"c","\u010d":"c","\u010e":"D","\u0110":"D","\u010f":"d","\u0111":"d","\u0112":"E","\u0114":"E","\u0116":"E","\u0118":"E","\u011a":"E","\u0113":"e","\u0115":"e","\u0117":"e","\u0119":"e","\u011b":"e","\u011c":"G","\u011e":"G","\u0120":"G","\u0122":"G","\u011d":"g","\u011f":"g","\u0121":"g","\u0123":"g","\u0124":"H","\u0126":"H","\u0125":"h","\u0127":"h","\u0128":"I","\u012a":"I","\u012c":"I","\u012e":"I","\u0130":"I","\u0129":"i","\u012b":"i","\u012d":"i","\u012f":"i","\u0131":"i","\u0134":"J","\u0135":"j","\u0136":"K","\u0137":"k","\u0138":"k","\u0139":"L","\u013b":"L","\u013d":"L","\u013f":"L","\u0141":"L","\u013a":"l","\u013c":"l","\u013e":"l","\u0140":"l","\u0142":"l","\u0143":"N","\u0145":"N","\u0147":"N","\u014a":"N","\u0144":"n","\u0146":"n","\u0148":"n","\u014b":"n","\u014c":"O","\u014e":"O","\u0150":"O","\u014d":"o","\u014f":"o","\u0151":"o","\u0154":"R","\u0156":"R","\u0158":"R","\u0155":"r","\u0157":"r","\u0159":"r","\u015a":"S","\u015c":"S","\u015e":"S","\u0160":"S","\u015b":"s","\u015d":"s","\u015f":"s","\u0161":"s","\u0162":"T","\u0164":"T","\u0166":"T","\u0163":"t","\u0165":"t","\u0167":"t","\u0168":"U","\u016a":"U","\u016c":"U","\u016e":"U","\u0170":"U","\u0172":"U","\u0169":"u","\u016b":"u","\u016d":"u","\u016f":"u","\u0171":"u","\u0173":"u","\u0174":"W","\u0175":"w","\u0176":"Y","\u0177":"y","\u0178":"Y","\u0179":"Z","\u017b":"Z","\u017d":"Z","\u017a":"z","\u017c":"z","\u017e":"z","\u0132":"IJ","\u0133":"ij","\u0152":"Oe","\u0153":"oe","\u0149":"'n","\u017f":"s"}),Qt=Vt({"&":"&","<":"<",">":">",'"':""","'":"'"});function ei(e){return"\\"+rt[e]}function ti(e){return $e.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,Me=t.Math,Se=t.Object,Ee=t.RegExp,Te=t.String,Ae=t.TypeError,Ce=xe.prototype,Pe=we.prototype,Re=Se.prototype,Le=t["__core-js_shared__"],De=Pe.toString,Ie=Re.hasOwnProperty,Oe=0,ke=(ie=/[^.]+$/.exec(Le&&Le.keys&&Le.keys.IE_PROTO||""))?"Symbol(src)_1."+ie:"",Ne=Re.toString,Fe=De.call(Se),Ue=ht._,Be=Ee("^"+De.call(Ie).replace(Q,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),ze=dt?t.Buffer:i,He=t.Symbol,Ve=t.Uint8Array,We=ze?ze.allocUnsafe:i,je=ni(Se.getPrototypeOf,Se),Ge=Se.create,Xe=Re.propertyIsEnumerable,qe=Ce.splice,Ze=He?He.isConcatSpreadable:i,$e=He?He.iterator:i,rt=He?He.toStringTag:i,ot=function(){try{var e=oa(Se,"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=Me.ceil,ft=Me.floor,Ot=Se.getOwnPropertySymbols,Vt=ze?ze.isBuffer:i,ui=t.isFinite,di=Ce.join,pi=ni(Se.keys,Se),fi=Me.max,mi=Me.min,gi=be.now,vi=t.parseInt,yi=Me.random,xi=Ce.reverse,bi=oa(t,"DataView"),_i=oa(t,"Map"),wi=oa(t,"Promise"),Mi=oa(t,"Set"),Si=oa(t,"WeakMap"),Ei=oa(Se,"create"),Ti=Si&&new Si,Ai={},Ci=Ia(bi),Pi=Ia(_i),Ri=Ia(wi),Li=Ia(Mi),Di=Ia(Si),Ii=He?He.prototype:i,Oi=Ii?Ii.valueOf:i,ki=Ii?Ii.toString:i;function Ni(e){if(Zs(e)&&!Bs(e)&&!(e instanceof zi)){if(e instanceof Bi)return e;if(Ie.call(e,"__wrapped__"))return Oa(e)}return new Bi(e)}var Fi=function(){function e(){}return function(t){if(!Js(t))return{};if(Ge)return Ge(t);e.prototype=t;var n=new e;return e.prototype=i,n}}();function Ui(){}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(!Js(e))return e;var u=Bs(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(Ws(e))return xr(e,l);if(d==w||d==p||f&&!a){if(o=h||f?{}:da(e),!l)return h?function(e,t){return Tr(e,ha(e),t)}(e,function(e,t){return e&&Tr(t,Co(t),e)}(o,e)):function(e,t){return Tr(e,la(e),t)}(e,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 L:case D:case I:case O:case k:case N:case F:case U:case B:return _r(e,i);case b:return new n;case _:case T:return new n(e);case S:return function(e){var t=new e.constructor(e.source,ce.exec(e));return t.lastIndex=e.lastIndex,t}(e);case E:return new n;case A:return function(e){return Oi?Se(Oi.call(e)):{}}(e)}}(e,d,l)}}s||(s=new Gi);var v=s.get(e);if(v)return v;s.set(e,o),to(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 M=u?i:(c?h?ea:Qr:h?Co:Ao)(e);return Mt(M||e,(function(i,r){M&&(i=e[r=i]),Ki(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=Se(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 Ta((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,qt(i))),n?(a=Ct,s=!1):t.length>=200&&(a=Jt,s=!1,t=new ji(t));e:for(;++r-1},Vi.prototype.set=function(e,t){var i=this.__data__,n=$i(i,e);return n<0?(++this.size,i.push([e,t])):i[n][1]=t,this},Wi.prototype.clear=function(){this.size=0,this.__data__={hash:new Hi,map:new(_i||Vi),string:new Hi}},Wi.prototype.delete=function(e){var t=aa(this,e).delete(e);return this.size-=t?1:0,t},Wi.prototype.get=function(e){return aa(this,e).get(e)},Wi.prototype.has=function(e){return aa(this,e).has(e)},Wi.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},ji.prototype.add=ji.prototype.push=function(e){return this.__data__.set(e,r),this},ji.prototype.has=function(e){return this.__data__.has(e)},Gi.prototype.clear=function(){this.__data__=new Vi,this.size=0},Gi.prototype.delete=function(e){var t=this.__data__,i=t.delete(e);return this.size=t.size,i},Gi.prototype.get=function(e){return this.__data__.get(e)},Gi.prototype.has=function(e){return this.__data__.has(e)},Gi.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 Wi(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,Ao)}function yn(e,t){return e&&gn(e,t,Ao)}function xn(e,t){return Tt(t,(function(t){return Xs(e[t])}))}function bn(e,t){for(var n=0,r=(t=mr(t,e)).length;null!=e&&nt}function Sn(e,t){return null!=e&&Ie.call(e,t)}function En(e,t){return null!=e&&t in Se(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,qt(t))),h=mi(u.length,h),l[o]=!n&&(t||a>=120&&u.length>=120)?new ji(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&&qe.call(o,l,1),qe.call(e,l,1);return e}function Wn(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)?qe.call(e,r,1):or(e,r)}}return e}function jn(e,t){return e+ft(yi()*(t-e+1))}function Gn(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 Aa(wa(e,t,Qo),e+"")}function qn(e){return qi(No(e))}function Yn(e,t){var i=No(e);return Ra(i,rn(t,0,i.length))}function Jn(e,t,n,r){if(!Js(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&&!no(s)&&(i?s<=t:s=200){var h=t?null:Gr(e);if(h)return ai(h);s=!1,r=Jt,l=new ji}else l=t?[]:o;e:for(;++n=r?e:Qn(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=We?We(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=no(e),o=t!==i,l=null===t,h=t==t,c=no(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=Se(t);++r-1?a[s?t[o]:o]:i}}function kr(e){return $r((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&&x.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 ji: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 Mt(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 Pa(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 Ra(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,es(e,n)}));function os(e){var t=Ni(e);return t.__chain__=!0,t}function ls(e,t){return t(e)}var hs=$r((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:ls,args:[a],thisArg:i}),new Bi(r,this.__chain__).thru((function(e){return t&&!e.length&&e.push(i),e}))):this.thru(a)})),cs=Ar((function(e,t,i){Ie.call(e,i)?++e[i]:tn(e,i,1)})),us=Or(Ua),ds=Or(Ba);function ps(e,t){return(Bs(e)?Mt:hn)(e,ra(t,3))}function fs(e,t){return(Bs(e)?St:cn)(e,ra(t,3))}var ms=Ar((function(e,t,i){Ie.call(e,i)?e[i].push(t):tn(e,i,[t])})),gs=Xn((function(e,t,i){var n=-1,r="function"==typeof t,a=Hs(e)?xe(e.length):[];return hn(e,(function(e){a[++n]=r?_t(t,e,i):An(e,t,i)})),a})),vs=Ar((function(e,t,i){tn(e,i,t)}));function ys(e,t){return(Bs(e)?Pt:kn)(e,ra(t,3))}var xs=Ar((function(e,t,i){e[i?0:1].push(t)}),(function(){return[[],[]]})),bs=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),[])})),_s=ct||function(){return ht.Date.now()};function ws(e,t,n){return t=n?i:t,t=e&&null==t?e.length:t,qr(e,o,i,i,i,i,t)}function Ms(e,t){var r;if("function"!=typeof t)throw new Ae(n);return e=ho(e),function(){return--e>0&&(r=t.apply(this,arguments)),e<=1&&(t=i),r}}var Ss=Xn((function(e,t,i){var n=1;if(i.length){var r=ri(i,na(Ss));n|=s}return qr(e,n,t,i,r)})),Es=Xn((function(e,t,i){var n=3;if(i.length){var r=ri(i,na(Es));n|=s}return qr(t,n,e,i,r)}));function Ts(e,t,r){var a,s,o,l,h,c,u=0,d=!1,p=!1,f=!0;if("function"!=typeof e)throw new Ae(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=_s();if(g(e))return y(e);h=Ta(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=_s(),n=g(e);if(a=arguments,s=this,c=e,n){if(h===i)return function(e){return u=e,h=Ta(v,t),d?m(e):l}(c);if(p)return yr(h),h=Ta(v,t),m(c)}return h===i&&(h=Ta(v,t)),l}return t=uo(t)||0,Js(r)&&(d=!!r.leading,o=(p="maxWait"in r)?fi(uo(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(_s())},x}var As=Xn((function(e,t){return on(e,1,t)})),Cs=Xn((function(e,t,i){return on(e,uo(t)||0,i)}));function Ps(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(Ps.Cache||Wi),i}function Rs(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)}}Ps.Cache=Wi;var Ls=gr((function(e,t){var i=(t=1==t.length&&Bs(t[0])?Pt(t[0],qt(ra())):Pt(fn(t,1),qt(ra()))).length;return Xn((function(n){for(var r=-1,a=mi(n.length,i);++r=t})),Us=Cn(function(){return arguments}())?Cn:function(e){return Zs(e)&&Ie.call(e,"callee")&&!Xe.call(e,"callee")},Bs=xe.isArray,zs=mt?qt(mt):function(e){return Zs(e)&&wn(e)==P};function Hs(e){return null!=e&&Ys(e.length)&&!Xs(e)}function Vs(e){return Zs(e)&&Hs(e)}var Ws=Vt||dl,js=gt?qt(gt):function(e){return Zs(e)&&wn(e)==g};function Gs(e){if(!Zs(e))return!1;var t=wn(e);return t==v||"[object DOMException]"==t||"string"==typeof e.message&&"string"==typeof e.name&&!Qs(e)}function Xs(e){if(!Js(e))return!1;var t=wn(e);return t==y||t==x||"[object AsyncFunction]"==t||"[object Proxy]"==t}function qs(e){return"number"==typeof e&&e==ho(e)}function Ys(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=h}function Js(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function Zs(e){return null!=e&&"object"==typeof e}var Ks=vt?qt(vt):function(e){return Zs(e)&&ca(e)==b};function $s(e){return"number"==typeof e||Zs(e)&&wn(e)==_}function Qs(e){if(!Zs(e)||wn(e)!=w)return!1;var t=je(e);if(null===t)return!0;var i=Ie.call(t,"constructor")&&t.constructor;return"function"==typeof i&&i instanceof i&&De.call(i)==Fe}var eo=yt?qt(yt):function(e){return Zs(e)&&wn(e)==S},to=xt?qt(xt):function(e){return Zs(e)&&ca(e)==E};function io(e){return"string"==typeof e||!Bs(e)&&Zs(e)&&wn(e)==T}function no(e){return"symbol"==typeof e||Zs(e)&&wn(e)==A}var ro=bt?qt(bt):function(e){return Zs(e)&&Ys(e.length)&&!!it[wn(e)]},ao=Vr(On),so=Vr((function(e,t){return e<=t}));function oo(e){if(!e)return[];if(Hs(e))return io(e)?oi(e):Er(e);if($e&&e[$e])return function(e){for(var t,i=[];!(t=e.next()).done;)i.push(t.value);return i}(e[$e]());var t=ca(e);return(t==b?ii:t==E?ai:No)(e)}function lo(e){return e?(e=uo(e))===l||e===-l?17976931348623157e292*(e<0?-1:1):e==e?e:0:0===e?e:0}function ho(e){var t=lo(e),i=t%1;return t==t?i?t-i:t:0}function co(e){return e?rn(ho(e),0,u):0}function uo(e){if("number"==typeof e)return e;if(no(e))return c;if(Js(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=Js(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=Xt(e);var i=de.test(e);return i||fe.test(e)?st(e.slice(2),i?2:8):ue.test(e)?c:+e}function po(e){return Tr(e,Co(e))}function fo(e){return null==e?"":ar(e)}var mo=Cr((function(e,t){if(xa(t)||Hs(t))Tr(t,Ao(t),e);else for(var i in t)Ie.call(t,i)&&Ki(e,i,t[i])})),go=Cr((function(e,t){Tr(t,Co(t),e)})),vo=Cr((function(e,t,i,n){Tr(t,Co(t),e,n)})),yo=Cr((function(e,t,i,n){Tr(t,Ao(t),e,n)})),xo=$r(nn),bo=Xn((function(e,t){e=Se(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,Zr));for(var r=t.length;r--;)or(i,t[r]);return i})),Do=$r((function(e,t){return null==e?{}:function(e,t){return Hn(e,t,(function(t,i){return Mo(e,i)}))}(e,t)}));function Io(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 Oo=Xr(Ao),ko=Xr(Co);function No(e){return null==e?[]:Yt(e,Ao(e))}var Fo=Dr((function(e,t,i){return t=t.toLowerCase(),e+(i?Uo(t):t)}));function Uo(e){return Xo(fo(e).toLowerCase())}function Bo(e){return(e=fo(e))&&e.replace(ge,$t).replace(Je,"")}var zo=Dr((function(e,t,i){return e+(i?"-":"")+t.toLowerCase()})),Ho=Dr((function(e,t,i){return e+(i?" ":"")+t.toLowerCase()})),Vo=Lr("toLowerCase"),Wo=Dr((function(e,t,i){return e+(i?"_":"")+t.toLowerCase()})),jo=Dr((function(e,t,i){return e+(i?" ":"")+Xo(t)})),Go=Dr((function(e,t,i){return e+(i?" ":"")+t.toUpperCase()})),Xo=Lr("toUpperCase");function qo(e,t,n){return e=fo(e),(t=n?i:t)===i?function(e){return Qe.test(e)}(e)?function(e){return e.match(Ke)||[]}(e):function(e){return e.match(se)||[]}(e):e.match(t)||[]}var Yo=Xn((function(e,t){try{return _t(e,i,t)}catch(e){return Gs(e)?e:new _e(e)}})),Jo=$r((function(e,t){return Mt(t,(function(t){t=Da(t),tn(e,t,Ss(e[t],e))})),e}));function Zo(e){return function(){return e}}var Ko=kr(),$o=kr(!0);function Qo(e){return e}function el(e){return Dn("function"==typeof e?e:an(e,1))}var tl=Xn((function(e,t){return function(i){return An(i,e,t)}})),il=Xn((function(e,t){return function(i){return An(e,i,t)}}));function nl(e,t,i){var n=Ao(t),r=xn(t,n);null==i&&(!Js(t)||!r.length&&n.length)&&(i=t,t=e,e=this,r=xn(t,Ao(t)));var a=!(Js(i)&&"chain"in i&&!i.chain),s=Xs(e);return Mt(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 rl(){}var al=Br(Pt),sl=Br(Et),ol=Br(It);function ll(e){return ga(e)?Ht(Da(e)):function(e){return function(t){return bn(t,e)}}(e)}var hl=Hr(),cl=Hr(!0);function ul(){return[]}function dl(){return!1}var pl=Ur((function(e,t){return e+t}),0),fl=jr("ceil"),ml=Ur((function(e,t){return e/t}),1),gl=jr("floor"),vl=Ur((function(e,t){return e*t}),1),yl=jr("round"),xl=Ur((function(e,t){return e-t}),0);return Ni.after=function(e,t){if("function"!=typeof t)throw new Ae(n);return e=ho(e),function(){if(--e<1)return t.apply(this,arguments)}},Ni.ary=ws,Ni.assign=mo,Ni.assignIn=go,Ni.assignInWith=vo,Ni.assignWith=yo,Ni.at=xo,Ni.before=Ms,Ni.bind=Ss,Ni.bindAll=Jo,Ni.bindKey=Es,Ni.castArray=function(){if(!arguments.length)return[];var e=arguments[0];return Bs(e)?e:[e]},Ni.chain=os,Ni.chunk=function(e,t,n){t=(n?ma(e,t,n):t===i)?1:fi(ho(t),0);var r=null==e?0:e.length;if(!r||t<1)return[];for(var a=0,s=0,o=xe(pt(r/t));aa?0:a+n),(r=r===i||r>a?a:ho(r))<0&&(r+=a),r=n>r?0:co(r);n>>0)?(e=fo(e))&&("string"==typeof t||null!=t&&!eo(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(ho(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?Qn(e,1,t):[]},Ni.take=function(e,t,n){return e&&e.length?Qn(e,0,(t=n||t===i?1:ho(t))<0?0:t):[]},Ni.takeRight=function(e,t,n){var r=null==e?0:e.length;return r?Qn(e,(t=r-(t=n||t===i?1:ho(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 Js(i)&&(r="leading"in i?!!i.leading:r,a="trailing"in i?!!i.trailing:a),Ts(e,t,{leading:r,maxWait:t,trailing:a})},Ni.thru=ls,Ni.toArray=oo,Ni.toPairs=Oo,Ni.toPairsIn=ko,Ni.toPath=function(e){return Bs(e)?Pt(e,Da):no(e)?[e]:Er(La(fo(e)))},Ni.toPlainObject=po,Ni.transform=function(e,t,i){var n=Bs(e),r=n||Ws(e)||ro(e);if(t=ra(t,4),null==i){var a=e&&e.constructor;i=r?n?new a:[]:Js(e)&&Xs(a)?Fi(je(e)):{}}return(r?Mt:vn)(e,(function(e,n,r){return t(i,e,n,r)})),i},Ni.unary=function(e){return ws(e,1)},Ni.union=Za,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=Qa,Ni.unzipWith=es,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=No,Ni.valuesIn=function(e){return null==e?[]:Yt(e,Co(e))},Ni.without=ts,Ni.words=qo,Ni.wrap=function(e,t){return Ds(fr(t),e)},Ni.xor=is,Ni.xorBy=ns,Ni.xorWith=rs,Ni.zip=as,Ni.zipObject=function(e,t){return dr(e||[],t||[],Ki)},Ni.zipObjectDeep=function(e,t){return dr(e||[],t||[],Jn)},Ni.zipWith=ss,Ni.entries=Oo,Ni.entriesIn=ko,Ni.extend=go,Ni.extendWith=vo,nl(Ni,Ni),Ni.add=pl,Ni.attempt=Yo,Ni.camelCase=Fo,Ni.capitalize=Uo,Ni.ceil=fl,Ni.clamp=function(e,t,n){return n===i&&(n=t,t=i),n!==i&&(n=(n=uo(n))==n?n:0),t!==i&&(t=(t=uo(t))==t?t:0),rn(uo(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,Ao(t))},Ni.deburr=Bo,Ni.defaultTo=function(e,t){return null==e||e!=e?t:e},Ni.divide=ml,Ni.endsWith=function(e,t,n){e=fo(e),t=ar(t);var r=e.length,a=n=n===i?r:rn(ho(n),0,r);return(n-=t.length)>=0&&e.slice(n,a)==t},Ni.eq=ks,Ni.escape=function(e){return(e=fo(e))&&X.test(e)?e.replace(j,Qt):e},Ni.escapeRegExp=function(e){return(e=fo(e))&&ee.test(e)?e.replace(Q,"\\$&"):e},Ni.every=function(e,t,n){var r=Bs(e)?Et:un;return n&&ma(e,t,n)&&(t=i),r(e,ra(t,3))},Ni.find=us,Ni.findIndex=Ua,Ni.findKey=function(e,t){return kt(e,ra(t,3),vn)},Ni.findLast=ds,Ni.findLastIndex=Ba,Ni.findLastKey=function(e,t){return kt(e,ra(t,3),yn)},Ni.floor=gl,Ni.forEach=ps,Ni.forEachRight=fs,Ni.forIn=function(e,t){return null==e?e:mn(e,ra(t,3),Co)},Ni.forInRight=function(e,t){return null==e?e:gn(e,ra(t,3),Co)},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=wo,Ni.gt=Ns,Ni.gte=Fs,Ni.has=function(e,t){return null!=e&&ua(e,t,Sn)},Ni.hasIn=Mo,Ni.head=Ha,Ni.identity=Qo,Ni.includes=function(e,t,i,n){e=Hs(e)?e:No(e),i=i&&!n?ho(i):0;var r=e.length;return i<0&&(i=fi(r+i,0)),io(e)?i<=r&&e.indexOf(t,i)>-1:!!r&&Ft(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:ho(i);return r<0&&(r=fi(n+r,0)),Ft(e,t,r)},Ni.inRange=function(e,t,n){return t=lo(t),n===i?(n=t,t=0):n=lo(n),function(e,t,i){return e>=mi(t,i)&&e=-h&&e<=h},Ni.isSet=to,Ni.isString=io,Ni.isSymbol=no,Ni.isTypedArray=ro,Ni.isUndefined=function(e){return e===i},Ni.isWeakMap=function(e){return Zs(e)&&ca(e)==C},Ni.isWeakSet=function(e){return Zs(e)&&"[object WeakSet]"==wn(e)},Ni.join=function(e,t){return null==e?"":di.call(e,t)},Ni.kebabCase=zo,Ni.last=Ga,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=ho(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=Ho,Ni.lowerFirst=Vo,Ni.lt=ao,Ni.lte=so,Ni.max=function(e){return e&&e.length?dn(e,Qo,Mn):i},Ni.maxBy=function(e,t){return e&&e.length?dn(e,ra(t,2),Mn):i},Ni.mean=function(e){return zt(e,Qo)},Ni.meanBy=function(e,t){return zt(e,ra(t,2))},Ni.min=function(e){return e&&e.length?dn(e,Qo,On):i},Ni.minBy=function(e,t){return e&&e.length?dn(e,ra(t,2),On):i},Ni.stubArray=ul,Ni.stubFalse=dl,Ni.stubObject=function(){return{}},Ni.stubString=function(){return""},Ni.stubTrue=function(){return!0},Ni.multiply=vl,Ni.nth=function(e,t){return e&&e.length?Bn(e,ho(t)):i},Ni.noConflict=function(){return ht._===this&&(ht._=Ue),this},Ni.noop=rl,Ni.now=_s,Ni.pad=function(e,t,i){e=fo(e);var n=(t=ho(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=fo(e);var n=(t=ho(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 jn(e,t)},Ni.reduce=function(e,t,i){var n=Bs(e)?Lt:Wt,r=arguments.length<3;return n(e,ra(t,4),i,r,hn)},Ni.reduceRight=function(e,t,i){var n=Bs(e)?Dt:Wt,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:ho(t),Gn(fo(e),t)},Ni.replace=function(){var e=arguments,t=fo(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=Gt(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),eo(a)){if(e.slice(l).search(a)){var c,u=h;for(a.global||(a=Ee(a.source,fo(ce.exec(a))+"g")),a.lastIndex=0;c=a.exec(u);)var d=c.index;h=h.slice(0,d===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=fo(e))&&G.test(e)?e.replace(W,hi):e},Ni.uniqueId=function(e){var t=++Oe;return fo(e)+t},Ni.upperCase=Go,Ni.upperFirst=Xo,Ni.each=ps,Ni.eachRight=fs,Ni.first=Ha,nl(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",Mt(["bind","bindKey","curry","curryRight","partial","partialRight"],(function(e){Ni[e].placeholder=Ni})),Mt(["drop","take"],(function(e,t){zi.prototype[e]=function(n){n=n===i?1:fi(ho(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()}})),Mt(["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}})),Mt(["head","last"],(function(e,t){var i="take"+(t?"Right":"");zi.prototype[e]=function(){return this[i](1).value()[0]}})),Mt(["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(Qo)},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(Rs(ra(e)))},zi.prototype.slice=function(e,t){e=ho(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=ho(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||Bs(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:ls,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)})})),Mt(["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(Bs(r)?r:[],e)}return this[i]((function(i){return t.apply(Bs(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=Bs(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 Ui;){var r=Oa(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:ls,args:[Ja],thisArg:i}),new Bi(t,this.__chain__)}return this.thru(Ja)},Ni.prototype.toJSON=Ni.prototype.valueOf=Ni.prototype.value=function(){return cr(this.__wrapped__,this.__actions__)},Ni.prototype.first=Ni.prototype.head,$e&&(Ni.prototype[$e]=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)})),Zhe=W(((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()})),Jhe=W(((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()})),ede=W(((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}})),nde=W(((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}})),sde=W(((e,t)=>{var i=ede(),n=nde();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})),ode=W(((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,M,S,E,T,A,C,P,R,L=e-c,D=l-c,I=i-u,O=h-u;v=(A=(b=L-(x=(y=134217729*L)-(y-L)))*(w=O-(_=(y=134217729*O)-(y-O)))-((T=L*O)-x*_-b*_-x*w))-(M=A-(P=(b=I-(x=(y=134217729*I)-(y-I)))*(w=D-(_=(y=134217729*D)-(y-D)))-((C=I*D)-x*_-b*_-x*w))),n[0]=A-(M+v)+(v-P),v=(E=T-((S=T+M)-(v=S-T))+(M-v))-(M=E-C),n[1]=E-(M+v)+(v-C),v=(R=S+M)-S,n[2]=S-(R-v)+(M-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-(L+(v=e-L))+(v-c),m=l-(D+(v=l-D))+(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+=L*g+O*p-(I*m+D*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))-(M=A-(P=(b=f-(x=(y=134217729*f)-(y-f)))*(w=D-(_=(y=134217729*D)-(y-D)))-((C=f*D)-x*_-b*_-x*w))),o[0]=A-(M+v)+(v-P),v=(E=T-((S=T+M)-(v=S-T))+(M-v))-(M=E-C),o[1]=E-(M+v)+(v-C),v=(R=S+M)-S,o[2]=S-(R-v)+(M-v),o[3]=R;let F=t(4,n,4,o,r);v=(A=(b=L-(x=(y=134217729*L)-(y-L)))*(w=g-(_=(y=134217729*g)-(y-g)))-((T=L*g)-x*_-b*_-x*w))-(M=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-(M+v)+(v-P),v=(E=T-((S=T+M)-(v=S-T))+(M-v))-(M=E-C),o[1]=E-(M+v)+(v-C),v=(R=S+M)-S,o[2]=S-(R-v)+(M-v),o[3]=R;let U=t(F,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))-(M=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-(M+v)+(v-P),v=(E=T-((S=T+M)-(v=S-T))+(M-v))-(M=E-C),o[1]=E-(M+v)+(v-C),v=(R=S+M)-S,o[2]=S-(R-v)+(M-v),o[3]=R;let B=t(U,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={})})),fde=W(((e,t)=>{"use strict";var i=Zhe(),n=Jhe(),r=sde(),a=ode().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,M=y*b-x*x,S=M,E=M;0===M?(h=0,S=1,u=w,E=b):(u=y*w-x*_,(h=x*w-b*_)<0?(h=0,u=w,E=b):h>S&&(h=S,u=w+x,E=b)),u<0?(u=0,-_<0?h=0:-_>y?h=S:(h=-_,S=y)):u>E&&(u=E,-_+x<0?h=0:-_+x>y?h=S:(h=-_+x,S=y));var T=(1-(c=0===u?0:u/E))*r+c*s-((1-(l=0===h?0:h/S))*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})),Ode=W(((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")}}}})),Fde=W(((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}})),Bde=W(((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}}})),Ude=W(((e,t)=>{var i=Bde();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})),Wde=W(((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=Ode(),r=Fde(),a=Ude(),s=zde(),o=qde(),l=Wde(),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})),Hpe=W(((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,L=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}(),D=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(L.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]:L.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 M=this._splitSafely(s,w),S=0,E=M.length;SB)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 U(m),M=m.size,S=m.pop();S;){var E=S.key;if(m.size===M){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{})),Wme=W((()=>{})),Xme=W((()=>{})),Yme=W((()=>{})),$me=W((()=>{})),Kme=W((()=>{})),Sge=W(((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(ao(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=>{pt(this,i,!0),e(t)},this.reject=e=>{pt(this,i,!0),t(e)}}))}get settled(){return ne(this,i)}};let p=null,f=null},(__unused_webpack_module,exports,__w_pdfjs_require__)=>{var s,e,n,r,Kv,a,p2,l,c,u,h,d,f,p,g,E6,v,b,_6,E,M;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,M="boolean"==typeof e.isOffscreenCanvasSupported?e.isOffscreenCanvasSupported:!_is_node.isNodeJS,S=Number.isInteger(e.canvasMaxAreaInBytes)?e.canvasMaxAreaInBytes:-1,E="boolean"==typeof e.disableFontFace?e.disableFontFace:_is_node.isNodeJS,T=!0===e.fontExtraProperties,A=!0===e.enableXfa,C=e.ownerDocument||globalThis.document,P=!0===e.disableRange,R=!0===e.disableStream,L=!0===e.disableAutoFetch,D=!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}),F=e.filterFactory||new DefaultFilterFactory({docId:r,ownerDocument:C});(0,_util.setVerbosityLevel)(p);let U={canvasFactory:N,filterFactory:F};if(k||(U.cMapReaderFactory=new v({baseUrl:m,isCompressed:g}),U.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:L,rangeChunkSize:u,length:I,docBaseUrl:f,enableXfa:A,evaluatorOptions:{maxImageSize:_,disableFontFace:E,ignoreErrors:b,isEvalSupported:w,isOffscreenCanvasSupported:M,canvasMaxAreaInBytes:S,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:L,pdfBug:D,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,U);n._transport=a,i.send("Ready",null)}))})).catch(n._capability.reject),n}function _fetchDocument(e,t){return nt(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"+k_(t,s)._++,this.destroyed=!1,this.onPassword=null,this.onProgress=null}get promise(){return this._capability.promise}destroy(){return nt(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;s=new WeakMap,ze(PDFDocumentLoadingTask,s,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){ze(this,r),ze(this,a),ze(this,e,null),ze(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 nt(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);pt(this,n,!1),rt(this,a,p2).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)&&pt(this,n,!0),rt(this,r,Kv).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(),pt(this,n,!1),rt(this,a,p2).call(this),Promise.all(e)}cleanup(e=!1){pt(this,n,!0);let t=rt(this,r,Kv).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();rt(this,r,Kv).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,Kv=function(t=!1){if(rt(this,a,p2).call(this),!ne(this,n)||this.destroyed)return!1;if(t)return pt(this,e,setTimeout((()=>{pt(this,e,null),rt(this,r,Kv).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(),pt(this,n,!1),!0},a=new WeakSet,p2=function(){ne(this,e)&&(clearTimeout(ne(this,e)),pt(this,e,null))},exports.PDFPageProxy=PDFPageProxy;class LoopbackPort{constructor(){ze(this,l,new Set),ze(this,c,Promise.resolve())}postMessage(e,t){let i={data:structuredClone(e,t?{transfer:t}:null)};ne(this,c).then((()=>{for(let e of ne(this,l))e.call(this,i)}))}addEventListener(e,t){ne(this,l).add(t)}removeEventListener(e,t){ne(this,l).delete(t)}terminate(){ne(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 OP)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&&ne(_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 ne(_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),ne(_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 ne(this,h).has(e.port)?ne(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=()=>nt(this,null,(function*(){let mainWorkerMessageHandler=this._mainThreadWorkerMessageHandler;if(mainWorkerMessageHandler)return mainWorkerMessageHandler;if(_is_node.isNodeJS&&"function"==typeof OP){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,ze(PDFWorker,h,new WeakMap),exports.PDFWorker=PDFWorker;class WorkerTransport{constructor(e,t,i,n,r){ze(this,g),ze(this,d,new Map),ze(this,f,new Map),ze(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 ne(this,f).values())e.push(i._destroy());ne(this,f).clear(),ne(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(),ne(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||ne(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=ne(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=ne(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 ne(this,f).set(t,i),i}));return ne(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 rt(this,g,E6).call(this,"GetFieldObjects")}hasJSActions(){return rt(this,g,E6).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=ne(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 ne(this,d).set(e,i),i}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}startCleanup(e=!1){return nt(this,null,(function*(){if(!this.destroyed){yield this.messageHandler.sendWithPromise("Cleanup",null);for(let e of ne(this,f).values())if(!e.cleanup())throw new Error(`startCleanup: Page ${e.pageNumber} is currently rendering.`);this.commonObjs.clear(),e||this.fontLoader.clear(),ne(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,E6=function(e,t=null){let i=ne(this,d).get(e);if(i)return i;let n=this.messageHandler.sendWithPromise(e,t);return ne(this,d).set(e,n),n};class PDFObjects{constructor(){ze(this,b),ze(this,v,Object.create(null))}get(e,t=null){if(t){let i=rt(this,b,_6).call(this,e);return i.capability.promise.then((()=>t(i.data))),null}let i=ne(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=ne(this,v)[e];return(null==t?void 0:t.capability.settled)||!1}resolve(e,t=null){let i=rt(this,b,_6).call(this,e);i.data=t,i.capability.resolve()}clear(){var e;for(let t in ne(this,v)){let{data:i}=ne(this,v)[t];null==(e=null==i?void 0:i.bitmap)||e.close()}pt(this,v,Object.create(null))}}v=new WeakMap,b=new WeakSet,_6=function(e){return ne(this,v)[e]||(ne(this,v)[e]={capability:new _util.PromiseCapability,data:null})};class RenderTask{constructor(e){ze(this,E,null),pt(this,E,e),this.onContinue=null}get promise(){return ne(this,E).capability.promise}cancel(e=0){ne(this,E).cancel(null,e)}get separateAnnots(){let{separateAnnots:e}=ne(this,E).operatorList;if(!e)return!1;let{annotationCanvasMap:t}=ne(this,E);return e.form||e.canvas&&(null==t?void 0:t.size)>0}}E=new WeakMap,exports.RenderTask=RenderTask;let T=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(ne(T,M).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.");ne(T,M).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&&ne(T,M).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 nt(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&&ne(T,M).delete(this._canvas),this.callback())))}))}},InternalRenderTask=T;M=new WeakMap,ze(InternalRenderTask,M,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(){ze(this,a),ze(this,n,!1),ze(this,r,new Map),this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(e,t){let i=ne(this,r).get(e);return void 0===i?t:Object.assign(t,i)}getRawValue(e){return ne(this,r).get(e)}remove(e){if(ne(this,r).delete(e),0===ne(this,r).size&&this.resetModified(),"function"==typeof this.onAnnotationEditor){for(let e of ne(this,r).values())if(e instanceof h.AnnotationEditor)return;this.onAnnotationEditor(null)}}setValue(e,t){let i=ne(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,ne(this,r).set(e,t);n&&rt(this,a,s).call(this),t instanceof h.AnnotationEditor&&"function"==typeof this.onAnnotationEditor&&this.onAnnotationEditor(t.constructor._type)}has(e){return ne(this,r).has(e)}getAll(){return ne(this,r).size>0?(0,l.objectFromMap)(ne(this,r)):null}setAll(e){for(let[t,i]of Object.entries(e))this.setValue(t,i)}get size(){return ne(this,r).size}resetModified(){ne(this,n)&&(pt(this,n,!1),"function"==typeof this.onResetModified&&this.onResetModified())}get print(){return new p(this)}get serializable(){if(0===ne(this,r).size)return u;let e=new Map,t=new c.MurmurHash3_64,i=[];for(let[n,a]of ne(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(){ne(this,n)||(pt(this,n,!0),"function"==typeof this.onSetModified&&this.onSetModified())},t.AnnotationStorage=d;class p extends d{constructor(e){super(),ze(this,o,void 0);let{map:t,hash:i,transfers:n}=e.serializable,r=structuredClone(t,n?{transfer:n}:null);pt(this,o,{map:r,hash:i,transfers:n})}get print(){(0,l.unreachable)("Should not call PrintAnnotationStorage.print")}get serializable(){return ne(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){ze(this,n,this.focusin.bind(this)),ze(this,r,this.focusout.bind(this)),ze(this,a,!1),ze(this,s,!1),ze(this,o,!1),Si(this,"_uiManager",null),ze(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=ne(this,l)}setParent(e){null!==e&&(this.pageIndex=e.pageIndex,this.pageDimensions=e.pageDimensions),this.parent=e}focusin(e){ne(this,a)?pt(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",ne(this,n)),this.div.addEventListener("focusout",ne(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),pt(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(){pt(this,o,!0)}disableEditMode(){pt(this,o,!1)}isInEditMode(){return ne(this,o)}shouldGetKeyboardEvents(){return!1}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}rebuild(){var e,t;null==(e=this.div)||e.addEventListener("focusin",ne(this,n)),null==(t=this.div)||t.addEventListener("focusout",ne(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",ne(this,n)),this.div.removeEventListener("focusout",ne(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 ne(this,s)}set isEditing(e){pt(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,Si(d,"_colorManager",new h.ColorManager),Si(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,M,S,E,T,A,C,P,R,L,D,I,O,k,N,F,U,B,z,H,V,W,j,G,X,q,Y,J,Z,K,$,Q,ee,te;Object.defineProperty(t,"__esModule",{value:!0}),t.KeyboardManager=t.CommandManager=t.ColorManager=t.AnnotationEditorUIManager=void 0,t.bindEvents=function(e,t,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),re=i(6);class ae{constructor(){ze(this,n,0)}getId(){return`${ie.AnnotationEditorPrefix}${k_(this,n)._++}`}}n=new WeakMap;class se{constructor(e=128){ze(this,r,[]),ze(this,a,!1),ze(this,s,void 0),ze(this,o,-1),pt(this,s,e)}add({cmd:e,undo:t,mustExec:i,type:n=NaN,overwriteIfSameType:l=!1,keepUndo:h=!1}){if(i&&e(),ne(this,a))return;let c={cmd:e,undo:t,type:n};if(-1===ne(this,o))return ne(this,r).length>0&&(ne(this,r).length=0),pt(this,o,0),void ne(this,r).push(c);if(l&&ne(this,r)[ne(this,o)].type===n)return h&&(c.undo=ne(this,r)[ne(this,o)].undo),void(ne(this,r)[ne(this,o)]=c);let u=ne(this,o)+1;u===ne(this,s)?ne(this,r).splice(0,1):(pt(this,o,u),ue===t[i])))return le._colorsMapping.get(i);return t}getHexCode(e){let t=this._colors.get(e);return t?ie.Util.makeHexColor(...t):e}},he=le;Si(he,"_colorsMapping",new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]])),t.ColorManager=he;let ce=class{constructor(e,t,i){ze(this,O),ze(this,N),ze(this,U),ze(this,z),ze(this,V),ze(this,j),ze(this,X),ze(this,Y),ze(this,Z),ze(this,$),ze(this,ee),ze(this,c,null),ze(this,u,new Map),ze(this,d,new Map),ze(this,p,null),ze(this,f,new se),ze(this,m,0),ze(this,g,new Set),ze(this,v,null),ze(this,y,new Set),ze(this,x,null),ze(this,b,new ae),ze(this,_,!1),ze(this,w,ie.AnnotationEditorType.NONE),ze(this,M,new Set),ze(this,S,this.copy.bind(this)),ze(this,E,this.cut.bind(this)),ze(this,T,this.paste.bind(this)),ze(this,A,this.keydown.bind(this)),ze(this,C,this.onEditingAction.bind(this)),ze(this,P,this.onPageChanging.bind(this)),ze(this,R,this.onScaleChanging.bind(this)),ze(this,L,this.onRotationChanging.bind(this)),ze(this,D,{isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1}),ze(this,I,null),pt(this,I,e),pt(this,x,t),ne(this,x)._on("editingaction",ne(this,C)),ne(this,x)._on("pagechanging",ne(this,P)),ne(this,x)._on("scalechanging",ne(this,R)),ne(this,x)._on("rotationchanging",ne(this,L)),pt(this,p,i),this.viewParameters={realScale:re.PixelsPerInch.PDF_TO_CSS_UNITS,rotation:0}}static get _keyboardManager(){return(0,ie.shadow)(this,"_keyboardManager",new oe([[["ctrl+a","mac+meta+a"],ce.prototype.selectAll],[["ctrl+z","mac+meta+z"],ce.prototype.undo],[["ctrl+y","ctrl+shift+Z","mac+meta+shift+Z"],ce.prototype.redo],[["Backspace","alt+Backspace","ctrl+Backspace","shift+Backspace","mac+Backspace","mac+alt+Backspace","mac+ctrl+Backspace","Delete","ctrl+Delete","shift+Delete"],ce.prototype.delete],[["Escape","mac+Escape"],ce.prototype.unselectAll]]))}destroy(){rt(this,N,F).call(this),ne(this,x)._off("editingaction",ne(this,C)),ne(this,x)._off("pagechanging",ne(this,P)),ne(this,x)._off("scalechanging",ne(this,R)),ne(this,x)._off("rotationchanging",ne(this,L));for(let e of ne(this,d).values())e.destroy();ne(this,d).clear(),ne(this,u).clear(),ne(this,y).clear(),pt(this,c,null),ne(this,M).clear(),ne(this,f).destroy()}onPageChanging({pageNumber:e}){pt(this,m,e-1)}focusMainContainer(){ne(this,I).focus()}addShouldRescale(e){ne(this,y).add(e)}removeShouldRescale(e){ne(this,y).delete(e)}onScaleChanging({scale:e}){this.commitOrRemove(),this.viewParameters.realScale=e*re.PixelsPerInch.PDF_TO_CSS_UNITS;for(let t of ne(this,y))t.onScaleChanging()}onRotationChanging({pagesRotation:e}){this.commitOrRemove(),this.viewParameters.rotation=e}addToAnnotationStorage(e){!e.isEmpty()&&ne(this,p)&&!ne(this,p).has(e.id)&&ne(this,p).setValue(e.id,e)}copy(e){if(e.preventDefault(),ne(this,c)&&ne(this,c).commitOrRemove(),!this.hasSelection)return;let t=[];for(let i of ne(this,M)){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=ne(this,d).get(ne(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)rt(this,Z,K).call(this,t);rt(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()||ce._keyboardManager.exec(this,e)}onEditingAction(e){["undo","redo","delete","selectAll"].includes(e.name)&&this[e.name]()}setEditingState(e){e?(rt(this,O,k).call(this),rt(this,U,B).call(this),rt(this,V,W).call(this,{isEditing:ne(this,w)!==ie.AnnotationEditorType.NONE,isEmpty:rt(this,$,Q).call(this),hasSomethingToUndo:ne(this,f).hasSomethingToUndo(),hasSomethingToRedo:ne(this,f).hasSomethingToRedo(),hasSelectedEditor:!1})):(rt(this,N,F).call(this),rt(this,z,H).call(this),rt(this,V,W).call(this,{isEditing:!1}))}registerEditorTypes(e){if(!ne(this,v)){pt(this,v,e);for(let e of ne(this,v))rt(this,j,G).call(this,e.defaultPropertiesToUpdate)}}getId(){return ne(this,b).getId()}get currentLayer(){return ne(this,d).get(ne(this,m))}get currentPageIndex(){return ne(this,m)}addLayer(e){ne(this,d).set(e.pageIndex,e),ne(this,_)?e.enable():e.disable()}removeLayer(e){ne(this,d).delete(e.pageIndex)}updateMode(e){if(pt(this,w,e),e===ie.AnnotationEditorType.NONE)this.setEditingState(!1),rt(this,Y,J).call(this);else{this.setEditingState(!0),rt(this,X,q).call(this);for(let t of ne(this,d).values())t.updateMode(e)}}updateToolbar(e){e!==ne(this,w)&&ne(this,x).dispatch("switchannotationeditormode",{source:this,mode:e})}updateParams(e,t){if(ne(this,v)){for(let i of ne(this,M))i.updateParams(e,t);for(let i of ne(this,v))i.updateDefaultParams(e,t)}}getEditors(e){let t=[];for(let i of ne(this,u).values())i.pageIndex===e&&t.push(i);return t}getEditor(e){return ne(this,u).get(e)}addEditor(e){ne(this,u).set(e.id,e)}removeEditor(e){var t;ne(this,u).delete(e.id),this.unselect(e),(!e.annotationElementId||!ne(this,g).has(e.annotationElementId))&&(null==(t=ne(this,p))||t.remove(e.id))}addDeletedAnnotationElement(e){ne(this,g).add(e.annotationElementId),e.deleted=!0}isDeletedAnnotationElement(e){return ne(this,g).has(e)}removeDeletedAnnotationElement(e){ne(this,g).delete(e.annotationElementId),e.deleted=!1}setActiveEditor(e){ne(this,c)!==e&&(pt(this,c,e),e&&rt(this,j,G).call(this,e.propertiesToUpdate))}toggleSelected(e){if(ne(this,M).has(e))return ne(this,M).delete(e),e.unselect(),void rt(this,V,W).call(this,{hasSelectedEditor:this.hasSelection});ne(this,M).add(e),e.select(),rt(this,j,G).call(this,e.propertiesToUpdate),rt(this,V,W).call(this,{hasSelectedEditor:!0})}setSelected(e){for(let t of ne(this,M))t!==e&&t.unselect();ne(this,M).clear(),ne(this,M).add(e),e.select(),rt(this,j,G).call(this,e.propertiesToUpdate),rt(this,V,W).call(this,{hasSelectedEditor:!0})}isSelected(e){return ne(this,M).has(e)}unselect(e){e.unselect(),ne(this,M).delete(e),rt(this,V,W).call(this,{hasSelectedEditor:this.hasSelection})}get hasSelection(){return 0!==ne(this,M).size}undo(){ne(this,f).undo(),rt(this,V,W).call(this,{hasSomethingToUndo:ne(this,f).hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:rt(this,$,Q).call(this)})}redo(){ne(this,f).redo(),rt(this,V,W).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:ne(this,f).hasSomethingToRedo(),isEmpty:rt(this,$,Q).call(this)})}addCommands(e){ne(this,f).add(e),rt(this,V,W).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:rt(this,$,Q).call(this)})}delete(){if(this.commitOrRemove(),!this.hasSelection)return;let e=[...ne(this,M)];this.addCommands({cmd:()=>{for(let t of e)t.remove()},undo:()=>{for(let t of e)rt(this,Z,K).call(this,t)},mustExec:!0})}commitOrRemove(){var e;null==(e=ne(this,c))||e.commitOrRemove()}selectAll(){for(let e of ne(this,M))e.commit();rt(this,ee,te).call(this,ne(this,u).values())}unselectAll(){if(ne(this,c))ne(this,c).commitOrRemove();else if(0!==ne(this,M).size){for(let e of ne(this,M))e.unselect();ne(this,M).clear(),rt(this,V,W).call(this,{hasSelectedEditor:!1})}}isActive(e){return ne(this,c)===e}getActive(){return ne(this,c)}getMode(){return ne(this,w)}},ue=ce;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,M=new WeakMap,S=new WeakMap,E=new WeakMap,T=new WeakMap,A=new WeakMap,C=new WeakMap,P=new WeakMap,R=new WeakMap,L=new WeakMap,D=new WeakMap,I=new WeakMap,O=new WeakSet,k=function(){ne(this,I).addEventListener("keydown",ne(this,A))},N=new WeakSet,F=function(){ne(this,I).removeEventListener("keydown",ne(this,A))},U=new WeakSet,B=function(){document.addEventListener("copy",ne(this,S)),document.addEventListener("cut",ne(this,E)),document.addEventListener("paste",ne(this,T))},z=new WeakSet,H=function(){document.removeEventListener("copy",ne(this,S)),document.removeEventListener("cut",ne(this,E)),document.removeEventListener("paste",ne(this,T))},V=new WeakSet,W=function(e){Object.entries(e).some((([e,t])=>ne(this,D)[e]!==t))&&ne(this,x).dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(ne(this,D),e)})},j=new WeakSet,G=function(e){ne(this,x).dispatch("annotationeditorparamschanged",{source:this,details:e})},X=new WeakSet,q=function(){if(!ne(this,_)){pt(this,_,!0);for(let e of ne(this,d).values())e.enable()}},Y=new WeakSet,J=function(){if(this.unselectAll(),ne(this,_)){pt(this,_,!1);for(let e of ne(this,d).values())e.disable()}},Z=new WeakSet,K=function(e){let t=ne(this,d).get(e.pageIndex);t?t.addOrRebuild(e):this.addEditor(e)},$=new WeakSet,Q=function(){if(0===ne(this,u).size)return!0;if(1===ne(this,u).size)for(let e of ne(this,u).values())return e.isEmpty();return!1},ee=new WeakSet,te=function(e){ne(this,M).clear();for(let t of e)t.isEmpty()||(ne(this,M).add(t),t.select());rt(this,V,W).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,M,S,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,j(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=j,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=W,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 L,D=class{},I=D;Si(I,"CSS",96),Si(I,"PDF",72),Si(I,"PDF_TO_CSS_UNITS",D.CSS/D.PDF),t.PixelsPerInch=I;class O extends C.BaseFilterFactory{constructor({docId:e,ownerDocument:t=globalThis.document}={}){super(),ze(this,f),ze(this,g),ze(this,y),ze(this,b),ze(this,w),ze(this,S),ze(this,T),ze(this,n,void 0),ze(this,r,void 0),ze(this,a,void 0),ze(this,s,void 0),ze(this,o,void 0),ze(this,l,void 0),ze(this,h,void 0),ze(this,c,void 0),ze(this,u,void 0),ze(this,d,void 0),ze(this,p,0),pt(this,a,e),pt(this,s,t)}addFilter(e){if(!e)return"none";let t,i,n,r,s=ne(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=ne(this,f,m).get(r),s)return ne(this,f,m).set(e,s),s;let o=`g_${ne(this,a)}_transfer_map_${k_(this,p)._++}`,l=`url(#${o})`;ne(this,f,m).set(e,l),ne(this,f,m).set(r,l);let h=rt(this,b,_).call(this,o);return rt(this,S,E).call(this,t,i,n,h),l}addHCMFilter(e,t){var i;let n=`${e}-${t}`;if(ne(this,l)===n)return ne(this,h);if(pt(this,l,n),pt(this,h,"none"),null==(i=ne(this,o))||i.remove(),!e||!t)return ne(this,h);let r=rt(this,T,A).call(this,e);e=P.Util.makeHexColor(...r);let s=rt(this,T,A).call(this,t);if(t=P.Util.makeHexColor(...s),ne(this,g,v).style.color="","#000000"===e&&"#ffffff"===t||e===t)return ne(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:ao((e+.055)/1.055,2.4)}let d=u.join(","),p=`g_${ne(this,a)}_hcm_filter`,f=pt(this,c,rt(this,b,_).call(this,p));rt(this,S,E).call(this,d,d,d,f),rt(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 rt(this,S,E).call(this,m(0,5),m(1,5),m(2,5),f),pt(this,h,`url(#${p})`),ne(this,h)}addHighlightHCMFilter(e,t,i,n){var r;let s=`${e}-${t}-${i}-${n}`;if(ne(this,u)===s)return ne(this,d);if(pt(this,u,s),pt(this,d,"none"),null==(r=ne(this,c))||r.remove(),!e||!t)return ne(this,d);let[o,l]=[e,t].map(rt(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(rt(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(",")},M=`g_${ne(this,a)}_hcm_highlight_filter`,C=pt(this,c,rt(this,b,_).call(this,M));return rt(this,y,x).call(this,C),rt(this,S,E).call(this,w(f[0],m[0],5),w(f[1],m[1],5),w(f[2],m[2],5),C),pt(this,d,`url(#${M})`),ne(this,d)}destroy(e=!1){e&&(ne(this,h)||ne(this,d))||(ne(this,r)&&(ne(this,r).parentNode.parentNode.remove(),pt(this,r,null)),ne(this,n)&&(ne(this,n).clear(),pt(this,n,null)),pt(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 ne(this,n)||pt(this,n,new Map)},g=new WeakSet,v=function(){if(!ne(this,r)){let e=ne(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=ne(this,s).createElementNS(R,"svg");i.setAttribute("width",0),i.setAttribute("height",0),pt(this,r,ne(this,s).createElementNS(R,"defs")),e.append(i),i.append(ne(this,r)),ne(this,s).body.append(e)}return ne(this,r)},y=new WeakSet,x=function(e){let t=ne(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=ne(this,s).createElementNS(R,"filter");return t.setAttribute("color-interpolation-filters","sRGB"),t.setAttribute("id",e),ne(this,g,v).append(t),t},w=new WeakSet,M=function(e,t,i){let n=ne(this,s).createElementNS(R,t);n.setAttribute("type","discrete"),n.setAttribute("tableValues",i),e.append(n)},S=new WeakSet,E=function(e,t,i,n){let r=ne(this,s).createElementNS(R,"feComponentTransfer");n.append(r),rt(this,w,M).call(this,r,"feFuncR",e),rt(this,w,M).call(this,r,"feFuncG",t),rt(this,w,M).call(this,r,"feFuncB",i)},T=new WeakSet,A=function(e){return ne(this,g,v).style.color=e,j(getComputedStyle(ne(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 nt(this,null,(function*(){if(W(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 F extends C.BaseCMapReaderFactory{_fetchData(e,t){return N(e,this.isCompressed).then((e=>({cMapData:e,compressionType:t})))}}t.DOMCMapReaderFactory=F;class U extends C.BaseStandardFontDataFactory{_fetchData(e){return N(e,!0)}}t.DOMStandardFontDataFactory=U;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(){Si(this,"started",Object.create(null)),Si(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;L||(L=new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?"));let t=L.exec(e);if(!t)return null;let 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 nt(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 nt(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}){ze(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(),ne(this,n).clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}loadSystemFont(e){return nt(this,null,(function*(){if(e&&!ne(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(),ne(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 nt(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,M=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,_,M),e.setTransform(u,d,p,f,m,g),[_,M]}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,M=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,M,_),e.setTransform(u,d,p,f,m,g),[M,_]}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 S(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){ze(this,n),ze(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(){rt(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(),rt(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,_),M=w.context,E=Math.min(g[0],v[0]),T=Math.min(g[1],v[1]);M.translate(-E,-T),M.transform(...f),n||(n=this._scaleImage(r.canvas,(0,l.getCurrentTransformInverse)(M)),n=n.img,t&&d&&t.set(i,n)),M.imageSmoothingEnabled=S((0,l.getCurrentTransform)(M),e.interpolate),m(M,n,0,0,n.width,n.height,0,0,s,c),M.globalCompositeOperation="source-in";let A=o.Util.transform((0,l.getCurrentTransformInverse)(M),[1,0,0,1,-E,-T]);return M.fillStyle=d?u.getPattern(a,this,A,h.PathType.FILL):u,M.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?M: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,M=0;for(w=0;w0){let e=1e3*a.measureText(b).width/n*s;if(Snew 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(rt(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(),rt(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 L in o.OPS)void 0!==R.prototype[L]&&(R.prototype[o.OPS[L]]=R.prototype[L])},(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,M,S,E,T,A=c[a],C=c[a+1],P=c[a+2],R=c[s],L=c[s+1],D=c[s+2],I=c[o],O=c[o+1],k=c[o+2],N=Math.round(f),F=Math.round(y);for(let U=N;U<=F;U++){if(Uy?1:g===y?0:(g-U)/(g-y),x=m-(m-v)*e,b=R-(R-I)*e,_=L-(L-O)*e,w=D-(D-k)*e}let e;e=Uy?1:(f-U)/(f-y),M=p-(p-v)*e,S=A-(A-I)*e,E=C-(C-O)*e,T=P-(P-k)*e;let t=Math.round(Math.min(x,M)),i=Math.round(Math.max(x,M)),n=d*U+4*t;for(let r=t;r<=i;r++)e=(x-r)/(x-M),e<0?e=0:e>1&&(e=1),u[n++]=b-(b-S)*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;Si(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(),rt(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)),rt(this,o,l).call(this,a,t);break;case 2:e.success?a.cancelCall.resolve():a.cancelCall.reject(c(e.reason)),rt(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 nt(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){ze(this,n),ze(this,a),ze(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 rt(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?rt(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}){ze(this,n,void 0),ze(this,r,void 0),pt(this,n,e),pt(this,r,t)}getRaw(){return ne(this,r)}get(e){var t;return null!=(t=ne(this,n).get(e))?t:null}getAll(){return(0,a.objectFromMap)(ne(this,n))}has(e){return ne(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){ze(this,n,!0),this.name=e,this.intent=t}get visible(){return ne(this,n)}_setVisible(e,t){e!==d&&(0,c.unreachable)("Internal method `_setVisible` called."),pt(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)(ne(this,a)):null}getGroup(e){return ne(this,a).get(e)||null}getHash(){if(null!==ne(this,r))return ne(this,r);let e=new u.MurmurHash3_64;for(let[t,i]of ne(this,a))e.update(`${t}:${i.visible}`);return pt(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 nt(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 nt(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)=>{b6().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 Wme().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=b6(),s=Xme(),o=Yme(),l=$me(),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 nt(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 nt(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 nt(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 nt(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 nt(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 nt(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),M=i(5),S=i(28),E=i(33),T=i(6);let A=class{constructor(e){ze(this,p),ze(this,m),ze(this,v),ze(this,x),ze(this,n,void 0),ze(this,r,!1),ze(this,a,null),ze(this,s,this.pointerup.bind(this)),ze(this,o,this.pointerdown.bind(this)),ze(this,l,new Map),ze(this,h,!1),ze(this,c,!1),ze(this,u,!1),ze(this,d,void 0),A._initialized||(A._initialized=!0,S.FreeTextEditor.initialize(e.l10n),E.InkEditor.initialize(e.l10n)),e.uiManager.registerEditorTypes([S.FreeTextEditor,E.InkEditor]),pt(this,d,e.uiManager),this.pageIndex=e.pageIndex,this.div=e.div,pt(this,n,e.accessibilityManager),pt(this,a,e.annotationLayer),this.viewport=e.viewport,ne(this,d).addLayer(this)}get isEmpty(){return 0===ne(this,l).size}updateToolbar(e){ne(this,d).updateToolbar(e)}updateMode(e=ne(this,d).getMode()){rt(this,x,b).call(this),e===_.AnnotationEditorType.INK?(this.addInkEditorIfNeeded(!1),this.disableClick()):this.enableClick(),ne(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||ne(this,d).getMode()===_.AnnotationEditorType.INK){if(!e)for(let e of ne(this,l).values())if(e.isEmpty())return void e.setInBackground();rt(this,v,y).call(this,{offsetX:0,offsetY:0}).setInBackground()}}setEditingState(e){ne(this,d).setEditingState(e)}addCommands(e){ne(this,d).addCommands(e)}enable(){this.div.style.pointerEvents="auto";let e=new Set;for(let i of ne(this,l).values())i.enableEditing(),i.annotationElementId&&e.add(i.annotationElementId);if(!ne(this,a))return;let t=ne(this,a).getEditableAnnotations();for(let i of t){if(i.hide(),ne(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;pt(this,u,!0),this.div.style.pointerEvents="none";let t=new Set;for(let i of ne(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(ne(this,a)){let e=ne(this,a).getEditableAnnotations();for(let i of e){let{id:e}=i.data;t.has(e)||ne(this,d).isDeletedAnnotationElement(e)||i.show()}}rt(this,x,b).call(this),this.isEmpty&&(this.div.hidden=!0),pt(this,u,!1)}getEditableAnnotation(e){var t;return(null==(t=ne(this,a))?void 0:t.getEditableAnnotation(e))||null}setActiveEditor(e){ne(this,d).getActive()!==e&&ne(this,d).setActiveEditor(e)}enableClick(){this.div.addEventListener("pointerdown",ne(this,o)),this.div.addEventListener("pointerup",ne(this,s))}disableClick(){this.div.removeEventListener("pointerdown",ne(this,o)),this.div.removeEventListener("pointerup",ne(this,s))}attach(e){ne(this,l).set(e.id,e);let{annotationElementId:t}=e;t&&ne(this,d).isDeletedAnnotationElement(t)&&ne(this,d).removeDeletedAnnotationElement(e)}detach(e){var t;ne(this,l).delete(e.id),null==(t=ne(this,n))||t.removePointerInTextLayer(e.contentDiv),!ne(this,u)&&e.annotationElementId&&ne(this,d).addDeletedAnnotationElement(e)}remove(e){this.detach(e),ne(this,d).removeEditor(e),e.div.style.display="none",setTimeout((()=>{e.div.style.display="",e.div.remove(),e.isAttachedToDOM=!1,document.activeElement===document.body&&ne(this,d).focusMainContainer()}),0),ne(this,c)||this.addInkEditorIfNeeded(!1)}add(e){if(rt(this,p,f).call(this,e),ne(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(),ne(this,d).addToAnnotationStorage(e)}moveEditorInDOM(e){var t;null==(t=ne(this,n))||t.moveElementInDOM(this.div,e.div,e.contentDiv,!0)}addOrRebuild(e){e.needsToBeRebuilt()?e.rebuild():this.add(e)}getNextId(){return ne(this,d).getId()}deserialize(e){var t;switch(null!=(t=e.annotationType)?t:e.annotationEditorType){case _.AnnotationEditorType.FREETEXT:return S.FreeTextEditor.deserialize(e,this,ne(this,d));case _.AnnotationEditorType.INK:return E.InkEditor.deserialize(e,this,ne(this,d))}return null}setSelected(e){ne(this,d).setSelected(e)}toggleSelected(e){ne(this,d).toggleSelected(e)}isSelected(e){return ne(this,d).isSelected(e)}unselect(e){ne(this,d).unselect(e)}pointerup(e){let{isMac:t}=_.FeatureTest.platform;if(!(0!==e.button||e.ctrlKey&&t)&&e.target===this.div&&ne(this,h)){if(pt(this,h,!1),!ne(this,r))return void pt(this,r,!0);rt(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;pt(this,h,!0);let i=ne(this,d).getActive();pt(this,r,!i||i.isEmpty())}drop(e){let t=e.dataTransfer.getData("text/plain"),i=ne(this,d).getEditor(t);if(!i)return;e.preventDefault(),e.dataTransfer.dropEffect="move",rt(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=ne(this,d).getActive())?void 0:e.parent)===this&&ne(this,d).setActiveEditor(null);for(let i of ne(this,l).values())null==(t=ne(this,n))||t.removePointerInTextLayer(i.contentDiv),i.setParent(null),i.isAttachedToDOM=!1,i.div.remove();this.div=null,ne(this,l).clear(),ne(this,d).removeLayer(this)}render({viewport:e}){this.viewport=e,(0,T.setLayerDimensions)(this.div,e),(0,M.bindEvents)(this,this.div,["dragover","drop"]);for(let t of ne(this,d).getEditors(this.pageIndex))this.add(t);this.updateMode()}update({viewport:e}){ne(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&&(ne(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(ne(this,d).getMode()){case _.AnnotationEditorType.FREETEXT:return new S.FreeTextEditor(e);case _.AnnotationEditorType.INK:return new E.InkEditor(e)}return null},v=new WeakSet,y=function(e){let t=this.getNextId(),i=rt(this,m,g).call(this,{parent:this,id:t,x:e.offsetX,y:e.offsetY,uiManager:ne(this,d)});return i&&this.add(i),i},x=new WeakSet,b=function(){pt(this,c,!0);for(let e of ne(this,l).values())e.isEmpty()&&e.remove();pt(this,c,!1)},Si(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,M,S,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(ai(qn({},e),{name:"freeTextEditor"})),ze(this,d),ze(this,f),ze(this,g),ze(this,y),ze(this,b),ze(this,w),ze(this,S),ze(this,n,this.editorDivBlur.bind(this)),ze(this,r,this.editorDivFocus.bind(this)),ze(this,a,this.editorDivInput.bind(this)),ze(this,s,this.editorDivKeydown.bind(this)),ze(this,o,void 0),ze(this,l,""),ze(this,h,`${this.id}-editor`),ze(this,c,void 0),ze(this,u,null),pt(this,o,e.color||R._defaultColor||C.AnnotationEditor._defaultLineColor),pt(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:rt(this,d,p).call(this,t);break;case T.AnnotationEditorParamsType.FREETEXT_COLOR:rt(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,ne(this,c)],[T.AnnotationEditorParamsType.FREETEXT_COLOR,ne(this,o)]]}getInitialTranslation(){let e=this.parentScale;return[-R._internalPadding*e,-(R._internalPadding+ne(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",ne(this,s)),this.editorDiv.addEventListener("focus",ne(this,r)),this.editorDiv.addEventListener("blur",ne(this,n)),this.editorDiv.addEventListener("input",ne(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",ne(this,h)),this.div.draggable=!0,this.editorDiv.removeEventListener("keydown",ne(this,s)),this.editorDiv.removeEventListener("focus",ne(this,r)),this.editorDiv.removeEventListener("blur",ne(this,n)),this.editorDiv.removeEventListener("input",ne(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?rt(this,S,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=ne(this,l),t=pt(this,l,rt(this,g,v).call(this).trimEnd());if(e===t)return;let i=e=>{pt(this,l,e),e?(rt(this,b,_).call(this),this.rebuild(),rt(this,y,x).call(this)):this.remove()};this.addCommands({cmd:()=>{i(t)},undo:()=>{i(e)},mustExec:!1}),rt(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",ne(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(${ne(this,c)}px * var(--scale-factor))`,i.color=ne(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);rt(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 pt(r,c,e.fontSize),pt(r,o,T.Util.makeHexColor(...e.color)),pt(r,l,e.value),r.annotationElementId=e.id||null,pt(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:ne(this,o)),r={annotationType:T.AnnotationEditorType.FREETEXT,color:n,fontSize:ne(this,c),value:ne(this,l),pageIndex:this.pageIndex,rect:i,rotation:this.rotation};return e?r:this.annotationElementId&&!rt(this,w,M).call(this,r)?null:(r.id=this.annotationElementId,r)}},L=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-ne(this,c))*this.parentScale),pt(this,c,e),rt(this,y,x).call(this)},i=ne(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=ne(this,o);this.addCommands({cmd:()=>{pt(this,o,this.editorDiv.style.color=e)},undo:()=>{pt(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(),ne(this,l))for(let e of ne(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,M=function(e){let{value:t,fontSize:i,color:n,rect:r,pageIndex:a}=ne(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},S=new WeakSet,E=function(e=!1){if(!this.annotationElementId)return;if(rt(this,y,x).call(this),!e&&(0===this.width||0===this.height))return void setTimeout((()=>rt(this,S,E).call(this,!0)),0);let t=R._internalPadding*this.parentScale;ne(this,u).rect=this.getRect(t,t)},Si(L,"_freeTextDefaultContent",""),Si(L,"_l10nPromise"),Si(L,"_internalPadding",0),Si(L,"_defaultColor",null),Si(L,"_defaultFontSize",10),Si(L,"_type","freetext"),t.FreeTextEditor=L},(e,t,i)=>{var n,r,a,s,o,l,h,c,u,d,p,f,m,g,v,y,x,b,_,w,M,S,E,T,A,C,P,R,L,D,I,O,k,N,F,U,B,z,H;Object.defineProperty(t,"__esModule",{value:!0}),t.InkAnnotationElement=t.FreeTextAnnotationElement=t.AnnotationLayer=void 0;var V=i(1),W=i(6),j=i(3),G=i(30),X=i(31);let q=1e3,Y=new WeakSet;function J(e){return{width:e[2]-e[0],height:e[3]-e[1]}}class Z{static create(e){switch(e.data.annotationType){case V.AnnotationType.LINK:return new $(e);case V.AnnotationType.TEXT:return new Q(e);case V.AnnotationType.WIDGET:switch(e.data.fieldType){case"Tx":return new te(e);case"Btn":return e.data.radioButton?new ae(e):e.data.checkBox?new re(e):new se(e);case"Ch":return new oe(e);case"Sig":return new ie(e)}return new ee(e);case V.AnnotationType.POPUP:return new le(e);case V.AnnotationType.FREETEXT:return new ce(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 Me(e);default:return new K(e)}}}class K{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 le){let{rotation:e}=t;return!t.hasOwnCanvas&&0!==e&&this.setRotation(e,r),r}let{width:h,height:c}=J(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 ae){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}=J(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]=G.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 le({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||Y.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&&Y.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 $ extends K{constructor(e,t=null){super(e,{isRenderable:!0,ignoreBorder:!(null==t||!t.ignoreBorder),createQuadrilaterals:!0}),ze(this,n),ze(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?(rt(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)&&rt(this,n,r).call(this)}_bindNamedAction(e,t){e.href=this.linkService.getAnchorUrl(""),e.onclick=()=>(this.linkService.executeNamedAction(t),!1),rt(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},rt(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),rt(this,n,r).call(this)}_bindResetFormAction(e,t){let i=e.onclick;if(i||(e.href=this.linkService.getAnchorUrl("")),rt(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&&(Y.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),rt(this,n,r).call(this)};class Q extends K{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 K{render(){return this.data.alternativeText&&(this.container.title=this.data.alternativeText),this.container}showElementAndHideCanvas(e){var t;this.data.hasOwnCanvas&&("CANVAS"===(null==(t=e.previousSibling)?void 0:t.nodeName)&&(e.previousSibling.hidden=!0),e.hidden=!1)}_getKeyModifier(e){let{isWin:t,isMac: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),Y.add(r),r.setAttribute("data-element-id",n),r.disabled=this.data.readOnly,r.name=this.data.baseFieldName||this.data.fieldName,r.tabIndex=q,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 re 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 Y.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=q,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 ae 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(Y.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=q,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 se extends ${constructor(e){super(e,{ignoreBorder:e.data.hasAppearance})}render(){let e=super.render();e.classList.add("buttonWidgetAnnotation","pushButton"),this.data.alternativeText&&(e.title=this.data.alternativeText);let t=e.lastChild;return this.enableScripting&&this.hasJSActions&&t&&(this._setDefaultPropertiesFromJS(t),t.addEventListener("updatefromsandbox",(e=>{this._dispatchEventFromSandbox({},e)}))),e}}class oe 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");Y.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=q;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 le extends K{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 he({container:this.container,color:this.data.color,titleObj:this.data.titleObj,modificationDate:this.data.modificationDate,contentsObj:this.data.contentsObj,richText:this.data.richText,rect:this.data.rect,parentRect:this.data.parentRect||null,parent:this.parent,elements:this.elements,open:this.data.open}),t=[];for(let 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 he{constructor({container:e,color:t,elements:i,titleObj:n,modificationDate:r,contentsObj:a,richText:s,parent:P,rect:R,parentRect:L,open:D}){ze(this,M),ze(this,E),ze(this,A),ze(this,o,null),ze(this,l,rt(this,A,C).bind(this)),ze(this,h,rt(this,E,T).bind(this)),ze(this,c,rt(this,M,S).bind(this)),ze(this,u,null),ze(this,d,null),ze(this,p,null),ze(this,f,null),ze(this,m,null),ze(this,g,null),ze(this,v,!1),ze(this,y,null),ze(this,x,null),ze(this,b,null),ze(this,_,null),ze(this,w,!1),pt(this,d,e),pt(this,_,n),pt(this,p,a),pt(this,b,s),pt(this,m,P),pt(this,u,t),pt(this,x,R),pt(this,g,L),pt(this,f,i);let I=W.PDFDateString.toDateObject(r);I&&pt(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",ne(this,c)),o.addEventListener("mouseenter",ne(this,h)),o.addEventListener("mouseleave",ne(this,l));ne(this,d).hidden=!0,D&&rt(this,M,S).call(this)}render(){if(ne(this,y))return;let{page:{view:e},viewport:{rawDims:{pageWidth:t,pageHeight:i,pageX:n,pageY:r}}}=ne(this,m),a=pt(this,y,document.createElement("div"));if(a.className="popup",ne(this,u)){let e=a.style.outlineColor=V.Util.makeHexColor(...ne(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(...ne(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}=ne(this,_)),a.append(s),ne(this,o)){let e=document.createElement("span");e.classList.add("popupDate"),ne(this,o).then((t=>{e.textContent=t})),s.append(e)}let h=ne(this,p),c=ne(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=!!ne(this,g),w=ne(this,v?g:x);for(let o of ne(this,f))if(!w||null!==V.Util.intersect(o.data.rect,w)){w=o.data.rect,v=!0;break}let M=V.Util.normalizeRect([w[0],e[3]-w[1]+e[1],w[2],e[3]-w[3]+e[1]]),S=v?w[2]-w[0]+5:0,E=M[0]+S,T=M[1],{style:A}=ne(this,d);A.left=100*(E-n)/t+"%",A.top=100*(T-r)/i+"%",ne(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&&ne(this,F).set(i.data.id,i);let a=i.render();if(e.hidden&&(a.style.visibility="hidden"),Array.isArray(a))for(let n of a)rt(this,U,B).call(this,n,e.id);else rt(this,U,B).call(this,a,e.id)}rt(this,z,H).call(this),yield this.l10n.translate(i)}))}update({viewport:e}){let t=this.div;this.viewport=e,(0,W.setLayerDimensions)(t,{rotation:e.rotation}),rt(this,z,H).call(this),t.hidden=!1}getEditableAnnotations(){return Array.from(ne(this,F).values())}getEditableAnnotation(e){return ne(this,F).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 nt(this,null,(function*(){return"en-us"}))},getDirection(){return nt(this,null,(function*(){return"ltr"}))},get(e){return nt(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 nt(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,M,S,E,T,A,C,P,R,L,D,I,O,k,N,F,U,B,z,H,V,W,j,G,X,q,Y,J,Z,K,$,Q,ee,te,ie,re,ae,se,oe,le,he,ce,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),Me=i(5);let Se=16,Ee=class extends _e.AnnotationEditor{constructor(e){super(ai(qn({},e),{name:"inkEditor"})),ze(this,x),ze(this,_),ze(this,M),ze(this,E),ze(this,A),ze(this,P),ze(this,L),ze(this,I),ze(this,k),ze(this,F),ze(this,B),ze(this,H),ze(this,W),ze(this,G),ze(this,q),ze(this,J),ze(this,K),ze(this,Q),ze(this,te),ze(this,ce),ze(this,de),ze(this,fe),ze(this,ge),ze(this,ye),ze(this,n,0),ze(this,r,0),ze(this,a,0),ze(this,s,this.canvasContextMenu.bind(this)),ze(this,o,this.canvasPointermove.bind(this)),ze(this,l,this.canvasPointerleave.bind(this)),ze(this,h,this.canvasPointerup.bind(this)),ze(this,c,this.canvasPointerdown.bind(this)),ze(this,u,new Path2D),ze(this,d,!1),ze(this,p,!1),ze(this,f,!1),ze(this,m,null),ze(this,g,0),ze(this,v,0),ze(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:rt(this,x,b).call(this,t);break;case be.AnnotationEditorParamsType.INK_COLOR:rt(this,_,w).call(this,t);break;case be.AnnotationEditorParamsType.INK_OPACITY:rt(this,M,S).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||(rt(this,q,Y).call(this),rt(this,J,Z).call(this)),this.isAttachedToDOM||(this.parent.add(this),rt(this,K,$).call(this)),rt(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,ne(this,m).disconnect(),pt(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(){ne(this,d)||null===this.canvas||(super.enableEditMode(),this.div.draggable=!1,this.canvas.addEventListener("pointerdown",ne(this,c)))}disableEditMode(){!this.isInEditMode()||null===this.canvas||(super.disableEditMode(),this.div.draggable=!this.isEmpty(),this.div.classList.remove("editing"),this.canvas.removeEventListener("pointerdown",ne(this,c)))}onceAdded(){this.div.draggable=!this.isEmpty()}isEmpty(){return 0===this.paths.length||1===this.paths.length&&0===this.paths[0].length}commit(){ne(this,d)||(super.commit(),this.isEditing=!1,this.disableEditMode(),this.setInForeground(),pt(this,d,!0),this.div.classList.add("disabled"),rt(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()||ne(this,d)||(this.setInForeground(),e.preventDefault(),"mouse"!==e.type&&this.div.focus(),rt(this,P,R).call(this,e.offsetX,e.offsetY))}canvasContextMenu(e){e.preventDefault()}canvasPointermove(e){e.preventDefault(),rt(this,L,D).call(this,e.offsetX,e.offsetY)}canvasPointerup(e){e.preventDefault(),rt(this,G,X).call(this,e)}canvasPointerleave(e){rt(this,G,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]=rt(this,E,T).call(this);if(this.setAt(i,n,0,0),this.setDims(r,a),rt(this,q,Y).call(this),this.width){let[i,n]=this.parentDimensions;this.setAt(e*i,t*n,this.width*i,this.height*n),pt(this,f,!0),rt(this,K,$).call(this),this.setDims(this.width*i,this.height*n),rt(this,W,j).call(this),rt(this,ye,xe).call(this),this.div.classList.add("disabled")}else this.div.classList.add("editing"),this.enableEditMode();return rt(this,J,Z).call(this),this.div}setDimensions(e,t){let i=Math.round(e),r=Math.round(t);if(ne(this,g)===i&&ne(this,v)===r)return;pt(this,g,i),pt(this,v,r),this.canvas.style.visibility="hidden",ne(this,n)&&Math.abs(ne(this,n)-e/t)>.01&&(t=Math.ceil(e/ne(this,n)),this.setDims(e,t));let[a,s]=this.parentDimensions;this.width=e/a,this.height=t/s,ne(this,d)&&rt(this,Q,ee).call(this,e,t),rt(this,K,$).call(this),rt(this,W,j).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;pt(h,n,p/f),pt(h,d,!0),pt(h,g,Math.round(p)),pt(h,v,Math.round(f));let{paths:x,rect:b,rotation:_}=e;for(let{bezier:n}of x){n=rt(s=Ee,le,he).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,rt(this,ge,ve).call(this)},undo:()=>{this.thickness=t,rt(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,rt(this,W,j).call(this)},undo:()=>{this.color=t,rt(this,W,j).call(this)},mustExec:!0,type:be.AnnotationEditorParamsType.INK_COLOR,overwriteIfSameType:!0,keepUndo:!0})},M=new WeakSet,S=function(e){e/=100;let t=this.opacity;this.addCommands({cmd:()=>{this.opacity=e,rt(this,W,j).call(this)},undo:()=>{this.opacity=t,rt(this,W,j).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,Me.opacityToHex)(i)}`},P=new WeakSet,R=function(e,t){this.canvas.addEventListener("contextmenu",ne(this,s)),this.canvas.addEventListener("pointerleave",ne(this,l)),this.canvas.addEventListener("pointermove",ne(this,o)),this.canvas.addEventListener("pointerup",ne(this,h)),this.canvas.removeEventListener("pointerdown",ne(this,c)),this.isEditing=!0,ne(this,f)||(pt(this,f,!0),rt(this,K,$).call(this),this.thickness||(this.thickness=Ee._defaultThickness),this.color||(this.color=Ee._defaultColor||_e.AnnotationEditor._defaultLineColor),null!=this.opacity||(this.opacity=Ee._defaultOpacity)),this.currentPath.push([e,t]),pt(this,p,!1),rt(this,A,C).call(this),pt(this,y,(()=>{rt(this,F,U).call(this),ne(this,y)&&window.requestAnimationFrame(ne(this,y))})),window.requestAnimationFrame(ne(this,y))},L=new WeakSet,D=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=ne(this,u);if(r.push([e,t]),pt(this,p,!0),r.length<=2)return a.moveTo(...r[0]),void a.lineTo(e,t);3===r.length&&(pt(this,u,a=new Path2D),a.moveTo(...r[0])),rt(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);ne(this,u).lineTo(...e)},k=new WeakSet,N=function(e,t){let i;if(pt(this,y,null),e=Math.min(Math.max(e,0),this.canvas.width),t=Math.min(Math.max(t,0),this.canvas.height),rt(this,L,D).call(this,e,t),rt(this,I,O).call(this),1!==this.currentPath.length)i=rt(this,H,V).call(this);else{let n=[e,t];i=[[n,n.slice(),n.slice(),n]]}let n=ne(this,u),r=this.currentPath;this.currentPath=[],pt(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||(rt(this,q,Y).call(this),rt(this,J,Z).call(this)),rt(this,ge,ve).call(this))},mustExec:!0})},F=new WeakSet,U=function(){if(!ne(this,p))return;pt(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(ne(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",ne(this,s))}),10),rt(this,k,N).call(this,e.offsetX,e.offsetY),this.addToAnnotationStorage(),this.setInBackground()},q=new WeakSet,Y=function(){this.canvas=document.createElement("canvas"),this.canvas.width=this.canvas.height=0,this.canvas.className="inkEditorCanvas",Ee._l10nPromise.get("editor_ink_canvas_aria_label").then((e=>{var t;return null==(t=this.canvas)?void 0:t.setAttribute("aria-label",e)})),this.div.append(this.canvas),this.ctx=this.canvas.getContext("2d")},J=new WeakSet,Z=function(){pt(this,m,new ResizeObserver((e=>{let t=e[0].contentRect;t.width&&t.height&&this.setDimensions(t.width,t.height)}))),ne(this,m).observe(this.div)},K=new WeakSet,$=function(){if(!ne(this,f))return;let[e,t]=this.parentDimensions;this.canvas.width=Math.ceil(this.width*e),this.canvas.height=Math.ceil(this.height*t),rt(this,te,ie).call(this)},Q=new WeakSet,ee=function(e,t){let i=rt(this,fe,me).call(this),n=(e-i)/ne(this,a),s=(t-i)/ne(this,r);this.scaleFactor=Math.min(n,s)},te=new WeakSet,ie=function(){let e=rt(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)},re=new WeakSet,ae=function(e){let t=new Path2D;for(let i=0,n=e.length;i=1?(e.minHeight="16px",e.minWidth=`${Math.round(ne(this,n)*Se)}px`):(e.minWidth="16px",e.minHeight=`${Math.round(Se/ne(this,n))}px`)},ze(Te,re),ze(Te,se),ze(Te,le),Si(Te,"_defaultColor",null),Si(Te,"_defaultOpacity",1),Si(Te,"_defaultThickness",1),Si(Te,"_l10nPromise"),Si(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=Kme().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(_),M=0;return w.set(e,M),M+=e.length,i("IHDR",x,w,M),M+=12+x.length,i("IDATA",b,w,M),M+=12+b.length,i("IEND",new Uint8Array(0),w,M),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 M=this.svg,S=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=M,this.transformMatrix=S,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("563bb8ac711ef3deabb13d3eedbfcfc8bbdaee81df4fe1b9799696cbfd3831d7")){var e=document.createElement("style");e.id="563bb8ac711ef3deabb13d3eedbfcfc8bbdaee81df4fe1b9799696cbfd3831d7",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}#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;border:rgba(153,153,153,.8) 1px solid;border-radius:4px;background:rgba(255,255,255,.8);transform:translate(-50%);align-items:center;z-index:10;user-select:none}.toolbar .toolbar-group{display:flex;padding:0 2px;box-sizing:border-box}.toolbar .toolbar-group-division{width:1px;background-color:#999c;height:60%}.toolbar .toolbar-menu{display:flex;box-sizing:border-box;flex-direction:column;word-break:break-word;width:50px;height:50px;padding:3px 1px;margin:0 2px;transition:all .3s;cursor:pointer;color:#666;border-radius:4px}.toolbar .toolbar-menu.active{color:#2c7be5}.toolbar .toolbar-menu .icon{width:24px;height:24px;margin:auto;font-size:24px;line-height:normal}.toolbar .toolbar-menu span{display:block;width:100%;margin:auto;font-size:12px;text-align:center;user-select:none}.toolbar .toolbar-menu-active{color:#2c7be5;background-color:#fffc}.toolbar .toolbar-parent-menu{position:relative}.toolbar .toolbar-parent-menu-active .toolbar-sub-menu{display:block}.toolbar .toolbar-parent-menu-active .toolbar-sub-menu-list{background:rgba(255,255,255,.8)}.toolbar .toolbar-parent-menu:after{content:"";position:absolute;box-sizing:border-box;width:0;height:0;right:2px;top:2px;border-width:4px;border-style:solid;border-top-color:#666;border-right-color:#666;border-bottom-color:transparent;border-left-color:transparent;border-radius:1px}.toolbar .toolbar-sub-menu{display:none;position:absolute;min-width:50px;bottom:100%}.toolbar .toolbar-sub-menu .toolbar-sub-menu-list{margin-bottom:2px;border-radius:4px}.toolbar .toolbar-sub-menu .toolbar-sub-menu-list .toolbar-menu{margin:0}@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}}#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 LEe=fetch;window.fetch=(...e)=>Promise.resolve(LEe(...e));var ptn=Xi(Mz(),1),mtn=Xi(eoe(),1),gtn=Xi(toe(),1),Ot={};O_(Ot,{ACESFilmicToneMapping:()=>Kle,AddEquation:()=>vo,AddOperation:()=>Wle,AdditiveAnimationBlendMode:()=>gB,AdditiveBlending:()=>$l,AlphaFormat:()=>ece,AlwaysCompare:()=>yce,AlwaysDepth:()=>Hle,AlwaysStencilFunc:()=>uce,AmbientLight:()=>il,AmbientLightProbe:()=>HN,AnimationAction:()=>VM,AnimationClip:()=>Ba,AnimationLoader:()=>IN,AnimationMixer:()=>WN,AnimationObjectGroup:()=>jN,AnimationUtils:()=>qit,ArcCurve:()=>Cp,ArrayCamera:()=>xM,ArrowHelper:()=>ec,Audio:()=>HM,AudioAnalyser:()=>GN,AudioContext:()=>Fx,AudioListener:()=>VN,AudioLoader:()=>NN,AxesHelper:()=>aB,BackSide:()=>Ci,BasicDepthPacking:()=>lce,BasicShadowMap:()=>PJe,Bone:()=>tl,BooleanKeyframeTrack:()=>gh,Box2:()=>Pi,Box3:()=>bt,Box3Helper:()=>iB,BoxGeometry:()=>Gs,BoxHelper:()=>rB,BufferAttribute:()=>nn,BufferGeometry:()=>Et,BufferGeometryLoader:()=>BM,ByteType:()=>Jle,Cache:()=>Op,Camera:()=>ch,CameraHelper:()=>Hx,CanvasTexture:()=>wx,CapsuleGeometry:()=>v0,CatmullRomCurve3:()=>TM,CineonToneMapping:()=>$le,CircleGeometry:()=>y0,ClampToEdgeWrapping:()=>oi,Clock:()=>Ua,Color:()=>Ye,ColorKeyframeTrack:()=>Dx,ColorManagement:()=>Jo,CompressedArrayTexture:()=>MN,CompressedTexture:()=>fh,CompressedTextureLoader:()=>DN,ConeGeometry:()=>x0,CubeCamera:()=>vM,CubeReflectionMapping:()=>Td,CubeRefractionMapping:()=>wd,CubeTexture:()=>Ap,CubeTextureLoader:()=>Lx,CubeUVReflectionMapping:()=>I0,CubicBezierCurve:()=>Sx,CubicBezierCurve3:()=>wM,CubicInterpolant:()=>DM,CullFaceBack:()=>PF,CullFaceFront:()=>Cle,CullFaceFrontBack:()=>CJe,CullFaceNone:()=>Ale,Curve:()=>ha,CurvePath:()=>MM,CustomBlending:()=>Bp,CustomToneMapping:()=>Zle,CylinderGeometry:()=>Zl,Cylindrical:()=>ZN,Data3DTexture:()=>bx,DataArrayTexture:()=>d0,DataTexture:()=>el,DataTextureLoader:()=>Fp,DataUtils:()=>k0,DecrementStencilOp:()=>HJe,DecrementWrapStencilOp:()=>VJe,DefaultLoadingManager:()=>Va,DepthFormat:()=>_d,DepthStencilFormat:()=>oh,DepthTexture:()=>Rd,DirectionalLight:()=>_s,DirectionalLightHelper:()=>Bx,DiscreteInterpolant:()=>LM,DisplayP3ColorSpace:()=>xB,DodecahedronGeometry:()=>b0,DoubleSide:()=>or,DstAlphaFactor:()=>C0,DstColorFactor:()=>P0,DynamicCopyUsage:()=>nQe,DynamicDrawUsage:()=>KJe,DynamicReadUsage:()=>QJe,EdgesGeometry:()=>Yc,EllipseCurve:()=>ph,EqualCompare:()=>fce,EqualDepth:()=>Vle,EqualStencilFunc:()=>jJe,EquirectangularReflectionMapping:()=>Mp,EquirectangularRefractionMapping:()=>px,Euler:()=>Dn,EventDispatcher:()=>bo,ExtrudeGeometry:()=>Ad,FileLoader:()=>Cr,Float16BufferAttribute:()=>pN,Float32BufferAttribute:()=>Rt,Float64BufferAttribute:()=>mN,FloatType:()=>zs,Fog:()=>qc,FogExp2:()=>p0,FramebufferTexture:()=>SN,FrontSide:()=>Xr,Frustum:()=>qs,GLBufferAttribute:()=>$N,GLSL1:()=>iQe,GLSL3:()=>iN,GreaterCompare:()=>mce,GreaterDepth:()=>Gle,GreaterEqualCompare:()=>vce,GreaterEqualDepth:()=>zle,GreaterEqualStencilFunc:()=>$Je,GreaterStencilFunc:()=>XJe,GridHelper:()=>Nx,Group:()=>Ln,HalfFloatType:()=>cr,HemisphereLight:()=>Jc,HemisphereLightHelper:()=>tB,HemisphereLightProbe:()=>BN,IcosahedronGeometry:()=>E0,ImageBitmapLoader:()=>kx,ImageLoader:()=>kp,ImageUtils:()=>xx,IncrementStencilOp:()=>BJe,IncrementWrapStencilOp:()=>UJe,InstancedBufferAttribute:()=>dh,InstancedBufferGeometry:()=>NM,InstancedInterleavedBuffer:()=>YN,InstancedMesh:()=>_i,Int16BufferAttribute:()=>dN,Int32BufferAttribute:()=>fN,Int8BufferAttribute:()=>cN,IntType:()=>uB,InterleavedBuffer:()=>hh,InterleavedBufferAttribute:()=>Fa,Interpolant:()=>mh,InterpolateDiscrete:()=>lh,InterpolateLinear:()=>Gc,InterpolateSmooth:()=>dM,InvertStencilOp:()=>zJe,KeepStencilOp:()=>fM,KeyframeTrack:()=>_o,LOD:()=>_M,LatheGeometry:()=>Ip,Layers:()=>Md,LessCompare:()=>dce,LessDepth:()=>Ule,LessEqualCompare:()=>pce,LessEqualDepth:()=>pM,LessEqualStencilFunc:()=>WJe,LessStencilFunc:()=>qJe,Light:()=>Ha,LightProbe:()=>M0,Line:()=>Wn,Line3:()=>pa,LineBasicMaterial:()=>En,LineCurve:()=>g0,LineCurve3:()=>SM,LineDashedMaterial:()=>Kc,LineLoop:()=>m0,LineSegments:()=>Ar,LinearEncoding:()=>yB,LinearFilter:()=>dr,LinearInterpolant:()=>Ix,LinearMipMapLinearFilter:()=>kJe,LinearMipMapNearestFilter:()=>OJe,LinearMipmapLinearFilter:()=>ca,LinearMipmapNearestFilter:()=>Hp,LinearSRGBColorSpace:()=>ua,LinearToneMapping:()=>Xle,Loader:()=>er,LoaderUtils:()=>Ps,LoadingManager:()=>Zc,LoopOnce:()=>sce,LoopPingPong:()=>oce,LoopRepeat:()=>ace,LuminanceAlphaFormat:()=>tce,LuminanceFormat:()=>jM,MOUSE:()=>GM,Material:()=>Qn,MaterialLoader:()=>R0,MathUtils:()=>gn,Matrix3:()=>pn,Matrix4:()=>qe,MaxEquation:()=>OF,Mesh:()=>ht,MeshBasicMaterial:()=>jt,MeshDepthMaterial:()=>Kl,MeshDistanceMaterial:()=>_x,MeshLambertMaterial:()=>$c,MeshMatcapMaterial:()=>IM,MeshNormalMaterial:()=>Id,MeshPhongMaterial:()=>Cs,MeshPhysicalMaterial:()=>Eo,MeshStandardMaterial:()=>Pd,MeshToonMaterial:()=>PM,MinEquation:()=>LF,MirroredRepeatWrapping:()=>ah,MixOperation:()=>jle,MultiplyBlending:()=>DF,MultiplyOperation:()=>Vx,NearestFilter:()=>Or,NearestMipMapLinearFilter:()=>LJe,NearestMipMapNearestFilter:()=>DJe,NearestMipmapLinearFilter:()=>sh,NearestMipmapNearestFilter:()=>Sd,NeverCompare:()=>hce,NeverDepth:()=>Ble,NeverStencilFunc:()=>GJe,NoBlending:()=>kr,NoColorSpace:()=>zc,NoToneMapping:()=>Hc,NormalAnimationBlendMode:()=>XM,NormalBlending:()=>wp,NotEqualCompare:()=>gce,NotEqualDepth:()=>qle,NotEqualStencilFunc:()=>YJe,NumberKeyframeTrack:()=>rl,Object3D:()=>Xt,ObjectLoader:()=>FN,ObjectSpaceNormalMap:()=>cce,OctahedronGeometry:()=>Lp,OneFactor:()=>Dle,OneMinusDstAlphaFactor:()=>kle,OneMinusDstColorFactor:()=>Fle,OneMinusSrcAlphaFactor:()=>cB,OneMinusSrcColorFactor:()=>Ole,OrthographicCamera:()=>Er,PCFShadowMap:()=>oB,PCFSoftShadowMap:()=>A0,PMREMGenerator:()=>uh,Path:()=>Wc,PerspectiveCamera:()=>jn,Plane:()=>Mr,PlaneGeometry:()=>zr,PlaneHelper:()=>sB,PointLight:()=>Ql,PointLightHelper:()=>eB,Points:()=>Yr,PointsMaterial:()=>ci,PolarGridHelper:()=>nB,PolyhedronGeometry:()=>Xc,PositionalAudio:()=>zN,PropertyBinding:()=>Fn,PropertyMixer:()=>UM,QuadraticBezierCurve:()=>Mx,QuadraticBezierCurve3:()=>Rx,Quaternion:()=>Xn,QuaternionKeyframeTrack:()=>fa,QuaternionLinearInterpolant:()=>OM,RED_GREEN_RGTC2_Format:()=>nN,RED_RGTC1_Format:()=>ice,REVISION:()=>zM,RGBADepthPacking:()=>O0,RGBAFormat:()=>As,RGBAIntegerFormat:()=>mB,RGBA_ASTC_10x10_Format:()=>JF,RGBA_ASTC_10x5_Format:()=>$F,RGBA_ASTC_10x6_Format:()=>KF,RGBA_ASTC_10x8_Format:()=>ZF,RGBA_ASTC_12x10_Format:()=>QF,RGBA_ASTC_12x12_Format:()=>eN,RGBA_ASTC_4x4_Format:()=>VF,RGBA_ASTC_5x4_Format:()=>zF,RGBA_ASTC_5x5_Format:()=>GF,RGBA_ASTC_6x5_Format:()=>qF,RGBA_ASTC_6x6_Format:()=>jF,RGBA_ASTC_8x5_Format:()=>WF,RGBA_ASTC_8x6_Format:()=>XF,RGBA_ASTC_8x8_Format:()=>YF,RGBA_BPTC_Format:()=>hM,RGBA_ETC2_EAC_Format:()=>UF,RGBA_PVRTC_2BPPV1_Format:()=>BF,RGBA_PVRTC_4BPPV1_Format:()=>NF,RGBA_S3TC_DXT1_Format:()=>lM,RGBA_S3TC_DXT3_Format:()=>cM,RGBA_S3TC_DXT5_Format:()=>uM,RGB_ETC1_Format:()=>rce,RGB_ETC2_Format:()=>HF,RGB_PVRTC_2BPPV1_Format:()=>FF,RGB_PVRTC_4BPPV1_Format:()=>kF,RGB_S3TC_DXT1_Format:()=>oM,RGFormat:()=>nce,RGIntegerFormat:()=>pB,RawShaderMaterial:()=>CM,Ray:()=>ka,Raycaster:()=>Is,RectAreaLight:()=>kM,RedFormat:()=>WM,RedIntegerFormat:()=>fB,ReinhardToneMapping:()=>Yle,RepeatWrapping:()=>li,ReplaceStencilOp:()=>NJe,ReverseSubtractEquation:()=>Ile,RingGeometry:()=>_0,SIGNED_RED_GREEN_RGTC2_Format:()=>rN,SIGNED_RED_RGTC1_Format:()=>tN,SRGBColorSpace:()=>zt,Scene:()=>ti,ShaderChunk:()=>Kn,ShaderLib:()=>Wl,ShaderMaterial:()=>Yt,ShadowMaterial:()=>AM,Shape:()=>us,ShapeGeometry:()=>Jl,ShapePath:()=>Ux,ShapeUtils:()=>Es,ShortType:()=>Qle,Skeleton:()=>nl,SkeletonHelper:()=>QN,SkinnedMesh:()=>jc,Source:()=>Xl,Sphere:()=>Jn,SphereGeometry:()=>da,Spherical:()=>Dd,SphericalHarmonics3:()=>FM,SplineCurve:()=>Pp,SpotLight:()=>Qc,SpotLightHelper:()=>JN,Sprite:()=>EM,SpriteMaterial:()=>Tx,SrcAlphaFactor:()=>lB,SrcAlphaSaturateFactor:()=>Nle,SrcColorFactor:()=>Lle,StaticCopyUsage:()=>tQe,StaticDrawUsage:()=>gx,StaticReadUsage:()=>JJe,StereoCamera:()=>UN,StreamCopyUsage:()=>rQe,StreamDrawUsage:()=>ZJe,StreamReadUsage:()=>eQe,StringKeyframeTrack:()=>vh,SubtractEquation:()=>Ple,SubtractiveBlending:()=>IF,TOUCH:()=>AJe,TangentSpaceNormalMap:()=>Od,TetrahedronGeometry:()=>T0,Texture:()=>Rr,TextureLoader:()=>rs,TorusGeometry:()=>Cd,TorusKnotGeometry:()=>w0,Triangle:()=>Vr,TriangleFanDrawMode:()=>L0,TriangleStripDrawMode:()=>zx,TrianglesDrawMode:()=>vB,TubeGeometry:()=>S0,TwoPassDoubleSide:()=>IJe,UVMapping:()=>qM,Uint16BufferAttribute:()=>Rp,Uint32BufferAttribute:()=>Ex,Uint8BufferAttribute:()=>uN,Uint8ClampedBufferAttribute:()=>hN,Uniform:()=>Np,UniformsGroup:()=>XN,UniformsLib:()=>Ht,UniformsUtils:()=>ni,UnsignedByteType:()=>Yl,UnsignedInt248Type:()=>Uc,UnsignedIntType:()=>ih,UnsignedShort4444Type:()=>hB,UnsignedShort5551Type:()=>dB,UnsignedShortType:()=>D0,VSMShadowMap:()=>Nc,Vector2:()=>fe,Vector3:()=>P,Vector4:()=>Zn,VectorKeyframeTrack:()=>Na,VideoTexture:()=>wN,WebGL1Renderer:()=>bM,WebGL3DRenderTarget:()=>oN,WebGLArrayRenderTarget:()=>aN,WebGLCoordinateSystem:()=>Bc,WebGLCubeRenderTarget:()=>yM,WebGLMultipleRenderTargets:()=>lN,WebGLRenderTarget:()=>Vn,WebGLRenderer:()=>ns,WebGLUtils:()=>Ace,WebGPUCoordinateSystem:()=>vx,WireframeGeometry:()=>RM,WrapAroundEnding:()=>mx,ZeroCurvatureEnding:()=>Ep,ZeroFactor:()=>Ld,ZeroSlopeEnding:()=>_p,ZeroStencilOp:()=>FJe,_SRGBAFormat:()=>mM,sRGBEncoding:()=>Vc});var zM="154",GM={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},AJe={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},Ale=0,PF=1,Cle=2,CJe=3,PJe=0,oB=1,A0=2,Nc=3,Xr=0,Ci=1,or=2,IJe=2,kr=0,wp=1,$l=2,IF=3,DF=4,Bp=5,vo=100,Ple=101,Ile=102,LF=103,OF=104,Ld=200,Dle=201,Lle=202,Ole=203,lB=204,cB=205,C0=206,kle=207,P0=208,Fle=209,Nle=210,Ble=0,Hle=1,Ule=2,pM=3,Vle=4,zle=5,Gle=6,qle=7,Vx=0,jle=1,Wle=2,Hc=0,Xle=1,Yle=2,$le=3,Kle=4,Zle=5,qM=300,Td=301,wd=302,Mp=303,px=304,I0=306,li=1e3,oi=1001,ah=1002,Or=1003,Sd=1004,DJe=1004,sh=1005,LJe=1005,dr=1006,Hp=1007,OJe=1007,ca=1008,kJe=1008,Yl=1009,Jle=1010,Qle=1011,D0=1012,uB=1013,ih=1014,zs=1015,cr=1016,hB=1017,dB=1018,Uc=1020,ece=1021,As=1023,jM=1024,tce=1025,_d=1026,oh=1027,WM=1028,fB=1029,nce=1030,pB=1031,mB=1033,oM=33776,lM=33777,cM=33778,uM=33779,kF=35840,FF=35841,NF=35842,BF=35843,rce=36196,HF=37492,UF=37496,VF=37808,zF=37809,GF=37810,qF=37811,jF=37812,WF=37813,XF=37814,YF=37815,$F=37816,KF=37817,ZF=37818,JF=37819,QF=37820,eN=37821,hM=36492,ice=36283,tN=36284,nN=36285,rN=36286,sce=2200,ace=2201,oce=2202,lh=2300,Gc=2301,dM=2302,Ep=2400,_p=2401,mx=2402,XM=2500,gB=2501,vB=0,zx=1,L0=2,yB=3e3,Vc=3001,lce=3200,O0=3201,Od=0,cce=1,zc="",zt="srgb",ua="srgb-linear",xB="display-p3",FJe=0,fM=7680,NJe=7681,BJe=7682,HJe=7683,UJe=34055,VJe=34056,zJe=5386,GJe=512,qJe=513,jJe=514,WJe=515,XJe=516,YJe=517,$Je=518,uce=519,hce=512,dce=513,fce=514,pce=515,mce=516,gce=517,vce=518,yce=519,gx=35044,KJe=35048,ZJe=35040,JJe=35045,QJe=35049,eQe=35041,tQe=35046,nQe=35050,rQe=35042,iQe="100",iN="300 es",mM=1035,Bc=2e3,vx=2001,bo=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]+Us[e>>16&255]+Us[e>>24&255]+"-"+Us[255&t]+Us[t>>8&255]+"-"+Us[t>>16&15|64]+Us[t>>24&255]+"-"+Us[63&i|128]+Us[i>>8&255]+"-"+Us[i>>16&255]+Us[i>>24&255]+Us[255&n]+Us[n>>8&255]+Us[n>>16&255]+Us[n>>24&255]).toLowerCase()}function Vi(e,t,i){return Math.max(t,Math.min(i,e))}function bB(e,t){return(e%t+t)%t}function sQe(e,t,i,n,r){return n+(e-t)*(r-n)/(i-t)}function aQe(e,t,i){return e!==t?(i-e)/(t-e):0}function cx(e,t,i){return(1-i)*e+i*t}function oQe(e,t,i,n){return cx(e,t,1-Math.exp(-i*n))}function lQe(e,t=1){return t-Math.abs(bB(e,2*t)-t)}function cQe(e,t,i){return e<=t?0:e>=i?1:(e=(e-t)/(i-t))*e*(3-2*e)}function uQe(e,t,i){return e<=t?0:e>=i?1:(e=(e-t)/(i-t))*e*e*(e*(6*e-15)+10)}function hQe(e,t){return e+Math.floor(Math.random()*(t-e+1))}function dQe(e,t){return e+Math.random()*(t-e)}function fQe(e){return e*(.5-Math.random())}function pQe(e){void 0!==e&&(noe=e);let t=noe+=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 mQe(e){return e*Sp}function gQe(e){return e*h0}function sN(e){return 0==(e&e-1)&&0!==e}function xce(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))}function gM(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}function vQe(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 yo(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 rr(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 gn={DEG2RAD:Sp,RAD2DEG:h0,generateUUID:xo,clamp:Vi,euclideanModulo:bB,mapLinear:sQe,inverseLerp:aQe,lerp:cx,damp:oQe,pingpong:lQe,smoothstep:cQe,smootherstep:uQe,randInt:hQe,randFloat:dQe,randFloatSpread:fQe,seededRandom:pQe,degToRad:mQe,radToDeg:gQe,isPowerOfTwo:sN,ceilPowerOfTwo:xce,floorPowerOfTwo:gM,setQuaternionFromProperEuler:vQe,normalize:rr,denormalize:yo},fe=class{constructor(e=0,t=0){fe.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(Vi(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}},pn=class{constructor(e,t,i,n,r,a,s,o,l){pn.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(Jk.makeScale(e,t)),this}rotate(e){return this.premultiply(Jk.makeRotation(-e)),this}translate(e,t){return this.premultiply(Jk.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)}},Jk=new pn;function bce(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}var yQe={Int8Array:Int8Array,Uint8Array:Uint8Array,Uint8ClampedArray:Uint8ClampedArray,Int16Array:Int16Array,Uint16Array:Uint16Array,Int32Array:Int32Array,Uint32Array:Uint32Array,Float32Array:Float32Array,Float64Array:Float64Array};function a0(e,t){return new yQe[e](t)}function yx(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}var roe={};function ux(e){e in roe||(roe[e]=!0,console.warn(e))}function c0(e){return e<.04045?.0773993808*e:Math.pow(.9478672986*e+.0521327014,2.4)}function Qk(e){return e<.0031308?12.92*e:1.055*Math.pow(e,.41666)-.055}var xQe=(new pn).fromArray([.8224621,.0331941,.0170827,.177538,.9668058,.0723974,-1e-7,1e-7,.9105199]),bQe=(new pn).fromArray([1.2249401,-.0420569,-.0196376,-.2249404,1.0420571,-.0786361,1e-7,0,1.0982735]);function EQe(e){return e.convertSRGBToLinear().applyMatrix3(bQe)}function _Qe(e){return e.applyMatrix3(xQe).convertLinearToSRGB()}var TQe={[ua]:e=>e,[zt]:e=>e.convertSRGBToLinear(),[xB]:EQe},wQe={[ua]:e=>e,[zt]:e=>e.convertLinearToSRGB(),[xB]:_Qe},Jo={enabled:!0,get legacyMode(){return console.warn("THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150."),!this.enabled},set legacyMode(e){console.warn("THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150."),this.enabled=!e},get workingColorSpace(){return ua},set workingColorSpace(e){console.warn("THREE.ColorManagement: .workingColorSpace is readonly.")},convert:function(e,t,i){if(!1===this.enabled||t===i||!t||!i)return e;let n=TQe[t],r=wQe[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)}},Bg,xx=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===Bg&&(Bg=yx("canvas")),Bg.width=e.width,Bg.height=e.height;let i=Bg.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),t=Bg}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=yx("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!==qM)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case li:e.x=e.x-Math.floor(e.x);break;case oi:e.x=e.x<0?0:1;break;case ah: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 li:e.y=e.y-Math.floor(e.y);break;case oi:e.y=e.y<0?0:1;break;case ah: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 ux("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace===zt?Vc:yB}set encoding(e){ux("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=e===Vc?zt:zc}};Rr.DEFAULT_IMAGE=null,Rr.DEFAULT_MAPPING=qM,Rr.DEFAULT_ANISOTROPY=1;var Zn=class{constructor(e=0,t=0,i=0,n=1){Zn.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}},Vn=class extends bo{constructor(e=1,t=1,i={}){super(),this.isWebGLRenderTarget=!0,this.width=e,this.height=t,this.depth=1,this.scissor=new Zn(0,0,e,t),this.scissorTest=!1,this.viewport=new Zn(0,0,e,t);let n={width:e,height:t,depth:1};void 0!==i.encoding&&(ux("THREE.WebGLRenderTarget: option.encoding has been replaced by option.colorSpace."),i.colorSpace=i.encoding===Vc?zt:zc),this.texture=new Rr(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:dr,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 Xl(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"})}},d0=class extends Rr{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=Or,this.minFilter=Or,this.wrapR=oi,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},aN=class extends Vn{constructor(e=1,t=1,i=1){super(e,t),this.isWebGLArrayRenderTarget=!0,this.depth=i,this.texture=new d0(null,e,t,i),this.texture.isRenderTargetTexture=!0}},bx=class extends Rr{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=Or,this.minFilter=Or,this.wrapR=oi,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},oN=class extends Vn{constructor(e=1,t=1,i=1){super(e,t),this.isWebGL3DRenderTarget=!0,this.depth=i,this.texture=new bx(null,e,t,i),this.texture.isRenderTargetTexture=!0}},lN=class extends Vn{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(Vi(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}},P=class{constructor(e=0,t=0,i=0){P.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(ioe.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(ioe.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 tF.copy(this).projectOnVector(e),this.sub(tF)}reflect(e){return this.sub(tF.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(Vi(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-ao(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}},tF=new P,ioe=new Xn,bt=class{constructor(e=new P(1/0,1/0,1/0),t=new P(-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,Zu),Zu.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(Zy),bS.subVectors(this.max,Zy),Ug.subVectors(e.a,Zy),Vg.subVectors(e.b,Zy),zg.subVectors(e.c,Zy),vd.subVectors(Vg,Ug),yd.subVectors(zg,Vg),up.subVectors(Ug,zg);let t=[0,-vd.z,vd.y,0,-yd.z,yd.y,0,-up.z,up.y,vd.z,0,-vd.x,yd.z,0,-yd.x,up.z,0,-up.x,-vd.y,vd.x,0,-yd.y,yd.x,0,-up.y,up.x,0];return!(!nF(t,Ug,Vg,zg,bS)||(t=[1,0,0,0,1,0,0,0,1],!nF(t,Ug,Vg,zg,bS)))&&(ES.crossVectors(vd,yd),t=[ES.x,ES.y,ES.z],nF(t,Ug,Vg,zg,bS))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Zu).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=.5*this.getSize(Zu).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()||(Ku[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Ku[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Ku[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Ku[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Ku[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Ku[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Ku[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Ku[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Ku)),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)}},Ku=[new P,new P,new P,new P,new P,new P,new P,new P],Zu=new P,Hg=new bt,Ug=new P,Vg=new P,zg=new P,vd=new P,yd=new P,up=new P,Zy=new P,bS=new P,ES=new P,hp=new P;function nF(e,t,i,n,r){for(let a=0,s=e.length-3;a<=s;a+=3){hp.fromArray(e,a);let s=r.x*Math.abs(hp.x)+r.y*Math.abs(hp.y)+r.z*Math.abs(hp.z),o=t.dot(hp),l=i.dot(hp),h=n.dot(hp);if(Math.max(-Math.max(o,l,h),Math.min(o,l,h))>s)return!1}return!0}var RQe=new bt,Jy=new P,rF=new P,Jn=class{constructor(e=new P,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):RQe.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;Jy.subVectors(e,this.center);let t=Jy.lengthSq();if(t>this.radius*this.radius){let e=Math.sqrt(t),i=.5*(e-this.radius);this.center.addScaledVector(Jy,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):(rF.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Jy.copy(e.center).add(rF)),this.expandByPoint(Jy.copy(e.center).sub(rF))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return(new this.constructor).copy(this)}},Ju=new P,iF=new P,_S=new P,xd=new P,sF=new P,TS=new P,aF=new P,ka=class{constructor(e=new P,t=new P(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,Ju)),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=Ju.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Ju.copy(this.origin).addScaledVector(this.direction,t),Ju.distanceToSquared(e))}distanceSqToSegment(e,t,i,n){iF.copy(e).add(t).multiplyScalar(.5),_S.copy(t).sub(e).normalize(),xd.copy(this.origin).sub(iF);let r,a,s,o,l=.5*e.distanceTo(t),h=-this.direction.dot(_S),c=xd.dot(this.direction),u=-xd.dot(_S),d=xd.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(iF).addScaledVector(_S,a),s}intersectSphere(e,t){Ju.subVectors(e.center,this.origin);let i=Ju.dot(this.direction),n=Ju.dot(Ju)-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,Ju)}intersectTriangle(e,t,i,n,r){sF.subVectors(t,e),TS.subVectors(i,e),aF.crossVectors(sF,TS);let a,s=this.direction.dot(aF);if(s>0){if(n)return null;a=1}else{if(!(s<0))return null;a=-1,s=-s}xd.subVectors(this.origin,e);let o=a*this.direction.dot(TS.crossVectors(xd,TS));if(o<0)return null;let l=a*this.direction.dot(sF.cross(xd));if(l<0||o+l>s)return null;let h=-a*xd.dot(aF);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)}},qe=class{constructor(e,t,i,n,r,a,s,o,l,h,c,u,d,p,f,m){qe.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 qe).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/Gg.setFromMatrixColumn(e,0).length(),r=1/Gg.setFromMatrixColumn(e,1).length(),a=1/Gg.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(AQe,e,CQe)}lookAt(e,t,i){let n=this.elements;return mo.subVectors(e,t),0===mo.lengthSq()&&(mo.z=1),mo.normalize(),bd.crossVectors(i,mo),0===bd.lengthSq()&&(1===Math.abs(i.z)?mo.x+=1e-4:mo.z+=1e-4,mo.normalize(),bd.crossVectors(i,mo)),bd.normalize(),wS.crossVectors(mo,bd),n[0]=bd.x,n[4]=wS.x,n[8]=mo.x,n[1]=bd.y,n[5]=wS.y,n[9]=mo.y,n[2]=bd.z,n[6]=wS.z,n[10]=mo.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],M=n[8],S=n[12],E=n[1],T=n[5],A=n[9],C=n[13],P=n[2],R=n[6],L=n[10],D=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*M+s*A+o*L+l*k,r[12]=a*S+s*C+o*D+l*N,r[1]=h*_+c*E+u*P+d*I,r[5]=h*w+c*T+u*R+d*O,r[9]=h*M+c*A+u*L+d*k,r[13]=h*S+c*C+u*D+d*N,r[2]=p*_+f*E+m*P+g*I,r[6]=p*w+f*T+m*R+g*O,r[10]=p*M+f*A+m*L+g*k,r[14]=p*S+f*C+m*D+g*N,r[3]=v*_+y*E+x*P+b*I,r[7]=v*w+y*T+x*R+b*O,r[11]=v*M+y*A+x*L+b*k,r[15]=v*S+y*C+x*D+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=Gg.set(n[0],n[1],n[2]).length(),a=Gg.set(n[4],n[5],n[6]).length(),s=Gg.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],Gl.copy(this);let o=1/r,l=1/a,h=1/s;return Gl.elements[0]*=o,Gl.elements[1]*=o,Gl.elements[2]*=o,Gl.elements[4]*=l,Gl.elements[5]*=l,Gl.elements[6]*=l,Gl.elements[8]*=h,Gl.elements[9]*=h,Gl.elements[10]*=h,t.setFromRotationMatrix(Gl),i.x=r,i.y=a,i.z=s,this}makePerspective(e,t,i,n,r,a,s=Bc){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===Bc)o=-(a+r)/(a-r),l=-2*a*r/(a-r);else{if(s!==vx)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=Bc){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===Bc)o=(a+r)*d,l=-2*d;else{if(s!==vx)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}},Gg=new P,Gl=new qe,AQe=new P(0,0,0),CQe=new P(1,1,1),bd=new P,wS=new P,mo=new P,soe=new qe,aoe=new Xn,Dn=class{constructor(e=0,t=0,i=0,n=Dn.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(Vi(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(-Vi(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(Vi(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(-Vi(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(Vi(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(-Vi(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 soe.makeRotationFromQuaternion(e),this.setFromRotationMatrix(soe,t,i)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return aoe.setFromEuler(this),this.setFromQuaternion(aoe,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}};Dn.DEFAULT_ORDER="XYZ";var Md=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(Qy,e,IQe),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Qy,DQe,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,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){ql.subVectors(n,t),eh.subVectors(i,t),oF.subVectors(e,t);let a=ql.dot(ql),s=ql.dot(eh),o=ql.dot(oF),l=eh.dot(eh),h=eh.dot(oF),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,th),th.x>=0&&th.y>=0&&th.x+th.y<=1}static getUV(e,t,i,n,r,a,s,o){return!1===MS&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),MS=!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,th),o.setScalar(0),o.addScaledVector(r,th.x),o.addScaledVector(a,th.y),o.addScaledVector(s,th.z),o}static isFrontFacing(e,t,i,n){return ql.subVectors(i,t),eh.subVectors(e,t),ql.cross(eh).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 ql.subVectors(this.c,this.b),eh.subVectors(this.a,this.b),.5*ql.cross(eh).length()}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Vr.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Vr.getBarycoord(e,this.a,this.b,this.c,t)}getUV(e,t,i,n,r){return!1===MS&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),MS=!0),Vr.getInterpolation(e,this.a,this.b,this.c,t,i,n,r)}getInterpolation(e,t,i,n,r){return Vr.getInterpolation(e,this.a,this.b,this.c,t,i,n,r)}containsPoint(e){return Vr.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Vr.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;jg.subVectors(a,r),Wg.subVectors(s,r),lF.subVectors(e,r);let o=jg.dot(lF),l=Wg.dot(lF);if(o<=0&&l<=0)return t.copy(r);cF.subVectors(e,a);let h=jg.dot(cF),c=Wg.dot(cF);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(jg,i);uF.subVectors(e,s);let d=jg.dot(uF),p=Wg.dot(uF);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(Wg,n);let m=h*p-d*c;if(m<=0&&c-h>=0&&d-p>=0)return doe.subVectors(s,a),n=(c-h)/(c-h+(d-p)),t.copy(a).addScaledVector(doe,n);let g=1/(m+f+u);return i=f*g,n=u*g,t.copy(r).addScaledVector(jg,i).addScaledVector(Wg,n)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},OQe=0,Qn=class extends bo{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:OQe++}),this.uuid=xo(),this.name="",this.type="Material",this.blending=wp,this.side=Xr,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=lB,this.blendDst=cB,this.blendEquation=vo,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=pM,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=uce,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=fM,this.stencilZFail=fM,this.stencilZPass=fM,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(void 0!==e)for(let t in e){let 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!==wp&&(i.blending=this.blending),this.side!==Xr&&(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++}},Ece={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},jl={h:0,s:0,l:0},RS={h:0,s:0,l:0};function hF(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 Ye=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=zt){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(255&e)/255,Jo.toWorkingColorSpace(this,t),this}setRGB(e,t,i,n=Jo.workingColorSpace){return this.r=e,this.g=t,this.b=i,Jo.toWorkingColorSpace(this,n),this}setHSL(e,t,i,n=Jo.workingColorSpace){if(e=bB(e,1),t=Vi(t,0,1),i=Vi(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=hF(r,n,e+1/3),this.g=hF(r,n,e),this.b=hF(r,n,e-1/3)}return Jo.toWorkingColorSpace(this,n),this}setStyle(e,t=zt){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=zt){let i=Ece[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=c0(e.r),this.g=c0(e.g),this.b=c0(e.b),this}copyLinearToSRGB(e){return this.r=Qk(e.r),this.g=Qk(e.g),this.b=Qk(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=zt){return Jo.fromWorkingColorSpace(Vs.copy(this),e),65536*Math.round(Vi(255*Vs.r,0,255))+256*Math.round(Vi(255*Vs.g,0,255))+Math.round(Vi(255*Vs.b,0,255))}getHexString(e=zt){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Jo.workingColorSpace){Jo.fromWorkingColorSpace(Vs.copy(this),t);let i,n,r=Vs.r,a=Vs.g,s=Vs.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 Oa(e){Math.abs(e)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),e=Vi(e,-65504,65504),rh.floatView[0]=e;let t=rh.uint32View[0],i=t>>23&511;return rh.baseTable[i]+((8388607&t)>>rh.shiftTable[i])}function ox(e){let t=e>>10;return rh.uint32View[0]=rh.mantissaTable[rh.offsetTable[t]+(1023&e)]+rh.exponentTable[t],rh.floatView[0]}var k0={toHalfFloat:Oa,fromHalfFloat:ox},ts=new P,AS=new fe,nn=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=gx,this.updateRange={offset:0,count:-1},this.gpuType=zs,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;eao(e.far-e.near,2)))&&(foe.copy(r).invert(),dp.copy(e.ray).applyMatrix4(foe),(null===i.boundingBox||!1!==dp.intersectsBox(i.boundingBox))&&this._computeIntersections(e,t,dp)))}_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:kS.clone(),object:e}}function FS(e,t,i,n,r,a,s,o,l,h){e.getVertexPosition(o,Yg),e.getVertexPosition(l,$g),e.getVertexPosition(h,Kg);let c=NQe(e,t,i,n,Yg,$g,Kg,OS);if(c){r&&(IS.fromBufferAttribute(r,o),DS.fromBufferAttribute(r,l),LS.fromBufferAttribute(r,h),c.uv=Vr.getInterpolation(OS,Yg,$g,Kg,IS,DS,LS,new fe)),a&&(IS.fromBufferAttribute(a,o),DS.fromBufferAttribute(a,l),LS.fromBufferAttribute(a,h),c.uv1=Vr.getInterpolation(OS,Yg,$g,Kg,IS,DS,LS,new fe),c.uv2=c.uv1),s&&(moe.fromBufferAttribute(s,o),goe.fromBufferAttribute(s,l),voe.fromBufferAttribute(s,h),c.normal=Vr.getInterpolation(OS,Yg,$g,Kg,moe,goe,voe,new P),c.normal.dot(n.direction)>0&&c.normal.multiplyScalar(-1));let e={a:o,b:l,c:h,normal:new P,materialIndex:0};Vr.getNormal(Yg,$g,Kg,e.normal),c.face=e}return c}var Gs=class extends Et{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,M=m+1,S=g+1,E=0,T=0,A=new P;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}},ch=class extends Xt{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new qe,this.projectionMatrix=new qe,this.projectionMatrixInverse=new qe,this.coordinateSystem=Bc}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)}},jn=class extends ch{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*h0*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(.5*Sp*this.fov);return.5*this.getFilmHeight()/e}getEffectiveFOV(){return 2*h0*Math.atan(Math.tan(.5*Sp*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*Sp*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}},Zg=-90,Jg=1,vM=class extends Xt{constructor(e,t,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null;let n=new jn(Zg,Jg,e,t);n.layers=this.layers,this.add(n);let r=new jn(Zg,Jg,e,t);r.layers=this.layers,this.add(r);let a=new jn(Zg,Jg,e,t);a.layers=this.layers,this.add(a);let s=new jn(Zg,Jg,e,t);s.layers=this.layers,this.add(s);let o=new jn(Zg,Jg,e,t);o.layers=this.layers,this.add(o);let l=new jn(Zg,Jg,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===Bc)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!==vx)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.toneMapping,u=e.xr.enabled;e.toneMapping=Hc,e.xr.enabled=!1;let d=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=d,e.setRenderTarget(i,5),e.render(t,l),e.setRenderTarget(h),e.toneMapping=c,e.xr.enabled=u,i.texture.needsPMREMUpdate=!0}},Ap=class extends Rr{constructor(e,t,i,n,r,a,s,o,l,h){super(e=void 0!==e?e:[],t=void 0!==t?t:Td,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}},yM=class extends Vn{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&&(ux("THREE.WebGLCubeRenderTarget: option.encoding has been replaced by option.colorSpace."),t.colorSpace=t.encoding===Vc?zt:zc),this.texture=new Ap(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:dr}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 Gs(5,5,5),s=new Yt({name:"CubemapFromEquirect",uniforms:f0(i),vertexShader:n,fragmentShader:r,side:Ci,blending:kr});s.uniforms.tEquirect.value=t;let o=new ht(a,s),l=t.minFilter;return t.minFilter===ca&&(t.minFilter=dr),new vM(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)}},pF=new P,VQe=new P,zQe=new pn,Mr=class{constructor(e=new P(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=pF.subVectors(i,t).cross(VQe.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(pF),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||zQe.getNormalMatrix(e),n=this.coplanarPoint(pF).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)}},fp=new Jn,NS=new P,qs=class{constructor(e=new Mr,t=new Mr,i=new Mr,n=new Mr,r=new Mr,a=new Mr){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=Bc){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===Bc)i[5].setComponents(o+s,u+c,m+f,x+y).normalize();else{if(t!==vx)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(),fp.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{let t=e.geometry;null===t.boundingSphere&&t.computeBoundingSphere(),fp.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(fp)}intersectsSprite(e){return fp.center.set(0,0,0),fp.radius=.7071067811865476,fp.applyMatrix4(e.matrixWorld),this.intersectsSphere(fp)}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,NS.y=n.normal.y>0?e.max.y:e.min.y,NS.z=n.normal.z>0?e.max.z:e.min.z,n.distanceToPoint(NS)<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 Tce(){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 GQe(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===I0)?(void 0===l&&(l=new ht(new Gs(1,1,1),new Yt({name:"BackgroundCubeMaterial",uniforms:f0(Wl.backgroundCube.uniforms),vertexShader:Wl.backgroundCube.vertexShader,fragmentShader:Wl.backgroundCube.fragmentShader,side:Ci,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!==zt,(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 ht(new zr(2,2),new Yt({name:"BackgroundMaterial",uniforms:f0(Wl.background.uniforms),vertexShader:Wl.background.vertexShader,fragmentShader:Wl.background.fragmentShader,side:Xr,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!==zt,!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 wnt(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===uB);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 Rnt(e){let t=this,i=null,n=0,r=!1,a=!1,s=new Mr,o=new pn,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 Ant(e){let t=new WeakMap;function i(e,t){return t===Mp?e.mapping=Td:t===px&&(e.mapping=wd),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===Mp||a===px){if(t.has(r))return i(t.get(r).texture,r.mapping);{let a=r.image;if(a&&a.height>0){let s=new yM(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 Er=class extends ch{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}},o0=4,yoe=[.125,.215,.35,.446,.526,.582],bp=20,mF=new Er,xoe=new Ye,gF=null,xp=(1+Math.sqrt(5))/2,Qg=1/xp,boe=[new P(1,1,1),new P(-1,1,1),new P(1,1,-1),new P(-1,1,-1),new P(0,xp,Qg),new P(0,xp,-Qg),new P(Qg,0,xp),new P(-Qg,0,xp),new P(xp,Qg,0),new P(-xp,Qg,0)],uh=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){gF=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=Toe(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=_oe(),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===Td||e.mapping===wd;n?(null===this._cubemapMaterial&&(this._cubemapMaterial=Toe()),this._cubemapMaterial.uniforms.flipEnvMap.value=!1===e.isRenderTargetTexture?-1:1):null===this._equirectMaterial&&(this._equirectMaterial=_oe());let r=n?this._cubemapMaterial:this._equirectMaterial,a=new ht(this._lodPlanes[0],r);r.uniforms.envMap.value=e;let s=this._cubeSize;HS(t,0,0,3*s,2*s),i.setRenderTarget(t),i.render(a,mF)}_applyPMREM(e){let t=this._renderer,i=t.autoClear;t.autoClear=!1;for(let n=1;nbp&&console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${f} samples when the maximum is set to ${bp}`);let m=[],g=0;for(let x=0;xv-o0?n-v+o0:0),4*(this._cubeSize-y),3*y,2*y),o.setRenderTarget(t),o.render(h,mF)}};function Cnt(e){let t=[],i=[],n=[],r=e,a=e-o0+1+yoe.length;for(let s=0;se-o0?o=yoe[s-e+o0-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 Et;b.setAttribute("position",new nn(v,f)),b.setAttribute("uv",new nn(y,m)),b.setAttribute("faceIndex",new nn(x,g)),t.push(b),r>o0&&r--}return{lodPlanes:t,sizeLods:i,sigmas:n}}function Eoe(e,t,i){let n=new Vn(e,t,i);return n.texture.mapping=I0,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function HS(e,t,i,n,r){e.viewport.set(t,i,n,r),e.scissor.set(t,i,n,r)}function Pnt(e,t,i){let n=new Float32Array(bp),r=new P(0,1,0);return new Yt({name:"SphericalGaussianBlur",defines:{n:bp,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:EB(),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:kr,depthTest:!1,depthWrite:!1})}function _oe(){return new Yt({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:EB(),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:kr,depthTest:!1,depthWrite:!1})}function Toe(){return new Yt({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:EB(),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:kr,depthTest:!1,depthWrite:!1})}function EB(){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 Int(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===Mp||a===px,o=a===Td||a===wd;if(s||o){if(r.isRenderTargetTexture&&!0===r.needsPMREMUpdate){r.needsPMREMUpdate=!1;let n=t.get(r);return null===i&&(i=new uh(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 uh(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 Dnt(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 Lnt(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 d0(g,f,m,r);v.type=zs,v.needsUpdate=!0;let y=4*p;for(let t=0;t0)return e;let r=t*i,a=woe[r];if(void 0===a&&(a=new Float32Array(r),woe[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 hs(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 Crt(e){switch(e){case ua:return["Linear","( value )"];case zt:return["sRGB","( value )"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",e),["Linear","( value )"]}}function Ioe(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"+Art(e.getShaderSource(t),n)}return r}function Prt(e,t){let i=Crt(t);return"vec4 "+e+"( vec4 value ) { return LinearTo"+i[0]+i[1]+"; }"}function Irt(e,t){let i;switch(t){case Xle:i="Linear";break;case Yle:i="Reinhard";break;case $le:i="OptimizedCineon";break;case Kle:i="ACESFilmic";break;case Zle:i="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",t),i="Linear"}return"vec3 "+e+"( vec3 color ) { return "+i+"ToneMapping( color ); }"}function Drt(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(lx).join("\n")}function Lrt(e){let t=[];for(let i in e){let n=e[i];!1!==n&&t.push("#define "+i+" "+n)}return t.join("\n")}function Ort(e,t){let i={},n=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let r=0;r/gm;function xN(e){return e.replace(krt,Nrt)}var Frt=new Map([["encodings_fragment","colorspace_fragment"],["encodings_pars_fragment","colorspace_pars_fragment"],["output_fragment","opaque_fragment"]]);function Nrt(e,t){let i=Kn[t];if(void 0===i){let e=Frt.get(t);if(void 0===e)throw new Error("Can not resolve #include <"+t+">");i=Kn[e],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,e)}return xN(i)}var Brt=/#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 Ooe(e){return e.replace(Brt,Hrt)}function Hrt(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(lx).join("\n"),a.length>0&&(a+="\n")):(r=[koe(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(lx).join("\n"),a=[m,koe(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!==Hc?"#define TONE_MAPPING":"",i.toneMapping!==Hc?Kn.tonemapping_pars_fragment:"",i.toneMapping!==Hc?Irt("toneMapping",i.toneMapping):"",i.dithering?"#define DITHERING":"",i.opaque?"#define OPAQUE":"",Kn.colorspace_pars_fragment,Prt("linearToOutputTexel",i.outputColorSpace),i.useDepthPacking?"#define DEPTH_PACKING "+i.depthPacking:"","\n"].filter(lx).join("\n")),l=xN(l),l=Doe(l,i),l=Loe(l,i),h=xN(h),h=Doe(h,i),h=Loe(h,i),l=Ooe(l),h=Ooe(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===iN?"":"layout(location = 0) out highp vec4 pc_fragColor;",i.glslVersion===iN?"":"#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,M=Poe(s,s.VERTEX_SHADER,_),S=Poe(s,s.FRAGMENT_SHADER,w);if(s.attachShader(v,M),s.attachShader(v,S),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(M).trim(),n=s.getShaderInfoLog(S).trim(),o=!0,l=!0;if(!1===s.getProgramParameter(v,s.LINK_STATUS))if(o=!1,"function"==typeof e.debug.onShaderError)e.debug.onShaderError(s,v,M,S);else{let e=Ioe(s,M,"vertex"),i=Ioe(s,S,"fragment");console.error("THREE.WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(v,s.VALIDATE_STATUS)+"\n\nProgram Info Log: "+t+"\n"+e+"\n"+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(M),s.deleteShader(S),this.getUniforms=function(){return void 0===x&&(x=new u0(s,v)),x},this.getAttributes=function(){return void 0===b&&(b=Ort(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=Rrt++,this.cacheKey=t,this.usedTimes=1,this.program=v,this.vertexShader=M,this.fragmentShader=S,this}var Wrt=0,bN=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 EN(e),t.set(e,i)),i}},EN=class{constructor(e){this.id=Wrt++,this.code=e,this.usedTimes=0}};function Xrt(e,t,i,n,r,a,s){let o=new Md,l=new bN,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===I0?_.image.height:null,M=f[a.type];null!==a.precision&&(p=r.getMaxPrecision(a.precision),p!==a.precision&&console.warn("THREE.WebGLProgram.getParameters:",a.precision,"not supported, using",p,"instead."));let S,E,T,A,C=x.morphAttributes.position||x.morphAttributes.normal||x.morphAttributes.color,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),M){let e=Wl[M];S=e.vertexShader,E=e.fragmentShader}else S=a.vertexShader,E=a.fragmentShader,l.update(a),T=l.getVertexShaderID(a),A=l.getFragmentShaderID(a);let L=e.getRenderTarget(),D=!0===v.isInstancedMesh,I=!!a.map,O=!!a.matcap,k=!!_,N=!!a.aoMap,F=!!a.lightMap,U=!!a.bumpMap,B=!!a.normalMap,z=!!a.displacementMap,H=!!a.emissiveMap,V=!!a.metalnessMap,W=!!a.roughnessMap,j=a.anisotropy>0,G=a.clearcoat>0,X=a.iridescence>0,q=a.sheen>0,Y=a.transmission>0,J=j&&!!a.anisotropyMap,Z=G&&!!a.clearcoatMap,K=G&&!!a.clearcoatNormalMap,$=G&&!!a.clearcoatRoughnessMap,Q=X&&!!a.iridescenceMap,ee=X&&!!a.iridescenceThicknessMap,te=q&&!!a.sheenColorMap,ie=q&&!!a.sheenRoughnessMap,ne=!!a.specularMap,re=!!a.specularColorMap,ae=!!a.specularIntensityMap,se=Y&&!!a.transmissionMap,oe=Y&&!!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;return{isWebGL2:c,shaderID:M,shaderType:a.type,shaderName:a.name,vertexShader:S,fragmentShader:E,defines:a.defines,customVertexShaderID:T,customFragmentShaderID:A,isRawShaderMaterial:!0===a.isRawShaderMaterial,glslVersion:a.glslVersion,precision:p,instancing:D,instancingColor:D&&null!==v.instanceColor,supportsVertexTextures:d,outputColorSpace:null===L?e.outputColorSpace:!0===L.isXRRenderTarget?L.texture.colorSpace:ua,map:I,matcap:O,envMap:k,envMapMode:k&&_.mapping,envMapCubeUVHeight:w,aoMap:N,lightMap:F,bumpMap:U,normalMap:B,displacementMap:d&&z,emissiveMap:H,normalMapObjectSpace:B&&a.normalMapType===cce,normalMapTangentSpace:B&&a.normalMapType===Od,metalnessMap:V,roughnessMap:W,anisotropy:j,anisotropyMap:J,clearcoat:G,clearcoatMap:Z,clearcoatNormalMap:K,clearcoatRoughnessMap:$,iridescence:X,iridescenceMap:Q,iridescenceThicknessMap:ee,sheen:q,sheenColorMap:te,sheenRoughnessMap:ie,specularMap:ne,specularColorMap:re,specularIntensityMap:ae,transmission:Y,transmissionMap:se,thicknessMap:oe,gradientMap:le,opaque:!1===a.transparent&&a.blending===wp,alphaMap:he,alphaTest:ce,alphaHash:ue,combine:a.combine,mapUv:I&&m(a.map.channel),aoMapUv:N&&m(a.aoMap.channel),lightMapUv:F&&m(a.lightMap.channel),bumpMapUv:U&&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:W&&m(a.roughnessMap.channel),anisotropyMapUv:J&&m(a.anisotropyMap.channel),clearcoatMapUv:Z&&m(a.clearcoatMap.channel),clearcoatNormalMapUv:K&&m(a.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:$&&m(a.clearcoatRoughnessMap.channel),iridescenceMapUv:Q&&m(a.iridescenceMap.channel),iridescenceThicknessMapUv:ee&&m(a.iridescenceThicknessMap.channel),sheenColorMapUv:te&&m(a.sheenColorMap.channel),sheenRoughnessMapUv: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||j),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:a.toneMapped?e.toneMapping:Hc,useLegacyLights:e.useLegacyLights,premultipliedAlpha:a.premultipliedAlpha,doubleSided:a.side===or,flipSided:a.side===Ci,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=Wl[i];t=ni.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||$rt),n.length>1&&n.sort(t||Foe),r.length>1&&r.sort(t||Foe)}}}function Krt(){let e=new WeakMap;return{get:function(t,i){let n,r=e.get(t);return void 0===r?(n=new Noe,e.set(t,[n])):i>=r.length?(n=new Noe,r.push(n)):n=r[i],n},dispose:function(){e=new WeakMap}}}function Zrt(){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 P,color:new Ye};break;case"SpotLight":i={position:new P,direction:new P,color:new Ye,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":i={position:new P,color:new Ye,distance:0,decay:0};break;case"HemisphereLight":i={direction:new P,skyColor:new Ye,groundColor:new Ye};break;case"RectAreaLight":i={color:new Ye,position:new P,halfWidth:new P,halfHeight:new P}}return e[t.id]=i,i}}}function Jrt(){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 fe};break;case"PointLight":i={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new fe,shadowCameraNear:1,shadowCameraFar:1e3}}return e[t.id]=i,i}}}var Qrt=0;function eit(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+(t.map?1:0)-(e.map?1:0)}function tit(e,t){let i=new Zrt,n=Jrt(),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 P);let a=new P,s=new qe,o=new qe;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(eit);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=Ht.LTC_FLOAT_1,r.rectAreaLTC2=Ht.LTC_FLOAT_2):!0===e.has("OES_texture_half_float_linear")?(r.rectAreaLTC1=Ht.LTC_HALF_1,r.rectAreaLTC2=Ht.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=Qrt++)},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 Boe(e,t),s.push(a)):a=s[r],a},dispose:function(){i=new WeakMap}}}var Kl=class extends Qn{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=lce,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}},_x=class extends Qn{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}},rit="void main() {\n\tgl_Position = vec4( position, 1.0 );\n}",iit="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 sit(e,t,i){let n=new qs,r=new fe,a=new fe,s=new Zn,o=new Kl({depthPacking:O0}),l=new _x,h={},c=i.maxTextureSize,u={[Xr]:Ci,[Ci]:Xr,[or]:or},d=new Yt({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new fe},radius:{value:4}},vertexShader:rit,fragmentShader:iit}),p=d.clone();p.defines.HORIZONTAL_PASS=1;let f=new Et;f.setAttribute("position",new nn(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let m=new ht(f,d),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=oB;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 Vn(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===Nc?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===Nc)&&(!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!==Nc?{minFilter:Or,magFilter:Or}:{};null!==h.map&&h.map.dispose(),h.map=new Vn(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!==L.indexOf("OpenGL ES")&&(R=parseFloat(/^OpenGL ES (\d)/.exec(L)[1]),P=R>=2);let D=null,I={},O=e.getParameter(e.SCISSOR_BOX),k=e.getParameter(e.VIEWPORT),N=(new Zn).fromArray(O),F=(new Zn).fromArray(k);function U(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?gM: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 sN(e.width)&&sN(e.height)}function _(e,t){return e.generateMipmaps&&t&&e.minFilter!==Or&&e.minFilter!==dr}function w(t){e.generateMipmap(t)}function M(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.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===zt&&!1===s?e.SRGB8_ALPHA8:e.RGBA8),r===e.UNSIGNED_SHORT_4_4_4_4&&(o=e.RGBA4),r===e.UNSIGNED_SHORT_5_5_5_1&&(o=e.RGB5_A1)),(o===e.R16F||o===e.R32F||o===e.RG16F||o===e.RG32F||o===e.RGBA16F||o===e.RGBA32F)&&t.get("EXT_color_buffer_float"),o}function S(e,t,i){return!0===_(e,i)||e.isFramebufferTexture&&e.minFilter!==Or&&e.minFilter!==dr?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===Or||t===Sd||t===sh?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++)e.deleteFramebuffer(r.__webglFramebuffer[n]),r.__webglDepthbuffer&&e.deleteRenderbuffer(r.__webglDepthbuffer[n]);else{if(e.deleteFramebuffer(r.__webglFramebuffer),r.__webglDepthbuffer&&e.deleteRenderbuffer(r.__webglDepthbuffer),r.__webglMultisampledFramebuffer&&e.deleteFramebuffer(r.__webglMultisampledFramebuffer),r.__webglColorRenderbuffer)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 L={[li]:e.REPEAT,[oi]:e.CLAMP_TO_EDGE,[ah]:e.MIRRORED_REPEAT},D={[Or]:e.NEAREST,[Sd]:e.NEAREST_MIPMAP_NEAREST,[sh]:e.NEAREST_MIPMAP_LINEAR,[dr]:e.LINEAR,[Hp]:e.LINEAR_MIPMAP_NEAREST,[ca]:e.LINEAR_MIPMAP_LINEAR},I={[hce]:e.NEVER,[yce]:e.ALWAYS,[dce]:e.LESS,[pce]:e.LEQUAL,[fce]:e.EQUAL,[vce]:e.GEQUAL,[mce]:e.GREATER,[gce]:e.NOTEQUAL};function O(i,a,s){if(s?(e.texParameteri(i,e.TEXTURE_WRAP_S,L[a.wrapS]),e.texParameteri(i,e.TEXTURE_WRAP_T,L[a.wrapT]),(i===e.TEXTURE_3D||i===e.TEXTURE_2D_ARRAY)&&e.texParameteri(i,e.TEXTURE_WRAP_R,L[a.wrapR]),e.texParameteri(i,e.TEXTURE_MAG_FILTER,D[a.magFilter]),e.texParameteri(i,e.TEXTURE_MIN_FILTER,D[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!==oi||a.wrapT!==oi)&&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!==Or&&a.minFilter!==dr&&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===Or||a.minFilter!==sh&&a.minFilter!==ca||a.type===zs&&!1===t.has("OES_texture_float_linear")||!1===l&&a.type===cr&&!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!==oi||e.wrapT!==oi||e.minFilter!==Or&&e.minFilter!==dr)}(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=M(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=S(r,n,p);if(r.isDepthTexture)g=e.DEPTH_COMPONENT,l?g=r.type===zs?e.DEPTH_COMPONENT32F:r.type===ih?e.DEPTH_COMPONENT24:r.type===Uc?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT16:r.type===zs&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),r.format===_d&&g===e.DEPTH_COMPONENT&&r.type!==D0&&r.type!==ih&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),r.type=ih,m=a.convert(r.type)),r.format===oh&&g===e.DEPTH_COMPONENT&&(g=e.DEPTH_STENCIL,r.type!==Uc&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),r.type=Uc,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=e.TEXTURE_CUBE_MAP_POSITIVE_X&&l<=e.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&e.framebufferTexture2D(e.FRAMEBUFFER,o,l,n.get(s).__webglTexture,0),i.bindFramebuffer(e.FRAMEBUFFER,null)}function U(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===zs?r=e.DEPTH_COMPONENT32F:t.type===ih&&(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===mM||n!==ua&&n!==zc&&(n===zt?!1===l?!0===t.has("EXT_sRGB")&&r===As?(e.format=mM,e.minFilter=dr,e.generateMipmaps=!1):i=xx.sRGBToLinear(i):(r!==As||a!==Yl)&&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=M(r.internalFormat,g,v,r.colorSpace),E=l&&!0!==r.isVideoTexture,T=void 0===u.__version||!0===o,A=S(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&&!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&&!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(lit)))}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 Ln;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}},Rd=class extends Rr{constructor(e,t,i,n,r,a,s,o,l,h){if((h=void 0!==h?h:_d)!==_d&&h!==oh)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===i&&h===_d&&(i=ih),void 0===i&&h===oh&&(i=Uc),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:Or,this.minFilter=void 0!==o?o:Or,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}},_N=class extends bo{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 jn;x.layers.enable(1),x.viewport=new Zn;let b=new jn;b.layers.enable(2),b.viewport=new Zn;let _=[x,b],w=new xM;w.layers.enable(1),w.layers.enable(2);let M=null,S=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 hx,v[e]=t),t.getTargetRaySpace()},this.getControllerGrip=function(e){let t=v[e];return void 0===t&&(t=new hx,v[e]=t),t.getGripSpace()},this.getHand=function(e){let t=v[e];return void 0===t&&(t=new hx,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 nt(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 Vn(d.framebufferWidth,d.framebufferHeight,{format:As,type:Yl,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?oh:_d,a=f.stencil?Uc:ih);let o={colorFormat:t.RGBA8,depthFormat:s,scaleFactor:r};c=new XRWebGLBinding(n,t),u=c.createProjectionLayer(o),n.updateRenderState({layers:[u]}),g=new Vn(u.textureWidth,u.textureHeight,{format:As,type:Yl,depthTexture:new Rd(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 P,R=new P;function L(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,(M!==w.near||S!==w.far)&&(n.updateRenderState({depthNear:w.near,depthFar:w.far}),M=w.near,S=w.far);let t=e.parent,i=w.cameras;L(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,_ce(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===Ci&&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 uit(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=n.toneMapped?y.toneMapping:Hc,g=i.morphAttributes.position||i.morphAttributes.normal||i.morphAttributes.color,v=void 0!==g?g.length:0,x=$.get(n),b=m.state.lights;if(!0===z&&(!0===H||e!==S)){let t=e===S&&n.id===M;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||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===J.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(Z.useProgram(E.program)&&(T=!0,A=!0,C=!0),n.id!==M&&(M=n.id,A=!0),T||S!==e){if(P.setValue(xe,"projectionMatrix",e.projectionMatrix),J.logarithmicDepthBuffer&&P.setValue(xe,"logDepthBufFC",2/(Math.log(e.far+1)/Math.LN2)),S!==e&&(S=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(xe,G.setFromMatrixPosition(e.matrixWorld))}(n.isMeshPhongMaterial||n.isMeshToonMaterial||n.isMeshLambertMaterial||n.isMeshBasicMaterial||n.isMeshStandardMaterial||n.isShaderMaterial)&&P.setValue(xe,"isOrthographic",!0===e.isOrthographicCamera),(n.isMeshPhongMaterial||n.isMeshToonMaterial||n.isMeshLambertMaterial||n.isMeshBasicMaterial||n.isMeshStandardMaterial||n.isShaderMaterial||n.isShadowMaterial||r.isSkinnedMesh)&&P.setValue(xe,"viewMatrix",e.matrixWorldInverse)}if(r.isSkinnedMesh){P.setOptional(xe,r,"bindMatrix"),P.setOptional(xe,r,"bindMatrixInverse");let e=r.skeleton;e&&(J.floatVertexTextures?(null===e.boneTexture&&e.computeBoneTexture(),P.setValue(xe,"boneTexture",e.boneTexture,Q),P.setValue(xe,"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 L=i.morphAttributes;if((void 0!==L.position||void 0!==L.normal||void 0!==L.color&&!0===J.isWebGL2)&&de.update(r,i,E),(A||x.receiveShadow!==r.receiveShadow)&&(x.receiveShadow=r.receiveShadow,P.setValue(xe,"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(xe,"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,D,V),u0.upload(xe,x.uniformsList,R,Q)),n.isShaderMaterial&&!0===n.uniformsNeedUpdate&&(u0.upload(xe,x.uniformsList,R,Q),n.uniformsNeedUpdate=!1),n.isSpriteMaterial&&P.setValue(xe,"center",r.center),P.setValue(xe,"modelViewMatrix",r.modelViewMatrix),P.setValue(xe,"normalMatrix",r.normalMatrix),P.setValue(xe,"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=J.isWebGL2;null===V&&(V=new Vn(1,1,{generateMipmaps:!0,type:Y.has("EXT_color_buffer_half_float")?cr:Yl,minFilter:ca,samples:r?4:0})),y.getDrawingBufferSize(j),r?V.setSize(j.x,j.y):V.setSize(gM(j.x),gM(j.y));let a=y.getRenderTarget();y.setRenderTarget(V),y.getClearColor(C),R=y.getClearAlpha(),R<1&&y.setClearColor(16777215,.5),y.clear();let s=y.toneMapping;y.toneMapping=Hc,Ie(e,i,n),Q.updateMultisampleRenderTarget(V),Q.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),Z.buffers.depth.setTest(!0),Z.buffers.depth.setMask(!0),Z.buffers.color.setMask(!0),Z.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){$.get(e.texture).__webglTexture=t,$.get(e.depthTexture).__webglTexture=i;let n=$.get(e);n.__hasExternalTextures=!0,n.__hasExternalTextures&&(n.__autoAllocateDepthBuffer=void 0===i,n.__autoAllocateDepthBuffer||!0===Y.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=$.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 i=$.get(e);void 0!==i.__useDefaultFramebuffer?(Z.bindFramebuffer(xe.FRAMEBUFFER,null),n=!1):void 0===i.__webglFramebuffer?Q.setupRenderTarget(e):i.__hasExternalTextures&&Q.rebindTextures(e,$.get(e.texture).__webglTexture,$.get(e.depthTexture).__webglTexture);let o=e.texture;(o.isData3DTexture||o.isDataArrayTexture||o.isCompressedArrayTexture)&&(s=!0);let l=$.get(e).__webglFramebuffer;e.isWebGLCubeRenderTarget?(r=l[t],a=!0):r=J.isWebGL2&&e.samples>0&&!1===Q.useMultisampledRTT(e)?$.get(e).__webglMultisampledFramebuffer:l,E.copy(e.viewport),T.copy(e.scissor),A=e.scissorTest}else E.copy(N).multiplyScalar(I).floor(),T.copy(F).multiplyScalar(I).floor(),A=U;if(Z.bindFramebuffer(xe.FRAMEBUFFER,r)&&J.drawBuffers&&n&&Z.drawBuffers(e,r),Z.viewport(E),Z.scissor(T),Z.setScissorTest(A),a){let n=$.get(e.texture);xe.framebufferTexture2D(xe.FRAMEBUFFER,xe.COLOR_ATTACHMENT0,xe.TEXTURE_CUBE_MAP_POSITIVE_X+t,n.__webglTexture,i)}else if(s){let n=$.get(e.texture),r=t||0;xe.framebufferTextureLayer(xe.FRAMEBUFFER,xe.COLOR_ATTACHMENT0,n.__webglTexture,i||0,r)}M=-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=$.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&void 0!==s&&(o=o[s]),o){Z.bindFramebuffer(xe.FRAMEBUFFER,o);try{let s=e.texture,o=s.format,l=s.type;if(o!==As&&ge.convert(o)!==xe.getParameter(xe.IMPLEMENTATION_COLOR_READ_FORMAT))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");let h=l===cr&&(Y.has("EXT_color_buffer_half_float")||J.isWebGL2&&Y.has("EXT_color_buffer_float"));if(!(l===Yl||ge.convert(l)===xe.getParameter(xe.IMPLEMENTATION_COLOR_READ_TYPE)||l===zs&&(J.isWebGL2||Y.has("OES_texture_float")||Y.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&&xe.readPixels(t,i,n,r,ge.convert(o),ge.convert(l),a)}finally{let e=null!==w?$.get(w).__webglFramebuffer:null;Z.bindFramebuffer(xe.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);Q.setTexture2D(t,0),xe.copyTexSubImage2D(xe.TEXTURE_2D,i,0,0,e.x,e.y,r,a),Z.unbindTexture()},this.copyTextureToTexture=function(e,t,i,n=0){let r=t.image.width,a=t.image.height,s=ge.convert(i.format),o=ge.convert(i.type);Q.setTexture2D(i,0),xe.pixelStorei(xe.UNPACK_FLIP_Y_WEBGL,i.flipY),xe.pixelStorei(xe.UNPACK_PREMULTIPLY_ALPHA_WEBGL,i.premultiplyAlpha),xe.pixelStorei(xe.UNPACK_ALIGNMENT,i.unpackAlignment),t.isDataTexture?xe.texSubImage2D(xe.TEXTURE_2D,n,e.x,e.y,r,a,s,o,t.image.data):t.isCompressedTexture?xe.compressedTexSubImage2D(xe.TEXTURE_2D,n,e.x,e.y,t.mipmaps[0].width,t.mipmaps[0].height,s,t.mipmaps[0].data):xe.texSubImage2D(xe.TEXTURE_2D,n,e.x,e.y,s,o,t.image),0===n&&i.generateMipmaps&&xe.generateMipmap(xe.TEXTURE_2D),Z.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=ge.convert(n.format),c=ge.convert(n.type);if(n.isData3DTexture)Q.setTexture3D(n,0),a=xe.TEXTURE_3D;else{if(!n.isDataArrayTexture)return void console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");Q.setTexture2DArray(n,0),a=xe.TEXTURE_2D_ARRAY}xe.pixelStorei(xe.UNPACK_FLIP_Y_WEBGL,n.flipY),xe.pixelStorei(xe.UNPACK_PREMULTIPLY_ALPHA_WEBGL,n.premultiplyAlpha),xe.pixelStorei(xe.UNPACK_ALIGNMENT,n.unpackAlignment);let u=xe.getParameter(xe.UNPACK_ROW_LENGTH),d=xe.getParameter(xe.UNPACK_IMAGE_HEIGHT),p=xe.getParameter(xe.UNPACK_SKIP_PIXELS),f=xe.getParameter(xe.UNPACK_SKIP_ROWS),m=xe.getParameter(xe.UNPACK_SKIP_IMAGES),g=i.isCompressedTexture?i.mipmaps[0]:i.image;xe.pixelStorei(xe.UNPACK_ROW_LENGTH,g.width),xe.pixelStorei(xe.UNPACK_IMAGE_HEIGHT,g.height),xe.pixelStorei(xe.UNPACK_SKIP_PIXELS,e.min.x),xe.pixelStorei(xe.UNPACK_SKIP_ROWS,e.min.y),xe.pixelStorei(xe.UNPACK_SKIP_IMAGES,e.min.z),i.isDataTexture||i.isData3DTexture?xe.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."),xe.compressedTexSubImage3D(a,r,t.x,t.y,t.z,s,o,l,h,g.data)):xe.texSubImage3D(a,r,t.x,t.y,t.z,s,o,l,h,c,g),xe.pixelStorei(xe.UNPACK_ROW_LENGTH,u),xe.pixelStorei(xe.UNPACK_IMAGE_HEIGHT,d),xe.pixelStorei(xe.UNPACK_SKIP_PIXELS,p),xe.pixelStorei(xe.UNPACK_SKIP_ROWS,f),xe.pixelStorei(xe.UNPACK_SKIP_IMAGES,m),0===r&&n.generateMipmaps&&xe.generateMipmap(a),Z.unbindTexture()},this.initTexture=function(e){e.isCubeTexture?Q.setTextureCube(e,0):e.isData3DTexture?Q.setTexture3D(e,0):e.isDataArrayTexture||e.isCompressedArrayTexture?Q.setTexture2DArray(e,0):Q.setTexture2D(e,0),Z.unbindTexture()},this.resetState=function(){b=0,_=0,w=null,Z.reset(),ve.reset()},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Bc}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===zt?Vc:yB}set outputEncoding(e){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=e===Vc?zt:ua}},bM=class extends ns{};bM.prototype.isWebGL1Renderer=!0;var p0=class{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new Ye(e),this.density=t}clone(){return new p0(this.color,this.density)}toJSON(){return{type:"FogExp2",color:this.color.getHex(),density:this.density}}},qc=class{constructor(e,t=1,i=1e3){this.isFog=!0,this.name="",this.color=new Ye(e),this.near=t,this.far=i}clone(){return new qc(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}},ti=class extends Xt{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}},hh=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=void 0!==e?e.length/t:0,this.usage=gx,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=xo()}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:tx.clone(),uv:Vr.getInterpolation(tx,US,rx,VS,Hoe,yF,Uoe,new fe),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 zS(e,t,i,n,r,a){r0.subVectors(e,i).addScalar(.5).multiply(n),void 0!==r?(nx.x=a*r0.x-r*r0.y,nx.y=r*r0.x+a*r0.y):nx.copy(r0),e.copy(t),e.x+=nx.x,e.y+=nx.y,e.applyMatrix4(Cce)}var GS=new P,Voe=new P,_M=class extends Xt{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){GS.setFromMatrixPosition(this.matrixWorld);let i=e.ray.origin.distanceTo(GS);this.getObjectForDistance(i).raycast(e,t)}}update(e){let t=this.levels;if(t.length>1){GS.setFromMatrixPosition(e.matrixWorld),Voe.setFromMatrixPosition(this.matrixWorld);let i,n,r=GS.distanceTo(Voe)/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 wN=class extends Rr{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:dr,this.magFilter=void 0!==r?r:dr,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)}},SN=class extends Rr{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=Or,this.minFilter=Or,this.generateMipmaps=!1,this.needsUpdate=!0}},fh=class extends Rr{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}},MN=class extends fh{constructor(e,t,i,n,r,a){super(e,t,i,r,a),this.isCompressedArrayTexture=!0,this.image.depth=n,this.wrapR=oi}},wx=class extends Rr{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}},ha=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 fe:new P);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 P,n=[],r=[],a=[],s=new P,o=new qe;for(let d=0;d<=e;d++){let t=d/e;n[d]=this.getTangentAt(t,new P)}r[0]=new P,a[0]=new P;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(Vi(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(Vi(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}},ph=class extends ha{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 fe,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]:(YS.subVectors(a[0],a[1]).add(a[0]),i=YS);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(rle(s,o.x,l.x,h.x,c.x),rle(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}},Ip=class extends Et{constructor(e=[new fe(0,-.5),new fe(.5,0),new fe(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=Vi(n,0,2*Math.PI);let r=[],a=[],s=[],o=[],l=[],h=1/t,c=new P,u=new fe,d=new P,p=new P,f=new P,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 Rt(c,3)),this.setAttribute("normal",new Rt(u,3)),this.setAttribute("uv",new Rt(d,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Zl(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},x0=class extends Zl{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 x0(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},Xc=class extends Et{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 Rt(r,3)),this.setAttribute("normal",new Rt(r.slice(),3)),this.setAttribute("uv",new Rt(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 Xc(e.vertices,e.indices,e.radius,e.details)}},b0=class extends Xc{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 b0(e.radius,e.detail)}},$S=new P,KS=new P,SF=new P,ZS=new Vr,Yc=class extends Et{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(Sp*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 Ax(d,p,i,n,r,h,0),p}};function Pce(e,t,i,n,r){let a,s;if(r===Bit(e,t,i,n)>0)for(a=t;a=t;a-=n)s=ile(a,e[a],e[a+1],s);return s&&$M(s,s.next)&&(Px(s),s=s.next),s}function Dp(e,t){if(!e)return e;t||(t=e);let i,n=e;do{if(i=!1,n.steiner||!$M(n,n.next)&&0!==Ai(n.prev,n,n.next))n=n.next;else{if(Px(n),n=t=n.prev,n===n.next)break;i=!0}}while(i||n!==t);return t}function Ax(e,t,i,n,r,a,s){if(!e)return;!s&&a&&Dit(e,n,r,a);let o,l,h=e;for(;e.prev!==e.next;)if(o=e.prev,l=e.next,a?wit(e,n,r,a):Tit(e))t.push(o.i/i|0),t.push(e.i/i|0),t.push(l.i/i|0),Px(e),e=l.next,h=l.next;else if((e=l)===h){s?1===s?Ax(e=Sit(Dp(e),t,i),t,i,n,r,a,2):2===s&&Mit(e,t,i,n,r,a):Ax(Dp(e),t,i,n,r,a,1);break}}function Tit(e){let t=e.prev,i=e,n=e.next;if(Ai(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&&l0(r,o,a,l,s,h,f.x,f.y)&&Ai(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function wit(e,t,i,n){let r=e.prev,a=e,s=e.next;if(Ai(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=RN(p,f,t,i,n),y=RN(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&&l0(o,c,l,u,h,d,x.x,x.y)&&Ai(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&&l0(o,c,l,u,h,d,b.x,b.y)&&Ai(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&&l0(o,c,l,u,h,d,x.x,x.y)&&Ai(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&&l0(o,c,l,u,h,d,b.x,b.y)&&Ai(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function Sit(e,t,i){let n=e;do{let r=n.prev,a=n.next.next;!$M(r,a)&&Ice(r,n,n.next,a)&&Cx(r,a)&&Cx(a,r)&&(t.push(r.i/i|0),t.push(n.i/i|0),t.push(a.i/i|0),Px(n),Px(n.next),n=e=a),n=n.next}while(n!==e);return Dp(n)}function Mit(e,t,i,n,r,a){let s=e;do{let e=s.next.next;for(;e!==s.prev;){if(s.i!==e.i&&kit(s,e)){let o=Dce(s,e);return s=Dp(s,s.next),o=Dp(o,o.next),Ax(s,t,i,n,r,a,0),void Ax(o,t,i,n,r,a,0)}e=e.next}s=s.next}while(s!==e)}function Rit(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&&l0(si.x||n.x===i.x&&Iit(i,n)))&&(i=n,u=o)),n=n.next}while(n!==l);return i}function Iit(e,t){return Ai(e.prev,e,t.prev)<0&&Ai(t.next,e,e.next)<0}function Dit(e,t,i,n){let r=e;do{0===r.z&&(r.z=RN(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,Lit(r)}function Lit(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 RN(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 Oit(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 kit(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!Fit(e,t)&&(Cx(e,t)&&Cx(t,e)&&Nit(e,t)&&(Ai(e.prev,e,t.prev)||Ai(e,t.prev,t))||$M(e,t)&&Ai(e.prev,e,e.next)>0&&Ai(t.prev,t,t.next)>0)}function Ai(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function $M(e,t){return e.x===t.x&&e.y===t.y}function Ice(e,t,i,n){let r=QS(Ai(e,t,i)),a=QS(Ai(e,t,n)),s=QS(Ai(i,n,e)),o=QS(Ai(i,n,t));return!!(r!==a&&s!==o||0===r&&JS(e,i,t)||0===a&&JS(e,n,t)||0===s&&JS(i,e,n)||0===o&&JS(i,t,n))}function JS(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 QS(e){return e>0?1:e<0?-1:0}function Fit(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&&Ice(i,i.next,e,t))return!0;i=i.next}while(i!==e);return!1}function Cx(e,t){return Ai(e.prev,e,e.next)<0?Ai(e,t,e.next)>=0&&Ai(e,e.prev,t)>=0:Ai(e,t,e.prev)<0||Ai(e,e.next,t)<0}function Nit(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 Dce(e,t){let i=new AN(e.i,e.x,e.y),n=new AN(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 ile(e,t,i,n){let r=new AN(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 Px(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 AN(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 Bit(e,t,i,n){let r=0;for(let a=t,s=i-n;a2&&e[t-1].equals(e[0])&&e.pop()}function ale(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 fe(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 fe(n/a,r/a)}let D=[];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}},Cs=class extends Qn{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new Ye(16777215),this.specular=new Ye(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ye(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Od,this.normalScale=new fe(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=Vx,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}},PM=class extends Qn{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new Ye(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ye(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Od,this.normalScale=new fe(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}},Id=class extends Qn{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Od,this.normalScale=new fe(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}},$c=class extends Qn{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Ye(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ye(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Od,this.normalScale=new fe(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=Vx,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}},IM=class extends Qn{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new Ye(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Od,this.normalScale=new fe(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}},Kc=class extends En{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 Qo(e,t,i){return wB(e)?new e.constructor(e.subarray(t,void 0!==i?i:e.length)):e.slice(t,i)}function Tp(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 wB(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Lce(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 CN(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 SB(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 zit(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=Qo(t.values,e,i)}else{let e=t.createInterpolant(),i=o,n=l-o;e.evaluate(a),u=Qo(e.resultBuffer,i,n)}"quaternion"===n&&(new Xn).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=Qo(i,r,a),this.values=Qo(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&&wB(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=Qo(this.times),t=Qo(this.values),i=this.getValueSize(),n=this.getInterpolation()===dM,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=Qo(e,0,a),this.values=Qo(t,0,a*i)):(this.times=e,this.values=t),this}clone(){let e=Qo(this.times,0),t=Qo(this.values,0),i=new(0,this.constructor)(this.name,e,t);return i.createInterpolant=this.createInterpolant,i}};_o.prototype.TimeBufferType=Float32Array,_o.prototype.ValueBufferType=Float32Array,_o.prototype.DefaultInterpolation=Gc;var gh=class extends _o{};gh.prototype.ValueTypeName="bool",gh.prototype.ValueBufferType=Array,gh.prototype.DefaultInterpolation=lh,gh.prototype.InterpolantFactoryMethodLinear=void 0,gh.prototype.InterpolantFactoryMethodSmooth=void 0;var Dx=class extends _o{};Dx.prototype.ValueTypeName="color";var rl=class extends _o{};rl.prototype.ValueTypeName="number";var OM=class extends mh{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)Xn.slerpFlat(r,0,a,l-s,a,l,o);return r}},fa=class extends _o{InterpolantFactoryMethodLinear(e){return new OM(this.times,this.values,this.getValueSize(),e)}};fa.prototype.ValueTypeName="quaternion",fa.prototype.DefaultInterpolation=Gc,fa.prototype.InterpolantFactoryMethodSmooth=void 0;var vh=class extends _o{};vh.prototype.ValueTypeName="string",vh.prototype.ValueBufferType=Array,vh.prototype.DefaultInterpolation=lh,vh.prototype.InterpolantFactoryMethodLinear=void 0,vh.prototype.InterpolantFactoryMethodSmooth=void 0;var Na=class extends _o{};Na.prototype.ValueTypeName="vector";var Ba=class{constructor(e,t=-1,i,n=XM){this.name=e,this.tracks=i,this.duration=t,this.blendMode=n,this.uuid=xo(),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(Wit(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(_o.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=[];SB(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!==nh[e])return void nh[e].push({onLoad:t,onProgress:i,onError:n});nh[e]=[],nh[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=nh[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=>{Op.add(e,t);let i=nh[e];delete nh[e];for(let e=0,n=i.length;e{let i=nh[e];if(void 0===i)throw this.manager.itemError(e),t;delete nh[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}},IN=class extends er{constructor(e){super(e)}load(e,t,i,n){let r=this,a=new Cr(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 Ye).setHex(t.value);break;case"v2":n.uniforms[r].value=(new fe).fromArray(t.value);break;case"v3":n.uniforms[r].value=(new P).fromArray(t.value);break;case"v4":n.uniforms[r].value=(new Zn).fromArray(t.value);break;case"m3":n.uniforms[r].value=(new pn).fromArray(t.value);break;case"m4":n.uniforms[r].value=(new qe).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 fe).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 fe).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:AM,SpriteMaterial:Tx,RawShaderMaterial:CM,ShaderMaterial:Yt,PointsMaterial:ci,MeshPhysicalMaterial:Eo,MeshStandardMaterial:Pd,MeshPhongMaterial:Cs,MeshToonMaterial:PM,MeshNormalMaterial:Id,MeshLambertMaterial:$c,MeshDepthMaterial:Kl,MeshDistanceMaterial:_x,MeshBasicMaterial:jt,MeshMatcapMaterial:IM,LineDashedMaterial:Kc,LineBasicMaterial:En,Material:Qn}[e]}},Ps=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 Zc(t);i=new kp(n),i.setCrossOrigin(this.crossOrigin);for(let t=0,i=e.length;t0){t=new kp(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){Xn.slerpFlat(e,t,e,t,e,i,n)}_slerpAdditive(e,t,i,n,r){let a=this._workIndex*r;Xn.multiplyQuaternionsFlat(e,a,e,t,e,i),Xn.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}}},MB="\\[\\]\\.:\\/",Kit=new RegExp("["+MB+"]","g"),RB="[^"+MB+"]",Zit="[^"+MB.replace("\\.","")+"]",Jit=/((?:WC+[\/:])*)/.source.replace("WC",RB),Qit=/(WCOD+)?/.source.replace("WCOD",Zit),est=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",RB),tst=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",RB),nst=new RegExp("^"+Jit+Qit+est+tst+"$"),rst=["material","materials","bones","map"],qN=class{constructor(e,t,i){let n=i||Fn.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()}},Fn=class{constructor(e,t,i){this.path=t,this.parsedPath=i||Fn.parseTrackName(t),this.node=Fn.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 Fn.Composite(e,t,i):new Fn(e,t,i)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(Kit,"")}static parseTrackName(e){let t=nst.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!==rst.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 Fn(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()}}},VM=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:Ep,endingEnd:Ep};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=ace,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===gB)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===oce;if(0===e)return-1===r?n:a&&1==(1&r)?t-n:n;if(i===sce){-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=_p,n.endingEnd=_p):(n.endingStart=e?this.zeroSlopeAtStart?_p:Ep:mx,n.endingEnd=t?this.zeroSlopeAtEnd?_p:Ep:mx)}_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}},ist=new Float32Array(1),WN=class extends bo{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 UM(Fn.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,ble).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)}},Ele=new P,tM=new P,pa=class{constructor(e=new P,t=new P){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){Ele.subVectors(e,this.start),tM.subVectors(this.end,this.start);let i=tM.dot(tM),n=tM.dot(Ele)/i;return t&&(n=Vi(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)}},_le=new P,JN=class extends Xt{constructor(e,t){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";let i=new Et,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{Rle.set(e.z,0,-e.x).normalize();let t=Math.acos(e.y);this.quaternion.setFromAxisAngle(Rle,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()}},aB=class extends Ar{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 Et;i.setAttribute("position",new Rt(t,3)),i.setAttribute("color",new Rt([1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],3)),super(i,new En({vertexColors:!0,toneMapped:!1})),this.type="AxesHelper"}setColors(e,t,i){let n=new Ye,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()}},Ux=class{constructor(){this.type="ShapePath",this.color=new Ye,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new Wc,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=Es.isClockWise,n=this.subPaths;if(0===n.length)return[];let r,a,s,o=[];if(1===n.length)return a=n[0],s=new us,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(Bce);return!(oi.far)&&(s.push({distance:o,point:Nce.clone(),index:n,object:e}),!0)}Wn.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(),eu.copy(i.boundingSphere),eu.applyMatrix4(n),eu.radius+=r,!1===e.ray.intersectsSphere(eu))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 Hce=Math.pow(2,-24),Up=class{constructor(){}};function al(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 AB(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 CB(e,t){t.set(e)}function PB(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 Gx(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 N0(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 cst(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 nn(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 M=e[y+4],S=e[y+5],E=M-S,T=M+S;Ec&&(c=T),v&&Mg&&(g=M)}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 hst(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 dst(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,kd=new Array(yh).fill().map((()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0}))),ZM=new Float32Array(6);function pst(e,t,i,n,r,a){let s=-1,o=0;if(0===a)s=AB(t),-1!==s&&(o=(t[s]+t[s+3])/2);else if(1===a)s=AB(e),-1!==s&&(o=mst(i,n,r,s));else if(2===a){let a=N0(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)/yh;if(r=a.candidate?Gx(r,i,a.rightCacheBounds):(Gx(r,i,a.leftCacheBounds),a.count++)}}for(let i=0;i=yh&&(t=yh-1);let a=kd[t];a.count++,Gx(r,i,a.bounds)}let t=kd[yh-1];CB(t.bounds,t.rightCacheBounds);for(let e=yh-2;e>=0;e--){let t=kd[e],i=kd[e+1];PB(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)*Hce,pt[n+3]&&(t[n+3]=m)}}return a}function vst(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=pst(t.boundingData,p,s,r,d,u);if(-1===g.axis)return i(r+d),t.offset=r,t.count=d,t;let v=dst(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 Up,i=r,o=v-r;t.left=e,e.boundingData=new Float32Array(6),DB(s,i,o,e.boundingData,a),n(e,i,o,a,m+1);let l=new Up,h=v,c=d-o;t.right=l,l.boundingData=new Float32Array(6),DB(s,h,c,l.boundingData,a),n(l,h,c,a,m+1)}return t}cst(e,t);let r=new Float32Array(6),a=new Float32Array(6),s=gst(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=ust(e);if(1===g.length){let e=g[0],t=new Up;t.boundingData=r,hst(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 Up;e.boundingData=new Float32Array(6),DB(s,v.offset,v.count,e.boundingData,a),n(e,v.offset,v.count,a),m.push(e)}return m}function zce(e,t){let i,n,r,a=vst(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 za=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}};za.prototype.setFromBox=function(){let e=new P;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 Bwt=function(){let e=new za;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}}}(),yst=function(){let e=new P,t=new P,i=new P;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}}(),qx=function(){let e=new fe,t=new P,i=new P;return function(n,r,a,s){yst(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))}}}(),Gce=function(){let e=new P,t=new P,i=new Mr,n=new pa;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}}(),xst=1e-15;function B0(e){return Math.abs(e)new P)),this.satBounds=new Array(4).fill().map((()=>new za)),this.points=[this.a,this.b,this.c],this.sphere=new Jn,this.plane=new Mr,this.needsUpdate=!0}intersectsSphere(e){return Gce(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}};Ga.prototype.closestPointToSegment=function(){let e=new P,t=new P,i=new pa;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]),qx(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=B0(g.distanceToPoint(n));if(B0(g.normal.dot(s))&&l){c.copy(h),i=2;break}if((g.intersectLine(h,a)||l)&&!B0(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=B0(m.distanceToPoint(e));if(B0(m.normal.dot(o))&&l){u.copy(h),a=2;break}if((m.intersectLine(h,i)||l)&&!B0(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)}}}(),Ga.prototype.distanceToPoint=function(){let e=new P;return function(t){return this.closestPointToPoint(t,e),t.distanceTo(e)}}(),Ga.prototype.distanceToTriangle=function(){let e=new P,t=new P,i=["a","b","c"],n=new pa,r=new pa;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 P)),this.satAxes=new Array(3).fill().map((()=>new P)),this.satBounds=new Array(3).fill().map((()=>new za)),this.alignedSatBounds=new Array(3).fill().map((()=>new za)),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}};qa.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 pa)),i=new Array(12).fill().map((()=>new pa)),n=new P,r=new P;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 ol(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 FB(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=V0(e),s=z0(e,o)):(r=z0(e,o),s=V0(e));let u=aR(r,a,n,rR)?sR(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=aR(s,a,n,rR)?sR(s,t,i,n):null;return u&&d?u.distance<=d.distance?u:d:u||d||null}}var Zce=function(){let e,t,i=[],n=new H0((()=>new bt));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=Fd,n=Nd;for(;!xh(t,i);)t=2*(e=V0(e));return Vp(e,n)}function u(e){let t=2*e,i=Fd,n=Nd;for(;!xh(t,i);)t=2*(e=z0(e,n));return Vp(e,n)+U0(t,i)}let d=2*i,p=q0,f=Fd,m=Nd;if(xh(d,f)){let t=Vp(i,m),n=U0(d,f);return al(i,p,e),s(t,n,!1,h,l+i,e)}{let d,g,v,y,x=V0(i),b=z0(i,m),_=x,w=b;if(o&&(v=e,y=t,al(_,p,v),al(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 Ga)),tc=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."),tc.serialize(arguments[0],{cloneBuffers:void 0===arguments[2]||arguments[2]});t=qn({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."),tc.deserialize(arguments[0],arguments[1],{setIndex:void 0===arguments[2]||arguments[2]});i=qn({setIndex:!0},i);let{index:n,roots:r}=e,a=new tc(t,ai(qn({},i),{[BB]:!0}));if(a._roots=r,i.setIndex){let i=t.getIndex();if(null===i){let i=new nn(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,[BB]:!1},t)).useSharedArrayBuffer&&"undefined"==typeof SharedArrayBuffer)throw new Error("MeshBVH: SharedArrayBuffer is not available.");this._roots=null,t[BB]||(this._roots=zce(e,t),!e.boundingBox&&t.setBoundingBox&&(e.boundingBox=this.getBoundingBox(new bt))),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=Xr){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=tu.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)||FB(t,i,n,l,a,s,r)}else o||(o=l?(e,t,i,a)=>FB(e,t,n,l,i,a,r):(e,t,i)=>i);let h=!1,c=0;for(let u of this._roots){if(j0(u),h=Zce(0,n,s,o,a,c),jx(),h)break;c+=u.byteLength}return tu.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;W0.copy(t).invert();let h=tu.getPrimitive(),c=tu.getPrimitive();if(r){let e=function(e,i,n,u,d,p,f,m){for(let g=n,v=n+u;gUB.intersectsBox(e),intersectsRange:(t,i,r,a,s,o)=>(HB.copy(o),HB.applyMatrix4(W0),e.shapecast({intersectsBounds:e=>HB.intersectsBox(e),intersectsRange:(e,r,o,l,h)=>n(t,i,e,r,a,s,l,h)}))});return tu.releasePrimitive(h),tu.releasePrimitive(c),u}intersectsBox(e,t){return zp.set(e.min,e.max,t),zp.needsUpdate=!0,this.shapecast({intersectsBounds:e=>zp.intersectsBox(e),intersectsTriangle:e=>zp.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(),zp.set(e.boundingBox.min,e.boundingBox.max,t),zp.needsUpdate=!0;let s=this.geometry,o=s.attributes.position,l=s.index,h=e.attributes.position,c=e.index,u=tu.getPrimitive(),d=tu.getPrimitive(),p=oR,f=wst,m=null,g=null;n&&(m=Sst,g=Mst);let v=1/0,y=null,x=null;return W0.copy(t).invert(),Wx.matrix.copy(W0),this.shapecast({boundsTraverseOrder:e=>zp.distanceToBox(e),intersectsBounds:(e,t,i)=>i{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:e=>Wx.distanceToBox(e),intersectsBounds:(e,t,i)=>i{for(let s=3*e,b=3*(e+a);s(Xx.copy(e).clamp(t.min,t.max),Xx.distanceToSquared(e)),intersectsBounds:(e,t,i)=>i{t.closestPointToPoint(e,Xx);let n=e.distanceToSquared(Xx);return n{al(0,new Float32Array(t),Qce),e.union(Qce)})),e}},VB=new ka,eue=new qe,Rst=ht.prototype.raycast;function zB(e,t){if(this.geometry.boundsTree){if(void 0===this.material)return;eue.copy(this.matrixWorld).invert(),VB.copy(e.ray).applyMatrix4(eue);let i=this.geometry.boundsTree;if(!0===e.firstHitOnly){let n=kB(i.raycastFirst(VB,this.material),this,e);n&&t.push(n)}else{let n=i.raycast(VB,this.material);for(let i=0,r=n.length;ii.far?null:{distance:h,point:pR.clone(),object:e}}function mR(e,t,i,n,r,a,s,o,l,h,c,u){Bd.fromBufferAttribute(r,h),Hd.fromBufferAttribute(r,c),Ud.fromBufferAttribute(r,u);let d=e.morphTargetInfluences;if(a&&d){lR.set(0,0,0),cR.set(0,0,0),uR.set(0,0,0);for(let e=0,t=a.length;e=1)return}}else for(let m=Math.max(0,p.start),g=Math.min(s.count,p.start+p.count);m=1)return}else if(void 0!==o)if(Array.isArray(n))for(let m=0,g=d.length;m=1)return}else for(let m=Math.max(0,p.start),g=Math.min(o.count,p.start+p.count);m=1)return},ht.prototype.raycast=zB;var gR=new Jn,vR=new P;function nue(e,t,i,n,r,a){let s=n.ray.distanceSqToPoint(e);if(sn.far)return;r.push({distance:o,distanceToRay:Math.sqrt(s),point:i,index:t,face:null,object:a})}}Yr.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(),gR.copy(i.boundingSphere),gR.applyMatrix4(n),gR.radius+=r,!1===e.ray.intersectsSphere(gR))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 YB=class{constructor(){this.id=0,this.object=null,this.z=0,this.renderOrder=0}},Yx=class{constructor(){this.id=0,this.v1=new Vd,this.v2=new Vd,this.v3=new Vd,this.normalModel=new P,this.vertexNormalsModel=[new P,new P,new P],this.vertexNormalsLength=0,this.color=new Ye,this.material=null,this.uvs=[new fe,new fe,new fe],this.z=0,this.renderOrder=0}},Vd=class{constructor(){this.position=new P,this.positionWorld=new P,this.positionScreen=new Zn,this.visible=!0}copy(e){this.positionWorld.copy(e.positionWorld),this.positionScreen.copy(e.positionScreen)}},$x=class{constructor(){this.id=0,this.v1=new Vd,this.v2=new Vd,this.vertexColors=[new Ye,new Ye],this.material=null,this.z=0,this.renderOrder=0}},Kx=class{constructor(){this.id=0,this.object=null,this.x=0,this.y=0,this.z=0,this.rotation=0,this.scale=new fe,this.material=null,this.renderOrder=0}},yR=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 P,y=new Zn,x=new bt(new P(-1,-1,-1),new P(1,1,1)),b=new bt,_=new Array(3),w=new qe,M=new qe,S=new qe,E=new qs,T=[],A=[],C=[],R=[],L=[],D=new function(){let e=[],t=[],l=[],h=null,u=new pn;function m(e){let t=e.position,i=e.positionWorld,n=e.positionScreen;i.copy(t).applyMatrix4(c),n.copy(i).applyMatrix4(M);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 w(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 E(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){h=i,u.getNormalMatrix(h.matrixWorld),e.length=0,t.length=0,l.length=0},projectVertex:m,checkTriangleVisibility:w,checkBackfaceCulling:E,pushVertex:function(e,t,r){i=function(){if(n===d){let e=new Vd;return A.push(e),d++,n++,e}return A[n++]}(),i.position.set(e,t,r),m(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){l.push(e,t)},pushLine:function(e,i){let n=A[e],r=A[i];n.positionScreen.copy(n.position).applyMatrix4(S),r.positionScreen.copy(r.position).applyMatrix4(S),!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 Kx;return L.push(e),m++,h++,e}return L[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(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),M.multiplyMatrices(i.projectionMatrix,w),E.setFromProjectionMatrix(M),t=0,g.objects.length=0,g.lights.length=0,I(e),!0===r&&g.objects.sort(N);let l=g.objects;for(let t=0,a=l.length;t0)for(let r=0;r0)for(let r=0;r0;)k.removeChild(k.childNodes[0])}function F(e){return null!==g?e.toFixed(g):e}function U(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"+F(e.x-.5*n)+","+F(e.y-.5*r)+"h"+F(n)+"v"+F(r)+"h"+F(-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"+F(e.positionScreen.x)+","+F(e.positionScreen.y)+"L"+F(t.positionScreen.x)+","+F(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"+F(e.positionScreen.x)+","+F(e.positionScreen.y)+"L"+F(t.positionScreen.x)+","+F(t.positionScreen.y)+"L"+F(n.positionScreen.x)+","+F(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(M),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)}}W(),n.traverseVisible((function(e){if(e.isSVGObject){if(T.setFromMatrixPosition(e.matrixWorld),T.applyMatrix4(D),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 Cst(e){let t={};return t.r=(e>>16&255)/255,t.g=(e>>8&255)/255,t.b=(255&e)/255,t}var xR=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"})}},Pst=Xi(aue(),1),J=Pst;J.setLevel("warn");var oue=e=>{try{J.setLevel(e)}catch(e){J.setLevel("error"),J.error(e)}},$B=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=$B.isTouchScreenDevice();t&&J.debug("[DI] is android"),i&&J.debug("[DI] is fireFox"),n&&J.debug("[DI] is chrome"),r&&J.debug("[DI] is tablet"),a&&J.debug("[DI] is iPhone"),s&&J.debug("[DI] is PC"),o&&J.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:()=>{}}}},dn=$B;dn.isMobile=/mobile/i.test(navigator.userAgent),dn.isBrowser="undefined"!=typeof document,dn.isNode="undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process);var ER=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 P?`(${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 fe?e:Array.isArray(e)&&e.length>=2?new fe(e[0],e[1]):void 0:e}static arrayToVector3(e){return e?e instanceof P?e:Array.isArray(e)&&e.length>=2?new P(e[0],e[1],e.length>2?e[2]:0):void 0:e}static arrayToEuler(e){return e?e instanceof Dn?e:Array.isArray(e)&&e.length>=3?new Dn(e[0],e[1],e[2]):void 0:e}static arrayOrObjectToVector3(e){if(!e)return e;if(e instanceof P)return e;if(e instanceof fe)return new P(e.x,e.y,0);if(Array.isArray(e)&&e.length>=2)return new P(e[0],e[1],e[2]||0);let t=e;return null!=t.x&&null!=t.y?new P(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 P&&(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 P;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 P(i.x-n/2,i.y-r/2,i.z-a/2),o=new P(i.x+n/2,i.y+r/2,i.z+a/2);e.set(s,o)}static expandBoxByMinSize(e,t){let i=new P;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(dn.isBrowser){let t=performance.memory;if(!t)return void J.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);J.info(`[CommonUtils] ${e}. jsHeapSizeLimit: ${i}M , totalJSHeapSize: ${n}M , usedJSHeapSize: ${r}M `)}}static printGpuInfo(e){if(dn.isBrowser){let t=e.getExtension("webgl_debug_renderer_info"),i=e.getParameter(t.UNMASKED_RENDERER_WEBGL);J.info("[CommonUtils] gpu:",i)}}static sleep(e){return nt(this,null,(function*(){let t;return new Promise((i=>{t=setTimeout((()=>{i("")}),e)})).then((()=>{clearTimeout(t)}))}))}static twinkle(e,t=500){return nt(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=>nt(this,null,(function*(){if(e){e(new ProgressEvent("",{loaded:i,total:100}));let n=500,r=Date.now();r-t>n&&(yield ER.sleep(0),t=r)}}))}static getUpdateProgressFuncForLoop(e,t){let i=Math.round(Math.pow(e,.5)),n=Date.now();return r=>nt(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 ER.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||(J.warn("[Progress] Invalid ProgressEvent:",r),n=!0),a=t),i&&i(new ProgressEvent(r.type,{loaded:a,total:100}))}}},ft=ER;ft.twinklingObjectIds={};var _R=(e,t,i)=>{let{default:n,active:r}=t;i?(e.remove(n),e.add(r||n)):(r&&e.remove(r),e.add(n))},vn=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}},$t=class{static getScreenPointByEvent(e,t){let i=new fe,{left:n,top:r}=t.getBoundingClientRect();return i.x=e.clientX-n,i.y=e.clientY-r,i}static getScreenPointByTouchEvent(e,t){let i=new fe,{left:n,top:r}=t.getBoundingClientRect();return i.x=e.touches[0].clientX-n,i.y=e.touches[0].clientY-r,i}static worldPosition2ScreenPoint(e,t,i){let{clientWidth:n,clientHeight:r}=i,a=e.clone(),s=new fe;return a.project(t),s.x=Math.round((.5+a.x/2)*n),s.y=Math.round((.5-a.y/2)*r),s}static screenPoint2worldPosition(e,t,i){let n=$t.screenPoint2NdcPoint(e,t,i);return new P(n.x,n.y,1).unproject(t)}static screenPoint2NdcPoint(e,t,i){let{clientWidth:n,clientHeight:r}=i,a=new fe;return a.x=e.x/n*2-1,a.y=-e.y/r*2+1,a}static worldCoordinate2NormalizedScreenCoordinate(e,t,i){let n=new P;e instanceof fe?n.set(e.x,e.y,0):n.set(e.x,e.y,e.z);let r=$t.worldPosition2ScreenPoint(n,t,i);return r.x/=i.clientWidth,r.y/=i.clientHeight,r}},$0=class extends Xt{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 fe(.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}},Y0=new P,lue=new qe,cue=new qe,uue=new P,hue=new P,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){Y0.setFromMatrixPosition(e.matrixWorld),Y0.applyMatrix4(cue);let l=!0===e.visible&&Y0.z>=-1&&Y0.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("+(Y0.x*n+n)+"px,"+(-Y0.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===due["Precision from file"]?2:t),zi=class{constructor(){this.map=new Map}addEventListener(e,t){let i=this.map.get(e);i||(i=new Set,this.map.set(e,i)),i.add(t)}dispatchEvent(e,t={}){let i=this.map.get(e);i&&[...i].forEach((e=>e(t)))}hasEventListener(e){return!!this.map.get(e)}removeEventListener(e,t){if(!e)return void this.map.clear();if(!t)return void this.map.delete(e);let i=this.map.get(e);i&&i.delete(t)}},js=class{parse(e,t={}){if(t=Object.assign({decodeSpeed:5,encodeSpeed:5,encoderMethod:js.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=gn.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 bue(e){return 4*Math.ceil(e/4)}function JB(e,t=0){let i=bue(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 QB=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 nt(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=JB(e.result),n=new DataView(new ArrayBuffer(vue));n.setUint32(0,i.byteLength,!0),n.setUint32(4,kst,!0);let r=JB(Fst(JSON.stringify(a)),32),s=new DataView(new ArrayBuffer(vue));s.setUint32(0,r.byteLength,!0),s.setUint32(4,Ost,!0);let o=new ArrayBuffer(gue),l=new DataView(o);l.setUint32(0,Dst,!0),l.setUint32(4,Lst,!0);let h=gue+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 P;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 P;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=gn.normalize(n,e.array))),t===_r.FLOAT?l.setFloat32(h,n,!0):t===_r.INT?l.setInt32(h,n,!0):t===_r.UNSIGNED_INT?l.setUint32(h,n,!0):t===_r.SHORT?l.setInt16(h,n,!0):t===_r.UNSIGNED_SHORT?l.setUint16(h,n,!0):t===_r.BYTE?l.setInt8(h,n):t===_r.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===_r.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=JB(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=_r.FLOAT;else if(e.array.constructor===Int32Array)r=_r.INT;else if(e.array.constructor===Uint32Array)r=_r.UNSIGNED_INT;else if(e.array.constructor===Int16Array)r=_r.SHORT;else if(e.array.constructor===Uint16Array)r=_r.UNSIGNED_SHORT;else if(e.array.constructor===Int8Array)r=_r.BYTE;else{if(e.array.constructor!==Uint8Array)throw new Error("THREE.GLTFExporter: Unsupported bufferAttribute component type: "+e.array.constructor.name);r=_r.UNSIGNED_BYTE}if(void 0===i&&(i=0),void 0===n&&(n=e.count),0===n)return null;let s,o=Bst(e,i,n);void 0!==t&&(s=e===t.index?_r.ELEMENT_ARRAY_BUFFER:_r.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=yue();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!==As&&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(xue(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:To[e.magFilter],minFilter:To[e.minFilter],wrapS:To[e.wrapS],wrapT:To[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 fh&&(e=SR(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(Zx(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===or&&(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[ZB])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];pue[n]&&pue[n].includes(i)&&(this.extensionsUsed[ZB]=!0,this.extensionsRequired[ZB]=!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:gn.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=J0.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 ti;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}}},t5=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}},n5=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}},r5=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}},i5=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}},s5=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}},a5=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}},o5=class{constructor(e){this.writer=e,this.name="KHR_materials_specular"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||1===e.specularIntensity&&e.specularColor.equals(Ist)&&!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}},l5=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}},c5=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}},u5=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}};J0.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=pi.addExtention(t,pi.EXTENSION_GLB);let i=e;pi.saveArrayBuffer(i,t)}else t=pi.addExtention(t,pi.EXTENSION_GLTF),pi.saveJson(e,t)}),(e=>console.log(e)),i)}static exportToObj(e,t){if(!e||!t)throw new Error("Invalid input or filename!");t=pi.addExtention(t,pi.EXTENSION_OBJ);let i=(new MR).parse(e);pi.saveString(i,t)}static exportToDraco(e,t,i={}){if(!e||!t)throw new Error("Invalid input or filename!");t=pi.addExtention(t,pi.EXTENSION_DRACO);let n=new js;i=Object.assign({},{encodeSpeed:5},i);let r=n.parse(e,i);pi.saveArrayBuffer(r,t)}static exportToThreeJsJson(e,t){let i=e.toJSON();t.toLowerCase().endsWith(pi.EXTENSION_JSON)||(t+=pi.EXTENSION_JSON),pi.saveJson(i,t)}static save(e,t){let i=pi.downloadLink;i||(i=document.createElement("a"),i.style.display="none",document.body.appendChild(i),pi.downloadLink=i),i.href=URL.createObjectURL(e),i.download=t,i.click()}static saveArrayBuffer(e,t){pi.save(new Blob([e],{type:"application/octet-stream"}),t)}static saveJson(e,t){pi.saveJsonString(JSON.stringify(e),t)}static saveJsonString(e,t){pi.save(new Blob([e],{type:"application/json"}),t)}static saveString(e,t){pi.save(new Blob([e],{type:"text/csv"}),t)}static addExtention(e,t){return e.toLowerCase().endsWith(t.toLowerCase())||(e+=t),e}},Gp=pi;Gp.EXTENSION_GLTF=".gltf",Gp.EXTENSION_GLB=".glb",Gp.EXTENSION_OBJ=".obj",Gp.EXTENSION_DRACO=".drc",Gp.EXTENSION_JSON=".json";var RR=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()}},g5={exports:{}};function PR(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=Mue(e,0,u,i,!0),p=[];if(!d||d.next===d.prev)return p;if(c&&(d=Gst(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 Jx(d,p,i,n,r,h,0),p}function Mue(e,t,i,n,r){var a,s;if(r===m5(e,t,i,n)>0)for(a=t;a=t;a-=n)s=Eue(a,e[a],e[a+1],s);return s&&IR(s,s.next)&&(eb(s),s=s.next),s}function qp(e,t){if(!e)return e;t||(t=e);var i,n=e;do{if(i=!1,n.steiner||!IR(n,n.next)&&0!==Ii(n.prev,n,n.next))n=n.next;else{if(eb(n),(n=t=n.prev)===n.next)break;i=!0}}while(i||n!==t);return t}function Jx(e,t,i,n,r,a,s){if(e){!s&&a&&Yst(e,n,r,a);for(var o,l,h=e;e.prev!==e.next;)if(o=e.prev,l=e.next,a?Ust(e,n,r,a):Hst(e))t.push(o.i/i|0),t.push(e.i/i|0),t.push(l.i/i|0),eb(e),e=l.next,h=l.next;else if((e=l)===h){s?1===s?Jx(e=Vst(qp(e),t,i),t,i,n,r,a,2):2===s&&zst(e,t,i,n,r,a):Jx(qp(e),t,i,n,r,a,1);break}}}function Hst(e){var t=e.prev,i=e,n=e.next;if(Ii(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&&Q0(r,o,a,l,s,h,f.x,f.y)&&Ii(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function Ust(e,t,i,n){var r=e.prev,a=e,s=e.next;if(Ii(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=f5(p,f,t,i,n),y=f5(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&&Q0(o,c,l,u,h,d,x.x,x.y)&&Ii(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&&Q0(o,c,l,u,h,d,b.x,b.y)&&Ii(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&&Q0(o,c,l,u,h,d,x.x,x.y)&&Ii(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&&Q0(o,c,l,u,h,d,b.x,b.y)&&Ii(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function Vst(e,t,i){var n=e;do{var r=n.prev,a=n.next.next;!IR(r,a)&&Rue(r,n,n.next,a)&&Qx(r,a)&&Qx(a,r)&&(t.push(r.i/i|0),t.push(n.i/i|0),t.push(a.i/i|0),eb(n),eb(n.next),n=e=a),n=n.next}while(n!==e);return qp(n)}function zst(e,t,i,n,r,a){var s=e;do{for(var o=s.next.next;o!==s.prev;){if(s.i!==o.i&&Zst(s,o)){var l=Aue(s,o);return s=qp(s,s.next),l=qp(l,l.next),Jx(s,t,i,n,r,a,0),void Jx(l,t,i,n,r,a,0)}o=o.next}s=s.next}while(s!==e)}function Gst(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&&Q0(ai.x||n.x===i.x&&Xst(i,n)))&&(i=n,d=l)),n=n.next}while(n!==h);return i}function Xst(e,t){return Ii(e.prev,e,t.prev)<0&&Ii(t.next,e,e.next)<0}function Yst(e,t,i,n){var r=e;do{0===r.z&&(r.z=f5(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,$st(r)}function $st(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 f5(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 Kst(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 Zst(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!Jst(e,t)&&(Qx(e,t)&&Qx(t,e)&&Qst(e,t)&&(Ii(e.prev,e,t.prev)||Ii(e,t.prev,t))||IR(e,t)&&Ii(e.prev,e,e.next)>0&&Ii(t.prev,t,t.next)>0)}function Ii(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function IR(e,t){return e.x===t.x&&e.y===t.y}function Rue(e,t,i,n){var r=CR(Ii(e,t,i)),a=CR(Ii(e,t,n)),s=CR(Ii(i,n,e)),o=CR(Ii(i,n,t));return!!(r!==a&&s!==o||0===r&&AR(e,i,t)||0===a&&AR(e,n,t)||0===s&&AR(i,e,n)||0===o&&AR(i,t,n))}function AR(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 CR(e){return e>0?1:e<0?-1:0}function Jst(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&&Rue(i,i.next,e,t))return!0;i=i.next}while(i!==e);return!1}function Qx(e,t){return Ii(e.prev,e,e.next)<0?Ii(e,t,e.next)>=0&&Ii(e,e.prev,t)>=0:Ii(e,t,e.prev)<0||Ii(e,e.next,t)<0}function Qst(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 Aue(e,t){var i=new p5(e.i,e.x,e.y),n=new p5(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 Eue(e,t,i,n){var r=new p5(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 eb(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 p5(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 m5(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 FMt=g5.exports;function _ue(e,t,i){return e[0]=t[0]-i[0],e[1]=t[1]-i[1],e[2]=t[2]-i[2],e}function eat(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 tat(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 nat(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 Br=!1,BMt=!1,iu=10,is=11,Fr=12,ev="gemini-viewer-iconfont",HMt="keydown",UMt="keyup",Gd="mousemove",v5="mouseup",y5="mousedown",VMt="Escape",zMt="Enter",GMt="axis-section-plane",qMt="axis-section-plane-control",jMt="section-plane",WMt="section-plane-control",XMt="section-box",x5="plane-section-boxface",Pue=-1e3,tv=(e=>(e.ObjectsBoxSection="ObjectsBoxSection",e.PickPlaneSection="PickPlaneSection",e.AxisPlaneSection="AxisPlaneSection",e))(tv||{}),b5=(e=>(e.Default="Default",e.BoxSelection="BoxSelection",e.PickMarkup="PickMarkup",e))(b5||{}),E5=1e-15,Iue=(new qe).set(0,0,-1,0,1,0,0,0,0,1,0,0,0,0,0,1),Due=(new qe).set(0,1,0,0,1,0,0,0,0,0,1,0,0,0,0,1),Nt=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 Fa){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 P,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=kue.subVectors(n,i).normalize(),o=Fue.subVectors(a,r).normalize();if(1===s.dot(o))return null;let l=Nue.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(Nt.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=kue.subVectors(n,r).length(),s=Fue.subVectors(e,n).length(),o=Nue.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(Ut.shouldRebasePositionOnRTC(t)){n=!0;for(let n=0;n_5||Math.abs(e.y)>_5||e instanceof P&&Math.abs(e.z)>_5}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 P(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||(Lue.setFromPoints(e),Oue.setFromPoints(t),!Lue.intersectsBox(Oue)))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}=Cue([i],{lineWidth:t,depth:1}),r=new Et;return r.setAttribute("position",new Rt(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 Qn)return this.clonedHighlightMaterial(i,t);console.warn(`[MaterialUtils] Invalid material: ${i}`)}static clonedHighlightMaterial(e,t={}){let{depthTest:i,highlightColor:n=new Ye(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=or),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 Ye(16777215);return e instanceof ci||e instanceof En||e instanceof jt?t=e.color:e instanceof Yt&&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 $i(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 Et,h=0;for(let c=0;c0){e.matrixWorld||(e.matrixWorld=new qe),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=or)},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 ht){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&&J.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 ht)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 nc.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}`);nc.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 ht&&(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 jt({color:0,transparent:!0,opacity:.05});this.applyMaterialToObject(e,n,t,i)}static setWireframeMode(e){let t=new jt({color:16732160,wireframe:!0,transparent:!0,opacity:.8});e.traverseVisible((e=>{if(e instanceof ht){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}`);nc.setWireframeMode(i)}static revertWireframeMode(e){e.traverseVisible((e=>{e instanceof ht&&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}`);nc.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 nt(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 ht)))return[];let n=[],r=e,a=r.children.length,s=Math.round(Math.pow(a,.5)),o=ft.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=ft.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 ht&&!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 Yc(e,5),r=new Ar(n,t);return r.layers.enableAll(),nc.disableLayerChannels(r,[12]),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 ht||e instanceof Wn)&&(e.material=Di.cloneMaterial(e.material))})),i}static createBox(e,t,i,n=nc.BOX_FACE_MATERIAL,r=!0){let a=[],s=(e,t,i)=>{a.push(new P(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 Et;o.setFromPoints(a);let l=[0,3,2,0,2,1,4,6,7,4,5,6,0,7,3,0,4,7,3,6,2,3,7,6,1,6,5,1,2,6];return r&&l.push(0,5,4,0,1,5),o.setIndex(l),o.computeVertexNormals(),new ht(o,n)}static rebaseObjectOnRTC(e){let t=e;if(!((t.isMesh||t.isLine||t.isPoints)&&t.geometry&&t.geometry instanceof Et))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=hat;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 ht||e instanceof Wn||e instanceof Yr)&&!!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 Et))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),Ut.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=$i(c);if(!e)return;e.userData={},n=new ht(e,h.material),a.push(n)}else if(h.isLine){let e=this.mergeLineGeometries(c,t,h.material instanceof Kc||h.material instanceof Yt,f);if(!e)return;n=new Ar(e,h.material),s.push(n)}else if(h.isPoints){let e=$i(c);if(!e)return;e.userData={},n=new Yr(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(),Ut.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)&&Di.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=void 0,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;J.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 En&&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=$i(o);if(!e)return;e.userData={},a=new ht(e,s.material),h.push(a)}else if(s.isLine){let e=this.mergeLineGeometries(o,r,s.material instanceof Kc||s.material instanceof Yt,m);if(!e)return;a=new Ar(e,s.material),c.push(a)}else if(s.isPoints){let e=$i(o);if(!e)return;e.userData={},a=new Yr(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(),Ut.releaseGeometryManually(e)})),o=[]}})),J.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&&Sn.removeEmptyObjects(t),a}static applyMatrix(e,t,i){let n=t;for(DR.identity();n&&n!==i&&(DR.premultiply(n.matrix),n.parent);)n=n.parent;return DR.equals(dat)?e:e.applyMatrix4(DR)}static mergeLineGeometries(e,t,i,n){let r;if(i)r=LR.mergeBufferGeometriesWithLinesToLineSegments(e,t,n);else{if(r=$i(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 Et,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&&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 sb(d,p,i,n,r,h,0),p}};function uhe(e,t,i,n,r){let a,s;if(r===iot(e,t,i,n)>0)for(a=t;a=t;a-=n)s=lhe(a,e[a],e[a+1],s);return s&&zR(s,s.next)&&(ob(s),s=s.next),s}function Wp(e,t){if(!e)return e;t||(t=e);let i,n=e;do{if(i=!1,n.steiner||!zR(n,n.next)&&0!==Li(n.prev,n,n.next))n=n.next;else{if(ob(n),n=t=n.prev,n===n.next)break;i=!0}}while(i||n!==t);return t}function sb(e,t,i,n,r,a,s){if(!e)return;!s&&a&&Jat(e,n,r,a);let o,l,h=e;for(;e.prev!==e.next;)if(o=e.prev,l=e.next,a?qat(e,n,r,a):Gat(e))t.push(o.i/i|0),t.push(e.i/i|0),t.push(l.i/i|0),ob(e),e=l.next,h=l.next;else if((e=l)===h){s?1===s?sb(e=jat(Wp(e),t,i),t,i,n,r,a,2):2===s&&Wat(e,t,i,n,r,a):sb(Wp(e),t,i,n,r,a,1);break}}function Gat(e){let t=e.prev,i=e,n=e.next;if(Li(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&&nv(r,o,a,l,s,h,f.x,f.y)&&Li(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function qat(e,t,i,n){let r=e.prev,a=e,s=e.next;if(Li(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=D5(p,f,t,i,n),y=D5(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&&nv(o,c,l,u,h,d,x.x,x.y)&&Li(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&&nv(o,c,l,u,h,d,b.x,b.y)&&Li(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&&nv(o,c,l,u,h,d,x.x,x.y)&&Li(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&&nv(o,c,l,u,h,d,b.x,b.y)&&Li(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function jat(e,t,i){let n=e;do{let r=n.prev,a=n.next.next;!zR(r,a)&&hhe(r,n,n.next,a)&&ab(r,a)&&ab(a,r)&&(t.push(r.i/i|0),t.push(n.i/i|0),t.push(a.i/i|0),ob(n),ob(n.next),n=e=a),n=n.next}while(n!==e);return Wp(n)}function Wat(e,t,i,n,r,a){let s=e;do{let e=s.next.next;for(;e!==s.prev;){if(s.i!==e.i&&tot(s,e)){let o=dhe(s,e);return s=Wp(s,s.next),o=Wp(o,o.next),sb(s,t,i,n,r,a,0),void sb(o,t,i,n,r,a,0)}e=e.next}s=s.next}while(s!==e)}function Xat(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&&nv(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 Li(e.prev,e,t.prev)<0&&Li(t.next,e,e.next)<0}function Jat(e,t,i,n){let r=e;do{0===r.z&&(r.z=D5(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 D5(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 eot(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 tot(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!not(e,t)&&(ab(e,t)&&ab(t,e)&&rot(e,t)&&(Li(e.prev,e,t.prev)||Li(e,t.prev,t))||zR(e,t)&&Li(e.prev,e,e.next)>0&&Li(t.prev,t,t.next)>0)}function Li(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function zR(e,t){return e.x===t.x&&e.y===t.y}function hhe(e,t,i,n){let r=VR(Li(e,t,i)),a=VR(Li(e,t,n)),s=VR(Li(i,n,e)),o=VR(Li(i,n,t));return!!(r!==a&&s!==o||0===r&&UR(e,i,t)||0===a&&UR(e,n,t)||0===s&&UR(i,e,n)||0===o&&UR(i,t,n))}function UR(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 VR(e){return e>0?1:e<0?-1:0}function not(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&&hhe(i,i.next,e,t))return!0;i=i.next}while(i!==e);return!1}function ab(e,t){return Li(e.prev,e,e.next)<0?Li(e,t,e.next)>=0&&Li(e,e.prev,t)>=0:Li(e,t,e.prev)<0||Li(e,e.next,t)<0}function rot(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 dhe(e,t){let i=new L5(e.i,e.x,e.y),n=new L5(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 lhe(e,t,i,n){let r=new L5(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 ob(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 L5(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 iot(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 che.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;nsot)return!1;return!0}static isSelfIntersecting(e){let t=e.map((e=>e.toArray().slice(0,-1)));return(0,fhe.default)(t).length>0}},fs=class{static getVisibleObjectBoundingBox(e){let t=new bt;return e.traverse((e=>{e.visible&&(e instanceof ht||e instanceof Wn)&&Sn.isObjectSelectable(e)&&t.expandByObject(e)})),t}static getObjectsBoundingBox(e,t,i){let n=new bt;return t.forEach((t=>{let r=e.getObjectById(t);if(r){let e=fs.getBoundingBox(r,i);e.isEmpty()||n.union(e)}})),n}static getBoundingBox(e,t=!0){let i=new bt;if(e instanceof _i)return fs.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=void 0})):t&&(t.clippingPlanes=void 0)}))}static addSection(e,t,i=!1,n=!1){e&&e.traverse((e=>{let r=e.material;Array.isArray(r)?r.forEach((e=>{su.setMaterialSection(e,t,i,n)})):r&&su.setMaterialSection(r,t,i,n)}))}static generateSectionPlanesByBox(e){let t=e.min,i=e.max;return[new Mr(new P(0,-1,0),i.y),new Mr(new P(0,1,0),-t.y),new Mr(new P(1,0,0),-t.x),new Mr(new P(-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 oot(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)&&lot(i.faces[a],t);for(let a=i.faces.length-1;a>=0;a--)i.faces[a].replaceVertex(i,n);mhe(i,e);for(let a=0;a0?(new GR).modify(e,i):e}static getNumberOfVerticesToRemove(e,t){let i=0;e instanceof Et&&e.index&&(i=e.attributes.position.count);let n=Math.floor(i*t);return i<20?0:n}},jR=class extends Xt{constructor(e){super(),this.isSVGObject=!0,this.node=e}},ZRt=10,xhe=(e=>(e.TripleCross="TripleCross",e.Square="Square",e.Triangle="Triangle",e.CircleWithCross="CircleWithCross",e.Cross="Cross",e.Perpendicular="Perpendicular",e))(xhe||{}),yhe=class{static createSVGObject(e){return new jR(e)}},WR=class extends Fp{constructor(e){super(e),this.type=cr}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 nt(this,arguments,(function*(e,t=this.HDR_CITY_STREET_64x32,i=64,n=32){if(e){let r=new el(t,i,n);r.flipY=!0,r.magFilter=dr,r.minFilter=dr,r.type=cr,r.version=1;let a=e.fromEquirectangular(r).texture;return e.dispose(),Promise.resolve(a)}return Promise.reject("Invalid pmremGenerator!")}))}};function hot(){if(dn.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}rc.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 bhe={file:1,m:1,mm:.001,cm:.01,ft:.3048,in:.0254,pt:hot()},dot={file:"m",m:"m",mm:"mm",cm:"cm",ft:"ft",in:"in",pt:"pt"},Ehe=e=>2===e?"\xb2":3===e?"\xb3":"",lb=(e,t=1)=>dot[e]+Ehe(t),sAt=(e,t,i,n=1)=>(null==i&&(i=t),i===t?{value:e,unit:lb(i)}:{value:e*Math.pow(bhe[t]/bhe[i],n),unit:lb(i)+Ehe(n)}),F5=(e=>(e.Top="Top",e.Bottom="Bottom",e.Front="Front",e.Back="Back",e.Left="Left",e.Right="Right",e))(F5||{}),cb=class{static getCameraPositionByBboxAndDirection(e,t,i,n,r){if(e.isEmpty()||!n)return;let a=new P,s=new P,o=new P(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 P))l=new P(a.x+c,a.y+c/1.5,a.z+c),h=l.clone().sub(a);else{let e=new P(c,c/1.5,c).length();h=new P(-r.x,-r.y,-r.z).normalize().multiplyScalar(e),l=h.clone().add(a)}c=h.length(),h=h.normalize();let u=new qe;u.lookAt(l,a,o);let d=new qe;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 P(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}},fot=!1,mi=class extends zi{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 qe,this.id=e||ft.guid()}setTolerance(e){this.tolerance=e}render(e,t){this.ctx=e,this.draw(e,t),this.selected&&this.drawSelect(e,t),fot&&(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 P(this.x,this.y,0),new P(this.x+this.width,this.y,0),new P(this.x+this.width,this.y-this.height,0),new P(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 P)}transToScreenCoord(e,t){return this.ctx?$t.worldPosition2ScreenPoint(e,t,this.ctx.canvas):new fe}drawBounds(e,t){let{min:i,max:n}=this.getBounds(),r=[],a=(e,t,i)=>r.push(new P(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 bt).setFromPoints(e)}},Ti=(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))(Ti||{}),_he={},_n=class extends zi{constructor(e){super(),this.drawableLists=[],this.frustum=new qs,this.projScreenMatrix=new qe,this.viewer=e,this.init()}static _registerDrawableClass(e){_he[e.prototype.getClassType()]=e}static createDrawable(e){let t=_he[e.type];if(!t)throw new Error(`Invalid drawable type: ${t}`);let i=e.points.map((e=>new P(e[0],e[1],e[2]||0))),n=new t(e.id,i);return n.setData(e),n}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(dn.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=dn.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 Jn,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){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)}},So=class extends zi{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 P)}isPointInPath(e){let t=this.getVertexes().map((e=>new fe(e.x,e.y)));return Ut.isPointInPolygon(new fe(e.x,e.y),t,!0)}setData(e){super.setData(e),this.update(e.points.map((e=>new P(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}=pot.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 P(e,t,0);return this.points.forEach((e=>e.add(i))),this.update(this.points),this}rotate(){return this}scale(){return this}},ma=(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))(ma||{}),N5=class extends ri{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 P).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=vn.rgba2Color(this.lineColor);let[n,r]=t,a=(new fe).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 fe(i.x+l,i.y+h),p=new fe(i.x+c,i.y+u);e.save(),e.fillStyle=vn.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 Ut.isPointOnLineSegments(e,this.points,this.tolerance)}getClassType(){return"ArrowMarkup"}};_n._registerDrawableClass(N5);var mot=new fe,The=new P,B5=class extends ri{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=mot.subVectors(n,i).length(),e.save(),e.lineWidth=this.lineWidth,e.strokeStyle=vn.rgba2Color(this.lineColor),e.fillStyle=vn.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=The.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=The.subVectors(t,i).length();return Math.abs(e.distanceTo(t)-n)<=2*this.tolerance}getClassType(){return"CircleMarkup"}};_n._registerDrawableClass(B5);var whe=new bt,ic=class extends ri{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=vn.rgba2Color(this.lineColor),e.fillStyle=vn.rgba2Color(this.fillColor),e.beginPath();for(let s=0;sthis.transToScreenCoord(e,t))),r=(new fe).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=vn.rgba2Color(this.lineColor),e.fillStyle=vn.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 P).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"}};_n._registerDrawableClass(V5);var ub=class extends ri{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>ub.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>ub.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 P(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=vn.rgba2Color(this.lineColor),e.fillStyle=vn.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 fe(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 ${vn.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=`${ub.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=vn.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")}},cl=ub;cl.DEFAULT_INPUT_WIDTH=50,_n._registerDrawableClass(cl);var She=new fe,Mhe=new fe(1,0),Rhe=new fe(0,-1),z5=class extends cl{constructor(e,t,i){super(e,t,i),this.type="LeaderLineMarkup",this.text="LeaderLine",this.fontSize=12,this.textBounds=new bt,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 P).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 fe(i.x+l,i.y+h),p=new fe(i.x+c,i.y+u);e.save(),e.fillStyle=vn.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=vn.rgba2Color(this.lineColor);let[n,r]=t,a=(new fe).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 fe).subVectors(r,n).normalize(),s=a.cross(Rhe)<0,o=a.cross(Mhe)<0,l=i.split("\n"),h=this.fontSize/this.tolerance,c=0;e.save(),e.lineWidth=this.lineWidth,e.strokeStyle=vn.rgba2Color(this.lineColor),e.fillStyle=vn.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 fe(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 Ut.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=>$t.worldPosition2ScreenPoint(t,e.camera,e.viewerCanvas))),a=(new fe).subVectors(r,n).normalize(),s=a.cross(Rhe)<0,o=a.cross(Mhe)<0,l=this.fontSize/this.tolerance,h=this.padding/this.tolerance,c=h+l/2,u=cl.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>cl.DEFAULT_INPUT_WIDTH){let e=this.points[1],t=$t.worldPosition2ScreenPoint(this.points[0],this.manager.camera,this.manager.viewerCanvas),n=$t.worldPosition2ScreenPoint(e,this.manager.camera,this.manager.viewerCanvas).clone().sub(t).normalize().cross(new fe(0,-1))<0,r=$t.worldPosition2ScreenPoint(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`}}};_n._registerDrawableClass(z5);var G5=class extends ri{constructor(e,t){super(e),this.type="PolylineMarkup",this.update(t)}draw(e,t){e.save(),e.lineWidth=this.lineWidth,e.strokeStyle=vn.rgba2Color(this.lineColor),e.fillStyle=vn.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 Ut.isPointOnLineSegments(e,[t,n,i,r],.1)}getClassType(){return"XMarkup"}};_n._registerDrawableClass(j5);var Ahe=new bt,W5=new P,X5=new fe,got=new fe(1,0),vot=new fe(0,-1),Y5=class extends cl{constructor(e,t,i=""){super(e,t,i),this.type="CloudRectWithTextMarkup",this.textPosition=new P,this.textBounds=new bt,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=vn.rgba2Color(this.lineColor),e.fillStyle=vn.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=Y5.LEADER_LINE_WIDTH,e.strokeStyle=vn.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=X5.subVectors(r,n).normalize(),s=a.cross(got)<0,o=a.cross(vot)<0,l=i.split("\n"),h=this.fontSize/this.tolerance,c=0;e.save(),e.lineWidth=this.lineWidth,e.strokeStyle=vn.rgba2Color(this.lineColor),e.fillStyle=vn.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 fe(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 P),this.textPosition.set(Math.max(t.x,i.x),Math.max(t.y,i.y),0),this}getCloudPoints(){return[new P(this.x,this.y,0),new P(this.x+this.width,this.y,0),new P(this.x+this.width,this.y-this.height,0),new P(this.x,this.y-this.height,0)]}getBounds(){return Ahe.setFromPoints([...this.points,...this.vertexes||[]]),Ahe.union(this.textBounds)}getVertexes(){let e=this.getBounds(),t=e.min,i=e.getSize(W5);return[new P(t.x,t.y,0),new P(t.x+i.x,t.y,0),new P(t.x+i.x,t.y+i.y,0),new P(t.x,t.y+i.y,0)]}isLeaderTextSelected(e){return this.textBounds.containsPoint(e)}translateLeaderText(e,t){let i=new P(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 fe(0,-1))<0,r=this.textInput.value,a=(null==(i=this.manager.overlayRender)?void 0:i.measureTextLength(r,this.fontSize/this.tolerance+"px Arial"))||cl.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($t.screenPoint2worldPosition(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>cl.DEFAULT_INPUT_WIDTH){let e=$t.worldPosition2ScreenPoint(this.points[0],this.manager.camera,this.manager.viewerCanvas),t=$t.worldPosition2ScreenPoint(this.textPosition,this.manager.camera,this.manager.viewerCanvas).clone().sub(e).normalize().cross(new fe(0,-1))<0,n=$t.worldPosition2ScreenPoint(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`}}},$p=Y5;$p.LEADER_LINE_WIDTH=1,_n._registerDrawableClass($p);var Nn={LEFT:1,RIGHT:2,MIDDLE:4},at=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 Wd(e){return e.isPerspectiveCamera}function au(e){return e.isOrthographicCamera}var yot=(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))(yot||{}),xot=(e=>(e.LEFT="ArrowLeft",e.UP="ArrowUp",e.RIGHT="ArrowRight",e.BOTTOM="ArrowDown",e))(xot||{});function rv(e){return{type:e}}var ou={movable:!1,startDistBetweenFingers:0,scale:1},iv=2*Math.PI,Che=1e-6,XR=class extends bo{constructor(e,t,i=!1){super(),this.enabled=!0,this.target=new P,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 P,this.pointerPositions={},this.rotateStart=new fe,this.rotateEnd=new fe,this.rotateDelta=new fe,this.dollyStart=new fe,this.dollyEnd=new fe,this.dollyDelta=new fe,this.panStart=new fe,this.panEnd=new fe,this.panDelta=new fe,this.pointers=[],this.spherical=new Dd,this.sphericalDelta=new Dd,this.update=function(e){let t=new P,i=new P,n=new Xn;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+=iv/60/60*e.autoRotateSpeed:e.sphericalDelta.theta-=iv/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+=iv:o>Math.PI&&(o-=iv),l<-Math.PI?l+=iv:l>Math.PI&&(l-=iv),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)>Che||8*(1-n.dot(e.object.quaternion))>Che)&&(e.dispatchEvent(rv("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(rv("end")),e.state=-1}}(this),this.onPointerCancel=function(e){return t=>{e.removePointer(t),e.handlerTouchEnd(t)}}(this),this.onMouseWheel=function(e){return t=>{!1===e.enabled||!1===e.enableZoom||-1!==e.state||(t.preventDefault(),t.stopPropagation(),e.dispatchEvent(rv("start")),e.handleMouseWheel(t),e.dispatchEvent(rv("end")))}}(this),this.pan=function(e){let t=new P;return function(i,n){let r=e.domElement;if(e.object instanceof jn){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 P;return function(i,n){t.setFromMatrixColumn(n,0),t.multiplyScalar(-i),e.panOffset.add(t)}}(this),this.panUp=function(e){let t=new P;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 Xn).setFromUnitVectors(this.object.up,new P(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];ou.startDistBetweenFingers=this.getDist([t.pageX,t.pageY],[i.pageX,i.pageY]),ou.movable=!0,ou.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 jn?this.scale/=e:(console.warn("WARNING: VRControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}dollyIn(e){this.object instanceof jn?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 jn))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(!ou.movable||this.pointers.length<2)return;let t=this.getSecondPointerPosition(e),i=[e.pageX,e.pageY],n=[t.x,t.y],r=ou.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-ou.scale;if(Math.abs(o)<.05)return;let l=0;l=o>0?10*-o:10*(ou.scale/s-1),this.updateFov(l),ou.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}},Mo=class extends zi{constructor(e){super(),this.enable=!0,this.mouseDownPositionX=0,this.mouseDownPositionY=0,this.lastLeftPointerUpTime=0,this.pointers=[],this.handleClick=e=>{if(!this.enable)return;let t=this.getBaseEvent(e);this.dispatchEvent("click",t)},this.handlePointerDown=e=>{if(!this.enable)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.enable)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.enable)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.enable&&(this.stop(e),this.dispatchEvent("pointercancel",this.getBaseEvent(e)))},this.handleMouseWheel=e=>{this.enable&&(this.stop(e),this.dispatchEvent("wheel",this.getBaseEvent(e)))},this.handleContextMenu=e=>{if(this.enable)return this.stop(e),this.dispatchEvent("contextmenu",this.getBaseEvent(e)),!1},this.handlePointerEnter=e=>{this.enable&&(this.stop(e),this.dispatchEvent("pointerenter",this.getBaseEvent(e)))},this.handlePointerLeave=e=>{this.enable&&(this.stop(e),this.dispatchEvent("pointerleave",this.getBaseEvent(e)))},this.handleResize=e=>{this.enable&&(this.stop(e),this.dispatchEvent("resize",this.getBaseEvent(e)))},this.handleKeydown=e=>{this.enable&&this.dispatchEvent("keydown",this.getBaseEvent(e))},this.handleKeyup=e=>{this.enable&&this.dispatchEvent("keyup",this.getBaseEvent(e))},this.style={},this.element=e,this.bindEvents()}setEnable(e){this.enable=e}setCursor(e){this.element.style&&(this.element.style.cursor=e||"default")}bindEvents(){this.element.style.touchAction="none",this.element.style.userSelect="none",this.element.style.webkitUserSelect="none",this.element.addEventListener("click",this.handleClick),this.element.addEventListener("pointerdown",this.handlePointerDown),this.element.addEventListener("pointermove",this.handlePointerMove),this.element.addEventListener("pointerup",this.handlePointerUp),this.element.addEventListener("pointercancel",this.handlePointerCancel),this.element.addEventListener("pointerenter",this.handlePointerEnter),this.element.addEventListener("pointerleave",this.handlePointerLeave),this.element.addEventListener("contextmenu",this.handleContextMenu),this.element.addEventListener("wheel",this.handleMouseWheel),window.addEventListener("resize",this.handleResize),window.addEventListener("keydown",this.handleKeydown),window.addEventListener("keyup",this.handleKeyup)}unBindEvents(){this.element.removeEventListener("pointerdown",this.handlePointerDown),this.element.removeEventListener("pointermove",this.handlePointerMove),this.element.removeEventListener("pointerup",this.handlePointerUp),this.element.removeEventListener("pointerenter",this.handlePointerEnter),this.element.removeEventListener("pointerleave",this.handlePointerLeave),this.element.removeEventListener("contextmenu",this.handleContextMenu),this.element.removeEventListener("wheel",this.handleMouseWheel),window.removeEventListener("resize",this.handleResize),window.removeEventListener("keydown",this.handleKeydown),window.removeEventListener("keyup",this.handleKeyup),this.element.style.touchAction="",this.element.style.userSelect="",this.element.style.webkitUserSelect=""}getBaseEvent(e){let t={x:0,y:0,pageX:0,pageY:0,clientX:0,clientY:0,deltaX:0,deltaY:0,movementX:0,movementY:0,deltaMode:0,pointerId:0,timestamp:0,buttons:0,pointerType:"mouse",altKey:!1,ctrlKey:!1,shiftKey:!1,metaKey:!1,originalEvent:e};if(t.timestamp=e.timeStamp,YR(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,YR(e,"pointerId")){t.pointerType=e.pointerType,t.buttons=e.buttons,t.pageX=e.pageX,t.pageY=e.pageY,t.pointerId=e.pointerId;let i=$t.getScreenPointByEvent(e,this.element);t.x=i.x,t.y=i.y,t.movementX=e.movementX,t.movementY=e.movementY}else YR(e,"deltaX")&&(t.deltaMode=e.deltaMode,t.deltaX=e.deltaX,t.deltaY=e.deltaY);else YR(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 Z5(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,M=(i.z+o*m)*a;i.x=(i.x-o*_)*h,i.y=(i.y-o*w)*h,i.z=(i.z-o*M)*h,s.x=c+(p+_)*h,s.y=u+(f+w)*h,s.z=d+(m+M)*h;let S=g-e.x,E=v-e.y,T=y-e.z;return S*(s.x-g)+E*(s.y-v)+T*(s.z-y)>0&&(s.x=g,s.y=v,s.z=y,i.x=(s.x-g)/a,i.y=(s.y-v)/a,i.z=(s.z-y)/a),s}function $R(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 KR(e,t){return!!au(e)&&(console.warn(`${t} is not supported in OrthographicCamera`),!0)}var ZR=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=at.NONE,this._viewport=null,this._dollyControlAmount=0,this._hasRested=!0,this._boundaryEnclosesCamera=!1,this._needsUpdate=!0,this._updatedLastTime=!1,this._elementRect=dn.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 Bn.Vector3,this._focalOffsetVelocity=new Bn.Vector3,this._zoomVelocity={value:0},this._truckInternal=(e,t,i)=>{if(Wd(this._camera)){let n=zn.copy(this._camera.position).sub(this._target),r=this._camera.getEffectiveFOV()*sv,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(au(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=Kp*this.azimuthRotateSpeed*e/this._elementRect.height,n=Kp*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===Bn&&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 Bn.Quaternion).setFromUnitVectors(this._camera.up,QR),this._yAxisUpSpaceInverse=this._yAxisUpSpace.clone().invert(),this._state=at.NONE,this._target=new Bn.Vector3,this._targetEnd=this._target.clone(),this._focalOffset=new Bn.Vector3,this._focalOffsetEnd=this._focalOffset.clone(),this._spherical=(new Bn.Spherical).setFromVector3(zn.copy(this._camera.position).applyQuaternion(this._yAxisUpSpace)),this._sphericalEnd=this._spherical.clone(),this._zoom=this._camera.zoom,this._zoomEnd=this._zoom,this._nearPlaneCorners=[new Bn.Vector3,new Bn.Vector3,new Bn.Vector3,new Bn.Vector3],this._updateNearPlaneCorners(),this._boundary=new Bn.Box3(new Bn.Vector3(-1/0,-1/0,-1/0),new Bn.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 Bn.Vector2,this.mouseButtons={left:at.ROTATE,middle:at.DOLLY,right:at.TRUCK,wheel:Wd(this._camera)?at.DOLLY:au(this._camera)?at.ZOOM:at.NONE},this.touches={one:at.TOUCH_ROTATE,two:Wd(this._camera)?at.TOUCH_DOLLY_TRUCK:au(this._camera)?at.TOUCH_ZOOM_TRUCK:at.NONE,three:at.TOUCH_TRUCK};let i=new Bn.Vector2,n=new Bn.Vector2,r=new Bn.Vector2,a=e=>{if(!this._enabled||!this._domElement)return;let t="mouse"!==e.pointerType?null:(e.buttons&Nn.LEFT)===Nn.LEFT?Nn.LEFT:(e.buttons&Nn.MIDDLE)===Nn.MIDDLE?Nn.MIDDLE:(e.buttons&Nn.RIGHT)===Nn.RIGHT?Nn.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&Nn.LEFT)===Nn.LEFT?Nn.LEFT:(e.buttons&Nn.MIDDLE)===Nn.MIDDLE?Nn.MIDDLE:(e.buttons&Nn.RIGHT)===Nn.RIGHT?Nn.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&Nn.LEFT)===Nn.LEFT?Nn.LEFT:(e.buttons&Nn.MIDDLE)===Nn.LEFT?Nn.MIDDLE:(e.buttons&Nn.RIGHT)===Nn.LEFT?Nn.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&Nn.LEFT)===Nn.LEFT&&(this._state=this._state|this.mouseButtons.left),(e.buttons&Nn.MIDDLE)===Nn.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),(e.buttons&Nn.RIGHT)===Nn.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&Nn.LEFT)===Nn.LEFT&&(this._state=this._state|this.mouseButtons.left),(e.buttons&Nn.MIDDLE)===Nn.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),(e.buttons&Nn.RIGHT)===Nn.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=at.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=at.NONE;g()},c=()=>{let e=this._findPointerById(0);e&&this._activePointers.splice(this._activePointers.indexOf(e),1),this._state=at.NONE,g()},u=-1,d=e=>{if(!this._enabled||this.mouseButtons.wheel===at.NONE)return;if(this.dollyToCursor||this.mouseButtons.wheel===at.ROTATE||this.mouseButtons.wheel===at.TRUCK){let e=performance.now();u-e<1e3&&this._getClientRect(this._elementRect),u=e}let t=bot?-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 at.ROTATE:this._rotateInternal(e.deltaX,e.deltaY),this._isUserControllingRotate=!0;break;case at.TRUCK:this._truckInternal(e.deltaX,e.deltaY,!1),this._isUserControllingTruck=!0;break;case at.OFFSET:this._truckInternal(e.deltaX,e.deltaY,!0),this._isUserControllingOffset=!0;break;case at.DOLLY:this._dollyInternal(-i,n,r),this._isUserControllingDolly=!0;break;case at.ZOOM:this._zoomInternal(-i,n,r),this._isUserControllingZoom=!0}this.dispatchEvent({type:"control"})},p=e=>{if(this._domElement&&this._enabled&&this.mouseButtons.right===Xd.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($R(this._activePointers,ja),this._getClientRect(this._elementRect),i.copy(ja),n.copy(ja),this._activePointers.length>=2){let e=ja.x-this._activePointers[1].clientX,t=ja.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&Nn.LEFT)===Nn.LEFT&&(this._state=this._state|this.mouseButtons.left),(e.buttons&Nn.MIDDLE)===Nn.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),(e.buttons&Nn.RIGHT)===Nn.RIGHT&&(this._state=this._state|this.mouseButtons.right);((this._state&at.ROTATE)===at.ROTATE||(this._state&at.TOUCH_ROTATE)===at.TOUCH_ROTATE||(this._state&at.TOUCH_DOLLY_ROTATE)===at.TOUCH_DOLLY_ROTATE||(this._state&at.TOUCH_ZOOM_ROTATE)===at.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&at.TRUCK)===at.TRUCK||(this._state&at.TOUCH_TRUCK)===at.TOUCH_TRUCK||(this._state&at.TOUCH_DOLLY_TRUCK)===at.TOUCH_DOLLY_TRUCK||(this._state&at.TOUCH_ZOOM_TRUCK)===at.TOUCH_ZOOM_TRUCK)&&(this._targetEnd.copy(this._target),this._targetVelocity.set(0,0,0)),((this._state&at.DOLLY)===at.DOLLY||(this._state&at.TOUCH_DOLLY)===at.TOUCH_DOLLY||(this._state&at.TOUCH_DOLLY_TRUCK)===at.TOUCH_DOLLY_TRUCK||(this._state&at.TOUCH_DOLLY_OFFSET)===at.TOUCH_DOLLY_OFFSET||(this._state&at.TOUCH_DOLLY_ROTATE)===at.TOUCH_DOLLY_ROTATE)&&(this._sphericalEnd.radius=this._spherical.radius,this._radiusVelocity.value=0),((this._state&at.ZOOM)===at.ZOOM||(this._state&at.TOUCH_ZOOM)===at.TOUCH_ZOOM||(this._state&at.TOUCH_ZOOM_TRUCK)===at.TOUCH_ZOOM_TRUCK||(this._state&at.TOUCH_ZOOM_OFFSET)===at.TOUCH_ZOOM_OFFSET||(this._state&at.TOUCH_ZOOM_ROTATE)===at.TOUCH_ZOOM_ROTATE)&&(this._zoomEnd=this._zoom,this._zoomVelocity.value=0),((this._state&at.OFFSET)===at.OFFSET||(this._state&at.TOUCH_OFFSET)===at.TOUCH_OFFSET||(this._state&at.TOUCH_DOLLY_OFFSET)===at.TOUCH_DOLLY_OFFSET||(this._state&at.TOUCH_ZOOM_OFFSET)===at.TOUCH_ZOOM_OFFSET)&&(this._focalOffsetEnd.copy(this._focalOffset),this._focalOffsetVelocity.set(0,0,0)),this.dispatchEvent({type:"controlstart"})}},m=()=>{if(!this._enabled)return;$R(this._activePointers,ja);let e=!!dn.isBrowser&&this._domElement&&document.pointerLockElement===this._domElement,t=e?-this._activePointers[0].deltaX:n.x-ja.x,a=e?-this._activePointers[0].deltaY:n.y-ja.y;if(n.copy(ja),((this._state&at.ROTATE)===at.ROTATE||(this._state&at.TOUCH_ROTATE)===at.TOUCH_ROTATE||(this._state&at.TOUCH_DOLLY_ROTATE)===at.TOUCH_DOLLY_ROTATE||(this._state&at.TOUCH_ZOOM_ROTATE)===at.TOUCH_ZOOM_ROTATE)&&(this._rotateInternal(t,a),this._isUserControllingRotate=!0),(this._state&at.DOLLY)===at.DOLLY||(this._state&at.ZOOM)===at.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&at.DOLLY)===at.DOLLY?(this._dollyInternal(a*JR,e,t),this._isUserControllingDolly=!0):(this._zoomInternal(a*JR,e,t),this._isUserControllingZoom=!0)}if((this._state&at.TOUCH_DOLLY)===at.TOUCH_DOLLY||(this._state&at.TOUCH_ZOOM)===at.TOUCH_ZOOM||(this._state&at.TOUCH_DOLLY_TRUCK)===at.TOUCH_DOLLY_TRUCK||(this._state&at.TOUCH_ZOOM_TRUCK)===at.TOUCH_ZOOM_TRUCK||(this._state&at.TOUCH_DOLLY_OFFSET)===at.TOUCH_DOLLY_OFFSET||(this._state&at.TOUCH_ZOOM_OFFSET)===at.TOUCH_ZOOM_OFFSET||(this._state&at.TOUCH_DOLLY_ROTATE)===at.TOUCH_DOLLY_ROTATE||(this._state&at.TOUCH_ZOOM_ROTATE)===at.TOUCH_ZOOM_ROTATE){let e=ja.x-this._activePointers[1].clientX,t=ja.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&at.TOUCH_DOLLY)===at.TOUCH_DOLLY||(this._state&at.TOUCH_DOLLY_ROTATE)===at.TOUCH_DOLLY_ROTATE||(this._state&at.TOUCH_DOLLY_TRUCK)===at.TOUCH_DOLLY_TRUCK||(this._state&at.TOUCH_DOLLY_OFFSET)===at.TOUCH_DOLLY_OFFSET?(this._dollyInternal(a*JR,s,o),this._isUserControllingDolly=!0):(this._zoomInternal(a*JR,s,o),this._isUserControllingZoom=!0)}((this._state&at.TRUCK)===at.TRUCK||(this._state&at.TOUCH_TRUCK)===at.TOUCH_TRUCK||(this._state&at.TOUCH_DOLLY_TRUCK)===at.TOUCH_DOLLY_TRUCK||(this._state&at.TOUCH_ZOOM_TRUCK)===at.TOUCH_ZOOM_TRUCK)&&(this._truckInternal(t,a,!1),this._isUserControllingTruck=!0),((this._state&at.OFFSET)===at.OFFSET||(this._state&at.TOUCH_OFFSET)===at.TOUCH_OFFSET||(this._state&at.TOUCH_DOLLY_OFFSET)===at.TOUCH_DOLLY_OFFSET||(this._state&at.TOUCH_ZOOM_OFFSET)===at.TOUCH_ZOOM_OFFSET)&&(this._truckInternal(t,a,!0),this._isUserControllingOffset=!0),this.dispatchEvent({type:"control"})},g=()=>{$R(this._activePointers,ja),n.copy(ja),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),Eot&&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!==at.NONE&&(this._state=at.NONE,this._activePointers.length=0,g())},t&&this.connect(t),this.update(0)}static install(e){Bn=e.THREE,Phe=Object.freeze(new Bn.Vector3(0,0,0)),QR=Object.freeze(new Bn.Vector3(0,1,0)),J5=Object.freeze(new Bn.Vector3(0,0,1)),ja=new Bn.Vector2,zn=new Bn.Vector3,Qr=new Bn.Vector3,lv=new Bn.Vector3,lu=new Bn.Vector3,cu=new Bn.Vector3,Jp=new Bn.Vector3,Ihe=new Bn.Vector3,Dhe=new Bn.Vector3,sc=new Bn.Spherical,db=new Bn.Spherical,cv=new Bn.Box3,Lhe=new Bn.Box3,Q5=new Bn.Sphere,Ohe=new Bn.Quaternion,eH=new Bn.Quaternion,tH=new Bn.Matrix4,eA=new Bn.Raycaster}static get ACTION(){return at}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=Zp(e,this.minAzimuthAngle,this.maxAzimuthAngle),r=Zp(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||vi(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&vi(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=Zp(e,this.minDistance,this.maxDistance);if(this.colliderMeshes.length>=1){let e=this._collisionTest(),t=vi(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||vi(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=Zp(e,this.minZoom,this.maxZoom),this._needsUpdate=!0,t||(this._zoom=this._zoomEnd);let i=!t||vi(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(),lu.setFromMatrixColumn(this._camera.matrix,0),cu.setFromMatrixColumn(this._camera.matrix,1),lu.multiplyScalar(e),cu.multiplyScalar(-t);let n=zn.copy(lu).add(cu),r=Qr.copy(this._targetEnd).add(n);return this.moveTo(r.x,r.y,r.z,i)}forward(e,t=!1){zn.setFromMatrixColumn(this._camera.matrix,0),zn.crossVectors(this._camera.up,zn),zn.multiplyScalar(e);let i=Qr.copy(this._targetEnd).add(zn);return this.moveTo(i.x,i.y,i.z,t)}elevate(e,t=!1){return zn.copy(this._camera.up).multiplyScalar(e),this.moveTo(this._targetEnd.x+zn.x,this._targetEnd.y+zn.y,this._targetEnd.z+zn.z,t)}moveTo(e,t,i,n=!1){this._isUserControllingTruck=!1;let r=zn.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||vi(this._target.x,this._targetEnd.x,this.restThreshold)&&vi(this._target.y,this._targetEnd.y,this.restThreshold)&&vi(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(a)}lookInDirectionOf(e,t,i,n=!1){let r=zn.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?cv.copy(e):cv.setFromObject(e);l.isEmpty()&&(console.warn("camera-controls: fitTo() cannot be used with an empty box. Aborting"),Promise.resolve());let h=K5(this._sphericalEnd.theta,$5),c=K5(this._sphericalEnd.phi,$5);o.push(this.rotateTo(h,c,t));let u=zn.setFromSpherical(this._sphericalEnd).normalize(),d=Ohe.setFromUnitVectors(u,J5),p=vi(Math.abs(u.y),1);p&&d.multiply(eH.setFromAxisAngle(QR,h)),d.multiply(this._yAxisUpSpaceInverse);let f=Lhe.makeEmpty();Qr.copy(l.min).applyQuaternion(d),f.expandByPoint(Qr),Qr.copy(l.min).setX(l.max.x).applyQuaternion(d),f.expandByPoint(Qr),Qr.copy(l.min).setY(l.max.y).applyQuaternion(d),f.expandByPoint(Qr),Qr.copy(l.max).setZ(l.min.z).applyQuaternion(d),f.expandByPoint(Qr),Qr.copy(l.min).setZ(l.max.z).applyQuaternion(d),f.expandByPoint(Qr),Qr.copy(l.max).setY(l.min.y).applyQuaternion(d),f.expandByPoint(Qr),Qr.copy(l.max).setX(l.min.x).applyQuaternion(d),f.expandByPoint(Qr),Qr.copy(l.max).applyQuaternion(d),f.expandByPoint(Qr),f.min.x-=n,f.min.y-=a,f.max.x+=r,f.max.y+=s,d.setFromUnitVectors(J5,u),p&&d.premultiply(eH.invert()),d.premultiply(this._yAxisUpSpace);let m=f.getSize(zn),g=f.getCenter(Qr).applyQuaternion(d);if(Wd(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(au(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 Bn.Sphere?Q5.copy(e):Xd.createBoundingSphere(e,Q5);if(i.push(this.moveTo(n.center.x,n.center.y,n.center.z,t)),Wd(this._camera)){let e=this.getDistanceToFitSphere(n.radius);i.push(this.dollyTo(e,t))}else if(au(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=Qr.set(n,r,a),l=zn.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||vi(this._target.x,this._targetEnd.x,this.restThreshold)&&vi(this._target.y,this._targetEnd.y,this.restThreshold)&&vi(this._target.z,this._targetEnd.z,this.restThreshold)&&vi(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&vi(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&vi(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=zn.set(n,r,a),m=Qr.set(e,t,i);sc.setFromVector3(m.sub(f).applyQuaternion(this._yAxisUpSpace));let g=lv.set(h,c,u),v=Qr.set(s,o,l);db.setFromVector3(v.sub(g).applyQuaternion(this._yAxisUpSpace)),this._targetEnd.copy(f.lerp(g,d));let y=db.theta-sc.theta,x=db.phi-sc.phi,b=db.radius-sc.radius;this._sphericalEnd.set(sc.radius+b*d,sc.phi+x*d,sc.theta+y*d),this.normalizeRotations(),this._needsUpdate=!0,p||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));let _=!p||vi(this._target.x,this._targetEnd.x,this.restThreshold)&&vi(this._target.y,this._targetEnd.y,this.restThreshold)&&vi(this._target.z,this._targetEnd.z,this.restThreshold)&&vi(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&vi(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&vi(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(zn),a=this.setLookAt(r.x,r.y,r.z,e,t,i,n);return this._sphericalEnd.phi=Zp(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||vi(this._focalOffset.x,this._focalOffsetEnd.x,this.restThreshold)&&vi(this._focalOffset.y,this._focalOffsetEnd.y,this.restThreshold)&&vi(this._focalOffset.z,this._focalOffsetEnd.z,this.restThreshold);return this._createOnRestPromise(r)}setOrbitPoint(e,t,i){this._camera.updateMatrixWorld(),lu.setFromMatrixColumn(this._camera.matrixWorldInverse,0),cu.setFromMatrixColumn(this._camera.matrixWorldInverse,1),Jp.setFromMatrixColumn(this._camera.matrixWorldInverse,2);let n=zn.set(e,t,i),r=n.distanceTo(this._camera.position),a=n.sub(this._camera.position);lu.multiplyScalar(a.x),cu.multiplyScalar(a.y),Jp.multiplyScalar(a.z),zn.copy(lu).add(cu).add(Jp),zn.z=zn.z+r,this.dollyTo(r,!1),this.setFocalOffset(-zn.x,zn.y,-zn.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 Bn.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(KR(this._camera,"getDistanceToFitBox"))return this._spherical.radius;let r=e/t,a=this._camera.getEffectiveFOV()*sv,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=Qr.copy(t).add(e),a=this._boundary.clampPoint(r,lv).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(Qr.copy(t).multiplyScalar(n)).add(a.multiplyScalar(1-i))}}_updateNearPlaneCorners(){if(Wd(this._camera)){let e=this._camera,t=e.near,i=e.getEffectiveFOV()*sv,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(au(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)||KR(this._camera,"_collisionTest"))return e;let t=zn.setFromSpherical(this._spherical).divideScalar(this._spherical.radius);tH.lookAt(Phe,t,this._camera.up);for(let i=0;i<4;i++){let n=Qr.copy(this._nearPlaneCorners[i]);n.applyMatrix4(tH);let r=lv.addVectors(this._target,n);eA.set(r,t),eA.far=this._spherical.radius+1;let a=eA.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 Bn.Sphere){let i=t,n=i.center;cv.makeEmpty(),e.traverseVisible((e=>{e.isMesh&&cv.expandByObject(e)})),cv.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()}},ul=class{constructor(e){this.name=e}},tA=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}},fb=class extends ul{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)}},nA=class extends ul{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)}},Qp=class extends ul{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)}},pb=class extends ul{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)}},uv=class extends ul{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)}},khe=new P,mb=class extends zi{constructor(e,t){var i;super(),this.drawableList=new So("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=$t.getScreenPointByEvent(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(this.mouseDownPositionX=i.x,this.mouseDownPositionY=i.y,this.mousedownPoint=new fe(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 $p&&(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(khe.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 $p&&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 P(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];khe.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 Qp(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,dn.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=at.NONE,this.tempTouch=e.touches.one,e.touches.one=at.NONE,this.tempArrowKeys=e.keys,e.keys={},this.render()}deactivate(){this.activated=!1,dn.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=$t.screenPoint2NdcPoint(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}pickThreejsPositionByMouse(e){return this.pickPositionByScreenPoint(new fe(e.x,e.y))}confirmToRemove(e){var t;this.selectedShape&&e&&(this.removeMarkup(this.selectedShape),null==(t=this.viewer.undoRedoManager)||t.addCommand(new Qp(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 nA(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 fb(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 _n.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 fb(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]),_n.createDrawable({id:ft.guid(),lineWidth:this.lineWidth,lineColor:this.lineColor,fillColor:this.fillColor,type:this.type,points:i})}drawLine(e){return _n.createDrawable({id:ft.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 _n.createDrawable({id:ft.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()}},Fhe=new P,em=class extends mi{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))(Nhe||{}),tm=["INSERT","DIMENSION"],Akt=Xi(zhe(),1),rA=[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],fv=class{constructor(){this.pointer=0,this.eof=!1}},iH=Xi(Ghe(),1),Yd=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 jhe(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?jhe(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 J.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>qhe)return J.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 jhe(e){return Array.prototype.map.call(e,(e=>("00"+e.toString(16)).slice(-2))).join("")}var pv=class extends fv{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=Tot(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 Tot(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?wot(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):(J.info("WARNING: Group code does not have a defined type: %j",{code:e,value:t}),t)}function wot(e){if("0"===e)return!1;if("1"===e)return!0;throw TypeError("String '"+e+"' cannot be cast to Boolean type")}var Yhe=Xi(ac(),1),Sot="OriginalHandle",Mot="OriginalType",Rot="Outlines",Whe=["PROXY","REGION","INSERT","HATCH"];function nm(e){return rA[e]}function St(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 Xhe(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 xn(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&&J.warn("[DxfParser] a negative value of colorIndex indicates that the layer is turned off"),e.color=nm(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(Sot)){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(Rot)&&(e.extendedData||(e.extendedData={}),e.extendedData.outlines=[]),t.value&&t.value.includes(Mot)){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 hl(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 xb=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=Aot(e,t),t=e.lastReadGroup;break;case 101:for(;0!=t.code;)t=e.next();break;default:xn(i,t),t=e.next()}return i}};function Aot(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,Yhe.isEmpty)(a)||i.push(a),n=!1,r=!1}return i}var bb=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=St(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:xn(i,t),t=e.next()}return i}},Eb=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=St(e),t=e.lastReadGroup;break;case 11:i.endPoint=St(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:xn(i,t),t=e.next()}return i}},_b=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=St(e),t=e.lastReadGroup;break;case 11:i.endPoint=St(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:xn(i,t),t=e.next()}return i}},Tb=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=St(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 Lot(e,t){let i=[],n=t.next();for(;i.length0&&(i.colorIndex=t.value,i.color=nm(Math.abs(t.value))))}t=e.next();break;default:xn(i,t),t=e.next()}return i}};function Oot(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 Pb=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(St(e)),t=e.lastReadGroup;break;case 11:i.vertices.push(St(e)),t=e.lastReadGroup;break;case 210:i.extrusionDirection=St(e),t=e.lastReadGroup;break;case 100:t=e.next();break;case 101:for(;0!=t.code;)t=e.next();break;default:xn(i,t),t=e.next()}return i}},Ib=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(...kot(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:xn(i,t),t=e.next()}return i}};function kot(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 Db=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=St(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=St(e),t=e.lastReadGroup;break;case 12:i.contextData.textLocation=St(e),t=e.lastReadGroup;break;case 13:i.contextData.textDirection=St(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=St(e),t=e.lastReadGroup;break;case 15:i.contextData.blockContentPosition=St(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=Xhe(e,47),t=e.lastReadGroup;break;case 110:i.contextData.planeOriginPoint=St(e),t=e.lastReadGroup;break;case 111:i.contextData.planeXAxisDirection=St(e),t=e.lastReadGroup;break;case 112:i.contextData.planeYAxisDirection=St(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=St(e),t=e.lastReadGroup;break;case 11:n.doglegVector=St(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(St(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=St(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:xn(i,t),t=e.next()}}(),i}},Lb=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=St(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=St(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:xn(i,t),t=e.next()}return i}},Ob=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:xn(i,t),t=e.next()}return i}},kb=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=St(e),t=e.lastReadGroup;break;case 39:i.thickness=t.value,t=e.next();break;case 210:i.extrusionDirection=St(e),t=e.lastReadGroup;break;case 100:t=e.next();break;case 101:for(;0!=t.code;)t=e.next();break;default:xn(i,t),t=e.next()}return i}},Fb=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:xn(i,t),t=e.next()}return i}},Nb=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=St(e),t=e.lastReadGroup;break;case 101:for(;0!=t.code;)t=e.next();break;default:xn(i,t),t=e.next()}return i.vertices=Fot(e,t),i}};function Fot(e,t){let i=new Fb,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){Not(e,t);break}return n}function Not(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 xn(i,t),t=e.next();return i}var Bb=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(St(e)),t=e.lastReadGroup;break;case 11:i.directionVector=St(e),t=e.lastReadGroup;break;case 100:t=e.next();break;case 101:for(;0!=t.code;)t=e.next();break;default:xn(i,t),t=e.next()}return i}},Hb=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:xn(i,t),t=e.next()}return i}},Ub=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||(xn(i,t),t=e.next());return i}},Vb=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]=St(e),t=e.lastReadGroup;break;case 11:i.points[1]=St(e),t=e.lastReadGroup;break;case 12:i.points[2]=St(e),t=e.lastReadGroup;break;case 13:i.points[3]=St(e),t=e.lastReadGroup;break;case 210:i.extrusionDirection=St(e),t=e.lastReadGroup;break;case 101:for(;0!=t.code;)t=e.next();break;default:xn(i,t),t=e.next()}return i}},zb=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(St(e)),t=e.lastReadGroup;break;case 11:i.fitPoints||(i.fitPoints=[]),i.fitPoints.push(St(e)),t=e.lastReadGroup;break;case 12:i.startTangent=St(e),t=e.lastReadGroup;break;case 13:i.endTangent=St(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=St(e),t=e.lastReadGroup;break;case 101:for(;0!=t.code;)t=e.next();break;default:xn(i,t),t=e.next()}return i}},Gb=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=St(e),t=e.lastReadGroup;break;case 11:i.endPoint=St(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:xn(i,t),t=e.next()}return i}},qb=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=St(e),t=e.lastReadGroup;break;case 12:i.centerPoint_dcs=St(e),t=e.lastReadGroup;break;case 13:i.snapBasePoint_dcs=St(e),t=e.lastReadGroup;break;case 14:i.snapSpacing_dcs=St(e),t=e.lastReadGroup;break;case 15:i.gridSpacing_dcs=St(e),t=e.lastReadGroup;break;case 16:i.viewDirection=St(e),t=e.lastReadGroup;break;case 17:i.viewTarget=St(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=St(e),t=e.lastReadGroup;break;case 111:i.ucsXAxis=St(e),t=e.lastReadGroup;break;case 112:i.ucsYAxis=St(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:xn(i,t),t=e.next()}return i}},jb=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(St(e)),t=e.lastReadGroup;break;case 11:i.directionVector=St(e),t=e.lastReadGroup;break;case 100:t=e.next();break;case 101:for(;0!=t.code;)t=e.next();break;default:xn(i,t),t=e.next()}return i}},iA=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:hl(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}},sA=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=St(e),t=e.next();break;case 11:i.pixelSize=St(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:hl(i,t),t=e.next()}return i}},aA=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=St(e),t=e.lastReadGroup;break;case 11:i.maxLimit=St(e),t=e.lastReadGroup;break;case 12:i.basePoint=St(e),t=e.lastReadGroup;break;case 13:i.origin=St(e),t=e.lastReadGroup;break;case 14:i.minExtent=St(e),t=e.lastReadGroup;break;case 15:i.maxExtent=St(e),t=e.lastReadGroup;break;case 16:i.XAxis=St(e),t=e.lastReadGroup;break;case 17:i.YAxis=St(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:hl(i,t),t=e.next()}return i.blockTableHandle=i.ownerHandle,i}},oA=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:hl(i,t),t=e.next()}return i}},lA=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=St(e),t=e.lastReadGroup;break;case 70:r.numberOfPointsOnClipBoundary=t.value,2===r.numberOfPointsOnClipBoundary?(t=e.next(),i=St(e),t=e.lastReadGroup,n=St(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=Bot(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=$he(e,40),r.matrix=$he(e,40),t=e.lastReadGroup;break;default:hl(r,t),t=e.next()}return r}};function Bot(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(Ao(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&&!Ao(n,0,"ENDSEC");)if(Ao(n,0,"BLOCK")){J.trace("block {");let e=o();J.trace("}"),m(e),e.name?t[e.name]=e:J.error(`[DxfParser] Block with handle '${e.handle}' is missing a name, ignored!`)}else bh(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:bh(n),n=e.next()}if(Ao(n,0,"ENDBLK")){n=e.next();break}}return t}function l(){let t={};for(n=e.next();"EOF"!==n.value&&!Ao(n,0,"ENDSEC");)Ao(n,0,"TABLE")?(n=e.next(),u[n.value]?(J.trace(n.value+" Table {"),t[u[n.value].tableName]=c(n),J.trace("}")):J.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();!Ao(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||bh(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():(bh(n),n=e.next());break;default:bh(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&&J.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(J.trace("Viewport {"),n=e.next();!Ao(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&&(J.trace("}"),t.push(i),J.trace("Viewport {"),i={},n=e.next());break;default:bh(n),n=e.next()}return J.trace("}"),t.push(i),t}},LTYPE:{tableRecordsProperty:"lineTypes",tableName:"lineType",dxfSymbolName:"LTYPE",parseTableRecords:function(){let t={},i={},a=0,s="",o=!1;for(J.trace("LType {"),n=e.next();!Ao(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:J.trace("}"),a>0&&a!==i.pattern.length&&J.warn("[DxfParser] lengths do not match on LTYPE pattern"),t[s]=i,i={},J.trace("LType {"),n=e.next()}return J.trace("}"),t[s]=i,t}},LAYER:{tableRecordsProperty:"layers",tableName:"layer",dxfSymbolName:"LAYER",parseTableRecords:function(){let t,i={},r={};for(J.trace("Layer {"),n=e.next();!Ao(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=zot(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&&(J.trace("}"),t&&(i[t]=r),J.trace("Layer {"),r={},t=void 0,n=e.next());break;default:bh(n),n=e.next()}return J.trace("}"),t&&(i[t]=r),i}},BLOCK_RECORD:{tableRecordsProperty:"blockRecords",tableName:"blockRecord",dxfSymbolName:"BLOCK_RECORD",parseTableRecords:function(){let t,i={},a={};for(J.trace("BlockRecord {"),n=e.next();!Ao(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){J.trace("}"),t&&(i[t]=a);let s=a.layoutHandle;t&&s&&s.length>0&&"0"!==s&&(r._layoutBlocks[s]=a),J.trace("BlockRecord {"),a={},t=void 0,n=e.next()}else bh(n),n=e.next();break;default:bh(n),n=e.next()}J.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(J.trace("Style {"),n=e.next();!Ao(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&&(J.trace("}"),t&&(i[t]=r),J.trace("Style {"),r={},t=void 0,n=e.next())}return J.trace("}"),t&&(i[t]=r),i}},DIMSTYLE:{tableRecordsProperty:"dimStyles",tableName:"dimStyle",dxfSymbolName:"DIMSTYLE",parseTableRecords:function(){let t,i={},r={};for(J.trace("DimStyle {"),n=e.next();!Ao(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&&(J.trace("}"),t&&(i[t]=r),J.trace("DimStyle {"),r={},t=void 0,n=e.next())}return J.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}{J.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=hv)),n=e.lastReadGroup,J.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}{J.trace(n.value+" {");let r=i.parseObject(e,n),a=n.value;n=e.lastReadGroup,J.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&&J.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){J.error("Unexpected code %s after 0:SECTION",Khe(n)),n=e.next();continue}if("HEADER"===n.value)J.trace("> HEADER"),t.header=a(),J.trace("<");else if("TABLES"===n.value)J.trace("> TABLES"),t.tables=l(),J.trace("<");else if("BLOCKS"===n.value)J.trace("> BLOCKS"),t.blocks=s(),J.trace("<");else if("ENTITIES"===n.value)J.trace("> ENTITIES"),t.entities=d(!1),J.trace("<");else if("OBJECTS"===n.value)J.trace("> OBJECTS"),t.objects=p(),J.trace("<");else if("EOF"===n.value)J.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))(uH||{}),ga=1,uA=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 nt(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);!uA.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);!uA.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,J.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),J.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]=ai(qn({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 nt(this,null,(function*(){var n,r;let a=ft.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 Whe.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!==hv&&e.lineType!==dv)return e.lineType;if(e.lineType===dv)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)?(J.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 J.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 Wb.forEach(((e,i)=>t[e]=i)),t})(),nlt=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,Ds=String.fromCharCode.bind(String),gde="function"==typeof Uint8Array.from?Uint8Array.from.bind(Uint8Array):e=>new Uint8Array(Array.prototype.slice.call(e,0)),bde=e=>e.replace(/=/g,"").replace(/[+\/]/g,(e=>"+"==e?"-":"_")),Ede=e=>e.replace(/[^A-Za-z0-9\+\/]/g,""),_de=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+=Wb[t>>18&63]+Wb[t>>12&63]+Wb[t>>6&63]+Wb[63&t]}return s?a.slice(0,s-3)+"===".substring(s):a},EH=elt?e=>btoa(e):yv?e=>Buffer.from(e,"binary").toString("base64"):_de,xH=yv?e=>Buffer.from(e).toString("base64"):e=>{let t=[];for(let i=0,n=e.length;it?bde(xH(e)):xH(e),rlt=e=>{if(e.length<2)return(t=e.charCodeAt(0))<128?e:t<2048?Ds(192|t>>>6)+Ds(128|63&t):Ds(224|t>>>12&15)+Ds(128|t>>>6&63)+Ds(128|63&t);var t=65536+1024*(e.charCodeAt(0)-55296)+(e.charCodeAt(1)-56320);return Ds(240|t>>>18&7)+Ds(128|t>>>12&63)+Ds(128|t>>>6&63)+Ds(128|63&t)},ilt=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,Tde=e=>e.replace(ilt,rlt),vde=yv?e=>Buffer.from(e,"utf8").toString("base64"):mde?e=>xH(mde.encode(e)):e=>EH(Tde(e)),vv=(e,t=!1)=>t?bde(vde(e)):vde(e),yde=e=>vv(e,!0),slt=/[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g,alt=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 Ds(55296+(t>>>10))+Ds(56320+(1023&t));case 3:return Ds((15&e.charCodeAt(0))<<12|(63&e.charCodeAt(1))<<6|63&e.charCodeAt(2));default:return Ds((31&e.charCodeAt(0))<<6|63&e.charCodeAt(1))}},wde=e=>e.replace(slt,alt),Sde=e=>{if(e=e.replace(/\s+/g,""),!nlt.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?Ds(t>>16&255,t>>8&255):Ds(t>>16&255,t>>8&255,255&t);return r},_H=Qot?e=>atob(Ede(e)):yv?e=>Buffer.from(e,"base64").toString("binary"):Sde,Mde=yv?e=>gde(Buffer.from(e,"base64")):e=>gde(_H(e).split("").map((e=>e.charCodeAt(0)))),Rde=e=>Mde(Ade(e)),olt=yv?e=>Buffer.from(e,"base64").toString("utf8"):pde?e=>pde.decode(Mde(e)):e=>wde(_H(e)),Ade=e=>Ede(e.replace(/[-_]/g,(e=>"-"==e?"+":"/"))),bH=e=>olt(Ade(e)),llt=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)},Cde=e=>({value:e,enumerable:!1,writable:!0,configurable:!0}),Pde=function(){let e=(e,t)=>Object.defineProperty(String.prototype,e,Cde(t));e("fromBase64",(function(){return bH(this)})),e("toBase64",(function(e){return vv(this,e)})),e("toBase64URI",(function(){return vv(this,!0)})),e("toBase64URL",(function(){return vv(this,!0)})),e("toUint8Array",(function(){return Rde(this)}))},Ide=function(){let e=(e,t)=>Object.defineProperty(Uint8Array.prototype,e,Cde(t));e("toBase64",(function(e){return gA(this,e)})),e("toBase64URI",(function(){return gA(this,!0)})),e("toBase64URL",(function(){return gA(this,!0)}))},clt=()=>{Pde(),Ide()},Dde={version:xde,VERSION:Jot,atob:_H,atobPolyfill:Sde,btoa:EH,btoaPolyfill:_de,fromBase64:bH,toBase64:vv,encode:vv,encodeURI:yde,encodeURL:yde,utob:Tde,btou:wde,decode:bH,isValid:llt,fromUint8Array:gA,toUint8Array:Rde,extendString:Pde,extendUint8Array:Ide,extendBuiltins:clt},fl=Xi(Kde(),1),sm=class extends Ad{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"}},uu=class extends er{constructor(e){super(e)}load(e,t,i,n){let r=this,a=new Cr(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,(function(e){let i=r.parse(JSON.parse(e));t&&t(i)}),i,n)}parse(e){return new Co(e)}},Co=class{constructor(e){this.isFont=!0,this.type="Font",this.data=e}generateShapes(e,t=100){let i=[],n=blt(e,t,this.data);for(let r=0,a=n.length;r0){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=$i(c);if(!e)return;e.userData={},n=new an(h.type),n.geometry=e,n.material=h.material,a.push(n)}else if(2===h.type||3===h.type){let e=Pr.mergeLineGeometries(c,t,h.material instanceof Kc||h.material instanceof Yt,f);if(!e)return;n=new an(3),n.geometry=e,n.material=h.material,s.push(n)}else if(1===h.type){let e=$i(c);if(!e)return;e.userData={},n=new an(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(),Ut.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)&&Pr.areGeometriesMergeable(l.geometry,h.geometry)&&Di.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=void 0,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;J.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 En&&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=$i(o);if(!e)return;e.userData={},a=new an(s.type),a.geometry=e,a.material=s.material,h.push(a)}else if(2===s.type||3===s.type){let e=Pr.mergeLineGeometries(o,r,s.material instanceof Kc||s.material instanceof Yt,m);if(!e)return;a=new an(3),a.geometry=e,a.material=s.material,c.push(a)}else if(1===s.type){let e=$i(o);if(!e)return;e.userData={},a=new an(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(),Ut.releaseGeometryManually(e)})),o=[]}})),J.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&&Sn.removeEmptyObjects(t),a}static applyMatrix(e,t,i){let n=t;for(vA.identity();n&&n!==i&&(vA.premultiply(n.matrix),n.parent);)n=n.parent;return vA.equals(Tlt)?e:e.applyMatrix4(vA)}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 Zde(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 Yt({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})}oc.mergeInfo={removedObjects:0,mergedMeshes:0,mergedLines:0,mergedPoints:0,mergedUnknownTypeObjects:0,elapsedTime:0};var yA=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 Yt({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})}},MH={};O_(MH,{default:()=>SH});var wH={};O_(wH,{default:()=>TH});var TH=(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)))),SH=(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)=>wlt[t]||t));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=Rlt(e),t?Alt(e,t):e),Rlt=e=>e.replace(/\\[uU]\+([0-9a-fA-F]{4})/g,((e,t)=>String.fromCodePoint(parseInt(t,16)))),Alt=(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)]))))},bA=(e,t)=>{let i=0,n={text:""},r=[n],a=(e=Mlt(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=Slt[t];a?n.text+=a:3===t.length?n.text+=String.fromCodePoint(+t):"k"===t||"o"===t||"u"===t?(n=ai(qn({},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))},RH=(e=>(e.Unitless="Unitless",e.Inches="Inches",e.Feet="Feet",e.Millimeters="Millimeters",e.Centimeters="Centimeters",e.Meters="Meters",e))(RH||{}),Jde=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),Qde=(e,t)=>Jde(e)/Jde(t),Jb="0.2.54",efe="VERSION",Clt=()=>window.localStorage.getItem(efe),Plt=()=>{window.localStorage.setItem(efe,Jb)},tfe=()=>Clt()!==Jb&&(Plt(),!0),xv=class{constructor(){this.DATABASE_NAME="gemini_viewer_db",this.TABLES=[{name:"viewpoint",options:{keyPath:"id",autoIncrement:!0},indexArray:[]},{name:"annotation",options:{keyPath:"id",autoIncrement:!0},indexArray:[]},{name:"dxfdata",options:{keyPath:"dxfDataId",autoIncrement:!1},indexArray:[]},{name:"fontdata",options:{keyPath:"url",autoIncrement:!0},indexArray:[]}],this.db=void 0}static instance(){return xv._instance||(xv._instance=new xv),xv._instance}getDatabase(){return nt(this,null,(function*(){let e=yield this.getDB(this.DATABASE_NAME);return this.db||(e.close(),tfe()&&(yield this.deleteDataBase(this.DATABASE_NAME)),e=yield this.getUpgradedDB(e)),e.onclose=()=>{this.db=void 0,J.debug(`[DB] Db ${e.name} is closed.`)},e.onerror=t=>{this.db=void 0,J.debug(`[DB] Db ${e.name} encountered error.`,t)},e.onabort=t=>{this.db=void 0,J.debug(`[DB] Db ${e.name} aborted.`,t)},e.onversionchange=e=>{J.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=>{J.debug(e),i(e)},n.onsuccess=i=>{let n=i.target;J.debug(`[DB] Db ${e} delete old version ${i.oldVersion}.`),t(n)}}))}getDB(e){return nt(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;J.debug(`[DB] Db ${i.name} opened (version ${i.version}).`),t(i)}}))}))}getUpgradedDB(e){return nt(this,null,(function*(){return new Promise(((t,i)=>{J.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=>{J.debug("onblocked",e)},n.onupgradeneeded=e=>{e.target.transaction.oncomplete=()=>{J.debug(`[DB] Upgrade is done (new version: ${t.version}).`)};let t=e.target.result,i=[];for(let n=0;n0&&Promise.all(i).then((()=>{J.debug(`[DB] All(${i.length}) tables created.`)}))},n.onsuccess=e=>{let i=e.target.result;J.debug(`[DB] Db ${i.name} opened (version ${i.version}).`),t(i)}}))}))}createTable(e,t,i,n){return nt(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})})),J.debug(`[DB] Table ${t} created.`),r(e)}))}))}},Oi=xv;Oi._instance=void 0;var hu=class{constructor(){if(this.db=void 0,this.isCreatingTable=!1,-1===Oi.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();Oi.instance().getDatabase().then((r=>{let a=r.transaction([n],"readwrite").objectStore(n).add(e);a.onsuccess=t,a.onerror=i})).finally((()=>{Oi.instance().closeDatabase()})).catch((e=>{i&&i(e)}))}save(e,t,i){let n=this.tableName();Oi.instance().getDatabase().then((r=>{let a=r.transaction([n],"readwrite").objectStore(n).put(e);a.onsuccess=t,a.onerror=i})).finally((()=>{Oi.instance().closeDatabase()}))}delete(e,t,i){let n=this.tableName();Oi.instance().getDatabase().then((r=>{let a=r.transaction([n],"readwrite").objectStore(n).delete(e);a.onsuccess=t,a.onerror=i})).finally((()=>{Oi.instance().closeDatabase()}))}update(){Oi.instance().getDatabase().then((()=>{}))}query(e,t){let i=this.tableName();Oi.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((()=>{Oi.instance().closeDatabase()}))}queryByIndex(e,t,i,n){let r=this.tableName();Oi.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((()=>{Oi.instance().closeDatabase()}))}queryAll(e,t){let i=this.tableName();Oi.instance().getDatabase().then((n=>{let r=n.transaction([i],"readonly").objectStore(i).getAll();r.onsuccess=t=>{e&&e(r.result)},r.onerror=t})).finally((()=>{Oi.instance().closeDatabase()}))}clearAll(e,t){let i=this.tableName();Oi.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((()=>{Oi.instance().closeDatabase()}))}},bv=class extends hu{tableName(){return"annotation"}static instance(){return bv._instance||(bv._instance=new bv),bv._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)}))}},AH=bv;AH._instance=void 0;var Ev=class extends hu{tableName(){return"viewpoint"}static instance(){return Ev._instance||(Ev._instance=new Ev),Ev._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)}))}},CH=Ev;CH._instance=void 0;var _v=class extends hu{tableName(){return"dxfdata"}static instance(){return _v._instance||(_v._instance=new _v),_v._instance}query(e,t,i){let n=[],r=this.tableName();Oi.instance().getDatabase().then((a=>{let s=a.transaction([r],"readonly").objectStore(r).get(e);s.onerror=e=>{i&&i(e),J.info("[DxfDataTable] Failed to query !",e)},s.onsuccess=()=>{s.result&&n.push(s.result),t&&t(n)}})).finally((()=>{Oi.instance().closeDatabase()}))}},Tv=_v;Tv._instance=void 0;var am=class extends hu{tableName(){return"fontdata"}static instance(){return am._instance||(am._instance=new am),am._instance}query(e,t,i){let n;super.query((i=>{i?!i.value||i.value.url!==e||(n=i.value):t&&t(n)}),(e=>{i&&i(),console.log(e)}))}queryAll(){return nt(this,null,(function*(){return new Promise(((e,t)=>{lz(am.prototype,this,"queryAll").call(this,(t=>{e(t)}),(e=>{t(e)}))}))}))}},du=am;du._instance=void 0;var nfe=(e=>(e[e.Horizontal=0]="Horizontal",e[e.Vertical=1]="Vertical",e[e.All=2]="All",e))(nfe||{}),om=(e=>(e[e.Shapes=0]="Shapes",e[e.Bigfont=1]="Bigfont",e[e.Unifont=2]="Unifont",e))(om||{}),PH=12,Ilt=!1,Dlt=new fe,Eh=class extends us{constructor(e,t){super(),this.width=0,this.bounds=new Pi,this.lastPoint=e,this.polylines=t,this.width=this.calcWidth(t)}offset(e){let t=[];for(let i=0;i0){let t=this.bounds.min,i=this.bounds.getSize(Dlt),n=new fe(t.x,t.y),r=new fe(t.x+i.width,t.y),a=new fe(t.x+i.width,t.y+i.height),s=new fe(t.x,t.y+i.height);e.push([n,r],[r,a],[a,s],[s,n])}let t=[],i=[],n=0,r=new Et;for(let a=0;a>8}}return t.subarray(0,i)}var Olt="\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",ife="\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 sfe(e){return Olt.charAt(ife.indexOf(e.charAt(0)))}var iBt=new RegExp("[\u4e00-\u9fa5]+");function afe(e){return ife.includes(e)}var fr=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.type){case 0:l++,o=t[l];break;case 1:l++,o=t[l],0==o&&(l++,o=fr.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=fr.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 fe;e.x=fr.byteTosbyte(t[++l]),e.y=fr.byteTosbyte(t[++l]),n.add(e.multiplyScalar(i)),o&&a.push(n.clone())}break;case 9:for(;;){let e=new fe;if(e.x=fr.byteTosbyte(t[++l]),e.y=fr.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=fr.byteTosbyte(t[++l]),s=(112&r)>>4,h=7&r;0==h&&(h=8);let c=Math.PI/4,u=c*h,d=$d.CIRCLE_SPAN;r<0&&(d=-d,u=-u);let p=c*s,f=p+u,m=n.clone().sub(new fe(Math.cos(p)*e,Math.sin(p)*e));if(n=m.clone().add(new fe(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 fe(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=fr.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=$d.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 fe(s*Math.cos(g),s*Math.sin(g)));if(n=y.clone().add(new fe(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 fe(s*Math.cos(e),s*Math.sin(e))));a.push(n.clone())}}break;case 12:{let e=new fe;e.x=fr.byteTosbyte(t[++l])*i,e.y=fr.byteTosbyte(t[++l])*i;let r=fr.byteTosbyte(t[++l]);r<-127&&(r=-127),o&&(0==r?a.push(n.clone().add(e)):a.push($d.generateArcPoints(n,e,r/127))),n.add(e)}break;case 13:for(;;){let e=new fe;if(e.x=fr.byteTosbyte(t[++l])*i,e.y=fr.byteTosbyte(t[++l])*i,0==e.x&&0==e.y)break;let r=fr.byteTosbyte(t[++l]);r<-127&&(r=-127),o&&(0==r?a.push(n.clone().add(e)):a.push($d.generateArcPoints(n.clone(),e,r/127))),n.add(e)}break;case 14:l=$d.skipCode(e,t,++l);break;default:if(h>15){let e=(240&h)>>4,t=15&h,r=new fe;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 Eh(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.type){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 fe(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=$d.CIRCLE_SPAN;r?(m=-m,pf&&(p-=2*Math.PI);let g=p;for(;;){if(g+=m,!r&&gf)return c.add(new fe(h*Math.cos(g),h*Math.sin(g)));break}return n}},lc=$d;lc.FILE_STOP_FLAG=["\r","\n","\x1a"],lc.CIRCLE_SPAN=Math.PI/18;var _A={130:[[[5,0],[5,9.5]],[[4,7.1],[2.6,6.6],[2.1,6.2],[1.7,5.4],[1.6,4],[2.1,3],[2.6,2.6],[3.9,2.2],[6.1,2.2],[7.5,2.6],[8,3.1],[8.4,3.9],[8.4,5.2],[7.9,6.1],[7.5,6.6],[6.1,7.1],[4,7.1]]],131:[[[3,0],[7,0]],[[5,0],[5,9.5]],[[4,7.1],[2.6,6.6],[2.1,6.2],[1.7,5.4],[1.6,4],[2.1,3],[2.6,2.6],[3.9,2.2],[6.1,2.2],[7.5,2.6],[8,3.1],[8.4,3.9],[8.4,5.2],[7.9,6.1],[7.5,6.6],[6.1,7.1],[4,7.1]]],132:[[[3,0],[7,0]],[[4,0],[4,9.5]],[[6,0],[6,9.5]],[[4,7.1],[2.6,6.6],[2.1,6.2],[1.7,5.4],[1.6,4],[2.1,3],[2.6,2.6],[3.9,2.2],[6.1,2.2],[7.5,2.6],[8,3.1],[8.4,3.9],[8.4,5.2],[7.9,6.1],[7.5,6.6],[6.1,7.1],[4,7.1]]],133:[[[3,0],[7,0]],[[4,0],[4,9.5]],[[6,0],[6,9.5]],[[4,7.1],[2.6,6.6],[2.1,6.2],[1.7,5.4],[1.6,4],[2.1,3],[2.6,2.6],[3.9,2.2],[6.1,2.2],[7.5,2.6],[8,3.1],[8.4,3.9],[8.4,5.2],[7.9,6.1],[7.5,6.6],[6.1,7.1],[4,7.1]],[[3,9.5],[7,9.5]]],134:[[[3,0],[7,0]],[[5,0],[5,9.5]],[[4,7.1],[2.6,6.6],[2.1,6.2],[1.7,5.4],[1.6,4],[2.1,3],[2.6,2.6],[3.9,2.2],[6.1,2.2],[7.5,2.6],[8,3.1],[8.4,3.9],[8.4,5.2],[7.9,6.1],[7.5,6.6],[6.1,7.1],[4,7.1]],[[12,10],[9,10],[9,6]],[[9,8],[11,8]]],135:[[[3,0],[7,0]],[[4,0],[4,9.5]],[[6,0],[6,9.5]],[[4,7.1],[2.6,6.6],[2.1,6.2],[1.7,5.4],[1.6,4],[2.1,3],[2.6,2.6],[3.9,2.2],[6.1,2.2],[7.5,2.6],[8,3.1],[8.4,3.9],[8.4,5.2],[7.9,6.1],[7.5,6.6],[6.1,7.1],[4,7.1]],[[12,10],[9,10],[9,6]],[[9,8],[11,8]]],136:[[[3,0],[7,0]],[[4,0],[4,9.5]],[[6,0],[6,9.5]],[[4,7.1],[2.6,6.6],[2.1,6.2],[1.7,5.4],[1.6,4],[2.1,3],[2.6,2.6],[3.9,2.2],[6.1,2.2],[7.5,2.6],[8,3.1],[8.4,3.9],[8.4,5.2],[7.9,6.1],[7.5,6.6],[6.1,7.1],[4,7.1]],[[3,9.5],[7,9.5]],[[12,10],[9,10],[9,6]],[[9,8],[11,8]]],178:[[[1.142,9.285],[1.142,9.428],[1.285,9.714],[1.428,9.857],[1.714,10],[2.285,10],[2.571,9.857],[2.714,9.714],[2.857,9.428],[2.857,9.142],[2.714,8.857],[2.428,8.428],[1,7],[3,7]]],8960:[[[2.9,8],[1.7,7.4],[.6,6.3],[0,4.6],[0,3.4],[.6,1.7],[1.7,.6],[2.9,0],[4.6,0],[5.7,.6],[6.9,1.7],[7.4,3.4],[7.4,4.6],[6.9,6.3],[5.7,7.4],[4.6,8],[2.9,8]],[[0,0],[8,8]]],20393:[[[0,0],[0,6.666]],[[0,4.761],[1.428,6.19],[2.38,6.666],[3.809,6.666],[4.761,6.19],[5.238,4.761],[5.238,0]],[[5.238,4.761],[6.666,6.19],[7.619,6.666],[9.047,6.666],[10,6.19],[10.476,4.761],[10.476,0]],[[11.142,9.285],[11.142,9.428],[11.285,9.714],[11.428,9.857],[11.714,10],[12.285,10],[12.571,9.857],[12.714,9.714],[12.857,9.428],[12.857,9.142],[12.714,8.857],[12.428,8.428],[11,7],[13,7]]],41123:[],55714:[[[2,5.9],[2.6,6.1],[3.4,7],[3.4,1]],[[2.9,8],[1.7,7.4],[.6,6.3],[0,4.6],[0,3.4],[.6,1.7],[1.7,.6],[2.9,0],[4.6,0],[5.7,.6],[6.9,1.7],[7.4,3.4],[7.4,4.6],[6.9,6.3],[5.7,7.4],[4.6,8],[2.9,8]]],55970:[[[2.3,5.6],[2.3,5.9],[2.6,6.4],[2.9,6.7],[3.4,7],[4.6,7],[5.1,6.7],[5.4,6.4],[5.7,5.9],[5.7,5.3],[5.4,4.7],[4.9,3.9],[2,1],[6,1]],[[2.9,8],[1.7,7.4],[.6,6.3],[0,4.6],[0,3.4],[.6,1.7],[1.7,.6],[2.9,0],[4.6,0],[5.7,.6],[6.9,1.7],[7.4,3.4],[7.4,4.6],[6.9,6.3],[5.7,7.4],[4.6,8],[2.9,8]]],56226:[[[2.6,7],[5.7,7],[4,4.7],[4.9,4.7],[5.4,4.4],[5.7,4.1],[6,3.3],[6,2.7],[5.7,1.9],[5.1,1.3],[4.3,1],[3.4,1],[2.6,1.3],[2.3,1.6],[2,2.1]],[[2.9,8],[1.7,7.4],[.6,6.3],[0,4.6],[0,3.4],[.6,1.7],[1.7,.6],[2.9,0],[4.6,0],[5.7,.6],[6.9,1.7],[7.4,3.4],[7.4,4.6],[6.9,6.3],[5.7,7.4],[4.6,8],[2.9,8]]],56482:[[[4.9,7],[2,3],[6.3,3]],[[4.9,7],[4.9,1]],[[2.9,8],[1.7,7.4],[.6,6.3],[0,4.6],[0,3.4],[.6,1.7],[1.7,.6],[2.9,0],[4.6,0],[5.7,.6],[6.9,1.7],[7.4,3.4],[7.4,4.6],[6.9,6.3],[5.7,7.4],[4.6,8],[2.9,8]]],56738:[[[5.4,7],[2.6,7],[2.3,4.4],[2.6,4.7],[3.4,5],[4.3,5],[5.1,4.7],[5.7,4.1],[6,3.3],[6,2.7],[5.7,1.9],[5.1,1.3],[4.3,1],[3.4,1],[2.6,1.3],[2.3,1.6],[2,2.1]],[[2.9,8],[1.7,7.4],[.6,6.3],[0,4.6],[0,3.4],[.6,1.7],[1.7,.6],[2.9,0],[4.6,0],[5.7,.6],[6.9,1.7],[7.4,3.4],[7.4,4.6],[6.9,6.3],[5.7,7.4],[4.6,8],[2.9,8]]],56994:[[[5.4,6.1],[5.1,6.7],[4.3,7],[3.7,7],[2.9,6.7],[2.3,5.9],[2,4.4],[2,3],[2.3,1.9],[2.9,1.3],[3.7,1],[4,1],[4.9,1.3],[5.4,1.9],[5.7,2.7],[5.7,3],[5.4,3.9],[4.9,4.4],[4,4.7],[3.7,4.7],[2.9,4.4],[2.3,3.9],[2,3]],[[2.9,8],[1.7,7.4],[.6,6.3],[0,4.6],[0,3.4],[.6,1.7],[1.7,.6],[2.9,0],[4.6,0],[5.7,.6],[6.9,1.7],[7.4,3.4],[7.4,4.6],[6.9,6.3],[5.7,7.4],[4.6,8],[2.9,8]]],57250:[[[2,7],[6,7],[3.1,1]],[[2.9,8],[1.7,7.4],[.6,6.3],[0,4.6],[0,3.4],[.6,1.7],[1.7,.6],[2.9,0],[4.6,0],[5.7,.6],[6.9,1.7],[7.4,3.4],[7.4,4.6],[6.9,6.3],[5.7,7.4],[4.6,8],[2.9,8]]],57506:[[[3.4,7],[2.6,6.7],[2.3,6.1],[2.3,5.6],[2.6,5],[3.1,4.7],[4.3,4.4],[5.1,4.1],[5.7,3.6],[6,3],[6,2.1],[5.7,1.6],[5.4,1.3],[4.6,1],[3.4,1],[2.6,1.3],[2.3,1.6],[2,2.1],[2,3],[2.3,3.6],[2.9,4.1],[3.7,4.4],[4.9,4.7],[5.4,5],[5.7,5.6],[5.7,6.1],[5.4,6.7],[4.6,7],[3.4,7]],[[2.9,8],[1.7,7.4],[.6,6.3],[0,4.6],[0,3.4],[.6,1.7],[1.7,.6],[2.9,0],[4.6,0],[5.7,.6],[6.9,1.7],[7.4,3.4],[7.4,4.6],[6.9,6.3],[5.7,7.4],[4.6,8],[2.9,8]]],57762:[[[5.7,5],[5.4,4.1],[4.9,3.6],[4,3.3],[3.7,3.3],[2.9,3.6],[2.3,4.1],[2,5],[2,5.3],[2.3,6.1],[2.9,6.7],[3.7,7],[4,7],[4.9,6.7],[5.4,6.1],[5.7,5],[5.7,3.6],[5.4,2.1],[4.9,1.3],[4,1],[3.4,1],[2.6,1.3],[2.3,1.9]],[[2.9,8],[1.7,7.4],[.6,6.3],[0,4.6],[0,3.4],[.6,1.7],[1.7,.6],[2.9,0],[4.6,0],[5.7,.6],[6.9,1.7],[7.4,3.4],[7.4,4.6],[6.9,6.3],[5.7,7.4],[4.6,8],[2.9,8]]],60070:[[[0,6],[10,6],[10,4]]],60326:[[[0,7],[0,5],[10,5]]]},ofe=new pn,Kd=class{constructor(e){this.type=1,this.info="",this.orientation=0,this.baseUp=0,this.baseDown=0,this.fileHeader="",this.fileVersion="",this.codes={},this.graphicData=new Map,this.url=e,this.fileName=this.getFileNameByPath(e)}getGraphicDataByCode(e,t){var i;if(0===e)return;let n,r=this.codes;if(!this.graphicData.has(e))if(r[e]){let t=r[e],i=PH/this.baseUp;n=lc.parserCode(this,t,i),this.graphicData.set(e,n)}else if(_A[e]){let t=[];for(let i=0;i<_A[e].length;i++)t.push(_A[e][i].map((e=>new fe(e[0],e[1]))));n=new Eh(new fe,t),this.graphicData.set(e,n)}if(this.graphicData.has(e)){let r=t/PH;ofe.identity().scale(r,r),n=null==(i=this.graphicData.get(e))?void 0:i.transform(ofe)}return n}getGraphicDataByCodeWithOffset(e,t,i){var n;return null==(n=this.getGraphicDataByCode(e,t))?void 0:n.offset(i)}getFontFile(){return{url:this.url,type:this.type,codes:this.codes,info:this.info,orientation:this.orientation,baseUp:this.baseUp,baseDown:this.baseDown,fileName:this.fileName,fileHeader:this.fileHeader,fileVersion:this.fileVersion}}setFontFile(e){this.url=e.url,this.fileName=e.fileName,this.type=e.type,this.codes=e.codes,this.info=e.info,this.orientation=e.orientation,this.baseUp=e.baseUp,this.baseDown=e.baseDown,this.fileHeader=e.fileHeader,this.fileVersion=e.fileVersion}releaseFontData(){this.codes={},this.graphicData.clear()}getFileNameByPath(e){let t=e.lastIndexOf("/");return e.substring(t+1)}setFontDataToIndexedDb(){return nt(this,null,(function*(){let e=this.getFontFile();return new Promise(((t,i)=>{du.instance().save(e,(()=>{console.log(`[FontFile] Saved '${this.url}' (${this.fileHeader}) to indexedDb`),t()}),(e=>i(`[FontFile] Failed to save '${this.url}' (${this.fileHeader}) to indexedDb! ${e}`)))}))}))}getFontDataByIndexedDb(){return nt(this,null,(function*(){return new Promise(((e,t)=>{du.instance().query(this.url,(t=>{e(t)}),(()=>t("[FontFile] Failed to get FontData from IndexedDB")))}))}))}},Qb=class extends Kd{constructor(e){super(e),this.isExtend=!1,this.type=1}init(e){fr.ToInt16(e.readBytes(2),0);let t=fr.ToInt16(e.readBytes(2),0),i=fr.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}var eE=class extends Kd{constructor(e){super(e),this.type=0}init(e){e.readBytes(2),e.readBytes(2);let t=fr.ToInt16(e.readBytes(2),0),i=[];for(let s=0;sa){u?(c+=t+r,u=!1):(u=!0,c=0,h-=n+i),TA.set(c,h);let e=d.offset(TA);o.push(e),!u&&(c+=d.width+r)}else{TA.set(c,h);let e=d.offset(TA);o.push(e),c+=d.width+r}else this.addUnsupportedChar(l)}u=!1,c=0,h-=n+i}return o}getNotFoundTextShape(e){let t=lc.getCode("\uff1f");return this.getGraphicDataByCode(t,e)}addUnsupportedChar(e){this.unsupportedChars[e]||(this.unsupportedChars[e]=0),this.unsupportedChars[e]++}static checkFontsAreLoaded(e){return nt(this,null,(function*(){if(!dn.isBrowser)return!1;let t=!1,i=yield du.instance().queryAll();if(i.length!==e.length)return!1;for(let n=0;ne.setFontDataToIndexedDb()));return yield Promise.all(e).then((()=>{J.debug("[ShxFont] Saves font data to IndexDB")}))}))}getFontData(){return nt(this,null,(function*(){if(dn.isBrowser){let e=yield du.instance().queryAll(),t=[],i=new Map;for(let n=0;n{let i=this.parse(e);t&&t(i)})).catch((e=>{n&&n(e)}))}loadFile(e,t){return nt(this,null,(function*(){return new Promise(((i,n)=>{let r=new Cr(this.manager);r.setResponseType("arraybuffer"),r.load(e,(t=>{i({url:e,arrayBuffer:t})}),t,(e=>{n(e)}))}))}))}loadAsync(e,t){return nt(this,null,(function*(){return Array.isArray(e)||(e=[e]),(yield ki.checkFontsAreLoaded(e))?Promise.resolve(new ki):new Promise(((i,n)=>{this.load(e,i,t,n)}))}))}parse(e){return new ki(e)}static isShxFile(e){var t;return"shx"===(null==(t=e.split(".").pop())?void 0:t.toLowerCase())}},cc=new P(1,0,0),DH=new P(0,1,0),fu=new P(0,0,1),lfe=new P(0,0,0),Jd=16777215,Flt="CONTINUOUS",wA=new ci({color:Jd}),Ls=new En({color:Jd}),lm=new jt({color:Jd}),cfe=(new Et).setFromPoints([new P]),ufe=new qe,hfe=new qe,Xa=new qe,Hn=new P,yi=new P,wv=new P,nE=new fe,Ts=new Xn,dfe=new Xn,SA=new Xt,Zd=new bt,ffe=new ci({color:65280,size:5,depthTest:!1}),pfe=new ci({color:65280,depthTest:!1}),mfe=new ci({color:65280,depthTest:!1}),Nlt=e=>void 0!==e.viewDirectionFromTarget,Blt=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 Dde.decode(e)}}}return null},gfe=(e,t)=>{let i=new fe(e.x,e.y),n=new fe(t.x,t.y);return n.sub(i),n.normalize(),n.y<0?-Math.acos(n.x):Math.acos(n.x)},vfe=(e,t,i)=>({x:e.x+t*Math.cos(i),y:e.y+t*Math.sin(i)}),Hlt=(e,t,i,n)=>{let r=e?new fe(e.x,e.y):new fe(0,0),a=t?new fe(t.x,t.y):new fe(1,0);i=i||1;let s=4*Math.atan(i),o=r.distanceTo(a)/2/Math.sin(s/2),l=vfe(e,o,gfe(r,a)+(Math.PI/2-s/2));n=n||Math.max(Math.abs(Math.ceil(s/(Math.PI/18))),6);let h=gfe(l,r),c=s/n,u=[];u.push(new P(r.x,r.y,0));for(let d=1;d<=n-1;d++){let e=vfe(l,Math.abs(o),h+c*d);u.push(new P(e.x,e.y,0))}return u},Ult=(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=SH(o,t,s,i,r);a.push(new P(e[0],e[1],0))}return a},LH=(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},zlt=e=>{let t=[],i=[];e.forEach((e=>{e.polyfaceMeshVertex&&(e.threeDPolylineMesh?t.push(new P(e.x,e.y,e.z)):i.push(Vlt(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},On=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)}},On.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=vn.rgb2Hex(t.overrideColor))),this.pointsMaterials[Jd]=wA,this.lineBasicMaterials[Jd]=Ls,this.meshBasicMaterials[Jd]=lm}setFont(e){this.font=e}download(e,t){return nt(this,null,(function*(){let i=Blt(e);if(!i){let n=Date.now(),r=new Cr(this.manager);r.setResponseType("arraybuffer"),r.setPath(this.path),i=yield r.loadAsync(e,t),J.info(`[DxfLoader] ${e} dxf file downloaded in ${(Date.now()-n)/1e3}s`)}return i}))}load(e,t,i){return nt(this,null,(function*(){return this.enableLocalCache&&t&&(t=t.trim()).length>0&&(this.dxfDataId=t),this.loadAsync(e,i)}))}loadAsync(e,t){return nt(this,null,(function*(){let i=ft.getUpdateSubProgressFunc(0,50,t),n=ft.getUpdateSubProgressFunc(50,100,t),r=ft.getUpdateSubProgressFunc(10,100,t);if(dn.isBrowser&&this.enableLocalCache&&this.dxfDataId){let t;try{if(this.timer=Date.now(),t=yield this.getDxfDataFromIndexedDb(this.dxfDataId),t){this.tryFixDxfData(t),J.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){J.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 nt(this,null,(function*(){let i=ft.getUpdateProgressFunc(t),n=ft.getUpdateSubProgressFunc(0,40,t),r=yield this.download(e,n);if(!r)return Promise.reject(`[DxfLoader] Failed to download ${e}`);if(On.abortJobs)return Promise.reject("[DxfLoader] Job aborted");this.timer=Date.now(),J.info("[DxfLoader] Start parsing...");let a=new im(this.encoding).parseSync(r);if(this.tryFixDxfData(a),i(80),J.info(`[DxfLoader] Parsed in ${(Date.now()-this.timer)/1e3}s, creating entities...`),On.abortJobs)return Promise.reject("[DxfLoader] Job aborted");if(a&&dn.isBrowser&&this.enableLocalCache&&this.dxfDataId){let t=Date.now();try{yield this.setDxfDataToIndexedDb(this.dxfDataId,a),J.info(`[DxfLoader] Saved to indexedDb in ${(Date.now()-t)/1e3}s`)}catch(e){J.warn(`[DxfLoader] Failed to save '${this.dxfDataId}' to indexedDb!`,e)}}return i(100),a}))}parseHeader(e){if(!e)return void J.error("[DxfLoader]: Invalid header!");this.header=e;let t=e.$ACADVER.toString();"AC1032"!==t&&J.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||(J.warn("[DxfLoader] No objects found, Will add one."),e.objects={}),e.objects.LAYOUT||(J.warn("[DxfLoader] No layout defined! Will add a default 'Model' layout!"),e.objects.LAYOUT=[{layoutName:On.MODEL_LAYOUT_NAME}]),e.tables||(J.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 nt(this,null,(function*(){let i=Date.now();this.parseHeader(e.header),this.enableRenderOrder&&(this.initRenderOrderInfo(e),this.enableMerge=!1);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=ft.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 an;for(let t=0;te.name===s));if(u||(u=new an,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){oc.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!==On.MODEL_LAYOUT_NAME)return;let r=i.associatedBlockName,a=e.blocks[r];a&&this.drawLayout(a,e,i,c,s,l)})),J.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 an;n.name=On.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(Sn.setSharedVariablesOfObject(t),!t.userData.isLayoutLevelObject)return;let i,n=t.name;if(n!==On.MODEL_LAYOUT_NAME){let e=d[n];e.directAssociatedLeafObjectSet||(e.directAssociatedLeafObjectSet=new Set),i=e.directAssociatedLeafObjectSet}t.traverse((t=>{if(Sn.setSharedVariablesOfObject(t),t.userData.isSnapGroup&&(t.visible=On.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)}}))})),J.info(`[DxfLoader] loadEntities() done in ${(Date.now()-i)/1e3}s`);let f=ai(qn({},e),{threejsObject:u,layersAndThreejsObjects:p,loadedEntityCount:n,layoutViewportsMap:l});return Promise.resolve(f)}))}loadEntitiesForCompare(e,t,i,n=!0,r){return nt(this,null,(function*(){let a=e.entities.length,s=t.entities.length,o=()=>nt(this,null,(function*(){var o;let l=this.compareContext,h=l.isTheFirstFile,c=h?e:t,u=new an,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=>nt(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 ft.sleep(0),m=n)}}));this.parseHeader(c.header);let v={};for(let e=0;ee.name===On.MODEL_LAYOUT_NAME));r||(r=new an,r.name=On.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=Xa.identity();for(;e&&!0!==e.userData.isLayoutLevelObject;)i.premultiply(e.matrix),e=e.parent;Zd.makeEmpty();let r=an.getBox(n,Zd);r.applyMatrix4(i),"Added"===t.type?!h&&(t.box=(new bt).copy(r)):"Removed"===t.type?h&&(t.box=(new bt).copy(r)):"Modified"===t.type&&(t.box?t.box.union(r):t.box=(new bt).copy(r))}}for(let e in this.layoutsSnapObjectsMap){let t=u.children.find((t=>t.name===e)),i=new an;i.name=On.SNAP_GROUP_NAME,t.add(i);let n=this.layoutsSnapObjectsMap[e];for(let e=0;e{Sn.setSharedVariablesOfObject(e),e.userData.isLayoutLevelObject&&e.traverse((e=>{if(Sn.setSharedVariablesOfObject(e),e.userData.isSnapGroup&&(e.visible=On.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},ft.printMemory("Before loading entities for first dxf"),yield o(),J.info(`[DxfLoader] loadEntities for first dxf in ${(Date.now()-l)/1e3}s`),ft.printMemory("After loading entities for first dxf"),this.releaseCachedData(!1),this.releaseDxfData(e),ft.printMemory("Before loading entities for second dxf"),l=Date.now(),this.compareContext.isTheFirstFile=!1,yield o(),J.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)),ft.printMemory("After loading entities for second dxf")}))}setObjectColorByChange(e,t){let i=(e,t)=>{e.traverse((e=>{if(e.material)if(e.material instanceof En)e.material=this.getLineBasicMaterial(t);else if(e.material instanceof jt)e.material=this.getMeshBasicMaterial(t);else if(e.material instanceof ci)e.material=this.getPointsMaterial(t);else if(e.material instanceof Yt){let i=e.material.clone();On.updateMaterialUniforms(i),i.uniforms.u_color.value.set(t),e.material=i}}))},n=(e=>{var t;let i=Gi.ENTITY_COLOR_NO_CHANGE;return"Added"===e.type?i=Gi.ENTITY_COLOR_ADDED:"Removed"===e.type?i=Gi.ENTITY_COLOR_REMOVED:"Modified"===e.type&&(i=null!=(t=this.compareContext)&&t.isTheFirstFile?Gi.ENTITY_COLOR_REMOVED:Gi.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)&&tm.includes(e.type)&&(n=!0),!n&&this.compareContext&&this.compareContext.preservedHandles&&!tm.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 tm.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,tm.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),Nt.areNumbersEqual(n,r,1e-5))return void J.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=Nt.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 ph(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(h,c,0),e.layers.enableAll()})),e.rotation&&Ts.setFromAxisAngle(fu,e.rotation*Math.PI/180),e.directionVector){let t=e.directionVector,i=new P(t.x,t.y,t.z),n=i.clone().cross(cc),r=cc.angleTo(i);Ts.multiply(dfe.setFromAxisAngle(fu,n.z>0?-r:r))}return Ut.shouldRebasePositionOnRTC(yi)&&this.setRTCUserData(a),a.matrix.compose(yi,Ts,wv),a}getMTextGroup(e,t,i,n,r=0,a=0,s=[]){if(0===e.length)return;let o=t.height||t.contextData&&t.contextData.textHeight||0;if(t.textStyle){let e=this.getTextStyle(i,t);if(e&&e.fontFile&&e.fontFile.endsWith(".shx")){let t=`${e.fontFile}_${e.styleName}`;this.statsInfo.unsupportedTextStyles[t]||(this.statsInfo.unsupportedTextStyles[t]=0),this.statsInfo.unsupportedTextStyles[t]++}o=o||e.textHeight}let l=t.lineSpaceFactor||1,h="Left";t.width&&t.attachmentPoint&&([1,4,7].includes(t.attachmentPoint)?h="Left":[2,5,8].includes(t.attachmentPoint)?h="Center":[3,6,9].includes(t.attachmentPoint)&&(h="Right"));let c,u,d=t.width||0,p=new an,f=1,m=1,g=256,v=l*o*.3,y=v+o;for(let x=0;x{let t=$i(e);t.boundingBox||t.computeBoundingBox();let i=t.boundingBox.getSize(Hn);switch(h){case"Left":default:break;case"Center":t.translate((d-i.x)/2,0,0);break;case"Right":t.translate(d-i.x,0,0)}_.push(t)};for(let t=0;t(d||1/0))r=0,a-=y,s.length>0&&w(s),s=[];else{e.boundingBox||e.computeBoundingBox();let t=e.boundingBox.getSize(Hn).x;" "===i&&(t=o/2),r+=t+m*(o/6),s.push(e)}else r+=o+m*(o/6)}else r=0,a-=y,s.length>0&&w(s),s=[]}if(s.length>0&&(w(s),s=[]),_.length>0){let e=$i(_);this.font instanceof ki?(x=new an(3),x.geometry=e,x.material=Ls):this.font instanceof Co&&(x=new an(4),x.geometry=e,x.material=lm)}if(!x)continue;c||(c=t.colorIndex),void 0!==g&&256!==g?(t.color=nm(g),t.colorIndex=g):t.colorIndex=c;let M=this.getColor(t,i,n);x.material instanceof jt?x.material=this.getMeshBasicMaterial(M):x.material instanceof En&&(x.material=this.getLineBasicMaterial(M)),x.matrix.makeTranslation(0,-o,0),p.add(x),u=void 0,f=1,m=1,g=256,l=t.lineSpaceFactor||1}else if(Array.isArray(b)){let e=this.getMTextGroup(b,t,i,n,r,a,s);e&&p.add(e)}else"object"==typeof b&&(b.f&&(u=b.f,u&&u.includes(".shx")&&J.info(`[DxfLoader] Doesn't support custom fonts: ${u}`)),b.C&&(g=b.C),b.W&&(f="x"===b.W[1]?b.W[0]*t.width:b.W[0]),b.H&&(o="x"===b.H[1]?b.H[0]*t.height:b.H[0]),b.T&&(m=b.T))}return 0!==p.children.length?(oc.merge(p,!1),c&&(t.colorIndex=c),1===p.children.length?p.children[0]:p):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 J.warn("[DxfLoader] Entity is missing vertices:",e.handle);let t=e.vertices.map((e=>new P(e.x,e.y,e.z)));if(0===t.length)return;Nt.areVector3sEqual(t[0],t[t.length-1])||t.push(t[0]);let i=new P,n=!1;this.enableRTC&&(n=Ut.checkAndRebasePositionsOnRTC(t,i));let r=(new Et).setFromPoints(t),a=new an(2);return a.geometry=r,a.material=Ls,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=Ult(e.controlPoints,e.degreeOfSplineCurve,e.knotValues,h),u=new P,d=!1;this.enableRTC&&(d=Ut.checkAndRebasePositionsOnRTC(c,u));let p=Ut.getAdjacentNonRepeatPoints(c);if(p.length<2)return void J.warn("[DxfLoader] Spline entity (handle '%s') contains less than 2 points, ignored!",e.handle);let f=(new Et).setFromPoints(p),m=new an(2);return m.geometry=f,m.material=Ls,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 J.warn("[DxfLoader] Entity is missing vertices:",e.handle);let t=ft.arrayOrObjectToVector3(e.directionVector),i=new P(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 P,a=!1;this.enableRTC&&(a=Ut.checkAndRebasePositionsOnRTC(n,r));let s=(new Et).setFromPoints(n),o=new an(2);return o.geometry=s,o.material=Ls,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 J.warn("[DxfLoader] Entity is missing vertices:",e.handle);let t=ft.arrayOrObjectToVector3(e.directionVector),i=e.vertices.map((e=>new P(e.x,e.y,0)));if(i.push(t.multiplyScalar(1e6).add(i[0])),0===i.length)return;let n=new P,r=!1;this.enableRTC&&(r=Ut.checkAndRebasePositionsOnRTC(i,n));let a=(new Et).setFromPoints(i),s=new an(2);return s.geometry=a,s.material=Ls,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 J.warn("[DxfLoader] Entity is missing vertices:",e.handle);let t=[];if(e.isPolyfaceMesh)t=zlt(e.vertices);else{let i=LH(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=Ut.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 Et).setFromPoints(e);c.setIndex(i),n=new an(3),n.geometry=c,n.material=Ls}if(i.length>0){this.enableRTC&&(a=Ut.checkAndRebasePositionsOnRTC(i,r));let e=(new Et).setFromPoints(i);n=new an(1),n.geometry=e,n.material=wA}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 J.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){Hn.set(s.extrusionDirectionX,s.extrusionDirectionY,s.extrusionDirectionZ);let e=On.getOcsMatrix(Hn).invert(),t=0;void 0!==s.elevation&&s.elevation>0&&(t=s.elevation),s.vertices.forEach((i=>{let n=Hn.set(i.x,i.y,t).applyMatrix4(e);i.x=n.x,i.y=n.y}))}let o=LH(e.vertices,e.shape);if(e.shape&&o.length>0&&!Nt.areVector3sEqual(o[0],o[o.length-1])&&o.push(o[0]),o.length<2)return void J.warn("[DxfLoader] Invalid LWPolyline entity (handle '%s'), ignored!",e.handle);let l=new an;if(null!=(n=e.extendedData)&&n.outlines){let t=e.extendedData.outlines,i=[];t.forEach((e=>{let t=new us;e.forEach(((e,i)=>{0===i?t.moveTo(e[0],e[1]):t.lineTo(e[0],e[1])})),t.closePath(),i.push(new Jl(t))}));let n=$i(i),r=new an(4);r.geometry=n,r.material=lm,r.layers.enableAll(),l.add(r)}let h=new P,c=!1;this.enableRTC&&(c=Ut.checkAndRebasePositionsOnRTC(o,h));let u=Ut.getAdjacentNonRepeatPoints(o);if(u.length<2)return void J.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=Ut.convertWidthLineToMeshGeometry(u,s.constantWidth);if(t){let e=new an(4);e.geometry=t,e.material=lm,e.layers.enableAll(),e.layers.disable(11),l.add(e);let i=Sn.createOutline(t,Ls,e.matrix),n=new an(3);n.geometry=i.geometry,n.material=i.material,n.matrix=i.matrix,n.layers.enableAll(),n.layers.disable(11),l.add(n)}else J.warn("[DxfLoader] Failed to convert line with width to mesh geometry: %s",e.handle)}}let d=new an(2);return d.geometry=(new Et).setFromPoints(u),d.material=Ls,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 an,p=xA(u),f=this.getMTextGroup(p,e,t,i);if(f){f.matrix.decompose(yi,Ts,wv),null!=(r=e.contextData)&&r.textLocation&&(yi.x+=e.contextData.textLocation.x,yi.y+=e.contextData.textLocation.y,f.matrix.compose(yi,Ts,wv)),Zd.makeEmpty();let t=an.getBox(f,Zd).getSize(Hn),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}if(f.traverse((e=>{e.geometry&&e.geometry.translate(l,h,0)})),null!=(s=e.contextData)&&s.textRotation&&Ts.setFromAxisAngle(fu,e.contextData.textRotation*Math.PI/180),null!=(o=e.contextData)&&o.textDirection){let t=e.contextData.textDirection,i=new P(t.x,t.y,t.z),n=i.clone().cross(cc),r=cc.angleTo(i);Ts.multiply(dfe.setFromAxisAngle(fu,n.z>0?-r:r))}Ut.shouldRebasePositionOnRTC(yi)&&this.setRTCUserData(f),f.matrix.compose(yi,Ts,wv),f.renderOrder=5,d.add(f)}if(0===e.leaderLineType)return null==f||f.traverse((e=>{e.layers.enableAll()})),f;{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 P(r.x,r.y,r.z),t=n.doglegLength,a=new P(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 P(e.x,e.y,e.z))),s=new P(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 J.warn("[DxfLoader] Entity is missing vertices:",e.handle);if(e.vertices.length<2)return void J.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 Pp(e.vertices).getPoints(50)),e.textWidth){let t=e.textWidth,i=new P(a[a.length-1].x,a[a.length-1].y,a[a.length-1].z);if(0===e.direction){let e=new P(1,0,0).multiplyScalar(t);a.push(e.add(i))}else{let e=new P(-1,0,0).multiplyScalar(t);a.push(e.add(i))}}for(let p=0;p0?(l.add(d),oc.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 P(t.x+r+s/6,t.y+a+o/6,0),h=new P(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 Yt&&(e.uniforms.u_cameraZoom&&(e.uniforms.u_cameraZoom=On.cameraZoomUniform),e.uniforms.u_viewportScale&&(e.uniforms.u_viewportScale=On.viewportScaleUniform))}static transformAngleByOcsMatrix(e,t){let i=Hn.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=Nt.getArcAngleSpanInRadian(t,i),a=On.transformAngleByOcsMatrix(e,t),s=On.transformAngleByOcsMatrix(e,i);if(Nt.areNumbersClose(r,Math.PI)){r=1;let i=On.transformAngleByOcsMatrix(e,t+r);n=Nt.getArcAngleSpanInRadian(a,i)}else{if(Nt.areNumbersClose(r,2*Math.PI))return[a,a+2*Math.PI];n=Nt.getArcAngleSpanInRadian(a,s)}return Nt.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 J.warn(`[DxfLoader] The radius of arc (handle '${e.handle}') is undefined, ignored!`);if(!e.radius||e.radius<.001)return void J.warn(`[DxfLoader] The radius of arc (handle '${e.handle}') is too small, ignored!`);let s=new P(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=On.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,Nt.areNumbersEqual(o,l,1e-6)))return;if(!Nt.areNumbersClose(Nt.getArcAngleSpanInRadian(o,l),2*Math.PI)){let e=On.getArcAnglesByOcsMatrix(h,o,l);o=e[0],l=e[1]}}let c=new Cp(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 P,g=!1;this.enableRTC&&(g=Ut.checkAndRebasePositionsOnRTC(f,m));let v=(new Et).setFromPoints(f),y=new an(2);y.geometry=v,y.material=Ls;let x=new P;e.center&&(x.x=e.center.x,x.y=e.center.y);let b=new P(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 an(1);return w.geometry=cfe,w.material=wA,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):Ut.shouldRebasePositionOnRTC(_)&&this.setRTCUserData(y),y.matrix.setPosition(_),y.layers.enableAll(),y}addTriangleFacingCamera(e,t,i,n){let r=new P,a=new P;r.subVectors(i,t),a.subVectors(n,t),r.cross(a);let s=new P(t.x,t.y,t.z),o=new P(i.x,i.y,i.z),l=new P(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){Hn.set(0,0,e.extrusionDirection.z);let t=On.getOcsMatrix(Hn).invert();n.forEach((e=>{let i=Hn.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 P,o=!1;this.enableRTC&&(o=Ut.checkAndRebasePositionsOnRTC(r,s));let l=(new Et).setFromPoints(r);l.setIndex(a);let h=new an(4);return h.geometry=l,h.material=lm,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){var r;if(!e)return;let a=this.getTextStyle(n,i),s=(null==a?void 0:a.styleName)||"";if(a&&a.fontFile&&a.fontFile.endsWith(".shx")){let e=`${a.fontFile}_${a.styleName}`;this.statsInfo.unsupportedTextStyles[e]||(this.statsInfo.unsupportedTextStyles[e]=0),this.statsInfo.unsupportedTextStyles[e]++}let o=.67,l={_TCH_DIM:1.45,ROMANS:1};s&&l[s]&&(o=l[s]),i.xScale&&(o*=i.xScale),s&&(o*=(null==a?void 0:a.xScale)||1,t=t||(null==a?void 0:a.textHeight)||0),0===t&&(t=s?1:.2);let h=this.createTextMeshByText(e,t,0,t/8);return null==(r=null==h?void 0:h.geometry)||r.scale(o,1,1),h}createTextMeshByText(e,t=12,i=0,n=0,r=1,a=1/0){let s,o=[],l=0,h=0,c=i+t;for(let u=0;ua?(l=0,h-=c):(i.boundingBox||i.computeBoundingBox(),l+=i.boundingBox.getSize(Hn).x+n),o.push(i))}else l=0,h-=c}if(o.length>0){let e=$i(o);this.font instanceof ki?(s=new an(3),s.geometry=e,s.material=Ls):this.font instanceof Co&&(s=new an(4),s.geometry=e,s.material=lm)}return s}transformTextMesh(e,t){Zd.makeEmpty();let i=an.getBox(t,Zd).getSize(Hn),{halign:n,valign:r}=e;t.matrix.decompose(SA.position,SA.quaternion,SA.scale);let a=SA,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 P(e.startPoint.x,e.startPoint.y,e.startPoint.z),i=new P(e.endPoint.x,e.endPoint.y,e.endPoint.z),n=(new P).subVectors(t,i),r=n.length()/s;a.scale.multiplyScalar(r);let o=n.clone().cross(cc),l=n.angleTo(cc);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 P(e.startPoint.x,e.startPoint.y,e.startPoint.z),i=new P(e.endPoint.x,e.endPoint.y,e.endPoint.z),n=(new P).subVectors(t,i),r=n.length()/s;a.scale.setX(r);let o=n.clone().cross(cc),l=n.angleTo(cc);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 J.info("[DxfLoader] Font file not set, ignoring text entity.");let r=this.getTextStyle(t,e);n=bA(n,{encoding:this.getTextEncoding(r)}).map((e=>e.text)).join("");let a=this.getTextMesh(n,e.textHeight,e,t);if(!a||!a.geometry)return;let s=a.geometry;if(a instanceof ht&&!s.getIndex()){let e=s.getAttribute("position"),t=[];for(let i=0;ie.text)).join();let r=this.getTextMesh(n,e.textHeight,e,t);if(!r||!r.geometry)return;let a=r.geometry;if(a.hasAttribute("uv")&&a.deleteAttribute("uv"),a.hasAttribute("normal")&&a.deleteAttribute("normal"),this.transformTextMesh(e,r),Hn.set(r.matrix.elements[12],r.matrix.elements[13],r.matrix.elements[14]),Ut.shouldRebasePositionOnRTC(Hn))this.setRTCUserData(r);else{let e=Ut.caculateGeometryCenter(a);e&&Ut.shouldRebasePositionOnRTC(e)&&this.setRTCUserData(r)}return r.layers.enableAll(),r}drawAttrib(e,t,i){let n=e.text;if(!n||!this.font)return;n=bA(n).map((e=>e.text)).join();let r=this.getTextMesh(n,e.textHeight,e,t);if(!r||!r.geometry)return;let a=r.geometry;if(a.hasAttribute("uv")&&a.deleteAttribute("uv"),a.hasAttribute("normal")&&a.deleteAttribute("normal"),this.transformTextMesh(e,r),Hn.set(r.matrix.elements[12],r.matrix.elements[13],r.matrix.elements[14]),Ut.shouldRebasePositionOnRTC(Hn))this.setRTCUserData(r);else{let e=Ut.caculateGeometryCenter(a);e&&Ut.shouldRebasePositionOnRTC(e)&&this.setRTCUserData(r)}return r.layers.enableAll(),r}drawPoint(e,t,i){if(!e.position)return;let n=new Et,r=[new P(e.position.x,e.position.y,e.position.z)];Hn.set(0,0,0);let a=Hn,s=!1;this.enableRTC&&(s=Ut.checkAndRebasePositionsOnRTC(r,a)),n.setFromPoints(r);let o=new an(1);return o.geometry=n,o.material=Ls,s&&(this.setRTCUserData(o),o.matrix.setPosition(a.x,a.y,0)),o.layers.enableAll(),o}drawDimension(e,t){if(!e.block)return;let i=t.blocks[e.block];if(!i||!i.entities)return;let n=t.tables.dimStyle.dimStyles[e.dimStyleName]||this.getDefaultDimensionStyle(t);n&&n.DIMCLRD>0&&(e.colorIndex=n.DIMCLRD,e.color=nm(e.colorIndex));let r=new an;for(let s=0;s`,r.userData.entityType=e.type;let a=null==e?void 0:e.insertionPoint;return Hn.set(0,0,0),a&&Hn.set(a.x,a.y,0),Ut.shouldRebasePositionOnRTC(Hn)&&this.setRTCUserData(r),r.matrix.setPosition(Hn),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 an,l=!1;2===e.flags||4===e.flags||8===e.flags||(l=!0);let h=new zr(a,s);if(l){let e=new rs(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=zt;let t=new jt({transparent:!0,side:Xr,map:e}),i=new an(4);i.geometry=h,i.material=t,o.add(i)}let c=new Yc(h),u=this.getColor(e,t,i),d=new an(2);d.geometry=c,d.material=this.getLineBasicMaterial(u);let p=e.uPixel?new P(e.uPixel.x,e.uPixel.y,e.uPixel.z):new P(r.pixelSize.x,0,0),f=e.vPixel?new P(e.vPixel.x,e.vPixel.y,e.vPixel.z):new P(r.pixelSize.y,0,0);if(o.add(d),yi.set(p.x,f.y,1),Hn.set(0,0,0),e.position){let t=new P(e.position.x,e.position.y,e.position.z);t.add(p.multiplyScalar(a/2)).add(f.multiplyScalar(s/2)),Hn.copy(t)}return Ut.shouldRebasePositionOnRTC(Hn)&&this.setRTCUserData(o),Ts.identity(),o.matrix.compose(Hn,Ts,yi),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 an;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=Hn.set(1,1,1);e.xScale&&(o.x=e.xScale),e.yScale&&(o.y=e.yScale);let l=new Dn;e.rotation&&(l.z=e.rotation*Math.PI/180),Ts.setFromEuler(l,!1);let h=yi.set(0,0,0);e.position&&(h.x=e.position.x,h.y=e.position.y),Xa.compose(h,Ts,o),e.extrusionDirection&&e.extrusionDirection.z<0&&Xa.premultiply(ufe.identity().makeScale(-1,1,1)),hfe.copy(s.matrix),s.matrix.premultiply(Xa),yi.set(s.matrix.elements[12],s.matrix.elements[13],s.matrix.elements[14]),Ut.shouldRebasePositionOnRTC(yi)&&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),J.debug("[DxfLoader] Spatial filter:",e.associatedSpatialFilter))}return s}drawSpatialFilter(e){let t=e;if(t.threejsObject)return t.threejsObject.clone();let i=e.invertBlockMatrix;Xa.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 P(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(Nt.areVector3sEqual(i,o)&&e+10)break;a.push(i)}if(s>0)for(let e=s+1;e{o.push(new fe(e.x,e.y)),l.push([e.x,e.y])})),!Ut.isConvex(o)){J.warn(`[DxfLoader] Concave polygon is not supported for spatial filter (handle '${e.handle}'), converting to convex polygon!`);let t=(0,yfe.default)(l,1/0);a=[],t.forEach((e=>{a.push(new P(e[0],e[1],0))}))}Nt.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=Xa.clone(),t.clipPolylines=[],void t.clipPolylines.push(r)}drawLayout(e,t,i,n,r,a){if(!e.entities)return;let s=new an;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 an,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 fe(i.startPoint.x,i.startPoint.y)),t.push(new fe(i.endPoint.x,i.endPoint.y));break}case 2:{let i=e,n=i.startAngle*gn.DEG2RAD,r=i.endAngle*gn.DEG2RAD;i.bCounterclockwise||(n=2*Math.PI-n,r=2*Math.PI-r);let a=new Cp(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*gn.DEG2RAD,o=i.endAngle*gn.DEG2RAD;i.bCounterclockwise||(s=2*Math.PI-s,o=2*Math.PI-o);let l=new ph(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(...LH(i.points,i.isClosed));break}}return t}drawHatch(e,t,i){var n;let r=e;if(0==r.boundaryPaths.length)return;let a=[],s=[],o=[],l=e=>{let t=[],i=[];i.push(...this.convertEdgeToPoints(e[0]));for(let n=1;n2){let a=this.convertEdgeToPoints(e[n-1]);Nt.areVector2sEqual(a[a.length-1],r[0])?Nt.areVector2sEqual(i[0],r[r.length-1],1e-5)&&(t.push(i),i=[]):Nt.areVector2sEqual(a[0],r[r.length-1])?Nt.areVector2sEqual(i[1],r[0],1e-5)&&(t.push(i),i=[]):i=[]}}return t};if(r.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 J.info(i,e.pathTypeFlag,t,r.handle)}let n=e.edges;if(0===n.length)return;let h=[];for(let a=0;a31&&(!(e=>{for(let t=1;t{Nt.areVector2sEqual(e[0],e[e.length-1])||e.push(e[0]);let t=e.map((e=>new fe(ft.roundNumber(e.x,7),ft.roundNumber(e.y,7))));if((null==t?void 0:t.length)>0){a.push(t);let e=(new Pi).setFromPoints(t);s.push(e);let i=e.getSize(nE),n=i.x*i.y;o.push({area:n,index:a.length-1})}}))})),0===a.length)return;let h=new fe,c=this.checkAndRebasePolygonsOnRTC(a,h);o.sort(((e,t)=>e.area-t.area));let u=[];o.forEach((e=>{u.push(e.index)}));let d,p=this.buildContainHierarchyTree(a,s,u),f=[];if(this.buildHatchGeometry(a,p,f),f.length>0&&(d=$i(f)),!d||!d.getIndex()||0===(null==(n=d.getIndex())?void 0:n.count))return void J.warn("[DxfLoader] Failed to convert hatch boundaries!");let m=new an(4);m.geometry=d,m.material=lm,this.setHatchMaterial(m,r,t,h,i);let g=m;return c&&(this.setRTCUserData(g),g.matrix.setPosition(h.x,h.y,0)),g.traverse((e=>{e.layers.enableAll(),e.layers.disable(11)})),g}drawOle2frame(e,t){let{leftUpX:i,leftUpY:n,rightDownX:r,rightDownY:a}=e;if(!(i&&n&&r&&a))return;let s=[new fe(i,n),new fe(i,a),new fe(r,a),new fe(r,n),new fe(i,n)],o=new P,l=!1;this.enableRTC&&(l=Ut.checkAndRebasePositionsOnRTC(s,o));let h=(new Et).setFromPoints(s),c=this.getLineBasicMaterial(16777215),u=new an(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 an;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=cc,i=DH,n=fu,r=new P(0,1,0),a=new P(0,0,1);return Nt.areVectorsClose(e,a)?Xa.identity():(n=e.clone().normalize(),Nt.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()),Xa.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=Nlt(e)?e.viewDirectionFromTarget:e.viewDirection;let n,r,a,s=new P(Nt.roundNumber(i.x,7),Nt.roundNumber(i.y,7),i.z),o=new P(e.viewTarget.x,e.viewTarget.y,e.viewTarget.z),l=e.viewTwistAngle||0;a=s.clone().normalize(),n=fu.clone().cross(s),n.length()>0?(n.normalize(),r=a.clone().cross(n)):a.z<0?(n=cc.clone().negate(),r=DH,a=fu.clone().negate()):(n=cc,r=DH,a=fu);let h=new qe,c=Xa.identity();return c.makeBasis(n,r,a),h.premultiply(c),h.premultiply(Xa.identity().compose(o.clone(),(new Xn).setFromAxisAngle(new P(0,0,1),gn.degToRad(t?l:-l)),new P(1,1,1))),h}getViewportMsToPsMatrix(e){let t=new P(e.centerPoint_dcs.x,e.centerPoint_dcs.y,0),i=new P(e.centerPoint.x,e.centerPoint.y,e.centerPoint.z),n=e.viewHeight/e.height_paperSpace,r=On.getDcs2WcsMatrix(e,this.angDir),a=new qe;a.setPosition(lfe.clone().sub(i));let s=ufe.identity();s.scale(Hn.set(n,n,n));let o=hfe.identity().setPosition(lfe.clone().sub(i));s.premultiply(o.clone().invert()).multiply(o),a.multiply(s);let l=Xa.identity();l.setPosition(t),r.multiply(l);let h=Xa.identity();return a.invert().multiply(h).multiply(r.invert())}drawViewport(e,t,i){let n=e;if("1"==n.viewportId)return e.psBBox=new bt,void(e.msToPsMatrix=new qe);let r=[],a=n.centerPoint,s=n.width_paperSpace/2,o=n.height_paperSpace/2;r.push(new P(a.x-s,a.y-o,0)),r.push(new P(a.x-s,a.y+o,0)),r.push(new P(a.x+s,a.y+o,0)),r.push(new P(a.x+s,a.y-o,0)),r.push(r[0]),e.psBBox=new bt(r[0],r[2]),e.msToPsMatrix=this.getViewportMsToPsMatrix(n);let l=new P,h=!1;this.enableRTC&&(h=Ut.checkAndRebasePositionsOnRTC(r,l));let c=(new Et).setFromPoints(r),u=new an(2);u.geometry=c,u.material=Ls,h&&(this.setRTCUserData(u),u.matrix.setPosition(l.x,l.y,0)),u.userData.entityType=e.type,u.layers.enableAll();let d=new an;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 P(p.min.x,p.max.y,0)),f.push(p.max),f.push(new P(p.max.x,p.min.y,0)),f.push(f[0]);let m=new P,g=!1;this.enableRTC&&(g=Ut.checkAndRebasePositionsOnRTC(f,m));let v=(new Et).setFromPoints(f),y=new an(2);return y.geometry=v,y.material=Ls,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 Gi.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!`;J.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=Jd;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 J.warn("[DxfLoader] Unknown colorIndex"),Jd}getLineType(e,t,i){var n,r;if(i&&"DIMENSION"===i.type)return this.getLineType(i,t);if(e.lineType!==hv&&e.lineType!==dv)return e.lineType;if(e.lineType===dv)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=Flt;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 nE.set(0,0),void this.setHatchMaterial(e,t,i,nE,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 ci)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 Yt){o=a.material;let e=new Ye(s);a.material.uniforms.u_color.value.equals(e)||(o=a.material.clone(),On.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 ci({size:.2,color:e})),this.pointsMaterials[e]}getLineBasicMaterial(e){return this.lineBasicMaterials[e]||(this.lineBasicMaterials[e]=new En({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]=yA.createLineShaderMaterial(e.pattern,t,a,On.viewportScaleUniform,On.cameraZoomUniform)}return this.lineShaderMaterials[n]}getMeshBasicMaterial(e){return this.meshBasicMaterials[e]||(this.meshBasicMaterials[e]=new jt({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 fe;for(let h of e.patternLines){let t=new fe(h.origin.x,h.origin.y).sub(i).rotateAround(o,-gn.degToRad(e.patternAngle)),n=new fe(h.delta.x,h.delta.y).rotateAround(o,-gn.degToRad(h.angle));if(0===n.y)return void J.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;eOn.maxFragmentUniforms){J.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=Zde(s,e.patternAngle,On.cameraZoomUniform,new Ye(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 nt(this,null,(function*(){let i={dxfDataId:e,dxf:t};return new Promise(((t,n)=>{Tv.instance().add(i,(()=>{J.info(`[DxfLoader] Saved '${e}' to indexedDb`),t()}),(e=>{n(e)}))}))}))}getDxfDataFromIndexedDb(e){return nt(this,null,(function*(){return new Promise(((t,i)=>{Tv.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 Jl(e);t.hasAttribute("uv")&&t.deleteAttribute("uv"),t.hasAttribute("normal")&&t.deleteAttribute("normal"),i.push(t)}catch(t){J.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 us(i);a(n)}));let s=e=>e.map((e=>e.toArray()));for(let o of r){let t=new us(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(fl.epsilon(Nt.getVector2RelativeEps(e[n][0]),1e-6),0===a)r=fl.segments({regions:[s(e[n])],inverted:!1});else{let a=fl.segments({regions:[s(e[n])],inverted:!1}),o=fl.combine(r,a);i=fl.polygon(fl.selectUnion(o)),i.regions.length>0?i.regions.forEach((e=>{if(0===e.length)return;let i=e.map((e=>new fe(e[0],e[1])));t.holes.push(new Wc(i))})):J.warn("[DxfLoader] mergedHoles.regions is empty")}}))}catch(e){J.warn(`[DxfLoader] polybooljs has error: ${e}, epsilon is ${fl.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&&Ut.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):(J.warn("[DxfLoader] Failed to find layout name for entity:",t),e.objects.LAYOUT.find((e=>e.layoutName===On.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();On.updateMaterialUniforms(n),t.set(e.id,n),i.push(n)}}))):e&&(t.has(e.id)?i=t.get(e.id):(i=e.clone(),On.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:J.warn(`[DxfLoader] Unsupported $INSUNITS '${e}'`)}return"Unitless"}static computeLineDistance(e){let t=!0===e.isLineSegments,i=e.geometry,n=e.matrixWorld;if(i.index&&(J.debug(`[DxfLoader] Line with id '${e.id}' contains index buffer, going to convert it to non-indexed.`),i=Ut.convertGeometryWithIndexedToNonIndexed(i),e.userData.batches&&e.userData.batches.length>0)){J.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 Yt&&On.computeLineDistance(t)})),J.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];On.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=oc.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();On.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,J.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=[]}J.debug(`[DxfLoader] MergeUtils.deepMerge costed ${Pr.mergeInfo.elapsedTime/1e3}s`),J.debug(`[DxfLoader] The remove operation of deep merge costed ${a/1e3}s`),J.debug(`[DxfLoader] Deep merge totally costed ${(Date.now()-t)/1e3}s`);let o=Pr.mergeInfo;J.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 nt(this,null,(function*(){let i=ft.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];On.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!==On.MODEL_LAYOUT_NAME){let i=n[e];i.directAssociatedLeafObjectSet||(i.directAssociatedLeafObjectSet=new Set),t=i.directAssociatedLeafObjectSet}let r=p[e],d=Pr.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();On.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,J.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===On.SNAP_GROUP_NAME));if(e&&t!==On.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=[]}J.debug(`[DxfLoader] MergeUtils.deepMerge costed ${Pr.mergeInfo.elapsedTime/1e3}s`),J.debug(`[DxfLoader] The remove operation of deep merge costed ${l/1e3}s`),J.debug(`[DxfLoader] Deep merge totally costed ${(Date.now()-r)/1e3}s`);let d=Pr.mergeInfo;J.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;J.debug("[DxfLoader] Entity types and cost times in ms:",this.entityTypesAndTimes),J.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&&J.debug(`[DxfLoader] Totally rebased ${this.statsInfo.rebasedEntityCount}(out of ${e}) entities`),this.enableMerge){let e=Pr.mergeInfo;J.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&&J.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&&this.font.unsupportedChars&&t(0,this.font.unsupportedChars)}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))}));J.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||Sn.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 Xs(e){return(Xs="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function pl(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function OH(e,t){if("object"!==Xs(e)||null===e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var n=i.call(e,t||"default");if("object"!==Xs(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}function rE(e){var t=OH(e,"string");return"symbol"===Xs(t)?t:String(t)}function bfe(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]:{};pl(this,e),this.init(t,i)}return ml(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||Glt,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 wfe(e,t,i){var n=VH(e,t,Object);n.obj[n.k]=i}function Wlt(e,t,i,n){var r=VH(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 CA(e,t){var i=VH(e,t),n=i.obj,r=i.k;if(n)return n[r]}function Sfe(e,t,i){var n=CA(e,i);return void 0!==n?n:CA(t,i)}function Nfe(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]):Nfe(e[n],t[n],i):e[n]=t[n]);return e}function Mv(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")}var Xlt={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};function Ylt(e){return"string"==typeof e?e.replace(/[&<>"'\/]/g,(function(e){return Xlt[e]})):e}var IA="undefined"!=typeof window&&window.navigator&&void 0===window.navigator.userAgentData&&window.navigator.userAgent&&window.navigator.userAgent.indexOf("MSIE")>-1,$lt=[" ",",","?","!",";"];function Klt(e,t,i){t=t||"",i=i||"";var n=$lt.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 Mfe(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 RA(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(null===l)return null;if(t.endsWith(o)){if("string"==typeof l)return l;if(o&&"string"==typeof l[o])return l[o]}var h=n.slice(a+s).join(i);return h?Bfe(l,h,i):void 0}r=r[n[a]]}return r}}var Qlt=function(e){Sv(i,ef);var t=Zlt(i);function i(e){var n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{ns:["translation"],defaultNS:"translation"};return pl(this,i),n=t.call(this),IA&&ef.call(uc(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 ml(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=CA(this.data,s);return o||!a||"string"!=typeof i?o:Bfe(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),wfe(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=CA(this.data,s)||{};n?Nfe(o,i,r):o=RA(RA({},o),i),wfe(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?RA(RA({},{}),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}(),Hfe={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 Rfe(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 va(e){for(var t=1;t1&&void 0!==arguments[1]?arguments[1]:{};return pl(this,i),n=t.call(this),IA&&ef.call(uc(n)),jlt(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,uc(n)),n.options=r,void 0===n.options.keySeparator&&(n.options.keySeparator="."),n.logger=gu.create("translator"),n}return ml(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||Klt(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"!==Xs(t)&&this.options.overloadTranslationOptionHandler&&(t=this.options.overloadTranslationOptionHandler(arguments)),t||(t={}),null==e)return"";Array.isArray(e)||(e=[String(e)]);var a=void 0!==t.returnDetails?t.returnDetails:this.options.returnDetails,s=void 0!==t.keySeparator?t.keySeparator:this.options.keySeparator,o=this.extractFromKey(e[e.length-1],t),l=o.key,h=o.namespaces,c=h[h.length-1],u=t.lng||this.language,d=t.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(u&&"cimode"===u.toLowerCase()){if(d){var p=t.nsSeparator||this.options.nsSeparator;return a?(f.res="".concat(c).concat(p).concat(l),f):"".concat(c).concat(p).concat(l)}return a?(f.res=l,f):l}var f=this.resolve(e,t),m=f&&f.res,g=f&&f.usedKey||l,v=f&&f.exactUsedKey||l,y=Object.prototype.toString.apply(m),x=void 0!==t.joinArrays?t.joinArrays:this.options.joinArrays,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,va(va({},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,M=w?[]:{},S=w?v:g;for(var E in m)if(Object.prototype.hasOwnProperty.call(m,E)){var T="".concat(S).concat(s).concat(E);M[E]=this.translate(T,va(va({},t),{joinArrays:!1,ns:h})),M[E]===T&&(M[E]=m[E])}m=M}}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),L=P?this.pluralResolver.getSuffix(u,t.count,t):"",D=t["defaultValue".concat(L)]||t.defaultValue;!this.isValidLookup(m)&&R&&(A=!0,m=D),this.isValidLookup(m)||(C=!0,m=l);var I=(t.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&C?void 0:m,O=R&&D!==m&&this.options.updateMissing;if(C||A||O){if(this.logger.log(O?"updateKey":"missingKey",u,c,l,O?D:m),s){var k=this.resolve(l,va(va({},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=[],F=this.languageUtils.getFallbackCodes(this.options.fallbackLng,t.lng||this.language);if("fallback"===this.options.saveMissingTo&&F&&F[0])for(var U=0;U1&&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,!Afe["".concat(f[0],"-").concat(e)]&&s.utils&&s.utils.hasLoadedNamespace&&!s.utils.hasLoadedNamespace(a)&&(Afe["".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="".concat(s.options.pluralSeparator,"zero");if(u&&(l.push(h+c),d&&l.push(h+f)),p){var m="".concat(h).concat(s.options.contextSeparator).concat(o.context);l.push(m),u&&(l.push(m+c),d&&l.push(m+f))}}for(;a=l.pop();)s.isValidLookup(t)||(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){for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&"defaultValue"===t.substring(0,12)&&void 0!==e[t])return!0;return!1}}]),i}();function UH(e){return e.charAt(0).toUpperCase()+e.slice(1)}var nct=function(){function e(t){pl(this,e),this.options=t,this.supportedLngs=this.options.supportedLngs||!1,this.logger=gu.create("languageUtils")}return ml(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]=UH(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]=UH(i[1].toLowerCase())),t.indexOf(i[2].toLowerCase())>-1&&(i[2]=UH(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}(),rct=[{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}],ict={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)}},sct=["v1","v2","v3"],Pfe={zero:0,one:1,two:2,few:3,many:4,other:5};function act(){var e={};return rct.forEach((function(t){t.lngs.forEach((function(i){e[i]={numbers:t.nr,plurals:ict[t.fc]}}))})),e}var oct=function(){function e(t){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};pl(this,e),this.languageUtils=t,this.options=i,this.logger=gu.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=act()}return ml(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 Pfe[e]-Pfe[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!sct.includes(this.options.compatibilityJSON)}}]),e}();function Ife(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 hc(e){for(var t=1;t0&&void 0!==arguments[0]?arguments[0]:{};pl(this,e),this.logger=gu.create("interpolator"),this.options=t,this.format=t.interpolation&&t.interpolation.format||function(e){return e},this.init(t)}return ml(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:Ylt,this.escapeValue=void 0===t.escapeValue||t.escapeValue,this.useRawValueToEscape=void 0!==t.useRawValueToEscape&&t.useRawValueToEscape,this.prefix=t.prefix?Mv(t.prefix):t.prefixEscaped||"{{",this.suffix=t.suffix?Mv(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?Mv(t.nestingPrefix):t.nestingPrefixEscaped||Mv("$t("),this.nestingSuffix=t.nestingSuffix?Mv(t.nestingSuffix):t.nestingSuffixEscaped||Mv(")"),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=Sfe(t,l,e);return o.alwaysFormat?o.format(r,void 0,i,hc(hc(hc({},n),t),{},{interpolationkey:e})):r}var a=e.split(o.formatSeparator),s=a.shift().trim(),h=a.join(o.formatSeparator).trim();return o.format(Sfe(t,l,s),h,i,hc(hc(hc({},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=Tfe(a));var h=t.safeValue(a);if(e=e.replace(r[0],h),d?(t.regex.lastIndex+=a.length,t.regex.lastIndex-=r[0].length):t.regex.lastIndex=0,++s>=o.maxReplaces)break}})),e}},{key:"nest",value:function(e,t){var i,n,r=this,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},s=hc({},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];var a=(r=this.interpolate(r,s)).match(/'/g),o=r.match(/"/g);(a&&a.length%2==0&&!o||o.length%2!=0)&&(r=r.replace(/'/g,'"'));try{s=JSON.parse(r),t&&(s=hc(hc({},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=Tfe(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,hc(hc({},a),{},{interpolationkey:i[1].trim()}))}),n.trim())),e=e.replace(i[0],n),this.regexp.lastIndex=0}return e}}]),e}();function Dfe(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 Qd(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=HH(e.split(":")),n=t[0],r=t.slice(1).join(":").trim().replace(/^'+|'+$/g,"");i[n.trim()]||(i[n.trim()]=r),"false"===r&&(i[n.trim()]=!1),"true"===r&&(i[n.trim()]=!0),isNaN(r)||(i[n.trim()]=parseInt(r,10))}}))}return{formatName:t,formatOptions:i}}function Rv(e){var t={};return function(i,n,r){var a=n+JSON.stringify(r),s=t[a];return s||(s=e(n,r),t[a]=s),s(i)}}var uct=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};pl(this,e),this.logger=gu.create("formatter"),this.options=t,this.formats={number:Rv((function(e,t){var i=new Intl.NumberFormat(e,t);return function(e){return i.format(e)}})),currency:Rv((function(e,t){var i=new Intl.NumberFormat(e,Qd(Qd({},t),{},{style:"currency"}));return function(e){return i.format(e)}})),datetime:Rv((function(e,t){var i=new Intl.DateTimeFormat(e,Qd({},t));return function(e){return i.format(e)}})),relativetime:Rv((function(e,t){var i=new Intl.RelativeTimeFormat(e,Qd({},t));return function(e){return i.format(e,t.range||"day")}})),list:Rv((function(e,t){var i=new Intl.ListFormat(e,Qd({},t));return function(e){return i.format(e)}}))},this.init(t)}return ml(e,[{key:"init",value:function(e){var t=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{interpolation:{}}).interpolation;this.formatSeparator=t.formatSeparator?t.formatSeparator:t.formatSeparator||","}},{key:"add",value:function(e,t){this.formats[e.toLowerCase().trim()]=t}},{key:"addCached",value:function(e,t){this.formats[e.toLowerCase().trim()]=Rv(t)}},{key:"format",value:function(e,t,i,n){var r=this;return t.split(this.formatSeparator).reduce((function(e,t){var a=cct(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,Qd(Qd(Qd({},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 Lfe(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 Ofe(e){for(var t=1;t3&&void 0!==arguments[3]?arguments[3]:{};return pl(this,i),a=t.call(this),IA&&ef.call(uc(a)),a.backend=e,a.store=n,a.services=r,a.languageUtils=r.languageUtils,a.options=s,a.logger=gu.create("backendConnector"),a.waitingReads=[],a.maxParallelReads=s.maxParallelReads||10,a.readingCalls=0,a.maxRetries=s.maxRetries>=0?s.maxRetries:5,a.retryTimeout=s.retryTimeout>=1?s.retryTimeout:350,a.state={},a.queue=[],a.backend&&a.backend.init&&a.backend.init(r,s.backend,s),a}return ml(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){Wlt(i.loaded,[r],a),fct(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=i.loaded[e];t.length&&t.forEach((function(t){void 0===s[e][t]&&(s[e][t]=!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]:this.retryTimeout,s=arguments.length>5?arguments[5]:void 0;return e.length?this.readingCalls>=this.maxParallelReads?void this.waitingReads.push({lng:e,ns:t,fcName:i,tried:r,wait:a,callback:s}):(this.readingCalls++,this.backend[i](e,t,(function(o,l){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)}o&&l&&r2&&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,Ofe(Ofe({},a),{},{isUpdate:r})),e&&e[0]&&this.store.addResource(e[0],t,i,n))}}]),i}();function mct(){return{debug:!1,initImmediate:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!0,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:function(e){var t={};if("object"===Xs(e[1])&&(t=e[1]),"string"==typeof e[1]&&(t.defaultValue=e[1]),"string"==typeof e[2]&&(t.tDescription=e[2]),"object"===Xs(e[2])||"object"===Xs(e[3])){var 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 kfe(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 Ffe(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 mu(e){for(var t=1;t0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0;if(pl(this,i),e=t.call(this),IA&&ef.call(uc(e)),e.options=kfe(n),e.services={},e.logger=gu,e.modules={external:[]},yct(uc(e)),r&&!e.isInitialized&&!n.isClone){if(!e.options.initImmediate)return e.init(n,r),cm(e,uc(e));setTimeout((function(){e.init(n,r)}),0)}return e}return ml(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&&!1!==t.defaultNS&&t.ns&&("string"==typeof t.ns?t.defaultNS=t.ns:t.ns.indexOf("translation")<0&&(t.defaultNS=t.ns[0]));var n=mct();function r(e){return e?"function"==typeof e?new e:e:null}if(this.options=mu(mu(mu({},n),this.options),kfe(t)),"v1"!==this.options.compatibilityAPI&&(this.options.interpolation=mu(mu({},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?gu.init(r(this.modules.logger),this.options):gu.init(null,this.options),this.modules.formatter?a=this.modules.formatter:"undefined"!=typeof Intl&&(a=uct);var s=new nct(this.options);this.store=new Qlt(this.options.resources,this.options);var o=this.services;o.logger=gu,o.resourceStore=this.store,o.languageUtils=s,o.pluralResolver=new oct(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 lct(this.options),o.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},o.backendConnector=new pct(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=sE(),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]:AA,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)}))};n?a(n):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=sE();return e||(e=this.languages),t||(t=this.options.ns),i||(i=AA),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&&Hfe.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=sE();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"!==Xs(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=sE();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=sE();"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]:AA,r=mu(mu(mu({},this.options),t),{isClone:!0}),a=new i(r);return(void 0!==t.debug||void 0!==t.prefix)&&(a.logger=a.logger.clone(t)),["store","services","language"].forEach((function(t){a[t]=e[t]})),a.services=mu({},this.services),a.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},a.translator=new Cfe(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 ya=PA.createInstance();ya.createInstance=PA.createInstance;var AUt=ya.createInstance,CUt=ya.init,PUt=ya.loadResources,IUt=ya.reloadResources,DUt=ya.use,LUt=ya.changeLanguage,OUt=ya.getFixedT,vu=ya.t,kUt=ya.exists,FUt=ya.setDefaultNamespace,NUt=ya.hasLoadedNamespace,BUt=ya.loadNamespaces,HUt=ya.loadLanguages,um=ya,tf=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)}},qi=Xi(ac(),1);function Av(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 DA=(e=>(e[e.ClickEvent=1]="ClickEvent",e[e.Popup=2]="Popup",e[e.SubMenu=3]="SubMenu",e[e.Switch=4]="Switch",e))(DA||{}),aE=(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))(aE||{}),Ufe=[["HomeView","OrthoMode","FullScreen","ZoomToRectangle","GetScreenshot"],["Measure","Markup","MarkupVisibility","Section"],["BimTree","Viewpoint","Annotation","Property","Compared","QuitCompare","Layers"],["Settings"]],yu=class{constructor(e,t,i=[...Ufe]){this.bimViewer=e,this.menuConfig=t,this.groupConfig=i,this.visible=!0,this.menuList=new Map,this.keydown=e=>{var t,i;if(this.visible&&"Escape"===e.code){if(null!=(t=this.bimViewer.measurePlugin)&&t.isMeasuring()||null!=(i=this.bimViewer.getMarkupManager())&&i.isMarkupActive())return;this.clearActive()}},this.init(),window.addEventListener("keydown",this.keydown,!1)}init(){var e;let t=document.createElement("div");t.classList.add("toolbar"),this.groupConfig.forEach(((e,i)=>{let n=document.createElement("div");n.classList.add("toolbar-group");let r=document.createElement("div");r.classList.add("toolbar-group-division"),e.forEach((e=>{let t=(0,qi.get)(this.menuConfig,e);if(t&&!1!==t.visible){let i=this.createToolbarMenu(this.bimViewer,e,t);n.appendChild(i.element)}})),n.hasChildNodes()&&(i&&t.appendChild(r),t.appendChild(n))})),this.element=t,null==(e=this.bimViewer.widgetContainer)||e.appendChild(t),t.oncontextmenu=e=>{e.preventDefault()}}clearActive(){if(this.activateMenuId){let e=this.menuList.get(this.activateMenuId);null==e||e.setActive(!1),this.activateMenuId=void 0}}setActive(e,t){let i=this.menuList.get(e);null==i||i.setActive(t),this.activateMenuId=t?e:void 0}createToolbarMenu(e,t,i,n){let r=new zH(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,qi.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,qi.assign)(this.menuConfig[e],t),this.refresh()}updateMenus(e){(0,qi.forEach)(e,(({menuId:e,config:t})=>{(0,qi.assign)(this.menuConfig[e],t)})),this.refresh()}addMenu(e,t,i){if((0,qi.keys)(this.menuConfig).includes(e))J.error("[Toolbar]",e,"exists.");else{if((0,qi.assign)(this.menuConfig,{[e]:t}),i){let[t,n]=i;if(t>this.groupConfig.length-1)this.groupConfig=(0,qi.concat)(this.groupConfig,[[e]]);else{let i=this.groupConfig[t];this.groupConfig[t]=n>i.length-1?(0,qi.concat)(i,e):(0,qi.concat)((0,qi.take)(i,n),e,(0,qi.takeRight)(i,i.length-n))}}else this.groupConfig=(0,qi.concat)(this.groupConfig,[[e]]);this.refresh()}}refresh(){this.element&&this.element.remove(),this.element=void 0,this.menuList.clear(),this.init()}show(){this.element&&(this.element.style.display=""),this.visible=!0}hide(){this.element&&(this.element.style.display="none"),this.visible=!1}destroy(){this.element&&this.element.remove(),this.element=void 0,this.menuList.clear(),window.removeEventListener("keydown",this.keydown,!1)}},zH=class{constructor(e,t,i,n,r){this.bimViewer=e,this.toolbar=t,this.menuId=i,this.eventBus=Av(),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,qi.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&&_R(this.element.firstChild.classList,n.icon,this.active),r&&r.setActive(t)})),dn.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=ev}=i.icon;return n.innerHTML=`
`,n.title=vu(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)}},Vfe={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=vn.rgba2Color(e.getMarkupLineColor()),a.click(),a.oninput=t=>{let i=t.target.value;e.setMarkupLineColor(...vn.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=vu(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=vu(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=>{J.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=vu(i.menuName),n.innerHTML+=`${n.title}`,n},onClick:(e,t)=>{var i;e.deactivateMarkup(),t.destroy(),null==(i=e.toolbar)||i.show()},type:1,menuName:"Toolbar.quitMarkup"}},xct=[["Arrow","Rect","CloudRect","PolyLine","Ellipse","Circle","Text","StrokeStyle","FontSize","MarkupClear","MarkupQuit"]],LA=class extends yu{constructor(e,t,i=[...xct]){super(e,t,i),this.keydown=()=>{}}},Cv=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(y5,this.start),n.addEventListener(v5,this.stop),document.body.addEventListener(Gd,this.follow),this.container.appendChild(this.element)}destroy(){document.body.removeEventListener(Gd,this.follow),this.element.removeEventListener(y5,this.start),this.element.removeEventListener(v5,this.stop),this.element.remove()}},xa=new P(1,0,0),nf=new P(0,1,0),rf=new P(0,0,1),zfe=new P(0,1,0),oE=new qe,Pv=2,dc=class extends Ln{constructor(e=xa){super(),this.redMaterial=new jt({color:16711680,depthTest:!1}),this.greenMaterial=new jt({color:65280,depthTest:!1}),this.blueMaterial=new jt({color:255,depthTest:!1}),this.highlightMaterial=new jt({color:16776960,depthTest:!1}),this.pickableMaterial=new jt({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 Xn;t.setFromUnitVectors(xa,e),this.applyQuaternion(t)}initOrUpdateByAxis(e){this.clear(),[{actionType:"TranslateX",direction:xa,material:this.redMaterial},{actionType:"TranslateY",direction:nf,material:this.greenMaterial},{actionType:"TranslateZ",direction:rf,material:this.blueMaterial}].forEach((t=>{let{actionType:i,direction:n,material:r}=t,a=this.createTranslateGizmo(i,n,Pv,0===n.angleTo(e)?r:this.pickableMaterial);this.add(a)})),[{actionType:"RotateX",direction:xa,material:this.redMaterial,degree:90},{actionType:"RotateY",direction:nf,material:this.greenMaterial,degree:90},{actionType:"RotateZ",direction:rf,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,Pv,r,a);this.add(e)}})),this.createSphere(1,this.pickableMaterial),this.createSphere(1,this.pickableMaterial,new P(12*Pv,0,0)),this.createSphere(1,this.pickableMaterial,new P(0,12*Pv,0)),this.createSphere(1,this.pickableMaterial,new P(0,0,12*Pv))}createTranslateGizmo(e,t,i,n){let r=t.angleTo(zfe),a=zfe.clone().cross(t);oE.makeRotationAxis(a,r);let s=new Zl(i/5,i/5,20*i),o=10*i;s.translate(0,o,0),s.applyMatrix4(oE);let l=new Zl(0,i,3*i),h=2*o;l.translate(0,h,0),l.applyMatrix4(oE);let c=$i([l,s]),u=new ht(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 P(0,0,1),s=t.clone().cross(a),o=t.angleTo(a);oE.makeRotationAxis(s,o);let l=new Cd(12*i,i/5,24,36,gn.degToRad(r));l.applyMatrix4(oE);let h=new ht(l,n);return h.layers.enable(12),h.userData.actionType=e,h}createSphere(e,t,i=new P){let n=new da(e,32,16),r=new ht(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=nf;break;case"RotateZ":t=rf}return this.createRotateGizmo("",t,Pv,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 P;this.getWorldPosition(t);let i=e.position,n=1;e instanceof Er?n=(e.top-e.bottom)/e.zoom:e instanceof jn&&(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)}},sf=class{constructor(e,t){if(this.raycaster=new Is,this.sectionBox=new bt,this.mouseDown=!1,this.lastWorldPos=new P,this.mouseMoved=!1,this.dragStarted=!1,this.refrencePlane=new Mr,this.active=!1,this.isShowSectionPlane=!1,this.mousedown=e=>{if(0===e.button){if(dn.isMobile){let t=this.getIntersections(e);t?(this.inputManager.setCursor("grab"),this.selectedObject=t.object,this.activateSelectedObject(!0),this.enableDefaultControl(!1),this.viewer.enableRender()):this.enableDefaultControl(!0)}this.camera&&this.selectedObject&&(this.inputManager.setCursor("grabbing"),this.mouseDown=!0)}},this.mousemove=e=>{if(this.dragStarted)this.updateRaycasterByMouse(e),this.inputManager.setCursor("grabbing"),this.onDragMove(e);else{this.activateSelectedObject(!1);let t=this.getIntersections(e);t?(this.inputManager.setCursor("grab"),this.selectedObject=t.object,this.activateSelectedObject(!0),this.mouseDown&&(this.dragStarted||(this.dragStarted=!0,this.enableDefaultControl(!1),this.onDragStart(e)))):(this.inputManager.setCursor("default"),this.selectedObject=void 0)}this.viewer.enableRender()},this.mouseup=e=>{0===e.button&&(this.activateSelectedObject(!1),this.mouseDown&&this.dragStarted&&(this.inputManager.setCursor("grab"),this.onDragEnd(e),this.dragStarted=!1,this.enableDefaultControl(!0)),this.mouseDown=!1,this.selectedObject=void 0)},this.keydown=e=>{"Escape"===e.code&&this.deactivate()},!(e.camera&&e.renderer&&e.controls&&e.scene))throw new Error("Invalid bimViewer!");this.viewer=e,this.inputManager=t,this.scene=e.scene,this.renderer=e.renderer,this.raycaster.layers.set(12)}get canvas(){var e;return null==(e=this.viewer.renderer)?void 0:e.domElement}get isActive(){return!!this.active}get camera(){return this.viewer.camera}get controls(){return this.viewer.controls}setGlobalClippingEnable(e){if(!this.clipPlanes)return;let t=e?this.clipPlanes:[];this.renderer.localClippingEnabled=e,this.renderer.clippingPlanes=t}setObjectClippingEnable(e){var t,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.setObjectClippingEnable(!1),this.clippingObjetIds=[]}setClippingEnable(e){var t;null!=(t=this.clippingObjetIds)&&t.length?(this.setGlobalClippingEnable(!1),this.setObjectClippingEnable(e)):this.setGlobalClippingEnable(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.enableDefaultControl(!0)}enableDefaultControl(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 dc))||t[0]}updateRaycasterByMouse(e){if(!this.raycaster)return;let t=new fe(e.x,e.y),i=$t.screenPoint2NdcPoint(t,this.camera,this.canvas);this.raycaster.setFromCamera(i,this.camera)}destroy(){this.deactivate()}},qfe=new bt,jfe=new Xn,OA=class extends ht{constructor(e,t){super(),this.vertices=[],this.layers.enable(12),this.actionType=e,this.geometry=new Et,this.vertices=t,this.geometry.setFromPoints(t),this.geometry.setIndex([0,1,2,0,2,3]),this.material=new jt({depthTest:!1,color:OA.normalPlaneColor,transparent:!0,opacity:.01,side:or}),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 Et;t.setFromPoints(e),t.setIndex([0,1,1,2,2,3,3,0]);let i=new En({color:OA.normalLineColor});return this.createIgnoreClipMaterials(i),new Wn(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();jfe.setFromAxisAngle(e,t),this.vertices=this.vertices.map((e=>e.sub(i).applyQuaternion(jfe).add(i))),this.update(this.vertices)}setDirection(e){let t=new Xn;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 P;return Vr.getNormal(e,t,i,n),n}setActive(e){this.material.opacity=e?.1:.01}getPlaneCenter(){qfe.setFromPoints(this.vertices);let e=new P;return qfe.getCenter(e),e}},ui=OA;ui.normalPlaneColor=new Ye(0,.855,.718),ui.activePlaneColor=new Ye(1,1,0),ui.normalLineColor=16777215;var Wfe=(e=>(e.X="X",e.Y="Y",e.Z="Z",e))(Wfe||{}),kA=class extends sf{constructor(e,t){super(e,t),this.activeAxis="X",this.center=new P,this.axisInfoMap={X:{normal:new P(1,0,0)},Y:{normal:new P(0,1,0)},Z:{normal:new P(0,0,1)}},this.viewer.addEventListener("AfterRender",(()=>{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.setClippingEnable(!1),this.planeMesh=void 0,this.gizmo=void 0,this.setActiveAxis("X")}setActiveAxis(e){this.activeAxis=e,this.initOrUpdateGizmo(),this.initOrUpdateSectionPlane(),this.initOrUpdateClipPlane(),this.setClippingEnable(!0),this.viewer.enableRender()}setSectionVisible(e){this.gizmo&&this.planeMesh&&(this.gizmo.visible=e,this.planeMesh.visible=e),this.isShowSectionPlane=e,this.viewer.enableRender()}initOrUpdateClipPlane(){switch(this.activeAxis){case"X":this.clipPlane=new Mr(new P(-1,0,0),this.center.x);break;case"Y":this.clipPlane=new Mr(new P(0,-1,0),this.center.y);break;case"Z":this.clipPlane=new Mr(new P(0,0,-1),this.center.z)}this.clipPlane&&(this.clipPlanes=[this.clipPlane])}initOrUpdateSectionPlane(){var e;let t=new P;this.sectionBox.getSize(t);let i=t.length(),n=this.center,r=(new bt).setFromCenterAndSize(n,new P(i,i,i)),{min:a,max:s}=r;switch(null==(e=this.planeMesh)||e.removeFromParent(),this.activeAxis){case"X":this.planeMesh=new ui("X",[new P(n.x,s.y,a.z),new P(n.x,s.y,s.z),new P(n.x,a.y,s.z),new P(n.x,a.y,a.z)]);break;case"Y":this.planeMesh=new ui("Y",[new P(s.x,n.y,a.z),new P(a.x,n.y,a.z),new P(a.x,n.y,s.z),new P(s.x,n.y,s.z)]);break;case"Z":this.planeMesh=new ui("Z",[new P(s.x,s.y,n.z),new P(a.x,s.y,n.z),new P(a.x,a.y,n.z),new P(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;this.gizmo=new dc,this.gizmo.setDirection(i),this.sectionBox.getCenter(this.gizmo.position),null==(t=this.scene)||t.add(this.gizmo)}onDragStart(e){var t;if(this.selectedObject instanceof ui)return;J.info("[AxisPlaneSection] onDragStart:",e);let i=new P;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 ui)return;let r=new P;null==(t=this.raycaster)||t.ray.intersectPlane(this.refrencePlane,r);let a=this.selectedObject.userData.actionType,s=(new P).subVectors(this.lastWorldPos,this.center).normalize(),o=(new P).subVectors(r,this.center).normalize(),l=(new P).subVectors(r,this.lastWorldPos).projectOnVector(xa.clone().applyQuaternion(this.gizmo.quaternion)),h=s.angleTo(o),c=(new P).crossVectors(s,o),u=new P;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 P).addVectors(this.gizmo.position,l),this.sectionBox.clone().setFromCenterAndSize(this.center,new P(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=nf.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=rf.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 ui||J.info("[AxisPlaneSection] onDragEnd:",e)}getIntersectObjects(){return this.planeMesh&&this.gizmo?[this.planeMesh,this.gizmo]:[]}activateSelectedObject(e){this.selectedObject&&(this.selectedObject instanceof ui?this.selectedObject.setActive(e):this.selectedObject.parent instanceof dc&&this.selectedObject.parent.setActive(e,this.selectedObject))}},FA=class extends Cv{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(ev),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.setSectionVisible(this.isVisible)}}},NA=class extends Cv{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.setSectionVisible(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")}},GH=Xi(ac(),1),vl=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(Gd,this.follow):document.removeEventListener(Gd,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(Gd,this.follow):document.addEventListener(Gd,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,GH.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,GH.forEach)(this.childNode.children,(e=>{this.childNode.removeChild(e)})),this.childNode.append(e)}},yl=(e=>(e.Distance="Distance",e.Area="Area",e.Angle="Angle",e.Coordinate="Coordinate",e))(yl||{}),xu=class extends zi{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.raycaster,this.lastMouseDownPosition),J.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);dn.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.raycaster,this.lastMouseDownPosition),J.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=()=>{J.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);J.debug(`[BaseMeasurement] The count of raycastable object is ${t.length}`,t);let i=Date.now(),n=this.raycaster.intersectObjects(t,!0)||[];return J.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(dn.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 vl("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;dn.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(dn.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")}},Ys=class extends mi{constructor(e,t){super(e),this.type="Distance",this.labelBounds=new Pi,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=Ys.MAJOR_COLOR,e.strokeStyle=Ys.MINOR_COLOR,e.lineWidth=Ys.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+Ys.POINT_RADIUS,n.y),e.arc(n.x,n.y,Ys.POINT_RADIUS,0,2*Math.PI)})),e.closePath(),e.fill(),e.stroke(),e.restore()}drawText(e,t){if(!this.label||!this.labelPositon)return;e.font=`${Ys.LABEL_FONT_SIZE}px Arial`;let i=1.2*e.measureText(this.label).width,n=1.5*Ys.LABEL_FONT_SIZE;this.labelBounds.setFromCenterAndSize(this.labelPositon,new fe(i,n)),this.drawRoundRect(e,this.labelPositon.x-i/2,this.labelPositon.y-n/2,i,n,4),e.save(),e.fillStyle=Ys.MINOR_COLOR,e.textBaseline="middle",e.textAlign="center",e.fillText(this.label,this.labelPositon.x,this.labelPositon.y),e.restore()}drawRoundRect(e,t,i,n,r,a){n<2*a&&(a=n/2),r<2*a&&(a=r/2),e.save(),e.fillStyle=Ys.MAJOR_COLOR,e.strokeStyle=Ys.MINOR_COLOR,e.lineWidth=Ys.LINE_WIDTH,e.beginPath(),e.moveTo(t+a,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 bt).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 bt).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(vn.colorStr2Rgba(Ys.MAJOR_COLOR)),this.setFillColor(vn.colorStr2Rgba(Ys.AREA_FILL_COLOR)),this.setLineWidth(Ys.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 P,s=new P,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 fe).subVectors(i,n).normalize(),s=(new fe).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=`${ru(s,2)} ${this.getUnitString()}`;let o=.3*Math.min(i.distanceTo(n),r.distanceTo(n));this.labelPositon=this.transToScreenCoord(n.clone().add(new P(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 P(n.x-r.x,n.y-r.y,n.z-r.z).normalize(),o=new P(a.x-r.x,a.y-r.y,a.z-r.z).normalize();return new P(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 P(n.x-r.x,n.y-r.y,n.z-r.z),o=new P(a.x-r.x,a.y-r.y,a.z-r.z);return 180*s.angleTo(o)/Math.PI}getClassType(){return"Angle"}};_n._registerDrawableClass(lE);var BA=class extends xu{constructor(e,t,i,n){super("Angle",e,t,i,n)}createMeasureDrawable(){if(this.drawingPoints)return new lE(ft.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]&&Nt.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))}},cE=class extends pr{constructor(e,t){super(e,t),this.type="Area",this.update(t)}draw(e,t){let i=this.points;if(e.save(),e.lineWidth=pr.LINE_WIDTH,e.strokeStyle=pr.MAJOR_COLOR,e.fillStyle=pr.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.label=`${ru(n,2)}`,this.labelPositon=this.transToScreenCoord(this.getBarycenter(i),t),super.drawText(e,t)}calculateArea(e){let t=0,i=Xp.getFaces(e);for(let n=0;n{i+=e.x,n+=e.y,r+=e.z})),new P(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 P,s=new P,o=this.points;for(let h=0;hn.far&&(e=e.clone().sub(t).normalize().multiplyScalar(.9*n.far),console.warn("[BimViewer] 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 P(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 P(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 P;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 P(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()}},Xfe=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)&&Di.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)&&Di.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 Qn)s=s.clone();else if(Array.isArray(s)){let e=[];s.forEach((t=>e.push(t.clone()))),s=e}let o=new _i(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 Ut.geometryEquals(e,t)}},af=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])}},uE=class extends Fp{constructor(e){super(e)}parse(e){e.length<19&&console.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++]};(function(e){switch(e.image_type){case 1:case 9:(e.colormap_length>256||24!==e.colormap_size||1!==e.colormap_type)&&console.error("THREE.TGALoader: Invalid type colormap data for indexed type.");break;case 2:case 3:case 10:case 11:e.colormap_type&&console.error("THREE.TGALoader: Invalid type colormap data for colormap type.");break;case 0:console.error("THREE.TGALoader: No data.");default:console.error('THREE.TGALoader: Invalid type "%s".',e.image_type)}(e.width<=0||e.height<=0)&&console.error("THREE.TGALoader: Invalid image size."),8!==e.pixel_size&&16!==e.pixel_size&&24!==e.pixel_size&&32!==e.pixel_size&&console.error('THREE.TGALoader: Invalid pixel size "%s".',e.pixel_size)})(n),n.id_length+t>e.length&&console.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:console.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:console.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:ca}}},UA=class extends er{constructor(e){super(e)}load(e,t,i,n){let r=this,a=""===r.path?Ps.extractUrlBase(e):r.path,s=new Cr(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 Na(n+".position",r,a)),s.length>0&&t.push(new fa(n+".quaternion",r,s)),o.length>0&&t.push(new Na(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)?Ze: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?li:oi,n.wrapT=e.wrapV?li:oi,n.offset.set(e.offsetU||0,e.offsetV||0),n.repeat.set(e.repeatU||1,e.repeatV||1)}else n.wrapS=li,n.wrapT=li;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,zt));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,zt));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,zt))}}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?or:Xr;break;case"bump":t.normalMap=r(n.texture),t.normalScale=new fe(1,1)}}}return t}function J(e){return c(tt.materials[e],Y)}function Z(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 Rt(r.array,r.stride)),a.array.length>0&&u.setAttribute("normal",new Rt(a.array,a.stride)),l.array.length>0&&u.setAttribute("color",new Rt(l.array,l.stride)),s.array.length>0&&u.setAttribute("uv",new Rt(s.array,s.stride)),o.array.length>0&&u.setAttribute("uv1",new Rt(o.array,o.stride)),h.length>0&&u.setAttribute("skinIndex",new Rt(h,4)),c.length>0&&u.setAttribute("skinWeight",new Rt(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 ye(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,zt).catch(i)}decodeDracoFile(e,t,i,n,r=ua){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(qH.has(e)){let t=qH.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)})),qH.set(e,{key:i,promise:s}),s}_createGeometry(e){let t=new Et;e.index&&t.setIndex(new nn(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=bct.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 Yfe=function(e){return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))},Ect=function(e){return new Worker(e)};try{URL.revokeObjectURL(Yfe(""))}catch(e){Yfe=function(e){return"data:application/javascript;charset=UTF-8,"+encodeURI(e)},Ect=function(e){return new Worker(e,{type:"module"})}}var xl=Uint8Array,of=Uint16Array,XH=Uint32Array,$fe=new xl([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Kfe=new xl([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),_ct=new xl([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Zfe=function(e,t){for(var i=new of(31),n=0;n<31;++n)i[n]=t+=1<>>1|(21845&Gr)<<1,_h=(52428&_h)>>>2|(13107&_h)<<2,_h=(61680&_h)>>>4|(3855&_h)<<4,YH[Gr]=((65280&_h)>>>8|(255&_h)<<8)>>>1;var _h,Gr,hE=function(e,t,i){for(var n=e.length,r=0,a=new of(t);r>>l]=h}else for(s=new of(n),r=0;r>>15-e[r]);return s},dE=new xl(288),Gr,Gr,Gr;for(Gr=0;Gr<144;++Gr)dE[Gr]=8;for(Gr=144;Gr<256;++Gr)dE[Gr]=9;for(Gr=256;Gr<280;++Gr)dE[Gr]=7;for(Gr=280;Gr<288;++Gr)dE[Gr]=8;var Gr,tpe=new xl(32),Gr;for(Gr=0;Gr<32;++Gr)tpe[Gr]=5;var Sct=hE(dE,9,1),Mct=hE(tpe,5,1),jH=function(e){for(var t=e[0],i=1;it&&(t=e[i]);return t},fc=function(e,t,i){var n=t/8|0;return(e[n]|e[n+1]<<8)>>(7&t)&i},WH=function(e,t){var i=t/8|0;return(e[i]|e[i+1]<<8|e[i+2]<<16)>>(7&t)},Rct=function(e){return(e/8|0)+(7&e&&1)},Act=function(e,t,i){(null==t||t<0)&&(t=0),(null==i||i>e.length)&&(i=e.length);var n=new(e instanceof of?of:e instanceof XH?XH:xl)(i-t);return n.set(e.subarray(t,i)),n},Cct=function(e,t,i){var n=e.length;if(!n||i&&!i.l&&n<5)return t||new xl(0);var r=!t||i,a=!i||i.i;i||(i={}),t||(t=new xl(3*n));var s=function(e){var i=t.length;if(e>i){var n=new xl(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=fc(e,l,1);var m=fc(e,l+1,3);if(l+=3,!m){var g=e[(A=Rct(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=Sct,u=Mct,d=9,p=5;else{if(2!=m)throw"invalid block type";var y=fc(e,l,31)+257,x=fc(e,l+10,15)+4,b=y+fc(e,l+5,31)+1;l+=14;for(var _=new xl(b),w=new xl(19),M=0;M>>4)<16)_[M++]=A;else{var P=0,R=0;for(16==A?(R=3+fc(e,l,3),l+=2,P=_[M-1]):17==A?(R=3+fc(e,l,7),l+=3):18==A&&(R=11+fc(e,l,127),l+=7);R--;)_[M++]=P}}var L=_.subarray(0,y),D=_.subarray(y);d=jH(L),p=jH(D),c=hE(L,d,1),u=hE(D,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 F=N-254;if(N>264){var U=$fe[M=N-257];F=fc(e,l,(1<>>4;if(!B)throw"invalid distance";if(l+=15&B,D=wct[z],z>3&&(U=Kfe[z],D+=WH(e,l)&(1<f){if(a)throw"unexpected EOF";break}r&&s(h+131072);for(var H=h+F;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 npe(e,t){return Cct((Ict(e),e.subarray(2,-4)),t)}var Dct="undefined"!=typeof TextDecoder&&new TextDecoder,Lct=0;try{Dct.decode(Pct,{stream:!0}),Lct=1}catch(e){}function rpe(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 Nct(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 mr.Objects){let i=mr.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?li:oi,i.wrapT=0===s?li:oi,"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=Ki.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 Rr):(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 Rr):a=this.textureLoader.load(i);return this.textureLoader.setPath(n),a}parseMaterials(e){let t=new Map;if("Material"in mr.Objects){let i=mr.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),!Ki.has(i))return null;let a,s=this.parseParameters(e,t,i);switch(r.toLowerCase()){case"phong":a=new Cs;break;case"lambert":a=new $c;break;default:console.warn('THREE.FBXLoader: unknown material type "%s". Defaulting to MeshPhongMaterial.',r),a=new Cs}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 Ye).fromArray(e.Diffuse.value).convertSRGBToLinear():e.DiffuseColor&&("Color"===e.DiffuseColor.type||"ColorRGB"===e.DiffuseColor.type)&&(n.color=(new Ye).fromArray(e.DiffuseColor.value).convertSRGBToLinear()),e.DisplacementFactor&&(n.displacementScale=e.DisplacementFactor.value),e.Emissive?n.emissive=(new Ye).fromArray(e.Emissive.value).convertSRGBToLinear():e.EmissiveColor&&("Color"===e.EmissiveColor.type||"ColorRGB"===e.EmissiveColor.type)&&(n.emissive=(new Ye).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 Ye).fromArray(e.Specular.value).convertSRGBToLinear():e.SpecularColor&&"Color"===e.SpecularColor.type&&(n.specular=(new Ye).fromArray(e.SpecularColor.value).convertSRGBToLinear());let r=this;return Ki.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=zt);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=zt);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=Mp,n.envMap.colorSpace=zt);break;case"SpecularColor":n.specularMap=r.getTexture(t,e.ID),void 0!==n.specularMap&&(n.specularMap.colorSpace=zt);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 mr.Objects&&t in mr.Objects.LayeredTexture&&(console.warn("THREE.FBXLoader: layered textures are not supported in three.js. Discarding all but first layer."),t=Ki.get(t).children[0].ID),e.get(t)}parseDeformers(){let e={},t={};if("Deformer"in mr.Objects){let i=mr.Objects.Deformer;for(let n in i){let r=i[n],a=Ki.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 qe).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 Cs({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 jc(r,a),n.normalizeSkinWeights()):n=new ht(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 En({name:er.DEFAULT_MATERIAL_NAME,color:3342591,linewidth:1});return new Wn(i,n)}getTransformData(e,t){let i={};"InheritType"in t&&(i.inheritType=parseInt(t.InheritType.value)),i.eulerOrder="RotationOrder"in t?cpe(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&&Ki.get(e.ID).children.forEach((function(t){if("LookAtProperty"===t.relationship){let i=mr.Objects.Model[t.ID];if("Lcl_Translation"in i){let t=i.Lcl_Translation.value;void 0!==e.target?(e.target.position.fromArray(t),Ya.add(e.target)):e.lookAt((new P).fromArray(t))}}}))}bindSkeleton(e,t,i){let n=this.parsePoseNodes();for(let r in e){let a=e[r];Ki.get(parseInt(a.ID)).parents.forEach((function(e){if(t.has(e.ID)){let t=e.ID;Ki.get(t).parents.forEach((function(e){i.has(e.ID)&&i.get(e.ID).bind(new nl(a.bones),n[e.ID])}))}}))}}parsePoseNodes(){let e={};if("Pose"in mr.Objects){let t=mr.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 qe).fromArray(t.Matrix.a)})):e[n.Node]=(new qe).fromArray(n.Matrix.a)}}return e}createAmbientLight(){if("GlobalSettings"in mr&&"AmbientColor"in mr.GlobalSettings){let e=mr.GlobalSettings.AmbientColor.value,t=e[0],i=e[1],n=e[2];if(0!==t||0!==i||0!==n){let e=new Ye(t,i,n).convertSRGBToLinear();Ya.add(new il(e,1))}}}},JH=class{constructor(){this.negativeMaterialIndices=!1}parse(e){let t=new Map;if("Geometry"in mr.Objects){let i=mr.Objects.Geometry;for(let n in i){let r=Ki.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 mr.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=cpe(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=lpe(l);return this.genGeometry(t,s,r,h)}genGeometry(e,t,i,n){let r=new Et;e.attrName&&(r.name=e.attrName);let a=this.parseGeoNode(e,t),s=this.genBuffers(a),o=new Rt(s.vertex,3);if(o.applyMatrix4(n),r.setAttribute("position",o),s.colors.length>0&&r.setAttribute("color",new Rt(s.colors,3)),t&&(r.setAttribute("skinIndex",new Rp(s.weightsIndices,4)),r.setAttribute("skinWeight",new Rt(s.vertexWeights,4)),r.FBX_Deformer=t),s.normal.length>0){let e=(new pn).getNormalMatrix(n),t=new Rt(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 Rt(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=GA(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=GA(p,i,d,e.normal);s.push(t[0],t[1],t[2])}e.material&&"AllSame"!==e.material.mappingType&&(f=GA(p,i,d,e.material)[0],f<0&&(u.negativeMaterialIndices=!0,f=0)),e.uv&&e.uv.forEach((function(e,t){let n=GA(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 Ba(e.name,-1,t)}generateTracks(e){let t=[],i=new P,n=new Xn,r=new P;if(e.transform&&e.transform.decompose(i,n,r),i=i.toArray(),n=(new Dn).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 Na(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(gn.degToRad)),void 0!==t.y&&(this.interpolateRotations(t.y),t.y.values=t.y.values.map(gn.degToRad)),void 0!==t.z&&(this.interpolateRotations(t.z),t.z.values=t.z.values.map(gn.degToRad));let s=this.getTimesForAllAxes(t),o=this.getKeyframeTrackValues(s,t,i);void 0!==n&&((n=n.map(gn.degToRad)).push(a),n=(new Dn).fromArray(n),n=(new Xn).setFromEuler(n)),void 0!==r&&((r=r.map(gn.degToRad)).push(a),r=(new Dn).fromArray(r),r=(new Xn).setFromEuler(r).invert());let l=new Xn,h=new Dn,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],jct(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=KH(r))}else this.parseNodeSpecialProperty(e,n,r)}parseNodePropertyContinued(e){let t=this.getCurrentNode();t.a+=e,","!==e.slice(-1)&&(t.a=KH(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=KH(l)}this.getPrevNode()[r]={type:a,type2:s,flag:o,value:l},this.setCurrentProp(this.getPrevNode(),r)}},tU=class{parse(e){let t=new jA(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 WA;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=npe(new Uint8Array(e.getArrayBuffer(a))),o=new jA(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)}}},jA=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)}},WA=class{add(e,t){this[e]=t}};function Vct(e){return e.byteLength>=21&&"Kaydara FBX Binary \0"===upe(e,0,21)}function zct(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 AU(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 Xct(){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 Ir={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"},sU=class{constructor(e){this.parser=e,this.name=Ir.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)}},vU=class{constructor(e){this.parser=e,this.name=Ir.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}},yU=class{constructor(e){this.parser=e,this.name=Ir.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}},xU=class{constructor(e){this.name=Ir.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}},bU=class{constructor(e){this.name=Ir.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!==bl.TRIANGLES&&o.mode!==bl.TRIANGLE_STRIP&&o.mode!==bl.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 qe,t=new P,i=new Xn,o=new P(1,1,1),l=new _i(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 tut=new qe,AU=class{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new Xct,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 rs(this.options.manager):this.textureLoader=new kx(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new Cr(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:{}};hm(r,a,n),cf(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=dpe[i.magFilter]||dr,t.minFilter=dpe[i.minFilter]||ca,t.wrapS=fpe[i.wrapS]||li,t.wrapT=fpe[i.wrapT]||li,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 Rr(e);t.needsUpdate=!0,i(t)}),t.load(Ps.resolveURL(e,n.path),a,void 0,r)}))})).then((function(e){return!0===o&&a.revokeObjectURL(s),e.userData.mimeType=r.mimeType||eut(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[Ir.KHR_TEXTURE_TRANSFORM]){let e=void 0!==i.extensions?i.extensions[Ir.KHR_TEXTURE_TRANSFORM]:void 0;if(e){let t=r.associations.get(a);a=r.extensions[Ir.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 ci,Qn.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 En,Qn.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 Pd}loadMaterial(e){let t,i=this,n=this.json,r=this.extensions,a=n.materials[e],s={},o=[];if((a.extensions||{})[Ir.KHR_MATERIALS_UNLIT]){let e=r[Ir.KHR_MATERIALS_UNLIT];t=e.getMaterialType(),o.push(e.extendParams(s,a,i))}else{let n=a.pbrMetallicRoughness||{};if(s.color=new Ye(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,zt)),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=or);let l=a.alphaMode||rU.OPAQUE;if(l===rU.BLEND?(s.transparent=!0,s.depthWrite=!1):(s.transparent=!1,l===rU.MASK&&(s.alphaTest=void 0!==a.alphaCutoff?a.alphaCutoff:.5)),void 0!==a.normalTexture&&t!==jt&&(o.push(i.assignTexture(s,"normalMap",a.normalTexture)),s.normalScale=new fe(1,1),void 0!==a.normalTexture.scale)){let e=a.normalTexture.scale;s.normalScale.set(e,e)}return void 0!==a.occlusionTexture&&t!==jt&&(o.push(i.assignTexture(s,"aoMap",a.occlusionTexture)),void 0!==a.occlusionTexture.strength&&(s.aoMapIntensity=a.occlusionTexture.strength)),void 0!==a.emissiveFactor&&t!==jt&&(s.emissive=(new Ye).fromArray(a.emissiveFactor)),void 0!==a.emissiveTexture&&t!==jt&&o.push(i.assignTexture(s,"emissiveMap",a.emissiveTexture,zt)),Promise.all(o).then((function(){let n=new t(s);return a.name&&(n.name=a.name),cf(n,a),i.associations.set(n,{materials:e}),a.extensions&&hm(r,n,a),n}))}createUniqueName(e){let t=Fn.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[Ir.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then((function(i){return ppe(i,e,t)}))}let a=[];for(let s=0,o=e.length;s0&&Jct(i,r),i.name=t.createUniqueName(r.name||"mesh_"+e),cf(i,r),u.extensions&&hm(n,i,u),t.assignFinalMaterial(i),l.push(i)}for(let n=0,r=l.length;n1?new Ln:1===t.length?t[0]:new Xt,s!==t[0])for(let e=0,i=t.length;e{let t=new Map;for(let[i,r]of n.associations)(i instanceof Qn||i instanceof Rr)&&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(lf[r.path]===lf.weights?e.traverse((function(e){e.morphTargetInfluences&&l.push(e.name?e.name:e.uuid)})):l.push(o),lf[r.path]){case lf.weights:a=rl;break;case lf.rotation:a=fa;break;case lf.position:case lf.scale:default:switch(i.itemSize){case 1:a=rl;break;case 2:case 3:a=Na}}let h=void 0!==n.interpolation?$ct[n.interpolation]:Gc,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 CU(this.resourcePath||t,this.materialOptions);return s.setCrossOrigin(this.crossOrigin),s.setManager(this.manager),s.setMaterials(a),s}},CU=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:Xr,this.wrap=void 0!==this.options.wrap?this.options.wrap:li}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=zt),n[e]=a}for(let a in i){let e,t=i[a];if(""!==t)switch(a.toLowerCase()){case"kd":n.color=(new Ye).fromArray(t).convertSRGBToLinear();break;case"ks":n.specular=(new Ye).fromArray(t).convertSRGBToLinear();break;case"ke":n.emissive=(new Ye).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 Cs(n),this.materials[e]}getTextureParams(e,t){let i,n={scale:new fe(1,1),offset:new fe(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:Va,s=a.getHandler(e);null===s&&(s=new rs(a)),s.setCrossOrigin&&s.setCrossOrigin(this.crossOrigin);let o=s.load(e,i,n,r);return void 0!==t&&(o.mapping=t),o}},rut=/^[og]\s*(.+)?/,iut=/^mtllib /,sut=/^usemtl /,aut=/^usemap /,gpe=/\s+/,vpe=new P,PU=new P,ype=new P,xpe=new P,El=new P,$A=new Ye;function out(){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;vpe.fromArray(n,e),PU.fromArray(n,t),ype.fromArray(n,i),El.subVectors(ype,PU),xpe.subVectors(vpe,PU),El.cross(xpe),El.normalize(),r.push(El.x,El.y,El.z),r.push(El.x,El.y,El.z),r.push(El.x,El.y,El.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?($A.setRGB(parseFloat(i[4]),parseFloat(i[5]),parseFloat(i[6])).convertSRGBToLinear(),t.colors.push($A.r,$A.g,$A.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(gpe),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 Ln;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 Rt(i.normals,3)),i.colors.length>0&&(l=!0,h.setAttribute("color",new Rt(i.colors,3))),!0===i.hasUVIndices&&h.setAttribute("uv",new Rt(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 ci({size:1,sizeAttenuation:!1}),i=new Et;i.setAttribute("position",new Rt(t.vertices,3)),t.colors.length>0&&void 0!==t.colors[0]&&(i.setAttribute("color",new Rt(t.colors,3)),e.vertexColors=!0);let n=new Yr(i,e);r.add(n)}return r}},$a=new Ye,ZA=class extends er{constructor(e){super(e),this.propertyNameMapping={},this.customPropertyMapping={}}load(e,t,i,n){let r=this,a=new Cr(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 Rt(e.vertices,3)),e.normals.length>0&&t.setAttribute("normal",new Rt(e.normals,3)),e.uvs.length>0&&t.setAttribute("uv",new Rt(e.uvs,2)),e.colors.length>0&&t.setAttribute("color",new Rt(e.colors,3)),(e.faceVertexUvs.length>0||e.faceVertexColors.length>0)&&(t=t.toNonIndexed(),e.faceVertexUvs.length>0&&t.setAttribute("uv",new Rt(e.faceVertexUvs,2)),e.faceVertexColors.length>0&&t.setAttribute("color",new Rt(e.faceVertexColors,3)));for(let i of Object.keys(d.customPropertyMapping))e[i].length>0&&t.setAttribute(i,new Rt(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&&($a.setRGB(i[n.attrR]/255,i[n.attrG]/255,i[n.attrB]/255).convertSRGBToLinear(),e.colors.push($a.r,$a.g,$a.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&&($a.setRGB(i[n.attrR]/255,i[n.attrG]/255,i[n.attrB]/255).convertSRGBToLinear(),e.faceVertexColors.push($a.r,$a.g,$a.b),e.faceVertexColors.push($a.r,$a.g,$a.b),e.faceVertexColors.push($a.r,$a.g,$a.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++]}},JA=class extends er{constructor(e){super(e)}load(e,t,i,n){let r=this,a=new Cr(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 nn(p,3)),d.setAttribute("normal",new nn(f,3)),u&&(d.setAttribute("color",new nn(r,3)),d.hasColors=!0,d.alpha=l),d}(i):function(e){let t,i=new Et,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 P,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 Rt(h,3)),i.setAttribute("normal",new Rt(c,3)),i}("string"!=typeof(n=e)?(new TextDecoder).decode(n):n);var n}},dm=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 dm(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}},bpe=(e=>(e[e.NULL=0]="NULL",e[e.POINT=1]="POINT",e[e.POLYLINE=3]="POLYLINE",e[e.POLYGON=5]="POLYGON",e))(bpe||{}),QA=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 Et;a.setFromPoints(e),a.setIndex(r),t.push(a);let s=new Et;e.length>2&&!e[0].equals(e[e.length-1])&&e.push(e[0]),s.setFromPoints(e),i.push(s)}else{let t=new Et;t.setFromPoints(e),i.push(t)}}}var d=new Xt;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 QA).parse(r.response),n=(new eC).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}))}},DU=class{constructor(e){this.manager=e}loadLocalModel(e,t,i){return nt(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")?(J.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 nt(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 J.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 nt(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 nt(this,null,(function*(){let i=yield new qA(this.manager).loadAsync(e,t);return Promise.resolve(i)}))}loadObj(e,t){return nt(this,null,(function*(){let i=new KA(this.manager),n=new YA(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 nt(this,null,(function*(){let i=yield new JA(this.manager).loadAsync(e,t);return Promise.resolve(new ht(i))}))}loadShp(e,t){return nt(this,null,(function*(){let i=new tC;return new Promise(((n,r)=>{i.load(e,(e=>{n(e)}),t,(e=>{r(e)}))}))}))}loadDae(e,t){return nt(this,null,(function*(){let i=yield new UA(this.manager).loadAsync(e,t);return Promise.resolve(i.scene)}))}loadDxf(e,t){return nt(this,null,(function*(){var i;this.font||console.warn("[LoadingHelper] Should set font first!");let n=new Zt(this.manager,{ignorePaperSpace:!0,enableLocalCache:!1});n.setFont(this.font);try{this.font&&this.font.getFontData&&(yield null==(i=this.font)?void 0:i.getFontData());let r=yield n.loadAsync(e,t);return Promise.resolve(r.threejsObject)}catch(e){let i=new ErrorEvent("");return Promise.reject(i)}}))}loadPly(e,t){return nt(this,null,(function*(){let i=yield new ZA(this.manager).loadAsync(e,t);return Promise.resolve(new ht(i))}))}loadImage(e,t){return nt(this,null,(function*(){let i=yield new rs(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 jt({map:i,side:or,transparent:!0}),o=new zr(a,r),l=new ht(o,s);return Promise.resolve(l)}))}loadDxfData(e,t,i,n,r){return nt(this,null,(function*(){var a;this.font||console.warn("[LoadingHelper] Should set font first!");let s=new Zt(this.manager,r);return s.setFont(this.font),s.manager.onLoad=()=>{n&&n()},this.font&&this.font.getFontData&&(yield null==(a=this.font)?void 0:a.getFontData()),s.load(e,t,i)}))}setFont(e){this.font=e}static setDracoDecoderPath(e){this.decoderPath=e}getGltfLoader(){if(!this.gltfLoader){this.gltfLoader=new bu(this.manager);let e=new VA(this.manager);e.setDecoderPath(DU.decoderPath),this.gltfLoader.setDRACOLoader(e)}return this.gltfLoader}},ba=DU;function LU(e){let t=new Blob([e],{type:"text/javascript"}),i=URL.createObjectURL(t),n=new Worker(i);return URL.revokeObjectURL(i),n}function OU(){return LU('var Zc=Object.defineProperty,Jc=Object.defineProperties;var $c=Object.getOwnPropertyDescriptors;var Bo=Object.getOwnPropertySymbols;var Kc=Object.prototype.hasOwnProperty,Qc=Object.prototype.propertyIsEnumerable;var zo=(i,t,e)=>t in i?Zc(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,ji=(i,t)=>{for(var e in t||(t={}))Kc.call(t,e)&&zo(i,e,t[e]);if(Bo)for(var e of Bo(t))Qc.call(t,e)&&zo(i,e,t[e]);return i},Vo=(i,t)=>Jc(i,$c(t));var po="154";var jc=0,ko=1,tl=2;var oc=1,el=2,on=3,He=0,he=1,ze=2;var Mn=0,fi=1,Ho=2,Go=3,Wo=4,nl=5,li=100,il=101,sl=102,Xo=103,qo=104,rl=200,ol=201,al=202,cl=203,ac=204,cc=205,ll=206,hl=207,ul=208,fl=209,dl=210,pl=0,ml=1,gl=2,Lr=3,_l=4,xl=5,yl=6,vl=7,lc=0,Ml=1,Sl=2,cn=0,bl=1,El=2,Tl=3,wl=4,Al=5,hc=300,mi=301,gi=302,Ir=303,Ur=304,Bs=306,Dr=1e3,Ve=1001,Nr=1002,pe=1003,Yo=1004;var er=1005;var Le=1006,Rl=1007;var ki=1008;var Sn=1009,Cl=1010,Pl=1011,mo=1012,uc=1013,yn=1014,vn=1015,Hi=1016,fc=1017,dc=1018,Fn=1020,Ll=1021,ke=1023,Il=1024,Ul=1025,On=1026,_i=1027,Dl=1028,pc=1029,Nl=1030,mc=1031,gc=1033,nr=33776,ir=33777,sr=33778,rr=33779,Zo=35840,Jo=35841,$o=35842,Ko=35843,Fl=36196,Qo=37492,jo=37496,ta=37808,ea=37809,na=37810,ia=37811,sa=37812,ra=37813,oa=37814,aa=37815,ca=37816,la=37817,ha=37818,ua=37819,fa=37820,da=37821,or=36492,Ol=36283,pa=36284,ma=36285,ga=36286;var bs=2300,Es=2301,ar=2302,_a=2400,xa=2401,ya=2402;var _c=3e3,Bn=3001,Bl=3200,zl=3201,Vl=0,kl=1,zn="",Rt="srgb",Je="srgb-linear",xc="display-p3";var cr=7680;var Hl=519,Gl=512,Wl=513,Xl=514,ql=515,Yl=516,Zl=517,Jl=518,$l=519,va=35044;var Ma="300 es",Fr=1035,an=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 Kl(i,t){return(i%t+t)%t}function hr(i,t,e){return(1-e)*i+e*t}function Sa(i){return(i&i-1)===0&&i!==0}function Br(i){return Math.pow(2,Math.floor(Math.log(i)/Math.LN2))}function ts(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 Te(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 Dt=class{constructor(t=0,e=0){Dt.prototype.isVector2=!0,this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){let e=this.x,n=this.y,s=t.elements;return this.x=s[0]*e+s[3]*n+s[6],this.y=s[1]*e+s[4]*n+s[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this}clampLength(t,e){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){let e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;let n=this.dot(t)/e;return Math.acos(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],M=s[2],T=s[5],A=s[8];return r[0]=a*x+o*v+c*M,r[3]=a*p+o*_+c*T,r[6]=a*f+o*b+c*A,r[1]=l*x+h*v+d*M,r[4]=l*p+h*_+d*T,r[7]=l*f+h*b+d*A,r[2]=u*x+m*v+g*M,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 yc(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 ba={};function zi(i){i in ba||(ba[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 Ql=new Ct().fromArray([.8224621,.0331941,.0170827,.177538,.9668058,.0723974,-1e-7,1e-7,.9105199]),jl=new Ct().fromArray([1.2249401,-.0420569,-.0196376,-.2249404,1.0420571,-.0786361,1e-7,0,1.0982735]);function th(i){return i.convertSRGBToLinear().applyMatrix3(jl)}function eh(i){return i.applyMatrix3(Ql).convertLinearToSRGB()}var nh={[Je]:i=>i,[Rt]:i=>i.convertSRGBToLinear(),[xc]:th},ih={[Je]:i=>i,[Rt]:i=>i.convertLinearToSRGB(),[xc]:eh},Ne={enabled:!0,get legacyMode(){return console.warn("THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150."),!this.enabled},set legacyMode(i){console.warn("THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150."),this.enabled=!i},get workingColorSpace(){return Je},set workingColorSpace(i){console.warn("THREE.ColorManagement: .workingColorSpace is readonly.")},convert:function(i,t,e){if(this.enabled===!1||t===e||!t||!e)return i;let n=nh[t],s=ih[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!==hc)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 zi("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace===Rt?Bn:_c}set encoding(t){zi("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=t===Bn?Rt:zn}};ge.DEFAULT_IMAGE=null;ge.DEFAULT_MAPPING=hc;ge.DEFAULT_ANISOTROPY=1;var Kt=class{constructor(t=0,e=0,n=0,s=1){Kt.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,M=(f+1)/2,T=(h+u)/4,A=(d+x)/4,L=(g+p)/4;return _>b&&_>M?_<.01?(n=0,s=.707106781,r=.707106781):(n=Math.sqrt(_),s=T/n,r=A/n):b>M?b<.01?(n=.707106781,s=0,r=.707106781):(s=Math.sqrt(b),n=T/s,r=L/s):M<.01?(n=.707106781,s=.707106781,r=0):(r=Math.sqrt(M),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}},hn=class extends bn{constructor(t=1,e=1,n={}){super(),this.isWebGLRenderTarget=!0,this.width=t,this.height=e,this.depth=1,this.scissor=new Kt(0,0,t,e),this.scissorTest=!1,this.viewport=new Kt(0,0,t,e);let s={width:t,height:e,depth:1};n.encoding!==void 0&&(zi("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:Le,this.depthBuffer=n.depthBuffer!==void 0?n.depthBuffer:!0,this.stencilBuffer=n.stencilBuffer!==void 0?n.stencilBuffer:!1,this.depthTexture=n.depthTexture!==void 0?n.depthTexture:null,this.samples=n.samples!==void 0?n.samples:0}setSize(t,e,n=1){(this.width!==t||this.height!==e||this.depth!==n)&&(this.width=t,this.height=e,this.depth=n,this.texture.image.width=t,this.texture.image.height=e,this.texture.image.depth=n,this.dispose()),this.viewport.set(0,0,t,e),this.scissor.set(0,0,t,e)}clone(){return new this.constructor().copy(this)}copy(t){this.width=t.width,this.height=t.height,this.depth=t.depth,this.scissor.copy(t.scissor),this.scissorTest=t.scissorTest,this.viewport.copy(t.viewport),this.texture=t.texture.clone(),this.texture.isRenderTargetTexture=!0;let e=Object.assign({},t.texture.image);return this.texture.source=new 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"})}},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 zr=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 M=Math.sqrt(_),T=Math.atan2(M,f*v);p=Math.sin(p*T)/M,o=Math.sin(o*T)/M}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 M=1/Math.sqrt(c*c+l*l+h*h+d*d);c*=M,l*=M,h*=M,d*=M}}t[e]=c,t[e+1]=l,t[e+2]=h,t[e+3]=d}static multiplyQuaternionsFlat(t,e,n,s,r,a){let o=n[s],c=n[s+1],l=n[s+2],h=n[s+3],d=r[a],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(Ea.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(Ea.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,Ea=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,tn),tn.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(Di),es.subVectors(this.max,Di),Jn.subVectors(t.a,Di),$n.subVectors(t.b,Di),Kn.subVectors(t.c,Di),pn.subVectors($n,Jn),mn.subVectors(Kn,$n),Pn.subVectors(Jn,Kn);let e=[0,-pn.z,pn.y,0,-mn.z,mn.y,0,-Pn.z,Pn.y,pn.z,0,-pn.x,mn.z,0,-mn.x,Pn.z,0,-Pn.x,-pn.y,pn.x,0,-mn.y,mn.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(pn,mn),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,tn).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=this.getSize(tn).length()*.5),t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()?this:(je[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),je[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),je[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),je[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),je[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),je[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),je[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),je[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(je),this)}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}},je=[new P,new P,new P,new P,new P,new P,new P,new P],tn=new P,Zn=new _e,Jn=new P,$n=new P,Kn=new P,pn=new P,mn=new P,Pn=new P,Di=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 oh=new _e,Ni=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):oh.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;Ni.subVectors(t,this.center);let e=Ni.lengthSq();if(e>this.radius*this.radius){let n=Math.sqrt(e),s=(n-this.radius)*.5;this.center.addScaledVector(Ni,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(Ni.copy(t.center).add(gr)),this.expandByPoint(Ni.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)}},en=new P,_r=new P,is=new P,gn=new P,xr=new P,ss=new P,yr=new P,Vr=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,en)),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=en.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(en.copy(this.origin).addScaledVector(this.direction,e),en.distanceToSquared(t))}distanceSqToSegment(t,e,n,s){_r.copy(t).add(e).multiplyScalar(.5),is.copy(e).sub(t).normalize(),gn.copy(this.origin).sub(_r);let r=t.distanceTo(e)*.5,a=-this.direction.dot(is),o=gn.dot(this.direction),c=-gn.dot(is),l=gn.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){en.subVectors(t.center,this.origin);let n=en.dot(this.direction),s=en.dot(en)-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,en)!==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;gn.subVectors(this.origin,t);let c=o*this.direction.dot(ss.crossVectors(gn,ss));if(c<0)return null;let l=o*this.direction.dot(xr.cross(gn));if(l<0||c+l>a)return null;let h=-o*gn.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(ah,t,ch)}lookAt(t,e,n){let s=this.elements;return we.subVectors(t,e),we.lengthSq()===0&&(we.z=1),we.normalize(),_n.crossVectors(n,we),_n.lengthSq()===0&&(Math.abs(n.z)===1?we.x+=1e-4:we.z+=1e-4,we.normalize(),_n.crossVectors(n,we)),_n.normalize(),rs.crossVectors(we,_n),s[0]=_n.x,s[4]=rs.x,s[8]=we.x,s[1]=_n.y,s[5]=rs.y,s[9]=we.y,s[2]=_n.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],M=n[15],T=s[0],A=s[4],L=s[8],y=s[12],w=s[1],z=s[5],q=s[9],I=s[13],D=s[2],O=s[6],$=s[10],k=s[14],X=s[3],J=s[7],K=s[11],B=s[15];return r[0]=a*T+o*w+c*D+l*X,r[4]=a*A+o*z+c*O+l*J,r[8]=a*L+o*q+c*$+l*K,r[12]=a*y+o*I+c*k+l*B,r[1]=h*T+d*w+u*D+m*X,r[5]=h*A+d*z+u*O+m*J,r[9]=h*L+d*q+u*$+m*K,r[13]=h*y+d*I+u*k+m*B,r[2]=g*T+x*w+p*D+f*X,r[6]=g*A+x*z+p*O+f*J,r[10]=g*L+x*q+p*$+f*K,r[14]=g*y+x*I+p*k+f*B,r[3]=v*T+_*w+b*D+M*X,r[7]=v*A+_*z+b*O+M*J,r[11]=v*L+_*q+b*$+M*K,r[15]=v*y+_*I+b*k+M*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,M=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*M;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]=M*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,M=n.x,T=n.y,A=n.z;return s[0]=(1-(x+f))*M,s[1]=(m+b)*M,s[2]=(g-_)*M,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=an){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===an)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=an){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===an)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,ah=new P(0,0,0),ch=new P(1,1,1),_n=new P,rs=new P,we=new P,Ta=new Gt,wa=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 Ta.makeRotationFromQuaternion(t),this.setFromRotationMatrix(Ta,e,n)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return wa.setFromEuler(this),this.setFromQuaternion(wa,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(Fi,t,hh),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Fi,uh,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,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),sn.subVectors(n,e),vr.subVectors(t,e);let a=Oe.dot(Oe),o=Oe.dot(sn),c=Oe.dot(vr),l=sn.dot(sn),h=sn.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,rn),rn.x>=0&&rn.y>=0&&rn.x+rn.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,rn),c.setScalar(0),c.addScaledVector(r,rn.x),c.addScaledVector(a,rn.y),c.addScaledVector(o,rn.z),c}static isFrontFacing(t,e,n,s){return Oe.subVectors(n,e),sn.subVectors(t,e),Oe.cross(sn).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),sn.subVectors(this.a,this.b),Oe.cross(sn).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 Ia.subVectors(r,s),o=(d-h)/(d-h+(m-g)),e.copy(s).addScaledVector(Ia,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)}},dh=0,yi=class extends bn{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:dh++}),this.uuid=Xi(),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=ac,this.blendDst=cc,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=Hl,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++}},vc={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=Kl(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=vc[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))&&(Ua.copy(r).invert(),In.copy(t.ray).applyMatrix4(Ua),!(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=mh(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 Dt)),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 Dt),h.uv2=h.uv1),a&&(Na.fromBufferAttribute(a,o),Fa.fromBufferAttribute(a,c),Oa.fromBufferAttribute(a,l),h.normal=se.getInterpolation(ms,ii,si,ri,Na,Fa,Oa,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 ln(l,3)),this.setAttribute("normal",new ln(h,3)),this.setAttribute("uv",new ln(d,2));function g(x,p,f,v,_,b,M,T,A,L,y){let w=b/A,z=M/L,q=b/2,I=M/2,D=T/2,O=A+1,$=L+1,k=0,X=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),k+=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 ye{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Gt,this.projectionMatrix=new Gt,this.projectionMatrixInverse=new Gt,this.coordinateSystem=an}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,kr=class extends ye{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===an)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.toneMapping,u=t.xr.enabled;t.toneMapping=cn,t.xr.enabled=!1;let m=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=m,t.setRenderTarget(n,5),t.render(e,l),t.setRenderTarget(h),t.toneMapping=d,t.xr.enabled=u,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}},Hr=class extends hn{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&&(zi("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:Le}fromEquirectangularTexture(t,e){this.texture.type=e.type,this.texture.colorSpace=e.colorSpace,this.texture.generateMipmaps=e.generateMipmaps,this.texture.minFilter=e.minFilter,this.texture.magFilter=e.magFilter;let n={uniforms:{tEquirect:{value:null}},vertexShader:`\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\tvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\n\t\t\t\t\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t\t\t\t\t#include \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 un({name:"CubemapFromEquirect",uniforms:vi(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:he,blending:Mn});r.uniforms.tEquirect.value=e;let a=new Ze(s,r),o=e.minFilter;return e.minFilter===ki&&(e.minFilter=Le),new kr(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,vh=new P,Mh=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(vh.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||Mh.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=an){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===an)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 Sc(){let i=null,t=!1,e=null,n=null;function s(r,a){e(r,a),n=i.requestAnimationFrame(s)}return{start:function(){t!==!0&&e!==null&&(n=i.requestAnimationFrame(s),t=!0)},stop:function(){i.cancelAnimationFrame(n),t=!1},setAnimationLoop:function(r){e=r},setContext:function(r){i=r}}}function Sh(i,t){let e=t.isWebGL2,n=new WeakMap;function s(l,h){let d=l.array,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`,Oh=`#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif`,Bh=`#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n#endif`,zh=`#if NUM_CLIPPING_PLANES > 0\n\tvClipPosition = - mvPosition.xyz;\n#endif`,Vh=`#if defined( USE_COLOR_ALPHA )\n\tdiffuseColor *= vColor;\n#elif defined( USE_COLOR )\n\tdiffuseColor.rgb *= vColor;\n#endif`,kh=`#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR )\n\tvarying vec3 vColor;\n#endif`,Hh=`#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvarying vec3 vColor;\n#endif`,Gh=`#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`,Wh=`#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`,Xh=`#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`,qh=`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`,Yh=`#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif`,Zh=`#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );\n#endif`,Jh=`#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif`,$h=`#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif`,Kh="gl_FragColor = linearToOutputTexel( gl_FragColor );",Qh=`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}`,jh=`#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`,tu=`#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`,eu=`#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`,nu=`#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`,iu=`#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`,su=`#ifdef USE_FOG\n\tvFogDepth = - mvPosition.z;\n#endif`,ru=`#ifdef USE_FOG\n\tvarying float vFogDepth;\n#endif`,ou=`#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`,au=`#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`,cu=`#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}`,lu=`#ifdef USE_LIGHTMAP\n\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\treflectedLight.indirectDiffuse += lightMapIrradiance;\n#endif`,hu=`#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif`,uu=`LambertMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularStrength = specularStrength;`,fu=`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`,du=`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`,pu=`#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`,mu=`ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;`,gu=`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`,_u=`BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;`,xu=`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`,yu=`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`,vu=`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}`,Mu=`\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`,Su=`#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`,bu=`#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`,Eu=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif`,Tu=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif`,wu=`#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t\tvarying float vIsPerspective;\n\t#else\n\t\tuniform float logDepthBufFC;\n\t#endif\n#endif`,Au=`#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n\t#else\n\t\tif ( isPerspectiveMatrix( projectionMatrix ) ) {\n\t\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\t\t\tgl_Position.z *= gl_Position.w;\n\t\t}\n\t#endif\n#endif`,Ru=`#ifdef USE_MAP\n\tdiffuseColor *= texture2D( map, vMapUv );\n#endif`,Cu=`#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif`,Pu=`#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`,Lu=`#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`,Iu=`float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif`,Uu=`#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif`,Du=`#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`,Nu=`#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`,Fu=`#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`,Ou=`#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`,Bu=`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;`,zu=`#ifdef USE_NORMALMAP_OBJECTSPACE\n\tnormal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( USE_NORMALMAP_TANGENTSPACE )\n\tvec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\tmapN.xy *= normalScale;\n\tnormal = normalize( tbn * mapN );\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );\n#endif`,Vu=`#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif`,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\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`,Gu=`#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`,Wu=`#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal = geometryNormal;\n#endif`,Xu=`#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`,qu=`#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`,Yu=`#ifdef USE_IRIDESCENCEMAP\n\tuniform sampler2D iridescenceMap;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform sampler2D iridescenceThicknessMap;\n#endif`,Zu=`#ifdef OPAQUE\ndiffuseColor.a = 1.0;\n#endif\n#ifdef USE_TRANSMISSION\ndiffuseColor.a *= material.transmissionAlpha;\n#endif\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );`,Ju=`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}`,$u=`#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif`,Ku=`vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;`,Qu=`#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif`,ju=`#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`,tf=`float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );\n\troughnessFactor *= texelRoughness.g;\n#endif`,ef=`#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif`,nf=`#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`,sf=`#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`,rf=`#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`,of=`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}`,af=`#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`,cf=`#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`,lf=`#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`,hf=`#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`,uf=`float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif`,ff=`#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif`,df=`#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif`,pf=`#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; }`,mf=`#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`,gf=`#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`,_f=`#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`,xf=`#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`,yf=`#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`,vf=`#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`,Mf=`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}`,Sf=`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}`,bf=`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}`,Ef=`#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}`,Tf=`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}`,wf=`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}`,Af=`#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}`,Rf=`#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}`,Cf=`#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}`,Pf=`#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}`,Lf=`varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n}`,If=`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}`,Uf=`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}`,Df=`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}`,Nf=`#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}`,Ff=`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}`,Of=`#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}`,Bf=`#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}`,zf=`#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}`,Vf=`#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}`,kf=`#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}`,Hf=`#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}`,Gf=`#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}`,Wf=`#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}`,Xf=`#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}`,qf=`#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}`,Yf=`#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}`,Zf=`#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}`,Jf=`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}`,$f=`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}`,Kf=`#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}`,Qf=`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}`,jf=`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}`,td=`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:bh,alphahash_pars_fragment:Eh,alphamap_fragment:Th,alphamap_pars_fragment:wh,alphatest_fragment:Ah,alphatest_pars_fragment:Rh,aomap_fragment:Ch,aomap_pars_fragment:Ph,begin_vertex:Lh,beginnormal_vertex:Ih,bsdfs:Uh,iridescence_fragment:Dh,bumpmap_pars_fragment:Nh,clipping_planes_fragment:Fh,clipping_planes_pars_fragment:Oh,clipping_planes_pars_vertex:Bh,clipping_planes_vertex:zh,color_fragment:Vh,color_pars_fragment:kh,color_pars_vertex:Hh,color_vertex:Gh,common:Wh,cube_uv_reflection_fragment:Xh,defaultnormal_vertex:qh,displacementmap_pars_vertex:Yh,displacementmap_vertex:Zh,emissivemap_fragment:Jh,emissivemap_pars_fragment:$h,colorspace_fragment:Kh,colorspace_pars_fragment:Qh,envmap_fragment:jh,envmap_common_pars_fragment:tu,envmap_pars_fragment:eu,envmap_pars_vertex:nu,envmap_physical_pars_fragment:pu,envmap_vertex:iu,fog_vertex:su,fog_pars_vertex:ru,fog_fragment:ou,fog_pars_fragment:au,gradientmap_pars_fragment:cu,lightmap_fragment:lu,lightmap_pars_fragment:hu,lights_lambert_fragment:uu,lights_lambert_pars_fragment:fu,lights_pars_begin:du,lights_toon_fragment:mu,lights_toon_pars_fragment:gu,lights_phong_fragment:_u,lights_phong_pars_fragment:xu,lights_physical_fragment:yu,lights_physical_pars_fragment:vu,lights_fragment_begin:Mu,lights_fragment_maps:Su,lights_fragment_end:bu,logdepthbuf_fragment:Eu,logdepthbuf_pars_fragment:Tu,logdepthbuf_pars_vertex:wu,logdepthbuf_vertex:Au,map_fragment:Ru,map_pars_fragment:Cu,map_particle_fragment:Pu,map_particle_pars_fragment:Lu,metalnessmap_fragment:Iu,metalnessmap_pars_fragment:Uu,morphcolor_vertex:Du,morphnormal_vertex:Nu,morphtarget_pars_vertex:Fu,morphtarget_vertex:Ou,normal_fragment_begin:Bu,normal_fragment_maps:zu,normal_pars_fragment:Vu,normal_pars_vertex:ku,normal_vertex:Hu,normalmap_pars_fragment:Gu,clearcoat_normal_fragment_begin:Wu,clearcoat_normal_fragment_maps:Xu,clearcoat_pars_fragment:qu,iridescence_pars_fragment:Yu,opaque_fragment:Zu,packing:Ju,premultiplied_alpha_fragment:$u,project_vertex:Ku,dithering_fragment:Qu,dithering_pars_fragment:ju,roughnessmap_fragment:tf,roughnessmap_pars_fragment:ef,shadowmap_pars_fragment:nf,shadowmap_pars_vertex:sf,shadowmap_vertex:rf,shadowmask_pars_fragment:of,skinbase_vertex:af,skinning_pars_vertex:cf,skinning_vertex:lf,skinnormal_vertex:hf,specularmap_fragment:uf,specularmap_pars_fragment:ff,tonemapping_fragment:df,tonemapping_pars_fragment:pf,transmission_fragment:mf,transmission_pars_fragment:gf,uv_pars_fragment:_f,uv_pars_vertex:xf,uv_vertex:yf,worldpos_vertex:vf,background_vert:Mf,background_frag:Sf,backgroundCube_vert:bf,backgroundCube_frag:Ef,cube_vert:Tf,cube_frag:wf,depth_vert:Af,depth_frag:Rf,distanceRGBA_vert:Cf,distanceRGBA_frag:Pf,equirect_vert:Lf,equirect_frag:If,linedashed_vert:Uf,linedashed_frag:Df,meshbasic_vert:Nf,meshbasic_frag:Ff,meshlambert_vert:Of,meshlambert_frag:Bf,meshmatcap_vert:zf,meshmatcap_frag:Vf,meshnormal_vert:kf,meshnormal_frag:Hf,meshphong_vert:Gf,meshphong_frag:Wf,meshphysical_vert:Xf,meshphysical_frag:qf,meshtoon_vert:Yf,meshtoon_frag:Zf,points_vert:Jf,points_frag:$f,shadow_vert:Kf,shadow_frag:Qf,sprite_vert:jf,sprite_frag:td},et={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 Dt(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Ct},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Ct}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Ct}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Ct}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new 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 Dt(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Ct},alphaMap:{value:null},alphaMapTransform:{value:new Ct},alphaTest:{value:0}}},Ye={basic:{uniforms:de([et.common,et.specularmap,et.envmap,et.aomap,et.lightmap,et.fog]),vertexShader:At.meshbasic_vert,fragmentShader:At.meshbasic_frag},lambert:{uniforms:de([et.common,et.specularmap,et.envmap,et.aomap,et.lightmap,et.emissivemap,et.bumpmap,et.normalmap,et.displacementmap,et.fog,et.lights,{emissive:{value:new kt(0)}}]),vertexShader:At.meshlambert_vert,fragmentShader:At.meshlambert_frag},phong:{uniforms:de([et.common,et.specularmap,et.envmap,et.aomap,et.lightmap,et.emissivemap,et.bumpmap,et.normalmap,et.displacementmap,et.fog,et.lights,{emissive:{value:new kt(0)},specular:{value:new kt(1118481)},shininess:{value:30}}]),vertexShader:At.meshphong_vert,fragmentShader:At.meshphong_frag},standard:{uniforms:de([et.common,et.envmap,et.aomap,et.lightmap,et.emissivemap,et.bumpmap,et.normalmap,et.displacementmap,et.roughnessmap,et.metalnessmap,et.fog,et.lights,{emissive:{value:new kt(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:At.meshphysical_vert,fragmentShader:At.meshphysical_frag},toon:{uniforms:de([et.common,et.aomap,et.lightmap,et.emissivemap,et.bumpmap,et.normalmap,et.displacementmap,et.gradientmap,et.fog,et.lights,{emissive:{value:new kt(0)}}]),vertexShader:At.meshtoon_vert,fragmentShader:At.meshtoon_frag},matcap:{uniforms:de([et.common,et.bumpmap,et.normalmap,et.displacementmap,et.fog,{matcap:{value:null}}]),vertexShader:At.meshmatcap_vert,fragmentShader:At.meshmatcap_frag},points:{uniforms:de([et.points,et.fog]),vertexShader:At.points_vert,fragmentShader:At.points_frag},dashed:{uniforms:de([et.common,et.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:At.linedashed_vert,fragmentShader:At.linedashed_frag},depth:{uniforms:de([et.common,et.displacementmap]),vertexShader:At.depth_vert,fragmentShader:At.depth_frag},normal:{uniforms:de([et.common,et.bumpmap,et.normalmap,et.displacementmap,{opacity:{value:1}}]),vertexShader:At.meshnormal_vert,fragmentShader:At.meshnormal_frag},sprite:{uniforms:de([et.sprite,et.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([et.common,et.displacementmap,{referencePosition:{value:new P},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:At.distanceRGBA_vert,fragmentShader:At.distanceRGBA_frag},shadow:{uniforms:de([et.lights,et.fog,{color:{value:new kt(0)},opacity:{value:1}}]),vertexShader:At.shadow_vert,fragmentShader:At.shadow_frag}};Ye.physical={uniforms:de([Ye.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Ct},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Ct},clearcoatNormalScale:{value:new Dt(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Ct},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Ct},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Ct},sheen:{value:0},sheenColor:{value:new 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 Dt},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 Dt},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Ct}}]),vertexShader:At.meshphysical_vert,fragmentShader:At.meshphysical_frag};var ys={r:0,b:0,g:0};function ed(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 Ze(new kn(1,1,1),new un({name:"BackgroundCubeMaterial",uniforms:vi(Ye.backgroundCube.uniforms),vertexShader:Ye.backgroundCube.vertexShader,fragmentShader:Ye.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 Ze(new Gi(2,2),new un({name:"BackgroundMaterial",uniforms:vi(Ye.background.uniforms),vertexShader:Ye.background.vertexShader,fragmentShader:Ye.background.fragmentShader,side:He,depthTest:!1,depthWrite:!1,fog:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),s.update(l)),l.material.uniforms.t2D.value=_,l.material.uniforms.backgroundIntensity.value=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,Mc(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 nd(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,$,k,X){let J=!1;if(a){let K=x(k,$,O);l!==K&&(l=K,m(l.object)),J=f(D,k,$,X),J&&v(D,k,$,X)}else{let K=O.wireframe===!0;(l.geometry!==k.id||l.program!==$.id||l.wireframe!==K)&&(l.geometry=k.id,l.program=$.id,l.wireframe=K,J=!0)}X!==null&&e.update(X,i.ELEMENT_ARRAY_BUFFER),(J||h)&&(h=!1,L(D,O,$,k),X!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e.get(X).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 k=$.wireframe===!0,X=o[D.id];X===void 0&&(X={},o[D.id]=X);let J=X[O.id];J===void 0&&(J={},X[O.id]=J);let K=J[k];return K===void 0&&(K=p(u()),J[k]=K),K}function p(D){let O=[],$=[],k=[];for(let X=0;X=0){let at=X[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!==k}function v(D,O,$,k){let X={},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),X[Z]=ct,K++}l.attributes=X,l.attributesNum=K,l.index=k}function _(){let D=l.newAttributes;for(let O=0,$=D.length;O<$;O++)D[O]=0}function b(D){M(D,0)}function M(D,O){let $=l.newAttributes,k=l.enabledAttributes,X=l.attributeDivisors;$[D]=1,k[D]===0&&(i.enableVertexAttribArray(D),k[D]=1),X[D]!==O&&((n.isWebGL2?i:t.get("ANGLE_instanced_arrays"))[n.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](D,O),X[D]=O)}function T(){let D=l.newAttributes,O=l.enabledAttributes;for(let $=0,k=O.length;$=0){let ot=X[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,gt=e.get(ot);if(gt===void 0)continue;let Et=gt.buffer,xt=gt.type,zt=gt.bytesPerElement,xe=n.isWebGL2===!0&&(xt===i.INT||xt===i.UNSIGNED_INT||ot.gpuType===uc);if(ot.isInterleavedBufferAttribute){let Ut=ot.data,N=Ut.stride,oe=ot.offset;if(Ut.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"),M=_&&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:M,maxSamples:T}}function rd(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 M=0;M!==_;++M)b[M]=e[M];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 Hr(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 Gr=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,Ba=[.125,.215,.35,.446,.526,.582],Nn=20,Rr=new Gr,za=new kt,Cr=null,Dn=(1+Math.sqrt(5))/2,ci=1/Dn,Va=[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=Ga(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Ha(),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=Ga()),this._cubemapMaterial.uniforms.flipEnvMap.value=t.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Ha());let r=s?this._cubemapMaterial:this._equirectMaterial,a=new Ze(this._lodPlanes[0],r),o=r.uniforms;o.envMap.value=t;let c=this._cubeSize;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,M,T,3*b,2*b),c.setRenderTarget(e),c.render(d,Rr)}};function ad(i){let t=[],e=[],n=[],s=i,r=i-hi+1+Ba.length;for(let a=0;ai-hi?c=Ba[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 M=new Ge;M.setAttribute("position",new Qt(v,x)),M.setAttribute("uv",new Qt(_,p)),M.setAttribute("faceIndex",new Qt(b,f)),t.push(M),s>hi&&s--}return{lodPlanes:t,sizeLods:e,sigmas:n}}function ka(i,t,e){let n=new hn(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 cd(i,t,e){let n=new Float32Array(Nn),s=new P(0,1,0);return new un({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:go(),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:Mn,depthTest:!1,depthWrite:!1})}function Ha(){return new un({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:go(),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:Mn,depthTest:!1,depthWrite:!1})}function Ga(){return new un({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:go(),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:Mn,depthTest:!1,depthWrite:!1})}function go(){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 ld(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),q=new Cs(z,y,w,g);q.type=vn,q.needsUpdate=!0;let I=L*4;for(let O=0;O0)return i;let s=t*e,r=Wa[s];if(r===void 0&&(r=new Float32Array(s),Wa[s]=r),t!==0){n.toArray(r,0);for(let a=1,o=0;a!==t;++a)o+=e,i[a].toArray(r,o)}return r}function jt(i,t){if(i.length!==t.length)return!1;for(let e=0,n=i.length;e":" "} ${o}: ${e[a]}`)}return n.join(`\n`)}function ap(i){switch(i){case Je:return["Linear","( value )"];case Rt:return["sRGB","( value )"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",i),["Linear","( value )"]}}function Ka(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`+op(i.getShaderSource(t),a)}else return s}function cp(i,t){let e=ap(t);return"vec4 "+i+"( vec4 value ) { return LinearTo"+e[0]+e[1]+"; }"}function lp(i,t){let e;switch(t){case bl:e="Linear";break;case El:e="Reinhard";break;case Tl:e="OptimizedCineon";break;case wl:e="ACESFilmic";break;case Al:e="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",t),e="Linear"}return"vec3 "+i+"( vec3 color ) { return "+e+"ToneMapping( color ); }"}function hp(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(Bi).join(`\n`)}function up(i){let t=[];for(let e in i){let n=i[e];n!==!1&&t.push("#define "+e+" "+n)}return t.join(`\n`)}function fp(i,t){let e={},n=i.getProgramParameter(t,i.ACTIVE_ATTRIBUTES);for(let s=0;s/gm;function Yr(i){return i.replace(dp,mp)}var pp=new Map([["encodings_fragment","colorspace_fragment"],["encodings_pars_fragment","colorspace_pars_fragment"],["output_fragment","opaque_fragment"]]);function mp(i,t){let e=At[t];if(e===void 0){let n=pp.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 Yr(e)}var gp=/#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 tc(i){return i.replace(gp,_p)}function _p(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(Bi).join(`\n`),f.length>0&&(f+=`\n`)):(p=[ec(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(Bi).join(`\n`),f=[m,ec(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!==cn?"#define TONE_MAPPING":"",e.toneMapping!==cn?At.tonemapping_pars_fragment:"",e.toneMapping!==cn?lp("toneMapping",e.toneMapping):"",e.dithering?"#define DITHERING":"",e.opaque?"#define OPAQUE":"",At.colorspace_pars_fragment,cp("linearToOutputTexel",e.outputColorSpace),e.useDepthPacking?"#define DEPTH_PACKING "+e.depthPacking:"",`\n`].filter(Bi).join(`\n`)),a=Yr(a),a=Qa(a,e),a=ja(a,e),o=Yr(o),o=Qa(o,e),o=ja(o,e),a=tc(a),o=tc(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===Ma?"":"layout(location = 0) out highp vec4 pc_fragColor;",e.glslVersion===Ma?"":"#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,M=$a(s,s.VERTEX_SHADER,_),T=$a(s,s.FRAGMENT_SHADER,b);if(s.attachShader(x,M),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(M).trim(),z=s.getShaderInfoLog(T).trim(),q=!0,I=!0;if(s.getProgramParameter(x,s.LINK_STATUS)===!1)if(q=!1,typeof i.debug.onShaderError=="function")i.debug.onShaderError(s,x,M,T);else{let D=Ka(s,M,"vertex"),O=Ka(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:q,programLog:y,vertexShader:{log:w,prefix:p},fragmentShader:{log:z,prefix:f}})}s.deleteShader(M),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=fp(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=rp++,this.cacheKey=t,this.usedTimes=1,this.program=x,this.vertexShader=M,this.fragmentShader=T,this}var Ep=0,Zr=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 Jr(t),e.set(t,n)),n}},Jr=class{constructor(t){this.id=Ep++,this.code=t,this.usedTimes=0}};function Tp(i,t,e,n,s,r,a){let o=new Ps,c=new Zr,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,q,I){let D=q.fog,O=I.geometry,$=y.isMeshStandardMaterial?q.environment:null,k=(y.isMeshStandardMaterial?e:t).get(y.envMap||$),X=k&&k.mapping===Bs?k.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,gt;if(J){let Xe=Ye[J];ot=Xe.vertexShader,at=Xe.fragmentShader}else ot=y.vertexShader,at=y.fragmentShader,c.update(y),ct=c.getVertexShaderID(y),gt=c.getFragmentShaderID(y);let Et=i.getRenderTarget(),xt=I.isInstancedMesh===!0,zt=!!y.map,xe=!!y.matcap,Ut=!!k,N=!!y.aoMap,oe=!!y.lightMap,yt=!!y.bumpMap,Tt=!!y.normalMap,St=!!y.displacementMap,Wt=!!y.emissiveMap,Nt=!!y.metalnessMap,Pt=!!y.roughnessMap,Vt=y.anisotropy>0,re=y.clearcoat>0,ae=y.iridescence>0,R=y.sheen>0,S=y.transmission>0,G=Vt&&!!y.anisotropyMap,Q=re&&!!y.clearcoatMap,j=re&&!!y.clearcoatNormalMap,it=re&&!!y.clearcoatRoughnessMap,ft=ae&&!!y.iridescenceMap,st=ae&&!!y.iridescenceThicknessMap,Y=R&&!!y.sheenColorMap,dt=R&&!!y.sheenRoughnessMap,pt=!!y.specularMap,_t=!!y.specularColorMap,ht=!!y.specularIntensityMap,ut=S&&!!y.transmissionMap,Lt=S&&!!y.thicknessMap,Ht=!!y.gradientMap,C=!!y.alphaMap,nt=y.alphaTest>0,V=!!y.alphaHash,tt=!!y.extensions,rt=!!O.attributes.uv1,Ot=!!O.attributes.uv2,Xt=!!O.attributes.uv3;return{isWebGL2:h,shaderID:J,shaderType:y.type,shaderName:y.name,vertexShader:ot,fragmentShader:at,defines:y.defines,customVertexShaderID:ct,customFragmentShaderID:gt,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:Je,map:zt,matcap:xe,envMap:Ut,envMapMode:Ut&&k.mapping,envMapCubeUVHeight:X,aoMap:N,lightMap:oe,bumpMap:yt,normalMap:Tt,displacementMap:u&&St,emissiveMap:Wt,normalMapObjectSpace:Tt&&y.normalMapType===kl,normalMapTangentSpace:Tt&&y.normalMapType===Vl,metalnessMap:Nt,roughnessMap:Pt,anisotropy:Vt,anisotropyMap:G,clearcoat:re,clearcoatMap:Q,clearcoatNormalMap:j,clearcoatRoughnessMap:it,iridescence:ae,iridescenceMap:ft,iridescenceThicknessMap:st,sheen:R,sheenColorMap:Y,sheenRoughnessMap:dt,specularMap:pt,specularColorMap:_t,specularIntensityMap:ht,transmission:S,transmissionMap:ut,thicknessMap:Lt,gradientMap:Ht,opaque:y.transparent===!1&&y.blending===fi,alphaMap:C,alphaTest:nt,alphaHash:V,combine:y.combine,mapUv:zt&&x(y.map.channel),aoMapUv:N&&x(y.aoMap.channel),lightMapUv:oe&&x(y.lightMap.channel),bumpMapUv:yt&&x(y.bumpMap.channel),normalMapUv:Tt&&x(y.normalMap.channel),displacementMapUv:St&&x(y.displacementMap.channel),emissiveMapUv:Wt&&x(y.emissiveMap.channel),metalnessMapUv:Nt&&x(y.metalnessMap.channel),roughnessMapUv:Pt&&x(y.roughnessMap.channel),anisotropyMapUv:G&&x(y.anisotropyMap.channel),clearcoatMapUv:Q&&x(y.clearcoatMap.channel),clearcoatNormalMapUv:j&&x(y.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:it&&x(y.clearcoatRoughnessMap.channel),iridescenceMapUv:ft&&x(y.iridescenceMap.channel),iridescenceThicknessMapUv:st&&x(y.iridescenceThicknessMap.channel),sheenColorMapUv:Y&&x(y.sheenColorMap.channel),sheenRoughnessMapUv:dt&&x(y.sheenRoughnessMap.channel),specularMapUv:pt&&x(y.specularMap.channel),specularColorMapUv:_t&&x(y.specularColorMap.channel),specularIntensityMapUv:ht&&x(y.specularIntensityMap.channel),transmissionMapUv:ut&&x(y.transmissionMap.channel),thicknessMapUv:Lt&&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:Xt,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:y.toneMapped?i.toneMapping:cn,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:tt&&y.extensions.derivatives===!0,extensionFragDepth:tt&&y.extensions.fragDepth===!0,extensionDrawBuffers:tt&&y.extensions.drawBuffers===!0,extensionShaderTextureLOD:tt&&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 q=Ye[w];z=_h.clone(q.uniforms)}else z=y.uniforms;return z}function M(y,w){let z;for(let q=0,I=l.length;q0?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||Ap),n.length>1&&n.sort(u||nc),s.length>1&&s.sort(u||nc)}function h(){for(let d=t,u=i.length;d=r.length?(a=new ic,r.push(a)):a=r[s],a}function e(){i=new WeakMap}return{get:t,dispose:e}}function Cp(){let i={};return{get:function(t){if(i[t.id]!==void 0)return i[t.id];let e;switch(t.type){case"DirectionalLight":e={direction:new P,color:new 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 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={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Dt};break;case"SpotLight":e={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Dt};break;case"PointLight":e={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Dt,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[t.id]=e,e}}}var Lp=0;function Ip(i,t){return(t.castShadow?2:0)-(i.castShadow?2:0)+(t.map?1:0)-(i.map?1:0)}function Up(i,t){let e=new Cp,n=Pp(),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,M=0,T=0,A=0,L=0;h.sort(Ip);let y=d===!0?Math.PI:1;for(let z=0,q=h.length;z0&&(t.isWebGL2||i.has("OES_texture_float_linear")===!0?(s.rectAreaLTC1=et.LTC_FLOAT_1,s.rectAreaLTC2=et.LTC_FLOAT_2):i.has("OES_texture_half_float_linear")===!0?(s.rectAreaLTC1=et.LTC_HALF_1,s.rectAreaLTC2=et.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),s.ambient[0]=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!==M||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=M,s.pointShadowMap.length=M,s.spotShadow.length=T,s.spotShadowMap.length=T,s.directionalShadowMatrix.length=b,s.pointShadowMatrix.length=M,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=M,w.numSpotShadows=T,w.numSpotMaps=A,s.version=Lp++)}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 M=s.directional[u];M.direction.setFromMatrixPosition(b.matrixWorld),r.setFromMatrixPosition(b.target.matrixWorld),M.direction.sub(r),M.direction.transformDirection(f),u++}else if(b.isSpotLight){let M=s.spot[g];M.position.setFromMatrixPosition(b.matrixWorld),M.position.applyMatrix4(f),M.direction.setFromMatrixPosition(b.matrixWorld),r.setFromMatrixPosition(b.target.matrixWorld),M.direction.sub(r),M.direction.transformDirection(f),g++}else if(b.isRectAreaLight){let M=s.rectArea[x];M.position.setFromMatrixPosition(b.matrixWorld),M.position.applyMatrix4(f),o.identity(),a.copy(b.matrixWorld),a.premultiply(f),o.extractRotation(a),M.halfWidth.set(b.width*.5,0,0),M.halfHeight.set(0,b.height*.5,0),M.halfWidth.applyMatrix4(o),M.halfHeight.applyMatrix4(o),x++}else if(b.isPointLight){let M=s.point[m];M.position.setFromMatrixPosition(b.matrixWorld),M.position.applyMatrix4(f),m++}else if(b.isHemisphereLight){let M=s.hemi[p];M.direction.setFromMatrixPosition(b.matrixWorld),M.direction.transformDirection(f),p++}}}return{setup:c,setupView:l,state:s}}function sc(i,t){let e=new Up(i,t),n=[],s=[];function r(){n.length=0,s.length=0}function a(d){n.push(d)}function o(d){s.push(d)}function c(d){e.setup(n,d)}function l(d){e.setupView(n,d)}return{init:r,state:{lightsArray:n,shadowsArray:s,lights:e},setupLights:c,setupLightsView:l,pushLight:a,pushShadow:o}}function Dp(i,t){let e=new WeakMap;function n(r,a=0){let o=e.get(r),c;return o===void 0?(c=new sc(i,t),e.set(r,[c])):a>=o.length?(c=new sc(i,t),o.push(c)):c=o[a],c}function s(){e=new WeakMap}return{get:n,dispose:s}}var $r=class extends yi{constructor(t){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Bl,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}},Kr=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}},Np=`void main() {\n\tgl_Position = vec4( position, 1.0 );\n}`,Fp=`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 Op(i,t,e){let n=new Fs,s=new Dt,r=new Dt,a=new Kt,o=new $r({depthPacking:zl}),c=new Kr,l={},h=e.maxTextureSize,d={[He]:he,[he]:He,[ze]:ze},u=new un({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Dt},radius:{value:4}},vertexShader:Np,fragmentShader:Fp}),m=u.clone();m.defines.HORIZONTAL_PASS=1;let g=new Ge;g.setAttribute("position",new Qt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let x=new Ze(g,u),p=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=oc;let f=this.type;this.render=function(M,T,A){if(p.enabled===!1||p.autoUpdate===!1&&p.needsUpdate===!1||M.length===0)return;let L=i.getRenderTarget(),y=i.getActiveCubeFace(),w=i.getActiveMipmapLevel(),z=i.state;z.setBlending(Mn),z.buffers.color.setClear(1,1,1,1),z.buffers.depth.setTest(!0),z.setScissorTest(!1);let q=f!==on&&this.type===on,I=f===on&&this.type!==on;for(let D=0,O=M.length;Dh||s.y>h)&&(s.x>h&&(r.x=Math.floor(h/X.x),s.x=r.x*X.x,k.mapSize.x=r.x),s.y>h&&(r.y=Math.floor(h/X.y),s.y=r.y*X.y,k.mapSize.y=r.y)),k.map===null||q===!0||I===!0){let K=this.type!==on?{minFilter:pe,magFilter:pe}:{};k.map!==null&&k.map.dispose(),k.map=new hn(s.x,s.y,K),k.map.texture.name=$.name+".shadowMap",k.camera.updateProjectionMatrix()}i.setRenderTarget(k.map),i.clear();let J=k.getViewportCount();for(let K=0;K0||T.map&&T.alphaTest>0){let z=y.uuid,q=T.uuid,I=l[z];I===void 0&&(I={},l[z]=I);let D=I[q];D===void 0&&(D=y.clone(),I[q]=D),y=D}if(y.visible=T.visible,y.wireframe=T.wireframe,L===on?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(M,T,A,L,y){if(M.visible===!1)return;if(M.layers.test(T.layers)&&(M.isMesh||M.isLine||M.isPoints)&&(M.castShadow||M.receiveShadow&&y===on)&&(!M.frustumCulled||n.intersectsObject(M))){M.modelViewMatrix.multiplyMatrices(A.matrixWorldInverse,M.matrixWorld);let q=t.update(M),I=M.material;if(Array.isArray(I)){let D=q.groups;for(let O=0,$=D.length;O<$;O++){let k=D[O],X=I[k.materialIndex];if(X&&X.visible){let J=_(M,X,L,y);i.renderBufferDirect(A,null,q,J,M,k)}}}else if(I.visible){let D=_(M,I,L,y);i.renderBufferDirect(A,null,q,D,M,null)}}let z=M.children;for(let q=0,I=z.length;q=1):X.indexOf("OpenGL ES")!==-1&&(k=parseFloat(/^OpenGL ES (\\d)/.exec(X)[1]),$=k>=2);let J=null,K={},B=i.getParameter(i.SCISSOR_BOX),Z=i.getParameter(i.VIEWPORT),ot=new Kt().fromArray(B),at=new Kt().fromArray(Z);function ct(C,nt,V,tt){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 Xt=0;XtQ||R.height>Q)&&(j=Q/Math.max(R.width,R.height)),j<1||S===!0)if(typeof HTMLImageElement!="undefined"&&R instanceof HTMLImageElement||typeof HTMLCanvasElement!="undefined"&&R instanceof HTMLCanvasElement||typeof ImageBitmap!="undefined"&&R instanceof ImageBitmap){let it=S?Br:Math.floor,ft=it(j*R.width),st=it(j*R.height);x===void 0&&(x=v(ft,st));let Y=G?v(ft,st):x;return Y.width=ft,Y.height=st,Y.getContext("2d").drawImage(R,0,0,ft,st),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+R.width+"x"+R.height+") to ("+ft+"x"+st+")."),Y}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 Sa(R.width)&&Sa(R.height)}function M(R){return o?!1:R.wrapS!==Ve||R.wrapT!==Ve||R.minFilter!==pe&&R.minFilter!==Le}function T(R,S){return R.generateMipmaps&&S&&R.minFilter!==pe&&R.minFilter!==Le}function A(R){i.generateMipmap(R)}function L(R,S,G,Q,j=!1){if(o===!1)return S;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 it=S;return S===i.RED&&(G===i.FLOAT&&(it=i.R32F),G===i.HALF_FLOAT&&(it=i.R16F),G===i.UNSIGNED_BYTE&&(it=i.R8)),S===i.RG&&(G===i.FLOAT&&(it=i.RG32F),G===i.HALF_FLOAT&&(it=i.RG16F),G===i.UNSIGNED_BYTE&&(it=i.RG8)),S===i.RGBA&&(G===i.FLOAT&&(it=i.RGBA32F),G===i.HALF_FLOAT&&(it=i.RGBA16F),G===i.UNSIGNED_BYTE&&(it=Q===Rt&&j===!1?i.SRGB8_ALPHA8:i.RGBA8),G===i.UNSIGNED_SHORT_4_4_4_4&&(it=i.RGBA4),G===i.UNSIGNED_SHORT_5_5_5_1&&(it=i.RGB5_A1)),(it===i.R16F||it===i.R32F||it===i.RG16F||it===i.RG32F||it===i.RGBA16F||it===i.RGBA32F)&&t.get("EXT_color_buffer_float"),it}function y(R,S,G){return T(R,G)===!0||R.isFramebufferTexture&&R.minFilter!==pe&&R.minFilter!==Le?Math.log2(Math.max(S.width,S.height))+1:R.mipmaps!==void 0&&R.mipmaps.length>0?R.mipmaps.length:R.isCompressedTexture&&Array.isArray(R.image)?S.mipmaps.length:1}function w(R){return R===pe||R===Yo||R===er?i.NEAREST:i.LINEAR}function z(R){let S=R.target;S.removeEventListener("dispose",z),I(S),S.isVideoTexture&&g.delete(S)}function q(R){let S=R.target;S.removeEventListener("dispose",q),O(S)}function I(R){let S=n.get(R);if(S.__webglInit===void 0)return;let G=R.source,Q=p.get(G);if(Q){let j=Q[S.__cacheKey];j.usedTimes--,j.usedTimes===0&&D(R),Object.keys(Q).length===0&&p.delete(G)}n.remove(R)}function D(R){let S=n.get(R);i.deleteTexture(S.__webglTexture);let G=R.source,Q=p.get(G);delete Q[S.__cacheKey],a.memory.textures--}function O(R){let S=R.texture,G=n.get(R),Q=n.get(S);if(Q.__webglTexture!==void 0&&(i.deleteTexture(Q.__webglTexture),a.memory.textures--),R.depthTexture&&R.depthTexture.dispose(),R.isWebGLCubeRenderTarget)for(let j=0;j<6;j++)i.deleteFramebuffer(G.__webglFramebuffer[j]),G.__webglDepthbuffer&&i.deleteRenderbuffer(G.__webglDepthbuffer[j]);else{if(i.deleteFramebuffer(G.__webglFramebuffer),G.__webglDepthbuffer&&i.deleteRenderbuffer(G.__webglDepthbuffer),G.__webglMultisampledFramebuffer&&i.deleteFramebuffer(G.__webglMultisampledFramebuffer),G.__webglColorRenderbuffer)for(let j=0;j=c&&console.warn("THREE.WebGLTextures: Trying to use "+R+" texture units while this GPU supports only "+c),$+=1,R}function J(R){let S=[];return S.push(R.wrapS),S.push(R.wrapT),S.push(R.wrapR||0),S.push(R.magFilter),S.push(R.minFilter),S.push(R.anisotropy),S.push(R.internalFormat),S.push(R.format),S.push(R.type),S.push(R.generateMipmaps),S.push(R.premultiplyAlpha),S.push(R.flipY),S.push(R.unpackAlignment),S.push(R.colorSpace),S.join()}function K(R,S){let G=n.get(R);if(R.isVideoTexture&&re(R),R.isRenderTargetTexture===!1&&R.version>0&&G.__version!==R.version){let Q=R.image;if(Q===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(Q.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{zt(G,R,S);return}}e.bindTexture(i.TEXTURE_2D,G.__webglTexture,i.TEXTURE0+S)}function B(R,S){let G=n.get(R);if(R.version>0&&G.__version!==R.version){zt(G,R,S);return}e.bindTexture(i.TEXTURE_2D_ARRAY,G.__webglTexture,i.TEXTURE0+S)}function Z(R,S){let G=n.get(R);if(R.version>0&&G.__version!==R.version){zt(G,R,S);return}e.bindTexture(i.TEXTURE_3D,G.__webglTexture,i.TEXTURE0+S)}function ot(R,S){let G=n.get(R);if(R.version>0&&G.__version!==R.version){xe(G,R,S);return}e.bindTexture(i.TEXTURE_CUBE_MAP,G.__webglTexture,i.TEXTURE0+S)}let at={[Dr]:i.REPEAT,[Ve]:i.CLAMP_TO_EDGE,[Nr]:i.MIRRORED_REPEAT},ct={[pe]:i.NEAREST,[Yo]:i.NEAREST_MIPMAP_NEAREST,[er]:i.NEAREST_MIPMAP_LINEAR,[Le]:i.LINEAR,[Rl]:i.LINEAR_MIPMAP_NEAREST,[ki]:i.LINEAR_MIPMAP_LINEAR},gt={[Gl]:i.NEVER,[$l]:i.ALWAYS,[Wl]:i.LESS,[ql]:i.LEQUAL,[Xl]:i.EQUAL,[Jl]:i.GEQUAL,[Yl]:i.GREATER,[Zl]:i.NOTEQUAL};function Et(R,S,G){if(G?(i.texParameteri(R,i.TEXTURE_WRAP_S,at[S.wrapS]),i.texParameteri(R,i.TEXTURE_WRAP_T,at[S.wrapT]),(R===i.TEXTURE_3D||R===i.TEXTURE_2D_ARRAY)&&i.texParameteri(R,i.TEXTURE_WRAP_R,at[S.wrapR]),i.texParameteri(R,i.TEXTURE_MAG_FILTER,ct[S.magFilter]),i.texParameteri(R,i.TEXTURE_MIN_FILTER,ct[S.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),(S.wrapS!==Ve||S.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(S.magFilter)),i.texParameteri(R,i.TEXTURE_MIN_FILTER,w(S.minFilter)),S.minFilter!==pe&&S.minFilter!==Le&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),S.compareFunction&&(i.texParameteri(R,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(R,i.TEXTURE_COMPARE_FUNC,gt[S.compareFunction])),t.has("EXT_texture_filter_anisotropic")===!0){let Q=t.get("EXT_texture_filter_anisotropic");if(S.magFilter===pe||S.minFilter!==er&&S.minFilter!==ki||S.type===vn&&t.has("OES_texture_float_linear")===!1||o===!1&&S.type===Hi&&t.has("OES_texture_half_float_linear")===!1)return;(S.anisotropy>1||n.get(S).__currentAnisotropy)&&(i.texParameterf(R,Q.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(S.anisotropy,s.getMaxAnisotropy())),n.get(S).__currentAnisotropy=S.anisotropy)}}function xt(R,S){let G=!1;R.__webglInit===void 0&&(R.__webglInit=!0,S.addEventListener("dispose",z));let Q=S.source,j=p.get(Q);j===void 0&&(j={},p.set(Q,j));let it=J(S);if(it!==R.__cacheKey){j[it]===void 0&&(j[it]={texture:i.createTexture(),usedTimes:0},a.memory.textures++,G=!0),j[it].usedTimes++;let ft=j[R.__cacheKey];ft!==void 0&&(j[R.__cacheKey].usedTimes--,ft.usedTimes===0&&D(S)),R.__cacheKey=it,R.__webglTexture=j[it].texture}return G}function zt(R,S,G){let Q=i.TEXTURE_2D;(S.isDataArrayTexture||S.isCompressedArrayTexture)&&(Q=i.TEXTURE_2D_ARRAY),S.isData3DTexture&&(Q=i.TEXTURE_3D);let j=xt(R,S),it=S.source;e.bindTexture(Q,R.__webglTexture,i.TEXTURE0+G);let ft=n.get(it);if(it.version!==ft.__version||j===!0){e.activeTexture(i.TEXTURE0+G),i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,S.flipY),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,S.premultiplyAlpha),i.pixelStorei(i.UNPACK_ALIGNMENT,S.unpackAlignment),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,i.NONE);let st=M(S)&&b(S.image)===!1,Y=_(S.image,st,!1,h);Y=ae(S,Y);let dt=b(Y)||o,pt=r.convert(S.format,S.colorSpace),_t=r.convert(S.type),ht=L(S.internalFormat,pt,_t,S.colorSpace);Et(Q,S,dt);let ut,Lt=S.mipmaps,Ht=o&&S.isVideoTexture!==!0,C=ft.__version===void 0||j===!0,nt=y(S,Y,dt);if(S.isDepthTexture)ht=i.DEPTH_COMPONENT,o?S.type===vn?ht=i.DEPTH_COMPONENT32F:S.type===yn?ht=i.DEPTH_COMPONENT24:S.type===Fn?ht=i.DEPTH24_STENCIL8:ht=i.DEPTH_COMPONENT16:S.type===vn&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),S.format===On&&ht===i.DEPTH_COMPONENT&&S.type!==mo&&S.type!==yn&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),S.type=yn,_t=r.convert(S.type)),S.format===_i&&ht===i.DEPTH_COMPONENT&&(ht=i.DEPTH_STENCIL,S.type!==Fn&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),S.type=Fn,_t=r.convert(S.type))),C&&(Ht?e.texStorage2D(i.TEXTURE_2D,1,ht,Y.width,Y.height):e.texImage2D(i.TEXTURE_2D,0,ht,Y.width,Y.height,0,pt,_t,null));else if(S.isDataTexture)if(Lt.length>0&&dt){Ht&&C&&e.texStorage2D(i.TEXTURE_2D,nt,ht,Lt[0].width,Lt[0].height);for(let V=0,tt=Lt.length;V>=1,tt>>=1}}else if(Lt.length>0&&dt){Ht&&C&&e.texStorage2D(i.TEXTURE_2D,nt,ht,Lt[0].width,Lt[0].height);for(let V=0,tt=Lt.length;V0&&C++,e.texStorage2D(i.TEXTURE_CUBE_MAP,C,ut,Y[0].width,Y[0].height));for(let V=0;V<6;V++)if(st){Lt?e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+V,0,0,0,Y[V].width,Y[V].height,_t,ht,Y[V].data):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+V,0,ut,Y[V].width,Y[V].height,0,_t,ht,Y[V].data);for(let tt=0;tt=i.TEXTURE_CUBE_MAP_POSITIVE_X&&j<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,Q,j,n.get(G).__webglTexture,0),e.bindFramebuffer(i.FRAMEBUFFER,null)}function N(R,S,G){if(i.bindRenderbuffer(i.RENDERBUFFER,R),S.depthBuffer&&!S.stencilBuffer){let Q=i.DEPTH_COMPONENT16;if(G||Vt(S)){let j=S.depthTexture;j&&j.isDepthTexture&&(j.type===vn?Q=i.DEPTH_COMPONENT32F:j.type===yn&&(Q=i.DEPTH_COMPONENT24));let it=Pt(S);Vt(S)?u.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,it,Q,S.width,S.height):i.renderbufferStorageMultisample(i.RENDERBUFFER,it,Q,S.width,S.height)}else i.renderbufferStorage(i.RENDERBUFFER,Q,S.width,S.height);i.framebufferRenderbuffer(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.RENDERBUFFER,R)}else if(S.depthBuffer&&S.stencilBuffer){let Q=Pt(S);G&&Vt(S)===!1?i.renderbufferStorageMultisample(i.RENDERBUFFER,Q,i.DEPTH24_STENCIL8,S.width,S.height):Vt(S)?u.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,Q,i.DEPTH24_STENCIL8,S.width,S.height):i.renderbufferStorage(i.RENDERBUFFER,i.DEPTH_STENCIL,S.width,S.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.RENDERBUFFER,R)}else{let Q=S.isWebGLMultipleRenderTargets===!0?S.texture:[S.texture];for(let j=0;j0&&Vt(R)===!1){let st=it?S:[S];G.__webglMultisampledFramebuffer=i.createFramebuffer(),G.__webglColorRenderbuffer=[],e.bindFramebuffer(i.FRAMEBUFFER,G.__webglMultisampledFramebuffer);for(let Y=0;Y0&&Vt(R)===!1){let S=R.isWebGLMultipleRenderTargets?R.texture:[R.texture],G=R.width,Q=R.height,j=i.COLOR_BUFFER_BIT,it=[],ft=R.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,st=n.get(R),Y=R.isWebGLMultipleRenderTargets===!0;if(Y)for(let dt=0;dt0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&S.__useRenderToTexture!==!1}function re(R){let S=a.render.frame;g.get(R)!==S&&(g.set(R,S),R.update())}function ae(R,S){let G=R.colorSpace,Q=R.format,j=R.type;return R.isCompressedTexture===!0||R.format===Fr||G!==Je&&G!==zn&&(G===Rt?o===!1?t.has("EXT_sRGB")===!0&&Q===ke?(R.format=Fr,R.minFilter=Le,R.generateMipmaps=!1):S=As.sRGBToLinear(S):(Q!==ke||j!==Sn)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",G)),S}this.allocateTextureUnit=X,this.resetTextureUnits=k,this.setTexture2D=K,this.setTexture2DArray=B,this.setTexture3D=Z,this.setTextureCube=ot,this.rebindTextures=Tt,this.setupRenderTarget=St,this.updateRenderTargetMipmap=Wt,this.updateMultisampleRenderTarget=Nt,this.setupDepthRenderbuffer=yt,this.setupFrameBufferTexture=Ut,this.useMultisampledRTT=Vt}function Vp(i,t,e){let n=e.isWebGL2;function s(r,a=zn){let o;if(r===Sn)return i.UNSIGNED_BYTE;if(r===fc)return i.UNSIGNED_SHORT_4_4_4_4;if(r===dc)return i.UNSIGNED_SHORT_5_5_5_1;if(r===Cl)return i.BYTE;if(r===Pl)return i.SHORT;if(r===mo)return i.UNSIGNED_SHORT;if(r===uc)return i.INT;if(r===yn)return i.UNSIGNED_INT;if(r===vn)return i.FLOAT;if(r===Hi)return n?i.HALF_FLOAT:(o=t.get("OES_texture_half_float"),o!==null?o.HALF_FLOAT_OES:null);if(r===Ll)return i.ALPHA;if(r===ke)return i.RGBA;if(r===Il)return i.LUMINANCE;if(r===Ul)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===Dl)return i.RED;if(r===pc)return i.RED_INTEGER;if(r===Nl)return i.RG;if(r===mc)return i.RG_INTEGER;if(r===gc)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===Zo||r===Jo||r===$o||r===Ko)if(o=t.get("WEBGL_compressed_texture_pvrtc"),o!==null){if(r===Zo)return o.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(r===Jo)return o.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(r===$o)return o.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(r===Ko)return o.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(r===Fl)return o=t.get("WEBGL_compressed_texture_etc1"),o!==null?o.COMPRESSED_RGB_ETC1_WEBGL:null;if(r===Qo||r===jo)if(o=t.get("WEBGL_compressed_texture_etc"),o!==null){if(r===Qo)return a===Rt?o.COMPRESSED_SRGB8_ETC2:o.COMPRESSED_RGB8_ETC2;if(r===jo)return a===Rt?o.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:o.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(r===ta||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)if(o=t.get("WEBGL_compressed_texture_astc"),o!==null){if(r===ta)return a===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:o.COMPRESSED_RGBA_ASTC_4x4_KHR;if(r===ea)return a===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:o.COMPRESSED_RGBA_ASTC_5x4_KHR;if(r===na)return a===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:o.COMPRESSED_RGBA_ASTC_5x5_KHR;if(r===ia)return a===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:o.COMPRESSED_RGBA_ASTC_6x5_KHR;if(r===sa)return a===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:o.COMPRESSED_RGBA_ASTC_6x6_KHR;if(r===ra)return a===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:o.COMPRESSED_RGBA_ASTC_8x5_KHR;if(r===oa)return a===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:o.COMPRESSED_RGBA_ASTC_8x6_KHR;if(r===aa)return a===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:o.COMPRESSED_RGBA_ASTC_8x8_KHR;if(r===ca)return a===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:o.COMPRESSED_RGBA_ASTC_10x5_KHR;if(r===la)return a===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:o.COMPRESSED_RGBA_ASTC_10x6_KHR;if(r===ha)return a===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:o.COMPRESSED_RGBA_ASTC_10x8_KHR;if(r===ua)return a===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:o.COMPRESSED_RGBA_ASTC_10x10_KHR;if(r===fa)return a===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:o.COMPRESSED_RGBA_ASTC_12x10_KHR;if(r===da)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===Ol||r===pa||r===ma||r===ga)if(o=t.get("EXT_texture_compression_rgtc"),o!==null){if(r===or)return o.COMPRESSED_RED_RGTC1_EXT;if(r===pa)return o.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(r===ma)return o.COMPRESSED_RED_GREEN_RGTC2_EXT;if(r===ga)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 Qr=class extends Re{constructor(t=[]){super(),this.isArrayCamera=!0,this.cameras=t}},ui=class extends ye{constructor(){super(),this.isGroup=!0,this.type="Group"}},kp={type:"move"},Vi=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(kp)))}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]}},jr=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=yn),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}},to=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 Kt;let M=new Re;M.layers.enable(2),M.viewport=new Kt;let T=[b,M],A=new Qr;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 Vi,v[B]=Z),Z.getTargetRaySpace()},this.getControllerGrip=function(B){let Z=v[B];return Z===void 0&&(Z=new Vi,v[B]=Z),Z.getGripSpace()},this.getHand=function(B){let Z=v[B];return Z===void 0&&(Z=new Vi,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",q);for(let B=0;B=0&&(_[at]=null,v[at].disconnect(ot))}for(let Z=0;Z=_.length){_.push(ot),at=gt;break}else if(_[gt]===null){_[gt]=ot,at=gt;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,gt=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],Ut=(ct[8]-1)/ct[0],N=(gt[8]+1)/gt[0],oe=Et*Ut,yt=Et*N,Tt=at/(-Ut+N),St=Tt*-Ut;Z.matrixWorld.decompose(B.position,B.quaternion,B.scale),B.translateX(St),B.translateZ(Tt),B.matrixWorld.compose(B.position,B.quaternion,B.scale),B.matrixWorldInverse.copy(B.matrixWorld).invert();let Wt=Et+Tt,Nt=xt+Tt,Pt=oe-St,Vt=yt+(at-St),re=zt*xt/Nt*Wt,ae=xe*xt/Nt*Wt;B.projectionMatrix.makePerspective(Pt,Vt,re,ae,Wt,Nt),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=M.near=b.near=B.near,A.far=M.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 Gp(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 M=_.program;n.updateUBOMapping(v,M);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(),M=v.__size,T=v.usage;return i.bindBuffer(i.UNIFORM_BUFFER,b),i.bufferData(i.UNIFORM_BUFFER,M,T),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,_,b),b}function d(){for(let v=0;v0){T=b%M;let q=M-T;T!==0&&q-w.boundary<0&&(b+=M-T,y.__offset=b)}b+=w.storage}return T=b%M,T>0&&(b+=M-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 Wp(){let i=ws("canvas");return i.style.display="block",i}var eo=class{constructor(t={}){let{canvas:e=Wp(),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=!0,this.toneMapping=cn,this.toneMappingExposure=1;let _=this,b=!1,M=0,T=0,A=null,L=-1,y=null,w=new Kt,z=new Kt,q=null,I=new kt(0),D=0,O=e.width,$=e.height,k=1,X=null,J=null,K=new Kt(0,0,O,$),B=new Kt(0,0,O,$),Z=!1,ot=new Fs,at=!1,ct=!1,gt=null,Et=new Gt,xt=new Dt,zt=new P,xe={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function Ut(){return A===null?k:1}let N=n;function oe(E,F){for(let H=0;H0?p=v[v.length-1]:p=null,f.pop(),f.length>0?x=f[f.length-1]:x=null};function Io(E,F,H,U){if(E.visible===!1)return;if(E.layers.test(F.layers)){if(E.isGroup)H=E.renderOrder;else if(E.isLOD)E.autoUpdate===!0&&E.update(F);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 mt=S.update(E),vt=E.material;vt.visible&&x.push(E,mt,vt,H,zt.z,null)}}else if((E.isMesh||E.isLine||E.isPoints)&&(!E.frustumCulled||ot.intersectsObject(E))){let mt=S.update(E),vt=E.material;if(U&&(E.boundingSphere!==void 0?(E.boundingSphere===null&&E.computeBoundingSphere(),zt.copy(E.boundingSphere.center)):(mt.boundingSphere===null&&mt.computeBoundingSphere(),zt.copy(mt.boundingSphere.center)),zt.applyMatrix4(E.matrixWorld).applyMatrix4(Et)),Array.isArray(vt)){let Mt=mt.groups;for(let It=0,bt=Mt.length;It0&&Gc(W,lt,F,H),U&&St.viewport(w.copy(U)),W.length>0&&Ki(W,F,H),lt.length>0&&Ki(lt,F,H),mt.length>0&&Ki(mt,F,H),St.buffers.depth.setTest(!0),St.buffers.depth.setMask(!0),St.buffers.color.setMask(!0),St.setPolygonOffset(!1)}function Gc(E,F,H,U){let W=Tt.isWebGL2;gt===null&&(gt=new hn(1,1,{generateMipmaps:!0,type:yt.has("EXT_color_buffer_half_float")?Hi:Sn,minFilter:ki,samples:W?4:0})),_.getDrawingBufferSize(xt),W?gt.setSize(xt.x,xt.y):gt.setSize(Br(xt.x),Br(xt.y));let lt=_.getRenderTarget();_.setRenderTarget(gt),_.getClearColor(I),D=_.getClearAlpha(),D<1&&_.setClearColor(16777215,.5),_.clear();let mt=_.toneMapping;_.toneMapping=cn,Ki(E,H,U),Pt.updateMultisampleRenderTarget(gt),Pt.updateRenderTargetMipmap(gt);let vt=!1;for(let Mt=0,It=F.length;Mt0),wt=!!H.morphAttributes.position,Yt=!!H.morphAttributes.normal,Zt=!!H.morphAttributes.color,De=U.toneMapped?_.toneMapping:cn,Qe=H.morphAttributes.position||H.morphAttributes.normal||H.morphAttributes.color,Jt=Qe!==void 0?Qe.length:0,Ft=Nt.get(U),Ks=p.state.lights;if(at===!0&&(ct===!0||E!==y)){let Ee=E===y&&U.id===L;ft.setState(U,E,Ee)}let ne=!1;U.version===Ft.__version?(Ft.needsLights&&Ft.lightsStateVersion!==Ks.state.version||Ft.outputColorSpace!==vt||W.isInstancedMesh&&Ft.instancing===!1||!W.isInstancedMesh&&Ft.instancing===!0||W.isSkinnedMesh&&Ft.skinning===!1||!W.isSkinnedMesh&&Ft.skinning===!0||Ft.envMap!==Mt||U.fog===!0&&Ft.fog!==lt||Ft.numClippingPlanes!==void 0&&(Ft.numClippingPlanes!==ft.numPlanes||Ft.numIntersection!==ft.numIntersection)||Ft.vertexAlphas!==It||Ft.vertexTangents!==bt||Ft.morphTargets!==wt||Ft.morphNormals!==Yt||Ft.morphColors!==Zt||Ft.toneMapping!==De||Tt.isWebGL2===!0&&Ft.morphTargetsCount!==Jt)&&(ne=!0):(ne=!0,Ft.__version=U.version);let Rn=Ft.currentProgram;ne===!0&&(Rn=Qi(U,F,W));let Fo=!1,Ui=!1,Qs=!1,fe=Rn.getUniforms(),Cn=Ft.uniforms;if(St.useProgram(Rn.program)&&(Fo=!0,Ui=!0,Qs=!0),U.id!==L&&(L=U.id,Ui=!0),Fo||y!==E){if(fe.setValue(N,"projectionMatrix",E.projectionMatrix),Tt.logarithmicDepthBuffer&&fe.setValue(N,"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 Ee=fe.map.cameraPosition;Ee!==void 0&&Ee.setValue(N,zt.setFromMatrixPosition(E.matrixWorld))}(U.isMeshPhongMaterial||U.isMeshToonMaterial||U.isMeshLambertMaterial||U.isMeshBasicMaterial||U.isMeshStandardMaterial||U.isShaderMaterial)&&fe.setValue(N,"isOrthographic",E.isOrthographicCamera===!0),(U.isMeshPhongMaterial||U.isMeshToonMaterial||U.isMeshLambertMaterial||U.isMeshBasicMaterial||U.isMeshStandardMaterial||U.isShaderMaterial||U.isShadowMaterial||W.isSkinnedMesh)&&fe.setValue(N,"viewMatrix",E.matrixWorldInverse)}if(W.isSkinnedMesh){fe.setOptional(N,W,"bindMatrix"),fe.setOptional(N,W,"bindMatrixInverse");let Ee=W.skeleton;Ee&&(Tt.floatVertexTextures?(Ee.boneTexture===null&&Ee.computeBoneTexture(),fe.setValue(N,"boneTexture",Ee.boneTexture,Pt),fe.setValue(N,"boneTextureSize",Ee.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=H.morphAttributes;if((js.position!==void 0||js.normal!==void 0||js.color!==void 0&&Tt.isWebGL2===!0)&&dt.update(W,H,Rn),(Ui||Ft.receiveShadow!==W.receiveShadow)&&(Ft.receiveShadow=W.receiveShadow,fe.setValue(N,"receiveShadow",W.receiveShadow)),U.isMeshGouraudMaterial&&U.envMap!==null&&(Cn.envMap.value=Mt,Cn.flipEnvMap.value=Mt.isCubeTexture&&Mt.isRenderTargetTexture===!1?-1:1),Ui&&(fe.setValue(N,"toneMappingExposure",_.toneMappingExposure),Ft.needsLights&&Xc(Cn,Qs),lt&&U.fog===!0&&Q.refreshFogUniforms(Cn,lt),Q.refreshMaterialUniforms(Cn,U,k,$,gt),pi.upload(N,Ft.uniformsList,Cn,Pt)),U.isShaderMaterial&&U.uniformsNeedUpdate===!0&&(pi.upload(N,Ft.uniformsList,Cn,Pt),U.uniformsNeedUpdate=!1),U.isSpriteMaterial&&fe.setValue(N,"center",W.center),fe.setValue(N,"modelViewMatrix",W.modelViewMatrix),fe.setValue(N,"normalMatrix",W.normalMatrix),fe.setValue(N,"modelMatrix",W.matrixWorld),U.isShaderMaterial||U.isRawShaderMaterial){let Ee=U.uniformsGroups;for(let tr=0,Yc=Ee.length;tr0&&Pt.useMultisampledRTT(E)===!1?W=Nt.get(E).__webglMultisampledFramebuffer:W=bt,w.copy(E.viewport),z.copy(E.scissor),q=E.scissorTest}else w.copy(K).multiplyScalar(k).floor(),z.copy(B).multiplyScalar(k).floor(),q=Z;if(St.bindFramebuffer(N.FRAMEBUFFER,W)&&Tt.drawBuffers&&U&&St.drawBuffers(E,W),St.viewport(w),St.scissor(z),St.setScissorTest(q),lt){let Mt=Nt.get(E.texture);N.framebufferTexture2D(N.FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_CUBE_MAP_POSITIVE_X+F,Mt.__webglTexture,H)}else if(mt){let Mt=Nt.get(E.texture),It=F||0;N.framebufferTextureLayer(N.FRAMEBUFFER,N.COLOR_ATTACHMENT0,Mt.__webglTexture,H||0,It)}L=-1},this.readRenderTargetPixels=function(E,F,H,U,W,lt,mt){if(!(E&&E.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let vt=Nt.get(E).__webglFramebuffer;if(E.isWebGLCubeRenderTarget&&mt!==void 0&&(vt=vt[mt]),vt){St.bindFramebuffer(N.FRAMEBUFFER,vt);try{let Mt=E.texture,It=Mt.format,bt=Mt.type;if(It!==ke&&ht.convert(It)!==N.getParameter(N.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}let wt=bt===Hi&&(yt.has("EXT_color_buffer_half_float")||Tt.isWebGL2&&yt.has("EXT_color_buffer_float"));if(bt!==Sn&&ht.convert(bt)!==N.getParameter(N.IMPLEMENTATION_COLOR_READ_TYPE)&&!(bt===vn&&(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}F>=0&&F<=E.width-U&&H>=0&&H<=E.height-W&&N.readPixels(F,H,U,W,ht.convert(It),ht.convert(bt),lt)}finally{let Mt=A!==null?Nt.get(A).__webglFramebuffer:null;St.bindFramebuffer(N.FRAMEBUFFER,Mt)}}},this.copyFramebufferToTexture=function(E,F,H=0){let U=Math.pow(2,-H),W=Math.floor(F.image.width*U),lt=Math.floor(F.image.height*U);Pt.setTexture2D(F,0),N.copyTexSubImage2D(N.TEXTURE_2D,H,0,0,E.x,E.y,W,lt),St.unbindTexture()},this.copyTextureToTexture=function(E,F,H,U=0){let W=F.image.width,lt=F.image.height,mt=ht.convert(H.format),vt=ht.convert(H.type);Pt.setTexture2D(H,0),N.pixelStorei(N.UNPACK_FLIP_Y_WEBGL,H.flipY),N.pixelStorei(N.UNPACK_PREMULTIPLY_ALPHA_WEBGL,H.premultiplyAlpha),N.pixelStorei(N.UNPACK_ALIGNMENT,H.unpackAlignment),F.isDataTexture?N.texSubImage2D(N.TEXTURE_2D,U,E.x,E.y,W,lt,mt,vt,F.image.data):F.isCompressedTexture?N.compressedTexSubImage2D(N.TEXTURE_2D,U,E.x,E.y,F.mipmaps[0].width,F.mipmaps[0].height,mt,F.mipmaps[0].data):N.texSubImage2D(N.TEXTURE_2D,U,E.x,E.y,mt,vt,F.image),U===0&&H.generateMipmaps&&N.generateMipmap(N.TEXTURE_2D),St.unbindTexture()},this.copyTextureToTexture3D=function(E,F,H,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,mt=E.max.y-E.min.y+1,vt=E.max.z-E.min.z+1,Mt=ht.convert(U.format),It=ht.convert(U.type),bt;if(U.isData3DTexture)Pt.setTexture3D(U,0),bt=N.TEXTURE_3D;else if(U.isDataArrayTexture)Pt.setTexture2DArray(U,0),bt=N.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}N.pixelStorei(N.UNPACK_FLIP_Y_WEBGL,U.flipY),N.pixelStorei(N.UNPACK_PREMULTIPLY_ALPHA_WEBGL,U.premultiplyAlpha),N.pixelStorei(N.UNPACK_ALIGNMENT,U.unpackAlignment);let wt=N.getParameter(N.UNPACK_ROW_LENGTH),Yt=N.getParameter(N.UNPACK_IMAGE_HEIGHT),Zt=N.getParameter(N.UNPACK_SKIP_PIXELS),De=N.getParameter(N.UNPACK_SKIP_ROWS),Qe=N.getParameter(N.UNPACK_SKIP_IMAGES),Jt=H.isCompressedTexture?H.mipmaps[0]:H.image;N.pixelStorei(N.UNPACK_ROW_LENGTH,Jt.width),N.pixelStorei(N.UNPACK_IMAGE_HEIGHT,Jt.height),N.pixelStorei(N.UNPACK_SKIP_PIXELS,E.min.x),N.pixelStorei(N.UNPACK_SKIP_ROWS,E.min.y),N.pixelStorei(N.UNPACK_SKIP_IMAGES,E.min.z),H.isDataTexture||H.isData3DTexture?N.texSubImage3D(bt,W,F.x,F.y,F.z,lt,mt,vt,Mt,It,Jt.data):H.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),N.compressedTexSubImage3D(bt,W,F.x,F.y,F.z,lt,mt,vt,Mt,Jt.data)):N.texSubImage3D(bt,W,F.x,F.y,F.z,lt,mt,vt,Mt,It,Jt),N.pixelStorei(N.UNPACK_ROW_LENGTH,wt),N.pixelStorei(N.UNPACK_IMAGE_HEIGHT,Yt),N.pixelStorei(N.UNPACK_SKIP_PIXELS,Zt),N.pixelStorei(N.UNPACK_SKIP_ROWS,De),N.pixelStorei(N.UNPACK_SKIP_IMAGES,Qe),W===0&&U.generateMipmaps&&N.generateMipmap(bt),St.unbindTexture()},this.initTexture=function(E){E.isCubeTexture?Pt.setTextureCube(E,0):E.isData3DTexture?Pt.setTexture3D(E,0):E.isDataArrayTexture||E.isCompressedArrayTexture?Pt.setTexture2DArray(E,0):Pt.setTexture2D(E,0),St.unbindTexture()},this.resetState=function(){M=0,T=0,A=null,St.reset(),ut.reset()},typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return an}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:_c}set outputEncoding(t){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=t===Bn?Rt:Je}},no=class extends eo{};no.prototype.isWebGL1Renderer=!0;function xn(i,t,e){return Ac(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 Ac(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=xn(n,r,a),this.values=xn(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&&Ac(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=xn(this.times),e=xn(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=xn(t,0,a),this.values=xn(e,0,a*n)):(this.times=t,this.values=e),this}clone(){let t=xn(this.times,0),e=xn(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 oo=class extends We{};oo.prototype.ValueTypeName="color";var ao=class extends We{};ao.prototype.ValueTypeName="number";var co=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}},Wi=class extends We{InterpolantFactoryMethodLinear(t){return new co(this.times,this.values,this.getValueSize(),t)}};Wi.prototype.ValueTypeName="quaternion";Wi.prototype.DefaultInterpolation=Es;Wi.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 lo=class extends We{};lo.prototype.ValueTypeName="vector";var ho=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 vo(i,t){t.set(i)}function Mo(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 qi(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 nm(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 Qt(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 q=i[v+4],I=i[v+5],D=q-I,O=q+I;Dh&&(h=O),f&&qp&&(p=q)}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 sm(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 rm(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(fn).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),Vs=new Float32Array(6);function am(i,t,e,n,s,r){let a=-1,o=0;if(r===0)a=yo(t),a!==-1&&(o=(t[a]+t[a+3])/2);else if(r===1)a=yo(i),a!==-1&&(o=cm(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)/fn;if(s=A.candidate?qi(b,e,A.rightCacheBounds):(qi(b,e,A.leftCacheBounds),A.count++)}}for(let b=0;b<_;b++){let M=f[b],T=M.count,A=s-M.count,L=M.leftCacheBounds,y=M.rightCacheBounds,w=0;T!==0&&(w=bi(L)/c);let z=0;A!==0&&(z=bi(y)/c);let q=1+1.25*(w*T+z*A);q=fn&&(T=fn-1);let A=Tn[T];A.count++,qi(_,e,A.bounds)}let f=Tn[fn-1];vo(f.bounds,f.rightCacheBounds);for(let _=fn-2;_>=0;_--){let b=Tn[_],M=Tn[_+1];Mo(b.bounds,M.rightCacheBounds,b.rightCacheBounds)}let v=0;for(let _=0;_T&&(T=_),b>T&&(T=b);let A=(T-M)/2,L=f*2;r[m+L+0]=M+A,r[m+L+1]=A+(Math.abs(M)+A)*Rc,Mt[f+3]&&(t[f+3]=T)}}return r}function hm(i,t){function e(f){u&&u(f/m)}function n(f,v,_,b=null,M=0){if(!g&&M>=c&&(g=!0,l&&(console.warn(`MeshBVH: Max depth of ${c} reached when generating BVH. Consider increasing maxDepth.`),console.warn(i))),_<=h||M>=c)return e(v+_),f.offset=v,f.count=_,f;let T=am(f.boundingData,b,a,v,_,d);if(T.axis===-1)return e(v+_),f.offset=v,f.count=_,f;let A=rm(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),bo(a,y,w,L.boundingData,r),n(L,y,w,r,M+1);let z=new Wn,q=A,I=_-w;f.right=z,z.boundingData=new Float32Array(6),bo(a,q,I,z.boundingData,r),n(z,q,I,r,M+1)}return f}nm(i,t);let s=new Float32Array(6),r=new Float32Array(6),a=lm(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=im(i);if(p.length===1){let f=p[0],v=new Wn;v.boundingData=s,sm(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),bo(a,f.offset,f.count,v.boundingData,r),n(v,f.offset,f.count,r),x.push(v)}return x}function Lc(i,t){let e=hm(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 Me=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}};Me.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 Im=function(){let i=new Me;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 um=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}}(),Yi=function(){let i=new Dt,t=new P,e=new P;return function(s,r,a,o){um(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}}}}(),Ic=function(){let i=new P,t=new P,e=new Ce,n=new ve;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 fm=1e-15;function Ei(i){return Math.abs(i)new P),this.satBounds=new Array(4).fill().map(()=>new Me),this.points=[this.a,this.b,this.c],this.sphere=new Vn,this.plane=new Ce,this.needsUpdate=!0}intersectsSphere(t){return Ic(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}};Se.prototype.closestPointToSegment=function(){let i=new P,t=new P,e=new ve;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]),Yi(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,M=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=M[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=M[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 k=_?h.start:h.end,X=Ei(f.distanceToPoint(O));if(Ei(f.normal.dot(a))&&X){h.copy(l),b=2;break}if((f.intersectLine(l,k)||X)&&!Ei(k.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 M=m.points,T=!1,A=0;for(let D=0;D<3;D++){let O=M[D],$=M[(D+1)%3];l.start.copy(O),l.end.copy($),l.delta(o);let k=T?d.start:d.end,X=Ei(p.distanceToPoint(O));if(Ei(p.normal.dot(o))&&X){d.copy(l),A=2;break}if((p.intersectLine(l,k)||X)&&!Ei(k.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),q=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)}}}();Se.prototype.distanceToPoint=function(){let i=new P;return function(e){return this.closestPointToPoint(e,i),e.distanceTo(i)}}();Se.prototype.distanceToTriangle=function(){let i=new P,t=new P,e=["a","b","c"],n=new ve,s=new ve;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 Me),this.alignedSatBounds=new Array(3).fill().map(()=>new Me),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}};be.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 ve),e=new Array(12).fill().map(()=>new ve),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 Vc=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,M=wn,T=An;for(;!dn(b,M);)_=Ai(_),b=_*2;return Xn(_,T)}function m(_){let b=_*2,M=wn,T=An;for(;!dn(b,M);)_=Ri(_,T),b=_*2;return Xn(_,T)+wi(b,M)}let g=r*2,x=Pi,p=wn,f=An;if(dn(g,p)){let _=Xn(r,f),b=wi(g,p);return Ie(r,x,i),c(_,b,!1,d,h+r,i)}else{let _=Ai(r),b=Ri(r,f),M=_,T=b,A,L,y,w;if(l&&(y=i,w=t,Ie(M,x,y),Ie(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=M*3,w=(T+M)*3;ynew Se),Ke=class{static serialize(t,e={}){if(e.isBufferGeometry)return console.warn("MeshBVH.serialize: The arguments for the function have changed. See documentation for new signature."),Ke.serialize(arguments[0],{cloneBuffers:arguments[2]===void 0?!0:arguments[2]});e=ji({cloneBuffers:!0},e);let n=t.geometry,s=t._roots,r=n.getIndex(),a;return e.cloneBuffers?a={roots:s.map(o=>o.slice()),index:r.array.slice()}:a={roots:s,index:r.array},a}static deserialize(t,e,n={}){if(typeof n=="boolean")return console.warn("MeshBVH.deserialize: The arguments for the function have changed. See documentation for new signature."),Ke.deserialize(arguments[0],arguments[1],{setIndex:arguments[2]===void 0?!0:arguments[2]});n=ji({setIndex:!0},n);let{index:s,roots:r}=t,a=new Ke(e,Vo(ji({},n),{[Ro]:!0}));if(a._roots=r,n.setIndex){let o=e.getIndex();if(o===null){let c=new Qt(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,[Ro]:!1},e),e.useSharedArrayBuffer&&typeof SharedArrayBuffer=="undefined")throw new Error("MeshBVH: SharedArrayBuffer is not available.");this._roots=null,e[Ro]||(this._roots=Lc(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=q),IA&&(A=I),DL&&(L=D)}return c[u+0]!==_||c[u+1]!==b||c[u+2]!==M||c[u+3]!==T||c[u+4]!==A||c[u+5]!==L?(c[u+0]=_,c[u+1]=b,c[u+2]=M,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,M=g,T=!1,A=!1;t?M||(T=t.has(_),A=t.has(b),M=!T&&!A):(T=!0,A=!0);let L=M||T,y=M||A,w=!1;L&&(w=d(f,m,M));let z=!1;y&&(z=d(v,m,M));let q=w||z;if(q)for(let I=0;I<3;I++){let D=f+I,O=v+I,$=c[D],k=c[D+3],X=c[O],J=c[O+3];c[u+I]=$J?k:J}return q}}}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=$e.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:wo(m,g,s,l,x,p,r)}else c||(l?c=(u,m,g,x)=>wo(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=Vc(0,s,o,c,a,d),Zi(),h)break;d+=u.byteLength}return $e.releasePrimitive(r),h}bvhcast(t,e,n){let{intersectsRanges:s,intersectsTriangles:r}=n,a=this.geometry.index,o=this.geometry.attributes.position,c=t.geometry.index,l=t.geometry.attributes.position;Ii.copy(e).invert();let h=$e.getPrimitive(),d=$e.getPrimitive();if(r){let m=function(g,x,p,f,v,_,b,M){for(let T=p,A=p+f;TPo.intersectsBox(m),intersectsRange:(m,g,x,p,f,v)=>(Co.copy(v),Co.applyMatrix4(Ii),t.shapecast({intersectsBounds:_=>Co.intersectsBox(_),intersectsRange:(_,b,M,T,A)=>s(m,g,_,b,p,f,T,A)}))});return $e.releasePrimitive(h),$e.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=$e.getPrimitive(),m=$e.getPrimitive(),g=$s,x=_m,p=null,f=null;s&&(p=xm,f=ym);let v=1/0,_=null,b=null;return Ii.copy(e).invert(),Ji.matrix.copy(Ii),this.shapecast({boundsTraverseOrder:M=>qn.distanceToBox(M),intersectsBounds:(M,T,A)=>A{if(t.boundsTree)return t.boundsTree.shapecast({boundsTraverseOrder:A=>Ji.distanceToBox(A),intersectsBounds:(A,L,y)=>y{for(let y=A*3,w=(A+L)*3;y($i.copy(t).clamp(h.min,h.max),$i.distanceToSquared(t)),intersectsBounds:(h,d,u)=>u{h.closestPointToPoint(t,$i);let u=t.distanceToSquared($i);return u{Ie(0,new Float32Array(n),Hc),t.union(Hc)}),t}};var Lo=self;Lo.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 Qt(r,3,!1)),s&&o.setIndex(new Qt(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 Ke(o,a),l=Ke.serialize(c,{cloneBuffers:!1});Lo.postMessage({id:n,error:void 0,serialized:l,position:r,progress:1},[l.index.buffer,r.buffer,...l.roots])}catch(o){Lo.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')}ba.decoderPath="libs/draco/gltf/";var nC=class{constructor(){this.running=!1,this.worker=new OU,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 J.warn("[GenerateMeshBVHWorker] Already running job.");if(!this.worker)return void J.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=>{J.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)J.warn(i.error),s();else if(i.serialized){let{serialized:e,position:r,id:a}=i,o=n.get(a),l=tc.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),J.debug("before update, index:",o.index.array),o.index.array=e.index;else{let t=new nn(e.index,1,!1);o.setIndex(t)}o.index&&(J.debug("after update, index:",o.index.array),o.index.needsUpdate=!0),h.setBoundingBox&&!o.boundingBox&&(o.boundingBox=l.getBoundingBox(new bt)),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){J.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:ai(qn({},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}},uf=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;J.debug("startIndex: "+l+" endIndex: "+h),a.push(i.generate(e.slice(l,h),t))}Promise.allSettled(a).then((()=>{this.running=!1,i()}))}));J.warn("[BVHHelper] Worker has been disposed.")}}))}dispose(){for(let e=0;e{e.traverse((e=>{let n=e;if(n.isMesh&&n.geometry&&Pr.isMergedMesh(n)&&!(n instanceof _i)){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 tc(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&&Pr.isMergedMesh(t)&&!(t instanceof _i)){if(i.has(t.geometry.id))return;n.push(t.geometry),i.add(t.geometry.id)}}))}));let r=new uf;r.generate(n,t).then((()=>{r.dispose()}))}},Epe=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 bt;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=lut(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()}},lut=(e,t,i=800,n=45)=>{let r=n*(Math.PI/180);return i*(e/(2*Math.tan(r/2)*t))},rC,iC=new fe,sC=new fe,aC=new fe,_pe=new fe,cut=new fe,uut=new fe,Ka=class extends mi{constructor(e){super(ft.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=Ka.FILL_COLOR_NONE,e.strokeStyle=Ka.LINE_COLOR,e.lineWidth=Ka.LINE_WIDTH,e.beginPath(),this.drawSnapFunctions[this.snapType](e,t),rC&&this.drawDebug(e,t),e.closePath(),e.fill(),e.stroke(),e.restore())}drawDebug(e,t){null==rC||rC.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=Ka.SNAP_LINE_COLOR,e.lineWidth=Ka.LINE_WIDTH;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=Ka.SNAP_ICON_SIZE/1.6,r=iC.set(i.x,i.y-n),a=sC.set(i.x-.87*n,i.y+n/1.4),s=aC.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=Ka.SNAP_ICON_SIZE,r=Ka.SNAP_ICON_SIZE;e.rect(i.x-n/2,i.y-r/2,n,r)}drawTriangle(e,t){let i=this.transToScreenCoord(this.osnapInfo.point,t),n=Ka.SNAP_ICON_SIZE/1.6,r=iC.set(i.x,i.y-n),a=sC.set(i.x-.87*n,i.y+n/2),s=aC.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=Ka.SNAP_ICON_SIZE/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=Ka.SNAP_ICON_SIZE/2,r=iC.set(i.x-n,i.y-n),a=sC.set(i.x+n,i.y+n),s=aC.set(i.x+n,i.y-n),o=_pe.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=Ka.SNAP_ICON_SIZE/2,r=iC.set(i.x,i.y),a=sC.set(i.x-n,i.y),s=aC.set(i.x,i.y+n),o=_pe.set(i.x-n,i.y-n),l=cut.set(i.x-n,i.y+n),h=uut.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"}},Za=Ka;Za.LINE_COLOR="rgba(255, 119, 0, 1)",Za.FILL_COLOR_NONE="rgba(0, 0, 0, 0)",Za.SNAP_LINE_COLOR="rgba(255, 240, 0, 0.3)",Za.LINE_WIDTH=2,Za.SNAP_ICON_SIZE=14,_n._registerDrawableClass(Za);var Tpe=(e=>(e[e.None=0]="None",e[e.PointOnLine=1]="PointOnLine",e[e.StartPoint=2]="StartPoint",e[e.EndPoint=4]="EndPoint",e[e.MiddlePoint=8]="MiddlePoint",e[e.FootOfPerpendicular=16]="FootOfPerpendicular",e[e.Intersection=32]="Intersection",e[e.CircleCenter=64]="CircleCenter",e))(Tpe||{}),hut=1e-5,oC=class{constructor(e){var t;this.drawableList=new So("snap"),this.markers={},this.activeOSnapType=0,this.snapToleranceInWorldCoord=1,this.intersectionLimit=10,this.osnapTypePriorities={2:0,4:0,8:1,64:2,32:3,16:4,1:5,0:6},this.overlayRender=e,null==(t=this.overlayRender)||t.addDrawableList(this.drawableList),this.initOSnapMarkers()}initOSnapMarkers(){let e=new Za("TripleCross"),t=new Za("Square"),i=new Za("Triangle"),n=new Za("CircleWithCross"),r=new Za("Cross"),a=new Za("Perpendicular");this.markers[2]=t,this.markers[4]=t,this.markers[8]=i,this.markers[1]=e,this.markers[32]=r,this.markers[64]=n,this.markers[16]=a,Object.values(this.markers).forEach((e=>{e.visible=!1,this.drawableList.addDrawable(e)}))}setSnapTolerance(e){this.snapToleranceInWorldCoord=e}getSnapTolerance(){return this.snapToleranceInWorldCoord}setIntersectionLimit(e){this.intersectionLimit=e}getIntersectionLimit(){return this.intersectionLimit}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,n){var r;if(t&&i&&(e.sort(((e,t)=>e.distance-t.distance)),e=this.getIntersectsIncludeOutline(e,i)),!e||e.length<1)return void this.deactivate();let a;if(!t){for(let t of e)if(t.point.z=0,"groundPlane"===(null==(r=t.object)?void 0:r.name)){a=t.point;continue}if(a){for(let i of e)i.distance=i.point.distanceTo(a);let t=e=>e instanceof Yr?0:e instanceof Ar?2:e instanceof Wn?1:3;e.sort(((e,i)=>{let n=t(e.object),r=t(i.object);return n!==r?n-r:e.distance-i.distance}))}}if(!a){for(let t of e)if(t.object instanceof ht){a=t.point;break}a||(J.warn("[OSnap] Potential to produce erroneous snap results"),a=e[0].point)}J.debug("[OSnap] intersections:",e),J.debug("[OSnap] mousePosition:",a);let s=this.getSnapPointAndUpdateMarker(a,e,t,n);return(null==s?void 0:s.clone())||a}getSnapPointAndUpdateMarker(e,t,i,n){if(null==t||!t.length)return void this.activateMarker(0);let r=this.getIntersectionPointsAndLines(e,t,i);if(r){let t=this.getSnapInfo(e,r,n);return t&&0!==t.type?(this.activateMarker(t.type,t),t.point):void this.activateMarker(0)}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=hut){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)2?r[s+2]:0,h=new P(r[s],r[s+1],l);h.applyMatrix4(o.matrixWorld),i||h.setZ(0),"CircleCenter"===o.userData.type?n.push(h):n.push({start:h,end:h})}}return n}getSnapInfo(e,t,i){let n,r=this.snapToleranceInWorldCoord,a=[];for(let s of t)if(s instanceof P){let t=e.distanceTo(s);t<2*r&&a.push({distance:t,type:64,point:s})}else{let t=s,{start:o,end:l}=t;if(i){let n=this.getFootOfPerpendicular(i,t,r),s=e.distanceTo(n);if(sthis.osnapTypePriorities[e.type]-this.osnapTypePriorities[t.type])),a[0]}getIntersectsIncludeOutline(e,t){let i=e.slice(),n=[];for(let a=0;a0&&(r=t.intersectObjects(n)||[],J.debug("[OSnap] Intersected with newly created edges: ",r),r.length>0&&i.push(...r)),i.sort(((e,t)=>e.distance-t.distance)),i}},lC=class{constructor(e){this.actived=!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=$t.worldCoordinate2NormalizedScreenCoordinate(e.min,this.camera,this.viewerContainer),i=$t.worldCoordinate2NormalizedScreenCoordinate(e.max,this.camera,this.viewerContainer),r=new Pi(new fe(Math.min(t.x,i.x),Math.min(t.y,i.y)),new fe(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}isActived(){return this.actived}activate(){var e,t;if(this.isActived())return void(this.reject&&(this.deactivate(),this.reject("PickMarkupHelper is already actived!"),this.isResolvedOrRejected=!0));this.actived=!0,this.viewer.addEventListener("MouseClicked",this.mouseClicked),null==(e=this.viewer.getInputManager())||e.addEventListener("keydown",this.keydown);let i=this.viewer.translate;if(i){this.tooltip=new vl("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.actived=!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 nt(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!")}},cC=class{constructor(e){this.mouseDown=!1,this.mouseMove=!1,this.mouseDownPositionX=-1,this.mouseDownPositionY=-1,this.tempEnableRotate=!1,this.actived=!1,this.isResolvedOrRejected=!1,this.mousedown=e=>{var t,i;if(0===e.button){this.mouseDown=!0;let n=new fe(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 fe(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 fe(Math.min(this.mouseDownPositionX,t.x),Math.min(this.mouseDownPositionY,t.y)),i=new fe(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 fe(e.x,e.y),i=new fe(Math.min(this.mouseDownPositionX,t.x),Math.min(this.mouseDownPositionY,t.y)),n=new fe(Math.max(this.mouseDownPositionX,t.x),Math.max(this.mouseDownPositionY,t.y)),r=new Pi(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}isActived(){return this.actived}activate(){var e;if(this.isActived())return void(this.reject&&(this.deactivate(),this.reject("BoxSelectHelper is already actived!"),this.isResolvedOrRejected=!0));this.actived=!0,this.input.addEventListener("pointerdown",this.mousedown),this.input.addEventListener("pointermove",this.mousemove),this.input.addEventListener("pointerup",this.mouseup),this.input.addEventListener("keydown",this.keydown);let t=this.viewer.controls;this.tempKey=t.mouseButtons.left,this.tempEnableRotate=t.enableRotate,t.mouseButtons.left=at.NONE,this.tempTouch=t.touches.one,t.touches.one=at.NONE,t.enableRotate=!1;let i=this.viewer.translate;if(i){this.tooltip=new vl("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.actived=!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: ${cC.BORDER_WIDTH} solid ${cC.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 nt(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!")}},hf=cC;hf.BORDER_COLOR="#fff000",hf.BORDER_WIDTH="2px";var Tr=class extends zi{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)}},Ov=(e=>(e.BaseViewer="BaseViewer",e.BimViewer="BimViewer",e.DxfViewer="DxfViewer",e.VRViewer="VRViewer",e))(Ov||{}),df=class extends zi{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 tA,this.initLogLevel(),this.initLocalization(),dn.isBrowser&&!e.context&&(this.initContainer(),this.initViewerContainer(),this.initWidgetContainer())}initLogLevel(){let e=this.viewerCfg.logLevel;e&&oue(e)}initLocalization(){var e;let t=(null==(e=this.viewerCfg)?void 0:e.language)||"cn";return um.init({lng:t,debug:!1,resources:{en:{translation:Bue},cn:{translation:Hue}}}),um.t}initContainer(){let e=document.getElementById(this.viewerCfg.containerId);e||(J.error("[BaseViewer] containerId:",this.viewerCfg.containerId,"is not found in dom tree! will append to document body"),e=document.body);let t=document.createElement("div");t.classList.add("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?J.warn("[BaseViewer] 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 jn)i.aspect=e/t;else if(i instanceof Er){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;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.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(),null==(n=this.undoRedoManager)||n.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 nt(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 P;e.getWorldPosition(r);let a=new P,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}addPlugin(e){this.plugins.find((t=>t.id===e.id))?J.error(`[BaseViewer] Plugin already exist: ${e.id}`):(this.plugins.push(e),J.debug(`[BaseViewer] Added plugin: ${e.id}`))}removePlugin(e){for(let t=0,i=this.plugins.length;tt.id===e))}},kv=class{constructor(e){this.actived=!1,this.viewer=e,this.boxSelectHelper=new hf(e)}get viewerContainer(){return this.viewer.viewerContainer}get camera(){return this.viewer.camera}get raycaster(){return this.viewer.getRaycaster()}isActived(){return this.actived}activate(){var e;this.actived=!0,null==(e=this.boxSelectHelper)||e.select().then((e=>{e&&this.handleZoomToRect(e.min,e.max)}))}deactivate(){var e;this.actived=!1,null==(e=this.boxSelectHelper)||e.deactivate()}pickPositionByScreenPoint(e){let t=$t.screenPoint2NdcPoint(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 P(Math.min(i.x,n.x),Math.min(i.y,n.y),Math.min(i.z,n.z)),t=new P(Math.max(i.x,n.x),Math.max(i.y,n.y),Math.max(i.z,n.z)),r=new bt(e,t);this.viewer.zoomToBBox(r)}}destroy(){var e;null==(e=this.boxSelectHelper)||e.destroy(),this.boxSelectHelper=void 0}},uC=class extends mi{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 fe(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"}},wpe=new P,hC=class extends xu{constructor(e,t,i,n){super("Area",e,t,i,n)}activate(){super.activate()}deactivate(){super.deactivate(),this.currentMeasureDrawable&&this.removeDrawable(this.currentMeasureDrawable),this.exitButton&&(this.exitButton.style.display="none")}createMeasureDrawable(){if(this.drawingPoints)return new cE(ft.guid(),this.drawingPoints)}onMouseMove(e){if(super.onMouseMove(e),this.drawingPoints&&this.drawingPoints.length>2&&this.drawingPoints[0]){let t=this.drawingPoints[0];wpe.subVectors(e,t).length()<3*this.viewer.getPixelSizeInWorldCoord()&&(this.osnapHelper.activateMarker(2,{point:t,type:2,distance:0}),J.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 J.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(wpe.subVectors(a,e).length()<3*this.viewer.getPixelSizeInWorldCoord())return J.info("[AreaMeasurement] auto close area measurement."),this.touchDowned=!1,void this.exitDrawing()}this.drawingPoints[0]&&Nt.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&&(J.warn("[Measure] If the number of points is less than 3, the measurement area cannot be formed !"),t=!1),t&&Xp.isSelfIntersecting(e)&&(J.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))}}},pE=class extends pr{constructor(e,t){super(e,t),this.type="Coordinate",this.update(t)}draw(e,t){this.drawText(e,t),e.save(),e.lineWidth=pr.LINE_WIDTH,e.strokeStyle=pr.MAJOR_COLOR,e.fillStyle=pr.AREA_FILL_COLOR;let i=this.points;e.beginPath(),i.forEach((i=>{let n=this.transToScreenCoord(i,t);e.arc(n.x,n.y,pr.POINT_RADIUS,0,2*Math.PI)})),e.fill(),e.stroke(),e.restore()}drawText(e,t){let i=this.points[0];Nt.areNumbersEqual(i.x,0);let n=Nt.areNumbersEqual(i.x,0)?0:i.x,r=Nt.areNumbersEqual(i.y,0)?0:i.y,a=Nt.areNumbersEqual(i.z,0)?0:i.z;this.label=`${ru(n,2)}, ${ru(r,2)}, ${ru(a,2)}`,e.font=`${pr.LABEL_FONT_SIZE}px Arial`;let s=1.2*e.measureText(this.label).width,o=1.5*pr.LABEL_FONT_SIZE;this.labelPositon=this.transToScreenCoord(i,t),this.labelPositon.y-=o/2,this.labelBounds.setFromCenterAndSize(this.labelPositon,new fe(s,o)),this.drawRoundRect(e,this.labelPositon.x-s/2,this.labelPositon.y-o/2,s,o,4),e.save(),e.fillStyle=pr.MINOR_COLOR,e.textBaseline="middle",e.textAlign="center",e.fillText(this.label,this.labelPositon.x,this.labelPositon.y),e.restore()}getClassType(){return"Coordinate"}};_n._registerDrawableClass(pE);var dC=class extends xu{constructor(e,t,i,n){super("Coordinate",e,t,i,n)}createMeasureDrawable(){if(this.drawingPoints)return new pE(ft.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))}}},kU=class extends pr{constructor(e,t){super(e,t),this.type="Distance",this.update(t)}draw(e,t){let i=this.points;if(e.save(),e.lineWidth=pr.LINE_WIDTH,e.strokeStyle=pr.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.label=`${ru(r,2)}`,this.labelPositon=this.transToScreenCoord((new P).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=pr.LINE_WIDTH,e.strokeStyle=pr.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 fe).subVectors(t,e).normalize(),n=kU.SHORT_LINE_LENGTH/2,r=Math.PI/2;return[i.clone().rotateAround(new fe,r).normalize().multiplyScalar(n).add(e),i.clone().rotateAround(new fe,-r).normalize().multiplyScalar(n).add(e)]}getClassType(){return"Distance"}},Fv=kU;Fv.SHORT_LINE_LENGTH=12,_n._registerDrawableClass(Fv);var fC=class extends xu{constructor(e,t,i,n){super("Distance",e,t,i,n)}createMeasureDrawable(){if(this.drawingPoints)return new Fv(ft.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]&&Nt.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))}}},Spe=class extends Tr{constructor(e){var t,i;super(e,{id:"MeasurementPlugin"}),this.selectedDrawable=void 0,this.drawableList=new So("measure"),this.drawableHelperList=new So("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 uv(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),this.osnapHelper=new oC(this.overlayRender),this.measurements.Distance=new fC(this.viewer,n,this.drawableList,this.osnapHelper),this.measurements.Area=new hC(this.viewer,n,this.drawableList,this.osnapHelper),this.measurements.Angle=new BA(this.viewer,n,this.drawableList,this.osnapHelper),this.measurements.Coordinate=new dC(this.viewer,n,this.drawableList,this.osnapHelper),this.inputManager.addEventListener("wheel",(()=>{this.updateSnapTolerance()})),this.viewer.addEventListener("LayoutChanged",(()=>{this.updateSnapTolerance()})),this.initEvents()}initEvents(){Object.values(this.measurements).forEach((e=>{e.addEventListener("Completed",(e=>{var t;this.viewer.dispatchEvent("MeasurementAdded",e.getData()),null==(t=this.viewer.undoRedoManager)||t.addCommand(new pb(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 _n.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,J.error("[Measure] Failed to activate measurement, type:",e));let{width:t,height:i}=this.canvas.getBoundingClientRect();dn.isMobile&&this.canvas&&!this.mobileTouchHelper&&(this.mobileTouchHelper=new uC(new fe(t/2,i/2)),this.drawableHelperList.addDrawable(this.mobileTouchHelper)),this.mobileTouchHelper&&(this.mobileTouchHelper.setPosition(new fe(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(_n.createDrawable(e)),null==(t=this.viewer.undoRedoManager)||t.addCommand(new pb(this,e))):J.info("[Measure] Invalid points found in MeasurementData:",e):J.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):J.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}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()}},$s,Mpe={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=>{J.info("[Toolbar]","Enter OrthoMode"),e.setToOrthographicCamera(!0)},onDeactive:e=>{J.info("[Toolbar]","Exit OrthoMode"),e.setToOrthographicCamera(!1)}},Measure:{icon:{default:"icon-measure",active:"icon-measure-filled",iconFont:"gemini-viewer-icon"},menuName:"Toolbar.measurement",type:3,children:{MeasureDistance:{icon:{default:"icon-measure-distance"},menuName:"Toolbar.distanceMeasurement",onActive:e=>{e.deactivateSection(),e.activateMeasurement("Distance")},onDeactive:e=>{e.deactivateMeasurement()},type:4,mutexIds:["MeasureArea","MeasureAngle","MeasureCoordinate"]},MeasureArea:{icon:{default:"icon-measure-area-color"},onActive:e=>{e.deactivateSection(),e.activateMeasurement("Area")},onDeactive:e=>{e.deactivateMeasurement()},type:4,menuName:"Toolbar.areaMeasurement",mutexIds:["MeasureDistance","MeasureAngle","MeasureCoordinate"]},MeasureAngle:{menuName:"Toolbar.angleMeasurement",icon:{default:"icon-angle-measure"},type:4,onActive:e=>{e.deactivateSection(),e.activateMeasurement("Angle")},onDeactive:e=>{e.deactivateMeasurement()},mutexIds:["MeasureDistance","MeasureArea","MeasureCoordinate"]},MeasureCoordinate:{menuName:"Toolbar.coordinateMeasurement",icon:{default:"icon-distancemeasure",iconFont:"gemini-viewer-icon"},type:4,onActive:e=>{e.deactivateSection(),e.activateMeasurement("Coordinate")},onDeactive:e=>{e.deactivateMeasurement()},mutexIds:["MeasureDistance","MeasureArea","MeasureAngle"]},MeasureClear:{icon:{default:"icon-clear",active:"icon-clear-filled",iconFont:"gemini-viewer-icon"},onClick:e=>{J.debug("[Toolbar]","Clearing Measure",e),e.clearMeasurements()},type:1,menuName:"Toolbar.clearMeasurement"}},mutexIds:["Section","SectionAxis","SectionBox","SectionPlane"]},Section:{icon:{default:"icon-section",active:"icon-section-filled",iconFont:"gemini-viewer-icon"},menuName:"Toolbar.section",type:3,children:{SectionAxis:{icon:{default:"icon-sectionplane",active:"icon-sectionplane-filled",iconFont:"gemini-viewer-icon"},menuName:"Toolbar.axisSection",type:4,onActive:e=>{e.deactivateMeasurement(),e.getMeasurements().forEach((t=>e.setMeasurementVisibility(t.id,!1))),null==$s||$s.destroy(),e.activateSection("AxisPlaneSection"),$s=new FA(e)},onDeactive:e=>{e.getMeasurements().forEach((t=>e.setMeasurementVisibility(t.id,!0))),e.deactivateSection(),null==$s||$s.destroy(),$s=void 0},mutexIds:["SectionBox","SectionPlane"]},SectionPlane:{icon:{default:"icon-choosesectionplane",active:"icon-choosesectionplane-filled",iconFont:"gemini-viewer-icon"},menuName:"Toolbar.pickSectionPlane",type:4,onActive:e=>{e.deactivateMeasurement(),e.getMeasurements().forEach((t=>e.setMeasurementVisibility(t.id,!1))),null==$s||$s.destroy(),e.activateSection("PickPlaneSection"),$s=new NA(e)},onDeactive:e=>{e.getMeasurements().forEach((t=>e.setMeasurementVisibility(t.id,!0))),e.deactivateSection(),null==$s||$s.destroy(),$s=void 0},mutexIds:["SectionAxis","SectionBox"]},SectionBox:{icon:{default:"icon-sectionbox",active:"icon-sectionbox-filled",iconFont:"gemini-viewer-icon"},menuName:"Toolbar.sectionBox",type:4,onActive:e=>{e.deactivateMeasurement(),e.getMeasurements().forEach((t=>e.setMeasurementVisibility(t.id,!1))),e.activateSection()},onDeactive:e=>{e.getMeasurements().forEach((t=>e.setMeasurementVisibility(t.id,!0))),e.deactivateSection()},mutexIds:["SectionAxis","SectionPlane"]}},mutexIds:["Measure","MeasureDistance","MeasureArea","MeasureAngle","MeasureCoordinate"]},BimTree:{icon:{default:"icon-bimtree",active:"icon-bimtree-filled",iconFont:"gemini-viewer-icon"},menuName:"Toolbar.bimTree",type:4,onActive:()=>{J.info("[Toolbar]","Activate Bim Tree")},onDeactive:()=>{J.info("[Toolbar]","Deactivate Bim Tree")}},Viewpoint:{icon:{default:"icon-viewpoint",active:"icon-viewpoint-filled",iconFont:"gemini-viewer-icon"},menuName:"Toolbar.viewpoint",type:4,onActive:()=>{J.info("[Toolbar]","Activate Viewpoint")},onDeactive:()=>{J.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:()=>{J.info("[Toolbar]","Activate Annotation")},onDeactive:()=>{J.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:()=>{J.info("[Toolbar]","Activate Property")},onDeactive:()=>{J.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:()=>{J.info("[Toolbar]","Activate Settings")},onDeactive:()=>{J.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(ft.isFullScreen())};ft.isFullScreen()?(ft.exitFullscreen(),window.removeEventListener("resize",n)):ft.fullScreen(null==(i=e.viewerContainer)?void 0:i.parentElement),window.addEventListener("resize",n)}}},Rpe={SceneClear:{icon:{default:"icon-clear",active:"icon-clear-filled"},menuName:"clear",type:1,onClick:()=>{}}},Ape={HomeView:{icon:{default:"icon-zhushitu",active:"icon-zhushitu"},menuName:"Toolbar.homeView",type:1,onClick:e=>{e.goToHomeView()}},ZoomToRectangle:{icon:{default:"icon-kuangxuanfangda",active:"icon-kuangxuanfangda"},menuName:"Toolbar.zoomToRectangle",type:4,onClick:e=>{e.removeEventListener("BoxSelectDeactivated"),e.addEventListener("BoxSelectDeactivated",(()=>{var t;null==(t=e.toolbar)||t.setActive("ZoomToRectangle",!1)})),e.zoomToRect()},mutexIds:["GetScreenshot"]},GetScreenshot:{icon:{default:"icon-frame-clipping",active:"icon-frame-clipping"},menuName:"Toolbar.screenshot",type:4,onClick:e=>{e.removeEventListener("BoxSelectDeactivated"),e.addEventListener("BoxSelectDeactivated",(()=>{var t;null==(t=e.toolbar)||t.setActive("GetScreenshot",!1)})),e.getScreenshot().then((e=>{if(J.info("[Toolbar] getScreenshot() returns:",null==e?void 0:e.base64Image),null==e||!e.base64Image)throw"[Toolbar] Image data is empty!";let t=document.createElement("a");t.href=null==e?void 0:e.base64Image,t.download="",t.click()})).catch((t=>{var i;J.error("[Toolbar] Failed to get screenshot, reason:",t),null==(i=e.toolbar)||i.setActive("GetScreenshot",!1)}))},mutexIds:["ZoomToRectangle"]},Measure:{icon:{default:"icon-celiang1",active:"icon-celiang1"},menuName:"Toolbar.measurement",type:3,children:{MeasureDistance:{icon:{default:"icon-measure-distance"},menuName:"Toolbar.distanceMeasurement",onActive:e=>{e.activateMeasurement("Distance")},onDeactive:e=>{e.deactivateMeasurement()},type:4,mutexIds:["MeasureArea","MeasureAngle","MeasureCoordinate","ZoomToRectangle","GetScreenshot"]},MeasureArea:{icon:{default:"icon-measure-area-color"},onActive:e=>{e.activateMeasurement("Area")},onDeactive:e=>{e.deactivateMeasurement()},type:4,menuName:"Toolbar.areaMeasurement",mutexIds:["MeasureDistance","MeasureAngle","MeasureCoordinate","ZoomToRectangle","GetScreenshot"]},MeasureAngle:{menuName:"Toolbar.angleMeasurement",icon:{default:"icon-angle-measure"},type:4,onActive:e=>{e.activateMeasurement("Angle")},onDeactive:e=>{e.deactivateMeasurement()},mutexIds:["MeasureDistance","MeasureArea","MeasureCoordinate","ZoomToRectangle","GetScreenshot"]},MeasureCoordinate:{menuName:"Toolbar.coordinateMeasurement",icon:{default:"icon-distancemeasure",iconFont:"gemini-viewer-icon"},type:4,onActive:e=>{e.activateMeasurement("Coordinate")},onDeactive:e=>{e.deactivateMeasurement()},visible:!1,mutexIds:["MeasureDistance","MeasureArea","MeasureAngle","ZoomToRectangle","GetScreenshot"]},MeasureClear:{icon:{default:"icon-clear",active:"icon-clear-filled",iconFont:"gemini-viewer-icon"},onClick:e=>{J.debug("[Toolbar]","Clearing Measure",e),e.clearMeasurements()},type:1,menuName:"Toolbar.clearMeasurement"}}},Markup:{icon:{default:"icon-annotation"},menuName:"Toolbar.markup",type:1,onClick:(e,t)=>{var i,n,r;null==(i=e.toolbar)||i.updateMenu("Measure",{defaultActive:!1}),null==(n=e.toolbar)||n.setActive("ZoomToRectangle",!1),e.getMarkups().forEach((t=>e.setMarkupVisibility(t.id,!0))),null==(r=e.toolbar)||r.setActive("MarkupVisibility",!1),e.activateMarkup("CloudRectWithTextMarkup"),t.hide(),new LA(e,qn({},Vfe))}},MarkupVisibility:{icon:{default:"icon-annotation-show",active:"icon-annotation-hide"},menuName:"Toolbar.markupVisibility",type:4,onActive:e=>{e.getMarkups().forEach((t=>e.setMarkupVisibility(t.id,!1)))},onDeactive:e=>{e.getMarkups().forEach((t=>e.setMarkupVisibility(t.id,!0)))},visible:!0},Settings:{icon:{default:"icon-settings",active:"icon-settings-filled",iconFont:"gemini-viewer-icon"},menuName:"Toolbar.settings",type:4,onActive:()=>{J.info("[Toolbar]","Activate Settings")},onDeactive:()=>{J.info("[Toolbar]","Deactivate Settings")},visible:!0},Compared:{icon:{default:"icon-compared"},menuName:"Toolbar.compared",type:4,onActive:()=>{J.info("[Toolbar]","Activate Compare")},onDeactive:()=>{J.info("[Toolbar]","Deactivate Compare")},visible:!1},QuitCompare:{icon:{default:"icon-compared"},menuName:"Toolbar.quitCompare",type:4,onActive:()=>{J.info("[Toolbar]","Activate Compare")},onDeactive:()=>{J.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(ft.isFullScreen())};ft.isFullScreen()?(ft.exitFullscreen(),window.removeEventListener("resize",n)):ft.fullScreen(null==(i=e.viewerContainer)?void 0:i.parentElement),window.addEventListener("resize",n)}}},Cpe={enableToolbar:!0,enableContextMenu:!0,enableSpinner:!0,containerId:"myCanvas",units:"meters"},VGt={enableToolbar:!1,enableContextMenu:!1,containerId:"myCanvas"},Npe=Xi(ac(),1),mE=Xi(ac(),1),dut="gemini-context-menu",pC=class{constructor(e){this.itemList=[],this.id=e.id||dut,this.container=e.container||document.body,this.context=e.context||{},this.element=this.createMenuUI(e.items||[]),this.handleClick=()=>{this.hide()},!1!==e.hideOnMouseDown&&document.addEventListener("click",this.handleClick),this.hide()}isEnable(e){return e.getEnabled?e.getEnabled(this.context):void 0===e.enabled||e.enabled}isShown(e){return e.getShown?e.getShown(this.context):void 0===e.shown||e.shown}getTitle(e){return e.title||e.getTitle&&e.getTitle(this.context)||""}createMenuUI(e){let t=document.createElement("div");t.id=this.id,t.classList.add("context-menu");let i=this.createMenuGroup(e);return t.append(...i),this.container.appendChild(t),t}createMenuGroup(e){return(0,mE.map)(e,(e=>{let t=document.createElement("ul");return(0,mE.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.isEnable(e)?t.classList.remove("disabled"):t.classList.add("disabled"),this.isShown(e)?t.removeAttribute("hidden"):t.setAttribute("hidden",""),this.itemList.push([e,t]),t}updateMenuItems(){(0,mE.forEach)(this.itemList,(([e,t])=>{this.isEnable(e)?t.classList.remove("disabled"):t.classList.add("disabled"),this.isShown(e)?t.removeAttribute("hidden"):t.setAttribute("hidden",""),t.innerHTML=this.getTitle(e)}))}showMenuElement(e,t){let 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)}},Ja=e=>({bimViewer:t})=>t.translate(`ContextMenu.${e}`),Ipe=e=>{var t;let i=0;return null==(t=e.scene)||t.traverseVisible((e=>{e instanceof ht&&i++})),i>0},fut=e=>{var t,i;let n=0;return null==(t=e.scene)||t.traverse((e=>{e instanceof ht&&n++})),null==(i=e.scene)||i.traverseVisible((e=>{e instanceof ht&&n--})),n>0},FU=e=>e.hasTransparentObject(),mC=e=>Sn.isObjectSelectable(e),Ppe=(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||!Pr.isMergedMesh(r)||n===r.userData.batchId)},put={getTitle:Ja("viewFitEntity"),getShown:({hit:e})=>e,doAction:({bimViewer:e,hit:t})=>{e.flyToObject(t)}},mut={getTitle:Ja("viewFitAll"),getEnabled:({bimViewer:e})=>Ipe(e),doAction:({bimViewer:e})=>e.viewFitAll()},gut={getTitle:Ja("hideEntity"),getShown:({hit:e})=>e,doAction:({bimViewer:e,hit:t})=>{mC(t)&&(e.clearSelection(),t.visible=!1,e.enableRender())}},vut={getTitle:Ja("hideOthers"),getShown:({hit:e})=>e,doAction:({bimViewer:e,hit:t})=>{var i;e.clearSelection(),null==(i=e.scene)||i.traverse((e=>{e instanceof ht&&mC(e)&&(e.visible=!1)})),t.visible=!0,e.enableRender()}},yut={getTitle:Ja("hideAll"),getEnabled:({bimViewer:e})=>Ipe(e),doAction:({bimViewer:e})=>{var t;e.clearSelection(),null==(t=e.scene)||t.traverse((e=>{e instanceof ht&&mC(e)&&(e.visible=!1)})),e.enableRender()}},xut={getTitle:Ja("showAll"),getEnabled:({bimViewer:e})=>fut(e),doAction:({bimViewer:e})=>{var t;null==(t=e.scene)||t.traverse((e=>{e instanceof ht&&mC(e)&&(e.visible=!0)})),e.enableRender()}},but={getTitle:({hit:e,bimViewer:t,instanceId:i,batchId:n})=>Ppe(t,e,i,n)?Ja("deselect")({bimViewer:t}):Ja("select")({bimViewer:t}),getShown:({hit:e})=>e,doAction:({hit:e,bimViewer:t,instanceId:i,batchId:n})=>{Sn.isObjectSelectable(e)?Ppe(t,e,i,n)?t.clearSelection():t.selectObject(e,e.instanceId,n):J.debug(`[ContextMenu] object(type: ${e.type}, name: ${e.name}) not selectable!`)}},Eut={getTitle:Ja("selectNone"),getEnabled:({bimViewer:e})=>e.selectedObject,doAction:({bimViewer:e})=>e.clearSelection()},_ut={getTitle:Ja("xRayAll"),getShown:({bimViewer:e})=>!FU(e),doAction:({bimViewer:e})=>{e.clearSelection(),e.addOrRemoveObjectOpacity(!0),e.enableRender()}},Tut={getTitle:Ja("xRayNone"),getEnabled:({bimViewer:e})=>FU(e),doAction:({bimViewer:e})=>{e.clearSelection(),FU(e)&&(e.addOrRemoveObjectOpacity(!1),e.enableRender())}},wut={getTitle:Ja("xRayEntity"),getShown:({hit:e})=>e,doAction:({bimViewer:e,hit:t})=>{e.clearSelection(),e.addOrRemoveObjectOpacity(!0,void 0,[t.id],void 0)}},Sut={getTitle:Ja("xRayOthers"),getShown:({hit:e})=>e,doAction:({bimViewer:e,hit:t})=>{e.clearSelection(),e.addOrRemoveObjectOpacity(!0,.1,void 0,[t.id]),e.enableRender()}},Mut={getTitle:({bimViewer:e})=>{let t="";switch(e.sectionType){case"PickPlaneSection":t="*showSectionPlane";break;case"AxisPlaneSection":t="showAxisSection";break;case"ObjectsBoxSection":t="*showSectionBox"}return e.translate(`ContextMenu.${t}`)},getShown:({bimViewer:e,section:t})=>("PickPlaneSection"===e.sectionType||"AxisPlaneSection"===e.sectionType)&&!!t&&!t.isShowSectionPlane,doAction:({bimViewer:e,section:t})=>{("PickPlaneSection"===e.sectionType||"AxisPlaneSection"===e.sectionType)&&(null==t||t.setSectionVisible(!0))}},Rut={getTitle:({bimViewer:e})=>{let t="";switch(e.sectionType){case"PickPlaneSection":t="hideSectionPlane";break;case"AxisPlaneSection":t="hideAxisSection";break;case"ObjectsBoxSection":t="hideSectionBox"}return e.translate(`ContextMenu.${t}`)},getShown:e=>Dpe(e),doAction:({bimViewer:e,section:t})=>{("PickPlaneSection"===e.sectionType||"AxisPlaneSection"===e.sectionType)&&(null==t||t.setSectionVisible(!1))}},Aut={getTitle:Ja("undoSection"),getShown:e=>Dpe(e),doAction:({bimViewer:e,toolbar:t})=>{if("PickPlaneSection"===e.sectionType){let e=null==t?void 0:t.menuList.get("SectionPlane");null==e||e.setActive(!1)}else if("AxisPlaneSection"===e.sectionType){let e=null==t?void 0:t.menuList.get("SectionAxis");null==e||e.setActive(!1)}else if("ObjectsBoxSection"===e.sectionType){let e=null==t?void 0:t.menuList.get("SectionBox");null==e||e.setActive(!1)}}},Dpe=({bimViewer:e,hit:t,section:i})=>("PickPlaneSection"===e.sectionType||"AxisPlaneSection"===e.sectionType)&&!!i&&i.isShowSectionPlane&&(null==t?void 0:t.name)===x5,Lpe=[[Mut],[Rut,Aut],[put,mut],[gut,vut,yut,xut],[wut,Sut,_ut,Tut],[but,Eut]],gC=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 NU(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")}},NU=class{constructor(e,t){this.viewer=e,this.eventBus=Av(),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")}},Nv=new qe,Ope=new qe,kpe=new qs,BU=new P,Bv=new bt,Fpe=new Ye,ff=class extends df{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 Is,this.selected=!0,this.raf=new af,this.clock=new Ua,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 RR,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(),J.info(`[DxfViewer] Initialized in ${(Date.now()-this.timer)/1e3}s`)}init(){let e=this.viewerCfg;this.initThree(),dn.isBrowser&&!e.context&&this.initDom(),this.initInputManager(),this.initEvents(),this.initControls(),this.initOthers(),this.enableSelection=e.enableSelection}initInputManager(){this.viewerContainer&&(this.inputManager=new Mo(this.viewerContainer))}initThree(){this.initScene(),this.initRenderer(),this.initCamera()}initDom(){let e=this.viewerCfg;this.initSpinner(),this.initCSS2DRenderer(),!0===e.enableAxisGizmo&&console.warn("[DxfViewer] enableAxisGizmo is deprecated, use AxisGizmoPlugin instead!"),!0===e.enableStats&&console.warn("[DxfViewer] enableStats is deprecated, use StatsPlugin instead!"),e.enableToolbar&&(this.toolbar=this.initToolbar()),e.enableBottomBar&&console.warn("[DxfViewer] enableBottomBar is deprecated, use BottomBarPlugin instead!"),e.enableProgressBar&&(this.loadingProgressBar=this.initLoadingProgressBar()),e.enableLayoutBar&&(this.dxfLayoutBar=new gC(this))}initScene(){let e=new ti;e.background=new Ye(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};!dn.isBrowser&&t&&Object.assign(i,{context:t,canvas:dn.creatReactNativeCanvas(t)}),t&&(this.width=t.drawingBufferWidth,this.height=t.drawingBufferHeight),this.renderer=new ns(i),this.renderer.setClearColor(11119017,1),this.renderer.localClippingEnabled=!0,dn.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),ft.printGpuInfo(this.renderer.getContext()),Zt.maxFragmentUniforms=this.renderer.capabilities.maxFragmentUniforms-20,this.enableOverlayRenderer&&(this.overlayRender=new _n(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 Er(-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 Ws(e,this.inputManager);t.enableRotate=!1,t.enabled=!0,t.keyTruckSpeed=10,t.dollyToCursor=!0,t.dollySpeed=.5,t.truckSpeed=1,t.mouseButtons={left:at.TRUCK,middle:at.TRUCK,wheel:at.ZOOM,right:at.TRUCK},t.touches={one:at.TOUCH_TRUCK,two:at.TOUCH_ZOOM_TRUCK,three:at.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 ri&&(r.markupData=this.selectedObject.getData()),this.selectedObject&&this.selectedObject instanceof pr&&(r.measureData=this.selectedObject.getData()),this.selectedObject&&this.selectedObject instanceof Xt){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 ri&&(this.markupManager.removeMarkup(this.selectedObject),null==(n=this.undoRedoManager)||n.addCommand(new Qp(this.markupManager,this.selectedObject.getData()))),this.measurePlugin&&this.selectedObject instanceof pr&&(null==(r=this.measurePlugin)||r.remove(this.selectedObject),null==(a=this.undoRedoManager)||a.addCommand(new uv(this.measurePlugin,this.selectedObject.getData()))))}))}initOthers(){!this.scene||!this.renderer||!this.camera||(this.renderer.domElement.style.outlineWidth="0")}initToolbar(){let e=this.viewerCfg;return new yu(this,(0,Npe.merge)({},Ape,e.toolbarMenuConfig))}initLoadingProgressBar(){return new tf(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.font&&this.font.releaseFontData&&this.font.releaseFontData()}));if(J.info(`[DxfViewer] Loaded '${e.src}' in ${(Date.now()-this.timer)/1e3}s, adding to scene...`),Zt.abortJobs&&Promise.reject("[DxfViewer] abort load dxf"),0===d.threejsObject.children.length){let t=`[DxfViewer] Nothing was loaded from ${e.src}`;return J.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),J.info(`[DxfViewer] Units of '${e.src}' is '${f}'`),e.matrix&&16===e.matrix.length){let t=new qe;t.elements=e.matrix,p.applyMatrix4(t)}return this.addModel({modelId:r,dxfData:d}),ft.printMemory("After addLoadedModelToScene"),J.info(`[DxfViewer] 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)return;let{dxfData:t,pdfData:i}=e,n=e.modelId,r=e=>!!this.loadedModels.find((t=>t.modelId===e));if(r(n)){let e=1;for(;r(`${n}_${e}`);)e++;n=`${n}_${e}`,J.warn(`[DxfViewer] Model '${n}' is loaded more than once!`)}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),Zt.computeLineDistances(e),this.getMsTransformMatrix(n),this.masterModelId===n?this.activateLayout(Zt.MODEL_LAYOUT_NAME):this.handleOverlayDxf(n),J.debug("[DxfViewer] dxfData:",t),this.scene.add(e);let r=null==t?void 0:t.threejsObject.children.find((e=>e.name===Zt.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=Zt.MODEL_LAYOUT_NAME;let n=(new bt).setFromObject(t);this.layoutInfos[this.activeLayoutName]={homeViewExtent:n,extent:n},this.loadedModels.push(e),this.scene.add(t),this.updateGroundPlane(),this.flyToObject(t)}}isCompareMode(){return this.compareMode}compare(e,t,i,n){return nt(this,null,(function*(){var r,a,s,o,l;let{src:h,modelId:c}=e,{src:u}=t;if(this.compareMode)return Promise.reject("[DxfViewer] It is already under comparing mode!");if(this.masterModelId||this.loadedModels.length>0)return Promise.reject("[DxfViewer] Shouldn't load anything else before compare!");if(this.compareMode=!0,this.timer=Date.now(),this.increaseJobCount(),!this.font)return Promise.reject("[DxfViewer] Should set font first!");let d={ignorePaperSpace:!0,encoding:e.encoding},p=new Zt(this.loadingManager,d);p.setFont(this.font),this.font instanceof ki&&this.font.getFontData&&(yield this.font.getFontData());let f=h+u,m=this.translate("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}))};ft.printMemory("Before comparing"),this.masterModelId=c||h,this.loadingDxfCount+=2,null==(r=this.loadingProgressBar)||r.addProgressItem(f),g(0);let y=Date.now(),x=yield p.parse(h,(e=>v(e,0,15))),b=yield p.parse(u,(e=>v(e,15,30))),[_,w]=yield Promise.allSettled([x,b]);if("rejected"===_.status)return Promise.reject(`[DxfViewer] Failed to parse ${h}`);if("rejected"===w.status)return Promise.reject(`[DxfViewer] Failed to parse ${u}`);if(J.info(`[DxfViewer] loadFiles in ${(Date.now()-y)/1e3}s`),Zt.abortJobs)return Promise.reject("[DxfViewer] compare loadFile aborted");let M=_.value,S=w.value;y=Date.now();let E=yield new Gi(M,S,i).compare((e=>v(e,30,60)));if(J.info(`[DxfViewer] Compared in ${(Date.now()-y)/1e3}s`),J.debug("[DxfViewer] Compared results:",E),Zt.abortJobs)return Promise.reject("[DxfViewer] compare change aborted");ft.printMemory("After getting the comparison results"),y=Date.now(),yield p.loadEntitiesForCompare(M,S,E,!0,(e=>v(e,60,95))),ft.printMemory("After Creating threejs objects based on comparison result"),null==(a=this.font)||a.releaseFontData(),this.changes=E,J.info(`[DxfViewer] Creates threejs objects based on comparison result in ${(Date.now()-y)/1e3}s`);let T=M,A=S;if(this.loadingDxfCount-=2,this.decreaseJobCount(),Object.keys(E).length||J.info("[DxfViewer] 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=`[DxfViewer] Nothing was loaded from ${h} and ${u}`;return J.warn(e),Promise.reject(e)}let C=T.threejsObject,P=A.threejsObject;return C.name=h,P.name=u,y=Date.now(),this.addModel({modelId:e.modelId||e.src,dxfData:T}),ft.printMemory("After adding first loaded Model to scene"),g(95),this.addModel({modelId:t.modelId||t.src,dxfData:A}),ft.printMemory("After adding second loaded Model to scene"),J.info(`[DxfViewer] Added compared objects to scene in ${(Date.now()-y)/1e3}s`),J.info(`[DxfViewer] The comparison between ${h}' and '${u}' is completed in ${(Date.now()-this.timer)/1e3}s !`),g(100),null==(l=this.loadingProgressBar)||l.delayRemoveProgressItem(f),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 J.warn(`[DxfViewer] Can't find model for modelId '${e}'!`);this.increaseJobCount(),this.switchTransformMs(Zt.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===Zt.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 J.warn("[DxfViewer] layout name is empty !"),void this.decreaseJobCount();if(e===this.activeLayoutName)return void this.decreaseJobCount();let a=Date.now(),s=this.camera,o=this.getLayoutByName(e);if(!o)return J.warn(`[DxfViewer] Can't find layout of ${e} !`),void this.decreaseJobCount();let l=this.loadedModels.find((e=>this.masterModelId===e.modelId));if(!l)return J.warn(`[DxfViewer] Can't find master model for modelId '${this.masterModelId}'!`),void this.decreaseJobCount();if(this.raycastableObjects=void 0,this.activeLayoutName){let e=this.getActiveLayoutInfo();e.lastCameraPosition||(e.lastCameraPosition=new P),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!==Zt.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&&J.warn(`[DxfViewer] Failed to find object for modelId '${this.masterModelId}', layer '${n}', layout '${e}'`)}})),t.forEach((e=>{e.removeFromParent()}))}let c=this.getFilteredViewports(o);J.debug("[DxfViewer] 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 P);if(p>m.z+d){let e=Math.ceil(p+d);J.info(`[DxfViewer] Changing camera's z value from ${m.z} to ${e}`);let t=f.getTarget(new P);m.setZ(e),f.setLookAt(m.x,m.y,m.z,t.x,t.y,t.z)}J.info(`[DxfViewer] generateObjectsByViewport in ${(Date.now()-u)/1e3}s`),e!==Zt.MODEL_LAYOUT_NAME&&this.switchTransformMs(Zt.MODEL_LAYOUT_NAME,this.masterModelId),e!==Zt.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)&&(J.warn(`[BimViewer] Got wired bbox, max: ${e.max.toArray()}, min: ${e.min.toArray()}, going to use the calculated one...`),e=h.extent)}else J.warn("[BimViewer] Failed to get layout extent, going to use the calculated one..."),e=h.extent;h.homeViewExtent=e,this.zoomToBBox(e)}this.updateGroundPlane(),this.dispatchEvent("LayoutChanged"),ft.printMemory(`After activated layout '${this.activeLayoutName}'`),this.enableRender(),this.decreaseJobCount(),J.info(`[DxfViewer] 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.isActived()&&(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:J.warn(`[DxfViewer] 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=Di.cloneMaterial(i.material));let e=Di.cloneMaterial(i.material);Di.setMaterialColor(e,new Ye(t)),Zt.updateMaterialUniforms(e),i.material=e}})):J.warn(`[DxfViewer] 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)})):J.warn(`[DxfViewer] No object found for layer '${e}'`),this.enableRender()}setFont(e){return nt(this,null,(function*(){let t=Date.now();Po.isShxFile(e[0])?this.font=yield(new Po).loadAsync(e):(e.length>1&&J.warn("[DxfViewer] Only support 1 typeface font file for now, others will be ignored!"),this.font=yield(new uu).loadAsync(e[0])),J.info(`[DxfViewer] Font file(s) load time in ${(Date.now()-t)/1e3}s`)}))}getFont(){return this.font}setLoadingManager(e){this.loadingManager=e}setDisplayLengthUnits(){throw new Error("Not implemented yet!")}setDisplayAreaUnits(){throw new Error("Not implemented yet!")}setDisplayPrecision(){throw new Error("Not implemented yet!")}getCurrentViewExtent(){return{min:this.getHitResultByNdcCoordinate({x:-1,y:-1}),max:this.getHitResultByNdcCoordinate({x:1,y:1})}}getScreenshot(){return nt(this,arguments,(function*(e="BoxSelection"){this.cancelAllOperations();let t=this.findPlugin("ScreenshotPlugin");if(t)return t.getScreenshotAsync(e);J.warn("[DxfViwer] ScreenshotPlugin doesn't seem to be installed!")}))}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")):J.warn("[DxfViewer] 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 mb(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 mb(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=$t.getScreenPointByEvent(e,t),n=$t.screenPoint2NdcPoint(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 kv(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 qe,h=Zt.getDcs2WcsMatrix(o[0],a),c=new P(o[0].center.x,o[0].center.y,0).applyMatrix4(h),u=1;this.units&&s!==this.units&&(u=Qde(s,this.units)),c.multiplyScalar(u),l.makeTranslation(c.x,c.y,0);let d=o[0].viewTwistAngle;null!=d&&l.multiply((new qe).makeRotationZ(gn.degToRad(d))),l.multiply((new qe).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 J.warn(`[DxfViewer] Can't find model whose modelId is ${t}`);let r=n.msTransformMatrix;if(Nv.identity(),!r||!ft.isMatrixValid(r)||r.equals(Nv))return;let a=null==(i=n.dxfData)?void 0:i.threejsObject,s=null==a?void 0:a.children.find((e=>e.name===Zt.MODEL_LAYOUT_NAME));s&&(e===Zt.MODEL_LAYOUT_NAME?s.applyMatrix4(r):s.applyMatrix4(r.clone().invert()),s.updateMatrixWorld(!0))}getLayoutExtentEx(e){return e.layoutName===Zt.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 P,a=new P;if(!n)return void J.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 P,a=new P;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=Zt.getDcs2WcsMatrix(e,h),c=new P(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 bt(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++})),J.debug(`[DxfViewer] 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 Yt&&(e.uniforms.u_cameraZoom&&(e.uniforms.u_cameraZoom=Zt.cameraZoomUniform),e.uniforms.u_viewportScale&&1===(null==t?void 0:t.header.$PSLTSCALE)&&(e.uniforms.u_viewportScale=Zt.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!");Zt.transformMatrixUniform={value:r.msToPsMatrix},Zt.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 Pi(new fe(l.x,l.y),new fe(h.x,h.y)),u=su.generateSectionPlanesByBox(c),d=[],p=e=>(d[e.id]||(d[e.id]=e.clone(),this.setMaterialUniforms(d[e.id],i),su.setMaterialSection(d[e.id],u)),d[e.id]),f=[...n,...t.frozenLayerHandles||[]];if(e!==Zt.MODEL_LAYOUT_NAME){let e=t;e.associatedLeafObjectSet||(e.associatedLeafObjectSet=new Set),o=e.associatedLeafObjectSet}let m=new Ln;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):J.warn(`[DxfViewer] 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 Ln,Sn.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===Zt.SNAP_GROUP_NAME));b||(b=new Ln,b.visible=Zt.SHOW_SNAP_OBJECT,b.name=Zt.SNAP_GROUP_NAME,x.add(b));let _=null==y?void 0:y.children.find((e=>e.name===Zt.MODEL_LAYOUT_NAME)),w=null==_?void 0:_.children.find((e=>e.name===Zt.SNAP_GROUP_NAME));w&&w.traverse((e=>{if(!e.geometry)return;let t=e.userData.layerName;if(this.isLayerFrozenForViewport(i,t,f)||(Bv.makeEmpty(),Bv.expandByObject(e),!a.intersectsBox(Bv)))return;let n=e.clone();Sn.setSharedVariablesOfObject(n);let s=n.parent,l=Nv.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&&Sn.removeEmptyObjectsFromRemovingObjects(v,m),m.traverse((e=>{Sn.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 J.warn("[DxfViewer] 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>Zt.maxFragmentUniforms},n=new Set,a=e=>{n.has(e.id)||(n.add(e.id),i(e)||su.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 J.warn("[DxfViewer] 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===Zt.MODEL_LAYOUT_NAME));return r&&r.children.forEach((t=>{t.name!==Zt.SNAP_GROUP_NAME&&(t=>{let n=fs.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 J.warn("DxfData or its header is undefined!"),"Unitless";let i=t.$INSUNITS;return Zt.getDxfUnits(i)}generateSectionsBySpatialFilter(e,t){let i=e.clipPolylines[0];if(i.bConcave)return void J.warn("[DxfViewer] clipPolyline.bConcave = true is not supported yet in spatialFilter !");Nv.copy(t),e.localMatrix&&Nv.multiply(e.localMatrix);let n=i.polyline,r=[];n.forEach((e=>{let t=e.clone().applyMatrix4(Nv);r.push(new fe(t.x,t.y))}));let a=Es.isClockWise(r),s=!a&&!i.bReversed||a&&i.bReversed;return su.generateSectionPlanesByPoints(r,s)}addLoadedModelToScene(e,t,i){return nt(this,null,(function*(){if(!this.scene)return;let n=t.modelId||t.src,r=e=>!!this.loadedModels.find((t=>t.modelId===e));if(r(n)){let e=1;for(;r(`${n}_${e}`);)e++;n=`${n}_${e}`,J.warn(`[DxfViewer] Model '${n}' is loaded more than once!`)}let a={modelId:n,dxfData:i};this.loadedModels.push(a),e.matrixAutoUpdate=!1,e.updateMatrix(),e.updateMatrixWorld(!0),Zt.computeLineDistances(e),this.getMsTransformMatrix(n),this.masterModelId===n?this.activateLayout(Zt.MODEL_LAYOUT_NAME):this.handleOverlayDxf(n),J.debug("[DxfViewer] dxfData:",i),this.scene.add(e);let s=null==i?void 0:i.threejsObject.children.find((e=>e.name===Zt.MODEL_LAYOUT_NAME));s&&this.setLayoutHidableObjectArray(s),this.updateGroundPlane(),this.raycastableObjects=void 0,this.masterModelId===n||this.enableRender()}))}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)&&Sn.isLeafObject(e)&&i.push(e)}))}return this.groundPlane&&i.push(this.groundPlane),this.raycastableObjects=i,J.debug(`[DxfViewer] getRaycastableObjects() finds ${i.length} objects`),J.debug(`[DxfViewer] getRaycastableObjects() costs ${(Date.now()-t)/1e3} s`),i}getViewportByPoint(e){if(0===this.activeLayoutName.length||this.activeLayoutName===Zt.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)})))}Ope.multiplyMatrices(this.camera.projectionMatrix,this.camera.matrixWorldInverse),kpe.setFromProjectionMatrix(Ope);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===Zt.SNAP_GROUP_NAME));null==e||e.traverse((e=>{if(Sn.isLeafObject(e)){if(Bv.makeEmpty(),Bv.expandByObject(e),!kpe.intersectsBox(Bv))return;o.push(e)}}))}}this.groundPlane&&o.push(this.groundPlane),J.debug("[DxfViewer] getRaycastableObjectsByMouse() from modelSpace"),this.lastFrame=(null==(a=this.renderer)?void 0:a.info.render.frame)||0,this.raycastableObjects=o}else{let e=new WeakSet,t=this.getLayoutByName(this.activeLayoutName);if(t){let 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))})),J.debug("[DxfViewer] getRaycastableObjectsByMouse() from inside of viewport:",i.viewportId)):J.debug("[DxfViewer] getRaycastableObjectsByMouse() from out of viewport"),this.groundPlane&&o.push(this.groundPlane)}return J.debug(`[DxfViewer] getRaycastableObjectsByMouse() costs ${(Date.now()-h)/1e3} s`),o}getIntersections(e){let t=this.getRaycastableObjectsByMouse(e);return this.raycaster&&this.raycaster.intersectObjects(t,!0)||[]}handleMouseClick(e){if(this.measurePlugin&&this.measurePlugin.isActive()||this.markupManager&&this.markupManager.isMarkupActive()||(this.selectDrawableByEvent(e),this.selectedObject)||!this.enableSelection)return;this.raycaster&&this.raycaster.layers.set(12);let t=this.getIntersections(e);if(t.length>0){let e=e=>ft.vectorToString(e);J.debug(`[DxfViewer] Clicked at: ${e(t[0].point)}`)}let i=t.find((e=>e.object.visible)),n=i&&i.object||void 0;this.selectedObject&&this.clearSelection(),n&&this.selectedObject&&this.selectedObject.id===n.id&&(n=void 0),n?this.selectObject(n):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 ht||e instanceof Wn||e instanceof Yr){let i=Di.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 ht||e instanceof Wn||e instanceof Yr)&&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 Qn&&t.dispose()}},r=!1;this.selectedObject&&(n(this.selectedObject),this.selectedObject=void 0,r=!0),e&&(i(e),this.selectedObject=e,e.userData.dxfEntity?J.info("[DxfViewer] Selected entity:",e.userData.dxfEntity):J.info("[DxfViewer] Selected object:",e),r=!0),r&&this.enableRender()}clearSelection(){var e;this.selectedObject&&this.selectedObject instanceof mi?(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 bt;e.forEach((e=>{let i=fs.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 _i&&e.userData.clonedMesh||e instanceof ht&&Pr.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 ht||e instanceof Wn)&&!["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&&(J.info(`[DxfViewer] 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 J.error("[DxfViewer] Camera position and lookAt cannot be the same!");if(!ft.isVectorValid(e)||!ft.isVectorValid(t))return void J.error("[DxfViewer] Invalid position or lookAt!",e,t);let s=e.distanceTo(t);sr.far&&(e=e.clone().sub(t).normalize().multiplyScalar(.9*r.far),J.warn("[DxfViewer] 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 P),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 P(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 P(e.x,e.y,n.position.z),s=r.getTarget(new P),o=new P(e.x,e.y,s.z);this.flyTo(a,o,t,i)}goToHomeView(){let e=this.getActiveLayoutInfo();e.homeViewExtent?this.zoomToBBox(e.homeViewExtent):J.error(`[DxfViewer] 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 bt(new P(e.min.x,e.min.y,0),new P(e.max.x,e.max.y,0)),l=new P;o.getCenter(l),l.z=0;let h=l.clone().setZ(Math.max(t.position.z,this.CAMERA_Z_POSITION));h.equals(l)||this.flyTo(h,l,s,!1)}zoomToExtent(){let e=this.getActiveLayoutInfo();e.extent?this.zoomToBBox(e.extent):(console.error("[DxfViewer] Failed to find extent of current layout! Will go to home view."),this.goToHomeView())}zoomToCompareChange(e){if(this.changes){let t=this.changes[e];if(!t)return;let i=t.box;i&&this.zoomToBBox(i.clone().expandByScalar(1.2))}}getCompareChanges(){return this.changes}setBackgroundColor(e,t,i){!this.scene||!this.renderer||(Fpe.setRGB(e,t,i,this.renderer.outputColorSpace),(!this.scene.background||!(this.scene.background instanceof Ye))&&(this.scene.background=new Ye(e,t,i)),this.scene.background.copy(Fpe),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();ft.expandBoxByScale(t,3);let i=t.min,n=t.max,r=n.x-i.x+n.y-i.y+n.z-i.z;ft.expandBoxByMinSize(t,r);let a=[],s=(e,t,i)=>{a.push(new P(e,t,i))},o=t.getSize(new P),l=t.getCenter(new P);if(s(-o.x/2,-o.y/2,0),s(o.x/2,-o.y/2,0),s(o.x/2,o.y/2,0),s(-o.x/2,o.y/2,0),this.groundPlane)this.groundPlane.position.copy(l),this.groundPlane.geometry.setFromPoints(a),this.groundPlane.geometry.computeBoundingSphere(),this.groundPlane.geometry.computeBoundingBox();else{let e=new Et;e.setFromPoints(a),e.setIndex([0,3,2,0,2,1]);let t=new jt({color:"#888",transparent:!0,opacity:0,side:or});this.groundPlane=new ht(e,t),this.groundPlane.visible=!0,this.groundPlane.frustumCulled=!1,this.groundPlane.position.copy(l),this.groundPlane.scale.set(1e5,1e5,1),this.groundPlane.name="groundPlane",this.groundPlane.renderOrder=-1e3,this.groundPlane.layers.enableAll(),Sn.disableLayerChannels(this.groundPlane,[12]),this.scene.add(this.groundPlane)}this.groundPlane.updateMatrixWorld()}computeBoundingBox(){var e;let t=new bt;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 Yt?e.material.uniforms.u_color.value:e.material.color,t.equals(new Ye(Gi.ENTITY_COLOR_ADDED))||t.equals(new Ye(Gi.ENTITY_COLOR_REMOVED))},o=1;e.traverse((e=>{if(this.isCompareMode()&&s(e)||e.userData.isSnapObject||!Sn.isLeafObject(e))return;let t=e.geometry;t.boundingBox||t.computeBoundingBox();let i=t.boundingBox.clone();if(!i||!ft.isBoxValid(i))return;i.applyMatrix4(e.matrixWorld),i.getSize(BU);let n=Math.max(BU.x,BU.y),a=o/n;a<1/0?r.push({visibleMinZoom:a,object:e}):e instanceof Yr?r.push({visibleMinZoom:o,object:e}):J.warn("[DxfViewer] The size of bbox is 0 ! ",e)})),o=this.getVisiblePixelSize(r.length);let l=0;r.forEach((e=>{let t=e.visibleMinZoom*o;e.visibleMinZoom=t,e.object.userData.visibleMinZoom=t,t>a&&(e.object.visible=!1,l++)})),r.sort(((e,t)=>e.visibleMinZoom-t.visibleMinZoom)),J.debug(`[DxfViewer] 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++})),J.info(`[DxfViewer] hidableObjects count:${i}, real count:${r}, layout count: ${a}, level:`,n),J.info("[DxfViewer] 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,J.debug(`[DxfViewer] 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){Zt.cameraZoomUniform.value=e}},vC=class{constructor(e){this.jobCount=0,this.viewer=new ff(e);let t=document.getElementById(e.containerId);this.container=(null==t?void 0:t.parentElement)||document.body,this.loadingProgressBar=new tf(this.container),this.loader=new Zt(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 nt(this,null,(function*(){let t=Date.now();Po.isShxFile(e[0])?this.font=yield(new Po).loadAsync(e):(e.length>1&&J.warn("[DxfCompareHelper] Only support 1 typeface font file for now, others will be ignored!"),this.font=yield(new uu).loadAsync(e[0])),J.info(`[DxfCompareHelper] Font file(s) load time in ${(Date.now()-t)/1e3}s`)}))}compare(e,t,i,n){return nt(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.font)return Promise.reject("[DxfCompareHelper] Should set font first!");this.loader.setFont(this.font),this.font instanceof ki&&this.font.getFontData&&(yield this.font.getFontData());let p=h+u,f=um.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}))};ft.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(J.info(`[DxfCompareHelper] loadFiles in ${(Date.now()-v)/1e3}s`),Zt.abortJobs)return Promise.reject("[DxfCompareHelper] compare loadFile aborted");let w=b.value,M=_.value;v=Date.now();let S=yield new Gi(w,M,i).compare((e=>g(e,30,60)));if(J.info(`[DxfCompareHelper] Compared in ${(Date.now()-v)/1e3}s`),J.debug("[DxfCompareHelper] Compared results:",S),Zt.abortJobs)return Promise.reject("[DxfCompareHelper] compare change aborted");ft.printMemory("After getting the comparison results"),v=Date.now(),yield this.loader.loadEntitiesForCompare(w,M,S,!0,(e=>g(e,60,95))),ft.printMemory("After Creating threejs objects based on comparison result"),null==(a=this.font)||a.releaseFontData(),this.changes=S,J.info(`[DxfCompareHelper] Creates threejs objects based on comparison result in ${(Date.now()-v)/1e3}s`);let E=w,T=M;if(this.decreaseJobCount(),Object.keys(S).length||J.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 J.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}),ft.printMemory("After adding first loaded Model to scene"),m(95),this.viewer.addModel({modelId:t.modelId||t.src,dxfData:T}),ft.printMemory("After adding second loaded Model to scene"),J.info(`[DxfCompareHelper] Added compared objects to scene in ${(Date.now()-v)/1e3}s`),J.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)}},Bpe=class extends vC{constructor(e,t){super(e),this.syncCamera=!1,this.syncCameraControls=(e,t,i)=>{let n=new P,r=new P,a=new P;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 ff(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 nt(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.font)return Promise.reject("[DxfCompareHelper] Should set font first!");this.loader.setFont(this.font),this.font instanceof ki&&this.font.getFontData&&(yield this.font.getFontData());let f=h+u,m=um.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}))};ft.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(J.info(`[DxfCompareHelper] loadFiles in ${(Date.now()-y)/1e3}s`),Zt.abortJobs)return Promise.reject("[DxfCompareHelper] compare loadFile aborted");let M=_.value,S=w.value;y=Date.now();let E=yield new Gi(M,S,i).compare((e=>v(e,30,60)));if(J.info(`[DxfCompareHelper] Compared in ${(Date.now()-y)/1e3}s`),J.debug("Compared results:",E),Zt.abortJobs)return Promise.reject("[DxfCompareHelper] compare change aborted");ft.printMemory("After getting the comparison results"),y=Date.now(),yield this.loader.loadEntitiesForCompare(M,S,E,!1,(e=>v(e,60,95))),ft.printMemory("After Creating threejs objects based on comparison result"),null==(a=this.font)||a.releaseFontData(),this.changes=E,J.info(`[DxfCompareHelper] Creates threejs objects based on comparison result in ${(Date.now()-y)/1e3}s`);let T=M,A=S;if(this.decreaseJobCount(),Object.keys(E).length||J.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 J.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}),ft.printMemory("After adding first loaded Model to scene"),g(95),this.viewer2.addModel({modelId:t.modelId||t.src,dxfData:A}),ft.printMemory("After adding second loaded Model to scene"),J.info(`[DxfCompareHelper] Added compared objects to scene in ${(Date.now()-y)/1e3}s`),J.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)))}}},fm=Xi(Hpe(),1),Th=class{constructor(e,t){this.current=e,this.next=t,this.inNormal=this.inwardsNormal(),this.outNormal=this.outwardsNormal()}outwardsNormal(){let e=this.inwardsNormal();return[-e[0],-e[1]]}inwardsNormal(){let e=this.next[0]-this.current[0],t=this.next[1]-this.current[1],i=Math.sqrt(e*e+t*t);if(0===i)throw new Error("Vertices overlap");return[-t/i,e/i]}offset(e,t){return Th.offsetEdge(this.current,this.next,e,t)}inverseOffset(e,t){return Th.offsetEdge(this.next,this.current,e,t)}inverse(){return new Th(this.next,this.current)}static offsetEdge(e,t,i,n){return new Th([e[0]+i,e[1]+n],[t[0]+i,t[1]+n])}},gE=Array.isArray,Upe=(e,t)=>e[0]===t[0]&&e[1]===t[1],VU=e=>Array.isArray(e)&&e.length,zpe=(e,t=0,i=!1)=>{let n,r;if(VU(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&&VU(e)&&VU(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},Vpe=class{constructor(e,t=5){if(this.distance=0,this.arcSegments=t,!gE(e))throw new Error("Offset requires at least one coodinate to work with");this.edges=[],gE(e)&&"number"==typeof e[0]?this.vertices=e:(this.vertices=zpe(e),this.processContour(this.vertices,this.edges))}processContour(e,t){let i,n;if(gE(e[0])&&"number"==typeof e[0][0])for(n=e.length,Upe(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,fm.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(gE(e[0])&&"number"==typeof e[0][0]){for(n=0,r=e.length-1;n0&&(i=1===i.length?[i[0]]:(0,fm.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,fm.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()})))}},vE=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)}},Put=.0033528106647474805,Gpe=-(6378137*Put-6378137);function qU(e){return 3===e||4===e}function pm(e,t){return e.__lastFrameVisited===t&&e.__used}function qpe(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 jpe(e,t,i){if(qpe(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,Iut=e=>1/(e.__depthFromRenderedParent+1),EC=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 yC;t.unloadPriorityCallback=Iut;let i=new vE;i.maxJobs=4,i.priorityCallback=Ype;let n=new vE;n.maxJobs=1,n.priorityCallback=Ype,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||bC(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++,jU(r,this),WU(r,this),XU(r,this),YU(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=zU(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(),bC(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=zU(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 _C(e){return(new TextDecoder).decode(e)}var wh=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(_C(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}getBuffer(e,t){let{buffer:i,binOffset:n}=this;return i.slice(n+e,n+e+t)}},pf=class extends wh{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 pc(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 TC=class extends _l{parse(e){let t=new DataView(e),i=pc(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 wh(h,0,a,s),u=28+a+s,d=e.slice(u,u+o+l),p=new pf(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)}}},Hv=class extends TC{constructor(e=Va){super(),this.manager=e,this.adjustmentTransform=new qe}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 bu(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)}))}},wC=class extends _l{parse(e){let t=new DataView(e),i=pc(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 wh(h,0,a,s),u=28+a+s,d=e.slice(u,u+o+l),p=new pf(d,c.getData("BATCH_LENGTH")||c.getData("POINTS_LENGTH"),0,o,l);return Promise.resolve({version:n,featureTable:c,batchTable:p})}},$pe={RGB:"color",POSITION:"position"},Uv=class extends wC{constructor(e=Va){super(),this.manager=e}parse(e){return super.parse(e).then((e=>nt(this,null,(function*(){let t,{featureTable:i}=e,n=new ci,r=i.header.extensions;if(r&&r["3DTILES_draco_point_compression"]){let{byteOffset:e,byteLength:a,properties:s}=r["3DTILES_draco_point_compression"],o=this.manager.getHandler("draco.drc");if(null==o)throw new Error("PNTSLoader: dracoLoader not available.");let l={};for(let t in s)t in $pe&&t in s&&(l[$pe[t]]=s[t]);let h={attributeIDs:l,attributeTypes:{position:"Float32Array",color:"Uint8Array"},useUniqueIDs:!0},c=i.getBuffer(e,a);t=yield o.decodeGeometry(c,h),t.attributes.color&&(n.vertexColors=!0)}else{let e=i.getData("POINTS_LENGTH"),r=i.getData("POSITION",e,"FLOAT","VEC3"),a=i.getData("RGB",e,"UNSIGNED_BYTE","VEC3");t=new Et,t.setAttribute("position",new nn(r,3,!1)),null!==a&&(t.setAttribute("color",new nn(a,3,!0)),n.vertexColors=!0)}["QUANTIZED_VOLUME_OFFSET","QUANTIZED_VOLUME_SCALE","CONSTANT_RGBA","BATCH_LENGTH","POSITION_QUANTIZED","RGBA","RGB565","NORMAL","NORMAL_OCT16P"].forEach((e=>{e in i.header&&console.warn(`PNTSLoader: Unsupported FeatureTable feature "${e}" detected.`)}));let a=new Yr(t,n);e.scene=a,e.scene.featureTable=i;let s=i.getData("RTC_CENTER");return s&&(e.scene.position.x+=s[0],e.scene.position.y+=s[1],e.scene.position.z+=s[2]),e}))))}},SC=class extends _l{parse(e){let t=new DataView(e),i=pc(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 wh(c,0,a,s),d=32+a+s,p=e.slice(d,d+o+l),f=new pf(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(_C(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})))}},Kpe=new P,ZU=new P,JU=new P,Zpe=new P,QU=new Xn,MC=new P,RC=new qe,Vv=class extends SC{constructor(e=Va){super(),this.manager=e,this.adjustmentTransform=new qe}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 bu(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 _i(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 P;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 Ln;return e.forEach((e=>{t.add(e.scene)})),{tiles:e,scene:t}}))}},PC=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])}}},IC=class extends _l{constructor(e=Va){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 bu(n),a.register((()=>new PC)),"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)}))}},DC=new qe,LC=class extends Ln{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?DC.copy(this.matrix):DC.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1;let e=DC.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(DC);let e=this.children;for(let t=0,i=e.length;t=t&&s<=i&&l>=n&&l<=r){let t=Lut(e);u.push(t),this.getCartographicToPosition(s,l,o,t)}}}return u}getBoundingBox(e,t){eme();let{latStart:i,latEnd:n,lonStart:r,lonEnd:a}=this;if(n-i{Object.getPrototypeOf(e).raycast.call(e,t,i)}))}function r6(e,t,i,n){if(i.has(e)){if(n6(e.cached.scene,n,Tl),Tl.length>0){Tl.length>1&&Tl.sort(t6);let e=Tl[0];return Tl.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),h.containsPoint(gm.origin)?i.distance=0:i.distance=tme.distanceToSquared(gm.origin)*t*t,i.tile=e}}}r.sort(t6);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)?(n6(a,n,Tl),Tl.length>0&&(Tl.length>1&&Tl.sort(t6),l=Tl[0])):l=r6(r,t,i,n),l){let e=l.distance*l.distance;e{e.frustumCulled=e[ime]&&t}))}var EE=class extends EC{get autoDisableRendererCulling(){return this._autoDisableRendererCulling}set autoDisableRendererCulling(e){this._autoDisableRendererCulling!==e&&(super._autoDisableRendererCulling=e,this.forEachLoadedModel((t=>{rme(t,!e)})))}constructor(...e){super(...e),this.group=new LC(this),this.cameras=[],this.cameraMap=new Map,this.cameraInfo=[],this.activeTiles=new Set,this.visibleTiles=new Set,this._autoDisableRendererCulling=!0,this.optimizeRaycast=!0,this.onLoadTileSet=null,this.onLoadModel=null,this.onDisposeModel=null,this.onTileVisibilityChange=null;let t=new Zc;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=r6(this.root,this.group,this.activeTiles,e);i&&t.push(i)}else i6(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 fe),t.push(e),!0)}setResolution(e,t,i){let n=this.cameraMap;return!!n.has(e)&&(t instanceof fe?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 Uv(s);t.workingPath=r,t.fetchOptions=a,l=t.parse(e).then((e=>e.scene));break}case"i3dm":{let t=new Vv(s);t.workingPath=r,t.fetchOptions=a,t.adjustmentTransform.copy(mc),l=t.parse(e).then((e=>e.scene));break}case"cmpt":{let t=new CC(s);t.workingPath=r,t.fetchOptions=a,t.adjustmentTransform.copy(mc),l=t.parse(e).then((e=>e.scene));break}case"gltf":case"glb":let t=new IC(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(mc),e.matrix.premultiply(u),e.matrix.decompose(e.position,e.quaternion,e.scale),e.traverse((e=>{e[ime]=e.frustumCulled})),rme(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=vc.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=vc.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=vc.BlurDirectionX,e.setRenderTarget(this.renderTargetBlurBuffer2),e.clear(),this.fsQuad.render(e),this.separableBlurMaterial2.uniforms.colorTexture.value=this.renderTargetBlurBuffer2.texture,this.separableBlurMaterial2.uniforms.direction.value=vc.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 Yt({uniforms:{depthTexture:{value:null},cameraNearFar:{value:new fe(.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 Yt({uniforms:{maskTexture:{value:null},texSize:{value:new fe(.5,.5)},visibleEdgeColor:{value:new P(1,1,1)},hiddenEdgeColor:{value:new P(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 Yt({defines:{MAX_RADIUS:e},uniforms:{colorTexture:{value:null},texSize:{value:new fe(.5,.5)},direction:{value:new fe(.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 Yt({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:$l,depthTest:!1,depthWrite:!1,transparent:!0})}};vc.BlurDirectionX=new fe(1,0),vc.BlurDirectionY=new fe(0,1);var zC=class extends Zi{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 Ye}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}},SE={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 fe(512,512)},cameraNear:{value:1},cameraFar:{value:100},cameraProjectionMatrix:{value:new qe},cameraInverseProjectionMatrix:{value:new qe},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}"},Ch={defines:{KERNEL_RADIUS:4,DEPTH_PACKING:1,PERSPECTIVE_CAMERA:1},uniforms:{tDiffuse:{value:null},size:{value:new fe(512,512)},sampleUvOffsets:{value:[new fe(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}"},ME={createSampleWeights:function(e,t){let i=[];for(let n=0;n<=e;n++)i.push(But(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=ME.createSampleOffsets(t,n),e.uniforms.sampleWeights.value=ME.createSampleWeights(t,i),e.needsUpdate=!0}};function But(e,t){return Math.exp(-e*e/(t*t*2))/(Math.sqrt(2*Math.PI)*t)}var GC={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}"},RE=class extends Zi{constructor(e,t,i=!1,n=!1,r=new fe(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 Ye,this._oldClearColor=new Ye,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 fe(r.x,r.y),this.saoRenderTarget=new Vn(this.resolution.x,this.resolution.y,{type:cr}),this.blurIntermediateRenderTarget=this.saoRenderTarget.clone(),this.beautyRenderTarget=this.saoRenderTarget.clone(),this.normalRenderTarget=new Vn(this.resolution.x,this.resolution.y,{minFilter:Or,magFilter:Or,type:cr}),this.depthRenderTarget=this.normalRenderTarget.clone(),this.supportsDepthTextureExtension&&(a=new Rd,a.type=D0,this.beautyRenderTarget.depthTexture=a,this.beautyRenderTarget.depthBuffer=!0),this.depthMaterial=new Kl,this.depthMaterial.depthPacking=O0,this.depthMaterial.blending=kr,this.normalMaterial=new Id,this.normalMaterial.blending=kr,this.saoMaterial=new Yt({defines:Object.assign({},SE.defines),fragmentShader:SE.fragmentShader,vertexShader:SE.vertexShader,uniforms:ni.clone(SE.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=kr,this.vBlurMaterial=new Yt({uniforms:ni.clone(Ch.uniforms),defines:Object.assign({},Ch.defines),vertexShader:Ch.vertexShader,fragmentShader:Ch.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=kr,this.hBlurMaterial=new Yt({uniforms:ni.clone(Ch.uniforms),defines:Object.assign({},Ch.defines),vertexShader:Ch.vertexShader,fragmentShader:Ch.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=kr,this.materialCopy=new Yt({uniforms:ni.clone(Zs.uniforms),vertexShader:Zs.vertexShader,fragmentShader:Zs.fragmentShader,blending:kr}),this.materialCopy.transparent=!0,this.materialCopy.depthTest=!1,this.materialCopy.depthWrite=!1,this.materialCopy.blending=Bp,this.materialCopy.blendSrc=P0,this.materialCopy.blendDst=Ld,this.materialCopy.blendEquation=vo,this.materialCopy.blendSrcAlpha=C0,this.materialCopy.blendDstAlpha=Ld,this.materialCopy.blendEquationAlpha=vo,this.depthCopy=new Yt({uniforms:ni.clone(GC.uniforms),vertexShader:GC.vertexShader,fragmentShader:GC.fragmentShader,blending:kr}),this.fsQuad=new Ks(null)}render(e,t,i){if(this.renderToScreen&&(this.materialCopy.blending=kr,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)&&(ME.configure(this.vBlurMaterial,this.params.saoBlurRadius,this.params.saoBlurStdDev,new fe(0,1)),ME.configure(this.hBlurMaterial,this.params.saoBlurRadius,this.params.saoBlurStdDev,new fe(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=Bp:a.blending=kr,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()}};RE.OUTPUT={Beauty:1,Default:0,SAO:2,Depth:3,Normal:4};var qC=class extends Zi{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 Ye;let r=Zs;this.copyUniforms=ni.clone(r.uniforms),this.copyMaterial=new Yt({uniforms:this.copyUniforms,vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,transparent:!0,depthTest:!1,depthWrite:!1,premultipliedAlpha:!0,blending:$l}),this.fsQuad=new Ks(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 Vn(i.width,i.height,{type:cr}),this.sampleRenderTarget.texture.name="SSAARenderPass.sample");let n=Hut[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,M=.5-d*d-p*p;M<0?i=0:(M*=M,i=M*M*this.dot(this.grad3[b],d,p));let S=.5-f*f-m*m;S<0?n=0:(S*=S,n=S*S*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,M=b-l+v,S=_-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,L=255&f,D=255&m,I=255&g,O=this.perm[L+this.perm[D+this.perm[I]]]%12,k=this.perm[L+o+this.perm[D+l+this.perm[I+h]]]%12,N=this.perm[L+c+this.perm[D+u+this.perm[I+d]]]%12,F=this.perm[L+1+this.perm[D+1+this.perm[I+1]]]%12,U=.6-x*x-b*b-_*_;U<0?n=0:(U*=U,n=U*U*this.dot3(this.grad3[O],x,b,_));let B=.6-w*w-M*M-S*S;B<0?r=0:(B*=B,r=B*B*this.dot3(this.grad3[k],w,M,S));let z=.6-E*E-T*T-A*A;z<0?a=0:(z*=z,a=z*z*this.dot3(this.grad3[N],E,T,A));let H=.6-C*C-P*P-R*R;return H<0?s=0:(H*=H,s=H*H*this.dot3(this.grad3[F],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),M=n-(y-x),S=(b>_?32:0)+(b>w?16:0)+(_>w?8:0)+(b>M?4:0)+(_>M?2:0)+(w>M?1:0),E=c[S][0]>=3?1:0,T=c[S][1]>=3?1:0,A=c[S][2]>=3?1:0,C=c[S][3]>=3?1:0,P=c[S][0]>=2?1:0,R=c[S][1]>=2?1:0,L=c[S][2]>=2?1:0,D=c[S][3]>=2?1:0,I=c[S][0]>=1?1:0,O=c[S][1]>=1?1:0,k=c[S][2]>=1?1:0,N=c[S][3]>=1?1:0,F=b-E+p,U=_-T+p,B=w-A+p,z=M-C+p,H=b-P+2*p,V=_-R+2*p,W=w-L+2*p,j=M-D+2*p,G=b-I+3*p,X=_-O+3*p,q=w-k+3*p,Y=M-N+3*p,J=b-1+4*p,Z=_-1+4*p,K=w-1+4*p,$=M-1+4*p,Q=255&m,ee=255&g,te=255&v,ie=255&y,ne=u[Q+u[ee+u[te+u[ie]]]]%32,re=u[Q+E+u[ee+T+u[te+A+u[ie+C]]]]%32,ae=u[Q+P+u[ee+R+u[te+L+u[ie+D]]]]%32,se=u[Q+I+u[ee+O+u[te+k+u[ie+N]]]]%32,oe=u[Q+1+u[ee+1+u[te+1+u[ie+1]]]]%32,le=.6-b*b-_*_-w*w-M*M;le<0?r=0:(le*=le,r=le*le*this.dot4(h[ne],b,_,w,M));let he=.6-F*F-U*U-B*B-z*z;he<0?a=0:(he*=he,a=he*he*this.dot4(h[re],F,U,B,z));let ce=.6-H*H-V*V-W*W-j*j;ce<0?s=0:(ce*=ce,s=ce*ce*this.dot4(h[ae],H,V,W,j));let ue=.6-G*G-X*X-q*q-Y*Y;ue<0?o=0:(ue*=ue,o=ue*ue*this.dot4(h[se],G,X,q,Y));let de=.6-J*J-Z*Z-K*K-$*$;return de<0?l=0:(de*=de,l=de*de*this.dot4(h[oe],J,Z,K,$)),27*(r+a+s+o+l)}},AE={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 fe},cameraProjectionMatrix:{value:new qe},cameraInverseProjectionMatrix:{value:new qe},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}"},CE={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}"},PE={uniforms:{tDiffuse:{value:null},resolution:{value:new fe}},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}"},wl=class extends Zi{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 Rd;r.format=oh,r.type=Uc,this.beautyRenderTarget=new Vn(this.width,this.height,{type:cr}),this.normalRenderTarget=new Vn(this.width,this.height,{minFilter:Or,magFilter:Or,type:cr,depthTexture:r}),this.ssaoRenderTarget=new Vn(this.width,this.height,{type:cr}),this.blurRenderTarget=this.ssaoRenderTarget.clone(),this.ssaoMaterial=new Yt({defines:Object.assign({},AE.defines),uniforms:ni.clone(AE.uniforms),vertexShader:AE.vertexShader,fragmentShader:AE.fragmentShader,blending:kr}),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 Id,this.normalMaterial.blending=kr,this.blurMaterial=new Yt({defines:Object.assign({},PE.defines),uniforms:ni.clone(PE.uniforms),vertexShader:PE.vertexShader,fragmentShader:PE.fragmentShader}),this.blurMaterial.uniforms.tDiffuse.value=this.ssaoRenderTarget.texture,this.blurMaterial.uniforms.resolution.value.set(this.width,this.height),this.depthRenderMaterial=new Yt({defines:Object.assign({},CE.defines),uniforms:ni.clone(CE.uniforms),vertexShader:CE.vertexShader,fragmentShader:CE.fragmentShader,blending:kr}),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 Yt({uniforms:ni.clone(Zs.uniforms),vertexShader:Zs.vertexShader,fragmentShader:Zs.fragmentShader,transparent:!0,depthTest:!1,depthWrite:!1,blendSrc:P0,blendDst:Ld,blendEquation:vo,blendSrcAlpha:C0,blendDstAlpha:Ld,blendEquationAlpha:vo}),this.fsQuad=new Ks(null),this.originalClearColor=new Ye}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=jM),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 wl.OUTPUT.SSAO:this.copyMaterial.uniforms.tDiffuse.value=this.ssaoRenderTarget.texture,this.copyMaterial.blending=kr,this.renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case wl.OUTPUT.Blur:this.copyMaterial.uniforms.tDiffuse.value=this.blurRenderTarget.texture,this.copyMaterial.blending=kr,this.renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case wl.OUTPUT.Beauty:this.copyMaterial.uniforms.tDiffuse.value=this.beautyRenderTarget.texture,this.copyMaterial.blending=kr,this.renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case wl.OUTPUT.Depth:this.renderPass(e,this.depthRenderMaterial,this.renderToScreen?null:t);break;case wl.OUTPUT.Normal:this.copyMaterial.uniforms.tDiffuse.value=this.normalRenderTarget.texture,this.copyMaterial.blending=kr,this.renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case wl.OUTPUT.Default:this.copyMaterial.uniforms.tDiffuse.value=this.beautyRenderTarget.texture,this.copyMaterial.blending=kr,this.renderPass(e,this.copyMaterial,this.renderToScreen?null:t),this.copyMaterial.uniforms.tDiffuse.value=this.blurRenderTarget.texture,this.copyMaterial.blending=Bp,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 texSize;\n\t\t\t\tuniform vec2 direction;\n\n\t\t\t\tfloat gaussianPdf(in float x, in float sigma) {\n\t\t\t\t\treturn 0.39894 * exp( -0.5 * x * x/( sigma * sigma))/sigma;\n\t\t\t\t}\n\t\t\t\tvoid main() {\n\t\t\t\t\tvec2 invSize = 1.0 / texSize;\n\t\t\t\t\tfloat fSigma = float(SIGMA);\n\t\t\t\t\tfloat weightSum = gaussianPdf(0.0, fSigma);\n\t\t\t\t\tvec3 diffuseSum = texture2D( colorTexture, vUv).rgb * weightSum;\n\t\t\t\t\tfor( int i = 1; i < KERNEL_RADIUS; i ++ ) {\n\t\t\t\t\t\tfloat x = float(i);\n\t\t\t\t\t\tfloat w = gaussianPdf(x, fSigma);\n\t\t\t\t\t\tvec2 uvOffset = direction * invSize * x;\n\t\t\t\t\t\tvec3 sample1 = texture2D( colorTexture, vUv + uvOffset).rgb;\n\t\t\t\t\t\tvec3 sample2 = texture2D( colorTexture, vUv - uvOffset).rgb;\n\t\t\t\t\t\tdiffuseSum += (sample1 + sample2) * w;\n\t\t\t\t\t\tweightSum += 2.0 * w;\n\t\t\t\t\t}\n\t\t\t\t\tgl_FragColor = vec4(diffuseSum/weightSum, 1.0);\n\t\t\t\t}"})}getCompositeMaterial(e){return new Yt({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}"})}};Ph.BlurDirectionX=new fe(1,0),Ph.BlurDirectionY=new fe(0,1);var ome={uniforms:{tDiffuse:{value:null},resolution:{value:new fe(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"},WC=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 Rr(this.webcamCanvas);this.webcamTexture=i,i.minFilter=dr,i.magFilter=dr,this.shaderMaterial=new Yt({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 zr(e,t);return new ht(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)}},Uut=new P(1,0,0),Vut=new P(0,1,0),zut=new P(0,0,1),XC=class extends sf{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.initOrUpdateClipPlane(),this.initOrUpdateVertices(),this.initOrUpdateSectionPlane(),this.setClippingEnable(!0)}deactivate(){super.deactivate(),this.planesMesh&&this.scene.remove(...this.planesMesh),this.planesMesh=void 0}initOrUpdateVertices(){if(!this.sectionBox)return;let{min:e,max:t}=this.sectionBox;this.vertices=[new P(t.x,t.y,t.z),new P(e.x,t.y,t.z),new P(e.x,e.y,t.z),new P(t.x,e.y,t.z),new P(t.x,t.y,e.z),new P(e.x,t.y,e.z),new P(e.x,e.y,e.z),new P(t.x,e.y,e.z)]}initOrUpdateClipPlane(){let{min:e,max:t}=this.sectionBox;this.clipPlanes?(this.clipPlanes[0].constant=t.x,this.clipPlanes[1].constant=-e.x,this.clipPlanes[2].constant=t.y,this.clipPlanes[3].constant=-e.y,this.clipPlanes[4].constant=t.z,this.clipPlanes[5].constant=-e.z):this.clipPlanes=[new Mr(new P(-1,0,0),t.x),new Mr(new P(1,0,0),-e.x),new Mr(new P(0,-1,0),t.y),new Mr(new P(0,1,0),-e.y),new Mr(new P(0,0,-1),t.z),new Mr(new P(0,0,1),-e.z)]}initOrUpdateSectionPlane(){let e=this.vertices;if(e){if(this.planesMesh)this.planesMesh[0].update([e[4],e[0],e[3],e[7]]),this.planesMesh[1].update([e[1],e[5],e[6],e[2]]),this.planesMesh[2].update([e[4],e[5],e[1],e[0]]),this.planesMesh[3].update([e[6],e[7],e[3],e[2]]),this.planesMesh[4].update([e[0],e[1],e[2],e[3]]),this.planesMesh[5].update([e[5],e[4],e[7],e[6]]);else{let t=[new ui("Right",[e[4],e[0],e[3],e[7]]),new ui("Left",[e[1],e[5],e[6],e[2]]),new ui("Top",[e[4],e[5],e[1],e[0]]),new ui("Bottom",[e[6],e[7],e[3],e[2]]),new ui("Front",[e[0],e[1],e[2],e[3]]),new ui("Back",[e[5],e[4],e[7],e[6]])];this.planesMesh=t,this.scene.add(...t)}this.viewer.enableRender()}}activateSelectedObject(e){var t;null==(t=this.selectedObject)||t.setActive(e)}onDragStart(e){var t;this.selectedObject&&(J.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 P;null==(t=this.raycaster)||t.ray.intersectPlane(this.refrencePlane,i);let n=this.selectedObject.actionType;switch(n){case"Top":case"Bottom":this.dragTranslateSectionPlane(Vut,this.lastWorldPos,i,n);break;case"Left":case"Right":this.dragTranslateSectionPlane(Uut,this.lastWorldPos,i,n);break;case"Front":case"Back":this.dragTranslateSectionPlane(zut,this.lastWorldPos,i,n)}this.lastWorldPos=i}onDragEnd(e){J.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.initOrUpdateSectionPlane(),this.initOrUpdateClipPlane(),this.viewer.enableRender()}isInRange(e,t){return e>t[0]&&et.visible=e)),this.isShowSectionPlane=e,this.viewer.enableRender()}},YC=class extends sf{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 pn;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(dn.isMobile){let t=this.getIntersections(e);t&&(this.inputManager.setCursor("grab"),this.selectedObject=t.object,this.activateSelectedObject(!0),this.enableDefaultControl(!1),this.viewer.enableRender())}this.camera&&this.selectedObject&&(this.mouseDown=!0)}},this.mousemove=e=>{var t,i,n;if(this.faceInfo){if(this.dragStarted)this.updateRaycasterByMouse(e),this.onDragMove(e);else{this.activateSelectedObject(!1);let t=this.getIntersections(e);t?(this.selectedObject=t.object,this.activateSelectedObject(!0),this.mouseDown&&(null==(n=this.selectedObject)?void 0:n.parent)instanceof dc&&(this.dragStarted||(this.dragStarted=!0,this.enableDefaultControl(!1),this.onDragStart(e)))):this.selectedObject=void 0}this.viewer.enableRender()}else this.pickFace(e)?null==(t=this.tooltip)||t.show():null==(i=this.tooltip)||i.hide()},this.center=new P,this.viewer.addEventListener("AfterRender",(()=>{var e;this.isActive&&(null==(e=this.gizmo)||e.adjustSize(this.camera))}))}activate(){super.activate(),this.sectionBox.getCenter(this.center),this.tooltip=new vl("pick-section-plane",vu("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.initOrUpdateSectionPlane(),this.initOrUpdateClipPlane(),this.setClippingEnable(!0),this.viewer.enableRender()}resetSection(){var e,t,i;null==(e=this.planeMesh)||e.removeFromParent(),null==(t=this.gizmo)||t.removeFromParent(),this.setClippingEnable(!1),this.planeMesh=void 0,this.gizmo=void 0,this.faceInfo=void 0,null==(i=this.tooltip)||i.show(),this.viewer.enableRender()}setSectionVisible(e){this.gizmo&&this.planeMesh&&(this.gizmo.visible=e,this.planeMesh.visible=e),this.isShowSectionPlane=e,this.viewer.enableRender()}initOrUpdateClipPlane(){if(!this.faceInfo)return;let{normal:e,position:t}=this.faceInfo;this.clipPlane=(new Mr).setFromNormalAndCoplanarPoint(e.clone().negate(),t),this.clipPlane&&(this.clipPlanes=[this.clipPlane])}initOrUpdateSectionPlane(){var e;if(!this.faceInfo)return;let{normal:t,position:i}=this.faceInfo,n=new P;this.sectionBox.getSize(n);let r=n.length(),a=i,s=(new bt).setFromCenterAndSize(a,new P(r,r,r)),{min:o,max:l}=s;null==(e=this.planeMesh)||e.removeFromParent(),this.planeMesh=new ui("Plane",[new P(a.x,l.y,o.z),new P(a.x,l.y,l.z),new P(a.x,o.y,l.z),new P(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;this.gizmo=new dc,this.gizmo.setDirection(i),this.gizmo.position.copy(n),null==(t=this.scene)||t.add(this.gizmo)}onDragStart(e){var t;if(!this.faceInfo||this.selectedObject instanceof ui)return;J.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 ui)return;let r=new P;null==(t=this.raycaster)||t.ray.intersectPlane(this.refrencePlane,r);let a=this.selectedObject.userData.actionType,{position:s}=this.faceInfo,o=(new P).subVectors(this.lastWorldPos,s).normalize(),l=(new P).subVectors(r,s).normalize(),h=(new P).subVectors(r,this.lastWorldPos).projectOnVector(xa.clone().applyQuaternion(this.gizmo.quaternion)),c=o.angleTo(l),u=(new P).crossVectors(o,l),d=new P;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 P).addVectors(this.gizmo.position,h),this.sectionBox.clone().setFromCenterAndSize(this.center,new P(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=nf.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=rf.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 ui||J.info("[PickPlaneSection] onDragEnd:",e)}getIntersectObjects(){return this.planeMesh&&this.gizmo?[this.planeMesh,this.gizmo]:[]}activateSelectedObject(e){this.selectedObject&&(this.selectedObject instanceof ui?this.selectedObject.setActive(e):this.selectedObject.parent instanceof dc&&this.selectedObject.parent.setActive(e,this.selectedObject))}pickFace(e){if(!this.raycaster)return;let t=new fe(e.x,e.y),i=$t.screenPoint2NdcPoint(t,this.camera,this.canvas);this.raycaster.setFromCamera(i,this.camera);let n=[];return this.viewer.loadedModels.forEach((e=>{let t=this.scene&&this.scene.getObjectById(e.objectId);t&&t.visible&&n.push(t)})),(this.raycaster.intersectObjects(this.viewer.getRaycastableObjectsByMouse(e))||[]).find((e=>{let t=e.object;return t.visible&&t instanceof ht}))}},$C=class extends Tr{constructor(e){super(e,{id:"SectionPlugin"}),this.sections={},this.viewer=e;let t=e.getInputManager();t&&(this.sections.ObjectsBoxSection=new XC(e,t),this.sections.AxisPlaneSection=new kA(e,t),this.sections.PickPlaneSection=new YC(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]}setAllSectionsClippingObjectIds(e){for(let t in this.sections)this.setSectionClippingObjectIds(t,e)}setSectionClippingObjectIds(e,t){this.sections[e].clearClippingObjectIds(),null!=t&&t.length&&(this.sections[e].clippingObjetIds=t,this.sections[e].setClippingEnable(!0))}destroy(){super.destroy(),this.deactivate(),this.activeSectionType=void 0}},lme=new P,cme=new Jn,ume=class extends df{constructor(e,t){var i;super(e),this.name="BimViewer",this.timer=Date.now(),this.selectedObject=void 0,this.loadedModels=[],this.loaded3dTiles=[],this.composerRenderEnabled=!0,this.composerEnabled=!1,this.savedMaterialsForOpacity=[],this.raf=new af,this.clock=new Ua,this.renderEnabled=!0,this.enableModelLevelFrustumCulling=!0,this.isFrustumInsectChecking=!1,this.settings=K0,this.twoDModelCount=0,this.enableFastOperation=!0,this.edgesVisible=!0,this.distanceCullingFactor=150,this.operationTimeoutMs=500,this.bbox=new bt,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 P),a=i.getTarget(new P),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 P(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 P).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)=>nt(this,null,(function*(){let r=ft.getUpdateProgressFunc(n),a=ft.getUpdateSubProgressFunc(50,99,n);r(0),J.info(`[BimViewer] '${e}' is loaded in ${(Date.now()-this.timer)/1e3}s, adding to scene...`),this.timer=Date.now();let s=i.src&&i.src.toLowerCase();if(s&&s.endsWith("dxf")&&this.twoDModelCount++,i.matrix&&16===i.matrix.length){let e=new qe;e.elements=i.matrix,t.applyMatrix4(e)}t.matrixAutoUpdate=!1,t.updateMatrix(),t.traverse((e=>{e.matrixAutoUpdate&&(e.matrixAutoUpdate=!1,e.updateMatrix())})),i.merge&&this.merge(t),r(50),yield this.addLoadedModelToScene(t,i,a),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=qn(qn({},Cpe),e),J.info("[BimViewer]","viewerCfg:",this.viewerCfg),this.settings=K0,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(),J.info(`[BimViewer] Initialized in ${(Date.now()-this.timer)/1e3}s`)}init(){let e=this.viewerCfg;this.initThree(),dn.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&&J.warn("[BimViewer] enableAxisGizmo is deprecated, use AxisGizmoPlugin instead!"),!0===e.enableStats&&J.warn("[BimViewer] enableStats is deprecated, use StatsPlugin instead!"),e.enableToolbar&&(this.toolbar=this.initToolbar()),e.enableBottomBar&&J.warn("[BimViewer] enableBottomBar is deprecated, use BottomBarPlugin instead!"),e.enableNavCube&&J.warn("[BimViewer] enableNavCube is deprecated, use NavCubePlugin instead!"),e.enableProgressBar&&(this.loadingProgressBar=this.initLoadingProgressBar()),e.enableContextMenu&&(this.contextMenu=this.initContextMenu())}initScene(){this.scene=new ti,this.scene.matrixAutoUpdate=!1}initRenderer(){this.renderer=new ns({antialias:!0,preserveDrawingBuffer:!0}),this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setSize(this.width,this.height),this.renderer.outputColorSpace=zt,this.renderer.toneMappingExposure=1,this.renderer.useLegacyLights=!1,this.renderer.setClearColor(11119017,1),this.renderer.shadowMap.enabled=!0,this.renderer.shadowMap.type=A0,this.renderer.shadowMap.autoUpdate=!1,ft.printGpuInfo(this.renderer.getContext()),this.pmremGenerator=new uh(this.renderer),this.pmremGenerator.compileEquirectangularShader(),this.enableOverlayRenderer&&(this.overlayRender=new _n(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 jn(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;dn.printDeviceInfo();let t,i=e?this.orthoCamera:this.perspectiveCamera;i&&this.inputManager&&((!this.perspectiveCameraControls||!this.orthoCameraConrols)&&(t=new Ws(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 P).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 _s(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 Bx(this.directionalLight),this.directionalLightHelper.visible=!1,this.scene.add(this.directionalLightHelper),this.shadowCameraHelper=new Hx(this.directionalLight.shadow.camera),this.shadowCameraHelper.visible=!1,this.scene.add(this.shadowCameraHelper),this.ambientLight=new il(e),this.hemisphereLight=new Jc(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 Mo(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=>{var o,l;if(t=!1,i)return i=!1,this.onAnchorPointerUp(),void(null==(o=this.contextMenu)||o.hide());if(0===e.button)if(null==(l=this.contextMenu)||l.hide(),(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 2===e.button&&this.handleRightClick(e);this.onAnchorPointerUp()})),e.addEventListener("keydown",(e=>{this.onKeyDown(e)})),this.initRotateToCursor(),this.raycaster=new Is}initOthers(){!this.scene||!this.renderer||!this.camera||(this.renderer.domElement.style.outlineWidth="0")}initContextMenu(){let e=new pC({items:Lpe,context:{bimViewer:this,toolbar:this.toolbar,section:this.section},container:this.widgetContainer});return window.oncontextmenu=e=>e.preventDefault(),e}initToolbar(){let e=this.viewerCfg;return new yu(this,(0,gf.merge)({},Mpe,e.toolbarMenuConfig))}initLoadingProgressBar(){return new tf(this.widgetContainer)}get has2dModel(){return this.twoDModelCount>0}showContextMenu(e){if(!this.contextMenu||!this.widgetContainer)return;let t=this.contextMenu.context;if(this.selectedObject){let e=this.selectedObject.userData.instanceId,i=this.selectedObject.userData.batchId;this.contextMenu.context=ai(qn({},t),{hit:this.selectedObject,instanceId:e,batchId:i})}else{this.raycaster&&this.raycaster.layers.set(10);let i=this.getAllIntersections(e);J.debug("[BimViewer] showContextMenu intersections = ",i);let n,r=(0,gf.find)(i,(e=>{let t=e.object;return t instanceof ht&&t.visible})),a=null==r?void 0:r.instanceId,s=null==r?void 0:r.faceIndex;s&&(n=Pr.getBatchIdByFaceIndex(null==r?void 0:r.object,s)),this.contextMenu.context=ai(qn({},t),{hit:null==r?void 0:r.object,instanceId:a,batchId:n})}let{x:i,y:n}=e;this.contextMenu.show(i,n)}handleRightClick(e){var t;null!=(t=this.measurePlugin)&&t.isActive()||this.showContextMenu(e)}sycnCameraAndControls(e){let t=e?this.orthoCamera:this.perspectiveCamera,i=e?this.perspectiveCameraControls:this.orthoCameraConrols,n=e?this.orthoCameraConrols:this.perspectiveCameraControls,r=new P;i.getPosition(r),n.setPosition(r.x,r.y,r.z);let a=i.getTarget(new P);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 Er(-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.update()})))}frustumCullingByModelBBox(){if(!this.enableModelLevelFrustumCulling)return;let e=this.camera,t=this.scene;if(!e||!t)return;e.updateMatrixWorld();let i=new qe;i.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse);let n=new qs;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,J.debug(`[BimViewer] frustumCullingByModelBBox() set model (id ${e.id})'s visible to:`,i))}};this.isFrustumInsectChecking=!0,this.loadedModels.forEach((e=>{let i=t.getObjectById(e.objectId);r(i,e.bbox)})),this.loaded3dTiles.forEach((e=>{let t=e.tilesRenderer.group;r(t,e.bbox)})),this.isFrustumInsectChecking=!1}destroy(){var e,t,i;null==(e=this.inputManager)||e.removeEventListener();let n=this.webcamPlane;this.scene&&n&&(this.scene.remove(n),n.geometry.dispose(),n.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=[],this.loaded3dTiles.forEach((e=>{e.tilesRenderer.dispose()})),this.loaded3dTiles=[],this.perspectiveCamera=void 0,this.perspectiveCameraControls=void 0,this.raf&&(this.timeoutSymbol&&this.raf.clearTimeout(this.timeoutSymbol),this.raf=void 0),this.contextMenu&&(this.contextMenu.destroy(),this.contextMenu=void 0),this.toolbar&&(this.toolbar.destroy(),this.toolbar=void 0),this.font=void 0,this.pmremGenerator&&(this.pmremGenerator.dispose(),this.pmremGenerator=void 0),null==(i=this.zoomToRectHelper)||i.destroy(),this.zoomToRectHelper=void 0,super.destroy()}loadLocalModel(e,t,i,n){return nt(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||(J.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 ba(i);this.font&&n.setFont(this.font);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 J.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 nt(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||(J.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 ba;this.font&&t.setFont(this.font);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 J.error(n,t),Promise.reject(n)}finally{this.decreaseJobCount(),s(100),null==(n=this.loadingProgressBar)||n.delayRemoveProgressItem(r)}return Promise.reject()}))}load3dTiles(e){return nt(this,null,(function*(){var t;this.timer=Date.now(),this.increaseJobCount();let i=new EE(e.src),n=new bt,r=yield new Promise(((t,r)=>{i.onLoadTileSet=()=>{i.getBounds(n)||(i.getBoundingSphere(cme)?cme.getBoundingBox(n):(J.warn(`[BimViewer] Can't get the correct bounding box of 3dTiles '${e.src}'!`),r())),J.debug(n),i.onLoadTileSet=null;let a=i.group;J.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=e.modelId||e.src,o=e=>!!this.loaded3dTiles.find((t=>t.modelId===e));if(o(s)){let e=1;for(;o(`${s}_${e}`);)e++;s=`${s}_${e}`,J.warn(`[BimViewer] 3dTiles '${s}' is loaded more than once!`)}let l={modelId:s,objectId:r.id,bbox:n,tilesRenderer:i};if(this.loaded3dTiles.push(l),e.matrix&&16===e.matrix.length){let t=new qe;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(),0===this.loadedModels.length&&1===this.loaded3dTiles.length&&(this.tryAdjustCameraNearAndFar(),this.goToHomeView()),J.info(`[BimViewer] 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 nt(this,null,(function*(){let t=Date.now();Po.isShxFile(e[0])?this.font=yield(new Po).loadAsync(e):(e.length>1&&J.warn("[BimViewer] Only support 1 typeface font file for now, others will be ignored!"),this.font=yield(new uu).loadAsync(e[0])),J.info(`[BimViewer] Font file(s) load time in ${(Date.now()-t)/1e3}s`)}))}setDracoDecoderPath(e){ba.setDracoDecoderPath(e)}addLoadedModelToScene(e,t,i){return nt(this,null,(function*(){if(!this.scene||!this.renderer)return;let n=ft.getUpdateProgressFunc(i),r=ft.getUpdateSubProgressFunc(20,99,i);if(n(0),t.merge){let t=Date.now();uf.createMeshBvhAsync([e],{saveOriginalIndex:!0}),J.info(`[BimViewer] Creates mesh bvh cost ${(Date.now()-t)/1e3}s`)}e.traverse((e=>{e.isMesh&&(e.castShadow=!0,e.receiveShadow=!0,e.userData.surfaceArea=this.calculateMeshSurfaceArea(e)),e.geometry&&e.layers.enableAll(),e instanceof Ha&&(e.visible=!1)})),this.scene.add(e);let a=(new bt).setFromObject(e),s=t.modelId||t.src,o=e=>!!this.loadedModels.find((t=>t.modelId===e));if(o(s)){let e=1;for(;o(`${s}_${e}`);)e++;s=`${s}_${e}`,J.warn(`[BimViewer] Model '${s}' is loaded more than once!`)}let l={modelId:s,objectId:e.id,bbox:a};this.loadedModels.push(l),this.computeBoundingBox(),this.tryAdjustDirectionalLight();let h=this.loadedModels.map((e=>e.objectId));this.loaded3dTiles.forEach((e=>h.push(e.objectId))),(!h||h.length<=1)&&(this.has2dModel&&this.setToOrthographicCamera(!0),this.tryAdjustCameraNearAndFar(),this.goToHomeView()),n(20),t.edges&&(l.edges=yield Sn.createOutlines(e,void 0,r)),n(100),J.info(`[BimViewer] Added '${t.src}' to scene in ${(Date.now()-this.timer)/1e3}s`),this.renderer.shadowMap.needsUpdate=!0,this.enableRender(),this.dispatchEvent("ModelLoaded",{modelId:s,bbox:a})}))}calculateMeshSurfaceArea(e){let t=new Vr,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.objectId));this.loaded3dTiles.forEach((e=>s.push(e.objectId))),s.forEach((s=>{if(e){this.savedMaterialsForOpacity&&this.savedMaterialsForOpacity.length>0&&Sn.revertObjectOpacityById(r,s,this.savedMaterialsForOpacity);let e=Sn.setObjectOpacityById(r,s,t,i,n);a.push(...e)}else this.savedMaterialsForOpacity&&Sn.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 Ln),null==(i=this.scene)||i.traverseVisible((e=>{var i;if(e instanceof ht&&!["SKYBOX","GROUND_GRID","GROUND_GRASS","BIM_VIEWER_BOX_HELPER"].includes(e.name)){if(!e.geometry.attributes.normal)return;let n=new BC(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 fe(e.x,e.y),n=$t.screenPoint2NdcPoint(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=this.scene&&this.scene.getObjectById(t.objectId);i&&i.visible&&e.push(i)})),this.loaded3dTiles.forEach((t=>{let i=this.scene&&this.scene.getObjectById(t.objectId);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 fe(null==e?void 0:e.x,null==e?void 0:e.y),i=$t.screenPoint2NdcPoint(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){let t=Date.now();this.raycaster&&this.raycaster.layers.set(12);let i=this.getIntersections(e);J.debug(`[BimViewer] getIntersections costs ${(Date.now()-t)/1e3}s`);let n=i.find((e=>{let t=e.object;return t.visible&&t instanceof ht}));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())return;let r=Date.now();this.raycaster&&this.raycaster.layers.set(12);let a=this.getIntersections(e);J.debug(`[BimViewer] getIntersections costs ${(Date.now()-r)/1e3}s`);let s,o,l=a.find((e=>{let t=e.object;return t.visible&&t instanceof ht})),h=l&&l.object||void 0;if(h)if(h instanceof _i)s=l.instanceId,this.selectedObject&&this.selectedObject.id===h.id&&this.selectedObject.userData.instanceId===s&&(h=void 0);else if(Pr.isMergedMesh(h)){let e=l&&l.faceIndex||-1;e>=0?(o=Pr.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.selectedObject&&this.clearSelection(),h?this.selectObject(h,s,o):this.clearSelection()}selectObject(e,t,i,n=void 0){if(e instanceof mi)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 Qn&&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 _i&&null!=t){let i=e,r=new qe,a=new qe;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=Di.clonedHighlightMaterials(e,{depthTest:n});if(s){let n=new ht(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(Pr.isMergedMesh(e)&&null!=i){let t=Pr.getBatchByBatchId(e,i),r=`[BimViewer] 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)}`),J.info(r);let a=Di.clonedHighlightMaterials(e,{depthTest:n}),s=Pr.cloneGeometryForBatch(e,t);if(a&&s){let t=new ht(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=Di.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 mi?this.selectedObject.selected=!1:this.selectObject(),this.selectedObject=void 0}getBBox(){return this.bbox}enableModelEdges(e,t){return nt(this,null,(function*(){var i;let n=ft.getUpdateProgressFunc(t);n(0),this.increaseJobCount();let r=this.loadedModels.length;for(let a=0;at.visible=e))}this.decreaseJobCount(),n(100),this.enableRender()}))}flyToObjects(e){if(!e||0===e.length||!this.camera)return;let t=new bt;e.forEach((e=>{let i=fs.getBoundingBox(e);t.union(i)}));let i=new Jn;t.getBoundingSphere(i),this.controls.fitToSphere(i,!0)}flyToObject(e){this.flyToObjects([e])}flyToSelectedObject(){if(!this.selectedObject)return;let e=this.selectedObject;(e instanceof _i&&e.userData.clonedMesh||Pr.isMergedMesh(e)&&e.userData.clonedMesh)&&(e=e.userData.clonedMesh),this.flyToObject(e)}flyToRandomObject(){var e,t,i;let n=this.loadedModels.map((e=>e.objectId));this.loaded3dTiles.forEach((e=>n.push(e.objectId)));let r=n.length;if(r<=0)return;let a=Math.floor(Math.random()*r),s=n[a];if(!(null==(e=this.scene)?void 0:e.getObjectById(s)))return;let o=[];if(null==(t=this.scene)||t.traverseVisible((e=>{(e instanceof ht||e instanceof Wn)&&!["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=null==(i=this.scene)?void 0:i.getObjectById(o[l]);h&&(J.info(`[BimViewer] Flying to random object: ${h.name}, type: ${h.type}`),this.selectObject(h,void 0,void 0,!1),this.flyToObject(h))}flyTo(e,t){let i=this.camera,n=this.controls;if(!i||!n)return;if(e.equals(t))return void J.error("[BimViewer] camera position and lookAt cannot be the same!");if(!ft.isVectorValid(e)||!ft.isVectorValid(t))return void J.error("[BimViewer] invalid position or lookAt!");let r=e.distanceTo(t);ri.far&&(e=e.clone().sub(t).normalize().multiplyScalar(.9*i.far),J.warn("[BimViewer] 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=fs.getVisibleObjectBoundingBox(this.scene),t=new Jn;e.getBoundingSphere(t),this.controls.fitToSphere(t,!0)}goToHomeView(){let e=this.camera,t=this.cameraCfg,i=t&&ft.arrayToVector3(t.eye),n=t&&ft.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 if(this.scene){let t=new P,i=new P,n=new P(-1,-.5,-1);if(this.has2dModel){let e=this.bbox.max.x-this.bbox.min.x,t=this.bbox.max.y-this.bbox.min.y,i=this.bbox.max.z-this.bbox.min.z,r=Math.min(e,t,i);e-r<=0?n.set(1,0,0):t-r<=0?n.set(0,-1,0):i-r<=0&&n.set(0,0,-1)}this.bbox.getCenter(i),t.subVectors(i,n);let r=new Jn;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 Er){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 Jn;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||nft.numberToString(e);J.info(`[BimViewer] BBox's longest side is: ${t(o)}`),i>l&&(J.warn(`[BimViewer] 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||J.warn("[BimViewer] 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()):J.warn("[BimViewer] 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 kv(this)),this.zoomToRectHelper.activate()}deactivateZoomRect(){var e;null==(e=this.zoomToRectHelper)||e.deactivate()}enableWebCam(){this.scene&&(this.webcam||(this.webcam=new WC),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){rc.createEnvTexture(this.pmremGenerator,e).then((e=>{this.scene&&(this.scene.environment&&this.scene.environment.dispose(),this.scene.environment=e,this.enableRender())}))}setEnvironmentFromDataArray(e){rc.createEnvTextureFromDataArray(this.pmremGenerator,e).then((e=>{this.scene&&(this.scene.environment=e,this.enableRender())}))}takeObjectsScreenshot(e){return nt(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 ht&&((0,gf.includes)(e,(0,gf.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)Di.setMaterialColor(i[n],new Ye(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)})),Pr.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 bt;return this.loadedModels.forEach((t=>{t.bbox&&!t.bbox.isEmpty()&&e.union(t.bbox)})),this.loaded3dTiles.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 P).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 P;return e.getWorldDirection(i),{position:{x:t.x,y:t.y,z:t.z},direction:{x:i.x,y:i.y,z:i.z}}}},KC=Xi(ac(),1),Gut=(e=>(e[e.Browser=0]="Browser",e[e.Browserless=1]="Browserless",e[e.Headless=2]="Headless",e))(Gut||{}),hme=class{constructor(e,t,i){if(this.scene=this.initScene(),this.selectedObject=void 0,this.loadedModels=[],this.clock=new Ua,this.viewerMode=0,this.raycaster=new Is,this.savedMaterialsForOpacity=[],this.jobCount=0,this.bbox=new bt,this.outlineMaterial=new En({color:1118481}),this.outlineRoot=new Ln,this.transparentObjectIds=[],this.applyOptionsAndAddToScene=(e,t,i,n)=>nt(this,null,(function*(){if(J.info(`[SimplifiedBimViewer] '${e}' is loaded, adding to scene...`),i.matrix&&16===i.matrix.length){let e=new qe;e.elements=i.matrix,t.applyMatrix4(e)}yield this.addLoadedModelToScene(t,i,n)})),this.getMeshes=e=>{let t=[];return e instanceof ht?t.push(e):e.traverseVisible((e=>{e instanceof ht&&t.push(e)})),t},this.containerOrCanvas=e,t&&(this.viewerMode=t),this.glContext=i,1===this.viewerMode&&(e instanceof HTMLDivElement||!i))throw new Error("[SimplifiedBimViewer] Parameters don't match Browserless viewerMode !");this.increaseJobCount(),this.init(),this.decreaseJobCount(),J.info("[SimplifiedBimViewer] Initialized"),this.animate()}init(){this.initRenderer(),this.initCamera(),this.initControls(),this.initLights(),this.initPointerEvents(),this.scene.add(this.outlineRoot)}initScene(){let e=new ti;return e.background=new Ye(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 ns(e);if(t){let e=this.containerOrCanvas.width,t=this.containerOrCanvas.height;J.info(`[SimplifiedBimViewer] Render target size: ${e} x ${t}`),this.renderTarget=new Vn(e,t,{minFilter:dr,magFilter:Or,format:As,type:Yl}),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=zt,i.toneMappingExposure=1,i.useLegacyLights=!1,i.setClearColor(11119017,1),i.shadowMap.enabled=!0,i.shadowMap.type=A0,this.renderer=i,t||(this.pmremGenerator=new uh(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 jn(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 Ws(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 _s(e,.3);t.position.set(-2,2,4);let i=new il(3158064),n=new Jc(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 nt(this,null,(function*(){let n=yield(new ba).loadLocalModel(e,t.src,i);return n?(yield this.applyOptionsAndAddToScene(e,n,t),Promise.resolve()):Promise.reject()}))}loadModel(e,t){return nt(this,null,(function*(){this.increaseJobCount();let i=yield(new ba).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 ba).parseGltf(e,t.src,(e=>{this.applyOptionsAndAddToScene(t.src,e,t),i&&i(e)}),(e=>{n&&n(e)}))}addLoadedModelToScene(e,t,i){return nt(this,null,(function*(){if(!this.scene)return Promise.resolve();e.updateMatrix(),e.traverse((e=>{e.geometry&&e.layers.enableAll()})),this.scene.add(e);let n=(new bt).setFromObject(e),r=t.modelId||t.src,a=e=>!!this.loadedModels.find((t=>t.modelId===e));if(a(r)){let e=1;for(;a(`${r}_${e}`);)e++;r=`${r}_${e}`,J.warn(`[BimViewer] Model '${r}' is loaded more than once!`)}let s={modelId:r,objectId:e.id,bbox:n};this.loadedModels.push(s),this.computeBoundingBox();let o=this.loadedModels.map((e=>e.objectId));(!o||o.length<=1)&&(this.tryAdjustCameraNearAndFar(),this.goToHomeView()),t.edges&&(s.edges=yield Sn.createOutlines(e,void 0,i)),this.decreaseJobCount(),J.info(`[SimplifiedBimViewer] Added '${t.src}' to scene`)}))}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&&Sn.revertObjectOpacityById(r,s.objectId,this.savedMaterialsForOpacity);let e=Sn.setObjectOpacityById(r,s.objectId,t,i,n);a.push(...e)}else this.savedMaterialsForOpacity&&Sn.revertObjectOpacityById(r,s.objectId,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 fe;e&&(t=$t.getScreenPointByEvent(e,this.containerOrCanvas));let i=$t.screenPoint2NdcPoint(t,this.camera,this.containerOrCanvas);this.raycaster.setFromCamera(i,this.camera);let n=[];return this.loadedModels.forEach((e=>{let t=this.scene&&this.scene.getObjectById(e.objectId);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 ht})),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 Qn&&e.dispose()}this.selectedObject.material=e.originalMaterial,delete e.originalMaterial}this.selectedObject=void 0}if(!this.scene||!e)return;let t=Di.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 bt;e.forEach((e=>{let i=fs.getBoundingBox(e);t.union(i)}));let i=new Jn;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 P(e[0],e[1],e[2]):e,o=t=Array.isArray(t)?new P(t[0],t[1],t[2]):t;J.info("[SimplifiedBimViewer] flyTo: ",ft.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 Jn;this.bbox.getBoundingSphere(e),this.controls.fitToSphere(e,!0)}setEnvironmentFromDataArray(e){rc.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||nft.numberToString(e);J.info(`[SimplifiedBimViewer] BBox's longest side is: ${t(o)}`),i>l&&(J.warn(`[SimplifiedBimViewer] 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 jt({color:16777215,transparent:!0,opacity:.1});this.loadedModels.forEach((e=>{Sn.applyMaterialToObjectById(this.scene,e.objectId,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=i?this.scene.getObjectById(i.objectId):this.scene;n||(J.warn(`[BimViewer] The ModelId of ${t} has no corresponding model.`),n=this.scene),n.traverse((t=>{if((0,KC.includes)(e.id,(0,KC.get)(t.userData,"UniqueId"))){let e=this.getMeshes(t);r=r.concat(e)}}))})),r.length>0){r.forEach((e=>{let t=Sn.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=>{Sn.revertAppliedMaterialToObjectById(this.scene,t.objectId,e)})),this.transparentObjectIds=e,this.flyToObjects(r)}else J.warn(`[BimViewer] No object found with uniqueIds: ${e.map((e=>e.id))}`);this.isBrowserMode()||this.animate()}increaseJobCount(){++this.jobCount}decreaseJobCount(){--this.jobCount}computeBoundingBox(){let e=new bt;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 P;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())}},dme=new P,qut=new Xn,fme=new P,vm=class extends Xt{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}},_u=new qe,jut=new qe,ZC=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?(_u.copy(i.matrixWorldInverse),_u.transpose(),0!==e.rotation2D&&_u.multiply(jut.makeRotationZ(e.rotation2D)),e.matrixWorld.decompose(dme,qut,fme),_u.setPosition(dme),_u.scale(fme),_u.elements[3]=0,_u.elements[7]=0,_u.elements[11]=0,_u.elements[15]=1,n=d(_u)):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 pme.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 nt(this,null,(function*(){if(!this.thumbnailImages||6!=this.thumbnailImages.length)return;this.thumbnailMesh=new ht(new Gs(e,e,e)),this.thumbnailMesh.geometry.scale(1,1,-1);let t=(yield this.loadTexturesAsync(this.thumbnailImages)).map((e=>new jt({map:e,side:Xr,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=zt,t}))}loadTexturesAsync(e){return nt(this,null,(function*(){let t=e.map((e=>this.textureLoader.loadAsync(e))),i=yield Promise.all(t);return i.forEach((e=>e.colorSpace=zt)),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 ht?this.destroyMesh(this.mesh):this.mesh.traverse((e=>{e instanceof ht&&this.destroyMesh(e)})),this.mesh=void 0)}},JC=class extends vf{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 nt(this,null,(function*(){yield this.createThumbnailMesh(this.size+.1),this.thumbnailMesh?this.createMesh():yield this.createMesh()}))}createMesh(){return nt(this,null,(function*(){let e=this.mesh;e.geometry=new Gs(this.size,this.size,this.size),e.geometry.scale(1,1,-1);let t=(yield this.loadTexturesAsync(this.images)).map((e=>new jt({map:e,side:Xr,transparent:!0})));e.material=t,this.add(e),this.thumbnailMesh&&(this.destroyMesh(this.thumbnailMesh),this.thumbnailMesh=void 0,this.thumbnailImages=void 0)}))}},QC=class extends vf{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 nt(this,null,(function*(){yield this.createThumbnailMesh(this.size+.1),this.thumbnailMesh?this.createMesh():yield this.createMesh()}))}createMesh(){return nt(this,null,(function*(){var e;this.mesh=new Ln,this.mesh.scale.set(1,1,-1);let t=(yield this.loadTexturesAsync(this.images)).map((e=>new jt({map:e,side:Ci,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 P(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 P(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 P(1,0,0),-Math.PI/2),r.rotateOnAxis(new P(0,0,1),Math.PI),r.rotateOnAxis(new P(1,0,0),Math.PI),r.position.set(0,this.size/2,0);let a=this.createPlaneOfAFace(t.slice(12,16));a.rotateOnAxis(new P(1,0,0),Math.PI/2),a.rotateOnAxis(new P(0,0,1),Math.PI),a.rotateOnAxis(new P(1,0,0),Math.PI),a.position.set(0,-this.size/2,0);let s=this.createPlaneOfAFace(t.slice(16,20));s.rotateOnAxis(new P(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 Ln,n=new zr(this.subPlaneWidth0,this.subPlaneWidth0),r=new zr(this.subPlaneWidth1,this.subPlaneWidth0),a=new zr(this.subPlaneWidth0,this.subPlaneWidth1),s=new zr(this.subPlaneWidth1,this.subPlaneWidth1),o=new ht(n,e[0]),l=new ht(r,e[1]),h=new ht(a,e[2]),c=new ht(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}},e2=class extends vf{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 nt(this,null,(function*(){yield this.createThumbnailMesh(this.size+.1),this.thumbnailMesh?this.createMesh():yield this.createMesh()}))}createMesh(){return nt(this,null,(function*(){var e;let t=this.mesh;t.geometry=new da(this.size,100,100),t.geometry.scale(-1,1,1);let i=(yield this.loadTexturesAsync(this.images)).map((e=>new jt({map:e,side:Xr,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)}))}},mme=class extends df{constructor(e,t){super(e),this.name="VRViewer",this.timer=Date.now(),this.loadedModels=[],this.minFov=50,this.maxFov=95,this.raycaster=new Is,this.autoRotate=!0,this.events=[],this.isMousePressing=!1,this.settings=K0,this.viewpoints=[],this.previousViewpointId="",this.previousPanoramaId="",this.activeViewpointId="",this.activePanoramaId="",this.viewpointAssetsMap=new Map,this.loadingPanos=[],this.onResize=()=>{this.viewerContainer&&this.viewerContainer.parentElement&&this.resize(this.viewerContainer.parentElement.clientWidth,this.viewerContainer.parentElement.clientHeight)},this.onMouseWheel=e=>{let t=e.deltaY<0?-5:5;this.updateFov(t)},this.applyOptionsAndAddToScene=(e,t,i,n)=>nt(this,null,(function*(){let r=ft.getUpdateProgressFunc(n),a=ft.getUpdateSubProgressFunc(50,99,n);if(r(0),J.info(`[VRViewer] '${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 qe;e.elements=i.matrix,t.applyMatrix4(e)}t.matrixAutoUpdate=!1,t.updateMatrix(),t.traverse((e=>{e.matrixAutoUpdate&&(e.matrixAutoUpdate=!1,e.updateMatrix())})),i.merge&&this.merge(t),r(50),yield this.addLoadedModelToScene(t,i,a),r(100)})),this.viewerCfg=e,this.cameraCfg=t||{eye:[0,0,0],look:[0,0,0]},this.settings=K0,this.cameraCfg.near&&(this.settings.camera.near=this.cameraCfg.near),this.cameraCfg.far&&(this.settings.camera.far=this.cameraCfg.far),this.setSpinnerVisibility(++this.jobCount>0),this.init(),this.animate(),this.setSpinnerVisibility(--this.jobCount>0)}init(){let e=this.viewerCfg;this.initSpinner(),this.initScene(),this.initRenderer(),this.initCamera(),this.initControls(),this.initLights(),this.initInputManager(),this.initEvents(),this.initOthers(),e.enableToolbar&&(this.toolbar=this.initToolbar())}initScene(){let e=new ti;e.background=new Ye(16777215),e.matrixAutoUpdate=!0,this.scene=e}initRenderer(){var e,t;this.renderer=new ns({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 jn(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 XR(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 HA(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 P(0,0,0),r=new P(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 _s(16777215,.3);e.position.set(-2,2,4),this.scene.add(e);let t=new Jc(16777215,14540253,2);t.position.set(0,300,0),this.scene.add(t)}initInputManager(){this.viewerContainer&&(this.inputManager=new Mo(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===GM.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===GM.LEFT)if(null!=(a=n.originalEvent)&&a.target&&n.originalEvent.target instanceof HTMLDivElement){let e=zd.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&&(J.info("[VRViewer] Clicked on hotpoint: ",e.hotpointId||e),this.onHotpointClicked&&this.onHotpointClicked(e))}}}else{let e=this.getIntersection(n);if(e){let i=e=>ft.vectorToString(e),n=e.point,r=n.clone().sub(t.position).normalize();J.info(`[VRViewer] 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")}initToolbar(){let e=this.viewerCfg;return new yu(this,qn(qn({},Rpe),e.toolbarMenuConfig),[["SceneClear"]])}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="",this.previousViewpointId="",this.previousPanoramaId=""}destroy(){var e,t;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)),null==(t=this.toolbar)||t.destroy(),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 P(t[0],t[1],t[2]):new P(t.x,t.y,t.z):s.target.clone().sub(a.position),n.normalize(),r=Array.isArray(e)?new P(e[0],e[1],e[2]):new P(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 P(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 P;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.previousViewpointId="",this.previousPanoramaId="",this.activeViewpointId="",this.activePanoramaId="",this.viewpoints=e}loadModel(e,t){return nt(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 ba).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 J.error(n,t),Promise.reject(n)}finally{this.decreaseJobCount(),s(100),null==(n=this.loadingProgressBar)||n.delayRemoveProgressItem(r)}return Promise.reject()}))}setModelVisibility(e,t){var i;let n=this.loadedModels.find((t=>t.modelId===e)),r=(null==n?void 0:n.objectId)&&(null==(i=this.scene)?void 0:i.getObjectById(n.objectId));if(!r)throw new Error(`Failed to find model by modelId '${e}'!`);r.visible=t,this.enableRender()}addLoadedModelToScene(e,t,i){return nt(this,null,(function*(){if(!this.scene)return;let n=ft.getUpdateProgressFunc(i),r=ft.getUpdateSubProgressFunc(20,99,i);if(n(0),t.merge){let t=Date.now();uf.createMeshBvhAsync([e],{saveOriginalIndex:!0}),J.info(`[VRViewer] Creates mesh bvh cost ${(Date.now()-t)/1e3}s`)}e.traverse((e=>{e.geometry&&e.layers.enableAll()})),this.scene.add(e);let a=(new bt).setFromObject(e),s=t.modelId||t.src,o=e=>!!this.loadedModels.find((t=>t.modelId===e));if(o(s)){let e=1;for(;o(`${s}_${e}`);)e++;s=`${s}_${e}`,J.warn(`[VRViewer] Model '${s}' is loaded more than once!`)}let l={modelId:s,objectId:e.id,bbox:a};this.loadedModels.push(l),t.edges&&(l.edges=yield Sn.createOutlines(e,void 0,r)),J.info(`[VRViewer] Added '${t.src}' to scene in ${(Date.now()-this.timer)/1e3}s`),this.enableRender(),this.dispatchEvent("ModelLoaded")}))}addPanorama(e,t){let i=this.viewpoints.find((t=>t.id===e));if(!i)throw new Error(`[VRViewer] 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 J.warn(`[VRViewer] Duplicated hotpointId: ${e.hotpointId}`);let a=t.position||[0,0,0],s=e.anchorPosition,o=zd.createHotpoint(e.html),l=new P(s[0],s[1],s[2]),h=new P(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(){this.viewpointAssetsMap.forEach(((e,t)=>{var i;let n=e.panoramas;for(let r=n.length-1;r>=0;--r){let e=n[r];if(t===this.activeViewpointId&&e.id===this.activePanoramaId||t===this.previousViewpointId&&e.id===this.previousPanoramaId)return;e.box.destroy(),null==(i=this.scene)||i.remove(e.box),n.splice(r,1)}}))}unlimitControlsAndShowAssets(e=!1){if(this.controls){let e=this.controls;e.enablePan=!0,e.enableZoom=!0}this.viewpointAssetsMap.forEach((t=>{t.panoramas.forEach((e=>{e.box.visible=!0})),e&&t.css2dObjects.forEach((e=>{e.visible=!0}))}))}relocateAnchorIfTooCloseToCamera(e,t,i){let n=this.camera;if(!n)return J.error("[VRViewer] 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 P(0,0,0),a=new P(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.previousViewpointId=this.activeViewpointId,this.previousPanoramaId=this.activePanoramaId,this.activeViewpointId=e.id,this.activePanoramaId=t;try{if(this.loadingPanos.some((i=>i.viewpointId===e.id&&i.panoramaId===t)))return void J.warn(`[VRViewer] Panorama with viewpointId=${e.id} and panoramaId=${t} is being created`);let i=new xR(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=zd.createHotpoint(r.html);s.visible=!1!==r.visible,s.userData.hotpoint=r;let o=new P(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],J.warn(`[VRViewer] Failed to find panorama by id '${t}', will use the first one`)),n=i.images,r=i.thumbnails}if(!n)throw new Error("[VRViewer] 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(`[VRViewer] Wrong number of images! Expected 1/6/24, got ${n.length}`)}createBoxByImage(e,t){return nt(this,null,(function*(){let i=new e2(e,t);return yield i.create(),i}))}createBoxBy6Images(e,t){return nt(this,null,(function*(){if(6!==e.length)throw new Error(`[VRCube] Wrong number of images! Expected 6, got ${e.length}`);let i=new JC(e,t);return yield i.create(),i}))}createBoxBy24Images(e,t){return nt(this,null,(function*(){if(24!==e.length)throw new Error(`[VRCube] Wrong number of images! Expected 24, got ${e.length}`);let i=new QC(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 fe;e&&(a=$t.getScreenPointByEvent(e,r));let s=$t.screenPoint2NdcPoint(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 ht})):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 P(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)})),Pr.deepMerge(t,e)}finally{this.decreaseJobCount()}}},t2=class extends Xt{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 P(0,0,0),n=new P(1,0,0),r=new P(0,1,0),a=new ec(n,i,this.AXIS_LENGTH,this.AXIS_COLOR_X,0,0),s=new ec(r,i,this.AXIS_LENGTH,this.AXIS_COLOR_Y,0,0);if(this.add(a,s),!t){let e=new P(0,0,1),t=new ec(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 $0(n)}},gme=class extends Tr{constructor(e,t){super(e,{id:"AxisGizmoPlugin"}),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 ns({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 ti,this.camera=new Er(-1,1,1,-1,.1,100),this.scene.add(this.camera),this.coordinateAxes=new t2(!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 P;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)}},c6=Xi(ac(),1),Wut="bottomBar",Xut={"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 ht||e instanceof Wn||e instanceof Yr)&&!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 ht)if(i.index&&i.index.count){let n=Math.round(i.index.count/3);e instanceof _i&&(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 Qn?i(n.id):Array.isArray(n)&&n.forEach((e=>i(e.id)))})(e,i):e instanceof Ha&&(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",`${Jb}${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=>ft.numberToString(e),a=e=>ft.vectorToString(e),s=i.position,o=n instanceof Ws?n.getTarget(new P):n.target;if(s){let t=document.createElement("span");t.innerHTML=`\n

Camera position:${a(s)}

\n

Camera target:${a(o)}

`,i instanceof Er&&(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()}}},vme=class extends Tr{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=Wut,t.classList.add("bottom-bar"),(0,c6.forEach)(Xut,((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 l6(e,this,t,i);return this.itemList.set(t,n),n}},l6=class{constructor(e,t,i,n){this.viewer=e,this.bottomBar=t,this.menuId=i,this.cfg=n,this.eventBus=Av(),this.active=!1,this.itemconfig=n,this.element=this.createButton(this.menuId,n),this.tooltip=new vl(i+"-tooltip",null,{parentNode:e.widgetContainer}),this.eventBus.on("activeChange",(e=>{e?(this.element.classList.add("active"),(0,c6.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&&_R(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=ev}=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)}};function Yut(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 $v(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 yme=Array.prototype.forEach,IE=Array.prototype.slice,At={BREAK:{},extend:function(e){return this.each(IE.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(IE.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=IE.call(arguments);return function(){for(var t=IE.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(yme&&e.forEach&&e.forEach===yme)e.forEach(t,i);else if(e.length===e.length+0){var n,r=void 0;for(r=0,n=e.length;r1?At.toArray(arguments):arguments[0];return At.each($ut,(function(t){if(t.litmus(e))return At.each(t.conversions,(function(t,i){if(DE=t.read(e),!1===n2&&!1!==DE)return n2=DE,DE.conversionName=i,DE.conversion=t,At.BREAK})),At.BREAK})),n2},xme=void 0,i2={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<<(xme=8*t)|e&~(255<-1?t.length-t.indexOf(".")-1:0}var Ime=function(e){function t(e,i,n){yc(this,t);var r=bf(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,At.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=bme(r.__impliedStep),r}return xf(t,ym),xc(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),yf(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=bme(e),this}}]),t}();function tht(e,t){var i=Math.pow(10,t);return Math.round(e*i)/i}var s2=function(e){function t(e,i,n){yc(this,t);var r=bf(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(){ot.unbind(window,"mousemove",l),ot.unbind(window,"mouseup",h),o()}return r.__input=document.createElement("input"),r.__input.setAttribute("type","text"),ot.bind(r.__input,"change",(function(){var e=parseFloat(a.__input.value);At.isNaN(e)||a.setValue(e)})),ot.bind(r.__input,"blur",(function(){o()})),ot.bind(r.__input,"mousedown",(function(e){ot.bind(window,"mousemove",l),ot.bind(window,"mouseup",h),s=e.clientY})),ot.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 xf(t,Ime),xc(t,[{key:"updateDisplay",value:function(){return this.__input.value=this.__truncationSuspended?this.getValue():tht(this.getValue(),this.__precision),yf(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"updateDisplay",this).call(this)}}]),t}();function Eme(e,t,i,n,r){return n+(e-t)/(i-t)*(r-n)}var d6=function(e){function t(e,i,n,r,a){yc(this,t);var s=bf(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(Eme(e.clientX,t.left,t.right,o.__min,o.__max)),!1}function h(){ot.unbind(window,"mousemove",l),ot.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(Eme(t,i.left,i.right,o.__min,o.__max))}function u(){ot.unbind(window,"touchmove",c),ot.unbind(window,"touchend",u),o.__onFinishChange&&o.__onFinishChange.call(o,o.getValue())}return s.__background=document.createElement("div"),s.__foreground=document.createElement("div"),ot.bind(s.__background,"mousedown",(function(e){document.activeElement.blur(),ot.bind(window,"mousemove",l),ot.bind(window,"mouseup",h),l(e)})),ot.bind(s.__background,"touchstart",(function(e){1===e.touches.length&&(ot.bind(window,"touchmove",c),ot.bind(window,"touchend",u),c(e))})),ot.addClass(s.__background,"slider"),ot.addClass(s.__foreground,"slider-fg"),s.updateDisplay(),s.__background.appendChild(s.__foreground),s.domElement.appendChild(s.__background),s}return xf(t,Ime),xc(t,[{key:"updateDisplay",value:function(){var e=(this.getValue()-this.__min)/(this.__max-this.__min);return this.__foreground.style.width=100*e+"%",yf(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"updateDisplay",this).call(this)}}]),t}(),Dme=function(e){function t(e,i,n){yc(this,t);var r=bf(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,ot.bind(r.__button,"click",(function(e){return e.preventDefault(),a.fire(),!1})),ot.addClass(r.__button,"button"),r.domElement.appendChild(r.__button),r}return xf(t,ym),xc(t,[{key:"fire",value:function(){this.__onChange&&this.__onChange.call(this),this.getValue().call(this.object),this.__onFinishChange&&this.__onFinishChange.call(this,this.getValue())}}]),t}(),f6=function(e){function t(e,i){yc(this,t);var n=bf(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,i));n.__color=new ws(n.getValue()),n.__temp=new ws(0);var r=n;n.domElement=document.createElement("div"),ot.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 ",ot.bind(n.__input,"keydown",(function(e){13===e.keyCode&&c.call(this)})),ot.bind(n.__input,"blur",c),ot.bind(n.__selector,"mousedown",(function(){ot.addClass(this,"drag").bind(window,"mouseup",(function(){ot.removeClass(r.__selector,"drag")}))})),ot.bind(n.__selector,"touchstart",(function(){ot.addClass(this,"drag").bind(window,"touchend",(function(){ot.removeClass(r.__selector,"drag")}))}));var a=document.createElement("div");function s(e){d(e),ot.bind(window,"mousemove",d),ot.bind(window,"touchmove",d),ot.bind(window,"mouseup",l),ot.bind(window,"touchend",l)}function o(e){p(e),ot.bind(window,"mousemove",p),ot.bind(window,"touchmove",p),ot.bind(window,"mouseup",h),ot.bind(window,"touchend",h)}function l(){ot.unbind(window,"mousemove",d),ot.unbind(window,"touchmove",d),ot.unbind(window,"mouseup",l),ot.unbind(window,"touchend",l),u()}function h(){ot.unbind(window,"mousemove",p),ot.unbind(window,"touchmove",p),ot.unbind(window,"mouseup",h),ot.unbind(window,"touchend",h),u()}function c(){var e=h6(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 At.extend(n.__selector.style,{width:"122px",height:"102px",padding:"3px",backgroundColor:"#222",boxShadow:"0px 1px 3px rgba(0,0,0,0.3)"}),At.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}),At.extend(n.__hue_knob.style,{position:"absolute",width:"15px",height:"2px",borderRight:"4px solid #fff",zIndex:1}),At.extend(n.__saturation_field.style,{width:"100px",height:"100px",border:"1px solid #555",marginRight:"3px",display:"inline-block",cursor:"pointer"}),At.extend(a.style,{width:"100%",height:"100%",background:"none"}),_me(a,"top","rgba(0,0,0,0)","#000"),At.extend(n.__hue_field.style,{width:"15px",height:"100px",border:"1px solid #555",cursor:"ns-resize",position:"absolute",top:"3px",right:"3px"}),rht(n.__hue_field),At.extend(n.__input.style,{outline:"none",textAlign:"center",color:"#fff",border:0,fontWeight:"bold",textShadow:n.__input_textShadow+"rgba(0,0,0,0.7)"}),ot.bind(n.__saturation_field,"mousedown",s),ot.bind(n.__saturation_field,"touchstart",s),ot.bind(n.__field_knob,"mousedown",s),ot.bind(n.__field_knob,"touchstart",s),ot.bind(n.__hue_field,"mousedown",o),ot.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 xf(t,ym),xc(t,[{key:"updateDisplay",value:function(){var e=h6(this.getValue());if(!1!==e){var t=!1;At.each(ws.COMPONENTS,(function(i){if(!At.isUndefined(e[i])&&!At.isUndefined(this.__color.__state[i])&&e[i]!==this.__color.__state[i])return t=!0,{}}),this),t&&At.extend(this.__color.__state,e)}At.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;At.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,_me(this.__saturation_field,"left","#fff",this.__temp.toHexString()),this.__input.value=this.__color.toString(),At.extend(this.__input.style,{backgroundColor:this.__color.toHexString(),color:"rgb("+i+","+i+","+i+")",textShadow:this.__input_textShadow+"rgba("+n+","+n+","+n+",.7)"})}}]),t}(),nht=["-moz-","-o-","-webkit-","-ms-",""];function _me(e,t,i,n){e.style.background="",At.each(nht,(function(r){e.style.cssText+="background: "+r+"linear-gradient("+t+", "+i+" 0%, "+n+" 100%); "}))}function rht(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 iht={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){}}},sht='
\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
',aht=function(e,t){var i=e[t];return At.isArray(arguments[2])||At.isObject(arguments[2])?new Qut(e,t,arguments[2]):At.isNumber(i)?At.isNumber(arguments[2])&&At.isNumber(arguments[3])?At.isNumber(arguments[4])?new d6(e,t,arguments[2],arguments[3],arguments[4]):new d6(e,t,arguments[2],arguments[3]):At.isNumber(arguments[4])?new s2(e,t,{min:arguments[2],max:arguments[3],step:arguments[4]}):new s2(e,t,{min:arguments[2],max:arguments[3]}):At.isString(i)?new eht(e,t):At.isFunction(i)?new Dme(e,t,""):At.isBoolean(i)?new Pme(e,t):null};function oht(e){setTimeout(e,1e3/60)}var lht=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||oht,cht=function(){function e(){yc(this,e),this.backgroundElement=document.createElement("div"),At.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"}),ot.makeFullscreen(this.backgroundElement),this.backgroundElement.style.position="fixed",this.domElement=document.createElement("div"),At.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;ot.bind(this.backgroundElement,"click",(function(){t.hide()}))}return xc(e,[{key:"show",value:function(){var e=this;this.backgroundElement.style.display="block",this.domElement.style.display="block",this.domElement.style.opacity=0,this.domElement.style.webkitTransform="scale(1.1)",this.layout(),At.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",ot.unbind(e.domElement,"webkitTransitionEnd",t),ot.unbind(e.domElement,"transitionend",t),ot.unbind(e.domElement,"oTransitionEnd",t)};ot.bind(this.domElement,"webkitTransitionEnd",t),ot.bind(this.domElement,"transitionend",t),ot.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-ot.getWidth(this.domElement)/2+"px",this.domElement.style.top=window.innerHeight/2-ot.getHeight(this.domElement)/2+"px"}}]),e}(),uht=Yut(".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");iht.inject(uht);var Tme="dg",wme=72,Sme=20,FE="Default",LE=function(){try{return!!window.localStorage}catch(e){return!1}}(),OE=void 0,Mme=!0,Xv=void 0,u6=!1,Lme=[],hi=function e(t){var i=this,n=t||{};this.domElement=document.createElement("div"),this.__ul=document.createElement("ul"),this.domElement.appendChild(this.__ul),ot.addClass(this.domElement,Tme),this.__folders={},this.__controllers=[],this.__rememberedObjects=[],this.__rememberedObjectIndecesToControllers=[],this.__listening=[],n=At.defaults(n,{closeOnTop:!1,autoPlace:!0,width:e.DEFAULT_WIDTH}),n=At.defaults(n,{resizable:n.autoPlace,hideable:n.autoPlace}),At.isUndefined(n.load)?n.load={preset:FE}:n.preset&&(n.load.preset=n.preset),At.isUndefined(n.parent)&&n.hideable&&Lme.push(this),n.resizable=At.isUndefined(n.parent)&&n.resizable,n.autoPlace&&At.isUndefined(n.scrollable)&&(n.scrollable=!0);var r,a=LE&&"true"===localStorage.getItem(Yv(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,pht(this),i.revert()}},width:{get:function(){return n.width},set:function(e){n.width=e,g6(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?ot.addClass(i.__ul,e.CLASS_CLOSED):ot.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){LE&&(a=e,e?ot.bind(window,"unload",s):ot.unbind(window,"unload",s),localStorage.setItem(Yv(i,"isLocal"),e))}}}),At.isUndefined(n.parent)){if(this.closed=n.closed||!1,ot.addClass(this.domElement,e.CLASS_MAIN),ot.makeSelectable(this.domElement,!1),LE&&a){i.useLocalStorage=!0;var l=localStorage.getItem(Yv(this,"gui"));l&&(n.load=JSON.parse(l))}this.__closeButton=document.createElement("div"),this.__closeButton.innerHTML=e.TEXT_CLOSED,ot.addClass(this.__closeButton,e.CLASS_CLOSE_BUTTON),n.closeOnTop?(ot.addClass(this.__closeButton,e.CLASS_CLOSE_TOP),this.domElement.insertBefore(this.__closeButton,this.domElement.childNodes[0])):(ot.addClass(this.__closeButton,e.CLASS_CLOSE_BOTTOM),this.domElement.appendChild(this.__closeButton)),ot.bind(this.__closeButton,"click",(function(){i.closed=!i.closed}))}else{void 0===n.closed&&(n.closed=!0);var h=document.createTextNode(n.name);ot.addClass(h,"controller-name"),o=x6(i,h),ot.addClass(this.__ul,e.CLASS_CLOSED),ot.addClass(o,"title"),ot.bind(o,"click",(function(e){return e.preventDefault(),i.closed=!i.closed,!1})),n.closed||(this.closed=!1)}n.autoPlace&&(At.isUndefined(n.parent)&&(Mme&&(Xv=document.createElement("div"),ot.addClass(Xv,Tme),ot.addClass(Xv,e.CLASS_AUTO_PLACE_CONTAINER),document.body.appendChild(Xv),Mme=!1),Xv.appendChild(this.domElement),ot.addClass(this.domElement,e.CLASS_AUTO_PLACE)),this.parent||g6(i,n.width)),this.__resizeHandler=function(){i.onResizeDebounced()},ot.bind(window,"resize",this.__resizeHandler),ot.bind(this.__ul,"webkitTransitionEnd",this.__resizeHandler),ot.bind(this.__ul,"transitionend",this.__resizeHandler),ot.bind(this.__ul,"oTransitionEnd",this.__resizeHandler),this.onResize(),n.resizable&&fht(this),s=function(){LE&&"true"===localStorage.getItem(Yv(i,"isLocal"))&&localStorage.setItem(Yv(i,"gui"),JSON.stringify(i.getSaveObject()))},this.saveToLocalStorageIfPossible=s,n.parent||((r=i.getRoot()).width+=1,At.defer((function(){r.width-=1})))};function x6(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 Rme(e){ot.unbind(window,"resize",e.__resizeHandler),e.saveToLocalStorageIfPossible&&ot.unbind(window,"unload",e.saveToLocalStorageIfPossible)}function p6(e,t){var i=e.__preset_select[e.__preset_select.selectedIndex];i.innerHTML=t?i.value+"*":i.value}function hht(e,t,i){if(i.__li=t,i.__gui=e,At.extend(i,{options:function(t){if(arguments.length>1){var n=i.__li.nextElementSibling;return i.remove(),kE(e,i.object,i.property,{before:n,factoryArgs:[At.toArray(arguments)]})}if(At.isArray(t)||At.isObject(t)){var r=i.__li.nextElementSibling;return i.remove(),kE(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 d6){var n=new s2(i.object,i.property,{min:i.__min,max:i.__max,step:i.__step});At.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)}})),ot.addClass(t,"has-slider"),i.domElement.insertBefore(n.domElement,i.domElement.firstElementChild)}else if(i instanceof s2){var r=function(t){if(At.isNumber(i.__min)&&At.isNumber(i.__max)){var n=i.__li.firstElementChild.firstElementChild.innerHTML,r=i.__gui.__listening.indexOf(i)>-1;i.remove();var a=kE(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=At.compose(r,i.min),i.max=At.compose(r,i.max)}else i instanceof Pme?(ot.bind(t,"click",(function(){ot.fakeEvent(i.__checkbox,"click")})),ot.bind(i.__checkbox,"click",(function(e){e.stopPropagation()}))):i instanceof Dme?(ot.bind(t,"click",(function(){ot.fakeEvent(i.__button,"click")})),ot.bind(t,"mouseover",(function(){ot.addClass(i.__button,"hover")})),ot.bind(t,"mouseout",(function(){ot.removeClass(i.__button,"hover")}))):i instanceof f6&&(ot.addClass(t,"color"),i.updateDisplay=At.compose((function(e){return t.style.borderLeftColor=i.__color.toString(),e}),i.updateDisplay),i.updateDisplay());i.setValue=At.compose((function(t){return e.getRoot().__preset_select&&i.isModified()&&p6(e.getRoot(),!0),t}),i.setValue)}function Ome(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[FE])return;s=a[FE]}if(s[n]&&void 0!==s[n][t.property]){var o=s[n][t.property];t.initialValue=o,t.setValue(o)}}}}function kE(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 f6(t,i);else{var a=[t,i].concat(n.factoryArgs);r=aht.apply(e,a)}n.before instanceof ym&&(n.before=n.before.__li),Ome(e,r),ot.addClass(r.domElement,"c");var s=document.createElement("span");ot.addClass(s,"property-name"),s.innerHTML=r.property;var o=document.createElement("div");o.appendChild(s),o.appendChild(r.domElement);var l=x6(e,o,n.before);return ot.addClass(l,hi.CLASS_CONTROLLER_ROW),r instanceof f6?ot.addClass(l,"color"):ot.addClass(l,Kut(r.getValue())),hht(e,l,r),e.__controllers.push(r),r}function Yv(e,t){return document.location.href+"."+t}function m6(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 Ame(e,t){t.style.display=e.useLocalStorage?"block":"none"}function dht(e){var t=e.__save_row=document.createElement("li");ot.addClass(e.domElement,"has-save"),e.__ul.insertBefore(t,e.__ul.firstChild),ot.addClass(t,"save-row");var i=document.createElement("span");i.innerHTML=" ",ot.addClass(i,"button gears");var n=document.createElement("span");n.innerHTML="Save",ot.addClass(n,"button"),ot.addClass(n,"save");var r=document.createElement("span");r.innerHTML="New",ot.addClass(r,"button"),ot.addClass(r,"save-as");var a=document.createElement("span");a.innerHTML="Revert",ot.addClass(a,"button"),ot.addClass(a,"revert");var s=e.__preset_select=document.createElement("select");if(e.load&&e.load.remembered?At.each(e.load.remembered,(function(t,i){m6(e,i,i===e.preset)})):m6(e,FE,!1),ot.bind(s,"change",(function(){for(var t=0;t0&&(e.preset=this.preset,e.remembered||(e.remembered={}),e.remembered[this.preset]=r2(this)),e.folders={},At.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]=r2(this),p6(this,!1),this.saveToLocalStorageIfPossible()},saveAs:function(e){this.load.remembered||(this.load.remembered={},this.load.remembered[FE]=r2(this,!0)),this.load.remembered[e]=r2(this),this.preset=e,m6(this,e,!0),this.saveToLocalStorageIfPossible()},revert:function(e){At.each(this.__controllers,(function(t){this.getRoot().load.remembered?Ome(e||this.getRoot(),t):t.setValue(t.initialValue),t.__onFinishChange&&t.__onFinishChange.call(t,t.getValue())}),this),At.each(this.__folders,(function(e){e.revert(e)})),e||p6(this.getRoot(),!1)},listen:function(e){var t=0===this.__listening.length;this.__listening.push(e),t&&kme(this.__listening)},updateDisplay:function(){At.each(this.__controllers,(function(e){e.updateDisplay()})),At.each(this.__folders,(function(e){e.updateDisplay()}))}});var Fme=hi,Nme=[["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"]],Ih=(()=>{if("undefined"==typeof document)return!1;let e=Nme[0],t={};for(let i of Nme)if((null==i?void 0:i[1])in document){for(let[n,r]of i.entries())t[e[n]]=r;return t}return!1})(),Bme={change:Ih.fullscreenchange,error:Ih.fullscreenerror},Io={request:(e=document.documentElement,t)=>new Promise(((i,n)=>{let r=()=>{Io.off("change",r),i()};Io.on("change",r);let a=e[Ih.requestFullscreen](t);a instanceof Promise&&a.then(r).catch(n)})),exit:()=>new Promise(((e,t)=>{if(!Io.isFullscreen)return void e();let i=()=>{Io.off("change",i),e()};Io.on("change",i);let n=document[Ih.exitFullscreen]();n instanceof Promise&&n.then(i).catch(t)})),toggle:(e,t)=>Io.isFullscreen?Io.exit():Io.request(e,t),onchange(e){Io.on("change",e)},onerror(e){Io.on("error",e)},on(e,t){let i=Bme[e];i&&document.addEventListener(i,t,!1)},off(e,t){let i=Bme[e];i&&document.removeEventListener(i,t,!1)},raw:Ih};Object.defineProperties(Io,{isFullscreen:{get:()=>Boolean(document[Ih.fullscreenElement])},element:{enumerable:!0,get:()=>{var e;return null!=(e=document[Ih.fullscreenElement])?e:void 0}},isEnabled:{enumerable:!0,get:()=>Boolean(document[Ih.fullscreenEnabled])}}),Ih||(Io={isEnabled:!1});var a2=Io,o2=new P,l2=class{constructor(e,t,i=void 0){this.scale=1,this.explodeUp=!1,this.scene=e,this.objectId=t,t||J.debug(`[EXP] Invalid objectId: ${t}`),i?this.explodeCenter=i:(this.explodeCenter=new P,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 J.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?(J.debug(`[EXP] Exploding object '${t.name}'(id: ${t.id}) at: ${ft.vectorToString(this.explodeCenter)}`),this.explodeObject(t)):J.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(),o2.set(0,0,0),null==(t=i.geometry.boundingBox)||t.getCenter(o2),o2.applyMatrix4(i.matrixWorld),i.userData.originalCenter=o2.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 qe;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?(J.debug(`[EXP] Unexploding '${e.name}'(id: ${e.id}) at: ${ft.vectorToString(this.explodeCenter)}`),this.unexplodeObject(e)):J.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 bt;if(!this.objectId)return void J.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)):J.debug("[EXP] No children to explode!")}},c2=class extends Tr{constructor(e,t){super(e,{id:"ExplodePlugin"}),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.objectId))return;let t=new P;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 l2(this.scene,e.objectId,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()}},u2=class extends Tr{constructor(e,t){super(e,{id:"GroundGrassPlugin"}),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 P,o=this.viewer.getBBox();o&&o.getCenter(s),nt(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 nt(this,null,(function*(){return new Promise((a=>{(new rs).load(e,(e=>{e.wrapS=e.wrapT=li,e.repeat.set(n,r),e.anisotropy=16,e.encoding=Vc;let s=new $c({map:e});s.side=Xr;let o=new ht(new zr(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)}},h2=class extends Tr{constructor(e,t){super(e,{id:"GroundGridPlugin"}),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 P,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 Nx(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)}},d2=class extends Tr{constructor(e,t){super(e,{id:"ScreenshotPlugin"}),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)}getScreenshotAsync(){return nt(this,arguments,(function*(e="BoxSelection"){var t;this.cancel();let i,n="image/png",r=this.viewer,a=null==(t=r.renderer)?void 0:t.domElement;if(!a||!r.viewerContainer||!r.camera)return;if("PickMarkup"===e?(this.pickMarkupHelper||(this.pickMarkupHelper=new lC(r)),i=yield this.pickMarkupHelper.pick()):"BoxSelection"===e&&(this.boxSelectHelper||(this.boxSelectHelper=new hf(r)),i=yield this.boxSelectHelper.select()),"Default"!==e&&!i)return;let s=yield ft.canvasToImage(a),o=document.createElement("canvas");o.width=a.width,o.height=a.height;let l=window.devicePixelRatio,h=o.getContext("2d");if(h.drawImage(s,0,0,s.width/l,s.height/l),r.overlayRender){let e=yield r.overlayRender.getImage((e=>e instanceof pr||e instanceof ri));h.drawImage(e,0,0,e.width/l,e.height/l)}let c=ft.renderingContextToImage(h,i,n,.8);return r instanceof ff?{base64Image:c,viewExtent:r.getCurrentViewExtent(),imageType:n}:{base64Image:c,imageType:n}}))}isActive(){var e,t;return(null==(e=this.boxSelectHelper)?void 0:e.isActived)||(null==(t=this.pickMarkupHelper)?void 0:t.isActived)}cancel(){var e,t;null!=(e=this.boxSelectHelper)&&e.isActived&&this.boxSelectHelper.deactivate(),null!=(t=this.pickMarkupHelper)&&t.isActived&&this.pickMarkupHelper.deactivate()}},Ef=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?J.error("[Uploader] No files to be uploaded!"):this.uploadFiles(t)}}formats(){return J.warn("[Uploader]: Should call derived class instead!"),[]}uploadFiles(e){J.warn(`[Uploader]: Should call derived class instead! files: ${e}`)}openFileBrowserToUpload(){this.input.click()}},f2=class extends Ef{constructor(e,t){super(t),this.defaultModelConfig={src:"",merge:!1},this.viewer=e}formats(){return["gltf","glb","dxf","obj","stl","fbx","ifc","dae","*"]}uploadFiles(e){let t=e.length;if(0===t)return;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=Ps.extractUrlBase(i);n=new Zc,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);J.info(`[Uploader] Loading ${null==r?void 0:r.name}, ${t}%`)})).then((()=>{J.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);J.info(`[Uploader] Loading ${null==e?void 0:e.name}, ${i}%`)}))}};function Hme(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 Ume=class extends Tr{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..."),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 Fme({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 h2(e)})),n.add(i,"showGroundGrass").name("Show ground grass").onChange((t=>{let i=e.findPlugin("GroundGrassPlugin");i?i.setVisible(t):i=new u2(e)})),n.add(i,"environments",i.environments).name("Environments").onChange((i=>{let n="";if("Default (City Streat 64x32)"===i){if(e.pmremGenerator)return rc.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}`,rc.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 P,a=new P,s=fs.getVisibleObjectBoundingBox(t),o=cb.getCameraDirectionByView(i);cb.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 d2(e));let i=t.getScreenshot(),n=document.createElement("a");n.href=i,n.download="",n.click()})),n.add(i,"fullScreen").name("Full screen").onChange((()=>{a2&&a2.isEnabled&&a2.request(),e.enableRender()})),n.add(i,"uploadFile").name("Upload file").onChange((()=>{new f2(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 c2(e)),i.explode(t)})),r.add(i,"sectionMode",i.sectionMode).name("Section mode").onChange((t=>{let i=e.findPlugin("SectionPlugin");i||(i=new $C(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 Ye(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 Ye(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()};Hme(t,"position",o.position,n),Hme(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 Ye(t)),e.enableRender()})),h.addColor(i,"hlGroundColor").name("groundColor").onChange((t=>{l&&(l.groundColor=new Ye(t)),e.enableRender()}));let c=this.gui.addFolder("Fog");c.add(i,"fogEnabled",i.fogEnabled).name("Enabled").onChange((n=>{t.fog=n?new qc(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 qc(i.fogColor,n,i.fogFarDistance)),e.enableRender()})),c.add(i,"fogFarDistance",100,2e3).name("Far").onChange((n=>{i.fogEnabled&&t&&(t.fog=new qc(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}},Vme=class extends Tr{constructor(e,t){super(e,{id:"LayerManagerPlugin"}),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;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.hide),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"),this.headerText=document.createElement("span"),this.headerText.innerHTML="Layers",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 `}addEventHandlers(){var e;null==(e=this.closeBtn)||e.addEventListener("click",this.hide.bind(this))}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.initMaterial(),this.initRenderTarget(),this.createGroundShadowByBBox(e,t)},this.onShadowRender=()=>{var e,t,i,n,r;this.shouldUpdateShadow()&&(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.cfg=t,this.viewer.addEventListener("ModelLoaded",this.onModelLoaded),this.viewer.addEventListener("BeforeRender",this.onShadowRender)}get scene(){return this.viewer.scene}get renderer(){return this.viewer.renderer}shouldUpdateShadow(){let e=!1,t=this.viewer.loadedModels.length;return this.modelCount!==t&&(this.modelCount=t,e=!0),e}initMaterial(){this.depthMaterial=new Kl,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\t\t\t\t\t\tuniform float darkness;\n\t\t\t\t\t\t${e.fragmentShader.replace("gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );","gl_FragColor = vec4( vec3( 0.0 ), ( 1.0 - fragCoordZ ) * darkness );")}\n\t\t\t\t\t`},this.depthMaterial.depthTest=!1,this.depthMaterial.depthWrite=!1,this.horizontalBlurMaterial=new Yt(zme),this.horizontalBlurMaterial.depthTest=!1,this.verticalBlurMaterial=new Yt(Gme),this.verticalBlurMaterial.depthTest=!1}initRenderTarget(){this.renderTarget=new Vn(128,128),this.renderTarget.texture.generateMipmaps=!1,this.renderTargetBlur=new Vn(128,128),this.renderTargetBlur.texture.generateMipmaps=!1}createGroundShadowByBBox(e,t){var i,n,r;this.shadowGroup=new Ln,this.shadowGroup.name=`${e}-ground-shadow`,Sn.disableLayerChannels(this.shadowGroup,[12,11]),null==(i=this.scene)||i.add(this.shadowGroup);let{min:a,max:s}=t,o=new P;t.getSize(o),o.multiplyScalar(2);let l=new P;t.getCenter(l);let h=new zr(o.x,o.z).rotateX(Math.PI/2),c=new jt({map:null==(n=this.renderTarget)?void 0:n.texture,transparent:!0,depthWrite:!1}),u=new ht(h,c);u.renderOrder=1,u.position.set(l.x,a.y,l.z),u.scale.y=-1,null==(r=this.shadowGroup)||r.add(u),this.shadowCamera=new Er(-o.x/2,o.x/2,o.z/2,-o.z/2,-o.y/2,o.y),this.shadowCamera.position.set(l.x,a.y,l.z),this.shadowCamera.lookAt(l.x,s.y,l.z),this.shadowGroup.add(this.shadowCamera),this.blurPlane=new ht(h),this.blurPlane.position.set(l.x,a.y,l.z),this.blurPlane.visible=!1,this.shadowGroup.add(this.blurPlane)}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}},jme=class extends Tr{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 J.warn(`[Hotpoint] Hotpoint with id '${e.hotpointId}' already exist!`);let i=e.anchorPosition,n=zd.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 Ln,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}))}},ii=Xi(Sge(),1),X6={Fill:"Fill",Stroke:"Stroke",Shading:"Shading"},t1={Fill:0,Stroke:1,FillStroke:2,Invisible:3,FillAddToPath:4,StrokeAddToPath:5,FillStrokeAddToPath:6,AddToPath:7,FillStrokeMask:3,AddToPathFlag:4},Mge=16,Rge=100,Y6=[1,0,0,1,0,0],$6=[.001,0,0,.001,0,0],ght=["butt","round","square"],vht=["miter","round","bevel"],yht={},Age={},_2=class extends er{constructor(e){if(super(),this.contentVisible=!0,this.markedContentStack=[],this.stateStack=[],this.current=new zE(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 qe,this.currentTransform=new qe,this.transformStack=[],void 0===ii)throw"[PdfLoader] need load pdf.js first";this.font=e.font,ii.GlobalWorkerOptions.workerSrc=e.pdfWorker}load(e,t,i,n){let{src:r,merge:a}=e,s=e.modelId||r,o=ii.getDocument(r);o.onProgress=i,o.promise.then((e=>{J.log("PDF loaded"),this.pdfDocumentGroup=new Ln,this.pdfDocumentGroup.name=`PdfDocument-${s}`,e.getPage(1).then((i=>{var n;J.log("Page loaded"),J.log(i),this.pdfPage=i,this.commonObjs=e._transport.commonObjs,this.objs=i.objs,this.pdfPageGroup=new Ln,this.pdfPageGroup.name=_2.MODEL_LAYOUT_NAME,null==(n=this.pdfDocumentGroup)||n.add(this.pdfPageGroup);let r=()=>{let e=i.view,n=8192/Math.max(e[2]-e[0],e[3]-e[1]),r=Math.min(300/72,n),o=i.getViewport({scale:r});this.beginDrawing(o),this.current=new zE(o.width,o.height),this.buildLayers(i),i.getOperatorList().then((e=>{this.operatorList=e,this.executeOperatorList(this.operatorList),this.operatorList.argsArray.length&&(this.endDrawing(),J.log("[PdfLoader] pdf endDrawing"),a&&Pr.merge(this.pdfDocumentGroup),t({modelId:s,pdfData:{threejsObject:this.pdfDocumentGroup,layers:this.layers,layersAndThreejsObjects:this.layersAndThreejsObjects,loadedEntityCount:this.loadedEntityCount}}))}))};this.font instanceof ki?this.font.getFontData().then((()=>{J.log("[PdfLoader] Font loaded."),r()})):r()}))}),(function(e){n&&n(e)}))}loadAsync(e,t){return nt(this,null,(function*(){let i=ft.getUpdateProgressFunc(t),n=ft.getUpdateSubProgressFunc(0,10,t),r=ft.getUpdateSubProgressFunc(30,90,t);i(0);let{src:a,merge:s}=e,o=e.modelId||a,l=Date.now(),h=ii.getDocument(a);h.onProgress=n;let c=yield h.promise;this.pdf=c,J.info(`[PdfLoader] Pdf document loaded in ${(Date.now()-l)/1e3}s`),l=Date.now(),J.log(c),this.pdfDocumentGroup=new Ln,this.pdfDocumentGroup.name=`PdfDocument-${o}`,this.optionalContentConfig=yield c.getOptionalContentConfig(),c.numPages>1&&J.info("[PdfLoader] Only the first page can be render others will be ignore.");let u=yield c.getPage(1);i(20),J.info(`[PdfLoader] Pdf page loaded in ${(Date.now()-l)/1e3}s`),l=Date.now(),J.log(u),this.pdfPage=u,this.pdfPageGroup=new Ln,this.pdfPageGroup.name=_2.MODEL_LAYOUT_NAME,this.pdfDocumentGroup.add(this.pdfPageGroup),this.commonObjs=c._transport.commonObjs,this.objs=u.objs,this.font instanceof ki&&(yield this.font.getFontData(),J.log("[PdfLoader] Font loaded."));let d=u.view,p=8192/Math.max(d[2]-d[0],d[3]-d[1]),f=Math.min(300/72,p),m=u.getViewport({scale:f});return this.beginDrawing(m),this.current=new zE(m.width,m.height),this.buildLayers(u),this.operatorList=yield u.getOperatorList(),i(30),yield this.executeOperatorList(this.operatorList,r),this.operatorList.argsArray.length&&(J.info(`[PdfLoader] Pdf page add to scene loaded in ${(Date.now()-l)/1e3}s`),this.endDrawing(),J.log("[PdfLoader] pdf endDrawing"),s&&Pr.merge(this.pdfPageGroup)),i(100),{modelId:o,pdfData:{threejsObject:this.pdfDocumentGroup,layers:this.layers||[],layersAndThreejsObjects:this.layersAndThreejsObjects,loadedEntityCount:this.loadedEntityCount}}}))}createTextMeshByText(e,t=12){let i;if(this.font instanceof ki){let n=this.font.getGraphicDataByChar(e,t);n&&(i=n.toThreeGeometry())}else if(this.font instanceof Co){let n={font:this.font,height:0,size:t||12,curveSegments:3,bevelSegments:3};i=new sm(e,n)}return i}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;J.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(gn.degToRad(-e.rotation));let{width:c,height:u}=e,d=(new Et).setFromPoints([new P(0,0,0),new P(c,0,0),new P(c,u,0),new P(0,0,0),new P(c,u,0),new P(0,u,0)]),p=new jt({color:16777215}),f=new ht(d,p);f.renderOrder=-999,null==(n=this.pdfDocumentGroup)||n.add(f)}endDrawing(){}buildLayers(e){return nt(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&&J.warn("[PdfLoader] Line width not supported now.")}setLineCap(e){J.log("setLineCap",ght[e])}setLineJoin(e){J.log("setLineJoin",vht[e])}setMiterLimit(e){J.log("setMiterLimit",e)}setDash(e,t){J.log("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(){J.log("[PdfLoader] ================save");let e=this.current;this.transformStack.push(this.currentTransform.clone()),this.stateStack.push(e),this.current=e.clone(),this.currentPath||(this.currentPath=new us)}restore(){J.log("[PdfLoader] ================restore"),0!==this.stateStack.length&&(this.current=this.stateStack.pop()),0!==this.transformStack.length&&this.currentTransform.copy(this.transformStack.pop()),this.pendingClip=null}transform(e,t,i,n,r,a){let s=new qe(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(){var e;null==(e=this.currentPath)||e.closePath()}rectangle(){}stroke(e=!0){if(!this.currentPath||!this.contentVisible)return;let t=(new Et).setFromPoints(this.currentPath.getPoints());t.applyMatrix4(this.currentTransform);let i=this.current.strokeColor,n=this.current.strokeAlpha,r=new En({color:i,transparent:!0,opacity:n}),a=new Wn(t,r);this.addObjectToModel(a),e&&this.consumePath(this.current.getClippedPathBoundingBox())}closeStroke(){this.closePath(),this.stroke()}fill(e=!0){if(!this.currentPath)return;let t=this.current.getClippedPathBoundingBox();if(this.contentVisible&&null!==t){this.pendingEOFill&&(this.pendingEOFill=!1,J.warn("[PdfLoader] Fill evenodd not supported now.")),this.currentPath.closePath();let e=new Jl(this.currentPath);e.applyMatrix4(this.currentTransform);let t=this.current.fillColor,i=new jt({color:t,side:or,transparent:!0}),n=new ht(e,i);this.addObjectToModel(n)}e&&this.consumePath(t)}eoFill(){this.pendingEOFill=!0,this.fill()}fillStroke(){this.fill(!1),this.stroke(!1),this.consumePath()}eoFillStroke(){this.pendingEOFill=!0,this.fillStroke()}closeFillStroke(){J.log("closeFillStroke"),this.closePath(),this.fillStroke()}closeEOFillStroke(){J.log("closeEOFillStroke"),this.pendingEOFill=!0,this.closePath(),this.fillStroke()}endPath(){this.consumePath()}clip(){this.pendingClip=yht}eoClip(){this.pendingClip=Age}beginText(){this.current.textMatrix=Y6,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}endText(){this.currentPath=new us}setCharSpacing(e){this.current.charSpacing=e}setWordSpacing(e){this.current.wordSpacing=e}setHScale(e){this.current.textHScale=e/100}setLeading(e){this.current.leading=-e}setFont(e,t){var i;let n=this.commonObjs.get(e),r=this.current;if(!n)throw new Error(`Can't find font for ${e}`);if(r.fontMatrix=n.fontMatrix||$6,(0===r.fontMatrix[0]||0===r.fontMatrix[3])&&J.warn("Invalid font matrix for font "+e),t<0?(t=-t,r.fontDirection=-1):r.fontDirection=1,this.current.font=n,this.current.fontSize=t,n.isType3Font)return;let a=n.loadedName||"sans-serif",s=(null==(i=n.systemFontInfo)?void 0:i.css)||`"${a}", ${n.fallbackName}`,o="normal";n.black?o="900":n.bold&&(o="bold");let l=n.italic?"italic":"normal",h=t;tRge&&(h=Rge),this.current.fontSizeScale=t/h,this.current.browserFontSize=h,J.log(`[PdfLoader] font: ${l} ${o} ${h}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(){}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){J.log("paintChar",e,t,i,n)}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=t.fontSizeScale,a=t.charSpacing,s=t.wordSpacing,o=t.fontDirection,l=t.textHScale*o,h=e.length,c=i.vertical,u=c?1:-1,d=i.defaultVMetrics,p=n*t.fontMatrix[0],f=t.textRenderingMode===t1.Fill&&!i.disableFontFace&&!t.patternFill;this.baseTransform.copy(this.currentTransform);let m=this.currentTransform.clone(),[g,v,y,x,b,_]=t.textMatrix;m.multiply(new qe(g,y,0,b,v,x,0,_,0,0,1,0,0,0,0,1)),m.multiply((new qe).makeTranslation(t.x,t.y+t.textRise,0)),o>0?m.scale(new P(l,1,1)):m.scale(new P(l,-1,1));let w=t.lineWidth,M=t.textMatrixScale;0===M||0===w?(t.textRenderingMode&t1.FillStrokeMask)===t1.Stroke||t1.FillStroke:w/=M,1!==r&&(m.scale(new P(r,r,1)),w/=r);let S,E=0,T=[];for(S=0;S0){let e,t=$i(T);this.font instanceof ki?e=new Ar(t,new En({color:this.current.fillColor,transparent:!0})):this.font instanceof Co&&(e=new ht(t,new jt({color:this.current.fillColor,transparent:!0}))),e&&(this.addObjectToModel(e),e.layers.disable(11))}c?t.y-=E:t.x+=E*l,this.currentTransform.copy(this.baseTransform)}showType3Text(e){}setCharWidth(e,t){}setCharWidthAndBounds(e,t,i,n,r,a){}setStrokeColor(){}setStrokeColorN(){}setFillColorN(){}setStrokeRGBColor(e,t,i){this.current.strokeColor=new Ye(e/255,t/255,i/255)}setFillRGBColor(e,t,i){this.current.fillColor=new Ye(e/255,t/255,i/255),this.current.patternFill=!1}shadingFill(){}beginInlineImage(){}beginImageData(){}markPoint(e){}markPointProps(e,t){}beginMarkedContent(e){J.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,this.pendingClip=null),this.current.startNewPathAndClipBox(this.current.clipBox),this.currentPath=new us}paintFormXObjectBegin(e,t){J.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):J.warn("Dependent image isn't ready yet")}paintInlineImageXObject(e){if(!this.contentVisible)return;J.log("paintInlineImageXObject",e),this.save();let{bitmap:t,width:i,height:n}=e;this.currentTransform.multiply((new qe).makeScale(1/i,-1/n,1));let r=new wx(t),a=new jt({map:r,transparent:!0}),s=new zr(i,n),o=new ht(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){if(!this.currentPath)return;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}},wu=_2;wu.MODEL_LAYOUT_NAME="Model";for(let t in ii.OPS)void 0!==wu.prototype[t]&&(wu.prototype[ii.OPS[t]]=wu.prototype[t]);var zE=class{constructor(e,t){this.textMatrix=Y6,this.fontMatrix=$6,this.textRenderingMode=t1.Fill,this.fillColor=new Ye("#000000"),this.strokeColor=new Ye("#000000"),this.activeSMask=null,this.alphaIsShape=!1,this.fontSize=0,this.fontSizeScale=1,this.browserFontSize=1,this.textMatrix=Y6,this.textMatrixScale=1,this.fontMatrix=$6,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=t1.Fill,this.textRise=0,this.fillColor=new Ye("#000000"),this.strokeColor=new Ye("#000000"),this.patternFill=!1,this.fillAlpha=1,this.strokeAlpha=1,this.lineWidth=1,this.activeSMask=null,this.transferMaps="none",this.ctxMatrix=new pn,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]=ii.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=X6.Fill,t=null){let i=[this.minX,this.minY,this.maxX,this.maxY];if(e===X6.Stroke){if(!t)throw new Error("Stroke bounding box must include transform.");let e=ii.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=ii.Util.applyTransform(t,e),n=ii.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){ii.Util.scaleMinMax(e,t),this.minX=Math.min(this.minX,t[0]),this.maxX=Math.max(this.maxX,t[1]),this.minY=Math.min(this.minY,t[2]),this.maxY=Math.max(this.maxY,t[3])}updateCurvePathMinMax(e,t,i,n,r,a,s,o,l,h){let c=ii.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=ii.Util.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(e||[0,0,0,0])}isEmptyClip(){return this.minX===1/0}getClippedPathBoundingBox(e=X6.Fill,t=null){return ii.Util.intersect(this.clipBox,this.getPathBoundingBox(e,t))||[]}},Cge=class extends Tr{constructor(e,t){super(e,{id:"PdfLoaderPlugin"}),this.cfg=t||{}}loadAsync(e,t){return nt(this,null,(function*(){let i=this.viewer;i.increaseJobCount();let n=this.cfg.font,r=this.cfg.pdfWorker,a=yield new wu({font:n,pdfWorker:r}).loadAsync(e,t);return i.decreaseJobCount(),a}))}},Pge=class extends Ef{constructor(e,t){super(t),this.defaultModelConfig={src:"",merge:!0},this.viewer=e}formats(){return["dxf","pdf"]}uploadFiles(e){for(let t=0;t{let i=Math.floor(100*t.loaded/t.total);J.info(`[Uploader] Loading ${null==e?void 0:e.name}, ${i}%`)}))}))}uploadSinglePdf(e){return nt(this,null,(function*(){let t=t=>{let i=Math.floor(100*t.loaded/t.total);J.info(`[Uploader] Loading ${null==e?void 0:e.name}, ${i}%`)};try{let i=this.viewer;i.increaseJobCount();let n={font:i.font,pdfWorker:"libs/pdf/pdf.worker.min.js"},r={src:URL.createObjectURL(e),modelId:e.name};new wu(n).loadAsync(r,t).then((e=>{this.viewer.addModel(e),this.onSuccess&&this.onSuccess({}),i.decreaseJobCount(),J.info(`[Uploader] Loaded model '${r.src}'`)}))}catch(e){J.info(e)}}))}},Ige=class extends Ef{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 P(e,t,i),rotation:new Dn(n,r,a)}),xht={Front:ai(qn({},Ss([0,0,1],[0,0,0])),{label:"NavCube.front"}),Right:ai(qn({},Ss([1,0,0],[0,$r,0])),{label:"NavCube.right"}),Back:ai(qn({},Ss([0,0,-1],[0,Math.PI,0])),{label:"NavCube.back"}),Left:ai(qn({},Ss([-1,0,0],[0,-$r,0])),{label:"NavCube.left"}),Top:ai(qn({},Ss([0,1,0],[-$r,0,0])),{label:"NavCube.top"}),Bottom:ai(qn({},Ss([0,-1,0],[$r,0,0])),{label:"NavCube.bottom"})},bht=[Ss([0,1,1],[-wr,0,-$r]),Ss([0,1,-1],[-3*wr,0,-$r]),Ss([0,-1,1],[wr,0,-$r]),Ss([0,-1,-1],[3*wr,0,-$r]),Ss([1,1,0],[-$r,wr,0]),Ss([1,-1,0],[-$r,3*wr,0]),Ss([-1,1,0],[-$r,-wr,0]),Ss([-1,-1,0],[-$r,-3*wr,0]),Ss([1,0,1],[0,wr,0]),Ss([1,0,-1],[0,3*wr,0]),Ss([-1,0,1],[0,-wr,0]),Ss([-1,0,-1],[0,-3*wr,0])],Eht=[{position:new P(1,1,1),rotation:[new Dn(-$r,$r,-wr),new Dn(-$r,0,wr),new Dn(0,0,3*wr)]},{position:new P(1,1,-1),rotation:[new Dn(0,$r,3*wr),new Dn(-$r,0,3*wr),new Dn(0,Math.PI,-3*wr)]},{position:new P(-1,1,-1),rotation:[new Dn(Math.PI,-$r,wr),new Dn(-$r,0,-3*wr),new Dn(0,Math.PI,3*wr)]},{position:new P(-1,1,1),rotation:[new Dn(0,-$r,3*wr),new Dn(-$r,0,-wr),new Dn(0,0,-3*wr)]},{position:new P(1,-1,1),rotation:[new Dn(0,$r,-wr),new Dn(-$r,Math.PI,-wr),new Dn(0,0,wr)]},{position:new P(1,-1,-1),rotation:[new Dn(-$r,$r,3*wr),new Dn($r,0,wr),new Dn(0,Math.PI,-wr)]},{position:new P(-1,-1,1),rotation:[new Dn(0,-$r,wr),new Dn($r,0,-3*wr),new Dn(0,0,-wr)]},{position:new P(-1,-1,-1),rotation:[new Dn(0,-$r,-wr),new Dn($r,0,-wr),new Dn(0,Math.PI,wr)]}],T2=class extends Xt{constructor(e={}){super(),this.NAVCUBE_SIZE=100,this.clickHandler=e.onClick,(0,bm.forEach)(xht,(e=>{this.createPlane(e)})),(0,bm.forEach)(bht,(e=>{this.createEdge(e)})),(0,bm.forEach)(Eht,((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=vu(n),a.classList.add("navcube-plane"),a.classList.add("inner"),r.appendChild(a);let s=new vm(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=Dge,i.classList.add("navcube-edge");let n=new vm(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 Dn)})),i.addEventListener("mouseenter",(()=>{let e=document.getElementsByClassName("group-"+t);(0,bm.forEach)(e,(e=>{e instanceof HTMLElement&&e.classList.add("highlight")}))})),i.addEventListener("mouseleave",(()=>{let e=document.getElementsByClassName("group-"+t);(0,bm.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 vm(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 Dn).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 ${Dge}`,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 vm(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,bm.forEach)(e.rotation,((e,i)=>{l(e,t,i)})),i(r)}},Lge=class extends Tr{constructor(e,t){super(e,{id:"NavCubePlugin"}),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 ZC,this.renderer.setSize(i,n),this.renderer.domElement.classList.add("css3d-navcube"),t.appendChild(this.renderer.domElement)}initScene(){this.scene=new ti;let e=window.innerWidth/window.innerHeight;this.camera=new Er(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 T2({onClick:e=>{let t=this.viewer.controls;if(!(this.camera&&e&&this.viewer.camera&&t))return;let i=t instanceof Ws?t.getTarget(new P):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 P;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)}},GE=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}};GE.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 Oge=GE,kge=class extends Tr{constructor(e){super(e,{id:"StatsPlugin"}),this.init()}init(){var e;let t=new Oge;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}},qE=class extends ht{constructor(e,t,i,n=4e3,r=32,a=15,s=new P,o=new P(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 P},sunDirection:{value:o.normalize()}};this.geometry=new da(n,r,a),this.material=new Yt({uniforms:l,vertexShader:qE.vertexShader,fragmentShader:qE.fragmentShader,side:Ci}),this.name=qE.NAME,this.matrixAutoUpdate=!1,this.layers.disable(12)}},Do=qE;Do.NAME="SKYBOX",Do.MIN_SKY_RADIUS=4e3,Do.MAX_SKY_RADIUS=2e4,Do.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 }",Do.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 Fge=class extends Tr{constructor(e,t){super(e,{id:"SkyboxPlugin"}),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&&ft.arrayToVector3(i.eye),n=i&&ft.arrayToVector3(i.look),r=new bt;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 Do(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 Lx;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));tDo.MAX_SKY_RADIUS&&(t=Do.MAX_SKY_RADIUS),this.gradientColorSkybox.geometry=new da(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 Ye;return r.setRGB(t,i,n),r}};function _ht(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}var Tht=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}),w2=class extends Rr{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 P,t=new fe,i=new P,n=new P,r=new fe;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(gn.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=qn(qn({},Tht),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 _ht(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 gn.ceilPowerOfTwo(this.width*this.pixelRatio)}getDrawingBufferHeight(){return gn.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=qn(qn({},this.cfg),e),this.needsRedraw=!0}};function K6(e,t,i){let n=new Ye(e),r=new Ye(t);return n.lerp(r,i).getHex()}var gr=(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))(gr||{}),Su=new P(1,0,0),Js=new P(0,1,0),ss=new P(0,0,1),Nge={right:{text:"\u53f3",name:"RightFace",position:new P(50,0,0),rotation:{axis:Js,rad:gr.Rotate90}},left:{text:"\u5de6",name:"LeftFace",position:new P(-50,0,0),rotation:{axis:Js,rad:gr.Rotate270}},top:{text:"\u4e0a",name:"TopFace",position:new P(0,50,0),rotation:{axis:Su,rad:gr.Rotate270}},bottom:{text:"\u4e0b",name:"BottomFace",position:new P(0,-50,0),rotation:{axis:Su,rad:gr.Rotate90}},front:{text:"\u524d",name:"FrontFace",position:new P(0,0,50),rotation:{axis:Js,rad:0}},back:{text:"\u540e",name:"BackFace",position:new P(0,0,-50),rotation:{axis:Js,rad:gr.Rotate180}}},S2=class extends Xt{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 fe(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 Xt,t=new P(-50,-50,-50),i=new P(1,0,0),n=new P(0,1,0),r=new P(0,0,1),a=this.AXIS_LENGTH/15,s=this.AXIS_LENGTH/20,o=new ec(i,t,this.AXIS_LENGTH,this.AXIS_COLOR_X,a,s),l=new ec(n,t,this.AXIS_LENGTH,this.AXIS_COLOR_Y,a,s),h=new ec(r,t,this.AXIS_LENGTH,this.AXIS_COLOR_Z,a,s);return e.add(o,l,h),e}createViewCubeFaces(){let e=new Xt,t=[],i=new jt({color:this.FACE_BACKGROUND_COLOR,opacity:0,transparent:!0});Object.keys(Nge).forEach((e=>{let n=Nge[e],r=new w2({text:n.text,fontSize:100,color:"#cccccc",backgroundColor:this.FACE_BACKGROUND_COLOR,padding:.8,fontWeight:"bold"});r.redrew();let a=new jt({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 Gs(76,76,76),r=new ht(n,t);this.innerViewCubeMesh=r,e.add(r);let a=new Yc(new Gs(100,100,100)),s=new jt({color:this.lineColor}),o=new Ar(a,s);return e.add(o),e.position.set(0,0,0),e}createViewCubeFace(e,t,i,n){let r=new zr(76,76),a=new ht(r,t);return a.name=e,a.rotateOnAxis(n.axis,n.rad),a.position.copy(i),a}createViewCubeEdges(){let e=new Xt,t=this.createEdge("TopFrontEdge",new P(0,51,51),[{axis:ss,rad:gr.Rotate180}]),i=this.createEdge("TopRightEdge",new P(51,51,0),[{axis:Su,rad:gr.Rotate180},{axis:Js,rad:gr.Rotate90},{axis:ss,rad:0}]),n=this.createEdge("TopBackEdge",new P(0,51,-51),[{axis:ss,rad:gr.Rotate180},{axis:Js,rad:gr.Rotate180}]),r=this.createEdge("TopLeftEdge",new P(-51,51,0),[{axis:Su,rad:gr.Rotate90},{axis:Js,rad:gr.Rotate180},{axis:ss,rad:gr.Rotate90}]),a=this.createEdge("BottomFrontEdge",new P(0,-51,51),[{axis:ss,rad:0}]),s=this.createEdge("BottomRightEdge",new P(51,-51,0),[{axis:Su,rad:gr.Rotate90},{axis:Js,rad:0},{axis:ss,rad:gr.Rotate90}]),o=this.createEdge("BottomBackEdge",new P(0,-51,-51),[{axis:ss,rad:0},{axis:Js,rad:gr.Rotate180}]),l=this.createEdge("BottomLeftEdge",new P(-51,-51,0),[{axis:Su,rad:gr.Rotate90},{axis:Js,rad:gr.Rotate270},{axis:ss,rad:gr.Rotate90}]),h=this.createEdge("FrontRightEdge",new P(51,0,51),[{axis:ss,rad:gr.Rotate90}]),c=this.createEdge("BackRightEdge",new P(51,0,-51),[{axis:ss,rad:gr.Rotate90},{axis:Js,rad:gr.Rotate180}]),u=this.createEdge("BackLeftEdge",new P(-51,0,-51),[{axis:ss,rad:gr.Rotate270},{axis:Js,rad:gr.Rotate180}]),d=this.createEdge("FrontLeftEdge",new P(-51,0,51),[{axis:ss,rad:gr.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 Xt,r=new zr(this.EDGE_SIZE.x,this.EDGE_SIZE.y),a=new jt({color:this.EDGE_COLOUR,opacity:this.EDGE_OPACITY,transparent:!0}),s={tick:0},o=new ht(r,a);o.name=e,o.userData=s,o.position.setY(this.EDGE_SIZE.y/2),o.layers.enableAll();let l=new ht(r,a);return l.name=e,l.userData=s,l.position.setZ(-this.EDGE_SIZE.y/2),l.rotateOnAxis(new P(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 Xt,t=this.createCorner("TopFrontLeftCorner",new P(-51,51,51),[{axis:ss,rad:gr.Rotate270}]),i=this.createCorner("TopFrontRightCorner",new P(51,51,51),[{axis:ss,rad:gr.Rotate180}]),n=this.createCorner("TopBackRightCorner",new P(51,51,-51),[{axis:Su,rad:gr.Rotate90},{axis:Js,rad:gr.Rotate180},{axis:ss,rad:0}]),r=this.createCorner("TopBackLeftCorner",new P(-51,51,-51),[{axis:Su,rad:gr.Rotate90},{axis:Js,rad:gr.Rotate180},{axis:ss,rad:gr.Rotate90}]),a=this.createCorner("BottomFrontLeftCorner",new P(-51,-51,51),[{axis:ss,rad:0}]),s=this.createCorner("BottomFrontRightCorner",new P(51,-51,51),[{axis:ss,rad:gr.Rotate90}]),o=this.createCorner("BottomBackRightCorner",new P(51,-51,-51),[{axis:Su,rad:0},{axis:Js,rad:gr.Rotate180},{axis:ss,rad:0}]),l=this.createCorner("BottomBackLeftCorner",new P(-51,-51,-51),[{axis:Su,rad:0},{axis:Js,rad:gr.Rotate180},{axis:ss,rad:gr.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 Xt,r=new zr(this.CORNER_WIDTH,this.CORNER_WIDTH),a=new jt({color:this.CORNER_COLOR,opacity:this.CORNER_OPACITY,transparent:!0}),s={tick:0},o=new ht(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 ht(r,a);l.name=e,l.userData=s,l.position.set(this.CORNER_WIDTH/2,0,-this.CORNER_WIDTH/2),l.rotateOnAxis(new P(1,0,0),Math.PI/2),l.layers.enableAll();let h=new ht(r,a);return h.name=e,h.userData=s,h.position.set(0,this.CORNER_WIDTH/2,-this.CORNER_WIDTH/2),h.rotateOnAxis(new P(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 bt;return e.setFromObject(this),e}getDirectionByViewCubeName(e){let t;switch(e){case"TopFace":t=new P(0,1,0);break;case"BottomFace":t=new P(0,-1,0);break;case"FrontFace":t=new P(0,0,1);break;case"BackFace":t=new P(0,0,-1);break;case"LeftFace":t=new P(-1,0,0);break;case"RightFace":t=new P(1,0,0);break;case"TopFrontEdge":t=new P(0,1,1);break;case"TopRightEdge":t=new P(1,1,0);break;case"TopBackEdge":t=new P(0,1,-1);break;case"TopLeftEdge":t=new P(-1,1,0);break;case"BottomFrontEdge":t=new P(0,-1,1);break;case"BottomRightEdge":t=new P(1,-1,0);break;case"BottomBackEdge":t=new P(0,-1,-1);break;case"BottomLeftEdge":t=new P(-1,-1,0);break;case"FrontLeftEdge":t=new P(-1,0,1);break;case"FrontRightEdge":t=new P(1,0,1);break;case"BackRightEdge":t=new P(1,0,-1);break;case"BackLeftEdge":t=new P(-1,0,-1);break;case"TopFrontLeftCorner":t=new P(-1,1,1);break;case"TopFrontRightCorner":t=new P(1,1,1);break;case"TopBackRightCorner":t=new P(1,1,-1);break;case"TopBackLeftCorner":t=new P(-1,1,-1);break;case"BottomFrontLeftCorner":t=new P(-1,-1,1);break;case"BottomFrontRightCorner":t=new P(1,-1,1);break;case"BottomBackRightCorner":t=new P(1,-1,-1);break;case"BottomBackLeftCorner":t=new P(-1,-1,-1)}return t}update(){this.traverse((e=>{e instanceof ht&&this.updateViewCube(e)}))}updateViewCube(e){if(this.updateMeshTick(e),e.name.indexOf("Face")>-1){let t=e.userData.textTexture;if(t){let i=K6(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=K6(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=K6(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 P;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(){dn.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=document.getElementById(this.cfg.containerId);if(!t){J.error("[ViewCube] containerId:",this.cfg.containerId,"is not found in dom tree! will append to gemini-widget-container");let i="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 Mo(this.container))}initScene(){let e=new ti;e.matrixAutoUpdate=!1,this.scene=e}initCamera(){if(!this.scene)return;let e=new Er(-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 ns({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 _s(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 S2(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 Ws?this.viewer.getBBox().getCenter(new P):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=$t.getScreenPointByEvent(e,this.container);return $t.screenPoint2NdcPoint(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 P;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)}},M2=class extends mi{constructor(e,t){super(e),this.needsFrustumCulled=!1,this.image=t.image,this.min=t.min,this.max=t.max,this.radius=t.radius}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 P;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(){}getBounds(){let e=new P(-1,-3,-1),t=new P(1,-3,1);return new bt(e,t)}isPointInPath(){return!1}getBBox(){return new bt(this.min,this.max)}},jE=class extends mi{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 P?t.position:new P(t.position.x,t.position.y,t.position.z),this.direction=t.direction?t.direction instanceof P?t.direction:new P(t.direction.x,t.direction.y,t.direction.z):void 0,this.radius=t.radius,this.rotation=t.rotation,this.enabledHover=!!t.enabledHover}direction2Rotation(e){return new fe(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 fe(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;if(this.radius){let e=new fe(i.x,i.z),n=new fe(t.position.x,t.position.z),r=e.distanceTo(n);0!==r&&i.lerp(t.position,1-this.radius/r)}let n=this.transToScreenCoord(i,t),r=this.hover&&this.hoverImage?this.hoverImage:this.image;e.save(),e.beginPath(),this.drawImage(e,r,n),e.closePath(),e.restore()}drawSelect(){}getBounds(){let e=new P(-1,0,-1),t=new P(1,0,1);return new bt(e,t)}getClassType(){return"ImageDrawable"}isPointInPath(e,t){var i,n;if(null==t||!t.camera||!this.ctx||!this.enabledHover)return!1;let r=this.transToScreenCoord(this.position,t.camera),a=this.transToScreenCoord(e,t.camera);this.ctx.save(),this.ctx.clearRect(0,0,null==(i=this.ctx)?void 0:i.canvas.width,null==(n=this.ctx)?void 0:n.canvas.height),this.drawImage(this.ctx,this.image,r);let s=Math.max(devicePixelRatio,1),o=this.ctx.getImageData(a.x*s,a.y*s,1,1);return this.ctx.restore(),!!(o&&o.data[3]>0)}getBBox(){let e=this.position,t=new fe(e.x,e.z),i=new bt,n=new fe(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 fe(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 P(i.x,e.y,i.y)}));return i.setFromPoints(l),i}},Hge=class extends mi{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]}draw(e,t){let i=this.positions.map((e=>{let i=new P(e.x,e.y,e.z);return this.transToScreenCoord(i,t)}));e.save(),e.beginPath(),e.lineWidth=this.lineWidth,e.strokeStyle=vn.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()}getBounds(){let e=new P(-1,-2,-1),t=new P(1,-2,1);return new bt(e,t)}drawSelect(){}getClassType(){return"LineDrawable"}isPointInPath(){return!1}getBBox(){let e=this.positions.map((e=>new P(e.x,e.y,e.z)));return(new bt).setFromPoints(e)}},Uge=class extends mi{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}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){let a=this.textStyle,s=a.borderRadius||0;n<2*s&&(s=n/2),r<2*s&&(s=r/2),e.save(),a.backgroundColor&&(e.fillStyle=a.backgroundColor),a.borderColor&&(e.strokeStyle=a.borderColor),a.borderWidth&&(e.lineWidth=a.borderWidth),e.beginPath(),e.moveTo(t+s,i),e.arcTo(t+n,i,t+n,i+r,s),e.arcTo(t+n,i+r,t,i+r,s),e.arcTo(t,i+r,t,i,s),e.arcTo(t,i,t+n,i,s),a.borderWidth&&e.stroke(),a.backgroundColor&&e.fill(),e.closePath(),a.backgroundColor&&e.fill(),e.restore()}draw(e,t){let i=this.textStyle,n=new P(this.position.x,this.position.y,this.position.z);if(this.radius){let e=new fe(n.x,n.z),i=new fe(t.position.x,t.position.z),r=e.distanceTo(i);0!==r&&n.lerp(t.position,1-this.radius/r)}let r=this.transToScreenCoord(n,t),a=this.getFont(),s=i.fontSize?i.fontSize:12;e.font=a,e.textAlign="center",e.textBaseline="middle";let o=e.measureText(this.text).width,l=s;i.outlineWidth&&(e.lineWidth=i.outlineWidth,e.strokeStyle=i.outlineColor||"black");let h=new fe(this.offset.x,this.offset.y);(i.borderWidth||i.backgroundColor)&&(o*=1.2,l*=1.5,this.drawRoundRect(e,r.x+(h.x-.5)*o,r.y+(h.y-.5)*l,o,l)),e.save(),e.beginPath(),i.outlineWidth&&e.strokeText(this.text,r.x+h.x*o,r.y+h.y*l),e.fillStyle=i.fontColor||"white",e.fillText(this.text,r.x+h.x*o,r.y+h.y*l),e.restore(),this.width=o*this.tolerance,this.height=l*this.tolerance}getBounds(){let e=new P(-1,-1,-1),t=new P(1,-1,1);return new bt(e,t)}drawSelect(){}getClassType(){return"TextMarker"}isPointInPath(){return!1}getBBox(){let e=new P(this.position.x,this.position.y,this.position.z),t=new bt;return t.min.x=e.x+(this.offset.x-.5)*this.width,t.min.y=e.y,t.min.z=e.z+(this.offset.y-.5)*this.height,t.max.x=e.x+(this.offset.x+.5)*this.width,t.max.y=e.y,t.max.z=e.z+(this.offset.y+.5)*this.height,t}},Vge="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFgAAABgCAMAAACuYkXGAAAAulBMVEUAAABJSV9pdntRWmdeaHZMW21ZYnJqcH9PV2dSWmtTXmtXX3Jka3tfZ3daY3NXYHBbZHNbZHJaYXNWX3D9/f5cZnT+/v6xs7zKzdKusbr6+vvs7e/Z29/s7e/09faPlaCVmaX6+vz6+vv5+fnw8fP3+Pjh4+Xu7/Da2+Dp6uz+/v719vjz9PX09PRfYXP///+vsLlpa3vDxMv19ffr6+7r6+2lprCHiJZ9fo1zdITNzdObnKeRkp9zdYQN9RLUAAAALnRSTlMAAwQICgYSBwsPDRUMDxcZHRsjH+Mg8TwvIMZ+UpGIMizVtqael3VrZ1zTuq2q+zBSvwAABtBJREFUaN7tmXlD00AQxSW7yeYsPaktKJcgeBRbbsHv/7V8b3ZjTOiRrfylTnoIpD+eb2dmD978j789dtzrjry8HrYWIL8u91Xx+HxgOYG88FHGK2gNbOxUb+7720It2BFNiAh4BXw66bjPMwlKA4gJTWiMUsrgUoZflrL9ra4sMCo0mlilldb4lxY6hQvbU7HDUipQiFjrPLYXvlKiXdAU7a03JCCWyNM8jfFM81znuRI0fmtovW7vr1ANpIGbpmmBSHglSZEiAIcr8JyOtLbDyoUarSGO2MnB/umn4RViOD3ZP0iKIi1yjQDY2EFsiUVwtHLITSaX072rWuydfIwgnG4rzWFsQxYsEkppcPGfn7wH9WUMT99Cth3HINysmQYzceECvU2IXRXv3yYp0YZFA3Abe0PYAG5xWWKvF3fPj/PZbPZ4f7e4KVV/TAr6oQwSb0PWkWsQzIVicuao3+5ntXgo2WcT2JHHSm3Q/Ct5NdI2efvJYam0GU8WPYQdcaxlBNc1DnIN0zcGd3jFAHZ5fHPkqKAbBK8mUzGqCeNWRJZ78zBbGT9unGaIps9rzEB5SmdIU8ddQO7qmH+v3IBm2ryKC3AIg4tiItxvFWSNHZ8mURLbQoGy5U6w3nRaJNGZ47Yin8HmnPnM/r3cYQMw8iz6yPu/z1rEgndeQnKs7AAuFwwfWMdi8M28DXh+Q5snEcbPlsnOipRQcV5E7ynjcdYqHqS6owRmhMsTQ+Y2ZAQyraXBlc17E9hMMwh+KTikExi5Uxoxaxvza5Ec5bDZvHRZ5mM6nBYZHX5qDXaSUSZQDEqzGUlXU2gRTAkK9pN8ic5PyS8Vsw2rGNzohCXnARbJ0wjj5yTXGzxTQhOcsQc/+IDv3fClOeoaAhsWg6vQfLIDPycY9OIgklxmw3jR4JWmE/ueTrjy288wnWhKRtSsMHboMlp85we+w0dOsyhx4GaHDy14irvu/cDP+MgxwbnSMvnVyxn9J0mizlDK2St+sF9kyAu2ZWj8XTPqmf0nirIrxMwv5vxMlqGsCa5lBZNCoeyiqOMLZpRgKnZeVE7I1BFlW4M7NFk18o1r0RDlUYLnW4B3Ac6RyBRcnz2M1N3WgwfFUcq5Lwga2YZZH2O3e4y7nv3ArOmpWKHZ7UVx1TSNyUXx1+0K5DPBhWazB7jeKix425ImmOlmalbYiTQnmE3o2g98yybkrDC1PHbpVhB8tOdb0w9sm71OmcdBo7sBzHTLelNOpb5OnAgYrb7RN6mYiYy06F3Qi7mnE+e9TOYQExqIrE9MRkki78ILL8lPzOIu6yPR0ukbM17AZTHBvXd+kin4C8GsD9PwGF64GSTr9Pwky7pw3KNigMEluV4hkm9Rp9el5KuHtuWMeNft2R7UXLKQLOCCXnSP2C9u2y0KacRwTCeK1K0461aUK0Ka3L24alt+sqg/7zonYhO8OHeBNdKRE3ox+OCz8P4w6O52skTWyA3BCPwq2X4kIvnouP1WYXjkBNvyaFj8a8mSsEZ6g/FQFvXrNzcL4Y4H4Eo962qD01wU0guRPLLk28c1LeLWcmkEBAOslu7WA9lDx1gCZB3aDPI6O+awwXEpmHs9dqA1WwWZ+KC578i3T0ux1/LD4/HICU4xQLUkbnY4DckkdwejQ+YG0YtGsdwTK/lwSL2Sw9wpALsCHMi+n82TZoz65xDt2Hf3j1T6+Hy3IFVsuOgPrF4Wh+aybcV+LJB2n8tEAnJ31B+julfE3rvD/qhLLo3gCtZW3XIwybG1mT4P+v3xl+FK7ACJ1ukIV8HgFVzaI6cKKpdZFT7TaLDPP+81qNMLwVZcdolVYGHLLh0tg/tpS4bTiIP9z1NRPjz+sn9wiO8MaK/4m3CRaeBwE9yskoAHFgBD9C7sABrsRozgbm/X+Ztq1Jw9ytpwOKboM8k0moMosivqgNiexRZJzoQwELzxEEt2qCQDDTbRZLsYIIC1XIDlWM9uzzeRgdaaI1iADD8QhDMGeBKKQetEkdgQIx/K7fkmdKioGXawCEs2ebwE6tSmItcm8MaTQueGNrKxLiy6YwNQJhipxNo0Y2W0PzWlaHEaqsXsKoSawIVcM89U24NvJzpkd1bidUG0C1KZClCLHyoFrPcBckgy0XGaJ0mBB4US6rxltTm5vkf0CkE20FCe5kVKKAtC8TIV1/OUHuMCWWTHuQZf57o8+scglNQd/7+DSLsj2GjrKJGa2NBiPeU6uKAlDM/5AeMbs8vIgUeD62kH4S4ok0IBbVC3RANUxU5FrcDbiy5pVMu3BnQ7dJl+AnZCeeHx5yE0C9us1R8uz//xD8RPQ80FqUsWMbIAAAAASUVORK5CYII=",zge="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKoAAACqCAMAAAAKqCSwAAAAh1BMVEUAAABfTP9eTP9fTP9eTP9fTP9fTP9fTf9fTf9fTP9fTP9fTP9fTf9fTP9eTf9eTP9fTP9fTP9eTP9eTP9eTP9fTf9fTf9fTf9fTf9fTf9fTf9eTP9fTf9cSP9dS/9eTP9fTf9fTf9fTP9fTf9cSv9fTf9fTf9fTf9fTf9fTf9fTf9fTf9fTf/hY9QXAAAALXRSTlMARjRhS0HMZ1M5PVgva1wrTyYbFyJwlnx0gaATeAUPH4mmjYUKm5Gvv7m0q8X/SpWnAAAGcklEQVR42tXcCXriMAwFYEFhBsqeQIEGB2jTjc79zzdmFaDEjgmyhU/wf6+yvIUCxxhE8CBj3Kw9iHXZbNYew7p81tSHsEbPe2pDvDVuH6nSrVkdqcMlCB6q2z6jtgRb1aB+pGrpsCXYOq4jdZuqXGtcR2ptl2qrI9Oadi+oO2unMwZ5Q43OqY0DVaR11L2kDvfUfl+cNRl0SQHsqU/CrNmAUlsHqiyrGg+KU316GoGcEY+M1L9yrOnojNo8dQCkirGq5ciSqhhrMkYq6at7aq8nwqrGhEoKQFsHEH5EudThOVVLe5Pw1nSJ1PbFduUy1Ulwq4o01TStkDoLbE1s1P6ROpvNuhBiYKj51GFOqrNFkFwxVHuqSF2EyzWLojK1itRpMGsckVSbeLbKo4ayZoRqTXU6D2NN4tidGsSaxXGMtWrcA5xT3+vgfaTxRQF0Tc0KqSGsKjmnDooKgKb6vvJtzZBarq8i1bc10VRDX20ZUl29ebVmSeLQASZXVK/WVEtdlgCk7qyf/qxqR7Wn2iepznepfn62wdPIMNXRsQO0Cw4sdFqtNPXFk1WlJNWucVrRVF88WbMtNTF2ALK1XpxNK2194bcilU4rWgB92qxOqb58eLCqLDVMK3oMLKKyWpGaklSte4Apob4+A/PITqlGBiqdVpTKbVUHqvPWmlKJlY8a3URdnVHXfFakJnkLK1LNBYDUdRPOh+ACWK8Zc1VFBeCwsL6dqNr6i7kyUXEPYE8Vm9X8ulY1Fa081L0Vqe7NCqlfJ6uQApjmU381Fa1M1Pg+02pL3aCVmWpP9WpnRaibGofUdQnoFXYALIANi7UClRbAWg8t1dSfnxprqsvbDtdb6yFVpGorF1Vbb6PSDnCgftfCpkoP1/nTaqOp2spCNd4EUuqisFlhqt/fDa5U3W5XpjmbQKzVzY76r8GUqlMBWPrqz56KVg8FQKeVvQAwVbT6KABaqxNDB8BmdaD+abBQ3Y+Bc9qsrqlo5acW7AGmZQrgrlZSq873q6vcJQBTRWtVae4xsGvtAJZUkYpW/iWAvgXQZkX7KlLR6nsJ6BmpNFW08lC7tpvAhW21QipaWVarrjFVWqufhlTvZdVSMq0sBUCalbkDoNX/gcWxA9zNqhhOrISK1oAdYJ5XAGRaoZX1wEKpDqlSayWq6dLS7Wz1YWhWaPW6tZ5cXa+ZlwBi5aTSFxaknlarDwsVrR7PVo4LK7VyUOm3K/bV6pfUKrXemdq+U1+l1q+IoQNYD9e0AOiBhUoZa1VL899YaQd4JVQq5TxcD7FWXU8BxLqJgJPqXqs4raiUmdqq3qzwrx+0r+LCSvcARHo36qh6ql+kVomUcwlwfws4UkmdyplWhIqZ+r8Ictta/yNS1mlF+ursQLWfWFHq89KyU+EYiNLKVHwOrlYAtAOglDXVpuGTsPKpolTc4ZrsV4k0yGo1t6a6k0qgYqpFZyuUVh7GWjVRp+WWACKtmmpa4lvrjvuVxVYq5XsAPFznp/qLUuZmVfUiCKX8BYCrFVLJC0vhErCO4TCE9tVTqlr6INR1LOrTBcMS8EqljFtrOq3+kmn1XrCwotRjquQxyH62QilvB3B/Y6UF8IFSP99ZNfN/c23fWaGUi7q8z2MQkxSwAGK6Wu1jHTo2qxci9bSzajhuAtmkANW2KzTVT5QyUqu/W11IxVCneZtAVilStdXxLYDeWrNKARy/te4ZvrN6S4B1ZOV+GmansktBOfw0zNhXVwlwD4dNoGm1eueUIlVbb0sVO4APKSjrtGrZfhuIUuZhP7BYC2DuRwrZjT8MwYXVlxSU6YWlYf/KAqX8w+k5mL6wTP1JIavw20BmKY21wv3qwqsUspuvLHxLAW7+txvepZA5XQUjdZaC76HofpW+W1FqAClAesu0moSQgnL7zGaxpXqWYqzOtdoLJAXl2qxCSDFWSj1KabP6m0K4UXoTqKWzoFJIS/+DiNBSgPIXQaGlkJ2oXfPvrZ5SCD3icqkKkIJa7qgD00WQDClAWuI1sC9CChBZP7ORIgV1ubDSJaAjRQqQmKeVICnAspgqTApqVExtZSBqpIU3gdKkAFF+qgKlAKPcL9iHAqWgclKVKQXI6C8uGzKlAPHVw6VcKcDysgBqcqUAg7MCkC0F1UWqbKm21o8F0BQuBcjae6p8KUCqqY8hBYg19fkhpFvro0gBEhbpfwjbOY5gXmpMAAAAAElFTkSuQmCC",Gge="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFgAAABgCAMAAACuYkXGAAAAt1BMVEUAAABRUmRVYHFcZHBRWWZia3plb39aYnFeZnVYYXNZYnJPWGdZYnJRWWtZYnJZY3JWYG9eZnVcY3RXXnH+/v7+/v78/P2xs7zKzdKusbr6+vv4+frz9PXn6evs7e/09faPlaCVmaX6+vz09PX5+fns7fDa2+Dp6uzS1Nni4+X+/v7l5+rx8vL9/f1fTf////+vpv9pWP/DvP/19P9zY//r6f/r6P+lm/+Hef99bv/Nx/+bkP+RhP+tEDdkAAAALnRSTlMAAQMGCAsIDQ8UEgsXEB0gGhojJOLx5DwvIMa4m3CRiDIs1aymfWdcV03ShXjTY8FN1QAABtZJREFUaN7tmWlb2kAUhS1knSFAXFBArFtduoAgbtX//7t67gITEsCM+rFHwNZHXs9z5t6bybDzX376hi/5Bx5fxsSTeIBD8qPPUxUndP6f0+fITo0GngUs/ZEPMl0ADVAbKgf3J+siLaxWpOY1HV8yIQvQZlOeJeNedaJWHLhZlrJ94/imKkCjZhAEUYDXSMjCVtN14c4tM/GIAA3CILRhRPyo6HunJrhoVuwCGQIZxqF8t4TH3xK0rqEPmJiwZ4UXx7GN6ZX+AtwHTTYOMkf9DlkqV1MAFO9nZKLK8Iwh0C24hG7UQmv5arphBHcgJf3b35c/9yfQ/mD4+5bxFIx6hriZ6q0arVZsbZL1rwcHkxUdDEcZ0KFkzZ5JW/2qXc6B7fa/g1rV/uUR0FhGVCEHLdo6y5gb0YLFjN2k70dZHGNlIwl6KxdSbmCBTa4X2PvZ09t8Oh6P589Ps8eFawSCqB1586hecqPQIoVjpd49j1f0smAf9xEH6iMQ8nospaBlBm4cZ0c/FQunFb0Kev8oS6Q6dHBU2cAqOEC+KIYjlBek2KrulGyEvCVm4WoORrgPL+ONmj+qZ8QRcdWtn3WLhUOvLbkz2N2s6V8lI+dA04DWcRnM68bcOwfZEsefvkls4EbSGjD3G7oiM8fKrUU+NlR1FIakUSkJDSJOzGgC/R3X0GwCXWeJDXkgrUkCaOLS2JGCeJjWAU8fKea+iS1bXkvmimDD38nGfFxLL9zdJkPNsWWozG1C4KKCawbsYj7oI2Ys4DrLmjCCMJcUxLiupvdkOUXNWYArMS97LklSSvi1Nlgto02WA3SlKggcseGRGPazfG2SxFrpkp2y4ygirhlSy3mA2fLAGFh289MVW4OXDuCUZvCLD/hZlw9kBrsW4Qsdd12SpbeeSUCUxa0xMVfct6JjvoCKYfPDMwltvx8pli8ky4C5peMoaEyYlCJ+8gM/4S2Xqcli6mvFqnSuJYh4gN969gO/4S3nBI65rXcaxdEGLkfc2ud29tKc5kXL0CjSEVdYPFk7Y1oTaOyn6QRqpdzWAJf6GVw4VrCnFAzHq+NCRzFd6tJPgBGFXlRXJ0WEokgFPP0QOEVZVBZPGxqOex9dvJRaJGByybG1Bo7P8VtvHlTt6QE5FrBm7EZQzI4vPtYgw5Z0SECtt2pYo/hoSzvHxcVjMEYFGuSG9mt+YLqg3pBjrWOXBNzTdZQdnx349vQLjc2c6xjgJsAlyzyDWl0aFne+SQxzqmOOuNR6dC8TMviKsph6JjHqEjjWXYsrYwYHvHo5svCy/Ipf77UZHHKDAOjAHEVoMSta+Qlb9jJ80c6pPyw7Lu1X5MpEWfhY1n3hYQ5wRhu4BuSi0ClkefXyNlmevNRtZ+iEkjC8swC2UdmvhGy52z7r+W0Ke4ftnKdxZcuiyxdowbWvJnXbjzf1o3YuY94Cu7qvwFWvyWMoyQjc8dt4d6QmLDtGwkWw7oSk+fL22Xn9W4XeWbvbJcOxcNWwWz2qi8Dy8nXbhz3e1G+/uZkx9xB+5boUuYSd5M6cLbcQhpIf5ltGxKNwOQgj29gq190yUcoIowPytjimiMFxOeEI4DIZKWtbWw1jSX54XYu9n5DOwVXDga3eKrgmCSJYlvVrd06PJ4KelZrlGVjW8Sn8Sm9QETdk31YFO8uoOZA7I5hW9tPznJzO355moEoMV7sdCRhgWbl1jvGQlOXSx553D08mm3RwcrrLOWhv8Cnf+jMnhCyW44TJOci7hxe9TVji5i2pCHc2VKGS9OY/pphTJnc6u3uj4UGJOriCW2DbLeLKfSn8rgW7YzE6akuSTMjIY29vd+/m13DAznvnF79uTvEj4nYxIpZcvRXbdsKCyqA+UTK7hvacQAWWY0izLNFjIT30rapwhEUdyFWHpLk8CA4gqSNYVJnYxcKBSwkTY/OpMU+5gD0jjZTIXbINuqpNWOVyAUdR4eht8znh8tgtzhLDprtd2HbKc1AhYzgGq+eQ2w/tGYwGFNOJVAeUgw7lOR6gils5dVNuCbux6Li56QiSAhE4VXZLoIJN5CxIRwT0DlhLA2i4RhtCJmUByVAJwfIJtY40UY1TaTnpDijqhBJZSKkUQhDyialy3/9wwZ1383k5H54SHDgg8SpHpUrV02OttBrkRRNGajvGQxXGQo0W3KLbWqZ1EZWNpyX7eOGT/yVWPzurx5X+dlk3iQ4envRFlaBYpZa575aHsiMMPXoqdJmtygPr6oO19gMhNcxcL8NVdqMELcwzL8/uY4ay8DPH9ZW+UcQwkeAqHwT5w6va+aLPTPW1QJXTni+QYuW7gr9SHO5/eesfYdwFkua/O6kAAAAASUVORK5CYII=",qge="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKoAAACqCAMAAAAKqCSwAAAB0VBMVEUAAAB5d55fTP9fTf9fTP9eTf9eTP9fTP9fTf5fTf9aYnFfTP9fTP9RV2hfTP9fTf9fTP9fTP9eTP9eTf9eTf9eTP9fTv5fTf9fTP9fTf9fTf9fTP9fTf9fTf9eTP9eTP9fTP9fTf9YX3BaYnRfTf9fTf9fTP9fTP9QVmZeTf9eTf9fTf9fTf9fTP9fTf9fTf9fTf9eTP9fTf9eTf9jantgTv1fTP9fTf9fTf9fTf9fTP9fTf9eTP9eTftfTf9fTf9eTf9fTP9fTf9fTf9gTvxfTf9aY3RaYnJfTf9fTf9fTf9eTf9aYnNZYXJeTP9fTf9eTuxbYnRfTv1cTuBfTvJfTf9eTP1fUPhfUuVcVsJbT91cT9tbWKtcWLFbXpNdVM5ZX3ReTvtcUsxbVMRcU8heUOb8/P5cWLlcVMheTPxZWZ79/v7+/v63ucpcXJvw8fSvs7r29vmVmarp6e7NztNWU7j7+/vR0eH7+/zh4uTy8/Tr7O2wsbr39/z3+Pj3+Pjl5+rKytSnptWpqsqKisD5+vro6PLs7PTa2ulfTf////9zY//r6P/19P9pWP/DvP+Hef+bkP/r6f+vpv/X0v+5sf/h3v/Nx/+lm/+RhP99bv89/FqOAAAAiXRSTlMABMw/RS9kbCdWB092BUIslzo8U180Ko9Zh5syI4RbNjh9DRBxaUd5CWdRrXNhXaNLSYpvCyBNgIGxjHtMG76UkqG6nh60JhnIqKbEExWqtyciFh4jwRkTIR0mGx0iISAdDycZFRjkKCQKGeLxOSeNP6ksby4QxVnUT5yAHsnJuF9HREI213iiZ4OOOrcAAA/ESURBVHja1NhPj5pAGAbwIYrr4gLVXf9lqavJFi3RZtHFblpJe/ATcIAzR7JNeuhemjTp3U/deWccRxjsSTLjYzTG0y9P3nkBURXpxehC4lj1EF1EAsuqX4Z1W6tZdde9AOu204FWfX+LFE/U7tQw1fX9jeLWrIupNdyq+7RpKW3V9DGlukD1AqRsNPuBUmFW1y3vVl2r02VU14dWvWtVrfF9l7f6BK1eK2pNdULlx6qFqQMVrVpTL7Ta8jB14CDl0tSPqO6BOvqknDWyCbW9p9IBINQ7xaxZj1L5rMKxuiXUhVJWzQFqYQBYq4tGE6mTuNmzbeFYsVYbClnTJqbqeeoG9iqjflTFqgWcyvfqGmaVUT8oYo2cIhVuAumsDvbUKyWsmiNQ6wfqiFGvekh+wgLVosdq7eWpK/nWNAjKWl23itRH2VYt5FTeqnu8Vxd76txGUpNsxVaBKrY6n99ItWrhNnDEDYCpa3YJuGuwVm+kWhNKFVsVNgChTnUkK1mMqUFJq/4GNkCx1en0qzRrFOap7fILK6dOJpKsWZRvtctaFQeAtTr5fI9kJGFUYa9SqnCsgPoiw5pFhHriwup5+3uARb7Vl/cSrGkUc6pd2KvlG2AC1IqtGrzJi/+URFF4guoL1Eeg0laHwy6qMsCEcG2WlA6AxfaqB9RR8VhBq8Mlt1ahNIGJvxw6TkQqf7Zie3VU2uryC7NWUadpsk+T9poxaumdFW2VD8Bqlaf2H1AFASIIDfIiZOCnSVRKtWir/OFaPFbD5bJfiZW2aRrG20/DMGmzCBkpH4CSVhl1dNzq9KjV/vfx+aEmxMB5/fGGrRCMT4EqbIDTDyz5AVhi6rfxuaEadc5mv3a7v7MZfAdt+r9WXfL/qjgAvFWgvmuf30qkf153u93v5+cZsWaEGpdT3dJba5H6j1Vz+00iCsJ4vDz4Um8x3qIxYdUYjalGaqJ4ibb1UkFbwQhCiwK1TcHUFrFatfEW4w5QWrHV+tc6c85ujzA7sCDzwusv337nm5lzQNYei0qgweAs/KjDa0RVrCWGymcApipDPdxbVg0aeAVQXq7AN2RF2GAp95hQ3SGQN1bKVSEBCPWyRkXWHgVqn/r6QSQNzEHNtjeg8D4QOBU8VSo9e5x7OImoQre6iA7gjTUUcsNKoSLr4N4eiYqkWtPAR6iWbdv+CbOWhbAlUpVQhxpQ93jNAGebDXDUGGBw8MbenoiqfEqklpWHuo21AoVXiBpA1Nwk1tWrA8LC0sarlzdRkbUHRaQIiqRF+GGrWoPXlqVIc48nUVU5AQiV71amW2mvDt7o79/WA1kJVZG+ysOqRl2uwlvLylFNEqqUAHKuEqo5Vqhq/8i2HpAqp1qWNQe/bKfqkA9bM0Sape8vtAC9BQiqGgPsVqqO3N3WC6cqo1JQ2W5V4F1kZmYml82RqkOCqsIW0JQAhx3U+zt7Ean4/cMUVLr0yZqfwcpOJpNJQdWmyeqERiVSMwMYAyDqmZ3/Q6qTKoikeKaMqBRYi0SazRLqkHysnNF6n6BqI6ph7fZUBUlUdaZMlQE+Sah8smpADXkcq36Nemnn/3x/R1Rs/obTCayURo1Gh3xNVuZYyahds24hqxIqBdWGwXQCayGVUqioasxzt8K+6qdbGQNcGh7e3jWrJrXoTDXVb3g+n0JSpWpMVLVVAhzgqg4/2N5tVOlOpYKqudZhNpVNtDCAeQ6WGytHvdmdrq5V30CdkarASiSS0WR0aCAWGxXerXyijjgGQNRuWGl7Uk21CNWVMq91mEslElFUNU4G2O+FeloMK1HVm9dOdmNVJWogD1ItJJLEGv/XAMfYDCCpyr06rFC7YHXOfzGv6rlHzSWUWQdadSt+FcznVST9F/XR+c7nP2KlBhC5/fTp2NjYLafGsJ5OTKTw+6eTJOpArAF1r2sAM6+ae4CQVlVIAI1671zn3x9RkTR8+zaxGlSqCWRNKK/G0QA7PEdrX8dqsMkAhHqvM111VhFqRKvawDqhUdPRNKLGRkfbvwbyIVBW9d6dc51d/ehNhb6/a4CvL1/Ob6Km0AHpdDoajcViXl41j+z7vK/XjKoc9c6VzkTto+9vRTTq/LulAlAtLS5o1nGSVanKDaA31u5VvbP1ov9DpRuAi7qwRJTVSqVKv/kikiLreFqjxvgLix6teViFzE2gV1g92ERlrHJX1VmlrTq/iJi11bKaVFZqFYDnL4mUDBAnVOZVWq5ZAvA18LpCRVKG2gErTYBoVYus+iIP1fqybWq1AoXvWtW4QkVSn+NKqH0L0KpiXfEpq5uqkcinAqw3zSvlGsDsOKFqVY/sN6iiAeRuNeKBylhlVHSq/v44rdaMpGZthaJinUZSMoD8xCajyqoqVp8e6NNZhah5vVZz1sKX8fHp6bg3aoOqZ8U7Kz1aC6oyXcVYRVH1skKa8qrBB0RF1iejox7HSj9biAnADWCO1SNC5azyAqBQww1zNVtaNCqy8ptAfr963MwA4hBowsqti+3XakJtvADgS8sHQn2iUXfxboVDIHtiI1U5qmQAzipvgOE8iSrL6qJSAnADiI9Bh5rWwLsc1T+rE1VvYd0Waw1mpzKOqgxVJwC/s/Kbq/5YTauyFmFNRl2BD1PTGUJFWduH1XF5ub7LjxVnlXcVGlXCr2FDRl2GwlQmk9Gouzz+ECIYwNe44p+VVEXUN/DHlqsKX6ccVO7V5o31gnC9JqByVpkUUfWpkqsCnxXqE6Oq2QLwhUXIVd5YDSozAGflBqBW1R41g4WkfAZgLyzcq/xYyagya5+zq7Q2AMCUqyrPVWe3OthqsrouG4CzSq//zq76t5oz/5EhCuJ4T4hr3UcciXMY1yJYZwhCTCJGXBnERGYdw65da9Z93yTNYtz8tar6Tc3r6W/XPNpMtpX1C798Ultdd72qX9NJf9FndVm0alCXLA61LP4is3Kj7tithYB6Wv2glbOq+Y8ElYeBOGSH1QXdVrEKQFK9BGTUe/6IjvrBfw2ocsIQGVyuwNWFFiGAWJFU/6wMav6u/xEQbe/6ua5VQZ2Hg0vMrLTA6ib1uLFmUIf8L7pSq5cJVUIAtte6lK41ahWdFZKqapVqdXjA/6ErVVBBq2QAzu6KAxVI9S4wOStWq5kCo9C4/Q2RXuHfv/WreMSEy0t6IwhQkRSFbFU6a1UeBKF89ysvL4e06t4IwhDgLliQFB1rowmYH74bw/r+i195ce0ao15BAzCoEq2c4+B9WhKIpCiCmuXOCrGOROz14zsmZdTz1lanYWptDQCc1U7HZ4WkurGaKpAbltxc+VQLgX7x/VdMyvUKpNaupiW2gvdpgRVJUSQISBvwRoVgP9RoJvCr9pX6QANDB68xap31ZAN1TthWuyJ+tVvRqqBCtHKTZpjVNFdZrWViZVgRAqXWZUAalIEnw1qd0XQcyqiLkjaCkFQfBBnXKi3rZw+ePK5UXj0ZunOQhEkF9SRWrDmpWPUqwJFaI6meBYpaiVUmAVaov8qopr92VJqWjrlVNwTWPWofAEgdxir+qhxhNQ12aa9RIwgKFj2wLv3TaIWkeieQm5YyCmBWS2pRSaBnNXMqNIJcVQB+VkDqrq+tWoX1WAO11GhaKmMLrK1WulBFq0iq+4AQqrCGx1YkJaPV2FZwzlYBLT2AZqtri3+5DMQW8PDmzUGW600yGEhjbAFazTVWF+bBCQOgYmB1k2LbgqfBqlQFVfEAYqvKhEX3AEeKyXYsbvNgBWXErwzawSUagCSBCfyqQuo01uy9+IT1nT9Ec0uaXKJW7asL2F2J3bNq7lkdAlKnVqVxVY2rWWp+pSRDVmV7LXQXsBpsVdWqQuqw1bpaHw5gKfj2nX9DULcog8uuuBDgHFxuKCZcCOoxu0vfYkpAnrGePasYgKQrjpYFFiwbjidaspB5AK2D/4AScJBQeXmFd1ccu9aOEBDOV/cRaWLWeuPifaSwqhrSs7wOoG0EMaq+ZwWfFaHu10jdxioF1m3/a+SbCpRqtHpasVVtxqr3V5ORZmTPKkivnzWPhOibOlcytkqs4WuLOTBi+4uu9QIHqXt2zZXA/bDD+uxXyv1MatYXTzt2AiEHUFAdpO702gyvh0MO6+2I/7RMrGdKsr0GBjBVdq1VZ4Wp9fSkpDJnk+z6Ac0vraPKl/sJtW6rFFhlywK6K4CqBtbkpOICBLVM63bWUeXzbAAXAls9razaKkuhSma1959ITbySQuAOOSwJ/mVC7S+ZVdtAq3FPGVjU2c7UWkiTokrZakpBcVjkqIbz+UI/CbEWT8C1haQreMaof1YJSbFoMYXAYPBlvSdHVTaoFwK1FpWlUO00LG5uNTcRKXYDpMI2XWE6CmDSw4cD0kvFS81anaPvBG5W/erOU225s2RUo1Z2WD/NN1UoHM5eZFb92iLnyletVhOTYoG1TFjJYVHwzwdKzd66GJww7FbPGNmvYisYndUmIE0YsEyB1fiy/IG6UpdlgyOWs0yK91birCBdwbHFfCBNHAWkxGa93qOVpUKBdZpd1sOkJKBVJbVW+qsLT7XzLtSwsg0Unlwl0EKWSXtuMSsfXOLJbWPE5spXgTS5mHu7VYaVd66eskYZla4DDWrLk1vX9tr2tpFmjF5XkbkaVgZllZJMmnTrFN2GFdmv6q8ugFabbFUhTewEmJXbLCQBJwufh07h1wGsreKQHSYs0XRlWxtIMRcUWCbtWUUq5TtxPg62L4SoBYt2GbS03aTm3ppIA9oeEjkPntLHatUOmR0b7G0ixQwrYxRLP/TXHF1nSPg6VD8N29pSqyuBtF32ynhMazQ6ie/uGw9EKI9EbW3lV9tEipkAsxKtEaKkH/vsBh4yu/dXJwNpu58ImGJISYwr65P3AVquhc8GrXb3eh2RDP8hMbyk4UDMf4EBwLK9bQVbZ9UBUnzPQlQq0otJoHsfYDmQtlOtQsuk8g8smegDETPw4jL6QgiRdliaEK1a40NADt9eEwMYD6SdACWRD0oko9iqbAXDazYdIkVelF5Exf6qrQJWdJYUYfGZOKwCcMTW3c2koyi9ylsWsGZDqKuJdDSlqLxlgQXLuFEm9fqU54y2hi/Z2VmtI9JRluNKdyViq7NHn9TLxNlqtL2WClL6stBWoWBZnwpSz9utPLthN4IWpYSU3rUVA1BCwLy0kHreqVa11ew0kXreAfAAoWg1MU2k9K49ttdEq7P6vFRJL+wDiK2mjZTia0wnkFHXpI7U8yZEcgBjAF0pJPUy02Ie4d+aRlLKW9Cv7konKZmroMr+6sa0knrelqY1m65cekk9bxqvL0ojaGyaSclcra2mm5RY54gBTE05KbEuMS2LMaknpQjLIeC/IKVSi7T6f5CSe5068z8hpUS7I6S/ARbzgdCIDH2vAAAAAElFTkSuQmCC",Aht=(e=>(e.ZoomChanged="ZoomChanged",e.SyncCamera="SyncCamera",e.CameraChanged="CameraChanged",e))(Aht||{}),jge=class extends zi{constructor(e){var t,i,n;super(),this.CAMERA_Z_POSITION=100,this.width=0,this.height=0,this.frustumSize=this.width,this.renderEnabled=!1,this.drawableList=new So("overviewMap"),this.clock=new Ua,this.raf=new af,this.raycaster=new Is,this.translateStart=new fe,this.rotateStart=new fe,this.isMarkerRotating=!1,this.isMarkerTranslating=!1,this.isUpdateWhenPawnMove=!0,this.allMarkersBBox=new bt,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=$t.getScreenPointByEvent(e,this.viewerContainer),a=this.lockCameraInViewCenter?this.camera.position:$t.worldPosition2ScreenPoint(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=$t.getScreenPointByEvent(e,this.viewerContainer),s=this.lockCameraInViewCenter?this.camera.position:$t.worldPosition2ScreenPoint(n.position,this.camera,this.viewerContainer);if(this.isMarkerRotating){let e=new fe(a.x-s.x,a.y-s.y),i=(new fe).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 fe(a.x,a.y),t=(new fe).subVectors(e,this.translateStart);if(Math.abs(t.x)>this.tolerance||Math.abs(t.y)>this.tolerance){let t=$t.screenPoint2worldPosition(this.translateStart,this.camera,this.viewerContainer),r=$t.screenPoint2worldPosition(e,this.camera,this.viewerContainer),a=(new P).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.controls.enabled=!0},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=$t.getScreenPointByEvent(e,this.viewerContainer),a=$t.screenPoint2worldPosition(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 fe(e.x,e.y);return this.boundaries.forEach((e=>{e.polygon.length<3||Ut.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),!dn.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=e||{},this.transformMatrix=new qe,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==(t=this.cfg.enabled)||t,this.lockCameraInViewCenter=!!this.cfg.lockCameraInViewCenter,this.radius=this.cfg.radius,this.size=this.cfg.size,this.minZoomFactor=null!=(i=this.cfg.minZoomFactor)?i:.3,this.maxZoomFactor=null!=(n=this.cfg.maxZoomFactor)?n: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(){dn.isBrowser&&!this.cfg.context&&this.initDom(),this.initScene(),this.initRenderer(),this.initCamera(),this.initInputManager(),this.initEvents(),this.initControls()}initDom(){let e=document.getElementById(this.cfg.containerId);if(!e){J.error("[ViewCube] containerId:",this.cfg.containerId,"is not found in dom tree! will append to document.body.");let t="overview-map";e=document.createElement("div"),e.id=t,document.body.appendChild(e),this.cfg.containerId=t}this.width=e.clientWidth,this.height=e.clientHeight,this.viewerContainer=e}initInputManager(){this.viewerContainer&&(this.inputManager=new Mo(this.viewerContainer))}initScene(){let e=new ti;e.background=null,e.matrixAutoUpdate=!1,e.matrixWorldAutoUpdate=!1,this.scene=e}initCamera(){if(!this.scene)return;let e=new Er(-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};!dn.isBrowser&&t&&Object.assign(i,{context:t,canvas:dn.creatReactNativeCanvas(t)}),t&&(this.width=t.drawingBufferWidth,this.height=t.drawingBufferHeight),this.renderer=new ns(i),this.renderer.setClearColor(11119017,1),this.renderer.setClearAlpha(0),dn.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 _n(this),this.overlayRender.addDrawableList(this.drawableList)}initControls(){let e=this.camera;if(!this.inputManager||!e)return;let t=new Ws(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:at.TRUCK,middle:at.TRUCK,wheel:at.ZOOM,right:at.TRUCK},t.touches={one:at.TOUCH_TRUCK,two:at.TOUCH_ZOOM_TRUCK,three:at.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;Nt.areNumbersEqual(e,this.cameraZoom)||(this.cameraZoom=e,this.dispatchEvent("ZoomChanged",(e/this.initialZoom).toFixed(2)))}}initEvents(){var e,t,i,n;!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))}getDrawableByEvent(e){var t;if(!this.camera||!this.groundPlane||!this.viewerContainer)return;let i=this.raycaster;if(!i)return;let n=$t.getScreenPointByEvent(e,this.viewerContainer),r=$t.screenPoint2NdcPoint(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;this.controls.minZoom=0,this.controls.maxZoom=1/0;let e=this.getContainerRadius(),t=this.camera.zoom*Number((e/this.radius).toFixed(2));this.controls.zoomTo(t),this.initMaxAndMinZoom()}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=$t.screenPoint2worldPosition(new fe(0,e),t,i),r=$t.screenPoint2worldPosition(new fe(0,0),t,i);return Math.abs(new fe(n.x,n.z).distanceTo(new fe(r.x,r.z)))}initGroundPlane(e){var t;ft.expandBoxByScale(e,3);let i=e.min,n=e.max,r=n.x-i.x+n.y-i.y+n.z-i.z;ft.expandBoxByMinSize(e,r);let a=[],s=(e,t,i)=>{a.push(new P(e,t,i))},o=e.getSize(new P),l=e.getCenter(new P);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 Et;e.setFromPoints(a),e.setIndex([0,3,2,0,2,1]),e.computeVertexNormals();let i=new jt({color:"#888",transparent:!0,opacity:0,side:or});this.groundPlane=new ht(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(),Sn.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 nt(this,null,(function*(){let t=new P,i=new P;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 P(Math.min(t.x,i.x),0,Math.min(t.z,i.z)),a=new P(Math.max(t.x,i.x),0,Math.max(t.z,i.z)),s=new bt(r,a);this.zoomToBBox(s),this.initMaxAndMinZoom(),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.addMarker(new M2("overviewMap",{image:n,min:t,max:i,radius:this.radius})),this.imgBBox=s,this.enableRender()}))}createCameraMarkers(e,t){return nt(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(zge),n=yield this.getImageElementFromUrl(qge);this.addMarker(new jE("cameraDirDrawable",{image:i,hoverImage:n,translate:new fe(-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(Vge),n=yield this.getImageElementFromUrl(Gge);this.addMarker(new jE("cameraDrawable",{image:i,hoverImage:n,translate:new fe(-.5,-.5),scale:.25,position:e,direction:t,enabledHover:this.enabled}))}this.enableRender()}))}initCameraMarkers(e,t){return nt(this,null,(function*(){var i;let n=new P(e.x,e.y,e.z),r=new P(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);this.updateZoomFromRadius()}))}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=s.lerp(o,l),u=this.cameraDrawable,d=this.cameraDirDrawable;if(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){let i=this.cameraDrawable,n=this.cameraDirDrawable;if(!(this.camera&&this.viewerContainer&&i&&n&&this.isUpdateWhenPawnMove))return;this.animationId&&cancelAnimationFrame(this.animationId);let r,a=new P(e.x,e.y,e.z),s=new P(t.x,t.y,t.z);a.applyMatrix4(this.transformMatrix),s.applyMatrix4(this.transformMatrix),this.lockCameraInViewCenter?(r=this.camera.position.clone(),a.setY(r.y)):r=i.position.clone();let o=Date.now(),l=n.direction.clone();this.animationParam={startTime:o,positionStart:r,positionEnd:a,directionStart:l,directionEnd:s},this.updateOverviewMapCameraAnimation(),this.dispatchEvent("CameraChanged",a)}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 P;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 fe(e.x,e.y)));null==(t=this.boundaries)||t.set(e.id,{id:e.id,name:e.name,polygon:i})}))}screenShot(){return nt(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 J.error(e)}}))}getViewConfig(){return this.cfg}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 bt;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 P(.01*n,0,.01*n)),Nt.areVector3sEqual(null==(e=this.allMarkersBBox)?void 0:e.min,i.min)&&Nt.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()}};export{qMt as AXIS_SECTION_PLANE_CONTROL_ID,GMt as AXIS_SECTION_PLANE_ID,AH as AnnotationTable,N5 as ArrowMarkup,gme as AxisGizmoPlugin,kA as AxisPlaneSection,Wfe as AxisType,dv as BYBLOCK,hv as BYLAYER,vC as BaseDxfCompareHelper,pr as BaseMeasureDrawable,xu as BaseMeasurement,sf as BaseSection,hu as BaseTable,vf as BaseVRMesh,df as BaseViewer,ume as BimViewer,Ume as BimViewerDatGuiPlugin,Yd as BinaryReader,dm as BitView,vme as BottomBarPlugin,hf as BoxSelectHelper,zd as CSS2DObjectUtils,Ws as CameraControlsEx,xR as CancelablePromise,_n as CanvasRender,B5 as CircleMarkup,ic as CloudLineMarkup,H5 as CloudRectMarkup,vn as ColorUtils,ft as CommonUtils,em as CompareDrawable,HA as ControlsHelper,$t as CoordinateConversionUtils,Mpe as DEFAULT_BIMVIEWER_TOOLBAR_CONFIG,Cpe as DEFAULT_BIM_VIEWER_CONFIG,Ape as DEFAULT_DXFVIEWER_TOOLBAR_CONFIG,Vfe as DEFAULT_MARKUP_TOOLBAR_CONFIG,PH as DEFAULT_SIZE,Rpe as DEFAULT_VRVIEWER_TOOLBAR_CONFIG,dn as DeviceUtils,U5 as DotMarkup,mi as Drawable,So as DrawableList,uH as DxfChangeType,Gi as DxfCompare,Bpe as DxfCompareHelper,xfe as DxfCompareMarkupManager,Tv as DxfDataTable,Zt as DxfLoader,im as DxfParser,Nhe as DxfRenderOrder,oc as DxfUtils,ff as DxfViewer,zMt as ENTER_KEY,VMt as ESC_KEY,V5 as EllipseMarkup,zi as Event,c2 as ExplodePlugin,Gp as ExportUtils,du as FontDataTable,RR as FpsUtils,Pue as GROUND_PLANE_RENDER_ORDER,Ufe as GROUP_CONFIG,nC as GenerateMeshBvhWorker,Ut as GeometryUtils,u2 as GroundGrassPlugin,h2 as GroundGridPlugin,qme as GroundShadowPlugin,jme as HotpointPlugin,ev as ICON_FONT_CLASS,jE as ImageDrawable,Oi as IndexedDbManager,Mo as InputManager,Xfe as InstantiateHelper,HMt as KEYDOWN_EVENT,UMt as KEYUP_EVENT,xot as Keys,Vme as LayerManagerPlugin,z5 as LeaderLineMarkup,Hge as LineDrawable,yA as LinePatternShaders,ba as LoadingHelper,Pge as LocalDxfUploader,Ige as LocalImageUploader,f2 as LocalModelUploader,y5 as MOUSEDOWN_EVENT,Gd as MOUSEMOVE_EVENT,v5 as MOUSEUP_EVENT,mb as MarkupManager,LA as MarkupToolbar,ma as MarkupType,Di as MaterialUtils,Nt as MathUtils,Spe as MeasurementPlugin,yl as MeasurementType,DA as MenuTypeEnums,Pr as MergeUtils,uf as MeshBvhHelper,uC as MobileTouchHelperDrawable,Lge as NavCubePlugin,tm as NestCompareTypes,oC as OSnapHelper,xhe as OSnapMarkerType,Tpe as OSnapType,Epe as ObjectPixelSizeHelper,Sn as ObjectUtils,XC as ObjectsBoxSection,Vpe as Offset,nfe as Orientation,M2 as OverviewMapDrawable,jge as OverviewMapPlugin,Aht as OverviewMapPluginEvent,wu as PdfLoader,Cge as PdfLoaderPlugin,lC as PickMarkupHelper,YC as PickPlaneSection,Tr as Plugin,Xp as PolygonUtils,G5 as PolylineMarkup,tf as ProgressBar,af as RafHelper,q5 as RectMarkup,XMt as SECTION_BOX_ID,WMt as SECTION_PLANE_CONTROL_ID,jMt as SECTION_PLANE_ID,x5 as SECTION_PLANE_NAME,bpe as SHP,tC as SHPLoader,QA as SHPParser,VGt as SIMPLE_BIM_VIEWER_CONFIG,ZRt as SNAP_ICON_SIZE,yot as STATE,rue as SVGObject,yhe as SVGObjectUtils,iue as SVGRenderer,fs as SceneUtils,b5 as ScreenshotMode,d2 as ScreenshotPlugin,$C as SectionPlugin,tv as SectionType,su as SectionUtils,eC as ShpThree,ki as ShxFont,Po as ShxFontLoader,om as ShxFontType,hme as SimplifiedBimViewer,vhe as SimplifyUtils,Fge as SkyboxPlugin,Za as SnapDrawable,kge as StatsPlugin,Uge as TextDrawable,cl as TextMarkup,rc as TextureUtils,yu as Toolbar,zH as ToolbarMenu,aE as ToolbarMenuId,RH as Units,XR as VRControls,JC as VRCube,QC as VRCube24Faces,e2 as VRSphere,mme as VRViewer,Bge as ViewCubePlugin,cb as Viewer3DUtils,Ti as ViewerEvent,Gut as ViewerMode,Ov as ViewerName,CH as ViewpointTable,F5 as Views,WC as WebCam,j5 as XMarkup,kv as ZoomToRectHelper,MH as bspline,tfe as checkIsNewVersion,Hue as cn,Zde as createHatchPatternShaderMaterial,Mlt as decodeDxfTextCharacterCodes,Alt as decodeDxfTextMbcsCharacterCodes,Rlt as decodeDxfTextUnicodeCodePoints,Bue as en,sAt as getLengthValueByUnit,lb as getUnitStr,Clt as getVersionFromLocalStorage,iu as layerForHitableObjects,Fr as layerForSelectableObjects,is as layerForSnapableObjects,J as log,Br as matrixAutoUpdate,xA as parseDxfMTextContent,bA as parseDxfTextContent,wH as round10,BMt as sceneAutoUpdate,_R as setIcon,oue as setLogLevel,Plt as setVersionToLocalStorage,ru as showPrecisionValue,bhe as unitConversionByMeter,dot as unitLabel,Qde as unitScaleConversion,Jde as unitScaleToMeter}; \ No newline at end of file +var CEe=Object.create,T1=Object.defineProperty,PEe=Object.defineProperties,IEe=Object.getOwnPropertyDescriptor,DEe=Object.getOwnPropertyDescriptors,LEe=Object.getOwnPropertyNames,oz=Object.getOwnPropertySymbols,lz=Object.getPrototypeOf,cz=Object.prototype.hasOwnProperty,OEe=Object.prototype.propertyIsEnumerable,kEe=Reflect.get,xo=Math.pow,NI=(e,t,i)=>t in e?T1(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,Kn=(e,t)=>{for(var i in t||(t={}))cz.call(t,i)&&NI(e,i,t[i]);if(oz)for(var i of oz(t))OEe.call(t,i)&&NI(e,i,t[i]);return e},pi=(e,t)=>PEe(e,DEe(t)),FI=(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')})),NEe=(e,t)=>()=>(e&&(t=e(e=0)),t),K=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),k_=(e,t)=>{for(var i in t)T1(e,i,{get:t[i],enumerable:!0})},uz=(e,t,i,n)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let r of LEe(t))!cz.call(e,r)&&r!==i&&T1(e,r,{get:()=>t[r],enumerable:!(n=IEe(t,r))||n.enumerable});return e},$i=(e,t,i)=>(i=null!=e?CEe(lz(e)):{},uz(!t&&e&&e.__esModule?i:T1(i,"default",{value:e,enumerable:!0}),e)),FEe=e=>uz(T1({},"__esModule",{value:!0}),e),Bi=(e,t,i)=>(NI(e,"symbol"!=typeof t?t+"":t,i),i),BI=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)},ce=(e,t,i)=>(BI(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)},St=(e,t,i,n)=>(BI(e,t,"write to private field"),n?n.call(e,i):t.set(e,i),i),N_=(e,t,i,n)=>({set _(n){St(e,t,n,i)},get _(){return ce(e,t,n)}}),ft=(e,t,i)=>(BI(e,t,"access private method"),i),hz=(e,t,i)=>kEe(lz(e),i,t),dt=(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())})),pz={};function F_(e){return(F_="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 HEe(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function dz(e,t){for(var i=0;i1&&void 0!==arguments[1]?arguments[1]:{};HEe(this,r),this._locale=function(e){for(var t=fz(e),i=0;iqEe});var VEe,fz,zEe,GEe,mz=NEe((()=>{VEe=function(e){return e.split("-").every((function(e){return/[a-z0-9]+/i.test(e)}))},fz=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})),Mz=K(((e,t)=>{"use strict";var i=(mz(),FEe(pz)),n=yz();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})),Cz=K((e=>{"use strict";var t,i,n=(t=Mz())&&"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}()||e||Function("return this")()})),Xt=K(((e,t)=>{t.exports=function(e){try{return!!e()}catch(e){return!0}}})),jn=K(((e,t)=>{var i=Xt();t.exports=!i((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]}))})),Um=K(((e,t)=>{var i=Xt();t.exports=!i((function(){var e=function(){}.bind();return"function"!=typeof e||e.hasOwnProperty("prototype")}))})),gr=K(((e,t)=>{var i=Um(),n=Function.prototype.call;t.exports=i?n.bind(n):function(){return n.apply(n,arguments)}})),w1=K((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})),bo=K(((e,t)=>{t.exports=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}}})),Qt=K(((e,t)=>{var i=Um(),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)}}})),Zs=K(((e,t)=>{var i=Qt(),n=i({}.toString),r=i("".slice);t.exports=function(e){return r(n(e),8,-1)}})),Hf=K(((e,t)=>{var i=Qt(),n=Xt(),r=Zs(),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})),ga=K(((e,t)=>{t.exports=function(e){return null==e}})),hs=K(((e,t)=>{var i=ga(),n=TypeError;t.exports=function(e){if(i(e))throw n("Can't call method on "+e);return e}})),_s=K(((e,t)=>{var i=Hf(),n=hs();t.exports=function(e){return i(n(e))}})),jI=K(((e,t)=>{var i="object"==typeof document&&document.all,n=void 0===i&&void 0!==i;t.exports={all:i,IS_HTMLDDA:n}})),Rr=K(((e,t)=>{var i=jI(),n=i.all;t.exports=i.IS_HTMLDDA?function(e){return"function"==typeof e||e===n}:function(e){return"function"==typeof e}})),Cr=K(((e,t)=>{var i=Rr(),n=jI(),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)}})),Si=K(((e,t)=>{var i=xn(),n=Rr();t.exports=function(e,t){return arguments.length<2?function(e){return n(e)?e:void 0}(i[e]):i[e]&&i[e][t]}})),Eo=K(((e,t)=>{var i=Qt();t.exports=i({}.isPrototypeOf)})),Fc=K(((e,t)=>{t.exports="undefined"!=typeof navigator&&String(navigator.userAgent)||""})),Bc=K(((e,t)=>{var i,n,r=xn(),a=Fc(),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})),Uf=K(((e,t)=>{var i=Bc(),n=Xt(),r=xn().String;t.exports=!!Object.getOwnPropertySymbols&&!n((function(){var e=Symbol();return!r(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&i&&i<41}))})),YI=K(((e,t)=>{var i=Uf();t.exports=i&&!Symbol.sham&&"symbol"==typeof Symbol.iterator})),sd=K(((e,t)=>{var i=Si(),n=Rr(),r=Eo(),a=YI(),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))}})),ad=K(((e,t)=>{var i=String;t.exports=function(e){try{return i(e)}catch(e){return"Object"}}})),Zi=K(((e,t)=>{var i=Rr(),n=ad(),r=TypeError;t.exports=function(e){if(i(e))return e;throw r(n(e)+" is not a function")}})),Hc=K(((e,t)=>{var i=Zi(),n=ga();t.exports=function(e,t){var r=e[t];return n(r)?void 0:i(r)}})),JI=K(((e,t)=>{var i=gr(),n=Rr(),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")}})),Ki=K(((e,t)=>{t.exports=!1})),z_=K(((e,t)=>{var i=xn(),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}})),G_=K(((e,t)=>{var i=xn(),n=z_(),r="__core-js_shared__",a=i[r]||n(r,{});t.exports=a})),Vf=K(((e,t)=>{var i=Ki(),n=G_();(t.exports=function(e,t){return n[e]||(n[e]=void 0!==t?t:{})})("versions",[]).push({version:"3.30.2",mode:i?"pure":"global",copyright:"\xa9 2014-2023 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.30.2/LICENSE",source:"https://github.com/zloirock/core-js"})})),Qr=K(((e,t)=>{var i=hs(),n=Object;t.exports=function(e){return n(i(e))}})),zr=K(((e,t)=>{var i=Qt(),n=Qr(),r=i({}.hasOwnProperty);t.exports=Object.hasOwn||function(e,t){return r(n(e),t)}})),zf=K(((e,t)=>{var i=Qt(),n=0,r=Math.random(),a=i(1..toString);t.exports=function(e){return"Symbol("+(void 0===e?"":e)+")_"+a(++n+r,36)}})),Pr=K(((e,t)=>{var i=xn(),n=Vf(),r=zr(),a=zf(),s=Uf(),o=YI(),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]}})),S1=K(((e,t)=>{var i=gr(),n=Cr(),r=sd(),a=Hc(),s=JI(),o=Pr(),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)}})),$u=K(((e,t)=>{var i=S1(),n=sd();t.exports=function(e){var t=i(e,"string");return n(t)?t:t+""}})),M1=K(((e,t)=>{var i=xn(),n=Cr(),r=i.document,a=n(r)&&n(r.createElement);t.exports=function(e){return a?r.createElement(e):{}}})),t3=K(((e,t)=>{var i=jn(),n=Xt(),r=M1();t.exports=!i&&!n((function(){return 7!=Object.defineProperty(r("div"),"a",{get:function(){return 7}}).a}))})),Us=K((e=>{var t=jn(),i=gr(),n=w1(),r=bo(),a=_s(),s=$u(),o=zr(),l=t3(),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])}})),n3=K(((e,t)=>{var i=jn(),n=Xt();t.exports=i&&n((function(){return 42!=Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype}))})),fr=K(((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")}})),Di=K((e=>{var t=jn(),i=t3(),n=n3(),r=fr(),a=$u(),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}})),Ks=K(((e,t)=>{var i=jn(),n=Di(),r=bo();t.exports=i?function(e,t,i){return n.f(e,t,r(1,i))}:function(e,t,i){return e[t]=i,e}})),Gf=K(((e,t)=>{var i=jn(),n=zr(),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}})),j_=K(((e,t)=>{var i=Qt(),n=Rr(),r=G_(),a=i(Function.toString);n(r.inspectSource)||(r.inspectSource=function(e){return a(e)}),t.exports=r.inspectSource})),u3=K(((e,t)=>{var i=xn(),n=Rr(),r=i.WeakMap;t.exports=n(r)&&/native code/.test(String(r))})),A1=K(((e,t)=>{var i=Vf(),n=zf(),r=i("keys");t.exports=function(e){return r[e]||(r[e]=n(e))}})),zm=K(((e,t)=>{t.exports={}})),ds=K(((e,t)=>{var i,n,r,a,s,o=u3(),l=xn(),h=Cr(),c=Ks(),u=zr(),d=G_(),p=A1(),f=zm(),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}}}})),Z_=K(((e,t)=>{var i=Qt(),n=Xt(),r=Rr(),a=zr(),s=jn(),o=Gf().CONFIGURABLE,l=j_(),h=ds(),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")})),Hi=K(((e,t)=>{var i=Rr(),n=Di(),r=Z_(),a=z_();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}})),g3=K(((e,t)=>{var i=Math.ceil,n=Math.floor;t.exports=Math.trunc||function(e){var t=+e;return(t>0?n:i)(t)}})),Ji=K(((e,t)=>{var i=g3();t.exports=function(e){var t=+e;return t!=t||0===t?0:i(t)}})),jl=K(((e,t)=>{var i=Ji(),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)}})),Ha=K(((e,t)=>{var i=Ji(),n=Math.min;t.exports=function(e){return e>0?n(i(e),9007199254740991):0}})),si=K(((e,t)=>{var i=Ha();t.exports=function(e){return i(e.length)}})),Gm=K(((e,t)=>{var i=_s(),n=jl(),r=si(),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)}})),y3=K(((e,t)=>{var i=Qt(),n=zr(),r=_s(),a=Gm().indexOf,s=zm(),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}})),K_=K(((e,t)=>{t.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]})),Zu=K((e=>{var t=y3(),i=K_().concat("length","prototype");e.f=Object.getOwnPropertyNames||function(e){return t(e,i)}})),C1=K((e=>{e.f=Object.getOwnPropertySymbols})),J_=K(((e,t)=>{var i=Si(),n=Qt(),r=Zu(),a=C1(),s=fr(),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}})),P1=K(((e,t)=>{var i=zr(),n=J_(),r=Us(),a=Di();t.exports=function(e,t,s){for(var o=n(t),l=a.f,h=r.f,c=0;c{var i=Xt(),n=Rr(),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})),tt=K(((e,t)=>{var i=xn(),n=Us().f,r=Ks(),a=Hi(),s=z_(),o=P1(),l=qm();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)}}})),Q_=K(((e,t)=>{var i={};i[Pr()("toStringTag")]="z",t.exports="[object z]"===String(i)})),Wl=K(((e,t)=>{var i=Q_(),n=Rr(),r=Zs(),a=Pr()("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}})),yr=K(((e,t)=>{var i=Wl(),n=String;t.exports=function(e){if("Symbol"===i(e))throw TypeError("Cannot convert a Symbol value to a string");return n(e)}})),jm=K(((e,t)=>{var i=y3(),n=K_();t.exports=Object.keys||function(e){return i(e,n)}})),tT=K((e=>{var t=jn(),i=n3(),n=Di(),r=fr(),a=_s(),s=jm();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}})),b3=K(((e,t)=>{var i=Si();t.exports=i("document","documentElement")})),Ua=K(((e,t)=>{var i,n=fr(),r=tT(),a=K_(),s=zm(),o=b3(),l=M1(),h=A1(),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)}})),Uc=K(((e,t)=>{"use strict";var i=$u(),n=Di(),r=bo();t.exports=function(e,t,a){var s=i(t);s in e?n.f(e,s,r(0,a)):e[s]=a}})),Wm=K(((e,t)=>{var i=jl(),n=si(),r=Uc(),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=Zs(),n=_s(),r=Zu().f,a=Wm(),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))}})),Cs=K(((e,t)=>{var i=Z_(),n=Di();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)}})),w3=K((e=>{var t=Pr();e.f=t})),sT=K(((e,t)=>{var i=xn();t.exports=i})),va=K(((e,t)=>{var i=sT(),n=zr(),r=w3(),a=Di().f;t.exports=function(e){var t=i.Symbol||(i.Symbol={});n(t,e)||a(t,e,{value:r.f(e)})}})),S3=K(((e,t)=>{var i=gr(),n=Si(),r=Pr(),a=Hi();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})}})),Va=K(((e,t)=>{var i=Di().f,n=zr(),r=Pr()("toStringTag");t.exports=function(e,t,a){e&&!a&&(e=e.prototype),e&&!n(e,r)&&i(e,r,{configurable:!0,value:t})}})),Ku=K(((e,t)=>{var i=Zs(),n=Qt();t.exports=function(e){if("Function"===i(e))return n(e)}})),Qo=K(((e,t)=>{var i=Ku(),n=Zi(),r=Um(),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)}}})),Ju=K(((e,t)=>{var i=Zs();t.exports=Array.isArray||function(e){return"Array"==i(e)}})),jf=K(((e,t)=>{var i=Qt(),n=Xt(),r=Rr(),a=Wl(),s=Si(),o=j_(),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})),c7=K(((e,t)=>{var i=Ju(),n=jf(),r=Cr(),a=Pr()("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}})),Xm=K(((e,t)=>{var i=c7();t.exports=function(e,t){return new(i(e))(0===t?0:t)}})),Ps=K(((e,t)=>{var i=Qo(),n=Qt(),r=Hf(),a=Qr(),s=si(),o=Xm(),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)}})),R7=K((()=>{"use strict";var e=tt(),t=xn(),i=gr(),n=Qt(),r=Ki(),a=jn(),s=Uf(),o=Xt(),l=zr(),h=Eo(),c=fr(),u=_s(),d=$u(),p=yr(),f=bo(),m=Ua(),g=jm(),v=Zu(),y=iT(),x=C1(),b=Us(),_=Di(),w=tT(),S=w1(),M=Hi(),E=Cs(),T=Vf(),A=A1(),C=zm(),P=zf(),R=Pr(),L=w3(),I=va(),D=S3(),O=Va(),k=ds(),N=Ps().forEach,F=A("hidden"),U="Symbol",B="prototype",z=k.set,H=k.getterFor(U),V=Object[B],j=t.Symbol,W=j&&j[B],G=t.TypeError,X=t.QObject,Y=b.f,q=_.f,K=y.f,J=S.f,Z=n([].push),$=T("symbols"),Q=T("op-symbols"),ee=T("wks"),te=!X||!X[B]||!X[B].findChild,ie=a&&o((function(){return 7!=m(q({},"a",{get:function(){return q(this,"a",{value:7}).a}})).a}))?function(e,t,i){var n=Y(V,t);n&&delete V[t],q(e,t,i),n&&e!==V&&q(V,t,n)}:q,ne=function(e,t){var i=$[e]=m(W);return z(i,{type:U,tag:e,description:t}),a||(i.description=t),i},re=function(e,t,i){e===V&&re(Q,t,i),c(e);var n=d(t);return c(i),l($,n)?(i.enumerable?(l(e,F)&&e[F][n]&&(e[F][n]=!1),i=m(i,{enumerable:f(0,!1)})):(l(e,F)||q(e,F,f(1,{})),e[F][n]=!0),ie(e,n,i)):q(e,n,i)},ae=function(e,t){c(e);var n=u(t),r=g(n).concat(he(n));return N(r,(function(t){(!a||i(se,n,t))&&re(e,t,n[t])})),e},se=function(e){var t=d(e),n=i(J,this,t);return!(this===V&&l($,t)&&!l(Q,t))&&(!(n||!l(this,t)||!l($,t)||l(this,F)&&this[F][t])||n)},oe=function(e,t){var i=u(e),n=d(t);if(i!==V||!l($,n)||l(Q,n)){var r=Y(i,n);return r&&l($,n)&&!(l(i,F)&&i[F][n])&&(r.enumerable=!0),r}},le=function(e){var t=K(u(e)),i=[];return N(t,(function(e){!l($,e)&&!l(C,e)&&Z(i,e)})),i},he=function(e){var t=e===V,i=K(t?Q:u(e)),n=[];return N(i,(function(e){l($,e)&&(!t||l(V,e))&&Z(n,$[e])})),n};s||(M(W=(j=function(){if(h(W,this))throw G("Symbol is not a constructor");var e=arguments.length&&void 0!==arguments[0]?p(arguments[0]):void 0,t=P(e),n=function(e){this===V&&i(n,Q,e),l(this,F)&&l(this[F],t)&&(this[F][t]=!1),ie(this,t,f(1,e))};return a&&te&&ie(V,t,{configurable:!0,set:n}),ne(t,e)})[B],"toString",(function(){return H(this).tag})),M(j,"withoutSetter",(function(e){return ne(P(e),e)})),S.f=se,_.f=re,w.f=ae,b.f=oe,v.f=y.f=le,x.f=he,L.f=function(e){return ne(R(e),e)},a&&(E(W,"description",{configurable:!0,get:function(){return H(this).description}}),r||M(V,"propertyIsEnumerable",se,{unsafe:!0}))),e({global:!0,constructor:!0,wrap:!0,forced:!s,sham:!s},{Symbol:j}),N(g(ee),(function(e){I(e)})),e({target:U,stat:!0,forced:!s},{useSetter:function(){te=!0},useSimple:function(){te=!1}}),e({target:"Object",stat:!0,forced:!s,sham:!a},{create:function(e,t){return void 0===t?m(e):ae(m(e),t)},defineProperty:re,defineProperties:ae,getOwnPropertyDescriptor:oe}),e({target:"Object",stat:!0,forced:!s},{getOwnPropertyNames:le}),D(),O(j,U),C[F]=!0})),U3=K(((e,t)=>{var i=Uf();t.exports=i&&!!Symbol.for&&!!Symbol.keyFor})),I7=K((()=>{var e=tt(),t=Si(),i=zr(),n=yr(),r=Vf(),a=U3(),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}})})),L7=K((()=>{var e=tt(),t=zr(),i=sd(),n=ad(),r=Vf(),a=U3(),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]}})})),_o=K(((e,t)=>{var i=Um(),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)})})),ld=K(((e,t)=>{var i=Qt();t.exports=i([].slice)})),G7=K(((e,t)=>{var i=Qt(),n=Ju(),r=Rr(),a=Zs(),s=yr(),o=i([].push);t.exports=function(e){if(r(e))return e;if(n(e)){for(var t=e.length,i=[],l=0;l{var e=tt(),t=Si(),i=_o(),n=gr(),r=Qt(),a=Xt(),s=Rr(),o=sd(),l=ld(),h=G7(),c=Uf(),u=String,d=t("JSON","stringify"),p=r(/./.exec),f=r("".charAt),m=r("".charCodeAt),g=r("".replace),v=r(1..toString),y=/[\uD800-\uDFFF]/g,x=/^[\uD800-\uDBFF]$/,b=/^[\uDC00-\uDFFF]$/,_=!c||a((function(){var e=t("Symbol")();return"[null]"!=d([e])||"{}"!=d({a:e})||"{}"!=d(Object(e))})),w=a((function(){return'"\\udf06\\ud834"'!==d("\udf06\ud834")||'"\\udead"'!==d("\udead")})),S=function(e,t){var r=l(arguments),a=h(t);if(s(a)||void 0!==e&&!o(e))return r[1]=function(e,t){if(s(a)&&(t=n(a,this,u(e),t)),!o(t))return 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=l(arguments),a=i(_?S:d,null,r);return w&&"string"==typeof a?g(a,y,M):a}})})),nq=K((()=>{var e=tt(),t=Uf(),i=Xt(),n=C1(),r=Qr();e({target:"Object",stat:!0,forced:!t||i((function(){n.f(1)}))},{getOwnPropertySymbols:function(e){var t=n.f;return t?t(r(e)):[]}})})),rq=K((()=>{R7(),I7(),L7(),z3(),nq()})),uq=K((()=>{"use strict";var e,t,i,n,r,a,s,o,l=tt(),h=jn(),c=xn(),u=Qt(),d=zr(),p=Rr(),f=Eo(),m=yr(),g=Cs(),v=P1(),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}))})),hq=K((()=>{va()("asyncIterator")})),dq=K((()=>{va()("hasInstance")})),fq=K((()=>{va()("isConcatSpreadable")})),pq=K((()=>{va()("iterator")})),mq=K((()=>{va()("match")})),gq=K((()=>{va()("matchAll")})),vq=K((()=>{va()("replace")})),yq=K((()=>{va()("search")})),xq=K((()=>{va()("species")})),bq=K((()=>{va()("split")})),Eq=K((()=>{var e=va(),t=S3();e("toPrimitive"),t()})),_q=K((()=>{var e=Si(),t=va(),i=Va();t("toStringTag"),i(e("Symbol"),"Symbol")})),Tq=K((()=>{va()("unscopables")})),Sq=K(((e,t)=>{var i=Qt(),n=Zi();t.exports=function(e,t,r){try{return i(n(Object.getOwnPropertyDescriptor(e,t)[r]))}catch(e){}}})),q3=K(((e,t)=>{var i=Rr(),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")}})),Xl=K(((e,t)=>{var i=Sq(),n=fr(),r=q3();t.exports=Object.setPrototypeOf||("__proto__"in{}?function(){var e,t=!1,a={};try{(e=i(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)})),j3=K(((e,t)=>{var i=Di().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}})}})),$f=K(((e,t)=>{var i=Rr(),n=Cr(),r=Xl();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}})),Zm=K(((e,t)=>{var i=yr();t.exports=function(e,t){return void 0===e?arguments.length<2?"":t:i(e)}})),W3=K(((e,t)=>{var i=Cr(),n=Ks();t.exports=function(e,t){i(t)&&"cause"in t&&n(e,"cause",t.cause)}})),fT=K(((e,t)=>{var i=Qt(),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}})),X3=K(((e,t)=>{var i=Xt(),n=bo();t.exports=!i((function(){var e=Error("a");return!("stack"in e)||(Object.defineProperty(e,"stack",n(1,7)),7!==e.stack)}))})),Y3=K(((e,t)=>{var i=Ks(),n=fT(),r=X3(),a=Error.captureStackTrace;t.exports=function(e,t,s,o){r&&(a?a(e,t):i(e,"stack",n(s,o)))}})),$3=K(((e,t)=>{"use strict";var i=Si(),n=zr(),r=Ks(),a=Eo(),s=Xl(),o=P1(),l=j3(),h=$f(),c=Zm(),u=W3(),d=Y3(),p=jn(),f=Ki();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}}})),$q=K((()=>{var e=tt(),t=xn(),i=_o(),n=$3(),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)}}))})),J3=K(((e,t)=>{"use strict";var i=jn(),n=Xt(),r=fr(),a=Ua(),s=Zm(),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})),e9=K((()=>{var e=Hi(),t=J3(),i=Error.prototype;i.toString!==t&&e(i,"toString",t)})),gT=K(((e,t)=>{var i=Xt();t.exports=!i((function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype}))})),To=K(((e,t)=>{var i=zr(),n=Rr(),r=Qr(),a=A1(),s=gT(),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}})),Km=K(((e,t)=>{t.exports={}})),vT=K(((e,t)=>{var i=Pr(),n=Km(),r=i("iterator"),a=Array.prototype;t.exports=function(e){return void 0!==e&&(n.Array===e||a[r]===e)}})),Jm=K(((e,t)=>{var i=Wl(),n=Hc(),r=ga(),a=Km(),s=Pr()("iterator");t.exports=function(e){if(!r(e))return n(e,s)||n(e,"@@iterator")||a[i(e)]}})),H1=K(((e,t)=>{var i=gr(),n=Zi(),r=fr(),a=ad(),s=Jm(),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")}})),e2=K(((e,t)=>{var i=gr(),n=fr(),r=Hc();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}})),Yl=K(((e,t)=>{var i=Qo(),n=gr(),r=fr(),a=ad(),s=vT(),o=si(),l=Eo(),h=H1(),c=Jm(),u=e2(),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)}})),g9=K((()=>{"use strict";var e=tt(),t=Eo(),i=To(),n=Xl(),r=P1(),a=Ua(),s=Ks(),o=bo(),l=W3(),h=Y3(),c=Yl(),u=Zm(),d=Pr()("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})})),v9=K((()=>{g9()})),E9=K((()=>{var e=tt(),t=Si(),i=_o(),n=Xt(),r=$3(),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)})})),ya=K(((e,t)=>{var i=Pr(),n=Ua(),r=Di().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}})),T9=K((()=>{"use strict";var e=tt(),t=Qr(),i=si(),n=Ji(),r=ya();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")})),Kf=K(((e,t)=>{var i=TypeError;t.exports=function(e){if(e>9007199254740991)throw i("Maximum allowed index exceeded");return e}})),eg=K(((e,t)=>{var i=Xt(),n=Pr(),r=Bc(),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}))}})),C9=K((()=>{"use strict";var e=tt(),t=Xt(),i=Ju(),n=Cr(),r=Qr(),a=si(),s=Kf(),o=Uc(),l=Xm(),h=eg(),c=Pr(),u=Bc(),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=ad(),n=TypeError;t.exports=function(e,t){if(!delete e[t])throw n("Cannot delete property "+i(t)+" of "+i(e))}})),l2=K(((e,t)=>{"use strict";var i=Qr(),n=jl(),r=si(),a=U1(),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}})),L9=K((()=>{var e=tt(),t=l2(),i=ya();e({target:"Array",proto:!0},{copyWithin:t}),i("copyWithin")})),zc=K(((e,t)=>{"use strict";var i=Xt();t.exports=function(e,t){var n=[][e];return!!n&&i((function(){n.call(null,t||function(){return 1},1)}))}})),k9=K((()=>{"use strict";var e=tt(),t=Ps().every;e({target:"Array",proto:!0,forced:!zc()("every")},{every:function(e){return t(this,e,arguments.length>1?arguments[1]:void 0)}})})),ET=K(((e,t)=>{"use strict";var i=Qr(),n=jl(),r=si();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}})),B9=K((()=>{var e=tt(),t=ET(),i=ya();e({target:"Array",proto:!0},{fill:t}),i("fill")})),H9=K((()=>{"use strict";var e=tt(),t=Ps().filter;e({target:"Array",proto:!0,forced:!eg()("filter")},{filter:function(e){return t(this,e,arguments.length>1?arguments[1]:void 0)}})})),V9=K((()=>{"use strict";var e=tt(),t=Ps().find,i=ya(),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)})),G9=K((()=>{"use strict";var e=tt(),t=Ps().findIndex,i=ya(),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)})),V1=K(((e,t)=>{var i=Qo(),n=Hf(),r=Qr(),a=si(),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)}})),W9=K((()=>{"use strict";var e=tt(),t=V1().findLast,i=ya();e({target:"Array",proto:!0},{findLast:function(e){return t(this,e,arguments.length>1?arguments[1]:void 0)}}),i("findLast")})),X9=K((()=>{"use strict";var e=tt(),t=V1().findLastIndex,i=ya();e({target:"Array",proto:!0},{findLastIndex:function(e){return t(this,e,arguments.length>1?arguments[1]:void 0)}}),i("findLastIndex")})),h2=K(((e,t)=>{"use strict";var i=Ju(),n=si(),r=Kf(),a=Qo(),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})),Z9=K((()=>{"use strict";var e=tt(),t=h2(),i=Qr(),n=si(),r=Ji(),a=Xm();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}})})),K9=K((()=>{"use strict";var e=tt(),t=h2(),i=Zi(),n=Qr(),r=si(),a=Xm();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}})})),d2=K(((e,t)=>{"use strict";var i=Ps().forEach,n=zc()("forEach");t.exports=n?[].forEach:function(e){return i(this,e,arguments.length>1?arguments[1]:void 0)}})),ej=K((()=>{"use strict";var e=tt(),t=d2();e({target:"Array",proto:!0,forced:[].forEach!=t},{forEach:t})})),nj=K(((e,t)=>{var i=fr(),n=e2();t.exports=function(e,t,r,a){try{return a?t(i(r)[0],r[1]):t(r)}catch(t){n(e,"throw",t)}}})),f2=K(((e,t)=>{"use strict";var i=Qo(),n=gr(),r=Qr(),a=nj(),s=vT(),o=jf(),l=si(),h=Uc(),c=H1(),u=Jm(),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}})),z1=K(((e,t)=>{var i,n,r=Pr()("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}})),uj=K((()=>{var e=tt(),t=f2();e({target:"Array",stat:!0,forced:!z1()((function(e){Array.from(e)}))},{from:t})})),hj=K((()=>{"use strict";var e=tt(),t=Gm().includes,i=Xt(),n=ya();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")})),fj=K((()=>{"use strict";var e=tt(),t=Ku(),i=Gm().indexOf,n=zc(),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)}})})),pj=K((()=>{tt()({target:"Array",stat:!0},{isArray:Ju()})})),x2=K(((e,t)=>{"use strict";var i,n,r,a=Xt(),s=Rr(),o=Cr(),l=Ua(),h=To(),c=Hi(),u=Pr(),d=Ki(),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}})),_T=K(((e,t)=>{"use strict";var i=x2().IteratorPrototype,n=Ua(),r=bo(),a=Va(),s=Km(),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}})),ST=K(((e,t)=>{"use strict";var i=tt(),n=gr(),r=Ki(),a=Gf(),s=Rr(),o=_T(),l=To(),h=Xl(),c=Va(),u=Ks(),d=Hi(),p=Pr(),f=Km(),m=x2(),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 D)return D[e];switch(e){case _:case w:case S:return function(){return new a(this,e)}}return function(){return new a(this)}},L=t+" Iterator",I=!1,D=e.prototype,O=D[b]||D["@@iterator"]||m&&D[m],k=!x&&O||R(m),N="Array"==t&&D.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,L,!0,!0),r&&(f[L]=M)),g&&m==w&&O&&O.name!==w&&(!r&&v?u(D,"name",w):(I=!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||I||!(P in D))&&d(D,P,C[P]);else i({target:t,proto:!0,forced:x||I},C);return(!r||T)&&D[b]!==k&&d(D,b,k,{name:m}),f[t]=k,C}})),j1=K(((e,t)=>{t.exports=function(e,t){return{value:e,done:t}}})),W1=K(((e,t)=>{"use strict";var i=_s(),n=ya(),r=Km(),a=ds(),s=Di().f,o=ST(),l=j1(),h=Ki(),c=jn(),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){}})),kj=K((()=>{"use strict";var e=tt(),t=Qt(),i=Hf(),n=_s(),r=zc(),a=t([].join);e({target:"Array",proto:!0,forced:i!=Object||!r("join",",")},{join:function(e){return a(n(this),void 0===e?",":e)}})})),T2=K(((e,t)=>{"use strict";var i=_o(),n=_s(),r=Ji(),a=si(),s=zc(),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})),Hj=K((()=>{var e=tt(),t=T2();e({target:"Array",proto:!0,forced:t!==[].lastIndexOf},{lastIndexOf:t})})),Uj=K((()=>{"use strict";var e=tt(),t=Ps().map;e({target:"Array",proto:!0,forced:!eg()("map")},{map:function(e){return t(this,e,arguments.length>1?arguments[1]:void 0)}})})),zj=K((()=>{"use strict";var e=tt(),t=Xt(),i=jf(),n=Uc(),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}})})),AT=K(((e,t)=>{"use strict";var i=jn(),n=Ju(),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}})),qj=K((()=>{"use strict";var e=tt(),t=Qr(),i=si(),n=AT(),r=Kf();e({target:"Array",proto:!0,arity:1,forced:Xt()((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=Zi(),n=Qr(),r=Hf(),a=si(),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)}})),Gc=K(((e,t)=>{var i=Zs();t.exports="undefined"!=typeof process&&"process"==i(process)})),$j=K((()=>{"use strict";var e=tt(),t=X1().left,i=zc(),n=Bc();e({target:"Array",proto:!0,forced:!Gc()&&n>79&&n<83||!i("reduce")},{reduce:function(e){var i=arguments.length;return t(this,e,i,i>1?arguments[1]:void 0)}})})),Kj=K((()=>{"use strict";var e=tt(),t=X1().right,i=zc(),n=Bc();e({target:"Array",proto:!0,forced:!Gc()&&n>79&&n<83||!i("reduceRight")},{reduceRight:function(e){return t(this,e,arguments.length,arguments.length>1?arguments[1]:void 0)}})})),Qj=K((()=>{"use strict";var e=tt(),t=Qt(),i=Ju(),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)}})})),nW=K((()=>{"use strict";var e=tt(),t=Ju(),i=jf(),n=Cr(),r=jl(),a=si(),s=_s(),o=Uc(),l=Pr(),h=eg(),c=ld(),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=tt(),t=Ps().some;e({target:"Array",proto:!0,forced:!zc()("some")},{some:function(e){return t(this,e,arguments.length>1?arguments[1]:void 0)}})})),RT=K(((e,t)=>{var i=Wm(),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=Fc().match(/firefox\/(\d+)/i);t.exports=!!i&&+i[1]})),A2=K(((e,t)=>{var i=Fc();t.exports=/MSIE|Trident/.test(i)})),CT=K(((e,t)=>{var i=Fc().match(/AppleWebKit\/(\d+)\./);t.exports=!!i&&+i[1]})),xW=K((()=>{"use strict";var e=tt(),t=Qt(),i=Zi(),n=Qr(),r=si(),a=U1(),s=yr(),o=Xt(),l=RT(),h=zc(),c=M2(),u=A2(),d=Bc(),p=CT(),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=Si(),n=Cs(),r=Pr(),a=jn(),s=r("species");t.exports=function(e){var t=i(e);a&&t&&!t[s]&&n(t,s,{configurable:!0,get:function(){return this}})}})),_W=K((()=>{Jf()("Array")})),TW=K((()=>{"use strict";var e=tt(),t=Qr(),i=jl(),n=Ji(),r=si(),a=AT(),s=Kf(),o=Xm(),l=Uc(),h=U1(),c=eg()("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{var i=si();t.exports=function(e,t){for(var n=i(e),r=new t(n),a=0;a{"use strict";var e=tt(),t=P2(),i=_s(),n=ya(),r=Array;e({target:"Array",proto:!0},{toReversed:function(){return t(i(this),r)}}),n("toReversed")})),PT=K(((e,t)=>{var i=si();t.exports=function(e,t){for(var n=0,r=i(t),a=new e(r);r>n;)a[n]=t[n++];return a}})),RW=K(((e,t)=>{var i=xn();t.exports=function(e){return i[e].prototype}})),CW=K((()=>{"use strict";var e=tt(),t=Qt(),i=Zi(),n=_s(),r=PT(),a=RW(),s=ya(),o=Array,l=t(a("Array").sort);e({target:"Array",proto:!0},{toSorted:function(e){void 0!==e&&i(e);var t=n(this),a=r(o,t);return l(a,e)}}),s("toSorted")})),PW=K((()=>{"use strict";var e=tt(),t=ya(),i=Kf(),n=si(),r=jl(),a=_s(),s=Ji(),o=Array,l=Math.max,h=Math.min;e({target:"Array",proto:!0},{toSpliced:function(e,t){var c,u,d,p,f=a(this),m=n(f),g=r(e,m),v=arguments.length,y=0;for(0===v?c=u=0:1===v?(c=0,u=m-g):(c=v-2,u=h(l(s(t),0),m-g)),d=i(m+c-u),p=o(d);y{ya()("flat")})),DW=K((()=>{ya()("flatMap")})),LW=K((()=>{"use strict";var e=tt(),t=Qr(),i=si(),n=AT(),r=U1(),a=Kf();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{var i=si(),n=Ji(),r=RangeError;t.exports=function(e,t,a,s){var o=i(e),l=n(a),h=l<0?o+l:l;if(h>=o||h<0)throw r("Incorrect index");for(var c=new t(o),u=0;u{"use strict";var e=tt(),t=I2(),i=_s(),n=Array;e({target:"Array",proto:!0},{with:function(e,r){return t(i(this),n,e,r)}})})),IT=K(((e,t)=>{t.exports="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof DataView})),tg=K(((e,t)=>{var i=Hi();t.exports=function(e,t,n){for(var r in t)i(e,r,t[r],n);return e}})),$l=K(((e,t)=>{var i=Eo(),n=TypeError;t.exports=function(e,t){if(i(t,e))return e;throw n("Incorrect invocation")}})),D2=K(((e,t)=>{var i=Ji(),n=Ha(),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}})),VW=K(((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)}}})),Z1=K(((e,t)=>{"use strict";var i,n,r,a,s,o,l=xn(),h=Qt(),c=jn(),u=IT(),d=Gf(),p=Ks(),f=Cs(),m=tg(),g=Xt(),v=$l(),y=Ji(),x=Ha(),b=D2(),_=VW(),w=To(),S=Xl(),M=Zu().f,E=ET(),T=Wm(),A=Va(),C=ds(),P=d.PROPER,R=d.CONFIGURABLE,L="ArrayBuffer",I="DataView",D="prototype",O="Wrong index",k=C.getterFor(L),N=C.getterFor(I),F=C.set,U=l[L],B=U,z=B&&B[D],H=l[I],V=H&&H[D],j=Object.prototype,W=l.Array,G=l.RangeError,X=h(E),Y=h([].reverse),q=_.pack,K=_.unpack,J=function(e){return[255&e]},Z=function(e){return[255&e,e>>8&255]},$=function(e){return[255&e,e>>8&255,e>>16&255,e>>24&255]},Q=function(e){return e[3]<<24|e[2]<<16|e[1]<<8|e[0]},ee=function(e){return q(e,23,4)},te=function(e){return q(e,52,8)},ie=function(e,t,i){f(e[D],t,{configurable:!0,get:function(){return i(this)[t]}})},ne=function(e,t,i,n){var r=b(i),a=N(e);if(r+t>a.byteLength)throw G(O);var s=a.bytes,o=r+a.byteOffset,l=T(s,o,o+t);return n?l:Y(l)},re=function(e,t,i,n,r,a){var s=b(i),o=N(e);if(s+t>o.byteLength)throw G(O);for(var l=o.bytes,h=s+o.byteOffset,c=n(+r),u=0;ur;)(a=n[r++])in B||p(B,a,U[a]);z.constructor=B}S&&w(V)!==j&&S(V,j),s=new H(new B(2)),o=h(V.setInt8),s.setInt8(0,2147483648),s.setInt8(1,2147483649),(s.getInt8(0)||!s.getInt8(1))&&m(V,{setInt8:function(e,t){o(this,e,t<<24>>24)},setUint8:function(e,t){o(this,e,t<<24>>24)}},{unsafe:!0})}else z=(B=function(e){v(this,z);var t=b(e);F(this,{type:L,bytes:X(W(t),0),byteLength:t}),c||(this.byteLength=t,this.detached=!1)})[D],V=(H=function(e,t,i){v(this,V),v(e,z);var n=k(e),r=n.byteLength,a=y(t);if(a<0||a>r)throw G("Wrong offset");if(a+(i=void 0===i?r-a:x(i))>r)throw G("Wrong length");F(this,{type:I,buffer:e,byteLength:i,byteOffset:a,bytes:n.bytes}),c||(this.buffer=e,this.byteLength=i,this.byteOffset=a)})[D],c&&(ie(B,"byteLength",k),ie(H,"buffer",N),ie(H,"byteLength",N),ie(H,"byteOffset",N)),m(V,{getInt8:function(e){return ne(this,1,e)[0]<<24>>24},getUint8:function(e){return ne(this,1,e)[0]},getInt16:function(e){var t=ne(this,2,e,arguments.length>1?arguments[1]:void 0);return(t[1]<<8|t[0])<<16>>16},getUint16:function(e){var t=ne(this,2,e,arguments.length>1?arguments[1]:void 0);return t[1]<<8|t[0]},getInt32:function(e){return Q(ne(this,4,e,arguments.length>1?arguments[1]:void 0))},getUint32:function(e){return Q(ne(this,4,e,arguments.length>1?arguments[1]:void 0))>>>0},getFloat32:function(e){return K(ne(this,4,e,arguments.length>1?arguments[1]:void 0),23)},getFloat64:function(e){return K(ne(this,8,e,arguments.length>1?arguments[1]:void 0),52)},setInt8:function(e,t){re(this,1,e,J,t)},setUint8:function(e,t){re(this,1,e,J,t)},setInt16:function(e,t){re(this,2,e,Z,t,arguments.length>2?arguments[2]:void 0)},setUint16:function(e,t){re(this,2,e,Z,t,arguments.length>2?arguments[2]:void 0)},setInt32:function(e,t){re(this,4,e,$,t,arguments.length>2?arguments[2]:void 0)},setUint32:function(e,t){re(this,4,e,$,t,arguments.length>2?arguments[2]:void 0)},setFloat32:function(e,t){re(this,4,e,ee,t,arguments.length>2?arguments[2]:void 0)},setFloat64:function(e,t){re(this,8,e,te,t,arguments.length>2?arguments[2]:void 0)}});A(B,L),A(H,I),t.exports={ArrayBuffer:B,DataView:H}})),oX=K((()=>{"use strict";var e=tt(),t=xn(),i=Z1(),n=Jf(),r="ArrayBuffer",a=i[r];e({global:!0,constructor:!0,forced:t[r]!==a},{ArrayBuffer:a}),n(r)})),Er=K(((e,t)=>{"use strict";var i,n,r,a=IT(),s=jn(),o=xn(),l=Rr(),h=Cr(),c=zr(),u=Wl(),d=ad(),p=Ks(),f=Hi(),m=Cs(),g=Eo(),v=To(),y=Xl(),x=Pr(),b=zf(),_=ds(),w=_.enforce,S=_.get,M=o.Int8Array,E=M&&M.prototype,T=o.Uint8ClampedArray,A=T&&T.prototype,C=M&&v(M),P=E&&v(E),R=Object.prototype,L=o.TypeError,I=x("toStringTag"),D=b("TYPED_ARRAY_TAG"),O="TypedArrayConstructor",k=a&&!!y&&"Opera"!==u(o.opera),N=!1,F={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8},U={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(F,t)||c(U,t)};for(i in F)(r=(n=o[i])&&n.prototype)?w(r)[O]=n:k=!1;for(i in U)(r=(n=o[i])&&n.prototype)&&(w(r)[O]=n);if((!k||!l(C)||C===Function.prototype)&&(C=function(){throw L("Incorrect invocation")},k))for(i in F)o[i]&&y(o[i],C);if((!k||!P||P===R)&&(P=C.prototype,k))for(i in F)o[i]&&y(o[i].prototype,P);if(k&&v(A)!==P&&y(A,P),s&&!c(P,I))for(i in N=!0,m(P,I,{configurable:!0,get:function(){return h(this)?this[D]:void 0}}),F)o[i]&&p(o[i],D,i);t.exports={NATIVE_ARRAY_BUFFER_VIEWS:k,TYPED_ARRAY_TAG:N&&D,aTypedArray:function(e){if(z(e))return e;throw L("Target is not a typed array")},aTypedArrayConstructor:function(e){if(l(e)&&(!y||g(C,e)))return e;throw L(d(e)+" is not a typed array constructor")},exportTypedArrayMethod:function(e,t,i,n){if(s){if(i)for(var r in F){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 F)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 F)(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(F,t)||c(U,t)},isTypedArray:z,TypedArray:C,TypedArrayPrototype:P}})),xX=K((()=>{var e=tt(),t=Er();e({target:"ArrayBuffer",stat:!0,forced:!t.NATIVE_ARRAY_BUFFER_VIEWS},{isView:t.isView})})),GT=K(((e,t)=>{var i=jf(),n=ad(),r=TypeError;t.exports=function(e){if(i(e))return e;throw r(n(e)+" is not a constructor")}})),ep=K(((e,t)=>{var i=fr(),n=GT(),r=ga(),a=Pr()("species");t.exports=function(e,t){var s,o=i(e).constructor;return void 0===o||r(s=i(o)[a])?t:n(s)}})),RX=K((()=>{"use strict";var e=tt(),t=Ku(),i=Xt(),n=Z1(),r=fr(),a=jl(),s=Ha(),o=ep(),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=tt(),t=Z1();e({global:!0,constructor:!0,forced:!IT()},{DataView:t.DataView})})),PX=K((()=>{CX()})),IX=K((()=>{"use strict";var e=tt(),t=Qt(),i=Xt()((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}})})),LX=K((()=>{var e=tt(),t=Qt(),i=Date,n=t(i.prototype.getTime);e({target:"Date",stat:!0},{now:function(){return n(new i)}})})),NX=K((()=>{"use strict";var e=tt(),t=Qt(),i=Ji(),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)}})})),FX=K((()=>{tt()({target:"Date",proto:!0},{toGMTString:Date.prototype.toUTCString})})),K1=K(((e,t)=>{"use strict";var i=Ji(),n=yr(),r=hs(),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}})),qT=K(((e,t)=>{var i=Qt(),n=Ha(),r=yr(),a=K1(),s=hs(),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)}})),jX=K(((e,t)=>{"use strict";var i=Qt(),n=Xt(),r=qT().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})),XX=K((()=>{var e=tt(),t=jX();e({target:"Date",proto:!0,forced:Date.prototype.toISOString!==t},{toISOString:t})})),YX=K((()=>{"use strict";var e=tt(),t=Xt(),i=Qr(),n=S1();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}})})),ZX=K(((e,t)=>{"use strict";var i=fr(),n=JI(),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)}})),QX=K((()=>{var e=zr(),t=Hi(),i=ZX(),n=Pr()("toPrimitive"),r=Date.prototype;e(r,n)||t(r,n,i)})),rY=K((()=>{var e=Qt(),t=Hi(),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}))})),sY=K((()=>{"use strict";var e=tt(),t=Qt(),i=yr(),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=Qt(),n=Zi(),r=Cr(),a=zr(),s=ld(),o=Um(),l=Function,h=i([].concat),c=i([].join),u={};t.exports=o?l.bind:function(e){var t=n(this),i=t.prototype,o=s(arguments,1),d=function(){var i=h(o,s(arguments));return this instanceof d?function(e,t,i){if(!a(u,t)){for(var n=[],r=0;r{var e=tt(),t=tD();e({target:"Function",proto:!0,forced:Function.bind!==t},{bind:t})})),pY=K((()=>{"use strict";var e=Rr(),t=Cr(),i=Di(),n=To(),r=Pr(),a=Z_(),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)})})),yY=K((()=>{var e=jn(),t=Gf().EXISTS,i=Qt(),n=Cs(),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""}}})})),xY=K((()=>{var e=tt(),t=xn();e({global:!0,forced:t.globalThis!==t},{globalThis:t})})),bY=K((()=>{var e=xn();Va()(e.JSON,"JSON",!0)})),jT=K(((e,t)=>{var i=Xt();t.exports=i((function(){if("function"==typeof ArrayBuffer){var e=new ArrayBuffer(8);Object.isExtensible(e)&&Object.defineProperty(e,"a",{value:8})}}))})),XT=K(((e,t)=>{var i=Xt(),n=Cr(),r=Zs(),a=jT(),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})),np=K(((e,t)=>{var i=Xt();t.exports=!i((function(){return Object.isExtensible(Object.preventExtensions({}))}))})),gd=K(((e,t)=>{var i=tt(),n=Qt(),r=zm(),a=Cr(),s=zr(),o=Di().f,l=Zu(),h=iT(),c=XT(),u=zf(),d=np(),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=tt(),n=xn(),r=Qt(),a=qm(),s=Hi(),o=gd(),l=Yl(),h=$l(),c=Rr(),u=ga(),d=Cr(),p=Xt(),f=z1(),m=Va(),g=$f();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}})),uD=K(((e,t)=>{"use strict";var i=Ua(),n=Cs(),r=tg(),a=Qo(),s=$l(),o=ga(),l=Yl(),h=ST(),c=j1(),u=Jf(),d=jn(),p=gd().fastKey,f=ds(),m=f.set,g=f.getterFor;t.exports={getConstructor:function(e,t,h,c){var u=e((function(e,n){s(e,f),m(e,{type:t,index:i(null),first:void 0,last:void 0,size:0}),d||(e.size=0),o(n)||l(n,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&&n(f,"size",{configurable:!0,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)}}})),kY=K((()=>{"use strict";Q1()("Map",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),uD())})),NY=K((()=>{kY()})),hD=K(((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)}})),HY=K((()=>{var e=tt(),t=hD(),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))}})})),zY=K((()=>{var e=tt(),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}})})),qY=K((()=>{var e=tt(),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}})})),$T=K(((e,t)=>{t.exports=Math.sign||function(e){var t=+e;return 0==t||t!=t?t:t<0?-1:1}})),WY=K((()=>{var e=tt(),t=$T(),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)}})})),XY=K((()=>{var e=tt(),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}})})),ny=K(((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})),ZY=K((()=>{var e=tt(),t=ny(),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)}})})),JY=K((()=>{var e=tt(),t=ny();e({target:"Math",stat:!0,forced:t!=Math.expm1},{expm1:t})})),e$=K(((e,t)=>{var i=$T(),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}})),t$=K((()=>{tt()({target:"Math",stat:!0},{fround:e$()})})),r$=K((()=>{var e=tt(),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)}})})),s$=K((()=>{var e=tt(),t=Xt(),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)}})})),gD=K(((e,t)=>{var i=Math.log,n=Math.LOG10E;t.exports=Math.log10||function(e){return i(e)*n}})),o$=K((()=>{tt()({target:"Math",stat:!0},{log10:gD()})})),l$=K((()=>{tt()({target:"Math",stat:!0},{log1p:hD()})})),c$=K((()=>{var e=tt(),t=Math.log,i=Math.LN2;e({target:"Math",stat:!0},{log2:function(e){return t(e)/i}})})),u$=K((()=>{tt()({target:"Math",stat:!0},{sign:$T()})})),f$=K((()=>{var e=tt(),t=Xt(),i=ny(),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)}})})),g$=K((()=>{var e=tt(),t=ny(),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))}})})),v$=K((()=>{Va()(Math,"Math",!0)})),y$=K((()=>{tt()({target:"Math",stat:!0},{trunc:g3()})})),ry=K(((e,t)=>{var i=Qt();t.exports=i(1..valueOf)})),iy=K(((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"})),rp=K(((e,t)=>{var i=Qt(),n=hs(),r=yr(),a=iy(),s=i("".replace),o=RegExp("^["+a+"]+"),l=RegExp("(^|[^"+a+"])["+a+"]+$"),h=function(e){return function(t){var i=r(n(t));return 1&e&&(i=s(i,o,"")),2&e&&(i=s(i,l,"$1")),i}};t.exports={start:h(1),end:h(2),trim:h(3)}})),C$=K((()=>{"use strict";var e=tt(),t=Ki(),i=jn(),n=xn(),r=sT(),a=Qt(),s=qm(),o=zr(),l=$f(),h=Eo(),c=sd(),u=S1(),d=Xt(),p=Zu().f,f=Us().f,m=Di().f,g=ry(),v=rp().trim,y="Number",x=n[y],b=r[y],_=x.prototype,w=n.TypeError,S=a("".slice),M=a("".charCodeAt),E=s(y,!x(" 0o1")||!x("0b1")||x("+0x1")),T=function(e){var t,i=arguments.length<1?0:x(function(e){var t=u(e,"number");return"bigint"==typeof t?t: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)}(e));return h(_,t=this)&&d((function(){g(t)}))?l(Object(i),this,T):i};T.prototype=_,E&&!t&&(_.constructor=T),e({global:!0,constructor:!0,wrap:!0,forced:E},{Number:T});var A=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&&A(r[y],b),(E||t)&&A(r[y],x)})),P$=K((()=>{tt()({target:"Number",stat:!0,nonConfigurable:!0,nonWritable:!0},{EPSILON:Math.pow(2,-52)})})),D$=K(((e,t)=>{var i=xn().isFinite;t.exports=Number.isFinite||function(e){return"number"==typeof e&&i(e)}})),L$=K((()=>{tt()({target:"Number",stat:!0},{isFinite:D$()})})),ew=K(((e,t)=>{var i=Cr(),n=Math.floor;t.exports=Number.isInteger||function(e){return!i(e)&&isFinite(e)&&n(e)===e}})),k$=K((()=>{tt()({target:"Number",stat:!0},{isInteger:ew()})})),N$=K((()=>{tt()({target:"Number",stat:!0},{isNaN:function(e){return e!=e}})})),F$=K((()=>{var e=tt(),t=ew(),i=Math.abs;e({target:"Number",stat:!0},{isSafeInteger:function(e){return t(e)&&i(e)<=9007199254740991}})})),B$=K((()=>{tt()({target:"Number",stat:!0,nonConfigurable:!0,nonWritable:!0},{MAX_SAFE_INTEGER:9007199254740991})})),H$=K((()=>{tt()({target:"Number",stat:!0,nonConfigurable:!0,nonWritable:!0},{MIN_SAFE_INTEGER:-9007199254740991})})),TD=K(((e,t)=>{var i=xn(),n=Xt(),r=Qt(),a=yr(),s=rp().trim,o=iy(),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})),j$=K((()=>{var e=tt(),t=TD();e({target:"Number",stat:!0,forced:Number.parseFloat!=t},{parseFloat:t})})),wD=K(((e,t)=>{var i=xn(),n=Xt(),r=Qt(),a=yr(),s=rp().trim,o=iy(),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})),Q$=K((()=>{var e=tt(),t=wD();e({target:"Number",stat:!0,forced:Number.parseInt!=t},{parseInt:t})})),iZ=K((()=>{"use strict";var e=tt(),t=Qt(),i=Ji(),n=ry(),r=K1(),a=gD(),s=Xt(),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+_}})})),uZ=K((()=>{"use strict";var e=tt(),t=Qt(),i=Ji(),n=ry(),r=K1(),a=Xt(),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}})})),fZ=K((()=>{"use strict";var e=tt(),t=Qt(),i=Xt(),n=ry(),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)}})})),ID=K(((e,t)=>{"use strict";var i=jn(),n=Qt(),r=gr(),a=Xt(),s=jm(),o=C1(),l=w1(),h=Qr(),c=Hf(),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})),yZ=K((()=>{var e=tt(),t=ID();e({target:"Object",stat:!0,arity:2,forced:Object.assign!==t},{assign:t})})),xZ=K((()=>{tt()({target:"Object",stat:!0,sham:!jn()},{create:Ua()})})),ly=K(((e,t)=>{"use strict";var i=Ki(),n=xn(),r=Xt(),a=CT();t.exports=i||!r((function(){if(!(a&&a<535)){var e=Math.random();__defineSetter__.call(null,e,(function(){})),delete n[e]}}))})),_Z=K((()=>{"use strict";var e=tt(),t=jn(),i=ly(),n=Zi(),r=Qr(),a=Di();t&&e({target:"Object",proto:!0,forced:i},{__defineGetter__:function(e,t){a.f(r(this),e,{get:n(t),enumerable:!0,configurable:!0})}})})),wZ=K((()=>{var e=tt(),t=jn(),i=tT().f;e({target:"Object",stat:!0,forced:Object.defineProperties!==i,sham:!t},{defineProperties:i})})),MZ=K((()=>{var e=tt(),t=jn(),i=Di().f;e({target:"Object",stat:!0,forced:Object.defineProperty!==i,sham:!t},{defineProperty:i})})),AZ=K((()=>{"use strict";var e=tt(),t=jn(),i=ly(),n=Zi(),r=Qr(),a=Di();t&&e({target:"Object",proto:!0,forced:i},{__defineSetter__:function(e,t){a.f(r(this),e,{set:n(t),enumerable:!0,configurable:!0})}})})),DD=K(((e,t)=>{var i=jn(),n=Qt(),r=jm(),a=_s(),s=n(w1().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)}})),IZ=K((()=>{var e=tt(),t=DD().entries;e({target:"Object",stat:!0},{entries:function(e){return t(e)}})})),DZ=K((()=>{var e=tt(),t=np(),i=Xt(),n=Cr(),r=gd().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}})})),LZ=K((()=>{var e=tt(),t=Yl(),i=Uc();e({target:"Object",stat:!0},{fromEntries:function(e){var n={};return t(e,(function(e,t){i(n,e,t)}),{AS_ENTRIES:!0}),n}})})),NZ=K((()=>{var e=tt(),t=Xt(),i=_s(),n=Us().f,r=jn();e({target:"Object",stat:!0,forced:!r||t((function(){n(1)})),sham:!r},{getOwnPropertyDescriptor:function(e,t){return n(i(e),t)}})})),FZ=K((()=>{var e=tt(),t=jn(),i=J_(),n=_s(),r=Us(),a=Uc();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}})})),BZ=K((()=>{var e=tt(),t=Xt(),i=iT().f;e({target:"Object",stat:!0,forced:t((function(){return!Object.getOwnPropertyNames(1)}))},{getOwnPropertyNames:i})})),UZ=K((()=>{var e=tt(),t=Xt(),i=Qr(),n=To(),r=gT();e({target:"Object",stat:!0,forced:t((function(){n(1)})),sham:!r},{getPrototypeOf:function(e){return n(i(e))}})})),VZ=K((()=>{tt()({target:"Object",stat:!0},{hasOwn:zr()})})),OD=K(((e,t)=>{t.exports=Object.is||function(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}})),GZ=K((()=>{tt()({target:"Object",stat:!0},{is:OD()})})),jZ=K((()=>{var e=tt(),t=XT();e({target:"Object",stat:!0,forced:Object.isExtensible!==t},{isExtensible:t})})),XZ=K((()=>{var e=tt(),t=Xt(),i=Cr(),n=Zs(),r=jT(),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)}})})),$Z=K((()=>{var e=tt(),t=Xt(),i=Cr(),n=Zs(),r=jT(),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)}})})),KZ=K((()=>{var e=tt(),t=Qr(),i=jm();e({target:"Object",stat:!0,forced:Xt()((function(){i(1)}))},{keys:function(e){return i(t(e))}})})),JZ=K((()=>{"use strict";var e=tt(),t=jn(),i=ly(),n=Qr(),r=$u(),a=To(),s=Us().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))}})})),QZ=K((()=>{"use strict";var e=tt(),t=jn(),i=ly(),n=Qr(),r=$u(),a=To(),s=Us().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))}})})),eK=K((()=>{var e=tt(),t=Cr(),i=gd().onFreeze,n=np(),r=Xt(),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}})})),aK=K((()=>{"use strict";var e=jn(),t=Cs(),i=Cr(),n=Qr(),r=hs(),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){}})),oK=K((()=>{var e=tt(),t=Cr(),i=gd().onFreeze,n=np(),r=Xt(),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}})})),lK=K((()=>{tt()({target:"Object",stat:!0},{setPrototypeOf:Xl()})})),uK=K(((e,t)=>{"use strict";var i=Q_(),n=Wl();t.exports=i?{}.toString:function(){return"[object "+n(this)+"]"}})),hK=K((()=>{var e=Q_(),t=Hi(),i=uK();e||t(Object.prototype,"toString",i,{unsafe:!0})})),dK=K((()=>{var e=tt(),t=DD().values;e({target:"Object",stat:!0},{values:function(e){return t(e)}})})),pK=K((()=>{var e=tt(),t=TD();e({global:!0,forced:parseFloat!=t},{parseFloat:t})})),gK=K((()=>{var e=tt(),t=wD();e({global:!0,forced:parseInt!=t},{parseInt:t})})),Xc=K(((e,t)=>{var i=TypeError;t.exports=function(e,t){if(e{var i=Fc();t.exports=/(?:ipad|iphone|ipod).*applewebkit/i.test(i)})),hy=K(((e,t)=>{var i,n,r,a,s=xn(),o=_o(),l=Qo(),h=Rr(),c=zr(),u=Xt(),d=b3(),p=ld(),f=M1(),m=Xc(),g=HD(),v=Gc(),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)},L=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(L)?(n=L,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}})),YD=K(((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})),IK=K(((e,t)=>{var i=Fc();t.exports=/ipad|iphone|ipod/i.test(i)&&"undefined"!=typeof Pebble})),LK=K(((e,t)=>{var i=Fc();t.exports=/web0s(?!.*chrome)/i.test(i)})),eL=K(((e,t)=>{var i,n,r,a,s,o,l,h=xn(),c=Qo(),u=Us().f,d=hy().set,p=YD(),f=HD(),m=IK(),g=LK(),v=Gc(),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})),zK=K(((e,t)=>{t.exports=function(e,t){try{1==arguments.length?console.error(e):console.error(e,t)}catch(e){}}})),dg=K(((e,t)=>{t.exports=function(e){try{return{error:!1,value:e()}}catch(e){return{error:!0,value:e}}}})),ap=K(((e,t)=>{var i=xn();t.exports=i.Promise})),sw=K(((e,t)=>{t.exports="object"==typeof Deno&&Deno&&"object"==typeof Deno.version})),tL=K(((e,t)=>{var i=sw(),n=Gc();t.exports=!i&&!n&&"object"==typeof window&&"object"==typeof document})),fg=K(((e,t)=>{var i=xn(),n=ap(),r=Rr(),a=qm(),s=j_(),o=Pr(),l=tL(),h=sw(),c=Ki(),u=Bc(),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}})),vd=K(((e,t)=>{"use strict";var i=Zi(),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)}})),gJ=K((()=>{"use strict";var e,t,i,n=tt(),r=Ki(),a=Gc(),s=xn(),o=gr(),l=Hi(),h=Xl(),c=Va(),u=Jf(),d=Zi(),p=Rr(),f=Cr(),m=$l(),g=ep(),v=hy().set,y=eL(),x=zK(),b=dg(),_=YD(),w=ds(),S=ap(),M=fg(),E=vd(),T="Promise",A=M.CONSTRUCTOR,C=M.REJECTION_EVENT,P=M.SUBCLASSING,R=w.getterFor(T),L=w.set,I=S&&S.prototype,D=S,O=I,k=s.TypeError,N=s.document,F=s.process,U=E.f,B=U,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)}},W=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)})))},G=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?F.emit("unhandledRejection",n,i):G(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?F.emit("rejectionHandled",t):G("rejectionhandled",t,e.value)}))},K=function(e,t,i){return function(n){e(t,n,i)}},J=function(e,t,i){e.done||(e.done=!0,i&&(e=i),e.value=t,e.state=2,W(e,!0))},Z=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,K(Z,i,e),K(J,i,e))}catch(t){J(i,t,e)}})):(e.value=t,e.state=1,W(e,!1))}catch(t){J({done:!1},t,e)}}};if(A&&(O=(D=function(t){m(this,O),d(t),o(e,this);var i=R(this);try{t(K(Z,i),K(J,i))}catch(e){J(i,e)}}).prototype,(e=function(e){L(this,{type:T,done:!1,notified:!1,parent:!1,reactions:new _,rejection:!1,state:0,value:void 0})}).prototype=l(O,"then",(function(e,t){var i=R(this),n=U(g(this,D));return i.parent=!0,n.ok=!p(e)||e,n.fail=p(t)&&t,n.domain=a?F.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=K(Z,i),this.reject=K(J,i)},E.f=U=function(e){return e===D||void 0===e?new t(e):B(e)},!r&&p(S)&&I!==Object.prototype)){i=I.then,P||l(I,"then",(function(e,t){var n=this;return new D((function(e,t){o(i,n,e,t)})).then(e,t)}),{unsafe:!0});try{delete I.constructor}catch(e){}h&&h(I,O)}n({global:!0,constructor:!0,wrap:!0,forced:A},{Promise:D}),c(D,T,!1,!0),u(T)})),my=K(((e,t)=>{var i=ap(),n=z1(),r=fg().CONSTRUCTOR;t.exports=r||!n((function(e){i.all(e).then(void 0,(function(){}))}))})),yJ=K((()=>{"use strict";var e=tt(),t=gr(),i=Zi(),n=vd(),r=dg(),a=Yl();e({target:"Promise",stat:!0,forced:my()},{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}})})),bJ=K((()=>{"use strict";var e,t=tt(),i=Ki(),n=fg().CONSTRUCTOR,r=ap(),a=Si(),s=Rr(),o=Hi(),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}))})),EJ=K((()=>{"use strict";var e=tt(),t=gr(),i=Zi(),n=vd(),r=dg(),a=Yl();e({target:"Promise",stat:!0,forced:my()},{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}})})),_J=K((()=>{"use strict";var e=tt(),t=gr(),i=vd();e({target:"Promise",stat:!0,forced:fg().CONSTRUCTOR},{reject:function(e){var n=i.f(this);return t(n.reject,void 0,e),n.promise}})})),pL=K(((e,t)=>{var i=fr(),n=Cr(),r=vd();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}})),MJ=K((()=>{"use strict";var e=tt(),t=Si(),i=Ki(),n=ap(),r=fg().CONSTRUCTOR,a=pL(),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)}})})),AJ=K((()=>{gJ(),yJ(),bJ(),EJ(),_J(),MJ()})),RJ=K((()=>{"use strict";var e=tt(),t=gr(),i=Zi(),n=vd(),r=dg(),a=Yl();e({target:"Promise",stat:!0,forced:my()},{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}})})),PJ=K((()=>{"use strict";var e=tt(),t=gr(),i=Zi(),n=Si(),r=vd(),a=dg(),s=Yl(),o=my(),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}})})),OJ=K((()=>{"use strict";var e,t=tt(),i=Ki(),n=ap(),r=Xt(),a=Si(),s=Rr(),o=ep(),l=pL(),h=Hi(),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}))})),kJ=K((()=>{var e=tt(),t=_o(),i=Zi(),n=fr();e({target:"Reflect",stat:!0,forced:!Xt()((function(){Reflect.apply((function(){}))}))},{apply:function(e,r,a){return t(i(e),r,n(a))}})})),zJ=K((()=>{var e=tt(),t=Si(),i=_o(),n=tD(),r=GT(),a=fr(),s=Cr(),o=Ua(),l=Xt(),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}})})),jJ=K((()=>{var e=tt(),t=jn(),i=fr(),n=$u(),r=Di();e({target:"Reflect",stat:!0,forced:Xt()((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}}})})),WJ=K((()=>{var e=tt(),t=fr(),i=Us().f;e({target:"Reflect",stat:!0},{deleteProperty:function(e,n){var r=i(t(e),n);return!(r&&!r.configurable)&&delete e[n]}})})),xL=K(((e,t)=>{var i=zr();t.exports=function(e){return void 0!==e&&(i(e,"value")||i(e,"writable"))}})),ZJ=K((()=>{var e=tt(),t=gr(),i=Cr(),n=fr(),r=xL(),a=Us(),s=To();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}})})),KJ=K((()=>{var e=tt(),t=jn(),i=fr(),n=Us();e({target:"Reflect",stat:!0,sham:!t},{getOwnPropertyDescriptor:function(e,t){return n.f(i(e),t)}})})),JJ=K((()=>{var e=tt(),t=fr(),i=To();e({target:"Reflect",stat:!0,sham:!gT()},{getPrototypeOf:function(e){return i(t(e))}})})),QJ=K((()=>{tt()({target:"Reflect",stat:!0},{has:function(e,t){return t in e}})})),eQ=K((()=>{var e=tt(),t=fr(),i=XT();e({target:"Reflect",stat:!0},{isExtensible:function(e){return t(e),i(e)}})})),tQ=K((()=>{tt()({target:"Reflect",stat:!0},{ownKeys:J_()})})),nQ=K((()=>{var e=tt(),t=Si(),i=fr();e({target:"Reflect",stat:!0,sham:!np()},{preventExtensions:function(e){i(e);try{var n=t("Object","preventExtensions");return n&&n(e),!0}catch(e){return!1}}})})),oQ=K((()=>{var e=tt(),t=gr(),i=fr(),n=Cr(),r=xL(),a=Xt(),s=Di(),o=Us(),l=To(),h=bo();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}})})),cQ=K((()=>{var e=tt(),t=fr(),i=q3(),n=Xl();n&&e({target:"Reflect",stat:!0},{setPrototypeOf:function(e,r){t(e),i(r);try{return n(e,r),!0}catch(e){return!1}}})})),uQ=K((()=>{var e=tt(),t=xn(),i=Va();e({global:!0},{Reflect:{}}),i(t.Reflect,"Reflect",!0)})),yg=K(((e,t)=>{var i=Cr(),n=Zs(),r=Pr()("match");t.exports=function(e){var t;return i(e)&&(void 0!==(t=e[r])?!!t:"RegExp"==n(e))}})),fw=K(((e,t)=>{"use strict";var i=fr();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}})),xg=K(((e,t)=>{var i=gr(),n=zr(),r=Eo(),a=fw(),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)}})),gy=K(((e,t)=>{var i=Xt(),n=xn().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}})),pw=K(((e,t)=>{var i=Xt(),n=xn().RegExp;t.exports=i((function(){var e=n(".","s");return!(e.dotAll&&e.exec("\n")&&"s"===e.flags)}))})),wL=K(((e,t)=>{var i=Xt(),n=xn().RegExp;t.exports=i((function(){var e=n("(?
b)","g");return"b"!==e.exec("b").groups.a||"bc"!=="b".replace(e,"$c")}))})),MQ=K((()=>{var e,t,i,n=jn(),r=xn(),a=Qt(),s=qm(),o=$f(),l=Ks(),h=Zu().f,c=Eo(),u=yg(),d=yr(),p=xg(),f=gy(),m=j3(),g=Hi(),v=Xt(),y=zr(),x=ds().enforce,b=Jf(),_=Pr(),w=pw(),S=wL(),M=_("match"),E=r.RegExp,T=E.prototype,A=r.SyntaxError,C=a(T.exec),P=a("".charAt),R=a("".replace),L=a("".indexOf),I=a("".slice),D=/^\?<[^\s\d!#%&*+<=>@^][^\s!#%&*+<=>@^]*>/,O=/a/g,k=/a/g,N=new E(O)!==O,F=f.MISSED_STICKY,U=f.UNSUPPORTED_Y;if(s("RegExp",n&&(!N||F||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&&L(i,"s")>-1)&&(i=R(i,/s/g,"")),n=i,F&&"sticky"in O&&(a=!!i&&L(i,"y")>-1)&&U&&(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(D,I(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")})),RQ=K((()=>{var e=jn(),t=pw(),i=Zs(),n=Cs(),r=ds().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")}}})})),yy=K(((e,t)=>{"use strict";var i,n,r=gr(),a=Qt(),s=yr(),o=fw(),l=gy(),h=Vf(),c=Ua(),u=ds().get,d=pw(),p=wL(),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,L=0,I=E;if(C&&(P=x(P,"y",""),-1===y(P,"g")&&(P+="g"),I=b(E,p.lastIndex),p.lastIndex>0&&(!p.multiline||p.multiline&&"\n"!==v(E,p.lastIndex-1))&&(R="(?: "+R+")",I=" "+I,L++),i=new RegExp("^(?:"+R+")",P)),S&&(i=new RegExp("^"+R+"$(?!\\s)",P)),_&&(n=p.lastIndex),a=r(m,C?i:p,I),C?a?(a.input=b(a.input,L),a[0]=b(a[0],L),a.index=p.lastIndex,p.lastIndex+=a[0].length):p.lastIndex=0:_&&a&&(p.lastIndex=p.global?a.index+a[0].length:n),S&&a&&a.length>1&&r(f,a[0],i,(function(){for(l=1;l{"use strict";var e=tt(),t=yy();e({target:"RegExp",proto:!0,forced:/./.exec!==t},{exec:t})})),OQ=K((()=>{var e=xn(),t=jn(),i=Cs(),n=fw(),r=Xt(),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})})),NQ=K((()=>{var e=jn(),t=gy().MISSED_STICKY,i=Zs(),n=Cs(),r=ds().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")}}})})),HQ=K((()=>{"use strict";yw();var e,t,i=tt(),n=gr(),r=Rr(),a=fr(),s=yr(),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)}})})),zQ=K((()=>{"use strict";var e=Gf().PROPER,t=Hi(),i=fr(),n=yr(),r=Xt(),a=xg(),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})})),GQ=K((()=>{"use strict";Q1()("Set",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),uD())})),qQ=K((()=>{GQ()})),jQ=K((()=>{"use strict";var e=tt(),t=Qt(),i=hs(),n=Ji(),r=yr(),a=Xt(),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)}})})),xy=K(((e,t)=>{var i=Qt(),n=Ji(),r=yr(),a=hs(),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)}})),$Q=K((()=>{"use strict";var e=tt(),t=xy().codeAt;e({target:"String",proto:!0},{codePointAt:function(e){return t(this,e)}})})),xw=K(((e,t)=>{var i=yg(),n=TypeError;t.exports=function(e){if(i(e))throw n("The method doesn't accept regular expressions");return e}})),bw=K(((e,t)=>{var i=Pr()("match");t.exports=function(e){var t=/./;try{"/./"[e](t)}catch(n){try{return t[i]=!1,"/./"[e](t)}catch(e){}}return!1}})),nee=K((()=>{"use strict";var e,t=tt(),i=Ku(),n=Us().f,r=Ha(),a=yr(),s=xw(),o=hs(),l=bw(),h=Ki(),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}})})),see=K((()=>{var e=tt(),t=Qt(),i=jl(),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,"")}})})),oee=K((()=>{"use strict";var e=tt(),t=Qt(),i=xw(),n=hs(),r=yr(),a=bw(),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)}})})),kL=K((()=>{"use strict";var e=xy().charAt,t=yr(),i=ds(),n=ST(),r=j1(),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))}))})),by=K(((e,t)=>{"use strict";yw();var i=Ku(),n=Hi(),r=yy(),a=Xt(),s=Pr(),o=Ks(),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)}})),Ey=K(((e,t)=>{"use strict";var i=xy().charAt;t.exports=function(e,t,n){return t+(n?i(e,t).length:1)}})),_g=K(((e,t)=>{var i=gr(),n=fr(),r=Rr(),a=Zs(),s=yy(),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")}})),bee=K((()=>{"use strict";var e=gr(),t=by(),i=fr(),n=ga(),r=Ha(),a=yr(),s=hs(),o=Hc(),l=Ey(),h=_g();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}]}))})),Pee=K((()=>{"use strict";var e=tt(),t=gr(),i=Ku(),n=_T(),r=j1(),a=hs(),s=Ha(),o=yr(),l=fr(),h=ga(),c=Zs(),u=yg(),d=xg(),p=Hc(),f=Hi(),m=Xt(),g=Pr(),v=ep(),y=Ey(),x=_g(),b=ds(),_=Ki(),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),L=!!R&&!m((function(){R("a",/./)})),I=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))})),D=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 I(t,a,i,n)};e({target:"String",proto:!0,forced:L},{matchAll:function(e){var i,n,r,s,l=a(this);if(h(e)){if(L)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(L)return R(l,e);if(void 0===(r=p(e,w))&&_&&"RegExp"==c(e)&&(r=D),r)return t(r,e,l)}return n=o(l),s=new RegExp(e,"g"),_?t(D,s,n):s[w](n)}}),_||w in A||f(A,w,D)})),zL=K(((e,t)=>{var i=Fc();t.exports=/Version\/10(?:\.\d+){1,2}(?: [\w./]+)?(?: Mobile\/\w+)? Safari\//.test(i)})),Dee=K((()=>{"use strict";var e=tt(),t=qT().end;e({target:"String",proto:!0,forced:zL()},{padEnd:function(e){return t(this,e,arguments.length>1?arguments[1]:void 0)}})})),Lee=K((()=>{"use strict";var e=tt(),t=qT().start;e({target:"String",proto:!0,forced:zL()},{padStart:function(e){return t(this,e,arguments.length>1?arguments[1]:void 0)}})})),Fee=K((()=>{var e=tt(),t=Qt(),i=_s(),n=Qr(),r=yr(),a=si(),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{tt()({target:"String",proto:!0},{repeat:K1()})})),WL=K(((e,t)=>{var i=Qt(),n=Qr(),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}))}})),qee=K((()=>{"use strict";var e=_o(),t=gr(),i=Qt(),n=by(),r=Xt(),a=fr(),s=Rr(),o=ga(),l=Ji(),h=Ha(),c=yr(),u=hs(),d=Ey(),p=Hc(),f=WL(),m=_g(),g=Pr()("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,L=0;L=R&&(P+=w(u,R,D)+U,R=D+I.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)})),$ee=K((()=>{"use strict";var e=tt(),t=gr(),i=Qt(),n=hs(),r=Rr(),a=ga(),s=yg(),o=yr(),l=Hc(),h=xg(),c=WL(),u=Pr(),d=Ki(),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,L="";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),L+=v(w,R,P)+A,R=P+E,P=x(w,S,P+T);return R{"use strict";var e=gr(),t=by(),i=fr(),n=ga(),r=hs(),a=OD(),s=yr(),o=Hc(),l=_g();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}]}))})),ite=K((()=>{"use strict";var e=_o(),t=gr(),i=Qt(),n=by(),r=fr(),a=ga(),s=yg(),o=hs(),l=ep(),h=Ey(),c=Ha(),u=yr(),d=Hc(),p=Wm(),f=_g(),m=yy(),g=gy(),v=Xt(),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=tt(),i=Ku(),n=Us().f,r=Ha(),a=yr(),s=xw(),o=hs(),l=bw(),h=Ki(),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}})})),hte=K((()=>{"use strict";var e=tt(),t=Qt(),i=hs(),n=Ji(),r=yr(),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)}})})),Sw=K(((e,t)=>{var i=Gf().PROPER,n=Xt(),r=iy();t.exports=function(e){return n((function(){return!!r[e]()||"\u200b\x85\u180e"!=="\u200b\x85\u180e"[e]()||i&&r[e].name!==e}))}})),mte=K((()=>{"use strict";var e=tt(),t=rp().trim;e({target:"String",proto:!0,forced:Sw()("trim")},{trim:function(){return t(this)}})})),JL=K(((e,t)=>{"use strict";var i=rp().end,n=Sw();t.exports=n("trimEnd")?function(){return i(this)}:"".trimEnd})),yte=K((()=>{var e=tt(),t=JL();e({target:"String",proto:!0,name:"trimEnd",forced:"".trimRight!==t},{trimRight:t})})),bte=K((()=>{yte();var e=tt(),t=JL();e({target:"String",proto:!0,name:"trimEnd",forced:"".trimEnd!==t},{trimEnd:t})})),QL=K(((e,t)=>{"use strict";var i=rp().start,n=Sw();t.exports=n("trimStart")?function(){return i(this)}:"".trimStart})),Tte=K((()=>{var e=tt(),t=QL();e({target:"String",proto:!0,name:"trimStart",forced:"".trimLeft!==t},{trimLeft:t})})),Ste=K((()=>{Tte();var e=tt(),t=QL();e({target:"String",proto:!0,name:"trimStart",forced:"".trimStart!==t},{trimStart:t})})),qa=K(((e,t)=>{var i=Qt(),n=hs(),r=yr(),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+""}})),ja=K(((e,t)=>{var i=Xt();t.exports=function(e){return i((function(){var t=""[e]('"');return t!==t.toLowerCase()||t.split('"').length>3}))}})),Cte=K((()=>{"use strict";var e=tt(),t=qa();e({target:"String",proto:!0,forced:ja()("anchor")},{anchor:function(e){return t(this,"a","name",e)}})})),Pte=K((()=>{"use strict";var e=tt(),t=qa();e({target:"String",proto:!0,forced:ja()("big")},{big:function(){return t(this,"big","","")}})})),Ite=K((()=>{"use strict";var e=tt(),t=qa();e({target:"String",proto:!0,forced:ja()("blink")},{blink:function(){return t(this,"blink","","")}})})),Dte=K((()=>{"use strict";var e=tt(),t=qa();e({target:"String",proto:!0,forced:ja()("bold")},{bold:function(){return t(this,"b","","")}})})),Lte=K((()=>{"use strict";var e=tt(),t=qa();e({target:"String",proto:!0,forced:ja()("fixed")},{fixed:function(){return t(this,"tt","","")}})})),Ote=K((()=>{"use strict";var e=tt(),t=qa();e({target:"String",proto:!0,forced:ja()("fontcolor")},{fontcolor:function(e){return t(this,"font","color",e)}})})),kte=K((()=>{"use strict";var e=tt(),t=qa();e({target:"String",proto:!0,forced:ja()("fontsize")},{fontsize:function(e){return t(this,"font","size",e)}})})),Nte=K((()=>{"use strict";var e=tt(),t=qa();e({target:"String",proto:!0,forced:ja()("italics")},{italics:function(){return t(this,"i","","")}})})),Fte=K((()=>{"use strict";var e=tt(),t=qa();e({target:"String",proto:!0,forced:ja()("link")},{link:function(e){return t(this,"a","href",e)}})})),Bte=K((()=>{"use strict";var e=tt(),t=qa();e({target:"String",proto:!0,forced:ja()("small")},{small:function(){return t(this,"small","","")}})})),Hte=K((()=>{"use strict";var e=tt(),t=qa();e({target:"String",proto:!0,forced:ja()("strike")},{strike:function(){return t(this,"strike","","")}})})),Ute=K((()=>{"use strict";var e=tt(),t=qa();e({target:"String",proto:!0,forced:ja()("sub")},{sub:function(){return t(this,"sub","","")}})})),Vte=K((()=>{"use strict";var e=tt(),t=qa();e({target:"String",proto:!0,forced:ja()("sup")},{sup:function(){return t(this,"sup","","")}})})),Mw=K(((e,t)=>{var i=xn(),n=Xt(),r=z1(),a=Er().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}))})),jte=K(((e,t)=>{var i=Ji(),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}})),tO=K(((e,t)=>{var i=jte(),n=RangeError;t.exports=function(e,t){var r=i(e);if(r%t)throw n("Wrong offset");return r}})),nO=K(((e,t)=>{var i=Wl();t.exports=function(e){var t=i(e);return"BigInt64Array"==t||"BigUint64Array"==t}})),Aw=K(((e,t)=>{var i=S1(),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)}})),rO=K(((e,t)=>{var i=Qo(),n=gr(),r=GT(),a=Qr(),s=si(),o=H1(),l=Jm(),h=vT(),c=nO(),u=Er().aTypedArrayConstructor,d=Aw();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}})),Yc=K(((e,t)=>{"use strict";var i=tt(),n=xn(),r=gr(),a=jn(),s=Mw(),o=Er(),l=Z1(),h=$l(),c=bo(),u=Ks(),d=ew(),p=Ha(),f=D2(),m=tO(),g=$u(),v=zr(),y=Wl(),x=Cr(),b=sd(),_=Ua(),w=Eo(),S=Xl(),M=Zu().f,E=rO(),T=Ps().forEach,A=Jf(),C=Cs(),P=Di(),R=Us(),L=ds(),I=$f(),D=L.get,O=L.set,k=L.enforce,N=P.f,F=R.f,U=Math.round,B=n.RangeError,z=l.ArrayBuffer,H=z.prototype,V=l.DataView,j=o.NATIVE_ARRAY_BUFFER_VIEWS,W=o.TYPED_ARRAY_TAG,G=o.TypedArray,X=o.TypedArrayPrototype,Y=o.aTypedArrayConstructor,q=o.isTypedArray,K="BYTES_PER_ELEMENT",J="Wrong length",Z=function(e,t){Y(e);for(var i=0,n=t.length,r=new e(n);n>i;)r[i]=t[i++];return r},$=function(e,t){C(e,t,{configurable:!0,get:function(){return D(this)[t]}})},Q=function(e){var t;return w(H,e)||"ArrayBuffer"==(t=y(e))||"SharedArrayBuffer"==t},ee=function(e,t){return q(e)&&!b(t)&&t in e&&d(+t)&&t>=0},te=function(e,t){return t=g(t),ee(e,t)?c(2,e[t]):F(e,t)},ie=function(e,t,i){return t=g(t),!(ee(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?N(e,t,i):(e[t]=i.value,e)};a?(j||(R.f=te,P.f=ie,$(X,"buffer"),$(X,"byteOffset"),$(X,"byteLength"),$(X,"length")),i({target:"Object",stat:!0,forced:!j},{getOwnPropertyDescriptor:te,defineProperty:ie}),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){N(e,t,{get:function(){return function(e,t){var i=D(e);return i.view[c](t*o+i.byteOffset,!0)}(this,t)},set:function(e){return function(e,t,i){var n=D(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})};j?s&&(v=t((function(e,t,i,n){return h(e,y),I(x(t)?Q(t)?void 0!==n?new g(t,m(i,o),n):void 0!==i?new g(t,m(i,o)):new g(t):q(t)?Z(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(!Q(t))return q(t)?Z(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 B(J)}else if((s=p(n)*o)+u>d)throw B(J);l=s/o}else l=f(t),a=new z(s=l*o);for(O(e,{buffer:a,byteOffset:u,byteLength:s,length:l,view:new V(a)});c{Yc()("Float32",(function(e){return function(t,i,n){return e(this,t,i,n)}}))})),gne=K((()=>{Yc()("Float64",(function(e){return function(t,i,n){return e(this,t,i,n)}}))})),vne=K((()=>{Yc()("Int8",(function(e){return function(t,i,n){return e(this,t,i,n)}}))})),yne=K((()=>{Yc()("Int16",(function(e){return function(t,i,n){return e(this,t,i,n)}}))})),xne=K((()=>{Yc()("Int32",(function(e){return function(t,i,n){return e(this,t,i,n)}}))})),bne=K((()=>{Yc()("Uint8",(function(e){return function(t,i,n){return e(this,t,i,n)}}))})),Ene=K((()=>{Yc()("Uint8",(function(e){return function(t,i,n){return e(this,t,i,n)}}),!0)})),_ne=K((()=>{Yc()("Uint16",(function(e){return function(t,i,n){return e(this,t,i,n)}}))})),Tne=K((()=>{Yc()("Uint32",(function(e){return function(t,i,n){return e(this,t,i,n)}}))})),Sne=K((()=>{"use strict";var e=Er(),t=si(),i=Ji(),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]}))})),Ane=K((()=>{"use strict";var e=Qt(),t=Er(),i=e(l2()),n=t.aTypedArray;(0,t.exportTypedArrayMethod)("copyWithin",(function(e,t){return i(n(this),e,t,arguments.length>2?arguments[2]:void 0)}))})),Cne=K((()=>{"use strict";var e=Er(),t=Ps().every,i=e.aTypedArray;(0,e.exportTypedArrayMethod)("every",(function(e){return t(i(this),e,arguments.length>1?arguments[1]:void 0)}))})),Ine=K((()=>{"use strict";var e=Er(),t=ET(),i=Aw(),n=Wl(),r=gr(),a=Qt(),s=Xt(),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})))})),Ry=K(((e,t)=>{var i=Er(),n=ep(),r=i.aTypedArrayConstructor,a=i.getTypedArrayConstructor;t.exports=function(e){return r(n(e,a(e)))}})),kne=K(((e,t)=>{var i=PT(),n=Ry();t.exports=function(e,t){return i(n(e),t)}})),Fne=K((()=>{"use strict";var e=Er(),t=Ps().filter,i=kne(),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)}))})),Hne=K((()=>{"use strict";var e=Er(),t=Ps().find,i=e.aTypedArray;(0,e.exportTypedArrayMethod)("find",(function(e){return t(i(this),e,arguments.length>1?arguments[1]:void 0)}))})),Vne=K((()=>{"use strict";var e=Er(),t=Ps().findIndex,i=e.aTypedArray;(0,e.exportTypedArrayMethod)("findIndex",(function(e){return t(i(this),e,arguments.length>1?arguments[1]:void 0)}))})),Gne=K((()=>{"use strict";var e=Er(),t=V1().findLast,i=e.aTypedArray;(0,e.exportTypedArrayMethod)("findLast",(function(e){return t(i(this),e,arguments.length>1?arguments[1]:void 0)}))})),jne=K((()=>{"use strict";var e=Er(),t=V1().findLastIndex,i=e.aTypedArray;(0,e.exportTypedArrayMethod)("findLastIndex",(function(e){return t(i(this),e,arguments.length>1?arguments[1]:void 0)}))})),Xne=K((()=>{"use strict";var e=Er(),t=Ps().forEach,i=e.aTypedArray;(0,e.exportTypedArrayMethod)("forEach",(function(e){t(i(this),e,arguments.length>1?arguments[1]:void 0)}))})),Yne=K((()=>{"use strict";var e=Mw();(0,Er().exportTypedArrayStaticMethod)("from",rO(),e)})),Zne=K((()=>{"use strict";var e=Er(),t=Gm().includes,i=e.aTypedArray;(0,e.exportTypedArrayMethod)("includes",(function(e){return t(i(this),e,arguments.length>1?arguments[1]:void 0)}))})),Jne=K((()=>{"use strict";var e=Er(),t=Gm().indexOf,i=e.aTypedArray;(0,e.exportTypedArrayMethod)("indexOf",(function(e){return t(i(this),e,arguments.length>1?arguments[1]:void 0)}))})),rre=K((()=>{"use strict";var e=xn(),t=Xt(),i=Qt(),n=Er(),r=W1(),a=Pr()("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"})})),sre=K((()=>{"use strict";var e=Er(),t=Qt(),i=e.aTypedArray,n=e.exportTypedArrayMethod,r=t([].join);n("join",(function(e){return r(i(this),e)}))})),ore=K((()=>{"use strict";var e=Er(),t=_o(),i=T2(),n=e.aTypedArray;(0,e.exportTypedArrayMethod)("lastIndexOf",(function(e){var r=arguments.length;return t(i,n(this),r>1?[e,arguments[1]]:[e])}))})),cre=K((()=>{"use strict";var e=Er(),t=Ps().map,i=Ry(),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)}))}))})),hre=K((()=>{"use strict";var e=Er(),t=Mw(),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)})),fre=K((()=>{"use strict";var e=Er(),t=X1().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)}))})),mre=K((()=>{"use strict";var e=Er(),t=X1().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)}))})),vre=K((()=>{"use strict";var e=Er(),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=xn(),t=gr(),i=Er(),n=si(),r=tO(),a=Qr(),s=Xt(),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=Er(),t=Ry(),i=Xt(),n=ld(),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()})))})),Are=K((()=>{"use strict";var e=Er(),t=Ps().some,i=e.aTypedArray;(0,e.exportTypedArrayMethod)("some",(function(e){return t(i(this),e,arguments.length>1?arguments[1]:void 0)}))})),Lre=K((()=>{"use strict";var e=xn(),t=Ku(),i=Xt(),n=Zi(),r=RT(),a=Er(),s=M2(),o=A2(),l=Bc(),h=CT(),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)})),Nre=K((()=>{"use strict";var e=Er(),t=Ha(),i=jl(),n=Ry(),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))}))})),Vre=K((()=>{"use strict";var e=xn(),t=_o(),i=Er(),n=Xt(),r=ld(),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])})))})),zre=K((()=>{"use strict";var e=P2(),t=Er(),i=t.aTypedArray,n=t.exportTypedArrayMethod,r=t.getTypedArrayConstructor;n("toReversed",(function(){return e(i(this),r(this))}))})),Gre=K((()=>{"use strict";var e=Er(),t=Qt(),i=Zi(),n=PT(),r=e.aTypedArray,a=e.getTypedArrayConstructor,s=e.exportTypedArrayMethod,o=t(e.TypedArrayPrototype.sort);s("toSorted",(function(e){void 0!==e&&i(e);var t=r(this),s=n(a(t),t);return o(s,e)}))})),jre=K((()=>{"use strict";var e=Er().exportTypedArrayMethod,t=Xt(),i=xn(),n=Qt(),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)})),Wre=K((()=>{"use strict";var e=I2(),t=Er(),i=nO(),n=Ji(),r=Aw(),a=t.aTypedArray,s=t.getTypedArrayConstructor;(0,t.exportTypedArrayMethod)("with",(function(t,o){var l=a(this),h=n(t),c=i(l)?r(o):+o;return e(l,s(l),h,c)}),!function(){try{new Int8Array(1).with(2,{valueOf:function(){throw 8}})}catch(e){return 8===e}}())})),Kre=K((()=>{"use strict";var e=tt(),t=Qt(),i=yr(),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=Qt(),n=tg(),r=gd().getWeakData,a=$l(),s=fr(),o=ga(),l=Cr(),h=Yl(),c=Ps(),u=zr(),d=ds(),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}}})),fie=K((()=>{"use strict";var e,t,i,n,r=np(),a=xn(),s=Qt(),o=tg(),l=gd(),h=Q1(),c=MO(),u=Cr(),d=ds().enforce,p=Xt(),f=u3(),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}}))})),pie=K((()=>{fie()})),mie=K((()=>{"use strict";Q1()("WeakSet",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),MO())})),gie=K((()=>{mie()})),CO=K(((e,t)=>{var i,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",r={};for(i=0;i<66;i++)r[n.charAt(i)]=i;t.exports={itoc:n,ctoi:r}})),Sie=K((()=>{var e=tt(),t=xn(),i=Si(),n=Qt(),r=gr(),a=Xt(),s=yr(),o=zr(),l=Xc(),h=CO().ctoi,c=/[^\d+/a-z]/i,u=/[\t\n\f\r ]+/g,d=/[=]{1,2}$/,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}})})),Oie=K((()=>{var e=tt(),t=xn(),i=Si(),n=Qt(),r=gr(),a=Xt(),s=yr(),o=Xc(),l=CO().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}})})),kO=K(((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}})),FO=K(((e,t)=>{var i=M1()("span").classList,n=i&&i.constructor&&i.constructor.prototype;t.exports=n===Object.prototype?void 0:n})),Vie=K((()=>{var e,t=xn(),i=kO(),n=FO(),r=d2(),a=Ks(),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)})),Xie=K((()=>{var e,t=xn(),i=kO(),n=FO(),r=W1(),a=Ks(),s=Pr(),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")})),$ie=K(((e,t)=>{var i=Gc();t.exports=function(e){try{if(i)return Function('return require("'+e+'")')()}catch(e){}}})),zO=K(((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}}})),ose=K((()=>{"use strict";var e=tt(),t=$ie(),i=Si(),n=Xt(),r=Ua(),a=bo(),s=Di().f,o=Hi(),l=Cs(),h=zr(),c=$l(),u=fr(),d=J3(),p=Zm(),f=zO(),m=fT(),g=ds(),v=jn(),y=Ki(),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),L=function(e){return{enumerable:!0,configurable:!0,get:e}},I=function(e){return L((function(){return T(this)[e]}))};v&&(l(R,"code",I("code")),l(R,"message",I("message")),l(R,"name",I("name"))),s(R,"constructor",a(1,P));var D=n((function(){return!(new w instanceof _)})),O=D||n((function(){return M.toString!==d||"2: 1"!==String(new w(1,2))})),k=D||n((function(){return 25!==new w(1,"DataCloneError").code})),N=D||25!==w[b]||25!==S[b],F=y?O||k||N:D;e({global:!0,constructor:!0,forced:F},{DOMException:F?P:w});var U,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",L((function(){return C(u(this).name)}))),f)h(f,H)&&(B=(U=f[H]).s,z=a(6,U.c),h(V,B)||s(V,B,z),h(j,B)||s(j,B,z))})),pse=K((()=>{"use strict";var e=tt(),t=xn(),i=Si(),n=bo(),r=Di().f,a=zr(),s=$l(),o=$f(),l=Zm(),h=zO(),c=fT(),u=jn(),d=Ki(),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)))})),gse=K((()=>{var e=Si(),t="DOMException";Va()(e(t),t)})),yse=K((()=>{var e=tt(),t=xn(),i=hy().clear;e({global:!0,bind:!0,enumerable:!0,forced:t.clearImmediate!==i},{clearImmediate:i})})),bse=K(((e,t)=>{t.exports="function"==typeof Bun&&Bun&&"string"==typeof Bun.version})),Qw=K(((e,t)=>{"use strict";var i,n=xn(),r=_o(),a=Rr(),s=bse(),o=Fc(),l=ld(),h=Xc(),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}})),Mse=K((()=>{var e=tt(),t=xn(),i=hy().set,n=Qw(),r=t.setImmediate?n(i,!1):i;e({global:!0,bind:!0,enumerable:!0,forced:t.setImmediate!==r},{setImmediate:r})})),Ase=K((()=>{yse(),Mse()})),Rse=K((()=>{var e=tt(),t=xn(),i=eL(),n=Zi(),r=Xc(),a=Gc(),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)}})})),Pse=K((()=>{"use strict";var e,t=tt(),i=xn(),n=Cs(),r=jn(),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){}})),Dse=K(((e,t)=>{var i=Qt(),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}})),Ose=K(((e,t)=>{var i=Qt(),n=Set.prototype;t.exports={Set:Set,add:i(n.add),has:i(n.has),remove:i(n.delete),proto:n}})),Fse=K(((e,t)=>{var i=xn(),n=Xt(),r=Bc(),a=tL(),s=sw(),o=Gc(),l=i.structuredClone;t.exports=!!l&&!n((function(){if(s&&r>92||o&&r>94||a&&r>97)return!1;var e=new ArrayBuffer(8),t=l(e,{transfer:[e]});return 0!=e.byteLength||8!=t.byteLength}))})),Wse=K((()=>{var e,t=Ki(),i=tt(),n=xn(),r=Si(),a=Qt(),s=Xt(),o=zf(),l=Rr(),h=jf(),c=ga(),u=Cr(),d=sd(),p=Yl(),f=fr(),m=Wl(),g=zr(),v=Uc(),y=Ks(),x=si(),b=Xc(),_=xg(),w=Dse(),S=Ose(),M=X3(),E=Fse(),T=n.Object,A=n.Array,C=n.Date,P=n.Error,R=n.EvalError,L=n.RangeError,I=n.ReferenceError,D=n.SyntaxError,O=n.TypeError,k=n.URIError,N=n.PerformanceMark,F=n.WebAssembly,U=F&&F.CompileError||P,B=F&&F.LinkError||P,z=F&&F.RuntimeError||P,H=r("DOMException"),V=w.Map,j=w.has,W=w.get,G=w.set,X=S.Set,Y=S.add,q=r("Object","keys"),K=a([].push),J=a((!0).valueOf),Z=a(1..valueOf),$=a("".valueOf),Q=a(C.prototype.getTime),ee=o("structuredClone"),te="DataCloneError",ie="Transferring",ne=function(e){return!s((function(){var t=new n.Set([7]),i=e(t),r=e(T(7));return i==t||!i.has(7)||"object"!=typeof r||7!=r}))&&e},re=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)}))},ae=n.structuredClone,se=t||!re(ae,P)||!re(ae,H)||(e=ae,!!s((function(){var t=e(new n.AggregateError([1],ee,{cause:3}));return"AggregateError"!=t.name||1!=t.errors[0]||t.message!=ee||3!=t.cause}))),oe=!ae&&ne((function(e){return new N(ee,{detail:e}).detail})),le=ne(ae)||oe,he=function(e){throw new H("Uncloneable type: "+e,te)},ce=function(e,t){throw new H((t||"Cloning")+" of "+e+" cannot be properly polyfilled in this engine",te)},ue=function(e,t){return le||ce(t),le(e)},de=function(e,t){if(d(e)&&he("Symbol"),!u(e))return e;if(t){if(j(t,e))return W(t,e)}else t=new V;var i,a,s,o,h,c,p,f,b,w,S,E=m(e),N=!1;switch(E){case"Array":s=A(x(e)),N=!0;break;case"Object":s={},N=!0;break;case"Map":s=new V,N=!0;break;case"Set":s=new X,N=!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=R();break;case"RangeError":s=L();break;case"ReferenceError":s=I();break;case"SyntaxError":s=D();break;case"TypeError":s=O();break;case"URIError":s=k();break;case"CompileError":s=U();break;case"LinkError":s=B();break;case"RuntimeError":s=z();break;default:s=P()}N=!0;break;case"DOMException":s=new H(e.message,e.name),N=!0;break;case"DataView":case"Int8Array":case"Uint8Array":case"Uint8ClampedArray":case"Int16Array":case"Uint16Array":case"Int32Array":case"Uint32Array":case"Float32Array":case"Float64Array":case"BigInt64Array":case"BigUint64Array":i=n[E],u(i)||ce(E),s=new i(de(e.buffer,t),e.byteOffset,"DataView"===E?e.byteLength:e.length);break;case"DOMQuad":try{s=new DOMQuad(de(e.p1,t),de(e.p2,t),de(e.p3,t),de(e.p4,t))}catch(t){s=ue(e,E)}break;case"File":if(le)try{s=le(e),m(s)!==E&&(s=void 0)}catch(e){}if(!s)try{s=new File([e],e.name,e)}catch(e){}s||ce(E);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);h1&&!c(arguments[1])?f(arguments[1]):void 0,r=i?i.transfer:void 0;return void 0!==r&&function(e,t){if(!u(e))throw O("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(E)for(o=ae(i,{transfer:i});g{var e=tt(),t=xn(),i=Qw()(t.setInterval,!0);e({global:!0,bind:!0,forced:t.setInterval!==i},{setInterval:i})})),Jse=K((()=>{var e=tt(),t=xn(),i=Qw()(t.setTimeout,!0);e({global:!0,bind:!0,forced:t.setTimeout!==i},{setTimeout:i})})),Qse=K((()=>{$se(),Jse()})),lS=K(((e,t)=>{var i=Xt(),n=Pr(),r=jn(),a=Ki(),s=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})),a&&!e.toJSON||!t.size&&(a||!r)||!t.sort||"http://a/c%20d?a=1&c=3"!==e.href||"3"!==t.get("c")||"a=1"!==String(new URLSearchParams("?a=1"))||!t[s]||"a"!==new URL("https://a@b").username||"b"!==new URLSearchParams(new URLSearchParams("a=b")).get("a")||"xn--e1aybc"!==new URL("http://\u0442\u0435\u0441\u0442").host||"#%D0%B1"!==new URL("http://a#\u0431").hash||"a1c3"!==i||"x"!==new URL("http://x",void 0).host}))})),uae=K(((e,t)=>{var i=Qt(),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";W1();var i=tt(),n=xn(),r=gr(),a=Qt(),s=jn(),o=lS(),l=Hi(),h=Cs(),c=tg(),u=Va(),d=_T(),p=ds(),f=$l(),m=Rr(),g=zr(),v=Qo(),y=Wl(),x=fr(),b=Cr(),_=yr(),w=Ua(),S=bo(),M=H1(),E=Jm(),T=Xc(),A=Pr(),C=RT(),P=A("iterator"),R="URLSearchParams",L=R+"Iterator",I=p.set,D=p.getterFor(R),O=p.getterFor(L),k=Object.getOwnPropertyDescriptor,N=function(e){if(!s)return n[e];var t=k(n,e);return t&&t.value},F=N("fetch"),U=N("Request"),B=N("Headers"),z=U&&U.prototype,H=B&&B.prototype,V=n.RegExp,j=n.TypeError,W=n.decodeURIComponent,G=n.encodeURIComponent,X=a("".charAt),Y=a([].join),q=a([].push),K=a("".replace),J=a([].shift),Z=a([].splice),$=a("".split),Q=a("".slice),ee=/\+/g,te=Array(4),ie=function(e){return te[e-1]||(te[e-1]=V("((?:%[\\da-f]{2}){"+e+"})","gi"))},ne=function(e){try{return W(e)}catch(t){return e}},re=function(e){var t=K(e,ee," "),i=4;try{return W(t)}catch(e){for(;i;)t=K(t,ie(i--),ne);return t}},ae=/[!'()~]|%20/g,se={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},oe=function(e){return se[e]},le=function(e){return K(G(e),ae,oe)},he=d((function(e,t){I(this,{type:L,iterator:M(D(e).entries),kind:t})}),"Iterator",(function(){var e=O(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),ce=function(e){this.entries=[],this.url=null,void 0!==e&&(b(e)?this.parseObject(e):this.parseQuery("string"==typeof e?"?"===X(e,0)?Q(e,1):e:_(e)))};ce.prototype={type:R,bindURL:function(e){this.url=e,this.update()},parseObject:function(e){var t,i,n,a,s,o,l,h=E(e);if(h)for(i=(t=M(e,h)).next;!(n=r(i,t)).done;){if(s=(a=M(x(n.value))).next,(o=r(s,a)).done||(l=r(s,a)).done||!r(s,a).done)throw j("Expected sequence with length 2");q(this.entries,{key:_(o.value),value:_(l.value)})}else for(var c in e)g(e,c)&&q(this.entries,{key:c,value:_(e[c])})},parseQuery:function(e){if(e)for(var t,i,n=$(e,"&"),r=0;r0?arguments[0]:void 0));s||(this.length=e.entries.length)},ge=me.prototype;c(ge,{append:function(e,t){T(arguments.length,2);var i=D(this);q(i.entries,{key:_(e),value:_(t)}),s||this.length++,i.updateURL()},delete:function(e){T(arguments.length,1);for(var t=D(this),i=t.entries,n=_(e),r=0;rt.key?1:-1})),e.updateURL()},forEach:function(e){for(var t,i=D(this).entries,n=v(e,arguments.length>1?arguments[1]:void 0),r=0;r1?pe(arguments[1]):{})}}),m(U)&&(fe=function(e){return f(this,z),new U(e,arguments.length>1?pe(arguments[1]):{})},z.constructor=fe,fe.prototype=z,i({global:!0,constructor:!0,dontCallGetSet:!0,forced:!0},{Request:fe}))),t.exports={URLSearchParams:me,getState:D}})),Yae=K((()=>{"use strict";kL();var e,t=tt(),i=jn(),n=lS(),r=xn(),a=Qo(),s=Qt(),o=Hi(),l=Cs(),h=$l(),c=zr(),u=ID(),d=f2(),p=Wm(),f=xy().codeAt,m=uae(),g=yr(),v=Va(),y=Xc(),x=Ik(),b=ds(),_=b.set,w=b.getterFor("URL"),S=x.URLSearchParams,M=x.getState,E=r.URL,T=r.TypeError,A=r.parseInt,C=Math.floor,P=Math.pow,R=s("".charAt),L=s(/./.exec),I=s([].join),D=s(1..toString),O=s([].pop),k=s([].push),N=s("".replace),F=s([].shift),U=s("".split),B=s("".slice),z=s("".toLowerCase),H=s([].unshift),V="Invalid scheme",j="Invalid host",W="Invalid port",G=/[a-z]/i,X=/[\d+-.a-z]/i,Y=/\d/,q=/^0x/i,K=/^[0-7]+$/,J=/^\d+$/,Z=/^[\da-f]+$/i,$=/[\0\t\n\r #%/:<>?@[\\\]^|]/,Q=/[\0\t\n\r #/:<>?@[\\\]^|]/,ee=/^[\u0000-\u0020]+/,te=/(^|[^\u0000-\u0020])[\u0000-\u0020]+$/,ie=/[\t\n\r]/g,ne=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 I(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+=D(e[i],16),i<7&&(t+=":")));return"["+t+"]"}return e},re={},ae=u({},re,{" ":1,'"':1,"<":1,">":1,"`":1}),se=u({},ae,{"#":1,"?":1,"{":1,"}":1}),oe=u({},se,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),le=function(e,t){var i=f(e,0);return i>32&&i<127&&!c(t,e)?e:encodeURIComponent(e)},he={ftp:21,file:null,http:80,https:443,ws:80,wss:443},ce=function(e,t){var i;return 2==e.length&&L(G,R(e,0))&&(":"==(i=R(e,1))||!t&&"|"==i)},ue=function(e){var t;return e.length>1&&ce(B(e,0,2))&&(2==e.length||"/"===(t=R(e,2))||"\\"===t||"?"===t||"#"===t)},de=function(e){return"."===e||"%2e"===z(e)},pe=function(e){return".."===(e=z(e))||"%2e."===e||".%2e"===e||"%2e%2e"===e},fe={},me={},ge={},ve={},ye={},xe={},be={},_e={},we={},Se={},Me={},Ee={},Te={},Ae={},Ce={},Pe={},Re={},Le={},Ie={},De={},Oe={},ke=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 ke(i,!0)),r=this.parse(s,null,n))throw T(r);(a=M(new S)).bindURL(this),this.searchParams=a}};ke.prototype={type:"URL",parse:function(t,i,n){var r,a,s,o,l=this,h=i||fe,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,"$1")),t=N(t,ie,""),r=d(t);u<=r.length;){switch(a=r[u],h){case fe:if(!a||!L(G,a)){if(i)return V;h=ge;continue}f+=z(a),h=me;break;case me:if(a&&(L(X,a)||"+"==a||"-"==a||"."==a))f+=z(a);else{if(":"!=a){if(i)return V;f="",h=ge,u=0;continue}if(i&&(l.isSpecial()!=c(he,f)||"file"==f&&(l.includesCredentials()||null!==l.port)||"file"==l.scheme&&!l.host))return;if(l.scheme=f,i)return void(l.isSpecial()&&he[l.scheme]==l.port&&(l.port=null));f="","file"==l.scheme?h=Ae:l.isSpecial()&&n&&n.scheme==l.scheme?h=ve:l.isSpecial()?h=_e:"/"==r[u+1]?(h=ye,u++):(l.cannotBeABaseURL=!0,k(l.path,""),h=Ie)}break;case ge: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=Oe;break}h="file"==n.scheme?Ae:xe;continue;case ve:if("/"!=a||"/"!=r[u+1]){h=xe;continue}h=we,u++;break;case ye:if("/"==a){h=Se;break}h=Le;continue;case xe: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=be;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=De;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=Le;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=Oe}break;case be:if(!l.isSpecial()||"/"!=a&&"\\"!=a){if("/"!=a){l.username=n.username,l.password=n.password,l.host=n.host,l.port=n.port,h=Le;continue}h=Se}else h=we;break;case _e:if(h=we,"/"!=a||"/"!=R(f,u+1))continue;u++;break;case we:if("/"!=a&&"\\"!=a){h=Se;continue}break;case Se:if("@"==a){m&&(f="%40"+f),m=!0,s=d(f);for(var x=0;x65535)return W;l.port=l.isSpecial()&&w===he[l.scheme]?null:w,f=""}if(i)return;h=Re;continue}return W}f+=a;break;case Ae:if(l.scheme="file","/"==a||"\\"==a)h=Ce;else{if(!n||"file"!=n.scheme){h=Le;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=De;else{if("#"!=a){ue(I(p(r,u),""))||(l.host=n.host,l.path=p(n.path),l.shortenPath()),h=Le;continue}l.host=n.host,l.path=p(n.path),l.query=n.query,l.fragment="",h=Oe}}break;case Ce:if("/"==a||"\\"==a){h=Pe;break}n&&"file"==n.scheme&&!ue(I(p(r,u),""))&&(ce(n.path[0],!0)?k(l.path,n.path[0]):l.host=n.host),h=Le;continue;case Pe:if(a==e||"/"==a||"\\"==a||"?"==a||"#"==a){if(!i&&ce(f))h=Le;else if(""==f){if(l.host="",i)return;h=Re}else{if(o=l.parseHost(f))return o;if("localhost"==l.host&&(l.host=""),i)return;f="",h=Re}continue}f+=a;break;case Re:if(l.isSpecial()){if(h=Le,"/"!=a&&"\\"!=a)continue}else if(i||"?"!=a)if(i||"#"!=a){if(a!=e&&(h=Le,"/"!=a))continue}else l.fragment="",h=Oe;else l.query="",h=De;break;case Le:if(a==e||"/"==a||"\\"==a&&l.isSpecial()||!i&&("?"==a||"#"==a)){if(pe(f)?(l.shortenPath(),"/"!=a&&!("\\"==a&&l.isSpecial())&&k(l.path,"")):de(f)?"/"!=a&&!("\\"==a&&l.isSpecial())&&k(l.path,""):("file"==l.scheme&&!l.path.length&&ce(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];)F(l.path);"?"==a?(l.query="",h=De):"#"==a&&(l.fragment="",h=Oe)}else f+=le(a,se);break;case Ie:"?"==a?(l.query="",h=De):"#"==a?(l.fragment="",h=Oe):a!=e&&(l.path[0]+=le(a,re));break;case De:i||"#"!=a?a!=e&&("'"==a&&l.isSpecial()?l.query+="%27":l.query+="#"==a?"%23":le(a,re)):(l.fragment="",h=Oe);break;case Oe:a!=e&&(l.fragment+=le(a,ae))}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&&L(Z,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(!L(Y,d()))return;for(;L(Y,d());){if(a=A(d(),10),null===r)r=a;else{if(0==r)return;r=10*r+a}if(r>255)return;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),L($,e)||(t=function(e){var t,i,n,r,a,s,o,l=U(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=L(q,r)?16:8,r=B(r,8==a?1:2)),""===r)s=0;else{if(!L(10==a?J:8==a?K:Z,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 ke(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())},Be=Ue.prototype,ze=function(e,t){return{get:function(){return w(this)[e]()},set:t&&function(e){return w(this)[t](e)},configurable:!0,enumerable:!0}};i&&(l(Be,"href",ze("serialize","setHref")),l(Be,"origin",ze("getOrigin")),l(Be,"protocol",ze("getProtocol","setProtocol")),l(Be,"username",ze("getUsername","setUsername")),l(Be,"password",ze("getPassword","setPassword")),l(Be,"host",ze("getHost","setHost")),l(Be,"hostname",ze("getHostname","setHostname")),l(Be,"port",ze("getPort","setPort")),l(Be,"pathname",ze("getPathname","setPathname")),l(Be,"search",ze("getSearch","setSearch")),l(Be,"searchParams",ze("getSearchParams")),l(Be,"hash",ze("getHash","setHash"))),o(Be,"toJSON",(function(){return w(this).serialize()}),{enumerable:!0}),o(Be,"toString",(function(){return w(this).serialize()}),{enumerable:!0}),E&&(Ne=E.createObjectURL,Fe=E.revokeObjectURL,Ne&&o(Ue,"createObjectURL",a(Ne,E)),Fe&&o(Ue,"revokeObjectURL",a(Fe,E))),v(Ue,"URL"),t({global:!0,constructor:!0,forced:!n,sham:!i},{URL:Ue})})),$ae=K((()=>{Yae()})),Jae=K((()=>{var e=tt(),t=Si(),i=Xt(),n=Xc(),r=yr(),a=lS(),s=t("URL");e({target:"URL",stat:!0,forced:!(a&&i((function(){s.canParse()})))},{canParse:function(e){var t=n(arguments.length,1),i=r(e),a=t<2||void 0===arguments[1]?void 0:r(arguments[1]);try{return!!new s(i,a)}catch(e){return!1}}})})),Qae=K((()=>{"use strict";var e=tt(),t=gr();e({target:"URL",proto:!0,enumerable:!0},{toJSON:function(){return t(URL.prototype.toString,this)}})})),eoe=K((()=>{Ik()})),toe=K((()=>{"use strict";var e=jn(),t=Qt(),i=Cs(),n=URLSearchParams.prototype,r=t(n.forEach);e&&!("size"in n)&&i(n,"size",{get:function(){var e=0;return r(this,(function(){e++})),e},configurable:!0,enumerable:!0})})),roe=K(((e,t)=>{rq(),uq(),hq(),dq(),fq(),pq(),mq(),gq(),vq(),yq(),xq(),bq(),Eq(),_q(),Tq(),$q(),e9(),v9(),E9(),T9(),C9(),L9(),k9(),B9(),H9(),V9(),G9(),W9(),X9(),Z9(),K9(),ej(),uj(),hj(),fj(),pj(),W1(),kj(),Hj(),Uj(),zj(),qj(),$j(),Kj(),Qj(),nW(),rW(),xW(),_W(),TW(),SW(),CW(),PW(),IW(),DW(),LW(),kW(),oX(),xX(),RX(),PX(),IX(),LX(),NX(),FX(),XX(),YX(),QX(),rY(),sY(),hY(),pY(),yY(),xY(),z3(),bY(),NY(),HY(),zY(),qY(),WY(),XY(),ZY(),JY(),t$(),r$(),s$(),o$(),l$(),c$(),u$(),f$(),g$(),v$(),y$(),C$(),P$(),L$(),k$(),N$(),F$(),B$(),H$(),j$(),Q$(),iZ(),uZ(),fZ(),yZ(),xZ(),_Z(),wZ(),MZ(),AZ(),IZ(),DZ(),LZ(),NZ(),FZ(),BZ(),UZ(),VZ(),GZ(),jZ(),XZ(),$Z(),KZ(),JZ(),QZ(),eK(),aK(),oK(),lK(),hK(),dK(),pK(),gK(),AJ(),RJ(),PJ(),OJ(),kJ(),zJ(),jJ(),WJ(),ZJ(),KJ(),JJ(),QJ(),eQ(),tQ(),nQ(),oQ(),cQ(),uQ(),MQ(),RQ(),yw(),OQ(),NQ(),HQ(),zQ(),qQ(),jQ(),$Q(),nee(),see(),oee(),kL(),bee(),Pee(),Dee(),Lee(),Fee(),Bee(),qee(),$ee(),Jee(),ite(),cte(),hte(),mte(),bte(),Ste(),Cte(),Pte(),Ite(),Dte(),Lte(),Ote(),kte(),Nte(),Fte(),Bte(),Hte(),Ute(),Vte(),mne(),gne(),vne(),yne(),xne(),bne(),Ene(),_ne(),Tne(),Sne(),Ane(),Cne(),Ine(),Fne(),Hne(),Vne(),Gne(),jne(),Xne(),Yne(),Zne(),Jne(),rre(),sre(),ore(),cre(),hre(),fre(),mre(),vre(),Tre(),Sre(),Are(),Lre(),Nre(),Vre(),zre(),Gre(),jre(),Wre(),Kre(),pie(),gie(),Sie(),Oie(),Vie(),Xie(),ose(),pse(),gse(),Ase(),Rse(),Pse(),Wse(),Qse(),$ae(),Jae(),Qae(),eoe(),toe(),t.exports=sT()})),ioe=K(((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 v?t:v,s=Object.create(a.prototype),o=new R(n||[]);return r(s,"_invoke",{value:T(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="suspendedYield",f="executing",m="completed",g={};function v(){}function y(){}function x(){}var b={};h(b,s,(function(){return this}));var _=Object.getPrototypeOf,w=_&&_(_(L([])));w&&w!==i&&n.call(w,s)&&(b=w);var S=x.prototype=v.prototype=Object.create(b);function M(e){["next","throw","return"].forEach((function(t){h(e,t,(function(e){return this._invoke(t,e)}))}))}function E(e,t){function 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 T(e,t,i){var n=d;return function(r,a){if(n===f)throw new Error("Generator is already running");if(n===m){if("throw"===r)throw a;return I()}for(i.method=r,i.arg=a;;){var s=i.delegate;if(s){var o=A(s,i);if(o){if(o===g)continue;return o}}if("next"===i.method)i.sent=i._sent=i.arg;else if("throw"===i.method){if(n===d)throw n=m,i.arg;i.dispatchException(i.arg)}else"return"===i.method&&i.abrupt("return",i.arg);n=f;var l=u(e,t,i);if("normal"===l.type){if(n=i.done?m:p,l.arg===g)continue;return{value:l.arg,done:i.done}}"throw"===l.type&&(n=m,i.method="throw",i.arg=l.arg)}}}function A(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,A(e,i),"throw"===i.method)||"return"!==n&&(i.method="throw",i.arg=new TypeError("The iterator does not provide a '"+n+"' method")),g;var a=u(r,e.iterator,i.arg);if("throw"===a.type)return i.method="throw",i.arg=a.arg,i.delegate=null,g;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,g):s:(i.method="throw",i.arg=new TypeError("iterator result is not an object"),i.delegate=null,g)}function C(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function P(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function R(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(C,this),this.reset(!0)}function L(e){if(e){var 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),P(i),g}},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;P(i)}return r}}throw new Error("illegal catch attempt")},delegateYield:function(e,i,n){return this.delegate={iterator:L(e),resultName:i,nextLoc:n},"next"===this.method&&(this.arg=t),g}},e}("object"==typeof t?t.exports:{});try{regeneratorRuntime=i}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=i:Function("r","regeneratorRuntime = r")(i)}})),cue=K(((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(t,i){for(var r=0;r=0&&i<=o.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&&h){try{return void(window.localStorage[h]=i)}catch(e){}try{window.document.cookie=encodeURIComponent(h)+"="+i+";"}catch(e){}}}(i),s.call(o,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)})),C5=K(((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]}})),I5=K(((e,t)=>{"use strict";var i=kA(),n=$ue();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=kA(),n=C5(),r=I5(),a=ehe();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=kA(),n=C5(),r=I5(),a=Jue(),s=ihe()})),lhe=K(((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=ahe(),n=lhe();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=zhe();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}})),Whe=K(((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);io.__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)}(o,e);var l=c(o);return function(e,t,i){t&&n(e.prototype,t),i&&n(e,i),Object.defineProperty(e,"prototype",{writable:!1})}(o,[{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=d(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,l=0;l>>15,d=o.__imul(c,n),p=o.__imul(c,r),f=o.__imul(u,n),m=s+d+a;a=m>>>30,m&=1073741823,a+=(m+=((32767&p)<<15)+((32767&f)<<15))>>>30,s=o.__imul(u,r)+(p>>>15)+(f>>>15),this.__setDigit(l,1073741823&m)}if(0!==a||0!==s)throw new Error("implementation bug")}},{key:"__inplaceAdd",value:function(e,t,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 o.__zero();if(o.__isOneDigitInt(e))return 0>e?o.__oneDigit(-e,!0):o.__oneDigit(e,!1);if(!t(e)||s(e)!==e)throw new RangeError("The number "+e+" cannot be converted to BigInt because it is not an integer");return o.__fromDouble(e)}if("string"==typeof e){var n=o.__fromString(e);if(null===n)throw new SyntaxError("Cannot convert "+e+" to a BigInt");return n}if("boolean"==typeof e)return!0===e?o.__oneDigit(1,!1):o.__zero();if("object"===i(e)){if(e.constructor===o)return e;var r=o.__toPrimitive(e);return o.BigInt(r)}throw new TypeError("Cannot convert "+e+" to a BigInt")}},{key:"toNumber",value:function(e){var t=e.length;if(0===t)return 0;if(1===t){var i=e.__unsignedDigit(0);return e.sign?-i:i}var n=e.__digit(t-1),r=o.__clz30(n),a=30*t-r;if(1024>>=12;var d=c-12,p=12<=c?0:l<<20+c,f=20+c;for(0>>30-d,p=l<>>30-f,f-=30;var m=o.__decideRounding(e,f,h,l);if((1===m||0===m&&1==(1&p))&&0==(p=p+1>>>0)&&++u>>>20!=0&&(u=0,1023<++s))return e.sign?-1/0:1/0;var g=e.sign?-2147483648:0;return s=s+1023<<20,o.__kBitConversionInts[1]=g|s|u,o.__kBitConversionInts[0]=p,o.__kBitConversionDouble[0]}},{key:"unaryMinus",value:function(e){if(0===e.length)return e;var t=e.__copy();return t.sign=!e.sign,t}},{key:"bitwiseNot",value:function(e){return e.sign?o.__absoluteSubOne(e).__trim():o.__absoluteAddOne(e,!0)}},{key:"exponentiate",value:function(e,t){if(t.sign)throw new RangeError("Exponent must be positive");if(0===t.length)return o.__oneDigit(1,!1);if(0===e.length)return e;if(1===e.length&&1===e.__digit(0))return!e.sign||1&t.__digit(0)?e:o.unaryMinus(e);if(1=o.__kMaxLengthBits)throw new RangeError("BigInt too big");if(1===e.length&&2===e.__digit(0)){var n=1+(0|i/30),r=new o(n,e.sign&&0!=(1&i));r.__initializeDigits();var a=1<>=1;0!==i;i>>=1)l=o.multiply(l,l),1&i&&(s=null===s?l:o.multiply(s,l));return s}},{key:"multiply",value:function(e,t){if(0===e.length)return e;if(0===t.length)return t;var i=e.length+t.length;30<=e.__clzmsd()+t.__clzmsd()&&i--;var n=new o(i,e.sign!==t.sign);n.__initializeDigits();for(var r=0;ro.__absoluteCompare(e,t))return o.__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:o.unaryMinus(e);i=o.__absoluteDivSmall(e,r,null)}else i=o.__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>o.__absoluteCompare(e,t))return e;var i=t.__unsignedDigit(0);if(1===t.length&&32767>=i){if(1===i)return o.__zero();var n=o.__absoluteModSmall(e,i);return 0===n?o.__zero():o.__oneDigit(n,e.sign)}var r=o.__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?o.__absoluteAdd(e,t,i):0<=o.__absoluteCompare(e,t)?o.__absoluteSub(e,t,i):o.__absoluteSub(t,e,!i)}},{key:"subtract",value:function(e,t){var i=e.sign;return i===t.sign?0<=o.__absoluteCompare(e,t)?o.__absoluteSub(e,t,i):o.__absoluteSub(t,e,!i):o.__absoluteAdd(e,t,i)}},{key:"leftShift",value:function(e,t){return 0===t.length||0===e.length?e:t.sign?o.__rightShiftByAbsolute(e,t):o.__leftShiftByAbsolute(e,t)}},{key:"signedRightShift",value:function(e,t){return 0===t.length||0===e.length?e:t.sign?o.__leftShiftByAbsolute(e,t):o.__rightShiftByAbsolute(e,t)}},{key:"unsignedRightShift",value:function(){throw new TypeError("BigInts have no unsigned right shift; use >> instead")}},{key:"lessThan",value:function(e,t){return 0>o.__compareToBigInt(e,t)}},{key:"lessThanOrEqual",value:function(e,t){return 0>=o.__compareToBigInt(e,t)}},{key:"greaterThan",value:function(e,t){return 0(e=s(e)))throw new RangeError("Invalid value: not (convertible to) a safe integer");if(0===e)return o.__zero();if(e>=o.__kMaxLengthBits)return t;var i=0|(e+29)/30;if(t.length(e=s(e)))throw new RangeError("Invalid value: not (convertible to) a safe integer");if(0===e)return o.__zero();if(t.sign){if(e>o.__kMaxLengthBits)throw new RangeError("BigInt too big");return o.__truncateAndSubFromPowerOfTwo(e,t,!1)}if(e>=o.__kMaxLengthBits)return t;var i=0|(e+29)/30;if(t.length>>n))return t}return o.__truncateToNBits(e,t)}},{key:"ADD",value:function(e,t){if(e=o.__toPrimitive(e),t=o.__toPrimitive(t),"string"==typeof e)return"string"!=typeof t&&(t=t.toString()),e+t;if("string"==typeof t)return e.toString()+t;if(e=o.__toNumeric(e),t=o.__toNumeric(t),o.__isBigInt(e)&&o.__isBigInt(t))return o.add(e,t);if("number"==typeof e&&"number"==typeof t)return e+t;throw new TypeError("Cannot mix BigInt and other types, use explicit conversions")}},{key:"LT",value:function(e,t){return o.__compare(e,t,0)}},{key:"LE",value:function(e,t){return o.__compare(e,t,1)}},{key:"GT",value:function(e,t){return o.__compare(e,t,2)}},{key:"GE",value:function(e,t){return o.__compare(e,t,3)}},{key:"EQ",value:function(e,t){for(;;){if(o.__isBigInt(e))return o.__isBigInt(t)?o.equal(e,t):o.EQ(t,e);if("number"==typeof e){if(o.__isBigInt(t))return o.__equalToNumber(t,e);if("object"!==i(t))return e==t;t=o.__toPrimitive(t)}else if("string"==typeof e){if(o.__isBigInt(t))return null!==(e=o.__fromString(e))&&o.equal(e,t);if("object"!==i(t))return e==t;t=o.__toPrimitive(t)}else if("boolean"==typeof e){if(o.__isBigInt(t))return o.__equalToNumber(t,+e);if("object"!==i(t))return e==t;t=o.__toPrimitive(t)}else if("symbol"===i(e)){if(o.__isBigInt(t))return!1;if("object"!==i(t))return e==t;t=o.__toPrimitive(t)}else{if("object"!==i(e))return e==t;if("object"===i(t)&&t.constructor!==o)return e==t;e=o.__toPrimitive(e)}}}},{key:"NE",value:function(e,t){return!o.EQ(e,t)}},{key:"DataViewGetBigInt64",value:function(e,t){var i=2>>30),h.__setDigit(2,s>>>28),h.__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 o(n,0>e),a=1048575&o.__kBitConversionInts[1]|1048576,s=o.__kBitConversionInts[0],l=i%30,h=0;if(l<20){var c=20-l;h=c+32,t=a>>>c,a=a<<32-c|s>>>c,s<<=32-c}else if(20===l)h=32,t=a,a=s,s=0;else{var u=l-20;h=32-u,t=a<>>32-u,a=s<>>2,a=a<<30|s>>>2,s<<=30):t=0,r.__setDigit(d,t);return r.__trim()}},{key:"__isWhitespace",value:function(e){return 13>=e&&9<=e||(159>=e?32==e:131071>=e?160==e||5760==e:196607>=e?10>=(e&=131071)||40==e||41==e||47==e||95==e||4096==e:65279==e)}},{key:"__fromString",value:function(e){var t=11073741824/l)return null;var c=new o(0|(29+(l*s+h>>>o.__kBitsPerCharTableShift))/30,!1),u=10>t?t:10,d=10>>0>>0>>o.__kBitsPerCharTableShift)/30;c.__inplaceMultiplyAdd(v,g,x)}while(!p)}else{l>>=o.__kBitsPerCharTableShift;var b=[],_=[],w=!1;do{for(var S,M=0,E=0;;){if(S=void 0,a-48>>>0>>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),l=0|(30*i-o.__clz30(s)+r-1)/r;if(e.sign&&l++,268435456>>g,d=30-g;d>=r;)h[c--]=o.__kConversionChars[u&a],u>>>=r,d-=r}var v=(u|s<>>r-d;0!==u;)h[c--]=o.__kConversionChars[u&a],u>>>=r;if(e.sign&&(h[c--]="-"),-1!==c)throw new Error("implementation bug");return h.join("")}},{key:"__toStringGeneric",value:function(e,t,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,l=30*n-o.__clz30(e.__digit(n-1)),h=o.__kMaxBitsPerChar[t]-1,c=l*o.__kBitsPerCharTableMultiplier,u=1+(c=0|(c+=h-1)/h)>>1,d=o.exponentiate(o.__oneDigit(t,!1),o.__oneDigit(u,!1)),p=d.__unsignedDigit(0);if(1===d.length&&32767>=p){(a=new o(e.length,!1)).__initializeDigits();for(var f,m=0,g=2*e.length-1;0<=g;g--)f=m<<15|e.__halfDigit(g),a.__setHalfDigit(g,0|f/p),m=0|f%p;s=m.toString(t)}else{var v=o.__absoluteDivLarge(e,d,!0,!0);a=v.quotient;var y=v.remainder.__trim();s=o.__toStringGeneric(y,t,!0)}a.__trim();for(var x=o.__toStringGeneric(a,t,!0);s.lengthn?o.__absoluteLess(i):0}},{key:"__compareToNumber",value:function(e,i){if(o.__isOneDigitInt(i)){var n=e.sign,r=0>i;if(n!==r)return o.__unequalSign(n);if(0===e.length){if(r)throw new Error("implementation bug");return 0===i?0:-1}if(1a?o.__absoluteGreater(n):st)return o.__unequalSign(i);if(0===t)throw new Error("implementation bug: should be handled elsewhere");if(0===e.length)return-1;o.__kBitConversionDouble[0]=t;var n=2047&o.__kBitConversionInts[1]>>>20;if(2047==n)throw new Error("implementation bug: handled elsewhere");var r=n-1023;if(0>r)return o.__absoluteGreater(i);var a=e.length,s=e.__digit(a-1),l=o.__clz30(s),h=30*a-l,c=r+1;if(hc)return o.__absoluteGreater(i);var u=1048576|1048575&o.__kBitConversionInts[1],d=o.__kBitConversionInts[0],p=29-l;if(p!==(0|(h-1)%30))throw new Error("implementation bug");var f,m=0;if(p<20){var g=20-p;m=g+32,f=u>>>g,u=u<<32-g|d>>>g,d<<=32-g}else if(20===p)m=32,f=u,u=d,d=0;else{var v=p-20;m=32-v,f=u<>>32-v,u=d<>>=0)>(f>>>=0))return o.__absoluteGreater(i);if(s>>2,u=u<<30|d>>>2,d<<=30):f=0;var x=e.__unsignedDigit(y);if(x>f)return o.__absoluteGreater(i);if(xi&&e.__unsignedDigit(0)===t(i):0===o.__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(o.__isBigInt(e)&&"string"==typeof t)return null!==(t=o.__fromString(t))&&o.__comparisonResultToBool(o.__compareToBigInt(e,t),i);if("string"==typeof e&&o.__isBigInt(t))return null!==(e=o.__fromString(e))&&o.__comparisonResultToBool(o.__compareToBigInt(e,t),i);if(e=o.__toNumeric(e),t=o.__toNumeric(t),o.__isBigInt(e)){if(o.__isBigInt(t))return o.__comparisonResultToBool(o.__compareToBigInt(e,t),i);if("number"!=typeof t)throw new Error("implementation bug");return o.__comparisonResultToBool(o.__compareToNumber(e,t),i)}if("number"!=typeof e)throw new Error("implementation bug");if(o.__isBigInt(t))return o.__comparisonResultToBool(o.__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(l,1073741823&r);for(;l>>30,a.__setDigit(l,1073741823&h)}return l>>30,r.__setDigit(s,1073741823&n);for(;s>>30,r.__setDigit(s,1073741823&l)}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 o(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 l=n;ln?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,l=0,h=0;h>>15,f=o.__imul(d,r),m=o.__imul(d,a),g=o.__imul(p,r);s=(c+=l+f+s)>>>30,c&=1073741823,s+=(c+=((32767&m)<<15)+((32767&g)<<15))>>>30,l=o.__imul(p,a)+(m>>>15)+(g>>>15),i.__setDigit(n,1073741823&c)}for(;0!==s||0!==l;n++){var v=i.__digit(n);v+=s+l,l=0,s=v>>>30,i.__setDigit(n,1073741823&v)}}}},{key:"__internalMultiplyAdd",value:function(e,t,i,n,r){for(var a=i,s=0,l=0;l>>15,t),d=c+((32767&u)<<15)+s+a;a=d>>>30,s=u>>>15,r.__setDigit(l,1073741823&d)}if(r.length>n)for(r.__setDigit(n++,a+s);n>>0,s=0|a/t,l=0|(a=((n=0|a%t)<<15|e.__halfDigit(r-1))>>>0)/t;n=0|a%t,i.__setDigit(r>>>1,s<<15|l)}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,l=null;i&&(l=new o(s+2>>>1,!1)).__initializeDigits();var h=new o(r+2>>>1,!1);h.__initializeDigits();var c=o.__clz15(t.__halfDigit(r-1));0>>0;m=0|v/d;for(var y=0|v%d,x=t.__halfDigit(r-2),b=u.__halfDigit(f+r-2);o.__imul(m,x)>>>0>(y<<16|b)>>>0&&(m--,!(32767<(y+=d))););}o.__internalMultiplyAdd(t,m,0,a,h);var _=u.__inplaceSub(h,f,r+1);0!==_&&(_=u.__inplaceAdd(t,f,r),u.__setHalfDigit(f+r,32767&u.__halfDigit(f+r)+_),m--),i&&(1&f?p=m<<15:l.__setDigit(f>>>1,p|m))}if(n)return u.__inplaceRightShift(c),i?{quotient:l,remainder:u}:u;if(i)return l;throw new Error("unreachable")}},{key:"__clz15",value:function(e){return o.__clz30(e)-15}},{key:"__specialLeftShift",value:function(e,t,i){var n=e.length,r=new o(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,l=a+n+(s?1:0),h=new o(l,e.sign);if(0===r){for(var c=0;c>>30-r;if(s)h.__setDigit(a+n,u);else if(0!==u)throw new Error("implementation bug")}return h.__trim()}},{key:"__rightShiftByAbsolute",value:function(e,t){var i=e.length,n=e.sign,r=o.__toShiftAmount(t);if(0>r)return o.__rightShiftByMaximum(n);var a=0|r/30,s=r%30,l=i-a;if(0>=l)return o.__rightShiftByMaximum(n);var h=!1;if(n)if(e.__digit(a)&(1<>>s,m=i-a-1,g=0;g>>s;u.__setDigit(m,f)}return h&&(u=o.__absoluteAddOne(u,!0,u)),u.__trim()}},{key:"__rightShiftByMaximum",value:function(e){return e?o.__oneDigit(1,!0):o.__zero()}},{key:"__toShiftAmount",value:function(e){if(1o.__kMaxLengthBits?-1:t}},{key:"__toPrimitive",value:function(e){var t=1>>l}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 o(a,i),l=0,h=a-1,c=0,u=r(h,t.length);l>>30,s.__setDigit(l,1073741823&n);for(;l>>m)-c,d&=g-1}return s.__setDigit(h,d),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}}]),o}(l(Array));return f.__kMaxLength=33554432,f.__kMaxLengthBits=f.__kMaxLength<<5,f.__kMaxBitsPerChar=[0,0,32,51,64,75,83,90,96,102,107,111,115,119,122,126,128,131,134,136,139,141,143,145,147,149,151,153,154,156,158,159,160,162,163,165,166],f.__kBitsPerCharTableShift=5,f.__kBitsPerCharTableMultiplier=1<>>0)/t)},f.__imul=e||function(e,t){return 0|e*t},f},"object"==typeof e&&void 0!==t?t.exports=n():"function"==typeof define&&define.amd?define(n):(i=i||self).JSBI=n()})),mc=K(((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]",L="[object Float32Array]",I="[object Float64Array]",D="[object Int8Array]",O="[object Int16Array]",k="[object Int32Array]",N="[object Uint8Array]",F="[object Uint8ClampedArray]",U="[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,W=/[&<>"']/g,G=RegExp(j.source),X=RegExp(W.source),Y=/<%-([\s\S]+?)%>/g,q=/<%([\s\S]+?)%>/g,K=/<%=([\s\S]+?)%>/g,J=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Z=/^\w*$/,$=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Q=/[\\^$.*+?()[\]{}|]/g,ee=RegExp(Q.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+"]",Le="["+we+"]",Ie="[^"+xe+Ee+Pe+_e+we+Se+"]",De="\\ud83c[\\udffb-\\udfff]",Oe="[^"+xe+"]",ke="(?:\\ud83c[\\udde6-\\uddff]){2}",Ne="[\\ud800-\\udbff][\\udc00-\\udfff]",Fe="["+Se+"]",Ue="\\u200d",Be="(?:"+Le+"|"+Ie+")",ze="(?:"+Fe+"|"+Ie+")",He="(?:['\u2019](?:d|ll|m|re|s|t|ve))?",Ve="(?:['\u2019](?:D|LL|M|RE|S|T|VE))?",je="(?:"+Ce+"|"+De+")?",We="["+Me+"]?",Ge=We+je+"(?:"+Ue+"(?:"+[Oe,ke,Ne].join("|")+")"+We+je+")*",Xe="(?:"+[Re,ke,Ne].join("|")+")"+Ge,Ye="(?:"+[Oe+Ce+"?",Ce,ke,Ne,Te].join("|")+")",qe=RegExp("['\u2019]","g"),Ke=RegExp(Ce,"g"),Je=RegExp(De+"(?="+De+")|"+Ye+Ge,"g"),Ze=RegExp([Fe+"?"+Le+"+"+He+"(?="+[Ae,Fe,"$"].join("|")+")",ze+"+"+Ve+"(?="+[Ae,Fe+Be,"$"].join("|")+")",Fe+"?"+Be+"+"+He,Fe+"+"+Ve,"\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Pe,Xe].join("|"),"g"),$e=RegExp("["+Ue+xe+be+Me+"]"),Qe=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,et=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],tt=-1,it={};it[L]=it[I]=it[D]=it[O]=it[k]=it[N]=it[F]=it[U]=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[L]=nt[I]=nt[D]=nt[O]=nt[k]=nt[b]=nt[_]=nt[w]=nt[M]=nt[E]=nt[T]=nt[A]=nt[N]=nt[F]=nt[U]=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 Zt(e,t){for(var i=e.length;i--&&Ft(t,e[i],0)>-1;);return i}var $t=Vt({"\xc0":"A","\xc1":"A","\xc2":"A","\xc3":"A","\xc4":"A","\xc5":"A","\xe0":"a","\xe1":"a","\xe2":"a","\xe3":"a","\xe4":"a","\xe5":"a","\xc7":"C","\xe7":"c","\xd0":"D","\xf0":"d","\xc8":"E","\xc9":"E","\xca":"E","\xcb":"E","\xe8":"e","\xe9":"e","\xea":"e","\xeb":"e","\xcc":"I","\xcd":"I","\xce":"I","\xcf":"I","\xec":"i","\xed":"i","\xee":"i","\xef":"i","\xd1":"N","\xf1":"n","\xd2":"O","\xd3":"O","\xd4":"O","\xd5":"O","\xd6":"O","\xd8":"O","\xf2":"o","\xf3":"o","\xf4":"o","\xf5":"o","\xf6":"o","\xf8":"o","\xd9":"U","\xda":"U","\xdb":"U","\xdc":"U","\xf9":"u","\xfa":"u","\xfb":"u","\xfc":"u","\xdd":"Y","\xfd":"y","\xff":"y","\xc6":"Ae","\xe6":"ae","\xde":"Th","\xfe":"th","\xdf":"ss","\u0100":"A","\u0102":"A","\u0104":"A","\u0101":"a","\u0103":"a","\u0105":"a","\u0106":"C","\u0108":"C","\u010a":"C","\u010c":"C","\u0107":"c","\u0109":"c","\u010b":"c","\u010d":"c","\u010e":"D","\u0110":"D","\u010f":"d","\u0111":"d","\u0112":"E","\u0114":"E","\u0116":"E","\u0118":"E","\u011a":"E","\u0113":"e","\u0115":"e","\u0117":"e","\u0119":"e","\u011b":"e","\u011c":"G","\u011e":"G","\u0120":"G","\u0122":"G","\u011d":"g","\u011f":"g","\u0121":"g","\u0123":"g","\u0124":"H","\u0126":"H","\u0125":"h","\u0127":"h","\u0128":"I","\u012a":"I","\u012c":"I","\u012e":"I","\u0130":"I","\u0129":"i","\u012b":"i","\u012d":"i","\u012f":"i","\u0131":"i","\u0134":"J","\u0135":"j","\u0136":"K","\u0137":"k","\u0138":"k","\u0139":"L","\u013b":"L","\u013d":"L","\u013f":"L","\u0141":"L","\u013a":"l","\u013c":"l","\u013e":"l","\u0140":"l","\u0142":"l","\u0143":"N","\u0145":"N","\u0147":"N","\u014a":"N","\u0144":"n","\u0146":"n","\u0148":"n","\u014b":"n","\u014c":"O","\u014e":"O","\u0150":"O","\u014d":"o","\u014f":"o","\u0151":"o","\u0154":"R","\u0156":"R","\u0158":"R","\u0155":"r","\u0157":"r","\u0159":"r","\u015a":"S","\u015c":"S","\u015e":"S","\u0160":"S","\u015b":"s","\u015d":"s","\u015f":"s","\u0161":"s","\u0162":"T","\u0164":"T","\u0166":"T","\u0163":"t","\u0165":"t","\u0167":"t","\u0168":"U","\u016a":"U","\u016c":"U","\u016e":"U","\u0170":"U","\u0172":"U","\u0169":"u","\u016b":"u","\u016d":"u","\u016f":"u","\u0171":"u","\u0173":"u","\u0174":"W","\u0175":"w","\u0176":"Y","\u0177":"y","\u0178":"Y","\u0179":"Z","\u017b":"Z","\u017d":"Z","\u017a":"z","\u017c":"z","\u017e":"z","\u0132":"IJ","\u0133":"ij","\u0152":"Oe","\u0153":"oe","\u0149":"'n","\u017f":"s"}),Qt=Vt({"&":"&","<":"<",">":">",'"':""","'":"'"});function ei(e){return"\\"+rt[e]}function ti(e){return $e.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,Le=t["__core-js_shared__"],Ie=Pe.toString,De=Re.hasOwnProperty,Oe=0,ke=(ie=/[^.]+$/.exec(Le&&Le.keys&&Le.keys.IE_PROTO||""))?"Symbol(src)_1."+ie:"",Ne=Re.toString,Fe=Ie.call(Me),Ue=ht._,Be=Ee("^"+Ie.call(De).replace(Q,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),ze=dt?t.Buffer:i,He=t.Symbol,Ve=t.Uint8Array,je=ze?ze.allocUnsafe:i,We=ni(Me.getPrototypeOf,Me),Ge=Me.create,Xe=Re.propertyIsEnumerable,Ye=Ce.splice,Je=He?He.isConcatSpreadable:i,$e=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=Da(bi),Pi=Da(_i),Ri=Da(wi),Li=Da(Si),Ii=Da(Mi),Di=He?He.prototype:i,Oi=Di?Di.valueOf:i,ki=Di?Di.toString:i;function Ni(e){if(Js(e)&&!Bs(e)&&!(e instanceof zi)){if(e instanceof Bi)return e;if(De.call(e,"__wrapped__"))return Oa(e)}return new Bi(e)}var Fi=function(){function e(){}return function(t){if(!Ks(t))return{};if(Ge)return Ge(t);e.prototype=t;var n=new e;return e.prototype=i,n}}();function Ui(){}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(!Ks(e))return e;var u=Bs(e);if(u){if(o=function(e){var t=e.length,i=new e.constructor(t);return t&&"string"==typeof e[0]&&De.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(js(e))return xr(e,l);if(d==w||d==p||f&&!a){if(o=h||f?{}:da(e),!l)return h?function(e,t){return Tr(e,ha(e),t)}(e,function(e,t){return e&&Tr(t,Co(t),e)}(o,e)):function(e,t){return Tr(e,la(e),t)}(e,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 L:case I:case D:case O:case k:case N:case F:case U: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 Gi);var v=s.get(e);if(v)return v;s.set(e,o),to(e)?e.forEach((function(i){o.add(an(i,t,n,i,e,s))})):Zs(e)&&e.forEach((function(i,r){o.set(r,an(i,t,n,r,e,s))}));var S=u?i:(c?h?ea:Qr:h?Co:Ao)(e);return St(S||e,(function(i,r){S&&(i=e[r=i]),Zi(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 Ta((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=Kt,s=!1,t=new Wi(t));e:for(;++r-1},Vi.prototype.set=function(e,t){var i=this.__data__,n=$i(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},Wi.prototype.add=Wi.prototype.push=function(e){return this.__data__.set(e,r),this},Wi.prototype.has=function(e){return this.__data__.has(e)},Gi.prototype.clear=function(){this.__data__=new Vi,this.size=0},Gi.prototype.delete=function(e){var t=this.__data__,i=t.delete(e);return this.size=t.size,i},Gi.prototype.get=function(e){return this.__data__.get(e)},Gi.prototype.has=function(e){return this.__data__.has(e)},Gi.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,Ao)}function yn(e,t){return e&&gn(e,t,Ao)}function xn(e,t){return Tt(t,(function(t){return Xs(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&&De.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 Wi(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 Wn(e,t){return e+ft(yi()*(t-e+1))}function Gn(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 Aa(wa(e,t,Qo),e+"")}function Yn(e){return Yi(No(e))}function qn(e,t){var i=No(e);return Ra(i,rn(t,0,i.length))}function Kn(e,t,n,r){if(!Ks(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&&!no(s)&&(i?s<=t:s=200){var h=t?null:Gr(e);if(h)return ai(h);s=!1,r=Kt,l=new Wi}else l=t?[]:o;e:for(;++n=r?e:Qn(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=no(e),o=t!==i,l=null===t,h=t==t,c=no(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 $r((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&&x.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 Wi: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 Pa(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 Ra(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,es(e,n)}));function os(e){var t=Ni(e);return t.__chain__=!0,t}function ls(e,t){return t(e)}var hs=$r((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:ls,args:[a],thisArg:i}),new Bi(r,this.__chain__).thru((function(e){return t&&!e.length&&e.push(i),e}))):this.thru(a)})),cs=Ar((function(e,t,i){De.call(e,i)?++e[i]:tn(e,i,1)})),us=Or(Ua),ds=Or(Ba);function ps(e,t){return(Bs(e)?St:hn)(e,ra(t,3))}function fs(e,t){return(Bs(e)?Mt:cn)(e,ra(t,3))}var ms=Ar((function(e,t,i){De.call(e,i)?e[i].push(t):tn(e,i,[t])})),gs=Xn((function(e,t,i){var n=-1,r="function"==typeof t,a=Hs(e)?xe(e.length):[];return hn(e,(function(e){a[++n]=r?_t(t,e,i):An(e,t,i)})),a})),vs=Ar((function(e,t,i){tn(e,i,t)}));function ys(e,t){return(Bs(e)?Pt:kn)(e,ra(t,3))}var xs=Ar((function(e,t,i){e[i?0:1].push(t)}),(function(){return[[],[]]})),bs=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),[])})),_s=ct||function(){return ht.Date.now()};function ws(e,t,n){return t=n?i:t,t=e&&null==t?e.length:t,Yr(e,o,i,i,i,i,t)}function Ss(e,t){var r;if("function"!=typeof t)throw new Ae(n);return e=ho(e),function(){return--e>0&&(r=t.apply(this,arguments)),e<=1&&(t=i),r}}var Ms=Xn((function(e,t,i){var n=1;if(i.length){var r=ri(i,na(Ms));n|=s}return Yr(e,n,t,i,r)})),Es=Xn((function(e,t,i){var n=3;if(i.length){var r=ri(i,na(Es));n|=s}return Yr(t,n,e,i,r)}));function Ts(e,t,r){var a,s,o,l,h,c,u=0,d=!1,p=!1,f=!0;if("function"!=typeof e)throw new Ae(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=_s();if(g(e))return y(e);h=Ta(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=_s(),n=g(e);if(a=arguments,s=this,c=e,n){if(h===i)return function(e){return u=e,h=Ta(v,t),d?m(e):l}(c);if(p)return yr(h),h=Ta(v,t),m(c)}return h===i&&(h=Ta(v,t)),l}return t=uo(t)||0,Ks(r)&&(d=!!r.leading,o=(p="maxWait"in r)?fi(uo(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(_s())},x}var As=Xn((function(e,t){return on(e,1,t)})),Cs=Xn((function(e,t,i){return on(e,uo(t)||0,i)}));function Ps(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(Ps.Cache||ji),i}function Rs(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)}}Ps.Cache=ji;var Ls=gr((function(e,t){var i=(t=1==t.length&&Bs(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})),Us=Cn(function(){return arguments}())?Cn:function(e){return Js(e)&&De.call(e,"callee")&&!Xe.call(e,"callee")},Bs=xe.isArray,zs=mt?Yt(mt):function(e){return Js(e)&&wn(e)==P};function Hs(e){return null!=e&&qs(e.length)&&!Xs(e)}function Vs(e){return Js(e)&&Hs(e)}var js=Vt||dl,Ws=gt?Yt(gt):function(e){return Js(e)&&wn(e)==g};function Gs(e){if(!Js(e))return!1;var t=wn(e);return t==v||"[object DOMException]"==t||"string"==typeof e.message&&"string"==typeof e.name&&!Qs(e)}function Xs(e){if(!Ks(e))return!1;var t=wn(e);return t==y||t==x||"[object AsyncFunction]"==t||"[object Proxy]"==t}function Ys(e){return"number"==typeof e&&e==ho(e)}function qs(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=h}function Ks(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function Js(e){return null!=e&&"object"==typeof e}var Zs=vt?Yt(vt):function(e){return Js(e)&&ca(e)==b};function $s(e){return"number"==typeof e||Js(e)&&wn(e)==_}function Qs(e){if(!Js(e)||wn(e)!=w)return!1;var t=We(e);if(null===t)return!0;var i=De.call(t,"constructor")&&t.constructor;return"function"==typeof i&&i instanceof i&&Ie.call(i)==Fe}var eo=yt?Yt(yt):function(e){return Js(e)&&wn(e)==M},to=xt?Yt(xt):function(e){return Js(e)&&ca(e)==E};function io(e){return"string"==typeof e||!Bs(e)&&Js(e)&&wn(e)==T}function no(e){return"symbol"==typeof e||Js(e)&&wn(e)==A}var ro=bt?Yt(bt):function(e){return Js(e)&&qs(e.length)&&!!it[wn(e)]},ao=Vr(On),so=Vr((function(e,t){return e<=t}));function oo(e){if(!e)return[];if(Hs(e))return io(e)?oi(e):Er(e);if($e&&e[$e])return function(e){for(var t,i=[];!(t=e.next()).done;)i.push(t.value);return i}(e[$e]());var t=ca(e);return(t==b?ii:t==E?ai:No)(e)}function lo(e){return e?(e=uo(e))===l||e===-l?17976931348623157e292*(e<0?-1:1):e==e?e:0:0===e?e:0}function ho(e){var t=lo(e),i=t%1;return t==t?i?t-i:t:0}function co(e){return e?rn(ho(e),0,u):0}function uo(e){if("number"==typeof e)return e;if(no(e))return c;if(Ks(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=Ks(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 po(e){return Tr(e,Co(e))}function fo(e){return null==e?"":ar(e)}var mo=Cr((function(e,t){if(xa(t)||Hs(t))Tr(t,Ao(t),e);else for(var i in t)De.call(t,i)&&Zi(e,i,t[i])})),go=Cr((function(e,t){Tr(t,Co(t),e)})),vo=Cr((function(e,t,i,n){Tr(t,Co(t),e,n)})),yo=Cr((function(e,t,i,n){Tr(t,Ao(t),e,n)})),xo=$r(nn),bo=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,Jr));for(var r=t.length;r--;)or(i,t[r]);return i})),Io=$r((function(e,t){return null==e?{}:function(e,t){return Hn(e,t,(function(t,i){return So(e,i)}))}(e,t)}));function Do(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 Oo=Xr(Ao),ko=Xr(Co);function No(e){return null==e?[]:qt(e,Ao(e))}var Fo=Ir((function(e,t,i){return t=t.toLowerCase(),e+(i?Uo(t):t)}));function Uo(e){return Xo(fo(e).toLowerCase())}function Bo(e){return(e=fo(e))&&e.replace(ge,$t).replace(Ke,"")}var zo=Ir((function(e,t,i){return e+(i?"-":"")+t.toLowerCase()})),Ho=Ir((function(e,t,i){return e+(i?" ":"")+t.toLowerCase()})),Vo=Lr("toLowerCase"),jo=Ir((function(e,t,i){return e+(i?"_":"")+t.toLowerCase()})),Wo=Ir((function(e,t,i){return e+(i?" ":"")+Xo(t)})),Go=Ir((function(e,t,i){return e+(i?" ":"")+t.toUpperCase()})),Xo=Lr("toUpperCase");function Yo(e,t,n){return e=fo(e),(t=n?i:t)===i?function(e){return Qe.test(e)}(e)?function(e){return e.match(Ze)||[]}(e):function(e){return e.match(se)||[]}(e):e.match(t)||[]}var qo=Xn((function(e,t){try{return _t(e,i,t)}catch(e){return Gs(e)?e:new _e(e)}})),Ko=$r((function(e,t){return St(t,(function(t){t=Ia(t),tn(e,t,Ms(e[t],e))})),e}));function Jo(e){return function(){return e}}var Zo=kr(),$o=kr(!0);function Qo(e){return e}function el(e){return In("function"==typeof e?e:an(e,1))}var tl=Xn((function(e,t){return function(i){return An(i,e,t)}})),il=Xn((function(e,t){return function(i){return An(e,i,t)}}));function nl(e,t,i){var n=Ao(t),r=xn(t,n);null==i&&(!Ks(t)||!r.length&&n.length)&&(i=t,t=e,e=this,r=xn(t,Ao(t)));var a=!(Ks(i)&&"chain"in i&&!i.chain),s=Xs(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 rl(){}var al=Br(Pt),sl=Br(Et),ol=Br(Dt);function ll(e){return ga(e)?Ht(Ia(e)):function(e){return function(t){return bn(t,e)}}(e)}var hl=Hr(),cl=Hr(!0);function ul(){return[]}function dl(){return!1}var pl=Ur((function(e,t){return e+t}),0),fl=Wr("ceil"),ml=Ur((function(e,t){return e/t}),1),gl=Wr("floor"),vl=Ur((function(e,t){return e*t}),1),yl=Wr("round"),xl=Ur((function(e,t){return e-t}),0);return Ni.after=function(e,t){if("function"!=typeof t)throw new Ae(n);return e=ho(e),function(){if(--e<1)return t.apply(this,arguments)}},Ni.ary=ws,Ni.assign=mo,Ni.assignIn=go,Ni.assignInWith=vo,Ni.assignWith=yo,Ni.at=xo,Ni.before=Ss,Ni.bind=Ms,Ni.bindAll=Ko,Ni.bindKey=Es,Ni.castArray=function(){if(!arguments.length)return[];var e=arguments[0];return Bs(e)?e:[e]},Ni.chain=os,Ni.chunk=function(e,t,n){t=(n?ma(e,t,n):t===i)?1:fi(ho(t),0);var r=null==e?0:e.length;if(!r||t<1)return[];for(var a=0,s=0,o=xe(pt(r/t));aa?0:a+n),(r=r===i||r>a?a:ho(r))<0&&(r+=a),r=n>r?0:co(r);n>>0)?(e=fo(e))&&("string"==typeof t||null!=t&&!eo(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(ho(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?Qn(e,1,t):[]},Ni.take=function(e,t,n){return e&&e.length?Qn(e,0,(t=n||t===i?1:ho(t))<0?0:t):[]},Ni.takeRight=function(e,t,n){var r=null==e?0:e.length;return r?Qn(e,(t=r-(t=n||t===i?1:ho(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 Ks(i)&&(r="leading"in i?!!i.leading:r,a="trailing"in i?!!i.trailing:a),Ts(e,t,{leading:r,maxWait:t,trailing:a})},Ni.thru=ls,Ni.toArray=oo,Ni.toPairs=Oo,Ni.toPairsIn=ko,Ni.toPath=function(e){return Bs(e)?Pt(e,Ia):no(e)?[e]:Er(La(fo(e)))},Ni.toPlainObject=po,Ni.transform=function(e,t,i){var n=Bs(e),r=n||js(e)||ro(e);if(t=ra(t,4),null==i){var a=e&&e.constructor;i=r?n?new a:[]:Ks(e)&&Xs(a)?Fi(We(e)):{}}return(r?St:vn)(e,(function(e,n,r){return t(i,e,n,r)})),i},Ni.unary=function(e){return ws(e,1)},Ni.union=Ja,Ni.unionBy=Za,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=Qa,Ni.unzipWith=es,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=No,Ni.valuesIn=function(e){return null==e?[]:qt(e,Co(e))},Ni.without=ts,Ni.words=Yo,Ni.wrap=function(e,t){return Is(fr(t),e)},Ni.xor=is,Ni.xorBy=ns,Ni.xorWith=rs,Ni.zip=as,Ni.zipObject=function(e,t){return dr(e||[],t||[],Zi)},Ni.zipObjectDeep=function(e,t){return dr(e||[],t||[],Kn)},Ni.zipWith=ss,Ni.entries=Oo,Ni.entriesIn=ko,Ni.extend=go,Ni.extendWith=vo,nl(Ni,Ni),Ni.add=pl,Ni.attempt=qo,Ni.camelCase=Fo,Ni.capitalize=Uo,Ni.ceil=fl,Ni.clamp=function(e,t,n){return n===i&&(n=t,t=i),n!==i&&(n=(n=uo(n))==n?n:0),t!==i&&(t=(t=uo(t))==t?t:0),rn(uo(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,Ao(t))},Ni.deburr=Bo,Ni.defaultTo=function(e,t){return null==e||e!=e?t:e},Ni.divide=ml,Ni.endsWith=function(e,t,n){e=fo(e),t=ar(t);var r=e.length,a=n=n===i?r:rn(ho(n),0,r);return(n-=t.length)>=0&&e.slice(n,a)==t},Ni.eq=ks,Ni.escape=function(e){return(e=fo(e))&&X.test(e)?e.replace(W,Qt):e},Ni.escapeRegExp=function(e){return(e=fo(e))&&ee.test(e)?e.replace(Q,"\\$&"):e},Ni.every=function(e,t,n){var r=Bs(e)?Et:un;return n&&ma(e,t,n)&&(t=i),r(e,ra(t,3))},Ni.find=us,Ni.findIndex=Ua,Ni.findKey=function(e,t){return kt(e,ra(t,3),vn)},Ni.findLast=ds,Ni.findLastIndex=Ba,Ni.findLastKey=function(e,t){return kt(e,ra(t,3),yn)},Ni.floor=gl,Ni.forEach=ps,Ni.forEachRight=fs,Ni.forIn=function(e,t){return null==e?e:mn(e,ra(t,3),Co)},Ni.forInRight=function(e,t){return null==e?e:gn(e,ra(t,3),Co)},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=wo,Ni.gt=Ns,Ni.gte=Fs,Ni.has=function(e,t){return null!=e&&ua(e,t,Mn)},Ni.hasIn=So,Ni.head=Ha,Ni.identity=Qo,Ni.includes=function(e,t,i,n){e=Hs(e)?e:No(e),i=i&&!n?ho(i):0;var r=e.length;return i<0&&(i=fi(r+i,0)),io(e)?i<=r&&e.indexOf(t,i)>-1:!!r&&Ft(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:ho(i);return r<0&&(r=fi(n+r,0)),Ft(e,t,r)},Ni.inRange=function(e,t,n){return t=lo(t),n===i?(n=t,t=0):n=lo(n),function(e,t,i){return e>=mi(t,i)&&e=-h&&e<=h},Ni.isSet=to,Ni.isString=io,Ni.isSymbol=no,Ni.isTypedArray=ro,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=zo,Ni.last=Ga,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=ho(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=Ho,Ni.lowerFirst=Vo,Ni.lt=ao,Ni.lte=so,Ni.max=function(e){return e&&e.length?dn(e,Qo,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,Qo)},Ni.meanBy=function(e,t){return zt(e,ra(t,2))},Ni.min=function(e){return e&&e.length?dn(e,Qo,On):i},Ni.minBy=function(e,t){return e&&e.length?dn(e,ra(t,2),On):i},Ni.stubArray=ul,Ni.stubFalse=dl,Ni.stubObject=function(){return{}},Ni.stubString=function(){return""},Ni.stubTrue=function(){return!0},Ni.multiply=vl,Ni.nth=function(e,t){return e&&e.length?Bn(e,ho(t)):i},Ni.noConflict=function(){return ht._===this&&(ht._=Ue),this},Ni.noop=rl,Ni.now=_s,Ni.pad=function(e,t,i){e=fo(e);var n=(t=ho(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=fo(e);var n=(t=ho(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 Wn(e,t)},Ni.reduce=function(e,t,i){var n=Bs(e)?Lt:jt,r=arguments.length<3;return n(e,ra(t,4),i,r,hn)},Ni.reduceRight=function(e,t,i){var n=Bs(e)?It: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:ho(t),Gn(fo(e),t)},Ni.replace=function(){var e=arguments,t=fo(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=Gt(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),eo(a)){if(e.slice(l).search(a)){var c,u=h;for(a.global||(a=Ee(a.source,fo(ce.exec(a))+"g")),a.lastIndex=0;c=a.exec(u);)var d=c.index;h=h.slice(0,d===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=fo(e))&&G.test(e)?e.replace(j,hi):e},Ni.uniqueId=function(e){var t=++Oe;return fo(e)+t},Ni.upperCase=Go,Ni.upperFirst=Xo,Ni.each=ps,Ni.eachRight=fs,Ni.first=Ha,nl(Ni,function(){var e={};return vn(Ni,(function(t,i){De.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(ho(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(Qo)},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(Rs(ra(e)))},zi.prototype.slice=function(e,t){e=ho(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=ho(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||Bs(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:ls,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(Bs(r)?r:[],e)}return this[i]((function(i){return t.apply(Bs(i)?i:[],e)}))}})),vn(zi.prototype,(function(e,t){var i=Ni[t];if(i){var n=i.name+"";De.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=Bs(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 Ui;){var r=Oa(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:ls,args:[Ka],thisArg:i}),new Bi(t,this.__chain__)}return this.thru(Ka)},Ni.prototype.toJSON=Ni.prototype.valueOf=Ni.prototype.value=function(){return cr(this.__wrapped__,this.__actions__)},Ni.prototype.first=Ni.prototype.head,$e&&(Ni.prototype[$e]=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)})),ede=K(((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()})),tde=K(((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()})),rde=K(((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}})),sde=K(((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}})),lde=K(((e,t)=>{var i=rde(),n=sde();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})),ude=K(((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,L=e-c,I=l-c,D=i-u,O=h-u;v=(A=(b=L-(x=(y=134217729*L)-(y-L)))*(w=O-(_=(y=134217729*O)-(y-O)))-((T=L*O)-x*_-b*_-x*w))-(S=A-(P=(b=D-(x=(y=134217729*D)-(y-D)))*(w=I-(_=(y=134217729*I)-(y-I)))-((C=D*I)-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-(L+(v=e-L))+(v-c),m=l-(I+(v=l-I))+(v-c),f=i-(D+(v=i-D))+(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+=L*g+O*p-(D*m+I*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=I-(_=(y=134217729*I)-(y-I)))-((C=f*I)-x*_-b*_-x*w))),o[0]=A-(S+v)+(v-P),v=(E=T-((M=T+S)-(v=M-T))+(S-v))-(S=E-C),o[1]=E-(S+v)+(v-C),v=(R=M+S)-M,o[2]=M-(R-v)+(S-v),o[3]=R;let F=t(4,n,4,o,r);v=(A=(b=L-(x=(y=134217729*L)-(y-L)))*(w=g-(_=(y=134217729*g)-(y-g)))-((T=L*g)-x*_-b*_-x*w))-(S=A-(P=(b=D-(x=(y=134217729*D)-(y-D)))*(w=m-(_=(y=134217729*m)-(y-m)))-((C=D*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 U=t(F,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(U,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={})})),gde=K(((e,t)=>{"use strict";var i=ede(),n=tde(),r=lde(),a=ude().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})),Fde=K(((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")}}}})),Hde=K(((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}})),Vde=K(((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}}})),Gde=K(((e,t)=>{var i=Vde();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})),$de=K(((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=Fde(),r=Hde(),a=Gde(),s=jde(),o=Xde(),l=$de(),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})),zpe=K(((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,L=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}(),I=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(L.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]:L.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 U(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[1];if((l=e[0]).Clear(),this.FixOrientations(),this.DoOffset(t),(s=new i.Clipper(0)).AddPaths(this.m_destPolys,i.PolyType.ptSubject,!0),t>0)s.Execute(i.ClipType.ctUnion,l,i.PolyFillType.pftPositive,i.PolyFillType.pftPositive);else{var n=i.Clipper.GetBounds(this.m_destPolys);if((o=new i.Path).push(new i.IntPoint2(n.left-10,n.bottom+10)),o.push(new i.IntPoint2(n.right+10,n.bottom+10)),o.push(new i.IntPoint2(n.right+10,n.top-10)),o.push(new i.IntPoint2(n.left-10,n.top-10)),s.AddPath(o,i.PolyType.ptSubject,!0),s.ReverseSolution=!0,s.Execute(i.ClipType.ctUnion,l,i.PolyFillType.pftNegative,i.PolyFillType.pftNegative),1===l.ChildCount()&&l.Childs()[0].ChildCount()>0){var r=l.Childs()[0];l.Childs()[0]=r.Childs()[0],l.Childs()[0].m_Parent=l;for(var a=1;a0)s.Execute(i.ClipType.ctUnion,l,i.PolyFillType.pftPositive,i.PolyFillType.pftPositive);else n=i.Clipper.GetBounds(this.m_destPolys),(o=new i.Path).push(new i.IntPoint2(n.left-10,n.bottom+10)),o.push(new i.IntPoint2(n.right+10,n.bottom+10)),o.push(new i.IntPoint2(n.right+10,n.top-10)),o.push(new i.IntPoint2(n.left-10,n.top-10)),s.AddPath(o,i.PolyType.ptSubject,!0),s.ReverseSolution=!0,s.Execute(i.ClipType.ctUnion,l,i.PolyFillType.pftNegative,i.PolyFillType.pftNegative),l.length>0&&l.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{})),Zme=K((()=>{})),Kme=K((()=>{})),Jme=K((()=>{})),Qme=K((()=>{})),ege=K((()=>{})),Cge=K(((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(xo(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=>{St(this,i,!0),e(t)},this.reject=e=>{St(this,i,!0),t(e)}}))}get settled(){return ce(this,i)}};let p=null,f=null},(__unused_webpack_module,exports,__w_pdfjs_require__)=>{var s,e,n,r,n1,a,gP,l,c,u,h,d,f,p,g,w6,v,E,S6,_,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,L=!0===e.disableAutoFetch,I=!0===e.pdfBug,D=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}),F=e.filterFactory||new DefaultFilterFactory({docId:r,ownerDocument:C});(0,_util.setVerbosityLevel)(p);let U={canvasFactory:N,filterFactory:F};if(k||(U.cMapReaderFactory=new v({baseUrl:m,isCompressed:g}),U.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:L,rangeChunkSize:u,length:D,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:L,pdfBug:I,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:D,initialData:c.initialData,progressiveDone:c.progressiveDone,contentDispositionFilename:c.contentDispositionFilename,disableRange:P,disableStream:R},c):s||(t=createPDFNetworkStream({url:a,length:D,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,U);n._transport=a,i.send("Ready",null)}))})).catch(n._capability.reject),n}function _fetchDocument(e,t){return dt(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"+N_(t,s)._++,this.destroyed=!1,this.onPassword=null,this.onProgress=null}get promise(){return this._capability.promise}destroy(){return dt(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;s=new WeakMap,Je(PDFDocumentLoadingTask,s,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 dt(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);St(this,n,!1),ft(this,a,gP).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)&&St(this,n,!0),ft(this,r,n1).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(),St(this,n,!1),ft(this,a,gP).call(this),Promise.all(e)}cleanup(e=!1){St(this,n,!0);let t=ft(this,r,n1).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();ft(this,r,n1).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,n1=function(t=!1){if(ft(this,a,gP).call(this),!ce(this,n)||this.destroyed)return!1;if(t)return St(this,e,setTimeout((()=>{St(this,e,null),ft(this,r,n1).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(),St(this,n,!1),!0},a=new WeakSet,gP=function(){ce(this,e)&&(clearTimeout(ce(this,e)),St(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 FI)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=()=>dt(this,null,(function*(){let mainWorkerMessageHandler=this._mainThreadWorkerMessageHandler;if(mainWorkerMessageHandler)return mainWorkerMessageHandler;if(_is_node.isNodeJS&&"function"==typeof FI){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 ft(this,g,w6).call(this,"GetFieldObjects")}hasJSActions(){return ft(this,g,w6).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 dt(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,w6=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=ft(this,E,S6).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=ft(this,E,S6).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()}St(this,v,Object.create(null))}}v=new WeakMap,E=new WeakSet,S6=function(e){return ce(this,v)[e]||(ce(this,v)[e]={capability:new _util.PromiseCapability,data:null})};class RenderTask{constructor(e){Je(this,_,null),St(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 w=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(w,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(w,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(w,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 dt(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(w,R).delete(this._canvas),this.callback())))}))}},InternalRenderTask=w;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&&ft(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)&&(St(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)||(St(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);St(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),Bi(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)?St(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),St(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(){St(this,o,!0)}disableEditMode(){St(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){St(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,Bi(d,"_colorManager",new h.ColorManager),Bi(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,L,I,D,O,k,N,F,U,B,z,H,V,j,W,G,X,Y,q,K,J,Z,$,Q,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}${N_(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),St(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),St(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):(St(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;Bi(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,U),Je(this,z),Je(this,V),Je(this,W),Je(this,X),Je(this,q),Je(this,J),Je(this,$),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,L,this.onRotationChanging.bind(this)),Je(this,I,{isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1}),Je(this,D,null),St(this,D,e),St(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,L)),St(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(){ft(this,N,F).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,L));for(let e of ce(this,d).values())e.destroy();ce(this,d).clear(),ce(this,u).clear(),ce(this,y).clear(),St(this,c,null),ce(this,S).clear(),ce(this,f).destroy()}onPageChanging({pageNumber:e}){St(this,m,e-1)}focusMainContainer(){ce(this,D).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)ft(this,J,Z).call(this,t);ft(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?(ft(this,O,k).call(this),ft(this,U,B).call(this),ft(this,V,j).call(this,{isEditing:ce(this,w)!==ie.AnnotationEditorType.NONE,isEmpty:ft(this,$,Q).call(this),hasSomethingToUndo:ce(this,f).hasSomethingToUndo(),hasSomethingToRedo:ce(this,f).hasSomethingToRedo(),hasSelectedEditor:!1})):(ft(this,N,F).call(this),ft(this,z,H).call(this),ft(this,V,j).call(this,{isEditing:!1}))}registerEditorTypes(e){if(!ce(this,v)){St(this,v,e);for(let e of ce(this,v))ft(this,W,G).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(St(this,w,e),e===ie.AnnotationEditorType.NONE)this.setEditingState(!1),ft(this,q,K).call(this);else{this.setEditingState(!0),ft(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&&(St(this,c,e),e&&ft(this,W,G).call(this,e.propertiesToUpdate))}toggleSelected(e){if(ce(this,S).has(e))return ce(this,S).delete(e),e.unselect(),void ft(this,V,j).call(this,{hasSelectedEditor:this.hasSelection});ce(this,S).add(e),e.select(),ft(this,W,G).call(this,e.propertiesToUpdate),ft(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(),ft(this,W,G).call(this,e.propertiesToUpdate),ft(this,V,j).call(this,{hasSelectedEditor:!0})}isSelected(e){return ce(this,S).has(e)}unselect(e){e.unselect(),ce(this,S).delete(e),ft(this,V,j).call(this,{hasSelectedEditor:this.hasSelection})}get hasSelection(){return 0!==ce(this,S).size}undo(){ce(this,f).undo(),ft(this,V,j).call(this,{hasSomethingToUndo:ce(this,f).hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:ft(this,$,Q).call(this)})}redo(){ce(this,f).redo(),ft(this,V,j).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:ce(this,f).hasSomethingToRedo(),isEmpty:ft(this,$,Q).call(this)})}addCommands(e){ce(this,f).add(e),ft(this,V,j).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:ft(this,$,Q).call(this)})}delete(){if(this.commitOrRemove(),!this.hasSelection)return;let e=[...ce(this,S)];this.addCommands({cmd:()=>{for(let t of e)t.remove()},undo:()=>{for(let t of e)ft(this,J,Z).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();ft(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(),ft(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,L=new WeakMap,I=new WeakMap,D=new WeakMap,O=new WeakSet,k=function(){ce(this,D).addEventListener("keydown",ce(this,A))},N=new WeakSet,F=function(){ce(this,D).removeEventListener("keydown",ce(this,A))},U=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,I)[e]!==t))&&ce(this,x).dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(ce(this,I),e)})},W=new WeakSet,G=function(e){ce(this,x).dispatch("annotationeditorparamschanged",{source:this,details:e})},X=new WeakSet,Y=function(){if(!ce(this,_)){St(this,_,!0);for(let e of ce(this,d).values())e.enable()}},q=new WeakSet,K=function(){if(this.unselectAll(),ce(this,_)){St(this,_,!1);for(let e of ce(this,d).values())e.disable()}},J=new WeakSet,Z=function(e){let t=ce(this,d).get(e.pageIndex);t?t.addOrRebuild(e):this.addEditor(e)},$=new WeakSet,Q=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());ft(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,W(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=W,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 L,I=class{},D=I;Bi(D,"CSS",96),Bi(D,"PDF",72),Bi(D,"PDF_TO_CSS_UNITS",I.CSS/I.PDF),t.PixelsPerInch=D;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),St(this,a,e),St(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_${N_(this,p)._++}`,l=`url(#${o})`;ce(this,f,m).set(e,l),ce(this,f,m).set(r,l);let h=ft(this,b,_).call(this,o);return ft(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(St(this,l,n),St(this,h,"none"),null==(i=ce(this,o))||i.remove(),!e||!t)return ce(this,h);let r=ft(this,T,A).call(this,e);e=P.Util.makeHexColor(...r);let s=ft(this,T,A).call(this,t);if(t=P.Util.makeHexColor(...s),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:xo((e+.055)/1.055,2.4)}let d=u.join(","),p=`g_${ce(this,a)}_hcm_filter`,f=St(this,c,ft(this,b,_).call(this,p));ft(this,M,E).call(this,d,d,d,f),ft(this,y,x).call(this,f);let m=(e,t)=>{let 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 ft(this,M,E).call(this,m(0,5),m(1,5),m(2,5),f),St(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(St(this,u,s),St(this,d,"none"),null==(r=ce(this,c))||r.remove(),!e||!t)return ce(this,d);let[o,l]=[e,t].map(ft(this,T,A).bind(this)),h=Math.round(.2126*o[0]+.7152*o[1]+.0722*o[2]),p=Math.round(.2126*l[0]+.7152*l[1]+.0722*l[2]),[f,m]=[i,n].map(ft(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=St(this,c,ft(this,b,_).call(this,S));return ft(this,y,x).call(this,C),ft(this,M,E).call(this,w(f[0],m[0],5),w(f[1],m[1],5),w(f[2],m[2],5),C),St(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(),St(this,r,null)),ce(this,n)&&(ce(this,n).clear(),St(this,n,null)),St(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)||St(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),St(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),ft(this,w,S).call(this,r,"feFuncR",e),ft(this,w,S).call(this,r,"feFuncG",t),ft(this,w,S).call(this,r,"feFuncB",i)},T=new WeakSet,A=function(e){return ce(this,g,v).style.color=e,W(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 dt(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 F extends C.BaseCMapReaderFactory{_fetchData(e,t){return N(e,this.isCompressed).then((e=>({cMapData:e,compressionType:t})))}}t.DOMCMapReaderFactory=F;class U extends C.BaseStandardFontDataFactory{_fetchData(e){return N(e,!0)}}t.DOMStandardFontDataFactory=U;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(){Bi(this,"started",Object.create(null)),Bi(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;L||(L=new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?"));let t=L.exec(e);if(!t)return null;let 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 dt(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 dt(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 dt(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 dt(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(){ft(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(),ft(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(ft(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(),ft(this,a,s).call(this),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas)}paintImageMaskXObject(e){if(!this.contentVisible)return;let t=e.count;(e=this.getObject(e.data,e)).count=t;let 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 L in o.OPS)void 0!==R.prototype[L]&&(R.prototype[o.OPS[L]]=R.prototype[L])},(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],L=c[s+1],I=c[s+2],D=c[o],O=c[o+1],k=c[o+2],N=Math.round(f),F=Math.round(y);for(let U=N;U<=F;U++){if(Uy?1:g===y?0:(g-U)/(g-y),x=m-(m-v)*e,b=R-(R-D)*e,_=L-(L-O)*e,w=I-(I-k)*e}let e;e=Uy?1:(f-U)/(f-y),S=p-(p-v)*e,M=A-(A-D)*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*U+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;Bi(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(),ft(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)),ft(this,o,l).call(this,a,t);break;case 2:e.success?a.cancelCall.resolve():a.cancelCall.reject(c(e.reason)),ft(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 dt(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 ft(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?ft(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),St(this,n,e),St(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."),St(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 St(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 dt(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 dt(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)=>{T6().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 Zme().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=T6(),s=Kme(),o=Jme(),l=Qme(),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 dt(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 dt(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 dt(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 dt(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 dt(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 dt(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]),St(this,d,e.uiManager),this.pageIndex=e.pageIndex,this.div=e.div,St(this,n,e.accessibilityManager),St(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()){ft(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();ft(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;St(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()}}ft(this,x,b).call(this),this.isEmpty&&(this.div.hidden=!0),St(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(ft(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(St(this,h,!1),!ce(this,r))return void St(this,r,!0);ft(this,v,y).call(this,e)}}pointerdown(e){let{isMac:t}=_.FeatureTest.platform;if(0!==e.button||e.ctrlKey&&t||e.target!==this.div)return;St(this,h,!0);let i=ce(this,d).getActive();St(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",ft(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=ft(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(){St(this,c,!0);for(let e of ce(this,l).values())e.isEmpty()&&e.remove();St(this,c,!1)},Bi(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(pi(Kn({},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),St(this,o,e.color||R._defaultColor||C.AnnotationEditor._defaultLineColor),St(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:ft(this,d,p).call(this,t);break;case T.AnnotationEditorParamsType.FREETEXT_COLOR:ft(this,f,m).call(this,t)}}static get defaultPropertiesToUpdate(){return[[T.AnnotationEditorParamsType.FREETEXT_SIZE,R._defaultFontSize],[T.AnnotationEditorParamsType.FREETEXT_COLOR,R._defaultColor||C.AnnotationEditor._defaultLineColor]]}get propertiesToUpdate(){return[[T.AnnotationEditorParamsType.FREETEXT_SIZE,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?ft(this,M,E).call(this):(this.enableEditMode(),this.editorDiv.focus())}isEmpty(){return!this.editorDiv||""===this.editorDiv.innerText.trim()}remove(){this.isEditing=!1,this.parent.setEditingState(!0),this.parent.div.classList.add("freeTextEditing"),super.remove()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();let e=ce(this,l),t=St(this,l,ft(this,g,v).call(this).trimEnd());if(e===t)return;let i=e=>{St(this,l,e),e?(ft(this,b,_).call(this),this.rebuild(),ft(this,y,x).call(this)):this.remove()};this.addCommands({cmd:()=>{i(t)},undo:()=>{i(e)},mustExec:!1}),ft(this,y,x).call(this)}shouldGetKeyboardEvents(){return this.isInEditMode()}dblclick(e){this.enableEditMode(),this.editorDiv.focus()}keydown(e){e.target===this.div&&"Enter"===e.key&&(this.enableEditMode(),this.editorDiv.focus())}editorDivKeydown(e){R._keyboardManager.exec(this,e)}editorDivFocus(e){this.isEditing=!0}editorDivBlur(e){this.isEditing=!1}editorDivInput(e){this.parent.div.classList.toggle("freeTextEditing",this.isEmpty())}disableEditing(){this.editorDiv.setAttribute("role","comment"),this.editorDiv.removeAttribute("aria-multiline")}enableEditing(){this.editorDiv.setAttribute("role","textbox"),this.editorDiv.setAttribute("aria-multiline",!0)}render(){if(this.div)return this.div;let e,t;this.width&&(e=this.x,t=this.y),super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",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);ft(this,b,_).call(this),this.div.draggable=!0,this.editorDiv.contentEditable=!1}else this.div.draggable=!1,this.editorDiv.contentEditable=!0;return this.div}get contentDiv(){return this.editorDiv}static deserialize(e,t,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 St(r,c,e.fontSize),St(r,o,T.Util.makeHexColor(...e.color)),St(r,l,e.value),r.annotationElementId=e.id||null,St(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&&!ft(this,w,S).call(this,r)?null:(r.id=this.annotationElementId,r)}},L=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),St(this,c,e),ft(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:()=>{St(this,o,this.editorDiv.style.color=e)},undo:()=>{St(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(ft(this,y,x).call(this),!e&&(0===this.width||0===this.height))return void setTimeout((()=>ft(this,M,E).call(this,!0)),0);let t=R._internalPadding*this.parentScale;ce(this,u).rect=this.getRect(t,t)},Bi(L,"_freeTextDefaultContent",""),Bi(L,"_l10nPromise"),Bi(L,"_internalPadding",0),Bi(L,"_defaultColor",null),Bi(L,"_defaultFontSize",10),Bi(L,"_type","freetext"),t.FreeTextEditor=L},(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,L,I,D,O,k,N,F,U,B,z,H;Object.defineProperty(t,"__esModule",{value:!0}),t.InkAnnotationElement=t.FreeTextAnnotationElement=t.AnnotationLayer=void 0;var V=i(1),j=i(6),W=i(3),G=i(30),X=i(31);let Y=1e3,q=new WeakSet;function K(e){return{width:e[2]-e[0],height:e[3]-e[1]}}class J{static create(e){switch(e.data.annotationType){case V.AnnotationType.LINK:return new $(e);case V.AnnotationType.TEXT:return new Q(e);case V.AnnotationType.WIDGET:switch(e.data.fieldType){case"Tx":return new te(e);case"Btn":return e.data.radioButton?new re(e):e.data.checkBox?new 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 Z(e)}}}class Z{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}=K(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}=K(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]=G.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 $ extends Z{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?(ft(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)&&ft(this,n,r).call(this)}_bindNamedAction(e,t){e.href=this.linkService.getAnchorUrl(""),e.onclick=()=>(this.linkService.executeNamedAction(t),!1),ft(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},ft(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),ft(this,n,r).call(this)}_bindResetFormAction(e,t){let i=e.onclick;if(i||(e.href=this.linkService.getAnchorUrl("")),ft(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),ft(this,n,r).call(this)};class Q extends Z{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 Z{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 ${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 Z{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:L,open:I}){Je(this,S),Je(this,E),Je(this,A),Je(this,o,null),Je(this,l,ft(this,A,C).bind(this)),Je(this,h,ft(this,E,T).bind(this)),Je(this,c,ft(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),St(this,d,e),St(this,_,n),St(this,p,a),St(this,b,s),St(this,m,P),St(this,u,t),St(this,x,R),St(this,g,L),St(this,f,i);let D=j.PDFDateString.toDateObject(r);D&&St(this,o,P.l10n.get("annotation_date_string",{date:D.toLocaleDateString(),time:D.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,I&&ft(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=St(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,F).set(i.data.id,i);let a=i.render();if(e.hidden&&(a.style.visibility="hidden"),Array.isArray(a))for(let n of a)ft(this,U,B).call(this,n,e.id);else ft(this,U,B).call(this,a,e.id)}ft(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}),ft(this,z,H).call(this),t.hidden=!1}getEditableAnnotations(){return Array.from(ce(this,F).values())}getEditableAnnotation(e){return ce(this,F).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 dt(this,null,(function*(){return"en-us"}))},getDirection(){return dt(this,null,(function*(){return"ltr"}))},get(e){return dt(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 dt(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,L,I,D,O,k,N,F,U,B,z,H,V,j,W,G,X,Y,q,K,J,Z,$,Q,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(pi(Kn({},e),{name:"inkEditor"})),Je(this,x),Je(this,_),Je(this,S),Je(this,E),Je(this,A),Je(this,P),Je(this,L),Je(this,D),Je(this,k),Je(this,F),Je(this,B),Je(this,H),Je(this,j),Je(this,G),Je(this,Y),Je(this,K),Je(this,Z),Je(this,Q),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:ft(this,x,b).call(this,t);break;case be.AnnotationEditorParamsType.INK_COLOR:ft(this,_,w).call(this,t);break;case be.AnnotationEditorParamsType.INK_OPACITY:ft(this,S,M).call(this,t)}}static get defaultPropertiesToUpdate(){return[[be.AnnotationEditorParamsType.INK_THICKNESS,Ee._defaultThickness],[be.AnnotationEditorParamsType.INK_COLOR,Ee._defaultColor||_e.AnnotationEditor._defaultLineColor],[be.AnnotationEditorParamsType.INK_OPACITY,Math.round(100*Ee._defaultOpacity)]]}get propertiesToUpdate(){var e;return[[be.AnnotationEditorParamsType.INK_THICKNESS,this.thickness||Ee._defaultThickness],[be.AnnotationEditorParamsType.INK_COLOR,this.color||Ee._defaultColor||_e.AnnotationEditor._defaultLineColor],[be.AnnotationEditorParamsType.INK_OPACITY,Math.round(100*(null!=(e=this.opacity)?e:Ee._defaultOpacity))]]}rebuild(){super.rebuild(),null!==this.div&&(this.canvas||(ft(this,Y,q).call(this),ft(this,K,J).call(this)),this.isAttachedToDOM||(this.parent.add(this),ft(this,Z,$).call(this)),ft(this,ge,ve).call(this))}remove(){null!==this.canvas&&(this.isEmpty()||this.commit(),this.canvas.width=this.canvas.height=0,this.canvas.remove(),this.canvas=null,ce(this,m).disconnect(),St(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(),St(this,d,!0),this.div.classList.add("disabled"),ft(this,ge,ve).call(this,!0),this.parent.addInkEditorIfNeeded(!0),this.parent.moveEditorInDOM(this),this.div.focus({preventScroll:!0}))}focusin(e){super.focusin(e),this.enableEditMode()}canvasPointerdown(e){0!==e.button||!this.isInEditMode()||ce(this,d)||(this.setInForeground(),e.preventDefault(),"mouse"!==e.type&&this.div.focus(),ft(this,P,R).call(this,e.offsetX,e.offsetY))}canvasContextMenu(e){e.preventDefault()}canvasPointermove(e){e.preventDefault(),ft(this,L,I).call(this,e.offsetX,e.offsetY)}canvasPointerup(e){e.preventDefault(),ft(this,G,X).call(this,e)}canvasPointerleave(e){ft(this,G,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]=ft(this,E,T).call(this);if(this.setAt(i,n,0,0),this.setDims(r,a),ft(this,Y,q).call(this),this.width){let[i,n]=this.parentDimensions;this.setAt(e*i,t*n,this.width*i,this.height*n),St(this,f,!0),ft(this,Z,$).call(this),this.setDims(this.width*i,this.height*n),ft(this,j,W).call(this),ft(this,ye,xe).call(this),this.div.classList.add("disabled")}else this.div.classList.add("editing"),this.enableEditMode();return ft(this,K,J).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;St(this,g,i),St(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)&&ft(this,Q,ee).call(this,e,t),ft(this,Z,$).call(this),ft(this,j,W).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;St(h,n,p/f),St(h,d,!0),St(h,g,Math.round(p)),St(h,v,Math.round(f));let{paths:x,rect:b,rotation:_}=e;for(let{bezier:n}of x){n=ft(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,ft(this,ge,ve).call(this)},undo:()=>{this.thickness=t,ft(this,ge,ve).call(this)},mustExec:!0,type:be.AnnotationEditorParamsType.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0})},_=new WeakSet,w=function(e){let t=this.color;this.addCommands({cmd:()=>{this.color=e,ft(this,j,W).call(this)},undo:()=>{this.color=t,ft(this,j,W).call(this)},mustExec:!0,type:be.AnnotationEditorParamsType.INK_COLOR,overwriteIfSameType:!0,keepUndo:!0})},S=new WeakSet,M=function(e){e/=100;let t=this.opacity;this.addCommands({cmd:()=>{this.opacity=e,ft(this,j,W).call(this)},undo:()=>{this.opacity=t,ft(this,j,W).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)||(St(this,f,!0),ft(this,Z,$).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]),St(this,p,!1),ft(this,A,C).call(this),St(this,y,(()=>{ft(this,F,U).call(this),ce(this,y)&&window.requestAnimationFrame(ce(this,y))})),window.requestAnimationFrame(ce(this,y))},L=new WeakSet,I=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]),St(this,p,!0),r.length<=2)return a.moveTo(...r[0]),void a.lineTo(e,t);3===r.length&&(St(this,u,a=new Path2D),a.moveTo(...r[0])),ft(this,B,z).call(this,a,...r.at(-3),...r.at(-2),e,t)},D=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(St(this,y,null),e=Math.min(Math.max(e,0),this.canvas.width),t=Math.min(Math.max(t,0),this.canvas.height),ft(this,L,I).call(this,e,t),ft(this,D,O).call(this),1!==this.currentPath.length)i=ft(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=[],St(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||(ft(this,Y,q).call(this),ft(this,K,J).call(this)),ft(this,ge,ve).call(this))},mustExec:!0})},F=new WeakSet,U=function(){if(!ce(this,p))return;St(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),ft(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")},K=new WeakSet,J=function(){St(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)},Z=new WeakSet,$=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),ft(this,te,ie).call(this)},Q=new WeakSet,ee=function(e,t){let i=ft(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=ft(this,fe,me).call(this)/2;this.ctx.setTransform(this.scaleFactor,0,0,this.scaleFactor,this.translationX*this.scaleFactor+e,this.translationY*this.scaleFactor+e)},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),Bi(Te,"_defaultColor",null),Bi(Te,"_defaultOpacity",1),Bi(Te,"_defaultThickness",1),Bi(Te,"_l10nPromise"),Bi(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=ege().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("e8e3d2b32fb89d6a2985daf9066550dd8bb4f8f4f8e8c208f55ede4744cd925f")){var e=document.createElement("style");e.id="e8e3d2b32fb89d6a2985daf9066550dd8bb4f8f4f8e8c208f55ede4744cd925f",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}#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}}#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 BEe=fetch;window.fetch=(...e)=>Promise.resolve(BEe(...e));var Etn=$i(Cz(),1),_tn=$i(roe(),1),Ttn=$i(ioe(),1),qt={};k_(qt,{ACESFilmicToneMapping:()=>Qle,AddEquation:()=>Co,AddOperation:()=>$le,AdditiveAnimationBlendMode:()=>xB,AdditiveBlending:()=>sc,AlphaFormat:()=>rce,AlwaysCompare:()=>Ece,AlwaysDepth:()=>zle,AlwaysStencilFunc:()=>fce,AmbientLight:()=>gl,AmbientLightProbe:()=>zF,AnimationAction:()=>zM,AnimationClip:()=>Ka,AnimationLoader:()=>OF,AnimationMixer:()=>$F,AnimationObjectGroup:()=>YF,AnimationUtils:()=>$it,ArcCurve:()=>kp,ArrayCamera:()=>bM,ArrowHelper:()=>cc,Audio:()=>UM,AudioAnalyser:()=>WF,AudioContext:()=>Ux,AudioListener:()=>qF,AudioLoader:()=>UF,AxesHelper:()=>cB,BackSide:()=>zi,BasicDepthPacking:()=>hce,BasicShadowMap:()=>kJe,Bone:()=>dl,BooleanKeyframeTrack:()=>Ph,Box2:()=>Gi,Box3:()=>It,Box3Helper:()=>oB,BoxGeometry:()=>na,BoxHelper:()=>aB,BufferAttribute:()=>pn,BufferGeometry:()=>Lt,BufferGeometryLoader:()=>HM,ByteType:()=>tce,Cache:()=>Up,Camera:()=>Th,CameraHelper:()=>Gx,CanvasTexture:()=>Rx,CapsuleGeometry:()=>w0,CatmullRomCurve3:()=>wM,CineonToneMapping:()=>Jle,CircleGeometry:()=>S0,ClampToEdgeWrapping:()=>bi,Clock:()=>Qa,Color:()=>ct,ColorKeyframeTrack:()=>Nx,ColorManagement:()=>cl,CompressedArrayTexture:()=>CF,CompressedTexture:()=>Ah,CompressedTextureLoader:()=>kF,ConeGeometry:()=>M0,CubeCamera:()=>yM,CubeReflectionMapping:()=>Pd,CubeRefractionMapping:()=>Id,CubeTexture:()=>Op,CubeTextureLoader:()=>Fx,CubeUVReflectionMapping:()=>B0,CubicBezierCurve:()=>Cx,CubicBezierCurve3:()=>SM,CubicInterpolant:()=>LM,CullFaceBack:()=>LN,CullFaceFront:()=>Dle,CullFaceFrontBack:()=>OJe,CullFaceNone:()=>Ile,Curve:()=>Sa,CurvePath:()=>AM,CustomBlending:()=>qp,CustomToneMapping:()=>ece,CylinderGeometry:()=>oc,Cylindrical:()=>eB,Data3DTexture:()=>wx,DataArrayTexture:()=>x0,DataTexture:()=>hl,DataTextureLoader:()=>zp,DataUtils:()=>z0,DecrementStencilOp:()=>qJe,DecrementWrapStencilOp:()=>WJe,DefaultLoadingManager:()=>eo,DepthFormat:()=>Cd,DepthStencilFormat:()=>Eh,DepthTexture:()=>Od,DirectionalLight:()=>Os,DirectionalLightHelper:()=>zx,DiscreteInterpolant:()=>OM,DisplayP3ColorSpace:()=>_B,DodecahedronGeometry:()=>A0,DoubleSide:()=>vr,DstAlphaFactor:()=>N0,DstColorFactor:()=>F0,DynamicCopyUsage:()=>oQe,DynamicDrawUsage:()=>tQe,DynamicReadUsage:()=>iQe,EdgesGeometry:()=>lu,EllipseCurve:()=>Rh,EqualCompare:()=>gce,EqualDepth:()=>qle,EqualStencilFunc:()=>ZJe,EquirectangularReflectionMapping:()=>Dp,EquirectangularRefractionMapping:()=>yx,Euler:()=>zn,EventDispatcher:()=>Do,ExtrudeGeometry:()=>kd,FileLoader:()=>Hr,Float16BufferAttribute:()=>vF,Float32BufferAttribute:()=>Ft,Float64BufferAttribute:()=>yF,FloatType:()=>ta,Fog:()=>iu,FogExp2:()=>E0,FramebufferTexture:()=>RF,FrontSide:()=>ai,Frustum:()=>ra,GLBufferAttribute:()=>JF,GLSL1:()=>cQe,GLSL3:()=>oF,GreaterCompare:()=>yce,GreaterDepth:()=>Wle,GreaterEqualCompare:()=>bce,GreaterEqualDepth:()=>jle,GreaterEqualStencilFunc:()=>eQe,GreaterStencilFunc:()=>JJe,GridHelper:()=>Vx,Group:()=>Gn,HalfFloatType:()=>xr,HemisphereLight:()=>du,HemisphereLightHelper:()=>iB,HemisphereLightProbe:()=>VF,IcosahedronGeometry:()=>R0,ImageBitmapLoader:()=>Hx,ImageLoader:()=>Vp,ImageUtils:()=>Tx,IncrementStencilOp:()=>GJe,IncrementWrapStencilOp:()=>jJe,InstancedBufferAttribute:()=>Mh,InstancedBufferGeometry:()=>BM,InstancedInterleavedBuffer:()=>KF,InstancedMesh:()=>Li,Int16BufferAttribute:()=>mF,Int32BufferAttribute:()=>gF,Int8BufferAttribute:()=>dF,IntType:()=>fB,InterleavedBuffer:()=>Sh,InterleavedBufferAttribute:()=>$a,Interpolant:()=>Ch,InterpolateDiscrete:()=>_h,InterpolateLinear:()=>ru,InterpolateSmooth:()=>fM,InvertStencilOp:()=>XJe,KeepStencilOp:()=>pM,KeyframeTrack:()=>Oo,LOD:()=>TM,LatheGeometry:()=>Fp,Layers:()=>Ld,LessCompare:()=>mce,LessDepth:()=>Gle,LessEqualCompare:()=>vce,LessEqualDepth:()=>mM,LessEqualStencilFunc:()=>KJe,LessStencilFunc:()=>$Je,Light:()=>Ja,LightProbe:()=>L0,Line:()=>rr,Line3:()=>Ra,LineBasicMaterial:()=>kn,LineCurve:()=>T0,LineCurve3:()=>MM,LineDashedMaterial:()=>uu,LineLoop:()=>_0,LineSegments:()=>Br,LinearEncoding:()=>EB,LinearFilter:()=>_r,LinearInterpolant:()=>kx,LinearMipMapLinearFilter:()=>UJe,LinearMipMapNearestFilter:()=>HJe,LinearMipmapLinearFilter:()=>Ta,LinearMipmapNearestFilter:()=>jp,LinearSRGBColorSpace:()=>wa,LinearToneMapping:()=>Zle,Loader:()=>hr,LoaderUtils:()=>Gs,LoadingManager:()=>hu,LoopOnce:()=>lce,LoopPingPong:()=>uce,LoopRepeat:()=>cce,LuminanceAlphaFormat:()=>ice,LuminanceFormat:()=>WM,MOUSE:()=>qM,Material:()=>ur,MaterialLoader:()=>O0,MathUtils:()=>Cn,Matrix3:()=>An,Matrix4:()=>Qe,MaxEquation:()=>FN,Mesh:()=>_t,MeshBasicMaterial:()=>rn,MeshDepthMaterial:()=>ac,MeshDistanceMaterial:()=>Mx,MeshLambertMaterial:()=>cu,MeshMatcapMaterial:()=>DM,MeshNormalMaterial:()=>Bd,MeshPhongMaterial:()=>zs,MeshPhysicalMaterial:()=>Lo,MeshStandardMaterial:()=>Fd,MeshToonMaterial:()=>IM,MinEquation:()=>NN,MirroredRepeatWrapping:()=>bh,MixOperation:()=>Yle,MultiplyBlending:()=>kN,MultiplyOperation:()=>jx,NearestFilter:()=>qr,NearestMipMapLinearFilter:()=>BJe,NearestMipMapNearestFilter:()=>FJe,NearestMipmapLinearFilter:()=>xh,NearestMipmapNearestFilter:()=>Dd,NeverCompare:()=>pce,NeverDepth:()=>Vle,NeverStencilFunc:()=>YJe,NoBlending:()=>jr,NoColorSpace:()=>nu,NoToneMapping:()=>Qc,NormalAnimationBlendMode:()=>YM,NormalBlending:()=>Pp,NotEqualCompare:()=>xce,NotEqualDepth:()=>Xle,NotEqualStencilFunc:()=>QJe,NumberKeyframeTrack:()=>ml,Object3D:()=>sn,ObjectLoader:()=>HF,ObjectSpaceNormalMap:()=>dce,OctahedronGeometry:()=>Hp,OneFactor:()=>kle,OneMinusDstAlphaFactor:()=>Ble,OneMinusDstColorFactor:()=>Hle,OneMinusSrcAlphaFactor:()=>dB,OneMinusSrcColorFactor:()=>Fle,OrthographicCamera:()=>Ir,PCFShadowMap:()=>uB,PCFSoftShadowMap:()=>k0,PMREMGenerator:()=>wh,Path:()=>au,PerspectiveCamera:()=>nr,Plane:()=>Nr,PlaneGeometry:()=>ti,PlaneHelper:()=>lB,PointLight:()=>lc,PointLightHelper:()=>rB,Points:()=>$r,PointsMaterial:()=>hi,PolarGridHelper:()=>sB,PolyhedronGeometry:()=>ou,PositionalAudio:()=>jF,PropertyBinding:()=>Wn,PropertyMixer:()=>VM,QuadraticBezierCurve:()=>Px,QuadraticBezierCurve3:()=>Ix,Quaternion:()=>ir,QuaternionKeyframeTrack:()=>Aa,QuaternionLinearInterpolant:()=>kM,RED_GREEN_RGTC2_Format:()=>sF,RED_RGTC1_Format:()=>oce,REVISION:()=>GM,RGBADepthPacking:()=>V0,RGBAFormat:()=>Vs,RGBAIntegerFormat:()=>yB,RGBA_ASTC_10x10_Format:()=>tF,RGBA_ASTC_10x5_Format:()=>JN,RGBA_ASTC_10x6_Format:()=>QN,RGBA_ASTC_10x8_Format:()=>eF,RGBA_ASTC_12x10_Format:()=>nF,RGBA_ASTC_12x12_Format:()=>rF,RGBA_ASTC_4x4_Format:()=>qN,RGBA_ASTC_5x4_Format:()=>jN,RGBA_ASTC_5x5_Format:()=>WN,RGBA_ASTC_6x5_Format:()=>XN,RGBA_ASTC_6x6_Format:()=>YN,RGBA_ASTC_8x5_Format:()=>$N,RGBA_ASTC_8x6_Format:()=>ZN,RGBA_ASTC_8x8_Format:()=>KN,RGBA_BPTC_Format:()=>dM,RGBA_ETC2_EAC_Format:()=>GN,RGBA_PVRTC_2BPPV1_Format:()=>VN,RGBA_PVRTC_4BPPV1_Format:()=>UN,RGBA_S3TC_DXT1_Format:()=>cM,RGBA_S3TC_DXT3_Format:()=>uM,RGBA_S3TC_DXT5_Format:()=>hM,RGB_ETC1_Format:()=>ace,RGB_ETC2_Format:()=>zN,RGB_PVRTC_2BPPV1_Format:()=>HN,RGB_PVRTC_4BPPV1_Format:()=>BN,RGB_S3TC_DXT1_Format:()=>lM,RGFormat:()=>sce,RGIntegerFormat:()=>vB,RawShaderMaterial:()=>PM,Ray:()=>Ya,Raycaster:()=>qs,RectAreaLight:()=>NM,RedFormat:()=>XM,RedIntegerFormat:()=>gB,ReinhardToneMapping:()=>Kle,RepeatWrapping:()=>Ei,ReplaceStencilOp:()=>zJe,ReverseSubtractEquation:()=>Ole,RingGeometry:()=>C0,SIGNED_RED_GREEN_RGTC2_Format:()=>aF,SIGNED_RED_RGTC1_Format:()=>iF,SRGBColorSpace:()=>en,Scene:()=>mi,ShaderChunk:()=>or,ShaderLib:()=>nc,ShaderMaterial:()=>an,ShadowMaterial:()=>CM,Shape:()=>ps,ShapeGeometry:()=>pl,ShapePath:()=>qx,ShapeUtils:()=>Ls,ShortType:()=>nce,Skeleton:()=>fl,SkeletonHelper:()=>nB,SkinnedMesh:()=>su,Source:()=>rc,Sphere:()=>cr,SphereGeometry:()=>Ma,Spherical:()=>Hd,SphericalHarmonics3:()=>FM,SplineCurve:()=>Np,SpotLight:()=>fu,SpotLightHelper:()=>tB,Sprite:()=>_M,SpriteMaterial:()=>Ax,SrcAlphaFactor:()=>hB,SrcAlphaSaturateFactor:()=>Ule,SrcColorFactor:()=>Nle,StaticCopyUsage:()=>aQe,StaticDrawUsage:()=>bx,StaticReadUsage:()=>rQe,StereoCamera:()=>GF,StreamCopyUsage:()=>lQe,StreamDrawUsage:()=>nQe,StreamReadUsage:()=>sQe,StringKeyframeTrack:()=>Ih,SubtractEquation:()=>Lle,SubtractiveBlending:()=>ON,TOUCH:()=>LJe,TangentSpaceNormalMap:()=>Vd,TetrahedronGeometry:()=>P0,Texture:()=>Fr,TextureLoader:()=>gs,TorusGeometry:()=>Nd,TorusKnotGeometry:()=>I0,Triangle:()=>ei,TriangleFanDrawMode:()=>U0,TriangleStripDrawMode:()=>Wx,TrianglesDrawMode:()=>bB,TubeGeometry:()=>D0,TwoPassDoubleSide:()=>NJe,UVMapping:()=>jM,Uint16BufferAttribute:()=>Lp,Uint32BufferAttribute:()=>Sx,Uint8BufferAttribute:()=>fF,Uint8ClampedBufferAttribute:()=>pF,Uniform:()=>Gp,UniformsGroup:()=>ZF,UniformsLib:()=>Kt,UniformsUtils:()=>gi,UnsignedByteType:()=>ic,UnsignedInt248Type:()=>eu,UnsignedIntType:()=>yh,UnsignedShort4444Type:()=>pB,UnsignedShort5551Type:()=>mB,UnsignedShortType:()=>H0,VSMShadowMap:()=>Kc,Vector2:()=>ye,Vector3:()=>L,Vector4:()=>lr,VectorKeyframeTrack:()=>Za,VideoTexture:()=>AF,WebGL1Renderer:()=>EM,WebGL3DRenderTarget:()=>uF,WebGLArrayRenderTarget:()=>cF,WebGLCoordinateSystem:()=>Jc,WebGLCubeRenderTarget:()=>xM,WebGLMultipleRenderTargets:()=>hF,WebGLRenderTarget:()=>Jn,WebGLRenderer:()=>ms,WebGLUtils:()=>Ice,WebGPUCoordinateSystem:()=>Ex,WireframeGeometry:()=>RM,WrapAroundEnding:()=>xx,ZeroCurvatureEnding:()=>Ap,ZeroFactor:()=>Ud,ZeroSlopeEnding:()=>Rp,ZeroStencilOp:()=>VJe,_SRGBAFormat:()=>gM,sRGBEncoding:()=>tu});var GM="154",qM={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},LJe={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},Ile=0,LN=1,Dle=2,OJe=3,kJe=0,uB=1,k0=2,Kc=3,ai=0,zi=1,vr=2,NJe=2,jr=0,Pp=1,sc=2,ON=3,kN=4,qp=5,Co=100,Lle=101,Ole=102,NN=103,FN=104,Ud=200,kle=201,Nle=202,Fle=203,hB=204,dB=205,N0=206,Ble=207,F0=208,Hle=209,Ule=210,Vle=0,zle=1,Gle=2,mM=3,qle=4,jle=5,Wle=6,Xle=7,jx=0,Yle=1,$le=2,Qc=0,Zle=1,Kle=2,Jle=3,Qle=4,ece=5,jM=300,Pd=301,Id=302,Dp=303,yx=304,B0=306,Ei=1e3,bi=1001,bh=1002,qr=1003,Dd=1004,FJe=1004,xh=1005,BJe=1005,_r=1006,jp=1007,HJe=1007,Ta=1008,UJe=1008,ic=1009,tce=1010,nce=1011,H0=1012,fB=1013,yh=1014,ta=1015,xr=1016,pB=1017,mB=1018,eu=1020,rce=1021,Vs=1023,WM=1024,ice=1025,Cd=1026,Eh=1027,XM=1028,gB=1029,sce=1030,vB=1031,yB=1033,lM=33776,cM=33777,uM=33778,hM=33779,BN=35840,HN=35841,UN=35842,VN=35843,ace=36196,zN=37492,GN=37496,qN=37808,jN=37809,WN=37810,XN=37811,YN=37812,$N=37813,ZN=37814,KN=37815,JN=37816,QN=37817,eF=37818,tF=37819,nF=37820,rF=37821,dM=36492,oce=36283,iF=36284,sF=36285,aF=36286,lce=2200,cce=2201,uce=2202,_h=2300,ru=2301,fM=2302,Ap=2400,Rp=2401,xx=2402,YM=2500,xB=2501,bB=0,Wx=1,U0=2,EB=3e3,tu=3001,hce=3200,V0=3201,Vd=0,dce=1,nu="",en="srgb",wa="srgb-linear",_B="display-p3",VJe=0,pM=7680,zJe=7681,GJe=7682,qJe=7683,jJe=34055,WJe=34056,XJe=5386,YJe=512,$Je=513,ZJe=514,KJe=515,JJe=516,QJe=517,eQe=518,fce=519,pce=512,mce=513,gce=514,vce=515,yce=516,xce=517,bce=518,Ece=519,bx=35044,tQe=35048,nQe=35040,rQe=35045,iQe=35049,sQe=35041,aQe=35046,oQe=35050,lQe=35042,cQe="100",oF="300 es",gM=1035,Jc=2e3,Ex=2001,Do=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]+Qs[e>>16&255]+Qs[e>>24&255]+"-"+Qs[255&t]+Qs[t>>8&255]+"-"+Qs[t>>16&15|64]+Qs[t>>24&255]+"-"+Qs[63&i|128]+Qs[i>>8&255]+"-"+Qs[i>>16&255]+Qs[i>>24&255]+Qs[255&n]+Qs[n>>8&255]+Qs[n>>16&255]+Qs[n>>24&255]).toLowerCase()}function es(e,t,i){return Math.max(t,Math.min(i,e))}function TB(e,t){return(e%t+t)%t}function uQe(e,t,i,n,r){return n+(e-t)*(r-n)/(i-t)}function hQe(e,t,i){return e!==t?(i-e)/(t-e):0}function fx(e,t,i){return(1-i)*e+i*t}function dQe(e,t,i,n){return fx(e,t,1-Math.exp(-i*n))}function fQe(e,t=1){return t-Math.abs(TB(e,2*t)-t)}function pQe(e,t,i){return e<=t?0:e>=i?1:(e=(e-t)/(i-t))*e*(3-2*e)}function mQe(e,t,i){return e<=t?0:e>=i?1:(e=(e-t)/(i-t))*e*e*(e*(6*e-15)+10)}function gQe(e,t){return e+Math.floor(Math.random()*(t-e+1))}function vQe(e,t){return e+Math.random()*(t-e)}function yQe(e){return e*(.5-Math.random())}function xQe(e){void 0!==e&&(soe=e);let t=soe+=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 bQe(e){return e*Ip}function EQe(e){return e*y0}function lF(e){return 0==(e&e-1)&&0!==e}function _ce(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))}function vM(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}function _Qe(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 Po(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return e/4294967295;case Uint16Array:return e/65535;case Uint8Array:return e/255;case Int32Array:return Math.max(e/2147483647,-1);case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw new Error("Invalid component type.")}}function pr(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return Math.round(4294967295*e);case Uint16Array:return Math.round(65535*e);case Uint8Array:return Math.round(255*e);case Int32Array:return Math.round(2147483647*e);case Int16Array:return Math.round(32767*e);case Int8Array:return Math.round(127*e);default:throw new Error("Invalid component type.")}}var Cn={DEG2RAD:Ip,RAD2DEG:y0,generateUUID:Io,clamp:es,euclideanModulo:TB,mapLinear:uQe,inverseLerp:hQe,lerp:fx,damp:dQe,pingpong:fQe,smoothstep:pQe,smootherstep:mQe,randInt:gQe,randFloat:vQe,randFloatSpread:yQe,seededRandom:xQe,degToRad:bQe,radToDeg:EQe,isPowerOfTwo:lF,ceilPowerOfTwo:_ce,floorPowerOfTwo:vM,setQuaternionFromProperEuler:_Qe,normalize:pr,denormalize:Po},ye=class{constructor(e=0,t=0){ye.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(es(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}},An=class{constructor(e,t,i,n,r,a,s,o,l){An.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(tN.makeScale(e,t)),this}rotate(e){return this.premultiply(tN.makeRotation(-e)),this}translate(e,t){return this.premultiply(tN.makeTranslation(e,t)),this}makeTranslation(e,t){return 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)}},tN=new An;function Tce(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}var TQe={Int8Array:Int8Array,Uint8Array:Uint8Array,Uint8ClampedArray:Uint8ClampedArray,Int16Array:Int16Array,Uint16Array:Uint16Array,Int32Array:Int32Array,Uint32Array:Uint32Array,Float32Array:Float32Array,Float64Array:Float64Array};function f0(e,t){return new TQe[e](t)}function _x(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}var aoe={};function px(e){e in aoe||(aoe[e]=!0,console.warn(e))}function g0(e){return e<.04045?.0773993808*e:Math.pow(.9478672986*e+.0521327014,2.4)}function nN(e){return e<.0031308?12.92*e:1.055*Math.pow(e,.41666)-.055}var wQe=(new An).fromArray([.8224621,.0331941,.0170827,.177538,.9668058,.0723974,-1e-7,1e-7,.9105199]),SQe=(new An).fromArray([1.2249401,-.0420569,-.0196376,-.2249404,1.0420571,-.0786361,1e-7,0,1.0982735]);function MQe(e){return e.convertSRGBToLinear().applyMatrix3(SQe)}function AQe(e){return e.applyMatrix3(wQe).convertLinearToSRGB()}var RQe={[wa]:e=>e,[en]:e=>e.convertSRGBToLinear(),[_B]:MQe},CQe={[wa]:e=>e,[en]:e=>e.convertLinearToSRGB(),[_B]:AQe},cl={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 wa},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=RQe[t],r=CQe[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)}},jg,Tx=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===jg&&(jg=_x("canvas")),jg.width=e.width,jg.height=e.height;let i=jg.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),t=jg}return t.width>2048||t.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),t.toDataURL("image/jpeg",.6)):t.toDataURL("image/png")}static sRGBToLinear(e){if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap){let t=_x("canvas");t.width=e.width,t.height=e.height;let 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!==jM)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Ei:e.x=e.x-Math.floor(e.x);break;case bi:e.x=e.x<0?0:1;break;case bh: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 Ei:e.y=e.y-Math.floor(e.y);break;case bi:e.y=e.y<0?0:1;break;case bh: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 px("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace===en?tu:EB}set encoding(e){px("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=e===tu?en:nu}};Fr.DEFAULT_IMAGE=null,Fr.DEFAULT_MAPPING=jM,Fr.DEFAULT_ANISOTROPY=1;var lr=class{constructor(e=0,t=0,i=0,n=1){lr.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}},Jn=class extends Do{constructor(e=1,t=1,i={}){super(),this.isWebGLRenderTarget=!0,this.width=e,this.height=t,this.depth=1,this.scissor=new lr(0,0,e,t),this.scissorTest=!1,this.viewport=new lr(0,0,e,t);let n={width:e,height:t,depth:1};void 0!==i.encoding&&(px("THREE.WebGLRenderTarget: option.encoding has been replaced by option.colorSpace."),i.colorSpace=i.encoding===tu?en:nu),this.texture=new Fr(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:_r,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 rc(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"})}},x0=class extends Fr{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=qr,this.minFilter=qr,this.wrapR=bi,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},cF=class extends Jn{constructor(e=1,t=1,i=1){super(e,t),this.isWebGLArrayRenderTarget=!0,this.depth=i,this.texture=new x0(null,e,t,i),this.texture.isRenderTargetTexture=!0}},wx=class extends Fr{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=qr,this.minFilter=qr,this.wrapR=bi,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},uF=class extends Jn{constructor(e=1,t=1,i=1){super(e,t),this.isWebGL3DRenderTarget=!0,this.depth=i,this.texture=new wx(null,e,t,i),this.texture.isRenderTargetTexture=!0}},hF=class extends Jn{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(es(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}},L=class{constructor(e=0,t=0,i=0){L.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(ooe.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(ooe.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 iN.copy(this).projectOnVector(e),this.sub(iN)}reflect(e){return this.sub(iN.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(0===t)return Math.PI/2;let i=this.dot(e)/t;return Math.acos(es(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-xo(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}},iN=new L,ooe=new ir,It=class{constructor(e=new L(1/0,1/0,1/0),t=new L(-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,hh),hh.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(tx),ES.subVectors(this.max,tx),Xg.subVectors(e.a,tx),Yg.subVectors(e.b,tx),$g.subVectors(e.c,tx),wd.subVectors(Yg,Xg),Sd.subVectors($g,Yg),gp.subVectors(Xg,$g);let t=[0,-wd.z,wd.y,0,-Sd.z,Sd.y,0,-gp.z,gp.y,wd.z,0,-wd.x,Sd.z,0,-Sd.x,gp.z,0,-gp.x,-wd.y,wd.x,0,-Sd.y,Sd.x,0,-gp.y,gp.x,0];return!(!sN(t,Xg,Yg,$g,ES)||(t=[1,0,0,0,1,0,0,0,1],!sN(t,Xg,Yg,$g,ES)))&&(_S.crossVectors(wd,Sd),t=[_S.x,_S.y,_S.z],sN(t,Xg,Yg,$g,ES))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,hh).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=.5*this.getSize(hh).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()||(uh[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),uh[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),uh[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),uh[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),uh[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),uh[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),uh[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),uh[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(uh)),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)}},uh=[new L,new L,new L,new L,new L,new L,new L,new L],hh=new L,Wg=new It,Xg=new L,Yg=new L,$g=new L,wd=new L,Sd=new L,gp=new L,tx=new L,ES=new L,_S=new L,vp=new L;function sN(e,t,i,n,r){for(let a=0,s=e.length-3;a<=s;a+=3){vp.fromArray(e,a);let s=r.x*Math.abs(vp.x)+r.y*Math.abs(vp.y)+r.z*Math.abs(vp.z),o=t.dot(vp),l=i.dot(vp),h=n.dot(vp);if(Math.max(-Math.max(o,l,h),Math.min(o,l,h))>s)return!1}return!0}var DQe=new It,nx=new L,aN=new L,cr=class{constructor(e=new L,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):DQe.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;nx.subVectors(e,this.center);let t=nx.lengthSq();if(t>this.radius*this.radius){let e=Math.sqrt(t),i=.5*(e-this.radius);this.center.addScaledVector(nx,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):(aN.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(nx.copy(e.center).add(aN)),this.expandByPoint(nx.copy(e.center).sub(aN))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return(new this.constructor).copy(this)}},dh=new L,oN=new L,TS=new L,Md=new L,lN=new L,wS=new L,cN=new L,Ya=class{constructor(e=new L,t=new L(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,dh)),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=dh.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(dh.copy(this.origin).addScaledVector(this.direction,t),dh.distanceToSquared(e))}distanceSqToSegment(e,t,i,n){oN.copy(e).add(t).multiplyScalar(.5),TS.copy(t).sub(e).normalize(),Md.copy(this.origin).sub(oN);let r,a,s,o,l=.5*e.distanceTo(t),h=-this.direction.dot(TS),c=Md.dot(this.direction),u=-Md.dot(TS),d=Md.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(oN).addScaledVector(TS,a),s}intersectSphere(e,t){dh.subVectors(e.center,this.origin);let i=dh.dot(this.direction),n=dh.dot(dh)-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,dh)}intersectTriangle(e,t,i,n,r){lN.subVectors(t,e),wS.subVectors(i,e),cN.crossVectors(lN,wS);let a,s=this.direction.dot(cN);if(s>0){if(n)return null;a=1}else{if(!(s<0))return null;a=-1,s=-s}Md.subVectors(this.origin,e);let o=a*this.direction.dot(wS.crossVectors(Md,wS));if(o<0)return null;let l=a*this.direction.dot(lN.cross(Md));if(l<0||o+l>s)return null;let h=-a*Md.dot(cN);return h<0?null:this.at(h/s,r)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return(new this.constructor).copy(this)}},Qe=class{constructor(e,t,i,n,r,a,s,o,l,h,c,u,d,p,f,m){Qe.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 Qe).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/Zg.setFromMatrixColumn(e,0).length(),r=1/Zg.setFromMatrixColumn(e,1).length(),a=1/Zg.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(LQe,e,OQe)}lookAt(e,t,i){let n=this.elements;return Ao.subVectors(e,t),0===Ao.lengthSq()&&(Ao.z=1),Ao.normalize(),Ad.crossVectors(i,Ao),0===Ad.lengthSq()&&(1===Math.abs(i.z)?Ao.x+=1e-4:Ao.z+=1e-4,Ao.normalize(),Ad.crossVectors(i,Ao)),Ad.normalize(),SS.crossVectors(Ao,Ad),n[0]=Ad.x,n[4]=SS.x,n[8]=Ao.x,n[1]=Ad.y,n[5]=SS.y,n[9]=Ao.y,n[2]=Ad.z,n[6]=SS.z,n[10]=Ao.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],L=n[10],I=n[14],D=n[3],O=n[7],k=n[11],N=n[15];return r[0]=a*_+s*E+o*P+l*D,r[4]=a*w+s*T+o*R+l*O,r[8]=a*S+s*A+o*L+l*k,r[12]=a*M+s*C+o*I+l*N,r[1]=h*_+c*E+u*P+d*D,r[5]=h*w+c*T+u*R+d*O,r[9]=h*S+c*A+u*L+d*k,r[13]=h*M+c*C+u*I+d*N,r[2]=p*_+f*E+m*P+g*D,r[6]=p*w+f*T+m*R+g*O,r[10]=p*S+f*A+m*L+g*k,r[14]=p*M+f*C+m*I+g*N,r[3]=v*_+y*E+x*P+b*D,r[7]=v*w+y*T+x*R+b*O,r[11]=v*S+y*A+x*L+b*k,r[15]=v*M+y*C+x*I+b*N,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){let e=this.elements,t=e[0],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=Zg.set(n[0],n[1],n[2]).length(),a=Zg.set(n[4],n[5],n[6]).length(),s=Zg.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],Ql.copy(this);let o=1/r,l=1/a,h=1/s;return Ql.elements[0]*=o,Ql.elements[1]*=o,Ql.elements[2]*=o,Ql.elements[4]*=l,Ql.elements[5]*=l,Ql.elements[6]*=l,Ql.elements[8]*=h,Ql.elements[9]*=h,Ql.elements[10]*=h,t.setFromRotationMatrix(Ql),i.x=r,i.y=a,i.z=s,this}makePerspective(e,t,i,n,r,a,s=Jc){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===Jc)o=-(a+r)/(a-r),l=-2*a*r/(a-r);else{if(s!==Ex)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=Jc){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===Jc)o=(a+r)*d,l=-2*d;else{if(s!==Ex)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}},Zg=new L,Ql=new Qe,LQe=new L(0,0,0),OQe=new L(1,1,1),Ad=new L,SS=new L,Ao=new L,loe=new Qe,coe=new ir,zn=class{constructor(e=0,t=0,i=0,n=zn.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(es(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(-es(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(es(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(-es(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(es(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(-es(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 loe.makeRotationFromQuaternion(e),this.setFromRotationMatrix(loe,t,i)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return coe.setFromEuler(this),this.setFromQuaternion(coe,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}};zn.DEFAULT_ORDER="XYZ";var Ld=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(rx,e,NQe),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(rx,FQe,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,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){ec.subVectors(n,t),ph.subVectors(i,t),uN.subVectors(e,t);let a=ec.dot(ec),s=ec.dot(ph),o=ec.dot(uN),l=ph.dot(ph),h=ph.dot(uN),c=a*l-s*s;if(0===c)return r.set(-2,-1,-1);let u=1/c,d=(l*o-s*h)*u,p=(a*h-s*o)*u;return r.set(1-d-p,p,d)}static containsPoint(e,t,i,n){return this.getBarycoord(e,t,i,n,mh),mh.x>=0&&mh.y>=0&&mh.x+mh.y<=1}static getUV(e,t,i,n,r,a,s,o){return!1===AS&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),AS=!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,mh),o.setScalar(0),o.addScaledVector(r,mh.x),o.addScaledVector(a,mh.y),o.addScaledVector(s,mh.z),o}static isFrontFacing(e,t,i,n){return ec.subVectors(i,t),ph.subVectors(e,t),ec.cross(ph).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 ec.subVectors(this.c,this.b),ph.subVectors(this.a,this.b),.5*ec.cross(ph).length()}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return ei.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return ei.getBarycoord(e,this.a,this.b,this.c,t)}getUV(e,t,i,n,r){return!1===AS&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),AS=!0),ei.getInterpolation(e,this.a,this.b,this.c,t,i,n,r)}getInterpolation(e,t,i,n,r){return ei.getInterpolation(e,this.a,this.b,this.c,t,i,n,r)}containsPoint(e){return ei.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return ei.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;Jg.subVectors(a,r),Qg.subVectors(s,r),hN.subVectors(e,r);let o=Jg.dot(hN),l=Qg.dot(hN);if(o<=0&&l<=0)return t.copy(r);dN.subVectors(e,a);let h=Jg.dot(dN),c=Qg.dot(dN);if(h>=0&&c<=h)return t.copy(a);let u=o*c-h*l;if(u<=0&&o>=0&&h<=0)return i=o/(o-h),t.copy(r).addScaledVector(Jg,i);fN.subVectors(e,s);let d=Jg.dot(fN),p=Qg.dot(fN);if(p>=0&&d<=p)return t.copy(s);let f=d*l-o*p;if(f<=0&&l>=0&&p<=0)return n=l/(l-p),t.copy(r).addScaledVector(Qg,n);let m=h*p-d*c;if(m<=0&&c-h>=0&&d-p>=0)return moe.subVectors(s,a),n=(c-h)/(c-h+(d-p)),t.copy(a).addScaledVector(moe,n);let g=1/(m+f+u);return i=f*g,n=u*g,t.copy(r).addScaledVector(Jg,i).addScaledVector(Qg,n)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},HQe=0,ur=class extends Do{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:HQe++}),this.uuid=Io(),this.name="",this.type="Material",this.blending=Pp,this.side=ai,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=hB,this.blendDst=dB,this.blendEquation=Co,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=mM,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=fce,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=pM,this.stencilZFail=pM,this.stencilZPass=pM,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!==Pp&&(i.blending=this.blending),this.side!==ai&&(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++}},wce={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},tc={h:0,s:0,l:0},RS={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,cl.toWorkingColorSpace(this,t),this}setRGB(e,t,i,n=cl.workingColorSpace){return this.r=e,this.g=t,this.b=i,cl.toWorkingColorSpace(this,n),this}setHSL(e,t,i,n=cl.workingColorSpace){if(e=TB(e,1),t=es(t,0,1),i=es(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 cl.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=wce[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=g0(e.r),this.g=g0(e.g),this.b=g0(e.b),this}copyLinearToSRGB(e){return this.r=nN(e.r),this.g=nN(e.g),this.b=nN(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=en){return cl.fromWorkingColorSpace(ea.copy(this),e),65536*Math.round(es(255*ea.r,0,255))+256*Math.round(es(255*ea.g,0,255))+Math.round(es(255*ea.b,0,255))}getHexString(e=en){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=cl.workingColorSpace){cl.fromWorkingColorSpace(ea.copy(this),t);let i,n,r=ea.r,a=ea.g,s=ea.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 Xa(e){Math.abs(e)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),e=es(e,-65504,65504),vh.floatView[0]=e;let t=vh.uint32View[0],i=t>>23&511;return vh.baseTable[i]+((8388607&t)>>vh.shiftTable[i])}function hx(e){let t=e>>10;return vh.uint32View[0]=vh.mantissaTable[vh.offsetTable[t]+(1023&e)]+vh.exponentTable[t],vh.floatView[0]}var z0={toHalfFloat:Xa,fromHalfFloat:hx},fs=new L,CS=new ye,pn=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=bx,this.updateRange={offset:0,count:-1},this.gpuType=ta,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;exo(e.far-e.near,2)))&&(goe.copy(r).invert(),yp.copy(e.ray).applyMatrix4(goe),(null===i.boundingBox||!1!==yp.intersectsBox(i.boundingBox))&&this._computeIntersections(e,t,yp)))}_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:NS.clone(),object:e}}function FS(e,t,i,n,r,a,s,o,l,h){e.getVertexPosition(o,t0),e.getVertexPosition(l,n0),e.getVertexPosition(h,r0);let c=zQe(e,t,i,n,t0,n0,r0,kS);if(c){r&&(DS.fromBufferAttribute(r,o),LS.fromBufferAttribute(r,l),OS.fromBufferAttribute(r,h),c.uv=ei.getInterpolation(kS,t0,n0,r0,DS,LS,OS,new ye)),a&&(DS.fromBufferAttribute(a,o),LS.fromBufferAttribute(a,l),OS.fromBufferAttribute(a,h),c.uv1=ei.getInterpolation(kS,t0,n0,r0,DS,LS,OS,new ye),c.uv2=c.uv1),s&&(yoe.fromBufferAttribute(s,o),xoe.fromBufferAttribute(s,l),boe.fromBufferAttribute(s,h),c.normal=ei.getInterpolation(kS,t0,n0,r0,yoe,xoe,boe,new L),c.normal.dot(n.direction)>0&&c.normal.multiplyScalar(-1));let e={a:o,b:l,c:h,normal:new L,materialIndex:0};ei.getNormal(t0,n0,r0,e.normal),c.face=e}return c}var na=class extends Lt{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 L;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}},Th=class extends sn{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Qe,this.projectionMatrix=new Qe,this.projectionMatrixInverse=new Qe,this.coordinateSystem=Jc}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)}},nr=class extends Th{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*y0*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(.5*Ip*this.fov);return.5*this.getFilmHeight()/e}getEffectiveFOV(){return 2*y0*Math.atan(Math.tan(.5*Ip*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*Ip*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}},i0=-90,s0=1,yM=class extends sn{constructor(e,t,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null;let n=new nr(i0,s0,e,t);n.layers=this.layers,this.add(n);let r=new nr(i0,s0,e,t);r.layers=this.layers,this.add(r);let a=new nr(i0,s0,e,t);a.layers=this.layers,this.add(a);let s=new nr(i0,s0,e,t);s.layers=this.layers,this.add(s);let o=new nr(i0,s0,e,t);o.layers=this.layers,this.add(o);let l=new nr(i0,s0,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===Jc)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!==Ex)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.toneMapping,u=e.xr.enabled;e.toneMapping=Qc,e.xr.enabled=!1;let d=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=d,e.setRenderTarget(i,5),e.render(t,l),e.setRenderTarget(h),e.toneMapping=c,e.xr.enabled=u,i.texture.needsPMREMUpdate=!0}},Op=class extends Fr{constructor(e,t,i,n,r,a,s,o,l,h){super(e=void 0!==e?e:[],t=void 0!==t?t:Pd,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}},xM=class extends Jn{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&&(px("THREE.WebGLCubeRenderTarget: option.encoding has been replaced by option.colorSpace."),t.colorSpace=t.encoding===tu?en:nu),this.texture=new Op(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:_r}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 na(5,5,5),s=new an({name:"CubemapFromEquirect",uniforms:b0(i),vertexShader:n,fragmentShader:r,side:zi,blending:jr});s.uniforms.tEquirect.value=t;let o=new _t(a,s),l=t.minFilter;return t.minFilter===Ta&&(t.minFilter=_r),new yM(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)}},vN=new L,WQe=new L,XQe=new An,Nr=class{constructor(e=new L(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=vN.subVectors(i,t).cross(WQe.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(vN),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||XQe.getNormalMatrix(e),n=this.coplanarPoint(vN).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)}},xp=new cr,BS=new L,ra=class{constructor(e=new Nr,t=new Nr,i=new Nr,n=new Nr,r=new Nr,a=new Nr){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=Jc){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===Jc)i[5].setComponents(o+s,u+c,m+f,x+y).normalize();else{if(t!==Ex)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(),xp.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{let t=e.geometry;null===t.boundingSphere&&t.computeBoundingSphere(),xp.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(xp)}intersectsSprite(e){return xp.center.set(0,0,0),xp.radius=.7071067811865476,xp.applyMatrix4(e.matrixWorld),this.intersectsSphere(xp)}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,BS.y=n.normal.y>0?e.max.y:e.min.y,BS.z=n.normal.z>0?e.max.z:e.min.z,n.distanceToPoint(BS)<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 Mce(){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 YQe(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===B0)?(void 0===l&&(l=new _t(new na(1,1,1),new an({name:"BackgroundCubeMaterial",uniforms:b0(nc.backgroundCube.uniforms),vertexShader:nc.backgroundCube.vertexShader,fragmentShader:nc.backgroundCube.fragmentShader,side:zi,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 _t(new ti(2,2),new an({name:"BackgroundMaterial",uniforms:b0(nc.background.uniforms),vertexShader:nc.background.vertexShader,fragmentShader:nc.background.fragmentShader,side:ai,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 Cnt(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===fB);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 Dnt(e){let t=this,i=null,n=0,r=!1,a=!1,s=new Nr,o=new An,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 Lnt(e){let t=new WeakMap;function i(e,t){return t===Dp?e.mapping=Pd:t===yx&&(e.mapping=Id),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===Dp||a===yx){if(t.has(r))return i(t.get(r).texture,r.mapping);{let a=r.image;if(a&&a.height>0){let s=new xM(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 Ir=class extends Th{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}},p0=4,Eoe=[.125,.215,.35,.446,.526,.582],Mp=20,yN=new Ir,_oe=new ct,xN=null,Sp=(1+Math.sqrt(5))/2,a0=1/Sp,Toe=[new L(1,1,1),new L(-1,1,1),new L(1,1,-1),new L(-1,1,-1),new L(0,Sp,a0),new L(0,Sp,-a0),new L(a0,0,Sp),new L(-a0,0,Sp),new L(Sp,a0,0),new L(-Sp,a0,0)],wh=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){xN=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=Moe(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=Soe(),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===Pd||e.mapping===Id;n?(null===this._cubemapMaterial&&(this._cubemapMaterial=Moe()),this._cubemapMaterial.uniforms.flipEnvMap.value=!1===e.isRenderTargetTexture?-1:1):null===this._equirectMaterial&&(this._equirectMaterial=Soe());let r=n?this._cubemapMaterial:this._equirectMaterial,a=new _t(this._lodPlanes[0],r);r.uniforms.envMap.value=e;let s=this._cubeSize;US(t,0,0,3*s,2*s),i.setRenderTarget(t),i.render(a,yN)}_applyPMREM(e){let t=this._renderer,i=t.autoClear;t.autoClear=!1;for(let n=1;nMp&&console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${f} samples when the maximum is set to ${Mp}`);let m=[],g=0;for(let x=0;xv-p0?n-v+p0:0),4*(this._cubeSize-y),3*y,2*y),o.setRenderTarget(t),o.render(h,yN)}};function Ont(e){let t=[],i=[],n=[],r=e,a=e-p0+1+Eoe.length;for(let s=0;se-p0?o=Eoe[s-e+p0-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 Lt;b.setAttribute("position",new pn(v,f)),b.setAttribute("uv",new pn(y,m)),b.setAttribute("faceIndex",new pn(x,g)),t.push(b),r>p0&&r--}return{lodPlanes:t,sizeLods:i,sigmas:n}}function woe(e,t,i){let n=new Jn(e,t,i);return n.texture.mapping=B0,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function US(e,t,i,n,r){e.viewport.set(t,i,n,r),e.scissor.set(t,i,n,r)}function knt(e,t,i){let n=new Float32Array(Mp),r=new L(0,1,0);return new an({name:"SphericalGaussianBlur",defines:{n:Mp,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:wB(),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:jr,depthTest:!1,depthWrite:!1})}function Soe(){return new an({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:wB(),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:jr,depthTest:!1,depthWrite:!1})}function Moe(){return new an({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:wB(),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:jr,depthTest:!1,depthWrite:!1})}function wB(){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 Nnt(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===Dp||a===yx,o=a===Pd||a===Id;if(s||o){if(r.isRenderTargetTexture&&!0===r.needsPMREMUpdate){r.needsPMREMUpdate=!1;let n=t.get(r);return null===i&&(i=new wh(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 wh(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 Fnt(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 Bnt(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 x0(g,f,m,r);v.type=ta,v.needsUpdate=!0;let y=4*p;for(let t=0;t0)return e;let r=t*i,a=Aoe[r];if(void 0===a&&(a=new Float32Array(r),Aoe[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 Ts(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 Ort(e){switch(e){case wa:return["Linear","( value )"];case en:return["sRGB","( value )"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",e),["Linear","( value )"]}}function Ooe(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"+Lrt(e.getShaderSource(t),n)}return r}function krt(e,t){let i=Ort(t);return"vec4 "+e+"( vec4 value ) { return LinearTo"+i[0]+i[1]+"; }"}function Nrt(e,t){let i;switch(t){case Zle:i="Linear";break;case Kle:i="Reinhard";break;case Jle:i="OptimizedCineon";break;case Qle:i="ACESFilmic";break;case ece:i="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",t),i="Linear"}return"vec3 "+e+"( vec3 color ) { return "+i+"ToneMapping( color ); }"}function Frt(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(dx).join("\n")}function Brt(e){let t=[];for(let i in e){let n=e[i];!1!==n&&t.push("#define "+i+" "+n)}return t.join("\n")}function Hrt(e,t){let i={},n=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let r=0;r/gm;function _F(e){return e.replace(Urt,zrt)}var Vrt=new Map([["encodings_fragment","colorspace_fragment"],["encodings_pars_fragment","colorspace_pars_fragment"],["output_fragment","opaque_fragment"]]);function zrt(e,t){let i=or[t];if(void 0===i){let e=Vrt.get(t);if(void 0===e)throw new Error("Can not resolve #include <"+t+">");i=or[e],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,e)}return _F(i)}var Grt=/#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 Foe(e){return e.replace(Grt,qrt)}function qrt(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(dx).join("\n"),a.length>0&&(a+="\n")):(r=[Boe(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(dx).join("\n"),a=[m,Boe(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!==Qc?"#define TONE_MAPPING":"",i.toneMapping!==Qc?or.tonemapping_pars_fragment:"",i.toneMapping!==Qc?Nrt("toneMapping",i.toneMapping):"",i.dithering?"#define DITHERING":"",i.opaque?"#define OPAQUE":"",or.colorspace_pars_fragment,krt("linearToOutputTexel",i.outputColorSpace),i.useDepthPacking?"#define DEPTH_PACKING "+i.depthPacking:"","\n"].filter(dx).join("\n")),l=_F(l),l=koe(l,i),l=Noe(l,i),h=_F(h),h=koe(h,i),h=Noe(h,i),l=Foe(l),h=Foe(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===oF?"":"layout(location = 0) out highp vec4 pc_fragColor;",i.glslVersion===oF?"":"#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=Loe(s,s.VERTEX_SHADER,_),M=Loe(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=Ooe(s,S,"vertex"),i=Ooe(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 v0(s,v)),x},this.getAttributes=function(){return void 0===b&&(b=Hrt(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=Drt++,this.cacheKey=t,this.usedTimes=1,this.program=v,this.vertexShader=S,this.fragmentShader=M,this}var Krt=0,TF=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 wF(e),t.set(e,i)),i}},wF=class{constructor(e){this.id=Krt++,this.code=e,this.usedTimes=0}};function Jrt(e,t,i,n,r,a,s){let o=new Ld,l=new TF,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===B0?_.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=nc[S];M=e.vertexShader,E=e.fragmentShader}else M=a.vertexShader,E=a.fragmentShader,l.update(a),T=l.getVertexShaderID(a),A=l.getFragmentShaderID(a);let L=e.getRenderTarget(),I=!0===v.isInstancedMesh,D=!!a.map,O=!!a.matcap,k=!!_,N=!!a.aoMap,F=!!a.lightMap,U=!!a.bumpMap,B=!!a.normalMap,z=!!a.displacementMap,H=!!a.emissiveMap,V=!!a.metalnessMap,j=!!a.roughnessMap,W=a.anisotropy>0,G=a.clearcoat>0,X=a.iridescence>0,Y=a.sheen>0,q=a.transmission>0,K=W&&!!a.anisotropyMap,J=G&&!!a.clearcoatMap,Z=G&&!!a.clearcoatNormalMap,$=G&&!!a.clearcoatRoughnessMap,Q=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;return{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:I,instancingColor:I&&null!==v.instanceColor,supportsVertexTextures:d,outputColorSpace:null===L?e.outputColorSpace:!0===L.isXRRenderTarget?L.texture.colorSpace:wa,map:D,matcap:O,envMap:k,envMapMode:k&&_.mapping,envMapCubeUVHeight:w,aoMap:N,lightMap:F,bumpMap:U,normalMap:B,displacementMap:d&&z,emissiveMap:H,normalMapObjectSpace:B&&a.normalMapType===dce,normalMapTangentSpace:B&&a.normalMapType===Vd,metalnessMap:V,roughnessMap:j,anisotropy:W,anisotropyMap:K,clearcoat:G,clearcoatMap:J,clearcoatNormalMap:Z,clearcoatRoughnessMap:$,iridescence:X,iridescenceMap:Q,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===Pp,alphaMap:he,alphaTest:ce,alphaHash:ue,combine:a.combine,mapUv:D&&m(a.map.channel),aoMapUv:N&&m(a.aoMap.channel),lightMapUv:F&&m(a.lightMap.channel),bumpMapUv:U&&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:K&&m(a.anisotropyMap.channel),clearcoatMapUv:J&&m(a.clearcoatMap.channel),clearcoatNormalMapUv:Z&&m(a.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:$&&m(a.clearcoatRoughnessMap.channel),iridescenceMapUv:Q&&m(a.iridescenceMap.channel),iridescenceThicknessMapUv:ee&&m(a.iridescenceThicknessMap.channel),sheenColorMapUv:te&&m(a.sheenColorMap.channel),sheenRoughnessMapUv: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||W),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&&(D||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:a.toneMapped?e.toneMapping:Qc,useLegacyLights:e.useLegacyLights,premultipliedAlpha:a.premultipliedAlpha,doubleSided:a.side===vr,flipSided:a.side===zi,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=nc[i];t=gi.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||eit),n.length>1&&n.sort(t||Hoe),r.length>1&&r.sort(t||Hoe)}}}function tit(){let e=new WeakMap;return{get:function(t,i){let n,r=e.get(t);return void 0===r?(n=new Uoe,e.set(t,[n])):i>=r.length?(n=new Uoe,r.push(n)):n=r[i],n},dispose:function(){e=new WeakMap}}}function nit(){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 L,color:new ct};break;case"SpotLight":i={position:new L,direction:new L,color:new ct,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":i={position:new L,color:new ct,distance:0,decay:0};break;case"HemisphereLight":i={direction:new L,skyColor:new ct,groundColor:new ct};break;case"RectAreaLight":i={color:new ct,position:new L,halfWidth:new L,halfHeight:new L}}return e[t.id]=i,i}}}function rit(){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 ye};break;case"PointLight":i={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ye,shadowCameraNear:1,shadowCameraFar:1e3}}return e[t.id]=i,i}}}var iit=0;function sit(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+(t.map?1:0)-(e.map?1:0)}function ait(e,t){let i=new nit,n=rit(),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 L);let a=new L,s=new Qe,o=new Qe;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(sit);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=Kt.LTC_FLOAT_1,r.rectAreaLTC2=Kt.LTC_FLOAT_2):!0===e.has("OES_texture_half_float_linear")?(r.rectAreaLTC1=Kt.LTC_HALF_1,r.rectAreaLTC2=Kt.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=iit++)},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 Voe(e,t),s.push(a)):a=s[r],a},dispose:function(){i=new WeakMap}}}var ac=class extends ur{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=hce,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}},Mx=class extends ur{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}},lit="void main() {\n\tgl_Position = vec4( position, 1.0 );\n}",cit="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 uit(e,t,i){let n=new ra,r=new ye,a=new ye,s=new lr,o=new ac({depthPacking:V0}),l=new Mx,h={},c=i.maxTextureSize,u={[ai]:zi,[zi]:ai,[vr]:vr},d=new an({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new ye},radius:{value:4}},vertexShader:lit,fragmentShader:cit}),p=d.clone();p.defines.HORIZONTAL_PASS=1;let f=new Lt;f.setAttribute("position",new pn(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let m=new _t(f,d),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=uB;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 Jn(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===Kc?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===Kc)&&(!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!==Kc?{minFilter:qr,magFilter:qr}:{};null!==h.map&&h.map.dispose(),h.map=new Jn(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!==L.indexOf("OpenGL ES")&&(R=parseFloat(/^OpenGL ES (\d)/.exec(L)[1]),P=R>=2);let I=null,D={},O=e.getParameter(e.SCISSOR_BOX),k=e.getParameter(e.VIEWPORT),N=(new lr).fromArray(O),F=(new lr).fromArray(k);function U(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?vM: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 lF(e.width)&&lF(e.height)}function _(e,t){return e.generateMipmaps&&t&&e.minFilter!==qr&&e.minFilter!==_r}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.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!==qr&&e.minFilter!==_r?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===qr||t===Dd||t===xh?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++)e.deleteFramebuffer(r.__webglFramebuffer[n]),r.__webglDepthbuffer&&e.deleteRenderbuffer(r.__webglDepthbuffer[n]);else{if(e.deleteFramebuffer(r.__webglFramebuffer),r.__webglDepthbuffer&&e.deleteRenderbuffer(r.__webglDepthbuffer),r.__webglMultisampledFramebuffer&&e.deleteFramebuffer(r.__webglMultisampledFramebuffer),r.__webglColorRenderbuffer)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 L={[Ei]:e.REPEAT,[bi]:e.CLAMP_TO_EDGE,[bh]:e.MIRRORED_REPEAT},I={[qr]:e.NEAREST,[Dd]:e.NEAREST_MIPMAP_NEAREST,[xh]:e.NEAREST_MIPMAP_LINEAR,[_r]:e.LINEAR,[jp]:e.LINEAR_MIPMAP_NEAREST,[Ta]:e.LINEAR_MIPMAP_LINEAR},D={[pce]:e.NEVER,[Ece]:e.ALWAYS,[mce]:e.LESS,[vce]:e.LEQUAL,[gce]:e.EQUAL,[bce]:e.GEQUAL,[yce]:e.GREATER,[xce]:e.NOTEQUAL};function O(i,a,s){if(s?(e.texParameteri(i,e.TEXTURE_WRAP_S,L[a.wrapS]),e.texParameteri(i,e.TEXTURE_WRAP_T,L[a.wrapT]),(i===e.TEXTURE_3D||i===e.TEXTURE_2D_ARRAY)&&e.texParameteri(i,e.TEXTURE_WRAP_R,L[a.wrapR]),e.texParameteri(i,e.TEXTURE_MAG_FILTER,I[a.magFilter]),e.texParameteri(i,e.TEXTURE_MIN_FILTER,I[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!==bi||a.wrapT!==bi)&&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!==qr&&a.minFilter!==_r&&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,D[a.compareFunction])),!0===t.has("EXT_texture_filter_anisotropic")){let s=t.get("EXT_texture_filter_anisotropic");if(a.magFilter===qr||a.minFilter!==xh&&a.minFilter!==Ta||a.type===ta&&!1===t.has("OES_texture_float_linear")||!1===l&&a.type===xr&&!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!==bi||e.wrapT!==bi||e.minFilter!==qr&&e.minFilter!==_r)}(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===ta?e.DEPTH_COMPONENT32F:r.type===yh?e.DEPTH_COMPONENT24:r.type===eu?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT16:r.type===ta&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),r.format===Cd&&g===e.DEPTH_COMPONENT&&r.type!==H0&&r.type!==yh&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),r.type=yh,m=a.convert(r.type)),r.format===Eh&&g===e.DEPTH_COMPONENT&&(g=e.DEPTH_STENCIL,r.type!==eu&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),r.type=eu,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=e.TEXTURE_CUBE_MAP_POSITIVE_X&&l<=e.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&e.framebufferTexture2D(e.FRAMEBUFFER,o,l,n.get(s).__webglTexture,0),i.bindFramebuffer(e.FRAMEBUFFER,null)}function U(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===ta?r=e.DEPTH_COMPONENT32F:t.type===yh&&(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===gM||n!==wa&&n!==nu&&(n===en?!1===l?!0===t.has("EXT_sRGB")&&r===Vs?(e.format=gM,e.minFilter=_r,e.generateMipmaps=!1):i=Tx.sRGBToLinear(i):(r!==Vs||a!==ic)&&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&&!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&&!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(fit)))}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 Gn;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}},Od=class extends Fr{constructor(e,t,i,n,r,a,s,o,l,h){if((h=void 0!==h?h:Cd)!==Cd&&h!==Eh)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===i&&h===Cd&&(i=yh),void 0===i&&h===Eh&&(i=eu),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:qr,this.minFilter=void 0!==o?o:qr,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}},SF=class extends Do{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 nr;x.layers.enable(1),x.viewport=new lr;let b=new nr;b.layers.enable(2),b.viewport=new lr;let _=[x,b],w=new bM;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 mx,v[e]=t),t.getTargetRaySpace()},this.getControllerGrip=function(e){let t=v[e];return void 0===t&&(t=new mx,v[e]=t),t.getGripSpace()},this.getHand=function(e){let t=v[e];return void 0===t&&(t=new mx,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 dt(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 Jn(d.framebufferWidth,d.framebufferHeight,{format:Vs,type:ic,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?Eh:Cd,a=f.stencil?eu:yh);let o={colorFormat:t.RGBA8,depthFormat:s,scaleFactor:r};c=new XRWebGLBinding(n,t),u=c.createProjectionLayer(o),n.updateRenderState({layers:[u]}),g=new Jn(u.textureWidth,u.textureHeight,{format:Vs,type:ic,depthTexture:new Od(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),D.setContext(n),D.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}}))},this.getEnvironmentBlendMode=function(){if(null!==n)return n.environmentBlendMode};let C=new L,P=new L;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,Sce(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===zi&&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 mit(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=n.toneMapped?y.toneMapping:Qc,g=i.morphAttributes.position||i.morphAttributes.normal||i.morphAttributes.color,v=void 0!==g?g.length:0,x=$.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||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===K.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(J.useProgram(E.program)&&(T=!0,A=!0,C=!0),n.id!==S&&(S=n.id,A=!0),T||M!==e){if(P.setValue(xe,"projectionMatrix",e.projectionMatrix),K.logarithmicDepthBuffer&&P.setValue(xe,"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(xe,G.setFromMatrixPosition(e.matrixWorld))}(n.isMeshPhongMaterial||n.isMeshToonMaterial||n.isMeshLambertMaterial||n.isMeshBasicMaterial||n.isMeshStandardMaterial||n.isShaderMaterial)&&P.setValue(xe,"isOrthographic",!0===e.isOrthographicCamera),(n.isMeshPhongMaterial||n.isMeshToonMaterial||n.isMeshLambertMaterial||n.isMeshBasicMaterial||n.isMeshStandardMaterial||n.isShaderMaterial||n.isShadowMaterial||r.isSkinnedMesh)&&P.setValue(xe,"viewMatrix",e.matrixWorldInverse)}if(r.isSkinnedMesh){P.setOptional(xe,r,"bindMatrix"),P.setOptional(xe,r,"bindMatrixInverse");let e=r.skeleton;e&&(K.floatVertexTextures?(null===e.boneTexture&&e.computeBoneTexture(),P.setValue(xe,"boneTexture",e.boneTexture,Q),P.setValue(xe,"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 L=i.morphAttributes;if((void 0!==L.position||void 0!==L.normal||void 0!==L.color&&!0===K.isWebGL2)&&de.update(r,i,E),(A||x.receiveShadow!==r.receiveShadow)&&(x.receiveShadow=r.receiveShadow,P.setValue(xe,"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(xe,"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,D,I,V),v0.upload(xe,x.uniformsList,R,Q)),n.isShaderMaterial&&!0===n.uniformsNeedUpdate&&(v0.upload(xe,x.uniformsList,R,Q),n.uniformsNeedUpdate=!1),n.isSpriteMaterial&&P.setValue(xe,"center",r.center),P.setValue(xe,"modelViewMatrix",r.modelViewMatrix),P.setValue(xe,"normalMatrix",r.normalMatrix),P.setValue(xe,"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=K.isWebGL2;null===V&&(V=new Jn(1,1,{generateMipmaps:!0,type:q.has("EXT_color_buffer_half_float")?xr:ic,minFilter:Ta,samples:r?4:0})),y.getDrawingBufferSize(W),r?V.setSize(W.x,W.y):V.setSize(vM(W.x),vM(W.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=Qc,De(e,i,n),Q.updateMultisampleRenderTarget(V),Q.updateRenderTargetMipmap(V);let o=!1;for(let l=0,h=t.length;l0&&De(r,t,i),a.length>0&&De(a,t,i),s.length>0&&De(s,t,i),J.buffers.depth.setTest(!0),J.buffers.depth.setMask(!0),J.buffers.color.setMask(!0),J.setPolygonOffset(!1)}function De(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){$.get(e.texture).__webglTexture=t,$.get(e.depthTexture).__webglTexture=i;let n=$.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=$.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 i=$.get(e);void 0!==i.__useDefaultFramebuffer?(J.bindFramebuffer(xe.FRAMEBUFFER,null),n=!1):void 0===i.__webglFramebuffer?Q.setupRenderTarget(e):i.__hasExternalTextures&&Q.rebindTextures(e,$.get(e.texture).__webglTexture,$.get(e.depthTexture).__webglTexture);let o=e.texture;(o.isData3DTexture||o.isDataArrayTexture||o.isCompressedArrayTexture)&&(s=!0);let l=$.get(e).__webglFramebuffer;e.isWebGLCubeRenderTarget?(r=l[t],a=!0):r=K.isWebGL2&&e.samples>0&&!1===Q.useMultisampledRTT(e)?$.get(e).__webglMultisampledFramebuffer:l,E.copy(e.viewport),T.copy(e.scissor),A=e.scissorTest}else E.copy(N).multiplyScalar(D).floor(),T.copy(F).multiplyScalar(D).floor(),A=U;if(J.bindFramebuffer(xe.FRAMEBUFFER,r)&&K.drawBuffers&&n&&J.drawBuffers(e,r),J.viewport(E),J.scissor(T),J.setScissorTest(A),a){let n=$.get(e.texture);xe.framebufferTexture2D(xe.FRAMEBUFFER,xe.COLOR_ATTACHMENT0,xe.TEXTURE_CUBE_MAP_POSITIVE_X+t,n.__webglTexture,i)}else if(s){let n=$.get(e.texture),r=t||0;xe.framebufferTextureLayer(xe.FRAMEBUFFER,xe.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=$.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&void 0!==s&&(o=o[s]),o){J.bindFramebuffer(xe.FRAMEBUFFER,o);try{let s=e.texture,o=s.format,l=s.type;if(o!==Vs&&me.convert(o)!==xe.getParameter(xe.IMPLEMENTATION_COLOR_READ_FORMAT))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");let h=l===xr&&(q.has("EXT_color_buffer_half_float")||K.isWebGL2&&q.has("EXT_color_buffer_float"));if(!(l===ic||me.convert(l)===xe.getParameter(xe.IMPLEMENTATION_COLOR_READ_TYPE)||l===ta&&(K.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&&xe.readPixels(t,i,n,r,me.convert(o),me.convert(l),a)}finally{let e=null!==w?$.get(w).__webglFramebuffer:null;J.bindFramebuffer(xe.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);Q.setTexture2D(t,0),xe.copyTexSubImage2D(xe.TEXTURE_2D,i,0,0,e.x,e.y,r,a),J.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);Q.setTexture2D(i,0),xe.pixelStorei(xe.UNPACK_FLIP_Y_WEBGL,i.flipY),xe.pixelStorei(xe.UNPACK_PREMULTIPLY_ALPHA_WEBGL,i.premultiplyAlpha),xe.pixelStorei(xe.UNPACK_ALIGNMENT,i.unpackAlignment),t.isDataTexture?xe.texSubImage2D(xe.TEXTURE_2D,n,e.x,e.y,r,a,s,o,t.image.data):t.isCompressedTexture?xe.compressedTexSubImage2D(xe.TEXTURE_2D,n,e.x,e.y,t.mipmaps[0].width,t.mipmaps[0].height,s,t.mipmaps[0].data):xe.texSubImage2D(xe.TEXTURE_2D,n,e.x,e.y,s,o,t.image),0===n&&i.generateMipmaps&&xe.generateMipmap(xe.TEXTURE_2D),J.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)Q.setTexture3D(n,0),a=xe.TEXTURE_3D;else{if(!n.isDataArrayTexture)return void console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");Q.setTexture2DArray(n,0),a=xe.TEXTURE_2D_ARRAY}xe.pixelStorei(xe.UNPACK_FLIP_Y_WEBGL,n.flipY),xe.pixelStorei(xe.UNPACK_PREMULTIPLY_ALPHA_WEBGL,n.premultiplyAlpha),xe.pixelStorei(xe.UNPACK_ALIGNMENT,n.unpackAlignment);let u=xe.getParameter(xe.UNPACK_ROW_LENGTH),d=xe.getParameter(xe.UNPACK_IMAGE_HEIGHT),p=xe.getParameter(xe.UNPACK_SKIP_PIXELS),f=xe.getParameter(xe.UNPACK_SKIP_ROWS),m=xe.getParameter(xe.UNPACK_SKIP_IMAGES),g=i.isCompressedTexture?i.mipmaps[0]:i.image;xe.pixelStorei(xe.UNPACK_ROW_LENGTH,g.width),xe.pixelStorei(xe.UNPACK_IMAGE_HEIGHT,g.height),xe.pixelStorei(xe.UNPACK_SKIP_PIXELS,e.min.x),xe.pixelStorei(xe.UNPACK_SKIP_ROWS,e.min.y),xe.pixelStorei(xe.UNPACK_SKIP_IMAGES,e.min.z),i.isDataTexture||i.isData3DTexture?xe.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."),xe.compressedTexSubImage3D(a,r,t.x,t.y,t.z,s,o,l,h,g.data)):xe.texSubImage3D(a,r,t.x,t.y,t.z,s,o,l,h,c,g),xe.pixelStorei(xe.UNPACK_ROW_LENGTH,u),xe.pixelStorei(xe.UNPACK_IMAGE_HEIGHT,d),xe.pixelStorei(xe.UNPACK_SKIP_PIXELS,p),xe.pixelStorei(xe.UNPACK_SKIP_ROWS,f),xe.pixelStorei(xe.UNPACK_SKIP_IMAGES,m),0===r&&n.generateMipmaps&&xe.generateMipmap(a),J.unbindTexture()},this.initTexture=function(e){e.isCubeTexture?Q.setTextureCube(e,0):e.isData3DTexture?Q.setTexture3D(e,0):e.isDataArrayTexture||e.isCompressedArrayTexture?Q.setTexture2DArray(e,0):Q.setTexture2D(e,0),J.unbindTexture()},this.resetState=function(){b=0,_=0,w=null,J.reset(),ge.reset()},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Jc}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?tu:EB}set outputEncoding(e){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=e===tu?en:wa}},EM=class extends ms{};EM.prototype.isWebGL1Renderer=!0;var E0=class{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new ct(e),this.density=t}clone(){return new E0(this.color,this.density)}toJSON(){return{type:"FogExp2",color:this.color.getHex(),density:this.density}}},iu=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 iu(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}},mi=class extends sn{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}},Sh=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=void 0!==e?e.length/t:0,this.usage=bx,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=Io()}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:sx.clone(),uv:ei.getInterpolation(sx,VS,ox,zS,zoe,EN,Goe,new ye),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 GS(e,t,i,n,r,a){u0.subVectors(e,i).addScalar(.5).multiply(n),void 0!==r?(ax.x=a*u0.x-r*u0.y,ax.y=r*u0.x+a*u0.y):ax.copy(u0),e.copy(t),e.x+=ax.x,e.y+=ax.y,e.applyMatrix4(Dce)}var qS=new L,qoe=new L,TM=class extends sn{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){qS.setFromMatrixPosition(this.matrixWorld);let i=e.ray.origin.distanceTo(qS);this.getObjectForDistance(i).raycast(e,t)}}update(e){let t=this.levels;if(t.length>1){qS.setFromMatrixPosition(e.matrixWorld),qoe.setFromMatrixPosition(this.matrixWorld);let i,n,r=qS.distanceTo(qoe)/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 AF=class extends Fr{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:_r,this.magFilter=void 0!==r?r:_r,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)}},RF=class extends Fr{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=qr,this.minFilter=qr,this.generateMipmaps=!1,this.needsUpdate=!0}},Ah=class extends Fr{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}},CF=class extends Ah{constructor(e,t,i,n,r,a){super(e,t,i,r,a),this.isCompressedArrayTexture=!0,this.image.depth=n,this.wrapR=bi}},Rx=class extends Fr{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}},Sa=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 ye:new L);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 L,n=[],r=[],a=[],s=new L,o=new Qe;for(let d=0;d<=e;d++){let t=d/e;n[d]=this.getTangentAt(t,new L)}r[0]=new L,a[0]=new L;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(es(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(es(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}},Rh=class extends Sa{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 ye,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]:($S.subVectors(a[0],a[1]).add(a[0]),i=$S);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(ale(s,o.x,l.x,h.x,c.x),ale(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}},Fp=class extends Lt{constructor(e=[new ye(0,-.5),new ye(.5,0),new ye(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=es(n,0,2*Math.PI);let r=[],a=[],s=[],o=[],l=[],h=1/t,c=new L,u=new ye,d=new L,p=new L,f=new L,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 Ft(c,3)),this.setAttribute("normal",new Ft(u,3)),this.setAttribute("uv",new Ft(d,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new oc(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},M0=class extends oc{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 M0(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},ou=class extends Lt{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 Ft(r,3)),this.setAttribute("normal",new Ft(r.slice(),3)),this.setAttribute("uv",new Ft(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 ou(e.vertices,e.indices,e.radius,e.details)}},A0=class extends ou{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 A0(e.radius,e.detail)}},ZS=new L,KS=new L,RN=new L,JS=new ei,lu=class extends Lt{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(Ip*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 Dx(d,p,i,n,r,h,0),p}};function Lce(e,t,i,n,r){let a,s;if(r===Git(e,t,i,n)>0)for(a=t;a=t;a-=n)s=ole(a,e[a],e[a+1],s);return s&&ZM(s,s.next)&&(Ox(s),s=s.next),s}function Bp(e,t){if(!e)return e;t||(t=e);let i,n=e;do{if(i=!1,n.steiner||!ZM(n,n.next)&&0!==Vi(n.prev,n,n.next))n=n.next;else{if(Ox(n),n=t=n.prev,n===n.next)break;i=!0}}while(i||n!==t);return t}function Dx(e,t,i,n,r,a,s){if(!e)return;!s&&a&&Fit(e,n,r,a);let o,l,h=e;for(;e.prev!==e.next;)if(o=e.prev,l=e.next,a?Cit(e,n,r,a):Rit(e))t.push(o.i/i|0),t.push(e.i/i|0),t.push(l.i/i|0),Ox(e),e=l.next,h=l.next;else if((e=l)===h){s?1===s?Dx(e=Pit(Bp(e),t,i),t,i,n,r,a,2):2===s&&Iit(e,t,i,n,r,a):Dx(Bp(e),t,i,n,r,a,1);break}}function Rit(e){let t=e.prev,i=e,n=e.next;if(Vi(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&&m0(r,o,a,l,s,h,f.x,f.y)&&Vi(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function Cit(e,t,i,n){let r=e.prev,a=e,s=e.next;if(Vi(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=PF(p,f,t,i,n),y=PF(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&&m0(o,c,l,u,h,d,x.x,x.y)&&Vi(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&&m0(o,c,l,u,h,d,b.x,b.y)&&Vi(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&&m0(o,c,l,u,h,d,x.x,x.y)&&Vi(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&&m0(o,c,l,u,h,d,b.x,b.y)&&Vi(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function Pit(e,t,i){let n=e;do{let r=n.prev,a=n.next.next;!ZM(r,a)&&Oce(r,n,n.next,a)&&Lx(r,a)&&Lx(a,r)&&(t.push(r.i/i|0),t.push(n.i/i|0),t.push(a.i/i|0),Ox(n),Ox(n.next),n=e=a),n=n.next}while(n!==e);return Bp(n)}function Iit(e,t,i,n,r,a){let s=e;do{let e=s.next.next;for(;e!==s.prev;){if(s.i!==e.i&&Uit(s,e)){let o=kce(s,e);return s=Bp(s,s.next),o=Bp(o,o.next),Dx(s,t,i,n,r,a,0),void Dx(o,t,i,n,r,a,0)}e=e.next}s=s.next}while(s!==e)}function Dit(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&&m0(si.x||n.x===i.x&&Nit(i,n)))&&(i=n,u=o)),n=n.next}while(n!==l);return i}function Nit(e,t){return Vi(e.prev,e,t.prev)<0&&Vi(t.next,e,e.next)<0}function Fit(e,t,i,n){let r=e;do{0===r.z&&(r.z=PF(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,Bit(r)}function Bit(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 PF(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 Hit(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 Uit(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!Vit(e,t)&&(Lx(e,t)&&Lx(t,e)&&zit(e,t)&&(Vi(e.prev,e,t.prev)||Vi(e,t.prev,t))||ZM(e,t)&&Vi(e.prev,e,e.next)>0&&Vi(t.prev,t,t.next)>0)}function Vi(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function ZM(e,t){return e.x===t.x&&e.y===t.y}function Oce(e,t,i,n){let r=eM(Vi(e,t,i)),a=eM(Vi(e,t,n)),s=eM(Vi(i,n,e)),o=eM(Vi(i,n,t));return!!(r!==a&&s!==o||0===r&&QS(e,i,t)||0===a&&QS(e,n,t)||0===s&&QS(i,e,n)||0===o&&QS(i,t,n))}function QS(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 eM(e){return e>0?1:e<0?-1:0}function Vit(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&&Oce(i,i.next,e,t))return!0;i=i.next}while(i!==e);return!1}function Lx(e,t){return Vi(e.prev,e,e.next)<0?Vi(e,t,e.next)>=0&&Vi(e,e.prev,t)>=0:Vi(e,t,e.prev)<0||Vi(e,e.next,t)<0}function zit(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 kce(e,t){let i=new IF(e.i,e.x,e.y),n=new IF(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 ole(e,t,i,n){let r=new IF(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 Ox(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 IF(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 Git(e,t,i,n){let r=0;for(let a=t,s=i-n;a2&&e[t-1].equals(e[0])&&e.pop()}function cle(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 ye(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 ye(n/a,r/a)}let I=[];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}},zs=class extends ur{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=Vd,this.normalScale=new ye(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=jx,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}},IM=class extends ur{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=Vd,this.normalScale=new ye(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}},Bd=class extends ur{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Vd,this.normalScale=new ye(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}},cu=class extends ur{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=Vd,this.normalScale=new ye(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=jx,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}},DM=class extends ur{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=Vd,this.normalScale=new ye(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}},uu=class extends kn{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 ul(e,t,i){return AB(e)?new e.constructor(e.subarray(t,void 0!==i?i:e.length)):e.slice(t,i)}function Cp(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 AB(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Nce(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 DF(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 RB(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 Xit(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=ul(t.values,e,i)}else{let e=t.createInterpolant(),i=o,n=l-o;e.evaluate(a),u=ul(e.resultBuffer,i,n)}"quaternion"===n&&(new ir).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=ul(i,r,a),this.values=ul(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&&AB(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=ul(this.times),t=ul(this.values),i=this.getValueSize(),n=this.getInterpolation()===fM,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=ul(e,0,a),this.values=ul(t,0,a*i)):(this.times=e,this.values=t),this}clone(){let e=ul(this.times,0),t=ul(this.values,0),i=new(0,this.constructor)(this.name,e,t);return i.createInterpolant=this.createInterpolant,i}};Oo.prototype.TimeBufferType=Float32Array,Oo.prototype.ValueBufferType=Float32Array,Oo.prototype.DefaultInterpolation=ru;var Ph=class extends Oo{};Ph.prototype.ValueTypeName="bool",Ph.prototype.ValueBufferType=Array,Ph.prototype.DefaultInterpolation=_h,Ph.prototype.InterpolantFactoryMethodLinear=void 0,Ph.prototype.InterpolantFactoryMethodSmooth=void 0;var Nx=class extends Oo{};Nx.prototype.ValueTypeName="color";var ml=class extends Oo{};ml.prototype.ValueTypeName="number";var kM=class extends Ch{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)ir.slerpFlat(r,0,a,l-s,a,l,o);return r}},Aa=class extends Oo{InterpolantFactoryMethodLinear(e){return new kM(this.times,this.values,this.getValueSize(),e)}};Aa.prototype.ValueTypeName="quaternion",Aa.prototype.DefaultInterpolation=ru,Aa.prototype.InterpolantFactoryMethodSmooth=void 0;var Ih=class extends Oo{};Ih.prototype.ValueTypeName="string",Ih.prototype.ValueBufferType=Array,Ih.prototype.DefaultInterpolation=_h,Ih.prototype.InterpolantFactoryMethodLinear=void 0,Ih.prototype.InterpolantFactoryMethodSmooth=void 0;var Za=class extends Oo{};Za.prototype.ValueTypeName="vector";var Ka=class{constructor(e,t=-1,i,n=YM){this.name=e,this.tracks=i,this.duration=t,this.blendMode=n,this.uuid=Io(),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(Kit(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(Oo.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=[];RB(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!==gh[e])return void gh[e].push({onLoad:t,onProgress:i,onError:n});gh[e]=[],gh[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=gh[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=>{Up.add(e,t);let i=gh[e];delete gh[e];for(let e=0,n=i.length;e{let i=gh[e];if(void 0===i)throw this.manager.itemError(e),t;delete gh[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}},OF=class extends hr{constructor(e){super(e)}load(e,t,i,n){let r=this,a=new Hr(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 ye).fromArray(t.value);break;case"v3":n.uniforms[r].value=(new L).fromArray(t.value);break;case"v4":n.uniforms[r].value=(new lr).fromArray(t.value);break;case"m3":n.uniforms[r].value=(new An).fromArray(t.value);break;case"m4":n.uniforms[r].value=(new Qe).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 ye).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 ye).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:CM,SpriteMaterial:Ax,RawShaderMaterial:PM,ShaderMaterial:an,PointsMaterial:hi,MeshPhysicalMaterial:Lo,MeshStandardMaterial:Fd,MeshPhongMaterial:zs,MeshToonMaterial:IM,MeshNormalMaterial:Bd,MeshLambertMaterial:cu,MeshDepthMaterial:ac,MeshDistanceMaterial:Mx,MeshBasicMaterial:rn,MeshMatcapMaterial:DM,LineDashedMaterial:uu,LineBasicMaterial:kn,Material:ur}[e]}},Gs=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 hu(t);i=new Vp(n),i.setCrossOrigin(this.crossOrigin);for(let t=0,i=e.length;t0){t=new Vp(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){ir.slerpFlat(e,t,e,t,e,i,n)}_slerpAdditive(e,t,i,n,r){let a=this._workIndex*r;ir.multiplyQuaternionsFlat(e,a,e,t,e,i),ir.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}}},CB="\\[\\]\\.:\\/",tst=new RegExp("["+CB+"]","g"),PB="[^"+CB+"]",nst="[^"+CB.replace("\\.","")+"]",rst=/((?:WC+[\/:])*)/.source.replace("WC",PB),ist=/(WCOD+)?/.source.replace("WCOD",nst),sst=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",PB),ast=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",PB),ost=new RegExp("^"+rst+ist+sst+ast+"$"),lst=["material","materials","bones","map"],XF=class{constructor(e,t,i){let n=i||Wn.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()}},Wn=class{constructor(e,t,i){this.path=t,this.parsedPath=i||Wn.parseTrackName(t),this.node=Wn.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 Wn.Composite(e,t,i):new Wn(e,t,i)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(tst,"")}static parseTrackName(e){let t=ost.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!==lst.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 Wn(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()}}},zM=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:Ap,endingEnd:Ap};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=cce,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===xB)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===uce;if(0===e)return-1===r?n:a&&1==(1&r)?t-n:n;if(i===lce){-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=Rp,n.endingEnd=Rp):(n.endingStart=e?this.zeroSlopeAtStart?Rp:Ap:xx,n.endingEnd=t?this.zeroSlopeAtEnd?Rp:Ap:xx)}_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}},cst=new Float32Array(1),$F=class extends Do{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 VM(Wn.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,Tle).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)}},wle=new L,nM=new L,Ra=class{constructor(e=new L,t=new L){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){wle.subVectors(e,this.start),nM.subVectors(this.end,this.start);let i=nM.dot(nM),n=nM.dot(wle)/i;return t&&(n=es(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)}},Sle=new L,tB=class extends sn{constructor(e,t){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";let i=new Lt,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{Ple.set(e.z,0,-e.x).normalize();let t=Math.acos(e.y);this.quaternion.setFromAxisAngle(Ple,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()}},cB=class extends Br{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 Lt;i.setAttribute("position",new Ft(t,3)),i.setAttribute("color",new Ft([1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],3)),super(i,new kn({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()}},qx=class{constructor(){this.type="ShapePath",this.color=new ct,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new au,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=Ls.isClockWise,n=this.subPaths;if(0===n.length)return[];let r,a,s,o=[];if(1===n.length)return a=n[0],s=new ps,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(Vce);return!(oi.far)&&(s.push({distance:o,point:Uce.clone(),index:n,object:e}),!0)}rr.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(),pu.copy(i.boundingSphere),pu.applyMatrix4(n),pu.radius+=r,!1===e.ray.intersectsSphere(pu))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 zce=Math.pow(2,-24),Wp=class{constructor(){}};function yl(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 IB(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 DB(e,t){t.set(e)}function LB(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 Xx(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 q0(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 pst(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 pn(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 gst(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 vst(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,zd=new Array(Dh).fill().map((()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0}))),JM=new Float32Array(6);function xst(e,t,i,n,r,a){let s=-1,o=0;if(0===a)s=IB(t),-1!==s&&(o=(t[s]+t[s+3])/2);else if(1===a)s=IB(e),-1!==s&&(o=bst(i,n,r,s));else if(2===a){let a=q0(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)/Dh;if(r=a.candidate?Xx(r,i,a.rightCacheBounds):(Xx(r,i,a.leftCacheBounds),a.count++)}}for(let i=0;i=Dh&&(t=Dh-1);let a=zd[t];a.count++,Xx(r,i,a.bounds)}let t=zd[Dh-1];DB(t.bounds,t.rightCacheBounds);for(let e=Dh-2;e>=0;e--){let t=zd[e],i=zd[e+1];LB(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)*zce,pt[n+3]&&(t[n+3]=m)}}return a}function _st(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=xst(t.boundingData,p,s,r,d,u);if(-1===g.axis)return i(r+d),t.offset=r,t.count=d,t;let v=vst(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 Wp,i=r,o=v-r;t.left=e,e.boundingData=new Float32Array(6),kB(s,i,o,e.boundingData,a),n(e,i,o,a,m+1);let l=new Wp,h=v,c=d-o;t.right=l,l.boundingData=new Float32Array(6),kB(s,h,c,l.boundingData,a),n(l,h,c,a,m+1)}return t}pst(e,t);let r=new Float32Array(6),a=new Float32Array(6),s=Est(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=mst(e);if(1===g.length){let e=g[0],t=new Wp;t.boundingData=r,gst(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 Wp;e.boundingData=new Float32Array(6),kB(s,v.offset,v.count,e.boundingData,a),n(e,v.offset,v.count,a),m.push(e)}return m}function jce(e,t){let i,n,r,a=_st(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 to=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}};to.prototype.setFromBox=function(){let e=new L;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 Gwt=function(){let e=new to;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}}}(),Tst=function(){let e=new L,t=new L,i=new L;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}}(),Yx=function(){let e=new ye,t=new L,i=new L;return function(n,r,a,s){Tst(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))}}}(),Wce=function(){let e=new L,t=new L,i=new Nr,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}}(),wst=1e-15;function j0(e){return Math.abs(e)new L)),this.satBounds=new Array(4).fill().map((()=>new to)),this.points=[this.a,this.b,this.c],this.sphere=new cr,this.plane=new Nr,this.needsUpdate=!0}intersectsSphere(e){return Wce(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}};no.prototype.closestPointToSegment=function(){let e=new L,t=new L,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]),Yx(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=j0(g.distanceToPoint(n));if(j0(g.normal.dot(s))&&l){c.copy(h),i=2;break}if((g.intersectLine(h,a)||l)&&!j0(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=j0(m.distanceToPoint(e));if(j0(m.normal.dot(o))&&l){u.copy(h),a=2;break}if((m.intersectLine(h,i)||l)&&!j0(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)}}}(),no.prototype.distanceToPoint=function(){let e=new L;return function(t){return this.closestPointToPoint(t,e),t.distanceTo(e)}}(),no.prototype.distanceToTriangle=function(){let e=new L,t=new L,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 L)),this.satAxes=new Array(3).fill().map((()=>new L)),this.satBounds=new Array(3).fill().map((()=>new to)),this.alignedSatBounds=new Array(3).fill().map((()=>new to)),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}};ro.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 L,r=new L;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 xl(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 HB(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=Y0(e),s=$0(e,o)):(r=$0(e,o),s=Y0(e));let u=oA(r,a,n,iA)?aA(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=oA(s,a,n,iA)?aA(s,t,i,n):null;return u&&d?u.distance<=d.distance?u:d:u||d||null}}var eue=function(){let e,t,i=[],n=new W0((()=>new It));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=Gd,n=qd;for(;!Lh(t,i);)t=2*(e=Y0(e));return Xp(e,n)}function u(e){let t=2*e,i=Gd,n=qd;for(;!Lh(t,i);)t=2*(e=$0(e,n));return Xp(e,n)+X0(t,i)}let d=2*i,p=K0,f=Gd,m=qd;if(Lh(d,f)){let t=Xp(i,m),n=X0(d,f);return yl(i,p,e),s(t,n,!1,h,l+i,e)}{let d,g,v,y,x=Y0(i),b=$0(i,m),_=x,w=b;if(o&&(v=e,y=t,yl(_,p,v),yl(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 no)),uc=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."),uc.serialize(arguments[0],{cloneBuffers:void 0===arguments[2]||arguments[2]});t=Kn({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."),uc.deserialize(arguments[0],arguments[1],{setIndex:void 0===arguments[2]||arguments[2]});i=Kn({setIndex:!0},i);let{index:n,roots:r}=e,a=new uc(t,pi(Kn({},i),{[VB]:!0}));if(a._roots=r,i.setIndex){let i=t.getIndex();if(null===i){let i=new pn(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,[VB]:!1},t)).useSharedArrayBuffer&&"undefined"==typeof SharedArrayBuffer)throw new Error("MeshBVH: SharedArrayBuffer is not available.");this._roots=null,t[VB]||(this._roots=jce(e,t),!e.boundingBox&&t.setBoundingBox&&(e.boundingBox=this.getBoundingBox(new It))),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=ai){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=mu.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)||HB(t,i,n,l,a,s,r)}else o||(o=l?(e,t,i,a)=>HB(e,t,n,l,i,a,r):(e,t,i)=>i);let h=!1,c=0;for(let u of this._roots){if(J0(u),h=eue(0,n,s,o,a,c),$x(),h)break;c+=u.byteLength}return mu.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;Q0.copy(t).invert();let h=mu.getPrimitive(),c=mu.getPrimitive();if(r){let e=function(e,i,n,u,d,p,f,m){for(let g=n,v=n+u;gGB.intersectsBox(e),intersectsRange:(t,i,r,a,s,o)=>(zB.copy(o),zB.applyMatrix4(Q0),e.shapecast({intersectsBounds:e=>zB.intersectsBox(e),intersectsRange:(e,r,o,l,h)=>n(t,i,e,r,a,s,l,h)}))});return mu.releasePrimitive(h),mu.releasePrimitive(c),u}intersectsBox(e,t){return Yp.set(e.min,e.max,t),Yp.needsUpdate=!0,this.shapecast({intersectsBounds:e=>Yp.intersectsBox(e),intersectsTriangle:e=>Yp.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(),Yp.set(e.boundingBox.min,e.boundingBox.max,t),Yp.needsUpdate=!0;let s=this.geometry,o=s.attributes.position,l=s.index,h=e.attributes.position,c=e.index,u=mu.getPrimitive(),d=mu.getPrimitive(),p=lA,f=Cst,m=null,g=null;n&&(m=Pst,g=Ist);let v=1/0,y=null,x=null;return Q0.copy(t).invert(),Zx.matrix.copy(Q0),this.shapecast({boundsTraverseOrder:e=>Yp.distanceToBox(e),intersectsBounds:(e,t,i)=>i{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:e=>Zx.distanceToBox(e),intersectsBounds:(e,t,i)=>i{for(let s=3*e,b=3*(e+a);s(Kx.copy(e).clamp(t.min,t.max),Kx.distanceToSquared(e)),intersectsBounds:(e,t,i)=>i{t.closestPointToPoint(e,Kx);let n=e.distanceToSquared(Kx);return n{yl(0,new Float32Array(t),nue),e.union(nue)})),e}},qB=new Ya,rue=new Qe,Dst=_t.prototype.raycast;function jB(e,t){if(this.geometry.boundsTree){if(void 0===this.material)return;rue.copy(this.matrixWorld).invert(),qB.copy(e.ray).applyMatrix4(rue);let i=this.geometry.boundsTree;if(!0===e.firstHitOnly){let n=BB(i.raycastFirst(qB,this.material),this,e);n&&t.push(n)}else{let n=i.raycast(qB,this.material);for(let i=0,r=n.length;ii.far?null:{distance:h,point:mA.clone(),object:e}}function gA(e,t,i,n,r,a,s,o,l,h,c,u){jd.fromBufferAttribute(r,h),Wd.fromBufferAttribute(r,c),Xd.fromBufferAttribute(r,u);let d=e.morphTargetInfluences;if(a&&d){cA.set(0,0,0),uA.set(0,0,0),hA.set(0,0,0);for(let e=0,t=a.length;e=1)return}}else for(let m=Math.max(0,p.start),g=Math.min(s.count,p.start+p.count);m=1)return}else if(void 0!==o)if(Array.isArray(n))for(let m=0,g=d.length;m=1)return}else for(let m=Math.max(0,p.start),g=Math.min(o.count,p.start+p.count);m=1)return},_t.prototype.raycast=jB;var vA=new cr,yA=new L;function sue(e,t,i,n,r,a){let s=n.ray.distanceSqToPoint(e);if(sn.far)return;r.push({distance:o,distanceToRay:Math.sqrt(s),point:i,index:t,face:null,object:a})}}$r.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(),vA.copy(i.boundingSphere),vA.applyMatrix4(n),vA.radius+=r,!1===e.ray.intersectsSphere(vA))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 KB=class{constructor(){this.id=0,this.object=null,this.z=0,this.renderOrder=0}},Jx=class{constructor(){this.id=0,this.v1=new Yd,this.v2=new Yd,this.v3=new Yd,this.normalModel=new L,this.vertexNormalsModel=[new L,new L,new L],this.vertexNormalsLength=0,this.color=new ct,this.material=null,this.uvs=[new ye,new ye,new ye],this.z=0,this.renderOrder=0}},Yd=class{constructor(){this.position=new L,this.positionWorld=new L,this.positionScreen=new lr,this.visible=!0}copy(e){this.positionWorld.copy(e.positionWorld),this.positionScreen.copy(e.positionScreen)}},Qx=class{constructor(){this.id=0,this.v1=new Yd,this.v2=new Yd,this.vertexColors=[new ct,new ct],this.material=null,this.z=0,this.renderOrder=0}},eb=class{constructor(){this.id=0,this.object=null,this.x=0,this.y=0,this.z=0,this.rotation=0,this.scale=new ye,this.material=null,this.renderOrder=0}},xA=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 L,y=new lr,x=new It(new L(-1,-1,-1),new L(1,1,1)),b=new It,_=new Array(3),w=new Qe,S=new Qe,M=new Qe,E=new ra,T=[],A=[],C=[],P=[],R=[],I=new function(){let e=[],t=[],l=[],h=null,u=new An;function m(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 w(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 E(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){h=i,u.getNormalMatrix(h.matrixWorld),e.length=0,t.length=0,l.length=0},projectVertex:m,checkTriangleVisibility:w,checkBackfaceCulling:E,pushVertex:function(e,t,r){i=function(){if(n===d){let e=new Yd;return A.push(e),d++,n++,e}return A[n++]}(),i.position.set(e,t,r),m(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){l.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 eb;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(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,D(e),!0===r&&g.objects.sort(N);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 F(e){return null!==g?e.toFixed(g):e}function U(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"+F(e.x-.5*n)+","+F(e.y-.5*r)+"h"+F(n)+"v"+F(r)+"h"+F(-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"+F(e.positionScreen.x)+","+F(e.positionScreen.y)+"L"+F(t.positionScreen.x)+","+F(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"+F(e.positionScreen.x)+","+F(e.positionScreen.y)+"L"+F(t.positionScreen.x)+","+F(t.positionScreen.y)+"L"+F(n.positionScreen.x)+","+F(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(I),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 Ost(e){let t={};return t.r=(e>>16&255)/255,t.g=(e>>8&255)/255,t.b=(255&e)/255,t}var bA=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"})}},kst=$i(cue(),1),ae=kst;ae.setLevel("warn");var uue=e=>{try{ae.setLevel(e)}catch(e){ae.setLevel("error"),ae.error(e)}},JB=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=JB.isTouchScreenDevice();t&&ae.debug("[DI] is android"),i&&ae.debug("[DI] is fireFox"),n&&ae.debug("[DI] is chrome"),r&&ae.debug("[DI] is tablet"),a&&ae.debug("[DI] is iPhone"),s&&ae.debug("[DI] is PC"),o&&ae.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:()=>{}}}},Tn=JB;Tn.isMobile=/mobile/i.test(navigator.userAgent),Tn.isBrowser="undefined"!=typeof document,Tn.isNode="undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process);var _A=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 L?`(${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 ye?e:Array.isArray(e)&&e.length>=2?new ye(e[0],e[1]):void 0:e}static arrayToVector3(e){return e?e instanceof L?e:Array.isArray(e)&&e.length>=2?new L(e[0],e[1],e.length>2?e[2]:0):void 0:e}static arrayToEuler(e){return e?e instanceof zn?e:Array.isArray(e)&&e.length>=3?new zn(e[0],e[1],e[2]):void 0:e}static arrayOrObjectToVector3(e){if(!e)return e;if(e instanceof L)return e;if(e instanceof ye)return new L(e.x,e.y,0);if(Array.isArray(e)&&e.length>=2)return new L(e[0],e[1],e[2]||0);let t=e;return null!=t.x&&null!=t.y?new L(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 L&&(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 L;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 L(i.x-n/2,i.y-r/2,i.z-a/2),o=new L(i.x+n/2,i.y+r/2,i.z+a/2);e.set(s,o)}static expandBoxByMinSize(e,t){let i=new L;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(Tn.isBrowser){let t=performance.memory;if(!t)return void ae.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);ae.info(`[CommonUtils] ${e}. jsHeapSizeLimit: ${i}M , totalJSHeapSize: ${n}M , usedJSHeapSize: ${r}M `)}}static printGpuInfo(e){if(Tn.isBrowser){let t=e.getExtension("webgl_debug_renderer_info"),i=e.getParameter(t.UNMASKED_RENDERER_WEBGL);ae.info("[CommonUtils] gpu:",i)}}static sleep(e){return dt(this,null,(function*(){let t;return new Promise((i=>{t=setTimeout((()=>{i("")}),e)})).then((()=>{clearTimeout(t)}))}))}static twinkle(e,t=500){return dt(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=>dt(this,null,(function*(){if(e){e(new ProgressEvent("",{loaded:i,total:100}));let n=500,r=Date.now();r-t>n&&(yield _A.sleep(0),t=r)}}))}static getUpdateProgressFuncForLoop(e,t){let i=Math.round(Math.pow(e,.5)),n=Date.now();return r=>dt(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 _A.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||(ae.warn("[Progress] Invalid ProgressEvent:",r),n=!0),a=t),i&&i(new ProgressEvent(r.type,{loaded:a,total:100}))}}},wt=_A;wt.twinklingObjectIds={};var TA=(e,t,i)=>{let{default:n,active:r}=t;i?(e.remove(n),e.add(r||n)):(r&&e.remove(r),e.add(n))},wn=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}},on=class{static getScreenPointByEvent(e,t){let i=new ye,{left:n,top:r}=t.getBoundingClientRect();return i.x=e.clientX-n,i.y=e.clientY-r,i}static getScreenPointByTouchEvent(e,t){let i=new ye,{left:n,top:r}=t.getBoundingClientRect();return i.x=e.touches[0].clientX-n,i.y=e.touches[0].clientY-r,i}static worldPosition2ScreenPoint(e,t,i){let{clientWidth:n,clientHeight:r}=i,a=e.clone(),s=new ye;return a.project(t),s.x=Math.round((.5+a.x/2)*n),s.y=Math.round((.5-a.y/2)*r),s}static screenPoint2worldPosition(e,t,i){let n=on.screenPoint2NdcPoint(e,t,i);return new L(n.x,n.y,1).unproject(t)}static screenPoint2NdcPoint(e,t,i){let{clientWidth:n,clientHeight:r}=i,a=new ye;return a.x=e.x/n*2-1,a.y=-e.y/r*2+1,a}static worldCoordinate2NormalizedScreenCoordinate(e,t,i){let n=new L;e instanceof ye?n.set(e.x,e.y,0):n.set(e.x,e.y,e.z);let r=on.worldPosition2ScreenPoint(n,t,i);return r.x/=i.clientWidth,r.y/=i.clientHeight,r}},nv=class extends sn{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 ye(.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}},tv=new L,hue=new Qe,due=new Qe,fue=new L,pue=new L,gu=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){tv.setFromMatrixPosition(e.matrixWorld),tv.applyMatrix4(due);let l=!0===e.visible&&tv.z>=-1&&tv.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("+(tv.x*n+n)+"px,"+(-tv.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===mue["Precision from file"]?2:t),ts=class{constructor(){this.map=new Map}addEventListener(e,t){let i=this.map.get(e);i||(i=new Set,this.map.set(e,i)),i.add(t)}dispatchEvent(e,t={}){let i=this.map.get(e);i&&[...i].forEach((e=>e(t)))}hasEventListener(e){return!!this.map.get(e)}removeEventListener(e,t){if(!e)return void this.map.clear();if(!t)return void this.map.delete(e);let i=this.map.get(e);i&&i.delete(t)}},ia=class{parse(e,t={}){if(t=Object.assign({decodeSpeed:5,encodeSpeed:5,encoderMethod:ia.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=Cn.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 Tue(e){return 4*Math.ceil(e/4)}function t5(e,t=0){let i=Tue(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 n5=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 dt(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=t5(e.result),n=new DataView(new ArrayBuffer(bue));n.setUint32(0,i.byteLength,!0),n.setUint32(4,Ust,!0);let r=t5(Vst(JSON.stringify(a)),32),s=new DataView(new ArrayBuffer(bue));s.setUint32(0,r.byteLength,!0),s.setUint32(4,Hst,!0);let o=new ArrayBuffer(xue),l=new DataView(o);l.setUint32(0,Fst,!0),l.setUint32(4,Bst,!0);let h=xue+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 L;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 L;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=Cn.normalize(n,e.array))),t===Dr.FLOAT?l.setFloat32(h,n,!0):t===Dr.INT?l.setInt32(h,n,!0):t===Dr.UNSIGNED_INT?l.setUint32(h,n,!0):t===Dr.SHORT?l.setInt16(h,n,!0):t===Dr.UNSIGNED_SHORT?l.setUint16(h,n,!0):t===Dr.BYTE?l.setInt8(h,n):t===Dr.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===Dr.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=t5(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=Dr.FLOAT;else if(e.array.constructor===Int32Array)r=Dr.INT;else if(e.array.constructor===Uint32Array)r=Dr.UNSIGNED_INT;else if(e.array.constructor===Int16Array)r=Dr.SHORT;else if(e.array.constructor===Uint16Array)r=Dr.UNSIGNED_SHORT;else if(e.array.constructor===Int8Array)r=Dr.BYTE;else{if(e.array.constructor!==Uint8Array)throw new Error("THREE.GLTFExporter: Unsupported bufferAttribute component type: "+e.array.constructor.name);r=Dr.UNSIGNED_BYTE}if(void 0===i&&(i=0),void 0===n&&(n=e.count),0===n)return null;let s,o=Gst(e,i,n);void 0!==t&&(s=e===t.index?Dr.ELEMENT_ARRAY_BUFFER:Dr.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=Eue();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!==Vs&&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(_ue(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:ko[e.magFilter],minFilter:ko[e.minFilter],wrapS:ko[e.wrapS],wrapT:ko[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 Ah&&(e=MA(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(tb(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===vr&&(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[e5])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];vue[n]&&vue[n].includes(i)&&(this.extensionsUsed[e5]=!0,this.extensionsRequired[e5]=!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:Cn.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=sv.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 mi;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}}},i5=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}},s5=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}},a5=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}},o5=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}},l5=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}},c5=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}},u5=class{constructor(e){this.writer=e,this.name="KHR_materials_specular"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||1===e.specularIntensity&&e.specularColor.equals(Nst)&&!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}},h5=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}},d5=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}},f5=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}};sv.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 AA).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 ia;i=Object.assign({},{encodeSpeed:5},i);let r=n.parse(e,i);Mi.saveArrayBuffer(r,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/csv"}),t)}static addExtention(e,t){return e.toLowerCase().endsWith(t.toLowerCase())||(e+=t),e}},$p=Mi;$p.EXTENSION_GLTF=".gltf",$p.EXTENSION_GLB=".glb",$p.EXTENSION_OBJ=".obj",$p.EXTENSION_DRACO=".drc",$p.EXTENSION_JSON=".json";var RA=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()}},x5={exports:{}};function IA(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=Cue(e,0,u,i,!0),p=[];if(!d||d.next===d.prev)return p;if(c&&(d=Yst(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 nb(d,p,i,n,r,h,0),p}function Cue(e,t,i,n,r){var a,s;if(r===y5(e,t,i,n)>0)for(a=t;a=t;a-=n)s=wue(a,e[a],e[a+1],s);return s&&DA(s,s.next)&&(ib(s),s=s.next),s}function Zp(e,t){if(!e)return e;t||(t=e);var i,n=e;do{if(i=!1,n.steiner||!DA(n,n.next)&&0!==qi(n.prev,n,n.next))n=n.next;else{if(ib(n),(n=t=n.prev)===n.next)break;i=!0}}while(i||n!==t);return t}function nb(e,t,i,n,r,a,s){if(e){!s&&a&&Qst(e,n,r,a);for(var o,l,h=e;e.prev!==e.next;)if(o=e.prev,l=e.next,a?jst(e,n,r,a):qst(e))t.push(o.i/i|0),t.push(e.i/i|0),t.push(l.i/i|0),ib(e),e=l.next,h=l.next;else if((e=l)===h){s?1===s?nb(e=Wst(Zp(e),t,i),t,i,n,r,a,2):2===s&&Xst(e,t,i,n,r,a):nb(Zp(e),t,i,n,r,a,1);break}}}function qst(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&&av(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 jst(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=g5(p,f,t,i,n),y=g5(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&&av(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&&av(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&&av(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&&av(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 Wst(e,t,i){var n=e;do{var r=n.prev,a=n.next.next;!DA(r,a)&&Pue(r,n,n.next,a)&&rb(r,a)&&rb(a,r)&&(t.push(r.i/i|0),t.push(n.i/i|0),t.push(a.i/i|0),ib(n),ib(n.next),n=e=a),n=n.next}while(n!==e);return Zp(n)}function Xst(e,t,i,n,r,a){var s=e;do{for(var o=s.next.next;o!==s.prev;){if(s.i!==o.i&&nat(s,o)){var l=Iue(s,o);return s=Zp(s,s.next),l=Zp(l,l.next),nb(s,t,i,n,r,a,0),void nb(l,t,i,n,r,a,0)}o=o.next}s=s.next}while(s!==e)}function Yst(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&&av(ai.x||n.x===i.x&&Jst(i,n)))&&(i=n,d=l)),n=n.next}while(n!==h);return i}function Jst(e,t){return qi(e.prev,e,t.prev)<0&&qi(t.next,e,e.next)<0}function Qst(e,t,i,n){var r=e;do{0===r.z&&(r.z=g5(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,eat(r)}function eat(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 g5(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 tat(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 nat(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!rat(e,t)&&(rb(e,t)&&rb(t,e)&&iat(e,t)&&(qi(e.prev,e,t.prev)||qi(e,t.prev,t))||DA(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 DA(e,t){return e.x===t.x&&e.y===t.y}function Pue(e,t,i,n){var r=PA(qi(e,t,i)),a=PA(qi(e,t,n)),s=PA(qi(i,n,e)),o=PA(qi(i,n,t));return!!(r!==a&&s!==o||0===r&&CA(e,i,t)||0===a&&CA(e,n,t)||0===s&&CA(i,e,n)||0===o&&CA(i,t,n))}function CA(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 PA(e){return e>0?1:e<0?-1:0}function rat(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&&Pue(i,i.next,e,t))return!0;i=i.next}while(i!==e);return!1}function rb(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 iat(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 Iue(e,t){var i=new v5(e.i,e.x,e.y),n=new v5(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 wue(e,t,i,n){var r=new v5(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 ib(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 v5(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 y5(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 VMt=x5.exports;function Sue(e,t,i){return e[0]=t[0]-i[0],e[1]=t[1]-i[1],e[2]=t[2]-i[2],e}function sat(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 aat(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 oat(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 Zr=!1,GMt=!1,yu=10,vs=11,Wr=12,ov="gemini-viewer-iconfont",qMt="keydown",jMt="keyup",Zd="mousemove",b5="mouseup",E5="mousedown",WMt="Escape",XMt="Enter",YMt="axis-section-plane",$Mt="axis-section-plane-control",ZMt="section-plane",KMt="section-plane-control",JMt="section-box",_5="plane-section-boxface",Lue=-1e3,lv=(e=>(e.ObjectsBoxSection="ObjectsBoxSection",e.PickPlaneSection="PickPlaneSection",e.AxisPlaneSection="AxisPlaneSection",e))(lv||{}),T5=(e=>(e.Default="Default",e.BoxSelection="BoxSelection",e.PickMarkup="PickMarkup",e))(T5||{}),w5=1e-15,Oue=(new Qe).set(0,0,-1,0,1,0,0,0,0,1,0,0,0,0,0,1),kue=(new Qe).set(0,1,0,0,1,0,0,0,0,0,1,0,0,0,0,1),$t=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 $a){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 L,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=Bue.subVectors(n,i).normalize(),o=Hue.subVectors(a,r).normalize();if(1===s.dot(o))return null;let l=Uue.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($t.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=Bue.subVectors(n,r).length(),s=Hue.subVectors(e,n).length(),o=Uue.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(Jt.shouldRebasePositionOnRTC(t)){n=!0;for(let n=0;nS5||Math.abs(e.y)>S5||e instanceof L&&Math.abs(e.z)>S5}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 L(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||(Nue.setFromPoints(e),Fue.setFromPoints(t),!Nue.intersectsBox(Fue)))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}=Due([i],{lineWidth:t,depth:1}),r=new Lt;return r.setAttribute("position",new Ft(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 ur)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=vr),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 hi||e instanceof kn||e instanceof rn?t=e.color:e instanceof an&&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 Oi(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 Lt,h=0;for(let c=0;c0){e.matrixWorld||(e.matrixWorld=new Qe),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=vr)},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 _t){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&&ae.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 _t)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 hc.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}`);hc.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 _t&&(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 rn({color:0,transparent:!0,opacity:.05});this.applyMaterialToObject(e,n,t,i)}static setWireframeMode(e){let t=new rn({color:16732160,wireframe:!0,transparent:!0,opacity:.8});e.traverseVisible((e=>{if(e instanceof _t){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}`);hc.setWireframeMode(i)}static revertWireframeMode(e){e.traverseVisible((e=>{e instanceof _t&&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}`);hc.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 dt(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 _t)))return[];let n=[],r=e,a=r.children.length,s=Math.round(Math.pow(a,.5)),o=wt.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=wt.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 _t&&!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 lu(e,5),r=new Br(n,t);return r.layers.enableAll(),hc.disableLayerChannels(r,[12]),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 _t||e instanceof rr)&&(e.material=ji.cloneMaterial(e.material))})),i}static createBox(e,t,i,n=hc.BOX_FACE_MATERIAL,r=!0){let a=[],s=(e,t,i)=>{a.push(new L(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 Lt;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 _t(o,n)}static rebaseObjectOnRTC(e){let t=e;if(!((t.isMesh||t.isLine||t.isPoints)&&t.geometry&&t.geometry instanceof Lt))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=gat;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 _t||e instanceof rr||e instanceof $r)&&!!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 Lt))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),Jt.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=Oi(c);if(!e)return;e.userData={},n=new _t(e,h.material),a.push(n)}else if(h.isLine){let e=this.mergeLineGeometries(c,t,h.material instanceof uu||h.material instanceof an,f);if(!e)return;n=new Br(e,h.material),s.push(n)}else if(h.isPoints){let e=Oi(c);if(!e)return;e.userData={},n=new $r(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(),Jt.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)&&ji.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=void 0,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;ae.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 kn&&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=Oi(o);if(!e)return;e.userData={},a=new _t(e,s.material),h.push(a)}else if(s.isLine){let e=this.mergeLineGeometries(o,r,s.material instanceof uu||s.material instanceof an,m);if(!e)return;a=new Br(e,s.material),c.push(a)}else if(s.isPoints){let e=Oi(o);if(!e)return;e.userData={},a=new $r(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(),Jt.releaseGeometryManually(e)})),o=[]}})),ae.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&&Nn.removeEmptyObjects(t),a}static applyMatrix(e,t,i){let n=t;for(LA.identity();n&&n!==i&&(LA.premultiply(n.matrix),n.parent);)n=n.parent;return LA.equals(vat)?e:e.applyMatrix4(LA)}static mergeLineGeometries(e,t,i,n){let r;if(i)r=OA.mergeBufferGeometriesWithLinesToLineSegments(e,t,n);else{if(r=Oi(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 Lt,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&&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 cb(d,p,i,n,r,h,0),p}};function fhe(e,t,i,n,r){let a,s;if(r===cot(e,t,i,n)>0)for(a=t;a=t;a-=n)s=hhe(a,e[a],e[a+1],s);return s&&GA(s,s.next)&&(hb(s),s=s.next),s}function Jp(e,t){if(!e)return e;t||(t=e);let i,n=e;do{if(i=!1,n.steiner||!GA(n,n.next)&&0!==Wi(n.prev,n,n.next))n=n.next;else{if(hb(n),n=t=n.prev,n===n.next)break;i=!0}}while(i||n!==t);return t}function cb(e,t,i,n,r,a,s){if(!e)return;!s&&a&&rot(e,n,r,a);let o,l,h=e;for(;e.prev!==e.next;)if(o=e.prev,l=e.next,a?$at(e,n,r,a):Yat(e))t.push(o.i/i|0),t.push(e.i/i|0),t.push(l.i/i|0),hb(e),e=l.next,h=l.next;else if((e=l)===h){s?1===s?cb(e=Zat(Jp(e),t,i),t,i,n,r,a,2):2===s&&Kat(e,t,i,n,r,a):cb(Jp(e),t,i,n,r,a,1);break}}function Yat(e){let t=e.prev,i=e,n=e.next;if(Wi(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&&cv(r,o,a,l,s,h,f.x,f.y)&&Wi(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function $at(e,t,i,n){let r=e.prev,a=e,s=e.next;if(Wi(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=k5(p,f,t,i,n),y=k5(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&&cv(o,c,l,u,h,d,x.x,x.y)&&Wi(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&&cv(o,c,l,u,h,d,b.x,b.y)&&Wi(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&&cv(o,c,l,u,h,d,x.x,x.y)&&Wi(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&&cv(o,c,l,u,h,d,b.x,b.y)&&Wi(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function Zat(e,t,i){let n=e;do{let r=n.prev,a=n.next.next;!GA(r,a)&&phe(r,n,n.next,a)&&ub(r,a)&&ub(a,r)&&(t.push(r.i/i|0),t.push(n.i/i|0),t.push(a.i/i|0),hb(n),hb(n.next),n=e=a),n=n.next}while(n!==e);return Jp(n)}function Kat(e,t,i,n,r,a){let s=e;do{let e=s.next.next;for(;e!==s.prev;){if(s.i!==e.i&&aot(s,e)){let o=mhe(s,e);return s=Jp(s,s.next),o=Jp(o,o.next),cb(s,t,i,n,r,a,0),void cb(o,t,i,n,r,a,0)}e=e.next}s=s.next}while(s!==e)}function Jat(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&&cv(si.x||n.x===i.x&¬(i,n)))&&(i=n,u=o)),n=n.next}while(n!==l);return i}function not(e,t){return Wi(e.prev,e,t.prev)<0&&Wi(t.next,e,e.next)<0}function rot(e,t,i,n){let r=e;do{0===r.z&&(r.z=k5(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,iot(r)}function iot(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 k5(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 sot(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 aot(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!oot(e,t)&&(ub(e,t)&&ub(t,e)&&lot(e,t)&&(Wi(e.prev,e,t.prev)||Wi(e,t.prev,t))||GA(e,t)&&Wi(e.prev,e,e.next)>0&&Wi(t.prev,t,t.next)>0)}function Wi(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function GA(e,t){return e.x===t.x&&e.y===t.y}function phe(e,t,i,n){let r=zA(Wi(e,t,i)),a=zA(Wi(e,t,n)),s=zA(Wi(i,n,e)),o=zA(Wi(i,n,t));return!!(r!==a&&s!==o||0===r&&VA(e,i,t)||0===a&&VA(e,n,t)||0===s&&VA(i,e,n)||0===o&&VA(i,t,n))}function VA(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 zA(e){return e>0?1:e<0?-1:0}function oot(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&&phe(i,i.next,e,t))return!0;i=i.next}while(i!==e);return!1}function ub(e,t){return Wi(e.prev,e,e.next)<0?Wi(e,t,e.next)>=0&&Wi(e,e.prev,t)>=0:Wi(e,t,e.prev)<0||Wi(e,e.next,t)<0}function lot(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 mhe(e,t){let i=new N5(e.i,e.x,e.y),n=new N5(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 hhe(e,t,i,n){let r=new N5(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 hb(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 N5(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 cot(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 dhe.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;nuot)return!1;return!0}static isSelfIntersecting(e){let t=e.map((e=>e.toArray().slice(0,-1)));return(0,ghe.default)(t).length>0}},Ss=class{static getVisibleObjectBoundingBox(e){let t=new It;return e.traverse((e=>{e.visible&&(e instanceof _t||e instanceof rr)&&Nn.isObjectSelectable(e)&&t.expandByObject(e)})),t}static getObjectsBoundingBox(e,t,i){let n=new It;return t.forEach((t=>{let r=e.getObjectById(t);if(r){let e=Ss.getBoundingBox(r,i);e.isEmpty()||n.union(e)}})),n}static getBoundingBox(e,t=!0){let i=new It;if(e instanceof Li)return Ss.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=void 0})):t&&(t.clippingPlanes=void 0)}))}static addSection(e,t,i=!1,n=!1){e&&e.traverse((e=>{let r=e.material;Array.isArray(r)?r.forEach((e=>{xu.setMaterialSection(e,t,i,n)})):r&&xu.setMaterialSection(r,t,i,n)}))}static generateSectionPlanesByBox(e){let t=e.min,i=e.max;return[new Nr(new L(0,-1,0),i.y),new Nr(new L(0,1,0),-t.y),new Nr(new L(1,0,0),-t.x),new Nr(new L(-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 dot(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)&&fot(i.faces[a],t);for(let a=i.faces.length-1;a>=0;a--)i.faces[a].replaceVertex(i,n);yhe(i,e);for(let a=0;a0?(new qA).modify(e,i):e}static getNumberOfVerticesToRemove(e,t){let i=0;e instanceof Lt&&e.index&&(i=e.attributes.position.count);let n=Math.floor(i*t);return i<20?0:n}},WA=class extends sn{constructor(e){super(),this.isSVGObject=!0,this.node=e}},nRt=10,_he=(e=>(e.TripleCross="TripleCross",e.Square="Square",e.Triangle="Triangle",e.CircleWithCross="CircleWithCross",e.Cross="Cross",e.Perpendicular="Perpendicular",e))(_he||{}),Ehe=class{static createSVGObject(e){return new WA(e)}},XA=class extends zp{constructor(e){super(e),this.type=xr}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 dt(this,arguments,(function*(e,t=this.HDR_CITY_STREET_64x32,i=64,n=32){if(e){let r=new hl(t,i,n);r.flipY=!0,r.magFilter=_r,r.minFilter=_r,r.type=xr,r.version=1;let a=e.fromEquirectangular(r).texture;return e.dispose(),Promise.resolve(a)}return Promise.reject("Invalid pmremGenerator!")}))}};function got(){if(Tn.isBrowser){let e=document.createElement("div");return e.setAttribute("style","height: 1in; visibility: hidden; position: absolute; margin: 0; padding: 0;"),document.body.appendChild(e),.0254/e.clientHeight}return.0254/96}dc.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 The={file:1,m:1,mm:.001,cm:.01,ft:.3048,in:.0254,pt:got()},vot={file:"m",m:"m",mm:"mm",cm:"cm",ft:"ft",in:"in",pt:"pt"},whe=e=>2===e?"\xb2":3===e?"\xb3":"",db=(e,t=1)=>vot[e]+whe(t),uRt=(e,t,i,n=1)=>(null==i&&(i=t),i===t?{value:e,unit:db(i)}:{value:e*Math.pow(The[t]/The[i],n),unit:db(i)+whe(n)}),H5=(e=>(e.Top="Top",e.Bottom="Bottom",e.Front="Front",e.Back="Back",e.Left="Left",e.Right="Right",e))(H5||{}),fb=class{static getCameraPositionByBboxAndDirection(e,t,i,n,r){if(e.isEmpty()||!n)return;let a=new L,s=new L,o=new L(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 L))l=new L(a.x+c,a.y+c/1.5,a.z+c),h=l.clone().sub(a);else{let e=new L(c,c/1.5,c).length();h=new L(-r.x,-r.y,-r.z).normalize().multiplyScalar(e),l=h.clone().add(a)}c=h.length(),h=h.normalize();let u=new Qe;u.lookAt(l,a,o);let d=new Qe;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 L(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}},yot=!1,Ai=class extends ts{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 Qe,this.id=e||wt.guid()}setTolerance(e){this.tolerance=e}render(e,t){this.ctx=e,this.draw(e,t),this.selected&&this.drawSelect(e,t),yot&&(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 L(this.x,this.y,0),new L(this.x+this.width,this.y,0),new L(this.x+this.width,this.y-this.height,0),new L(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 L)}transToScreenCoord(e,t){return this.ctx?on.worldPosition2ScreenPoint(e,t,this.ctx.canvas):new ye}drawBounds(e,t){let{min:i,max:n}=this.getBounds(),r=[],a=(e,t,i)=>r.push(new L(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 It).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||{}),She={},On=class extends ts{constructor(e){super(),this.drawableLists=[],this.frustum=new ra,this.projScreenMatrix=new Qe,this.viewer=e,this.init()}static _registerDrawableClass(e){She[e.prototype.getClassType()]=e}static createDrawable(e){let t=She[e.type];if(!t)throw new Error(`Invalid drawable type: ${t}`);let i=e.points.map((e=>new L(e[0],e[1],e[2]||0))),n=new t(e.id,i);return n.setData(e),n}get container(){return this.viewer.viewerContainer}get camera(){return this.viewer.camera}get raycaster(){return this.viewer.getRaycaster()}init(){this.initCanvas(),this.viewer.addEventListener("AfterRender",(()=>{this.projScreenMatrix.multiplyMatrices(this.camera.projectionMatrix,this.camera.matrixWorldInverse),this.frustum.setFromProjectionMatrix(this.projScreenMatrix),this.render()}))}initCanvas(){let e=this.viewer.getViewConfig();if(Tn.isBrowser&&!e.context2d){let e=this.canvas=document.createElement("canvas"),t=this.viewer.viewerContainer;t.appendChild(e),e.classList.add("overlay-renderer"),e.style.pointerEvents="none",e.style.position="absolute",e.style.left="0px",e.style.top="0px",e.style.userSelect="none",this.context=e.getContext("2d",{willReadFrequently:!0});let{clientWidth:i,clientHeight:n}=t;this.setSize(i,n)}else e.context2d&&(this.context=e.context2d,this.canvas=Tn.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 cr,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){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)}},Fo=class extends ts{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 L)}isPointInPath(e){let t=this.getVertexes().map((e=>new ye(e.x,e.y)));return Jt.isPointInPolygon(new ye(e.x,e.y),t,!0)}setData(e){super.setData(e),this.update(e.points.map((e=>new L(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}=xot.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 L(e,t,0);return this.points.forEach((e=>e.add(i))),this.update(this.points),this}rotate(){return this}scale(){return this}},Ca=(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))(Ca||{}),U5=class extends vi{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 L).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=wn.rgba2Color(this.lineColor);let[n,r]=t,a=(new ye).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 ye(i.x+l,i.y+h),p=new ye(i.x+c,i.y+u);e.save(),e.fillStyle=wn.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 Jt.isPointOnLineSegments(e,this.points,this.tolerance)}getClassType(){return"ArrowMarkup"}};On._registerDrawableClass(U5);var bot=new ye,Mhe=new L,V5=class extends vi{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=bot.subVectors(n,i).length(),e.save(),e.lineWidth=this.lineWidth,e.strokeStyle=wn.rgba2Color(this.lineColor),e.fillStyle=wn.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=Mhe.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=Mhe.subVectors(t,i).length();return Math.abs(e.distanceTo(t)-n)<=2*this.tolerance}getClassType(){return"CircleMarkup"}};On._registerDrawableClass(V5);var Ahe=new It,fc=class extends vi{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=wn.rgba2Color(this.lineColor),e.fillStyle=wn.rgba2Color(this.fillColor),e.beginPath();for(let s=0;sthis.transToScreenCoord(e,t))),r=(new ye).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=wn.rgba2Color(this.lineColor),e.fillStyle=wn.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 L).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"}};On._registerDrawableClass(q5);var pb=class extends vi{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>pb.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>pb.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 L(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=wn.rgba2Color(this.lineColor),e.fillStyle=wn.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 ye(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 ${wn.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=`${pb.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=wn.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")}},El=pb;El.DEFAULT_INPUT_WIDTH=50,On._registerDrawableClass(El);var Rhe=new ye,Che=new ye(1,0),Phe=new ye(0,-1),j5=class extends El{constructor(e,t,i){super(e,t,i),this.type="LeaderLineMarkup",this.text="LeaderLine",this.fontSize=12,this.textBounds=new It,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 L).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 ye(i.x+l,i.y+h),p=new ye(i.x+c,i.y+u);e.save(),e.fillStyle=wn.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=wn.rgba2Color(this.lineColor);let[n,r]=t,a=(new ye).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 ye).subVectors(r,n).normalize(),s=a.cross(Phe)<0,o=a.cross(Che)<0,l=i.split("\n"),h=this.fontSize/this.tolerance,c=0;e.save(),e.lineWidth=this.lineWidth,e.strokeStyle=wn.rgba2Color(this.lineColor),e.fillStyle=wn.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 ye(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 Jt.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=>on.worldPosition2ScreenPoint(t,e.camera,e.viewerCanvas))),a=(new ye).subVectors(r,n).normalize(),s=a.cross(Phe)<0,o=a.cross(Che)<0,l=this.fontSize/this.tolerance,h=this.padding/this.tolerance,c=h+l/2,u=El.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>El.DEFAULT_INPUT_WIDTH){let e=this.points[1],t=on.worldPosition2ScreenPoint(this.points[0],this.manager.camera,this.manager.viewerCanvas),n=on.worldPosition2ScreenPoint(e,this.manager.camera,this.manager.viewerCanvas).clone().sub(t).normalize().cross(new ye(0,-1))<0,r=on.worldPosition2ScreenPoint(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`}}};On._registerDrawableClass(j5);var W5=class extends vi{constructor(e,t){super(e),this.type="PolylineMarkup",this.update(t)}draw(e,t){e.save(),e.lineWidth=this.lineWidth,e.strokeStyle=wn.rgba2Color(this.lineColor),e.fillStyle=wn.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 Jt.isPointOnLineSegments(e,[t,n,i,r],.1)}getClassType(){return"XMarkup"}};On._registerDrawableClass(Y5);var Ihe=new It,$5=new L,Z5=new ye,Eot=new ye(1,0),_ot=new ye(0,-1),K5=class extends El{constructor(e,t,i=""){super(e,t,i),this.type="CloudRectWithTextMarkup",this.textPosition=new L,this.textBounds=new It,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=wn.rgba2Color(this.lineColor),e.fillStyle=wn.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=K5.LEADER_LINE_WIDTH,e.strokeStyle=wn.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=Z5.subVectors(r,n).normalize(),s=a.cross(Eot)<0,o=a.cross(_ot)<0,l=i.split("\n"),h=this.fontSize/this.tolerance,c=0;e.save(),e.lineWidth=this.lineWidth,e.strokeStyle=wn.rgba2Color(this.lineColor),e.fillStyle=wn.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 ye(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 L),this.textPosition.set(Math.max(t.x,i.x),Math.max(t.y,i.y),0),this}getCloudPoints(){return[new L(this.x,this.y,0),new L(this.x+this.width,this.y,0),new L(this.x+this.width,this.y-this.height,0),new L(this.x,this.y-this.height,0)]}getBounds(){return Ihe.setFromPoints([...this.points,...this.vertexes||[]]),Ihe.union(this.textBounds)}getVertexes(){let e=this.getBounds(),t=e.min,i=e.getSize($5);return[new L(t.x,t.y,0),new L(t.x+i.x,t.y,0),new L(t.x+i.x,t.y+i.y,0),new L(t.x,t.y+i.y,0)]}isLeaderTextSelected(e){return this.textBounds.containsPoint(e)}translateLeaderText(e,t){let i=new L(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 ye(0,-1))<0,r=this.textInput.value,a=(null==(i=this.manager.overlayRender)?void 0:i.measureTextLength(r,this.fontSize/this.tolerance+"px Arial"))||El.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(on.screenPoint2worldPosition(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>El.DEFAULT_INPUT_WIDTH){let e=on.worldPosition2ScreenPoint(this.points[0],this.manager.camera,this.manager.viewerCanvas),t=on.worldPosition2ScreenPoint(this.textPosition,this.manager.camera,this.manager.viewerCanvas).clone().sub(e).normalize().cross(new ye(0,-1))<0,n=on.worldPosition2ScreenPoint(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`}}},tm=K5;tm.LEADER_LINE_WIDTH=1,On._registerDrawableClass(tm);var Xn={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 Qd(e){return e.isPerspectiveCamera}function bu(e){return e.isOrthographicCamera}var Tot=(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))(Tot||{}),wot=(e=>(e.LEFT="ArrowLeft",e.UP="ArrowUp",e.RIGHT="ArrowRight",e.BOTTOM="ArrowDown",e))(wot||{});function uv(e){return{type:e}}var Eu={movable:!1,startDistBetweenFingers:0,scale:1},hv=2*Math.PI,Dhe=1e-6,YA=class extends Do{constructor(e,t,i=!1){super(),this.enabled=!0,this.target=new L,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 L,this.pointerPositions={},this.rotateStart=new ye,this.rotateEnd=new ye,this.rotateDelta=new ye,this.dollyStart=new ye,this.dollyEnd=new ye,this.dollyDelta=new ye,this.panStart=new ye,this.panEnd=new ye,this.panDelta=new ye,this.pointers=[],this.spherical=new Hd,this.sphericalDelta=new Hd,this.update=function(e){let t=new L,i=new L,n=new ir;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+=hv/60/60*e.autoRotateSpeed:e.sphericalDelta.theta-=hv/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+=hv:o>Math.PI&&(o-=hv),l<-Math.PI?l+=hv:l>Math.PI&&(l-=hv),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)>Dhe||8*(1-n.dot(e.object.quaternion))>Dhe)&&(e.dispatchEvent(uv("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(uv("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(uv("start")),e.handleMouseWheel(t),e.dispatchEvent(uv("end")))}}(this),this.pan=function(e){let t=new L;return function(i,n){let r=e.domElement;if(e.object instanceof nr){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 L;return function(i,n){t.setFromMatrixColumn(n,0),t.multiplyScalar(-i),e.panOffset.add(t)}}(this),this.panUp=function(e){let t=new L;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 ir).setFromUnitVectors(this.object.up,new L(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];Eu.startDistBetweenFingers=this.getDist([t.pageX,t.pageY],[i.pageX,i.pageY]),Eu.movable=!0,Eu.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 nr?this.scale/=e:(console.warn("WARNING: VRControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}dollyIn(e){this.object instanceof nr?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 nr))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(!Eu.movable||this.pointers.length<2)return;let t=this.getSecondPointerPosition(e),i=[e.pageX,e.pageY],n=[t.x,t.y],r=Eu.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-Eu.scale;if(Math.abs(o)<.05)return;let l=0;l=o>0?10*-o:10*(Eu.scale/s-1),this.updateFov(l),Eu.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}},Bo=class extends ts{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,$A(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,$A(e,"pointerId")){t.pointerType=e.pointerType,t.buttons=e.buttons,t.pageX=e.pageX,t.pageY=e.pageY,t.pointerId=e.pointerId;let i=on.getScreenPointByEvent(e,this.element);t.x=i.x,t.y=i.y,t.movementX=e.movementX,t.movementY=e.movementY}else $A(e,"deltaX")&&(t.deltaMode=e.deltaMode,t.deltaX=e.deltaX,t.deltaY=e.deltaY);else $A(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 eH(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 ZA(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 KA(e,t){return!!bu(e)&&(console.warn(`${t} is not supported in OrthographicCamera`),!0)}var JA=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=Tn.isBrowser?new DOMRect:{x:0,y:0,width:0,height:0,left:0,right:0,top:0,bottom:0},this._activePointers=[],this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._isUserControllingOffset=!1,this._isUserControllingZoom=!1,this._thetaVelocity={value:0},this._phiVelocity={value:0},this._radiusVelocity={value:0},this._targetVelocity=new Yn.Vector3,this._focalOffsetVelocity=new Yn.Vector3,this._zoomVelocity={value:0},this._truckInternal=(e,t,i)=>{if(Qd(this._camera)){let n=Qn.copy(this._camera.position).sub(this._target),r=this._camera.getEffectiveFOV()*dv,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(bu(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=nm*this.azimuthRotateSpeed*e/this._elementRect.height,n=nm*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===Yn&&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 Yn.Quaternion).setFromUnitVectors(this._camera.up,eR),this._yAxisUpSpaceInverse=this._yAxisUpSpace.clone().invert(),this._state=yt.NONE,this._target=new Yn.Vector3,this._targetEnd=this._target.clone(),this._focalOffset=new Yn.Vector3,this._focalOffsetEnd=this._focalOffset.clone(),this._spherical=(new Yn.Spherical).setFromVector3(Qn.copy(this._camera.position).applyQuaternion(this._yAxisUpSpace)),this._sphericalEnd=this._spherical.clone(),this._zoom=this._camera.zoom,this._zoomEnd=this._zoom,this._nearPlaneCorners=[new Yn.Vector3,new Yn.Vector3,new Yn.Vector3,new Yn.Vector3],this._updateNearPlaneCorners(),this._boundary=new Yn.Box3(new Yn.Vector3(-1/0,-1/0,-1/0),new Yn.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 Yn.Vector2,this.mouseButtons={left:yt.ROTATE,middle:yt.DOLLY,right:yt.TRUCK,wheel:Qd(this._camera)?yt.DOLLY:bu(this._camera)?yt.ZOOM:yt.NONE},this.touches={one:yt.TOUCH_ROTATE,two:Qd(this._camera)?yt.TOUCH_DOLLY_TRUCK:bu(this._camera)?yt.TOUCH_ZOOM_TRUCK:yt.NONE,three:yt.TOUCH_TRUCK};let i=new Yn.Vector2,n=new Yn.Vector2,r=new Yn.Vector2,a=e=>{if(!this._enabled||!this._domElement)return;let t="mouse"!==e.pointerType?null:(e.buttons&Xn.LEFT)===Xn.LEFT?Xn.LEFT:(e.buttons&Xn.MIDDLE)===Xn.MIDDLE?Xn.MIDDLE:(e.buttons&Xn.RIGHT)===Xn.RIGHT?Xn.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&Xn.LEFT)===Xn.LEFT?Xn.LEFT:(e.buttons&Xn.MIDDLE)===Xn.MIDDLE?Xn.MIDDLE:(e.buttons&Xn.RIGHT)===Xn.RIGHT?Xn.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&Xn.LEFT)===Xn.LEFT?Xn.LEFT:(e.buttons&Xn.MIDDLE)===Xn.LEFT?Xn.MIDDLE:(e.buttons&Xn.RIGHT)===Xn.LEFT?Xn.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&Xn.LEFT)===Xn.LEFT&&(this._state=this._state|this.mouseButtons.left),(e.buttons&Xn.MIDDLE)===Xn.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),(e.buttons&Xn.RIGHT)===Xn.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&Xn.LEFT)===Xn.LEFT&&(this._state=this._state|this.mouseButtons.left),(e.buttons&Xn.MIDDLE)===Xn.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),(e.buttons&Xn.RIGHT)===Xn.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=Sot?-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===ef.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(ZA(this._activePointers,io),this._getClientRect(this._elementRect),i.copy(io),n.copy(io),this._activePointers.length>=2){let e=io.x-this._activePointers[1].clientX,t=io.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&Xn.LEFT)===Xn.LEFT&&(this._state=this._state|this.mouseButtons.left),(e.buttons&Xn.MIDDLE)===Xn.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),(e.buttons&Xn.RIGHT)===Xn.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;ZA(this._activePointers,io);let e=!!Tn.isBrowser&&this._domElement&&document.pointerLockElement===this._domElement,t=e?-this._activePointers[0].deltaX:n.x-io.x,a=e?-this._activePointers[0].deltaY:n.y-io.y;if(n.copy(io),((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*QA,e,t),this._isUserControllingDolly=!0):(this._zoomInternal(a*QA,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=io.x-this._activePointers[1].clientX,t=io.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*QA,s,o),this._isUserControllingDolly=!0):(this._zoomInternal(a*QA,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=()=>{ZA(this._activePointers,io),n.copy(io),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),Mot&&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){Yn=e.THREE,Lhe=Object.freeze(new Yn.Vector3(0,0,0)),eR=Object.freeze(new Yn.Vector3(0,1,0)),tH=Object.freeze(new Yn.Vector3(0,0,1)),io=new Yn.Vector2,Qn=new Yn.Vector3,di=new Yn.Vector3,mv=new Yn.Vector3,_u=new Yn.Vector3,Tu=new Yn.Vector3,im=new Yn.Vector3,Ohe=new Yn.Vector3,khe=new Yn.Vector3,pc=new Yn.Spherical,gb=new Yn.Spherical,gv=new Yn.Box3,Nhe=new Yn.Box3,nH=new Yn.Sphere,Fhe=new Yn.Quaternion,rH=new Yn.Quaternion,iH=new Yn.Matrix4,tR=new Yn.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=rm(e,this.minAzimuthAngle,this.maxAzimuthAngle),r=rm(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||Ci(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&Ci(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=rm(e,this.minDistance,this.maxDistance);if(this.colliderMeshes.length>=1){let e=this._collisionTest(),t=Ci(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||Ci(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=rm(e,this.minZoom,this.maxZoom),this._needsUpdate=!0,t||(this._zoom=this._zoomEnd);let i=!t||Ci(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(),_u.setFromMatrixColumn(this._camera.matrix,0),Tu.setFromMatrixColumn(this._camera.matrix,1),_u.multiplyScalar(e),Tu.multiplyScalar(-t);let n=Qn.copy(_u).add(Tu),r=di.copy(this._targetEnd).add(n);return this.moveTo(r.x,r.y,r.z,i)}forward(e,t=!1){Qn.setFromMatrixColumn(this._camera.matrix,0),Qn.crossVectors(this._camera.up,Qn),Qn.multiplyScalar(e);let i=di.copy(this._targetEnd).add(Qn);return this.moveTo(i.x,i.y,i.z,t)}elevate(e,t=!1){return Qn.copy(this._camera.up).multiplyScalar(e),this.moveTo(this._targetEnd.x+Qn.x,this._targetEnd.y+Qn.y,this._targetEnd.z+Qn.z,t)}moveTo(e,t,i,n=!1){this._isUserControllingTruck=!1;let r=Qn.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||Ci(this._target.x,this._targetEnd.x,this.restThreshold)&&Ci(this._target.y,this._targetEnd.y,this.restThreshold)&&Ci(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(a)}lookInDirectionOf(e,t,i,n=!1){let r=Qn.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?gv.copy(e):gv.setFromObject(e);l.isEmpty()&&(console.warn("camera-controls: fitTo() cannot be used with an empty box. Aborting"),Promise.resolve());let h=Q5(this._sphericalEnd.theta,J5),c=Q5(this._sphericalEnd.phi,J5);o.push(this.rotateTo(h,c,t));let u=Qn.setFromSpherical(this._sphericalEnd).normalize(),d=Fhe.setFromUnitVectors(u,tH),p=Ci(Math.abs(u.y),1);p&&d.multiply(rH.setFromAxisAngle(eR,h)),d.multiply(this._yAxisUpSpaceInverse);let f=Nhe.makeEmpty();di.copy(l.min).applyQuaternion(d),f.expandByPoint(di),di.copy(l.min).setX(l.max.x).applyQuaternion(d),f.expandByPoint(di),di.copy(l.min).setY(l.max.y).applyQuaternion(d),f.expandByPoint(di),di.copy(l.max).setZ(l.min.z).applyQuaternion(d),f.expandByPoint(di),di.copy(l.min).setZ(l.max.z).applyQuaternion(d),f.expandByPoint(di),di.copy(l.max).setY(l.min.y).applyQuaternion(d),f.expandByPoint(di),di.copy(l.max).setX(l.min.x).applyQuaternion(d),f.expandByPoint(di),di.copy(l.max).applyQuaternion(d),f.expandByPoint(di),f.min.x-=n,f.min.y-=a,f.max.x+=r,f.max.y+=s,d.setFromUnitVectors(tH,u),p&&d.premultiply(rH.invert()),d.premultiply(this._yAxisUpSpace);let m=f.getSize(Qn),g=f.getCenter(di).applyQuaternion(d);if(Qd(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(bu(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 Yn.Sphere?nH.copy(e):ef.createBoundingSphere(e,nH);if(i.push(this.moveTo(n.center.x,n.center.y,n.center.z,t)),Qd(this._camera)){let e=this.getDistanceToFitSphere(n.radius);i.push(this.dollyTo(e,t))}else if(bu(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=di.set(n,r,a),l=Qn.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||Ci(this._target.x,this._targetEnd.x,this.restThreshold)&&Ci(this._target.y,this._targetEnd.y,this.restThreshold)&&Ci(this._target.z,this._targetEnd.z,this.restThreshold)&&Ci(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&Ci(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&Ci(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=Qn.set(n,r,a),m=di.set(e,t,i);pc.setFromVector3(m.sub(f).applyQuaternion(this._yAxisUpSpace));let g=mv.set(h,c,u),v=di.set(s,o,l);gb.setFromVector3(v.sub(g).applyQuaternion(this._yAxisUpSpace)),this._targetEnd.copy(f.lerp(g,d));let y=gb.theta-pc.theta,x=gb.phi-pc.phi,b=gb.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||Ci(this._target.x,this._targetEnd.x,this.restThreshold)&&Ci(this._target.y,this._targetEnd.y,this.restThreshold)&&Ci(this._target.z,this._targetEnd.z,this.restThreshold)&&Ci(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&Ci(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&Ci(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(Qn),a=this.setLookAt(r.x,r.y,r.z,e,t,i,n);return this._sphericalEnd.phi=rm(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||Ci(this._focalOffset.x,this._focalOffsetEnd.x,this.restThreshold)&&Ci(this._focalOffset.y,this._focalOffsetEnd.y,this.restThreshold)&&Ci(this._focalOffset.z,this._focalOffsetEnd.z,this.restThreshold);return this._createOnRestPromise(r)}setOrbitPoint(e,t,i){this._camera.updateMatrixWorld(),_u.setFromMatrixColumn(this._camera.matrixWorldInverse,0),Tu.setFromMatrixColumn(this._camera.matrixWorldInverse,1),im.setFromMatrixColumn(this._camera.matrixWorldInverse,2);let n=Qn.set(e,t,i),r=n.distanceTo(this._camera.position),a=n.sub(this._camera.position);_u.multiplyScalar(a.x),Tu.multiplyScalar(a.y),im.multiplyScalar(a.z),Qn.copy(_u).add(Tu).add(im),Qn.z=Qn.z+r,this.dollyTo(r,!1),this.setFocalOffset(-Qn.x,Qn.y,-Qn.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 Yn.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(KA(this._camera,"getDistanceToFitBox"))return this._spherical.radius;let r=e/t,a=this._camera.getEffectiveFOV()*dv,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=di.copy(t).add(e),a=this._boundary.clampPoint(r,mv).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(di.copy(t).multiplyScalar(n)).add(a.multiplyScalar(1-i))}}_updateNearPlaneCorners(){if(Qd(this._camera)){let e=this._camera,t=e.near,i=e.getEffectiveFOV()*dv,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(bu(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)||KA(this._camera,"_collisionTest"))return e;let t=Qn.setFromSpherical(this._spherical).divideScalar(this._spherical.radius);iH.lookAt(Lhe,t,this._camera.up);for(let i=0;i<4;i++){let n=di.copy(this._nearPlaneCorners[i]);n.applyMatrix4(iH);let r=mv.addVectors(this._target,n);tR.set(r,t),tR.far=this._spherical.radius+1;let a=tR.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 Yn.Sphere){let i=t,n=i.center;gv.makeEmpty(),e.traverseVisible((e=>{e.isMesh&&gv.expandByObject(e)})),gv.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()}},_l=class{constructor(e){this.name=e}},nR=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}},vb=class extends _l{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)}},rR=class extends _l{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)}},sm=class extends _l{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)}},yb=class extends _l{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)}},vv=class extends _l{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)}},Bhe=new L,xb=class extends ts{constructor(e,t){var i;super(),this.drawableList=new Fo("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=on.getScreenPointByEvent(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(this.mouseDownPositionX=i.x,this.mouseDownPositionY=i.y,this.mousedownPoint=new ye(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 tm&&(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(Bhe.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 tm&&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 L(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];Bhe.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 sm(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,Tn.isMobile?(this.inputManager.addEventListener("touchstart",this.mousedown),this.inputManager.addEventListener("touchmove",this.mousemove),this.inputManager.addEventListener("touchend",this.mouseup)):(this.inputManager.addEventListener("mousedown",this.mousedown),this.inputManager.addEventListener("mousemove",this.mousemove),this.inputManager.addEventListener("mouseup",this.mouseup),this.inputManager.addEventListener("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,Tn.isMobile?(this.inputManager.removeEventListener("touchstart",this.mousedown),this.inputManager.removeEventListener("touchmove",this.mousemove),this.inputManager.removeEventListener("touchend",this.mouseup)):(this.inputManager.removeEventListener("mousedown",this.mousedown),this.inputManager.removeEventListener("mousemove",this.mousemove),this.inputManager.removeEventListener("mouseup",this.mouseup),this.inputManager.removeEventListener("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=on.screenPoint2NdcPoint(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}pickThreejsPositionByMouse(e){return this.pickPositionByScreenPoint(new ye(e.x,e.y))}confirmToRemove(e){var t;this.selectedShape&&e&&(this.removeMarkup(this.selectedShape),null==(t=this.viewer.undoRedoManager)||t.addCommand(new sm(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 rR(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 vb(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 On.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 vb(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]),On.createDrawable({id:wt.guid(),lineWidth:this.lineWidth,lineColor:this.lineColor,fillColor:this.fillColor,type:this.type,points:i})}drawLine(e){return On.createDrawable({id:wt.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 On.createDrawable({id:wt.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()}},Hhe=new L,am=class extends Ai{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))(Uhe||{}),om=["INSERT","DIMENSION"],Lkt=$i(jhe(),1),iR=[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],bv=class{constructor(){this.pointer=0,this.eof=!1}},oH=$i(Whe(),1),tf=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 Yhe(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?Yhe(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 ae.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>Xhe)return ae.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 Yhe(e){return Array.prototype.map.call(e,(e=>("00"+e.toString(16)).slice(-2))).join("")}var Ev=class extends bv{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=Rot(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 Rot(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?Cot(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):(ae.info("WARNING: Group code does not have a defined type: %j",{code:e,value:t}),t)}function Cot(e){if("0"===e)return!1;if("1"===e)return!0;throw TypeError("String '"+e+"' cannot be cast to Boolean type")}var Khe=$i(mc(),1),Pot="OriginalHandle",Iot="OriginalType",Dot="Outlines",$he=["PROXY","REGION","INSERT","HATCH"];function lm(e){return iR[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 Zhe(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 Dn(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&&ae.warn("[DxfParser] a negative value of colorIndex indicates that the layer is turned off"),e.color=lm(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(Pot)){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(Dot)&&(e.extendedData||(e.extendedData={}),e.extendedData.outlines=[]),t.value&&t.value.includes(Iot)){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 Tl(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 Tb=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=Lot(e,t),t=e.lastReadGroup;break;case 101:for(;0!=t.code;)t=e.next();break;default:Dn(i,t),t=e.next()}return i}};function Lot(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,Khe.isEmpty)(a)||i.push(a),n=!1,r=!1}return i}var wb=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:Dn(i,t),t=e.next()}return i}},Sb=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:Dn(i,t),t=e.next()}return i}},Mb=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:Dn(i,t),t=e.next()}return i}},Ab=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 Bot(e,t){let i=[],n=t.next();for(;i.length0&&(i.colorIndex=t.value,i.color=lm(Math.abs(t.value))))}t=e.next();break;default:Dn(i,t),t=e.next()}return i}};function Hot(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 Ob=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:Dn(i,t),t=e.next()}return i}},kb=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(...Uot(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:Dn(i,t),t=e.next()}return i}};function Uot(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 Nb=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=Zhe(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:Dn(i,t),t=e.next()}}(),i}},Fb=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:Dn(i,t),t=e.next()}return i}},Bb=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:Dn(i,t),t=e.next()}return i}},Hb=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:Dn(i,t),t=e.next()}return i}},Ub=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:Dn(i,t),t=e.next()}return i}},Vb=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:Dn(i,t),t=e.next()}return i.vertices=Vot(e,t),i}};function Vot(e,t){let i=new Ub,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){zot(e,t);break}return n}function zot(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 Dn(i,t),t=e.next();return i}var zb=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:Dn(i,t),t=e.next()}return i}},Gb=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:Dn(i,t),t=e.next()}return i}},qb=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||(Dn(i,t),t=e.next());return i}},jb=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:Dn(i,t),t=e.next()}return i}},Wb=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:Dn(i,t),t=e.next()}return i}},Xb=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:Dn(i,t),t=e.next()}return i}},Yb=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:Dn(i,t),t=e.next()}return i}},$b=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:Dn(i,t),t=e.next()}return i}},sR=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:Tl(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}},aR=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:Tl(i,t),t=e.next()}return i}},oR=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:Tl(i,t),t=e.next()}return i.blockTableHandle=i.ownerHandle,i}},lR=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:Tl(i,t),t=e.next()}return i}},cR=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=Got(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=Jhe(e,40),r.matrix=Jhe(e,40),t=e.lastReadGroup;break;default:Tl(r,t),t=e.next()}return r}};function Got(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(Uo(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&&!Uo(n,0,"ENDSEC");)if(Uo(n,0,"BLOCK")){ae.trace("block {");let e=o();ae.trace("}"),m(e),e.name?t[e.name]=e:ae.error(`[DxfParser] Block with handle '${e.handle}' is missing a name, ignored!`)}else Oh(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:Oh(n),n=e.next()}if(Uo(n,0,"ENDBLK")){n=e.next();break}}return t}function l(){let t={};for(n=e.next();"EOF"!==n.value&&!Uo(n,0,"ENDSEC");)Uo(n,0,"TABLE")?(n=e.next(),u[n.value]?(ae.trace(n.value+" Table {"),t[u[n.value].tableName]=c(n),ae.trace("}")):ae.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();!Uo(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||Oh(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():(Oh(n),n=e.next());break;default:Oh(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&&ae.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(ae.trace("Viewport {"),n=e.next();!Uo(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&&(ae.trace("}"),t.push(i),ae.trace("Viewport {"),i={},n=e.next());break;default:Oh(n),n=e.next()}return ae.trace("}"),t.push(i),t}},LTYPE:{tableRecordsProperty:"lineTypes",tableName:"lineType",dxfSymbolName:"LTYPE",parseTableRecords:function(){let t={},i={},a=0,s="",o=!1;for(ae.trace("LType {"),n=e.next();!Uo(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:ae.trace("}"),a>0&&a!==i.pattern.length&&ae.warn("[DxfParser] lengths do not match on LTYPE pattern"),t[s]=i,i={},ae.trace("LType {"),n=e.next()}return ae.trace("}"),t[s]=i,t}},LAYER:{tableRecordsProperty:"layers",tableName:"layer",dxfSymbolName:"LAYER",parseTableRecords:function(){let t,i={},r={};for(ae.trace("Layer {"),n=e.next();!Uo(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=Xot(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&&(ae.trace("}"),t&&(i[t]=r),ae.trace("Layer {"),r={},t=void 0,n=e.next());break;default:Oh(n),n=e.next()}return ae.trace("}"),t&&(i[t]=r),i}},BLOCK_RECORD:{tableRecordsProperty:"blockRecords",tableName:"blockRecord",dxfSymbolName:"BLOCK_RECORD",parseTableRecords:function(){let t,i={},a={};for(ae.trace("BlockRecord {"),n=e.next();!Uo(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){ae.trace("}"),t&&(i[t]=a);let s=a.layoutHandle;t&&s&&s.length>0&&"0"!==s&&(r._layoutBlocks[s]=a),ae.trace("BlockRecord {"),a={},t=void 0,n=e.next()}else Oh(n),n=e.next();break;default:Oh(n),n=e.next()}ae.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(ae.trace("Style {"),n=e.next();!Uo(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&&(ae.trace("}"),t&&(i[t]=r),ae.trace("Style {"),r={},t=void 0,n=e.next())}return ae.trace("}"),t&&(i[t]=r),i}},DIMSTYLE:{tableRecordsProperty:"dimStyles",tableName:"dimStyle",dxfSymbolName:"DIMSTYLE",parseTableRecords:function(){let t,i={},r={};for(ae.trace("DimStyle {"),n=e.next();!Uo(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&&(ae.trace("}"),t&&(i[t]=r),ae.trace("DimStyle {"),r={},t=void 0,n=e.next())}return ae.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}{ae.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=yv)),n=e.lastReadGroup,ae.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}{ae.trace(n.value+" {");let r=i.parseObject(e,n),a=n.value;n=e.lastReadGroup,ae.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&&ae.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){ae.error("Unexpected code %s after 0:SECTION",Qhe(n)),n=e.next();continue}if("HEADER"===n.value)ae.trace("> HEADER"),t.header=a(),ae.trace("<");else if("TABLES"===n.value)ae.trace("> TABLES"),t.tables=l(),ae.trace("<");else if("BLOCKS"===n.value)ae.trace("> BLOCKS"),t.blocks=s(),ae.trace("<");else if("ENTITIES"===n.value)ae.trace("> ENTITIES"),t.entities=d(!1),ae.trace("<");else if("OBJECTS"===n.value)ae.trace("> OBJECTS"),t.objects=p(),ae.trace("<");else if("EOF"===n.value)ae.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))(fH||{}),Pa=1,hR=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 dt(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);!hR.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);!hR.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,ae.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),ae.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[Pa]=pi(Kn({id:Pa},t),{parentHandles:i})),Pa++}})),!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 dt(this,null,(function*(){var n,r;let a=wt.getUpdateProgressFuncForLoop(e.length,i);for(let i=0;i0&&(this.changes[Pa].detailChanges=l),Pa++}t.delete(s)}else this.changes[Pa]={id:Pa,type:"Removed",handle:s},Pa++;yield a(i)}for(let e of t){let t=e[0];this.changes[Pa]={id:Pa,type:"Added",handle:t},Pa++}}))}bIgnoreChildEntitiesOriginalType(e){var t;return $he.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!==yv&&e.lineType!==xv)return e.lineType;if(e.lineType===xv)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)?(ae.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 ae.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 Zb.forEach(((e,i)=>t[e]=i)),t})(),olt=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,js=String.fromCharCode.bind(String),xde="function"==typeof Uint8Array.from?Uint8Array.from.bind(Uint8Array):e=>new Uint8Array(Array.prototype.slice.call(e,0)),Tde=e=>e.replace(/=/g,"").replace(/[+\/]/g,(e=>"+"==e?"-":"_")),wde=e=>e.replace(/[^A-Za-z0-9\+\/]/g,""),Sde=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+=Zb[t>>18&63]+Zb[t>>12&63]+Zb[t>>6&63]+Zb[63&t]}return s?a.slice(0,s-3)+"===".substring(s):a},wH=slt?e=>btoa(e):Sv?e=>Buffer.from(e,"binary").toString("base64"):Sde,_H=Sv?e=>Buffer.from(e).toString("base64"):e=>{let t=[];for(let i=0,n=e.length;it?Tde(_H(e)):_H(e),llt=e=>{if(e.length<2)return(t=e.charCodeAt(0))<128?e:t<2048?js(192|t>>>6)+js(128|63&t):js(224|t>>>12&15)+js(128|t>>>6&63)+js(128|63&t);var t=65536+1024*(e.charCodeAt(0)-55296)+(e.charCodeAt(1)-56320);return js(240|t>>>18&7)+js(128|t>>>12&63)+js(128|t>>>6&63)+js(128|63&t)},clt=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,Mde=e=>e.replace(clt,llt),bde=Sv?e=>Buffer.from(e,"utf8").toString("base64"):yde?e=>_H(yde.encode(e)):e=>wH(Mde(e)),wv=(e,t=!1)=>t?Tde(bde(e)):bde(e),Ede=e=>wv(e,!0),ult=/[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g,hlt=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 js(55296+(t>>>10))+js(56320+(1023&t));case 3:return js((15&e.charCodeAt(0))<<12|(63&e.charCodeAt(1))<<6|63&e.charCodeAt(2));default:return js((31&e.charCodeAt(0))<<6|63&e.charCodeAt(1))}},Ade=e=>e.replace(ult,hlt),Rde=e=>{if(e=e.replace(/\s+/g,""),!olt.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?js(t>>16&255,t>>8&255):js(t>>16&255,t>>8&255,255&t);return r},SH=ilt?e=>atob(wde(e)):Sv?e=>Buffer.from(e,"base64").toString("binary"):Rde,Cde=Sv?e=>xde(Buffer.from(e,"base64")):e=>xde(SH(e).split("").map((e=>e.charCodeAt(0)))),Pde=e=>Cde(Ide(e)),dlt=Sv?e=>Buffer.from(e,"base64").toString("utf8"):vde?e=>vde.decode(Cde(e)):e=>Ade(SH(e)),Ide=e=>wde(e.replace(/[-_]/g,(e=>"-"==e?"+":"/"))),TH=e=>dlt(Ide(e)),flt=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)},Dde=e=>({value:e,enumerable:!1,writable:!0,configurable:!0}),Lde=function(){let e=(e,t)=>Object.defineProperty(String.prototype,e,Dde(t));e("fromBase64",(function(){return TH(this)})),e("toBase64",(function(e){return wv(this,e)})),e("toBase64URI",(function(){return wv(this,!0)})),e("toBase64URL",(function(){return wv(this,!0)})),e("toUint8Array",(function(){return Pde(this)}))},Ode=function(){let e=(e,t)=>Object.defineProperty(Uint8Array.prototype,e,Dde(t));e("toBase64",(function(e){return vR(this,e)})),e("toBase64URI",(function(){return vR(this,!0)})),e("toBase64URL",(function(){return vR(this,!0)}))},plt=()=>{Lde(),Ode()},kde={version:_de,VERSION:rlt,atob:SH,atobPolyfill:Rde,btoa:wH,btoaPolyfill:Sde,fromBase64:TH,toBase64:wv,encode:wv,encodeURI:Ede,encodeURL:Ede,utob:Mde,btou:Ade,decode:TH,isValid:flt,fromUint8Array:vR,toUint8Array:Pde,extendString:Lde,extendUint8Array:Ode,extendBuiltins:plt},Sl=$i(Qde(),1),hm=class extends kd{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"}},wu=class extends hr{constructor(e){super(e)}load(e,t,i,n){let r=this,a=new Hr(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,(function(e){let i=r.parse(JSON.parse(e));t&&t(i)}),i,n)}parse(e){return new Vo(e)}},Vo=class{constructor(e){this.isFont=!0,this.type="Font",this.data=e}generateShapes(e,t=100){let i=[],n=Slt(e,t,this.data);for(let r=0,a=n.length;r0){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=Oi(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=Gr.mergeLineGeometries(c,t,h.material instanceof uu||h.material instanceof an,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=Oi(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(),Jt.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)&&Gr.areGeometriesMergeable(l.geometry,h.geometry)&&ji.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=void 0,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;ae.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 kn&&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=Oi(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=Gr.mergeLineGeometries(o,r,s.material instanceof uu||s.material instanceof an,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=Oi(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(),Jt.releaseGeometryManually(e)})),o=[]}})),ae.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&&Nn.removeEmptyObjects(t),a}static applyMatrix(e,t,i){let n=t;for(yR.identity();n&&n!==i&&(yR.premultiply(n.matrix),n.parent);)n=n.parent;return yR.equals(Rlt)?e:e.applyMatrix4(yR)}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 efe(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 an({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})}gc.mergeInfo={removedObjects:0,mergedMeshes:0,mergedLines:0,mergedPoints:0,mergedUnknownTypeObjects:0,elapsedTime:0};var xR=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 an({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})}},CH={};k_(CH,{default:()=>RH});var AH={};k_(AH,{default:()=>MH});var MH=(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)))),RH=(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)=>Clt[t]||t));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=Dlt(e),t?Llt(e,t):e),Dlt=e=>e.replace(/\\[uU]\+([0-9a-fA-F]{4})/g,((e,t)=>String.fromCodePoint(parseInt(t,16)))),Llt=(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)]))))},ER=(e,t)=>{let i=0,n={text:""},r=[n],a=(e=Ilt(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=Plt[t];a?n.text+=a:3===t.length?n.text+=String.fromCodePoint(+t):"k"===t||"o"===t||"u"===t?(n=pi(Kn({},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))},PH=(e=>(e.Unitless="Unitless",e.Inches="Inches",e.Feet="Feet",e.Millimeters="Millimeters",e.Centimeters="Centimeters",e.Meters="Meters",e))(PH||{}),tfe=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),nfe=(e,t)=>tfe(e)/tfe(t),nE="0.2.55",rfe="VERSION",Olt=()=>window.localStorage.getItem(rfe),klt=()=>{window.localStorage.setItem(rfe,nE)},ife=()=>Olt()!==nE&&(klt(),!0),Mv=class{constructor(){this.DATABASE_NAME="gemini_viewer_db",this.TABLES=[{name:"viewpoint",options:{keyPath:"id",autoIncrement:!0},indexArray:[]},{name:"annotation",options:{keyPath:"id",autoIncrement:!0},indexArray:[]},{name:"dxfdata",options:{keyPath:"dxfDataId",autoIncrement:!1},indexArray:[]},{name:"fontdata",options:{keyPath:"url",autoIncrement:!0},indexArray:[]}],this.db=void 0}static instance(){return Mv._instance||(Mv._instance=new Mv),Mv._instance}getDatabase(){return dt(this,null,(function*(){let e=yield this.getDB(this.DATABASE_NAME);return this.db||(e.close(),ife()&&(yield this.deleteDataBase(this.DATABASE_NAME)),e=yield this.getUpgradedDB(e)),e.onclose=()=>{this.db=void 0,ae.debug(`[DB] Db ${e.name} is closed.`)},e.onerror=t=>{this.db=void 0,ae.debug(`[DB] Db ${e.name} encountered error.`,t)},e.onabort=t=>{this.db=void 0,ae.debug(`[DB] Db ${e.name} aborted.`,t)},e.onversionchange=e=>{ae.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=>{ae.debug(e),i(e)},n.onsuccess=i=>{let n=i.target;ae.debug(`[DB] Db ${e} delete old version ${i.oldVersion}.`),t(n)}}))}getDB(e){return dt(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;ae.debug(`[DB] Db ${i.name} opened (version ${i.version}).`),t(i)}}))}))}getUpgradedDB(e){return dt(this,null,(function*(){return new Promise(((t,i)=>{ae.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=>{ae.debug("onblocked",e)},n.onupgradeneeded=e=>{e.target.transaction.oncomplete=()=>{ae.debug(`[DB] Upgrade is done (new version: ${t.version}).`)};let t=e.target.result,i=[];for(let n=0;n0&&Promise.all(i).then((()=>{ae.debug(`[DB] All(${i.length}) tables created.`)}))},n.onsuccess=e=>{let i=e.target.result;ae.debug(`[DB] Db ${i.name} opened (version ${i.version}).`),t(i)}}))}))}createTable(e,t,i,n){return dt(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})})),ae.debug(`[DB] Table ${t} created.`),r(e)}))}))}},Xi=Mv;Xi._instance=void 0;var Su=class{constructor(){if(this.db=void 0,this.isCreatingTable=!1,-1===Xi.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();Xi.instance().getDatabase().then((r=>{let a=r.transaction([n],"readwrite").objectStore(n).add(e);a.onsuccess=t,a.onerror=i})).finally((()=>{Xi.instance().closeDatabase()})).catch((e=>{i&&i(e)}))}save(e,t,i){let n=this.tableName();Xi.instance().getDatabase().then((r=>{let a=r.transaction([n],"readwrite").objectStore(n).put(e);a.onsuccess=t,a.onerror=i})).finally((()=>{Xi.instance().closeDatabase()}))}delete(e,t,i){let n=this.tableName();Xi.instance().getDatabase().then((r=>{let a=r.transaction([n],"readwrite").objectStore(n).delete(e);a.onsuccess=t,a.onerror=i})).finally((()=>{Xi.instance().closeDatabase()}))}update(){Xi.instance().getDatabase().then((()=>{}))}query(e,t){let i=this.tableName();Xi.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((()=>{Xi.instance().closeDatabase()}))}queryByIndex(e,t,i,n){let r=this.tableName();Xi.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((()=>{Xi.instance().closeDatabase()}))}queryAll(e,t){let i=this.tableName();Xi.instance().getDatabase().then((n=>{let r=n.transaction([i],"readonly").objectStore(i).getAll();r.onsuccess=t=>{e&&e(r.result)},r.onerror=t})).finally((()=>{Xi.instance().closeDatabase()}))}clearAll(e,t){let i=this.tableName();Xi.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((()=>{Xi.instance().closeDatabase()}))}},Av=class extends Su{tableName(){return"annotation"}static instance(){return Av._instance||(Av._instance=new Av),Av._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)}))}},IH=Av;IH._instance=void 0;var Rv=class extends Su{tableName(){return"viewpoint"}static instance(){return Rv._instance||(Rv._instance=new Rv),Rv._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)}))}},DH=Rv;DH._instance=void 0;var Cv=class extends Su{tableName(){return"dxfdata"}static instance(){return Cv._instance||(Cv._instance=new Cv),Cv._instance}query(e,t,i){let n=[],r=this.tableName();Xi.instance().getDatabase().then((a=>{let s=a.transaction([r],"readonly").objectStore(r).get(e);s.onerror=e=>{i&&i(e),ae.info("[DxfDataTable] Failed to query !",e)},s.onsuccess=()=>{s.result&&n.push(s.result),t&&t(n)}})).finally((()=>{Xi.instance().closeDatabase()}))}},Pv=Cv;Pv._instance=void 0;var dm=class extends Su{tableName(){return"fontdata"}static instance(){return dm._instance||(dm._instance=new dm),dm._instance}query(e,t,i){let n;super.query((i=>{i?!i.value||i.value.url!==e||(n=i.value):t&&t(n)}),(e=>{i&&i(),console.log(e)}))}queryAll(){return dt(this,null,(function*(){return new Promise(((e,t)=>{hz(dm.prototype,this,"queryAll").call(this,(t=>{e(t)}),(e=>{t(e)}))}))}))}},Mu=dm;Mu._instance=void 0;var sfe=(e=>(e[e.Horizontal=0]="Horizontal",e[e.Vertical=1]="Vertical",e[e.All=2]="All",e))(sfe||{}),fm=(e=>(e[e.Shapes=0]="Shapes",e[e.Bigfont=1]="Bigfont",e[e.Unifont=2]="Unifont",e))(fm||{}),LH=12,Nlt=!1,Flt=new ye,kh=class extends ps{constructor(e,t){super(),this.width=0,this.bounds=new Gi,this.lastPoint=e,this.polylines=t,this.width=this.calcWidth(t)}offset(e){let t=[];for(let i=0;i0){let t=this.bounds.min,i=this.bounds.getSize(Flt),n=new ye(t.x,t.y),r=new ye(t.x+i.width,t.y),a=new ye(t.x+i.width,t.y+i.height),s=new ye(t.x,t.y+i.height);e.push([n,r],[r,a],[a,s],[s,n])}let t=[],i=[],n=0,r=new Lt;for(let a=0;a>8}}return t.subarray(0,i)}var Hlt="\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",ofe="\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 lfe(e){return Hlt.charAt(ofe.indexOf(e.charAt(0)))}var cBt=new RegExp("[\u4e00-\u9fa5]+");function cfe(e){return ofe.includes(e)}var Tr=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.type){case 0:l++,o=t[l];break;case 1:l++,o=t[l],0==o&&(l++,o=Tr.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=Tr.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 ye;e.x=Tr.byteTosbyte(t[++l]),e.y=Tr.byteTosbyte(t[++l]),n.add(e.multiplyScalar(i)),o&&a.push(n.clone())}break;case 9:for(;;){let e=new ye;if(e.x=Tr.byteTosbyte(t[++l]),e.y=Tr.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=Tr.byteTosbyte(t[++l]),s=(112&r)>>4,h=7&r;0==h&&(h=8);let c=Math.PI/4,u=c*h,d=nf.CIRCLE_SPAN;r<0&&(d=-d,u=-u);let p=c*s,f=p+u,m=n.clone().sub(new ye(Math.cos(p)*e,Math.sin(p)*e));if(n=m.clone().add(new ye(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 ye(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=Tr.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=nf.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 ye(s*Math.cos(g),s*Math.sin(g)));if(n=y.clone().add(new ye(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 ye(s*Math.cos(e),s*Math.sin(e))));a.push(n.clone())}}break;case 12:{let e=new ye;e.x=Tr.byteTosbyte(t[++l])*i,e.y=Tr.byteTosbyte(t[++l])*i;let r=Tr.byteTosbyte(t[++l]);r<-127&&(r=-127),o&&(0==r?a.push(n.clone().add(e)):a.push(nf.generateArcPoints(n,e,r/127))),n.add(e)}break;case 13:for(;;){let e=new ye;if(e.x=Tr.byteTosbyte(t[++l])*i,e.y=Tr.byteTosbyte(t[++l])*i,0==e.x&&0==e.y)break;let r=Tr.byteTosbyte(t[++l]);r<-127&&(r=-127),o&&(0==r?a.push(n.clone().add(e)):a.push(nf.generateArcPoints(n.clone(),e,r/127))),n.add(e)}break;case 14:l=nf.skipCode(e,t,++l);break;default:if(h>15){let e=(240&h)>>4,t=15&h,r=new ye;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 kh(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.type){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 ye(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=nf.CIRCLE_SPAN;r?(m=-m,pf&&(p-=2*Math.PI);let g=p;for(;;){if(g+=m,!r&&gf)return c.add(new ye(h*Math.cos(g),h*Math.sin(g)));break}return n}},vc=nf;vc.FILE_STOP_FLAG=["\r","\n","\x1a"],vc.CIRCLE_SPAN=Math.PI/18;var TR={130:[[[5,0],[5,9.5]],[[4,7.1],[2.6,6.6],[2.1,6.2],[1.7,5.4],[1.6,4],[2.1,3],[2.6,2.6],[3.9,2.2],[6.1,2.2],[7.5,2.6],[8,3.1],[8.4,3.9],[8.4,5.2],[7.9,6.1],[7.5,6.6],[6.1,7.1],[4,7.1]]],131:[[[3,0],[7,0]],[[5,0],[5,9.5]],[[4,7.1],[2.6,6.6],[2.1,6.2],[1.7,5.4],[1.6,4],[2.1,3],[2.6,2.6],[3.9,2.2],[6.1,2.2],[7.5,2.6],[8,3.1],[8.4,3.9],[8.4,5.2],[7.9,6.1],[7.5,6.6],[6.1,7.1],[4,7.1]]],132:[[[3,0],[7,0]],[[4,0],[4,9.5]],[[6,0],[6,9.5]],[[4,7.1],[2.6,6.6],[2.1,6.2],[1.7,5.4],[1.6,4],[2.1,3],[2.6,2.6],[3.9,2.2],[6.1,2.2],[7.5,2.6],[8,3.1],[8.4,3.9],[8.4,5.2],[7.9,6.1],[7.5,6.6],[6.1,7.1],[4,7.1]]],133:[[[3,0],[7,0]],[[4,0],[4,9.5]],[[6,0],[6,9.5]],[[4,7.1],[2.6,6.6],[2.1,6.2],[1.7,5.4],[1.6,4],[2.1,3],[2.6,2.6],[3.9,2.2],[6.1,2.2],[7.5,2.6],[8,3.1],[8.4,3.9],[8.4,5.2],[7.9,6.1],[7.5,6.6],[6.1,7.1],[4,7.1]],[[3,9.5],[7,9.5]]],134:[[[3,0],[7,0]],[[5,0],[5,9.5]],[[4,7.1],[2.6,6.6],[2.1,6.2],[1.7,5.4],[1.6,4],[2.1,3],[2.6,2.6],[3.9,2.2],[6.1,2.2],[7.5,2.6],[8,3.1],[8.4,3.9],[8.4,5.2],[7.9,6.1],[7.5,6.6],[6.1,7.1],[4,7.1]],[[12,10],[9,10],[9,6]],[[9,8],[11,8]]],135:[[[3,0],[7,0]],[[4,0],[4,9.5]],[[6,0],[6,9.5]],[[4,7.1],[2.6,6.6],[2.1,6.2],[1.7,5.4],[1.6,4],[2.1,3],[2.6,2.6],[3.9,2.2],[6.1,2.2],[7.5,2.6],[8,3.1],[8.4,3.9],[8.4,5.2],[7.9,6.1],[7.5,6.6],[6.1,7.1],[4,7.1]],[[12,10],[9,10],[9,6]],[[9,8],[11,8]]],136:[[[3,0],[7,0]],[[4,0],[4,9.5]],[[6,0],[6,9.5]],[[4,7.1],[2.6,6.6],[2.1,6.2],[1.7,5.4],[1.6,4],[2.1,3],[2.6,2.6],[3.9,2.2],[6.1,2.2],[7.5,2.6],[8,3.1],[8.4,3.9],[8.4,5.2],[7.9,6.1],[7.5,6.6],[6.1,7.1],[4,7.1]],[[3,9.5],[7,9.5]],[[12,10],[9,10],[9,6]],[[9,8],[11,8]]],178:[[[1.142,9.285],[1.142,9.428],[1.285,9.714],[1.428,9.857],[1.714,10],[2.285,10],[2.571,9.857],[2.714,9.714],[2.857,9.428],[2.857,9.142],[2.714,8.857],[2.428,8.428],[1,7],[3,7]]],8960:[[[2.9,8],[1.7,7.4],[.6,6.3],[0,4.6],[0,3.4],[.6,1.7],[1.7,.6],[2.9,0],[4.6,0],[5.7,.6],[6.9,1.7],[7.4,3.4],[7.4,4.6],[6.9,6.3],[5.7,7.4],[4.6,8],[2.9,8]],[[0,0],[8,8]]],20393:[[[0,0],[0,6.666]],[[0,4.761],[1.428,6.19],[2.38,6.666],[3.809,6.666],[4.761,6.19],[5.238,4.761],[5.238,0]],[[5.238,4.761],[6.666,6.19],[7.619,6.666],[9.047,6.666],[10,6.19],[10.476,4.761],[10.476,0]],[[11.142,9.285],[11.142,9.428],[11.285,9.714],[11.428,9.857],[11.714,10],[12.285,10],[12.571,9.857],[12.714,9.714],[12.857,9.428],[12.857,9.142],[12.714,8.857],[12.428,8.428],[11,7],[13,7]]],41123:[],55714:[[[2,5.9],[2.6,6.1],[3.4,7],[3.4,1]],[[2.9,8],[1.7,7.4],[.6,6.3],[0,4.6],[0,3.4],[.6,1.7],[1.7,.6],[2.9,0],[4.6,0],[5.7,.6],[6.9,1.7],[7.4,3.4],[7.4,4.6],[6.9,6.3],[5.7,7.4],[4.6,8],[2.9,8]]],55970:[[[2.3,5.6],[2.3,5.9],[2.6,6.4],[2.9,6.7],[3.4,7],[4.6,7],[5.1,6.7],[5.4,6.4],[5.7,5.9],[5.7,5.3],[5.4,4.7],[4.9,3.9],[2,1],[6,1]],[[2.9,8],[1.7,7.4],[.6,6.3],[0,4.6],[0,3.4],[.6,1.7],[1.7,.6],[2.9,0],[4.6,0],[5.7,.6],[6.9,1.7],[7.4,3.4],[7.4,4.6],[6.9,6.3],[5.7,7.4],[4.6,8],[2.9,8]]],56226:[[[2.6,7],[5.7,7],[4,4.7],[4.9,4.7],[5.4,4.4],[5.7,4.1],[6,3.3],[6,2.7],[5.7,1.9],[5.1,1.3],[4.3,1],[3.4,1],[2.6,1.3],[2.3,1.6],[2,2.1]],[[2.9,8],[1.7,7.4],[.6,6.3],[0,4.6],[0,3.4],[.6,1.7],[1.7,.6],[2.9,0],[4.6,0],[5.7,.6],[6.9,1.7],[7.4,3.4],[7.4,4.6],[6.9,6.3],[5.7,7.4],[4.6,8],[2.9,8]]],56482:[[[4.9,7],[2,3],[6.3,3]],[[4.9,7],[4.9,1]],[[2.9,8],[1.7,7.4],[.6,6.3],[0,4.6],[0,3.4],[.6,1.7],[1.7,.6],[2.9,0],[4.6,0],[5.7,.6],[6.9,1.7],[7.4,3.4],[7.4,4.6],[6.9,6.3],[5.7,7.4],[4.6,8],[2.9,8]]],56738:[[[5.4,7],[2.6,7],[2.3,4.4],[2.6,4.7],[3.4,5],[4.3,5],[5.1,4.7],[5.7,4.1],[6,3.3],[6,2.7],[5.7,1.9],[5.1,1.3],[4.3,1],[3.4,1],[2.6,1.3],[2.3,1.6],[2,2.1]],[[2.9,8],[1.7,7.4],[.6,6.3],[0,4.6],[0,3.4],[.6,1.7],[1.7,.6],[2.9,0],[4.6,0],[5.7,.6],[6.9,1.7],[7.4,3.4],[7.4,4.6],[6.9,6.3],[5.7,7.4],[4.6,8],[2.9,8]]],56994:[[[5.4,6.1],[5.1,6.7],[4.3,7],[3.7,7],[2.9,6.7],[2.3,5.9],[2,4.4],[2,3],[2.3,1.9],[2.9,1.3],[3.7,1],[4,1],[4.9,1.3],[5.4,1.9],[5.7,2.7],[5.7,3],[5.4,3.9],[4.9,4.4],[4,4.7],[3.7,4.7],[2.9,4.4],[2.3,3.9],[2,3]],[[2.9,8],[1.7,7.4],[.6,6.3],[0,4.6],[0,3.4],[.6,1.7],[1.7,.6],[2.9,0],[4.6,0],[5.7,.6],[6.9,1.7],[7.4,3.4],[7.4,4.6],[6.9,6.3],[5.7,7.4],[4.6,8],[2.9,8]]],57250:[[[2,7],[6,7],[3.1,1]],[[2.9,8],[1.7,7.4],[.6,6.3],[0,4.6],[0,3.4],[.6,1.7],[1.7,.6],[2.9,0],[4.6,0],[5.7,.6],[6.9,1.7],[7.4,3.4],[7.4,4.6],[6.9,6.3],[5.7,7.4],[4.6,8],[2.9,8]]],57506:[[[3.4,7],[2.6,6.7],[2.3,6.1],[2.3,5.6],[2.6,5],[3.1,4.7],[4.3,4.4],[5.1,4.1],[5.7,3.6],[6,3],[6,2.1],[5.7,1.6],[5.4,1.3],[4.6,1],[3.4,1],[2.6,1.3],[2.3,1.6],[2,2.1],[2,3],[2.3,3.6],[2.9,4.1],[3.7,4.4],[4.9,4.7],[5.4,5],[5.7,5.6],[5.7,6.1],[5.4,6.7],[4.6,7],[3.4,7]],[[2.9,8],[1.7,7.4],[.6,6.3],[0,4.6],[0,3.4],[.6,1.7],[1.7,.6],[2.9,0],[4.6,0],[5.7,.6],[6.9,1.7],[7.4,3.4],[7.4,4.6],[6.9,6.3],[5.7,7.4],[4.6,8],[2.9,8]]],57762:[[[5.7,5],[5.4,4.1],[4.9,3.6],[4,3.3],[3.7,3.3],[2.9,3.6],[2.3,4.1],[2,5],[2,5.3],[2.3,6.1],[2.9,6.7],[3.7,7],[4,7],[4.9,6.7],[5.4,6.1],[5.7,5],[5.7,3.6],[5.4,2.1],[4.9,1.3],[4,1],[3.4,1],[2.6,1.3],[2.3,1.9]],[[2.9,8],[1.7,7.4],[.6,6.3],[0,4.6],[0,3.4],[.6,1.7],[1.7,.6],[2.9,0],[4.6,0],[5.7,.6],[6.9,1.7],[7.4,3.4],[7.4,4.6],[6.9,6.3],[5.7,7.4],[4.6,8],[2.9,8]]],60070:[[[0,6],[10,6],[10,4]]],60326:[[[0,7],[0,5],[10,5]]]},ufe=new An,rf=class{constructor(e){this.type=1,this.info="",this.orientation=0,this.baseUp=0,this.baseDown=0,this.fileHeader="",this.fileVersion="",this.codes={},this.graphicData=new Map,this.url=e,this.fileName=this.getFileNameByPath(e)}getGraphicDataByCode(e,t){var i;if(0===e)return;let n,r=this.codes;if(!this.graphicData.has(e))if(r[e]){let t=r[e],i=LH/this.baseUp;n=vc.parserCode(this,t,i),this.graphicData.set(e,n)}else if(TR[e]){let t=[];for(let i=0;inew ye(e[0],e[1]))));n=new kh(new ye,t),this.graphicData.set(e,n)}if(this.graphicData.has(e)){let r=t/LH;ufe.identity().scale(r,r),n=null==(i=this.graphicData.get(e))?void 0:i.transform(ufe)}return n}getGraphicDataByCodeWithOffset(e,t,i){var n;return null==(n=this.getGraphicDataByCode(e,t))?void 0:n.offset(i)}getFontFile(){return{url:this.url,type:this.type,codes:this.codes,info:this.info,orientation:this.orientation,baseUp:this.baseUp,baseDown:this.baseDown,fileName:this.fileName,fileHeader:this.fileHeader,fileVersion:this.fileVersion}}setFontFile(e){this.url=e.url,this.fileName=e.fileName,this.type=e.type,this.codes=e.codes,this.info=e.info,this.orientation=e.orientation,this.baseUp=e.baseUp,this.baseDown=e.baseDown,this.fileHeader=e.fileHeader,this.fileVersion=e.fileVersion}releaseFontData(){this.codes={},this.graphicData.clear()}getFileNameByPath(e){let t=e.lastIndexOf("/");return e.substring(t+1)}setFontDataToIndexedDb(){return dt(this,null,(function*(){let e=this.getFontFile();return new Promise(((t,i)=>{Mu.instance().save(e,(()=>{console.log(`[FontFile] Saved '${this.url}' (${this.fileHeader}) to indexedDb`),t()}),(e=>i(`[FontFile] Failed to save '${this.url}' (${this.fileHeader}) to indexedDb! ${e}`)))}))}))}getFontDataByIndexedDb(){return dt(this,null,(function*(){return new Promise(((e,t)=>{Mu.instance().query(this.url,(t=>{e(t)}),(()=>t("[FontFile] Failed to get FontData from IndexedDB")))}))}))}},rE=class extends rf{constructor(e){super(e),this.isExtend=!1,this.type=1}init(e){Tr.ToInt16(e.readBytes(2),0);let t=Tr.ToInt16(e.readBytes(2),0),i=Tr.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}var iE=class extends rf{constructor(e){super(e),this.type=0}init(e){e.readBytes(2),e.readBytes(2);let t=Tr.ToInt16(e.readBytes(2),0),i=[];for(let s=0;sa){u?(c+=t+r,u=!1):(u=!0,c=0,h-=n+i),wR.set(c,h);let e=d.offset(wR);o.push(e),!u&&(c+=d.width+r)}else{wR.set(c,h);let e=d.offset(wR);o.push(e),c+=d.width+r}else this.addUnsupportedChar(l)}u=!1,c=0,h-=n+i}return o}getNotFoundTextShape(e){let t=vc.getCode("\uff1f");return this.getGraphicDataByCode(t,e)}addUnsupportedChar(e){this.unsupportedChars[e]||(this.unsupportedChars[e]=0),this.unsupportedChars[e]++}static checkFontsAreLoaded(e){return dt(this,null,(function*(){if(!Tn.isBrowser)return!1;let t=!1,i=yield Mu.instance().queryAll();if(i.length!==e.length)return!1;for(let n=0;ne.setFontDataToIndexedDb()));return yield Promise.all(e).then((()=>{ae.debug("[ShxFont] Saves font data to IndexDB")}))}))}getFontData(){return dt(this,null,(function*(){if(Tn.isBrowser){let e=yield Mu.instance().queryAll(),t=[],i=new Map;for(let n=0;n{let i=this.parse(e);t&&t(i)})).catch((e=>{n&&n(e)}))}loadFile(e,t){return dt(this,null,(function*(){return new Promise(((i,n)=>{let r=new Hr(this.manager);r.setResponseType("arraybuffer"),r.load(e,(t=>{i({url:e,arrayBuffer:t})}),t,(e=>{n(e)}))}))}))}loadAsync(e,t){return dt(this,null,(function*(){return Array.isArray(e)||(e=[e]),(yield Ni.checkFontsAreLoaded(e))?Promise.resolve(new Ni):new Promise(((i,n)=>{this.load(e,i,t,n)}))}))}parse(e){return new Ni(e)}static isShxFile(e){var t;return"shx"===(null==(t=e.split(".").pop())?void 0:t.toLowerCase())}},yc=new L(1,0,0),kH=new L(0,1,0),Au=new L(0,0,1),hfe=new L(0,0,0),af=16777215,Vlt="CONTINUOUS",SR=new hi({color:af}),Ws=new kn({color:af}),pm=new rn({color:af}),dfe=(new Lt).setFromPoints([new L]),ffe=new Qe,pfe=new Qe,ao=new Qe,$n=new L,Pi=new L,Iv=new L,aE=new ye,ks=new ir,mfe=new ir,MR=new sn,sf=new It,gfe=new hi({color:65280,size:5,depthTest:!1}),vfe=new hi({color:65280,depthTest:!1}),yfe=new hi({color:65280,depthTest:!1}),zlt=e=>void 0!==e.viewDirectionFromTarget,Glt=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 kde.decode(e)}}}return null},xfe=(e,t)=>{let i=new ye(e.x,e.y),n=new ye(t.x,t.y);return n.sub(i),n.normalize(),n.y<0?-Math.acos(n.x):Math.acos(n.x)},bfe=(e,t,i)=>({x:e.x+t*Math.cos(i),y:e.y+t*Math.sin(i)}),qlt=(e,t,i,n)=>{let r=e?new ye(e.x,e.y):new ye(0,0),a=t?new ye(t.x,t.y):new ye(1,0);i=i||1;let s=4*Math.atan(i),o=r.distanceTo(a)/2/Math.sin(s/2),l=bfe(e,o,xfe(r,a)+(Math.PI/2-s/2));n=n||Math.max(Math.abs(Math.ceil(s/(Math.PI/18))),6);let h=xfe(l,r),c=s/n,u=[];u.push(new L(r.x,r.y,0));for(let d=1;d<=n-1;d++){let e=bfe(l,Math.abs(o),h+c*d);u.push(new L(e.x,e.y,0))}return u},jlt=(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=RH(o,t,s,i,r);a.push(new L(e[0],e[1],0))}return a},NH=(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},Xlt=e=>{let t=[],i=[];e.forEach((e=>{e.polyfaceMeshVertex&&(e.threeDPolylineMesh?t.push(new L(e.x,e.y,e.z)):i.push(Wlt(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},qn=class extends hr{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)}},qn.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=wn.rgb2Hex(t.overrideColor))),this.pointsMaterials[af]=SR,this.lineBasicMaterials[af]=Ws,this.meshBasicMaterials[af]=pm}setFont(e){this.font=e}download(e,t){return dt(this,null,(function*(){let i=Glt(e);if(!i){let n=Date.now(),r=new Hr(this.manager);r.setResponseType("arraybuffer"),r.setPath(this.path),i=yield r.loadAsync(e,t),ae.info(`[DxfLoader] ${e} dxf file downloaded in ${(Date.now()-n)/1e3}s`)}return i}))}load(e,t,i){return dt(this,null,(function*(){return this.enableLocalCache&&t&&(t=t.trim()).length>0&&(this.dxfDataId=t),this.loadAsync(e,i)}))}loadAsync(e,t){return dt(this,null,(function*(){let i=wt.getUpdateSubProgressFunc(0,50,t),n=wt.getUpdateSubProgressFunc(50,100,t),r=wt.getUpdateSubProgressFunc(10,100,t);if(Tn.isBrowser&&this.enableLocalCache&&this.dxfDataId){let t;try{if(this.timer=Date.now(),t=yield this.getDxfDataFromIndexedDb(this.dxfDataId),t){this.tryFixDxfData(t),ae.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){ae.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 dt(this,null,(function*(){let i=wt.getUpdateProgressFunc(t),n=wt.getUpdateSubProgressFunc(0,40,t),r=yield this.download(e,n);if(!r)return Promise.reject(`[DxfLoader] Failed to download ${e}`);if(qn.abortJobs)return Promise.reject("[DxfLoader] Job aborted");this.timer=Date.now(),ae.info("[DxfLoader] Start parsing...");let a=new um(this.encoding).parseSync(r);if(this.tryFixDxfData(a),i(80),ae.info(`[DxfLoader] Parsed in ${(Date.now()-this.timer)/1e3}s, creating entities...`),qn.abortJobs)return Promise.reject("[DxfLoader] Job aborted");if(a&&Tn.isBrowser&&this.enableLocalCache&&this.dxfDataId){let t=Date.now();try{yield this.setDxfDataToIndexedDb(this.dxfDataId,a),ae.info(`[DxfLoader] Saved to indexedDb in ${(Date.now()-t)/1e3}s`)}catch(e){ae.warn(`[DxfLoader] Failed to save '${this.dxfDataId}' to indexedDb!`,e)}}return i(100),a}))}parseHeader(e){if(!e)return void ae.error("[DxfLoader]: Invalid header!");this.header=e;let t=e.$ACADVER.toString();"AC1032"!==t&&ae.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||(ae.warn("[DxfLoader] No objects found, Will add one."),e.objects={}),e.objects.LAYOUT||(ae.warn("[DxfLoader] No layout defined! Will add a default 'Model' layout!"),e.objects.LAYOUT=[{layoutName:qn.MODEL_LAYOUT_NAME}]),e.tables||(ae.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 dt(this,null,(function*(){let i=Date.now();this.parseHeader(e.header),this.enableRenderOrder&&(this.initRenderOrderInfo(e),this.enableMerge=!1);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=wt.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){gc.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!==qn.MODEL_LAYOUT_NAME)return;let r=i.associatedBlockName,a=e.blocks[r];a&&this.drawLayout(a,e,i,c,s,l)})),ae.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=qn.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(Nn.setSharedVariablesOfObject(t),!t.userData.isLayoutLevelObject)return;let i,n=t.name;if(n!==qn.MODEL_LAYOUT_NAME){let e=d[n];e.directAssociatedLeafObjectSet||(e.directAssociatedLeafObjectSet=new Set),i=e.directAssociatedLeafObjectSet}t.traverse((t=>{if(Nn.setSharedVariablesOfObject(t),t.userData.isSnapGroup&&(t.visible=qn.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)}}))})),ae.info(`[DxfLoader] loadEntities() done in ${(Date.now()-i)/1e3}s`);let f=pi(Kn({},e),{threejsObject:u,layersAndThreejsObjects:p,loadedEntityCount:n,layoutViewportsMap:l});return Promise.resolve(f)}))}loadEntitiesForCompare(e,t,i,n=!0,r){return dt(this,null,(function*(){let a=e.entities.length,s=t.entities.length,o=()=>dt(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=>dt(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 wt.sleep(0),m=n)}}));this.parseHeader(c.header);let v={};for(let e=0;ee.name===qn.MODEL_LAYOUT_NAME));r||(r=new bn,r.name=qn.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=ao.identity();for(;e&&!0!==e.userData.isLayoutLevelObject;)i.premultiply(e.matrix),e=e.parent;sf.makeEmpty();let r=bn.getBox(n,sf);r.applyMatrix4(i),"Added"===t.type?!h&&(t.box=(new It).copy(r)):"Removed"===t.type?h&&(t.box=(new It).copy(r)):"Modified"===t.type&&(t.box?t.box.union(r):t.box=(new It).copy(r))}}for(let e in this.layoutsSnapObjectsMap){let t=u.children.find((t=>t.name===e)),i=new bn;i.name=qn.SNAP_GROUP_NAME,t.add(i);let n=this.layoutsSnapObjectsMap[e];for(let e=0;e{Nn.setSharedVariablesOfObject(e),e.userData.isLayoutLevelObject&&e.traverse((e=>{if(Nn.setSharedVariablesOfObject(e),e.userData.isSnapGroup&&(e.visible=qn.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},wt.printMemory("Before loading entities for first dxf"),yield o(),ae.info(`[DxfLoader] loadEntities for first dxf in ${(Date.now()-l)/1e3}s`),wt.printMemory("After loading entities for first dxf"),this.releaseCachedData(!1),this.releaseDxfData(e),wt.printMemory("Before loading entities for second dxf"),l=Date.now(),this.compareContext.isTheFirstFile=!1,yield o(),ae.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)),wt.printMemory("After loading entities for second dxf")}))}setObjectColorByChange(e,t){let i=(e,t)=>{e.traverse((e=>{if(e.material)if(e.material instanceof kn)e.material=this.getLineBasicMaterial(t);else if(e.material instanceof rn)e.material=this.getMeshBasicMaterial(t);else if(e.material instanceof hi)e.material=this.getPointsMaterial(t);else if(e.material instanceof an){let i=e.material.clone();qn.updateMaterialUniforms(i),i.uniforms.u_color.value.set(t),e.material=i}}))},n=(e=>{var t;let i=ns.ENTITY_COLOR_NO_CHANGE;return"Added"===e.type?i=ns.ENTITY_COLOR_ADDED:"Removed"===e.type?i=ns.ENTITY_COLOR_REMOVED:"Modified"===e.type&&(i=null!=(t=this.compareContext)&&t.isTheFirstFile?ns.ENTITY_COLOR_REMOVED:ns.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)&&om.includes(e.type)&&(n=!0),!n&&this.compareContext&&this.compareContext.preservedHandles&&!om.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 om.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,om.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),$t.areNumbersEqual(n,r,1e-5))return void ae.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=$t.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 Rh(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()})),e.rotation&&ks.setFromAxisAngle(Au,e.rotation*Math.PI/180),e.directionVector){let t=e.directionVector,i=new L(t.x,t.y,t.z),n=i.clone().cross(yc),r=yc.angleTo(i);ks.multiply(mfe.setFromAxisAngle(Au,n.z>0?-r:r))}return Jt.shouldRebasePositionOnRTC(Pi)&&this.setRTCUserData(s),s.matrix.compose(Pi,ks,Iv),s}getMTextGroup(e,t,i,n,r=0,a=0,s=[]){if(0===e.length)return;let o=t.height||t.contextData&&t.contextData.textHeight||0;if(t.textStyle){let e=this.getTextStyle(i,t);if(e&&e.fontFile&&e.fontFile.endsWith(".shx")){let t=`${e.fontFile}_${e.styleName}`;this.statsInfo.unsupportedTextStyles[t]||(this.statsInfo.unsupportedTextStyles[t]=0),this.statsInfo.unsupportedTextStyles[t]++}o=o||e.textHeight}let l=t.lineSpaceFactor||1,h="Left";t.width&&t.attachmentPoint&&([1,4,7].includes(t.attachmentPoint)?h="Left":[2,5,8].includes(t.attachmentPoint)?h="Center":[3,6,9].includes(t.attachmentPoint)&&(h="Right"));let c,u,d=t.width||0,p=new bn,f=1,m=1,g=256,v=l*o*.3,y=v+o;for(let x=0;x{let t=Oi(e);t.boundingBox||t.computeBoundingBox();let i=t.boundingBox.getSize($n);switch(h){case"Left":default:break;case"Center":t.translate((d-i.x)/2,0,0);break;case"Right":t.translate(d-i.x,0,0)}_.push(t)};for(let t=0;t(d||1/0))r=0,a-=y,s.length>0&&w(s),s=[];else{e.boundingBox||e.computeBoundingBox();let t=e.boundingBox.getSize($n).x;" "===i&&(t=o/2),r+=t+m*(o/6),s.push(e)}else r+=o+m*(o/6)}else r=0,a-=y,s.length>0&&w(s),s=[]}if(s.length>0&&(w(s),s=[]),_.length>0){let e=Oi(_);this.font instanceof Ni?(x=new bn(3),x.geometry=e,x.material=Ws):this.font instanceof Vo&&(x=new bn(4),x.geometry=e,x.material=pm)}if(!x)continue;c||(c=t.colorIndex),void 0!==g&&256!==g?(t.color=lm(g),t.colorIndex=g):t.colorIndex=c;let S=this.getColor(t,i,n);x.material instanceof rn?x.material=this.getMeshBasicMaterial(S):x.material instanceof kn&&(x.material=this.getLineBasicMaterial(S)),x.matrix.makeTranslation(0,-o,0),p.add(x),u=void 0,f=1,m=1,g=256,l=t.lineSpaceFactor||1}else if(Array.isArray(b)){let e=this.getMTextGroup(b,t,i,n,r,a,s);e&&(p.add(e.object),r+=e.hOffset,a+=e.vOffset)}else"object"==typeof b&&(b.f&&(u=b.f,u&&u.includes(".shx")&&ae.info(`[DxfLoader] Doesn't support custom fonts: ${u}`)),b.C&&(g=b.C),b.W&&(f="x"===b.W[1]?b.W[0]*t.width:b.W[0]),b.H&&(o="x"===b.H[1]?b.H[0]*t.height:b.H[0]),b.T&&(m=b.T))}return 0!==p.children.length?(gc.merge(p,!1),c&&(t.colorIndex=c),1===p.children.length?{object:p.children[0],hOffset:r,vOffset:a}:{object:p,hOffset:r,vOffset:a}):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 ae.warn("[DxfLoader] Entity is missing vertices:",e.handle);let t=e.vertices.map((e=>new L(e.x,e.y,e.z)));if(0===t.length)return;$t.areVector3sEqual(t[0],t[t.length-1])||t.push(t[0]);let i=new L,n=!1;this.enableRTC&&(n=Jt.checkAndRebasePositionsOnRTC(t,i));let r=(new Lt).setFromPoints(t),a=new bn(2);return a.geometry=r,a.material=Ws,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=jlt(e.controlPoints,e.degreeOfSplineCurve,e.knotValues,h),u=new L,d=!1;this.enableRTC&&(d=Jt.checkAndRebasePositionsOnRTC(c,u));let p=Jt.getAdjacentNonRepeatPoints(c);if(p.length<2)return void ae.warn("[DxfLoader] Spline entity (handle '%s') contains less than 2 points, ignored!",e.handle);let f=(new Lt).setFromPoints(p),m=new bn(2);return m.geometry=f,m.material=Ws,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 ae.warn("[DxfLoader] Entity is missing vertices:",e.handle);let t=wt.arrayOrObjectToVector3(e.directionVector),i=new L(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 L,a=!1;this.enableRTC&&(a=Jt.checkAndRebasePositionsOnRTC(n,r));let s=(new Lt).setFromPoints(n),o=new bn(2);return o.geometry=s,o.material=Ws,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 ae.warn("[DxfLoader] Entity is missing vertices:",e.handle);let t=wt.arrayOrObjectToVector3(e.directionVector),i=e.vertices.map((e=>new L(e.x,e.y,0)));if(i.push(t.multiplyScalar(1e6).add(i[0])),0===i.length)return;let n=new L,r=!1;this.enableRTC&&(r=Jt.checkAndRebasePositionsOnRTC(i,n));let a=(new Lt).setFromPoints(i),s=new bn(2);return s.geometry=a,s.material=Ws,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 ae.warn("[DxfLoader] Entity is missing vertices:",e.handle);let t=[];if(e.isPolyfaceMesh)t=Xlt(e.vertices);else{let i=NH(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=Jt.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 Lt).setFromPoints(e);c.setIndex(i),n=new bn(3),n.geometry=c,n.material=Ws}if(i.length>0){this.enableRTC&&(a=Jt.checkAndRebasePositionsOnRTC(i,r));let e=(new Lt).setFromPoints(i);n=new bn(1),n.geometry=e,n.material=SR}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 ae.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){$n.set(s.extrusionDirectionX,s.extrusionDirectionY,s.extrusionDirectionZ);let e=qn.getOcsMatrix($n).invert(),t=0;void 0!==s.elevation&&s.elevation>0&&(t=s.elevation),s.vertices.forEach((i=>{let n=$n.set(i.x,i.y,t).applyMatrix4(e);i.x=n.x,i.y=n.y}))}let o=NH(e.vertices,e.shape);if(e.shape&&o.length>0&&!$t.areVector3sEqual(o[0],o[o.length-1])&&o.push(o[0]),o.length<2)return void ae.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 ps;e.forEach(((e,i)=>{0===i?t.moveTo(e[0],e[1]):t.lineTo(e[0],e[1])})),t.closePath(),i.push(new pl(t))}));let n=Oi(i),r=new bn(4);r.geometry=n,r.material=pm,r.layers.enableAll(),l.add(r)}let h=new L,c=!1;this.enableRTC&&(c=Jt.checkAndRebasePositionsOnRTC(o,h));let u=Jt.getAdjacentNonRepeatPoints(o);if(u.length<2)return void ae.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=Jt.convertWidthLineToMeshGeometry(u,s.constantWidth);if(t){let e=new bn(4);e.geometry=t,e.material=pm,e.layers.enableAll(),e.layers.disable(11),l.add(e);let i=Nn.createOutline(t,Ws,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 ae.warn("[DxfLoader] Failed to convert line with width to mesh geometry: %s",e.handle)}}let d=new bn(2);return d.geometry=(new Lt).setFromPoints(u),d.material=Ws,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=bR(u),f=this.getMTextGroup(p,e,t,i),m=f&&f.object;if(m){m.matrix.decompose(Pi,ks,Iv),null!=(r=e.contextData)&&r.textLocation&&(Pi.x+=e.contextData.textLocation.x,Pi.y+=e.contextData.textLocation.y,m.matrix.compose(Pi,ks,Iv)),sf.makeEmpty();let t=bn.getBox(m,sf).getSize($n),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}if(m.traverse((e=>{e.geometry&&e.geometry.translate(l,h,0)})),null!=(s=e.contextData)&&s.textRotation&&ks.setFromAxisAngle(Au,e.contextData.textRotation*Math.PI/180),null!=(o=e.contextData)&&o.textDirection){let t=e.contextData.textDirection,i=new L(t.x,t.y,t.z),n=i.clone().cross(yc),r=yc.angleTo(i);ks.multiply(mfe.setFromAxisAngle(Au,n.z>0?-r:r))}Jt.shouldRebasePositionOnRTC(Pi)&&this.setRTCUserData(m),m.matrix.compose(Pi,ks,Iv),m.renderOrder=5,d.add(m)}if(0===e.leaderLineType)return null==m||m.traverse((e=>{e.layers.enableAll()})),m;{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 L(r.x,r.y,r.z),t=n.doglegLength,a=new L(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 L(e.x,e.y,e.z))),s=new L(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 ae.warn("[DxfLoader] Entity is missing vertices:",e.handle);if(e.vertices.length<2)return void ae.warn("leader's vertices number must be greater than 2");let r=t.tables.dimStyle.dimStyles[e.dimensionStyle]||this.getDefaultDimensionStyle(t),a=e.vertices;if(1===e.pathType&&(a=new Np(e.vertices).getPoints(50)),e.textWidth){let t=e.textWidth,i=new L(a[a.length-1].x,a[a.length-1].y,a[a.length-1].z);if(0===e.direction){let e=new L(1,0,0).multiplyScalar(t);a.push(e.add(i))}else{let e=new L(-1,0,0).multiplyScalar(t);a.push(e.add(i))}}for(let p=0;p0?(l.add(d),gc.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 L(t.x+r+s/6,t.y+a+o/6,0),h=new L(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 an&&(e.uniforms.u_cameraZoom&&(e.uniforms.u_cameraZoom=qn.cameraZoomUniform),e.uniforms.u_viewportScale&&(e.uniforms.u_viewportScale=qn.viewportScaleUniform))}static transformAngleByOcsMatrix(e,t){let i=$n.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=$t.getArcAngleSpanInRadian(t,i),a=qn.transformAngleByOcsMatrix(e,t),s=qn.transformAngleByOcsMatrix(e,i);if($t.areNumbersClose(r,Math.PI)){r=1;let i=qn.transformAngleByOcsMatrix(e,t+r);n=$t.getArcAngleSpanInRadian(a,i)}else{if($t.areNumbersClose(r,2*Math.PI))return[a,a+2*Math.PI];n=$t.getArcAngleSpanInRadian(a,s)}return $t.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 ae.warn(`[DxfLoader] The radius of arc (handle '${e.handle}') is undefined, ignored!`);if(!e.radius||e.radius<.001)return void ae.warn(`[DxfLoader] The radius of arc (handle '${e.handle}') is too small, ignored!`);let s=new L(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=qn.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,$t.areNumbersEqual(o,l,1e-6)))return;if(!$t.areNumbersClose($t.getArcAngleSpanInRadian(o,l),2*Math.PI)){let e=qn.getArcAnglesByOcsMatrix(h,o,l);o=e[0],l=e[1]}}let c=new kp(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 L,g=!1;this.enableRTC&&(g=Jt.checkAndRebasePositionsOnRTC(f,m));let v=(new Lt).setFromPoints(f),y=new bn(2);y.geometry=v,y.material=Ws;let x=new L;e.center&&(x.x=e.center.x,x.y=e.center.y);let b=new L(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=dfe,w.material=SR,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):Jt.shouldRebasePositionOnRTC(_)&&this.setRTCUserData(y),y.matrix.setPosition(_),y.layers.enableAll(),y}addTriangleFacingCamera(e,t,i,n){let r=new L,a=new L;r.subVectors(i,t),a.subVectors(n,t),r.cross(a);let s=new L(t.x,t.y,t.z),o=new L(i.x,i.y,i.z),l=new L(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){$n.set(0,0,e.extrusionDirection.z);let t=qn.getOcsMatrix($n).invert();n.forEach((e=>{let i=$n.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 L,o=!1;this.enableRTC&&(o=Jt.checkAndRebasePositionsOnRTC(r,s));let l=(new Lt).setFromPoints(r);l.setIndex(a);let h=new bn(4);return h.geometry=l,h.material=pm,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){var r;if(!e)return;let a=this.getTextStyle(n,i),s=(null==a?void 0:a.styleName)||"";if(a&&a.fontFile&&a.fontFile.endsWith(".shx")){let e=`${a.fontFile}_${a.styleName}`;this.statsInfo.unsupportedTextStyles[e]||(this.statsInfo.unsupportedTextStyles[e]=0),this.statsInfo.unsupportedTextStyles[e]++}let o=.67,l={_TCH_DIM:1.45,ROMANS:1};s&&l[s]&&(o=l[s]),i.xScale&&(o*=i.xScale),s&&(o*=(null==a?void 0:a.xScale)||1,t=t||(null==a?void 0:a.textHeight)||0),0===t&&(t=s?1:.2);let h=this.createTextMeshByText(e,t,0,t/8);return null==(r=null==h?void 0:h.geometry)||r.scale(o,1,1),h}createTextMeshByText(e,t=12,i=0,n=0,r=1,a=1/0){let s,o=[],l=0,h=0,c=i+t;for(let u=0;ua?(l=0,h-=c):(i.boundingBox||i.computeBoundingBox(),l+=i.boundingBox.getSize($n).x+n),o.push(i))}else l=0,h-=c}if(o.length>0){let e=Oi(o);this.font instanceof Ni?(s=new bn(3),s.geometry=e,s.material=Ws):this.font instanceof Vo&&(s=new bn(4),s.geometry=e,s.material=pm)}return s}transformTextMesh(e,t){sf.makeEmpty();let i=bn.getBox(t,sf).getSize($n),{halign:n,valign:r}=e;t.matrix.decompose(MR.position,MR.quaternion,MR.scale);let a=MR,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 L(e.startPoint.x,e.startPoint.y,e.startPoint.z),i=new L(e.endPoint.x,e.endPoint.y,e.endPoint.z),n=(new L).subVectors(t,i),r=n.length()/s;a.scale.multiplyScalar(r);let o=n.clone().cross(yc),l=n.angleTo(yc);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 L(e.startPoint.x,e.startPoint.y,e.startPoint.z),i=new L(e.endPoint.x,e.endPoint.y,e.endPoint.z),n=(new L).subVectors(t,i),r=n.length()/s;a.scale.setX(r);let o=n.clone().cross(yc),l=n.angleTo(yc);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 ae.info("[DxfLoader] Font file not set, ignoring text entity.");let r=this.getTextStyle(t,e);n=ER(n,{encoding:this.getTextEncoding(r)}).map((e=>e.text)).join("");let a=this.getTextMesh(n,e.textHeight,e,t);if(!a||!a.geometry)return;let s=a.geometry;if(a instanceof _t&&!s.getIndex()){let e=s.getAttribute("position"),t=[];for(let i=0;ie.text)).join();let r=this.getTextMesh(n,e.textHeight,e,t);if(!r||!r.geometry)return;let a=r.geometry;if(a.hasAttribute("uv")&&a.deleteAttribute("uv"),a.hasAttribute("normal")&&a.deleteAttribute("normal"),this.transformTextMesh(e,r),$n.set(r.matrix.elements[12],r.matrix.elements[13],r.matrix.elements[14]),Jt.shouldRebasePositionOnRTC($n))this.setRTCUserData(r);else{let e=Jt.caculateGeometryCenter(a);e&&Jt.shouldRebasePositionOnRTC(e)&&this.setRTCUserData(r)}return r.layers.enableAll(),r}drawAttrib(e,t,i){let n=e.text;if(!n||!this.font)return;n=ER(n).map((e=>e.text)).join();let r=this.getTextMesh(n,e.textHeight,e,t);if(!r||!r.geometry)return;let a=r.geometry;if(a.hasAttribute("uv")&&a.deleteAttribute("uv"),a.hasAttribute("normal")&&a.deleteAttribute("normal"),this.transformTextMesh(e,r),$n.set(r.matrix.elements[12],r.matrix.elements[13],r.matrix.elements[14]),Jt.shouldRebasePositionOnRTC($n))this.setRTCUserData(r);else{let e=Jt.caculateGeometryCenter(a);e&&Jt.shouldRebasePositionOnRTC(e)&&this.setRTCUserData(r)}return r.layers.enableAll(),r}drawPoint(e,t,i){if(!e.position)return;let n=new Lt,r=[new L(e.position.x,e.position.y,e.position.z)];$n.set(0,0,0);let a=$n,s=!1;this.enableRTC&&(s=Jt.checkAndRebasePositionsOnRTC(r,a)),n.setFromPoints(r);let o=new bn(1);return o.geometry=n,o.material=Ws,s&&(this.setRTCUserData(o),o.matrix.setPosition(a.x,a.y,0)),o.layers.enableAll(),o}drawDimension(e,t){if(!e.block)return;let i=t.blocks[e.block];if(!i||!i.entities)return;let n=t.tables.dimStyle.dimStyles[e.dimStyleName]||this.getDefaultDimensionStyle(t);n&&n.DIMCLRD>0&&(e.colorIndex=n.DIMCLRD,e.color=lm(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 $n.set(0,0,0),a&&$n.set(a.x,a.y,0),Jt.shouldRebasePositionOnRTC($n)&&this.setRTCUserData(r),r.matrix.setPosition($n),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 ti(a,s);if(l){let e=new gs(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 rn({transparent:!0,side:ai,map:e}),i=new bn(4);i.geometry=h,i.material=t,o.add(i)}let c=new lu(h),u=this.getColor(e,t,i),d=new bn(2);d.geometry=c,d.material=this.getLineBasicMaterial(u);let p=e.uPixel?new L(e.uPixel.x,e.uPixel.y,e.uPixel.z):new L(r.pixelSize.x,0,0),f=e.vPixel?new L(e.vPixel.x,e.vPixel.y,e.vPixel.z):new L(r.pixelSize.y,0,0);if(o.add(d),Pi.set(p.x,f.y,1),$n.set(0,0,0),e.position){let t=new L(e.position.x,e.position.y,e.position.z);t.add(p.multiplyScalar(a/2)).add(f.multiplyScalar(s/2)),$n.copy(t)}return Jt.shouldRebasePositionOnRTC($n)&&this.setRTCUserData(o),ks.identity(),o.matrix.compose($n,ks,Pi),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=$n.set(1,1,1);e.xScale&&(o.x=e.xScale),e.yScale&&(o.y=e.yScale);let l=new zn;e.rotation&&(l.z=e.rotation*Math.PI/180),ks.setFromEuler(l,!1);let h=Pi.set(0,0,0);e.position&&(h.x=e.position.x,h.y=e.position.y),ao.compose(h,ks,o),e.extrusionDirection&&e.extrusionDirection.z<0&&ao.premultiply(ffe.identity().makeScale(-1,1,1)),pfe.copy(s.matrix),s.matrix.premultiply(ao),Pi.set(s.matrix.elements[12],s.matrix.elements[13],s.matrix.elements[14]),Jt.shouldRebasePositionOnRTC(Pi)&&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),ae.debug("[DxfLoader] Spatial filter:",e.associatedSpatialFilter))}return s}drawSpatialFilter(e){let t=e;if(t.threejsObject)return t.threejsObject.clone();let i=e.invertBlockMatrix;ao.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 L(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($t.areVector3sEqual(i,o)&&e+10)break;a.push(i)}if(s>0)for(let e=s+1;e{o.push(new ye(e.x,e.y)),l.push([e.x,e.y])})),!Jt.isConvex(o)){ae.warn(`[DxfLoader] Concave polygon is not supported for spatial filter (handle '${e.handle}'), converting to convex polygon!`);let t=(0,Efe.default)(l,1/0);a=[],t.forEach((e=>{a.push(new L(e[0],e[1],0))}))}$t.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=ao.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 ye(i.startPoint.x,i.startPoint.y)),t.push(new ye(i.endPoint.x,i.endPoint.y));break}case 2:{let i=e,n=i.startAngle*Cn.DEG2RAD,r=i.endAngle*Cn.DEG2RAD;i.bCounterclockwise||(n=2*Math.PI-n,r=2*Math.PI-r);let a=new kp(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*Cn.DEG2RAD,o=i.endAngle*Cn.DEG2RAD;i.bCounterclockwise||(s=2*Math.PI-s,o=2*Math.PI-o);let l=new Rh(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(...NH(i.points,i.isClosed));break}}return t}drawHatch(e,t,i){var n;let r=e;if(0==r.boundaryPaths.length)return;let a=[],s=[],o=[],l=e=>{let t=[],i=[];i.push(...this.convertEdgeToPoints(e[0]));for(let n=1;n2){let a=this.convertEdgeToPoints(e[n-1]);$t.areVector2sEqual(a[a.length-1],r[0])?$t.areVector2sEqual(i[0],r[r.length-1],1e-5)&&(t.push(i),i=[]):$t.areVector2sEqual(a[0],r[r.length-1])?$t.areVector2sEqual(i[1],r[0],1e-5)&&(t.push(i),i=[]):i=[]}}return t};if(r.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 ae.info(i,e.pathTypeFlag,t,r.handle)}let n=e.edges;if(0===n.length)return;let h=[];for(let a=0;a31&&(!(e=>{for(let t=1;t{$t.areVector2sEqual(e[0],e[e.length-1])||e.push(e[0]);let t=e.map((e=>new ye(wt.roundNumber(e.x,7),wt.roundNumber(e.y,7))));if((null==t?void 0:t.length)>0){a.push(t);let e=(new Gi).setFromPoints(t);s.push(e);let i=e.getSize(aE),n=i.x*i.y;o.push({area:n,index:a.length-1})}}))})),0===a.length)return;let h=new ye,c=this.checkAndRebasePolygonsOnRTC(a,h);o.sort(((e,t)=>e.area-t.area));let u=[];o.forEach((e=>{u.push(e.index)}));let d,p=this.buildContainHierarchyTree(a,s,u),f=[];if(this.buildHatchGeometry(a,p,f),f.length>0&&(d=Oi(f)),!d||!d.getIndex()||0===(null==(n=d.getIndex())?void 0:n.count))return void ae.warn("[DxfLoader] Failed to convert hatch boundaries!");let m=new bn(4);m.geometry=d,m.material=pm,this.setHatchMaterial(m,r,t,h,i);let g=m;return c&&(this.setRTCUserData(g),g.matrix.setPosition(h.x,h.y,0)),g.traverse((e=>{e.layers.enableAll(),e.layers.disable(11)})),g}drawOle2frame(e,t){let{leftUpX:i,leftUpY:n,rightDownX:r,rightDownY:a}=e;if(!(i&&n&&r&&a))return;let s=[new ye(i,n),new ye(i,a),new ye(r,a),new ye(r,n),new ye(i,n)],o=new L,l=!1;this.enableRTC&&(l=Jt.checkAndRebasePositionsOnRTC(s,o));let h=(new Lt).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=yc,i=kH,n=Au,r=new L(0,1,0),a=new L(0,0,1);return $t.areVectorsClose(e,a)?ao.identity():(n=e.clone().normalize(),$t.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()),ao.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=zlt(e)?e.viewDirectionFromTarget:e.viewDirection;let n,r,a,s=new L($t.roundNumber(i.x,7),$t.roundNumber(i.y,7),i.z),o=new L(e.viewTarget.x,e.viewTarget.y,e.viewTarget.z),l=e.viewTwistAngle||0;a=s.clone().normalize(),n=Au.clone().cross(s),n.length()>0?(n.normalize(),r=a.clone().cross(n)):a.z<0?(n=yc.clone().negate(),r=kH,a=Au.clone().negate()):(n=yc,r=kH,a=Au);let h=new Qe,c=ao.identity();return c.makeBasis(n,r,a),h.premultiply(c),h.premultiply(ao.identity().compose(o.clone(),(new ir).setFromAxisAngle(new L(0,0,1),Cn.degToRad(t?l:-l)),new L(1,1,1))),h}getViewportMsToPsMatrix(e){let t=new L(e.centerPoint_dcs.x,e.centerPoint_dcs.y,0),i=new L(e.centerPoint.x,e.centerPoint.y,e.centerPoint.z),n=e.viewHeight/e.height_paperSpace,r=qn.getDcs2WcsMatrix(e,this.angDir),a=new Qe;a.setPosition(hfe.clone().sub(i));let s=ffe.identity();s.scale($n.set(n,n,n));let o=pfe.identity().setPosition(hfe.clone().sub(i));s.premultiply(o.clone().invert()).multiply(o),a.multiply(s);let l=ao.identity();l.setPosition(t),r.multiply(l);let h=ao.identity();return a.invert().multiply(h).multiply(r.invert())}drawViewport(e,t,i){let n=e;if("1"==n.viewportId)return e.psBBox=new It,void(e.msToPsMatrix=new Qe);let r=[],a=n.centerPoint,s=n.width_paperSpace/2,o=n.height_paperSpace/2;r.push(new L(a.x-s,a.y-o,0)),r.push(new L(a.x-s,a.y+o,0)),r.push(new L(a.x+s,a.y+o,0)),r.push(new L(a.x+s,a.y-o,0)),r.push(r[0]),e.psBBox=new It(r[0],r[2]),e.msToPsMatrix=this.getViewportMsToPsMatrix(n);let l=new L,h=!1;this.enableRTC&&(h=Jt.checkAndRebasePositionsOnRTC(r,l));let c=(new Lt).setFromPoints(r),u=new bn(2);u.geometry=c,u.material=Ws,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 L(p.min.x,p.max.y,0)),f.push(p.max),f.push(new L(p.max.x,p.min.y,0)),f.push(f[0]);let m=new L,g=!1;this.enableRTC&&(g=Jt.checkAndRebasePositionsOnRTC(f,m));let v=(new Lt).setFromPoints(f),y=new bn(2);return y.geometry=v,y.material=Ws,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 ns.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!`;ae.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=af;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 ae.warn("[DxfLoader] Unknown colorIndex"),af}getLineType(e,t,i){var n,r;if(i&&"DIMENSION"===i.type)return this.getLineType(i,t);if(e.lineType!==yv&&e.lineType!==xv)return e.lineType;if(e.lineType===xv)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=Vlt;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 aE.set(0,0),void this.setHatchMaterial(e,t,i,aE,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 hi)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 an){o=a.material;let e=new ct(s);a.material.uniforms.u_color.value.equals(e)||(o=a.material.clone(),qn.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 hi({size:.2,color:e})),this.pointsMaterials[e]}getLineBasicMaterial(e){return this.lineBasicMaterials[e]||(this.lineBasicMaterials[e]=new kn({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]=xR.createLineShaderMaterial(e.pattern,t,a,qn.viewportScaleUniform,qn.cameraZoomUniform)}return this.lineShaderMaterials[n]}getMeshBasicMaterial(e){return this.meshBasicMaterials[e]||(this.meshBasicMaterials[e]=new rn({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 ye;for(let h of e.patternLines){let t=new ye(h.origin.x,h.origin.y).sub(i).rotateAround(o,-Cn.degToRad(e.patternAngle)),n=new ye(h.delta.x,h.delta.y).rotateAround(o,-Cn.degToRad(h.angle));if(0===n.y)return void ae.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;eqn.maxFragmentUniforms){ae.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=efe(s,e.patternAngle,qn.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 dt(this,null,(function*(){let i={dxfDataId:e,dxf:t};return new Promise(((t,n)=>{Pv.instance().add(i,(()=>{ae.info(`[DxfLoader] Saved '${e}' to indexedDb`),t()}),(e=>{n(e)}))}))}))}getDxfDataFromIndexedDb(e){return dt(this,null,(function*(){return new Promise(((t,i)=>{Pv.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 pl(e);t.hasAttribute("uv")&&t.deleteAttribute("uv"),t.hasAttribute("normal")&&t.deleteAttribute("normal"),i.push(t)}catch(t){ae.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 ps(i);a(n)}));let s=e=>e.map((e=>e.toArray()));for(let o of r){let t=new ps(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(Sl.epsilon($t.getVector2RelativeEps(e[n][0]),1e-6),0===a)r=Sl.segments({regions:[s(e[n])],inverted:!1});else{let a=Sl.segments({regions:[s(e[n])],inverted:!1}),o=Sl.combine(r,a);i=Sl.polygon(Sl.selectUnion(o)),i.regions.length>0?i.regions.forEach((e=>{if(0===e.length)return;let i=e.map((e=>new ye(e[0],e[1])));t.holes.push(new au(i))})):ae.warn("[DxfLoader] mergedHoles.regions is empty")}}))}catch(e){ae.warn(`[DxfLoader] polybooljs has error: ${e}, epsilon is ${Sl.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&&Jt.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):(ae.warn("[DxfLoader] Failed to find layout name for entity:",t),e.objects.LAYOUT.find((e=>e.layoutName===qn.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();qn.updateMaterialUniforms(n),t.set(e.id,n),i.push(n)}}))):e&&(t.has(e.id)?i=t.get(e.id):(i=e.clone(),qn.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:ae.warn(`[DxfLoader] Unsupported $INSUNITS '${e}'`)}return"Unitless"}static computeLineDistance(e){let t=!0===e.isLineSegments,i=e.geometry,n=e.matrixWorld;if(i.index&&(ae.debug(`[DxfLoader] Line with id '${e.id}' contains index buffer, going to convert it to non-indexed.`),i=Jt.convertGeometryWithIndexedToNonIndexed(i),e.userData.batches&&e.userData.batches.length>0)){ae.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 an&&qn.computeLineDistance(t)})),ae.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];qn.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=gc.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();qn.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,ae.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=[]}ae.debug(`[DxfLoader] MergeUtils.deepMerge costed ${Gr.mergeInfo.elapsedTime/1e3}s`),ae.debug(`[DxfLoader] The remove operation of deep merge costed ${a/1e3}s`),ae.debug(`[DxfLoader] Deep merge totally costed ${(Date.now()-t)/1e3}s`);let o=Gr.mergeInfo;ae.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 dt(this,null,(function*(){let i=wt.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];qn.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!==qn.MODEL_LAYOUT_NAME){let i=n[e];i.directAssociatedLeafObjectSet||(i.directAssociatedLeafObjectSet=new Set),t=i.directAssociatedLeafObjectSet}let r=p[e],d=Gr.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();qn.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,ae.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===qn.SNAP_GROUP_NAME));if(e&&t!==qn.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=[]}ae.debug(`[DxfLoader] MergeUtils.deepMerge costed ${Gr.mergeInfo.elapsedTime/1e3}s`),ae.debug(`[DxfLoader] The remove operation of deep merge costed ${l/1e3}s`),ae.debug(`[DxfLoader] Deep merge totally costed ${(Date.now()-r)/1e3}s`);let d=Gr.mergeInfo;ae.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;ae.debug("[DxfLoader] Entity types and cost times in ms:",this.entityTypesAndTimes),ae.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&&ae.debug(`[DxfLoader] Totally rebased ${this.statsInfo.rebasedEntityCount}(out of ${e}) entities`),this.enableMerge){let e=Gr.mergeInfo;ae.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&&ae.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&&this.font.unsupportedChars&&t(0,this.font.unsupportedChars)}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))}));ae.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||Nn.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 aa(e){return(aa="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 Ml(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function FH(e,t){if("object"!==aa(e)||null===e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var n=i.call(e,t||"default");if("object"!==aa(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}function oE(e){var t=FH(e,"string");return"symbol"===aa(t)?t:String(t)}function Tfe(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]:{};Ml(this,e),this.init(t,i)}return Al(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||Ylt,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 Afe(e,t,i){var n=qH(e,t,Object);n.obj[n.k]=i}function Klt(e,t,i,n){var r=qH(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 PR(e,t){var i=qH(e,t),n=i.obj,r=i.k;if(n)return n[r]}function Rfe(e,t,i){var n=PR(e,i);return void 0!==n?n:PR(t,i)}function Ufe(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]):Ufe(e[n],t[n],i):e[n]=t[n]);return e}function Lv(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")}var Jlt={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};function Qlt(e){return"string"==typeof e?e.replace(/[&<>"'\/]/g,(function(e){return Jlt[e]})):e}var DR="undefined"!=typeof window&&window.navigator&&void 0===window.navigator.userAgentData&&window.navigator.userAgent&&window.navigator.userAgent.indexOf("MSIE")>-1,ect=[" ",",","?","!",";"];function tct(e,t,i){t=t||"",i=i||"";var n=ect.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 Cfe(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 RR(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(null===l)return null;if(t.endsWith(o)){if("string"==typeof l)return l;if(o&&"string"==typeof l[o])return l[o]}var h=n.slice(a+s).join(i);return h?Vfe(l,h,i):void 0}r=r[n[a]]}return r}}var ict=function(e){Dv(i,lf);var t=nct(i);function i(e){var n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{ns:["translation"],defaultNS:"translation"};return Ml(this,i),n=t.call(this),DR&&lf.call(xc(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 Al(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=PR(this.data,s);return o||!a||"string"!=typeof i?o:Vfe(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),Afe(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=PR(this.data,s)||{};n?Ufe(o,i,r):o=RR(RR({},o),i),Afe(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?RR(RR({},{}),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}(),zfe={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 Pfe(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 Ia(e){for(var t=1;t1&&void 0!==arguments[1]?arguments[1]:{};return Ml(this,i),n=t.call(this),DR&&lf.call(xc(n)),Zlt(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,xc(n)),n.options=r,void 0===n.options.keySeparator&&(n.options.keySeparator="."),n.logger=Pu.create("translator"),n}return Al(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||tct(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"!==aa(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,Ia(Ia({},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,Ia(Ia({},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),L=P?this.pluralResolver.getSuffix(u,t.count,t):"",I=t["defaultValue".concat(L)]||t.defaultValue;!this.isValidLookup(m)&&R&&(A=!0,m=I),this.isValidLookup(m)||(C=!0,m=l);var D=(t.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&C?void 0:m,O=R&&I!==m&&this.options.updateMissing;if(C||A||O){if(this.logger.log(O?"updateKey":"missingKey",u,c,l,O?I:m),s){var k=this.resolve(l,Ia(Ia({},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=[],F=this.languageUtils.getFallbackCodes(this.options.fallbackLng,t.lng||this.language);if("fallback"===this.options.saveMissingTo&&F&&F[0])for(var U=0;U1&&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,!Ife["".concat(f[0],"-").concat(e)]&&s.utils&&s.utils.hasLoadedNamespace&&!s.utils.hasLoadedNamespace(a)&&(Ife["".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="".concat(s.options.pluralSeparator,"zero");if(u&&(l.push(h+c),d&&l.push(h+f)),p){var m="".concat(h).concat(s.options.contextSeparator).concat(o.context);l.push(m),u&&(l.push(m+c),d&&l.push(m+f))}}for(;a=l.pop();)s.isValidLookup(t)||(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){for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&"defaultValue"===t.substring(0,12)&&void 0!==e[t])return!0;return!1}}]),i}();function GH(e){return e.charAt(0).toUpperCase()+e.slice(1)}var oct=function(){function e(t){Ml(this,e),this.options=t,this.supportedLngs=this.options.supportedLngs||!1,this.logger=Pu.create("languageUtils")}return Al(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]=GH(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]=GH(i[1].toLowerCase())),t.indexOf(i[2].toLowerCase())>-1&&(i[2]=GH(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}(),lct=[{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}],cct={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)}},uct=["v1","v2","v3"],Lfe={zero:0,one:1,two:2,few:3,many:4,other:5};function hct(){var e={};return lct.forEach((function(t){t.lngs.forEach((function(i){e[i]={numbers:t.nr,plurals:cct[t.fc]}}))})),e}var dct=function(){function e(t){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Ml(this,e),this.languageUtils=t,this.options=i,this.logger=Pu.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=hct()}return Al(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 Lfe[e]-Lfe[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!uct.includes(this.options.compatibilityJSON)}}]),e}();function Ofe(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 bc(e){for(var t=1;t0&&void 0!==arguments[0]?arguments[0]:{};Ml(this,e),this.logger=Pu.create("interpolator"),this.options=t,this.format=t.interpolation&&t.interpolation.format||function(e){return e},this.init(t)}return Al(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:Qlt,this.escapeValue=void 0===t.escapeValue||t.escapeValue,this.useRawValueToEscape=void 0!==t.useRawValueToEscape&&t.useRawValueToEscape,this.prefix=t.prefix?Lv(t.prefix):t.prefixEscaped||"{{",this.suffix=t.suffix?Lv(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?Lv(t.nestingPrefix):t.nestingPrefixEscaped||Lv("$t("),this.nestingSuffix=t.nestingSuffix?Lv(t.nestingSuffix):t.nestingSuffixEscaped||Lv(")"),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=Rfe(t,l,e);return o.alwaysFormat?o.format(r,void 0,i,bc(bc(bc({},n),t),{},{interpolationkey:e})):r}var a=e.split(o.formatSeparator),s=a.shift().trim(),h=a.join(o.formatSeparator).trim();return o.format(Rfe(t,l,s),h,i,bc(bc(bc({},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=Mfe(a));var h=t.safeValue(a);if(e=e.replace(r[0],h),d?(t.regex.lastIndex+=a.length,t.regex.lastIndex-=r[0].length):t.regex.lastIndex=0,++s>=o.maxReplaces)break}})),e}},{key:"nest",value:function(e,t){var i,n,r=this,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},s=bc({},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];var a=(r=this.interpolate(r,s)).match(/'/g),o=r.match(/"/g);(a&&a.length%2==0&&!o||o.length%2!=0)&&(r=r.replace(/'/g,'"'));try{s=JSON.parse(r),t&&(s=bc(bc({},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=Mfe(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,bc(bc({},a),{},{interpolationkey:i[1].trim()}))}),n.trim())),e=e.replace(i[0],n),this.regexp.lastIndex=0}return e}}]),e}();function kfe(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 of(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=zH(e.split(":")),n=t[0],r=t.slice(1).join(":").trim().replace(/^'+|'+$/g,"");i[n.trim()]||(i[n.trim()]=r),"false"===r&&(i[n.trim()]=!1),"true"===r&&(i[n.trim()]=!0),isNaN(r)||(i[n.trim()]=parseInt(r,10))}}))}return{formatName:t,formatOptions:i}}function Ov(e){var t={};return function(i,n,r){var a=n+JSON.stringify(r),s=t[a];return s||(s=e(n,r),t[a]=s),s(i)}}var mct=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Ml(this,e),this.logger=Pu.create("formatter"),this.options=t,this.formats={number:Ov((function(e,t){var i=new Intl.NumberFormat(e,t);return function(e){return i.format(e)}})),currency:Ov((function(e,t){var i=new Intl.NumberFormat(e,of(of({},t),{},{style:"currency"}));return function(e){return i.format(e)}})),datetime:Ov((function(e,t){var i=new Intl.DateTimeFormat(e,of({},t));return function(e){return i.format(e)}})),relativetime:Ov((function(e,t){var i=new Intl.RelativeTimeFormat(e,of({},t));return function(e){return i.format(e,t.range||"day")}})),list:Ov((function(e,t){var i=new Intl.ListFormat(e,of({},t));return function(e){return i.format(e)}}))},this.init(t)}return Al(e,[{key:"init",value:function(e){var t=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{interpolation:{}}).interpolation;this.formatSeparator=t.formatSeparator?t.formatSeparator:t.formatSeparator||","}},{key:"add",value:function(e,t){this.formats[e.toLowerCase().trim()]=t}},{key:"addCached",value:function(e,t){this.formats[e.toLowerCase().trim()]=Ov(t)}},{key:"format",value:function(e,t,i,n){var r=this;return t.split(this.formatSeparator).reduce((function(e,t){var a=pct(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,of(of(of({},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 Nfe(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 Ffe(e){for(var t=1;t3&&void 0!==arguments[3]?arguments[3]:{};return Ml(this,i),a=t.call(this),DR&&lf.call(xc(a)),a.backend=e,a.store=n,a.services=r,a.languageUtils=r.languageUtils,a.options=s,a.logger=Pu.create("backendConnector"),a.waitingReads=[],a.maxParallelReads=s.maxParallelReads||10,a.readingCalls=0,a.maxRetries=s.maxRetries>=0?s.maxRetries:5,a.retryTimeout=s.retryTimeout>=1?s.retryTimeout:350,a.state={},a.queue=[],a.backend&&a.backend.init&&a.backend.init(r,s.backend,s),a}return Al(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){Klt(i.loaded,[r],a),yct(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=i.loaded[e];t.length&&t.forEach((function(t){void 0===s[e][t]&&(s[e][t]=!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]:this.retryTimeout,s=arguments.length>5?arguments[5]:void 0;return e.length?this.readingCalls>=this.maxParallelReads?void this.waitingReads.push({lng:e,ns:t,fcName:i,tried:r,wait:a,callback:s}):(this.readingCalls++,this.backend[i](e,t,(function(o,l){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)}o&&l&&r2&&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,Ffe(Ffe({},a),{},{isUpdate:r})),e&&e[0]&&this.store.addResource(e[0],t,i,n))}}]),i}();function bct(){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"===aa(e[1])&&(t=e[1]),"string"==typeof e[1]&&(t.defaultValue=e[1]),"string"==typeof e[2]&&(t.tDescription=e[2]),"object"===aa(e[2])||"object"===aa(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 Bfe(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 Hfe(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 Cu(e){for(var t=1;t0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0;if(Ml(this,i),e=t.call(this),DR&&lf.call(xc(e)),e.options=Bfe(n),e.services={},e.logger=Pu,e.modules={external:[]},Tct(xc(e)),r&&!e.isInitialized&&!n.isClone){if(!e.options.initImmediate)return e.init(n,r),mm(e,xc(e));setTimeout((function(){e.init(n,r)}),0)}return e}return Al(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&&!1!==t.defaultNS&&t.ns&&("string"==typeof t.ns?t.defaultNS=t.ns:t.ns.indexOf("translation")<0&&(t.defaultNS=t.ns[0]));var n=bct();function r(e){return e?"function"==typeof e?new e:e:null}if(this.options=Cu(Cu(Cu({},n),this.options),Bfe(t)),"v1"!==this.options.compatibilityAPI&&(this.options.interpolation=Cu(Cu({},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?Pu.init(r(this.modules.logger),this.options):Pu.init(null,this.options),this.modules.formatter?a=this.modules.formatter:"undefined"!=typeof Intl&&(a=mct);var s=new oct(this.options);this.store=new ict(this.options.resources,this.options);var o=this.services;o.logger=Pu,o.resourceStore=this.store,o.languageUtils=s,o.pluralResolver=new dct(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 fct(this.options),o.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},o.backendConnector=new xct(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=cE(),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]:CR,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)}))};n?a(n):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=cE();return e||(e=this.languages),t||(t=this.options.ns),i||(i=CR),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&&zfe.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=cE();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"!==aa(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=cE();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=cE();"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]:CR,r=Cu(Cu(Cu({},this.options),t),{isClone:!0}),a=new i(r);return(void 0!==t.debug||void 0!==t.prefix)&&(a.logger=a.logger.clone(t)),["store","services","language"].forEach((function(t){a[t]=e[t]})),a.services=Cu({},this.services),a.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},a.translator=new Dfe(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 Da=IR.createInstance();Da.createInstance=IR.createInstance;var LUt=Da.createInstance,OUt=Da.init,kUt=Da.loadResources,NUt=Da.reloadResources,FUt=Da.use,BUt=Da.changeLanguage,HUt=Da.getFixedT,Iu=Da.t,UUt=Da.exists,VUt=Da.setDefaultNamespace,zUt=Da.hasLoadedNamespace,GUt=Da.loadNamespaces,qUt=Da.loadLanguages,gm=Da,cf=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)}},rs=$i(mc(),1);function kv(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 LR=(e=>(e[e.ClickEvent=1]="ClickEvent",e[e.Popup=2]="Popup",e[e.SubMenu=3]="SubMenu",e[e.Switch=4]="Switch",e))(LR||{}),uE=(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))(uE||{}),Gfe=[["HomeView","OrthoMode","FullScreen","ZoomToRectangle","GetScreenshot"],["Measure","Markup","MarkupVisibility","Section"],["BimTree","Viewpoint","Annotation","Property","Compared","QuitCompare","Layers"],["Settings"]],Du=class{constructor(e,t,i=[...Gfe]){this.bimViewer=e,this.menuConfig=t,this.groupConfig=i,this.visible=!0,this.menuList=new Map,this.keydown=e=>{var t,i;if(this.visible&&"Escape"===e.code){if(null!=(t=this.bimViewer.measurePlugin)&&t.isMeasuring()||null!=(i=this.bimViewer.getMarkupManager())&&i.isMarkupActive())return;this.clearActive()}},this.init(),window.addEventListener("keydown",this.keydown,!1)}init(){var e;let t=document.createElement("div");t.classList.add("toolbar"),this.groupConfig.forEach(((e,i)=>{let n=document.createElement("div");n.classList.add("toolbar-group");let r=document.createElement("div");r.classList.add("toolbar-group-division"),e.forEach((e=>{let t=(0,rs.get)(this.menuConfig,e);if(t&&!1!==t.visible){let i=this.createToolbarMenu(this.bimViewer,e,t);n.appendChild(i.element)}})),n.hasChildNodes()&&(i&&t.appendChild(r),t.appendChild(n))})),this.element=t,null==(e=this.bimViewer.widgetContainer)||e.appendChild(t),t.oncontextmenu=e=>{e.preventDefault()}}clearActive(){if(this.activateMenuId){let e=this.menuList.get(this.activateMenuId);null==e||e.setActive(!1),this.activateMenuId=void 0}}setActive(e,t){let i=this.menuList.get(e);null==i||i.setActive(t),this.activateMenuId=t?e:void 0}createToolbarMenu(e,t,i,n){let r=new jH(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,rs.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,rs.assign)(this.menuConfig[e],t),this.refresh()}updateMenus(e){(0,rs.forEach)(e,(({menuId:e,config:t})=>{(0,rs.assign)(this.menuConfig[e],t)})),this.refresh()}addMenu(e,t,i){if((0,rs.keys)(this.menuConfig).includes(e))ae.error("[Toolbar]",e,"exists.");else{if((0,rs.assign)(this.menuConfig,{[e]:t}),i){let[t,n]=i;if(t>this.groupConfig.length-1)this.groupConfig=(0,rs.concat)(this.groupConfig,[[e]]);else{let i=this.groupConfig[t];this.groupConfig[t]=n>i.length-1?(0,rs.concat)(i,e):(0,rs.concat)((0,rs.take)(i,n),e,(0,rs.takeRight)(i,i.length-n))}}else this.groupConfig=(0,rs.concat)(this.groupConfig,[[e]]);this.refresh()}}refresh(){this.element&&this.element.remove(),this.element=void 0,this.menuList.clear(),this.init()}show(){this.element&&(this.element.style.display=""),this.visible=!0}hide(){this.element&&(this.element.style.display="none"),this.visible=!1}destroy(){this.element&&this.element.remove(),this.element=void 0,this.menuList.clear(),window.removeEventListener("keydown",this.keydown,!1)}},jH=class{constructor(e,t,i,n,r){this.bimViewer=e,this.toolbar=t,this.menuId=i,this.eventBus=kv(),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,rs.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&&TA(this.element.firstChild.classList,n.icon,this.active),r&&r.setActive(t)})),Tn.isMobile?(this.element.ontouchstart=t=>{switch(this.element.classList.toggle("toolbar-parent-menu-active"),this.element.classList.toggle("toolbar-menu-active"),t.stopPropagation(),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=ov}=i.icon;return n.innerHTML=`
`,n.title=Iu(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)}},qfe={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=wn.rgba2Color(e.getMarkupLineColor()),a.click(),a.oninput=t=>{let i=t.target.value;e.setMarkupLineColor(...wn.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=Iu(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=Iu(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=>{ae.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=Iu(i.menuName),n.innerHTML+=`${n.title}`,n},onClick:(e,t)=>{var i;e.deactivateMarkup(),t.destroy(),null==(i=e.toolbar)||i.show()},type:1,menuName:"Toolbar.quitMarkup"}},wct=[["Arrow","Rect","CloudRect","PolyLine","Ellipse","Circle","Text","StrokeStyle","FontSize","MarkupClear","MarkupQuit"]],OR=class extends Du{constructor(e,t,i=[...wct]){super(e,t,i),this.keydown=()=>{}}},Nv=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(E5,this.start),n.addEventListener(b5,this.stop),document.body.addEventListener(Zd,this.follow),this.container.appendChild(this.element)}destroy(){document.body.removeEventListener(Zd,this.follow),this.element.removeEventListener(E5,this.start),this.element.removeEventListener(b5,this.stop),this.element.remove()}},La=new L(1,0,0),uf=new L(0,1,0),hf=new L(0,0,1),jfe=new L(0,1,0),hE=new Qe,Fv=2,Ec=class extends Gn{constructor(e=La){super(),this.redMaterial=new rn({color:16711680,depthTest:!1}),this.greenMaterial=new rn({color:65280,depthTest:!1}),this.blueMaterial=new rn({color:255,depthTest:!1}),this.highlightMaterial=new rn({color:16776960,depthTest:!1}),this.pickableMaterial=new rn({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 ir;t.setFromUnitVectors(La,e),this.applyQuaternion(t)}initOrUpdateByAxis(e){this.clear(),[{actionType:"TranslateX",direction:La,material:this.redMaterial},{actionType:"TranslateY",direction:uf,material:this.greenMaterial},{actionType:"TranslateZ",direction:hf,material:this.blueMaterial}].forEach((t=>{let{actionType:i,direction:n,material:r}=t,a=this.createTranslateGizmo(i,n,Fv,0===n.angleTo(e)?r:this.pickableMaterial);this.add(a)})),[{actionType:"RotateX",direction:La,material:this.redMaterial,degree:90},{actionType:"RotateY",direction:uf,material:this.greenMaterial,degree:90},{actionType:"RotateZ",direction:hf,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,Fv,r,a);this.add(e)}})),this.createSphere(1,this.pickableMaterial),this.createSphere(1,this.pickableMaterial,new L(12*Fv,0,0)),this.createSphere(1,this.pickableMaterial,new L(0,12*Fv,0)),this.createSphere(1,this.pickableMaterial,new L(0,0,12*Fv))}createTranslateGizmo(e,t,i,n){let r=t.angleTo(jfe),a=jfe.clone().cross(t);hE.makeRotationAxis(a,r);let s=new oc(i/5,i/5,20*i),o=10*i;s.translate(0,o,0),s.applyMatrix4(hE);let l=new oc(0,i,3*i),h=2*o;l.translate(0,h,0),l.applyMatrix4(hE);let c=Oi([l,s]),u=new _t(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 L(0,0,1),s=t.clone().cross(a),o=t.angleTo(a);hE.makeRotationAxis(s,o);let l=new Nd(12*i,i/5,24,36,Cn.degToRad(r));l.applyMatrix4(hE);let h=new _t(l,n);return h.layers.enable(12),h.userData.actionType=e,h}createSphere(e,t,i=new L){let n=new Ma(e,32,16),r=new _t(n,t);r.position.copy(i),r.layers.disable(12),this.add(r)}setActiveAxis(e){this.initOrUpdateByAxis(e)}createHoverRotateObjectByAxis(e){let t=La;switch(e){case"RotateX":t=La;break;case"RotateY":t=uf;break;case"RotateZ":t=hf}return this.createRotateGizmo("",t,Fv,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 L;this.getWorldPosition(t);let i=e.position,n=1;e instanceof Ir?n=(e.top-e.bottom)/e.zoom:e instanceof nr&&(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)}},df=class{constructor(e,t){if(this.raycaster=new qs,this.sectionBox=new It,this.mouseDown=!1,this.lastWorldPos=new L,this.mouseMoved=!1,this.dragStarted=!1,this.refrencePlane=new Nr,this.active=!1,this.isShowSectionPlane=!1,this.mousedown=e=>{if(0===e.button){if(Tn.isMobile){let t=this.getIntersections(e);t?(this.inputManager.setCursor("grab"),this.selectedObject=t.object,this.activateSelectedObject(!0),this.enableDefaultControl(!1),this.viewer.enableRender()):this.enableDefaultControl(!0)}this.camera&&this.selectedObject&&(this.inputManager.setCursor("grabbing"),this.mouseDown=!0)}},this.mousemove=e=>{if(this.dragStarted)this.updateRaycasterByMouse(e),this.inputManager.setCursor("grabbing"),this.onDragMove(e);else{this.activateSelectedObject(!1);let t=this.getIntersections(e);t?(this.inputManager.setCursor("grab"),this.selectedObject=t.object,this.activateSelectedObject(!0),this.mouseDown&&(this.dragStarted||(this.dragStarted=!0,this.enableDefaultControl(!1),this.onDragStart(e)))):(this.inputManager.setCursor("default"),this.selectedObject=void 0)}this.viewer.enableRender()},this.mouseup=e=>{0===e.button&&(this.activateSelectedObject(!1),this.mouseDown&&this.dragStarted&&(this.inputManager.setCursor("grab"),this.onDragEnd(e),this.dragStarted=!1,this.enableDefaultControl(!0)),this.mouseDown=!1,this.selectedObject=void 0)},this.keydown=e=>{"Escape"===e.code&&this.deactivate()},!(e.camera&&e.renderer&&e.controls&&e.scene))throw new Error("Invalid bimViewer!");this.viewer=e,this.inputManager=t,this.scene=e.scene,this.renderer=e.renderer,this.raycaster.layers.set(12)}get canvas(){var e;return null==(e=this.viewer.renderer)?void 0:e.domElement}get isActive(){return!!this.active}get camera(){return this.viewer.camera}get controls(){return this.viewer.controls}setGlobalClippingEnable(e){if(!this.clipPlanes)return;let t=e?this.clipPlanes:[];this.renderer.localClippingEnabled=e,this.renderer.clippingPlanes=t}setObjectClippingEnable(e){var t,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.setObjectClippingEnable(!1),this.clippingObjetIds=[]}setClippingEnable(e){var t;null!=(t=this.clippingObjetIds)&&t.length?(this.setGlobalClippingEnable(!1),this.setObjectClippingEnable(e)):this.setGlobalClippingEnable(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.enableDefaultControl(!0)}enableDefaultControl(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 Ec))||t[0]}updateRaycasterByMouse(e){if(!this.raycaster)return;let t=new ye(e.x,e.y),i=on.screenPoint2NdcPoint(t,this.camera,this.canvas);this.raycaster.setFromCamera(i,this.camera)}destroy(){this.deactivate()}},Xfe=new It,Yfe=new ir,kR=class extends _t{constructor(e,t){super(),this.vertices=[],this.layers.enable(12),this.actionType=e,this.geometry=new Lt,this.vertices=t,this.geometry.setFromPoints(t),this.geometry.setIndex([0,1,2,0,2,3]),this.material=new rn({depthTest:!1,color:kR.normalPlaneColor,transparent:!0,opacity:.01,side:vr}),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 Lt;t.setFromPoints(e),t.setIndex([0,1,1,2,2,3,3,0]);let i=new kn({color:kR.normalLineColor});return this.createIgnoreClipMaterials(i),new rr(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();Yfe.setFromAxisAngle(e,t),this.vertices=this.vertices.map((e=>e.sub(i).applyQuaternion(Yfe).add(i))),this.update(this.vertices)}setDirection(e){let t=new ir;t.setFromUnitVectors(La,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 L;return ei.getNormal(e,t,i,n),n}setActive(e){this.material.opacity=e?.1:.01}getPlaneCenter(){Xfe.setFromPoints(this.vertices);let e=new L;return Xfe.getCenter(e),e}},_i=kR;_i.normalPlaneColor=new ct(0,.855,.718),_i.activePlaneColor=new ct(1,1,0),_i.normalLineColor=16777215;var $fe=(e=>(e.X="X",e.Y="Y",e.Z="Z",e))($fe||{}),NR=class extends df{constructor(e,t){super(e,t),this.activeAxis="X",this.center=new L,this.axisInfoMap={X:{normal:new L(1,0,0)},Y:{normal:new L(0,1,0)},Z:{normal:new L(0,0,1)}},this.viewer.addEventListener("AfterRender",(()=>{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.setClippingEnable(!1),this.planeMesh=void 0,this.gizmo=void 0,this.setActiveAxis("X")}setActiveAxis(e){this.activeAxis=e,this.initOrUpdateGizmo(),this.initOrUpdateSectionPlane(),this.initOrUpdateClipPlane(),this.setClippingEnable(!0),this.viewer.enableRender()}setSectionVisible(e){this.gizmo&&this.planeMesh&&(this.gizmo.visible=e,this.planeMesh.visible=e),this.isShowSectionPlane=e,this.viewer.enableRender()}initOrUpdateClipPlane(){switch(this.activeAxis){case"X":this.clipPlane=new Nr(new L(-1,0,0),this.center.x);break;case"Y":this.clipPlane=new Nr(new L(0,-1,0),this.center.y);break;case"Z":this.clipPlane=new Nr(new L(0,0,-1),this.center.z)}this.clipPlane&&(this.clipPlanes=[this.clipPlane])}initOrUpdateSectionPlane(){var e;let t=new L;this.sectionBox.getSize(t);let i=t.length(),n=this.center,r=(new It).setFromCenterAndSize(n,new L(i,i,i)),{min:a,max:s}=r;switch(null==(e=this.planeMesh)||e.removeFromParent(),this.activeAxis){case"X":this.planeMesh=new _i("X",[new L(n.x,s.y,a.z),new L(n.x,s.y,s.z),new L(n.x,a.y,s.z),new L(n.x,a.y,a.z)]);break;case"Y":this.planeMesh=new _i("Y",[new L(s.x,n.y,a.z),new L(a.x,n.y,a.z),new L(a.x,n.y,s.z),new L(s.x,n.y,s.z)]);break;case"Z":this.planeMesh=new _i("Z",[new L(s.x,s.y,n.z),new L(a.x,s.y,n.z),new L(a.x,a.y,n.z),new L(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;this.gizmo=new Ec,this.gizmo.setDirection(i),this.sectionBox.getCenter(this.gizmo.position),null==(t=this.scene)||t.add(this.gizmo)}onDragStart(e){var t;if(this.selectedObject instanceof _i)return;ae.info("[AxisPlaneSection] onDragStart:",e);let i=new L;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 _i)return;let r=new L;null==(t=this.raycaster)||t.ray.intersectPlane(this.refrencePlane,r);let a=this.selectedObject.userData.actionType,s=(new L).subVectors(this.lastWorldPos,this.center).normalize(),o=(new L).subVectors(r,this.center).normalize(),l=(new L).subVectors(r,this.lastWorldPos).projectOnVector(La.clone().applyQuaternion(this.gizmo.quaternion)),h=s.angleTo(o),c=(new L).crossVectors(s,o),u=new L;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 L).addVectors(this.gizmo.position,l),this.sectionBox.clone().setFromCenterAndSize(this.center,new L(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=La.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=uf.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=hf.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 _i||ae.info("[AxisPlaneSection] onDragEnd:",e)}getIntersectObjects(){return this.planeMesh&&this.gizmo?[this.planeMesh,this.gizmo]:[]}activateSelectedObject(e){this.selectedObject&&(this.selectedObject instanceof _i?this.selectedObject.setActive(e):this.selectedObject.parent instanceof Ec&&this.selectedObject.parent.setActive(e,this.selectedObject))}},FR=class extends Nv{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(ov),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.setSectionVisible(this.isVisible)}}},BR=class extends Nv{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.setSectionVisible(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")}},WH=$i(mc(),1),Cl=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(Zd,this.follow):document.removeEventListener(Zd,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(Zd,this.follow):document.addEventListener(Zd,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,WH.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,WH.forEach)(this.childNode.children,(e=>{this.childNode.removeChild(e)})),this.childNode.append(e)}},Pl=(e=>(e.Distance="Distance",e.Area="Area",e.Angle="Angle",e.Coordinate="Coordinate",e))(Pl||{}),Lu=class extends ts{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.raycaster,this.lastMouseDownPosition),ae.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);Tn.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.raycaster,this.lastMouseDownPosition),ae.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=()=>{ae.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);ae.debug(`[BaseMeasurement] The count of raycastable object is ${t.length}`,t);let i=Date.now(),n=this.raycaster.intersectObjects(t,!0)||[];return ae.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(Tn.isMobile)this.inputManager.addEventListener("touchstart",this.touchstart),this.inputManager.addEventListener("touchmove",this.touchmove),this.inputManager.addEventListener("touchend",this.touchend);else{this.inputManager.addEventListener("pointerdown",this.mousedown),this.inputManager.addEventListener("pointermove",this.mousemove),this.inputManager.addEventListener("pointerup",this.mouseup);let e=this.viewer.translate;if(e){this.tooltip=new Cl("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;Tn.isMobile?(this.inputManager.removeEventListener("touchstart",this.touchstart),this.inputManager.removeEventListener("touchmove",this.touchmove),this.inputManager.removeEventListener("touchend",this.touchend)):(this.inputManager.removeEventListener("pointerdown",this.mousedown),this.inputManager.removeEventListener("pointermove",this.mousemove),this.inputManager.removeEventListener("pointerup",this.mouseup)),this.inputManager.removeEventListener("dblclick",this.dblclick),this.inputManager.removeEventListener("keydown",this.keydown),null==(e=this.tooltip)||e.hide(),null==(t=this.tooltip)||t.destroy(),this.tooltip=void 0,this.raycaster=void 0,this.currentMeasureDrawable&&this.removeDrawable(this.currentMeasureDrawable),this.osnapHelper.deactivate(),this.drawingPoints=void 0,this.currentMeasureDrawable=void 0,this.lastMouseDownPosition=void 0}removeDrawable(e){this.dispatchEvent("WillBeRemoved",e)}clearClickedDrawable(){this.clickedOnMeasurementDrawable&&(this.clickedOnMeasurementDrawable.selected=!1,this.clickedOnMeasurementDrawable=void 0)}onMouseClick(e){if(Tn.isMobile)return;let t=Date.now();this.lastClickTime&&t-this.lastClickTime<500||(this.lastClickTime=t,this.selectMeasurementByEvent(e))}selectMeasurementByEvent(e){if(this.clickedOnMeasurementDrawable&&(this.clickedOnMeasurementDrawable.selected=!1,this.clickedOnMeasurementDrawable=void 0),null==this.completed||!0===this.completed){let t=this.getIntersections(e)[0];if(t){let e=this.drawList.getDrawableByPosition(t.point,this.raycaster);e&&(this.dispatchEvent("ClickedOnMeasurement",e),this.clickedOnMeasurementDrawable=e)}}}onMouseMove(e){this.createOrUpdateMeasureDrawable(e)}createOrUpdateMeasureDrawable(e){if(!this.drawingPoints||this.drawingPoints&&this.drawingPoints.length<1)return;let t=[...this.drawingPoints];if(!this.currentMeasureDrawable)return this.currentMeasureDrawable=this.createMeasureDrawable(),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")}},oa=class extends Ai{constructor(e,t){super(e),this.type="Distance",this.labelBounds=new Gi,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=oa.MAJOR_COLOR,e.strokeStyle=oa.MINOR_COLOR,e.lineWidth=oa.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+oa.POINT_RADIUS,n.y),e.arc(n.x,n.y,oa.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=`${oa.LABEL_FONT_SIZE}px Arial`;let i=1.2*e.measureText(this.label).width,n=1.5*oa.LABEL_FONT_SIZE;this.labelBounds.setFromCenterAndSize(this.labelPositon,new ye(i,n)),this.drawRoundRect(e,this.labelPositon.x-i/2,this.labelPositon.y-n/2,i,n,4),e.save(),e.fillStyle=oa.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=oa.MAJOR_COLOR,e.strokeStyle=oa.MINOR_COLOR,e.lineWidth=oa.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 It).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 It).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(wn.colorStr2Rgba(oa.MAJOR_COLOR)),this.setFillColor(wn.colorStr2Rgba(oa.AREA_FILL_COLOR)),this.setLineWidth(oa.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 L,s=new L,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 ye).subVectors(i,n).normalize(),s=(new ye).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=`${vu(s,2)} ${this.getUnitString()}`;let o=.3*Math.min(i.distanceTo(n),r.distanceTo(n));this.labelPositon=this.transToScreenCoord(n.clone().add(new L(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 L(n.x-r.x,n.y-r.y,n.z-r.z).normalize(),o=new L(a.x-r.x,a.y-r.y,a.z-r.z).normalize();return new L(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 L(n.x-r.x,n.y-r.y,n.z-r.z),o=new L(a.x-r.x,a.y-r.y,a.z-r.z);return 180*s.angleTo(o)/Math.PI}getClassType(){return"Angle"}};On._registerDrawableClass(dE);var HR=class extends Lu{constructor(e,t,i,n){super("Angle",e,t,i,n)}createMeasureDrawable(){if(this.drawingPoints)return new dE(wt.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]&&$t.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))}},ff=class extends wr{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=wr.LINE_WIDTH,e.strokeStyle=wr.MAJOR_COLOR,e.fillStyle=wr.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=`${vu(n,2)}`,this.labelPositon=this.transToScreenCoord(this.getBarycenter(i),t),super.drawText(e,t)}calculateArea(e){let t=0,i=Qp.getFaces(e);for(let n=0;n{i+=e.x,n+=e.y,r+=e.z})),new L(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 L,s=new L,o=this.points;for(let h=0;hn.far&&(e=e.clone().sub(t).normalize().multiplyScalar(.9*n.far),console.warn("[BimViewer] 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 L(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 L(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 L;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 L(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()}},Zfe=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)&&ji.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)&&ji.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 ur)s=s.clone();else if(Array.isArray(s)){let e=[];s.forEach((t=>e.push(t.clone()))),s=e}let o=new Li(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 Jt.geometryEquals(e,t)}},pf=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])}},fE=class extends zp{constructor(e){super(e)}parse(e){e.length<19&&console.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++]};(function(e){switch(e.image_type){case 1:case 9:(e.colormap_length>256||24!==e.colormap_size||1!==e.colormap_type)&&console.error("THREE.TGALoader: Invalid type colormap data for indexed type.");break;case 2:case 3:case 10:case 11:e.colormap_type&&console.error("THREE.TGALoader: Invalid type colormap data for colormap type.");break;case 0:console.error("THREE.TGALoader: No data.");default:console.error('THREE.TGALoader: Invalid type "%s".',e.image_type)}(e.width<=0||e.height<=0)&&console.error("THREE.TGALoader: Invalid image size."),8!==e.pixel_size&&16!==e.pixel_size&&24!==e.pixel_size&&32!==e.pixel_size&&console.error('THREE.TGALoader: Invalid pixel size "%s".',e.pixel_size)})(n),n.id_length+t>e.length&&console.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:console.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:console.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:Ta}}},VR=class extends hr{constructor(e){super(e)}load(e,t,i,n){let r=this,a=""===r.path?Gs.extractUrlBase(e):r.path,s=new Hr(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 Za(n+".position",r,a)),s.length>0&&t.push(new Aa(n+".quaternion",r,s)),o.length>0&&t.push(new Za(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?Ei:bi,n.wrapT=e.wrapV?Ei:bi,n.offset.set(e.offsetU||0,e.offsetV||0),n.repeat.set(e.repeatU||1,e.repeatV||1)}else n.wrapS=Ei,n.wrapT=Ei;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?vr:ai;break;case"bump":t.normalMap=r(n.texture),t.normalScale=new ye(1,1)}}}return t}function K(e){return c(et.materials[e],q)}function J(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 Ft(r.array,r.stride)),a.array.length>0&&u.setAttribute("normal",new Ft(a.array,a.stride)),l.array.length>0&&u.setAttribute("color",new Ft(l.array,l.stride)),s.array.length>0&&u.setAttribute("uv",new Ft(s.array,s.stride)),o.array.length>0&&u.setAttribute("uv1",new Ft(o.array,o.stride)),h.length>0&&u.setAttribute("skinIndex",new Ft(h,4)),c.length>0&&u.setAttribute("skinWeight",new Ft(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=wa){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(XH.has(e)){let t=XH.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)})),XH.set(e,{key:i,promise:s}),s}_createGeometry(e){let t=new Lt;e.index&&t.setIndex(new pn(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=Sct.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 Kfe=function(e){return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))},Mct=function(e){return new Worker(e)};try{URL.revokeObjectURL(Kfe(""))}catch(e){Kfe=function(e){return"data:application/javascript;charset=UTF-8,"+encodeURI(e)},Mct=function(e){return new Worker(e,{type:"module"})}}var Il=Uint8Array,mf=Uint16Array,ZH=Uint32Array,Jfe=new Il([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]),Qfe=new Il([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]),Act=new Il([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),epe=function(e,t){for(var i=new mf(31),n=0;n<31;++n)i[n]=t+=1<>>1|(21845&ni)<<1,Nh=(52428&Nh)>>>2|(13107&Nh)<<2,Nh=(61680&Nh)>>>4|(3855&Nh)<<4,KH[ni]=((65280&Nh)>>>8|(255&Nh)<<8)>>>1;var Nh,ni,pE=function(e,t,i){for(var n=e.length,r=0,a=new mf(t);r>>l]=h}else for(s=new mf(n),r=0;r>>15-e[r]);return s},mE=new Il(288),ni,ni,ni;for(ni=0;ni<144;++ni)mE[ni]=8;for(ni=144;ni<256;++ni)mE[ni]=9;for(ni=256;ni<280;++ni)mE[ni]=7;for(ni=280;ni<288;++ni)mE[ni]=8;var ni,ipe=new Il(32),ni;for(ni=0;ni<32;++ni)ipe[ni]=5;var Pct=pE(mE,9,1),Ict=pE(ipe,5,1),YH=function(e){for(var t=e[0],i=1;it&&(t=e[i]);return t},_c=function(e,t,i){var n=t/8|0;return(e[n]|e[n+1]<<8)>>(7&t)&i},$H=function(e,t){var i=t/8|0;return(e[i]|e[i+1]<<8|e[i+2]<<16)>>(7&t)},Dct=function(e){return(e/8|0)+(7&e&&1)},Lct=function(e,t,i){(null==t||t<0)&&(t=0),(null==i||i>e.length)&&(i=e.length);var n=new(e instanceof mf?mf:e instanceof ZH?ZH:Il)(i-t);return n.set(e.subarray(t,i)),n},Oct=function(e,t,i){var n=e.length;if(!n||i&&!i.l&&n<5)return t||new Il(0);var r=!t||i,a=!i||i.i;i||(i={}),t||(t=new Il(3*n));var s=function(e){var i=t.length;if(e>i){var n=new Il(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=_c(e,l,1);var m=_c(e,l+1,3);if(l+=3,!m){var g=e[(A=Dct(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=Pct,u=Ict,d=9,p=5;else{if(2!=m)throw"invalid block type";var y=_c(e,l,31)+257,x=_c(e,l+10,15)+4,b=y+_c(e,l+5,31)+1;l+=14;for(var _=new Il(b),w=new Il(19),S=0;S>>4)<16)_[S++]=A;else{var P=0,R=0;for(16==A?(R=3+_c(e,l,3),l+=2,P=_[S-1]):17==A?(R=3+_c(e,l,7),l+=3):18==A&&(R=11+_c(e,l,127),l+=7);R--;)_[S++]=P}}var L=_.subarray(0,y),I=_.subarray(y);d=YH(L),p=YH(I),c=pE(L,d,1),u=pE(I,p,1)}if(l>f){if(a)throw"unexpected EOF";break}}r&&s(h+131072);for(var D=(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 F=N-254;if(N>264){var U=Jfe[S=N-257];F=_c(e,l,(1<>>4;if(!B)throw"invalid distance";if(l+=15&B,I=Cct[z],z>3&&(U=Qfe[z],I+=$H(e,l)&(1<f){if(a)throw"unexpected EOF";break}r&&s(h+131072);for(var H=h+F;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 spe(e,t){return Oct((Nct(e),e.subarray(2,-4)),t)}var Fct="undefined"!=typeof TextDecoder&&new TextDecoder,Bct=0;try{Fct.decode(kct,{stream:!0}),Bct=1}catch(e){}function ape(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 zct(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 Sr.Objects){let i=Sr.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?Ei:bi,i.wrapT=0===s?Ei:bi,"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=ls.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 Fr):(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 Fr):a=this.textureLoader.load(i);return this.textureLoader.setPath(n),a}parseMaterials(e){let t=new Map;if("Material"in Sr.Objects){let i=Sr.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),!ls.has(i))return null;let a,s=this.parseParameters(e,t,i);switch(r.toLowerCase()){case"phong":a=new zs;break;case"lambert":a=new cu;break;default:console.warn('THREE.FBXLoader: unknown material type "%s". Defaulting to MeshPhongMaterial.',r),a=new zs}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 ls.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=Dp,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 Sr.Objects&&t in Sr.Objects.LayeredTexture&&(console.warn("THREE.FBXLoader: layered textures are not supported in three.js. Discarding all but first layer."),t=ls.get(t).children[0].ID),e.get(t)}parseDeformers(){let e={},t={};if("Deformer"in Sr.Objects){let i=Sr.Objects.Deformer;for(let n in i){let r=i[n],a=ls.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 Qe).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 zs({name:hr.DEFAULT_MATERIAL_NAME,color:13421772}),s.push(a)),"color"in r.attributes&&s.forEach((function(e){e.vertexColors=!0})),r.FBX_Deformer?(n=new su(r,a),n.normalizeSkinWeights()):n=new _t(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 kn({name:hr.DEFAULT_MATERIAL_NAME,color:3342591,linewidth:1});return new rr(i,n)}getTransformData(e,t){let i={};"InheritType"in t&&(i.inheritType=parseInt(t.InheritType.value)),i.eulerOrder="RotationOrder"in t?dpe(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&&ls.get(e.ID).children.forEach((function(t){if("LookAtProperty"===t.relationship){let i=Sr.Objects.Model[t.ID];if("Lcl_Translation"in i){let t=i.Lcl_Translation.value;void 0!==e.target?(e.target.position.fromArray(t),oo.add(e.target)):e.lookAt((new L).fromArray(t))}}}))}bindSkeleton(e,t,i){let n=this.parsePoseNodes();for(let r in e){let a=e[r];ls.get(parseInt(a.ID)).parents.forEach((function(e){if(t.has(e.ID)){let t=e.ID;ls.get(t).parents.forEach((function(e){i.has(e.ID)&&i.get(e.ID).bind(new fl(a.bones),n[e.ID])}))}}))}}parsePoseNodes(){let e={};if("Pose"in Sr.Objects){let t=Sr.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 Qe).fromArray(t.Matrix.a)})):e[n.Node]=(new Qe).fromArray(n.Matrix.a)}}return e}createAmbientLight(){if("GlobalSettings"in Sr&&"AmbientColor"in Sr.GlobalSettings){let e=Sr.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();oo.add(new gl(e,1))}}}},tU=class{constructor(){this.negativeMaterialIndices=!1}parse(e){let t=new Map;if("Geometry"in Sr.Objects){let i=Sr.Objects.Geometry;for(let n in i){let r=ls.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 Sr.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=dpe(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=hpe(l);return this.genGeometry(t,s,r,h)}genGeometry(e,t,i,n){let r=new Lt;e.attrName&&(r.name=e.attrName);let a=this.parseGeoNode(e,t),s=this.genBuffers(a),o=new Ft(s.vertex,3);if(o.applyMatrix4(n),r.setAttribute("position",o),s.colors.length>0&&r.setAttribute("color",new Ft(s.colors,3)),t&&(r.setAttribute("skinIndex",new Lp(s.weightsIndices,4)),r.setAttribute("skinWeight",new Ft(s.vertexWeights,4)),r.FBX_Deformer=t),s.normal.length>0){let e=(new An).getNormalMatrix(n),t=new Ft(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 Ft(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=qR(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=qR(p,i,d,e.normal);s.push(t[0],t[1],t[2])}e.material&&"AllSame"!==e.material.mappingType&&(f=qR(p,i,d,e.material)[0],f<0&&(u.negativeMaterialIndices=!0,f=0)),e.uv&&e.uv.forEach((function(e,t){let n=qR(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 Ka(e.name,-1,t)}generateTracks(e){let t=[],i=new L,n=new ir,r=new L;if(e.transform&&e.transform.decompose(i,n,r),i=i.toArray(),n=(new zn).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 Za(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(Cn.degToRad)),void 0!==t.y&&(this.interpolateRotations(t.y),t.y.values=t.y.values.map(Cn.degToRad)),void 0!==t.z&&(this.interpolateRotations(t.z),t.z.values=t.z.values.map(Cn.degToRad));let s=this.getTimesForAllAxes(t),o=this.getKeyframeTrackValues(s,t,i);void 0!==n&&((n=n.map(Cn.degToRad)).push(a),n=(new zn).fromArray(n),n=(new ir).setFromEuler(n)),void 0!==r&&((r=r.map(Cn.degToRad)).push(a),r=(new zn).fromArray(r),r=(new ir).setFromEuler(r).invert());let l=new ir,h=new zn,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],Zct(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=QH(r))}else this.parseNodeSpecialProperty(e,n,r)}parseNodePropertyContinued(e){let t=this.getCurrentNode();t.a+=e,","!==e.slice(-1)&&(t.a=QH(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=QH(l)}this.getPrevNode()[r]={type:a,type2:s,flag:o,value:l},this.setCurrentProp(this.getPrevNode(),r)}},iU=class{parse(e){let t=new WR(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 XR;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=spe(new Uint8Array(e.getArrayBuffer(a))),o=new WR(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)}}},WR=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)}},XR=class{add(e,t){this[e]=t}};function Wct(e){return e.byteLength>=21&&"Kaydara FBX Binary \0"===fpe(e,0,21)}function Xct(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 IU(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 Jct(){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 Ur={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"},lU=class{constructor(e){this.parser=e,this.name=Ur.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)}},bU=class{constructor(e){this.parser=e,this.name=Ur.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}},EU=class{constructor(e){this.parser=e,this.name=Ur.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}},_U=class{constructor(e){this.name=Ur.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}},TU=class{constructor(e){this.name=Ur.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!==Dl.TRIANGLES&&o.mode!==Dl.TRIANGLE_STRIP&&o.mode!==Dl.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 Qe,t=new L,i=new ir,o=new L(1,1,1),l=new Li(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 aut=new Qe,IU=class{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new Jct,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 gs(this.options.manager):this.textureLoader=new Hx(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new Hr(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:{}};vm(r,a,n),vf(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=mpe[i.magFilter]||_r,t.minFilter=mpe[i.minFilter]||Ta,t.wrapS=gpe[i.wrapS]||Ei,t.wrapT=gpe[i.wrapT]||Ei,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 Fr(e);t.needsUpdate=!0,i(t)}),t.load(Gs.resolveURL(e,n.path),a,void 0,r)}))})).then((function(e){return!0===o&&a.revokeObjectURL(s),e.userData.mimeType=r.mimeType||sut(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[Ur.KHR_TEXTURE_TRANSFORM]){let e=void 0!==i.extensions?i.extensions[Ur.KHR_TEXTURE_TRANSFORM]:void 0;if(e){let t=r.associations.get(a);a=r.extensions[Ur.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 hi,ur.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 kn,ur.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 Fd}loadMaterial(e){let t,i=this,n=this.json,r=this.extensions,a=n.materials[e],s={},o=[];if((a.extensions||{})[Ur.KHR_MATERIALS_UNLIT]){let e=r[Ur.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=vr);let l=a.alphaMode||aU.OPAQUE;if(l===aU.BLEND?(s.transparent=!0,s.depthWrite=!1):(s.transparent=!1,l===aU.MASK&&(s.alphaTest=void 0!==a.alphaCutoff?a.alphaCutoff:.5)),void 0!==a.normalTexture&&t!==rn&&(o.push(i.assignTexture(s,"normalMap",a.normalTexture)),s.normalScale=new ye(1,1),void 0!==a.normalTexture.scale)){let e=a.normalTexture.scale;s.normalScale.set(e,e)}return void 0!==a.occlusionTexture&&t!==rn&&(o.push(i.assignTexture(s,"aoMap",a.occlusionTexture)),void 0!==a.occlusionTexture.strength&&(s.aoMapIntensity=a.occlusionTexture.strength)),void 0!==a.emissiveFactor&&t!==rn&&(s.emissive=(new ct).fromArray(a.emissiveFactor)),void 0!==a.emissiveTexture&&t!==rn&&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),vf(n,a),i.associations.set(n,{materials:e}),a.extensions&&vm(r,n,a),n}))}createUniqueName(e){let t=Wn.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[Ur.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then((function(i){return vpe(i,e,t)}))}let a=[];for(let s=0,o=e.length;s0&&rut(i,r),i.name=t.createUniqueName(r.name||"mesh_"+e),vf(i,r),u.extensions&&vm(n,i,u),t.assignFinalMaterial(i),l.push(i)}for(let n=0,r=l.length;n1?new Gn:1===t.length?t[0]:new sn,s!==t[0])for(let e=0,i=t.length;e{let t=new Map;for(let[i,r]of n.associations)(i instanceof ur||i instanceof Fr)&&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(gf[r.path]===gf.weights?e.traverse((function(e){e.morphTargetInfluences&&l.push(e.name?e.name:e.uuid)})):l.push(o),gf[r.path]){case gf.weights:a=ml;break;case gf.rotation:a=Aa;break;case gf.position:case gf.scale:default:switch(i.itemSize){case 1:a=ml;break;case 2:case 3:a=Za}}let h=void 0!==n.interpolation?eut[n.interpolation]:ru,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 DU(this.resourcePath||t,this.materialOptions);return s.setCrossOrigin(this.crossOrigin),s.setManager(this.manager),s.setMaterials(a),s}},DU=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:ai,this.wrap=void 0!==this.options.wrap?this.options.wrap:Ei}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 zs(n),this.materials[e]}getTextureParams(e,t){let i,n={scale:new ye(1,1),offset:new ye(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:eo,s=a.getHandler(e);null===s&&(s=new gs(a)),s.setCrossOrigin&&s.setCrossOrigin(this.crossOrigin);let o=s.load(e,i,n,r);return void 0!==t&&(o.mapping=t),o}},lut=/^[og]\s*(.+)?/,cut=/^mtllib /,uut=/^usemtl /,hut=/^usemap /,xpe=/\s+/,bpe=new L,LU=new L,Epe=new L,_pe=new L,Ll=new L,ZR=new ct;function dut(){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;bpe.fromArray(n,e),LU.fromArray(n,t),Epe.fromArray(n,i),Ll.subVectors(Epe,LU),_pe.subVectors(bpe,LU),Ll.cross(_pe),Ll.normalize(),r.push(Ll.x,Ll.y,Ll.z),r.push(Ll.x,Ll.y,Ll.z),r.push(Ll.x,Ll.y,Ll.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?(ZR.setRGB(parseFloat(i[4]),parseFloat(i[5]),parseFloat(i[6])).convertSRGBToLinear(),t.colors.push(ZR.r,ZR.g,ZR.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(xpe),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 Gn;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 Ft(i.normals,3)),i.colors.length>0&&(l=!0,h.setAttribute("color",new Ft(i.colors,3))),!0===i.hasUVIndices&&h.setAttribute("uv",new Ft(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 hi({size:1,sizeAttenuation:!1}),i=new Lt;i.setAttribute("position",new Ft(t.vertices,3)),t.colors.length>0&&void 0!==t.colors[0]&&(i.setAttribute("color",new Ft(t.colors,3)),e.vertexColors=!0);let n=new $r(i,e);r.add(n)}return r}},lo=new ct,JR=class extends hr{constructor(e){super(e),this.propertyNameMapping={},this.customPropertyMapping={}}load(e,t,i,n){let r=this,a=new Hr(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 Ft(e.vertices,3)),e.normals.length>0&&t.setAttribute("normal",new Ft(e.normals,3)),e.uvs.length>0&&t.setAttribute("uv",new Ft(e.uvs,2)),e.colors.length>0&&t.setAttribute("color",new Ft(e.colors,3)),(e.faceVertexUvs.length>0||e.faceVertexColors.length>0)&&(t=t.toNonIndexed(),e.faceVertexUvs.length>0&&t.setAttribute("uv",new Ft(e.faceVertexUvs,2)),e.faceVertexColors.length>0&&t.setAttribute("color",new Ft(e.faceVertexColors,3)));for(let i of Object.keys(d.customPropertyMapping))e[i].length>0&&t.setAttribute(i,new Ft(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&&(lo.setRGB(i[n.attrR]/255,i[n.attrG]/255,i[n.attrB]/255).convertSRGBToLinear(),e.colors.push(lo.r,lo.g,lo.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&&(lo.setRGB(i[n.attrR]/255,i[n.attrG]/255,i[n.attrB]/255).convertSRGBToLinear(),e.faceVertexColors.push(lo.r,lo.g,lo.b),e.faceVertexColors.push(lo.r,lo.g,lo.b),e.faceVertexColors.push(lo.r,lo.g,lo.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++]}},QR=class extends hr{constructor(e){super(e)}load(e,t,i,n){let r=this,a=new Hr(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 pn(p,3)),d.setAttribute("normal",new pn(f,3)),u&&(d.setAttribute("color",new pn(r,3)),d.hasColors=!0,d.alpha=l),d}(i):function(e){let t,i=new Lt,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 L,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 Ft(h,3)),i.setAttribute("normal",new Ft(c,3)),i}("string"!=typeof(n=e)?(new TextDecoder).decode(n):n);var n}},ym=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 ym(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}},Tpe=(e=>(e[e.NULL=0]="NULL",e[e.POINT=1]="POINT",e[e.POLYLINE=3]="POLYLINE",e[e.POLYGON=5]="POLYGON",e))(Tpe||{}),eC=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 Lt;a.setFromPoints(e),a.setIndex(r),t.push(a);let s=new Lt;e.length>2&&!e[0].equals(e[e.length-1])&&e.push(e[0]),s.setFromPoints(e),i.push(s)}else{let t=new Lt;t.setFromPoints(e),i.push(t)}}}var d=new sn;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 eC).parse(r.response),n=(new tC).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}))}},kU=class{constructor(e){this.manager=e}loadLocalModel(e,t,i){return dt(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")?(ae.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 dt(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 ae.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 dt(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 dt(this,null,(function*(){let i=yield new jR(this.manager).loadAsync(e,t);return Promise.resolve(i)}))}loadObj(e,t){return dt(this,null,(function*(){let i=new KR(this.manager),n=new $R(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 dt(this,null,(function*(){let i=yield new QR(this.manager).loadAsync(e,t);return Promise.resolve(new _t(i))}))}loadShp(e,t){return dt(this,null,(function*(){let i=new nC;return new Promise(((n,r)=>{i.load(e,(e=>{n(e)}),t,(e=>{r(e)}))}))}))}loadDae(e,t){return dt(this,null,(function*(){let i=yield new VR(this.manager).loadAsync(e,t);return Promise.resolve(i.scene)}))}loadDxf(e,t){return dt(this,null,(function*(){var i;this.font||console.warn("[LoadingHelper] Should set font first!");let n=new un(this.manager,{ignorePaperSpace:!0,enableLocalCache:!1});n.setFont(this.font);try{this.font&&this.font.getFontData&&(yield null==(i=this.font)?void 0:i.getFontData());let r=yield n.loadAsync(e,t);return Promise.resolve(r.threejsObject)}catch(e){let i=new ErrorEvent("");return Promise.reject(i)}}))}loadPly(e,t){return dt(this,null,(function*(){let i=yield new JR(this.manager).loadAsync(e,t);return Promise.resolve(new _t(i))}))}loadImage(e,t){return dt(this,null,(function*(){let i=yield new gs(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 rn({map:i,side:vr,transparent:!0}),o=new ti(a,r),l=new _t(o,s);return Promise.resolve(l)}))}loadDxfData(e,t,i,n,r){return dt(this,null,(function*(){var a;this.font||console.warn("[LoadingHelper] Should set font first!");let s=new un(this.manager,r);return s.setFont(this.font),s.manager.onLoad=()=>{n&&n()},this.font&&this.font.getFontData&&(yield null==(a=this.font)?void 0:a.getFontData()),s.load(e,t,i)}))}setFont(e){this.font=e}static setDracoDecoderPath(e){this.decoderPath=e}getGltfLoader(){if(!this.gltfLoader){this.gltfLoader=new Ou(this.manager);let e=new zR(this.manager);e.setDecoderPath(kU.decoderPath),this.gltfLoader.setDRACOLoader(e)}return this.gltfLoader}},Oa=kU;function NU(e){let t=new Blob([e],{type:"text/javascript"}),i=URL.createObjectURL(t),n=new Worker(i);return URL.revokeObjectURL(i),n}function FU(){return NU('var Zc=Object.defineProperty,Jc=Object.defineProperties;var $c=Object.getOwnPropertyDescriptors;var Bo=Object.getOwnPropertySymbols;var Kc=Object.prototype.hasOwnProperty,Qc=Object.prototype.propertyIsEnumerable;var zo=(i,t,e)=>t in i?Zc(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,ji=(i,t)=>{for(var e in t||(t={}))Kc.call(t,e)&&zo(i,e,t[e]);if(Bo)for(var e of Bo(t))Qc.call(t,e)&&zo(i,e,t[e]);return i},Vo=(i,t)=>Jc(i,$c(t));var po="154";var jc=0,ko=1,tl=2;var oc=1,el=2,on=3,He=0,he=1,ze=2;var Mn=0,fi=1,Ho=2,Go=3,Wo=4,nl=5,li=100,il=101,sl=102,Xo=103,qo=104,rl=200,ol=201,al=202,cl=203,ac=204,cc=205,ll=206,hl=207,ul=208,fl=209,dl=210,pl=0,ml=1,gl=2,Lr=3,_l=4,xl=5,yl=6,vl=7,lc=0,Ml=1,Sl=2,cn=0,bl=1,El=2,Tl=3,wl=4,Al=5,hc=300,mi=301,gi=302,Ir=303,Ur=304,Bs=306,Dr=1e3,Ve=1001,Nr=1002,pe=1003,Yo=1004;var er=1005;var Le=1006,Rl=1007;var ki=1008;var Sn=1009,Cl=1010,Pl=1011,mo=1012,uc=1013,yn=1014,vn=1015,Hi=1016,fc=1017,dc=1018,Fn=1020,Ll=1021,ke=1023,Il=1024,Ul=1025,On=1026,_i=1027,Dl=1028,pc=1029,Nl=1030,mc=1031,gc=1033,nr=33776,ir=33777,sr=33778,rr=33779,Zo=35840,Jo=35841,$o=35842,Ko=35843,Fl=36196,Qo=37492,jo=37496,ta=37808,ea=37809,na=37810,ia=37811,sa=37812,ra=37813,oa=37814,aa=37815,ca=37816,la=37817,ha=37818,ua=37819,fa=37820,da=37821,or=36492,Ol=36283,pa=36284,ma=36285,ga=36286;var bs=2300,Es=2301,ar=2302,_a=2400,xa=2401,ya=2402;var _c=3e3,Bn=3001,Bl=3200,zl=3201,Vl=0,kl=1,zn="",Rt="srgb",Je="srgb-linear",xc="display-p3";var cr=7680;var Hl=519,Gl=512,Wl=513,Xl=514,ql=515,Yl=516,Zl=517,Jl=518,$l=519,va=35044;var Ma="300 es",Fr=1035,an=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 Kl(i,t){return(i%t+t)%t}function hr(i,t,e){return(1-e)*i+e*t}function Sa(i){return(i&i-1)===0&&i!==0}function Br(i){return Math.pow(2,Math.floor(Math.log(i)/Math.LN2))}function ts(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 Te(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 Dt=class{constructor(t=0,e=0){Dt.prototype.isVector2=!0,this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){let e=this.x,n=this.y,s=t.elements;return this.x=s[0]*e+s[3]*n+s[6],this.y=s[1]*e+s[4]*n+s[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this}clampLength(t,e){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){let e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;let n=this.dot(t)/e;return Math.acos(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],M=s[2],T=s[5],A=s[8];return r[0]=a*x+o*v+c*M,r[3]=a*p+o*_+c*T,r[6]=a*f+o*b+c*A,r[1]=l*x+h*v+d*M,r[4]=l*p+h*_+d*T,r[7]=l*f+h*b+d*A,r[2]=u*x+m*v+g*M,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 yc(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 ba={};function zi(i){i in ba||(ba[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 Ql=new Ct().fromArray([.8224621,.0331941,.0170827,.177538,.9668058,.0723974,-1e-7,1e-7,.9105199]),jl=new Ct().fromArray([1.2249401,-.0420569,-.0196376,-.2249404,1.0420571,-.0786361,1e-7,0,1.0982735]);function th(i){return i.convertSRGBToLinear().applyMatrix3(jl)}function eh(i){return i.applyMatrix3(Ql).convertLinearToSRGB()}var nh={[Je]:i=>i,[Rt]:i=>i.convertSRGBToLinear(),[xc]:th},ih={[Je]:i=>i,[Rt]:i=>i.convertLinearToSRGB(),[xc]:eh},Ne={enabled:!0,get legacyMode(){return console.warn("THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150."),!this.enabled},set legacyMode(i){console.warn("THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150."),this.enabled=!i},get workingColorSpace(){return Je},set workingColorSpace(i){console.warn("THREE.ColorManagement: .workingColorSpace is readonly.")},convert:function(i,t,e){if(this.enabled===!1||t===e||!t||!e)return i;let n=nh[t],s=ih[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!==hc)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 zi("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace===Rt?Bn:_c}set encoding(t){zi("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=t===Bn?Rt:zn}};ge.DEFAULT_IMAGE=null;ge.DEFAULT_MAPPING=hc;ge.DEFAULT_ANISOTROPY=1;var Kt=class{constructor(t=0,e=0,n=0,s=1){Kt.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,M=(f+1)/2,T=(h+u)/4,A=(d+x)/4,L=(g+p)/4;return _>b&&_>M?_<.01?(n=0,s=.707106781,r=.707106781):(n=Math.sqrt(_),s=T/n,r=A/n):b>M?b<.01?(n=.707106781,s=0,r=.707106781):(s=Math.sqrt(b),n=T/s,r=L/s):M<.01?(n=.707106781,s=.707106781,r=0):(r=Math.sqrt(M),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}},hn=class extends bn{constructor(t=1,e=1,n={}){super(),this.isWebGLRenderTarget=!0,this.width=t,this.height=e,this.depth=1,this.scissor=new Kt(0,0,t,e),this.scissorTest=!1,this.viewport=new Kt(0,0,t,e);let s={width:t,height:e,depth:1};n.encoding!==void 0&&(zi("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:Le,this.depthBuffer=n.depthBuffer!==void 0?n.depthBuffer:!0,this.stencilBuffer=n.stencilBuffer!==void 0?n.stencilBuffer:!1,this.depthTexture=n.depthTexture!==void 0?n.depthTexture:null,this.samples=n.samples!==void 0?n.samples:0}setSize(t,e,n=1){(this.width!==t||this.height!==e||this.depth!==n)&&(this.width=t,this.height=e,this.depth=n,this.texture.image.width=t,this.texture.image.height=e,this.texture.image.depth=n,this.dispose()),this.viewport.set(0,0,t,e),this.scissor.set(0,0,t,e)}clone(){return new this.constructor().copy(this)}copy(t){this.width=t.width,this.height=t.height,this.depth=t.depth,this.scissor.copy(t.scissor),this.scissorTest=t.scissorTest,this.viewport.copy(t.viewport),this.texture=t.texture.clone(),this.texture.isRenderTargetTexture=!0;let e=Object.assign({},t.texture.image);return this.texture.source=new 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"})}},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 zr=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 M=Math.sqrt(_),T=Math.atan2(M,f*v);p=Math.sin(p*T)/M,o=Math.sin(o*T)/M}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 M=1/Math.sqrt(c*c+l*l+h*h+d*d);c*=M,l*=M,h*=M,d*=M}}t[e]=c,t[e+1]=l,t[e+2]=h,t[e+3]=d}static multiplyQuaternionsFlat(t,e,n,s,r,a){let o=n[s],c=n[s+1],l=n[s+2],h=n[s+3],d=r[a],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(Ea.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(Ea.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,Ea=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,tn),tn.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(Di),es.subVectors(this.max,Di),Jn.subVectors(t.a,Di),$n.subVectors(t.b,Di),Kn.subVectors(t.c,Di),pn.subVectors($n,Jn),mn.subVectors(Kn,$n),Pn.subVectors(Jn,Kn);let e=[0,-pn.z,pn.y,0,-mn.z,mn.y,0,-Pn.z,Pn.y,pn.z,0,-pn.x,mn.z,0,-mn.x,Pn.z,0,-Pn.x,-pn.y,pn.x,0,-mn.y,mn.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(pn,mn),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,tn).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=this.getSize(tn).length()*.5),t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()?this:(je[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),je[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),je[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),je[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),je[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),je[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),je[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),je[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(je),this)}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}},je=[new P,new P,new P,new P,new P,new P,new P,new P],tn=new P,Zn=new _e,Jn=new P,$n=new P,Kn=new P,pn=new P,mn=new P,Pn=new P,Di=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 oh=new _e,Ni=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):oh.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;Ni.subVectors(t,this.center);let e=Ni.lengthSq();if(e>this.radius*this.radius){let n=Math.sqrt(e),s=(n-this.radius)*.5;this.center.addScaledVector(Ni,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(Ni.copy(t.center).add(gr)),this.expandByPoint(Ni.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)}},en=new P,_r=new P,is=new P,gn=new P,xr=new P,ss=new P,yr=new P,Vr=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,en)),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=en.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(en.copy(this.origin).addScaledVector(this.direction,e),en.distanceToSquared(t))}distanceSqToSegment(t,e,n,s){_r.copy(t).add(e).multiplyScalar(.5),is.copy(e).sub(t).normalize(),gn.copy(this.origin).sub(_r);let r=t.distanceTo(e)*.5,a=-this.direction.dot(is),o=gn.dot(this.direction),c=-gn.dot(is),l=gn.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){en.subVectors(t.center,this.origin);let n=en.dot(this.direction),s=en.dot(en)-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,en)!==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;gn.subVectors(this.origin,t);let c=o*this.direction.dot(ss.crossVectors(gn,ss));if(c<0)return null;let l=o*this.direction.dot(xr.cross(gn));if(l<0||c+l>a)return null;let h=-o*gn.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(ah,t,ch)}lookAt(t,e,n){let s=this.elements;return we.subVectors(t,e),we.lengthSq()===0&&(we.z=1),we.normalize(),_n.crossVectors(n,we),_n.lengthSq()===0&&(Math.abs(n.z)===1?we.x+=1e-4:we.z+=1e-4,we.normalize(),_n.crossVectors(n,we)),_n.normalize(),rs.crossVectors(we,_n),s[0]=_n.x,s[4]=rs.x,s[8]=we.x,s[1]=_n.y,s[5]=rs.y,s[9]=we.y,s[2]=_n.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],M=n[15],T=s[0],A=s[4],L=s[8],y=s[12],w=s[1],z=s[5],q=s[9],I=s[13],D=s[2],O=s[6],$=s[10],k=s[14],X=s[3],J=s[7],K=s[11],B=s[15];return r[0]=a*T+o*w+c*D+l*X,r[4]=a*A+o*z+c*O+l*J,r[8]=a*L+o*q+c*$+l*K,r[12]=a*y+o*I+c*k+l*B,r[1]=h*T+d*w+u*D+m*X,r[5]=h*A+d*z+u*O+m*J,r[9]=h*L+d*q+u*$+m*K,r[13]=h*y+d*I+u*k+m*B,r[2]=g*T+x*w+p*D+f*X,r[6]=g*A+x*z+p*O+f*J,r[10]=g*L+x*q+p*$+f*K,r[14]=g*y+x*I+p*k+f*B,r[3]=v*T+_*w+b*D+M*X,r[7]=v*A+_*z+b*O+M*J,r[11]=v*L+_*q+b*$+M*K,r[15]=v*y+_*I+b*k+M*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,M=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*M;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]=M*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,M=n.x,T=n.y,A=n.z;return s[0]=(1-(x+f))*M,s[1]=(m+b)*M,s[2]=(g-_)*M,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=an){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===an)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=an){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===an)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,ah=new P(0,0,0),ch=new P(1,1,1),_n=new P,rs=new P,we=new P,Ta=new Gt,wa=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 Ta.makeRotationFromQuaternion(t),this.setFromRotationMatrix(Ta,e,n)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return wa.setFromEuler(this),this.setFromQuaternion(wa,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(Fi,t,hh),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Fi,uh,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,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),sn.subVectors(n,e),vr.subVectors(t,e);let a=Oe.dot(Oe),o=Oe.dot(sn),c=Oe.dot(vr),l=sn.dot(sn),h=sn.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,rn),rn.x>=0&&rn.y>=0&&rn.x+rn.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,rn),c.setScalar(0),c.addScaledVector(r,rn.x),c.addScaledVector(a,rn.y),c.addScaledVector(o,rn.z),c}static isFrontFacing(t,e,n,s){return Oe.subVectors(n,e),sn.subVectors(t,e),Oe.cross(sn).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),sn.subVectors(this.a,this.b),Oe.cross(sn).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 Ia.subVectors(r,s),o=(d-h)/(d-h+(m-g)),e.copy(s).addScaledVector(Ia,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)}},dh=0,yi=class extends bn{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:dh++}),this.uuid=Xi(),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=ac,this.blendDst=cc,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=Hl,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++}},vc={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=Kl(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=vc[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))&&(Ua.copy(r).invert(),In.copy(t.ray).applyMatrix4(Ua),!(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=mh(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 Dt)),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 Dt),h.uv2=h.uv1),a&&(Na.fromBufferAttribute(a,o),Fa.fromBufferAttribute(a,c),Oa.fromBufferAttribute(a,l),h.normal=se.getInterpolation(ms,ii,si,ri,Na,Fa,Oa,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 ln(l,3)),this.setAttribute("normal",new ln(h,3)),this.setAttribute("uv",new ln(d,2));function g(x,p,f,v,_,b,M,T,A,L,y){let w=b/A,z=M/L,q=b/2,I=M/2,D=T/2,O=A+1,$=L+1,k=0,X=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),k+=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 ye{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Gt,this.projectionMatrix=new Gt,this.projectionMatrixInverse=new Gt,this.coordinateSystem=an}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,kr=class extends ye{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===an)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.toneMapping,u=t.xr.enabled;t.toneMapping=cn,t.xr.enabled=!1;let m=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=m,t.setRenderTarget(n,5),t.render(e,l),t.setRenderTarget(h),t.toneMapping=d,t.xr.enabled=u,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}},Hr=class extends hn{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&&(zi("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:Le}fromEquirectangularTexture(t,e){this.texture.type=e.type,this.texture.colorSpace=e.colorSpace,this.texture.generateMipmaps=e.generateMipmaps,this.texture.minFilter=e.minFilter,this.texture.magFilter=e.magFilter;let n={uniforms:{tEquirect:{value:null}},vertexShader:`\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\tvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\n\t\t\t\t\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t\t\t\t\t#include \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 un({name:"CubemapFromEquirect",uniforms:vi(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:he,blending:Mn});r.uniforms.tEquirect.value=e;let a=new Ze(s,r),o=e.minFilter;return e.minFilter===ki&&(e.minFilter=Le),new kr(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,vh=new P,Mh=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(vh.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||Mh.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=an){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===an)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 Sc(){let i=null,t=!1,e=null,n=null;function s(r,a){e(r,a),n=i.requestAnimationFrame(s)}return{start:function(){t!==!0&&e!==null&&(n=i.requestAnimationFrame(s),t=!0)},stop:function(){i.cancelAnimationFrame(n),t=!1},setAnimationLoop:function(r){e=r},setContext:function(r){i=r}}}function Sh(i,t){let e=t.isWebGL2,n=new WeakMap;function s(l,h){let d=l.array,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`,Oh=`#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif`,Bh=`#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n#endif`,zh=`#if NUM_CLIPPING_PLANES > 0\n\tvClipPosition = - mvPosition.xyz;\n#endif`,Vh=`#if defined( USE_COLOR_ALPHA )\n\tdiffuseColor *= vColor;\n#elif defined( USE_COLOR )\n\tdiffuseColor.rgb *= vColor;\n#endif`,kh=`#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR )\n\tvarying vec3 vColor;\n#endif`,Hh=`#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvarying vec3 vColor;\n#endif`,Gh=`#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`,Wh=`#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`,Xh=`#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`,qh=`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`,Yh=`#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif`,Zh=`#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );\n#endif`,Jh=`#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif`,$h=`#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif`,Kh="gl_FragColor = linearToOutputTexel( gl_FragColor );",Qh=`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}`,jh=`#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`,tu=`#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`,eu=`#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`,nu=`#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`,iu=`#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`,su=`#ifdef USE_FOG\n\tvFogDepth = - mvPosition.z;\n#endif`,ru=`#ifdef USE_FOG\n\tvarying float vFogDepth;\n#endif`,ou=`#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`,au=`#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`,cu=`#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}`,lu=`#ifdef USE_LIGHTMAP\n\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\treflectedLight.indirectDiffuse += lightMapIrradiance;\n#endif`,hu=`#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif`,uu=`LambertMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularStrength = specularStrength;`,fu=`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`,du=`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`,pu=`#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`,mu=`ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;`,gu=`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`,_u=`BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;`,xu=`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`,yu=`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`,vu=`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}`,Mu=`\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`,Su=`#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`,bu=`#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`,Eu=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif`,Tu=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif`,wu=`#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t\tvarying float vIsPerspective;\n\t#else\n\t\tuniform float logDepthBufFC;\n\t#endif\n#endif`,Au=`#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n\t#else\n\t\tif ( isPerspectiveMatrix( projectionMatrix ) ) {\n\t\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\t\t\tgl_Position.z *= gl_Position.w;\n\t\t}\n\t#endif\n#endif`,Ru=`#ifdef USE_MAP\n\tdiffuseColor *= texture2D( map, vMapUv );\n#endif`,Cu=`#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif`,Pu=`#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`,Lu=`#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`,Iu=`float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif`,Uu=`#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif`,Du=`#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`,Nu=`#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`,Fu=`#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`,Ou=`#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`,Bu=`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;`,zu=`#ifdef USE_NORMALMAP_OBJECTSPACE\n\tnormal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( USE_NORMALMAP_TANGENTSPACE )\n\tvec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\tmapN.xy *= normalScale;\n\tnormal = normalize( tbn * mapN );\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );\n#endif`,Vu=`#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif`,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\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`,Gu=`#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`,Wu=`#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal = geometryNormal;\n#endif`,Xu=`#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`,qu=`#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`,Yu=`#ifdef USE_IRIDESCENCEMAP\n\tuniform sampler2D iridescenceMap;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform sampler2D iridescenceThicknessMap;\n#endif`,Zu=`#ifdef OPAQUE\ndiffuseColor.a = 1.0;\n#endif\n#ifdef USE_TRANSMISSION\ndiffuseColor.a *= material.transmissionAlpha;\n#endif\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );`,Ju=`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}`,$u=`#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif`,Ku=`vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;`,Qu=`#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif`,ju=`#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`,tf=`float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );\n\troughnessFactor *= texelRoughness.g;\n#endif`,ef=`#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif`,nf=`#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`,sf=`#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`,rf=`#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`,of=`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}`,af=`#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`,cf=`#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`,lf=`#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`,hf=`#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`,uf=`float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif`,ff=`#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif`,df=`#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif`,pf=`#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; }`,mf=`#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`,gf=`#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`,_f=`#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`,xf=`#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`,yf=`#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`,vf=`#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`,Mf=`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}`,Sf=`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}`,bf=`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}`,Ef=`#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}`,Tf=`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}`,wf=`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}`,Af=`#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}`,Rf=`#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}`,Cf=`#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}`,Pf=`#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}`,Lf=`varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n}`,If=`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}`,Uf=`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}`,Df=`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}`,Nf=`#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}`,Ff=`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}`,Of=`#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}`,Bf=`#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}`,zf=`#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}`,Vf=`#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}`,kf=`#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}`,Hf=`#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}`,Gf=`#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}`,Wf=`#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}`,Xf=`#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}`,qf=`#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}`,Yf=`#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}`,Zf=`#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}`,Jf=`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}`,$f=`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}`,Kf=`#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}`,Qf=`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}`,jf=`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}`,td=`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:bh,alphahash_pars_fragment:Eh,alphamap_fragment:Th,alphamap_pars_fragment:wh,alphatest_fragment:Ah,alphatest_pars_fragment:Rh,aomap_fragment:Ch,aomap_pars_fragment:Ph,begin_vertex:Lh,beginnormal_vertex:Ih,bsdfs:Uh,iridescence_fragment:Dh,bumpmap_pars_fragment:Nh,clipping_planes_fragment:Fh,clipping_planes_pars_fragment:Oh,clipping_planes_pars_vertex:Bh,clipping_planes_vertex:zh,color_fragment:Vh,color_pars_fragment:kh,color_pars_vertex:Hh,color_vertex:Gh,common:Wh,cube_uv_reflection_fragment:Xh,defaultnormal_vertex:qh,displacementmap_pars_vertex:Yh,displacementmap_vertex:Zh,emissivemap_fragment:Jh,emissivemap_pars_fragment:$h,colorspace_fragment:Kh,colorspace_pars_fragment:Qh,envmap_fragment:jh,envmap_common_pars_fragment:tu,envmap_pars_fragment:eu,envmap_pars_vertex:nu,envmap_physical_pars_fragment:pu,envmap_vertex:iu,fog_vertex:su,fog_pars_vertex:ru,fog_fragment:ou,fog_pars_fragment:au,gradientmap_pars_fragment:cu,lightmap_fragment:lu,lightmap_pars_fragment:hu,lights_lambert_fragment:uu,lights_lambert_pars_fragment:fu,lights_pars_begin:du,lights_toon_fragment:mu,lights_toon_pars_fragment:gu,lights_phong_fragment:_u,lights_phong_pars_fragment:xu,lights_physical_fragment:yu,lights_physical_pars_fragment:vu,lights_fragment_begin:Mu,lights_fragment_maps:Su,lights_fragment_end:bu,logdepthbuf_fragment:Eu,logdepthbuf_pars_fragment:Tu,logdepthbuf_pars_vertex:wu,logdepthbuf_vertex:Au,map_fragment:Ru,map_pars_fragment:Cu,map_particle_fragment:Pu,map_particle_pars_fragment:Lu,metalnessmap_fragment:Iu,metalnessmap_pars_fragment:Uu,morphcolor_vertex:Du,morphnormal_vertex:Nu,morphtarget_pars_vertex:Fu,morphtarget_vertex:Ou,normal_fragment_begin:Bu,normal_fragment_maps:zu,normal_pars_fragment:Vu,normal_pars_vertex:ku,normal_vertex:Hu,normalmap_pars_fragment:Gu,clearcoat_normal_fragment_begin:Wu,clearcoat_normal_fragment_maps:Xu,clearcoat_pars_fragment:qu,iridescence_pars_fragment:Yu,opaque_fragment:Zu,packing:Ju,premultiplied_alpha_fragment:$u,project_vertex:Ku,dithering_fragment:Qu,dithering_pars_fragment:ju,roughnessmap_fragment:tf,roughnessmap_pars_fragment:ef,shadowmap_pars_fragment:nf,shadowmap_pars_vertex:sf,shadowmap_vertex:rf,shadowmask_pars_fragment:of,skinbase_vertex:af,skinning_pars_vertex:cf,skinning_vertex:lf,skinnormal_vertex:hf,specularmap_fragment:uf,specularmap_pars_fragment:ff,tonemapping_fragment:df,tonemapping_pars_fragment:pf,transmission_fragment:mf,transmission_pars_fragment:gf,uv_pars_fragment:_f,uv_pars_vertex:xf,uv_vertex:yf,worldpos_vertex:vf,background_vert:Mf,background_frag:Sf,backgroundCube_vert:bf,backgroundCube_frag:Ef,cube_vert:Tf,cube_frag:wf,depth_vert:Af,depth_frag:Rf,distanceRGBA_vert:Cf,distanceRGBA_frag:Pf,equirect_vert:Lf,equirect_frag:If,linedashed_vert:Uf,linedashed_frag:Df,meshbasic_vert:Nf,meshbasic_frag:Ff,meshlambert_vert:Of,meshlambert_frag:Bf,meshmatcap_vert:zf,meshmatcap_frag:Vf,meshnormal_vert:kf,meshnormal_frag:Hf,meshphong_vert:Gf,meshphong_frag:Wf,meshphysical_vert:Xf,meshphysical_frag:qf,meshtoon_vert:Yf,meshtoon_frag:Zf,points_vert:Jf,points_frag:$f,shadow_vert:Kf,shadow_frag:Qf,sprite_vert:jf,sprite_frag:td},et={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 Dt(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Ct},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Ct}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Ct}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Ct}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new 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 Dt(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Ct},alphaMap:{value:null},alphaMapTransform:{value:new Ct},alphaTest:{value:0}}},Ye={basic:{uniforms:de([et.common,et.specularmap,et.envmap,et.aomap,et.lightmap,et.fog]),vertexShader:At.meshbasic_vert,fragmentShader:At.meshbasic_frag},lambert:{uniforms:de([et.common,et.specularmap,et.envmap,et.aomap,et.lightmap,et.emissivemap,et.bumpmap,et.normalmap,et.displacementmap,et.fog,et.lights,{emissive:{value:new kt(0)}}]),vertexShader:At.meshlambert_vert,fragmentShader:At.meshlambert_frag},phong:{uniforms:de([et.common,et.specularmap,et.envmap,et.aomap,et.lightmap,et.emissivemap,et.bumpmap,et.normalmap,et.displacementmap,et.fog,et.lights,{emissive:{value:new kt(0)},specular:{value:new kt(1118481)},shininess:{value:30}}]),vertexShader:At.meshphong_vert,fragmentShader:At.meshphong_frag},standard:{uniforms:de([et.common,et.envmap,et.aomap,et.lightmap,et.emissivemap,et.bumpmap,et.normalmap,et.displacementmap,et.roughnessmap,et.metalnessmap,et.fog,et.lights,{emissive:{value:new kt(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:At.meshphysical_vert,fragmentShader:At.meshphysical_frag},toon:{uniforms:de([et.common,et.aomap,et.lightmap,et.emissivemap,et.bumpmap,et.normalmap,et.displacementmap,et.gradientmap,et.fog,et.lights,{emissive:{value:new kt(0)}}]),vertexShader:At.meshtoon_vert,fragmentShader:At.meshtoon_frag},matcap:{uniforms:de([et.common,et.bumpmap,et.normalmap,et.displacementmap,et.fog,{matcap:{value:null}}]),vertexShader:At.meshmatcap_vert,fragmentShader:At.meshmatcap_frag},points:{uniforms:de([et.points,et.fog]),vertexShader:At.points_vert,fragmentShader:At.points_frag},dashed:{uniforms:de([et.common,et.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:At.linedashed_vert,fragmentShader:At.linedashed_frag},depth:{uniforms:de([et.common,et.displacementmap]),vertexShader:At.depth_vert,fragmentShader:At.depth_frag},normal:{uniforms:de([et.common,et.bumpmap,et.normalmap,et.displacementmap,{opacity:{value:1}}]),vertexShader:At.meshnormal_vert,fragmentShader:At.meshnormal_frag},sprite:{uniforms:de([et.sprite,et.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([et.common,et.displacementmap,{referencePosition:{value:new P},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:At.distanceRGBA_vert,fragmentShader:At.distanceRGBA_frag},shadow:{uniforms:de([et.lights,et.fog,{color:{value:new kt(0)},opacity:{value:1}}]),vertexShader:At.shadow_vert,fragmentShader:At.shadow_frag}};Ye.physical={uniforms:de([Ye.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Ct},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Ct},clearcoatNormalScale:{value:new Dt(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Ct},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Ct},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Ct},sheen:{value:0},sheenColor:{value:new 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 Dt},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 Dt},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Ct}}]),vertexShader:At.meshphysical_vert,fragmentShader:At.meshphysical_frag};var ys={r:0,b:0,g:0};function ed(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 Ze(new kn(1,1,1),new un({name:"BackgroundCubeMaterial",uniforms:vi(Ye.backgroundCube.uniforms),vertexShader:Ye.backgroundCube.vertexShader,fragmentShader:Ye.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 Ze(new Gi(2,2),new un({name:"BackgroundMaterial",uniforms:vi(Ye.background.uniforms),vertexShader:Ye.background.vertexShader,fragmentShader:Ye.background.fragmentShader,side:He,depthTest:!1,depthWrite:!1,fog:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),s.update(l)),l.material.uniforms.t2D.value=_,l.material.uniforms.backgroundIntensity.value=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,Mc(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 nd(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,$,k,X){let J=!1;if(a){let K=x(k,$,O);l!==K&&(l=K,m(l.object)),J=f(D,k,$,X),J&&v(D,k,$,X)}else{let K=O.wireframe===!0;(l.geometry!==k.id||l.program!==$.id||l.wireframe!==K)&&(l.geometry=k.id,l.program=$.id,l.wireframe=K,J=!0)}X!==null&&e.update(X,i.ELEMENT_ARRAY_BUFFER),(J||h)&&(h=!1,L(D,O,$,k),X!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e.get(X).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 k=$.wireframe===!0,X=o[D.id];X===void 0&&(X={},o[D.id]=X);let J=X[O.id];J===void 0&&(J={},X[O.id]=J);let K=J[k];return K===void 0&&(K=p(u()),J[k]=K),K}function p(D){let O=[],$=[],k=[];for(let X=0;X=0){let at=X[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!==k}function v(D,O,$,k){let X={},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),X[Z]=ct,K++}l.attributes=X,l.attributesNum=K,l.index=k}function _(){let D=l.newAttributes;for(let O=0,$=D.length;O<$;O++)D[O]=0}function b(D){M(D,0)}function M(D,O){let $=l.newAttributes,k=l.enabledAttributes,X=l.attributeDivisors;$[D]=1,k[D]===0&&(i.enableVertexAttribArray(D),k[D]=1),X[D]!==O&&((n.isWebGL2?i:t.get("ANGLE_instanced_arrays"))[n.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](D,O),X[D]=O)}function T(){let D=l.newAttributes,O=l.enabledAttributes;for(let $=0,k=O.length;$=0){let ot=X[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,gt=e.get(ot);if(gt===void 0)continue;let Et=gt.buffer,xt=gt.type,zt=gt.bytesPerElement,xe=n.isWebGL2===!0&&(xt===i.INT||xt===i.UNSIGNED_INT||ot.gpuType===uc);if(ot.isInterleavedBufferAttribute){let Ut=ot.data,N=Ut.stride,oe=ot.offset;if(Ut.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"),M=_&&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:M,maxSamples:T}}function rd(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 M=0;M!==_;++M)b[M]=e[M];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 Hr(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 Gr=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,Ba=[.125,.215,.35,.446,.526,.582],Nn=20,Rr=new Gr,za=new kt,Cr=null,Dn=(1+Math.sqrt(5))/2,ci=1/Dn,Va=[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=Ga(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Ha(),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=Ga()),this._cubemapMaterial.uniforms.flipEnvMap.value=t.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Ha());let r=s?this._cubemapMaterial:this._equirectMaterial,a=new Ze(this._lodPlanes[0],r),o=r.uniforms;o.envMap.value=t;let c=this._cubeSize;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,M,T,3*b,2*b),c.setRenderTarget(e),c.render(d,Rr)}};function ad(i){let t=[],e=[],n=[],s=i,r=i-hi+1+Ba.length;for(let a=0;ai-hi?c=Ba[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 M=new Ge;M.setAttribute("position",new Qt(v,x)),M.setAttribute("uv",new Qt(_,p)),M.setAttribute("faceIndex",new Qt(b,f)),t.push(M),s>hi&&s--}return{lodPlanes:t,sizeLods:e,sigmas:n}}function ka(i,t,e){let n=new hn(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 cd(i,t,e){let n=new Float32Array(Nn),s=new P(0,1,0);return new un({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:go(),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:Mn,depthTest:!1,depthWrite:!1})}function Ha(){return new un({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:go(),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:Mn,depthTest:!1,depthWrite:!1})}function Ga(){return new un({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:go(),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:Mn,depthTest:!1,depthWrite:!1})}function go(){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 ld(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),q=new Cs(z,y,w,g);q.type=vn,q.needsUpdate=!0;let I=L*4;for(let O=0;O0)return i;let s=t*e,r=Wa[s];if(r===void 0&&(r=new Float32Array(s),Wa[s]=r),t!==0){n.toArray(r,0);for(let a=1,o=0;a!==t;++a)o+=e,i[a].toArray(r,o)}return r}function jt(i,t){if(i.length!==t.length)return!1;for(let e=0,n=i.length;e":" "} ${o}: ${e[a]}`)}return n.join(`\n`)}function ap(i){switch(i){case Je:return["Linear","( value )"];case Rt:return["sRGB","( value )"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",i),["Linear","( value )"]}}function Ka(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`+op(i.getShaderSource(t),a)}else return s}function cp(i,t){let e=ap(t);return"vec4 "+i+"( vec4 value ) { return LinearTo"+e[0]+e[1]+"; }"}function lp(i,t){let e;switch(t){case bl:e="Linear";break;case El:e="Reinhard";break;case Tl:e="OptimizedCineon";break;case wl:e="ACESFilmic";break;case Al:e="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",t),e="Linear"}return"vec3 "+i+"( vec3 color ) { return "+e+"ToneMapping( color ); }"}function hp(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(Bi).join(`\n`)}function up(i){let t=[];for(let e in i){let n=i[e];n!==!1&&t.push("#define "+e+" "+n)}return t.join(`\n`)}function fp(i,t){let e={},n=i.getProgramParameter(t,i.ACTIVE_ATTRIBUTES);for(let s=0;s/gm;function Yr(i){return i.replace(dp,mp)}var pp=new Map([["encodings_fragment","colorspace_fragment"],["encodings_pars_fragment","colorspace_pars_fragment"],["output_fragment","opaque_fragment"]]);function mp(i,t){let e=At[t];if(e===void 0){let n=pp.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 Yr(e)}var gp=/#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 tc(i){return i.replace(gp,_p)}function _p(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(Bi).join(`\n`),f.length>0&&(f+=`\n`)):(p=[ec(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(Bi).join(`\n`),f=[m,ec(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!==cn?"#define TONE_MAPPING":"",e.toneMapping!==cn?At.tonemapping_pars_fragment:"",e.toneMapping!==cn?lp("toneMapping",e.toneMapping):"",e.dithering?"#define DITHERING":"",e.opaque?"#define OPAQUE":"",At.colorspace_pars_fragment,cp("linearToOutputTexel",e.outputColorSpace),e.useDepthPacking?"#define DEPTH_PACKING "+e.depthPacking:"",`\n`].filter(Bi).join(`\n`)),a=Yr(a),a=Qa(a,e),a=ja(a,e),o=Yr(o),o=Qa(o,e),o=ja(o,e),a=tc(a),o=tc(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===Ma?"":"layout(location = 0) out highp vec4 pc_fragColor;",e.glslVersion===Ma?"":"#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,M=$a(s,s.VERTEX_SHADER,_),T=$a(s,s.FRAGMENT_SHADER,b);if(s.attachShader(x,M),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(M).trim(),z=s.getShaderInfoLog(T).trim(),q=!0,I=!0;if(s.getProgramParameter(x,s.LINK_STATUS)===!1)if(q=!1,typeof i.debug.onShaderError=="function")i.debug.onShaderError(s,x,M,T);else{let D=Ka(s,M,"vertex"),O=Ka(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:q,programLog:y,vertexShader:{log:w,prefix:p},fragmentShader:{log:z,prefix:f}})}s.deleteShader(M),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=fp(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=rp++,this.cacheKey=t,this.usedTimes=1,this.program=x,this.vertexShader=M,this.fragmentShader=T,this}var Ep=0,Zr=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 Jr(t),e.set(t,n)),n}},Jr=class{constructor(t){this.id=Ep++,this.code=t,this.usedTimes=0}};function Tp(i,t,e,n,s,r,a){let o=new Ps,c=new Zr,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,q,I){let D=q.fog,O=I.geometry,$=y.isMeshStandardMaterial?q.environment:null,k=(y.isMeshStandardMaterial?e:t).get(y.envMap||$),X=k&&k.mapping===Bs?k.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,gt;if(J){let Xe=Ye[J];ot=Xe.vertexShader,at=Xe.fragmentShader}else ot=y.vertexShader,at=y.fragmentShader,c.update(y),ct=c.getVertexShaderID(y),gt=c.getFragmentShaderID(y);let Et=i.getRenderTarget(),xt=I.isInstancedMesh===!0,zt=!!y.map,xe=!!y.matcap,Ut=!!k,N=!!y.aoMap,oe=!!y.lightMap,yt=!!y.bumpMap,Tt=!!y.normalMap,St=!!y.displacementMap,Wt=!!y.emissiveMap,Nt=!!y.metalnessMap,Pt=!!y.roughnessMap,Vt=y.anisotropy>0,re=y.clearcoat>0,ae=y.iridescence>0,R=y.sheen>0,S=y.transmission>0,G=Vt&&!!y.anisotropyMap,Q=re&&!!y.clearcoatMap,j=re&&!!y.clearcoatNormalMap,it=re&&!!y.clearcoatRoughnessMap,ft=ae&&!!y.iridescenceMap,st=ae&&!!y.iridescenceThicknessMap,Y=R&&!!y.sheenColorMap,dt=R&&!!y.sheenRoughnessMap,pt=!!y.specularMap,_t=!!y.specularColorMap,ht=!!y.specularIntensityMap,ut=S&&!!y.transmissionMap,Lt=S&&!!y.thicknessMap,Ht=!!y.gradientMap,C=!!y.alphaMap,nt=y.alphaTest>0,V=!!y.alphaHash,tt=!!y.extensions,rt=!!O.attributes.uv1,Ot=!!O.attributes.uv2,Xt=!!O.attributes.uv3;return{isWebGL2:h,shaderID:J,shaderType:y.type,shaderName:y.name,vertexShader:ot,fragmentShader:at,defines:y.defines,customVertexShaderID:ct,customFragmentShaderID:gt,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:Je,map:zt,matcap:xe,envMap:Ut,envMapMode:Ut&&k.mapping,envMapCubeUVHeight:X,aoMap:N,lightMap:oe,bumpMap:yt,normalMap:Tt,displacementMap:u&&St,emissiveMap:Wt,normalMapObjectSpace:Tt&&y.normalMapType===kl,normalMapTangentSpace:Tt&&y.normalMapType===Vl,metalnessMap:Nt,roughnessMap:Pt,anisotropy:Vt,anisotropyMap:G,clearcoat:re,clearcoatMap:Q,clearcoatNormalMap:j,clearcoatRoughnessMap:it,iridescence:ae,iridescenceMap:ft,iridescenceThicknessMap:st,sheen:R,sheenColorMap:Y,sheenRoughnessMap:dt,specularMap:pt,specularColorMap:_t,specularIntensityMap:ht,transmission:S,transmissionMap:ut,thicknessMap:Lt,gradientMap:Ht,opaque:y.transparent===!1&&y.blending===fi,alphaMap:C,alphaTest:nt,alphaHash:V,combine:y.combine,mapUv:zt&&x(y.map.channel),aoMapUv:N&&x(y.aoMap.channel),lightMapUv:oe&&x(y.lightMap.channel),bumpMapUv:yt&&x(y.bumpMap.channel),normalMapUv:Tt&&x(y.normalMap.channel),displacementMapUv:St&&x(y.displacementMap.channel),emissiveMapUv:Wt&&x(y.emissiveMap.channel),metalnessMapUv:Nt&&x(y.metalnessMap.channel),roughnessMapUv:Pt&&x(y.roughnessMap.channel),anisotropyMapUv:G&&x(y.anisotropyMap.channel),clearcoatMapUv:Q&&x(y.clearcoatMap.channel),clearcoatNormalMapUv:j&&x(y.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:it&&x(y.clearcoatRoughnessMap.channel),iridescenceMapUv:ft&&x(y.iridescenceMap.channel),iridescenceThicknessMapUv:st&&x(y.iridescenceThicknessMap.channel),sheenColorMapUv:Y&&x(y.sheenColorMap.channel),sheenRoughnessMapUv:dt&&x(y.sheenRoughnessMap.channel),specularMapUv:pt&&x(y.specularMap.channel),specularColorMapUv:_t&&x(y.specularColorMap.channel),specularIntensityMapUv:ht&&x(y.specularIntensityMap.channel),transmissionMapUv:ut&&x(y.transmissionMap.channel),thicknessMapUv:Lt&&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:Xt,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:y.toneMapped?i.toneMapping:cn,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:tt&&y.extensions.derivatives===!0,extensionFragDepth:tt&&y.extensions.fragDepth===!0,extensionDrawBuffers:tt&&y.extensions.drawBuffers===!0,extensionShaderTextureLOD:tt&&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 q=Ye[w];z=_h.clone(q.uniforms)}else z=y.uniforms;return z}function M(y,w){let z;for(let q=0,I=l.length;q0?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||Ap),n.length>1&&n.sort(u||nc),s.length>1&&s.sort(u||nc)}function h(){for(let d=t,u=i.length;d=r.length?(a=new ic,r.push(a)):a=r[s],a}function e(){i=new WeakMap}return{get:t,dispose:e}}function Cp(){let i={};return{get:function(t){if(i[t.id]!==void 0)return i[t.id];let e;switch(t.type){case"DirectionalLight":e={direction:new P,color:new 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 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={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Dt};break;case"SpotLight":e={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Dt};break;case"PointLight":e={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Dt,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[t.id]=e,e}}}var Lp=0;function Ip(i,t){return(t.castShadow?2:0)-(i.castShadow?2:0)+(t.map?1:0)-(i.map?1:0)}function Up(i,t){let e=new Cp,n=Pp(),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,M=0,T=0,A=0,L=0;h.sort(Ip);let y=d===!0?Math.PI:1;for(let z=0,q=h.length;z0&&(t.isWebGL2||i.has("OES_texture_float_linear")===!0?(s.rectAreaLTC1=et.LTC_FLOAT_1,s.rectAreaLTC2=et.LTC_FLOAT_2):i.has("OES_texture_half_float_linear")===!0?(s.rectAreaLTC1=et.LTC_HALF_1,s.rectAreaLTC2=et.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),s.ambient[0]=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!==M||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=M,s.pointShadowMap.length=M,s.spotShadow.length=T,s.spotShadowMap.length=T,s.directionalShadowMatrix.length=b,s.pointShadowMatrix.length=M,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=M,w.numSpotShadows=T,w.numSpotMaps=A,s.version=Lp++)}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 M=s.directional[u];M.direction.setFromMatrixPosition(b.matrixWorld),r.setFromMatrixPosition(b.target.matrixWorld),M.direction.sub(r),M.direction.transformDirection(f),u++}else if(b.isSpotLight){let M=s.spot[g];M.position.setFromMatrixPosition(b.matrixWorld),M.position.applyMatrix4(f),M.direction.setFromMatrixPosition(b.matrixWorld),r.setFromMatrixPosition(b.target.matrixWorld),M.direction.sub(r),M.direction.transformDirection(f),g++}else if(b.isRectAreaLight){let M=s.rectArea[x];M.position.setFromMatrixPosition(b.matrixWorld),M.position.applyMatrix4(f),o.identity(),a.copy(b.matrixWorld),a.premultiply(f),o.extractRotation(a),M.halfWidth.set(b.width*.5,0,0),M.halfHeight.set(0,b.height*.5,0),M.halfWidth.applyMatrix4(o),M.halfHeight.applyMatrix4(o),x++}else if(b.isPointLight){let M=s.point[m];M.position.setFromMatrixPosition(b.matrixWorld),M.position.applyMatrix4(f),m++}else if(b.isHemisphereLight){let M=s.hemi[p];M.direction.setFromMatrixPosition(b.matrixWorld),M.direction.transformDirection(f),p++}}}return{setup:c,setupView:l,state:s}}function sc(i,t){let e=new Up(i,t),n=[],s=[];function r(){n.length=0,s.length=0}function a(d){n.push(d)}function o(d){s.push(d)}function c(d){e.setup(n,d)}function l(d){e.setupView(n,d)}return{init:r,state:{lightsArray:n,shadowsArray:s,lights:e},setupLights:c,setupLightsView:l,pushLight:a,pushShadow:o}}function Dp(i,t){let e=new WeakMap;function n(r,a=0){let o=e.get(r),c;return o===void 0?(c=new sc(i,t),e.set(r,[c])):a>=o.length?(c=new sc(i,t),o.push(c)):c=o[a],c}function s(){e=new WeakMap}return{get:n,dispose:s}}var $r=class extends yi{constructor(t){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Bl,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}},Kr=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}},Np=`void main() {\n\tgl_Position = vec4( position, 1.0 );\n}`,Fp=`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 Op(i,t,e){let n=new Fs,s=new Dt,r=new Dt,a=new Kt,o=new $r({depthPacking:zl}),c=new Kr,l={},h=e.maxTextureSize,d={[He]:he,[he]:He,[ze]:ze},u=new un({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Dt},radius:{value:4}},vertexShader:Np,fragmentShader:Fp}),m=u.clone();m.defines.HORIZONTAL_PASS=1;let g=new Ge;g.setAttribute("position",new Qt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let x=new Ze(g,u),p=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=oc;let f=this.type;this.render=function(M,T,A){if(p.enabled===!1||p.autoUpdate===!1&&p.needsUpdate===!1||M.length===0)return;let L=i.getRenderTarget(),y=i.getActiveCubeFace(),w=i.getActiveMipmapLevel(),z=i.state;z.setBlending(Mn),z.buffers.color.setClear(1,1,1,1),z.buffers.depth.setTest(!0),z.setScissorTest(!1);let q=f!==on&&this.type===on,I=f===on&&this.type!==on;for(let D=0,O=M.length;Dh||s.y>h)&&(s.x>h&&(r.x=Math.floor(h/X.x),s.x=r.x*X.x,k.mapSize.x=r.x),s.y>h&&(r.y=Math.floor(h/X.y),s.y=r.y*X.y,k.mapSize.y=r.y)),k.map===null||q===!0||I===!0){let K=this.type!==on?{minFilter:pe,magFilter:pe}:{};k.map!==null&&k.map.dispose(),k.map=new hn(s.x,s.y,K),k.map.texture.name=$.name+".shadowMap",k.camera.updateProjectionMatrix()}i.setRenderTarget(k.map),i.clear();let J=k.getViewportCount();for(let K=0;K0||T.map&&T.alphaTest>0){let z=y.uuid,q=T.uuid,I=l[z];I===void 0&&(I={},l[z]=I);let D=I[q];D===void 0&&(D=y.clone(),I[q]=D),y=D}if(y.visible=T.visible,y.wireframe=T.wireframe,L===on?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(M,T,A,L,y){if(M.visible===!1)return;if(M.layers.test(T.layers)&&(M.isMesh||M.isLine||M.isPoints)&&(M.castShadow||M.receiveShadow&&y===on)&&(!M.frustumCulled||n.intersectsObject(M))){M.modelViewMatrix.multiplyMatrices(A.matrixWorldInverse,M.matrixWorld);let q=t.update(M),I=M.material;if(Array.isArray(I)){let D=q.groups;for(let O=0,$=D.length;O<$;O++){let k=D[O],X=I[k.materialIndex];if(X&&X.visible){let J=_(M,X,L,y);i.renderBufferDirect(A,null,q,J,M,k)}}}else if(I.visible){let D=_(M,I,L,y);i.renderBufferDirect(A,null,q,D,M,null)}}let z=M.children;for(let q=0,I=z.length;q=1):X.indexOf("OpenGL ES")!==-1&&(k=parseFloat(/^OpenGL ES (\\d)/.exec(X)[1]),$=k>=2);let J=null,K={},B=i.getParameter(i.SCISSOR_BOX),Z=i.getParameter(i.VIEWPORT),ot=new Kt().fromArray(B),at=new Kt().fromArray(Z);function ct(C,nt,V,tt){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 Xt=0;XtQ||R.height>Q)&&(j=Q/Math.max(R.width,R.height)),j<1||S===!0)if(typeof HTMLImageElement!="undefined"&&R instanceof HTMLImageElement||typeof HTMLCanvasElement!="undefined"&&R instanceof HTMLCanvasElement||typeof ImageBitmap!="undefined"&&R instanceof ImageBitmap){let it=S?Br:Math.floor,ft=it(j*R.width),st=it(j*R.height);x===void 0&&(x=v(ft,st));let Y=G?v(ft,st):x;return Y.width=ft,Y.height=st,Y.getContext("2d").drawImage(R,0,0,ft,st),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+R.width+"x"+R.height+") to ("+ft+"x"+st+")."),Y}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 Sa(R.width)&&Sa(R.height)}function M(R){return o?!1:R.wrapS!==Ve||R.wrapT!==Ve||R.minFilter!==pe&&R.minFilter!==Le}function T(R,S){return R.generateMipmaps&&S&&R.minFilter!==pe&&R.minFilter!==Le}function A(R){i.generateMipmap(R)}function L(R,S,G,Q,j=!1){if(o===!1)return S;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 it=S;return S===i.RED&&(G===i.FLOAT&&(it=i.R32F),G===i.HALF_FLOAT&&(it=i.R16F),G===i.UNSIGNED_BYTE&&(it=i.R8)),S===i.RG&&(G===i.FLOAT&&(it=i.RG32F),G===i.HALF_FLOAT&&(it=i.RG16F),G===i.UNSIGNED_BYTE&&(it=i.RG8)),S===i.RGBA&&(G===i.FLOAT&&(it=i.RGBA32F),G===i.HALF_FLOAT&&(it=i.RGBA16F),G===i.UNSIGNED_BYTE&&(it=Q===Rt&&j===!1?i.SRGB8_ALPHA8:i.RGBA8),G===i.UNSIGNED_SHORT_4_4_4_4&&(it=i.RGBA4),G===i.UNSIGNED_SHORT_5_5_5_1&&(it=i.RGB5_A1)),(it===i.R16F||it===i.R32F||it===i.RG16F||it===i.RG32F||it===i.RGBA16F||it===i.RGBA32F)&&t.get("EXT_color_buffer_float"),it}function y(R,S,G){return T(R,G)===!0||R.isFramebufferTexture&&R.minFilter!==pe&&R.minFilter!==Le?Math.log2(Math.max(S.width,S.height))+1:R.mipmaps!==void 0&&R.mipmaps.length>0?R.mipmaps.length:R.isCompressedTexture&&Array.isArray(R.image)?S.mipmaps.length:1}function w(R){return R===pe||R===Yo||R===er?i.NEAREST:i.LINEAR}function z(R){let S=R.target;S.removeEventListener("dispose",z),I(S),S.isVideoTexture&&g.delete(S)}function q(R){let S=R.target;S.removeEventListener("dispose",q),O(S)}function I(R){let S=n.get(R);if(S.__webglInit===void 0)return;let G=R.source,Q=p.get(G);if(Q){let j=Q[S.__cacheKey];j.usedTimes--,j.usedTimes===0&&D(R),Object.keys(Q).length===0&&p.delete(G)}n.remove(R)}function D(R){let S=n.get(R);i.deleteTexture(S.__webglTexture);let G=R.source,Q=p.get(G);delete Q[S.__cacheKey],a.memory.textures--}function O(R){let S=R.texture,G=n.get(R),Q=n.get(S);if(Q.__webglTexture!==void 0&&(i.deleteTexture(Q.__webglTexture),a.memory.textures--),R.depthTexture&&R.depthTexture.dispose(),R.isWebGLCubeRenderTarget)for(let j=0;j<6;j++)i.deleteFramebuffer(G.__webglFramebuffer[j]),G.__webglDepthbuffer&&i.deleteRenderbuffer(G.__webglDepthbuffer[j]);else{if(i.deleteFramebuffer(G.__webglFramebuffer),G.__webglDepthbuffer&&i.deleteRenderbuffer(G.__webglDepthbuffer),G.__webglMultisampledFramebuffer&&i.deleteFramebuffer(G.__webglMultisampledFramebuffer),G.__webglColorRenderbuffer)for(let j=0;j=c&&console.warn("THREE.WebGLTextures: Trying to use "+R+" texture units while this GPU supports only "+c),$+=1,R}function J(R){let S=[];return S.push(R.wrapS),S.push(R.wrapT),S.push(R.wrapR||0),S.push(R.magFilter),S.push(R.minFilter),S.push(R.anisotropy),S.push(R.internalFormat),S.push(R.format),S.push(R.type),S.push(R.generateMipmaps),S.push(R.premultiplyAlpha),S.push(R.flipY),S.push(R.unpackAlignment),S.push(R.colorSpace),S.join()}function K(R,S){let G=n.get(R);if(R.isVideoTexture&&re(R),R.isRenderTargetTexture===!1&&R.version>0&&G.__version!==R.version){let Q=R.image;if(Q===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(Q.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{zt(G,R,S);return}}e.bindTexture(i.TEXTURE_2D,G.__webglTexture,i.TEXTURE0+S)}function B(R,S){let G=n.get(R);if(R.version>0&&G.__version!==R.version){zt(G,R,S);return}e.bindTexture(i.TEXTURE_2D_ARRAY,G.__webglTexture,i.TEXTURE0+S)}function Z(R,S){let G=n.get(R);if(R.version>0&&G.__version!==R.version){zt(G,R,S);return}e.bindTexture(i.TEXTURE_3D,G.__webglTexture,i.TEXTURE0+S)}function ot(R,S){let G=n.get(R);if(R.version>0&&G.__version!==R.version){xe(G,R,S);return}e.bindTexture(i.TEXTURE_CUBE_MAP,G.__webglTexture,i.TEXTURE0+S)}let at={[Dr]:i.REPEAT,[Ve]:i.CLAMP_TO_EDGE,[Nr]:i.MIRRORED_REPEAT},ct={[pe]:i.NEAREST,[Yo]:i.NEAREST_MIPMAP_NEAREST,[er]:i.NEAREST_MIPMAP_LINEAR,[Le]:i.LINEAR,[Rl]:i.LINEAR_MIPMAP_NEAREST,[ki]:i.LINEAR_MIPMAP_LINEAR},gt={[Gl]:i.NEVER,[$l]:i.ALWAYS,[Wl]:i.LESS,[ql]:i.LEQUAL,[Xl]:i.EQUAL,[Jl]:i.GEQUAL,[Yl]:i.GREATER,[Zl]:i.NOTEQUAL};function Et(R,S,G){if(G?(i.texParameteri(R,i.TEXTURE_WRAP_S,at[S.wrapS]),i.texParameteri(R,i.TEXTURE_WRAP_T,at[S.wrapT]),(R===i.TEXTURE_3D||R===i.TEXTURE_2D_ARRAY)&&i.texParameteri(R,i.TEXTURE_WRAP_R,at[S.wrapR]),i.texParameteri(R,i.TEXTURE_MAG_FILTER,ct[S.magFilter]),i.texParameteri(R,i.TEXTURE_MIN_FILTER,ct[S.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),(S.wrapS!==Ve||S.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(S.magFilter)),i.texParameteri(R,i.TEXTURE_MIN_FILTER,w(S.minFilter)),S.minFilter!==pe&&S.minFilter!==Le&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),S.compareFunction&&(i.texParameteri(R,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(R,i.TEXTURE_COMPARE_FUNC,gt[S.compareFunction])),t.has("EXT_texture_filter_anisotropic")===!0){let Q=t.get("EXT_texture_filter_anisotropic");if(S.magFilter===pe||S.minFilter!==er&&S.minFilter!==ki||S.type===vn&&t.has("OES_texture_float_linear")===!1||o===!1&&S.type===Hi&&t.has("OES_texture_half_float_linear")===!1)return;(S.anisotropy>1||n.get(S).__currentAnisotropy)&&(i.texParameterf(R,Q.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(S.anisotropy,s.getMaxAnisotropy())),n.get(S).__currentAnisotropy=S.anisotropy)}}function xt(R,S){let G=!1;R.__webglInit===void 0&&(R.__webglInit=!0,S.addEventListener("dispose",z));let Q=S.source,j=p.get(Q);j===void 0&&(j={},p.set(Q,j));let it=J(S);if(it!==R.__cacheKey){j[it]===void 0&&(j[it]={texture:i.createTexture(),usedTimes:0},a.memory.textures++,G=!0),j[it].usedTimes++;let ft=j[R.__cacheKey];ft!==void 0&&(j[R.__cacheKey].usedTimes--,ft.usedTimes===0&&D(S)),R.__cacheKey=it,R.__webglTexture=j[it].texture}return G}function zt(R,S,G){let Q=i.TEXTURE_2D;(S.isDataArrayTexture||S.isCompressedArrayTexture)&&(Q=i.TEXTURE_2D_ARRAY),S.isData3DTexture&&(Q=i.TEXTURE_3D);let j=xt(R,S),it=S.source;e.bindTexture(Q,R.__webglTexture,i.TEXTURE0+G);let ft=n.get(it);if(it.version!==ft.__version||j===!0){e.activeTexture(i.TEXTURE0+G),i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,S.flipY),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,S.premultiplyAlpha),i.pixelStorei(i.UNPACK_ALIGNMENT,S.unpackAlignment),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,i.NONE);let st=M(S)&&b(S.image)===!1,Y=_(S.image,st,!1,h);Y=ae(S,Y);let dt=b(Y)||o,pt=r.convert(S.format,S.colorSpace),_t=r.convert(S.type),ht=L(S.internalFormat,pt,_t,S.colorSpace);Et(Q,S,dt);let ut,Lt=S.mipmaps,Ht=o&&S.isVideoTexture!==!0,C=ft.__version===void 0||j===!0,nt=y(S,Y,dt);if(S.isDepthTexture)ht=i.DEPTH_COMPONENT,o?S.type===vn?ht=i.DEPTH_COMPONENT32F:S.type===yn?ht=i.DEPTH_COMPONENT24:S.type===Fn?ht=i.DEPTH24_STENCIL8:ht=i.DEPTH_COMPONENT16:S.type===vn&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),S.format===On&&ht===i.DEPTH_COMPONENT&&S.type!==mo&&S.type!==yn&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),S.type=yn,_t=r.convert(S.type)),S.format===_i&&ht===i.DEPTH_COMPONENT&&(ht=i.DEPTH_STENCIL,S.type!==Fn&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),S.type=Fn,_t=r.convert(S.type))),C&&(Ht?e.texStorage2D(i.TEXTURE_2D,1,ht,Y.width,Y.height):e.texImage2D(i.TEXTURE_2D,0,ht,Y.width,Y.height,0,pt,_t,null));else if(S.isDataTexture)if(Lt.length>0&&dt){Ht&&C&&e.texStorage2D(i.TEXTURE_2D,nt,ht,Lt[0].width,Lt[0].height);for(let V=0,tt=Lt.length;V>=1,tt>>=1}}else if(Lt.length>0&&dt){Ht&&C&&e.texStorage2D(i.TEXTURE_2D,nt,ht,Lt[0].width,Lt[0].height);for(let V=0,tt=Lt.length;V0&&C++,e.texStorage2D(i.TEXTURE_CUBE_MAP,C,ut,Y[0].width,Y[0].height));for(let V=0;V<6;V++)if(st){Lt?e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+V,0,0,0,Y[V].width,Y[V].height,_t,ht,Y[V].data):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+V,0,ut,Y[V].width,Y[V].height,0,_t,ht,Y[V].data);for(let tt=0;tt=i.TEXTURE_CUBE_MAP_POSITIVE_X&&j<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,Q,j,n.get(G).__webglTexture,0),e.bindFramebuffer(i.FRAMEBUFFER,null)}function N(R,S,G){if(i.bindRenderbuffer(i.RENDERBUFFER,R),S.depthBuffer&&!S.stencilBuffer){let Q=i.DEPTH_COMPONENT16;if(G||Vt(S)){let j=S.depthTexture;j&&j.isDepthTexture&&(j.type===vn?Q=i.DEPTH_COMPONENT32F:j.type===yn&&(Q=i.DEPTH_COMPONENT24));let it=Pt(S);Vt(S)?u.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,it,Q,S.width,S.height):i.renderbufferStorageMultisample(i.RENDERBUFFER,it,Q,S.width,S.height)}else i.renderbufferStorage(i.RENDERBUFFER,Q,S.width,S.height);i.framebufferRenderbuffer(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.RENDERBUFFER,R)}else if(S.depthBuffer&&S.stencilBuffer){let Q=Pt(S);G&&Vt(S)===!1?i.renderbufferStorageMultisample(i.RENDERBUFFER,Q,i.DEPTH24_STENCIL8,S.width,S.height):Vt(S)?u.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,Q,i.DEPTH24_STENCIL8,S.width,S.height):i.renderbufferStorage(i.RENDERBUFFER,i.DEPTH_STENCIL,S.width,S.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.RENDERBUFFER,R)}else{let Q=S.isWebGLMultipleRenderTargets===!0?S.texture:[S.texture];for(let j=0;j0&&Vt(R)===!1){let st=it?S:[S];G.__webglMultisampledFramebuffer=i.createFramebuffer(),G.__webglColorRenderbuffer=[],e.bindFramebuffer(i.FRAMEBUFFER,G.__webglMultisampledFramebuffer);for(let Y=0;Y0&&Vt(R)===!1){let S=R.isWebGLMultipleRenderTargets?R.texture:[R.texture],G=R.width,Q=R.height,j=i.COLOR_BUFFER_BIT,it=[],ft=R.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,st=n.get(R),Y=R.isWebGLMultipleRenderTargets===!0;if(Y)for(let dt=0;dt0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&S.__useRenderToTexture!==!1}function re(R){let S=a.render.frame;g.get(R)!==S&&(g.set(R,S),R.update())}function ae(R,S){let G=R.colorSpace,Q=R.format,j=R.type;return R.isCompressedTexture===!0||R.format===Fr||G!==Je&&G!==zn&&(G===Rt?o===!1?t.has("EXT_sRGB")===!0&&Q===ke?(R.format=Fr,R.minFilter=Le,R.generateMipmaps=!1):S=As.sRGBToLinear(S):(Q!==ke||j!==Sn)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",G)),S}this.allocateTextureUnit=X,this.resetTextureUnits=k,this.setTexture2D=K,this.setTexture2DArray=B,this.setTexture3D=Z,this.setTextureCube=ot,this.rebindTextures=Tt,this.setupRenderTarget=St,this.updateRenderTargetMipmap=Wt,this.updateMultisampleRenderTarget=Nt,this.setupDepthRenderbuffer=yt,this.setupFrameBufferTexture=Ut,this.useMultisampledRTT=Vt}function Vp(i,t,e){let n=e.isWebGL2;function s(r,a=zn){let o;if(r===Sn)return i.UNSIGNED_BYTE;if(r===fc)return i.UNSIGNED_SHORT_4_4_4_4;if(r===dc)return i.UNSIGNED_SHORT_5_5_5_1;if(r===Cl)return i.BYTE;if(r===Pl)return i.SHORT;if(r===mo)return i.UNSIGNED_SHORT;if(r===uc)return i.INT;if(r===yn)return i.UNSIGNED_INT;if(r===vn)return i.FLOAT;if(r===Hi)return n?i.HALF_FLOAT:(o=t.get("OES_texture_half_float"),o!==null?o.HALF_FLOAT_OES:null);if(r===Ll)return i.ALPHA;if(r===ke)return i.RGBA;if(r===Il)return i.LUMINANCE;if(r===Ul)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===Dl)return i.RED;if(r===pc)return i.RED_INTEGER;if(r===Nl)return i.RG;if(r===mc)return i.RG_INTEGER;if(r===gc)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===Zo||r===Jo||r===$o||r===Ko)if(o=t.get("WEBGL_compressed_texture_pvrtc"),o!==null){if(r===Zo)return o.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(r===Jo)return o.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(r===$o)return o.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(r===Ko)return o.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(r===Fl)return o=t.get("WEBGL_compressed_texture_etc1"),o!==null?o.COMPRESSED_RGB_ETC1_WEBGL:null;if(r===Qo||r===jo)if(o=t.get("WEBGL_compressed_texture_etc"),o!==null){if(r===Qo)return a===Rt?o.COMPRESSED_SRGB8_ETC2:o.COMPRESSED_RGB8_ETC2;if(r===jo)return a===Rt?o.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:o.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(r===ta||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)if(o=t.get("WEBGL_compressed_texture_astc"),o!==null){if(r===ta)return a===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:o.COMPRESSED_RGBA_ASTC_4x4_KHR;if(r===ea)return a===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:o.COMPRESSED_RGBA_ASTC_5x4_KHR;if(r===na)return a===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:o.COMPRESSED_RGBA_ASTC_5x5_KHR;if(r===ia)return a===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:o.COMPRESSED_RGBA_ASTC_6x5_KHR;if(r===sa)return a===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:o.COMPRESSED_RGBA_ASTC_6x6_KHR;if(r===ra)return a===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:o.COMPRESSED_RGBA_ASTC_8x5_KHR;if(r===oa)return a===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:o.COMPRESSED_RGBA_ASTC_8x6_KHR;if(r===aa)return a===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:o.COMPRESSED_RGBA_ASTC_8x8_KHR;if(r===ca)return a===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:o.COMPRESSED_RGBA_ASTC_10x5_KHR;if(r===la)return a===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:o.COMPRESSED_RGBA_ASTC_10x6_KHR;if(r===ha)return a===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:o.COMPRESSED_RGBA_ASTC_10x8_KHR;if(r===ua)return a===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:o.COMPRESSED_RGBA_ASTC_10x10_KHR;if(r===fa)return a===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:o.COMPRESSED_RGBA_ASTC_12x10_KHR;if(r===da)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===Ol||r===pa||r===ma||r===ga)if(o=t.get("EXT_texture_compression_rgtc"),o!==null){if(r===or)return o.COMPRESSED_RED_RGTC1_EXT;if(r===pa)return o.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(r===ma)return o.COMPRESSED_RED_GREEN_RGTC2_EXT;if(r===ga)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 Qr=class extends Re{constructor(t=[]){super(),this.isArrayCamera=!0,this.cameras=t}},ui=class extends ye{constructor(){super(),this.isGroup=!0,this.type="Group"}},kp={type:"move"},Vi=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(kp)))}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]}},jr=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=yn),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}},to=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 Kt;let M=new Re;M.layers.enable(2),M.viewport=new Kt;let T=[b,M],A=new Qr;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 Vi,v[B]=Z),Z.getTargetRaySpace()},this.getControllerGrip=function(B){let Z=v[B];return Z===void 0&&(Z=new Vi,v[B]=Z),Z.getGripSpace()},this.getHand=function(B){let Z=v[B];return Z===void 0&&(Z=new Vi,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",q);for(let B=0;B=0&&(_[at]=null,v[at].disconnect(ot))}for(let Z=0;Z=_.length){_.push(ot),at=gt;break}else if(_[gt]===null){_[gt]=ot,at=gt;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,gt=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],Ut=(ct[8]-1)/ct[0],N=(gt[8]+1)/gt[0],oe=Et*Ut,yt=Et*N,Tt=at/(-Ut+N),St=Tt*-Ut;Z.matrixWorld.decompose(B.position,B.quaternion,B.scale),B.translateX(St),B.translateZ(Tt),B.matrixWorld.compose(B.position,B.quaternion,B.scale),B.matrixWorldInverse.copy(B.matrixWorld).invert();let Wt=Et+Tt,Nt=xt+Tt,Pt=oe-St,Vt=yt+(at-St),re=zt*xt/Nt*Wt,ae=xe*xt/Nt*Wt;B.projectionMatrix.makePerspective(Pt,Vt,re,ae,Wt,Nt),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=M.near=b.near=B.near,A.far=M.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 Gp(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 M=_.program;n.updateUBOMapping(v,M);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(),M=v.__size,T=v.usage;return i.bindBuffer(i.UNIFORM_BUFFER,b),i.bufferData(i.UNIFORM_BUFFER,M,T),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,_,b),b}function d(){for(let v=0;v0){T=b%M;let q=M-T;T!==0&&q-w.boundary<0&&(b+=M-T,y.__offset=b)}b+=w.storage}return T=b%M,T>0&&(b+=M-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 Wp(){let i=ws("canvas");return i.style.display="block",i}var eo=class{constructor(t={}){let{canvas:e=Wp(),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=!0,this.toneMapping=cn,this.toneMappingExposure=1;let _=this,b=!1,M=0,T=0,A=null,L=-1,y=null,w=new Kt,z=new Kt,q=null,I=new kt(0),D=0,O=e.width,$=e.height,k=1,X=null,J=null,K=new Kt(0,0,O,$),B=new Kt(0,0,O,$),Z=!1,ot=new Fs,at=!1,ct=!1,gt=null,Et=new Gt,xt=new Dt,zt=new P,xe={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function Ut(){return A===null?k:1}let N=n;function oe(E,F){for(let H=0;H0?p=v[v.length-1]:p=null,f.pop(),f.length>0?x=f[f.length-1]:x=null};function Io(E,F,H,U){if(E.visible===!1)return;if(E.layers.test(F.layers)){if(E.isGroup)H=E.renderOrder;else if(E.isLOD)E.autoUpdate===!0&&E.update(F);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 mt=S.update(E),vt=E.material;vt.visible&&x.push(E,mt,vt,H,zt.z,null)}}else if((E.isMesh||E.isLine||E.isPoints)&&(!E.frustumCulled||ot.intersectsObject(E))){let mt=S.update(E),vt=E.material;if(U&&(E.boundingSphere!==void 0?(E.boundingSphere===null&&E.computeBoundingSphere(),zt.copy(E.boundingSphere.center)):(mt.boundingSphere===null&&mt.computeBoundingSphere(),zt.copy(mt.boundingSphere.center)),zt.applyMatrix4(E.matrixWorld).applyMatrix4(Et)),Array.isArray(vt)){let Mt=mt.groups;for(let It=0,bt=Mt.length;It0&&Gc(W,lt,F,H),U&&St.viewport(w.copy(U)),W.length>0&&Ki(W,F,H),lt.length>0&&Ki(lt,F,H),mt.length>0&&Ki(mt,F,H),St.buffers.depth.setTest(!0),St.buffers.depth.setMask(!0),St.buffers.color.setMask(!0),St.setPolygonOffset(!1)}function Gc(E,F,H,U){let W=Tt.isWebGL2;gt===null&&(gt=new hn(1,1,{generateMipmaps:!0,type:yt.has("EXT_color_buffer_half_float")?Hi:Sn,minFilter:ki,samples:W?4:0})),_.getDrawingBufferSize(xt),W?gt.setSize(xt.x,xt.y):gt.setSize(Br(xt.x),Br(xt.y));let lt=_.getRenderTarget();_.setRenderTarget(gt),_.getClearColor(I),D=_.getClearAlpha(),D<1&&_.setClearColor(16777215,.5),_.clear();let mt=_.toneMapping;_.toneMapping=cn,Ki(E,H,U),Pt.updateMultisampleRenderTarget(gt),Pt.updateRenderTargetMipmap(gt);let vt=!1;for(let Mt=0,It=F.length;Mt0),wt=!!H.morphAttributes.position,Yt=!!H.morphAttributes.normal,Zt=!!H.morphAttributes.color,De=U.toneMapped?_.toneMapping:cn,Qe=H.morphAttributes.position||H.morphAttributes.normal||H.morphAttributes.color,Jt=Qe!==void 0?Qe.length:0,Ft=Nt.get(U),Ks=p.state.lights;if(at===!0&&(ct===!0||E!==y)){let Ee=E===y&&U.id===L;ft.setState(U,E,Ee)}let ne=!1;U.version===Ft.__version?(Ft.needsLights&&Ft.lightsStateVersion!==Ks.state.version||Ft.outputColorSpace!==vt||W.isInstancedMesh&&Ft.instancing===!1||!W.isInstancedMesh&&Ft.instancing===!0||W.isSkinnedMesh&&Ft.skinning===!1||!W.isSkinnedMesh&&Ft.skinning===!0||Ft.envMap!==Mt||U.fog===!0&&Ft.fog!==lt||Ft.numClippingPlanes!==void 0&&(Ft.numClippingPlanes!==ft.numPlanes||Ft.numIntersection!==ft.numIntersection)||Ft.vertexAlphas!==It||Ft.vertexTangents!==bt||Ft.morphTargets!==wt||Ft.morphNormals!==Yt||Ft.morphColors!==Zt||Ft.toneMapping!==De||Tt.isWebGL2===!0&&Ft.morphTargetsCount!==Jt)&&(ne=!0):(ne=!0,Ft.__version=U.version);let Rn=Ft.currentProgram;ne===!0&&(Rn=Qi(U,F,W));let Fo=!1,Ui=!1,Qs=!1,fe=Rn.getUniforms(),Cn=Ft.uniforms;if(St.useProgram(Rn.program)&&(Fo=!0,Ui=!0,Qs=!0),U.id!==L&&(L=U.id,Ui=!0),Fo||y!==E){if(fe.setValue(N,"projectionMatrix",E.projectionMatrix),Tt.logarithmicDepthBuffer&&fe.setValue(N,"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 Ee=fe.map.cameraPosition;Ee!==void 0&&Ee.setValue(N,zt.setFromMatrixPosition(E.matrixWorld))}(U.isMeshPhongMaterial||U.isMeshToonMaterial||U.isMeshLambertMaterial||U.isMeshBasicMaterial||U.isMeshStandardMaterial||U.isShaderMaterial)&&fe.setValue(N,"isOrthographic",E.isOrthographicCamera===!0),(U.isMeshPhongMaterial||U.isMeshToonMaterial||U.isMeshLambertMaterial||U.isMeshBasicMaterial||U.isMeshStandardMaterial||U.isShaderMaterial||U.isShadowMaterial||W.isSkinnedMesh)&&fe.setValue(N,"viewMatrix",E.matrixWorldInverse)}if(W.isSkinnedMesh){fe.setOptional(N,W,"bindMatrix"),fe.setOptional(N,W,"bindMatrixInverse");let Ee=W.skeleton;Ee&&(Tt.floatVertexTextures?(Ee.boneTexture===null&&Ee.computeBoneTexture(),fe.setValue(N,"boneTexture",Ee.boneTexture,Pt),fe.setValue(N,"boneTextureSize",Ee.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=H.morphAttributes;if((js.position!==void 0||js.normal!==void 0||js.color!==void 0&&Tt.isWebGL2===!0)&&dt.update(W,H,Rn),(Ui||Ft.receiveShadow!==W.receiveShadow)&&(Ft.receiveShadow=W.receiveShadow,fe.setValue(N,"receiveShadow",W.receiveShadow)),U.isMeshGouraudMaterial&&U.envMap!==null&&(Cn.envMap.value=Mt,Cn.flipEnvMap.value=Mt.isCubeTexture&&Mt.isRenderTargetTexture===!1?-1:1),Ui&&(fe.setValue(N,"toneMappingExposure",_.toneMappingExposure),Ft.needsLights&&Xc(Cn,Qs),lt&&U.fog===!0&&Q.refreshFogUniforms(Cn,lt),Q.refreshMaterialUniforms(Cn,U,k,$,gt),pi.upload(N,Ft.uniformsList,Cn,Pt)),U.isShaderMaterial&&U.uniformsNeedUpdate===!0&&(pi.upload(N,Ft.uniformsList,Cn,Pt),U.uniformsNeedUpdate=!1),U.isSpriteMaterial&&fe.setValue(N,"center",W.center),fe.setValue(N,"modelViewMatrix",W.modelViewMatrix),fe.setValue(N,"normalMatrix",W.normalMatrix),fe.setValue(N,"modelMatrix",W.matrixWorld),U.isShaderMaterial||U.isRawShaderMaterial){let Ee=U.uniformsGroups;for(let tr=0,Yc=Ee.length;tr0&&Pt.useMultisampledRTT(E)===!1?W=Nt.get(E).__webglMultisampledFramebuffer:W=bt,w.copy(E.viewport),z.copy(E.scissor),q=E.scissorTest}else w.copy(K).multiplyScalar(k).floor(),z.copy(B).multiplyScalar(k).floor(),q=Z;if(St.bindFramebuffer(N.FRAMEBUFFER,W)&&Tt.drawBuffers&&U&&St.drawBuffers(E,W),St.viewport(w),St.scissor(z),St.setScissorTest(q),lt){let Mt=Nt.get(E.texture);N.framebufferTexture2D(N.FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_CUBE_MAP_POSITIVE_X+F,Mt.__webglTexture,H)}else if(mt){let Mt=Nt.get(E.texture),It=F||0;N.framebufferTextureLayer(N.FRAMEBUFFER,N.COLOR_ATTACHMENT0,Mt.__webglTexture,H||0,It)}L=-1},this.readRenderTargetPixels=function(E,F,H,U,W,lt,mt){if(!(E&&E.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let vt=Nt.get(E).__webglFramebuffer;if(E.isWebGLCubeRenderTarget&&mt!==void 0&&(vt=vt[mt]),vt){St.bindFramebuffer(N.FRAMEBUFFER,vt);try{let Mt=E.texture,It=Mt.format,bt=Mt.type;if(It!==ke&&ht.convert(It)!==N.getParameter(N.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}let wt=bt===Hi&&(yt.has("EXT_color_buffer_half_float")||Tt.isWebGL2&&yt.has("EXT_color_buffer_float"));if(bt!==Sn&&ht.convert(bt)!==N.getParameter(N.IMPLEMENTATION_COLOR_READ_TYPE)&&!(bt===vn&&(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}F>=0&&F<=E.width-U&&H>=0&&H<=E.height-W&&N.readPixels(F,H,U,W,ht.convert(It),ht.convert(bt),lt)}finally{let Mt=A!==null?Nt.get(A).__webglFramebuffer:null;St.bindFramebuffer(N.FRAMEBUFFER,Mt)}}},this.copyFramebufferToTexture=function(E,F,H=0){let U=Math.pow(2,-H),W=Math.floor(F.image.width*U),lt=Math.floor(F.image.height*U);Pt.setTexture2D(F,0),N.copyTexSubImage2D(N.TEXTURE_2D,H,0,0,E.x,E.y,W,lt),St.unbindTexture()},this.copyTextureToTexture=function(E,F,H,U=0){let W=F.image.width,lt=F.image.height,mt=ht.convert(H.format),vt=ht.convert(H.type);Pt.setTexture2D(H,0),N.pixelStorei(N.UNPACK_FLIP_Y_WEBGL,H.flipY),N.pixelStorei(N.UNPACK_PREMULTIPLY_ALPHA_WEBGL,H.premultiplyAlpha),N.pixelStorei(N.UNPACK_ALIGNMENT,H.unpackAlignment),F.isDataTexture?N.texSubImage2D(N.TEXTURE_2D,U,E.x,E.y,W,lt,mt,vt,F.image.data):F.isCompressedTexture?N.compressedTexSubImage2D(N.TEXTURE_2D,U,E.x,E.y,F.mipmaps[0].width,F.mipmaps[0].height,mt,F.mipmaps[0].data):N.texSubImage2D(N.TEXTURE_2D,U,E.x,E.y,mt,vt,F.image),U===0&&H.generateMipmaps&&N.generateMipmap(N.TEXTURE_2D),St.unbindTexture()},this.copyTextureToTexture3D=function(E,F,H,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,mt=E.max.y-E.min.y+1,vt=E.max.z-E.min.z+1,Mt=ht.convert(U.format),It=ht.convert(U.type),bt;if(U.isData3DTexture)Pt.setTexture3D(U,0),bt=N.TEXTURE_3D;else if(U.isDataArrayTexture)Pt.setTexture2DArray(U,0),bt=N.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}N.pixelStorei(N.UNPACK_FLIP_Y_WEBGL,U.flipY),N.pixelStorei(N.UNPACK_PREMULTIPLY_ALPHA_WEBGL,U.premultiplyAlpha),N.pixelStorei(N.UNPACK_ALIGNMENT,U.unpackAlignment);let wt=N.getParameter(N.UNPACK_ROW_LENGTH),Yt=N.getParameter(N.UNPACK_IMAGE_HEIGHT),Zt=N.getParameter(N.UNPACK_SKIP_PIXELS),De=N.getParameter(N.UNPACK_SKIP_ROWS),Qe=N.getParameter(N.UNPACK_SKIP_IMAGES),Jt=H.isCompressedTexture?H.mipmaps[0]:H.image;N.pixelStorei(N.UNPACK_ROW_LENGTH,Jt.width),N.pixelStorei(N.UNPACK_IMAGE_HEIGHT,Jt.height),N.pixelStorei(N.UNPACK_SKIP_PIXELS,E.min.x),N.pixelStorei(N.UNPACK_SKIP_ROWS,E.min.y),N.pixelStorei(N.UNPACK_SKIP_IMAGES,E.min.z),H.isDataTexture||H.isData3DTexture?N.texSubImage3D(bt,W,F.x,F.y,F.z,lt,mt,vt,Mt,It,Jt.data):H.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),N.compressedTexSubImage3D(bt,W,F.x,F.y,F.z,lt,mt,vt,Mt,Jt.data)):N.texSubImage3D(bt,W,F.x,F.y,F.z,lt,mt,vt,Mt,It,Jt),N.pixelStorei(N.UNPACK_ROW_LENGTH,wt),N.pixelStorei(N.UNPACK_IMAGE_HEIGHT,Yt),N.pixelStorei(N.UNPACK_SKIP_PIXELS,Zt),N.pixelStorei(N.UNPACK_SKIP_ROWS,De),N.pixelStorei(N.UNPACK_SKIP_IMAGES,Qe),W===0&&U.generateMipmaps&&N.generateMipmap(bt),St.unbindTexture()},this.initTexture=function(E){E.isCubeTexture?Pt.setTextureCube(E,0):E.isData3DTexture?Pt.setTexture3D(E,0):E.isDataArrayTexture||E.isCompressedArrayTexture?Pt.setTexture2DArray(E,0):Pt.setTexture2D(E,0),St.unbindTexture()},this.resetState=function(){M=0,T=0,A=null,St.reset(),ut.reset()},typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return an}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:_c}set outputEncoding(t){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=t===Bn?Rt:Je}},no=class extends eo{};no.prototype.isWebGL1Renderer=!0;function xn(i,t,e){return Ac(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 Ac(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=xn(n,r,a),this.values=xn(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&&Ac(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=xn(this.times),e=xn(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=xn(t,0,a),this.values=xn(e,0,a*n)):(this.times=t,this.values=e),this}clone(){let t=xn(this.times,0),e=xn(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 oo=class extends We{};oo.prototype.ValueTypeName="color";var ao=class extends We{};ao.prototype.ValueTypeName="number";var co=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}},Wi=class extends We{InterpolantFactoryMethodLinear(t){return new co(this.times,this.values,this.getValueSize(),t)}};Wi.prototype.ValueTypeName="quaternion";Wi.prototype.DefaultInterpolation=Es;Wi.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 lo=class extends We{};lo.prototype.ValueTypeName="vector";var ho=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 vo(i,t){t.set(i)}function Mo(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 qi(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 nm(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 Qt(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 q=i[v+4],I=i[v+5],D=q-I,O=q+I;Dh&&(h=O),f&&qp&&(p=q)}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 sm(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 rm(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(fn).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),Vs=new Float32Array(6);function am(i,t,e,n,s,r){let a=-1,o=0;if(r===0)a=yo(t),a!==-1&&(o=(t[a]+t[a+3])/2);else if(r===1)a=yo(i),a!==-1&&(o=cm(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)/fn;if(s=A.candidate?qi(b,e,A.rightCacheBounds):(qi(b,e,A.leftCacheBounds),A.count++)}}for(let b=0;b<_;b++){let M=f[b],T=M.count,A=s-M.count,L=M.leftCacheBounds,y=M.rightCacheBounds,w=0;T!==0&&(w=bi(L)/c);let z=0;A!==0&&(z=bi(y)/c);let q=1+1.25*(w*T+z*A);q=fn&&(T=fn-1);let A=Tn[T];A.count++,qi(_,e,A.bounds)}let f=Tn[fn-1];vo(f.bounds,f.rightCacheBounds);for(let _=fn-2;_>=0;_--){let b=Tn[_],M=Tn[_+1];Mo(b.bounds,M.rightCacheBounds,b.rightCacheBounds)}let v=0;for(let _=0;_T&&(T=_),b>T&&(T=b);let A=(T-M)/2,L=f*2;r[m+L+0]=M+A,r[m+L+1]=A+(Math.abs(M)+A)*Rc,Mt[f+3]&&(t[f+3]=T)}}return r}function hm(i,t){function e(f){u&&u(f/m)}function n(f,v,_,b=null,M=0){if(!g&&M>=c&&(g=!0,l&&(console.warn(`MeshBVH: Max depth of ${c} reached when generating BVH. Consider increasing maxDepth.`),console.warn(i))),_<=h||M>=c)return e(v+_),f.offset=v,f.count=_,f;let T=am(f.boundingData,b,a,v,_,d);if(T.axis===-1)return e(v+_),f.offset=v,f.count=_,f;let A=rm(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),bo(a,y,w,L.boundingData,r),n(L,y,w,r,M+1);let z=new Wn,q=A,I=_-w;f.right=z,z.boundingData=new Float32Array(6),bo(a,q,I,z.boundingData,r),n(z,q,I,r,M+1)}return f}nm(i,t);let s=new Float32Array(6),r=new Float32Array(6),a=lm(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=im(i);if(p.length===1){let f=p[0],v=new Wn;v.boundingData=s,sm(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),bo(a,f.offset,f.count,v.boundingData,r),n(v,f.offset,f.count,r),x.push(v)}return x}function Lc(i,t){let e=hm(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 Me=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}};Me.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 Im=function(){let i=new Me;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 um=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}}(),Yi=function(){let i=new Dt,t=new P,e=new P;return function(s,r,a,o){um(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}}}}(),Ic=function(){let i=new P,t=new P,e=new Ce,n=new ve;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 fm=1e-15;function Ei(i){return Math.abs(i)new P),this.satBounds=new Array(4).fill().map(()=>new Me),this.points=[this.a,this.b,this.c],this.sphere=new Vn,this.plane=new Ce,this.needsUpdate=!0}intersectsSphere(t){return Ic(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}};Se.prototype.closestPointToSegment=function(){let i=new P,t=new P,e=new ve;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]),Yi(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,M=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=M[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=M[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 k=_?h.start:h.end,X=Ei(f.distanceToPoint(O));if(Ei(f.normal.dot(a))&&X){h.copy(l),b=2;break}if((f.intersectLine(l,k)||X)&&!Ei(k.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 M=m.points,T=!1,A=0;for(let D=0;D<3;D++){let O=M[D],$=M[(D+1)%3];l.start.copy(O),l.end.copy($),l.delta(o);let k=T?d.start:d.end,X=Ei(p.distanceToPoint(O));if(Ei(p.normal.dot(o))&&X){d.copy(l),A=2;break}if((p.intersectLine(l,k)||X)&&!Ei(k.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),q=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)}}}();Se.prototype.distanceToPoint=function(){let i=new P;return function(e){return this.closestPointToPoint(e,i),e.distanceTo(i)}}();Se.prototype.distanceToTriangle=function(){let i=new P,t=new P,e=["a","b","c"],n=new ve,s=new ve;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 Me),this.alignedSatBounds=new Array(3).fill().map(()=>new Me),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}};be.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 ve),e=new Array(12).fill().map(()=>new ve),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 Vc=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,M=wn,T=An;for(;!dn(b,M);)_=Ai(_),b=_*2;return Xn(_,T)}function m(_){let b=_*2,M=wn,T=An;for(;!dn(b,M);)_=Ri(_,T),b=_*2;return Xn(_,T)+wi(b,M)}let g=r*2,x=Pi,p=wn,f=An;if(dn(g,p)){let _=Xn(r,f),b=wi(g,p);return Ie(r,x,i),c(_,b,!1,d,h+r,i)}else{let _=Ai(r),b=Ri(r,f),M=_,T=b,A,L,y,w;if(l&&(y=i,w=t,Ie(M,x,y),Ie(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=M*3,w=(T+M)*3;ynew Se),Ke=class{static serialize(t,e={}){if(e.isBufferGeometry)return console.warn("MeshBVH.serialize: The arguments for the function have changed. See documentation for new signature."),Ke.serialize(arguments[0],{cloneBuffers:arguments[2]===void 0?!0:arguments[2]});e=ji({cloneBuffers:!0},e);let n=t.geometry,s=t._roots,r=n.getIndex(),a;return e.cloneBuffers?a={roots:s.map(o=>o.slice()),index:r.array.slice()}:a={roots:s,index:r.array},a}static deserialize(t,e,n={}){if(typeof n=="boolean")return console.warn("MeshBVH.deserialize: The arguments for the function have changed. See documentation for new signature."),Ke.deserialize(arguments[0],arguments[1],{setIndex:arguments[2]===void 0?!0:arguments[2]});n=ji({setIndex:!0},n);let{index:s,roots:r}=t,a=new Ke(e,Vo(ji({},n),{[Ro]:!0}));if(a._roots=r,n.setIndex){let o=e.getIndex();if(o===null){let c=new Qt(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,[Ro]:!1},e),e.useSharedArrayBuffer&&typeof SharedArrayBuffer=="undefined")throw new Error("MeshBVH: SharedArrayBuffer is not available.");this._roots=null,e[Ro]||(this._roots=Lc(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=q),IA&&(A=I),DL&&(L=D)}return c[u+0]!==_||c[u+1]!==b||c[u+2]!==M||c[u+3]!==T||c[u+4]!==A||c[u+5]!==L?(c[u+0]=_,c[u+1]=b,c[u+2]=M,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,M=g,T=!1,A=!1;t?M||(T=t.has(_),A=t.has(b),M=!T&&!A):(T=!0,A=!0);let L=M||T,y=M||A,w=!1;L&&(w=d(f,m,M));let z=!1;y&&(z=d(v,m,M));let q=w||z;if(q)for(let I=0;I<3;I++){let D=f+I,O=v+I,$=c[D],k=c[D+3],X=c[O],J=c[O+3];c[u+I]=$J?k:J}return q}}}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=$e.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:wo(m,g,s,l,x,p,r)}else c||(l?c=(u,m,g,x)=>wo(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=Vc(0,s,o,c,a,d),Zi(),h)break;d+=u.byteLength}return $e.releasePrimitive(r),h}bvhcast(t,e,n){let{intersectsRanges:s,intersectsTriangles:r}=n,a=this.geometry.index,o=this.geometry.attributes.position,c=t.geometry.index,l=t.geometry.attributes.position;Ii.copy(e).invert();let h=$e.getPrimitive(),d=$e.getPrimitive();if(r){let m=function(g,x,p,f,v,_,b,M){for(let T=p,A=p+f;TPo.intersectsBox(m),intersectsRange:(m,g,x,p,f,v)=>(Co.copy(v),Co.applyMatrix4(Ii),t.shapecast({intersectsBounds:_=>Co.intersectsBox(_),intersectsRange:(_,b,M,T,A)=>s(m,g,_,b,p,f,T,A)}))});return $e.releasePrimitive(h),$e.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=$e.getPrimitive(),m=$e.getPrimitive(),g=$s,x=_m,p=null,f=null;s&&(p=xm,f=ym);let v=1/0,_=null,b=null;return Ii.copy(e).invert(),Ji.matrix.copy(Ii),this.shapecast({boundsTraverseOrder:M=>qn.distanceToBox(M),intersectsBounds:(M,T,A)=>A{if(t.boundsTree)return t.boundsTree.shapecast({boundsTraverseOrder:A=>Ji.distanceToBox(A),intersectsBounds:(A,L,y)=>y{for(let y=A*3,w=(A+L)*3;y($i.copy(t).clamp(h.min,h.max),$i.distanceToSquared(t)),intersectsBounds:(h,d,u)=>u{h.closestPointToPoint(t,$i);let u=t.distanceToSquared($i);return u{Ie(0,new Float32Array(n),Hc),t.union(Hc)}),t}};var Lo=self;Lo.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 Qt(r,3,!1)),s&&o.setIndex(new Qt(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 Ke(o,a),l=Ke.serialize(c,{cloneBuffers:!1});Lo.postMessage({id:n,error:void 0,serialized:l,position:r,progress:1},[l.index.buffer,r.buffer,...l.roots])}catch(o){Lo.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')}Oa.decoderPath="libs/draco/gltf/";var rC=class{constructor(){this.running=!1,this.worker=new FU,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 ae.warn("[GenerateMeshBVHWorker] Already running job.");if(!this.worker)return void ae.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=>{ae.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)ae.warn(i.error),s();else if(i.serialized){let{serialized:e,position:r,id:a}=i,o=n.get(a),l=uc.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),ae.debug("before update, index:",o.index.array),o.index.array=e.index;else{let t=new pn(e.index,1,!1);o.setIndex(t)}o.index&&(ae.debug("after update, index:",o.index.array),o.index.needsUpdate=!0),h.setBoundingBox&&!o.boundingBox&&(o.boundingBox=l.getBoundingBox(new It)),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){ae.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:pi(Kn({},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}},yf=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;ae.debug("startIndex: "+l+" endIndex: "+h),a.push(i.generate(e.slice(l,h),t))}Promise.allSettled(a).then((()=>{this.running=!1,i()}))}));ae.warn("[BVHHelper] Worker has been disposed.")}}))}dispose(){for(let e=0;e{e.traverse((e=>{let n=e;if(n.isMesh&&n.geometry&&Gr.isMergedMesh(n)&&!(n instanceof Li)){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 uc(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&&Gr.isMergedMesh(t)&&!(t instanceof Li)){if(i.has(t.geometry.id))return;n.push(t.geometry),i.add(t.geometry.id)}}))}));let r=new yf;r.generate(n,t).then((()=>{r.dispose()}))}},wpe=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 It;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=fut(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()}},fut=(e,t,i=800,n=45)=>{let r=n*(Math.PI/180);return i*(e/(2*Math.tan(r/2)*t))},iC,sC=new ye,aC=new ye,oC=new ye,Spe=new ye,put=new ye,mut=new ye,co=class extends Ai{constructor(e){super(wt.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=co.FILL_COLOR_NONE,e.strokeStyle=co.lineColor,e.lineWidth=co.lineWidth,e.beginPath(),this.drawSnapFunctions[this.snapType](e,t),iC&&this.drawDebug(e,t),e.closePath(),e.fill(),e.stroke(),e.restore())}drawDebug(e,t){null==iC||iC.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=co.SNAP_LINE_COLOR,e.lineWidth=co.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=co.iconSize/1.6,r=sC.set(i.x,i.y-n),a=aC.set(i.x-.87*n,i.y+n/1.4),s=oC.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=co.iconSize,r=co.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=co.iconSize/1.6,r=sC.set(i.x,i.y-n),a=aC.set(i.x-.87*n,i.y+n/2),s=oC.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=co.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=co.iconSize/2,r=sC.set(i.x-n,i.y-n),a=aC.set(i.x+n,i.y+n),s=oC.set(i.x+n,i.y-n),o=Spe.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=co.iconSize/2,r=sC.set(i.x,i.y),a=aC.set(i.x-n,i.y),s=oC.set(i.x,i.y+n),o=Spe.set(i.x-n,i.y-n),l=put.set(i.x-n,i.y+n),h=mut.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"}},ys=co;ys.lineColor="rgba(255, 119, 0, 1)",ys.FILL_COLOR_NONE="rgba(0, 0, 0, 0)",ys.SNAP_LINE_COLOR="rgba(255, 240, 0, 0.3)",ys.lineWidth=2,ys.iconSize=14,On._registerDrawableClass(ys);var Mpe=(e=>(e[e.None=0]="None",e[e.PointOnLine=1]="PointOnLine",e[e.StartPoint=2]="StartPoint",e[e.EndPoint=4]="EndPoint",e[e.MiddlePoint=8]="MiddlePoint",e[e.FootOfPerpendicular=16]="FootOfPerpendicular",e[e.Intersection=32]="Intersection",e[e.CircleCenter=64]="CircleCenter",e))(Mpe||{}),gut=1e-5,lC=class{constructor(e){var t;this.drawableList=new Fo("snap"),this.markers={},this.activeOSnapType=0,this.snapToleranceInWorldCoord=1,this.intersectionLimit=10,this.osnapTypePriorities={2:0,4:0,8:1,64:2,32:3,16:4,1:5,0:6},this.overlayRender=e,null==(t=this.overlayRender)||t.addDrawableList(this.drawableList),this.initOSnapMarkers()}initOSnapMarkers(){let e=new ys("TripleCross"),t=new ys("Square"),i=new ys("Triangle"),n=new ys("CircleWithCross"),r=new ys("Cross"),a=new ys("Perpendicular");this.markers[2]=t,this.markers[4]=t,this.markers[8]=i,this.markers[1]=e,this.markers[32]=r,this.markers[64]=n,this.markers[16]=a,Object.values(this.markers).forEach((e=>{e.visible=!1,this.drawableList.addDrawable(e)}))}setSnapTolerance(e){this.snapToleranceInWorldCoord=e}getSnapTolerance(){return this.snapToleranceInWorldCoord}setIntersectionLimit(e){this.intersectionLimit=e}getIntersectionLimit(){return this.intersectionLimit}getMarkerLineColor(){return wn.colorStr2Rgba(ys.lineColor)}setMarkerLineColor(e){ys.lineColor=wn.rgba2Color(e)}getMarkerLineWidth(){return ys.lineWidth}setMarkerLineWidth(e){ys.lineWidth=e}getMarkerIconSize(){return ys.iconSize}setMarkerIconSize(e){ys.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,n){var r;if(t&&i&&(e.sort(((e,t)=>e.distance-t.distance)),e=this.getIntersectsIncludeOutline(e,i)),!e||e.length<1)return void this.deactivate();let a;if(!t){for(let t of e)if(t.point.z=0,"groundPlane"===(null==(r=t.object)?void 0:r.name)){a=t.point;continue}if(a){for(let i of e)i.distance=i.point.distanceTo(a);let t=e=>e instanceof $r?0:e instanceof Br?2:e instanceof rr?1:3;e.sort(((e,i)=>{let n=t(e.object),r=t(i.object);return n!==r?n-r:e.distance-i.distance}))}}if(!a){for(let t of e)if(t.object instanceof _t){a=t.point;break}a||(ae.warn("[OSnap] Potential to produce erroneous snap results"),a=e[0].point)}ae.debug("[OSnap] intersections:",e),ae.debug("[OSnap] mousePosition:",a);let s=this.getSnapPointAndUpdateMarker(a,e,t,n);return(null==s?void 0:s.clone())||a}getSnapPointAndUpdateMarker(e,t,i,n){if(null==t||!t.length)return void this.activateMarker(0);let r=this.getIntersectionPointsAndLines(e,t,i);if(r){let t=this.getSnapInfo(e,r,n);return t&&0!==t.type?(this.activateMarker(t.type,t),t.point):void this.activateMarker(0)}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=gut){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)2?r[s+2]:0,h=new L(r[s],r[s+1],l);h.applyMatrix4(o.matrixWorld),i||h.setZ(0),"CircleCenter"===o.userData.type?n.push(h):n.push({start:h,end:h})}}return n}getSnapInfo(e,t,i){let n,r=this.snapToleranceInWorldCoord,a=[];for(let s of t)if(s instanceof L){let t=e.distanceTo(s);t<2*r&&a.push({distance:t,type:64,point:s})}else{let t=s,{start:o,end:l}=t;if(i){let n=this.getFootOfPerpendicular(i,t,r),s=e.distanceTo(n);if(sthis.osnapTypePriorities[e.type]-this.osnapTypePriorities[t.type])),a[0]}getIntersectsIncludeOutline(e,t){let i=e.slice(),n=[];for(let a=0;a0&&(r=t.intersectObjects(n)||[],ae.debug("[OSnap] Intersected with newly created edges: ",r),r.length>0&&i.push(...r)),i.sort(((e,t)=>e.distance-t.distance)),i}},cC=class{constructor(e){this.actived=!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=on.worldCoordinate2NormalizedScreenCoordinate(e.min,this.camera,this.viewerContainer),i=on.worldCoordinate2NormalizedScreenCoordinate(e.max,this.camera,this.viewerContainer),r=new Gi(new ye(Math.min(t.x,i.x),Math.min(t.y,i.y)),new ye(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}isActived(){return this.actived}activate(){var e,t;if(this.isActived())return void(this.reject&&(this.deactivate(),this.reject("PickMarkupHelper is already actived!"),this.isResolvedOrRejected=!0));this.actived=!0,this.viewer.addEventListener("MouseClicked",this.mouseClicked),null==(e=this.viewer.getInputManager())||e.addEventListener("keydown",this.keydown);let i=this.viewer.translate;if(i){this.tooltip=new Cl("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.actived=!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 dt(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!")}},uC=class{constructor(e){this.mouseDown=!1,this.mouseMove=!1,this.mouseDownPositionX=-1,this.mouseDownPositionY=-1,this.tempEnableRotate=!1,this.actived=!1,this.isResolvedOrRejected=!1,this.mousedown=e=>{var t,i;if(0===e.button){this.mouseDown=!0;let n=new ye(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 ye(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 ye(Math.min(this.mouseDownPositionX,t.x),Math.min(this.mouseDownPositionY,t.y)),i=new ye(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 ye(e.x,e.y),i=new ye(Math.min(this.mouseDownPositionX,t.x),Math.min(this.mouseDownPositionY,t.y)),n=new ye(Math.max(this.mouseDownPositionX,t.x),Math.max(this.mouseDownPositionY,t.y)),r=new Gi(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}isActived(){return this.actived}activate(){var e;if(this.isActived())return void(this.reject&&(this.deactivate(),this.reject("BoxSelectHelper is already actived!"),this.isResolvedOrRejected=!0));this.actived=!0,this.input.addEventListener("pointerdown",this.mousedown),this.input.addEventListener("pointermove",this.mousemove),this.input.addEventListener("pointerup",this.mouseup),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 Cl("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.actived=!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: ${uC.BORDER_WIDTH} solid ${uC.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 dt(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!")}},xf=uC;xf.BORDER_COLOR="#fff000",xf.BORDER_WIDTH="2px";var Lr=class extends ts{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)}},Vv=(e=>(e.BaseViewer="BaseViewer",e.BimViewer="BimViewer",e.DxfViewer="DxfViewer",e.VRViewer="VRViewer",e))(Vv||{}),bf=class extends ts{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 nR,this.initLogLevel(),this.initLocalization(),Tn.isBrowser&&!e.context&&(this.initContainer(),this.initViewerContainer(),this.initWidgetContainer())}initLogLevel(){let e=this.viewerCfg.logLevel;e&&uue(e)}initLocalization(){var e;let t=(null==(e=this.viewerCfg)?void 0:e.language)||"cn";return gm.init({lng:t,debug:!1,resources:{en:{translation:Vue},cn:{translation:zue}}}),gm.t}initContainer(){let e=document.getElementById(this.viewerCfg.containerId);e||(ae.error("[BaseViewer] containerId:",this.viewerCfg.containerId,"is not found in dom tree! will append to document body"),e=document.body);let t=document.createElement("div");t.classList.add("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?ae.warn("[BaseViewer] 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 nr)i.aspect=e/t;else if(i instanceof Ir){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;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.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(),null==(n=this.undoRedoManager)||n.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 dt(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 L;e.getWorldPosition(r);let a=new L,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}addPlugin(e){this.plugins.find((t=>t.id===e.id))?ae.error(`[BaseViewer] Plugin already exist: ${e.id}`):(this.plugins.push(e),ae.debug(`[BaseViewer] Added plugin: ${e.id}`))}removePlugin(e){for(let t=0,i=this.plugins.length;tt.id===e))}},zv=class{constructor(e){this.actived=!1,this.viewer=e,this.boxSelectHelper=new xf(e)}get viewerContainer(){return this.viewer.viewerContainer}get camera(){return this.viewer.camera}get raycaster(){return this.viewer.getRaycaster()}isActived(){return this.actived}activate(){var e;this.actived=!0,null==(e=this.boxSelectHelper)||e.select().then((e=>{e&&this.handleZoomToRect(e.min,e.max)}))}deactivate(){var e;this.actived=!1,null==(e=this.boxSelectHelper)||e.deactivate()}pickPositionByScreenPoint(e){let t=on.screenPoint2NdcPoint(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 L(Math.min(i.x,n.x),Math.min(i.y,n.y),Math.min(i.z,n.z)),t=new L(Math.max(i.x,n.x),Math.max(i.y,n.y),Math.max(i.z,n.z)),r=new It(e,t);this.viewer.zoomToBBox(r)}}destroy(){var e;null==(e=this.boxSelectHelper)||e.destroy(),this.boxSelectHelper=void 0}},hC=class extends Ai{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 ye(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"}},Ape=new L,dC=class extends Lu{constructor(e,t,i,n){super("Area",e,t,i,n)}activate(){super.activate()}deactivate(){super.deactivate(),this.currentMeasureDrawable&&this.removeDrawable(this.currentMeasureDrawable),this.exitButton&&(this.exitButton.style.display="none")}createMeasureDrawable(){if(this.drawingPoints)return new ff(wt.guid(),this.drawingPoints,this.scale)}onMouseMove(e){if(super.onMouseMove(e),this.drawingPoints&&this.drawingPoints.length>2&&this.drawingPoints[0]){let t=this.drawingPoints[0];Ape.subVectors(e,t).length()<3*this.viewer.getPixelSizeInWorldCoord()&&(this.osnapHelper.activateMarker(2,{point:t,type:2,distance:0}),ae.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 ae.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(Ape.subVectors(a,e).length()<3*this.viewer.getPixelSizeInWorldCoord())return ae.info("[AreaMeasurement] auto close area measurement."),this.touchDowned=!1,void this.exitDrawing()}this.drawingPoints[0]&&$t.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&&(ae.warn("[Measure] If the number of points is less than 3, the measurement area cannot be formed !"),t=!1),t&&Qp.isSelfIntersecting(e)&&(ae.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 ff&&(t.scale=e)}}},vE=class extends wr{constructor(e,t){super(e,t),this.type="Coordinate",this.update(t)}draw(e,t){this.drawText(e,t),e.save(),e.lineWidth=wr.LINE_WIDTH,e.strokeStyle=wr.MAJOR_COLOR,e.fillStyle=wr.AREA_FILL_COLOR;let i=this.points;e.beginPath(),i.forEach((i=>{let n=this.transToScreenCoord(i,t);e.arc(n.x,n.y,wr.POINT_RADIUS,0,2*Math.PI)})),e.fill(),e.stroke(),e.restore()}drawText(e,t){let i=this.points[0];$t.areNumbersEqual(i.x,0);let n=$t.areNumbersEqual(i.x,0)?0:i.x,r=$t.areNumbersEqual(i.y,0)?0:i.y,a=$t.areNumbersEqual(i.z,0)?0:i.z;this.label=`${vu(n,2)}, ${vu(r,2)}, ${vu(a,2)}`,e.font=`${wr.LABEL_FONT_SIZE}px Arial`;let s=1.2*e.measureText(this.label).width,o=1.5*wr.LABEL_FONT_SIZE;this.labelPositon=this.transToScreenCoord(i,t),this.labelPositon.y-=o/2,this.labelBounds.setFromCenterAndSize(this.labelPositon,new ye(s,o)),this.drawRoundRect(e,this.labelPositon.x-s/2,this.labelPositon.y-o/2,s,o,4),e.save(),e.fillStyle=wr.MINOR_COLOR,e.textBaseline="middle",e.textAlign="center",e.fillText(this.label,this.labelPositon.x,this.labelPositon.y),e.restore()}getClassType(){return"Coordinate"}};On._registerDrawableClass(vE);var fC=class extends Lu{constructor(e,t,i,n){super("Coordinate",e,t,i,n)}createMeasureDrawable(){if(this.drawingPoints)return new vE(wt.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))}}},BU=class extends wr{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=wr.LINE_WIDTH,e.strokeStyle=wr.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=`${vu(r,2)}`,this.labelPositon=this.transToScreenCoord((new L).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=wr.LINE_WIDTH,e.strokeStyle=wr.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 ye).subVectors(t,e).normalize(),n=BU.SHORT_LINE_LENGTH/2,r=Math.PI/2;return[i.clone().rotateAround(new ye,r).normalize().multiplyScalar(n).add(e),i.clone().rotateAround(new ye,-r).normalize().multiplyScalar(n).add(e)]}getClassType(){return"Distance"}setScale(e){this.scale=e}},xm=BU;xm.SHORT_LINE_LENGTH=12,On._registerDrawableClass(xm);var pC=class extends Lu{constructor(e,t,i,n){super("Distance",e,t,i,n)}createMeasureDrawable(){if(this.drawingPoints)return new xm(wt.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]&&$t.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 xm||t instanceof ff)&&(t.scale=e)}}},Rpe=class extends Lr{constructor(e){var t,i;super(e,{id:"MeasurementPlugin"}),this.selectedDrawable=void 0,this.drawableList=new Fo("measure"),this.drawableHelperList=new Fo("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 vv(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 lC(this.overlayRender);this.measurements.Distance=new pC(e,n,this.drawableList,r),this.measurements.Area=new dC(e,n,this.drawableList,r),this.measurements.Angle=new HR(e,n,this.drawableList,r),this.measurements.Coordinate=new fC(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 yb(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 On.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,ae.error("[Measure] Failed to activate measurement, type:",e));let{width:t,height:i}=this.canvas.getBoundingClientRect();Tn.isMobile&&this.canvas&&!this.mobileTouchHelper&&(this.mobileTouchHelper=new hC(new ye(t/2,i/2)),this.drawableHelperList.addDrawable(this.mobileTouchHelper)),this.mobileTouchHelper&&(this.mobileTouchHelper.setPosition(new ye(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(On.createDrawable(e)),null==(t=this.viewer.undoRedoManager)||t.addCommand(new yb(this,e))):ae.info("[Measure] Invalid points found in MeasurementData:",e):ae.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):ae.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 ae.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()}},la,Cpe={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=>{ae.info("[Toolbar]","Enter OrthoMode"),e.setToOrthographicCamera(!0)},onDeactive:e=>{ae.info("[Toolbar]","Exit OrthoMode"),e.setToOrthographicCamera(!1)}},Measure:{icon:{default:"icon-measure",active:"icon-measure-filled",iconFont:"gemini-viewer-icon"},menuName:"Toolbar.measurement",type:3,children:{MeasureDistance:{icon:{default:"icon-measure-distance"},menuName:"Toolbar.distanceMeasurement",onActive:e=>{e.deactivateSection(),e.activateMeasurement("Distance")},onDeactive:e=>{e.deactivateMeasurement()},type:4,mutexIds:["MeasureArea","MeasureAngle","MeasureCoordinate"]},MeasureArea:{icon:{default:"icon-measure-area-color"},onActive:e=>{e.deactivateSection(),e.activateMeasurement("Area")},onDeactive:e=>{e.deactivateMeasurement()},type:4,menuName:"Toolbar.areaMeasurement",mutexIds:["MeasureDistance","MeasureAngle","MeasureCoordinate"]},MeasureAngle:{menuName:"Toolbar.angleMeasurement",icon:{default:"icon-angle-measure"},type:4,onActive:e=>{e.deactivateSection(),e.activateMeasurement("Angle")},onDeactive:e=>{e.deactivateMeasurement()},mutexIds:["MeasureDistance","MeasureArea","MeasureCoordinate"]},MeasureCoordinate:{menuName:"Toolbar.coordinateMeasurement",icon:{default:"icon-distancemeasure",iconFont:"gemini-viewer-icon"},type:4,onActive:e=>{e.deactivateSection(),e.activateMeasurement("Coordinate")},onDeactive:e=>{e.deactivateMeasurement()},mutexIds:["MeasureDistance","MeasureArea","MeasureAngle"]},MeasureClear:{icon:{default:"icon-clear",active:"icon-clear-filled",iconFont:"gemini-viewer-icon"},onClick:e=>{ae.debug("[Toolbar]","Clearing Measure",e),e.clearMeasurements()},type:1,menuName:"Toolbar.clearMeasurement"}},mutexIds:["Section","SectionAxis","SectionBox","SectionPlane"]},Section:{icon:{default:"icon-section",active:"icon-section-filled",iconFont:"gemini-viewer-icon"},menuName:"Toolbar.section",type:3,children:{SectionAxis:{icon:{default:"icon-sectionplane",active:"icon-sectionplane-filled",iconFont:"gemini-viewer-icon"},menuName:"Toolbar.axisSection",type:4,onActive:e=>{e.deactivateMeasurement(),e.getMeasurements().forEach((t=>e.setMeasurementVisibility(t.id,!1))),null==la||la.destroy(),e.activateSection("AxisPlaneSection"),la=new FR(e)},onDeactive:e=>{e.getMeasurements().forEach((t=>e.setMeasurementVisibility(t.id,!0))),e.deactivateSection(),null==la||la.destroy(),la=void 0},mutexIds:["SectionBox","SectionPlane"]},SectionPlane:{icon:{default:"icon-choosesectionplane",active:"icon-choosesectionplane-filled",iconFont:"gemini-viewer-icon"},menuName:"Toolbar.pickSectionPlane",type:4,onActive:e=>{e.deactivateMeasurement(),e.getMeasurements().forEach((t=>e.setMeasurementVisibility(t.id,!1))),null==la||la.destroy(),e.activateSection("PickPlaneSection"),la=new BR(e)},onDeactive:e=>{e.getMeasurements().forEach((t=>e.setMeasurementVisibility(t.id,!0))),e.deactivateSection(),null==la||la.destroy(),la=void 0},mutexIds:["SectionAxis","SectionBox"]},SectionBox:{icon:{default:"icon-sectionbox",active:"icon-sectionbox-filled",iconFont:"gemini-viewer-icon"},menuName:"Toolbar.sectionBox",type:4,onActive:e=>{e.deactivateMeasurement(),e.getMeasurements().forEach((t=>e.setMeasurementVisibility(t.id,!1))),e.activateSection()},onDeactive:e=>{e.getMeasurements().forEach((t=>e.setMeasurementVisibility(t.id,!0))),e.deactivateSection()},mutexIds:["SectionAxis","SectionPlane"]}},mutexIds:["Measure","MeasureDistance","MeasureArea","MeasureAngle","MeasureCoordinate"]},BimTree:{icon:{default:"icon-bimtree",active:"icon-bimtree-filled",iconFont:"gemini-viewer-icon"},menuName:"Toolbar.bimTree",type:4,onActive:()=>{ae.info("[Toolbar]","Activate Bim Tree")},onDeactive:()=>{ae.info("[Toolbar]","Deactivate Bim Tree")}},Viewpoint:{icon:{default:"icon-viewpoint",active:"icon-viewpoint-filled",iconFont:"gemini-viewer-icon"},menuName:"Toolbar.viewpoint",type:4,onActive:()=>{ae.info("[Toolbar]","Activate Viewpoint")},onDeactive:()=>{ae.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:()=>{ae.info("[Toolbar]","Activate Annotation")},onDeactive:()=>{ae.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:()=>{ae.info("[Toolbar]","Activate Property")},onDeactive:()=>{ae.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:()=>{ae.info("[Toolbar]","Activate Settings")},onDeactive:()=>{ae.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(wt.isFullScreen())};wt.isFullScreen()?(wt.exitFullscreen(),window.removeEventListener("resize",n)):wt.fullScreen(null==(i=e.viewerContainer)?void 0:i.parentElement),window.addEventListener("resize",n)}}},Ppe={SceneClear:{icon:{default:"icon-clear",active:"icon-clear-filled"},menuName:"clear",type:1,onClick:()=>{}}},Ipe={HomeView:{icon:{default:"icon-zhushitu",active:"icon-zhushitu"},menuName:"Toolbar.homeView",type:1,onClick:e=>{e.goToHomeView()}},ZoomToRectangle:{icon:{default:"icon-kuangxuanfangda",active:"icon-kuangxuanfangda"},menuName:"Toolbar.zoomToRectangle",type:4,onClick:e=>{e.removeEventListener("BoxSelectDeactivated"),e.addEventListener("BoxSelectDeactivated",(()=>{var t;null==(t=e.toolbar)||t.setActive("ZoomToRectangle",!1)})),e.zoomToRect()},mutexIds:["GetScreenshot"]},GetScreenshot:{icon:{default:"icon-frame-clipping",active:"icon-frame-clipping"},menuName:"Toolbar.screenshot",type:4,onClick:e=>{e.removeEventListener("BoxSelectDeactivated"),e.addEventListener("BoxSelectDeactivated",(()=>{var t;null==(t=e.toolbar)||t.setActive("GetScreenshot",!1)})),e.getScreenshot().then((e=>{if(ae.info("[Toolbar] getScreenshot() returns:",null==e?void 0:e.base64Image),null==e||!e.base64Image)throw"[Toolbar] Image data is empty!";let t=document.createElement("a");t.href=null==e?void 0:e.base64Image,t.download="",t.click()})).catch((t=>{var i;ae.error("[Toolbar] Failed to get screenshot, reason:",t),null==(i=e.toolbar)||i.setActive("GetScreenshot",!1)}))},mutexIds:["ZoomToRectangle"]},Measure:{icon:{default:"icon-celiang1",active:"icon-celiang1"},menuName:"Toolbar.measurement",type:3,children:{MeasureDistance:{icon:{default:"icon-measure-distance"},menuName:"Toolbar.distanceMeasurement",onActive:e=>{e.activateMeasurement("Distance")},onDeactive:e=>{e.deactivateMeasurement()},type:4,mutexIds:["MeasureArea","MeasureAngle","MeasureCoordinate","ZoomToRectangle","GetScreenshot"]},MeasureArea:{icon:{default:"icon-measure-area-color"},onActive:e=>{e.activateMeasurement("Area")},onDeactive:e=>{e.deactivateMeasurement()},type:4,menuName:"Toolbar.areaMeasurement",mutexIds:["MeasureDistance","MeasureAngle","MeasureCoordinate","ZoomToRectangle","GetScreenshot"]},MeasureAngle:{menuName:"Toolbar.angleMeasurement",icon:{default:"icon-angle-measure"},type:4,onActive:e=>{e.activateMeasurement("Angle")},onDeactive:e=>{e.deactivateMeasurement()},mutexIds:["MeasureDistance","MeasureArea","MeasureCoordinate","ZoomToRectangle","GetScreenshot"]},MeasureCoordinate:{menuName:"Toolbar.coordinateMeasurement",icon:{default:"icon-distancemeasure",iconFont:"gemini-viewer-icon"},type:4,onActive:e=>{e.activateMeasurement("Coordinate")},onDeactive:e=>{e.deactivateMeasurement()},visible:!1,mutexIds:["MeasureDistance","MeasureArea","MeasureAngle","ZoomToRectangle","GetScreenshot"]},MeasureClear:{icon:{default:"icon-clear",active:"icon-clear-filled",iconFont:"gemini-viewer-icon"},onClick:e=>{ae.debug("[Toolbar]","Clearing Measure",e),e.clearMeasurements()},type:1,menuName:"Toolbar.clearMeasurement"}}},Markup:{icon:{default:"icon-annotation"},menuName:"Toolbar.markup",type:1,onClick:(e,t)=>{var i,n,r;null==(i=e.toolbar)||i.updateMenu("Measure",{defaultActive:!1}),null==(n=e.toolbar)||n.setActive("ZoomToRectangle",!1),e.getMarkups().forEach((t=>e.setMarkupVisibility(t.id,!0))),null==(r=e.toolbar)||r.setActive("MarkupVisibility",!1),e.activateMarkup("CloudRectWithTextMarkup"),t.hide(),new OR(e,Kn({},qfe))}},MarkupVisibility:{icon:{default:"icon-annotation-show",active:"icon-annotation-hide"},menuName:"Toolbar.markupVisibility",type:4,onActive:e=>{e.getMarkups().forEach((t=>e.setMarkupVisibility(t.id,!1)))},onDeactive:e=>{e.getMarkups().forEach((t=>e.setMarkupVisibility(t.id,!0)))},visible:!0},Settings:{icon:{default:"icon-settings",active:"icon-settings-filled",iconFont:"gemini-viewer-icon"},menuName:"Toolbar.settings",type:4,onActive:()=>{ae.info("[Toolbar]","Activate Settings")},onDeactive:()=>{ae.info("[Toolbar]","Deactivate Settings")},visible:!0},Compared:{icon:{default:"icon-compared"},menuName:"Toolbar.compared",type:4,onActive:()=>{ae.info("[Toolbar]","Activate Compare")},onDeactive:()=>{ae.info("[Toolbar]","Deactivate Compare")},visible:!1},QuitCompare:{icon:{default:"icon-compared"},menuName:"Toolbar.quitCompare",type:4,onActive:()=>{ae.info("[Toolbar]","Activate Compare")},onDeactive:()=>{ae.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(wt.isFullScreen())};wt.isFullScreen()?(wt.exitFullscreen(),window.removeEventListener("resize",n)):wt.fullScreen(null==(i=e.viewerContainer)?void 0:i.parentElement),window.addEventListener("resize",n)}}},Dpe={enableToolbar:!0,enableContextMenu:!0,enableSpinner:!0,containerId:"myCanvas",units:"meters"},XGt={enableToolbar:!1,enableContextMenu:!1,containerId:"myCanvas"},Upe=$i(mc(),1),yE=$i(mc(),1),vut="gemini-context-menu",mC=class{constructor(e){this.itemList=[],this.id=e.id||vut,this.container=e.container||document.body,this.context=e.context||{},this.element=this.createMenuUI(e.items||[]),this.handleClick=()=>{this.hide()},!1!==e.hideOnMouseDown&&document.addEventListener("click",this.handleClick),this.hide()}isEnable(e){return e.getEnabled?e.getEnabled(this.context):void 0===e.enabled||e.enabled}isShown(e){return e.getShown?e.getShown(this.context):void 0===e.shown||e.shown}getTitle(e){return e.title||e.getTitle&&e.getTitle(this.context)||""}createMenuUI(e){let t=document.createElement("div");t.id=this.id,t.classList.add("context-menu");let i=this.createMenuGroup(e);return t.append(...i),this.container.appendChild(t),t}createMenuGroup(e){return(0,yE.map)(e,(e=>{let t=document.createElement("ul");return(0,yE.forEach)(e,(e=>{let 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.isEnable(e)?t.classList.remove("disabled"):t.classList.add("disabled"),this.isShown(e)?t.removeAttribute("hidden"):t.setAttribute("hidden",""),this.itemList.push([e,t]),t}updateMenuItems(){(0,yE.forEach)(this.itemList,(([e,t])=>{this.isEnable(e)?t.classList.remove("disabled"):t.classList.add("disabled"),this.isShown(e)?t.removeAttribute("hidden"):t.setAttribute("hidden",""),t.innerHTML=this.getTitle(e)}))}showMenuElement(e,t){let 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)}},uo=e=>({bimViewer:t})=>t.translate(`ContextMenu.${e}`),Ope=e=>{var t;let i=0;return null==(t=e.scene)||t.traverseVisible((e=>{e instanceof _t&&i++})),i>0},yut=e=>{var t,i;let n=0;return null==(t=e.scene)||t.traverse((e=>{e instanceof _t&&n++})),null==(i=e.scene)||i.traverseVisible((e=>{e instanceof _t&&n--})),n>0},HU=e=>e.hasTransparentObject(),gC=e=>Nn.isObjectSelectable(e),Lpe=(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||!Gr.isMergedMesh(r)||n===r.userData.batchId)},xut={getTitle:uo("viewFitEntity"),getShown:({hit:e})=>e,doAction:({bimViewer:e,hit:t})=>{e.flyToObject(t)}},but={getTitle:uo("viewFitAll"),getEnabled:({bimViewer:e})=>Ope(e),doAction:({bimViewer:e})=>e.viewFitAll()},Eut={getTitle:uo("hideEntity"),getShown:({hit:e})=>e,doAction:({bimViewer:e,hit:t})=>{gC(t)&&(e.clearSelection(),t.visible=!1,e.enableRender())}},_ut={getTitle:uo("hideOthers"),getShown:({hit:e})=>e,doAction:({bimViewer:e,hit:t})=>{var i;e.clearSelection(),null==(i=e.scene)||i.traverse((e=>{e instanceof _t&&gC(e)&&(e.visible=!1)})),t.visible=!0,e.enableRender()}},Tut={getTitle:uo("hideAll"),getEnabled:({bimViewer:e})=>Ope(e),doAction:({bimViewer:e})=>{var t;e.clearSelection(),null==(t=e.scene)||t.traverse((e=>{e instanceof _t&&gC(e)&&(e.visible=!1)})),e.enableRender()}},wut={getTitle:uo("showAll"),getEnabled:({bimViewer:e})=>yut(e),doAction:({bimViewer:e})=>{var t;null==(t=e.scene)||t.traverse((e=>{e instanceof _t&&gC(e)&&(e.visible=!0)})),e.enableRender()}},Sut={getTitle:({hit:e,bimViewer:t,instanceId:i,batchId:n})=>Lpe(t,e,i,n)?uo("deselect")({bimViewer:t}):uo("select")({bimViewer:t}),getShown:({hit:e,bimViewer:t})=>t.enableSelection&&e,doAction:({hit:e,bimViewer:t,instanceId:i,batchId:n})=>{Nn.isObjectSelectable(e)?Lpe(t,e,i,n)?t.clearSelection():t.selectObject(e,e.instanceId,n):ae.debug(`[ContextMenu] object(type: ${e.type}, name: ${e.name}) not selectable!`)}},Mut={getTitle:uo("selectNone"),getShown:({bimViewer:e})=>e.enableSelection,getEnabled:({bimViewer:e})=>e.selectedObject,doAction:({bimViewer:e})=>e.clearSelection()},Aut={getTitle:uo("xRayAll"),getShown:({bimViewer:e})=>!HU(e),doAction:({bimViewer:e})=>{e.clearSelection(),e.addOrRemoveObjectOpacity(!0),e.enableRender()}},Rut={getTitle:uo("xRayNone"),getEnabled:({bimViewer:e})=>HU(e),doAction:({bimViewer:e})=>{e.clearSelection(),HU(e)&&(e.addOrRemoveObjectOpacity(!1),e.enableRender())}},Cut={getTitle:uo("xRayEntity"),getShown:({hit:e})=>e,doAction:({bimViewer:e,hit:t})=>{e.clearSelection(),e.addOrRemoveObjectOpacity(!0,void 0,[t.id],void 0)}},Put={getTitle:uo("xRayOthers"),getShown:({hit:e})=>e,doAction:({bimViewer:e,hit:t})=>{e.clearSelection(),e.addOrRemoveObjectOpacity(!0,.1,void 0,[t.id]),e.enableRender()}},Iut={getTitle:({bimViewer:e})=>{let t="";switch(e.sectionType){case"PickPlaneSection":t="*showSectionPlane";break;case"AxisPlaneSection":t="showAxisSection";break;case"ObjectsBoxSection":t="*showSectionBox"}return e.translate(`ContextMenu.${t}`)},getShown:({bimViewer:e,section:t})=>("PickPlaneSection"===e.sectionType||"AxisPlaneSection"===e.sectionType)&&!!t&&!t.isShowSectionPlane,doAction:({bimViewer:e,section:t})=>{("PickPlaneSection"===e.sectionType||"AxisPlaneSection"===e.sectionType)&&(null==t||t.setSectionVisible(!0))}},Dut={getTitle:({bimViewer:e})=>{let t="";switch(e.sectionType){case"PickPlaneSection":t="hideSectionPlane";break;case"AxisPlaneSection":t="hideAxisSection";break;case"ObjectsBoxSection":t="hideSectionBox"}return e.translate(`ContextMenu.${t}`)},getShown:e=>kpe(e),doAction:({bimViewer:e,section:t})=>{("PickPlaneSection"===e.sectionType||"AxisPlaneSection"===e.sectionType)&&(null==t||t.setSectionVisible(!1))}},Lut={getTitle:uo("undoSection"),getShown:e=>kpe(e),doAction:({bimViewer:e,toolbar:t})=>{if("PickPlaneSection"===e.sectionType){let e=null==t?void 0:t.menuList.get("SectionPlane");null==e||e.setActive(!1)}else if("AxisPlaneSection"===e.sectionType){let e=null==t?void 0:t.menuList.get("SectionAxis");null==e||e.setActive(!1)}else if("ObjectsBoxSection"===e.sectionType){let e=null==t?void 0:t.menuList.get("SectionBox");null==e||e.setActive(!1)}}},kpe=({bimViewer:e,hit:t,section:i})=>("PickPlaneSection"===e.sectionType||"AxisPlaneSection"===e.sectionType)&&!!i&&i.isShowSectionPlane&&(null==t?void 0:t.name)===_5,Npe=[[Iut],[Dut,Lut],[xut,but],[Eut,_ut,Tut,wut],[Cut,Put,Aut,Rut],[Sut,Mut]],vC=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 UU(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")}},UU=class{constructor(e,t){this.viewer=e,this.eventBus=kv(),this.active=!1,this.element=this.createItem(t),this.eventBus.on("activechange",(e=>{this.resetActivate&&this.resetActivate(),e?(this.element.classList.add("activate"),this.viewer.activateLayout(t)):this.element.classList.remove("activate")}))}createItem(e){let t=document.createElement("div"),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")}},Gv=new Qe,Fpe=new Qe,Bpe=new ra,VU=new L,qv=new It,Hpe=new ct,Ef=class extends bf{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 qs,this.selected=!0,this.raf=new pf,this.clock=new Qa,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 RA,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(),ae.info(`[DxfViewer] Initialized in ${(Date.now()-this.timer)/1e3}s`)}init(){let e=this.viewerCfg;this.initThree(),Tn.isBrowser&&!e.context&&this.initDom(),this.initInputManager(),this.initEvents(),this.initControls(),this.initOthers(),this.enableSelection=e.enableSelection}initInputManager(){this.viewerContainer&&(this.inputManager=new Bo(this.viewerContainer))}initThree(){this.initScene(),this.initRenderer(),this.initCamera()}initDom(){let e=this.viewerCfg;this.initSpinner(),this.initCSS2DRenderer(),!0===e.enableAxisGizmo&&console.warn("[DxfViewer] enableAxisGizmo is deprecated, use AxisGizmoPlugin instead!"),!0===e.enableStats&&console.warn("[DxfViewer] enableStats is deprecated, use StatsPlugin instead!"),e.enableToolbar&&(this.toolbar=this.initToolbar()),e.enableBottomBar&&console.warn("[DxfViewer] enableBottomBar is deprecated, use BottomBarPlugin instead!"),e.enableProgressBar&&(this.loadingProgressBar=this.initLoadingProgressBar()),e.enableLayoutBar&&(this.dxfLayoutBar=new vC(this))}initScene(){let e=new mi;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};!Tn.isBrowser&&t&&Object.assign(i,{context:t,canvas:Tn.creatReactNativeCanvas(t)}),t&&(this.width=t.drawingBufferWidth,this.height=t.drawingBufferHeight),this.renderer=new ms(i),this.renderer.setClearColor(11119017,1),this.renderer.localClippingEnabled=!0,Tn.isBrowser&&(!t&&this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.domElement.classList.add("webgl-renderer"),null==(e=this.viewerContainer)||e.appendChild(this.renderer.domElement)),this.renderer.setSize(this.width,this.height),wt.printGpuInfo(this.renderer.getContext()),un.maxFragmentUniforms=this.renderer.capabilities.maxFragmentUniforms-20,this.enableOverlayRenderer&&(this.overlayRender=new On(this))}initCSS2DRenderer(){var e;let t=new gu;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 Ir(-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 sa(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 vi&&(r.markupData=this.selectedObject.getData()),this.selectedObject&&this.selectedObject instanceof wr&&(r.measureData=this.selectedObject.getData()),this.selectedObject&&this.selectedObject instanceof sn){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 vi&&(this.markupManager.removeMarkup(this.selectedObject),null==(n=this.undoRedoManager)||n.addCommand(new sm(this.markupManager,this.selectedObject.getData()))),this.measurePlugin&&this.selectedObject instanceof wr&&(null==(r=this.measurePlugin)||r.remove(this.selectedObject),null==(a=this.undoRedoManager)||a.addCommand(new vv(this.measurePlugin,this.selectedObject.getData()))))}))}initOthers(){!this.scene||!this.renderer||!this.camera||(this.renderer.domElement.style.outlineWidth="0")}initToolbar(){let e=this.viewerCfg;return new Du(this,(0,Upe.merge)({},Ipe,e.toolbarMenuConfig))}initLoadingProgressBar(){return new cf(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.font&&this.font.releaseFontData&&this.font.releaseFontData()}));if(ae.info(`[DxfViewer] Loaded '${e.src}' in ${(Date.now()-this.timer)/1e3}s, adding to scene...`),un.abortJobs&&Promise.reject("[DxfViewer] abort load dxf"),0===d.threejsObject.children.length){let t=`[DxfViewer] Nothing was loaded from ${e.src}`;return ae.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),ae.info(`[DxfViewer] Units of '${e.src}' is '${f}'`),e.matrix&&16===e.matrix.length){let t=new Qe;t.elements=e.matrix,p.applyMatrix4(t)}return this.addModel({modelId:r,dxfData:d}),wt.printMemory("After addLoadedModelToScene"),ae.info(`[DxfViewer] 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)return;let{dxfData:t,pdfData:i}=e,n=e.modelId,r=e=>!!this.loadedModels.find((t=>t.modelId===e));if(r(n)){let e=1;for(;r(`${n}_${e}`);)e++;n=`${n}_${e}`,ae.warn(`[DxfViewer] Model '${n}' is loaded more than once!`)}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),un.computeLineDistances(e),this.getMsTransformMatrix(n),this.masterModelId===n?this.activateLayout(un.MODEL_LAYOUT_NAME):this.handleOverlayDxf(n),ae.debug("[DxfViewer] dxfData:",t),this.scene.add(e);let r=null==t?void 0:t.threejsObject.children.find((e=>e.name===un.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=un.MODEL_LAYOUT_NAME;let n=(new It).setFromObject(t);this.layoutInfos[this.activeLayoutName]={homeViewExtent:n,extent:n},this.loadedModels.push(e),this.scene.add(t),this.updateGroundPlane(),this.flyToObject(t)}}isCompareMode(){return this.compareMode}compare(e,t,i,n){return dt(this,null,(function*(){var r,a,s,o,l;let{src:h,modelId:c}=e,{src:u}=t;if(this.compareMode)return Promise.reject("[DxfViewer] It is already under comparing mode!");if(this.masterModelId||this.loadedModels.length>0)return Promise.reject("[DxfViewer] Shouldn't load anything else before compare!");if(this.compareMode=!0,this.timer=Date.now(),this.increaseJobCount(),!this.font)return Promise.reject("[DxfViewer] Should set font first!");let d={ignorePaperSpace:!0,encoding:e.encoding},p=new un(this.loadingManager,d);p.setFont(this.font),this.font instanceof Ni&&this.font.getFontData&&(yield this.font.getFontData());let f=h+u,m=this.translate("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}))};wt.printMemory("Before comparing"),this.masterModelId=c||h,this.loadingDxfCount+=2,null==(r=this.loadingProgressBar)||r.addProgressItem(f),g(0);let y=Date.now(),x=yield p.parse(h,(e=>v(e,0,15))),b=yield p.parse(u,(e=>v(e,15,30))),[_,w]=yield Promise.allSettled([x,b]);if("rejected"===_.status)return Promise.reject(`[DxfViewer] Failed to parse ${h}`);if("rejected"===w.status)return Promise.reject(`[DxfViewer] Failed to parse ${u}`);if(ae.info(`[DxfViewer] loadFiles in ${(Date.now()-y)/1e3}s`),un.abortJobs)return Promise.reject("[DxfViewer] compare loadFile aborted");let S=_.value,M=w.value;y=Date.now();let E=yield new ns(S,M,i).compare((e=>v(e,30,60)));if(ae.info(`[DxfViewer] Compared in ${(Date.now()-y)/1e3}s`),ae.debug("[DxfViewer] Compared results:",E),un.abortJobs)return Promise.reject("[DxfViewer] compare change aborted");wt.printMemory("After getting the comparison results"),y=Date.now(),yield p.loadEntitiesForCompare(S,M,E,!0,(e=>v(e,60,95))),wt.printMemory("After Creating threejs objects based on comparison result"),null==(a=this.font)||a.releaseFontData(),this.changes=E,ae.info(`[DxfViewer] Creates threejs objects based on comparison result in ${(Date.now()-y)/1e3}s`);let T=S,A=M;if(this.loadingDxfCount-=2,this.decreaseJobCount(),Object.keys(E).length||ae.info("[DxfViewer] 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=`[DxfViewer] Nothing was loaded from ${h} and ${u}`;return ae.warn(e),Promise.reject(e)}let C=T.threejsObject,P=A.threejsObject;return C.name=h,P.name=u,y=Date.now(),this.addModel({modelId:e.modelId||e.src,dxfData:T}),wt.printMemory("After adding first loaded Model to scene"),g(95),this.addModel({modelId:t.modelId||t.src,dxfData:A}),wt.printMemory("After adding second loaded Model to scene"),ae.info(`[DxfViewer] Added compared objects to scene in ${(Date.now()-y)/1e3}s`),ae.info(`[DxfViewer] The comparison between ${h}' and '${u}' is completed in ${(Date.now()-this.timer)/1e3}s !`),g(100),null==(l=this.loadingProgressBar)||l.delayRemoveProgressItem(f),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 ae.warn(`[DxfViewer] Can't find model for modelId '${e}'!`);this.increaseJobCount(),this.switchTransformMs(un.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===un.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 ae.warn("[DxfViewer] layout name is empty !"),void this.decreaseJobCount();if(e===this.activeLayoutName)return void this.decreaseJobCount();let a=Date.now(),s=this.camera,o=this.getLayoutByName(e);if(!o)return ae.warn(`[DxfViewer] Can't find layout of ${e} !`),void this.decreaseJobCount();let l=this.loadedModels.find((e=>this.masterModelId===e.modelId));if(!l)return ae.warn(`[DxfViewer] Can't find master model for modelId '${this.masterModelId}'!`),void this.decreaseJobCount();if(this.raycastableObjects=void 0,this.activeLayoutName){let e=this.getActiveLayoutInfo();e.lastCameraPosition||(e.lastCameraPosition=new L),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!==un.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&&ae.warn(`[DxfViewer] Failed to find object for modelId '${this.masterModelId}', layer '${n}', layout '${e}'`)}})),t.forEach((e=>{e.removeFromParent()}))}let c=this.getFilteredViewports(o);ae.debug("[DxfViewer] 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 L);if(p>m.z+d){let e=Math.ceil(p+d);ae.info(`[DxfViewer] Changing camera's z value from ${m.z} to ${e}`);let t=f.getTarget(new L);m.setZ(e),f.setLookAt(m.x,m.y,m.z,t.x,t.y,t.z)}ae.info(`[DxfViewer] generateObjectsByViewport in ${(Date.now()-u)/1e3}s`),e!==un.MODEL_LAYOUT_NAME&&this.switchTransformMs(un.MODEL_LAYOUT_NAME,this.masterModelId),e!==un.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)&&(ae.warn(`[BimViewer] Got wired bbox, max: ${e.max.toArray()}, min: ${e.min.toArray()}, going to use the calculated one...`),e=h.extent)}else ae.warn("[BimViewer] Failed to get layout extent, going to use the calculated one..."),e=h.extent;h.homeViewExtent=e,this.zoomToBBox(e)}this.updateGroundPlane(),this.dispatchEvent("LayoutChanged"),wt.printMemory(`After activated layout '${this.activeLayoutName}'`),this.enableRender(),this.decreaseJobCount(),ae.info(`[DxfViewer] 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.isActived()&&(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:ae.warn(`[DxfViewer] 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=ji.cloneMaterial(i.material));let e=ji.cloneMaterial(i.material);ji.setMaterialColor(e,new ct(t)),un.updateMaterialUniforms(e),i.material=e}})):ae.warn(`[DxfViewer] 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)})):ae.warn(`[DxfViewer] No object found for layer '${e}'`),this.enableRender()}setFont(e){return dt(this,null,(function*(){let t=Date.now();zo.isShxFile(e[0])?this.font=yield(new zo).loadAsync(e):(e.length>1&&ae.warn("[DxfViewer] Only support 1 typeface font file for now, others will be ignored!"),this.font=yield(new wu).loadAsync(e[0])),ae.info(`[DxfViewer] Font file(s) load time in ${(Date.now()-t)/1e3}s`)}))}getFont(){return this.font}setLoadingManager(e){this.loadingManager=e}setDisplayLengthUnits(){throw new Error("Not implemented yet!")}setDisplayAreaUnits(){throw new Error("Not implemented yet!")}setDisplayPrecision(){throw new Error("Not implemented yet!")}getCurrentViewExtent(){return{min:this.getHitResultByNdcCoordinate({x:-1,y:-1}),max:this.getHitResultByNdcCoordinate({x:1,y:1})}}getScreenshot(){return dt(this,arguments,(function*(e="BoxSelection"){this.cancelAllOperations();let t=this.findPlugin("ScreenshotPlugin");if(t)return t.getScreenshotAsync(e);ae.warn("[DxfViwer] ScreenshotPlugin doesn't seem to be installed!")}))}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")):ae.warn("[DxfViewer] 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 xb(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 xb(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=on.getScreenPointByEvent(e,t),n=on.screenPoint2NdcPoint(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 zv(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 Qe,h=un.getDcs2WcsMatrix(o[0],a),c=new L(o[0].center.x,o[0].center.y,0).applyMatrix4(h),u=1;this.units&&s!==this.units&&(u=nfe(s,this.units)),c.multiplyScalar(u),l.makeTranslation(c.x,c.y,0);let d=o[0].viewTwistAngle;null!=d&&l.multiply((new Qe).makeRotationZ(Cn.degToRad(d))),l.multiply((new Qe).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 ae.warn(`[DxfViewer] Can't find model whose modelId is ${t}`);let r=n.msTransformMatrix;if(Gv.identity(),!r||!wt.isMatrixValid(r)||r.equals(Gv))return;let a=null==(i=n.dxfData)?void 0:i.threejsObject,s=null==a?void 0:a.children.find((e=>e.name===un.MODEL_LAYOUT_NAME));s&&(e===un.MODEL_LAYOUT_NAME?s.applyMatrix4(r):s.applyMatrix4(r.clone().invert()),s.updateMatrixWorld(!0))}getLayoutExtentEx(e){return e.layoutName===un.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 L,a=new L;if(!n)return void ae.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 L,a=new L;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=un.getDcs2WcsMatrix(e,h),c=new L(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 It(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++})),ae.debug(`[DxfViewer] 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 an&&(e.uniforms.u_cameraZoom&&(e.uniforms.u_cameraZoom=un.cameraZoomUniform),e.uniforms.u_viewportScale&&1===(null==t?void 0:t.header.$PSLTSCALE)&&(e.uniforms.u_viewportScale=un.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!");un.transformMatrixUniform={value:r.msToPsMatrix},un.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 Gi(new ye(l.x,l.y),new ye(h.x,h.y)),u=xu.generateSectionPlanesByBox(c),d=[],p=e=>(d[e.id]||(d[e.id]=e.clone(),this.setMaterialUniforms(d[e.id],i),xu.setMaterialSection(d[e.id],u)),d[e.id]),f=[...n,...t.frozenLayerHandles||[]];if(e!==un.MODEL_LAYOUT_NAME){let e=t;e.associatedLeafObjectSet||(e.associatedLeafObjectSet=new Set),o=e.associatedLeafObjectSet}let m=new Gn;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):ae.warn(`[DxfViewer] 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 Gn,Nn.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===un.SNAP_GROUP_NAME));b||(b=new Gn,b.visible=un.SHOW_SNAP_OBJECT,b.name=un.SNAP_GROUP_NAME,x.add(b));let _=null==y?void 0:y.children.find((e=>e.name===un.MODEL_LAYOUT_NAME)),w=null==_?void 0:_.children.find((e=>e.name===un.SNAP_GROUP_NAME));w&&w.traverse((e=>{if(!e.geometry)return;let t=e.userData.layerName;if(this.isLayerFrozenForViewport(i,t,f)||(qv.makeEmpty(),qv.expandByObject(e),!a.intersectsBox(qv)))return;let n=e.clone();Nn.setSharedVariablesOfObject(n);let s=n.parent,l=Gv.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&&Nn.removeEmptyObjectsFromRemovingObjects(v,m),m.traverse((e=>{Nn.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 ae.warn("[DxfViewer] 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>un.maxFragmentUniforms},n=new Set,a=e=>{n.has(e.id)||(n.add(e.id),i(e)||xu.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 ae.warn("[DxfViewer] 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===un.MODEL_LAYOUT_NAME));return r&&r.children.forEach((t=>{t.name!==un.SNAP_GROUP_NAME&&(t=>{let n=Ss.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 ae.warn("DxfData or its header is undefined!"),"Unitless";let i=t.$INSUNITS;return un.getDxfUnits(i)}generateSectionsBySpatialFilter(e,t){let i=e.clipPolylines[0];if(i.bConcave)return void ae.warn("[DxfViewer] clipPolyline.bConcave = true is not supported yet in spatialFilter !");Gv.copy(t),e.localMatrix&&Gv.multiply(e.localMatrix);let n=i.polyline,r=[];n.forEach((e=>{let t=e.clone().applyMatrix4(Gv);r.push(new ye(t.x,t.y))}));let a=Ls.isClockWise(r),s=!a&&!i.bReversed||a&&i.bReversed;return xu.generateSectionPlanesByPoints(r,s)}addLoadedModelToScene(e,t,i){return dt(this,null,(function*(){if(!this.scene)return;let n=t.modelId||t.src,r=e=>!!this.loadedModels.find((t=>t.modelId===e));if(r(n)){let e=1;for(;r(`${n}_${e}`);)e++;n=`${n}_${e}`,ae.warn(`[DxfViewer] Model '${n}' is loaded more than once!`)}let a={modelId:n,dxfData:i};this.loadedModels.push(a),e.matrixAutoUpdate=!1,e.updateMatrix(),e.updateMatrixWorld(!0),un.computeLineDistances(e),this.getMsTransformMatrix(n),this.masterModelId===n?this.activateLayout(un.MODEL_LAYOUT_NAME):this.handleOverlayDxf(n),ae.debug("[DxfViewer] dxfData:",i),this.scene.add(e);let s=null==i?void 0:i.threejsObject.children.find((e=>e.name===un.MODEL_LAYOUT_NAME));s&&this.setLayoutHidableObjectArray(s),this.updateGroundPlane(),this.raycastableObjects=void 0,this.masterModelId===n||this.enableRender()}))}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)&&Nn.isLeafObject(e)&&i.push(e)}))}return this.groundPlane&&i.push(this.groundPlane),this.raycastableObjects=i,ae.debug(`[DxfViewer] getRaycastableObjects() finds ${i.length} objects`),ae.debug(`[DxfViewer] getRaycastableObjects() costs ${(Date.now()-t)/1e3} s`),i}getViewportByPoint(e){if(0===this.activeLayoutName.length||this.activeLayoutName===un.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)})))}Fpe.multiplyMatrices(this.camera.projectionMatrix,this.camera.matrixWorldInverse),Bpe.setFromProjectionMatrix(Fpe);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===un.SNAP_GROUP_NAME));null==e||e.traverse((e=>{if(Nn.isLeafObject(e)){if(qv.makeEmpty(),qv.expandByObject(e),!Bpe.intersectsBox(qv))return;o.push(e)}}))}}this.groundPlane&&o.push(this.groundPlane),ae.debug("[DxfViewer] getRaycastableObjectsByMouse() from modelSpace"),this.lastFrame=(null==(a=this.renderer)?void 0:a.info.render.frame)||0,this.raycastableObjects=o}else{let e=new WeakSet,t=this.getLayoutByName(this.activeLayoutName);if(t){let 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))})),ae.debug("[DxfViewer] getRaycastableObjectsByMouse() from inside of viewport:",i.viewportId)):ae.debug("[DxfViewer] getRaycastableObjectsByMouse() from out of viewport"),this.groundPlane&&o.push(this.groundPlane)}return ae.debug(`[DxfViewer] getRaycastableObjectsByMouse() costs ${(Date.now()-h)/1e3} s`),o}getIntersections(e){let t=this.getRaycastableObjectsByMouse(e);return this.raycaster&&this.raycaster.intersectObjects(t,!0)||[]}handleMouseClick(e){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=>wt.vectorToString(e);ae.debug(`[DxfViewer] 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 _t||e instanceof rr||e instanceof $r){let i=ji.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 _t||e instanceof rr||e instanceof $r)&&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 ur&&t.dispose()}},r=!1;this.selectedObject&&(n(this.selectedObject),this.selectedObject=void 0,r=!0),e&&(i(e),this.selectedObject=e,e.userData.dxfEntity?ae.info("[DxfViewer] Selected entity:",e.userData.dxfEntity):ae.info("[DxfViewer] Selected object:",e),r=!0),r&&this.enableRender()}clearSelection(){var e;this.selectedObject&&this.selectedObject instanceof Ai?(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 It;e.forEach((e=>{let i=Ss.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 Li&&e.userData.clonedMesh||e instanceof _t&&Gr.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 _t||e instanceof rr)&&!["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&&(ae.info(`[DxfViewer] 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 ae.error("[DxfViewer] Camera position and lookAt cannot be the same!");if(!wt.isVectorValid(e)||!wt.isVectorValid(t))return void ae.error("[DxfViewer] Invalid position or lookAt!",e,t);let s=e.distanceTo(t);sr.far&&(e=e.clone().sub(t).normalize().multiplyScalar(.9*r.far),ae.warn("[DxfViewer] 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 L),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 L(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 L(e.x,e.y,n.position.z),s=r.getTarget(new L),o=new L(e.x,e.y,s.z);this.flyTo(a,o,t,i)}goToHomeView(){let e=this.getActiveLayoutInfo();e.homeViewExtent?this.zoomToBBox(e.homeViewExtent):ae.error(`[DxfViewer] 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 It(new L(e.min.x,e.min.y,0),new L(e.max.x,e.max.y,0)),l=new L;o.getCenter(l),l.z=0;let h=l.clone().setZ(Math.max(t.position.z,this.CAMERA_Z_POSITION));h.equals(l)||this.flyTo(h,l,s,!1)}zoomToExtent(){let e=this.getActiveLayoutInfo();e.extent?this.zoomToBBox(e.extent):(console.error("[DxfViewer] Failed to find extent of current layout! Will go to home view."),this.goToHomeView())}zoomToCompareChange(e){if(this.changes){let t=this.changes[e];if(!t)return;let i=t.box;i&&this.zoomToBBox(i.clone().expandByScalar(1.2))}}getCompareChanges(){return this.changes}setBackgroundColor(e,t,i){!this.scene||!this.renderer||(Hpe.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(Hpe),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();wt.expandBoxByScale(t,3);let i=t.min,n=t.max,r=n.x-i.x+n.y-i.y+n.z-i.z;wt.expandBoxByMinSize(t,r);let a=[],s=(e,t,i)=>{a.push(new L(e,t,i))},o=t.getSize(new L),l=t.getCenter(new L);if(s(-o.x/2,-o.y/2,0),s(o.x/2,-o.y/2,0),s(o.x/2,o.y/2,0),s(-o.x/2,o.y/2,0),this.groundPlane)this.groundPlane.position.copy(l),this.groundPlane.geometry.setFromPoints(a),this.groundPlane.geometry.computeBoundingSphere(),this.groundPlane.geometry.computeBoundingBox();else{let e=new Lt;e.setFromPoints(a),e.setIndex([0,3,2,0,2,1]);let t=new rn({color:"#888",transparent:!0,opacity:0,side:vr});this.groundPlane=new _t(e,t),this.groundPlane.visible=!0,this.groundPlane.frustumCulled=!1,this.groundPlane.position.copy(l),this.groundPlane.scale.set(1e5,1e5,1),this.groundPlane.name="groundPlane",this.groundPlane.renderOrder=-1e3,this.groundPlane.layers.enableAll(),Nn.disableLayerChannels(this.groundPlane,[12]),this.scene.add(this.groundPlane)}this.groundPlane.updateMatrixWorld()}computeBoundingBox(){var e;let t=new It;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 an?e.material.uniforms.u_color.value:e.material.color,t.equals(new ct(ns.ENTITY_COLOR_ADDED))||t.equals(new ct(ns.ENTITY_COLOR_REMOVED))},o=1;e.traverse((e=>{if(this.isCompareMode()&&s(e)||e.userData.isSnapObject||!Nn.isLeafObject(e))return;let t=e.geometry;t.boundingBox||t.computeBoundingBox();let i=t.boundingBox.clone();if(!i||!wt.isBoxValid(i))return;i.applyMatrix4(e.matrixWorld),i.getSize(VU);let n=Math.max(VU.x,VU.y),a=o/n;a<1/0?r.push({visibleMinZoom:a,object:e}):e instanceof $r?r.push({visibleMinZoom:o,object:e}):ae.warn("[DxfViewer] The size of bbox is 0 ! ",e)})),o=this.getVisiblePixelSize(r.length);let l=0;r.forEach((e=>{let t=e.visibleMinZoom*o;e.visibleMinZoom=t,e.object.userData.visibleMinZoom=t,t>a&&(e.object.visible=!1,l++)})),r.sort(((e,t)=>e.visibleMinZoom-t.visibleMinZoom)),ae.debug(`[DxfViewer] 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++})),ae.info(`[DxfViewer] hidableObjects count:${i}, real count:${r}, layout count: ${a}, level:`,n),ae.info("[DxfViewer] 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,ae.debug(`[DxfViewer] 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){un.cameraZoomUniform.value=e}},yC=class{constructor(e){this.jobCount=0,this.viewer=new Ef(e);let t=document.getElementById(e.containerId);this.container=(null==t?void 0:t.parentElement)||document.body,this.loadingProgressBar=new cf(this.container),this.loader=new un(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 dt(this,null,(function*(){let t=Date.now();zo.isShxFile(e[0])?this.font=yield(new zo).loadAsync(e):(e.length>1&&ae.warn("[DxfCompareHelper] Only support 1 typeface font file for now, others will be ignored!"),this.font=yield(new wu).loadAsync(e[0])),ae.info(`[DxfCompareHelper] Font file(s) load time in ${(Date.now()-t)/1e3}s`)}))}compare(e,t,i,n){return dt(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.font)return Promise.reject("[DxfCompareHelper] Should set font first!");this.loader.setFont(this.font),this.font instanceof Ni&&this.font.getFontData&&(yield this.font.getFontData());let p=h+u,f=gm.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}))};wt.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(ae.info(`[DxfCompareHelper] loadFiles in ${(Date.now()-v)/1e3}s`),un.abortJobs)return Promise.reject("[DxfCompareHelper] compare loadFile aborted");let w=b.value,S=_.value;v=Date.now();let M=yield new ns(w,S,i).compare((e=>g(e,30,60)));if(ae.info(`[DxfCompareHelper] Compared in ${(Date.now()-v)/1e3}s`),ae.debug("[DxfCompareHelper] Compared results:",M),un.abortJobs)return Promise.reject("[DxfCompareHelper] compare change aborted");wt.printMemory("After getting the comparison results"),v=Date.now(),yield this.loader.loadEntitiesForCompare(w,S,M,!0,(e=>g(e,60,95))),wt.printMemory("After Creating threejs objects based on comparison result"),null==(a=this.font)||a.releaseFontData(),this.changes=M,ae.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||ae.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 ae.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}),wt.printMemory("After adding first loaded Model to scene"),m(95),this.viewer.addModel({modelId:t.modelId||t.src,dxfData:T}),wt.printMemory("After adding second loaded Model to scene"),ae.info(`[DxfCompareHelper] Added compared objects to scene in ${(Date.now()-v)/1e3}s`),ae.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)}},Vpe=class extends yC{constructor(e,t){super(e),this.syncCamera=!1,this.syncCameraControls=(e,t,i)=>{let n=new L,r=new L,a=new L;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 Ef(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 dt(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.font)return Promise.reject("[DxfCompareHelper] Should set font first!");this.loader.setFont(this.font),this.font instanceof Ni&&this.font.getFontData&&(yield this.font.getFontData());let f=h+u,m=gm.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}))};wt.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(ae.info(`[DxfCompareHelper] loadFiles in ${(Date.now()-y)/1e3}s`),un.abortJobs)return Promise.reject("[DxfCompareHelper] compare loadFile aborted");let S=_.value,M=w.value;y=Date.now();let E=yield new ns(S,M,i).compare((e=>v(e,30,60)));if(ae.info(`[DxfCompareHelper] Compared in ${(Date.now()-y)/1e3}s`),ae.debug("Compared results:",E),un.abortJobs)return Promise.reject("[DxfCompareHelper] compare change aborted");wt.printMemory("After getting the comparison results"),y=Date.now(),yield this.loader.loadEntitiesForCompare(S,M,E,!1,(e=>v(e,60,95))),wt.printMemory("After Creating threejs objects based on comparison result"),null==(a=this.font)||a.releaseFontData(),this.changes=E,ae.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||ae.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 ae.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}),wt.printMemory("After adding first loaded Model to scene"),g(95),this.viewer2.addModel({modelId:t.modelId||t.src,dxfData:A}),wt.printMemory("After adding second loaded Model to scene"),ae.info(`[DxfCompareHelper] Added compared objects to scene in ${(Date.now()-y)/1e3}s`),ae.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)))}}},bm=$i(zpe(),1),Fh=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 Fh.offsetEdge(this.current,this.next,e,t)}inverseOffset(e,t){return Fh.offsetEdge(this.next,this.current,e,t)}inverse(){return new Fh(this.next,this.current)}static offsetEdge(e,t,i,n){return new Fh([e[0]+i,e[1]+n],[t[0]+i,t[1]+n])}},xE=Array.isArray,Gpe=(e,t)=>e[0]===t[0]&&e[1]===t[1],qU=e=>Array.isArray(e)&&e.length,jpe=(e,t=0,i=!1)=>{let n,r;if(qU(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&&qU(e)&&qU(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},qpe=class{constructor(e,t=5){if(this.distance=0,this.arcSegments=t,!xE(e))throw new Error("Offset requires at least one coodinate to work with");this.edges=[],xE(e)&&"number"==typeof e[0]?this.vertices=e:(this.vertices=jpe(e),this.processContour(this.vertices,this.edges))}processContour(e,t){let i,n;if(xE(e[0])&&"number"==typeof e[0][0])for(n=e.length,Gpe(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,bm.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(xE(e[0])&&"number"==typeof e[0][0]){for(n=0,r=e.length-1;n0&&(i=1===i.length?[i[0]]:(0,bm.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,bm.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()})))}},bE=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)}},kut=.0033528106647474805,Wpe=-(6378137*kut-6378137);function XU(e){return 3===e||4===e}function Em(e,t){return e.__lastFrameVisited===t&&e.__used}function Xpe(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 Ype(e,t,i){if(Xpe(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,Nut=e=>1/(e.__depthFromRenderedParent+1),_C=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 xC;t.unloadPriorityCallback=Nut;let i=new bE;i.maxJobs=4,i.priorityCallback=Kpe;let n=new bE;n.maxJobs=1,n.priorityCallback=Kpe,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||EC(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++,YU(r,this),$U(r,this),ZU(r,this),KU(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=jU(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(),EC(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=jU(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 TC(e){return(new TextDecoder).decode(e)}var Bh=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(TC(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}getBuffer(e,t){let{buffer:i,binOffset:n}=this;return i.slice(n+e,n+e+t)}},_f=class extends Bh{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)}},Ol=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 Tc(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 wC=class extends Ol{parse(e){let t=new DataView(e),i=Tc(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 Bh(h,0,a,s),u=28+a+s,d=e.slice(u,u+o+l),p=new _f(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)}}},jv=class extends wC{constructor(e=eo){super(),this.manager=e,this.adjustmentTransform=new Qe}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 Ou(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)}))}},SC=class extends Ol{parse(e){let t=new DataView(e),i=Tc(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 Bh(h,0,a,s),u=28+a+s,d=e.slice(u,u+o+l),p=new _f(d,c.getData("BATCH_LENGTH")||c.getData("POINTS_LENGTH"),0,o,l);return Promise.resolve({version:n,featureTable:c,batchTable:p})}},Jpe={RGB:"color",POSITION:"position"},Wv=class extends SC{constructor(e=eo){super(),this.manager=e}parse(e){return super.parse(e).then((e=>dt(this,null,(function*(){let t,{featureTable:i}=e,n=new hi,r=i.header.extensions;if(r&&r["3DTILES_draco_point_compression"]){let{byteOffset:e,byteLength:a,properties:s}=r["3DTILES_draco_point_compression"],o=this.manager.getHandler("draco.drc");if(null==o)throw new Error("PNTSLoader: dracoLoader not available.");let l={};for(let t in s)t in Jpe&&t in s&&(l[Jpe[t]]=s[t]);let h={attributeIDs:l,attributeTypes:{position:"Float32Array",color:"Uint8Array"},useUniqueIDs:!0},c=i.getBuffer(e,a);t=yield o.decodeGeometry(c,h),t.attributes.color&&(n.vertexColors=!0)}else{let e=i.getData("POINTS_LENGTH"),r=i.getData("POSITION",e,"FLOAT","VEC3"),a=i.getData("RGB",e,"UNSIGNED_BYTE","VEC3");t=new Lt,t.setAttribute("position",new pn(r,3,!1)),null!==a&&(t.setAttribute("color",new pn(a,3,!0)),n.vertexColors=!0)}["QUANTIZED_VOLUME_OFFSET","QUANTIZED_VOLUME_SCALE","CONSTANT_RGBA","BATCH_LENGTH","POSITION_QUANTIZED","RGBA","RGB565","NORMAL","NORMAL_OCT16P"].forEach((e=>{e in i.header&&console.warn(`PNTSLoader: Unsupported FeatureTable feature "${e}" detected.`)}));let a=new $r(t,n);e.scene=a,e.scene.featureTable=i;let s=i.getData("RTC_CENTER");return s&&(e.scene.position.x+=s[0],e.scene.position.y+=s[1],e.scene.position.z+=s[2]),e}))))}},MC=class extends Ol{parse(e){let t=new DataView(e),i=Tc(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 Bh(c,0,a,s),d=32+a+s,p=e.slice(d,d+o+l),f=new _f(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(TC(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})))}},Qpe=new L,e6=new L,t6=new L,eme=new L,n6=new ir,AC=new L,RC=new Qe,Xv=class extends MC{constructor(e=eo){super(),this.manager=e,this.adjustmentTransform=new Qe}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 Ou(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 Li(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 L;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 Gn;return e.forEach((e=>{t.add(e.scene)})),{tiles:e,scene:t}}))}},IC=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])}}},DC=class extends Ol{constructor(e=eo){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 Ou(n),a.register((()=>new IC)),"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)}))}},LC=new Qe,OC=class extends Gn{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?LC.copy(this.matrix):LC.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1;let e=LC.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(LC);let e=this.children;for(let t=0,i=e.length;t=t&&s<=i&&l>=n&&l<=r){let t=But(e);u.push(t),this.getCartographicToPosition(s,l,o,t)}}}return u}getBoundingBox(e,t){rme();let{latStart:i,latEnd:n,lonStart:r,lonEnd:a}=this;if(n-i{Object.getPrototypeOf(e).raycast.call(e,t,i)}))}function a6(e,t,i,n){if(i.has(e)){if(s6(e.cached.scene,n,kl),kl.length>0){kl.length>1&&kl.sort(i6);let e=kl[0];return kl.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),h.containsPoint(Tm.origin)?i.distance=0:i.distance=ime.distanceToSquared(Tm.origin)*t*t,i.tile=e}}}r.sort(i6);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)?(s6(a,n,kl),kl.length>0&&(kl.length>1&&kl.sort(i6),l=kl[0])):l=a6(r,t,i,n),l){let e=l.distance*l.distance;e{e.frustumCulled=e[ome]&&t}))}var wE=class extends _C{get autoDisableRendererCulling(){return this._autoDisableRendererCulling}set autoDisableRendererCulling(e){this._autoDisableRendererCulling!==e&&(super._autoDisableRendererCulling=e,this.forEachLoadedModel((t=>{ame(t,!e)})))}constructor(...e){super(...e),this.group=new OC(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 hu;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=a6(this.root,this.group,this.activeTiles,e);i&&t.push(i)}else o6(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 ye),t.push(e),!0)}setResolution(e,t,i){let n=this.cameraMap;return!!n.has(e)&&(t instanceof ye?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 Wv(s);t.workingPath=r,t.fetchOptions=a,l=t.parse(e).then((e=>e.scene));break}case"i3dm":{let t=new Xv(s);t.workingPath=r,t.fetchOptions=a,t.adjustmentTransform.copy(wc),l=t.parse(e).then((e=>e.scene));break}case"cmpt":{let t=new PC(s);t.workingPath=r,t.fetchOptions=a,t.adjustmentTransform.copy(wc),l=t.parse(e).then((e=>e.scene));break}case"gltf":case"glb":let t=new DC(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(wc),e.matrix.premultiply(u),e.matrix.decompose(e.position,e.quaternion,e.scale),e.traverse((e=>{e[ome]=e.frustumCulled})),ame(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=Mc.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=Mc.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=Mc.BlurDirectionX,e.setRenderTarget(this.renderTargetBlurBuffer2),e.clear(),this.fsQuad.render(e),this.separableBlurMaterial2.uniforms.colorTexture.value=this.renderTargetBlurBuffer2.texture,this.separableBlurMaterial2.uniforms.direction.value=Mc.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 an({uniforms:{depthTexture:{value:null},cameraNearFar:{value:new ye(.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 an({uniforms:{maskTexture:{value:null},texSize:{value:new ye(.5,.5)},visibleEdgeColor:{value:new L(1,1,1)},hiddenEdgeColor:{value:new L(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 an({defines:{MAX_RADIUS:e},uniforms:{colorTexture:{value:null},texSize:{value:new ye(.5,.5)},direction:{value:new ye(.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 an({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:sc,depthTest:!1,depthWrite:!1,transparent:!0})}};Mc.BlurDirectionX=new ye(1,0),Mc.BlurDirectionY=new ye(0,1);var GC=class extends cs{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}},RE={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 ye(512,512)},cameraNear:{value:1},cameraFar:{value:100},cameraProjectionMatrix:{value:new Qe},cameraInverseProjectionMatrix:{value:new Qe},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}"},Gh={defines:{KERNEL_RADIUS:4,DEPTH_PACKING:1,PERSPECTIVE_CAMERA:1},uniforms:{tDiffuse:{value:null},size:{value:new ye(512,512)},sampleUvOffsets:{value:[new ye(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}"},CE={createSampleWeights:function(e,t){let i=[];for(let n=0;n<=e;n++)i.push(Gut(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=CE.createSampleOffsets(t,n),e.uniforms.sampleWeights.value=CE.createSampleWeights(t,i),e.needsUpdate=!0}};function Gut(e,t){return Math.exp(-e*e/(t*t*2))/(Math.sqrt(2*Math.PI)*t)}var qC={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}"},PE=class extends cs{constructor(e,t,i=!1,n=!1,r=new ye(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 ye(r.x,r.y),this.saoRenderTarget=new Jn(this.resolution.x,this.resolution.y,{type:xr}),this.blurIntermediateRenderTarget=this.saoRenderTarget.clone(),this.beautyRenderTarget=this.saoRenderTarget.clone(),this.normalRenderTarget=new Jn(this.resolution.x,this.resolution.y,{minFilter:qr,magFilter:qr,type:xr}),this.depthRenderTarget=this.normalRenderTarget.clone(),this.supportsDepthTextureExtension&&(a=new Od,a.type=H0,this.beautyRenderTarget.depthTexture=a,this.beautyRenderTarget.depthBuffer=!0),this.depthMaterial=new ac,this.depthMaterial.depthPacking=V0,this.depthMaterial.blending=jr,this.normalMaterial=new Bd,this.normalMaterial.blending=jr,this.saoMaterial=new an({defines:Object.assign({},RE.defines),fragmentShader:RE.fragmentShader,vertexShader:RE.vertexShader,uniforms:gi.clone(RE.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=jr,this.vBlurMaterial=new an({uniforms:gi.clone(Gh.uniforms),defines:Object.assign({},Gh.defines),vertexShader:Gh.vertexShader,fragmentShader:Gh.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=jr,this.hBlurMaterial=new an({uniforms:gi.clone(Gh.uniforms),defines:Object.assign({},Gh.defines),vertexShader:Gh.vertexShader,fragmentShader:Gh.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=jr,this.materialCopy=new an({uniforms:gi.clone(ua.uniforms),vertexShader:ua.vertexShader,fragmentShader:ua.fragmentShader,blending:jr}),this.materialCopy.transparent=!0,this.materialCopy.depthTest=!1,this.materialCopy.depthWrite=!1,this.materialCopy.blending=qp,this.materialCopy.blendSrc=F0,this.materialCopy.blendDst=Ud,this.materialCopy.blendEquation=Co,this.materialCopy.blendSrcAlpha=N0,this.materialCopy.blendDstAlpha=Ud,this.materialCopy.blendEquationAlpha=Co,this.depthCopy=new an({uniforms:gi.clone(qC.uniforms),vertexShader:qC.vertexShader,fragmentShader:qC.fragmentShader,blending:jr}),this.fsQuad=new ca(null)}render(e,t,i){if(this.renderToScreen&&(this.materialCopy.blending=jr,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)&&(CE.configure(this.vBlurMaterial,this.params.saoBlurRadius,this.params.saoBlurStdDev,new ye(0,1)),CE.configure(this.hBlurMaterial,this.params.saoBlurRadius,this.params.saoBlurStdDev,new ye(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=qp:a.blending=jr,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()}};PE.OUTPUT={Beauty:1,Default:0,SAO:2,Depth:3,Normal:4};var jC=class extends cs{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=ua;this.copyUniforms=gi.clone(r.uniforms),this.copyMaterial=new an({uniforms:this.copyUniforms,vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,transparent:!0,depthTest:!1,depthWrite:!1,premultipliedAlpha:!0,blending:sc}),this.fsQuad=new ca(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 Jn(i.width,i.height,{type:xr}),this.sampleRenderTarget.texture.name="SSAARenderPass.sample");let n=qut[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,L=255&f,I=255&m,D=255&g,O=this.perm[L+this.perm[I+this.perm[D]]]%12,k=this.perm[L+o+this.perm[I+l+this.perm[D+h]]]%12,N=this.perm[L+c+this.perm[I+u+this.perm[D+d]]]%12,F=this.perm[L+1+this.perm[I+1+this.perm[D+1]]]%12,U=.6-x*x-b*b-_*_;U<0?n=0:(U*=U,n=U*U*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[F],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,L=c[M][2]>=2?1:0,I=c[M][3]>=2?1:0,D=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,F=b-E+p,U=_-T+p,B=w-A+p,z=S-C+p,H=b-P+2*p,V=_-R+2*p,j=w-L+2*p,W=S-I+2*p,G=b-D+3*p,X=_-O+3*p,Y=w-k+3*p,q=S-N+3*p,K=b-1+4*p,J=_-1+4*p,Z=w-1+4*p,$=S-1+4*p,Q=255&m,ee=255&g,te=255&v,ie=255&y,ne=u[Q+u[ee+u[te+u[ie]]]]%32,re=u[Q+E+u[ee+T+u[te+A+u[ie+C]]]]%32,ae=u[Q+P+u[ee+R+u[te+L+u[ie+I]]]]%32,se=u[Q+D+u[ee+O+u[te+k+u[ie+N]]]]%32,oe=u[Q+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-F*F-U*U-B*B-z*z;he<0?a=0:(he*=he,a=he*he*this.dot4(h[re],F,U,B,z));let ce=.6-H*H-V*V-j*j-W*W;ce<0?s=0:(ce*=ce,s=ce*ce*this.dot4(h[ae],H,V,j,W));let ue=.6-G*G-X*X-Y*Y-q*q;ue<0?o=0:(ue*=ue,o=ue*ue*this.dot4(h[se],G,X,Y,q));let de=.6-K*K-J*J-Z*Z-$*$;return de<0?l=0:(de*=de,l=de*de*this.dot4(h[oe],K,J,Z,$)),27*(r+a+s+o+l)}},IE={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 ye},cameraProjectionMatrix:{value:new Qe},cameraInverseProjectionMatrix:{value:new Qe},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}"},DE={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}"},LE={uniforms:{tDiffuse:{value:null},resolution:{value:new ye}},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}"},Nl=class extends cs{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 Od;r.format=Eh,r.type=eu,this.beautyRenderTarget=new Jn(this.width,this.height,{type:xr}),this.normalRenderTarget=new Jn(this.width,this.height,{minFilter:qr,magFilter:qr,type:xr,depthTexture:r}),this.ssaoRenderTarget=new Jn(this.width,this.height,{type:xr}),this.blurRenderTarget=this.ssaoRenderTarget.clone(),this.ssaoMaterial=new an({defines:Object.assign({},IE.defines),uniforms:gi.clone(IE.uniforms),vertexShader:IE.vertexShader,fragmentShader:IE.fragmentShader,blending:jr}),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 Bd,this.normalMaterial.blending=jr,this.blurMaterial=new an({defines:Object.assign({},LE.defines),uniforms:gi.clone(LE.uniforms),vertexShader:LE.vertexShader,fragmentShader:LE.fragmentShader}),this.blurMaterial.uniforms.tDiffuse.value=this.ssaoRenderTarget.texture,this.blurMaterial.uniforms.resolution.value.set(this.width,this.height),this.depthRenderMaterial=new an({defines:Object.assign({},DE.defines),uniforms:gi.clone(DE.uniforms),vertexShader:DE.vertexShader,fragmentShader:DE.fragmentShader,blending:jr}),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 an({uniforms:gi.clone(ua.uniforms),vertexShader:ua.vertexShader,fragmentShader:ua.fragmentShader,transparent:!0,depthTest:!1,depthWrite:!1,blendSrc:F0,blendDst:Ud,blendEquation:Co,blendSrcAlpha:N0,blendDstAlpha:Ud,blendEquationAlpha:Co}),this.fsQuad=new ca(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=WM),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 Nl.OUTPUT.SSAO:this.copyMaterial.uniforms.tDiffuse.value=this.ssaoRenderTarget.texture,this.copyMaterial.blending=jr,this.renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case Nl.OUTPUT.Blur:this.copyMaterial.uniforms.tDiffuse.value=this.blurRenderTarget.texture,this.copyMaterial.blending=jr,this.renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case Nl.OUTPUT.Beauty:this.copyMaterial.uniforms.tDiffuse.value=this.beautyRenderTarget.texture,this.copyMaterial.blending=jr,this.renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case Nl.OUTPUT.Depth:this.renderPass(e,this.depthRenderMaterial,this.renderToScreen?null:t);break;case Nl.OUTPUT.Normal:this.copyMaterial.uniforms.tDiffuse.value=this.normalRenderTarget.texture,this.copyMaterial.blending=jr,this.renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case Nl.OUTPUT.Default:this.copyMaterial.uniforms.tDiffuse.value=this.beautyRenderTarget.texture,this.copyMaterial.blending=jr,this.renderPass(e,this.copyMaterial,this.renderToScreen?null:t),this.copyMaterial.uniforms.tDiffuse.value=this.blurRenderTarget.texture,this.copyMaterial.blending=qp,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 texSize;\n\t\t\t\tuniform vec2 direction;\n\n\t\t\t\tfloat gaussianPdf(in float x, in float sigma) {\n\t\t\t\t\treturn 0.39894 * exp( -0.5 * x * x/( sigma * sigma))/sigma;\n\t\t\t\t}\n\t\t\t\tvoid main() {\n\t\t\t\t\tvec2 invSize = 1.0 / texSize;\n\t\t\t\t\tfloat fSigma = float(SIGMA);\n\t\t\t\t\tfloat weightSum = gaussianPdf(0.0, fSigma);\n\t\t\t\t\tvec3 diffuseSum = texture2D( colorTexture, vUv).rgb * weightSum;\n\t\t\t\t\tfor( int i = 1; i < KERNEL_RADIUS; i ++ ) {\n\t\t\t\t\t\tfloat x = float(i);\n\t\t\t\t\t\tfloat w = gaussianPdf(x, fSigma);\n\t\t\t\t\t\tvec2 uvOffset = direction * invSize * x;\n\t\t\t\t\t\tvec3 sample1 = texture2D( colorTexture, vUv + uvOffset).rgb;\n\t\t\t\t\t\tvec3 sample2 = texture2D( colorTexture, vUv - uvOffset).rgb;\n\t\t\t\t\t\tdiffuseSum += (sample1 + sample2) * w;\n\t\t\t\t\t\tweightSum += 2.0 * w;\n\t\t\t\t\t}\n\t\t\t\t\tgl_FragColor = vec4(diffuseSum/weightSum, 1.0);\n\t\t\t\t}"})}getCompositeMaterial(e){return new an({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}"})}};qh.BlurDirectionX=new ye(1,0),qh.BlurDirectionY=new ye(0,1);var ume={uniforms:{tDiffuse:{value:null},resolution:{value:new ye(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"},XC=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 Fr(this.webcamCanvas);this.webcamTexture=i,i.minFilter=_r,i.magFilter=_r,this.shaderMaterial=new an({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 ti(e,t);return new _t(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)}},jut=new L(1,0,0),Wut=new L(0,1,0),Xut=new L(0,0,1),YC=class extends df{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.initOrUpdateClipPlane(),this.initOrUpdateVertices(),this.initOrUpdateSectionPlane(),this.setClippingEnable(!0)}deactivate(){super.deactivate(),this.planesMesh&&this.scene.remove(...this.planesMesh),this.planesMesh=void 0}initOrUpdateVertices(){if(!this.sectionBox)return;let{min:e,max:t}=this.sectionBox;this.vertices=[new L(t.x,t.y,t.z),new L(e.x,t.y,t.z),new L(e.x,e.y,t.z),new L(t.x,e.y,t.z),new L(t.x,t.y,e.z),new L(e.x,t.y,e.z),new L(e.x,e.y,e.z),new L(t.x,e.y,e.z)]}initOrUpdateClipPlane(){let{min:e,max:t}=this.sectionBox;this.clipPlanes?(this.clipPlanes[0].constant=t.x,this.clipPlanes[1].constant=-e.x,this.clipPlanes[2].constant=t.y,this.clipPlanes[3].constant=-e.y,this.clipPlanes[4].constant=t.z,this.clipPlanes[5].constant=-e.z):this.clipPlanes=[new Nr(new L(-1,0,0),t.x),new Nr(new L(1,0,0),-e.x),new Nr(new L(0,-1,0),t.y),new Nr(new L(0,1,0),-e.y),new Nr(new L(0,0,-1),t.z),new Nr(new L(0,0,1),-e.z)]}initOrUpdateSectionPlane(){let e=this.vertices;if(e){if(this.planesMesh)this.planesMesh[0].update([e[4],e[0],e[3],e[7]]),this.planesMesh[1].update([e[1],e[5],e[6],e[2]]),this.planesMesh[2].update([e[4],e[5],e[1],e[0]]),this.planesMesh[3].update([e[6],e[7],e[3],e[2]]),this.planesMesh[4].update([e[0],e[1],e[2],e[3]]),this.planesMesh[5].update([e[5],e[4],e[7],e[6]]);else{let t=[new _i("Right",[e[4],e[0],e[3],e[7]]),new _i("Left",[e[1],e[5],e[6],e[2]]),new _i("Top",[e[4],e[5],e[1],e[0]]),new _i("Bottom",[e[6],e[7],e[3],e[2]]),new _i("Front",[e[0],e[1],e[2],e[3]]),new _i("Back",[e[5],e[4],e[7],e[6]])];this.planesMesh=t,this.scene.add(...t)}this.viewer.enableRender()}}activateSelectedObject(e){var t;null==(t=this.selectedObject)||t.setActive(e)}onDragStart(e){var t;this.selectedObject&&(ae.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 L;null==(t=this.raycaster)||t.ray.intersectPlane(this.refrencePlane,i);let n=this.selectedObject.actionType;switch(n){case"Top":case"Bottom":this.dragTranslateSectionPlane(Wut,this.lastWorldPos,i,n);break;case"Left":case"Right":this.dragTranslateSectionPlane(jut,this.lastWorldPos,i,n);break;case"Front":case"Back":this.dragTranslateSectionPlane(Xut,this.lastWorldPos,i,n)}this.lastWorldPos=i}onDragEnd(e){ae.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.initOrUpdateSectionPlane(),this.initOrUpdateClipPlane(),this.viewer.enableRender()}isInRange(e,t){return e>t[0]&&et.visible=e)),this.isShowSectionPlane=e,this.viewer.enableRender()}},$C=class extends df{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 An;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(Tn.isMobile){let t=this.getIntersections(e);t&&(this.inputManager.setCursor("grab"),this.selectedObject=t.object,this.activateSelectedObject(!0),this.enableDefaultControl(!1),this.viewer.enableRender())}this.camera&&this.selectedObject&&(this.mouseDown=!0)}},this.mousemove=e=>{var t,i,n;if(this.faceInfo){if(this.dragStarted)this.updateRaycasterByMouse(e),this.onDragMove(e);else{this.activateSelectedObject(!1);let t=this.getIntersections(e);t?(this.selectedObject=t.object,this.activateSelectedObject(!0),this.mouseDown&&(null==(n=this.selectedObject)?void 0:n.parent)instanceof Ec&&(this.dragStarted||(this.dragStarted=!0,this.enableDefaultControl(!1),this.onDragStart(e)))):this.selectedObject=void 0}this.viewer.enableRender()}else this.pickFace(e)?null==(t=this.tooltip)||t.show():null==(i=this.tooltip)||i.hide()},this.center=new L,this.viewer.addEventListener("AfterRender",(()=>{var e;this.isActive&&(null==(e=this.gizmo)||e.adjustSize(this.camera))}))}activate(){super.activate(),this.sectionBox.getCenter(this.center),this.tooltip=new Cl("pick-section-plane",Iu("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.initOrUpdateSectionPlane(),this.initOrUpdateClipPlane(),this.setClippingEnable(!0),this.viewer.enableRender()}resetSection(){var e,t,i;null==(e=this.planeMesh)||e.removeFromParent(),null==(t=this.gizmo)||t.removeFromParent(),this.setClippingEnable(!1),this.planeMesh=void 0,this.gizmo=void 0,this.faceInfo=void 0,null==(i=this.tooltip)||i.show(),this.viewer.enableRender()}setSectionVisible(e){this.gizmo&&this.planeMesh&&(this.gizmo.visible=e,this.planeMesh.visible=e),this.isShowSectionPlane=e,this.viewer.enableRender()}initOrUpdateClipPlane(){if(!this.faceInfo)return;let{normal:e,position:t}=this.faceInfo;this.clipPlane=(new Nr).setFromNormalAndCoplanarPoint(e.clone().negate(),t),this.clipPlane&&(this.clipPlanes=[this.clipPlane])}initOrUpdateSectionPlane(){var e;if(!this.faceInfo)return;let{normal:t,position:i}=this.faceInfo,n=new L;this.sectionBox.getSize(n);let r=n.length(),a=i,s=(new It).setFromCenterAndSize(a,new L(r,r,r)),{min:o,max:l}=s;null==(e=this.planeMesh)||e.removeFromParent(),this.planeMesh=new _i("Plane",[new L(a.x,l.y,o.z),new L(a.x,l.y,l.z),new L(a.x,o.y,l.z),new L(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;this.gizmo=new Ec,this.gizmo.setDirection(i),this.gizmo.position.copy(n),null==(t=this.scene)||t.add(this.gizmo)}onDragStart(e){var t;if(!this.faceInfo||this.selectedObject instanceof _i)return;ae.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 _i)return;let r=new L;null==(t=this.raycaster)||t.ray.intersectPlane(this.refrencePlane,r);let a=this.selectedObject.userData.actionType,{position:s}=this.faceInfo,o=(new L).subVectors(this.lastWorldPos,s).normalize(),l=(new L).subVectors(r,s).normalize(),h=(new L).subVectors(r,this.lastWorldPos).projectOnVector(La.clone().applyQuaternion(this.gizmo.quaternion)),c=o.angleTo(l),u=(new L).crossVectors(o,l),d=new L;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 L).addVectors(this.gizmo.position,h),this.sectionBox.clone().setFromCenterAndSize(this.center,new L(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=La.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=uf.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=hf.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 _i||ae.info("[PickPlaneSection] onDragEnd:",e)}getIntersectObjects(){return this.planeMesh&&this.gizmo?[this.planeMesh,this.gizmo]:[]}activateSelectedObject(e){this.selectedObject&&(this.selectedObject instanceof _i?this.selectedObject.setActive(e):this.selectedObject.parent instanceof Ec&&this.selectedObject.parent.setActive(e,this.selectedObject))}pickFace(e){if(!this.raycaster)return;let t=new ye(e.x,e.y),i=on.screenPoint2NdcPoint(t,this.camera,this.canvas);this.raycaster.setFromCamera(i,this.camera);let n=[];return this.viewer.loadedModels.forEach((e=>{let t=this.scene&&this.scene.getObjectById(e.objectId);t&&t.visible&&n.push(t)})),(this.raycaster.intersectObjects(this.viewer.getRaycastableObjectsByMouse(e))||[]).find((e=>{let t=e.object;return t.visible&&t instanceof _t}))}},ZC=class extends Lr{constructor(e){super(e,{id:"SectionPlugin"}),this.sections={},this.viewer=e;let t=e.getInputManager();t&&(this.sections.ObjectsBoxSection=new YC(e,t),this.sections.AxisPlaneSection=new NR(e,t),this.sections.PickPlaneSection=new $C(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]}setAllSectionsClippingObjectIds(e){for(let t in this.sections)this.setSectionClippingObjectIds(t,e)}setSectionClippingObjectIds(e,t){this.sections[e].clearClippingObjectIds(),null!=t&&t.length&&(this.sections[e].clippingObjetIds=t,this.sections[e].setClippingEnable(!0))}destroy(){super.destroy(),this.deactivate(),this.activeSectionType=void 0}},hme=new L,dme=new cr,fme=class extends bf{constructor(e,t){var i;super(e),this.name="BimViewer",this.timer=Date.now(),this.enableSelection=!0,this.selectedObject=void 0,this.loadedModels=[],this.loaded3dTiles=[],this.composerRenderEnabled=!0,this.composerEnabled=!1,this.savedMaterialsForOpacity=[],this.raf=new pf,this.clock=new Qa,this.renderEnabled=!0,this.enableModelLevelFrustumCulling=!0,this.isFrustumInsectChecking=!1,this.settings=rv,this.twoDModelCount=0,this.enableFastOperation=!0,this.edgesVisible=!0,this.distanceCullingFactor=150,this.operationTimeoutMs=500,this.bbox=new It,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 L),a=i.getTarget(new L),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 L(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 L).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)=>dt(this,null,(function*(){let r=wt.getUpdateProgressFunc(n),a=wt.getUpdateSubProgressFunc(50,99,n);r(0),ae.info(`[BimViewer] '${e}' is loaded in ${(Date.now()-this.timer)/1e3}s, adding to scene...`),this.timer=Date.now();let s=i.src&&i.src.toLowerCase();if(s&&s.endsWith("dxf")&&this.twoDModelCount++,i.matrix&&16===i.matrix.length){let e=new Qe;e.elements=i.matrix,t.applyMatrix4(e)}t.matrixAutoUpdate=!1,t.updateMatrix(),t.traverse((e=>{e.matrixAutoUpdate&&(e.matrixAutoUpdate=!1,e.updateMatrix())})),i.merge&&this.merge(t),r(50),yield this.addLoadedModelToScene(t,i,a),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=Kn(Kn({},Dpe),e),ae.info("[BimViewer]","viewerCfg:",this.viewerCfg),this.settings=rv,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(),ae.info(`[BimViewer] Initialized in ${(Date.now()-this.timer)/1e3}s`)}init(){let e=this.viewerCfg;this.initThree(),Tn.isBrowser&&!e.context&&this.initDom(),this.initEvents(),this.initControls()}initThree(){this.initScene(),this.initRenderer(),this.initCamera(),this.initLights()}initDom(){let e=this.viewerCfg;this.initSpinner(),this.initCSS2DRenderer(),this.initOthers(),!0===e.enableAxisGizmo&&ae.warn("[BimViewer] enableAxisGizmo is deprecated, use AxisGizmoPlugin instead!"),!0===e.enableStats&&ae.warn("[BimViewer] enableStats is deprecated, use StatsPlugin instead!"),e.enableToolbar&&(this.toolbar=this.initToolbar()),e.enableBottomBar&&ae.warn("[BimViewer] enableBottomBar is deprecated, use BottomBarPlugin instead!"),e.enableNavCube&&ae.warn("[BimViewer] enableNavCube is deprecated, use NavCubePlugin instead!"),e.enableProgressBar&&(this.loadingProgressBar=this.initLoadingProgressBar()),e.enableContextMenu&&(this.contextMenu=this.initContextMenu()),null!=e.enableSelection&&(this.enableSelection=e.enableSelection)}initScene(){this.scene=new mi,this.scene.matrixAutoUpdate=!1}initRenderer(){this.renderer=new ms({antialias:!0,preserveDrawingBuffer:!0}),this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setSize(this.width,this.height),this.renderer.outputColorSpace=en,this.renderer.toneMappingExposure=1,this.renderer.useLegacyLights=!1,this.renderer.setClearColor(11119017,1),this.renderer.shadowMap.enabled=!0,this.renderer.shadowMap.type=k0,this.renderer.shadowMap.autoUpdate=!1,wt.printGpuInfo(this.renderer.getContext()),this.pmremGenerator=new wh(this.renderer),this.pmremGenerator.compileEquirectangularShader(),this.enableOverlayRenderer&&(this.overlayRender=new On(this)),this.setEnvironmentFromDataArray()}initCSS2DRenderer(){var e;let t=new gu;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 nr(45,this.width/this.height,this.settings.camera.near,this.settings.camera.far),this.perspectiveCamera.position.set(0,100,0),this.scene.add(this.perspectiveCamera),this.camera=this.perspectiveCamera)}initControls(e=!1){if(!this.renderer)return;Tn.printDeviceInfo();let t,i=e?this.orthoCamera:this.perspectiveCamera;i&&this.inputManager&&((!this.perspectiveCameraControls||!this.orthoCameraConrols)&&(t=new sa(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 L).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 Os(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 zx(this.directionalLight),this.directionalLightHelper.visible=!1,this.scene.add(this.directionalLightHelper),this.shadowCameraHelper=new Gx(this.directionalLight.shadow.camera),this.shadowCameraHelper.visible=!1,this.scene.add(this.shadowCameraHelper),this.ambientLight=new gl(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 Bo(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=>{var o,l;if(t=!1,i)return i=!1,this.onAnchorPointerUp(),void(null==(o=this.contextMenu)||o.hide());if(0===e.button)if(null==(l=this.contextMenu)||l.hide(),(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 2===e.button&&this.handleRightClick(e);this.onAnchorPointerUp()})),e.addEventListener("keydown",(e=>{this.onKeyDown(e)})),this.initRotateToCursor(),this.raycaster=new qs}initOthers(){!this.scene||!this.renderer||!this.camera||(this.renderer.domElement.style.outlineWidth="0")}initContextMenu(){let e=new mC({items:Npe,context:{bimViewer:this,toolbar:this.toolbar,section:this.section},container:this.widgetContainer});return window.oncontextmenu=e=>e.preventDefault(),e}initToolbar(){let e=this.viewerCfg;return new Du(this,(0,wf.merge)({},Cpe,e.toolbarMenuConfig))}initLoadingProgressBar(){return new cf(this.widgetContainer)}get has2dModel(){return this.twoDModelCount>0}showContextMenu(e){if(!this.contextMenu||!this.widgetContainer)return;let t=this.contextMenu.context;if(this.selectedObject){let e=this.selectedObject.userData.instanceId,i=this.selectedObject.userData.batchId;this.contextMenu.context=pi(Kn({},t),{hit:this.selectedObject,instanceId:e,batchId:i})}else{this.raycaster&&this.raycaster.layers.set(10);let i=this.getAllIntersections(e);ae.debug("[BimViewer] showContextMenu intersections = ",i);let n,r=(0,wf.find)(i,(e=>{let t=e.object;return t instanceof _t&&t.visible})),a=null==r?void 0:r.instanceId,s=null==r?void 0:r.faceIndex;s&&(n=Gr.getBatchIdByFaceIndex(null==r?void 0:r.object,s)),this.contextMenu.context=pi(Kn({},t),{hit:null==r?void 0:r.object,instanceId:a,batchId:n})}let{x:i,y:n}=e;this.contextMenu.show(i,n)}handleRightClick(e){var t;null!=(t=this.measurePlugin)&&t.isActive()||this.showContextMenu(e)}sycnCameraAndControls(e){let t=e?this.orthoCamera:this.perspectiveCamera,i=e?this.perspectiveCameraControls:this.orthoCameraConrols,n=e?this.orthoCameraConrols:this.perspectiveCameraControls,r=new L;i.getPosition(r),n.setPosition(r.x,r.y,r.z);let a=i.getTarget(new L);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 Ir(-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.update()})))}frustumCullingByModelBBox(){if(!this.enableModelLevelFrustumCulling)return;let e=this.camera,t=this.scene;if(!e||!t)return;e.updateMatrixWorld();let i=new Qe;i.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse);let n=new ra;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,ae.debug(`[BimViewer] frustumCullingByModelBBox() set model (id ${e.id})'s visible to:`,i))}};this.isFrustumInsectChecking=!0,this.loadedModels.forEach((e=>{let i=t.getObjectById(e.objectId);r(i,e.bbox)})),this.loaded3dTiles.forEach((e=>{let t=e.tilesRenderer.group;r(t,e.bbox)})),this.isFrustumInsectChecking=!1}destroy(){var e,t,i;null==(e=this.inputManager)||e.removeEventListener();let n=this.webcamPlane;this.scene&&n&&(this.scene.remove(n),n.geometry.dispose(),n.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=[],this.loaded3dTiles.forEach((e=>{e.tilesRenderer.dispose()})),this.loaded3dTiles=[],this.perspectiveCamera=void 0,this.perspectiveCameraControls=void 0,this.raf&&(this.timeoutSymbol&&this.raf.clearTimeout(this.timeoutSymbol),this.raf=void 0),this.contextMenu&&(this.contextMenu.destroy(),this.contextMenu=void 0),this.toolbar&&(this.toolbar.destroy(),this.toolbar=void 0),this.font=void 0,this.pmremGenerator&&(this.pmremGenerator.dispose(),this.pmremGenerator=void 0),null==(i=this.zoomToRectHelper)||i.destroy(),this.zoomToRectHelper=void 0,super.destroy()}loadLocalModel(e,t,i,n){return dt(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||(ae.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 Oa(i);this.font&&n.setFont(this.font);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 ae.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 dt(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||(ae.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 Oa;this.font&&t.setFont(this.font);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 ae.error(n,t),Promise.reject(n)}finally{this.decreaseJobCount(),s(100),null==(n=this.loadingProgressBar)||n.delayRemoveProgressItem(r)}return Promise.reject()}))}load3dTiles(e){return dt(this,null,(function*(){var t;this.timer=Date.now(),this.increaseJobCount();let i=new wE(e.src),n=new It,r=yield new Promise(((t,r)=>{i.onLoadTileSet=()=>{i.getBounds(n)||(i.getBoundingSphere(dme)?dme.getBoundingBox(n):(ae.warn(`[BimViewer] Can't get the correct bounding box of 3dTiles '${e.src}'!`),r())),ae.debug(n),i.onLoadTileSet=null;let a=i.group;ae.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=e.modelId||e.src,o=e=>!!this.loaded3dTiles.find((t=>t.modelId===e));if(o(s)){let e=1;for(;o(`${s}_${e}`);)e++;s=`${s}_${e}`,ae.warn(`[BimViewer] 3dTiles '${s}' is loaded more than once!`)}let l={modelId:s,objectId:r.id,bbox:n,tilesRenderer:i};if(this.loaded3dTiles.push(l),e.matrix&&16===e.matrix.length){let t=new Qe;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(),0===this.loadedModels.length&&1===this.loaded3dTiles.length&&(this.tryAdjustCameraNearAndFar(),this.goToHomeView()),ae.info(`[BimViewer] 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 dt(this,null,(function*(){let t=Date.now();zo.isShxFile(e[0])?this.font=yield(new zo).loadAsync(e):(e.length>1&&ae.warn("[BimViewer] Only support 1 typeface font file for now, others will be ignored!"),this.font=yield(new wu).loadAsync(e[0])),ae.info(`[BimViewer] Font file(s) load time in ${(Date.now()-t)/1e3}s`)}))}setDracoDecoderPath(e){Oa.setDracoDecoderPath(e)}addLoadedModelToScene(e,t,i){return dt(this,null,(function*(){if(!this.scene||!this.renderer)return;let n=wt.getUpdateProgressFunc(i),r=wt.getUpdateSubProgressFunc(20,99,i);if(n(0),t.merge){let t=Date.now();yf.createMeshBvhAsync([e],{saveOriginalIndex:!0}),ae.info(`[BimViewer] Creates mesh bvh cost ${(Date.now()-t)/1e3}s`)}e.traverse((e=>{e.isMesh&&(e.castShadow=!0,e.receiveShadow=!0,e.userData.surfaceArea=this.calculateMeshSurfaceArea(e)),e.geometry&&e.layers.enableAll(),e instanceof Ja&&(e.visible=!1)})),this.scene.add(e);let a=(new It).setFromObject(e),s=t.modelId||t.src,o=e=>!!this.loadedModels.find((t=>t.modelId===e));if(o(s)){let e=1;for(;o(`${s}_${e}`);)e++;s=`${s}_${e}`,ae.warn(`[BimViewer] Model '${s}' is loaded more than once!`)}let l={modelId:s,objectId:e.id,bbox:a};this.loadedModels.push(l),this.computeBoundingBox(),this.tryAdjustDirectionalLight();let h=this.loadedModels.map((e=>e.objectId));this.loaded3dTiles.forEach((e=>h.push(e.objectId))),(!h||h.length<=1)&&(this.has2dModel&&this.setToOrthographicCamera(!0),this.tryAdjustCameraNearAndFar(),this.goToHomeView()),n(20),t.edges&&(l.edges=yield Nn.createOutlines(e,void 0,r)),n(100),ae.info(`[BimViewer] Added '${t.src}' to scene in ${(Date.now()-this.timer)/1e3}s`),this.renderer.shadowMap.needsUpdate=!0,this.enableRender(),this.dispatchEvent("ModelLoaded",{modelId:s,bbox:a})}))}calculateMeshSurfaceArea(e){let t=new ei,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.objectId));this.loaded3dTiles.forEach((e=>s.push(e.objectId))),s.forEach((s=>{if(e){this.savedMaterialsForOpacity&&this.savedMaterialsForOpacity.length>0&&Nn.revertObjectOpacityById(r,s,this.savedMaterialsForOpacity);let e=Nn.setObjectOpacityById(r,s,t,i,n);a.push(...e)}else this.savedMaterialsForOpacity&&Nn.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 Gn),null==(i=this.scene)||i.traverseVisible((e=>{var i;if(e instanceof _t&&!["SKYBOX","GROUND_GRID","GROUND_GRASS","BIM_VIEWER_BOX_HELPER"].includes(e.name)){if(!e.geometry.attributes.normal)return;let n=new HC(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 ye(e.x,e.y),n=on.screenPoint2NdcPoint(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=this.scene&&this.scene.getObjectById(t.objectId);i&&i.visible&&e.push(i)})),this.loaded3dTiles.forEach((t=>{let i=this.scene&&this.scene.getObjectById(t.objectId);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 ye(null==e?void 0:e.x,null==e?void 0:e.y),i=on.screenPoint2NdcPoint(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);ae.debug(`[BimViewer] getIntersections costs ${(Date.now()-t)/1e3}s`);let n=i.find((e=>{let t=e.object;return t.visible&&t instanceof _t}));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);ae.debug(`[BimViewer] getIntersections costs ${(Date.now()-r)/1e3}s`);let s,o,l=a.find((e=>{let t=e.object;return t.visible&&t instanceof _t})),h=l&&l.object||void 0;if(h)if(h instanceof Li)s=l.instanceId,this.selectedObject&&this.selectedObject.id===h.id&&this.selectedObject.userData.instanceId===s&&(h=void 0);else if(Gr.isMergedMesh(h)){let e=l&&l.faceIndex||-1;e>=0?(o=Gr.getBatchIdByFaceIndex(h,e),this.selectedObject&&this.selectedObject.id===h.id&&this.selectedObject.userData.batchId===o&&(h=void 0)):h=void 0}else this.selectedObject&&this.selectedObject.id===h.id&&(h=void 0);if(a.length>0&&a[0].point){let e=null==(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=void 0){if(e instanceof Ai)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 ur&&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 Li&&null!=t){let i=e,r=new Qe,a=new Qe;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=ji.clonedHighlightMaterials(e,{depthTest:n});if(s){let n=new _t(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(Gr.isMergedMesh(e)&&null!=i){let t=Gr.getBatchByBatchId(e,i),r=`[BimViewer] 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)}`),ae.info(r);let a=ji.clonedHighlightMaterials(e,{depthTest:n}),s=Gr.cloneGeometryForBatch(e,t);if(a&&s){let t=new _t(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=ji.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 Ai?this.selectedObject.selected=!1:this.selectObject(),this.selectedObject=void 0}getBBox(){return this.bbox}enableModelEdges(e,t){return dt(this,null,(function*(){var i;let n=wt.getUpdateProgressFunc(t);n(0),this.increaseJobCount();let r=this.loadedModels.length;for(let a=0;at.visible=e))}this.decreaseJobCount(),n(100),this.enableRender()}))}flyToObjects(e){if(!e||0===e.length||!this.camera)return;let t=new It;e.forEach((e=>{let i=Ss.getBoundingBox(e);t.union(i)}));let i=new cr;t.getBoundingSphere(i),this.controls.fitToSphere(i,!0)}flyToObject(e){this.flyToObjects([e])}flyToSelectedObject(){if(!this.selectedObject)return;let e=this.selectedObject;(e instanceof Li&&e.userData.clonedMesh||Gr.isMergedMesh(e)&&e.userData.clonedMesh)&&(e=e.userData.clonedMesh),this.flyToObject(e)}flyToRandomObject(){var e,t,i;let n=this.loadedModels.map((e=>e.objectId));this.loaded3dTiles.forEach((e=>n.push(e.objectId)));let r=n.length;if(r<=0)return;let a=Math.floor(Math.random()*r),s=n[a];if(!(null==(e=this.scene)?void 0:e.getObjectById(s)))return;let o=[];if(null==(t=this.scene)||t.traverseVisible((e=>{(e instanceof _t||e instanceof rr)&&!["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=null==(i=this.scene)?void 0:i.getObjectById(o[l]);h&&(ae.info(`[BimViewer] Flying to random object: ${h.name}, type: ${h.type}`),this.selectObject(h,void 0,void 0,!1),this.flyToObject(h))}flyTo(e,t){let i=this.camera,n=this.controls;if(!i||!n)return;if(e.equals(t))return void ae.error("[BimViewer] camera position and lookAt cannot be the same!");if(!wt.isVectorValid(e)||!wt.isVectorValid(t))return void ae.error("[BimViewer] invalid position or lookAt!");let r=e.distanceTo(t);ri.far&&(e=e.clone().sub(t).normalize().multiplyScalar(.9*i.far),ae.warn("[BimViewer] 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=Ss.getVisibleObjectBoundingBox(this.scene),t=new cr;e.getBoundingSphere(t),this.controls.fitToSphere(t,!0)}goToHomeView(){let e=this.camera,t=this.cameraCfg,i=t&&wt.arrayToVector3(t.eye),n=t&&wt.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 if(this.scene){let t=new L,i=new L,n=new L(-1,-.5,-1);if(this.has2dModel){let e=this.bbox.max.x-this.bbox.min.x,t=this.bbox.max.y-this.bbox.min.y,i=this.bbox.max.z-this.bbox.min.z,r=Math.min(e,t,i);e-r<=0?n.set(1,0,0):t-r<=0?n.set(0,-1,0):i-r<=0&&n.set(0,0,-1)}this.bbox.getCenter(i),t.subVectors(i,n);let r=new cr;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 Ir){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 cr;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||nwt.numberToString(e);ae.info(`[BimViewer] BBox's longest side is: ${t(o)}`),i>l&&(ae.warn(`[BimViewer] 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||ae.warn("[BimViewer] 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()):ae.warn("[BimViewer] 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 zv(this)),this.zoomToRectHelper.activate()}deactivateZoomRect(){var e;null==(e=this.zoomToRectHelper)||e.deactivate()}enableWebCam(){this.scene&&(this.webcam||(this.webcam=new XC),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){dc.createEnvTexture(this.pmremGenerator,e).then((e=>{this.scene&&(this.scene.environment&&this.scene.environment.dispose(),this.scene.environment=e,this.enableRender())}))}setEnvironmentFromDataArray(e){dc.createEnvTextureFromDataArray(this.pmremGenerator,e).then((e=>{this.scene&&(this.scene.environment=e,this.enableRender())}))}takeObjectsScreenshot(e){return dt(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 _t&&((0,wf.includes)(e,(0,wf.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)ji.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)})),Gr.deepMerge(t,e)}finally{this.decreaseJobCount()}}updateProjectSettings(e){this.settings=e;let t=(e,t)=>{e&&t&&(e.near=t.near,e.far=t.far,e.updateProjectionMatrix())};t(this.perspectiveCamera,this.settings.camera),t(this.orthoCamera,this.settings.camera),this.enableRender(10)}computeBoundingBox(){let e=new It;return this.loadedModels.forEach((t=>{t.bbox&&!t.bbox.isEmpty()&&e.union(t.bbox)})),this.loaded3dTiles.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 L).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 L;return e.getWorldDirection(i),{position:{x:t.x,y:t.y,z:t.z},direction:{x:i.x,y:i.y,z:i.z}}}},KC=$i(mc(),1),Yut=(e=>(e[e.Browser=0]="Browser",e[e.Browserless=1]="Browserless",e[e.Headless=2]="Headless",e))(Yut||{}),pme=class{constructor(e,t,i){if(this.scene=this.initScene(),this.selectedObject=void 0,this.loadedModels=[],this.clock=new Qa,this.viewerMode=0,this.raycaster=new qs,this.savedMaterialsForOpacity=[],this.jobCount=0,this.bbox=new It,this.outlineMaterial=new kn({color:1118481}),this.outlineRoot=new Gn,this.transparentObjectIds=[],this.applyOptionsAndAddToScene=(e,t,i,n)=>dt(this,null,(function*(){if(ae.info(`[SimplifiedBimViewer] '${e}' is loaded, adding to scene...`),i.matrix&&16===i.matrix.length){let e=new Qe;e.elements=i.matrix,t.applyMatrix4(e)}yield this.addLoadedModelToScene(t,i,n)})),this.getMeshes=e=>{let t=[];return e instanceof _t?t.push(e):e.traverseVisible((e=>{e instanceof _t&&t.push(e)})),t},this.containerOrCanvas=e,t&&(this.viewerMode=t),this.glContext=i,1===this.viewerMode&&(e instanceof HTMLDivElement||!i))throw new Error("[SimplifiedBimViewer] Parameters don't match Browserless viewerMode !");this.increaseJobCount(),this.init(),this.decreaseJobCount(),ae.info("[SimplifiedBimViewer] Initialized"),this.animate()}init(){this.initRenderer(),this.initCamera(),this.initControls(),this.initLights(),this.initPointerEvents(),this.scene.add(this.outlineRoot)}initScene(){let e=new mi;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 ms(e);if(t){let e=this.containerOrCanvas.width,t=this.containerOrCanvas.height;ae.info(`[SimplifiedBimViewer] Render target size: ${e} x ${t}`),this.renderTarget=new Jn(e,t,{minFilter:_r,magFilter:qr,format:Vs,type:ic}),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=k0,this.renderer=i,t||(this.pmremGenerator=new wh(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 nr(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 sa(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 Os(e,.3);t.position.set(-2,2,4);let i=new gl(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 dt(this,null,(function*(){let n=yield(new Oa).loadLocalModel(e,t.src,i);return n?(yield this.applyOptionsAndAddToScene(e,n,t),Promise.resolve()):Promise.reject()}))}loadModel(e,t){return dt(this,null,(function*(){this.increaseJobCount();let i=yield(new Oa).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 Oa).parseGltf(e,t.src,(e=>{this.applyOptionsAndAddToScene(t.src,e,t),i&&i(e)}),(e=>{n&&n(e)}))}addLoadedModelToScene(e,t,i){return dt(this,null,(function*(){if(!this.scene)return Promise.resolve();e.updateMatrix(),e.traverse((e=>{e.geometry&&e.layers.enableAll()})),this.scene.add(e);let n=(new It).setFromObject(e),r=t.modelId||t.src,a=e=>!!this.loadedModels.find((t=>t.modelId===e));if(a(r)){let e=1;for(;a(`${r}_${e}`);)e++;r=`${r}_${e}`,ae.warn(`[BimViewer] Model '${r}' is loaded more than once!`)}let s={modelId:r,objectId:e.id,bbox:n};this.loadedModels.push(s),this.computeBoundingBox();let o=this.loadedModels.map((e=>e.objectId));(!o||o.length<=1)&&(this.tryAdjustCameraNearAndFar(),this.goToHomeView()),t.edges&&(s.edges=yield Nn.createOutlines(e,void 0,i)),this.decreaseJobCount(),ae.info(`[SimplifiedBimViewer] Added '${t.src}' to scene`)}))}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&&Nn.revertObjectOpacityById(r,s.objectId,this.savedMaterialsForOpacity);let e=Nn.setObjectOpacityById(r,s.objectId,t,i,n);a.push(...e)}else this.savedMaterialsForOpacity&&Nn.revertObjectOpacityById(r,s.objectId,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 ye;e&&(t=on.getScreenPointByEvent(e,this.containerOrCanvas));let i=on.screenPoint2NdcPoint(t,this.camera,this.containerOrCanvas);this.raycaster.setFromCamera(i,this.camera);let n=[];return this.loadedModels.forEach((e=>{let t=this.scene&&this.scene.getObjectById(e.objectId);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 _t})),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 ur&&e.dispose()}this.selectedObject.material=e.originalMaterial,delete e.originalMaterial}this.selectedObject=void 0}if(!this.scene||!e)return;let t=ji.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 It;e.forEach((e=>{let i=Ss.getBoundingBox(e);t.union(i)}));let i=new cr;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 L(e[0],e[1],e[2]):e,o=t=Array.isArray(t)?new L(t[0],t[1],t[2]):t;ae.info("[SimplifiedBimViewer] flyTo: ",wt.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 cr;this.bbox.getBoundingSphere(e),this.controls.fitToSphere(e,!0)}setEnvironmentFromDataArray(e){dc.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||nwt.numberToString(e);ae.info(`[SimplifiedBimViewer] BBox's longest side is: ${t(o)}`),i>l&&(ae.warn(`[SimplifiedBimViewer] 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 rn({color:16777215,transparent:!0,opacity:.1});this.loadedModels.forEach((e=>{Nn.applyMaterialToObjectById(this.scene,e.objectId,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=i?this.scene.getObjectById(i.objectId):this.scene;n||(ae.warn(`[BimViewer] The ModelId of ${t} has no corresponding model.`),n=this.scene),n.traverse((t=>{if((0,KC.includes)(e.id,(0,KC.get)(t.userData,"UniqueId"))){let e=this.getMeshes(t);r=r.concat(e)}}))})),r.length>0){r.forEach((e=>{let t=Nn.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=>{Nn.revertAppliedMaterialToObjectById(this.scene,t.objectId,e)})),this.transparentObjectIds=e,this.flyToObjects(r)}else ae.warn(`[BimViewer] No object found with uniqueIds: ${e.map((e=>e.id))}`);this.isBrowserMode()||this.animate()}increaseJobCount(){++this.jobCount}decreaseJobCount(){--this.jobCount}computeBoundingBox(){let e=new It;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 L;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())}},mme=new L,$ut=new ir,gme=new L,wm=class extends sn{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}},Nu=new Qe,Zut=new Qe,JC=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?(Nu.copy(i.matrixWorldInverse),Nu.transpose(),0!==e.rotation2D&&Nu.multiply(Zut.makeRotationZ(e.rotation2D)),e.matrixWorld.decompose(mme,$ut,gme),Nu.setPosition(mme),Nu.scale(gme),Nu.elements[3]=0,Nu.elements[7]=0,Nu.elements[11]=0,Nu.elements[15]=1,n=d(Nu)):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 vme.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 dt(this,null,(function*(){if(!this.thumbnailImages||6!=this.thumbnailImages.length)return;this.thumbnailMesh=new _t(new na(e,e,e)),this.thumbnailMesh.geometry.scale(1,1,-1);let t=(yield this.loadTexturesAsync(this.thumbnailImages)).map((e=>new rn({map:e,side:ai,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 dt(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 _t?this.destroyMesh(this.mesh):this.mesh.traverse((e=>{e instanceof _t&&this.destroyMesh(e)})),this.mesh=void 0)}},QC=class extends Sf{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 dt(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)=>dt(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 dt(this,null,(function*(){let e=this.mesh;e.geometry=new na(this.size,this.size,this.size),e.geometry.scale(1,1,-1);let t=(yield this.loadTexturesAsync(this.images)).map((e=>new rn({map:e,side:ai,transparent:!0})));e.material=t,this.add(e),this.thumbnailMesh&&(this.destroyMesh(this.thumbnailMesh),this.thumbnailMesh=void 0,this.thumbnailImages=void 0)}))}},eP=class extends Sf{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 dt(this,null,(function*(){yield this.createThumbnailMesh(this.size+.1),this.thumbnailMesh?this.createMesh():yield this.createMesh()}))}createMesh(){return dt(this,null,(function*(){var e;this.mesh=new Gn,this.mesh.scale.set(1,1,-1);let t=(yield this.loadTexturesAsync(this.images)).map((e=>new rn({map:e,side:zi,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 L(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 L(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 L(1,0,0),-Math.PI/2),r.rotateOnAxis(new L(0,0,1),Math.PI),r.rotateOnAxis(new L(1,0,0),Math.PI),r.position.set(0,this.size/2,0);let a=this.createPlaneOfAFace(t.slice(12,16));a.rotateOnAxis(new L(1,0,0),Math.PI/2),a.rotateOnAxis(new L(0,0,1),Math.PI),a.rotateOnAxis(new L(1,0,0),Math.PI),a.position.set(0,-this.size/2,0);let s=this.createPlaneOfAFace(t.slice(16,20));s.rotateOnAxis(new L(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 Gn,n=new ti(this.subPlaneWidth0,this.subPlaneWidth0),r=new ti(this.subPlaneWidth1,this.subPlaneWidth0),a=new ti(this.subPlaneWidth0,this.subPlaneWidth1),s=new ti(this.subPlaneWidth1,this.subPlaneWidth1),o=new _t(n,e[0]),l=new _t(r,e[1]),h=new _t(a,e[2]),c=new _t(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}},tP=class extends Sf{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 dt(this,null,(function*(){yield this.createThumbnailMesh(this.size+.1),this.thumbnailMesh?this.createMesh():yield this.createMesh()}))}createMesh(){return dt(this,null,(function*(){var e;let t=this.mesh;t.geometry=new Ma(this.size,100,100),t.geometry.scale(-1,1,1);let i=(yield this.loadTexturesAsync(this.images)).map((e=>new rn({map:e,side:ai,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)}))}},yme=class extends bf{constructor(e,t){super(e),this.name="VRViewer",this.timer=Date.now(),this.loadedModels=[],this.minFov=50,this.maxFov=95,this.raycaster=new qs,this.autoRotate=!0,this.events=[],this.isMousePressing=!1,this.settings=rv,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)=>dt(this,null,(function*(){let r=wt.getUpdateProgressFunc(n),a=wt.getUpdateSubProgressFunc(50,99,n);if(r(0),ae.info(`[VRViewer] '${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 Qe;e.elements=i.matrix,t.applyMatrix4(e)}t.matrixAutoUpdate=!1,t.updateMatrix(),t.traverse((e=>{e.matrixAutoUpdate&&(e.matrixAutoUpdate=!1,e.updateMatrix())})),i.merge&&this.merge(t),r(50),yield this.addLoadedModelToScene(t,i,a),r(100)})),this.viewerCfg=e,this.cameraCfg=t||{eye:[0,0,0],look:[0,0,0]},this.settings=rv,this.cameraCfg.near&&(this.settings.camera.near=this.cameraCfg.near),this.cameraCfg.far&&(this.settings.camera.far=this.cameraCfg.far),this.setSpinnerVisibility(++this.jobCount>0),this.init(),this.animate(),this.setSpinnerVisibility(--this.jobCount>0)}init(){let e=this.viewerCfg;this.initSpinner(),this.initScene(),this.initRenderer(),this.initCamera(),this.initControls(),this.initLights(),this.initInputManager(),this.initEvents(),this.initOthers(),e.enableToolbar&&(this.toolbar=this.initToolbar())}initScene(){let e=new mi;e.background=new ct(16777215),e.matrixAutoUpdate=!0,this.scene=e}initRenderer(){var e,t;this.renderer=new ms({antialias:!0,preserveDrawingBuffer:!1}),this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setSize(this.width,this.height),this.renderer.useLegacyLights=!1,this.css2dRenderer=new gu,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 nr(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 YA(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 UR(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 L(0,0,0),r=new L(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 Os(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 Bo(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===qM.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===qM.LEFT)if(null!=(a=n.originalEvent)&&a.target&&n.originalEvent.target instanceof HTMLDivElement){let e=$d.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&&(ae.info("[VRViewer] Clicked on hotpoint: ",e.hotpointId||e),this.onHotpointClicked&&this.onHotpointClicked(e))}}}else{let e=this.getIntersection(n);if(e){let i=e=>wt.vectorToString(e),n=e.point,r=n.clone().sub(t.position).normalize();ae.info(`[VRViewer] 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")}initToolbar(){let e=this.viewerCfg;return new Du(this,Kn(Kn({},Ppe),e.toolbarMenuConfig),[["SceneClear"]])}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,t;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)),null==(t=this.toolbar)||t.destroy(),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 L(t[0],t[1],t[2]):new L(t.x,t.y,t.z):s.target.clone().sub(a.position),n.normalize(),r=Array.isArray(e)?new L(e[0],e[1],e[2]):new L(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 L(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 L;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 dt(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 Oa).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 ae.error(n,t),Promise.reject(n)}finally{this.decreaseJobCount(),s(100),null==(n=this.loadingProgressBar)||n.delayRemoveProgressItem(r)}return Promise.reject()}))}setModelVisibility(e,t){var i;let n=this.loadedModels.find((t=>t.modelId===e)),r=(null==n?void 0:n.objectId)&&(null==(i=this.scene)?void 0:i.getObjectById(n.objectId));if(!r)throw new Error(`Failed to find model by modelId '${e}'!`);r.visible=t,this.enableRender()}addLoadedModelToScene(e,t,i){return dt(this,null,(function*(){if(!this.scene)return;let n=wt.getUpdateProgressFunc(i),r=wt.getUpdateSubProgressFunc(20,99,i);if(n(0),t.merge){let t=Date.now();yf.createMeshBvhAsync([e],{saveOriginalIndex:!0}),ae.info(`[VRViewer] Creates mesh bvh cost ${(Date.now()-t)/1e3}s`)}e.traverse((e=>{e.geometry&&e.layers.enableAll()})),this.scene.add(e);let a=(new It).setFromObject(e),s=t.modelId||t.src,o=e=>!!this.loadedModels.find((t=>t.modelId===e));if(o(s)){let e=1;for(;o(`${s}_${e}`);)e++;s=`${s}_${e}`,ae.warn(`[VRViewer] Model '${s}' is loaded more than once!`)}let l={modelId:s,objectId:e.id,bbox:a};this.loadedModels.push(l),t.edges&&(l.edges=yield Nn.createOutlines(e,void 0,r)),ae.info(`[VRViewer] Added '${t.src}' to scene in ${(Date.now()-this.timer)/1e3}s`),this.enableRender(),this.dispatchEvent("ModelLoaded")}))}addPanorama(e,t){let i=this.viewpoints.find((t=>t.id===e));if(!i)throw new Error(`[VRViewer] 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 ae.warn(`[VRViewer] Duplicated hotpointId: ${e.hotpointId}`);let a=t.position||[0,0,0],s=e.anchorPosition,o=$d.createHotpoint(e.html),l=new L(s[0],s[1],s[2]),h=new L(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 ae.error("[VRViewer] 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 L(0,0,0),a=new L(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 ae.warn(`[VRViewer] Panorama with viewpointId=${e.id} and panoramaId=${t} is being created`);let i=new bA(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=$d.createHotpoint(r.html);s.visible=!1!==r.visible,s.userData.hotpoint=r;let o=new L(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],ae.warn(`[VRViewer] Failed to find panorama by id '${t}', will use the first one`)),n=i.images,r=i.thumbnails}if(!n)throw new Error("[VRViewer] 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(`[VRViewer] Wrong number of images! Expected 1/6/24, got ${n.length}`)}createBoxByImage(e,t){return dt(this,null,(function*(){let i=new tP(e,t);return yield i.create(),i}))}createBoxBy6Images(e,t){return dt(this,null,(function*(){if(6!==e.length)throw new Error(`[VRCube] Wrong number of images! Expected 6, got ${e.length}`);let i=new QC(e,t);return yield i.create(),i}))}createBoxBy24Images(e,t){return dt(this,null,(function*(){if(24!==e.length)throw new Error(`[VRCube] Wrong number of images! Expected 24, got ${e.length}`);let i=new eP(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 ye;e&&(a=on.getScreenPointByEvent(e,r));let s=on.screenPoint2NdcPoint(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 _t})):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 L(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)})),Gr.deepMerge(t,e)}finally{this.decreaseJobCount()}}},nP=class extends sn{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 L(0,0,0),n=new L(1,0,0),r=new L(0,1,0),a=new cc(n,i,this.AXIS_LENGTH,this.AXIS_COLOR_X,0,0),s=new cc(r,i,this.AXIS_LENGTH,this.AXIS_COLOR_Y,0,0);if(this.add(a,s),!t){let e=new L(0,0,1),t=new cc(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 nv(n)}},xme=class extends Lr{constructor(e,t){super(e,{id:"AxisGizmoPlugin"}),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 ms({antialias:!0,alpha:!0}),this.renderer.setSize(i,n),t.appendChild(this.renderer.domElement),this.css2dRenderer=new gu,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 mi,this.camera=new Ir(-1,1,1,-1,.1,100),this.scene.add(this.camera),this.coordinateAxes=new nP(!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 L;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)}},d6=$i(mc(),1),Kut="bottomBar",Jut={"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 _t||e instanceof rr||e instanceof $r)&&!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 _t)if(i.index&&i.index.count){let n=Math.round(i.index.count/3);e instanceof Li&&(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 ur?i(n.id):Array.isArray(n)&&n.forEach((e=>i(e.id)))})(e,i):e instanceof Ja&&(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",`${nE}${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=>wt.numberToString(e),a=e=>wt.vectorToString(e),s=i.position,o=n instanceof sa?n.getTarget(new L):n.target;if(s){let t=document.createElement("span");t.innerHTML=`\n

Camera position:${a(s)}

\n

Camera target:${a(o)}

`,i instanceof Ir&&(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()}}},bme=class extends Lr{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=Kut,t.classList.add("bottom-bar"),(0,d6.forEach)(Jut,((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 h6(e,this,t,i);return this.itemList.set(t,n),n}},h6=class{constructor(e,t,i,n){this.viewer=e,this.bottomBar=t,this.menuId=i,this.cfg=n,this.eventBus=kv(),this.active=!1,this.itemconfig=n,this.element=this.createButton(this.menuId,n),this.tooltip=new Cl(i+"-tooltip",null,{parentNode:e.widgetContainer}),this.eventBus.on("activeChange",(e=>{e?(this.element.classList.add("active"),(0,d6.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&&TA(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=ov}=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)}};function Qut(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 t1(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 Eme=Array.prototype.forEach,OE=Array.prototype.slice,Ht={BREAK:{},extend:function(e){return this.each(OE.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(OE.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=OE.call(arguments);return function(){for(var t=OE.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(Eme&&e.forEach&&e.forEach===Eme)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(eht,(function(t){if(t.litmus(e))return Ht.each(t.conversions,(function(t,i){if(kE=t.read(e),!1===rP&&!1!==kE)return rP=kE,kE.conversionName=i,kE.conversion=t,Ht.BREAK})),Ht.BREAK})),rP},_me=void 0,sP={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<<(_me=8*t)|e&~(255<<_me)}},tht="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},Ac=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},Rc=function(){function e(e,t){for(var i=0;i-1?t.length-t.indexOf(".")-1:0}var Ome=function(e){function t(e,i,n){Ac(this,t);var r=Rf(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=Tme(r.__impliedStep),r}return Af(t,Sm),Rc(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),Mf(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=Tme(e),this}}]),t}();function aht(e,t){var i=Math.pow(10,t);return Math.round(e*i)/i}var aP=function(e){function t(e,i,n){Ac(this,t);var r=Rf(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(){xt.unbind(window,"mousemove",l),xt.unbind(window,"mouseup",h),o()}return r.__input=document.createElement("input"),r.__input.setAttribute("type","text"),xt.bind(r.__input,"change",(function(){var e=parseFloat(a.__input.value);Ht.isNaN(e)||a.setValue(e)})),xt.bind(r.__input,"blur",(function(){o()})),xt.bind(r.__input,"mousedown",(function(e){xt.bind(window,"mousemove",l),xt.bind(window,"mouseup",h),s=e.clientY})),xt.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 Af(t,Ome),Rc(t,[{key:"updateDisplay",value:function(){return this.__input.value=this.__truncationSuspended?this.getValue():aht(this.getValue(),this.__precision),Mf(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"updateDisplay",this).call(this)}}]),t}();function wme(e,t,i,n,r){return n+(e-t)/(i-t)*(r-n)}var m6=function(e){function t(e,i,n,r,a){Ac(this,t);var s=Rf(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(wme(e.clientX,t.left,t.right,o.__min,o.__max)),!1}function h(){xt.unbind(window,"mousemove",l),xt.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(wme(t,i.left,i.right,o.__min,o.__max))}function u(){xt.unbind(window,"touchmove",c),xt.unbind(window,"touchend",u),o.__onFinishChange&&o.__onFinishChange.call(o,o.getValue())}return s.__background=document.createElement("div"),s.__foreground=document.createElement("div"),xt.bind(s.__background,"mousedown",(function(e){document.activeElement.blur(),xt.bind(window,"mousemove",l),xt.bind(window,"mouseup",h),l(e)})),xt.bind(s.__background,"touchstart",(function(e){1===e.touches.length&&(xt.bind(window,"touchmove",c),xt.bind(window,"touchend",u),c(e))})),xt.addClass(s.__background,"slider"),xt.addClass(s.__foreground,"slider-fg"),s.updateDisplay(),s.__background.appendChild(s.__foreground),s.domElement.appendChild(s.__background),s}return Af(t,Ome),Rc(t,[{key:"updateDisplay",value:function(){var e=(this.getValue()-this.__min)/(this.__max-this.__min);return this.__foreground.style.width=100*e+"%",Mf(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"updateDisplay",this).call(this)}}]),t}(),kme=function(e){function t(e,i,n){Ac(this,t);var r=Rf(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,xt.bind(r.__button,"click",(function(e){return e.preventDefault(),a.fire(),!1})),xt.addClass(r.__button,"button"),r.domElement.appendChild(r.__button),r}return Af(t,Sm),Rc(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}(),g6=function(e){function t(e,i){Ac(this,t);var n=Rf(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,i));n.__color=new Ns(n.getValue()),n.__temp=new Ns(0);var r=n;n.domElement=document.createElement("div"),xt.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 ",xt.bind(n.__input,"keydown",(function(e){13===e.keyCode&&c.call(this)})),xt.bind(n.__input,"blur",c),xt.bind(n.__selector,"mousedown",(function(){xt.addClass(this,"drag").bind(window,"mouseup",(function(){xt.removeClass(r.__selector,"drag")}))})),xt.bind(n.__selector,"touchstart",(function(){xt.addClass(this,"drag").bind(window,"touchend",(function(){xt.removeClass(r.__selector,"drag")}))}));var a=document.createElement("div");function s(e){d(e),xt.bind(window,"mousemove",d),xt.bind(window,"touchmove",d),xt.bind(window,"mouseup",l),xt.bind(window,"touchend",l)}function o(e){p(e),xt.bind(window,"mousemove",p),xt.bind(window,"touchmove",p),xt.bind(window,"mouseup",h),xt.bind(window,"touchend",h)}function l(){xt.unbind(window,"mousemove",d),xt.unbind(window,"touchmove",d),xt.unbind(window,"mouseup",l),xt.unbind(window,"touchend",l),u()}function h(){xt.unbind(window,"mousemove",p),xt.unbind(window,"touchmove",p),xt.unbind(window,"mouseup",h),xt.unbind(window,"touchend",h),u()}function c(){var e=p6(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"}),Sme(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"}),lht(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)"}),xt.bind(n.__saturation_field,"mousedown",s),xt.bind(n.__saturation_field,"touchstart",s),xt.bind(n.__field_knob,"mousedown",s),xt.bind(n.__field_knob,"touchstart",s),xt.bind(n.__hue_field,"mousedown",o),xt.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 Af(t,Sm),Rc(t,[{key:"updateDisplay",value:function(){var e=p6(this.getValue());if(!1!==e){var t=!1;Ht.each(Ns.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,Sme(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}(),oht=["-moz-","-o-","-webkit-","-ms-",""];function Sme(e,t,i,n){e.style.background="",Ht.each(oht,(function(r){e.style.cssText+="background: "+r+"linear-gradient("+t+", "+i+" 0%, "+n+" 100%); "}))}function lht(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 cht={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){}}},uht='
\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
',hht=function(e,t){var i=e[t];return Ht.isArray(arguments[2])||Ht.isObject(arguments[2])?new iht(e,t,arguments[2]):Ht.isNumber(i)?Ht.isNumber(arguments[2])&&Ht.isNumber(arguments[3])?Ht.isNumber(arguments[4])?new m6(e,t,arguments[2],arguments[3],arguments[4]):new m6(e,t,arguments[2],arguments[3]):Ht.isNumber(arguments[4])?new aP(e,t,{min:arguments[2],max:arguments[3],step:arguments[4]}):new aP(e,t,{min:arguments[2],max:arguments[3]}):Ht.isString(i)?new sht(e,t):Ht.isFunction(i)?new kme(e,t,""):Ht.isBoolean(i)?new Lme(e,t):null};function dht(e){setTimeout(e,1e3/60)}var fht=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||dht,pht=function(){function e(){Ac(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"}),xt.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;xt.bind(this.backgroundElement,"click",(function(){t.hide()}))}return Rc(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",xt.unbind(e.domElement,"webkitTransitionEnd",t),xt.unbind(e.domElement,"transitionend",t),xt.unbind(e.domElement,"oTransitionEnd",t)};xt.bind(this.domElement,"webkitTransitionEnd",t),xt.bind(this.domElement,"transitionend",t),xt.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-xt.getWidth(this.domElement)/2+"px",this.domElement.style.top=window.innerHeight/2-xt.getHeight(this.domElement)/2+"px"}}]),e}(),mht=Qut(".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");cht.inject(mht);var Mme="dg",Ame=72,Rme=20,HE="Default",NE=function(){try{return!!window.localStorage}catch(e){return!1}}(),FE=void 0,Cme=!0,Qv=void 0,f6=!1,Nme=[],Ti=function e(t){var i=this,n=t||{};this.domElement=document.createElement("div"),this.__ul=document.createElement("ul"),this.domElement.appendChild(this.__ul),xt.addClass(this.domElement,Mme),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:HE}:n.preset&&(n.load.preset=n.preset),Ht.isUndefined(n.parent)&&n.hideable&&Nme.push(this),n.resizable=Ht.isUndefined(n.parent)&&n.resizable,n.autoPlace&&Ht.isUndefined(n.scrollable)&&(n.scrollable=!0);var r,a=NE&&"true"===localStorage.getItem(e1(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,xht(this),i.revert()}},width:{get:function(){return n.width},set:function(e){n.width=e,x6(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?xt.addClass(i.__ul,e.CLASS_CLOSED):xt.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){NE&&(a=e,e?xt.bind(window,"unload",s):xt.unbind(window,"unload",s),localStorage.setItem(e1(i,"isLocal"),e))}}}),Ht.isUndefined(n.parent)){if(this.closed=n.closed||!1,xt.addClass(this.domElement,e.CLASS_MAIN),xt.makeSelectable(this.domElement,!1),NE&&a){i.useLocalStorage=!0;var l=localStorage.getItem(e1(this,"gui"));l&&(n.load=JSON.parse(l))}this.__closeButton=document.createElement("div"),this.__closeButton.innerHTML=e.TEXT_CLOSED,xt.addClass(this.__closeButton,e.CLASS_CLOSE_BUTTON),n.closeOnTop?(xt.addClass(this.__closeButton,e.CLASS_CLOSE_TOP),this.domElement.insertBefore(this.__closeButton,this.domElement.childNodes[0])):(xt.addClass(this.__closeButton,e.CLASS_CLOSE_BOTTOM),this.domElement.appendChild(this.__closeButton)),xt.bind(this.__closeButton,"click",(function(){i.closed=!i.closed}))}else{void 0===n.closed&&(n.closed=!0);var h=document.createTextNode(n.name);xt.addClass(h,"controller-name"),o=_6(i,h),xt.addClass(this.__ul,e.CLASS_CLOSED),xt.addClass(o,"title"),xt.bind(o,"click",(function(e){return e.preventDefault(),i.closed=!i.closed,!1})),n.closed||(this.closed=!1)}n.autoPlace&&(Ht.isUndefined(n.parent)&&(Cme&&(Qv=document.createElement("div"),xt.addClass(Qv,Mme),xt.addClass(Qv,e.CLASS_AUTO_PLACE_CONTAINER),document.body.appendChild(Qv),Cme=!1),Qv.appendChild(this.domElement),xt.addClass(this.domElement,e.CLASS_AUTO_PLACE)),this.parent||x6(i,n.width)),this.__resizeHandler=function(){i.onResizeDebounced()},xt.bind(window,"resize",this.__resizeHandler),xt.bind(this.__ul,"webkitTransitionEnd",this.__resizeHandler),xt.bind(this.__ul,"transitionend",this.__resizeHandler),xt.bind(this.__ul,"oTransitionEnd",this.__resizeHandler),this.onResize(),n.resizable&&yht(this),s=function(){NE&&"true"===localStorage.getItem(e1(i,"isLocal"))&&localStorage.setItem(e1(i,"gui"),JSON.stringify(i.getSaveObject()))},this.saveToLocalStorageIfPossible=s,n.parent||((r=i.getRoot()).width+=1,Ht.defer((function(){r.width-=1})))};function _6(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 Pme(e){xt.unbind(window,"resize",e.__resizeHandler),e.saveToLocalStorageIfPossible&&xt.unbind(window,"unload",e.saveToLocalStorageIfPossible)}function v6(e,t){var i=e.__preset_select[e.__preset_select.selectedIndex];i.innerHTML=t?i.value+"*":i.value}function ght(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(),BE(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(),BE(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 m6){var n=new aP(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)}})),xt.addClass(t,"has-slider"),i.domElement.insertBefore(n.domElement,i.domElement.firstElementChild)}else if(i instanceof aP){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=BE(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 Lme?(xt.bind(t,"click",(function(){xt.fakeEvent(i.__checkbox,"click")})),xt.bind(i.__checkbox,"click",(function(e){e.stopPropagation()}))):i instanceof kme?(xt.bind(t,"click",(function(){xt.fakeEvent(i.__button,"click")})),xt.bind(t,"mouseover",(function(){xt.addClass(i.__button,"hover")})),xt.bind(t,"mouseout",(function(){xt.removeClass(i.__button,"hover")}))):i instanceof g6&&(xt.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()&&v6(e.getRoot(),!0),t}),i.setValue)}function Fme(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[HE])return;s=a[HE]}if(s[n]&&void 0!==s[n][t.property]){var o=s[n][t.property];t.initialValue=o,t.setValue(o)}}}}function BE(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 g6(t,i);else{var a=[t,i].concat(n.factoryArgs);r=hht.apply(e,a)}n.before instanceof Sm&&(n.before=n.before.__li),Fme(e,r),xt.addClass(r.domElement,"c");var s=document.createElement("span");xt.addClass(s,"property-name"),s.innerHTML=r.property;var o=document.createElement("div");o.appendChild(s),o.appendChild(r.domElement);var l=_6(e,o,n.before);return xt.addClass(l,Ti.CLASS_CONTROLLER_ROW),r instanceof g6?xt.addClass(l,"color"):xt.addClass(l,tht(r.getValue())),ght(e,l,r),e.__controllers.push(r),r}function e1(e,t){return document.location.href+"."+t}function y6(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 Ime(e,t){t.style.display=e.useLocalStorage?"block":"none"}function vht(e){var t=e.__save_row=document.createElement("li");xt.addClass(e.domElement,"has-save"),e.__ul.insertBefore(t,e.__ul.firstChild),xt.addClass(t,"save-row");var i=document.createElement("span");i.innerHTML=" ",xt.addClass(i,"button gears");var n=document.createElement("span");n.innerHTML="Save",xt.addClass(n,"button"),xt.addClass(n,"save");var r=document.createElement("span");r.innerHTML="New",xt.addClass(r,"button"),xt.addClass(r,"save-as");var a=document.createElement("span");a.innerHTML="Revert",xt.addClass(a,"button"),xt.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){y6(e,i,i===e.preset)})):y6(e,HE,!1),xt.bind(s,"change",(function(){for(var t=0;t0&&(e.preset=this.preset,e.remembered||(e.remembered={}),e.remembered[this.preset]=iP(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]=iP(this),v6(this,!1),this.saveToLocalStorageIfPossible()},saveAs:function(e){this.load.remembered||(this.load.remembered={},this.load.remembered[HE]=iP(this,!0)),this.load.remembered[e]=iP(this),this.preset=e,y6(this,e,!0),this.saveToLocalStorageIfPossible()},revert:function(e){Ht.each(this.__controllers,(function(t){this.getRoot().load.remembered?Fme(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||v6(this.getRoot(),!1)},listen:function(e){var t=0===this.__listening.length;this.__listening.push(e),t&&Bme(this.__listening)},updateDisplay:function(){Ht.each(this.__controllers,(function(e){e.updateDisplay()})),Ht.each(this.__folders,(function(e){e.updateDisplay()}))}});var Hme=Ti,Ume=[["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"]],jh=(()=>{if("undefined"==typeof document)return!1;let e=Ume[0],t={};for(let i of Ume)if((null==i?void 0:i[1])in document){for(let[n,r]of i.entries())t[e[n]]=r;return t}return!1})(),Vme={change:jh.fullscreenchange,error:jh.fullscreenerror},Go={request:(e=document.documentElement,t)=>new Promise(((i,n)=>{let r=()=>{Go.off("change",r),i()};Go.on("change",r);let a=e[jh.requestFullscreen](t);a instanceof Promise&&a.then(r).catch(n)})),exit:()=>new Promise(((e,t)=>{if(!Go.isFullscreen)return void e();let i=()=>{Go.off("change",i),e()};Go.on("change",i);let n=document[jh.exitFullscreen]();n instanceof Promise&&n.then(i).catch(t)})),toggle:(e,t)=>Go.isFullscreen?Go.exit():Go.request(e,t),onchange(e){Go.on("change",e)},onerror(e){Go.on("error",e)},on(e,t){let i=Vme[e];i&&document.addEventListener(i,t,!1)},off(e,t){let i=Vme[e];i&&document.removeEventListener(i,t,!1)},raw:jh};Object.defineProperties(Go,{isFullscreen:{get:()=>Boolean(document[jh.fullscreenElement])},element:{enumerable:!0,get:()=>{var e;return null!=(e=document[jh.fullscreenElement])?e:void 0}},isEnabled:{enumerable:!0,get:()=>Boolean(document[jh.fullscreenEnabled])}}),jh||(Go={isEnabled:!1});var oP=Go,lP=new L,cP=class{constructor(e,t,i=void 0){this.scale=1,this.explodeUp=!1,this.scene=e,this.objectId=t,t||ae.debug(`[EXP] Invalid objectId: ${t}`),i?this.explodeCenter=i:(this.explodeCenter=new L,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 ae.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?(ae.debug(`[EXP] Exploding object '${t.name}'(id: ${t.id}) at: ${wt.vectorToString(this.explodeCenter)}`),this.explodeObject(t)):ae.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(),lP.set(0,0,0),null==(t=i.geometry.boundingBox)||t.getCenter(lP),lP.applyMatrix4(i.matrixWorld),i.userData.originalCenter=lP.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 Qe;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?(ae.debug(`[EXP] Unexploding '${e.name}'(id: ${e.id}) at: ${wt.vectorToString(this.explodeCenter)}`),this.unexplodeObject(e)):ae.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 It;if(!this.objectId)return void ae.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)):ae.debug("[EXP] No children to explode!")}},uP=class extends Lr{constructor(e,t){super(e,{id:"ExplodePlugin"}),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.objectId))return;let t=new L;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 cP(this.scene,e.objectId,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()}},hP=class extends Lr{constructor(e,t){super(e,{id:"GroundGrassPlugin"}),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 L,o=this.viewer.getBBox();o&&o.getCenter(s),dt(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 dt(this,null,(function*(){return new Promise((a=>{(new gs).load(e,(e=>{e.wrapS=e.wrapT=Ei,e.repeat.set(n,r),e.anisotropy=16,e.encoding=tu;let s=new cu({map:e});s.side=ai;let o=new _t(new ti(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)}},dP=class extends Lr{constructor(e,t){super(e,{id:"GroundGridPlugin"}),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 L,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 Vx(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)}},fP=class extends Lr{constructor(e,t){super(e,{id:"ScreenshotPlugin"}),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)}getScreenshotAsync(){return dt(this,arguments,(function*(e="BoxSelection"){var t;this.cancel();let i,n="image/png",r=this.viewer,a=null==(t=r.renderer)?void 0:t.domElement;if(!a||!r.viewerContainer||!r.camera)return;if("PickMarkup"===e?(this.pickMarkupHelper||(this.pickMarkupHelper=new cC(r)),i=yield this.pickMarkupHelper.pick()):"BoxSelection"===e&&(this.boxSelectHelper||(this.boxSelectHelper=new xf(r)),i=yield this.boxSelectHelper.select()),"Default"!==e&&!i)return;let s=yield wt.canvasToImage(a),o=document.createElement("canvas");o.width=a.width,o.height=a.height;let l=window.devicePixelRatio,h=o.getContext("2d");if(h.drawImage(s,0,0,s.width/l,s.height/l),r.overlayRender){let e=yield r.overlayRender.getImage((e=>e instanceof wr||e instanceof vi));h.drawImage(e,0,0,e.width/l,e.height/l)}let c=wt.renderingContextToImage(h,i,n,.8);return r instanceof Ef?{base64Image:c,viewExtent:r.getCurrentViewExtent(),imageType:n}:{base64Image:c,imageType:n}}))}isActive(){var e,t;return(null==(e=this.boxSelectHelper)?void 0:e.isActived)||(null==(t=this.pickMarkupHelper)?void 0:t.isActived)}cancel(){var e,t;null!=(e=this.boxSelectHelper)&&e.isActived&&this.boxSelectHelper.deactivate(),null!=(t=this.pickMarkupHelper)&&t.isActived&&this.pickMarkupHelper.deactivate()}},Cf=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?ae.error("[Uploader] No files to be uploaded!"):this.uploadFiles(t)}}formats(){return ae.warn("[Uploader]: Should call derived class instead!"),[]}uploadFiles(e){ae.warn(`[Uploader]: Should call derived class instead! files: ${e}`)}openFileBrowserToUpload(){this.input.click()}},pP=class extends Cf{constructor(e,t){super(t),this.defaultModelConfig={src:"",merge:!1},this.viewer=e}formats(){return["gltf","glb","dxf","obj","stl","fbx","ifc","dae","*"]}uploadFiles(e){let t=e.length;if(0===t)return;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=Gs.extractUrlBase(i);n=new hu,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);ae.info(`[Uploader] Loading ${null==r?void 0:r.name}, ${t}%`)})).then((()=>{ae.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);ae.info(`[Uploader] Loading ${null==e?void 0:e.name}, ${i}%`)}))}};function zme(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 Gme=class extends Lr{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..."),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 Hme({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 dP(e)})),n.add(i,"showGroundGrass").name("Show ground grass").onChange((t=>{let i=e.findPlugin("GroundGrassPlugin");i?i.setVisible(t):i=new hP(e)})),n.add(i,"environments",i.environments).name("Environments").onChange((i=>{let n="";if("Default (City Streat 64x32)"===i){if(e.pmremGenerator)return dc.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}`,dc.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 L,a=new L,s=Ss.getVisibleObjectBoundingBox(t),o=fb.getCameraDirectionByView(i);fb.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 fP(e));let i=t.getScreenshot(),n=document.createElement("a");n.href=i,n.download="",n.click()})),n.add(i,"fullScreen").name("Full screen").onChange((()=>{oP&&oP.isEnabled&&oP.request(),e.enableRender()})),n.add(i,"uploadFile").name("Upload file").onChange((()=>{new pP(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 uP(e)),i.explode(t)})),r.add(i,"sectionMode",i.sectionMode).name("Section mode").onChange((t=>{let i=e.findPlugin("SectionPlugin");i||(i=new ZC(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()};zme(t,"position",o.position,n),zme(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 iu(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 iu(i.fogColor,n,i.fogFarDistance)),e.enableRender()})),c.add(i,"fogFarDistance",100,2e3).name("Far").onChange((n=>{i.fogEnabled&&t&&(t.fog=new iu(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}},qme=class extends Lr{constructor(e,t){super(e,{id:"LayerManagerPlugin"}),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;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.hide),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"),this.headerText=document.createElement("span"),this.headerText.innerHTML="Layers",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 `}addEventHandlers(){var e;null==(e=this.closeBtn)||e.addEventListener("click",this.hide.bind(this))}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.initMaterial(),this.initRenderTarget(),this.createGroundShadowByBBox(e,t)},this.onShadowRender=()=>{var e,t,i,n,r;this.shouldUpdateShadow()&&(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.cfg=t,this.viewer.addEventListener("ModelLoaded",this.onModelLoaded),this.viewer.addEventListener("BeforeRender",this.onShadowRender)}get scene(){return this.viewer.scene}get renderer(){return this.viewer.renderer}shouldUpdateShadow(){let e=!1,t=this.viewer.loadedModels.length;return this.modelCount!==t&&(this.modelCount=t,e=!0),e}initMaterial(){this.depthMaterial=new ac,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 an(jme),this.horizontalBlurMaterial.depthTest=!1,this.verticalBlurMaterial=new an(Wme),this.verticalBlurMaterial.depthTest=!1}initRenderTarget(){this.renderTarget=new Jn(128,128),this.renderTarget.texture.generateMipmaps=!1,this.renderTargetBlur=new Jn(128,128),this.renderTargetBlur.texture.generateMipmaps=!1}createGroundShadowByBBox(e,t){var i,n,r;this.shadowGroup=new Gn,this.shadowGroup.name=`${e}-ground-shadow`,Nn.disableLayerChannels(this.shadowGroup,[12,11]),null==(i=this.scene)||i.add(this.shadowGroup);let{min:a,max:s}=t,o=new L;t.getSize(o),o.multiplyScalar(2);let l=new L;t.getCenter(l);let h=new ti(o.x,o.z).rotateX(Math.PI/2),c=new rn({map:null==(n=this.renderTarget)?void 0:n.texture,transparent:!0,depthWrite:!1}),u=new _t(h,c);u.renderOrder=1,u.position.set(l.x,a.y,l.z),u.scale.y=-1,null==(r=this.shadowGroup)||r.add(u),this.shadowCamera=new Ir(-o.x/2,o.x/2,o.z/2,-o.z/2,-o.y/2,o.y),this.shadowCamera.position.set(l.x,a.y,l.z),this.shadowCamera.lookAt(l.x,s.y,l.z),this.shadowGroup.add(this.shadowCamera),this.blurPlane=new _t(h),this.blurPlane.position.set(l.x,a.y,l.z),this.blurPlane.visible=!1,this.shadowGroup.add(this.blurPlane)}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}},Yme=class extends Lr{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 ae.warn(`[Hotpoint] Hotpoint with id '${e.hotpointId}' already exist!`);let i=e.anchorPosition,n=$d.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 Gn,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}))}},Ms=$i($me(),1),yi=$i(Cge(),1),Z6={Fill:"Fill",Stroke:"Stroke",Shading:"Shading"},o1={Fill:0,Stroke:1,FillStroke:2,Invisible:3,FillAddToPath:4,StrokeAddToPath:5,FillStrokeAddToPath:6,AddToPath:7,FillStrokeMask:3,AddToPathFlag:4},Pge=16,Ige=100,K6=[1,0,0,1,0,0],J6=[.001,0,0,.001,0,0],Eht=["butt","round","square"],_ht=["miter","round","bevel"],Tht={},Dge={},Lge=new ct,wP=new Qe,SP=class extends hr{constructor(e){if(super(),this.contentVisible=!0,this.markedContentStack=[],this.stateStack=[],this.current=new jE(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 Qe,this.currentTransform=new Qe,this.transformStack=[],this.clipType=Ms.PolyFillType.pftNonZero,this.paths=[],this.pointsMaterials={},this.lineBasicMaterials={},this.meshBasicMaterials={},void 0===yi)throw"[PdfLoader] need load pdf.js first";this.font=e.font,yi.GlobalWorkerOptions.workerSrc=e.pdfWorker}load(e,t,i,n){let{src:r,merge:a}=e,s=e.modelId||r,o=yi.getDocument(r);o.onProgress=i,o.promise.then((e=>{ae.log("PDF loaded"),this.pdfDocumentGroup=new Gn,this.pdfDocumentGroup.name=`PdfDocument-${s}`,e.getPage(1).then((i=>{var n;ae.log("Page loaded"),ae.log(i),this.pdfPage=i,this.commonObjs=e._transport.commonObjs,this.objs=i.objs,this.pdfPageGroup=new Gn,this.pdfPageGroup.name=SP.MODEL_LAYOUT_NAME,null==(n=this.pdfDocumentGroup)||n.add(this.pdfPageGroup);let r=()=>{let e=i.view,n=8192/Math.max(e[2]-e[0],e[3]-e[1]),r=Math.min(300/72,n),o=i.getViewport({scale:r});this.beginDrawing(o),this.current=new jE(o.width,o.height),this.buildLayers(i),i.getOperatorList().then((e=>{this.operatorList=e,this.executeOperatorList(this.operatorList),this.operatorList.argsArray.length&&(this.endDrawing(),ae.log("[PdfLoader] pdf endDrawing"),a&&this.mergePdfObjects(),t({modelId:s,pdfData:{threejsObject:this.pdfDocumentGroup,layers:this.layers,layersAndThreejsObjects:this.layersAndThreejsObjects,loadedEntityCount:this.loadedEntityCount}}))}))};this.font instanceof Ni?this.font.getFontData().then((()=>{ae.log("[PdfLoader] Font loaded."),r()})):r()}))}),(function(e){n&&n(e)}))}loadAsync(e,t){return dt(this,null,(function*(){let i=wt.getUpdateProgressFunc(t),n=wt.getUpdateSubProgressFunc(0,10,t),r=wt.getUpdateSubProgressFunc(30,90,t);i(0);let{src:a,merge:s}=e,o=e.modelId||a,l=Date.now(),h=yi.getDocument(a);h.onProgress=n;let c=yield h.promise;this.pdf=c,ae.info(`[PdfLoader] Pdf document loaded in ${(Date.now()-l)/1e3}s`),l=Date.now(),ae.log(c),this.pdfDocumentGroup=new Gn,this.pdfDocumentGroup.name=`PdfDocument-${o}`,this.optionalContentConfig=yield c.getOptionalContentConfig(),c.numPages>1&&ae.info("[PdfLoader] Only the first page can be render others will be ignore.");let u=yield c.getPage(1);i(20),ae.info(`[PdfLoader] Pdf page loaded in ${(Date.now()-l)/1e3}s`),l=Date.now(),ae.log(u),this.pdfPage=u,this.pdfPageGroup=new Gn,this.pdfPageGroup.name=SP.MODEL_LAYOUT_NAME,this.pdfDocumentGroup.add(this.pdfPageGroup),this.commonObjs=c._transport.commonObjs,this.objs=u.objs,this.font instanceof Ni&&(yield this.font.getFontData(),ae.log("[PdfLoader] Font loaded."));let d=u.view,p=8192/Math.max(d[2]-d[0],d[3]-d[1]),f=Math.min(300/72,p),m=u.getViewport({scale:f});return this.beginDrawing(m),this.current=new jE(m.width,m.height),this.buildLayers(u),this.operatorList=yield u.getOperatorList(),i(30),yield this.executeOperatorList(this.operatorList,r),this.operatorList.argsArray.length&&(ae.info(`[PdfLoader] Pdf page add to scene loaded in ${(Date.now()-l)/1e3}s`),s&&this.mergePdfObjects(),this.endDrawing(),ae.log("[PdfLoader] pdf endDrawing")),i(100),{modelId:o,pdfData:{threejsObject:this.pdfDocumentGroup,layers:this.layers||[],layersAndThreejsObjects:this.layersAndThreejsObjects,loadedEntityCount:this.loadedEntityCount}}}))}mergePdfObjects(){for(let e in this.layersAndThreejsObjects){let t=this.layersAndThreejsObjects[e];if(t.length<=1)continue;let i=Gr.deepMerge(t,this.pdfDocumentGroup,!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]||(this.pointsMaterials[e]=new hi({color:e,transparent:!0,opacity:t})),this.pointsMaterials[e]}getLineBasicMaterial(e,t=1){return this.lineBasicMaterials[e]||(this.lineBasicMaterials[e]=new kn({color:e,transparent:!0,opacity:t})),this.lineBasicMaterials[e]}getMeshBasicMaterial(e,t=1){return this.meshBasicMaterials[e]||(this.meshBasicMaterials[e]=new rn({color:e,transparent:!0,opacity:t,side:vr})),this.meshBasicMaterials[e]}createTextMeshByText(e,t=12){let i;if(this.font instanceof Ni){let n=this.font.getGraphicDataByChar(e,t);n&&(i=n.toThreeGeometry())}else if(this.font instanceof Vo){let n={font:this.font,height:0,size:t||12,curveSegments:3,bevelSegments:3};i=new hm(e,n)}return i}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;ae.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(Cn.degToRad(-e.rotation));let{width:c,height:u}=e,d=(new Lt).setFromPoints([new L(0,0,0),new L(c,0,0),new L(c,u,0),new L(0,0,0),new L(c,u,0),new L(0,u,0)]),p=new rn({color:16777215}),f=new _t(d,p);f.renderOrder=-999,null==(n=this.pdfDocumentGroup)||n.add(f)}endDrawing(){this.font instanceof Ni&&this.font.releaseFontData()}buildLayers(e){return dt(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&&ae.warn("[PdfLoader] Line width not supported now.")}setLineCap(e){ae.log("setLineCap",Eht[e]),this.current.lineCap=e}setLineJoin(e){ae.log("setLineJoin",_ht[e]),this.current.lineJoin=e}setMiterLimit(e){ae.log("setMiterLimit",e),this.current.miterLimit=e}setDash(e,t){ae.log("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(){ae.log("[PdfLoader] ================save");let e=this.current;this.transformStack.push(this.currentTransform.clone()),this.stateStack.push(e),this.current=e.clone()}restore(){ae.log("[PdfLoader] ================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=wP.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.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=Oi(i),r=new $r(n,this.getPointsMaterial(e,t));this.addObjectToModel(r)}if(n.length>0){let i=Oi(n),r=new rr(i,this.getLineBasicMaterial(e,t));this.addObjectToModel(r)}}e&&this.consumePath(this.current.getClippedPathBoundingBox())}closeStroke(){this.closePath(),this.stroke()}fill(e=!0){this.current.patternFill&&ae.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 Ms.PolyTree,i=new Ms.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;Ms.JS.ScaleUpPaths(n,a),Ms.JS.ScaleUpPaths(r,a),i.AddPaths(n,Ms.PolyType.ptSubject,!0),i.AddPaths(r,Ms.PolyType.ptClip,!0),i.Execute(Ms.ClipType.ctIntersection,e,this.pendingEOFill?Ms.PolyFillType.pftEvenOdd:Ms.PolyFillType.pftNonZero,this.clipType);let s=Ms.JS.PolyTreeToExPolygons(e);for(let o=0;onew ye(e.X/a,e.Y/a)))),i.length>0&&i.forEach((e=>{let t=new ps;t.setFromPoints(e.map((e=>new ye(e.X/a,e.Y/a)))),n.holes.push(t)})),t.push(n)}this.clipPaths=void 0}e=t.length>0?new pl(t):Oi(this.paths.map((e=>new pl(e)))),e.applyMatrix4(this.currentTransform);let i=this.current.fillColor,n=this.current.fillAlpha,r=new _t(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.stroke(!1),this.consumePath()}eoFillStroke(){this.pendingEOFill=!0,this.fillStroke()}closeFillStroke(){this.closePath(),this.fillStroke()}closeEOFillStroke(){this.pendingEOFill=!0,this.closePath(),this.fillStroke()}endPath(){this.consumePath()}clip(){this.pendingClip=Tht}eoClip(){this.pendingClip=Dge}beginText(){this.current.textMatrix=K6,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}endText(){this.currentPath=new ps}setCharSpacing(e){this.current.charSpacing=e}setWordSpacing(e){this.current.wordSpacing=e}setHScale(e){this.current.textHScale=e/100}setLeading(e){this.current.leading=-e}setFont(e,t){var i;let n=this.commonObjs.get(e),r=this.current;if(!n)throw new Error(`Can't find font for ${e}`);if(r.fontMatrix=n.fontMatrix||J6,(0===r.fontMatrix[0]||0===r.fontMatrix[3])&&ae.warn("Invalid font matrix for font "+e),t<0?(t=-t,r.fontDirection=-1):r.fontDirection=1,this.current.font=n,this.current.fontSize=t,n.isType3Font)return;let a=n.loadedName||"sans-serif",s=(null==(i=n.systemFontInfo)?void 0:i.css)||`"${a}", ${n.fallbackName}`,o="normal";n.black?o="900":n.bold&&(o="bold");let l=n.italic?"italic":"normal",h=t;tIge&&(h=Ige),this.current.fontSizeScale=t/h,this.current.browserFontSize=h,ae.log(`[PdfLoader] font: ${l} ${o} ${h}px ${s}`),ae.log(`[PdfLoader] current font is: ${n.name}`)}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,n){ae.log("paintChar",e,t,i,n)}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=t.fontSizeScale,a=t.charSpacing,s=t.wordSpacing,o=t.fontDirection,l=t.textHScale*o,h=e.length,c=i.vertical,u=c?1:-1,d=i.defaultVMetrics,p=n*t.fontMatrix[0],f=t.textRenderingMode===o1.Fill&&!i.disableFontFace&&!t.patternFill;this.baseTransform.copy(this.currentTransform);let m=this.currentTransform.clone(),[g,v,y,x,b,_]=t.textMatrix;m.multiply(wP.set(g,y,0,b,v,x,0,_,0,0,1,0,0,0,0,1)),m.multiply(wP.makeTranslation(t.x,t.y+t.textRise,0)),o>0?m.scale(new L(l,1,1)):m.scale(new L(l,-1,1));let w=t.lineWidth,S=t.textMatrixScale;0===S||0===w?(t.textRenderingMode&o1.FillStrokeMask)===o1.Stroke||o1.FillStroke:w/=S,1!==r&&(m.scale(new L(r,r,1)),w/=r);let M,E=0,T=[];for(M=0;M0){let e,t=Oi(T);this.font instanceof Ni?e=new Br(t,this.getLineBasicMaterial(this.current.fillColor)):this.font instanceof Vo&&(e=new _t(t,this.getMeshBasicMaterial(this.current.fillColor))),e&&(this.addObjectToModel(e),e.layers.disable(11))}c?t.y-=E:t.x+=E*l,this.currentTransform.copy(this.baseTransform)}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=Lge.setRGB(e/255,t/255,i/255).convertSRGBToLinear().getHex()}setFillRGBColor(e,t,i){ae.log("setFillRGBColor",[e,t,i]),this.current.fillColor=Lge.setRGB(e/255,t/255,i/255).convertSRGBToLinear().getHex(),this.current.patternFill=!1}shadingFill(){}beginInlineImage(){}beginImageData(){}markPoint(e){}markPointProps(e,t){}beginMarkedContent(e){ae.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===Dge?this.clipType=Ms.PolyFillType.pftEvenOdd:this.clipType=Ms.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){ae.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):ae.warn("Dependent image isn't ready yet")}paintInlineImageXObject(e){if(!this.contentVisible)return;ae.log("paintInlineImageXObject",e),this.save();let{bitmap:t,width:i,height:n}=e;this.currentTransform.multiply(wP.makeScale(1/i,-1/n,1));let r=new Rx(t),a=new rn({map:r,transparent:!0}),s=new ti(i,n),o=new _t(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}},Bu=SP;Bu.MODEL_LAYOUT_NAME="Model";for(let t in yi.OPS)void 0!==Bu.prototype[t]&&(Bu.prototype[yi.OPS[t]]=Bu.prototype[t]);var jE=class{constructor(e,t){this.textMatrix=K6,this.fontMatrix=J6,this.textRenderingMode=o1.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=K6,this.textMatrixScale=1,this.fontMatrix=J6,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=o1.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 An,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]=yi.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=Z6.Fill,t=null){let i=[this.minX,this.minY,this.maxX,this.maxY];if(e===Z6.Stroke){if(!t)throw new Error("Stroke bounding box must include transform.");let e=yi.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=yi.Util.applyTransform(t,e),n=yi.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){yi.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=yi.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=yi.Util.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(e||[0,0,0,0])}isEmptyClip(){return this.minX===1/0}getClippedPathBoundingBox(e=Z6.Fill,t=null){return yi.Util.intersect(this.clipBox,this.getPathBoundingBox(e,t))||[]}},Oge=class extends Lr{constructor(e,t){super(e,{id:"PdfLoaderPlugin"}),this.cfg=t||{}}loadAsync(e,t){return dt(this,null,(function*(){let i=this.viewer;i.increaseJobCount();let n=this.cfg.font,r=this.cfg.pdfWorker,a=yield new Bu({font:n,pdfWorker:r}).loadAsync(e,t);return i.decreaseJobCount(),a}))}},kge=class extends Cf{constructor(e,t){super(t),this.defaultModelConfig={src:"",merge:!0},this.viewer=e}formats(){return["dxf","pdf"]}uploadFiles(e){for(let t=0;t{let i=Math.floor(100*t.loaded/t.total);ae.info(`[Uploader] Loading ${null==e?void 0:e.name}, ${i}%`)}))}))}uploadSinglePdf(e){return dt(this,null,(function*(){let t=t=>{let i=Math.floor(100*t.loaded/t.total);ae.info(`[Uploader] Loading ${null==e?void 0:e.name}, ${i}%`)};try{let i=this.viewer;i.increaseJobCount();let n={font:i.font,pdfWorker:"libs/pdf/pdf.worker.min.js"},r=pi(Kn({},this.defaultModelConfig),{src:URL.createObjectURL(e),modelId:e.name});new Bu(n).loadAsync(r,t).then((e=>{this.viewer.addModel(e),this.onSuccess&&this.onSuccess({}),i.decreaseJobCount(),ae.info(`[Uploader] Loaded model '${r.src}'`)}))}catch(e){ae.info(e)}}))}},Nge=class extends Cf{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 L(e,t,i),rotation:new zn(n,r,a)}),wht={Front:pi(Kn({},Fs([0,0,1],[0,0,0])),{label:"NavCube.front"}),Right:pi(Kn({},Fs([1,0,0],[0,oi,0])),{label:"NavCube.right"}),Back:pi(Kn({},Fs([0,0,-1],[0,Math.PI,0])),{label:"NavCube.back"}),Left:pi(Kn({},Fs([-1,0,0],[0,-oi,0])),{label:"NavCube.left"}),Top:pi(Kn({},Fs([0,1,0],[-oi,0,0])),{label:"NavCube.top"}),Bottom:pi(Kn({},Fs([0,-1,0],[oi,0,0])),{label:"NavCube.bottom"})},Sht=[Fs([0,1,1],[-Or,0,-oi]),Fs([0,1,-1],[-3*Or,0,-oi]),Fs([0,-1,1],[Or,0,-oi]),Fs([0,-1,-1],[3*Or,0,-oi]),Fs([1,1,0],[-oi,Or,0]),Fs([1,-1,0],[-oi,3*Or,0]),Fs([-1,1,0],[-oi,-Or,0]),Fs([-1,-1,0],[-oi,-3*Or,0]),Fs([1,0,1],[0,Or,0]),Fs([1,0,-1],[0,3*Or,0]),Fs([-1,0,1],[0,-Or,0]),Fs([-1,0,-1],[0,-3*Or,0])],Mht=[{position:new L(1,1,1),rotation:[new zn(-oi,oi,-Or),new zn(-oi,0,Or),new zn(0,0,3*Or)]},{position:new L(1,1,-1),rotation:[new zn(0,oi,3*Or),new zn(-oi,0,3*Or),new zn(0,Math.PI,-3*Or)]},{position:new L(-1,1,-1),rotation:[new zn(Math.PI,-oi,Or),new zn(-oi,0,-3*Or),new zn(0,Math.PI,3*Or)]},{position:new L(-1,1,1),rotation:[new zn(0,-oi,3*Or),new zn(-oi,0,-Or),new zn(0,0,-3*Or)]},{position:new L(1,-1,1),rotation:[new zn(0,oi,-Or),new zn(-oi,Math.PI,-Or),new zn(0,0,Or)]},{position:new L(1,-1,-1),rotation:[new zn(-oi,oi,3*Or),new zn(oi,0,Or),new zn(0,Math.PI,-Or)]},{position:new L(-1,-1,1),rotation:[new zn(0,-oi,Or),new zn(oi,0,-3*Or),new zn(0,0,-Or)]},{position:new L(-1,-1,-1),rotation:[new zn(0,-oi,-Or),new zn(oi,0,-Or),new zn(0,Math.PI,Or)]}],MP=class extends sn{constructor(e={}){super(),this.NAVCUBE_SIZE=100,this.clickHandler=e.onClick,(0,Am.forEach)(wht,(e=>{this.createPlane(e)})),(0,Am.forEach)(Sht,(e=>{this.createEdge(e)})),(0,Am.forEach)(Mht,((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=Iu(n),a.classList.add("navcube-plane"),a.classList.add("inner"),r.appendChild(a);let s=new wm(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=Fge,i.classList.add("navcube-edge");let n=new wm(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 zn)})),i.addEventListener("mouseenter",(()=>{let e=document.getElementsByClassName("group-"+t);(0,Am.forEach)(e,(e=>{e instanceof HTMLElement&&e.classList.add("highlight")}))})),i.addEventListener("mouseleave",(()=>{let e=document.getElementsByClassName("group-"+t);(0,Am.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 wm(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 zn).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 ${Fge}`,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 wm(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,Am.forEach)(e.rotation,((e,i)=>{l(e,t,i)})),i(r)}},Bge=class extends Lr{constructor(e,t){super(e,{id:"NavCubePlugin"}),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 JC,this.renderer.setSize(i,n),this.renderer.domElement.classList.add("css3d-navcube"),t.appendChild(this.renderer.domElement)}initScene(){this.scene=new mi;let e=window.innerWidth/window.innerHeight;this.camera=new Ir(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 MP({onClick:e=>{let t=this.viewer.controls;if(!(this.camera&&e&&this.viewer.camera&&t))return;let i=t instanceof sa?t.getTarget(new L):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 L;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)}},WE=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}};WE.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 Hge=WE,Uge=class extends Lr{constructor(e){super(e,{id:"StatsPlugin"}),this.init()}init(){var e;let t=new Hge;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}},XE=class extends _t{constructor(e,t,i,n=4e3,r=32,a=15,s=new L,o=new L(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 L},sunDirection:{value:o.normalize()}};this.geometry=new Ma(n,r,a),this.material=new an({uniforms:l,vertexShader:XE.vertexShader,fragmentShader:XE.fragmentShader,side:zi}),this.name=XE.NAME,this.matrixAutoUpdate=!1,this.layers.disable(12)}},qo=XE;qo.NAME="SKYBOX",qo.MIN_SKY_RADIUS=4e3,qo.MAX_SKY_RADIUS=2e4,qo.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 }",qo.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 Vge=class extends Lr{constructor(e,t){super(e,{id:"SkyboxPlugin"}),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&&wt.arrayToVector3(i.eye),n=i&&wt.arrayToVector3(i.look),r=new It;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 qo(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 Fx;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));tqo.MAX_SKY_RADIUS&&(t=qo.MAX_SKY_RADIUS),this.gradientColorSkybox.geometry=new Ma(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}};function Aht(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}var Rht=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}),AP=class extends Fr{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 L,t=new ye,i=new L,n=new L,r=new ye;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(Cn.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=Kn(Kn({},Rht),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 Aht(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 Cn.ceilPowerOfTwo(this.width*this.pixelRatio)}getDrawingBufferHeight(){return Cn.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=Kn(Kn({},this.cfg),e),this.needsRedraw=!0}};function Q6(e,t,i){let n=new ct(e),r=new ct(t);return n.lerp(r,i).getHex()}var Mr=(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))(Mr||{}),Hu=new L(1,0,0),ha=new L(0,1,0),xs=new L(0,0,1),zge={right:{text:"\u53f3",name:"RightFace",position:new L(50,0,0),rotation:{axis:ha,rad:Mr.Rotate90}},left:{text:"\u5de6",name:"LeftFace",position:new L(-50,0,0),rotation:{axis:ha,rad:Mr.Rotate270}},top:{text:"\u4e0a",name:"TopFace",position:new L(0,50,0),rotation:{axis:Hu,rad:Mr.Rotate270}},bottom:{text:"\u4e0b",name:"BottomFace",position:new L(0,-50,0),rotation:{axis:Hu,rad:Mr.Rotate90}},front:{text:"\u524d",name:"FrontFace",position:new L(0,0,50),rotation:{axis:ha,rad:0}},back:{text:"\u540e",name:"BackFace",position:new L(0,0,-50),rotation:{axis:ha,rad:Mr.Rotate180}}},RP=class extends sn{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 ye(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 sn,t=new L(-50,-50,-50),i=new L(1,0,0),n=new L(0,1,0),r=new L(0,0,1),a=this.AXIS_LENGTH/15,s=this.AXIS_LENGTH/20,o=new cc(i,t,this.AXIS_LENGTH,this.AXIS_COLOR_X,a,s),l=new cc(n,t,this.AXIS_LENGTH,this.AXIS_COLOR_Y,a,s),h=new cc(r,t,this.AXIS_LENGTH,this.AXIS_COLOR_Z,a,s);return e.add(o,l,h),e}createViewCubeFaces(){let e=new sn,t=[],i=new rn({color:this.FACE_BACKGROUND_COLOR,opacity:0,transparent:!0});Object.keys(zge).forEach((e=>{let n=zge[e],r=new AP({text:n.text,fontSize:100,color:"#cccccc",backgroundColor:this.FACE_BACKGROUND_COLOR,padding:.8,fontWeight:"bold"});r.redrew();let a=new rn({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 na(76,76,76),r=new _t(n,t);this.innerViewCubeMesh=r,e.add(r);let a=new lu(new na(100,100,100)),s=new rn({color:this.lineColor}),o=new Br(a,s);return e.add(o),e.position.set(0,0,0),e}createViewCubeFace(e,t,i,n){let r=new ti(76,76),a=new _t(r,t);return a.name=e,a.rotateOnAxis(n.axis,n.rad),a.position.copy(i),a}createViewCubeEdges(){let e=new sn,t=this.createEdge("TopFrontEdge",new L(0,51,51),[{axis:xs,rad:Mr.Rotate180}]),i=this.createEdge("TopRightEdge",new L(51,51,0),[{axis:Hu,rad:Mr.Rotate180},{axis:ha,rad:Mr.Rotate90},{axis:xs,rad:0}]),n=this.createEdge("TopBackEdge",new L(0,51,-51),[{axis:xs,rad:Mr.Rotate180},{axis:ha,rad:Mr.Rotate180}]),r=this.createEdge("TopLeftEdge",new L(-51,51,0),[{axis:Hu,rad:Mr.Rotate90},{axis:ha,rad:Mr.Rotate180},{axis:xs,rad:Mr.Rotate90}]),a=this.createEdge("BottomFrontEdge",new L(0,-51,51),[{axis:xs,rad:0}]),s=this.createEdge("BottomRightEdge",new L(51,-51,0),[{axis:Hu,rad:Mr.Rotate90},{axis:ha,rad:0},{axis:xs,rad:Mr.Rotate90}]),o=this.createEdge("BottomBackEdge",new L(0,-51,-51),[{axis:xs,rad:0},{axis:ha,rad:Mr.Rotate180}]),l=this.createEdge("BottomLeftEdge",new L(-51,-51,0),[{axis:Hu,rad:Mr.Rotate90},{axis:ha,rad:Mr.Rotate270},{axis:xs,rad:Mr.Rotate90}]),h=this.createEdge("FrontRightEdge",new L(51,0,51),[{axis:xs,rad:Mr.Rotate90}]),c=this.createEdge("BackRightEdge",new L(51,0,-51),[{axis:xs,rad:Mr.Rotate90},{axis:ha,rad:Mr.Rotate180}]),u=this.createEdge("BackLeftEdge",new L(-51,0,-51),[{axis:xs,rad:Mr.Rotate270},{axis:ha,rad:Mr.Rotate180}]),d=this.createEdge("FrontLeftEdge",new L(-51,0,51),[{axis:xs,rad:Mr.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 sn,r=new ti(this.EDGE_SIZE.x,this.EDGE_SIZE.y),a=new rn({color:this.EDGE_COLOUR,opacity:this.EDGE_OPACITY,transparent:!0}),s={tick:0},o=new _t(r,a);o.name=e,o.userData=s,o.position.setY(this.EDGE_SIZE.y/2),o.layers.enableAll();let l=new _t(r,a);return l.name=e,l.userData=s,l.position.setZ(-this.EDGE_SIZE.y/2),l.rotateOnAxis(new L(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 sn,t=this.createCorner("TopFrontLeftCorner",new L(-51,51,51),[{axis:xs,rad:Mr.Rotate270}]),i=this.createCorner("TopFrontRightCorner",new L(51,51,51),[{axis:xs,rad:Mr.Rotate180}]),n=this.createCorner("TopBackRightCorner",new L(51,51,-51),[{axis:Hu,rad:Mr.Rotate90},{axis:ha,rad:Mr.Rotate180},{axis:xs,rad:0}]),r=this.createCorner("TopBackLeftCorner",new L(-51,51,-51),[{axis:Hu,rad:Mr.Rotate90},{axis:ha,rad:Mr.Rotate180},{axis:xs,rad:Mr.Rotate90}]),a=this.createCorner("BottomFrontLeftCorner",new L(-51,-51,51),[{axis:xs,rad:0}]),s=this.createCorner("BottomFrontRightCorner",new L(51,-51,51),[{axis:xs,rad:Mr.Rotate90}]),o=this.createCorner("BottomBackRightCorner",new L(51,-51,-51),[{axis:Hu,rad:0},{axis:ha,rad:Mr.Rotate180},{axis:xs,rad:0}]),l=this.createCorner("BottomBackLeftCorner",new L(-51,-51,-51),[{axis:Hu,rad:0},{axis:ha,rad:Mr.Rotate180},{axis:xs,rad:Mr.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 sn,r=new ti(this.CORNER_WIDTH,this.CORNER_WIDTH),a=new rn({color:this.CORNER_COLOR,opacity:this.CORNER_OPACITY,transparent:!0}),s={tick:0},o=new _t(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 _t(r,a);l.name=e,l.userData=s,l.position.set(this.CORNER_WIDTH/2,0,-this.CORNER_WIDTH/2),l.rotateOnAxis(new L(1,0,0),Math.PI/2),l.layers.enableAll();let h=new _t(r,a);return h.name=e,h.userData=s,h.position.set(0,this.CORNER_WIDTH/2,-this.CORNER_WIDTH/2),h.rotateOnAxis(new L(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 It;return e.setFromObject(this),e}getDirectionByViewCubeName(e){let t;switch(e){case"TopFace":t=new L(0,1,0);break;case"BottomFace":t=new L(0,-1,0);break;case"FrontFace":t=new L(0,0,1);break;case"BackFace":t=new L(0,0,-1);break;case"LeftFace":t=new L(-1,0,0);break;case"RightFace":t=new L(1,0,0);break;case"TopFrontEdge":t=new L(0,1,1);break;case"TopRightEdge":t=new L(1,1,0);break;case"TopBackEdge":t=new L(0,1,-1);break;case"TopLeftEdge":t=new L(-1,1,0);break;case"BottomFrontEdge":t=new L(0,-1,1);break;case"BottomRightEdge":t=new L(1,-1,0);break;case"BottomBackEdge":t=new L(0,-1,-1);break;case"BottomLeftEdge":t=new L(-1,-1,0);break;case"FrontLeftEdge":t=new L(-1,0,1);break;case"FrontRightEdge":t=new L(1,0,1);break;case"BackRightEdge":t=new L(1,0,-1);break;case"BackLeftEdge":t=new L(-1,0,-1);break;case"TopFrontLeftCorner":t=new L(-1,1,1);break;case"TopFrontRightCorner":t=new L(1,1,1);break;case"TopBackRightCorner":t=new L(1,1,-1);break;case"TopBackLeftCorner":t=new L(-1,1,-1);break;case"BottomFrontLeftCorner":t=new L(-1,-1,1);break;case"BottomFrontRightCorner":t=new L(1,-1,1);break;case"BottomBackRightCorner":t=new L(1,-1,-1);break;case"BottomBackLeftCorner":t=new L(-1,-1,-1)}return t}update(){this.traverse((e=>{e instanceof _t&&this.updateViewCube(e)}))}updateViewCube(e){if(this.updateMeshTick(e),e.name.indexOf("Face")>-1){let t=e.userData.textTexture;if(t){let i=Q6(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=Q6(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=Q6(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 L;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(){Tn.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=document.getElementById(this.cfg.containerId);if(!t){ae.error("[ViewCube] containerId:",this.cfg.containerId,"is not found in dom tree! will append to gemini-widget-container");let i="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 Bo(this.container))}initScene(){let e=new mi;e.matrixAutoUpdate=!1,this.scene=e}initCamera(){if(!this.scene)return;let e=new Ir(-this.width/2,this.width/2,this.height/2,-this.height/2,.1,1e5);e.position.set(300,300,300),e.lookAt(0,0,0),e.zoom=10,e.updateProjectionMatrix(),this.scene.add(e),this.camera=e}initRenderer(){var e;this.renderer=new ms({antialias:!0,preserveDrawingBuffer:!0}),this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setSize(this.width,this.height),this.renderer.setClearColor(11119017,0),null==(e=this.container)||e.appendChild(this.renderer.domElement)}initLights(){if(!this.scene)return;let e=new Os(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 RP(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 sa?this.viewer.getBBox().getCenter(new L):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=on.getScreenPointByEvent(e,this.container);return on.screenPoint2NdcPoint(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 L;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)}},CP=class extends Ai{constructor(e,t){super(e),this.needsFrustumCulled=!1,this.image=t.image,this.min=t.min,this.max=t.max,this.radius=t.radius}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 L;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(){}getBounds(){let e=new L(-1,-3,-1),t=new L(1,-3,1);return new It(e,t)}isPointInPath(){return!1}getBBox(){return new It(this.min,this.max)}},YE=class extends Ai{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 L?t.position:new L(t.position.x,t.position.y,t.position.z),this.direction=t.direction?t.direction instanceof L?t.direction:new L(t.direction.x,t.direction.y,t.direction.z):void 0,this.radius=t.radius,this.rotation=t.rotation,this.enabledHover=!!t.enabledHover}direction2Rotation(e){return new ye(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 ye(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;if(this.radius){let e=new ye(i.x,i.z),n=new ye(t.position.x,t.position.z),r=e.distanceTo(n);0!==r&&i.lerp(t.position,1-this.radius/r)}let n=this.transToScreenCoord(i,t),r=this.hover&&this.hoverImage?this.hoverImage:this.image;e.save(),e.beginPath(),this.drawImage(e,r,n),e.closePath(),e.restore()}drawSelect(){}getBounds(){let e=new L(-1,0,-1),t=new L(1,0,1);return new It(e,t)}getClassType(){return"ImageDrawable"}isPointInPath(e,t){var i,n;if(null==t||!t.camera||!this.ctx||!this.enabledHover)return!1;let r=this.transToScreenCoord(this.position,t.camera),a=this.transToScreenCoord(e,t.camera);this.ctx.save(),this.ctx.clearRect(0,0,null==(i=this.ctx)?void 0:i.canvas.width,null==(n=this.ctx)?void 0:n.canvas.height),this.drawImage(this.ctx,this.image,r);let s=Math.max(devicePixelRatio,1),o=this.ctx.getImageData(a.x*s,a.y*s,1,1);return this.ctx.restore(),!!(o&&o.data[3]>0)}getBBox(){let e=this.position,t=new ye(e.x,e.z),i=new It,n=new ye(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 ye(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 L(i.x,e.y,i.y)}));return i.setFromPoints(l),i}},qge=class extends Ai{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]}draw(e,t){let i=this.positions.map((e=>{let i=new L(e.x,e.y,e.z);return this.transToScreenCoord(i,t)}));e.save(),e.beginPath(),e.lineWidth=this.lineWidth,e.strokeStyle=wn.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()}getBounds(){let e=new L(-1,-2,-1),t=new L(1,-2,1);return new It(e,t)}drawSelect(){}getClassType(){return"LineDrawable"}isPointInPath(){return!1}getBBox(){let e=this.positions.map((e=>new L(e.x,e.y,e.z)));return(new It).setFromPoints(e)}},jge=class extends Ai{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}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){let a=this.textStyle,s=a.borderRadius||0;n<2*s&&(s=n/2),r<2*s&&(s=r/2),e.save(),a.backgroundColor&&(e.fillStyle=a.backgroundColor),a.borderColor&&(e.strokeStyle=a.borderColor),a.borderWidth&&(e.lineWidth=a.borderWidth),e.beginPath(),e.moveTo(t+s,i),e.arcTo(t+n,i,t+n,i+r,s),e.arcTo(t+n,i+r,t,i+r,s),e.arcTo(t,i+r,t,i,s),e.arcTo(t,i,t+n,i,s),a.borderWidth&&e.stroke(),a.backgroundColor&&e.fill(),e.closePath(),a.backgroundColor&&e.fill(),e.restore()}draw(e,t){let i=this.textStyle,n=new L(this.position.x,this.position.y,this.position.z);if(this.radius){let e=new ye(n.x,n.z),i=new ye(t.position.x,t.position.z),r=e.distanceTo(i);0!==r&&n.lerp(t.position,1-this.radius/r)}let r=this.transToScreenCoord(n,t),a=this.getFont(),s=i.fontSize?i.fontSize:12;e.font=a,e.textAlign="center",e.textBaseline="middle";let o=e.measureText(this.text).width,l=s;i.outlineWidth&&(e.lineWidth=i.outlineWidth,e.strokeStyle=i.outlineColor||"black");let h=new ye(this.offset.x,this.offset.y);(i.borderWidth||i.backgroundColor)&&(o*=1.2,l*=1.5,this.drawRoundRect(e,r.x+(h.x-.5)*o,r.y+(h.y-.5)*l,o,l)),e.save(),e.beginPath(),i.outlineWidth&&e.strokeText(this.text,r.x+h.x*o,r.y+h.y*l),e.fillStyle=i.fontColor||"white",e.fillText(this.text,r.x+h.x*o,r.y+h.y*l),e.restore(),this.width=o*this.tolerance,this.height=l*this.tolerance}getBounds(){let e=new L(-1,-1,-1),t=new L(1,-1,1);return new It(e,t)}drawSelect(){}getClassType(){return"TextMarker"}isPointInPath(){return!1}getBBox(){let e=new L(this.position.x,this.position.y,this.position.z),t=new It;return t.min.x=e.x+(this.offset.x-.5)*this.width,t.min.y=e.y,t.min.z=e.z+(this.offset.y-.5)*this.height,t.max.x=e.x+(this.offset.x+.5)*this.width,t.max.y=e.y,t.max.z=e.z+(this.offset.y+.5)*this.height,t}},Wge="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFgAAABgCAMAAACuYkXGAAAAulBMVEUAAABJSV9pdntRWmdeaHZMW21ZYnJqcH9PV2dSWmtTXmtXX3Jka3tfZ3daY3NXYHBbZHNbZHJaYXNWX3D9/f5cZnT+/v6xs7zKzdKusbr6+vvs7e/Z29/s7e/09faPlaCVmaX6+vz6+vv5+fnw8fP3+Pjh4+Xu7/Da2+Dp6uz+/v719vjz9PX09PRfYXP///+vsLlpa3vDxMv19ffr6+7r6+2lprCHiJZ9fo1zdITNzdObnKeRkp9zdYQN9RLUAAAALnRSTlMAAwQICgYSBwsPDRUMDxcZHRsjH+Mg8TwvIMZ+UpGIMizVtqael3VrZ1zTuq2q+zBSvwAABtBJREFUaN7tmXlD00AQxSW7yeYsPaktKJcgeBRbbsHv/7V8b3ZjTOiRrfylTnoIpD+eb2dmD978j789dtzrjry8HrYWIL8u91Xx+HxgOYG88FHGK2gNbOxUb+7720It2BFNiAh4BXw66bjPMwlKA4gJTWiMUsrgUoZflrL9ra4sMCo0mlilldb4lxY6hQvbU7HDUipQiFjrPLYXvlKiXdAU7a03JCCWyNM8jfFM81znuRI0fmtovW7vr1ANpIGbpmmBSHglSZEiAIcr8JyOtLbDyoUarSGO2MnB/umn4RViOD3ZP0iKIi1yjQDY2EFsiUVwtHLITSaX072rWuydfIwgnG4rzWFsQxYsEkppcPGfn7wH9WUMT99Cth3HINysmQYzceECvU2IXRXv3yYp0YZFA3Abe0PYAG5xWWKvF3fPj/PZbPZ4f7e4KVV/TAr6oQwSb0PWkWsQzIVicuao3+5ntXgo2WcT2JHHSm3Q/Ct5NdI2efvJYam0GU8WPYQdcaxlBNc1DnIN0zcGd3jFAHZ5fHPkqKAbBK8mUzGqCeNWRJZ78zBbGT9unGaIps9rzEB5SmdIU8ddQO7qmH+v3IBm2ryKC3AIg4tiItxvFWSNHZ8mURLbQoGy5U6w3nRaJNGZ47Yin8HmnPnM/r3cYQMw8iz6yPu/z1rEgndeQnKs7AAuFwwfWMdi8M28DXh+Q5snEcbPlsnOipRQcV5E7ynjcdYqHqS6owRmhMsTQ+Y2ZAQyraXBlc17E9hMMwh+KTikExi5Uxoxaxvza5Ec5bDZvHRZ5mM6nBYZHX5qDXaSUSZQDEqzGUlXU2gRTAkK9pN8ic5PyS8Vsw2rGNzohCXnARbJ0wjj5yTXGzxTQhOcsQc/+IDv3fClOeoaAhsWg6vQfLIDPycY9OIgklxmw3jR4JWmE/ueTrjy288wnWhKRtSsMHboMlp85we+w0dOsyhx4GaHDy14irvu/cDP+MgxwbnSMvnVyxn9J0mizlDK2St+sF9kyAu2ZWj8XTPqmf0nirIrxMwv5vxMlqGsCa5lBZNCoeyiqOMLZpRgKnZeVE7I1BFlW4M7NFk18o1r0RDlUYLnW4B3Ac6RyBRcnz2M1N3WgwfFUcq5Lwga2YZZH2O3e4y7nv3ArOmpWKHZ7UVx1TSNyUXx1+0K5DPBhWazB7jeKix425ImmOlmalbYiTQnmE3o2g98yybkrDC1PHbpVhB8tOdb0w9sm71OmcdBo7sBzHTLelNOpb5OnAgYrb7RN6mYiYy06F3Qi7mnE+e9TOYQExqIrE9MRkki78ILL8lPzOIu6yPR0ukbM17AZTHBvXd+kin4C8GsD9PwGF64GSTr9Pwky7pw3KNigMEluV4hkm9Rp9el5KuHtuWMeNft2R7UXLKQLOCCXnSP2C9u2y0KacRwTCeK1K0461aUK0Ka3L24alt+sqg/7zonYhO8OHeBNdKRE3ox+OCz8P4w6O52skTWyA3BCPwq2X4kIvnouP1WYXjkBNvyaFj8a8mSsEZ6g/FQFvXrNzcL4Y4H4Eo962qD01wU0guRPLLk28c1LeLWcmkEBAOslu7WA9lDx1gCZB3aDPI6O+awwXEpmHs9dqA1WwWZ+KC578i3T0ux1/LD4/HICU4xQLUkbnY4DckkdwejQ+YG0YtGsdwTK/lwSL2Sw9wpALsCHMi+n82TZoz65xDt2Hf3j1T6+Hy3IFVsuOgPrF4Wh+aybcV+LJB2n8tEAnJ31B+julfE3rvD/qhLLo3gCtZW3XIwybG1mT4P+v3xl+FK7ACJ1ukIV8HgFVzaI6cKKpdZFT7TaLDPP+81qNMLwVZcdolVYGHLLh0tg/tpS4bTiIP9z1NRPjz+sn9wiO8MaK/4m3CRaeBwE9yskoAHFgBD9C7sABrsRozgbm/X+Ztq1Jw9ytpwOKboM8k0moMosivqgNiexRZJzoQwELzxEEt2qCQDDTbRZLsYIIC1XIDlWM9uzzeRgdaaI1iADD8QhDMGeBKKQetEkdgQIx/K7fkmdKioGXawCEs2ebwE6tSmItcm8MaTQueGNrKxLiy6YwNQJhipxNo0Y2W0PzWlaHEaqsXsKoSawIVcM89U24NvJzpkd1bidUG0C1KZClCLHyoFrPcBckgy0XGaJ0mBB4US6rxltTm5vkf0CkE20FCe5kVKKAtC8TIV1/OUHuMCWWTHuQZf57o8+scglNQd/7+DSLsj2GjrKJGa2NBiPeU6uKAlDM/5AeMbs8vIgUeD62kH4S4ok0IBbVC3RANUxU5FrcDbiy5pVMu3BnQ7dJl+AnZCeeHx5yE0C9us1R8uz//xD8RPQ80FqUsWMbIAAAAASUVORK5CYII=",Xge="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKoAAACqCAMAAAAKqCSwAAAAh1BMVEUAAABfTP9eTP9fTP9eTP9fTP9fTP9fTf9fTf9fTP9fTP9fTP9fTf9fTP9eTf9eTP9fTP9fTP9eTP9eTP9eTP9fTf9fTf9fTf9fTf9fTf9fTf9eTP9fTf9cSP9dS/9eTP9fTf9fTf9fTP9fTf9cSv9fTf9fTf9fTf9fTf9fTf9fTf9fTf9fTf/hY9QXAAAALXRSTlMARjRhS0HMZ1M5PVgva1wrTyYbFyJwlnx0gaATeAUPH4mmjYUKm5Gvv7m0q8X/SpWnAAAGcklEQVR42tXcCXriMAwFYEFhBsqeQIEGB2jTjc79zzdmFaDEjgmyhU/wf6+yvIUCxxhE8CBj3Kw9iHXZbNYew7p81tSHsEbPe2pDvDVuH6nSrVkdqcMlCB6q2z6jtgRb1aB+pGrpsCXYOq4jdZuqXGtcR2ptl2qrI9Oadi+oO2unMwZ5Q43OqY0DVaR11L2kDvfUfl+cNRl0SQHsqU/CrNmAUlsHqiyrGg+KU316GoGcEY+M1L9yrOnojNo8dQCkirGq5ciSqhhrMkYq6at7aq8nwqrGhEoKQFsHEH5EudThOVVLe5Pw1nSJ1PbFduUy1Ulwq4o01TStkDoLbE1s1P6ROpvNuhBiYKj51GFOqrNFkFwxVHuqSF2EyzWLojK1itRpMGsckVSbeLbKo4ayZoRqTXU6D2NN4tidGsSaxXGMtWrcA5xT3+vgfaTxRQF0Tc0KqSGsKjmnDooKgKb6vvJtzZBarq8i1bc10VRDX20ZUl29ebVmSeLQASZXVK/WVEtdlgCk7qyf/qxqR7Wn2iepznepfn62wdPIMNXRsQO0Cw4sdFqtNPXFk1WlJNWucVrRVF88WbMtNTF2ALK1XpxNK2194bcilU4rWgB92qxOqb58eLCqLDVMK3oMLKKyWpGaklSte4Apob4+A/PITqlGBiqdVpTKbVUHqvPWmlKJlY8a3URdnVHXfFakJnkLK1LNBYDUdRPOh+ACWK8Zc1VFBeCwsL6dqNr6i7kyUXEPYE8Vm9X8ulY1Fa081L0Vqe7NCqlfJ6uQApjmU381Fa1M1Pg+02pL3aCVmWpP9WpnRaibGofUdQnoFXYALIANi7UClRbAWg8t1dSfnxprqsvbDtdb6yFVpGorF1Vbb6PSDnCgftfCpkoP1/nTaqOp2spCNd4EUuqisFlhqt/fDa5U3W5XpjmbQKzVzY76r8GUqlMBWPrqz56KVg8FQKeVvQAwVbT6KABaqxNDB8BmdaD+abBQ3Y+Bc9qsrqlo5acW7AGmZQrgrlZSq873q6vcJQBTRWtVae4xsGvtAJZUkYpW/iWAvgXQZkX7KlLR6nsJ6BmpNFW08lC7tpvAhW21QipaWVarrjFVWqufhlTvZdVSMq0sBUCalbkDoNX/gcWxA9zNqhhOrISK1oAdYJ5XAGRaoZX1wEKpDqlSayWq6dLS7Wz1YWhWaPW6tZ5cXa+ZlwBi5aTSFxaknlarDwsVrR7PVo4LK7VyUOm3K/bV6pfUKrXemdq+U1+l1q+IoQNYD9e0AOiBhUoZa1VL899YaQd4JVQq5TxcD7FWXU8BxLqJgJPqXqs4raiUmdqq3qzwrx+0r+LCSvcARHo36qh6ql+kVomUcwlwfws4UkmdyplWhIqZ+r8Ictta/yNS1mlF+ursQLWfWFHq89KyU+EYiNLKVHwOrlYAtAOglDXVpuGTsPKpolTc4ZrsV4k0yGo1t6a6k0qgYqpFZyuUVh7GWjVRp+WWACKtmmpa4lvrjvuVxVYq5XsAPFznp/qLUuZmVfUiCKX8BYCrFVLJC0vhErCO4TCE9tVTqlr6INR1LOrTBcMS8EqljFtrOq3+kmn1XrCwotRjquQxyH62QilvB3B/Y6UF8IFSP99ZNfN/c23fWaGUi7q8z2MQkxSwAGK6Wu1jHTo2qxci9bSzajhuAtmkANW2KzTVT5QyUqu/W11IxVCneZtAVilStdXxLYDeWrNKARy/te4ZvrN6S4B1ZOV+GmansktBOfw0zNhXVwlwD4dNoGm1eueUIlVbb0sVO4APKSjrtGrZfhuIUuZhP7BYC2DuRwrZjT8MwYXVlxSU6YWlYf/KAqX8w+k5mL6wTP1JIavw20BmKY21wv3qwqsUspuvLHxLAW7+txvepZA5XQUjdZaC76HofpW+W1FqAClAesu0moSQgnL7zGaxpXqWYqzOtdoLJAXl2qxCSDFWSj1KabP6m0K4UXoTqKWzoFJIS/+DiNBSgPIXQaGlkJ2oXfPvrZ5SCD3icqkKkIJa7qgD00WQDClAWuI1sC9CChBZP7ORIgV1ubDSJaAjRQqQmKeVICnAspgqTApqVExtZSBqpIU3gdKkAFF+qgKlAKPcL9iHAqWgclKVKQXI6C8uGzKlAPHVw6VcKcDysgBqcqUAg7MCkC0F1UWqbKm21o8F0BQuBcjae6p8KUCqqY8hBYg19fkhpFvro0gBEhbpfwjbOY5gXmpMAAAAAElFTkSuQmCC",Yge="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFgAAABgCAMAAACuYkXGAAAAt1BMVEUAAABRUmRVYHFcZHBRWWZia3plb39aYnFeZnVYYXNZYnJPWGdZYnJRWWtZYnJZY3JWYG9eZnVcY3RXXnH+/v7+/v78/P2xs7zKzdKusbr6+vv4+frz9PXn6evs7e/09faPlaCVmaX6+vz09PX5+fns7fDa2+Dp6uzS1Nni4+X+/v7l5+rx8vL9/f1fTf////+vpv9pWP/DvP/19P9zY//r6f/r6P+lm/+Hef99bv/Nx/+bkP+RhP+tEDdkAAAALnRSTlMAAQMGCAsIDQ8UEgsXEB0gGhojJOLx5DwvIMa4m3CRiDIs1aymfWdcV03ShXjTY8FN1QAABtZJREFUaN7tmWlb2kAUhS1knSFAXFBArFtduoAgbtX//7t67gITEsCM+rFHwNZHXs9z5t6bybDzX376hi/5Bx5fxsSTeIBD8qPPUxUndP6f0+fITo0GngUs/ZEPMl0ADVAbKgf3J+siLaxWpOY1HV8yIQvQZlOeJeNedaJWHLhZlrJ94/imKkCjZhAEUYDXSMjCVtN14c4tM/GIAA3CILRhRPyo6HunJrhoVuwCGQIZxqF8t4TH3xK0rqEPmJiwZ4UXx7GN6ZX+AtwHTTYOMkf9DlkqV1MAFO9nZKLK8Iwh0C24hG7UQmv5arphBHcgJf3b35c/9yfQ/mD4+5bxFIx6hriZ6q0arVZsbZL1rwcHkxUdDEcZ0KFkzZ5JW/2qXc6B7fa/g1rV/uUR0FhGVCEHLdo6y5gb0YLFjN2k70dZHGNlIwl6KxdSbmCBTa4X2PvZ09t8Oh6P589Ps8eFawSCqB1586hecqPQIoVjpd49j1f0smAf9xEH6iMQ8nospaBlBm4cZ0c/FQunFb0Kev8oS6Q6dHBU2cAqOEC+KIYjlBek2KrulGyEvCVm4WoORrgPL+ONmj+qZ8QRcdWtn3WLhUOvLbkz2N2s6V8lI+dA04DWcRnM68bcOwfZEsefvkls4EbSGjD3G7oiM8fKrUU+NlR1FIakUSkJDSJOzGgC/R3X0GwCXWeJDXkgrUkCaOLS2JGCeJjWAU8fKea+iS1bXkvmimDD38nGfFxLL9zdJkPNsWWozG1C4KKCawbsYj7oI2Ys4DrLmjCCMJcUxLiupvdkOUXNWYArMS97LklSSvi1Nlgto02WA3SlKggcseGRGPazfG2SxFrpkp2y4ygirhlSy3mA2fLAGFh289MVW4OXDuCUZvCLD/hZlw9kBrsW4Qsdd12SpbeeSUCUxa0xMVfct6JjvoCKYfPDMwltvx8pli8ky4C5peMoaEyYlCJ+8gM/4S2Xqcli6mvFqnSuJYh4gN969gO/4S3nBI65rXcaxdEGLkfc2ud29tKc5kXL0CjSEVdYPFk7Y1oTaOyn6QRqpdzWAJf6GVw4VrCnFAzHq+NCRzFd6tJPgBGFXlRXJ0WEokgFPP0QOEVZVBZPGxqOex9dvJRaJGByybG1Bo7P8VtvHlTt6QE5FrBm7EZQzI4vPtYgw5Z0SECtt2pYo/hoSzvHxcVjMEYFGuSG9mt+YLqg3pBjrWOXBNzTdZQdnx349vQLjc2c6xjgJsAlyzyDWl0aFne+SQxzqmOOuNR6dC8TMviKsph6JjHqEjjWXYsrYwYHvHo5svCy/Ipf77UZHHKDAOjAHEVoMSta+Qlb9jJ80c6pPyw7Lu1X5MpEWfhY1n3hYQ5wRhu4BuSi0ClkefXyNlmevNRtZ+iEkjC8swC2UdmvhGy52z7r+W0Ke4ftnKdxZcuiyxdowbWvJnXbjzf1o3YuY94Cu7qvwFWvyWMoyQjc8dt4d6QmLDtGwkWw7oSk+fL22Xn9W4XeWbvbJcOxcNWwWz2qi8Dy8nXbhz3e1G+/uZkx9xB+5boUuYSd5M6cLbcQhpIf5ltGxKNwOQgj29gq190yUcoIowPytjimiMFxOeEI4DIZKWtbWw1jSX54XYu9n5DOwVXDga3eKrgmCSJYlvVrd06PJ4KelZrlGVjW8Sn8Sm9QETdk31YFO8uoOZA7I5hW9tPznJzO355moEoMV7sdCRhgWbl1jvGQlOXSx553D08mm3RwcrrLOWhv8Cnf+jMnhCyW44TJOci7hxe9TVji5i2pCHc2VKGS9OY/pphTJnc6u3uj4UGJOriCW2DbLeLKfSn8rgW7YzE6akuSTMjIY29vd+/m13DAznvnF79uTvEj4nYxIpZcvRXbdsKCyqA+UTK7hvacQAWWY0izLNFjIT30rapwhEUdyFWHpLk8CA4gqSNYVJnYxcKBSwkTY/OpMU+5gD0jjZTIXbINuqpNWOVyAUdR4eht8znh8tgtzhLDprtd2HbKc1AhYzgGq+eQ2w/tGYwGFNOJVAeUgw7lOR6gils5dVNuCbux6Li56QiSAhE4VXZLoIJN5CxIRwT0DlhLA2i4RhtCJmUByVAJwfIJtY40UY1TaTnpDijqhBJZSKkUQhDyialy3/9wwZ1383k5H54SHDgg8SpHpUrV02OttBrkRRNGajvGQxXGQo0W3KLbWqZ1EZWNpyX7eOGT/yVWPzurx5X+dlk3iQ4envRFlaBYpZa575aHsiMMPXoqdJmtygPr6oO19gMhNcxcL8NVdqMELcwzL8/uY4ay8DPH9ZW+UcQwkeAqHwT5w6va+aLPTPW1QJXTni+QYuW7gr9SHO5/eesfYdwFkua/O6kAAAAASUVORK5CYII=",$ge="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKoAAACqCAMAAAAKqCSwAAAB0VBMVEUAAAB5d55fTP9fTf9fTP9eTf9eTP9fTP9fTf5fTf9aYnFfTP9fTP9RV2hfTP9fTf9fTP9fTP9eTP9eTf9eTf9eTP9fTv5fTf9fTP9fTf9fTf9fTP9fTf9fTf9eTP9eTP9fTP9fTf9YX3BaYnRfTf9fTf9fTP9fTP9QVmZeTf9eTf9fTf9fTf9fTP9fTf9fTf9fTf9eTP9fTf9eTf9jantgTv1fTP9fTf9fTf9fTf9fTP9fTf9eTP9eTftfTf9fTf9eTf9fTP9fTf9fTf9gTvxfTf9aY3RaYnJfTf9fTf9fTf9eTf9aYnNZYXJeTP9fTf9eTuxbYnRfTv1cTuBfTvJfTf9eTP1fUPhfUuVcVsJbT91cT9tbWKtcWLFbXpNdVM5ZX3ReTvtcUsxbVMRcU8heUOb8/P5cWLlcVMheTPxZWZ79/v7+/v63ucpcXJvw8fSvs7r29vmVmarp6e7NztNWU7j7+/vR0eH7+/zh4uTy8/Tr7O2wsbr39/z3+Pj3+Pjl5+rKytSnptWpqsqKisD5+vro6PLs7PTa2ulfTf////9zY//r6P/19P9pWP/DvP+Hef+bkP/r6f+vpv/X0v+5sf/h3v/Nx/+lm/+RhP99bv89/FqOAAAAiXRSTlMABMw/RS9kbCdWB092BUIslzo8U180Ko9Zh5syI4RbNjh9DRBxaUd5CWdRrXNhXaNLSYpvCyBNgIGxjHtMG76UkqG6nh60JhnIqKbEExWqtyciFh4jwRkTIR0mGx0iISAdDycZFRjkKCQKGeLxOSeNP6ksby4QxVnUT5yAHsnJuF9HREI213iiZ4OOOrcAAA/ESURBVHja1NhPj5pAGAbwIYrr4gLVXf9lqavJFi3RZtHFblpJe/ATcIAzR7JNeuhemjTp3U/deWccRxjsSTLjYzTG0y9P3nkBURXpxehC4lj1EF1EAsuqX4Z1W6tZdde9AOu204FWfX+LFE/U7tQw1fX9jeLWrIupNdyq+7RpKW3V9DGlukD1AqRsNPuBUmFW1y3vVl2r02VU14dWvWtVrfF9l7f6BK1eK2pNdULlx6qFqQMVrVpTL7Ta8jB14CDl0tSPqO6BOvqknDWyCbW9p9IBINQ7xaxZj1L5rMKxuiXUhVJWzQFqYQBYq4tGE6mTuNmzbeFYsVYbClnTJqbqeeoG9iqjflTFqgWcyvfqGmaVUT8oYo2cIhVuAumsDvbUKyWsmiNQ6wfqiFGvekh+wgLVosdq7eWpK/nWNAjKWl23itRH2VYt5FTeqnu8Vxd76txGUpNsxVaBKrY6n99ItWrhNnDEDYCpa3YJuGuwVm+kWhNKFVsVNgChTnUkK1mMqUFJq/4GNkCx1en0qzRrFOap7fILK6dOJpKsWZRvtctaFQeAtTr5fI9kJGFUYa9SqnCsgPoiw5pFhHriwup5+3uARb7Vl/cSrGkUc6pd2KvlG2AC1IqtGrzJi/+URFF4guoL1Eeg0laHwy6qMsCEcG2WlA6AxfaqB9RR8VhBq8Mlt1ahNIGJvxw6TkQqf7Zie3VU2uryC7NWUadpsk+T9poxaumdFW2VD8Bqlaf2H1AFASIIDfIiZOCnSVRKtWir/OFaPFbD5bJfiZW2aRrG20/DMGmzCBkpH4CSVhl1dNzq9KjV/vfx+aEmxMB5/fGGrRCMT4EqbIDTDyz5AVhi6rfxuaEadc5mv3a7v7MZfAdt+r9WXfL/qjgAvFWgvmuf30qkf153u93v5+cZsWaEGpdT3dJba5H6j1Vz+00iCsJ4vDz4Um8x3qIxYdUYjalGaqJ4ibb1UkFbwQhCiwK1TcHUFrFatfEW4w5QWrHV+tc6c85ujzA7sCDzwusv337nm5lzQNYei0qgweAs/KjDa0RVrCWGymcApipDPdxbVg0aeAVQXq7AN2RF2GAp95hQ3SGQN1bKVSEBCPWyRkXWHgVqn/r6QSQNzEHNtjeg8D4QOBU8VSo9e5x7OImoQre6iA7gjTUUcsNKoSLr4N4eiYqkWtPAR6iWbdv+CbOWhbAlUpVQhxpQ93jNAGebDXDUGGBw8MbenoiqfEqklpWHuo21AoVXiBpA1Nwk1tWrA8LC0sarlzdRkbUHRaQIiqRF+GGrWoPXlqVIc48nUVU5AQiV71amW2mvDt7o79/WA1kJVZG+ysOqRl2uwlvLylFNEqqUAHKuEqo5Vqhq/8i2HpAqp1qWNQe/bKfqkA9bM0Sape8vtAC9BQiqGgPsVqqO3N3WC6cqo1JQ2W5V4F1kZmYml82RqkOCqsIW0JQAhx3U+zt7Ean4/cMUVLr0yZqfwcpOJpNJQdWmyeqERiVSMwMYAyDqmZ3/Q6qTKoikeKaMqBRYi0SazRLqkHysnNF6n6BqI6ph7fZUBUlUdaZMlQE+Sah8smpADXkcq36Nemnn/3x/R1Rs/obTCayURo1Gh3xNVuZYyahds24hqxIqBdWGwXQCayGVUqioasxzt8K+6qdbGQNcGh7e3jWrJrXoTDXVb3g+n0JSpWpMVLVVAhzgqg4/2N5tVOlOpYKqudZhNpVNtDCAeQ6WGytHvdmdrq5V30CdkarASiSS0WR0aCAWGxXerXyijjgGQNRuWGl7Uk21CNWVMq91mEslElFUNU4G2O+FeloMK1HVm9dOdmNVJWogD1ItJJLEGv/XAMfYDCCpyr06rFC7YHXOfzGv6rlHzSWUWQdadSt+FcznVST9F/XR+c7nP2KlBhC5/fTp2NjYLafGsJ5OTKTw+6eTJOpArAF1r2sAM6+ae4CQVlVIAI1671zn3x9RkTR8+zaxGlSqCWRNKK/G0QA7PEdrX8dqsMkAhHqvM111VhFqRKvawDqhUdPRNKLGRkfbvwbyIVBW9d6dc51d/ehNhb6/a4CvL1/Ob6Km0AHpdDoajcViXl41j+z7vK/XjKoc9c6VzkTto+9vRTTq/LulAlAtLS5o1nGSVanKDaA31u5VvbP1ov9DpRuAi7qwRJTVSqVKv/kikiLreFqjxvgLix6teViFzE2gV1g92ERlrHJX1VmlrTq/iJi11bKaVFZqFYDnL4mUDBAnVOZVWq5ZAvA18LpCRVKG2gErTYBoVYus+iIP1fqybWq1AoXvWtW4QkVSn+NKqH0L0KpiXfEpq5uqkcinAqw3zSvlGsDsOKFqVY/sN6iiAeRuNeKBylhlVHSq/v44rdaMpGZthaJinUZSMoD8xCajyqoqVp8e6NNZhah5vVZz1sKX8fHp6bg3aoOqZ8U7Kz1aC6oyXcVYRVH1skKa8qrBB0RF1iejox7HSj9biAnADWCO1SNC5azyAqBQww1zNVtaNCqy8ptAfr963MwA4hBowsqti+3XakJtvADgS8sHQn2iUXfxboVDIHtiI1U5qmQAzipvgOE8iSrL6qJSAnADiI9Bh5rWwLsc1T+rE1VvYd0Waw1mpzKOqgxVJwC/s/Kbq/5YTauyFmFNRl2BD1PTGUJFWduH1XF5ub7LjxVnlXcVGlXCr2FDRl2GwlQmk9Gouzz+ECIYwNe44p+VVEXUN/DHlqsKX6ccVO7V5o31gnC9JqByVpkUUfWpkqsCnxXqE6Oq2QLwhUXIVd5YDSozAGflBqBW1R41g4WkfAZgLyzcq/xYyagya5+zq7Q2AMCUqyrPVWe3OthqsrouG4CzSq//zq76t5oz/5EhCuJ4T4hr3UcciXMY1yJYZwhCTCJGXBnERGYdw65da9Z93yTNYtz8tar6Tc3r6W/XPNpMtpX1C798Ultdd72qX9NJf9FndVm0alCXLA61LP4is3Kj7tithYB6Wv2glbOq+Y8ElYeBOGSH1QXdVrEKQFK9BGTUe/6IjvrBfw2ocsIQGVyuwNWFFiGAWJFU/6wMav6u/xEQbe/6ua5VQZ2Hg0vMrLTA6ib1uLFmUIf8L7pSq5cJVUIAtte6lK41ahWdFZKqapVqdXjA/6ErVVBBq2QAzu6KAxVI9S4wOStWq5kCo9C4/Q2RXuHfv/WreMSEy0t6IwhQkRSFbFU6a1UeBKF89ysvL4e06t4IwhDgLliQFB1rowmYH74bw/r+i195ce0ao15BAzCoEq2c4+B9WhKIpCiCmuXOCrGOROz14zsmZdTz1lanYWptDQCc1U7HZ4WkurGaKpAbltxc+VQLgX7x/VdMyvUKpNaupiW2gvdpgRVJUSQISBvwRoVgP9RoJvCr9pX6QANDB68xap31ZAN1TthWuyJ+tVvRqqBCtHKTZpjVNFdZrWViZVgRAqXWZUAalIEnw1qd0XQcyqiLkjaCkFQfBBnXKi3rZw+ePK5UXj0ZunOQhEkF9SRWrDmpWPUqwJFaI6meBYpaiVUmAVaov8qopr92VJqWjrlVNwTWPWofAEgdxir+qhxhNQ12aa9RIwgKFj2wLv3TaIWkeieQm5YyCmBWS2pRSaBnNXMqNIJcVQB+VkDqrq+tWoX1WAO11GhaKmMLrK1WulBFq0iq+4AQqrCGx1YkJaPV2FZwzlYBLT2AZqtri3+5DMQW8PDmzUGW600yGEhjbAFazTVWF+bBCQOgYmB1k2LbgqfBqlQFVfEAYqvKhEX3AEeKyXYsbvNgBWXErwzawSUagCSBCfyqQuo01uy9+IT1nT9Ec0uaXKJW7asL2F2J3bNq7lkdAlKnVqVxVY2rWWp+pSRDVmV7LXQXsBpsVdWqQuqw1bpaHw5gKfj2nX9DULcog8uuuBDgHFxuKCZcCOoxu0vfYkpAnrGePasYgKQrjpYFFiwbjidaspB5AK2D/4AScJBQeXmFd1ccu9aOEBDOV/cRaWLWeuPifaSwqhrSs7wOoG0EMaq+ZwWfFaHu10jdxioF1m3/a+SbCpRqtHpasVVtxqr3V5ORZmTPKkivnzWPhOibOlcytkqs4WuLOTBi+4uu9QIHqXt2zZXA/bDD+uxXyv1MatYXTzt2AiEHUFAdpO702gyvh0MO6+2I/7RMrGdKsr0GBjBVdq1VZ4Wp9fSkpDJnk+z6Ac0vraPKl/sJtW6rFFhlywK6K4CqBtbkpOICBLVM63bWUeXzbAAXAls9razaKkuhSma1959ITbySQuAOOSwJ/mVC7S+ZVdtAq3FPGVjU2c7UWkiTokrZakpBcVjkqIbz+UI/CbEWT8C1haQreMaof1YJSbFoMYXAYPBlvSdHVTaoFwK1FpWlUO00LG5uNTcRKXYDpMI2XWE6CmDSw4cD0kvFS81anaPvBG5W/erOU225s2RUo1Z2WD/NN1UoHM5eZFb92iLnyletVhOTYoG1TFjJYVHwzwdKzd66GJww7FbPGNmvYisYndUmIE0YsEyB1fiy/IG6UpdlgyOWs0yK91birCBdwbHFfCBNHAWkxGa93qOVpUKBdZpd1sOkJKBVJbVW+qsLT7XzLtSwsg0Unlwl0EKWSXtuMSsfXOLJbWPE5spXgTS5mHu7VYaVd66eskYZla4DDWrLk1vX9tr2tpFmjF5XkbkaVgZllZJMmnTrFN2GFdmv6q8ugFabbFUhTewEmJXbLCQBJwufh07h1wGsreKQHSYs0XRlWxtIMRcUWCbtWUUq5TtxPg62L4SoBYt2GbS03aTm3ppIA9oeEjkPntLHatUOmR0b7G0ixQwrYxRLP/TXHF1nSPg6VD8N29pSqyuBtF32ynhMazQ6ie/uGw9EKI9EbW3lV9tEipkAsxKtEaKkH/vsBh4yu/dXJwNpu58ImGJISYwr65P3AVquhc8GrXb3eh2RDP8hMbyk4UDMf4EBwLK9bQVbZ9UBUnzPQlQq0otJoHsfYDmQtlOtQsuk8g8smegDETPw4jL6QgiRdliaEK1a40NADt9eEwMYD6SdACWRD0oko9iqbAXDazYdIkVelF5Exf6qrQJWdJYUYfGZOKwCcMTW3c2koyi9ylsWsGZDqKuJdDSlqLxlgQXLuFEm9fqU54y2hi/Z2VmtI9JRluNKdyViq7NHn9TLxNlqtL2WClL6stBWoWBZnwpSz9utPLthN4IWpYSU3rUVA1BCwLy0kHreqVa11ew0kXreAfAAoWg1MU2k9K49ttdEq7P6vFRJL+wDiK2mjZTia0wnkFHXpI7U8yZEcgBjAF0pJPUy02Ie4d+aRlLKW9Cv7konKZmroMr+6sa0knrelqY1m65cekk9bxqvL0ojaGyaSclcra2mm5RY54gBTE05KbEuMS2LMaknpQjLIeC/IKVSi7T6f5CSe5068z8hpUS7I6S/ARbzgdCIDH2vAAAAAElFTkSuQmCC",Lht=(e=>(e.ZoomChanged="ZoomChanged",e.SyncCamera="SyncCamera",e.CameraChanged="CameraChanged",e))(Lht||{}),Zge=class extends ts{constructor(e){var t,i,n;super(),this.CAMERA_Z_POSITION=100,this.width=0,this.height=0,this.frustumSize=this.width,this.renderEnabled=!1,this.drawableList=new Fo("overviewMap"),this.clock=new Qa,this.raf=new pf,this.raycaster=new qs,this.translateStart=new ye,this.rotateStart=new ye,this.markerRotateState=!1,this.markerTranslateState=!1,this.isMarkerRotating=!1,this.isMarkerTranslating=!1,this.isUpdateWhenPawnMove=!0,this.allMarkersBBox=new It,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=on.getScreenPointByEvent(e,this.viewerContainer),a=this.lockCameraInViewCenter?this.camera.position:on.worldPosition2ScreenPoint(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=on.getScreenPointByEvent(e,this.viewerContainer),s=this.lockCameraInViewCenter?this.camera.position:on.worldPosition2ScreenPoint(n.position,this.camera,this.viewerContainer);if(this.isMarkerRotating){let e=new ye(a.x-s.x,a.y-s.y),i=(new ye).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 ye(a.x,a.y),t=(new ye).subVectors(e,this.translateStart);if(Math.abs(t.x)>this.tolerance||Math.abs(t.y)>this.tolerance){let t=on.screenPoint2worldPosition(this.translateStart,this.camera,this.viewerContainer),r=on.screenPoint2worldPosition(e,this.camera,this.viewerContainer),a=(new L).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=on.getScreenPointByEvent(e,this.viewerContainer),a=on.screenPoint2worldPosition(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 ye(e.x,e.y);return this.boundaries.forEach((e=>{e.polygon.length<3||Jt.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),!Tn.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=e||{},this.transformMatrix=new Qe,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==(t=this.cfg.enabled)||t,this.lockCameraInViewCenter=!!this.cfg.lockCameraInViewCenter,this.radius=this.cfg.radius,this.size=this.cfg.size,this.minZoomFactor=null!=(i=this.cfg.minZoomFactor)?i:.3,this.maxZoomFactor=null!=(n=this.cfg.maxZoomFactor)?n: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(){Tn.isBrowser&&!this.cfg.context&&this.initDom(),this.initScene(),this.initRenderer(),this.initCamera(),this.initInputManager(),this.initEvents(),this.initControls()}initDom(){let e=document.getElementById(this.cfg.containerId);if(!e){ae.error("[ViewCube] containerId:",this.cfg.containerId,"is not found in dom tree! will append to document.body.");let t="overview-map";e=document.createElement("div"),e.id=t,document.body.appendChild(e),this.cfg.containerId=t}this.width=e.clientWidth,this.height=e.clientHeight,this.viewerContainer=e}initInputManager(){this.viewerContainer&&(this.inputManager=new Bo(this.viewerContainer))}initScene(){let e=new mi;e.background=null,e.matrixAutoUpdate=!1,e.matrixWorldAutoUpdate=!1,this.scene=e}initCamera(){if(!this.scene)return;let e=new Ir(-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};!Tn.isBrowser&&t&&Object.assign(i,{context:t,canvas:Tn.creatReactNativeCanvas(t)}),t&&(this.width=t.drawingBufferWidth,this.height=t.drawingBufferHeight),this.renderer=new ms(i),this.renderer.setClearColor(11119017,1),this.renderer.setClearAlpha(0),Tn.isBrowser&&(!t&&this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.domElement.classList.add("webgl-renderer"),null==(e=this.viewerContainer)||e.appendChild(this.renderer.domElement)),this.renderer.setSize(this.width,this.height),this.overlayRender=new On(this),this.overlayRender.addDrawableList(this.drawableList)}initControls(){let e=this.camera;if(!this.inputManager||!e)return;let t=new sa(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;$t.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=on.getScreenPointByEvent(e,this.viewerContainer),r=on.screenPoint2NdcPoint(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;this.controls.minZoom=0,this.controls.maxZoom=1/0;let e=this.getContainerRadius(),t=this.camera.zoom*Number((e/this.radius).toFixed(2));this.controls.zoomTo(t),this.initMaxAndMinZoom()}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=on.screenPoint2worldPosition(new ye(0,e),t,i),r=on.screenPoint2worldPosition(new ye(0,0),t,i);return Math.abs(new ye(n.x,n.z).distanceTo(new ye(r.x,r.z)))}initGroundPlane(e){var t;wt.expandBoxByScale(e,3);let i=e.min,n=e.max,r=n.x-i.x+n.y-i.y+n.z-i.z;wt.expandBoxByMinSize(e,r);let a=[],s=(e,t,i)=>{a.push(new L(e,t,i))},o=e.getSize(new L),l=e.getCenter(new L);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 Lt;e.setFromPoints(a),e.setIndex([0,3,2,0,2,1]),e.computeVertexNormals();let i=new rn({color:"#888",transparent:!0,opacity:0,side:vr});this.groundPlane=new _t(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(),Nn.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 dt(this,null,(function*(){let t=new L,i=new L;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 L(Math.min(t.x,i.x),0,Math.min(t.z,i.z)),a=new L(Math.max(t.x,i.x),0,Math.max(t.z,i.z)),s=new It(r,a);this.zoomToBBox(s),this.initMaxAndMinZoom(),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.addMarker(new CP("overviewMap",{image:n,min:t,max:i,radius:this.radius})),this.imgBBox=s,this.enableRender()}))}createCameraMarkers(e,t){return dt(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(Xge),n=yield this.getImageElementFromUrl($ge);this.addMarker(new YE("cameraDirDrawable",{image:i,hoverImage:n,translate:new ye(-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(Wge),n=yield this.getImageElementFromUrl(Yge);this.addMarker(new YE("cameraDrawable",{image:i,hoverImage:n,translate:new ye(-.5,-.5),scale:.25,position:e,direction:t,enabledHover:this.enabled}))}this.enableRender()}))}initCameraMarkers(e,t){return dt(this,null,(function*(){var i;let n=new L(e.x,e.y,e.z),r=new L(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);this.updateZoomFromRadius()}))}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=s.lerp(o,l),u=this.cameraDrawable,d=this.cameraDirDrawable;if(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){let i=this.cameraDrawable,n=this.cameraDirDrawable;if(!(this.camera&&this.viewerContainer&&i&&n&&this.isUpdateWhenPawnMove))return;this.animationId&&cancelAnimationFrame(this.animationId);let r,a=new L(e.x,e.y,e.z),s=new L(t.x,t.y,t.z);a.applyMatrix4(this.transformMatrix),s.applyMatrix4(this.transformMatrix),this.lockCameraInViewCenter?(r=this.camera.position.clone(),a.setY(r.y)):r=i.position.clone();let o=Date.now(),l=n.direction.clone();this.animationParam={startTime:o,positionStart:r,positionEnd:a,directionStart:l,directionEnd:s},this.updateOverviewMapCameraAnimation(),this.dispatchEvent("CameraChanged",a)}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 L;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 ye(e.x,e.y)));null==(t=this.boundaries)||t.set(e.id,{id:e.id,name:e.name,polygon:i})}))}screenShot(){return dt(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 ae.error(e)}}))}getViewConfig(){return this.cfg}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 It;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 L(.01*n,0,.01*n)),$t.areVector3sEqual(null==(e=this.allMarkersBBox)?void 0:e.min,i.min)&&$t.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()}};export{$Mt as AXIS_SECTION_PLANE_CONTROL_ID,YMt as AXIS_SECTION_PLANE_ID,IH as AnnotationTable,U5 as ArrowMarkup,xme as AxisGizmoPlugin,NR as AxisPlaneSection,$fe as AxisType,xv as BYBLOCK,yv as BYLAYER,yC as BaseDxfCompareHelper,wr as BaseMeasureDrawable,Lu as BaseMeasurement,df as BaseSection,Su as BaseTable,Sf as BaseVRMesh,bf as BaseViewer,fme as BimViewer,Gme as BimViewerDatGuiPlugin,tf as BinaryReader,ym as BitView,bme as BottomBarPlugin,xf as BoxSelectHelper,$d as CSS2DObjectUtils,sa as CameraControlsEx,bA as CancelablePromise,On as CanvasRender,V5 as CircleMarkup,fc as CloudLineMarkup,z5 as CloudRectMarkup,wn as ColorUtils,wt as CommonUtils,am as CompareDrawable,UR as ControlsHelper,on as CoordinateConversionUtils,Cpe as DEFAULT_BIMVIEWER_TOOLBAR_CONFIG,Dpe as DEFAULT_BIM_VIEWER_CONFIG,Ipe as DEFAULT_DXFVIEWER_TOOLBAR_CONFIG,qfe as DEFAULT_MARKUP_TOOLBAR_CONFIG,LH as DEFAULT_SIZE,Ppe as DEFAULT_VRVIEWER_TOOLBAR_CONFIG,Tn as DeviceUtils,G5 as DotMarkup,Ai as Drawable,Fo as DrawableList,fH as DxfChangeType,ns as DxfCompare,Vpe as DxfCompareHelper,_fe as DxfCompareMarkupManager,Pv as DxfDataTable,un as DxfLoader,um as DxfParser,Uhe as DxfRenderOrder,gc as DxfUtils,Ef as DxfViewer,XMt as ENTER_KEY,WMt as ESC_KEY,q5 as EllipseMarkup,ts as Event,uP as ExplodePlugin,$p as ExportUtils,Mu as FontDataTable,RA as FpsUtils,Lue as GROUND_PLANE_RENDER_ORDER,Gfe as GROUP_CONFIG,rC as GenerateMeshBvhWorker,Jt as GeometryUtils,hP as GroundGrassPlugin,dP as GroundGridPlugin,Xme as GroundShadowPlugin,Yme as HotpointPlugin,ov as ICON_FONT_CLASS,YE as ImageDrawable,Xi as IndexedDbManager,Bo as InputManager,Zfe as InstantiateHelper,qMt as KEYDOWN_EVENT,jMt as KEYUP_EVENT,wot as Keys,qme as LayerManagerPlugin,j5 as LeaderLineMarkup,qge as LineDrawable,xR as LinePatternShaders,Oa as LoadingHelper,kge as LocalDxfUploader,Nge as LocalImageUploader,pP as LocalModelUploader,E5 as MOUSEDOWN_EVENT,Zd as MOUSEMOVE_EVENT,b5 as MOUSEUP_EVENT,xb as MarkupManager,OR as MarkupToolbar,Ca as MarkupType,ji as MaterialUtils,$t as MathUtils,Rpe as MeasurementPlugin,Pl as MeasurementType,LR as MenuTypeEnums,Gr as MergeUtils,yf as MeshBvhHelper,hC as MobileTouchHelperDrawable,Bge as NavCubePlugin,om as NestCompareTypes,lC as OSnapHelper,_he as OSnapMarkerType,Mpe as OSnapType,wpe as ObjectPixelSizeHelper,Nn as ObjectUtils,YC as ObjectsBoxSection,qpe as Offset,sfe as Orientation,CP as OverviewMapDrawable,Zge as OverviewMapPlugin,Lht as OverviewMapPluginEvent,Bu as PdfLoader,Oge as PdfLoaderPlugin,cC as PickMarkupHelper,$C as PickPlaneSection,Lr as Plugin,Qp as PolygonUtils,W5 as PolylineMarkup,cf as ProgressBar,pf as RafHelper,X5 as RectMarkup,JMt as SECTION_BOX_ID,KMt as SECTION_PLANE_CONTROL_ID,ZMt as SECTION_PLANE_ID,_5 as SECTION_PLANE_NAME,Tpe as SHP,nC as SHPLoader,eC as SHPParser,XGt as SIMPLE_BIM_VIEWER_CONFIG,nRt as SNAP_ICON_SIZE,Tot as STATE,aue as SVGObject,Ehe as SVGObjectUtils,oue as SVGRenderer,Ss as SceneUtils,T5 as ScreenshotMode,fP as ScreenshotPlugin,ZC as SectionPlugin,lv as SectionType,xu as SectionUtils,tC as ShpThree,Ni as ShxFont,zo as ShxFontLoader,fm as ShxFontType,pme as SimplifiedBimViewer,bhe as SimplifyUtils,Vge as SkyboxPlugin,ys as SnapDrawable,Uge as StatsPlugin,jge as TextDrawable,El as TextMarkup,dc as TextureUtils,Du as Toolbar,jH as ToolbarMenu,uE as ToolbarMenuId,PH as Units,YA as VRControls,QC as VRCube,eP as VRCube24Faces,tP as VRSphere,yme as VRViewer,Gge as ViewCubePlugin,fb as Viewer3DUtils,ki as ViewerEvent,Yut as ViewerMode,Vv as ViewerName,DH as ViewpointTable,H5 as Views,XC as WebCam,Y5 as XMarkup,zv as ZoomToRectHelper,CH as bspline,ife as checkIsNewVersion,zue as cn,efe as createHatchPatternShaderMaterial,Ilt as decodeDxfTextCharacterCodes,Llt as decodeDxfTextMbcsCharacterCodes,Dlt as decodeDxfTextUnicodeCodePoints,Vue as en,uRt as getLengthValueByUnit,db as getUnitStr,Olt as getVersionFromLocalStorage,yu as layerForHitableObjects,Wr as layerForSelectableObjects,vs as layerForSnapableObjects,ae as log,Zr as matrixAutoUpdate,bR as parseDxfMTextContent,ER as parseDxfTextContent,AH as round10,GMt as sceneAutoUpdate,TA as setIcon,uue as setLogLevel,klt as setVersionToLocalStorage,vu as showPrecisionValue,The as unitConversionByMeter,vot as unitLabel,nfe as unitScaleConversion,tfe as unitScaleToMeter}; \ No newline at end of file diff --git a/demo/libs/types/core/Configs.d.ts b/demo/libs/types/core/Configs.d.ts index 80083b0..3a035f1 100644 --- a/demo/libs/types/core/Configs.d.ts +++ b/demo/libs/types/core/Configs.d.ts @@ -225,6 +225,12 @@ export interface BimViewerConfig extends BaseViewerConfig { * Shows the context-menu. */ enableContextMenu?: boolean; + /** + * If user can select an entity by mouse click + * @internal + * @default true + */ + enableSelection?: boolean; /** * Default is `meters` * @internal diff --git a/demo/libs/types/core/canvas/CanvasRender.d.ts b/demo/libs/types/core/canvas/CanvasRender.d.ts index 5eb38d8..1c35b26 100644 --- a/demo/libs/types/core/canvas/CanvasRender.d.ts +++ b/demo/libs/types/core/canvas/CanvasRender.d.ts @@ -45,7 +45,7 @@ export declare class CanvasRender extends Event { type: string; quality: number; }): Promise; - getImage(filter: (drawabkle: Drawable) => boolean): Promise; + getImage(filter: (drawable: Drawable) => boolean): Promise; getCanvas(): HTMLCanvasElement | undefined; destroy(): void; } diff --git a/demo/libs/types/core/helpers/OSnapHelper.d.ts b/demo/libs/types/core/helpers/OSnapHelper.d.ts index 32506d7..5ce1e47 100644 --- a/demo/libs/types/core/helpers/OSnapHelper.d.ts +++ b/demo/libs/types/core/helpers/OSnapHelper.d.ts @@ -2,11 +2,11 @@ import * as THREE from "three"; import { CanvasRender, Drawable, DrawableList } from "../../core/canvas"; import { ILine, OSnapMarkerType } from "../../core/utils"; export declare class SnapDrawable extends Drawable { - static readonly LINE_COLOR = "rgba(255, 119, 0, 1)"; + static lineColor: string; static readonly FILL_COLOR_NONE = "rgba(0, 0, 0, 0)"; static readonly SNAP_LINE_COLOR = "rgba(255, 240, 0, 0.3)"; - static readonly LINE_WIDTH = 2; - static readonly SNAP_ICON_SIZE = 14; + static lineWidth: number; + static iconSize: number; needsFrustumCulled: boolean; renderOrder: number; snapType: OSnapMarkerType; @@ -87,6 +87,32 @@ export declare class OSnapHelper { getSnapTolerance(): number; setIntersectionLimit(val: number): void; getIntersectionLimit(): number; + /** + * Gets osnap marker line color. + * @returns rgb/rgba number array, each value is between 0 and 1. e.g. [0.92, 0.95, 0.96]. + */ + getMarkerLineColor(): number[]; + /** + * Sets osnap marker line color. + * @param color rgb/rgba number array, each value is between 0 and 1. e.g. [0.92, 0.95, 0.96]. + */ + setMarkerLineColor(color: number[]): void; + /** + * Gets osnap marker line width. + */ + getMarkerLineWidth(): number; + /** + * Sets osnap marker line width. + */ + setMarkerLineWidth(width: number): void; + /** + * Gets osnap marker icon size in pixel. + */ + getMarkerIconSize(): number; + /** + * Sets osnap marker icon size in pixel. + */ + setMarkerIconSize(size: number): void; getMarker(type: OSnapType): SnapDrawable; setAllSnapLinesVisible(visible: boolean): void; deactivate(): void; diff --git a/demo/libs/types/core/input/InputManager.d.ts b/demo/libs/types/core/input/InputManager.d.ts index 19588e8..29c83fa 100644 --- a/demo/libs/types/core/input/InputManager.d.ts +++ b/demo/libs/types/core/input/InputManager.d.ts @@ -108,13 +108,17 @@ export declare type InputEvents = { }; export declare class InputManager extends Event { private element; - private enable; + private enabled; + private keyboardEnabled; protected mouseDownPositionX: number; protected mouseDownPositionY: number; protected lastLeftPointerUpTime: number; private pointers; constructor(element: HTMLElement); - setEnable(enable: boolean): void; + getEnabled(): boolean; + setEnabled(enable: boolean): void; + getkKeyboardEnabled(): boolean; + setkKeyboardEnabled(enable: boolean): void; setCursor(cursorStyle: string): void; bindEvents(): void; private handleClick; diff --git a/demo/libs/types/core/viewers/BimViewer.d.ts b/demo/libs/types/core/viewers/BimViewer.d.ts index e9903ab..49026a4 100644 --- a/demo/libs/types/core/viewers/BimViewer.d.ts +++ b/demo/libs/types/core/viewers/BimViewer.d.ts @@ -28,6 +28,7 @@ export declare class BimViewer extends BaseViewer { * @internal */ hemisphereLight?: THREE.HemisphereLight; + enableSelection: boolean; /** * @internal */ diff --git a/demo/libs/types/core/viewers/VRViewer.d.ts b/demo/libs/types/core/viewers/VRViewer.d.ts index fb209a8..7ba994a 100644 --- a/demo/libs/types/core/viewers/VRViewer.d.ts +++ b/demo/libs/types/core/viewers/VRViewer.d.ts @@ -1,9 +1,19 @@ -import { CSS2DRenderer } from "three/examples/jsm/renderers/CSS2DRenderer.js"; +import { CSS2DObject, CSS2DRenderer } from "three/examples/jsm/renderers/CSS2DRenderer.js"; import { CSS3DRenderer } from "three/examples/jsm/renderers/CSS3DRenderer.js"; import { Toolbar } from "../../components/toolbar"; import { Model3d, CameraConfig, Hotpoint, ModelConfig, Panorama, VRViewerConfig, VRViewpoint } from "../../core/Configs"; import { Vector3 } from "../../core/Constants"; import { BaseViewer, ViewerName } from "../../core/viewers/BaseViewer"; +import { BaseVRMesh } from "../../core/vr"; +interface ViewpointAssets { + panoramas: [ + { + id: string; + box: BaseVRMesh; + } + ]; + css2dObjects: CSS2DObject[]; +} export declare class VRViewer extends BaseViewer { /** * @internal @@ -36,11 +46,9 @@ export declare class VRViewer extends BaseViewer { private isMousePressing; private settings; private viewpoints; - private previousViewpointId; - private previousPanoramaId; private activeViewpointId; private activePanoramaId; - private viewpointAssetsMap; + viewpointAssetsMap: Map; private controlsHelper?; private cameraUpdateInterval?; private fianlCameraPosition?; @@ -169,7 +177,7 @@ export declare class VRViewer extends BaseViewer { * Activates a panorama by viewpointId and panoramaId */ activatePanoramaById(viewpointId: string, panoramaId: string, setCameraToInitialDirection?: boolean, animate?: boolean, onSuccess?: (viewpoint: VRViewpoint) => void, onError?: (event: ErrorEvent) => void): void; - removeCachedPanoramas(): void; + removeCachedPanoramas(excludePanoramas?: Record): void; /** * Unlimits controls and show all assets. This is useful for debugging. * @internal @@ -223,3 +231,4 @@ export declare class VRViewer extends BaseViewer { */ private merge; } +export {}; diff --git a/demo/libs/types/core/vr/VRCube.d.ts b/demo/libs/types/core/vr/VRCube.d.ts index b1642bb..1bf13ae 100644 --- a/demo/libs/types/core/vr/VRCube.d.ts +++ b/demo/libs/types/core/vr/VRCube.d.ts @@ -7,5 +7,6 @@ import { BaseVRMesh } from "./BaseVRMesh"; export declare class VRCube extends BaseVRMesh { constructor(images: string[], thumbnailImages?: string[], size?: number); create(): Promise; + private updateMesh; protected createMesh(): Promise; } diff --git a/demo/libs/types/plugins/measure/AreaMeasureDrawable.d.ts b/demo/libs/types/plugins/measure/AreaMeasureDrawable.d.ts index 9125843..846a0c1 100644 --- a/demo/libs/types/plugins/measure/AreaMeasureDrawable.d.ts +++ b/demo/libs/types/plugins/measure/AreaMeasureDrawable.d.ts @@ -3,7 +3,8 @@ import { BaseMeasureDrawable } from "./BaseMeasureDrawable"; import { MeasurementType } from "./BaseMeasurement"; export declare class AreaMeasureDrawable extends BaseMeasureDrawable { type: MeasurementType; - constructor(id: string, points: THREE.Vector3[]); + scale?: number; + constructor(id: string, points: THREE.Vector3[], scale?: number); draw(ctx: CanvasRenderingContext2D, camera: THREE.Camera): void; drawText(ctx: CanvasRenderingContext2D, camera: THREE.Camera): void; calculateArea(points: THREE.Vector3[]): number; diff --git a/demo/libs/types/plugins/measure/AreaMeasurement.d.ts b/demo/libs/types/plugins/measure/AreaMeasurement.d.ts index 6e257b6..86ce149 100644 --- a/demo/libs/types/plugins/measure/AreaMeasurement.d.ts +++ b/demo/libs/types/plugins/measure/AreaMeasurement.d.ts @@ -6,6 +6,10 @@ import { OSnapHelper } from "../../core/helpers"; import { EventInfo, InputManager } from "../../core/input/InputManager"; import type { BaseViewer } from "../../core/viewers"; export declare class AreaMeasurement extends BaseMeasurement { + /** + * The ratio of real world value and the value in three.js(pdf, a map, etc.). + */ + private scale?; constructor(viewer: BaseViewer, input: InputManager, drawList: DrawableList, osnapHelper: OSnapHelper); activate(): void; deactivate(): void; @@ -16,4 +20,12 @@ export declare class AreaMeasurement extends BaseMeasurement { protected complete(): void; cancel(): void; protected setTooltipContent(): void; + /** + * Gets the scale value. + */ + getScale(): number | undefined; + /** + * Sets the scale value. + */ + setScale(scale: number): void; } diff --git a/demo/libs/types/plugins/measure/DistanceMeasureDrawable.d.ts b/demo/libs/types/plugins/measure/DistanceMeasureDrawable.d.ts index de2ceb9..5ecf718 100644 --- a/demo/libs/types/plugins/measure/DistanceMeasureDrawable.d.ts +++ b/demo/libs/types/plugins/measure/DistanceMeasureDrawable.d.ts @@ -3,11 +3,13 @@ import { BaseMeasureDrawable } from "./BaseMeasureDrawable"; import { MeasurementType } from "./BaseMeasurement"; export declare class DistanceMeasureDrawable extends BaseMeasureDrawable { static readonly SHORT_LINE_LENGTH = 12; + scale?: number; type: MeasurementType; - constructor(id: string, points: THREE.Vector3[]); + constructor(id: string, points: THREE.Vector3[], scale?: number); draw(ctx: CanvasRenderingContext2D, camera: THREE.Camera): void; drawText(ctx: CanvasRenderingContext2D, camera: THREE.Camera): void; private drawVerticalLine; private getShortLineBySegments; getClassType(): string; + setScale(scale: number): void; } diff --git a/demo/libs/types/plugins/measure/DistanceMeasurement.d.ts b/demo/libs/types/plugins/measure/DistanceMeasurement.d.ts index 2b90079..b741670 100644 --- a/demo/libs/types/plugins/measure/DistanceMeasurement.d.ts +++ b/demo/libs/types/plugins/measure/DistanceMeasurement.d.ts @@ -5,6 +5,10 @@ import { OSnapHelper } from "../../core/helpers"; import { EventInfo, InputManager } from "../../core/input/InputManager"; import type { BaseViewer } from "../../core/viewers"; export declare class DistanceMeasurement extends BaseMeasurement { + /** + * The ratio of real world value and the value in three.js(pdf, a map, etc.). + */ + private scale?; constructor(viewer: BaseViewer, input: InputManager, drawList: DrawableList, osnapHelper: OSnapHelper); protected createMeasureDrawable(): DistanceMeasureDrawable | undefined; protected onMouseClick(e: EventInfo): void; @@ -13,4 +17,12 @@ export declare class DistanceMeasurement extends BaseMeasurement { cancel(): void; deactivate(): void; protected setTooltipContent(): void; + /** + * Gets the scale value. + */ + getScale(): number | undefined; + /** + * Sets the scale value. + */ + setScale(scale: number): void; } diff --git a/demo/libs/types/plugins/measure/MeasurementPlugin.d.ts b/demo/libs/types/plugins/measure/MeasurementPlugin.d.ts index ca57fdb..5b6fc4b 100644 --- a/demo/libs/types/plugins/measure/MeasurementPlugin.d.ts +++ b/demo/libs/types/plugins/measure/MeasurementPlugin.d.ts @@ -111,6 +111,17 @@ export declare class MeasurementPlugin extends Plugin { * @description Unselects a measurement. */ unselect(renderEnabled?: boolean): void; + /** + * Gets the scale value. + * Scale is the ratio of real world value and the value in three.js(pdf, a map, etc.). + * e.g., Real world distance is 1000, and the value in three.js is 1, then scale is 1000. + * We should display 1000 rather than 1 while measuring. + */ + getScale(): number | undefined; + /** + * Sets the scale value. + */ + setScale(scale: number | undefined): void; /** * @description Destroy measure plugin */ diff --git a/demo/libs/types/plugins/overview-map/OverviewMapPlugin.d.ts b/demo/libs/types/plugins/overview-map/OverviewMapPlugin.d.ts index 3f8a3c3..792dd73 100644 --- a/demo/libs/types/plugins/overview-map/OverviewMapPlugin.d.ts +++ b/demo/libs/types/plugins/overview-map/OverviewMapPlugin.d.ts @@ -62,6 +62,8 @@ export declare class OverviewMapPlugin extends Event<{ private imgBBox?; private translateStart; private rotateStart; + private markerRotateState; + private markerTranslateState; private isMarkerRotating; private isMarkerTranslating; private isUpdateWhenPawnMove; @@ -94,6 +96,8 @@ export declare class OverviewMapPlugin extends Event<{ private handlePointerDown; private onCameraMove; private handlePointerUp; + private handlePointerLeave; + private handlePointerEnter; private handleDblClick; private handlePointerMove; private syncCamera; diff --git a/demo/libs/types/plugins/pdf/PdfLoader.d.ts b/demo/libs/types/plugins/pdf/PdfLoader.d.ts index 02b5082..9f331c0 100644 --- a/demo/libs/types/plugins/pdf/PdfLoader.d.ts +++ b/demo/libs/types/plugins/pdf/PdfLoader.d.ts @@ -44,6 +44,12 @@ export declare class PdfLoader extends THREE.Loader { currentTransform: THREE.Matrix4; transformStack: THREE.Matrix4[]; currentPath?: THREE.Shape; + clipPaths?: THREE.Shape[]; + clipType: any; + paths: THREE.Shape[]; + private pointsMaterials; + private lineBasicMaterials; + private meshBasicMaterials; font?: ShxFont | Font; constructor(cfg: PdfLoaderConfig); load(modelCfg: DxfModelConfig, onLoad: (data: Model2d) => void, onProgress: (event: ProgressEvent) => void, onError: (error: any) => void): void; @@ -54,6 +60,10 @@ export declare class PdfLoader extends THREE.Loader { * @returns */ loadAsync(modelCfg: DxfModelConfig, onProgress: (event: ProgressEvent) => void): Promise; + private mergePdfObjects; + private getPointsMaterial; + private getLineBasicMaterial; + private getMeshBasicMaterial; private createTextMeshByText; getTransformByMatrix4(matrix: THREE.Matrix4): number[]; getObject(data: any, fallback?: null): any; @@ -187,8 +197,8 @@ declare class CanvasExtraState { textHScale: number; textRenderingMode: number; textRise: number; - fillColor: THREE.Color; - strokeColor: THREE.Color; + fillColor: number; + strokeColor: number; patternFill: boolean; fillAlpha: number; strokeAlpha: number; @@ -203,6 +213,9 @@ declare class CanvasExtraState { maxX: number; minY: number; maxY: number; + lineCap: number; + lineJoin: number; + miterLimit: number; constructor(width: number, height: number); clone(): any; setCurrentPoint(x: number, y: number): void; diff --git a/index.html b/index.html index f59cfb2..ad0e5e9 100644 --- a/index.html +++ b/index.html @@ -1 +1 @@ -React App
\ No newline at end of file +React App
\ No newline at end of file diff --git a/static/js/main.7de1cc52.js b/static/js/main.7de1cc52.js deleted file mode 100644 index c96fa46..0000000 --- a/static/js/main.7de1cc52.js +++ /dev/null @@ -1,2 +0,0 @@ -!function(){var e={694:function(e,t){var n;!function(){"use strict";var r={}.hasOwnProperty;function i(){for(var e=[],t=0;t
attribute.\n *\n * @param to - The destination URL\n */\n createHref(to: To): string;\n\n /**\n * Returns a URL for the given `to` value\n *\n * @param to - The destination URL\n */\n createURL(to: To): URL;\n\n /**\n * Encode a location the same way window.history would do (no-op for memory\n * history) so we ensure our PUSH/REPLACE navigations for data routers\n * behave the same as POP\n *\n * @param to Unencoded path\n */\n encodeLocation(to: To): Path;\n\n /**\n * Pushes a new location onto the history stack, increasing its length by one.\n * If there were any entries in the stack after the current one, they are\n * lost.\n *\n * @param to - The new URL\n * @param state - Data to associate with the new location\n */\n push(to: To, state?: any): void;\n\n /**\n * Replaces the current location in the history stack with a new one. The\n * location that was replaced will no longer be available.\n *\n * @param to - The new URL\n * @param state - Data to associate with the new location\n */\n replace(to: To, state?: any): void;\n\n /**\n * Navigates `n` entries backward/forward in the history stack relative to the\n * current index. For example, a \"back\" navigation would use go(-1).\n *\n * @param delta - The delta in the stack index\n */\n go(delta: number): void;\n\n /**\n * Sets up a listener that will be called whenever the current location\n * changes.\n *\n * @param listener - A function that will be called when the location changes\n * @returns unlisten - A function that may be used to stop listening\n */\n listen(listener: Listener): () => void;\n}\n\ntype HistoryState = {\n usr: any;\n key?: string;\n idx: number;\n};\n\nconst PopStateEventType = \"popstate\";\n//#endregion\n\n////////////////////////////////////////////////////////////////////////////////\n//#region Memory History\n////////////////////////////////////////////////////////////////////////////////\n\n/**\n * A user-supplied object that describes a location. Used when providing\n * entries to `createMemoryHistory` via its `initialEntries` option.\n */\nexport type InitialEntry = string | Partial;\n\nexport type MemoryHistoryOptions = {\n initialEntries?: InitialEntry[];\n initialIndex?: number;\n v5Compat?: boolean;\n};\n\n/**\n * A memory history stores locations in memory. This is useful in stateful\n * environments where there is no web browser, such as node tests or React\n * Native.\n */\nexport interface MemoryHistory extends History {\n /**\n * The current index in the history stack.\n */\n readonly index: number;\n}\n\n/**\n * Memory history stores the current location in memory. It is designed for use\n * in stateful non-browser environments like tests and React Native.\n */\nexport function createMemoryHistory(\n options: MemoryHistoryOptions = {}\n): MemoryHistory {\n let { initialEntries = [\"/\"], initialIndex, v5Compat = false } = options;\n let entries: Location[]; // Declare so we can access from createMemoryLocation\n entries = initialEntries.map((entry, index) =>\n createMemoryLocation(\n entry,\n typeof entry === \"string\" ? null : entry.state,\n index === 0 ? \"default\" : undefined\n )\n );\n let index = clampIndex(\n initialIndex == null ? entries.length - 1 : initialIndex\n );\n let action = Action.Pop;\n let listener: Listener | null = null;\n\n function clampIndex(n: number): number {\n return Math.min(Math.max(n, 0), entries.length - 1);\n }\n function getCurrentLocation(): Location {\n return entries[index];\n }\n function createMemoryLocation(\n to: To,\n state: any = null,\n key?: string\n ): Location {\n let location = createLocation(\n entries ? getCurrentLocation().pathname : \"/\",\n to,\n state,\n key\n );\n warning(\n location.pathname.charAt(0) === \"/\",\n `relative pathnames are not supported in memory history: ${JSON.stringify(\n to\n )}`\n );\n return location;\n }\n\n function createHref(to: To) {\n return typeof to === \"string\" ? to : createPath(to);\n }\n\n let history: MemoryHistory = {\n get index() {\n return index;\n },\n get action() {\n return action;\n },\n get location() {\n return getCurrentLocation();\n },\n createHref,\n createURL(to) {\n return new URL(createHref(to), \"http://localhost\");\n },\n encodeLocation(to: To) {\n let path = typeof to === \"string\" ? parsePath(to) : to;\n return {\n pathname: path.pathname || \"\",\n search: path.search || \"\",\n hash: path.hash || \"\",\n };\n },\n push(to, state) {\n action = Action.Push;\n let nextLocation = createMemoryLocation(to, state);\n index += 1;\n entries.splice(index, entries.length, nextLocation);\n if (v5Compat && listener) {\n listener({ action, location: nextLocation, delta: 1 });\n }\n },\n replace(to, state) {\n action = Action.Replace;\n let nextLocation = createMemoryLocation(to, state);\n entries[index] = nextLocation;\n if (v5Compat && listener) {\n listener({ action, location: nextLocation, delta: 0 });\n }\n },\n go(delta) {\n action = Action.Pop;\n let nextIndex = clampIndex(index + delta);\n let nextLocation = entries[nextIndex];\n index = nextIndex;\n if (listener) {\n listener({ action, location: nextLocation, delta });\n }\n },\n listen(fn: Listener) {\n listener = fn;\n return () => {\n listener = null;\n };\n },\n };\n\n return history;\n}\n//#endregion\n\n////////////////////////////////////////////////////////////////////////////////\n//#region Browser History\n////////////////////////////////////////////////////////////////////////////////\n\n/**\n * A browser history stores the current location in regular URLs in a web\n * browser environment. This is the standard for most web apps and provides the\n * cleanest URLs the browser's address bar.\n *\n * @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#browserhistory\n */\nexport interface BrowserHistory extends UrlHistory {}\n\nexport type BrowserHistoryOptions = UrlHistoryOptions;\n\n/**\n * Browser history stores the location in regular URLs. This is the standard for\n * most web apps, but it requires some configuration on the server to ensure you\n * serve the same app at multiple URLs.\n *\n * @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#createbrowserhistory\n */\nexport function createBrowserHistory(\n options: BrowserHistoryOptions = {}\n): BrowserHistory {\n function createBrowserLocation(\n window: Window,\n globalHistory: Window[\"history\"]\n ) {\n let { pathname, search, hash } = window.location;\n return createLocation(\n \"\",\n { pathname, search, hash },\n // state defaults to `null` because `window.history.state` does\n (globalHistory.state && globalHistory.state.usr) || null,\n (globalHistory.state && globalHistory.state.key) || \"default\"\n );\n }\n\n function createBrowserHref(window: Window, to: To) {\n return typeof to === \"string\" ? to : createPath(to);\n }\n\n return getUrlBasedHistory(\n createBrowserLocation,\n createBrowserHref,\n null,\n options\n );\n}\n//#endregion\n\n////////////////////////////////////////////////////////////////////////////////\n//#region Hash History\n////////////////////////////////////////////////////////////////////////////////\n\n/**\n * A hash history stores the current location in the fragment identifier portion\n * of the URL in a web browser environment.\n *\n * This is ideal for apps that do not control the server for some reason\n * (because the fragment identifier is never sent to the server), including some\n * shared hosting environments that do not provide fine-grained controls over\n * which pages are served at which URLs.\n *\n * @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#hashhistory\n */\nexport interface HashHistory extends UrlHistory {}\n\nexport type HashHistoryOptions = UrlHistoryOptions;\n\n/**\n * Hash history stores the location in window.location.hash. This makes it ideal\n * for situations where you don't want to send the location to the server for\n * some reason, either because you do cannot configure it or the URL space is\n * reserved for something else.\n *\n * @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#createhashhistory\n */\nexport function createHashHistory(\n options: HashHistoryOptions = {}\n): HashHistory {\n function createHashLocation(\n window: Window,\n globalHistory: Window[\"history\"]\n ) {\n let {\n pathname = \"/\",\n search = \"\",\n hash = \"\",\n } = parsePath(window.location.hash.substr(1));\n return createLocation(\n \"\",\n { pathname, search, hash },\n // state defaults to `null` because `window.history.state` does\n (globalHistory.state && globalHistory.state.usr) || null,\n (globalHistory.state && globalHistory.state.key) || \"default\"\n );\n }\n\n function createHashHref(window: Window, to: To) {\n let base = window.document.querySelector(\"base\");\n let href = \"\";\n\n if (base && base.getAttribute(\"href\")) {\n let url = window.location.href;\n let hashIndex = url.indexOf(\"#\");\n href = hashIndex === -1 ? url : url.slice(0, hashIndex);\n }\n\n return href + \"#\" + (typeof to === \"string\" ? to : createPath(to));\n }\n\n function validateHashLocation(location: Location, to: To) {\n warning(\n location.pathname.charAt(0) === \"/\",\n `relative pathnames are not supported in hash history.push(${JSON.stringify(\n to\n )})`\n );\n }\n\n return getUrlBasedHistory(\n createHashLocation,\n createHashHref,\n validateHashLocation,\n options\n );\n}\n//#endregion\n\n////////////////////////////////////////////////////////////////////////////////\n//#region UTILS\n////////////////////////////////////////////////////////////////////////////////\n\n/**\n * @private\n */\nexport function invariant(value: boolean, message?: string): asserts value;\nexport function invariant(\n value: T | null | undefined,\n message?: string\n): asserts value is T;\nexport function invariant(value: any, message?: string) {\n if (value === false || value === null || typeof value === \"undefined\") {\n throw new Error(message);\n }\n}\n\nexport function warning(cond: any, message: string) {\n if (!cond) {\n // eslint-disable-next-line no-console\n if (typeof console !== \"undefined\") console.warn(message);\n\n try {\n // Welcome to debugging history!\n //\n // This error is thrown as a convenience so you can more easily\n // find the source for a warning that appears in the console by\n // enabling \"pause on exceptions\" in your JavaScript debugger.\n throw new Error(message);\n // eslint-disable-next-line no-empty\n } catch (e) {}\n }\n}\n\nfunction createKey() {\n return Math.random().toString(36).substr(2, 8);\n}\n\n/**\n * For browser-based histories, we combine the state and key into an object\n */\nfunction getHistoryState(location: Location, index: number): HistoryState {\n return {\n usr: location.state,\n key: location.key,\n idx: index,\n };\n}\n\n/**\n * Creates a Location object with a unique key from the given Path\n */\nexport function createLocation(\n current: string | Location,\n to: To,\n state: any = null,\n key?: string\n): Readonly {\n let location: Readonly = {\n pathname: typeof current === \"string\" ? current : current.pathname,\n search: \"\",\n hash: \"\",\n ...(typeof to === \"string\" ? parsePath(to) : to),\n state,\n // TODO: This could be cleaned up. push/replace should probably just take\n // full Locations now and avoid the need to run through this flow at all\n // But that's a pretty big refactor to the current test suite so going to\n // keep as is for the time being and just let any incoming keys take precedence\n key: (to && (to as Location).key) || key || createKey(),\n };\n return location;\n}\n\n/**\n * Creates a string URL path from the given pathname, search, and hash components.\n */\nexport function createPath({\n pathname = \"/\",\n search = \"\",\n hash = \"\",\n}: Partial) {\n if (search && search !== \"?\")\n pathname += search.charAt(0) === \"?\" ? search : \"?\" + search;\n if (hash && hash !== \"#\")\n pathname += hash.charAt(0) === \"#\" ? hash : \"#\" + hash;\n return pathname;\n}\n\n/**\n * Parses a string URL path into its separate pathname, search, and hash components.\n */\nexport function parsePath(path: string): Partial {\n let parsedPath: Partial = {};\n\n if (path) {\n let hashIndex = path.indexOf(\"#\");\n if (hashIndex >= 0) {\n parsedPath.hash = path.substr(hashIndex);\n path = path.substr(0, hashIndex);\n }\n\n let searchIndex = path.indexOf(\"?\");\n if (searchIndex >= 0) {\n parsedPath.search = path.substr(searchIndex);\n path = path.substr(0, searchIndex);\n }\n\n if (path) {\n parsedPath.pathname = path;\n }\n }\n\n return parsedPath;\n}\n\nexport interface UrlHistory extends History {}\n\nexport type UrlHistoryOptions = {\n window?: Window;\n v5Compat?: boolean;\n};\n\nfunction getUrlBasedHistory(\n getLocation: (window: Window, globalHistory: Window[\"history\"]) => Location,\n createHref: (window: Window, to: To) => string,\n validateLocation: ((location: Location, to: To) => void) | null,\n options: UrlHistoryOptions = {}\n): UrlHistory {\n let { window = document.defaultView!, v5Compat = false } = options;\n let globalHistory = window.history;\n let action = Action.Pop;\n let listener: Listener | null = null;\n\n let index = getIndex()!;\n // Index should only be null when we initialize. If not, it's because the\n // user called history.pushState or history.replaceState directly, in which\n // case we should log a warning as it will result in bugs.\n if (index == null) {\n index = 0;\n globalHistory.replaceState({ ...globalHistory.state, idx: index }, \"\");\n }\n\n function getIndex(): number {\n let state = globalHistory.state || { idx: null };\n return state.idx;\n }\n\n function handlePop() {\n action = Action.Pop;\n let nextIndex = getIndex();\n let delta = nextIndex == null ? null : nextIndex - index;\n index = nextIndex;\n if (listener) {\n listener({ action, location: history.location, delta });\n }\n }\n\n function push(to: To, state?: any) {\n action = Action.Push;\n let location = createLocation(history.location, to, state);\n if (validateLocation) validateLocation(location, to);\n\n index = getIndex() + 1;\n let historyState = getHistoryState(location, index);\n let url = history.createHref(location);\n\n // try...catch because iOS limits us to 100 pushState calls :/\n try {\n globalHistory.pushState(historyState, \"\", url);\n } catch (error) {\n // If the exception is because `state` can't be serialized, let that throw\n // outwards just like a replace call would so the dev knows the cause\n // https://html.spec.whatwg.org/multipage/nav-history-apis.html#shared-history-push/replace-state-steps\n // https://html.spec.whatwg.org/multipage/structured-data.html#structuredserializeinternal\n if (error instanceof DOMException && error.name === \"DataCloneError\") {\n throw error;\n }\n // They are going to lose state here, but there is no real\n // way to warn them about it since the page will refresh...\n window.location.assign(url);\n }\n\n if (v5Compat && listener) {\n listener({ action, location: history.location, delta: 1 });\n }\n }\n\n function replace(to: To, state?: any) {\n action = Action.Replace;\n let location = createLocation(history.location, to, state);\n if (validateLocation) validateLocation(location, to);\n\n index = getIndex();\n let historyState = getHistoryState(location, index);\n let url = history.createHref(location);\n globalHistory.replaceState(historyState, \"\", url);\n\n if (v5Compat && listener) {\n listener({ action, location: history.location, delta: 0 });\n }\n }\n\n function createURL(to: To): URL {\n // window.location.origin is \"null\" (the literal string value) in Firefox\n // under certain conditions, notably when serving from a local HTML file\n // See https://bugzilla.mozilla.org/show_bug.cgi?id=878297\n let base =\n window.location.origin !== \"null\"\n ? window.location.origin\n : window.location.href;\n\n let href = typeof to === \"string\" ? to : createPath(to);\n invariant(\n base,\n `No window.location.(origin|href) available to create URL for href: ${href}`\n );\n return new URL(href, base);\n }\n\n let history: History = {\n get action() {\n return action;\n },\n get location() {\n return getLocation(window, globalHistory);\n },\n listen(fn: Listener) {\n if (listener) {\n throw new Error(\"A history only accepts one active listener\");\n }\n window.addEventListener(PopStateEventType, handlePop);\n listener = fn;\n\n return () => {\n window.removeEventListener(PopStateEventType, handlePop);\n listener = null;\n };\n },\n createHref(to) {\n return createHref(window, to);\n },\n createURL,\n encodeLocation(to) {\n // Encode a Location the same way window.location would\n let url = createURL(to);\n return {\n pathname: url.pathname,\n search: url.search,\n hash: url.hash,\n };\n },\n push,\n replace,\n go(n) {\n return globalHistory.go(n);\n },\n };\n\n return history;\n}\n\n//#endregion\n","export default function _arrayWithHoles(arr) {\n if (Array.isArray(arr)) return arr;\n}","export default function _arrayLikeToArray(arr, len) {\n if (len == null || len > arr.length) len = arr.length;\n for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];\n return arr2;\n}","import arrayLikeToArray from \"./arrayLikeToArray.js\";\nexport default function _unsupportedIterableToArray(o, minLen) {\n if (!o) return;\n if (typeof o === \"string\") return arrayLikeToArray(o, minLen);\n var n = Object.prototype.toString.call(o).slice(8, -1);\n if (n === \"Object\" && o.constructor) n = o.constructor.name;\n if (n === \"Map\" || n === \"Set\") return Array.from(o);\n if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return arrayLikeToArray(o, minLen);\n}","export default function _nonIterableRest() {\n throw new TypeError(\"Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\");\n}","import arrayWithHoles from \"./arrayWithHoles.js\";\nimport iterableToArrayLimit from \"./iterableToArrayLimit.js\";\nimport unsupportedIterableToArray from \"./unsupportedIterableToArray.js\";\nimport nonIterableRest from \"./nonIterableRest.js\";\nexport default function _slicedToArray(arr, i) {\n return arrayWithHoles(arr) || iterableToArrayLimit(arr, i) || unsupportedIterableToArray(arr, i) || nonIterableRest();\n}","export default function _iterableToArrayLimit(arr, i) {\n var _i = null == arr ? null : \"undefined\" != typeof Symbol && arr[Symbol.iterator] || arr[\"@@iterator\"];\n if (null != _i) {\n var _s,\n _e,\n _x,\n _r,\n _arr = [],\n _n = !0,\n _d = !1;\n try {\n if (_x = (_i = _i.call(arr)).next, 0 === i) {\n if (Object(_i) !== _i) return;\n _n = !1;\n } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0);\n } catch (err) {\n _d = !0, _e = err;\n } finally {\n try {\n if (!_n && null != _i[\"return\"] && (_r = _i[\"return\"](), Object(_r) !== _r)) return;\n } finally {\n if (_d) throw _e;\n }\n }\n return _arr;\n }\n}","export default function _iterableToArray(iter) {\n if (typeof Symbol !== \"undefined\" && iter[Symbol.iterator] != null || iter[\"@@iterator\"] != null) return Array.from(iter);\n}","import arrayWithoutHoles from \"./arrayWithoutHoles.js\";\nimport iterableToArray from \"./iterableToArray.js\";\nimport unsupportedIterableToArray from \"./unsupportedIterableToArray.js\";\nimport nonIterableSpread from \"./nonIterableSpread.js\";\nexport default function _toConsumableArray(arr) {\n return arrayWithoutHoles(arr) || iterableToArray(arr) || unsupportedIterableToArray(arr) || nonIterableSpread();\n}","import arrayLikeToArray from \"./arrayLikeToArray.js\";\nexport default function _arrayWithoutHoles(arr) {\n if (Array.isArray(arr)) return arrayLikeToArray(arr);\n}","export default function _nonIterableSpread() {\n throw new TypeError(\"Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\");\n}","export default function _classCallCheck(instance, Constructor) {\n if (!(instance instanceof Constructor)) {\n throw new TypeError(\"Cannot call a class as a function\");\n }\n}","export default function _typeof(obj) {\n \"@babel/helpers - typeof\";\n\n return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (obj) {\n return typeof obj;\n } : function (obj) {\n return obj && \"function\" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj;\n }, _typeof(obj);\n}","import _typeof from \"./typeof.js\";\nimport toPrimitive from \"./toPrimitive.js\";\nexport default function _toPropertyKey(arg) {\n var key = toPrimitive(arg, \"string\");\n return _typeof(key) === \"symbol\" ? key : String(key);\n}","import _typeof from \"./typeof.js\";\nexport default function _toPrimitive(input, hint) {\n if (_typeof(input) !== \"object\" || input === null) return input;\n var prim = input[Symbol.toPrimitive];\n if (prim !== undefined) {\n var res = prim.call(input, hint || \"default\");\n if (_typeof(res) !== \"object\") return res;\n throw new TypeError(\"@@toPrimitive must return a primitive value.\");\n }\n return (hint === \"string\" ? String : Number)(input);\n}","import toPropertyKey from \"./toPropertyKey.js\";\nfunction _defineProperties(target, props) {\n for (var i = 0; i < props.length; i++) {\n var descriptor = props[i];\n descriptor.enumerable = descriptor.enumerable || false;\n descriptor.configurable = true;\n if (\"value\" in descriptor) descriptor.writable = true;\n Object.defineProperty(target, toPropertyKey(descriptor.key), descriptor);\n }\n}\nexport default function _createClass(Constructor, protoProps, staticProps) {\n if (protoProps) _defineProperties(Constructor.prototype, protoProps);\n if (staticProps) _defineProperties(Constructor, staticProps);\n Object.defineProperty(Constructor, \"prototype\", {\n writable: false\n });\n return Constructor;\n}","export default function _setPrototypeOf(o, p) {\n _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {\n o.__proto__ = p;\n return o;\n };\n return _setPrototypeOf(o, p);\n}","import setPrototypeOf from \"./setPrototypeOf.js\";\nexport default function _inherits(subClass, superClass) {\n if (typeof superClass !== \"function\" && superClass !== null) {\n throw new TypeError(\"Super expression must either be null or a function\");\n }\n subClass.prototype = Object.create(superClass && superClass.prototype, {\n constructor: {\n value: subClass,\n writable: true,\n configurable: true\n }\n });\n Object.defineProperty(subClass, \"prototype\", {\n writable: false\n });\n if (superClass) setPrototypeOf(subClass, superClass);\n}","export default function _getPrototypeOf(o) {\n _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {\n return o.__proto__ || Object.getPrototypeOf(o);\n };\n return _getPrototypeOf(o);\n}","export default function _isNativeReflectConstruct() {\n if (typeof Reflect === \"undefined\" || !Reflect.construct) return false;\n if (Reflect.construct.sham) return false;\n if (typeof Proxy === \"function\") return true;\n try {\n Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));\n return true;\n } catch (e) {\n return false;\n }\n}","export default function _assertThisInitialized(self) {\n if (self === void 0) {\n throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\");\n }\n return self;\n}","import getPrototypeOf from \"./getPrototypeOf.js\";\nimport isNativeReflectConstruct from \"./isNativeReflectConstruct.js\";\nimport possibleConstructorReturn from \"./possibleConstructorReturn.js\";\nexport default function _createSuper(Derived) {\n var hasNativeReflectConstruct = isNativeReflectConstruct();\n return function _createSuperInternal() {\n var Super = getPrototypeOf(Derived),\n result;\n if (hasNativeReflectConstruct) {\n var NewTarget = getPrototypeOf(this).constructor;\n result = Reflect.construct(Super, arguments, NewTarget);\n } else {\n result = Super.apply(this, arguments);\n }\n return possibleConstructorReturn(this, result);\n };\n}","import _typeof from \"./typeof.js\";\nimport assertThisInitialized from \"./assertThisInitialized.js\";\nexport default function _possibleConstructorReturn(self, call) {\n if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) {\n return call;\n } else if (call !== void 0) {\n throw new TypeError(\"Derived constructors may only return object or undefined\");\n }\n return assertThisInitialized(self);\n}","import setPrototypeOf from \"./setPrototypeOf.js\";\nimport isNativeReflectConstruct from \"./isNativeReflectConstruct.js\";\nexport default function _construct(Parent, args, Class) {\n if (isNativeReflectConstruct()) {\n _construct = Reflect.construct.bind();\n } else {\n _construct = function _construct(Parent, args, Class) {\n var a = [null];\n a.push.apply(a, args);\n var Constructor = Function.bind.apply(Parent, a);\n var instance = new Constructor();\n if (Class) setPrototypeOf(instance, Class.prototype);\n return instance;\n };\n }\n return _construct.apply(null, arguments);\n}","import getPrototypeOf from \"./getPrototypeOf.js\";\nimport setPrototypeOf from \"./setPrototypeOf.js\";\nimport isNativeFunction from \"./isNativeFunction.js\";\nimport construct from \"./construct.js\";\nexport default function _wrapNativeSuper(Class) {\n var _cache = typeof Map === \"function\" ? new Map() : undefined;\n _wrapNativeSuper = function _wrapNativeSuper(Class) {\n if (Class === null || !isNativeFunction(Class)) return Class;\n if (typeof Class !== \"function\") {\n throw new TypeError(\"Super expression must either be null or a function\");\n }\n if (typeof _cache !== \"undefined\") {\n if (_cache.has(Class)) return _cache.get(Class);\n _cache.set(Class, Wrapper);\n }\n function Wrapper() {\n return construct(Class, arguments, getPrototypeOf(this).constructor);\n }\n Wrapper.prototype = Object.create(Class.prototype, {\n constructor: {\n value: Wrapper,\n enumerable: false,\n writable: true,\n configurable: true\n }\n });\n return setPrototypeOf(Wrapper, Class);\n };\n return _wrapNativeSuper(Class);\n}","export default function _isNativeFunction(fn) {\n return Function.toString.call(fn).indexOf(\"[native code]\") !== -1;\n}","import arrayWithHoles from \"./arrayWithHoles.js\";\nimport iterableToArray from \"./iterableToArray.js\";\nimport unsupportedIterableToArray from \"./unsupportedIterableToArray.js\";\nimport nonIterableRest from \"./nonIterableRest.js\";\nexport default function _toArray(arr) {\n return arrayWithHoles(arr) || iterableToArray(arr) || unsupportedIterableToArray(arr) || nonIterableRest();\n}","import unsupportedIterableToArray from \"./unsupportedIterableToArray.js\";\nexport default function _createForOfIteratorHelper(o, allowArrayLike) {\n var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"];\n if (!it) {\n if (Array.isArray(o) || (it = unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") {\n if (it) o = it;\n var i = 0;\n var F = function F() {};\n return {\n s: F,\n n: function n() {\n if (i >= o.length) return {\n done: true\n };\n return {\n done: false,\n value: o[i++]\n };\n },\n e: function e(_e) {\n throw _e;\n },\n f: F\n };\n }\n throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\");\n }\n var normalCompletion = true,\n didErr = false,\n err;\n return {\n s: function s() {\n it = it.call(o);\n },\n n: function n() {\n var step = it.next();\n normalCompletion = step.done;\n return step;\n },\n e: function e(_e2) {\n didErr = true;\n err = _e2;\n },\n f: function f() {\n try {\n if (!normalCompletion && it[\"return\"] != null) it[\"return\"]();\n } finally {\n if (didErr) throw err;\n }\n }\n };\n}","import type { Location, Path, To } from \"./history\";\nimport { warning, invariant, parsePath } from \"./history\";\n\n/**\n * Map of routeId -> data returned from a loader/action/error\n */\nexport interface RouteData {\n [routeId: string]: any;\n}\n\nexport enum ResultType {\n data = \"data\",\n deferred = \"deferred\",\n redirect = \"redirect\",\n error = \"error\",\n}\n\n/**\n * Successful result from a loader or action\n */\nexport interface SuccessResult {\n type: ResultType.data;\n data: any;\n statusCode?: number;\n headers?: Headers;\n}\n\n/**\n * Successful defer() result from a loader or action\n */\nexport interface DeferredResult {\n type: ResultType.deferred;\n deferredData: DeferredData;\n statusCode?: number;\n headers?: Headers;\n}\n\n/**\n * Redirect result from a loader or action\n */\nexport interface RedirectResult {\n type: ResultType.redirect;\n status: number;\n location: string;\n revalidate: boolean;\n}\n\n/**\n * Unsuccessful result from a loader or action\n */\nexport interface ErrorResult {\n type: ResultType.error;\n error: any;\n headers?: Headers;\n}\n\n/**\n * Result from a loader or action - potentially successful or unsuccessful\n */\nexport type DataResult =\n | SuccessResult\n | DeferredResult\n | RedirectResult\n | ErrorResult;\n\ntype LowerCaseFormMethod = \"get\" | \"post\" | \"put\" | \"patch\" | \"delete\";\ntype UpperCaseFormMethod = Uppercase;\n\n/**\n * Users can specify either lowercase or uppercase form methods on
,\n * useSubmit(), , etc.\n */\nexport type HTMLFormMethod = LowerCaseFormMethod | UpperCaseFormMethod;\n\n/**\n * Active navigation/fetcher form methods are exposed in lowercase on the\n * RouterState\n */\nexport type FormMethod = LowerCaseFormMethod;\nexport type MutationFormMethod = Exclude;\n\n/**\n * In v7, active navigation/fetcher form methods are exposed in uppercase on the\n * RouterState. This is to align with the normalization done via fetch().\n */\nexport type V7_FormMethod = UpperCaseFormMethod;\nexport type V7_MutationFormMethod = Exclude;\n\nexport type FormEncType =\n | \"application/x-www-form-urlencoded\"\n | \"multipart/form-data\"\n | \"application/json\"\n | \"text/plain\";\n\n// Thanks https://github.com/sindresorhus/type-fest!\ntype JsonObject = { [Key in string]: JsonValue } & {\n [Key in string]?: JsonValue | undefined;\n};\ntype JsonArray = JsonValue[] | readonly JsonValue[];\ntype JsonPrimitive = string | number | boolean | null;\ntype JsonValue = JsonPrimitive | JsonObject | JsonArray;\n\n/**\n * @private\n * Internal interface to pass around for action submissions, not intended for\n * external consumption\n */\nexport type Submission =\n | {\n formMethod: FormMethod | V7_FormMethod;\n formAction: string;\n formEncType: FormEncType;\n formData: FormData;\n json: undefined;\n text: undefined;\n }\n | {\n formMethod: FormMethod | V7_FormMethod;\n formAction: string;\n formEncType: FormEncType;\n formData: undefined;\n json: JsonValue;\n text: undefined;\n }\n | {\n formMethod: FormMethod | V7_FormMethod;\n formAction: string;\n formEncType: FormEncType;\n formData: undefined;\n json: undefined;\n text: string;\n };\n\n/**\n * @private\n * Arguments passed to route loader/action functions. Same for now but we keep\n * this as a private implementation detail in case they diverge in the future.\n */\ninterface DataFunctionArgs {\n request: Request;\n params: Params;\n context?: any;\n}\n\n/**\n * Arguments passed to loader functions\n */\nexport interface LoaderFunctionArgs extends DataFunctionArgs {}\n\n/**\n * Arguments passed to action functions\n */\nexport interface ActionFunctionArgs extends DataFunctionArgs {}\n\n/**\n * Loaders and actions can return anything except `undefined` (`null` is a\n * valid return value if there is no data to return). Responses are preferred\n * and will ease any future migration to Remix\n */\ntype DataFunctionValue = Response | NonNullable | null;\n\n/**\n * Route loader function signature\n */\nexport interface LoaderFunction {\n (args: LoaderFunctionArgs): Promise | DataFunctionValue;\n}\n\n/**\n * Route action function signature\n */\nexport interface ActionFunction {\n (args: ActionFunctionArgs): Promise | DataFunctionValue;\n}\n\n/**\n * Route shouldRevalidate function signature. This runs after any submission\n * (navigation or fetcher), so we flatten the navigation/fetcher submission\n * onto the arguments. It shouldn't matter whether it came from a navigation\n * or a fetcher, what really matters is the URLs and the formData since loaders\n * have to re-run based on the data models that were potentially mutated.\n */\nexport interface ShouldRevalidateFunction {\n (args: {\n currentUrl: URL;\n currentParams: AgnosticDataRouteMatch[\"params\"];\n nextUrl: URL;\n nextParams: AgnosticDataRouteMatch[\"params\"];\n formMethod?: Submission[\"formMethod\"];\n formAction?: Submission[\"formAction\"];\n formEncType?: Submission[\"formEncType\"];\n text?: Submission[\"text\"];\n formData?: Submission[\"formData\"];\n json?: Submission[\"json\"];\n actionResult?: DataResult;\n defaultShouldRevalidate: boolean;\n }): boolean;\n}\n\n/**\n * Function provided by the framework-aware layers to set `hasErrorBoundary`\n * from the framework-aware `errorElement` prop\n *\n * @deprecated Use `mapRouteProperties` instead\n */\nexport interface DetectErrorBoundaryFunction {\n (route: AgnosticRouteObject): boolean;\n}\n\n/**\n * Function provided by the framework-aware layers to set any framework-specific\n * properties from framework-agnostic properties\n */\nexport interface MapRoutePropertiesFunction {\n (route: AgnosticRouteObject): {\n hasErrorBoundary: boolean;\n } & Record;\n}\n\n/**\n * Keys we cannot change from within a lazy() function. We spread all other keys\n * onto the route. Either they're meaningful to the router, or they'll get\n * ignored.\n */\nexport type ImmutableRouteKey =\n | \"lazy\"\n | \"caseSensitive\"\n | \"path\"\n | \"id\"\n | \"index\"\n | \"children\";\n\nexport const immutableRouteKeys = new Set([\n \"lazy\",\n \"caseSensitive\",\n \"path\",\n \"id\",\n \"index\",\n \"children\",\n]);\n\ntype RequireOne = Exclude<\n {\n [K in keyof T]: K extends Key ? Omit & Required> : never;\n }[keyof T],\n undefined\n>;\n\n/**\n * lazy() function to load a route definition, which can add non-matching\n * related properties to a route\n */\nexport interface LazyRouteFunction {\n (): Promise>>;\n}\n\n/**\n * Base RouteObject with common props shared by all types of routes\n */\ntype AgnosticBaseRouteObject = {\n caseSensitive?: boolean;\n path?: string;\n id?: string;\n loader?: LoaderFunction;\n action?: ActionFunction;\n hasErrorBoundary?: boolean;\n shouldRevalidate?: ShouldRevalidateFunction;\n handle?: any;\n lazy?: LazyRouteFunction;\n};\n\n/**\n * Index routes must not have children\n */\nexport type AgnosticIndexRouteObject = AgnosticBaseRouteObject & {\n children?: undefined;\n index: true;\n};\n\n/**\n * Non-index routes may have children, but cannot have index\n */\nexport type AgnosticNonIndexRouteObject = AgnosticBaseRouteObject & {\n children?: AgnosticRouteObject[];\n index?: false;\n};\n\n/**\n * A route object represents a logical route, with (optionally) its child\n * routes organized in a tree-like structure.\n */\nexport type AgnosticRouteObject =\n | AgnosticIndexRouteObject\n | AgnosticNonIndexRouteObject;\n\nexport type AgnosticDataIndexRouteObject = AgnosticIndexRouteObject & {\n id: string;\n};\n\nexport type AgnosticDataNonIndexRouteObject = AgnosticNonIndexRouteObject & {\n children?: AgnosticDataRouteObject[];\n id: string;\n};\n\n/**\n * A data route object, which is just a RouteObject with a required unique ID\n */\nexport type AgnosticDataRouteObject =\n | AgnosticDataIndexRouteObject\n | AgnosticDataNonIndexRouteObject;\n\nexport type RouteManifest = Record;\n\n// Recursive helper for finding path parameters in the absence of wildcards\ntype _PathParam =\n // split path into individual path segments\n Path extends `${infer L}/${infer R}`\n ? _PathParam | _PathParam\n : // find params after `:`\n Path extends `:${infer Param}`\n ? Param extends `${infer Optional}?`\n ? Optional\n : Param\n : // otherwise, there aren't any params present\n never;\n\n/**\n * Examples:\n * \"/a/b/*\" -> \"*\"\n * \":a\" -> \"a\"\n * \"/a/:b\" -> \"b\"\n * \"/a/blahblahblah:b\" -> \"b\"\n * \"/:a/:b\" -> \"a\" | \"b\"\n * \"/:a/b/:c/*\" -> \"a\" | \"c\" | \"*\"\n */\ntype PathParam =\n // check if path is just a wildcard\n Path extends \"*\" | \"/*\"\n ? \"*\"\n : // look for wildcard at the end of the path\n Path extends `${infer Rest}/*`\n ? \"*\" | _PathParam\n : // look for params in the absence of wildcards\n _PathParam;\n\n// Attempt to parse the given string segment. If it fails, then just return the\n// plain string type as a default fallback. Otherwise return the union of the\n// parsed string literals that were referenced as dynamic segments in the route.\nexport type ParamParseKey =\n // if could not find path params, fallback to `string`\n [PathParam] extends [never] ? string : PathParam;\n\n/**\n * The parameters that were parsed from the URL path.\n */\nexport type Params = {\n readonly [key in Key]: string | undefined;\n};\n\n/**\n * A RouteMatch contains info about how a route matched a URL.\n */\nexport interface AgnosticRouteMatch<\n ParamKey extends string = string,\n RouteObjectType extends AgnosticRouteObject = AgnosticRouteObject\n> {\n /**\n * The names and values of dynamic parameters in the URL.\n */\n params: Params;\n /**\n * The portion of the URL pathname that was matched.\n */\n pathname: string;\n /**\n * The portion of the URL pathname that was matched before child routes.\n */\n pathnameBase: string;\n /**\n * The route object that was used to match.\n */\n route: RouteObjectType;\n}\n\nexport interface AgnosticDataRouteMatch\n extends AgnosticRouteMatch {}\n\nfunction isIndexRoute(\n route: AgnosticRouteObject\n): route is AgnosticIndexRouteObject {\n return route.index === true;\n}\n\n// Walk the route tree generating unique IDs where necessary so we are working\n// solely with AgnosticDataRouteObject's within the Router\nexport function convertRoutesToDataRoutes(\n routes: AgnosticRouteObject[],\n mapRouteProperties: MapRoutePropertiesFunction,\n parentPath: number[] = [],\n manifest: RouteManifest = {}\n): AgnosticDataRouteObject[] {\n return routes.map((route, index) => {\n let treePath = [...parentPath, index];\n let id = typeof route.id === \"string\" ? route.id : treePath.join(\"-\");\n invariant(\n route.index !== true || !route.children,\n `Cannot specify children on an index route`\n );\n invariant(\n !manifest[id],\n `Found a route id collision on id \"${id}\". Route ` +\n \"id's must be globally unique within Data Router usages\"\n );\n\n if (isIndexRoute(route)) {\n let indexRoute: AgnosticDataIndexRouteObject = {\n ...route,\n ...mapRouteProperties(route),\n id,\n };\n manifest[id] = indexRoute;\n return indexRoute;\n } else {\n let pathOrLayoutRoute: AgnosticDataNonIndexRouteObject = {\n ...route,\n ...mapRouteProperties(route),\n id,\n children: undefined,\n };\n manifest[id] = pathOrLayoutRoute;\n\n if (route.children) {\n pathOrLayoutRoute.children = convertRoutesToDataRoutes(\n route.children,\n mapRouteProperties,\n treePath,\n manifest\n );\n }\n\n return pathOrLayoutRoute;\n }\n });\n}\n\n/**\n * Matches the given routes to a location and returns the match data.\n *\n * @see https://reactrouter.com/utils/match-routes\n */\nexport function matchRoutes<\n RouteObjectType extends AgnosticRouteObject = AgnosticRouteObject\n>(\n routes: RouteObjectType[],\n locationArg: Partial | string,\n basename = \"/\"\n): AgnosticRouteMatch[] | null {\n let location =\n typeof locationArg === \"string\" ? parsePath(locationArg) : locationArg;\n\n let pathname = stripBasename(location.pathname || \"/\", basename);\n\n if (pathname == null) {\n return null;\n }\n\n let branches = flattenRoutes(routes);\n rankRouteBranches(branches);\n\n let matches = null;\n for (let i = 0; matches == null && i < branches.length; ++i) {\n matches = matchRouteBranch(\n branches[i],\n // Incoming pathnames are generally encoded from either window.location\n // or from router.navigate, but we want to match against the unencoded\n // paths in the route definitions. Memory router locations won't be\n // encoded here but there also shouldn't be anything to decode so this\n // should be a safe operation. This avoids needing matchRoutes to be\n // history-aware.\n safelyDecodeURI(pathname)\n );\n }\n\n return matches;\n}\n\ninterface RouteMeta<\n RouteObjectType extends AgnosticRouteObject = AgnosticRouteObject\n> {\n relativePath: string;\n caseSensitive: boolean;\n childrenIndex: number;\n route: RouteObjectType;\n}\n\ninterface RouteBranch<\n RouteObjectType extends AgnosticRouteObject = AgnosticRouteObject\n> {\n path: string;\n score: number;\n routesMeta: RouteMeta[];\n}\n\nfunction flattenRoutes<\n RouteObjectType extends AgnosticRouteObject = AgnosticRouteObject\n>(\n routes: RouteObjectType[],\n branches: RouteBranch[] = [],\n parentsMeta: RouteMeta[] = [],\n parentPath = \"\"\n): RouteBranch[] {\n let flattenRoute = (\n route: RouteObjectType,\n index: number,\n relativePath?: string\n ) => {\n let meta: RouteMeta = {\n relativePath:\n relativePath === undefined ? route.path || \"\" : relativePath,\n caseSensitive: route.caseSensitive === true,\n childrenIndex: index,\n route,\n };\n\n if (meta.relativePath.startsWith(\"/\")) {\n invariant(\n meta.relativePath.startsWith(parentPath),\n `Absolute route path \"${meta.relativePath}\" nested under path ` +\n `\"${parentPath}\" is not valid. An absolute child route path ` +\n `must start with the combined path of all its parent routes.`\n );\n\n meta.relativePath = meta.relativePath.slice(parentPath.length);\n }\n\n let path = joinPaths([parentPath, meta.relativePath]);\n let routesMeta = parentsMeta.concat(meta);\n\n // Add the children before adding this route to the array so we traverse the\n // route tree depth-first and child routes appear before their parents in\n // the \"flattened\" version.\n if (route.children && route.children.length > 0) {\n invariant(\n // Our types know better, but runtime JS may not!\n // @ts-expect-error\n route.index !== true,\n `Index routes must not have child routes. Please remove ` +\n `all child routes from route path \"${path}\".`\n );\n\n flattenRoutes(route.children, branches, routesMeta, path);\n }\n\n // Routes without a path shouldn't ever match by themselves unless they are\n // index routes, so don't add them to the list of possible branches.\n if (route.path == null && !route.index) {\n return;\n }\n\n branches.push({\n path,\n score: computeScore(path, route.index),\n routesMeta,\n });\n };\n routes.forEach((route, index) => {\n // coarse-grain check for optional params\n if (route.path === \"\" || !route.path?.includes(\"?\")) {\n flattenRoute(route, index);\n } else {\n for (let exploded of explodeOptionalSegments(route.path)) {\n flattenRoute(route, index, exploded);\n }\n }\n });\n\n return branches;\n}\n\n/**\n * Computes all combinations of optional path segments for a given path,\n * excluding combinations that are ambiguous and of lower priority.\n *\n * For example, `/one/:two?/three/:four?/:five?` explodes to:\n * - `/one/three`\n * - `/one/:two/three`\n * - `/one/three/:four`\n * - `/one/three/:five`\n * - `/one/:two/three/:four`\n * - `/one/:two/three/:five`\n * - `/one/three/:four/:five`\n * - `/one/:two/three/:four/:five`\n */\nfunction explodeOptionalSegments(path: string): string[] {\n let segments = path.split(\"/\");\n if (segments.length === 0) return [];\n\n let [first, ...rest] = segments;\n\n // Optional path segments are denoted by a trailing `?`\n let isOptional = first.endsWith(\"?\");\n // Compute the corresponding required segment: `foo?` -> `foo`\n let required = first.replace(/\\?$/, \"\");\n\n if (rest.length === 0) {\n // Intepret empty string as omitting an optional segment\n // `[\"one\", \"\", \"three\"]` corresponds to omitting `:two` from `/one/:two?/three` -> `/one/three`\n return isOptional ? [required, \"\"] : [required];\n }\n\n let restExploded = explodeOptionalSegments(rest.join(\"/\"));\n\n let result: string[] = [];\n\n // All child paths with the prefix. Do this for all children before the\n // optional version for all children so we get consistent ordering where the\n // parent optional aspect is preferred as required. Otherwise, we can get\n // child sections interspersed where deeper optional segments are higher than\n // parent optional segments, where for example, /:two would explodes _earlier_\n // then /:one. By always including the parent as required _for all children_\n // first, we avoid this issue\n result.push(\n ...restExploded.map((subpath) =>\n subpath === \"\" ? required : [required, subpath].join(\"/\")\n )\n );\n\n // Then if this is an optional value, add all child versions without\n if (isOptional) {\n result.push(...restExploded);\n }\n\n // for absolute paths, ensure `/` instead of empty segment\n return result.map((exploded) =>\n path.startsWith(\"/\") && exploded === \"\" ? \"/\" : exploded\n );\n}\n\nfunction rankRouteBranches(branches: RouteBranch[]): void {\n branches.sort((a, b) =>\n a.score !== b.score\n ? b.score - a.score // Higher score first\n : compareIndexes(\n a.routesMeta.map((meta) => meta.childrenIndex),\n b.routesMeta.map((meta) => meta.childrenIndex)\n )\n );\n}\n\nconst paramRe = /^:\\w+$/;\nconst dynamicSegmentValue = 3;\nconst indexRouteValue = 2;\nconst emptySegmentValue = 1;\nconst staticSegmentValue = 10;\nconst splatPenalty = -2;\nconst isSplat = (s: string) => s === \"*\";\n\nfunction computeScore(path: string, index: boolean | undefined): number {\n let segments = path.split(\"/\");\n let initialScore = segments.length;\n if (segments.some(isSplat)) {\n initialScore += splatPenalty;\n }\n\n if (index) {\n initialScore += indexRouteValue;\n }\n\n return segments\n .filter((s) => !isSplat(s))\n .reduce(\n (score, segment) =>\n score +\n (paramRe.test(segment)\n ? dynamicSegmentValue\n : segment === \"\"\n ? emptySegmentValue\n : staticSegmentValue),\n initialScore\n );\n}\n\nfunction compareIndexes(a: number[], b: number[]): number {\n let siblings =\n a.length === b.length && a.slice(0, -1).every((n, i) => n === b[i]);\n\n return siblings\n ? // If two routes are siblings, we should try to match the earlier sibling\n // first. This allows people to have fine-grained control over the matching\n // behavior by simply putting routes with identical paths in the order they\n // want them tried.\n a[a.length - 1] - b[b.length - 1]\n : // Otherwise, it doesn't really make sense to rank non-siblings by index,\n // so they sort equally.\n 0;\n}\n\nfunction matchRouteBranch<\n ParamKey extends string = string,\n RouteObjectType extends AgnosticRouteObject = AgnosticRouteObject\n>(\n branch: RouteBranch,\n pathname: string\n): AgnosticRouteMatch[] | null {\n let { routesMeta } = branch;\n\n let matchedParams = {};\n let matchedPathname = \"/\";\n let matches: AgnosticRouteMatch[] = [];\n for (let i = 0; i < routesMeta.length; ++i) {\n let meta = routesMeta[i];\n let end = i === routesMeta.length - 1;\n let remainingPathname =\n matchedPathname === \"/\"\n ? pathname\n : pathname.slice(matchedPathname.length) || \"/\";\n let match = matchPath(\n { path: meta.relativePath, caseSensitive: meta.caseSensitive, end },\n remainingPathname\n );\n\n if (!match) return null;\n\n Object.assign(matchedParams, match.params);\n\n let route = meta.route;\n\n matches.push({\n // TODO: Can this as be avoided?\n params: matchedParams as Params,\n pathname: joinPaths([matchedPathname, match.pathname]),\n pathnameBase: normalizePathname(\n joinPaths([matchedPathname, match.pathnameBase])\n ),\n route,\n });\n\n if (match.pathnameBase !== \"/\") {\n matchedPathname = joinPaths([matchedPathname, match.pathnameBase]);\n }\n }\n\n return matches;\n}\n\n/**\n * Returns a path with params interpolated.\n *\n * @see https://reactrouter.com/utils/generate-path\n */\nexport function generatePath(\n originalPath: Path,\n params: {\n [key in PathParam]: string | null;\n } = {} as any\n): string {\n let path: string = originalPath;\n if (path.endsWith(\"*\") && path !== \"*\" && !path.endsWith(\"/*\")) {\n warning(\n false,\n `Route path \"${path}\" will be treated as if it were ` +\n `\"${path.replace(/\\*$/, \"/*\")}\" because the \\`*\\` character must ` +\n `always follow a \\`/\\` in the pattern. To get rid of this warning, ` +\n `please change the route path to \"${path.replace(/\\*$/, \"/*\")}\".`\n );\n path = path.replace(/\\*$/, \"/*\") as Path;\n }\n\n // ensure `/` is added at the beginning if the path is absolute\n const prefix = path.startsWith(\"/\") ? \"/\" : \"\";\n\n const stringify = (p: any) =>\n p == null ? \"\" : typeof p === \"string\" ? p : String(p);\n\n const segments = path\n .split(/\\/+/)\n .map((segment, index, array) => {\n const isLastSegment = index === array.length - 1;\n\n // only apply the splat if it's the last segment\n if (isLastSegment && segment === \"*\") {\n const star = \"*\" as PathParam;\n // Apply the splat\n return stringify(params[star]);\n }\n\n const keyMatch = segment.match(/^:(\\w+)(\\??)$/);\n if (keyMatch) {\n const [, key, optional] = keyMatch;\n let param = params[key as PathParam];\n invariant(optional === \"?\" || param != null, `Missing \":${key}\" param`);\n return stringify(param);\n }\n\n // Remove any optional markers from optional static segments\n return segment.replace(/\\?$/g, \"\");\n })\n // Remove empty segments\n .filter((segment) => !!segment);\n\n return prefix + segments.join(\"/\");\n}\n\n/**\n * A PathPattern is used to match on some portion of a URL pathname.\n */\nexport interface PathPattern {\n /**\n * A string to match against a URL pathname. May contain `:id`-style segments\n * to indicate placeholders for dynamic parameters. May also end with `/*` to\n * indicate matching the rest of the URL pathname.\n */\n path: Path;\n /**\n * Should be `true` if the static portions of the `path` should be matched in\n * the same case.\n */\n caseSensitive?: boolean;\n /**\n * Should be `true` if this pattern should match the entire URL pathname.\n */\n end?: boolean;\n}\n\n/**\n * A PathMatch contains info about how a PathPattern matched on a URL pathname.\n */\nexport interface PathMatch {\n /**\n * The names and values of dynamic parameters in the URL.\n */\n params: Params;\n /**\n * The portion of the URL pathname that was matched.\n */\n pathname: string;\n /**\n * The portion of the URL pathname that was matched before child routes.\n */\n pathnameBase: string;\n /**\n * The pattern that was used to match.\n */\n pattern: PathPattern;\n}\n\ntype Mutable = {\n -readonly [P in keyof T]: T[P];\n};\n\n/**\n * Performs pattern matching on a URL pathname and returns information about\n * the match.\n *\n * @see https://reactrouter.com/utils/match-path\n */\nexport function matchPath<\n ParamKey extends ParamParseKey,\n Path extends string\n>(\n pattern: PathPattern | Path,\n pathname: string\n): PathMatch | null {\n if (typeof pattern === \"string\") {\n pattern = { path: pattern, caseSensitive: false, end: true };\n }\n\n let [matcher, paramNames] = compilePath(\n pattern.path,\n pattern.caseSensitive,\n pattern.end\n );\n\n let match = pathname.match(matcher);\n if (!match) return null;\n\n let matchedPathname = match[0];\n let pathnameBase = matchedPathname.replace(/(.)\\/+$/, \"$1\");\n let captureGroups = match.slice(1);\n let params: Params = paramNames.reduce>(\n (memo, paramName, index) => {\n // We need to compute the pathnameBase here using the raw splat value\n // instead of using params[\"*\"] later because it will be decoded then\n if (paramName === \"*\") {\n let splatValue = captureGroups[index] || \"\";\n pathnameBase = matchedPathname\n .slice(0, matchedPathname.length - splatValue.length)\n .replace(/(.)\\/+$/, \"$1\");\n }\n\n memo[paramName] = safelyDecodeURIComponent(\n captureGroups[index] || \"\",\n paramName\n );\n return memo;\n },\n {}\n );\n\n return {\n params,\n pathname: matchedPathname,\n pathnameBase,\n pattern,\n };\n}\n\nfunction compilePath(\n path: string,\n caseSensitive = false,\n end = true\n): [RegExp, string[]] {\n warning(\n path === \"*\" || !path.endsWith(\"*\") || path.endsWith(\"/*\"),\n `Route path \"${path}\" will be treated as if it were ` +\n `\"${path.replace(/\\*$/, \"/*\")}\" because the \\`*\\` character must ` +\n `always follow a \\`/\\` in the pattern. To get rid of this warning, ` +\n `please change the route path to \"${path.replace(/\\*$/, \"/*\")}\".`\n );\n\n let paramNames: string[] = [];\n let regexpSource =\n \"^\" +\n path\n .replace(/\\/*\\*?$/, \"\") // Ignore trailing / and /*, we'll handle it below\n .replace(/^\\/*/, \"/\") // Make sure it has a leading /\n .replace(/[\\\\.*+^$?{}|()[\\]]/g, \"\\\\$&\") // Escape special regex chars\n .replace(/\\/:(\\w+)/g, (_: string, paramName: string) => {\n paramNames.push(paramName);\n return \"/([^\\\\/]+)\";\n });\n\n if (path.endsWith(\"*\")) {\n paramNames.push(\"*\");\n regexpSource +=\n path === \"*\" || path === \"/*\"\n ? \"(.*)$\" // Already matched the initial /, just match the rest\n : \"(?:\\\\/(.+)|\\\\/*)$\"; // Don't include the / in params[\"*\"]\n } else if (end) {\n // When matching to the end, ignore trailing slashes\n regexpSource += \"\\\\/*$\";\n } else if (path !== \"\" && path !== \"/\") {\n // If our path is non-empty and contains anything beyond an initial slash,\n // then we have _some_ form of path in our regex so we should expect to\n // match only if we find the end of this path segment. Look for an optional\n // non-captured trailing slash (to match a portion of the URL) or the end\n // of the path (if we've matched to the end). We used to do this with a\n // word boundary but that gives false positives on routes like\n // /user-preferences since `-` counts as a word boundary.\n regexpSource += \"(?:(?=\\\\/|$))\";\n } else {\n // Nothing to match for \"\" or \"/\"\n }\n\n let matcher = new RegExp(regexpSource, caseSensitive ? undefined : \"i\");\n\n return [matcher, paramNames];\n}\n\nfunction safelyDecodeURI(value: string) {\n try {\n return decodeURI(value);\n } catch (error) {\n warning(\n false,\n `The URL path \"${value}\" could not be decoded because it is is a ` +\n `malformed URL segment. This is probably due to a bad percent ` +\n `encoding (${error}).`\n );\n\n return value;\n }\n}\n\nfunction safelyDecodeURIComponent(value: string, paramName: string) {\n try {\n return decodeURIComponent(value);\n } catch (error) {\n warning(\n false,\n `The value for the URL param \"${paramName}\" will not be decoded because` +\n ` the string \"${value}\" is a malformed URL segment. This is probably` +\n ` due to a bad percent encoding (${error}).`\n );\n\n return value;\n }\n}\n\n/**\n * @private\n */\nexport function stripBasename(\n pathname: string,\n basename: string\n): string | null {\n if (basename === \"/\") return pathname;\n\n if (!pathname.toLowerCase().startsWith(basename.toLowerCase())) {\n return null;\n }\n\n // We want to leave trailing slash behavior in the user's control, so if they\n // specify a basename with a trailing slash, we should support it\n let startIndex = basename.endsWith(\"/\")\n ? basename.length - 1\n : basename.length;\n let nextChar = pathname.charAt(startIndex);\n if (nextChar && nextChar !== \"/\") {\n // pathname does not start with basename/\n return null;\n }\n\n return pathname.slice(startIndex) || \"/\";\n}\n\n/**\n * Returns a resolved path object relative to the given pathname.\n *\n * @see https://reactrouter.com/utils/resolve-path\n */\nexport function resolvePath(to: To, fromPathname = \"/\"): Path {\n let {\n pathname: toPathname,\n search = \"\",\n hash = \"\",\n } = typeof to === \"string\" ? parsePath(to) : to;\n\n let pathname = toPathname\n ? toPathname.startsWith(\"/\")\n ? toPathname\n : resolvePathname(toPathname, fromPathname)\n : fromPathname;\n\n return {\n pathname,\n search: normalizeSearch(search),\n hash: normalizeHash(hash),\n };\n}\n\nfunction resolvePathname(relativePath: string, fromPathname: string): string {\n let segments = fromPathname.replace(/\\/+$/, \"\").split(\"/\");\n let relativeSegments = relativePath.split(\"/\");\n\n relativeSegments.forEach((segment) => {\n if (segment === \"..\") {\n // Keep the root \"\" segment so the pathname starts at /\n if (segments.length > 1) segments.pop();\n } else if (segment !== \".\") {\n segments.push(segment);\n }\n });\n\n return segments.length > 1 ? segments.join(\"/\") : \"/\";\n}\n\nfunction getInvalidPathError(\n char: string,\n field: string,\n dest: string,\n path: Partial\n) {\n return (\n `Cannot include a '${char}' character in a manually specified ` +\n `\\`to.${field}\\` field [${JSON.stringify(\n path\n )}]. Please separate it out to the ` +\n `\\`to.${dest}\\` field. Alternatively you may provide the full path as ` +\n `a string in and the router will parse it for you.`\n );\n}\n\n/**\n * @private\n *\n * When processing relative navigation we want to ignore ancestor routes that\n * do not contribute to the path, such that index/pathless layout routes don't\n * interfere.\n *\n * For example, when moving a route element into an index route and/or a\n * pathless layout route, relative link behavior contained within should stay\n * the same. Both of the following examples should link back to the root:\n *\n * \n * \n * \n *\n * \n * \n * }> // <-- Does not contribute\n * // <-- Does not contribute\n * \n * \n */\nexport function getPathContributingMatches<\n T extends AgnosticRouteMatch = AgnosticRouteMatch\n>(matches: T[]) {\n return matches.filter(\n (match, index) =>\n index === 0 || (match.route.path && match.route.path.length > 0)\n );\n}\n\n/**\n * @private\n */\nexport function resolveTo(\n toArg: To,\n routePathnames: string[],\n locationPathname: string,\n isPathRelative = false\n): Path {\n let to: Partial;\n if (typeof toArg === \"string\") {\n to = parsePath(toArg);\n } else {\n to = { ...toArg };\n\n invariant(\n !to.pathname || !to.pathname.includes(\"?\"),\n getInvalidPathError(\"?\", \"pathname\", \"search\", to)\n );\n invariant(\n !to.pathname || !to.pathname.includes(\"#\"),\n getInvalidPathError(\"#\", \"pathname\", \"hash\", to)\n );\n invariant(\n !to.search || !to.search.includes(\"#\"),\n getInvalidPathError(\"#\", \"search\", \"hash\", to)\n );\n }\n\n let isEmptyPath = toArg === \"\" || to.pathname === \"\";\n let toPathname = isEmptyPath ? \"/\" : to.pathname;\n\n let from: string;\n\n // Routing is relative to the current pathname if explicitly requested.\n //\n // If a pathname is explicitly provided in `to`, it should be relative to the\n // route context. This is explained in `Note on `` values` in our\n // migration guide from v5 as a means of disambiguation between `to` values\n // that begin with `/` and those that do not. However, this is problematic for\n // `to` values that do not provide a pathname. `to` can simply be a search or\n // hash string, in which case we should assume that the navigation is relative\n // to the current location's pathname and *not* the route pathname.\n if (isPathRelative || toPathname == null) {\n from = locationPathname;\n } else {\n let routePathnameIndex = routePathnames.length - 1;\n\n if (toPathname.startsWith(\"..\")) {\n let toSegments = toPathname.split(\"/\");\n\n // Each leading .. segment means \"go up one route\" instead of \"go up one\n // URL segment\". This is a key difference from how works and a\n // major reason we call this a \"to\" value instead of a \"href\".\n while (toSegments[0] === \"..\") {\n toSegments.shift();\n routePathnameIndex -= 1;\n }\n\n to.pathname = toSegments.join(\"/\");\n }\n\n // If there are more \"..\" segments than parent routes, resolve relative to\n // the root / URL.\n from = routePathnameIndex >= 0 ? routePathnames[routePathnameIndex] : \"/\";\n }\n\n let path = resolvePath(to, from);\n\n // Ensure the pathname has a trailing slash if the original \"to\" had one\n let hasExplicitTrailingSlash =\n toPathname && toPathname !== \"/\" && toPathname.endsWith(\"/\");\n // Or if this was a link to the current path which has a trailing slash\n let hasCurrentTrailingSlash =\n (isEmptyPath || toPathname === \".\") && locationPathname.endsWith(\"/\");\n if (\n !path.pathname.endsWith(\"/\") &&\n (hasExplicitTrailingSlash || hasCurrentTrailingSlash)\n ) {\n path.pathname += \"/\";\n }\n\n return path;\n}\n\n/**\n * @private\n */\nexport function getToPathname(to: To): string | undefined {\n // Empty strings should be treated the same as / paths\n return to === \"\" || (to as Path).pathname === \"\"\n ? \"/\"\n : typeof to === \"string\"\n ? parsePath(to).pathname\n : to.pathname;\n}\n\n/**\n * @private\n */\nexport const joinPaths = (paths: string[]): string =>\n paths.join(\"/\").replace(/\\/\\/+/g, \"/\");\n\n/**\n * @private\n */\nexport const normalizePathname = (pathname: string): string =>\n pathname.replace(/\\/+$/, \"\").replace(/^\\/*/, \"/\");\n\n/**\n * @private\n */\nexport const normalizeSearch = (search: string): string =>\n !search || search === \"?\"\n ? \"\"\n : search.startsWith(\"?\")\n ? search\n : \"?\" + search;\n\n/**\n * @private\n */\nexport const normalizeHash = (hash: string): string =>\n !hash || hash === \"#\" ? \"\" : hash.startsWith(\"#\") ? hash : \"#\" + hash;\n\nexport type JsonFunction = (\n data: Data,\n init?: number | ResponseInit\n) => Response;\n\n/**\n * This is a shortcut for creating `application/json` responses. Converts `data`\n * to JSON and sets the `Content-Type` header.\n */\nexport const json: JsonFunction = (data, init = {}) => {\n let responseInit = typeof init === \"number\" ? { status: init } : init;\n\n let headers = new Headers(responseInit.headers);\n if (!headers.has(\"Content-Type\")) {\n headers.set(\"Content-Type\", \"application/json; charset=utf-8\");\n }\n\n return new Response(JSON.stringify(data), {\n ...responseInit,\n headers,\n });\n};\n\nexport interface TrackedPromise extends Promise {\n _tracked?: boolean;\n _data?: any;\n _error?: any;\n}\n\nexport class AbortedDeferredError extends Error {}\n\nexport class DeferredData {\n private pendingKeysSet: Set = new Set();\n private controller: AbortController;\n private abortPromise: Promise;\n private unlistenAbortSignal: () => void;\n private subscribers: Set<(aborted: boolean, settledKey?: string) => void> =\n new Set();\n data: Record;\n init?: ResponseInit;\n deferredKeys: string[] = [];\n\n constructor(data: Record, responseInit?: ResponseInit) {\n invariant(\n data && typeof data === \"object\" && !Array.isArray(data),\n \"defer() only accepts plain objects\"\n );\n\n // Set up an AbortController + Promise we can race against to exit early\n // cancellation\n let reject: (e: AbortedDeferredError) => void;\n this.abortPromise = new Promise((_, r) => (reject = r));\n this.controller = new AbortController();\n let onAbort = () =>\n reject(new AbortedDeferredError(\"Deferred data aborted\"));\n this.unlistenAbortSignal = () =>\n this.controller.signal.removeEventListener(\"abort\", onAbort);\n this.controller.signal.addEventListener(\"abort\", onAbort);\n\n this.data = Object.entries(data).reduce(\n (acc, [key, value]) =>\n Object.assign(acc, {\n [key]: this.trackPromise(key, value),\n }),\n {}\n );\n\n if (this.done) {\n // All incoming values were resolved\n this.unlistenAbortSignal();\n }\n\n this.init = responseInit;\n }\n\n private trackPromise(\n key: string,\n value: Promise | unknown\n ): TrackedPromise | unknown {\n if (!(value instanceof Promise)) {\n return value;\n }\n\n this.deferredKeys.push(key);\n this.pendingKeysSet.add(key);\n\n // We store a little wrapper promise that will be extended with\n // _data/_error props upon resolve/reject\n let promise: TrackedPromise = Promise.race([value, this.abortPromise]).then(\n (data) => this.onSettle(promise, key, undefined, data as unknown),\n (error) => this.onSettle(promise, key, error as unknown)\n );\n\n // Register rejection listeners to avoid uncaught promise rejections on\n // errors or aborted deferred values\n promise.catch(() => {});\n\n Object.defineProperty(promise, \"_tracked\", { get: () => true });\n return promise;\n }\n\n private onSettle(\n promise: TrackedPromise,\n key: string,\n error: unknown,\n data?: unknown\n ): unknown {\n if (\n this.controller.signal.aborted &&\n error instanceof AbortedDeferredError\n ) {\n this.unlistenAbortSignal();\n Object.defineProperty(promise, \"_error\", { get: () => error });\n return Promise.reject(error);\n }\n\n this.pendingKeysSet.delete(key);\n\n if (this.done) {\n // Nothing left to abort!\n this.unlistenAbortSignal();\n }\n\n // If the promise was resolved/rejected with undefined, we'll throw an error as you\n // should always resolve with a value or null\n if (error === undefined && data === undefined) {\n let undefinedError = new Error(\n `Deferred data for key \"${key}\" resolved/rejected with \\`undefined\\`, ` +\n `you must resolve/reject with a value or \\`null\\`.`\n );\n Object.defineProperty(promise, \"_error\", { get: () => undefinedError });\n this.emit(false, key);\n return Promise.reject(undefinedError);\n }\n\n if (data === undefined) {\n Object.defineProperty(promise, \"_error\", { get: () => error });\n this.emit(false, key);\n return Promise.reject(error);\n }\n\n Object.defineProperty(promise, \"_data\", { get: () => data });\n this.emit(false, key);\n return data;\n }\n\n private emit(aborted: boolean, settledKey?: string) {\n this.subscribers.forEach((subscriber) => subscriber(aborted, settledKey));\n }\n\n subscribe(fn: (aborted: boolean, settledKey?: string) => void) {\n this.subscribers.add(fn);\n return () => this.subscribers.delete(fn);\n }\n\n cancel() {\n this.controller.abort();\n this.pendingKeysSet.forEach((v, k) => this.pendingKeysSet.delete(k));\n this.emit(true);\n }\n\n async resolveData(signal: AbortSignal) {\n let aborted = false;\n if (!this.done) {\n let onAbort = () => this.cancel();\n signal.addEventListener(\"abort\", onAbort);\n aborted = await new Promise((resolve) => {\n this.subscribe((aborted) => {\n signal.removeEventListener(\"abort\", onAbort);\n if (aborted || this.done) {\n resolve(aborted);\n }\n });\n });\n }\n return aborted;\n }\n\n get done() {\n return this.pendingKeysSet.size === 0;\n }\n\n get unwrappedData() {\n invariant(\n this.data !== null && this.done,\n \"Can only unwrap data on initialized and settled deferreds\"\n );\n\n return Object.entries(this.data).reduce(\n (acc, [key, value]) =>\n Object.assign(acc, {\n [key]: unwrapTrackedPromise(value),\n }),\n {}\n );\n }\n\n get pendingKeys() {\n return Array.from(this.pendingKeysSet);\n }\n}\n\nfunction isTrackedPromise(value: any): value is TrackedPromise {\n return (\n value instanceof Promise && (value as TrackedPromise)._tracked === true\n );\n}\n\nfunction unwrapTrackedPromise(value: any) {\n if (!isTrackedPromise(value)) {\n return value;\n }\n\n if (value._error) {\n throw value._error;\n }\n return value._data;\n}\n\nexport type DeferFunction = (\n data: Record,\n init?: number | ResponseInit\n) => DeferredData;\n\nexport const defer: DeferFunction = (data, init = {}) => {\n let responseInit = typeof init === \"number\" ? { status: init } : init;\n\n return new DeferredData(data, responseInit);\n};\n\nexport type RedirectFunction = (\n url: string,\n init?: number | ResponseInit\n) => Response;\n\n/**\n * A redirect response. Sets the status code and the `Location` header.\n * Defaults to \"302 Found\".\n */\nexport const redirect: RedirectFunction = (url, init = 302) => {\n let responseInit = init;\n if (typeof responseInit === \"number\") {\n responseInit = { status: responseInit };\n } else if (typeof responseInit.status === \"undefined\") {\n responseInit.status = 302;\n }\n\n let headers = new Headers(responseInit.headers);\n headers.set(\"Location\", url);\n\n return new Response(null, {\n ...responseInit,\n headers,\n });\n};\n\n/**\n * @private\n * Utility class we use to hold auto-unwrapped 4xx/5xx Response bodies\n */\nexport class ErrorResponse {\n status: number;\n statusText: string;\n data: any;\n error?: Error;\n internal: boolean;\n\n constructor(\n status: number,\n statusText: string | undefined,\n data: any,\n internal = false\n ) {\n this.status = status;\n this.statusText = statusText || \"\";\n this.internal = internal;\n if (data instanceof Error) {\n this.data = data.toString();\n this.error = data;\n } else {\n this.data = data;\n }\n }\n}\n\n/**\n * Check if the given error is an ErrorResponse generated from a 4xx/5xx\n * Response thrown from an action/loader\n */\nexport function isRouteErrorResponse(error: any): error is ErrorResponse {\n return (\n error != null &&\n typeof error.status === \"number\" &&\n typeof error.statusText === \"string\" &&\n typeof error.internal === \"boolean\" &&\n \"data\" in error\n );\n}\n","import type { History, Location, Path, To } from \"./history\";\nimport {\n Action as HistoryAction,\n createLocation,\n createPath,\n invariant,\n parsePath,\n warning,\n} from \"./history\";\nimport type {\n DataResult,\n DeferredData,\n AgnosticDataRouteMatch,\n AgnosticDataRouteObject,\n DeferredResult,\n ErrorResult,\n FormEncType,\n FormMethod,\n DetectErrorBoundaryFunction,\n RedirectResult,\n RouteData,\n AgnosticRouteObject,\n Submission,\n SuccessResult,\n AgnosticRouteMatch,\n ShouldRevalidateFunction,\n RouteManifest,\n ImmutableRouteKey,\n ActionFunction,\n LoaderFunction,\n V7_MutationFormMethod,\n V7_FormMethod,\n HTMLFormMethod,\n MutationFormMethod,\n MapRoutePropertiesFunction,\n} from \"./utils\";\nimport {\n ErrorResponse,\n ResultType,\n convertRoutesToDataRoutes,\n getPathContributingMatches,\n immutableRouteKeys,\n isRouteErrorResponse,\n joinPaths,\n matchRoutes,\n resolveTo,\n stripBasename,\n} from \"./utils\";\n\n////////////////////////////////////////////////////////////////////////////////\n//#region Types and Constants\n////////////////////////////////////////////////////////////////////////////////\n\n/**\n * A Router instance manages all navigation and data loading/mutations\n */\nexport interface Router {\n /**\n * @internal\n * PRIVATE - DO NOT USE\n *\n * Return the basename for the router\n */\n get basename(): RouterInit[\"basename\"];\n\n /**\n * @internal\n * PRIVATE - DO NOT USE\n *\n * Return the current state of the router\n */\n get state(): RouterState;\n\n /**\n * @internal\n * PRIVATE - DO NOT USE\n *\n * Return the routes for this router instance\n */\n get routes(): AgnosticDataRouteObject[];\n\n /**\n * @internal\n * PRIVATE - DO NOT USE\n *\n * Initialize the router, including adding history listeners and kicking off\n * initial data fetches. Returns a function to cleanup listeners and abort\n * any in-progress loads\n */\n initialize(): Router;\n\n /**\n * @internal\n * PRIVATE - DO NOT USE\n *\n * Subscribe to router.state updates\n *\n * @param fn function to call with the new state\n */\n subscribe(fn: RouterSubscriber): () => void;\n\n /**\n * @internal\n * PRIVATE - DO NOT USE\n *\n * Enable scroll restoration behavior in the router\n *\n * @param savedScrollPositions Object that will manage positions, in case\n * it's being restored from sessionStorage\n * @param getScrollPosition Function to get the active Y scroll position\n * @param getKey Function to get the key to use for restoration\n */\n enableScrollRestoration(\n savedScrollPositions: Record,\n getScrollPosition: GetScrollPositionFunction,\n getKey?: GetScrollRestorationKeyFunction\n ): () => void;\n\n /**\n * @internal\n * PRIVATE - DO NOT USE\n *\n * Navigate forward/backward in the history stack\n * @param to Delta to move in the history stack\n */\n navigate(to: number): Promise;\n\n /**\n * Navigate to the given path\n * @param to Path to navigate to\n * @param opts Navigation options (method, submission, etc.)\n */\n navigate(to: To | null, opts?: RouterNavigateOptions): Promise;\n\n /**\n * @internal\n * PRIVATE - DO NOT USE\n *\n * Trigger a fetcher load/submission\n *\n * @param key Fetcher key\n * @param routeId Route that owns the fetcher\n * @param href href to fetch\n * @param opts Fetcher options, (method, submission, etc.)\n */\n fetch(\n key: string,\n routeId: string,\n href: string | null,\n opts?: RouterFetchOptions\n ): void;\n\n /**\n * @internal\n * PRIVATE - DO NOT USE\n *\n * Trigger a revalidation of all current route loaders and fetcher loads\n */\n revalidate(): void;\n\n /**\n * @internal\n * PRIVATE - DO NOT USE\n *\n * Utility function to create an href for the given location\n * @param location\n */\n createHref(location: Location | URL): string;\n\n /**\n * @internal\n * PRIVATE - DO NOT USE\n *\n * Utility function to URL encode a destination path according to the internal\n * history implementation\n * @param to\n */\n encodeLocation(to: To): Path;\n\n /**\n * @internal\n * PRIVATE - DO NOT USE\n *\n * Get/create a fetcher for the given key\n * @param key\n */\n getFetcher(key?: string): Fetcher;\n\n /**\n * @internal\n * PRIVATE - DO NOT USE\n *\n * Delete the fetcher for a given key\n * @param key\n */\n deleteFetcher(key?: string): void;\n\n /**\n * @internal\n * PRIVATE - DO NOT USE\n *\n * Cleanup listeners and abort any in-progress loads\n */\n dispose(): void;\n\n /**\n * @internal\n * PRIVATE - DO NOT USE\n *\n * Get a navigation blocker\n * @param key The identifier for the blocker\n * @param fn The blocker function implementation\n */\n getBlocker(key: string, fn: BlockerFunction): Blocker;\n\n /**\n * @internal\n * PRIVATE - DO NOT USE\n *\n * Delete a navigation blocker\n * @param key The identifier for the blocker\n */\n deleteBlocker(key: string): void;\n\n /**\n * @internal\n * PRIVATE - DO NOT USE\n *\n * HMR needs to pass in-flight route updates to React Router\n * TODO: Replace this with granular route update APIs (addRoute, updateRoute, deleteRoute)\n */\n _internalSetRoutes(routes: AgnosticRouteObject[]): void;\n\n /**\n * @internal\n * PRIVATE - DO NOT USE\n *\n * Internal fetch AbortControllers accessed by unit tests\n */\n _internalFetchControllers: Map;\n\n /**\n * @internal\n * PRIVATE - DO NOT USE\n *\n * Internal pending DeferredData instances accessed by unit tests\n */\n _internalActiveDeferreds: Map;\n}\n\n/**\n * State maintained internally by the router. During a navigation, all states\n * reflect the the \"old\" location unless otherwise noted.\n */\nexport interface RouterState {\n /**\n * The action of the most recent navigation\n */\n historyAction: HistoryAction;\n\n /**\n * The current location reflected by the router\n */\n location: Location;\n\n /**\n * The current set of route matches\n */\n matches: AgnosticDataRouteMatch[];\n\n /**\n * Tracks whether we've completed our initial data load\n */\n initialized: boolean;\n\n /**\n * Current scroll position we should start at for a new view\n * - number -> scroll position to restore to\n * - false -> do not restore scroll at all (used during submissions)\n * - null -> don't have a saved position, scroll to hash or top of page\n */\n restoreScrollPosition: number | false | null;\n\n /**\n * Indicate whether this navigation should skip resetting the scroll position\n * if we are unable to restore the scroll position\n */\n preventScrollReset: boolean;\n\n /**\n * Tracks the state of the current navigation\n */\n navigation: Navigation;\n\n /**\n * Tracks any in-progress revalidations\n */\n revalidation: RevalidationState;\n\n /**\n * Data from the loaders for the current matches\n */\n loaderData: RouteData;\n\n /**\n * Data from the action for the current matches\n */\n actionData: RouteData | null;\n\n /**\n * Errors caught from loaders for the current matches\n */\n errors: RouteData | null;\n\n /**\n * Map of current fetchers\n */\n fetchers: Map;\n\n /**\n * Map of current blockers\n */\n blockers: Map;\n}\n\n/**\n * Data that can be passed into hydrate a Router from SSR\n */\nexport type HydrationState = Partial<\n Pick\n>;\n\n/**\n * Future flags to toggle new feature behavior\n */\nexport interface FutureConfig {\n v7_normalizeFormMethod: boolean;\n v7_prependBasename: boolean;\n}\n\n/**\n * Initialization options for createRouter\n */\nexport interface RouterInit {\n routes: AgnosticRouteObject[];\n history: History;\n basename?: string;\n /**\n * @deprecated Use `mapRouteProperties` instead\n */\n detectErrorBoundary?: DetectErrorBoundaryFunction;\n mapRouteProperties?: MapRoutePropertiesFunction;\n future?: Partial;\n hydrationData?: HydrationState;\n window?: Window;\n}\n\n/**\n * State returned from a server-side query() call\n */\nexport interface StaticHandlerContext {\n basename: Router[\"basename\"];\n location: RouterState[\"location\"];\n matches: RouterState[\"matches\"];\n loaderData: RouterState[\"loaderData\"];\n actionData: RouterState[\"actionData\"];\n errors: RouterState[\"errors\"];\n statusCode: number;\n loaderHeaders: Record;\n actionHeaders: Record;\n activeDeferreds: Record | null;\n _deepestRenderedBoundaryId?: string | null;\n}\n\n/**\n * A StaticHandler instance manages a singular SSR navigation/fetch event\n */\nexport interface StaticHandler {\n dataRoutes: AgnosticDataRouteObject[];\n query(\n request: Request,\n opts?: { requestContext?: unknown }\n ): Promise;\n queryRoute(\n request: Request,\n opts?: { routeId?: string; requestContext?: unknown }\n ): Promise;\n}\n\n/**\n * Subscriber function signature for changes to router state\n */\nexport interface RouterSubscriber {\n (state: RouterState): void;\n}\n\ninterface UseMatchesMatch {\n id: string;\n pathname: string;\n params: AgnosticRouteMatch[\"params\"];\n data: unknown;\n handle: unknown;\n}\n\n/**\n * Function signature for determining the key to be used in scroll restoration\n * for a given location\n */\nexport interface GetScrollRestorationKeyFunction {\n (location: Location, matches: UseMatchesMatch[]): string | null;\n}\n\n/**\n * Function signature for determining the current scroll position\n */\nexport interface GetScrollPositionFunction {\n (): number;\n}\n\nexport type RelativeRoutingType = \"route\" | \"path\";\n\n// Allowed for any navigation or fetch\ntype BaseNavigateOrFetchOptions = {\n preventScrollReset?: boolean;\n relative?: RelativeRoutingType;\n};\n\n// Only allowed for navigations\ntype BaseNavigateOptions = BaseNavigateOrFetchOptions & {\n replace?: boolean;\n state?: any;\n fromRouteId?: string;\n};\n\n// Only allowed for submission navigations\ntype BaseSubmissionOptions = {\n formMethod?: HTMLFormMethod;\n formEncType?: FormEncType;\n} & (\n | { formData: FormData; body?: undefined }\n | { formData?: undefined; body: any }\n);\n\n/**\n * Options for a navigate() call for a normal (non-submission) navigation\n */\ntype LinkNavigateOptions = BaseNavigateOptions;\n\n/**\n * Options for a navigate() call for a submission navigation\n */\ntype SubmissionNavigateOptions = BaseNavigateOptions & BaseSubmissionOptions;\n\n/**\n * Options to pass to navigate() for a navigation\n */\nexport type RouterNavigateOptions =\n | LinkNavigateOptions\n | SubmissionNavigateOptions;\n\n/**\n * Options for a fetch() load\n */\ntype LoadFetchOptions = BaseNavigateOrFetchOptions;\n\n/**\n * Options for a fetch() submission\n */\ntype SubmitFetchOptions = BaseNavigateOrFetchOptions & BaseSubmissionOptions;\n\n/**\n * Options to pass to fetch()\n */\nexport type RouterFetchOptions = LoadFetchOptions | SubmitFetchOptions;\n\n/**\n * Potential states for state.navigation\n */\nexport type NavigationStates = {\n Idle: {\n state: \"idle\";\n location: undefined;\n formMethod: undefined;\n formAction: undefined;\n formEncType: undefined;\n formData: undefined;\n json: undefined;\n text: undefined;\n };\n Loading: {\n state: \"loading\";\n location: Location;\n formMethod: Submission[\"formMethod\"] | undefined;\n formAction: Submission[\"formAction\"] | undefined;\n formEncType: Submission[\"formEncType\"] | undefined;\n formData: Submission[\"formData\"] | undefined;\n json: Submission[\"json\"] | undefined;\n text: Submission[\"text\"] | undefined;\n };\n Submitting: {\n state: \"submitting\";\n location: Location;\n formMethod: Submission[\"formMethod\"];\n formAction: Submission[\"formAction\"];\n formEncType: Submission[\"formEncType\"];\n formData: Submission[\"formData\"];\n json: Submission[\"json\"];\n text: Submission[\"text\"];\n };\n};\n\nexport type Navigation = NavigationStates[keyof NavigationStates];\n\nexport type RevalidationState = \"idle\" | \"loading\";\n\n/**\n * Potential states for fetchers\n */\ntype FetcherStates = {\n Idle: {\n state: \"idle\";\n formMethod: undefined;\n formAction: undefined;\n formEncType: undefined;\n text: undefined;\n formData: undefined;\n json: undefined;\n data: TData | undefined;\n \" _hasFetcherDoneAnything \"?: boolean;\n };\n Loading: {\n state: \"loading\";\n formMethod: Submission[\"formMethod\"] | undefined;\n formAction: Submission[\"formAction\"] | undefined;\n formEncType: Submission[\"formEncType\"] | undefined;\n text: Submission[\"text\"] | undefined;\n formData: Submission[\"formData\"] | undefined;\n json: Submission[\"json\"] | undefined;\n data: TData | undefined;\n \" _hasFetcherDoneAnything \"?: boolean;\n };\n Submitting: {\n state: \"submitting\";\n formMethod: Submission[\"formMethod\"];\n formAction: Submission[\"formAction\"];\n formEncType: Submission[\"formEncType\"];\n text: Submission[\"text\"];\n formData: Submission[\"formData\"];\n json: Submission[\"json\"];\n data: TData | undefined;\n \" _hasFetcherDoneAnything \"?: boolean;\n };\n};\n\nexport type Fetcher =\n FetcherStates[keyof FetcherStates];\n\ninterface BlockerBlocked {\n state: \"blocked\";\n reset(): void;\n proceed(): void;\n location: Location;\n}\n\ninterface BlockerUnblocked {\n state: \"unblocked\";\n reset: undefined;\n proceed: undefined;\n location: undefined;\n}\n\ninterface BlockerProceeding {\n state: \"proceeding\";\n reset: undefined;\n proceed: undefined;\n location: Location;\n}\n\nexport type Blocker = BlockerUnblocked | BlockerBlocked | BlockerProceeding;\n\nexport type BlockerFunction = (args: {\n currentLocation: Location;\n nextLocation: Location;\n historyAction: HistoryAction;\n}) => boolean;\n\ninterface ShortCircuitable {\n /**\n * startNavigation does not need to complete the navigation because we\n * redirected or got interrupted\n */\n shortCircuited?: boolean;\n}\n\ninterface HandleActionResult extends ShortCircuitable {\n /**\n * Error thrown from the current action, keyed by the route containing the\n * error boundary to render the error. To be committed to the state after\n * loaders have completed\n */\n pendingActionError?: RouteData;\n /**\n * Data returned from the current action, keyed by the route owning the action.\n * To be committed to the state after loaders have completed\n */\n pendingActionData?: RouteData;\n}\n\ninterface HandleLoadersResult extends ShortCircuitable {\n /**\n * loaderData returned from the current set of loaders\n */\n loaderData?: RouterState[\"loaderData\"];\n /**\n * errors thrown from the current set of loaders\n */\n errors?: RouterState[\"errors\"];\n}\n\n/**\n * Cached info for active fetcher.load() instances so they can participate\n * in revalidation\n */\ninterface FetchLoadMatch {\n routeId: string;\n path: string;\n}\n\n/**\n * Identified fetcher.load() calls that need to be revalidated\n */\ninterface RevalidatingFetcher extends FetchLoadMatch {\n key: string;\n match: AgnosticDataRouteMatch | null;\n matches: AgnosticDataRouteMatch[] | null;\n controller: AbortController | null;\n}\n\n/**\n * Wrapper object to allow us to throw any response out from callLoaderOrAction\n * for queryRouter while preserving whether or not it was thrown or returned\n * from the loader/action\n */\ninterface QueryRouteResponse {\n type: ResultType.data | ResultType.error;\n response: Response;\n}\n\nconst validMutationMethodsArr: MutationFormMethod[] = [\n \"post\",\n \"put\",\n \"patch\",\n \"delete\",\n];\nconst validMutationMethods = new Set(\n validMutationMethodsArr\n);\n\nconst validRequestMethodsArr: FormMethod[] = [\n \"get\",\n ...validMutationMethodsArr,\n];\nconst validRequestMethods = new Set(validRequestMethodsArr);\n\nconst redirectStatusCodes = new Set([301, 302, 303, 307, 308]);\nconst redirectPreserveMethodStatusCodes = new Set([307, 308]);\n\nexport const IDLE_NAVIGATION: NavigationStates[\"Idle\"] = {\n state: \"idle\",\n location: undefined,\n formMethod: undefined,\n formAction: undefined,\n formEncType: undefined,\n formData: undefined,\n json: undefined,\n text: undefined,\n};\n\nexport const IDLE_FETCHER: FetcherStates[\"Idle\"] = {\n state: \"idle\",\n data: undefined,\n formMethod: undefined,\n formAction: undefined,\n formEncType: undefined,\n formData: undefined,\n json: undefined,\n text: undefined,\n};\n\nexport const IDLE_BLOCKER: BlockerUnblocked = {\n state: \"unblocked\",\n proceed: undefined,\n reset: undefined,\n location: undefined,\n};\n\nconst ABSOLUTE_URL_REGEX = /^(?:[a-z][a-z0-9+.-]*:|\\/\\/)/i;\n\nconst defaultMapRouteProperties: MapRoutePropertiesFunction = (route) => ({\n hasErrorBoundary: Boolean(route.hasErrorBoundary),\n});\n\n//#endregion\n\n////////////////////////////////////////////////////////////////////////////////\n//#region createRouter\n////////////////////////////////////////////////////////////////////////////////\n\n/**\n * Create a router and listen to history POP navigations\n */\nexport function createRouter(init: RouterInit): Router {\n const routerWindow = init.window\n ? init.window\n : typeof window !== \"undefined\"\n ? window\n : undefined;\n const isBrowser =\n typeof routerWindow !== \"undefined\" &&\n typeof routerWindow.document !== \"undefined\" &&\n typeof routerWindow.document.createElement !== \"undefined\";\n const isServer = !isBrowser;\n\n invariant(\n init.routes.length > 0,\n \"You must provide a non-empty routes array to createRouter\"\n );\n\n let mapRouteProperties: MapRoutePropertiesFunction;\n if (init.mapRouteProperties) {\n mapRouteProperties = init.mapRouteProperties;\n } else if (init.detectErrorBoundary) {\n // If they are still using the deprecated version, wrap it with the new API\n let detectErrorBoundary = init.detectErrorBoundary;\n mapRouteProperties = (route) => ({\n hasErrorBoundary: detectErrorBoundary(route),\n });\n } else {\n mapRouteProperties = defaultMapRouteProperties;\n }\n\n // Routes keyed by ID\n let manifest: RouteManifest = {};\n // Routes in tree format for matching\n let dataRoutes = convertRoutesToDataRoutes(\n init.routes,\n mapRouteProperties,\n undefined,\n manifest\n );\n let inFlightDataRoutes: AgnosticDataRouteObject[] | undefined;\n let basename = init.basename || \"/\";\n // Config driven behavior flags\n let future: FutureConfig = {\n v7_normalizeFormMethod: false,\n v7_prependBasename: false,\n ...init.future,\n };\n // Cleanup function for history\n let unlistenHistory: (() => void) | null = null;\n // Externally-provided functions to call on all state changes\n let subscribers = new Set();\n // Externally-provided object to hold scroll restoration locations during routing\n let savedScrollPositions: Record | null = null;\n // Externally-provided function to get scroll restoration keys\n let getScrollRestorationKey: GetScrollRestorationKeyFunction | null = null;\n // Externally-provided function to get current scroll position\n let getScrollPosition: GetScrollPositionFunction | null = null;\n // One-time flag to control the initial hydration scroll restoration. Because\n // we don't get the saved positions from until _after_\n // the initial render, we need to manually trigger a separate updateState to\n // send along the restoreScrollPosition\n // Set to true if we have `hydrationData` since we assume we were SSR'd and that\n // SSR did the initial scroll restoration.\n let initialScrollRestored = init.hydrationData != null;\n\n let initialMatches = matchRoutes(dataRoutes, init.history.location, basename);\n let initialErrors: RouteData | null = null;\n\n if (initialMatches == null) {\n // If we do not match a user-provided-route, fall back to the root\n // to allow the error boundary to take over\n let error = getInternalRouterError(404, {\n pathname: init.history.location.pathname,\n });\n let { matches, route } = getShortCircuitMatches(dataRoutes);\n initialMatches = matches;\n initialErrors = { [route.id]: error };\n }\n\n let initialized =\n // All initialMatches need to be loaded before we're ready. If we have lazy\n // functions around still then we'll need to run them in initialize()\n !initialMatches.some((m) => m.route.lazy) &&\n // And we have to either have no loaders or have been provided hydrationData\n (!initialMatches.some((m) => m.route.loader) || init.hydrationData != null);\n\n let router: Router;\n let state: RouterState = {\n historyAction: init.history.action,\n location: init.history.location,\n matches: initialMatches,\n initialized,\n navigation: IDLE_NAVIGATION,\n // Don't restore on initial updateState() if we were SSR'd\n restoreScrollPosition: init.hydrationData != null ? false : null,\n preventScrollReset: false,\n revalidation: \"idle\",\n loaderData: (init.hydrationData && init.hydrationData.loaderData) || {},\n actionData: (init.hydrationData && init.hydrationData.actionData) || null,\n errors: (init.hydrationData && init.hydrationData.errors) || initialErrors,\n fetchers: new Map(),\n blockers: new Map(),\n };\n\n // -- Stateful internal variables to manage navigations --\n // Current navigation in progress (to be committed in completeNavigation)\n let pendingAction: HistoryAction = HistoryAction.Pop;\n\n // Should the current navigation prevent the scroll reset if scroll cannot\n // be restored?\n let pendingPreventScrollReset = false;\n\n // AbortController for the active navigation\n let pendingNavigationController: AbortController | null;\n\n // We use this to avoid touching history in completeNavigation if a\n // revalidation is entirely uninterrupted\n let isUninterruptedRevalidation = false;\n\n // Use this internal flag to force revalidation of all loaders:\n // - submissions (completed or interrupted)\n // - useRevalidator()\n // - X-Remix-Revalidate (from redirect)\n let isRevalidationRequired = false;\n\n // Use this internal array to capture routes that require revalidation due\n // to a cancelled deferred on action submission\n let cancelledDeferredRoutes: string[] = [];\n\n // Use this internal array to capture fetcher loads that were cancelled by an\n // action navigation and require revalidation\n let cancelledFetcherLoads: string[] = [];\n\n // AbortControllers for any in-flight fetchers\n let fetchControllers = new Map();\n\n // Track loads based on the order in which they started\n let incrementingLoadId = 0;\n\n // Track the outstanding pending navigation data load to be compared against\n // the globally incrementing load when a fetcher load lands after a completed\n // navigation\n let pendingNavigationLoadId = -1;\n\n // Fetchers that triggered data reloads as a result of their actions\n let fetchReloadIds = new Map();\n\n // Fetchers that triggered redirect navigations\n let fetchRedirectIds = new Set();\n\n // Most recent href/match for fetcher.load calls for fetchers\n let fetchLoadMatches = new Map();\n\n // Store DeferredData instances for active route matches. When a\n // route loader returns defer() we stick one in here. Then, when a nested\n // promise resolves we update loaderData. If a new navigation starts we\n // cancel active deferreds for eliminated routes.\n let activeDeferreds = new Map();\n\n // Store blocker functions in a separate Map outside of router state since\n // we don't need to update UI state if they change\n let blockerFunctions = new Map();\n\n // Flag to ignore the next history update, so we can revert the URL change on\n // a POP navigation that was blocked by the user without touching router state\n let ignoreNextHistoryUpdate = false;\n\n // Initialize the router, all side effects should be kicked off from here.\n // Implemented as a Fluent API for ease of:\n // let router = createRouter(init).initialize();\n function initialize() {\n // If history informs us of a POP navigation, start the navigation but do not update\n // state. We'll update our own state once the navigation completes\n unlistenHistory = init.history.listen(\n ({ action: historyAction, location, delta }) => {\n // Ignore this event if it was just us resetting the URL from a\n // blocked POP navigation\n if (ignoreNextHistoryUpdate) {\n ignoreNextHistoryUpdate = false;\n return;\n }\n\n warning(\n blockerFunctions.size === 0 || delta != null,\n \"You are trying to use a blocker on a POP navigation to a location \" +\n \"that was not created by @remix-run/router. This will fail silently in \" +\n \"production. This can happen if you are navigating outside the router \" +\n \"via `window.history.pushState`/`window.location.hash` instead of using \" +\n \"router navigation APIs. This can also happen if you are using \" +\n \"createHashRouter and the user manually changes the URL.\"\n );\n\n let blockerKey = shouldBlockNavigation({\n currentLocation: state.location,\n nextLocation: location,\n historyAction,\n });\n\n if (blockerKey && delta != null) {\n // Restore the URL to match the current UI, but don't update router state\n ignoreNextHistoryUpdate = true;\n init.history.go(delta * -1);\n\n // Put the blocker into a blocked state\n updateBlocker(blockerKey, {\n state: \"blocked\",\n location,\n proceed() {\n updateBlocker(blockerKey!, {\n state: \"proceeding\",\n proceed: undefined,\n reset: undefined,\n location,\n });\n // Re-do the same POP navigation we just blocked\n init.history.go(delta);\n },\n reset() {\n let blockers = new Map(state.blockers);\n blockers.set(blockerKey!, IDLE_BLOCKER);\n updateState({ blockers });\n },\n });\n return;\n }\n\n return startNavigation(historyAction, location);\n }\n );\n\n // Kick off initial data load if needed. Use Pop to avoid modifying history\n // Note we don't do any handling of lazy here. For SPA's it'll get handled\n // in the normal navigation flow. For SSR it's expected that lazy modules are\n // resolved prior to router creation since we can't go into a fallbackElement\n // UI for SSR'd apps\n if (!state.initialized) {\n startNavigation(HistoryAction.Pop, state.location);\n }\n\n return router;\n }\n\n // Clean up a router and it's side effects\n function dispose() {\n if (unlistenHistory) {\n unlistenHistory();\n }\n subscribers.clear();\n pendingNavigationController && pendingNavigationController.abort();\n state.fetchers.forEach((_, key) => deleteFetcher(key));\n state.blockers.forEach((_, key) => deleteBlocker(key));\n }\n\n // Subscribe to state updates for the router\n function subscribe(fn: RouterSubscriber) {\n subscribers.add(fn);\n return () => subscribers.delete(fn);\n }\n\n // Update our state and notify the calling context of the change\n function updateState(newState: Partial): void {\n state = {\n ...state,\n ...newState,\n };\n subscribers.forEach((subscriber) => subscriber(state));\n }\n\n // Complete a navigation returning the state.navigation back to the IDLE_NAVIGATION\n // and setting state.[historyAction/location/matches] to the new route.\n // - Location is a required param\n // - Navigation will always be set to IDLE_NAVIGATION\n // - Can pass any other state in newState\n function completeNavigation(\n location: Location,\n newState: Partial>\n ): void {\n // Deduce if we're in a loading/actionReload state:\n // - We have committed actionData in the store\n // - The current navigation was a mutation submission\n // - We're past the submitting state and into the loading state\n // - The location being loaded is not the result of a redirect\n let isActionReload =\n state.actionData != null &&\n state.navigation.formMethod != null &&\n isMutationMethod(state.navigation.formMethod) &&\n state.navigation.state === \"loading\" &&\n location.state?._isRedirect !== true;\n\n let actionData: RouteData | null;\n if (newState.actionData) {\n if (Object.keys(newState.actionData).length > 0) {\n actionData = newState.actionData;\n } else {\n // Empty actionData -> clear prior actionData due to an action error\n actionData = null;\n }\n } else if (isActionReload) {\n // Keep the current data if we're wrapping up the action reload\n actionData = state.actionData;\n } else {\n // Clear actionData on any other completed navigations\n actionData = null;\n }\n\n // Always preserve any existing loaderData from re-used routes\n let loaderData = newState.loaderData\n ? mergeLoaderData(\n state.loaderData,\n newState.loaderData,\n newState.matches || [],\n newState.errors\n )\n : state.loaderData;\n\n // On a successful navigation we can assume we got through all blockers\n // so we can start fresh\n let blockers = state.blockers;\n if (blockers.size > 0) {\n blockers = new Map(blockers);\n blockers.forEach((_, k) => blockers.set(k, IDLE_BLOCKER));\n }\n\n // Always respect the user flag. Otherwise don't reset on mutation\n // submission navigations unless they redirect\n let preventScrollReset =\n pendingPreventScrollReset === true ||\n (state.navigation.formMethod != null &&\n isMutationMethod(state.navigation.formMethod) &&\n location.state?._isRedirect !== true);\n\n if (inFlightDataRoutes) {\n dataRoutes = inFlightDataRoutes;\n inFlightDataRoutes = undefined;\n }\n\n if (isUninterruptedRevalidation) {\n // If this was an uninterrupted revalidation then do not touch history\n } else if (pendingAction === HistoryAction.Pop) {\n // Do nothing for POP - URL has already been updated\n } else if (pendingAction === HistoryAction.Push) {\n init.history.push(location, location.state);\n } else if (pendingAction === HistoryAction.Replace) {\n init.history.replace(location, location.state);\n }\n\n updateState({\n ...newState, // matches, errors, fetchers go through as-is\n actionData,\n loaderData,\n historyAction: pendingAction,\n location,\n initialized: true,\n navigation: IDLE_NAVIGATION,\n revalidation: \"idle\",\n restoreScrollPosition: getSavedScrollPosition(\n location,\n newState.matches || state.matches\n ),\n preventScrollReset,\n blockers,\n });\n\n // Reset stateful navigation vars\n pendingAction = HistoryAction.Pop;\n pendingPreventScrollReset = false;\n isUninterruptedRevalidation = false;\n isRevalidationRequired = false;\n cancelledDeferredRoutes = [];\n cancelledFetcherLoads = [];\n }\n\n // Trigger a navigation event, which can either be a numerical POP or a PUSH\n // replace with an optional submission\n async function navigate(\n to: number | To | null,\n opts?: RouterNavigateOptions\n ): Promise {\n if (typeof to === \"number\") {\n init.history.go(to);\n return;\n }\n\n let normalizedPath = normalizeTo(\n state.location,\n state.matches,\n basename,\n future.v7_prependBasename,\n to,\n opts?.fromRouteId,\n opts?.relative\n );\n let { path, submission, error } = normalizeNavigateOptions(\n future.v7_normalizeFormMethod,\n false,\n normalizedPath,\n opts\n );\n\n let currentLocation = state.location;\n let nextLocation = createLocation(state.location, path, opts && opts.state);\n\n // When using navigate as a PUSH/REPLACE we aren't reading an already-encoded\n // URL from window.location, so we need to encode it here so the behavior\n // remains the same as POP and non-data-router usages. new URL() does all\n // the same encoding we'd get from a history.pushState/window.location read\n // without having to touch history\n nextLocation = {\n ...nextLocation,\n ...init.history.encodeLocation(nextLocation),\n };\n\n let userReplace = opts && opts.replace != null ? opts.replace : undefined;\n\n let historyAction = HistoryAction.Push;\n\n if (userReplace === true) {\n historyAction = HistoryAction.Replace;\n } else if (userReplace === false) {\n // no-op\n } else if (\n submission != null &&\n isMutationMethod(submission.formMethod) &&\n submission.formAction === state.location.pathname + state.location.search\n ) {\n // By default on submissions to the current location we REPLACE so that\n // users don't have to double-click the back button to get to the prior\n // location. If the user redirects to a different location from the\n // action/loader this will be ignored and the redirect will be a PUSH\n historyAction = HistoryAction.Replace;\n }\n\n let preventScrollReset =\n opts && \"preventScrollReset\" in opts\n ? opts.preventScrollReset === true\n : undefined;\n\n let blockerKey = shouldBlockNavigation({\n currentLocation,\n nextLocation,\n historyAction,\n });\n\n if (blockerKey) {\n // Put the blocker into a blocked state\n updateBlocker(blockerKey, {\n state: \"blocked\",\n location: nextLocation,\n proceed() {\n updateBlocker(blockerKey!, {\n state: \"proceeding\",\n proceed: undefined,\n reset: undefined,\n location: nextLocation,\n });\n // Send the same navigation through\n navigate(to, opts);\n },\n reset() {\n let blockers = new Map(state.blockers);\n blockers.set(blockerKey!, IDLE_BLOCKER);\n updateState({ blockers });\n },\n });\n return;\n }\n\n return await startNavigation(historyAction, nextLocation, {\n submission,\n // Send through the formData serialization error if we have one so we can\n // render at the right error boundary after we match routes\n pendingError: error,\n preventScrollReset,\n replace: opts && opts.replace,\n });\n }\n\n // Revalidate all current loaders. If a navigation is in progress or if this\n // is interrupted by a navigation, allow this to \"succeed\" by calling all\n // loaders during the next loader round\n function revalidate() {\n interruptActiveLoads();\n updateState({ revalidation: \"loading\" });\n\n // If we're currently submitting an action, we don't need to start a new\n // navigation, we'll just let the follow up loader execution call all loaders\n if (state.navigation.state === \"submitting\") {\n return;\n }\n\n // If we're currently in an idle state, start a new navigation for the current\n // action/location and mark it as uninterrupted, which will skip the history\n // update in completeNavigation\n if (state.navigation.state === \"idle\") {\n startNavigation(state.historyAction, state.location, {\n startUninterruptedRevalidation: true,\n });\n return;\n }\n\n // Otherwise, if we're currently in a loading state, just start a new\n // navigation to the navigation.location but do not trigger an uninterrupted\n // revalidation so that history correctly updates once the navigation completes\n startNavigation(\n pendingAction || state.historyAction,\n state.navigation.location,\n { overrideNavigation: state.navigation }\n );\n }\n\n // Start a navigation to the given action/location. Can optionally provide a\n // overrideNavigation which will override the normalLoad in the case of a redirect\n // navigation\n async function startNavigation(\n historyAction: HistoryAction,\n location: Location,\n opts?: {\n submission?: Submission;\n fetcherSubmission?: Submission;\n overrideNavigation?: Navigation;\n pendingError?: ErrorResponse;\n startUninterruptedRevalidation?: boolean;\n preventScrollReset?: boolean;\n replace?: boolean;\n }\n ): Promise {\n // Abort any in-progress navigations and start a new one. Unset any ongoing\n // uninterrupted revalidations unless told otherwise, since we want this\n // new navigation to update history normally\n pendingNavigationController && pendingNavigationController.abort();\n pendingNavigationController = null;\n pendingAction = historyAction;\n isUninterruptedRevalidation =\n (opts && opts.startUninterruptedRevalidation) === true;\n\n // Save the current scroll position every time we start a new navigation,\n // and track whether we should reset scroll on completion\n saveScrollPosition(state.location, state.matches);\n pendingPreventScrollReset = (opts && opts.preventScrollReset) === true;\n\n let routesToUse = inFlightDataRoutes || dataRoutes;\n let loadingNavigation = opts && opts.overrideNavigation;\n let matches = matchRoutes(routesToUse, location, basename);\n\n // Short circuit with a 404 on the root error boundary if we match nothing\n if (!matches) {\n let error = getInternalRouterError(404, { pathname: location.pathname });\n let { matches: notFoundMatches, route } =\n getShortCircuitMatches(routesToUse);\n // Cancel all pending deferred on 404s since we don't keep any routes\n cancelActiveDeferreds();\n completeNavigation(location, {\n matches: notFoundMatches,\n loaderData: {},\n errors: {\n [route.id]: error,\n },\n });\n return;\n }\n\n // Short circuit if it's only a hash change and not a revalidation or\n // mutation submission.\n //\n // Ignore on initial page loads because since the initial load will always\n // be \"same hash\". For example, on /page#hash and submit a \n // which will default to a navigation to /page\n if (\n state.initialized &&\n !isRevalidationRequired &&\n isHashChangeOnly(state.location, location) &&\n !(opts && opts.submission && isMutationMethod(opts.submission.formMethod))\n ) {\n completeNavigation(location, { matches });\n return;\n }\n\n // Create a controller/Request for this navigation\n pendingNavigationController = new AbortController();\n let request = createClientSideRequest(\n init.history,\n location,\n pendingNavigationController.signal,\n opts && opts.submission\n );\n let pendingActionData: RouteData | undefined;\n let pendingError: RouteData | undefined;\n\n if (opts && opts.pendingError) {\n // If we have a pendingError, it means the user attempted a GET submission\n // with binary FormData so assign here and skip to handleLoaders. That\n // way we handle calling loaders above the boundary etc. It's not really\n // different from an actionError in that sense.\n pendingError = {\n [findNearestBoundary(matches).route.id]: opts.pendingError,\n };\n } else if (\n opts &&\n opts.submission &&\n isMutationMethod(opts.submission.formMethod)\n ) {\n // Call action if we received an action submission\n let actionOutput = await handleAction(\n request,\n location,\n opts.submission,\n matches,\n { replace: opts.replace }\n );\n\n if (actionOutput.shortCircuited) {\n return;\n }\n\n pendingActionData = actionOutput.pendingActionData;\n pendingError = actionOutput.pendingActionError;\n loadingNavigation = getLoadingNavigation(location, opts.submission);\n\n // Create a GET request for the loaders\n request = new Request(request.url, { signal: request.signal });\n }\n\n // Call loaders\n let { shortCircuited, loaderData, errors } = await handleLoaders(\n request,\n location,\n matches,\n loadingNavigation,\n opts && opts.submission,\n opts && opts.fetcherSubmission,\n opts && opts.replace,\n pendingActionData,\n pendingError\n );\n\n if (shortCircuited) {\n return;\n }\n\n // Clean up now that the action/loaders have completed. Don't clean up if\n // we short circuited because pendingNavigationController will have already\n // been assigned to a new controller for the next navigation\n pendingNavigationController = null;\n\n completeNavigation(location, {\n matches,\n ...(pendingActionData ? { actionData: pendingActionData } : {}),\n loaderData,\n errors,\n });\n }\n\n // Call the action matched by the leaf route for this navigation and handle\n // redirects/errors\n async function handleAction(\n request: Request,\n location: Location,\n submission: Submission,\n matches: AgnosticDataRouteMatch[],\n opts: { replace?: boolean } = {}\n ): Promise {\n interruptActiveLoads();\n\n // Put us in a submitting state\n let navigation = getSubmittingNavigation(location, submission);\n updateState({ navigation });\n\n // Call our action and get the result\n let result: DataResult;\n let actionMatch = getTargetMatch(matches, location);\n\n if (!actionMatch.route.action && !actionMatch.route.lazy) {\n result = {\n type: ResultType.error,\n error: getInternalRouterError(405, {\n method: request.method,\n pathname: location.pathname,\n routeId: actionMatch.route.id,\n }),\n };\n } else {\n result = await callLoaderOrAction(\n \"action\",\n request,\n actionMatch,\n matches,\n manifest,\n mapRouteProperties,\n basename\n );\n\n if (request.signal.aborted) {\n return { shortCircuited: true };\n }\n }\n\n if (isRedirectResult(result)) {\n let replace: boolean;\n if (opts && opts.replace != null) {\n replace = opts.replace;\n } else {\n // If the user didn't explicity indicate replace behavior, replace if\n // we redirected to the exact same location we're currently at to avoid\n // double back-buttons\n replace =\n result.location === state.location.pathname + state.location.search;\n }\n await startRedirectNavigation(state, result, { submission, replace });\n return { shortCircuited: true };\n }\n\n if (isErrorResult(result)) {\n // Store off the pending error - we use it to determine which loaders\n // to call and will commit it when we complete the navigation\n let boundaryMatch = findNearestBoundary(matches, actionMatch.route.id);\n\n // By default, all submissions are REPLACE navigations, but if the\n // action threw an error that'll be rendered in an errorElement, we fall\n // back to PUSH so that the user can use the back button to get back to\n // the pre-submission form location to try again\n if ((opts && opts.replace) !== true) {\n pendingAction = HistoryAction.Push;\n }\n\n return {\n // Send back an empty object we can use to clear out any prior actionData\n pendingActionData: {},\n pendingActionError: { [boundaryMatch.route.id]: result.error },\n };\n }\n\n if (isDeferredResult(result)) {\n throw getInternalRouterError(400, { type: \"defer-action\" });\n }\n\n return {\n pendingActionData: { [actionMatch.route.id]: result.data },\n };\n }\n\n // Call all applicable loaders for the given matches, handling redirects,\n // errors, etc.\n async function handleLoaders(\n request: Request,\n location: Location,\n matches: AgnosticDataRouteMatch[],\n overrideNavigation?: Navigation,\n submission?: Submission,\n fetcherSubmission?: Submission,\n replace?: boolean,\n pendingActionData?: RouteData,\n pendingError?: RouteData\n ): Promise {\n // Figure out the right navigation we want to use for data loading\n let loadingNavigation =\n overrideNavigation || getLoadingNavigation(location, submission);\n\n // If this was a redirect from an action we don't have a \"submission\" but\n // we have it on the loading navigation so use that if available\n let activeSubmission =\n submission ||\n fetcherSubmission ||\n getSubmissionFromNavigation(loadingNavigation);\n\n let routesToUse = inFlightDataRoutes || dataRoutes;\n let [matchesToLoad, revalidatingFetchers] = getMatchesToLoad(\n init.history,\n state,\n matches,\n activeSubmission,\n location,\n isRevalidationRequired,\n cancelledDeferredRoutes,\n cancelledFetcherLoads,\n fetchLoadMatches,\n fetchRedirectIds,\n routesToUse,\n basename,\n pendingActionData,\n pendingError\n );\n\n // Cancel pending deferreds for no-longer-matched routes or routes we're\n // about to reload. Note that if this is an action reload we would have\n // already cancelled all pending deferreds so this would be a no-op\n cancelActiveDeferreds(\n (routeId) =>\n !(matches && matches.some((m) => m.route.id === routeId)) ||\n (matchesToLoad && matchesToLoad.some((m) => m.route.id === routeId))\n );\n\n pendingNavigationLoadId = ++incrementingLoadId;\n\n // Short circuit if we have no loaders to run\n if (matchesToLoad.length === 0 && revalidatingFetchers.length === 0) {\n let updatedFetchers = markFetchRedirectsDone();\n completeNavigation(location, {\n matches,\n loaderData: {},\n // Commit pending error if we're short circuiting\n errors: pendingError || null,\n ...(pendingActionData ? { actionData: pendingActionData } : {}),\n ...(updatedFetchers ? { fetchers: new Map(state.fetchers) } : {}),\n });\n return { shortCircuited: true };\n }\n\n // If this is an uninterrupted revalidation, we remain in our current idle\n // state. If not, we need to switch to our loading state and load data,\n // preserving any new action data or existing action data (in the case of\n // a revalidation interrupting an actionReload)\n if (!isUninterruptedRevalidation) {\n revalidatingFetchers.forEach((rf) => {\n let fetcher = state.fetchers.get(rf.key);\n let revalidatingFetcher = getLoadingFetcher(\n undefined,\n fetcher ? fetcher.data : undefined\n );\n state.fetchers.set(rf.key, revalidatingFetcher);\n });\n let actionData = pendingActionData || state.actionData;\n updateState({\n navigation: loadingNavigation,\n ...(actionData\n ? Object.keys(actionData).length === 0\n ? { actionData: null }\n : { actionData }\n : {}),\n ...(revalidatingFetchers.length > 0\n ? { fetchers: new Map(state.fetchers) }\n : {}),\n });\n }\n\n revalidatingFetchers.forEach((rf) => {\n if (fetchControllers.has(rf.key)) {\n abortFetcher(rf.key);\n }\n if (rf.controller) {\n // Fetchers use an independent AbortController so that aborting a fetcher\n // (via deleteFetcher) does not abort the triggering navigation that\n // triggered the revalidation\n fetchControllers.set(rf.key, rf.controller);\n }\n });\n\n // Proxy navigation abort through to revalidation fetchers\n let abortPendingFetchRevalidations = () =>\n revalidatingFetchers.forEach((f) => abortFetcher(f.key));\n if (pendingNavigationController) {\n pendingNavigationController.signal.addEventListener(\n \"abort\",\n abortPendingFetchRevalidations\n );\n }\n\n let { results, loaderResults, fetcherResults } =\n await callLoadersAndMaybeResolveData(\n state.matches,\n matches,\n matchesToLoad,\n revalidatingFetchers,\n request\n );\n\n if (request.signal.aborted) {\n return { shortCircuited: true };\n }\n\n // Clean up _after_ loaders have completed. Don't clean up if we short\n // circuited because fetchControllers would have been aborted and\n // reassigned to new controllers for the next navigation\n if (pendingNavigationController) {\n pendingNavigationController.signal.removeEventListener(\n \"abort\",\n abortPendingFetchRevalidations\n );\n }\n revalidatingFetchers.forEach((rf) => fetchControllers.delete(rf.key));\n\n // If any loaders returned a redirect Response, start a new REPLACE navigation\n let redirect = findRedirect(results);\n if (redirect) {\n if (redirect.idx >= matchesToLoad.length) {\n // If this redirect came from a fetcher make sure we mark it in\n // fetchRedirectIds so it doesn't get revalidated on the next set of\n // loader executions\n let fetcherKey =\n revalidatingFetchers[redirect.idx - matchesToLoad.length].key;\n fetchRedirectIds.add(fetcherKey);\n }\n await startRedirectNavigation(state, redirect.result, { replace });\n return { shortCircuited: true };\n }\n\n // Process and commit output from loaders\n let { loaderData, errors } = processLoaderData(\n state,\n matches,\n matchesToLoad,\n loaderResults,\n pendingError,\n revalidatingFetchers,\n fetcherResults,\n activeDeferreds\n );\n\n // Wire up subscribers to update loaderData as promises settle\n activeDeferreds.forEach((deferredData, routeId) => {\n deferredData.subscribe((aborted) => {\n // Note: No need to updateState here since the TrackedPromise on\n // loaderData is stable across resolve/reject\n // Remove this instance if we were aborted or if promises have settled\n if (aborted || deferredData.done) {\n activeDeferreds.delete(routeId);\n }\n });\n });\n\n let updatedFetchers = markFetchRedirectsDone();\n let didAbortFetchLoads = abortStaleFetchLoads(pendingNavigationLoadId);\n let shouldUpdateFetchers =\n updatedFetchers || didAbortFetchLoads || revalidatingFetchers.length > 0;\n\n return {\n loaderData,\n errors,\n ...(shouldUpdateFetchers ? { fetchers: new Map(state.fetchers) } : {}),\n };\n }\n\n function getFetcher(key: string): Fetcher {\n return state.fetchers.get(key) || IDLE_FETCHER;\n }\n\n // Trigger a fetcher load/submit for the given fetcher key\n function fetch(\n key: string,\n routeId: string,\n href: string | null,\n opts?: RouterFetchOptions\n ) {\n if (isServer) {\n throw new Error(\n \"router.fetch() was called during the server render, but it shouldn't be. \" +\n \"You are likely calling a useFetcher() method in the body of your component. \" +\n \"Try moving it to a useEffect or a callback.\"\n );\n }\n\n if (fetchControllers.has(key)) abortFetcher(key);\n\n let routesToUse = inFlightDataRoutes || dataRoutes;\n let normalizedPath = normalizeTo(\n state.location,\n state.matches,\n basename,\n future.v7_prependBasename,\n href,\n routeId,\n opts?.relative\n );\n let matches = matchRoutes(routesToUse, normalizedPath, basename);\n\n if (!matches) {\n setFetcherError(\n key,\n routeId,\n getInternalRouterError(404, { pathname: normalizedPath })\n );\n return;\n }\n\n let { path, submission, error } = normalizeNavigateOptions(\n future.v7_normalizeFormMethod,\n true,\n normalizedPath,\n opts\n );\n\n if (error) {\n setFetcherError(key, routeId, error);\n return;\n }\n\n let match = getTargetMatch(matches, path);\n\n pendingPreventScrollReset = (opts && opts.preventScrollReset) === true;\n\n if (submission && isMutationMethod(submission.formMethod)) {\n handleFetcherAction(key, routeId, path, match, matches, submission);\n return;\n }\n\n // Store off the match so we can call it's shouldRevalidate on subsequent\n // revalidations\n fetchLoadMatches.set(key, { routeId, path });\n handleFetcherLoader(key, routeId, path, match, matches, submission);\n }\n\n // Call the action for the matched fetcher.submit(), and then handle redirects,\n // errors, and revalidation\n async function handleFetcherAction(\n key: string,\n routeId: string,\n path: string,\n match: AgnosticDataRouteMatch,\n requestMatches: AgnosticDataRouteMatch[],\n submission: Submission\n ) {\n interruptActiveLoads();\n fetchLoadMatches.delete(key);\n\n if (!match.route.action && !match.route.lazy) {\n let error = getInternalRouterError(405, {\n method: submission.formMethod,\n pathname: path,\n routeId: routeId,\n });\n setFetcherError(key, routeId, error);\n return;\n }\n\n // Put this fetcher into it's submitting state\n let existingFetcher = state.fetchers.get(key);\n let fetcher = getSubmittingFetcher(submission, existingFetcher);\n state.fetchers.set(key, fetcher);\n updateState({ fetchers: new Map(state.fetchers) });\n\n // Call the action for the fetcher\n let abortController = new AbortController();\n let fetchRequest = createClientSideRequest(\n init.history,\n path,\n abortController.signal,\n submission\n );\n fetchControllers.set(key, abortController);\n\n let originatingLoadId = incrementingLoadId;\n let actionResult = await callLoaderOrAction(\n \"action\",\n fetchRequest,\n match,\n requestMatches,\n manifest,\n mapRouteProperties,\n basename\n );\n\n if (fetchRequest.signal.aborted) {\n // We can delete this so long as we weren't aborted by ou our own fetcher\n // re-submit which would have put _new_ controller is in fetchControllers\n if (fetchControllers.get(key) === abortController) {\n fetchControllers.delete(key);\n }\n return;\n }\n\n if (isRedirectResult(actionResult)) {\n fetchControllers.delete(key);\n if (pendingNavigationLoadId > originatingLoadId) {\n // A new navigation was kicked off after our action started, so that\n // should take precedence over this redirect navigation. We already\n // set isRevalidationRequired so all loaders for the new route should\n // fire unless opted out via shouldRevalidate\n let doneFetcher = getDoneFetcher(undefined);\n state.fetchers.set(key, doneFetcher);\n updateState({ fetchers: new Map(state.fetchers) });\n return;\n } else {\n fetchRedirectIds.add(key);\n let loadingFetcher = getLoadingFetcher(submission);\n state.fetchers.set(key, loadingFetcher);\n updateState({ fetchers: new Map(state.fetchers) });\n\n return startRedirectNavigation(state, actionResult, {\n submission,\n isFetchActionRedirect: true,\n });\n }\n }\n\n // Process any non-redirect errors thrown\n if (isErrorResult(actionResult)) {\n setFetcherError(key, routeId, actionResult.error);\n return;\n }\n\n if (isDeferredResult(actionResult)) {\n throw getInternalRouterError(400, { type: \"defer-action\" });\n }\n\n // Start the data load for current matches, or the next location if we're\n // in the middle of a navigation\n let nextLocation = state.navigation.location || state.location;\n let revalidationRequest = createClientSideRequest(\n init.history,\n nextLocation,\n abortController.signal\n );\n let routesToUse = inFlightDataRoutes || dataRoutes;\n let matches =\n state.navigation.state !== \"idle\"\n ? matchRoutes(routesToUse, state.navigation.location, basename)\n : state.matches;\n\n invariant(matches, \"Didn't find any matches after fetcher action\");\n\n let loadId = ++incrementingLoadId;\n fetchReloadIds.set(key, loadId);\n\n let loadFetcher = getLoadingFetcher(submission, actionResult.data);\n state.fetchers.set(key, loadFetcher);\n\n let [matchesToLoad, revalidatingFetchers] = getMatchesToLoad(\n init.history,\n state,\n matches,\n submission,\n nextLocation,\n isRevalidationRequired,\n cancelledDeferredRoutes,\n cancelledFetcherLoads,\n fetchLoadMatches,\n fetchRedirectIds,\n routesToUse,\n basename,\n { [match.route.id]: actionResult.data },\n undefined // No need to send through errors since we short circuit above\n );\n\n // Put all revalidating fetchers into the loading state, except for the\n // current fetcher which we want to keep in it's current loading state which\n // contains it's action submission info + action data\n revalidatingFetchers\n .filter((rf) => rf.key !== key)\n .forEach((rf) => {\n let staleKey = rf.key;\n let existingFetcher = state.fetchers.get(staleKey);\n let revalidatingFetcher = getLoadingFetcher(\n undefined,\n existingFetcher ? existingFetcher.data : undefined\n );\n state.fetchers.set(staleKey, revalidatingFetcher);\n if (fetchControllers.has(staleKey)) {\n abortFetcher(staleKey);\n }\n if (rf.controller) {\n fetchControllers.set(staleKey, rf.controller);\n }\n });\n\n updateState({ fetchers: new Map(state.fetchers) });\n\n let abortPendingFetchRevalidations = () =>\n revalidatingFetchers.forEach((rf) => abortFetcher(rf.key));\n\n abortController.signal.addEventListener(\n \"abort\",\n abortPendingFetchRevalidations\n );\n\n let { results, loaderResults, fetcherResults } =\n await callLoadersAndMaybeResolveData(\n state.matches,\n matches,\n matchesToLoad,\n revalidatingFetchers,\n revalidationRequest\n );\n\n if (abortController.signal.aborted) {\n return;\n }\n\n abortController.signal.removeEventListener(\n \"abort\",\n abortPendingFetchRevalidations\n );\n\n fetchReloadIds.delete(key);\n fetchControllers.delete(key);\n revalidatingFetchers.forEach((r) => fetchControllers.delete(r.key));\n\n let redirect = findRedirect(results);\n if (redirect) {\n if (redirect.idx >= matchesToLoad.length) {\n // If this redirect came from a fetcher make sure we mark it in\n // fetchRedirectIds so it doesn't get revalidated on the next set of\n // loader executions\n let fetcherKey =\n revalidatingFetchers[redirect.idx - matchesToLoad.length].key;\n fetchRedirectIds.add(fetcherKey);\n }\n return startRedirectNavigation(state, redirect.result);\n }\n\n // Process and commit output from loaders\n let { loaderData, errors } = processLoaderData(\n state,\n state.matches,\n matchesToLoad,\n loaderResults,\n undefined,\n revalidatingFetchers,\n fetcherResults,\n activeDeferreds\n );\n\n // Since we let revalidations complete even if the submitting fetcher was\n // deleted, only put it back to idle if it hasn't been deleted\n if (state.fetchers.has(key)) {\n let doneFetcher = getDoneFetcher(actionResult.data);\n state.fetchers.set(key, doneFetcher);\n }\n\n let didAbortFetchLoads = abortStaleFetchLoads(loadId);\n\n // If we are currently in a navigation loading state and this fetcher is\n // more recent than the navigation, we want the newer data so abort the\n // navigation and complete it with the fetcher data\n if (\n state.navigation.state === \"loading\" &&\n loadId > pendingNavigationLoadId\n ) {\n invariant(pendingAction, \"Expected pending action\");\n pendingNavigationController && pendingNavigationController.abort();\n\n completeNavigation(state.navigation.location, {\n matches,\n loaderData,\n errors,\n fetchers: new Map(state.fetchers),\n });\n } else {\n // otherwise just update with the fetcher data, preserving any existing\n // loaderData for loaders that did not need to reload. We have to\n // manually merge here since we aren't going through completeNavigation\n updateState({\n errors,\n loaderData: mergeLoaderData(\n state.loaderData,\n loaderData,\n matches,\n errors\n ),\n ...(didAbortFetchLoads || revalidatingFetchers.length > 0\n ? { fetchers: new Map(state.fetchers) }\n : {}),\n });\n isRevalidationRequired = false;\n }\n }\n\n // Call the matched loader for fetcher.load(), handling redirects, errors, etc.\n async function handleFetcherLoader(\n key: string,\n routeId: string,\n path: string,\n match: AgnosticDataRouteMatch,\n matches: AgnosticDataRouteMatch[],\n submission?: Submission\n ) {\n let existingFetcher = state.fetchers.get(key);\n // Put this fetcher into it's loading state\n let loadingFetcher = getLoadingFetcher(\n submission,\n existingFetcher ? existingFetcher.data : undefined\n );\n state.fetchers.set(key, loadingFetcher);\n updateState({ fetchers: new Map(state.fetchers) });\n\n // Call the loader for this fetcher route match\n let abortController = new AbortController();\n let fetchRequest = createClientSideRequest(\n init.history,\n path,\n abortController.signal\n );\n fetchControllers.set(key, abortController);\n\n let originatingLoadId = incrementingLoadId;\n let result: DataResult = await callLoaderOrAction(\n \"loader\",\n fetchRequest,\n match,\n matches,\n manifest,\n mapRouteProperties,\n basename\n );\n\n // Deferred isn't supported for fetcher loads, await everything and treat it\n // as a normal load. resolveDeferredData will return undefined if this\n // fetcher gets aborted, so we just leave result untouched and short circuit\n // below if that happens\n if (isDeferredResult(result)) {\n result =\n (await resolveDeferredData(result, fetchRequest.signal, true)) ||\n result;\n }\n\n // We can delete this so long as we weren't aborted by our our own fetcher\n // re-load which would have put _new_ controller is in fetchControllers\n if (fetchControllers.get(key) === abortController) {\n fetchControllers.delete(key);\n }\n\n if (fetchRequest.signal.aborted) {\n return;\n }\n\n // If the loader threw a redirect Response, start a new REPLACE navigation\n if (isRedirectResult(result)) {\n if (pendingNavigationLoadId > originatingLoadId) {\n // A new navigation was kicked off after our loader started, so that\n // should take precedence over this redirect navigation\n let doneFetcher = getDoneFetcher(undefined);\n state.fetchers.set(key, doneFetcher);\n updateState({ fetchers: new Map(state.fetchers) });\n return;\n } else {\n fetchRedirectIds.add(key);\n await startRedirectNavigation(state, result);\n return;\n }\n }\n\n // Process any non-redirect errors thrown\n if (isErrorResult(result)) {\n let boundaryMatch = findNearestBoundary(state.matches, routeId);\n state.fetchers.delete(key);\n // TODO: In remix, this would reset to IDLE_NAVIGATION if it was a catch -\n // do we need to behave any differently with our non-redirect errors?\n // What if it was a non-redirect Response?\n updateState({\n fetchers: new Map(state.fetchers),\n errors: {\n [boundaryMatch.route.id]: result.error,\n },\n });\n return;\n }\n\n invariant(!isDeferredResult(result), \"Unhandled fetcher deferred data\");\n\n // Put the fetcher back into an idle state\n let doneFetcher = getDoneFetcher(result.data);\n state.fetchers.set(key, doneFetcher);\n updateState({ fetchers: new Map(state.fetchers) });\n }\n\n /**\n * Utility function to handle redirects returned from an action or loader.\n * Normally, a redirect \"replaces\" the navigation that triggered it. So, for\n * example:\n *\n * - user is on /a\n * - user clicks a link to /b\n * - loader for /b redirects to /c\n *\n * In a non-JS app the browser would track the in-flight navigation to /b and\n * then replace it with /c when it encountered the redirect response. In\n * the end it would only ever update the URL bar with /c.\n *\n * In client-side routing using pushState/replaceState, we aim to emulate\n * this behavior and we also do not update history until the end of the\n * navigation (including processed redirects). This means that we never\n * actually touch history until we've processed redirects, so we just use\n * the history action from the original navigation (PUSH or REPLACE).\n */\n async function startRedirectNavigation(\n state: RouterState,\n redirect: RedirectResult,\n {\n submission,\n replace,\n isFetchActionRedirect,\n }: {\n submission?: Submission;\n replace?: boolean;\n isFetchActionRedirect?: boolean;\n } = {}\n ) {\n if (redirect.revalidate) {\n isRevalidationRequired = true;\n }\n\n let redirectLocation = createLocation(\n state.location,\n redirect.location,\n // TODO: This can be removed once we get rid of useTransition in Remix v2\n {\n _isRedirect: true,\n ...(isFetchActionRedirect ? { _isFetchActionRedirect: true } : {}),\n }\n );\n invariant(\n redirectLocation,\n \"Expected a location on the redirect navigation\"\n );\n // Check if this an absolute external redirect that goes to a new origin\n if (ABSOLUTE_URL_REGEX.test(redirect.location) && isBrowser) {\n let url = init.history.createURL(redirect.location);\n let isDifferentBasename = stripBasename(url.pathname, basename) == null;\n\n if (routerWindow.location.origin !== url.origin || isDifferentBasename) {\n if (replace) {\n routerWindow.location.replace(redirect.location);\n } else {\n routerWindow.location.assign(redirect.location);\n }\n return;\n }\n }\n\n // There's no need to abort on redirects, since we don't detect the\n // redirect until the action/loaders have settled\n pendingNavigationController = null;\n\n let redirectHistoryAction =\n replace === true ? HistoryAction.Replace : HistoryAction.Push;\n\n // Use the incoming submission if provided, fallback on the active one in\n // state.navigation\n let activeSubmission =\n submission || getSubmissionFromNavigation(state.navigation);\n\n // If this was a 307/308 submission we want to preserve the HTTP method and\n // re-submit the GET/POST/PUT/PATCH/DELETE as a submission navigation to the\n // redirected location\n if (\n redirectPreserveMethodStatusCodes.has(redirect.status) &&\n activeSubmission &&\n isMutationMethod(activeSubmission.formMethod)\n ) {\n await startNavigation(redirectHistoryAction, redirectLocation, {\n submission: {\n ...activeSubmission,\n formAction: redirect.location,\n },\n // Preserve this flag across redirects\n preventScrollReset: pendingPreventScrollReset,\n });\n } else if (isFetchActionRedirect) {\n // For a fetch action redirect, we kick off a new loading navigation\n // without the fetcher submission, but we send it along for shouldRevalidate\n await startNavigation(redirectHistoryAction, redirectLocation, {\n overrideNavigation: getLoadingNavigation(redirectLocation),\n fetcherSubmission: activeSubmission,\n // Preserve this flag across redirects\n preventScrollReset: pendingPreventScrollReset,\n });\n } else {\n // If we have a submission, we will preserve it through the redirect navigation\n let overrideNavigation = getLoadingNavigation(\n redirectLocation,\n activeSubmission\n );\n await startNavigation(redirectHistoryAction, redirectLocation, {\n overrideNavigation,\n // Preserve this flag across redirects\n preventScrollReset: pendingPreventScrollReset,\n });\n }\n }\n\n async function callLoadersAndMaybeResolveData(\n currentMatches: AgnosticDataRouteMatch[],\n matches: AgnosticDataRouteMatch[],\n matchesToLoad: AgnosticDataRouteMatch[],\n fetchersToLoad: RevalidatingFetcher[],\n request: Request\n ) {\n // Call all navigation loaders and revalidating fetcher loaders in parallel,\n // then slice off the results into separate arrays so we can handle them\n // accordingly\n let results = await Promise.all([\n ...matchesToLoad.map((match) =>\n callLoaderOrAction(\n \"loader\",\n request,\n match,\n matches,\n manifest,\n mapRouteProperties,\n basename\n )\n ),\n ...fetchersToLoad.map((f) => {\n if (f.matches && f.match && f.controller) {\n return callLoaderOrAction(\n \"loader\",\n createClientSideRequest(init.history, f.path, f.controller.signal),\n f.match,\n f.matches,\n manifest,\n mapRouteProperties,\n basename\n );\n } else {\n let error: ErrorResult = {\n type: ResultType.error,\n error: getInternalRouterError(404, { pathname: f.path }),\n };\n return error;\n }\n }),\n ]);\n let loaderResults = results.slice(0, matchesToLoad.length);\n let fetcherResults = results.slice(matchesToLoad.length);\n\n await Promise.all([\n resolveDeferredResults(\n currentMatches,\n matchesToLoad,\n loaderResults,\n loaderResults.map(() => request.signal),\n false,\n state.loaderData\n ),\n resolveDeferredResults(\n currentMatches,\n fetchersToLoad.map((f) => f.match),\n fetcherResults,\n fetchersToLoad.map((f) => (f.controller ? f.controller.signal : null)),\n true\n ),\n ]);\n\n return { results, loaderResults, fetcherResults };\n }\n\n function interruptActiveLoads() {\n // Every interruption triggers a revalidation\n isRevalidationRequired = true;\n\n // Cancel pending route-level deferreds and mark cancelled routes for\n // revalidation\n cancelledDeferredRoutes.push(...cancelActiveDeferreds());\n\n // Abort in-flight fetcher loads\n fetchLoadMatches.forEach((_, key) => {\n if (fetchControllers.has(key)) {\n cancelledFetcherLoads.push(key);\n abortFetcher(key);\n }\n });\n }\n\n function setFetcherError(key: string, routeId: string, error: any) {\n let boundaryMatch = findNearestBoundary(state.matches, routeId);\n deleteFetcher(key);\n updateState({\n errors: {\n [boundaryMatch.route.id]: error,\n },\n fetchers: new Map(state.fetchers),\n });\n }\n\n function deleteFetcher(key: string): void {\n let fetcher = state.fetchers.get(key);\n // Don't abort the controller if this is a deletion of a fetcher.submit()\n // in it's loading phase since - we don't want to abort the corresponding\n // revalidation and want them to complete and land\n if (\n fetchControllers.has(key) &&\n !(fetcher && fetcher.state === \"loading\" && fetchReloadIds.has(key))\n ) {\n abortFetcher(key);\n }\n fetchLoadMatches.delete(key);\n fetchReloadIds.delete(key);\n fetchRedirectIds.delete(key);\n state.fetchers.delete(key);\n }\n\n function abortFetcher(key: string) {\n let controller = fetchControllers.get(key);\n invariant(controller, `Expected fetch controller: ${key}`);\n controller.abort();\n fetchControllers.delete(key);\n }\n\n function markFetchersDone(keys: string[]) {\n for (let key of keys) {\n let fetcher = getFetcher(key);\n let doneFetcher = getDoneFetcher(fetcher.data);\n state.fetchers.set(key, doneFetcher);\n }\n }\n\n function markFetchRedirectsDone(): boolean {\n let doneKeys = [];\n let updatedFetchers = false;\n for (let key of fetchRedirectIds) {\n let fetcher = state.fetchers.get(key);\n invariant(fetcher, `Expected fetcher: ${key}`);\n if (fetcher.state === \"loading\") {\n fetchRedirectIds.delete(key);\n doneKeys.push(key);\n updatedFetchers = true;\n }\n }\n markFetchersDone(doneKeys);\n return updatedFetchers;\n }\n\n function abortStaleFetchLoads(landedId: number): boolean {\n let yeetedKeys = [];\n for (let [key, id] of fetchReloadIds) {\n if (id < landedId) {\n let fetcher = state.fetchers.get(key);\n invariant(fetcher, `Expected fetcher: ${key}`);\n if (fetcher.state === \"loading\") {\n abortFetcher(key);\n fetchReloadIds.delete(key);\n yeetedKeys.push(key);\n }\n }\n }\n markFetchersDone(yeetedKeys);\n return yeetedKeys.length > 0;\n }\n\n function getBlocker(key: string, fn: BlockerFunction) {\n let blocker: Blocker = state.blockers.get(key) || IDLE_BLOCKER;\n\n if (blockerFunctions.get(key) !== fn) {\n blockerFunctions.set(key, fn);\n }\n\n return blocker;\n }\n\n function deleteBlocker(key: string) {\n state.blockers.delete(key);\n blockerFunctions.delete(key);\n }\n\n // Utility function to update blockers, ensuring valid state transitions\n function updateBlocker(key: string, newBlocker: Blocker) {\n let blocker = state.blockers.get(key) || IDLE_BLOCKER;\n\n // Poor mans state machine :)\n // https://mermaid.live/edit#pako:eNqVkc9OwzAMxl8l8nnjAYrEtDIOHEBIgwvKJTReGy3_lDpIqO27k6awMG0XcrLlnz87nwdonESogKXXBuE79rq75XZO3-yHds0RJVuv70YrPlUrCEe2HfrORS3rubqZfuhtpg5C9wk5tZ4VKcRUq88q9Z8RS0-48cE1iHJkL0ugbHuFLus9L6spZy8nX9MP2CNdomVaposqu3fGayT8T8-jJQwhepo_UtpgBQaDEUom04dZhAN1aJBDlUKJBxE1ceB2Smj0Mln-IBW5AFU2dwUiktt_2Qaq2dBfaKdEup85UV7Yd-dKjlnkabl2Pvr0DTkTreM\n invariant(\n (blocker.state === \"unblocked\" && newBlocker.state === \"blocked\") ||\n (blocker.state === \"blocked\" && newBlocker.state === \"blocked\") ||\n (blocker.state === \"blocked\" && newBlocker.state === \"proceeding\") ||\n (blocker.state === \"blocked\" && newBlocker.state === \"unblocked\") ||\n (blocker.state === \"proceeding\" && newBlocker.state === \"unblocked\"),\n `Invalid blocker state transition: ${blocker.state} -> ${newBlocker.state}`\n );\n\n let blockers = new Map(state.blockers);\n blockers.set(key, newBlocker);\n updateState({ blockers });\n }\n\n function shouldBlockNavigation({\n currentLocation,\n nextLocation,\n historyAction,\n }: {\n currentLocation: Location;\n nextLocation: Location;\n historyAction: HistoryAction;\n }): string | undefined {\n if (blockerFunctions.size === 0) {\n return;\n }\n\n // We ony support a single active blocker at the moment since we don't have\n // any compelling use cases for multi-blocker yet\n if (blockerFunctions.size > 1) {\n warning(false, \"A router only supports one blocker at a time\");\n }\n\n let entries = Array.from(blockerFunctions.entries());\n let [blockerKey, blockerFunction] = entries[entries.length - 1];\n let blocker = state.blockers.get(blockerKey);\n\n if (blocker && blocker.state === \"proceeding\") {\n // If the blocker is currently proceeding, we don't need to re-check\n // it and can let this navigation continue\n return;\n }\n\n // At this point, we know we're unblocked/blocked so we need to check the\n // user-provided blocker function\n if (blockerFunction({ currentLocation, nextLocation, historyAction })) {\n return blockerKey;\n }\n }\n\n function cancelActiveDeferreds(\n predicate?: (routeId: string) => boolean\n ): string[] {\n let cancelledRouteIds: string[] = [];\n activeDeferreds.forEach((dfd, routeId) => {\n if (!predicate || predicate(routeId)) {\n // Cancel the deferred - but do not remove from activeDeferreds here -\n // we rely on the subscribers to do that so our tests can assert proper\n // cleanup via _internalActiveDeferreds\n dfd.cancel();\n cancelledRouteIds.push(routeId);\n activeDeferreds.delete(routeId);\n }\n });\n return cancelledRouteIds;\n }\n\n // Opt in to capturing and reporting scroll positions during navigations,\n // used by the component\n function enableScrollRestoration(\n positions: Record,\n getPosition: GetScrollPositionFunction,\n getKey?: GetScrollRestorationKeyFunction\n ) {\n savedScrollPositions = positions;\n getScrollPosition = getPosition;\n getScrollRestorationKey = getKey || null;\n\n // Perform initial hydration scroll restoration, since we miss the boat on\n // the initial updateState() because we've not yet rendered \n // and therefore have no savedScrollPositions available\n if (!initialScrollRestored && state.navigation === IDLE_NAVIGATION) {\n initialScrollRestored = true;\n let y = getSavedScrollPosition(state.location, state.matches);\n if (y != null) {\n updateState({ restoreScrollPosition: y });\n }\n }\n\n return () => {\n savedScrollPositions = null;\n getScrollPosition = null;\n getScrollRestorationKey = null;\n };\n }\n\n function getScrollKey(location: Location, matches: AgnosticDataRouteMatch[]) {\n if (getScrollRestorationKey) {\n let key = getScrollRestorationKey(\n location,\n matches.map((m) => createUseMatchesMatch(m, state.loaderData))\n );\n return key || location.key;\n }\n return location.key;\n }\n\n function saveScrollPosition(\n location: Location,\n matches: AgnosticDataRouteMatch[]\n ): void {\n if (savedScrollPositions && getScrollPosition) {\n let key = getScrollKey(location, matches);\n savedScrollPositions[key] = getScrollPosition();\n }\n }\n\n function getSavedScrollPosition(\n location: Location,\n matches: AgnosticDataRouteMatch[]\n ): number | null {\n if (savedScrollPositions) {\n let key = getScrollKey(location, matches);\n let y = savedScrollPositions[key];\n if (typeof y === \"number\") {\n return y;\n }\n }\n return null;\n }\n\n function _internalSetRoutes(newRoutes: AgnosticDataRouteObject[]) {\n manifest = {};\n inFlightDataRoutes = convertRoutesToDataRoutes(\n newRoutes,\n mapRouteProperties,\n undefined,\n manifest\n );\n }\n\n router = {\n get basename() {\n return basename;\n },\n get state() {\n return state;\n },\n get routes() {\n return dataRoutes;\n },\n initialize,\n subscribe,\n enableScrollRestoration,\n navigate,\n fetch,\n revalidate,\n // Passthrough to history-aware createHref used by useHref so we get proper\n // hash-aware URLs in DOM paths\n createHref: (to: To) => init.history.createHref(to),\n encodeLocation: (to: To) => init.history.encodeLocation(to),\n getFetcher,\n deleteFetcher,\n dispose,\n getBlocker,\n deleteBlocker,\n _internalFetchControllers: fetchControllers,\n _internalActiveDeferreds: activeDeferreds,\n // TODO: Remove setRoutes, it's temporary to avoid dealing with\n // updating the tree while validating the update algorithm.\n _internalSetRoutes,\n };\n\n return router;\n}\n//#endregion\n\n////////////////////////////////////////////////////////////////////////////////\n//#region createStaticHandler\n////////////////////////////////////////////////////////////////////////////////\n\nexport const UNSAFE_DEFERRED_SYMBOL = Symbol(\"deferred\");\n\nexport interface CreateStaticHandlerOptions {\n basename?: string;\n /**\n * @deprecated Use `mapRouteProperties` instead\n */\n detectErrorBoundary?: DetectErrorBoundaryFunction;\n mapRouteProperties?: MapRoutePropertiesFunction;\n}\n\nexport function createStaticHandler(\n routes: AgnosticRouteObject[],\n opts?: CreateStaticHandlerOptions\n): StaticHandler {\n invariant(\n routes.length > 0,\n \"You must provide a non-empty routes array to createStaticHandler\"\n );\n\n let manifest: RouteManifest = {};\n let basename = (opts ? opts.basename : null) || \"/\";\n let mapRouteProperties: MapRoutePropertiesFunction;\n if (opts?.mapRouteProperties) {\n mapRouteProperties = opts.mapRouteProperties;\n } else if (opts?.detectErrorBoundary) {\n // If they are still using the deprecated version, wrap it with the new API\n let detectErrorBoundary = opts.detectErrorBoundary;\n mapRouteProperties = (route) => ({\n hasErrorBoundary: detectErrorBoundary(route),\n });\n } else {\n mapRouteProperties = defaultMapRouteProperties;\n }\n\n let dataRoutes = convertRoutesToDataRoutes(\n routes,\n mapRouteProperties,\n undefined,\n manifest\n );\n\n /**\n * The query() method is intended for document requests, in which we want to\n * call an optional action and potentially multiple loaders for all nested\n * routes. It returns a StaticHandlerContext object, which is very similar\n * to the router state (location, loaderData, actionData, errors, etc.) and\n * also adds SSR-specific information such as the statusCode and headers\n * from action/loaders Responses.\n *\n * It _should_ never throw and should report all errors through the\n * returned context.errors object, properly associating errors to their error\n * boundary. Additionally, it tracks _deepestRenderedBoundaryId which can be\n * used to emulate React error boundaries during SSr by performing a second\n * pass only down to the boundaryId.\n *\n * The one exception where we do not return a StaticHandlerContext is when a\n * redirect response is returned or thrown from any action/loader. We\n * propagate that out and return the raw Response so the HTTP server can\n * return it directly.\n */\n async function query(\n request: Request,\n { requestContext }: { requestContext?: unknown } = {}\n ): Promise {\n let url = new URL(request.url);\n let method = request.method;\n let location = createLocation(\"\", createPath(url), null, \"default\");\n let matches = matchRoutes(dataRoutes, location, basename);\n\n // SSR supports HEAD requests while SPA doesn't\n if (!isValidMethod(method) && method !== \"HEAD\") {\n let error = getInternalRouterError(405, { method });\n let { matches: methodNotAllowedMatches, route } =\n getShortCircuitMatches(dataRoutes);\n return {\n basename,\n location,\n matches: methodNotAllowedMatches,\n loaderData: {},\n actionData: null,\n errors: {\n [route.id]: error,\n },\n statusCode: error.status,\n loaderHeaders: {},\n actionHeaders: {},\n activeDeferreds: null,\n };\n } else if (!matches) {\n let error = getInternalRouterError(404, { pathname: location.pathname });\n let { matches: notFoundMatches, route } =\n getShortCircuitMatches(dataRoutes);\n return {\n basename,\n location,\n matches: notFoundMatches,\n loaderData: {},\n actionData: null,\n errors: {\n [route.id]: error,\n },\n statusCode: error.status,\n loaderHeaders: {},\n actionHeaders: {},\n activeDeferreds: null,\n };\n }\n\n let result = await queryImpl(request, location, matches, requestContext);\n if (isResponse(result)) {\n return result;\n }\n\n // When returning StaticHandlerContext, we patch back in the location here\n // since we need it for React Context. But this helps keep our submit and\n // loadRouteData operating on a Request instead of a Location\n return { location, basename, ...result };\n }\n\n /**\n * The queryRoute() method is intended for targeted route requests, either\n * for fetch ?_data requests or resource route requests. In this case, we\n * are only ever calling a single action or loader, and we are returning the\n * returned value directly. In most cases, this will be a Response returned\n * from the action/loader, but it may be a primitive or other value as well -\n * and in such cases the calling context should handle that accordingly.\n *\n * We do respect the throw/return differentiation, so if an action/loader\n * throws, then this method will throw the value. This is important so we\n * can do proper boundary identification in Remix where a thrown Response\n * must go to the Catch Boundary but a returned Response is happy-path.\n *\n * One thing to note is that any Router-initiated Errors that make sense\n * to associate with a status code will be thrown as an ErrorResponse\n * instance which include the raw Error, such that the calling context can\n * serialize the error as they see fit while including the proper response\n * code. Examples here are 404 and 405 errors that occur prior to reaching\n * any user-defined loaders.\n */\n async function queryRoute(\n request: Request,\n {\n routeId,\n requestContext,\n }: { requestContext?: unknown; routeId?: string } = {}\n ): Promise {\n let url = new URL(request.url);\n let method = request.method;\n let location = createLocation(\"\", createPath(url), null, \"default\");\n let matches = matchRoutes(dataRoutes, location, basename);\n\n // SSR supports HEAD requests while SPA doesn't\n if (!isValidMethod(method) && method !== \"HEAD\" && method !== \"OPTIONS\") {\n throw getInternalRouterError(405, { method });\n } else if (!matches) {\n throw getInternalRouterError(404, { pathname: location.pathname });\n }\n\n let match = routeId\n ? matches.find((m) => m.route.id === routeId)\n : getTargetMatch(matches, location);\n\n if (routeId && !match) {\n throw getInternalRouterError(403, {\n pathname: location.pathname,\n routeId,\n });\n } else if (!match) {\n // This should never hit I don't think?\n throw getInternalRouterError(404, { pathname: location.pathname });\n }\n\n let result = await queryImpl(\n request,\n location,\n matches,\n requestContext,\n match\n );\n if (isResponse(result)) {\n return result;\n }\n\n let error = result.errors ? Object.values(result.errors)[0] : undefined;\n if (error !== undefined) {\n // If we got back result.errors, that means the loader/action threw\n // _something_ that wasn't a Response, but it's not guaranteed/required\n // to be an `instanceof Error` either, so we have to use throw here to\n // preserve the \"error\" state outside of queryImpl.\n throw error;\n }\n\n // Pick off the right state value to return\n if (result.actionData) {\n return Object.values(result.actionData)[0];\n }\n\n if (result.loaderData) {\n let data = Object.values(result.loaderData)[0];\n if (result.activeDeferreds?.[match.route.id]) {\n data[UNSAFE_DEFERRED_SYMBOL] = result.activeDeferreds[match.route.id];\n }\n return data;\n }\n\n return undefined;\n }\n\n async function queryImpl(\n request: Request,\n location: Location,\n matches: AgnosticDataRouteMatch[],\n requestContext: unknown,\n routeMatch?: AgnosticDataRouteMatch\n ): Promise | Response> {\n invariant(\n request.signal,\n \"query()/queryRoute() requests must contain an AbortController signal\"\n );\n\n try {\n if (isMutationMethod(request.method.toLowerCase())) {\n let result = await submit(\n request,\n matches,\n routeMatch || getTargetMatch(matches, location),\n requestContext,\n routeMatch != null\n );\n return result;\n }\n\n let result = await loadRouteData(\n request,\n matches,\n requestContext,\n routeMatch\n );\n return isResponse(result)\n ? result\n : {\n ...result,\n actionData: null,\n actionHeaders: {},\n };\n } catch (e) {\n // If the user threw/returned a Response in callLoaderOrAction, we throw\n // it to bail out and then return or throw here based on whether the user\n // returned or threw\n if (isQueryRouteResponse(e)) {\n if (e.type === ResultType.error && !isRedirectResponse(e.response)) {\n throw e.response;\n }\n return e.response;\n }\n // Redirects are always returned since they don't propagate to catch\n // boundaries\n if (isRedirectResponse(e)) {\n return e;\n }\n throw e;\n }\n }\n\n async function submit(\n request: Request,\n matches: AgnosticDataRouteMatch[],\n actionMatch: AgnosticDataRouteMatch,\n requestContext: unknown,\n isRouteRequest: boolean\n ): Promise | Response> {\n let result: DataResult;\n\n if (!actionMatch.route.action && !actionMatch.route.lazy) {\n let error = getInternalRouterError(405, {\n method: request.method,\n pathname: new URL(request.url).pathname,\n routeId: actionMatch.route.id,\n });\n if (isRouteRequest) {\n throw error;\n }\n result = {\n type: ResultType.error,\n error,\n };\n } else {\n result = await callLoaderOrAction(\n \"action\",\n request,\n actionMatch,\n matches,\n manifest,\n mapRouteProperties,\n basename,\n { isStaticRequest: true, isRouteRequest, requestContext }\n );\n\n if (request.signal.aborted) {\n let method = isRouteRequest ? \"queryRoute\" : \"query\";\n throw new Error(`${method}() call aborted`);\n }\n }\n\n if (isRedirectResult(result)) {\n // Uhhhh - this should never happen, we should always throw these from\n // callLoaderOrAction, but the type narrowing here keeps TS happy and we\n // can get back on the \"throw all redirect responses\" train here should\n // this ever happen :/\n throw new Response(null, {\n status: result.status,\n headers: {\n Location: result.location,\n },\n });\n }\n\n if (isDeferredResult(result)) {\n let error = getInternalRouterError(400, { type: \"defer-action\" });\n if (isRouteRequest) {\n throw error;\n }\n result = {\n type: ResultType.error,\n error,\n };\n }\n\n if (isRouteRequest) {\n // Note: This should only be non-Response values if we get here, since\n // isRouteRequest should throw any Response received in callLoaderOrAction\n if (isErrorResult(result)) {\n throw result.error;\n }\n\n return {\n matches: [actionMatch],\n loaderData: {},\n actionData: { [actionMatch.route.id]: result.data },\n errors: null,\n // Note: statusCode + headers are unused here since queryRoute will\n // return the raw Response or value\n statusCode: 200,\n loaderHeaders: {},\n actionHeaders: {},\n activeDeferreds: null,\n };\n }\n\n if (isErrorResult(result)) {\n // Store off the pending error - we use it to determine which loaders\n // to call and will commit it when we complete the navigation\n let boundaryMatch = findNearestBoundary(matches, actionMatch.route.id);\n let context = await loadRouteData(\n request,\n matches,\n requestContext,\n undefined,\n {\n [boundaryMatch.route.id]: result.error,\n }\n );\n\n // action status codes take precedence over loader status codes\n return {\n ...context,\n statusCode: isRouteErrorResponse(result.error)\n ? result.error.status\n : 500,\n actionData: null,\n actionHeaders: {\n ...(result.headers ? { [actionMatch.route.id]: result.headers } : {}),\n },\n };\n }\n\n // Create a GET request for the loaders\n let loaderRequest = new Request(request.url, {\n headers: request.headers,\n redirect: request.redirect,\n signal: request.signal,\n });\n let context = await loadRouteData(loaderRequest, matches, requestContext);\n\n return {\n ...context,\n // action status codes take precedence over loader status codes\n ...(result.statusCode ? { statusCode: result.statusCode } : {}),\n actionData: {\n [actionMatch.route.id]: result.data,\n },\n actionHeaders: {\n ...(result.headers ? { [actionMatch.route.id]: result.headers } : {}),\n },\n };\n }\n\n async function loadRouteData(\n request: Request,\n matches: AgnosticDataRouteMatch[],\n requestContext: unknown,\n routeMatch?: AgnosticDataRouteMatch,\n pendingActionError?: RouteData\n ): Promise<\n | Omit<\n StaticHandlerContext,\n \"location\" | \"basename\" | \"actionData\" | \"actionHeaders\"\n >\n | Response\n > {\n let isRouteRequest = routeMatch != null;\n\n // Short circuit if we have no loaders to run (queryRoute())\n if (\n isRouteRequest &&\n !routeMatch?.route.loader &&\n !routeMatch?.route.lazy\n ) {\n throw getInternalRouterError(400, {\n method: request.method,\n pathname: new URL(request.url).pathname,\n routeId: routeMatch?.route.id,\n });\n }\n\n let requestMatches = routeMatch\n ? [routeMatch]\n : getLoaderMatchesUntilBoundary(\n matches,\n Object.keys(pendingActionError || {})[0]\n );\n let matchesToLoad = requestMatches.filter(\n (m) => m.route.loader || m.route.lazy\n );\n\n // Short circuit if we have no loaders to run (query())\n if (matchesToLoad.length === 0) {\n return {\n matches,\n // Add a null for all matched routes for proper revalidation on the client\n loaderData: matches.reduce(\n (acc, m) => Object.assign(acc, { [m.route.id]: null }),\n {}\n ),\n errors: pendingActionError || null,\n statusCode: 200,\n loaderHeaders: {},\n activeDeferreds: null,\n };\n }\n\n let results = await Promise.all([\n ...matchesToLoad.map((match) =>\n callLoaderOrAction(\n \"loader\",\n request,\n match,\n matches,\n manifest,\n mapRouteProperties,\n basename,\n { isStaticRequest: true, isRouteRequest, requestContext }\n )\n ),\n ]);\n\n if (request.signal.aborted) {\n let method = isRouteRequest ? \"queryRoute\" : \"query\";\n throw new Error(`${method}() call aborted`);\n }\n\n // Process and commit output from loaders\n let activeDeferreds = new Map();\n let context = processRouteLoaderData(\n matches,\n matchesToLoad,\n results,\n pendingActionError,\n activeDeferreds\n );\n\n // Add a null for any non-loader matches for proper revalidation on the client\n let executedLoaders = new Set(\n matchesToLoad.map((match) => match.route.id)\n );\n matches.forEach((match) => {\n if (!executedLoaders.has(match.route.id)) {\n context.loaderData[match.route.id] = null;\n }\n });\n\n return {\n ...context,\n matches,\n activeDeferreds:\n activeDeferreds.size > 0\n ? Object.fromEntries(activeDeferreds.entries())\n : null,\n };\n }\n\n return {\n dataRoutes,\n query,\n queryRoute,\n };\n}\n\n//#endregion\n\n////////////////////////////////////////////////////////////////////////////////\n//#region Helpers\n////////////////////////////////////////////////////////////////////////////////\n\n/**\n * Given an existing StaticHandlerContext and an error thrown at render time,\n * provide an updated StaticHandlerContext suitable for a second SSR render\n */\nexport function getStaticContextFromError(\n routes: AgnosticDataRouteObject[],\n context: StaticHandlerContext,\n error: any\n) {\n let newContext: StaticHandlerContext = {\n ...context,\n statusCode: 500,\n errors: {\n [context._deepestRenderedBoundaryId || routes[0].id]: error,\n },\n };\n return newContext;\n}\n\nfunction isSubmissionNavigation(\n opts: RouterNavigateOptions\n): opts is SubmissionNavigateOptions {\n return (\n opts != null &&\n ((\"formData\" in opts && opts.formData != null) ||\n (\"body\" in opts && opts.body !== undefined))\n );\n}\n\nfunction normalizeTo(\n location: Path,\n matches: AgnosticDataRouteMatch[],\n basename: string,\n prependBasename: boolean,\n to: To | null,\n fromRouteId?: string,\n relative?: RelativeRoutingType\n) {\n let contextualMatches: AgnosticDataRouteMatch[];\n let activeRouteMatch: AgnosticDataRouteMatch | undefined;\n if (fromRouteId != null && relative !== \"path\") {\n // Grab matches up to the calling route so our route-relative logic is\n // relative to the correct source route. When using relative:path,\n // fromRouteId is ignored since that is always relative to the current\n // location path\n contextualMatches = [];\n for (let match of matches) {\n contextualMatches.push(match);\n if (match.route.id === fromRouteId) {\n activeRouteMatch = match;\n break;\n }\n }\n } else {\n contextualMatches = matches;\n activeRouteMatch = matches[matches.length - 1];\n }\n\n // Resolve the relative path\n let path = resolveTo(\n to ? to : \".\",\n getPathContributingMatches(contextualMatches).map((m) => m.pathnameBase),\n stripBasename(location.pathname, basename) || location.pathname,\n relative === \"path\"\n );\n\n // When `to` is not specified we inherit search/hash from the current\n // location, unlike when to=\".\" and we just inherit the path.\n // See https://github.com/remix-run/remix/issues/927\n if (to == null) {\n path.search = location.search;\n path.hash = location.hash;\n }\n\n // Add an ?index param for matched index routes if we don't already have one\n if (\n (to == null || to === \"\" || to === \".\") &&\n activeRouteMatch &&\n activeRouteMatch.route.index &&\n !hasNakedIndexQuery(path.search)\n ) {\n path.search = path.search\n ? path.search.replace(/^\\?/, \"?index&\")\n : \"?index\";\n }\n\n // If we're operating within a basename, prepend it to the pathname. If\n // this is a root navigation, then just use the raw basename which allows\n // the basename to have full control over the presence of a trailing slash\n // on root actions\n if (prependBasename && basename !== \"/\") {\n path.pathname =\n path.pathname === \"/\" ? basename : joinPaths([basename, path.pathname]);\n }\n\n return createPath(path);\n}\n\n// Normalize navigation options by converting formMethod=GET formData objects to\n// URLSearchParams so they behave identically to links with query params\nfunction normalizeNavigateOptions(\n normalizeFormMethod: boolean,\n isFetcher: boolean,\n path: string,\n opts?: RouterNavigateOptions\n): {\n path: string;\n submission?: Submission;\n error?: ErrorResponse;\n} {\n // Return location verbatim on non-submission navigations\n if (!opts || !isSubmissionNavigation(opts)) {\n return { path };\n }\n\n if (opts.formMethod && !isValidMethod(opts.formMethod)) {\n return {\n path,\n error: getInternalRouterError(405, { method: opts.formMethod }),\n };\n }\n\n let getInvalidBodyError = () => ({\n path,\n error: getInternalRouterError(400, { type: \"invalid-body\" }),\n });\n\n // Create a Submission on non-GET navigations\n let rawFormMethod = opts.formMethod || \"get\";\n let formMethod = normalizeFormMethod\n ? (rawFormMethod.toUpperCase() as V7_FormMethod)\n : (rawFormMethod.toLowerCase() as FormMethod);\n let formAction = stripHashFromPath(path);\n\n if (opts.body !== undefined) {\n if (opts.formEncType === \"text/plain\") {\n // text only support POST/PUT/PATCH/DELETE submissions\n if (!isMutationMethod(formMethod)) {\n return getInvalidBodyError();\n }\n\n let text =\n typeof opts.body === \"string\"\n ? opts.body\n : opts.body instanceof FormData ||\n opts.body instanceof URLSearchParams\n ? // https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#plain-text-form-data\n Array.from(opts.body.entries()).reduce(\n (acc, [name, value]) => `${acc}${name}=${value}\\n`,\n \"\"\n )\n : String(opts.body);\n\n return {\n path,\n submission: {\n formMethod,\n formAction,\n formEncType: opts.formEncType,\n formData: undefined,\n json: undefined,\n text,\n },\n };\n } else if (opts.formEncType === \"application/json\") {\n // json only supports POST/PUT/PATCH/DELETE submissions\n if (!isMutationMethod(formMethod)) {\n return getInvalidBodyError();\n }\n\n try {\n let json =\n typeof opts.body === \"string\" ? JSON.parse(opts.body) : opts.body;\n\n return {\n path,\n submission: {\n formMethod,\n formAction,\n formEncType: opts.formEncType,\n formData: undefined,\n json,\n text: undefined,\n },\n };\n } catch (e) {\n return getInvalidBodyError();\n }\n }\n }\n\n invariant(\n typeof FormData === \"function\",\n \"FormData is not available in this environment\"\n );\n\n let searchParams: URLSearchParams;\n let formData: FormData;\n\n if (opts.formData) {\n searchParams = convertFormDataToSearchParams(opts.formData);\n formData = opts.formData;\n } else if (opts.body instanceof FormData) {\n searchParams = convertFormDataToSearchParams(opts.body);\n formData = opts.body;\n } else if (opts.body instanceof URLSearchParams) {\n searchParams = opts.body;\n formData = convertSearchParamsToFormData(searchParams);\n } else if (opts.body == null) {\n searchParams = new URLSearchParams();\n formData = new FormData();\n } else {\n try {\n searchParams = new URLSearchParams(opts.body);\n formData = convertSearchParamsToFormData(searchParams);\n } catch (e) {\n return getInvalidBodyError();\n }\n }\n\n let submission: Submission = {\n formMethod,\n formAction,\n formEncType:\n (opts && opts.formEncType) || \"application/x-www-form-urlencoded\",\n formData,\n json: undefined,\n text: undefined,\n };\n\n if (isMutationMethod(submission.formMethod)) {\n return { path, submission };\n }\n\n // Flatten submission onto URLSearchParams for GET submissions\n let parsedPath = parsePath(path);\n // On GET navigation submissions we can drop the ?index param from the\n // resulting location since all loaders will run. But fetcher GET submissions\n // only run a single loader so we need to preserve any incoming ?index params\n if (isFetcher && parsedPath.search && hasNakedIndexQuery(parsedPath.search)) {\n searchParams.append(\"index\", \"\");\n }\n parsedPath.search = `?${searchParams}`;\n\n return { path: createPath(parsedPath), submission };\n}\n\n// Filter out all routes below any caught error as they aren't going to\n// render so we don't need to load them\nfunction getLoaderMatchesUntilBoundary(\n matches: AgnosticDataRouteMatch[],\n boundaryId?: string\n) {\n let boundaryMatches = matches;\n if (boundaryId) {\n let index = matches.findIndex((m) => m.route.id === boundaryId);\n if (index >= 0) {\n boundaryMatches = matches.slice(0, index);\n }\n }\n return boundaryMatches;\n}\n\nfunction getMatchesToLoad(\n history: History,\n state: RouterState,\n matches: AgnosticDataRouteMatch[],\n submission: Submission | undefined,\n location: Location,\n isRevalidationRequired: boolean,\n cancelledDeferredRoutes: string[],\n cancelledFetcherLoads: string[],\n fetchLoadMatches: Map,\n fetchRedirectIds: Set,\n routesToUse: AgnosticDataRouteObject[],\n basename: string | undefined,\n pendingActionData?: RouteData,\n pendingError?: RouteData\n): [AgnosticDataRouteMatch[], RevalidatingFetcher[]] {\n let actionResult = pendingError\n ? Object.values(pendingError)[0]\n : pendingActionData\n ? Object.values(pendingActionData)[0]\n : undefined;\n\n let currentUrl = history.createURL(state.location);\n let nextUrl = history.createURL(location);\n\n // Pick navigation matches that are net-new or qualify for revalidation\n let boundaryId = pendingError ? Object.keys(pendingError)[0] : undefined;\n let boundaryMatches = getLoaderMatchesUntilBoundary(matches, boundaryId);\n\n let navigationMatches = boundaryMatches.filter((match, index) => {\n if (match.route.lazy) {\n // We haven't loaded this route yet so we don't know if it's got a loader!\n return true;\n }\n if (match.route.loader == null) {\n return false;\n }\n\n // Always call the loader on new route instances and pending defer cancellations\n if (\n isNewLoader(state.loaderData, state.matches[index], match) ||\n cancelledDeferredRoutes.some((id) => id === match.route.id)\n ) {\n return true;\n }\n\n // This is the default implementation for when we revalidate. If the route\n // provides it's own implementation, then we give them full control but\n // provide this value so they can leverage it if needed after they check\n // their own specific use cases\n let currentRouteMatch = state.matches[index];\n let nextRouteMatch = match;\n\n return shouldRevalidateLoader(match, {\n currentUrl,\n currentParams: currentRouteMatch.params,\n nextUrl,\n nextParams: nextRouteMatch.params,\n ...submission,\n actionResult,\n defaultShouldRevalidate:\n // Forced revalidation due to submission, useRevalidator, or X-Remix-Revalidate\n isRevalidationRequired ||\n // Clicked the same link, resubmitted a GET form\n currentUrl.pathname + currentUrl.search ===\n nextUrl.pathname + nextUrl.search ||\n // Search params affect all loaders\n currentUrl.search !== nextUrl.search ||\n isNewRouteInstance(currentRouteMatch, nextRouteMatch),\n });\n });\n\n // Pick fetcher.loads that need to be revalidated\n let revalidatingFetchers: RevalidatingFetcher[] = [];\n fetchLoadMatches.forEach((f, key) => {\n // Don't revalidate if fetcher won't be present in the subsequent render\n if (!matches.some((m) => m.route.id === f.routeId)) {\n return;\n }\n\n let fetcherMatches = matchRoutes(routesToUse, f.path, basename);\n\n // If the fetcher path no longer matches, push it in with null matches so\n // we can trigger a 404 in callLoadersAndMaybeResolveData. Note this is\n // currently only a use-case for Remix HMR where the route tree can change\n // at runtime and remove a route previously loaded via a fetcher\n if (!fetcherMatches) {\n revalidatingFetchers.push({\n key,\n routeId: f.routeId,\n path: f.path,\n matches: null,\n match: null,\n controller: null,\n });\n return;\n }\n\n // Revalidating fetchers are decoupled from the route matches since they\n // load from a static href. They revalidate based on explicit revalidation\n // (submission, useRevalidator, or X-Remix-Revalidate)\n let fetcher = state.fetchers.get(key);\n let fetcherMatch = getTargetMatch(fetcherMatches, f.path);\n\n let shouldRevalidate = false;\n if (fetchRedirectIds.has(key)) {\n // Never trigger a revalidation of an actively redirecting fetcher\n shouldRevalidate = false;\n } else if (cancelledFetcherLoads.includes(key)) {\n // Always revalidate if the fetcher was cancelled\n shouldRevalidate = true;\n } else if (\n fetcher &&\n fetcher.state !== \"idle\" &&\n fetcher.data === undefined\n ) {\n // If the fetcher hasn't ever completed loading yet, then this isn't a\n // revalidation, it would just be a brand new load if an explicit\n // revalidation is required\n shouldRevalidate = isRevalidationRequired;\n } else {\n // Otherwise fall back on any user-defined shouldRevalidate, defaulting\n // to explicit revalidations only\n shouldRevalidate = shouldRevalidateLoader(fetcherMatch, {\n currentUrl,\n currentParams: state.matches[state.matches.length - 1].params,\n nextUrl,\n nextParams: matches[matches.length - 1].params,\n ...submission,\n actionResult,\n defaultShouldRevalidate: isRevalidationRequired,\n });\n }\n\n if (shouldRevalidate) {\n revalidatingFetchers.push({\n key,\n routeId: f.routeId,\n path: f.path,\n matches: fetcherMatches,\n match: fetcherMatch,\n controller: new AbortController(),\n });\n }\n });\n\n return [navigationMatches, revalidatingFetchers];\n}\n\nfunction isNewLoader(\n currentLoaderData: RouteData,\n currentMatch: AgnosticDataRouteMatch,\n match: AgnosticDataRouteMatch\n) {\n let isNew =\n // [a] -> [a, b]\n !currentMatch ||\n // [a, b] -> [a, c]\n match.route.id !== currentMatch.route.id;\n\n // Handle the case that we don't have data for a re-used route, potentially\n // from a prior error or from a cancelled pending deferred\n let isMissingData = currentLoaderData[match.route.id] === undefined;\n\n // Always load if this is a net-new route or we don't yet have data\n return isNew || isMissingData;\n}\n\nfunction isNewRouteInstance(\n currentMatch: AgnosticDataRouteMatch,\n match: AgnosticDataRouteMatch\n) {\n let currentPath = currentMatch.route.path;\n return (\n // param change for this match, /users/123 -> /users/456\n currentMatch.pathname !== match.pathname ||\n // splat param changed, which is not present in match.path\n // e.g. /files/images/avatar.jpg -> files/finances.xls\n (currentPath != null &&\n currentPath.endsWith(\"*\") &&\n currentMatch.params[\"*\"] !== match.params[\"*\"])\n );\n}\n\nfunction shouldRevalidateLoader(\n loaderMatch: AgnosticDataRouteMatch,\n arg: Parameters[0]\n) {\n if (loaderMatch.route.shouldRevalidate) {\n let routeChoice = loaderMatch.route.shouldRevalidate(arg);\n if (typeof routeChoice === \"boolean\") {\n return routeChoice;\n }\n }\n\n return arg.defaultShouldRevalidate;\n}\n\n/**\n * Execute route.lazy() methods to lazily load route modules (loader, action,\n * shouldRevalidate) and update the routeManifest in place which shares objects\n * with dataRoutes so those get updated as well.\n */\nasync function loadLazyRouteModule(\n route: AgnosticDataRouteObject,\n mapRouteProperties: MapRoutePropertiesFunction,\n manifest: RouteManifest\n) {\n if (!route.lazy) {\n return;\n }\n\n let lazyRoute = await route.lazy();\n\n // If the lazy route function was executed and removed by another parallel\n // call then we can return - first lazy() to finish wins because the return\n // value of lazy is expected to be static\n if (!route.lazy) {\n return;\n }\n\n let routeToUpdate = manifest[route.id];\n invariant(routeToUpdate, \"No route found in manifest\");\n\n // Update the route in place. This should be safe because there's no way\n // we could yet be sitting on this route as we can't get there without\n // resolving lazy() first.\n //\n // This is different than the HMR \"update\" use-case where we may actively be\n // on the route being updated. The main concern boils down to \"does this\n // mutation affect any ongoing navigations or any current state.matches\n // values?\". If not, it should be safe to update in place.\n let routeUpdates: Record = {};\n for (let lazyRouteProperty in lazyRoute) {\n let staticRouteValue =\n routeToUpdate[lazyRouteProperty as keyof typeof routeToUpdate];\n\n let isPropertyStaticallyDefined =\n staticRouteValue !== undefined &&\n // This property isn't static since it should always be updated based\n // on the route updates\n lazyRouteProperty !== \"hasErrorBoundary\";\n\n warning(\n !isPropertyStaticallyDefined,\n `Route \"${routeToUpdate.id}\" has a static property \"${lazyRouteProperty}\" ` +\n `defined but its lazy function is also returning a value for this property. ` +\n `The lazy route property \"${lazyRouteProperty}\" will be ignored.`\n );\n\n if (\n !isPropertyStaticallyDefined &&\n !immutableRouteKeys.has(lazyRouteProperty as ImmutableRouteKey)\n ) {\n routeUpdates[lazyRouteProperty] =\n lazyRoute[lazyRouteProperty as keyof typeof lazyRoute];\n }\n }\n\n // Mutate the route with the provided updates. Do this first so we pass\n // the updated version to mapRouteProperties\n Object.assign(routeToUpdate, routeUpdates);\n\n // Mutate the `hasErrorBoundary` property on the route based on the route\n // updates and remove the `lazy` function so we don't resolve the lazy\n // route again.\n Object.assign(routeToUpdate, {\n // To keep things framework agnostic, we use the provided\n // `mapRouteProperties` (or wrapped `detectErrorBoundary`) function to\n // set the framework-aware properties (`element`/`hasErrorBoundary`) since\n // the logic will differ between frameworks.\n ...mapRouteProperties(routeToUpdate),\n lazy: undefined,\n });\n}\n\nasync function callLoaderOrAction(\n type: \"loader\" | \"action\",\n request: Request,\n match: AgnosticDataRouteMatch,\n matches: AgnosticDataRouteMatch[],\n manifest: RouteManifest,\n mapRouteProperties: MapRoutePropertiesFunction,\n basename: string,\n opts: {\n isStaticRequest?: boolean;\n isRouteRequest?: boolean;\n requestContext?: unknown;\n } = {}\n): Promise {\n let resultType;\n let result;\n let onReject: (() => void) | undefined;\n\n let runHandler = (handler: ActionFunction | LoaderFunction) => {\n // Setup a promise we can race against so that abort signals short circuit\n let reject: () => void;\n let abortPromise = new Promise((_, r) => (reject = r));\n onReject = () => reject();\n request.signal.addEventListener(\"abort\", onReject);\n return Promise.race([\n handler({\n request,\n params: match.params,\n context: opts.requestContext,\n }),\n abortPromise,\n ]);\n };\n\n try {\n let handler = match.route[type];\n\n if (match.route.lazy) {\n if (handler) {\n // Run statically defined handler in parallel with lazy()\n let values = await Promise.all([\n runHandler(handler),\n loadLazyRouteModule(match.route, mapRouteProperties, manifest),\n ]);\n result = values[0];\n } else {\n // Load lazy route module, then run any returned handler\n await loadLazyRouteModule(match.route, mapRouteProperties, manifest);\n\n handler = match.route[type];\n if (handler) {\n // Handler still run even if we got interrupted to maintain consistency\n // with un-abortable behavior of handler execution on non-lazy or\n // previously-lazy-loaded routes\n result = await runHandler(handler);\n } else if (type === \"action\") {\n let url = new URL(request.url);\n let pathname = url.pathname + url.search;\n throw getInternalRouterError(405, {\n method: request.method,\n pathname,\n routeId: match.route.id,\n });\n } else {\n // lazy() route has no loader to run. Short circuit here so we don't\n // hit the invariant below that errors on returning undefined.\n return { type: ResultType.data, data: undefined };\n }\n }\n } else if (!handler) {\n let url = new URL(request.url);\n let pathname = url.pathname + url.search;\n throw getInternalRouterError(404, {\n pathname,\n });\n } else {\n result = await runHandler(handler);\n }\n\n invariant(\n result !== undefined,\n `You defined ${type === \"action\" ? \"an action\" : \"a loader\"} for route ` +\n `\"${match.route.id}\" but didn't return anything from your \\`${type}\\` ` +\n `function. Please return a value or \\`null\\`.`\n );\n } catch (e) {\n resultType = ResultType.error;\n result = e;\n } finally {\n if (onReject) {\n request.signal.removeEventListener(\"abort\", onReject);\n }\n }\n\n if (isResponse(result)) {\n let status = result.status;\n\n // Process redirects\n if (redirectStatusCodes.has(status)) {\n let location = result.headers.get(\"Location\");\n invariant(\n location,\n \"Redirects returned/thrown from loaders/actions must have a Location header\"\n );\n\n // Support relative routing in internal redirects\n if (!ABSOLUTE_URL_REGEX.test(location)) {\n location = normalizeTo(\n new URL(request.url),\n matches.slice(0, matches.indexOf(match) + 1),\n basename,\n true,\n location\n );\n } else if (!opts.isStaticRequest) {\n // Strip off the protocol+origin for same-origin + same-basename absolute\n // redirects. If this is a static request, we can let it go back to the\n // browser as-is\n let currentUrl = new URL(request.url);\n let url = location.startsWith(\"//\")\n ? new URL(currentUrl.protocol + location)\n : new URL(location);\n let isSameBasename = stripBasename(url.pathname, basename) != null;\n if (url.origin === currentUrl.origin && isSameBasename) {\n location = url.pathname + url.search + url.hash;\n }\n }\n\n // Don't process redirects in the router during static requests requests.\n // Instead, throw the Response and let the server handle it with an HTTP\n // redirect. We also update the Location header in place in this flow so\n // basename and relative routing is taken into account\n if (opts.isStaticRequest) {\n result.headers.set(\"Location\", location);\n throw result;\n }\n\n return {\n type: ResultType.redirect,\n status,\n location,\n revalidate: result.headers.get(\"X-Remix-Revalidate\") !== null,\n };\n }\n\n // For SSR single-route requests, we want to hand Responses back directly\n // without unwrapping. We do this with the QueryRouteResponse wrapper\n // interface so we can know whether it was returned or thrown\n if (opts.isRouteRequest) {\n // eslint-disable-next-line no-throw-literal\n throw {\n type: resultType || ResultType.data,\n response: result,\n };\n }\n\n let data: any;\n let contentType = result.headers.get(\"Content-Type\");\n // Check between word boundaries instead of startsWith() due to the last\n // paragraph of https://httpwg.org/specs/rfc9110.html#field.content-type\n if (contentType && /\\bapplication\\/json\\b/.test(contentType)) {\n data = await result.json();\n } else {\n data = await result.text();\n }\n\n if (resultType === ResultType.error) {\n return {\n type: resultType,\n error: new ErrorResponse(status, result.statusText, data),\n headers: result.headers,\n };\n }\n\n return {\n type: ResultType.data,\n data,\n statusCode: result.status,\n headers: result.headers,\n };\n }\n\n if (resultType === ResultType.error) {\n return { type: resultType, error: result };\n }\n\n if (isDeferredData(result)) {\n return {\n type: ResultType.deferred,\n deferredData: result,\n statusCode: result.init?.status,\n headers: result.init?.headers && new Headers(result.init.headers),\n };\n }\n\n return { type: ResultType.data, data: result };\n}\n\n// Utility method for creating the Request instances for loaders/actions during\n// client-side navigations and fetches. During SSR we will always have a\n// Request instance from the static handler (query/queryRoute)\nfunction createClientSideRequest(\n history: History,\n location: string | Location,\n signal: AbortSignal,\n submission?: Submission\n): Request {\n let url = history.createURL(stripHashFromPath(location)).toString();\n let init: RequestInit = { signal };\n\n if (submission && isMutationMethod(submission.formMethod)) {\n let { formMethod, formEncType } = submission;\n // Didn't think we needed this but it turns out unlike other methods, patch\n // won't be properly normalized to uppercase and results in a 405 error.\n // See: https://fetch.spec.whatwg.org/#concept-method\n init.method = formMethod.toUpperCase();\n\n if (formEncType === \"application/json\") {\n init.headers = new Headers({ \"Content-Type\": formEncType });\n init.body = JSON.stringify(submission.json);\n } else if (formEncType === \"text/plain\") {\n // Content-Type is inferred (https://fetch.spec.whatwg.org/#dom-request)\n init.body = submission.text;\n } else if (\n formEncType === \"application/x-www-form-urlencoded\" &&\n submission.formData\n ) {\n // Content-Type is inferred (https://fetch.spec.whatwg.org/#dom-request)\n init.body = convertFormDataToSearchParams(submission.formData);\n } else {\n // Content-Type is inferred (https://fetch.spec.whatwg.org/#dom-request)\n init.body = submission.formData;\n }\n }\n\n return new Request(url, init);\n}\n\nfunction convertFormDataToSearchParams(formData: FormData): URLSearchParams {\n let searchParams = new URLSearchParams();\n\n for (let [key, value] of formData.entries()) {\n // https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#converting-an-entry-list-to-a-list-of-name-value-pairs\n searchParams.append(key, typeof value === \"string\" ? value : value.name);\n }\n\n return searchParams;\n}\n\nfunction convertSearchParamsToFormData(\n searchParams: URLSearchParams\n): FormData {\n let formData = new FormData();\n for (let [key, value] of searchParams.entries()) {\n formData.append(key, value);\n }\n return formData;\n}\n\nfunction processRouteLoaderData(\n matches: AgnosticDataRouteMatch[],\n matchesToLoad: AgnosticDataRouteMatch[],\n results: DataResult[],\n pendingError: RouteData | undefined,\n activeDeferreds: Map\n): {\n loaderData: RouterState[\"loaderData\"];\n errors: RouterState[\"errors\"] | null;\n statusCode: number;\n loaderHeaders: Record;\n} {\n // Fill in loaderData/errors from our loaders\n let loaderData: RouterState[\"loaderData\"] = {};\n let errors: RouterState[\"errors\"] | null = null;\n let statusCode: number | undefined;\n let foundError = false;\n let loaderHeaders: Record = {};\n\n // Process loader results into state.loaderData/state.errors\n results.forEach((result, index) => {\n let id = matchesToLoad[index].route.id;\n invariant(\n !isRedirectResult(result),\n \"Cannot handle redirect results in processLoaderData\"\n );\n if (isErrorResult(result)) {\n // Look upwards from the matched route for the closest ancestor\n // error boundary, defaulting to the root match\n let boundaryMatch = findNearestBoundary(matches, id);\n let error = result.error;\n // If we have a pending action error, we report it at the highest-route\n // that throws a loader error, and then clear it out to indicate that\n // it was consumed\n if (pendingError) {\n error = Object.values(pendingError)[0];\n pendingError = undefined;\n }\n\n errors = errors || {};\n\n // Prefer higher error values if lower errors bubble to the same boundary\n if (errors[boundaryMatch.route.id] == null) {\n errors[boundaryMatch.route.id] = error;\n }\n\n // Clear our any prior loaderData for the throwing route\n loaderData[id] = undefined;\n\n // Once we find our first (highest) error, we set the status code and\n // prevent deeper status codes from overriding\n if (!foundError) {\n foundError = true;\n statusCode = isRouteErrorResponse(result.error)\n ? result.error.status\n : 500;\n }\n if (result.headers) {\n loaderHeaders[id] = result.headers;\n }\n } else {\n if (isDeferredResult(result)) {\n activeDeferreds.set(id, result.deferredData);\n loaderData[id] = result.deferredData.data;\n } else {\n loaderData[id] = result.data;\n }\n\n // Error status codes always override success status codes, but if all\n // loaders are successful we take the deepest status code.\n if (\n result.statusCode != null &&\n result.statusCode !== 200 &&\n !foundError\n ) {\n statusCode = result.statusCode;\n }\n if (result.headers) {\n loaderHeaders[id] = result.headers;\n }\n }\n });\n\n // If we didn't consume the pending action error (i.e., all loaders\n // resolved), then consume it here. Also clear out any loaderData for the\n // throwing route\n if (pendingError) {\n errors = pendingError;\n loaderData[Object.keys(pendingError)[0]] = undefined;\n }\n\n return {\n loaderData,\n errors,\n statusCode: statusCode || 200,\n loaderHeaders,\n };\n}\n\nfunction processLoaderData(\n state: RouterState,\n matches: AgnosticDataRouteMatch[],\n matchesToLoad: AgnosticDataRouteMatch[],\n results: DataResult[],\n pendingError: RouteData | undefined,\n revalidatingFetchers: RevalidatingFetcher[],\n fetcherResults: DataResult[],\n activeDeferreds: Map\n): {\n loaderData: RouterState[\"loaderData\"];\n errors?: RouterState[\"errors\"];\n} {\n let { loaderData, errors } = processRouteLoaderData(\n matches,\n matchesToLoad,\n results,\n pendingError,\n activeDeferreds\n );\n\n // Process results from our revalidating fetchers\n for (let index = 0; index < revalidatingFetchers.length; index++) {\n let { key, match, controller } = revalidatingFetchers[index];\n invariant(\n fetcherResults !== undefined && fetcherResults[index] !== undefined,\n \"Did not find corresponding fetcher result\"\n );\n let result = fetcherResults[index];\n\n // Process fetcher non-redirect errors\n if (controller && controller.signal.aborted) {\n // Nothing to do for aborted fetchers\n continue;\n } else if (isErrorResult(result)) {\n let boundaryMatch = findNearestBoundary(state.matches, match?.route.id);\n if (!(errors && errors[boundaryMatch.route.id])) {\n errors = {\n ...errors,\n [boundaryMatch.route.id]: result.error,\n };\n }\n state.fetchers.delete(key);\n } else if (isRedirectResult(result)) {\n // Should never get here, redirects should get processed above, but we\n // keep this to type narrow to a success result in the else\n invariant(false, \"Unhandled fetcher revalidation redirect\");\n } else if (isDeferredResult(result)) {\n // Should never get here, deferred data should be awaited for fetchers\n // in resolveDeferredResults\n invariant(false, \"Unhandled fetcher deferred data\");\n } else {\n let doneFetcher = getDoneFetcher(result.data);\n state.fetchers.set(key, doneFetcher);\n }\n }\n\n return { loaderData, errors };\n}\n\nfunction mergeLoaderData(\n loaderData: RouteData,\n newLoaderData: RouteData,\n matches: AgnosticDataRouteMatch[],\n errors: RouteData | null | undefined\n): RouteData {\n let mergedLoaderData = { ...newLoaderData };\n for (let match of matches) {\n let id = match.route.id;\n if (newLoaderData.hasOwnProperty(id)) {\n if (newLoaderData[id] !== undefined) {\n mergedLoaderData[id] = newLoaderData[id];\n } else {\n // No-op - this is so we ignore existing data if we have a key in the\n // incoming object with an undefined value, which is how we unset a prior\n // loaderData if we encounter a loader error\n }\n } else if (loaderData[id] !== undefined && match.route.loader) {\n // Preserve existing keys not included in newLoaderData and where a loader\n // wasn't removed by HMR\n mergedLoaderData[id] = loaderData[id];\n }\n\n if (errors && errors.hasOwnProperty(id)) {\n // Don't keep any loader data below the boundary\n break;\n }\n }\n return mergedLoaderData;\n}\n\n// Find the nearest error boundary, looking upwards from the leaf route (or the\n// route specified by routeId) for the closest ancestor error boundary,\n// defaulting to the root match\nfunction findNearestBoundary(\n matches: AgnosticDataRouteMatch[],\n routeId?: string\n): AgnosticDataRouteMatch {\n let eligibleMatches = routeId\n ? matches.slice(0, matches.findIndex((m) => m.route.id === routeId) + 1)\n : [...matches];\n return (\n eligibleMatches.reverse().find((m) => m.route.hasErrorBoundary === true) ||\n matches[0]\n );\n}\n\nfunction getShortCircuitMatches(routes: AgnosticDataRouteObject[]): {\n matches: AgnosticDataRouteMatch[];\n route: AgnosticDataRouteObject;\n} {\n // Prefer a root layout route if present, otherwise shim in a route object\n let route = routes.find((r) => r.index || !r.path || r.path === \"/\") || {\n id: `__shim-error-route__`,\n };\n\n return {\n matches: [\n {\n params: {},\n pathname: \"\",\n pathnameBase: \"\",\n route,\n },\n ],\n route,\n };\n}\n\nfunction getInternalRouterError(\n status: number,\n {\n pathname,\n routeId,\n method,\n type,\n }: {\n pathname?: string;\n routeId?: string;\n method?: string;\n type?: \"defer-action\" | \"invalid-body\";\n } = {}\n) {\n let statusText = \"Unknown Server Error\";\n let errorMessage = \"Unknown @remix-run/router error\";\n\n if (status === 400) {\n statusText = \"Bad Request\";\n if (method && pathname && routeId) {\n errorMessage =\n `You made a ${method} request to \"${pathname}\" but ` +\n `did not provide a \\`loader\\` for route \"${routeId}\", ` +\n `so there is no way to handle the request.`;\n } else if (type === \"defer-action\") {\n errorMessage = \"defer() is not supported in actions\";\n } else if (type === \"invalid-body\") {\n errorMessage = \"Unable to encode submission body\";\n }\n } else if (status === 403) {\n statusText = \"Forbidden\";\n errorMessage = `Route \"${routeId}\" does not match URL \"${pathname}\"`;\n } else if (status === 404) {\n statusText = \"Not Found\";\n errorMessage = `No route matches URL \"${pathname}\"`;\n } else if (status === 405) {\n statusText = \"Method Not Allowed\";\n if (method && pathname && routeId) {\n errorMessage =\n `You made a ${method.toUpperCase()} request to \"${pathname}\" but ` +\n `did not provide an \\`action\\` for route \"${routeId}\", ` +\n `so there is no way to handle the request.`;\n } else if (method) {\n errorMessage = `Invalid request method \"${method.toUpperCase()}\"`;\n }\n }\n\n return new ErrorResponse(\n status || 500,\n statusText,\n new Error(errorMessage),\n true\n );\n}\n\n// Find any returned redirect errors, starting from the lowest match\nfunction findRedirect(\n results: DataResult[]\n): { result: RedirectResult; idx: number } | undefined {\n for (let i = results.length - 1; i >= 0; i--) {\n let result = results[i];\n if (isRedirectResult(result)) {\n return { result, idx: i };\n }\n }\n}\n\nfunction stripHashFromPath(path: To) {\n let parsedPath = typeof path === \"string\" ? parsePath(path) : path;\n return createPath({ ...parsedPath, hash: \"\" });\n}\n\nfunction isHashChangeOnly(a: Location, b: Location): boolean {\n if (a.pathname !== b.pathname || a.search !== b.search) {\n return false;\n }\n\n if (a.hash === \"\") {\n // /page -> /page#hash\n return b.hash !== \"\";\n } else if (a.hash === b.hash) {\n // /page#hash -> /page#hash\n return true;\n } else if (b.hash !== \"\") {\n // /page#hash -> /page#other\n return true;\n }\n\n // If the hash is removed the browser will re-perform a request to the server\n // /page#hash -> /page\n return false;\n}\n\nfunction isDeferredResult(result: DataResult): result is DeferredResult {\n return result.type === ResultType.deferred;\n}\n\nfunction isErrorResult(result: DataResult): result is ErrorResult {\n return result.type === ResultType.error;\n}\n\nfunction isRedirectResult(result?: DataResult): result is RedirectResult {\n return (result && result.type) === ResultType.redirect;\n}\n\nexport function isDeferredData(value: any): value is DeferredData {\n let deferred: DeferredData = value;\n return (\n deferred &&\n typeof deferred === \"object\" &&\n typeof deferred.data === \"object\" &&\n typeof deferred.subscribe === \"function\" &&\n typeof deferred.cancel === \"function\" &&\n typeof deferred.resolveData === \"function\"\n );\n}\n\nfunction isResponse(value: any): value is Response {\n return (\n value != null &&\n typeof value.status === \"number\" &&\n typeof value.statusText === \"string\" &&\n typeof value.headers === \"object\" &&\n typeof value.body !== \"undefined\"\n );\n}\n\nfunction isRedirectResponse(result: any): result is Response {\n if (!isResponse(result)) {\n return false;\n }\n\n let status = result.status;\n let location = result.headers.get(\"Location\");\n return status >= 300 && status <= 399 && location != null;\n}\n\nfunction isQueryRouteResponse(obj: any): obj is QueryRouteResponse {\n return (\n obj &&\n isResponse(obj.response) &&\n (obj.type === ResultType.data || ResultType.error)\n );\n}\n\nfunction isValidMethod(method: string): method is FormMethod | V7_FormMethod {\n return validRequestMethods.has(method.toLowerCase() as FormMethod);\n}\n\nfunction isMutationMethod(\n method: string\n): method is MutationFormMethod | V7_MutationFormMethod {\n return validMutationMethods.has(method.toLowerCase() as MutationFormMethod);\n}\n\nasync function resolveDeferredResults(\n currentMatches: AgnosticDataRouteMatch[],\n matchesToLoad: (AgnosticDataRouteMatch | null)[],\n results: DataResult[],\n signals: (AbortSignal | null)[],\n isFetcher: boolean,\n currentLoaderData?: RouteData\n) {\n for (let index = 0; index < results.length; index++) {\n let result = results[index];\n let match = matchesToLoad[index];\n // If we don't have a match, then we can have a deferred result to do\n // anything with. This is for revalidating fetchers where the route was\n // removed during HMR\n if (!match) {\n continue;\n }\n\n let currentMatch = currentMatches.find(\n (m) => m.route.id === match!.route.id\n );\n let isRevalidatingLoader =\n currentMatch != null &&\n !isNewRouteInstance(currentMatch, match) &&\n (currentLoaderData && currentLoaderData[match.route.id]) !== undefined;\n\n if (isDeferredResult(result) && (isFetcher || isRevalidatingLoader)) {\n // Note: we do not have to touch activeDeferreds here since we race them\n // against the signal in resolveDeferredData and they'll get aborted\n // there if needed\n let signal = signals[index];\n invariant(\n signal,\n \"Expected an AbortSignal for revalidating fetcher deferred result\"\n );\n await resolveDeferredData(result, signal, isFetcher).then((result) => {\n if (result) {\n results[index] = result || results[index];\n }\n });\n }\n }\n}\n\nasync function resolveDeferredData(\n result: DeferredResult,\n signal: AbortSignal,\n unwrap = false\n): Promise {\n let aborted = await result.deferredData.resolveData(signal);\n if (aborted) {\n return;\n }\n\n if (unwrap) {\n try {\n return {\n type: ResultType.data,\n data: result.deferredData.unwrappedData,\n };\n } catch (e) {\n // Handle any TrackedPromise._error values encountered while unwrapping\n return {\n type: ResultType.error,\n error: e,\n };\n }\n }\n\n return {\n type: ResultType.data,\n data: result.deferredData.data,\n };\n}\n\nfunction hasNakedIndexQuery(search: string): boolean {\n return new URLSearchParams(search).getAll(\"index\").some((v) => v === \"\");\n}\n\n// Note: This should match the format exported by useMatches, so if you change\n// this please also change that :) Eventually we'll DRY this up\nfunction createUseMatchesMatch(\n match: AgnosticDataRouteMatch,\n loaderData: RouteData\n): UseMatchesMatch {\n let { route, pathname, params } = match;\n return {\n id: route.id,\n pathname,\n params,\n data: loaderData[route.id] as unknown,\n handle: route.handle as unknown,\n };\n}\n\nfunction getTargetMatch(\n matches: AgnosticDataRouteMatch[],\n location: Location | string\n) {\n let search =\n typeof location === \"string\" ? parsePath(location).search : location.search;\n if (\n matches[matches.length - 1].route.index &&\n hasNakedIndexQuery(search || \"\")\n ) {\n // Return the leaf index route when index is present\n return matches[matches.length - 1];\n }\n // Otherwise grab the deepest \"path contributing\" match (ignoring index and\n // pathless layout routes)\n let pathMatches = getPathContributingMatches(matches);\n return pathMatches[pathMatches.length - 1];\n}\n\nfunction getSubmissionFromNavigation(\n navigation: Navigation\n): Submission | undefined {\n let { formMethod, formAction, formEncType, text, formData, json } =\n navigation;\n if (!formMethod || !formAction || !formEncType) {\n return;\n }\n\n if (text != null) {\n return {\n formMethod,\n formAction,\n formEncType,\n formData: undefined,\n json: undefined,\n text,\n };\n } else if (formData != null) {\n return {\n formMethod,\n formAction,\n formEncType,\n formData,\n json: undefined,\n text: undefined,\n };\n } else if (json !== undefined) {\n return {\n formMethod,\n formAction,\n formEncType,\n formData: undefined,\n json,\n text: undefined,\n };\n }\n}\n\nfunction getLoadingNavigation(\n location: Location,\n submission?: Submission\n): NavigationStates[\"Loading\"] {\n if (submission) {\n let navigation: NavigationStates[\"Loading\"] = {\n state: \"loading\",\n location,\n formMethod: submission.formMethod,\n formAction: submission.formAction,\n formEncType: submission.formEncType,\n formData: submission.formData,\n json: submission.json,\n text: submission.text,\n };\n return navigation;\n } else {\n let navigation: NavigationStates[\"Loading\"] = {\n state: \"loading\",\n location,\n formMethod: undefined,\n formAction: undefined,\n formEncType: undefined,\n formData: undefined,\n json: undefined,\n text: undefined,\n };\n return navigation;\n }\n}\n\nfunction getSubmittingNavigation(\n location: Location,\n submission: Submission\n): NavigationStates[\"Submitting\"] {\n let navigation: NavigationStates[\"Submitting\"] = {\n state: \"submitting\",\n location,\n formMethod: submission.formMethod,\n formAction: submission.formAction,\n formEncType: submission.formEncType,\n formData: submission.formData,\n json: submission.json,\n text: submission.text,\n };\n return navigation;\n}\n\nfunction getLoadingFetcher(\n submission?: Submission,\n data?: Fetcher[\"data\"]\n): FetcherStates[\"Loading\"] {\n if (submission) {\n let fetcher: FetcherStates[\"Loading\"] = {\n state: \"loading\",\n formMethod: submission.formMethod,\n formAction: submission.formAction,\n formEncType: submission.formEncType,\n formData: submission.formData,\n json: submission.json,\n text: submission.text,\n data,\n \" _hasFetcherDoneAnything \": true,\n };\n return fetcher;\n } else {\n let fetcher: FetcherStates[\"Loading\"] = {\n state: \"loading\",\n formMethod: undefined,\n formAction: undefined,\n formEncType: undefined,\n formData: undefined,\n json: undefined,\n text: undefined,\n data,\n \" _hasFetcherDoneAnything \": true,\n };\n return fetcher;\n }\n}\n\nfunction getSubmittingFetcher(\n submission: Submission,\n existingFetcher?: Fetcher\n): FetcherStates[\"Submitting\"] {\n let fetcher: FetcherStates[\"Submitting\"] = {\n state: \"submitting\",\n formMethod: submission.formMethod,\n formAction: submission.formAction,\n formEncType: submission.formEncType,\n formData: submission.formData,\n json: submission.json,\n text: submission.text,\n data: existingFetcher ? existingFetcher.data : undefined,\n \" _hasFetcherDoneAnything \": true,\n };\n return fetcher;\n}\n\nfunction getDoneFetcher(data: Fetcher[\"data\"]): FetcherStates[\"Idle\"] {\n let fetcher: FetcherStates[\"Idle\"] = {\n state: \"idle\",\n formMethod: undefined,\n formAction: undefined,\n formEncType: undefined,\n formData: undefined,\n json: undefined,\n text: undefined,\n data,\n \" _hasFetcherDoneAnything \": true,\n };\n return fetcher;\n}\n//#endregion\n","import * as React from \"react\";\nimport type {\n AgnosticRouteMatch,\n AgnosticIndexRouteObject,\n AgnosticNonIndexRouteObject,\n History,\n Location,\n RelativeRoutingType,\n Router,\n StaticHandlerContext,\n To,\n TrackedPromise,\n LazyRouteFunction,\n} from \"@remix-run/router\";\nimport type { Action as NavigationType } from \"@remix-run/router\";\n\n// Create react-specific types from the agnostic types in @remix-run/router to\n// export from react-router\nexport interface IndexRouteObject {\n caseSensitive?: AgnosticIndexRouteObject[\"caseSensitive\"];\n path?: AgnosticIndexRouteObject[\"path\"];\n id?: AgnosticIndexRouteObject[\"id\"];\n loader?: AgnosticIndexRouteObject[\"loader\"];\n action?: AgnosticIndexRouteObject[\"action\"];\n hasErrorBoundary?: AgnosticIndexRouteObject[\"hasErrorBoundary\"];\n shouldRevalidate?: AgnosticIndexRouteObject[\"shouldRevalidate\"];\n handle?: AgnosticIndexRouteObject[\"handle\"];\n index: true;\n children?: undefined;\n element?: React.ReactNode | null;\n errorElement?: React.ReactNode | null;\n Component?: React.ComponentType | null;\n ErrorBoundary?: React.ComponentType | null;\n lazy?: LazyRouteFunction;\n}\n\nexport interface NonIndexRouteObject {\n caseSensitive?: AgnosticNonIndexRouteObject[\"caseSensitive\"];\n path?: AgnosticNonIndexRouteObject[\"path\"];\n id?: AgnosticNonIndexRouteObject[\"id\"];\n loader?: AgnosticNonIndexRouteObject[\"loader\"];\n action?: AgnosticNonIndexRouteObject[\"action\"];\n hasErrorBoundary?: AgnosticNonIndexRouteObject[\"hasErrorBoundary\"];\n shouldRevalidate?: AgnosticNonIndexRouteObject[\"shouldRevalidate\"];\n handle?: AgnosticNonIndexRouteObject[\"handle\"];\n index?: false;\n children?: RouteObject[];\n element?: React.ReactNode | null;\n errorElement?: React.ReactNode | null;\n Component?: React.ComponentType | null;\n ErrorBoundary?: React.ComponentType | null;\n lazy?: LazyRouteFunction;\n}\n\nexport type RouteObject = IndexRouteObject | NonIndexRouteObject;\n\nexport type DataRouteObject = RouteObject & {\n children?: DataRouteObject[];\n id: string;\n};\n\nexport interface RouteMatch<\n ParamKey extends string = string,\n RouteObjectType extends RouteObject = RouteObject\n> extends AgnosticRouteMatch {}\n\nexport interface DataRouteMatch extends RouteMatch {}\n\nexport interface DataRouterContextObject extends NavigationContextObject {\n router: Router;\n staticContext?: StaticHandlerContext;\n}\n\nexport const DataRouterContext =\n React.createContext(null);\nif (__DEV__) {\n DataRouterContext.displayName = \"DataRouter\";\n}\n\nexport const DataRouterStateContext = React.createContext<\n Router[\"state\"] | null\n>(null);\nif (__DEV__) {\n DataRouterStateContext.displayName = \"DataRouterState\";\n}\n\nexport const AwaitContext = React.createContext(null);\nif (__DEV__) {\n AwaitContext.displayName = \"Await\";\n}\n\nexport interface NavigateOptions {\n replace?: boolean;\n state?: any;\n preventScrollReset?: boolean;\n relative?: RelativeRoutingType;\n}\n\n/**\n * A Navigator is a \"location changer\"; it's how you get to different locations.\n *\n * Every history instance conforms to the Navigator interface, but the\n * distinction is useful primarily when it comes to the low-level API\n * where both the location and a navigator must be provided separately in order\n * to avoid \"tearing\" that may occur in a suspense-enabled app if the action\n * and/or location were to be read directly from the history instance.\n */\nexport interface Navigator {\n createHref: History[\"createHref\"];\n // Optional for backwards-compat with Router/HistoryRouter usage (edge case)\n encodeLocation?: History[\"encodeLocation\"];\n go: History[\"go\"];\n push(to: To, state?: any, opts?: NavigateOptions): void;\n replace(to: To, state?: any, opts?: NavigateOptions): void;\n}\n\ninterface NavigationContextObject {\n basename: string;\n navigator: Navigator;\n static: boolean;\n}\n\nexport const NavigationContext = React.createContext(\n null!\n);\n\nif (__DEV__) {\n NavigationContext.displayName = \"Navigation\";\n}\n\ninterface LocationContextObject {\n location: Location;\n navigationType: NavigationType;\n}\n\nexport const LocationContext = React.createContext(\n null!\n);\n\nif (__DEV__) {\n LocationContext.displayName = \"Location\";\n}\n\nexport interface RouteContextObject {\n outlet: React.ReactElement | null;\n matches: RouteMatch[];\n isDataRoute: boolean;\n}\n\nexport const RouteContext = React.createContext({\n outlet: null,\n matches: [],\n isDataRoute: false,\n});\n\nif (__DEV__) {\n RouteContext.displayName = \"Route\";\n}\n\nexport const RouteErrorContext = React.createContext(null);\n\nif (__DEV__) {\n RouteErrorContext.displayName = \"RouteError\";\n}\n","import * as React from \"react\";\nimport type {\n Blocker,\n BlockerFunction,\n Location,\n ParamParseKey,\n Params,\n Path,\n PathMatch,\n PathPattern,\n RelativeRoutingType,\n Router as RemixRouter,\n RevalidationState,\n To,\n} from \"@remix-run/router\";\nimport {\n Action as NavigationType,\n UNSAFE_invariant as invariant,\n isRouteErrorResponse,\n joinPaths,\n matchPath,\n matchRoutes,\n parsePath,\n resolveTo,\n stripBasename,\n IDLE_BLOCKER,\n UNSAFE_getPathContributingMatches as getPathContributingMatches,\n UNSAFE_warning as warning,\n} from \"@remix-run/router\";\n\nimport type {\n NavigateOptions,\n RouteContextObject,\n RouteMatch,\n RouteObject,\n DataRouteMatch,\n} from \"./context\";\nimport {\n DataRouterContext,\n DataRouterStateContext,\n LocationContext,\n NavigationContext,\n RouteContext,\n RouteErrorContext,\n AwaitContext,\n} from \"./context\";\n\n/**\n * Returns the full href for the given \"to\" value. This is useful for building\n * custom links that are also accessible and preserve right-click behavior.\n *\n * @see https://reactrouter.com/hooks/use-href\n */\nexport function useHref(\n to: To,\n { relative }: { relative?: RelativeRoutingType } = {}\n): string {\n invariant(\n useInRouterContext(),\n // TODO: This error is probably because they somehow have 2 versions of the\n // router loaded. We can help them understand how to avoid that.\n `useHref() may be used only in the context of a component.`\n );\n\n let { basename, navigator } = React.useContext(NavigationContext);\n let { hash, pathname, search } = useResolvedPath(to, { relative });\n\n let joinedPathname = pathname;\n\n // If we're operating within a basename, prepend it to the pathname prior\n // to creating the href. If this is a root navigation, then just use the raw\n // basename which allows the basename to have full control over the presence\n // of a trailing slash on root links\n if (basename !== \"/\") {\n joinedPathname =\n pathname === \"/\" ? basename : joinPaths([basename, pathname]);\n }\n\n return navigator.createHref({ pathname: joinedPathname, search, hash });\n}\n\n/**\n * Returns true if this component is a descendant of a .\n *\n * @see https://reactrouter.com/hooks/use-in-router-context\n */\nexport function useInRouterContext(): boolean {\n return React.useContext(LocationContext) != null;\n}\n\n/**\n * Returns the current location object, which represents the current URL in web\n * browsers.\n *\n * Note: If you're using this it may mean you're doing some of your own\n * \"routing\" in your app, and we'd like to know what your use case is. We may\n * be able to provide something higher-level to better suit your needs.\n *\n * @see https://reactrouter.com/hooks/use-location\n */\nexport function useLocation(): Location {\n invariant(\n useInRouterContext(),\n // TODO: This error is probably because they somehow have 2 versions of the\n // router loaded. We can help them understand how to avoid that.\n `useLocation() may be used only in the context of a component.`\n );\n\n return React.useContext(LocationContext).location;\n}\n\n/**\n * Returns the current navigation action which describes how the router came to\n * the current location, either by a pop, push, or replace on the history stack.\n *\n * @see https://reactrouter.com/hooks/use-navigation-type\n */\nexport function useNavigationType(): NavigationType {\n return React.useContext(LocationContext).navigationType;\n}\n\n/**\n * Returns a PathMatch object if the given pattern matches the current URL.\n * This is useful for components that need to know \"active\" state, e.g.\n * .\n *\n * @see https://reactrouter.com/hooks/use-match\n */\nexport function useMatch<\n ParamKey extends ParamParseKey,\n Path extends string\n>(pattern: PathPattern | Path): PathMatch | null {\n invariant(\n useInRouterContext(),\n // TODO: This error is probably because they somehow have 2 versions of the\n // router loaded. We can help them understand how to avoid that.\n `useMatch() may be used only in the context of a component.`\n );\n\n let { pathname } = useLocation();\n return React.useMemo(\n () => matchPath(pattern, pathname),\n [pathname, pattern]\n );\n}\n\n/**\n * The interface for the navigate() function returned from useNavigate().\n */\nexport interface NavigateFunction {\n (to: To, options?: NavigateOptions): void;\n (delta: number): void;\n}\n\nconst navigateEffectWarning =\n `You should call navigate() in a React.useEffect(), not when ` +\n `your component is first rendered.`;\n\n// Mute warnings for calls to useNavigate in SSR environments\nfunction useIsomorphicLayoutEffect(\n cb: Parameters[0]\n) {\n let isStatic = React.useContext(NavigationContext).static;\n if (!isStatic) {\n // We should be able to get rid of this once react 18.3 is released\n // See: https://github.com/facebook/react/pull/26395\n // eslint-disable-next-line react-hooks/rules-of-hooks\n React.useLayoutEffect(cb);\n }\n}\n\n/**\n * Returns an imperative method for changing the location. Used by s, but\n * may also be used by other elements to change the location.\n *\n * @see https://reactrouter.com/hooks/use-navigate\n */\nexport function useNavigate(): NavigateFunction {\n let { isDataRoute } = React.useContext(RouteContext);\n // Conditional usage is OK here because the usage of a data router is static\n // eslint-disable-next-line react-hooks/rules-of-hooks\n return isDataRoute ? useNavigateStable() : useNavigateUnstable();\n}\n\nfunction useNavigateUnstable(): NavigateFunction {\n invariant(\n useInRouterContext(),\n // TODO: This error is probably because they somehow have 2 versions of the\n // router loaded. We can help them understand how to avoid that.\n `useNavigate() may be used only in the context of a component.`\n );\n\n let dataRouterContext = React.useContext(DataRouterContext);\n let { basename, navigator } = React.useContext(NavigationContext);\n let { matches } = React.useContext(RouteContext);\n let { pathname: locationPathname } = useLocation();\n\n let routePathnamesJson = JSON.stringify(\n getPathContributingMatches(matches).map((match) => match.pathnameBase)\n );\n\n let activeRef = React.useRef(false);\n useIsomorphicLayoutEffect(() => {\n activeRef.current = true;\n });\n\n let navigate: NavigateFunction = React.useCallback(\n (to: To | number, options: NavigateOptions = {}) => {\n warning(activeRef.current, navigateEffectWarning);\n\n // Short circuit here since if this happens on first render the navigate\n // is useless because we haven't wired up our history listener yet\n if (!activeRef.current) return;\n\n if (typeof to === \"number\") {\n navigator.go(to);\n return;\n }\n\n let path = resolveTo(\n to,\n JSON.parse(routePathnamesJson),\n locationPathname,\n options.relative === \"path\"\n );\n\n // If we're operating within a basename, prepend it to the pathname prior\n // to handing off to history (but only if we're not in a data router,\n // otherwise it'll prepend the basename inside of the router).\n // If this is a root navigation, then we navigate to the raw basename\n // which allows the basename to have full control over the presence of a\n // trailing slash on root links\n if (dataRouterContext == null && basename !== \"/\") {\n path.pathname =\n path.pathname === \"/\"\n ? basename\n : joinPaths([basename, path.pathname]);\n }\n\n (!!options.replace ? navigator.replace : navigator.push)(\n path,\n options.state,\n options\n );\n },\n [\n basename,\n navigator,\n routePathnamesJson,\n locationPathname,\n dataRouterContext,\n ]\n );\n\n return navigate;\n}\n\nconst OutletContext = React.createContext(null);\n\n/**\n * Returns the context (if provided) for the child route at this level of the route\n * hierarchy.\n * @see https://reactrouter.com/hooks/use-outlet-context\n */\nexport function useOutletContext(): Context {\n return React.useContext(OutletContext) as Context;\n}\n\n/**\n * Returns the element for the child route at this level of the route\n * hierarchy. Used internally by to render child routes.\n *\n * @see https://reactrouter.com/hooks/use-outlet\n */\nexport function useOutlet(context?: unknown): React.ReactElement | null {\n let outlet = React.useContext(RouteContext).outlet;\n if (outlet) {\n return (\n {outlet}\n );\n }\n return outlet;\n}\n\n/**\n * Returns an object of key/value pairs of the dynamic params from the current\n * URL that were matched by the route path.\n *\n * @see https://reactrouter.com/hooks/use-params\n */\nexport function useParams<\n ParamsOrKey extends string | Record = string\n>(): Readonly<\n [ParamsOrKey] extends [string] ? Params : Partial\n> {\n let { matches } = React.useContext(RouteContext);\n let routeMatch = matches[matches.length - 1];\n return routeMatch ? (routeMatch.params as any) : {};\n}\n\n/**\n * Resolves the pathname of the given `to` value against the current location.\n *\n * @see https://reactrouter.com/hooks/use-resolved-path\n */\nexport function useResolvedPath(\n to: To,\n { relative }: { relative?: RelativeRoutingType } = {}\n): Path {\n let { matches } = React.useContext(RouteContext);\n let { pathname: locationPathname } = useLocation();\n\n let routePathnamesJson = JSON.stringify(\n getPathContributingMatches(matches).map((match) => match.pathnameBase)\n );\n\n return React.useMemo(\n () =>\n resolveTo(\n to,\n JSON.parse(routePathnamesJson),\n locationPathname,\n relative === \"path\"\n ),\n [to, routePathnamesJson, locationPathname, relative]\n );\n}\n\n/**\n * Returns the element of the route that matched the current location, prepared\n * with the correct context to render the remainder of the route tree. Route\n * elements in the tree must render an to render their child route's\n * element.\n *\n * @see https://reactrouter.com/hooks/use-routes\n */\nexport function useRoutes(\n routes: RouteObject[],\n locationArg?: Partial | string\n): React.ReactElement | null {\n return useRoutesImpl(routes, locationArg);\n}\n\n// Internal implementation with accept optional param for RouterProvider usage\nexport function useRoutesImpl(\n routes: RouteObject[],\n locationArg?: Partial | string,\n dataRouterState?: RemixRouter[\"state\"]\n): React.ReactElement | null {\n invariant(\n useInRouterContext(),\n // TODO: This error is probably because they somehow have 2 versions of the\n // router loaded. We can help them understand how to avoid that.\n `useRoutes() may be used only in the context of a component.`\n );\n\n let { navigator } = React.useContext(NavigationContext);\n let { matches: parentMatches } = React.useContext(RouteContext);\n let routeMatch = parentMatches[parentMatches.length - 1];\n let parentParams = routeMatch ? routeMatch.params : {};\n let parentPathname = routeMatch ? routeMatch.pathname : \"/\";\n let parentPathnameBase = routeMatch ? routeMatch.pathnameBase : \"/\";\n let parentRoute = routeMatch && routeMatch.route;\n\n if (__DEV__) {\n // You won't get a warning about 2 different under a \n // without a trailing *, but this is a best-effort warning anyway since we\n // cannot even give the warning unless they land at the parent route.\n //\n // Example:\n //\n // \n // {/* This route path MUST end with /* because otherwise\n // it will never match /blog/post/123 */}\n // } />\n // } />\n // \n //\n // function Blog() {\n // return (\n // \n // } />\n // \n // );\n // }\n let parentPath = (parentRoute && parentRoute.path) || \"\";\n warningOnce(\n parentPathname,\n !parentRoute || parentPath.endsWith(\"*\"),\n `You rendered descendant (or called \\`useRoutes()\\`) at ` +\n `\"${parentPathname}\" (under ) but the ` +\n `parent route path has no trailing \"*\". This means if you navigate ` +\n `deeper, the parent won't match anymore and therefore the child ` +\n `routes will never render.\\n\\n` +\n `Please change the parent to .`\n );\n }\n\n let locationFromContext = useLocation();\n\n let location;\n if (locationArg) {\n let parsedLocationArg =\n typeof locationArg === \"string\" ? parsePath(locationArg) : locationArg;\n\n invariant(\n parentPathnameBase === \"/\" ||\n parsedLocationArg.pathname?.startsWith(parentPathnameBase),\n `When overriding the location using \\`\\` or \\`useRoutes(routes, location)\\`, ` +\n `the location pathname must begin with the portion of the URL pathname that was ` +\n `matched by all parent routes. The current pathname base is \"${parentPathnameBase}\" ` +\n `but pathname \"${parsedLocationArg.pathname}\" was given in the \\`location\\` prop.`\n );\n\n location = parsedLocationArg;\n } else {\n location = locationFromContext;\n }\n\n let pathname = location.pathname || \"/\";\n let remainingPathname =\n parentPathnameBase === \"/\"\n ? pathname\n : pathname.slice(parentPathnameBase.length) || \"/\";\n\n let matches = matchRoutes(routes, { pathname: remainingPathname });\n\n if (__DEV__) {\n warning(\n parentRoute || matches != null,\n `No routes matched location \"${location.pathname}${location.search}${location.hash}\" `\n );\n\n warning(\n matches == null ||\n matches[matches.length - 1].route.element !== undefined ||\n matches[matches.length - 1].route.Component !== undefined,\n `Matched leaf route at location \"${location.pathname}${location.search}${location.hash}\" ` +\n `does not have an element or Component. This means it will render an with a ` +\n `null value by default resulting in an \"empty\" page.`\n );\n }\n\n let renderedMatches = _renderMatches(\n matches &&\n matches.map((match) =>\n Object.assign({}, match, {\n params: Object.assign({}, parentParams, match.params),\n pathname: joinPaths([\n parentPathnameBase,\n // Re-encode pathnames that were decoded inside matchRoutes\n navigator.encodeLocation\n ? navigator.encodeLocation(match.pathname).pathname\n : match.pathname,\n ]),\n pathnameBase:\n match.pathnameBase === \"/\"\n ? parentPathnameBase\n : joinPaths([\n parentPathnameBase,\n // Re-encode pathnames that were decoded inside matchRoutes\n navigator.encodeLocation\n ? navigator.encodeLocation(match.pathnameBase).pathname\n : match.pathnameBase,\n ]),\n })\n ),\n parentMatches,\n dataRouterState\n );\n\n // When a user passes in a `locationArg`, the associated routes need to\n // be wrapped in a new `LocationContext.Provider` in order for `useLocation`\n // to use the scoped location instead of the global location.\n if (locationArg && renderedMatches) {\n return (\n \n {renderedMatches}\n \n );\n }\n\n return renderedMatches;\n}\n\nfunction DefaultErrorComponent() {\n let error = useRouteError();\n let message = isRouteErrorResponse(error)\n ? `${error.status} ${error.statusText}`\n : error instanceof Error\n ? error.message\n : JSON.stringify(error);\n let stack = error instanceof Error ? error.stack : null;\n let lightgrey = \"rgba(200,200,200, 0.5)\";\n let preStyles = { padding: \"0.5rem\", backgroundColor: lightgrey };\n let codeStyles = { padding: \"2px 4px\", backgroundColor: lightgrey };\n\n let devInfo = null;\n if (__DEV__) {\n console.error(\n \"Error handled by React Router default ErrorBoundary:\",\n error\n );\n\n devInfo = (\n <>\n

💿 Hey developer 👋

\n

\n You can provide a way better UX than this when your app throws errors\n by providing your own ErrorBoundary or{\" \"}\n errorElement prop on your route.\n

\n \n );\n }\n\n return (\n <>\n

Unexpected Application Error!

\n

{message}

\n {stack ?
{stack}
: null}\n {devInfo}\n \n );\n}\n\nconst defaultErrorElement = ;\n\ntype RenderErrorBoundaryProps = React.PropsWithChildren<{\n location: Location;\n revalidation: RevalidationState;\n error: any;\n component: React.ReactNode;\n routeContext: RouteContextObject;\n}>;\n\ntype RenderErrorBoundaryState = {\n location: Location;\n revalidation: RevalidationState;\n error: any;\n};\n\nexport class RenderErrorBoundary extends React.Component<\n RenderErrorBoundaryProps,\n RenderErrorBoundaryState\n> {\n constructor(props: RenderErrorBoundaryProps) {\n super(props);\n this.state = {\n location: props.location,\n revalidation: props.revalidation,\n error: props.error,\n };\n }\n\n static getDerivedStateFromError(error: any) {\n return { error: error };\n }\n\n static getDerivedStateFromProps(\n props: RenderErrorBoundaryProps,\n state: RenderErrorBoundaryState\n ) {\n // When we get into an error state, the user will likely click \"back\" to the\n // previous page that didn't have an error. Because this wraps the entire\n // application, that will have no effect--the error page continues to display.\n // This gives us a mechanism to recover from the error when the location changes.\n //\n // Whether we're in an error state or not, we update the location in state\n // so that when we are in an error state, it gets reset when a new location\n // comes in and the user recovers from the error.\n if (\n state.location !== props.location ||\n (state.revalidation !== \"idle\" && props.revalidation === \"idle\")\n ) {\n return {\n error: props.error,\n location: props.location,\n revalidation: props.revalidation,\n };\n }\n\n // If we're not changing locations, preserve the location but still surface\n // any new errors that may come through. We retain the existing error, we do\n // this because the error provided from the app state may be cleared without\n // the location changing.\n return {\n error: props.error || state.error,\n location: state.location,\n revalidation: props.revalidation || state.revalidation,\n };\n }\n\n componentDidCatch(error: any, errorInfo: any) {\n console.error(\n \"React Router caught the following error during render\",\n error,\n errorInfo\n );\n }\n\n render() {\n return this.state.error ? (\n \n \n \n ) : (\n this.props.children\n );\n }\n}\n\ninterface RenderedRouteProps {\n routeContext: RouteContextObject;\n match: RouteMatch;\n children: React.ReactNode | null;\n}\n\nfunction RenderedRoute({ routeContext, match, children }: RenderedRouteProps) {\n let dataRouterContext = React.useContext(DataRouterContext);\n\n // Track how deep we got in our render pass to emulate SSR componentDidCatch\n // in a DataStaticRouter\n if (\n dataRouterContext &&\n dataRouterContext.static &&\n dataRouterContext.staticContext &&\n (match.route.errorElement || match.route.ErrorBoundary)\n ) {\n dataRouterContext.staticContext._deepestRenderedBoundaryId = match.route.id;\n }\n\n return (\n \n {children}\n \n );\n}\n\nexport function _renderMatches(\n matches: RouteMatch[] | null,\n parentMatches: RouteMatch[] = [],\n dataRouterState: RemixRouter[\"state\"] | null = null\n): React.ReactElement | null {\n if (matches == null) {\n if (dataRouterState?.errors) {\n // Don't bail if we have data router errors so we can render them in the\n // boundary. Use the pre-matched (or shimmed) matches\n matches = dataRouterState.matches as DataRouteMatch[];\n } else {\n return null;\n }\n }\n\n let renderedMatches = matches;\n\n // If we have data errors, trim matches to the highest error boundary\n let errors = dataRouterState?.errors;\n if (errors != null) {\n let errorIndex = renderedMatches.findIndex(\n (m) => m.route.id && errors?.[m.route.id]\n );\n invariant(\n errorIndex >= 0,\n `Could not find a matching route for errors on route IDs: ${Object.keys(\n errors\n ).join(\",\")}`\n );\n renderedMatches = renderedMatches.slice(\n 0,\n Math.min(renderedMatches.length, errorIndex + 1)\n );\n }\n\n return renderedMatches.reduceRight((outlet, match, index) => {\n let error = match.route.id ? errors?.[match.route.id] : null;\n // Only data routers handle errors\n let errorElement: React.ReactNode | null = null;\n if (dataRouterState) {\n errorElement = match.route.errorElement || defaultErrorElement;\n }\n let matches = parentMatches.concat(renderedMatches.slice(0, index + 1));\n let getChildren = () => {\n let children: React.ReactNode;\n if (error) {\n children = errorElement;\n } else if (match.route.Component) {\n // Note: This is a de-optimized path since React won't re-use the\n // ReactElement since it's identity changes with each new\n // React.createElement call. We keep this so folks can use\n // `` in `` but generally `Component`\n // usage is only advised in `RouterProvider` when we can convert it to\n // `element` ahead of time.\n children = ;\n } else if (match.route.element) {\n children = match.route.element;\n } else {\n children = outlet;\n }\n return (\n \n );\n };\n // Only wrap in an error boundary within data router usages when we have an\n // ErrorBoundary/errorElement on this route. Otherwise let it bubble up to\n // an ancestor ErrorBoundary/errorElement\n return dataRouterState &&\n (match.route.ErrorBoundary || match.route.errorElement || index === 0) ? (\n \n ) : (\n getChildren()\n );\n }, null as React.ReactElement | null);\n}\n\nenum DataRouterHook {\n UseBlocker = \"useBlocker\",\n UseRevalidator = \"useRevalidator\",\n UseNavigateStable = \"useNavigate\",\n}\n\nenum DataRouterStateHook {\n UseBlocker = \"useBlocker\",\n UseLoaderData = \"useLoaderData\",\n UseActionData = \"useActionData\",\n UseRouteError = \"useRouteError\",\n UseNavigation = \"useNavigation\",\n UseRouteLoaderData = \"useRouteLoaderData\",\n UseMatches = \"useMatches\",\n UseRevalidator = \"useRevalidator\",\n UseNavigateStable = \"useNavigate\",\n UseRouteId = \"useRouteId\",\n}\n\nfunction getDataRouterConsoleError(\n hookName: DataRouterHook | DataRouterStateHook\n) {\n return `${hookName} must be used within a data router. See https://reactrouter.com/routers/picking-a-router.`;\n}\n\nfunction useDataRouterContext(hookName: DataRouterHook) {\n let ctx = React.useContext(DataRouterContext);\n invariant(ctx, getDataRouterConsoleError(hookName));\n return ctx;\n}\n\nfunction useDataRouterState(hookName: DataRouterStateHook) {\n let state = React.useContext(DataRouterStateContext);\n invariant(state, getDataRouterConsoleError(hookName));\n return state;\n}\n\nfunction useRouteContext(hookName: DataRouterStateHook) {\n let route = React.useContext(RouteContext);\n invariant(route, getDataRouterConsoleError(hookName));\n return route;\n}\n\n// Internal version with hookName-aware debugging\nfunction useCurrentRouteId(hookName: DataRouterStateHook) {\n let route = useRouteContext(hookName);\n let thisRoute = route.matches[route.matches.length - 1];\n invariant(\n thisRoute.route.id,\n `${hookName} can only be used on routes that contain a unique \"id\"`\n );\n return thisRoute.route.id;\n}\n\n/**\n * Returns the ID for the nearest contextual route\n */\nexport function useRouteId() {\n return useCurrentRouteId(DataRouterStateHook.UseRouteId);\n}\n\n/**\n * Returns the current navigation, defaulting to an \"idle\" navigation when\n * no navigation is in progress\n */\nexport function useNavigation() {\n let state = useDataRouterState(DataRouterStateHook.UseNavigation);\n return state.navigation;\n}\n\n/**\n * Returns a revalidate function for manually triggering revalidation, as well\n * as the current state of any manual revalidations\n */\nexport function useRevalidator() {\n let dataRouterContext = useDataRouterContext(DataRouterHook.UseRevalidator);\n let state = useDataRouterState(DataRouterStateHook.UseRevalidator);\n return {\n revalidate: dataRouterContext.router.revalidate,\n state: state.revalidation,\n };\n}\n\n/**\n * Returns the active route matches, useful for accessing loaderData for\n * parent/child routes or the route \"handle\" property\n */\nexport function useMatches() {\n let { matches, loaderData } = useDataRouterState(\n DataRouterStateHook.UseMatches\n );\n return React.useMemo(\n () =>\n matches.map((match) => {\n let { pathname, params } = match;\n // Note: This structure matches that created by createUseMatchesMatch\n // in the @remix-run/router , so if you change this please also change\n // that :) Eventually we'll DRY this up\n return {\n id: match.route.id,\n pathname,\n params,\n data: loaderData[match.route.id] as unknown,\n handle: match.route.handle as unknown,\n };\n }),\n [matches, loaderData]\n );\n}\n\n/**\n * Returns the loader data for the nearest ancestor Route loader\n */\nexport function useLoaderData(): unknown {\n let state = useDataRouterState(DataRouterStateHook.UseLoaderData);\n let routeId = useCurrentRouteId(DataRouterStateHook.UseLoaderData);\n\n if (state.errors && state.errors[routeId] != null) {\n console.error(\n `You cannot \\`useLoaderData\\` in an errorElement (routeId: ${routeId})`\n );\n return undefined;\n }\n return state.loaderData[routeId];\n}\n\n/**\n * Returns the loaderData for the given routeId\n */\nexport function useRouteLoaderData(routeId: string): unknown {\n let state = useDataRouterState(DataRouterStateHook.UseRouteLoaderData);\n return state.loaderData[routeId];\n}\n\n/**\n * Returns the action data for the nearest ancestor Route action\n */\nexport function useActionData(): unknown {\n let state = useDataRouterState(DataRouterStateHook.UseActionData);\n\n let route = React.useContext(RouteContext);\n invariant(route, `useActionData must be used inside a RouteContext`);\n\n return Object.values(state?.actionData || {})[0];\n}\n\n/**\n * Returns the nearest ancestor Route error, which could be a loader/action\n * error or a render error. This is intended to be called from your\n * ErrorBoundary/errorElement to display a proper error message.\n */\nexport function useRouteError(): unknown {\n let error = React.useContext(RouteErrorContext);\n let state = useDataRouterState(DataRouterStateHook.UseRouteError);\n let routeId = useCurrentRouteId(DataRouterStateHook.UseRouteError);\n\n // If this was a render error, we put it in a RouteError context inside\n // of RenderErrorBoundary\n if (error) {\n return error;\n }\n\n // Otherwise look for errors from our data router state\n return state.errors?.[routeId];\n}\n\n/**\n * Returns the happy-path data from the nearest ancestor value\n */\nexport function useAsyncValue(): unknown {\n let value = React.useContext(AwaitContext);\n return value?._data;\n}\n\n/**\n * Returns the error from the nearest ancestor value\n */\nexport function useAsyncError(): unknown {\n let value = React.useContext(AwaitContext);\n return value?._error;\n}\n\nlet blockerId = 0;\n\n/**\n * Allow the application to block navigations within the SPA and present the\n * user a confirmation dialog to confirm the navigation. Mostly used to avoid\n * using half-filled form data. This does not handle hard-reloads or\n * cross-origin navigations.\n */\nexport function useBlocker(shouldBlock: boolean | BlockerFunction): Blocker {\n let { router, basename } = useDataRouterContext(DataRouterHook.UseBlocker);\n let state = useDataRouterState(DataRouterStateHook.UseBlocker);\n\n let [blockerKey, setBlockerKey] = React.useState(\"\");\n let blockerFunction = React.useCallback(\n (arg) => {\n if (typeof shouldBlock !== \"function\") {\n return !!shouldBlock;\n }\n if (basename === \"/\") {\n return shouldBlock(arg);\n }\n\n // If they provided us a function and we've got an active basename, strip\n // it from the locations we expose to the user to match the behavior of\n // useLocation\n let { currentLocation, nextLocation, historyAction } = arg;\n return shouldBlock({\n currentLocation: {\n ...currentLocation,\n pathname:\n stripBasename(currentLocation.pathname, basename) ||\n currentLocation.pathname,\n },\n nextLocation: {\n ...nextLocation,\n pathname:\n stripBasename(nextLocation.pathname, basename) ||\n nextLocation.pathname,\n },\n historyAction,\n });\n },\n [basename, shouldBlock]\n );\n\n // This effect is in charge of blocker key assignment and deletion (which is\n // tightly coupled to the key)\n React.useEffect(() => {\n let key = String(++blockerId);\n setBlockerKey(key);\n return () => router.deleteBlocker(key);\n }, [router]);\n\n // This effect handles assigning the blockerFunction. This is to handle\n // unstable blocker function identities, and happens only after the prior\n // effect so we don't get an orphaned blockerFunction in the router with a\n // key of \"\". Until then we just have the IDLE_BLOCKER.\n React.useEffect(() => {\n if (blockerKey !== \"\") {\n router.getBlocker(blockerKey, blockerFunction);\n }\n }, [router, blockerKey, blockerFunction]);\n\n // Prefer the blocker from `state` not `router.state` since DataRouterContext\n // is memoized so this ensures we update on blocker state updates\n return blockerKey && state.blockers.has(blockerKey)\n ? state.blockers.get(blockerKey)!\n : IDLE_BLOCKER;\n}\n\n/**\n * Stable version of useNavigate that is used when we are in the context of\n * a RouterProvider.\n */\nfunction useNavigateStable(): NavigateFunction {\n let { router } = useDataRouterContext(DataRouterHook.UseNavigateStable);\n let id = useCurrentRouteId(DataRouterStateHook.UseNavigateStable);\n\n let activeRef = React.useRef(false);\n useIsomorphicLayoutEffect(() => {\n activeRef.current = true;\n });\n\n let navigate: NavigateFunction = React.useCallback(\n (to: To | number, options: NavigateOptions = {}) => {\n warning(activeRef.current, navigateEffectWarning);\n\n // Short circuit here since if this happens on first render the navigate\n // is useless because we haven't wired up our router subscriber yet\n if (!activeRef.current) return;\n\n if (typeof to === \"number\") {\n router.navigate(to);\n } else {\n router.navigate(to, { fromRouteId: id, ...options });\n }\n },\n [router, id]\n );\n\n return navigate;\n}\n\nconst alreadyWarned: Record = {};\n\nfunction warningOnce(key: string, cond: boolean, message: string) {\n if (!cond && !alreadyWarned[key]) {\n alreadyWarned[key] = true;\n warning(false, message);\n }\n}\n","import * as React from \"react\";\nimport type {\n TrackedPromise,\n InitialEntry,\n Location,\n MemoryHistory,\n Router as RemixRouter,\n To,\n LazyRouteFunction,\n RelativeRoutingType,\n RouterState,\n} from \"@remix-run/router\";\nimport {\n Action as NavigationType,\n AbortedDeferredError,\n createMemoryHistory,\n UNSAFE_invariant as invariant,\n parsePath,\n resolveTo,\n stripBasename,\n UNSAFE_warning as warning,\n UNSAFE_getPathContributingMatches as getPathContributingMatches,\n} from \"@remix-run/router\";\n\nimport type {\n DataRouteObject,\n IndexRouteObject,\n RouteMatch,\n RouteObject,\n Navigator,\n NonIndexRouteObject,\n} from \"./context\";\nimport {\n LocationContext,\n NavigationContext,\n DataRouterContext,\n DataRouterStateContext,\n AwaitContext,\n RouteContext,\n} from \"./context\";\nimport {\n useAsyncValue,\n useInRouterContext,\n useNavigate,\n useOutlet,\n useRoutes,\n _renderMatches,\n useRoutesImpl,\n useLocation,\n} from \"./hooks\";\n\nexport interface FutureConfig {\n v7_startTransition: boolean;\n}\n\nexport interface RouterProviderProps {\n fallbackElement?: React.ReactNode;\n router: RemixRouter;\n future?: FutureConfig;\n}\n\n/**\n Webpack + React 17 fails to compile on any of the following because webpack\n complains that `startTransition` doesn't exist in `React`:\n * import { startTransition } from \"react\"\n * import * as React from from \"react\";\n \"startTransition\" in React ? React.startTransition(() => setState()) : setState()\n * import * as React from from \"react\";\n \"startTransition\" in React ? React[\"startTransition\"](() => setState()) : setState()\n\n Moving it to a constant such as the following solves the Webpack/React 17 issue:\n * import * as React from from \"react\";\n const START_TRANSITION = \"startTransition\";\n START_TRANSITION in React ? React[START_TRANSITION](() => setState()) : setState()\n\n However, that introduces webpack/terser minification issues in production builds\n in React 18 where minification/obfuscation ends up removing the call of\n React.startTransition entirely from the first half of the ternary. Grabbing\n this exported reference once up front resolves that issue.\n\n See https://github.com/remix-run/react-router/issues/10579\n*/\nconst START_TRANSITION = \"startTransition\";\nconst startTransitionImpl = React[START_TRANSITION];\n\n/**\n * Given a Remix Router instance, render the appropriate UI\n */\nexport function RouterProvider({\n fallbackElement,\n router,\n future,\n}: RouterProviderProps): React.ReactElement {\n // Need to use a layout effect here so we are subscribed early enough to\n // pick up on any render-driven redirects/navigations (useEffect/)\n let [state, setStateImpl] = React.useState(router.state);\n let { v7_startTransition } = future || {};\n let setState = React.useCallback(\n (newState: RouterState) => {\n v7_startTransition && startTransitionImpl\n ? startTransitionImpl(() => setStateImpl(newState))\n : setStateImpl(newState);\n },\n [setStateImpl, v7_startTransition]\n );\n React.useLayoutEffect(() => router.subscribe(setState), [router, setState]);\n\n let navigator = React.useMemo((): Navigator => {\n return {\n createHref: router.createHref,\n encodeLocation: router.encodeLocation,\n go: (n) => router.navigate(n),\n push: (to, state, opts) =>\n router.navigate(to, {\n state,\n preventScrollReset: opts?.preventScrollReset,\n }),\n replace: (to, state, opts) =>\n router.navigate(to, {\n replace: true,\n state,\n preventScrollReset: opts?.preventScrollReset,\n }),\n };\n }, [router]);\n\n let basename = router.basename || \"/\";\n\n let dataRouterContext = React.useMemo(\n () => ({\n router,\n navigator,\n static: false,\n basename,\n }),\n [router, navigator, basename]\n );\n\n // The fragment and {null} here are important! We need them to keep React 18's\n // useId happy when we are server-rendering since we may have a