import { c as p } from "../../chunks/runtime.js";
import { html as a } from "lit";
import { watch as s } from "@arcgis/core/core/reactiveUtils.js";
import l from "@arcgis/core/views/MapView.js";
import v from "@arcgis/core/WebMap.js";
import { LitElement as m, createEvent as r, safeClassMap as h } from "@arcgis/lumina";
import { makeAccessorController as c, reEmitEvent as e, reCreateAccessor as d } from "@arcgis/lumina/controllers/accessor";
import { createRef as n, ref as o } from "lit/directives/ref.js";
import { s as g } from "../../chunks/esri-main.js";
import { s as y, C as w } from "../../chunks/slots.js";
import { c as u, i as f } from "../../chunks/component-utils.js";
import { U as V, u as b, a as C } from "../../chunks/useArcgisViewReadyError.js";
import E from "@arcgis/core/core/Collection.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 A = c(
  v,
  /**
   * Since omitProps is only needed for typing, not runtime, `{} as { ... }` is
   * a hack to remove them from the runtime code. This argument is not used at
   * all at runtime. For makeViewModelController and makeWidgetController, the
   * minifier is able to remove them automatically. However, minifier does not
   * remove them for makeAccessorController as makeAccessorController is defined
   * in an externalized package.
   */
  {}
), R = c(l, {});
class _ extends m {
  constructor() {
    super(), this._containerRef = n(), this._mapRef = n(), this._uiController = new V(this), this.extraContent = new E(), this.arcgisLoadError = b(this), this.arcgisViewReadyError = C(this), this._map = A(this), this.view = R(this), this.animationsDisabled = this.view.animationsEnabled, this.allLayerViews = this.view.allLayerViews, this.analyses = this.view.analyses, this.autoDestroyDisabled = !1, this.background = this.view.background, this.basemap = this._map.basemap, this.basemapView = this.view.basemapView, this.constraints = this.view.constraints, this.displayFilterDisabled = this.view.displayFilterEnabled, this.fatalError = this.view.fatalError, this.floors = this.view.floors, this.graphics = this.view.graphics, this.ground = this._map.ground, this.highlights = this.view.highlights, this.highlightOptions = this.view.highlightOptions, this.ipsInfo = this._map.ipsInfo, this.layerViews = this.view.layerViews, this.magnifier = this.view.magnifier, this.map = this.view.map, this.navigation = this.view.navigation, this.padding = this.view.padding, this.popup = this.view.popup, this.popupDisabled = this.view.popupEnabled, this.ready = this.view.ready, this.resizeAlign = this.view.resizeAlign, this.resolution = this.view.resolution, this.rotation = this.view.rotation, this.spatialReference = this.view.spatialReference, this.spatialReferenceLocked = this.view.spatialReferenceLocked, this.suspended = this.view.suspended, this.theme = this.view.theme, this.timeExtent = this.view.timeExtent, this.timeZone = this.view.timeZone, this.updating = this.view.updating, this.visibleArea = this.view.visibleArea, this.arcgisViewAnalysisViewCreate = e(() => this.view, "analysis-view-create"), this.arcgisViewAnalysisViewCreateError = e(() => this.view, "analysis-view-create-error"), this.arcgisViewAnalysisViewDestroy = e(() => this.view, "analysis-view-destroy"), this.arcgisViewChange = r(), this.arcgisViewClick = e(() => this.view, "click"), this.arcgisViewDoubleClick = e(() => this.view, "double-click"), this.arcgisViewDrag = e(() => this.view, "drag"), this.arcgisViewHold = e(() => this.view, "hold"), this.arcgisViewImmediateClick = e(() => this.view, "immediate-click"), this.arcgisViewImmediateDoubleClick = e(() => this.view, "immediate-double-click"), this.arcgisViewKeyDown = e(() => this.view, "key-down"), this.arcgisViewKeyUp = e(() => this.view, "key-up"), this.arcgisViewLayerviewCreate = e(() => this.view, "layerview-create"), this.arcgisViewLayerviewCreateError = e(() => this.view, "layerview-create-error"), this.arcgisViewLayerviewDestroy = e(() => this.view, "layerview-destroy"), this.arcgisViewMouseWheel = e(() => this.view, "mouse-wheel"), this.arcgisViewPointerDown = e(() => this.view, "pointer-down"), this.arcgisViewPointerEnter = e(() => this.view, "pointer-enter"), this.arcgisViewPointerLeave = e(() => this.view, "pointer-leave"), this.arcgisViewPointerMove = e(() => this.view, "pointer-move"), this.arcgisViewPointerUp = e(() => this.view, "pointer-up"), this.arcgisViewReadyChange = r(), this.view.ui = {
      components: ["attribution"]
    };
  }
  static {
    this.properties = { _map: 16, view: 32, animationsDisabled: 5, aria: 0, allLayerViews: 0, analyses: 0, autoDestroyDisabled: 5, background: 0, basemap: 1, basemapView: 0, center: 1, constraints: 0, displayFilterDisabled: 5, extent: 0, fatalError: 0, floors: 0, focusAreas: 0, gamepad: 32, graphics: 0, ground: 1, highlights: 0, highlightOptions: 0, interacting: 32, ipsInfo: 0, itemId: 3, layerViews: 0, magnifier: 0, map: 0, navigating: 32, navigation: 0, padding: 0, popup: 0, popupDisabled: 5, ready: 4, resizeAlign: 1, resolution: 8, rotation: 9, scale: 9, spatialReference: 0, spatialReferenceLocked: 5, stationary: 32, suspended: 7, theme: 0, timeExtent: 0, timeZone: 1, updating: 4, viewpoint: 0, visibleArea: 0, zoom: 9, loadErrorSources: 0 };
  }
  static {
    this.styles = [g, y];
  }
  get aria() {
    return this.view?.aria;
  }
  set aria(i) {
    this.view && (this.view.aria = i);
  }
  get center() {
    return this.view.center;
  }
  set center(i) {
    const t = u(i, this.view);
    t && (this.view.center = t);
  }
  get extent() {
    return this.view.extent;
  }
  set extent(i) {
    i && !this.extent?.equals(i) && (this.view.extent = i);
  }
  get focusAreas() {
    return this.map ? this.map.focusAreas : {
      areas: [],
      style: "bright"
    };
  }
  set focusAreas(i) {
    this.map && (this.map.focusAreas = i);
  }
  get gamepad() {
    return this.view.input.gamepad;
  }
  get interacting() {
    return this.view.interacting;
  }
  get itemId() {
    return this._map.portalItem?.id;
  }
  set itemId(i) {
    d(this._map, this), this._map.portalItem = { id: i }, this.view.map = this._map;
  }
  get navigating() {
    return this.view.navigating;
  }
  get scale() {
    return this.view.scale;
  }
  set scale(i) {
    this.view.scale = i;
  }
  get stationary() {
    return this.view.stationary;
  }
  get viewpoint() {
    return this.view.viewpoint;
  }
  set viewpoint(i) {
    f(this.viewpoint, i) && (this.view.viewpoint = i);
  }
  get zoom() {
    return this.view.zoom;
  }
  set zoom(i) {
    this.view.zoom = i;
  }
  async addLayer(i, t) {
    this.map?.add(i, t);
  }
  async addLayers(i, t) {
    this.map?.addMany(i, t);
  }
  async addTable(i) {
    this.map?.tables.add(i);
  }
  async addTables(i, t) {
    this.map?.tables.addMany(i, t);
  }
  async closePopup() {
    this._uiController.closePopup();
  }
  async destroy() {
    await this.manager.destroy();
  }
  async goTo(i, t) {
    return await this.view.goTo(i, t);
  }
  async hitTest(i, t) {
    return await this.view.hitTest(i, t);
  }
  async openPopup(i) {
    this._uiController.openPopup(i);
  }
  async takeScreenshot(i) {
    return await this.view.takeScreenshot(i);
  }
  toMap(i) {
    return this.view.toMap(i);
  }
  toScreen(i, t) {
    return this.view.toScreen(i, t);
  }
  async tryFatalErrorRecovery() {
    this.view.tryFatalErrorRecovery();
  }
  async viewOnReady(i, t) {
    return await this.componentOnReady(), await this.view.whenReady().then(() => i?.()).catch(t);
  }
  async whenAnalysisView(i) {
    return await this.view.whenAnalysisView(i);
  }
  async whenLayerView(i) {
    return await this.view?.whenLayerView(i);
  }
  loaded() {
    const i = this;
    i.el.childElem = this._mapRef.value, this.view.container ??= i.el.childElem, this.map ||= this._map, this.manager.onLifecycle(() => [
      s(() => this.map, (t) => {
        t && (this._map = t);
      }, { initial: !0, sync: !0 }),
      s(() => this.view.stationary, () => this.arcgisViewChange.emit(), { initial: !0 }),
      s(() => this.view.ready, () => this.arcgisViewReadyChange.emit(), { initial: this.view.ready })
    ]);
  }
  renderMain() {
    return a`<div class=${h(w.base)} ${o(this._mapRef)}></div>`;
  }
  render() {
    return a`<section class=${h(w.containerUI)} ${o(this._containerRef)}>${this._uiController.render()}${this.extraContent}</section>${this.renderMain()}`;
  }
}
p("arcgis-map", _);
export {
  _ as ArcgisMap
};
