@webqit/oohtml 1.9.21 → 1.9.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,3 @@
1
- (()=>{"use strict";function e(e,...t){globalThis.WebQitInternalsRegistry||(globalThis.WebQitInternalsRegistry=new Map);var r,n,s=globalThis.WebQitInternalsRegistry.get(e);if(!s){if(s=new Map,!1===t[0])return s;globalThis.WebQitInternalsRegistry.set(e,s)}for(;r=t.shift();)if((n=s)&&!(s=s.get(r))){if(s=new Map,!1===t[0])return s;n.set(r,s)}return s}function t(e){return Array.isArray(e)}function r(e){return e instanceof String||"string"==typeof e&&null!==e}function n(e){return arguments.length&&(void 0===e||void 0===e)}function s(e){return"function"==typeof e}function o(e){return Array.isArray(e)||"object"==typeof e&&e||s(e)}function i(e){return!Array.isArray(e)&&"object"==typeof e&&e}function a(e,s=!0){return t(e)?e:!s&&i(e)?[e]:!1!==e&&0!==e&&function(e){return function(e){return null===e||""===e}(e)||n(e)||!1===e||0===e||o(e)&&!Object.keys(e).length}(e)?[]:function(e){return!r(e)&&!n(e.length)}(e)?Array.prototype.slice.call(e):i(e)?Object.values(e):[e]}function l(e){return!Array.isArray(e)&&"object"==typeof e&&e}function c(){if(!(l(this)&&this.window||"undefined"!=typeof window))throw new Error("A window context is required.");const e=l(this)&&this.window?this.window:window;if(e.WebQit||(e.WebQit={}),!e.WebQit.window){let t,r;Object.defineProperty(e.WebQit,"window",{get:()=>e}),Object.defineProperty(e.WebQit,"vendor",{value:{getName:()=>(t||(t=function(e){if(void 0!==e.InstallTrigger)return"firefox";if(/constructor/i.test(e.HTMLElement)||"[object SafariRemoteNotification]"===(!e.safari||void 0!==e.safari&&e.safari.pushNotification).toString())return"safari";var t=!(!e.chrome||!e.chrome.webstore&&!e.chrome.runtime),r=t&&-1!=e.navigator.userAgent.indexOf("Edg"),n=!!e.opr&&!!e.opr.addons||!!e.opera||e.navigator.userAgent.indexOf(" OPR/")>=0,s=!!e.document.documentMode,o=!s&&!!e.StyleMedia;return(t||n)&&e.CSS,o?"edge":s?"ie":n?"opera":r?"ie-chromium":t?"chrome":"unknown"}(e)),t),getPrefix:()=>(r||(r=function(e){var t=e.getComputedStyle(e.document.documentElement,""),r=(Array.prototype.slice.call(t).join("").match(/-(moz|webkit|ms)-/)||""===t.Olink&&["","o"])[1];return{api:("WebKit|Moz|Ms|O".match(new RegExp("("+r+")","i"))||[])[1],prefix:r,css:"-"+r+"-"}}(e)),r)}})}return e.WebQit}new Map;class h{constructor(e,t=!0){this.window=e,this.async=t,this.readCallbacks=[],this.writeCallbacks=[],this._run()}_run(){this.window.requestAnimationFrame((()=>{this.readCallbacks.forEach(((e,t)=>{e&&!e()&&(this.readCallbacks[t]=null)})),this.writeCallbacks.forEach(((e,t)=>{e&&!e()&&(this.writeCallbacks[t]=null)})),this._run()}))}onread(e,t=!1){if(t)return new Promise(((t,r)=>{!1===this.async?e(t,r):this.readCallbacks.push((()=>{e(t,r)}))}));!1===this.async?e():this.readCallbacks.push(e)}onwrite(e,t=!1){if(t)return new Promise(((t,r)=>{!1===this.async?e(t,r):this.writeCallbacks.push((()=>{e(t,r)}))}));!1===this.async?e():this.writeCallbacks.push(e)}cycle(e,t,r){this.onread((()=>{var n=e(r);if(n){var s=n=>{this.onwrite((()=>{var s=t(n,r);if(s){var o=r=>{this.cycle(e,t,r)};s instanceof Promise?s.then(o):o()}}))};n instanceof Promise?n.then(s):s()}}))}}function u(e){return e instanceof String||"string"==typeof e&&null!==e}function d(e){return Array.isArray(e)}function m(e){return arguments.length&&(void 0===e||void 0===e)}function p(e){return null===e||""===e}function f(e){return"function"==typeof e}function g(e){return Array.isArray(e)||"object"==typeof e&&e||f(e)}function v(e,t=!0){return d(e)?e:!t&&l(e)?[e]:!1!==e&&0!==e&&function(e){return p(e)||m(e)||!1===e||0===e||g(e)&&!Object.keys(e).length}(e)?[]:function(e){return!u(e)&&!m(e.length)}(e)?Array.prototype.slice.call(e):l(e)?Object.values(e):[e]}function b(e){const t=c.call(this);t.DOM.isDOMReady||"complete"===t.window.document.readyState?e(t.window):(t.window.domReadyCallbacks||(t.window.domReadyCallbacks=[],t.window.document.addEventListener("DOMContentLoaded",(()=>{t.DOM.isDOMReady=!0,t.window.domReadyCallbacks.splice(0).forEach((e=>e(t.window)))}),!1)),t.window.domReadyCallbacks.push(e))}class w{constructor(e){this.window=e}onAdded(e,t,r={}){return r.on="added",this.onPresenceChange(e,((e,r,n,s,o)=>{t(e,r,n,s,o)}),r)}onRemoved(e,t,r={}){return r.on="removed",this.onPresenceChange(e,((e,r,n,s,o)=>{t(e,r,n,s,o)}),r)}onPresent(e,t,r={}){b.call(this.window,(()=>{this.window.MutationObserver&&this.onAdded(e,((e,r)=>{e.forEach((e=>t(e,r)))}),r),u(e)?v(this.window.document.querySelectorAll(e)).forEach((e=>t(e,1))):e.parentNode&&t(e,1)}))}onAbsent(e,t,r={}){b.call(this.window,(()=>{this.window.MutationObserver&&onRemoved(e,((e,r)=>{e.forEach((e=>t(e,r)))}),r),u(e)?0===v(this.window.document.querySelectorAll(e)).length&&t(null,0):e.parentNode||t(e,0)}))}onPresenceChange(e,t,r={}){e=v(e,!1);var n=new Set,s=new Set,o=(o,i,a)=>{i&&"removed"===r.on||!i&&"added"===r.on||(o=((e,t)=>(t.$$searchCache||(t.$$searchCache=new Map),e.reduce(((e,n)=>{var s;return t.$$searchCache.has(n)?s=t.$$searchCache.get(n):(s=((e,t)=>{if(t=t.filter((e=>e.matches)),u(e)){var n=t.filter((t=>t.matches(e)));if(!1!==r.observeIndirectMutation&&(n=t.reduce(((t,r)=>t.concat(v(r.querySelectorAll(e)))),n)).length)return n}else{if(t.includes(e))return[e];if(!1!==r.observeIndirectMutation&&t.length)for(var s=e;s=s.parentNode;)if(t.includes(s))return[e]}})(n,t,u(n))||[],t.$$searchCache.set(n,s)),e.concat(s)}),[])))(e,o)).length&&(r.maintainCallState?(o.forEach((e=>{i?(n.add(e),s.delete(e)):(n.delete(e),s.add(e))})),t(o,i,a,n,s)):t(o,i,a))},i=r.context||this.window.document.documentElement;return this._observe(i,((e,t,n,s)=>{r.ignoreTransients||(o(e,0,!0),o(e.concat(t),1,!0),o(t,0,!0)),o(s,0),o(n,1)}))}onAttrChange(e,t,r=[]){var n=new this.window.MutationObserver(t),s={attributes:!0,attributeOldValue:!0};return r&&(s.attributeFilter=r),n.observe(e,s),n}onTreeChange(e,t,r=!1){var n=new this.window.MutationObserver(t),s={childList:!0,subtree:r};return n.observe(e,s),n}onMutation(e,t,r){var n=new this.window.MutationObserver(t);return n.observe(e,r),n}_observe(e,t){if(!y.has(e)){const t=new Set,r=new this.window.MutationObserver((e=>{if(t.size){var r=e.reduce(((e,t)=>e.concat(v(t.addedNodes))),[]),n=e.reduce(((e,t)=>e.concat(v(t.removedNodes))),[]),s=[],o=[];r=new Set(r),n=new Set(n),r.forEach((e=>{n.has(e)&&(n.delete(e),r.delete(e),e.isConnected?s.push(e):o.push(e))})),r=[...r],n=[...n],t.forEach((e=>e(s,o,r,n)))}}));r.observe(e,{childList:!0,subtree:!0}),y.set(e,{callbacks:t,observer:r})}const r=y.get(e);return r.callbacks.add(t),{disconnect(){r.callbacks.delete(t)},reconnect(){r.callbacks.add(t)}}}}const y=new Map;function O(e,t=null,r=!1){const n=c.call(this);if(u(e)){var s;if(e.trim().startsWith("<")){var o=n.window.document.createElement("div");o.innerHTML=e,s=r?v(o.children):o.firstChild}else s=r?v(k.call(this,e,t)):x.call(this,e,t);return s}return e instanceof n.window.Element?r?[e]:e:r?v(e):e}function E(e,t=null){return O.call(this,e,t,!0)}function x(e,t=null,r=!1){const n=c.call(this);t=t||n.window.document;var s,o=r?"querySelectorAll":"querySelector";try{s=t[o](e)}catch(r){try{s=t[o](e.replace(/\:is\(/g,":matches("))}catch(r){try{s=t[o](e.replace(/\:is\(/g,":-webkit-any("))}catch(r){try{s=t[o](e.replace(/\:is\(/g,":-moz-any("))}catch(e){throw e}}}}return s}function k(e,t=null){return x.call(this,e,t,!0)}function j(e){return function(e){return e instanceof Number||"number"==typeof e}(e)||!0!==e&&!1!==e&&null!==e&&""!==e&&!isNaN(1*e)}function C(e){return f(e)||e&&"[object function]"==={}.toString.call(e)}function $(e,t,r={},n={}){t=v(t).slice();for(var s=e;!m(s)&&!p(s)&&t.length;){var o=t.shift();if(!(r.get?r.get(s,o):g(s)?o in s:s[o]))return void(n.exists=!1);s=r.get?r.get(s,o):s[o]}return n.exists=!0,s}function M(e,t,r,n={},s={}){const o=(e,r,n)=>s.set?s.set(e,r,n):(j(t[a])&&d(e)?e.push(n):e[r]=n,!0);t=v(t);for(var i=e,a=0;a<t.length;a++){if(!(a<t.length-1))return o(i,t[a],r);if(!i||!g(i)&&!C(i))return!1;var l=$(i,t[a],s);if(!g(l)){if(!1===s.buildTree)return!1;if(l=C(s.buildTree)?s.buildTree(a):j(t[a+1])?[]:{},!o(i,t[a],l))return!1}i=l}}function T(e,t,r=!1,n={}){t=v(t);var s=!1;do{var o=""===(o=t.pop())?0:o,i=e;t.length&&(i=$(e,t,{},n)),(g(i)||C(i))&&(n.has?n.has(i,o):o in i)&&(n.deleteProperty?s=n.deleteProperty(i,o):n.del?s=n.del(i,o):(delete i[o],s=!0))}while(s&&r&&t.length&&(g(i)||C(i))&&!(n.keys?n.keys(i):Object.keys(i)).length);return s}function A(e,t,r={}){var n={};return $(e,t,r,n),n.exists}function S(e,t=!1){const r=c.call(this);var n={};return!(n.el=r.window.document.head.querySelector('meta[name="oohtml"]'))&&t&&(n.el=r.window.document.createElement("meta"),n.el.setAttribute("name",e),r.window.document.head.append(n.el)),n.el&&(n.vars=(n.el.getAttribute("content")||"").split(";").filter((e=>e)).reduce(((e,t)=>{var r=t.split("=").map((e=>e.trim()));return M(e,r[0].split("."),"true"===r[1]||"false"!==r[1]&&(j(r[1])?parseInt(r[1]):r[1])),e}),{})),n.get=function(e){return $(this.vars,e.split("."))},n.set=function(e,r=null,n=!1){var s=l(e)?e:{[e]:!0===r?"true":r};if(n=arguments.length<3?r:n,Object.keys(s).forEach((e=>{if(!1===s[e])T(this.vars,e.split("."));else if(l(s[e]))Object.keys(s[e]).forEach((t=>{var r=(e+"."+t).split(".");n&&A(this.vars,r)||M(this.vars,r,s[e][t])}));else{var t=e.split(".");n&&A(this.vars,t)||M(this.vars,t,s[e])}})),t){const e=(t,r)=>Object.keys(r).reduce(((n,s)=>{var o=(t?t+".":"")+s;return l(r[s])?n.push(...e(o,r[s])):n.push(o+"="+r[s]),n}),[]);this.el.setAttribute("content",e("",this.vars).join(";"))}return!0},n.defaults=function(e,t=null){return this.set(e,t,!0)},n}function P(){const e=c.call(this);return e.DOM||(e.DOM={},function(e){!function(e){e.CSS||(e.CSS={}),e.CSS.escape||(e.CSS.escape=e=>e.replace(/([\:@\~\$\&])/g,"\\$1"))}(e),function(e){"isConnected"in e.Node.prototype||Object.defineProperty(e.Node.prototype,"isConnected",{get:function(){return!(this.ownerDocument&&this.ownerDocument.compareDocumentPosition(this)&this.DOCUMENT_POSITION_DISCONNECTED)}})}(e),function(e){e.Element.prototype.matches||(e.Element.prototype.matches=e.Element.prototype.matchesSelector||e.Element.prototype.mozMatchesSelector||e.Element.prototype.msMatchesSelector||e.Element.prototype.oMatchesSelector||e.Element.prototype.webkitMatchesSelector||function(e){for(var t=(this.document||this.ownerDocument).querySelectorAll(e),r=t.length;--r>=0&&t.item(r)!==this;);return r>-1})}(e)}(e.window),e.DOM.reflow=new h(e.window),e.DOM.mutations=new w(e.window),e.DOM.meta=S.bind(e.window),e.DOM.query=O.bind(e.window),e.DOM.queryAll=E.bind(e.window),e.DOM.ready=b.bind(e.window)),e}function D(e,t,r){return function(e,t){return function(e,t,r=!1){if(""==t)return e;var n=r?e.lastIndexOf(t):e.indexOf(t);return-1===n?e:e.substr(0,n)}(e,t,!0)}(function(e,t,r=!1){if(""==t)return e;var n=r?e.lastIndexOf(t):e.indexOf(t);return-1===n?"":e.substr(n+t.length)}(e,t),r)}function _(e){return s(e)||e&&"[object function]"==={}.toString.call(e)}function N(e){return e instanceof Number||"number"==typeof e}function L(e){return N(e)||!0!==e&&!1!==e&&null!==e&&""!==e&&!isNaN(1*e)}function R(e,r,n=!1,s=!1,a=!1){var l=0,c=e.shift();if((L(c)||!0===c||!1===c)&&(l=c,c=e.shift()),!e.length)throw new Error("_merge() requires two or more array/objects.");return e.forEach(((e,h)=>{var u,d,m;(o(e)||_(e))&&(n?(u=e,m=[],function(e,r){r=(r=r||Object.prototype)&&!t(r)?[r]:r;var n=[];for(e=e;e&&(!r||r.indexOf(e)<0)&&"default"!==e.name;)n.push(e),e=e?Object.getPrototypeOf(e):null;return n}(u,d).forEach((e=>{!function(e,...t){t.forEach((t=>{e.indexOf(t)<0&&e.push(t)}))}(m,...Object.getOwnPropertyNames(e))})),m):Object.getOwnPropertyNames(e)).forEach((o=>{if(r(o,c,e,h)){var u=c[o],d=e[o];if((t(u)&&t(d)||i(u)&&i(d))&&(!0===l||l>0))c[o]=t(u)&&t(d)?[]:{},R([L(l)?l-1:l,c[o],u,d],r,n,s,a);else if(t(c)&&t(e))s?c[o]=d:c.push(d);else try{a?Object.defineProperty(c,o,Object.getOwnPropertyDescriptor(e,o)):c[o]=e[o]}catch(e){}}}))})),c}function W(...e){return R(e,((e,t,r)=>!0),!1,!1,!1)}const q=function(e,r=1,n=!0){return!L(r)||r<=0?e:(!t(e)&&i(e)&&n&&(e=Object.values(e)),t(e)?e.reduce(((e,s)=>t(s)||i(s)&&n?e.concat(q(t(s)?s:Object.values(s),r-1,n)):e.concat(s)),[]):e)},Q=q;function I(e,t=1){var r=0;e.forEach((e=>{r++}));var n=e.slice(e.length-r,t);return arguments.length>1?n:n[0]}function H(e,t=1){return arguments.length>1?I(e.slice().reverse(),t).reverse():I(e.slice().reverse())}function z(e){return i(e)&&Object.getPrototypeOf(e)===Object.prototype}function F(e){return!0===e||!1===e}const U=function(e,r,n=!0,s=1){if(t(e)&&t(r)&&e.length!==r.length)return!n;if(i(e)&&i(r)){var a=Object.keys(e),l=Object.keys(r);if(!a.length&&!l.length)return z(e)&&z(r)?n:e===r===n;if(!U(a,l))return!n}if(s>0&&(t(e)&&t(r)||i(e)&&i(r))){var c=function(e,r,n=!0,s=!0,a=!1,l=!1){if(t(e)&&t(r)){var c=[],h=!0;return e.forEach((e=>{if(h){var u,d,m,p=!1;d=(r,a)=>{(!p||s&&o(e))&&((t(p=n(e,a))&&!p.length||i(p)&&!Object.keys(p).length)&&(p=!1),o(p)&&s&&(e=p))},m=void 0,o(u=r)&&Object.keys(u).forEach(((e,t)=>{!1!==m&&(m=d(L(e)&&parseFloat(e),u[e]))})),o(p)?c.push(s?p:e):F(p)?a&&!p||!a&&p?c.push(e):l&&(h=!1):c.push(p)}})),c}if(i(e)&&i(r))return c={},h=!0,Object.keys(e).forEach((u=>{if(h){var d=n(e[u],r[u]);(t(d)&&!d.length||i(d)&&!Object.keys(d).length)&&(d=!1),o(d)?c[u]=s?d:e[u]:F(d)?a&&!d||!a&&d?c[u]=e[u]:l&&(h=!1):c[u]=d}})),c}(e,r,((e,t)=>U(e,t,n,s-1)),!1,!1,!0);return t(c)?c.length===e.length&&c.length===r.length:i(c)&&i(e)?Object.keys(c).length===Object.keys(e).length&&Object.keys(c).length===Object.keys(r).length:c}return _(n)?n(e,r):N(e)&&N(r)&&isNaN(e)&&isNaN(r)?n:e===r===n},V=U;function K(e,r=[]){return R([{},e],((e,n,s)=>{if(!_(s[e]))return _(r)?r(e):!t(r)||!r.length||r.indexOf(e)>-1}),!1,!1,!1)}class Z{static lex(e,t,n={}){if(!r(e+=""))throw new Error("Argument1 must be a string!");var s=e=>({delims:e.delims.slice(),options:K(e.options),nesting:e.nesting.slice(),maxDepth:e.maxDepth,comments:e.comments.slice(),tokens:e.tokens.slice(),matches:e.matches.slice(),matchesi:K(e.matchesi)});if(Z.$cache[e]&&!1!==n.cache)for(var o=0;o<Z.$cache[e].length;o++){var i=Z.$cache[e][o];if(V(i.delims,t))return s(i)}var a=new Z(e,n).lex(t);return!1!==n.cache&&(Z.$cache[e]=Z.$cache[e]||[],Z.$cache[e].push(a)),s(a)}static split(e,t,r){return Z.lex(e,t,r).tokens}static match(e,t,r){return Z.lex(e,t,r).matches}constructor(e,t){if(!r(e))throw new Error("Lexer requires the first argument to be a string.");this.$str=e,this.$options=t||{},this.$options.blocks||(this.$options.blocks=Z.$blocks),this.$options.quotes||(this.$options.quotes=Z.$quotes),this.$options.comments||(this.$options.comments=Z.$comments)}lex(e,t){for(var r={delims:a(e),options:W(!0,{},this.$options,t||{}),nesting:[],maxDepth:0,comments:[],tokens:[],matches:[],matchesi:{}},n=0;"number"==typeof n;)n=this._evalCharsAt(r,n);if(r.nesting.length)throw new Error("Error parsing the string: "+this.$str+". Unterminated blocks: "+Q(r.nesting).join(", "));return r}_evalCharsAt(e,t){if(!(t>=this.$str.length)){var r=1,n={},s={},o={};if(e.openComment||(s=this._testQuotes(e,t)),e.openQuote||(n=this._testComments(e,t)),e.openComment||n.ending)e.nesting.length||o.ending?this._push(e,this.$str[t]):(r=(a=n.starting||n.ending||this.$str[t]).length,this._push(e,a,"comments",n.starting));else if(e.openQuote||s.ending)this._push(e,this.$str[t]);else{if(e.options.limit&&e.matches.length===e.options.limit)return this._push(e,this.$str[t]),t+1;o=this._testNesting(e,t),o=this._testNesting(e,t);var i=this._testChars(e.options.stopChars||[],e,t);if(!e.nesting.length&&!1!==i)return e.options.stopChar=i,void(e.options.stopCharForward=this.$str.substr(t));if(e.delims.length)if(e.nesting.length||o.ending){var a;r=(a=o.starting||o.ending||this.$str[t]).length,this._push(e,a)}else{this._push(e,"");var l=this._testChars(e.delims,e,t);if(!1!==l&&(e.matches.push(l),e.matchesi[t]=l,r=l.length||1,!e.options.preserveDelims)){var c=t+(l.length||1);return c===this.$str.length&&this._push(e,""),c}this._push(e,l||this.$str[t])}else 2===e.nesting.length&&o.starting?(e.matches.push(null),this._push(e,o.starting),r=o.starting.length):!e.nesting.length&&o.ending?(this._push(e,o.ending),r=o.ending.length,e.matches.push(null)):this._push(e,this.$str[t])}return t+r}}_testQuotes(e,t){var r={};return(e.options.quotes||[]).forEach((n=>{this.$str.substr(t,1)===n&&(e.openQuote?n===e.openQuote&&(e.openQuote=!1,r.ending=n):(e.openQuote=n,r.starting=n))})),r}_testComments(e,t){var r={};return(e.options.comments||[]).forEach((n=>{if(e.openComment){if(H(n)===H(e.openComment)){var s=H(n);this.$str.substr(t).startsWith(s)&&(e.openComment=!1,r.ending=s)}}else{var o=I(n);this.$str.substr(t).startsWith(o)&&(e.openComment=n,r.starting=o)}})),r}_testNesting(e,t){var r={};return(e.options.blocks||[]).forEach((n=>{var s=I(n);if(this.$str.substr(t).startsWith(s))e.nesting=e.nesting.concat([n]),r.starting=s;else if(e.nesting.length&&H(n)===H(H(e.nesting))){var o=H(n);this.$str.substr(t).startsWith(o)&&(e.nesting=e.nesting.slice(0,-1),r.ending=o)}})),e.maxDepth=Math.max(e.maxDepth,e.nesting.length),r}_testChars(e,t,r){for(var n=0;n<e.length;n++){var s=e[n];if(_(s)){var o=s(this.$str.substr(0,r),this.$str.substr(r),t.tokens.slice());if(!1!==o)return o}if(t.options.useRegex){var i=this.$str.substr(r).match(new RegExp("^"+s,!0!==t.options.useRegex?t.options.useRegex:""));if(i)return i[0]}if(!t.options.ci&&this.$str.substr(r,s.length)===s||t.options.ci&&this.$str.substr(r,s.length).toLowerCase()===s.toLowerCase())return s}return!1}_push(e,t,r="tokens",s=!1){var o=e.matches.length;if(n(e.tokens[o])&&(e.tokens[o]=""),"comments"===r){e.tokens[o].comments||(e.tokens[o]=new String(e.tokens[o]),e.tokens[o].comments=[]);var i=e.tokens[o].comments.length-(!e.tokens[o].comments.length||s?0:1);e.tokens[o].comments[i]=(e.tokens[o].comments[i]||"")+t}else e.tokens[o].comments,e.tokens[o]=e.tokens[o]+t}split(e,t,r){return this.lex(t,r).tokens}match(e,t,r){return this.lex(t,r).matches}regParse(e,t){return this.lex(e,W({useRegex:!0},t||{}))}regSplit(e,t){return this.regParse(e,t).tokens}regMatch(e,t){return this.regParse(e,t).matches}}function B(e,t={}){const r=P.call(this);return r.OOHTML||(r.OOHTML={}),r.OOHTML.meta||(r.OOHTML.meta=r.DOM.meta("oohtml",!0)),r.OOHTML.meta.defaults(W(3,e,t)),r.OOHTML.meta}Z.$blocks=[["(",")"],["[","]"],["{","}"]],Z.$quotes=['"',"'","`"],Z.$comments=[["/*","*/"],["//","\n"]],Z.$cache=Object.create(null);const G=(e,t)=>Z.split(e.trim(),["|","+"],{preserveDelims:!0}).reduce(((e,r)=>{var n;return(r.startsWith("|")||r.startsWith("+"))&&(n=r.substr(0,1),r=r.substr(1).trim()),e.theEnd||"|"===n&&e.length?(e.theEnd=!0,e):e.concat(t(r.trim()))}),[]).filter((e=>e)),J=(e,t,r)=>{const n=e=>e.reduce(((e,t)=>e.concat(...r(t).values())),[]);return G(t,(t=>{var s,o,[t,i]=(s=t,o=Z.split(s.trim(),[":"]),[s=o.shift(),o.reduce(((e,t)=>{var[r,n]=Z.split(t.trim(),[]);return e[r]=D(n,"(",")"),e}),{})]);return e.reduce(((e,s)=>{var o=r(s);"*"===t&&(t="("+o.keys().join("+")+")");var l,c=("(",")",(l=t).startsWith("(")&&l.endsWith(")")?J([s],D(t,"(",")"),r):a(o.get(t),!1)),h=[];return Object.keys(i).forEach((e=>{if("deep"===e||"deepest"===e)for(var o=[s];("deepest"===e||!c.length)&&(o=n(o)).length;){var a=J(o,`${t}${h.map((e=>`:${e}(${i[e]})`)).join("")}`,r);a.length&&(c=a)}else"having"!==e&&"not-having"!==e||(c=c.filter((t=>{var n=G(i[e],(e=>r(t,e)));return"not-having"===e?!n.length:n.length}))),h.push(e)})),e.concat(c)}),[])}))},X=function(e,t,r,n=null,s=0){if(!t.length)return[];var o,i=t.shift();i.endsWith(".")&&(o=!0,i=i.substr(0,i.length-1).trim());var a=J(e,i,r);if(a.length&&o)return a;if(t.length){var l=X(a,t.slice(),r,n,s+1);return-1===l?n(a,s,!0):l}return n?n(a,s):a};(function t(r={}){const n=P.call(this);if(r.onDomReady)return void n.DOM.ready((()=>{t.call(this,{...r,onDomReady:!1})}));const s=n.window,o=n.window.document,i=n.DOM.mutations,l=B.call(this,{element:{template:"",export:"export",import:"import"},attr:{moduleid:"name",moduleref:"template",exportid:"name",exportgroup:"exportgroup"},api:{templateClass:"",templates:"templates",exports:"exports",moduleref:"template"}},r.params),c="template"+(l.get("element.template")?'[is="'+l.get("element.template")+'"]':"")+"["+s.CSS.escape(l.get("attr.moduleid"))+"]";var h=s.HTMLTemplateElement;if(l.get("api.templateClass")){if(!s[l.get("api.templateClass")])throw new Error('The custom element class "'+l.get("api.templateClass")+'" is not defined!');h=s[l.get("api.templateClass")]}const u=(e,t,r)=>{"templatemutation"===e&&(["addedExports","removedExports"].forEach((e=>{Object.defineProperty(t,e,{value:Object.keys(t[e]).map((r=>({name:r,items:t[e][r]})))})})),["addedTemplates","removedTemplates"].forEach((e=>{Object.defineProperty(t,e,{value:Object.keys(t[e]).map((r=>({name:r,item:t[e][r]})))})}))),Object.defineProperty(t,"path",{value:r}),o.dispatchEvent(new s.CustomEvent(e,{detail:t}))},d=(e,t)=>{const r=r=>{e.dispatchEvent(new s.CustomEvent(r,{detail:{path:t}}))};var n=e.getAttribute("src");return new Promise(((o,i)=>{s.fetch?s.fetch(n).then((e=>e.ok?e.text():Promise.reject(e.statusText))).then((n=>{e.innerHTML=n,r("load"),u("templatecontentloaded",{template:e},t),o(e)})).catch((s=>{console.error("Error fetching the bundle at "+n+". ("+s+")"),e.innerHTML="",r("loaderror"),u("templatecontentloaderror",{template:e},t),o(e)})):(o(),console.error("Error fetching the bundle at "+n+". (window.fetch() not supported by browser.)"))}))},m=(t,r,n,o=null,h=!0)=>{const f=(t,s,o,i)=>{var h;if(t.matches)if(t.matches(c)&&(h=t.getAttribute(l.get("attr.moduleid")))&&g(h)){var u=(n?n+"/":"")+h;"removed"===o?(e(r,"oohtml","templates").delete(h),e(r,"oohtml").get("parentTemplate")===r&&e(r,"oohtml").delete("parentTemplate"),s&&(s.removedTemplates[h]=t)):"added"===o&&(e(r,"oohtml","templates").set(h,t),e(t,"oohtml").set("parentTemplate",r),s&&(s.addedTemplates[h]=t)),m(t.content,t,u,o,i)}else{const n=t=>{var n=t.getAttribute(l.get("attr.exportgroup"))||"default";"removed"===o?e(r,"oohtml","exports").has(n)&&(function(e,t,r=!1){for(var n=e.indexOf(t);n>-1&&(r||!1===r);)e.splice(n,1),r>0&&r--,n=e.indexOf(t)}(e(r,"oohtml","exports").get(n),t),e(r,"oohtml","exports").has(n).length||e(r,"oohtml","exports").delete(n),s&&(s.removedExports[n]||(s.removedExports[n]=[]),s.removedExports[n].push(t))):"added"===o&&(e(r,"oohtml","exports").has(n)||e(r,"oohtml","exports").set(n,[]),e(r,"oohtml","exports").get(n).push(t),s&&(s.addedExports[n]||(s.addedExports[n]=[]),s.addedExports[n].push(t)))};if(t.matches(l.get("element.export"))){var d=t.getAttribute(l.get("attr.exportid"))||"default";a(t.children).forEach((e=>{e.setAttribute(l.get("attr.exportgroup"),d),n(e)}))}else n(t)}};r.modulemutationsType=o;const v={addedTemplates:Object.create(null),removedTemplates:Object.create(null),addedExports:Object.create(null),removedExports:Object.create(null)};if(a(t.children).forEach((e=>f(e,v,o,h))),h&&u("templatemutation",v,n),"added"===o&&!e(r,"oohtml").get("onLiveMode")){e(r,"oohtml").set("onLiveMode",!0),r.getAttribute("src")&&!r.content.children.length&&p.push(d(r,n)),i.onAttrChange(r,(e=>{e[0].target.getAttribute(e[0].attributeName)!==e[0].oldValue&&d(r,n)}),["src"]);var b=new s.MutationObserver((e=>{const t={addedTemplates:Object.create(null),removedTemplates:Object.create(null),addedExports:Object.create(null),removedExports:Object.create(null)};e.forEach((e=>{e.addedNodes.forEach((e=>f(e,t,"added",!0))),e.removedNodes.forEach((e=>f(e,t,"removed",!0)))})),u("templatemutation",t,n)}));b.observe(t,{childList:!0})}};if(l.get("api.templates")in o)throw new Error('document already has a "'+l.get("api.templates")+'" property!');const p=[];if(Object.defineProperty(o,l.get("api.templates"),{get:function(){return f(e(o,"oohtml","templates"))}}),l.get("api.templates")in h.prototype)throw new Error('The "HTMLTemplateElement" class already has a "'+l.get("api.templates")+'" property!');if(Object.defineProperty(h.prototype,l.get("api.templates"),{get:function(){return f(e(this,"oohtml","templates"))}}),l.get("api.exports")in h.prototype)throw new Error('The "HTMLTemplateElement" class already has a "'+l.get("api.exports")+'" property!');Object.defineProperty(h.prototype,l.get("api.exports"),{get:function(){return f(e(this,"oohtml","exports"))}});const f=e=>Object.defineProperties({},Array.from(e.keys()).reduce(((t,r)=>(t[r]={get:()=>e.get(r)},t)),{})),g=e=>{var t;return!(t=e.match(/([^a-zA-Z0-9\_\-\@])/))||(console.error(`Invalid character "${t}" in the module name: ${e}.`),!1)};if(a(o.querySelectorAll(c)).forEach((async t=>{var r=t.getAttribute(l.get("attr.moduleid"));!t.closest(l.get("element.import"))&&g(r)&&(e(o,"oohtml","templates").set(r,t),m(t.content,t,r,"added",!1))})),i.onPresenceChange(c,(async(t,r)=>{const n={addedTemplates:Object.create(null),removedTemplates:Object.create(null),addedExports:Object.create(null),removedExports:Object.create(null)};t.forEach((t=>{var s=t.getAttribute(l.get("attr.moduleid"));!t.closest(l.get("element.import"))&&g(s)&&(r?(e(o,"oohtml","templates").set(s,t),m(t.content,t,s,"added"),n.addedTemplates[s]=t):(e(o,"oohtml","templates").get(s)===t&&e(o,"oohtml","templates").delete(s),m(t.content,t,s,"removed"),n.removedTemplates[s]=t))})),u("templatemutation",n,"")})),i.onPresent(l.get("element.import"),(e=>{m(e,e,"","added",!1)})),l.get("api.moduleref")in s.Element.prototype)throw new Error('The "Element" class already has a "'+l.get("api.moduleref")+'" property!');Object.defineProperty(s.Element.prototype,l.get("api.moduleref"),{get:function(){var t;if(!e(this,"oohtml").has("module")&&(t=this.getAttribute(l.get("attr.moduleref")))){var r=(t=>{var r=o.createElement("template");return function(e,t,r,n=null){var s=t.split("#")[0].split("/").map((e=>e.trim())).filter((e=>e));return X(e,s,r,n)}([o],t,(function(t,r){var n=e(t,"oohtml","templates");return 1===arguments.length?n:r.startsWith(":")?e(t,"oohtml","exports").get(r.substr(1)):n.get(r)})).forEach((t=>{e(t,"oohtml","templates").forEach(((t,n)=>{e(r,"oohtml","templates").set(n,t)})),e(t,"oohtml","exports").forEach(((t,n)=>{e(r,"oohtml","exports").has(n)||e(r,"oohtml","exports").set(n,[]),e(r,"oohtml","exports").get(n).push(...t)}))})),r})(t);e(this,"oohtml").set("module",r)}return e(this,"oohtml").get("module")}});var v=p.length?"loading":"indeterminate";Object.defineProperty(o,"templatesReadyState",{get:()=>v}),n.DOM.ready.call(n,(()=>(p.forEach((e=>{e.catch((e=>{console.warn(e)}))})),Promise.all(p).then((()=>{v="complete",o.dispatchEvent(new s.Event("templatesreadystatechange"))})))))}).call(window)})();
2
- //# sourceMappingURL=html-modules.js.map
1
+ (()=>{function y(e){return!Array.isArray(e)&&typeof e=="object"&&e}function g(e,...t){globalThis.WebQitInternalsRegistry||(globalThis.WebQitInternalsRegistry=new Map);var r=globalThis.WebQitInternalsRegistry.get(e);if(!r){if(r=new Map,t[0]===!1)return r;globalThis.WebQitInternalsRegistry.set(e,r)}for(var o,i;o=t.shift();)if((i=r)&&!(r=r.get(o))){if(r=new Map,t[0]===!1)return r;i.set(o,r)}return r}function c(e){return Array.isArray(e)}function re(e){return e===!0||e===!1}function X(e){return typeof e=="function"}function me(e){return e===null||e===""}function Q(e){return arguments.length&&(e===void 0||typeof e>"u")}function T(e){return Array.isArray(e)||typeof e=="object"&&e||X(e)}function Oe(e){return me(e)||Q(e)||e===!1||e===0||T(e)&&!Object.keys(e).length}function C(e){return X(e)||e&&{}.toString.call(e)==="[object function]"}function z(e){return e instanceof Number||typeof e=="number"}function R(e){return z(e)||e!==!0&&e!==!1&&e!==null&&e!==""&&!isNaN(e*1)}function ue(e){return y(e)&&Object.getPrototypeOf(e)===Object.prototype}function V(e){return e instanceof String||typeof e=="string"&&e!==null}function we(e){return!V(e)&&!Q(e.length)}function U(e,t=1){var r=0;e.forEach(i=>{r++});var o=e.slice(e.length-r,t);return arguments.length>1?o:o[0]}function F(e,t=1){return arguments.length>1?U(e.slice().reverse(),t).reverse():U(e.slice().reverse())}function ae(e,...t){return t.forEach(r=>{e.indexOf(r)<0&&e.push(r)}),e}function Ee(o,t){t=t||Object.prototype,t=t&&!c(t)?[t]:t;for(var r=[],o=o;o&&(!t||t.indexOf(o)<0)&&o.name!=="default";)r.push(o),o=o?Object.getPrototypeOf(o):null;return r}function be(e,t){var r=[];return Ee(e,t).forEach(o=>{ae(r,...Object.getOwnPropertyNames(o))}),r}function q(e,t,r=!1,o=!1,i=!1){var n=0,f=e.shift();if((R(f)||f===!0||f===!1)&&(n=f,f=e.shift()),!e.length)throw new Error("_merge() requires two or more array/objects.");return e.forEach((s,u)=>{!T(s)&&!C(s)||(r?be(s):Object.getOwnPropertyNames(s)).forEach(a=>{if(!!t(a,f,s,u)){var p=f[a],m=s[a];if((c(p)&&c(m)||y(p)&&y(m))&&(n===!0||n>0))f[a]=c(p)&&c(m)?[]:{},q([R(n)?n-1:n,f[a],p,m],t,r,o,i);else if(c(f)&&c(s))o?f[a]=m:f.push(m);else try{i?Object.defineProperty(f,a,Object.getOwnPropertyDescriptor(s,a)):f[a]=s[a]}catch{}}})}),f}function oe(e,t){var r=void 0;return T(e)&&Object.keys(e).forEach((o,i)=>{r!==!1&&(r=t(R(o)?parseFloat(o):o,e[o],i))}),r}function H(...e){return q(e,(t,r,o)=>!0,!1,!1,!1)}function le(e,t,r=!1){if(t=="")return e;var o=r?e.lastIndexOf(t):e.indexOf(t);return o===-1?"":e.substr(o+t.length)}function Te(e,t,r=!1){if(t=="")return e;var o=r?e.lastIndexOf(t):e.indexOf(t);return o===-1?e:e.substr(0,o)}function N(e,t=!0){return c(e)?e:!t&&y(e)?[e]:e!==!1&&e!==0&&Oe(e)?[]:we(e)?Array.prototype.slice.call(e):y(e)?Object.values(e):[e]}function pe(e,t,r=!1){for(var o=e.indexOf(t);o>-1&&(r||r===!1);)e.splice(o,1),r>0&&r--,o=e.indexOf(t);return e}var He=function(e,t=1,r=!0){return!R(t)||t<=0||(!c(e)&&y(e)&&r&&(e=Object.values(e)),!c(e))?e:e.reduce((o,i)=>c(i)||y(i)&&r?o.concat(He(c(i)?i:Object.values(i),t-1,r)):o.concat(i),[])},Ae=He;function Y(e,t,r=!0,o=!0,i=!1,n=!1){if(c(e)&&c(t)){var f=[],s=!0;return e.forEach(u=>{if(!!s){var a=!1;oe(t,(p,m)=>{(!a||o&&T(u))&&(a=r(u,m),(c(a)&&!a.length||y(a)&&!Object.keys(a).length)&&(a=!1),T(a)&&o&&(u=a))}),T(a)?f.push(o?a:u):re(a)?i&&!a||!i&&a?f.push(u):n&&(s=!1):f.push(a)}}),f}if(y(e)&&y(t)){var f={},s=!0;return Object.keys(e).forEach(p=>{if(!!s){var m=r(e[p],t[p]);(c(m)&&!m.length||y(m)&&!Object.keys(m).length)&&(m=!1),T(m)?f[p]=o?m:e[p]:re(m)?i&&!m||!i&&m?f[p]=e[p]:n&&(s=!1):f[p]=m}}),f}}function ce(e,t=[]){return q([{},e],(r,o,i)=>{if(!C(i[r]))return C(t)?t(r):c(t)&&t.length?t.indexOf(r)>-1:!0},!1,!1,!1)}var Se=function(e,t,r=!0,o=1){if(c(e)&&c(t)&&e.length!==t.length)return!r;if(y(e)&&y(t)){var i=Object.keys(e),n=Object.keys(t);if(!i.length&&!n.length)return ue(e)&&ue(t)?r:e===t===r;if(!Se(i,n))return!r}if(o>0&&(c(e)&&c(t)||y(e)&&y(t))){var f=Y(e,t,(s,u)=>Se(s,u,r,o-1),!1,!1,!0);return c(f)?f.length===e.length&&f.length===t.length:y(f)&&y(e)?Object.keys(f).length===Object.keys(e).length&&Object.keys(f).length===Object.keys(t).length:f}return C(r)?r(e,t):z(e)&&z(t)&&isNaN(e)&&isNaN(t)?r:e===t===r},Me=Se;function W(e){return!Array.isArray(e)&&typeof e=="object"&&e}function ke(e){var t=typeof e.InstallTrigger<"u";if(t)return"firefox";var r=/constructor/i.test(e.HTMLElement)||function(a){return a.toString()==="[object SafariRemoteNotification]"}(!e.safari||typeof e.safari<"u"&&e.safari.pushNotification);if(r)return"safari";var o=!!e.chrome&&(!!e.chrome.webstore||!!e.chrome.runtime),i=o&&e.navigator.userAgent.indexOf("Edg")!=-1,n=!!e.opr&&!!e.opr.addons||!!e.opera||e.navigator.userAgent.indexOf(" OPR/")>=0,f=!!e.document.documentMode,s=!f&&!!e.StyleMedia,u=(o||n)&&!!e.CSS;return s?"edge":f?"ie":n?"opera":i?"ie-chromium":o?"chrome":"unknown"}function Be(e){var t=e.getComputedStyle(e.document.documentElement,""),r=(Array.prototype.slice.call(t).join("").match(/-(moz|webkit|ms)-/)||t.Olink===""&&["","o"])[1],o=("WebKit|Moz|Ms|O".match(new RegExp("("+r+")","i"))||[])[1];return{api:o,prefix:r,css:"-"+r+"-"}}function I(){if(!(W(this)&&this.window)&&typeof window>"u")throw new Error("A window context is required.");let e=W(this)&&this.window?this.window:window;if(e.WebQit||(e.WebQit={}),!e.WebQit.window){let t,r;Object.defineProperty(e.WebQit,"window",{get:()=>e}),Object.defineProperty(e.WebQit,"vendor",{value:{getName:()=>(t||(t=ke(e)),t),getPrefix:()=>(r||(r=Be(e)),r)}})}return e.WebQit}function de(e){return typeof e=="function"}function $(e){return Array.isArray(e)||typeof e=="object"&&e||de(e)}function ze(e){return e instanceof Number||typeof e=="number"}function Z(e){return ze(e)||e!==!0&&e!==!1&&e!==null&&e!==""&&!isNaN(e*1)}var ie=class{constructor(t,r=!0){this.window=t,this.async=r,this.readCallbacks=[],this.writeCallbacks=[],this._run()}_run(){this.window.requestAnimationFrame(()=>{this.readCallbacks.forEach((t,r)=>{t&&!t()&&(this.readCallbacks[r]=null)}),this.writeCallbacks.forEach((t,r)=>{t&&!t()&&(this.writeCallbacks[r]=null)}),this._run()})}onread(t,r=!1){if(r)return new Promise((o,i)=>{this.async===!1?t(o,i):this.readCallbacks.push(()=>{t(o,i)})});this.async===!1?t():this.readCallbacks.push(t)}onwrite(t,r=!1){if(r)return new Promise((o,i)=>{this.async===!1?t(o,i):this.writeCallbacks.push(()=>{t(o,i)})});this.async===!1?t():this.writeCallbacks.push(t)}cycle(t,r,o){this.onread(()=>{var i=t(o);if(i){var n=f=>{this.onwrite(()=>{var s=r(f,o);if(s){var u=a=>{this.cycle(t,r,a)};s instanceof Promise?s.then(u):u()}})};i instanceof Promise?i.then(n):n()}})}};function j(e){return e instanceof String||typeof e=="string"&&e!==null}function J(e){return Array.isArray(e)}function K(e){return arguments.length&&(e===void 0||typeof e>"u")}function Ve(e){return!j(e)&&!K(e.length)}function he(e){return e===null||e===""}function Ze(e){return he(e)||K(e)||e===!1||e===0||$(e)&&!Object.keys(e).length}function A(e,t=!0){return J(e)?e:!t&&W(e)?[e]:e!==!1&&e!==0&&Ze(e)?[]:Ve(e)?Array.prototype.slice.call(e):W(e)?Object.values(e):[e]}function ne(e){let t=I.call(this);t.DOM.isDOMReady||t.window.document.readyState==="complete"?e(t.window):(t.window.domReadyCallbacks||(t.window.domReadyCallbacks=[],t.window.document.addEventListener("DOMContentLoaded",()=>{t.DOM.isDOMReady=!0,t.window.domReadyCallbacks.splice(0).forEach(r=>r(t.window))},!1)),t.window.domReadyCallbacks.push(e))}var fe=class{constructor(t){this.window=t}onAdded(t,r,o={}){return o.on="added",this.onPresenceChange(t,(i,n,f,s,u)=>{r(i,n,f,s,u)},o)}onRemoved(t,r,o={}){return o.on="removed",this.onPresenceChange(t,(i,n,f,s,u)=>{r(i,n,f,s,u)},o)}onPresent(t,r,o={}){ne.call(this.window,()=>{this.window.MutationObserver&&this.onAdded(t,(i,n)=>{i.forEach(f=>r(f,n))},o),j(t)?A(this.window.document.querySelectorAll(t)).forEach(i=>r(i,1)):t.parentNode&&r(t,1)})}onAbsent(t,r,o={}){ne.call(this.window,()=>{this.window.MutationObserver&&onRemoved(t,(i,n)=>{i.forEach(f=>r(f,n))},o),j(t)?A(this.window.document.querySelectorAll(t)).length===0&&r(null,0):t.parentNode||r(t,0)})}onPresenceChange(t,r,o={}){t=A(t,!1);var i=(m,d)=>{if(d=d.filter(S=>S.matches),j(m)){var v=d.filter(S=>S.matches(m));if(o.observeIndirectMutation!==!1&&(v=d.reduce((S,h)=>S.concat(A(h.querySelectorAll(m))),v),v.length))return v}else{if(d.includes(m))return[m];if(o.observeIndirectMutation!==!1&&d.length){for(var w=m;w=w.parentNode;)if(d.includes(w))return[m]}}},n=(m,d)=>(d.$$searchCache||(d.$$searchCache=new Map),m.reduce((v,w)=>{var S;return d.$$searchCache.has(w)?S=d.$$searchCache.get(w):(S=i(w,d,j(w))||[],d.$$searchCache.set(w,S)),v.concat(S)},[])),f=new Set,s=new Set,u=(m,d,v)=>{d&&o.on==="removed"||!d&&o.on==="added"||(m=n(t,m)).length&&(o.maintainCallState?(m.forEach(w=>{d?(f.add(w),s.delete(w)):(f.delete(w),s.add(w))}),r(m,d,v,f,s)):r(m,d,v))},a=o.context||this.window.document.documentElement,p=this._observe(a,(m,d,v,w)=>{o.ignoreTransients||(u(m,0,!0),u(m.concat(d),1,!0),u(d,0,!0)),u(w,0),u(v,1)});return p}onAttrChange(t,r,o=[]){var i=new this.window.MutationObserver(r),n={attributes:!0,attributeOldValue:!0};return o&&(n.attributeFilter=o),i.observe(t,n),i}onTreeChange(t,r,o=!1){var i=new this.window.MutationObserver(r),n={childList:!0,subtree:o};return i.observe(t,n),i}onMutation(t,r,o){var i=new this.window.MutationObserver(r);return i.observe(t,o),i}_observe(t,r){if(!Ne.has(t)){let i=new Set,n=new this.window.MutationObserver(f=>{if(!!i.size){var s=f.reduce((m,d)=>m.concat(A(d.addedNodes)),[]),u=f.reduce((m,d)=>m.concat(A(d.removedNodes)),[]),a=[],p=[];s=new Set(s),u=new Set(u),s.forEach(m=>{u.has(m)&&(u.delete(m),s.delete(m),m.isConnected?a.push(m):p.push(m))}),s=[...s],u=[...u],i.forEach(m=>m(a,p,s,u))}});n.observe(t,{childList:!0,subtree:!0}),Ne.set(t,{callbacks:i,observer:n})}let o=Ne.get(t);return o.callbacks.add(r),{disconnect(){o.callbacks.delete(r)},reconnect(){o.callbacks.add(r)}}}},Ne=new Map;function Je(e){_t(e),xt(e),yt(e)}function _t(e){e.CSS||(e.CSS={}),e.CSS.escape||(e.CSS.escape=t=>t.replace(/([\:@\~\$\&])/g,"\\$1"))}function xt(e){"isConnected"in e.Node.prototype||Object.defineProperty(e.Node.prototype,"isConnected",{get:function(){return!this.ownerDocument||!(this.ownerDocument.compareDocumentPosition(this)&this.DOCUMENT_POSITION_DISCONNECTED)}})}function yt(e){e.Element.prototype.matches||(e.Element.prototype.matches=e.Element.prototype.matchesSelector||e.Element.prototype.mozMatchesSelector||e.Element.prototype.msMatchesSelector||e.Element.prototype.oMatchesSelector||e.Element.prototype.webkitMatchesSelector||function(t){for(var r=(this.document||this.ownerDocument).querySelectorAll(t),o=r.length;--o>=0&&r.item(o)!==this;);return o>-1})}function ge(e,t=null,r=!1){let o=I.call(this);if(j(e)){var i;if(e.trim().startsWith("<")){var n=o.window.document.createElement("div");n.innerHTML=e,i=r?A(n.children):n.firstChild}else i=r?A(Xe.call(this,e,t)):$e.call(this,e,t);return i}return e instanceof o.window.Element?r?[e]:e:r?A(e):e}function Ge(e,t=null){return ge.call(this,e,t,!0)}function $e(e,t=null,r=!1){let o=I.call(this);t=t||o.window.document;var i,n=r?"querySelectorAll":"querySelector";try{i=t[n](e)}catch{try{i=t[n](e.replace(/\:is\(/g,":matches("))}catch{try{i=t[n](e.replace(/\:is\(/g,":-webkit-any("))}catch{try{i=t[n](e.replace(/\:is\(/g,":-moz-any("))}catch(a){throw a}}}}return i}function Xe(e,t=null){return $e.call(this,e,t,!0)}function G(e){return de(e)||e&&{}.toString.call(e)==="[object function]"}function k(e,t,r={},o={}){t=A(t).slice();for(var i=e;!K(i)&&!he(i)&&t.length;){var n=t.shift();if(!(r.get?r.get(i,n):$(i)?n in i:i[n])){o.exists=!1;return}i=r.get?r.get(i,n):i[n]}return o.exists=!0,i}function _e(e,t,r,o={},i={}){let n=(p,m,d)=>i.set?i.set(p,m,d):(Z(t[s])&&J(p)?p.push(d):p[m]=d,!0);t=A(t);for(var f=e,s=0;s<t.length;s++)if(s<t.length-1){if(!f||!$(f)&&!G(f))return!1;var u=k(f,t[s],i);if(!$(u)){if(i.buildTree===!1)return!1;u=G(i.buildTree)?i.buildTree(s):Z(t[s+1])?[]:{};var a=n(f,t[s],u);if(!a)return!1}f=u}else return n(f,t[s],r)}function Ye(e,t,r=!1,o={}){t=A(t);var i=!1;do{var n=t.pop(),n=n===""?0:n,f=e;t.length&&(f=k(e,t,{},o)),($(f)||G(f))&&(o.has?o.has(f,n):n in f)&&(o.deleteProperty?i=o.deleteProperty(f,n):o.del?i=o.del(f,n):(delete f[n],i=!0))}while(i&&r&&t.length&&($(f)||G(f))&&!(o.keys?o.keys(f):Object.keys(f)).length);return i}function Fe(e,t,r={}){var o={};return k(e,t,r,o),o.exists}function qe(e,t=!1){let r=I.call(this);var o={};return!(o.el=r.window.document.head.querySelector('meta[name="oohtml"]'))&&t&&(o.el=r.window.document.createElement("meta"),o.el.setAttribute("name",e),r.window.document.head.append(o.el)),o.el&&(o.vars=(o.el.getAttribute("content")||"").split(";").filter(i=>i).reduce((i,n)=>{var f=n.split("=").map(s=>s.trim());return _e(i,f[0].split("."),f[1]==="true"?!0:f[1]==="false"?!1:Z(f[1])?parseInt(f[1]):f[1]),i},{})),o.get=function(i){return k(this.vars,i.split("."))},o.set=function(i,n=null,f=!1){var s=W(i)?i:{[i]:n===!0?"true":n};if(f=arguments.length<3?n:f,Object.keys(s).forEach(u=>{if(s[u]===!1)Ye(this.vars,u.split("."));else if(W(s[u]))Object.keys(s[u]).forEach(p=>{var m=(u+"."+p).split(".");(!f||!Fe(this.vars,m))&&_e(this.vars,m,s[u][p])});else{var a=u.split(".");(!f||!Fe(this.vars,a))&&_e(this.vars,a,s[u])}}),t){let u=(a,p)=>Object.keys(p).reduce((m,d)=>{var v=(a?a+".":"")+d;return W(p[d])?m.push(...u(v,p[d])):m.push(v+"="+p[d]),m},[]);this.el.setAttribute("content",u("",this.vars).join(";"))}return!0},o.defaults=function(i,n=null){return this.set(i,n,!0)},o}function xe(){let e=I.call(this);return e.DOM||(e.DOM={},Je(e.window),e.DOM.reflow=new ie(e.window),e.DOM.mutations=new fe(e.window),e.DOM.meta=qe.bind(e.window),e.DOM.query=ge.bind(e.window),e.DOM.queryAll=Ge.bind(e.window),e.DOM.ready=ne.bind(e.window)),e}function We(e,t){return Te(e,t,!0)}function ye(e,t,r){return We(le(e,t),r)}function De(e,t,r){return e.startsWith(t)&&e.endsWith(r)}var E=class{static lex(t,r,o={}){if(!V(t=t+""))throw new Error("Argument1 must be a string!");var i=a=>({delims:a.delims.slice(),options:ce(a.options),nesting:a.nesting.slice(),maxDepth:a.maxDepth,comments:a.comments.slice(),tokens:a.tokens.slice(),matches:a.matches.slice(),matchesi:ce(a.matchesi)});if(E.$cache[t]&&o.cache!==!1)for(var n=0;n<E.$cache[t].length;n++){var f=E.$cache[t][n];if(Me(f.delims,r))return i(f)}var s=new E(t,o),u=s.lex(r);return o.cache!==!1&&(E.$cache[t]=E.$cache[t]||[],E.$cache[t].push(u)),i(u)}static split(t,r,o){return E.lex(t,r,o).tokens}static match(t,r,o){return E.lex(t,r,o).matches}constructor(t,r){if(!V(t))throw new Error("Lexer requires the first argument to be a string.");this.$str=t,this.$options=r||{},this.$options.blocks||(this.$options.blocks=E.$blocks),this.$options.quotes||(this.$options.quotes=E.$quotes),this.$options.comments||(this.$options.comments=E.$comments)}lex(t,r){for(var o={delims:N(t),options:H(!0,{},this.$options,r||{}),nesting:[],maxDepth:0,comments:[],tokens:[],matches:[],matchesi:{}},i=0;typeof i=="number";)i=this._evalCharsAt(o,i);if(o.nesting.length)throw new Error("Error parsing the string: "+this.$str+". Unterminated blocks: "+Ae(o.nesting).join(", "));return o}_evalCharsAt(t,r){if(!(r>=this.$str.length)){var o=1,i={},n={},f={};if(t.openComment||(n=this._testQuotes(t,r)),t.openQuote||(i=this._testComments(t,r)),t.openComment||i.ending)if(!t.nesting.length&&!f.ending){var s=i.starting||i.ending||this.$str[r];o=s.length,this._push(t,s,"comments",i.starting)}else this._push(t,this.$str[r]);else if(t.openQuote||n.ending)this._push(t,this.$str[r]);else{if(t.options.limit&&t.matches.length===t.options.limit)return this._push(t,this.$str[r]),r+1;f=this._testNesting(t,r);var f=this._testNesting(t,r),u=this._testChars(t.options.stopChars||[],t,r);if(!t.nesting.length&&u!==!1){t.options.stopChar=u,t.options.stopCharForward=this.$str.substr(r);return}if(!t.delims.length)t.nesting.length===2&&f.starting?(t.matches.push(null),this._push(t,f.starting),o=f.starting.length):!t.nesting.length&&f.ending?(this._push(t,f.ending),o=f.ending.length,t.matches.push(null)):this._push(t,this.$str[r]);else if(!t.nesting.length&&!f.ending){this._push(t,"");var a=this._testChars(t.delims,t,r);if(a!==!1&&(t.matches.push(a),t.matchesi[r]=a,o=a.length||1,!t.options.preserveDelims)){var p=r+(a.length||1);return p===this.$str.length&&this._push(t,""),p}this._push(t,a||this.$str[r])}else{var s=f.starting||f.ending||this.$str[r];o=s.length,this._push(t,s)}}return r+o}}_testQuotes(t,r){var o={};return(t.options.quotes||[]).forEach(i=>{this.$str.substr(r,1)===i&&(t.openQuote?i===t.openQuote&&(t.openQuote=!1,o.ending=i):(t.openQuote=i,o.starting=i))}),o}_testComments(t,r){var o={};return(t.options.comments||[]).forEach(i=>{if(t.openComment){if(F(i)===F(t.openComment)){var f=F(i);this.$str.substr(r).startsWith(f)&&(t.openComment=!1,o.ending=f)}}else{var n=U(i);this.$str.substr(r).startsWith(n)&&(t.openComment=i,o.starting=n)}}),o}_testNesting(t,r){var o={};return(t.options.blocks||[]).forEach(i=>{var n=U(i);if(this.$str.substr(r).startsWith(n))t.nesting=t.nesting.concat([i]),o.starting=n;else if(t.nesting.length&&F(i)===F(F(t.nesting))){var f=F(i);this.$str.substr(r).startsWith(f)&&(t.nesting=t.nesting.slice(0,-1),o.ending=f)}}),t.maxDepth=Math.max(t.maxDepth,t.nesting.length),o}_testChars(t,r,o){for(var i=0;i<t.length;i++){var n=t[i];if(C(n)){var f=n(this.$str.substr(0,o),this.$str.substr(o),r.tokens.slice());if(f!==!1)return f}if(r.options.useRegex){var s=this.$str.substr(o).match(new RegExp("^"+n,r.options.useRegex!==!0?r.options.useRegex:""));if(s)return s[0]}if(!r.options.ci&&this.$str.substr(o,n.length)===n||r.options.ci&&this.$str.substr(o,n.length).toLowerCase()===n.toLowerCase())return n}return!1}_push(t,r,o="tokens",i=!1){var n=t.matches.length;if(Q(t.tokens[n])&&(t.tokens[n]=""),o==="comments"){t.tokens[n].comments||(t.tokens[n]=new String(t.tokens[n]),t.tokens[n].comments=[]);var f=t.tokens[n].comments.length-(!t.tokens[n].comments.length||i?0:1);t.tokens[n].comments[f]=(t.tokens[n].comments[f]||"")+r}else{var s=t.tokens[n].comments;t.tokens[n]=t.tokens[n]+r}}split(t,r,o){return this.lex(r,o).tokens}match(t,r,o){return this.lex(r,o).matches}regParse(t,r){return this.lex(t,H({useRegex:!0},r||{}))}regSplit(t,r){return this.regParse(t,r).tokens}regMatch(t,r){return this.regParse(t,r).matches}};E.$blocks=[["(",")"],["[","]"],["{","}"]];E.$quotes=['"',"'","`"];E.$comments=[["/*","*/"],["//",`
2
+ `]];E.$cache=Object.create(null);function et(e,t={}){let r=xe.call(this);return r.OOHTML||(r.OOHTML={}),r.OOHTML.meta||(r.OOHTML.meta=r.DOM.meta("oohtml",!0)),r.OOHTML.meta.defaults(H(3,e,t)),r.OOHTML.meta}function tt(e,t,r,o=null){var i=t.split("#")[0].split("/").map(n=>n.trim()).filter(n=>n);return rt(e,i,r,o)}function Ot(e){var t=E.split(e.trim(),[":"]);e=t.shift();var r=t.reduce((o,i)=>{var[n,f]=E.split(i.trim(),[]);return o[n]=ye(f,"(",")"),o},{});return[e,r]}var Ke=(e,t)=>E.split(e.trim(),["|","+"],{preserveDelims:!0}).reduce((r,o)=>{var i;return(o.startsWith("|")||o.startsWith("+"))&&(i=o.substr(0,1),o=o.substr(1).trim()),r.theEnd||i==="|"&&r.length?(r.theEnd=!0,r):r.concat(t(o.trim()))},[]).filter(r=>r),Qe=(e,t,r)=>{let o=i=>i.reduce((n,f)=>n.concat(...r(f).values()),[]);return Ke(t,n=>{var[n,f]=Ot(n);return e.reduce((s,u)=>{var a=r(u);n==="*"&&(n="("+a.keys().join("+")+")");var p=De(n,"(",")")?Qe([u],ye(n,"(",")"),r):N(a.get(n),!1),m=[],d=v=>`${v}${m.map(w=>`:${w}(${f[w]})`).join("")}`;return Object.keys(f).forEach(v=>{if(v==="deep"||v==="deepest")for(var w=[u];(v==="deepest"||!p.length)&&(w=o(w)).length;){var S=Qe(w,d(n),r);S.length&&(p=S)}else(v==="having"||v==="not-having")&&(p=p.filter(h=>{var l=Ke(f[v],O=>r(h,O));return v==="not-having"?!l.length:l.length})),m.push(v)}),s.concat(p)},[])})},rt=function(e,t,r,o=null,i=0){if(!t.length)return[];var n=t.shift(),f;n.endsWith(".")&&(f=!0,n=n.substr(0,n.length-1).trim());var s=Qe(e,n,r);if(s.length&&f)return s;if(t.length){var u=rt(s,t.slice(),r,o,i+1);return u===-1?o(s,i,!0):u}return o?o(s,i):s};function ve(e={}){let t=xe.call(this);if(e.onDomReady){t.DOM.ready(()=>{ve.call(this,{...e,onDomReady:!1})});return}let r=t.window,o=t.window.document,i=t.DOM.mutations,n=et.call(this,{element:{template:"",export:"export",import:"import"},attr:{moduleid:"name",moduleref:"template",exportid:"name",exportgroup:"exportgroup"},api:{templateClass:"",templates:"templates",exports:"exports",moduleref:"template"}},e.params),f="template"+(n.get("element.template")?'[is="'+n.get("element.template")+'"]':"")+"["+r.CSS.escape(n.get("attr.moduleid"))+"]";var s=r.HTMLTemplateElement;if(n.get("api.templateClass")){if(!r[n.get("api.templateClass")])throw new Error('The custom element class "'+n.get("api.templateClass")+'" is not defined!');s=r[n.get("api.templateClass")]}let u=(h,l,O)=>{h==="templatemutation"&&(["addedExports","removedExports"].forEach(_=>{Object.defineProperty(l,_,{value:Object.keys(l[_]).map(x=>({name:x,items:l[_][x]}))})}),["addedTemplates","removedTemplates"].forEach(_=>{Object.defineProperty(l,_,{value:Object.keys(l[_]).map(x=>({name:x,item:l[_][x]}))})})),Object.defineProperty(l,"path",{value:O}),o.dispatchEvent(new r.CustomEvent(h,{detail:l}))},a=(h,l)=>{let O=x=>{h.dispatchEvent(new r.CustomEvent(x,{detail:{path:l}}))};var _=h.getAttribute("src");return new Promise((x,se)=>{r.fetch?r.fetch(_).then(D=>D.ok?D.text():Promise.reject(D.statusText)).then(D=>{h.innerHTML=D,O("load"),u("templatecontentloaded",{template:h},l),x(h)}).catch(D=>{console.error("Error fetching the bundle at "+_+". ("+D+")"),h.innerHTML="",O("loaderror"),u("templatecontentloaderror",{template:h},l),x(h)}):(x(),console.error("Error fetching the bundle at "+_+". (window.fetch() not supported by browser.)"))})},p=(h,l,O,_=null,x=!0)=>{let se=(b,M,L,ee)=>{if(!!b.matches){var B,Re;if(b.matches(f)&&(B=b.getAttribute(n.get("attr.moduleid")))&&v(B)){var it=(O?O+"/":"")+B;L==="removed"?(g(l,"oohtml","templates").delete(B),g(l,"oohtml").get("parentTemplate")===l&&g(l,"oohtml").delete("parentTemplate"),M&&(M.removedTemplates[B]=b)):L==="added"&&(g(l,"oohtml","templates").set(B,b),g(b,"oohtml").set("parentTemplate",l),M&&(M.addedTemplates[B]=b)),p(b.content,b,it,L,ee)}else{let Ie=te=>{var P=te.getAttribute(n.get("attr.exportgroup"))||"default";L==="removed"?g(l,"oohtml","exports").has(P)&&(pe(g(l,"oohtml","exports").get(P),te),g(l,"oohtml","exports").has(P).length||g(l,"oohtml","exports").delete(P),M&&(M.removedExports[P]||(M.removedExports[P]=[]),M.removedExports[P].push(te))):L==="added"&&(g(l,"oohtml","exports").has(P)||g(l,"oohtml","exports").set(P,[]),g(l,"oohtml","exports").get(P).push(te),M&&(M.addedExports[P]||(M.addedExports[P]=[]),M.addedExports[P].push(te)))};if(b.matches(n.get("element.export"))){var Re=b.getAttribute(n.get("attr.exportid"))||"default";N(b.children).forEach(P=>{P.setAttribute(n.get("attr.exportgroup"),Re),Ie(P)})}else Ie(b)}}};l.modulemutationsType=_;let D={addedTemplates:Object.create(null),removedTemplates:Object.create(null),addedExports:Object.create(null),removedExports:Object.create(null)};if(N(h.children).forEach(b=>se(b,D,_,x)),x&&u("templatemutation",D,O),_==="added"&&!g(l,"oohtml").get("onLiveMode")){g(l,"oohtml").set("onLiveMode",!0),l.getAttribute("src")&&!l.content.children.length&&m.push(a(l,O)),i.onAttrChange(l,b=>{b[0].target.getAttribute(b[0].attributeName)!==b[0].oldValue&&a(l,O)},["src"]);var ot=new r.MutationObserver(b=>{let M={addedTemplates:Object.create(null),removedTemplates:Object.create(null),addedExports:Object.create(null),removedExports:Object.create(null)};b.forEach(L=>{L.addedNodes.forEach(ee=>se(ee,M,"added",!0)),L.removedNodes.forEach(ee=>se(ee,M,"removed",!0))}),u("templatemutation",M,O)});ot.observe(h,{childList:!0})}};if(n.get("api.templates")in o)throw new Error('document already has a "'+n.get("api.templates")+'" property!');let m=[];if(Object.defineProperty(o,n.get("api.templates"),{get:function(){return d(g(o,"oohtml","templates"))}}),n.get("api.templates")in s.prototype)throw new Error('The "HTMLTemplateElement" class already has a "'+n.get("api.templates")+'" property!');if(Object.defineProperty(s.prototype,n.get("api.templates"),{get:function(){return d(g(this,"oohtml","templates"))}}),n.get("api.exports")in s.prototype)throw new Error('The "HTMLTemplateElement" class already has a "'+n.get("api.exports")+'" property!');Object.defineProperty(s.prototype,n.get("api.exports"),{get:function(){return d(g(this,"oohtml","exports"))}});let d=h=>Object.defineProperties({},Array.from(h.keys()).reduce((l,O)=>(l[O]={get:()=>h.get(O)},l),{})),v=h=>{var l;return(l=h.match(/([^a-zA-Z0-9\_\-\@])/))?(console.error(`Invalid character "${l}" in the module name: ${h}.`),!1):!0},w=h=>{var l=o.createElement("template");return tt([o],h,function(O,_){var x=g(O,"oohtml","templates");return arguments.length===1?x:_.startsWith(":")?g(O,"oohtml","exports").get(_.substr(1)):x.get(_)}).forEach(O=>{g(O,"oohtml","templates").forEach((_,x)=>{g(l,"oohtml","templates").set(x,_)}),g(O,"oohtml","exports").forEach((_,x)=>{g(l,"oohtml","exports").has(x)||g(l,"oohtml","exports").set(x,[]),g(l,"oohtml","exports").get(x).push(..._)})}),l};if(N(o.querySelectorAll(f)).forEach(async h=>{var l=h.getAttribute(n.get("attr.moduleid"));!h.closest(n.get("element.import"))&&v(l)&&(g(o,"oohtml","templates").set(l,h),p(h.content,h,l,"added",!1))}),i.onPresenceChange(f,async(h,l)=>{let O={addedTemplates:Object.create(null),removedTemplates:Object.create(null),addedExports:Object.create(null),removedExports:Object.create(null)};h.forEach(_=>{var x=_.getAttribute(n.get("attr.moduleid"));!_.closest(n.get("element.import"))&&v(x)&&(l?(g(o,"oohtml","templates").set(x,_),p(_.content,_,x,"added"),O.addedTemplates[x]=_):(g(o,"oohtml","templates").get(x)===_&&g(o,"oohtml","templates").delete(x),p(_.content,_,x,"removed"),O.removedTemplates[x]=_))}),u("templatemutation",O,"")}),i.onPresent(n.get("element.import"),h=>{p(h,h,"","added",!1)}),n.get("api.moduleref")in r.Element.prototype)throw new Error('The "Element" class already has a "'+n.get("api.moduleref")+'" property!');Object.defineProperty(r.Element.prototype,n.get("api.moduleref"),{get:function(){var h;if(!g(this,"oohtml").has("module")&&(h=this.getAttribute(n.get("attr.moduleref")))){var l=w(h);g(this,"oohtml").set("module",l)}return g(this,"oohtml").get("module")}});var S=m.length?"loading":"indeterminate";Object.defineProperty(o,"templatesReadyState",{get:()=>S}),t.DOM.ready.call(t,()=>(m.forEach(h=>{h.catch(l=>{console.warn(l)})}),Promise.all(m).then(()=>{S="complete",o.dispatchEvent(new r.Event("templatesreadystatechange"))})))}ve.call(window);})();
3
+ //# sourceMappingURL=html-modules.js.map