import { c as h } from "../../chunks/runtime.js";
import { css as g, html as b } from "lit";
import { classes as s } from "@arcgis/toolkit/dom";
import { ignoreAbortErrors as l } from "@arcgis/core/core/promiseUtils.js";
import { when as y } from "@arcgis/core/core/reactiveUtils.js";
import { LitElement as z, createEvent as p, safeClassMap as i, nothing as m } from "@arcgis/lumina";
import { usePropertyChange as v } from "@arcgis/lumina/controllers";
import { u as x } from "../../chunks/useT9n.js";
import { u as $ } from "../../chunks/useView.js";
/*! All material copyright Esri, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
v4.34.7 */
const r = {
  base: "arcgis-zoom",
  button: "arcgis-button",
  horizontalLayout: "arcgis-zoom--horizontal",
  zoomIn: "arcgis-zoom__zoom-in",
  zoomOut: "arcgis-zoom__zoom-out"
};
function u(t) {
  if (!t)
    return !1;
  if (t.type === "3d")
    return t.ready;
  if (!t?.ready)
    return !1;
  const e = f(t), a = t.constraints?.effectiveMaxScale;
  return a === 0 || e > a;
}
function d(t) {
  if (!t)
    return !1;
  if (t.type === "3d")
    return t.ready;
  if (!t?.ready)
    return !1;
  const e = f(t), a = t.constraints?.effectiveMinScale;
  return a === 0 || e < a;
}
function f(t) {
  const o = t?.animation?.target;
  return (o && "then" in o ? void 0 : o?.scale) ?? t?.scale ?? 0;
}
const E = g`.arcgis-button{--calcite-icon-color: var(--calcite-color-text-3);--calcite-button-background-color: var(--calcite-color-foreground-1);color:var(--calcite-color-text-3);line-height:var(--calcite-font-line-height-relative-tight);display:flex;flex-flow:column;cursor:pointer;background-color:var(--calcite-color-foreground-1);font-size:var(--calcite-font-size);:hover{--calcite-icon-color: var(--calcite-color-text-1);--calcite-button-background-color: var(--calcite-color-transparent-hover)}calcite-button{width:var(--calcite-spacing-xxxl);height:var(--calcite-spacing-xxxl)}}:host{display:flex;max-width:fit-content}.arcgis-zoom__zoom-out{border-block-start:solid 1px var(--calcite-color-border-1)}.arcgis-zoom--horizontal{flex-flow:row-reverse nowrap}.arcgis-zoom--horizontal .arcgis-zoom__zoom-out{border-block-start:none;border-inline-end:solid 1px var(--calcite-color-border-1)}`;
class O extends z {
  constructor() {
    super(...arguments), this.messages = x({}), this.view = $(this), this.autoDestroyDisabled = !1, this.icon = "magnifying-glass-plus", this.layout = "vertical", this.state = "disabled", this.arcgisPropertyChange = v()("state"), this.arcgisReady = p();
  }
  static {
    this.properties = { view: 0, autoDestroyDisabled: 5, icon: 1, label: 1, layout: 3, messageOverrides: 0, position: 1, referenceElement: 1, state: 3 };
  }
  static {
    this.styles = E;
  }
  async destroy() {
    await this.manager.destroy();
  }
  async zoomIn() {
    const { view: o } = this;
    !u(o) || !o || (o.type === "2d" ? o.mapViewNavigation.zoomIn() : l(o.goTo({ zoomFactor: 2 })));
  }
  async zoomOut() {
    const { view: o } = this;
    !d(o) || !o || (o.type === "2d" ? o.mapViewNavigation.zoomOut() : l(o.goTo({ zoomFactor: 0.5 })));
  }
  loaded() {
    this.manager.onLifecycle(() => [
      y(() => this.view?.ready ? "ready" : "disabled", (o) => {
        this.state = o;
      }, { sync: !0, initial: !0 })
    ]);
  }
  render() {
    const o = {
      [r.horizontalLayout]: this.layout === "horizontal"
    }, e = u(this.view), a = d(this.view), { zoomIn: c, zoomOut: n } = this.messages;
    return b`<div class=${i(s(r.base, r.button, o))}><calcite-button class=${i(s(r.zoomIn))} .disabled=${!e} icon-start=plus kind=neutral .label=${c} @click=${this.zoomIn} title=${c ?? m}></calcite-button><calcite-button class=${i(s(r.zoomOut))} .disabled=${!a} icon-start=minus kind=neutral .label=${n} @click=${this.zoomOut} title=${n ?? m}></calcite-button></div>`;
  }
}
h("arcgis-zoom", O);
export {
  O as ArcgisZoom
};
