{"version":3,"file":"sanityChecks.cjs","names":["ElementError","Error","constructor","message","element","name","console","error","exports","normalizeText","text","replace","trim","getWindow","htmlElement","ownerDocument","defaultView","validateHtmlElement","window","SVGElement","HTMLElement"],"sources":["../../../src/test-selectors/sanityChecks.ts"],"sourcesContent":["/*!\n * Copyright (c) 2024-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n */\n\n// Code modified from: https://github.com/testing-library/jest-dom/blob/main/src/utils.js\n\nexport class ElementError extends Error {\n  constructor(message: string, element: HTMLElement) {\n    super(message);\n\n    this.name = \"ElementError\";\n\n    console.error(\"ElementError\", element);\n  }\n}\n\nexport const normalizeText = (text: string) => {\n  return text.replace(/\\s+/g, \" \").trim();\n};\n\nexport const getWindow = (htmlElement: HTMLElement) => {\n  if (\n    !htmlElement ||\n    !htmlElement.ownerDocument ||\n    !htmlElement.ownerDocument.defaultView\n  ) {\n    throw new ElementError(\"Expected element to have a `window`\", htmlElement);\n  }\n\n  return htmlElement.ownerDocument.defaultView;\n};\n\nexport const validateHtmlElement = (htmlElement: HTMLElement) => {\n  const window = getWindow(htmlElement);\n\n  if (\n    !(htmlElement instanceof window.SVGElement) &&\n    !(htmlElement instanceof window.HTMLElement)\n  ) {\n    throw new ElementError(\n      \"Expected element to be an HTMLElement or an SVGElement\",\n      htmlElement,\n    );\n  }\n};\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAIO,MAAMA,YAAY,SAASC,KAAK,CAAC;EACtCC,WAAWA,CAACC,OAAe,EAAEC,OAAoB,EAAE;IACjD,KAAK,CAACD,OAAO,CAAC;IAEd,IAAI,CAACE,IAAI,GAAG,cAAc;IAE1BC,OAAO,CAACC,KAAK,CAAC,cAAc,EAAEH,OAAO,CAAC;EACxC;AACF;AAACI,OAAA,CAAAR,YAAA,GAAAA,YAAA;AAEM,MAAMS,aAAa,GAAIC,IAAY,IAAK;EAC7C,OAAOA,IAAI,CAACC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAACC,IAAI,CAAC,CAAC;AACzC,CAAC;AAACJ,OAAA,CAAAC,aAAA,GAAAA,aAAA;AAEK,MAAMI,SAAS,GAAIC,WAAwB,IAAK;EACrD,IACE,CAACA,WAAW,IACZ,CAACA,WAAW,CAACC,aAAa,IAC1B,CAACD,WAAW,CAACC,aAAa,CAACC,WAAW,EACtC;IACA,MAAM,IAAIhB,YAAY,CAAC,qCAAqC,EAAEc,WAAW,CAAC;EAC5E;EAEA,OAAOA,WAAW,CAACC,aAAa,CAACC,WAAW;AAC9C,CAAC;AAACR,OAAA,CAAAK,SAAA,GAAAA,SAAA;AAEK,MAAMI,mBAAmB,GAAIH,WAAwB,IAAK;EAC/D,MAAMI,MAAM,GAAGL,SAAS,CAACC,WAAW,CAAC;EAErC,IACE,EAAEA,WAAW,YAAYI,MAAM,CAACC,UAAU,CAAC,IAC3C,EAAEL,WAAW,YAAYI,MAAM,CAACE,WAAW,CAAC,EAC5C;IACA,MAAM,IAAIpB,YAAY,CACpB,wDAAwD,EACxDc,WACF,CAAC;EACH;AACF,CAAC;AAACN,OAAA,CAAAS,mBAAA,GAAAA,mBAAA","ignoreList":[]}