1var m=Object.defineProperty;var g=(h,t,e)=>t in h?m(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e;var s=(h,t,e)=>g(h,typeof t!="symbol"?t+"":t,e);import{d as n}from"./dayjs.min-CdIAE-_V.js";import"./feed-BZ6OquvI.js";import"./index--6mjBm2l.js";class k{constructor(t="[data-datepicker]"){s(this,"allPickers");s(this,"pickerInput");s(this,"prevButton");s(this,"nextButton");s(this,"monthSelect");s(this,"yearSelect");s(this,"calendarSection");s(this,"calendarHelp");s(this,"calendarUpdates");s(this,"currentDate");s(this,"minDate");s(this,"maxDate");s(this,"holidays");s(this,"dialog");s(this,"close");s(this,"selected");s(this,"pickerToggle");s(this,"isOpen");s(this,"idBase","a11y-picker");s(this,"classBase","a11y-picker");s(this,"calItem",this.classBase+"-item");s(this,"selector");s(this,"togglePicker",t=>{this.isOpen?this.pickerToggle!=t.currentTarget?(this.closeCalendar(),this.pickerToggle=t.currentTarget,this.openCalendar()):this.closeCalendar():(this.pickerToggle=t.currentTarget,this.openCalendar())});s(this,"closeCalendar",()=>{const t=document.querySelector("#"+this.idBase);t!==null&&t.remove(),this.isOpen&&(this.pickerToggle.focus(),this.monthSelect.removeEventListener("change",this.updateUI),this.yearSelect.removeEventListener("change",this.updateUI),this.prevButton.removeEventListener("click",this.previousMonth),this.nextButton.removeEventListener("click",this.nextMonth),this.calendarSection.removeEventListener("click",this.onActivation),this.calendarSection.removeEventListener("keydown",this.onKeydown),this.calendarHelp.removeEventListener("click",this.showDialog)),this.isOpen=!1});s(this,"openCalendar",()=>{this.pickerToggle.focus(),this.pickerInput=this.pickerToggle.previousElementSibling;const t=this.pickerInput.parentElement;t&&(this.pickerToggle.insertAdjacentHTML("afterend",this.getCalendarTemplate()),this.prevButton=t.querySelector("[data-ui-previous]"),this.nextButton=t.querySelector("[data-ui-next]"),this.monthSelect=t.querySelector("[data-ui-month]"),this.yearSelect=t.querySelector("[data-ui-year]"),this.calendarSection=t.querySelector("[data-ui-dates]"),this.calendarHelp=t.querySelector("[data-ui-help-trigger]"),this.calendarUpdates=t.querySelector("[data-ui-updates]"),this.dialog=t.querySelector("[data-ui-help-dialog]"),this.close=t.querySelector("[data-ui-help-close]"),this.currentDate=n().startOf("day"),this.minDate=this.currentDate,this.maxDate=n().startOf("day").add(1,"year").add(1,"month"),this.holidays={},this.monthSelect.selectedIndex=this.currentDate.get("M"),this.monthSelect.addEventListener("change",this.updateUI),this.yearSelect.addEventListener("change",this.updateUI),this.prevButton.addEventListener("click",this.previousMonth),this.nextButton.addEventListener("click",this.nextMonth),this.calendarSection.addEventListener("click",this.onActivation),this.calendarSection.addEventListener("keydown",this.onKeydown),this.calendarHelp.addEventListener("click",this.showDialog),this.isOpen=!0,this.updateUI())});s(this,"announce",t=>{this.setText(this.calendarUpdates,t),setTimeout(()=>{this.setText(this.calendarUpdates,"")},1e3)});s(this,"selectDate",t=>{const e=this.calendarSection.querySelector('[aria-pressed="true"]');e&&(e.setAttribute("aria-pressed","false"),e.setAttribute("tabindex","-1")),t.setAttribute("aria-pressed","true"),t.removeAttribute("tabindex"),this.selected=n.unix(parseInt(t.getAttribute("data-timestamp"),10));const a=this.pickerInput.getAttribute("data-disp-format")||"MM-DD-YYYY",i=this.pickerInput.getAttribute("data-submit-format")||"YYYY-MM-DD";this.pickerInput.value=n(this.selected).format(a),this.pickerInput.setAttribute("data-submit-value",n(this.selected).format(i));const l=this.pickerInput.getAttribute("data-mirrors-to");if(this.pickerInput.hasAttribute("data-mirrors-to")&&l){const o=document.getElementById(l);o&&(o.value=n(this.selected).format(i))}this.announce(`selected ${t.getAttribute("aria-label")}`),this.closeCalendar()});s(this,"setMirrorDateInput",t=>{const e=t.value;if(e&&n(e)){const a=t,i=a.getAttribute("data-disp-format")||"MM-DD-YYYY",l=a.getAttribute("data-submit-format")||"YYYY-MM-DD",o=a.getAttribute("data-mirrors-to"),r=o?document.getElementById(o):null;this.selected=e,a.value=n(this.selected).format(i),a.setAttribute("data-submit-value",n(this.selected).format(l)),r&&(r.value=n(this.selected).format(l))}});s(this,"showDialog",()=>{this.dialog.setAttribute("aria-hidden","false"),this.dialog.firstElementChild.focus(),this.dialog.addEventListener("keydown",this.onDialogKeydown),this.dialog.addEventListener("click",this.onDialogUx),document.documentElement.setAttribute("tabindex","-1"),document.addEventListener("focus",this.onDialogUx,!0)});s(this,"closeDialog",()=>{this.dialog.removeEventListener("keydown",this.onDialogKeydown),this.dialog.removeEventListener("click",this.onDialogUx),document.removeEventListener("focus",this.onDialogUx,!0),document.documentElement.removeAttribute("tabindex"),this.dialog.setAttribute("aria-hidden","true"),this.calendarHelp.focus()});s(this,"onDialogKeydown",t=>{const e=t.target;if(t.key==="Escape"){this.closeDialog();return}t.key==="Tab"&&(t.shiftKey&&e===this.dialog?(t.preventDefault(),this.close.focus()):e===this.close&&(t.preventDefault(),this.dialog.focus()))});s(this,"getButtonTemplate",t=>`<button type="button" 2 class="${this.classBase}__toggle" 3 id="${this.idBase}-toggle-${t}" 4 aria-controls="${this.idBase}" 5 aria-label="Toggle Date Picker"> 6 <svg height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M17 12h-5v5h5v-5zM16 1v2H8V1H6v2H5c-1.11 0-1.99.9-1.99 2L3 19c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2h-1V1h-2zm3 18H5V8h14v11z" fill="currentColor" /></svg> 7 </button>`);s(this,"getCalendarTemplate",()=>`<section class="${this.classBase}" id="${this.idBase}" aria-label="Calendar"> 8 <section aria-label="Calendar Navigation" class="${this.classBase}-nav u-flex"> 9 10 <button data-ui-previous 11 class="${this.classBase}-nav--button" 12 type="button" 13 aria-label="Previous month, ${n().subtract(1,"month").format("MMMM YYYY")}">❮
13</button> 14 15 <div class="${this.classBase}-nav--selects"> 16 17 <div class="${this.classBase}-nav--select"> 18 <select data-ui-month aria-label="month"> 19 <option>January</option> 20 <option>February</option> 21 <option>March</option> 22 <option>April</option> 23 <option>May</option> 24 <option>June</option> 25 <option>July</option> 26 <option>August</option> 27 <option>September</option> 28 <option>October</option> 29 <option>November</option> 30 <option>December</option> 31 </select> 32 </div> 33 <div class="${this.classBase}-nav--select"> 34 <select data-ui-year aria-label="year"> 35 <option selected>${n().format("YYYY")}</option> 36 <option>${n().add(1,"year").format("YYYY")}</option> 37 </select> 38 </div> 39 40 </div> 41 42 <button data-ui-next 43 class="${this.classBase}-nav--button" 44 type="button" 45 aria-label="Next month, ${n().add(1,"month").format("MMMM YYYY")}">❯</button> 46 47 </section> 48 49 <div class="${this.classBase}-grid"> 50 <div class="${this.classBase}-help"> 51 <button data-ui-help-trigger 52 class="${this.classBase}-help-trigger" 53 aria-label="keyboard shortcuts" 54 aria-haspopup="dialog">Keyboard Shortcuts</button> 55 </div> 56 57 <div class="${this.classBase}-days ${this.classBase}-row" aria-hidden="true"> 58 <span class="${this.calItem} ${this.calItem}--day">Su</span> 59 <span class="${this.calItem} ${this.calItem}--day">Mo</span> 60 <span class="${this.calItem} ${this.calItem}--day">Tu</span> 61 <span class="${this.calItem} ${this.calItem}--day">We</span> 62 <span class="${this.calItem} ${this.calItem}--day">Th</span> 63 <span class="${this.calItem} ${this.calItem}--day">Fr</span> 64 <span class="${this.calItem} ${this.calItem}--day">Sa</span> 65 </div> 66 67 <section data-ui-dates aria-label="Calendar dates" role="application"> 68 </section> 69 </div> 70 71 <div data-ui-help-dialog 72 class="${this.classBase}-help-dialog" 73 role="dialog" 74 aria-labelledby="${this.idBase}-help-trigger" 75 aria-hidden="true" 76 tabindex="-1"> 77 78 <p tabindex="-1">The following keyboard shortcuts are available:</p> 79 <ul> 80 <li><kbd>LEFT</kbd>/ <kbd>RIGHT</kbd> to move day to day.</li> 81 <li><kbd>UP</kbd>/ <kbd>DOWN</kbd> to move week to week.</li> 82 <li><kbd>HOME</kbd> to move to the first day of the month.</li> 83 <li><kbd>END</kbd> to move to the last day of the month.</li> 84 <li><kbd>PAGE UP</kbd> to move to the same day in the previous month.</li> 85 <li><kbd>PAGE DOWN</kbd> to move to the same day in the next month.</li> 86 <li><kbd>SPACE</kbd> to select a date.</li> 87 </ul> 88 89 <button data-ui-help-close class="${this.classBase}-help-close" type="button">Got it!</button> 90 </div> 91 92 <span data-ui-updates 93 class="show-for-sr" 94 aria-live="assertive"></span> 95 </section>`);s(this,"getDateTemplate",(t,e,a)=>{const i=this.getHoliday(t),l=t.get("M")!==e.get("M")||i&&!i.isEnabled,o=t.isSame(a),r=t.isSame(this.selected);return`<button 96 class="${this.calItem} ${l?this.calItem+"--unavailable":this.calItem+"--active"} ${i?this.calItem+"--holiday":""}" 97 type="button" 98 aria-pressed="${r}" 99 ${t.isBefore(this.minDate)?"disabled":""} 100 aria-label="${n(t).format("D, dddd MMMM YYYY")}${i?`, ${i.label}`:""}${l?", Unavailable":""}" 101 ${o?'aria-current="date"':""} 102 ${t.format("D")!==a.format("D")?'tabindex="-1"':""} 103 ${i?`data-holiday="${i.label}"`:""} 104 data-timestamp="${t.unix()}"> 105 ${t.format("D")} 106 </button>`});s(this,"onKeydown",t=>{const e=t.target,a=t.key.replace("Arrow","");let i=null;if(e.classList.contains(this.calItem)&&a.match(/Up|Down|Left|Right|Home|End|PageUp|PageDown/)){switch(a){case"Right":e===this.getLastDate()?(this.nextMonth(),i=this.getFirstDate()):i=e.nextElementSibling||e.parentElement?.nextElementSibling?.firstElementChild;break;case"Left":e===this.getFirstDate()?(this.previousMonth(),i=this.getLastDate()):i=e.previousElementSibling||e.parentElement?.previousElementSibling?.lastElementChild;break;case"Up":if(e===this.getFirstDate())this.previousMonth(),i=this.getLastDate();else{const o=e.parentElement;if(!o)break;const r=Array.from(o.children).indexOf(e),c=o.previousElementSibling;c&&(i=c.children.item(r))}break;case"Down":if(e===this.getLastDate())this.nextMonth(),i=this.getFirstDate();else{const o=e.parentElement;if(!o)break;const r=Array.from(o.children).indexOf(e),c=o.nextElementSibling;c&&(i=c.children.item(r))}break;case"Home":i=this.getFirstDate();break;case"End":i=this.getLastDate();break;case"PageUp":case"PageDown":a==="PageUp"?this.previousMonth():this.nextMonth();const l=this.calendarSection.querySelectorAll("."+this.calItem);l.length&&(i=Array.from(l).find(o=>o.textContent===e.textContent)||null);break}t.preventDefault(),i?i.focus():this.announce("end of calendar")}});s(this,"getDisplayedMonth",()=>n(new Date(parseInt(this.yearSelect.item(this.yearSelect.selectedIndex).value),this.monthSelect.selectedIndex,1)));s(this,"getFirstDate",()=>this.calendarSection.firstElementChild.querySelector(`.${this.calItem}:first-of-type:not(.${this.calItem}--empty)`));s(this,"getLastDate",()=>this.calendarSection.lastElementChild.querySelector(`.${this.calItem}:last-of-type:not(.${this.calItem}--empty)`));s(this,"getHoliday",t=>{const e=t.get("y"),a=t.get("M"),i=t.get("d"),o=this.holidays[e];if(!o)return null;const r=o[a];return r?r[i]??null:null});s(this,"setText",(t,e="")=>{const a=t.firstChild;a&&!a.nextSibling&&a.nodeType===3?a.data=e:t.textContent=e});s(this,"previousMonth",()=>{const t=n(this.getDisplayedMonth()).subtract(1,"month"),e=t.get("M"),a=t>=this.minDate.startOf("M"),i=a?this.yearSelect.selectedIndex-1:this.yearSelect.selectedIndex;a&&(this.monthSelect.selectedIndex=e,t.get("M")===11&&i>=0&&(this.yearSelect.selectedIndex=i),this.updateUI())});s(this,"nextMonth",()=>{const t=n(this.getDisplayedMonth()).add(1,"month"),e=t.get("M"),a=t<=this.maxDate,i=a?this.yearSelect.selectedIndex+1:this.yearSelect.selectedIndex;a&&(this.monthSelect.selectedIndex=e,t.get("M")==0&&(this.yearSelect.selectedIndex=i)),this.updateUI()});s(this,"onDialogUx",t=>{const e=t.target;(!this.dialog.contains(e)||t.type==="click"&&e===this.close)&&this.closeDialog()});s(this,"onActivation",t=>{const e=t.target;e.classList.contains(this.calItem+"--active")&&this.selectDate(e)});s(this,"onMirrorInputActivation",t=>{const e=t.target;this.setMirrorDateInput(e)});s(this,"updateUI",()=>{const t=this.getDisplayedMonth(),e=n(t).subtract(1,"month"),a=n(t).add(1,"month");this.nextButton.disabled=a>this.maxDate,e>=this.minDate.startOf("M")?(this.prevButton.disabled=!1,this.prevButton.setAttribute("aria-label","Previous month, "+this.monthSelect.item(e.get("M")).value+" "+e.get("y"))):this.prevButton.disabled=!0,this.nextButton.setAttribute("aria-label",`Next month, ${this.monthSelect.item(a.get("M")).value} ${a.get("y")}`);const i=`${this.monthSelect.value} ${this.yearSelect.value}`;this.announce(i),this.renderDates(t)});s(this,"renderDates",t=>{let e=n(t).startOf("month").startOf("week").subtract(1,"day");const a=n(t).endOf("month").endOf("week").subtract(1,"day"),i=n().set("hour",0).set("minute",0).set("second",0).set("millisecond",0),l=[];for(;e.isBefore(a);)l.push(Array(7).fill(0).map(()=>(e=e.add(1,"day"),e)));const o=l.reduce((r,c)=>{const p=c.reduce((u,d)=>(d=d.set("hour",0).set("minute",0).set("second",0).set("millisecond",0),d.get("M")!==t.get("M")?`${u}<span class="${this.calItem} ${this.calItem}--empty"></span>`:`${u}${this.getDateTemplate(d,t,i)}`),"");return`${r}<div class="${this.classBase}-row">${p}</div>`},"");this.calendarSection.innerHTML="",this.calendarSection.insertAdjacentHTML("beforeend",o)});this.selector=t,this.allPickers=document.querySelectorAll(t),this.allPickers!==null&&this.allPickers.forEac
106h((e,a)=>{if(e.hasAttribute("type")&&e.getAttribute("type")=="text"&&!e.hasAttribute("data-datepicker-setup")){e.setAttribute("data-datepicker-setup",""),e.insertAdjacentHTML("afterend",this.getButtonTemplate(a+1));const i=e.nextSibling;i&&i.addEventListener("click",this.togglePicker),e.parentElement&&e.parentElement.classList.add(this.classBase+"-wrap"),e.hasAttribute("data-mirrors-to")&&e.addEventListener("blur",this.onMirrorInputActivation)}})}}export{k as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.