/*! All material copyright GeoScene, All Rights Reserved, unless otherwise specified.
See https://js.geoscene.cn/4.33/geoscene/copyright.txt for details.
v4.33.18 */
import c from"./E5V5AKTV.js";import{a as f}from"./VK24LKXI.js";import{a as r}from"./LL7T22QC.js";import b from"./Y4DAIYBP.js";import a from"./DTE4O2DP.js";import{e as w}from"./LYMDZ73M.js";import"./MG6XDMQJ.js";import"./HITJFSBP.js";import{B as g,E as p,P as m,Q as e,S as v,U as u,a as d,j as h,k as o}from"./3VKC6PRK.js";export default $geoscene.t(([T,,{a:s},M])=>{var $=h`@layer{geoscene-track{display:block}}`,D={base:"geoscene-track"},O=M(T),a=class extends m{constructor(){super(...arguments),this.messages=f(),this.viewModel=O(this),this.autoDestroyDisabled=!1,this.error=this.viewModel.error,this.geolocationOptions=this.viewModel.geolocationOptions,this.goToOverride=this.viewModel.goToOverride,this.goToLocationDisabled=this.viewModel.goToLocationEnabled,this.graphic=this.viewModel.graphic,this.icon="compass-north-circle",this.position="top-left",this.positionFilterFunction=this.viewModel.positionFilterFunction,this.rotationDisabled=this.viewModel.rotationEnabled,this.scale=this.viewModel.scale,this.state=this.viewModel.state,this.tracking=this.viewModel.tracking,this.geosceneComplete=s(()=>this.viewModel,"track"),this.geosceneError=s(()=>this.viewModel,"track-error"),this.geoscenePropertyChange=w()("state"),this.geosceneReady=g()}static{this.properties={autoDestroyDisabled:5,error:1,geolocationOptions:1,goToOverride:0,goToLocationDisabled:7,graphic:0,icon:1,label:1,messageOverrides:0,position:3,positionFilterFunction:0,referenceElement:1,rotationDisabled:5,scale:9,state:3,tracking:4}}static{this.shadowRootOptions=p}static{this.styles=$}async destroy(){await this.manager.destroy()}async start(){this.viewModel.start()}async stop(){this.viewModel.stop()}_localizeError(i){if(i instanceof GeolocationPositionError)return i.code===GeolocationPositionError.PERMISSION_DENIED?this.messages?.permissionError:i.code===GeolocationPositionError.TIMEOUT?this.messages?.timeoutError:this.messages?.positionUnavailable;if(i instanceof Error)return i.message}_toggleTracking(){if(!this.viewModel)return;let{state:i}=this.viewModel;if(!(i==="feature-unsupported"||i==="disabled")){if(i==="tracking"||i==="waiting"){this.viewModel.stop();return}this.viewModel.start()}}render(){let{viewModel:i,messages:n,icon:E}=this,t=i?.state,b=t==="tracking",l=this._localizeError(this.viewModel?.error),c=(b?n?.stopTracking:n?.startTracking)??"",k=t==="feature-unsupported",y=(t==="tracking"?"pause":void 0)??E??void 0;return o`<div class=${e(d(D.base,r.widget))}>${!k&&o`<calcite-button class=${e(r.widgetButton)} .disabled=${t==="disabled"} .iconStart=${y} kind=neutral .label=${c} .loading=${t==="waiting"} @click=${this._toggleTracking} title=${c??v}></calcite-button>`||""}${l?o`<calcite-tooltip open overlay-positioning=fixed .referenceElement=${this.el}>${l}</calcite-tooltip>`:null}</div>`}};u("geoscene-track",a);return a},"widgets/Track/TrackViewModel",a,b,c)