/**
 * Returns the shadow root by casting it to AnyHTMLElement to be able to use
 * DOM functions such as 'getElementsByTagName'. I have no idea why ShadowRoot in lib.dom.d.ts
 * doesn't have this on ShadowRoot definition.
 *
 * @param page
 */
export function getShadowRoot(page) {
  // TODO check this later on
  // @ts-ignore
  return page.root.shadowRoot;
}
/**
 * Fix around getElementsByTagName not returning a proper HTMLCollectionOf object.
 * HTMLCollectionOf should have a function 'item(index: number): T | null;' which
 * returns the item at index but apparently it's undefined.
 *
 * @param parent
 * @param tag
 */
export function getFirstByTagName(parent, tag) {
  const elems = parent.getElementsByTagName(tag);
  // @ts-ignore
  return elems ? elems[0] : undefined;
}
/**
 * Fix around getElementsByClassName not returning a proper HTMLCollectionOf object.
 * HTMLCollectionOf should have a function 'item(index: number): T | null;' which
 * returns the item at index but apparently it's undefined.
 *
 * @param parent
 * @param tag
 */
export function getFirstByClassName(parent, tag) {
  const elems = parent.getElementsByClassName(tag);
  // @ts-ignore
  return elems ? elems[0] : undefined;
}
export const iconFontURL = 'https://unicons.iconscout.com/release/v4.0.0/css/line.css';
