@arcgis/core 4.28.0-next.20230721 → 4.28.0-next.20230724

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 (31) hide show
  1. package/applications/SceneViewer/devEnvironmentUtils.d.ts +4 -0
  2. package/applications/SceneViewer/devEnvironmentUtils.js +5 -0
  3. package/assets/esri/core/workers/RemoteClient.js +1 -1
  4. package/assets/esri/core/workers/chunks/83f65d80d5adf7539cdf.js +1 -0
  5. package/assets/esri/themes/base/widgets/_Daylight.scss +1 -2
  6. package/assets/esri/themes/dark/main.css +1 -1
  7. package/assets/esri/themes/light/main.css +1 -1
  8. package/assets/esri/themes/light/view.css +1 -1
  9. package/core/devEnvironmentUtils.js +1 -1
  10. package/interfaces.d.ts +29 -1
  11. package/layers/KnowledgeGraphLayer.js +1 -1
  12. package/layers/LinkChartLayer.js +1 -1
  13. package/layers/knowledgeGraph/KnowledgeGraphLayerDataManager.js +1 -1
  14. package/package.json +1 -1
  15. package/support/revision.js +1 -1
  16. package/views/2d/engine/vectorTiles/VectorTile.js +1 -1
  17. package/views/2d/engine/vectorTiles/VectorTileContainer.js +1 -1
  18. package/views/2d/engine/vectorTiles/decluttering/SymbolFader.js +1 -1
  19. package/views/2d/layers/VectorTileLayerView2D.js +1 -1
  20. package/widgets/Daylight/css.js +1 -1
  21. package/widgets/Daylight.js +1 -1
  22. package/widgets/Editor/workflowUtils.js +1 -1
  23. package/widgets/ElevationProfile/components/Legend.js +1 -1
  24. package/widgets/ElevationProfile/components/SettingsButton.js +1 -1
  25. package/widgets/ElevationProfile.js +1 -1
  26. package/widgets/Legend/styles/Card.js +1 -1
  27. package/widgets/Legend/styles/Classic.js +1 -1
  28. package/widgets/Slider/css.js +5 -0
  29. package/widgets/Slider.js +1 -1
  30. package/assets/esri/core/workers/chunks/a54ec9929a7db879d5db.js +0 -1
  31. package/layers/orientedImagery/urlUtils.js +0 -5
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import{on as t}from"../../../core/reactiveUtils.js";import{property as o}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import{subclass as i}from"../../../core/accessorSupport/decorators/subclass.js";import r from"../../Widget.js";import{SETTINGS_CSS as s}from"../css.js";import{loadCalciteComponents as n}from"../../support/componentsUtils.js";import{UnitSelect as c}from"../../support/UnitSelect.js";import"../../support/widgetUtils.js";import{tsx as a}from"../../support/jsxFactory.js";let l=class extends r{constructor(e,t){super(e,t),this.messages=null,this._popover=null,this._popoverIsOpen=!1,this._onPopoverAfterCreate=e=>{this._popover=e},this._onUnitChange=e=>{this.viewModel.unit=e},this._onUniformChartScalingChange=e=>{this.viewModel.uniformChartScaling=e.target.checked}}loadDependencies(){return n({action:()=>import("@esri/calcite-components/dist/components/calcite-action.js"),checkbox:()=>import("@esri/calcite-components/dist/components/calcite-checkbox.js"),label:()=>import("@esri/calcite-components/dist/components/calcite-label.js"),popover:()=>import("@esri/calcite-components/dist/components/calcite-popover.js"),tooltip:()=>import("@esri/calcite-components/dist/components/calcite-tooltip.js")})}initialize(){const e=()=>this._popover;this.addHandles([t(e,"calcitePopoverOpen",(()=>this._popoverIsOpen=!0)),t(e,"calcitePopoverClose",(()=>this._popoverIsOpen=!1))])}render(){const{id:e,messages:t,visibleElements:o}=this,{unitSelector:i,uniformChartScalingToggle:r}=o;if(!t||!i&&!r)return a("div",{key:`${e}-empty`});const n=`${e}__action`,c=this._popoverIsOpen?t.hideSettings:t.showSettings;return a("div",{key:this,class:s.base},a("calcite-popover",{afterCreate:this._onPopoverAfterCreate,autoClose:!0,label:c,overlayPositioning:"fixed",referenceElement:n},this._renderPopoverContent()),a("calcite-action",{appearance:"transparent",icon:"gear",id:n,scale:"s",text:c,label:c,"data-testid":"settings-button"}))}_renderPopoverContent(){const{unitSelector:e,uniformChartScalingToggle:t}=this.visibleElements;return a("div",{class:s.popoverContent},e&&this._renderUnitSelector(),t&&this._renderUniformChartScalingToggle())}_renderUnitSelector(){const{messages:e,viewModel:t}=this,{unit:o,unitOptions:i}=t;return a(c,{key:"unit-selector-label",onChange:this._onUnitChange,options:i,selectLabel:e?.unitSelectLabel??"",value:o})}_renderUniformChartScalingToggle(){const{messages:e,viewModel:t}=this,o=t.uniformChartScaling,i=`${this.id}__uniform-chart-scaling-toggle`,r=e?.[o?"uniformChartScalingDisable":"uniformChartScalingEnable"]??"";return a("calcite-label",{class:s.uniformChartScalingLabel,key:"uniform-chart-scaling-label",layout:"inline"},a("calcite-checkbox",{checked:o,class:s.uniformChartScalingCheckbox,id:i,onCalciteCheckboxChange:this._onUniformChartScalingChange}),a("calcite-tooltip",{label:r,overlayPositioning:"fixed",referenceElement:i},r),e?.uniformChartScalingLabel)}};e([o()],l.prototype,"messages",void 0),e([o()],l.prototype,"viewModel",void 0),e([o()],l.prototype,"visibleElements",void 0),e([o()],l.prototype,"_popover",void 0),e([o()],l.prototype,"_popoverIsOpen",void 0),l=e([i("esri.widgets.ElevationProfile.SettingsButton")],l);export{l as SettingsButton};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import{on as t}from"../../../core/reactiveUtils.js";import{property as o}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import{subclass as i}from"../../../core/accessorSupport/decorators/subclass.js";import r from"../../Widget.js";import{SETTINGS_CSS as s}from"../css.js";import{loadCalciteComponents as n}from"../../support/componentsUtils.js";import{UnitSelect as c}from"../../support/UnitSelect.js";import"../../support/widgetUtils.js";import{tsx as a}from"../../support/jsxFactory.js";let p=class extends r{constructor(){super(...arguments),this.messages=null,this._popover=null,this._popoverIsOpen=!1,this._onPopoverAfterCreate=e=>{this._popover=e},this._onUniformChartScalingChange=e=>{this.onUniformChartScalingChange(e.target.checked)}}loadDependencies(){return n({action:()=>import("@esri/calcite-components/dist/components/calcite-action.js"),checkbox:()=>import("@esri/calcite-components/dist/components/calcite-checkbox.js"),label:()=>import("@esri/calcite-components/dist/components/calcite-label.js"),popover:()=>import("@esri/calcite-components/dist/components/calcite-popover.js"),tooltip:()=>import("@esri/calcite-components/dist/components/calcite-tooltip.js")})}initialize(){const e=()=>this._popover;this.addHandles([t(e,"calcitePopoverOpen",(()=>this._popoverIsOpen=!0)),t(e,"calcitePopoverClose",(()=>this._popoverIsOpen=!1))])}render(){const{id:e,messages:t,visibleElements:o}=this,{unitSelector:i,uniformChartScalingToggle:r}=o;if(!t||!i&&!r)return a("div",{key:`${e}-empty`});const n=`${e}__action`,c=this._popoverIsOpen?t.hideSettings:t.showSettings;return a("div",{key:this,class:s.base},a("calcite-popover",{afterCreate:this._onPopoverAfterCreate,autoClose:!0,label:c,overlayPositioning:"fixed",referenceElement:n},this._renderPopoverContent()),a("calcite-action",{appearance:"transparent",icon:"gear",id:n,scale:"s",text:c,label:c,"data-testid":"settings-button"}))}_renderPopoverContent(){const{unitSelector:e,uniformChartScalingToggle:t}=this.visibleElements;return a("div",{class:s.popoverContent},e&&this._renderUnitSelector(),t&&this._renderUniformChartScalingToggle())}_renderUnitSelector(){const{messages:e}=this;return a(c,{key:"unit-selector-label",onChange:this.onUnitChange,options:this.unitOptions,selectLabel:e?.unitSelectLabel??"",value:this.unit})}_renderUniformChartScalingToggle(){const{messages:e}=this,t=this.uniformChartScaling,o=`${this.id}__uniform-chart-scaling-toggle`,i=e?.[t?"uniformChartScalingDisable":"uniformChartScalingEnable"]??"";return a("calcite-label",{class:s.uniformChartScalingLabel,key:"uniform-chart-scaling-label",layout:"inline"},a("calcite-checkbox",{checked:t,class:s.uniformChartScalingCheckbox,id:o,onCalciteCheckboxChange:this._onUniformChartScalingChange}),a("calcite-tooltip",{label:i,overlayPositioning:"fixed",referenceElement:o},i),e?.uniformChartScalingLabel)}};e([o()],p.prototype,"messages",void 0),e([o()],p.prototype,"onUniformChartScalingChange",void 0),e([o()],p.prototype,"onUnitChange",void 0),e([o()],p.prototype,"uniformChartScaling",void 0),e([o()],p.prototype,"unit",void 0),e([o()],p.prototype,"unitOptions",void 0),e([o()],p.prototype,"visibleElements",void 0),e([o()],p.prototype,"_popover",void 0),e([o()],p.prototype,"_popoverIsOpen",void 0),p=e([i("esri.widgets.ElevationProfile.components.SettingsButton")],p);export{p as SettingsButton};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../chunks/tslib.es6.js";import{createTask as e}from"../core/asyncUtils.js";import{destroyMaybe as s,abortMaybe as i}from"../core/maybe.js";import{memoize as r}from"../core/memoize.js";import{throwIfAborted as n,createAbortError as o}from"../core/promiseUtils.js";import{watch as a,initial as l}from"../core/reactiveUtils.js";import{property as c}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import"../core/has.js";import{subclass as h}from"../core/accessorSupport/decorators/subclass.js";import d from"./Widget.js";import{CSS as p}from"./ElevationProfile/css.js";import u from"./ElevationProfile/ElevationProfileViewModel.js";import m from"./ElevationProfile/ElevationProfileVisibleElements.js";import{Legend as _}from"./ElevationProfile/components/Legend.js";import{SettingsButton as C}from"./ElevationProfile/components/SettingsButton.js";import{ElevationProfileErrorState as v,getConfig as g,ElevationProfileState as f}from"./ElevationProfile/support/constants.js";import{loadCalciteComponents as y}from"./support/componentsUtils.js";import{onResize as w}from"./support/widgetUtils.js";import{messageBundle as b}from"./support/decorators/messageBundle.js";import{tsx as k,tsxFragment as S}from"./support/jsxFactory.js";var B;!function(t){t.Sketch="sketch",t.SketchCancel="sketch-cancel",t.SketchDone="sketch-done",t.Select="select",t.SelectCancel="select-cancel"}(B||(B={}));const M=[{type:B.Select},{type:B.Sketch}],P={[v.None]:null,[v.NoValidInput]:"noProfile",[v.NoVisibleProfiles]:"noProfile",[v.RefinedButNoChartData]:"noProfile",[v.TooComplex]:"tooComplex",[v.UnknownError]:"unknown",[v.InvalidGeometry]:"invalidGeometry",[v.InvalidElevationInfo]:"invalidElevationInfo"},E=Symbol("resize-observer-handle");let j=class extends d{constructor(t,e){super(t,e),this.viewModel=null,this.visibleElements=new m,this.iconClass=p.widgetIcon,this.icon=null,this.messages=null,this.messagesCommon=null,this.messagesUnits=null,this._chartContainer=null,this._chart=null,this._chartInitTask=null,this._chartIsRefined=!1,this._width=0,this._zoomOutButtonVisible=!1,this._getChartUpdateParamsMemoized=r(((t,e,s,i)=>({chart:t,data:e,stationary:s,messages:i}))),this._getDetailsPropsMemoized=r(((t,e,s)=>({effectiveUnits:t,messages:e,profiles:s}))),this._onZoomOutButtonClick=()=>{this._chart?.zoomOut()},this._onClearButtonClick=()=>{this.viewModel.clear()},t?.viewModel||(this._defaultViewModel=new u({view:t?.view}),this.viewModel=this._defaultViewModel)}loadDependencies(){return y({action:()=>import("@esri/calcite-components/dist/components/calcite-action.js"),button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader.js")})}initialize(){this._legend=new _(this._legendProps),this._settingsButton=new C(this._settingsButtonProps),this.addHandles([a((()=>this._legendProps),(t=>this._legend.set(t))),a((()=>this._settingsButtonProps),(t=>this._settingsButton.set(t)))])}postInitialize(){this.addHandles([a((()=>({container:this._chartContainer,width:this._width})),(({container:t,width:e})=>{this._destroyChart(),null!=t&&e>0&&this._initializeChart(t)}),l),a((()=>this._chartUpdateParams),(()=>this._updateChart(this._chartUpdateParams)),l)])}destroy(){this._destroyChart(),null!=this._defaultViewModel&&this.viewModel!==this._defaultViewModel&&this._defaultViewModel.destroy(),this._legend=s(this._legend),this._settingsButton=s(this._settingsButton)}get view(){return this.viewModel.view}set view(t){this.viewModel.view=t}get input(){return this.viewModel.input}set input(t){this.viewModel.input=t}get profiles(){return this.viewModel.profiles}set profiles(t){this.viewModel.profiles=t}get unitOptions(){return this.viewModel.unitOptions}set unitOptions(t){this.viewModel.unitOptions=t}get unit(){return this.viewModel.unit}set unit(t){this.viewModel.unit=t}get geodesicDistanceThreshold(){return this.viewModel.geodesicDistanceThreshold}set geodesicDistanceThreshold(t){this.viewModel.geodesicDistanceThreshold=t}get label(){return this.messages?.widgetLabel??""}set label(t){this._overrideIfSome("label",t)}get visible(){return this.viewModel.visible}set visible(t){this.viewModel.visible=t}get _portrait(){return this._width<g().portraitModePixelBreakpoint}get _chartUpdateParams(){const t=this.view;return this._getChartUpdateParamsMemoized(this._chart,this.viewModel.chartData,null==t||t.stationary,this._chartMessages)}get _chartMessages(){return{...this.messagesUnits,...this.messages}}get _legendProps(){return this._getDetailsPropsMemoized(this.viewModel.effectiveUnits,this.messages,this._profilesArray)}get _profilesArray(){return this.profiles.toArray()}get _settingsButtonProps(){return{messages:this.messages,viewModel:this.viewModel,visibleElements:this.visibleElements}}render(){const{viewModel:t,visible:e}=this;return k("div",{key:this,class:this.classes({[p.base]:e,[p.esriWidget]:e,[p.esriWidgetDisabled]:e&&"disabled"===t.state,[p.portrait]:this._portrait,[p.refined]:1===t.progress}),"aria-label":this.messages.widgetLabel},k("div",{key:"content-wrapper",bind:this,afterCreate:this._onContentWrapperAfterCreate,afterRemoved:this._onContentWrapperRemoved},e&&this._renderContentForState()))}_renderContentForState(){switch(this.viewModel.state){case f.Ready:return this._renderContentForReadyState();case f.Selecting:return this._renderContentForSelectingState();case f.Creating:return this._renderContentForCreatingState();case f.Selected:return this._renderContentForSelectedState();case f.Created:return this._renderContentForCreatedState();case f.Disabled:return this._renderContentForReadyState()}}_renderContentForReadyState(){const{sketchButton:t,selectButton:e}=this.visibleElements,s=this.messages;let i;return i=t&&e?s.readyPrompt:t?s.readyPromptCreateOnly:e?s.readyPromptSelectOnly:s.errors?.noProfile,this._renderContent({prompt:i,chart:!1,actions:M})}_renderContentForSelectingState(){const t=this.view;if(null==t)return null;const e=this.messages[`selectingPrompt-${t.type}`];return this._renderContent({prompt:e,chart:!1,actions:[{type:B.SelectCancel}]})}_renderContentForCreatingState(){const{view:t,viewModel:e}=this;if(null==t)return null;const s=e.hasVertices?[{type:B.SketchCancel},{type:B.SketchDone,disabled:!e.tool.interaction.canStopCreating}]:[{type:B.Select},{type:B.Sketch,disabled:!0}];if(e.errorState===v.NoValidInput){const e=this.messages[`creatingPrompt-${t.type}`];return this._renderContent({chart:!1,actions:s,prompt:e})}const i=this._getErrorMessage();return i?this._renderContent({chart:!1,actions:s,prompt:i}):this._renderContent({chart:!0,actions:s})}_renderContentForSelectedState(){const t=this._getErrorMessage();return t?this._renderContent({chart:!1,actions:M,prompt:t}):this._renderContent({chart:!0,actions:M})}_renderContentForCreatedState(){const t=this._getErrorMessage();return t?this._renderContent({chart:!1,actions:M,prompt:t}):this._renderContent({chart:!0,actions:M})}_getErrorMessage(){const t=P[this.viewModel.errorState];return t?this.messages?.errors?.[t]:null}_renderContent(t){const e=null!=t.prompt?this._renderPrompt(t.prompt):t.chart&&this._renderChart(),s=null!=this.viewModel.input;return[k("header",{key:"header",class:p.header},this._zoomOutButtonVisible&&this._renderZoomOutButton(),this.visibleElements.clearButton&&s&&this._renderClearButton(),this.visibleElements.settingsButton&&this._settingsButton.render()),k("div",{class:p.mainContainer},e),this.visibleElements.legend&&this._legend.render(),this._renderActions(t)]}_renderZoomOutButton(){return k("calcite-action",{appearance:"transparent",class:p.zoomOutButton,icon:"magnifying-glass-minus",key:"zoom-out",onclick:this._onZoomOutButtonClick,scale:"s",text:this.messages.zoomOut,"data-testid":"zoom-out-button"})}_renderClearButton(){return k("calcite-action",{appearance:"transparent",class:p.clearButton,icon:"trash",key:"clear-profile",onclick:this._onClearButtonClick,scale:"s",text:this.messages.clearProfile,"data-testid":"clear-button"})}_renderPrompt(t){return[k("div",{key:"prompt-container",bind:this,class:p.promptContainer},k("p",null,t))]}_renderChart(){if(!this.visibleElements.chart)return k("div",{key:"empty-chart-container",class:p.chartContainer});const t=this._chartIsRefined||this._canRenderChart();if(!t)return k(S,null,this._renderSpinner({size:"large"}),k("div",{key:"chart-container-empty",class:p.chartContainer}));const{chartData:e,progress:s}=this.viewModel;return k(S,null,null!=e&&s>0&&s<1&&this._renderSpinner({size:t?"small":"large"}),k("div",{key:"chart-container",bind:this,class:p.chartContainer,afterCreate:this._onChartContainerAfterCreate,afterRemoved:this._onChartContainerRemoved}))}_renderSpinner(t){const e="small"===t.size;return k("calcite-loader",{afterCreate:this._onSpinnerAfterCreate,class:this.classes(p.chartSpinner,e&&p.chartSpinnerSmall),exitAnimation:this._onSpinnerExit,inline:e,key:"spinner",label:"",scale:"s"})}_onSpinnerAfterCreate(t){requestAnimationFrame((()=>t.classList.add(p.chartSpinnerVisible)))}_onSpinnerExit(t,e){t.classList.remove(p.chartSpinnerVisible),setTimeout(e,200)}_canRenderChart(){const t=this.viewModel.chartData;if(null==t)return!1;if(!this.viewModel.inputIsSketched)return t.refined;let e=0;for(const{samples:s}of t.lines)e+=null!=s?s.length:0;return t.refined||e<=g().largeChartSamples}_renderActions({actions:t}){const e=t.map((t=>{switch(t.type){case B.Sketch:return this.visibleElements.sketchButton&&this._renderAction({action:t,className:p.sketchButton,label:this.messages.sketchButtonLabel,onClick:this._onSketchButtonClick,primary:!0});case B.SketchCancel:return this.visibleElements.sketchButton&&this._renderAction({action:t,onClick:this._onCancelButtonClick,className:p.sketchCancelButton,label:this.messagesCommon.cancel,primary:!1});case B.SketchDone:return this.visibleElements.sketchButton&&this._renderAction({action:t,onClick:this._onDoneButtonClick,className:p.sketchDoneButton,label:this.messagesCommon.done,primary:!0});case B.Select:return this.visibleElements.selectButton&&this._renderAction({action:t,onClick:this._onSelectButtonClick,className:p.selectButton,label:this.messages.selectButtonLabel,primary:!1});case B.SelectCancel:return this.visibleElements.selectButton&&this._renderAction({action:t,onClick:this._onCancelButtonClick,className:p.selectCancelButton,label:this.messagesCommon.cancel,primary:!1})}})).filter(Boolean);return e.length?k("footer",{key:"footer",class:p.footer},e):null}_renderAction({action:t,className:e,label:s,onClick:i,primary:r}){return k("calcite-button",{appearance:r?"solid":"outline-fill",bind:this,class:this.classes(p.actionButton,e),disabled:t.disabled,key:`action-${t.type}`,onclick:i},s)}_onSketchButtonClick(){this.viewModel.start({mode:"sketch"})}_onSelectButtonClick(){this.viewModel.start({mode:"select"})}_onCancelButtonClick(){this.viewModel.cancel()}_onDoneButtonClick(){this.viewModel.stop()}_onContentWrapperAfterCreate(t){const e=w(t,(t=>{this._width=t.contentRect.width}));this.addHandles(e,E)}_onContentWrapperRemoved(){this.removeHandles(E)}_updateChart(t){const{data:e,chart:s,messages:i,stationary:r}=t;null!=s&&null!=i&&r&&this._canRenderChart()&&(s.update(t),this._chartIsRefined=null!=e&&e.refined)}_onChartContainerAfterCreate(t){this._chartContainer=t}_onChartContainerRemoved(){this._chartContainer=null}_initializeChart(t){i(this._chartInitTask),this._chartInitTask=e((async e=>{const{createChart:i}=await import("./ElevationProfile/support/chartUtils.js");n(e);const{view:r}=this,a=await i({container:t,scheduler:"3d"===r?.type?r.resourceController?.scheduler:void 0,abortOptions:{signal:e},onRangeChange:(t,e)=>{this._zoomOutButtonVisible=1!==t||1!==e},onCursorPositionChange:t=>{this.viewModel.hoveredChartPosition=t}});if(e.aborted)throw s(a),o();this._chart=a,this._updateChart(this._chartUpdateParams)}))}_destroyChart(){this._chartInitTask=i(this._chartInitTask),this._chart=s(this._chart),this._chartIsRefined=!1}};t([c({type:u})],j.prototype,"viewModel",void 0),t([c()],j.prototype,"view",null),t([c()],j.prototype,"input",null),t([c()],j.prototype,"profiles",null),t([c()],j.prototype,"unitOptions",null),t([c()],j.prototype,"unit",null),t([c()],j.prototype,"geodesicDistanceThreshold",null),t([c({type:m,nonNullable:!0})],j.prototype,"visibleElements",void 0),t([c()],j.prototype,"iconClass",void 0),t([c()],j.prototype,"icon",void 0),t([c()],j.prototype,"label",null),t([c()],j.prototype,"visible",null),t([c(),b("esri/widgets/ElevationProfile/t9n/ElevationProfile")],j.prototype,"messages",void 0),t([c(),b("esri/t9n/common")],j.prototype,"messagesCommon",void 0),t([c(),b("esri/core/t9n/Units")],j.prototype,"messagesUnits",void 0),t([c()],j.prototype,"_chartContainer",void 0),t([c()],j.prototype,"_chart",void 0),t([c()],j.prototype,"_chartInitTask",void 0),t([c()],j.prototype,"_chartIsRefined",void 0),t([c()],j.prototype,"_settingsButton",void 0),t([c()],j.prototype,"_legend",void 0),t([c()],j.prototype,"_width",void 0),t([c()],j.prototype,"_portrait",null),t([c()],j.prototype,"_zoomOutButtonVisible",void 0),t([c()],j.prototype,"_chartUpdateParams",null),t([c()],j.prototype,"_chartMessages",null),t([c()],j.prototype,"_legendProps",null),t([c()],j.prototype,"_profilesArray",null),t([c()],j.prototype,"_settingsButtonProps",null),j=t([h("esri.widgets.ElevationProfile")],j);const z=j;export{z as default};
5
+ import{_ as t}from"../chunks/tslib.es6.js";import{createTask as e}from"../core/asyncUtils.js";import{abortMaybe as i,destroyMaybe as s}from"../core/maybe.js";import{memoize as r}from"../core/memoize.js";import{throwIfAborted as n,createAbortError as o}from"../core/promiseUtils.js";import{watch as a,initial as l}from"../core/reactiveUtils.js";import{property as c}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import"../core/has.js";import{subclass as h}from"../core/accessorSupport/decorators/subclass.js";import d from"./Widget.js";import{CSS as p}from"./ElevationProfile/css.js";import u from"./ElevationProfile/ElevationProfileViewModel.js";import m from"./ElevationProfile/ElevationProfileVisibleElements.js";import{Legend as _}from"./ElevationProfile/components/Legend.js";import{SettingsButton as C}from"./ElevationProfile/components/SettingsButton.js";import{ElevationProfileErrorState as v,getConfig as f,ElevationProfileState as g}from"./ElevationProfile/support/constants.js";import{loadCalciteComponents as y}from"./support/componentsUtils.js";import{onResize as w}from"./support/widgetUtils.js";import{messageBundle as k}from"./support/decorators/messageBundle.js";import{tsx as b,tsxFragment as S}from"./support/jsxFactory.js";var M;!function(t){t.Sketch="sketch",t.SketchCancel="sketch-cancel",t.SketchDone="sketch-done",t.Select="select",t.SelectCancel="select-cancel"}(M||(M={}));const B=[{type:M.Select},{type:M.Sketch}],E={[v.None]:null,[v.NoValidInput]:"noProfile",[v.NoVisibleProfiles]:"noProfile",[v.RefinedButNoChartData]:"noProfile",[v.TooComplex]:"tooComplex",[v.UnknownError]:"unknown",[v.InvalidGeometry]:"invalidGeometry",[v.InvalidElevationInfo]:"invalidElevationInfo"},P=Symbol("resize-observer-handle");let j=class extends d{constructor(t,e){super(t,e),this.viewModel=null,this.visibleElements=new m,this.iconClass=p.widgetIcon,this.icon=null,this.messages=null,this.messagesCommon=null,this.messagesUnits=null,this._chartContainer=null,this._chart=null,this._chartInitTask=null,this._chartIsRefined=!1,this._width=0,this._zoomOutButtonVisible=!1,this._getChartUpdateParamsMemoized=r(((t,e,i,s)=>({chart:t,data:e,stationary:i,messages:s}))),this._onZoomOutButtonClick=()=>{this._chart?.zoomOut()},this._onClearButtonClick=()=>{this.viewModel.clear()},t?.viewModel||(this._defaultViewModel=new u({view:t?.view}),this.viewModel=this._defaultViewModel)}loadDependencies(){return y({action:()=>import("@esri/calcite-components/dist/components/calcite-action.js"),button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader.js")})}postInitialize(){this.addHandles([a((()=>({container:this._chartContainer,width:this._width})),(({container:t,width:e})=>{this._destroyChart(),null!=t&&e>0&&this._initializeChart(t)}),l),a((()=>this._chartUpdateParams),(()=>this._updateChart(this._chartUpdateParams)),l)])}destroy(){this._destroyChart(),null!=this._defaultViewModel&&this.viewModel!==this._defaultViewModel&&this._defaultViewModel.destroy()}get view(){return this.viewModel.view}set view(t){this.viewModel.view=t}get input(){return this.viewModel.input}set input(t){this.viewModel.input=t}get profiles(){return this.viewModel.profiles}set profiles(t){this.viewModel.profiles=t}get unitOptions(){return this.viewModel.unitOptions}set unitOptions(t){this.viewModel.unitOptions=t}get unit(){return this.viewModel.unit}set unit(t){this.viewModel.unit=t}get geodesicDistanceThreshold(){return this.viewModel.geodesicDistanceThreshold}set geodesicDistanceThreshold(t){this.viewModel.geodesicDistanceThreshold=t}get label(){return this.messages?.widgetLabel??""}set label(t){this._overrideIfSome("label",t)}get visible(){return this.viewModel.visible}set visible(t){this.viewModel.visible=t}get _portrait(){return this._width<f().portraitModePixelBreakpoint}get _chartUpdateParams(){const t=this.view;return this._getChartUpdateParamsMemoized(this._chart,this.viewModel.chartData,null==t||t.stationary,this._chartMessages)}get _chartMessages(){return{...this.messagesUnits,...this.messages}}get _profilesArray(){return this.profiles.toArray()}render(){const{viewModel:t,visible:e}=this;return b("div",{key:this,class:this.classes({[p.base]:e,[p.esriWidget]:e,[p.esriWidgetDisabled]:e&&"disabled"===t.state,[p.portrait]:this._portrait,[p.refined]:1===t.progress}),"aria-label":this.messages.widgetLabel},b("div",{key:"content-wrapper",bind:this,afterCreate:this._onContentWrapperAfterCreate,afterRemoved:this._onContentWrapperRemoved},e&&this._renderContentForState()))}_renderContentForState(){switch(this.viewModel.state){case g.Ready:return this._renderContentForReadyState();case g.Selecting:return this._renderContentForSelectingState();case g.Creating:return this._renderContentForCreatingState();case g.Selected:return this._renderContentForSelectedState();case g.Created:return this._renderContentForCreatedState();case g.Disabled:return this._renderContentForReadyState()}}_renderContentForReadyState(){const{sketchButton:t,selectButton:e}=this.visibleElements,i=this.messages;let s;return s=t&&e?i.readyPrompt:t?i.readyPromptCreateOnly:e?i.readyPromptSelectOnly:i.errors?.noProfile,this._renderContent({prompt:s,chart:!1,actions:B})}_renderContentForSelectingState(){const t=this.view;if(null==t)return null;const e=this.messages[`selectingPrompt-${t.type}`];return this._renderContent({prompt:e,chart:!1,actions:[{type:M.SelectCancel}]})}_renderContentForCreatingState(){const{view:t,viewModel:e}=this;if(null==t)return null;const i=e.hasVertices?[{type:M.SketchCancel},{type:M.SketchDone,disabled:!e.tool.interaction.canStopCreating}]:[{type:M.Select},{type:M.Sketch,disabled:!0}];if(e.errorState===v.NoValidInput){const e=this.messages[`creatingPrompt-${t.type}`];return this._renderContent({chart:!1,actions:i,prompt:e})}const s=this._getErrorMessage();return s?this._renderContent({chart:!1,actions:i,prompt:s}):this._renderContent({chart:!0,actions:i})}_renderContentForSelectedState(){const t=this._getErrorMessage();return t?this._renderContent({chart:!1,actions:B,prompt:t}):this._renderContent({chart:!0,actions:B})}_renderContentForCreatedState(){const t=this._getErrorMessage();return t?this._renderContent({chart:!1,actions:B,prompt:t}):this._renderContent({chart:!0,actions:B})}_getErrorMessage(){const t=E[this.viewModel.errorState];return t?this.messages?.errors?.[t]:null}_renderContent(t){const e=null!=t.prompt?this._renderPrompt(t.prompt):t.chart&&this._renderChart(),{viewModel:i}=this,s=null!=i.input;return b(S,null,b("header",{key:"header",class:p.header},this._zoomOutButtonVisible&&this._renderZoomOutButton(),this.visibleElements.clearButton&&s&&this._renderClearButton(),this.visibleElements.settingsButton&&b(C,{messages:this.messages,onUniformChartScalingChange:t=>i.uniformChartScaling=t,onUnitChange:t=>i.unit=t,uniformChartScaling:i.uniformChartScaling,unit:i.unit,unitOptions:i.unitOptions,visibleElements:this.visibleElements})),b("div",{key:"main-container",class:p.mainContainer},e),this.visibleElements.legend&&b(_,{effectiveUnits:i.effectiveUnits,messages:this.messages,profiles:this._profilesArray}),this._renderActions(t))}_renderZoomOutButton(){return b("calcite-action",{appearance:"transparent",class:p.zoomOutButton,icon:"magnifying-glass-minus",key:"zoom-out",onclick:this._onZoomOutButtonClick,scale:"s",text:this.messages.zoomOut,"data-testid":"zoom-out-button"})}_renderClearButton(){return b("calcite-action",{appearance:"transparent",class:p.clearButton,icon:"trash",key:"clear-profile",onclick:this._onClearButtonClick,scale:"s",text:this.messages.clearProfile,"data-testid":"clear-button"})}_renderPrompt(t){return[b("div",{key:"prompt-container",bind:this,class:p.promptContainer},b("p",null,t))]}_renderChart(){if(!this.visibleElements.chart)return b("div",{key:"empty-chart-container",class:p.chartContainer});const t=this._chartIsRefined||this._canRenderChart();if(!t)return b(S,null,this._renderSpinner({size:"large"}),b("div",{key:"chart-container-empty",class:p.chartContainer}));const{chartData:e,progress:i}=this.viewModel;return b(S,null,null!=e&&i>0&&i<1&&this._renderSpinner({size:t?"small":"large"}),b("div",{key:"chart-container",bind:this,class:p.chartContainer,afterCreate:this._onChartContainerAfterCreate,afterRemoved:this._onChartContainerRemoved}))}_renderSpinner(t){const e="small"===t.size;return b("calcite-loader",{afterCreate:this._onSpinnerAfterCreate,class:this.classes(p.chartSpinner,e&&p.chartSpinnerSmall),exitAnimation:this._onSpinnerExit,inline:e,key:"spinner",label:"",scale:"s"})}_onSpinnerAfterCreate(t){requestAnimationFrame((()=>t.classList.add(p.chartSpinnerVisible)))}_onSpinnerExit(t,e){t.classList.remove(p.chartSpinnerVisible),setTimeout(e,200)}_canRenderChart(){const t=this.viewModel.chartData;if(null==t)return!1;if(!this.viewModel.inputIsSketched)return t.refined;let e=0;for(const{samples:i}of t.lines)e+=null!=i?i.length:0;return t.refined||e<=f().largeChartSamples}_renderActions({actions:t}){const e=t.map((t=>{switch(t.type){case M.Sketch:return this.visibleElements.sketchButton&&this._renderAction({action:t,className:p.sketchButton,label:this.messages.sketchButtonLabel,onClick:this._onSketchButtonClick,primary:!0});case M.SketchCancel:return this.visibleElements.sketchButton&&this._renderAction({action:t,onClick:this._onCancelButtonClick,className:p.sketchCancelButton,label:this.messagesCommon.cancel,primary:!1});case M.SketchDone:return this.visibleElements.sketchButton&&this._renderAction({action:t,onClick:this._onDoneButtonClick,className:p.sketchDoneButton,label:this.messagesCommon.done,primary:!0});case M.Select:return this.visibleElements.selectButton&&this._renderAction({action:t,onClick:this._onSelectButtonClick,className:p.selectButton,label:this.messages.selectButtonLabel,primary:!1});case M.SelectCancel:return this.visibleElements.selectButton&&this._renderAction({action:t,onClick:this._onCancelButtonClick,className:p.selectCancelButton,label:this.messagesCommon.cancel,primary:!1})}})).filter(Boolean);return e.length?b("footer",{key:"footer",class:p.footer},e):null}_renderAction({action:t,className:e,label:i,onClick:s,primary:r}){return b("calcite-button",{appearance:r?"solid":"outline-fill",bind:this,class:this.classes(p.actionButton,e),disabled:t.disabled,key:`action-${t.type}`,onclick:s},i)}_onSketchButtonClick(){this.viewModel.start({mode:"sketch"})}_onSelectButtonClick(){this.viewModel.start({mode:"select"})}_onCancelButtonClick(){this.viewModel.cancel()}_onDoneButtonClick(){this.viewModel.stop()}_onContentWrapperAfterCreate(t){const e=w(t,(t=>{this._width=t.contentRect.width}));this.addHandles(e,P)}_onContentWrapperRemoved(){this.removeHandles(P)}_updateChart(t){const{data:e,chart:i,messages:s,stationary:r}=t;null!=i&&null!=s&&r&&this._canRenderChart()&&(i.update(t),this._chartIsRefined=null!=e&&e.refined)}_onChartContainerAfterCreate(t){this._chartContainer=t}_onChartContainerRemoved(){this._chartContainer=null}_initializeChart(t){i(this._chartInitTask),this._chartInitTask=e((async e=>{const{createChart:i}=await import("./ElevationProfile/support/chartUtils.js");n(e);const{view:r}=this,a=await i({container:t,scheduler:"3d"===r?.type?r.resourceController?.scheduler:void 0,abortOptions:{signal:e},onRangeChange:(t,e)=>{this._zoomOutButtonVisible=1!==t||1!==e},onCursorPositionChange:t=>{this.viewModel.hoveredChartPosition=t}});if(e.aborted)throw s(a),o();this._chart=a,this._updateChart(this._chartUpdateParams)}))}_destroyChart(){this._chartInitTask=i(this._chartInitTask),this._chart=s(this._chart),this._chartIsRefined=!1}};t([c({type:u})],j.prototype,"viewModel",void 0),t([c()],j.prototype,"view",null),t([c()],j.prototype,"input",null),t([c()],j.prototype,"profiles",null),t([c()],j.prototype,"unitOptions",null),t([c()],j.prototype,"unit",null),t([c()],j.prototype,"geodesicDistanceThreshold",null),t([c({type:m,nonNullable:!0})],j.prototype,"visibleElements",void 0),t([c()],j.prototype,"iconClass",void 0),t([c()],j.prototype,"icon",void 0),t([c()],j.prototype,"label",null),t([c()],j.prototype,"visible",null),t([c(),k("esri/widgets/ElevationProfile/t9n/ElevationProfile")],j.prototype,"messages",void 0),t([c(),k("esri/t9n/common")],j.prototype,"messagesCommon",void 0),t([c(),k("esri/core/t9n/Units")],j.prototype,"messagesUnits",void 0),t([c()],j.prototype,"_chartContainer",void 0),t([c()],j.prototype,"_chart",void 0),t([c()],j.prototype,"_chartInitTask",void 0),t([c()],j.prototype,"_chartIsRefined",void 0),t([c()],j.prototype,"_width",void 0),t([c()],j.prototype,"_portrait",null),t([c()],j.prototype,"_zoomOutButtonVisible",void 0),t([c()],j.prototype,"_chartUpdateParams",null),t([c()],j.prototype,"_chartMessages",null),t([c()],j.prototype,"_profilesArray",null),j=t([h("esri.widgets.ElevationProfile")],j);const U=j;export{U 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.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import"../../../intl.js";import{watch as t}from"../../../core/reactiveUtils.js";import{pt2px as s}from"../../../core/screenUtils.js";import{property as i}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import{subclass as a}from"../../../core/accessorSupport/decorators/subclass.js";import{renderSVG as r}from"../../../symbols/support/svgUtils.js";import{getCSSFilterFromEffectList as o}from"../../../symbols/support/utils.js";import l from"../../Widget.js";import{CSS as n}from"./CardCSS.js";import{renderRelationshipRamp as c}from"./support/relationshipUtils.js";import{getUnivariateAboveAndBelowRampElements as p,getUnivariateSizeRampSize as d,getUnivariateColorRampSize as m,getUnivariateColorRampPreview as h,getUnivariateColorRampMargin as y,getUnivariateColorSizeRampElements as g}from"./support/univariateUtils.js";import{getTitle as v,attachToNode as u,isImageryStretchedLegend as f,getStretchStopLabel as b}from"../support/styleUtils.js";import{Heading as _,incrementHeadingLevel as w}from"../../support/Heading.js";import{accessibleHandler as L}from"../../support/decorators/accessibleHandler.js";import{messageBundle as S}from"../../support/decorators/messageBundle.js";import{tsx as x}from"../../support/jsxFactory.js";import{isRTL as C}from"../../support/widgetUtils.js";import{substitute as R}from"../../../intl/substitute.js";const $=25,k=25,z=768,I=100;var A;!function(e){e.Auto="auto",e.Stack="stack",e.SideBySide="side-by-side"}(A||(A={}));const N="#ddd",j=window.devicePixelRatio;function E(e){if(e){if(e.type.includes("3d")){const t=e.symbolLayers&&e.symbolLayers.length;if(!t)return;const s=e.symbolLayers.at(t-1),i=s.resource&&s.resource.primitive;return"circle"===i||"cross"===i||"kite"===i||"sphere"===i||"cube"===i||"diamond"===i}{const t=e.style;return"circle"===t||"diamond"===t||"cross"===t}}}function F(e){if(e){if(e.type.includes("3d")){const t=e.symbolLayers&&e.symbolLayers.length;if(!t)return;const s=e.symbolLayers.at(t-1).get("resource.primitive");return"triangle"===s||"cone"===s||"tetrahedron"===s}return"triangle"===e.style}}let T=class extends l{constructor(e,t){super(e,t),this._hasIndicators=!1,this._selectedSectionName=null,this._sectionNames=[],this._sectionMap=new Map,this.activeLayerInfos=null,this.headingLevel=3,this.layout=A.Stack,this.messages=null,this.messagesCommon=null,this.type="card",this.view=null}initialize(){this.addHandles(t((()=>this.activeLayerInfos),(e=>{this.removeAllHandles(),this._watchForSectionChanges(e)})))}render(){const{view:e}=this;this._hasIndicators=this.layout===A.Auto&&e&&e.container.clientWidth<=z||this.layout===A.Stack;const t=this.activeLayerInfos,s=t&&t.toArray().map((e=>this._renderLegendForLayer(e))).filter((e=>!!e));this._hasIndicators?this._selectedSectionName&&this._sectionNames.includes(this._selectedSectionName)||(this._selectedSectionName=this._sectionNames&&this._sectionNames[0]):this._selectedSectionName=null;const i=this._sectionNames.length,a=this._sectionNames.map(((e,t)=>{const s=R(this.messagesCommon.pagination.pageText,{index:t+1,total:i});return x("div",{key:e,role:"tab",id:e,"aria-label":s,"aria-controls":`${e}-panel`,"aria-selected":(this._selectedSectionName===e).toString(),tabIndex:this._selectedSectionName===e?0:-1,title:s,onclick:this._selectSection,onkeydown:this._focusSection,bind:this,class:this.classes(n.indicator,{[n.activated]:this._selectedSectionName===e}),"data-section-name":e})})),r=this._hasIndicators&&i>1?x("div",{class:n.indicatorContainer,key:"carousel-navigation",role:"tablist"},a):null,o=this._hasIndicators?this._sectionMap.get(this._selectedSectionName):s&&s.length?s:null,l={[n.stacked]:this._hasIndicators};return x("div",{class:this.classes(n.base,l)},o||x("div",{class:n.message},this.messages.noLegend),r)}_selectSection(e){const t=e.target.getAttribute("data-section-name");t&&(this._selectedSectionName=t)}_focusSection(e){switch(e.key){case"ArrowLeft":case"ArrowRight":this._switchSectionOnArrowPress(e);break;case"Enter":case" ":this._selectSection(e)}}_switchSectionOnArrowPress(e){const t=e.key,s="ArrowLeft"===t?-1:1,i=e.target.getAttribute("data-section-name"),a=this._sectionNames.indexOf(i),r=this._sectionNames;let o=null;-1!==a&&(r[a+s]?o=document.getElementById(r[a+s]):"ArrowLeft"===t?o=document.getElementById(r[r.length-1]):"ArrowRight"===t&&(o=document.getElementById(r[0])),o?.focus())}_watchForSectionChanges(e){if(this._generateSectionNames(),e){e.forEach((e=>{const s=`activeLayerInfo-${e.layer.uid}-version-change`;this.removeHandles(s),this._watchForSectionChanges(e.children),this.addHandles(t((()=>e.version),(()=>this._generateSectionNames())),s)}));const s="activeLayerInfos-collection-change";this.removeHandles(s),this.addHandles(e.on("change",(()=>this._watchForSectionChanges(e))),s)}}_generateSectionNames(){this._sectionNames.length=0,this._selectedSectionName=null,this.activeLayerInfos&&this.activeLayerInfos.forEach(this._generateSectionNamesForActiveLayerInfo,this)}_getSectionName(e,t,s){return`${this.id}${e.uid}-type-${t.type}-${s}`}_generateSectionNamesForActiveLayerInfo(e){e.children.forEach(this._generateSectionNamesForActiveLayerInfo,this),e.legendElements&&e.legendElements.forEach(((t,s)=>{this._sectionNames.push(this._getSectionName(e.layer,t,s))}))}_renderLegendForLayer(e){if(!e.ready)return null;if(e.children.length){const t=e.children.map((e=>this._renderLegendForLayer(e))).toArray();return x("div",{key:e.layer.uid,class:this.classes(n.service,n.groupLayer)},x("div",{class:n.serviceCaptionContainer},e.title),t)}{const t=e.legendElements;if(t&&!t.length)return null;const s=t.some((e=>"relationship-ramp"===e.type)),i=t.map(((t,i)=>this._renderLegendForElement(t,e,i,s))).filter((e=>!!e));if(!i.length)return null;const a={[n.groupLayerChild]:!!e.parent};return x("div",{key:e.layer.uid,class:this.classes(n.service,a)},x("div",{class:n.serviceCaptionContainer},x("div",{class:n.serviceCaptionText},e.title)),x("div",{class:n.serviceContent},i))}}_renderLegendForElement(e,t,s,i=!1,a=!1){const r="color-ramp"===e.type,o="opacity-ramp"===e.type,l=t.layer;let p=null;if("string"==typeof e.title)p=e.title;else if(e.title){const t=e.title,s=v(this.messages,t,r||o);p=t.title?`${t.title} (${s})`:s}const d=this._getSectionName(l,e,s),m=this._hasIndicators&&!a?x("div",null,x(_,{level:this.headingLevel,class:n.carouselTitle},t.title),x(_,{level:w(this.headingLevel),class:n.layerCaption},p)):p?x(_,{level:this.headingLevel,class:n.layerCaption},p):null,h=t.effectList;let y=null;switch(e.type){case"symbol-table":{const s=e.infos.map(((s,i)=>this._renderLegendForElementInfo(s,t,e.legendType,i))).filter((e=>!!e));if(s.length){const e=s[0].properties.classes&&s[0].properties.classes[n.symbolRow],t={[n.labelContainer]:!e&&!i,[n.relationshipLabelContainer]:i};y=x("div",{class:this.classes(t)},s)}break}case"color-ramp":case"opacity-ramp":case"heatmap-ramp":case"stretch-ramp":y=this._renderLegendForRamp(e,l.opacity,h);break;case"size-ramp":y=this._renderSizeRamp(e,l.opacity);break;case"pie-chart-ramp":y=this._renderPieChartRamp(e);break;case"relationship-ramp":y=c(e,this.id,{opacity:l.opacity,effectList:h,ariaLabel:this.messages.previewRelationshipRampAriaLabel});break;case"univariate-above-and-below-ramp":y=this._renderUnivariateAboveAndBelowRamp(e,l.opacity,h);break;case"univariate-color-size-ramp":y=this._renderUnivariateColorSizeRamp(e,l.opacity,h)}if(!y)return null;const g=x("div",{key:d,class:n.section,id:`${d}-panel`,role:"tabpanel","aria-labelledby":d,tabIndex:0},[m,y]);return a||this._sectionMap.set(d,g),g}_renderPieChartRamp(e){return x("div",{class:n.pieChartRampPreview,bind:e.preview,afterCreate:u})}_renderUnivariateAboveAndBelowRamp(e,t,s){const{sizeRampElement:i,colorRampElement:a}=p(e,t,"horizontal");if(!i)return null;const r=d(i,"full",!0,"horizontal"),o=m(i,"above",!0,"horizontal"),l=m(i,"below",!0,"horizontal"),c=12,g=this.messages?.previewColorRampAriaLabel,v=h(a,{width:o,height:c,rampAlignment:"horizontal",opacity:t,type:"above",effectList:s,ariaLabel:g}),f=h(a,{width:l,height:c,rampAlignment:"horizontal",opacity:t,type:"below",effectList:s,ariaLabel:g}),b=y(i,"card"),_=i.infos.map((e=>e.label)),w=_.length-1,L=_.map(((e,t)=>0===t||t===w?x("div",{key:t},e):null)),S={display:"flex",flexDirection:"column"},R={display:"flex",flexDirection:"row"},$={marginTop:"3px",display:"flex"};C(this.container)?$.marginRight=`${b}px`:$.marginLeft=`${b}px`;const k={width:`${r}px`,display:"flex",flexDirection:"row",justifyContent:"space-between"};return x("div",{class:n.layerRow,key:"size-ramp-preview",styles:S},x("div",{class:this.classes(n.symbolContainer,n.sizeRampHorizontal),styles:R},i.infos.map(((e,t)=>x("div",{key:t,class:n.symbol,bind:e.preview,afterCreate:u})))),v?x("div",{class:n.univariateAboveAndBelowColorRamp,styles:$,key:"color-ramp-preview"},x("div",{bind:v,afterCreate:u}),x("div",{bind:f,afterCreate:u})):null,x("div",{class:n.layerInfo},x("div",{class:n.rampLabelsContainer,styles:k},L)))}_renderUnivariateColorSizeRamp(e,t,s){const{sizeRampElement:i,colorRampElement:a}=g(e,"horizontal");if(!i)return null;const r=d(i,"full",!1,"horizontal"),o=m(i,"full",!1,"horizontal"),l=h(a,{width:o,height:12,rampAlignment:"horizontal",opacity:t,type:"full",effectList:s,ariaLabel:this.messages?.previewColorRampAriaLabel}),c=y(i,"card"),p=i.infos.length-1,v=i.infos.map(((e,t)=>0===t||t===p?x("div",{key:t},e.label):null)),f={display:"flex",flexDirection:"column"},b={display:"flex",flexDirection:"row"},_={marginTop:"3px",display:"flex"};C(this.container)?_.marginRight=`${c}px`:_.marginLeft=`${c}px`;const w={width:`${r}px`,display:"flex",flexDirection:"row",justifyContent:"space-between"};return x("div",{class:n.layerRow,key:"size-ramp-preview",styles:f},x("div",{class:this.classes(n.symbolContainer,n.sizeRampHorizontal),styles:b},i.infos.map(((e,t)=>x("div",{key:t,class:n.symbol,bind:e.preview,afterCreate:u})))),x("div",{class:n.univariateAboveAndBelowColorRamp,styles:_,key:"color-ramp-preview"},x("div",{bind:l,afterCreate:u})),x("div",{class:n.layerInfo},x("div",{class:n.rampLabelsContainer,styles:w},v)))}_renderLegendForElementInfo(e,t,s,i){const a=t.layer;if(e.type)return this._renderLegendForElement(e,t,i,!1,!0);const r=f(a,s),l=v(this.messages,e.label,!1)??"";if(e.preview){if(!e.symbol||!e.symbol.type.includes("simple-fill")){if(!e.label)return x("div",{key:i,bind:e.preview,afterCreate:u});const t={[n.symbolCell]:this._hasIndicators};return x("div",{key:i,class:this.classes(n.layerRow,{[n.symbolRow]:this._hasIndicators})},x("div",{class:this.classes(t),bind:e.preview,afterCreate:u}),x("div",{class:this.classes(n.imageLabel,{[n.labelCell]:this._hasIndicators})},l))}let s=255,r=255,c=255,p=0,d=255,m=255,h=255,y=0;const g=e.symbol.color&&e.symbol.color.a,v=e.symbol.outline&&e.symbol.outline.color&&e.symbol.outline.color.a;g&&(s=e.symbol.color.r,r=e.symbol.color.g,c=e.symbol.color.b,p=e.symbol.color.a*a.opacity),v&&(d=e.symbol.outline.color.r,m=e.symbol.outline.color.g,h=e.symbol.outline.color.b,y=e.symbol.outline.color.a*a.opacity);const f=e.symbol.color?.isBright??!0,b=f?"rgba(255, 255, 255, .6)":"rgba(0, 0, 0, .6)",_={background:g?`rgba(${s}, ${r}, ${c}, ${p})`:"none",color:f?"black":"white",textShadow:`-1px -1px 0 ${b},\n 1px -1px 0 ${b},\n -1px 1px 0 ${b},\n 1px 1px 0 ${b}`,border:v?`1px solid rgba(${d}, ${m}, ${h}, ${y})`:"none",filter:o(t.effectList)??void 0};return x("div",{key:i,class:n.layerRow},x("div",{class:n.labelElement,styles:_},l))}if(e.src){const t=this._renderImage(e,a,r);return x("div",{key:i,class:n.layerRow},t,x("div",{class:n.imageLabel},l))}}_renderImage(e,t,s){const{label:i,src:a,opacity:r}=e,o={[n.imageryLayerStretchedImage]:s,[n.symbol]:!s},l={opacity:`${null!=r?r:t.opacity}`};return x("img",{alt:v(this.messages,i,!1),"aria-label":v(this.messages,i,!1),src:a,border:0,width:e.width,height:e.height,class:this.classes(o),styles:l})}_renderSizeRampLines(e){const t=e.infos,i=t[0],a=t[t.length-1],r=i.symbol,o=this._hasIndicators,l=s(i.size+i.outlineSize)*j,n=s(a.size+a.outlineSize)*j,c=o?l:l+50*j,p=o?l/2+50*j:l,d=F(r),m=E(r),h=document.createElement("canvas");h.width=c,h.height=p,h.style.width=h.width/j+"px",h.style.height=h.height/j+"px";const y=h.getContext("2d");if(o){y.beginPath();const e=0,t=0,s=c/2-n/2,i=p;y.moveTo(e,t),y.lineTo(s,i);const a=c,r=0,o=c/2+n/2,l=p;y.moveTo(a,r),y.lineTo(o,l)}else{y.beginPath();const e=0,t=p/2-n/2,s=c,i=0;y.moveTo(e,t),y.lineTo(s,i);const a=0,r=p/2+n/2,o=c,l=p;y.moveTo(a,r),y.lineTo(o,l)}return y.strokeStyle=N,y.stroke(),x("div",{bind:h,afterCreate:u,styles:o?{display:"flex",marginTop:`-${d?0:m?l/2:0}px`,marginBottom:`-${d?n:m?n/2:0}px`}:{display:"flex",marginRight:`-${d?0:m?l/2:0}px`,marginLeft:`-${d?0:m?n/2:0}px`}})}_renderSizeRamp(e,t){const s=e.infos,i=s[0].label,a=s[s.length-1].label;let r=s[0].preview,o=s[s.length-1].preview;const l=this._hasIndicators,c={"flex-direction":l?"column":"row-reverse"};r&&(r=r.cloneNode(!0),r.style.display="flex"),o&&(o=o.cloneNode(!0),o.style.display="flex");const p={opacity:null!=t?`${t}`:""};return x("div",{class:this.classes(n.layerRow,{[n.sizeRampRow]:l})},x("div",{class:n.rampLabel},l?i:a),x("div",{class:n.sizeRampContainer,styles:c},x("div",{bind:r,afterCreate:u,class:n.sizeRampPreview,styles:p}),this._renderSizeRampLines(e),x("div",{bind:o,afterCreate:u,class:n.sizeRampContainer,styles:p})),x("div",{class:n.rampLabel},l?a:i))}_getRampStopLabel(e,t){switch(t){case"heatmap-ramp":return this.messages[e.label];case"stretch-ramp":return b(e,this.messages);default:return e.label}}_renderLegendForRamp(e,t,s){const i=e.infos,a=e.type,l="heatmap-ramp"===a,c=i.length-1,p=k,d=c>2&&!l?$*c:I,m=d+20,h=10,y=i.slice(0).reverse(),g=y.length-1,v=y.length%2!=0?y[y.length/2|0]:null,u=v&&x("div",{class:n.intervalSeparatorsContainer},x("div",{class:n.intervalSeparator},"|"),x("div",{class:n.rampLabel},this._getRampStopLabel(v,a))),f=[[{shape:{type:"path",path:`M0 ${p/2} L${h} 0 L${h} ${p} Z`},fill:y[0].color,stroke:{width:0}},{shape:{type:"rect",x:h,y:0,width:d,height:p},fill:{type:"linear",x1:h,y1:0,x2:d+h,y2:0,colors:y.map(((e,t)=>({color:e.color?.toArray(),offset:l&&"ratio"in e?e.ratio:t/c})))},stroke:{width:0}},{shape:{type:"path",path:`M${d+h} 0 L${m} ${p/2} L${d+h} ${p} Z`},fill:y[g].color,stroke:{width:0}}]],b=r(f,m,p),_={filter:o(s)??void 0,opacity:null==t?void 0:`${t}`},w={justifyContent:"center"};return x("div",{class:n.layerRow,styles:w},x("div",{class:n.rampLabel},this._getRampStopLabel(y[0],a)),x("div",{class:n.symbolContainer},x("div",{styles:_},b),u),x("div",{class:n.rampLabel},this._getRampStopLabel(y[g],a)))}};e([i()],T.prototype,"activeLayerInfos",void 0),e([i()],T.prototype,"headingLevel",void 0),e([i()],T.prototype,"layout",void 0),e([i(),S("esri/widgets/Legend/t9n/Legend")],T.prototype,"messages",void 0),e([i(),S("esri/t9n/common")],T.prototype,"messagesCommon",void 0),e([i({readOnly:!0})],T.prototype,"type",void 0),e([i()],T.prototype,"view",void 0),e([L()],T.prototype,"_selectSection",null),T=e([a("esri.widgets.Legend.styles.Card")],T);const U=T;export{U as default};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import"../../../intl.js";import{watch as t}from"../../../core/reactiveUtils.js";import{pt2px as s}from"../../../core/screenUtils.js";import{property as i}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import{subclass as a}from"../../../core/accessorSupport/decorators/subclass.js";import{renderSVG as r}from"../../../symbols/support/svgUtils.js";import{getCSSFilterFromEffectList as o}from"../../../symbols/support/utils.js";import l from"../../Widget.js";import{CSS as n}from"./CardCSS.js";import{renderRelationshipRamp as c}from"./support/relationshipUtils.js";import{getUnivariateAboveAndBelowRampElements as p,getUnivariateSizeRampSize as d,getUnivariateColorRampSize as m,getUnivariateColorRampPreview as h,getUnivariateColorRampMargin as y,getUnivariateColorSizeRampElements as g}from"./support/univariateUtils.js";import{getTitle as v,attachToNode as u,isImageryStretchedLegend as f,getStretchStopLabel as b}from"../support/styleUtils.js";import{Heading as _,incrementHeadingLevel as w}from"../../support/Heading.js";import{accessibleHandler as L}from"../../support/decorators/accessibleHandler.js";import{messageBundle as S}from"../../support/decorators/messageBundle.js";import{tsx as x}from"../../support/jsxFactory.js";import{isRTL as C}from"../../support/widgetUtils.js";import{substitute as R}from"../../../intl/substitute.js";const $=25,k=25,z=768,I=100;var N;!function(e){e.Auto="auto",e.Stack="stack",e.SideBySide="side-by-side"}(N||(N={}));const A="#ddd",j=window.devicePixelRatio;function E(e){if(e){if(e.type.includes("3d")){const t=e.symbolLayers&&e.symbolLayers.length;if(!t)return;const s=e.symbolLayers.at(t-1),i=s.resource&&s.resource.primitive;return"circle"===i||"cross"===i||"kite"===i||"sphere"===i||"cube"===i||"diamond"===i}{const t=e.style;return"circle"===t||"diamond"===t||"cross"===t}}}function F(e){if(e){if(e.type.includes("3d")){const t=e.symbolLayers&&e.symbolLayers.length;if(!t)return;const s=e.symbolLayers.at(t-1).get("resource.primitive");return"triangle"===s||"cone"===s||"tetrahedron"===s}return"triangle"===e.style}}let T=class extends l{constructor(e,t){super(e,t),this._hasIndicators=!1,this._selectedSectionName=null,this._sectionNames=[],this._sectionMap=new Map,this.activeLayerInfos=null,this.headingLevel=3,this.layout=N.Stack,this.messages=null,this.messagesCommon=null,this.type="card",this.view=null}initialize(){this.addHandles(t((()=>this.activeLayerInfos),(e=>{this.removeAllHandles(),this._watchForSectionChanges(e)})))}render(){const{view:e}=this;this._hasIndicators=this.layout===N.Auto&&e&&e.container.clientWidth<=z||this.layout===N.Stack;const t=this.activeLayerInfos,s=t&&t.toArray().map((e=>this._renderLegendForLayer(e))).filter((e=>!!e));this._hasIndicators?this._selectedSectionName&&this._sectionNames.includes(this._selectedSectionName)||(this._selectedSectionName=this._sectionNames&&this._sectionNames[0]):this._selectedSectionName=null;const i=this._sectionNames.length,a=this._sectionNames.map(((e,t)=>{const s=R(this.messagesCommon.pagination.pageText,{index:t+1,total:i});return x("div",{key:e,role:"tab",id:e,"aria-label":s,"aria-controls":`${e}-panel`,"aria-selected":(this._selectedSectionName===e).toString(),tabIndex:this._selectedSectionName===e?0:-1,title:s,onclick:this._selectSection,onkeydown:this._focusSection,bind:this,class:this.classes(n.indicator,{[n.activated]:this._selectedSectionName===e}),"data-section-name":e})})),r=this._hasIndicators&&i>1?x("div",{class:n.indicatorContainer,key:"carousel-navigation",role:"tablist"},a):null,o=this._hasIndicators?this._sectionMap.get(this._selectedSectionName):s&&s.length?s:null,l={[n.stacked]:this._hasIndicators};return x("div",{class:this.classes(n.base,l)},o||x("div",{class:n.message},this.messages.noLegend),r)}_selectSection(e){const t=e.target.getAttribute("data-section-name");t&&(this._selectedSectionName=t)}_focusSection(e){switch(e.key){case"ArrowLeft":case"ArrowRight":this._switchSectionOnArrowPress(e);break;case"Enter":case" ":this._selectSection(e)}}_switchSectionOnArrowPress(e){const t=e.key,s="ArrowLeft"===t?-1:1,i=e.target.getAttribute("data-section-name"),a=this._sectionNames.indexOf(i),r=this._sectionNames;let o=null;-1!==a&&(r[a+s]?o=document.getElementById(r[a+s]):"ArrowLeft"===t?o=document.getElementById(r[r.length-1]):"ArrowRight"===t&&(o=document.getElementById(r[0])),o?.focus())}_watchForSectionChanges(e){if(this._generateSectionNames(),e){e.forEach((e=>{const s=`activeLayerInfo-${e.layer.uid}-version-change`;this.removeHandles(s),this._watchForSectionChanges(e.children),this.addHandles(t((()=>e.version),(()=>this._generateSectionNames())),s)}));const s="activeLayerInfos-collection-change";this.removeHandles(s),this.addHandles(e.on("change",(()=>this._watchForSectionChanges(e))),s)}}_generateSectionNames(){this._sectionNames.length=0,this._selectedSectionName=null,this.activeLayerInfos&&this.activeLayerInfos.forEach(this._generateSectionNamesForActiveLayerInfo,this)}_getSectionName(e,t,s){return`${this.id}${e.uid}-type-${t.type}-${s}`}_generateSectionNamesForActiveLayerInfo(e){e.children.forEach(this._generateSectionNamesForActiveLayerInfo,this),e.legendElements&&e.legendElements.forEach(((t,s)=>{this._sectionNames.push(this._getSectionName(e.layer,t,s))}))}_renderLegendForLayer(e){if(!e.ready)return null;if(e.children.length){const t=e.children.map((e=>this._renderLegendForLayer(e))).toArray();return x("div",{key:e.layer.uid,class:this.classes(n.service,n.groupLayer)},x("div",{class:n.serviceCaptionContainer},e.title),t)}{const t=e.legendElements;if(t&&!t.length)return null;const s=t.some((e=>"relationship-ramp"===e.type)),i=t.map(((t,i)=>this._renderLegendForElement(t,e,i,s))).filter((e=>!!e));if(!i.length)return null;const a={[n.groupLayerChild]:!!e.parent};return x("div",{key:e.layer.uid,class:this.classes(n.service,a)},x("div",{class:n.serviceCaptionContainer},x("div",{class:n.serviceCaptionText},e.title)),x("div",{class:n.serviceContent},i))}}_renderLegendForElement(e,t,s,i=!1,a=!1){const r="color-ramp"===e.type,o="opacity-ramp"===e.type,l=t.layer;let p=null;if("string"==typeof e.title)p=e.title;else if(e.title){const t=e.title,s=v(this.messages,t,r||o);p=t.title?`${t.title} (${s})`:s}const d=this._getSectionName(l,e,s),m=this._hasIndicators&&!a?x("div",null,x(_,{level:this.headingLevel,class:n.carouselTitle},t.title),x(_,{level:w(this.headingLevel),class:n.layerCaption},p)):p?x(_,{level:this.headingLevel,class:n.layerCaption},p):null,h=t.effectList;let y=null;switch(e.type){case"symbol-table":{const s=e.infos.map(((s,i)=>this._renderLegendForElementInfo(s,t,e.legendType,i))).filter((e=>!!e));if(s.length){const e=s[0].properties.classes&&s[0].properties.classes[n.symbolRow],t={[n.labelContainer]:!e&&!i,[n.relationshipLabelContainer]:i};y=x("div",{class:this.classes(t)},s)}break}case"color-ramp":case"opacity-ramp":case"heatmap-ramp":case"stretch-ramp":y=this._renderLegendForRamp(e,l.opacity,h);break;case"size-ramp":y=this._renderSizeRamp(e,l.opacity);break;case"pie-chart-ramp":y=this._renderPieChartRamp(e);break;case"relationship-ramp":y=c(e,this.id,{opacity:l.opacity,effectList:h,ariaLabel:this.messages.previewRelationshipRampAriaLabel});break;case"univariate-above-and-below-ramp":y=this._renderUnivariateAboveAndBelowRamp(e,l.opacity,h);break;case"univariate-color-size-ramp":y=this._renderUnivariateColorSizeRamp(e,l.opacity,h)}if(!y)return null;const g=x("div",{key:d,class:n.section,id:`${d}-panel`,role:"tabpanel","aria-labelledby":d,tabIndex:0},[m,y]);return a||this._sectionMap.set(d,g),g}_renderPieChartRamp(e){return x("div",{class:n.pieChartRampPreview,bind:e.preview,afterCreate:u})}_renderUnivariateAboveAndBelowRamp(e,t,s){const{sizeRampElement:i,colorRampElement:a}=p(e,t,"horizontal");if(!i)return null;const r=d(i,"full",!0,"horizontal"),o=m(i,"above",!0,"horizontal"),l=m(i,"below",!0,"horizontal"),c=12,g=this.messages?.previewColorRampAriaLabel,v=h(a,{width:o,height:c,rampAlignment:"horizontal",opacity:t,type:"above",effectList:s,ariaLabel:g}),f=h(a,{width:l,height:c,rampAlignment:"horizontal",opacity:t,type:"below",effectList:s,ariaLabel:g}),b=y(i,"card"),_=i.infos.map((e=>e.label)),w=_.length-1,L=_.map(((e,t)=>0===t||t===w?x("div",{key:t},e):null)),S={display:"flex",flexDirection:"column"},R={display:"flex",flexDirection:"row"},$={marginTop:"3px",display:"flex"};C(this.container)?$.marginRight=`${b}px`:$.marginLeft=`${b}px`;const k={width:`${r}px`,display:"flex",flexDirection:"row",justifyContent:"space-between"};return x("div",{class:n.layerRow,key:"size-ramp-preview",styles:S},x("div",{class:this.classes(n.symbolContainer,n.sizeRampHorizontal),styles:R},i.infos.map(((e,t)=>x("div",{key:t,class:n.symbol,bind:e.preview,afterCreate:u})))),v?x("div",{class:n.univariateAboveAndBelowColorRamp,styles:$,key:"color-ramp-preview"},x("div",{bind:v,afterCreate:u}),x("div",{bind:f,afterCreate:u})):null,x("div",{class:n.layerInfo},x("div",{class:n.rampLabelsContainer,styles:k},L)))}_renderUnivariateColorSizeRamp(e,t,s){const{sizeRampElement:i,colorRampElement:a}=g(e,"horizontal");if(!i)return null;const r=d(i,"full",!1,"horizontal"),o=m(i,"full",!1,"horizontal"),l=h(a,{width:o,height:12,rampAlignment:"horizontal",opacity:t,type:"full",effectList:s,ariaLabel:this.messages?.previewColorRampAriaLabel}),c=y(i,"card"),p=i.infos.length-1,v=i.infos.map(((e,t)=>0===t||t===p?x("div",{key:t},e.label):null)),f={display:"flex",flexDirection:"column"},b={display:"flex",flexDirection:"row"},_={marginTop:"3px",display:"flex"};C(this.container)?_.marginRight=`${c}px`:_.marginLeft=`${c}px`;const w={width:`${r}px`,display:"flex",flexDirection:"row",justifyContent:"space-between"};return x("div",{class:n.layerRow,key:"size-ramp-preview",styles:f},x("div",{class:this.classes(n.symbolContainer,n.sizeRampHorizontal),styles:b},i.infos.map(((e,t)=>x("div",{key:t,class:n.symbol,bind:e.preview,afterCreate:u})))),x("div",{class:n.univariateAboveAndBelowColorRamp,styles:_,key:"color-ramp-preview"},x("div",{bind:l,afterCreate:u})),x("div",{class:n.layerInfo},x("div",{class:n.rampLabelsContainer,styles:w},v)))}_renderLegendForElementInfo(e,t,s,i){const a=t.layer;if(e.type)return this._renderLegendForElement(e,t,i,!1,!0);const r=f(a,s),l=v(this.messages,e.label,!1)??"";if(e.preview){if(!e.symbol||!e.symbol.type.includes("simple-fill")){if(!e.label)return x("div",{key:i,bind:e.preview,afterCreate:u});const t={[n.symbolCell]:this._hasIndicators};return x("div",{key:i,class:this.classes(n.layerRow,{[n.symbolRow]:this._hasIndicators})},x("div",{class:this.classes(t),bind:e.preview,afterCreate:u}),x("div",{class:this.classes(n.imageLabel,{[n.labelCell]:this._hasIndicators})},l))}let s=255,r=255,c=255,p=0,d=255,m=255,h=255,y=0;const g=e.symbol.color&&e.symbol.color.a,v=e.symbol.outline&&e.symbol.outline.color&&e.symbol.outline.color.a;g&&(s=e.symbol.color.r,r=e.symbol.color.g,c=e.symbol.color.b,p=e.symbol.color.a*a.opacity),v&&(d=e.symbol.outline.color.r,m=e.symbol.outline.color.g,h=e.symbol.outline.color.b,y=e.symbol.outline.color.a*a.opacity);const f=e.symbol.color?.isBright??!0,b=f?"rgba(255, 255, 255, .6)":"rgba(0, 0, 0, .6)",_={background:g?`rgba(${s}, ${r}, ${c}, ${p})`:"none",color:f?"black":"white",textShadow:`-1px -1px 0 ${b},\n 1px -1px 0 ${b},\n -1px 1px 0 ${b},\n 1px 1px 0 ${b}`,border:v?`1px solid rgba(${d}, ${m}, ${h}, ${y})`:"none",filter:o(t.effectList)??void 0};return x("div",{key:i,class:n.layerRow},x("div",{class:n.labelElement,styles:_},l))}if(e.src){const t=this._renderImage(e,a,r);return x("div",{key:i,class:n.layerRow},t,x("div",{class:n.imageLabel},l))}}_renderImage(e,t,s){const{label:i,src:a,opacity:r}=e,o={[n.imageryLayerStretchedImage]:s,[n.symbol]:!s},l={opacity:`${null!=r?r:t.opacity}`};return x("img",{alt:v(this.messages,i,!1),"aria-label":v(this.messages,i,!1),src:a,border:0,width:e.width,height:e.height,class:this.classes(o),styles:l})}_renderSizeRampLines(e){const t=e.infos,i=t[0],a=t[t.length-1],r=i.symbol,o=this._hasIndicators,l=s(i.size+i.outlineSize)*j,n=s(a.size+a.outlineSize)*j,c=o?l:l+50*j,p=o?l/2+50*j:l,d=F(r),m=E(r),h=document.createElement("canvas");h.width=c,h.height=p,h.style.width=h.width/j+"px",h.style.height=h.height/j+"px";const y=h.getContext("2d");if(o){y.beginPath();const e=0,t=0,s=c/2-n/2,i=p;y.moveTo(e,t),y.lineTo(s,i);const a=c,r=0,o=c/2+n/2,l=p;y.moveTo(a,r),y.lineTo(o,l)}else{y.beginPath();const e=0,t=p/2-n/2,s=c,i=0;y.moveTo(e,t),y.lineTo(s,i);const a=0,r=p/2+n/2,o=c,l=p;y.moveTo(a,r),y.lineTo(o,l)}return y.strokeStyle=A,y.stroke(),x("div",{bind:h,afterCreate:u,styles:o?{display:"flex",marginTop:`-${d?0:m?l/2:0}px`,marginBottom:`-${d?n:m?n/2:0}px`}:{display:"flex",marginRight:`-${d?0:m?l/2:0}px`,marginLeft:`-${d?0:m?n/2:0}px`}})}_renderSizeRamp(e,t){const s=e.infos,i=s[0].label,a=s[s.length-1].label;let r=s[0].preview,o=s[s.length-1].preview;const l=this._hasIndicators,c={"flex-direction":l?"column":"row-reverse"};r&&(r=r.cloneNode(!0),r.style.display="flex"),o&&(o=o.cloneNode(!0),o.style.display="flex");const p={opacity:null!=t?`${t}`:""};return x("div",{class:this.classes(n.layerRow,{[n.sizeRampRow]:l})},x("div",{class:n.rampLabel},l?i:a),x("div",{class:n.sizeRampContainer,styles:c},x("div",{bind:r,afterCreate:u,class:n.sizeRampPreview,styles:p}),this._renderSizeRampLines(e),x("div",{bind:o,afterCreate:u,class:n.sizeRampContainer,styles:p})),x("div",{class:n.rampLabel},l?a:i))}_getRampStopLabel(e,t){switch(t){case"heatmap-ramp":return this.messages[e.label];case"stretch-ramp":return b(e,this.messages);default:return e.label}}_renderLegendForRamp(e,t,s){const i=e.infos,a=e.type,l="heatmap-ramp"===a,c=i.length-1,p=k,d=c>2&&!l?$*c:I,m=d+20,h=10,y=i.slice(0).reverse(),g=y.length-1,v=y.length%2!=0?y[y.length/2|0]:null,u=v&&x("div",{class:n.intervalSeparatorsContainer},x("div",{class:n.intervalSeparator},"|"),x("div",{class:n.rampLabel},this._getRampStopLabel(v,a))),f=[[{shape:{type:"path",path:`M0 ${p/2} L${h} 0 L${h} ${p} Z`},fill:y[0].color,stroke:{width:0}},{shape:{type:"rect",x:h,y:0,width:d,height:p},fill:{type:"linear",x1:h,y1:0,x2:d+h,y2:0,colors:y.map(((e,t)=>({color:e.color,offset:l&&"ratio"in e?e.ratio:t/c})))},stroke:{width:0}},{shape:{type:"path",path:`M${d+h} 0 L${m} ${p/2} L${d+h} ${p} Z`},fill:y[g].color,stroke:{width:0}}]],b=r(f,m,p),_={filter:o(s)??void 0,opacity:null==t?void 0:`${t}`},w={justifyContent:"center"};return x("div",{class:n.layerRow,styles:w},x("div",{class:n.rampLabel},this._getRampStopLabel(y[0],a)),x("div",{class:n.symbolContainer},x("div",{styles:_},b),u),x("div",{class:n.rampLabel},this._getRampStopLabel(y[g],a)))}};e([i()],T.prototype,"activeLayerInfos",void 0),e([i()],T.prototype,"headingLevel",void 0),e([i()],T.prototype,"layout",void 0),e([i(),S("esri/widgets/Legend/t9n/Legend")],T.prototype,"messages",void 0),e([i(),S("esri/t9n/common")],T.prototype,"messagesCommon",void 0),e([i({readOnly:!0})],T.prototype,"type",void 0),e([i()],T.prototype,"view",void 0),e([L()],T.prototype,"_selectSection",null),T=e([a("esri.widgets.Legend.styles.Card")],T);const U=T;export{U 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.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import{property as s}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import{subclass as a}from"../../../core/accessorSupport/decorators/subclass.js";import t from"../../Widget.js";import{CSS as r,LEGEND as i}from"./ClassicCSS.js";import{renderRelationshipRamp as l}from"./support/relationshipUtils.js";import{getUnivariateAboveAndBelowRampElements as o,getUnivariateColorRampSize as n,getUnivariateColorRampPreview as p,getUnivariateColorRampMargin as d,getUnivariateColorSizeRampElements as c}from"./support/univariateUtils.js";import{getTitle as m,isRendererTitle as y,attachToNode as v,getStretchStopLabel as h,isImageryStretchedLegend as g}from"../support/styleUtils.js";import{Heading as u}from"../../support/Heading.js";import"../../support/widgetUtils.js";import{messageBundle as b}from"../../support/decorators/messageBundle.js";import{tsx as f}from"../../support/jsxFactory.js";const L=`${i}__`,w=24,C={display:"flex",alignItems:"flex-start"},R={marginLeft:"3px"},A={display:"table-cell",verticalAlign:"middle"};let _=class extends t{constructor(e,s){super(e,s),this.activeLayerInfos=null,this.headingLevel=3,this.messages=null,this.type="classic"}render(){const e=this.activeLayerInfos,s=e&&e.toArray().map((e=>this._renderLegendForLayer(e))).filter((e=>!!e));return f("div",null,s&&s.length?s:f("div",{class:r.message},this.messages.noLegend))}_renderLegendForLayer(e){if(!e.ready)return null;const s=!!e.children.length,a=`${L}${e.layer.uid}-version-${e.version}`,t=e.title?u({level:this.headingLevel,class:this.classes(r.header,r.label)},e.title):null;if(s){const s=e.children.map((e=>this._renderLegendForLayer(e))).toArray();return f("div",{key:a,class:this.classes(r.service,r.groupLayer)},t,s)}{const s=e.legendElements;if(s&&!s.length)return null;const i=s.map((s=>this._renderLegendForElement(s,e.layer,e.effectList))).filter((e=>!!e));if(!i.length)return null;const l={[r.groupLayerChild]:!!e.parent};return f("div",{key:a,class:this.classes(r.service,l),tabIndex:0},t,f("div",{class:r.layer},i))}}_renderLegendForElement(e,s,a,t){const i="color-ramp"===e.type,o="opacity-ramp"===e.type,n="size-ramp"===e.type;let p=null;if("symbol-table"===e.type||n){const t=e.infos.map((t=>this._renderLegendForElementInfo(t,s,a,n,e.legendType))).filter((e=>!!e));t.length&&(p=f("div",{class:r.layerBody},t))}else"color-ramp"===e.type||"opacity-ramp"===e.type||"heatmap-ramp"===e.type||"stretch-ramp"===e.type?p=this._renderLegendForRamp(e,s.opacity):"relationship-ramp"===e.type?p=l(e,this.id,{opacity:s.opacity,effectList:a,ariaLabel:this.messages.previewRelationshipRampAriaLabel}):"pie-chart-ramp"===e.type?p=this._renderPieChartRamp(e):"univariate-above-and-below-ramp"===e.type?p=this._renderUnivariateAboveAndBelowRamp(e,s.opacity,a):"univariate-color-size-ramp"===e.type&&(p=this._renderUnivariateColorSizeRamp(e,s.opacity,a));if(!p)return null;const d=e.title;let c=null;if("string"==typeof d)c=d;else if(d){const e=m(this.messages,d,i||o);c=y(d,i||o)&&d.title?`${d.title} (${e})`:e}const v=t?r.layerChildTable:r.layerTable,h=c?f("div",{class:r.layerCaption},c):null,g={[r.layerTableSizeRamp]:n||!t};return f("div",{class:this.classes(v,g)},h,p)}_renderPieChartRamp(e){return f("div",{bind:e.preview,afterCreate:v})}_renderUnivariateAboveAndBelowRamp(e,s,a){const{sizeRampElement:t,colorRampElement:i}=o(e,s);if(!t)return null;const l=this.messages?.previewColorRampAriaLabel,c=n(t,"above",!0),m=n(t,"below",!0),y=12,h=p(i,{width:y,height:c,rampAlignment:"vertical",opacity:s,type:"above",effectList:a,ariaLabel:l}),g=p(i,{width:y,height:m,rampAlignment:"vertical",opacity:s,type:"below",effectList:a,ariaLabel:l}),u=d(t),b=t.infos.map((e=>e.label)),L=b.map(((e,s)=>{const a=2===s;return 0===s?f("div",{key:s,class:e?h?r.univariateAboveAndBelowLabel:r.rampLabel:void 0},e):a?f("div",null):null})),w=b.length-1,_=Math.floor(b.length/2),j=b.map(((e,s)=>s===_||s===w?f("div",{key:s,class:e?h?r.univariateAboveAndBelowLabel:r.rampLabel:void 0},e):null)),I={display:"table-cell",verticalAlign:"middle"},$={marginTop:`${u}px`},x={height:`${c}px`},S={height:`${m}px`};return f("div",{key:"univariate-above-and-below-ramp-preview",styles:C},f("div",{class:r.layerBody},t.infos.map(((e,s)=>f("div",{class:this.classes(r.layerRow,r.sizeRamp)},f("div",{class:r.symbol,styles:I,bind:e.preview,afterCreate:v}),h||s%2!=0?null:f("div",{class:r.layerInfo},b[s]))))),h?f("div",{styles:$,key:"color-ramp-preview"},f("div",{styles:R},f("div",{styles:A},f("div",{class:r.rampContainer,bind:h,afterCreate:v})),f("div",{styles:A},f("div",{class:r.rampLabelsContainer,styles:x},L))),f("div",{styles:R},f("div",{styles:A},f("div",{class:r.rampContainer,bind:g,afterCreate:v})),f("div",{styles:A},f("div",{class:r.rampLabelsContainer,styles:S},j)))):null)}_renderUnivariateColorSizeRamp(e,s,a){const{sizeRampElement:t,colorRampElement:i}=c(e);if(!t)return null;const l=d(t),o=12,m=n(t,"full",!1),y=p(i,{width:o,height:m,rampAlignment:"vertical",opacity:s,type:"full",effectList:a,ariaLabel:this.messages?.previewColorRampAriaLabel}),h=t.infos.length-1,g=t.infos.map(((e,s)=>0===s||s===h?f("div",{key:s,class:e.label?i?r.univariateAboveAndBelowLabel:r.rampLabel:void 0},e.label):null)),u={display:"table-cell",verticalAlign:"middle"},b={marginTop:`${l}px`},L={height:`${m}px`};return f("div",{key:"univariate-above-and-below-ramp-preview",styles:C},f("div",{class:r.layerBody},t.infos.map((e=>f("div",{class:this.classes(r.layerRow,r.sizeRamp)},f("div",{class:r.symbol,styles:u,bind:e.preview,afterCreate:v}))))),f("div",{styles:b,key:"color-ramp-preview"},f("div",{styles:R},f("div",{styles:A},f("div",{class:r.rampContainer,bind:y,afterCreate:v})),f("div",{styles:A},f("div",{class:r.rampLabelsContainer,styles:L},g)))))}_renderLegendForRamp(e,s){const a=e.infos,t="opacity-ramp"===e.type,i="heatmap-ramp"===e.type,l="stretch-ramp"===e.type,o=e.preview,n=t?r.opacityRamp:"";o.className=`${r.colorRamp} ${n}`,null!=s&&(o.style.opacity=s.toString());const p=a.map((e=>f("div",{class:e.label?r.rampLabel:void 0},i?this.messages[e.label]||e.label:l?h(e,this.messages):e.label))),d={width:`${w}px`},c={height:o.style.height};return f("div",{class:r.layerRow},f("div",{class:r.symbolContainer,styles:d},f("div",{class:r.rampContainer,bind:o,afterCreate:v})),f("div",{class:r.layerInfo},f("div",{class:r.rampLabelsContainer,styles:c},p)))}_renderLegendForElementInfo(e,s,a,t,i){if(e.type)return this._renderLegendForElement(e,s,a,!0);let l=null;const o=g(s,i);if(e.preview?l=f("div",{class:r.symbol,bind:e.preview,afterCreate:v}):e.src&&(l=this._renderImage(e,s,o)),!l)return null;const n={[r.imageryLayerInfoStretched]:o},p={[r.imageryLayerInfoStretched]:o,[r.sizeRamp]:!o&&t};return f("div",{class:r.layerRow},f("div",{class:this.classes(r.symbolContainer,p)},l),f("div",{class:this.classes(r.layerInfo,n)},m(this.messages,e.label,!1)||""))}_renderImage(e,s,a){const{label:t,src:i,opacity:l}=e,o={[r.imageryLayerStretchedImage]:a,[r.symbol]:!a},n={opacity:`${null!=l?l:s.opacity}`};return f("img",{alt:m(this.messages,t,!1),"aria-label":m(this.messages,t,!1),src:i,border:0,width:e.width,height:e.height,class:this.classes(o),styles:n})}};e([s()],_.prototype,"activeLayerInfos",void 0),e([s()],_.prototype,"headingLevel",void 0),e([s(),b("esri/widgets/Legend/t9n/Legend")],_.prototype,"messages",void 0),e([s({readOnly:!0})],_.prototype,"type",void 0),_=e([a("esri.widgets.Legend.styles.Classic")],_);const j=_;export{j as default};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import{property as s}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import{subclass as a}from"../../../core/accessorSupport/decorators/subclass.js";import t from"../../Widget.js";import{CSS as r,LEGEND as i}from"./ClassicCSS.js";import{renderRelationshipRamp as l}from"./support/relationshipUtils.js";import{getUnivariateAboveAndBelowRampElements as o,getUnivariateColorRampSize as n,getUnivariateColorRampPreview as p,getUnivariateColorRampMargin as d,getUnivariateColorSizeRampElements as c}from"./support/univariateUtils.js";import{getTitle as m,isRendererTitle as y,attachToNode as v,getStretchStopLabel as h,isImageryStretchedLegend as g}from"../support/styleUtils.js";import{Heading as u}from"../../support/Heading.js";import"../../support/widgetUtils.js";import{messageBundle as b}from"../../support/decorators/messageBundle.js";import{tsx as f}from"../../support/jsxFactory.js";const L=`${i}__`,w=24,C={display:"flex",alignItems:"flex-start"},R={marginLeft:"3px"},A={display:"table-cell",verticalAlign:"middle"};let _=class extends t{constructor(e,s){super(e,s),this.activeLayerInfos=null,this.headingLevel=3,this.messages=null,this.type="classic"}render(){const e=this.activeLayerInfos,s=e&&e.toArray().map((e=>this._renderLegendForLayer(e))).filter((e=>!!e));return f("div",null,s&&s.length?s:f("div",{class:r.message},this.messages.noLegend))}_renderLegendForLayer(e){if(!e.ready)return null;const s=!!e.children.length,a=`${L}${e.layer.uid}-version-${e.version}`,t=e.title?u({level:this.headingLevel,class:this.classes(r.header,r.label)},e.title):null;if(s){const s=e.children.map((e=>this._renderLegendForLayer(e))).toArray();return f("div",{key:a,class:this.classes(r.service,r.groupLayer)},t,s)}{const s=e.legendElements;if(s&&!s.length)return null;const i=s.map((s=>this._renderLegendForElement(s,e.layer,e.effectList))).filter((e=>!!e));if(!i.length)return null;const l={[r.groupLayerChild]:!!e.parent};return f("div",{key:a,class:this.classes(r.service,l)},t,f("div",{class:r.layer},i))}}_renderLegendForElement(e,s,a,t){const i="color-ramp"===e.type,o="opacity-ramp"===e.type,n="size-ramp"===e.type;let p=null;if("symbol-table"===e.type||n){const t=e.infos.map((t=>this._renderLegendForElementInfo(t,s,a,n,e.legendType))).filter((e=>!!e));t.length&&(p=f("div",{class:r.layerBody},t))}else"color-ramp"===e.type||"opacity-ramp"===e.type||"heatmap-ramp"===e.type||"stretch-ramp"===e.type?p=this._renderLegendForRamp(e,s.opacity):"relationship-ramp"===e.type?p=l(e,this.id,{opacity:s.opacity,effectList:a,ariaLabel:this.messages.previewRelationshipRampAriaLabel}):"pie-chart-ramp"===e.type?p=this._renderPieChartRamp(e):"univariate-above-and-below-ramp"===e.type?p=this._renderUnivariateAboveAndBelowRamp(e,s.opacity,a):"univariate-color-size-ramp"===e.type&&(p=this._renderUnivariateColorSizeRamp(e,s.opacity,a));if(!p)return null;const d=e.title;let c=null;if("string"==typeof d)c=d;else if(d){const e=m(this.messages,d,i||o);c=y(d,i||o)&&d.title?`${d.title} (${e})`:e}const v=t?r.layerChildTable:r.layerTable,h=c?f("div",{class:r.layerCaption},c):null,g={[r.layerTableSizeRamp]:n||!t};return f("div",{class:this.classes(v,g)},h,p)}_renderPieChartRamp(e){return f("div",{bind:e.preview,afterCreate:v})}_renderUnivariateAboveAndBelowRamp(e,s,a){const{sizeRampElement:t,colorRampElement:i}=o(e,s);if(!t)return null;const l=this.messages?.previewColorRampAriaLabel,c=n(t,"above",!0),m=n(t,"below",!0),y=12,h=p(i,{width:y,height:c,rampAlignment:"vertical",opacity:s,type:"above",effectList:a,ariaLabel:l}),g=p(i,{width:y,height:m,rampAlignment:"vertical",opacity:s,type:"below",effectList:a,ariaLabel:l}),u=d(t),b=t.infos.map((e=>e.label)),L=b.map(((e,s)=>{const a=2===s;return 0===s?f("div",{key:s,class:e?h?r.univariateAboveAndBelowLabel:r.rampLabel:void 0},e):a?f("div",null):null})),w=b.length-1,_=Math.floor(b.length/2),j=b.map(((e,s)=>s===_||s===w?f("div",{key:s,class:e?h?r.univariateAboveAndBelowLabel:r.rampLabel:void 0},e):null)),$={display:"table-cell",verticalAlign:"middle"},I={marginTop:`${u}px`},x={height:`${c}px`},S={height:`${m}px`};return f("div",{key:"univariate-above-and-below-ramp-preview",styles:C},f("div",{class:r.layerBody},t.infos.map(((e,s)=>f("div",{class:this.classes(r.layerRow,r.sizeRamp)},f("div",{class:r.symbol,styles:$,bind:e.preview,afterCreate:v}),h||s%2!=0?null:f("div",{class:r.layerInfo},b[s]))))),h?f("div",{styles:I,key:"color-ramp-preview"},f("div",{styles:R},f("div",{styles:A},f("div",{class:r.rampContainer,bind:h,afterCreate:v})),f("div",{styles:A},f("div",{class:r.rampLabelsContainer,styles:x},L))),f("div",{styles:R},f("div",{styles:A},f("div",{class:r.rampContainer,bind:g,afterCreate:v})),f("div",{styles:A},f("div",{class:r.rampLabelsContainer,styles:S},j)))):null)}_renderUnivariateColorSizeRamp(e,s,a){const{sizeRampElement:t,colorRampElement:i}=c(e);if(!t)return null;const l=d(t),o=12,m=n(t,"full",!1),y=p(i,{width:o,height:m,rampAlignment:"vertical",opacity:s,type:"full",effectList:a,ariaLabel:this.messages?.previewColorRampAriaLabel}),h=t.infos.length-1,g=t.infos.map(((e,s)=>0===s||s===h?f("div",{key:s,class:e.label?i?r.univariateAboveAndBelowLabel:r.rampLabel:void 0},e.label):null)),u={display:"table-cell",verticalAlign:"middle"},b={marginTop:`${l}px`},L={height:`${m}px`};return f("div",{key:"univariate-above-and-below-ramp-preview",styles:C},f("div",{class:r.layerBody},t.infos.map((e=>f("div",{class:this.classes(r.layerRow,r.sizeRamp)},f("div",{class:r.symbol,styles:u,bind:e.preview,afterCreate:v}))))),f("div",{styles:b,key:"color-ramp-preview"},f("div",{styles:R},f("div",{styles:A},f("div",{class:r.rampContainer,bind:y,afterCreate:v})),f("div",{styles:A},f("div",{class:r.rampLabelsContainer,styles:L},g)))))}_renderLegendForRamp(e,s){const a=e.infos,t="opacity-ramp"===e.type,i="heatmap-ramp"===e.type,l="stretch-ramp"===e.type,o=e.preview,n=t?r.opacityRamp:"";o.className=`${r.colorRamp} ${n}`,null!=s&&(o.style.opacity=s.toString());const p=a.map((e=>f("div",{class:e.label?r.rampLabel:void 0},i?this.messages[e.label]||e.label:l?h(e,this.messages):e.label))),d={width:`${w}px`},c={height:o.style.height};return f("div",{class:r.layerRow},f("div",{class:r.symbolContainer,styles:d},f("div",{class:r.rampContainer,bind:o,afterCreate:v})),f("div",{class:r.layerInfo},f("div",{class:r.rampLabelsContainer,styles:c},p)))}_renderLegendForElementInfo(e,s,a,t,i){if(e.type)return this._renderLegendForElement(e,s,a,!0);let l=null;const o=g(s,i);if(e.preview?l=f("div",{class:r.symbol,bind:e.preview,afterCreate:v}):e.src&&(l=this._renderImage(e,s,o)),!l)return null;const n={[r.imageryLayerInfoStretched]:o},p={[r.imageryLayerInfoStretched]:o,[r.sizeRamp]:!o&&t};return f("div",{class:r.layerRow},f("div",{class:this.classes(r.symbolContainer,p)},l),f("div",{class:this.classes(r.layerInfo,n)},m(this.messages,e.label,!1)||""))}_renderImage(e,s,a){const{label:t,src:i,opacity:l}=e,o={[r.imageryLayerStretchedImage]:a,[r.symbol]:!a},n={opacity:`${null!=l?l:s.opacity}`};return f("img",{alt:m(this.messages,t,!1),"aria-label":m(this.messages,t,!1),src:i,border:0,width:e.width,height:e.height,class:this.classes(o),styles:n})}};e([s()],_.prototype,"activeLayerInfos",void 0),e([s()],_.prototype,"headingLevel",void 0),e([s(),b("esri/widgets/Legend/t9n/Legend")],_.prototype,"messages",void 0),e([s({readOnly:!0})],_.prototype,"type",void 0),_=e([a("esri.widgets.Legend.styles.Classic")],_);const j=_;export{j as default};
@@ -0,0 +1,5 @@
1
+ /*
2
+ All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
+ See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
+ */
5
+ const e="esri-slider",t={base:e,reversed:`${e}--reversed`,horizontalLayout:`${e}--horizontal`,verticalLayout:`${e}--vertical`,contentElement:`${e}__content`,extraContentElement:`${e}__extra-content`,trackElement:`${e}__track`,ticksContainerElement:`${e}__ticks`,tickElement:`${e}__tick`,tickLabelElement:`${e}__tick-label`,maxElement:`${e}__max`,minElement:`${e}__min`,maxElementInteractive:`${e}__max--interactive`,minElementInteractive:`${e}__min--interactive`,rangeElementActive:`${e}__range--active`,rangeInput:`${e}__range-input`,anchorElement:`${e}__anchor`,movingAnchorElement:`${e}__anchor--moving`,lastMovedAnchorElement:`${e}__anchor--moved`,anchorElementActive:`${e}__anchor--active`,anchorElementIndexPrefix:`${e}__anchor-`,segmentElement:`${e}__segment`,segmentElementIndexPrefix:`${e}__segment-`,segmentElementInteractive:`${e}__segment--interactive`,segmentElementActive:`${e}__segment--active`,effectiveSegmentElement:`${e}__effective-segment`,effectiveMaxSegmentElement:`${e}__effective-max-segment`,effectiveMinSegmentElement:`${e}__effective-min-segment`,thumbElement:`${e}__thumb`,labelElement:`${e}__label`,labelElementInteractive:`${e}__label--interactive`,labelInput:`${e}__label-input`,esriWidget:"esri-widget",widgetIcon:"esri-icon-edit",disabled:"esri-disabled",hidden:"esri-hidden"};export{t as CSS};
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.28/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 n}from"../core/events.js";import{assertIsSome as i}from"../core/maybe.js";import{property as s}from"../core/accessorSupport/decorators/property.js";import{cast as o}from"../core/accessorSupport/decorators/cast.js";import"../core/arrayUtils.js";import"../core/has.js";import{subclass as r}from"../core/accessorSupport/decorators/subclass.js";import a from"./Widget.js";import l from"./Slider/SliderViewModel.js";import{onResize as h}from"./support/widgetUtils.js";import{messageBundle as u}from"./support/decorators/messageBundle.js";import{tsx as c}from"./support/jsxFactory.js";import{substitute as d}from"../intl/substitute.js";const m="esri-slider",_={base:m,reversed:`${m}--reversed`,horizontalLayout:`${m}--horizontal`,verticalLayout:`${m}--vertical`,contentElement:`${m}__content`,extraContentElement:`${m}__extra-content`,trackElement:`${m}__track`,ticksContainerElement:`${m}__ticks`,tickElement:`${m}__tick`,tickLabelElement:`${m}__tick-label`,maxElement:`${m}__max`,minElement:`${m}__min`,maxElementInteractive:`${m}__max--interactive`,minElementInteractive:`${m}__min--interactive`,rangeElementActive:`${m}__range--active`,rangeInput:`${m}__range-input`,anchorElement:`${m}__anchor`,movingAnchorElement:`${m}__anchor--moving`,lastMovedAnchorElement:`${m}__anchor--moved`,anchorElementActive:`${m}__anchor--active`,anchorElementIndexPrefix:`${m}__anchor-`,segmentElement:`${m}__segment`,segmentElementIndexPrefix:`${m}__segment-`,segmentElementInteractive:`${m}__segment--interactive`,segmentElementActive:`${m}__segment--active`,effectiveSegmentElement:`${m}__effective-segment`,effectiveMaxSegmentElement:`${m}__effective-max-segment`,effectiveMinSegmentElement:`${m}__effective-min-segment`,thumbElement:`${m}__thumb`,labelElement:`${m}__label`,labelElementInteractive:`${m}__label--interactive`,labelInput:`${m}__label-input`,esriWidget:"esri-widget",widgetIcon:"esri-icon-edit",disabled:"esri-disabled",hidden:"esri-hidden"},p={showInput:"Enter",hideInput1:"Enter",hideInput2:"Escape",hideInput3:"Tab",moveAnchorUp:"ArrowUp",moveAnchorDown:"ArrowDown",moveAnchorLeft:"ArrowLeft",moveAnchorRight:"ArrowRight",moveAnchorToMax:"End",moveAnchorToMin:"Home"},v="esri.widgets.Slider",g={labels:!1,rangeLabels:!1};let f=class extends a{constructor(e,n){super(e,n),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=[],this._zIndexOffset=3,this.disabled=!1,this.draggableSegmentsEnabled=!0,this.effectiveSegmentElements=new t,this.extraNodes=[],this.inputCreatedFunction=null,this.labelElements=new t,this.labelInputsEnabled=!1,this.maxLabelElement=null,this.messages=null,this.minLabelElement=null,this.rangeLabelInputsEnabled=!1,this.segmentElements=new t,this.snapOnClickEnabled=!0,this.steps=null,this.syncedSegmentsEnabled=!1,this.thumbCreatedFunction=null,this.thumbElements=new t,this.tickElements=new t,this.trackElement=null,this.viewModel=new l,this.visibleElements={...g},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()}get effectiveMax(){return this.viewModel.effectiveMax}set effectiveMax(e){this.viewModel.effectiveMax=e}get effectiveMin(){return this.viewModel.effectiveMin}set effectiveMin(e){this.viewModel.effectiveMin=e}get inputFormatFunction(){return this.viewModel.inputFormatFunction}set inputFormatFunction(e){this.viewModel.inputFormatFunction=e}get inputParseFunction(){return this.viewModel.inputParseFunction}set inputParseFunction(e){this.viewModel.inputParseFunction=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get labelFormatFunction(){return this.viewModel.labelFormatFunction}set labelFormatFunction(e){this.viewModel.labelFormatFunction=e}get labels(){return this.viewModel.labels}set layout(e){["vertical","vertical-reversed","horizontal","horizontal-reversed"].includes(e)||(e="horizontal"),this._set("layout",e)}get max(){return this.viewModel.max}set max(e){this.viewModel.max=e}get min(){return this.viewModel.min}set min(e){this.viewModel.min=e}get precision(){return this.viewModel.precision}set precision(e){this.viewModel.precision=e}get state(){const{_activeLabelInputIndex:e,_isMaxInputActive:t,_isMinInputActive:n,_dragStartInfo:i,_segmentDragStartInfo:s,disabled:o,viewModel:r}=this;return o?"disabled":!(null===e&&!t&&!n)?"editing":null!=i||null!=s?"dragging":r.state}get thumbsConstrained(){return this.viewModel.thumbsConstrained}set thumbsConstrained(e){this.viewModel.thumbsConstrained=e}set tickConfigs(e){this._set("tickConfigs",e),this.scheduleRender()}get values(){return this.viewModel.values}set values(e){this.viewModel.values=e}castVisibleElements(e){return{...g,...e}}render(){const{label:e}=this,t=this.classes(_.base,_.esriWidget,this._isHorizontalLayout()?_.horizontalLayout:_.verticalLayout,this._isReversedLayout()?_.reversed:null,this._isDisabled()?_.disabled:null);return this._storeTrackDimensions(),c("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(!(null==t||null==e||t>=e))return[this.renderMin(),this.renderSliderContainer(),this.renderMax()]}renderSliderContainer(){return c("div",{key:"slider-container",bind:this,class:_.contentElement},this.renderTrackElement(),this.renderTicksContainer(),this.renderExtraContentElements())}renderTrackElement(){return c("div",{afterCreate:this._afterTrackCreate,afterRemoved:this._afterTrackRemoved,bind:this,class:_.trackElement,"touch-action":"none"},this.renderEffectiveSegmentElements(),this.renderSegmentElements(),this.renderAnchorElements())}renderEffectiveSegmentElements(){if(!this.trackElement||!this.values||!this.values.length)return;const e=null!=this.effectiveMax,t=null!=this.effectiveMin;if(!e&&!t)return;const{max:n,min:i,viewModel:s}=this,o=s.getBounds(),r=[];return t&&r.push(this.renderEffectiveSegmentElement(i,o.min,!0)),e&&r.push(this.renderEffectiveSegmentElement(o.max,n,!1)),r}renderSegmentElements(){if(!this.trackElement||!this.values||!this.values.length)return;const e=this.values.length,t=[];for(let n=0;n<=e;n++)t.push(this.renderSegmentElement(n));return t}renderSegmentElement(e){const{_trackHeight:t,_trackWidth:n,draggableSegmentsEnabled:i,id:s,state:o}=this,r=this.values,a=this._isHorizontalLayout(),l=a?n:t,h=this.viewModel.getBounds(),u=this._positionFromValue(h.max),d=this._positionFromValue(h.min),m=e===r?.length?null:e,p=0===e?null:e-1,v=null!=m,g=null!=p;let f,b;const E=[...r].sort(((e,t)=>e-t));this._isReversedLayout()?(f=g?this._positionFromValue(E[p]):d,b=v?this._positionFromValue(E[m]):u):(f=v?this._positionFromValue(E[m]):u,b=g?this._positionFromValue(E[p]):d);const x=this._applyPrecisionToPosition(100*b/l),y=(f-b)/l,k=a?`transform: translate(${x}%, 0px) scale(${y}, 1);`:`transform: translate(0px, ${x}%) scale(1, ${y});`,P=this.classes(_.segmentElement,_.segmentElementIndexPrefix+e,i&&v&&g&&"disabled"!==o?_.segmentElementInteractive:null);return c("div",{afterCreate:this._afterSegmentCreate,afterRemoved:this._afterSegmentRemoved,bind:this,class:P,"data-max-thumb-index":m,"data-min-thumb-index":p,"data-segment-index":e,key:`${s}-segment-${e}`,style:k,"touch-action":"none"})}renderEffectiveSegmentElement(e,t,n){const{_trackHeight:i,_trackWidth:s,layout:o}=this,r=this._positionFromValue(e),a=this._positionFromValue(t),l=this._isHorizontalLayout(),h=l?s:i,u=this._applyPrecisionToPosition(100*r/h);let d=null;if("horizontal"===o){const e=n?h-a:a,t=r===h?0:u;d=`clip-path: inset(0% ${a===h?0:this._applyPrecisionToPosition(e/h*100)}% 0% ${t}%);`}else{const e=(a-r)/h;d=l?`transform: translate(${u}%, 0px) scale(${e}, 1);`:`transform: translate(0px, ${u}%) scale(1, ${e});`}const m=n?_.effectiveMinSegmentElement:_.effectiveMaxSegmentElement,p=this.classes(_.segmentElement,_.effectiveSegmentElement,m);return c("div",{afterCreate:this._afterEffectiveSegmentCreate,afterRemoved:this._afterEffectiveSegmentRemoved,bind:this,class:p,style:d,"touch-action":"none"})}renderAnchorElements(){const{trackElement:e,values:t}=this;if(t&&t.length)return this._zIndices=t.map(((e,n)=>{const i=this._positionFromValue(e),s=this._positionToPercent(i),o=(this._isHorizontalLayout()?s>50:s<50)?-1:1;return this._zIndexOffset+(t.length+o*n)})),e&&t&&t.length?t.map(((e,t)=>this.renderAnchorElement(e,t))):null}renderAnchorElement(e,t){const n=this._positionFromValue(e),i=this._valueFromPosition(n);if(null==i||isNaN(i))return;const{_dragStartInfo:s,_lastMovedHandleIndex:o,id:r,layout:a,visibleElements:{labels:l}}=this,h=this.values,u=s&&s.index===t,m=o===t,p=this.classes(_.anchorElement,_.anchorElementIndexPrefix+t,u?_.movingAnchorElement:null,m?_.lastMovedAnchorElement:null),v=this.labels.values[t],g=this._getStyleForAnchor(e,t,u||m),{min:f,max:b}=this.viewModel.getBoundsForValueAtIndex(t),{disabled:E,messages:x}=this,y=2===h.length?d(0===t?x.rangeMinimum:x.rangeMaximum,{value:e}):v,k=1===h.length?null:0===t?`${r}-handle-${t+1}`:t===h.length-1?`${r}-handle-${t-1}`:`${r}-handle-${t-1} ${r}-handle-${t+1}`;return c("div",{afterCreate:this._afterAnchorCreate,afterUpdate:this._afterAnchorUpdate,afterRemoved:this._afterAnchorRemoved,"aria-controls":k,"aria-label":x.sliderValue,"aria-labelledby":l?`${r}-label-${t}`:null,"aria-orientation":a,"aria-valuemax":b?.toString(),"aria-valuemin":f?.toString(),"aria-valuenow":e.toString(),"aria-valuetext":y,bind:this,class:p,"data-thumb-index":t,"data-value":e,id:`${r}-handle-${t}`,key:`${r}-handle-${t}`,onkeydown:this._onAnchorKeyDown,"touch-action":"none",role:"slider",style:g,tabIndex:E?-1:0},c("span",{afterCreate:this._afterThumbCreate,afterRemoved:this._afterThumbRemoved,bind:this,class:_.thumbElement,"data-thumb-index":t,"touch-action":"none"}),this.renderThumbLabel(t))}renderThumbLabel(e){const{id:t,labels:n,labelInputsEnabled:i,state:s}=this,o=this.visibleElements.labels,r=n.values[e],a=this.classes(_.labelElement,o?null:_.hidden,i&&"disabled"!==s?_.labelElementInteractive:null);return c("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:i?"button":null,"touch-action":"none"},this._activeLabelInputIndex===e?this.renderValueInput(e):r)}renderValueInput(e){const{disabled:t,values:n}=this;if(null==n)return;const i=n[e];return c("input",{key:`value-input-${e}`,afterCreate:this._afterInputCreate,"aria-label":this.messages.sliderValue,bind:this,class:_.labelInput,"data-input-type":"thumb","data-input-index":e,required:!0,tabIndex:t?-1:0,type:"text",value:this._formatInputValue(i,"value",e),onblur:this._onLabelInputBlur,onkeydown:this._onInputKeyDown})}renderMax(){const{_isMaxInputActive:e,labels:t,rangeLabelInputsEnabled:n,state:i}=this,s=this.visibleElements.rangeLabels,o=this.classes(_.maxElement,{[_.hidden]:!s,[_.maxElementInteractive]:n&&"disabled"!==i,[_.rangeElementActive]:e});return c("div",{"aria-hidden":(!s).toString(),afterCreate:this._afterMaxLabelCreate,bind:this,class:o,onclick:this._onMaxLabelClick,onkeydown:this._onMaxLabelKeyDown,role:n?"button":null,tabIndex:!this.disabled&&n?0:-1},e?this.renderMaxInput():t.max)}renderMin(){const{_isMinInputActive:e,labels:t,rangeLabelInputsEnabled:n,state:i}=this,s=this.visibleElements.rangeLabels,o=this.classes(_.minElement,{[_.hidden]:!s,[_.minElementInteractive]:n&&"disabled"!==i,[_.rangeElementActive]:e});return c("div",{"aria-hidden":(!s).toString(),afterCreate:this._afterMinLabelCreate,bind:this,class:o,onclick:this._onMinLabelClick,onkeydown:this._onMinLabelKeyDown,role:n?"button":null,tabIndex:!this.disabled&&n?0:-1},e?this.renderMinInput():t.min)}renderMaxInput(){return c("input",{afterCreate:this._afterInputCreate,"aria-label":this.messages.maximumValue,bind:this,class:_.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 c("input",{afterCreate:this._afterInputCreate,"aria-label":this.messages.minimumValue,bind:this,class:_.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 c("div",{bind:this,class:_.extraContentElement},this.extraNodes)}renderTicksContainer(){if(this.tickConfigs&&this.trackElement&&(0!==this._trackHeight||0!==this._trackWidth))return this.tickConfigs.map(((e,t)=>c("div",{key:"ticks-container",class:this.classes(_.ticksContainerElement)},this.renderTicks(e,t))))}renderTicks(e,n){const{mode:i,values:s}=e;if(this.tickElements.at(n)||this.tickElements.add(new t,n),"position"===i){const t=Array.isArray(s)?s:[s];return this._calculateTickPositions(t).map(((t,i)=>this.renderTickGroup(e,i,n,t)))}if("percent"===i&&Array.isArray(s)){const t=this.min??0,i=(this.max??0)-t,o=s.map((e=>this._applyPrecisionToPosition(e/100*i+t)));return this._calculateTickPositions(o).map(((t,i)=>this.renderTickGroup(e,i,n,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,i)=>this.renderTickGroup(e,i,n,t)))}renderTickGroup(e,t,n,i){const s="position"===e.mode?Array.isArray(e.values)?e.values[t]:e.values:this._valueFromPosition(i);if(null!=s&&!isNaN(s))return c("div",{afterCreate:this._afterTickGroupCreate,afterRemoved:this._afterTickGroupRemoved,bind:this,"data-config":e,"data-position":i,"data-tick-config-index":n,"data-tick-group-index":t,"data-value":s,onclick:this._onTickGroupClick,key:`tick-group-${t}`},this.renderTickLine(e,t,n,s),e.labelsVisible?this.renderTickLabel(e,t,n,s):null)}renderTickLine(e,t,n,i){return c("div",{afterCreate:this._afterTickLineCreate,"aria-valuenow":i.toString(),bind:this,class:_.tickElement,"data-config":e,"data-tick-config-index":n,"data-tick-group-index":t,"data-value":i,key:`tick-label-${t}`,style:this._getPositionStyleForElement(i)})}renderTickLabel(e,t,n,i){const s=e.labelFormatFunction?e.labelFormatFunction(i,"tick",t):this.viewModel.getLabelForValue(i,"tick",t);return c("div",{afterCreate:this._afterTickLabelCreate,"aria-label":s,"aria-valuenow":i.toString(),"aria-valuetext":s,bind:this,class:_.tickLabelElement,"data-config":e,"data-tick-config-index":n,"data-tick-group-index":t,"data-value":i,key:`tick-label-${t}`,style:`transform: translate(-50%); ${this._getPositionStyleForElement(i)}`},s)}getCurrentPosition(){return this._positionFromValue(this.values?.[0]??0)}_afterContainerCreate(e){this.addHandles(h(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=b(e),n=P(e),i=this.thumbElements.at(t),s=this.labelElements.at(t)||null;this.thumbCreatedFunction(t,n,i,s)}}_afterAnchorUpdate(e){if(null!=this._focusedAnchorIndex){b(e)===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"),n="thumb"===t?E(e):null;this.inputCreatedFunction(e,t,n)}}_afterTickLineCreate(e){const t=I(e),n=A(e),i=this.tickElements.at(t),s=i.at(n);s?s.tickElement=e:i.add({groupElement:null,tickElement:e,labelElement:null},n)}_afterTickLabelCreate(e){const t=I(e),n=A(e),i=this.tickElements.at(t),s=i.at(n);s?s.labelElement=e:i.add({groupElement:null,labelElement:e,tickElement:null},n)}_afterTickGroupRemoved(e){const t=I(e),n=this.tickElements.items[t],i=n?.find((t=>t.groupElement===e));i&&n.remove(i)}_afterTickGroupCreate(e){const t=L(e);if(t?.tickCreatedFunction){const n=I(e),i=A(e),s=P(e),o=this.tickElements?.at(n)?.at(i);if(o){o.groupElement=e;const n=o.tickElement||null,i=o.labelElement||null;t.tickCreatedFunction(s,n,i)}}}_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,i=n(e),s=this.values,o=b(t),r=this._anchorElements[o],a=s[o],l=[p.moveAnchorUp,p.moveAnchorDown,p.moveAnchorLeft,p.moveAnchorRight];if(i===p.showInput&&this.labelInputsEnabled)this._activeLabelInputIndex=o,this.notifyChange("state");else if(l.includes(i)){e.preventDefault();const{steps:t}=this,n=i===p.moveAnchorUp||i===p.moveAnchorRight?1:-1;if(null!=t)this._toStep(o,this._isReversedLayout()?-1*n:n);else{const{precision:e}=this,t=this._getPositionOfElement(r),i=this._valueFromPosition(t),s=this._isHorizontalLayout()?n:-1*n;let a;a=0===e?this._positionFromValue(i+s):1===e?this._positionFromValue(i+.1*s):t+s,this._toPosition(o,a)}const s=this.values[o];a!==s&&this._emitThumbChangeEvent({index:o,oldValue:a,value:s})}else if(i===p.moveAnchorToMax||i===p.moveAnchorToMin){e.preventDefault();const{min:t,max:n}=this._getAnchorBoundsInPixels(o),s=this._isPositionInverted()?i===p.moveAnchorToMax?t:n:i===p.moveAnchorToMin?t:n;this._toPosition(o,s);const r=this.values[o];a!==r&&this._emitThumbChangeEvent({index:o,oldValue:a,value:r})}}_onAnchorPointerDown(e){if(this._isDisabled())return;const{target:t,clientX:n,clientY:i}=e,s=b(t);null!=s&&(e.preventDefault(),this._anchorElements[s]&&this._anchorElements[s].focus(),this._storeTrackDimensions(),this._dragStartInfo={clientX:n,clientY:i,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:n,_dragged:i,_dragStartInfo:s,_dragStartInfo:{index:o,position:r}}=this,{clientX:a,clientY:l}=e,h=i?"drag":"start",u=n[o],c=this._getPositionOfElement(u),d=this._applyPrecisionToPosition(this._isHorizontalLayout()?r+a-s.clientX:r+l-s.clientY);if(c===d)return;const m=t[o];this._dragged=!0,this._toPosition(o,d);const _=this.values[o];i?m!==_&&this._emitThumbDragEvent({index:o,state:h,value:_}):this._emitThumbDragEvent({index:o,state:h,value:m})}_onAnchorPointerUp(e){if(document.removeEventListener("pointerup",this._onAnchorPointerUp),document.removeEventListener("pointermove",this._onAnchorPointerMove),!this._dragStartInfo)return;e.preventDefault();const{index:t}=this._dragStartInfo,n=this._dragged,i=this.values[t];this._dragged=!1,this._dragStartInfo=null,this._lastMovedHandleIndex=t,this.notifyChange("state"),n?this._emitThumbDragEvent({index:t,state:"stop",value:i}):(this.scheduleRender(),"editing"!==this.state&&this._emitThumbClickEvent({index:t,value:i}))}_onTrackPointerDown(e){const{_dragStartInfo:t,snapOnClickEnabled:n,state:i,values:s}=this;if(this._isDisabled()||"editing"===i||t)return;if(document.addEventListener("pointermove",this._onTrackPointerMove),document.addEventListener("pointerup",this._onTrackPointerUp),!n||!s?.length)return;const{steps:o}=this,{clientX:r,clientY:a}=e,l=this._getCursorPositionFromEvent(e),h=this._valueFromPosition(l),u=this._getIndexOfNearestValue(h),c=s[u],d=s.some(((e,t)=>e===c&&t!==u))&&h>c?s.lastIndexOf(c):u;if(null==d)return;const m=s[d],_=null!=o?this._calculateNearestStepPosition(l):l;this._toPosition(d,_),this._dragged=!0,this._dragStartInfo={clientX:r,clientY:a,index:d,position:_},this._focusedAnchorIndex=d,this.notifyChange("state"),this._emitThumbDragEvent({index:d,state:"start",value:m});const p=this.values[d];m!==p&&this._emitThumbDragEvent({index:d,state:"drag",value:p}),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),n=this._valueFromPosition(t);this._emitTrackClickEvent({value:n})}}_onSegmentPointerDown(e){e.preventDefault();const t=e.target,n=x(t),i=y(t),s=k(t);if(this._isDisabled()||null==i||null==s)return;e.stopPropagation(),this._storeTrackDimensions(),document.addEventListener("pointerup",this._onSegmentPointerUp);const o=this._getAnchorDetails(i),r=this._getAnchorDetails(s);this.syncedSegmentsEnabled?(this.segmentElements.forEach((e=>e.classList.add(_.segmentElementActive))),this._anchorElements.forEach((e=>e.classList.add(_.anchorElementActive)))):(this.segmentElements.at(n).classList.add(_.segmentElementActive),this._anchorElements[o.index]?.classList.add(_.anchorElementActive),this._anchorElements[r.index]?.classList.add(_.anchorElementActive)),this._segmentDragStartInfo={cursorPosition:this._getCursorPositionFromEvent(e),index:n,details:this._normalizeSegmentDetails({min:o,max:r})},this.draggableSegmentsEnabled&&(document.addEventListener("pointermove",this._onSegmentPointerMove),this.notifyChange("state"),this._emitSegmentDragEvent({index:n,state:"start",thumbIndices:[i,s]}))}_onSegmentPointerMove(e){if(!this._segmentDragStartInfo)return;e.preventDefault();const{_trackHeight:t,_trackWidth:n,_segmentDragStartInfo:{index:i,cursorPosition:s,details:{min:o,max:r}}}=this,{index:a,position:l,value:h}=o,{index:u,position:c,value:d}=r;this._dragged=!0;const m=this._getCursorPositionFromEvent(e);if(m===s)return;const _=this._positionToPercent(s),p=this._positionToPercent(m)-_,v=this._positionToPercent(l)+p,g=this._positionToPercent(c)+p,{min:f}=this._getAnchorBoundsAsPercents(a),{max:b}=this._getAnchorBoundsAsPercents(u);let E=!1,x=!1;if(v<f?E=!0:g>b&&(x=!0),E){const{min:e,max:t}=this.viewModel.getBoundsForValueAtIndex(a),n=this._isPositionInverted()?t:e,i=n,s=d+(n-h),o=s-this.values[u];return void(this.syncedSegmentsEnabled?this._updateAnchorValuesByDifference(o):this._updateAnchorValues([a,u],[i,s]))}if(x){const{min:e,max:t}=this.viewModel.getBoundsForValueAtIndex(u),n=this._isPositionInverted()?e:t,i=n,s=h+(n-d),o=s-this.values[a];return void(this.syncedSegmentsEnabled?this._updateAnchorValuesByDifference(o):this._updateAnchorValues([a,u],[s,i]))}const y=this._isHorizontalLayout()?n:t,k=g/100*y,P=v/100*y,I=this.values,A=[I[a],I[u]],L=this._getValueForAnchorAtPosition(a,P),M=this._getValueForAnchorAtPosition(u,k);this.syncedSegmentsEnabled?this._updateAnchorValuesByDifference(L-A[0]):this._updateAnchorValues([a,u],[L,M]);[this.values[a],this.values[u]].every(((e,t)=>e===A[t]))||this._emitSegmentDragEvent({index:i,state:"drag",thumbIndices:[a,u]})}_onSegmentPointerUp(e){if(e.preventDefault(),document.removeEventListener("pointerup",this._onSegmentPointerUp),document.removeEventListener("pointermove",this._onSegmentPointerMove),!this._segmentDragStartInfo)return;const{_dragged:t}=this,n=this.min,i=this.max,s=this.values,{index:o,details:{min:{index:r},max:{index:a}}}=this._segmentDragStartInfo;if(this.segmentElements.forEach((e=>e.classList.remove(_.segmentElementActive))),this._anchorElements.forEach((e=>e.classList.remove(_.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),n=this._valueFromPosition(t);this._emitSegmentClickEvent({index:o,value:n,thumbIndices:[r,a]})}}_onTickGroupClick(e){const t=e.target;if(L(t)){const e=I(t),n=A(t),i=P(t);this._emitTickClickEvent({configIndex:e,groupIndex:n,value:i})}}_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=b(e.target);this.labelInputsEnabled&&!this._dragged&&null!=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:n,viewModel:i}=this,s=e.target.value;if(this._activeLabelInputIndex=null,this.notifyChange("state"),!s||null==t||null==n)return;const o=this._parseInputValue(s,"value",t),r=n[t],{min:a,max:l}=this.viewModel.getBoundsForValueAtIndex(t);if(o<a||o>l)return;i.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,i=n(e),{hideInput1:s,hideInput2:o,hideInput3:r}=p,{_activeLabelInputIndex:a,_anchorElements:l}=this,h=t;if(i===s||i===o||i===r){e.stopPropagation();const t=a;h.blur(),null!=t?l[t].focus():h.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()||n(e)!==p.showInput||(this._isMaxInputActive=!0,this.notifyChange("state"))}_onMaxInputBlur(e){const t=e.target.value;if(this._isMaxInputActive=!1,this.notifyChange("state"),!t)return;const n=this.max,i=this._parseInputValue(t,"max");i<=this.min||(this.viewModel.set("max",i),this.max!==n&&this._emitMaxChangeEvent({oldValue:n,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()||n(e)!==p.showInput||(this._isMinInputActive=!0,this.notifyChange("state"))}_onMinInputBlur(e){const t=e.target.value;if(this._isMinInputActive=!1,this.notifyChange("state"),!t)return;const n=this.min,i=this._parseInputValue(t,"min");i>=this.max||(this.viewModel.set("min",i),this.min!==n&&this._emitMinChangeEvent({oldValue:n,value:this.min}))}_isDisabled(){return this.disabled||"disabled"===this.state}_positionFromValue(e){const{_trackHeight:t,_trackWidth:n}=this,i=this.min??0,s=this.max??0,o=s-i;if(0===o||null==e)return 0;const r=this._isHorizontalLayout();let a=r?parseFloat((n*(e-i)/o).toFixed(2)):parseFloat((t*(s-e)/o).toFixed(2));return this._isReversedLayout()&&(a=r?n-a:t-a),a}_valueFromPosition(e){const{_trackHeight:t,_trackWidth:n,precision:i}=this,s=this.min??0,o=this.max??0,r=o-s;let a=this._isHorizontalLayout()?e*r/n+s:r*(1e3-e/t*1e3)/1e3+s;return this._isReversedLayout()&&(a=o+s-a),parseFloat(a.toFixed(i))}_positionToPercent(e){const{_trackHeight:t,_trackWidth:n}=this,i=100*e/(this._isHorizontalLayout()?n:t);return this._applyPrecisionToPosition(i)}_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:n}=e;return{min:n,max:t}}return e}_parseInputValue(e,t,n){return this.inputParseFunction?this.inputParseFunction(e,t,n):this.viewModel.defaultInputParseFunction(e)}_formatInputValue(e,t,n){return this.inputFormatFunction?this.inputFormatFunction(e,t,n):this.viewModel.defaultInputFormatFunction(e)}_getAnchorDetails(e){const t=this.values,n=[...t].sort(((e,t)=>e-t))[e],i=t.indexOf(n);return{index:i,position:this._getPositionOfElement(this._anchorElements[i]),value:n}}_updateAnchorStyle(e,t){const n=this._anchorElements[e];n&&(this._isHorizontalLayout()?n.style.left=`${t}`:n.style.top=`${t}`)}_getStyleForAnchor(e,t,n){const i=this._getPositionStyleForElement(e);if(1===this.values?.length)return`${i}`;const s=this._zIndices[t];return`${i}; z-index: ${n?this._zIndexOffset+s:s}`}_getPositionStyleForElement(e){const t=this._positionFromValue(e),n=this._positionToPercent(t);return`${this._isHorizontalLayout()?"left":"top"}: ${n}%`}_getPositionOfElement(e){const t=this._getDimensions(e.offsetParent),n=this._getDimensions(e);return this._isHorizontalLayout()?this._applyPrecisionToPosition(n.left-t.left):this._applyPrecisionToPosition(n.top-t.top)}_updateAnchorValues(e,t){e.forEach(((e,n)=>this._toValue(e,t[n])))}_updateAnchorValuesByDifference(e){const{min:t,max:n,values:i}=this;i?.forEach(((i,s)=>this._toValue(s,Math.max(Math.min(i+e,n),t))))}_toValue(e,t){if(null!=this.steps){t=this._getStepValues()[this._getIndexOfNearestStepValue(t)]}this._updateAnchorStyle(e,this._getPositionStyleForElement(t)),this.viewModel.setValue(e,t)}_toPosition(e,t){const n=null!=this.steps?this._getStepValueForAnchorAtPosition(e,t):this._getValueForAnchorAtPosition(e,t);this._updateAnchorStyle(e,this._getPositionStyleForElement(n)),this.viewModel.setValue(e,n)}_getValueForAnchorAtPosition(e,t){const{min:n,max:i}=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>i?r:t<n?a:this._valueFromPosition(t),l>o?l=o:l<s&&(l=s),l}_getStepValueForAnchorAtPosition(e,t){const n=this._getStepValues(),i=this._calculateNearestStepPosition(t),s=this._getValueForAnchorAtPosition(e,i);return n[this._getIndexOfNearestStepValue(s)]}_getAnchorBoundsAsPercents(e){const{min:t,max:n}=this._getAnchorBoundsInPixels(e);return{min:this._positionToPercent(t),max:this._positionToPercent(n)}}_getAnchorBoundsInPixels(e){const{_anchorElements:t,_trackHeight:n,_trackWidth:i,effectiveMax:s,effectiveMin:o,thumbsConstrained:r}=this,a=t[e-1],l=t[e+1],h=this._isHorizontalLayout()?i:n;let u,c;return this._isPositionInverted()?(u=null!=o?this._positionFromValue(o):h,c=null!=s?this._positionFromValue(s):0):(u=null!=s?this._positionFromValue(s):h,c=null!=o?this._positionFromValue(o):0),r?this._isPositionInverted()?{max:a?this._getPositionOfElement(a):u,min:l?this._getPositionOfElement(l):c}:{max:l?this._getPositionOfElement(l):u,min:a?this._getPositionOfElement(a):c}:{max:u,min:c}}_getIndexOfNearestValue(e){const t=this.values;return t.indexOf(t.reduce(((t,n)=>Math.abs(n-e)<Math.abs(t-e)?n: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:n}=this;if(null==n||null==t||null==e)return[];const i=Math.ceil((t-n)/e),s=[];for(let o=0;o<=i;o++){const i=n+e*o;s.push(i>t?t:i)}return s}_toStep(e,t){const n=this.values[e],i=this._getStepValues(),s=i.indexOf(n);let o=null;if(s>-1){let n=i[s+t];isNaN(n)&&(n=i[s]);const r=this._positionFromValue(n);o=this._getStepValueForAnchorAtPosition(e,r)}else{o=i[this._getIndexOfNearestStepValue(n)+t]}this.viewModel.setValue(e,o)}_getIndexOfNearestStepValue(e){const{steps:t}=this;if(null==t)return null;const n=this._getStepValues(),i=n.reduce(((t,n)=>Math.abs(n-e)<Math.abs(t-e)?n:t));return n.indexOf(i)}_calculateNearestStepPosition(e){const t=this._valueFromPosition(e),n=this._getIndexOfNearestStepValue(t),i=this._getStepValues();return this._positionFromValue(i[n])}_getTickCounts(e,t){const{mode:n}=t;return"count"===n||"position"===n?e||0:"percent"===n&&100/e||0}_calculateTickPositions(e){return e.map((e=>this._positionFromValue(e)))}_calculateEquidistantTickPositions(e){const{_trackWidth:t,_trackHeight:n}=this,i=this._isHorizontalLayout()?t:n,s=i/(e-1),o=[];if(1===e)return[i/2];for(let r=0;r<e;r++){const e=r*s;e<=i&&o.push(e)}return o}_getDimensions(e){try{return i(e),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})}};function b(e){return e?.["data-thumb-index"]}function E(e){return e?.["data-input-index"]}function x(e){return e?.["data-segment-index"]}function y(e){return e?.["data-min-thumb-index"]}function k(e){return e?.["data-max-thumb-index"]}function P(e){return e?.["data-value"]}function I(e){return e?.["data-tick-config-index"]}function A(e){return e?.["data-tick-group-index"]}function L(e){return e?.["data-config"]}e([s()],f.prototype,"disabled",void 0),e([s()],f.prototype,"draggableSegmentsEnabled",void 0),e([s()],f.prototype,"effectiveMax",null),e([s()],f.prototype,"effectiveMin",null),e([s({readOnly:!0})],f.prototype,"effectiveSegmentElements",void 0),e([s()],f.prototype,"extraNodes",void 0),e([s()],f.prototype,"inputCreatedFunction",void 0),e([s()],f.prototype,"inputFormatFunction",null),e([s()],f.prototype,"inputParseFunction",null),e([s()],f.prototype,"label",null),e([s({readOnly:!0})],f.prototype,"labelElements",void 0),e([s()],f.prototype,"labelInputsEnabled",void 0),e([s()],f.prototype,"labelFormatFunction",null),e([s({readOnly:!0})],f.prototype,"labels",null),e([s({value:"horizontal"})],f.prototype,"layout",null),e([s()],f.prototype,"max",null),e([s({readOnly:!0})],f.prototype,"maxLabelElement",void 0),e([s(),u("esri/widgets/Slider/t9n/Slider")],f.prototype,"messages",void 0),e([s()],f.prototype,"min",null),e([s({readOnly:!0})],f.prototype,"minLabelElement",void 0),e([s()],f.prototype,"precision",null),e([s()],f.prototype,"rangeLabelInputsEnabled",void 0),e([s({readOnly:!0})],f.prototype,"segmentElements",void 0),e([s()],f.prototype,"snapOnClickEnabled",void 0),e([s({readOnly:!0})],f.prototype,"state",null),e([s()],f.prototype,"steps",void 0),e([s()],f.prototype,"syncedSegmentsEnabled",void 0),e([s()],f.prototype,"thumbsConstrained",null),e([s()],f.prototype,"thumbCreatedFunction",void 0),e([s({readOnly:!0})],f.prototype,"thumbElements",void 0),e([s()],f.prototype,"tickConfigs",null),e([s({readOnly:!0})],f.prototype,"tickElements",void 0),e([s({readOnly:!0})],f.prototype,"trackElement",void 0),e([s()],f.prototype,"values",null),e([s()],f.prototype,"viewModel",void 0),e([s()],f.prototype,"visibleElements",void 0),e([o("visibleElements")],f.prototype,"castVisibleElements",null),f=e([r(v)],f);const M=f;export{M as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import t from"../core/Collection.js";import{eventKey as n}from"../core/events.js";import{assertIsSome as i}from"../core/maybe.js";import{property as s}from"../core/accessorSupport/decorators/property.js";import{cast as o}from"../core/accessorSupport/decorators/cast.js";import"../core/arrayUtils.js";import"../core/has.js";import{subclass as r}from"../core/accessorSupport/decorators/subclass.js";import a from"./Widget.js";import{CSS as l}from"./Slider/css.js";import h from"./Slider/SliderViewModel.js";import{onResize as u}from"./support/widgetUtils.js";import{messageBundle as c}from"./support/decorators/messageBundle.js";import{tsx as d}from"./support/jsxFactory.js";import{substitute as m}from"../intl/substitute.js";const p={showInput:"Enter",hideInput1:"Enter",hideInput2:"Escape",hideInput3:"Tab",moveAnchorUp:"ArrowUp",moveAnchorDown:"ArrowDown",moveAnchorLeft:"ArrowLeft",moveAnchorRight:"ArrowRight",moveAnchorToMax:"End",moveAnchorToMin:"Home"},_={labels:!1,rangeLabels:!1};let v=class extends a{constructor(e,n){super(e,n),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=[],this._zIndexOffset=3,this.disabled=!1,this.draggableSegmentsEnabled=!0,this.effectiveSegmentElements=new t,this.extraNodes=[],this.inputCreatedFunction=null,this.labelElements=new t,this.labelInputsEnabled=!1,this.maxLabelElement=null,this.messages=null,this.minLabelElement=null,this.rangeLabelInputsEnabled=!1,this.segmentElements=new t,this.snapOnClickEnabled=!0,this.steps=null,this.syncedSegmentsEnabled=!1,this.thumbCreatedFunction=null,this.thumbElements=new t,this.tickElements=new t,this.trackElement=null,this.viewModel=new h,this.visibleElements={..._},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()}get effectiveMax(){return this.viewModel.effectiveMax}set effectiveMax(e){this.viewModel.effectiveMax=e}get effectiveMin(){return this.viewModel.effectiveMin}set effectiveMin(e){this.viewModel.effectiveMin=e}get inputFormatFunction(){return this.viewModel.inputFormatFunction}set inputFormatFunction(e){this.viewModel.inputFormatFunction=e}get inputParseFunction(){return this.viewModel.inputParseFunction}set inputParseFunction(e){this.viewModel.inputParseFunction=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get labelFormatFunction(){return this.viewModel.labelFormatFunction}set labelFormatFunction(e){this.viewModel.labelFormatFunction=e}get labels(){return this.viewModel.labels}set layout(e){["vertical","vertical-reversed","horizontal","horizontal-reversed"].includes(e)||(e="horizontal"),this._set("layout",e)}get max(){return this.viewModel.max}set max(e){this.viewModel.max=e}get min(){return this.viewModel.min}set min(e){this.viewModel.min=e}get precision(){return this.viewModel.precision}set precision(e){this.viewModel.precision=e}get state(){const{_activeLabelInputIndex:e,_isMaxInputActive:t,_isMinInputActive:n,_dragStartInfo:i,_segmentDragStartInfo:s,disabled:o,viewModel:r}=this;return o?"disabled":!(null===e&&!t&&!n)?"editing":null!=i||null!=s?"dragging":r.state}get thumbsConstrained(){return this.viewModel.thumbsConstrained}set thumbsConstrained(e){this.viewModel.thumbsConstrained=e}set tickConfigs(e){this._set("tickConfigs",e),this.scheduleRender()}get values(){return this.viewModel.values}set values(e){this.viewModel.values=e}castVisibleElements(e){return{..._,...e}}render(){const{label:e}=this,t=this.classes(l.base,l.esriWidget,this._isHorizontalLayout()?l.horizontalLayout:l.verticalLayout,this._isReversedLayout()?l.reversed:null,this._isDisabled()?l.disabled:null);return this._storeTrackDimensions(),d("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(!(null==t||null==e||t>=e))return[this.renderMin(),this.renderSliderContainer(),this.renderMax()]}renderSliderContainer(){return d("div",{key:"slider-container",bind:this,class:l.contentElement},this.renderTrackElement(),this.renderTicksContainer(),this.renderExtraContentElements())}renderTrackElement(){return d("div",{afterCreate:this._afterTrackCreate,afterRemoved:this._afterTrackRemoved,bind:this,class:l.trackElement,"touch-action":"none"},this.renderEffectiveSegmentElements(),this.renderSegmentElements(),this.renderAnchorElements())}renderEffectiveSegmentElements(){if(!this.trackElement||!this.values||!this.values.length)return;const e=null!=this.effectiveMax,t=null!=this.effectiveMin;if(!e&&!t)return;const{max:n,min:i,viewModel:s}=this,o=s.getBounds(),r=[];return t&&r.push(this.renderEffectiveSegmentElement(i,o.min,!0)),e&&r.push(this.renderEffectiveSegmentElement(o.max,n,!1)),r}renderSegmentElements(){if(!this.trackElement||!this.values||!this.values.length)return;const e=this.values.length,t=[];for(let n=0;n<=e;n++)t.push(this.renderSegmentElement(n));return t}renderSegmentElement(e){const{_trackHeight:t,_trackWidth:n,draggableSegmentsEnabled:i,id:s,state:o}=this,r=this.values,a=this._isHorizontalLayout(),h=a?n:t,u=this.viewModel.getBounds(),c=this._positionFromValue(u.max),m=this._positionFromValue(u.min),p=e===r?.length?null:e,_=0===e?null:e-1,v=null!=p,g=null!=_;let f,b;const E=[...r].sort(((e,t)=>e-t));this._isReversedLayout()?(f=g?this._positionFromValue(E[_]):m,b=v?this._positionFromValue(E[p]):c):(f=v?this._positionFromValue(E[p]):c,b=g?this._positionFromValue(E[_]):m);const x=this._applyPrecisionToPosition(100*b/h),y=(f-b)/h,k=a?`transform: translate(${x}%, 0px) scale(${y}, 1);`:`transform: translate(0px, ${x}%) scale(1, ${y});`,P=this.classes(l.segmentElement,l.segmentElementIndexPrefix+e,i&&v&&g&&"disabled"!==o?l.segmentElementInteractive:null);return d("div",{afterCreate:this._afterSegmentCreate,afterRemoved:this._afterSegmentRemoved,bind:this,class:P,"data-max-thumb-index":p,"data-min-thumb-index":_,"data-segment-index":e,key:`${s}-segment-${e}`,style:k,"touch-action":"none"})}renderEffectiveSegmentElement(e,t,n){const{_trackHeight:i,_trackWidth:s,layout:o}=this,r=this._positionFromValue(e),a=this._positionFromValue(t),h=this._isHorizontalLayout(),u=h?s:i,c=this._applyPrecisionToPosition(100*r/u);let m=null;if("horizontal"===o){const e=n?u-a:a,t=r===u?0:c;m=`clip-path: inset(0% ${a===u?0:this._applyPrecisionToPosition(e/u*100)}% 0% ${t}%);`}else{const e=(a-r)/u;m=h?`transform: translate(${c}%, 0px) scale(${e}, 1);`:`transform: translate(0px, ${c}%) scale(1, ${e});`}const p=n?l.effectiveMinSegmentElement:l.effectiveMaxSegmentElement,_=this.classes(l.segmentElement,l.effectiveSegmentElement,p);return d("div",{afterCreate:this._afterEffectiveSegmentCreate,afterRemoved:this._afterEffectiveSegmentRemoved,bind:this,class:_,style:m,"touch-action":"none"})}renderAnchorElements(){const{trackElement:e,values:t}=this;if(t&&t.length)return this._zIndices=t.map(((e,n)=>{const i=this._positionFromValue(e),s=this._positionToPercent(i),o=(this._isHorizontalLayout()?s>50:s<50)?-1:1;return this._zIndexOffset+(t.length+o*n)})),e&&t&&t.length?t.map(((e,t)=>this.renderAnchorElement(e,t))):null}renderAnchorElement(e,t){const n=this._positionFromValue(e),i=this._valueFromPosition(n);if(null==i||isNaN(i))return;const{_dragStartInfo:s,_lastMovedHandleIndex:o,id:r,layout:a,visibleElements:{labels:h}}=this,u=this.values,c=s&&s.index===t,p=o===t,_=this.classes(l.anchorElement,l.anchorElementIndexPrefix+t,c?l.movingAnchorElement:null,p?l.lastMovedAnchorElement:null),v=this.labels.values[t],g=this._getStyleForAnchor(e,t,c||p),{min:f,max:b}=this.viewModel.getBoundsForValueAtIndex(t),{disabled:E,messages:x}=this,y=2===u.length?m(0===t?x.rangeMinimum:x.rangeMaximum,{value:e}):v,k=1===u.length?null:0===t?`${r}-handle-${t+1}`:t===u.length-1?`${r}-handle-${t-1}`:`${r}-handle-${t-1} ${r}-handle-${t+1}`;return d("div",{afterCreate:this._afterAnchorCreate,afterUpdate:this._afterAnchorUpdate,afterRemoved:this._afterAnchorRemoved,"aria-controls":k,"aria-label":x.sliderValue,"aria-labelledby":h?`${r}-label-${t}`:null,"aria-orientation":a,"aria-valuemax":b?.toString(),"aria-valuemin":f?.toString(),"aria-valuenow":e.toString(),"aria-valuetext":y,bind:this,class:_,"data-thumb-index":t,"data-value":e,id:`${r}-handle-${t}`,key:`${r}-handle-${t}`,onkeydown:this._onAnchorKeyDown,"touch-action":"none",role:"slider",style:g,tabIndex:E?-1:0},d("span",{afterCreate:this._afterThumbCreate,afterRemoved:this._afterThumbRemoved,bind:this,class:l.thumbElement,"data-thumb-index":t,"touch-action":"none"}),this.renderThumbLabel(t))}renderThumbLabel(e){const{id:t,labels:n,labelInputsEnabled:i,state:s}=this,o=this.visibleElements.labels,r=n.values[e],a=this.classes(l.labelElement,o?null:l.hidden,i&&"disabled"!==s?l.labelElementInteractive:null);return d("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:i?"button":null,"touch-action":"none"},this._activeLabelInputIndex===e?this.renderValueInput(e):r)}renderValueInput(e){const{disabled:t,values:n}=this;if(null==n)return;const i=n[e];return d("input",{key:`value-input-${e}`,afterCreate:this._afterInputCreate,"aria-label":this.messages.sliderValue,bind:this,class:l.labelInput,"data-input-type":"thumb","data-input-index":e,required:!0,tabIndex:t?-1:0,type:"text",value:this._formatInputValue(i,"value",e),onblur:this._onLabelInputBlur,onkeydown:this._onInputKeyDown})}renderMax(){const{_isMaxInputActive:e,labels:t,rangeLabelInputsEnabled:n,state:i}=this,s=this.visibleElements.rangeLabels,o=this.classes(l.maxElement,{[l.hidden]:!s,[l.maxElementInteractive]:n&&"disabled"!==i,[l.rangeElementActive]:e});return d("div",{"aria-hidden":(!s).toString(),afterCreate:this._afterMaxLabelCreate,bind:this,class:o,onclick:this._onMaxLabelClick,onkeydown:this._onMaxLabelKeyDown,role:n?"button":null,tabIndex:!this.disabled&&n?0:-1},e?this.renderMaxInput():t.max)}renderMin(){const{_isMinInputActive:e,labels:t,rangeLabelInputsEnabled:n,state:i}=this,s=this.visibleElements.rangeLabels,o=this.classes(l.minElement,{[l.hidden]:!s,[l.minElementInteractive]:n&&"disabled"!==i,[l.rangeElementActive]:e});return d("div",{"aria-hidden":(!s).toString(),afterCreate:this._afterMinLabelCreate,bind:this,class:o,onclick:this._onMinLabelClick,onkeydown:this._onMinLabelKeyDown,role:n?"button":null,tabIndex:!this.disabled&&n?0:-1},e?this.renderMinInput():t.min)}renderMaxInput(){return d("input",{afterCreate:this._afterInputCreate,"aria-label":this.messages.maximumValue,bind:this,class:l.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 d("input",{afterCreate:this._afterInputCreate,"aria-label":this.messages.minimumValue,bind:this,class:l.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 d("div",{bind:this,class:l.extraContentElement},this.extraNodes)}renderTicksContainer(){if(this.tickConfigs&&this.trackElement&&(0!==this._trackHeight||0!==this._trackWidth))return this.tickConfigs.map(((e,t)=>d("div",{key:"ticks-container",class:this.classes(l.ticksContainerElement)},this.renderTicks(e,t))))}renderTicks(e,n){const{mode:i,values:s}=e;if(this.tickElements.at(n)||this.tickElements.add(new t,n),"position"===i){const t=Array.isArray(s)?s:[s];return this._calculateTickPositions(t).map(((t,i)=>this.renderTickGroup(e,i,n,t)))}if("percent"===i&&Array.isArray(s)){const t=this.min??0,i=(this.max??0)-t,o=s.map((e=>this._applyPrecisionToPosition(e/100*i+t)));return this._calculateTickPositions(o).map(((t,i)=>this.renderTickGroup(e,i,n,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,i)=>this.renderTickGroup(e,i,n,t)))}renderTickGroup(e,t,n,i){const s="position"===e.mode?Array.isArray(e.values)?e.values[t]:e.values:this._valueFromPosition(i);if(null!=s&&!isNaN(s))return d("div",{afterCreate:this._afterTickGroupCreate,afterRemoved:this._afterTickGroupRemoved,bind:this,"data-config":e,"data-position":i,"data-tick-config-index":n,"data-tick-group-index":t,"data-value":s,onclick:this._onTickGroupClick,key:`tick-group-${t}`},this.renderTickLine(e,t,n,s),e.labelsVisible?this.renderTickLabel(e,t,n,s):null)}renderTickLine(e,t,n,i){return d("div",{afterCreate:this._afterTickLineCreate,"aria-valuenow":i.toString(),bind:this,class:l.tickElement,"data-config":e,"data-tick-config-index":n,"data-tick-group-index":t,"data-value":i,key:`tick-label-${t}`,style:this._getPositionStyleForElement(i)})}renderTickLabel(e,t,n,i){const s=e.labelFormatFunction?e.labelFormatFunction(i,"tick",t):this.viewModel.getLabelForValue(i,"tick",t);return d("div",{afterCreate:this._afterTickLabelCreate,"aria-label":s,"aria-valuenow":i.toString(),"aria-valuetext":s,bind:this,class:l.tickLabelElement,"data-config":e,"data-tick-config-index":n,"data-tick-group-index":t,"data-value":i,key:`tick-label-${t}`,style:`transform: translate(-50%); ${this._getPositionStyleForElement(i)}`},s)}getCurrentPosition(){return this._positionFromValue(this.values?.[0]??0)}_afterContainerCreate(e){this.addHandles(u(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=g(e),n=y(e),i=this.thumbElements.at(t),s=this.labelElements.at(t)||null;this.thumbCreatedFunction(t,n,i,s)}}_afterAnchorUpdate(e){if(null!=this._focusedAnchorIndex){g(e)===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"),n="thumb"===t?f(e):null;this.inputCreatedFunction(e,t,n)}}_afterTickLineCreate(e){const t=k(e),n=P(e),i=this.tickElements.at(t),s=i.at(n);s?s.tickElement=e:i.add({groupElement:null,tickElement:e,labelElement:null},n)}_afterTickLabelCreate(e){const t=k(e),n=P(e),i=this.tickElements.at(t),s=i.at(n);s?s.labelElement=e:i.add({groupElement:null,labelElement:e,tickElement:null},n)}_afterTickGroupRemoved(e){const t=k(e),n=this.tickElements.items[t],i=n?.find((t=>t.groupElement===e));i&&n.remove(i)}_afterTickGroupCreate(e){const t=I(e);if(t?.tickCreatedFunction){const n=k(e),i=P(e),s=y(e),o=this.tickElements?.at(n)?.at(i);if(o){o.groupElement=e;const n=o.tickElement||null,i=o.labelElement||null;t.tickCreatedFunction(s,n,i)}}}_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,i=n(e),s=this.values,o=g(t),r=this._anchorElements[o],a=s[o],l=[p.moveAnchorUp,p.moveAnchorDown,p.moveAnchorLeft,p.moveAnchorRight];if(i===p.showInput&&this.labelInputsEnabled)this._activeLabelInputIndex=o,this.notifyChange("state");else if(l.includes(i)){e.preventDefault();const{steps:t}=this,n=i===p.moveAnchorUp||i===p.moveAnchorRight?1:-1;if(null!=t)this._toStep(o,this._isReversedLayout()?-1*n:n);else{const{precision:e}=this,t=this._getPositionOfElement(r),i=this._valueFromPosition(t),s=this._isHorizontalLayout()?n:-1*n;let a;a=0===e?this._positionFromValue(i+s):1===e?this._positionFromValue(i+.1*s):t+s,this._toPosition(o,a)}const s=this.values[o];a!==s&&this._emitThumbChangeEvent({index:o,oldValue:a,value:s})}else if(i===p.moveAnchorToMax||i===p.moveAnchorToMin){e.preventDefault();const{min:t,max:n}=this._getAnchorBoundsInPixels(o),s=this._isPositionInverted()?i===p.moveAnchorToMax?t:n:i===p.moveAnchorToMin?t:n;this._toPosition(o,s);const r=this.values[o];a!==r&&this._emitThumbChangeEvent({index:o,oldValue:a,value:r})}}_onAnchorPointerDown(e){if(this._isDisabled())return;const{target:t,clientX:n,clientY:i}=e,s=g(t);null!=s&&(e.preventDefault(),this._anchorElements[s]&&this._anchorElements[s].focus(),this._storeTrackDimensions(),this._dragStartInfo={clientX:n,clientY:i,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:n,_dragged:i,_dragStartInfo:s,_dragStartInfo:{index:o,position:r}}=this,{clientX:a,clientY:l}=e,h=i?"drag":"start",u=n[o],c=this._getPositionOfElement(u),d=this._applyPrecisionToPosition(this._isHorizontalLayout()?r+a-s.clientX:r+l-s.clientY);if(c===d)return;const m=t[o];this._dragged=!0,this._toPosition(o,d);const p=this.values[o];i?m!==p&&this._emitThumbDragEvent({index:o,state:h,value:p}):this._emitThumbDragEvent({index:o,state:h,value:m})}_onAnchorPointerUp(e){if(document.removeEventListener("pointerup",this._onAnchorPointerUp),document.removeEventListener("pointermove",this._onAnchorPointerMove),!this._dragStartInfo)return;e.preventDefault();const{index:t}=this._dragStartInfo,n=this._dragged,i=this.values[t];this._dragged=!1,this._dragStartInfo=null,this._lastMovedHandleIndex=t,this.notifyChange("state"),n?this._emitThumbDragEvent({index:t,state:"stop",value:i}):(this.scheduleRender(),"editing"!==this.state&&this._emitThumbClickEvent({index:t,value:i}))}_onTrackPointerDown(e){const{_dragStartInfo:t,snapOnClickEnabled:n,state:i,values:s}=this;if(this._isDisabled()||"editing"===i||t)return;if(document.addEventListener("pointermove",this._onTrackPointerMove),document.addEventListener("pointerup",this._onTrackPointerUp),!n||!s?.length)return;const{steps:o}=this,{clientX:r,clientY:a}=e,l=this._getCursorPositionFromEvent(e),h=this._valueFromPosition(l),u=this._getIndexOfNearestValue(h),c=s[u],d=s.some(((e,t)=>e===c&&t!==u))&&h>c?s.lastIndexOf(c):u;if(null==d)return;const m=s[d],p=null!=o?this._calculateNearestStepPosition(l):l;this._toPosition(d,p),this._dragged=!0,this._dragStartInfo={clientX:r,clientY:a,index:d,position:p},this._focusedAnchorIndex=d,this.notifyChange("state"),this._emitThumbDragEvent({index:d,state:"start",value:m});const _=this.values[d];m!==_&&this._emitThumbDragEvent({index:d,state:"drag",value:_}),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),n=this._valueFromPosition(t);this._emitTrackClickEvent({value:n})}}_onSegmentPointerDown(e){e.preventDefault();const t=e.target,n=b(t),i=E(t),s=x(t);if(this._isDisabled()||null==i||null==s)return;e.stopPropagation(),this._storeTrackDimensions(),document.addEventListener("pointerup",this._onSegmentPointerUp);const o=this._getAnchorDetails(i),r=this._getAnchorDetails(s);this.syncedSegmentsEnabled?(this.segmentElements.forEach((e=>e.classList.add(l.segmentElementActive))),this._anchorElements.forEach((e=>e.classList.add(l.anchorElementActive)))):(this.segmentElements.at(n).classList.add(l.segmentElementActive),this._anchorElements[o.index]?.classList.add(l.anchorElementActive),this._anchorElements[r.index]?.classList.add(l.anchorElementActive)),this._segmentDragStartInfo={cursorPosition:this._getCursorPositionFromEvent(e),index:n,details:this._normalizeSegmentDetails({min:o,max:r})},this.draggableSegmentsEnabled&&(document.addEventListener("pointermove",this._onSegmentPointerMove),this.notifyChange("state"),this._emitSegmentDragEvent({index:n,state:"start",thumbIndices:[i,s]}))}_onSegmentPointerMove(e){if(!this._segmentDragStartInfo)return;e.preventDefault();const{_trackHeight:t,_trackWidth:n,_segmentDragStartInfo:{index:i,cursorPosition:s,details:{min:o,max:r}}}=this,{index:a,position:l,value:h}=o,{index:u,position:c,value:d}=r;this._dragged=!0;const m=this._getCursorPositionFromEvent(e);if(m===s)return;const p=this._positionToPercent(s),_=this._positionToPercent(m)-p,v=this._positionToPercent(l)+_,g=this._positionToPercent(c)+_,{min:f}=this._getAnchorBoundsAsPercents(a),{max:b}=this._getAnchorBoundsAsPercents(u);let E=!1,x=!1;if(v<f?E=!0:g>b&&(x=!0),E){const{min:e,max:t}=this.viewModel.getBoundsForValueAtIndex(a),n=this._isPositionInverted()?t:e,i=n,s=d+(n-h),o=s-this.values[u];return void(this.syncedSegmentsEnabled?this._updateAnchorValuesByDifference(o):this._updateAnchorValues([a,u],[i,s]))}if(x){const{min:e,max:t}=this.viewModel.getBoundsForValueAtIndex(u),n=this._isPositionInverted()?e:t,i=n,s=h+(n-d),o=s-this.values[a];return void(this.syncedSegmentsEnabled?this._updateAnchorValuesByDifference(o):this._updateAnchorValues([a,u],[s,i]))}const y=this._isHorizontalLayout()?n:t,k=g/100*y,P=v/100*y,I=this.values,A=[I[a],I[u]],L=this._getValueForAnchorAtPosition(a,P),M=this._getValueForAnchorAtPosition(u,k);this.syncedSegmentsEnabled?this._updateAnchorValuesByDifference(L-A[0]):this._updateAnchorValues([a,u],[L,M]);[this.values[a],this.values[u]].every(((e,t)=>e===A[t]))||this._emitSegmentDragEvent({index:i,state:"drag",thumbIndices:[a,u]})}_onSegmentPointerUp(e){if(e.preventDefault(),document.removeEventListener("pointerup",this._onSegmentPointerUp),document.removeEventListener("pointermove",this._onSegmentPointerMove),!this._segmentDragStartInfo)return;const{_dragged:t}=this,n=this.min,i=this.max,s=this.values,{index:o,details:{min:{index:r},max:{index:a}}}=this._segmentDragStartInfo;if(this.segmentElements.forEach((e=>e.classList.remove(l.segmentElementActive))),this._anchorElements.forEach((e=>e.classList.remove(l.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),n=this._valueFromPosition(t);this._emitSegmentClickEvent({index:o,value:n,thumbIndices:[r,a]})}}_onTickGroupClick(e){const t=e.target;if(I(t)){const e=k(t),n=P(t),i=y(t);this._emitTickClickEvent({configIndex:e,groupIndex:n,value:i})}}_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=g(e.target);this.labelInputsEnabled&&!this._dragged&&null!=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:n,viewModel:i}=this,s=e.target.value;if(this._activeLabelInputIndex=null,this.notifyChange("state"),!s||null==t||null==n)return;const o=this._parseInputValue(s,"value",t),r=n[t],{min:a,max:l}=this.viewModel.getBoundsForValueAtIndex(t);if(o<a||o>l)return;i.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,i=n(e),{hideInput1:s,hideInput2:o,hideInput3:r}=p,{_activeLabelInputIndex:a,_anchorElements:l}=this,h=t;if(i===s||i===o||i===r){e.stopPropagation();const t=a;h.blur(),null!=t?l[t].focus():h.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()||n(e)!==p.showInput||(this._isMaxInputActive=!0,this.notifyChange("state"))}_onMaxInputBlur(e){const t=e.target.value;if(this._isMaxInputActive=!1,this.notifyChange("state"),!t)return;const n=this.max,i=this._parseInputValue(t,"max");i<=this.min||(this.viewModel.set("max",i),this.max!==n&&this._emitMaxChangeEvent({oldValue:n,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()||n(e)!==p.showInput||(this._isMinInputActive=!0,this.notifyChange("state"))}_onMinInputBlur(e){const t=e.target.value;if(this._isMinInputActive=!1,this.notifyChange("state"),!t)return;const n=this.min,i=this._parseInputValue(t,"min");i>=this.max||(this.viewModel.set("min",i),this.min!==n&&this._emitMinChangeEvent({oldValue:n,value:this.min}))}_isDisabled(){return this.disabled||"disabled"===this.state}_positionFromValue(e){const{_trackHeight:t,_trackWidth:n}=this,i=this.min??0,s=this.max??0,o=s-i;if(0===o||null==e)return 0;const r=this._isHorizontalLayout();let a=r?parseFloat((n*(e-i)/o).toFixed(2)):parseFloat((t*(s-e)/o).toFixed(2));return this._isReversedLayout()&&(a=r?n-a:t-a),a}_valueFromPosition(e){const{_trackHeight:t,_trackWidth:n,precision:i}=this,s=this.min??0,o=this.max??0,r=o-s;let a=this._isHorizontalLayout()?e*r/n+s:r*(1e3-e/t*1e3)/1e3+s;return this._isReversedLayout()&&(a=o+s-a),parseFloat(a.toFixed(i))}_positionToPercent(e){const{_trackHeight:t,_trackWidth:n}=this,i=100*e/(this._isHorizontalLayout()?n:t);return this._applyPrecisionToPosition(i)}_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:n}=e;return{min:n,max:t}}return e}_parseInputValue(e,t,n){return this.inputParseFunction?this.inputParseFunction(e,t,n):this.viewModel.defaultInputParseFunction(e)}_formatInputValue(e,t,n){return this.inputFormatFunction?this.inputFormatFunction(e,t,n):this.viewModel.defaultInputFormatFunction(e)}_getAnchorDetails(e){const t=this.values,n=[...t].sort(((e,t)=>e-t))[e],i=t.indexOf(n);return{index:i,position:this._getPositionOfElement(this._anchorElements[i]),value:n}}_updateAnchorStyle(e,t){const n=this._anchorElements[e];n&&(this._isHorizontalLayout()?n.style.left=`${t}`:n.style.top=`${t}`)}_getStyleForAnchor(e,t,n){const i=this._getPositionStyleForElement(e);if(1===this.values?.length)return`${i}`;const s=this._zIndices[t];return`${i}; z-index: ${n?this._zIndexOffset+s:s}`}_getPositionStyleForElement(e){const t=this._positionFromValue(e),n=this._positionToPercent(t);return`${this._isHorizontalLayout()?"left":"top"}: ${n}%`}_getPositionOfElement(e){const t=this._getDimensions(e.offsetParent),n=this._getDimensions(e);return this._isHorizontalLayout()?this._applyPrecisionToPosition(n.left-t.left):this._applyPrecisionToPosition(n.top-t.top)}_updateAnchorValues(e,t){e.forEach(((e,n)=>this._toValue(e,t[n])))}_updateAnchorValuesByDifference(e){const{min:t,max:n,values:i}=this;i?.forEach(((i,s)=>this._toValue(s,Math.max(Math.min(i+e,n),t))))}_toValue(e,t){if(null!=this.steps){t=this._getStepValues()[this._getIndexOfNearestStepValue(t)]}this._updateAnchorStyle(e,this._getPositionStyleForElement(t)),this.viewModel.setValue(e,t)}_toPosition(e,t){const n=null!=this.steps?this._getStepValueForAnchorAtPosition(e,t):this._getValueForAnchorAtPosition(e,t);this._updateAnchorStyle(e,this._getPositionStyleForElement(n)),this.viewModel.setValue(e,n)}_getValueForAnchorAtPosition(e,t){const{min:n,max:i}=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>i?r:t<n?a:this._valueFromPosition(t),l>o?l=o:l<s&&(l=s),l}_getStepValueForAnchorAtPosition(e,t){const n=this._getStepValues(),i=this._calculateNearestStepPosition(t),s=this._getValueForAnchorAtPosition(e,i);return n[this._getIndexOfNearestStepValue(s)]}_getAnchorBoundsAsPercents(e){const{min:t,max:n}=this._getAnchorBoundsInPixels(e);return{min:this._positionToPercent(t),max:this._positionToPercent(n)}}_getAnchorBoundsInPixels(e){const{_anchorElements:t,_trackHeight:n,_trackWidth:i,effectiveMax:s,effectiveMin:o,thumbsConstrained:r}=this,a=t[e-1],l=t[e+1],h=this._isHorizontalLayout()?i:n;let u,c;return this._isPositionInverted()?(u=null!=o?this._positionFromValue(o):h,c=null!=s?this._positionFromValue(s):0):(u=null!=s?this._positionFromValue(s):h,c=null!=o?this._positionFromValue(o):0),r?this._isPositionInverted()?{max:a?this._getPositionOfElement(a):u,min:l?this._getPositionOfElement(l):c}:{max:l?this._getPositionOfElement(l):u,min:a?this._getPositionOfElement(a):c}:{max:u,min:c}}_getIndexOfNearestValue(e){const t=this.values;return t.indexOf(t.reduce(((t,n)=>Math.abs(n-e)<Math.abs(t-e)?n: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:n}=this;if(null==n||null==t||null==e)return[];const i=Math.ceil((t-n)/e),s=[];for(let o=0;o<=i;o++){const i=n+e*o;s.push(i>t?t:i)}return s}_toStep(e,t){const n=this.values[e],i=this._getStepValues(),s=i.indexOf(n);let o=null;if(s>-1){let n=i[s+t];isNaN(n)&&(n=i[s]);const r=this._positionFromValue(n);o=this._getStepValueForAnchorAtPosition(e,r)}else{o=i[this._getIndexOfNearestStepValue(n)+t]}this.viewModel.setValue(e,o)}_getIndexOfNearestStepValue(e){const{steps:t}=this;if(null==t)return null;const n=this._getStepValues(),i=n.reduce(((t,n)=>Math.abs(n-e)<Math.abs(t-e)?n:t));return n.indexOf(i)}_calculateNearestStepPosition(e){const t=this._valueFromPosition(e),n=this._getIndexOfNearestStepValue(t),i=this._getStepValues();return this._positionFromValue(i[n])}_getTickCounts(e,t){const{mode:n}=t;return"count"===n||"position"===n?e||0:"percent"===n&&100/e||0}_calculateTickPositions(e){return e.map((e=>this._positionFromValue(e)))}_calculateEquidistantTickPositions(e){const{_trackWidth:t,_trackHeight:n}=this,i=this._isHorizontalLayout()?t:n,s=i/(e-1),o=[];if(1===e)return[i/2];for(let r=0;r<e;r++){const e=r*s;e<=i&&o.push(e)}return o}_getDimensions(e){try{return i(e),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})}};function g(e){return e?.["data-thumb-index"]}function f(e){return e?.["data-input-index"]}function b(e){return e?.["data-segment-index"]}function E(e){return e?.["data-min-thumb-index"]}function x(e){return e?.["data-max-thumb-index"]}function y(e){return e?.["data-value"]}function k(e){return e?.["data-tick-config-index"]}function P(e){return e?.["data-tick-group-index"]}function I(e){return e?.["data-config"]}e([s()],v.prototype,"disabled",void 0),e([s()],v.prototype,"draggableSegmentsEnabled",void 0),e([s()],v.prototype,"effectiveMax",null),e([s()],v.prototype,"effectiveMin",null),e([s({readOnly:!0})],v.prototype,"effectiveSegmentElements",void 0),e([s()],v.prototype,"extraNodes",void 0),e([s()],v.prototype,"inputCreatedFunction",void 0),e([s()],v.prototype,"inputFormatFunction",null),e([s()],v.prototype,"inputParseFunction",null),e([s()],v.prototype,"label",null),e([s({readOnly:!0})],v.prototype,"labelElements",void 0),e([s()],v.prototype,"labelInputsEnabled",void 0),e([s()],v.prototype,"labelFormatFunction",null),e([s({readOnly:!0})],v.prototype,"labels",null),e([s({value:"horizontal"})],v.prototype,"layout",null),e([s()],v.prototype,"max",null),e([s({readOnly:!0})],v.prototype,"maxLabelElement",void 0),e([s(),c("esri/widgets/Slider/t9n/Slider")],v.prototype,"messages",void 0),e([s()],v.prototype,"min",null),e([s({readOnly:!0})],v.prototype,"minLabelElement",void 0),e([s()],v.prototype,"precision",null),e([s()],v.prototype,"rangeLabelInputsEnabled",void 0),e([s({readOnly:!0})],v.prototype,"segmentElements",void 0),e([s()],v.prototype,"snapOnClickEnabled",void 0),e([s({readOnly:!0})],v.prototype,"state",null),e([s()],v.prototype,"steps",void 0),e([s()],v.prototype,"syncedSegmentsEnabled",void 0),e([s()],v.prototype,"thumbsConstrained",null),e([s()],v.prototype,"thumbCreatedFunction",void 0),e([s({readOnly:!0})],v.prototype,"thumbElements",void 0),e([s()],v.prototype,"tickConfigs",null),e([s({readOnly:!0})],v.prototype,"tickElements",void 0),e([s({readOnly:!0})],v.prototype,"trackElement",void 0),e([s()],v.prototype,"values",null),e([s()],v.prototype,"viewModel",void 0),e([s()],v.prototype,"visibleElements",void 0),e([o("visibleElements")],v.prototype,"castVisibleElements",null),v=e([r("esri.widgets.Slider")],v);const A=v;export{A as default};