/* COPYRIGHT Esri - https://js.arcgis.com/1.2/LICENSE.txt */
import a from"./HBC3TKGZ.js";import{a as m,b as S}from"./W4YXXJAS.js";import{b as c}from"./S7VQX4XX.js";import"./4Q4PZB7R.js";import{a as g}from"./XN2LWKJE.js";import"./4BPRM7CL.js";import"./NIL6NWG5.js";import"./ED6SUP22.js";import"./E6P6PYNW.js";import"./IKKBLHLZ.js";import"./CUA2IUXX.js";import"./4UZDZNJD.js";import"./KOTG6W5Z.js";import"./6SC7YR5Y.js";import"./Z6NOHRUL.js";import"./GVM4XYEI.js";import"./NGDVSE4Z.js";import"./BTNJZZQQ.js";import"./ZYQ4P2ON.js";import"./5MKH4QDV.js";import"./3GWWHA4S.js";import"./3YYHZQJB.js";import"./JEJ23R3P.js";import"./TONS7KZJ.js";import"./Q62UEPOL.js";import"./44A5XEM4.js";import{b as u}from"./ODCCVHGI.js";import{H as d,L as l,h as p,i as r,r as n}from"./42WFQ3AX.js";import"./3QPJ2JCA.js";export default $arcgis.t(([{c:y}])=>{var _=p`/** @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.
 */

.toolbar-sizing {
  display: flex;
  align-items: center;
  padding-right: 0px;
  padding-left: 0px;
  margin-left: auto;
  margin-right: auto;
  box-sizing: border-box;
  height: 65px;
}

.flex-row {
  display: flex;
  flex-direction: row;
}

.flex-grow-1 {
  flex-grow: 1;
}

calcite-input-text {
  --calcite-color-focus: transparent;
  --calcite-input-text-border-color: transparent;
  --calcite-color-border-input: transparent;
  --calcite-color-brand: transparent;
  display: grid;
  block-size: 65px;
  box-sizing: border-box;
  border-bottom: 2px solid transparent;
}

calcite-dropdown {
  --calcite-color-focus: transparent;
}

@media (prefers-color-scheme: dark) {
  calcite-input-text:focus {
    border-bottom: 2px solid #009AF2;
  }
}

@media (prefers-color-scheme: light) {
  calcite-input-text:focus {
    border-bottom: 2px solid #007AC2;
  }
}

.focus-color {
  --calcite-color-focus: transparent;
}`,h=class extends d{constructor(){super(),this.defaultSortType="relevance",this.isOrgSolutions=!1,this.isMobile=!1,this._activeSearchSortSettings=[{scope:"all-solutions",settings:{enabled:!0,isOrgSolutions:!1,searchTerm:"",sortType:"relevance"}},{scope:"deployments",settings:{enabled:!0,isOrgSolutions:!1,searchTerm:"",sortType:"created"}}],this._isMobile=!1,this._isOrgAdmin=!1,this._translations=g({name:"solutions-searchsort-toolbar",blocking:!0}),this._configContextConsumer=c({context:S,subscribe:!0,callback:async t=>{t&&(this._isOrgAdmin=t.authentication?.PortalUserSubset?.role==="org_admin"||y(t.authentication))}}),this._isMobileContextConsumer=c({context:m,subscribe:!0,callback:t=>this._isMobile=t}),this.searchChanged=n(),this.sortTypeChanged=n(),this.toggleFilter=n(),this.updateUrlParams=n(),this.listenOn(window,"deployAppTabSelected",t=>{let e=t.detail;this.scope=e,this._updateUrlParams(t)}),this.listenOn(window,"detailsCardSelected",()=>{this.scope=void 0}),this.listenOn(window,"deployedCardSelected",()=>{this.scope=void 0}),this.listenOn(window,"searchTermSet",t=>{let e=t.detail;this.scope=e.scope,this.changeSearchFilter(e.searchTerm,!1)}),this.listenOn(window,"sortTypeSet",t=>{let e=t.detail;this.scope=e.scope,this.sortChanged(e.sortType,!1)})}static{this.properties={defaultSortType:[0,{type:String,attribute:"default-sort-type"},{}],isOrgSolutions:[5,{},{type:Boolean}],isMobile:[5,{},{type:Boolean}],scope:1,_activeSearchSortSettings:[16,{},{state:!0}],_isMobile:[16,{},{state:!0}],_isOrgAdmin:[16,{},{state:!0}],_translations:[16,{},{state:!0}]}}static{this.styles=_}changeOwnerFilter(t){this.isOrgSolutions=!t,this._activeSearchSortSettings=this._activeSearchSortSettings.map(s=>s.scope===this.scope?{...s,settings:{...s.settings,isOrgSolutions:this.isOrgSolutions}}:s);let e={displayValue:this.isOrgSolutions?this._translations.myOrgSolutions:this._translations.mySolutions,type:"owner",value:this.isOrgSolutions?"My organization's solutions":"My solutions"};this.searchChanged.emit({option:e,scope:this.scope})}changeSearchFilter(t,e,s){let i=this._activeSearchSortSettings.map(a=>a.scope===this.scope?{...a,settings:{...a.settings,searchTerm:t}}:a),o=JSON.stringify(this._activeSearchSortSettings)!==JSON.stringify(i);this._activeSearchSortSettings=i,e&&o&&this.searchChanged.emit({option:{searchTerm:t},scope:this.scope}),s&&(this._searchTelemetryTimer&&window.clearTimeout(this._searchTelemetryTimer),this._searchTelemetryTimer=window.setTimeout(()=>{this.searchChanged.emit({option:{searchTerm:t},scope:this.scope,logSearchTelemetry:!0})},1e3))}sortChanged(t,e){this._activeSearchSortSettings=this._activeSearchSortSettings.map(s=>s.scope===this.scope?{...s,settings:{...s.settings,sortType:t}}:s),e&&this.sortTypeChanged.emit({sortType:t,scope:this.scope})}async load(){this._isMobileContextConsumer.value&&(this._isMobile=this._isMobileContextConsumer.value)}render(){let t=this.scope==="all-solutions"||this.scope==="deployments"&&this._configContextConsumer.value?.authentication?.IsSignedIn,e=t?this._getCurrentScopeSetting():void 0,s=this.scope==="deployments"?this._translations.search.deployments:this._translations.search.solutions;return t?r`<div class="flex-row toolbar-sizing"><calcite-input-text class="flex-grow-1" clearable icon=search @keyup=${i=>{let o=i.target;i.key==="Enter"?this.changeSearchFilter(o.value,!0,!1):(o.value.length>=3||o.value.length===0)&&this.changeSearchFilter(o.value,o.value.length>=3||o.value.length===0,!0)}} @blur=${i=>{let o=i.target;this.changeSearchFilter(o.value,!0,!1)}} .placeholder=${s} scale=l slot=content-top .value=${e?.searchTerm}></calcite-input-text>${this._isMobile&&this.scope==="all-solutions"?r`<calcite-button appearance=transparent class="focus-color" icon-start=filter kind=neutral .label=${this._translations.showFilters} @click=${this._toggleFilter}></calcite-button>`:""}${this.scope==="deployments"&&this._isOrgAdmin&&this._renderOwnerBlock()||""}${this._renderDropdown()}</div>`:""}_renderOwnerBlock(){return r`<calcite-dropdown width=m overlay-positioning=fixed><calcite-button appearance=transparent class="header-button-padding" .iconStart=${this.isOrgSolutions?"organization":"user"} kind=neutral slot=trigger>${this.isMobile?"":this.isOrgSolutions?this._translations.myOrgSolutions:this._translations.mySolutions}</calcite-button><calcite-dropdown-group group-title=${this._translations.filterBy??l}><calcite-dropdown-item icon-start=user @click=${()=>{this.changeOwnerFilter(!0)}} .selected=${!this.isOrgSolutions}>${this._translations.mySolutions}</calcite-dropdown-item><calcite-dropdown-item icon-start=organization @click=${()=>{this.changeOwnerFilter(!1)}} .selected=${this.isOrgSolutions}>${this._translations.myOrgSolutions}</calcite-dropdown-item></calcite-dropdown-group></calcite-dropdown>`}_renderDropdown(){let t=[];t=[{displayValue:this._translations.sortByRelevance,sortType:"relevance"},{displayValue:this._translations.sortByTitle,sortType:"title"}],this.scope==="deployments"?t.push({displayValue:this._translations.sortByDateDeployed,sortType:"created"}):(t.push({displayValue:this._translations.sortByNew,sortType:"new"}),t.push({displayValue:this._translations.sortByUpdated,sortType:"updated"}),this._configContextConsumer.value?.authentication?.IsSignedIn&&t.push({displayValue:this._translations.sortBySuggestedForYou,sortType:"suggested"}));let e=this._getCurrentScopeSetting();return r`<calcite-dropdown width=m><calcite-button appearance=transparent class="header-button-padding" icon-start=sort-descending kind=neutral slot=trigger>${this.isMobile?"":this._getString(e.sortType)}</calcite-button><calcite-dropdown-group group-title=${this._translations.chooseSortType??l}>${t.map(s=>this._getDropdownItem(s.displayValue,s.sortType))}</calcite-dropdown-group></calcite-dropdown>`}_getDropdownItem(t,e){return this._getCurrentScopeSetting().sortType!==e?r`<calcite-dropdown-item @click=${()=>this.sortChanged(e,!0)}>${t}</calcite-dropdown-item>`:r`<calcite-dropdown-item @click=${()=>this.sortChanged(e,!0)} selected>${t}</calcite-dropdown-item>`}_getString(t){let e="";switch(t){case"new":e=this._translations.sortByNew;break;case"relevance":e=this._translations.sortByRelevance;break;case"suggested":e=this._translations.sortBySuggestedForYou;break;case"title":e=this._translations.sortByTitle;break;case"updated":e=this._translations.sortByUpdated;break;case"created":e=this._translations.sortByDateDeployed;break}return e}_getCurrentScopeSetting(){return this._activeSearchSortSettings.filter(e=>e.scope===this.scope)[0].settings}_toggleFilter(){this.toggleFilter.emit()}_updateUrlParams(t){let e=t.detail,s;this._activeSearchSortSettings.some(i=>i.scope===e?(s=i,!0):!1),s&&this.updateUrlParams.emit({settings:s,scope:s.scope})}};u("solutions-searchsort-toolbar",h);return h},a)