/* COPYRIGHT Esri - https://js.arcgis.com/1.2/LICENSE.txt */
import{a as u}from"./YOH3QK7R.js";import{b as y}from"./77CU4WA2.js";import{a as f}from"./6S75SIVV.js";import"./5IZMQFRP.js";import"./FOQPGXXA.js";import{b as m}from"./ABSRNM72.js";import{F as d,G as p,H as g,J as r,h as c,i as l,r as o,u as n}from"./5CQPQ7AE.js";import"./3QPJ2JCA.js";export default $arcgis.t(([_,b,k])=>{var w=c`@layer{
/** @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;
}

.border {
  outline: 1px solid var(--calcite-color-border-input);
}

.border-left {
  border-left: 1px solid rgba(110, 110, 110, 0.3);
}

.border-left[dir='rtl'] {
  border-right: 1px solid rgba(110, 110, 110, 0.3);
}

/* from js api */
.esri-widget {
  box-sizing: border-box;
  color: #323232;
  font-size: 14px;
  font-family: 'Avenir Next', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  line-height: 1.3em;
  background-color: #fff;
  --esri-widget-padding-v: 12px;
  --esri-widget-padding-h: 15px;
  --esri-widget-padding: var(--esri-widget-padding-v) var(--esri-widget-padding-h);
}

.esri-sketch__panel {
  align-items: center;
  display: flex;
  flex-flow: row wrap;
  padding: 0;
  justify-content: flex-start !important;
}

.esri-sketch__section {
  align-items: center;
  display: flex;
  flex-flow: row wrap;
  padding: 0 7px;
  margin: 6px 0;
}

.esri-responsive-toolbar__bar--horizontal {
  --calcite-action-group-border-color: var(--calcite-color-border-3) !important;
}
}`,h=class extends g{constructor(){super(...arguments),this.active=!1,this.drawMode="SKETCH",this.editGraphicsEnabled=!0,this.graphics=[],this.redoEnabled=!1,this.undoEnabled=!1,this._translations=f({name:"map-draw-tools",blocking:!0}),this._pnContextConsumer=y({context:u,subscribe:!0}),this._sketchElement=d(),this.selectionLoadingChange=o(),this.sketchGraphicsChange=o(),this.drawUndo=o(),this.drawRedo=o()}static{this.properties={active:[5,{},{type:Boolean}],drawMode:1,editGraphicsEnabled:[5,{},{type:Boolean}],graphics:[0,{},{attribute:!1}],mapView:[0,{},{attribute:!1}],pointSymbol:[0,{},{attribute:!1}],polylineSymbol:[0,{},{attribute:!1}],polygonSymbol:[0,{},{attribute:!1}],redoEnabled:[5,{},{type:Boolean}],undoEnabled:[5,{},{type:Boolean}],_translations:[16,{},{state:!0}],_selectionMode:[16,{},{state:!0}]}}static{this.styles=w}static{this.shadowRootOptions=n}willUpdate(e){e.has("graphics")&&this.graphicsWatchHandler(this.graphics,e.get("graphics")),e.has("mapView")&&this.mapView&&this.mapViewWatchHandler(this.mapView,e.get("mapView"))}graphicsWatchHandler(e,i){e&&e.length>0&&JSON.stringify(e)!==JSON.stringify(i)&&this._sketchGraphicsLayer&&(this._updateGraphicsSymbols(e),this._sketchGraphicsLayer.removeAll(),this._sketchGraphicsLayer.addMany(e))}mapViewWatchHandler(e,i){e&&e!==i&&this._init()}async clear(){this._clearSketch()}async updateGraphics(){this._updateGraphics()}loaded(){this._init()}disconnectedCallback(){super.disconnectedCallback(),this._sketchWidget?.cancel(),this._clearSketch()}render(){let e=this.drawMode==="SKETCH"?"border":"border esri-widget esri-sketch__panel",i=this.drawMode==="SKETCH"?"display-none":"esri-widget esri-sketch__panel border-left esri-sketch__section";return l`<div class=${r(e)}><div ${p(this._sketchElement)}></div><div class=${r(i)}><calcite-action appearance=solid .disabled=${!this.undoEnabled} icon=undo @click=${()=>this._undo()} scale=s .text=${this._translations.undo}></calcite-action><calcite-action appearance=solid .disabled=${!this.redoEnabled} icon=redo @click=${()=>this._redo()} scale=s .text=${this._translations.redo}></calcite-action></div></div>`}_init(){this.mapView&&this._sketchElement.value&&(this._initGraphicsLayer(),this._initSketch())}_initGraphicsLayer(){let e=this._pnContextConsumer.value,i=this._translations.sketchLayer;if(this.mapView){let s=this.mapView.map.layers.findIndex(t=>t.title===i);s>-1?this._sketchGraphicsLayer=this.mapView.map.layers.getItemAt(s):(this._sketchGraphicsLayer=new _({title:i,listMode:"hide"}),this._sketchGraphicsLayer&&(e.managedLayers[i]="sketch",this.mapView.map.layers.add(this._sketchGraphicsLayer))),this.graphics&&this.graphics.length>0&&this._sketchGraphicsLayer&&this._sketchGraphicsLayer.addMany(this.graphics)}}_initSketch(){let e={layer:this._sketchGraphicsLayer,view:this.mapView,defaultCreateOptions:{mode:"hybrid"},defaultUpdateOptions:{preserveAspectRatio:!1,enableScaling:!1,enableRotation:!1,tool:"reshape",toggleToolOnClick:!1}};if(this._sketchWidget=new k({...e,container:this._sketchElement.value,creationMode:"single",toolbarKind:"docked",visibleElements:{duplicateButton:!1,selectionTools:{"lasso-selection":!1,"rectangle-selection":!1},createTools:{circle:!1},undoRedoMenu:!1,settingsMenu:this.drawMode==="SKETCH"}}),this._sketchWidget&&this._sketchWidget.viewModel){this._sketchViewModel=new b({...e}),this.polylineSymbol&&(this._sketchWidget.viewModel.polylineSymbol=this.polylineSymbol),this.pointSymbol&&(this._sketchWidget.viewModel.pointSymbol=this.pointSymbol),this.polygonSymbol&&(this._sketchWidget.viewModel.polygonSymbol=this.polygonSymbol),this._sketchWidget?.when(async()=>{await new Promise(a=>setTimeout(a,50)),this._sketchElement.value?.getElementsByTagName("calcite-popover")[0]?.setAttribute("placement","auto")});let i=!1;this._sketchWidget.viewModel.addHandles(this._sketchWidget.on("create",t=>{t.state==="complete"&&(this.graphics=t.graphic?[t.graphic]:[],this.sketchGraphicsChange.emit({graphics:this.graphics,useOIDs:!1}),this.drawMode==="REFINE"&&(i=!0,this._sketchWidget?.viewModel.create(t.tool))),t.state==="cancel"&&this.drawMode==="REFINE"&&i&&(i=!i,this._sketchWidget?.viewModel.create(t.tool))}));let s;this._sketchWidget.viewModel.addHandles(this._sketchWidget.on("update",t=>{if(!this.editGraphicsEnabled)this._sketchWidget?.viewModel.cancel(),this._sketchViewModel?.cancel();else{let a=t?.toolEventInfo?.type;(a==="move"||a==="reshape-stop"||a==="move-stop")&&(clearTimeout(s),s=window.setTimeout(async()=>{this.graphics=t.graphics,this.sketchGraphicsChange.emit({graphics:this.graphics,useOIDs:!1})},1e3))}})),this._sketchWidget.viewModel.addHandles(this._sketchWidget.on("delete",()=>{this.graphics=[],this.sketchGraphicsChange.emit({graphics:this.graphics,useOIDs:!1})})),this._sketchWidget.viewModel.addHandles(this._sketchWidget.on("undo",t=>{this.graphics=t.graphics,this.sketchGraphicsChange.emit({graphics:this.graphics,useOIDs:!1})})),this._sketchWidget.viewModel.addHandles(this._sketchWidget.on("redo",t=>{this.graphics=t.graphics,this.sketchGraphicsChange.emit({graphics:this.graphics,useOIDs:!1})}))}}_clearSketch(){this._sketchWidget?.viewModel.cancel(),this.graphics=[],this._sketchGraphicsLayer?.removeAll()}_undo(){this.drawUndo.emit()}_redo(){this.drawRedo.emit()}_updateGraphics(){setTimeout(()=>{this.graphics.length===1&&this._sketchWidget&&this._sketchWidget.update(this.graphics,{tool:"reshape",enableRotation:!1,enableScaling:!1,preserveAspectRatio:!1,toggleToolOnClick:!1})},100)}_updateGraphicsSymbols(e){let s=e[0]?.geometry?.type,t=s==="point"?this.pointSymbol:s==="polyline"?this.polylineSymbol:s==="polygon"?this.polygonSymbol:void 0;t&&e.forEach(a=>a.symbol=t)}};m("map-draw-tools",h);return h},"layers/GraphicsLayer","widgets/Sketch/SketchViewModel","widgets/Sketch")