@moduk/frontend 2.0.23 → 2.0.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client/moduk-frontend.umd.js +1 -1
- package/client/moduk-frontend.umd.js.LICENSE.txt +21 -0
- package/client/moduk-frontend.umd.js.map +1 -1
- package/css/index.css +1 -1
- package/dist/client/moduk-frontend.umd.js +1 -1
- package/dist/client/moduk-frontend.umd.js.LICENSE.txt +21 -0
- package/dist/client/moduk-frontend.umd.js.map +1 -1
- package/dist/css/index.css +1 -1
- package/dist/lib/utils.d.ts.map +1 -1
- package/dist/lib/utils.js +4 -6
- package/dist/lib/utils.js.map +1 -1
- package/lib/utils.d.ts.map +1 -1
- package/lib/utils.js +4 -6
- package/lib/utils.js.map +1 -1
- package/package.json +39 -37
- package/react/MODUKBody/MODUKBody.d.ts +1 -1
- package/react/MODUKBody/MODUKBody.d.ts.map +1 -1
- package/react/VisuallyHiddenText/VisuallyHiddenText.d.ts.map +1 -1
- package/react/esm/MODUKBody/MODUKBody.js +2 -2
- package/react/esm/accordion/Accordion.js +2 -2
- package/react/esm/back-link/BackLink.js +2 -2
- package/react/esm/character-count/CharacterCount.js +2 -2
- package/react/esm/details/Details.js +2 -2
- package/react/esm/error-message/ErrorMessage.js +2 -2
- package/react/esm/fieldset/Fieldset.js +2 -2
- package/react/esm/fieldset/FieldsetLegend.js +2 -2
- package/react/esm/footer/Footer.js +2 -2
- package/react/esm/footer/FooterMetaLink.js +2 -2
- package/react/esm/footer/FooterNavigationLink.js +2 -2
- package/react/esm/header/Header.js +2 -2
- package/react/esm/header/HeaderNavigationItem.js +2 -2
- package/react/esm/header/HeaderNavigationLink.js +2 -2
- package/react/esm/hint/Hint.js +2 -2
- package/react/esm/input/Input.js +2 -2
- package/react/esm/inset-text/InsetText.js +2 -2
- package/react/esm/internal/Link/Link.js +2 -2
- package/react/esm/internal/hooks/useMODUKComponent/useMODUKComponent.js +10 -11
- package/react/esm/internal/hooks/usePrevious/usePrevious.js +1 -1
- package/react/esm/label/Label.js +2 -2
- package/react/esm/notification-banner/NotificationBanner.js +2 -2
- package/react/esm/phase-banner/PhaseBanner.js +2 -2
- package/react/esm/phase-banner/PhaseTag.js +2 -2
- package/react/esm/skip-link/SkipLink.js +2 -2
- package/react/esm/summary-list/SummaryList.js +2 -2
- package/react/esm/summary-list/SummaryListActionLink.js +2 -2
- package/react/esm/table/TableBody.js +2 -2
- package/react/esm/table/TableCaption.js +2 -2
- package/react/esm/table/TableCell.js +2 -2
- package/react/esm/table/TableColumnHeader.js +2 -2
- package/react/esm/table/TableHead.js +2 -2
- package/react/esm/table/TableRow.js +2 -2
- package/react/esm/table/TableRowHeader.js +2 -2
- package/react/esm/tag/Tag.js +2 -2
- package/react/esm/textarea/Textarea.js +2 -2
- package/react/esm/warning-text/WarningText.js +2 -2
- package/react/index.js +1 -1
- package/react/index.js.map +1 -1
- package/react/internal/hooks/useMODUKComponent/useMODUKComponent.d.ts +1 -1
- package/react/internal/test-utils/Root.d.ts.map +1 -1
- package/react/summary-list/SummaryCardActions.d.ts.map +1 -1
- package/react/summary-list/SummaryCardTitle.d.ts.map +1 -1
- package/react/summary-list/SummaryListActions.d.ts.map +1 -1
- package/react/summary-list/SummaryListKey.d.ts.map +1 -1
- package/react/summary-list/SummaryListValue.d.ts.map +1 -1
- package/assets/images/govuk-crest-2x.png +0 -0
- package/assets/images/govuk-crest.png +0 -0
- package/dist/assets/images/govuk-crest-2x.png +0 -0
- package/dist/assets/images/govuk-crest.png +0 -0
@@ -1,3 +1,3 @@
|
|
1
1
|
/*! For license information please see moduk-frontend.umd.js.LICENSE.txt */
|
2
|
-
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.MODUK=e():t.MODUK=e()}(self,(function(){return function(){"use strict";var t={d:function(e,s){for(var i in s)t.o(s,i)&&!t.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:s[i]})},o:function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r:function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{Accordion:function(){return v},Button:function(){return $},CharacterCount:function(){return k},Checkboxes:function(){return C},ErrorSummary:function(){return A},ExitThisPage:function(){return x},Header:function(){return S},NotificationBanner:function(){return E},PasswordInput:function(){return T},Radios:function(){return L},SkipLink:function(){return M},Tabs:function(){return I},initAll:function(){return H},version:function(){return s}});const s="5.3.1";function i(t,e){const s=t?t.trim():"";let i,n=null==e?void 0:e.type;switch(n||(["true","false"].includes(s)&&(n="boolean"),s.length>0&&isFinite(Number(s))&&(n="number")),n){case"boolean":i="true"===s;break;case"number":i=Number(s);break;default:i=t}return i}function n(...t){const e={};for(const s of t)for(const t of Object.keys(s)){const i=e[t],o=s[t];u(i)&&u(o)?e[t]=n(i,o):e[t]=o}return e}function o(t,e,s){const n=t.schema.properties[s];if("object"!==(null==n?void 0:n.type))return;const o={[s]:{}};for(const[t,n]of Object.entries(e)){let e=o;const r=t.split(".");for(const[o,a]of r.entries())"object"==typeof e&&(o<r.length-1?(u(e[a])||(e[a]={}),e=e[a]):t!==s&&(e[a]=i(n)))}return o[s]}function r(t){if(t.includes("#"))return t.split("#").pop()}function a(t){const e=`--govuk-frontend-breakpoint-${t}`;return{property:e,value:window.getComputedStyle(document.documentElement).getPropertyValue(e)||void 0}}function l(t,e={}){var s;const i=t.getAttribute("tabindex");function n(){var s;null==(s=e.onBlur)||s.call(t),i||t.removeAttribute("tabindex")}i||t.setAttribute("tabindex","-1"),t.addEventListener("focus",(function(){t.addEventListener("blur",n,{once:!0})}),{once:!0}),null==(s=e.onBeforeFocus)||s.call(t),t.focus()}function c(t=document.body){return!!t&&t.classList.contains("govuk-frontend-supported")}function u(t){return!!t&&"object"==typeof t&&!function(t){return Array.isArray(t)}(t)}function h(t,e){const s={};for(const[n,r]of Object.entries(t.schema.properties))n in e&&(s[n]=i(e[n],r)),"object"===(null==r?void 0:r.type)&&(s[n]=o(t,e,n));return s}class d extends Error{constructor(...t){super(...t),this.name="GOVUKFrontendError"}}class m extends d{constructor(t=document.body){const e="noModule"in HTMLScriptElement.prototype?'GOV.UK Frontend initialised without `<body class="govuk-frontend-supported">` from template `<script>` snippet':"GOV.UK Frontend is not supported in this browser";super(t?e:'GOV.UK Frontend initialised without `<script type="module">`'),this.name="SupportError"}}class p extends d{constructor(...t){super(...t),this.name="ConfigError"}}class g extends d{constructor(t){let e="string"==typeof t?t:"";if("object"==typeof t){const{componentName:s,identifier:i,element:n,expectedType:o}=t;e=`${s}: ${i}`,e+=n?` is not of type ${null!=o?o:"HTMLElement"}`:" not found"}super(e),this.name="ElementError"}}class f{constructor(){this.checkSupport()}checkSupport(){if(!c())throw new m}}class b{constructor(t={},e={}){var s;this.translations=void 0,this.locale=void 0,this.translations=t,this.locale=null!=(s=e.locale)?s:document.documentElement.lang||"en"}t(t,e){if(!t)throw new Error("i18n: lookup key missing");let s=this.translations[t];if("number"==typeof(null==e?void 0:e.count)&&"object"==typeof s){const i=s[this.getPluralSuffix(t,e.count)];i&&(s=i)}if("string"==typeof s){if(s.match(/%{(.\S+)}/)){if(!e)throw new Error("i18n: cannot replace placeholders in string if no option data provided");return this.replacePlaceholders(s,e)}return s}return t}replacePlaceholders(t,e){const s=Intl.NumberFormat.supportedLocalesOf(this.locale).length?new Intl.NumberFormat(this.locale):void 0;return t.replace(/%{(.\S+)}/g,(function(t,i){if(Object.prototype.hasOwnProperty.call(e,i)){const t=e[i];return!1===t||"number"!=typeof t&&"string"!=typeof t?"":"number"==typeof t?s?s.format(t):`${t}`:t}throw new Error(`i18n: no data found to replace ${t} placeholder in string`)}))}hasIntlPluralRulesSupport(){return Boolean("PluralRules"in window.Intl&&Intl.PluralRules.supportedLocalesOf(this.locale).length)}getPluralSuffix(t,e){if(e=Number(e),!isFinite(e))return"other";const s=this.translations[t],i=this.hasIntlPluralRulesSupport()?new Intl.PluralRules(this.locale).select(e):this.selectPluralFormUsingFallbackRules(e);if("object"==typeof s){if(i in s)return i;if("other"in s)return console.warn(`i18n: Missing plural form ".${i}" for "${this.locale}" locale. Falling back to ".other".`),"other"}throw new Error(`i18n: Plural form ".other" is required for "${this.locale}" locale`)}selectPluralFormUsingFallbackRules(t){t=Math.abs(Math.floor(t));const e=this.getPluralRulesForLocale();return e?b.pluralRules[e](t):"other"}getPluralRulesForLocale(){const t=this.locale.split("-")[0];for(const e in b.pluralRulesMap){const s=b.pluralRulesMap[e];if(s.includes(this.locale)||s.includes(t))return e}}}b.pluralRulesMap={arabic:["ar"],chinese:["my","zh","id","ja","jv","ko","ms","th","vi"],french:["hy","bn","fr","gu","hi","fa","pa","zu"],german:["af","sq","az","eu","bg","ca","da","nl","en","et","fi","ka","de","el","hu","lb","no","so","sw","sv","ta","te","tr","ur"],irish:["ga"],russian:["ru","uk"],scottish:["gd"],spanish:["pt-PT","it","es"],welsh:["cy"]},b.pluralRules={arabic(t){return 0===t?"zero":1===t?"one":2===t?"two":t%100>=3&&t%100<=10?"few":t%100>=11&&t%100<=99?"many":"other"},chinese(){return"other"},french(t){return 0===t||1===t?"one":"other"},german(t){return 1===t?"one":"other"},irish(t){return 1===t?"one":2===t?"two":t>=3&&t<=6?"few":t>=7&&t<=10?"many":"other"},russian(t){const e=t%100,s=e%10;return 1===s&&11!==e?"one":s>=2&&s<=4&&!(e>=12&&e<=14)?"few":0===s||s>=5&&s<=9||e>=11&&e<=14?"many":"other"},scottish(t){return 1===t||11===t?"one":2===t||12===t?"two":t>=3&&t<=10||t>=13&&t<=19?"few":"other"},spanish(t){return 1===t?"one":t%1e6==0&&0!==t?"many":"other"},welsh(t){return 0===t?"zero":1===t?"one":2===t?"two":3===t?"few":6===t?"many":"other"}};class v extends f{constructor(t,e={}){if(super(),this.$module=void 0,this.config=void 0,this.i18n=void 0,this.controlsClass="govuk-accordion__controls",this.showAllClass="govuk-accordion__show-all",this.showAllTextClass="govuk-accordion__show-all-text",this.sectionClass="govuk-accordion__section",this.sectionExpandedClass="govuk-accordion__section--expanded",this.sectionButtonClass="govuk-accordion__section-button",this.sectionHeaderClass="govuk-accordion__section-header",this.sectionHeadingClass="govuk-accordion__section-heading",this.sectionHeadingDividerClass="govuk-accordion__section-heading-divider",this.sectionHeadingTextClass="govuk-accordion__section-heading-text",this.sectionHeadingTextFocusClass="govuk-accordion__section-heading-text-focus",this.sectionShowHideToggleClass="govuk-accordion__section-toggle",this.sectionShowHideToggleFocusClass="govuk-accordion__section-toggle-focus",this.sectionShowHideTextClass="govuk-accordion__section-toggle-text",this.upChevronIconClass="govuk-accordion-nav__chevron",this.downChevronIconClass="govuk-accordion-nav__chevron--down",this.sectionSummaryClass="govuk-accordion__section-summary",this.sectionSummaryFocusClass="govuk-accordion__section-summary-focus",this.sectionContentClass="govuk-accordion__section-content",this.$sections=void 0,this.browserSupportsSessionStorage=!1,this.$showAllButton=null,this.$showAllIcon=null,this.$showAllText=null,!(t instanceof HTMLElement))throw new g({componentName:"Accordion",element:t,identifier:"Root element (`$module`)"});this.$module=t,this.config=n(v.defaults,e,h(v,t.dataset)),this.i18n=new b(this.config.i18n);const s=this.$module.querySelectorAll(`.${this.sectionClass}`);if(!s.length)throw new g({componentName:"Accordion",identifier:`Sections (\`<div class="${this.sectionClass}">\`)`});this.$sections=s,this.browserSupportsSessionStorage=w.checkForSessionStorage(),this.initControls(),this.initSectionHeaders();const i=this.checkIfAllSectionsOpen();this.updateShowAllButton(i)}initControls(){this.$showAllButton=document.createElement("button"),this.$showAllButton.setAttribute("type","button"),this.$showAllButton.setAttribute("class",this.showAllClass),this.$showAllButton.setAttribute("aria-expanded","false"),this.$showAllIcon=document.createElement("span"),this.$showAllIcon.classList.add(this.upChevronIconClass),this.$showAllButton.appendChild(this.$showAllIcon);const t=document.createElement("div");t.setAttribute("class",this.controlsClass),t.appendChild(this.$showAllButton),this.$module.insertBefore(t,this.$module.firstChild),this.$showAllText=document.createElement("span"),this.$showAllText.classList.add(this.showAllTextClass),this.$showAllButton.appendChild(this.$showAllText),this.$showAllButton.addEventListener("click",(()=>this.onShowOrHideAllToggle())),"onbeforematch"in document&&document.addEventListener("beforematch",(t=>this.onBeforeMatch(t)))}initSectionHeaders(){this.$sections.forEach(((t,e)=>{const s=t.querySelector(`.${this.sectionHeaderClass}`);if(!s)throw new g({componentName:"Accordion",identifier:`Section headers (\`<div class="${this.sectionHeaderClass}">\`)`});this.constructHeaderMarkup(s,e),this.setExpanded(this.isExpanded(t),t),s.addEventListener("click",(()=>this.onSectionToggle(t))),this.setInitialState(t)}))}constructHeaderMarkup(t,e){const s=t.querySelector(`.${this.sectionButtonClass}`),i=t.querySelector(`.${this.sectionHeadingClass}`),n=t.querySelector(`.${this.sectionSummaryClass}`);if(!i)throw new g({componentName:"Accordion",identifier:`Section heading (\`.${this.sectionHeadingClass}\`)`});if(!s)throw new g({componentName:"Accordion",identifier:`Section button placeholder (\`<span class="${this.sectionButtonClass}">\`)`});const o=document.createElement("button");o.setAttribute("type","button"),o.setAttribute("aria-controls",`${this.$module.id}-content-${e+1}`);for(const t of Array.from(s.attributes))"id"!==t.nodeName&&o.setAttribute(t.nodeName,`${t.nodeValue}`);const r=document.createElement("span");r.classList.add(this.sectionHeadingTextClass),r.id=s.id;const a=document.createElement("span");a.classList.add(this.sectionHeadingTextFocusClass),r.appendChild(a),a.innerHTML=s.innerHTML;const l=document.createElement("span");l.classList.add(this.sectionShowHideToggleClass),l.setAttribute("data-nosnippet","");const c=document.createElement("span");c.classList.add(this.sectionShowHideToggleFocusClass),l.appendChild(c);const u=document.createElement("span"),h=document.createElement("span");if(h.classList.add(this.upChevronIconClass),c.appendChild(h),u.classList.add(this.sectionShowHideTextClass),c.appendChild(u),o.appendChild(r),o.appendChild(this.getButtonPunctuationEl()),null!=n&&n.parentNode){const t=document.createElement("span"),e=document.createElement("span");e.classList.add(this.sectionSummaryFocusClass),t.appendChild(e);for(const e of Array.from(n.attributes))t.setAttribute(e.nodeName,`${e.nodeValue}`);e.innerHTML=n.innerHTML,n.parentNode.replaceChild(t,n),o.appendChild(t),o.appendChild(this.getButtonPunctuationEl())}o.appendChild(l),i.removeChild(s),i.appendChild(o)}onBeforeMatch(t){const e=t.target;if(!(e instanceof Element))return;const s=e.closest(`.${this.sectionClass}`);s&&this.setExpanded(!0,s)}onSectionToggle(t){const e=this.isExpanded(t);this.setExpanded(!e,t),this.storeState(t)}onShowOrHideAllToggle(){const t=!this.checkIfAllSectionsOpen();this.$sections.forEach((e=>{this.setExpanded(t,e),this.storeState(e)})),this.updateShowAllButton(t)}setExpanded(t,e){const s=e.querySelector(`.${this.upChevronIconClass}`),i=e.querySelector(`.${this.sectionShowHideTextClass}`),n=e.querySelector(`.${this.sectionButtonClass}`),o=e.querySelector(`.${this.sectionContentClass}`);if(!o)throw new g({componentName:"Accordion",identifier:`Section content (\`<div class="${this.sectionContentClass}">\`)`});if(!s||!i||!n)return;const r=t?this.i18n.t("hideSection"):this.i18n.t("showSection");i.textContent=r,n.setAttribute("aria-expanded",`${t}`);const a=[],l=e.querySelector(`.${this.sectionHeadingTextClass}`);l&&a.push(`${l.textContent}`.trim());const c=e.querySelector(`.${this.sectionSummaryClass}`);c&&a.push(`${c.textContent}`.trim());const u=t?this.i18n.t("hideSectionAriaLabel"):this.i18n.t("showSectionAriaLabel");a.push(u),n.setAttribute("aria-label",a.join(" , ")),t?(o.removeAttribute("hidden"),e.classList.add(this.sectionExpandedClass),s.classList.remove(this.downChevronIconClass)):(o.setAttribute("hidden","until-found"),e.classList.remove(this.sectionExpandedClass),s.classList.add(this.downChevronIconClass));const h=this.checkIfAllSectionsOpen();this.updateShowAllButton(h)}isExpanded(t){return t.classList.contains(this.sectionExpandedClass)}checkIfAllSectionsOpen(){return this.$sections.length===this.$module.querySelectorAll(`.${this.sectionExpandedClass}`).length}updateShowAllButton(t){this.$showAllButton&&this.$showAllText&&this.$showAllIcon&&(this.$showAllButton.setAttribute("aria-expanded",t.toString()),this.$showAllText.textContent=t?this.i18n.t("hideAllSections"):this.i18n.t("showAllSections"),this.$showAllIcon.classList.toggle(this.downChevronIconClass,!t))}storeState(t){if(this.browserSupportsSessionStorage&&this.config.rememberExpanded){const e=t.querySelector(`.${this.sectionButtonClass}`);if(e){const t=e.getAttribute("aria-controls"),s=e.getAttribute("aria-expanded");t&&s&&window.sessionStorage.setItem(t,s)}}}setInitialState(t){if(this.browserSupportsSessionStorage&&this.config.rememberExpanded){const e=t.querySelector(`.${this.sectionButtonClass}`);if(e){const s=e.getAttribute("aria-controls"),i=s?window.sessionStorage.getItem(s):null;null!==i&&this.setExpanded("true"===i,t)}}}getButtonPunctuationEl(){const t=document.createElement("span");return t.classList.add("govuk-visually-hidden",this.sectionHeadingDividerClass),t.innerHTML=", ",t}}v.moduleName="govuk-accordion",v.defaults=Object.freeze({i18n:{hideAllSections:"Hide all sections",hideSection:"Hide",hideSectionAriaLabel:"Hide this section",showAllSections:"Show all sections",showSection:"Show",showSectionAriaLabel:"Show this section"},rememberExpanded:!0}),v.schema=Object.freeze({properties:{i18n:{type:"object"},rememberExpanded:{type:"boolean"}}});const w={checkForSessionStorage:function(){const t="this is the test string";let e;try{return window.sessionStorage.setItem(t,t),e=window.sessionStorage.getItem(t)===t.toString(),window.sessionStorage.removeItem(t),e}catch(t){return!1}}};class $ extends f{constructor(t,e={}){if(super(),this.$module=void 0,this.config=void 0,this.debounceFormSubmitTimer=null,!(t instanceof HTMLElement))throw new g({componentName:"Button",element:t,identifier:"Root element (`$module`)"});this.$module=t,this.config=n($.defaults,e,h($,t.dataset)),this.$module.addEventListener("keydown",(t=>this.handleKeyDown(t))),this.$module.addEventListener("click",(t=>this.debounce(t)))}handleKeyDown(t){const e=t.target;" "===t.key&&e instanceof HTMLElement&&"button"===e.getAttribute("role")&&(t.preventDefault(),e.click())}debounce(t){if(this.config.preventDoubleClick)return this.debounceFormSubmitTimer?(t.preventDefault(),!1):void(this.debounceFormSubmitTimer=window.setTimeout((()=>{this.debounceFormSubmitTimer=null}),1e3))}}function y(t,e){const s=t.closest(`[${e}]`);return s?s.getAttribute(e):null}$.moduleName="govuk-button",$.defaults=Object.freeze({preventDoubleClick:!1}),$.schema=Object.freeze({properties:{preventDoubleClick:{type:"boolean"}}});class k extends f{constructor(t,e={}){var s,i;if(super(),this.$module=void 0,this.$textarea=void 0,this.$visibleCountMessage=void 0,this.$screenReaderCountMessage=void 0,this.lastInputTimestamp=null,this.lastInputValue="",this.valueChecker=null,this.config=void 0,this.i18n=void 0,this.maxLength=void 0,!(t instanceof HTMLElement))throw new g({componentName:"Character count",element:t,identifier:"Root element (`$module`)"});const o=t.querySelector(".govuk-js-character-count");if(!(o instanceof HTMLTextAreaElement||o instanceof HTMLInputElement))throw new g({componentName:"Character count",element:o,expectedType:"HTMLTextareaElement or HTMLInputElement",identifier:"Form field (`.govuk-js-character-count`)"});const r=h(k,t.dataset);let a={};("maxwords"in r||"maxlength"in r)&&(a={maxlength:void 0,maxwords:void 0}),this.config=n(k.defaults,e,a,r);const l=function(t,e){const s=[];for(const[i,n]of Object.entries(t)){const t=[];if(Array.isArray(n)){for(const{required:s,errorMessage:i}of n)s.every((t=>!!e[t]))||t.push(i);"anyOf"!==i||n.length-t.length>=1||s.push(...t)}}return s}(k.schema,this.config);if(l[0])throw new p(`Character count: ${l[0]}`);this.i18n=new b(this.config.i18n,{locale:y(t,"lang")}),this.maxLength=null!=(s=null!=(i=this.config.maxwords)?i:this.config.maxlength)?s:1/0,this.$module=t,this.$textarea=o;const c=`${this.$textarea.id}-info`,u=document.getElementById(c);if(!u)throw new g({componentName:"Character count",element:u,identifier:`Count message (\`id="${c}"\`)`});`${u.textContent}`.match(/^\s*$/)&&(u.textContent=this.i18n.t("textareaDescription",{count:this.maxLength})),this.$textarea.insertAdjacentElement("afterend",u);const d=document.createElement("div");d.className="govuk-character-count__sr-status govuk-visually-hidden",d.setAttribute("aria-live","polite"),this.$screenReaderCountMessage=d,u.insertAdjacentElement("afterend",d);const m=document.createElement("div");m.className=u.className,m.classList.add("govuk-character-count__status"),m.setAttribute("aria-hidden","true"),this.$visibleCountMessage=m,u.insertAdjacentElement("afterend",m),u.classList.add("govuk-visually-hidden"),this.$textarea.removeAttribute("maxlength"),this.bindChangeEvents(),window.addEventListener("pageshow",(()=>this.updateCountMessage())),this.updateCountMessage()}bindChangeEvents(){this.$textarea.addEventListener("keyup",(()=>this.handleKeyUp())),this.$textarea.addEventListener("focus",(()=>this.handleFocus())),this.$textarea.addEventListener("blur",(()=>this.handleBlur()))}handleKeyUp(){this.updateVisibleCountMessage(),this.lastInputTimestamp=Date.now()}handleFocus(){this.valueChecker=window.setInterval((()=>{(!this.lastInputTimestamp||Date.now()-500>=this.lastInputTimestamp)&&this.updateIfValueChanged()}),1e3)}handleBlur(){this.valueChecker&&window.clearInterval(this.valueChecker)}updateIfValueChanged(){this.$textarea.value!==this.lastInputValue&&(this.lastInputValue=this.$textarea.value,this.updateCountMessage())}updateCountMessage(){this.updateVisibleCountMessage(),this.updateScreenReaderCountMessage()}updateVisibleCountMessage(){const t=this.maxLength-this.count(this.$textarea.value)<0;this.$visibleCountMessage.classList.toggle("govuk-character-count__message--disabled",!this.isOverThreshold()),this.$textarea.classList.toggle("govuk-textarea--error",t),this.$visibleCountMessage.classList.toggle("govuk-error-message",t),this.$visibleCountMessage.classList.toggle("govuk-hint",!t),this.$visibleCountMessage.textContent=this.getCountMessage()}updateScreenReaderCountMessage(){this.isOverThreshold()?this.$screenReaderCountMessage.removeAttribute("aria-hidden"):this.$screenReaderCountMessage.setAttribute("aria-hidden","true"),this.$screenReaderCountMessage.textContent=this.getCountMessage()}count(t){var e;return this.config.maxwords?(null!=(e=t.match(/\S+/g))?e:[]).length:t.length}getCountMessage(){const t=this.maxLength-this.count(this.$textarea.value),e=this.config.maxwords?"words":"characters";return this.formatCountMessage(t,e)}formatCountMessage(t,e){if(0===t)return this.i18n.t(`${e}AtLimit`);const s=t<0?"OverLimit":"UnderLimit";return this.i18n.t(`${e}${s}`,{count:Math.abs(t)})}isOverThreshold(){if(!this.config.threshold)return!0;const t=this.count(this.$textarea.value);return this.maxLength*this.config.threshold/100<=t}}k.moduleName="govuk-character-count",k.defaults=Object.freeze({threshold:0,i18n:{charactersUnderLimit:{one:"You have %{count} character remaining",other:"You have %{count} characters remaining"},charactersAtLimit:"You have 0 characters remaining",charactersOverLimit:{one:"You have %{count} character too many",other:"You have %{count} characters too many"},wordsUnderLimit:{one:"You have %{count} word remaining",other:"You have %{count} words remaining"},wordsAtLimit:"You have 0 words remaining",wordsOverLimit:{one:"You have %{count} word too many",other:"You have %{count} words too many"},textareaDescription:{other:""}}}),k.schema=Object.freeze({properties:{i18n:{type:"object"},maxwords:{type:"number"},maxlength:{type:"number"},threshold:{type:"number"}},anyOf:[{required:["maxwords"],errorMessage:'Either "maxlength" or "maxwords" must be provided'},{required:["maxlength"],errorMessage:'Either "maxlength" or "maxwords" must be provided'}]});class C extends f{constructor(t){if(super(),this.$module=void 0,this.$inputs=void 0,!(t instanceof HTMLElement))throw new g({componentName:"Checkboxes",element:t,identifier:"Root element (`$module`)"});const e=t.querySelectorAll('input[type="checkbox"]');if(!e.length)throw new g({componentName:"Checkboxes",identifier:'Form inputs (`<input type="checkbox">`)'});this.$module=t,this.$inputs=e,this.$inputs.forEach((t=>{const e=t.getAttribute("data-aria-controls");if(e){if(!document.getElementById(e))throw new g({componentName:"Checkboxes",identifier:`Conditional reveal (\`id="${e}"\`)`});t.setAttribute("aria-controls",e),t.removeAttribute("data-aria-controls")}})),window.addEventListener("pageshow",(()=>this.syncAllConditionalReveals())),this.syncAllConditionalReveals(),this.$module.addEventListener("click",(t=>this.handleClick(t)))}syncAllConditionalReveals(){this.$inputs.forEach((t=>this.syncConditionalRevealWithInputState(t)))}syncConditionalRevealWithInputState(t){const e=t.getAttribute("aria-controls");if(!e)return;const s=document.getElementById(e);if(null!=s&&s.classList.contains("govuk-checkboxes__conditional")){const e=t.checked;t.setAttribute("aria-expanded",e.toString()),s.classList.toggle("govuk-checkboxes__conditional--hidden",!e)}}unCheckAllInputsExcept(t){document.querySelectorAll(`input[type="checkbox"][name="${t.name}"]`).forEach((e=>{t.form===e.form&&e!==t&&(e.checked=!1,this.syncConditionalRevealWithInputState(e))}))}unCheckExclusiveInputs(t){document.querySelectorAll(`input[data-behaviour="exclusive"][type="checkbox"][name="${t.name}"]`).forEach((e=>{t.form===e.form&&(e.checked=!1,this.syncConditionalRevealWithInputState(e))}))}handleClick(t){const e=t.target;e instanceof HTMLInputElement&&"checkbox"===e.type&&(e.getAttribute("aria-controls")&&this.syncConditionalRevealWithInputState(e),e.checked&&("exclusive"===e.getAttribute("data-behaviour")?this.unCheckAllInputsExcept(e):this.unCheckExclusiveInputs(e)))}}C.moduleName="govuk-checkboxes";class A extends f{constructor(t,e={}){if(super(),this.$module=void 0,this.config=void 0,!(t instanceof HTMLElement))throw new g({componentName:"Error summary",element:t,identifier:"Root element (`$module`)"});this.$module=t,this.config=n(A.defaults,e,h(A,t.dataset)),this.config.disableAutoFocus||l(this.$module),this.$module.addEventListener("click",(t=>this.handleClick(t)))}handleClick(t){const e=t.target;e&&this.focusTarget(e)&&t.preventDefault()}focusTarget(t){if(!(t instanceof HTMLAnchorElement))return!1;const e=r(t.href);if(!e)return!1;const s=document.getElementById(e);if(!s)return!1;const i=this.getAssociatedLegendOrLabel(s);return!!i&&(i.scrollIntoView(),s.focus({preventScroll:!0}),!0)}getAssociatedLegendOrLabel(t){var e;const s=t.closest("fieldset");if(s){const e=s.getElementsByTagName("legend");if(e.length){const s=e[0];if(t instanceof HTMLInputElement&&("checkbox"===t.type||"radio"===t.type))return s;const i=s.getBoundingClientRect().top,n=t.getBoundingClientRect();if(n.height&&window.innerHeight&&n.top+n.height-i<window.innerHeight/2)return s}}return null!=(e=document.querySelector(`label[for='${t.getAttribute("id")}']`))?e:t.closest("label")}}A.moduleName="govuk-error-summary",A.defaults=Object.freeze({disableAutoFocus:!1}),A.schema=Object.freeze({properties:{disableAutoFocus:{type:"boolean"}}});class x extends f{constructor(t,e={}){if(super(),this.$module=void 0,this.config=void 0,this.i18n=void 0,this.$button=void 0,this.$skiplinkButton=null,this.$updateSpan=null,this.$indicatorContainer=null,this.$overlay=null,this.keypressCounter=0,this.lastKeyWasModified=!1,this.timeoutTime=5e3,this.keypressTimeoutId=null,this.timeoutMessageId=null,!(t instanceof HTMLElement))throw new g({componentName:"Exit this page",element:t,identifier:"Root element (`$module`)"});const s=t.querySelector(".govuk-exit-this-page__button");if(!(s instanceof HTMLAnchorElement))throw new g({componentName:"Exit this page",element:s,expectedType:"HTMLAnchorElement",identifier:"Button (`.govuk-exit-this-page__button`)"});this.config=n(x.defaults,e,h(x,t.dataset)),this.i18n=new b(this.config.i18n),this.$module=t,this.$button=s;const i=document.querySelector(".govuk-js-exit-this-page-skiplink");i instanceof HTMLAnchorElement&&(this.$skiplinkButton=i),this.buildIndicator(),this.initUpdateSpan(),this.initButtonClickHandler(),"govukFrontendExitThisPageKeypress"in document.body.dataset||(document.addEventListener("keyup",this.handleKeypress.bind(this),!0),document.body.dataset.govukFrontendExitThisPageKeypress="true"),window.addEventListener("pageshow",this.resetPage.bind(this))}initUpdateSpan(){this.$updateSpan=document.createElement("span"),this.$updateSpan.setAttribute("role","status"),this.$updateSpan.className="govuk-visually-hidden",this.$module.appendChild(this.$updateSpan)}initButtonClickHandler(){this.$button.addEventListener("click",this.handleClick.bind(this)),this.$skiplinkButton&&this.$skiplinkButton.addEventListener("click",this.handleClick.bind(this))}buildIndicator(){this.$indicatorContainer=document.createElement("div"),this.$indicatorContainer.className="govuk-exit-this-page__indicator",this.$indicatorContainer.setAttribute("aria-hidden","true");for(let t=0;t<3;t++){const t=document.createElement("div");t.className="govuk-exit-this-page__indicator-light",this.$indicatorContainer.appendChild(t)}this.$button.appendChild(this.$indicatorContainer)}updateIndicator(){this.$indicatorContainer&&(this.$indicatorContainer.classList.toggle("govuk-exit-this-page__indicator--visible",this.keypressCounter>0),this.$indicatorContainer.querySelectorAll(".govuk-exit-this-page__indicator-light").forEach(((t,e)=>{t.classList.toggle("govuk-exit-this-page__indicator-light--on",e<this.keypressCounter)})))}exitPage(){this.$updateSpan&&(this.$updateSpan.textContent="",document.body.classList.add("govuk-exit-this-page-hide-content"),this.$overlay=document.createElement("div"),this.$overlay.className="govuk-exit-this-page-overlay",this.$overlay.setAttribute("role","alert"),document.body.appendChild(this.$overlay),this.$overlay.textContent=this.i18n.t("activated"),window.location.href=this.$button.href)}handleClick(t){t.preventDefault(),this.exitPage()}handleKeypress(t){this.$updateSpan&&("Shift"!==t.key||this.lastKeyWasModified?this.keypressTimeoutId&&this.resetKeypressTimer():(this.keypressCounter+=1,this.updateIndicator(),this.timeoutMessageId&&(window.clearTimeout(this.timeoutMessageId),this.timeoutMessageId=null),this.keypressCounter>=3?(this.keypressCounter=0,this.keypressTimeoutId&&(window.clearTimeout(this.keypressTimeoutId),this.keypressTimeoutId=null),this.exitPage()):1===this.keypressCounter?this.$updateSpan.textContent=this.i18n.t("pressTwoMoreTimes"):this.$updateSpan.textContent=this.i18n.t("pressOneMoreTime"),this.setKeypressTimer()),this.lastKeyWasModified=t.shiftKey)}setKeypressTimer(){this.keypressTimeoutId&&window.clearTimeout(this.keypressTimeoutId),this.keypressTimeoutId=window.setTimeout(this.resetKeypressTimer.bind(this),this.timeoutTime)}resetKeypressTimer(){if(!this.$updateSpan)return;this.keypressTimeoutId&&(window.clearTimeout(this.keypressTimeoutId),this.keypressTimeoutId=null);const t=this.$updateSpan;this.keypressCounter=0,t.textContent=this.i18n.t("timedOut"),this.timeoutMessageId=window.setTimeout((()=>{t.textContent=""}),this.timeoutTime),this.updateIndicator()}resetPage(){document.body.classList.remove("govuk-exit-this-page-hide-content"),this.$overlay&&(this.$overlay.remove(),this.$overlay=null),this.$updateSpan&&(this.$updateSpan.setAttribute("role","status"),this.$updateSpan.textContent=""),this.updateIndicator(),this.keypressTimeoutId&&window.clearTimeout(this.keypressTimeoutId),this.timeoutMessageId&&window.clearTimeout(this.timeoutMessageId)}}x.moduleName="govuk-exit-this-page",x.defaults=Object.freeze({i18n:{activated:"Loading.",timedOut:"Exit this page expired.",pressTwoMoreTimes:"Shift, press 2 more times to exit.",pressOneMoreTime:"Shift, press 1 more time to exit."}}),x.schema=Object.freeze({properties:{i18n:{type:"object"}}});class S extends f{constructor(t){if(super(),this.$module=void 0,this.$menuButton=void 0,this.$menu=void 0,this.menuIsOpen=!1,this.mql=null,!t)throw new g({componentName:"Header",element:t,identifier:"Root element (`$module`)"});this.$module=t;const e=t.querySelector(".govuk-js-header-toggle");if(!e)return this;const s=e.getAttribute("aria-controls");if(!s)throw new g({componentName:"Header",identifier:'Navigation button (`<button class="govuk-js-header-toggle">`) attribute (`aria-controls`)'});const i=document.getElementById(s);if(!i)throw new g({componentName:"Header",element:i,identifier:`Navigation (\`<ul id="${s}">\`)`});this.$menu=i,this.$menuButton=e,this.setupResponsiveChecks(),this.$menuButton.addEventListener("click",(()=>this.handleMenuButtonClick()))}setupResponsiveChecks(){const t=a("desktop");if(!t.value)throw new g({componentName:"Header",identifier:`CSS custom property (\`${t.property}\`) on pseudo-class \`:root\``});this.mql=window.matchMedia(`(min-width: ${t.value})`),"addEventListener"in this.mql?this.mql.addEventListener("change",(()=>this.checkMode())):this.mql.addListener((()=>this.checkMode())),this.checkMode()}checkMode(){this.mql&&this.$menu&&this.$menuButton&&(this.mql.matches?(this.$menu.removeAttribute("hidden"),this.$menuButton.setAttribute("hidden","")):(this.$menuButton.removeAttribute("hidden"),this.$menuButton.setAttribute("aria-expanded",this.menuIsOpen.toString()),this.menuIsOpen?this.$menu.removeAttribute("hidden"):this.$menu.setAttribute("hidden","")))}handleMenuButtonClick(){this.menuIsOpen=!this.menuIsOpen,this.checkMode()}}S.moduleName="govuk-header";class E extends f{constructor(t,e={}){if(super(),this.$module=void 0,this.config=void 0,!(t instanceof HTMLElement))throw new g({componentName:"Notification banner",element:t,identifier:"Root element (`$module`)"});this.$module=t,this.config=n(E.defaults,e,h(E,t.dataset)),"alert"!==this.$module.getAttribute("role")||this.config.disableAutoFocus||l(this.$module)}}E.moduleName="govuk-notification-banner",E.defaults=Object.freeze({disableAutoFocus:!1}),E.schema=Object.freeze({properties:{disableAutoFocus:{type:"boolean"}}});class T extends f{constructor(t,e={}){if(super(),this.$module=void 0,this.config=void 0,this.i18n=void 0,this.$input=void 0,this.$showHideButton=void 0,this.$screenReaderStatusMessage=void 0,!(t instanceof HTMLElement))throw new g({componentName:"Password input",element:t,identifier:"Root element (`$module`)"});const s=t.querySelector(".govuk-js-password-input-input");if(!(s instanceof HTMLInputElement))throw new g({componentName:"Password input",element:s,expectedType:"HTMLInputElement",identifier:"Form field (`.govuk-js-password-input-input`)"});if("password"!==s.type)throw new g("Password input: Form field (`.govuk-js-password-input-input`) must be of type `password`.");const i=t.querySelector(".govuk-js-password-input-toggle");if(!(i instanceof HTMLButtonElement))throw new g({componentName:"Password input",element:i,expectedType:"HTMLButtonElement",identifier:"Button (`.govuk-js-password-input-toggle`)"});if("button"!==i.type)throw new g("Password input: Button (`.govuk-js-password-input-toggle`) must be of type `button`.");this.$module=t,this.$input=s,this.$showHideButton=i,this.config=n(T.defaults,e,h(T,t.dataset)),this.i18n=new b(this.config.i18n,{locale:y(t,"lang")}),this.$showHideButton.removeAttribute("hidden");const o=document.createElement("div");o.className="govuk-password-input__sr-status govuk-visually-hidden",o.setAttribute("aria-live","polite"),this.$screenReaderStatusMessage=o,this.$input.insertAdjacentElement("afterend",o),this.$showHideButton.addEventListener("click",this.toggle.bind(this)),this.$input.form&&this.$input.form.addEventListener("submit",(()=>this.hide())),window.addEventListener("pageshow",(t=>{t.persisted&&"password"!==this.$input.type&&this.hide()})),this.hide()}toggle(t){t.preventDefault(),"password"!==this.$input.type?this.hide():this.show()}show(){this.setType("text")}hide(){this.setType("password")}setType(t){if(t===this.$input.type)return;this.$input.setAttribute("type",t);const e="password"===t,s=e?"show":"hide",i=e?"passwordHidden":"passwordShown";this.$showHideButton.innerText=this.i18n.t(`${s}Password`),this.$showHideButton.setAttribute("aria-label",this.i18n.t(`${s}PasswordAriaLabel`)),this.$screenReaderStatusMessage.innerText=this.i18n.t(`${i}Announcement`)}}T.moduleName="govuk-password-input",T.defaults=Object.freeze({i18n:{showPassword:"Show",hidePassword:"Hide",showPasswordAriaLabel:"Show password",hidePasswordAriaLabel:"Hide password",passwordShownAnnouncement:"Your password is visible",passwordHiddenAnnouncement:"Your password is hidden"}}),T.schema=Object.freeze({properties:{i18n:{type:"object"}}});class L extends f{constructor(t){if(super(),this.$module=void 0,this.$inputs=void 0,!(t instanceof HTMLElement))throw new g({componentName:"Radios",element:t,identifier:"Root element (`$module`)"});const e=t.querySelectorAll('input[type="radio"]');if(!e.length)throw new g({componentName:"Radios",identifier:'Form inputs (`<input type="radio">`)'});this.$module=t,this.$inputs=e,this.$inputs.forEach((t=>{const e=t.getAttribute("data-aria-controls");if(e){if(!document.getElementById(e))throw new g({componentName:"Radios",identifier:`Conditional reveal (\`id="${e}"\`)`});t.setAttribute("aria-controls",e),t.removeAttribute("data-aria-controls")}})),window.addEventListener("pageshow",(()=>this.syncAllConditionalReveals())),this.syncAllConditionalReveals(),this.$module.addEventListener("click",(t=>this.handleClick(t)))}syncAllConditionalReveals(){this.$inputs.forEach((t=>this.syncConditionalRevealWithInputState(t)))}syncConditionalRevealWithInputState(t){const e=t.getAttribute("aria-controls");if(!e)return;const s=document.getElementById(e);if(null!=s&&s.classList.contains("govuk-radios__conditional")){const e=t.checked;t.setAttribute("aria-expanded",e.toString()),s.classList.toggle("govuk-radios__conditional--hidden",!e)}}handleClick(t){const e=t.target;if(!(e instanceof HTMLInputElement)||"radio"!==e.type)return;const s=document.querySelectorAll('input[type="radio"][aria-controls]'),i=e.form,n=e.name;s.forEach((t=>{const e=t.form===i;t.name===n&&e&&this.syncConditionalRevealWithInputState(t)}))}}L.moduleName="govuk-radios";class M extends f{constructor(t){var e;if(super(),this.$module=void 0,!(t instanceof HTMLAnchorElement))throw new g({componentName:"Skip link",element:t,expectedType:"HTMLAnchorElement",identifier:"Root element (`$module`)"});this.$module=t;const s=this.$module.hash,i=null!=(e=this.$module.getAttribute("href"))?e:"";let n;try{n=new window.URL(this.$module.href)}catch(t){throw new g(`Skip link: Target link (\`href="${i}"\`) is invalid`)}if(n.origin!==window.location.origin||n.pathname!==window.location.pathname)return;const o=r(s);if(!o)throw new g(`Skip link: Target link (\`href="${i}"\`) has no hash fragment`);const a=document.getElementById(o);if(!a)throw new g({componentName:"Skip link",element:a,identifier:`Target content (\`id="${o}"\`)`});this.$module.addEventListener("click",(()=>l(a,{onBeforeFocus(){a.classList.add("govuk-skip-link-focused-element")},onBlur(){a.classList.remove("govuk-skip-link-focused-element")}})))}}M.moduleName="govuk-skip-link";class I extends f{constructor(t){if(super(),this.$module=void 0,this.$tabs=void 0,this.$tabList=void 0,this.$tabListItems=void 0,this.jsHiddenClass="govuk-tabs__panel--hidden",this.changingHash=!1,this.boundTabClick=void 0,this.boundTabKeydown=void 0,this.boundOnHashChange=void 0,this.mql=null,!t)throw new g({componentName:"Tabs",element:t,identifier:"Root element (`$module`)"});const e=t.querySelectorAll("a.govuk-tabs__tab");if(!e.length)throw new g({componentName:"Tabs",identifier:'Links (`<a class="govuk-tabs__tab">`)'});this.$module=t,this.$tabs=e,this.boundTabClick=this.onTabClick.bind(this),this.boundTabKeydown=this.onTabKeydown.bind(this),this.boundOnHashChange=this.onHashChange.bind(this);const s=this.$module.querySelector(".govuk-tabs__list"),i=this.$module.querySelectorAll("li.govuk-tabs__list-item");if(!s)throw new g({componentName:"Tabs",identifier:'List (`<ul class="govuk-tabs__list">`)'});if(!i.length)throw new g({componentName:"Tabs",identifier:'List items (`<li class="govuk-tabs__list-item">`)'});this.$tabList=s,this.$tabListItems=i,this.setupResponsiveChecks()}setupResponsiveChecks(){const t=a("tablet");if(!t.value)throw new g({componentName:"Tabs",identifier:`CSS custom property (\`${t.property}\`) on pseudo-class \`:root\``});this.mql=window.matchMedia(`(min-width: ${t.value})`),"addEventListener"in this.mql?this.mql.addEventListener("change",(()=>this.checkMode())):this.mql.addListener((()=>this.checkMode())),this.checkMode()}checkMode(){var t;null!=(t=this.mql)&&t.matches?this.setup():this.teardown()}setup(){var t;this.$tabList.setAttribute("role","tablist"),this.$tabListItems.forEach((t=>{t.setAttribute("role","presentation")})),this.$tabs.forEach((t=>{this.setAttributes(t),t.addEventListener("click",this.boundTabClick,!0),t.addEventListener("keydown",this.boundTabKeydown,!0),this.hideTab(t)}));const e=null!=(t=this.getTab(window.location.hash))?t:this.$tabs[0];this.showTab(e),window.addEventListener("hashchange",this.boundOnHashChange,!0)}teardown(){this.$tabList.removeAttribute("role"),this.$tabListItems.forEach((t=>{t.removeAttribute("role")})),this.$tabs.forEach((t=>{t.removeEventListener("click",this.boundTabClick,!0),t.removeEventListener("keydown",this.boundTabKeydown,!0),this.unsetAttributes(t)})),window.removeEventListener("hashchange",this.boundOnHashChange,!0)}onHashChange(){const t=window.location.hash,e=this.getTab(t);if(!e)return;if(this.changingHash)return void(this.changingHash=!1);const s=this.getCurrentTab();s&&(this.hideTab(s),this.showTab(e),e.focus())}hideTab(t){this.unhighlightTab(t),this.hidePanel(t)}showTab(t){this.highlightTab(t),this.showPanel(t)}getTab(t){return this.$module.querySelector(`a.govuk-tabs__tab[href="${t}"]`)}setAttributes(t){const e=r(t.href);if(!e)return;t.setAttribute("id",`tab_${e}`),t.setAttribute("role","tab"),t.setAttribute("aria-controls",e),t.setAttribute("aria-selected","false"),t.setAttribute("tabindex","-1");const s=this.getPanel(t);s&&(s.setAttribute("role","tabpanel"),s.setAttribute("aria-labelledby",t.id),s.classList.add(this.jsHiddenClass))}unsetAttributes(t){t.removeAttribute("id"),t.removeAttribute("role"),t.removeAttribute("aria-controls"),t.removeAttribute("aria-selected"),t.removeAttribute("tabindex");const e=this.getPanel(t);e&&(e.removeAttribute("role"),e.removeAttribute("aria-labelledby"),e.classList.remove(this.jsHiddenClass))}onTabClick(t){const e=this.getCurrentTab(),s=t.currentTarget;e&&s instanceof HTMLAnchorElement&&(t.preventDefault(),this.hideTab(e),this.showTab(s),this.createHistoryEntry(s))}createHistoryEntry(t){const e=this.getPanel(t);if(!e)return;const s=e.id;e.id="",this.changingHash=!0,window.location.hash=s,e.id=s}onTabKeydown(t){switch(t.key){case"ArrowLeft":case"ArrowUp":case"Left":case"Up":this.activatePreviousTab(),t.preventDefault();break;case"ArrowRight":case"ArrowDown":case"Right":case"Down":this.activateNextTab(),t.preventDefault()}}activateNextTab(){const t=this.getCurrentTab();if(null==t||!t.parentElement)return;const e=t.parentElement.nextElementSibling;if(!e)return;const s=e.querySelector("a.govuk-tabs__tab");s&&(this.hideTab(t),this.showTab(s),s.focus(),this.createHistoryEntry(s))}activatePreviousTab(){const t=this.getCurrentTab();if(null==t||!t.parentElement)return;const e=t.parentElement.previousElementSibling;if(!e)return;const s=e.querySelector("a.govuk-tabs__tab");s&&(this.hideTab(t),this.showTab(s),s.focus(),this.createHistoryEntry(s))}getPanel(t){const e=r(t.href);return e?this.$module.querySelector(`#${e}`):null}showPanel(t){const e=this.getPanel(t);e&&e.classList.remove(this.jsHiddenClass)}hidePanel(t){const e=this.getPanel(t);e&&e.classList.add(this.jsHiddenClass)}unhighlightTab(t){t.parentElement&&(t.setAttribute("aria-selected","false"),t.parentElement.classList.remove("govuk-tabs__list-item--selected"),t.setAttribute("tabindex","-1"))}highlightTab(t){t.parentElement&&(t.setAttribute("aria-selected","true"),t.parentElement.classList.add("govuk-tabs__list-item--selected"),t.setAttribute("tabindex","0"))}getCurrentTab(){return this.$module.querySelector(".govuk-tabs__list-item--selected a.govuk-tabs__tab")}}function H(t){var e;if(t=void 0!==t?t:{},!c())return void console.log(new m);const s=[[v,t.accordion],[$,t.button],[k,t.characterCount],[C],[A,t.errorSummary],[x,t.exitThisPage],[S],[E,t.notificationBanner],[T,t.passwordInput],[L],[M],[I]],i=null!=(e=t.scope)?e:document;s.forEach((([t,e])=>{i.querySelectorAll(`[data-module="${t.moduleName}"]`).forEach((s=>{try{"defaults"in t?new t(s,e):new t(s)}catch(t){console.log(t)}}))}))}return I.moduleName="govuk-tabs",e}()}));
|
2
|
+
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.MODUK=e():t.MODUK=e()}(self,(function(){return function(){"use strict";var t={d:function(e,i){for(var n in i)t.o(i,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:i[n]})},o:function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r:function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{Accordion:function(){return y},Button:function(){return k},CharacterCount:function(){return A},Checkboxes:function(){return E},Component:function(){return m},ConfigurableComponent:function(){return f},ErrorSummary:function(){return x},ExitThisPage:function(){return S},FileUpload:function(){return T},Header:function(){return I},NotificationBanner:function(){return _},PasswordInput:function(){return M},Radios:function(){return B},ServiceNavigation:function(){return H},SkipLink:function(){return O},Tabs:function(){return j},createAll:function(){return F},initAll:function(){return q},isSupported:function(){return r},version:function(){return i}});const i="5.10.2";function n(t){if(t.includes("#"))return t.split("#").pop()}function s(t){const e=`--govuk-frontend-breakpoint-${t}`;return{property:e,value:window.getComputedStyle(document.documentElement).getPropertyValue(e)||void 0}}function o(t,e={}){var i;const n=t.getAttribute("tabindex");function s(){var i;null==(i=e.onBlur)||i.call(t),n||t.removeAttribute("tabindex")}n||t.setAttribute("tabindex","-1"),t.addEventListener("focus",(function(){t.addEventListener("blur",s,{once:!0})}),{once:!0}),null==(i=e.onBeforeFocus)||i.call(t),t.focus()}function r(t=document.body){return!!t&&t.classList.contains("govuk-frontend-supported")}function a(t){return!!t&&"object"==typeof t&&!function(t){return Array.isArray(t)}(t)}function u(t,e){return`${t.moduleName}: ${e}`}class l extends Error{constructor(...t){super(...t),this.name="GOVUKFrontendError"}}class c extends l{constructor(t=document.body){const e="noModule"in HTMLScriptElement.prototype?'GOV.UK Frontend initialised without `<body class="govuk-frontend-supported">` from template `<script>` snippet':"GOV.UK Frontend is not supported in this browser";super(t?e:'GOV.UK Frontend initialised without `<script type="module">`'),this.name="SupportError"}}class h extends l{constructor(...t){super(...t),this.name="ConfigError"}}class d extends l{constructor(t){let e="string"==typeof t?t:"";if("object"==typeof t){const{component:i,identifier:n,element:s,expectedType:o}=t;e=n,e+=s?` is not of type ${null!=o?o:"HTMLElement"}`:" not found",e=u(i,e)}super(e),this.name="ElementError"}}class p extends l{constructor(t){super("string"==typeof t?t:u(t,"Root element (`$root`) already initialised")),this.name="InitError"}}class m{get $root(){return this._$root}constructor(t){this._$root=void 0;const e=this.constructor;if("string"!=typeof e.moduleName)throw new p("`moduleName` not defined in component");if(!(t instanceof e.elementType))throw new d({element:t,component:e,identifier:"Root element (`$root`)",expectedType:e.elementType.name});this._$root=t,e.checkSupport(),this.checkInitialised();const i=e.moduleName;this.$root.setAttribute(`data-${i}-init`,"")}checkInitialised(){const t=this.constructor,e=t.moduleName;if(e&&function(t,e){return t instanceof HTMLElement&&t.hasAttribute(`data-${e}-init`)}(this.$root,e))throw new p(t)}static checkSupport(){if(!r())throw new c}}m.elementType=HTMLElement;const g=Symbol.for("configOverride");class f extends m{[g](t){return{}}get config(){return this._config}constructor(t,e){super(t),this._config=void 0;const i=this.constructor;if(!a(i.defaults))throw new h(u(i,"Config passed as parameter into constructor but no defaults defined"));const n=function(t,e){if(!a(t.schema))throw new h(u(t,"Config passed as parameter into constructor but no schema defined"));const i={},n=Object.entries(t.schema.properties);for(const s of n){const[n,o]=s,r=n.toString();r in e&&(i[r]=b(e[r],o)),"object"===(null==o?void 0:o.type)&&(i[r]=w(t.schema,e,n))}return i}(i,this._$root.dataset);this._config=v(i.defaults,null!=e?e:{},this[g](n),n)}}function b(t,e){const i=t?t.trim():"";let n,s=null==e?void 0:e.type;switch(s||(["true","false"].includes(i)&&(s="boolean"),i.length>0&&isFinite(Number(i))&&(s="number")),s){case"boolean":n="true"===i;break;case"number":n=Number(i);break;default:n=t}return n}function v(...t){const e={};for(const i of t)for(const t of Object.keys(i)){const n=e[t],s=i[t];a(n)&&a(s)?e[t]=v(n,s):e[t]=s}return e}function w(t,e,i){const n=t.properties[i];if("object"!==(null==n?void 0:n.type))return;const s={[i]:{}};for(const[t,n]of Object.entries(e)){let e=s;const o=t.split(".");for(const[s,r]of o.entries())a(e)&&(s<o.length-1?(a(e[r])||(e[r]={}),e=e[r]):t!==i&&(e[r]=b(n)))}return s[i]}class ${constructor(t={},e={}){var i;this.translations=void 0,this.locale=void 0,this.translations=t,this.locale=null!=(i=e.locale)?i:document.documentElement.lang||"en"}t(t,e){if(!t)throw new Error("i18n: lookup key missing");let i=this.translations[t];if("number"==typeof(null==e?void 0:e.count)&&"object"==typeof i){const n=i[this.getPluralSuffix(t,e.count)];n&&(i=n)}if("string"==typeof i){if(i.match(/%{(.\S+)}/)){if(!e)throw new Error("i18n: cannot replace placeholders in string if no option data provided");return this.replacePlaceholders(i,e)}return i}return t}replacePlaceholders(t,e){const i=Intl.NumberFormat.supportedLocalesOf(this.locale).length?new Intl.NumberFormat(this.locale):void 0;return t.replace(/%{(.\S+)}/g,(function(t,n){if(Object.prototype.hasOwnProperty.call(e,n)){const t=e[n];return!1===t||"number"!=typeof t&&"string"!=typeof t?"":"number"==typeof t?i?i.format(t):`${t}`:t}throw new Error(`i18n: no data found to replace ${t} placeholder in string`)}))}hasIntlPluralRulesSupport(){return Boolean("PluralRules"in window.Intl&&Intl.PluralRules.supportedLocalesOf(this.locale).length)}getPluralSuffix(t,e){if(e=Number(e),!isFinite(e))return"other";const i=this.translations[t],n=this.hasIntlPluralRulesSupport()?new Intl.PluralRules(this.locale).select(e):this.selectPluralFormUsingFallbackRules(e);if("object"==typeof i){if(n in i)return n;if("other"in i)return console.warn(`i18n: Missing plural form ".${n}" for "${this.locale}" locale. Falling back to ".other".`),"other"}throw new Error(`i18n: Plural form ".other" is required for "${this.locale}" locale`)}selectPluralFormUsingFallbackRules(t){t=Math.abs(Math.floor(t));const e=this.getPluralRulesForLocale();return e?$.pluralRules[e](t):"other"}getPluralRulesForLocale(){const t=this.locale.split("-")[0];for(const e in $.pluralRulesMap){const i=$.pluralRulesMap[e];if(i.includes(this.locale)||i.includes(t))return e}}}$.pluralRulesMap={arabic:["ar"],chinese:["my","zh","id","ja","jv","ko","ms","th","vi"],french:["hy","bn","fr","gu","hi","fa","pa","zu"],german:["af","sq","az","eu","bg","ca","da","nl","en","et","fi","ka","de","el","hu","lb","no","so","sw","sv","ta","te","tr","ur"],irish:["ga"],russian:["ru","uk"],scottish:["gd"],spanish:["pt-PT","it","es"],welsh:["cy"]},$.pluralRules={arabic(t){return 0===t?"zero":1===t?"one":2===t?"two":t%100>=3&&t%100<=10?"few":t%100>=11&&t%100<=99?"many":"other"},chinese(){return"other"},french(t){return 0===t||1===t?"one":"other"},german(t){return 1===t?"one":"other"},irish(t){return 1===t?"one":2===t?"two":t>=3&&t<=6?"few":t>=7&&t<=10?"many":"other"},russian(t){const e=t%100,i=e%10;return 1===i&&11!==e?"one":i>=2&&i<=4&&!(e>=12&&e<=14)?"few":0===i||i>=5&&i<=9||e>=11&&e<=14?"many":"other"},scottish(t){return 1===t||11===t?"one":2===t||12===t?"two":t>=3&&t<=10||t>=13&&t<=19?"few":"other"},spanish(t){return 1===t?"one":t%1e6==0&&0!==t?"many":"other"},welsh(t){return 0===t?"zero":1===t?"one":2===t?"two":3===t?"few":6===t?"many":"other"}};class y extends f{constructor(t,e={}){super(t,e),this.i18n=void 0,this.controlsClass="govuk-accordion__controls",this.showAllClass="govuk-accordion__show-all",this.showAllTextClass="govuk-accordion__show-all-text",this.sectionClass="govuk-accordion__section",this.sectionExpandedClass="govuk-accordion__section--expanded",this.sectionButtonClass="govuk-accordion__section-button",this.sectionHeaderClass="govuk-accordion__section-header",this.sectionHeadingClass="govuk-accordion__section-heading",this.sectionHeadingDividerClass="govuk-accordion__section-heading-divider",this.sectionHeadingTextClass="govuk-accordion__section-heading-text",this.sectionHeadingTextFocusClass="govuk-accordion__section-heading-text-focus",this.sectionShowHideToggleClass="govuk-accordion__section-toggle",this.sectionShowHideToggleFocusClass="govuk-accordion__section-toggle-focus",this.sectionShowHideTextClass="govuk-accordion__section-toggle-text",this.upChevronIconClass="govuk-accordion-nav__chevron",this.downChevronIconClass="govuk-accordion-nav__chevron--down",this.sectionSummaryClass="govuk-accordion__section-summary",this.sectionSummaryFocusClass="govuk-accordion__section-summary-focus",this.sectionContentClass="govuk-accordion__section-content",this.$sections=void 0,this.$showAllButton=null,this.$showAllIcon=null,this.$showAllText=null,this.i18n=new $(this.config.i18n);const i=this.$root.querySelectorAll(`.${this.sectionClass}`);if(!i.length)throw new d({component:y,identifier:`Sections (\`<div class="${this.sectionClass}">\`)`});this.$sections=i,this.initControls(),this.initSectionHeaders(),this.updateShowAllButton(this.areAllSectionsOpen())}initControls(){this.$showAllButton=document.createElement("button"),this.$showAllButton.setAttribute("type","button"),this.$showAllButton.setAttribute("class",this.showAllClass),this.$showAllButton.setAttribute("aria-expanded","false"),this.$showAllIcon=document.createElement("span"),this.$showAllIcon.classList.add(this.upChevronIconClass),this.$showAllButton.appendChild(this.$showAllIcon);const t=document.createElement("div");t.setAttribute("class",this.controlsClass),t.appendChild(this.$showAllButton),this.$root.insertBefore(t,this.$root.firstChild),this.$showAllText=document.createElement("span"),this.$showAllText.classList.add(this.showAllTextClass),this.$showAllButton.appendChild(this.$showAllText),this.$showAllButton.addEventListener("click",(()=>this.onShowOrHideAllToggle())),"onbeforematch"in document&&document.addEventListener("beforematch",(t=>this.onBeforeMatch(t)))}initSectionHeaders(){this.$sections.forEach(((t,e)=>{const i=t.querySelector(`.${this.sectionHeaderClass}`);if(!i)throw new d({component:y,identifier:`Section headers (\`<div class="${this.sectionHeaderClass}">\`)`});this.constructHeaderMarkup(i,e),this.setExpanded(this.isExpanded(t),t),i.addEventListener("click",(()=>this.onSectionToggle(t))),this.setInitialState(t)}))}constructHeaderMarkup(t,e){const i=t.querySelector(`.${this.sectionButtonClass}`),n=t.querySelector(`.${this.sectionHeadingClass}`),s=t.querySelector(`.${this.sectionSummaryClass}`);if(!n)throw new d({component:y,identifier:`Section heading (\`.${this.sectionHeadingClass}\`)`});if(!i)throw new d({component:y,identifier:`Section button placeholder (\`<span class="${this.sectionButtonClass}">\`)`});const o=document.createElement("button");o.setAttribute("type","button"),o.setAttribute("aria-controls",`${this.$root.id}-content-${e+1}`);for(const t of Array.from(i.attributes))"id"!==t.name&&o.setAttribute(t.name,t.value);const r=document.createElement("span");r.classList.add(this.sectionHeadingTextClass),r.id=i.id;const a=document.createElement("span");a.classList.add(this.sectionHeadingTextFocusClass),r.appendChild(a),Array.from(i.childNodes).forEach((t=>a.appendChild(t)));const u=document.createElement("span");u.classList.add(this.sectionShowHideToggleClass),u.setAttribute("data-nosnippet","");const l=document.createElement("span");l.classList.add(this.sectionShowHideToggleFocusClass),u.appendChild(l);const c=document.createElement("span"),h=document.createElement("span");if(h.classList.add(this.upChevronIconClass),l.appendChild(h),c.classList.add(this.sectionShowHideTextClass),l.appendChild(c),o.appendChild(r),o.appendChild(this.getButtonPunctuationEl()),s){const t=document.createElement("span"),e=document.createElement("span");e.classList.add(this.sectionSummaryFocusClass),t.appendChild(e);for(const e of Array.from(s.attributes))t.setAttribute(e.name,e.value);Array.from(s.childNodes).forEach((t=>e.appendChild(t))),s.remove(),o.appendChild(t),o.appendChild(this.getButtonPunctuationEl())}o.appendChild(u),n.removeChild(i),n.appendChild(o)}onBeforeMatch(t){const e=t.target;if(!(e instanceof Element))return;const i=e.closest(`.${this.sectionClass}`);i&&this.setExpanded(!0,i)}onSectionToggle(t){const e=!this.isExpanded(t);this.setExpanded(e,t),this.storeState(t,e)}onShowOrHideAllToggle(){const t=!this.areAllSectionsOpen();this.$sections.forEach((e=>{this.setExpanded(t,e),this.storeState(e,t)})),this.updateShowAllButton(t)}setExpanded(t,e){const i=e.querySelector(`.${this.upChevronIconClass}`),n=e.querySelector(`.${this.sectionShowHideTextClass}`),s=e.querySelector(`.${this.sectionButtonClass}`),o=e.querySelector(`.${this.sectionContentClass}`);if(!o)throw new d({component:y,identifier:`Section content (\`<div class="${this.sectionContentClass}">\`)`});if(!i||!n||!s)return;const r=t?this.i18n.t("hideSection"):this.i18n.t("showSection");n.textContent=r,s.setAttribute("aria-expanded",`${t}`);const a=[],u=e.querySelector(`.${this.sectionHeadingTextClass}`);u&&a.push(`${u.textContent}`.trim());const l=e.querySelector(`.${this.sectionSummaryClass}`);l&&a.push(`${l.textContent}`.trim());const c=t?this.i18n.t("hideSectionAriaLabel"):this.i18n.t("showSectionAriaLabel");a.push(c),s.setAttribute("aria-label",a.join(" , ")),t?(o.removeAttribute("hidden"),e.classList.add(this.sectionExpandedClass),i.classList.remove(this.downChevronIconClass)):(o.setAttribute("hidden","until-found"),e.classList.remove(this.sectionExpandedClass),i.classList.add(this.downChevronIconClass)),this.updateShowAllButton(this.areAllSectionsOpen())}isExpanded(t){return t.classList.contains(this.sectionExpandedClass)}areAllSectionsOpen(){return Array.from(this.$sections).every((t=>this.isExpanded(t)))}updateShowAllButton(t){this.$showAllButton&&this.$showAllText&&this.$showAllIcon&&(this.$showAllButton.setAttribute("aria-expanded",t.toString()),this.$showAllText.textContent=t?this.i18n.t("hideAllSections"):this.i18n.t("showAllSections"),this.$showAllIcon.classList.toggle(this.downChevronIconClass,!t))}getIdentifier(t){const e=t.querySelector(`.${this.sectionButtonClass}`);return null==e?void 0:e.getAttribute("aria-controls")}storeState(t,e){if(!this.config.rememberExpanded)return;const i=this.getIdentifier(t);if(i)try{window.sessionStorage.setItem(i,e.toString())}catch(t){}}setInitialState(t){if(!this.config.rememberExpanded)return;const e=this.getIdentifier(t);if(e)try{const i=window.sessionStorage.getItem(e);null!==i&&this.setExpanded("true"===i,t)}catch(t){}}getButtonPunctuationEl(){const t=document.createElement("span");return t.classList.add("govuk-visually-hidden",this.sectionHeadingDividerClass),t.textContent=", ",t}}y.moduleName="govuk-accordion",y.defaults=Object.freeze({i18n:{hideAllSections:"Hide all sections",hideSection:"Hide",hideSectionAriaLabel:"Hide this section",showAllSections:"Show all sections",showSection:"Show",showSectionAriaLabel:"Show this section"},rememberExpanded:!0}),y.schema=Object.freeze({properties:{i18n:{type:"object"},rememberExpanded:{type:"boolean"}}});class k extends f{constructor(t,e={}){super(t,e),this.debounceFormSubmitTimer=null,this.$root.addEventListener("keydown",(t=>this.handleKeyDown(t))),this.$root.addEventListener("click",(t=>this.debounce(t)))}handleKeyDown(t){const e=t.target;" "===t.key&&e instanceof HTMLElement&&"button"===e.getAttribute("role")&&(t.preventDefault(),e.click())}debounce(t){if(this.config.preventDoubleClick)return this.debounceFormSubmitTimer?(t.preventDefault(),!1):void(this.debounceFormSubmitTimer=window.setTimeout((()=>{this.debounceFormSubmitTimer=null}),1e3))}}function C(t,e){const i=t.closest(`[${e}]`);return i?i.getAttribute(e):null}k.moduleName="govuk-button",k.defaults=Object.freeze({preventDoubleClick:!1}),k.schema=Object.freeze({properties:{preventDoubleClick:{type:"boolean"}}});class A extends f{[g](t){let e={};return("maxwords"in t||"maxlength"in t)&&(e={maxlength:void 0,maxwords:void 0}),e}constructor(t,e={}){var i,n;super(t,e),this.$textarea=void 0,this.$visibleCountMessage=void 0,this.$screenReaderCountMessage=void 0,this.lastInputTimestamp=null,this.lastInputValue="",this.valueChecker=null,this.i18n=void 0,this.maxLength=void 0;const s=this.$root.querySelector(".govuk-js-character-count");if(!(s instanceof HTMLTextAreaElement||s instanceof HTMLInputElement))throw new d({component:A,element:s,expectedType:"HTMLTextareaElement or HTMLInputElement",identifier:"Form field (`.govuk-js-character-count`)"});const o=function(t,e){const i=[];for(const[n,s]of Object.entries(t)){const t=[];if(Array.isArray(s)){for(const{required:i,errorMessage:n}of s)i.every((t=>!!e[t]))||t.push(n);"anyOf"!==n||s.length-t.length>=1||i.push(...t)}}return i}(A.schema,this.config);if(o[0])throw new h(u(A,o[0]));this.i18n=new $(this.config.i18n,{locale:C(this.$root,"lang")}),this.maxLength=null!=(i=null!=(n=this.config.maxwords)?n:this.config.maxlength)?i:1/0,this.$textarea=s;const r=`${this.$textarea.id}-info`,a=document.getElementById(r);if(!a)throw new d({component:A,element:a,identifier:`Count message (\`id="${r}"\`)`});this.$errorMessage=this.$root.querySelector(".govuk-error-message"),`${a.textContent}`.match(/^\s*$/)&&(a.textContent=this.i18n.t("textareaDescription",{count:this.maxLength})),this.$textarea.insertAdjacentElement("afterend",a);const l=document.createElement("div");l.className="govuk-character-count__sr-status govuk-visually-hidden",l.setAttribute("aria-live","polite"),this.$screenReaderCountMessage=l,a.insertAdjacentElement("afterend",l);const c=document.createElement("div");c.className=a.className,c.classList.add("govuk-character-count__status"),c.setAttribute("aria-hidden","true"),this.$visibleCountMessage=c,a.insertAdjacentElement("afterend",c),a.classList.add("govuk-visually-hidden"),this.$textarea.removeAttribute("maxlength"),this.bindChangeEvents(),window.addEventListener("pageshow",(()=>this.updateCountMessage())),this.updateCountMessage()}bindChangeEvents(){this.$textarea.addEventListener("keyup",(()=>this.handleKeyUp())),this.$textarea.addEventListener("focus",(()=>this.handleFocus())),this.$textarea.addEventListener("blur",(()=>this.handleBlur()))}handleKeyUp(){this.updateVisibleCountMessage(),this.lastInputTimestamp=Date.now()}handleFocus(){this.valueChecker=window.setInterval((()=>{(!this.lastInputTimestamp||Date.now()-500>=this.lastInputTimestamp)&&this.updateIfValueChanged()}),1e3)}handleBlur(){this.valueChecker&&window.clearInterval(this.valueChecker)}updateIfValueChanged(){this.$textarea.value!==this.lastInputValue&&(this.lastInputValue=this.$textarea.value,this.updateCountMessage())}updateCountMessage(){this.updateVisibleCountMessage(),this.updateScreenReaderCountMessage()}updateVisibleCountMessage(){const t=this.maxLength-this.count(this.$textarea.value)<0;this.$visibleCountMessage.classList.toggle("govuk-character-count__message--disabled",!this.isOverThreshold()),this.$errorMessage||this.$textarea.classList.toggle("govuk-textarea--error",t),this.$visibleCountMessage.classList.toggle("govuk-error-message",t),this.$visibleCountMessage.classList.toggle("govuk-hint",!t),this.$visibleCountMessage.textContent=this.getCountMessage()}updateScreenReaderCountMessage(){this.isOverThreshold()?this.$screenReaderCountMessage.removeAttribute("aria-hidden"):this.$screenReaderCountMessage.setAttribute("aria-hidden","true"),this.$screenReaderCountMessage.textContent=this.getCountMessage()}count(t){var e;return this.config.maxwords?(null!=(e=t.match(/\S+/g))?e:[]).length:t.length}getCountMessage(){const t=this.maxLength-this.count(this.$textarea.value),e=this.config.maxwords?"words":"characters";return this.formatCountMessage(t,e)}formatCountMessage(t,e){if(0===t)return this.i18n.t(`${e}AtLimit`);const i=t<0?"OverLimit":"UnderLimit";return this.i18n.t(`${e}${i}`,{count:Math.abs(t)})}isOverThreshold(){if(!this.config.threshold)return!0;const t=this.count(this.$textarea.value);return this.maxLength*this.config.threshold/100<=t}}A.moduleName="govuk-character-count",A.defaults=Object.freeze({threshold:0,i18n:{charactersUnderLimit:{one:"You have %{count} character remaining",other:"You have %{count} characters remaining"},charactersAtLimit:"You have 0 characters remaining",charactersOverLimit:{one:"You have %{count} character too many",other:"You have %{count} characters too many"},wordsUnderLimit:{one:"You have %{count} word remaining",other:"You have %{count} words remaining"},wordsAtLimit:"You have 0 words remaining",wordsOverLimit:{one:"You have %{count} word too many",other:"You have %{count} words too many"},textareaDescription:{other:""}}}),A.schema=Object.freeze({properties:{i18n:{type:"object"},maxwords:{type:"number"},maxlength:{type:"number"},threshold:{type:"number"}},anyOf:[{required:["maxwords"],errorMessage:'Either "maxlength" or "maxwords" must be provided'},{required:["maxlength"],errorMessage:'Either "maxlength" or "maxwords" must be provided'}]});class E extends m{constructor(t){super(t),this.$inputs=void 0;const e=this.$root.querySelectorAll('input[type="checkbox"]');if(!e.length)throw new d({component:E,identifier:'Form inputs (`<input type="checkbox">`)'});this.$inputs=e,this.$inputs.forEach((t=>{const e=t.getAttribute("data-aria-controls");if(e){if(!document.getElementById(e))throw new d({component:E,identifier:`Conditional reveal (\`id="${e}"\`)`});t.setAttribute("aria-controls",e),t.removeAttribute("data-aria-controls")}})),window.addEventListener("pageshow",(()=>this.syncAllConditionalReveals())),this.syncAllConditionalReveals(),this.$root.addEventListener("click",(t=>this.handleClick(t)))}syncAllConditionalReveals(){this.$inputs.forEach((t=>this.syncConditionalRevealWithInputState(t)))}syncConditionalRevealWithInputState(t){const e=t.getAttribute("aria-controls");if(!e)return;const i=document.getElementById(e);if(null!=i&&i.classList.contains("govuk-checkboxes__conditional")){const e=t.checked;t.setAttribute("aria-expanded",e.toString()),i.classList.toggle("govuk-checkboxes__conditional--hidden",!e)}}unCheckAllInputsExcept(t){document.querySelectorAll(`input[type="checkbox"][name="${t.name}"]`).forEach((e=>{t.form===e.form&&e!==t&&(e.checked=!1,this.syncConditionalRevealWithInputState(e))}))}unCheckExclusiveInputs(t){document.querySelectorAll(`input[data-behaviour="exclusive"][type="checkbox"][name="${t.name}"]`).forEach((e=>{t.form===e.form&&(e.checked=!1,this.syncConditionalRevealWithInputState(e))}))}handleClick(t){const e=t.target;e instanceof HTMLInputElement&&"checkbox"===e.type&&(e.getAttribute("aria-controls")&&this.syncConditionalRevealWithInputState(e),e.checked&&("exclusive"===e.getAttribute("data-behaviour")?this.unCheckAllInputsExcept(e):this.unCheckExclusiveInputs(e)))}}E.moduleName="govuk-checkboxes";class x extends f{constructor(t,e={}){super(t,e),this.config.disableAutoFocus||o(this.$root),this.$root.addEventListener("click",(t=>this.handleClick(t)))}handleClick(t){const e=t.target;e&&this.focusTarget(e)&&t.preventDefault()}focusTarget(t){if(!(t instanceof HTMLAnchorElement))return!1;const e=n(t.href);if(!e)return!1;const i=document.getElementById(e);if(!i)return!1;const s=this.getAssociatedLegendOrLabel(i);return!!s&&(s.scrollIntoView(),i.focus({preventScroll:!0}),!0)}getAssociatedLegendOrLabel(t){var e;const i=t.closest("fieldset");if(i){const e=i.getElementsByTagName("legend");if(e.length){const i=e[0];if(t instanceof HTMLInputElement&&("checkbox"===t.type||"radio"===t.type))return i;const n=i.getBoundingClientRect().top,s=t.getBoundingClientRect();if(s.height&&window.innerHeight&&s.top+s.height-n<window.innerHeight/2)return i}}return null!=(e=document.querySelector(`label[for='${t.getAttribute("id")}']`))?e:t.closest("label")}}x.moduleName="govuk-error-summary",x.defaults=Object.freeze({disableAutoFocus:!1}),x.schema=Object.freeze({properties:{disableAutoFocus:{type:"boolean"}}});class S extends f{constructor(t,e={}){super(t,e),this.i18n=void 0,this.$button=void 0,this.$skiplinkButton=null,this.$updateSpan=null,this.$indicatorContainer=null,this.$overlay=null,this.keypressCounter=0,this.lastKeyWasModified=!1,this.timeoutTime=5e3,this.keypressTimeoutId=null,this.timeoutMessageId=null;const i=this.$root.querySelector(".govuk-exit-this-page__button");if(!(i instanceof HTMLAnchorElement))throw new d({component:S,element:i,expectedType:"HTMLAnchorElement",identifier:"Button (`.govuk-exit-this-page__button`)"});this.i18n=new $(this.config.i18n),this.$button=i;const n=document.querySelector(".govuk-js-exit-this-page-skiplink");n instanceof HTMLAnchorElement&&(this.$skiplinkButton=n),this.buildIndicator(),this.initUpdateSpan(),this.initButtonClickHandler(),"govukFrontendExitThisPageKeypress"in document.body.dataset||(document.addEventListener("keyup",this.handleKeypress.bind(this),!0),document.body.dataset.govukFrontendExitThisPageKeypress="true"),window.addEventListener("pageshow",this.resetPage.bind(this))}initUpdateSpan(){this.$updateSpan=document.createElement("span"),this.$updateSpan.setAttribute("role","status"),this.$updateSpan.className="govuk-visually-hidden",this.$root.appendChild(this.$updateSpan)}initButtonClickHandler(){this.$button.addEventListener("click",this.handleClick.bind(this)),this.$skiplinkButton&&this.$skiplinkButton.addEventListener("click",this.handleClick.bind(this))}buildIndicator(){this.$indicatorContainer=document.createElement("div"),this.$indicatorContainer.className="govuk-exit-this-page__indicator",this.$indicatorContainer.setAttribute("aria-hidden","true");for(let t=0;t<3;t++){const t=document.createElement("div");t.className="govuk-exit-this-page__indicator-light",this.$indicatorContainer.appendChild(t)}this.$button.appendChild(this.$indicatorContainer)}updateIndicator(){this.$indicatorContainer&&(this.$indicatorContainer.classList.toggle("govuk-exit-this-page__indicator--visible",this.keypressCounter>0),this.$indicatorContainer.querySelectorAll(".govuk-exit-this-page__indicator-light").forEach(((t,e)=>{t.classList.toggle("govuk-exit-this-page__indicator-light--on",e<this.keypressCounter)})))}exitPage(){this.$updateSpan&&(this.$updateSpan.textContent="",document.body.classList.add("govuk-exit-this-page-hide-content"),this.$overlay=document.createElement("div"),this.$overlay.className="govuk-exit-this-page-overlay",this.$overlay.setAttribute("role","alert"),document.body.appendChild(this.$overlay),this.$overlay.textContent=this.i18n.t("activated"),window.location.href=this.$button.href)}handleClick(t){t.preventDefault(),this.exitPage()}handleKeypress(t){this.$updateSpan&&("Shift"!==t.key||this.lastKeyWasModified?this.keypressTimeoutId&&this.resetKeypressTimer():(this.keypressCounter+=1,this.updateIndicator(),this.timeoutMessageId&&(window.clearTimeout(this.timeoutMessageId),this.timeoutMessageId=null),this.keypressCounter>=3?(this.keypressCounter=0,this.keypressTimeoutId&&(window.clearTimeout(this.keypressTimeoutId),this.keypressTimeoutId=null),this.exitPage()):1===this.keypressCounter?this.$updateSpan.textContent=this.i18n.t("pressTwoMoreTimes"):this.$updateSpan.textContent=this.i18n.t("pressOneMoreTime"),this.setKeypressTimer()),this.lastKeyWasModified=t.shiftKey)}setKeypressTimer(){this.keypressTimeoutId&&window.clearTimeout(this.keypressTimeoutId),this.keypressTimeoutId=window.setTimeout(this.resetKeypressTimer.bind(this),this.timeoutTime)}resetKeypressTimer(){if(!this.$updateSpan)return;this.keypressTimeoutId&&(window.clearTimeout(this.keypressTimeoutId),this.keypressTimeoutId=null);const t=this.$updateSpan;this.keypressCounter=0,t.textContent=this.i18n.t("timedOut"),this.timeoutMessageId=window.setTimeout((()=>{t.textContent=""}),this.timeoutTime),this.updateIndicator()}resetPage(){document.body.classList.remove("govuk-exit-this-page-hide-content"),this.$overlay&&(this.$overlay.remove(),this.$overlay=null),this.$updateSpan&&(this.$updateSpan.setAttribute("role","status"),this.$updateSpan.textContent=""),this.updateIndicator(),this.keypressTimeoutId&&window.clearTimeout(this.keypressTimeoutId),this.timeoutMessageId&&window.clearTimeout(this.timeoutMessageId)}}S.moduleName="govuk-exit-this-page",S.defaults=Object.freeze({i18n:{activated:"Loading.",timedOut:"Exit this page expired.",pressTwoMoreTimes:"Shift, press 2 more times to exit.",pressOneMoreTime:"Shift, press 1 more time to exit."}}),S.schema=Object.freeze({properties:{i18n:{type:"object"}}});class T extends f{constructor(t,e={}){super(t,e),this.$input=void 0,this.$button=void 0,this.$status=void 0,this.i18n=void 0,this.id=void 0,this.$announcements=void 0,this.enteredAnotherElement=void 0;const i=this.$root.querySelector("input");if(null===i)throw new d({component:T,identifier:'File inputs (`<input type="file">`)'});if("file"!==i.type)throw new d(u(T,'File input (`<input type="file">`) attribute (`type`) is not `file`'));if(this.$input=i,this.$input.setAttribute("hidden","true"),!this.$input.id)throw new d({component:T,identifier:'File input (`<input type="file">`) attribute (`id`)'});this.id=this.$input.id,this.i18n=new $(this.config.i18n,{locale:C(this.$root,"lang")});const n=this.findLabel();n.id||(n.id=`${this.id}-label`),this.$input.id=`${this.id}-input`;const s=document.createElement("button");s.classList.add("govuk-file-upload-button"),s.type="button",s.id=this.id,s.classList.add("govuk-file-upload-button--empty");const o=this.$input.getAttribute("aria-describedby");o&&s.setAttribute("aria-describedby",o);const r=document.createElement("span");r.className="govuk-body govuk-file-upload-button__status",r.setAttribute("aria-live","polite"),r.innerText=this.i18n.t("noFileChosen"),s.appendChild(r);const a=document.createElement("span");a.className="govuk-visually-hidden",a.innerText=", ",a.id=`${this.id}-comma`,s.appendChild(a);const l=document.createElement("span");l.className="govuk-file-upload-button__pseudo-button-container";const c=document.createElement("span");c.className="govuk-button govuk-button--secondary govuk-file-upload-button__pseudo-button",c.innerText=this.i18n.t("chooseFilesButton"),l.appendChild(c),l.insertAdjacentText("beforeend"," ");const h=document.createElement("span");h.className="govuk-body govuk-file-upload-button__instruction",h.innerText=this.i18n.t("dropInstruction"),l.appendChild(h),s.appendChild(l),s.setAttribute("aria-labelledby",`${n.id} ${a.id} ${s.id}`),s.addEventListener("click",this.onClick.bind(this)),s.addEventListener("dragover",(t=>{t.preventDefault()})),this.$root.insertAdjacentElement("afterbegin",s),this.$input.setAttribute("tabindex","-1"),this.$input.setAttribute("aria-hidden","true"),this.$button=s,this.$status=r,this.$input.addEventListener("change",this.onChange.bind(this)),this.updateDisabledState(),this.observeDisabledState(),this.$announcements=document.createElement("span"),this.$announcements.classList.add("govuk-file-upload-announcements"),this.$announcements.classList.add("govuk-visually-hidden"),this.$announcements.setAttribute("aria-live","assertive"),this.$root.insertAdjacentElement("afterend",this.$announcements),this.$button.addEventListener("drop",this.onDrop.bind(this)),document.addEventListener("dragenter",this.updateDropzoneVisibility.bind(this)),document.addEventListener("dragenter",(()=>{this.enteredAnotherElement=!0})),document.addEventListener("dragleave",(()=>{this.enteredAnotherElement||this.$button.disabled||(this.hideDraggingState(),this.$announcements.innerText=this.i18n.t("leftDropZone")),this.enteredAnotherElement=!1}))}updateDropzoneVisibility(t){this.$button.disabled||t.target instanceof Node&&(this.$root.contains(t.target)?t.dataTransfer&&L(t.dataTransfer)&&(this.$button.classList.contains("govuk-file-upload-button--dragging")||(this.showDraggingState(),this.$announcements.innerText=this.i18n.t("enteredDropZone"))):this.$button.classList.contains("govuk-file-upload-button--dragging")&&(this.hideDraggingState(),this.$announcements.innerText=this.i18n.t("leftDropZone")))}showDraggingState(){this.$button.classList.add("govuk-file-upload-button--dragging")}hideDraggingState(){this.$button.classList.remove("govuk-file-upload-button--dragging")}onDrop(t){t.preventDefault(),t.dataTransfer&&L(t.dataTransfer)&&(this.$input.files=t.dataTransfer.files,this.$input.dispatchEvent(new CustomEvent("change")),this.hideDraggingState())}onChange(){const t=this.$input.files.length;0===t?(this.$status.innerText=this.i18n.t("noFileChosen"),this.$button.classList.add("govuk-file-upload-button--empty")):(this.$status.innerText=1===t?this.$input.files[0].name:this.i18n.t("multipleFilesChosen",{count:t}),this.$button.classList.remove("govuk-file-upload-button--empty"))}findLabel(){const t=document.querySelector(`label[for="${this.$input.id}"]`);if(!t)throw new d({component:T,identifier:`Field label (\`<label for=${this.$input.id}>\`)`});return t}onClick(){this.$input.click()}observeDisabledState(){new MutationObserver((t=>{for(const e of t)"attributes"===e.type&&"disabled"===e.attributeName&&this.updateDisabledState()})).observe(this.$input,{attributes:!0})}updateDisabledState(){this.$button.disabled=this.$input.disabled,this.$root.classList.toggle("govuk-drop-zone--disabled",this.$button.disabled)}}function L(t){const e=0===t.types.length,i=t.types.some((t=>"Files"===t));return e||i}T.moduleName="govuk-file-upload",T.defaults=Object.freeze({i18n:{chooseFilesButton:"Choose file",dropInstruction:"or drop file",noFileChosen:"No file chosen",multipleFilesChosen:{one:"%{count} file chosen",other:"%{count} files chosen"},enteredDropZone:"Entered drop zone",leftDropZone:"Left drop zone"}}),T.schema=Object.freeze({properties:{i18n:{type:"object"}}});class I extends m{constructor(t){super(t),this.$menuButton=void 0,this.$menu=void 0,this.menuIsOpen=!1,this.mql=null;const e=this.$root.querySelector(".govuk-js-header-toggle");if(!e)return this;this.$root.classList.add("govuk-header--with-js-navigation");const i=e.getAttribute("aria-controls");if(!i)throw new d({component:I,identifier:'Navigation button (`<button class="govuk-js-header-toggle">`) attribute (`aria-controls`)'});const n=document.getElementById(i);if(!n)throw new d({component:I,element:n,identifier:`Navigation (\`<ul id="${i}">\`)`});this.$menu=n,this.$menuButton=e,this.setupResponsiveChecks(),this.$menuButton.addEventListener("click",(()=>this.handleMenuButtonClick()))}setupResponsiveChecks(){const t=s("desktop");if(!t.value)throw new d({component:I,identifier:`CSS custom property (\`${t.property}\`) on pseudo-class \`:root\``});this.mql=window.matchMedia(`(min-width: ${t.value})`),"addEventListener"in this.mql?this.mql.addEventListener("change",(()=>this.checkMode())):this.mql.addListener((()=>this.checkMode())),this.checkMode()}checkMode(){this.mql&&this.$menu&&this.$menuButton&&(this.mql.matches?(this.$menu.removeAttribute("hidden"),this.$menuButton.setAttribute("hidden","")):(this.$menuButton.removeAttribute("hidden"),this.$menuButton.setAttribute("aria-expanded",this.menuIsOpen.toString()),this.menuIsOpen?this.$menu.removeAttribute("hidden"):this.$menu.setAttribute("hidden","")))}handleMenuButtonClick(){this.menuIsOpen=!this.menuIsOpen,this.checkMode()}}I.moduleName="govuk-header";class _ extends f{constructor(t,e={}){super(t,e),"alert"!==this.$root.getAttribute("role")||this.config.disableAutoFocus||o(this.$root)}}_.moduleName="govuk-notification-banner",_.defaults=Object.freeze({disableAutoFocus:!1}),_.schema=Object.freeze({properties:{disableAutoFocus:{type:"boolean"}}});class M extends f{constructor(t,e={}){super(t,e),this.i18n=void 0,this.$input=void 0,this.$showHideButton=void 0,this.$screenReaderStatusMessage=void 0;const i=this.$root.querySelector(".govuk-js-password-input-input");if(!(i instanceof HTMLInputElement))throw new d({component:M,element:i,expectedType:"HTMLInputElement",identifier:"Form field (`.govuk-js-password-input-input`)"});if("password"!==i.type)throw new d("Password input: Form field (`.govuk-js-password-input-input`) must be of type `password`.");const n=this.$root.querySelector(".govuk-js-password-input-toggle");if(!(n instanceof HTMLButtonElement))throw new d({component:M,element:n,expectedType:"HTMLButtonElement",identifier:"Button (`.govuk-js-password-input-toggle`)"});if("button"!==n.type)throw new d("Password input: Button (`.govuk-js-password-input-toggle`) must be of type `button`.");this.$input=i,this.$showHideButton=n,this.i18n=new $(this.config.i18n,{locale:C(this.$root,"lang")}),this.$showHideButton.removeAttribute("hidden");const s=document.createElement("div");s.className="govuk-password-input__sr-status govuk-visually-hidden",s.setAttribute("aria-live","polite"),this.$screenReaderStatusMessage=s,this.$input.insertAdjacentElement("afterend",s),this.$showHideButton.addEventListener("click",this.toggle.bind(this)),this.$input.form&&this.$input.form.addEventListener("submit",(()=>this.hide())),window.addEventListener("pageshow",(t=>{t.persisted&&"password"!==this.$input.type&&this.hide()})),this.hide()}toggle(t){t.preventDefault(),"password"!==this.$input.type?this.hide():this.show()}show(){this.setType("text")}hide(){this.setType("password")}setType(t){if(t===this.$input.type)return;this.$input.setAttribute("type",t);const e="password"===t,i=e?"show":"hide",n=e?"passwordHidden":"passwordShown";this.$showHideButton.innerText=this.i18n.t(`${i}Password`),this.$showHideButton.setAttribute("aria-label",this.i18n.t(`${i}PasswordAriaLabel`)),this.$screenReaderStatusMessage.innerText=this.i18n.t(`${n}Announcement`)}}M.moduleName="govuk-password-input",M.defaults=Object.freeze({i18n:{showPassword:"Show",hidePassword:"Hide",showPasswordAriaLabel:"Show password",hidePasswordAriaLabel:"Hide password",passwordShownAnnouncement:"Your password is visible",passwordHiddenAnnouncement:"Your password is hidden"}}),M.schema=Object.freeze({properties:{i18n:{type:"object"}}});class B extends m{constructor(t){super(t),this.$inputs=void 0;const e=this.$root.querySelectorAll('input[type="radio"]');if(!e.length)throw new d({component:B,identifier:'Form inputs (`<input type="radio">`)'});this.$inputs=e,this.$inputs.forEach((t=>{const e=t.getAttribute("data-aria-controls");if(e){if(!document.getElementById(e))throw new d({component:B,identifier:`Conditional reveal (\`id="${e}"\`)`});t.setAttribute("aria-controls",e),t.removeAttribute("data-aria-controls")}})),window.addEventListener("pageshow",(()=>this.syncAllConditionalReveals())),this.syncAllConditionalReveals(),this.$root.addEventListener("click",(t=>this.handleClick(t)))}syncAllConditionalReveals(){this.$inputs.forEach((t=>this.syncConditionalRevealWithInputState(t)))}syncConditionalRevealWithInputState(t){const e=t.getAttribute("aria-controls");if(!e)return;const i=document.getElementById(e);if(null!=i&&i.classList.contains("govuk-radios__conditional")){const e=t.checked;t.setAttribute("aria-expanded",e.toString()),i.classList.toggle("govuk-radios__conditional--hidden",!e)}}handleClick(t){const e=t.target;if(!(e instanceof HTMLInputElement)||"radio"!==e.type)return;const i=document.querySelectorAll('input[type="radio"][aria-controls]'),n=e.form,s=e.name;i.forEach((t=>{const e=t.form===n;t.name===s&&e&&this.syncConditionalRevealWithInputState(t)}))}}B.moduleName="govuk-radios";class H extends m{constructor(t){super(t),this.$menuButton=void 0,this.$menu=void 0,this.menuIsOpen=!1,this.mql=null;const e=this.$root.querySelector(".govuk-js-service-navigation-toggle");if(!e)return this;const i=e.getAttribute("aria-controls");if(!i)throw new d({component:H,identifier:'Navigation button (`<button class="govuk-js-service-navigation-toggle">`) attribute (`aria-controls`)'});const n=document.getElementById(i);if(!n)throw new d({component:H,element:n,identifier:`Navigation (\`<ul id="${i}">\`)`});this.$menu=n,this.$menuButton=e,this.setupResponsiveChecks(),this.$menuButton.addEventListener("click",(()=>this.handleMenuButtonClick()))}setupResponsiveChecks(){const t=s("tablet");if(!t.value)throw new d({component:H,identifier:`CSS custom property (\`${t.property}\`) on pseudo-class \`:root\``});this.mql=window.matchMedia(`(min-width: ${t.value})`),"addEventListener"in this.mql?this.mql.addEventListener("change",(()=>this.checkMode())):this.mql.addListener((()=>this.checkMode())),this.checkMode()}checkMode(){this.mql&&this.$menu&&this.$menuButton&&(this.mql.matches?(this.$menu.removeAttribute("hidden"),this.$menuButton.setAttribute("hidden","")):(this.$menuButton.removeAttribute("hidden"),this.$menuButton.setAttribute("aria-expanded",this.menuIsOpen.toString()),this.menuIsOpen?this.$menu.removeAttribute("hidden"):this.$menu.setAttribute("hidden","")))}handleMenuButtonClick(){this.menuIsOpen=!this.menuIsOpen,this.checkMode()}}H.moduleName="govuk-service-navigation";class O extends m{constructor(t){var e;super(t);const i=this.$root.hash,s=null!=(e=this.$root.getAttribute("href"))?e:"";let r;try{r=new window.URL(this.$root.href)}catch(t){throw new d(`Skip link: Target link (\`href="${s}"\`) is invalid`)}if(r.origin!==window.location.origin||r.pathname!==window.location.pathname)return;const a=n(i);if(!a)throw new d(`Skip link: Target link (\`href="${s}"\`) has no hash fragment`);const u=document.getElementById(a);if(!u)throw new d({component:O,element:u,identifier:`Target content (\`id="${a}"\`)`});this.$root.addEventListener("click",(()=>o(u,{onBeforeFocus(){u.classList.add("govuk-skip-link-focused-element")},onBlur(){u.classList.remove("govuk-skip-link-focused-element")}})))}}O.elementType=HTMLAnchorElement,O.moduleName="govuk-skip-link";class j extends m{constructor(t){super(t),this.$tabs=void 0,this.$tabList=void 0,this.$tabListItems=void 0,this.jsHiddenClass="govuk-tabs__panel--hidden",this.changingHash=!1,this.boundTabClick=void 0,this.boundTabKeydown=void 0,this.boundOnHashChange=void 0,this.mql=null;const e=this.$root.querySelectorAll("a.govuk-tabs__tab");if(!e.length)throw new d({component:j,identifier:'Links (`<a class="govuk-tabs__tab">`)'});this.$tabs=e,this.boundTabClick=this.onTabClick.bind(this),this.boundTabKeydown=this.onTabKeydown.bind(this),this.boundOnHashChange=this.onHashChange.bind(this);const i=this.$root.querySelector(".govuk-tabs__list"),n=this.$root.querySelectorAll("li.govuk-tabs__list-item");if(!i)throw new d({component:j,identifier:'List (`<ul class="govuk-tabs__list">`)'});if(!n.length)throw new d({component:j,identifier:'List items (`<li class="govuk-tabs__list-item">`)'});this.$tabList=i,this.$tabListItems=n,this.setupResponsiveChecks()}setupResponsiveChecks(){const t=s("tablet");if(!t.value)throw new d({component:j,identifier:`CSS custom property (\`${t.property}\`) on pseudo-class \`:root\``});this.mql=window.matchMedia(`(min-width: ${t.value})`),"addEventListener"in this.mql?this.mql.addEventListener("change",(()=>this.checkMode())):this.mql.addListener((()=>this.checkMode())),this.checkMode()}checkMode(){var t;null!=(t=this.mql)&&t.matches?this.setup():this.teardown()}setup(){var t;this.$tabList.setAttribute("role","tablist"),this.$tabListItems.forEach((t=>{t.setAttribute("role","presentation")})),this.$tabs.forEach((t=>{this.setAttributes(t),t.addEventListener("click",this.boundTabClick,!0),t.addEventListener("keydown",this.boundTabKeydown,!0),this.hideTab(t)}));const e=null!=(t=this.getTab(window.location.hash))?t:this.$tabs[0];this.showTab(e),window.addEventListener("hashchange",this.boundOnHashChange,!0)}teardown(){this.$tabList.removeAttribute("role"),this.$tabListItems.forEach((t=>{t.removeAttribute("role")})),this.$tabs.forEach((t=>{t.removeEventListener("click",this.boundTabClick,!0),t.removeEventListener("keydown",this.boundTabKeydown,!0),this.unsetAttributes(t)})),window.removeEventListener("hashchange",this.boundOnHashChange,!0)}onHashChange(){const t=window.location.hash,e=this.getTab(t);if(!e)return;if(this.changingHash)return void(this.changingHash=!1);const i=this.getCurrentTab();i&&(this.hideTab(i),this.showTab(e),e.focus())}hideTab(t){this.unhighlightTab(t),this.hidePanel(t)}showTab(t){this.highlightTab(t),this.showPanel(t)}getTab(t){return this.$root.querySelector(`a.govuk-tabs__tab[href="${t}"]`)}setAttributes(t){const e=n(t.href);if(!e)return;t.setAttribute("id",`tab_${e}`),t.setAttribute("role","tab"),t.setAttribute("aria-controls",e),t.setAttribute("aria-selected","false"),t.setAttribute("tabindex","-1");const i=this.getPanel(t);i&&(i.setAttribute("role","tabpanel"),i.setAttribute("aria-labelledby",t.id),i.classList.add(this.jsHiddenClass))}unsetAttributes(t){t.removeAttribute("id"),t.removeAttribute("role"),t.removeAttribute("aria-controls"),t.removeAttribute("aria-selected"),t.removeAttribute("tabindex");const e=this.getPanel(t);e&&(e.removeAttribute("role"),e.removeAttribute("aria-labelledby"),e.classList.remove(this.jsHiddenClass))}onTabClick(t){const e=this.getCurrentTab(),i=t.currentTarget;e&&i instanceof HTMLAnchorElement&&(t.preventDefault(),this.hideTab(e),this.showTab(i),this.createHistoryEntry(i))}createHistoryEntry(t){const e=this.getPanel(t);if(!e)return;const i=e.id;e.id="",this.changingHash=!0,window.location.hash=i,e.id=i}onTabKeydown(t){switch(t.key){case"ArrowLeft":case"Left":this.activatePreviousTab(),t.preventDefault();break;case"ArrowRight":case"Right":this.activateNextTab(),t.preventDefault()}}activateNextTab(){const t=this.getCurrentTab();if(null==t||!t.parentElement)return;const e=t.parentElement.nextElementSibling;if(!e)return;const i=e.querySelector("a.govuk-tabs__tab");i&&(this.hideTab(t),this.showTab(i),i.focus(),this.createHistoryEntry(i))}activatePreviousTab(){const t=this.getCurrentTab();if(null==t||!t.parentElement)return;const e=t.parentElement.previousElementSibling;if(!e)return;const i=e.querySelector("a.govuk-tabs__tab");i&&(this.hideTab(t),this.showTab(i),i.focus(),this.createHistoryEntry(i))}getPanel(t){const e=n(t.href);return e?this.$root.querySelector(`#${e}`):null}showPanel(t){const e=this.getPanel(t);e&&e.classList.remove(this.jsHiddenClass)}hidePanel(t){const e=this.getPanel(t);e&&e.classList.add(this.jsHiddenClass)}unhighlightTab(t){t.parentElement&&(t.setAttribute("aria-selected","false"),t.parentElement.classList.remove("govuk-tabs__list-item--selected"),t.setAttribute("tabindex","-1"))}highlightTab(t){t.parentElement&&(t.setAttribute("aria-selected","true"),t.parentElement.classList.add("govuk-tabs__list-item--selected"),t.setAttribute("tabindex","0"))}getCurrentTab(){return this.$root.querySelector(".govuk-tabs__list-item--selected a.govuk-tabs__tab")}}function q(t){var e;if(t=void 0!==t?t:{},!r())return void(t.onError?t.onError(new c,{config:t}):console.log(new c));const i=[[y,t.accordion],[k,t.button],[A,t.characterCount],[E],[x,t.errorSummary],[S,t.exitThisPage],[T,t.fileUpload],[I],[_,t.notificationBanner],[M,t.passwordInput],[B],[H],[O],[j]],n={scope:null!=(e=t.scope)?e:document,onError:t.onError};i.forEach((([t,e])=>{F(t,e,n)}))}function F(t,e,i){let n,s=document;var o;"object"==typeof i&&(s=null!=(o=i.scope)?o:s,n=i.onError),"function"==typeof i&&(n=i),i instanceof HTMLElement&&(s=i);const a=s.querySelectorAll(`[data-module="${t.moduleName}"]`);return r()?Array.from(a).map((i=>{try{return void 0!==e?new t(i,e):new t(i)}catch(s){return n?n(s,{element:i,component:t,config:e}):console.log(s),null}})).filter(Boolean):(n?n(new c,{component:t,config:e}):console.log(new c),[])}return j.moduleName="govuk-tabs",e}()}));
|
3
3
|
//# sourceMappingURL=moduk-frontend.umd.js.map
|
@@ -11,6 +11,7 @@
|
|
11
11
|
* attribute, which also provides accessibility.
|
12
12
|
*
|
13
13
|
* @preserve
|
14
|
+
* @augments ConfigurableComponent<AccordionConfig>
|
14
15
|
*/
|
15
16
|
|
16
17
|
/**
|
@@ -24,6 +25,7 @@
|
|
24
25
|
* of the available characters/words has been entered.
|
25
26
|
*
|
26
27
|
* @preserve
|
28
|
+
* @augments ConfigurableComponent<CharacterCountConfig>
|
27
29
|
*/
|
28
30
|
|
29
31
|
/**
|
@@ -39,12 +41,21 @@
|
|
39
41
|
* configuration.
|
40
42
|
*
|
41
43
|
* @preserve
|
44
|
+
* @augments ConfigurableComponent<ErrorSummaryConfig>
|
42
45
|
*/
|
43
46
|
|
44
47
|
/**
|
45
48
|
* Exit this page component
|
46
49
|
*
|
47
50
|
* @preserve
|
51
|
+
* @augments ConfigurableComponent<ExitThisPageConfig>
|
52
|
+
*/
|
53
|
+
|
54
|
+
/**
|
55
|
+
* File upload component
|
56
|
+
*
|
57
|
+
* @preserve
|
58
|
+
* @augments ConfigurableComponent<FileUploadConfig>
|
48
59
|
*/
|
49
60
|
|
50
61
|
/**
|
@@ -57,18 +68,21 @@
|
|
57
68
|
* JavaScript enhancements for the Button component
|
58
69
|
*
|
59
70
|
* @preserve
|
71
|
+
* @augments ConfigurableComponent<ButtonConfig>
|
60
72
|
*/
|
61
73
|
|
62
74
|
/**
|
63
75
|
* Notification Banner component
|
64
76
|
*
|
65
77
|
* @preserve
|
78
|
+
* @augments ConfigurableComponent<NotificationBannerConfig>
|
66
79
|
*/
|
67
80
|
|
68
81
|
/**
|
69
82
|
* Password input component
|
70
83
|
*
|
71
84
|
* @preserve
|
85
|
+
* @augments ConfigurableComponent<PasswordInputConfig>
|
72
86
|
*/
|
73
87
|
|
74
88
|
/**
|
@@ -77,10 +91,17 @@
|
|
77
91
|
* @preserve
|
78
92
|
*/
|
79
93
|
|
94
|
+
/**
|
95
|
+
* Service Navigation component
|
96
|
+
*
|
97
|
+
* @preserve
|
98
|
+
*/
|
99
|
+
|
80
100
|
/**
|
81
101
|
* Skip link component
|
82
102
|
*
|
83
103
|
* @preserve
|
104
|
+
* @augments Component<HTMLAnchorElement>
|
84
105
|
*/
|
85
106
|
|
86
107
|
/**
|