/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
import { c as B } from "../../chunks/runtime.js";
import { css as H, html as d } from "lit";
import { LitElement as R, createEvent as F, nothing as D, safeClassMap as O, safeStyleMap as q } from "@arcgis/lumina";
import { usePropertyChange as Z } from "@arcgis/lumina/controllers";
import { createRef as X, ref as k } from "lit/directives/ref.js";
import { u as G } from "../../chunks/useT9n.js";
import { m as J } from "../../chunks/useViewModel.js";
import { H as K } from "../../chunks/heading.js";
import { b as N } from "../../chunks/async-utils.js";
import { g as M } from "../../chunks/globalCss.js";
import { V as h } from "../../chunks/visible-element.js";
import Q from "@arcgis/core/analysis/VolumeMeasurementAnalysis.js";
import { property as n, subclass as W } from "@arcgis/core/core/accessorSupport/decorators.js";
import { watch as Y } from "@arcgis/core/core/reactiveUtils.js";
import { A as ee } from "../../chunks/AnalysisViewModel.js";
import { g as ie, a as te, b as u, r as g, e as S, c as m, d as y, l as z, m as V } from "../../chunks/measurementUtils.js";
import { convertUnit as re } from "@arcgis/core/applications/Components/unitUtils.js";
const se = H`:host{--arcgis-internal-color-black-30: color-mix(in srgb, #000000 30.2%, transparent);--arcgis-internal-box-shadow: var(--calcite-spacing-none) var(--calcite-spacing-px) var(--calcite-spacing-base) var(--arcgis-internal-color-black-30);--arcgis-internal-top-max-width: calc(min(100cqw, 100vw) - var(--calcite-spacing-xxxl));--arcgis-internal-panel-width: 300px;--arcgis-internal-panel-height: 100%;--arcgis-internal-panel-height-sm: 240px;--arcgis-internal-panel-height-md: 420px;--arcgis-internal-panel-height-lg: 540px;--arcgis-internal-panel-height-xl: 680px;--arcgis-internal-panel-gap: var(--calcite-spacing-lg);--arcgis-internal-panel-actions-gap: var(--calcite-spacing-sm);--arcgis-internal-basemap-gallery-width-lg: 450px;--arcgis-internal-collapse-icon-flip: scaleX(1);--arcgis-internal-row-direction: row;--arcgis-internal-legend-width: 300px;--arcgis-internal-layout-overlay-space-top: var(--arcgis-layout-overlay-space-top, 0px);--arcgis-internal-layout-overlay-space-bottom: var(--arcgis-layout-overlay-space-bottom, 0px);--arcgis-internal-layout-overlay-space-left: var(--arcgis-layout-overlay-space-left, 0px);--arcgis-internal-layout-overlay-space-right: var(--arcgis-layout-overlay-space-right, 0px);--arcgis-internal-view-color-focus: var(--arcgis-view-color-focus, var(--calcite-color-brand));--arcgis-internal-attribution-space-bottom: var(--arcgis-internal-layout-overlay-space-bottom);--arcgis-internal-attribution-space-left: var(--arcgis-internal-layout-overlay-space-left);--arcgis-internal-attribution-space-right: var(--arcgis-internal-layout-overlay-space-right);--arcgis-internal-attribution-font-size: var(--calcite-font-size-sm);--arcgis-internal-attribution-font-size-sm: var(--calcite-font-size-xs);--arcgis-internal-sketch-justify-content: flex-start}.esri-widget__heading{color:var(--calcite-color-text-2);margin:0 0 .5rem;font-weight:var(--calcite-font-weight-semibold)}h1.esri-widget__heading{font-size:var(--calcite-font-size-xl)}h2.esri-widget__heading{font-size:var(--calcite-font-size-md)}h3.esri-widget__heading,h4.esri-widget__heading,h5.esri-widget__heading,h6.esri-widget__heading{font-size:var(--calcite-font-size)}.esri-widget{box-sizing:border-box;color:var(--calcite-color-text-2);background-color:var(--calcite-color-foreground-1);font-size:var(--calcite-font-size);line-height:var(--calcite-font-line-height-relative-tight)}.esri-widget *,.esri-widget :before,.esri-widget :after{box-sizing:inherit}.esri-widget.esri-widget--disabled>*{opacity:.4;pointer-events:none}.esri-widget.esri-widget--compact{--esri-widget-padding-y: 0;--esri-widget-padding-x: 0}.esri-widget__anchor{color:var(--calcite-color-text-2)}.esri-widget__anchor:hover{color:var(--calcite-color-text-3)}.esri-widget__anchor:hover,.esri-widget__anchor:focus{text-decoration:underline}.esri-widget__anchor--disabled{opacity:.4;pointer-events:none}.esri-widget__header{background-color:var(--calcite-color-foreground-1);flex:1 0 100%;justify-content:space-between;align-items:center;width:100%;min-height:48px;padding:12px 0 12px 15px;display:flex}.esri-widget__heading{word-break:break-word}.esri-widget__header .esri-widget__heading{width:calc(100% - 48px);text-align:initial;color:var(--calcite-color-text-1);align-items:center;margin:0;padding:0;display:flex}.esri-widget__header-button{appearance:none;cursor:pointer;color:var(--calcite-color-text-2);background-color:var(--calcite-color-foreground-1);border:none;flex:0 0 48px;justify-content:center;align-self:stretch;align-items:center;width:48px;padding:0;display:flex}.esri-widget__footer{background-color:var(--calcite-color-foreground-1);justify-content:center;align-items:center;width:100%;min-height:48px;display:flex}.esri-widget__footer-pagination{color:var(--calcite-color-text-2);justify-content:space-between;align-items:center;display:flex}.esri-widget__footer-pagination-previous-button,.esri-widget__footer-pagination-next-button{cursor:pointer;background-color:var(--calcite-color-foreground-1);border:0;margin:0 7px;padding:12px 15px;transition:background-color .125s ease-in-out}.esri-widget__footer-pagination-previous-button:hover,.esri-widget__footer-pagination-previous-button:focus,.esri-widget__footer-pagination-next-button:hover,.esri-widget__footer-pagination-next-button:focus{color:var(--calcite-color-text-1);background-color:var(--calcite-color-foreground-1)}.esri-menu{visibility:hidden;z-index:1;background-clip:padding;background-color:var(--calcite-color-foreground-1);background-clip:padding-box;width:100%;max-height:0;margin:2px 0 0;padding:0;font-size:var(--calcite-font-size);line-height:var(--calcite-spacing-xl);position:absolute;top:100%;left:0;overflow:hidden;box-shadow:0 1px 2px #0000004d}.esri-menu .esri-menu__header{color:var(--calcite-color-text-inverse);background-color:var(--calcite-color-inverse);padding:6px 12px}.esri-menu__list{margin:0;padding:0;list-style:none}.esri-menu__list-item{cursor:pointer;border-top:1px solid #adadad4d;border-left:3px solid #0000;padding:.8em 1em}.esri-menu__list-item [class^=esri-icon-],.esri-menu__list-item [class*=" esri-icon-"]{padding-right:2.8px}.esri-menu__list-item:first-child{border-top:none}.esri-menu__list-item--focus,.esri-menu__list-item:hover,.esri-menu__list-item:focus{background-color:var(--calcite-color-foreground-1)}.esri-menu__list-item:active{background-color:var(--calcite-color-foreground-current)}.esri-menu__list-item--active,.esri-menu__list-item--active:hover,.esri-menu__list-item--active:focus{background-color:var(--calcite-color-foreground-1);border-left-color:var(--calcite-color-brand)}.esri-widget__table{border-collapse:collapse;color:var(--calcite-color-text-1);border:none;width:100%;line-height:var(--calcite-font-line-height-relative-tight)}.esri-widget__table tr:nth-child(odd){background-color:var(--calcite-color-transparent)}.esri-widget__table tr:nth-child(2n){background-color:var(--calcite-color-transparent-press)}.esri-widget__table tr a{color:var(--calcite-color-text-2)}.esri-widget__table tr a:hover,.esri-widget__table tr a:focus{color:var(--calcite-color-text-1)}.esri-widget__table tr td,.esri-widget__table tr th{vertical-align:top;word-break:break-word;padding:.5em .7em;font-size:var(--calcite-font-size-sm);font-weight:var(--calcite-font-weight-regular)}.esri-widget__table tr th{text-align:left;border-right:3px solid #0000000d;width:50%}.esri-widget__table tr td{width:50%}.esri-input{color:var(--calcite-color-text-1);background-color:var(--calcite-color-foreground-1);border:1px solid #959595;font-size:var(--calcite-font-size)}.esri-input::-ms-clear{display:none}.esri-input::placeholder{opacity:1;color:var(--calcite-color-text-2)}.esri-input:placeholder-shown{text-overflow:ellipsis}.esri-input[type=text],.esri-input[type=password],.esri-input[type=number]{height:32px;padding:0 .5em}calcite-combobox.esri-input{border:none}.esri-widget__content--empty{text-align:center;color:var(--calcite-color-border-input);flex-flow:column wrap;align-items:center;padding:18px 22px;display:flex}.esri-widget__content--empty h1.esri-widget__heading,.esri-widget__content--empty h2.esri-widget__heading,.esri-widget__content--empty h3.esri-widget__heading,.esri-widget__content--empty h4.esri-widget__heading,.esri-widget__content--empty h5.esri-widget__heading{font-weight:var(--calcite-font-weight-regular)}.esri-widget__content-illustration--empty{width:128px;padding:1rem 0}.esri-widget__content-icon--empty{width:32px;padding:.5rem 0}.esri-select{appearance:none;cursor:pointer;color:var(--calcite-color-text-2);background:var(--calcite-color-foreground-1) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='-8 -8 32 32' width='32' height='32'%3E%3Cpath d='M8 11.207l-4-4V5.793l4 4 4-4v1.414z' fill='%23adadad' fillrule='nonzero'/%3E%3C/svg%3E") 100% no-repeat;border:1px solid #959595;border-radius:0;width:100%;height:32px;margin:0;padding:0 .5em;font-family:inherit;font-size:.85em;display:block}.esri-select[disabled]{cursor:auto}.esri-select::-ms-expand{display:none}.esri-disabled a,.esri-disabled [role=menu],.esri-disabled [role=checkbox],.esri-disabled [class^=esri-icon-],.esri-disabled [class*=" esri-icon-"]{color:var(--calcite-color-text-3)}.keynav-mode .esri-widget:focus,.keynav-mode .esri-widget :focus{z-index:1;outline-offset:2px;outline:2px solid #adadad}.esri-widget__loader-animation{border:.15em solid #adadad4d;border-top-color:var(--calcite-color-border-input);border-radius:100%;width:1em;height:1em;font-size:var(--calcite-font-size-md);animation:1.25s linear infinite esri-rotate;display:block;transform:translateZ(0)}:dir(rtl) .esri-widget__table th{text-align:right;border-left:3px solid #0000000d;border-right:none}:dir(rtl) .esri-select{background-position:0}:dir(rtl) .esri-menu__list-item{border-left:none;border-right:3px solid #0000}:dir(rtl) .esri-menu__list-item [class^=esri-icon-],:dir(rtl) .esri-menu__list-item [class*=" esri-icon-"]{padding-left:2px;padding-right:0}:dir(rtl) .esri-menu__list-item--active{border-right-color:var(--calcite-color-brand)}.esri-icon-font-fallback-text{clip:rect(0 0 0 0);width:1px;height:1px;position:absolute;overflow:hidden}.esri-rotating{animation:1.25s linear infinite esri-rotate;transform:translateZ(0)}.esri-clearfix:before,.esri-clearfix:after{content:" ";display:table}.esri-clearfix:after{clear:both}.esri-interactive{cursor:pointer}.esri-hidden{display:none!important}.esri-invisible{visibility:hidden!important}.esri-offscreen{position:absolute;top:-999em;left:-999em}.esri-match-height{flex-direction:column;flex:auto;display:flex;overflow:hidden}@supports (-ms-ime-align: auto){.esri-slider__anchor:focus{outline:1px dotted var(--calcite-color-foreground-current)}}.esri-slider{-webkit-user-select:none;user-select:none;direction:ltr;width:100%;height:100%;display:flex}.esri-disabled{pointer-events:none}.esri-disabled .esri-slider__content,.esri-disabled .esri-slider__min,.esri-disabled .esri-slider__max{opacity:var(--calcite-opacity-light)}.esri-slider--reversed.esri-slider--horizontal{flex-direction:row-reverse}.esri-slider--reversed.esri-slider--vertical{flex-direction:column}.esri-slider--horizontal{flex-direction:row}.esri-slider--horizontal .esri-slider__content{height:auto}.esri-slider--horizontal .esri-slider__track{width:100%;height:2px}.esri-slider--horizontal .esri-slider__segment--interactive:hover{cursor:ew-resize}.esri-slider--horizontal .esri-slider__anchor{width:1px;height:100%}.esri-slider--horizontal .esri-slider__label{text-align:center;margin:0 11px;top:-30px;left:-50px}.esri-slider--horizontal .esri-slider__label-input{text-align:center}.esri-slider--horizontal .esri-slider__max,.esri-slider--horizontal .esri-slider__min{flex:none;width:50px;height:auto;margin:auto}.esri-slider--horizontal .esri-slider__ticks{width:100%;margin:9px 0 0;top:100%;left:0}.esri-slider--horizontal .esri-slider__tick{width:1px;height:5px}.esri-slider--horizontal .esri-slider__tick-label{margin-top:18px}.esri-slider--vertical{flex-direction:column-reverse}.esri-slider--vertical .esri-slider__content{flex-direction:column;width:auto}.esri-slider--vertical .esri-slider__track{flex-direction:column;flex:1 0 0;width:2px;height:100%}.esri-slider--vertical .esri-slider__segment--interactive:hover{cursor:ns-resize}.esri-slider--vertical .esri-slider__anchor{width:100%;height:1px}.esri-slider--vertical .esri-slider__label{text-align:left;top:-10px;left:20px}.esri-slider--vertical .esri-slider__max,.esri-slider--vertical .esri-slider__min{flex:0 0 22px;width:100%;margin:auto}.esri-slider--vertical .esri-slider__ticks{margin:0 0 0 11px;top:0;left:100%}.esri-slider--vertical .esri-slider__tick{width:5px;height:1px}.esri-slider--vertical .esri-slider__tick-label{margin-left:30px}.esri-slider__content{z-index:0;flex:1 0 auto;justify-content:center;align-items:center;margin:auto;line-height:0;display:flex;position:relative}.esri-slider__track{touch-action:none;background-color:var(--calcite-color-border-ghost);display:inline-block;position:relative}.esri-slider__segment{transform-origin:0 0;will-change:transform;touch-action:none;width:100%;height:100%;position:absolute;top:0;left:0}.esri-slider__segment:hover{cursor:pointer}.esri-slider__anchor{touch-action:none;-webkit-user-select:none;user-select:none;background-color:var(--calcite-color-brand);position:absolute}.esri-slider__anchor:focus .esri-slider__thumb,.esri-slider__anchor:focus .esri-slider__label{outline:inherit}.esri-slider__anchor--moving:focus .esri-slider__thumb{cursor:grabbing;border:3px solid var(--calcite-color-brand-press)}.esri-slider__anchor--moving .esri-slider__label:hover,.esri-slider__anchor--moving .esri-slider__label--interactive:hover{cursor:grabbing}.esri-slider__thumb{box-sizing:border-box;z-index:1;touch-action:none;background-color:var(--calcite-color-foreground-2);border:2px solid var(--calcite-color-brand);border-radius:16px;width:16px;height:16px;transition:all .125s ease-in-out;position:absolute;top:-7px;left:-7px}.esri-slider__thumb:hover{cursor:grab;border-width:3px;border-color:var(--calcite-color-brand-press);width:19.2px;height:19.2px;top:-8.6px;left:-8.6px}.esri-slider__label{min-width:80px;line-height:var(--calcite-font-line-height-fixed-xl);position:absolute}.esri-slider__label:hover{cursor:grab}.esri-slider__label--interactive:hover,.esri-slider__max--interactive:hover,.esri-slider__min--interactive:hover{cursor:pointer;text-decoration:underline}.esri-slider__label-input{z-index:1;width:100%;position:relative}.esri-slider__extra-content{display:inline-block}.esri-slider__max,.esri-slider__min{text-align:center;justify-content:center;align-items:center;height:22px;line-height:var(--calcite-font-line-height-fixed-xl);display:flex}.esri-slider__max--interactive:hover,.esri-slider__min--interactive:hover{background-color:var(--calcite-color-foreground-2)}.esri-slider__range-input{text-align:center;width:100%;padding:1px 0}.esri-slider__ticks{z-index:0;height:100%;display:inline-block;position:absolute}.esri-slider__tick{background:var(--calcite-color-foreground-1);position:absolute}.esri-slider__tick-label{width:max-content;position:absolute}:dir(rtl) .esri-slider__label,:dir(rtl) .esri-slider__max,:dir(rtl) .esri-slider__min,:dir(rtl) .esri-slider__tick-label{direction:rtl;unicode-bidi:plaintext}:dir(rtl) .esri-slider__range-input,:dir(rtl) .esri-slider__label-input{unicode-bidi:plaintext}:host{width:300px;position:relative}.root{--calcite-label-margin-bottom: 0;padding:var(--arcgis-internal-padding)}.content{flex-direction:column;display:flex;gap:var(--arcgis-internal-panel-gap)}.header{display:flex;align-items:center;justify-content:space-between;margin-block-end:var(--calcite-spacing-sm);&.no-content{margin-block-end:calc(var(--calcite-spacing-sm) * -1)}}.heading{margin:0}.settings-content{display:flex;flex-direction:column;gap:var(--calcite-spacing-xxl);padding:var(--calcite-spacing-md);>div{display:flex;flex-direction:column;gap:var(--calcite-spacing-sm);>p{margin:0;font-size:var(--calcite-font-size-md)}}}.warning-title{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);border:0}`;
var ne = Object.defineProperty, ae = Object.getOwnPropertyDescriptor, s = (i, e, t, a) => {
  for (var o = a > 1 ? void 0 : a ? ae(e, t) : e, c = i.length - 1, p; c >= 0; c--)
    (p = i[c]) && (o = (a ? p(e, t, o) : p(o)) || o);
  return a && o && ne(e, t, o), o;
};
let r = class extends ee {
  constructor() {
    super(...arguments), this.supportedViewType = "3d", this.unsupportedErrorMessage = "The Volume Measurement component is only supported in 3D views.";
  }
  initialize() {
    this.addHandles([
      Y(
        () => ({
          analysis: this.analysis,
          volumeDisplayUnit: this._userVolumeDisplayUnit,
          elevationDisplayUnit: this._userElevationDisplayUnit,
          areaDisplayUnit: this._userAreaDisplayUnit,
          perimeterDisplayUnit: this._userPerimeterDisplayUnit,
          elevationInputUnit: this._userElevationInputUnit
        }),
        ({
          analysis: i,
          volumeDisplayUnit: e,
          elevationDisplayUnit: t,
          areaDisplayUnit: a,
          perimeterDisplayUnit: o,
          elevationInputUnit: c
        }) => {
          e && (i.displayUnits.volume = e), t && (i.displayUnits.elevation = t), a && (i.displayUnits.area = a), o && (i.displayUnits.length = o), c && (i.inputUnits.elevation = c);
        },
        { sync: !0, initial: !0 }
      )
    ]);
  }
  get _defaultElevationInputUnit() {
    return this.defaultMeasurementSystem === "metric" ? "meters" : "feet";
  }
  get state() {
    const { analysis: i, disabled: e, operationState: t, ready: a, supported: o } = this, { valid: c } = i;
    return ie({ supported: o, disabled: e, ready: a, operationState: t, valid: c });
  }
  get displayState() {
    return te(this.state, this.analysis.geometry != null);
  }
  get measurement() {
    const { analysisView: i } = this, e = i?.result, t = i?.error == null;
    return {
      mode: "euclidean",
      totalVolume: u(e?.totalVolume, t),
      cutVolume: u(e?.cutVolume, t),
      fillVolume: u(e?.fillVolume, t),
      netVolume: u(e?.netVolume, t),
      area: u(e?.area, t),
      perimeter: u(e?.perimeter, t)
    };
  }
  constructAnalysis() {
    return new Q();
  }
  async place(i) {
    await this.analysisView?.place(i);
  }
  clearAnalysis() {
    this.analysis.geometry = null;
  }
  get volumeDisplayUnitOptions() {
    return g(this._userVolumeUnitOptions, S, S);
  }
  set volumeDisplayUnitOptions(i) {
    this._userVolumeUnitOptions = i;
  }
  get volumeDisplayUnit() {
    const i = this.volumeDisplayUnitOptions;
    return m(
      this._userVolumeDisplayUnit,
      this.analysis.displayUnits?.volume,
      i,
      this.defaultMeasurementSystem
    );
  }
  set volumeDisplayUnit(i) {
    this._userVolumeDisplayUnit = i;
  }
  get elevationDisplayUnitOptions() {
    return g(this._userElevationDisplayUnitOptions, y, y);
  }
  set elevationDisplayUnitOptions(i) {
    this._userElevationDisplayUnitOptions = i;
  }
  get elevationDisplayUnit() {
    const i = this.elevationDisplayUnitOptions;
    return m(
      this._userElevationDisplayUnit,
      this.analysis.displayUnits?.elevation,
      i,
      this.defaultMeasurementSystem
    );
  }
  set elevationDisplayUnit(i) {
    this._userElevationDisplayUnit = i;
  }
  get elevationInputUnitOptions() {
    return g(this._userElevationInputUnitOptions, z, z);
  }
  set elevationInputUnitOptions(i) {
    this._userElevationInputUnitOptions = i;
  }
  get elevationInputUnit() {
    const i = this.elevationInputUnitOptions;
    return m(
      this._userElevationInputUnit,
      this.analysis.inputUnits?.elevation,
      i,
      this._defaultElevationInputUnit
    );
  }
  set elevationInputUnit(i) {
    const e = this.analysis.cutFillOptions.targetElevation ?? 0;
    this.analysis.cutFillOptions.targetElevation = re(
      e,
      this.elevationInputUnit,
      i ?? this.elevationInputUnit
    ), this._userElevationInputUnit = i;
  }
  get areaDisplayUnitOptions() {
    return g(this._userAreaUnitOptions, V, V);
  }
  set areaDisplayUnitOptions(i) {
    this._userAreaUnitOptions = i;
  }
  get areaDisplayUnit() {
    const i = this.areaDisplayUnitOptions;
    return m(
      this._userAreaDisplayUnit,
      this.analysis.displayUnits?.area,
      i,
      this.defaultMeasurementSystem
    );
  }
  set areaDisplayUnit(i) {
    this._userAreaDisplayUnit = i;
  }
  get perimeterDisplayUnitOptions() {
    return g(this._userPerimeterDisplayUnitOptions, y, y);
  }
  set perimeterDisplayUnitOptions(i) {
    this._userPerimeterDisplayUnitOptions = i;
  }
  get perimeterDisplayUnit() {
    const i = this.perimeterDisplayUnitOptions;
    return m(
      this._userPerimeterDisplayUnit,
      this.analysis.displayUnits?.length,
      i,
      this.defaultMeasurementSystem
    );
  }
  set perimeterDisplayUnit(i) {
    this._userPerimeterDisplayUnit = i;
  }
};
s([
  n()
], r.prototype, "_defaultElevationInputUnit", 1);
s([
  n()
], r.prototype, "state", 1);
s([
  n()
], r.prototype, "displayState", 1);
s([
  n({ readOnly: !0 })
], r.prototype, "measurement", 1);
s([
  n()
], r.prototype, "volumeDisplayUnitOptions", 1);
s([
  n()
], r.prototype, "volumeDisplayUnit", 1);
s([
  n()
], r.prototype, "_userVolumeDisplayUnit", 2);
s([
  n()
], r.prototype, "_userVolumeUnitOptions", 2);
s([
  n()
], r.prototype, "elevationDisplayUnitOptions", 1);
s([
  n()
], r.prototype, "elevationDisplayUnit", 1);
s([
  n()
], r.prototype, "_userElevationDisplayUnit", 2);
s([
  n()
], r.prototype, "_userElevationDisplayUnitOptions", 2);
s([
  n()
], r.prototype, "elevationInputUnitOptions", 1);
s([
  n()
], r.prototype, "elevationInputUnit", 1);
s([
  n()
], r.prototype, "_userElevationInputUnit", 2);
s([
  n()
], r.prototype, "_userElevationInputUnitOptions", 2);
s([
  n()
], r.prototype, "areaDisplayUnitOptions", 1);
s([
  n()
], r.prototype, "areaDisplayUnit", 1);
s([
  n()
], r.prototype, "_userAreaDisplayUnit", 2);
s([
  n()
], r.prototype, "_userAreaUnitOptions", 2);
s([
  n()
], r.prototype, "perimeterDisplayUnitOptions", 1);
s([
  n()
], r.prototype, "perimeterDisplayUnit", 1);
s([
  n()
], r.prototype, "_userPerimeterDisplayUnit", 2);
s([
  n()
], r.prototype, "_userPerimeterDisplayUnitOptions", 2);
r = s([
  W("components.volume-measurement.VolumeMeasurementViewModel")
], r);
const oe = J(r);
class le extends R {
  constructor() {
    super(...arguments), this.viewModel = oe(this), this.messages = G({ blocking: !0 }), this.#e = X(), this._settingsPopoverIsOpen = !1, this.view = this.viewModel.view, this.analysis = this.viewModel.analysis, this.autoDestroyDisabled = !1, this.icon = "measure-area", this.state = this.viewModel.state, this.volumeDisplayUnit = this.viewModel.volumeDisplayUnit, this.volumeDisplayUnitOptions = this.viewModel.volumeDisplayUnitOptions, this.elevationDisplayUnit = this.viewModel.elevationDisplayUnit, this.elevationDisplayUnitOptions = this.viewModel.elevationDisplayUnitOptions, this.elevationInputUnit = this.viewModel.elevationInputUnit, this.elevationInputUnitOptions = this.viewModel.elevationInputUnitOptions, this.areaDisplayUnit = this.viewModel.areaDisplayUnit, this.areaDisplayUnitOptions = this.viewModel.areaDisplayUnitOptions, this.perimeterDisplayUnit = this.viewModel.perimeterDisplayUnit, this.perimeterDisplayUnitOptions = this.viewModel.perimeterDisplayUnitOptions, this.hideHeader = !1, this.hideSettingsButton = !1, this.hideElevationDisplayUnitSelect = !1, this.hideElevationInputUnitSelect = !1, this.hideVolumeDisplayUnitSelect = !1, this.hideModeSelect = !1, this.hideStartButton = !1, this.hideVisualization = this.viewModel.hideVisualization, this.headingLevel = 2, this.hideAreaDisplayUnitSelect = !1, this.hidePerimeterDisplayUnitSelect = !1, this.arcgisPropertyChange = Z()("analysis", "state"), this.arcgisReady = F();
  }
  static {
    this.properties = { _settingsPopoverIsOpen: 16, view: 0, analysis: 0, autoDestroyDisabled: 5, icon: 3, label: 1, referenceElement: 1, mode: 1, state: 32, volumeDisplayUnit: 1, volumeDisplayUnitOptions: 0, elevationDisplayUnit: 1, elevationDisplayUnitOptions: 0, elevationInputUnit: 1, elevationInputUnitOptions: 0, areaDisplayUnit: 1, areaDisplayUnitOptions: 0, perimeterDisplayUnit: 1, perimeterDisplayUnitOptions: 0, hideHeader: 5, hideSettingsButton: 5, hideElevationDisplayUnitSelect: 5, hideElevationInputUnitSelect: 5, hideVolumeDisplayUnitSelect: 5, hideModeSelect: 5, hideStartButton: 5, hideVisualization: 5, headingLevel: 9, hideAreaDisplayUnitSelect: 5, hidePerimeterDisplayUnitSelect: 5 };
  }
  static {
    this.styles = se;
  }
  #e;
  #i(e) {
    e && queueMicrotask(() => {
      this.isConnected && (e.referenceElement = this.#e.value);
    });
  }
  get mode() {
    return this.viewModel.analysis.measureType;
  }
  set mode(e) {
    this.viewModel.analysis.measureType = e;
  }
  async clear() {
    this.viewModel.clear();
  }
  async destroy() {
    await this.manager.destroy();
  }
  async start() {
    N(this.viewModel.start());
  }
  _onSettingsPopoverClose() {
    this._settingsPopoverIsOpen = !1;
  }
  _onSettingsPopoverOpen() {
    this._settingsPopoverIsOpen = !0;
  }
  render() {
    const { messages: e, viewModel: t } = this, { measurement: a, state: o } = t, c = this.volumeDisplayUnitOptions, p = this.volumeDisplayUnit, _ = this.elevationDisplayUnitOptions, $ = this.elevationDisplayUnit, I = this.elevationInputUnitOptions, E = this.elevationInputUnit, P = this.perimeterDisplayUnitOptions, C = this.perimeterDisplayUnit, A = this.areaDisplayUnitOptions, L = this.areaDisplayUnit, U = t.analysisView?.error?.name, T = [
      v({ hidden: this.hideElevationInputUnitSelect, options: I, selectLabel: e.elevationInputUnit, value: E, onChange: (l) => {
        this.viewModel.elevationInputUnit = l;
      } })
    ], j = [
      v({ hidden: this.hideElevationDisplayUnitSelect, options: _, selectLabel: e.elevationDisplayUnit, value: $, onChange: (l) => {
        this.analysis.displayUnits.elevation = l;
      } }),
      v({ hidden: this.hideVolumeDisplayUnitSelect, options: c, selectLabel: e.volumeDisplayUnit, value: p, onChange: (l) => {
        this.viewModel.volumeDisplayUnit = l;
      } }),
      v({ hidden: this.hideAreaDisplayUnitSelect, options: A, selectLabel: e.areaDisplayUnit, value: L, onChange: (l) => {
        this.viewModel.areaDisplayUnit = l;
      } }),
      v({ hidden: this.hidePerimeterDisplayUnitSelect, options: P, selectLabel: e.perimeterDisplayUnit, value: C, onChange: (l) => {
        this.viewModel.perimeterDisplayUnit = l;
      } })
    ], f = [this.hideElevationInputUnitSelect].filter((l) => !l).length === 0, b = [
      this.hideElevationDisplayUnitSelect,
      this.hideVolumeDisplayUnitSelect,
      this.hideAreaDisplayUnitSelect,
      this.hidePerimeterDisplayUnitSelect
    ].filter((l) => !l).length === 0, x = this.hideSettingsButton || f && b, w = (this._settingsPopoverIsOpen ? e.hideSettings : e.showSettings) ?? "";
    return d`<div aria-label=${e.componentLabel ?? D} class=${O({
      root: !0,
      [M.widget]: !0,
      [M.panel]: !0
    })} role=presentation>${o === "disabled" && d`<calcite-scrim></calcite-scrim>` || ""}${h({ hidden: this.hideHeader && x, children: d`<div class=${O({
      header: !0,
      "no-content": this.hideHeader
    })}>${h({ hidden: this.hideHeader, children: K({ class: "heading", level: this.headingLevel, children: e.title }) })}<span style=${q({ flex: 1 })}></span>${h({ hidden: x, children: d`<calcite-action icon=gear slot=settings .text=${w} title=${w ?? D} ${k(this.#e)}></calcite-action><calcite-popover slot=settings .label=${w} .referenceElement=${this.#e.value} overlay-positioning=fixed placement=bottom-end auto-close .open=${x ? !1 : void 0} @calcitePopoverOpen=${this._onSettingsPopoverOpen} @calcitePopoverClose=${this._onSettingsPopoverClose} ${k(this.#i)}><div class="settings-content">${h({ hidden: f, children: d`<div><p .hidden=${b}>${e.inputUnits}</p>${T}</div>` })}${h({ hidden: b, children: d`<div><p .hidden=${f}>${e.displayUnits}</p>${j}</div>` })}</div></calcite-popover>` })}</div>` })}<div class="content">${h({ hidden: this.hideModeSelect, children: d`<calcite-label>${this.messages.measurementMode}<calcite-select label="Select measurement mode" .value=${this.mode} @calciteSelectChange=${(l) => {
      this.analysis.measureType = l.target.selectedOption.value;
    }}><calcite-option value=cut-fill>${e.cutAndFillMode}</calcite-option><calcite-option value=stockpile>${e.stockpileMode}</calcite-option></calcite-select></calcite-label>` })}${U != null && ce({ error: U, messages: e }) || ""}<arcgis-measurement-content .state=${t.displayState} .hintLabel=${e.hint} .unsupportedLabel=${e.unsupported} .items=${[
      {
        title: e.cutVolume,
        measurement: a.cutVolume
      },
      {
        title: e.fillVolume,
        measurement: a.fillVolume
      },
      {
        title: e.netVolume,
        measurement: a.netVolume
      },
      {
        title: e.area,
        measurement: a.area
      },
      {
        title: e.perimeter,
        measurement: a.perimeter
      }
    ]}>${h({ hidden: this.hideStartButton, children: d`<calcite-button slot=actions width=full .disabled=${o === "disabled"} @click=${() => {
      this.viewModel.start({ clear: !0 });
    }}>${e.newMeasurement}</calcite-button>` })}</arcgis-measurement-content></div></div>`;
  }
}
function v(i) {
  const { hidden: e, options: t, selectLabel: a, value: o, onChange: c } = i;
  return e ? null : d`<arcgis-unit-select layout=inline-space-between .options=${t} .selectLabel=${a} .value=${o} @arcgisUnitSelectChange=${(p) => {
    const _ = p.detail;
    t.includes(_) && c(_);
  }}></arcgis-unit-select>`;
}
function ce(i) {
  let e;
  const { messages: t, error: a } = i;
  switch (a) {
    case "insufficient-data":
      e = t.errorInsufficientData;
      break;
    case "perimeter-too-large":
      e = t.errorPerimeterTooLarge;
      break;
    case "unsupported-coordinate-system":
      e = t.errorUnsupportedCoordinateSystem;
      break;
    case "unsupported-layer-transparency":
      e = t.errorUnsupportedLayerTransparency;
      break;
    default:
      e = t.errorUnknown;
      break;
  }
  return d`<calcite-notice aria-live=polite open icon=exclamation-mark-triangle-f kind=warning><div slot=title class="warning-title">${e}</div><div slot=message>${e}</div></calcite-notice>`;
}
B("arcgis-volume-measurement", le);
export {
  le as ArcgisVolumeMeasurement
};
