/* COPYRIGHT Esri - https://js.arcgis.com/1.2/LICENSE.txt */
import { c as n } from "../../chunks/runtime.js";
import { u as o } from "../../chunks/useT9n.js";
import { LitElement as s, createEvent as l, safeStyleMap as r } from "@arcgis/lumina";
import { useContextConsumer as a } from "@arcgis/lumina/context";
import { css as c, html as t, svg as d } from "lit";
import { A as h, G as p, J as g } from "../../chunks/interfaces.js";
import { createRef as u, ref as m } from "lit/directives/ref.js";
const v = c`calcite-shell-panel{z-index:var(--calcite-z-index-1)}.display-flex{display:flex}.flex-1,.flex-grow{flex:1}.flex-shrink-0{flex:0 0 auto}.leader-1{margin-top:var(--calcite-spacing-xxl)}.trailer-1{margin-bottom:var(--calcite-spacing-xxl)}.warning-text{max-width:35em;margin-left:auto;margin-right:auto;font-size:var(--calcite-font-size-md)}.text-center{text-align:center}.border-override{border-top-width:var(--calcite-border-width-none);border-bottom-width:var(--calcite-border-width-none)}.header-override{--calcite-panel-header-content-space: var(--calcite-spacing-none);--calcite-panel-header-background-color: var(--calcite-color-foreground-2)}.panel-override{--calcite-panel-background-color: var(--calcite-color-foreground-2);--calcite-panel-border-color: none}.label-override{--calcite-label-margin-bottom: var(--calcite-spacing-none);font-weight:var(--calcite-font-weight-medium)}.header-content-wrapper{padding-inline-start:var(--calcite-spacing-xxs)}.header-button-padding{padding-top:var(--calcite-spacing-sm);padding-bottom:var(--calcite-spacing-sm);padding-inline-start:var(--calcite-spacing-lg);padding-inline-end:var(--calcite-spacing-lg)}.padding-start{padding-inline-start:var(--calcite-spacing-lg)}.align-items-center{align-items:center}.justify-content-end{justify-content:end}.filter-width-350{--calcite-shell-panel-width: 350px}.z-index-2{z-index:2}.mock-fab{--calcite-fab-shadow-internal: 0 6px 20px -4px rgba(0, 0, 0, .1), 0 4px 12px -2px rgba(0, 0, 0, .08);box-shadow:var(--calcite-fab-shadow, var(--calcite-fab-shadow-internal));--calcite-button-background-color: var(--calcite-fab-background-color);--calcite-button-border-color: var(--calcite-fab-border-color);--calcite-button-text-color: var(--calcite-fab-text-color);--calcite-button-loader-color: var(--calcite-fab-loader-color)}.position-relative{position:relative}.height-100{height:100%}.height-50{height:50px}.sign-in-prompt{display:flex;flex-direction:column;justify-content:center;align-items:center;width:100%;height:100%}.sign-in-icon{transform:translate(-20px)}.height-150{height:150px}.width-150{width:150px}.padding-top-3{padding-top:3px}`;
class f extends s {
  constructor() {
    super(), this.solutionsCount = 0, this.filterOpen = !0, this.isMobile = !1, this._showAlertFailed = !1, this._translations = o({ name: "solutions-deployed-shell", blocking: !0 }), this._configContextConsumer = a({
      context: h,
      subscribe: !0
    }), this._deployedCardFetchFailedMessage = "", this._deployedCardFetchFailedTitle = "", this._isMobileContextConsumer = a({
      context: p,
      subscribe: !0,
      callback: (e) => this.isMobile = e
    }), this._solutionsDeployedPanelRef = u(), this.filterRemoved = l(), this.tokenRefreshed = l(), this._handleSignIn = () => {
      const e = window.location.pathname.endsWith("deployments") ? "" : "deployments";
      this._configContextConsumer.value?.authentication?.signIn(e);
    }, this.listenOn(window, "deployedCardFetchFailed", (e) => {
      const i = e.detail;
      this._deployedCardFetchFailedTitle = i.title, this._deployedCardFetchFailedMessage = i.message, this._showAlertFailed = !0;
    });
  }
  static {
    this.properties = { solutionsCount: 9, filterOpen: 16, isMobile: 16, _showAlertFailed: 16, _translations: 16 };
  }
  static {
    this.styles = v;
  }
  willUpdate(e) {
    e.has("isMobile") && (this.filterOpen = !this.isMobile);
  }
  async searchSolutions(e) {
    this._solutionsDeployedPanelRef.value?.setSearchOptions(e), ("sortType" in e || "searchTerm" in e) && this._solutionsDeployedPanelRef.value?.searchSolutions(e);
  }
  async load() {
    this._isMobileContextConsumer.value && (this.isMobile = this._isMobileContextConsumer.value);
  }
  render() {
    if (!this._configContextConsumer.value?.authentication?.IsSignedIn)
      return this._getSignInPrompt();
    const e = this.isMobile ? "justify-content-end" : "";
    return t`<calcite-shell class="position-relative"><calcite-panel class="border-override header-override panel-override z-index-1"><div class=${`display-flex align-items-center height-50 header-content-wrapper ${e}`} slot=header-content><calcite-label class="label-override flex-shrink-0 padding-top-3" layout=inline>${this._translations.numberOfDeployments?.replace("{{count}}", this.solutionsCount.toString())}</calcite-label></div>${this._getSolutionsDeployedPanel()}</calcite-panel></calcite-shell>`;
  }
  _getSignInPrompt() {
    return t`<div class="sign-in-prompt">${this._getSignInIcon()}<div class="text-center leader-1 warning-text trailer-1">${this._translations.signInMessage}</div><calcite-button appearance=outline @click=${this._handleSignIn} @keydown=${(e) => g(e, () => this._handleSignIn())} scale=l>${this._translations.signIn}</calcite-button></div>`;
  }
  _getSolutionsDeployedPanel() {
    const e = this.isMobile && this.filterOpen ? { display: "none" } : "";
    return t`<div><solutions-deployed-panel @deployedCardsFetched=${this._updateSolutionCount} style=${r(e)} ${m(this._solutionsDeployedPanelRef)}></solutions-deployed-panel><calcite-alert icon=exclamation-mark-triangle kind=danger .label=${this._deployedCardFetchFailedTitle} @calciteAlertClose=${() => {
      this._showAlertFailed = !1;
    }} .open=${this._showAlertFailed}><div slot=title>${this._deployedCardFetchFailedTitle}</div><div slot=message>${this._deployedCardFetchFailedMessage}</div></calcite-alert></div>`;
  }
  _updateSolutionCount(e) {
    this.solutionsCount = e.detail;
  }
  _getSignInIcon() {
    return t`<div class="sign-in-icon"><svg viewBox="0 0 64 64" width=200 height=200 xmlns=http://www.w3.org/2000/svg>${d`<path d="M56.9 4.1V60h-.8V4.9H23.3l25.6 7.47v39.26l-28.8 8.4V35h.8v23.97l27.2-7.94V12.97L20.9 5.03V30h-.8V4.1h36.8zM30.735 41.7l.565.566 9.766-9.766-9.766-9.766-.565.567 8.799 8.799H5v.8h34.534l-8.8 8.8z" fill=var(--calcite-color-text-3) />`}</svg></div>`;
  }
}
n("solutions-deployed-shell", f);
export {
  f as SolutionsDeployedShell
};
