@madgex/design-system 14.2.0 → 14.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/icons.json +1 -1
- package/dist/js/index.js +1 -1
- package/package.json +1 -1
- package/src/components/conditional-section/README.md +2 -2
- package/src/components/conditional-section/conditional-section.config.js +54 -0
- package/src/components/conditional-section/conditional-section.js +91 -26
- package/src/components/conditional-section/conditional-section.spec.js +402 -0
package/dist/assets/icons.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
[{"name":"add"},{"name":"arrow-left"},{"name":"arrow-right"},{"name":"asterisk"},{"name":"calendar"},{"name":"cart"},{"name":"check"},{"name":"chevron-
|
|
1
|
+
[{"name":"add"},{"name":"arrow-left"},{"name":"arrow-right"},{"name":"asterisk"},{"name":"calendar"},{"name":"cart"},{"name":"check"},{"name":"chevron-left"},{"name":"chevron-down"},{"name":"chevron-right"},{"name":"chevron-up"},{"name":"close"},{"name":"cross"},{"name":"doc-pdf"},{"name":"doc"},{"name":"email"},{"name":"external"},{"name":"flag"},{"name":"information"},{"name":"job"},{"name":"list-bullets"},{"name":"list-numbers"},{"name":"location-pin"},{"name":"menu"},{"name":"minus"},{"name":"plus-small"},{"name":"plus"},{"name":"question-mark"},{"name":"redo"},{"name":"search"},{"name":"settings"},{"name":"share"},{"name":"social-facebook"},{"name":"social-linkedin"},{"name":"social-pinterest"},{"name":"social-reddit"},{"name":"social-twitter"},{"name":"spinner"},{"name":"star-fill"},{"name":"star-outline"},{"name":"text-bold"},{"name":"text-italic"},{"name":"text-link"},{"name":"text-strike-through"},{"name":"text-underline"},{"name":"triangle-down"},{"name":"triangle-right"},{"name":"triangle-up"},{"name":"undo"},{"name":"upload"},{"name":"user"},{"name":"remove"}]
|
package/dist/js/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{M as Lt}from"./dropdown-nav-DGGzV21D.js";import{M as Ct}from"./timeout-dialog-plrFUmdZ.js";import{M as Ot}from"./image-cropper-BUN9gxO4.js";import{M as Tt}from"./consent-gate-DVi5q-ir.js";import{s as hn}from"./consent-gate-DVi5q-ir.js";window.addEventListener("hashchange",()=>{const t=window.location.hash.trim();Array.from(document.querySelectorAll(`a[href='${t}']`)).forEach(r=>{r.click()})},!1);const ut={baseline:{$value:"4px"},breakpoint:{md:{$value:"600px"},lg:{$value:"1008px"}}},ft={size:ut},qt="js-tabs-item",Je="mds-tabs",Pt="mds-tabs__list",$t="mds-tabs__list-item",Ke="mds-tabs__panel",me="mds-tabs__tab",ve="mds-tabs__tab--selected",Ue="mds-tabs__panel--hidden",be={left:37,right:39,up:38,down:40},Dt=".js-desktop-tabbed",_t=".js-full-tabbed",It=parseInt(ft.size.breakpoint.lg.$value,10),x={init:()=>{x.setTabs(_t),window.innerWidth>It&&x.setTabs(Dt)},setTabs:t=>{const e=Array.from(document.querySelectorAll(`${t} .${me}`)),r=Array.from(document.querySelectorAll(`${t} .${Pt}`)),n=Array.from(document.querySelectorAll(`${t} .${$t}`)),s=Array.from(document.querySelectorAll(`${t} .${Ke}`));r.forEach(o=>{o.setAttribute("role","tablist")}),n.forEach(o=>{o.setAttribute("role","presentation")}),e.forEach(o=>{o.setAttribute("role","tab"),o.setAttribute("aria-controls",o.attributes.href.value.substring(1)),o.classList.contains(ve)?o.setAttribute("tabindex","0"):o.setAttribute("tabindex","-1")}),s.forEach(o=>{o.setAttribute("role","tabpanel"),o.setAttribute("aria-labelledby",`label-${o.attributes.id.value}`)});const i=document.querySelectorAll(`${t} .${qt}`);Array.from(i).forEach(o=>{const c=window.location.hash.trim(),l=o.attributes.href.value,d=o.closest(`.${Je}`),p=x.getAllPanels(d),f=x.getAllTabs(d),h=x.getTargetPanel(o,d);o.addEventListener("click",m=>{m.preventDefault(),x.updateTabs(f,p,o,h,l)}),l===c&&x.updateTabs(f,p,o,h,l)}),r.forEach(o=>{const c=o.closest(`.${Je}`),l=x.getAllPanels(c),d=x.getAllTabs(c);o.addEventListener("keydown",p=>{switch(p.keyCode){case be.left:case be.up:p.preventDefault(),x.moveTab(o,c,d,l,!1);break;case be.right:case be.down:p.preventDefault(),x.moveTab(o,c,d,l,!0);break}})})},getSelectedTab:t=>t.querySelector(`.${ve}`),getPrevTab:t=>t.parentElement.previousSibling?t.parentElement.previousSibling.querySelector(`.${me}`):!1,getNextTab:t=>t.parentElement.nextSibling?t.parentElement.nextSibling.querySelector(`.${me}`):!1,getTargetPanel:(t,e)=>{const r=t.attributes.href.value;return e.querySelector(r)},getAllPanels:t=>Array.from(t.querySelectorAll(`.${Ke}`)),getAllTabs:t=>Array.from(t.querySelectorAll(`.${me}`)),moveTab:(t,e,r,n,s)=>{const i=x.getSelectedTab(t),a=s?x.getNextTab(i):x.getPrevTab(i);if(a){const o=a.attributes.href.value,c=x.getTargetPanel(a,e);x.updateTabs(r,n,a,c,o,!1)}},updateTabs:(t,e,r,n,s)=>{x.clearAllTabs(t),x.setActiveTab(r),x.clearAllPanels(e),x.setActivePanel(n,s)},clearAllTabs:t=>{t.forEach(e=>{e.classList.remove(ve),e.setAttribute("aria-selected","false"),e.setAttribute("tabindex","-1")})},clearAllPanels:t=>{t.forEach(e=>{e.classList.add(Ue)})},setActiveTab:t=>{t.classList.add(ve),t.setAttribute("aria-selected","true"),t.setAttribute("tabindex","0"),t.focus()},setActivePanel:(t,e)=>{t.classList.remove(Ue),window.history.replaceState({},"",e)}},Mt="mds-accordion--breakpoint",Bt="mds-accordion__label",pt={init:()=>{const t=document.querySelectorAll(`.${Mt}`),e=window.innerWidth;t.forEach(n=>{pt.checkBreakpoint(n,e)||(n.open=!0,n.querySelector("summary").style.display="none")}),document.querySelectorAll(`.${Bt}`).forEach(n=>{n.addEventListener("click",({target:s})=>{const i=s.closest("details"),a=i.querySelector("summary");i.open=!1,a.focus()})})},checkBreakpoint:(t,e)=>{let r=0;if(t.dataset.bp){const n=t.dataset.bp.replace(/\D/g,""),s=t.dataset.bp.replace(/[0-9]/g,"");let i,a;switch(s){case"px":r=n;break;case"em":i=window.getComputedStyle(document.querySelector("body"))["font-size"],a=n*parseFloat(i),r=a;break;case"rem":i=window.getComputedStyle(document.querySelector("body"))["font-size"],a=n*parseFloat(i),r=a;break;default:return!0}return!(e>r)}return!0}},Rt={init:()=>{const t=document.querySelectorAll(".mds-subnavigation"),e=[];let r;t.forEach(s=>{const i=s.querySelector(".mds-subnavigation__link-list"),a=Array.from(i.children),o=a[0],c=s.querySelector(".mds-subnavigation__mobile-title"),l=s.querySelector(".mds-subnavigation__drawer"),d=s.querySelector(".mds-subnavigation__drawer-label"),p=s.querySelector(".mds-subnavigation__drawer-label-text"),f=s.querySelector(".mds-subnavigation__drawer-content"),h=l.dataset.label,m=l.dataset.labelPlural;d.addEventListener("click",()=>{d.getAttribute("aria-expanded")==="true"?d.setAttribute("aria-expanded","false"):d.setAttribute("aria-expanded","true")}),l.addEventListener("focusout",v=>{l.contains(v.relatedTarget)||d.setAttribute("aria-expanded","false")});const g=()=>i.clientHeight>o.offsetHeight;e.push(()=>{d.setAttribute("aria-expanded","false"),window.getComputedStyle(c).getPropertyValue("display")==="none"?(a.forEach(b=>{i.append(b)}),l.style.display="none",g()&&(l.style.display="list-item",a.slice().reverse().forEach(b=>{if(g()&&b!==l){f.prepend(b);const y=Array.from(f.children).length,E=y>1?m:h;p.innerText=E.replace("{count}",y)}else i.prepend(b)}),f.style.width=`${i.offsetWidth-l.offsetLeft}px`)):(a.forEach(b=>{b!==l&&b!==c&&f.append(b)}),f.style.width="initial",l.style.display="block")})});const n=()=>{e.forEach(s=>{s()})};n(),window.onresize=()=>{clearTimeout(r),r=setTimeout(n,100)}}},Nt="mds-checkbox-accordion__button",jt="mds-checkbox-accordion__button--open",Wt={init:()=>{document.querySelectorAll(`.${Nt}`).forEach(e=>{e.classList.contains(jt)?e.setAttribute("aria-expanded","true"):e.setAttribute("aria-expanded","false"),e.addEventListener("click",()=>{e.getAttribute("aria-expanded")==="true"?e.setAttribute("aria-expanded","false"):e.setAttribute("aria-expanded","true")})})}};var T="top",P="bottom",$="right",q="left",_e="auto",le=[T,P,$,q],Z="start",Ie="end",Ft="clippingParents",ht="viewport",re="popper",Ht="reference",Ge=le.reduce(function(t,e){return t.concat([e+"-"+Z,e+"-"+Ie])},[]),mt=[].concat(le,[_e]).reduce(function(t,e){return t.concat([e,e+"-"+Z,e+"-"+Ie])},[]),Vt="beforeRead",zt="read",Xt="afterRead",Yt="beforeMain",Jt="main",Kt="afterMain",Ut="beforeWrite",Gt="write",Qt="afterWrite",Zt=[Vt,zt,Xt,Yt,Jt,Kt,Ut,Gt,Qt];function R(t){return t?(t.nodeName||"").toLowerCase():null}function _(t){if(t==null)return window;if(t.toString()!=="[object Window]"){var e=t.ownerDocument;return e&&e.defaultView||window}return t}function oe(t){var e=_(t).Element;return t instanceof e||t instanceof Element}function D(t){var e=_(t).HTMLElement;return t instanceof e||t instanceof HTMLElement}function vt(t){if(typeof ShadowRoot>"u")return!1;var e=_(t).ShadowRoot;return t instanceof e||t instanceof ShadowRoot}function er(t){var e=t.state;Object.keys(e.elements).forEach(function(r){var n=e.styles[r]||{},s=e.attributes[r]||{},i=e.elements[r];!D(i)||!R(i)||(Object.assign(i.style,n),Object.keys(s).forEach(function(a){var o=s[a];o===!1?i.removeAttribute(a):i.setAttribute(a,o===!0?"":o)}))})}function tr(t){var e=t.state,r={popper:{position:e.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};return Object.assign(e.elements.popper.style,r.popper),e.styles=r,e.elements.arrow&&Object.assign(e.elements.arrow.style,r.arrow),function(){Object.keys(e.elements).forEach(function(n){var s=e.elements[n],i=e.attributes[n]||{},a=Object.keys(e.styles.hasOwnProperty(n)?e.styles[n]:r[n]),o=a.reduce(function(c,l){return c[l]="",c},{});!D(s)||!R(s)||(Object.assign(s.style,o),Object.keys(i).forEach(function(c){s.removeAttribute(c)}))})}}const rr={name:"applyStyles",enabled:!0,phase:"write",fn:er,effect:tr,requires:["computeStyles"]};function B(t){return t.split("-")[0]}function ee(t){var e=t.getBoundingClientRect();return{width:e.width,height:e.height,top:e.top,right:e.right,bottom:e.bottom,left:e.left,x:e.left,y:e.top}}function Me(t){var e=ee(t),r=t.offsetWidth,n=t.offsetHeight;return Math.abs(e.width-r)<=1&&(r=e.width),Math.abs(e.height-n)<=1&&(n=e.height),{x:t.offsetLeft,y:t.offsetTop,width:r,height:n}}function bt(t,e){var r=e.getRootNode&&e.getRootNode();if(t.contains(e))return!0;if(r&&vt(r)){var n=e;do{if(n&&t.isSameNode(n))return!0;n=n.parentNode||n.host}while(n)}return!1}function W(t){return _(t).getComputedStyle(t)}function nr(t){return["table","td","th"].indexOf(R(t))>=0}function V(t){return((oe(t)?t.ownerDocument:t.document)||window.document).documentElement}function Se(t){return R(t)==="html"?t:t.assignedSlot||t.parentNode||(vt(t)?t.host:null)||V(t)}function Qe(t){return!D(t)||W(t).position==="fixed"?null:t.offsetParent}function sr(t){var e=navigator.userAgent.toLowerCase().indexOf("firefox")!==-1,r=navigator.userAgent.indexOf("Trident")!==-1;if(r&&D(t)){var n=W(t);if(n.position==="fixed")return null}for(var s=Se(t);D(s)&&["html","body"].indexOf(R(s))<0;){var i=W(s);if(i.transform!=="none"||i.perspective!=="none"||i.contain==="paint"||["transform","perspective"].indexOf(i.willChange)!==-1||e&&i.willChange==="filter"||e&&i.filter&&i.filter!=="none")return s;s=s.parentNode}return null}function de(t){for(var e=_(t),r=Qe(t);r&&nr(r)&&W(r).position==="static";)r=Qe(r);return r&&(R(r)==="html"||R(r)==="body"&&W(r).position==="static")?e:r||sr(t)||e}function Be(t){return["top","bottom"].indexOf(t)>=0?"x":"y"}var H=Math.max,ie=Math.min,ge=Math.round;function Ae(t,e,r){return H(t,ie(e,r))}function gt(){return{top:0,right:0,bottom:0,left:0}}function yt(t){return Object.assign({},gt(),t)}function wt(t,e){return e.reduce(function(r,n){return r[n]=t,r},{})}var or=function(e,r){return e=typeof e=="function"?e(Object.assign({},r.rects,{placement:r.placement})):e,yt(typeof e!="number"?e:wt(e,le))};function ir(t){var e,r=t.state,n=t.name,s=t.options,i=r.elements.arrow,a=r.modifiersData.popperOffsets,o=B(r.placement),c=Be(o),l=[q,$].indexOf(o)>=0,d=l?"height":"width";if(!(!i||!a)){var p=or(s.padding,r),f=Me(i),h=c==="y"?T:q,m=c==="y"?P:$,g=r.rects.reference[d]+r.rects.reference[c]-a[c]-r.rects.popper[d],v=a[c]-r.rects.reference[c],b=de(i),y=b?c==="y"?b.clientHeight||0:b.clientWidth||0:0,E=g/2-v/2,u=p[h],k=y-f[d]-p[m],w=y/2-f[d]/2+E,S=Ae(u,w,k),A=c;r.modifiersData[n]=(e={},e[A]=S,e.centerOffset=S-w,e)}}function ar(t){var e=t.state,r=t.options,n=r.element,s=n===void 0?"[data-popper-arrow]":n;s!=null&&(typeof s=="string"&&(s=e.elements.popper.querySelector(s),!s)||bt(e.elements.popper,s)&&(e.elements.arrow=s))}const cr={name:"arrow",enabled:!0,phase:"main",fn:ir,effect:ar,requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};var lr={top:"auto",right:"auto",bottom:"auto",left:"auto"};function dr(t){var e=t.x,r=t.y,n=window,s=n.devicePixelRatio||1;return{x:ge(ge(e*s)/s)||0,y:ge(ge(r*s)/s)||0}}function Ze(t){var e,r=t.popper,n=t.popperRect,s=t.placement,i=t.offsets,a=t.position,o=t.gpuAcceleration,c=t.adaptive,l=t.roundOffsets,d=l===!0?dr(i):typeof l=="function"?l(i):i,p=d.x,f=p===void 0?0:p,h=d.y,m=h===void 0?0:h,g=i.hasOwnProperty("x"),v=i.hasOwnProperty("y"),b=q,y=T,E=window;if(c){var u=de(r),k="clientHeight",w="clientWidth";u===_(r)&&(u=V(r),W(u).position!=="static"&&(k="scrollHeight",w="scrollWidth")),u=u,s===T&&(y=P,m-=u[k]-n.height,m*=o?1:-1),s===q&&(b=$,f-=u[w]-n.width,f*=o?1:-1)}var S=Object.assign({position:a},c&&lr);if(o){var A;return Object.assign({},S,(A={},A[y]=v?"0":"",A[b]=g?"0":"",A.transform=(E.devicePixelRatio||1)<2?"translate("+f+"px, "+m+"px)":"translate3d("+f+"px, "+m+"px, 0)",A))}return Object.assign({},S,(e={},e[y]=v?m+"px":"",e[b]=g?f+"px":"",e.transform="",e))}function ur(t){var e=t.state,r=t.options,n=r.gpuAcceleration,s=n===void 0?!0:n,i=r.adaptive,a=i===void 0?!0:i,o=r.roundOffsets,c=o===void 0?!0:o,l={placement:B(e.placement),popper:e.elements.popper,popperRect:e.rects.popper,gpuAcceleration:s};e.modifiersData.popperOffsets!=null&&(e.styles.popper=Object.assign({},e.styles.popper,Ze(Object.assign({},l,{offsets:e.modifiersData.popperOffsets,position:e.options.strategy,adaptive:a,roundOffsets:c})))),e.modifiersData.arrow!=null&&(e.styles.arrow=Object.assign({},e.styles.arrow,Ze(Object.assign({},l,{offsets:e.modifiersData.arrow,position:"absolute",adaptive:!1,roundOffsets:c})))),e.attributes.popper=Object.assign({},e.attributes.popper,{"data-popper-placement":e.placement})}const fr={name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:ur,data:{}};var ye={passive:!0};function pr(t){var e=t.state,r=t.instance,n=t.options,s=n.scroll,i=s===void 0?!0:s,a=n.resize,o=a===void 0?!0:a,c=_(e.elements.popper),l=[].concat(e.scrollParents.reference,e.scrollParents.popper);return i&&l.forEach(function(d){d.addEventListener("scroll",r.update,ye)}),o&&c.addEventListener("resize",r.update,ye),function(){i&&l.forEach(function(d){d.removeEventListener("scroll",r.update,ye)}),o&&c.removeEventListener("resize",r.update,ye)}}const hr={name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:pr,data:{}};var mr={left:"right",right:"left",bottom:"top",top:"bottom"};function xe(t){return t.replace(/left|right|bottom|top/g,function(e){return mr[e]})}var vr={start:"end",end:"start"};function et(t){return t.replace(/start|end/g,function(e){return vr[e]})}function Re(t){var e=_(t),r=e.pageXOffset,n=e.pageYOffset;return{scrollLeft:r,scrollTop:n}}function Ne(t){return ee(V(t)).left+Re(t).scrollLeft}function br(t){var e=_(t),r=V(t),n=e.visualViewport,s=r.clientWidth,i=r.clientHeight,a=0,o=0;return n&&(s=n.width,i=n.height,/^((?!chrome|android).)*safari/i.test(navigator.userAgent)||(a=n.offsetLeft,o=n.offsetTop)),{width:s,height:i,x:a+Ne(t),y:o}}function gr(t){var e,r=V(t),n=Re(t),s=(e=t.ownerDocument)==null?void 0:e.body,i=H(r.scrollWidth,r.clientWidth,s?s.scrollWidth:0,s?s.clientWidth:0),a=H(r.scrollHeight,r.clientHeight,s?s.scrollHeight:0,s?s.clientHeight:0),o=-n.scrollLeft+Ne(t),c=-n.scrollTop;return W(s||r).direction==="rtl"&&(o+=H(r.clientWidth,s?s.clientWidth:0)-i),{width:i,height:a,x:o,y:c}}function je(t){var e=W(t),r=e.overflow,n=e.overflowX,s=e.overflowY;return/auto|scroll|overlay|hidden/.test(r+s+n)}function Et(t){return["html","body","#document"].indexOf(R(t))>=0?t.ownerDocument.body:D(t)&&je(t)?t:Et(Se(t))}function se(t,e){var r;e===void 0&&(e=[]);var n=Et(t),s=n===((r=t.ownerDocument)==null?void 0:r.body),i=_(n),a=s?[i].concat(i.visualViewport||[],je(n)?n:[]):n,o=e.concat(a);return s?o:o.concat(se(Se(a)))}function Pe(t){return Object.assign({},t,{left:t.x,top:t.y,right:t.x+t.width,bottom:t.y+t.height})}function yr(t){var e=ee(t);return e.top=e.top+t.clientTop,e.left=e.left+t.clientLeft,e.bottom=e.top+t.clientHeight,e.right=e.left+t.clientWidth,e.width=t.clientWidth,e.height=t.clientHeight,e.x=e.left,e.y=e.top,e}function tt(t,e){return e===ht?Pe(br(t)):D(e)?yr(e):Pe(gr(V(t)))}function wr(t){var e=se(Se(t)),r=["absolute","fixed"].indexOf(W(t).position)>=0,n=r&&D(t)?de(t):t;return oe(n)?e.filter(function(s){return oe(s)&&bt(s,n)&&R(s)!=="body"}):[]}function Er(t,e,r){var n=e==="clippingParents"?wr(t):[].concat(e),s=[].concat(n,[r]),i=s[0],a=s.reduce(function(o,c){var l=tt(t,c);return o.top=H(l.top,o.top),o.right=ie(l.right,o.right),o.bottom=ie(l.bottom,o.bottom),o.left=H(l.left,o.left),o},tt(t,i));return a.width=a.right-a.left,a.height=a.bottom-a.top,a.x=a.left,a.y=a.top,a}function ae(t){return t.split("-")[1]}function At(t){var e=t.reference,r=t.element,n=t.placement,s=n?B(n):null,i=n?ae(n):null,a=e.x+e.width/2-r.width/2,o=e.y+e.height/2-r.height/2,c;switch(s){case T:c={x:a,y:e.y-r.height};break;case P:c={x:a,y:e.y+e.height};break;case $:c={x:e.x+e.width,y:o};break;case q:c={x:e.x-r.width,y:o};break;default:c={x:e.x,y:e.y}}var l=s?Be(s):null;if(l!=null){var d=l==="y"?"height":"width";switch(i){case Z:c[l]=c[l]-(e[d]/2-r[d]/2);break;case Ie:c[l]=c[l]+(e[d]/2-r[d]/2);break}}return c}function ce(t,e){e===void 0&&(e={});var r=e,n=r.placement,s=n===void 0?t.placement:n,i=r.boundary,a=i===void 0?Ft:i,o=r.rootBoundary,c=o===void 0?ht:o,l=r.elementContext,d=l===void 0?re:l,p=r.altBoundary,f=p===void 0?!1:p,h=r.padding,m=h===void 0?0:h,g=yt(typeof m!="number"?m:wt(m,le)),v=d===re?Ht:re,b=t.elements.reference,y=t.rects.popper,E=t.elements[f?v:d],u=Er(oe(E)?E:E.contextElement||V(t.elements.popper),a,c),k=ee(b),w=At({reference:k,element:y,placement:s}),S=Pe(Object.assign({},y,w)),A=d===re?S:k,L={top:u.top-A.top+g.top,bottom:A.bottom-u.bottom+g.bottom,left:u.left-A.left+g.left,right:A.right-u.right+g.right},O=t.modifiersData.offset;if(d===re&&O){var I=O[s];Object.keys(L).forEach(function(N){var C=[$,P].indexOf(N)>=0?1:-1,z=[T,P].indexOf(N)>=0?"y":"x";L[N]+=I[z]*C})}return L}function Ar(t,e){e===void 0&&(e={});var r=e,n=r.placement,s=r.boundary,i=r.rootBoundary,a=r.padding,o=r.flipVariations,c=r.allowedAutoPlacements,l=c===void 0?mt:c,d=ae(n),p=d?o?Ge:Ge.filter(function(m){return ae(m)===d}):le,f=p.filter(function(m){return l.indexOf(m)>=0});f.length===0&&(f=p);var h=f.reduce(function(m,g){return m[g]=ce(t,{placement:g,boundary:s,rootBoundary:i,padding:a})[B(g)],m},{});return Object.keys(h).sort(function(m,g){return h[m]-h[g]})}function xr(t){if(B(t)===_e)return[];var e=xe(t);return[et(t),e,et(e)]}function Sr(t){var e=t.state,r=t.options,n=t.name;if(!e.modifiersData[n]._skip){for(var s=r.mainAxis,i=s===void 0?!0:s,a=r.altAxis,o=a===void 0?!0:a,c=r.fallbackPlacements,l=r.padding,d=r.boundary,p=r.rootBoundary,f=r.altBoundary,h=r.flipVariations,m=h===void 0?!0:h,g=r.allowedAutoPlacements,v=e.options.placement,b=B(v),y=b===v,E=c||(y||!m?[xe(v)]:xr(v)),u=[v].concat(E).reduce(function(Y,M){return Y.concat(B(M)===_e?Ar(e,{placement:M,boundary:d,rootBoundary:p,padding:l,flipVariations:m,allowedAutoPlacements:g}):M)},[]),k=e.rects.reference,w=e.rects.popper,S=new Map,A=!0,L=u[0],O=0;O<u.length;O++){var I=u[O],N=B(I),C=ae(I)===Z,z=[T,P].indexOf(N)>=0,te=z?"width":"height",J=ce(e,{placement:I,boundary:d,rootBoundary:p,altBoundary:f,padding:l}),X=z?C?$:q:C?P:T;k[te]>w[te]&&(X=xe(X));var ke=xe(X),K=[];if(i&&K.push(J[N]<=0),o&&K.push(J[X]<=0,J[ke]<=0),K.every(function(Y){return Y})){L=I,A=!1;break}S.set(I,K)}if(A)for(var ue=m?3:1,Le=function(M){var pe=u.find(function(Ce){var G=S.get(Ce);if(G)return G.slice(0,M).every(function(Oe){return Oe})});if(pe)return L=pe,"break"},U=ue;U>0;U--){var fe=Le(U);if(fe==="break")break}e.placement!==L&&(e.modifiersData[n]._skip=!0,e.placement=L,e.reset=!0)}}const kr={name:"flip",enabled:!0,phase:"main",fn:Sr,requiresIfExists:["offset"],data:{_skip:!1}};function rt(t,e,r){return r===void 0&&(r={x:0,y:0}),{top:t.top-e.height-r.y,right:t.right-e.width+r.x,bottom:t.bottom-e.height+r.y,left:t.left-e.width-r.x}}function nt(t){return[T,$,P,q].some(function(e){return t[e]>=0})}function Lr(t){var e=t.state,r=t.name,n=e.rects.reference,s=e.rects.popper,i=e.modifiersData.preventOverflow,a=ce(e,{elementContext:"reference"}),o=ce(e,{altBoundary:!0}),c=rt(a,n),l=rt(o,s,i),d=nt(c),p=nt(l);e.modifiersData[r]={referenceClippingOffsets:c,popperEscapeOffsets:l,isReferenceHidden:d,hasPopperEscaped:p},e.attributes.popper=Object.assign({},e.attributes.popper,{"data-popper-reference-hidden":d,"data-popper-escaped":p})}const Cr={name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:Lr};function Or(t,e,r){var n=B(t),s=[q,T].indexOf(n)>=0?-1:1,i=typeof r=="function"?r(Object.assign({},e,{placement:t})):r,a=i[0],o=i[1];return a=a||0,o=(o||0)*s,[q,$].indexOf(n)>=0?{x:o,y:a}:{x:a,y:o}}function Tr(t){var e=t.state,r=t.options,n=t.name,s=r.offset,i=s===void 0?[0,0]:s,a=mt.reduce(function(d,p){return d[p]=Or(p,e.rects,i),d},{}),o=a[e.placement],c=o.x,l=o.y;e.modifiersData.popperOffsets!=null&&(e.modifiersData.popperOffsets.x+=c,e.modifiersData.popperOffsets.y+=l),e.modifiersData[n]=a}const qr={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:Tr};function Pr(t){var e=t.state,r=t.name;e.modifiersData[r]=At({reference:e.rects.reference,element:e.rects.popper,placement:e.placement})}const $r={name:"popperOffsets",enabled:!0,phase:"read",fn:Pr,data:{}};function Dr(t){return t==="x"?"y":"x"}function _r(t){var e=t.state,r=t.options,n=t.name,s=r.mainAxis,i=s===void 0?!0:s,a=r.altAxis,o=a===void 0?!1:a,c=r.boundary,l=r.rootBoundary,d=r.altBoundary,p=r.padding,f=r.tether,h=f===void 0?!0:f,m=r.tetherOffset,g=m===void 0?0:m,v=ce(e,{boundary:c,rootBoundary:l,padding:p,altBoundary:d}),b=B(e.placement),y=ae(e.placement),E=!y,u=Be(b),k=Dr(u),w=e.modifiersData.popperOffsets,S=e.rects.reference,A=e.rects.popper,L=typeof g=="function"?g(Object.assign({},e.rects,{placement:e.placement})):g,O={x:0,y:0};if(w){if(i||o){var I=u==="y"?T:q,N=u==="y"?P:$,C=u==="y"?"height":"width",z=w[u],te=w[u]+v[I],J=w[u]-v[N],X=h?-A[C]/2:0,ke=y===Z?S[C]:A[C],K=y===Z?-A[C]:-S[C],ue=e.elements.arrow,Le=h&&ue?Me(ue):{width:0,height:0},U=e.modifiersData["arrow#persistent"]?e.modifiersData["arrow#persistent"].padding:gt(),fe=U[I],Y=U[N],M=Ae(0,S[C],Le[C]),pe=E?S[C]/2-X-M-fe-L:ke-M-fe-L,Ce=E?-S[C]/2+X+M+Y+L:K+M+Y+L,G=e.elements.arrow&&de(e.elements.arrow),Oe=G?u==="y"?G.clientTop||0:G.clientLeft||0:0,We=e.modifiersData.offset?e.modifiersData.offset[e.placement][u]:0,Fe=w[u]+pe-We-Oe,He=w[u]+Ce-We;if(i){var Ve=Ae(h?ie(te,Fe):te,z,h?H(J,He):J);w[u]=Ve,O[u]=Ve-z}if(o){var St=u==="x"?T:q,kt=u==="x"?P:$,he=w[k],ze=he+v[St],Xe=he-v[kt],Ye=Ae(h?ie(ze,Fe):ze,he,h?H(Xe,He):Xe);w[k]=Ye,O[k]=Ye-he}}e.modifiersData[n]=O}}const Ir={name:"preventOverflow",enabled:!0,phase:"main",fn:_r,requiresIfExists:["offset"]};function Mr(t){return{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}}function Br(t){return t===_(t)||!D(t)?Re(t):Mr(t)}function Rr(t,e,r){r===void 0&&(r=!1);var n=V(e),s=ee(t),i=D(e),a={scrollLeft:0,scrollTop:0},o={x:0,y:0};return(i||!i&&!r)&&((R(e)!=="body"||je(n))&&(a=Br(e)),D(e)?(o=ee(e),o.x+=e.clientLeft,o.y+=e.clientTop):n&&(o.x=Ne(n))),{x:s.left+a.scrollLeft-o.x,y:s.top+a.scrollTop-o.y,width:s.width,height:s.height}}function Nr(t){var e=new Map,r=new Set,n=[];t.forEach(function(i){e.set(i.name,i)});function s(i){r.add(i.name);var a=[].concat(i.requires||[],i.requiresIfExists||[]);a.forEach(function(o){if(!r.has(o)){var c=e.get(o);c&&s(c)}}),n.push(i)}return t.forEach(function(i){r.has(i.name)||s(i)}),n}function jr(t){var e=Nr(t);return Zt.reduce(function(r,n){return r.concat(e.filter(function(s){return s.phase===n}))},[])}function Wr(t){var e;return function(){return e||(e=new Promise(function(r){Promise.resolve().then(function(){e=void 0,r(t())})})),e}}function Fr(t){var e=t.reduce(function(r,n){var s=r[n.name];return r[n.name]=s?Object.assign({},s,n,{options:Object.assign({},s.options,n.options),data:Object.assign({},s.data,n.data)}):n,r},{});return Object.keys(e).map(function(r){return e[r]})}var st={placement:"bottom",modifiers:[],strategy:"absolute"};function ot(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return!e.some(function(n){return!(n&&typeof n.getBoundingClientRect=="function")})}function Hr(t){t===void 0&&(t={});var e=t,r=e.defaultModifiers,n=r===void 0?[]:r,s=e.defaultOptions,i=s===void 0?st:s;return function(o,c,l){l===void 0&&(l=i);var d={placement:"bottom",orderedModifiers:[],options:Object.assign({},st,i),modifiersData:{},elements:{reference:o,popper:c},attributes:{},styles:{}},p=[],f=!1,h={state:d,setOptions:function(b){g(),d.options=Object.assign({},i,d.options,b),d.scrollParents={reference:oe(o)?se(o):o.contextElement?se(o.contextElement):[],popper:se(c)};var y=jr(Fr([].concat(n,d.options.modifiers)));return d.orderedModifiers=y.filter(function(E){return E.enabled}),m(),h.update()},forceUpdate:function(){if(!f){var b=d.elements,y=b.reference,E=b.popper;if(ot(y,E)){d.rects={reference:Rr(y,de(E),d.options.strategy==="fixed"),popper:Me(E)},d.reset=!1,d.placement=d.options.placement,d.orderedModifiers.forEach(function(O){return d.modifiersData[O.name]=Object.assign({},O.data)});for(var u=0;u<d.orderedModifiers.length;u++){if(d.reset===!0){d.reset=!1,u=-1;continue}var k=d.orderedModifiers[u],w=k.fn,S=k.options,A=S===void 0?{}:S,L=k.name;typeof w=="function"&&(d=w({state:d,options:A,name:L,instance:h})||d)}}}},update:Wr(function(){return new Promise(function(v){h.forceUpdate(),v(d)})}),destroy:function(){g(),f=!0}};if(!ot(o,c))return h;h.setOptions(l).then(function(v){!f&&l.onFirstUpdate&&l.onFirstUpdate(v)});function m(){d.orderedModifiers.forEach(function(v){var b=v.name,y=v.options,E=y===void 0?{}:y,u=v.effect;if(typeof u=="function"){var k=u({state:d,name:b,instance:h,options:E}),w=function(){};p.push(k||w)}})}function g(){p.forEach(function(v){return v()}),p=[]}return h}}var Vr=[hr,$r,fr,rr,qr,kr,Ir,cr,Cr],zr=Hr({defaultModifiers:Vr});const Xr=parseInt(ut.baseline.$value,10),Yr="js-mds-popover-trigger",we="mds-popover--active",ne={init:()=>{Array.from(document.querySelectorAll(`.${Yr}`)).forEach(e=>{const n=`${e.getAttribute("id")}-content`,s=document.getElementById(n),i=s.dataset?s.dataset.placement:null,a=zr(e,s,{placement:i||"top-end",strategy:"fixed",modifiers:[{name:"offset",options:{offset:[0,Xr*3]}},{name:"arrow",options:{padding:5}}]});e.setAttribute("aria-expanded","false"),s.setAttribute("aria-hidden","true"),e.addEventListener("click",o=>{o.preventDefault(),a.update(),s.classList.toggle(we),ne.setAriaAttr(e,s,we)}),document.addEventListener("mousedown",o=>{ne.hide(e,s,a,we,o)}),document.addEventListener("keydown",o=>{ne.hide(e,s,a,we,o)})})},hide:(t,e,r,n,s)=>{!t.contains(s.target)&&!r.state.elements.popper.contains(s.target)&&e.classList.contains(n)&&(e.classList.remove(n),ne.setAriaAttr(t,e,n))},setAriaAttr:(t,e,r)=>{e.classList.contains(r)?(t.setAttribute("aria-expanded","true"),e.removeAttribute("aria-hidden")):(t.setAttribute("aria-expanded","false"),e.setAttribute("aria-hidden","true"))}},Jr=parseInt(ft.size.breakpoint.md.$value,10),it="data-modal-id",at="mds-modal--active",Kr="js-mds-modal-close";let Ee;const Q={init:()=>{window.innerWidth>Jr&&Array.from(document.querySelectorAll(`[${it}]`)).forEach(r=>{const n=r.getAttribute(it),s=document.getElementById(n),i=Array.from(s.querySelectorAll(`.${Kr}`)),a=s.getAttribute("data-site-container"),o=document.getElementById(a);let l=s.querySelectorAll('a[href], area[href], input:not([disabled]):not([type="hidden"]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), iframe, object, embed, [tabindex="0"], [contenteditable]');l=Array.prototype.slice.call(l);const d=l[0],p=l[l.length-1];r.addEventListener("click",f=>{f.preventDefault(),Q.open(s,d,o)}),s.addEventListener("click",f=>{f.target===s&&Q.close(s,Ee,o)}),s.addEventListener("keydown",f=>{Q.trapFocus(f,d,p),(f.key==="Escape"||f.key==="Esc")&&Q.close(s,Ee,o)}),i.forEach(f=>{f.addEventListener("click",()=>{Q.close(s,Ee,o)})})})},open:(t,e,r)=>{Ee=document.activeElement,t.classList.add(at),e.focus(),r?.setAttribute("aria-hidden","true")},close:(t,e,r)=>{r?.removeAttribute("aria-hidden"),t.classList.remove(at),e.focus()},trapFocus:(t,e,r)=>{t.key==="Tab"&&(t.shiftKey?document.activeElement===e&&(t.preventDefault(),r.focus()):document.activeElement===r&&(t.preventDefault(),e.focus()))}};class j extends HTMLElement{static selectedFileClass="mds-file-upload--selected-file";static selectedFileIsImageClass="mds-file-upload--selected-file-is-image";static dragOverClass="mds-file-upload--dragover";constructor(){super()}connectedCallback(){this.classList.add("mds-form-element--file-supported"),this.#e.addEventListener("change",this.#l),this.#r.addEventListener("click",this.#p),this.#e.addEventListener("dragover",this.#s),this.#e.addEventListener("dragenter",this.#s),this.#e.addEventListener("dragleave",this.#d),this.#e.addEventListener("dragend",this.#d),this.#e.addEventListener("drop",this.#d),this.#o?.addEventListener("commit",this.#h),this.#o?.addEventListener("reset",this.#v),this.#b(!0)}disconnectedCallback(){this.#e?.removeEventListener("change",this.#l),this.#r?.removeEventListener("click",this.#p),this.#e?.removeEventListener("dragover",this.#s),this.#e?.removeEventListener("dragenter",this.#s),this.#e?.removeEventListener("dragleave",this.#d),this.#e?.removeEventListener("dragend",this.#d),this.#e?.removeEventListener("drop",this.#d),this.#o?.removeEventListener("commit",this.#h),this.#o?.removeEventListener("reset",this.#v)}get rootNode(){return this}get#a(){return this.getRootNode({composed:!0})}get#n(){return this.#e?.files?.[0]}get#c(){return this.#n?.type?.startsWith("image/")}get#i(){const e=this.rootNode.getAttribute("no-auto-open-image-cropper");return e!==null&&e!=="false"}get#t(){return this.rootNode.querySelector(".mds-file-upload__file-name")}get#e(){return this.rootNode.querySelector("input[type=file]")}get#r(){return this.rootNode.querySelector(".mds-file-upload__remove-button")}get#u(){return this.rootNode.querySelector(".mds-file-upload__preview-image")}get#m(){return this.rootNode.querySelector(".mds-file-upload__open-modal")}get#f(){return this.rootNode.querySelector(".mds-modal")}get#o(){return this.rootNode.querySelector("mds-image-cropper")}#l=e=>{const{dontOpenModal:r=!1}=e?.detail||{};this.#b(),this.#n&&this.#r.focus(),!r&&this.#c&&!this.#i&&this.#y()};#p=e=>{e.preventDefault(),this.removeFile(),this.#e.focus()};#s=e=>{e.stopPropagation(),this.classList.add(j.dragOverClass)};#d=e=>{e.stopPropagation(),this.classList.remove(j.dragOverClass)};#h=e=>{const r=e.detail;if(r){const n=new File([r],this.#n?.name||"cropped-image",{type:r.type}),s=new DataTransfer;s.items.add(n),this.#e.files=s.files,this.#e.dispatchEvent(new CustomEvent("change",{detail:{dontOpenModal:!0},bubbles:!0})),this.#g()}};#v=()=>{this.#g()};#b(e=!1){if(this.#n)if(this.#t.textContent=this.#n.name,this.classList.add(j.selectedFileClass),this.#c){this.classList.add(j.selectedFileIsImageClass);const r=new FileReader;r.onload=n=>{this.#u.src=n.target.result,this.#o?.setAttribute("src",n.target.result)},r.readAsDataURL(this.#n)}else this.classList.remove(j.selectedFileIsImageClass);else e||(this.#t.textContent="",this.classList.remove(j.selectedFileClass),this.classList.remove(j.selectedFileIsImageClass))}#y(){this.#m?.dispatchEvent(new Event("click"))}#g(){this.#f?.querySelector(".js-mds-modal-close").dispatchEvent(new Event("click"))}removeFile(){this.#e.value="",this.#e.dispatchEvent(new Event("change",{bubbles:!0}))}}const Ur=".mds-form-element--character-count",Gr=".mds-form-message--character-count",Qr=".js-character-count-number",Zr=".mds-form-control",$e={init:()=>{Array.from(document.querySelectorAll(Ur)).forEach(e=>{const r=e.querySelector(Zr),n=r.getAttribute("maxlength"),s=e.querySelector(Gr),i=e.querySelector(Qr);r.removeAttribute("maxlength"),$e.updateCounter(r,n,i,s),r.addEventListener("input",a=>{a.stopPropagation(),$e.updateCounter(r,n,i,s)})})},updateCounter:(t,e,r,n)=>{const s=t.value.match(/(\r\n|\n|\r)/g),i=t.value.length+(s?s.length:0),a=e-i;r.textContent=a,a<0?n.classList.add("mds-form-message--error"):n.classList.remove("mds-form-message--error")}},en="js-mds-button-double-submit",xt={init:()=>{Array.from(document.querySelectorAll(`.${en}`)).forEach(e=>{e.addEventListener("click",()=>{xt.toggleDisable(e)})})},toggleDisable:t=>{setTimeout(()=>{t.setAttribute("disabled","")},1),setTimeout(()=>{t.removeAttribute("disabled")},1e3)}},tn={setFluidVideos:()=>{Array.from(document.querySelectorAll(".mds-prose iframe, .mds-prose embed, .mds-prose object")).filter(e=>!e.closest("mds-consent-gate")).forEach(e=>{const r=document.createElement("div");r.classList.add("mds-fluid-video"),r.innerHTML=e.outerHTML,e.replaceWith(r)})}};class rn extends HTMLElement{connectedCallback(){const r=this.querySelector(".mds-card-link__link");let n;this.onmousedown=()=>{n=+new Date},this.onmouseup=()=>{+new Date-n<200&&r.click(),n=void 0}}disconnectedCallback(){this.onmousedown=this.onmouseup=null}}class nn extends HTMLElement{static observedAttributes=["form","field-name","show-when"];showHide=()=>{const{field:e}=this,r=this.getAttribute("show-when");(e.type==="checkbox"?e.checked.toString():e.value.toString())===r?this.hidden=!1:this.hidden=!0};setup=()=>{this.cleanup();const e=this.getAttribute("form"),r=this.getAttribute("field-name");if(this.formElement=e?document.querySelector(e):this.closest("form"),!this.formElement)throw new Error(`<mds-conditional-section> for ${r} could not find the associated form`);if(this.field=this.formElement.elements[r],!this.field)throw new Error(`<mds-conditional-section> for ${r} could not find the associated field`);this.showHide(),this.formElement.addEventListener("input",this.showHide)};connectedCallback(){this.setup()}cleanup=()=>{this.formElement?.removeEventListener("input",this.showHide)};disconnectedCallback(){this.cleanup()}attributeChangedCallback(e,r,n){const{showHide:s,setup:i}=this;this.isConnected&&r!==n&&(e==="show-when"?s():(e==="field-name"||e==="form")&&i())}}const F=".mds-form-check",Te=".mds-form-check__input",sn=".mds-form-check__label",ct=".mds-form-check__nested-container",lt=".mds-category-picker__pill",qe=".mds-category-picker__clear-pill",dt={optionsSelectedSingular:"1 option selected",optionsSelectedPlural:"{count} options selected",optionsFoundSingular:"1 option found",optionsFoundPlural:"{count} options found"};class on extends HTMLElement{#a;#n;#c;#i;#t;#e;#r;#u;#m;#f;#o=new WeakMap;#l=!1;connectedCallback(){const e=this.querySelector(".mds-category-picker__templates");if(this.#n=this.querySelector(".mds-category-picker__pillbox"),this.#t=this.querySelector(".mds-category-picker__search"),this.#e=this.querySelector(".mds-category-picker__input-wrapper"),this.#r=this.querySelector(".mds-category-picker__dropdown"),this.#u=this.querySelector(".mds-category-picker__live-region"),this.#m=this.querySelector(".mds-category-picker__no-results"),!e||!this.#n||!this.#t||!this.#r)return;try{this.#f={...dt,...JSON.parse(this.getAttribute("i18n")||"{}")}}catch{this.#f=dt}if(this.#c=e.querySelector(lt),this.#i=e.querySelector(qe),!this.#c||!this.#i)return;e.remove(),this.#a=new AbortController;const r={signal:this.#a.signal};this.#n.addEventListener("click",this.#b,r),this.#r.addEventListener("change",this.#y,r),this.#t.addEventListener("blur",this.#d,r),this.#t.addEventListener("input",this.#g,r),this.#t.addEventListener("keydown",this.#k,r),this.#e.addEventListener("click",()=>this.#t.focus(),r),this.#t.addEventListener("focus",()=>this.#p(),r),this.#r.addEventListener("mousedown",n=>{n.target!==this.#t&&n.preventDefault()},r),this.#r.addEventListener("focusout",n=>{(!n.relatedTarget||!this.contains(n.relatedTarget))&&this.#s()},r),this.#r.addEventListener("keydown",n=>{n.key==="Escape"&&(this.#s(),this.#t.focus())},r),document.addEventListener("click",n=>{n.composedPath().includes(this)||this.#s()},r),this.#h()}disconnectedCallback(){this.#a?.abort()}#p(){this.#l||(this.#l=!0,this.classList.add("mds-category-picker--open"),this.#t.setAttribute("aria-expanded","true"))}#s(){this.#l&&(this.#l=!1,this.classList.remove("mds-category-picker--open"),this.#t.setAttribute("aria-expanded","false"),this.#t.value="",this.#w())}#d=e=>{const r=e.relatedTarget;r&&(this.#r.contains(r)||this.#e.contains(r))||this.#s()};#h=()=>{this.#n.replaceChildren(),this.#o=new WeakMap;const e="mds-form-check--has-selection";for(const r of this.#r.querySelectorAll(F))r.classList.remove(e);for(const r of this.#r.querySelectorAll(`${Te}:checked`)){this.#v(r);let n=r.closest(F)?.parentElement;for(;n&&n!==this.#r;)n.matches(F)&&n.classList.add(e),n=n.parentElement}};#v(e){const r=e.dataset.path;if(!r)return;const n=this.#c.cloneNode(!0),s=this.#i.cloneNode(!0);s.setAttribute("aria-label",`${s.getAttribute("aria-label")} ${r}`);const i=document.createElement("span");i.className="mds-category-picker__pill-text",i.textContent=r,n.appendChild(i),n.appendChild(s),this.#n.appendChild(n),this.#o.set(s,e)}#b=({target:e})=>{const r=this.#o.get(e.closest(qe));r&&(r.checked=!1,r.dispatchEvent(new Event("change",{bubbles:!0})))};#y=()=>{this.#h(),this.#t.value="",this.#w();const e=this.#r.querySelectorAll(`${Te}:checked`).length;this.#x(this.#A("optionsSelectedSingular","optionsSelectedPlural",e))};#g=()=>{const e=this.#t.value.trim();e.length>=2?this.#S(e):this.#w()};#S(e){const r=e.toLowerCase(),n=this.#r.querySelectorAll(F),s=new Set,i=new Set;for(const o of n){const c=o.querySelector(sn)?.textContent.trim().toLowerCase()||"";if(c){if(o.querySelector(ct)){c.includes(r)&&(s.add(o),i.add(o));continue}if(o.hidden=!c.includes(r),!o.hidden){let l=o.parentElement;for(;l&&l!==this.#r;)l.matches(F)&&s.add(l),l=l.parentElement}}}for(const o of n){const c=o.querySelector(ct);if(c)if(s.has(o)){if(o.hidden=!1,o.querySelector(".mds-checkbox-accordion__button")?.setAttribute("aria-expanded","true"),i.has(o))for(const l of c.querySelectorAll(F))l.hidden=!1}else o.hidden=!0}let a=0;for(const o of n)o.hidden||a++;this.#E(a===0),this.#x(this.#A("optionsFoundSingular","optionsFoundPlural",a))}#w(){for(const e of this.#r.querySelectorAll(F))e.hidden=!1;this.#E(!1)}#E(e){this.#m?.classList.toggle("mds-category-picker__no-results--visible",e)}#k=e=>{switch(e.key){case"Escape":this.#s(),this.#t.blur();break;case"ArrowDown":{e.preventDefault(),this.#l||this.#p();for(const r of this.#r.querySelectorAll(F)){if(r.hidden)continue;const n=r.querySelector(Te);if(n){n.focus();break}}break}case"Backspace":if(this.#t.value===""){const r=this.#n.querySelectorAll(lt),n=r[r.length-1];if(!n)break;const s=this.#o.get(n.querySelector(qe));s&&(s.checked=!1,s.dispatchEvent(new Event("change",{bubbles:!0})))}break;case"Tab":this.#s();break}};#A(e,r,n){return n===1?this.#f[e]:this.#f[r].replace("{count}",String(n))}#x(e){this.#u&&(this.#u.textContent="",requestAnimationFrame(()=>{this.#u.textContent=e}))}}class an extends HTMLElement{#a;constructor(){super()}#n(e){const r=[0,.25,.5,.75,1];if(e==null||e.trim()==="")return r;const n=Number(e);if(!Number.isNaN(n))return n;const s=i=>Array.isArray(i)&&i.length>0&&i.every(a=>typeof a=="number"&&!Number.isNaN(a));try{const i=JSON.parse(e);if(s(i))return i}catch{}return console.warn(`${this.constructor.name}: Invalid observer-threshold "${e}". Falling back to default thresholds.`),r}#c(){const e=new Map,r=n=>{if(n.forEach(o=>{o.intersectionRatio===0?e.delete(o.target.id):e.set(o.target.id,o.intersectionRatio)}),e.size===0){this.#i.forEach(o=>o.removeAttribute("aria-current"));return}const s=e.entries().reduce((o,c)=>c[1]>o[1]?c:o),i=s[0],a=s[1];this.#i.forEach(o=>o.removeAttribute("aria-current")),i&&a>0&&this.querySelector(`[href="#${CSS.escape(i)}"]`)?.setAttribute("aria-current",this.#e)};this.#a=new IntersectionObserver(r,this.#r),this.#t.forEach(n=>this.#a.observe(n))}connectedCallback(){this.#t.length>0&&this.#c()}disconnectedCallback(){this.#a?.disconnect()}get#i(){return Array.from(this.querySelectorAll("a"))}get#t(){const e=[];return this.#i.forEach(r=>{if(new URL(r.href).host!==window.location.host||!r.hash)return;const n=document.querySelector(`#${CSS.escape(r.hash.substring(1))}`);if(!n){console.warn(`${this.constructor.name}: Element with id "${r.hash}" doesn't exist on this page.`);return}e.push(n)}),e}get#e(){return this.getAttribute("aria-current-value")||"step"}get#r(){const e=this.getAttribute("observer-root"),r=this.getAttribute("observer-threshold");return{root:document.querySelector(e),threshold:this.#n(r)}}}window.customElements.get("mds-dropdown-nav")||window.customElements.define("mds-dropdown-nav",Lt);window.customElements.get("mds-timeout-dialog")||window.customElements.define("mds-timeout-dialog",Ct);window.customElements.get("mds-card-link")||window.customElements.define("mds-card-link",rn);window.customElements.get("mds-conditional-section")||window.customElements.define("mds-conditional-section",nn);window.customElements.get("mds-image-cropper")||window.customElements.define("mds-image-cropper",Ot);window.customElements.get("mds-file-upload")||window.customElements.define("mds-file-upload",j);window.customElements.get("mds-category-picker")||window.customElements.define("mds-category-picker",on);window.customElements.get("mds-scroll-spy")||window.customElements.define("mds-scroll-spy",an);window.customElements.get("mds-consent-gate")||window.customElements.define("mds-consent-gate",Tt);const De=()=>{x.init(),pt.init(),Rt.init(),Wt.init(),Q.init(),$e.init(),ne.init(),xt.init(),tn.setFluidVideos()};window.mdgxInitAll=De;document.readyState==="loading"?document.addEventListener("DOMContentLoaded",De):De();export{hn as setConsentAdapter};
|
|
1
|
+
import{M as Ct}from"./dropdown-nav-DGGzV21D.js";import{M as Lt}from"./timeout-dialog-plrFUmdZ.js";import{M as Ot}from"./image-cropper-BUN9gxO4.js";import{M as Tt}from"./consent-gate-DVi5q-ir.js";import{s as bn}from"./consent-gate-DVi5q-ir.js";window.addEventListener("hashchange",()=>{const t=window.location.hash.trim();Array.from(document.querySelectorAll(`a[href='${t}']`)).forEach(r=>{r.click()})},!1);const ut={baseline:{$value:"4px"},breakpoint:{md:{$value:"600px"},lg:{$value:"1008px"}}},ft={size:ut},qt="js-tabs-item",Je="mds-tabs",Pt="mds-tabs__list",$t="mds-tabs__list-item",Ke="mds-tabs__panel",me="mds-tabs__tab",ve="mds-tabs__tab--selected",Ue="mds-tabs__panel--hidden",be={left:37,right:39,up:38,down:40},Dt=".js-desktop-tabbed",_t=".js-full-tabbed",It=parseInt(ft.size.breakpoint.lg.$value,10),x={init:()=>{x.setTabs(_t),window.innerWidth>It&&x.setTabs(Dt)},setTabs:t=>{const e=Array.from(document.querySelectorAll(`${t} .${me}`)),r=Array.from(document.querySelectorAll(`${t} .${Pt}`)),n=Array.from(document.querySelectorAll(`${t} .${$t}`)),s=Array.from(document.querySelectorAll(`${t} .${Ke}`));r.forEach(i=>{i.setAttribute("role","tablist")}),n.forEach(i=>{i.setAttribute("role","presentation")}),e.forEach(i=>{i.setAttribute("role","tab"),i.setAttribute("aria-controls",i.attributes.href.value.substring(1)),i.classList.contains(ve)?i.setAttribute("tabindex","0"):i.setAttribute("tabindex","-1")}),s.forEach(i=>{i.setAttribute("role","tabpanel"),i.setAttribute("aria-labelledby",`label-${i.attributes.id.value}`)});const o=document.querySelectorAll(`${t} .${qt}`);Array.from(o).forEach(i=>{const c=window.location.hash.trim(),l=i.attributes.href.value,d=i.closest(`.${Je}`),p=x.getAllPanels(d),f=x.getAllTabs(d),h=x.getTargetPanel(i,d);i.addEventListener("click",m=>{m.preventDefault(),x.updateTabs(f,p,i,h,l)}),l===c&&x.updateTabs(f,p,i,h,l)}),r.forEach(i=>{const c=i.closest(`.${Je}`),l=x.getAllPanels(c),d=x.getAllTabs(c);i.addEventListener("keydown",p=>{switch(p.keyCode){case be.left:case be.up:p.preventDefault(),x.moveTab(i,c,d,l,!1);break;case be.right:case be.down:p.preventDefault(),x.moveTab(i,c,d,l,!0);break}})})},getSelectedTab:t=>t.querySelector(`.${ve}`),getPrevTab:t=>t.parentElement.previousSibling?t.parentElement.previousSibling.querySelector(`.${me}`):!1,getNextTab:t=>t.parentElement.nextSibling?t.parentElement.nextSibling.querySelector(`.${me}`):!1,getTargetPanel:(t,e)=>{const r=t.attributes.href.value;return e.querySelector(r)},getAllPanels:t=>Array.from(t.querySelectorAll(`.${Ke}`)),getAllTabs:t=>Array.from(t.querySelectorAll(`.${me}`)),moveTab:(t,e,r,n,s)=>{const o=x.getSelectedTab(t),a=s?x.getNextTab(o):x.getPrevTab(o);if(a){const i=a.attributes.href.value,c=x.getTargetPanel(a,e);x.updateTabs(r,n,a,c,i,!1)}},updateTabs:(t,e,r,n,s)=>{x.clearAllTabs(t),x.setActiveTab(r),x.clearAllPanels(e),x.setActivePanel(n,s)},clearAllTabs:t=>{t.forEach(e=>{e.classList.remove(ve),e.setAttribute("aria-selected","false"),e.setAttribute("tabindex","-1")})},clearAllPanels:t=>{t.forEach(e=>{e.classList.add(Ue)})},setActiveTab:t=>{t.classList.add(ve),t.setAttribute("aria-selected","true"),t.setAttribute("tabindex","0"),t.focus()},setActivePanel:(t,e)=>{t.classList.remove(Ue),window.history.replaceState({},"",e)}},Mt="mds-accordion--breakpoint",Bt="mds-accordion__label",pt={init:()=>{const t=document.querySelectorAll(`.${Mt}`),e=window.innerWidth;t.forEach(n=>{pt.checkBreakpoint(n,e)||(n.open=!0,n.querySelector("summary").style.display="none")}),document.querySelectorAll(`.${Bt}`).forEach(n=>{n.addEventListener("click",({target:s})=>{const o=s.closest("details"),a=o.querySelector("summary");o.open=!1,a.focus()})})},checkBreakpoint:(t,e)=>{let r=0;if(t.dataset.bp){const n=t.dataset.bp.replace(/\D/g,""),s=t.dataset.bp.replace(/[0-9]/g,"");let o,a;switch(s){case"px":r=n;break;case"em":o=window.getComputedStyle(document.querySelector("body"))["font-size"],a=n*parseFloat(o),r=a;break;case"rem":o=window.getComputedStyle(document.querySelector("body"))["font-size"],a=n*parseFloat(o),r=a;break;default:return!0}return!(e>r)}return!0}},Rt={init:()=>{const t=document.querySelectorAll(".mds-subnavigation"),e=[];let r;t.forEach(s=>{const o=s.querySelector(".mds-subnavigation__link-list"),a=Array.from(o.children),i=a[0],c=s.querySelector(".mds-subnavigation__mobile-title"),l=s.querySelector(".mds-subnavigation__drawer"),d=s.querySelector(".mds-subnavigation__drawer-label"),p=s.querySelector(".mds-subnavigation__drawer-label-text"),f=s.querySelector(".mds-subnavigation__drawer-content"),h=l.dataset.label,m=l.dataset.labelPlural;d.addEventListener("click",()=>{d.getAttribute("aria-expanded")==="true"?d.setAttribute("aria-expanded","false"):d.setAttribute("aria-expanded","true")}),l.addEventListener("focusout",v=>{l.contains(v.relatedTarget)||d.setAttribute("aria-expanded","false")});const g=()=>o.clientHeight>i.offsetHeight;e.push(()=>{d.setAttribute("aria-expanded","false"),window.getComputedStyle(c).getPropertyValue("display")==="none"?(a.forEach(b=>{o.append(b)}),l.style.display="none",g()&&(l.style.display="list-item",a.slice().reverse().forEach(b=>{if(g()&&b!==l){f.prepend(b);const y=Array.from(f.children).length,E=y>1?m:h;p.innerText=E.replace("{count}",y)}else o.prepend(b)}),f.style.width=`${o.offsetWidth-l.offsetLeft}px`)):(a.forEach(b=>{b!==l&&b!==c&&f.append(b)}),f.style.width="initial",l.style.display="block")})});const n=()=>{e.forEach(s=>{s()})};n(),window.onresize=()=>{clearTimeout(r),r=setTimeout(n,100)}}},Nt="mds-checkbox-accordion__button",jt="mds-checkbox-accordion__button--open",Wt={init:()=>{document.querySelectorAll(`.${Nt}`).forEach(e=>{e.classList.contains(jt)?e.setAttribute("aria-expanded","true"):e.setAttribute("aria-expanded","false"),e.addEventListener("click",()=>{e.getAttribute("aria-expanded")==="true"?e.setAttribute("aria-expanded","false"):e.setAttribute("aria-expanded","true")})})}};var T="top",P="bottom",$="right",q="left",_e="auto",le=[T,P,$,q],Z="start",Ie="end",Ft="clippingParents",ht="viewport",re="popper",Ht="reference",Ge=le.reduce(function(t,e){return t.concat([e+"-"+Z,e+"-"+Ie])},[]),mt=[].concat(le,[_e]).reduce(function(t,e){return t.concat([e,e+"-"+Z,e+"-"+Ie])},[]),Vt="beforeRead",zt="read",Xt="afterRead",Yt="beforeMain",Jt="main",Kt="afterMain",Ut="beforeWrite",Gt="write",Qt="afterWrite",Zt=[Vt,zt,Xt,Yt,Jt,Kt,Ut,Gt,Qt];function R(t){return t?(t.nodeName||"").toLowerCase():null}function _(t){if(t==null)return window;if(t.toString()!=="[object Window]"){var e=t.ownerDocument;return e&&e.defaultView||window}return t}function ie(t){var e=_(t).Element;return t instanceof e||t instanceof Element}function D(t){var e=_(t).HTMLElement;return t instanceof e||t instanceof HTMLElement}function vt(t){if(typeof ShadowRoot>"u")return!1;var e=_(t).ShadowRoot;return t instanceof e||t instanceof ShadowRoot}function er(t){var e=t.state;Object.keys(e.elements).forEach(function(r){var n=e.styles[r]||{},s=e.attributes[r]||{},o=e.elements[r];!D(o)||!R(o)||(Object.assign(o.style,n),Object.keys(s).forEach(function(a){var i=s[a];i===!1?o.removeAttribute(a):o.setAttribute(a,i===!0?"":i)}))})}function tr(t){var e=t.state,r={popper:{position:e.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};return Object.assign(e.elements.popper.style,r.popper),e.styles=r,e.elements.arrow&&Object.assign(e.elements.arrow.style,r.arrow),function(){Object.keys(e.elements).forEach(function(n){var s=e.elements[n],o=e.attributes[n]||{},a=Object.keys(e.styles.hasOwnProperty(n)?e.styles[n]:r[n]),i=a.reduce(function(c,l){return c[l]="",c},{});!D(s)||!R(s)||(Object.assign(s.style,i),Object.keys(o).forEach(function(c){s.removeAttribute(c)}))})}}const rr={name:"applyStyles",enabled:!0,phase:"write",fn:er,effect:tr,requires:["computeStyles"]};function B(t){return t.split("-")[0]}function ee(t){var e=t.getBoundingClientRect();return{width:e.width,height:e.height,top:e.top,right:e.right,bottom:e.bottom,left:e.left,x:e.left,y:e.top}}function Me(t){var e=ee(t),r=t.offsetWidth,n=t.offsetHeight;return Math.abs(e.width-r)<=1&&(r=e.width),Math.abs(e.height-n)<=1&&(n=e.height),{x:t.offsetLeft,y:t.offsetTop,width:r,height:n}}function bt(t,e){var r=e.getRootNode&&e.getRootNode();if(t.contains(e))return!0;if(r&&vt(r)){var n=e;do{if(n&&t.isSameNode(n))return!0;n=n.parentNode||n.host}while(n)}return!1}function W(t){return _(t).getComputedStyle(t)}function nr(t){return["table","td","th"].indexOf(R(t))>=0}function V(t){return((ie(t)?t.ownerDocument:t.document)||window.document).documentElement}function Se(t){return R(t)==="html"?t:t.assignedSlot||t.parentNode||(vt(t)?t.host:null)||V(t)}function Qe(t){return!D(t)||W(t).position==="fixed"?null:t.offsetParent}function sr(t){var e=navigator.userAgent.toLowerCase().indexOf("firefox")!==-1,r=navigator.userAgent.indexOf("Trident")!==-1;if(r&&D(t)){var n=W(t);if(n.position==="fixed")return null}for(var s=Se(t);D(s)&&["html","body"].indexOf(R(s))<0;){var o=W(s);if(o.transform!=="none"||o.perspective!=="none"||o.contain==="paint"||["transform","perspective"].indexOf(o.willChange)!==-1||e&&o.willChange==="filter"||e&&o.filter&&o.filter!=="none")return s;s=s.parentNode}return null}function de(t){for(var e=_(t),r=Qe(t);r&&nr(r)&&W(r).position==="static";)r=Qe(r);return r&&(R(r)==="html"||R(r)==="body"&&W(r).position==="static")?e:r||sr(t)||e}function Be(t){return["top","bottom"].indexOf(t)>=0?"x":"y"}var H=Math.max,oe=Math.min,ge=Math.round;function Ae(t,e,r){return H(t,oe(e,r))}function gt(){return{top:0,right:0,bottom:0,left:0}}function yt(t){return Object.assign({},gt(),t)}function wt(t,e){return e.reduce(function(r,n){return r[n]=t,r},{})}var ir=function(e,r){return e=typeof e=="function"?e(Object.assign({},r.rects,{placement:r.placement})):e,yt(typeof e!="number"?e:wt(e,le))};function or(t){var e,r=t.state,n=t.name,s=t.options,o=r.elements.arrow,a=r.modifiersData.popperOffsets,i=B(r.placement),c=Be(i),l=[q,$].indexOf(i)>=0,d=l?"height":"width";if(!(!o||!a)){var p=ir(s.padding,r),f=Me(o),h=c==="y"?T:q,m=c==="y"?P:$,g=r.rects.reference[d]+r.rects.reference[c]-a[c]-r.rects.popper[d],v=a[c]-r.rects.reference[c],b=de(o),y=b?c==="y"?b.clientHeight||0:b.clientWidth||0:0,E=g/2-v/2,u=p[h],k=y-f[d]-p[m],w=y/2-f[d]/2+E,S=Ae(u,w,k),A=c;r.modifiersData[n]=(e={},e[A]=S,e.centerOffset=S-w,e)}}function ar(t){var e=t.state,r=t.options,n=r.element,s=n===void 0?"[data-popper-arrow]":n;s!=null&&(typeof s=="string"&&(s=e.elements.popper.querySelector(s),!s)||bt(e.elements.popper,s)&&(e.elements.arrow=s))}const cr={name:"arrow",enabled:!0,phase:"main",fn:or,effect:ar,requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};var lr={top:"auto",right:"auto",bottom:"auto",left:"auto"};function dr(t){var e=t.x,r=t.y,n=window,s=n.devicePixelRatio||1;return{x:ge(ge(e*s)/s)||0,y:ge(ge(r*s)/s)||0}}function Ze(t){var e,r=t.popper,n=t.popperRect,s=t.placement,o=t.offsets,a=t.position,i=t.gpuAcceleration,c=t.adaptive,l=t.roundOffsets,d=l===!0?dr(o):typeof l=="function"?l(o):o,p=d.x,f=p===void 0?0:p,h=d.y,m=h===void 0?0:h,g=o.hasOwnProperty("x"),v=o.hasOwnProperty("y"),b=q,y=T,E=window;if(c){var u=de(r),k="clientHeight",w="clientWidth";u===_(r)&&(u=V(r),W(u).position!=="static"&&(k="scrollHeight",w="scrollWidth")),u=u,s===T&&(y=P,m-=u[k]-n.height,m*=i?1:-1),s===q&&(b=$,f-=u[w]-n.width,f*=i?1:-1)}var S=Object.assign({position:a},c&&lr);if(i){var A;return Object.assign({},S,(A={},A[y]=v?"0":"",A[b]=g?"0":"",A.transform=(E.devicePixelRatio||1)<2?"translate("+f+"px, "+m+"px)":"translate3d("+f+"px, "+m+"px, 0)",A))}return Object.assign({},S,(e={},e[y]=v?m+"px":"",e[b]=g?f+"px":"",e.transform="",e))}function ur(t){var e=t.state,r=t.options,n=r.gpuAcceleration,s=n===void 0?!0:n,o=r.adaptive,a=o===void 0?!0:o,i=r.roundOffsets,c=i===void 0?!0:i,l={placement:B(e.placement),popper:e.elements.popper,popperRect:e.rects.popper,gpuAcceleration:s};e.modifiersData.popperOffsets!=null&&(e.styles.popper=Object.assign({},e.styles.popper,Ze(Object.assign({},l,{offsets:e.modifiersData.popperOffsets,position:e.options.strategy,adaptive:a,roundOffsets:c})))),e.modifiersData.arrow!=null&&(e.styles.arrow=Object.assign({},e.styles.arrow,Ze(Object.assign({},l,{offsets:e.modifiersData.arrow,position:"absolute",adaptive:!1,roundOffsets:c})))),e.attributes.popper=Object.assign({},e.attributes.popper,{"data-popper-placement":e.placement})}const fr={name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:ur,data:{}};var ye={passive:!0};function pr(t){var e=t.state,r=t.instance,n=t.options,s=n.scroll,o=s===void 0?!0:s,a=n.resize,i=a===void 0?!0:a,c=_(e.elements.popper),l=[].concat(e.scrollParents.reference,e.scrollParents.popper);return o&&l.forEach(function(d){d.addEventListener("scroll",r.update,ye)}),i&&c.addEventListener("resize",r.update,ye),function(){o&&l.forEach(function(d){d.removeEventListener("scroll",r.update,ye)}),i&&c.removeEventListener("resize",r.update,ye)}}const hr={name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:pr,data:{}};var mr={left:"right",right:"left",bottom:"top",top:"bottom"};function xe(t){return t.replace(/left|right|bottom|top/g,function(e){return mr[e]})}var vr={start:"end",end:"start"};function et(t){return t.replace(/start|end/g,function(e){return vr[e]})}function Re(t){var e=_(t),r=e.pageXOffset,n=e.pageYOffset;return{scrollLeft:r,scrollTop:n}}function Ne(t){return ee(V(t)).left+Re(t).scrollLeft}function br(t){var e=_(t),r=V(t),n=e.visualViewport,s=r.clientWidth,o=r.clientHeight,a=0,i=0;return n&&(s=n.width,o=n.height,/^((?!chrome|android).)*safari/i.test(navigator.userAgent)||(a=n.offsetLeft,i=n.offsetTop)),{width:s,height:o,x:a+Ne(t),y:i}}function gr(t){var e,r=V(t),n=Re(t),s=(e=t.ownerDocument)==null?void 0:e.body,o=H(r.scrollWidth,r.clientWidth,s?s.scrollWidth:0,s?s.clientWidth:0),a=H(r.scrollHeight,r.clientHeight,s?s.scrollHeight:0,s?s.clientHeight:0),i=-n.scrollLeft+Ne(t),c=-n.scrollTop;return W(s||r).direction==="rtl"&&(i+=H(r.clientWidth,s?s.clientWidth:0)-o),{width:o,height:a,x:i,y:c}}function je(t){var e=W(t),r=e.overflow,n=e.overflowX,s=e.overflowY;return/auto|scroll|overlay|hidden/.test(r+s+n)}function Et(t){return["html","body","#document"].indexOf(R(t))>=0?t.ownerDocument.body:D(t)&&je(t)?t:Et(Se(t))}function se(t,e){var r;e===void 0&&(e=[]);var n=Et(t),s=n===((r=t.ownerDocument)==null?void 0:r.body),o=_(n),a=s?[o].concat(o.visualViewport||[],je(n)?n:[]):n,i=e.concat(a);return s?i:i.concat(se(Se(a)))}function Pe(t){return Object.assign({},t,{left:t.x,top:t.y,right:t.x+t.width,bottom:t.y+t.height})}function yr(t){var e=ee(t);return e.top=e.top+t.clientTop,e.left=e.left+t.clientLeft,e.bottom=e.top+t.clientHeight,e.right=e.left+t.clientWidth,e.width=t.clientWidth,e.height=t.clientHeight,e.x=e.left,e.y=e.top,e}function tt(t,e){return e===ht?Pe(br(t)):D(e)?yr(e):Pe(gr(V(t)))}function wr(t){var e=se(Se(t)),r=["absolute","fixed"].indexOf(W(t).position)>=0,n=r&&D(t)?de(t):t;return ie(n)?e.filter(function(s){return ie(s)&&bt(s,n)&&R(s)!=="body"}):[]}function Er(t,e,r){var n=e==="clippingParents"?wr(t):[].concat(e),s=[].concat(n,[r]),o=s[0],a=s.reduce(function(i,c){var l=tt(t,c);return i.top=H(l.top,i.top),i.right=oe(l.right,i.right),i.bottom=oe(l.bottom,i.bottom),i.left=H(l.left,i.left),i},tt(t,o));return a.width=a.right-a.left,a.height=a.bottom-a.top,a.x=a.left,a.y=a.top,a}function ae(t){return t.split("-")[1]}function At(t){var e=t.reference,r=t.element,n=t.placement,s=n?B(n):null,o=n?ae(n):null,a=e.x+e.width/2-r.width/2,i=e.y+e.height/2-r.height/2,c;switch(s){case T:c={x:a,y:e.y-r.height};break;case P:c={x:a,y:e.y+e.height};break;case $:c={x:e.x+e.width,y:i};break;case q:c={x:e.x-r.width,y:i};break;default:c={x:e.x,y:e.y}}var l=s?Be(s):null;if(l!=null){var d=l==="y"?"height":"width";switch(o){case Z:c[l]=c[l]-(e[d]/2-r[d]/2);break;case Ie:c[l]=c[l]+(e[d]/2-r[d]/2);break}}return c}function ce(t,e){e===void 0&&(e={});var r=e,n=r.placement,s=n===void 0?t.placement:n,o=r.boundary,a=o===void 0?Ft:o,i=r.rootBoundary,c=i===void 0?ht:i,l=r.elementContext,d=l===void 0?re:l,p=r.altBoundary,f=p===void 0?!1:p,h=r.padding,m=h===void 0?0:h,g=yt(typeof m!="number"?m:wt(m,le)),v=d===re?Ht:re,b=t.elements.reference,y=t.rects.popper,E=t.elements[f?v:d],u=Er(ie(E)?E:E.contextElement||V(t.elements.popper),a,c),k=ee(b),w=At({reference:k,element:y,placement:s}),S=Pe(Object.assign({},y,w)),A=d===re?S:k,C={top:u.top-A.top+g.top,bottom:A.bottom-u.bottom+g.bottom,left:u.left-A.left+g.left,right:A.right-u.right+g.right},O=t.modifiersData.offset;if(d===re&&O){var I=O[s];Object.keys(C).forEach(function(N){var L=[$,P].indexOf(N)>=0?1:-1,z=[T,P].indexOf(N)>=0?"y":"x";C[N]+=I[z]*L})}return C}function Ar(t,e){e===void 0&&(e={});var r=e,n=r.placement,s=r.boundary,o=r.rootBoundary,a=r.padding,i=r.flipVariations,c=r.allowedAutoPlacements,l=c===void 0?mt:c,d=ae(n),p=d?i?Ge:Ge.filter(function(m){return ae(m)===d}):le,f=p.filter(function(m){return l.indexOf(m)>=0});f.length===0&&(f=p);var h=f.reduce(function(m,g){return m[g]=ce(t,{placement:g,boundary:s,rootBoundary:o,padding:a})[B(g)],m},{});return Object.keys(h).sort(function(m,g){return h[m]-h[g]})}function xr(t){if(B(t)===_e)return[];var e=xe(t);return[et(t),e,et(e)]}function Sr(t){var e=t.state,r=t.options,n=t.name;if(!e.modifiersData[n]._skip){for(var s=r.mainAxis,o=s===void 0?!0:s,a=r.altAxis,i=a===void 0?!0:a,c=r.fallbackPlacements,l=r.padding,d=r.boundary,p=r.rootBoundary,f=r.altBoundary,h=r.flipVariations,m=h===void 0?!0:h,g=r.allowedAutoPlacements,v=e.options.placement,b=B(v),y=b===v,E=c||(y||!m?[xe(v)]:xr(v)),u=[v].concat(E).reduce(function(Y,M){return Y.concat(B(M)===_e?Ar(e,{placement:M,boundary:d,rootBoundary:p,padding:l,flipVariations:m,allowedAutoPlacements:g}):M)},[]),k=e.rects.reference,w=e.rects.popper,S=new Map,A=!0,C=u[0],O=0;O<u.length;O++){var I=u[O],N=B(I),L=ae(I)===Z,z=[T,P].indexOf(N)>=0,te=z?"width":"height",J=ce(e,{placement:I,boundary:d,rootBoundary:p,altBoundary:f,padding:l}),X=z?L?$:q:L?P:T;k[te]>w[te]&&(X=xe(X));var ke=xe(X),K=[];if(o&&K.push(J[N]<=0),i&&K.push(J[X]<=0,J[ke]<=0),K.every(function(Y){return Y})){C=I,A=!1;break}S.set(I,K)}if(A)for(var ue=m?3:1,Ce=function(M){var pe=u.find(function(Le){var G=S.get(Le);if(G)return G.slice(0,M).every(function(Oe){return Oe})});if(pe)return C=pe,"break"},U=ue;U>0;U--){var fe=Ce(U);if(fe==="break")break}e.placement!==C&&(e.modifiersData[n]._skip=!0,e.placement=C,e.reset=!0)}}const kr={name:"flip",enabled:!0,phase:"main",fn:Sr,requiresIfExists:["offset"],data:{_skip:!1}};function rt(t,e,r){return r===void 0&&(r={x:0,y:0}),{top:t.top-e.height-r.y,right:t.right-e.width+r.x,bottom:t.bottom-e.height+r.y,left:t.left-e.width-r.x}}function nt(t){return[T,$,P,q].some(function(e){return t[e]>=0})}function Cr(t){var e=t.state,r=t.name,n=e.rects.reference,s=e.rects.popper,o=e.modifiersData.preventOverflow,a=ce(e,{elementContext:"reference"}),i=ce(e,{altBoundary:!0}),c=rt(a,n),l=rt(i,s,o),d=nt(c),p=nt(l);e.modifiersData[r]={referenceClippingOffsets:c,popperEscapeOffsets:l,isReferenceHidden:d,hasPopperEscaped:p},e.attributes.popper=Object.assign({},e.attributes.popper,{"data-popper-reference-hidden":d,"data-popper-escaped":p})}const Lr={name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:Cr};function Or(t,e,r){var n=B(t),s=[q,T].indexOf(n)>=0?-1:1,o=typeof r=="function"?r(Object.assign({},e,{placement:t})):r,a=o[0],i=o[1];return a=a||0,i=(i||0)*s,[q,$].indexOf(n)>=0?{x:i,y:a}:{x:a,y:i}}function Tr(t){var e=t.state,r=t.options,n=t.name,s=r.offset,o=s===void 0?[0,0]:s,a=mt.reduce(function(d,p){return d[p]=Or(p,e.rects,o),d},{}),i=a[e.placement],c=i.x,l=i.y;e.modifiersData.popperOffsets!=null&&(e.modifiersData.popperOffsets.x+=c,e.modifiersData.popperOffsets.y+=l),e.modifiersData[n]=a}const qr={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:Tr};function Pr(t){var e=t.state,r=t.name;e.modifiersData[r]=At({reference:e.rects.reference,element:e.rects.popper,placement:e.placement})}const $r={name:"popperOffsets",enabled:!0,phase:"read",fn:Pr,data:{}};function Dr(t){return t==="x"?"y":"x"}function _r(t){var e=t.state,r=t.options,n=t.name,s=r.mainAxis,o=s===void 0?!0:s,a=r.altAxis,i=a===void 0?!1:a,c=r.boundary,l=r.rootBoundary,d=r.altBoundary,p=r.padding,f=r.tether,h=f===void 0?!0:f,m=r.tetherOffset,g=m===void 0?0:m,v=ce(e,{boundary:c,rootBoundary:l,padding:p,altBoundary:d}),b=B(e.placement),y=ae(e.placement),E=!y,u=Be(b),k=Dr(u),w=e.modifiersData.popperOffsets,S=e.rects.reference,A=e.rects.popper,C=typeof g=="function"?g(Object.assign({},e.rects,{placement:e.placement})):g,O={x:0,y:0};if(w){if(o||i){var I=u==="y"?T:q,N=u==="y"?P:$,L=u==="y"?"height":"width",z=w[u],te=w[u]+v[I],J=w[u]-v[N],X=h?-A[L]/2:0,ke=y===Z?S[L]:A[L],K=y===Z?-A[L]:-S[L],ue=e.elements.arrow,Ce=h&&ue?Me(ue):{width:0,height:0},U=e.modifiersData["arrow#persistent"]?e.modifiersData["arrow#persistent"].padding:gt(),fe=U[I],Y=U[N],M=Ae(0,S[L],Ce[L]),pe=E?S[L]/2-X-M-fe-C:ke-M-fe-C,Le=E?-S[L]/2+X+M+Y+C:K+M+Y+C,G=e.elements.arrow&&de(e.elements.arrow),Oe=G?u==="y"?G.clientTop||0:G.clientLeft||0:0,We=e.modifiersData.offset?e.modifiersData.offset[e.placement][u]:0,Fe=w[u]+pe-We-Oe,He=w[u]+Le-We;if(o){var Ve=Ae(h?oe(te,Fe):te,z,h?H(J,He):J);w[u]=Ve,O[u]=Ve-z}if(i){var St=u==="x"?T:q,kt=u==="x"?P:$,he=w[k],ze=he+v[St],Xe=he-v[kt],Ye=Ae(h?oe(ze,Fe):ze,he,h?H(Xe,He):Xe);w[k]=Ye,O[k]=Ye-he}}e.modifiersData[n]=O}}const Ir={name:"preventOverflow",enabled:!0,phase:"main",fn:_r,requiresIfExists:["offset"]};function Mr(t){return{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}}function Br(t){return t===_(t)||!D(t)?Re(t):Mr(t)}function Rr(t,e,r){r===void 0&&(r=!1);var n=V(e),s=ee(t),o=D(e),a={scrollLeft:0,scrollTop:0},i={x:0,y:0};return(o||!o&&!r)&&((R(e)!=="body"||je(n))&&(a=Br(e)),D(e)?(i=ee(e),i.x+=e.clientLeft,i.y+=e.clientTop):n&&(i.x=Ne(n))),{x:s.left+a.scrollLeft-i.x,y:s.top+a.scrollTop-i.y,width:s.width,height:s.height}}function Nr(t){var e=new Map,r=new Set,n=[];t.forEach(function(o){e.set(o.name,o)});function s(o){r.add(o.name);var a=[].concat(o.requires||[],o.requiresIfExists||[]);a.forEach(function(i){if(!r.has(i)){var c=e.get(i);c&&s(c)}}),n.push(o)}return t.forEach(function(o){r.has(o.name)||s(o)}),n}function jr(t){var e=Nr(t);return Zt.reduce(function(r,n){return r.concat(e.filter(function(s){return s.phase===n}))},[])}function Wr(t){var e;return function(){return e||(e=new Promise(function(r){Promise.resolve().then(function(){e=void 0,r(t())})})),e}}function Fr(t){var e=t.reduce(function(r,n){var s=r[n.name];return r[n.name]=s?Object.assign({},s,n,{options:Object.assign({},s.options,n.options),data:Object.assign({},s.data,n.data)}):n,r},{});return Object.keys(e).map(function(r){return e[r]})}var st={placement:"bottom",modifiers:[],strategy:"absolute"};function it(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return!e.some(function(n){return!(n&&typeof n.getBoundingClientRect=="function")})}function Hr(t){t===void 0&&(t={});var e=t,r=e.defaultModifiers,n=r===void 0?[]:r,s=e.defaultOptions,o=s===void 0?st:s;return function(i,c,l){l===void 0&&(l=o);var d={placement:"bottom",orderedModifiers:[],options:Object.assign({},st,o),modifiersData:{},elements:{reference:i,popper:c},attributes:{},styles:{}},p=[],f=!1,h={state:d,setOptions:function(b){g(),d.options=Object.assign({},o,d.options,b),d.scrollParents={reference:ie(i)?se(i):i.contextElement?se(i.contextElement):[],popper:se(c)};var y=jr(Fr([].concat(n,d.options.modifiers)));return d.orderedModifiers=y.filter(function(E){return E.enabled}),m(),h.update()},forceUpdate:function(){if(!f){var b=d.elements,y=b.reference,E=b.popper;if(it(y,E)){d.rects={reference:Rr(y,de(E),d.options.strategy==="fixed"),popper:Me(E)},d.reset=!1,d.placement=d.options.placement,d.orderedModifiers.forEach(function(O){return d.modifiersData[O.name]=Object.assign({},O.data)});for(var u=0;u<d.orderedModifiers.length;u++){if(d.reset===!0){d.reset=!1,u=-1;continue}var k=d.orderedModifiers[u],w=k.fn,S=k.options,A=S===void 0?{}:S,C=k.name;typeof w=="function"&&(d=w({state:d,options:A,name:C,instance:h})||d)}}}},update:Wr(function(){return new Promise(function(v){h.forceUpdate(),v(d)})}),destroy:function(){g(),f=!0}};if(!it(i,c))return h;h.setOptions(l).then(function(v){!f&&l.onFirstUpdate&&l.onFirstUpdate(v)});function m(){d.orderedModifiers.forEach(function(v){var b=v.name,y=v.options,E=y===void 0?{}:y,u=v.effect;if(typeof u=="function"){var k=u({state:d,name:b,instance:h,options:E}),w=function(){};p.push(k||w)}})}function g(){p.forEach(function(v){return v()}),p=[]}return h}}var Vr=[hr,$r,fr,rr,qr,kr,Ir,cr,Lr],zr=Hr({defaultModifiers:Vr});const Xr=parseInt(ut.baseline.$value,10),Yr="js-mds-popover-trigger",we="mds-popover--active",ne={init:()=>{Array.from(document.querySelectorAll(`.${Yr}`)).forEach(e=>{const n=`${e.getAttribute("id")}-content`,s=document.getElementById(n),o=s.dataset?s.dataset.placement:null,a=zr(e,s,{placement:o||"top-end",strategy:"fixed",modifiers:[{name:"offset",options:{offset:[0,Xr*3]}},{name:"arrow",options:{padding:5}}]});e.setAttribute("aria-expanded","false"),s.setAttribute("aria-hidden","true"),e.addEventListener("click",i=>{i.preventDefault(),a.update(),s.classList.toggle(we),ne.setAriaAttr(e,s,we)}),document.addEventListener("mousedown",i=>{ne.hide(e,s,a,we,i)}),document.addEventListener("keydown",i=>{ne.hide(e,s,a,we,i)})})},hide:(t,e,r,n,s)=>{!t.contains(s.target)&&!r.state.elements.popper.contains(s.target)&&e.classList.contains(n)&&(e.classList.remove(n),ne.setAriaAttr(t,e,n))},setAriaAttr:(t,e,r)=>{e.classList.contains(r)?(t.setAttribute("aria-expanded","true"),e.removeAttribute("aria-hidden")):(t.setAttribute("aria-expanded","false"),e.setAttribute("aria-hidden","true"))}},Jr=parseInt(ft.size.breakpoint.md.$value,10),ot="data-modal-id",at="mds-modal--active",Kr="js-mds-modal-close";let Ee;const Q={init:()=>{window.innerWidth>Jr&&Array.from(document.querySelectorAll(`[${ot}]`)).forEach(r=>{const n=r.getAttribute(ot),s=document.getElementById(n),o=Array.from(s.querySelectorAll(`.${Kr}`)),a=s.getAttribute("data-site-container"),i=document.getElementById(a);let l=s.querySelectorAll('a[href], area[href], input:not([disabled]):not([type="hidden"]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), iframe, object, embed, [tabindex="0"], [contenteditable]');l=Array.prototype.slice.call(l);const d=l[0],p=l[l.length-1];r.addEventListener("click",f=>{f.preventDefault(),Q.open(s,d,i)}),s.addEventListener("click",f=>{f.target===s&&Q.close(s,Ee,i)}),s.addEventListener("keydown",f=>{Q.trapFocus(f,d,p),(f.key==="Escape"||f.key==="Esc")&&Q.close(s,Ee,i)}),o.forEach(f=>{f.addEventListener("click",()=>{Q.close(s,Ee,i)})})})},open:(t,e,r)=>{Ee=document.activeElement,t.classList.add(at),e.focus(),r?.setAttribute("aria-hidden","true")},close:(t,e,r)=>{r?.removeAttribute("aria-hidden"),t.classList.remove(at),e.focus()},trapFocus:(t,e,r)=>{t.key==="Tab"&&(t.shiftKey?document.activeElement===e&&(t.preventDefault(),r.focus()):document.activeElement===r&&(t.preventDefault(),e.focus()))}};class j extends HTMLElement{static selectedFileClass="mds-file-upload--selected-file";static selectedFileIsImageClass="mds-file-upload--selected-file-is-image";static dragOverClass="mds-file-upload--dragover";constructor(){super()}connectedCallback(){this.classList.add("mds-form-element--file-supported"),this.#e.addEventListener("change",this.#l),this.#r.addEventListener("click",this.#p),this.#e.addEventListener("dragover",this.#s),this.#e.addEventListener("dragenter",this.#s),this.#e.addEventListener("dragleave",this.#d),this.#e.addEventListener("dragend",this.#d),this.#e.addEventListener("drop",this.#d),this.#i?.addEventListener("commit",this.#h),this.#i?.addEventListener("reset",this.#v),this.#b(!0)}disconnectedCallback(){this.#e?.removeEventListener("change",this.#l),this.#r?.removeEventListener("click",this.#p),this.#e?.removeEventListener("dragover",this.#s),this.#e?.removeEventListener("dragenter",this.#s),this.#e?.removeEventListener("dragleave",this.#d),this.#e?.removeEventListener("dragend",this.#d),this.#e?.removeEventListener("drop",this.#d),this.#i?.removeEventListener("commit",this.#h),this.#i?.removeEventListener("reset",this.#v)}get rootNode(){return this}get#a(){return this.getRootNode({composed:!0})}get#n(){return this.#e?.files?.[0]}get#c(){return this.#n?.type?.startsWith("image/")}get#o(){const e=this.rootNode.getAttribute("no-auto-open-image-cropper");return e!==null&&e!=="false"}get#t(){return this.rootNode.querySelector(".mds-file-upload__file-name")}get#e(){return this.rootNode.querySelector("input[type=file]")}get#r(){return this.rootNode.querySelector(".mds-file-upload__remove-button")}get#u(){return this.rootNode.querySelector(".mds-file-upload__preview-image")}get#m(){return this.rootNode.querySelector(".mds-file-upload__open-modal")}get#f(){return this.rootNode.querySelector(".mds-modal")}get#i(){return this.rootNode.querySelector("mds-image-cropper")}#l=e=>{const{dontOpenModal:r=!1}=e?.detail||{};this.#b(),this.#n&&this.#r.focus(),!r&&this.#c&&!this.#o&&this.#y()};#p=e=>{e.preventDefault(),this.removeFile(),this.#e.focus()};#s=e=>{e.stopPropagation(),this.classList.add(j.dragOverClass)};#d=e=>{e.stopPropagation(),this.classList.remove(j.dragOverClass)};#h=e=>{const r=e.detail;if(r){const n=new File([r],this.#n?.name||"cropped-image",{type:r.type}),s=new DataTransfer;s.items.add(n),this.#e.files=s.files,this.#e.dispatchEvent(new CustomEvent("change",{detail:{dontOpenModal:!0},bubbles:!0})),this.#g()}};#v=()=>{this.#g()};#b(e=!1){if(this.#n)if(this.#t.textContent=this.#n.name,this.classList.add(j.selectedFileClass),this.#c){this.classList.add(j.selectedFileIsImageClass);const r=new FileReader;r.onload=n=>{this.#u.src=n.target.result,this.#i?.setAttribute("src",n.target.result)},r.readAsDataURL(this.#n)}else this.classList.remove(j.selectedFileIsImageClass);else e||(this.#t.textContent="",this.classList.remove(j.selectedFileClass),this.classList.remove(j.selectedFileIsImageClass))}#y(){this.#m?.dispatchEvent(new Event("click"))}#g(){this.#f?.querySelector(".js-mds-modal-close").dispatchEvent(new Event("click"))}removeFile(){this.#e.value="",this.#e.dispatchEvent(new Event("change",{bubbles:!0}))}}const Ur=".mds-form-element--character-count",Gr=".mds-form-message--character-count",Qr=".js-character-count-number",Zr=".mds-form-control",$e={init:()=>{Array.from(document.querySelectorAll(Ur)).forEach(e=>{const r=e.querySelector(Zr),n=r.getAttribute("maxlength"),s=e.querySelector(Gr),o=e.querySelector(Qr);r.removeAttribute("maxlength"),$e.updateCounter(r,n,o,s),r.addEventListener("input",a=>{a.stopPropagation(),$e.updateCounter(r,n,o,s)})})},updateCounter:(t,e,r,n)=>{const s=t.value.match(/(\r\n|\n|\r)/g),o=t.value.length+(s?s.length:0),a=e-o;r.textContent=a,a<0?n.classList.add("mds-form-message--error"):n.classList.remove("mds-form-message--error")}},en="js-mds-button-double-submit",xt={init:()=>{Array.from(document.querySelectorAll(`.${en}`)).forEach(e=>{e.addEventListener("click",()=>{xt.toggleDisable(e)})})},toggleDisable:t=>{setTimeout(()=>{t.setAttribute("disabled","")},1),setTimeout(()=>{t.removeAttribute("disabled")},1e3)}},tn={setFluidVideos:()=>{Array.from(document.querySelectorAll(".mds-prose iframe, .mds-prose embed, .mds-prose object")).filter(e=>!e.closest("mds-consent-gate")).forEach(e=>{const r=document.createElement("div");r.classList.add("mds-fluid-video"),r.innerHTML=e.outerHTML,e.replaceWith(r)})}};class rn extends HTMLElement{connectedCallback(){const r=this.querySelector(".mds-card-link__link");let n;this.onmousedown=()=>{n=+new Date},this.onmouseup=()=>{+new Date-n<200&&r.click(),n=void 0}}disconnectedCallback(){this.onmousedown=this.onmouseup=null}}function nn(t){if(t==null)return null;const e=new Set(t.split(",").map(r=>r.trim()).filter(Boolean));return e.size===0?null:e}function sn(t){return t instanceof RadioNodeList?[...t]:t?.tagName?[t]:null}function on(t,e){const r=nn(e);if(!r)return!1;const n=sn(t);if(!n?.length)return!1;const s=n[0];return n.length===1&&s.type==="checkbox"?s.checked?r.has("true")||r.has(s.value||"on"):r.has("false"):n.every(a=>a.type==="checkbox"||a.type==="radio")?n.some(a=>a.checked&&r.has(a.value||"on")):n.length===1&&s.tagName==="SELECT"&&s.multiple?[...s.selectedOptions].some(a=>r.has(a.value)):r.has(s.value?.toString()??"")}class an extends HTMLElement{static observedAttributes=["form","field-name","show-when"];syncVisibility=()=>{this.hidden=!on(this.field,this.getAttribute("show-when"))};setup=()=>{this.cleanup();const e=this.getAttribute("form"),r=this.getAttribute("field-name");if(this.formElement=e?document.querySelector(e):this.closest("form"),!this.formElement)throw new Error(`<mds-conditional-section> for ${r} could not find the associated form`);if(this.field=this.formElement.elements[r],!this.field)throw new Error(`<mds-conditional-section> for ${r} could not find the associated field`);this.syncVisibility(),this.formElement.addEventListener("input",this.syncVisibility)};connectedCallback(){this.setup()}cleanup=()=>{this.formElement?.removeEventListener("input",this.syncVisibility)};disconnectedCallback(){this.cleanup()}attributeChangedCallback(e,r,n){this.isConnected&&r!==n&&(e==="show-when"?this.syncVisibility():(e==="field-name"||e==="form")&&this.setup())}}const F=".mds-form-check",Te=".mds-form-check__input",cn=".mds-form-check__label",ct=".mds-form-check__nested-container",lt=".mds-category-picker__pill",qe=".mds-category-picker__clear-pill",dt={optionsSelectedSingular:"1 option selected",optionsSelectedPlural:"{count} options selected",optionsFoundSingular:"1 option found",optionsFoundPlural:"{count} options found"};class ln extends HTMLElement{#a;#n;#c;#o;#t;#e;#r;#u;#m;#f;#i=new WeakMap;#l=!1;connectedCallback(){const e=this.querySelector(".mds-category-picker__templates");if(this.#n=this.querySelector(".mds-category-picker__pillbox"),this.#t=this.querySelector(".mds-category-picker__search"),this.#e=this.querySelector(".mds-category-picker__input-wrapper"),this.#r=this.querySelector(".mds-category-picker__dropdown"),this.#u=this.querySelector(".mds-category-picker__live-region"),this.#m=this.querySelector(".mds-category-picker__no-results"),!e||!this.#n||!this.#t||!this.#r)return;try{this.#f={...dt,...JSON.parse(this.getAttribute("i18n")||"{}")}}catch{this.#f=dt}if(this.#c=e.querySelector(lt),this.#o=e.querySelector(qe),!this.#c||!this.#o)return;e.remove(),this.#a=new AbortController;const r={signal:this.#a.signal};this.#n.addEventListener("click",this.#b,r),this.#r.addEventListener("change",this.#y,r),this.#t.addEventListener("blur",this.#d,r),this.#t.addEventListener("input",this.#g,r),this.#t.addEventListener("keydown",this.#k,r),this.#e.addEventListener("click",()=>this.#t.focus(),r),this.#t.addEventListener("focus",()=>this.#p(),r),this.#r.addEventListener("mousedown",n=>{n.target!==this.#t&&n.preventDefault()},r),this.#r.addEventListener("focusout",n=>{(!n.relatedTarget||!this.contains(n.relatedTarget))&&this.#s()},r),this.#r.addEventListener("keydown",n=>{n.key==="Escape"&&(this.#s(),this.#t.focus())},r),document.addEventListener("click",n=>{n.composedPath().includes(this)||this.#s()},r),this.#h()}disconnectedCallback(){this.#a?.abort()}#p(){this.#l||(this.#l=!0,this.classList.add("mds-category-picker--open"),this.#t.setAttribute("aria-expanded","true"))}#s(){this.#l&&(this.#l=!1,this.classList.remove("mds-category-picker--open"),this.#t.setAttribute("aria-expanded","false"),this.#t.value="",this.#w())}#d=e=>{const r=e.relatedTarget;r&&(this.#r.contains(r)||this.#e.contains(r))||this.#s()};#h=()=>{this.#n.replaceChildren(),this.#i=new WeakMap;const e="mds-form-check--has-selection";for(const r of this.#r.querySelectorAll(F))r.classList.remove(e);for(const r of this.#r.querySelectorAll(`${Te}:checked`)){this.#v(r);let n=r.closest(F)?.parentElement;for(;n&&n!==this.#r;)n.matches(F)&&n.classList.add(e),n=n.parentElement}};#v(e){const r=e.dataset.path;if(!r)return;const n=this.#c.cloneNode(!0),s=this.#o.cloneNode(!0);s.setAttribute("aria-label",`${s.getAttribute("aria-label")} ${r}`);const o=document.createElement("span");o.className="mds-category-picker__pill-text",o.textContent=r,n.appendChild(o),n.appendChild(s),this.#n.appendChild(n),this.#i.set(s,e)}#b=({target:e})=>{const r=this.#i.get(e.closest(qe));r&&(r.checked=!1,r.dispatchEvent(new Event("change",{bubbles:!0})))};#y=()=>{this.#h(),this.#t.value="",this.#w();const e=this.#r.querySelectorAll(`${Te}:checked`).length;this.#x(this.#A("optionsSelectedSingular","optionsSelectedPlural",e))};#g=()=>{const e=this.#t.value.trim();e.length>=2?this.#S(e):this.#w()};#S(e){const r=e.toLowerCase(),n=this.#r.querySelectorAll(F),s=new Set,o=new Set;for(const i of n){const c=i.querySelector(cn)?.textContent.trim().toLowerCase()||"";if(c){if(i.querySelector(ct)){c.includes(r)&&(s.add(i),o.add(i));continue}if(i.hidden=!c.includes(r),!i.hidden){let l=i.parentElement;for(;l&&l!==this.#r;)l.matches(F)&&s.add(l),l=l.parentElement}}}for(const i of n){const c=i.querySelector(ct);if(c)if(s.has(i)){if(i.hidden=!1,i.querySelector(".mds-checkbox-accordion__button")?.setAttribute("aria-expanded","true"),o.has(i))for(const l of c.querySelectorAll(F))l.hidden=!1}else i.hidden=!0}let a=0;for(const i of n)i.hidden||a++;this.#E(a===0),this.#x(this.#A("optionsFoundSingular","optionsFoundPlural",a))}#w(){for(const e of this.#r.querySelectorAll(F))e.hidden=!1;this.#E(!1)}#E(e){this.#m?.classList.toggle("mds-category-picker__no-results--visible",e)}#k=e=>{switch(e.key){case"Escape":this.#s(),this.#t.blur();break;case"ArrowDown":{e.preventDefault(),this.#l||this.#p();for(const r of this.#r.querySelectorAll(F)){if(r.hidden)continue;const n=r.querySelector(Te);if(n){n.focus();break}}break}case"Backspace":if(this.#t.value===""){const r=this.#n.querySelectorAll(lt),n=r[r.length-1];if(!n)break;const s=this.#i.get(n.querySelector(qe));s&&(s.checked=!1,s.dispatchEvent(new Event("change",{bubbles:!0})))}break;case"Tab":this.#s();break}};#A(e,r,n){return n===1?this.#f[e]:this.#f[r].replace("{count}",String(n))}#x(e){this.#u&&(this.#u.textContent="",requestAnimationFrame(()=>{this.#u.textContent=e}))}}class dn extends HTMLElement{#a;constructor(){super()}#n(e){const r=[0,.25,.5,.75,1];if(e==null||e.trim()==="")return r;const n=Number(e);if(!Number.isNaN(n))return n;const s=o=>Array.isArray(o)&&o.length>0&&o.every(a=>typeof a=="number"&&!Number.isNaN(a));try{const o=JSON.parse(e);if(s(o))return o}catch{}return console.warn(`${this.constructor.name}: Invalid observer-threshold "${e}". Falling back to default thresholds.`),r}#c(){const e=new Map,r=n=>{if(n.forEach(i=>{i.intersectionRatio===0?e.delete(i.target.id):e.set(i.target.id,i.intersectionRatio)}),e.size===0){this.#o.forEach(i=>i.removeAttribute("aria-current"));return}const s=e.entries().reduce((i,c)=>c[1]>i[1]?c:i),o=s[0],a=s[1];this.#o.forEach(i=>i.removeAttribute("aria-current")),o&&a>0&&this.querySelector(`[href="#${CSS.escape(o)}"]`)?.setAttribute("aria-current",this.#e)};this.#a=new IntersectionObserver(r,this.#r),this.#t.forEach(n=>this.#a.observe(n))}connectedCallback(){this.#t.length>0&&this.#c()}disconnectedCallback(){this.#a?.disconnect()}get#o(){return Array.from(this.querySelectorAll("a"))}get#t(){const e=[];return this.#o.forEach(r=>{if(new URL(r.href).host!==window.location.host||!r.hash)return;const n=document.querySelector(`#${CSS.escape(r.hash.substring(1))}`);if(!n){console.warn(`${this.constructor.name}: Element with id "${r.hash}" doesn't exist on this page.`);return}e.push(n)}),e}get#e(){return this.getAttribute("aria-current-value")||"step"}get#r(){const e=this.getAttribute("observer-root"),r=this.getAttribute("observer-threshold");return{root:document.querySelector(e),threshold:this.#n(r)}}}window.customElements.get("mds-dropdown-nav")||window.customElements.define("mds-dropdown-nav",Ct);window.customElements.get("mds-timeout-dialog")||window.customElements.define("mds-timeout-dialog",Lt);window.customElements.get("mds-card-link")||window.customElements.define("mds-card-link",rn);window.customElements.get("mds-conditional-section")||window.customElements.define("mds-conditional-section",an);window.customElements.get("mds-image-cropper")||window.customElements.define("mds-image-cropper",Ot);window.customElements.get("mds-file-upload")||window.customElements.define("mds-file-upload",j);window.customElements.get("mds-category-picker")||window.customElements.define("mds-category-picker",ln);window.customElements.get("mds-scroll-spy")||window.customElements.define("mds-scroll-spy",dn);window.customElements.get("mds-consent-gate")||window.customElements.define("mds-consent-gate",Tt);const De=()=>{x.init(),pt.init(),Rt.init(),Wt.init(),Q.init(),$e.init(),ne.init(),xt.init(),tn.setFluidVideos()};window.mdgxInitAll=De;document.readyState==="loading"?document.addEventListener("DOMContentLoaded",De):De();export{bn as setConsentAdapter};
|
package/package.json
CHANGED
|
@@ -8,7 +8,7 @@ Use the [callable](https://mozilla.github.io/nunjucks/templating.html#call) synt
|
|
|
8
8
|
|
|
9
9
|
- `form`: Targets the parent form by default, but a specific form can be provided using a query selector **optional**
|
|
10
10
|
- `fieldName`: The name of the field on the form to monitor **required**
|
|
11
|
-
- `showWhen`:
|
|
11
|
+
- `showWhen`: Value(s) that show the section **required**. Lone checkbox: `"true"` / `"false"`, or its `value` when checked (e.g. `showWhen="weekly"` with `value="weekly"`). Other fields: the value to match (e.g. `"Broccoli"`, `"cat"`). Checkbox groups and `select multiple`: comma-separated OR list (e.g. `"remote,hybrid"`, `"js,css"`).
|
|
12
12
|
|
|
13
13
|
The web component is also usable without the Nunjucks component, as shown below:
|
|
14
14
|
|
|
@@ -20,4 +20,4 @@ The web component is also usable without the Nunjucks component, as shown below:
|
|
|
20
20
|
>
|
|
21
21
|
<!-- section content -->
|
|
22
22
|
</mds-conditional-section>
|
|
23
|
-
```
|
|
23
|
+
```
|
|
@@ -10,6 +10,18 @@ module.exports = {
|
|
|
10
10
|
content: '<p><strong>Hello world!</strong></p>',
|
|
11
11
|
},
|
|
12
12
|
variants: [
|
|
13
|
+
{
|
|
14
|
+
name: 'Lone checkbox with value',
|
|
15
|
+
context: {
|
|
16
|
+
fractalLabel: 'Lone checkbox with custom value',
|
|
17
|
+
inputExample: `
|
|
18
|
+
<input type="checkbox" name="newsletter" id="newsletter" value="weekly" />
|
|
19
|
+
<label for="newsletter">Send me a weekly digest</label>`,
|
|
20
|
+
showWhen: 'weekly',
|
|
21
|
+
fieldName: 'newsletter',
|
|
22
|
+
content: '<p class="mds-padding-b2">Thanks — we\'ll send a digest every week.</p>',
|
|
23
|
+
},
|
|
24
|
+
},
|
|
13
25
|
{
|
|
14
26
|
name: 'Radio buttons',
|
|
15
27
|
context: {
|
|
@@ -35,6 +47,31 @@ module.exports = {
|
|
|
35
47
|
content: '<p class="mds-padding-b2"><strong>Well done!</strong></p>',
|
|
36
48
|
},
|
|
37
49
|
},
|
|
50
|
+
{
|
|
51
|
+
name: 'Checkbox group',
|
|
52
|
+
context: {
|
|
53
|
+
fractalLabel: 'Checkbox group',
|
|
54
|
+
inputExample: `
|
|
55
|
+
<fieldset>
|
|
56
|
+
<p><legend>Which work setups suit you?</legend></p>
|
|
57
|
+
<div>
|
|
58
|
+
<input type="checkbox" id="work-remote" name="work-setup" value="remote" />
|
|
59
|
+
<label for="work-remote">Remote</label>
|
|
60
|
+
</div>
|
|
61
|
+
<div>
|
|
62
|
+
<input type="checkbox" id="work-hybrid" name="work-setup" value="hybrid" />
|
|
63
|
+
<label for="work-hybrid">Hybrid</label>
|
|
64
|
+
</div>
|
|
65
|
+
<div>
|
|
66
|
+
<input type="checkbox" id="work-office" name="work-setup" value="office" />
|
|
67
|
+
<label for="work-office">Office only</label>
|
|
68
|
+
</div>
|
|
69
|
+
</fieldset>`,
|
|
70
|
+
showWhen: 'remote,hybrid',
|
|
71
|
+
fieldName: 'work-setup',
|
|
72
|
+
content: '<p class="mds-padding-b2">🏠</p>',
|
|
73
|
+
},
|
|
74
|
+
},
|
|
38
75
|
{
|
|
39
76
|
name: 'Select',
|
|
40
77
|
context: {
|
|
@@ -56,6 +93,23 @@ module.exports = {
|
|
|
56
93
|
content: '<p class="mds-padding-b2"><strong>Correct ✅</strong></p>',
|
|
57
94
|
},
|
|
58
95
|
},
|
|
96
|
+
{
|
|
97
|
+
name: 'Multiple select',
|
|
98
|
+
context: {
|
|
99
|
+
fractalLabel: 'Multiple select',
|
|
100
|
+
inputExample: `
|
|
101
|
+
<label for="skills-select">Pick your skills (Ctrl/Cmd+click for several):</label>
|
|
102
|
+
|
|
103
|
+
<select name="skills" id="skills-select" multiple size="3">
|
|
104
|
+
<option value="js">JavaScript</option>
|
|
105
|
+
<option value="css">CSS</option>
|
|
106
|
+
<option value="beekeeping">Beekeeping</option>
|
|
107
|
+
</select>`,
|
|
108
|
+
showWhen: 'js,css',
|
|
109
|
+
fieldName: 'skills',
|
|
110
|
+
content: '<p class="mds-padding-b2">JavaScript or CSS selected.</p>',
|
|
111
|
+
},
|
|
112
|
+
},
|
|
59
113
|
{
|
|
60
114
|
name: 'Number',
|
|
61
115
|
context: {
|
|
@@ -1,38 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `<mds-conditional-section>` — toggles `hidden` from `field-name` and `show-when`.
|
|
3
|
+
* {@link shouldShow} exposes the same matching rules for tests and non-CE use.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/** @param {string | null | undefined} showWhenAttr @returns {Set<string> | null} */
|
|
7
|
+
function parseShowWhen(showWhenAttr) {
|
|
8
|
+
if (showWhenAttr == null) return null;
|
|
9
|
+
const showWhenValues = new Set(
|
|
10
|
+
showWhenAttr
|
|
11
|
+
.split(',')
|
|
12
|
+
.map((s) => s.trim())
|
|
13
|
+
.filter(Boolean),
|
|
14
|
+
);
|
|
15
|
+
if (showWhenValues.size === 0) return null;
|
|
16
|
+
return showWhenValues;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** @param {Element | RadioNodeList} field @returns {Element[] | null} */
|
|
20
|
+
function resolveControls(field) {
|
|
21
|
+
if (field instanceof RadioNodeList) return [...field];
|
|
22
|
+
if (field?.tagName) return [field];
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Whether the conditional section should be visible for this field and `show-when` value.
|
|
28
|
+
*
|
|
29
|
+
* Lone checkbox: `"true"` / `"false"`, or its `value` when checked. Groups / `select[multiple]`: any active
|
|
30
|
+
* `value` against comma-separated `show-when` values. Other controls: single `.value`.
|
|
31
|
+
*
|
|
32
|
+
* @param {Element | RadioNodeList} field `HTMLFormElement.elements[fieldName]`.
|
|
33
|
+
* @param {string | null} showWhenAttr Raw `show-when` attribute, or `null` if absent.
|
|
34
|
+
* @returns {boolean}
|
|
35
|
+
*/
|
|
36
|
+
export function shouldShow(field, showWhenAttr) {
|
|
37
|
+
const showWhenValues = parseShowWhen(showWhenAttr);
|
|
38
|
+
if (!showWhenValues) return false;
|
|
39
|
+
|
|
40
|
+
const controls = resolveControls(field);
|
|
41
|
+
if (!controls?.length) return false;
|
|
42
|
+
|
|
43
|
+
const first = controls[0];
|
|
44
|
+
|
|
45
|
+
/* Single checkbox */
|
|
46
|
+
if (controls.length === 1 && first.type === 'checkbox') {
|
|
47
|
+
if (first.checked) {
|
|
48
|
+
return showWhenValues.has('true') || showWhenValues.has(first.value || 'on');
|
|
49
|
+
}
|
|
50
|
+
return showWhenValues.has('false');
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/* Checkbox / radio group */
|
|
54
|
+
const allCheckable = controls.every((el) => el.type === 'checkbox' || el.type === 'radio');
|
|
55
|
+
if (allCheckable) {
|
|
56
|
+
return controls.some((el) => el.checked && showWhenValues.has(el.value || 'on'));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/* Multiple select */
|
|
60
|
+
if (controls.length === 1 && first.tagName === 'SELECT' && first.multiple) {
|
|
61
|
+
return [...first.selectedOptions].some((opt) => showWhenValues.has(opt.value));
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/* Single-value control (select, text, number, etc.) */
|
|
65
|
+
return showWhenValues.has(first.value?.toString() ?? '');
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Shows or hides light DOM content when a watched form field matches `show-when`.
|
|
70
|
+
*
|
|
71
|
+
* Attributes: `field-name` (required), `show-when` (optional, comma-separated OR),
|
|
72
|
+
* `form` (optional selector; default nearest ancestor `form`). Updates on bubbling `input`.
|
|
73
|
+
*
|
|
74
|
+
* @extends HTMLElement
|
|
75
|
+
*/
|
|
1
76
|
export class MdsConditionalSection extends HTMLElement {
|
|
2
77
|
static observedAttributes = ['form', 'field-name', 'show-when'];
|
|
3
78
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const showWhen = this.getAttribute("show-when");
|
|
7
|
-
const fieldValue = field.type === 'checkbox'
|
|
8
|
-
? field.checked.toString()
|
|
9
|
-
: field.value.toString();
|
|
10
|
-
|
|
11
|
-
if (fieldValue === showWhen) {
|
|
12
|
-
this.hidden = false;
|
|
13
|
-
} else {
|
|
14
|
-
this.hidden = true;
|
|
15
|
-
}
|
|
79
|
+
syncVisibility = () => {
|
|
80
|
+
this.hidden = !shouldShow(this.field, this.getAttribute('show-when'));
|
|
16
81
|
};
|
|
17
82
|
|
|
18
83
|
setup = () => {
|
|
19
84
|
this.cleanup();
|
|
20
85
|
|
|
21
|
-
const form = this.getAttribute(
|
|
22
|
-
const fieldName = this.getAttribute(
|
|
86
|
+
const form = this.getAttribute('form');
|
|
87
|
+
const fieldName = this.getAttribute('field-name');
|
|
23
88
|
|
|
24
|
-
this.formElement = form
|
|
25
|
-
? document.querySelector(form)
|
|
26
|
-
: this.closest('form');
|
|
89
|
+
this.formElement = form ? document.querySelector(form) : this.closest('form');
|
|
27
90
|
|
|
28
|
-
if (!this.formElement)
|
|
91
|
+
if (!this.formElement) {
|
|
92
|
+
throw new Error(`<mds-conditional-section> for ${fieldName} could not find the associated form`);
|
|
93
|
+
}
|
|
29
94
|
|
|
30
95
|
this.field = this.formElement.elements[fieldName];
|
|
31
96
|
|
|
32
|
-
if (!this.field)
|
|
97
|
+
if (!this.field) {
|
|
98
|
+
throw new Error(`<mds-conditional-section> for ${fieldName} could not find the associated field`);
|
|
99
|
+
}
|
|
33
100
|
|
|
34
|
-
this.
|
|
35
|
-
this.formElement.addEventListener('input', this.
|
|
101
|
+
this.syncVisibility();
|
|
102
|
+
this.formElement.addEventListener('input', this.syncVisibility);
|
|
36
103
|
};
|
|
37
104
|
|
|
38
105
|
connectedCallback() {
|
|
@@ -40,7 +107,7 @@ export class MdsConditionalSection extends HTMLElement {
|
|
|
40
107
|
}
|
|
41
108
|
|
|
42
109
|
cleanup = () => {
|
|
43
|
-
this.formElement?.removeEventListener('input', this.
|
|
110
|
+
this.formElement?.removeEventListener('input', this.syncVisibility);
|
|
44
111
|
};
|
|
45
112
|
|
|
46
113
|
disconnectedCallback() {
|
|
@@ -48,15 +115,13 @@ export class MdsConditionalSection extends HTMLElement {
|
|
|
48
115
|
}
|
|
49
116
|
|
|
50
117
|
attributeChangedCallback(name, oldValue, newValue) {
|
|
51
|
-
const { showHide, setup } = this;
|
|
52
|
-
|
|
53
118
|
if (!this.isConnected) return;
|
|
54
119
|
if (oldValue === newValue) return;
|
|
55
120
|
|
|
56
121
|
if (name === 'show-when') {
|
|
57
|
-
|
|
122
|
+
this.syncVisibility();
|
|
58
123
|
} else if (name === 'field-name' || name === 'form') {
|
|
59
|
-
setup();
|
|
124
|
+
this.setup();
|
|
60
125
|
}
|
|
61
126
|
}
|
|
62
127
|
}
|
|
@@ -0,0 +1,402 @@
|
|
|
1
|
+
// eslint-disable-next-line n/no-unpublished-import
|
|
2
|
+
import { describe, it, expect, afterEach } from 'vitest';
|
|
3
|
+
import { MdsConditionalSection, shouldShow } from './conditional-section.js';
|
|
4
|
+
|
|
5
|
+
if (!customElements.get('mds-conditional-section')) {
|
|
6
|
+
customElements.define('mds-conditional-section', MdsConditionalSection);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function emitInput(target) {
|
|
10
|
+
target.dispatchEvent(new Event('input', { bubbles: true }));
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function mountScenario({ inputsHtml, fieldName, showWhen, includeShowWhen = true }) {
|
|
14
|
+
const container = document.createElement('div');
|
|
15
|
+
const showWhenAttr = includeShowWhen ? `show-when="${String(showWhen).replace(/"/g, '"')}"` : '';
|
|
16
|
+
container.innerHTML = `
|
|
17
|
+
<form id="test-conditional-form">
|
|
18
|
+
${inputsHtml}
|
|
19
|
+
<mds-conditional-section field-name="${fieldName}" ${showWhenAttr}>
|
|
20
|
+
<p data-testid="conditional-content">Conditional content</p>
|
|
21
|
+
</mds-conditional-section>
|
|
22
|
+
</form>
|
|
23
|
+
`;
|
|
24
|
+
document.body.appendChild(container);
|
|
25
|
+
const form = container.querySelector('form');
|
|
26
|
+
const section = container.querySelector('mds-conditional-section');
|
|
27
|
+
return { container, form, section };
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
describe('shouldShow', () => {
|
|
31
|
+
it('is true when any checked value matches a comma-separated trigger (OR)', () => {
|
|
32
|
+
const form = document.createElement('form');
|
|
33
|
+
form.innerHTML = `
|
|
34
|
+
<input type="checkbox" name="i" value="sports" checked />
|
|
35
|
+
<input type="checkbox" name="i" value="music" />
|
|
36
|
+
`;
|
|
37
|
+
expect(shouldShow(form.elements.i, 'sports,music')).toBe(true);
|
|
38
|
+
|
|
39
|
+
form.querySelector('[value="sports"]').checked = false;
|
|
40
|
+
form.querySelector('[value="music"]').checked = true;
|
|
41
|
+
expect(shouldShow(form.elements.i, 'sports,music')).toBe(true);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('is false when no checked value matches triggers', () => {
|
|
45
|
+
const form = document.createElement('form');
|
|
46
|
+
form.innerHTML = `
|
|
47
|
+
<input type="checkbox" name="i" value="sports" />
|
|
48
|
+
<input type="checkbox" name="i" value="music" />
|
|
49
|
+
<input type="checkbox" name="i" value="travel" checked />
|
|
50
|
+
`;
|
|
51
|
+
expect(shouldShow(form.elements.i, 'sports,music')).toBe(false);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it('is false when a checkbox group has nothing checked', () => {
|
|
55
|
+
const form = document.createElement('form');
|
|
56
|
+
form.innerHTML = `
|
|
57
|
+
<input type="checkbox" name="i" value="sports" />
|
|
58
|
+
<input type="checkbox" name="i" value="music" />
|
|
59
|
+
`;
|
|
60
|
+
expect(shouldShow(form.elements.i, 'sports')).toBe(false);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it('trims trigger segments and ignores empty parts', () => {
|
|
64
|
+
const form = document.createElement('form');
|
|
65
|
+
form.innerHTML = `
|
|
66
|
+
<input type="checkbox" name="i" value="a" checked />
|
|
67
|
+
<input type="checkbox" name="i" value="b" />
|
|
68
|
+
`;
|
|
69
|
+
expect(shouldShow(form.elements.i, ' a , b ')).toBe(true);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it('is false when show-when is null or empty', () => {
|
|
73
|
+
const form = document.createElement('form');
|
|
74
|
+
form.innerHTML = `<input type="checkbox" name="i" value="x" checked />`;
|
|
75
|
+
expect(shouldShow(form.elements.i, null)).toBe(false);
|
|
76
|
+
expect(shouldShow(form.elements.i, '')).toBe(false);
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it('for a lone checkbox uses true/false against triggers', () => {
|
|
80
|
+
const form = document.createElement('form');
|
|
81
|
+
form.innerHTML = '<input type="checkbox" name="c" />';
|
|
82
|
+
const field = form.elements.c;
|
|
83
|
+
expect(shouldShow(field, 'false')).toBe(true);
|
|
84
|
+
expect(shouldShow(field, 'true')).toBe(false);
|
|
85
|
+
field.checked = true;
|
|
86
|
+
expect(shouldShow(field, 'true')).toBe(true);
|
|
87
|
+
expect(shouldShow(field, 'false')).toBe(false);
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it('for a lone checkbox with a custom value matches show-when against that value when checked', () => {
|
|
91
|
+
const form = document.createElement('form');
|
|
92
|
+
form.innerHTML = '<input type="checkbox" name="c" value="yes" />';
|
|
93
|
+
const field = form.elements.c;
|
|
94
|
+
expect(shouldShow(field, 'yes')).toBe(false);
|
|
95
|
+
field.checked = true;
|
|
96
|
+
expect(shouldShow(field, 'yes')).toBe(true);
|
|
97
|
+
expect(shouldShow(field, 'no')).toBe(false);
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
it('for a lone checkbox with a custom value still supports show-when true/false', () => {
|
|
101
|
+
const form = document.createElement('form');
|
|
102
|
+
form.innerHTML = '<input type="checkbox" name="c" value="yes" />';
|
|
103
|
+
const field = form.elements.c;
|
|
104
|
+
field.checked = true;
|
|
105
|
+
expect(shouldShow(field, 'true')).toBe(true);
|
|
106
|
+
expect(shouldShow(field, 'false')).toBe(false);
|
|
107
|
+
field.checked = false;
|
|
108
|
+
expect(shouldShow(field, 'false')).toBe(true);
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
it('for a checkbox group matches checked values', () => {
|
|
112
|
+
const form = document.createElement('form');
|
|
113
|
+
form.innerHTML = `
|
|
114
|
+
<input type="checkbox" name="i" value="sports" />
|
|
115
|
+
<input type="checkbox" name="i" value="music" checked />
|
|
116
|
+
<input type="checkbox" name="i" value="travel" />
|
|
117
|
+
`;
|
|
118
|
+
expect(shouldShow(form.elements.i, 'music')).toBe(true);
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
it('uses "on" when a checked checkbox has no value attribute', () => {
|
|
122
|
+
const form = document.createElement('form');
|
|
123
|
+
form.innerHTML = `
|
|
124
|
+
<input type="checkbox" name="i" checked />
|
|
125
|
+
<input type="checkbox" name="i" />
|
|
126
|
+
`;
|
|
127
|
+
expect(shouldShow(form.elements.i, 'on')).toBe(true);
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
it('for a radio group matches the selected value', () => {
|
|
131
|
+
const form = document.createElement('form');
|
|
132
|
+
form.innerHTML = `
|
|
133
|
+
<input type="radio" name="r" value="a" />
|
|
134
|
+
<input type="radio" name="r" value="b" checked />
|
|
135
|
+
`;
|
|
136
|
+
expect(shouldShow(form.elements.r, 'b')).toBe(true);
|
|
137
|
+
expect(shouldShow(form.elements.r, 'a')).toBe(false);
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
it('reads multiple same-name controls from a RadioNodeList', () => {
|
|
141
|
+
const form = document.createElement('form');
|
|
142
|
+
form.innerHTML = `
|
|
143
|
+
<input type="checkbox" name="i" value="a" />
|
|
144
|
+
<input type="checkbox" name="i" value="b" />
|
|
145
|
+
`;
|
|
146
|
+
const list = form.elements.i;
|
|
147
|
+
expect(list).toBeInstanceOf(RadioNodeList);
|
|
148
|
+
expect(list.length).toBe(2);
|
|
149
|
+
list[1].checked = true;
|
|
150
|
+
expect(shouldShow(list, 'b')).toBe(true);
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
it('for a multiple select matches any selected option against comma-separated triggers', () => {
|
|
154
|
+
const form = document.createElement('form');
|
|
155
|
+
form.innerHTML = `
|
|
156
|
+
<select name="skills" id="skills" multiple>
|
|
157
|
+
<option value="js">JavaScript</option>
|
|
158
|
+
<option value="css">CSS</option>
|
|
159
|
+
<option value="html">HTML</option>
|
|
160
|
+
</select>
|
|
161
|
+
`;
|
|
162
|
+
const select = form.elements.skills;
|
|
163
|
+
expect(shouldShow(select, 'js,css')).toBe(false);
|
|
164
|
+
|
|
165
|
+
select.options[1].selected = true;
|
|
166
|
+
expect(shouldShow(select, 'js,css')).toBe(true);
|
|
167
|
+
|
|
168
|
+
select.options[1].selected = false;
|
|
169
|
+
select.options[2].selected = true;
|
|
170
|
+
expect(shouldShow(select, 'js,css')).toBe(false);
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
it('for a multiple select matches when a non-first selected option matches show-when alone', () => {
|
|
174
|
+
const form = document.createElement('form');
|
|
175
|
+
form.innerHTML = `
|
|
176
|
+
<select name="skills" id="skills" multiple>
|
|
177
|
+
<option value="js">JavaScript</option>
|
|
178
|
+
<option value="css">CSS</option>
|
|
179
|
+
</select>
|
|
180
|
+
`;
|
|
181
|
+
const select = form.elements.skills;
|
|
182
|
+
select.options[0].selected = true;
|
|
183
|
+
select.options[1].selected = true;
|
|
184
|
+
expect(shouldShow(select, 'css')).toBe(true);
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
it('for a multiple select stays visible while any matching option remains selected', () => {
|
|
188
|
+
const form = document.createElement('form');
|
|
189
|
+
form.innerHTML = `
|
|
190
|
+
<select name="skills" id="skills" multiple>
|
|
191
|
+
<option value="js">JavaScript</option>
|
|
192
|
+
<option value="css">CSS</option>
|
|
193
|
+
</select>
|
|
194
|
+
`;
|
|
195
|
+
const select = form.elements.skills;
|
|
196
|
+
select.options[0].selected = true;
|
|
197
|
+
select.options[1].selected = true;
|
|
198
|
+
expect(shouldShow(select, 'js,css')).toBe(true);
|
|
199
|
+
|
|
200
|
+
select.options[0].selected = false;
|
|
201
|
+
expect(shouldShow(select, 'js,css')).toBe(true);
|
|
202
|
+
|
|
203
|
+
select.options[1].selected = false;
|
|
204
|
+
expect(shouldShow(select, 'js,css')).toBe(false);
|
|
205
|
+
});
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
describe('MdsConditionalSection', () => {
|
|
209
|
+
let container;
|
|
210
|
+
|
|
211
|
+
afterEach(() => {
|
|
212
|
+
container?.remove();
|
|
213
|
+
container = undefined;
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
describe('checkbox group', () => {
|
|
217
|
+
it('shows when a non-first checkbox matching show-when is checked', () => {
|
|
218
|
+
({ container } = mountScenario({
|
|
219
|
+
fieldName: 'interests',
|
|
220
|
+
showWhen: 'music',
|
|
221
|
+
inputsHtml: `
|
|
222
|
+
<input type="checkbox" name="interests" value="sports" id="cb-sports" />
|
|
223
|
+
<input type="checkbox" name="interests" value="music" id="cb-music" />
|
|
224
|
+
<input type="checkbox" name="interests" value="travel" id="cb-travel" />
|
|
225
|
+
`,
|
|
226
|
+
}));
|
|
227
|
+
const section = container.querySelector('mds-conditional-section');
|
|
228
|
+
expect(section.hidden).toBe(true);
|
|
229
|
+
|
|
230
|
+
const music = container.querySelector('#cb-music');
|
|
231
|
+
music.checked = true;
|
|
232
|
+
emitInput(music);
|
|
233
|
+
|
|
234
|
+
expect(section.hidden).toBe(false);
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
it('matches any comma-separated trigger (OR)', () => {
|
|
238
|
+
({ container } = mountScenario({
|
|
239
|
+
fieldName: 'interests',
|
|
240
|
+
showWhen: 'sports,music',
|
|
241
|
+
inputsHtml: `
|
|
242
|
+
<input type="checkbox" name="interests" value="sports" id="cb-sports" />
|
|
243
|
+
<input type="checkbox" name="interests" value="music" id="cb-music" />
|
|
244
|
+
<input type="checkbox" name="interests" value="travel" id="cb-travel" />
|
|
245
|
+
`,
|
|
246
|
+
}));
|
|
247
|
+
const section = container.querySelector('mds-conditional-section');
|
|
248
|
+
const travel = container.querySelector('#cb-travel');
|
|
249
|
+
travel.checked = true;
|
|
250
|
+
emitInput(travel);
|
|
251
|
+
expect(section.hidden).toBe(true);
|
|
252
|
+
|
|
253
|
+
const music = container.querySelector('#cb-music');
|
|
254
|
+
music.checked = true;
|
|
255
|
+
emitInput(music);
|
|
256
|
+
expect(section.hidden).toBe(false);
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
it('stays visible if one matching trigger is unchecked but another remains checked', () => {
|
|
260
|
+
({ container } = mountScenario({
|
|
261
|
+
fieldName: 'interests',
|
|
262
|
+
showWhen: 'sports,music',
|
|
263
|
+
inputsHtml: `
|
|
264
|
+
<input type="checkbox" name="interests" value="sports" id="cb-sports" />
|
|
265
|
+
<input type="checkbox" name="interests" value="music" id="cb-music" />
|
|
266
|
+
`,
|
|
267
|
+
}));
|
|
268
|
+
const section = container.querySelector('mds-conditional-section');
|
|
269
|
+
const sports = container.querySelector('#cb-sports');
|
|
270
|
+
const music = container.querySelector('#cb-music');
|
|
271
|
+
sports.checked = true;
|
|
272
|
+
music.checked = true;
|
|
273
|
+
emitInput(sports);
|
|
274
|
+
|
|
275
|
+
expect(section.hidden).toBe(false);
|
|
276
|
+
|
|
277
|
+
sports.checked = false;
|
|
278
|
+
emitInput(sports);
|
|
279
|
+
expect(section.hidden).toBe(false);
|
|
280
|
+
|
|
281
|
+
music.checked = false;
|
|
282
|
+
emitInput(music);
|
|
283
|
+
expect(section.hidden).toBe(true);
|
|
284
|
+
});
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
describe('regressions', () => {
|
|
288
|
+
it('single checkbox with show-when true toggles visibility', () => {
|
|
289
|
+
({ container } = mountScenario({
|
|
290
|
+
fieldName: 'agree',
|
|
291
|
+
showWhen: 'true',
|
|
292
|
+
inputsHtml: '<input type="checkbox" name="agree" id="agree" />',
|
|
293
|
+
}));
|
|
294
|
+
const section = container.querySelector('mds-conditional-section');
|
|
295
|
+
const cb = container.querySelector('#agree');
|
|
296
|
+
expect(section.hidden).toBe(true);
|
|
297
|
+
cb.checked = true;
|
|
298
|
+
emitInput(cb);
|
|
299
|
+
expect(section.hidden).toBe(false);
|
|
300
|
+
});
|
|
301
|
+
|
|
302
|
+
it('hide-salary pattern: show-when false when checkbox unchecked', () => {
|
|
303
|
+
({ container } = mountScenario({
|
|
304
|
+
fieldName: 'HideSalary',
|
|
305
|
+
showWhen: 'false',
|
|
306
|
+
inputsHtml: '<input type="checkbox" name="HideSalary" id="HideSalary" />',
|
|
307
|
+
}));
|
|
308
|
+
const section = container.querySelector('mds-conditional-section');
|
|
309
|
+
expect(section.hidden).toBe(false);
|
|
310
|
+
const cb = container.querySelector('#HideSalary');
|
|
311
|
+
cb.checked = true;
|
|
312
|
+
emitInput(cb);
|
|
313
|
+
expect(section.hidden).toBe(true);
|
|
314
|
+
});
|
|
315
|
+
|
|
316
|
+
it('single checkbox with custom value and show-when toggles visibility', () => {
|
|
317
|
+
({ container } = mountScenario({
|
|
318
|
+
fieldName: 'newsletter',
|
|
319
|
+
showWhen: 'weekly',
|
|
320
|
+
inputsHtml: '<input type="checkbox" name="newsletter" id="newsletter" value="weekly" />',
|
|
321
|
+
}));
|
|
322
|
+
const section = container.querySelector('mds-conditional-section');
|
|
323
|
+
const cb = container.querySelector('#newsletter');
|
|
324
|
+
expect(section.hidden).toBe(true);
|
|
325
|
+
cb.checked = true;
|
|
326
|
+
emitInput(cb);
|
|
327
|
+
expect(section.hidden).toBe(false);
|
|
328
|
+
});
|
|
329
|
+
|
|
330
|
+
it('radio group show-when matches selected value', () => {
|
|
331
|
+
({ container } = mountScenario({
|
|
332
|
+
fieldName: 'option',
|
|
333
|
+
showWhen: 'Broccoli',
|
|
334
|
+
inputsHtml: `
|
|
335
|
+
<input type="radio" name="option" value="Donkey" id="r1" />
|
|
336
|
+
<input type="radio" name="option" value="Broccoli" id="r2" />
|
|
337
|
+
`,
|
|
338
|
+
}));
|
|
339
|
+
const section = container.querySelector('mds-conditional-section');
|
|
340
|
+
expect(section.hidden).toBe(true);
|
|
341
|
+
container.querySelector('#r2').checked = true;
|
|
342
|
+
emitInput(container.querySelector('#r2'));
|
|
343
|
+
expect(section.hidden).toBe(false);
|
|
344
|
+
});
|
|
345
|
+
|
|
346
|
+
it('select show-when matches option value', () => {
|
|
347
|
+
({ container } = mountScenario({
|
|
348
|
+
fieldName: 'pets',
|
|
349
|
+
showWhen: 'cat',
|
|
350
|
+
inputsHtml: `
|
|
351
|
+
<select name="pets" id="pets">
|
|
352
|
+
<option value="">Choose</option>
|
|
353
|
+
<option value="dog">Dog</option>
|
|
354
|
+
<option value="cat">Cat</option>
|
|
355
|
+
</select>
|
|
356
|
+
`,
|
|
357
|
+
}));
|
|
358
|
+
const section = container.querySelector('mds-conditional-section');
|
|
359
|
+
const sel = container.querySelector('#pets');
|
|
360
|
+
sel.value = 'cat';
|
|
361
|
+
emitInput(sel);
|
|
362
|
+
expect(section.hidden).toBe(false);
|
|
363
|
+
});
|
|
364
|
+
|
|
365
|
+
it('multiple select show-when matches any selected option (OR)', () => {
|
|
366
|
+
({ container } = mountScenario({
|
|
367
|
+
fieldName: 'skills',
|
|
368
|
+
showWhen: 'js,css',
|
|
369
|
+
inputsHtml: `
|
|
370
|
+
<label for="skills">Pick your skills (hold Ctrl/Cmd to select several):</label>
|
|
371
|
+
<select name="skills" id="skills" multiple size="3">
|
|
372
|
+
<option value="js">JavaScript</option>
|
|
373
|
+
<option value="css">CSS</option>
|
|
374
|
+
<option value="html">HTML</option>
|
|
375
|
+
</select>
|
|
376
|
+
`,
|
|
377
|
+
}));
|
|
378
|
+
const section = container.querySelector('mds-conditional-section');
|
|
379
|
+
const sel = container.querySelector('#skills');
|
|
380
|
+
expect(section.hidden).toBe(true);
|
|
381
|
+
|
|
382
|
+
sel.options[1].selected = true;
|
|
383
|
+
emitInput(sel);
|
|
384
|
+
expect(section.hidden).toBe(false);
|
|
385
|
+
});
|
|
386
|
+
});
|
|
387
|
+
|
|
388
|
+
describe('missing show-when', () => {
|
|
389
|
+
it('keeps section hidden when show-when attribute is omitted', () => {
|
|
390
|
+
({ container } = mountScenario({
|
|
391
|
+
fieldName: 'interests',
|
|
392
|
+
showWhen: '',
|
|
393
|
+
includeShowWhen: false,
|
|
394
|
+
inputsHtml: `
|
|
395
|
+
<input type="checkbox" name="interests" value="sports" checked />
|
|
396
|
+
`,
|
|
397
|
+
}));
|
|
398
|
+
const section = container.querySelector('mds-conditional-section');
|
|
399
|
+
expect(section.hidden).toBe(true);
|
|
400
|
+
});
|
|
401
|
+
});
|
|
402
|
+
});
|