{
  "version": 3,
  "sources": ["../../src/modal/aria-helper.ts"],
  "sourcesContent": ["const LIVE_REGION_ARIA_ROLES = new Set(['alert', 'status', 'log', 'marquee', 'timer']);\nconst hiddenElementsByDepth = [];\n\n/**\n * Hides all elements in the body element from screen-readers except\n * the provided element and elements that should not be hidden from\n * screen-readers.\n *\n * The reason we do this is because `aria-modal=\"true\"` currently is bugged\n * in Safari, and support is spotty in other browsers overall. In the future\n * we should consider removing these helper functions in favor of\n * `aria-modal=\"true\"`.\n *\n * @param modalElement The element that should not be hidden.\n */\nexport function modalize(modalElement) {\n  const elements = Array.from(document.body.children);\n  const hiddenElements = [];\n  hiddenElementsByDepth.push(hiddenElements);\n  for (const element of elements) {\n    if (element === modalElement) {\n      continue;\n    }\n    if (elementShouldBeHidden(element)) {\n      element.setAttribute('aria-hidden', 'true');\n      hiddenElements.push(element);\n    }\n  }\n}\n\n/**\n * Determines if the passed element should not be hidden from screen readers.\n *\n * @param element The element that should be checked.\n *\n * @return Whether the element should not be hidden from screen-readers.\n */\nexport function elementShouldBeHidden(element) {\n  const role = element.getAttribute('role');\n  return !(element.tagName === 'SCRIPT' || element.hasAttribute('hidden') || element.hasAttribute('aria-hidden') || element.hasAttribute('aria-live') || role && LIVE_REGION_ARIA_ROLES.has(role));\n}\n\n/**\n * Accessibly reveals the elements hidden by the latest modal.\n */\nexport function unmodalize() {\n  const hiddenElements = hiddenElementsByDepth.pop();\n  if (!hiddenElements) {\n    return;\n  }\n  for (const element of hiddenElements) {\n    element.removeAttribute('aria-hidden');\n  }\n}"],
  "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAM,yBAAyB,oBAAI,IAAI,CAAC,SAAS,UAAU,OAAO,WAAW,OAAO,CAAC;AACrF,IAAM,wBAAwB,CAAC;AAcxB,SAAS,SAAS,cAAc;AACrC,QAAM,WAAW,MAAM,KAAK,SAAS,KAAK,QAAQ;AAClD,QAAM,iBAAiB,CAAC;AACxB,wBAAsB,KAAK,cAAc;AACzC,aAAW,WAAW,UAAU;AAC9B,QAAI,YAAY,cAAc;AAC5B;AAAA,IACF;AACA,QAAI,sBAAsB,OAAO,GAAG;AAClC,cAAQ,aAAa,eAAe,MAAM;AAC1C,qBAAe,KAAK,OAAO;AAAA,IAC7B;AAAA,EACF;AACF;AASO,SAAS,sBAAsB,SAAS;AAC7C,QAAM,OAAO,QAAQ,aAAa,MAAM;AACxC,SAAO,EAAE,QAAQ,YAAY,YAAY,QAAQ,aAAa,QAAQ,KAAK,QAAQ,aAAa,aAAa,KAAK,QAAQ,aAAa,WAAW,KAAK,QAAQ,uBAAuB,IAAI,IAAI;AAChM;AAKO,SAAS,aAAa;AAC3B,QAAM,iBAAiB,sBAAsB,IAAI;AACjD,MAAI,CAAC,gBAAgB;AACnB;AAAA,EACF;AACA,aAAW,WAAW,gBAAgB;AACpC,YAAQ,gBAAgB,aAAa;AAAA,EACvC;AACF;",
  "names": []
}
