/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.25/esri/copyright.txt for details. */ import{_ as e}from"../../chunks/tslib.es6.js";import"../../geometry.js";import t from"../../core/Accessor.js";import{isNone as r}from"../../core/maybe.js";import{createScreenPoint as s}from"../../core/screenUtils.js";import{property as i}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/accessorSupport/ensureType.js";import{subclass as o}from"../../core/accessorSupport/decorators/subclass.js";import{isSupported as n,geodesicLengths as a}from"../../geometry/support/geodesicUtils.js";import{straightLineDensify as c}from"../../geometry/support/normalizeUtils.js";import{getInfo as m}from"../../geometry/support/spatialReferenceUtils.js";import{webMercatorToGeographic as l}from"../../geometry/support/webMercatorUtils.js";import p from"../../geometry/support/WKIDUnitConversion.js";import u from"../../geometry/SpatialReference.js";import d from"../../geometry/Polyline.js";import f from"../../geometry/Point.js";function g(e){const{wkid:t}=e;if(null!=p[t])return p.values[p[t]];const{wkt:r}=e,s=r.lastIndexOf(",")+1,i=r.lastIndexOf("]]");return parseFloat(r.substring(s,i))}function has(e,t){return e&&e.includes(t)}function h(e,t){const{x:r,y:s}="decimal-degrees"===e?l(t,!0):t;return[r,s]}function w({state:{paddedViewState:e},spatialReference:t,width:r}){return t.isWrappable&&e.worldScreenWidthi?a=i:a<0&&(a=0);const c=s(0,a),l=s(r,a);return[e.toMap(c),e.toMap(l)]}_getScaleBarProps(e,t,r){const{view:s}=this;let i=e*t/(w(s)?s.state.paddedViewState.worldScreenWidth:s.width),o="metric"===r?"km":"mi";if(i<.1)if("mi"===o){i*=5280,o="ft"}else if("km"===o){i*=1e3,o="m"}let n=0;for(;i>=1;)i/=10,n++;const a=this._getConstraints(i);if(!a)return null;const{min:c,max:m}=a,l=m/i>=i/c?c:m;return{length:e*(l/i),value:10**n*l,unit:o}}_getConstraints(e){return e>.5?{min:.5,max:1}:e>.3?{min:.3,max:.5}:e>.2?{min:.2,max:.3}:e>.15?{min:.15,max:.2}:e>=.1?{min:.15,max:.1}:void 0}};e([i()],y.prototype,"scaleComputedFrom",void 0),e([i({readOnly:!0})],y.prototype,"state",null),e([i()],y.prototype,"view",void 0),y=e([o("esri.widgets.Scalebar.ScaleBarViewModel")],y);const S=y;export{S as default};