import*as e from"lit";import*as t from"lit/decorators.js";var s,i,r={8358(e,t,s){s.d(t,{z:()=>i});var i,r=s(2900),o=s(7704),d=s(9609),a=s(4084),l=s(2927),n=s(8899),c=s(7231),h=function(e,t,s,i){var r,o=arguments.length,d=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,s):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)d=Reflect.decorate(e,t,s,i);else for(var a=e.length-1;a>=0;a--)(r=e[a])&&(d=(o<3?r(d):o>3?r(t,s,d):r(t,s))||d);return o>3&&d&&Object.defineProperty(t,s,d),d};!function(e){let t=class extends((0,o.Io)(l.LitElement)){constructor(){super(...arguments),this.label="group",this.checked=-1,this.alignment="vertical",this._disabled=!1}get disabled(){return this._disabled}set disabled(e){const t=this._disabled;this._disabled=e,this.requestUpdate("disabled",t)}firstUpdated(e){super.firstUpdated(e),this.setAttribute("role","radiogroup"),this.setAttribute("aria-label",this.label)}willUpdate(e){var t;null===(t=super.willUpdate)||void 0===t||t.call(this,e),(e.has("slotted")||e.has("checked"))&&this.setFirstChecked()}get selectedRadioValue(){return this.slotted[this.selected].value}notifySelectedChange(){this.dispatchEvent(new CustomEvent("radio-change",{detail:{selected:this.selectedRadioValue},bubbles:!0,composed:!0}))}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)}setFirstChecked(){-1!==this.checked&&(this.selected=this.checked,this.setChecked(this.checked))}findRadioIndex(e){const t=e.composedPath();return this.slotted.findIndex(e=>t.includes(e))}findCheckedRadioIndex(){return this.slotted.findIndex(e=>e.checked)}setChecked(e){const t=this.findCheckedRadioIndex();-1!==t&&t!==e&&this.slotted[t]&&(this.slotted[t].checked=!1),this.slotted[e]&&(this.slotted[e].checked=!0)}switchRadioOnArrowPress(e,t=1){const s=super.getAvailableSelectedIndex(e,t);-1!==s&&(this.selected=s,this.setChecked(s),this.notifySelectedChange())}isRadioDisabled(e){return this.slotted[e].disabled}handleClick(e){if(this.disabled)return!1;const t=this.findRadioIndex(e);-1!==t&&(this.isRadioDisabled(t)||(this.selected=t,this.setChecked(t),this.notifySelectedChange()))}handleKeyDown(e){if(this.disabled)return!1;const{code:t}=e;switch(t){case r.Uz.Enter:case r.Uz.Space:this.isRadioDisabled(this.selected)||(this.setChecked(this.selected),this.notifySelectedChange(),e.stopPropagation(),e.preventDefault());break;case r.Uz.ArrowUp:case r.Uz.ArrowLeft:0===this.selected?this.switchRadioOnArrowPress(this.slotted.length-1,-1):this.switchRadioOnArrowPress(this.selected-1,-1),e.stopPropagation(),e.preventDefault();break;case r.Uz.ArrowDown:case r.Uz.ArrowRight:this.selected===this.slotted.length-1?this.switchRadioOnArrowPress(0):this.switchRadioOnArrowPress(this.selected+1),e.stopPropagation(),e.preventDefault()}}get slotElement(){return this.radioSlot}static get styles(){return[a.A,c.A]}clearSelection(){const e=this.findCheckedRadioIndex();-1!=e&&(this.checked=-1,this.slotted[e].checked=!1)}render(){return l.html`
        <div class="radio-group-container" part="radio-group-container">
          <slot name="radio"></slot>
        </div>
      `}};h([(0,n.property)({type:String,attribute:"group-label"})],t.prototype,"label",void 0),h([(0,n.property)({type:Number,reflect:!0})],t.prototype,"checked",void 0),h([(0,n.property)({type:String,reflect:!0})],t.prototype,"alignment",void 0),h([(0,n.query)("slot[name='radio']")],t.prototype,"radioSlot",void 0),h([(0,n.property)({type:Boolean,reflect:!0})],t.prototype,"disabled",null),t=h([(0,d.w)("md-radiogroup")],t),e.ELEMENT=t}(i||(i={}))},2927(t,s,i){var r,o;t.exports=(r={LitElement:()=>e.LitElement,css:()=>e.css,html:()=>e.html},o={},i.d(o,r),o)},8899(e,s,i){var r,o;e.exports=(r={property:()=>t.property,query:()=>t.query},o={},i.d(o,r),o)}},o={};function d(e){var t=o[e];if(void 0!==t)return t.exports;var s=o[e]={exports:{}};return r[e](s,s.exports,d),s.exports}d.m=r,s=[],d.O=(e,t,i,r)=>{if(!t){var o=1/0;for(c=0;c<s.length;c++){for(var[t,i,r]=s[c],a=!0,l=0;l<t.length;l++)(!1&r||o>=r)&&Object.keys(d.O).every(e=>d.O[e](t[l]))?t.splice(l--,1):(a=!1,r<o&&(o=r));if(a){s.splice(c--,1);var n=i();void 0!==n&&(e=n)}}return e}r=r||0;for(var c=s.length;c>0&&s[c-1][2]>r;c--)s[c]=s[c-1];s[c]=[t,i,r]},d.d=(e,t)=>{for(var s in t)d.o(t,s)&&!d.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:t[s]})},d.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);export{d as __webpack_require__};i={8334:0},d.C=e=>{var t,s,{__webpack_esm_ids__:r,__webpack_esm_modules__:o,__webpack_esm_runtime__:a}=e,l=0;for(t in o)d.o(o,t)&&(d.m[t]=o[t]);for(a&&a(d);l<r.length;l++)s=r[l],d.o(i,s)&&i[s]&&i[s][0](),i[r[l]]=0;d.O()},d.O.j=e=>0===i[e];import*as a from"../9609.js";d.C(a);import*as l from"../4084.js";d.C(l);import*as n from"../2364.js";d.C(n);import*as c from"../9938.js";d.C(c);import*as h from"../5201.js";d.C(h);import*as p from"../2900.js";d.C(p);import*as f from"../608.js";d.C(f);import*as u from"../3203.js";d.C(u);import*as m from"../7162.js";d.C(m);import*as b from"../7231.js";d.C(b);import*as v from"../2942.js";d.C(v);var k=d.O(void 0,[9609,4084,2364,9938,5201,2900,608,3203,7162,7231,2942],()=>d(8358));const y=(k=d.O(k)).z;export{y as RadioGroup};