import{p as t,H as e,c as i,h as s,t as a}from"./p-Bpcl2TqF.js";import{i as r,d as p,t as c}from"./p-94ZtGp9D.js";const n=()=>`.stepper{display:flex;align-items:center}.stepper.compact{align-items:center;gap:8px}.stepper.compact.compact-right{flex-direction:row-reverse;text-align:left}.stepper.compact .stepper-wrapper{width:unset;flex-direction:column}.stepper.vertical{height:100%}.stepper.vertical .stepper-wrapper{flex-direction:column;width:unset;height:100%}.stepper-wrapper{display:flex;flex-direction:row;width:100%}.stepper-wrapper ::slotted(*){display:flex;flex:1;justify-content:flex-start}.stepper-progress{display:flex;justify-content:center;align-items:center;font:600 0.875rem/1.25rem "Source Sans 3";min-width:56px;height:56px;border-radius:9999px;background:conic-gradient(#0A8276 var(--pb, 0%), #BFBBBB 0)}.stepper-progress .progress-detail{display:flex;justify-content:center;align-items:center;text-align:center;width:48px;height:48px;border-radius:9999px;background:white}`;const o=t(class t extends e{constructor(t){super();if(t!==false){this.__registerHost()}this.__attachShadow();this.ifxChange=i(this,"ifxChange",7)}get el(){return this}ifxChange;activeStep=1;indicatorPosition="left";showStepNumber=false;variant="default";ariaLabel;ariaCurrent;stepsCount;shouldEmitEvent=true;emittedByClick=false;onStepChange(t){const e=this.getSteps();const i=e[t.detail.previousActiveStep-1];if(i&&!i.complete){i.setAttribute("error","true")}}handleActiveStep(t,e){const i=this.getSteps();if(!this.shouldEmitEvent){this.shouldEmitEvent=true;return}if(i[t-1]){if(!i[t-1].disabled){this.emitIfxChange(t,e)}else{if(t<e){let s=t;this.shouldEmitEvent=false;while(s>=1&&i[s-1].disabled)s--;if(s<1){this.activeStep=e}else{this.emitIfxChange(s,e);this.activeStep=s}}else{let s=t;this.shouldEmitEvent=false;while(s<=this.stepsCount&&i[s-1].disabled)s++;if(s>this.stepsCount){this.activeStep=e}else{this.emitIfxChange(s,e);this.activeStep=s}}}}}emitIfxChange(t,e){this.ifxChange.emit({activeStep:t,previousActiveStep:e,totalSteps:this.stepsCount,emittedByClick:this.emittedByClick});this.emittedByClick=false}getSteps(){const t=this.el.querySelectorAll("ifx-step");return t}addStepIdsToStepsAndCountSteps(){const t=this.getSteps();t[t.length-1].lastStep=true;for(let e=0;e<t.length;e++){t[e].stepId=e+1}this.stepsCount=t.length}setActiveStep(t,e=false){this.emittedByClick=e;this.activeStep=t}setStepsBeforeActiveToComplete(){const t=this.getSteps();t.forEach(((t,e)=>{if(e+1<this.activeStep)t.complete=true}))}syncIfxSteps(){const t=this.getSteps();for(let e=0;e<t.length;e++){const i={activeStep:this.activeStep,indicatorPosition:this.indicatorPosition!=="right"?"left":"right",showStepNumber:this.showStepNumber,variant:this.variant!=="compact"&&this.variant!=="vertical"?"default":this.variant,setActiveStep:this.setActiveStep.bind(this)};t[e].stepperState=i}}setInitialActiveStep(){this.activeStep=Math.max(1,Math.min(this.stepsCount+(this.variant!=="compact"?1:0),this.activeStep))}componentWillLoad(){this.addStepIdsToStepsAndCountSteps();this.setInitialActiveStep();this.setStepsBeforeActiveToComplete()}async componentDidLoad(){if(!r(this.el)){const t=p();c("ifx-stepper",await t)}this.syncIfxSteps()}componentWillUpdate(){this.syncIfxSteps()}render(){return s("div",{key:"efa801c6a9fc193568af2a61a243963cc68f8ccf","aria-label":this.ariaLabel,"aria-current":this.ariaCurrent,role:"navigation",class:`stepper ${this.variant!=="compact"&&this.variant!=="vertical"?"default":this.variant} ${this.variant==="compact"?"compact-"+this.indicatorPosition:""}`},this.variant==="compact"&&s("div",{key:"3953441142ea4a971d83f4a0ee9efe95cd52808b",class:"stepper-progress"},s("div",{key:"98cea01acba664c602269b7db9283ab25ab8838f",class:"progress-detail"},`${Math.min(this.activeStep,this.stepsCount)} of ${this.stepsCount}`)),s("div",{key:"982731469dbc7fea23a44f2400fa12bfd6e2f961",class:`stepper-wrapper`},s("slot",{key:"6ab26615393a3dc9811da23fc258cf21fb009a98"})))}componentDidRender(){if(this.variant=="compact"){const t=this.el.shadowRoot.querySelector(".stepper-progress");t.style.setProperty("--pb",`${this.activeStep/this.stepsCount*100}%`)}}static get watchers(){return{activeStep:[{handleActiveStep:0}]}}static get style(){return n()}},[769,"ifx-stepper",{activeStep:[1026,"active-step"],indicatorPosition:[1,"indicator-position"],showStepNumber:[4,"show-step-number"],variant:[1],ariaLabel:[1,"aria-label"],ariaCurrent:[1,"aria-current"],stepsCount:[32],shouldEmitEvent:[32],emittedByClick:[32]},[[0,"ifxChange","onStepChange"]],{activeStep:[{handleActiveStep:0}]}]);function h(){if(typeof customElements==="undefined"){return}const t=["ifx-stepper"];t.forEach((t=>{switch(t){case"ifx-stepper":if(!customElements.get(a(t))){customElements.define(a(t),o)}break}}))}const l=o;const f=h;export{l as IfxStepper,f as defineCustomElement};
//# sourceMappingURL=ifx-stepper.js.map