@arcgis/core 4.24.0-next.20220604 → 4.24.0-next.20220607

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 (50) hide show
  1. package/analysis/Analysis.js +1 -1
  2. package/analysis/LineOfSightAnalysis.js +1 -1
  3. package/arcade/featureset/support/sqlUtils.js +1 -1
  4. package/assets/esri/core/workers/RemoteClient.js +1 -1
  5. package/assets/esri/core/workers/chunks/471beeb6924599209567.js +1 -0
  6. package/assets/esri/core/workers/chunks/{8102bb78fe96e6197e4e.js → 5da1b3dacc6c8c080a1c.js} +1 -1
  7. package/assets/esri/core/workers/chunks/b780228a520e1a0b100b.js +1 -0
  8. package/assets/esri/themes/base/widgets/_Daylight.scss +31 -32
  9. package/assets/esri/themes/base/widgets/_FloorFilter.scss +1 -0
  10. package/assets/esri/themes/base/widgets/_SnappingControls.scss +14 -0
  11. package/assets/esri/themes/dark/main.css +1 -1
  12. package/assets/esri/themes/light/main.css +1 -1
  13. package/assets/esri/themes/light/view.css +1 -1
  14. package/core/unitUtils.js +1 -1
  15. package/interfaces.d.ts +19 -41
  16. package/layers/LineOfSightLayer.js +1 -1
  17. package/networks/support/typeUtils.js +1 -1
  18. package/package.json +1 -1
  19. package/properties/defaultUnit.js +1 -1
  20. package/rest/networks/queryAssociations.js +5 -0
  21. package/rest/networks/support/Association.js +1 -1
  22. package/rest/networks/support/QueryAssociationsParameters.js +5 -0
  23. package/rest/networks/support/QueryAssociationsResult.js +5 -0
  24. package/smartMapping/support/adapters/FeatureLayerAdapter.js +1 -1
  25. package/support/revision.js +1 -1
  26. package/symbols/cim/CIMSymbolDrawHelper.js +1 -1
  27. package/views/2d/engine/webgl/mesh/templates/WGLLabelTemplate.js +1 -1
  28. package/views/3d/analysis/LineOfSight/LineOfSightController.js +1 -1
  29. package/views/3d/analysis/LineOfSight/LineOfSightVisualization.js +1 -1
  30. package/views/3d/interactive/editingTools/moveGraphic/GraphicMoveTool.js +1 -1
  31. package/views/3d/interactive/editingTools/reshapeGraphic/ReshapeOperation.js +1 -1
  32. package/views/3d/layers/i3s/I3SIndex.js +1 -1
  33. package/views/3d/layers/i3s/I3SIntersectionHandler.js +1 -1
  34. package/views/3d/layers/i3s/I3SUtil.js +1 -1
  35. package/views/3d/layers/i3s/I3SViewportQueries.js +1 -1
  36. package/views/3d/state/helpers/SceneIntersectionHelper.js +1 -1
  37. package/views/draw/DrawOperation.js +1 -1
  38. package/views/interactive/SegmentLabels.js +1 -1
  39. package/views/interactive/tooltip/Tooltip.js +1 -1
  40. package/views/interactive/tooltip/content/TooltipContent.js +1 -1
  41. package/views/support/lengthMeasurementUtils.js +1 -1
  42. package/widgets/Daylight/support/SliderWithDropdown.js +1 -1
  43. package/widgets/Slider.js +1 -1
  44. package/widgets/support/AnalysisViewModel.js +1 -1
  45. package/widgets/support/InteractiveAnalysisViewModel.js +1 -1
  46. package/widgets/support/SnappingControls/SnappingControlsViewModel.js +1 -1
  47. package/widgets/support/SnappingControls/SnappingListItem.js +1 -1
  48. package/widgets/support/SnappingControls.js +1 -1
  49. package/assets/esri/core/workers/chunks/0832c0f5e61b7b354a17.js +0 -1
  50. package/assets/esri/core/workers/chunks/6f41f039226a043a2d18.js +0 -1
package/widgets/Slider.js CHANGED
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import t from"../core/Collection.js";import{eventKey as i}from"../core/events.js";import{isNone as n,isSome as s}from"../core/maybe.js";import{aliasOf as o}from"../core/accessorSupport/decorators/aliasOf.js";import"../core/arrayUtils.js";import"../core/has.js";import{cast as r}from"../core/accessorSupport/decorators/cast.js";import{property as a}from"../core/accessorSupport/decorators/property.js";import{subclass as l}from"../core/accessorSupport/decorators/subclass.js";import h from"./Widget.js";import d from"./Slider/SliderViewModel.js";import{onResize as c}from"./support/widgetUtils.js";import{messageBundle as m}from"./support/decorators/messageBundle.js";import{tsx as u}from"./support/jsxFactory.js";import{substitute as _}from"../intl/substitute.js";const p={base:"esri-slider",reversed:"esri-slider--reversed",horizontalLayout:"esri-slider--horizontal",verticalLayout:"esri-slider--vertical",contentElement:"esri-slider__content",extraContentElement:"esri-slider__extra-content",trackElement:"esri-slider__track",ticksContainerElement:"esri-slider__ticks",tickElement:"esri-slider__tick",tickLabelElement:"esri-slider__tick-label",maxElement:"esri-slider__max",minElement:"esri-slider__min",maxElementInteractive:"esri-slider__max--interactive",minElementInteractive:"esri-slider__min--interactive",rangeElementActive:"esri-slider__range--active",rangeInput:"esri-slider__range-input",anchorElement:"esri-slider__anchor",movingAnchorElement:"esri-slider__anchor--moving",lastMovedAnchorElement:"esri-slider__anchor--moved",anchorElementActive:"esri-slider__anchor--active",anchorElementIndexPrefix:"esri-slider__anchor-",segmentElement:"esri-slider__segment",segmentElementIndexPrefix:"esri-slider__segment-",segmentElementInteractive:"esri-slider__segment--interactive",segmentElementActive:"esri-slider__segment--active",effectiveSegmentElement:"esri-slider__effective-segment",effectiveMaxSegmentElement:"esri-slider__effective-max-segment",effectiveMinSegmentElement:"esri-slider__effective-min-segment",thumbElement:"esri-slider__thumb",labelElement:"esri-slider__label",labelElementInteractive:"esri-slider__label--interactive",labelInput:"esri-slider__label-input",esriWidget:"esri-widget",widgetIcon:"esri-icon-edit",disabled:"esri-disabled",hidden:"esri-hidden"},v={showInput:"Enter",hideInput1:"Enter",hideInput2:"Escape",hideInput3:"Tab",moveAnchorUp:"ArrowUp",moveAnchorDown:"ArrowDown",moveAnchorLeft:"ArrowLeft",moveAnchorRight:"ArrowRight",moveAnchorToMax:"End",moveAnchorToMin:"Home"},g="esri.widgets.Slider",f={labels:!1,rangeLabels:!1};let b=class extends h{constructor(e,i){super(e,i),this._activeLabelInputIndex=null,this._anchorElements=[],this._dragged=!1,this._dragStartInfo=null,this._focusedAnchorIndex=null,this._isMinInputActive=!1,this._isMaxInputActive=!1,this._lastMovedHandleIndex=null,this._positionPrecision=5,this._segmentDragStartInfo=null,this._trackHeight=null,this._trackWidth=null,this._zIndices=null,this._zIndexOffset=3,this.disabled=!1,this.draggableSegmentsEnabled=!0,this.effectiveMax=null,this.effectiveMin=null,this.effectiveSegmentElements=new t,this.extraNodes=[],this.inputCreatedFunction=null,this.inputFormatFunction=null,this.inputParseFunction=null,this.label=void 0,this.labelElements=new t,this.labelInputsEnabled=!1,this.labelFormatFunction=null,this.labels=null,this.max=null,this.maxLabelElement=null,this.messages=null,this.min=null,this.minLabelElement=null,this.precision=4,this.rangeLabelInputsEnabled=!1,this.segmentElements=new t,this.snapOnClickEnabled=!0,this.steps=null,this.syncedSegmentsEnabled=!1,this.thumbsConstrained=!0,this.thumbCreatedFunction=null,this.thumbElements=new t,this.tickElements=new t,this.trackElement=null,this.values=null,this.viewModel=new d,this.visibleElements={...f},this._onAnchorPointerDown=this._onAnchorPointerDown.bind(this),this._onAnchorPointerMove=this._onAnchorPointerMove.bind(this),this._onAnchorPointerUp=this._onAnchorPointerUp.bind(this),this._onLabelPointerDown=this._onLabelPointerDown.bind(this),this._onLabelPointerUp=this._onLabelPointerUp.bind(this),this._onSegmentPointerDown=this._onSegmentPointerDown.bind(this),this._onSegmentPointerMove=this._onSegmentPointerMove.bind(this),this._onSegmentPointerUp=this._onSegmentPointerUp.bind(this),this._onTrackPointerDown=this._onTrackPointerDown.bind(this),this._onTrackPointerMove=this._onTrackPointerMove.bind(this),this._onTrackPointerUp=this._onTrackPointerUp.bind(this)}destroy(){document.removeEventListener("pointerup",this._onLabelPointerUp),document.removeEventListener("pointermove",this._onLabelPointerMove),document.removeEventListener("pointerup",this._onAnchorPointerUp),document.removeEventListener("pointermove",this._onAnchorPointerMove),this.labelElements.removeAll(),this.labelElements.destroy(),this.segmentElements.removeAll(),this.segmentElements.destroy(),this.effectiveSegmentElements.removeAll(),this.effectiveSegmentElements.destroy(),this.thumbElements.removeAll(),this.thumbElements.destroy(),this.tickElements.removeAll(),this.tickElements.destroy()}set layout(e){["vertical","vertical-reversed","horizontal","horizontal-reversed"].includes(e)||(e="horizontal"),this._set("layout",e)}get state(){const{_activeLabelInputIndex:e,_isMaxInputActive:t,_isMinInputActive:i,_dragStartInfo:n,_segmentDragStartInfo:o,disabled:r,viewModel:a}=this,l=s(n)||s(o);return r?"disabled":!(null===e&&!t&&!i)?"editing":l?"dragging":a.state}set tickConfigs(e){this._set("tickConfigs",e),this.scheduleRender()}castVisibleElements(e){return{...f,...e}}render(){const{label:e}=this,t=this.classes(p.base,p.esriWidget,this._isHorizontalLayout()?p.horizontalLayout:p.verticalLayout,this._isReversedLayout()?p.reversed:null,this._isDisabled()?p.disabled:null);return this._storeTrackDimensions(),u("div",{"aria-label":e,class:t,"touch-action":"none",bind:this,afterCreate:this._afterContainerCreate},this.renderContent())}toNextStep(e){this._toStep(e,1)}toPreviousStep(e){this._toStep(e,-1)}renderContent(){const{max:e,min:t}=this;if(!(n(t)||n(e)||t>=e))return[this.renderMin(),this.renderSliderContainer(),this.renderMax()]}renderSliderContainer(){return u("div",{key:"slider-container",bind:this,class:p.contentElement},this.renderTrackElement(),this.renderTicksContainer(),this.renderExtraContentElements())}renderTrackElement(){return u("div",{afterCreate:this._afterTrackCreate,afterRemoved:this._afterTrackRemoved,bind:this,class:p.trackElement,"data-node-ref":"trackElement","touch-action":"none"},this.renderEffectiveSegmentElements(),this.renderSegmentElements(),this.renderAnchorElements())}renderEffectiveSegmentElements(){if(!this.trackElement||!this.values||!this.values.length)return;const e=s(this.effectiveMax),t=s(this.effectiveMin);if(!e&&!t)return;const{max:i,min:n,viewModel:o}=this,r=o.getBounds(),a=[];return t&&a.push(this.renderEffectiveSegmentElement(n,r.min,!0)),e&&a.push(this.renderEffectiveSegmentElement(r.max,i,!1)),a}renderSegmentElements(){if(!this.trackElement||!this.values||!this.values.length)return;const e=this.values.length,t=[];for(let i=0;i<=e;i++)t.push(this.renderSegmentElement(i));return t}renderSegmentElement(e){const{_trackHeight:t,_trackWidth:i,draggableSegmentsEnabled:n,id:o,state:r,values:a}=this,l=this._isHorizontalLayout(),h=l?i:t,d=this.viewModel.getBounds(),c=this._positionFromValue(d.max),m=this._positionFromValue(d.min),_=e===a.length?null:e,v=0===e?null:e-1,g=s(_),f=s(v);let b,E;const x=[...a].sort(((e,t)=>e-t));this._isReversedLayout()?(b=f?this._positionFromValue(x[v]):m,E=g?this._positionFromValue(x[_]):c):(b=g?this._positionFromValue(x[_]):c,E=f?this._positionFromValue(x[v]):m);const k=this._applyPrecisionToPosition(100*E/h),y=(b-E)/h,I=l?`transform: translate(${k}%, 0px) scale(${y}, 1);`:`transform: translate(0px, ${k}%) scale(1, ${y});`,P=this.classes(p.segmentElement,p.segmentElementIndexPrefix+e,n&&g&&f&&"disabled"!==r?p.segmentElementInteractive:null);return u("div",{afterCreate:this._afterSegmentCreate,afterRemoved:this._afterSegmentRemoved,bind:this,class:P,"data-max-thumb-index":_,"data-min-thumb-index":v,"data-segment-index":e,key:`${o}-segment-${e}`,style:I,"touch-action":"none"})}renderEffectiveSegmentElement(e,t,i){const{_trackHeight:n,_trackWidth:s}=this,o=this._positionFromValue(e),r=this._positionFromValue(t),a=this._isHorizontalLayout(),l=a?s:n,h=i?l-r:r,d=o===l?0:this._applyPrecisionToPosition(o/l*100),c=r===l?0:this._applyPrecisionToPosition(h/l*100),m=a?`clip-path: inset(0% ${c}% 0% ${d}%);`:`clip-path: inset(${c}% 0% ${d}% 0%);`,_=i?p.effectiveMinSegmentElement:p.effectiveMaxSegmentElement,v=this.classes(p.segmentElement,p.effectiveSegmentElement,_);return u("div",{afterCreate:this._afterEffectiveSegmentCreate,afterRemoved:this._afterEffectiveSegmentRemoved,bind:this,class:v,style:m,"touch-action":"none"})}renderAnchorElements(){const{trackElement:e,values:t}=this;if(t&&t.length)return this._zIndices=t.map(((e,i)=>{const n=this._positionFromValue(e),s=this._positionToPercent(n),o=(this._isHorizontalLayout()?s>50:s<50)?-1:1;return this._zIndexOffset+(t.length+o*i)})),e&&t&&t.length?t.map(((e,t)=>this.renderAnchorElement(e,t))):null}renderAnchorElement(e,t){const i=this._positionFromValue(e),s=this._valueFromPosition(i);if(n(s)||isNaN(s))return;const{_dragStartInfo:o,_lastMovedHandleIndex:r,id:a,layout:l,values:h,visibleElements:{labels:d}}=this,c=o&&o.index===t,m=r===t,v=this.classes(p.anchorElement,p.anchorElementIndexPrefix+t,c?p.movingAnchorElement:null,m?p.lastMovedAnchorElement:null),g=this.labels.values[t],f=this._getStyleForAnchor(e,t,c||m),{min:b,max:E}=this.viewModel.getBoundsForValueAtIndex(t),{disabled:x,messages:k}=this,y=2===h.length?_(0===t?k.rangeMinimum:k.rangeMaximum,{value:e}):g,I=1===h.length?null:0===t?`${a}-handle-${t+1}`:t===h.length-1?`${a}-handle-${t-1}`:`${a}-handle-${t-1} ${a}-handle-${t+1}`;return u("div",{afterCreate:this._afterAnchorCreate,afterUpdate:this._afterAnchorUpdate,afterRemoved:this._afterAnchorRemoved,"aria-controls":I,"aria-label":k.sliderValue,"aria-labelledby":d?`${a}-label-${t}`:null,"aria-orientation":l,"aria-valuemax":E.toString(),"aria-valuemin":b.toString(),"aria-valuenow":e.toString(),"aria-valuetext":y,bind:this,class:v,"data-thumb-index":t,"data-value":e,id:`${a}-handle-${t}`,key:`${a}-handle-${t}-${x}`,onkeydown:this._onAnchorKeyDown,"touch-action":"none",role:"slider",style:f,tabIndex:x?null:0},u("span",{afterCreate:this._afterThumbCreate,afterRemoved:this._afterThumbRemoved,bind:this,class:p.thumbElement,"data-thumb-index":t,"touch-action":"none"}),this.renderThumbLabel(t))}renderThumbLabel(e){const{id:t,labels:i,labelInputsEnabled:n,state:s}=this,o=this.visibleElements.labels,r=i.values[e],a=this.classes(p.labelElement,o?null:p.hidden,n&&"disabled"!==s?p.labelElementInteractive:null);return u("span",{afterCreate:this._afterLabelCreate,afterRemoved:this._afterLabelRemoved,"aria-hidden":(!o).toString(),bind:this,class:a,"data-thumb-index":e,key:`${t}-label-${e}`,id:`${t}-label-${e}`,role:n?"button":null,"touch-action":"none"},this._activeLabelInputIndex===e?this.renderValueInput(e):r)}renderValueInput(e){const{disabled:t,values:i}=this,n=i[e];return u("input",{key:`value-input-${e}-${t}`,afterCreate:this._afterInputCreate,"aria-label":this.messages.sliderValue,bind:this,class:p.labelInput,"data-input-type":"thumb","data-input-index":e,required:!0,tabIndex:t?null:0,type:"text",value:this._formatInputValue(n,"value",e),onblur:this._onLabelInputBlur,onkeydown:this._onInputKeyDown})}renderMax(){const{_isMaxInputActive:e,labels:t,rangeLabelInputsEnabled:i,state:n}=this,s=this.visibleElements.rangeLabels,o=this.classes(p.maxElement,{[p.hidden]:!s,[p.maxElementInteractive]:i&&"disabled"!==n,[p.rangeElementActive]:e});return u("div",{"aria-hidden":(!s).toString(),afterCreate:this._afterMaxLabelCreate,bind:this,class:o,onclick:this._onMaxLabelClick,onkeydown:this._onMaxLabelKeyDown,role:i?"button":null,tabIndex:!this.disabled&&i?0:null},e?this.renderMaxInput():t.max)}renderMin(){const{_isMinInputActive:e,labels:t,rangeLabelInputsEnabled:i,state:n}=this,s=this.visibleElements.rangeLabels,o=this.classes(p.minElement,{[p.hidden]:!s,[p.minElementInteractive]:i&&"disabled"!==n,[p.rangeElementActive]:e});return u("div",{"aria-hidden":(!s).toString(),afterCreate:this._afterMinLabelCreate,bind:this,class:o,onclick:this._onMinLabelClick,onkeydown:this._onMinLabelKeyDown,role:i?"button":null,tabIndex:!this.disabled&&i?0:null},e?this.renderMinInput():t.min)}renderMaxInput(){return u("input",{afterCreate:this._afterInputCreate,"aria-label":this.messages.maximumValue,bind:this,class:p.rangeInput,"data-input-type":"max",required:!0,tabIndex:this.disabled?null:0,type:"text",value:this._formatInputValue(this.max,"max"),onblur:this._onMaxInputBlur,onkeydown:this._onInputKeyDown})}renderMinInput(){return u("input",{afterCreate:this._afterInputCreate,"aria-label":this.messages.minimumValue,bind:this,class:p.rangeInput,"data-input-type":"min",required:!0,tabIndex:this.disabled?null:0,type:"text",value:this._formatInputValue(this.min,"min"),onblur:this._onMinInputBlur,onkeydown:this._onInputKeyDown})}renderExtraContentElements(){return u("div",{bind:this,class:p.extraContentElement},this.extraNodes)}renderTicksContainer(){if(this.tickConfigs&&this.trackElement&&(0!==this._trackHeight||0!==this._trackWidth))return this.tickConfigs.map(((e,t)=>u("div",{key:"ticks-container",class:this.classes(p.ticksContainerElement)},this.renderTicks(e,t))))}renderTicks(e,i){const{mode:n,values:s}=e;if(this.tickElements.getItemAt(i)||this.tickElements.add(new t,i),"position"===n){const t=Array.isArray(s)?s:[s];return this._calculateTickPositions(t).map(((t,n)=>this.renderTickGroup(e,n,i,t)))}if("percent"===n&&Array.isArray(s)){const{max:t,min:n}=this,o=t-n,r=s.map((e=>this._applyPrecisionToPosition(e/100*o+n)));return this._calculateTickPositions(r).map(((t,n)=>this.renderTickGroup(e,n,i,t)))}const o=Array.isArray(s)&&s.length?s[0]:isNaN(s)?null:s,r=this._getTickCounts(o,e);return this._calculateEquidistantTickPositions(r).map(((t,n)=>this.renderTickGroup(e,n,i,t)))}renderTickGroup(e,t,i,s){const o="position"===e.mode?Array.isArray(e.values)?e.values[t]:e.values:this._valueFromPosition(s);if(!n(o)&&!isNaN(o))return u("div",{afterCreate:this._afterTickGroupCreate,afterRemoved:this._afterTickGroupRemoved,bind:this,"data-config":e,"data-position":s,"data-tick-config-index":i,"data-tick-group-index":t,"data-value":o,onclick:this._onTickGroupClick,key:`tick-group-${t}`},this.renderTickLine(e,t,i,o),e.labelsVisible?this.renderTickLabel(e,t,i,o):null)}renderTickLine(e,t,i,n){return u("div",{afterCreate:this._afterTickLineCreate,"aria-valuenow":n.toString(),bind:this,class:p.tickElement,"data-config":e,"data-tick-config-index":i,"data-tick-group-index":t,"data-value":n,key:`tick-label-${t}`,style:this._getPositionStyleForElement(n)})}renderTickLabel(e,t,i,n){const s=e.labelFormatFunction?e.labelFormatFunction(n,"tick",t):this.viewModel.getLabelForValue(n,"tick",t);return u("div",{afterCreate:this._afterTickLabelCreate,"aria-label":s,"aria-valuenow":n.toString(),"aria-valuetext":s,bind:this,class:p.tickLabelElement,"data-config":e,"data-tick-config-index":i,"data-tick-group-index":t,"data-value":n,key:`tick-label-${t}`,style:`transform: translate(-50%); ${this._getPositionStyleForElement(n)}`},s)}_afterContainerCreate(e){this.own(c(e,(()=>this.scheduleRender())))}_afterTrackCreate(e){this._set("trackElement",e),e.addEventListener("pointerdown",this._onTrackPointerDown),this.scheduleRender()}_afterTrackRemoved(e){e.removeEventListener("pointerdown",this._onTrackPointerDown),document.removeEventListener("pointermove",this._onTrackPointerMove),document.removeEventListener("pointerup",this._onTrackPointerUp)}_afterSegmentCreate(e){this.segmentElements.add(e),e.addEventListener("pointerdown",this._onSegmentPointerDown)}_afterSegmentRemoved(e){this.segmentElements.remove(e),e.removeEventListener("pointerdown",this._onSegmentPointerDown)}_afterEffectiveSegmentCreate(e){this.effectiveSegmentElements.add(e)}_afterEffectiveSegmentRemoved(e){this.effectiveSegmentElements.remove(e)}_afterAnchorCreate(e){if(this._anchorElements.push(e),e.addEventListener("pointerdown",this._onAnchorPointerDown),this.thumbCreatedFunction){const t=e["data-thumb-index"],i=e["data-value"],n=this.thumbElements.getItemAt(t)||null,s=this.labelElements.getItemAt(t)||null;this.thumbCreatedFunction(t,i,n,s)}}_afterAnchorUpdate(e){if(s(this._focusedAnchorIndex)){e["data-thumb-index"]===this._focusedAnchorIndex&&(e.focus(),this._focusedAnchorIndex=null)}}_afterAnchorRemoved(e){const t=this._anchorElements.indexOf(e,0);t>-1&&this._anchorElements.splice(t,1),e.removeEventListener("pointerdown",this._onAnchorPointerDown)}_afterThumbCreate(e){this.thumbElements.add(e)}_afterThumbRemoved(e){this.thumbElements.remove(e)}_afterLabelCreate(e){this.labelElements.add(e),e.addEventListener("pointerdown",this._onLabelPointerDown),e.addEventListener("pointerup",this._onLabelPointerUp)}_afterLabelRemoved(e){this.labelElements.remove(e),e.removeEventListener("pointerdown",this._onLabelPointerDown),e.removeEventListener("pointerup",this._onLabelPointerUp)}_afterInputCreate(e){if(e.focus(),e.select(),this.inputCreatedFunction){const t=e.getAttribute("data-input-type"),i="thumb"===t?e["data-input-index"]:null;this.inputCreatedFunction(e,t,i)}}_afterTickLineCreate(e){const t=e["data-tick-config-index"],i=e["data-tick-group-index"],n=this.tickElements.getItemAt(t);n.getItemAt(i)?n.getItemAt(i).tickElement=e:n.add({groupElement:null,tickElement:e,labelElement:null},i)}_afterTickLabelCreate(e){const t=e["data-tick-config-index"],i=e["data-tick-group-index"],n=this.tickElements.getItemAt(t);n.getItemAt(i)?n.getItemAt(i).labelElement=e:n.add({groupElement:null,labelElement:e,tickElement:null},i)}_afterTickGroupRemoved(e){const t=e["data-tick-config-index"],i=this.tickElements.items[t],n=i?.find((t=>t.groupElement===e));n&&i.remove(n)}_afterTickGroupCreate(e){const t=e["data-config"];if(t&&t.tickCreatedFunction){const i=e["data-tick-config-index"],n=e["data-tick-group-index"],s=e["data-value"],o=this.tickElements?.getItemAt(i)?.getItemAt(n);if(o){o.groupElement=e;const i=o.tickElement||null,n=o.labelElement||null;t.tickCreatedFunction(s,i,n)}}}_afterMaxLabelCreate(e){this._set("maxLabelElement",e)}_afterMinLabelCreate(e){this._set("minLabelElement",e)}_onAnchorKeyDown(e){if(this._isDisabled()||"editing"===this.state)return;const{target:t}=e,n=i(e),{_anchorElements:o,values:r}=this,a=t["data-thumb-index"],l=o[a],h=r[a],d=[v.moveAnchorUp,v.moveAnchorDown,v.moveAnchorLeft,v.moveAnchorRight];if(n===v.showInput&&this.labelInputsEnabled)this._activeLabelInputIndex=a,this.notifyChange("state");else if(d.includes(n)){e.preventDefault();const{steps:t}=this,i=n===v.moveAnchorUp||n===v.moveAnchorRight?1:-1;if(s(t))this._toStep(a,this._isReversedLayout()?-1*i:i);else{const{precision:e}=this,t=this._getPositionOfElement(l),n=this._valueFromPosition(t),s=this._isHorizontalLayout()?i:-1*i;let o;o=0===e?this._positionFromValue(n+s):1===e?this._positionFromValue(n+.1*s):t+s,this._toPosition(a,o)}const o=this.values[a];h!==o&&this._emitThumbChangeEvent({index:a,oldValue:h,value:o})}else if(n===v.moveAnchorToMax||n===v.moveAnchorToMin){e.preventDefault();const{min:t,max:i}=this._getAnchorBoundsInPixels(a),s=this._isPositionInverted()?n===v.moveAnchorToMax?t:i:n===v.moveAnchorToMin?t:i;this._toPosition(a,s);const o=this.values[a];h!==o&&this._emitThumbChangeEvent({index:a,oldValue:h,value:o})}}_onAnchorPointerDown(e){if(this._isDisabled())return;const{target:t,clientX:i,clientY:n}=e,s=t["data-thumb-index"];void 0!==s&&(e.preventDefault(),this._anchorElements[s]&&this._anchorElements[s].focus(),this._storeTrackDimensions(),this._dragStartInfo={clientX:i,clientY:n,index:s,position:this._getPositionOfElement(this._anchorElements[s])},this.notifyChange("state"),document.addEventListener("pointerup",this._onAnchorPointerUp),document.addEventListener("pointermove",this._onAnchorPointerMove))}_onAnchorPointerMove(e){if("editing"===this.state||!this._dragStartInfo)return;e.preventDefault();const{values:t,_anchorElements:i,_dragged:n,_dragStartInfo:s,_dragStartInfo:{index:o,position:r}}=this,{clientX:a,clientY:l}=e,h=n?"drag":"start",d=i[o],c=this._getPositionOfElement(d),m=this._applyPrecisionToPosition(this._isHorizontalLayout()?r+a-s.clientX:r+l-s.clientY);if(c===m)return;const u=t[o];this._dragged=!0,this._toPosition(o,m);const _=this.values[o];n?u!==_&&this._emitThumbDragEvent({index:o,state:h,value:_}):this._emitThumbDragEvent({index:o,state:h,value:u})}_onAnchorPointerUp(e){if(document.removeEventListener("pointerup",this._onAnchorPointerUp),document.removeEventListener("pointermove",this._onAnchorPointerMove),!this._dragStartInfo)return;e.preventDefault();const{index:t}=this._dragStartInfo,i=this._dragged,n=this.values[t];this._dragged=!1,this._dragStartInfo=null,this._lastMovedHandleIndex=t,this.notifyChange("state"),i?this._emitThumbDragEvent({index:t,state:"stop",value:n}):(this.scheduleRender(),"editing"!==this.state&&this._emitThumbClickEvent({index:t,value:n}))}_onTrackPointerDown(e){const{_dragStartInfo:t,snapOnClickEnabled:i,state:o,values:r}=this;if(this._isDisabled()||"editing"===o||t)return;if(document.addEventListener("pointermove",this._onTrackPointerMove),document.addEventListener("pointerup",this._onTrackPointerUp),!i||!r.length)return;const{steps:a}=this,{clientX:l,clientY:h}=e,d=this._getCursorPositionFromEvent(e),c=this._valueFromPosition(d),m=this._getIndexOfNearestValue(c),u=r[m],_=r.some(((e,t)=>e===u&&t!==m))&&c>u?this.values.lastIndexOf(u):m;if(n(_))return;const p=r[_],v=s(a)?this._calculateNearestStepPosition(d):d;this._toPosition(_,v),this._dragged=!0,this._dragStartInfo={clientX:l,clientY:h,index:_,position:v},this._focusedAnchorIndex=_,this.notifyChange("state"),this._emitThumbDragEvent({index:_,state:"start",value:p});const g=this.values[_];p!==g&&this._emitThumbDragEvent({index:_,state:"drag",value:g}),document.addEventListener("pointerup",this._onAnchorPointerUp),document.addEventListener("pointermove",this._onAnchorPointerMove)}_onTrackPointerMove(e){e.preventDefault(),this._dragged=!0}_onTrackPointerUp(e){if(e.preventDefault(),document.removeEventListener("pointermove",this._onTrackPointerMove),document.removeEventListener("pointerup",this._onTrackPointerUp),this.snapOnClickEnabled||(this._dragged=!1),!this._dragged){const t=this._getCursorPositionFromEvent(e),i=this._valueFromPosition(t);this._emitTrackClickEvent({value:i})}}_onSegmentPointerDown(e){e.preventDefault();const t=e.target,i=t["data-segment-index"],s=t["data-min-thumb-index"],o=t["data-max-thumb-index"];if(this._isDisabled()||n(s)||n(o))return;e.stopPropagation(),this._storeTrackDimensions(),document.addEventListener("pointerup",this._onSegmentPointerUp);const r=this._getAnchorDetails(s),a=this._getAnchorDetails(o);this.syncedSegmentsEnabled?(this.segmentElements.forEach((e=>e.classList.add(p.segmentElementActive))),this._anchorElements.forEach((e=>e.classList.add(p.anchorElementActive)))):(this.segmentElements.getItemAt(i).classList.add(p.segmentElementActive),this._anchorElements[r.index]?.classList.add(p.anchorElementActive),this._anchorElements[a.index]?.classList.add(p.anchorElementActive)),this._segmentDragStartInfo={cursorPosition:this._getCursorPositionFromEvent(e),index:i,details:this._normalizeSegmentDetails({min:r,max:a})},this.draggableSegmentsEnabled&&(document.addEventListener("pointermove",this._onSegmentPointerMove),this.notifyChange("state"),this._emitSegmentDragEvent({index:i,state:"start",thumbIndices:[s,o]}))}_onSegmentPointerMove(e){if(!this._segmentDragStartInfo)return;e.preventDefault();const{_trackHeight:t,_trackWidth:i,_segmentDragStartInfo:{index:n,cursorPosition:s,details:{min:o,max:r}}}=this,{index:a,position:l,value:h}=o,{index:d,position:c,value:m}=r;this._dragged=!0;const u=this._getCursorPositionFromEvent(e);if(u===s)return;const _=this._positionToPercent(s),p=this._positionToPercent(u)-_,v=this._positionToPercent(l)+p,g=this._positionToPercent(c)+p,{min:f}=this._getAnchorBoundsAsPercents(a),{max:b}=this._getAnchorBoundsAsPercents(d);let E=!1,x=!1;if(v<f?E=!0:g>b&&(x=!0),E){const{min:e,max:t}=this.viewModel.getBoundsForValueAtIndex(a),i=this._isPositionInverted()?t:e,n=i,s=m+(i-h),o=s-this.values[d];return void(this.syncedSegmentsEnabled?this._updateAnchorValuesByDifference(o):this._updateAnchorValues([a,d],[n,s]))}if(x){const{min:e,max:t}=this.viewModel.getBoundsForValueAtIndex(d),i=this._isPositionInverted()?e:t,n=i,s=h+(i-m),o=s-this.values[a];return void(this.syncedSegmentsEnabled?this._updateAnchorValuesByDifference(o):this._updateAnchorValues([a,d],[s,n]))}const k=this._isHorizontalLayout()?i:t,y=g/100*k,I=v/100*k,P=this.values,A=[P[a],P[d]],L=this._getValueForAnchorAtPosition(a,I),S=this._getValueForAnchorAtPosition(d,y);this.syncedSegmentsEnabled?this._updateAnchorValuesByDifference(L-A[0]):this._updateAnchorValues([a,d],[L,S]);[this.values[a],this.values[d]].every(((e,t)=>e===A[t]))||this._emitSegmentDragEvent({index:n,state:"drag",thumbIndices:[a,d]})}_onSegmentPointerUp(e){if(e.preventDefault(),document.removeEventListener("pointerup",this._onSegmentPointerUp),document.removeEventListener("pointermove",this._onSegmentPointerMove),!this._segmentDragStartInfo)return;const{_dragged:t,max:i,min:n,values:s}=this,{index:o,details:{min:{index:r},max:{index:a}}}=this._segmentDragStartInfo;if(this.segmentElements.forEach((e=>e.classList.remove(p.segmentElementActive))),this._anchorElements.forEach((e=>e.classList.remove(p.anchorElementActive))),this.draggableSegmentsEnabled){const e=i-n,t=s[r],l=s[a];this._lastMovedHandleIndex=t===l?t>e/2?r:a:null,this._dragged=!1,this._segmentDragStartInfo=null,this.notifyChange("state"),this._emitSegmentDragEvent({index:o,state:"stop",thumbIndices:[r,a]})}if(!t){const t=this._getCursorPositionFromEvent(e),i=this._valueFromPosition(t);this._emitSegmentClickEvent({index:o,value:i,thumbIndices:[r,a]})}}_onTickGroupClick(e){const t=e.target;if(t["data-config"]){const e=t["data-tick-config-index"],i=t["data-tick-group-index"],n=t["data-value"];this._emitTickClickEvent({configIndex:e,groupIndex:i,value:n})}}_storeTrackDimensions(){if(this.trackElement){const e=this._getDimensions(this.trackElement);this._trackHeight=e.height,this._trackWidth=e.width}}_onLabelPointerDown(){this._isDisabled()||(this._dragged=!1,document.addEventListener("pointerup",this._onAnchorPointerUp),document.addEventListener("pointermove",this._onAnchorPointerMove))}_onLabelPointerMove(){this._isDisabled()||(this._dragged=!0)}_onLabelPointerUp(e){if(this._isDisabled())return;const t=e.target["data-thumb-index"];this.labelInputsEnabled&&!this._dragged&&s(t)&&(this._activeLabelInputIndex=t),this._dragged=!1,this.notifyChange("state"),document.removeEventListener("pointerup",this._onLabelPointerUp),document.removeEventListener("pointermove",this._onLabelPointerMove)}_onLabelInputBlur(e){const{_activeLabelInputIndex:t,values:i,viewModel:n}=this,s=e.target.value;if(this._activeLabelInputIndex=null,this.notifyChange("state"),!s)return;const o=this._parseInputValue(s,"value",t),r=i[t],{min:a,max:l}=this.viewModel.getBoundsForValueAtIndex(t);if(o<a||o>l)return;n.setValue(t,o);const h=this.values[t];r!==h&&this._emitThumbChangeEvent({index:t,oldValue:r,value:h})}_onInputKeyDown(e){if(this._isDisabled())return;const{target:t}=e,n=i(e),{hideInput1:o,hideInput2:r,hideInput3:a}=v,{_activeLabelInputIndex:l,_anchorElements:h}=this,d=t;if(n===o||n===r||n===a){e.stopPropagation();const t=l;d.blur(),s(t)?h[t].focus():d.parentElement.focus()}}_onMaxLabelClick(){this._isDisabled()||(this._emitRangeLabelClickEvent({type:"max-click",value:this.max}),this.rangeLabelInputsEnabled&&(this._isMaxInputActive=!0,this.notifyChange("state")))}_onMaxLabelKeyDown(e){this._isDisabled()||i(e)!==v.showInput||(this._isMaxInputActive=!0,this.notifyChange("state"))}_onMaxInputBlur(e){const t=e.target.value;if(this._isMaxInputActive=!1,this.notifyChange("state"),!t)return;const i=this.max,n=this._parseInputValue(t,"max");n<=this.min||(this.viewModel.set("max",n),this.max!==i&&this._emitMaxChangeEvent({oldValue:i,value:this.max}))}_onMinLabelClick(){this._isDisabled()||(this._emitRangeLabelClickEvent({type:"min-click",value:this.min}),this.rangeLabelInputsEnabled&&(this._isMinInputActive=!0,this.notifyChange("state")))}_onMinLabelKeyDown(e){this._isDisabled()||i(e)!==v.showInput||(this._isMinInputActive=!0,this.notifyChange("state"))}_onMinInputBlur(e){const t=e.target.value;if(this._isMinInputActive=!1,this.notifyChange("state"),!t)return;const i=this.min,n=this._parseInputValue(t,"min");n>=this.max||(this.viewModel.set("min",n),this.min!==i&&this._emitMinChangeEvent({oldValue:i,value:this.min}))}_isDisabled(){return this.disabled||"disabled"===this.state}_positionFromValue(e){const{max:t,min:i}=this,n=t-i;if(0===n)return 0;const{_trackHeight:s,_trackWidth:o}=this,r=this._isHorizontalLayout();let a=r?parseFloat((o*(e-i)/n).toFixed(2)):parseFloat((s*(t-e)/n).toFixed(2));return this._isReversedLayout()&&(a=r?o-a:s-a),a}_valueFromPosition(e){const{_trackHeight:t,_trackWidth:i,max:n,min:s,precision:o}=this,r=n-s;let a=this._isHorizontalLayout()?e*r/i+s:r*(1e3-e/t*1e3)/1e3+s;return this._isReversedLayout()&&(a=n+s-a),parseFloat(a.toFixed(o))}_positionToPercent(e){const{_trackHeight:t,_trackWidth:i}=this,n=100*e/(this._isHorizontalLayout()?i:t);return this._applyPrecisionToPosition(n)}_applyPrecisionToPosition(e){return parseFloat(e.toFixed(this._positionPrecision))}_isPositionInverted(){const{layout:e}=this;return"horizontal-reversed"===e||"vertical"===e}_isHorizontalLayout(){return this.layout.includes("horizontal")}_isReversedLayout(){return this.layout.includes("reversed")}_normalizeSegmentDetails(e){if(this._isPositionInverted()){const{min:t,max:i}=e;return{min:i,max:t}}return e}_parseInputValue(e,t,i){return this.inputParseFunction?this.inputParseFunction(e,t,i):this.viewModel.defaultInputParseFunction(e)}_formatInputValue(e,t,i){return this.inputFormatFunction?this.inputFormatFunction(e,t,i):this.viewModel.defaultInputFormatFunction(e)}_getAnchorDetails(e){const t=[...this.values].sort(((e,t)=>e-t))[e],i=this.values.indexOf(t);return{index:i,position:this._getPositionOfElement(this._anchorElements[i]),value:t}}_updateAnchorStyle(e,t){const i=this._anchorElements[e];i&&(this._isHorizontalLayout()?i.style.left=`${t}`:i.style.top=`${t}`)}_getStyleForAnchor(e,t,i){const n=this._getPositionStyleForElement(e);if(1===this.values.length)return`${n}`;const s=this._zIndices[t];return`${n}; z-index: ${i?this._zIndexOffset+s:s}`}_getPositionStyleForElement(e){const t=this._positionFromValue(e),i=this._positionToPercent(t);return`${this._isHorizontalLayout()?"left":"top"}: ${i+"%"}`}_getPositionOfElement(e){const t=this._getDimensions(e.offsetParent),i=this._getDimensions(e);return this._isHorizontalLayout()?this._applyPrecisionToPosition(i.left-t.left):this._applyPrecisionToPosition(i.top-t.top)}_updateAnchorValues(e,t){e.forEach(((e,i)=>this._toValue(e,t[i])))}_updateAnchorValuesByDifference(e){const{min:t,max:i,values:n}=this;n.forEach(((n,s)=>this._toValue(s,Math.max(Math.min(n+e,i),t))))}_toValue(e,t){if(s(this.steps)){t=this._getStepValues()[this._getIndexOfNearestStepValue(t)]}this._updateAnchorStyle(e,this._getPositionStyleForElement(t)),this.viewModel.setValue(e,t)}_toPosition(e,t){const i=s(this.steps)?this._getStepValueForAnchorAtPosition(e,t):this._getValueForAnchorAtPosition(e,t);this._updateAnchorStyle(e,this._getPositionStyleForElement(i)),this.viewModel.setValue(e,i)}_getValueForAnchorAtPosition(e,t){const{min:i,max:n}=this._getAnchorBoundsInPixels(e),{min:s,max:o}=this.viewModel.getBoundsForValueAtIndex(e);let r,a,l=null;return this._isPositionInverted()?(r=s,a=o):(r=o,a=s),l=t>n?r:t<i?a:this._valueFromPosition(t),l>o?l=o:l<s&&(l=s),l}_getStepValueForAnchorAtPosition(e,t){const i=this._getStepValues(),n=this._calculateNearestStepPosition(t),s=this._getValueForAnchorAtPosition(e,n);return i[this._getIndexOfNearestStepValue(s)]}_getAnchorBoundsAsPercents(e){const{min:t,max:i}=this._getAnchorBoundsInPixels(e);return{min:this._positionToPercent(t),max:this._positionToPercent(i)}}_getAnchorBoundsInPixels(e){const{_anchorElements:t,_trackHeight:i,_trackWidth:n,effectiveMax:o,effectiveMin:r,thumbsConstrained:a}=this,l=t[e-1],h=t[e+1],d=this._isHorizontalLayout()?n:i,c=s(o)?this._isPositionInverted()?d-this._positionFromValue(o):this._positionFromValue(o):d,m=s(r)?this._isPositionInverted()?d-this._positionFromValue(r):this._positionFromValue(r):0;return a?this._isPositionInverted()?{max:l?this._getPositionOfElement(l):c,min:h?this._getPositionOfElement(h):m}:{max:h?this._getPositionOfElement(h):c,min:l?this._getPositionOfElement(l):m}:{max:c,min:m}}_getIndexOfNearestValue(e){return this.values.indexOf(this.values.reduce(((t,i)=>Math.abs(i-e)<Math.abs(t-e)?i:t)))}_getCursorPositionFromEvent(e){const t=this._getDimensions(this.trackElement);return this._isHorizontalLayout()?e.clientX-t.left:e.clientY-t.top}_getStepValues(){const{steps:e}=this;if(Array.isArray(e))return e;const{max:t,min:i}=this,n=Math.ceil((t-i)/e),s=[];for(let o=0;o<=n;o++){const n=i+e*o;s.push(n>t?t:n)}return s}_toStep(e,t){const{values:i,viewModel:n}=this,s=i[e],o=this._getStepValues(),r=o.indexOf(s);let a=null;if(r>-1){let i=o[r+t];isNaN(i)&&(i=o[r]);const n=this._positionFromValue(i);a=this._getStepValueForAnchorAtPosition(e,n)}else{a=o[this._getIndexOfNearestStepValue(s)+t]}n.setValue(e,a)}_getIndexOfNearestStepValue(e){const{steps:t}=this;if(n(t))return null;const i=this._getStepValues(),s=i.reduce(((t,i)=>Math.abs(i-e)<Math.abs(t-e)?i:t));return i.indexOf(s)}_calculateNearestStepPosition(e){const t=this._valueFromPosition(e),i=this._getIndexOfNearestStepValue(t),n=this._getStepValues();return this._positionFromValue(n[i])}_getTickCounts(e,t){const{mode:i}=t;return"count"===i||"position"===i?e||0:"percent"===i&&100/e||0}_calculateTickPositions(e){return e.map((e=>this._positionFromValue(e)))}_calculateEquidistantTickPositions(e){const{_trackWidth:t,_trackHeight:i}=this,n=this._isHorizontalLayout()?t:i,s=n/(e-1),o=[];if(1===e)return[n/2];for(let r=0;r<e;r++){const e=r*s;e<=n&&o.push(e)}return o}_getDimensions(e){try{return e.getBoundingClientRect()}catch(t){if("object"==typeof t&&null!==t)return new DOMRect(0,0,0,0);throw t}}_emitTrackClickEvent(e){this.emit("track-click",{...e,type:"track-click"})}_emitTickClickEvent(e){this.emit("tick-click",{...e,type:"tick-click"})}_emitMaxChangeEvent(e){this.emit("max-change",{...e,type:"max-change"})}_emitMinChangeEvent(e){this.emit("min-change",{...e,type:"min-change"})}_emitThumbChangeEvent(e){this.emit("thumb-change",{...e,type:"thumb-change"})}_emitThumbClickEvent(e){this.emit("thumb-click",{...e,type:"thumb-click"})}_emitThumbDragEvent(e){this.emit("thumb-drag",{...e,type:"thumb-drag"})}_emitSegmentClickEvent(e){this.emit("segment-click",{...e,type:"segment-click"})}_emitSegmentDragEvent(e){this.emit("segment-drag",{...e,type:"segment-drag"})}_emitRangeLabelClickEvent(e){this.emit(e.type,{...e})}};e([a()],b.prototype,"disabled",void 0),e([a()],b.prototype,"draggableSegmentsEnabled",void 0),e([o("viewModel.effectiveMax")],b.prototype,"effectiveMax",void 0),e([o("viewModel.effectiveMin")],b.prototype,"effectiveMin",void 0),e([a({readOnly:!0})],b.prototype,"effectiveSegmentElements",void 0),e([a()],b.prototype,"extraNodes",void 0),e([a()],b.prototype,"inputCreatedFunction",void 0),e([o("viewModel.inputFormatFunction")],b.prototype,"inputFormatFunction",void 0),e([o("viewModel.inputParseFunction")],b.prototype,"inputParseFunction",void 0),e([a({aliasOf:{source:"messages.widgetLabel",overridable:!0}})],b.prototype,"label",void 0),e([a({readOnly:!0})],b.prototype,"labelElements",void 0),e([a()],b.prototype,"labelInputsEnabled",void 0),e([o("viewModel.labelFormatFunction")],b.prototype,"labelFormatFunction",void 0),e([o("viewModel.labels")],b.prototype,"labels",void 0),e([a({value:"horizontal"})],b.prototype,"layout",null),e([o("viewModel.max")],b.prototype,"max",void 0),e([a({readOnly:!0})],b.prototype,"maxLabelElement",void 0),e([a(),m("esri/widgets/Slider/t9n/Slider")],b.prototype,"messages",void 0),e([o("viewModel.min")],b.prototype,"min",void 0),e([a({readOnly:!0})],b.prototype,"minLabelElement",void 0),e([o("viewModel.precision")],b.prototype,"precision",void 0),e([a()],b.prototype,"rangeLabelInputsEnabled",void 0),e([a({readOnly:!0})],b.prototype,"segmentElements",void 0),e([a()],b.prototype,"snapOnClickEnabled",void 0),e([a({readOnly:!0})],b.prototype,"state",null),e([a()],b.prototype,"steps",void 0),e([a()],b.prototype,"syncedSegmentsEnabled",void 0),e([o("viewModel.thumbsConstrained")],b.prototype,"thumbsConstrained",void 0),e([a()],b.prototype,"thumbCreatedFunction",void 0),e([a({readOnly:!0})],b.prototype,"thumbElements",void 0),e([a()],b.prototype,"tickConfigs",null),e([a({readOnly:!0})],b.prototype,"tickElements",void 0),e([a({readOnly:!0})],b.prototype,"trackElement",void 0),e([o("viewModel.values")],b.prototype,"values",void 0),e([a()],b.prototype,"viewModel",void 0),e([a()],b.prototype,"visibleElements",void 0),e([r("visibleElements")],b.prototype,"castVisibleElements",null),b=e([l(g)],b);const E=b;export{E as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import t from"../core/Collection.js";import{eventKey as i}from"../core/events.js";import{isNone as n,isSome as s}from"../core/maybe.js";import{aliasOf as o}from"../core/accessorSupport/decorators/aliasOf.js";import"../core/arrayUtils.js";import"../core/has.js";import{cast as r}from"../core/accessorSupport/decorators/cast.js";import{property as a}from"../core/accessorSupport/decorators/property.js";import{subclass as l}from"../core/accessorSupport/decorators/subclass.js";import h from"./Widget.js";import d from"./Slider/SliderViewModel.js";import{onResize as c}from"./support/widgetUtils.js";import{messageBundle as m}from"./support/decorators/messageBundle.js";import{tsx as u}from"./support/jsxFactory.js";import{substitute as _}from"../intl/substitute.js";const p={base:"esri-slider",reversed:"esri-slider--reversed",horizontalLayout:"esri-slider--horizontal",verticalLayout:"esri-slider--vertical",contentElement:"esri-slider__content",extraContentElement:"esri-slider__extra-content",trackElement:"esri-slider__track",ticksContainerElement:"esri-slider__ticks",tickElement:"esri-slider__tick",tickLabelElement:"esri-slider__tick-label",maxElement:"esri-slider__max",minElement:"esri-slider__min",maxElementInteractive:"esri-slider__max--interactive",minElementInteractive:"esri-slider__min--interactive",rangeElementActive:"esri-slider__range--active",rangeInput:"esri-slider__range-input",anchorElement:"esri-slider__anchor",movingAnchorElement:"esri-slider__anchor--moving",lastMovedAnchorElement:"esri-slider__anchor--moved",anchorElementActive:"esri-slider__anchor--active",anchorElementIndexPrefix:"esri-slider__anchor-",segmentElement:"esri-slider__segment",segmentElementIndexPrefix:"esri-slider__segment-",segmentElementInteractive:"esri-slider__segment--interactive",segmentElementActive:"esri-slider__segment--active",effectiveSegmentElement:"esri-slider__effective-segment",effectiveMaxSegmentElement:"esri-slider__effective-max-segment",effectiveMinSegmentElement:"esri-slider__effective-min-segment",thumbElement:"esri-slider__thumb",labelElement:"esri-slider__label",labelElementInteractive:"esri-slider__label--interactive",labelInput:"esri-slider__label-input",esriWidget:"esri-widget",widgetIcon:"esri-icon-edit",disabled:"esri-disabled",hidden:"esri-hidden"},v={showInput:"Enter",hideInput1:"Enter",hideInput2:"Escape",hideInput3:"Tab",moveAnchorUp:"ArrowUp",moveAnchorDown:"ArrowDown",moveAnchorLeft:"ArrowLeft",moveAnchorRight:"ArrowRight",moveAnchorToMax:"End",moveAnchorToMin:"Home"},g="esri.widgets.Slider",f={labels:!1,rangeLabels:!1};let b=class extends h{constructor(e,i){super(e,i),this._activeLabelInputIndex=null,this._anchorElements=[],this._dragged=!1,this._dragStartInfo=null,this._focusedAnchorIndex=null,this._isMinInputActive=!1,this._isMaxInputActive=!1,this._lastMovedHandleIndex=null,this._positionPrecision=5,this._segmentDragStartInfo=null,this._trackHeight=null,this._trackWidth=null,this._zIndices=null,this._zIndexOffset=3,this.disabled=!1,this.draggableSegmentsEnabled=!0,this.effectiveMax=null,this.effectiveMin=null,this.effectiveSegmentElements=new t,this.extraNodes=[],this.inputCreatedFunction=null,this.inputFormatFunction=null,this.inputParseFunction=null,this.label=void 0,this.labelElements=new t,this.labelInputsEnabled=!1,this.labelFormatFunction=null,this.labels=null,this.max=null,this.maxLabelElement=null,this.messages=null,this.min=null,this.minLabelElement=null,this.precision=4,this.rangeLabelInputsEnabled=!1,this.segmentElements=new t,this.snapOnClickEnabled=!0,this.steps=null,this.syncedSegmentsEnabled=!1,this.thumbsConstrained=!0,this.thumbCreatedFunction=null,this.thumbElements=new t,this.tickElements=new t,this.trackElement=null,this.values=null,this.viewModel=new d,this.visibleElements={...f},this._onAnchorPointerDown=this._onAnchorPointerDown.bind(this),this._onAnchorPointerMove=this._onAnchorPointerMove.bind(this),this._onAnchorPointerUp=this._onAnchorPointerUp.bind(this),this._onLabelPointerDown=this._onLabelPointerDown.bind(this),this._onLabelPointerUp=this._onLabelPointerUp.bind(this),this._onSegmentPointerDown=this._onSegmentPointerDown.bind(this),this._onSegmentPointerMove=this._onSegmentPointerMove.bind(this),this._onSegmentPointerUp=this._onSegmentPointerUp.bind(this),this._onTrackPointerDown=this._onTrackPointerDown.bind(this),this._onTrackPointerMove=this._onTrackPointerMove.bind(this),this._onTrackPointerUp=this._onTrackPointerUp.bind(this)}destroy(){document.removeEventListener("pointerup",this._onLabelPointerUp),document.removeEventListener("pointermove",this._onLabelPointerMove),document.removeEventListener("pointerup",this._onAnchorPointerUp),document.removeEventListener("pointermove",this._onAnchorPointerMove),this.labelElements.removeAll(),this.labelElements.destroy(),this.segmentElements.removeAll(),this.segmentElements.destroy(),this.effectiveSegmentElements.removeAll(),this.effectiveSegmentElements.destroy(),this.thumbElements.removeAll(),this.thumbElements.destroy(),this.tickElements.removeAll(),this.tickElements.destroy()}set layout(e){["vertical","vertical-reversed","horizontal","horizontal-reversed"].includes(e)||(e="horizontal"),this._set("layout",e)}get state(){const{_activeLabelInputIndex:e,_isMaxInputActive:t,_isMinInputActive:i,_dragStartInfo:n,_segmentDragStartInfo:o,disabled:r,viewModel:a}=this,l=s(n)||s(o);return r?"disabled":!(null===e&&!t&&!i)?"editing":l?"dragging":a.state}set tickConfigs(e){this._set("tickConfigs",e),this.scheduleRender()}castVisibleElements(e){return{...f,...e}}render(){const{label:e}=this,t=this.classes(p.base,p.esriWidget,this._isHorizontalLayout()?p.horizontalLayout:p.verticalLayout,this._isReversedLayout()?p.reversed:null,this._isDisabled()?p.disabled:null);return this._storeTrackDimensions(),u("div",{"aria-label":e,class:t,"touch-action":"none",bind:this,afterCreate:this._afterContainerCreate},this.renderContent())}toNextStep(e){this._toStep(e,1)}toPreviousStep(e){this._toStep(e,-1)}renderContent(){const{max:e,min:t}=this;if(!(n(t)||n(e)||t>=e))return[this.renderMin(),this.renderSliderContainer(),this.renderMax()]}renderSliderContainer(){return u("div",{key:"slider-container",bind:this,class:p.contentElement},this.renderTrackElement(),this.renderTicksContainer(),this.renderExtraContentElements())}renderTrackElement(){return u("div",{afterCreate:this._afterTrackCreate,afterRemoved:this._afterTrackRemoved,bind:this,class:p.trackElement,"data-node-ref":"trackElement","touch-action":"none"},this.renderEffectiveSegmentElements(),this.renderSegmentElements(),this.renderAnchorElements())}renderEffectiveSegmentElements(){if(!this.trackElement||!this.values||!this.values.length)return;const e=s(this.effectiveMax),t=s(this.effectiveMin);if(!e&&!t)return;const{max:i,min:n,viewModel:o}=this,r=o.getBounds(),a=[];return t&&a.push(this.renderEffectiveSegmentElement(n,r.min,!0)),e&&a.push(this.renderEffectiveSegmentElement(r.max,i,!1)),a}renderSegmentElements(){if(!this.trackElement||!this.values||!this.values.length)return;const e=this.values.length,t=[];for(let i=0;i<=e;i++)t.push(this.renderSegmentElement(i));return t}renderSegmentElement(e){const{_trackHeight:t,_trackWidth:i,draggableSegmentsEnabled:n,id:o,state:r,values:a}=this,l=this._isHorizontalLayout(),h=l?i:t,d=this.viewModel.getBounds(),c=this._positionFromValue(d.max),m=this._positionFromValue(d.min),_=e===a.length?null:e,v=0===e?null:e-1,g=s(_),f=s(v);let b,E;const x=[...a].sort(((e,t)=>e-t));this._isReversedLayout()?(b=f?this._positionFromValue(x[v]):m,E=g?this._positionFromValue(x[_]):c):(b=g?this._positionFromValue(x[_]):c,E=f?this._positionFromValue(x[v]):m);const k=this._applyPrecisionToPosition(100*E/h),y=(b-E)/h,I=l?`transform: translate(${k}%, 0px) scale(${y}, 1);`:`transform: translate(0px, ${k}%) scale(1, ${y});`,P=this.classes(p.segmentElement,p.segmentElementIndexPrefix+e,n&&g&&f&&"disabled"!==r?p.segmentElementInteractive:null);return u("div",{afterCreate:this._afterSegmentCreate,afterRemoved:this._afterSegmentRemoved,bind:this,class:P,"data-max-thumb-index":_,"data-min-thumb-index":v,"data-segment-index":e,key:`${o}-segment-${e}`,style:I,"touch-action":"none"})}renderEffectiveSegmentElement(e,t,i){const{_trackHeight:n,_trackWidth:s,layout:o}=this,r=this._positionFromValue(e),a=this._positionFromValue(t),l=this._isHorizontalLayout(),h=l?s:n,d=this._applyPrecisionToPosition(100*r/h);let c=null;if("horizontal"===o){const e=i?h-a:a,t=r===h?0:d;c=`clip-path: inset(0% ${a===h?0:this._applyPrecisionToPosition(e/h*100)}% 0% ${t}%);`}else{const e=(a-r)/h;c=l?`transform: translate(${d}%, 0px) scale(${e}, 1);`:`transform: translate(0px, ${d}%) scale(1, ${e});`}const m=i?p.effectiveMinSegmentElement:p.effectiveMaxSegmentElement,_=this.classes(p.segmentElement,p.effectiveSegmentElement,m);return u("div",{afterCreate:this._afterEffectiveSegmentCreate,afterRemoved:this._afterEffectiveSegmentRemoved,bind:this,class:_,style:c,"touch-action":"none"})}renderAnchorElements(){const{trackElement:e,values:t}=this;if(t&&t.length)return this._zIndices=t.map(((e,i)=>{const n=this._positionFromValue(e),s=this._positionToPercent(n),o=(this._isHorizontalLayout()?s>50:s<50)?-1:1;return this._zIndexOffset+(t.length+o*i)})),e&&t&&t.length?t.map(((e,t)=>this.renderAnchorElement(e,t))):null}renderAnchorElement(e,t){const i=this._positionFromValue(e),s=this._valueFromPosition(i);if(n(s)||isNaN(s))return;const{_dragStartInfo:o,_lastMovedHandleIndex:r,id:a,layout:l,values:h,visibleElements:{labels:d}}=this,c=o&&o.index===t,m=r===t,v=this.classes(p.anchorElement,p.anchorElementIndexPrefix+t,c?p.movingAnchorElement:null,m?p.lastMovedAnchorElement:null),g=this.labels.values[t],f=this._getStyleForAnchor(e,t,c||m),{min:b,max:E}=this.viewModel.getBoundsForValueAtIndex(t),{disabled:x,messages:k}=this,y=2===h.length?_(0===t?k.rangeMinimum:k.rangeMaximum,{value:e}):g,I=1===h.length?null:0===t?`${a}-handle-${t+1}`:t===h.length-1?`${a}-handle-${t-1}`:`${a}-handle-${t-1} ${a}-handle-${t+1}`;return u("div",{afterCreate:this._afterAnchorCreate,afterUpdate:this._afterAnchorUpdate,afterRemoved:this._afterAnchorRemoved,"aria-controls":I,"aria-label":k.sliderValue,"aria-labelledby":d?`${a}-label-${t}`:null,"aria-orientation":l,"aria-valuemax":E.toString(),"aria-valuemin":b.toString(),"aria-valuenow":e.toString(),"aria-valuetext":y,bind:this,class:v,"data-thumb-index":t,"data-value":e,id:`${a}-handle-${t}`,key:`${a}-handle-${t}`,onkeydown:this._onAnchorKeyDown,"touch-action":"none",role:"slider",style:f,tabIndex:x?-1:0},u("span",{afterCreate:this._afterThumbCreate,afterRemoved:this._afterThumbRemoved,bind:this,class:p.thumbElement,"data-thumb-index":t,"touch-action":"none"}),this.renderThumbLabel(t))}renderThumbLabel(e){const{id:t,labels:i,labelInputsEnabled:n,state:s}=this,o=this.visibleElements.labels,r=i.values[e],a=this.classes(p.labelElement,o?null:p.hidden,n&&"disabled"!==s?p.labelElementInteractive:null);return u("span",{afterCreate:this._afterLabelCreate,afterRemoved:this._afterLabelRemoved,"aria-hidden":(!o).toString(),bind:this,class:a,"data-thumb-index":e,key:`${t}-label-${e}`,id:`${t}-label-${e}`,role:n?"button":null,"touch-action":"none"},this._activeLabelInputIndex===e?this.renderValueInput(e):r)}renderValueInput(e){const{disabled:t,values:i}=this,n=i[e];return u("input",{key:`value-input-${e}`,afterCreate:this._afterInputCreate,"aria-label":this.messages.sliderValue,bind:this,class:p.labelInput,"data-input-type":"thumb","data-input-index":e,required:!0,tabIndex:t?-1:0,type:"text",value:this._formatInputValue(n,"value",e),onblur:this._onLabelInputBlur,onkeydown:this._onInputKeyDown})}renderMax(){const{_isMaxInputActive:e,labels:t,rangeLabelInputsEnabled:i,state:n}=this,s=this.visibleElements.rangeLabels,o=this.classes(p.maxElement,{[p.hidden]:!s,[p.maxElementInteractive]:i&&"disabled"!==n,[p.rangeElementActive]:e});return u("div",{"aria-hidden":(!s).toString(),afterCreate:this._afterMaxLabelCreate,bind:this,class:o,onclick:this._onMaxLabelClick,onkeydown:this._onMaxLabelKeyDown,role:i?"button":null,tabIndex:!this.disabled&&i?0:-1},e?this.renderMaxInput():t.max)}renderMin(){const{_isMinInputActive:e,labels:t,rangeLabelInputsEnabled:i,state:n}=this,s=this.visibleElements.rangeLabels,o=this.classes(p.minElement,{[p.hidden]:!s,[p.minElementInteractive]:i&&"disabled"!==n,[p.rangeElementActive]:e});return u("div",{"aria-hidden":(!s).toString(),afterCreate:this._afterMinLabelCreate,bind:this,class:o,onclick:this._onMinLabelClick,onkeydown:this._onMinLabelKeyDown,role:i?"button":null,tabIndex:!this.disabled&&i?0:-1},e?this.renderMinInput():t.min)}renderMaxInput(){return u("input",{afterCreate:this._afterInputCreate,"aria-label":this.messages.maximumValue,bind:this,class:p.rangeInput,"data-input-type":"max",required:!0,tabIndex:this.disabled?-1:0,type:"text",value:this._formatInputValue(this.max,"max"),onblur:this._onMaxInputBlur,onkeydown:this._onInputKeyDown})}renderMinInput(){return u("input",{afterCreate:this._afterInputCreate,"aria-label":this.messages.minimumValue,bind:this,class:p.rangeInput,"data-input-type":"min",required:!0,tabIndex:this.disabled?-1:0,type:"text",value:this._formatInputValue(this.min,"min"),onblur:this._onMinInputBlur,onkeydown:this._onInputKeyDown})}renderExtraContentElements(){return u("div",{bind:this,class:p.extraContentElement},this.extraNodes)}renderTicksContainer(){if(this.tickConfigs&&this.trackElement&&(0!==this._trackHeight||0!==this._trackWidth))return this.tickConfigs.map(((e,t)=>u("div",{key:"ticks-container",class:this.classes(p.ticksContainerElement)},this.renderTicks(e,t))))}renderTicks(e,i){const{mode:n,values:s}=e;if(this.tickElements.getItemAt(i)||this.tickElements.add(new t,i),"position"===n){const t=Array.isArray(s)?s:[s];return this._calculateTickPositions(t).map(((t,n)=>this.renderTickGroup(e,n,i,t)))}if("percent"===n&&Array.isArray(s)){const{max:t,min:n}=this,o=t-n,r=s.map((e=>this._applyPrecisionToPosition(e/100*o+n)));return this._calculateTickPositions(r).map(((t,n)=>this.renderTickGroup(e,n,i,t)))}const o=Array.isArray(s)&&s.length?s[0]:isNaN(s)?null:s,r=this._getTickCounts(o,e);return this._calculateEquidistantTickPositions(r).map(((t,n)=>this.renderTickGroup(e,n,i,t)))}renderTickGroup(e,t,i,s){const o="position"===e.mode?Array.isArray(e.values)?e.values[t]:e.values:this._valueFromPosition(s);if(!n(o)&&!isNaN(o))return u("div",{afterCreate:this._afterTickGroupCreate,afterRemoved:this._afterTickGroupRemoved,bind:this,"data-config":e,"data-position":s,"data-tick-config-index":i,"data-tick-group-index":t,"data-value":o,onclick:this._onTickGroupClick,key:`tick-group-${t}`},this.renderTickLine(e,t,i,o),e.labelsVisible?this.renderTickLabel(e,t,i,o):null)}renderTickLine(e,t,i,n){return u("div",{afterCreate:this._afterTickLineCreate,"aria-valuenow":n.toString(),bind:this,class:p.tickElement,"data-config":e,"data-tick-config-index":i,"data-tick-group-index":t,"data-value":n,key:`tick-label-${t}`,style:this._getPositionStyleForElement(n)})}renderTickLabel(e,t,i,n){const s=e.labelFormatFunction?e.labelFormatFunction(n,"tick",t):this.viewModel.getLabelForValue(n,"tick",t);return u("div",{afterCreate:this._afterTickLabelCreate,"aria-label":s,"aria-valuenow":n.toString(),"aria-valuetext":s,bind:this,class:p.tickLabelElement,"data-config":e,"data-tick-config-index":i,"data-tick-group-index":t,"data-value":n,key:`tick-label-${t}`,style:`transform: translate(-50%); ${this._getPositionStyleForElement(n)}`},s)}_afterContainerCreate(e){this.own(c(e,(()=>this.scheduleRender())))}_afterTrackCreate(e){this._set("trackElement",e),e.addEventListener("pointerdown",this._onTrackPointerDown),this.scheduleRender()}_afterTrackRemoved(e){e.removeEventListener("pointerdown",this._onTrackPointerDown),document.removeEventListener("pointermove",this._onTrackPointerMove),document.removeEventListener("pointerup",this._onTrackPointerUp)}_afterSegmentCreate(e){this.segmentElements.add(e),e.addEventListener("pointerdown",this._onSegmentPointerDown)}_afterSegmentRemoved(e){this.segmentElements.remove(e),e.removeEventListener("pointerdown",this._onSegmentPointerDown)}_afterEffectiveSegmentCreate(e){this.effectiveSegmentElements.add(e)}_afterEffectiveSegmentRemoved(e){this.effectiveSegmentElements.remove(e)}_afterAnchorCreate(e){if(this._anchorElements.push(e),e.addEventListener("pointerdown",this._onAnchorPointerDown),this.thumbCreatedFunction){const t=e["data-thumb-index"],i=e["data-value"],n=this.thumbElements.getItemAt(t)||null,s=this.labelElements.getItemAt(t)||null;this.thumbCreatedFunction(t,i,n,s)}}_afterAnchorUpdate(e){if(s(this._focusedAnchorIndex)){e["data-thumb-index"]===this._focusedAnchorIndex&&(e.focus(),this._focusedAnchorIndex=null)}}_afterAnchorRemoved(e){const t=this._anchorElements.indexOf(e,0);t>-1&&this._anchorElements.splice(t,1),e.removeEventListener("pointerdown",this._onAnchorPointerDown)}_afterThumbCreate(e){this.thumbElements.add(e)}_afterThumbRemoved(e){this.thumbElements.remove(e)}_afterLabelCreate(e){this.labelElements.add(e),e.addEventListener("pointerdown",this._onLabelPointerDown),e.addEventListener("pointerup",this._onLabelPointerUp)}_afterLabelRemoved(e){this.labelElements.remove(e),e.removeEventListener("pointerdown",this._onLabelPointerDown),e.removeEventListener("pointerup",this._onLabelPointerUp)}_afterInputCreate(e){if(e.focus(),e.select(),this.inputCreatedFunction){const t=e.getAttribute("data-input-type"),i="thumb"===t?e["data-input-index"]:null;this.inputCreatedFunction(e,t,i)}}_afterTickLineCreate(e){const t=e["data-tick-config-index"],i=e["data-tick-group-index"],n=this.tickElements.getItemAt(t);n.getItemAt(i)?n.getItemAt(i).tickElement=e:n.add({groupElement:null,tickElement:e,labelElement:null},i)}_afterTickLabelCreate(e){const t=e["data-tick-config-index"],i=e["data-tick-group-index"],n=this.tickElements.getItemAt(t);n.getItemAt(i)?n.getItemAt(i).labelElement=e:n.add({groupElement:null,labelElement:e,tickElement:null},i)}_afterTickGroupRemoved(e){const t=e["data-tick-config-index"],i=this.tickElements.items[t],n=i?.find((t=>t.groupElement===e));n&&i.remove(n)}_afterTickGroupCreate(e){const t=e["data-config"];if(t&&t.tickCreatedFunction){const i=e["data-tick-config-index"],n=e["data-tick-group-index"],s=e["data-value"],o=this.tickElements?.getItemAt(i)?.getItemAt(n);if(o){o.groupElement=e;const i=o.tickElement||null,n=o.labelElement||null;t.tickCreatedFunction(s,i,n)}}}_afterMaxLabelCreate(e){this._set("maxLabelElement",e)}_afterMinLabelCreate(e){this._set("minLabelElement",e)}_onAnchorKeyDown(e){if(this._isDisabled()||"editing"===this.state)return;const{target:t}=e,n=i(e),{_anchorElements:o,values:r}=this,a=t["data-thumb-index"],l=o[a],h=r[a],d=[v.moveAnchorUp,v.moveAnchorDown,v.moveAnchorLeft,v.moveAnchorRight];if(n===v.showInput&&this.labelInputsEnabled)this._activeLabelInputIndex=a,this.notifyChange("state");else if(d.includes(n)){e.preventDefault();const{steps:t}=this,i=n===v.moveAnchorUp||n===v.moveAnchorRight?1:-1;if(s(t))this._toStep(a,this._isReversedLayout()?-1*i:i);else{const{precision:e}=this,t=this._getPositionOfElement(l),n=this._valueFromPosition(t),s=this._isHorizontalLayout()?i:-1*i;let o;o=0===e?this._positionFromValue(n+s):1===e?this._positionFromValue(n+.1*s):t+s,this._toPosition(a,o)}const o=this.values[a];h!==o&&this._emitThumbChangeEvent({index:a,oldValue:h,value:o})}else if(n===v.moveAnchorToMax||n===v.moveAnchorToMin){e.preventDefault();const{min:t,max:i}=this._getAnchorBoundsInPixels(a),s=this._isPositionInverted()?n===v.moveAnchorToMax?t:i:n===v.moveAnchorToMin?t:i;this._toPosition(a,s);const o=this.values[a];h!==o&&this._emitThumbChangeEvent({index:a,oldValue:h,value:o})}}_onAnchorPointerDown(e){if(this._isDisabled())return;const{target:t,clientX:i,clientY:n}=e,s=t["data-thumb-index"];void 0!==s&&(e.preventDefault(),this._anchorElements[s]&&this._anchorElements[s].focus(),this._storeTrackDimensions(),this._dragStartInfo={clientX:i,clientY:n,index:s,position:this._getPositionOfElement(this._anchorElements[s])},this.notifyChange("state"),document.addEventListener("pointerup",this._onAnchorPointerUp),document.addEventListener("pointermove",this._onAnchorPointerMove))}_onAnchorPointerMove(e){if("editing"===this.state||!this._dragStartInfo)return;e.preventDefault();const{values:t,_anchorElements:i,_dragged:n,_dragStartInfo:s,_dragStartInfo:{index:o,position:r}}=this,{clientX:a,clientY:l}=e,h=n?"drag":"start",d=i[o],c=this._getPositionOfElement(d),m=this._applyPrecisionToPosition(this._isHorizontalLayout()?r+a-s.clientX:r+l-s.clientY);if(c===m)return;const u=t[o];this._dragged=!0,this._toPosition(o,m);const _=this.values[o];n?u!==_&&this._emitThumbDragEvent({index:o,state:h,value:_}):this._emitThumbDragEvent({index:o,state:h,value:u})}_onAnchorPointerUp(e){if(document.removeEventListener("pointerup",this._onAnchorPointerUp),document.removeEventListener("pointermove",this._onAnchorPointerMove),!this._dragStartInfo)return;e.preventDefault();const{index:t}=this._dragStartInfo,i=this._dragged,n=this.values[t];this._dragged=!1,this._dragStartInfo=null,this._lastMovedHandleIndex=t,this.notifyChange("state"),i?this._emitThumbDragEvent({index:t,state:"stop",value:n}):(this.scheduleRender(),"editing"!==this.state&&this._emitThumbClickEvent({index:t,value:n}))}_onTrackPointerDown(e){const{_dragStartInfo:t,snapOnClickEnabled:i,state:o,values:r}=this;if(this._isDisabled()||"editing"===o||t)return;if(document.addEventListener("pointermove",this._onTrackPointerMove),document.addEventListener("pointerup",this._onTrackPointerUp),!i||!r.length)return;const{steps:a}=this,{clientX:l,clientY:h}=e,d=this._getCursorPositionFromEvent(e),c=this._valueFromPosition(d),m=this._getIndexOfNearestValue(c),u=r[m],_=r.some(((e,t)=>e===u&&t!==m))&&c>u?this.values.lastIndexOf(u):m;if(n(_))return;const p=r[_],v=s(a)?this._calculateNearestStepPosition(d):d;this._toPosition(_,v),this._dragged=!0,this._dragStartInfo={clientX:l,clientY:h,index:_,position:v},this._focusedAnchorIndex=_,this.notifyChange("state"),this._emitThumbDragEvent({index:_,state:"start",value:p});const g=this.values[_];p!==g&&this._emitThumbDragEvent({index:_,state:"drag",value:g}),document.addEventListener("pointerup",this._onAnchorPointerUp),document.addEventListener("pointermove",this._onAnchorPointerMove)}_onTrackPointerMove(e){e.preventDefault(),this._dragged=!0}_onTrackPointerUp(e){if(e.preventDefault(),document.removeEventListener("pointermove",this._onTrackPointerMove),document.removeEventListener("pointerup",this._onTrackPointerUp),this.snapOnClickEnabled||(this._dragged=!1),!this._dragged){const t=this._getCursorPositionFromEvent(e),i=this._valueFromPosition(t);this._emitTrackClickEvent({value:i})}}_onSegmentPointerDown(e){e.preventDefault();const t=e.target,i=t["data-segment-index"],s=t["data-min-thumb-index"],o=t["data-max-thumb-index"];if(this._isDisabled()||n(s)||n(o))return;e.stopPropagation(),this._storeTrackDimensions(),document.addEventListener("pointerup",this._onSegmentPointerUp);const r=this._getAnchorDetails(s),a=this._getAnchorDetails(o);this.syncedSegmentsEnabled?(this.segmentElements.forEach((e=>e.classList.add(p.segmentElementActive))),this._anchorElements.forEach((e=>e.classList.add(p.anchorElementActive)))):(this.segmentElements.getItemAt(i).classList.add(p.segmentElementActive),this._anchorElements[r.index]?.classList.add(p.anchorElementActive),this._anchorElements[a.index]?.classList.add(p.anchorElementActive)),this._segmentDragStartInfo={cursorPosition:this._getCursorPositionFromEvent(e),index:i,details:this._normalizeSegmentDetails({min:r,max:a})},this.draggableSegmentsEnabled&&(document.addEventListener("pointermove",this._onSegmentPointerMove),this.notifyChange("state"),this._emitSegmentDragEvent({index:i,state:"start",thumbIndices:[s,o]}))}_onSegmentPointerMove(e){if(!this._segmentDragStartInfo)return;e.preventDefault();const{_trackHeight:t,_trackWidth:i,_segmentDragStartInfo:{index:n,cursorPosition:s,details:{min:o,max:r}}}=this,{index:a,position:l,value:h}=o,{index:d,position:c,value:m}=r;this._dragged=!0;const u=this._getCursorPositionFromEvent(e);if(u===s)return;const _=this._positionToPercent(s),p=this._positionToPercent(u)-_,v=this._positionToPercent(l)+p,g=this._positionToPercent(c)+p,{min:f}=this._getAnchorBoundsAsPercents(a),{max:b}=this._getAnchorBoundsAsPercents(d);let E=!1,x=!1;if(v<f?E=!0:g>b&&(x=!0),E){const{min:e,max:t}=this.viewModel.getBoundsForValueAtIndex(a),i=this._isPositionInverted()?t:e,n=i,s=m+(i-h),o=s-this.values[d];return void(this.syncedSegmentsEnabled?this._updateAnchorValuesByDifference(o):this._updateAnchorValues([a,d],[n,s]))}if(x){const{min:e,max:t}=this.viewModel.getBoundsForValueAtIndex(d),i=this._isPositionInverted()?e:t,n=i,s=h+(i-m),o=s-this.values[a];return void(this.syncedSegmentsEnabled?this._updateAnchorValuesByDifference(o):this._updateAnchorValues([a,d],[s,n]))}const k=this._isHorizontalLayout()?i:t,y=g/100*k,I=v/100*k,P=this.values,A=[P[a],P[d]],L=this._getValueForAnchorAtPosition(a,I),S=this._getValueForAnchorAtPosition(d,y);this.syncedSegmentsEnabled?this._updateAnchorValuesByDifference(L-A[0]):this._updateAnchorValues([a,d],[L,S]);[this.values[a],this.values[d]].every(((e,t)=>e===A[t]))||this._emitSegmentDragEvent({index:n,state:"drag",thumbIndices:[a,d]})}_onSegmentPointerUp(e){if(e.preventDefault(),document.removeEventListener("pointerup",this._onSegmentPointerUp),document.removeEventListener("pointermove",this._onSegmentPointerMove),!this._segmentDragStartInfo)return;const{_dragged:t,max:i,min:n,values:s}=this,{index:o,details:{min:{index:r},max:{index:a}}}=this._segmentDragStartInfo;if(this.segmentElements.forEach((e=>e.classList.remove(p.segmentElementActive))),this._anchorElements.forEach((e=>e.classList.remove(p.anchorElementActive))),this.draggableSegmentsEnabled){const e=i-n,t=s[r],l=s[a];this._lastMovedHandleIndex=t===l?t>e/2?r:a:null,this._dragged=!1,this._segmentDragStartInfo=null,this.notifyChange("state"),this._emitSegmentDragEvent({index:o,state:"stop",thumbIndices:[r,a]})}if(!t){const t=this._getCursorPositionFromEvent(e),i=this._valueFromPosition(t);this._emitSegmentClickEvent({index:o,value:i,thumbIndices:[r,a]})}}_onTickGroupClick(e){const t=e.target;if(t["data-config"]){const e=t["data-tick-config-index"],i=t["data-tick-group-index"],n=t["data-value"];this._emitTickClickEvent({configIndex:e,groupIndex:i,value:n})}}_storeTrackDimensions(){if(this.trackElement){const e=this._getDimensions(this.trackElement);this._trackHeight=e.height,this._trackWidth=e.width}}_onLabelPointerDown(){this._isDisabled()||(this._dragged=!1,document.addEventListener("pointerup",this._onAnchorPointerUp),document.addEventListener("pointermove",this._onAnchorPointerMove))}_onLabelPointerMove(){this._isDisabled()||(this._dragged=!0)}_onLabelPointerUp(e){if(this._isDisabled())return;const t=e.target["data-thumb-index"];this.labelInputsEnabled&&!this._dragged&&s(t)&&(this._activeLabelInputIndex=t),this._dragged=!1,this.notifyChange("state"),document.removeEventListener("pointerup",this._onLabelPointerUp),document.removeEventListener("pointermove",this._onLabelPointerMove)}_onLabelInputBlur(e){const{_activeLabelInputIndex:t,values:i,viewModel:n}=this,s=e.target.value;if(this._activeLabelInputIndex=null,this.notifyChange("state"),!s)return;const o=this._parseInputValue(s,"value",t),r=i[t],{min:a,max:l}=this.viewModel.getBoundsForValueAtIndex(t);if(o<a||o>l)return;n.setValue(t,o);const h=this.values[t];r!==h&&this._emitThumbChangeEvent({index:t,oldValue:r,value:h})}_onInputKeyDown(e){if(this._isDisabled())return;const{target:t}=e,n=i(e),{hideInput1:o,hideInput2:r,hideInput3:a}=v,{_activeLabelInputIndex:l,_anchorElements:h}=this,d=t;if(n===o||n===r||n===a){e.stopPropagation();const t=l;d.blur(),s(t)?h[t].focus():d.parentElement.focus()}}_onMaxLabelClick(){this._isDisabled()||(this._emitRangeLabelClickEvent({type:"max-click",value:this.max}),this.rangeLabelInputsEnabled&&(this._isMaxInputActive=!0,this.notifyChange("state")))}_onMaxLabelKeyDown(e){this._isDisabled()||i(e)!==v.showInput||(this._isMaxInputActive=!0,this.notifyChange("state"))}_onMaxInputBlur(e){const t=e.target.value;if(this._isMaxInputActive=!1,this.notifyChange("state"),!t)return;const i=this.max,n=this._parseInputValue(t,"max");n<=this.min||(this.viewModel.set("max",n),this.max!==i&&this._emitMaxChangeEvent({oldValue:i,value:this.max}))}_onMinLabelClick(){this._isDisabled()||(this._emitRangeLabelClickEvent({type:"min-click",value:this.min}),this.rangeLabelInputsEnabled&&(this._isMinInputActive=!0,this.notifyChange("state")))}_onMinLabelKeyDown(e){this._isDisabled()||i(e)!==v.showInput||(this._isMinInputActive=!0,this.notifyChange("state"))}_onMinInputBlur(e){const t=e.target.value;if(this._isMinInputActive=!1,this.notifyChange("state"),!t)return;const i=this.min,n=this._parseInputValue(t,"min");n>=this.max||(this.viewModel.set("min",n),this.min!==i&&this._emitMinChangeEvent({oldValue:i,value:this.min}))}_isDisabled(){return this.disabled||"disabled"===this.state}_positionFromValue(e){const{max:t,min:i}=this,n=t-i;if(0===n)return 0;const{_trackHeight:s,_trackWidth:o}=this,r=this._isHorizontalLayout();let a=r?parseFloat((o*(e-i)/n).toFixed(2)):parseFloat((s*(t-e)/n).toFixed(2));return this._isReversedLayout()&&(a=r?o-a:s-a),a}_valueFromPosition(e){const{_trackHeight:t,_trackWidth:i,max:n,min:s,precision:o}=this,r=n-s;let a=this._isHorizontalLayout()?e*r/i+s:r*(1e3-e/t*1e3)/1e3+s;return this._isReversedLayout()&&(a=n+s-a),parseFloat(a.toFixed(o))}_positionToPercent(e){const{_trackHeight:t,_trackWidth:i}=this,n=100*e/(this._isHorizontalLayout()?i:t);return this._applyPrecisionToPosition(n)}_applyPrecisionToPosition(e){return parseFloat(e.toFixed(this._positionPrecision))}_isPositionInverted(){const{layout:e}=this;return"horizontal-reversed"===e||"vertical"===e}_isHorizontalLayout(){return this.layout.includes("horizontal")}_isReversedLayout(){return this.layout.includes("reversed")}_normalizeSegmentDetails(e){if(this._isPositionInverted()){const{min:t,max:i}=e;return{min:i,max:t}}return e}_parseInputValue(e,t,i){return this.inputParseFunction?this.inputParseFunction(e,t,i):this.viewModel.defaultInputParseFunction(e)}_formatInputValue(e,t,i){return this.inputFormatFunction?this.inputFormatFunction(e,t,i):this.viewModel.defaultInputFormatFunction(e)}_getAnchorDetails(e){const t=[...this.values].sort(((e,t)=>e-t))[e],i=this.values.indexOf(t);return{index:i,position:this._getPositionOfElement(this._anchorElements[i]),value:t}}_updateAnchorStyle(e,t){const i=this._anchorElements[e];i&&(this._isHorizontalLayout()?i.style.left=`${t}`:i.style.top=`${t}`)}_getStyleForAnchor(e,t,i){const n=this._getPositionStyleForElement(e);if(1===this.values.length)return`${n}`;const s=this._zIndices[t];return`${n}; z-index: ${i?this._zIndexOffset+s:s}`}_getPositionStyleForElement(e){const t=this._positionFromValue(e),i=this._positionToPercent(t);return`${this._isHorizontalLayout()?"left":"top"}: ${i+"%"}`}_getPositionOfElement(e){const t=this._getDimensions(e.offsetParent),i=this._getDimensions(e);return this._isHorizontalLayout()?this._applyPrecisionToPosition(i.left-t.left):this._applyPrecisionToPosition(i.top-t.top)}_updateAnchorValues(e,t){e.forEach(((e,i)=>this._toValue(e,t[i])))}_updateAnchorValuesByDifference(e){const{min:t,max:i,values:n}=this;n.forEach(((n,s)=>this._toValue(s,Math.max(Math.min(n+e,i),t))))}_toValue(e,t){if(s(this.steps)){t=this._getStepValues()[this._getIndexOfNearestStepValue(t)]}this._updateAnchorStyle(e,this._getPositionStyleForElement(t)),this.viewModel.setValue(e,t)}_toPosition(e,t){const i=s(this.steps)?this._getStepValueForAnchorAtPosition(e,t):this._getValueForAnchorAtPosition(e,t);this._updateAnchorStyle(e,this._getPositionStyleForElement(i)),this.viewModel.setValue(e,i)}_getValueForAnchorAtPosition(e,t){const{min:i,max:n}=this._getAnchorBoundsInPixels(e),{min:s,max:o}=this.viewModel.getBoundsForValueAtIndex(e);let r,a,l=null;return this._isPositionInverted()?(r=s,a=o):(r=o,a=s),l=t>n?r:t<i?a:this._valueFromPosition(t),l>o?l=o:l<s&&(l=s),l}_getStepValueForAnchorAtPosition(e,t){const i=this._getStepValues(),n=this._calculateNearestStepPosition(t),s=this._getValueForAnchorAtPosition(e,n);return i[this._getIndexOfNearestStepValue(s)]}_getAnchorBoundsAsPercents(e){const{min:t,max:i}=this._getAnchorBoundsInPixels(e);return{min:this._positionToPercent(t),max:this._positionToPercent(i)}}_getAnchorBoundsInPixels(e){const{_anchorElements:t,_trackHeight:i,_trackWidth:n,effectiveMax:o,effectiveMin:r,thumbsConstrained:a}=this,l=t[e-1],h=t[e+1],d=this._isHorizontalLayout()?n:i;let c,m;return this._isPositionInverted()?(c=s(r)?this._positionFromValue(r):d,m=s(o)?this._positionFromValue(o):0):(c=s(o)?this._positionFromValue(o):d,m=s(r)?this._positionFromValue(r):0),a?this._isPositionInverted()?{max:l?this._getPositionOfElement(l):c,min:h?this._getPositionOfElement(h):m}:{max:h?this._getPositionOfElement(h):c,min:l?this._getPositionOfElement(l):m}:{max:c,min:m}}_getIndexOfNearestValue(e){return this.values.indexOf(this.values.reduce(((t,i)=>Math.abs(i-e)<Math.abs(t-e)?i:t)))}_getCursorPositionFromEvent(e){const t=this._getDimensions(this.trackElement);return this._isHorizontalLayout()?e.clientX-t.left:e.clientY-t.top}_getStepValues(){const{steps:e}=this;if(Array.isArray(e))return e;const{max:t,min:i}=this,n=Math.ceil((t-i)/e),s=[];for(let o=0;o<=n;o++){const n=i+e*o;s.push(n>t?t:n)}return s}_toStep(e,t){const{values:i,viewModel:n}=this,s=i[e],o=this._getStepValues(),r=o.indexOf(s);let a=null;if(r>-1){let i=o[r+t];isNaN(i)&&(i=o[r]);const n=this._positionFromValue(i);a=this._getStepValueForAnchorAtPosition(e,n)}else{a=o[this._getIndexOfNearestStepValue(s)+t]}n.setValue(e,a)}_getIndexOfNearestStepValue(e){const{steps:t}=this;if(n(t))return null;const i=this._getStepValues(),s=i.reduce(((t,i)=>Math.abs(i-e)<Math.abs(t-e)?i:t));return i.indexOf(s)}_calculateNearestStepPosition(e){const t=this._valueFromPosition(e),i=this._getIndexOfNearestStepValue(t),n=this._getStepValues();return this._positionFromValue(n[i])}_getTickCounts(e,t){const{mode:i}=t;return"count"===i||"position"===i?e||0:"percent"===i&&100/e||0}_calculateTickPositions(e){return e.map((e=>this._positionFromValue(e)))}_calculateEquidistantTickPositions(e){const{_trackWidth:t,_trackHeight:i}=this,n=this._isHorizontalLayout()?t:i,s=n/(e-1),o=[];if(1===e)return[n/2];for(let r=0;r<e;r++){const e=r*s;e<=n&&o.push(e)}return o}_getDimensions(e){try{return e.getBoundingClientRect()}catch(t){if("object"==typeof t&&null!==t)return new DOMRect(0,0,0,0);throw t}}_emitTrackClickEvent(e){this.emit("track-click",{...e,type:"track-click"})}_emitTickClickEvent(e){this.emit("tick-click",{...e,type:"tick-click"})}_emitMaxChangeEvent(e){this.emit("max-change",{...e,type:"max-change"})}_emitMinChangeEvent(e){this.emit("min-change",{...e,type:"min-change"})}_emitThumbChangeEvent(e){this.emit("thumb-change",{...e,type:"thumb-change"})}_emitThumbClickEvent(e){this.emit("thumb-click",{...e,type:"thumb-click"})}_emitThumbDragEvent(e){this.emit("thumb-drag",{...e,type:"thumb-drag"})}_emitSegmentClickEvent(e){this.emit("segment-click",{...e,type:"segment-click"})}_emitSegmentDragEvent(e){this.emit("segment-drag",{...e,type:"segment-drag"})}_emitRangeLabelClickEvent(e){this.emit(e.type,{...e})}};e([a()],b.prototype,"disabled",void 0),e([a()],b.prototype,"draggableSegmentsEnabled",void 0),e([o("viewModel.effectiveMax")],b.prototype,"effectiveMax",void 0),e([o("viewModel.effectiveMin")],b.prototype,"effectiveMin",void 0),e([a({readOnly:!0})],b.prototype,"effectiveSegmentElements",void 0),e([a()],b.prototype,"extraNodes",void 0),e([a()],b.prototype,"inputCreatedFunction",void 0),e([o("viewModel.inputFormatFunction")],b.prototype,"inputFormatFunction",void 0),e([o("viewModel.inputParseFunction")],b.prototype,"inputParseFunction",void 0),e([a({aliasOf:{source:"messages.widgetLabel",overridable:!0}})],b.prototype,"label",void 0),e([a({readOnly:!0})],b.prototype,"labelElements",void 0),e([a()],b.prototype,"labelInputsEnabled",void 0),e([o("viewModel.labelFormatFunction")],b.prototype,"labelFormatFunction",void 0),e([o("viewModel.labels")],b.prototype,"labels",void 0),e([a({value:"horizontal"})],b.prototype,"layout",null),e([o("viewModel.max")],b.prototype,"max",void 0),e([a({readOnly:!0})],b.prototype,"maxLabelElement",void 0),e([a(),m("esri/widgets/Slider/t9n/Slider")],b.prototype,"messages",void 0),e([o("viewModel.min")],b.prototype,"min",void 0),e([a({readOnly:!0})],b.prototype,"minLabelElement",void 0),e([o("viewModel.precision")],b.prototype,"precision",void 0),e([a()],b.prototype,"rangeLabelInputsEnabled",void 0),e([a({readOnly:!0})],b.prototype,"segmentElements",void 0),e([a()],b.prototype,"snapOnClickEnabled",void 0),e([a({readOnly:!0})],b.prototype,"state",null),e([a()],b.prototype,"steps",void 0),e([a()],b.prototype,"syncedSegmentsEnabled",void 0),e([o("viewModel.thumbsConstrained")],b.prototype,"thumbsConstrained",void 0),e([a()],b.prototype,"thumbCreatedFunction",void 0),e([a({readOnly:!0})],b.prototype,"thumbElements",void 0),e([a()],b.prototype,"tickConfigs",null),e([a({readOnly:!0})],b.prototype,"tickElements",void 0),e([a({readOnly:!0})],b.prototype,"trackElement",void 0),e([o("viewModel.values")],b.prototype,"values",void 0),e([a()],b.prototype,"viewModel",void 0),e([a()],b.prototype,"visibleElements",void 0),e([r("visibleElements")],b.prototype,"castVisibleElements",null),b=e([l(g)],b);const E=b;export{E as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- import{_ as s}from"../../chunks/tslib.es6.js";import e from"../../core/Accessor.js";import i from"../../core/Logger.js";import{isSome as t,abortMaybe as n,isNone as o,applySome as r}from"../../core/maybe.js";import{createTask as a,throwIfAborted as l,isAbortError as h,isAborted as c}from"../../core/promiseUtils.js";import{watch as w,syncAndInitial as y,whenOnce as p,when as u}from"../../core/reactiveUtils.js";import{property as v}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import{subclass as _}from"../../core/accessorSupport/decorators/subclass.js";var d;!function(s){s[s.PENDING=0]="PENDING",s[s.WAIT_FOR_VIEW_READY=1]="WAIT_FOR_VIEW_READY",s[s.RUNNING=2]="RUNNING"}(d||(d={}));let V=class extends e{constructor(s={}){super(s),this.analysisView=null,this._reconnectViewTask=null,this._parentChangeFromReconnect=!1,this._startUserOperation=null,this.logger=i.getLogger(this.declaredClass);const e=s?.analysis;t(e)?this.analysis=e:(this._set("analysis",this.constructAnalysis()),this._set("isAnalysisOwner",!0)),s&&null!=s.visible&&(this.visible=s.visible)}normalizeCtorArgs(s){const{analysis:e,...i}=s;return i}initialize(){this.own([w((()=>({readyAndNotSupported:t(this.view)&&this.view.ready&&!this.supported})),(({readyAndNotSupported:s})=>{s&&this.logger.errorOnce(this.unsupportedErrorMessage)}),y),w((()=>r(this.analysis,(({parent:s})=>s))),(s=>{this._parentChangeFromReconnect||s===this.view||this._set("isAnalysisOwner",!1);const e=!this._parentChangeFromReconnect;this._parentChangeFromReconnect=!1,e&&this._scheduleViewReconnect()})),w((()=>({view:this.view,ready:t(this.view)&&this.view.ready,supported:this.supported})),(({view:s},{view:e})=>{s!==e&&(this._startUserOperation=n(this._startUserOperation),this._disconnectFromView(e)),this._scheduleViewReconnect()}),y),w((()=>this.analysis.isEditable),(s=>{o(this.analysisView)||(s&&o(this.tool)?this.createTool():s||!t(this.tool)||this.tool.active||this.removeTool())}))])}destroy(){this.removeTool(),this._reconnectViewTask=n(this._reconnectViewTask),this._startUserOperation=n(this._startUserOperation),t(this.analysisView)&&(this.analysisView.visible=void 0),this._disconnectFromView(this.view),this._set("view",null),t(this.analysis)&&this.isAnalysisOwner&&(this.analysis.destroy(),this._set("analysis",null))}get supported(){return o(this.view)||this.view.type===this.supportedViewType}get view(){return this._get("view")}set view(s){s!==this._get("view")&&(this.removeTool(),this._set("view",s))}set visible(s){this._set("visible",s),t(this.analysisView)&&(this.analysisView.visible=s),t(this.tool)&&(this.tool.visible=s)}get active(){return t(this.tool)&&this.tool.active}get disabled(){return o(this.view)||!this.view.ready||!this.supported}set analysis(s){s!==this._get("analysis")&&(this._startUserOperation=n(this._startUserOperation),this._disconnectFromView(this.view),this._setExternalAnalysis(s),this._scheduleViewReconnect())}get ready(){return t(this.analysisView)&&!this.connectingToView}get connectingToView(){return t(this._reconnectViewTask)}get isAnalysisOwner(){return this._get("isAnalysisOwner")}get tool(){return t(this.analysisView)?this.analysisView.tool:null}clear(){this._startUserOperation=n(this._startUserOperation),this.removeTool(),this.clearAnalysis()}async start(){this.clear();const s={task:null,abort:null,state:d.PENDING},e=a((async e=>{if(s.state=d.WAIT_FOR_VIEW_READY,await p((()=>this.ready),e),s.state=d.RUNNING,o(this.analysisView)||o(this.view))return;this.createTool();const i=this.analysisView.tool;o(i)||(this.view.activeTool=i,u((()=>i.created),(()=>{i.active&&t(this.view)&&(this.view.activeTool=null)}),{initial:!0,once:!0}))}));return s.task=e,s.abort=()=>e.abort(),this._startUserOperation=s,e.promise}onConnectToAnalysisView(s){}onDisconnectFromAnalysisView(){}_scheduleViewReconnect(){this._reconnectViewTask=n(this._reconnectViewTask);const s=a((async e=>{try{await this._reconnectView(e)}catch(i){if(l(e),!h(i))return void this.logger.warn("Failed to use analysis in view model",i);throw i}finally{s===this._reconnectViewTask&&(this._reconnectViewTask=null)}}));this._reconnectViewTask=s}async _reconnectView(s){const{view:e}=this,i=t(e)&&e.ready&&this.supported,n=this.analysis;if(this._startUserOperation=m(this._startUserOperation),this._disconnectFromView(e),i&&!o(e)&&!o(n)){if(this.isAnalysisOwner){if(t(n.parent))return void this.logger.errorOnce("expected owned analysis to have null parent when connecting to view");this._parentChangeFromReconnect=!0,e.analyses.add(n)}if(this.analysisView=await e.whenAnalysisView(n),c(s))return this._startUserOperation=m(this._startUserOperation),void this._disconnectFromView(e);this.analysisView.visible=this.visible,this.onConnectToAnalysisView(this.analysisView),this.createTool(),this._removeToolIfAnalysisIsIncomplete()}}_disconnectFromView(s){t(s)&&this.isAnalysisOwner&&s.analyses.includes(this.analysis)&&(this._parentChangeFromReconnect=!0,s.analyses.remove(this.analysis),this.clearAnalysis()),this.onDisconnectFromAnalysisView(),this.removeTool(),this.analysisView=null}_setExternalAnalysis(s){if(t(this.analysisView)&&!this.isAnalysisOwner&&(this.analysisView.visible=void 0),this.analysisView=null,this._set("analysis",s),this._set("isAnalysisOwner",!1),this._parentChangeFromReconnect=!1,!s.isEditable){const e=s.nonEditableMessage;this.logger.warn(`The assigned ${s.type} analysis object will not be editable in the view. ${e}`)}}createTool(){if(this.removeTool(),o(this.analysisView)||!this.supported)return;this.analysisView.interactive=!0;const s=this.analysisView.tool;t(s)&&(s.visible=this.visible)}removeTool(){o(this.analysisView)||(this.analysisView.interactive=!1)}_removeToolIfAnalysisIsIncomplete(){if(o(this.analysisView))return;const s=this.analysisView.tool;o(s)||s.created||this.removeTool()}get testInfo(){return{analysisView:this.analysisView}}};function m(s){return t(s)&&s.state>=d.RUNNING?(s.abort(),null):s}s([v()],V.prototype,"supported",null),s([v({value:null})],V.prototype,"view",null),s([v({type:Boolean,value:!0})],V.prototype,"visible",null),s([v()],V.prototype,"active",null),s([v()],V.prototype,"disabled",null),s([v({nonNullable:!0})],V.prototype,"analysis",null),s([v()],V.prototype,"analysisView",void 0),s([v()],V.prototype,"ready",null),s([v()],V.prototype,"connectingToView",null),s([v({readOnly:!0})],V.prototype,"isAnalysisOwner",null),s([v()],V.prototype,"_reconnectViewTask",void 0),s([v()],V.prototype,"tool",null),V=s([_("esri.widgets.support.AnalysisViewModel")],V);export{V as AnalysisViewModel};
5
+ import{_ as s}from"../../chunks/tslib.es6.js";import e from"../../core/Accessor.js";import i from"../../core/Logger.js";import{isSome as t,abortMaybe as n,isNone as o,applySome as a}from"../../core/maybe.js";import{createTask as r,throwIfAborted as l,isAbortError as h,isAborted as c}from"../../core/promiseUtils.js";import{watch as y,syncAndInitial as w,whenOnce as p,when as u}from"../../core/reactiveUtils.js";import{property as v}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import{subclass as _}from"../../core/accessorSupport/decorators/subclass.js";var d;!function(s){s[s.PENDING=0]="PENDING",s[s.WAIT_FOR_VIEW_READY=1]="WAIT_FOR_VIEW_READY",s[s.RUNNING=2]="RUNNING"}(d||(d={}));let V=class extends e{constructor(s={}){super(s),this.analysisView=null,this._reconnectViewTask=null,this._parentChangeFromReconnect=!1,this._startUserOperation=null,this.logger=i.getLogger(this.declaredClass);const e=s?.analysis;t(e)?this.analysis=e:(this._set("analysis",this.constructAnalysis()),this._set("isAnalysisOwner",!0)),s&&null!=s.visible&&(this.visible=s.visible)}normalizeCtorArgs(s){const{analysis:e,...i}=s;return i}initialize(){this.own([y((()=>({readyAndNotSupported:t(this.view)&&this.view.ready&&!this.supported})),(({readyAndNotSupported:s})=>{s&&this.logger.errorOnce(this.unsupportedErrorMessage)}),w),y((()=>a(this.analysis,(({parent:s})=>s))),(s=>{this._parentChangeFromReconnect||s===this.view||this._set("isAnalysisOwner",!1);const e=!this._parentChangeFromReconnect;this._parentChangeFromReconnect=!1,e&&this._scheduleViewReconnect()})),y((()=>({view:this.view,ready:t(this.view)&&this.view.ready,supported:this.supported})),(({view:s},{view:e})=>{s!==e&&(this._startUserOperation=n(this._startUserOperation),this._disconnectFromView(e)),this._scheduleViewReconnect()}),w),y((()=>this.analysis.isEditable),(s=>{o(this.analysisView)||(s&&o(this.tool)?this.createTool():s||!t(this.tool)||this.tool.active||this.removeTool())}))])}destroy(){this.removeTool(),this._reconnectViewTask=n(this._reconnectViewTask),this._startUserOperation=n(this._startUserOperation),t(this.analysisView)&&(this.analysisView.visible=void 0),this._disconnectFromView(this.view),this._set("view",null),t(this.analysis)&&this.isAnalysisOwner&&(this.analysis.destroy(),this._set("analysis",null))}get supported(){return o(this.view)||this.view.type===this.supportedViewType}get view(){return this._get("view")}set view(s){s!==this._get("view")&&(this.removeTool(),this._set("view",s))}set visible(s){this._set("visible",s),t(this.analysisView)&&(this.analysisView.visible=s),t(this.tool)&&(this.tool.visible=s)}get active(){return t(this.tool)&&this.tool.active}get disabled(){return o(this.view)||!this.view.ready||!this.supported}set analysis(s){s!==this._get("analysis")&&(this._startUserOperation=n(this._startUserOperation),this._disconnectFromView(this.view),this._setExternalAnalysis(s),this._scheduleViewReconnect())}get ready(){return t(this.analysisView)&&!this.connectingToView}get connectingToView(){return t(this._reconnectViewTask)}get isAnalysisOwner(){return this._get("isAnalysisOwner")}get tool(){return t(this.analysisView)?this.analysisView.tool:null}clear(){this._startUserOperation=n(this._startUserOperation),this.removeTool(),this.clearAnalysis()}async start(){this.clear();const s={task:null,abort:null,state:d.PENDING},e=r((async e=>{if(s.state=d.WAIT_FOR_VIEW_READY,await p((()=>this.ready),e),s.state=d.RUNNING,o(this.analysisView)||o(this.view))return;this.createTool();const i=this.analysisView.tool;o(i)||(this.view.activeTool=i,u((()=>i.created),(()=>{i.active&&t(this.view)&&(this.view.activeTool=null)}),{initial:!0,once:!0}))}));return s.task=e,s.abort=()=>e.abort(),this._startUserOperation=s,e.promise}onConnectToAnalysisView(s){}onDisconnectFromAnalysisView(){}_scheduleViewReconnect(){this._reconnectViewTask=n(this._reconnectViewTask);const s=r((async e=>{try{await this._reconnectView(e)}catch(i){if(l(e),!h(i))return void this.logger.warn("Failed to use analysis in view model",i);throw i}finally{s===this._reconnectViewTask&&(this._reconnectViewTask=null)}}));this._reconnectViewTask=s}async _reconnectView(s){const{view:e}=this,i=t(e)&&e.ready&&this.supported,n=this.analysis;if(this._startUserOperation=m(this._startUserOperation),this._disconnectFromView(e),i&&!o(e)&&!o(n)){if(this.isAnalysisOwner){if(t(n.parent))return void this.logger.errorOnce("expected owned analysis to have null parent when connecting to view");this._parentChangeFromReconnect=!0,e.analyses.add(n)}this.analysisView=await e.whenAnalysisView(n),c(s)?this._startUserOperation=m(this._startUserOperation):(this.analysisView.visible=this.visible,this.onConnectToAnalysisView(this.analysisView),this.createTool(),this._removeToolIfAnalysisIsIncomplete())}}_disconnectFromView(s){t(s)&&this.isAnalysisOwner&&s.analyses.includes(this.analysis)&&(this._parentChangeFromReconnect=!0,s.analyses.remove(this.analysis),this.clearAnalysis()),this.onDisconnectFromAnalysisView(),this.removeTool(),this.analysisView=null}_setExternalAnalysis(s){if(t(this.analysisView)&&!this.isAnalysisOwner&&(this.analysisView.visible=void 0),this.analysisView=null,this._set("analysis",s),this._set("isAnalysisOwner",!1),this._parentChangeFromReconnect=!1,!s.isEditable){const e=s.nonEditableMessage;this.logger.warn(`The assigned ${s.type} analysis object will not be editable in the view. ${e}`)}}createTool(){if(this.removeTool(),o(this.analysisView)||!this.supported)return;this.analysisView.interactive=!0;const s=this.analysisView.tool;t(s)&&(s.visible=this.visible)}removeTool(){o(this.analysisView)||(this.analysisView.interactive=!1)}_removeToolIfAnalysisIsIncomplete(){if(o(this.analysisView))return;const s=this.analysisView.tool;o(s)||s.created||this.removeTool()}get testInfo(){return{analysisView:this.analysisView}}};function m(s){return t(s)&&s.state>=d.RUNNING?(s.abort(),null):s}s([v()],V.prototype,"supported",null),s([v({value:null})],V.prototype,"view",null),s([v({type:Boolean,value:!0})],V.prototype,"visible",null),s([v()],V.prototype,"active",null),s([v()],V.prototype,"disabled",null),s([v({nonNullable:!0})],V.prototype,"analysis",null),s([v()],V.prototype,"analysisView",void 0),s([v()],V.prototype,"ready",null),s([v()],V.prototype,"connectingToView",null),s([v({readOnly:!0})],V.prototype,"isAnalysisOwner",null),s([v()],V.prototype,"_reconnectViewTask",void 0),s([v()],V.prototype,"tool",null),V=s([_("esri.widgets.support.AnalysisViewModel")],V);export{V as AnalysisViewModel};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- import{_ as s}from"../../chunks/tslib.es6.js";import i from"../../core/Handles.js";import{isSome as e,destroyMaybe as t,abortMaybe as n,isNone as a,applySome as o}from"../../core/maybe.js";import{createTask as r,throwIfAborted as l,isAbortError as c,isAborted as h}from"../../core/promiseUtils.js";import{watch as y,syncAndInitial as w,whenOnce as p}from"../../core/reactiveUtils.js";import{property as d}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import{subclass as _}from"../../core/accessorSupport/decorators/subclass.js";import{InteractiveToolViewModel as V}from"./InteractiveToolViewModel.js";let m=class extends V{constructor(s={}){super(s),this.analysisView=null,this._reconnectViewTask=null,this._analysisBaseHandles=new i,this._parentChangeFromReconnect=!1,this._startTask=null;const t=s?.analysis;e(t)?this.analysis=t:(this._set("analysis",this.constructAnalysis()),this._set("isAnalysisOwner",!0))}normalizeCtorArgs(s){const{analysis:i,...e}=s;return e}initialize(){this._analysisBaseHandles.add([y((()=>o(this.analysis,(({parent:s})=>s))),(s=>{this._parentChangeFromReconnect||s===this.view||this._set("isAnalysisOwner",!1);const i=!this._parentChangeFromReconnect;this._parentChangeFromReconnect=!1,i&&this._scheduleViewReconnect()})),y((()=>({view:this.view,ready:e(this.view)&&this.view.ready,supported:this.supported})),(({view:s},{view:i})=>{s!==i&&this._disconnectFromView(i),this._scheduleViewReconnect()}),w),y((()=>this.analysis.isEditable),((s,i)=>{a(this.analysisView)||(s&&!i&&a(this.tool)?this.createTool():!s&&i&&e(this.tool)&&!this.tool.active&&this.removeTool())}))])}destroy(){this._analysisBaseHandles=t(this._analysisBaseHandles),this._reconnectViewTask=n(this._reconnectViewTask),e(this.analysisView)&&(this.analysisView.visible=void 0),this._disconnectFromView(this.view),e(this.analysis)&&this.isAnalysisOwner&&(this.analysis.destroy(),this._set("analysis",null))}set analysis(s){s!==this._get("analysis")&&(this._disconnectFromView(this.view),this._setExternalAnalysis(s),this._scheduleViewReconnect())}get ready(){return e(this.analysisView)&&!this.connectingToView}get connectingToView(){return e(this._reconnectViewTask)}get isAnalysisOwner(){return this._get("isAnalysisOwner")}set visible(s){this._set("visible",s),e(this.analysisView)&&(this.analysisView.visible=s),e(this.tool)&&(this.tool.visible=s)}async start(){this.clear();const s=r((async s=>{await p((()=>this.ready),s),this.createTool({interactive:!0})}));return this._startTask=s,s.promise}clear(){this._startTask=n(this._startTask),this.removeTool(),this.clearAnalysis()}onConnectToAnalysisView(s){}onDisconnectFromAnalysisView(){}_scheduleViewReconnect(){this._reconnectViewTask=n(this._reconnectViewTask);const s=r((async i=>{try{await this._reconnectView(i)}catch(e){if(l(i),!c(e))return void this.logger.warn("Failed to use analysis in view model",e);throw e}finally{s===this._reconnectViewTask&&(this._reconnectViewTask=null)}}));this._reconnectViewTask=s}async _reconnectView(s){const{view:i}=this,t=e(i)&&i.ready&&this.supported,n=this.analysis;if(this._disconnectFromView(i),t&&!a(i)&&!a(n)){if(this.isAnalysisOwner){if(e(n.parent))return void this.logError("expected owned analysis to have null parent when connecting to view");this._parentChangeFromReconnect=!0,i.analyses.add(n)}this.analysisView=await i.whenAnalysisView(n),h(s)?this._disconnectFromView(i):(this.analysisView.visible=this.visible,this.onConnectToAnalysisView(this.analysisView),this.createTool())}}_disconnectFromView(s){this._startTask=n(this._startTask),this.removeTool(),e(s)&&this.isAnalysisOwner&&(this._parentChangeFromReconnect=!0,s.analyses.remove(this.analysis),this.clearAnalysis()),this.analysisView=null,this.onDisconnectFromAnalysisView()}_setExternalAnalysis(s){if(e(this.analysisView)&&!this.isAnalysisOwner&&(this.analysisView.visible=!0),this.analysisView=null,this._set("analysis",s),this._set("isAnalysisOwner",!1),this._parentChangeFromReconnect=!1,!s.isEditable){const i=s.nonEditableMessage;this.logger.warn(`The assigned ${s.type} analysis object will not be editable in the view. ${i}`)}}get testInfo(){return{analysisView:this.analysisView}}};s([d({nonNullable:!0})],m.prototype,"analysis",null),s([d()],m.prototype,"analysisView",void 0),s([d()],m.prototype,"ready",null),s([d()],m.prototype,"connectingToView",null),s([d({readOnly:!0})],m.prototype,"isAnalysisOwner",null),s([d({type:Boolean,value:!0})],m.prototype,"visible",null),s([d()],m.prototype,"_reconnectViewTask",void 0),m=s([_("esri.widgets.support.InteractiveAnalysisViewModel")],m);export{m as InteractiveAnalysisViewModel};
5
+ import{_ as s}from"../../chunks/tslib.es6.js";import e from"../../core/Handles.js";import{isSome as i,abortMaybe as t,destroyMaybe as n,isNone as a,applySome as r}from"../../core/maybe.js";import{createTask as o,throwIfAborted as l,isAbortError as h,isAborted as c}from"../../core/promiseUtils.js";import{watch as y,syncAndInitial as w,whenOnce as p}from"../../core/reactiveUtils.js";import{property as _}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import{subclass as V}from"../../core/accessorSupport/decorators/subclass.js";import{InteractiveToolViewModel as d}from"./InteractiveToolViewModel.js";var u;!function(s){s[s.PENDING=0]="PENDING",s[s.WAIT_FOR_VIEW_READY=1]="WAIT_FOR_VIEW_READY",s[s.RUNNING=2]="RUNNING"}(u||(u={}));let m=class extends d{constructor(s={}){super(s),this.analysisView=null,this._reconnectViewTask=null,this._analysisBaseHandles=new e,this._parentChangeFromReconnect=!1,this._startUserOperation=null;const t=s?.analysis;i(t)?this.analysis=t:(this._set("analysis",this.constructAnalysis()),this._set("isAnalysisOwner",!0))}normalizeCtorArgs(s){const{analysis:e,...i}=s;return i}initialize(){this._analysisBaseHandles.add([y((()=>r(this.analysis,(({parent:s})=>s))),(s=>{this._parentChangeFromReconnect||s===this.view||this._set("isAnalysisOwner",!1);const e=!this._parentChangeFromReconnect;this._parentChangeFromReconnect=!1,e&&this._scheduleViewReconnect()})),y((()=>({view:this.view,ready:i(this.view)&&this.view.ready,supported:this.supported})),(({view:s},{view:e})=>{s!==e&&(this._startUserOperation=t(this._startUserOperation),this._disconnectFromView(e)),this._scheduleViewReconnect()}),w),y((()=>this.analysis.isEditable),((s,e)=>{a(this.analysisView)||(s&&!e&&a(this.tool)?this.createTool():!s&&e&&i(this.tool)&&!this.tool.active&&this.removeTool())}))])}destroy(){this._analysisBaseHandles=n(this._analysisBaseHandles),this._reconnectViewTask=t(this._reconnectViewTask),this._startUserOperation=t(this._startUserOperation),i(this.analysisView)&&(this.analysisView.visible=void 0),this._disconnectFromView(this.view),i(this.analysis)&&this.isAnalysisOwner&&(this.analysis.destroy(),this._set("analysis",null))}set analysis(s){s!==this._get("analysis")&&(this._startUserOperation=t(this._startUserOperation),this._disconnectFromView(this.view),this._setExternalAnalysis(s),this._scheduleViewReconnect())}get ready(){return i(this.analysisView)&&!this.connectingToView}get connectingToView(){return i(this._reconnectViewTask)}get isAnalysisOwner(){return this._get("isAnalysisOwner")}set visible(s){this._set("visible",s),i(this.analysisView)&&(this.analysisView.visible=s),i(this.tool)&&(this.tool.visible=s)}async start(){this.clear();const s={task:null,abort:null,state:u.PENDING},e=o((async e=>{s.state=u.WAIT_FOR_VIEW_READY,await p((()=>this.ready),e),s.state=u.RUNNING,this.createTool({interactive:!0})}));return s.task=e,s.abort=()=>e.abort(),this._startUserOperation=s,e.promise}clear(){this._startUserOperation=t(this._startUserOperation),this.removeTool(),this.clearAnalysis()}onConnectToAnalysisView(s){}onDisconnectFromAnalysisView(){}_scheduleViewReconnect(){this._reconnectViewTask=t(this._reconnectViewTask);const s=o((async e=>{try{await this._reconnectView(e)}catch(i){if(l(e),!h(i))return void this.logger.warn("Failed to use analysis in view model",i);throw i}finally{s===this._reconnectViewTask&&(this._reconnectViewTask=null)}}));this._reconnectViewTask=s}async _reconnectView(s){const{view:e}=this,t=i(e)&&e.ready&&this.supported,n=this.analysis;if(this._startUserOperation=v(this._startUserOperation),this._disconnectFromView(e),t&&!a(e)&&!a(n)){if(this.isAnalysisOwner){if(i(n.parent))return void this.logError("expected owned analysis to have null parent when connecting to view");this._parentChangeFromReconnect=!0,e.analyses.add(n)}this.analysisView=await e.whenAnalysisView(n),c(s)?this._startUserOperation=v(this._startUserOperation):(this.analysisView.visible=this.visible,this.onConnectToAnalysisView(this.analysisView),this.createTool())}}_disconnectFromView(s){this.removeTool(),i(s)&&this.isAnalysisOwner&&(this._parentChangeFromReconnect=!0,s.analyses.remove(this.analysis),this.clearAnalysis()),this.analysisView=null,this.onDisconnectFromAnalysisView()}_setExternalAnalysis(s){if(i(this.analysisView)&&!this.isAnalysisOwner&&(this.analysisView.visible=!0),this.analysisView=null,this._set("analysis",s),this._set("isAnalysisOwner",!1),this._parentChangeFromReconnect=!1,!s.isEditable){const e=s.nonEditableMessage;this.logger.warn(`The assigned ${s.type} analysis object will not be editable in the view. ${e}`)}}get testInfo(){return{analysisView:this.analysisView}}};function v(s){return i(s)&&s.state>=u.RUNNING?(s.abort(),null):s}s([_({nonNullable:!0})],m.prototype,"analysis",null),s([_()],m.prototype,"analysisView",void 0),s([_()],m.prototype,"ready",null),s([_()],m.prototype,"connectingToView",null),s([_({readOnly:!0})],m.prototype,"isAnalysisOwner",null),s([_({type:Boolean,value:!0})],m.prototype,"visible",null),s([_()],m.prototype,"_reconnectViewTask",void 0),m=s([V("esri.widgets.support.InteractiveAnalysisViewModel")],m);export{m as InteractiveAnalysisViewModel};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import r from"../../../core/Accessor.js";import o from"../../../core/Error.js";import{HandleOwnerMixin as s}from"../../../core/HandleOwner.js";import{watch as i,initial as t}from"../../../core/reactiveUtils.js";import{property as n}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as a}from"../../../core/accessorSupport/decorators/subclass.js";import p from"../../../views/interactive/snapping/FeatureSnappingLayerSource.js";import{canDisplayLayer as l}from"../../LayerList/support/layerListUtils.js";import{SnappingLayerListViewModel as c}from"./SnappingLayerListViewModel.js";const u="esri.widgets.support.SnappingControls.SnappingControlsViewModel";let d=class extends(s(r)){constructor(e){super(e),this.layerListViewModel=new c,this.snappingOptions=null,this.view=null}initialize(){this.handles.add([i((()=>({viewModel:this.layerListViewModel,view:this.view})),(({viewModel:e,view:r})=>{e.view=r}),t),i((()=>({viewModel:this.layerListViewModel,sources:this.snappingOptions?.featureSources})),(({viewModel:e,sources:r})=>{e.featureSnappingSources=r}),t)])}get state(){return this.get("snappingOptions")?"ready":"disabled"}enableSnappingForLayer(e){(this._findSnappingSourceForLayer(e)??this._makeSnappingSourceForLayer(e)).enabled=!0}disableSnappingForLayer(e){const r=this._findSnappingSourceForLayer(e);r&&(r.enabled=!1)}updateEnabledFeatureSources(e){for(const r of this.snappingOptions.featureSources)l(r.layer)&&(r.enabled=e.includes(r.layer.id))}_findSnappingSourceForLayer(e){return this.snappingOptions.featureSources.find((r=>r.layer.id===e))}_makeSnappingSourceForLayer(e){const r=this.view.map.layers.find((r=>r.id===e));if(!r)throw new o("snapping-controls:layer-not-found",`cannot enable snapping for layer with id ${e} because no such layer was found in the view`);const s=new p({layer:r});this.snappingOptions.featureSources.add(s);const i=this.layerListViewModel.operationalItemsFlat.find((r=>r.layer.id===e));return i&&(i.featureSource=s),s}};e([n({constructOnly:!0})],d.prototype,"layerListViewModel",void 0),e([n({constructOnly:!0})],d.prototype,"snappingOptions",void 0),e([n()],d.prototype,"state",null),e([n({constructOnly:!0})],d.prototype,"view",void 0),d=e([a(u)],d);const y=d;export{y as default};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import r from"../../../core/Accessor.js";import o from"../../../core/Error.js";import{HandleOwnerMixin as i}from"../../../core/HandleOwner.js";import{watch as s,initial as t}from"../../../core/reactiveUtils.js";import{property as n}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as a}from"../../../core/accessorSupport/decorators/subclass.js";import p from"../../../views/interactive/snapping/FeatureSnappingLayerSource.js";import{canDisplayLayer as l}from"../../LayerList/support/layerListUtils.js";import{SnappingLayerListViewModel as c}from"./SnappingLayerListViewModel.js";const d="esri.widgets.support.SnappingControls.SnappingControlsViewModel";let u=class extends(i(r)){constructor(e){super(e),this.layerListViewModel=new c,this.snappingOptions=null,this.view=null}initialize(){this.handles.add([s((()=>({viewModel:this.layerListViewModel,view:this.view})),(({viewModel:e,view:r})=>{e.view=r}),t),s((()=>({viewModel:this.layerListViewModel,sources:this.snappingOptions?.featureSources})),(({viewModel:e,sources:r})=>{e.featureSnappingSources=r}),t)])}get state(){return this.get("snappingOptions")?"ready":"disabled"}enableSnappingForLayer(e){(this._findSnappingSourceForLayer(e)??this._makeSnappingSourceForLayer(e)).enabled=!0}disableSnappingForLayer(e){const r=this._findSnappingSourceForLayer(e);r&&(r.enabled=!1)}updateEnabledFeatureSources(e){for(const r of this.snappingOptions.featureSources)l(r.layer)&&(r.enabled=e.includes(r.layer.id))}_findSnappingSourceForLayer(e){return this.snappingOptions.featureSources.find((r=>r.layer.id===e))}_makeSnappingSourceForLayer(e){const{layer:r}=this.layerListViewModel.operationalItemsFlat.find((r=>r.layer.id===e));if(!r)throw new o("snapping-controls:layer-not-found",`cannot enable snapping for layer with id ${e} because no such layer was found in the view`);const i=new p({layer:r});this.snappingOptions.featureSources.add(i);const s=this.layerListViewModel.operationalItemsFlat.find((r=>r.layer.id===e));return s&&(s.featureSource=i),i}};e([n({constructOnly:!0})],u.prototype,"layerListViewModel",void 0),e([n({constructOnly:!0})],u.prototype,"snappingOptions",void 0),e([n()],u.prototype,"state",null),e([n({constructOnly:!0})],u.prototype,"view",void 0),u=e([a(d)],u);const y=u;export{y as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- import{_ as r}from"../../../chunks/tslib.es6.js";import{isSome as e}from"../../../core/maybe.js";import{property as t}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as o}from"../../../core/accessorSupport/decorators/subclass.js";import s from"../../LayerList/ListItem.js";import{canDisplayLayer as i}from"../../LayerList/support/layerListUtils.js";import{isValidSnappingLayer as p}from"./snappingLayerListUtils.js";var a;let n=a=class extends s{constructor(){super(...arguments),this.featureSource=null}get enabled(){return!!e(this.featureSource)&&this.featureSource.enabled}_initializeChildLayers(r){const e=r.filter(p);super._initializeChildLayers(e)}_makeChildren(r){return r.map((r=>i(r)?new a({layer:r,parent:this,view:this.view}):null)).reverse()}};r([t()],n.prototype,"children",void 0),r([t()],n.prototype,"enabled",null),r([t()],n.prototype,"featureSource",void 0),r([t()],n.prototype,"parent",void 0),n=a=r([o("esri.widgets.support.SnappingControls.SnappingListItem")],n);export{n as SnappingListItem};
5
+ import{_ as r}from"../../../chunks/tslib.es6.js";import e from"../../../core/Collection.js";import{isSome as t}from"../../../core/maybe.js";import{property as o}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as s}from"../../../core/accessorSupport/decorators/subclass.js";import i from"../../LayerList/ListItem.js";import{canDisplayLayer as p}from"../../LayerList/support/layerListUtils.js";import{isValidSnappingLayer as a}from"./snappingLayerListUtils.js";var n;let l=n=class extends i{constructor(){super(...arguments),this.children=new e,this.featureSource=null}get enabled(){return!!t(this.featureSource)&&this.featureSource.enabled}_initializeChildLayers(r){const e=r.filter(a);super._initializeChildLayers(e)}_makeChildren(r){return r.map((r=>p(r)?new n({layer:r,parent:this,view:this.view}):null)).reverse()}};r([o()],l.prototype,"children",void 0),r([o()],l.prototype,"enabled",null),r([o()],l.prototype,"featureSource",void 0),r([o()],l.prototype,"parent",void 0),l=n=r([s("esri.widgets.support.SnappingControls.SnappingListItem")],l);export{l as SnappingListItem};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import{destroyMaybe as t,isNone as i}from"../../core/maybe.js";import{aliasOf as s}from"../../core/accessorSupport/decorators/aliasOf.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{cast as n}from"../../core/accessorSupport/decorators/cast.js";import{property as l}from"../../core/accessorSupport/decorators/property.js";import{subclass as o}from"../../core/accessorSupport/decorators/subclass.js";import a from"../Widget.js";import"./widgetUtils.js";import{messageBundle as r}from"./decorators/messageBundle.js";import{tsx as c}from"./jsxFactory.js";import d from"./SnappingControls/SnappingControlsViewModel.js";const p={header:!0,enabledToggle:!0,selfEnabledToggle:!0,featureEnabledToggle:!0,layerList:!0},g={base:"esri-snapping-controls",container:"esri-snapping-controls__container",panel:"esri-snapping-controls__panel",item:"esri-snapping-controls__item",toggleBlock:"esri-snapping-controls__toggle-block",layerListBlock:"esri-snapping-controls__layer-list-block",layerList:"esri-snapping-controls__layer-list",nestedContainer:"esri-snapping-controls__nested-container",disabled:"esri-disabled",esriWidget:"esri-widget",widgetIcon:"esri-icon-vertex-gps"};let h=class extends a{constructor(e,t){super((()=>{const{view:t,viewModel:i,snappingOptions:s,...n}=e;return n})(),t),this.label=void 0,this.messages=null,this.messagesCommon=null,this.snappingOptions=null,this.view=null,this.visibleElements={...p},this._defaultViewModel=null,e?.viewModel?this.viewModel=e.viewModel:(this._defaultViewModel=new d({snappingOptions:e.snappingOptions,view:e.view}),this.viewModel=this._defaultViewModel)}destroy(){this._defaultViewModel=t(this._defaultViewModel)}loadDependencies(){return Promise.all([import("@esri/calcite-components/dist/components/calcite-action.js"),import("@esri/calcite-components/dist/components/calcite-block.js"),import("@esri/calcite-components/dist/components/calcite-icon.js"),import("@esri/calcite-components/dist/components/calcite-label.js"),import("@esri/calcite-components/dist/components/calcite-panel.js"),import("@esri/calcite-components/dist/components/calcite-pick-list.js"),import("@esri/calcite-components/dist/components/calcite-pick-list-item.js"),import("@esri/calcite-components/dist/components/calcite-switch.js")])}set viewModel(e){e!==this._get("viewModel")&&((i(this._defaultViewModel)||this._defaultViewModel!==e)&&(this._defaultViewModel=t(this._defaultViewModel)),this._set("viewModel",e))}castVisibleElements(e){return{...p,...e}}render(){const{label:e,visibleElements:{header:t}}=this;return c("div",{"aria-label":e,class:this.classes(g.base,g.esriWidget)},c("div",{class:g.container},t?this.renderHeaderView():this.renderContent()))}renderHeaderView(){return c("calcite-panel",{heading:this.label,class:g.panel},this.renderContent())}renderContent(){return[this.renderToggles(),this.renderLayerList()]}renderToggles(){return c("calcite-block",{class:g.toggleBlock,heading:"",open:!0},this.renderEnabledToggle(),c("div",{class:g.nestedContainer},this.renderSelfEnabledToggle(),this.renderFeatureEnabledToggle()))}renderEnabledToggle(){if(!this.visibleElements.enabledToggle)return;const{messages:{enableSnapping:e},viewModel:{snappingOptions:{enabled:t,enabledToggled:i}}}=this;return c("calcite-label",{layout:"inline-space-between"},e,c("calcite-switch",{checked:t,disabled:i,bind:this,onCalciteSwitchChange:this._enableSnappingSwitchChange}))}renderSelfEnabledToggle(){if(!this.visibleElements.selfEnabledToggle)return;const{messages:{geometryGuides:e},viewModel:{snappingOptions:{enabled:t,selfEnabled:i,enabledToggled:s}}}=this;return c("calcite-label",{layout:"inline-space-between"},e,c("calcite-switch",{checked:i,disabled:s||!t,bind:this,onCalciteSwitchChange:this._selfEnabledSwitchChange}))}renderFeatureEnabledToggle(){if(!this.visibleElements.featureEnabledToggle)return;const{messages:{featureToFeature:e},viewModel:{snappingOptions:{enabled:t,featureEnabled:i,enabledToggled:s}}}=this;return c("calcite-label",{layout:"inline-space-between"},e,c("calcite-switch",{checked:i,disabled:s||!t,bind:this,onCalciteSwitchChange:this._featureEnabledSwitchChange}))}renderLayerList(){if(!this.visibleElements.layerList)return;const{messages:{snappingLayers:e,searchLayers:t}}=this;return c("calcite-block",{"intl-collapse":this.messagesCommon?.collapse,"intl-expand":this.messagesCommon?.expand,heading:e,class:g.layerListBlock,open:!0,collapsible:!0},c("calcite-pick-list",{class:g.layerList,multiple:!0,filterEnabled:this.viewModel.layerListViewModel.operationalItems.length>=10,"filter-placeholder":t},this.renderLayerListItemCollection(this.viewModel.layerListViewModel.operationalItems)))}renderLayerListItemCollection(e){return e.map((e=>e.children.length>0?this.renderLayerListItemGroup(e):this.renderLayerListItem(e))).toArray()}renderLayerListItem(e){const{messages:{untitledLayer:t}}=this,i=e.title||t,s=e.children?.length>0,n=e.enabled;return c("calcite-pick-list-item",{slot:s?"parent-item":null,key:`${this.id}-pick-list-item-${e.uid}`,label:i,value:e.layer.id,selected:n,bind:this,onCalciteListItemChange:this._handleLayerListItemChange})}renderLayerListItemGroup(e){const t=e.title||this.messages.untitledLayer;return c("calcite-pick-list-group",{"group-title":t,key:e.uid},[...this.renderLayerListItemCollection(e.children)])}_enableSnappingSwitchChange(e){this.snappingOptions.enabled=e.target.checked}_featureEnabledSwitchChange(e){this.snappingOptions.featureEnabled=e.target.checked}_selfEnabledSwitchChange(e){this.snappingOptions.selfEnabled=e.target.checked}async _handleLayerListItemChange(e){const{target:t}=e;t.selected?this.viewModel.enableSnappingForLayer(t.value):this.viewModel.disableSnappingForLayer(t.value)}};e([l({aliasOf:{source:"messages.widgetLabel",overridable:!0}})],h.prototype,"label",void 0),e([l(),r("esri/widgets/support/SnappingControls/t9n/SnappingControls")],h.prototype,"messages",void 0),e([l(),r("esri/t9n/common")],h.prototype,"messagesCommon",void 0),e([s("viewModel.snappingOptions")],h.prototype,"snappingOptions",void 0),e([s("viewModel.view")],h.prototype,"view",void 0),e([l()],h.prototype,"viewModel",null),e([l()],h.prototype,"visibleElements",void 0),e([n("visibleElements")],h.prototype,"castVisibleElements",null),h=e([o("esri.widgets.support.SnappingControls")],h);const m=h;export{m as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import{destroyMaybe as t,isNone as i,unwrap as s}from"../../core/maybe.js";import{generateUID as l}from"../../core/uid.js";import{aliasOf as n}from"../../core/accessorSupport/decorators/aliasOf.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{cast as a}from"../../core/accessorSupport/decorators/cast.js";import{property as r}from"../../core/accessorSupport/decorators/property.js";import{subclass as o}from"../../core/accessorSupport/decorators/subclass.js";import c from"../Widget.js";import"./widgetUtils.js";import{messageBundle as p}from"./decorators/messageBundle.js";import{tsx as d}from"./jsxFactory.js";import m from"./SnappingControls/SnappingControlsViewModel.js";const h={header:!0,enabledToggle:!0,selfEnabledToggle:!0,featureEnabledToggle:!0,layerList:!0},g={base:"esri-snapping-controls",container:"esri-snapping-controls__container",panel:"esri-snapping-controls__panel",item:"esri-snapping-controls__item",toggleBlock:"esri-snapping-controls__toggle-block",layerListBlock:"esri-snapping-controls__layer-list-block",layerList:"esri-snapping-controls__layer-list",layerListFilter:"esri-snapping-controls__layer-list__filter",layerListItem:"esri-snapping-controls__layer-list__item",layerListItemCheckbox:"esri-snapping-controls__layer-list__item__checkbox",layerListItemLabel:"esri-snapping-controls__layer-list__item__label",nestedContainer:"esri-snapping-controls__nested-container",disabled:"esri-disabled",esriWidget:"esri-widget",widgetIcon:"esri-icon-vertex-gps"};let b=class extends c{constructor(e,t){super((()=>{const{view:t,viewModel:i,snappingOptions:s,...l}=e;return l})(),t),this._layerListFilter=null,this.label=void 0,this.messages=null,this.messagesCommon=null,this.snappingOptions=null,this.view=null,this.visibleElements={...h},this._defaultViewModel=null,e?.viewModel?this.viewModel=e.viewModel:(this._defaultViewModel=new m({snappingOptions:e.snappingOptions,view:e.view}),this.viewModel=this._defaultViewModel)}destroy(){this._defaultViewModel=t(this._defaultViewModel)}loadDependencies(){return Promise.all([import("@esri/calcite-components/dist/components/calcite-action.js"),import("@esri/calcite-components/dist/components/calcite-block.js"),import("@esri/calcite-components/dist/components/calcite-icon.js"),import("@esri/calcite-components/dist/components/calcite-label.js"),import("@esri/calcite-components/dist/components/calcite-panel.js"),import("@esri/calcite-components/dist/components/calcite-list.js"),import("@esri/calcite-components/dist/components/calcite-list-item.js"),import("@esri/calcite-components/dist/components/calcite-list-item-group.js"),import("@esri/calcite-components/dist/components/calcite-switch.js"),import("@esri/calcite-components/dist/components/calcite-checkbox.js"),import("@esri/calcite-components/dist/components/calcite-accordion-item.js"),import("@esri/calcite-components/dist/components/calcite-accordion.js"),import("@esri/calcite-components/dist/components/calcite-input.js")])}set viewModel(e){e!==this._get("viewModel")&&((i(this._defaultViewModel)||this._defaultViewModel!==e)&&(this._defaultViewModel=t(this._defaultViewModel)),this._set("viewModel",e))}castVisibleElements(e){return{...h,...e}}render(){const{label:e,visibleElements:{header:t}}=this;return d("div",{"aria-label":e,class:this.classes(g.base,g.esriWidget)},d("div",{class:g.container},t?this.renderHeaderView():this.renderContent()))}renderHeaderView(){return d("calcite-panel",{heading:this.label,class:g.panel},this.renderContent())}renderContent(){return[this.renderToggles(),this.renderLayerList()]}renderToggles(){return d("calcite-block",{class:g.toggleBlock,heading:"",open:!0},this.renderEnabledToggle(),d("div",{class:g.nestedContainer},this.renderSelfEnabledToggle(),this.renderFeatureEnabledToggle()))}renderEnabledToggle(){if(!this.visibleElements.enabledToggle)return;const{messages:{enableSnapping:e},viewModel:{snappingOptions:{enabled:t,enabledToggled:i}}}=this;return d("calcite-label",{layout:"inline-space-between"},e,d("calcite-switch",{checked:t,disabled:i,bind:this,onCalciteSwitchChange:this._enableSnappingSwitchChange}))}renderSelfEnabledToggle(){if(!this.visibleElements.selfEnabledToggle)return;const{messages:{geometryGuides:e},viewModel:{snappingOptions:{enabled:t,selfEnabled:i,enabledToggled:s}}}=this;return d("calcite-label",{layout:"inline-space-between"},e,d("calcite-switch",{checked:i,disabled:s||!t,bind:this,onCalciteSwitchChange:this._selfEnabledSwitchChange}))}renderFeatureEnabledToggle(){if(!this.visibleElements.featureEnabledToggle)return;const{messages:{featureToFeature:e},viewModel:{snappingOptions:{enabled:t,featureEnabled:i,enabledToggled:s}}}=this;return d("calcite-label",{layout:"inline-space-between"},e,d("calcite-switch",{checked:i,disabled:s||!t,bind:this,onCalciteSwitchChange:this._featureEnabledSwitchChange}))}renderLayerList(){if(!this.visibleElements.layerList)return;const{messages:e,messagesCommon:t}=this,i=({target:{value:e}})=>this._layerListFilter=""===e?null:new RegExp(e,"i"),l=this.viewModel.layerListViewModel.operationalItems.length>9?d("calcite-input",{class:g.layerListFilter,clearable:!0,placeholder:e?.searchLayers,onCalciteInputInput:i}):null;return d("calcite-block",{"intl-collapse":t?.collapse,"intl-expand":t?.expand,heading:e.snappingLayers,class:g.layerListBlock,open:!0,collapsible:!0},l,d("calcite-list",{class:g.layerList},this.renderLayerListItemCollection(this.viewModel.layerListViewModel.operationalItems,s(this._layerListFilter))))}renderLayerListItemCollection(e,t){return e.map((e=>{if(!t||this._itemTitleMatchesFilter(e,t))return e.children.length>0?this.renderLayerListItemGroup(e):this.renderLayerListItem(e);const i=e.children.filter((e=>this._itemTitleMatchesFilter(e,t)));return i.length>0?this.renderLayerListItemGroup(e,i):null})).toArray()}renderLayerListItem(e){const{messages:{untitledLayer:t}}=this,i=e.title||t,s=e.enabled,l=d("calcite-checkbox",{value:e.layer.id,checked:s,bind:this,onCalciteCheckboxChange:e=>this._handleLayerListItemChange(e.target)}),n=()=>{const e=!l.properties.checked;this._handleLayerListItemChange({checked:e,value:l.properties.value})};return d("calcite-list-item",{key:`${this.id}-list-item-${e.uid}`,onclick:n},d("calcite-label",{class:g.layerListItem,slot:"content-start",tabIndex:-1,layout:"inline","disable-spacing":"true"},d("div",{class:g.layerListItemCheckbox},l),d("div",{class:g.layerListItemLabel},i)))}renderLayerListItemGroup(e,t){const i=e.title||this.messages.untitledLayer,s=e.title&&""!==e.title?e.title:l(),n=!!t,a=t??e.children;return d("calcite-list-item",{key:s},d("calcite-accordion",{"icon-position":"start",appearance:"transparent",afterCreate:e=>{e.append(...Array.from(e.children).map((e=>(e.remove(),e))))}},d("calcite-accordion-item",{active:n,"item-title":i,key:e.uid},d("calcite-list",null,[...this.renderLayerListItemCollection(a)]))))}_enableSnappingSwitchChange(e){this.snappingOptions.enabled=e.target.checked}_featureEnabledSwitchChange(e){this.snappingOptions.featureEnabled=e.target.checked}_itemTitleMatchesFilter(e,t){return t.test(e.title)}_selfEnabledSwitchChange(e){this.snappingOptions.selfEnabled=e.target.checked}async _handleLayerListItemChange(e){e.checked?this.viewModel.enableSnappingForLayer(e.value):this.viewModel.disableSnappingForLayer(e.value)}};e([r()],b.prototype,"_layerListFilter",void 0),e([r({aliasOf:{source:"messages.widgetLabel",overridable:!0}})],b.prototype,"label",void 0),e([r(),p("esri/widgets/support/SnappingControls/t9n/SnappingControls")],b.prototype,"messages",void 0),e([r(),p("esri/t9n/common")],b.prototype,"messagesCommon",void 0),e([n("viewModel.snappingOptions")],b.prototype,"snappingOptions",void 0),e([n("viewModel.view")],b.prototype,"view",void 0),e([r()],b.prototype,"viewModel",null),e([r()],b.prototype,"visibleElements",void 0),e([a("visibleElements")],b.prototype,"castVisibleElements",null),b=e([o("esri.widgets.support.SnappingControls")],b);const u=b;export{u as default};