"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var n=require("../../../../_virtual/jsx-runtime.js"),m=require("../../../Chip/Chip.js"),v=require("../../utils.js"),b=require("./styles.js");function f({selectors:t,handleChange:u,narrow:r,selectedSelector:c,"data-testid":d}){const s=e=>()=>{const l=t==null?void 0:t.find(a=>a.value===e);l&&(u==null||u(l))};return n.jsxRuntimeExports.jsx(b.SelectorsWrapper,{narrow:!!r,"data-testid":d,children:t==null?void 0:t.map(e=>n.jsxRuntimeExports.jsx(m.Chip,{label:e.label||"",selected:e.value===c.value,disabled:e.disabled,variant:"primary","data-testid":`${d}-${e.value}`,onClick:s(e.value)},e.label))})}function o(t){var s;const u=t.defaultSelectorValues&&Object.entries(t.defaultSelectorValues),r=v.getSelectors(v.commonDateSelectors),c=r.reduce((e,l)=>{if(u){const a=u.find(i=>i[0].toUpperCase()===l.value);if(a!=null&&a[1]){const i={...l,label:a[1].label};return[...e,i]}else if(a&&a[1]===null)return[...e]}return[...e,l]},[]);function d(e,l){if(l){const a=r.find(i=>i.value===e);a&&t.handleChange(a)}else if(t.customSelectors){const a=t.customSelectors.find(i=>i.value===e);a&&t.handleChange(a)}}return n.jsxRuntimeExports.jsxs(b.SelectorsWrapper,{narrow:!!t.narrow,"data-testid":t["data-testid"],children:[c.map(e=>n.jsxRuntimeExports.jsx(m.Chip,{label:e.label||"",selected:e.value===t.selectedSelector.value,disabled:e.disabled,variant:"primary","data-testid":`${t["data-testid"]}-${e.value}`,onClick:()=>d(e.value,!0)},e.label)),(s=t.customSelectors)==null?void 0:s.map(e=>n.jsxRuntimeExports.jsx(m.Chip,{label:e.label,selected:e.value===t.selectedSelector.value,disabled:e.disabled,variant:"primary","data-testid":`${t["data-testid"]}-${e.value}`,onClick:()=>d(e.value,!1)},e.label))]})}exports.Selectors=f;exports.SelectorsOld=o;
