/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
import { c as u } from "../../chunks/runtime.js";
import { css as o, html as l } from "lit";
import { E as i, a as c, c as p } from "../../chunks/pciUtils.js";
import { createRef as s, ref as n } from "lit-html/directives/ref.js";
import { LitElement as m, createEvent as y } from "@arcgis/lumina";
const d = o`:host{display:block;--calcite-label-margin-bottom: 0}.label-display{display:block;padding-bottom:1rem}`;
class v extends m {
  constructor() {
    super(...arguments), this._densityElement = s(), this._typeElement = s(), this._severityElement = s(), this._types = Object.keys(i).filter((e) => !Number.isNaN(Number(i[e]))), this.deductValueComplete = y();
  }
  static {
    this.styles = d;
  }
  render() {
    return l`<div class="label-display"><calcite-label class="label-display">\r\n            Density %${this._getDensityInput()}</calcite-label><calcite-label class="label-display">\r\n            Type${this._getTypeInput()}</calcite-label><calcite-label class="label-display">\r\n            Severity${this._getSeverityInput()}</calcite-label></div><div>${this._getCalculateInput()}</div>`;
  }
  _getDensityInput() {
    return l`<calcite-input max=100 min=0 type=number ${n(this._densityElement)}></calcite-input>`;
  }
  _getTypeInput() {
    return l`<calcite-select label=Type ${n(this._typeElement)}>${this._types.map((e, t) => l`<calcite-option .value=${i[e].toString()}>${`${e} (${t + 1})`}</calcite-option>`)}</calcite-select>`;
  }
  _getSeverityInput() {
    return l`<calcite-select label=Severity ${n(this._severityElement)}><calcite-option .value=${c.H}>\r\n          High</calcite-option><calcite-option .value=${c.M}>\r\n          Medium</calcite-option><calcite-option .value=${c.L}>\r\n          Low</calcite-option></calcite-select>`;
  }
  _getCalculateInput() {
    const e = this._typeElement.value && Number.parseFloat(this._typeElement.value.value), t = this._severityElement.value && this._severityElement.value.value, a = this._densityElement.value && Number.parseFloat(this._densityElement.value.value);
    return l`<calcite-button @click=${() => this._calculateDeduct(e, t, a)}>\r\n        Calculate Deduct Value</calcite-button>`;
  }
  _calculateDeduct(e, t, a) {
    if (e && t && !Number.isNaN(a)) {
      const r = p(e.toString(), t.toString(), a.toString(), !0);
      this.deductValueComplete.emit(r), alert(r);
    } else
      alert("Type, severity, and a density number are required");
  }
}
u("deduct-calculator", v);
export {
  v as DeductCalculator
};
