import{r as e,c as t,h as s,a as i}from"./p-DtIEDtZ8.js";import{d as r,t as o}from"./p-DcmcuUOA.js";import{i as a}from"./p-Bw2fh5LT.js";const l=":root{--ifx-font-family:\"Source Sans 3\", 'Arial, sans-serif'}.group{display:flex;flex-direction:column;justify-content:space-between}.group__label{font-size:1rem;color:#1D1D1D;line-height:1.5rem;font-weight:400}.group__label:empty{display:none}.group__label .required{color:#575352;margin-left:4px}.group__label .required.error{color:#CD002F}.group__controls{display:flex;flex-wrap:wrap}.group__controls ::slotted(*){margin-left:-1px;margin-top:-1px}.group__caption{margin-top:4px;display:flex;align-items:center;gap:8px;font-weight:400;font-size:0.75rem;line-height:1rem}.group__caption.error{color:#CD002F}";const n=class{constructor(s){e(this,s);this.ifxChange=t(this,"ifxChange",7);this.caption="";this.label="";this.size="regular";this.required=false;this.error=false;this.selectedValue=""}onSegmentSelect(e){const{previousValue:t,selectedValue:s}=this.unselectPreviousSegment(e.detail);this.selectedValue=s;this.ifxChange.emit({previousValue:t,selectedValue:s})}unselectPreviousSegment(e){let t;let s;const i=this.getSegments();i.forEach((i=>{if(i.selected){if(i.segmentIndex!==e){i.selected=false;t=i.value}else{s=i.value}}}));return{previousValue:t,selectedValue:s}}getSegments(){return this.SegmentedControl.querySelectorAll("ifx-segment")}setActiveSegment(){const e=this.getSegments();let t=false;e.forEach(((e,s)=>{e.segmentIndex=s;if(t){if(e.selected)e.selected=false}else{if(e.selected){t=true;this.selectedValue=e.value}}}))}setSegmentSize(){const e=this.getSegments();e.forEach((e=>{e.shadowRoot.querySelector(".segment").classList.add(`segment--${this.size}`)}))}async componentDidLoad(){if(!a(this.SegmentedControl)){const e=r();o("ifx-segmented-control",await e)}this.setActiveSegment()}render(){return s("div",{key:"74bfd584af640b44d4fdeaa674e0df4003d58383","aria-value":this.selectedValue,"aria-label":"segmented control",class:"group"},s("div",{key:"233e32decc7484857fe34397d10191fa60f101ff",class:"group__label"},this.label.trim(),this.required&&this.label.trim().toLowerCase()!==""&&s("span",{key:"59e000fd4bf388832d2dc31f2487f90a555aedf7",class:`required ${this.error?"error":""}`},"*")),s("div",{key:"4368841e6a763be4407ada54434297b699e8d2b8",class:"group__controls"},s("slot",{key:"f4d60a5f83969042e4198aa67687628b25dbf68b"})),this.caption.trim()&&s("div",{key:"4c46eec275fea48fd95df56519739fd2ba97b807",class:`group__caption ${this.error?"error":""}`},s("ifx-icon",{key:"656b6becac2b36bb32bf7ba8b4b247fe69e1a212",icon:"c-info-16"})," ",this.caption.trim()))}componentDidRender(){this.setSegmentSize()}get SegmentedControl(){return i(this)}};n.style=l;export{n as ifx_segmented_control};
//# sourceMappingURL=p-f5811026.entry.js.map