/* COPYRIGHT Esri - https://js.arcgis.com/1.2/LICENSE.txt */
import { c as customElement } from "../../chunks/runtime.js";
import { u as useT9n } from "../../chunks/useT9n.js";
import { createRef, ref } from "lit-html/directives/ref.js";
import { LitElement, createEvent, safeClassMap, nothing, safeStyleMap } from "@arcgis/lumina";
import { useContextConsumer } from "@arcgis/lumina/context";
import { c as configContext, i as isMobileContext } from "../../chunks/deployAppContexts.js";
import { css, html } from "lit";
import { request, getWorkflowBaseURL, getWorkflowManagerAuthorized, sanitizeHTML, getItemDataAsJson, getItem, getPropWithDefault, getProp, setCreateProp } from "@esri/solution-common";
import { E as ECustomPrivileges, f as EPrivileges, T as TELEMETRY_CATEGORY, y as getRequiredSolutionPrivileges, z as getPrivilegeMessages } from "../../chunks/interfaces.js";
import { _findExistingItem } from "@esri/solution-deployer";
import { k as checkVelocitySupport, l as calculateDuration, m as extractErrorMessage } from "../../chunks/helpers.js";
import { a as getItemResourceUrl, g as getItemUrl } from "../../chunks/common.js";
import "../../chunks/solution-deploy-dialog.js";
import "../solution-snapshot-gallery/customElement.js";
import "../solution-deploying-dialog/customElement.js";
const styles = css`/** @license
 * Copyright 2025 Esri
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

.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: 0.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: 0.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;
}

#screenshots-subsection calcite-card {
  width: calc(33.333% - .5rem);
}

calcite-card {
  width: 450px;
  --calcite-card-border-color: transparent;
}

@media (max-width: 1496px) {
  calcite-card {
    width: calc(100% / 3 - .5rem);
  }
  
  #screenshots-subsection calcite-card {
    width: calc(33.333% - .5rem);
  }
}

@media (max-width: 1100px) {
  calcite-card {
    width: calc(100% / 2 - .5rem);
  }
  
  #screenshots-subsection calcite-card {
    width: calc(50% - .5rem);
  }
}

@media (max-width: 550px) {
  calcite-card {
    width: 100%;
  }
  
  #screenshots-subsection calcite-card {
    width: 100%;
  }
}

/* This is tied to a supporting prop _screenshotsBaseHeight */
.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: #ffffff;
}

calcite-card:hover {
  border: var(--calcite-spacing-base) solid var(--calcite-color-brand);
  box-sizing: border-box;
  cursor: pointer;
  padding: var(--calcite-spacing-base);
}

calcite-card {
  border: var(--calcite-spacing-base) solid transparent;
  box-sizing: border-box;
  padding: var(--calcite-spacing-base);
  /* transition: border .1s ease, padding .1s ease; */
}

.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 0.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;
}

/* Style for anchor elements that may appear in innerHTML content to emulate calcite-link */
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, 150ms);
  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 getUserPrivileges(authentication, userSession, portalUserPrivileges) {
  let privileges = portalUserPrivileges;
  if (authentication) {
    if (authentication?.IsEnterprisePortal) {
      const hasNotebookServer = await _hasNotebookServer(
        "",
        // the portal url
        userSession
      );
      if (hasNotebookServer) {
        privileges.push(ECustomPrivileges.NOTEBOOK);
      }
    }
    const velocitySupported = await checkVelocitySupport(userSession);
    if (!velocitySupported) {
      if (authentication?.PortalUserPrivileges) {
        const velocityPrivileges = [
          EPrivileges.VELOCITYFEEDS,
          EPrivileges.VELOCITYBIGDATA,
          EPrivileges.VELOCITYREALTIME
        ];
        velocityPrivileges.forEach((p) => {
          const i = portalUserPrivileges.indexOf(p) || -1;
          if (i !== -1) {
            portalUserPrivileges.splice(i, 1);
          }
        });
      }
    } else {
      portalUserPrivileges.push(ECustomPrivileges.VELOCITY);
    }
    privileges = privileges.concat(
      _getLocationTrackingPrivileges(
        _getUserIsAdmin(authentication),
        _isLocationTrackingEnabled(authentication)
      )
    );
    privileges = privileges.concat(_getHubPrivileges(authentication));
    privileges = privileges.concat(await _getWorkflowManagerPrivileges(authentication));
  }
  return Promise.resolve(privileges);
}
function _getLocationTrackingPrivileges(userIsAdmin, locationTrackingEnabled) {
  let privileges = [];
  if (userIsAdmin && locationTrackingEnabled) {
    privileges = [
      ECustomPrivileges.TRACKINGADMINANDTRACKING,
      ECustomPrivileges.TRACKINGADMIN,
      ECustomPrivileges.TRACKING
    ];
  } else if (userIsAdmin && !locationTrackingEnabled) {
    privileges = [ECustomPrivileges.TRACKINGADMIN];
  } else if (!userIsAdmin && locationTrackingEnabled) {
    privileges = [ECustomPrivileges.TRACKING];
  }
  return privileges;
}
function _getHubPrivileges(authentication) {
  return _isHubPremiumEnabled(
    authentication
  ) ? [ECustomPrivileges.HUBPREMIUM] : [];
}
async function _getWorkflowManagerPrivileges(authentication) {
  const baseUrl = await getWorkflowBaseURL(authentication?.RestUserSession);
  const isAuthorized = await getWorkflowManagerAuthorized(
    baseUrl,
    authentication?.RestUserSession
  );
  return isAuthorized ? [ECustomPrivileges.WORKFLOW] : [];
}
async function _hasNotebookServer(portalUrl, userSession) {
  const portal = portalUrl + "/sharing/rest";
  const requestParams = {
    authentication: userSession,
    portal,
    params: {
      f: "json"
    }
  };
  return request(`${portal}/portals/self/servers`, requestParams).then((response) => {
    return response?.servers?.find((s) => s.serverFunction.indexOf("NotebookServer") > -1);
  }, (e) => {
    console.error(e);
    return false;
  });
}
function _getUserIsAdmin(authentication) {
  const portalUserSubset = authentication?.PortalUserSubset;
  return portalUserSubset?.role === "org_admin" && !portalUserSubset?.hasOwnProperty("roleId");
}
function _isLocationTrackingEnabled(authentication) {
  return authentication?.PortalSubset?.locationTrackingEnabled || false;
}
function _isHubPremiumEnabled(authentication) {
  return authentication?.PortalSubset?.hubPremiumEnabled || false;
}
class SolutionDetailsPanel extends LitElement {
  constructor() {
    super();
    this._isDeployDisabled = false;
    this._isLoaded = false;
    this._showScreenshotsShowMore = false;
    this._showYouMayAlsoLikeShowMore = false;
    this.isMobile = false;
    this._isScreenshotsRowExpanded = false;
    this._isYouMayAlsoLikeRowExpanded = false;
    this._screenshotsRowBaseHeight = 340;
    this._showLoader = false;
    this._templates = [];
    this._translations = useT9n({ name: "solution-details-panel", blocking: true });
    this._youMayAlsoLikeBaseHeight = 340;
    this._allCards = [];
    this._configContextConsumer = useContextConsumer({
      context: configContext,
      subscribe: true
    });
    this._configureLearnMore = "";
    this._customDeploymentMappings = {};
    this._deployDialogRef = createRef();
    this._deployingDialogRef = createRef();
    this._isMobileContextConsumer = useContextConsumer({
      context: isMobileContext,
      subscribe: true,
      callback: (value) => this.isMobile = value
    });
    this._overviewAccordionItemElement = createRef();
    this._privilegePopoverRef = createRef();
    this._privileges = [];
    this._regexFsUrl = "https?:\\/\\/.+FeatureServer\\b";
    this._regexID = "\\b[0-9A-F]{32}\\b";
    this._releaseNotesAccordionItemElement = createRef();
    this._relatedResourcesAccordionItemElement = createRef();
    this._screenshotsAccordionItemElement = createRef();
    this._screenshotsDialogRef = createRef();
    this._screenshotsElement = createRef();
    this._termsOfUseAccordionItemElement = createRef();
    this._userOptions = [];
    this._youMayAlsoLikeAccordionItemElement = createRef();
    this._youMayAlsoLikeElement = createRef();
    this._signInParamValue = null;
    this._deploymentStartTime = null;
    this._cancellationStartTime = null;
    this._deployToCancelDuration = 0;
    this.templatesFetched = createEvent();
    this.itemPropertiesFetched = createEvent();
    this.sortTypeChanged = createEvent();
    this.tokenRefreshed = createEvent();
    this._handleDeployCancelled = () => {
      this._telemetry?.logEvent({
        category: TELEMETRY_CATEGORY.SOLUTION_DETAILS,
        action: "Deploy Dialog Canceled",
        dimensions: [
          this.card?.title || "",
          this.card?.deployCommonId || "",
          this.card?.deployVersion || ""
        ]
      });
    };
    this._handleDeploySuccess = () => {
      const durationSeconds = calculateDuration(this._deploymentStartTime);
      this._deploymentStartTime = null;
      if (this._deployingDialogRef.value) {
        this._deployingDialogRef.value.isWaitingForCard = true;
      }
      this._telemetry?.logEvent({
        category: TELEMETRY_CATEGORY.SOLUTION_DETAILS,
        action: "Deploy Success",
        dimensions: [
          this.card?.title || "",
          this.card?.deployCommonId || "",
          this.card?.deployVersion || ""
        ],
        metrics: [durationSeconds]
      });
    };
    this._handleDeployedCardReady = async (evt) => {
      this._closeDialogs();
      await new Promise((resolve) => requestAnimationFrame(() => requestAnimationFrame(resolve)));
      window.dispatchEvent(new CustomEvent("displayDeployedCard", {
        detail: evt.detail
      }));
    };
    this._handleDeploymentFallback = () => {
      console.warn("Deployment completed but unable to navigate to deployed card - closing dialogs");
      this._closeDialogs();
      window.dispatchEvent(new CustomEvent("navTabSelected", {
        detail: "deployments"
      }));
    };
    this._handleDeploymentProcessCancelled = () => {
      this._cancellationStartTime = Date.now();
      this._deployToCancelDuration = calculateDuration(this._deploymentStartTime);
      this._deploymentStartTime = null;
    };
    this._handleDeployFailed = (evt) => {
      if (this._cancellationStartTime !== null) {
        this._closeDialogs();
        return;
      }
      const durationSeconds = calculateDuration(this._deploymentStartTime);
      this._deploymentStartTime = null;
      const errorInfo = extractErrorMessage(evt.detail?.error);
      const truncatedError = errorInfo.length > 200 ? errorInfo.slice(-200) : errorInfo;
      console.error("Deployment failed:", evt.detail?.error);
      this._telemetry?.logEvent({
        category: TELEMETRY_CATEGORY.SOLUTION_DETAILS,
        action: "Deploy Failure",
        dimensions: [
          this.card?.title || "",
          this.card?.deployCommonId || "",
          this.card?.deployVersion || "",
          truncatedError
        ],
        metrics: [durationSeconds]
      });
      this._closeDialogs(true);
    };
    this.listenOn(window, "detailsCardSelected", this._detailsCardSelected);
    this.listenOn(window, "allCardsFetched", this._allCardsFetched);
    this.listenOn(window, "deployAppTabSelected", this._handleDeployAppTabSelected);
    this.listenOn(window, "deployedCardReady", this._handleDeployedCardReady);
    this.listenOn(window, "deploymentCompletedWithoutNav", this._handleDeploymentFallback);
  }
  static {
    this.properties = { card: [0, {}, { attribute: false }], _isDeployDisabled: [16, {}, { state: true }], _isLoaded: [16, {}, { state: true }], _showScreenshotsShowMore: [16, {}, { state: true }], _showYouMayAlsoLikeShowMore: [16, {}, { state: true }], isMobile: [16, {}, { state: true }], _isScreenshotsRowExpanded: [16, {}, { state: true }], _isYouMayAlsoLikeRowExpanded: [16, {}, { state: true }], _itemProperties: [16, {}, { state: true }], _missingPrivilegeMessages: [16, {}, { state: true }], _screenshotsRowBaseHeight: [16, {}, { state: true }], _showLoader: [16, {}, { state: true }], _templates: [16, {}, { state: true }], _translations: [16, {}, { state: true }], _youMayAlsoLikeBaseHeight: [16, {}, { state: true }] };
  }
  static {
    this.styles = styles;
  }
  get _telemetry() {
    return this._configContextConsumer.value?.telemetrySession;
  }
  async connectedCallback() {
    super.connectedCallback();
    this.listenOn(window, "calciteTabChange", this._cleanupPanel);
  }
  async load() {
    if (this._isMobileContextConsumer.value) {
      this.isMobile = this._isMobileContextConsumer.value;
    }
  }
  willUpdate(_changedProperties) {
    if (_changedProperties.has("card")) {
      this._isDeployDisabled = false;
      this._isLoaded = false;
      this._showLoader = false;
      if (this._signInParamValue === "deploy") {
        this._showLoader = true;
      }
    }
  }
  loaded() {
    if (this._signInParamValue === null && this._configContextConsumer.value?.authentication?.SignInParam) {
      this._signInParamValue = this._configContextConsumer.value.authentication.SignInParam;
    }
    this._resizeObserver = new ResizeObserver(async () => {
      this._onResize();
    });
    if (this._screenshotsElement.value) {
      this._resizeObserver.observe(this._screenshotsElement.value);
    }
  }
  disconnectedCallback() {
    super.disconnectedCallback();
    this._resizeObserver?.disconnect();
  }
  render() {
    const rowClass = "padding-bottom-1-5";
    const relatedResources = this._getRelatedResources();
    const youMayAlsoLikeCards = this._getYouMayAlsoLikeCards();
    return html`<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=${safeClassMap(rowClass)}>${this._getScreenshotsRow()}</div><div class=${safeClassMap(rowClass)}>${this._getOverviewRow()}</div><div class=${safeClassMap(rowClass)}>${this._getReleaseNotesRow()}</div>${relatedResources.length > 0 ? html`<div class=${safeClassMap(rowClass)}>${this._getRelatedResourcesRow(relatedResources)}</div>` : ""}${youMayAlsoLikeCards.length > 0 ? html`<div class=${safeClassMap(rowClass)}>${this._getYouMayAlsoLikeRow(youMayAlsoLikeCards)}</div>` : ""}<div class=${safeClassMap(rowClass)}>${this._getTermsOfUseRow()}</div>${this.isMobile ? "" : html`<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} ${ref(this._deployDialogRef)}></solution-deploy-dialog>`}<solution-snapshot-gallery .card=${this.card} id=solutionSnapshotGallery .itemProperties=${this._itemProperties} ${ref(this._screenshotsDialogRef)}></solution-snapshot-gallery><solution-deploying-dialog .card=${this.card} @deploymentProcessCancelled=${this._handleDeploymentProcessCancelled} ${ref(this._deployingDialogRef)}></solution-deploying-dialog></calcite-panel></calcite-shell>`;
  }
  updated() {
    setTimeout(() => {
      const youMayAlsoLikeCards = this._getYouMayAlsoLikeCards();
      let height = 340;
      for (let i = 0; i < youMayAlsoLikeCards.length; i++) {
        const cNode = this.el.shadowRoot?.getElementById(`you-may-also-like-${i}`);
        const cNodeHeight = cNode?.offsetHeight ? cNode.offsetHeight + 40 : 0;
        if (cNodeHeight > height) {
          height = cNodeHeight;
        }
      }
      this._youMayAlsoLikeBaseHeight = height;
      this._showYouMayAlsoLikeShowMore = (this._youMayAlsoLikeElement.value?.scrollHeight || 0) > this._youMayAlsoLikeBaseHeight;
    }, 100);
  }
  _checkUrlParametersForAutoDeployment() {
    const signInParam = this._signInParamValue;
    if (signInParam === "deploy") {
      const hasMissingPrivileges = this._missingPrivilegeMessages && (this._missingPrivilegeMessages.leadingMessages.length > 0 || this._missingPrivilegeMessages.bulletedMessages.length > 0 || this._missingPrivilegeMessages.trailingMessages.length > 0);
      if (this._configContextConsumer.value?.authentication?.IsSignedIn && this.card && this._deployDialogRef.value && !hasMissingPrivileges) {
        this._signInParamValue = null;
        this._openDeploy();
      }
    }
  }
  _getSolutionRow() {
    const thumbnailUrl = this.card?.thumbnailUrl.replace(/w=\d+/, "w=400");
    const leadingMessages = this._missingPrivilegeMessages?.leadingMessages || [];
    const hasLeading = leadingMessages.length > 0;
    const bulletedMessages = this._missingPrivilegeMessages?.bulletedMessages || [];
    const hasBulleted = bulletedMessages.length > 0;
    const trailingMessages = this._missingPrivilegeMessages?.trailingMessages || [];
    const hasTrailing = trailingMessages.length > 0;
    return html`<div class="display-flex flex-direction-row width-full"><div class="padding-end-1-75 image-width"><img alt=${this.card?.title ?? nothing} src=${thumbnailUrl ?? nothing}></div><div class="display-flex flex-direction-row flex-1">${this._getTextSection(hasLeading, hasBulleted, hasTrailing, leadingMessages, bulletedMessages, trailingMessages)}${this._getButtons()}</div></div>`;
  }
  _getTextSection(hasLeading, hasBulleted, hasTrailing, leadingMessages, bulletedMessages, trailingMessages) {
    return html`<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")) && html`<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>${hasLeading || hasBulleted || hasTrailing ? html`<div class="display-flex flex-direction-row padding-top-1">${this._getMissingPrivilegesNotice(leadingMessages, bulletedMessages, trailingMessages)}</div>` : ""}</div>`;
  }
  _getButtons() {
    const demoUrl = this._itemProperties?.demoURL || "";
    return html`<div class="display-flex flex-direction-column button-width"><calcite-button class="padding-bottom-1 solution-detail-action" .disabled=${this.isMobile ? true : this._isDeployDisabled} icon-flip-rtl=end @click=${() => this._checkPermissionsBeforeDeploy()} scale=m>${this._showLoader ? html`<calcite-loader inline label></calcite-loader>` : this._translations.deployButton}</calcite-button>${!this._configContextConsumer.value?.isEnterprise && demoUrl && html`<calcite-button appearance=outline-fill kind=neutral class="padding-bottom-1 solution-detail-action" @click=${() => this._handleWatchDemoClick(demoUrl)} 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 && html`<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(leadingMessages, bulletedMessages, trailingMessages) {
    const referenceElement = "solutions-missing-privileges-notice";
    const heading = this._translations.missingPrivilegesPopup.missingLicensingOrPrivileges;
    const bulletedMessagesClass = bulletedMessages.length > 0 ? "" : "display-none";
    const trailingMessagesClass = bulletedMessages.length > 0 ? "padding-top-sm" : "";
    return html`<div><calcite-notice class="margin-inline-unset" kind=info open><div slot=message>${`${heading}`}</div><calcite-action icon=information id=${referenceElement} slot=actions-end .text=${heading}></calcite-action></calcite-notice><calcite-popover closable label overlay-positioning=fixed placement=bottom reference-element=solutions-missing-privileges-notice ${ref(this._privilegePopoverRef)}><div class="padding-1 display-flex flex-direction-column">${// Leading messages
    this._getSpanMessages(leadingMessages, "padding-bottom-1")}<span class=${`padding-bottom-1-2 ${bulletedMessagesClass}`}>${this._translations.missingPrivilegesPopup.missingPrivilegesListHeading}</span>${// Bulleted messages
    this._getBulletedMessages(bulletedMessages)}${// Trailing messages
    this._getSpanMessages(trailingMessages, trailingMessagesClass)}</div></calcite-popover></div>`;
  }
  _getSpanMessages(messages, css2) {
    return messages.length > 0 ? messages.map((message) => {
      return html`<span class=${safeClassMap(css2)}>${message}</span>`;
    }) : "";
  }
  _getBulletedMessages(messages) {
    return messages.length > 0 ? html`<ul>${messages.map((p) => {
      return html`<li>${p}</li>`;
    })}</ul>` : "";
  }
  _getScreenshotsRow() {
    const showText = this._isScreenshotsRowExpanded ? this._translations.showLess : this._translations.showMore;
    const fabIcon = this._isScreenshotsRowExpanded ? "arrow-up" : "arrow-down";
    const showMoreClass = this._showScreenshotsShowMore ? "" : "display-none";
    return html`<calcite-accordion class="accordion-bg " icon-position=start scale=l appearance=transparent><calcite-accordion-item class="item-padding" expanded ${ref(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 ${ref(this._screenshotsElement)}>${this._getScreenshots()}</div><calcite-fab appearance=outline-fill class=${`align-self-center ${showMoreClass}`} .icon=${fabIcon} kind=neutral @click=${() => {
      this._screenshotsElement.value?.classList.toggle("expanded");
      this._isScreenshotsRowExpanded = this._screenshotsElement.value.classList.contains("expanded");
    }} .text=${showText} text-enabled></calcite-fab></div></calcite-panel></calcite-accordion-item></calcite-accordion>`;
  }
  _getScreenshots() {
    const screenshots = this._itemProperties?.preview.filter((ss) => ss.format === "image") || [];
    const context = this._configContextConsumer.value;
    return html`<calcite-card-group class="card-group" .label=${this._translations.solutionOverview}>${screenshots.reduce((prev, cur) => {
      const url = getItemResourceUrl(this.card?.id || "", cur.name, context.authentication);
      let url2;
      if (context.agoBasedEnterpriseSolutionsGroupId && context.isEnterprise) {
        url2 = getItemResourceUrl(this.card?.id || "", cur.name, void 0, context.agolPortalUrl);
      }
      this.card?.id ? prev.push(html`<calcite-card class="cursor-pointer" .label=${cur.alt} @click=${() => this._openScreenshotGallery(cur)}><div class="card-image-wrap" slot=thumbnail><img alt=${cur.alt ?? nothing} class="thumbnail card-image" slot=thumbnail src=${(url2 || url) ?? nothing}><div class="hover-text">${this._translations.openInGallery}</div></div></calcite-card>`) : prev.push("");
      return prev;
    }, [])}</calcite-card-group>`;
  }
  _openScreenshotGallery(screenshot) {
    this._telemetry?.logEvent({
      category: TELEMETRY_CATEGORY.SOLUTION_DETAILS,
      action: "Screenshot Gallery",
      dimensions: [
        this.card?.title || "",
        this.card?.deployCommonId || "",
        this.card?.deployVersion || ""
      ]
    });
    const dialog = this._screenshotsDialogRef.value;
    if (dialog) {
      dialog.screenshot = screenshot;
      dialog.open = true;
    }
  }
  _getOverviewRow() {
    return html`<calcite-accordion class="accordion-bg " icon-position=start scale=l appearance=transparent><calcite-accordion-item class="item-padding" expanded ${ref(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 html`<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 html`<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 html`<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() {
    const infoProducts = this._itemProperties?.infoProducts || [];
    return infoProducts.map((i) => {
      return html`<calcite-table-row><calcite-table-cell><p class="table-cell" .innerHTML=${sanitizeHTML(i.item) ?? ""}></p></calcite-table-cell><calcite-table-cell><p class="table-cell" .innerHTML=${sanitizeHTML(i.description) ?? ""}></p></calcite-table-cell><calcite-table-cell><p class="table-cell" .innerHTML=${sanitizeHTML(i.userType) ?? ""}></p></calcite-table-cell></calcite-table-row>`;
    });
  }
  _getReleaseNotesRow() {
    return html`<calcite-accordion class="accordion-bg " icon-position=start scale=l appearance=transparent><calcite-accordion-item class="item-padding" expanded ${ref(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 html`<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() {
    const releaseNotes = this._itemProperties?.releaseNotes || [];
    return releaseNotes?.map((n) => {
      return html`<calcite-table-row><calcite-table-cell><p class="table-cell" .innerHTML=${sanitizeHTML(n.version) ?? ""}></p></calcite-table-cell><calcite-table-cell><p class="table-cell" .innerHTML=${sanitizeHTML(n.description) ?? ""}></p></calcite-table-cell></calcite-table-row>`;
    });
  }
  _getRelatedResourcesRow(relatedResources) {
    return html`<calcite-accordion class="accordion-bg " icon-position=start scale=l appearance=transparent><calcite-accordion-item class="item-padding" expanded ${ref(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">${relatedResources.map(() => {
      html`<solution-resource-card></solution-resource-card>`;
    })}</div></calcite-accordion-item></calcite-accordion>`;
  }
  _getRelatedResources() {
    return [];
  }
  _getYouMayAlsoLikeRow(cards) {
    const showMoreFabClass = this._showYouMayAlsoLikeShowMore ? "" : "display-none";
    const showText = this._isYouMayAlsoLikeRowExpanded ? this._translations.showLess : this._translations.showMore;
    const fabIcon = this._isYouMayAlsoLikeRowExpanded ? "arrow-up" : "arrow-down";
    const height = this._isYouMayAlsoLikeRowExpanded ? "" : { "height": `${this._youMayAlsoLikeBaseHeight}px` };
    return html`<calcite-accordion class="accordion-bg " icon-position=start scale=l appearance=transparent><calcite-accordion-item class="item-padding" expanded ${ref(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=${safeStyleMap(height)} ${ref(this._youMayAlsoLikeElement)}><div class="display-flex flex-direction-row"><calcite-card-group class="card-group" .label=${this._translations.youMayAlsoLike}>${cards.map((card, i) => {
      return html`<solution-details-card .id=${`you-may-also-like-${i}`} .card=${card} 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 ${showMoreFabClass}`} .icon=${fabIcon} kind=inverse @click=${() => {
      this._youMayAlsoLikeElement.value?.classList.toggle("expanded");
      this._isYouMayAlsoLikeRowExpanded = this._youMayAlsoLikeElement.value.classList.contains("expanded");
    }} .text=${showText} text-enabled></calcite-fab></div></calcite-accordion-item></calcite-accordion>`;
  }
  _getYouMayAlsoLikeCards() {
    const relatedSolutions = this._itemProperties?.relatedSolutions || [];
    return this._allCards.filter((c) => relatedSolutions.indexOf(c.deployCommonId) > -1);
  }
  _getTermsOfUseRow() {
    return html`<calcite-accordion class="accordion-bg " icon-position=start scale=l appearance=transparent><calcite-accordion-item class="item-padding" expanded ${ref(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 dialog = this._deployDialogRef.value;
      if (dialog) {
        this._telemetry?.logEvent({
          category: TELEMETRY_CATEGORY.SOLUTION_DETAILS,
          action: "Deploy Dialog Opened",
          dimensions: [
            this.card?.title || "",
            this.card?.deployCommonId || "",
            this.card?.deployVersion || ""
          ]
        });
        dialog.userOptions = this._userOptions;
        dialog.open = true;
      }
    } else {
      this._configContextConsumer.value.authentication.signIn("deploy");
    }
  }
  _openUrl(url) {
    window.open(url, "_blank");
  }
  _handleWatchDemoClick(url) {
    this._telemetry?.logEvent({
      category: TELEMETRY_CATEGORY.SOLUTION_DETAILS,
      action: "Watch Demo",
      dimensions: [
        this.card?.title || "",
        this.card?.deployCommonId || "",
        this.card?.deployVersion || ""
      ]
    });
    this._openUrl(url);
  }
  _handleLearnMoreClick() {
    this._telemetry?.logEvent({
      category: TELEMETRY_CATEGORY.SOLUTION_DETAILS,
      action: "Open Help",
      dimensions: [
        this.card?.title || "",
        this.card?.deployCommonId || "",
        this.card?.deployVersion || ""
      ]
    });
    this._openUrl(this.card?.learnMoreUrl || "");
  }
  async _detailsCardSelected(evt) {
    this.card = evt.detail;
    this.el.scrollIntoView(true);
    this._onResize();
    this._missingPrivilegeMessages = void 0;
    await this._getItemData();
    this._expandAccordions();
  }
  _expandAccordions() {
    if (this._overviewAccordionItemElement.value) {
      this._overviewAccordionItemElement.value.expanded = true;
    }
    if (this._releaseNotesAccordionItemElement.value) {
      this._releaseNotesAccordionItemElement.value.expanded = true;
    }
    if (this._relatedResourcesAccordionItemElement.value) {
      this._relatedResourcesAccordionItemElement.value.expanded = true;
    }
    if (this._screenshotsAccordionItemElement.value) {
      this._screenshotsAccordionItemElement.value.expanded = true;
    }
    if (this._termsOfUseAccordionItemElement.value) {
      this._termsOfUseAccordionItemElement.value.expanded = true;
    }
    if (this._youMayAlsoLikeAccordionItemElement.value) {
      this._youMayAlsoLikeAccordionItemElement.value.expanded = true;
    }
  }
  async _getItemData() {
    const context = this._configContextConsumer.value;
    const userSession = context?.agoBasedEnterpriseSolutionsGroupId && context?.isEnterprise ? context.anonAgolSession : context?.userSession;
    const solutionData = await getItemDataAsJson(this.card.id, userSession);
    const item = await getItem(this.card.id, userSession);
    this._itemProperties = item.properties;
    this.itemPropertiesFetched.emit(this._itemProperties);
    const privilegeList = getRequiredSolutionPrivileges(solutionData, this.card.typeKeywords, context?.authentication);
    this._privileges = userSession.username ? privilegeList : [];
    this._userPrivileges = context?.authentication && context?.userSession ? await getUserPrivileges(context.authentication, context.userSession, context.authentication.PortalUserPrivileges) : [];
    const privilegesDiff = this._privileges.filter((p) => !this._userPrivileges.includes(p));
    this._missingPrivilegeMessages = getPrivilegeMessages(this._translations, privilegesDiff);
    this._isDeployDisabled = this._missingPrivilegeMessages && (this._missingPrivilegeMessages.leadingMessages.length > 0 || this._missingPrivilegeMessages.bulletedMessages.length > 0 || this._missingPrivilegeMessages.trailingMessages.length > 0);
    const userOptions = solutionData.params ? await this.formatParams(solutionData.params) : [];
    this._userOptions = userOptions;
    this._templates = solutionData.templates;
    this.templatesFetched.emit(solutionData.templates);
    this._checkUrlParametersForAutoDeployment();
    this._isLoaded = true;
    if (this._showLoader) {
      this._showLoader = false;
      if (!this._isDeployDisabled) {
        this._openDeploy();
      }
    }
  }
  formatParams(params) {
    const userSession = this._configContextConsumer.value.userSession;
    const userOptions = [];
    const paramKeys = params ? Object.keys(params) : [];
    const userOption = {
      id: "",
      props: [],
      accordionDisplay: false
    };
    if (paramKeys.length > 0) {
      const existingItemDefs = [];
      paramKeys.forEach((id) => {
        const p = params[id];
        if (p.valueType && p.valueType.toLowerCase() === "itemid") {
          existingItemDefs.push(this._findExistingItem(id, "Feature Service", userSession.username || ""));
        }
      });
      return Promise.all(existingItemDefs).then((results) => {
        const idHash = {};
        results.forEach((r) => {
          if (r.query && r.results && r.results.length > 0) {
            const sourceId = r.query.split(" ")[0].replace("typekeywords:source-", "");
            idHash[sourceId] = {
              resultId: r.results[0].id,
              response: r.results[0]
            };
          }
        });
        paramKeys.forEach((id) => {
          if (id === "serviceLearnMore") {
            this._configureLearnMore = params[id];
            alert(this._configureLearnMore);
            delete params[id];
            return;
          }
          if (params[id].enterpriseIDMapping) {
            this._customDeploymentMappings[id] = params[id].enterpriseIDMapping;
          }
          userOption.id = id;
          if (idHash[id]) {
            params[id].existingItemId = idHash[id].resultId;
            this.updateUserProp(params[id], idHash[id].response);
          }
          this.updateOption(params[id], userOption, id);
        });
        userOptions.push(userOption);
        return Promise.resolve(userOptions);
      }).catch(() => Promise.resolve([]));
    } else {
      return Promise.resolve([]);
    }
  }
  _findExistingItem(itemId, type, userName) {
    const userSession = this._configContextConsumer.value.userSession;
    return _findExistingItem(`typekeywords:source-${itemId} type:${type} owner:${userName}`, userSession);
  }
  updateUserProp(userProp, response) {
    const isLayer = userProp.itemType?.toLowerCase() === "feature service";
    const responseTest = new RegExp(isLayer ? this._regexFsUrl : userProp.itemType, "iu");
    const responseProp = getPropWithDefault(response, isLayer ? "url" : "type", "") || "";
    const validProp = responseProp !== "" && responseTest.test(responseProp);
    userProp.responseValue = validProp ? responseProp : "";
    userProp.name = validProp ? getProp(response, "name") || "" : "";
    userProp.title = validProp ? getProp(response, "title") || "" : "";
    userProp.itemType = validProp ? getProp(response, "type") : userProp.itemType;
    userProp.validId = validProp;
    userProp.itemUrl = getItemUrl(response.id, this._configContextConsumer.value.authentication);
    return validProp;
  }
  updateOption(v, userOption, id) {
    const defValue = v.default || "";
    const outType = typeof defValue;
    const defaultValue = defValue.toString();
    this._setFeatureServiceProps(v);
    const validation = this.getValidation(v, defaultValue);
    userOption.props.push({
      id,
      outType,
      prop: id,
      itemType: v.itemType || "",
      responseValue: v.responseValue || "",
      label: v.label || "",
      choices: v.choices || [],
      valueType: v.valueType.toLowerCase(),
      attributes: v.attributes || {},
      value: v.existingItemId && v.valueType.toLowerCase() === "itemid" ? v.existingItemId : defaultValue,
      default: defaultValue,
      srSearchText: defaultValue,
      autoSelect: defaultValue !== "",
      ...validation,
      loading: false,
      validId: true,
      tooltip: v.tooltip || "",
      name: v.name || "",
      title: v.title || "",
      itemUrl: v.itemUrl || ""
    });
  }
  _setFeatureServiceProps(v) {
    if (v.valueType && v.valueType.toLowerCase() === "itemid") {
      setCreateProp(v, "attributes.required", "true");
    }
  }
  getValidation(v, defaultValue) {
    let expression = "";
    let message = getProp(v, "validation.message") || "";
    let valid = true;
    if (getProp(v, "attributes.required") === "true") {
      expression = getPropWithDefault(v, "validation.expression", "\\S{1,}");
      const regEx = new RegExp(expression);
      valid = regEx.test(defaultValue);
    }
    if (v.valueType && v.valueType.toLowerCase() === "itemid") {
      expression = this._regexID;
      message = this._translations.configure.invalidID;
    }
    return {
      valid,
      validation: {
        expression,
        message
      }
    };
  }
  _allCardsFetched(event) {
    this._allCards = event.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(true);
    this._isScreenshotsRowExpanded = false;
    this._showScreenshotsShowMore = false;
    this._screenshotsElement.value?.classList.remove("expanded");
    this._isYouMayAlsoLikeRowExpanded = false;
    this._showYouMayAlsoLikeShowMore = false;
    this._youMayAlsoLikeElement.value?.classList.remove("expanded");
    if (this._privilegePopoverRef.value?.open) {
      this._privilegePopoverRef.value.open = false;
    }
    this._isDeployDisabled = false;
    this._isLoaded = false;
    this._showLoader = false;
    this._expandAccordions();
  }
  _deployProgressStart(abortController) {
    this._deploymentStartTime = Date.now();
    this._telemetry?.logEvent({
      category: TELEMETRY_CATEGORY.SOLUTION_DETAILS,
      action: "Deploy Started",
      dimensions: [
        this.card?.title || "",
        this.card?.deployCommonId || "",
        this.card?.deployVersion || ""
      ]
    });
    if (this._deployingDialogRef.value) {
      this._deployingDialogRef.value.open = true;
      this._deployingDialogRef.value.abortController = abortController.detail;
    }
    if (this._deployDialogRef.value) {
      this._deployDialogRef.value.classList.add("display-none");
    }
  }
  _deployProgessUpdated(evt) {
    const update = evt.detail;
    this._deployingDialogRef.value.deploymentProgress = update.progress;
  }
  _closeDialogs(keepDeployDialogOpen = false) {
    if (this._cancellationStartTime !== null) {
      const cancelCompletionDuration = calculateDuration(this._cancellationStartTime);
      this._telemetry?.logEvent({
        category: TELEMETRY_CATEGORY.SOLUTION_DETAILS,
        action: "Deploy Canceled",
        dimensions: [
          this.card?.title || "",
          this.card?.deployCommonId || "",
          this.card?.deployVersion || ""
        ],
        metrics: [this._deployToCancelDuration, cancelCompletionDuration]
      });
      this._cancellationStartTime = null;
      this._deployToCancelDuration = 0;
    }
    this._deployingDialogRef.value.close();
    if (keepDeployDialogOpen) {
      this._deployDialogRef.value.open = true;
    } else {
      this._deployDialogRef.value.close();
    }
    this._deployDialogRef.value.classList.remove("display-none");
  }
  _handleDeployAppTabSelected(evt) {
    const activeTab = evt.detail;
    if (activeTab === "details") {
      this.sortTypeChanged.emit("");
    }
  }
  _checkPermissionsBeforeDeploy() {
    if (this._isLoaded) {
      this._openDeploy();
    } else {
      if (this._configContextConsumer.value.authentication?.IsSignedIn) {
        this._showLoader = true;
      } else {
        this._openDeploy();
      }
    }
  }
}
customElement("solution-details-panel", SolutionDetailsPanel);
export {
  SolutionDetailsPanel
};
