/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["exports","../support/Heading","../support/widgetUtils","../support/jsxFactory"],(function(e,t,i,s){"use strict";const n={base:"esri-item-list",list:"esri-item-list__list",group:"esri-item-list__group",scroller:"esri-item-list__scroller",groupHeader:"esri-item-list__group__header",item:"esri-item-list__list-item",itemSelected:"esri-item-list__list-item--selected",itemContainer:"esri-item-list__list-item-container",itemLabel:"esri-item-list__list-item-label",noMatchesMessage:"esri-item-list__no-matches-message",noItemsMessage:"esri-item-list__no-items-message",filterContainer:"esri-item-list__filter-container",filterContainerSticky:"esri-item-list__filter-container--sticky",filterPlaceholder:"esri-item-list__filter-placeholder",filterInput:"esri-item-list__filter-input",filterPlaceholderText:"esri-item-list__filter-placeholder-text",searchIcon:"esri-icon-search",widget:"esri-widget",input:"esri-input"};function l(e){var t;const{id:i,identify:n,filterEnabled:l=!0,headingLevel:r=4,items:c,selectedItem:m,messages:u,filterText:d="",onFilterChange:g,renderIcon:I,onItemMouseLeave:f,onItemMouseEnter:_,onItemSelect:p}=e,v=null==(t=e.enableListScroll)||t;return s.tsx("div",{key:i},l?a({filterText:d,messages:u,onFilterChange:g,id:i}):null,o({enableListScroll:v,identify:n,items:c,selectedItem:m,messages:u,filterText:d,headingLevel:r,renderIcon:I,onItemMouseLeave:f,onItemMouseEnter:_,onItemSelect:p}))}function r(e){return!!e.items}function o(e){const{headingLevel:t,identify:i,items:l,renderIcon:o,filterText:a,onItemMouseLeave:u,onItemMouseEnter:d,onItemSelect:g,selectedItem:I}=e,f=e.enableListScroll?n.scroller:null;return 0===l.length?s.tsx("div",{class:n.noMatchesMessage,key:"no-matches"},e.messages.noMatches):s.tsx("div",{class:f,key:"item-container"},l.map((e=>r(e)?m({group:e,filterText:a,headingLevel:t,identify:i,onItemMouseLeave:u,onItemMouseEnter:d,onItemSelect:g,renderIcon:o,selectedItem:I}):c({item:e,identify:i,grouped:!0,onItemMouseLeave:u,onItemMouseEnter:d,onItemSelect:g,renderIcon:o,filterText:a,selectedItem:I}))))}function a(e){const{messages:t,filterText:i,enableListScroll:l}=e;return s.tsx("div",{key:"filter",class:l?null:n.filterContainerSticky},s.tsx("calcite-input",{onCalciteInputInput:t=>{const i=t.currentTarget;e.onFilterChange&&e.onFilterChange(i.value)},placeholder:t.filterPlaceholder,value:i,type:"search"}))}function c(e){const{identify:t,item:l,selectedItem:r,grouped:o,onItemSelect:a,onItemMouseEnter:c,onItemMouseLeave:m,renderIcon:u}=e,d=`${(null==t?void 0:t(l))||l.id}__${l.label}`,g=r?`${(null==t?void 0:t(r))||r.id}__${r.label}`:"";return s.tsx("calcite-list-item",{"aria-level":o?"2":"","data-item":l,key:d,class:i.classes(n.item,d===g?n.itemSelected:""),label:l.label,onclick:e=>{const t=e.currentTarget["data-item"];a&&a(t)},onmouseenter:e=>{const t=e.currentTarget["data-item"];c&&c(t)},onkeydown:e=>{if(!i.isActivationKey(e.key))return;const t=e.currentTarget["data-item"];a&&a(t)},onmouseleave:e=>{const t=e.currentTarget["data-item"];m&&m(t)},tabIndex:0},s.tsx("div",{slot:"content-start"},u&&u({item:l})))}function m(e){const{group:i,identify:l,onItemMouseLeave:r,onItemMouseEnter:o,onItemSelect:a,filterText:m,renderIcon:u,selectedItem:d,headingLevel:g}=e;return s.tsx("div",{class:n.group,key:i.label},s.tsx(t.Heading,{level:g,class:n.groupHeader},i.label),i.items.map((e=>c({item:e,identify:l,grouped:!0,onItemMouseLeave:r,onItemMouseEnter:o,onItemSelect:a,renderIcon:u,filterText:m,selectedItem:d}))))}function u(e){const{match:t,text:i}=e;let l=null;if(t){const e=i.toLowerCase(),n=t.toLowerCase(),r=e.indexOf(n);if(-1===r)l=i;else{const e=i.substring(0,r),n=i.substr(r,t.length),o=i.substring(r+t.length);l=s.tsx("span",null,e,s.tsx("strong",null,n),o)}}else l=i;return s.tsx("span",{class:n.itemLabel},l)}e.ItemList=l,e.renderGroup=m,e.renderItem=c,e.renderLabel=u,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
