/* COPYRIGHT Esri - https://js.arcgis.com/1.2/LICENSE.txt */
import { c as S } from "../../chunks/runtime.js";
import { css as k, html as l } from "lit";
import { u as E } from "../../chunks/useT9n.js";
import { createRef as d, ref as h } from "lit-html/directives/ref.js";
import { LitElement as C, createEvent as f, safeClassMap as u, nothing as y, safeStyleMap as R } from "@arcgis/lumina";
import { useContextConsumer as M } from "@arcgis/lumina/context";
import { c as T } from "../../chunks/deployAppContexts.js";
import { request as L, getWorkflowBaseURL as A, getWorkflowManagerAuthorized as D, sanitizeHTML as _, getItemDataAsJson as P, getItem as O, getPropWithDefault as w, getProp as v, setCreateProp as U } from "@esri/solution-common";
import { E as m, f as x, T as g, y as N, z as H } from "../../chunks/interfaces.js";
import { _findExistingItem as F } from "@esri/solution-deployer";
import { k as V, l as b, m as z } from "../../chunks/helpers.js";
import { a as $, g as Y } from "../../chunks/common.js";
import "../../chunks/solution-deploy-dialog.js";
import "../solution-snapshot-gallery/customElement.js";
import "../solution-deploying-dialog/customElement.js";
const B = k`.display-flex{display:flex}.flex-direction-row{flex-direction:row}.flex-direction-column{flex-direction:column}.flex-1{flex:1}.cursor-default{cursor:default}solution-details-card[id*=you-may-also-like]{width:240px}.border-bottom{border-bottom-color:var(--calcite-color-border-1);border-bottom-width:var(--calcite-spacing-px);border-bottom-style:solid}ul{list-style-type:disc;margin-block-start:var(--calcite-spacing-none);margin-block-end:var(--calcite-spacing-none)}ul ul{list-style-type:circle}li{margin:var(--calcite-spacing-sm) var(--calcite-spacing-none)}calcite-label{--calcite-label-margin-bottom: var(--calcite-spacing-none)}.padding-1{padding:var(--calcite-spacing-lg)}.padding-1-5{padding:var(--calcite-spacing-xl)}.padding-2px{padding:var(--calcite-spacing-base)}.padding-bottom-xxl{padding-bottom:var(--calcite-spacing-xxl)}.padding-bottom-1{padding-bottom:var(--calcite-spacing-lg)}.padding-bottom-sm{padding-bottom:var(--calcite-spacing-sm)}.padding-top-md{padding-top:var(--calcite-spacing-md)}.padding-top-sm{padding-top:var(--calcite-spacing-sm)}.padding-top-xs{padding-top:.25rem}.padding-bottom-1-5{padding-bottom:var(--calcite-spacing-xxl)}.padding-top-1{padding-top:var(--calcite-spacing-lg)}.padding-top-1-5{padding-top:var(--calcite-spacing-xxl)}.padding-top-1-2{padding-top:var(--calcite-spacing-sm)}.padding-end-1{padding-inline-end:var(--calcite-spacing-lg)}.padding-end-1-75{padding-inline-end:1.75rem}.padding-end-2{padding-inline-end:var(--calcite-spacing-xxxl)}.padding-start-1{padding-inline-start:var(--calcite-spacing-lg)}.margin-bottom-1{margin-bottom:var(--calcite-spacing-lg)}.margin-bottom-1-5{margin-bottom:var(--calcite-spacing-xxl)}.margin-end-1{margin-inline-end:var(--calcite-spacing-lg)}.margin-top-0{margin-top:var(--calcite-spacing-none)}.margin-top-1{margin-top:var(--calcite-spacing-lg)}.margin-top-875{margin-top:.875rem}.margin-top-1-5{margin-top:var(--calcite-spacing-xxl)}.margin-sides-0-5{margin-left:var(--calcite-spacing-sm);margin-right:var(--calcite-spacing-sm)}.margin-sides-1{margin-left:var(--calcite-spacing-lg);margin-right:var(--calcite-spacing-lg)}.margin-block-start-end-0{margin-block-start:var(--calcite-spacing-none);margin-block-end:var(--calcite-spacing-none)}.align-self-center{align-self:center;padding:5px;--calcite-fab-shadow: #FFFFFF00}.align-items-center{align-items:center}.align-items-baseline{align-items:baseline}.button-width{width:260px;flex-grow:0;flex-shrink:0}@media(max-width:1280px){.button-width{width:auto}}.image-width{width:300px;flex-grow:0;flex-shrink:0}@media(max-width:1280px){.image-width{flex-grow:0;flex-shrink:1}}.width-full{width:100%}@media(max-width:768px){.width-full{flex-direction:column}.width-full>.display-flex{flex-direction:column}.image-width{width:100%;padding-inline-end:0;margin-bottom:var(--calcite-spacing-lg)}.button-width{width:100%;margin-top:var(--calcite-spacing-lg)}}.card-group{overflow:hidden}calcite-card{width:450px;--calcite-card-border-color: transparent}@media(max-width:1496px){calcite-card{width:calc(100% / 3 - .5rem)}}@media(max-width:1100px){calcite-card{width:calc(50% - .5rem)}}@media(max-width:550px){calcite-card{width:100%}}.max-height-300{max-height:300px}.display-none{display:none}.cursor-pointer{cursor:pointer}calcite-card:hover img{-webkit-filter:brightness(30%);filter:brightness(30%);-webkit-transition:all .1s ease;-moz-transition:all .1s ease;-o-transition:all .1s ease;-ms-transition:all .1s ease;transition:all .1s ease}calcite-card:hover .hover-text{opacity:1;color:#fff}calcite-card:hover{border:var(--calcite-spacing-base) solid var(--calcite-color-brand);box-sizing:border-box;cursor:pointer;padding:var(--calcite-spacing-base)}.hover-text{transition:.1s ease;opacity:0;position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);-ms-transform:translate(-50%,-50%);text-align:center;display:flex;flex-direction:row;align-items:center;height:100%;font-size:var(--calcite-spacing-xl)}.card-image-wrap{width:100%;position:relative;margin-bottom:0;-webkit-box-flex:0 0 auto;-ms-flex:0 0 auto;flex:0 0 auto}.card-image{width:100%;display:block}video,img{max-width:100%;height:auto}img{overflow-clip-margin:content-box;overflow:clip;display:block}.margin-inline-unset{margin-inline:unset}.collapsible-div{overflow:hidden;transition:max-height .3s ease-in-out}.collapsible-div.expanded{max-height:100%}.back-color-override{--calcite-panel-background-color: var(--calcite-color-foreground-2)}.back-color-override-1{background-color:var(--calcite-color-foreground-1)}.title-font{font-size:1.8rem;font-weight:var(--calcite-font-weight-medium);color:var(--calcite-color-text-1)}.heading-font{font-size:var(--calcite-font-size-0);font-weight:var(--calcite-font-weight-medium)}.line-height-xxl{line-height:var(--calcite-spacing-xxl)}.line-height-1{line-height:1.1}.font-1{font-size:var(--calcite-spacing-lg)}.font-color-1{color:var(--calcite-color-text-1)}.font-color-2{color:var(--calcite-color-text-2)}h1{font-weight:unset;margin:var(--calcite-spacing-none);padding:var(--calcite-spacing-none)}.item-padding{--calcite-internal-accordion-item-padding: var(--calcite-spacing-xl)}.accordion-bg{--calcite-accordion-background-color: var(--calcite-color-foreground-1)}.table-cell{font-size:var(--calcite-spacing-lg);color:var(--calcite-color-text-2);margin:0}.table-cell p{margin:0}calcite-table-header{font-weight:var(--calcite-font-weight-medium);--calcite-internal-table-cell-font-size: var(--calcite-font-size-md)}.position-relative{position:relative}.background-color-2{background-color:var(--calcite-color-foreground-2)}.panel-background-2{--calcite-panel-background-color: var(--calcite-color-foreground-2);background-color:var(--calcite-color-foreground-2)}.border-none{border:none}.padding-end-xxl{padding-inline-end:var(--calcite-spacing-xxl)}calcite-shell{block-size:unset}.solution-detail-action{--calcite-color-focus: initial}a{color:var(--calcite-link-text-color, var(--calcite-color-text-link));cursor:pointer;text-decoration:none;line-height:inherit;background-image:linear-gradient(currentColor,currentColor),linear-gradient(var(--calcite-color-brand-underline),var(--calcite-color-brand-underline));background-position-x:0%,100%;background-position-y:min(1.5em,100%);background-repeat:no-repeat,no-repeat;background-size:0% 1px,100% 1px;transition-property:background-size,color;transition-duration:var(--calcite-animation-timing, .15s);transition-timing-function:ease-in-out;outline-color:transparent;position:relative}a:hover{background-size:100% 1px,100% 1px}a:focus{outline:2px solid var(--calcite-color-brand);outline-offset:2px;outline-color:var(--calcite-color-brand)}a:active{color:var(--calcite-color-brand-press)}`;
async function G(n, e, t) {
  let i = t;
  return n && (n?.IsEnterprisePortal && await j(
    "",
    // the portal url
    e
  ) && i.push(m.NOTEBOOK), await V(e) ? t.push(m.VELOCITY) : n?.PortalUserPrivileges && [
    x.VELOCITYFEEDS,
    x.VELOCITYBIGDATA,
    x.VELOCITYREALTIME
  ].forEach((o) => {
    const c = t.indexOf(o) || -1;
    c !== -1 && t.splice(c, 1);
  }), i = i.concat(
    K(
      J(n),
      Q(n)
    )
  ), i = i.concat(q(n)), i = i.concat(await W(n))), Promise.resolve(i);
}
function K(n, e) {
  let t = [];
  return n && e ? t = [
    m.TRACKINGADMINANDTRACKING,
    m.TRACKINGADMIN,
    m.TRACKING
  ] : n && !e ? t = [m.TRACKINGADMIN] : !n && e && (t = [m.TRACKING]), t;
}
function q(n) {
  return X(
    n
  ) ? [m.HUBPREMIUM] : [];
}
async function W(n) {
  const e = await A(n?.RestUserSession);
  return await D(
    e,
    n?.RestUserSession
  ) ? [m.WORKFLOW] : [];
}
async function j(n, e) {
  const t = n + "/sharing/rest", i = {
    authentication: e,
    portal: t,
    params: {
      f: "json"
    }
  };
  return L(`${t}/portals/self/servers`, i).then((s) => s?.servers?.find((a) => a.serverFunction.indexOf("NotebookServer") > -1), (s) => (console.error(s), !1));
}
function J(n) {
  const e = n?.PortalUserSubset;
  return e?.role === "org_admin" && !e?.hasOwnProperty("roleId");
}
function Q(n) {
  return n?.PortalSubset?.locationTrackingEnabled || !1;
}
function X(n) {
  return n?.PortalSubset?.hubPremiumEnabled || !1;
}
class Z extends C {
  constructor() {
    super(), this._showScreenshotsShowMore = !1, this._showYouMayAlsoLikeShowMore = !1, this._isScreenshotsRowExpanded = !1, this._isYouMayAlsoLikeRowExpanded = !1, this._screenshotsRowBaseHeight = 340, this._templates = [], this._translations = E({ name: "solution-details-panel", blocking: !0 }), this._youMayAlsoLikeBaseHeight = 340, this._allCards = [], this._configContextConsumer = M({
      context: T,
      subscribe: !0
    }), this._configureLearnMore = "", this._customDeploymentMappings = {}, this._deployDialogRef = d(), this._deployingDialogRef = d(), this._overviewAccordionItemElement = d(), this._privilegePopoverRef = d(), this._privileges = [], this._regexFsUrl = "https?:\\/\\/.+FeatureServer\\b", this._regexID = "\\b[0-9A-F]{32}\\b", this._releaseNotesAccordionItemElement = d(), this._relatedResourcesAccordionItemElement = d(), this._screenshotsAccordionItemElement = d(), this._screenshotsDialogRef = d(), this._screenshotsElement = d(), this._termsOfUseAccordionItemElement = d(), this._userOptions = [], this._youMayAlsoLikeAccordionItemElement = d(), this._youMayAlsoLikeElement = d(), this._signInParamValue = null, this._deploymentStartTime = null, this._cancellationStartTime = null, this._deployToCancelDuration = 0, this.templatesFetched = f(), this.itemPropertiesFetched = f(), this.sortTypeChanged = f(), this.tokenRefreshed = f(), this._handleDeployCancelled = () => {
      this._telemetry?.logEvent({
        category: g.SOLUTION_DETAILS,
        action: "Deploy Dialog Canceled",
        dimensions: [
          this.card?.title || "",
          this.card?.deployCommonId || "",
          this.card?.deployVersion || ""
        ]
      });
    }, this._handleDeploySuccess = () => {
      const e = b(this._deploymentStartTime);
      this._deploymentStartTime = null, this._telemetry?.logEvent({
        category: g.SOLUTION_DETAILS,
        action: "Deploy Success",
        dimensions: [
          this.card?.title || "",
          this.card?.deployCommonId || "",
          this.card?.deployVersion || ""
        ],
        metrics: [e]
      });
    }, this._handleDeployedCardReady = async (e) => {
      this._closeDialogs(), await new Promise((t) => requestAnimationFrame(() => requestAnimationFrame(t))), window.dispatchEvent(new CustomEvent("displayDeployedCard", {
        detail: e.detail
      }));
    }, this._handleDeploymentProcessCancelled = () => {
      this._cancellationStartTime = Date.now(), this._deployToCancelDuration = b(this._deploymentStartTime), this._deploymentStartTime = null;
    }, this._handleDeployFailed = (e) => {
      if (this._cancellationStartTime !== null) {
        this._closeDialogs();
        return;
      }
      const t = b(this._deploymentStartTime);
      this._deploymentStartTime = null;
      const i = z(e.detail?.error), s = i.length > 200 ? i.slice(-200) : i;
      console.error("Deployment failed:", e.detail?.error), this._telemetry?.logEvent({
        category: g.SOLUTION_DETAILS,
        action: "Deploy Failure",
        dimensions: [
          this.card?.title || "",
          this.card?.deployCommonId || "",
          this.card?.deployVersion || "",
          s
        ],
        metrics: [t]
      }), this._closeDialogs(!0);
    }, this.listenOn(window, "detailsCardSelected", this._detailsCardSelected), this.listenOn(window, "allCardsFetched", this._allCardsFetched), this.listenOn(window, "deployAppTabSelected", this._handleDeployAppTabSelected), this.listenOn(window, "deployedCardReady", this._handleDeployedCardReady);
  }
  static {
    this.properties = { card: 0, _showScreenshotsShowMore: 16, _showYouMayAlsoLikeShowMore: 16, _isScreenshotsRowExpanded: 16, _isYouMayAlsoLikeRowExpanded: 16, _itemProperties: 16, _missingPrivilegeMessages: 16, _screenshotsRowBaseHeight: 16, _templates: 16, _translations: 16, _youMayAlsoLikeBaseHeight: 16 };
  }
  static {
    this.styles = B;
  }
  get _telemetry() {
    return this._configContextConsumer.value?.telemetrySession;
  }
  async connectedCallback() {
    super.connectedCallback(), this.listenOn(window, "calciteTabChange", this._cleanupPanel);
  }
  loaded() {
    this._signInParamValue === null && this._configContextConsumer.value?.authentication?.SignInParam && (this._signInParamValue = this._configContextConsumer.value.authentication.SignInParam), this._resizeObserver = new ResizeObserver(async () => {
      this._onResize();
    }), this._screenshotsElement.value && this._resizeObserver.observe(this._screenshotsElement.value);
  }
  disconnectedCallback() {
    super.disconnectedCallback(), this._resizeObserver?.disconnect();
  }
  render() {
    const e = "padding-bottom-1-5", t = this._getRelatedResources(), i = this._getYouMayAlsoLikeCards();
    return l`<calcite-shell class="position-relative background-color-2"><calcite-panel class="panel-background-2 border-none" slot=panel-bottom><div class="margin-top-875 padding-1-5 back-color-override-1 margin-bottom-1-5" id=solution-details-row>${this._getSolutionRow()}</div><div class=${u(e)}>${this._getScreenshotsRow()}</div><div class=${u(e)}>${this._getOverviewRow()}</div><div class=${u(e)}>${this._getReleaseNotesRow()}</div>${t.length > 0 ? l`<div class=${u(e)}>${this._getRelatedResourcesRow(t)}</div>` : ""}${i.length > 0 ? l`<div class=${u(e)}>${this._getYouMayAlsoLikeRow(i)}</div>` : ""}<div class=${u(e)}>${this._getTermsOfUseRow()}</div><solution-deploy-dialog .card=${this.card} @deployCancelled=${this._handleDeployCancelled} @deployFailed=${this._handleDeployFailed} @deployProgressEnd=${this._handleDeploySuccess} @deployProgressStart=${this._deployProgressStart} @deployProgressUpdated=${this._deployProgessUpdated} id=solutionDeployDialog .userOptions=${this._userOptions} ${h(this._deployDialogRef)}></solution-deploy-dialog><solution-snapshot-gallery .card=${this.card} id=solutionSnapshotGallery .itemProperties=${this._itemProperties} ${h(this._screenshotsDialogRef)}></solution-snapshot-gallery><solution-deploying-dialog .card=${this.card} @deploymentProcessCancelled=${this._handleDeploymentProcessCancelled} ${h(this._deployingDialogRef)}></solution-deploying-dialog></calcite-panel></calcite-shell>`;
  }
  updated() {
    setTimeout(() => {
      const e = this._getYouMayAlsoLikeCards();
      let t = 340;
      for (let i = 0; i < e.length; i++) {
        const s = this.el.shadowRoot?.getElementById(`you-may-also-like-${i}`), a = s?.offsetHeight ? s.offsetHeight + 40 : 0;
        a > t && (t = a);
      }
      this._youMayAlsoLikeBaseHeight = t, this._showYouMayAlsoLikeShowMore = (this._youMayAlsoLikeElement.value?.scrollHeight || 0) > this._youMayAlsoLikeBaseHeight;
    }, 100);
  }
  _checkUrlParametersForAutoDeployment() {
    if (this._signInParamValue === "deploy") {
      const t = this._missingPrivilegeMessages && (this._missingPrivilegeMessages.leadingMessages.length > 0 || this._missingPrivilegeMessages.bulletedMessages.length > 0 || this._missingPrivilegeMessages.trailingMessages.length > 0);
      this._configContextConsumer.value?.authentication?.IsSignedIn && this.card && this._deployDialogRef.value && !t && (this._signInParamValue = null, this._openDeploy());
    }
  }
  _getSolutionRow() {
    const e = this.card?.thumbnailUrl.replace(/w=\d+/, "w=400"), t = this._missingPrivilegeMessages?.leadingMessages || [], i = t.length > 0, s = this._missingPrivilegeMessages?.bulletedMessages || [], a = s.length > 0, o = this._missingPrivilegeMessages?.trailingMessages || [], c = o.length > 0;
    return l`<div class="display-flex flex-direction-row width-full"><div class="padding-end-1-75 image-width"><img alt=${this.card?.title ?? y} src=${e ?? y}></div><div class="display-flex flex-direction-row flex-1">${this._getTextSection(i, a, c, t, s, o)}${this._getButtons(i || a || c)}</div></div>`;
  }
  _getTextSection(e, t, i, s, a, o) {
    return l`<div class="display-flex flex-direction-column padding-end-1 flex-1"><div class="display-flex flex-direction-row align-items-baseline"><h1 class="padding-top-xs title-font margin-top-0 margin-bottom-1-5 line-height-1">${this.card?.title}</h1>${this.card?.categories?.some((c) => c.includes("New Release")) && l`<calcite-chip class="margin-bottom-1-5 margin-sides-1" kind=brand .label=${this._translations.newChip} scale=m icon=star>${this._translations.newChip}</calcite-chip>` || ""}</div><div class="font-1 padding-end-1 line-height-xxl">${this.card?.snippet}</div>${e || t || i ? l`<div class="display-flex flex-direction-row padding-top-1">${this._getMissingPrivilegesNotice(s, a, o)}</div>` : ""}</div>`;
  }
  _getButtons(e) {
    const t = this._itemProperties?.demoURL || "";
    return l`<div class="display-flex flex-direction-column button-width"><calcite-button class="padding-bottom-1 solution-detail-action" .disabled=${e} icon-flip-rtl=end @click=${() => this._openDeploy()} scale=m>${this._translations.deployButton}</calcite-button>${!this._configContextConsumer.value?.isEnterprise && t && l`<calcite-button appearance=outline-fill kind=neutral class="padding-bottom-1 solution-detail-action" @click=${() => this._handleWatchDemoClick(t)} scale=m>${this._translations.watchDemo}</calcite-button>` || ""}<calcite-button appearance=outline-fill kind=neutral class="padding-bottom-1 solution-detail-action" @click=${() => this._handleLearnMoreClick()} scale=m>${this._translations.openHelp}</calcite-button>${!this._configContextConsumer.value?.isEnterprise && l`<solution-social-share button-appearance=outline-fill class="padding-bottom-1" share-button-kind=neutral .shareButtonText=${this._translations.share} share-button-scale=m .solutionId=${this.card?.deployCommonId || ""} .solutionTitle=${this.card?.title || ""} .solutionVersion=${this.card?.deployVersion || ""}></solution-social-share>` || ""}</div>`;
  }
  _getMissingPrivilegesNotice(e, t, i) {
    const s = "solutions-missing-privileges-notice", a = this._translations.missingPrivilegesPopup.missingLicensingOrPrivileges, o = t.length > 0 ? "" : "display-none", c = t.length > 0 ? "padding-top-sm" : "";
    return l`<div><calcite-notice class="margin-inline-unset" kind=info open><div slot=message>${`${a}`}</div><calcite-action icon=information id=${s} slot=actions-end .text=${a}></calcite-action></calcite-notice><calcite-popover closable label overlay-positioning=fixed placement=bottom reference-element=solutions-missing-privileges-notice ${h(this._privilegePopoverRef)}><div class="padding-1 display-flex flex-direction-column">${// Leading messages
    this._getSpanMessages(e, "padding-bottom-1")}<span class=${`padding-bottom-1-2 ${o}`}>${this._translations.missingPrivilegesPopup.missingPrivilegesListHeading}</span>${// Bulleted messages
    this._getBulletedMessages(t)}${// Trailing messages
    this._getSpanMessages(i, c)}</div></calcite-popover></div>`;
  }
  _getSpanMessages(e, t) {
    return e.length > 0 ? e.map((i) => l`<span class=${u(t)}>${i}</span>`) : "";
  }
  _getBulletedMessages(e) {
    return e.length > 0 ? l`<ul>${e.map((t) => l`<li>${t}</li>`)}</ul>` : "";
  }
  _getScreenshotsRow() {
    const e = this._isScreenshotsRowExpanded ? this._translations.showLess : this._translations.showMore, t = this._isScreenshotsRowExpanded ? "arrow-up" : "arrow-down", i = this._showScreenshotsShowMore ? "" : "display-none";
    return l`<calcite-accordion class="accordion-bg " icon-position=start scale=l appearance=transparent><calcite-accordion-item class="item-padding" expanded ${h(this._screenshotsAccordionItemElement)}><div class="margin-block-start-end-0 heading-font" slot=content-start>${this._translations.solutionOverview}</div><calcite-panel><div class="display-flex flex-direction-column back-color-override-1"><div class="collapsible-div max-height-300" id=screenshots-subsection ${h(this._screenshotsElement)}>${this._getScreenshots()}</div><calcite-fab appearance=outline-fill class=${`align-self-center ${i}`} .icon=${t} kind=neutral @click=${() => {
      this._screenshotsElement.value?.classList.toggle("expanded"), this._isScreenshotsRowExpanded = this._screenshotsElement.value.classList.contains("expanded");
    }} .text=${e} text-enabled></calcite-fab></div></calcite-panel></calcite-accordion-item></calcite-accordion>`;
  }
  _getScreenshots() {
    const e = this._itemProperties?.preview.filter((i) => i.format === "image") || [], t = this._configContextConsumer.value;
    return l`<calcite-card-group class="card-group" .label=${this._translations.solutionOverview}>${e.reduce((i, s) => {
      const a = $(this.card?.id || "", s.name, t.authentication);
      let o;
      return t.agoBasedEnterpriseSolutionsGroupId && t.isEnterprise && (o = $(this.card?.id || "", s.name, void 0, t.agolPortalUrl)), this.card?.id ? i.push(l`<calcite-card class="cursor-pointer" .label=${s.alt} @click=${() => this._openScreenshotGallery(s)}><div class="card-image-wrap" slot=thumbnail><img alt=${s.alt ?? y} class="thumbnail card-image" slot=thumbnail src=${(o || a) ?? y}><div class="hover-text">${this._translations.openInGallery}</div></div></calcite-card>`) : i.push(""), i;
    }, [])}</calcite-card-group>`;
  }
  _openScreenshotGallery(e) {
    this._telemetry?.logEvent({
      category: g.SOLUTION_DETAILS,
      action: "Screenshot Gallery",
      dimensions: [
        this.card?.title || "",
        this.card?.deployCommonId || "",
        this.card?.deployVersion || ""
      ]
    });
    const t = this._screenshotsDialogRef.value;
    t && (t.screenshot = e, t.open = !0);
  }
  _getOverviewRow() {
    return l`<calcite-accordion class="accordion-bg " icon-position=start scale=l appearance=transparent><calcite-accordion-item class="item-padding" expanded ${h(this._overviewAccordionItemElement)}><div class="margin-block-start-end-0 heading-font" slot=content-start>${this._translations.solutionDetails}</div>${this._getDescriptionRow()}${this._getInformationProductsRow()}</calcite-accordion-item></calcite-accordion>`;
  }
  _getDescriptionRow() {
    return l`<div class="display-flex flex-direction-column"><div class="font-color-2 font-1 margin-top-0 line-height-xxl padding-bottom-xxl">${this.card?.snippet}</div><div class="font-color-2 font-1 margin-top-0 line-height-xxl padding-bottom-xxl" .innerHTML=${this.card?.description ?? ""}></div></div>`;
  }
  _getInformationProductsRow() {
    return l`<div class="display-flex flex-direction-column font-1 line-height-xxl font-color-2"><span>${this.card?.title ? this._translations.informationProductsSubText.replace("{{solutionTitle}}", this.card.title) : ""}</span><calcite-table bordered caption class="padding-top-1">${this._getInformationTableHeaderRow()}${this._getInformationTableRows()}</calcite-table><p>${this._translations.informationProductsFooterText}</p></div>`;
  }
  _getInformationTableHeaderRow() {
    return l`<calcite-table-row slot=table-header><calcite-table-header .heading=${this._translations.solutionItem}></calcite-table-header><calcite-table-header .heading=${this._translations.description}></calcite-table-header><calcite-table-header .heading=${this._translations.minimumUserType}></calcite-table-header></calcite-table-row>`;
  }
  _getInformationTableRows() {
    return (this._itemProperties?.infoProducts || []).map((t) => l`<calcite-table-row><calcite-table-cell><p class="table-cell" .innerHTML=${_(t.item) ?? ""}></p></calcite-table-cell><calcite-table-cell><p class="table-cell" .innerHTML=${_(t.description) ?? ""}></p></calcite-table-cell><calcite-table-cell><p class="table-cell" .innerHTML=${_(t.userType) ?? ""}></p></calcite-table-cell></calcite-table-row>`);
  }
  _getReleaseNotesRow() {
    return l`<calcite-accordion class="accordion-bg " icon-position=start scale=l appearance=transparent><calcite-accordion-item class="item-padding" expanded ${h(this._releaseNotesAccordionItemElement)}><div class="margin-block-start-end-0 heading-font" slot=content-start>${this._translations.releaseNotes}</div><div class="display-flex flex-direction-column"><calcite-table bordered caption>${this._getReleaseNotesTableHeaderRow()}${this._getReleaseNotesTableRows()}</calcite-table></div></calcite-accordion-item></calcite-accordion>`;
  }
  _getReleaseNotesTableHeaderRow() {
    return l`<calcite-table-row slot=table-header><calcite-table-header .heading=${this._translations.version}></calcite-table-header><calcite-table-header .heading=${this._translations.description}></calcite-table-header></calcite-table-row>`;
  }
  _getReleaseNotesTableRows() {
    return (this._itemProperties?.releaseNotes || [])?.map((t) => l`<calcite-table-row><calcite-table-cell><p class="table-cell" .innerHTML=${_(t.version) ?? ""}></p></calcite-table-cell><calcite-table-cell><p class="table-cell" .innerHTML=${_(t.description) ?? ""}></p></calcite-table-cell></calcite-table-row>`);
  }
  _getRelatedResourcesRow(e) {
    return l`<calcite-accordion class="accordion-bg " icon-position=start scale=l appearance=transparent><calcite-accordion-item class="item-padding" expanded ${h(this._relatedResourcesAccordionItemElement)}><div class="margin-block-start-end-0 heading-font" slot=content-start>${this._translations.relatedResources}</div><div class="display-flex flex-direction-row">${e.map(() => {
      l`<solution-resource-card></solution-resource-card>`;
    })}</div></calcite-accordion-item></calcite-accordion>`;
  }
  _getRelatedResources() {
    return [];
  }
  _getYouMayAlsoLikeRow(e) {
    const t = this._showYouMayAlsoLikeShowMore ? "" : "display-none", i = this._isYouMayAlsoLikeRowExpanded ? this._translations.showLess : this._translations.showMore, s = this._isYouMayAlsoLikeRowExpanded ? "arrow-up" : "arrow-down", a = this._isYouMayAlsoLikeRowExpanded ? "" : { height: `${this._youMayAlsoLikeBaseHeight}px` };
    return l`<calcite-accordion class="accordion-bg " icon-position=start scale=l appearance=transparent><calcite-accordion-item class="item-padding" expanded ${h(this._youMayAlsoLikeAccordionItemElement)}><div class="margin-block-start-end-0 heading-font" slot=content-start>${this._translations.youMayAlsoLike}</div><div class="display-flex flex-direction-column"><div class="collapsible-div" id=you-may-also-like-subsection style=${R(a)} ${h(this._youMayAlsoLikeElement)}><div class="display-flex flex-direction-row"><calcite-card-group class="card-group" .label=${this._translations.youMayAlsoLike}>${e.map((o, c) => l`<solution-details-card .id=${`you-may-also-like-${c}`} .card=${o} class="padding-2px" source=you-may-also-like .referrerSolutionId=${this.card?.deployCommonId || ""} .referrerSolutionTitle=${this.card?.title || ""} .referrerSolutionVersion=${this.card?.deployVersion || ""}></solution-details-card>`)}</calcite-card-group></div></div><calcite-fab appearance=outline-fill class=${`align-self-center ${t}`} .icon=${s} kind=inverse @click=${() => {
      this._youMayAlsoLikeElement.value?.classList.toggle("expanded"), this._isYouMayAlsoLikeRowExpanded = this._youMayAlsoLikeElement.value.classList.contains("expanded");
    }} .text=${i} text-enabled></calcite-fab></div></calcite-accordion-item></calcite-accordion>`;
  }
  _getYouMayAlsoLikeCards() {
    const e = this._itemProperties?.relatedSolutions || [];
    return this._allCards.filter((t) => e.indexOf(t.deployCommonId) > -1);
  }
  _getTermsOfUseRow() {
    return l`<calcite-accordion class="accordion-bg " icon-position=start scale=l appearance=transparent><calcite-accordion-item class="item-padding" expanded ${h(this._termsOfUseAccordionItemElement)}><div class="margin-block-start-end-0 heading-font" slot=content-start>${this._translations.termsOfUse}</div><div class="font-color-2" .innerHTML=${(this.card?.licenseInfo || "") ?? ""}></div></calcite-accordion-item></calcite-accordion>`;
  }
  _openDeploy() {
    if (this._configContextConsumer.value.authentication.IsSignedIn) {
      const e = this._deployDialogRef.value;
      e && (this._telemetry?.logEvent({
        category: g.SOLUTION_DETAILS,
        action: "Deploy Dialog Opened",
        dimensions: [
          this.card?.title || "",
          this.card?.deployCommonId || "",
          this.card?.deployVersion || ""
        ]
      }), e.userOptions = this._userOptions, e.open = !0);
    } else
      this._configContextConsumer.value.authentication.signIn("deploy");
  }
  _openUrl(e) {
    window.open(e, "_blank");
  }
  _handleWatchDemoClick(e) {
    this._telemetry?.logEvent({
      category: g.SOLUTION_DETAILS,
      action: "Watch Demo",
      dimensions: [
        this.card?.title || "",
        this.card?.deployCommonId || "",
        this.card?.deployVersion || ""
      ]
    }), this._openUrl(e);
  }
  _handleLearnMoreClick() {
    this._telemetry?.logEvent({
      category: g.SOLUTION_DETAILS,
      action: "Open Help",
      dimensions: [
        this.card?.title || "",
        this.card?.deployCommonId || "",
        this.card?.deployVersion || ""
      ]
    }), this._openUrl(this.card?.learnMoreUrl || "");
  }
  async _detailsCardSelected(e) {
    this.card = e.detail, this.el.scrollIntoView(!0), this._onResize(), this._missingPrivilegeMessages = void 0, await this._getItemData(), this._expandAccordions();
  }
  _expandAccordions() {
    this._overviewAccordionItemElement.value && (this._overviewAccordionItemElement.value.expanded = !0), this._releaseNotesAccordionItemElement.value && (this._releaseNotesAccordionItemElement.value.expanded = !0), this._relatedResourcesAccordionItemElement.value && (this._relatedResourcesAccordionItemElement.value.expanded = !0), this._screenshotsAccordionItemElement.value && (this._screenshotsAccordionItemElement.value.expanded = !0), this._termsOfUseAccordionItemElement.value && (this._termsOfUseAccordionItemElement.value.expanded = !0), this._youMayAlsoLikeAccordionItemElement.value && (this._youMayAlsoLikeAccordionItemElement.value.expanded = !0);
  }
  async _getItemData() {
    const e = this._configContextConsumer.value, t = e?.agoBasedEnterpriseSolutionsGroupId && e?.isEnterprise ? e.anonAgolSession : e?.userSession, i = await P(this.card.id, t), s = await O(this.card.id, t);
    this._itemProperties = s.properties, this.itemPropertiesFetched.emit(this._itemProperties);
    const a = N(i, this.card.typeKeywords, e?.authentication);
    this._privileges = t.username ? a : [], this._userPrivileges = e?.authentication && e?.userSession ? await G(e.authentication, e.userSession, e.authentication.PortalUserPrivileges) : [];
    const o = this._privileges.filter((p) => !this._userPrivileges.includes(p));
    this._missingPrivilegeMessages = H(this._translations, o), (i.params ? this.formatParams(i.params) : Promise.resolve([])).then((p) => {
      this._userOptions = p;
    }), this._templates = i.templates, this.templatesFetched.emit(i.templates), this._checkUrlParametersForAutoDeployment();
  }
  formatParams(e) {
    const t = this._configContextConsumer.value.userSession, i = [], s = e ? Object.keys(e) : [], a = {
      id: "",
      props: [],
      accordionDisplay: !1
    };
    if (s.length > 0) {
      const o = [];
      return s.forEach((c) => {
        const p = e[c];
        p.valueType && p.valueType.toLowerCase() === "itemid" && o.push(this._findExistingItem(c, "Feature Service", t.username || ""));
      }), Promise.all(o).then((c) => {
        const p = {};
        return c.forEach((r) => {
          if (r.query && r.results && r.results.length > 0) {
            const I = r.query.split(" ")[0].replace("typekeywords:source-", "");
            p[I] = {
              resultId: r.results[0].id,
              response: r.results[0]
            };
          }
        }), s.forEach((r) => {
          if (r === "serviceLearnMore") {
            this._configureLearnMore = e[r], alert(this._configureLearnMore), delete e[r];
            return;
          }
          e[r].enterpriseIDMapping && (this._customDeploymentMappings[r] = e[r].enterpriseIDMapping), a.id = r, p[r] && (e[r].existingItemId = p[r].resultId, this.updateUserProp(e[r], p[r].response)), this.updateOption(e[r], a, r);
        }), i.push(a), Promise.resolve(i);
      }).catch(() => Promise.resolve([]));
    } else
      return Promise.resolve([]);
  }
  _findExistingItem(e, t, i) {
    const s = this._configContextConsumer.value.userSession;
    return F(`typekeywords:source-${e} type:${t} owner:${i}`, s);
  }
  updateUserProp(e, t) {
    const i = e.itemType?.toLowerCase() === "feature service", s = new RegExp(i ? this._regexFsUrl : e.itemType, "iu"), a = w(t, i ? "url" : "type", "") || "", o = a !== "" && s.test(a);
    return e.responseValue = o ? a : "", e.name = o && v(t, "name") || "", e.title = o && v(t, "title") || "", e.itemType = o ? v(t, "type") : e.itemType, e.validId = o, e.itemUrl = Y(t.id, this._configContextConsumer.value.authentication), o;
  }
  updateOption(e, t, i) {
    const s = e.default || "", a = typeof s, o = s.toString();
    this._setFeatureServiceProps(e);
    const c = this.getValidation(e, o);
    t.props.push({
      id: i,
      outType: a,
      prop: i,
      itemType: e.itemType || "",
      responseValue: e.responseValue || "",
      label: e.label || "",
      choices: e.choices || [],
      valueType: e.valueType.toLowerCase(),
      attributes: e.attributes || {},
      value: e.existingItemId && e.valueType.toLowerCase() === "itemid" ? e.existingItemId : o,
      default: o,
      srSearchText: o,
      autoSelect: o !== "",
      ...c,
      loading: !1,
      validId: !0,
      tooltip: e.tooltip || "",
      name: e.name || "",
      title: e.title || "",
      itemUrl: e.itemUrl || ""
    });
  }
  _setFeatureServiceProps(e) {
    e.valueType && e.valueType.toLowerCase() === "itemid" && U(e, "attributes.required", "true");
  }
  getValidation(e, t) {
    let i = "", s = v(e, "validation.message") || "", a = !0;
    return v(e, "attributes.required") === "true" && (i = w(e, "validation.expression", "\\S{1,}"), a = new RegExp(i).test(t)), e.valueType && e.valueType.toLowerCase() === "itemid" && (i = this._regexID, s = this._translations.configure.invalidID), {
      valid: a,
      validation: {
        expression: i,
        message: s
      }
    };
  }
  _allCardsFetched(e) {
    this._allCards = e.detail;
  }
  _onResize() {
    this._showYouMayAlsoLikeShowMore = (this._youMayAlsoLikeElement.value?.scrollHeight || 0) > this._youMayAlsoLikeBaseHeight, this._showScreenshotsShowMore = (this._screenshotsElement.value?.scrollHeight || 0) > this._screenshotsRowBaseHeight + 2;
  }
  _cleanupPanel() {
    this.el.scrollIntoView(!0), this._isScreenshotsRowExpanded = !1, this._showScreenshotsShowMore = !1, this._screenshotsElement.value?.classList.remove("expanded"), this._isYouMayAlsoLikeRowExpanded = !1, this._showYouMayAlsoLikeShowMore = !1, this._youMayAlsoLikeElement.value?.classList.remove("expanded"), this._privilegePopoverRef.value?.open && (this._privilegePopoverRef.value.open = !1), this._expandAccordions();
  }
  _deployProgressStart(e) {
    this._deploymentStartTime = Date.now(), this._telemetry?.logEvent({
      category: g.SOLUTION_DETAILS,
      action: "Deploy Started",
      dimensions: [
        this.card?.title || "",
        this.card?.deployCommonId || "",
        this.card?.deployVersion || ""
      ]
    }), this._deployingDialogRef.value && (this._deployingDialogRef.value.open = !0, this._deployingDialogRef.value.abortController = e.detail), this._deployDialogRef.value && this._deployDialogRef.value.classList.add("display-none");
  }
  _deployProgessUpdated(e) {
    const t = e.detail;
    this._deployingDialogRef.value.deploymentProgress = t.progress;
  }
  _closeDialogs(e = !1) {
    if (this._cancellationStartTime !== null) {
      const t = b(this._cancellationStartTime);
      this._telemetry?.logEvent({
        category: g.SOLUTION_DETAILS,
        action: "Deploy Canceled",
        dimensions: [
          this.card?.title || "",
          this.card?.deployCommonId || "",
          this.card?.deployVersion || ""
        ],
        metrics: [this._deployToCancelDuration, t]
      }), this._cancellationStartTime = null, this._deployToCancelDuration = 0;
    }
    this._deployingDialogRef.value.close(), e ? this._deployDialogRef.value.open = !0 : this._deployDialogRef.value.close(), this._deployDialogRef.value.classList.remove("display-none");
  }
  _handleDeployAppTabSelected(e) {
    e.detail === "details" && this.sortTypeChanged.emit("");
  }
}
S("solution-details-panel", Z);
export {
  Z as SolutionDetailsPanel
};
