import*as e from"lit";import*as t from"lit/decorators.js";var o,s,r={3701(e,t,o){o.d(t,{n:()=>s});var s,r=o(2900),i=o(7704),c=o(9609),n=o(4084),d=o(2927),a=o(8899),l=o(742),p=function(e,t,o,s){var r,i=arguments.length,c=i<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,o):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,o,s);else for(var n=e.length-1;n>=0;n--)(r=e[n])&&(c=(i<3?r(c):i>3?r(t,o,c):r(t,o))||c);return i>3&&c&&Object.defineProperty(t,o,c),c};!function(e){let t=class extends((0,i.TS)(d.LitElement)){constructor(){super(...arguments),this.multiple=!1,this.suppressContainerFocus=!1,this.doubleClickToExpand=!1,this.handleAccordionItemFocus=()=>{this.toggleAttribute("focusable",!0)},this.handleAccordionItemBlur=()=>{this.toggleAttribute("focusable",!1)}}get slotItem(){return this.accordionItemSlotElement}filterSlotted(){return this.accordionItemSlotElement.assignedElements()}switchFocusedAccordionItem(e){const t=this.slotted.findIndex(e=>e.hasAttribute("focus-visible")),o=this.slotted.length;let s=t;for(s=(o+s+e)%o;this.slotted[s].disabled;)s=(o+s+e)%o;this.focusAccordionItem(this.slotted[s])}focusAccordionItem(e){e.hasAttribute("focus-visible")||requestAnimationFrame(()=>e.header.focus())}setActiveAccordionItem(e){this.multiple?e.expanded=!e.expanded:(this.slotted.forEach(t=>{const o=t;o.expanded&&!t.isEqualNode(e)&&(o.expanded=!1)}),e.expanded=!0)}setupExpandedAccordionItems(){this.multiple||this.slotted.filter(e=>e.expanded).forEach((e,t)=>{const o=e;o.expanded&&t>0&&(o.expanded=!1)})}setupFocusAccordionItems(){this.slotted.forEach(e=>{this.suppressContainerFocus||(e.addEventListener("focus",this.handleAccordionItemFocus),e.addEventListener("blur",this.handleAccordionItemBlur))})}removeFocusAccordionItems(){this.slotted.forEach(e=>{this.suppressContainerFocus||(e.removeEventListener("focus",this.handleAccordionItemFocus),e.removeEventListener("blur",this.handleAccordionItemBlur))})}handleKeyDown(e){const{srcEvent:t}=e.detail,{code:o}=t;switch(o){case r.Uz.Space:case r.Uz.Enter:{const{target:t}=e;t&&this.setActiveAccordionItem(t);break}case r.Uz.ArrowDown:this.switchFocusedAccordionItem(1);break;case r.Uz.ArrowUp:this.switchFocusedAccordionItem(-1);break;case r.Uz.Home:{const e=this.slotted[0];this.focusAccordionItem(e);break}case r.Uz.End:{const e=this.slotted[this.slotted.length-1];this.focusAccordionItem(e);break}}}handleClick(e){const{target:t}=e,o=this.slotted.find(e=>e.isSameNode(t));o&&this.setActiveAccordionItem(o)}propagateDoubleClickSetting(){this.slotted.forEach(e=>{e.doubleClickToExpand=this.doubleClickToExpand})}updated(e){super.updated(e),e.has("slotted")&&(this.setupExpandedAccordionItems(),this.setupFocusAccordionItems(),this.propagateDoubleClickSetting())}connectedCallback(){super.connectedCallback(),this.addEventListener("accordion-item-keydown",this.handleKeyDown),this.addEventListener("accordion-item-click",this.handleClick)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("accordion-item-keydown",this.handleKeyDown),this.removeEventListener("accordion-item-click",this.handleClick),this.removeFocusAccordionItems()}static get styles(){return[n.A,l.A]}render(){return d.html`
        <div class="md-accordion" part="accordion">
          <slot name="accordion-item"></slot>
        </div>
      `}};p([(0,a.property)({type:Boolean,reflect:!0})],t.prototype,"multiple",void 0),p([(0,a.property)({type:Boolean,attribute:"suppress-container-focus"})],t.prototype,"suppressContainerFocus",void 0),p([(0,a.property)({type:Boolean,attribute:"double-click-to-expand"})],t.prototype,"doubleClickToExpand",void 0),p([(0,a.query)('slot[name="accordion-item"]')],t.prototype,"accordionItemSlotElement",void 0),t=p([(0,c.w)("md-accordion")],t),e.ELEMENT=t}(s||(s={}))},7704(e,t,o){o.d(t,{TS:()=>s.T}),o(2364),o(3203),o(9938),o(5201),o(4781);var s=o(608)},2927(t,o,s){var r,i;t.exports=(r={LitElement:()=>e.LitElement,css:()=>e.css,html:()=>e.html},i={},s.d(i,r),i)},8899(e,o,s){var r,i;e.exports=(r={property:()=>t.property,query:()=>t.query},i={},s.d(i,r),i)}},i={};function c(e){var t=i[e];if(void 0!==t)return t.exports;var o=i[e]={exports:{}};return r[e](o,o.exports,c),o.exports}c.m=r,o=[],c.O=(e,t,s,r)=>{if(!t){var i=1/0;for(l=0;l<o.length;l++){for(var[t,s,r]=o[l],n=!0,d=0;d<t.length;d++)(!1&r||i>=r)&&Object.keys(c.O).every(e=>c.O[e](t[d]))?t.splice(d--,1):(n=!1,r<i&&(i=r));if(n){o.splice(l--,1);var a=s();void 0!==a&&(e=a)}}return e}r=r||0;for(var l=o.length;l>0&&o[l-1][2]>r;l--)o[l]=o[l-1];o[l]=[t,s,r]},c.d=(e,t)=>{for(var o in t)c.o(t,o)&&!c.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},c.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);export{c as __webpack_require__};s={561:0,2942:0,5323:0,6220:0,7704:0,8180:0},c.C=e=>{var t,o,{__webpack_esm_ids__:r,__webpack_esm_modules__:i,__webpack_esm_runtime__:n}=e,d=0;for(t in i)c.o(i,t)&&(c.m[t]=i[t]);for(n&&n(c);d<r.length;d++)o=r[d],c.o(s,o)&&s[o]&&s[o][0](),s[r[d]]=0;c.O()},c.O.j=e=>0===s[e];import*as n from"../9609.js";c.C(n);import*as d from"../4084.js";c.C(d);import*as a from"../2364.js";c.C(a);import*as l from"../9938.js";c.C(l);import*as p from"../4781.js";c.C(p);import*as m from"../5201.js";c.C(m);import*as h from"../2900.js";c.C(h);import*as u from"../608.js";c.C(u);import*as f from"../3203.js";c.C(f);import*as v from"../742.js";c.C(v);var b=c.O(void 0,[9609,4084,2364,9938,4781,5201,2900,608,3203,742],()=>c(3701));const A=(b=c.O(b)).n;export{A as Accordion};