{"version":3,"file":"CookieBanner.65cfe9a6ee7740aeb9bd.js","mappings":"yBAAA,iBAGE,WAAYA,GACVC,KAAKD,GAAKA,EACV,IAAME,EAAcC,SAASC,cAAc,uBACvCF,aAAuBG,oBACzBJ,KAAKK,MAAQJ,GAGfD,KAAKM,MACP,CAkDF,OAhDE,YAAAA,KAAA,sBAEE,KADqBC,OAAOC,SAASC,KAAKC,cAAcC,QAAQ,iBAAmB,GAChE,CACjBT,SAASU,KAAKC,UAAUC,IAAI,aAC5B,IAAMC,EAAOb,SAASc,eAAe,iBAIrC,GAFAD,SAAAA,EAAME,aAAa,cAAe,QAE9BjB,KAAKK,iBAAiBD,kBAAmB,CAC3CJ,KAAKK,MAAMa,QACX,IAAM,EAAchB,SAASc,eAAe,+BAC5C,GAAI,aAAuBG,eAAgB,CAKzCjB,SAASkB,iBAAiB,WAJJ,SAACC,GACrB,EAAKC,oBAAoBD,EAAG,EAC9B,G,GAOR,EACA,YAAAC,oBAAA,SAAoBD,EAAkBE,GACpC,GAAIvB,KAAKK,iBAAiBD,mBACT,QAAXiB,EAAEG,KAAgB,CACpB,IAAMC,EAAiBF,EAAUG,iBAAiB,mCAC5CC,EAAsBF,EAAeG,OACrCC,EAAc3B,SAAS4B,cAE7B,GAAID,EAAa,CACf,IAAME,EAAmBC,MAAMC,UAAUtB,QAAQuB,KAAKT,EAAgBI,GACjER,EAAEc,UAAaJ,IAAqBJ,EAAsB,IAC5DF,EAAe,GAAmBP,QACnCG,EAAEe,kBAEAf,EAAEc,UAAiC,IAArBJ,IACfN,EAAeE,EAAsB,GAAmBT,QACzDG,EAAEe,mBAEsB,IAAtBL,IACDN,EAAe,GAAmBP,QACnCG,EAAEe,iB,EAKZ,EAEF,EA7DA,GA+DA,IC7DMrC,EAAKG,SAASC,cAAc,wBAE9BJ,aAAcoB,gBAChB,IAAI,EAAYpB,E","sources":["webpack://dfe-web-skeleton/./ClientApp/AppComponents/CookieBanner/CookieModal.ts","webpack://dfe-web-skeleton/./ClientApp/Entry/CookieBanner.ts"],"sourcesContent":["class CookieModal {\r\n  private el: HTMLDivElement;\r\n  private readonly modal?: Element;\r\n  constructor(el: HTMLDivElement) {\r\n    this.el = el;\r\n    const cookieModal = document.querySelector('.cookie-prefs-modal');\r\n    if (cookieModal instanceof HTMLDialogElement) {\r\n      this.modal = cookieModal;\r\n    }\r\n    \r\n    this.init();\r\n  }\r\n  \r\n  init() {\r\n    const isCookiePage = window.location.href.toLowerCase().indexOf(\"/help/cookies\") > 0;\r\n    if (!isCookiePage) {\r\n      document.body.classList.add('no-scroll');\r\n      const page = document.getElementById('ts-modal-page');\r\n      \r\n      page?.setAttribute('aria-hidden', 'true');\r\n      \r\n      if (this.modal instanceof HTMLDialogElement) {\r\n        this.modal.focus();\r\n        const contentArea = document.getElementById('govuk-cookie-banner-message');\r\n        if (contentArea instanceof HTMLDivElement) {\r\n          const modalKeyPress = (e: KeyboardEvent) => {\r\n            this.manageModalKeyPress(e, contentArea)\r\n          }\r\n          \r\n          document.addEventListener('keydown', modalKeyPress);\r\n          \r\n        }\r\n      }\r\n    }\r\n  }\r\n  manageModalKeyPress(e: KeyboardEvent, container: HTMLDivElement) {\r\n    if (this.modal instanceof HTMLDialogElement) {\r\n      if (e.code === 'Tab') {\r\n        const focusableItems = container.querySelectorAll('a[href], button:not([disabled])');\r\n        const focusableItemsCount = focusableItems.length;\r\n        const focusedItem = document.activeElement;\r\n        \r\n        if (focusedItem) {\r\n          const focusedItemIndex = Array.prototype.indexOf.call(focusableItems, focusedItem);\r\n          if (!e.shiftKey && (focusedItemIndex === focusableItemsCount - 1)) {\r\n            (focusableItems[0] as HTMLElement).focus();\r\n            e.preventDefault();\r\n          }\r\n          if (e.shiftKey && focusedItemIndex === 0) {\r\n            (focusableItems[focusableItemsCount - 1] as HTMLElement).focus();\r\n            e.preventDefault();\r\n          }\r\n          if (focusedItemIndex === -1) {\r\n            (focusableItems[0] as HTMLElement).focus();\r\n            e.preventDefault();\r\n          }\r\n        }\r\n      }\r\n    }\r\n  }\r\n\r\n}\r\n\r\nexport default CookieModal;","import CookieModal from \"../AppComponents/CookieBanner/CookieModal\";\r\n\r\nconst el = document.querySelector('.govuk-cookie-banner');\r\n\r\nif (el instanceof HTMLDivElement) {\r\n  new CookieModal(el);\r\n}"],"names":["el","this","cookieModal","document","querySelector","HTMLDialogElement","modal","init","window","location","href","toLowerCase","indexOf","body","classList","add","page","getElementById","setAttribute","focus","HTMLDivElement","addEventListener","e","manageModalKeyPress","container","code","focusableItems","querySelectorAll","focusableItemsCount","length","focusedItem","activeElement","focusedItemIndex","Array","prototype","call","shiftKey","preventDefault"],"sourceRoot":""}