import { c as f } from "../../chunks/runtime.js";
import { html as l } from "lit-html";
import { usePropertyChange as m } from "@arcgis/lumina/controllers";
import { LitElement as y, createEvent as v, noShadowRoot as _, safeClassMap as n } from "@arcgis/lumina";
import { css as w } from "@lit/reactive-element/css-tag.js";
import { g } from "../../chunks/globalCss.js";
import { u as $ } from "../../chunks/useT9n.js";
import { m as b } from "../../chunks/useViewModel.js";
import { A as M } from "../../chunks/AnalysisViewModel.js";
import x from "@geoscene/core/analysis/LineOfSightAnalysis.js";
import { property as O, subclass as A } from "@geoscene/core/core/accessorSupport/decorators.js";
/*! 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 */
const C = w`@layer{geoscene-line-of-sight{display:block}.geoscene-line-of-sight__container{display:flex;position:relative;flex-flow:column;gap:var(--calcite-spacing-md);padding:var(--geoscene-widget-padding);overflow-y:auto}.geoscene-line-of-sight__error{color:var(--calcite-color-status-danger)}.geoscene-line-of-sight__hint{display:flex;flex-direction:column;gap:var(--calcite-spacing-md)}.geoscene-line-of-sight__error,.geoscene-line-of-sight__hint{overflow:hidden;animation:geoscene-line-of-sight-fade-in .25s ease-in-out;p{margin:0;padding:0}}.geoscene-line-of-sight__actions{display:flex;flex-flow:column;gap:var(--calcite-spacing-xxs);justify-content:center}@keyframes geoscene-line-of-sight-fade-in{0%{opacity:0}25%{opacity:0}to{opacity:1}}}`, a = "geoscene-line-of-sight", r = {
  base: a,
  actions: `${a}__actions`,
  container: `${a}__container`,
  error: `${a}__error`,
  hint: `${a}__hint`,
  hintText: `${a}__hint-text`,
  newAnalysisButton: `${a}__new-analysis-button`
};
var S = Object.defineProperty, D = Object.getOwnPropertyDescriptor, u = (t, e, i, o) => {
  for (var s = o > 1 ? void 0 : o ? D(e, i) : e, d = t.length - 1, h; d >= 0; d--)
    (h = t[d]) && (s = (o ? h(e, i, s) : h(s)) || s);
  return o && s && S(e, i, s), s;
};
let c = class extends M {
  constructor() {
    super(...arguments), this.supportedViewType = "3d", this.unsupportedErrorMessage = "The Line Of Sight component is only supported in 3D views.";
  }
  get state() {
    return this.disabled || !this.ready ? "disabled" : this.operationState === "active" ? "creating" : this.analysis.valid ? "created" : "ready";
  }
  constructAnalysis() {
    return new x();
  }
  clearAnalysis() {
    this.analysis.observer = null, this.analysis.targets.removeAll();
  }
  async place(t) {
    await this.analysisView?.place(t);
  }
};
u([
  O({ readOnly: !0 })
], c.prototype, "state", 1);
c = u([
  A("geoscene.components.LineOfSight.LineOfSightViewModel")
], c);
const L = b(c);
class V extends y {
  constructor() {
    super(...arguments), this.viewModel = L(this), this._messages = $({ blocking: !0 }), this.view = this.viewModel.view, this.analysis = this.viewModel.analysis, this.autoDestroyDisabled = !1, this.icon = "line-of-sight", this.position = "bottom-left", this.geoscenePropertyChange = m()("analysis", "state"), this.geosceneReady = v();
  }
  static {
    this.properties = { analysis: 0, autoDestroyDisabled: 5, icon: 3, label: 1, messageOverrides: 0, position: 1, referenceElement: 1, state: 35, _supported: 16 };
  }
  static {
    this.shadowRootOptions = _;
  }
  static {
    this.styles = C;
  }
  get state() {
    return this.viewModel.state;
  }
  get _supported() {
    return this.view == null || this.view.type === "3d";
  }
  async clear() {
    this.viewModel.clear();
  }
  async continue() {
    this.viewModel.start();
  }
  async destroy() {
    await this.manager.destroy();
  }
  async start() {
    this.viewModel.startNewAnalysis();
  }
  async stop() {
    this.viewModel.stop();
  }
  render() {
    return l`<div class=${n({
      [r.base]: !0,
      [g.widget]: !0,
      [g.panel]: !0
    })} role=presentation>${this._renderContainerNode()}</div>`;
  }
  _renderContainerNode() {
    if (!this._supported)
      return l`<div class=${n(r.error)}><p>${this._messages.unsupported}</p></div>`;
    const e = this.viewModel.state, i = e === "creating";
    return l`<div class=${n(r.container)}>${i ? l`<div class=${n(r.hint)}><p class=${n(r.hintText)}>${this._messages.hint}</p></div>` : null}<div class=${n(r.actions)}>${e === "creating" ? p({ onClick: () => {
      this.stop();
    }, children: this._messages.done }) : null}${e === "created" ? p({ onClick: () => {
      this.continue();
    }, children: this._messages.continueAnalysis }) : null}${p({ className: r.newAnalysisButton, onClick: () => {
      this.start();
    }, primary: !0, disabled: e === "disabled", children: this._messages.newAnalysis })}</div></div>`;
  }
}
function p({ className: t, onClick: e, primary: i, disabled: o, children: s }) {
  return l`<calcite-button .appearance=${i ? "solid" : "outline-fill"} class=${n(t)} .disabled=${o} @click=${e}>${s}</calcite-button>`;
}
f("geoscene-line-of-sight", V);
export {
  V as GeosceneLineOfSight
};