var t,e,s={2890(t,e,s){s.d(e,{e:()=>i});var i,r=s(2900),o=s(7704),n=s(4084),d=s(2927),l=s(8899),a=s(2670),c=function(t,e,s,i){var r,o=arguments.length,n=o<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,s):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(t,e,s,i);else for(var d=t.length-1;d>=0;d--)(r=t[d])&&(n=(o<3?r(n):o>3?r(e,s,n):r(e,s))||n);return o>3&&n&&Object.defineProperty(e,s,n),n};!function(t){let e=class extends((0,o.TS)((0,o.yC)(d.LitElement))){constructor(){super(...arguments),this.active=0,this.tabIndex=0,this.newMomentum=!1,this._disabled=!1}get disabled(){return this._disabled}set disabled(t){const e=this._disabled;this._disabled=t,this.setAttribute("aria-disabled",`${t}`),this.tabIndex=t?-1:0,this.requestUpdate("disabled",e)}get slotElement(){return this.buttonSlot}static get styles(){return[n.A,a.A]}firstUpdated(t){super.firstUpdated(t),this.setAttribute("role","group")}setButtonTabIndex(){this.slotted.forEach(t=>t.tabIndex=-1)}updated(t){super.updated(t),t.has("slotted")&&(this.setButtonTabIndex(),this.setFirstActive())}get selectedBtnValue(){return this.slotted[this.active].value}notifySelectedChange(){this.dispatchEvent(new CustomEvent("button-group-change",{detail:{selected:this.selectedBtnValue},bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("focus-visible",{composed:!0,bubbles:!0}))}setSelected(t){var e,s;const i=this.findSelectedBtnIndex();-1!==i&&i!==t&&(null===(e=this.slotted[i])||void 0===e||e.toggleAttribute("selected",!1)),null===(s=this.slotted[t])||void 0===s||s.toggleAttribute("selected",!0)}setFirstActive(){-1===this.findSelectedBtnIndex()&&this.setSelected(this.active)}findBtnIndex(t){const e=t.composedPath();return this.slotted.findIndex(t=>e.includes(t))}findSelectedBtnIndex(){return this.slotted.findIndex(t=>t.hasAttribute("selected"))}isBtnDisabled(t){return this.slotted[t].disabled}connectedCallback(){super.connectedCallback(),this.addEventListener("keydown",this.handleKeyDown),this.addEventListener("click",this.handleClick)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("keydown",this.handleKeyDown),this.removeEventListener("click",this.handleClick)}switchBtnOnArrowPress(t,e=1){const s=this.getAvailableSelectedIndex(t,e);-1!==s&&(this.active=s,this.setSelected(s),this.notifySelectedChange())}getAvailableSelectedIndex(t,e=1){const s=this.slotted.length;for(let i=0,r=t;i<s;i+=1,r+=e){r<0?r=s-1:r>=s&&(r=0);const t=this.slotted[r];if(this.isFocusable(t))return r}return-1}isFocusable(t){return!t.hasAttribute("disabled")&&!t.hasAttribute("hidden")}handleClick(t){const e=this.findBtnIndex(t);-1!==e&&(this.isBtnDisabled(e)||(this.active=e,this.setSelected(e),this.notifySelectedChange()))}handleKeyDown(t){const{code:e}=t;switch(e){case r.Uz.Enter:case r.Uz.Space:this.isBtnDisabled(this.active)||(this.setSelected(this.active),this.notifySelectedChange());break;case r.Uz.ArrowLeft:0===this.active?this.switchBtnOnArrowPress(this.slotted.length-1,-1):this.switchBtnOnArrowPress(this.active-1,-1);break;case r.Uz.ArrowRight:this.active===this.slotted.length-1?this.switchBtnOnArrowPress(0):this.switchBtnOnArrowPress(this.active+1)}}render(){return d.html`
        <div role="group" class="md-button-group" part="button-group">
          <slot name="button"></slot>
        </div>
      `}};c([(0,l.property)({type:Number,reflect:!0})],e.prototype,"active",void 0),c([(0,l.property)({type:Number,reflect:!0})],e.prototype,"tabIndex",void 0),c([(0,l.property)({type:Boolean,reflect:!0})],e.prototype,"newMomentum",void 0),c([(0,l.query)("slot[name='button']")],e.prototype,"buttonSlot",void 0),c([(0,l.property)({type:Boolean,reflect:!0})],e.prototype,"disabled",null),e=c([(0,o.wW)("md-button-group")],e),t.ELEMENT=e}(i||(i={}))},7704(t,e,s){s.d(e,{TS:()=>r.T,wW:()=>o.w,yC:()=>i.y}),s(2364);var i=s(3203),r=(s(9938),s(5201),s(4781),s(608)),o=s(9609)}},i={};function r(t){var e=i[t];if(void 0!==e)return e.exports;var o=i[t]={exports:{}};return s[t](o,o.exports,r),o.exports}r.m=s,t=[],r.O=(e,s,i,o)=>{if(!s){var n=1/0;for(c=0;c<t.length;c++){for(var[s,i,o]=t[c],d=!0,l=0;l<s.length;l++)(!1&o||n>=o)&&Object.keys(r.O).every(t=>r.O[t](s[l]))?s.splice(l--,1):(d=!1,o<n&&(n=o));if(d){t.splice(c--,1);var a=i();void 0!==a&&(e=a)}}return e}o=o||0;for(var c=t.length;c>0&&t[c-1][2]>o;c--)t[c]=t[c-1];t[c]=[s,i,o]},r.d=(t,e)=>{for(var s in e)r.o(e,s)&&!r.o(t,s)&&Object.defineProperty(t,s,{enumerable:!0,get:e[s]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);export{r as __webpack_require__};e={561:0,2942:0,5310:0,5323:0,7704:0,8180:0},r.C=t=>{var s,i,{__webpack_esm_ids__:o,__webpack_esm_modules__:n,__webpack_esm_runtime__:d}=t,l=0;for(s in n)r.o(n,s)&&(r.m[s]=n[s]);for(d&&d(r);l<o.length;l++)i=o[l],r.o(e,i)&&e[i]&&e[i][0](),e[o[l]]=0;r.O()},r.O.j=t=>0===e[t];import*as o from"../9609.js";r.C(o);import*as n from"../4084.js";r.C(n);import*as d from"../2364.js";r.C(d);import*as l from"../9938.js";r.C(l);import*as a from"../4781.js";r.C(a);import*as c from"../5201.js";r.C(c);import*as h from"../5584.js";r.C(h);import*as p from"../2900.js";r.C(p);import*as u from"../2927.js";r.C(u);import*as b from"../608.js";r.C(b);import*as f from"../8899.js";r.C(f);import*as v from"../2670.js";r.C(v);var m=r.O(void 0,[9609,4084,2364,9938,4781,5201,5584,2900,2927,608,8899,2670],()=>r(2890));const y=(m=r.O(m)).e;export{y as ButtonGroup};