/*! All material copyright GeoScene, All Rights Reserved, unless otherwise specified.
See https://js.geoscene.cn/4.33/geoscene/copyright.txt for details.
v4.33.18 */
import{a as o}from"./PBTK3Z7K.js";import{a as _}from"./LL7T22QC.js";import{B as d,E as m,P as p,Q as l,U as g,a as n,j as h,k as t}from"./3VKC6PRK.js";export default $geoscene.t(([{watch:R},{substitute:$}])=>{var w="geoscene-search-result-renderer",M={base:w,moreResults:`${w}__more-results`},b=h`@layer{.geoscene-search-result-renderer calcite-block,.geoscene-search-result-renderer calcite-block[expanded]{margin-block:0;margin-block-start:var(--calcite-spacing-md);border:0}}`,a=class extends p{constructor(){super(...arguments),this._resultCount=0,this._showMoreResultsOpen=!1,this.autoDestroyDisabled=!1,this.geosceneReady=d()}static{this.properties={_results:16,_resultCount:16,_selectedResult:16,_showMoreResultsOpen:16,messages:0,autoDestroyDisabled:5,viewModel:0}}static{this.styles=b}static{this.shadowRootOptions=m}async destroy(){await this.manager.destroy()}loaded(){this.manager.onLifecycle(()=>[R(()=>[this.viewModel?.results,this.viewModel?.resultCount],()=>{this._results=this.viewModel?.results,this._resultCount=this.viewModel?.resultCount??0,this._showMoreResultsOpen=!1},{initial:!0}),R(()=>this.viewModel?.selectedResult,e=>this._selectedResult=e,{initial:!0})])}_selectResult(e){this._showMoreResultsOpen=!1,this.viewModel?.select(e)}_getSourceName(e,s){return s===-1?this.messages?.all??"":e.name}_toggleShowMoreResults(e){this._showMoreResultsOpen=e;let s=this.viewModel?.view?.popup;s&&"reposition"in s&&s.reposition()}render(){return t`<div class=${l(n(M.base,_.widget))}>${this._selectedResult?.name??""}${this._renderMoreResults()}</div>`}_renderMoreResults(){let{_resultCount:e,_results:s}=this;return!e||e<2||!s?null:t`<calcite-block class=${l(M.moreResults)} collapsible .expanded=${this._showMoreResultsOpen} .heading=${$(this.messages?.showMoreResults??"",{count:e-1})} @calciteBlockClose=${()=>this._toggleShowMoreResults(!1)} @calciteBlockOpen=${()=>this._toggleShowMoreResults(!0)}>${s.map(r=>this._renderMoreResultsList(r,s?.length>1))}</calcite-block>`}_renderMoreResultsList(e,s){let{results:r}=e;if(!(r?.length??0)||!r)return null;let c=this._getSourceName(e.source,e.sourceIndex),u=r.filter(i=>i!==this._selectedResult).map(i=>this._renderListItem(i));return t`<calcite-list .label=${c}>${s?o(`group-${e.sourceIndex}`,t`<calcite-list-item-group .heading=${c}>${u}</calcite-list-item-group>`):u}</calcite-list>`}_renderListItem(e){return o(`result-${e.sourceIndex}-${e.key}`,t`<calcite-list-item .label=${e.name} @calciteListItemSelect=${()=>this._selectResult(e)}></calcite-list-item>`)}};g("geoscene-search-result-renderer",a);return a},"core/reactiveUtils","intl")