/* COPYRIGHT Esri - https://js.arcgis.com/1.2/LICENSE.txt */
import{a as m}from"./6S75SIVV.js";import"./5IZMQFRP.js";import"./FOQPGXXA.js";import{b as d}from"./ABSRNM72.js";import{F as o,G as c,H as u,h,i as s,r as n}from"./5CQPQ7AE.js";import"./3QPJ2JCA.js";export default $arcgis.t(([i,r])=>{var p=h`/** @license
 * Copyright 2025 Esri
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

:host {
  display: block;
}

.c-container {
  display: inline-flex;
}

.flex-1 {
  flex: '1';
}

.padding-end-1 {
  padding-inline-end: 1rem;
}

.w-50 {
  width: 50%;
}`,a=class extends u{constructor(){super(...arguments),this.appearance="text",this.distance=0,this.geometries=[],this.max=0,this.min=0,this.sliderTicks=10,this.unionResults=!0,this.unit="meters",this.disabled=!1,this._translations=m({name:"buffer-tools",blocking:!0}),this._unitElement=o(),this.bufferComplete=n(),this.distanceChanged=n(),this.unitChanged=n()}static{this.properties={appearance:1,distance:[9,{},{type:Number}],geometries:[0,{},{attribute:!1}],max:[9,{},{type:Number}],min:[9,{},{type:Number}],sliderTicks:[9,{},{type:Number}],unionResults:[5,{},{type:Boolean}],unit:1,disabled:[5,{},{type:Boolean}],_translations:[16,{},{state:!0}],_units:[16,{},{state:!0}]}}static{this.styles=p}willUpdate(e){e.has("geometries")&&(this.hasUpdated||this.geometries?.length>0)&&this.geometriesWatchHandler(),e.has("disabled")&&(this.hasUpdated||this.disabled!==!1)&&this.disabledWatchHandler(),e.has("_translations")&&this._defineTranslations(),e.has("unit")&&this.hasUpdated&&this._setUnit(this.unit),e.has("distance")&&this.hasUpdated&&this._setDistance({target:{value:this.distance}})}geometriesWatchHandler(){this._buffer()}disabledWatchHandler(){this._buffer()}async getTranslatedUnit(e){return this._units||await this._defineTranslations(),this._units?this._units[e]:""}render(){return this.appearance==="text"?this._getTextBoxDisplay():this._getSliderDisplay()}async _defineTranslations(){this._units={feet:this._translations.feet||"Feet",meters:this._translations.meters||"Meters",miles:this._translations.miles||"Miles",kilometers:this._translations.kilometers||"Kilometers"}}_getUnits(){return this._units?Object.keys(this._units).map(e=>this._units?s`<calcite-option .label=${this._units[e]} .selected=${this.unit===e} .value=${e}></calcite-option>`:void 0):void 0}_setDistance(e){let t=Number.parseInt(e.target.value,10);this.distance!==t&&t>=this.min&&(this.distanceChanged.emit({oldValue:this.distance,newValue:t}),this.distance=t,this.distance>0?this._buffer():this.bufferComplete.emit(void 0))}_setUnit(e){this.unitChanged.emit({oldValue:this.unit,newValue:e}),this.unit=e,this._buffer()}_buffer(){this.disabled?this.bufferComplete.emit(void 0):(this._bufferTimeout&&clearTimeout(this._bufferTimeout),this._bufferTimeout=setTimeout(async()=>{if(this.geometries?.length>0&&this.unit&&this.distance>0&&i&&r){i.isLoaded()||await i.load();let t=this.geometries[0].spatialReference,l=this.geometries,f=t.isWGS84||t.isWebMercator?i.executeMany(l,[this.distance],{union:this.unionResults,unit:this.unit}):r.executeMany(l,[this.distance],{unit:this.unit,union:this.unionResults});this.bufferComplete.emit(f)}},400))}_getTextBoxDisplay(){return s`<div class="c-container"><calcite-input class="padding-end-1 w-50" .max=${this.max&&this.max>0?this.max:void 0} .min=${this.min} number-button-type=vertical @calciteInputInput=${this._setDistance} placeholder=0 type=number .value=${this.distance?this.distance.toString():void 0}></calcite-input><calcite-select class="flex-1 w-50" label=label @calciteSelectChange=${()=>{this._unitElement?.value&&this._setUnit(this._unitElement?.value.value)}} ${c(this._unitElement)}>${this._getUnits()}</calcite-select></div>`}_getSliderDisplay(){return s`<div><calcite-slider label-handles .max=${this.max&&this.max>0?this.max:void 0} .min=${this.min} .ticks=${this.sliderTicks}></calcite-slider></div>`}_testAccess(e,t){switch(e){case"_setUnit":return this._setUnit(t);case"_setDistance":return this._setDistance(t)}return null}};d("buffer-tools",a);return a},"geometry/operators/geodesicBufferOperator","geometry/operators/bufferOperator")