/* @license GPL-2.0-or-later https://www.drupal.org/licensing/faq */ (function(Drupal,Popper,once){const onceName='tooltip';const triggerSelector='[data-tooltip]';const tooltipSelector='[data-tooltip-id]';const tooltipHoverTimeout=250;Drupal.behaviors.tooltip={attach:function(context,settings){function createTooltipFromElement(element){let attr={};let content='';try{attr=JSON.parse(element.dataset.tooltip||'{}');content=attr.content||element.title;}catch(e){return;}if(!content.length)return;let displayArrow=Boolean(attr.arrow??true);let uniqueId=Date.now()+'-'+Math.random().toString().slice(2,4);let tooltip=document.createElement('div');tooltip.classList.add('tooltip');tooltip.dataset.tooltipId=uniqueId;tooltip.innerHTML=content;if(displayArrow)tooltip.innerHTML+='
';document.body.appendChild(tooltip);attr.block=uniqueId;delete attr.block;element.dataset.tooltip=JSON.stringify(attr);delete element.title;return tooltip;};function instanciateTooltip(element,tooltip){let arrow=tooltip.querySelector('[data-popper-arrow]');if(arrow)tooltip.appendChild(arrow);let attr=JSON.parse(element.dataset.tooltip||'{}');element.dataset.popperPlacement=attr.placement??'top';let options={};options.placement=element.dataset.popperPlacement;options.modifiers=attr.modifiers||[];if(!options.modifiers.filter((_modifier)=>_modifier.name=='offset'))options.modifiers.push({name:'offset',options:{offset:[0,10]}});const popperInstance=Popper.createPopper(element,tooltip,options);tooltip.classList.add('visually-hidden');tooltip.addEventListener('mouseenter',function(){this.dataset.reading=true;});tooltip.addEventListener('mouseleave',function(){delete this.dataset.reading;this.classList.add('visually-hidden');});element.addEventListener('mouseenter',function(){tooltip.classList.remove('visually-hidden');popperInstance.update();});element.addEventListener('focus',function(){tooltip.classList.remove('visually-hidden');popperInstance.update();});element.addEventListener('mouseleave',function(){setTimeout(function(){if(!Boolean(tooltip.dataset.reading))tooltip.classList.add('visually-hidden');},tooltipHoverTimeout);});element.addEventListener('blur',function(){setTimeout(function(){if(!Boolean(tooltip.dataset.reading))tooltip.classList.add('visually-hidden');},tooltipHoverTimeout);});};once(onceName,triggerSelector,context).forEach(async function(element){let attr=JSON.parse(element.dataset.tooltip||'{}');let tooltipQuerySelector='[data-tooltip-id="'+attr.block+'"]';let tooltip=context.querySelector(tooltipQuerySelector);if(!tooltip&&Boolean(attr.block)){const ajaxObject=Drupal.ajax({url:Drupal.url(`tooltip/block/${attr.block}`)});ajaxObject.success=function(response,status){let attr=JSON.parse(element.dataset.tooltip||'{}');attr.content=response.content;element.dataset.tooltip=JSON.stringify(attr);tooltip=createTooltipFromElement(element);if(tooltip)instanciateTooltip(element,tooltip);else delete element.dataset.tooltip;};ajaxObject.execute();return;}if(!tooltip)tooltip=createTooltipFromElement(element);if(tooltip){if(tooltip.dataset.tooltipId){element.setAttribute('tabindex','0');element.setAttribute('aria-describedby',tooltip.dataset.tooltipId);tooltip.setAttribute('id',tooltip.dataset.tooltipId);tooltip.setAttribute('role','tooltip');}instanciateTooltip(element,tooltip);}else delete element.dataset.tooltip;});once(onceName,tooltipSelector,context).forEach(function(element){if(!element.classList.contains('visually-hidden'))element.classList.add('visually-hidden');});},detach(context,settings,trigger){if(trigger==='unload'){once.remove(onceName,triggerSelector,context);once.remove(onceName,tooltipSelector,context);}}};})(Drupal,Popper,once);; (function($,once){Drupal.behaviors.dojAnalyticsEvents={attach:function(context,settings){if(typeof ga==='undefined'||typeof ga.getAll!=='function')trackerName='GSA_ENOR0';else var trackerName=ga.getAll()[0].get('name');var regex=/(\/download$)|(\/dl$)|(\/dl\?inline$)|(\.(png|gif|jpg|jpeg|pdf|txt|rtf|doc|docx|xls|xsd|xlsx|csv|mp3|mp4|wpd|wp|qpw|xml|ppt|pptx|wmv|swf|flv|ods|zip|xht|tex|tiff|tif|bmp|json))$/i;var $downloadables=$('a',context).filter(function(){var href=$(this).attr('href');return (href&&href.match(regex));});$(once('doj-analytics',$downloadables)).click(function(e){if(typeof ga==='undefined')return;ga(trackerName+'.send','event',{eventCategory:'Downloads-DOJ_Sitewide',eventAction:'Click',eventLabel:$(this).attr('href'),eventValue:0});});$(once('doj-analytics','#sharing-links li a',context)).click(function(e){if(typeof ga==='undefined')return;ga(trackerName+'.send','event',{eventCategory:'Sharing',eventAction:'Link click',eventLabel:$(this).attr('data-event-label'),eventValue:0});});}};})(jQuery,once);; (function($,Drupal,once){'use strict';Drupal.behaviors.unorderedListJumpmenu={attach:function(context,settings){$(once('unorderedListJumpmenu','.jumpmenu.js-jumpmenu',context)).each(function(){let $jumpmenu=$('
').addClass('jumpmenu container-inline');let chooseOptionText=Drupal.t('Choose Option');let selectClasses='jumpmenu-select form-select';if($(this).hasClass('jumpmenu-no-tabs'))selectClasses+=' jumpmenu-no-tabs';let $select=$('').attr('type','submit').attr('name','op').attr('value','Go').addClass('form-submit'));$jumpmenu.append($formTypeSelect);$(this).replaceWith($jumpmenu);});$('form.jumpmenu',context).each(function(){var $select=$(this).find('select.jumpmenu-select');$select.val('_none');var submitCallback=function(){var url=$(this).find('option:selected').val();if(url!='_none'){if($select.hasClass('jumpmenu-no-tabs'))window.location=url;else window.open(url,'newTab');return false;}};if($select.hasClass('jumpmenu-hide-button')){$(this).find('.form-submit').hide();$select.change(submitCallback);}else $(this).submit(submitCallback);});}};})(jQuery,Drupal,once);; (function($,window){"use strict";Drupal.behaviors.usdojSeaerch={attach:function(context){let affiliate;let component=document.querySelector('#affiliate');if(component){let affiliate=component.getAttribute('value');}var moduleConfig=drupalSettings.usasearch;window.usasearch_config={siteHandle:affiliate};var script=document.createElement("script");script.type="text/javascript";script.src="//search.justice.gov/javascripts/remote.loader.js";if(once('search-script','body',context).length)$('body').append(script);}};})(jQuery,window,once);; ;(function(factory){'use strict';if(typeof define==='function'&&define.amd)define(['jquery'],factory);else{if(jQuery&&!jQuery.fn.hoverIntent)factory(jQuery);}})(function($){'use strict';var _cfg={interval:100,sensitivity:6,timeout:0};var INSTANCE_COUNT=0;var cX,cY;var track=function(ev){cX=ev.pageX;cY=ev.pageY;};var compare=function(ev,$el,s,cfg){if(Math.sqrt((s.pX-cX)*(s.pX-cX)+(s.pY-cY)*(s.pY-cY))'],191:['/','?'],192:['`','~'],219:['[','{'],220:['\\','|'],221:[']','}'],222:["'",'"'],224:'Meta',225:'AltGraph',246:'Attn',247:'CrSel',248:'ExSel',249:'EraseEof',250:'Play',251:'ZoomOut'}};var i;for(i=1;i<25;i++)keyboardeventKeyPolyfill.keys[111+i]='F'+i;var letter='';for(i=65;i<91;i++){letter=String.fromCharCode(i);keyboardeventKeyPolyfill.keys[i]=[letter.toLowerCase(),letter.toUpperCase()];}function polyfill(){if(!('KeyboardEvent' in window)||'key' in KeyboardEvent.prototype)return false;var proto={get:function(x){var key=keyboardeventKeyPolyfill.keys[this.which||this.keyCode];if(Array.isArray(key))key=key[+this.shiftKey];return key;}};Object.defineProperty(KeyboardEvent.prototype,'key',proto);return proto;}if(typeof define==='function'&&define.amd)define('keyboardevent-key-polyfill',keyboardeventKeyPolyfill);else if(typeof exports!=='undefined'&&typeof module!=='undefined')module.exports=keyboardeventKeyPolyfill;else{if(window)window.keyboardeventKeyPolyfill=keyboardeventKeyPolyfill;}})();},{}],3:[function(require,module,exports){'use strict';var getOwnPropertySymbols=Object.getOwnPropertySymbols;var hasOwnProperty=Object.prototype.hasOwnProperty;var propIsEnumerable=Object.prototype.propertyIsEnumerable;function toObject(val){if(val===null||val===undefined)throw new TypeError('Object.assign cannot be called with null or undefined');return Object(val);}function shouldUseNative(){try{if(!Object.assign)return false;var test1=new String('abc');test1[5]='de';if(Object.getOwnPropertyNames(test1)[0]==='5')return false;var test2={};for(var i=0;i<10;i++)test2['_'+String.fromCharCode(i)]=i;var order2=Object.getOwnPropertyNames(test2).map(function(n){return test2[n];});if(order2.join('')!=='0123456789')return false;var test3={};'abcdefghijklmnopqrst'.split('').forEach(function(letter){test3[letter]=letter;});if(Object.keys(Object.assign({},test3)).join('')!=='abcdefghijklmnopqrst')return false;return true;}catch(err){return false;}}module.exports=shouldUseNative()?Object.assign:function(target,source){var from;var to=toObject(target);var symbols;for(var s=1;s-1)return type.split(SPACE).map(function(_type){return assign({type:_type},listener);});else{listener.type=type;return [listener];}};var popKey=function(obj,key){var value=obj[key];delete obj[key];return value;};module.exports=function behavior(events,props){const listeners=Object.keys(events).reduce(function(memo,type){var listeners=getListeners(type,events[type]);return memo.concat(listeners);},[]);return assign({add:function addBehavior(element){listeners.forEach(function(listener){element.addEventListener(listener.type,listener.delegate,listener.options);});},remove:function removeBehavior(element){listeners.forEach(function(listener){element.removeEventListener(listener.type,listener.delegate,listener.options);});}},props);};},{"../delegate":6,"../delegateAll":7,"object-assign":3}],5:[function(require,module,exports){"use strict";module.exports=function compose(functions){return function(e){return functions.some(function(fn){return fn.call(this,e)===false;},this);};};},{}],6:[function(require,module,exports){"use strict";require('element-closest');module.exports=function delegate(selector,fn){return function delegation(event){var target=event.target.closest(selector);if(target)return fn.call(target,event);};};},{"element-closest":1}],7:[function(require,module,exports){"use strict";const delegate=require('../delegate');const compose=require('../compose');const SPLAT='*';module.exports=function delegateAll(selectors){const keys=Object.keys(selectors);if(keys.length===1&&keys[0]===SPLAT)return selectors[SPLAT];const delegates=keys.reduce(function(memo,selector){memo.push(delegate(selector,selectors[selector]));return memo;},[]);return compose(delegates);};},{"../compose":5,"../delegate":6}],8:[function(require,module,exports){"use strict";module.exports=function ignore(element,fn){return function ignorance(e){if(element!==e.target&&!element.contains(e.target))return fn.call(this,e);};};},{}],9:[function(require,module,exports){"use strict";module.exports={behavior:require('./behavior'),delegate:require('./delegate'),delegateAll:require('./delegateAll'),ignore:require('./ignore'),keymap:require('./keymap')};},{"./behavior":4,"./delegate":6,"./delegateAll":7,"./ignore":8,"./keymap":10}],10:[function(require,module,exports){"use strict";require('keyboardevent-key-polyfill');const MODIFIERS={'Alt':'altKey','Control':'ctrlKey','Ctrl':'ctrlKey','Shift':'shiftKey'};const MODIFIER_SEPARATOR='+';const getEventKey=function(event,hasModifiers){var key=event.key;if(hasModifiers)for(var modifier in MODIFIERS)if(event[MODIFIERS[modifier]]===true)key=[modifier,key].join(MODIFIER_SEPARATOR);return key;};module.exports=function keymap(keys){const hasModifiers=Object.keys(keys).some(function(key){return key.indexOf(MODIFIER_SEPARATOR)>-1;});return function(event){var key=getEventKey(event,hasModifiers);return [key,key.toLowerCase()].reduce(function(result,_key){if(_key in keys)result=keys[key].call(this,event);return result;},undefined);};};module.exports.MODIFIERS=MODIFIERS;},{"keyboardevent-key-polyfill":2}],11:[function(require,module,exports){"use strict";module.exports=function once(listener,options){var wrapped=function wrappedOnce(e){e.currentTarget.removeEventListener(e.type,wrapped,options);return listener.call(this,e);};return wrapped;};},{}],12:[function(require,module,exports){"use strict";const behavior=require("../../uswds-core/src/js/utils/behavior");const toggleFormInput=require("../../uswds-core/src/js/utils/toggle-form-input");const {CLICK}=require("../../uswds-core/src/js/events");const {prefix:PREFIX}=require("../../uswds-core/src/js/config");const LINK=`.${PREFIX}-show-password`;function toggle(event){event.preventDefault();toggleFormInput(this);}module.exports=behavior({[CLICK]:{[LINK]:toggle}});},{"../../uswds-core/src/js/config":34,"../../uswds-core/src/js/events":35,"../../uswds-core/src/js/utils/behavior":39,"../../uswds-core/src/js/utils/toggle-form-input":49}],13:[function(require,module,exports){"use strict";const select=require("../../uswds-core/src/js/utils/select");const behavior=require("../../uswds-core/src/js/utils/behavior");const toggle=require("../../uswds-core/src/js/utils/toggle");const isElementInViewport=require("../../uswds-core/src/js/utils/is-in-viewport");const {CLICK}=require("../../uswds-core/src/js/events");const {prefix:PREFIX}=require("../../uswds-core/src/js/config");const ACCORDION=`.${PREFIX}-accordion, .${PREFIX}-accordion--bordered`;const BANNER_BUTTON=`.${PREFIX}-banner__button`;const BUTTON=`.${PREFIX}-accordion__button[aria-controls]:not(${BANNER_BUTTON})`;const EXPANDED="aria-expanded";const MULTISELECTABLE="data-allow-multiple";const getAccordionButtons=(accordion)=>{const buttons=select(BUTTON,accordion);return buttons.filter((button)=>button.closest(ACCORDION)===accordion);};const toggleButton=(button,expanded)=>{const accordion=button.closest(ACCORDION);let safeExpanded=expanded;if(!accordion)throw new Error(`${BUTTON} is missing outer ${ACCORDION}`);safeExpanded=toggle(button,expanded);const multiselectable=accordion.hasAttribute(MULTISELECTABLE);if(safeExpanded&&!multiselectable)getAccordionButtons(accordion).forEach((other)=>{if(other!==button)toggle(other,false);});};const showButton=(button)=>toggleButton(button,true);const hideButton=(button)=>toggleButton(button,false);const accordion=behavior({[CLICK]:{[BUTTON](){toggleButton(this);if(this.getAttribute(EXPANDED)==="true")if(!isElementInViewport(this))this.scrollIntoView();}}},{init(root){select(BUTTON,root).forEach((button)=>{const expanded=button.getAttribute(EXPANDED)==="true";toggleButton(button,expanded);});},ACCORDION,BUTTON,show:showButton,hide:hideButton,toggle:toggleButton,getButtons:getAccordionButtons});module.exports=accordion;},{"../../uswds-core/src/js/config":34,"../../uswds-core/src/js/events":35,"../../uswds-core/src/js/utils/behavior":39,"../../uswds-core/src/js/utils/is-in-viewport":42,"../../uswds-core/src/js/utils/select":47,"../../uswds-core/src/js/utils/toggle":50}],14:[function(require,module,exports){"use strict";const behavior=require("../../uswds-core/src/js/utils/behavior");const select=require("../../uswds-core/src/js/utils/select");const {CLICK}=require("../../uswds-core/src/js/events");const {prefix:PREFIX}=require("../../uswds-core/src/js/config");const toggle=require("../../uswds-core/src/js/utils/toggle");const HEADER=`.${PREFIX}-banner__header`;const EXPANDED_CLASS=`${PREFIX}-banner__header--expanded`;const BANNER_BUTTON=`${HEADER} [aria-controls]`;const toggleBanner=function toggleEl(event){event.preventDefault();const trigger=event.target.closest(BANNER_BUTTON);toggle(trigger);this.closest(HEADER).classList.toggle(EXPANDED_CLASS);};module.exports=behavior({[CLICK]:{[BANNER_BUTTON]:toggleBanner}},{init(root){select(BANNER_BUTTON,root).forEach((button)=>{const expanded=button.getAttribute(EXPANDED_CLASS)==="true";toggle(button,expanded);});}});},{"../../uswds-core/src/js/config":34,"../../uswds-core/src/js/events":35,"../../uswds-core/src/js/utils/behavior":39,"../../uswds-core/src/js/utils/select":47,"../../uswds-core/src/js/utils/toggle":50}],15:[function(require,module,exports){"use strict";const keymap=require("receptor/keymap");const behavior=require("../../uswds-core/src/js/utils/behavior");const ANCHOR_BUTTON=`a[class*="usa-button"]`;const toggleButton=(event)=>{event.preventDefault();event.target.click();};const anchorButton=behavior({keydown:{[ANCHOR_BUTTON]:keymap({" ":toggleButton})}});module.exports=anchorButton;},{"../../uswds-core/src/js/utils/behavior":39,"receptor/keymap":10}],16:[function(require,module,exports){"use strict";const select=require("../../uswds-core/src/js/utils/select");const behavior=require("../../uswds-core/src/js/utils/behavior");const debounce=require("../../uswds-core/src/js/utils/debounce");const {prefix:PREFIX}=require("../../uswds-core/src/js/config");const CHARACTER_COUNT_CLASS=`${PREFIX}-character-count`;const CHARACTER_COUNT=`.${CHARACTER_COUNT_CLASS}`;const FORM_GROUP_CLASS=`${PREFIX}-form-group`;const FORM_GROUP_ERROR_CLASS=`${FORM_GROUP_CLASS}--error`;const FORM_GROUP=`.${FORM_GROUP_CLASS}`;const LABEL_CLASS=`${PREFIX}-label`;const LABEL_ERROR_CLASS=`${LABEL_CLASS}--error`;const INPUT=`.${PREFIX}-character-count__field`;const INPUT_ERROR_CLASS=`${PREFIX}-input--error`;const MESSAGE=`.${PREFIX}-character-count__message`;const VALIDATION_MESSAGE="The content is too long.";const MESSAGE_INVALID_CLASS=`${PREFIX}-character-count__status--invalid`;const STATUS_MESSAGE_CLASS=`${CHARACTER_COUNT_CLASS}__status`;const STATUS_MESSAGE_SR_ONLY_CLASS=`${CHARACTER_COUNT_CLASS}__sr-status`;const STATUS_MESSAGE=`.${STATUS_MESSAGE_CLASS}`;const STATUS_MESSAGE_SR_ONLY=`.${STATUS_MESSAGE_SR_ONLY_CLASS}`;const DEFAULT_STATUS_LABEL=`characters allowed`;const getCharacterCountElements=(inputEl)=>{const characterCountEl=inputEl.closest(CHARACTER_COUNT);if(!characterCountEl)throw new Error(`${INPUT} is missing outer ${CHARACTER_COUNT}`);const formGroupEl=characterCountEl.querySelector(FORM_GROUP);const inputID=inputEl.getAttribute("id");const labelEl=document.querySelector(`label[for=${inputID}]`);const messageEl=characterCountEl.querySelector(MESSAGE);if(!messageEl)throw new Error(`${CHARACTER_COUNT} is missing inner ${MESSAGE}`);return {characterCountEl,formGroupEl,inputID,labelEl,messageEl};};const setDataLength=(inputEl)=>{const {characterCountEl}=getCharacterCountElements(inputEl);const maxlength=inputEl.getAttribute("maxlength");if(!maxlength)return;inputEl.removeAttribute("maxlength");characterCountEl.setAttribute("data-maxlength",maxlength);};const createStatusMessages=(characterCountEl)=>{const statusMessage=document.createElement("div");const srStatusMessage=document.createElement("div");const maxLength=characterCountEl.dataset.maxlength;const defaultMessage=`${maxLength} ${DEFAULT_STATUS_LABEL}`;statusMessage.classList.add(`${STATUS_MESSAGE_CLASS}`,"usa-hint");srStatusMessage.classList.add(`${STATUS_MESSAGE_SR_ONLY_CLASS}`,"usa-sr-only");statusMessage.setAttribute("aria-hidden",true);srStatusMessage.setAttribute("aria-live","polite");statusMessage.textContent=defaultMessage;srStatusMessage.textContent=defaultMessage;characterCountEl.append(statusMessage,srStatusMessage);};const getCountMessage=(currentLength,maxLength)=>{let newMessage="";if(currentLength===0)newMessage=`${maxLength} ${DEFAULT_STATUS_LABEL}`;else{const difference=Math.abs(maxLength-currentLength);const characters=`character${difference===1?"":"s"}`;const guidance=currentLength>maxLength?"over limit":"left";newMessage=`${difference} ${characters} ${guidance}`;}return newMessage;};const srUpdateStatus=debounce((msgEl,statusMessage)=>{const srStatusMessage=msgEl;srStatusMessage.textContent=statusMessage;},1000);const updateCountMessage=(inputEl)=>{const {characterCountEl,labelEl,formGroupEl}=getCharacterCountElements(inputEl);const currentLength=inputEl.value.length;const maxLength=parseInt(characterCountEl.getAttribute("data-maxlength"),10);const statusMessage=characterCountEl.querySelector(STATUS_MESSAGE);const srStatusMessage=characterCountEl.querySelector(STATUS_MESSAGE_SR_ONLY);const currentStatusMessage=getCountMessage(currentLength,maxLength);if(!maxLength)return;const isOverLimit=currentLength&¤tLength>maxLength;statusMessage.textContent=currentStatusMessage;srUpdateStatus(srStatusMessage,currentStatusMessage);if(isOverLimit&&!inputEl.validationMessage)inputEl.setCustomValidity(VALIDATION_MESSAGE);if(!isOverLimit&&inputEl.validationMessage===VALIDATION_MESSAGE)inputEl.setCustomValidity("");if(formGroupEl)formGroupEl.classList.toggle(FORM_GROUP_ERROR_CLASS,isOverLimit);if(labelEl)labelEl.classList.toggle(LABEL_ERROR_CLASS,isOverLimit);inputEl.classList.toggle(INPUT_ERROR_CLASS,isOverLimit);statusMessage.classList.toggle(MESSAGE_INVALID_CLASS,isOverLimit);};const enhanceCharacterCount=(inputEl)=>{const {characterCountEl,messageEl}=getCharacterCountElements(inputEl);messageEl.classList.add("usa-sr-only");messageEl.removeAttribute("aria-live");setDataLength(inputEl);createStatusMessages(characterCountEl);};const characterCount=behavior({input:{[INPUT](){updateCountMessage(this);}}},{init(root){select(INPUT,root).forEach((input)=>enhanceCharacterCount(input));},FORM_GROUP_ERROR_CLASS,LABEL_ERROR_CLASS,INPUT_ERROR_CLASS,MESSAGE_INVALID_CLASS,VALIDATION_MESSAGE,STATUS_MESSAGE_CLASS,STATUS_MESSAGE_SR_ONLY_CLASS,DEFAULT_STATUS_LABEL,createStatusMessages,getCountMessage,updateCountMessage});module.exports=characterCount;},{"../../uswds-core/src/js/config":34,"../../uswds-core/src/js/utils/behavior":39,"../../uswds-core/src/js/utils/debounce":40,"../../uswds-core/src/js/utils/select":47}],17:[function(require,module,exports){"use strict";const keymap=require("receptor/keymap");const selectOrMatches=require("../../uswds-core/src/js/utils/select-or-matches");const behavior=require("../../uswds-core/src/js/utils/behavior");const Sanitizer=require("../../uswds-core/src/js/utils/sanitizer");const {prefix:PREFIX}=require("../../uswds-core/src/js/config");const {CLICK}=require("../../uswds-core/src/js/events");const COMBO_BOX_CLASS=`${PREFIX}-combo-box`;const COMBO_BOX_PRISTINE_CLASS=`${COMBO_BOX_CLASS}--pristine`;const SELECT_CLASS=`${COMBO_BOX_CLASS}__select`;const INPUT_CLASS=`${COMBO_BOX_CLASS}__input`;const CLEAR_INPUT_BUTTON_CLASS=`${COMBO_BOX_CLASS}__clear-input`;const CLEAR_INPUT_BUTTON_WRAPPER_CLASS=`${CLEAR_INPUT_BUTTON_CLASS}__wrapper`;const INPUT_BUTTON_SEPARATOR_CLASS=`${COMBO_BOX_CLASS}__input-button-separator`;const TOGGLE_LIST_BUTTON_CLASS=`${COMBO_BOX_CLASS}__toggle-list`;const TOGGLE_LIST_BUTTON_WRAPPER_CLASS=`${TOGGLE_LIST_BUTTON_CLASS}__wrapper`;const LIST_CLASS=`${COMBO_BOX_CLASS}__list`;const LIST_OPTION_CLASS=`${COMBO_BOX_CLASS}__list-option`;const LIST_OPTION_FOCUSED_CLASS=`${LIST_OPTION_CLASS}--focused`;const LIST_OPTION_SELECTED_CLASS=`${LIST_OPTION_CLASS}--selected`;const STATUS_CLASS=`${COMBO_BOX_CLASS}__status`;const COMBO_BOX=`.${COMBO_BOX_CLASS}`;const SELECT=`.${SELECT_CLASS}`;const INPUT=`.${INPUT_CLASS}`;const CLEAR_INPUT_BUTTON=`.${CLEAR_INPUT_BUTTON_CLASS}`;const TOGGLE_LIST_BUTTON=`.${TOGGLE_LIST_BUTTON_CLASS}`;const LIST=`.${LIST_CLASS}`;const LIST_OPTION=`.${LIST_OPTION_CLASS}`;const LIST_OPTION_FOCUSED=`.${LIST_OPTION_FOCUSED_CLASS}`;const LIST_OPTION_SELECTED=`.${LIST_OPTION_SELECTED_CLASS}`;const STATUS=`.${STATUS_CLASS}`;const DEFAULT_FILTER=".*{{query}}.*";const noop=()=>{};const changeElementValue=(el,value="")=>{const elementToChange=el;elementToChange.value=value;const event=new CustomEvent("change",{bubbles:true,cancelable:true,detail:{value}});elementToChange.dispatchEvent(event);};const getComboBoxContext=(el)=>{const comboBoxEl=el.closest(COMBO_BOX);if(!comboBoxEl)throw new Error(`Element is missing outer ${COMBO_BOX}`);const selectEl=comboBoxEl.querySelector(SELECT);const inputEl=comboBoxEl.querySelector(INPUT);const listEl=comboBoxEl.querySelector(LIST);const statusEl=comboBoxEl.querySelector(STATUS);const focusedOptionEl=comboBoxEl.querySelector(LIST_OPTION_FOCUSED);const selectedOptionEl=comboBoxEl.querySelector(LIST_OPTION_SELECTED);const toggleListBtnEl=comboBoxEl.querySelector(TOGGLE_LIST_BUTTON);const clearInputBtnEl=comboBoxEl.querySelector(CLEAR_INPUT_BUTTON);const isPristine=comboBoxEl.classList.contains(COMBO_BOX_PRISTINE_CLASS);const disableFiltering=comboBoxEl.dataset.disableFiltering==="true";return {comboBoxEl,selectEl,inputEl,listEl,statusEl,focusedOptionEl,selectedOptionEl,toggleListBtnEl,clearInputBtnEl,isPristine,disableFiltering};};const disable=(el)=>{const {inputEl,toggleListBtnEl,clearInputBtnEl}=getComboBoxContext(el);clearInputBtnEl.hidden=true;clearInputBtnEl.disabled=true;toggleListBtnEl.disabled=true;inputEl.disabled=true;};const ariaDisable=(el)=>{const {inputEl,toggleListBtnEl,clearInputBtnEl}=getComboBoxContext(el);clearInputBtnEl.hidden=true;clearInputBtnEl.setAttribute("aria-disabled",true);toggleListBtnEl.setAttribute("aria-disabled",true);inputEl.setAttribute("aria-disabled",true);};const enable=(el)=>{const {inputEl,toggleListBtnEl,clearInputBtnEl}=getComboBoxContext(el);clearInputBtnEl.hidden=false;clearInputBtnEl.disabled=false;toggleListBtnEl.disabled=false;inputEl.disabled=false;};const enhanceComboBox=(_comboBoxEl)=>{const comboBoxEl=_comboBoxEl.closest(COMBO_BOX);if(comboBoxEl.dataset.enhanced)return;const selectEl=comboBoxEl.querySelector("select");if(!selectEl)throw new Error(`${COMBO_BOX} is missing inner select`);const selectId=selectEl.id;const selectLabel=document.querySelector(`label[for="${selectId}"]`);const listId=`${selectId}--list`;const listIdLabel=`${selectId}-label`;const additionalAttributes=[];const {defaultValue}=comboBoxEl.dataset;const {placeholder}=comboBoxEl.dataset;let selectedOption;if(placeholder)additionalAttributes.push({placeholder});if(defaultValue){for(let i=0,len=selectEl.options.length;i{if(selectEl.hasAttribute(name)){const value=selectEl.getAttribute(name);additionalAttributes.push({[name]:value});selectEl.removeAttribute(name);}});const input=document.createElement("input");input.setAttribute("id",selectId);input.setAttribute("aria-owns",listId);input.setAttribute("aria-controls",listId);input.setAttribute("aria-autocomplete","list");input.setAttribute("aria-expanded","false");input.setAttribute("autocapitalize","off");input.setAttribute("autocomplete","off");input.setAttribute("class",INPUT_CLASS);input.setAttribute("type","text");input.setAttribute("role","combobox");additionalAttributes.forEach((attr)=>Object.keys(attr).forEach((key)=>{const value=Sanitizer.escapeHTML`${attr[key]}`;input.setAttribute(key,value);}));comboBoxEl.insertAdjacentElement("beforeend",input);comboBoxEl.insertAdjacentHTML("beforeend",Sanitizer.escapeHTML`  
`);if(selectedOption){const {inputEl}=getComboBoxContext(comboBoxEl);changeElementValue(selectEl,selectedOption.value);changeElementValue(inputEl,selectedOption.text);comboBoxEl.classList.add(COMBO_BOX_PRISTINE_CLASS);}if(selectEl.disabled){disable(comboBoxEl);selectEl.disabled=false;}if(selectEl.hasAttribute("aria-disabled")){ariaDisable(comboBoxEl);selectEl.removeAttribute("aria-disabled");}comboBoxEl.dataset.enhanced="true";};const highlightOption=(el,nextEl,{skipFocus,preventScroll}={})=>{const {inputEl,listEl,focusedOptionEl}=getComboBoxContext(el);if(focusedOptionEl){focusedOptionEl.classList.remove(LIST_OPTION_FOCUSED_CLASS);focusedOptionEl.setAttribute("tabIndex","-1");}if(nextEl){inputEl.setAttribute("aria-activedescendant",nextEl.id);nextEl.setAttribute("tabIndex","0");nextEl.classList.add(LIST_OPTION_FOCUSED_CLASS);if(!preventScroll){const optionBottom=nextEl.offsetTop+nextEl.offsetHeight;const currentBottom=listEl.scrollTop+listEl.offsetHeight;if(optionBottom>currentBottom)listEl.scrollTop=optionBottom-listEl.offsetHeight;if(nextEl.offsetTop{const escapeRegExp=(text)=>text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&");let find=filter.replace(/{{(.*?)}}/g,(m,$1)=>{const key=$1.trim();const queryFilter=extras[key];if(key!=="query"&&queryFilter){const matcher=new RegExp(queryFilter,"i");const matches=query.match(matcher);if(matches)return escapeRegExp(matches[1]);return "";}return escapeRegExp(query);});find=`^(?:${find})$`;return new RegExp(find,"i");};const displayList=(el)=>{const {comboBoxEl,selectEl,inputEl,listEl,statusEl,isPristine,disableFiltering}=getComboBoxContext(el);let selectedItemId;let firstFoundId;const listOptionBaseId=`${listEl.id}--option-`;const inputValue=(inputEl.value||"").toLowerCase();const filter=comboBoxEl.dataset.filter||DEFAULT_FILTER;const regex=generateDynamicRegExp(filter,inputValue,comboBoxEl.dataset);let options=[];const optionsStartsWith=[];const optionsContains=[];const optionList=[...selectEl.options];const buildOptionsArray=(option)=>{if(disableFiltering||isPristine){options.push(option);return;}const matchStartsWith=option.text.toLowerCase().startsWith(inputValue);if(matchStartsWith)optionsStartsWith.push(option);else optionsContains.push(option);options=[...optionsStartsWith,...optionsContains];};const optionMatchesQuery=(option)=>regex.test(option.text);const arrayNeedsUpdate=(option)=>option.value&&(disableFiltering||isPristine||!inputValue||optionMatchesQuery(option));const isFirstMatch=(option)=>disableFiltering&&!firstFoundId&&optionMatchesQuery(option);const isCurrentSelection=(option)=>selectEl.value&&option.value===selectEl.value;optionList.forEach((option)=>{if(arrayNeedsUpdate(option)){buildOptionsArray(option);const optionId=`${listOptionBaseId}${options.indexOf(option)}`;if(isFirstMatch(option))firstFoundId=optionId;if(isCurrentSelection(option))selectedItemId=optionId;}});const numOptions=options.length;const optionHtml=options.map((option,index)=>{const optionId=`${listOptionBaseId}${index}`;const classes=[LIST_OPTION_CLASS];let tabindex="-1";let ariaSelected="false";if(optionId===selectedItemId){classes.push(LIST_OPTION_SELECTED_CLASS,LIST_OPTION_FOCUSED_CLASS);tabindex="0";ariaSelected="true";}if(!selectedItemId&&index===0){classes.push(LIST_OPTION_FOCUSED_CLASS);tabindex="0";}const li=document.createElement("li");li.setAttribute("aria-setsize",options.length);li.setAttribute("aria-posinset",index+1);li.setAttribute("aria-selected",ariaSelected);li.setAttribute("id",optionId);li.setAttribute("class",classes.join(" "));li.setAttribute("tabindex",tabindex);li.setAttribute("role","option");li.setAttribute("data-value",option.value);li.textContent=option.text;return li;});const noResults=document.createElement("li");noResults.setAttribute("class",`${LIST_OPTION_CLASS}--no-results`);noResults.textContent="No results found";listEl.hidden=false;if(numOptions){listEl.innerHTML="";optionHtml.forEach((item)=>listEl.insertAdjacentElement("beforeend",item));}else{listEl.innerHTML="";listEl.insertAdjacentElement("beforeend",noResults);}inputEl.setAttribute("aria-expanded","true");statusEl.textContent=numOptions?`${numOptions} result${numOptions>1?"s":""} available.`:"No results.";let itemToFocus;if(isPristine&&selectedItemId)itemToFocus=listEl.querySelector(`#${selectedItemId}`);else{if(disableFiltering&&firstFoundId)itemToFocus=listEl.querySelector(`#${firstFoundId}`);}if(itemToFocus)highlightOption(listEl,itemToFocus,{skipFocus:true});};const hideList=(el)=>{const {inputEl,listEl,statusEl,focusedOptionEl}=getComboBoxContext(el);statusEl.innerHTML="";inputEl.setAttribute("aria-expanded","false");inputEl.setAttribute("aria-activedescendant","");if(focusedOptionEl)focusedOptionEl.classList.remove(LIST_OPTION_FOCUSED_CLASS);listEl.scrollTop=0;listEl.hidden=true;};const selectItem=(listOptionEl)=>{const {comboBoxEl,selectEl,inputEl}=getComboBoxContext(listOptionEl);changeElementValue(selectEl,listOptionEl.dataset.value);changeElementValue(inputEl,listOptionEl.textContent);comboBoxEl.classList.add(COMBO_BOX_PRISTINE_CLASS);hideList(comboBoxEl);inputEl.focus();};const clearInput=(clearButtonEl)=>{const {comboBoxEl,listEl,selectEl,inputEl}=getComboBoxContext(clearButtonEl);const listShown=!listEl.hidden;if(selectEl.value)changeElementValue(selectEl);if(inputEl.value)changeElementValue(inputEl);comboBoxEl.classList.remove(COMBO_BOX_PRISTINE_CLASS);if(listShown)displayList(comboBoxEl);inputEl.focus();};const resetSelection=(el)=>{const {comboBoxEl,selectEl,inputEl}=getComboBoxContext(el);const selectValue=selectEl.value;const inputValue=(inputEl.value||"").toLowerCase();if(selectValue){for(let i=0,len=selectEl.options.length;i{const {comboBoxEl,selectEl,inputEl,statusEl}=getComboBoxContext(el);statusEl.textContent="";const inputValue=(inputEl.value||"").toLowerCase();if(inputValue){for(let i=0,len=selectEl.options.length;i{const {comboBoxEl,inputEl}=getComboBoxContext(event.target);hideList(comboBoxEl);resetSelection(comboBoxEl);inputEl.focus();};const handleDownFromInput=(event)=>{const {comboBoxEl,listEl}=getComboBoxContext(event.target);if(listEl.hidden)displayList(comboBoxEl);const nextOptionEl=listEl.querySelector(LIST_OPTION_FOCUSED)||listEl.querySelector(LIST_OPTION);if(nextOptionEl)highlightOption(comboBoxEl,nextOptionEl);event.preventDefault();};const handleEnterFromInput=(event)=>{const {comboBoxEl,listEl}=getComboBoxContext(event.target);const listShown=!listEl.hidden;completeSelection(comboBoxEl);if(listShown)hideList(comboBoxEl);event.preventDefault();};const handleDownFromListOption=(event)=>{const focusedOptionEl=event.target;const nextOptionEl=focusedOptionEl.nextSibling;if(nextOptionEl)highlightOption(focusedOptionEl,nextOptionEl);event.preventDefault();};const handleSpaceFromListOption=(event)=>{selectItem(event.target);event.preventDefault();};const handleEnterFromListOption=(event)=>{selectItem(event.target);event.preventDefault();};const handleUpFromListOption=(event)=>{const {comboBoxEl,listEl,focusedOptionEl}=getComboBoxContext(event.target);const nextOptionEl=focusedOptionEl&&focusedOptionEl.previousSibling;const listShown=!listEl.hidden;highlightOption(comboBoxEl,nextOptionEl);if(listShown)event.preventDefault();if(!nextOptionEl)hideList(comboBoxEl);};const handleMouseover=(listOptionEl)=>{const isCurrentlyFocused=listOptionEl.classList.contains(LIST_OPTION_FOCUSED_CLASS);if(isCurrentlyFocused)return;highlightOption(listOptionEl,listOptionEl,{preventScroll:true});};const toggleList=(el)=>{const {comboBoxEl,listEl,inputEl}=getComboBoxContext(el);if(listEl.hidden)displayList(comboBoxEl);else hideList(comboBoxEl);inputEl.focus();};const handleClickFromInput=(el)=>{const {comboBoxEl,listEl}=getComboBoxContext(el);if(listEl.hidden)displayList(comboBoxEl);};const comboBox=behavior({[CLICK]:{[INPUT](){if(this.disabled)return;handleClickFromInput(this);},[TOGGLE_LIST_BUTTON](){if(this.disabled)return;toggleList(this);},[LIST_OPTION](){if(this.disabled)return;selectItem(this);},[CLEAR_INPUT_BUTTON](){if(this.disabled)return;clearInput(this);}},focusout:{[COMBO_BOX](event){if(!this.contains(event.relatedTarget)){resetSelection(this);hideList(this);}}},keydown:{[COMBO_BOX]:keymap({Escape:handleEscape}),[INPUT]:keymap({Enter:handleEnterFromInput,ArrowDown:handleDownFromInput,Down:handleDownFromInput}),[LIST_OPTION]:keymap({ArrowUp:handleUpFromListOption,Up:handleUpFromListOption,ArrowDown:handleDownFromListOption,Down:handleDownFromListOption,Enter:handleEnterFromListOption," ":handleSpaceFromListOption,"Shift+Tab":noop})},input:{[INPUT](){const comboBoxEl=this.closest(COMBO_BOX);comboBoxEl.classList.remove(COMBO_BOX_PRISTINE_CLASS);displayList(this);}},mouseover:{[LIST_OPTION](){handleMouseover(this);}}},{init(root){selectOrMatches(COMBO_BOX,root).forEach((comboBoxEl)=>{enhanceComboBox(comboBoxEl);});},getComboBoxContext,enhanceComboBox,generateDynamicRegExp,disable,enable,displayList,hideList,COMBO_BOX_CLASS});module.exports=comboBox;},{"../../uswds-core/src/js/config":34,"../../uswds-core/src/js/events":35,"../../uswds-core/src/js/utils/behavior":39,"../../uswds-core/src/js/utils/sanitizer":44,"../../uswds-core/src/js/utils/select-or-matches":46,"receptor/keymap":10}],18:[function(require,module,exports){"use strict";const keymap=require("receptor/keymap");const behavior=require("../../uswds-core/src/js/utils/behavior");const select=require("../../uswds-core/src/js/utils/select");const selectOrMatches=require("../../uswds-core/src/js/utils/select-or-matches");const {prefix:PREFIX}=require("../../uswds-core/src/js/config");const {CLICK}=require("../../uswds-core/src/js/events");const activeElement=require("../../uswds-core/src/js/utils/active-element");const isIosDevice=require("../../uswds-core/src/js/utils/is-ios-device");const Sanitizer=require("../../uswds-core/src/js/utils/sanitizer");const DATE_PICKER_CLASS=`${PREFIX}-date-picker`;const DATE_PICKER_WRAPPER_CLASS=`${DATE_PICKER_CLASS}__wrapper`;const DATE_PICKER_INITIALIZED_CLASS=`${DATE_PICKER_CLASS}--initialized`;const DATE_PICKER_ACTIVE_CLASS=`${DATE_PICKER_CLASS}--active`;const DATE_PICKER_INTERNAL_INPUT_CLASS=`${DATE_PICKER_CLASS}__internal-input`;const DATE_PICKER_EXTERNAL_INPUT_CLASS=`${DATE_PICKER_CLASS}__external-input`;const DATE_PICKER_BUTTON_CLASS=`${DATE_PICKER_CLASS}__button`;const DATE_PICKER_CALENDAR_CLASS=`${DATE_PICKER_CLASS}__calendar`;const DATE_PICKER_STATUS_CLASS=`${DATE_PICKER_CLASS}__status`;const CALENDAR_DATE_CLASS=`${DATE_PICKER_CALENDAR_CLASS}__date`;const CALENDAR_DATE_FOCUSED_CLASS=`${CALENDAR_DATE_CLASS}--focused`;const CALENDAR_DATE_SELECTED_CLASS=`${CALENDAR_DATE_CLASS}--selected`;const CALENDAR_DATE_PREVIOUS_MONTH_CLASS=`${CALENDAR_DATE_CLASS}--previous-month`;const CALENDAR_DATE_CURRENT_MONTH_CLASS=`${CALENDAR_DATE_CLASS}--current-month`;const CALENDAR_DATE_NEXT_MONTH_CLASS=`${CALENDAR_DATE_CLASS}--next-month`;const CALENDAR_DATE_RANGE_DATE_CLASS=`${CALENDAR_DATE_CLASS}--range-date`;const CALENDAR_DATE_TODAY_CLASS=`${CALENDAR_DATE_CLASS}--today`;const CALENDAR_DATE_RANGE_DATE_START_CLASS=`${CALENDAR_DATE_CLASS}--range-date-start`;const CALENDAR_DATE_RANGE_DATE_END_CLASS=`${CALENDAR_DATE_CLASS}--range-date-end`;const CALENDAR_DATE_WITHIN_RANGE_CLASS=`${CALENDAR_DATE_CLASS}--within-range`;const CALENDAR_PREVIOUS_YEAR_CLASS=`${DATE_PICKER_CALENDAR_CLASS}__previous-year`;const CALENDAR_PREVIOUS_MONTH_CLASS=`${DATE_PICKER_CALENDAR_CLASS}__previous-month`;const CALENDAR_NEXT_YEAR_CLASS=`${DATE_PICKER_CALENDAR_CLASS}__next-year`;const CALENDAR_NEXT_MONTH_CLASS=`${DATE_PICKER_CALENDAR_CLASS}__next-month`;const CALENDAR_MONTH_SELECTION_CLASS=`${DATE_PICKER_CALENDAR_CLASS}__month-selection`;const CALENDAR_YEAR_SELECTION_CLASS=`${DATE_PICKER_CALENDAR_CLASS}__year-selection`;const CALENDAR_MONTH_CLASS=`${DATE_PICKER_CALENDAR_CLASS}__month`;const CALENDAR_MONTH_FOCUSED_CLASS=`${CALENDAR_MONTH_CLASS}--focused`;const CALENDAR_MONTH_SELECTED_CLASS=`${CALENDAR_MONTH_CLASS}--selected`;const CALENDAR_YEAR_CLASS=`${DATE_PICKER_CALENDAR_CLASS}__year`;const CALENDAR_YEAR_FOCUSED_CLASS=`${CALENDAR_YEAR_CLASS}--focused`;const CALENDAR_YEAR_SELECTED_CLASS=`${CALENDAR_YEAR_CLASS}--selected`;const CALENDAR_PREVIOUS_YEAR_CHUNK_CLASS=`${DATE_PICKER_CALENDAR_CLASS}__previous-year-chunk`;const CALENDAR_NEXT_YEAR_CHUNK_CLASS=`${DATE_PICKER_CALENDAR_CLASS}__next-year-chunk`;const CALENDAR_DATE_PICKER_CLASS=`${DATE_PICKER_CALENDAR_CLASS}__date-picker`;const CALENDAR_MONTH_PICKER_CLASS=`${DATE_PICKER_CALENDAR_CLASS}__month-picker`;const CALENDAR_YEAR_PICKER_CLASS=`${DATE_PICKER_CALENDAR_CLASS}__year-picker`;const CALENDAR_TABLE_CLASS=`${DATE_PICKER_CALENDAR_CLASS}__table`;const CALENDAR_ROW_CLASS=`${DATE_PICKER_CALENDAR_CLASS}__row`;const CALENDAR_CELL_CLASS=`${DATE_PICKER_CALENDAR_CLASS}__cell`;const CALENDAR_CELL_CENTER_ITEMS_CLASS=`${CALENDAR_CELL_CLASS}--center-items`;const CALENDAR_MONTH_LABEL_CLASS=`${DATE_PICKER_CALENDAR_CLASS}__month-label`;const CALENDAR_DAY_OF_WEEK_CLASS=`${DATE_PICKER_CALENDAR_CLASS}__day-of-week`;const DATE_PICKER=`.${DATE_PICKER_CLASS}`;const DATE_PICKER_BUTTON=`.${DATE_PICKER_BUTTON_CLASS}`;const DATE_PICKER_INTERNAL_INPUT=`.${DATE_PICKER_INTERNAL_INPUT_CLASS}`;const DATE_PICKER_EXTERNAL_INPUT=`.${DATE_PICKER_EXTERNAL_INPUT_CLASS}`;const DATE_PICKER_CALENDAR=`.${DATE_PICKER_CALENDAR_CLASS}`;const DATE_PICKER_STATUS=`.${DATE_PICKER_STATUS_CLASS}`;const CALENDAR_DATE=`.${CALENDAR_DATE_CLASS}`;const CALENDAR_DATE_FOCUSED=`.${CALENDAR_DATE_FOCUSED_CLASS}`;const CALENDAR_DATE_CURRENT_MONTH=`.${CALENDAR_DATE_CURRENT_MONTH_CLASS}`;const CALENDAR_PREVIOUS_YEAR=`.${CALENDAR_PREVIOUS_YEAR_CLASS}`;const CALENDAR_PREVIOUS_MONTH=`.${CALENDAR_PREVIOUS_MONTH_CLASS}`;const CALENDAR_NEXT_YEAR=`.${CALENDAR_NEXT_YEAR_CLASS}`;const CALENDAR_NEXT_MONTH=`.${CALENDAR_NEXT_MONTH_CLASS}`;const CALENDAR_YEAR_SELECTION=`.${CALENDAR_YEAR_SELECTION_CLASS}`;const CALENDAR_MONTH_SELECTION=`.${CALENDAR_MONTH_SELECTION_CLASS}`;const CALENDAR_MONTH=`.${CALENDAR_MONTH_CLASS}`;const CALENDAR_YEAR=`.${CALENDAR_YEAR_CLASS}`;const CALENDAR_PREVIOUS_YEAR_CHUNK=`.${CALENDAR_PREVIOUS_YEAR_CHUNK_CLASS}`;const CALENDAR_NEXT_YEAR_CHUNK=`.${CALENDAR_NEXT_YEAR_CHUNK_CLASS}`;const CALENDAR_DATE_PICKER=`.${CALENDAR_DATE_PICKER_CLASS}`;const CALENDAR_MONTH_PICKER=`.${CALENDAR_MONTH_PICKER_CLASS}`;const CALENDAR_YEAR_PICKER=`.${CALENDAR_YEAR_PICKER_CLASS}`;const CALENDAR_MONTH_FOCUSED=`.${CALENDAR_MONTH_FOCUSED_CLASS}`;const CALENDAR_YEAR_FOCUSED=`.${CALENDAR_YEAR_FOCUSED_CLASS}`;const VALIDATION_MESSAGE="Please enter a valid date";const MONTH_DATE_SEED=Array.from({length:12}).map((_,i)=>new Date(0,i));const DAY_OF_WEEK_DATE_SEED=Array.from({length:7}).map((_,i)=>new Date(0,0,i));const CALENDAR_LABELS_BY_LANG=new Map();const ENTER_KEYCODE=13;const YEAR_CHUNK=12;const DEFAULT_MIN_DATE="0000-01-01";const DEFAULT_EXTERNAL_DATE_FORMAT="MM/DD/YYYY";const INTERNAL_DATE_FORMAT="YYYY-MM-DD";const NOT_DISABLED_SELECTOR=":not([disabled])";const processFocusableSelectors=(...selectors)=>selectors.map((query)=>query+NOT_DISABLED_SELECTOR).join(", ");const DATE_PICKER_FOCUSABLE=processFocusableSelectors(CALENDAR_PREVIOUS_YEAR,CALENDAR_PREVIOUS_MONTH,CALENDAR_YEAR_SELECTION,CALENDAR_MONTH_SELECTION,CALENDAR_NEXT_YEAR,CALENDAR_NEXT_MONTH,CALENDAR_DATE_FOCUSED);const MONTH_PICKER_FOCUSABLE=processFocusableSelectors(CALENDAR_MONTH_FOCUSED);const YEAR_PICKER_FOCUSABLE=processFocusableSelectors(CALENDAR_PREVIOUS_YEAR_CHUNK,CALENDAR_NEXT_YEAR_CHUNK,CALENDAR_YEAR_FOCUSED);const keepDateWithinMonth=(dateToCheck,month)=>{if(month!==dateToCheck.getMonth())dateToCheck.setDate(0);return dateToCheck;};const setDate=(year,month,date)=>{const newDate=new Date(0);newDate.setFullYear(year,month,date);return newDate;};const today=()=>{const newDate=new Date();const day=newDate.getDate();const month=newDate.getMonth();const year=newDate.getFullYear();return setDate(year,month,day);};const startOfMonth=(date)=>{const newDate=new Date(0);newDate.setFullYear(date.getFullYear(),date.getMonth(),1);return newDate;};const lastDayOfMonth=(date)=>{const newDate=new Date(0);newDate.setFullYear(date.getFullYear(),date.getMonth()+1,0);return newDate;};const addDays=(_date,numDays)=>{const newDate=new Date(_date.getTime());newDate.setDate(newDate.getDate()+numDays);return newDate;};const subDays=(_date,numDays)=>addDays(_date,-numDays);const addWeeks=(_date,numWeeks)=>addDays(_date,numWeeks*7);const subWeeks=(_date,numWeeks)=>addWeeks(_date,-numWeeks);const startOfWeek=(_date)=>{const dayOfWeek=_date.getDay();return subDays(_date,dayOfWeek);};const endOfWeek=(_date)=>{const dayOfWeek=_date.getDay();return addDays(_date,6-dayOfWeek);};const addMonths=(_date,numMonths)=>{const newDate=new Date(_date.getTime());const dateMonth=(newDate.getMonth()+12+numMonths)%12;newDate.setMonth(newDate.getMonth()+numMonths);keepDateWithinMonth(newDate,dateMonth);return newDate;};const subMonths=(_date,numMonths)=>addMonths(_date,-numMonths);const addYears=(_date,numYears)=>addMonths(_date,numYears*12);const subYears=(_date,numYears)=>addYears(_date,-numYears);const setMonth=(_date,month)=>{const newDate=new Date(_date.getTime());newDate.setMonth(month);keepDateWithinMonth(newDate,month);return newDate;};const setYear=(_date,year)=>{const newDate=new Date(_date.getTime());const month=newDate.getMonth();newDate.setFullYear(year);keepDateWithinMonth(newDate,month);return newDate;};const min=(dateA,dateB)=>{let newDate=dateA;if(dateB{let newDate=dateA;if(dateB>dateA)newDate=dateB;return new Date(newDate.getTime());};const isSameYear=(dateA,dateB)=>dateA&&dateB&&dateA.getFullYear()===dateB.getFullYear();const isSameMonth=(dateA,dateB)=>isSameYear(dateA,dateB)&&dateA.getMonth()===dateB.getMonth();const isSameDay=(dateA,dateB)=>isSameMonth(dateA,dateB)&&dateA.getDate()===dateB.getDate();const keepDateBetweenMinAndMax=(date,minDate,maxDate)=>{let newDate=date;if(datemaxDate)newDate=maxDate;}return new Date(newDate.getTime());};const isDateWithinMinAndMax=(date,minDate,maxDate)=>date>=minDate&&(!maxDate||date<=maxDate);const isDatesMonthOutsideMinOrMax=(date,minDate,maxDate)=>lastDayOfMonth(date)maxDate;const isDatesYearOutsideMinOrMax=(date,minDate,maxDate)=>lastDayOfMonth(setMonth(date,11))maxDate;const setRangeDates=(date,rangeDate)=>{const rangeConclusionDate=date;const rangeStartDate=rangeDate&&min(rangeConclusionDate,rangeDate);const rangeEndDate=rangeDate&&max(rangeConclusionDate,rangeDate);const withinRangeStartDate=rangeDate&&addDays(rangeStartDate,1);const withinRangeEndDate=rangeDate&&subDays(rangeEndDate,1);return {rangeStartDate,rangeEndDate,withinRangeStartDate,withinRangeEndDate};};const parseDateString=(dateString,dateFormat=INTERNAL_DATE_FORMAT,adjustDate=false)=>{let date;let month;let day;let year;let parsed;if(dateString){let monthStr;let dayStr;let yearStr;if(dateFormat===DEFAULT_EXTERNAL_DATE_FORMAT)[monthStr,dayStr,yearStr]=dateString.split("/");else [yearStr,monthStr,dayStr]=dateString.split("-");if(yearStr){parsed=parseInt(yearStr,10);if(!Number.isNaN(parsed)){year=parsed;if(adjustDate){year=Math.max(0,year);if(yearStr.length<3){const currentYear=today().getFullYear();const currentYearStub=currentYear-currentYear%10**yearStr.length;year=currentYearStub+parsed;}}}}if(monthStr){parsed=parseInt(monthStr,10);if(!Number.isNaN(parsed)){month=parsed;if(adjustDate){month=Math.max(1,month);month=Math.min(12,month);}}}if(month&&dayStr&&year!=null){parsed=parseInt(dayStr,10);if(!Number.isNaN(parsed)){day=parsed;if(adjustDate){const lastDayOfTheMonth=setDate(year,month,0).getDate();day=Math.max(1,day);day=Math.min(lastDayOfTheMonth,day);}}}if(month&&day&&year!=null)date=setDate(year,month-1,day);}return date;};const formatDate=(date,dateFormat=INTERNAL_DATE_FORMAT)=>{const padZeros=(value,length)=>`0000${value}`.slice(-length);const month=date.getMonth()+1;const day=date.getDate();const year=date.getFullYear();if(dateFormat===DEFAULT_EXTERNAL_DATE_FORMAT)return [padZeros(month,2),padZeros(day,2),padZeros(year,4)].join("/");return [padZeros(year,4),padZeros(month,2),padZeros(day,2)].join("-");};const listToGridHtml=(htmlArray,rowSize)=>{const grid=[];let row=[];let i=0;while(i{tr.insertAdjacentElement("beforeend",element);});grid.push(tr);}return grid;};const createTableBody=(grid)=>{const tableBody=document.createElement("tbody");grid.forEach((element)=>{tableBody.insertAdjacentElement("beforeend",element);});return tableBody;};const changeElementValue=(el,value="")=>{const elementToChange=el;elementToChange.value=value;const event=new CustomEvent("change",{bubbles:true,cancelable:true,detail:{value}});elementToChange.dispatchEvent(event);};const getDatePickerContext=(el)=>{const datePickerEl=el.closest(DATE_PICKER);if(!datePickerEl)throw new Error(`Element is missing outer ${DATE_PICKER}`);const internalInputEl=datePickerEl.querySelector(DATE_PICKER_INTERNAL_INPUT);const externalInputEl=datePickerEl.querySelector(DATE_PICKER_EXTERNAL_INPUT);const calendarEl=datePickerEl.querySelector(DATE_PICKER_CALENDAR);const toggleBtnEl=datePickerEl.querySelector(DATE_PICKER_BUTTON);const statusEl=datePickerEl.querySelector(DATE_PICKER_STATUS);const firstYearChunkEl=datePickerEl.querySelector(CALENDAR_YEAR);const inputDate=parseDateString(externalInputEl.value,DEFAULT_EXTERNAL_DATE_FORMAT,true);const selectedDate=parseDateString(internalInputEl.value);const calendarDate=parseDateString(calendarEl.dataset.value);const minDate=parseDateString(datePickerEl.dataset.minDate);const maxDate=parseDateString(datePickerEl.dataset.maxDate);const rangeDate=parseDateString(datePickerEl.dataset.rangeDate);const defaultDate=parseDateString(datePickerEl.dataset.defaultDate);if(minDate&&maxDate&&minDate>maxDate)throw new Error("Minimum date cannot be after maximum date");const lang=document.documentElement.lang||"en";if(!CALENDAR_LABELS_BY_LANG.has(lang))CALENDAR_LABELS_BY_LANG.set(lang,{monthLabels:MONTH_DATE_SEED.map((date)=>date.toLocaleString(lang,{month:"long"})),dayOfWeeklabels:DAY_OF_WEEK_DATE_SEED.map((date)=>date.toLocaleString(lang,{weekday:"long"})),dayOfWeeksAbv:DAY_OF_WEEK_DATE_SEED.map((date)=>date.toLocaleString(lang,{weekday:"narrow"}))});const {monthLabels,dayOfWeeklabels,dayOfWeeksAbv}=CALENDAR_LABELS_BY_LANG.get(lang);return {calendarDate,minDate,toggleBtnEl,selectedDate,maxDate,firstYearChunkEl,datePickerEl,inputDate,internalInputEl,externalInputEl,calendarEl,rangeDate,defaultDate,statusEl,monthLabels,dayOfWeeklabels,dayOfWeeksAbv};};const disable=(el)=>{const {externalInputEl,toggleBtnEl}=getDatePickerContext(el);toggleBtnEl.disabled=true;externalInputEl.disabled=true;};const ariaDisable=(el)=>{const {externalInputEl,toggleBtnEl}=getDatePickerContext(el);toggleBtnEl.setAttribute("aria-disabled",true);externalInputEl.setAttribute("aria-disabled",true);externalInputEl.setAttribute("readonly","");};const enable=(el)=>{const {externalInputEl,toggleBtnEl}=getDatePickerContext(el);toggleBtnEl.disabled=false;toggleBtnEl.removeAttribute("aria-disabled");externalInputEl.disabled=false;externalInputEl.removeAttribute("aria-disabled");externalInputEl.removeAttribute("readonly");};const isDateInputInvalid=(el)=>{const {externalInputEl,minDate,maxDate}=getDatePickerContext(el);const dateString=externalInputEl.value;let isInvalid=false;if(dateString){isInvalid=true;const dateStringParts=dateString.split("/");const [month,day,year]=dateStringParts.map((str)=>{let value;const parsed=parseInt(str,10);if(!Number.isNaN(parsed))value=parsed;return value;});if(month&&day&&year!=null){const checkDate=setDate(year,month-1,day);if(checkDate.getMonth()===month-1&&checkDate.getDate()===day&&checkDate.getFullYear()===year&&dateStringParts[2].length===4&&isDateWithinMinAndMax(checkDate,minDate,maxDate))isInvalid=false;}}return isInvalid;};const validateDateInput=(el)=>{const {externalInputEl}=getDatePickerContext(el);const isInvalid=isDateInputInvalid(externalInputEl);if(isInvalid&&!externalInputEl.validationMessage)externalInputEl.setCustomValidity(VALIDATION_MESSAGE);if(!isInvalid&&externalInputEl.validationMessage===VALIDATION_MESSAGE)externalInputEl.setCustomValidity("");};const reconcileInputValues=(el)=>{const {internalInputEl,inputDate}=getDatePickerContext(el);let newValue="";if(inputDate&&!isDateInputInvalid(el))newValue=formatDate(inputDate);if(internalInputEl.value!==newValue)changeElementValue(internalInputEl,newValue);};const setCalendarValue=(el,dateString)=>{const parsedDate=parseDateString(dateString);if(parsedDate){const formattedDate=formatDate(parsedDate,DEFAULT_EXTERNAL_DATE_FORMAT);const {datePickerEl,internalInputEl,externalInputEl}=getDatePickerContext(el);changeElementValue(internalInputEl,dateString);changeElementValue(externalInputEl,formattedDate);validateDateInput(datePickerEl);}};const enhanceDatePicker=(el)=>{const datePickerEl=el.closest(DATE_PICKER);const {defaultValue}=datePickerEl.dataset;const internalInputEl=datePickerEl.querySelector(`input`);if(!internalInputEl)throw new Error(`${DATE_PICKER} is missing inner input`);if(internalInputEl.value)internalInputEl.value="";const minDate=parseDateString(datePickerEl.dataset.minDate||internalInputEl.getAttribute("min"));datePickerEl.dataset.minDate=minDate?formatDate(minDate):DEFAULT_MIN_DATE;const maxDate=parseDateString(datePickerEl.dataset.maxDate||internalInputEl.getAttribute("max"));if(maxDate)datePickerEl.dataset.maxDate=formatDate(maxDate);const calendarWrapper=document.createElement("div");calendarWrapper.classList.add(DATE_PICKER_WRAPPER_CLASS);const externalInputEl=internalInputEl.cloneNode();externalInputEl.classList.add(DATE_PICKER_EXTERNAL_INPUT_CLASS);externalInputEl.type="text";calendarWrapper.appendChild(externalInputEl);calendarWrapper.insertAdjacentHTML("beforeend",Sanitizer.escapeHTML`
`);internalInputEl.setAttribute("aria-hidden","true");internalInputEl.setAttribute("tabindex","-1");internalInputEl.style.display="none";internalInputEl.classList.add(DATE_PICKER_INTERNAL_INPUT_CLASS);internalInputEl.removeAttribute("id");internalInputEl.removeAttribute("name");internalInputEl.required=false;datePickerEl.appendChild(calendarWrapper);datePickerEl.classList.add(DATE_PICKER_INITIALIZED_CLASS);if(defaultValue)setCalendarValue(datePickerEl,defaultValue);if(internalInputEl.disabled){disable(datePickerEl);internalInputEl.disabled=false;}if(internalInputEl.hasAttribute("aria-disabled")){ariaDisable(datePickerEl);internalInputEl.removeAttribute("aria-disabled");}};const renderCalendar=(el,_dateToDisplay)=>{const {datePickerEl,calendarEl,statusEl,selectedDate,maxDate,minDate,rangeDate,monthLabels,dayOfWeeklabels,dayOfWeeksAbv}=getDatePickerContext(el);const todaysDate=today();let dateToDisplay=_dateToDisplay||todaysDate;const calendarWasHidden=calendarEl.hidden;const focusedDate=addDays(dateToDisplay,0);const focusedMonth=dateToDisplay.getMonth();const focusedYear=dateToDisplay.getFullYear();const prevMonth=subMonths(dateToDisplay,1);const nextMonth=addMonths(dateToDisplay,1);const currentFormattedDate=formatDate(dateToDisplay);const firstOfMonth=startOfMonth(dateToDisplay);const prevButtonsDisabled=isSameMonth(dateToDisplay,minDate);const nextButtonsDisabled=isSameMonth(dateToDisplay,maxDate);const {rangeStartDate,rangeEndDate,withinRangeStartDate,withinRangeEndDate}=setRangeDates(selectedDate||dateToDisplay,rangeDate);const monthLabel=monthLabels[focusedMonth];const generateDateHtml=(dateToRender)=>{const classes=[CALENDAR_DATE_CLASS];const day=dateToRender.getDate();const month=dateToRender.getMonth();const year=dateToRender.getFullYear();const dayOfWeek=dateToRender.getDay();const formattedDate=formatDate(dateToRender);let tabindex="-1";const isDisabled=!isDateWithinMinAndMax(dateToRender,minDate,maxDate);const isSelected=isSameDay(dateToRender,selectedDate);if(isSameMonth(dateToRender,prevMonth))classes.push(CALENDAR_DATE_PREVIOUS_MONTH_CLASS);if(isSameMonth(dateToRender,focusedDate))classes.push(CALENDAR_DATE_CURRENT_MONTH_CLASS);if(isSameMonth(dateToRender,nextMonth))classes.push(CALENDAR_DATE_NEXT_MONTH_CLASS);if(isSelected)classes.push(CALENDAR_DATE_SELECTED_CLASS);if(isSameDay(dateToRender,todaysDate))classes.push(CALENDAR_DATE_TODAY_CLASS);if(rangeDate){if(isSameDay(dateToRender,rangeDate))classes.push(CALENDAR_DATE_RANGE_DATE_CLASS);if(isSameDay(dateToRender,rangeStartDate))classes.push(CALENDAR_DATE_RANGE_DATE_START_CLASS);if(isSameDay(dateToRender,rangeEndDate))classes.push(CALENDAR_DATE_RANGE_DATE_END_CLASS);if(isDateWithinMinAndMax(dateToRender,withinRangeStartDate,withinRangeEndDate))classes.push(CALENDAR_DATE_WITHIN_RANGE_CLASS);}if(isSameDay(dateToRender,focusedDate)){tabindex="0";classes.push(CALENDAR_DATE_FOCUSED_CLASS);}const monthStr=monthLabels[month];const dayStr=dayOfWeeklabels[dayOfWeek];const btn=document.createElement("button");btn.setAttribute("type","button");btn.setAttribute("tabindex",tabindex);btn.setAttribute("class",classes.join(" "));btn.setAttribute("data-day",day);btn.setAttribute("data-month",month+1);btn.setAttribute("data-year",year);btn.setAttribute("data-value",formattedDate);btn.setAttribute("aria-label",Sanitizer.escapeHTML`${day} ${monthStr} ${year} ${dayStr}`);btn.setAttribute("aria-selected",isSelected?"true":"false");if(isDisabled===true)btn.disabled=true;btn.textContent=day;return btn;};dateToDisplay=startOfWeek(firstOfMonth);const days=[];while(days.length<28||dateToDisplay.getMonth()===focusedMonth||days.length%7!==0){days.push(generateDateHtml(dateToDisplay));dateToDisplay=addDays(dateToDisplay,1);}const datesGrid=listToGridHtml(days,7);const newCalendar=calendarEl.cloneNode();newCalendar.dataset.value=currentFormattedDate;newCalendar.style.top=`${datePickerEl.offsetHeight}px`;newCalendar.hidden=false;newCalendar.innerHTML=Sanitizer.escapeHTML`
`;const table=document.createElement("table");table.setAttribute("class",CALENDAR_TABLE_CLASS);const tableHead=document.createElement("thead");table.insertAdjacentElement("beforeend",tableHead);const tableHeadRow=document.createElement("tr");tableHead.insertAdjacentElement("beforeend",tableHeadRow);dayOfWeeklabels.forEach((dayOfWeek,i)=>{const th=document.createElement("th");th.setAttribute("class",CALENDAR_DAY_OF_WEEK_CLASS);th.setAttribute("scope","col");th.setAttribute("aria-label",dayOfWeek);th.textContent=dayOfWeeksAbv[i];tableHeadRow.insertAdjacentElement("beforeend",th);});const tableBody=createTableBody(datesGrid);table.insertAdjacentElement("beforeend",tableBody);const datePickerCalendarContainer=newCalendar.querySelector(CALENDAR_DATE_PICKER);datePickerCalendarContainer.insertAdjacentElement("beforeend",table);calendarEl.parentNode.replaceChild(newCalendar,calendarEl);datePickerEl.classList.add(DATE_PICKER_ACTIVE_CLASS);const statuses=[];if(isSameDay(selectedDate,focusedDate))statuses.push("Selected date");if(calendarWasHidden){statuses.push("You can navigate by day using left and right arrows","Weeks by using up and down arrows","Months by using page up and page down keys","Years by using shift plus page up and shift plus page down","Home and end keys navigate to the beginning and end of a week");statusEl.textContent="";}else statuses.push(`${monthLabel} ${focusedYear}`);statusEl.textContent=statuses.join(". ");return newCalendar;};const displayPreviousYear=(_buttonEl)=>{if(_buttonEl.disabled)return;const {calendarEl,calendarDate,minDate,maxDate}=getDatePickerContext(_buttonEl);let date=subYears(calendarDate,1);date=keepDateBetweenMinAndMax(date,minDate,maxDate);const newCalendar=renderCalendar(calendarEl,date);let nextToFocus=newCalendar.querySelector(CALENDAR_PREVIOUS_YEAR);if(nextToFocus.disabled)nextToFocus=newCalendar.querySelector(CALENDAR_DATE_PICKER);nextToFocus.focus();};const displayPreviousMonth=(_buttonEl)=>{if(_buttonEl.disabled)return;const {calendarEl,calendarDate,minDate,maxDate}=getDatePickerContext(_buttonEl);let date=subMonths(calendarDate,1);date=keepDateBetweenMinAndMax(date,minDate,maxDate);const newCalendar=renderCalendar(calendarEl,date);let nextToFocus=newCalendar.querySelector(CALENDAR_PREVIOUS_MONTH);if(nextToFocus.disabled)nextToFocus=newCalendar.querySelector(CALENDAR_DATE_PICKER);nextToFocus.focus();};const displayNextMonth=(_buttonEl)=>{if(_buttonEl.disabled)return;const {calendarEl,calendarDate,minDate,maxDate}=getDatePickerContext(_buttonEl);let date=addMonths(calendarDate,1);date=keepDateBetweenMinAndMax(date,minDate,maxDate);const newCalendar=renderCalendar(calendarEl,date);let nextToFocus=newCalendar.querySelector(CALENDAR_NEXT_MONTH);if(nextToFocus.disabled)nextToFocus=newCalendar.querySelector(CALENDAR_DATE_PICKER);nextToFocus.focus();};const displayNextYear=(_buttonEl)=>{if(_buttonEl.disabled)return;const {calendarEl,calendarDate,minDate,maxDate}=getDatePickerContext(_buttonEl);let date=addYears(calendarDate,1);date=keepDateBetweenMinAndMax(date,minDate,maxDate);const newCalendar=renderCalendar(calendarEl,date);let nextToFocus=newCalendar.querySelector(CALENDAR_NEXT_YEAR);if(nextToFocus.disabled)nextToFocus=newCalendar.querySelector(CALENDAR_DATE_PICKER);nextToFocus.focus();};const hideCalendar=(el)=>{const {datePickerEl,calendarEl,statusEl}=getDatePickerContext(el);datePickerEl.classList.remove(DATE_PICKER_ACTIVE_CLASS);calendarEl.hidden=true;statusEl.textContent="";};const selectDate=(calendarDateEl)=>{if(calendarDateEl.disabled)return;const {datePickerEl,externalInputEl}=getDatePickerContext(calendarDateEl);setCalendarValue(calendarDateEl,calendarDateEl.dataset.value);hideCalendar(datePickerEl);externalInputEl.focus();};const toggleCalendar=(el)=>{if(el.disabled||el.hasAttribute("aria-disabled"))return;const {calendarEl,inputDate,minDate,maxDate,defaultDate}=getDatePickerContext(el);if(calendarEl.hidden){const dateToDisplay=keepDateBetweenMinAndMax(inputDate||defaultDate||today(),minDate,maxDate);const newCalendar=renderCalendar(calendarEl,dateToDisplay);newCalendar.querySelector(CALENDAR_DATE_FOCUSED).focus();}else hideCalendar(el);};const updateCalendarIfVisible=(el)=>{const {calendarEl,inputDate,minDate,maxDate}=getDatePickerContext(el);const calendarShown=!calendarEl.hidden;if(calendarShown&&inputDate){const dateToDisplay=keepDateBetweenMinAndMax(inputDate,minDate,maxDate);renderCalendar(calendarEl,dateToDisplay);}};const displayMonthSelection=(el,monthToDisplay)=>{const {calendarEl,statusEl,calendarDate,minDate,maxDate,monthLabels}=getDatePickerContext(el);const selectedMonth=calendarDate.getMonth();const focusedMonth=monthToDisplay==null?selectedMonth:monthToDisplay;const months=monthLabels.map((month,index)=>{const monthToCheck=setMonth(calendarDate,index);const isDisabled=isDatesMonthOutsideMinOrMax(monthToCheck,minDate,maxDate);let tabindex="-1";const classes=[CALENDAR_MONTH_CLASS];const isSelected=index===selectedMonth;if(index===focusedMonth){tabindex="0";classes.push(CALENDAR_MONTH_FOCUSED_CLASS);}if(isSelected)classes.push(CALENDAR_MONTH_SELECTED_CLASS);const btn=document.createElement("button");btn.setAttribute("type","button");btn.setAttribute("tabindex",tabindex);btn.setAttribute("class",classes.join(" "));btn.setAttribute("data-value",index);btn.setAttribute("data-label",month);btn.setAttribute("aria-selected",isSelected?"true":"false");if(isDisabled===true)btn.disabled=true;btn.textContent=month;return btn;});const monthsHtml=document.createElement("div");monthsHtml.setAttribute("tabindex","-1");monthsHtml.setAttribute("class",CALENDAR_MONTH_PICKER_CLASS);const table=document.createElement("table");table.setAttribute("class",CALENDAR_TABLE_CLASS);table.setAttribute("role","presentation");const monthsGrid=listToGridHtml(months,3);const tableBody=createTableBody(monthsGrid);table.insertAdjacentElement("beforeend",tableBody);monthsHtml.insertAdjacentElement("beforeend",table);const newCalendar=calendarEl.cloneNode();newCalendar.insertAdjacentElement("beforeend",monthsHtml);calendarEl.parentNode.replaceChild(newCalendar,calendarEl);statusEl.textContent="Select a month.";return newCalendar;};const selectMonth=(monthEl)=>{if(monthEl.disabled)return;const {calendarEl,calendarDate,minDate,maxDate}=getDatePickerContext(monthEl);const selectedMonth=parseInt(monthEl.dataset.value,10);let date=setMonth(calendarDate,selectedMonth);date=keepDateBetweenMinAndMax(date,minDate,maxDate);const newCalendar=renderCalendar(calendarEl,date);newCalendar.querySelector(CALENDAR_DATE_FOCUSED).focus();};const displayYearSelection=(el,yearToDisplay)=>{const {calendarEl,statusEl,calendarDate,minDate,maxDate}=getDatePickerContext(el);const selectedYear=calendarDate.getFullYear();const focusedYear=yearToDisplay==null?selectedYear:yearToDisplay;let yearToChunk=focusedYear;yearToChunk-=yearToChunk%YEAR_CHUNK;yearToChunk=Math.max(0,yearToChunk);const prevYearChunkDisabled=isDatesYearOutsideMinOrMax(setYear(calendarDate,yearToChunk-1),minDate,maxDate);const nextYearChunkDisabled=isDatesYearOutsideMinOrMax(setYear(calendarDate,yearToChunk+YEAR_CHUNK),minDate,maxDate);const years=[];let yearIndex=yearToChunk;while(years.length{if(el.disabled)return;const {calendarEl,calendarDate,minDate,maxDate}=getDatePickerContext(el);const yearEl=calendarEl.querySelector(CALENDAR_YEAR_FOCUSED);const selectedYear=parseInt(yearEl.textContent,10);let adjustedYear=selectedYear-YEAR_CHUNK;adjustedYear=Math.max(0,adjustedYear);const date=setYear(calendarDate,adjustedYear);const cappedDate=keepDateBetweenMinAndMax(date,minDate,maxDate);const newCalendar=displayYearSelection(calendarEl,cappedDate.getFullYear());let nextToFocus=newCalendar.querySelector(CALENDAR_PREVIOUS_YEAR_CHUNK);if(nextToFocus.disabled)nextToFocus=newCalendar.querySelector(CALENDAR_YEAR_PICKER);nextToFocus.focus();};const displayNextYearChunk=(el)=>{if(el.disabled)return;const {calendarEl,calendarDate,minDate,maxDate}=getDatePickerContext(el);const yearEl=calendarEl.querySelector(CALENDAR_YEAR_FOCUSED);const selectedYear=parseInt(yearEl.textContent,10);let adjustedYear=selectedYear+YEAR_CHUNK;adjustedYear=Math.max(0,adjustedYear);const date=setYear(calendarDate,adjustedYear);const cappedDate=keepDateBetweenMinAndMax(date,minDate,maxDate);const newCalendar=displayYearSelection(calendarEl,cappedDate.getFullYear());let nextToFocus=newCalendar.querySelector(CALENDAR_NEXT_YEAR_CHUNK);if(nextToFocus.disabled)nextToFocus=newCalendar.querySelector(CALENDAR_YEAR_PICKER);nextToFocus.focus();};const selectYear=(yearEl)=>{if(yearEl.disabled)return;const {calendarEl,calendarDate,minDate,maxDate}=getDatePickerContext(yearEl);const selectedYear=parseInt(yearEl.innerHTML,10);let date=setYear(calendarDate,selectedYear);date=keepDateBetweenMinAndMax(date,minDate,maxDate);const newCalendar=renderCalendar(calendarEl,date);newCalendar.querySelector(CALENDAR_DATE_FOCUSED).focus();};const handleEscapeFromCalendar=(event)=>{const {datePickerEl,externalInputEl}=getDatePickerContext(event.target);hideCalendar(datePickerEl);externalInputEl.focus();event.preventDefault();};const adjustCalendar=(adjustDateFn)=>(event)=>{const {calendarEl,calendarDate,minDate,maxDate}=getDatePickerContext(event.target);const date=adjustDateFn(calendarDate);const cappedDate=keepDateBetweenMinAndMax(date,minDate,maxDate);if(!isSameDay(calendarDate,cappedDate)){const newCalendar=renderCalendar(calendarEl,cappedDate);newCalendar.querySelector(CALENDAR_DATE_FOCUSED).focus();}event.preventDefault();};const handleUpFromDate=adjustCalendar((date)=>subWeeks(date,1));const handleDownFromDate=adjustCalendar((date)=>addWeeks(date,1));const handleLeftFromDate=adjustCalendar((date)=>subDays(date,1));const handleRightFromDate=adjustCalendar((date)=>addDays(date,1));const handleHomeFromDate=adjustCalendar((date)=>startOfWeek(date));const handleEndFromDate=adjustCalendar((date)=>endOfWeek(date));const handlePageDownFromDate=adjustCalendar((date)=>addMonths(date,1));const handlePageUpFromDate=adjustCalendar((date)=>subMonths(date,1));const handleShiftPageDownFromDate=adjustCalendar((date)=>addYears(date,1));const handleShiftPageUpFromDate=adjustCalendar((date)=>subYears(date,1));const handleMouseoverFromDate=(dateEl)=>{if(dateEl.disabled)return;const hoverDate=parseDateString(dateEl.dataset.value);const {calendarEl,selectedDate,rangeDate}=getDatePickerContext(dateEl);if(selectedDate)return;const {withinRangeStartDate,withinRangeEndDate}=setRangeDates(hoverDate,rangeDate);const dateButtons=calendarEl.querySelectorAll(`.${CALENDAR_DATE_CURRENT_MONTH_CLASS}`);dateButtons.forEach((button)=>{const buttonDate=parseDateString(button.dataset.value);if(isDateWithinMinAndMax(buttonDate,withinRangeStartDate,withinRangeEndDate))button.classList.add(CALENDAR_DATE_WITHIN_RANGE_CLASS);else button.classList.remove(CALENDAR_DATE_WITHIN_RANGE_CLASS);});};const adjustMonthSelectionScreen=(adjustMonthFn)=>(event)=>{const monthEl=event.target;const selectedMonth=parseInt(monthEl.dataset.value,10);const {calendarEl,calendarDate,minDate,maxDate}=getDatePickerContext(monthEl);const currentDate=setMonth(calendarDate,selectedMonth);let adjustedMonth=adjustMonthFn(selectedMonth);adjustedMonth=Math.max(0,Math.min(11,adjustedMonth));const date=setMonth(calendarDate,adjustedMonth);const cappedDate=keepDateBetweenMinAndMax(date,minDate,maxDate);if(!isSameMonth(currentDate,cappedDate)){const newCalendar=displayMonthSelection(calendarEl,cappedDate.getMonth());newCalendar.querySelector(CALENDAR_MONTH_FOCUSED).focus();}event.preventDefault();};const handleUpFromMonth=adjustMonthSelectionScreen((month)=>month-3);const handleDownFromMonth=adjustMonthSelectionScreen((month)=>month+3);const handleLeftFromMonth=adjustMonthSelectionScreen((month)=>month-1);const handleRightFromMonth=adjustMonthSelectionScreen((month)=>month+1);const handleHomeFromMonth=adjustMonthSelectionScreen((month)=>month-month%3);const handleEndFromMonth=adjustMonthSelectionScreen((month)=>month+2-month%3);const handlePageDownFromMonth=adjustMonthSelectionScreen(()=>11);const handlePageUpFromMonth=adjustMonthSelectionScreen(()=>0);const adjustYearSelectionScreen=(adjustYearFn)=>(event)=>{const yearEl=event.target;const selectedYear=parseInt(yearEl.dataset.value,10);const {calendarEl,calendarDate,minDate,maxDate}=getDatePickerContext(yearEl);const currentDate=setYear(calendarDate,selectedYear);let adjustedYear=adjustYearFn(selectedYear);adjustedYear=Math.max(0,adjustedYear);const date=setYear(calendarDate,adjustedYear);const cappedDate=keepDateBetweenMinAndMax(date,minDate,maxDate);if(!isSameYear(currentDate,cappedDate)){const newCalendar=displayYearSelection(calendarEl,cappedDate.getFullYear());newCalendar.querySelector(CALENDAR_YEAR_FOCUSED).focus();}event.preventDefault();};const handleUpFromYear=adjustYearSelectionScreen((year)=>year-3);const handleDownFromYear=adjustYearSelectionScreen((year)=>year+3);const handleLeftFromYear=adjustYearSelectionScreen((year)=>year-1);const handleRightFromYear=adjustYearSelectionScreen((year)=>year+1);const handleHomeFromYear=adjustYearSelectionScreen((year)=>year-year%3);const handleEndFromYear=adjustYearSelectionScreen((year)=>year+2-year%3);const handlePageUpFromYear=adjustYearSelectionScreen((year)=>year-YEAR_CHUNK);const handlePageDownFromYear=adjustYearSelectionScreen((year)=>year+YEAR_CHUNK);const tabHandler=(focusable)=>{const getFocusableContext=(el)=>{const {calendarEl}=getDatePickerContext(el);const focusableElements=select(focusable,calendarEl);const firstTabIndex=0;const lastTabIndex=focusableElements.length-1;const firstTabStop=focusableElements[firstTabIndex];const lastTabStop=focusableElements[lastTabIndex];const focusIndex=focusableElements.indexOf(activeElement());const isLastTab=focusIndex===lastTabIndex;const isFirstTab=focusIndex===firstTabIndex;const isNotFound=focusIndex===-1;return {focusableElements,isNotFound,firstTabStop,isFirstTab,lastTabStop,isLastTab};};return {tabAhead(event){const {firstTabStop,isLastTab,isNotFound}=getFocusableContext(event.target);if(isLastTab||isNotFound){event.preventDefault();firstTabStop.focus();}},tabBack(event){const {lastTabStop,isFirstTab,isNotFound}=getFocusableContext(event.target);if(isFirstTab||isNotFound){event.preventDefault();lastTabStop.focus();}}};};const datePickerTabEventHandler=tabHandler(DATE_PICKER_FOCUSABLE);const monthPickerTabEventHandler=tabHandler(MONTH_PICKER_FOCUSABLE);const yearPickerTabEventHandler=tabHandler(YEAR_PICKER_FOCUSABLE);const datePickerEvents={[CLICK]:{[DATE_PICKER_BUTTON](){toggleCalendar(this);},[CALENDAR_DATE](){selectDate(this);},[CALENDAR_MONTH](){selectMonth(this);},[CALENDAR_YEAR](){selectYear(this);},[CALENDAR_PREVIOUS_MONTH](){displayPreviousMonth(this);},[CALENDAR_NEXT_MONTH](){displayNextMonth(this);},[CALENDAR_PREVIOUS_YEAR](){displayPreviousYear(this);},[CALENDAR_NEXT_YEAR](){displayNextYear(this);},[CALENDAR_PREVIOUS_YEAR_CHUNK](){displayPreviousYearChunk(this);},[CALENDAR_NEXT_YEAR_CHUNK](){displayNextYearChunk(this);},[CALENDAR_MONTH_SELECTION](){const newCalendar=displayMonthSelection(this);newCalendar.querySelector(CALENDAR_MONTH_FOCUSED).focus();},[CALENDAR_YEAR_SELECTION](){const newCalendar=displayYearSelection(this);newCalendar.querySelector(CALENDAR_YEAR_FOCUSED).focus();}},keyup:{[DATE_PICKER_CALENDAR](event){const keydown=this.dataset.keydownKeyCode;if(`${event.keyCode}`!==keydown)event.preventDefault();}},keydown:{[DATE_PICKER_EXTERNAL_INPUT](event){if(event.keyCode===ENTER_KEYCODE)validateDateInput(this);},[CALENDAR_DATE]:keymap({Up:handleUpFromDate,ArrowUp:handleUpFromDate,Down:handleDownFromDate,ArrowDown:handleDownFromDate,Left:handleLeftFromDate,ArrowLeft:handleLeftFromDate,Right:handleRightFromDate,ArrowRight:handleRightFromDate,Home:handleHomeFromDate,End:handleEndFromDate,PageDown:handlePageDownFromDate,PageUp:handlePageUpFromDate,"Shift+PageDown":handleShiftPageDownFromDate,"Shift+PageUp":handleShiftPageUpFromDate,Tab:datePickerTabEventHandler.tabAhead}),[CALENDAR_DATE_PICKER]:keymap({Tab:datePickerTabEventHandler.tabAhead,"Shift+Tab":datePickerTabEventHandler.tabBack}),[CALENDAR_MONTH]:keymap({Up:handleUpFromMonth,ArrowUp:handleUpFromMonth,Down:handleDownFromMonth,ArrowDown:handleDownFromMonth,Left:handleLeftFromMonth,ArrowLeft:handleLeftFromMonth,Right:handleRightFromMonth,ArrowRight:handleRightFromMonth,Home:handleHomeFromMonth,End:handleEndFromMonth,PageDown:handlePageDownFromMonth,PageUp:handlePageUpFromMonth}),[CALENDAR_MONTH_PICKER]:keymap({Tab:monthPickerTabEventHandler.tabAhead,"Shift+Tab":monthPickerTabEventHandler.tabBack}),[CALENDAR_YEAR]:keymap({Up:handleUpFromYear,ArrowUp:handleUpFromYear,Down:handleDownFromYear,ArrowDown:handleDownFromYear,Left:handleLeftFromYear,ArrowLeft:handleLeftFromYear,Right:handleRightFromYear,ArrowRight:handleRightFromYear,Home:handleHomeFromYear,End:handleEndFromYear,PageDown:handlePageDownFromYear,PageUp:handlePageUpFromYear}),[CALENDAR_YEAR_PICKER]:keymap({Tab:yearPickerTabEventHandler.tabAhead,"Shift+Tab":yearPickerTabEventHandler.tabBack}),[DATE_PICKER_CALENDAR](event){this.dataset.keydownKeyCode=event.keyCode;},[DATE_PICKER](event){const keyMap=keymap({Escape:handleEscapeFromCalendar});keyMap(event);}},focusout:{[DATE_PICKER_EXTERNAL_INPUT](){validateDateInput(this);},[DATE_PICKER](event){if(!this.contains(event.relatedTarget))hideCalendar(this);}},input:{[DATE_PICKER_EXTERNAL_INPUT](){reconcileInputValues(this);updateCalendarIfVisible(this);}}};if(!isIosDevice())datePickerEvents.mouseover={[CALENDAR_DATE_CURRENT_MONTH](){handleMouseoverFromDate(this);}};const datePicker=behavior(datePickerEvents,{init(root){selectOrMatches(DATE_PICKER,root).forEach((datePickerEl)=>{enhanceDatePicker(datePickerEl);});},getDatePickerContext,disable,ariaDisable,enable,isDateInputInvalid,setCalendarValue,validateDateInput,renderCalendar,updateCalendarIfVisible});module.exports=datePicker;},{"../../uswds-core/src/js/config":34,"../../uswds-core/src/js/events":35,"../../uswds-core/src/js/utils/active-element":38,"../../uswds-core/src/js/utils/behavior":39,"../../uswds-core/src/js/utils/is-ios-device":43,"../../uswds-core/src/js/utils/sanitizer":44,"../../uswds-core/src/js/utils/select":47,"../../uswds-core/src/js/utils/select-or-matches":46,"receptor/keymap":10}],19:[function(require,module,exports){"use strict";const behavior=require("../../uswds-core/src/js/utils/behavior");const select=require("../../uswds-core/src/js/utils/select");const selectOrMatches=require("../../uswds-core/src/js/utils/select-or-matches");const {prefix:PREFIX}=require("../../uswds-core/src/js/config");const {getDatePickerContext,isDateInputInvalid,updateCalendarIfVisible}=require("../../usa-date-picker/src/index");const DATE_PICKER_CLASS=`${PREFIX}-date-picker`;const DATE_RANGE_PICKER_CLASS=`${PREFIX}-date-range-picker`;const DATE_RANGE_PICKER_RANGE_START_CLASS=`${DATE_RANGE_PICKER_CLASS}__range-start`;const DATE_RANGE_PICKER_RANGE_END_CLASS=`${DATE_RANGE_PICKER_CLASS}__range-end`;const DATE_PICKER=`.${DATE_PICKER_CLASS}`;const DATE_RANGE_PICKER=`.${DATE_RANGE_PICKER_CLASS}`;const DATE_RANGE_PICKER_RANGE_START=`.${DATE_RANGE_PICKER_RANGE_START_CLASS}`;const DATE_RANGE_PICKER_RANGE_END=`.${DATE_RANGE_PICKER_RANGE_END_CLASS}`;const DEFAULT_MIN_DATE="0000-01-01";const getDateRangePickerContext=(el)=>{const dateRangePickerEl=el.closest(DATE_RANGE_PICKER);if(!dateRangePickerEl)throw new Error(`Element is missing outer ${DATE_RANGE_PICKER}`);const rangeStartEl=dateRangePickerEl.querySelector(DATE_RANGE_PICKER_RANGE_START);const rangeEndEl=dateRangePickerEl.querySelector(DATE_RANGE_PICKER_RANGE_END);return {dateRangePickerEl,rangeStartEl,rangeEndEl};};const handleRangeStartUpdate=(el)=>{const {dateRangePickerEl,rangeStartEl,rangeEndEl}=getDateRangePickerContext(el);const {internalInputEl}=getDatePickerContext(rangeStartEl);const updatedDate=internalInputEl.value;if(updatedDate&&!isDateInputInvalid(internalInputEl)){rangeEndEl.dataset.minDate=updatedDate;rangeEndEl.dataset.rangeDate=updatedDate;rangeEndEl.dataset.defaultDate=updatedDate;}else{rangeEndEl.dataset.minDate=dateRangePickerEl.dataset.minDate||"";rangeEndEl.dataset.rangeDate="";rangeEndEl.dataset.defaultDate="";}updateCalendarIfVisible(rangeEndEl);};const handleRangeEndUpdate=(el)=>{const {dateRangePickerEl,rangeStartEl,rangeEndEl}=getDateRangePickerContext(el);const {internalInputEl}=getDatePickerContext(rangeEndEl);const updatedDate=internalInputEl.value;if(updatedDate&&!isDateInputInvalid(internalInputEl)){rangeStartEl.dataset.maxDate=updatedDate;rangeStartEl.dataset.rangeDate=updatedDate;rangeStartEl.dataset.defaultDate=updatedDate;}else{rangeStartEl.dataset.maxDate=dateRangePickerEl.dataset.maxDate||"";rangeStartEl.dataset.rangeDate="";rangeStartEl.dataset.defaultDate="";}updateCalendarIfVisible(rangeStartEl);};const enhanceDateRangePicker=(el)=>{const dateRangePickerEl=el.closest(DATE_RANGE_PICKER);const [rangeStart,rangeEnd]=select(DATE_PICKER,dateRangePickerEl);if(!rangeStart)throw new Error(`${DATE_RANGE_PICKER} is missing inner two '${DATE_PICKER}' elements`);if(!rangeEnd)throw new Error(`${DATE_RANGE_PICKER} is missing second '${DATE_PICKER}' element`);rangeStart.classList.add(DATE_RANGE_PICKER_RANGE_START_CLASS);rangeEnd.classList.add(DATE_RANGE_PICKER_RANGE_END_CLASS);if(!dateRangePickerEl.dataset.minDate)dateRangePickerEl.dataset.minDate=DEFAULT_MIN_DATE;const {minDate}=dateRangePickerEl.dataset;rangeStart.dataset.minDate=minDate;rangeEnd.dataset.minDate=minDate;const {maxDate}=dateRangePickerEl.dataset;if(maxDate){rangeStart.dataset.maxDate=maxDate;rangeEnd.dataset.maxDate=maxDate;}handleRangeStartUpdate(dateRangePickerEl);handleRangeEndUpdate(dateRangePickerEl);};const dateRangePicker=behavior({"input change":{[DATE_RANGE_PICKER_RANGE_START](){handleRangeStartUpdate(this);},[DATE_RANGE_PICKER_RANGE_END](){handleRangeEndUpdate(this);}}},{init(root){selectOrMatches(DATE_RANGE_PICKER,root).forEach((dateRangePickerEl)=>{enhanceDateRangePicker(dateRangePickerEl);});}});module.exports=dateRangePicker;},{"../../usa-date-picker/src/index":18,"../../uswds-core/src/js/config":34,"../../uswds-core/src/js/utils/behavior":39,"../../uswds-core/src/js/utils/select":47,"../../uswds-core/src/js/utils/select-or-matches":46}],20:[function(require,module,exports){"use strict";const selectOrMatches=require("../../uswds-core/src/js/utils/select-or-matches");const behavior=require("../../uswds-core/src/js/utils/behavior");const Sanitizer=require("../../uswds-core/src/js/utils/sanitizer");const {prefix:PREFIX}=require("../../uswds-core/src/js/config");const DROPZONE_CLASS=`${PREFIX}-file-input`;const DROPZONE=`.${DROPZONE_CLASS}`;const INPUT_CLASS=`${PREFIX}-file-input__input`;const TARGET_CLASS=`${PREFIX}-file-input__target`;const INPUT=`.${INPUT_CLASS}`;const BOX_CLASS=`${PREFIX}-file-input__box`;const INSTRUCTIONS_CLASS=`${PREFIX}-file-input__instructions`;const PREVIEW_CLASS=`${PREFIX}-file-input__preview`;const PREVIEW_HEADING_CLASS=`${PREFIX}-file-input__preview-heading`;const DISABLED_CLASS=`${PREFIX}-file-input--disabled`;const CHOOSE_CLASS=`${PREFIX}-file-input__choose`;const ACCEPTED_FILE_MESSAGE_CLASS=`${PREFIX}-file-input__accepted-files-message`;const DRAG_TEXT_CLASS=`${PREFIX}-file-input__drag-text`;const DRAG_CLASS=`${PREFIX}-file-input--drag`;const LOADING_CLASS="is-loading";const INVALID_FILE_CLASS="has-invalid-file";const GENERIC_PREVIEW_CLASS_NAME=`${PREFIX}-file-input__preview-image`;const GENERIC_PREVIEW_CLASS=`${GENERIC_PREVIEW_CLASS_NAME}--generic`;const PDF_PREVIEW_CLASS=`${GENERIC_PREVIEW_CLASS_NAME}--pdf`;const WORD_PREVIEW_CLASS=`${GENERIC_PREVIEW_CLASS_NAME}--word`;const VIDEO_PREVIEW_CLASS=`${GENERIC_PREVIEW_CLASS_NAME}--video`;const EXCEL_PREVIEW_CLASS=`${GENERIC_PREVIEW_CLASS_NAME}--excel`;const SR_ONLY_CLASS=`${PREFIX}-sr-only`;const SPACER_GIF="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";const DEFAULT_ERROR_LABEL_TEXT="Error: This is not a valid file type.";let TYPE_IS_VALID=Boolean(true);let DEFAULT_ARIA_LABEL_TEXT="";let DEFAULT_FILE_STATUS_TEXT="";const getFileInputContext=(el)=>{const dropZoneEl=el.closest(DROPZONE);if(!dropZoneEl)throw new Error(`Element is missing outer ${DROPZONE}`);const inputEl=dropZoneEl.querySelector(INPUT);return {dropZoneEl,inputEl};};const disable=(el)=>{const {dropZoneEl,inputEl}=getFileInputContext(el);inputEl.disabled=true;dropZoneEl.classList.add(DISABLED_CLASS);};const ariaDisable=(el)=>{const {dropZoneEl}=getFileInputContext(el);dropZoneEl.classList.add(DISABLED_CLASS);};const enable=(el)=>{const {dropZoneEl,inputEl}=getFileInputContext(el);inputEl.disabled=false;dropZoneEl.classList.remove(DISABLED_CLASS);dropZoneEl.removeAttribute("aria-disabled");};const replaceName=(s)=>{const c=s.charCodeAt(0);if(c===32)return "-";if(c>=65&&c<=90)return `img_${s.toLowerCase()}`;return `__${("000",c.toString(16)).slice(-4)}`;};const makeSafeForID=(name)=>name.replace(/[^a-z0-9]/g,replaceName);const createUniqueID=(name)=>`${name}-${Math.floor(Date.now().toString()/1000)}`;const getItemsLabel=(fileInputEl)=>{const acceptsMultiple=fileInputEl.hasAttribute("multiple");const itemsLabel=acceptsMultiple?"files":"file";return itemsLabel;};const createTargetArea=(fileInputEl)=>{const fileInputParent=document.createElement("div");const dropTarget=document.createElement("div");const box=document.createElement("div");fileInputEl.classList.remove(DROPZONE_CLASS);fileInputEl.classList.add(INPUT_CLASS);fileInputParent.classList.add(DROPZONE_CLASS);box.classList.add(BOX_CLASS);dropTarget.classList.add(TARGET_CLASS);dropTarget.prepend(box);fileInputEl.parentNode.insertBefore(dropTarget,fileInputEl);fileInputEl.parentNode.insertBefore(fileInputParent,dropTarget);dropTarget.appendChild(fileInputEl);fileInputParent.appendChild(dropTarget);return dropTarget;};const createVisibleInstructions=(fileInputEl)=>{const fileInputParent=fileInputEl.closest(DROPZONE);const itemsLabel=getItemsLabel(fileInputEl);const instructions=document.createElement("div");const dragText=`Drag ${itemsLabel} here or`;const chooseText="choose from folder";DEFAULT_ARIA_LABEL_TEXT=`${dragText} ${chooseText}`;instructions.classList.add(INSTRUCTIONS_CLASS);instructions.setAttribute("aria-hidden","true");fileInputEl.setAttribute("aria-label",DEFAULT_ARIA_LABEL_TEXT);instructions.innerHTML=Sanitizer.escapeHTML`${dragText} ${chooseText}`;fileInputEl.parentNode.insertBefore(instructions,fileInputEl);if(/rv:11.0/i.test(navigator.userAgent)||/Edge\/\d./i.test(navigator.userAgent))fileInputParent.querySelector(`.${DRAG_TEXT_CLASS}`).outerHTML="";return instructions;};const createSROnlyStatus=(fileInputEl)=>{const statusEl=document.createElement("div");const itemsLabel=getItemsLabel(fileInputEl);const fileInputParent=fileInputEl.closest(DROPZONE);const fileInputTarget=fileInputEl.closest(`.${TARGET_CLASS}`);DEFAULT_FILE_STATUS_TEXT=`No ${itemsLabel} selected.`;statusEl.classList.add(SR_ONLY_CLASS);statusEl.setAttribute("aria-live","polite");statusEl.textContent=DEFAULT_FILE_STATUS_TEXT;fileInputParent.insertBefore(statusEl,fileInputTarget);};const enhanceFileInput=(fileInputEl)=>{const isInputDisabled=fileInputEl.hasAttribute("aria-disabled")||fileInputEl.hasAttribute("disabled");const dropTarget=createTargetArea(fileInputEl);const instructions=createVisibleInstructions(fileInputEl);const {dropZoneEl}=getFileInputContext(fileInputEl);if(isInputDisabled)dropZoneEl.classList.add(DISABLED_CLASS);else createSROnlyStatus(fileInputEl);return {instructions,dropTarget};};const removeOldPreviews=(dropTarget,instructions)=>{const filePreviews=dropTarget.querySelectorAll(`.${PREVIEW_CLASS}`);const currentPreviewHeading=dropTarget.querySelector(`.${PREVIEW_HEADING_CLASS}`);const currentErrorMessage=dropTarget.querySelector(`.${ACCEPTED_FILE_MESSAGE_CLASS}`);const removeImages=(node)=>{node.parentNode.removeChild(node);};if(currentPreviewHeading)currentPreviewHeading.outerHTML="";if(currentErrorMessage){currentErrorMessage.outerHTML="";dropTarget.classList.remove(INVALID_FILE_CLASS);}if(filePreviews!==null){if(instructions)instructions.removeAttribute("hidden");Array.prototype.forEach.call(filePreviews,removeImages);}};const updateStatusMessage=(statusElement,fileNames,fileStore)=>{const statusEl=statusElement;let statusMessage=DEFAULT_FILE_STATUS_TEXT;if(fileNames.length===1)statusMessage=`You have selected the file: ${fileStore}`;else{if(fileNames.length>1)statusMessage=`You have selected ${fileNames.length} files: ${fileStore.join(", ")}`;}setTimeout(()=>{statusEl.textContent=statusMessage;},1000);};const addPreviewHeading=(fileInputEl,fileNames)=>{const filePreviewsHeading=document.createElement("div");const dropTarget=fileInputEl.closest(`.${TARGET_CLASS}`);const instructions=dropTarget.querySelector(`.${INSTRUCTIONS_CLASS}`);let changeItemText="Change file";let previewHeadingText="";if(fileNames.length===1)previewHeadingText=Sanitizer.escapeHTML`Selected file ${changeItemText}`;else{if(fileNames.length>1){changeItemText="Change files";previewHeadingText=Sanitizer.escapeHTML`${fileNames.length} files selected ${changeItemText}`;}}instructions.setAttribute("hidden","true");filePreviewsHeading.classList.add(PREVIEW_HEADING_CLASS);filePreviewsHeading.innerHTML=previewHeadingText;dropTarget.insertBefore(filePreviewsHeading,instructions);fileInputEl.setAttribute("aria-label",changeItemText);};const setPreviewFallback=(previewImage,fallbackClass)=>{previewImage.addEventListener("error",()=>{const localPreviewImage=previewImage;localPreviewImage.src=SPACER_GIF;localPreviewImage.classList.add(fallbackClass);},{once:true});};const handleChange=(e,fileInputEl,instructions,dropTarget)=>{const fileNames=e.target.files;const inputParent=dropTarget.closest(`.${DROPZONE_CLASS}`);const statusElement=inputParent.querySelector(`.${SR_ONLY_CLASS}`);const fileStore=[];removeOldPreviews(dropTarget,instructions);for(let i=0;i