[
  {
    "tags": [],
    "description": {
      "full": "",
      "summary": "",
      "body": ""
    },
    "isPrivate": false,
    "isConstructor": false,
    "line": 1,
    "codeStart": null,
    "code": "import {Aire}               from \"aire/core/application\";\nimport {makePropertyMapper} from \"aire/core/decorators\";\n\nexport const $ = document;\n\nexport namespace dom {\n  export function pathTo(hostOrSelector : string | Node) : string {\n    if (typeof hostOrSelector === 'string') {\n      return hostOrSelector;\n    } else {\n      let path = [],\n        el = hostOrSelector as any;\n      while (el.nodeType === Node.ELEMENT_NODE) {\n        let selector = el.nodeName.toLowerCase();\n        if (el.id) {\n          selector += '#' + el.id;\n          path.unshift(selector);\n          break;\n        } else {\n          let sib = el, nth = 1;\n          while (sib = sib.previousElementSibling) {\n            if (sib.nodeName.toLowerCase() == selector) {\n              nth++;\n            }\n          }\n          if (nth != 1) {\n            selector += \":nth-of-type(\" + nth + \")\";\n          }\n        }\n        path.unshift(selector);\n        el = el.parentNode;\n      }\n      return path.join(\" > \");\n    }\n  }\n\n  export function $(s : string) : Element {\n    return document.querySelector(s);\n  }\n\n  export function isAncestor(test : Element, target : Element) {\n    if (test === target) {\n      return true;\n    }\n    let c = test;\n    while ((c = c.parentElement) && c !== target) {\n    }\n    return !!c;\n  }\n\n  export function decorateTo(\n    sourceEl : Element,\n    el : Element,\n    decoration : string,\n    className? : string\n  ) {\n    if (sourceEl.hasAttribute(decoration)) {\n      if (className) {\n        el.classList.add(className);\n      } else {\n        el.classList.add(decoration);\n      }\n    }\n  }\n\n  export function decorate(\n    el : Element,\n    decoration : string,\n    className? : string\n  ) : boolean {\n    if (el.hasAttribute(decoration)) {\n      if (className) {\n        el.classList.add(className);\n      } else {\n        el.classList.add(decoration);\n      }\n      return true;\n    }\n    return false;\n  }\n}\n\nexport function Id() {\n  return function (target : any, key : string) {\n    makePropertyMapper(target, key, () => {\n      return Aire.id;\n    });\n  };\n}\n\n// export function Id(instance : any, key : string) {\n//   let value = instance[key] || Aire.id,\n//     getter = function () : string {\n//       return value;\n//     },\n//     setter = function (v : string) : void {\n//       value = v;\n//     };\n//   if (delete instance[key]) {\n//     Object.defineProperty(instance, key, {\n//       get          : getter,\n//       set          : setter,\n//       enumerable   : true,\n//       configurable : true\n//     });\n//   }\n// }\n\nexport function findParentByClass(el : Element, selectorClass : string) : Element {\n  if (Element.prototype.closest) {\n    return el.closest(selectorClass);\n  }\n  while (\n    (el = el.parentElement) &&\n    !(el.matches || (el as any).matchesSelector).call(el, selectorClass)\n    ) {\n  }\n  return el;\n}\n\nexport function createEvent(name : string, value : any) : Event {\n  let w = window as any;\n  if (w.CustomEvent) {\n    return new CustomEvent(name, {\n      detail  : {\n        value : value\n      },\n      bubbles : true\n    });\n  } else {\n    let e = document.createEvent('CustomEvent');\n    e.initCustomEvent(name, true, true, {\n      detail : {\n        value : value\n      }\n    });\n  }\n}",
    "ctx": false
  }
]