import{r as t,c as e,a as i,h as s}from"./p-wX3eJOEL.js";import{i as r}from"./p-CtINY9El.js";import{d as p,t as a}from"./p-DNHOWgWh.js";const c=class{constructor(i){t(this,i),this.ifxChange=e(this,"ifxChange",7)}get el(){return i(this)}ifxChange;activeStep=1;indicatorPosition="left";showStepNumber=!1;variant="default";ariaLabelText;ariaCurrentText;stepsCount;shouldEmitEvent=!0;emittedByClick=!1;onStepChange(t){const e=this.getSteps()[t.detail.previousActiveStep-1];e&&!e.complete&&e.setAttribute("error","true")}handleActiveStep(t,e){const i=this.getSteps();if(this.shouldEmitEvent){if(i[t-1])if(i[t-1].disabled)if(t<e){let s=t;for(this.shouldEmitEvent=!1;s>=1&&i[s-1].disabled;)s--;s<1?this.activeStep=e:(this.emitIfxChange(s,e),this.activeStep=s)}else{let s=t;for(this.shouldEmitEvent=!1;s<=this.stepsCount&&i[s-1].disabled;)s++;s>this.stepsCount?this.activeStep=e:(this.emitIfxChange(s,e),this.activeStep=s)}else this.emitIfxChange(t,e)}else this.shouldEmitEvent=!0}emitIfxChange(t,e){this.ifxChange.emit({activeStep:t,previousActiveStep:e,totalSteps:this.stepsCount,emittedByClick:this.emittedByClick}),this.emittedByClick=!1}getSteps(){return this.el.querySelectorAll("ifx-step")}addStepIdsToStepsAndCountSteps(){const t=this.getSteps();t[t.length-1].lastStep=!0;for(let e=0;e<t.length;e++)t[e].stepId=e+1;this.stepsCount=t.length}setActiveStep(t,e=!1){this.emittedByClick=e,this.activeStep=t}setStepsBeforeActiveToComplete(){this.getSteps().forEach(((t,e)=>{e+1<this.activeStep&&(t.complete=!0)}))}syncIfxSteps(){const t=this.getSteps();for(let e=0;e<t.length;e++){const i={activeStep:this.activeStep,indicatorPosition:"right"!==this.indicatorPosition?"left":"right",showStepNumber:this.showStepNumber,variant:"compact"!==this.variant&&"vertical"!==this.variant?"default":this.variant,setActiveStep:this.setActiveStep.bind(this)};t[e].stepperState=i}}setInitialActiveStep(){this.activeStep=Math.max(1,Math.min(this.stepsCount+("compact"!==this.variant?1:0),this.activeStep))}componentWillLoad(){this.addStepIdsToStepsAndCountSteps(),this.setInitialActiveStep(),this.setStepsBeforeActiveToComplete()}async componentDidLoad(){if(!r(this.el)){const t=p();a("ifx-stepper",await t)}this.syncIfxSteps()}componentWillUpdate(){this.syncIfxSteps()}render(){return s("div",{key:"5138d0d39b48558835131175b4115ec88e221edc","aria-label":this.ariaLabelText,"aria-current":this.ariaCurrentText,role:"navigation",class:`stepper ${"compact"!==this.variant&&"vertical"!==this.variant?"default":this.variant} ${"compact"===this.variant?"compact-"+this.indicatorPosition:""}`},"compact"===this.variant&&s("div",{key:"7a54901eb69eac87abd302de79d3ff5f767173be",class:"stepper-progress"},s("div",{key:"628395a4684077f72b973f33d1a3f2d85c9a12a4",class:"progress-detail"},`${Math.min(this.activeStep,this.stepsCount)} of ${this.stepsCount}`)),s("div",{key:"7cddc051a09495ccd20ff8b49809c37fdd2ddd69",class:"stepper-wrapper"},s("slot",{key:"17922d117b17ed2956bc921b7e50c58b654ad7c8"})))}componentDidRender(){"compact"==this.variant&&this.el.shadowRoot.querySelector(".stepper-progress").style.setProperty("--pb",this.activeStep/this.stepsCount*100+"%")}static get watchers(){return{activeStep:[{handleActiveStep:0}]}}};c.style='.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}';export{c as ifx_stepper}