@arcgis/core 5.1.0-next.45 → 5.1.0-next.46

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/{288bd32831e94e81653e.js → 08d76c600926d7642a8b.js} +1 -1
  3. package/assets/esri/core/workers/chunks/{54db91c0a3bd1946e026.js → 0d59f5cd3fdd7d6fd693.js} +1 -1
  4. package/assets/esri/core/workers/chunks/{288082ae7b19837a3d38.js → 20e715e3aeb1c3265901.js} +1 -1
  5. package/assets/esri/core/workers/chunks/{0155e5679ded9de5c327.js → 3a7c02616d942c81257d.js} +1 -1
  6. package/assets/esri/core/workers/chunks/3e9700445518b8f9ae1b.js +1 -0
  7. package/assets/esri/core/workers/chunks/{375eac59c9f88c7572db.js → 4b3545965b11a54184d4.js} +2 -2
  8. package/assets/esri/core/workers/chunks/{d3d024b3d2bb8fbbf760.js → 569e4479707bc6881d97.js} +1 -1
  9. package/assets/esri/core/workers/chunks/{8cafdd4addd366795600.js → 6c49ac7888679b9f7823.js} +1 -1
  10. package/assets/esri/core/workers/chunks/{ca88a364ef911526102e.js → 7b48c102a44606291f82.js} +1 -1
  11. package/assets/esri/core/workers/chunks/{e5927f9d0e757ec4c22a.js → a422cfe1e2afe0722acd.js} +1 -1
  12. package/assets/esri/core/workers/chunks/{f6e3954ddbb5993d56df.js → b45fdc04d399d2849d63.js} +1 -1
  13. package/assets/esri/core/workers/chunks/{dbafe96ce37bb82d0584.js → b49b608c0d58a9b55fa2.js} +1 -1
  14. package/assets/esri/core/workers/chunks/b744b950999b92393e37.js +1 -0
  15. package/assets/esri/core/workers/chunks/{1a3f874700f86b750390.js → ce0a6bc9df30af778ac9.js} +2 -2
  16. package/assets/esri/core/workers/chunks/{b86cb84c03b76e824213.js → f9fe89ced41b49608667.js} +1 -1
  17. package/assets/esri/core/workers/chunks/{bf4d2f42d31861ea1046.js → ff75fb0fce51ac12e656.js} +1 -1
  18. package/chunks/GaussianSplat.glsl.js +2 -2
  19. package/chunks/HUDMaterial.glsl.js +1 -1
  20. package/chunks/LineCallout.glsl.js +1 -1
  21. package/chunks/PointRenderer.glsl.js +1 -1
  22. package/chunks/Terrain.glsl.js +4 -4
  23. package/config.js +1 -1
  24. package/kernel.js +1 -1
  25. package/layers/IntegratedMesh3DTilesLayer.d.ts +2 -1
  26. package/layers/IntegratedMesh3DTilesLayer.js +1 -1
  27. package/layers/knowledgeGraph/dataModelVisualizationUtils.js +1 -1
  28. package/layers/support/schemaValidator.js +1 -1
  29. package/libs/ajv/ajv.bundle-wrapper.js +2 -0
  30. package/package.json +3 -3
  31. package/renderers/visualVariables/SizeVariable.js +1 -1
  32. package/rest/locator/locationToAddress.js +1 -1
  33. package/rest/support/LocationToAddressParameters.d.ts +62 -2
  34. package/rest/support/types.d.ts +6 -0
  35. package/support/revision.js +1 -1
  36. package/views/2d/analysis/AreaMeasurement/AreaMeasurementTool.js +1 -1
  37. package/views/2d/engine/vectorTiles/Placement.js +1 -1
  38. package/views/3d/layers/GaussianSplatLayerView3D.js +1 -1
  39. package/views/3d/terrain/OverlayRenderer.js +1 -1
  40. package/views/3d/terrain/TerrainRenderer.js +1 -1
  41. package/views/3d/terrain/TileCompositor.js +1 -1
  42. package/views/3d/webgl-engine/core/shaderLibrary/Slice.glsl.js +3 -3
  43. package/views/3d/webgl-engine/effects/debug/RenderNodeVisualizerNode.js +1 -1
  44. package/views/3d/webgl-engine/effects/highlight/ShadowHighlight.js +1 -1
  45. package/views/3d/webgl-engine/lib/BindParameters.js +1 -1
  46. package/views/3d/webgl-engine/lib/GaussianSplatRenderNode.js +1 -1
  47. package/views/3d/webgl-engine/lib/RenderContext.js +1 -1
  48. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  49. package/views/3d/webgl-engine/lib/ShadowAccumulator.js +1 -1
  50. package/views/3d/webgl-engine/shaders/GaussianSplat.glsl.js +1 -1
  51. package/views/3d/webgl-engine/shaders/GaussianSplatTechniqueConfiguration.js +1 -1
  52. package/views/3d/webgl-engine/shaders/OutputColorHighlightOLID.glsl.js +1 -1
  53. package/views/webgl/InstanceCounter.js +1 -1
  54. package/webscene/support/schemaValidator.js +1 -1
  55. package/widgets/Editor/workflowUtils.js +1 -1
  56. package/widgets/Sketch/SketchViewModel.js +1 -1
  57. package/assets/esri/core/workers/chunks/385f1bb9164b2d488b2d.js +0 -1
  58. package/assets/esri/core/workers/chunks/73d7337ac9efdbad14a4.js +0 -1
  59. package/chunks/ajv.bundle.js +0 -2
  60. /package/assets/esri/core/workers/chunks/{375eac59c9f88c7572db.js.LICENSE.txt → 4b3545965b11a54184d4.js.LICENSE.txt} +0 -0
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../../Graphic.js";import{isSome as o}from"../../core/arrayUtils.js";import i from"../../core/Collection.js";import a from"../../core/Error.js";import{EventedAccessor as r}from"../../core/Evented.js";import{drainHandles as s,destroyHandle as n}from"../../core/handleUtils.js";import"../../core/has.js";import p from"../../core/Logger.js";import{destroyMaybe as l,abortMaybe as h}from"../../core/maybe.js";import{createAbortError as c,whenOrAbort as d,ignoreAbortErrors as u}from"../../core/promiseUtils.js";import{watch as g,syncAndInitial as m,on as y,when as v,whenOnce as f}from"../../core/reactiveUtils.js";import{property as _,subclass as b}from"../../core/accessorSupport/decorators.js";import{UpdatingHandles as w}from"../../core/support/UpdatingHandles.js";import{getReferenceEllipsoid as G}from"../../geometry/ellipsoidUtils.js";import{canProjectWithoutEngine as T,isLoaded as O,load as S,project as E}from"../../geometry/projectionUtils.js";import{geometryToCoordinates as C}from"../../geometry/support/coordsUtils.js";import{equals as M}from"../../geometry/support/spatialReferenceUtils.js";import A from"../../layers/GraphicsLayer.js";import{isIntegratedMeshLayer as k}from"../../layers/support/layerUtils.js";import{getEffectiveElevationInfo as H}from"../../support/elevationInfoUtils.js";import D from"../../symbols/FillSymbol3DLayer.js";import I from"../../symbols/MeshSymbol3D.js";import P from"../../symbols/SimpleFillSymbol.js";import j from"../../symbols/SimpleLineSymbol.js";import R from"../../symbols/SimpleMarkerSymbol.js";import x from"../../symbols/TextSymbol.js";import{symbolTypes as U}from"../../symbols/support/typeUtils.js";import{isSupportedObjectResultMessage as L}from"../../views/3d/interactive/editingTools/isSupportedObjectUtils.js";import{isSupportedObject as F}from"../../views/3d/interactive/editingTools/move/isSupportedObject.js";import{isSupportedObject as V}from"../../views/3d/interactive/editingTools/reshape/isSupportedObject.js";import{isSupportedGraphic as K}from"../../views/3d/interactive/editingTools/transform/isSupportedGraphic.js";import{addUniqueLayer as W}from"../../views/draw/support/layerUtils.js";import{ViewEventPriorities as Z}from"../../views/input/InputManager.js";import{sketchKeys as q}from"../../views/interactive/keybindings.js";import N from"../../views/interactive/sketch/SketchLabelOptions.js";import z from"../../views/interactive/sketch/SketchOptions.js";import B from"../../views/interactive/sketch/SketchTooltipOptions.js";import $ from"../../views/interactive/sketch/SketchValueOptions.js";import{SnappingManager as Y}from"../../views/interactive/snapping/SnappingManager.js";import J from"../../views/interactive/snapping/SnappingOptions.js";import{setupSnappingToggleHandles as Q}from"../../views/interactive/snapping/snappingUtils.js";import{defaultHighlightName as X}from"../../views/support/HighlightDefaults.js";import{findFirstGraphicHit as ee}from"../../views/support/hitTestSelectUtils.js";import{createScreenPointFromEvent as te}from"../../views/support/screenUtils.js";import oe from"./adapters/layer/GraphicsLayerAdapter.js";import ie from"./adapters/layer/MapNotesLayerAdapter.js";import{CreateOperationHandle as ae,DrawToolOperationHandle as re,UpdateOperationHandle as se}from"./support/OperationHandle.js";import{PluginManager as ne}from"./support/PluginManager.js";import{getLegacyTool as pe,isCompletelyDegenerate as le,graphicsHaveTooFewVerticesForBox as he,getModeFromCreateOptions as ce,getDrawToolGeometryTypeFromCreateTool as de}from"./support/sketchUtils.js";const ue={defaultZ:0},ge={reshapeOptions:{edgeOperation:"split",shapeOperation:"move",vertexOperation:"move",enableCreateCurveFromStraightEdge:!0},enableMoveAllGraphics:!0,enableRotation:!0,enableScaling:!0,multipleSelectionEnabled:!0,preserveAspectRatio:!1,toggleToolOnClick:!0,enableZ:!0,highlightOptions:{enabled:!0,name:X},tool:"transform"},me=Symbol(),ye=Symbol();let ve=class extends r{constructor(e){super(e),this._defaultSnappingManager=null,this._internalGraphicsLayer=new A({listMode:"hide",internal:!0,title:"SVM Internal"}),this._pluginManager=new ne({sketchViewModel:this}),this._operationHandle=null,this._updatingHandles=new w,this._viewHandlesKey="viewHandles",this.activeFillSymbol=null,this.activeLineSymbol=null,this.activeVertexSymbol=null,this.allowDeleteKey=!0,this.layer=null,this.pointSymbol=new R({style:"circle",size:6,color:[255,255,255],outline:{color:[50,50,50],width:1}}),this.polygonSymbol=new P({color:[150,150,150,.2],outline:{color:[50,50,50],width:2}}),this.polylineSymbol=new j({color:[130,130,130,1],width:2}),this.meshSymbol=new I({symbolLayers:new i([new D])}),this.updateGraphics=new i,this.updateOnGraphicClick=!0,this.creationMode="single",this.vertexSymbol=new R({style:"circle",size:6,color:[255,255,255],outline:{color:[50,50,50],width:1}}),this.sketchOptions=new z,this.useLegacyCreateTools=!0,this._moduleLoaderAbortController=null,this._viewReadyAbortController=null,this._sketchContinuationFlag=!1,this._onLayerAdapterChange=async()=>{const{_layerAdapter:e}=this;if(this.removeHandles(ye),!e)return;const t=[e.onGraphicsChange(e=>this._onLayerGraphicsChangeCallback(e)),g(()=>e.elevationInfo,e=>{e!==this._internalGraphicsLayer.elevationInfo&&(this.cancel(),this._internalGraphicsLayer&&(this._internalGraphicsLayer.elevationInfo=e))},m)].filter(o);this.addHandles(t,ye)},this._originalPopupEnabled=null,this.defaultCreateOptions=ue,this.defaultUpdateOptions=ge,this.snappingOptions=e?.snappingManager?.options??e?.snappingOptions??new J,this.textSymbol=new x({text:"text"})}initialize(){this._updatingHandles.addPromise(this._setupAdvancedDrawToolIntegrationMaybe()),this.addHandles([y(()=>this.view?.map?.layers,"change",e=>{this.layer&&e.removed.includes(this.layer)&&this.cancel()}),g(()=>this._layerAdapter,()=>this._onLayerAdapterChange(),m),g(()=>this.view,e=>{this._defaultSnappingManager=l(this._defaultSnappingManager),e&&(this.snappingManager||(this._defaultSnappingManager=new Y({view:e,options:this.snappingOptions})),"2d"===e.type?(import("../../views/2d/interactive/editingTools.js"),this._updatingHandles.addPromise(this._setupAdvancedDrawToolIntegrationMaybe())):"3d"===e.type&&(import("../../views/3d/interactive/editingTools.js"),import("../../views/3d/layers/GraphicsLayerView3D.js")))},m),g(()=>this.view?.spatialReference,(e,t)=>{e&&t&&!e.equals(t)&&this.cancel()})]),Q(this)}destroy(){this.cancel(),this._removeDefaultLayer(),this._defaultSnappingManager=l(this._defaultSnappingManager),this._set("snappingManager",null),this._set("view",null),this._updatingHandles.destroy(),this._pluginManager?.destroy(),this.emit("destroy")}get _layerAdapter(){const{layer:e}=this;switch(e?.type){case"graphics":return new oe(e);case"map-notes":return new ie(e);default:return null}}get activeTool(){return this._operationHandle?.tool??null}get activeCreateToolDrawMode(){const e=this._operationHandle;if("create"===e?.type&&e.activeComponent&&"mode"in e.activeComponent)return e.activeComponent.mode;if("draw-2.0"===e?.activeComponent?.type){const t=e.activeComponent.pluginStack.map(e=>e.configuration).filter(o).toArray();if(t.length>0)return this._pluginManager?.getDrawingModeEquivalentToPluginStack(t)}return null}get activeTooltip(){const{activeComponent:e,destroyed:t}=this,o=!t&&e&&"tooltip"in e?e.tooltip:null;return o?.visible?o:null}get activeComponent(){return this._operationHandle?.activeComponent??null}get createGraphic(){return null==this.activeComponent||"draw-3d"!==this.activeComponent.type&&"draw-2d"!==this.activeComponent.type?this._get("createGraphic"):this.activeComponent.graphic}get defaultCreateOptions(){return this._get("defaultCreateOptions")}set defaultCreateOptions(e){this._set("defaultCreateOptions",{...ue,...e})}get defaultUpdateOptions(){return this._get("defaultUpdateOptions")}set defaultUpdateOptions(e){this._set("defaultUpdateOptions",{...ge,...e,reshapeOptions:{...ge.reshapeOptions,...e?.reshapeOptions},highlightOptions:{...ge.highlightOptions,...e?.highlightOptions}})}get labelOptions(){return this.sketchOptions.labels}set labelOptions(e){this.sketchOptions.labels=e}get textSymbol(){return this._get("textSymbol")}set textSymbol(e){this._set("textSymbol",e)}get snappingOptions(){return this.snappingManager?.options??this._get("snappingOptions")}set snappingOptions(e){null!=this._defaultSnappingManager&&(this._defaultSnappingManager.options=e),this._set("snappingOptions",e)}get snappingManager(){return this._isOverridden("snappingManager")&&this._get("snappingManager"),this._defaultSnappingManager}set snappingManager(e){if(e)this._isOverridden("snappingManager")||(this._defaultSnappingManager=l(this._defaultSnappingManager)),this._override("snappingManager",e);else{const{view:e}=this;!this._defaultSnappingManager&&e&&(this._defaultSnappingManager=new Y({options:this.snappingOptions,view:e})),this._clearOverride("snappingManager")}}get state(){const e=!(!this.view?.ready||!this.layer),t=this._operationHandle;return e&&t?"active":e?"ready":"disabled"}get tooltipOptions(){return this.sketchOptions.tooltips}set tooltipOptions(e){this.sketchOptions.tooltips=e}get updating(){return this.activeComponent&&"updating"in this.activeComponent&&this.activeComponent.updating||!!(this._updatingHandles.updating||this.snappingManager?.updating||this.drawTool?.updating)}get valueOptions(){return this.sketchOptions.values}set valueOptions(e){this.sketchOptions.values=e}get view(){return this._get("view")}set view(e){const t=this._get("view");if(t){const{container:e,map:o}=t;e&&this._clearCursor(),o?.remove(this._internalGraphicsLayer),this.removeHandles(this._viewHandlesKey),this.cancel()}const o="view-ready";this.removeHandles(o),e&&this.addHandles(v(()=>e.ready,t=>{this.removeHandles(this._viewHandlesKey),t&&this.addHandles(this._generateViewHandles(e),this._viewHandlesKey)},m),o),this._set("view",e),this._updatingHandles.addPromise(this._setupAdvancedDrawToolIntegrationMaybe())}get isUsingLegacyCreateTools(){return this.useLegacyCreateTools||"2d"!==this.view?.type}get pluginManager(){return this._pluginManager}get drawTool(){return"draw-2.0"!==this.activeComponent?.type?null:this.activeComponent}get rootPlugins(){return this._pluginManager?.availablePlugins}set rootPlugins(e){this._overrideIfSome("rootPlugins",e)}get effectiveAvailablePlugins(){if(this.isUsingLegacyCreateTools)return null;const e=this.view?.type??"2d",{firstPluginWithSwappableLeaf:t}=this;return t?t.availableDownstreamPlugins.filter(t=>!t.excludedViews?.includes(e)):this.rootPlugins?.filter(t=>!t.excludedViews?.includes(e)).filter(o)??[]}get firstPluginWithSwappableLeaf(){const e=this.view?.type??"2d",t=this.drawTool?.pluginStack.toArray().map(e=>e.configuration).findLast(t=>null!=t&&!t.hidden&&t.availableDownstreamPlugins&&t.availableDownstreamPlugins.filter(t=>!t.excludedViews?.includes(e))?.length>1);return t}get multiplePluginsActive(){return!!this.drawTool&&this.drawTool.pluginStack.length>1}addGraphic(e){this._layerAdapter?.add(e)}addGraphics(e){this._layerAdapter?.addMany(e)}hasGraphic(e){return!!this._layerAdapter?.has(e)}removeGraphic(e){this._layerAdapter?.remove(e)}removeGraphics(e){this._layerAdapter?.removeMany(e)}removeAllGraphics(){this._layerAdapter?.removeAll()}cancel(){this._moduleLoaderAbortController=h(this._moduleLoaderAbortController),this._viewReadyAbortController=h(this._viewReadyAbortController),this._sketchContinuationFlag=!0,this._operationHandle?.cancel()}complete(){this._operationHandle?.complete()}delete(){const{state:e,updateGraphics:t}=this;if("active"===e&&t.length){const{activeTool:e}=this,o=t.toArray();this.removeGraphics(o),this.cancel(),this._emitDeleteEvent({graphics:o,tool:e})}}duplicate(){if("active"===this.state&&this.updateGraphics.length){const e=this.updateGraphics.map(e=>e.clone()).toArray();return this.addGraphics(e),this.emit("duplicate",{graphics:e,type:"duplicate"}),e}return[]}async create(e,t){this.cancel(),await this._waitViewReady();const{view:o,layer:i}=this;if(!o||"disabled"===this.state)throw i||this._logMissingLayer(),c();if(null!=o.activeTool&&(o.activeTool=null),!e)return void this._logError("sketch:missing-parameter","Missing parameter 'tool'.");W(o,this._internalGraphicsLayer);const a=await this._updatingHandles.addPromise(this._setupCreateOperation(e,t));if(null==a||this.destroyed)return void o.map?.remove(this._internalGraphicsLayer);const r=pe(e),s=()=>{if(a===this._operationHandle){const o=this.createGraphic,i=this._operationHandle.cancelled;if(this._operationHandle.destroy(),this._operationHandle=null,this._set("createGraphic",null),this.view?.map?.remove(this._internalGraphicsLayer),a.cancelled||null==o||this.addGraphic(o),this._sketchContinuationFlag=!1,this.emit("create",{graphic:o,state:i?"cancel":"complete",tool:r??"point",toolEventInfo:null,type:"create"}),i||this._sketchContinuationFlag)return;const{creationMode:s}=this;if("continuous"===s){if(t?.geometryToPlace)return;this._updatingHandles.consumePromise(u(this.create(e,t)))}else"update"===s&&o&&this._updatingHandles.consumePromise(u(this.update([o])))}};a.on("complete",s),this._operationHandle=a,o.ready&&o.focus()}async place(e,t){return await e.load(),this.create("mesh",{mode:"click",hasZ:e.hasZ,geometryToPlace:e,...t})}async update(e,t){this.cancel(),await this._waitViewReady();const{layer:o,view:i,state:a}=this;if(!i||"disabled"===a)throw o||this._logMissingLayer(),c();null!=i.activeTool&&(i.activeTool=null);const r=Array.isArray(e)?e:[e];if(null==e||!r?.length)return void this._logError("sketch:missing-parameter","Missing parameter 'graphics'.");if(r.some(e=>this.hasGraphic(e)?null==e.geometry&&(this._logError("sketch:invalid-parameter","Parameter 'graphics' contains one or more graphics with an unsupported geometry."),!0):(this._logError("sketch:invalid-parameter","Parameter 'graphics' contains one or more graphics missing from the supplied GraphicsLayer."),!0)))return;const s=await this._updatingHandles.addPromise(this._setupUpdateOperation(r,t));this.destroyed||null==s||Ce(s)||(W(i,this._internalGraphicsLayer),this._setUpdateOperationHandle(s,t),this.emit("update",{graphics:r,state:"start",aborted:!1,tool:s.tool,toolEventInfo:null,type:"update"}))}async _updateSpatialReference(e){const t=this.view;if(t){e=Array.isArray(e)?e:[e];for(const o of e)null==o.geometry||"mesh"===o.geometry.type||M(o.geometry.spatialReference,t.spatialReference)||(T(o.geometry.spatialReference,t.spatialReference)||O()||await S(),o.geometry=E(o.geometry,t.spatialReference))}else this._logMissingView()}undo(){this.canUndo()&&this._operationHandle?.undo()}redo(){this.canRedo()&&this._operationHandle?.redo()}canUndo(){return!!this._operationHandle?.canUndo()}canRedo(){return!!this._operationHandle?.canRedo()}toggleUpdateTool(){this._operationHandle?.toggleTool()}async _getFirstHit(e){const t=this.view;if(!t)return this._logMissingView(),null;if("2d"===t.type){const o=[];t.map.allLayers.forEach(e=>{"vector-tile"!==e.type&&"imagery"!==e.type||o.push(e)});const i=await t.hitTest(e,{exclude:o});return ee(i.results)}const o=[t.map.ground];t.map.allLayers.forEach(e=>{k(e)&&o.push(e)});const i=await t.hitTest(e,{exclude:o});if(i.results.length>0){const e=i.results[0];if(null!=e&&"graphic"===e.type&&e.graphic&&(!i.ground.mapPoint||t.map.ground.opacity<1||i.ground.distance-(e.distance??0)>-Math.min(3*i.ground.distance,"global"===t.viewingMode?G(t.renderCoordsHelper.spatialReference).radius/t.renderCoordsHelper.unitInMeters:Number.POSITIVE_INFINITY)))return e}return null}_generateViewHandles(e){return[e.on("immediate-click",async e=>{const t="active"===this.state&&"create"===this._operationHandle?.type;"disabled"!==this.state&&!t&&this.updateOnGraphicClick&&await this._updatingHandles.addPromise(this._handleImmediateClick(e))},Z.WIDGET)]}async _handleImmediateClick(e){const t=await e.defer(()=>this._getFirstHit(te(e)));let o=null;if(null!=t){const i=t.graphic;this.updateGraphics.includes(i)||this.hasGraphic(i)?(e.stopPropagation(),o=i):"2d"!==this.view?.type||this._isComponentGraphic(i)||"active"!==this.state||this.cancel()}else"active"===this.state&&this.cancel();null==o||this.updateGraphics.includes(o)||await this.update([o],{...this.defaultUpdateOptions,reshapeOptions:{...this.defaultUpdateOptions.reshapeOptions}})}async _setupCreateOperation(e,t){const o=this.view;if(!o)return this._logMissingView(),null;const i={hasZ:"3d"===o.type,...this.defaultCreateOptions,...t},a="string"==typeof e?this.pluginManager?.getPluginsEquivalentToCreateTool(e,i.mode):e,r=pe(e);if(a&&!this.isUsingLegacyCreateTools){const e=await this._setupDrawTool(a,i,r??"polyline");if(e)return this._setupDrawToolOperationHandle(e,r??"point")}if(!r)return null;const s=await this._setupDrawGraphicTool(r,o,i);return null==s?null:(o.tools.add(s),o.activeTool=s,this._setupCreateOperationHandle(s,r))}async _setupDrawGraphicTool(e,t,o){if("multipoint"===e&&"3d"===t.type)return this._logError("sketch:create","Multipoint geometries are not supported in SceneView."),null;if(!t)return this._logMissingView(),null;const{cursor:i,defaultZ:a,hasZ:r,geometryToPlace:s,graphicProperties:n,mode:p,preserveAspectRatio:l}=o,h=ce(p,e),c=de(e),d=o?.optionsPerTool?.has(e)?o.optionsPerTool.get(e):{},u=d?.preserveAspectRatio??l??"rectangle"!==e,g={centered:"rectangle"!==e&&!("circle"===e&&!u),cursor:i,defaultZ:a,forceUniformSize:u,graphicProperties:{...n,attributes:{...n?.attributes}},geometryToPlace:s,geometryType:c,mode:h,graphicSymbol:o.graphicSymbol??this._getGraphicSymbolFromTool(e),hasZ:r,snappingManager:this.snappingManager,snapToScene:!1,view:t,...d};return"2d"===t.type?this._makeDrawGraphicTool2D(g):this._makeDrawGraphicTool3D(g)}async _makeDrawGraphicTool2D(e){const t=await this._requireModule(import("../../views/2d/interactive/editingTools.js"));return Ce(t)||this.destroyed?null:new t.module.DrawGraphicTool2D({...e,activeVertexSymbol:this.activeVertexSymbol,regularVerticesSymbol:this.vertexSymbol,activeLineSymbol:this.activeLineSymbol,activeFillSymbol:be(e.geometryType)?this.activeFillSymbol:null,sketchOptions:this.sketchOptions})}async _makeDrawGraphicTool3D(e){const t=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));return Ce(t)||this.destroyed?null:new t.module.DrawGraphicTool3D({...e,elevationInfo:this._layerAdapter?.elevationInfo,snapToScene:!0,sketchOptions:this.sketchOptions})}_setupCreateOperationHandle(e,t){const o=this.view;if(!o)return this._logMissingView(),null;let i=null;const a=e.forceUniformSize,r=e.centered,n=[o.on("key-down",t=>{if(t.key===q.pan)t.stopPropagation(),t.repeat||(e.enabled=!1);else if(t.key===q.complete)t.stopPropagation(),e.completeCreateOperation();else if(t.key!==q.vertexAdd||t.repeat)t.key===q.undo?(t.stopPropagation(),p.undo()):t.key===q.redo?(t.stopPropagation(),p.redo()):t.key!==q.constraint||"rectangle"!==e.geometryType&&"circle"!==e.geometryType||t.repeat?t.key===q.center&&(t.repeat||(e.centered=!r,t.stopPropagation())):(e.forceUniformSize=!a,t.stopPropagation());else{const o=e.drawOperation.geometryType;"polyline"!==o&&"polygon"!==o&&"multipoint"!==o||(t.stopPropagation(),e.drawOperation.commitStagedVertex())}},Z.WIDGET),o.on("key-up",t=>{t.key===q.pan?e.enabled=!0:t.key!==q.constraint||"rectangle"!==e.geometryType&&"circle"!==e.geometryType?t.key===q.center&&(e.centered=r,t.stopPropagation()):(e.forceUniformSize=a,t.stopPropagation())},Z.WIDGET),e.on("vertex-add",t=>{switch(i=null==i?"start":"active",t.operation){case"apply":this.emit("create",{graphic:e.graphic,state:i,tool:this.activeTool,toolEventInfo:t,type:"create"});break;case"undo":this._emitUndoEvent({graphics:[e.graphic],tool:e.geometryType});break;case"redo":this._emitRedoEvent({graphics:[e.graphic],tool:e.geometryType})}}),e.on("cursor-update",t=>{e.drawOperation.numCommittedVertices>0&&this.emit("create",{graphic:e.graphic,state:"active",tool:this.activeTool,toolEventInfo:{coordinates:t.vertices[0].coordinates,type:"cursor-update"},type:"create"})}),e.on("vertex-remove",t=>{switch(t.operation){case"apply":this.emit("create",{graphic:e.graphic,state:"active",tool:this.activeTool,toolEventInfo:t,type:"create"});break;case"undo":this._emitUndoEvent({graphics:[e.graphic],tool:e.geometryType});break;case"redo":this._emitRedoEvent({graphics:[e.graphic],tool:e.geometryType})}}),e.on("complete",e=>{this._set("createGraphic",e.graphic),i="complete",e.aborted?p&&p.cancel():p&&p.complete()}),g(()=>this._getGraphicSymbolFromTool(t),t=>{e.graphicSymbol=t})],p=new ae({activeComponent:e,type:"create",onEnd:()=>{s(n),o.tools?.remove(e)},undo:()=>{e.canUndo&&e.undo()},redo:()=>{e.canRedo&&e.redo()},canUndo:()=>e.canUndo,canRedo:()=>e.canRedo});return p}_setupDrawToolOperationHandle(e,t){const i=this.view;if(!i)return this._logMissingView(),null;let a=null;const r=[i.on("key-down",t=>{t.key===q.pan&&(t.stopPropagation(),t.repeat||(e.editable=!1))},Z.WIDGET),i.on("key-up",t=>{t.key===q.pan&&(e.editable=!0)},Z.WIDGET),e.on("before-vertex-add",t=>{const o=e.mostUpstreamPlugin?.configuration;if(o&&"legacyCreateTool"in o&&("point"===o?.legacyCreateTool||"text"===o.legacyCreateTool)){const e=t.detail.originalEvent;return void(e&&"key"in e&&e.key===q.vertexAdd&&t.preventDefault())}}),e.on("before-complete",t=>{const o=e.getGeometryIfCompleted();(!o||le(o))&&t.preventDefault()}),e.on(["vertex-add","vertex-remove"],i=>{switch(this.createGraphic&&(this.createGraphic.geometry=e.getGeometryIfCompleted()),a=null==a&&"vertex-remove"!==i.type?"start":"active",i.operation){case"apply":this.emit("create",{graphic:this.createGraphic,state:a,tool:this.activeTool,toolEventInfo:i,type:"create"});break;case"undo":this._emitUndoEvent({graphics:[this.createGraphic].filter(o),tool:t});break;case"redo":this._emitRedoEvent({graphics:[this.createGraphic].filter(o),tool:t})}}),e.on("cursor-update",t=>{this.createGraphic&&(this.createGraphic.geometry=e.unprocessedGeometry),(t.vertices[0]?.vertexIndex>0||t.vertices[0]?.componentIndex>0)&&this.emit("create",{graphic:this.createGraphic,state:"active",tool:this.activeTool,toolEventInfo:{coordinates:t.vertices[0].coordinates,type:"cursor-update"},type:"create"})}),e.on("complete",({geometry:e})=>{const t=this.createGraphic;t&&e&&(t.geometry=e),n.complete()})],n=new re({activeComponent:e,type:"create",onEnd:()=>{s(r),i.tools.remove(e)},undo:()=>e.undo(),redo:()=>e.redo(),canUndo:()=>e.canUndo,canRedo:()=>e.canRedo});return r.push(e.on("cancel",()=>n.cancel())),n}_getGraphicSymbolFromTool(e){switch(e){case"point":case"multipoint":return this.pointSymbol;case"polyline":case"freehandPolyline":return this.polylineSymbol;case"circle":case"rectangle":case"polygon":case"freehandPolygon":return this.polygonSymbol;case"mesh":return this.meshSymbol;case"text":return this.textSymbol}}async _setupUpdateOperation(e,t){const{view:o}=this;if(!o)return this._logMissingView(),null;const i={...this.defaultUpdateOptions,...t,reshapeOptions:{...this.defaultUpdateOptions.reshapeOptions,...t?.reshapeOptions},highlightOptions:{...this.defaultUpdateOptions.highlightOptions,...t?.highlightOptions}};let a=i.tool??ge.tool;if(this.removeGraphics(e),this.addGraphics(e),"3d"===o.type){if(0===e.length)return null;switch(a){case"move":return this._setupMove3DOperation(e,i,o,a);case"reshape":return e.length>1?(this._logError("sketch:reshape-multiple","Reshape operation does not support multiple graphics."),null):this._setupReshape3DOperation(e[0],i,o);case"transform":return this._setupGraphicTransform3DOperation(e,i,o)}}switch(a){case"move":return this._setupMove2DOperation(e,i,o);case"reshape":return e.length>1?(this._logError("sketch:reshape-multiple","Reshape operation does not support multiple graphics."),null):this._setupTransformOrReshape2DOperation(e,a,i,o);case"transform":return he(e)&&(a="reshape"),this._setupTransformOrReshape2DOperation(e,a,i,o)}}async _setupMove3DOperation(e,t,o,i,a=!1){const r=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));if(Ce(r))return r;const{ManipulatedObject3DGraphic:n,MoveTool3D:p}=r.module,l=new Map,h=()=>{l.forEach(e=>e.destroy()),l.clear()};for(const s of e){const e=new n({view:o,graphic:s}),t=F(e);if(0!==t)return h(),this._logError("sketch:move",`Move operation not supported for provided graphic(s) (${L(t)}).`),null;l.set(s,e)}const c=new p({view:o,enableZ:t.enableZ,snappingManager:this.snappingManager,sketchOptions:this.sketchOptions});o.tools.add(c),c.objects.addMany(Array.from(l.values())),a||this.updateGraphics.addMany(e);const d=[],u=new se({activeComponent:c,tool:i,type:"update",onEnd:()=>{s(d),Ee(o,c),h()},undo:()=>{Oe(this.view,c),we(u,this.updateGraphics.toArray()),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:i})},redo:()=>{Ge(u,this.updateGraphics.toArray()),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:i})},addToSelection:e=>{this.updateGraphics.push(e);const t=new n({view:o,graphic:e});l.set(e,t),c.objects.push(t),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"})},removeFromSelection:e=>{const t=this.updateGraphics.indexOf(e);if(u.history.undo.forEach(e=>e.updates.splice(t,1)),u.history.redo.forEach(e=>e.updates.splice(t,1)),this.updateGraphics.remove(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"}),0===this.updateGraphics.length)return void u.complete();const o=l.get(e);o&&(c.objects.remove(o),o.destroy(),l.delete(e))},toggleTool:async()=>{if(1!==this.updateGraphics.length||!1===t.toggleToolOnClick)return;if("transform"!==i)return;const e=this.updateGraphics.at(0),a=await this._updatingHandles.addPromise(this._setupReshape3DOperation(e,t,o,!0));a&&!Ce(a)&&(u.onEnd(),u.destroy(),this._setUpdateOperationHandle(a,t))}});return d.push(...this._getHandlesForComponent(u,t),o.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(u,e,t),Z.WIDGET),o.on("key-down",e=>{this._getCommonUpdateOperationKeyDownHandlers(u,e)},Z.WIDGET)),u}_setupGraphicTransform3DOperation(e,t,o,i=!1){if(1===e.length&&0===K(e[0])){const a=e[0],r=a.geometry;if(null!=r&&("point"===r.type||"mesh"===r.type))return this._setupPointTransform3DOperation(a,t,o);if(null!=r&&("polygon"===r.type||"polyline"===r.type))return this._setupPolyTransform3DOperation(a,t,o,i)}return this._setupMove3DOperation(e,t,o,"transform",i)}async _setupPointTransform3DOperation(e,t,o){const i="transform",{enableRotation:a,enableScaling:r,enableZ:n}=t,p=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));if(Ce(p))return p;const{TransformTool3D:l,ManipulatedObject3DGraphic:h}=p.module,c=new h({graphic:e,view:o}),d=new l({object:c,view:o,enableRotation:a,enableScaling:r,enableZ:n,snappingManager:this.snappingManager,sketchOptions:this.sketchOptions});o.tools.add(d),this.updateGraphics.add(e);const u=[],g=new se({activeComponent:d,tool:i,type:"update",onEnd:()=>{s(u),Ee(o,d),c.destroy()},undo:()=>{Oe(this.view,d),we(g,this.updateGraphics.toArray()),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:i})},redo:()=>{Ge(g,this.updateGraphics.toArray()),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:i})},addToSelection:async e=>{this.updateGraphics.add(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"}),g.onEnd(),g.destroy();const i=await this._updatingHandles.addPromise(this._setupMove3DOperation(this.updateGraphics.toArray(),t,o,"transform",!0));Ce(i)||this._setUpdateOperationHandle(i,t)},removeFromSelection:e=>{this.updateGraphics.remove(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"}),g.complete()},toggleTool:()=>{}});return u.push(...this._getHandlesForComponent(g,t),o.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(g,e,t),Z.WIDGET),o.on("key-down",e=>{this._getCommonUpdateOperationKeyDownHandlers(g,e)},Z.WIDGET)),g}async _setupPolyTransform3DOperation(e,t,o,i=!1){const a="transform",{enableRotation:r,enableScaling:n,enableZ:p,preserveAspectRatio:l}=t,h=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));if(Ce(h))return h;const{ManipulatedObject3DGraphic:c,ExtentTransformTool:d}=h.module,u=this.view?.inputManager?.isModifierKeyDown(q.constraint),g=new c({view:o,graphic:e}),m=new d({object:g,view:o,enableRotation:r,enableScaling:n,enableZ:p,preserveAspectRatio:!!l!=!!u,sketchOptions:this.sketchOptions});o.tools.add(m),i||this.updateGraphics.add(e);const y=[],v=new se({activeComponent:m,tool:a,type:"update",onEnd:()=>{s(y),Ee(o,m),g.destroy()},canUndo:()=>!m.destroyed&&m.canUndo,undo:()=>{m.destroyed||(m.undo(),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:a}))},canRedo:()=>!m.destroyed&&m.canRedo,redo:()=>{m.destroyed||(m.redo(),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:a}))},addToSelection:async e=>{this.updateGraphics.add(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"}),v.onEnd(),v.destroy();const i=await this._updatingHandles.addPromise(this._setupMove3DOperation(this.updateGraphics.toArray(),t,o,"transform",!0));Ce(i)||this._setUpdateOperationHandle(i,t)},removeFromSelection:e=>{this.updateGraphics.remove(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"}),v.complete()},toggleTool:async()=>{if(1!==this.updateGraphics.length||!1===t.toggleToolOnClick)return;const i=await this._updatingHandles.addPromise(this._setupReshape3DOperation(e,t,o,!0));i&&!Ce(i)&&(v.onEnd(),v.destroy(),this._setUpdateOperationHandle(i,t))}});return y.push(...this._getHandlesForComponent(v,t),o.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(v,e,t),Z.WIDGET),o.on("key-down",e=>this._getCommonUpdateOperationKeyDownHandlers(v,e),Z.WIDGET),o.on("key-down",e=>{e.key!==q.constraint||e.repeat||(m.preserveAspectRatio=!m.preserveAspectRatio,e.stopPropagation())},Z.WIDGET),o.on("key-up",e=>{e.key===q.constraint&&(m.preserveAspectRatio=!m.preserveAspectRatio,e.stopPropagation())},Z.WIDGET)),v}async _setupMove2DOperation(e,t,o){const i="move";this.updateGraphics.addMany(e),await this._updatingHandles.addPromise(this._updateSpatialReference(e));const a=await this._updatingHandles.addPromise(this._getGraphicMover(e,t,o));if(Ce(a))return a;const r=new se({activeComponent:a,tool:i,type:"update",onEnd:()=>{this._clearCursor(),s(l),s(p),a.destroy(),this._internalGraphicsLayer?.removeMany([...this.updateGraphics.toArray()])},undo:()=>{const e=this.updateGraphics.toArray();we(r,e),r.refreshComponent(),this._emitUndoEvent({graphics:e,tool:i})},redo:()=>{const e=this.updateGraphics.toArray();Ge(r,e),r.refreshComponent(),this._emitRedoEvent({graphics:e,tool:i})},addToSelection:async e=>{await this._updatingHandles.addPromise(this._updateSpatialReference(e)),this.updateGraphics.push(e),a.graphics=this.updateGraphics.toArray(),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"})},removeFromSelection:e=>{const t=this.updateGraphics.indexOf(e);r.history.undo.forEach(e=>e.updates.splice(t,1)),r.history.redo.forEach(e=>e.updates.splice(t,1)),this.updateGraphics.remove(e);const o=this.updateGraphics.toArray();this.emit("update",{graphics:o,state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"}),0!==this.updateGraphics.length?a.graphics=o:r.complete()}});let n=!1;const p=[o.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(r,e,t),Z.WIDGET),o.on("key-down",e=>{this._getCommonUpdateOperationKeyDownHandlers(r,e),e.key!==q.constraint||e.repeat||(n=!0,a.enableMoveAllGraphics=!a.enableMoveAllGraphics)},Z.WIDGET),o.on("key-up",e=>{e.key===q.constraint&&n&&(n=!1,a.enableMoveAllGraphics=!a.enableMoveAllGraphics)},Z.WIDGET)],l=this._getHandlesForComponent(r,t);return r}async _setupReshape3DOperation(e,t,o,i=!1){const a="reshape",r=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));if(Ce(r))return r;const{ManipulatedObject3DGraphic:n,ReshapeTool3D:p}=r.module,l=new n({view:o,graphic:e}),h=V(l);if(0!==h)return l.destroy(),this._logError("sketch:reshape",`Reshape operation not supported for provided graphic(s) (${L(h)}).`),null;const c=t.reshapeOptions,d=new p({view:o,object:l,enableZVertex:t.enableZ&&"move"===c?.vertexOperation,enableZShape:t.enableZ&&"move"===c?.shapeOperation,enableMoveObject:"move"===c?.shapeOperation||"move-xy"===c?.shapeOperation,enableMidpoints:"split"===c?.edgeOperation,enableEdgeOffset:"offset"===c?.edgeOperation,snappingManager:this.snappingManager,sketchOptions:this.sketchOptions});o.tools.add(d),i||this.updateGraphics.add(l.graphic);const u=[],g=new se({activeComponent:d,tool:a,type:"update",onEnd:()=>{s(u),Ee(o,d),l.destroy()},canUndo:()=>!d.destroyed&&d.canUndo,undo:()=>{d.destroyed||(d.undo(),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:a}))},canRedo:()=>!d.destroyed&&d.canRedo,redo:()=>{d.destroyed||(d.redo(),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:a}))},addToSelection:async e=>{this.updateGraphics.add(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"}),g.onEnd(),g.destroy();const i=await this._updatingHandles.addPromise(this._setupMove3DOperation(this.updateGraphics.toArray(),t,o,"transform",!0));Ce(i)||this._setUpdateOperationHandle(i,t)},removeFromSelection:e=>{this.updateGraphics.remove(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"}),g.complete()},toggleTool:async()=>{if(!1===t.toggleToolOnClick)return;g.onEnd(),g.destroy();const e=await this._updatingHandles.addPromise(this._setupGraphicTransform3DOperation(this.updateGraphics.toArray(),t,o,!0));Ce(e)||this._setUpdateOperationHandle(e,t)}});return u.push(...this._getHandlesForComponent(g,t),o.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(g,e,t),Z.WIDGET),o.on("key-down",e=>{this._getCommonUpdateOperationKeyDownHandlers(g,e)},Z.WIDGET)),g}async _setupTransformOrReshape2DOperation(e,t,o,i){this.updateGraphics.addMany(e),await this._updatingHandles.addPromise(this._updateSpatialReference(e));const a=await this._updatingHandles.addPromise("transform"===t?this._getBox(e,o,i):this._getReshape(e,o,i));if(Ce(a))return a;const r=new se({activeComponent:a,type:"update",onEnd:()=>{s(p),s(n),r.activeComponent&&!r.activeComponent.destroyed&&r.activeComponent.destroy(),this._internalGraphicsLayer.removeMany(this.updateGraphics.toArray())},undo:()=>{we(r,this.updateGraphics.toArray()),r.refreshComponent(),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:r.tool})},redo:()=>{Ge(r,this.updateGraphics.toArray()),r.refreshComponent(),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:r.tool})},addToSelection:async e=>{let t=r.activeComponent;if("reshape"===t?.type){const t=[...this.updateGraphics,e];this.updateGraphics.removeAll(),r.onEnd(),r.destroy();const a=await this._updatingHandles.addPromise(this._setupTransformOrReshape2DOperation(t,"transform",o,i));if(Ce(a))return;this._setUpdateOperationHandle(a,o)}else this.updateGraphics.add(e),t.graphics=this.updateGraphics.toArray(),t.refresh(),r.resetHistory();this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"})},removeFromSelection:e=>{const t=this.updateGraphics.indexOf(e);r.history.undo.forEach(e=>e.updates.splice(t,1)),r.history.redo.forEach(e=>e.updates.splice(t,1)),this.updateGraphics.remove(e);const o=this.updateGraphics.toArray();0===o.length?r.complete():he(o)?r.toggleTool():r.activeComponent.graphics=o,this.emit("update",{graphics:o,state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"})},toggleTool:async()=>{if(this.updateGraphics.length>1)return;const e=this.updateGraphics.at(0),t=e.geometry;if(null!=t&&("reshape"===r.tool&&"point"===t.type||"transform"===r.tool&&"extent"===t.type))return;let a=null;"transform"===r.tool?a=await this._updatingHandles.addPromise(this._getReshape([e],o,i)):"reshape"===r.tool&&(a=await this._updatingHandles.addPromise(this._getBox([e],o,i))),Ce(a)||(r.activeComponent?.destroy(),r.activeComponent=a,r.activeComponent&&(s(p),p=this._getHandlesForComponent(r,o)))}}),n=[i.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(r,e,o),Z.WIDGET),i.on("key-down",e=>{if(this._getCommonUpdateOperationKeyDownHandlers(r,e),e.key===q.constraint&&!e.repeat&&r){const e=r.activeComponent;"box"===e?.type&&(e.preserveAspectRatio=!e.preserveAspectRatio)}},Z.WIDGET),i.on("key-up",e=>{if(e.key===q.constraint&&r){const e=r.activeComponent;"box"===e?.type&&(e.preserveAspectRatio=!e.preserveAspectRatio)}},Z.WIDGET)];let p=this._getHandlesForComponent(r,o);return r}async _getGraphicMover(e,t,o){const{enableMoveAllGraphics:i,highlightOptions:a}=t,r=await this._requireModule(import("../../views/draw/support/GraphicMover.js"));return Ce(r)?r:new r.module.default({enableMoveAllGraphics:i,highlightName:a?.name,highlightsEnabled:!!a?.enabled,indicatorsEnabled:!1,graphics:e,view:o,callbacks:{onGraphicMoveStart:({dx:e,dy:t,graphic:o})=>{this._displayCursor("grabbing"),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:"move-start"},type:"update"})},onGraphicMove:({dx:e,dy:t,graphic:o})=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:"move"},type:"update"}),onGraphicMoveStop:({dx:e,dy:t,graphic:o})=>{this._displayCursor("pointer"),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:"move-stop"},type:"update"})},onGraphicPointerOver:()=>this._displayCursor("move"),onGraphicPointerOut:()=>this._clearCursor()}})}async _getBox(e,t,o){const{enableRotation:i,enableScaling:a,highlightOptions:r,preserveAspectRatio:s}=t,n=await this._requireModule(import("../../views/draw/support/Box.js"));if(Ce(n))return n;const p=this.view?.inputManager?.isModifierKeyDown(q.constraint);return new n.module.default({graphics:e,enableRotation:i,enableScaling:a,highlightName:r?.name,highlightsEnabled:!!r?.enabled,preserveAspectRatio:!!s!=!!p,layer:this._internalGraphicsLayer,view:o,sketchOptions:this.sketchOptions,callbacks:{onMoveStart:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onMove:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onMoveStop:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onScaleStart:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onScale:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onScaleStop:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onRotateStart:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onRotate:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onRotateStop:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"})}})}async _getReshape(e,t,o){const{highlightOptions:i,reshapeOptions:a}=t,r="split"===a?.edgeOperation,s="move"===a?.shapeOperation,n=!!a?.enableCreateCurveFromStraightEdge,p=await this._requireModule(import("../../views/draw/support/Reshape.js"));return Ce(p)?p:new p.module.default({enableMidpoints:r,enableMovement:s,enableCurveOnMidpoint:n,graphic:e[0],highlightName:i?.name,highlightsEnabled:!!i?.enabled,layer:this._internalGraphicsLayer,snappingManager:this.snappingManager,sketchOptions:this.sketchOptions,view:o,callbacks:{onReshapeStart:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onReshape:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onReshapeStop:({mover:e,type:t})=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e,type:t},type:"update"}),onMoveStart:({dx:e,dy:t,mover:o,type:i})=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:i},type:"update"}),onMove:({dx:e,dy:t,mover:o,type:i})=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:i},type:"update"}),onMoveStop:({dx:e,dy:t,mover:o,type:i})=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:i},type:"update"}),onVertexAdd:({added:e,type:t,vertices:o})=>{const i=e.map(e=>C(e.geometry));this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:i,vertices:o,type:t},type:"update"})},onVertexRemove:({removed:e,type:t,vertices:o})=>{const i=e.map(e=>C(e.geometry));this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{removed:i,vertices:o,type:t},type:"update"})}}})}_getHandlesForComponent(e,t){const o=e.activeComponent;if(!o)return[];switch(o.type){case"graphic-mover":return[o.on("graphic-click",({graphic:o,viewEvent:i})=>{i.native?.shiftKey&&t.multipleSelectionEnabled&&(i.stopPropagation(),e.removeFromSelection(o))}),o.on("graphic-move-start",t=>e.addToHistory(Se(t.allGraphics)))];case"box":return[o.on("graphic-click",o=>this._onTransformOrReshape2DGraphicClick(e,t,o)),o.on("move-start",t=>e.addToHistory(Se(t.graphics))),o.on("rotate-start",t=>e.addToHistory(Se(t.graphics))),o.on("scale-start",t=>e.addToHistory(Se(t.graphics)))];case"reshape":return[o.on("graphic-click",o=>this._onTransformOrReshape2DGraphicClick(e,t,o)),o.on("move-start",t=>e.addToHistory(Se([t.mover]))),o.on("reshape-start",t=>e.addToHistory(Se([t.graphic]))),o.on("vertex-add",t=>e.addToHistory(Se([t.oldGraphic]))),o.on("vertex-remove",t=>e.addToHistory(Se([t.oldGraphic])))];case"move-3d":return[o.events.on("record-undo",({updates:t})=>{e.addToHistory({updates:t})}),o.events.on("move-start",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:0,dy:0,mover:e.objects.length>0?e.objects[0].graphic:null,type:"move-start"},type:"update"})}),o.events.on("move",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e.dx,dy:e.dy,mover:e.objects.length>0?e.objects[0].graphic:null,type:"move"},type:"update"})}),o.events.on("move-stop",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:0,dy:0,mover:e.objects.length>0?e.objects[0].graphic:null,type:"move-stop"},type:"update"})}),o.events.on("immediate-click",o=>{o.shiftKey?this._toggleSelection([o.object.graphic],e,t):e.toggleTool()})];case"transform-3d":return[o.events.on("record-undo",({updates:t})=>{e.addToHistory({updates:t})}),o.events.on("translate-start",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,dx:e.dxScreen,dy:e.dyScreen,type:"move-start"},type:"update"})}),o.events.on("translate-stop",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,dx:e.dxScreen,dy:e.dyScreen,type:"move-stop"},type:"update"})}),o.events.on("rotate-start",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,angle:e.angle,type:"rotate-start"},type:"update"})}),o.events.on("rotate-stop",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,angle:e.angle,type:"rotate-stop"},type:"update"})}),o.events.on("scale-start",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,xScale:e.xScale,yScale:e.yScale,type:"scale-start"},type:"update"})}),o.events.on("scale-stop",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,xScale:e.xScale,yScale:e.yScale,type:"scale-stop"},type:"update"})}),o.events.on("translate",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,dx:e.dxScreen,dy:e.dyScreen,type:"move"},type:"update"})}),o.events.on("rotate",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,angle:e.angle,type:"rotate"},type:"update"})}),o.events.on("scale",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,xScale:e.xScale,yScale:e.yScale,type:"scale"},type:"update"})}),o.events.on("immediate-click",o=>{o.shiftKey?this._toggleSelection([o.object.graphic],e,t):e.toggleTool()})];case"reshape-3d":return[o.events.on("reshape",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e,mover:e.object.graphic},type:"update"})}),o.events.on("move",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e,mover:e.object.graphic},type:"update"})}),o.events.on("vertex-add",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:e,type:"update"})}),o.events.on("vertex-remove",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:e,type:"update"})}),o.events.on("immediate-click",o=>{o.shiftKey?this._toggleSelection([o.object.graphic],e,t):e.toggleTool()})]}}_onTransformOrReshape2DGraphicClick(e,t,o){const{graphic:i,viewEvent:a}=o;return a.native?.shiftKey&&this.hasGraphic(i)?(a.stopPropagation(),e.removeFromSelection(i)):t.toggleToolOnClick?(a.stopPropagation(),e.toggleTool()):void 0}_setUpdateOperationHandle(e,t){this._operationHandle=e;const o=this.view?.map;this._disablePopup(t);const i=()=>{if(e===this._operationHandle){const i=this.updateGraphics.toArray(),a=this._operationHandle.tool;this._operationHandle.destroy(),this._operationHandle=null,this._internalGraphicsLayer.removeMany(this.updateGraphics.toArray()),this.updateGraphics.removeAll(),o&&o.remove(this._internalGraphicsLayer),this._restorePopup(t),this.emit("update",{graphics:i,state:"complete",aborted:e.cancelled,tool:a,toolEventInfo:null,type:"update"})}};e.on("complete",i)}async _getCommonUpdateOperationClickHandlers(e,t,o){const i=te(t),a=await t.defer(()=>this._getFirstHit(i));if(null==a)return void e.complete();if(t.native.shiftKey&&this._toggleSelection([a.graphic],e,o))return void t.stopPropagation();this.updateGraphics.includes(a.graphic)?t.stopPropagation():e.complete()}_toggleSelection(e,t,o){const i=!!o.multipleSelectionEnabled;return e.some(e=>null!=e&&(!(!i||!this.hasGraphic(e))&&(this.updateGraphics.includes(e)?t.removeFromSelection(e):t.addToSelection(e),!0)))}_getCommonUpdateOperationKeyDownHandlers(e,t){if(!e)return;const o=t.key;o===q.undo&&e.canUndo()?(t.stopPropagation(),e.undo()):o===q.redo&&e.canRedo()?(t.stopPropagation(),e.redo()):o===q.cancel?(t.stopPropagation(),e.cancel()):this.allowDeleteKey&&q.delete.includes(o)&&this._onDeleteKey(t)}_onDeleteKey(e){this._operationHandle&&"update"===this._operationHandle.type&&null!=this.activeComponent&&(e.stopPropagation(),this.delete())}_removeDefaultLayer(){this._internalGraphicsLayer&&(this.view?.map?.remove(this._internalGraphicsLayer),this._internalGraphicsLayer=l(this._internalGraphicsLayer))}_isComponentGraphic(e){const{activeComponent:t}=this;return!(!e||null==t)&&(e.attributes?.esriSketchTool||"draw-2d"===t.type&&t.graphic===e||("box"===t.type||"reshape"===t.type)&&t.isUIGraphic(e))}_clearCursor(){this.removeHandles(me)}_displayCursor(e){this.removeHandles(me),this.view?.container&&null!=e&&this.addHandles(this.view.acquireCursor(e,"high"),me)}_logError(e,t,o){p.getLogger(this).error(new a(e,t,o))}async _requireModule(e){const t=new AbortController;this._moduleLoaderAbortController=t;const o=await e;return this._moduleLoaderAbortController!==t||t.signal.aborted?{requireError:"aborted"}:{module:o}}_emitUndoEvent(e){this.emit("undo",{...e,type:"undo"})}_emitRedoEvent(e){this.emit("redo",{...e,type:"redo"})}_emitDeleteEvent(e){this.emit("delete",{...e,type:"delete"})}_onLayerGraphicsChangeCallback(e){if(null!=this._operationHandle){const{updateGraphics:t}=this;for(const o of e.removed)if(t.includes(o)){if(!(t.length>1)){this._operationHandle.cancel();break}this._operationHandle.removeFromSelection(o)}}}async _setupAdvancedDrawToolIntegrationMaybe(){this.isUsingLegacyCreateTools||this.pluginManager.loaded||await this.pluginManager.loadPlugins()}async _setupDrawTool(e,o,i){if(this.isUsingLegacyCreateTools||!this._pluginManager)return null;const a=this.view,r=await import("../../views/draw/DrawTool.js");await this.pluginManager.loadPlugins();const s=await this.pluginManager.makeRenderer({customSymbol:o.graphicSymbol,useTextSymbol:"text"===i}),p=new r.DrawTool({view:a,elevationInfo:this._layerAdapter?.elevationInfo??H("3d"===a.type),hasZ:!!o.hasZ,sketchOptions:this.sketchOptions,renderer:s,defaultZ:o.defaultZ??0,directionOptions:o.directionOptions,snappingManager:this.snappingManager,enableVertexVisuals:"rectangle"!==i&&"circle"!==i});p.addHandles(n(s));const l=new t({...o.graphicProperties,attributes:{...o.graphicProperties?.attributes},symbol:o.graphicSymbol??this._getGraphicSymbolFromTool(i)});return o.graphicSymbol||p.addHandles(g(()=>this._getGraphicSymbolFromTool(i),e=>l.symbol=e)),this._set("createGraphic",l),a.addAndActivateTool(p),p.begin(e),p}get test(){}wait(){return f(()=>!this.updating)}_disablePopupEnabled(e){return"3d"!==this.view?.type||this.updateOnGraphicClick||(e?.toggleToolOnClick??!1)}_disablePopup(e){this._disablePopupEnabled(e)&&this.view&&null==this._originalPopupEnabled&&(this._originalPopupEnabled=this.view.popupEnabled,this.view.popupEnabled=!1)}_restorePopup(e){this._disablePopupEnabled(e)&&this.view&&null!=this._originalPopupEnabled&&(this.view.popupEnabled=this._originalPopupEnabled,this._originalPopupEnabled=null)}async _waitViewReady(){const e=this.view;e?(h(this._viewReadyAbortController),this._viewReadyAbortController=new AbortController,await d(f(()=>e?.ready),this._viewReadyAbortController.signal)):this._logMissingView()}_logMissingView(){this._logError("sketch:missing-property",_e("view"))}_logMissingLayer(){this._logError(fe,_e("layer"))}};e([_()],ve.prototype,"_defaultSnappingManager",void 0),e([_()],ve.prototype,"_layerAdapter",null),e([_()],ve.prototype,"_pluginManager",void 0),e([_()],ve.prototype,"_operationHandle",void 0),e([_({readOnly:!0})],ve.prototype,"_updatingHandles",void 0),e([_({readOnly:!0})],ve.prototype,"activeTool",null),e([_({readOnly:!0})],ve.prototype,"activeCreateToolDrawMode",null),e([_()],ve.prototype,"activeTooltip",null),e([_({types:U})],ve.prototype,"activeFillSymbol",void 0),e([_()],ve.prototype,"activeLineSymbol",void 0),e([_()],ve.prototype,"activeVertexSymbol",void 0),e([_()],ve.prototype,"allowDeleteKey",void 0),e([_({readOnly:!0})],ve.prototype,"createGraphic",null),e([_()],ve.prototype,"defaultCreateOptions",null),e([_()],ve.prototype,"defaultUpdateOptions",null),e([_({type:N,nonNullable:!0})],ve.prototype,"labelOptions",null),e([_()],ve.prototype,"layer",void 0),e([_({types:U})],ve.prototype,"pointSymbol",void 0),e([_({types:U})],ve.prototype,"polygonSymbol",void 0),e([_({types:U})],ve.prototype,"polylineSymbol",void 0),e([_()],ve.prototype,"meshSymbol",void 0),e([_({type:x})],ve.prototype,"textSymbol",null),e([_({type:J,nonNullable:!0})],ve.prototype,"snappingOptions",null),e([_()],ve.prototype,"snappingManager",null),e([_({readOnly:!0})],ve.prototype,"state",null),e([_({type:B,nonNullable:!0})],ve.prototype,"tooltipOptions",null),e([_({readOnly:!0})],ve.prototype,"updateGraphics",void 0),e([_()],ve.prototype,"updateOnGraphicClick",void 0),e([_()],ve.prototype,"updating",null),e([_()],ve.prototype,"creationMode",void 0),e([_({type:$,nonNullable:!0})],ve.prototype,"valueOptions",null),e([_({types:U})],ve.prototype,"vertexSymbol",void 0),e([_({value:null})],ve.prototype,"view",null),e([_({constructOnly:!0,type:z})],ve.prototype,"sketchOptions",void 0),e([_()],ve.prototype,"useLegacyCreateTools",void 0),e([_()],ve.prototype,"isUsingLegacyCreateTools",null),e([_()],ve.prototype,"pluginManager",null),e([_()],ve.prototype,"drawTool",null),e([_()],ve.prototype,"rootPlugins",null),e([_()],ve.prototype,"effectiveAvailablePlugins",null),e([_()],ve.prototype,"firstPluginWithSwappableLeaf",null),e([_()],ve.prototype,"multiplePluginsActive",null),ve=e([b("esri.widgets.Sketch.SketchViewModel")],ve);const fe="sketch:missing-property",_e=e=>`Property '${e}' is missing on SketchViewModel.`;function be(e){return"polygon"===e||"rectangle"===e||"circle"===e}function we(e,t){Te("undo",e.history.undo,e.history.redo,t)}function Ge(e,t){Te("redo",e.history.redo,e.history.undo,t)}function Te(e,t,o,i){const a=t.pop();if(!a)return;const r=a.updates,s=[];i.forEach((t,o)=>{const i=r[o];null!=i&&("geometry"in i&&null!=i.geometry&&(s.push({geometry:t.geometry}),t.geometry=i.geometry),"symbol"in i&&null!=i.symbol&&(s.push({symbol:t.symbol}),t.symbol=i.symbol),"undo"in i&&(s.push(i),i[e](t)))}),o.push({updates:s})}function Oe(e,t){null!=e&&t.hasGrabbedManipulators&&(e.activeTool=null)}function Se(e){return{updates:e.map(({geometry:e})=>"mesh"===e?.type?{geometry:e.cloneShallow()}:{geometry:e})}}function Ee(e,t){e.tools?.remove(t),t.destroyed||t.destroy()}function Ce(e){return"requireError"in e&&"aborted"===e.requireError}export{ve as default};
2
+ import{__decorate as e}from"tslib";import t from"../../Graphic.js";import{isSome as o}from"../../core/arrayUtils.js";import i from"../../core/Collection.js";import a from"../../core/Error.js";import{EventedAccessor as r}from"../../core/Evented.js";import{drainHandles as s,destroyHandle as n}from"../../core/handleUtils.js";import"../../core/has.js";import p from"../../core/Logger.js";import{destroyMaybe as l,abortMaybe as h}from"../../core/maybe.js";import{createAbortError as c,whenOrAbort as d,ignoreAbortErrors as u}from"../../core/promiseUtils.js";import{watch as g,syncAndInitial as m,on as y,when as v,whenOnce as f}from"../../core/reactiveUtils.js";import{property as _,subclass as b}from"../../core/accessorSupport/decorators.js";import{UpdatingHandles as w}from"../../core/support/UpdatingHandles.js";import{getReferenceEllipsoid as G}from"../../geometry/ellipsoidUtils.js";import{canProjectWithoutEngine as T,isLoaded as O,load as S,project as E}from"../../geometry/projectionUtils.js";import{geometryToCoordinates as C}from"../../geometry/support/coordsUtils.js";import{equals as M}from"../../geometry/support/spatialReferenceUtils.js";import A from"../../layers/GraphicsLayer.js";import{isIntegratedMeshLayer as k}from"../../layers/support/layerUtils.js";import{getEffectiveElevationInfo as H}from"../../support/elevationInfoUtils.js";import D from"../../symbols/FillSymbol3DLayer.js";import I from"../../symbols/MeshSymbol3D.js";import P from"../../symbols/SimpleFillSymbol.js";import j from"../../symbols/SimpleLineSymbol.js";import R from"../../symbols/SimpleMarkerSymbol.js";import x from"../../symbols/TextSymbol.js";import{symbolTypes as U}from"../../symbols/support/typeUtils.js";import{isSupportedObjectResultMessage as L}from"../../views/3d/interactive/editingTools/isSupportedObjectUtils.js";import{isSupportedObject as F}from"../../views/3d/interactive/editingTools/move/isSupportedObject.js";import{isSupportedObject as V}from"../../views/3d/interactive/editingTools/reshape/isSupportedObject.js";import{isSupportedGraphic as K}from"../../views/3d/interactive/editingTools/transform/isSupportedGraphic.js";import{addUniqueLayer as W}from"../../views/draw/support/layerUtils.js";import{ViewEventPriorities as Z}from"../../views/input/InputManager.js";import{sketchKeys as q}from"../../views/interactive/keybindings.js";import N from"../../views/interactive/sketch/SketchLabelOptions.js";import z from"../../views/interactive/sketch/SketchOptions.js";import B from"../../views/interactive/sketch/SketchTooltipOptions.js";import $ from"../../views/interactive/sketch/SketchValueOptions.js";import{SnappingManager as Y}from"../../views/interactive/snapping/SnappingManager.js";import J from"../../views/interactive/snapping/SnappingOptions.js";import{setupSnappingToggleHandles as Q}from"../../views/interactive/snapping/snappingUtils.js";import{defaultHighlightName as X}from"../../views/support/HighlightDefaults.js";import{findFirstGraphicHit as ee}from"../../views/support/hitTestSelectUtils.js";import{createScreenPointFromEvent as te}from"../../views/support/screenUtils.js";import oe from"./adapters/layer/GraphicsLayerAdapter.js";import ie from"./adapters/layer/MapNotesLayerAdapter.js";import{CreateOperationHandle as ae,DrawToolOperationHandle as re,UpdateOperationHandle as se}from"./support/OperationHandle.js";import{PluginManager as ne}from"./support/PluginManager.js";import{getLegacyTool as pe,isCompletelyDegenerate as le,graphicsHaveTooFewVerticesForBox as he,getModeFromCreateOptions as ce,getDrawToolGeometryTypeFromCreateTool as de}from"./support/sketchUtils.js";const ue={defaultZ:0},ge={reshapeOptions:{edgeOperation:"split",shapeOperation:"move",vertexOperation:"move",enableCreateCurveFromStraightEdge:!0},enableMoveAllGraphics:!0,enableRotation:!0,enableScaling:!0,multipleSelectionEnabled:!0,preserveAspectRatio:!1,toggleToolOnClick:!0,enableZ:!0,highlightOptions:{enabled:!0,name:X},tool:"transform"},me=Symbol(),ye=Symbol();let ve=class extends r{constructor(e){super(e),this._defaultSnappingManager=null,this._internalGraphicsLayer=new A({listMode:"hide",internal:!0,title:"SVM Internal"}),this._pluginManager=new ne({sketchViewModel:this}),this._operationHandle=null,this._updatingHandles=new w,this._viewHandlesKey="viewHandles",this.activeFillSymbol=null,this.activeLineSymbol=null,this.activeVertexSymbol=null,this.allowDeleteKey=!0,this.layer=null,this.pointSymbol=new R({style:"circle",size:6,color:[255,255,255],outline:{color:[50,50,50],width:1}}),this.polygonSymbol=new P({color:[150,150,150,.2],outline:{color:[50,50,50],width:2}}),this.polylineSymbol=new j({color:[130,130,130,1],width:2}),this.meshSymbol=new I({symbolLayers:new i([new D])}),this.updateGraphics=new i,this.updateOnGraphicClick=!0,this.creationMode="single",this.vertexSymbol=new R({style:"circle",size:6,color:[255,255,255],outline:{color:[50,50,50],width:1}}),this.sketchOptions=new z,this.useLegacyCreateTools=!0,this._moduleLoaderAbortController=null,this._viewReadyAbortController=null,this._sketchContinuationFlag=!1,this._onLayerAdapterChange=async()=>{const{_layerAdapter:e}=this;if(this.removeHandles(ye),!e)return;const t=[e.onGraphicsChange(e=>this._onLayerGraphicsChangeCallback(e)),g(()=>e.elevationInfo,e=>{e!==this._internalGraphicsLayer.elevationInfo&&(this.cancel(),this._internalGraphicsLayer&&(this._internalGraphicsLayer.elevationInfo=e))},m)].filter(o);this.addHandles(t,ye)},this._originalPopupEnabled=null,this.defaultCreateOptions=ue,this.defaultUpdateOptions=ge,this.snappingOptions=e?.snappingManager?.options??e?.snappingOptions??new J,this.textSymbol=new x({text:"text"})}initialize(){this._updatingHandles.addPromise(this._setupAdvancedDrawToolIntegrationMaybe()),this.addHandles([y(()=>this.view?.map?.layers,"change",e=>{this.layer&&e.removed.includes(this.layer)&&this.cancel()}),g(()=>this._layerAdapter,()=>this._onLayerAdapterChange(),m),g(()=>this.view,e=>{this._defaultSnappingManager=l(this._defaultSnappingManager),e&&(this.snappingManager||(this._defaultSnappingManager=new Y({view:e,options:this.snappingOptions})),"2d"===e.type?(import("../../views/2d/interactive/editingTools.js"),this._updatingHandles.addPromise(this._setupAdvancedDrawToolIntegrationMaybe())):"3d"===e.type&&(import("../../views/3d/interactive/editingTools.js"),import("../../views/3d/layers/GraphicsLayerView3D.js")))},m),g(()=>this.view?.spatialReference,(e,t)=>{e&&t&&!e.equals(t)&&this.cancel()})]),Q(this)}destroy(){this.cancel(),this._removeDefaultLayer(),this._defaultSnappingManager=l(this._defaultSnappingManager),this._set("snappingManager",null),this._set("view",null),this._updatingHandles.destroy(),this._pluginManager?.destroy(),this.emit("destroy")}get _layerAdapter(){const{layer:e}=this;switch(e?.type){case"graphics":return new oe(e);case"map-notes":return new ie(e);default:return null}}get activeTool(){return this._operationHandle?.tool??null}get activeCreateToolDrawMode(){const e=this._operationHandle;if("create"===e?.type&&e.activeComponent&&"mode"in e.activeComponent)return e.activeComponent.mode;if("draw-2.0"===e?.activeComponent?.type){const t=e.activeComponent.pluginStack.map(e=>e.configuration).filter(o).toArray();if(t.length>0)return this._pluginManager?.getDrawingModeEquivalentToPluginStack(t)}return null}get activeTooltip(){const{activeComponent:e,destroyed:t}=this,o=!t&&e&&"tooltip"in e?e.tooltip:null;return o?.visible?o:null}get activeComponent(){return this._operationHandle?.activeComponent??null}get createGraphic(){return null==this.activeComponent||"draw-3d"!==this.activeComponent.type&&"draw-2d"!==this.activeComponent.type?this._get("createGraphic"):this.activeComponent.graphic}get defaultCreateOptions(){return this._get("defaultCreateOptions")}set defaultCreateOptions(e){this._set("defaultCreateOptions",{...ue,...e})}get defaultUpdateOptions(){return this._get("defaultUpdateOptions")}set defaultUpdateOptions(e){this._set("defaultUpdateOptions",{...ge,...e,reshapeOptions:{...ge.reshapeOptions,...e?.reshapeOptions},highlightOptions:{...ge.highlightOptions,...e?.highlightOptions}})}get labelOptions(){return this.sketchOptions.labels}set labelOptions(e){this.sketchOptions.labels=e}get textSymbol(){return this._get("textSymbol")}set textSymbol(e){this._set("textSymbol",e)}get snappingOptions(){return this.snappingManager?.options??this._get("snappingOptions")}set snappingOptions(e){null!=this._defaultSnappingManager&&(this._defaultSnappingManager.options=e),this._set("snappingOptions",e)}get snappingManager(){return this._isOverridden("snappingManager")&&this._get("snappingManager"),this._defaultSnappingManager}set snappingManager(e){if(e)this._isOverridden("snappingManager")||(this._defaultSnappingManager=l(this._defaultSnappingManager)),this._override("snappingManager",e);else{const{view:e}=this;!this._defaultSnappingManager&&e&&(this._defaultSnappingManager=new Y({options:this.snappingOptions,view:e})),this._clearOverride("snappingManager")}}get state(){const e=!(!this.view?.ready||!this.layer),t=this._operationHandle;return e&&t?"active":e?"ready":"disabled"}get tooltipOptions(){return this.sketchOptions.tooltips}set tooltipOptions(e){this.sketchOptions.tooltips=e}get updating(){return this.activeComponent&&"updating"in this.activeComponent&&this.activeComponent.updating||!!(this._updatingHandles.updating||this.snappingManager?.updating||this.drawTool?.updating)}get valueOptions(){return this.sketchOptions.values}set valueOptions(e){this.sketchOptions.values=e}get view(){return this._get("view")}set view(e){const t=this._get("view");if(t){const{container:e,map:o}=t;e&&this._clearCursor(),o?.remove(this._internalGraphicsLayer),this.removeHandles(this._viewHandlesKey),this.cancel()}const o="view-ready";this.removeHandles(o),e&&this.addHandles(v(()=>e.ready,t=>{this.removeHandles(this._viewHandlesKey),t&&this.addHandles(this._generateViewHandles(e),this._viewHandlesKey)},m),o),this._set("view",e),this._updatingHandles.addPromise(this._setupAdvancedDrawToolIntegrationMaybe())}get isUsingLegacyCreateTools(){return this.useLegacyCreateTools||"2d"!==this.view?.type}get pluginManager(){return this._pluginManager}get drawTool(){return"draw-2.0"!==this.activeComponent?.type?null:this.activeComponent}get rootPlugins(){return this._pluginManager?.availablePlugins}set rootPlugins(e){this._overrideIfSome("rootPlugins",e)}get effectiveAvailablePlugins(){if(this.isUsingLegacyCreateTools)return null;const e=this.view?.type??"2d",{firstPluginWithSwappableLeaf:t}=this;return t?t.availableDownstreamPlugins.filter(t=>!t.excludedViews?.includes(e)):this.rootPlugins?.filter(t=>!t.excludedViews?.includes(e)).filter(o)??[]}get firstPluginWithSwappableLeaf(){const e=this.view?.type??"2d",t=this.drawTool?.pluginStack.toArray().map(e=>e.configuration).findLast(t=>null!=t&&!t.hidden&&t.availableDownstreamPlugins&&t.availableDownstreamPlugins.filter(t=>!t.excludedViews?.includes(e))?.length>1);return t}get multiplePluginsActive(){return!!this.drawTool&&this.drawTool.pluginStack.length>1}addGraphic(e){this._layerAdapter?.add(e)}addGraphics(e){this._layerAdapter?.addMany(e)}hasGraphic(e){return!!this._layerAdapter?.has(e)}removeGraphic(e){this._layerAdapter?.remove(e)}removeGraphics(e){this._layerAdapter?.removeMany(e)}removeAllGraphics(){this._layerAdapter?.removeAll()}cancel(){this._moduleLoaderAbortController=h(this._moduleLoaderAbortController),this._viewReadyAbortController=h(this._viewReadyAbortController),this._sketchContinuationFlag=!0,this._operationHandle?.cancel()}complete(){this._operationHandle?.complete()}delete(){const{state:e,updateGraphics:t}=this;if("active"===e&&t.length){const{activeTool:e}=this,o=t.toArray();this.removeGraphics(o),this.cancel(),this._emitDeleteEvent({graphics:o,tool:e})}}duplicate(){if("active"===this.state&&this.updateGraphics.length){const e=this.updateGraphics.map(e=>e.clone()).toArray();return this.addGraphics(e),this.emit("duplicate",{graphics:e,type:"duplicate"}),e}return[]}async create(e,t){this.cancel(),await this._waitViewReady();const{view:o,layer:i}=this;if(!o||"disabled"===this.state)throw i||this._logMissingLayer(),c();if(null!=o.activeTool&&(o.activeTool=null),!e)return void this._logError("sketch:missing-parameter","Missing parameter 'tool'.");W(o,this._internalGraphicsLayer);const a=await this._updatingHandles.addPromise(this._setupCreateOperation(e,t));if(null==a||this.destroyed)return void o.map?.remove(this._internalGraphicsLayer);const r=pe(e),s=()=>{if(a===this._operationHandle){const o=this.createGraphic,i=this._operationHandle.cancelled;if(this._operationHandle.destroy(),this._operationHandle=null,this._set("createGraphic",null),this.view?.map?.remove(this._internalGraphicsLayer),a.cancelled||null==o||this.addGraphic(o),this._sketchContinuationFlag=!1,this.emit("create",{graphic:o,state:i?"cancel":"complete",tool:r??"point",toolEventInfo:null,type:"create"}),i||this._sketchContinuationFlag)return;const{creationMode:s}=this;if("continuous"===s){if(t?.geometryToPlace)return;this._updatingHandles.consumePromise(u(this.create(e,t)))}else"update"===s&&o&&this._updatingHandles.consumePromise(u(this.update([o])))}};a.on("complete",s),this._operationHandle=a,o.ready&&o.focus()}async place(e,t){return await e.load(),this.create("mesh",{mode:"click",hasZ:e.hasZ,geometryToPlace:e,...t})}async update(e,t){this.cancel(),await this._waitViewReady();const{layer:o,view:i,state:a}=this;if(!i||"disabled"===a)throw o||this._logMissingLayer(),c();null!=i.activeTool&&(i.activeTool=null);const r=Array.isArray(e)?e:[e];if(null==e||!r?.length)return void this._logError("sketch:missing-parameter","Missing parameter 'graphics'.");if(r.some(e=>this.hasGraphic(e)?null==e.geometry&&(this._logError("sketch:invalid-parameter","Parameter 'graphics' contains one or more graphics with an unsupported geometry."),!0):(this._logError("sketch:invalid-parameter","Parameter 'graphics' contains one or more graphics missing from the supplied GraphicsLayer."),!0)))return;const s=await this._updatingHandles.addPromise(this._setupUpdateOperation(r,t));this.destroyed||null==s||Ce(s)||(W(i,this._internalGraphicsLayer),this._setUpdateOperationHandle(s,t),this.emit("update",{graphics:r,state:"start",aborted:!1,tool:s.tool,toolEventInfo:null,type:"update"}))}async _updateSpatialReference(e){const t=this.view;if(t){e=Array.isArray(e)?e:[e];for(const o of e)null==o.geometry||"mesh"===o.geometry.type||M(o.geometry.spatialReference,t.spatialReference)||(T(o.geometry.spatialReference,t.spatialReference)||O()||await S(),o.geometry=E(o.geometry,t.spatialReference))}else this._logMissingView()}undo(){this.canUndo()&&this._operationHandle?.undo()}redo(){this.canRedo()&&this._operationHandle?.redo()}canUndo(){return!!this._operationHandle?.canUndo()}canRedo(){return!!this._operationHandle?.canRedo()}toggleUpdateTool(){this._operationHandle?.toggleTool()}async _getFirstHit(e){const t=this.view;if(!t)return this._logMissingView(),null;if("2d"===t.type){const o=[];t.map.allLayers.forEach(e=>{"vector-tile"!==e.type&&"imagery"!==e.type||o.push(e)});const i=await t.hitTest(e,{exclude:o});return ee(i.results)}const o=[t.map.ground];t.map.allLayers.forEach(e=>{k(e)&&o.push(e)});const i=await t.hitTest(e,{exclude:o});if(i.results.length>0){const e=i.results[0];if(null!=e&&"graphic"===e.type&&e.graphic&&(!i.ground.mapPoint||t.map.ground.opacity<1||i.ground.distance-(e.distance??0)>-Math.min(3*i.ground.distance,"global"===t.viewingMode?G(t.renderCoordsHelper.spatialReference).radius/t.renderCoordsHelper.unitInMeters:Number.POSITIVE_INFINITY)))return e}return null}_generateViewHandles(e){return[e.on("immediate-click",async e=>{const t="active"===this.state&&"create"===this._operationHandle?.type;"disabled"!==this.state&&!t&&this.updateOnGraphicClick&&await this._updatingHandles.addPromise(this._handleImmediateClick(e))},Z.WIDGET)]}async _handleImmediateClick(e){const t=await e.defer(()=>this._getFirstHit(te(e)));let o=null;if(null!=t){const i=t.graphic;this.updateGraphics.includes(i)||this.hasGraphic(i)?(e.stopPropagation(),o=i):"2d"!==this.view?.type||this._isComponentGraphic(i)||"active"!==this.state||this.cancel()}else"active"===this.state&&this.cancel();null==o||this.updateGraphics.includes(o)||await this.update([o],{...this.defaultUpdateOptions,reshapeOptions:{...this.defaultUpdateOptions.reshapeOptions}})}async _setupCreateOperation(e,t){const o=this.view;if(!o)return this._logMissingView(),null;const i={hasZ:"3d"===o.type,...this.defaultCreateOptions,...t},a="string"==typeof e?this.pluginManager?.getPluginsEquivalentToCreateTool(e,i.mode):e,r=pe(e);if(a&&!this.isUsingLegacyCreateTools){const e=await this._setupDrawTool(a,i,r??"polyline");if(e)return this._setupDrawToolOperationHandle(e,r??"point")}if(!r)return null;const s=await this._setupDrawGraphicTool(r,o,i);return null==s?null:(o.tools.add(s),o.activeTool=s,this._setupCreateOperationHandle(s,r))}async _setupDrawGraphicTool(e,t,o){if("multipoint"===e&&"3d"===t.type)return this._logError("sketch:create","Multipoint geometries are not supported in SceneView."),null;if(!t)return this._logMissingView(),null;const{cursor:i,defaultZ:a,hasZ:r,geometryToPlace:s,graphicProperties:n,mode:p,preserveAspectRatio:l}=o,h=ce(p,e),c=de(e),d=o?.optionsPerTool?.has(e)?o.optionsPerTool.get(e):{},u=d?.preserveAspectRatio??l??"rectangle"!==e,g={centered:"rectangle"!==e&&!("circle"===e&&!u),cursor:i,defaultZ:a,forceUniformSize:u,graphicProperties:{...n,attributes:{...n?.attributes}},geometryToPlace:s,geometryType:c,mode:h,graphicSymbol:o.graphicSymbol??this._getGraphicSymbolFromTool(e),hasZ:r,snappingManager:this.snappingManager,snapToScene:!1,view:t,...d};return"2d"===t.type?this._makeDrawGraphicTool2D(g):this._makeDrawGraphicTool3D(g)}async _makeDrawGraphicTool2D(e){const t=await this._requireModule(import("../../views/2d/interactive/editingTools.js"));return Ce(t)||this.destroyed?null:new t.module.DrawGraphicTool2D({...e,activeVertexSymbol:this.activeVertexSymbol,regularVerticesSymbol:this.vertexSymbol,activeLineSymbol:this.activeLineSymbol,activeFillSymbol:be(e.geometryType)?this.activeFillSymbol:null,sketchOptions:this.sketchOptions})}async _makeDrawGraphicTool3D(e){const t=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));return Ce(t)||this.destroyed?null:new t.module.DrawGraphicTool3D({...e,elevationInfo:this._layerAdapter?.elevationInfo,snapToScene:!0,sketchOptions:this.sketchOptions})}_setupCreateOperationHandle(e,t){const o=this.view;if(!o)return this._logMissingView(),null;let i=null;const a=e.forceUniformSize,r=e.centered,n=[o.on("key-down",t=>{if(t.key===q.pan)t.stopPropagation(),t.repeat||(e.enabled=!1);else if(t.key===q.complete)t.stopPropagation(),e.completeCreateOperation();else if(t.key!==q.vertexAdd||t.repeat)t.key===q.undo?(t.stopPropagation(),p.undo()):t.key===q.redo?(t.stopPropagation(),p.redo()):t.key!==q.constraint||"rectangle"!==e.geometryType&&"circle"!==e.geometryType||t.repeat?t.key===q.center&&(t.repeat||(e.centered=!r,t.stopPropagation())):(e.forceUniformSize=!a,t.stopPropagation());else{const o=e.drawOperation.geometryType;"polyline"!==o&&"polygon"!==o&&"multipoint"!==o||(t.stopPropagation(),e.drawOperation.commitStagedVertex())}},Z.WIDGET),o.on("key-up",t=>{t.key===q.pan?e.enabled=!0:t.key!==q.constraint||"rectangle"!==e.geometryType&&"circle"!==e.geometryType?t.key===q.center&&(e.centered=r,t.stopPropagation()):(e.forceUniformSize=a,t.stopPropagation())},Z.WIDGET),e.on("vertex-add",t=>{switch(i=null==i?"start":"active",t.operation){case"apply":this.emit("create",{graphic:e.graphic,state:i,tool:this.activeTool,toolEventInfo:t,type:"create"});break;case"undo":this._emitUndoEvent({graphics:[e.graphic],tool:e.geometryType});break;case"redo":this._emitRedoEvent({graphics:[e.graphic],tool:e.geometryType})}}),e.on("cursor-update",t=>{e.drawOperation.numCommittedVertices>0&&this.emit("create",{graphic:e.graphic,state:"active",tool:this.activeTool,toolEventInfo:{coordinates:t.vertices[0].coordinates,type:"cursor-update"},type:"create"})}),e.on("vertex-remove",t=>{switch(t.operation){case"apply":this.emit("create",{graphic:e.graphic,state:"active",tool:this.activeTool,toolEventInfo:t,type:"create"});break;case"undo":this._emitUndoEvent({graphics:[e.graphic],tool:e.geometryType});break;case"redo":this._emitRedoEvent({graphics:[e.graphic],tool:e.geometryType})}}),e.on("complete",e=>{this._set("createGraphic",e.graphic),i="complete",e.aborted?p&&p.cancel():p&&p.complete()}),g(()=>this._getGraphicSymbolFromTool(t),t=>{e.graphicSymbol=t})],p=new ae({activeComponent:e,type:"create",onEnd:()=>{s(n),o.tools?.remove(e)},undo:()=>{e.canUndo&&e.undo()},redo:()=>{e.canRedo&&e.redo()},canUndo:()=>e.canUndo,canRedo:()=>e.canRedo});return p}_setupDrawToolOperationHandle(e,t){const i=this.view;if(!i)return this._logMissingView(),null;let a=null;const r=[i.on("key-down",t=>{t.key===q.pan&&(t.stopPropagation(),t.repeat||(e.editable=!1))},Z.WIDGET),i.on("key-up",t=>{t.key===q.pan&&(e.editable=!0)},Z.WIDGET),e.on("before-vertex-add",t=>{const o=e.mostUpstreamPlugin?.configuration;if(o&&"legacyCreateTool"in o&&("point"===o?.legacyCreateTool||"text"===o.legacyCreateTool)){const e=t.detail.originalEvent;return void(e&&"key"in e&&e.key===q.vertexAdd&&t.preventDefault())}}),e.on("before-complete",t=>{const o=e.getGeometryIfCompleted();(!o||le(o))&&t.preventDefault()}),e.on(["vertex-add","vertex-remove"],i=>{switch(this.createGraphic&&(this.createGraphic.geometry=e.getGeometryIfCompleted()),a=null==a&&"vertex-remove"!==i.type?"start":"active",i.operation){case"apply":this.emit("create",{graphic:this.createGraphic,state:a,tool:this.activeTool,toolEventInfo:i,type:"create"});break;case"undo":this._emitUndoEvent({graphics:[this.createGraphic].filter(o),tool:t});break;case"redo":this._emitRedoEvent({graphics:[this.createGraphic].filter(o),tool:t})}}),e.on("cursor-update",t=>{this.createGraphic&&(this.createGraphic.geometry=e.unprocessedGeometry),(t.vertices[0]?.vertexIndex>0||t.vertices[0]?.componentIndex>0)&&this.emit("create",{graphic:this.createGraphic,state:"active",tool:this.activeTool,toolEventInfo:{coordinates:t.vertices[0].coordinates,type:"cursor-update"},type:"create"})}),e.on("complete",({geometry:e})=>{const t=this.createGraphic;t&&e&&(t.geometry=e),n.complete()})],n=new re({activeComponent:e,type:"create",onEnd:()=>{s(r),i.tools.remove(e)},undo:()=>e.undo(),redo:()=>e.redo(),canUndo:()=>e.canUndo,canRedo:()=>e.canRedo});return r.push(e.on("cancel",()=>n.cancel())),n}_getGraphicSymbolFromTool(e){switch(e){case"point":case"multipoint":return this.pointSymbol;case"polyline":case"freehandPolyline":return this.polylineSymbol;case"circle":case"rectangle":case"polygon":case"freehandPolygon":return this.polygonSymbol;case"mesh":return this.meshSymbol;case"text":return this.textSymbol}}async _setupUpdateOperation(e,t){const{view:o}=this;if(!o)return this._logMissingView(),null;const i={...this.defaultUpdateOptions,...t,reshapeOptions:{...this.defaultUpdateOptions.reshapeOptions,...t?.reshapeOptions},highlightOptions:{...this.defaultUpdateOptions.highlightOptions,...t?.highlightOptions}};let a=i.tool??ge.tool;if(this.removeGraphics(e),this.addGraphics(e),"3d"===o.type){if(0===e.length)return null;switch(a){case"move":return this._setupMove3DOperation(e,i,o,a);case"reshape":return e.length>1?(this._logError("sketch:reshape-multiple","Reshape operation does not support multiple graphics."),null):this._setupReshape3DOperation(e[0],i,o);case"transform":return this._setupGraphicTransform3DOperation(e,i,o)}}switch(a){case"move":return this._setupMove2DOperation(e,i,o);case"reshape":return e.length>1?(this._logError("sketch:reshape-multiple","Reshape operation does not support multiple graphics."),null):this._setupTransformOrReshape2DOperation(e,a,i,o);case"transform":return he(e)&&(a="reshape"),this._setupTransformOrReshape2DOperation(e,a,i,o)}}async _setupMove3DOperation(e,t,o,i,a=!1){const r=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));if(Ce(r))return r;const{ManipulatedObject3DGraphic:n,MoveTool3D:p}=r.module,l=new Map,h=()=>{l.forEach(e=>e.destroy()),l.clear()};for(const s of e){const e=new n({view:o,graphic:s}),t=F(e);if(0!==t)return h(),this._logError("sketch:move",`Move operation not supported for provided graphic(s) (${L(t)}).`),null;l.set(s,e)}const c=new p({view:o,enableZ:t.enableZ,snappingManager:this.snappingManager,sketchOptions:this.sketchOptions});o.tools.add(c),c.objects.addMany(Array.from(l.values())),a||this.updateGraphics.addMany(e);const d=[],u=new se({activeComponent:c,tool:i,type:"update",onEnd:()=>{s(d),Ee(o,c),h()},undo:()=>{Oe(this.view,c),we(u,this.updateGraphics.toArray()),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:i})},redo:()=>{Ge(u,this.updateGraphics.toArray()),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:i})},addToSelection:e=>{this.updateGraphics.push(e);const t=new n({view:o,graphic:e});l.set(e,t),c.objects.push(t),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"})},removeFromSelection:e=>{const t=this.updateGraphics.indexOf(e);if(u.history.undo.forEach(e=>e.updates.splice(t,1)),u.history.redo.forEach(e=>e.updates.splice(t,1)),this.updateGraphics.remove(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"}),0===this.updateGraphics.length)return void u.complete();const o=l.get(e);o&&(c.objects.remove(o),o.destroy(),l.delete(e))},toggleTool:async()=>{if(1!==this.updateGraphics.length||!1===t.toggleToolOnClick)return;if("transform"!==i)return;const e=this.updateGraphics.at(0),a=await this._updatingHandles.addPromise(this._setupReshape3DOperation(e,t,o,!0));a&&!Ce(a)&&(u.onEnd(),u.destroy(),this._setUpdateOperationHandle(a,t))}});return d.push(...this._getHandlesForComponent(u,t),o.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(u,e,t),Z.WIDGET),o.on("key-down",e=>{this._getCommonUpdateOperationKeyDownHandlers(u,e)},Z.WIDGET)),u}_setupGraphicTransform3DOperation(e,t,o,i=!1){if(1===e.length&&0===K(e[0])){const a=e[0],r=a.geometry;if(null!=r&&("point"===r.type||"mesh"===r.type))return this._setupPointTransform3DOperation(a,t,o);if(null!=r&&("polygon"===r.type||"polyline"===r.type))return this._setupPolyTransform3DOperation(a,t,o,i)}return this._setupMove3DOperation(e,t,o,"transform",i)}async _setupPointTransform3DOperation(e,t,o){const i="transform",{enableRotation:a,enableScaling:r,enableZ:n}=t,p=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));if(Ce(p))return p;const{TransformTool3D:l,ManipulatedObject3DGraphic:h}=p.module,c=new h({graphic:e,view:o}),d=new l({object:c,view:o,enableRotation:a,enableScaling:r,enableZ:n,snappingManager:this.snappingManager,sketchOptions:this.sketchOptions});o.tools.add(d),this.updateGraphics.add(e);const u=[],g=new se({activeComponent:d,tool:i,type:"update",onEnd:()=>{s(u),Ee(o,d),c.destroy()},undo:()=>{Oe(this.view,d),we(g,this.updateGraphics.toArray()),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:i})},redo:()=>{Ge(g,this.updateGraphics.toArray()),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:i})},addToSelection:async e=>{this.updateGraphics.add(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"}),g.onEnd(),g.destroy();const i=await this._updatingHandles.addPromise(this._setupMove3DOperation(this.updateGraphics.toArray(),t,o,"transform",!0));Ce(i)||this._setUpdateOperationHandle(i,t)},removeFromSelection:e=>{this.updateGraphics.remove(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"}),g.complete()},toggleTool:()=>{}});return u.push(...this._getHandlesForComponent(g,t),o.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(g,e,t),Z.WIDGET),o.on("key-down",e=>{this._getCommonUpdateOperationKeyDownHandlers(g,e)},Z.WIDGET)),g}async _setupPolyTransform3DOperation(e,t,o,i=!1){const a="transform",{enableRotation:r,enableScaling:n,enableZ:p,preserveAspectRatio:l}=t,h=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));if(Ce(h))return h;const{ManipulatedObject3DGraphic:c,ExtentTransformTool:d}=h.module,u=this.view?.inputManager?.isModifierKeyDown(q.constraint),g=new c({view:o,graphic:e}),m=new d({object:g,view:o,enableRotation:r,enableScaling:n,enableZ:p,preserveAspectRatio:!!l!=!!u,sketchOptions:this.sketchOptions});o.tools.add(m),i||this.updateGraphics.add(e);const y=[],v=new se({activeComponent:m,tool:a,type:"update",onEnd:()=>{s(y),Ee(o,m),g.destroy()},canUndo:()=>!m.destroyed&&m.canUndo,undo:()=>{m.destroyed||(m.undo(),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:a}))},canRedo:()=>!m.destroyed&&m.canRedo,redo:()=>{m.destroyed||(m.redo(),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:a}))},addToSelection:async e=>{this.updateGraphics.add(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"}),v.onEnd(),v.destroy();const i=await this._updatingHandles.addPromise(this._setupMove3DOperation(this.updateGraphics.toArray(),t,o,"transform",!0));Ce(i)||this._setUpdateOperationHandle(i,t)},removeFromSelection:e=>{this.updateGraphics.remove(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"}),v.complete()},toggleTool:async()=>{if(1!==this.updateGraphics.length||!1===t.toggleToolOnClick)return;const i=await this._updatingHandles.addPromise(this._setupReshape3DOperation(e,t,o,!0));i&&!Ce(i)&&(v.onEnd(),v.destroy(),this._setUpdateOperationHandle(i,t))}});return y.push(...this._getHandlesForComponent(v,t),o.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(v,e,t),Z.WIDGET),o.on("key-down",e=>this._getCommonUpdateOperationKeyDownHandlers(v,e),Z.WIDGET),o.on("key-down",e=>{e.key!==q.constraint||e.repeat||(m.preserveAspectRatio=!m.preserveAspectRatio,e.stopPropagation())},Z.WIDGET),o.on("key-up",e=>{e.key===q.constraint&&(m.preserveAspectRatio=!m.preserveAspectRatio,e.stopPropagation())},Z.WIDGET)),v}async _setupMove2DOperation(e,t,o){const i="move";this.updateGraphics.addMany(e),await this._updatingHandles.addPromise(this._updateSpatialReference(e));const a=await this._updatingHandles.addPromise(this._getGraphicMover(e,t,o));if(Ce(a))return a;const r=new se({activeComponent:a,tool:i,type:"update",onEnd:()=>{this._clearCursor(),s(l),s(p),a.destroy(),this._internalGraphicsLayer?.removeMany([...this.updateGraphics.toArray()])},undo:()=>{const e=this.updateGraphics.toArray();we(r,e),r.refreshComponent(),this._emitUndoEvent({graphics:e,tool:i})},redo:()=>{const e=this.updateGraphics.toArray();Ge(r,e),r.refreshComponent(),this._emitRedoEvent({graphics:e,tool:i})},addToSelection:async e=>{await this._updatingHandles.addPromise(this._updateSpatialReference(e)),this.updateGraphics.push(e),a.graphics=this.updateGraphics.toArray(),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"})},removeFromSelection:e=>{const t=this.updateGraphics.indexOf(e);r.history.undo.forEach(e=>e.updates.splice(t,1)),r.history.redo.forEach(e=>e.updates.splice(t,1)),this.updateGraphics.remove(e);const o=this.updateGraphics.toArray();this.emit("update",{graphics:o,state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"}),0!==this.updateGraphics.length?a.graphics=o:r.complete()}});let n=!1;const p=[o.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(r,e,t),Z.WIDGET),o.on("key-down",e=>{this._getCommonUpdateOperationKeyDownHandlers(r,e),e.key!==q.constraint||e.repeat||(n=!0,a.enableMoveAllGraphics=!a.enableMoveAllGraphics)},Z.WIDGET),o.on("key-up",e=>{e.key===q.constraint&&n&&(n=!1,a.enableMoveAllGraphics=!a.enableMoveAllGraphics)},Z.WIDGET)],l=this._getHandlesForComponent(r,t);return r}async _setupReshape3DOperation(e,t,o,i=!1){const a="reshape",r=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));if(Ce(r))return r;const{ManipulatedObject3DGraphic:n,ReshapeTool3D:p}=r.module,l=new n({view:o,graphic:e}),h=V(l);if(0!==h)return l.destroy(),this._logError("sketch:reshape",`Reshape operation not supported for provided graphic(s) (${L(h)}).`),null;const c=t.reshapeOptions,d=new p({view:o,object:l,enableZVertex:t.enableZ&&"move"===c?.vertexOperation,enableZShape:t.enableZ&&"move"===c?.shapeOperation,enableMoveObject:"move"===c?.shapeOperation||"move-xy"===c?.shapeOperation,enableMidpoints:"split"===c?.edgeOperation,enableEdgeOffset:"offset"===c?.edgeOperation,snappingManager:this.snappingManager,sketchOptions:this.sketchOptions});o.tools.add(d),i||this.updateGraphics.add(l.graphic);const u=[],g=new se({activeComponent:d,tool:a,type:"update",onEnd:()=>{s(u),Ee(o,d),l.destroy()},canUndo:()=>!d.destroyed&&d.canUndo,undo:()=>{d.destroyed||(d.undo(),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:a}))},canRedo:()=>!d.destroyed&&d.canRedo,redo:()=>{d.destroyed||(d.redo(),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:a}))},addToSelection:async e=>{this.updateGraphics.add(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"}),g.onEnd(),g.destroy();const i=await this._updatingHandles.addPromise(this._setupMove3DOperation(this.updateGraphics.toArray(),t,o,"transform",!0));Ce(i)||this._setUpdateOperationHandle(i,t)},removeFromSelection:e=>{this.updateGraphics.remove(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"}),g.complete()},toggleTool:async()=>{if(!1===t.toggleToolOnClick)return;g.onEnd(),g.destroy();const e=await this._updatingHandles.addPromise(this._setupGraphicTransform3DOperation(this.updateGraphics.toArray(),t,o,!0));Ce(e)||this._setUpdateOperationHandle(e,t)}});return u.push(...this._getHandlesForComponent(g,t),o.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(g,e,t),Z.WIDGET),o.on("key-down",e=>{this._getCommonUpdateOperationKeyDownHandlers(g,e)},Z.WIDGET)),g}async _setupTransformOrReshape2DOperation(e,t,o,i){this.updateGraphics.addMany(e),await this._updatingHandles.addPromise(this._updateSpatialReference(e));const a=await this._updatingHandles.addPromise("transform"===t?this._getBox(e,o,i):this._getReshape(e,o,i));if(Ce(a))return a;const r=new se({activeComponent:a,type:"update",onEnd:()=>{s(p),s(n),r.activeComponent&&!r.activeComponent.destroyed&&r.activeComponent.destroy(),this._internalGraphicsLayer.removeMany(this.updateGraphics.toArray())},undo:()=>{we(r,this.updateGraphics.toArray()),r.refreshComponent(),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:r.tool})},redo:()=>{Ge(r,this.updateGraphics.toArray()),r.refreshComponent(),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:r.tool})},addToSelection:async e=>{let t=r.activeComponent;if("reshape"===t?.type){const t=[...this.updateGraphics,e];this.updateGraphics.removeAll(),r.onEnd(),r.destroy();const a=await this._updatingHandles.addPromise(this._setupTransformOrReshape2DOperation(t,"transform",o,i));if(Ce(a))return;this._setUpdateOperationHandle(a,o)}else this.updateGraphics.add(e),t.graphics=this.updateGraphics.toArray(),t.refresh(),r.resetHistory();this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"})},removeFromSelection:e=>{const t=this.updateGraphics.indexOf(e);r.history.undo.forEach(e=>e.updates.splice(t,1)),r.history.redo.forEach(e=>e.updates.splice(t,1)),this.updateGraphics.remove(e);const o=this.updateGraphics.toArray();0===o.length?r.complete():he(o)?r.toggleTool():r.activeComponent.graphics=o,this.emit("update",{graphics:o,state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"})},toggleTool:async()=>{if(this.updateGraphics.length>1)return;const e=this.updateGraphics.at(0),t=e.geometry;if(null!=t&&("reshape"===r.tool&&"point"===t.type||"transform"===r.tool&&"extent"===t.type))return;let a=null;"transform"===r.tool?a=await this._updatingHandles.addPromise(this._getReshape([e],o,i)):"reshape"===r.tool&&(a=await this._updatingHandles.addPromise(this._getBox([e],o,i))),Ce(a)||(r.activeComponent?.destroy(),r.activeComponent=a,r.activeComponent&&(s(p),p=this._getHandlesForComponent(r,o)))}}),n=[i.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(r,e,o),Z.WIDGET),i.on("key-down",e=>{if(this._getCommonUpdateOperationKeyDownHandlers(r,e),e.key===q.constraint&&!e.repeat&&r){const e=r.activeComponent;"box"===e?.type&&(e.preserveAspectRatio=!e.preserveAspectRatio)}},Z.WIDGET),i.on("key-up",e=>{if(e.key===q.constraint&&r){const e=r.activeComponent;"box"===e?.type&&(e.preserveAspectRatio=!e.preserveAspectRatio)}},Z.WIDGET)];let p=this._getHandlesForComponent(r,o);return r}async _getGraphicMover(e,t,o){const{enableMoveAllGraphics:i,highlightOptions:a}=t,r=await this._requireModule(import("../../views/draw/support/GraphicMover.js"));return Ce(r)?r:new r.module.default({enableMoveAllGraphics:i,highlightName:a?.name,highlightsEnabled:!!a?.enabled,indicatorsEnabled:!1,graphics:e,view:o,callbacks:{onGraphicMoveStart:({dx:e,dy:t,graphic:o})=>{this._displayCursor("grabbing"),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:"move-start"},type:"update"})},onGraphicMove:({dx:e,dy:t,graphic:o})=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:"move"},type:"update"}),onGraphicMoveStop:({dx:e,dy:t,graphic:o})=>{this._displayCursor("pointer"),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:"move-stop"},type:"update"})},onGraphicPointerOver:()=>this._displayCursor("move"),onGraphicPointerOut:()=>this._clearCursor()}})}async _getBox(e,t,o){const{enableRotation:i,enableScaling:a,highlightOptions:r,preserveAspectRatio:s}=t,n=await this._requireModule(import("../../views/draw/support/Box.js"));if(Ce(n))return n;const p=this.view?.inputManager?.isModifierKeyDown(q.constraint);return new n.module.default({graphics:e,enableRotation:i,enableScaling:a,highlightName:r?.name,highlightsEnabled:!!r?.enabled,preserveAspectRatio:!!s!=!!p,layer:this._internalGraphicsLayer,view:o,sketchOptions:this.sketchOptions,callbacks:{onMoveStart:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onMove:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onMoveStop:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onScaleStart:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onScale:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onScaleStop:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onRotateStart:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onRotate:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onRotateStop:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"})}})}async _getReshape(e,t,o){const{highlightOptions:i,reshapeOptions:a}=t,r="split"===a?.edgeOperation,s="move"===a?.shapeOperation,n=!!a?.enableCreateCurveFromStraightEdge,p=await this._requireModule(import("../../views/draw/support/Reshape.js"));return Ce(p)?p:new p.module.default({enableMidpoints:r,enableMovement:s,enableCurveOnMidpoint:n,graphic:e[0],highlightName:i?.name,highlightsEnabled:!!i?.enabled,layer:this._internalGraphicsLayer,snappingManager:this.snappingManager,sketchOptions:this.sketchOptions,view:o,callbacks:{onReshapeStart:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onReshape:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onReshapeStop:({mover:e,type:t})=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e,type:t},type:"update"}),onMoveStart:({dx:e,dy:t,mover:o,type:i})=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:i},type:"update"}),onMove:({dx:e,dy:t,mover:o,type:i})=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:i},type:"update"}),onMoveStop:({dx:e,dy:t,mover:o,type:i})=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:i},type:"update"}),onVertexAdd:({added:e,type:t,vertices:o})=>{const i=e.map(e=>C(e.geometry));this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:i,vertices:o,type:t},type:"update"})},onVertexRemove:({removed:e,type:t,vertices:o})=>{const i=e.map(e=>C(e.geometry));this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{removed:i,vertices:o,type:t},type:"update"})}}})}_getHandlesForComponent(e,t){const o=e.activeComponent;if(!o)return[];switch(o.type){case"graphic-mover":return[o.on("graphic-click",({graphic:o,viewEvent:i})=>{i.native?.shiftKey&&t.multipleSelectionEnabled&&(i.stopPropagation(),e.removeFromSelection(o))}),o.on("graphic-move-start",t=>e.addToHistory(Se(t.allGraphics)))];case"box":return[o.on("graphic-click",o=>this._onTransformOrReshape2DGraphicClick(e,t,o)),o.on("move-start",t=>e.addToHistory(Se(t.graphics))),o.on("rotate-start",t=>e.addToHistory(Se(t.graphics))),o.on("scale-start",t=>e.addToHistory(Se(t.graphics)))];case"reshape":return[o.on("graphic-click",o=>this._onTransformOrReshape2DGraphicClick(e,t,o)),o.on("move-start",t=>e.addToHistory(Se([t.mover]))),o.on("reshape-start",t=>e.addToHistory(Se([t.graphic]))),o.on("vertex-add",t=>e.addToHistory(Se([t.oldGraphic]))),o.on("vertex-remove",t=>e.addToHistory(Se([t.oldGraphic])))];case"move-3d":return[o.events.on("record-undo",({updates:t})=>{e.addToHistory({updates:t})}),o.events.on("move-start",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:0,dy:0,mover:e.objects.length>0?e.objects[0].graphic:null,type:"move-start"},type:"update"})}),o.events.on("move",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e.dx,dy:e.dy,mover:e.objects.length>0?e.objects[0].graphic:null,type:"move"},type:"update"})}),o.events.on("move-stop",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:0,dy:0,mover:e.objects.length>0?e.objects[0].graphic:null,type:"move-stop"},type:"update"})}),o.events.on("immediate-click",o=>{o.shiftKey?this._toggleSelection([o.object.graphic],e,t):e.toggleTool()})];case"transform-3d":return[o.events.on("record-undo",({updates:t})=>{e.addToHistory({updates:t})}),o.events.on("translate-start",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,dx:e.dxScreen,dy:e.dyScreen,type:"move-start"},type:"update"})}),o.events.on("translate-stop",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,dx:e.dxScreen,dy:e.dyScreen,type:"move-stop"},type:"update"})}),o.events.on("rotate-start",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,angle:e.angle,type:"rotate-start"},type:"update"})}),o.events.on("rotate-stop",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,angle:e.angle,type:"rotate-stop"},type:"update"})}),o.events.on("scale-start",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,xScale:e.xScale,yScale:e.yScale,type:"scale-start"},type:"update"})}),o.events.on("scale-stop",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,xScale:e.xScale,yScale:e.yScale,type:"scale-stop"},type:"update"})}),o.events.on("translate",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,dx:e.dxScreen,dy:e.dyScreen,type:"move"},type:"update"})}),o.events.on("rotate",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,angle:e.angle,type:"rotate"},type:"update"})}),o.events.on("scale",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,xScale:e.xScale,yScale:e.yScale,type:"scale"},type:"update"})}),o.events.on("immediate-click",o=>{o.shiftKey?this._toggleSelection([o.object.graphic],e,t):e.toggleTool()})];case"reshape-3d":return[o.events.on("reshape",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e,mover:e.object.graphic},type:"update"})}),o.events.on("move",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e,mover:e.object.graphic},type:"update"})}),o.events.on("vertex-add",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:e,type:"update"})}),o.events.on("vertex-remove",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:e,type:"update"})}),o.events.on("immediate-click",o=>{o.shiftKey?this._toggleSelection([o.object.graphic],e,t):e.toggleTool()})]}}_onTransformOrReshape2DGraphicClick(e,t,o){const{graphic:i,viewEvent:a}=o;return a.native?.shiftKey&&this.hasGraphic(i)?(a.stopPropagation(),e.removeFromSelection(i)):t.toggleToolOnClick?(a.stopPropagation(),e.toggleTool()):void 0}_setUpdateOperationHandle(e,t){this._operationHandle=e;const o=this.view?.map;this._disablePopup(t);const i=()=>{if(e===this._operationHandle){const i=this.updateGraphics.toArray(),a=this._operationHandle.tool;this._operationHandle.destroy(),this._operationHandle=null,this._internalGraphicsLayer.removeMany(this.updateGraphics.toArray()),this.updateGraphics.removeAll(),o&&o.remove(this._internalGraphicsLayer),this._restorePopup(t),this.emit("update",{graphics:i,state:"complete",aborted:e.cancelled,tool:a,toolEventInfo:null,type:"update"})}};e.on("complete",i)}async _getCommonUpdateOperationClickHandlers(e,t,o){const i=te(t),a=await t.defer(()=>this._getFirstHit(i));if(null==a)return void(this.updateOnGraphicClick&&e.complete());if(t.native.shiftKey&&this._toggleSelection([a.graphic],e,o))return void t.stopPropagation();this.updateGraphics.includes(a.graphic)?t.stopPropagation():e.complete()}_toggleSelection(e,t,o){const i=!!o.multipleSelectionEnabled;return e.some(e=>null!=e&&(!(!i||!this.hasGraphic(e))&&(this.updateGraphics.includes(e)?t.removeFromSelection(e):t.addToSelection(e),!0)))}_getCommonUpdateOperationKeyDownHandlers(e,t){if(!e)return;const o=t.key;o===q.undo&&e.canUndo()?(t.stopPropagation(),e.undo()):o===q.redo&&e.canRedo()?(t.stopPropagation(),e.redo()):o===q.cancel?(t.stopPropagation(),e.cancel()):this.allowDeleteKey&&q.delete.includes(o)&&this._onDeleteKey(t)}_onDeleteKey(e){this._operationHandle&&"update"===this._operationHandle.type&&null!=this.activeComponent&&(e.stopPropagation(),this.delete())}_removeDefaultLayer(){this._internalGraphicsLayer&&(this.view?.map?.remove(this._internalGraphicsLayer),this._internalGraphicsLayer=l(this._internalGraphicsLayer))}_isComponentGraphic(e){const{activeComponent:t}=this;return!(!e||null==t)&&(e.attributes?.esriSketchTool||"draw-2d"===t.type&&t.graphic===e||("box"===t.type||"reshape"===t.type)&&t.isUIGraphic(e))}_clearCursor(){this.removeHandles(me)}_displayCursor(e){this.removeHandles(me),this.view?.container&&null!=e&&this.addHandles(this.view.acquireCursor(e,"high"),me)}_logError(e,t,o){p.getLogger(this).error(new a(e,t,o))}async _requireModule(e){const t=new AbortController;this._moduleLoaderAbortController=t;const o=await e;return this._moduleLoaderAbortController!==t||t.signal.aborted?{requireError:"aborted"}:{module:o}}_emitUndoEvent(e){this.emit("undo",{...e,type:"undo"})}_emitRedoEvent(e){this.emit("redo",{...e,type:"redo"})}_emitDeleteEvent(e){this.emit("delete",{...e,type:"delete"})}_onLayerGraphicsChangeCallback(e){if(null!=this._operationHandle){const{updateGraphics:t}=this;for(const o of e.removed)if(t.includes(o)){if(!(t.length>1)){this._operationHandle.cancel();break}this._operationHandle.removeFromSelection(o)}}}async _setupAdvancedDrawToolIntegrationMaybe(){this.isUsingLegacyCreateTools||this.pluginManager.loaded||await this.pluginManager.loadPlugins()}async _setupDrawTool(e,o,i){if(this.isUsingLegacyCreateTools||!this._pluginManager)return null;const a=this.view,r=await import("../../views/draw/DrawTool.js");await this.pluginManager.loadPlugins();const s=await this.pluginManager.makeRenderer({customSymbol:o.graphicSymbol,useTextSymbol:"text"===i}),p=new r.DrawTool({view:a,elevationInfo:this._layerAdapter?.elevationInfo??H("3d"===a.type),hasZ:!!o.hasZ,sketchOptions:this.sketchOptions,renderer:s,defaultZ:o.defaultZ??0,directionOptions:o.directionOptions,snappingManager:this.snappingManager,enableVertexVisuals:"rectangle"!==i&&"circle"!==i});p.addHandles(n(s));const l=new t({...o.graphicProperties,attributes:{...o.graphicProperties?.attributes},symbol:o.graphicSymbol??this._getGraphicSymbolFromTool(i)});return o.graphicSymbol||p.addHandles(g(()=>this._getGraphicSymbolFromTool(i),e=>l.symbol=e)),this._set("createGraphic",l),a.addAndActivateTool(p),p.begin(e),p}get test(){}wait(){return f(()=>!this.updating)}_disablePopupEnabled(e){return"3d"!==this.view?.type||this.updateOnGraphicClick||(e?.toggleToolOnClick??!1)}_disablePopup(e){this._disablePopupEnabled(e)&&this.view&&null==this._originalPopupEnabled&&(this._originalPopupEnabled=this.view.popupEnabled,this.view.popupEnabled=!1)}_restorePopup(e){this._disablePopupEnabled(e)&&this.view&&null!=this._originalPopupEnabled&&(this.view.popupEnabled=this._originalPopupEnabled,this._originalPopupEnabled=null)}async _waitViewReady(){const e=this.view;e?(h(this._viewReadyAbortController),this._viewReadyAbortController=new AbortController,await d(f(()=>e?.ready),this._viewReadyAbortController.signal)):this._logMissingView()}_logMissingView(){this._logError("sketch:missing-property",_e("view"))}_logMissingLayer(){this._logError(fe,_e("layer"))}};e([_()],ve.prototype,"_defaultSnappingManager",void 0),e([_()],ve.prototype,"_layerAdapter",null),e([_()],ve.prototype,"_pluginManager",void 0),e([_()],ve.prototype,"_operationHandle",void 0),e([_({readOnly:!0})],ve.prototype,"_updatingHandles",void 0),e([_({readOnly:!0})],ve.prototype,"activeTool",null),e([_({readOnly:!0})],ve.prototype,"activeCreateToolDrawMode",null),e([_()],ve.prototype,"activeTooltip",null),e([_({types:U})],ve.prototype,"activeFillSymbol",void 0),e([_()],ve.prototype,"activeLineSymbol",void 0),e([_()],ve.prototype,"activeVertexSymbol",void 0),e([_()],ve.prototype,"allowDeleteKey",void 0),e([_({readOnly:!0})],ve.prototype,"createGraphic",null),e([_()],ve.prototype,"defaultCreateOptions",null),e([_()],ve.prototype,"defaultUpdateOptions",null),e([_({type:N,nonNullable:!0})],ve.prototype,"labelOptions",null),e([_()],ve.prototype,"layer",void 0),e([_({types:U})],ve.prototype,"pointSymbol",void 0),e([_({types:U})],ve.prototype,"polygonSymbol",void 0),e([_({types:U})],ve.prototype,"polylineSymbol",void 0),e([_()],ve.prototype,"meshSymbol",void 0),e([_({type:x})],ve.prototype,"textSymbol",null),e([_({type:J,nonNullable:!0})],ve.prototype,"snappingOptions",null),e([_()],ve.prototype,"snappingManager",null),e([_({readOnly:!0})],ve.prototype,"state",null),e([_({type:B,nonNullable:!0})],ve.prototype,"tooltipOptions",null),e([_({readOnly:!0})],ve.prototype,"updateGraphics",void 0),e([_()],ve.prototype,"updateOnGraphicClick",void 0),e([_()],ve.prototype,"updating",null),e([_()],ve.prototype,"creationMode",void 0),e([_({type:$,nonNullable:!0})],ve.prototype,"valueOptions",null),e([_({types:U})],ve.prototype,"vertexSymbol",void 0),e([_({value:null})],ve.prototype,"view",null),e([_({constructOnly:!0,type:z})],ve.prototype,"sketchOptions",void 0),e([_()],ve.prototype,"useLegacyCreateTools",void 0),e([_()],ve.prototype,"isUsingLegacyCreateTools",null),e([_()],ve.prototype,"pluginManager",null),e([_()],ve.prototype,"drawTool",null),e([_()],ve.prototype,"rootPlugins",null),e([_()],ve.prototype,"effectiveAvailablePlugins",null),e([_()],ve.prototype,"firstPluginWithSwappableLeaf",null),e([_()],ve.prototype,"multiplePluginsActive",null),ve=e([b("esri.widgets.Sketch.SketchViewModel")],ve);const fe="sketch:missing-property",_e=e=>`Property '${e}' is missing on SketchViewModel.`;function be(e){return"polygon"===e||"rectangle"===e||"circle"===e}function we(e,t){Te("undo",e.history.undo,e.history.redo,t)}function Ge(e,t){Te("redo",e.history.redo,e.history.undo,t)}function Te(e,t,o,i){const a=t.pop();if(!a)return;const r=a.updates,s=[];i.forEach((t,o)=>{const i=r[o];null!=i&&("geometry"in i&&null!=i.geometry&&(s.push({geometry:t.geometry}),t.geometry=i.geometry),"symbol"in i&&null!=i.symbol&&(s.push({symbol:t.symbol}),t.symbol=i.symbol),"undo"in i&&(s.push(i),i[e](t)))}),o.push({updates:s})}function Oe(e,t){null!=e&&t.hasGrabbedManipulators&&(e.activeTool=null)}function Se(e){return{updates:e.map(({geometry:e})=>"mesh"===e?.type?{geometry:e.cloneShallow()}:{geometry:e})}}function Ee(e,t){e.tools?.remove(t),t.destroyed||t.destroy()}function Ce(e){return"requireError"in e&&"aborted"===e.requireError}export{ve as default};
@@ -1 +0,0 @@
1
- "use strict";(self.webpackChunkRemoteClient=self.webpackChunkRemoteClient||[]).push([[9544],{35522(t,e,n){n.d(e,{$A:()=>w,Bw:()=>o,C:()=>s,Cc:()=>R,DI:()=>_,Il:()=>D,Io:()=>M,Ln:()=>y,Om:()=>S,Qr:()=>h,Re:()=>u,S8:()=>v,T9:()=>g,WQ:()=>l,Z0:()=>E,_S:()=>f,aI:()=>L,ei:()=>T,gL:()=>I,hG:()=>A,hZ:()=>a,hs:()=>p,jb:()=>q,jk:()=>m,lo:()=>z,lw:()=>c,m3:()=>b,oW:()=>P,t2:()=>k,tn:()=>d,uE:()=>N,xg:()=>U,ze:()=>x});var i=n(51850),r=n(34304);function o(t){const e=t[0],n=t[1],i=t[2];return Math.sqrt(e*e+n*n+i*i)}function s(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function a(t,e,n,i){return t[0]=e,t[1]=n,t[2]=i,t}function l(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t[2]=e[2]+n[2],t}function u(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t[2]=e[2]-n[2],t}function c(t,e,n){return t[0]=e[0]*n[0],t[1]=e[1]*n[1],t[2]=e[2]*n[2],t}function h(t,e,n){return t[0]=e[0]/n[0],t[1]=e[1]/n[1],t[2]=e[2]/n[2],t}function d(t,e){return t[0]=Math.abs(e[0]),t[1]=Math.abs(e[1]),t[2]=Math.abs(e[2]),t}function f(t,e){return t[0]=Math.sign(e[0]),t[1]=Math.sign(e[1]),t[2]=Math.sign(e[2]),t}function m(t,e,n){return t[0]=Math.min(e[0],n[0]),t[1]=Math.min(e[1],n[1]),t[2]=Math.min(e[2],n[2]),t}function g(t,e,n){return t[0]=Math.max(e[0],n[0]),t[1]=Math.max(e[1],n[1]),t[2]=Math.max(e[2],n[2]),t}function p(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t}function y(t,e,n,i){return t[0]=e[0]+n[0]*i,t[1]=e[1]+n[1]*i,t[2]=e[2]+n[2]*i,t}function M(t,e){const n=e[0]-t[0],i=e[1]-t[1],r=e[2]-t[2];return Math.sqrt(n*n+i*i+r*r)}function A(t,e){const n=e[0]-t[0],i=e[1]-t[1],r=e[2]-t[2];return n*n+i*i+r*r}function b(t){const e=t[0],n=t[1],i=t[2];return e*e+n*n+i*i}function x(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t}function _(t,e){return t[0]=1/e[0],t[1]=1/e[1],t[2]=1/e[2],t}function v(t,e){const n=e[0],i=e[1],r=e[2];let o=n*n+i*i+r*r;return o>0&&(o=1/Math.sqrt(o),t[0]=e[0]*o,t[1]=e[1]*o,t[2]=e[2]*o),t}function S(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function w(t,e,n){const i=e[0],r=e[1],o=e[2],s=n[0],a=n[1],l=n[2];return t[0]=r*l-o*a,t[1]=o*s-i*l,t[2]=i*a-r*s,t}function R(t,e,n,i){const r=e[0],o=e[1],s=e[2];return t[0]=r+i*(n[0]-r),t[1]=o+i*(n[1]-o),t[2]=s+i*(n[2]-s),t}function E(t,e,n){const i=e[0],r=e[1],o=e[2];return t[0]=n[0]*i+n[4]*r+n[8]*o+n[12],t[1]=n[1]*i+n[5]*r+n[9]*o+n[13],t[2]=n[2]*i+n[6]*r+n[10]*o+n[14],t}function T(t,e,n){const i=e[0],r=e[1],o=e[2];return t[0]=i*n[0]+r*n[3]+o*n[6],t[1]=i*n[1]+r*n[4]+o*n[7],t[2]=i*n[2]+r*n[5]+o*n[8],t}function I(t,e,n){const i=n[0],r=n[1],o=n[2],s=n[3],a=e[0],l=e[1],u=e[2],c=r*u-o*l,h=o*a-i*u,d=i*l-r*a,f=r*d-o*h,m=o*c-i*d,g=i*h-r*c,p=2*s;return t[0]=a+c*p+2*f,t[1]=l+h*p+2*m,t[2]=u+d*p+2*g,t}const j=(0,i.vt)(),C=(0,i.vt)();function k(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]}function L(t,e){if(t===e)return!0;const n=t[0],i=t[1],o=t[2],s=e[0],a=e[1],l=e[2],u=(0,r.FD)();return Math.abs(n-s)<=u*Math.max(1,Math.abs(n),Math.abs(s))&&Math.abs(i-a)<=u*Math.max(1,Math.abs(i),Math.abs(a))&&Math.abs(o-l)<=u*Math.max(1,Math.abs(o),Math.abs(l))}function P(t,e,n){const i=n[0]-e[0],r=n[1]-e[1],o=n[2]-e[2];let s=i*i+r*r+o*o;return s>0?(s=1/Math.sqrt(s),t[0]=i*s,t[1]=r*s,t[2]=o*s,t):(t[0]=0,t[1]=0,t[2]=0,t)}const q=u,W=c,Z=h,U=M,z=A,D=o,N=b;Object.freeze(Object.defineProperty({__proto__:null,abs:d,add:l,angle:function(t,e){v(j,t),v(C,e);const n=S(j,C);return n>1?0:n<-1?Math.PI:Math.acos(n)},bezier:function(t,e,n,i,r,o){const s=1-o,a=s*s,l=o*o,u=a*s,c=3*o*a,h=3*l*s,d=l*o;return t[0]=e[0]*u+n[0]*c+i[0]*h+r[0]*d,t[1]=e[1]*u+n[1]*c+i[1]*h+r[1]*d,t[2]=e[2]*u+n[2]*c+i[2]*h+r[2]*d,t},ceil:function(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t[2]=Math.ceil(e[2]),t},clamp:function(t,e=0,n=1){return t[0]=Math.min(Math.max(t[0],e),n),t[1]=Math.min(Math.max(t[1],e),n),t[2]=Math.min(Math.max(t[2],e),n),t},copy:s,cross:w,crossAndNormalize:function(t,e,n){const i=e[0],r=e[1],o=e[2],s=n[0],a=n[1],l=n[2],u=r*l-o*a,c=o*s-i*l,h=i*a-r*s,d=Math.sqrt(u*u+c*c+h*h);return t[0]=u/d,t[1]=c/d,t[2]=h/d,t},direction:P,dist:U,distance:M,div:Z,divide:h,dot:S,equals:L,exactEquals:k,floor:function(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t[2]=Math.floor(e[2]),t},hermite:function(t,e,n,i,r,o){const s=o*o,a=s*(2*o-3)+1,l=s*(o-2)+o,u=s*(o-1),c=s*(3-2*o);return t[0]=e[0]*a+n[0]*l+i[0]*u+r[0]*c,t[1]=e[1]*a+n[1]*l+i[1]*u+r[1]*c,t[2]=e[2]*a+n[2]*l+i[2]*u+r[2]*c,t},inverse:_,len:D,length:o,lerp:R,max:g,min:m,mul:W,multiply:c,negate:x,normalize:v,random:function(t,e=1){const n=r.Ov,i=2*n()*Math.PI,o=2*n()-1,s=Math.sqrt(1-o*o)*e;return t[0]=Math.cos(i)*s,t[1]=Math.sin(i)*s,t[2]=o*e,t},rotateX:function(t,e,n,i){const r=[],o=[];return r[0]=e[0]-n[0],r[1]=e[1]-n[1],r[2]=e[2]-n[2],o[0]=r[0],o[1]=r[1]*Math.cos(i)-r[2]*Math.sin(i),o[2]=r[1]*Math.sin(i)+r[2]*Math.cos(i),t[0]=o[0]+n[0],t[1]=o[1]+n[1],t[2]=o[2]+n[2],t},rotateY:function(t,e,n,i){const r=[],o=[];return r[0]=e[0]-n[0],r[1]=e[1]-n[1],r[2]=e[2]-n[2],o[0]=r[2]*Math.sin(i)+r[0]*Math.cos(i),o[1]=r[1],o[2]=r[2]*Math.cos(i)-r[0]*Math.sin(i),t[0]=o[0]+n[0],t[1]=o[1]+n[1],t[2]=o[2]+n[2],t},rotateZ:function(t,e,n,i){const r=[],o=[];return r[0]=e[0]-n[0],r[1]=e[1]-n[1],r[2]=e[2]-n[2],o[0]=r[0]*Math.cos(i)-r[1]*Math.sin(i),o[1]=r[0]*Math.sin(i)+r[1]*Math.cos(i),o[2]=r[2],t[0]=o[0]+n[0],t[1]=o[1]+n[1],t[2]=o[2]+n[2],t},round:function(t,e){return t[0]=Math.round(e[0]),t[1]=Math.round(e[1]),t[2]=Math.round(e[2]),t},scale:p,scaleAndAdd:y,set:a,sign:f,sqrDist:z,sqrLen:N,squaredDistance:A,squaredLength:b,str:function(t){return"vec3("+t[0]+", "+t[1]+", "+t[2]+")"},sub:q,subtract:u,transformMat3:T,transformMat4:E,transformQuat:I},Symbol.toStringTag,{value:"Module"}))},76553(t,e,n){function i(t){return t&&"getAtOrigin"in t&&"originOf"in t}n.d(e,{H:()=>i})},65806(t,e,n){n.d(e,{g:()=>s});var i=n(51850),r=n(91218),o=n(9762);function s(t,e,n,i){if((0,r.canProjectWithoutEngine)(t.spatialReference,n))return a[0]=t.x,a[1]=t.y,a[2]=t.z??0,(0,o.projectBuffer)(a,t.spatialReference,0,e,n,0);const s=(0,r.tryProject)(t,n,i);return!!s&&(e[0]=s.x,e[1]=s.y,e[2]=s.z??0,!0)}const a=(0,i.vt)()},27993(t,e,n){n.d(e,{F:()=>a});var i=n(91218),r=n(16930),o=n(9762),s=n(65806);function a(t,e,n,r){return!(null==e||null==r||t.length<2)&&((0,i.canProjectWithoutEngine)(e,r)?(0,o.projectBuffer)(t,e,0,n,r,0,1):(l.x=t[0],l.y=t[1],l.z=t[2],l.spatialReference=e,(0,s.g)(l,n,r)))}const l={x:0,y:0,z:0,hasZ:!0,hasM:!1,spatialReference:r.A.WGS84,type:"point"}},61528(t,e,n){n.r(e),n.d(e,{default:()=>L});var i=n(5482),r=n(11254),o=n(49186),s=n(44208),a=n(53966),l=n(25728),u=n(17676),c=n(36708),h=n(91429),d=n(87024),f=n(5443),m=n(16930),g=n(4146),p=n(52136),y=n(18768),M=n(69208),A=n(16131),b=n(8303),x=n(25036),_=n(10873),v=n(58325),S=n(88546),w=n(20655),R=n(24212),E=n(97159),T=n(16215),I=n(72772),j=n(98697),C=n(36005);let k=class extends((0,y.b)((0,A.q)((0,b.A)((0,x.j)((0,l.M)((0,M.d)((0,p.p)(g.A)))))))){readModifications(t,e,n){this._modificationsSource={url:(0,E.f)(t,n),context:n}}initialize(){this.addHandles((0,c.on)(()=>this.modifications,"after-changes",()=>this.modifications=this.modifications,c.OH))}constructor(t){super(t),this.operationalLayerType="IntegratedMesh3DTilesLayer",this.modifications=null,this._modificationsSource=null,this.spatialReference=S.Zx,this.fullExtent=S.zq,this.url=null,this.type="integrated-mesh-3dtiles",this.path=null,this.minScale=0,this.maxScale=0,this._rootTilesetJSON=null,this._rootTileset=null,this._key=null,this._session=null,this._rootRequestPromise=null,this.queryElevationCallback=null}set elevationInfo(t){null!=t&&"absolute-height"!==t.mode||this._set("elevationInfo",t),this._validateElevationInfo(t)}async load(t){return this.addResolvingPromise(this._doLoad(t)),this}get rootTilesetJSON(){return this._rootTilesetJSON}get rootTileset(){return this._rootTileset}get key(){return this._key}get session(){return this._session}_findSessionParameter(t){const e=[t];for(;e?.length>0;){const t=e.pop();if(!t)return;for(const[n,i]of Object.entries(t)){if("uri"===n)try{const t=new URL("https://tmp"+i).searchParams.get("session");if(t)return t}catch(t){}"object"==typeof i&&null!==i&&e.push(i)}}return null}async requestRootAndSession(t){const e=(t,e)=>new o.A("3dtiles-init:"+t,e);return this._rootRequestPromise||(this._rootRequestPromise=new Promise((n,i)=>{this.url||i(e("url-missing","Layer url missing")),this._key=this.customParameters?this.customParameters.key:null,new Promise((t,n)=>{if(this.replacesTerrain&&!this._key){const i=this.portalItem?.portal||this.parent?.portalItem?.portal||w.A.getDefault();i.signIn().then(()=>{i.g3dTilesEnabled?(0,r.A)(i.restUrl+"/portals/self/modules/g3dtiles",{responseType:"json",query:{f:"json"}}).then(e=>{this._key=e.data.keyString,t()},()=>n(e("g3dtiles-key-error","Error fetching Google 3D Tiles key from portal"))):n(e("g3dTilesEnabled-false","Google 3D Tiles are not enabled on Portal "+i.url))},()=>n(e("sign-in-failed","Error signing in to Portal")))}else t()}).then(()=>{(0,r.A)(this.url,{query:this._key?{key:this._key,token:this.apiKey}:{token:this.apiKey},responseType:"array-buffer",signal:t}).then(t=>{try{this._rootTilesetJSON=JSON.parse((new TextDecoder).decode(t.data))}catch(t){return void i(e("root-parse-failed","Error parsing root tile, details: "+t))}this._rootTilesetJSON?(this._session=this._findSessionParameter(this._rootTilesetJSON),this._rootTileset=t.data,this.fullExtent=(0,S.uB)(this._rootTilesetJSON),n(),this._rootRequestPromise=null):i(e("root-is-null","Root tile is null."))},t=>{(0,u.QP)(t),i(e("root-load-failed","Error loading root tile")),this._rootRequestPromise=null,a.A.getLogger("IntegratedMesh3DTilesLayer").error("Layer loading failed",t)})},t=>i(t))})),this._rootRequestPromise}async _doLoad(t){const e=null!=t?t.signal:null;if(this.isUsedAsGroundLayer&&!(0,s.A)("enable-feature:basemap-groundlayers"))throw new o.A("3dtiles-init:not-supported-in-groundlayers","Layer is not supported in basemap.");try{await this.loadFromPortal({supportedTypes:["3DTiles Service"],validateItem:t=>{if(t.typeKeywords?.includes("IntegratedMesh"))return!0;throw new o.A("portal:invalid-layer-item-type","Invalid layer item, expected '${expectedType}' ",{expectedType:"3DTiles Service containing IntegratedMesh"})}},t)}catch(t){(0,u.QP)(t)}if(null!=this._modificationsSource){const e=await v.A.fromUrl(this._modificationsSource.url,this.spatialReference,t);if(e&&e.length>0){await(0,I.initialize)();try{const t=(0,j.Ir)(null,e.toArray(),this.spatialReference),n=(0,I.switchMeshModificationPolygonVCSSync)({modifications:t,inVCS:115700});n.success&&n.modifications&&(0,j.H1)(n.modifications,e)}catch(t){a.A.getLogger(this).error("convert-mesh-modification-z-error","Error when converting:",t)}null!=this._modificationsSource&&this.setAtOrigin("modifications",e,this._modificationsSource.context.origin),this._modificationsSource=null}}await this.requestRootAndSession(e)}async beforeSave(){if(null==this._modificationsSource){const{modifications:t}=this;return void(t&&t.length>0&&await(0,I.initialize)())}await this.load().then(()=>{},()=>{})}get hasAttributionData(){return!1}_validateElevationInfo(t){const e="Integrated mesh 3d tiles layers";(0,R.XF)(a.A.getLogger(this),(0,R.B)(e,"absolute-height",t)),(0,R.XF)(a.A.getLogger(this),(0,R.tW)(e,t))}get replacesTerrain(){return!!(0,s.A)("enable-feature:basemap-groundlayers")&&this.hasGoogleUrl&&this.isUsedAsGroundLayer}get isUsedAsGroundLayer(){return(0,T.S)(this.parent)}get hasGoogleUrl(){return!!this.url?.match(/.+\.googleapis.com/)}};(0,i.Cg)([(0,h.MZ)({type:["IntegratedMesh3DTilesLayer"]})],k.prototype,"operationalLayerType",void 0),(0,i.Cg)([(0,h.MZ)({type:v.A,clonable:t=>t.clone()}),(0,d.P)({origins:["web-scene","portal-item"],type:"resource",prefix:"modifications"})],k.prototype,"modifications",void 0),(0,i.Cg)([(0,C.w)(["web-scene","portal-item"],"modifications")],k.prototype,"readModifications",null),(0,i.Cg)([(0,h.MZ)({type:m.A})],k.prototype,"spatialReference",void 0),(0,i.Cg)([(0,h.MZ)({type:f.A})],k.prototype,"fullExtent",void 0),(0,i.Cg)([(0,h.MZ)(_.Yj)],k.prototype,"elevationInfo",null),(0,i.Cg)([(0,h.MZ)({type:["show","hide"]})],k.prototype,"listMode",void 0),(0,i.Cg)([(0,h.MZ)(_.OZ)],k.prototype,"url",void 0),(0,i.Cg)([(0,h.MZ)({readOnly:!0})],k.prototype,"type",void 0),(0,i.Cg)([(0,h.MZ)({type:String,json:{origins:{"web-scene":{read:!0,write:!0},"portal-item":{read:!0,write:!0}},read:!1}})],k.prototype,"path",void 0),(0,i.Cg)([(0,h.MZ)({type:Number,json:{name:"layerDefinition.minScale",write:!0,origins:{service:{read:!1,write:!1}}}})],k.prototype,"minScale",void 0),(0,i.Cg)([(0,h.MZ)({type:Number,json:{name:"layerDefinition.maxScale",write:!0,origins:{service:{read:!1,write:!1}}}})],k.prototype,"maxScale",void 0),(0,i.Cg)([(0,h.MZ)({readOnly:!0})],k.prototype,"hasAttributionData",null),(0,i.Cg)([(0,h.MZ)()],k.prototype,"replacesTerrain",null),(0,i.Cg)([(0,h.MZ)()],k.prototype,"isUsedAsGroundLayer",null),(0,i.Cg)([(0,h.MZ)()],k.prototype,"hasGoogleUrl",null),k=(0,i.Cg)([(0,h.$K)("esri.layers.IntegratedMesh3DTilesLayer")],k);const L=k},88546(t,e,n){n.d(e,{Zx:()=>h,_8:()=>p,uB:()=>y,zq:()=>d});var i=n(34727),r=n(35522),o=n(51850),s=n(73941),a=n(5443),l=n(54239),u=n(16930),c=n(9762);const h=new u.A({wkid:4326,vcsWkid:115700}),d=new a.A(-180,-90,180,90,h);function f(t,e){if(!Array.isArray(t)||t.length<e)return!1;for(const e of t)if("number"!=typeof e)return!1;return!0}const m=7645211,g={xmin:-180,ymin:-90,zmin:-450,xmax:180,ymax:90,zmax:8850};function p(t){return!(!(t.extensions?.ESRI_crs?.wkid||t.extensions?.ESRI_crs?.latestWkid||t.extensions?.ESRI_crs?.wkt)||!t.root?.extensions?.ESRI_crs?.boundingVolume?.box&&!t.root?.extensions?.ESRI_crs?.boundingVolume?.sphere)}function y(t,e=!1){let n=new u.A({wkid:4326,vcsWkid:115700}),l=t.root?.boundingVolume,h=!1,d=t?.root?.transform;if(e&&(t.extensions?.ESRI_crs?.wkid||t.extensions?.ESRI_crs?.latestWkid||t.extensions?.ESRI_crs?.wkt)&&(t.root?.extensions?.ESRI_crs?.boundingVolume?.box||t.root?.extensions?.ESRI_crs?.boundingVolume?.sphere))n=new u.A(t.extensions?.ESRI_crs),l=t.root?.extensions?.ESRI_crs?.boundingVolume,d=t.root?.transform,h=!0;else if(!l)return new a.A(-180,-90,180,90,n);if(l.box){const t=l?.box;if(t[3]>m&&t[7]>m&&t[11]>m)return new a.A({...g,spatialReference:n})}const p=(0,o.vt)();if(!h&&l.region&&f(l.region,6)){const t=l.region,e=(0,i.KJ)(t[0]),r=(0,i.KJ)(t[1]),o=t[4],s=(0,i.KJ)(t[2]),u=(0,i.KJ)(t[3]),c=t[5];return new a.A({xmin:e,ymin:r,zmin:o,xmax:s,ymax:u,zmax:c,spatialReference:n})}if(l.sphere&&f(l.sphere,4)){const t=l.sphere,e=(0,o.fA)(t[0],t[1],t[2]),i=t[3]/Math.sqrt(3),m=(0,o.vt)();(0,r.Re)(m,e,(0,o.fA)(i,i,i));const g=(0,o.vt)();if((0,r.WQ)(g,e,(0,o.fA)(i,i,i)),d&&f(d,16)){const t=d;(0,r.Z0)(p,m,t),(0,r.C)(m,p),(0,r.Z0)(p,g,t),(0,r.C)(g,p)}h||((0,c.projectBuffer)(m,s.Ro,0,m,u.A.WGS84,0),(0,c.projectBuffer)(g,s.Ro,0,g,u.A.WGS84,0));const y=(0,o.vt)(),M=(0,o.vt)();return(0,r.jk)(y,m,g),(0,r.T9)(M,m,g),new a.A({xmin:y[0],ymin:y[1],zmin:y[2],xmax:M[0],ymax:M[1],zmax:M[2],spatialReference:n})}if(l.box&&f(l.box,12)){const t=l.box,e=(0,o.fA)(t[0],t[1],t[2]),i=(0,o.fA)(t[3],t[4],t[5]),m=(0,o.fA)(t[6],t[7],t[8]),g=(0,o.fA)(t[9],t[10],t[11]),p=[];for(let t=0;t<8;++t)p.push((0,o.vt)());if((0,r.WQ)(p[0],e,i),(0,r.WQ)(p[0],p[0],m),(0,r.WQ)(p[0],p[0],g),(0,r.jb)(p[1],e,i),(0,r.WQ)(p[1],p[1],m),(0,r.WQ)(p[1],p[1],g),(0,r.WQ)(p[2],e,i),(0,r.jb)(p[2],p[2],m),(0,r.WQ)(p[2],p[2],g),(0,r.jb)(p[3],e,i),(0,r.jb)(p[3],p[3],m),(0,r.WQ)(p[3],p[3],g),(0,r.WQ)(p[4],e,i),(0,r.WQ)(p[4],p[4],m),(0,r.jb)(p[4],p[4],g),(0,r.jb)(p[5],e,i),(0,r.WQ)(p[5],p[5],m),(0,r.jb)(p[5],p[5],g),(0,r.WQ)(p[6],e,i),(0,r.jb)(p[6],p[6],m),(0,r.jb)(p[6],p[6],g),(0,r.jb)(p[7],e,i),(0,r.jb)(p[7],p[7],m),(0,r.jb)(p[7],p[7],g),d&&f(d,16)){const t=d;for(let e=0;e<8;++e)(0,r.Z0)(p[e],p[e],t)}const y=(0,o.fA)(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),M=(0,o.fA)(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE);for(let t=0;t<8;++t)h||(0,c.projectBuffer)(p[t],s.Ro,0,p[t],u.A.WGS84,0),(0,r.jk)(M,M,p[t]),(0,r.T9)(y,y,p[t]);return new a.A({xmin:M[0],ymin:M[1],zmin:M[2],xmax:y[0],ymax:y[1],zmax:y[2],spatialReference:n})}return new a.A(-180,-90,180,90,n)}new Map([[5773,new l.A({heightModel:"gravity-related-height",heightUnit:"meters",vertCRS:"EGM96_Geoid"})],[3855,new l.A({heightModel:"gravity-related-height",heightUnit:"meters",vertCRS:"EGM2008_Geoid"})],[115700,new l.A({heightModel:"ellipsoidal",heightUnit:"meters",vertCRS:"WGS_1984"})],[115701,new l.A({heightModel:"ellipsoidal",heightUnit:"meters",vertCRS:"ETRS_1989"})],[6360,new l.A({heightModel:"gravity-related-height",heightUnit:"us-feet",vertCRS:"NAVD88_height_(ftUS)"})],[7837,new l.A({heightModel:"gravity-related-height",heightUnit:"meters",vertCRS:"DHHN2016_(height)"})],[5709,new l.A({heightModel:"gravity-related-height",heightUnit:"meters",vertCRS:"NAP"})]])}}]);
@@ -1 +0,0 @@
1
- "use strict";(self.webpackChunkRemoteClient=self.webpackChunkRemoteClient||[]).push([[3875,9397],{5482(e,t,r){function n(e,t,r,n){var s,i=arguments.length,a=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,r,n);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(a=(i<3?s(a):i>3?s(t,r,a):s(t,r))||a);return i>3&&a&&Object.defineProperty(t,r,a),a}function s(e,t,r){if(null!=t){if("object"!=typeof t&&"function"!=typeof t)throw new TypeError("Object expected.");var n,s;if(r){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");n=t[Symbol.asyncDispose]}if(void 0===n){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");n=t[Symbol.dispose],r&&(s=n)}if("function"!=typeof n)throw new TypeError("Object not disposable.");s&&(n=function(){try{s.call(this)}catch(e){return Promise.reject(e)}}),e.stack.push({value:t,dispose:n,async:r})}else r&&e.stack.push({async:!0});return t}r.d(t,{Cg:()=>n,hk:()=>a,mS:()=>s}),Object.create,Object.create;var i="function"==typeof SuppressedError?SuppressedError:function(e,t,r){var n=new Error(r);return n.name="SuppressedError",n.error=e,n.suppressed=t,n};function a(e){function t(t){e.error=e.hasError?new i(t,e.error,"An error was suppressed during disposal."):t,e.hasError=!0}var r,n=0;return function s(){for(;r=e.stack.pop();)try{if(!r.async&&1===n)return n=0,e.stack.push(r),Promise.resolve().then(s);if(r.dispose){var i=r.dispose.call(r.value);if(r.async)return n|=2,Promise.resolve(i).then(s,function(e){return t(e),s()})}else n|=1}catch(e){t(e)}if(1===n)return e.hasError?Promise.reject(e.error):Promise.resolve();if(e.hasError)throw e.error}()}},83349(e,t,r){function n(e,t,r){r=r||2;var n,i,o,l,h,c,f,d=t&&t.length,p=d?t[0]*r:e.length,y=s(e,0,p,r,!0),x=[];if(!y||y.next===y.prev)return x;if(d&&(y=u(e,t,y,r)),e.length>80*r){n=o=e[0],i=l=e[1];for(var g=r;g<p;g+=r)(h=e[g])<n&&(n=h),(c=e[g+1])<i&&(i=c),h>o&&(o=h),c>l&&(l=c);f=0!==(f=Math.max(o-n,l-i))?1/f:0}return a(y,x,r,n,i,f),x}function s(e,t,r,n,s){var i,a;if(s===S(e,t,r,n)>0)for(i=t;i<r;i+=n)a=A(i,e[i],e[i+1],a);else for(i=r-n;i>=t;i-=n)a=A(i,e[i],e[i+1],a);if(a&&M(a,a.next)){var o=a.next;B(a),a=o}return a}function i(e,t){if(!e)return e;t||(t=e);var r,n=e;do{if(r=!1,n.steiner||!M(n,n.next)&&0!==w(n.prev,n,n.next))n=n.next;else{var s=n.prev;if(B(n),(n=t=s)===n.next)break;r=!0}}while(r||n!==t);return t}function a(e,t,r,n,s,u,f){if(e){!f&&u&&x(e,n,s,u);for(var d,p,y=e;e.prev!==e.next;)if(d=e.prev,p=e.next,u?l(e,n,s,u):o(e))t.push(d.i/r),t.push(e.i/r),t.push(p.i/r),B(e),e=p.next,y=p.next;else if((e=p)===y){f?1===f?a(e=h(i(e),t,r),t,r,n,s,u,2):2===f&&c(e,t,r,n,s,u):a(i(e),t,r,n,s,u,1);break}}}function o(e){var t=e.prev,r=e,n=e.next;if(w(t,r,n)>=0)return!1;for(var s=e.next.next;s!==e.prev;){if(m(t.x,t.y,r.x,r.y,n.x,n.y,s.x,s.y)&&w(s.prev,s,s.next)>=0)return!1;s=s.next}return!0}function l(e,t,r,n){var s=e.prev,i=e,a=e.next;if(w(s,i,a)>=0)return!1;for(var o=s.x<i.x?s.x<a.x?s.x:a.x:i.x<a.x?i.x:a.x,l=s.y<i.y?s.y<a.y?s.y:a.y:i.y<a.y?i.y:a.y,h=s.x>i.x?s.x>a.x?s.x:a.x:i.x>a.x?i.x:a.x,c=s.y>i.y?s.y>a.y?s.y:a.y:i.y>a.y?i.y:a.y,u=g(o,l,t,r,n),f=g(h,c,t,r,n),d=e.prevZ,p=e.nextZ;d&&d.z>=u&&p&&p.z<=f;){if(d!==e.prev&&d!==e.next&&m(s.x,s.y,i.x,i.y,a.x,a.y,d.x,d.y)&&w(d.prev,d,d.next)>=0)return!1;if(d=d.prevZ,p!==e.prev&&p!==e.next&&m(s.x,s.y,i.x,i.y,a.x,a.y,p.x,p.y)&&w(p.prev,p,p.next)>=0)return!1;p=p.nextZ}for(;d&&d.z>=u;){if(d!==e.prev&&d!==e.next&&m(s.x,s.y,i.x,i.y,a.x,a.y,d.x,d.y)&&w(d.prev,d,d.next)>=0)return!1;d=d.prevZ}for(;p&&p.z<=f;){if(p!==e.prev&&p!==e.next&&m(s.x,s.y,i.x,i.y,a.x,a.y,p.x,p.y)&&w(p.prev,p,p.next)>=0)return!1;p=p.nextZ}return!0}function h(e,t,r){var n=e;do{var s=n.prev,a=n.next.next;!M(s,a)&&I(s,n,n.next,a)&&P(s,a)&&P(a,s)&&(t.push(s.i/r),t.push(n.i/r),t.push(a.i/r),B(n),B(n.next),n=e=a),n=n.next}while(n!==e);return i(n)}function c(e,t,r,n,s,o){var l=e;do{for(var h=l.next.next;h!==l.prev;){if(l.i!==h.i&&b(l,h)){var c=V(l,h);return l=i(l,l.next),c=i(c,c.next),a(l,t,r,n,s,o),void a(c,t,r,n,s,o)}h=h.next}l=l.next}while(l!==e)}function u(e,t,r,n){var a,o,l,h=[];for(a=0,o=t.length;a<o;a++)(l=s(e,t[a]*n,a<o-1?t[a+1]*n:e.length,n,!1))===l.next&&(l.steiner=!0),h.push(_(l));for(h.sort(f),a=0;a<h.length;a++)r=i(r=p(h[a],r),r.next);return r}function f(e,t){return e.x-t.x}function d(e){if(e.next.prev===e)return e;let t=e;for(;;){const r=t.next;if(r.prev===t||r===t||r===e)break;t=r}return t}function p(e,t){var r=function(e,t){var r,n=t,s=e.x,i=e.y,a=-1/0;do{if(i<=n.y&&i>=n.next.y&&n.next.y!==n.y){var o=n.x+(i-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(o<=s&&o>a){if(a=o,o===s){if(i===n.y)return n;if(i===n.next.y)return n.next}r=n.x<n.next.x?n:n.next}}n=n.next}while(n!==t);if(!r)return null;if(s===a)return r;var l,h=r,c=r.x,u=r.y,f=1/0;n=r;do{s>=n.x&&n.x>=c&&s!==n.x&&m(i<u?s:a,i,c,u,i<u?a:s,i,n.x,n.y)&&(l=Math.abs(i-n.y)/(s-n.x),P(n,e)&&(l<f||l===f&&(n.x>r.x||n.x===r.x&&y(r,n)))&&(r=n,f=l)),n=n.next}while(n!==h);return r}(e,t);if(!r)return t;var n=V(r,e),s=i(r,r.next);let a=d(n);return i(a,a.next),s=d(s),d(t===r?s:t)}function y(e,t){return w(e.prev,e,t.prev)<0&&w(t.next,e,e.next)<0}function x(e,t,r,n){var s=e;do{null===s.z&&(s.z=g(s.x,s.y,t,r,n)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next}while(s!==e);s.prevZ.nextZ=null,s.prevZ=null,function(e){var t,r,n,s,i,a,o,l,h=1;do{for(r=e,e=null,i=null,a=0;r;){for(a++,n=r,o=0,t=0;t<h&&(o++,n=n.nextZ);t++);for(l=h;o>0||l>0&&n;)0!==o&&(0===l||!n||r.z<=n.z)?(s=r,r=r.nextZ,o--):(s=n,n=n.nextZ,l--),i?i.nextZ=s:e=s,s.prevZ=i,i=s;r=n}i.nextZ=null,h*=2}while(a>1)}(s)}function g(e,t,r,n,s){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-r)*s)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-n)*s)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function _(e){var t=e,r=e;do{(t.x<r.x||t.x===r.x&&t.y<r.y)&&(r=t),t=t.next}while(t!==e);return r}function m(e,t,r,n,s,i,a,o){return(s-a)*(t-o)-(e-a)*(i-o)>=0&&(e-a)*(n-o)-(r-a)*(t-o)>=0&&(r-a)*(i-o)-(s-a)*(n-o)>=0}function b(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){var r=e;do{if(r.i!==e.i&&r.next.i!==e.i&&r.i!==t.i&&r.next.i!==t.i&&I(r,r.next,e,t))return!0;r=r.next}while(r!==e);return!1}(e,t)&&(P(e,t)&&P(t,e)&&function(e,t){var r=e,n=!1,s=(e.x+t.x)/2,i=(e.y+t.y)/2;do{r.y>i!=r.next.y>i&&r.next.y!==r.y&&s<(r.next.x-r.x)*(i-r.y)/(r.next.y-r.y)+r.x&&(n=!n),r=r.next}while(r!==e);return n}(e,t)&&(w(e.prev,e,t.prev)||w(e,t.prev,t))||M(e,t)&&w(e.prev,e,e.next)>0&&w(t.prev,t,t.next)>0)}function w(e,t,r){return(t.y-e.y)*(r.x-t.x)-(t.x-e.x)*(r.y-t.y)}function M(e,t){return e.x===t.x&&e.y===t.y}function I(e,t,r,n){var s=k(w(e,t,r)),i=k(w(e,t,n)),a=k(w(r,n,e)),o=k(w(r,n,t));return s!==i&&a!==o||!(0!==s||!v(e,r,t))||!(0!==i||!v(e,n,t))||!(0!==a||!v(r,e,n))||!(0!==o||!v(r,t,n))}function v(e,t,r){return t.x<=Math.max(e.x,r.x)&&t.x>=Math.min(e.x,r.x)&&t.y<=Math.max(e.y,r.y)&&t.y>=Math.min(e.y,r.y)}function k(e){return e>0?1:e<0?-1:0}function P(e,t){return w(e.prev,e,e.next)<0?w(e,t,e.next)>=0&&w(e,e.prev,t)>=0:w(e,t,e.prev)<0||w(e,e.next,t)<0}function V(e,t){var r=new D(e.i,e.x,e.y),n=new D(t.i,t.x,t.y),s=e.next,i=t.prev;return e.next=t,t.prev=e,r.next=s,s.prev=r,n.next=r,r.prev=n,i.next=n,n.prev=i,n}function A(e,t,r,n){var s=new D(e,t,r);return n?(s.next=n.next,s.prev=n,n.next.prev=s,n.next=s):(s.prev=s,s.next=s),s}function B(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 D(e,t,r){this.i=e,this.x=t,this.y=r,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function S(e,t,r,n){for(var s=0,i=t,a=r-n;i<r;i+=n)s+=(e[a]-e[i])*(e[i+1]+e[a+1]),a=i;return s}r.d(t,{e:()=>n}),n.deviation=function(e,t,r,n){var s=t&&t.length,i=s?t[0]*r:e.length,a=Math.abs(S(e,0,i,r));if(s)for(var o=0,l=t.length;o<l;o++){var h=t[o]*r,c=o<l-1?t[o+1]*r:e.length;a-=Math.abs(S(e,h,c,r))}var u=0;for(o=0;o<n.length;o+=3){var f=n[o]*r,d=n[o+1]*r,p=n[o+2]*r;u+=Math.abs((e[f]-e[p])*(e[d+1]-e[f+1])-(e[f]-e[d])*(e[p+1]-e[f+1]))}return 0===a&&0===u?0:Math.abs((u-a)/a)},n.flatten=function(e){for(var t=e[0][0].length,r={vertices:[],holes:[],dimensions:t},n=0,s=0;s<e.length;s++){for(var i=0;i<e[s].length;i++)for(var a=0;a<t;a++)r.vertices.push(e[s][i][a]);s>0&&(n+=e[s-1].length,r.holes.push(n))}return r}},40876(e,t,r){r.d(t,{Eq:()=>d,G1:()=>y,TS:()=>i,Tf:()=>_,V6:()=>s,Vm:()=>p,ay:()=>l,c1:()=>x,c4:()=>a,j5:()=>h,lT:()=>u,oW:()=>c,xV:()=>b});const n={transparent:[0,0,0,0],black:[0,0,0,1],silver:[192,192,192,1],gray:[128,128,128,1],white:[255,255,255,1],maroon:[128,0,0,1],red:[255,0,0,1],purple:[128,0,128,1],fuchsia:[255,0,255,1],green:[0,128,0,1],lime:[0,255,0,1],olive:[128,128,0,1],yellow:[255,255,0,1],navy:[0,0,128,1],blue:[0,0,255,1],teal:[0,128,128,1],aqua:[0,255,255,1],aliceblue:[240,248,255,1],antiquewhite:[250,235,215,1],aquamarine:[127,255,212,1],azure:[240,255,255,1],beige:[245,245,220,1],bisque:[255,228,196,1],blanchedalmond:[255,235,205,1],blueviolet:[138,43,226,1],brown:[165,42,42,1],burlywood:[222,184,135,1],cadetblue:[95,158,160,1],chartreuse:[127,255,0,1],chocolate:[210,105,30,1],coral:[255,127,80,1],cornflowerblue:[100,149,237,1],cornsilk:[255,248,220,1],crimson:[220,20,60,1],cyan:[0,255,255,1],darkblue:[0,0,139,1],darkcyan:[0,139,139,1],darkgoldenrod:[184,134,11,1],darkgray:[169,169,169,1],darkgreen:[0,100,0,1],darkgrey:[169,169,169,1],darkkhaki:[189,183,107,1],darkmagenta:[139,0,139,1],darkolivegreen:[85,107,47,1],darkorange:[255,140,0,1],darkorchid:[153,50,204,1],darkred:[139,0,0,1],darksalmon:[233,150,122,1],darkseagreen:[143,188,143,1],darkslateblue:[72,61,139,1],darkslategray:[47,79,79,1],darkslategrey:[47,79,79,1],darkturquoise:[0,206,209,1],darkviolet:[148,0,211,1],deeppink:[255,20,147,1],deepskyblue:[0,191,255,1],dimgray:[105,105,105,1],dimgrey:[105,105,105,1],dodgerblue:[30,144,255,1],firebrick:[178,34,34,1],floralwhite:[255,250,240,1],forestgreen:[34,139,34,1],gainsboro:[220,220,220,1],ghostwhite:[248,248,255,1],gold:[255,215,0,1],goldenrod:[218,165,32,1],greenyellow:[173,255,47,1],grey:[128,128,128,1],honeydew:[240,255,240,1],hotpink:[255,105,180,1],indianred:[205,92,92,1],indigo:[75,0,130,1],ivory:[255,255,240,1],khaki:[240,230,140,1],lavender:[230,230,250,1],lavenderblush:[255,240,245,1],lawngreen:[124,252,0,1],lemonchiffon:[255,250,205,1],lightblue:[173,216,230,1],lightcoral:[240,128,128,1],lightcyan:[224,255,255,1],lightgoldenrodyellow:[250,250,210,1],lightgray:[211,211,211,1],lightgreen:[144,238,144,1],lightgrey:[211,211,211,1],lightpink:[255,182,193,1],lightsalmon:[255,160,122,1],lightseagreen:[32,178,170,1],lightskyblue:[135,206,250,1],lightslategray:[119,136,153,1],lightslategrey:[119,136,153,1],lightsteelblue:[176,196,222,1],lightyellow:[255,255,224,1],limegreen:[50,205,50,1],linen:[250,240,230,1],magenta:[255,0,255,1],mediumaquamarine:[102,205,170,1],mediumblue:[0,0,205,1],mediumorchid:[186,85,211,1],mediumpurple:[147,112,219,1],mediumseagreen:[60,179,113,1],mediumslateblue:[123,104,238,1],mediumspringgreen:[0,250,154,1],mediumturquoise:[72,209,204,1],mediumvioletred:[199,21,133,1],midnightblue:[25,25,112,1],mintcream:[245,255,250,1],mistyrose:[255,228,225,1],moccasin:[255,228,181,1],navajowhite:[255,222,173,1],oldlace:[253,245,230,1],olivedrab:[107,142,35,1],orange:[255,165,0,1],orangered:[255,69,0,1],orchid:[218,112,214,1],palegoldenrod:[238,232,170,1],palegreen:[152,251,152,1],paleturquoise:[175,238,238,1],palevioletred:[219,112,147,1],papayawhip:[255,239,213,1],peachpuff:[255,218,185,1],peru:[205,133,63,1],pink:[255,192,203,1],plum:[221,160,221,1],powderblue:[176,224,230,1],rebeccapurple:[102,51,153,1],rosybrown:[188,143,143,1],royalblue:[65,105,225,1],saddlebrown:[139,69,19,1],salmon:[250,128,114,1],sandybrown:[244,164,96,1],seagreen:[46,139,87,1],seashell:[255,245,238,1],sienna:[160,82,45,1],skyblue:[135,206,235,1],slateblue:[106,90,205,1],slategray:[112,128,144,1],slategrey:[112,128,144,1],snow:[255,250,250,1],springgreen:[0,255,127,1],steelblue:[70,130,180,1],tan:[210,180,140,1],thistle:[216,191,216,1],tomato:[255,99,71,1],turquoise:[64,224,208,1],violet:[238,130,238,1],wheat:[245,222,179,1],whitesmoke:[245,245,245,1],yellowgreen:[154,205,50,1]};function s(e){return!!n[e]||!!n[e.toLowerCase()]}function i(e){return n[e]??n[e.toLowerCase()]}function a(e){return[...i(e)]}function o(e,t,r){r<0&&++r,r>1&&--r;const n=6*r;return n<1?e+(t-e)*n:2*r<1?t:3*r<2?e+(t-e)*(2/3-r)*6:e}function l(e,t,r,n=1){const s=(e%360+360)%360/360,i=r<=.5?r*(t+1):r+t-r*t,a=2*r-i;return[Math.round(255*o(a,i,s+1/3)),Math.round(255*o(a,i,s)),Math.round(255*o(a,i,s-1/3)),n]}function h(e){const t=e.length>5,r=t?8:4,n=(1<<r)-1,s=t?1:17,i=t?9===e.length:5===e.length;let a=Number("0x"+e.slice(1));if(isNaN(a))return null;const o=[0,0,0,1];let l;return i&&(l=a&n,a>>=r,o[3]=s*l/255),l=a&n,a>>=r,o[2]=s*l,l=a&n,a>>=r,o[1]=s*l,l=a&n,a>>=r,o[0]=s*l,o}function c(e){if(!e.startsWith("#")||isNaN(Number(`0x${e.slice(1)}`)))return null;switch(e.length){case 4:case 5:{const t=parseInt(e.slice(1,2),16),r=parseInt(e.slice(2,3),16),n=parseInt(e.slice(3,4),16),s=4===e.length?15:parseInt(e.slice(4),16);return[t+16*t,r+16*r,n+16*n,(s+16*s)/255]}case 7:case 9:return[parseInt(e.slice(1,3),16),parseInt(e.slice(3,5),16),parseInt(e.slice(5,7),16),(7===e.length?255:parseInt(e.slice(7),16))/255];default:return null}}function u(e){const t=e.toLowerCase().match(/^(rgba?|hsla?)\(([\s.\-,%0-9]+)\)/);if(t){const e=t[2].split(/\s*,\s*/),r=t[1];if("rgb"===r&&3===e.length||"rgba"===r&&4===e.length){if(e[0].endsWith("%")){const t=e.map(e=>2.56*parseFloat(e));return 4===e.length&&(t[3]=parseFloat(e[3])),f(t)}return f(e.map(e=>parseFloat(e)))}if("hsl"===r&&3===e.length||"hsla"===r&&4===e.length)return l(parseFloat(e[0]),parseFloat(e[1])/100,parseFloat(e[2])/100,parseFloat(e[3]??"1"))}return null}function f(e){return e[0]=x(e[0]),e[1]=x(e[1]),e[2]=x(e[2]),e[3]=4===e.length?y(e[3]):1,e}function d(e){let t=s(e)?i(e):null;return t??=u(e),t??=c(e),t}function p(e){const t=d(e);return null!=t?[t[0]/255,t[1]/255,t[2]/255,t[3]]:null}function y(e){return g(e,0,1)}function x(e){return Math.round(g(e,0,255))}function g(e,t,r){return e=Number(e),isNaN(e)?r:e<t?t:e>r?r:e}const _=2.2,m=1/_;function b(e){return e**m}},91829(e,t,r){function n(){return[0,0,0,0]}function s(e,t,r,n){return[e,t,r,n]}function i(){return s(1,1,1,1)}function a(){return s(1,0,0,0)}function o(){return s(0,1,0,0)}function l(){return s(0,0,1,0)}function h(){return s(0,0,0,1)}r.d(t,{Un:()=>u,fA:()=>s,uY:()=>c,vt:()=>n});const c=[0,0,0,0],u=i(),f=a(),d=o(),p=l(),y=h();Object.freeze(Object.defineProperty({__proto__:null,ONES:u,UNIT_W:y,UNIT_X:f,UNIT_Y:d,UNIT_Z:p,ZEROS:c,clone:function(e){return[e[0],e[1],e[2],e[3]]},create:n,freeze:function(e,t,r,n){return[e,t,r,n]},fromArray:function(e,t=[0,0,0,0]){const r=Math.min(4,e.length);for(let n=0;n<r;++n)t[n]=e[n];return t},fromValues:s,ones:i,unitW:h,unitX:a,unitY:o,unitZ:l,zeros:function(){return[0,0,0,0]}},Symbol.toStringTag,{value:"Module"}))},34304(e,t,r){r.d(t,{DF:()=>l,FD:()=>s,Ov:()=>i,ct:()=>h});let n=1e-6;function s(){return n}const i=Math.random,a=Math.PI/180,o=180/Math.PI;function l(e){return e*a}function h(e){return e*o}Object.freeze(Object.defineProperty({__proto__:null,RANDOM:i,equals:function(e,t){return Math.abs(e-t)<=n*Math.max(1,Math.abs(e),Math.abs(t))},getEpsilon:s,setEpsilon:function(e){n=e},toDegree:h,toRadian:l},Symbol.toStringTag,{value:"Module"}))},78955(e,t,r){r.d(t,{Bw:()=>x,C:()=>s,Cc:()=>b,LI:()=>f,Om:()=>m,S8:()=>_,T9:()=>u,WQ:()=>a,Z0:()=>w,aI:()=>I,hG:()=>y,hZ:()=>i,hs:()=>d,jk:()=>c,m3:()=>g,t2:()=>M});var n=r(34304);function s(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e}function i(e,t,r,n,s){return e[0]=t,e[1]=r,e[2]=n,e[3]=s,e}function a(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e[2]=t[2]+r[2],e[3]=t[3]+r[3],e}function o(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e[2]=t[2]-r[2],e[3]=t[3]-r[3],e}function l(e,t,r){return e[0]=t[0]*r[0],e[1]=t[1]*r[1],e[2]=t[2]*r[2],e[3]=t[3]*r[3],e}function h(e,t,r){return e[0]=t[0]/r[0],e[1]=t[1]/r[1],e[2]=t[2]/r[2],e[3]=t[3]/r[3],e}function c(e,t,r){return e[0]=Math.min(t[0],r[0]),e[1]=Math.min(t[1],r[1]),e[2]=Math.min(t[2],r[2]),e[3]=Math.min(t[3],r[3]),e}function u(e,t,r){return e[0]=Math.max(t[0],r[0]),e[1]=Math.max(t[1],r[1]),e[2]=Math.max(t[2],r[2]),e[3]=Math.max(t[3],r[3]),e}function f(e,t){return e[0]=Math.round(t[0]),e[1]=Math.round(t[1]),e[2]=Math.round(t[2]),e[3]=Math.round(t[3]),e}function d(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e}function p(e,t){const r=t[0]-e[0],n=t[1]-e[1],s=t[2]-e[2],i=t[3]-e[3];return Math.sqrt(r*r+n*n+s*s+i*i)}function y(e,t){const r=t[0]-e[0],n=t[1]-e[1],s=t[2]-e[2],i=t[3]-e[3];return r*r+n*n+s*s+i*i}function x(e){const t=e[0],r=e[1],n=e[2],s=e[3];return Math.sqrt(t*t+r*r+n*n+s*s)}function g(e){const t=e[0],r=e[1],n=e[2],s=e[3];return t*t+r*r+n*n+s*s}function _(e,t){const r=t[0],n=t[1],s=t[2],i=t[3];let a=r*r+n*n+s*s+i*i;return a>0&&(a=1/Math.sqrt(a),e[0]=r*a,e[1]=n*a,e[2]=s*a,e[3]=i*a),e}function m(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]}function b(e,t,r,n){const s=t[0],i=t[1],a=t[2],o=t[3];return e[0]=s+n*(r[0]-s),e[1]=i+n*(r[1]-i),e[2]=a+n*(r[2]-a),e[3]=o+n*(r[3]-o),e}function w(e,t,r){const n=t[0],s=t[1],i=t[2],a=t[3];return e[0]=r[0]*n+r[4]*s+r[8]*i+r[12]*a,e[1]=r[1]*n+r[5]*s+r[9]*i+r[13]*a,e[2]=r[2]*n+r[6]*s+r[10]*i+r[14]*a,e[3]=r[3]*n+r[7]*s+r[11]*i+r[15]*a,e}function M(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]}function I(e,t){const r=e[0],s=e[1],i=e[2],a=e[3],o=t[0],l=t[1],h=t[2],c=t[3],u=(0,n.FD)();return Math.abs(r-o)<=u*Math.max(1,Math.abs(r),Math.abs(o))&&Math.abs(s-l)<=u*Math.max(1,Math.abs(s),Math.abs(l))&&Math.abs(i-h)<=u*Math.max(1,Math.abs(i),Math.abs(h))&&Math.abs(a-c)<=u*Math.max(1,Math.abs(a),Math.abs(c))}const v=o,k=l,P=h,V=p,A=y,B=x,D=g;Object.freeze(Object.defineProperty({__proto__:null,add:a,ceil:function(e,t){return e[0]=Math.ceil(t[0]),e[1]=Math.ceil(t[1]),e[2]=Math.ceil(t[2]),e[3]=Math.ceil(t[3]),e},copy:s,copyVec3:function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e},dist:V,distance:p,div:P,divide:h,dot:m,equals:I,exactEquals:M,floor:function(e,t){return e[0]=Math.floor(t[0]),e[1]=Math.floor(t[1]),e[2]=Math.floor(t[2]),e[3]=Math.floor(t[3]),e},inverse:function(e,t){return e[0]=1/t[0],e[1]=1/t[1],e[2]=1/t[2],e[3]=1/t[3],e},len:B,length:x,lerp:b,max:u,min:c,mul:k,multiply:l,negate:function(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=-t[3],e},normalize:_,random:function(e,t=1){const r=n.Ov;let s,i,a,o,l,h;do{s=2*r()-1,i=2*r()-1,l=s*s+i*i}while(l>=1);do{a=2*r()-1,o=2*r()-1,h=a*a+o*o}while(h>=1);const c=Math.sqrt((1-l)/h);return e[0]=t*s,e[1]=t*i,e[2]=t*a*c,e[3]=t*o*c,e},round:f,scale:d,scaleAndAdd:function(e,t,r,n){return e[0]=t[0]+r[0]*n,e[1]=t[1]+r[1]*n,e[2]=t[2]+r[2]*n,e[3]=t[3]+r[3]*n,e},set:i,sqrDist:A,sqrLen:D,squaredDistance:y,squaredLength:g,str:function(e){return"vec4("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+")"},sub:v,subtract:o,transformMat4:w,transformQuat:function(e,t,r){const n=t[0],s=t[1],i=t[2],a=r[0],o=r[1],l=r[2],h=r[3],c=h*n+o*i-l*s,u=h*s+l*n-a*i,f=h*i+a*s-o*n,d=-a*n-o*s-l*i;return e[0]=c*h+d*-a+u*-l-f*-o,e[1]=u*h+d*-o+f*-a-c*-l,e[2]=f*h+d*-l+c*-o-u*-a,e[3]=t[3],e}},Symbol.toStringTag,{value:"Module"}))},69397(e,t,r){r.d(t,{Qf:()=>l,Qh:()=>a,RS:()=>s,Ul:()=>d,i5:()=>f,lM:()=>i,qK:()=>c});var n=r(34275);const s=16;function i(e){if(!e)return 0;let t=c;for(const r in e)e.hasOwnProperty(r)&&(t+=o(e[r],!1));return t}function a(e){if(!e)return 0;if("number"==typeof e[0])return l(e);if(Array.isArray(e))return function(e){const t=e.length;if(0===t||"number"==typeof e[0])return h(e,8);let r=u;for(let n=0;n<t;n++)r+=o(e[n]);return r}(e);let t=c;for(const r in e)e.hasOwnProperty(r)&&(t+=o(e[r]));return t}function o(e,t=!0){switch(typeof e){case"object":return t?a(e):c;case"string":return function(e){return 32+e.length}(e);case"number":return s;case"boolean":return 4;default:return 8}}function l(...e){return e.reduce((e,t)=>e+(t?(0,n.iu)(t)?t.byteLength+f:Array.isArray(t)?h(t,s):0:0),0)}function h(e,t){return u+e.length*t}const c=32,u=16,f=145,d=64},51624(e,t,r){r.d(t,{A:()=>h});var n=r(44208),s=r(69397),i=r(93687);const a=4294967296,o=new TextDecoder("utf-8"),l=(0,n.A)("safari")||(0,n.A)("ios")?6:(0,n.A)("ff")?12:32;class h{constructor(e,t,r=0,n=e?.byteLength??0){this._tag=0,this._dataType=99,this._init(e,t,r,n)}[Symbol.dispose](){this.release()}_init(e,t,r,n){this._data=e,this._dataView=t,this._pos=r,this._end=n}get usedMemory(){return 64+(0,s.Qf)(this._data)}asUnsafe(){return this}clone(){return new h(this._data,this._dataView,this._pos,this._end)}clonePooled(){return h.constructPooled(this._data,this._dataView,this._pos,this._end)}static constructPooled(e,t,r=0,n=e?.byteLength??0){const s=h.pool.acquire();return s._init(e,t,r,n),s}pos(){return this._pos}move(e){this._pos=e}nextTag(e){for(;;){if(this._pos===this._end)return!1;const t=this._decodeVarint();if(this._tag=t>>3,this._dataType=7&t,!e||e===this._tag)break;this.skip()}return!0}next(){if(this._pos===this._end)return!1;const e=this._decodeVarint();return this._tag=e>>3,this._dataType=7&e,!0}empty(){return this._pos>=this._end}tag(){return this._tag}getInt32(){return this._decodeVarint()}getInt64(){return this._decodeVarint()}getUInt32(){let e=4294967295;if(e=(127&this._data[this._pos])>>>0,this._data[this._pos++]<128)return e;if(e=(e|(127&this._data[this._pos])<<7)>>>0,this._data[this._pos++]<128)return e;if(e=(e|(127&this._data[this._pos])<<14)>>>0,this._data[this._pos++]<128)return e;if(e=(e|(127&this._data[this._pos])<<21)>>>0,this._data[this._pos++]<128)return e;if(e=(e|(15&this._data[this._pos])<<28)>>>0,this._data[this._pos++]<128)return e;throw new Error("Varint overflow")}getPackedEnd(){const e=this.getUInt32();return this._pos+e}getUInt64(){return this._decodeVarint()}getSInt32(){const e=this.getUInt32();return e>>>1^-(1&e)}getSInt64(){return this._decodeSVarint()}getBool(){const e=0!==this._data[this._pos];return this._skip(1),e}getEnum(){return this._decodeVarint()}getFixed64(){const e=this._dataView,t=this._pos,r=e.getUint32(t,!0)+e.getUint32(t+4,!0)*a;return this._skip(8),r}getSFixed64(){const e=this._dataView,t=this._pos,r=e.getUint32(t,!0)+e.getInt32(t+4,!0)*a;return this._skip(8),r}getDouble(){const e=this._dataView.getFloat64(this._pos,!0);return this._skip(8),e}getFixed32(){const e=this._dataView.getUint32(this._pos,!0);return this._skip(4),e}getSFixed32(){const e=this._dataView.getInt32(this._pos,!0);return this._skip(4),e}getFloat(){const e=this._dataView.getFloat32(this._pos,!0);return this._skip(4),e}getString(){const e=this._getLength(),t=this._pos,r=this._toString(this._data,t,t+e);return this._skip(e),r}getBytes(){const e=this._getLength(),t=this._pos,r=this._toBytes(this._data,t,t+e);return this._skip(e),r}getLength(){return this._getLengthUnsafe()}processMessageWithArgs(e,t,r,n){const s=this.getMessage(),i=e(s,t,r,n);return s.release(),i}processMessage(e){const t=this.getMessage(),r=e(t);return t.release(),r}getMessage(){const e=this._getLength(),t=h.pool.acquire();return t._init(this._data,this._dataView,this._pos,this._pos+e),this._skip(e),t}release(){h.pool.release(this)}dataType(){return this._dataType}skip(){switch(this._dataType){case 0:this._decodeVarint();break;case 1:this._skip(8);break;case 2:this._skip(this._getLength());break;case 5:this._skip(4);break;default:throw new Error("Invalid data type!")}}skipToEnd(){for(;this.next();)this.skip()}skipLen(e){this._skip(e)}_skip(e){if(this._pos+e>this._end)throw new Error("Attempt to skip past the end of buffer!");this._pos+=e}_decodeVarint(){const e=this._data;let t=this._pos,r=0,n=0;if(this._end-t>=10)do{if(n=e[t++],r|=127&n,!(128&n))break;if(n=e[t++],r|=(127&n)<<7,!(128&n))break;if(n=e[t++],r|=(127&n)<<14,!(128&n))break;if(n=e[t++],r|=(127&n)<<21,!(128&n))break;if(n=e[t++],r+=268435456*(127&n),!(128&n))break;if(n=e[t++],r+=34359738368*(127&n),!(128&n))break;if(n=e[t++],r+=4398046511104*(127&n),!(128&n))break;if(n=e[t++],r+=562949953421312*(127&n),!(128&n))break;if(n=e[t++],r+=72057594037927940*(127&n),!(128&n))break;if(n=e[t++],r+=0x8000000000000000*(127&n),!(128&n))break;throw new Error("Varint too long!")}while(0);else{let s=1;for(;t!==this._end&&(n=e[t],128&n);)++t,r+=(127&n)*s,s*=128;if(t===this._end)throw new Error("Varint overrun!");++t,r+=n*s}return this._pos=t,r}_decodeSVarint(){const e=this._data;let t,r=0,n=0;const s=1&e[this._pos];if(n=e[this._pos++],r|=127&n,!(128&n))return s?-(r+1)/2:r/2;if(n=e[this._pos++],r|=(127&n)<<7,!(128&n))return s?-(r+1)/2:r/2;if(n=e[this._pos++],r|=(127&n)<<14,!(128&n))return s?-(r+1)/2:r/2;if(n=e[this._pos++],r|=(127&n)<<21,!(128&n))return s?-(r+1)/2:r/2;if(n=e[this._pos++],r+=268435456*(127&n),!(128&n))return s?-(r+1)/2:r/2;if(n=e[this._pos++],r+=34359738368*(127&n),!(128&n))return s?-(r+1)/2:r/2;if(n=e[this._pos++],r+=4398046511104*(127&n),!(128&n))return s?-(r+1)/2:r/2;if(t=BigInt(r),n=e[this._pos++],t+=0x2000000000000n*BigInt(127&n),!(128&n))return Number(s?-(t+1n)/2n:t/2n);if(n=e[this._pos++],t+=0x100000000000000n*BigInt(127&n),!(128&n))return Number(s?-(t+1n)/2n:t/2n);if(n=e[this._pos++],t+=0x8000000000000000n*BigInt(127&n),!(128&n))return Number(s?-(t+1n)/2n:t/2n);throw new Error("Varint too long!")}_getLength(){if(2!==this._dataType)throw new Error("Not a delimited data type!");return this._decodeVarint()}_getLengthUnsafe(){return this.getUInt32()}_toString(e,t,r){if((r=Math.min(this._end,r))-t>l){const n=e.subarray(t,r);return o.decode(n)}let n="",s="";for(let i=t;i<r;++i){const t=e[i];128&t?s+="%"+t.toString(16):(n+=decodeURIComponent(s)+String.fromCharCode(t),s="")}return s.length&&(n+=decodeURIComponent(s)),n}_toBytes(e,t,r){return r=Math.min(this._end,r),new Uint8Array(e.buffer,t,r-t)}static{this.pool=new i.A(()=>new h(null,null),void 0,e=>{e._data=null,e._dataView=null})}}},91075(e,t,r){r.d(t,{A:()=>l});var n=r(5482),s=r(25482),i=r(91429),a=r(16930),o=r(36005);let l=class extends s.o{constructor(...e){super(...e),this.type=null,this.hasM=!1,this.hasZ=!1,this.spatialReference=a.A.WGS84}get cache(){return this.commitProperty("spatialReference"),{}}get extent(){return null}readSpatialReference(e,t){if(e instanceof a.A)return e;if(null!=e){const r=new a.A;return r.read(e,t),r}return e}clone(){return console.warn(".clone() is not implemented for "+this.declaredClass),null}clearCache(){this.notifyChange("cache")}getCacheValue(e){return this.cache[e]}setCacheValue(e,t){this.cache[e]=t}};(0,n.Cg)([(0,i.MZ)()],l.prototype,"type",void 0),(0,n.Cg)([(0,i.MZ)({readOnly:!0})],l.prototype,"cache",null),(0,n.Cg)([(0,i.MZ)({readOnly:!0})],l.prototype,"extent",null),(0,n.Cg)([(0,i.MZ)({type:Boolean,json:{write:{overridePolicy:e=>({enabled:e})}}})],l.prototype,"hasM",void 0),(0,n.Cg)([(0,i.MZ)({type:Boolean,json:{write:{overridePolicy:e=>({enabled:e})}}})],l.prototype,"hasZ",void 0),(0,n.Cg)([(0,i.MZ)({type:a.A,json:{write:!0},value:a.A.WGS84})],l.prototype,"spatialReference",void 0),(0,n.Cg)([(0,o.w)("spatialReference")],l.prototype,"readSpatialReference",null),l=(0,n.Cg)([(0,i.$K)("esri.geometry.Geometry")],l)},86738(e,t,r){r.d(t,{A:()=>m});var n=r(5482),s=r(69622),i=r(53966),a=r(91429),o=r(56507),l=r(91075),h=r(16930),c=r(21325),u=r(28735);function f({x:e,y:t,spatialReference:r},n=[0,0]){if(r){if((0,c.K8)(r))return(0,u.tD)(e,t,n);if((0,c.EA)(r))return n[0]=e,n[1]=t,n}return null}const d=[0,0];var p,y=r(43937),x=r(36005);const g=[0,0];function _(e){return e&&("esri.geometry.SpatialReference"===e.declaredClass||null!=e.wkid)}let m=p=class extends l.A{static copy(e,t){t._set("x",e._get("x")),t._set("y",e._get("y")),t._set("z",e._get("z")),t._set("m",e._get("m"));const r=e._get("spatialReference");t._set("spatialReference",s.A.isFrozen(r)?r:r.clone())}constructor(...e){super(...e),this.x=0,this.y=0,this.z=void 0,this.m=void 0,this.type="point"}normalizeCtorArgs(e,t,r,n,s){let a;if(Array.isArray(e))a=e,s=t,e=a[0],t=a[1],r=a[2],n=a[3];else if(e&&"object"==typeof e){if(a=e,e=null!=a.x?a.x:a.longitude,t=null!=a.y?a.y:a.latitude,r=a.z,n=a.m,(s=a.spatialReference)&&"esri.geometry.SpatialReference"!==s.declaredClass&&(s=new h.A(s)),null!=a.longitude||null!=a.latitude)if(null==a.longitude)i.A.getLogger(this).warn(".longitude=","Latitude was defined without longitude");else if(null==a.latitude)i.A.getLogger(this).warn(".latitude=","Longitude was defined without latitude");else if(!a.declaredClass&&s?.isWebMercator){const r=(0,u.je)(a.longitude,a.latitude,g);e=r[0],t=r[1]}}else _(r)?(s=r,r=null):_(n)&&(s=n,n=null);const o={x:e,y:t};return null==o.x&&null!=o.y?i.A.getLogger(this).warn(".y=","Y coordinate was defined without an X coordinate"):null==o.y&&null!=o.x&&i.A.getLogger(this).warn(".x=","X coordinate was defined without a Y coordinate"),null!=s&&(o.spatialReference=s),null!=r&&(o.z=r),null!=n&&(o.m=n),o}get cache(){return this.commitProperty("x"),this.commitProperty("y"),this.commitProperty("z"),this.commitProperty("m"),this.commitProperty("spatialReference"),{}}get hasM(){return void 0!==this.m}set hasM(e){e!==(void 0!==this._get("m"))&&(this._set("m",e?0:void 0),this._set("hasM",e))}get hasZ(){return void 0!==this.z}set hasZ(e){e!==(void 0!==this._get("z"))&&(this._set("z",e?0:void 0),this._set("hasZ",e))}get latitude(){return f(this,d)?.[1]??null}set latitude(e){const{spatialReference:t,x:r}=this;null!=e&&t&&(t.isWebMercator?this._set("y",(0,u.je)(r,e,g)[1]):t.isGeographic&&this._set("y",e),this._set("latitude",e))}get longitude(){return f(this,d)?.[0]??null}set longitude(e){const{y:t,spatialReference:r}=this;null!=e&&r&&(r.isWebMercator?this._set("x",(0,u.je)(e,t,g)[0]):r.isGeographic&&this._set("x",e),this._set("longitude",e))}writeX(e,t,r){t[r]=isNaN(e)?"NaN":e}readX(e){return"string"==typeof e?NaN:e}clone(){const e=new p;return e.x=this.x,e.y=this.y,e.z=this.z,e.m=this.m,e.spatialReference=this.spatialReference,e}copy(e){return p.copy(e,this),this}equals(e){if(null==e)return!1;const{x:t,y:r,z:n,m:s,spatialReference:i}=this,{z:a,m:o}=e;let{x:l,y:h,spatialReference:c}=e;if(!i.equals(c))if(i.isWebMercator&&c.isWGS84)[l,h]=(0,u.je)(l,h),c=i;else{if(!i.isWGS84||!c.isWebMercator)return!1;[l,h]=(0,u.tD)(l,h),c=i}return t===l&&r===h&&n===a&&s===o&&i.wkid===c.wkid}offset(e,t,r){return this.x+=e,this.y+=t,null!=r&&(this.z=(this.z??0)+r),this}normalize(){if(!this.spatialReference)return this;const e=(0,c.Vp)(this.spatialReference);if(!e)return this;let t=this.x;const[r,n]=e.valid,s=2*n;let i;return t>n?(i=Math.ceil(Math.abs(t-n)/s),t-=i*s):t<r&&(i=Math.ceil(Math.abs(t-r)/s),t+=i*s),this._set("x",t),this}distance(e){return function(e,t){const r=e.x-t.x,n=e.y-t.y,s=null!=e.z&&null!=t.z?e.z-t.z:0;return Math.sqrt(r*r+n*n+s*s)}(this,e)}toArray(){const e=this.hasZ,t=this.hasM;return e&&t?[this.x,this.y,this.z,this.m]:e?[this.x,this.y,this.z]:t?[this.x,this.y,this.m]:[this.x,this.y]}toJSON(e){return this.write({},e)}};(0,n.Cg)([(0,a.MZ)({readOnly:!0})],m.prototype,"cache",null),(0,n.Cg)([(0,a.MZ)({type:Boolean,json:{read:!1,write:{enabled:!1,overridePolicy:null}}})],m.prototype,"hasM",null),(0,n.Cg)([(0,a.MZ)({type:Boolean,json:{read:!1,write:{enabled:!1,overridePolicy:null}}})],m.prototype,"hasZ",null),(0,n.Cg)([(0,a.MZ)({type:Number})],m.prototype,"latitude",null),(0,n.Cg)([(0,a.MZ)({type:Number})],m.prototype,"longitude",null),(0,n.Cg)([(0,a.MZ)({type:Number,json:{type:[Number,String],write:{isRequired:!0,allowNull:!0}}}),(0,a.wg)(e=>isNaN(e)?e:(0,o.GB)(e))],m.prototype,"x",void 0),(0,n.Cg)([(0,y.K)("x")],m.prototype,"writeX",null),(0,n.Cg)([(0,x.w)("x")],m.prototype,"readX",null),(0,n.Cg)([(0,a.MZ)({type:Number,json:{write:!0}})],m.prototype,"y",void 0),(0,n.Cg)([(0,a.MZ)({type:Number,json:{write:{overridePolicy(){return{enabled:this.hasZ}}}}})],m.prototype,"z",void 0),(0,n.Cg)([(0,a.MZ)({type:Number,json:{write:{overridePolicy(){return{enabled:this.hasM}}}}})],m.prototype,"m",void 0),m=p=(0,n.Cg)([(0,a.$K)("esri.geometry.Point")],m),m.prototype.toJSON.isDefaultToJSON=!0},21276(e,t,r){r.d(t,{H:()=>i,f:()=>s});var n=r(49186);function s(e){if(e&&"object"==typeof e&&"type"in e&&"mesh"===e.type)throw new n.A("internal:mesh","Mesh geometries are not supported for this operation")}function i(e){e.forEach(s)}},28735(e,t,r){r.d(t,{Cv:()=>x,Gh:()=>m,ci:()=>b,je:()=>g,jg:()=>u,tD:()=>_,y7:()=>y,yw:()=>c});var n=r(4718),s=r(21276),i=r(16930),a=r(79258),o=r(21325);function l(e){return 57.29577951308232*e}function h(e){return.017453292519943*e}function c(e){return e/a.$O.radius}function u(e){return Math.PI/2-2*Math.atan(Math.exp(-e/a.$O.radius))}function f(e){return null!=e.wkid||null!=e.wkt}const d=[0,0];function p(e,t,r,n,s){const i=e,a=s;if(a.spatialReference=r,"x"in i&&"x"in a)[a.x,a.y]=t(i.x,i.y,d,n);else if("xmin"in i&&"xmin"in a)[a.xmin,a.ymin]=t(i.xmin,i.ymin,d,n),[a.xmax,a.ymax]=t(i.xmax,i.ymax,d,n);else if("paths"in i&&"paths"in a||"rings"in i&&"rings"in a){const e="paths"in i?i.paths:i.rings,r=[];let s;for(let i=0;i<e.length;i++){const a=e[i];s=[],r.push(s);for(let e=0;e<a.length;e++)s.push(t(a[e][0],a[e][1],[0,0],n)),a[e].length>2&&s[e].push(a[e][2]),a[e].length>3&&s[e].push(a[e][3])}"paths"in a?a.paths=r:a.rings=r}else if("points"in i&&"points"in a){const e=i.points,r=[];for(let s=0;s<e.length;s++)r[s]=t(e[s][0],e[s][1],[0,0],n),e[s].length>2&&r[s].push(e[s][2]),e[s].length>3&&r[s].push(e[s][3]);a.points=r}return s}function y(e,t){const r=e&&(f(e)?e:e.spatialReference),n=t&&(f(t)?t:t.spatialReference);return!(e&&"type"in e&&"mesh"===e.type||t&&"type"in t&&"mesh"===t.type||!r||!n)&&(!!(0,o.aI)(n,r)||(0,o.K8)(n)&&(0,o.oT)(r)||(0,o.K8)(r)&&(0,o.oT)(n))}function x(e,t){if(null==e)return null;const r=e.spatialReference,s=t&&(f(t)?t:t.spatialReference);return y(r,s)?(0,o.aI)(r,s)?(0,n.o8)(e):(0,o.K8)(s)?p(e,g,i.A.WebMercator,!1,(0,n.o8)(e)):(0,o.oT)(s)?p(e,_,i.A.WGS84,!1,(0,n.o8)(e)):null:null}function g(e,t,r=[0,0]){t>89.99999?t=89.99999:t<-89.99999&&(t=-89.99999);const n=h(t);return r[0]=h(e)*a.$O.radius,r[1]=a.$O.halfSemiMajorAxis*Math.log((1+Math.sin(n))/(1-Math.sin(n))),r}function _(e,t,r=[0,0],n=!1){if(e===o.Mc[0])r[0]=-180;else if(e===o.Mc[1])r[0]=180;else{const t=l(e/a.$O.radius);r[0]=n?t:t-360*Math.floor((t+180)/360)}return r[1]=l(Math.PI/2-2*Math.atan(Math.exp(-t/a.$O.radius))),r}function m(e,t=!1,r=(0,n.o8)(e)){return(0,s.f)(e),(0,s.f)(r),p(e,g,i.A.WebMercator,t,r)}function b(e,t=!1,r=(0,n.o8)(e)){return(0,s.f)(e),(0,s.f)(r),p(e,_,i.A.WGS84,t,r)}},36849(e,t,r){r.r(t),r.d(t,{default:()=>Y});var n=r(17676),s=r(6774),i=r(5408),a=r(13195);function o(e){return 746===e||747===e||!(e<4352)&&(e>=12704&&e<=12735||e>=12544&&e<=12591||e>=65072&&e<=65103&&!(e>=65097&&e<=65103)||e>=63744&&e<=64255||e>=13056&&e<=13311||e>=11904&&e<=12031||e>=12736&&e<=12783||e>=12288&&e<=12351&&!(e>=12296&&e<=12305||e>=12308&&e<=12319||12336===e)||e>=13312&&e<=19903||e>=19968&&e<=40959||e>=12800&&e<=13055||e>=12592&&e<=12687||e>=43360&&e<=43391||e>=55216&&e<=55295||e>=4352&&e<=4607||e>=44032&&e<=55215||e>=12352&&e<=12447||e>=12272&&e<=12287||e>=12688&&e<=12703||e>=12032&&e<=12255||e>=12784&&e<=12799||e>=12448&&e<=12543&&12540!==e||e>=65280&&e<=65519&&!(65288===e||65289===e||65293===e||e>=65306&&e<=65310||65339===e||65341===e||65343===e||e>=65371&&e<=65503||65507===e||e>=65512&&e<=65519)||e>=65104&&e<=65135&&!(e>=65112&&e<=65118||e>=65123&&e<=65126)||e>=5120&&e<=5759||e>=6320&&e<=6399||e>=65040&&e<=65055||e>=19904&&e<=19967||e>=40960&&e<=42127||e>=42128&&e<=42191)}function l(e){return!(e<11904)&&(e>=12704&&e<=12735||e>=12544&&e<=12591||e>=65072&&e<=65103||e>=63744&&e<=64255||e>=13056&&e<=13311||e>=11904&&e<=12031||e>=12736&&e<=12783||e>=12288&&e<=12351||e>=13312&&e<=19903||e>=19968&&e<=40959||e>=12800&&e<=13055||e>=65280&&e<=65519||e>=12352&&e<=12447||e>=12272&&e<=12287||e>=12032&&e<=12255||e>=12784&&e<=12799||e>=12448&&e<=12543||e>=65040&&e<=65055||e>=42128&&e<=42191||e>=40960&&e<=42127)}function h(e){switch(e){case 10:case 32:case 38:case 40:case 41:case 43:case 45:case 47:case 173:case 183:case 8203:case 8208:case 8211:case 8231:return!0}return!1}function c(e){switch(e){case 9:case 10:case 11:case 12:case 13:case 32:return!0}return!1}var u=r(18989);const f=24;class d{constructor(e,t,r,n,s,i,a){this._glyphItems=e,this._maxWidth=t,this._lineHeight=r,this._letterSpacing=n,this._hAnchor=s,this._vAnchor=i,this._justify=a}getShaping(e,t,r){const n=this._letterSpacing,s=this._lineHeight,i=this._justify,a=this._maxWidth,u=[];let f=0,d=0;for(const t of e){const e=t.codePointAt(0);if(null==e)continue;const s=r&&o(e);let i;for(const t of this._glyphItems)if(i=t[e],i)break;u.push({codePoint:e,x:f,y:d,vertical:s,glyphMosaicItem:i}),i&&(f+=i.metrics.advance+n)}let p=f;a>0&&(p=f/Math.max(1,Math.ceil(f/a)));const y=e.includes("​"),x=[],g=u.length;for(let e=0;e<g-1;e++){const t=u[e].codePoint,r=l(t);if(h(t)||r){let n=0;if(10===t)n-=1e4;else if(r&&y)n+=150;else{40!==t&&65288!==t||(n+=50);const r=u[e+1].codePoint;41!==r&&65289!==r||(n+=50)}x.push(this._buildBreak(e+1,u[e].x,p,x,n,!1))}}const _=this._optimalBreaks(this._buildBreak(g,f,p,x,0,!0));let m=0;const b=t?-s:s;let w=0;for(let e=0;e<_.length;e++){const t=_[e];let r=w;for(;r<t&&c(u[r].codePoint);)u[r].glyphMosaicItem=null,++r;let n=t-1;for(;n>r&&c(u[n].codePoint);)u[n].glyphMosaicItem=null,--n;if(r<=n){const e=u[r].x;for(let t=r;t<=n;t++)u[t].x-=e,u[t].y=d;let t=u[n].x;u[n].glyphMosaicItem&&(t+=u[n].glyphMosaicItem.metrics.advance),m=Math.max(t,m),i&&this._applyJustification(u,r,n)}w=t,d+=b}if(u.length>0){const e=_.length-1,r=(i-this._hAnchor)*m;let n=(-this._vAnchor*(e+1)+.5)*s;t&&e&&(n+=e*s);for(const e of u)e.x+=r,e.y+=n}return u.filter(e=>e.glyphMosaicItem)}static getTextBox(e,t){if(!e.length)return null;let r=1/0,n=1/0,s=0,i=0;for(const a of e){const e=a.glyphMosaicItem.metrics.advance,o=a.x,l=a.y-17,h=o+e,c=l+t;r=Math.min(r,o),s=Math.max(s,h),n=Math.min(n,l),i=Math.max(i,c)}return{x:r,y:n,width:s-r,height:i-n}}static getBox(e){if(!e.length)return null;let t=1/0,r=1/0,n=0,s=0;for(const i of e){const{height:e,left:a,top:o,width:l}=i.glyphMosaicItem.metrics,h=i.x,c=i.y-(e-Math.abs(o)),u=h+l+a,f=c+e;t=Math.min(t,h),n=Math.max(n,u),r=Math.min(r,c),s=Math.max(s,f)}return{x:t,y:r,width:n-t,height:s-r}}static addDecoration(e,t){const r=e.length;if(0===r)return;let n=e[0].x+e[0].glyphMosaicItem.metrics.left,s=e[0].y;for(let i=1;i<r;i++){const r=e[i];if(r.y!==s){const a=e[i-1].x+e[i-1].glyphMosaicItem.metrics.left+e[i-1].glyphMosaicItem.metrics.width;e.push({codePoint:0,x:n,y:s+t-3,vertical:!1,glyphMosaicItem:{sdf:!0,rect:new u.A(4,0,4,8),metrics:{width:a-n,height:8,left:0,top:0,advance:0},page:0,code:0}}),s=r.y,n=r.x+r.glyphMosaicItem.metrics.left}}const i=e[r-1].x+e[r-1].glyphMosaicItem.metrics.left+e[r-1].glyphMosaicItem.metrics.width;e.push({codePoint:0,x:n,y:s+t-3,vertical:!1,glyphMosaicItem:{sdf:!0,rect:new u.A(4,0,4,8),metrics:{width:i-n,height:8,left:0,top:0,advance:0},page:0,code:0}})}_breakScore(e,t,r,n){const s=(e-t)*(e-t);return n?e<t?s/2:2*s:s+Math.abs(r)*r}_buildBreak(e,t,r,n,s,i){let a=null,o=this._breakScore(t,r,s,i);for(const e of n){const n=t-e.x,l=this._breakScore(n,r,s,i)+e.score;l<=o&&(a=e,o=l)}return{index:e,x:t,score:o,previousBreak:a}}_optimalBreaks(e){return e?this._optimalBreaks(e.previousBreak).concat(e.index):[]}_applyJustification(e,t,r){const n=e[r],s=n.vertical?f:n.glyphMosaicItem?n.glyphMosaicItem.metrics.advance:0,i=(n.x+s)*this._justify;for(let n=t;n<=r;n++)e[n].x-=i}}const p=.5;class y{constructor(e,t,r=0,n=-1,s=p){this.x=e,this.y=t,this.angle=r,this.segment=n,this.minzoom=s}}class x{constructor(e,t,r,n,s,i=p,o=a.MG){this.anchor=e,this.labelAngle=t,this.glyphAngle=r,this.page=n,this.alternateVerticalGlyph=s,this.minzoom=i,this.maxzoom=o}}class g{constructor(e,t,r,n,s,i,a,o,l,h,c,u){this.tl=e,this.tr=t,this.bl=r,this.br=n,this.mosaicRect=s,this.labelAngle=i,this.minAngle=a,this.maxAngle=o,this.anchor=l,this.minzoom=h,this.maxzoom=c,this.page=u}}class _{constructor(e){this.shapes=e}}class m{getIconPlacement(e,t,r){const n=new s.bR(e.x,e.y),i=0===r.rotationAlignment,o=r.keepUpright;let l=r.rotate*a.os;i&&(l+=e.angle);const h=new _([]);return h.iconColliders=[],this._addIconPlacement(h,n,t,r,l),i&&o&&this._addIconPlacement(h,n,t,r,l+a.Jo),h}_addIconPlacement(e,t,r,n,i){const o=r.rasterizationScale,l=r.width/o,h=r.height/o,c=n.offset;let u=c[0],f=c[1];switch(n.anchor){case 0:u-=l/2,f-=h/2;break;case 1:f-=h/2;break;case 2:u-=l,f-=h/2;break;case 3:u-=l/2;break;case 4:u-=l/2,f-=h;break;case 5:break;case 7:f-=h;break;case 6:u-=l;break;case 8:u-=l,f-=h}const d=r.rect,y=2/o,x=u-y,_=f-y,m=x+d.width/o,b=_+d.height/o,w=new s.bR(x,_),M=new s.bR(m,b),I=new s.bR(x,b),v=new s.bR(m,_);if(0!==i){const e=Math.cos(i),t=Math.sin(i);w.rotate(e,t),M.rotate(e,t),I.rotate(e,t),v.rotate(e,t)}const k=new g(w,v,I,M,d,i,0,256,t,p,a.MG,0);e.shapes.push(k);{const r=n.size,s=n.padding,o={xTile:t.x,yTile:t.y,dxPixels:u*r-s,dyPixels:f*r-s,hard:!n.optional,partIndex:0,width:l*r+2*s,height:h*r+2*s,angle:i,minLod:p,maxLod:a.MG};e.iconColliders.push(o)}}getTextPlacement(e,t,r,n){const o=new s.bR(e.x,e.y),{keepUpright:l,rotate:h,rotationAlignment:c,size:u}=n,y=h*a.os,m=0===c,b=l,w=n.padding;let M=p;const I=m?e.angle:0,v=e.segment>=0&&m,k=[],P=[],V=!v;let A=Number.POSITIVE_INFINITY,B=Number.NEGATIVE_INFINITY,D=A,S=B;const L=(v||m)&&b,R=u/f;let C=!1;for(const e of t)if(e.vertical){C=!0;break}let T,z=0,U=0;if(!v&&C){const e=d.getTextBox(t,n.lineHeight*f);switch(n.anchor){case 1:z=e.height/2,U=-e.width/2;break;case 2:z=-e.height/2,U=e.width/2;break;case 3:z=e.height/2,U=e.width/2;break;case 4:z=-e.height/2,U=-e.width/2;break;case 5:z=e.height;break;case 7:U=-e.width;break;case 6:U=e.width;break;case 8:z=-e.height}}z+=n.offset[0]*f,U+=n.offset[1]*f;for(const l of t){const t=l.glyphMosaicItem;if(!t||t.rect.isEmpty)continue;const h=t.rect,c=t.metrics,u=t.page;if(k&&V){if(void 0!==T&&T!==l.y){let t,r,s,i;C?(t=-S+z,r=A+U,s=S-D,i=B-A):(t=A+z,r=D+U,s=B-A,i=S-D);const o={xTile:e.x,yTile:e.y,dxPixels:t*R-w,dyPixels:r*R-w,hard:!n.optional,partIndex:1,width:s*R+2*w,height:i*R+2*w,angle:y,minLod:p,maxLod:a.MG};k.push(o),A=Number.POSITIVE_INFINITY,B=Number.NEGATIVE_INFINITY,D=A,S=B}T=l.y}const f=[];if(v){const n=.5*t.metrics.width,s=(l.x+c.left-4+n)*R*i.ih;if(M=this._placeGlyph(e,M,s,r,e.segment,1,l.vertical,u,f),b&&(M=this._placeGlyph(e,M,s,r,e.segment,-1,l.vertical,u,f)),M>=2)break}else f.push(new x(o,I,I,u,!1)),m&&b&&f.push(new x(o,I+a.Jo,I+a.Jo,u,!1));const d=l.x+c.left,_=l.y-17-c.top,F=d+c.width,N=_+c.height;let E,O,G,Z,j,W,q,K;if(!v&&C)if(l.vertical){const e=(d+F)/2-c.height/2,t=(_+N)/2+c.width/2;E=new s.bR(-t-4+z,e-4+U),O=new s.bR(E.x+h.width,E.y+h.height),G=new s.bR(E.x,O.y),Z=new s.bR(O.x,E.y)}else E=new s.bR(4-_+z,d-4+U),O=new s.bR(E.x-h.height,E.y+h.width),G=new s.bR(O.x,E.y),Z=new s.bR(E.x,O.y);else E=new s.bR(d-4+z,_-4+U),O=new s.bR(E.x+h.width,E.y+h.height),G=new s.bR(E.x,O.y),Z=new s.bR(O.x,E.y);for(const t of f){let r,i,a,o;if(t.alternateVerticalGlyph){if(!j){const e=(_+N)/2+U;j=new s.bR((d+F)/2+z-c.height/2-4,e+c.width/2+4),W=new s.bR(j.x+h.height,j.y-h.width),q=new s.bR(W.x,j.y),K=new s.bR(j.x,W.y)}r=j,i=q,a=K,o=W}else r=E,i=G,a=Z,o=O;const u=_,f=N,p=t.glyphAngle+y;if(0!==p){const e=Math.cos(p),t=Math.sin(p);r=r.clone(),i=i?.clone(),a=a?.clone(),o=o?.clone(),r.rotate(e,t),o?.rotate(e,t),i?.rotate(e,t),a?.rotate(e,t)}let x=0,m=256;if(v&&C?l.vertical?t.alternateVerticalGlyph?(x=32,m=96):(x=224,m=32):(x=224,m=96):(x=192,m=64),P.push(new g(r,a,i,o,h,t.labelAngle,x,m,t.anchor,t.minzoom,t.maxzoom,t.page)),k&&(!L||this._legible(t.labelAngle)))if(V)d<A&&(A=d),u<D&&(D=u),F>B&&(B=F),f>S&&(S=f);else if(t.minzoom<2){const r={xTile:e.x,yTile:e.y,dxPixels:(d+z)*R-w,dyPixels:(u+z)*R-w,hard:!n.optional,partIndex:1,width:(F-d)*R+2*w,height:(f-u)*R+2*w,angle:p,minLod:t.minzoom,maxLod:t.maxzoom};k.push(r)}}}if(M>=2)return null;if(k&&V){let t,r,s,i;C?(t=-S+z,r=A+U,s=S-D,i=B-A):(t=A+z,r=D+U,s=B-A,i=S-D);const o={xTile:e.x,yTile:e.y,dxPixels:t*R-w,dyPixels:r*R-w,hard:!n.optional,partIndex:1,width:s*R+2*w,height:i*R+2*w,angle:y,minLod:p,maxLod:a.MG};k.push(o)}const F=new _(P);return k&&k.length>0&&(F.textColliders=k),F}_legible(e){const t=(0,a.z0)(e);return t<65||t>=193}_placeGlyph(e,t,r,n,i,o,l,h,c){let u=o;const f=u<0?(0,a.Wh)(e.angle+a.Jo,a.pJ):e.angle;let d=0;r<0&&(u*=-1,r*=-1,d=a.Jo),u>0&&++i;let p=new s.bR(e.x,e.y),y=n[i],g=a.MG;if(n.length<=i)return g;for(;;){const e=y.x-p.x,s=y.y-p.y,o=Math.sqrt(e*e+s*s),_=Math.max(r/o,t),m=e/o,b=s/o,w=(0,a.Wh)(Math.atan2(b,m)+d,a.pJ);if(c.push(new x(p,f,w,h,!1,_,g)),l&&c.push(new x(p,f,w,h,!0,_,g)),_<=t)return _;p=y.clone();do{if(i+=u,n.length<=i||i<0)return _;y=n[i]}while(p.isEqual(y));let M=y.x-p.x,I=y.y-p.y;const v=Math.sqrt(M*M+I*I);M*=o/v,I*=o/v,p.x-=M,p.y-=I,g=_}}}var b=r(51624),w=r(15585);class M{constructor(e,t,r=0){this.values={},this._geometry=void 0,this._pbfGeometry=null,this.featureIndex=r;const n=t.keys,s=t.values,i=e.asUnsafe();for(;i.next();)switch(i.tag()){case 1:this.id=i.getUInt64();break;case 2:{const e=i.getMessage().asUnsafe(),t=this.values;for(;!e.empty();){const r=e.getUInt32(),i=e.getUInt32();t[n[r]]=s[i]}e.release();break}case 3:this.type=i.getUInt32();break;case 4:this._pbfGeometry=i.getMessage();break;default:i.skip()}}getGeometry(e){if(void 0!==this._geometry)return this._geometry;if(!this._pbfGeometry)return null;const t=this._pbfGeometry.asUnsafe();let r,n;this._pbfGeometry=null,e?e.reset(this.type):r=[];let i,a=1,o=0,l=0,h=0;for(;!t.empty();){if(0===o){const e=t.getUInt32();a=7&e,o=e>>3}switch(o--,a){case 1:l+=t.getSInt32(),h+=t.getSInt32(),e?e.moveTo(l,h):r&&(n&&r.push(n),n=[],n.push(new s.bR(l,h)));break;case 2:l+=t.getSInt32(),h+=t.getSInt32(),e?e.lineTo(l,h):n&&n.push(new s.bR(l,h));break;case 7:e?e.close():n&&!n[0].equals(l,h)&&n.push(n[0].clone());break;default:throw t.release(),new Error("Invalid path operation")}}return e?i=e.result():r&&(n&&r.push(n),i=r),t.release(),this._geometry=i,i}}r(44208);class I{constructor(e){this._array=[],this._stride=e}get array(){return this._array}get index(){return 4*this._array.length/this._stride}get itemSize(){return this._stride}get sizeInBytes(){return 4*this._array.length}reset(){this.array.length=0}toBuffer(){return new Uint32Array(this._array).buffer}}class v extends I{constructor(){super(12)}add(e,t,r){const n=this.array;n.push(e),n.push(t),n.push(r)}}class k{constructor(e){this.extent=i._H,this.keys=[],this.values=[],this._pbfLayer=e.clone();const t=e.asUnsafe();for(;t.next();)switch(t.tag()){case 1:this.name=t.getString();break;case 3:this.keys.push(t.getString());break;case 4:this.values.push(t.processMessage(k._parseValue));break;case 5:this.extent=t.getUInt32();break;default:t.skip()}}getData(){return this._pbfLayer}static _parseValue(e){for(;e.next();)switch(e.tag()){case 1:return e.getString();case 2:return e.getFloat();case 3:return e.getDouble();case 4:return e.getInt64();case 5:return e.getUInt64();case 6:return e.getSInt64();case 7:return e.getBool();default:e.skip()}return null}}var P=r(89518);class V extends I{constructor(e){super(e)}add(e,t,r,n,s,i,a,o,l,h,c,u){const f=this.array;let d=(0,P.M9)(e,t);f.push(d);const p=31;d=(0,P.Ss)(Math.round(p*r),Math.round(p*n),Math.round(p*s),Math.round(p*i)),f.push(d),d=(0,P.Ss)(Math.round(p*a),Math.round(p*o),Math.round(p*l),Math.round(p*h)),f.push(d),d=(0,P.M9)(c,0),f.push(d),u&&f.push(...u)}}class A extends I{constructor(e){super(e)}add(e,t,r){const n=this.array;n.push((0,P.M9)(e,t)),r&&n.push(...r)}}class B extends I{constructor(e){super(e)}add(e,t,r,n,s,i,a){const o=this.array,l=this.index;let h=(0,P.M9)(e,t);return o.push(h),h=(0,P.Ss)(Math.round(15*r),Math.round(15*n),s,i),o.push(h),a&&o.push(...a),l}}class D extends I{constructor(e){super(e)}add(e,t,r,n,s,i,o,l,h,c,u,f){const d=this.array;let p=(0,P.M9)(e,t);d.push(p),p=(0,P.M9)(Math.round(8*r),Math.round(8*n)),d.push(p),p=(0,P.M9)((0,P.ws)(s/4,i/4),(0,P.ws)(l,h)),d.push(p),p=(0,P.M9)((0,P.ws)(0,(0,a.z0)(o)),(0,P.ws)(10*c,Math.min(10*u,255))),d.push(p),f&&d.push(...f)}}class S extends I{constructor(e){super(e)}add(e,t,r,n,s){const i=this.array,a=(0,P.M9)(2*e+r,2*t+n);i.push(a),s&&i.push(...s)}}class L{constructor(e,t,r){this.layerExtent=i._H,this._features=[],this.layer=e,this.zoom=t,this._spriteInfo=r,this._filter=e.getFeatureFilter()}pushFeature(e){this._filter&&!this._filter.filter(e,this.zoom)||this._features.push(e)}hasFeatures(){return this._features.length>0}getResources(e,t,r){}}class R extends L{constructor(e,t,r,n,s){super(e,t,r),this.type=4,this._circleVertexBuffer=n,this._circleIndexBuffer=s}get circleIndexStart(){return this._circleIndexStart}get circleIndexCount(){return this._circleIndexCount}processFeatures(e){const t=this._circleVertexBuffer,r=this._circleIndexBuffer;this._circleIndexStart=3*r.index,this._circleIndexCount=0;const n=this.layer,s=this.zoom;e&&e.setExtent(this.layerExtent);for(const i of this._features){const a=i.getGeometry(e);if(!a)continue;const o=n.circleMaterial.encodeAttributes(i,s,n);for(const e of a)if(e)for(const n of e){const e=t.index;t.add(n.x,n.y,0,0,o),t.add(n.x,n.y,0,1,o),t.add(n.x,n.y,1,0,o),t.add(n.x,n.y,1,1,o),r.add(e,e+1,e+2),r.add(e+1,e+2,e+3),this._circleIndexCount+=6}}}serialize(){let e=6;e+=this.layerUIDs.length,e+=this._circleVertexBuffer.array.length,e+=this._circleIndexBuffer.array.length;const t=new Uint32Array(e),r=new Int32Array(t.buffer);let n=0;t[n++]=this.type,t[n++]=this.layerUIDs.length;for(let e=0;e<this.layerUIDs.length;e++)t[n++]=this.layerUIDs[e];t[n++]=this._circleIndexStart,t[n++]=this._circleIndexCount,t[n++]=this._circleVertexBuffer.array.length;for(let e=0;e<this._circleVertexBuffer.array.length;e++)r[n++]=this._circleVertexBuffer.array[e];t[n++]=this._circleIndexBuffer.array.length;for(let e=0;e<this._circleIndexBuffer.array.length;e++)t[n++]=this._circleIndexBuffer.array[e];return t.buffer}}var C=r(98291),T=r(83349);class z extends L{constructor(e,t,r,n,s,i,a){super(e,t,r),this.type=1,this._patternMap=new Map,this._fillVertexBuffer=n,this._fillIndexBuffer=s,this._outlineVertexBuffer=i,this._outlineIndexBuffer=a}get fillIndexStart(){return this._fillIndexStart}get fillIndexCount(){return this._fillIndexCount}get outlineIndexStart(){return this._outlineIndexStart}get outlineIndexCount(){return this._outlineIndexCount}getResources(e,t,r){const n=this.layer,s=this.zoom,i=n.getPaintProperty("fill-pattern");if(i)if(i.isDataDriven)for(const e of this._features)t(i.getValue(s,e),!0);else t(i.getValue(s),!0)}processFeatures(e){this._fillIndexStart=3*this._fillIndexBuffer.index,this._fillIndexCount=0,this._outlineIndexStart=3*this._outlineIndexBuffer.index,this._outlineIndexCount=0;const t=this.layer,r=this.zoom,{fillMaterial:n,outlineMaterial:s,hasDataDrivenFill:i,hasDataDrivenOutline:a}=t;e&&e.setExtent(this.layerExtent);const o=t.getPaintProperty("fill-pattern"),l=o?.isDataDriven;let h=!o&&t.getPaintValue("fill-antialias",r);if(t.outlineUsesFillColor){if(h&&!t.hasDataDrivenOpacity){const e=t.getPaintValue("fill-opacity",r),n=t.getPaintValue("fill-opacity",r+1);e<1&&n<1&&(h=!1)}if(h&&!t.hasDataDrivenColor){const e=t.getPaintValue("fill-color",r),n=t.getPaintValue("fill-color",r+1);e[3]<1&&n[3]<1&&(h=!1)}}const c=this._features,u=e?.validateTessellation;if(l){const i=[];for(const l of c){const c=o.getValue(r,l),u=this._spriteInfo[c];if(!u?.rect)continue;const f=n.encodeAttributes(l,r,t,u),d=h&&a?s.encodeAttributes(l,r,t):[],p=l.getGeometry(e);i.push({ddFillAttributes:f,ddOutlineAttributes:d,page:u.page,geometry:p}),i.sort((e,t)=>e.page-t.page)}for(const{ddFillAttributes:e,ddOutlineAttributes:r,page:n,geometry:s}of i)this._processFeature(s,h,t.outlineUsesFillColor,e,r,u,n)}else for(const o of c){const l=i?n.encodeAttributes(o,r,t):null,c=h&&a?s.encodeAttributes(o,r,t):null,f=o.getGeometry(e);this._processFeature(f,h,t.outlineUsesFillColor,l,c,u)}}serialize(){let e=10;e+=this.layerUIDs.length,e+=this._fillVertexBuffer.array.length,e+=this._fillIndexBuffer.array.length,e+=this._outlineVertexBuffer.array.length,e+=this._outlineIndexBuffer.array.length,e+=3*this._patternMap.size+1;const t=new Uint32Array(e),r=new Int32Array(t.buffer);let n=0;t[n++]=this.type,t[n++]=this.layerUIDs.length;for(let e=0;e<this.layerUIDs.length;e++)t[n++]=this.layerUIDs[e];t[n++]=this._fillIndexStart,t[n++]=this._fillIndexCount,t[n++]=this._outlineIndexStart,t[n++]=this._outlineIndexCount;const s=this._patternMap,i=s.size;if(t[n++]=i,i>0)for(const[e,[r,i]]of s)t[n++]=e,t[n++]=r,t[n++]=i;t[n++]=this._fillVertexBuffer.array.length;for(let e=0;e<this._fillVertexBuffer.array.length;e++)r[n++]=this._fillVertexBuffer.array[e];t[n++]=this._fillIndexBuffer.array.length;for(let e=0;e<this._fillIndexBuffer.array.length;e++)t[n++]=this._fillIndexBuffer.array[e];t[n++]=this._outlineVertexBuffer.array.length;for(let e=0;e<this._outlineVertexBuffer.array.length;e++)r[n++]=this._outlineVertexBuffer.array[e];t[n++]=this._outlineIndexBuffer.array.length;for(let e=0;e<this._outlineIndexBuffer.array.length;e++)t[n++]=this._outlineIndexBuffer.array[e];return t.buffer}_processFeature(e,t,r,n,s,i,a){if(!e)return;const o=e.length,l=!s||0===s.length;if(t&&(!r||l))for(let t=0;t<o;t++)this._processOutline(e[t],s);let h;for(let t=0;t<o;t++){const r=z._area(e[t]);r>32?(void 0!==h&&this._processFill(e,h,n,i,a),h=[t]):r<-32&&void 0!==h&&h.push(t)}void 0!==h&&this._processFill(e,h,n,i,a)}_processOutline(e,t){const r=this._outlineVertexBuffer,n=this._outlineIndexBuffer,i=n.index;let a,o,l;const h=new s.bR(0,0),c=new s.bR(0,0),u=new s.bR(0,0);let f=-1,d=-1,p=-1,y=-1,x=-1,g=!1,_=e.length;if(_<2)return;const m=e[0];let b=e[_-1];for(;_&&b.isEqual(m);)--_,b=e[_-1];if(!(_-0<2)){for(let s=0;s<_;++s){0===s?(a=e[_-1],o=e[0],l=e[1],h.assignSub(o,a),h.normalize(),h.rightPerpendicular()):(a=o,o=l,l=s!==_-1?e[s+1]:e[0],h.assign(c));const i=this._isClipEdge(a,o);-1===y&&(g=i),c.assignSub(l,o),c.normalize(),c.rightPerpendicular();const m=h.x*c.y-h.y*c.x;u.assignAdd(h,c),u.normalize();const b=-u.x*-h.x+-u.y*-h.y;let w=Math.abs(0!==b?1/b:1);w>8&&(w=8),m>=0?(p=r.add(o.x,o.y,h.x,h.y,0,1,t),-1===y&&(y=p),f>=0&&d>=0&&p>=0&&!i&&n.add(f,d,p),d=r.add(o.x,o.y,w*-u.x,w*-u.y,0,-1,t),-1===x&&(x=d),f>=0&&d>=0&&p>=0&&!i&&n.add(f,d,p),f=d,d=p,p=r.add(o.x,o.y,u.x,u.y,0,1,t),f>=0&&d>=0&&p>=0&&!i&&n.add(f,d,p),d=r.add(o.x,o.y,c.x,c.y,0,1,t),f>=0&&d>=0&&p>=0&&!i&&n.add(f,d,p)):(p=r.add(o.x,o.y,w*u.x,w*u.y,0,1,t),-1===y&&(y=p),f>=0&&d>=0&&p>=0&&!i&&n.add(f,d,p),d=r.add(o.x,o.y,-h.x,-h.y,0,-1,t),-1===x&&(x=d),f>=0&&d>=0&&p>=0&&!i&&n.add(f,d,p),f=d,d=p,p=r.add(o.x,o.y,-u.x,-u.y,0,-1,t),f>=0&&d>=0&&p>=0&&!i&&n.add(f,d,p),f=r.add(o.x,o.y,-c.x,-c.y,0,-1,t),f>=0&&d>=0&&p>=0&&!i&&n.add(f,d,p))}f>=0&&d>=0&&y>=0&&!g&&n.add(f,d,y),f>=0&&y>=0&&x>=0&&!g&&n.add(f,x,y),this._outlineIndexCount+=3*(n.index-i)}}_processFill(e,t,r,n,s){let i;t.length>1&&(i=[]);let a=0;for(const r of t)0!==a&&i.push(a),a+=e[r].length;const o=2*a,l=C.A.acquire();for(const r of t){const t=e[r],n=t.length;for(let e=0;e<n;++e)l.push(t[e].x,t[e].y)}const h=(0,T.e)(l,i,2);if(T.e.deviation(l,i,2,h)>0){const n=t.map(t=>e[t].length),{buffer:i,vertexCount:a}=(0,w.QT)(l,n);if(a>0){const e=this._fillVertexBuffer.index;for(let e=0;e<a;e++)this._fillVertexBuffer.add(i[2*e],i[2*e+1],r);for(let t=0;t<a;t+=3){const r=e+t;this._fillIndexBuffer.add(r,r+1,r+2)}if(void 0!==s){const e=this._patternMap,t=e.get(s);t?t[1]+=a:e.set(s,[this._fillIndexStart+this._fillIndexCount,a])}this._fillIndexCount+=a}}else{const e=h.length;if(e>0){const t=this._fillVertexBuffer.index;let n=0;for(;n<o;)this._fillVertexBuffer.add(l[n++],l[n++],r);let i=0;for(;i<e;)this._fillIndexBuffer.add(t+h[i++],t+h[i++],t+h[i++]);if(void 0!==s){const t=this._patternMap,r=t.get(s);r?r[1]+=e:t.set(s,[this._fillIndexStart+this._fillIndexCount,e])}this._fillIndexCount+=e}}C.A.release(l)}_isClipEdge(e,t){return e.x===t.x?e.x<=-64||e.x>=4160:e.y===t.y&&(e.y<=-64||e.y>=4160)}static _area(e){let t=0;const r=e.length-1;for(let n=0;n<r;n++)t+=(e[n].x-e[n+1].x)*(e[n].y+e[n+1].y);return t+=(e[r].x-e[0].x)*(e[r].y+e[0].y),.5*t}}var U=r(83773);class F extends L{constructor(e,t,r,n,s){super(e,t,r),this.type=2,this._tessellationOptions={pixelCoordRatio:8,halfWidth:0,offset:0},this._patternMap=new Map,this.tessellationProperties={_lineVertexBuffer:null,_lineIndexBuffer:null,_ddValues:null},this.tessellationProperties._lineVertexBuffer=n,this.tessellationProperties._lineIndexBuffer=s,this._lineTessellator=new U.i(N(this.tessellationProperties),E(this.tessellationProperties),e.canUseThinTessellation)}get lineIndexStart(){return this._lineIndexStart}get lineIndexCount(){return this._lineIndexCount}getResources(e,t,r){const n=this.layer,s=this.zoom,i=n.getPaintProperty("line-pattern"),a=n.getPaintProperty("line-dasharray"),o=n.getLayoutProperty("line-cap");if(!i&&!a)return;const l=o?.getValue(s)||0,h=o?.isDataDriven,c=i?.isDataDriven,u=a?.isDataDriven;if(c||u)for(const e of this._features)t(c?i.getValue(s,e):this._getDashArrayKey(e,s,n,a,h,o,l));else if(i)t(i.getValue(s));else if(a){const e=a.getValue(s);t(n.getDashKey(e,l))}}processFeatures(e){this._lineIndexStart=3*this.tessellationProperties._lineIndexBuffer.index,this._lineIndexCount=0;const t=this.layer,r=this.zoom,n=this._features,s=this._tessellationOptions,{hasDataDrivenLine:i,lineMaterial:a}=t;e&&e.setExtent(this.layerExtent);const o=t.getPaintProperty("line-pattern"),l=t.getPaintProperty("line-dasharray"),h=o?.isDataDriven,c=l?.isDataDriven;let u;u=t.getLayoutProperty("line-cap");const f=u?.isDataDriven?u:null,d=f?null:t.getLayoutValue("line-cap",r),p=d||0,y=!!f;u=t.getLayoutProperty("line-join");const x=u?.isDataDriven?u:null,g=x?null:t.getLayoutValue("line-join",r);u=t.getLayoutProperty("line-miter-limit");const _=u?.isDataDriven?u:null,m=_?null:t.getLayoutValue("line-miter-limit",r);u=t.getLayoutProperty("line-round-limit");const b=u?.isDataDriven?u:null,w=b?null:t.getLayoutValue("line-round-limit",r);u=t.getPaintProperty("line-width");const M=u?.isDataDriven?u:null,I=M?null:t.getPaintValue("line-width",r);u=t.getPaintProperty("line-offset");const v=u?.isDataDriven?u:null,k=v?null:t.getPaintValue("line-offset",r);if(h||c){const i=[];for(const s of n){const n=h?o.getValue(r,s):this._getDashArrayKey(s,r,t,l,y,f,p),c=this._spriteInfo[n];if(!c?.rect)continue;const u=a.encodeAttributes(s,r,t,c),P=s.getGeometry(e);i.push({ddAttributes:u,page:c.page,cap:f?f.getValue(r,s):d,join:x?x.getValue(r,s):g,miterLimit:_?_.getValue(r,s):m,roundLimit:b?b.getValue(r,s):w,halfWidth:.5*(M?M.getValue(r,s):I),offset:v?v.getValue(r,s):k,geometry:P})}i.sort((e,t)=>e.page-t.page),s.textured=!0;for(const{ddAttributes:e,page:t,cap:r,join:n,miterLimit:a,roundLimit:o,halfWidth:l,offset:h,geometry:c}of i)s.capType=r,s.joinType=n,s.miterLimit=a,s.roundLimit=o,s.halfWidth=l,s.offset=h,this._processFeature(c,e,t)}else{if(o){const e=o.getValue(r),t=this._spriteInfo[e];if(!t?.rect)return}s.textured=!(!o&&!l),s.capType=d,s.joinType=g,s.miterLimit=m,s.roundLimit=w,s.halfWidth=.5*I,s.offset=k;for(const o of n){const n=i?a.encodeAttributes(o,r,t):null;f&&(s.capType=f.getValue(r,o)),x&&(s.joinType=x.getValue(r,o)),_&&(s.miterLimit=_.getValue(r,o)),b&&(s.roundLimit=b.getValue(r,o)),M&&(s.halfWidth=.5*M.getValue(r,o)),v&&(s.offset=v.getValue(r,o));const l=o.getGeometry(e);this._processFeature(l,n)}}}serialize(){let e=6;e+=this.layerUIDs.length,e+=this.tessellationProperties._lineVertexBuffer.array.length,e+=this.tessellationProperties._lineIndexBuffer.array.length,e+=3*this._patternMap.size+1;const t=new Uint32Array(e),r=new Int32Array(t.buffer);let n=0;t[n++]=this.type,t[n++]=this.layerUIDs.length;for(let e=0;e<this.layerUIDs.length;e++)t[n++]=this.layerUIDs[e];t[n++]=this._lineIndexStart,t[n++]=this._lineIndexCount;const s=this._patternMap,i=s.size;if(t[n++]=i,i>0)for(const[e,[r,i]]of s)t[n++]=e,t[n++]=r,t[n++]=i;t[n++]=this.tessellationProperties._lineVertexBuffer.array.length;for(let e=0;e<this.tessellationProperties._lineVertexBuffer.array.length;e++)r[n++]=this.tessellationProperties._lineVertexBuffer.array[e];t[n++]=this.tessellationProperties._lineIndexBuffer.array.length;for(let e=0;e<this.tessellationProperties._lineIndexBuffer.array.length;e++)t[n++]=this.tessellationProperties._lineIndexBuffer.array[e];return t.buffer}_processFeature(e,t,r){if(!e)return;const n=e.length;for(let s=0;s<n;s++)this._processGeometry(e[s],t,r)}_processGeometry(e,t,r){if(e.length<2)return;let n,s,i=e[0],a=1;for(;a<e.length;)n=e[a].x-i.x,s=e[a].y-i.y,n*n+s*s<1e-6?e.splice(a,1):(i=e[a],++a);if(e.length<2)return;const o=this.tessellationProperties._lineIndexBuffer,l=3*o.index;this._tessellationOptions.initialDistance=0,this._tessellationOptions.wrapDistance=65535,this.tessellationProperties._ddValues=t,this._lineTessellator.tessellate(e,this._tessellationOptions);const h=3*o.index-l;if(void 0!==r){const e=this._patternMap,t=e.get(r);t?t[1]+=h:e.set(r,[l+this._lineIndexCount,h])}this._lineIndexCount+=h}_getDashArrayKey(e,t,r,n,s,i,a){const o=s?i.getValue(t,e):a,l=n.getValue(t,e);return r.getDashKey(l,o)}}const N=e=>(t,r,n,s,i,a,o,l,h,c,u)=>(e._lineVertexBuffer.add(t,r,o,l,n,s,i,a,h,c,u,e._ddValues),e._lineVertexBuffer.index-1),E=e=>(t,r,n)=>{e._lineIndexBuffer.add(t,r,n)};var O=r(32488),G=r(97768),Z=r(799),j=r(4264);function W(e,t){return e.iconMosaicItem&&t.iconMosaicItem?e.iconMosaicItem.page===t.iconMosaicItem.page?0:e.iconMosaicItem.page-t.iconMosaicItem.page:e.iconMosaicItem&&!t.iconMosaicItem?1:!e.iconMosaicItem&&t.iconMosaicItem?-1:0}class q extends L{constructor(e,t,r,n,s,i,a,o,l){super(t,r,l.getSpriteItems()),this.type=3,this._markerMap=new Map,this._glyphMap=new Map,this._glyphBufferDataStorage=new Map,this._isIconSDF=!1,this._sourceTileKey=e,this._iconVertexBuffer=n,this._iconIndexBuffer=s,this._textVertexBuffer=i,this._textIndexBuffer=a,this._placementEngine=o,this._workerTileHandler=l}get markerPageMap(){return this._markerMap}get glyphsPageMap(){return this._glyphMap}get symbolInstances(){return this._symbolInstances}static{this._bidiEngine=new O.A}getResources(e,t,r){const n=this.layer,s=this.zoom;e&&e.setExtent(this.layerExtent);const i=n.getLayoutProperty("icon-image"),a=n.getLayoutProperty("text-field");let o=n.getLayoutProperty("text-transform"),l=n.getLayoutProperty("text-font");const h=[];let c,u,f,d;i&&!i.isDataDriven&&(c=i.getValue(s)),a&&!a.isDataDriven&&(u=a.getValue(s)),o&&o.isDataDriven||(f=n.getLayoutValue("text-transform",s),o=null),l&&l.isDataDriven||(d=n.getLayoutValue("text-font",s),l=null);for(const p of this._features){const y=p.getGeometry(e);if(!y||0===y.length)continue;let x,g;i&&(x=i.isDataDriven?i.getValue(s,p):this._replaceKeys(c,p.values),x&&t(x));let _=!1;if(a&&(g=a.isDataDriven?a.getValue(s,p):this._replaceKeys(u,p.values),g)){switch(g=g.replaceAll("\\n","\n"),o&&(f=o.getValue(s,p)),f){case 2:g=g.toLowerCase();break;case 1:g=g.toUpperCase()}if(q._bidiEngine.hasBidiChar(g)){let e;e="rtl"===q._bidiEngine.checkContextual(g)?"IDNNN":"ICNNN",g=q._bidiEngine.bidiTransform(g,e,"VLYSN"),_=!0}if(g.length>0){l&&(d=l.getValue(s,p));for(const e of d){let t=r[e];t||(t=r[e]=new Set);for(const e of g){const r=e.codePointAt(0);null!=r&&t.add(r)}}}}if(!x&&!g)continue;const m=n.getLayoutValue("symbol-sort-key",s,p),b={feature:p,sprite:x,label:g,rtl:_,geometry:y,hash:(g?(0,Z.Wm)(g):0)^(x?(0,Z.Wm)(x):0),priority:m,textFont:d};h.push(b)}this._symbolFeatures=h}processFeatures(e){e&&e.setExtent(this.layerExtent);const t=this.layer,r=this.zoom,n=t.getLayoutValue("symbol-placement",r),s=0!==n,o=t.getLayoutValue("symbol-spacing",r)*i.ih,l=t.getLayoutProperty("icon-image"),h=t.getLayoutProperty("text-field"),c=l?new j.aR(t,r,s):null,u=h?new j.uU(t,r,s):null,p=this._workerTileHandler;let x;l&&(x=p.getSpriteItems()),this._iconIndexStart=3*this._iconIndexBuffer.index,this._textIndexStart=3*this._textIndexBuffer.index,this._iconIndexCount=0,this._textIndexCount=0,this._markerMap.clear(),this._glyphMap.clear();const g=[];let _=1;u?.size&&(_=u.size/f);const m=u?u.maxAngle*a.os:0,b=u?u.size*i.ih:0;for(const e of this._symbolFeatures){let t,a;c&&x&&e.sprite&&(t=x[e.sprite],t&&t.sdf&&(this._isIconSDF=!0)),t&&c.update(r,e.feature);let l=0;const h=e.label;if(h){(0,G.Lw)(u),u.update(r,e.feature);const t=s&&0===u.rotationAlignment?u.keepUpright:u.writingMode&&u.writingMode.includes(1);let n=.5;switch(u.anchor){case 5:case 1:case 7:n=0;break;case 6:case 2:case 8:n=1}let o=.5;switch(u.anchor){case 5:case 3:case 6:o=0;break;case 7:case 4:case 8:o=1}let c=.5;switch(u.justify){case 0:c=n;break;case 1:c=0;break;case 3:c=1}const y=u.letterSpacing*f,x=s?0:u.maxWidth*f,g=u.lineHeight*f,m=e.textFont.map(e=>p.getGlyphItems(e));if(a=new d(m,x,g,y,n,o,c).getShaping(h,e.rtl,t),a&&a.length>0){let e=1e30,t=-1e30;for(const r of a)e=Math.min(e,r.x),t=Math.max(t,r.x);l=(t-e+48)*_*i.ih}}for(let r of e.geometry){const h=[];if(1===n){if(a?.length&&u?.size){const e=u.size*i.ih*(2+Math.min(2,4*Math.abs(u.offset[1])));r=q._smoothVertices(r,e)}q._pushAnchors(h,r,o,l)}else 2===n?q._pushCenterAnchor(h,r):3===e.feature.type?q._pushCentroid(h,r):h.push(new y(r[0].x,r[0].y));for(const n of h){if(n.x<0||n.x>i._H||n.y<0||n.y>i._H)continue;if(s&&l>0&&0===u?.rotationAlignment&&!q._honorsTextMaxAngle(r,n,l,m,b))continue;const o={shaping:a,line:r,iconMosaicItem:t,anchor:n,symbolFeature:e,textColliders:[],iconColliders:[],textVertexRanges:[],iconVertexRanges:[]};g.push(o),this._processFeature(o,c,u)}}}g.sort(W),this._addPlacedGlyphs(),this._symbolInstances=g}serialize(){let e=14;e+=this.layerUIDs.length,e+=3*this.markerPageMap.size,e+=3*this.glyphsPageMap.size,e+=q._symbolsSerializationLength(this._symbolInstances),e+=this._iconVertexBuffer.array.length,e+=this._iconIndexBuffer.array.length,e+=this._textVertexBuffer.array.length,e+=this._textIndexBuffer.array.length;const t=new Uint32Array(e),r=new Int32Array(t.buffer),n=new Float32Array(t.buffer),[s,i,a]=this._sourceTileKey.split("/");let o=0;t[o++]=this.type,t[o++]=this.layerUIDs.length;for(let e=0;e<this.layerUIDs.length;e++)t[o++]=this.layerUIDs[e];t[o++]=this._isIconSDF?1:0,t[o++]=parseFloat(s),t[o++]=parseFloat(i),t[o++]=parseFloat(a),t[o++]=this.markerPageMap.size;for(const[e,[r,n]]of this.markerPageMap)t[o++]=e,t[o++]=r,t[o++]=n;t[o++]=this.glyphsPageMap.size;for(const[e,[r,n]]of this.glyphsPageMap)t[o++]=e,t[o++]=r,t[o++]=n;t[o++]=this._iconVertexBuffer.index/4,t[o++]=this._textVertexBuffer.index/4,o=q.serializeSymbols(t,r,n,o,this._symbolInstances),t[o++]=this._iconVertexBuffer.array.length;for(let e=0;e<this._iconVertexBuffer.array.length;e++)r[o++]=this._iconVertexBuffer.array[e];t[o++]=this._iconIndexBuffer.array.length;for(let e=0;e<this._iconIndexBuffer.array.length;e++)t[o++]=this._iconIndexBuffer.array[e];t[o++]=this._textVertexBuffer.array.length;for(let e=0;e<this._textVertexBuffer.array.length;e++)r[o++]=this._textVertexBuffer.array[e];t[o++]=this._textIndexBuffer.array.length;for(let e=0;e<this._textIndexBuffer.array.length;e++)t[o++]=this._textIndexBuffer.array[e];return t.buffer}static _symbolsSerializationLength(e){let t=0;t+=1;for(const r of e||[]){t+=5,t+=1;for(const e of r.textColliders)t+=10;for(const e of r.iconColliders)t+=10;t+=1,t+=2*r.textVertexRanges.length,t+=1,t+=2*r.iconVertexRanges.length}return t}static serializeSymbols(e,t,r,n,s){s=s||[],t[n++]=s.length;for(const e of s){t[n++]=e.anchor.x,t[n++]=e.anchor.y,t[n++]=e.symbolFeature.hash,t[n++]=e.symbolFeature.priority,t[n++]=e.symbolFeature.feature.featureIndex,t[n++]=e.textColliders.length+e.iconColliders.length;for(const s of e.textColliders)t[n++]=s.xTile,t[n++]=s.yTile,t[n++]=s.dxPixels,t[n++]=s.dyPixels,t[n++]=s.hard?1:0,t[n++]=s.partIndex,r[n++]=s.minLod,r[n++]=s.maxLod,t[n++]=s.width,t[n++]=s.height;for(const s of e.iconColliders)t[n++]=s.xTile,t[n++]=s.yTile,t[n++]=s.dxPixels,t[n++]=s.dyPixels,t[n++]=s.hard?1:0,t[n++]=s.partIndex,r[n++]=s.minLod,r[n++]=s.maxLod,t[n++]=s.width,t[n++]=s.height;t[n++]=e.textVertexRanges.length;for(const[r,s]of e.textVertexRanges)t[n++]=r,t[n++]=s;t[n++]=e.iconVertexRanges.length;for(const[r,s]of e.iconVertexRanges)t[n++]=r,t[n++]=s}return n}_replaceKeys(e,t){return e.replaceAll(/{([^{}]+)}/g,(e,r)=>r in t?t[r]:"")}_processFeature(e,t,r){const{line:n,iconMosaicItem:s,shaping:i,anchor:o}=e,l=this.zoom,h=this.layer,c=!!s;let u=!0;c&&(u=t?.optional||!s);const f=i&&i.length>0,d=!f||r?.optional;let p,y;if(c&&(p=this._placementEngine.getIconPlacement(o,s,t)),(p||u)&&(f&&(y=this._placementEngine.getTextPlacement(o,i,n,r)),y||d)){if(p&&y||(d||u?d||y?u||p||(y=null):p=null:(p=null,y=null)),y){const t=h.hasDataDrivenText?h.textMaterial.encodeAttributes(e.symbolFeature.feature,l,h):null;if(this._storePlacedGlyphs(e,y.shapes,l,r.rotationAlignment,t),y.textColliders){e.textColliders=y.textColliders;for(const e of y.textColliders){e.minLod=Math.max(l+(0,a.p6)(e.minLod),0),e.maxLod=Math.min(l+(0,a.p6)(e.maxLod),25);const t=e.angle;if(t){const r=Math.cos(t),n=Math.sin(t),s=e.dxPixels*r-e.dyPixels*n,i=e.dxPixels*n+e.dyPixels*r,a=(e.dxPixels+e.width)*r-e.dyPixels*n,o=(e.dxPixels+e.width)*n+e.dyPixels*r,l=e.dxPixels*r-(e.dyPixels+e.height)*n,h=e.dxPixels*n+(e.dyPixels+e.height)*r,c=(e.dxPixels+e.width)*r-(e.dyPixels+e.height)*n,u=(e.dxPixels+e.width)*n+(e.dyPixels+e.height)*r,f=Math.min(s,a,l,c),d=Math.max(s,a,l,c),p=Math.min(i,o,h,u),y=Math.max(i,o,h,u);e.dxPixels=f,e.dyPixels=p,e.width=d-f,e.height=y-p}}}}if(p){const r=h.hasDataDrivenIcon?h.iconMaterial.encodeAttributes(e.symbolFeature.feature,l,h):null;if(this._addPlacedIcons(e,p.shapes,l,s.page,1===t.rotationAlignment,r),p.iconColliders){e.iconColliders=p.iconColliders;for(const e of p.iconColliders){e.minLod=Math.max(l+(0,a.p6)(e.minLod),0),e.maxLod=Math.min(l+(0,a.p6)(e.maxLod),25);const t=e.angle;if(t){const r=Math.cos(t),n=Math.sin(t),s=e.dxPixels*r-e.dyPixels*n,i=e.dxPixels*n+e.dyPixels*r,a=(e.dxPixels+e.width)*r-e.dyPixels*n,o=(e.dxPixels+e.width)*n+e.dyPixels*r,l=e.dxPixels*r-(e.dyPixels+e.height)*n,h=e.dxPixels*n+(e.dyPixels+e.height)*r,c=(e.dxPixels+e.width)*r-(e.dyPixels+e.height)*n,u=(e.dxPixels+e.width)*n+(e.dyPixels+e.height)*r,f=Math.min(s,a,l,c),d=Math.max(s,a,l,c),p=Math.min(i,o,h,u),y=Math.max(i,o,h,u);e.dxPixels=f,e.dyPixels=p,e.width=d-f,e.height=y-p}}}}}}_addPlacedIcons(e,t,r,n,s,i){const o=Math.max(r-1,0),l=this._iconVertexBuffer,h=this._iconIndexBuffer,c=this._markerMap;for(const u of t){const t=s?0:Math.max(r+(0,a.p6)(u.minzoom),o),f=s?25:Math.min(r+(0,a.p6)(u.maxzoom),25);if(f<=t)continue;const d=u.tl,p=u.tr,y=u.bl,x=u.br,g=u.mosaicRect,_=u.labelAngle,m=u.minAngle,b=u.maxAngle,w=u.anchor,M=l.index,I=g.x,v=g.y,k=I+g.width,P=v+g.height,V=l.index;l.add(w.x,w.y,d.x,d.y,I,v,_,m,b,t,f,i),l.add(w.x,w.y,p.x,p.y,k,v,_,m,b,t,f,i),l.add(w.x,w.y,y.x,y.y,I,P,_,m,b,t,f,i),l.add(w.x,w.y,x.x,x.y,k,P,_,m,b,t,f,i),e.iconVertexRanges.length>0&&e.iconVertexRanges[0][0]+e.iconVertexRanges[0][1]===V?e.iconVertexRanges[0][1]+=4:e.iconVertexRanges.push([V,4]),h.add(M,M+1,M+2),h.add(M+1,M+2,M+3),c.has(n)?c.get(n)[1]+=6:c.set(n,[this._iconIndexStart+this._iconIndexCount,6]),this._iconIndexCount+=6}}_addPlacedGlyphs(){const e=this._textVertexBuffer,t=this._textIndexBuffer,r=this._glyphMap;for(const[n,s]of this._glyphBufferDataStorage)for(const i of s){const s=e.index,a=i.symbolInstance,o=i.ddAttributes,l=e.index;e.add(i.glyphAnchor[0],i.glyphAnchor[1],i.tl[0],i.tl[1],i.xmin,i.ymin,i.labelAngle,i.minAngle,i.maxAngle,i.minLod,i.maxLod,o),e.add(i.glyphAnchor[0],i.glyphAnchor[1],i.tr[0],i.tr[1],i.xmax,i.ymin,i.labelAngle,i.minAngle,i.maxAngle,i.minLod,i.maxLod,o),e.add(i.glyphAnchor[0],i.glyphAnchor[1],i.bl[0],i.bl[1],i.xmin,i.ymax,i.labelAngle,i.minAngle,i.maxAngle,i.minLod,i.maxLod,o),e.add(i.glyphAnchor[0],i.glyphAnchor[1],i.br[0],i.br[1],i.xmax,i.ymax,i.labelAngle,i.minAngle,i.maxAngle,i.minLod,i.maxLod,o),a.textVertexRanges.length>0&&a.textVertexRanges[0][0]+a.textVertexRanges[0][1]===l?a.textVertexRanges[0][1]+=4:a.textVertexRanges.push([l,4]),t.add(s,s+1,s+2),t.add(s+1,s+2,s+3),r.has(n)?r.get(n)[1]+=6:r.set(n,[this._textIndexStart+this._textIndexCount,6]),this._textIndexCount+=6}this._glyphBufferDataStorage.clear()}_storePlacedGlyphs(e,t,r,n,s){const i=Math.max(r-1,0),o=1===n;let l,h,c,u,f,d,p,y,x,g,_;for(const n of t)l=o?0:Math.max(r+(0,a.p6)(n.minzoom),i),h=o?25:Math.min(r+(0,a.p6)(n.maxzoom),25),h<=l||(c=n.tl,u=n.tr,f=n.bl,d=n.br,p=n.labelAngle,y=n.minAngle,x=n.maxAngle,g=n.anchor,_=n.mosaicRect,this._glyphBufferDataStorage.has(n.page)||this._glyphBufferDataStorage.set(n.page,[]),this._glyphBufferDataStorage.get(n.page).push({glyphAnchor:[g.x,g.y],tl:[c.x,c.y],tr:[u.x,u.y],bl:[f.x,f.y],br:[d.x,d.y],xmin:_.x,ymin:_.y,xmax:_.x+_.width,ymax:_.y+_.height,labelAngle:p,minAngle:y,maxAngle:x,minLod:l,maxLod:h,placementLod:i,symbolInstance:e,ddAttributes:s}))}static _pushAnchors(e,t,r,n){r+=n;let i=0;const o=t.length-1;for(let e=0;e<o;e++)i+=s.bR.distance(t[e],t[e+1]);let l=n||r;if(l*=.5,i<=l)return;const h=l/i;let c=0,u=-(r=i/Math.max(Math.round(i/r),1))/2;const f=t.length-1;for(let n=0;n<f;n++){const s=t[n],i=t[n+1],o=i.x-s.x,l=i.y-s.y,f=Math.sqrt(o*o+l*l);let d;for(;u+r<c+f;){u+=r;const t=(u-c)/f,p=(0,a.GW)(s.x,i.x,t),x=(0,a.GW)(s.y,i.y,t);void 0===d&&(d=Math.atan2(l,o)),e.push(new y(p,x,d,n,h))}c+=f}}static _pushCenterAnchor(e,t){let r=0;const n=t.length-1;for(let e=0;e<n;e++)r+=s.bR.distance(t[e],t[e+1]);const i=r/2;let o=0;const l=t.length-1;for(let r=0;r<l;r++){const n=t[r],s=t[r+1],l=s.x-n.x,h=s.y-n.y,c=Math.sqrt(l*l+h*h);if(i<o+c){const t=(i-o)/c,u=(0,a.GW)(n.x,s.x,t),f=(0,a.GW)(n.y,s.y,t),d=Math.atan2(h,l);return void e.push(new y(u,f,d,r,0))}o+=c}}static _deviation(e,t,r){const n=(t.x-e.x)*(r.x-t.x)+(t.y-e.y)*(r.y-t.y),s=(t.x-e.x)*(r.y-t.y)-(t.y-e.y)*(r.x-t.x);return Math.atan2(s,n)}static _honorsTextMaxAngle(e,t,r,n,i){let a=0;const o=r/2;let l=new s.bR(t.x,t.y),h=t.segment+1;for(;a>-o;){if(--h,h<0)return!1;a-=s.bR.distance(e[h],l),l=e[h]}a+=s.bR.distance(e[h],e[h+1]);const c=[];let u=0;const f=e.length;for(;a<o;){const t=e[h];let r,o=h;do{if(++o,o===f)return!1;r=e[o]}while(r.isEqual(t));let l,d=o;do{if(++d,d===f)return!1;l=e[d]}while(l.isEqual(r));const p=this._deviation(t,r,l);for(c.push({deviation:p,distToAnchor:a}),u+=p;a-c[0].distToAnchor>i;)u-=c.shift().deviation;if(Math.abs(u)>n)return!1;a+=s.bR.distance(r,l),h=o}return!0}static _smoothVertices(e,t){if(t<=0)return e;let r=e.length;if(r<3)return e;const n=[];let i=0,a=0;n.push(0);for(let t=1;t<r;t++){const r=s.bR.distance(e[t],e[t-1]);r>0&&(i+=r,n.push(i),a++,a!==t&&(e[a]=e[t]))}if(r=a+1,r<3)return e;t=Math.min(t,.2*i);const o=e[0].x,l=e[0].y,h=e[r-1].x,c=e[r-1].y,u=s.bR.sub(e[0],e[1]);u.normalize(),e[0].x+=t*u.x,e[0].y+=t*u.y,u.assignSub(e[r-1],e[r-2]),u.normalize(),e[r-1].x+=t*u.x,e[r-1].y+=t*u.y,n[0]-=t,n[r-1]+=t;const f=[];f.push(new s.bR(o,l));const d=1e-6,p=.5*t;for(let i=1;i<r-1;i++){let a=0,o=0,l=0;for(let r=i-1;r>=0;r--){const s=p+n[r+1]-n[i];if(s<0)break;const h=n[r+1]-n[r],c=n[i]-n[r]<p?1:s/h;if(c<d)break;const u=c*c,f=c*s-.5*u*h,y=c*h/t,x=e[r+1],g=e[r].x-x.x,_=e[r].y-x.y;a+=y/f*(x.x*c*s+.5*u*(s*g-h*x.x)-u*c*h*g/3),o+=y/f*(x.y*c*s+.5*u*(s*_-h*x.y)-u*c*h*_/3),l+=y}for(let s=i+1;s<r;s++){const r=p-n[s-1]+n[i];if(r<0)break;const h=n[s]-n[s-1],c=n[s]-n[i]<p?1:r/h;if(c<d)break;const u=c*c,f=c*r-.5*u*h,y=c*h/t,x=e[s-1],g=e[s].x-x.x,_=e[s].y-x.y;a+=y/f*(x.x*c*r+.5*u*(r*g-h*x.x)-u*c*h*g/3),o+=y/f*(x.y*c*r+.5*u*(r*_-h*x.y)-u*c*h*_/3),l+=y}f.push(new s.bR(a/l,o/l))}return f.push(new s.bR(h,c)),e[0].x=o,e[0].y=l,e[r-1].x=h,e[r-1].y=c,f}static _pushCentroid(e,t){const r=i._H,n=i._H,s=t.length-1;let a=0,o=0,l=0,h=t[0].x,c=t[0].y;h>r&&(h=r),h<0&&(h=0),c>n&&(c=n),c<0&&(c=0);for(let e=1;e<s;e++){let s=t[e].x,i=t[e].y,u=t[e+1].x,f=t[e+1].y;s>r&&(s=r),s<0&&(s=0),i>n&&(i=n),i<0&&(i=0),u>r&&(u=r),u<0&&(u=0),f>n&&(f=n),f<0&&(f=0);const d=(s-h)*(f-c)-(u-h)*(i-c);a+=d*(h+s+u),o+=d*(c+i+f),l+=d}a/=3*l,o/=3*l,isNaN(a)||isNaN(o)||e.push(new y(a,o))}}class K{constructor(e,t,r,n,i,o){if(this._pbfTiles={},this._tileClippers={},this._client=r,this._tile=t,this._sourceDataMaxLOD=n,o){this._styleLayerUIDs=new Set;for(const e of o)this._styleLayerUIDs.add(e)}this._styleRepository=i,this._layers=this._styleRepository?.layers??[];const[l,h,c]=t.tileKey.split("/").map(parseFloat);this._level=l;const u=(0,a.IU)(this._level);for(const t of Object.keys(e)){const r=e[t];if(this._pbfTiles[t]=new b.A(new Uint8Array(r.protobuff),new DataView(r.protobuff)),r.refKey){const[e]=r.refKey.split("/").map(parseFloat),n=l-e;if(n>0){const e=(1<<n)-1,r=h&e,i=c&e;this._tileClippers[t]=new s.O3(n,r,i,8,u)}}this._tileClippers[t]||(this._tileClippers[t]=new s.Ox)}}_canParseStyleLayer(e){return!this._styleLayerUIDs||this._styleLayerUIDs.has(e)}async parse(e){const t=(0,w.If)(),r=this._initialize(e),{returnedBuckets:n}=r;this._processLayers(r),this._linkReferences(r),this._filterFeatures(r);const s=[],i=new Set,a=(e,t)=>{i.has(e)||(s.push({name:e,repeat:t}),i.add(e))},o={};for(const e of n)e.getResources(e.tileClipper,a,o);if(4===this._tile.status)return[];const l=this._fetchResources(s,o,e);return Promise.all([...l,t]).then(()=>this._processFeatures(r.returnedBuckets))}_initialize(e){const t=e?.signal;return{signal:t,sourceNameToTileData:this._parseTileData(this._pbfTiles),layers:this._layers,zoom:this._level,sourceNameToTileClipper:this._tileClippers,sourceNameToUniqueSourceLayerBuckets:{},sourceNameToUniqueSourceLayers:{},returnedBuckets:[],layerIdToBucket:{},referencerUIDToReferencedId:new Map}}_processLayers(e){const{sourceNameToTileData:t,zoom:r,layers:n,sourceNameToTileClipper:s,sourceNameToUniqueSourceLayerBuckets:i,sourceNameToUniqueSourceLayers:a,returnedBuckets:o,layerIdToBucket:l,referencerUIDToReferencedId:h}=e,c=this._sourceDataMaxLOD;for(let e=n.length-1;e>=0;e--){const u=n[e];if(r<c){if(u.minzoom&&r<Math.floor(u.minzoom)||u.maxzoom&&r>=u.maxzoom)continue}else if(u.maxzoom&&r>=u.maxzoom)continue;if(0===u.type||!this._canParseStyleLayer(u.uid)||!t[u.source]||!s[u.source])continue;const f=t[u.source],d=s[u.source],p=u.sourceLayer,y=f[p];if(y){let e=a[u.source];if(e||(e=a[u.source]=new Set),e.add(u.sourceLayer),u.refLayerId)h.set(u.uid,u.refLayerId);else{const e=this._createBucket(u);if(e){e.layerUIDs=[u.uid],e.layerExtent=y.extent,e.tileClipper=d;let t=i[u.source];t||(t=i[u.source]={});let r=t[p];r||(r=t[p]=[]),r.push(e),o.push(e),l[u.id]=e}}}}}_linkReferences(e){const{layerIdToBucket:t,referencerUIDToReferencedId:r}=e;r.forEach((e,r)=>{t[e]&&t[e].layerUIDs.push(r)})}_filterFeatures(e){const{signal:t,sourceNameToTileData:r,sourceNameToUniqueSourceLayerBuckets:s,sourceNameToUniqueSourceLayers:i}=e,a=10*this._level,o=10*(this._level+1),l=[],h=[];for(const e of Object.keys(i))i[e].forEach(t=>{l.push(t),h.push(e)});for(let e=0;e<l.length;e++){const i=h[e],c=l[e];if(!r[i]||!s[i])continue;const u=r[i][c],f=s[i][c];if(!f||0===f.length)continue;if((0,n.G4)(t))return;let d=0;const p=u.getData();for(;p.nextTag(2);){const e=p.getMessage(),t=new M(e,u,d++);e.release();const r=t.values;if(r){const e=r._minzoom;if(e&&e>=o)continue;const t=r._maxzoom;if(t&&t<=a)continue}for(const e of f)e.pushFeature(t)}}}_fetchResources(e,t,r){const n=[],s=this._tile.getWorkerTileHandler();let i,a;e.length>0&&(i=s.fetchSprites(e,this._client,r),n.push(i));for(const e in t){const i=t[e];i.size>0&&(a=s.fetchGlyphs(this._tile.tileKey,e,i,this._client,r),n.push(a))}return n}_processFeatures(e){const t=e.filter(e=>e.hasFeatures()||this._canParseStyleLayer(e.layer.uid));for(const e of t)e.processFeatures(e.tileClipper);return t}_parseTileData(e){const t={};for(const r of Object.keys(e)){const n=e[r],s={};for(;n.next();)switch(n.tag()){case 3:{const e=n.getMessage(),t=new k(e);e.release(),s[t.name]=t;break}default:n.skip()}t[r]=s}return t}_createBucket(e){switch(e.type){case 0:return null;case 1:return this._createFillBucket(e);case 2:return this._createLineBucket(e);case 4:return this._createCircleBucket(e);case 3:return this._createSymbolBucket(e)}}_createFillBucket(e){return new z(e,this._level,this._tile.getWorkerTileHandler().getSpriteItems(),new A(e.fillMaterial.getStride()),new v,new B(e.outlineMaterial.getStride()),new v)}_createLineBucket(e){return new F(e,this._level,this._tile.getWorkerTileHandler().getSpriteItems(),new V(e.lineMaterial.getStride()),new v)}_createCircleBucket(e){return new R(e,this._level,this._tile.getWorkerTileHandler().getSpriteItems(),new S(e.circleMaterial.getStride()),new v)}_createSymbolBucket(e){const t=this._tile;return new q(t.tileKey,e,this._level,new D(e.iconMaterial.getStride()),new v,new D(e.textMaterial.getStride()),new v,t.placementEngine,t.getWorkerTileHandler())}}class H{constructor(e,t,r,n){this.status=0,this.placementEngine=new m,this.tileKey=e,this.refKeys=t,this._workerTileHandler=r,this._styleRepository=n}release(){this.tileKey="",this.refKeys=null,this.status=0,this._workerTileHandler=null}async parse(e,t){const r=t?.signal;if(null!=r){const e=()=>{r.removeEventListener("abort",e),this.status=4};r.addEventListener("abort",e)}let s;const i={bucketsWithData:[],emptyBuckets:null};try{s=await this._parse(e,t)}catch(e){if((0,n.zf)(e))throw e;return{result:i,transferList:[]}}this.status=2;const a=i.bucketsWithData,o=[];for(const e of s)if(e.hasFeatures()){const t=e.serialize();a.push(t)}else o.push(e.layer.uid);const l=[...a];let h=null;return o.length>0&&(h=Uint32Array.from(o),l.push(h.buffer)),i.emptyBuckets=h,{result:i,transferList:l}}setObsolete(){this.status=4}getLayers(){return this._workerTileHandler.getLayers()}getWorkerTileHandler(){return this._workerTileHandler}async _parse(e,t){const r=e.sourceName2DataAndRefKey;return 0===Object.keys(r).length?[]:(this.status=3,new K(r,this,t.client,e.sourceDataMaxLOD,this._styleRepository,e.styleLayerUIDs).parse(t))}}var J=r(45013);class Y{constructor(){this._spriteInfo={},this._glyphInfo={},this._sourceDataMaxLOD=25}reset(){return this._spriteInfo={},this._glyphInfo={},Promise.resolve()}getLayers(){return this._styleRepository?.layers??[]}async createTileAndParse(e,t){const{key:r}=e,s={};for(const t of Object.keys(e.sourceName2DataAndRefKey)){const r=e.sourceName2DataAndRefKey[t];s[t]=r.refKey}const i=new H(r,s,this,this._styleRepository);try{return await i.parse({...e,sourceDataMaxLOD:this._sourceDataMaxLOD},t)}catch(e){if(i.setObsolete(),i.release(),!(0,n.zf)(e))throw e;return null}}updateStyle(e){if(!e||0===e.length||!this._styleRepository)return;const t=this._styleRepository;for(const r of e){const e=r.type,n=r.data;switch(e){case 0:t.setPaintProperties(n.layer,n.paint);break;case 1:t.setLayoutProperties(n.layer,n.layout);break;case 3:t.deleteStyleLayer(n.layer);break;case 2:t.setStyleLayer(n.layer,n.index);break;case 4:this._spriteInfo={}}}}setStyle(e){const{style:t,sourceDataMaxLOD:r}=e;this._styleRepository=new J.A(t),this._sourceDataMaxLOD=r,this._spriteInfo={},this._glyphInfo={}}fetchSprites(e,t,r){const n=[],s=this._spriteInfo;for(const t of e)void 0===s[t.name]&&n.push(t);return 0===n.length?Promise.resolve():t.invoke("getSprites",n,{signal:r?.signal}).then(e=>{for(const t in e){const r=e[t];s[t]=r}})}getSpriteItems(){return this._spriteInfo}fetchGlyphs(e,t,r,n,s){const i=[];let a=this._glyphInfo[t];return a?r.forEach(e=>{a[e]||i.push(e)}):(a=this._glyphInfo[t]=[],r.forEach(e=>i.push(e))),0===i.length?Promise.resolve():n.invoke("getGlyphs",{tileID:e,font:t,codePoints:i},s).then(e=>{for(let t=0;t<e.length;t++)e[t]&&(a[t]=e[t])})}getGlyphItems(e){return this._glyphInfo[e]}}}}]);