forked from dagger8224/dagger.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdagger.min.js
1 lines (1 loc) · 38.8 KB
/
dagger.min.js
1
export default((e={integrity:!0},t=[],s=(()=>Object.create(null)),r=((e,t)=>{if(!e)return;const s=e.length||0;for(let r=0;r<s;++r)t(e[r],r)}),i=(e=>{if(e&&w(typeof e,"object")){r(C(e),t=>i(e[t]));try{Object.freeze(e)}catch(e){}}return e}),o=((...e)=>{const t=s();return r(e,e=>t[e]=!0)||t}),n=s(),l=document.head,a=s(),c=!1,h=Symbol("meta"),d=new Set,u=Object.assign(s(),{$modules:s(),$router:s(),$validator:(e,t,{type:s,assert:i,required:o}={})=>{(null==e||Number.isNaN(e))&&_([`The data "${t}" should be assigned a valid value instead of "%o" before using`,e],!o),s&&(Array.isArray(s)?_([`The type of data "${t}" should be one of "%o" instead of "%o"`,s,(e.constructor||{}).name],s.some(t=>T(e,t))):_([`The type of data "${t}" should be "%o" instead of "%o"`,s,(e.constructor||{}).name],T(e,s))),i&&(T(i,Function)?_(`The assert of "${t}" is falsy`,i(e)):Array.isArray(i)?r(i,s=>{_(`The type of assert should be "function" instead of "${typeof s}"`,T(s,Function)),_(`The assert of "${t}" is falsy`,s(e))}):_(`The type of assert should be "function" or "function array" instead of "${typeof i}"`))}}),p=s(),m=new Set,f=new Map,y=((e={controller:null,sensitive:!1,topology:null})=>(t=null)=>Object.assign(p,e,t))(),g=((e,t=1)=>{if(w(t,1))return`_$$_dg_scope => { with (_$$_dg_scope) { return ${e}; } }`;{const s=new Array(t).fill().map((e,t)=>`_$$_dg_scope_${t}`);return`(${s.join(", ")}) => { ${s.map(e=>`with (${e})`).join(" ")} { return ${e}; } }`}}),v=((e,t=document.baseURI)=>{const s=k(e,'script[type="dagger/configs"]'),r=s.getAttribute("src");return s.hasAttribute("base")&&(t=new URL(s.getAttribute("base")||"",t).href),r?j(new URL(r,t),s.integrity,!0).then(({content:e})=>({base:t,content:N(e)})):{base:t,content:N(s.textContent)}}),b=(e=>r(Reflect.ownKeys(e),t=>Reflect.deleteProperty(e,t))),$=((t,s,r)=>e.directiveAttribute&&t.setAttribute(`${s}-debug`,r)),S=(e=>new Function(`return ${e};`)()),w=((e,t)=>Object.is(e,t)),T=((e,t=Object)=>e instanceof t),A=(e=>w(typeof e,"string")),N=(e=>{try{return JSON.parse(e)}catch(t){_(`Failed to parse string "${e}" as JSON`)}}),C=(e=>Reflect.ownKeys(e).filter(e=>!w(e,h))),E=(e=>`'${e}'`),x=(([e,...t],s={stop:!1})=>{if(!s.stop)return T(e,Promise)?e.then(e=>x([e,...t],s)):T(e,Function)?x([e(null,s),...t],s):t.length?x([t.shift()(e,s),...t],s):e}),k=((e,t,s=!1,r=!1)=>{const i=e[s?"querySelectorAll":"querySelector"](t);return r||_(`Failed to get element matched selector "${t}"`,s?i.length:i),i}),j=((t,s="",r=!1)=>fetch(t,e.integrity&&s?{integrity:`sha256-${s}`}:{}).then(e=>{if(e.ok){const s=e.headers.get("content-type");return _(`Missing "content-type" for the response content of "${t}"`,s),e.text().then(e=>({content:e,type:s}))}_(`Failed to fetch remote module from "${t}"`,!r)}).catch(()=>{const s=`Failed to fetch remote module from "${t}"`;r?_(s):e.moduleLog&&I(s)})),R=(e=>{try{return JSON.parse(e.replace(/'/g,'"'))}catch(t){return e}}),L=(e=>{const t=document.createElement("template");return t.innerHTML=e,t.content}),M=((e,t)=>r(e.children,e=>{w(e.tagName,"TEMPLATE")?(e.getAttribute("$html")&&e.setAttribute("dg_scoped_styles",t.join(",")),M(e.content,t)):T(e,HTMLElement)&&r(t,t=>e.setAttribute(t,""))})),O=((e,t=!0)=>{if(!A(e)){if(null==e||Number.isNaN(e))return"";if(T(e))return JSON.stringify(e);e=String(e)}return t?e.trim():e}),P=(e=>e&&Reflect.has(e[h]||{},"value")?e[h].value:e.value||e.textContent),{asserter:_,logger:U,warner:I}=((e=((e,t,s)=>{const i=e.startsWith('"')?1:0,o=[],n=[];return r(e.split('"').filter(e=>e),(e,r)=>(r+i)%2?o.push(`%c"${e}"`)&&n.push(s):o.push(`%c${e}`)&&n.push(t))||[o.join(""),...n]}),t=((t,s,i,o,n,l=!1)=>{if(s)return;if(Array.isArray(t)){const[s,...l]=t,a='%c"%o"';let c=[],h="";r(`${s}, please double check.`.split('"%o"'),(t,s)=>{const[r,...i]=e(t,o,n);h+=r,c=[...c,...i],s<l.length&&(h+=a,c=[...c,n,l[s]])}),i(h,...c)}else i(...e(`${t}, please double check.`,o,n));if(l)throw new Error("dagger AssertionError occurred!")}))=>({asserter:(e,s)=>t(e,s,console.assert.bind(console,!1),"color: #ff0000","color: #b22222",!0),logger:t=>console.log(...e(t,"color: #337ab7","color: #9442d0")),warner:(e,s)=>t(e,s,console.warn,"color: #ff0000","color: #b22222")}))(),F=((e=((e,t,s,{name:r})=>w(e)?t.removeAttribute(r):t.setAttribute(r,O(e))),t=((t=new Event("change"),s=((e,t,s,r,i,o,n,l,a,c,h,d,u)=>{let p=null;const m=i.get(s);if(m){if(p=m.shift(),m.length||i.delete(s),e>0){const t=r[e-1],s=p.landmark;if(w(t.landmark.compareDocumentPosition(s),Node.DOCUMENT_POSITION_PRECEDING)){const e=p.upperBoundary,r=[e];let i=e;for(;!w(i,s);)i=i.nextSibling,r.push(i);const o=document.createDocumentFragment();o.append(...r),u.insertBefore(o,t.landmark.nextSibling)}}p.index=e,r[e]=p,p.resolvedSliceScope[l]=t,p.resolvedSliceScope[n]=e}else p=new D(h,d,c,e,{[l]:t,[a]:s,[n]:e});const f=o.get(s);f?f.push(p):o.set(s,[p])}),i=((e,t,s)=>{const r=P(e);return s?(t||[]).some(e=>w(e,r)):w(t,r)}),o=((e,t)=>{if(!t)return;const[s,r=""]=t.split(":").map(e=>e.trim());_(`The content "${t}" is not a valid style declaration`,s&&r),e[s]=r}),l=((e,t=2)=>String(e).padStart(t,"0")))=>({$boolean:(e,t,s,{name:r})=>e?t.setAttribute(r,""):t.removeAttribute(r),checked:(s,i,{parentNode:o},{decorators:n})=>{const{tagName:l,type:a}=i,c=w(l,"OPTION"),h=w(a,"radio");if(c||w(l,"INPUT")&&(h||w(a,"checkbox"))){let e=null;if(s=!!s,c){if(w(s,i.selected))return;i.selected=s;const n=o;n&&(!n.multiple&&s&&(e=k(n,"option",!0)),n.$changeEvent||(n.$changeEvent=!0,n.addEventListener("change",e=>r(k(e.target,"option",!0),e=>e.dispatchEvent(t)))))}else i.checked=s,h&&s&&(e=k(n.scope?k(document,n.scope):o,`input[type="radio"][name="${i.name}"]`,!0,!0));e&&r(e,e=>e.dispatchEvent(t))}else e(s,i,null,{name:"checked"})},class:(e,t,{profile:{classNames:s}})=>{if(e){const i=new Set(s);Array.isArray(e)?r(e,e=>i.add(O(e))):T(e)?r(Object.entries(e),([e,t])=>t&&i.add(e.trim())):i.add(O(e)),t.className=[...i].join(" ").trim()}else s?t.className=s.join(" "):t.removeAttribute("class")},each:(e,t,i,{decorators:o})=>{e=Object.entries(e||n);const{children:l,childrenMap:a=new Map,profile:c,parentNode:h}=i;if(!e.length)return a.clear()||i.removeChildren();let{item:d="item",key:u="key",index:p="index"}=o;w(d,!0)&&(d="item"),w(u,!0)&&(u="key"),w(p,!0)&&(p="index"),I(['duplication found in slice scope schemes "%o"',{item:d,key:u,index:p}],!w(u,p)&&!w(u,d)&&!w(d,p));const m=new Map,f=i.closures.slice;r(e,([e,t],r)=>s(r,e,t,l,a,m,p,u,d,i,c,f,h)),l.length=e.length,i.childrenMap=m,a.forEach(e=>r(e,e=>e.destructor())),a.clear()},exist:(e,t,s)=>e?t||s.create():s.destroy(),file:e=>_(['The data bound to directive "$file" should either be "File" or "FileList" instead of "%o"',e],!e||T(e,File)||T(e,FileList)),focus:(e,t,s,{decorators:{prevent:r=!1}})=>e?t.focus({preventScroll:r}):t.blur(),html:(e,t,s)=>{if(e=O(e),s.removeChildren(),!e)return;const i=[],o=s.profile,n=L(e);if(!t){const e=o.node.getAttribute("dg_scoped_styles");e&&M(n,e.split(","))}if(Reflect.construct(z,[n,o.namespace,i,null,!0]),i.length){const e=s.scopes,t=e.length;r(i,(r,i)=>Promise.all(r.promises||[]).then(()=>new D(r,S(g(r.closures,t))(...e),s,i,null,e,(r.landmark||r.node).parentNode)))}t?t.appendChild(n):s.parentNode.insertBefore(n,s.landmark)},selected:(s,o)=>{const{type:n,tagName:l}=o,a=w(l,"SELECT");if(a||w(l,"INPUT")&&(w(n,"checkbox")||w(n,"radio"))){const e=a?o.multiple:w(n,"checkbox");if(e&&_(['The data bound to directive "$selected" of element "%o" should be "array" instead of "%o"',o,s],null==s||Array.isArray(s)),a){const n=k(o,"option",!0);r(n,t=>t.selected=i(t,s,e)),e||r(n,e=>e.dispatchEvent(t))}else o.checked=i(o,s,e)}else e(s,o,null,{name:"selected"})},style:(e,t,{profile:{inlineStyle:s,styles:i}})=>{if(e){const s={...i};Array.isArray(e)?r(e,e=>o(s,O(e))):T(e)?r(Object.entries(e),([e,t])=>s[e.trim()]=O(t)):r(O(e).split(";"),e=>o(s,e.trim())),t.style.cssText=Object.entries(s).filter(([e,t])=>t).map(([e,t])=>`${e}: ${t}; `).join("").trim()}else s?t.setAttribute("style",s):t.removeAttribute("style")},text:(e,t)=>{e=O(e),w(e,t.textContent)||(t.textContent=e)},value:(e,t,s,{decorators:r})=>{s.value=e;const{tagName:i,type:o}=t,n=w(i,"INPUT");if(_(['It\'s illegal to use directive "$value" on element "%o"',t],!(n&&w(o,"file"))),n){const s=w(o,"date")||w(o,"datetime-local");if(T(e,Date))if(s||w(o,"week"))t.valueAsNumber=e;else if(w(o,"month"))t.value=`${e.getUTCFullYear()}-${l(e.getUTCMonth()+1)}`;else if(w(o,"time")){const s=t.step||0;let r=`${l(e.getUTCHours())}:${l(e.getUTCMinutes())}`;s%60&&(r=`${r}:${l(e.getUTCSeconds())}`,s%1&&(r=`${r}.${l(e.getUTCMilliseconds(),3)}`)),t.value=r}else t.value=e;else e=O(e,r.trim||!1),s?t.valueAsNumber=new Date(e):t.value=e}else t.value=O(e,r.trim||!1)}}))(),s=o("checked","focus","selected"),i=class{constructor(r,{name:i,decorators:o=n,processor:l}){if(this.nodeContext=r,this.decorators=o,this.processor=l,this.topologySet=new Set,this.visitedTopologySet=new Set,i){this.name=i,s[i]&&(this.lazy=!0);const o=r.node;this.updater=t[i]||o&&w(typeof o[i],"boolean")&&t.$boolean||e,w(i,"selected")&&o&&w(o.tagName,"SELECT")&&(this.observer=new MutationObserver(()=>this.trigger()),this.observer.observe(o,{childList:!0}))}}destructor(){this.topologySet.forEach(e=>e.unsubscribe(this)),this.topologySet.clear(),this.visitedTopologySet.clear(),this.observer&&this.observer.disconnect(),b(this)}trigger(e=!0){if(d.delete(this),e||this.topologySet&&[...this.topologySet].some(e=>!w(e[h].oldValue,e[h].value))){if(!this.processor)return;this.topologySet.clear(),this.visitedTopologySet.clear();const e={...p};y({controller:this,sensitive:this.decorators.sensitive||!1}),x([this.processor(),t=>y(e)&&this.update(t)])}return queueMicrotask(()=>this.topologySet&&this.topologySet.forEach(e=>Reflect.deleteProperty(e[h],"oldValue"))),this}update(e){if(!this.updater)return;const t=this.nodeContext,s=t.node;this.decorators.immutable&&w(e,this.data)||x([!(s||{}).isConnected&&this.lazy?queueMicrotask(()=>this.updater(e,s,t,this)):this.updater(e,s,t,this),()=>this.data=e])}})=>i)(),H=((t=new Map,i={json:"dagger/json",namespace:"dagger/configs",script:"dagger/script",style:"dagger/style",string:"dagger/string"},n=s(),a={html:"text/html",json:"application/json",script:["application/javascript","javascript/esm","text/javascript"],style:"text/css"},c=/^[$a-zA-Z-_]{1}[\w-$]*$/,d=/^[$a-zA-Z-_]{1}[\w-$]*(\.[$a-zA-Z-_]{1}[\w-$]*)*$/,u=/'BASE\(([-\w@:%.\/+~#=$]+)\)'|"BASE\(([-\w@:%.\/+~#=$]+)\)"/g,p={json:"json",namespace:"namespace",script:"script",style:"style",string:"string",template:"template"},m=/^(http:\/\/|https:\/\/|\/|\.\/|\.\.\/)/i,f={resolved:"resolved",resolving:"resolving",unresolved:"unresolved"},y=((e=o(...Object.keys(p).map(e=>`@${e}`)),t=((e,t)=>((Array.isArray(e)||!T(e))&&(e={uri:e,candidates:e}),e.candidates&&(Array.isArray(e.candidates)||(e.candidates=[e.candidates])),Object.assign(e,(e.candidates||[]).find(e=>T(e)&&(!Reflect.has(e,"media")||matchMedia(e.media).matches)&&(!Reflect.has(e,"condition")||e.condition&&S(e.condition)))),e.type||(e.type=t),e.uri&&(Array.isArray(e.uri)||(e.uri=[e.uri])),e)))=>s=>r(Object.keys(s),i=>e[i]&&T(s[i])?r(Object.entries(s[i]),([e,r])=>{_([`The module named "${e}" already exists in "%o"`,s],!Reflect.has(s,e)),s[e]=t(r,i.substr(1))})||Reflect.deleteProperty(s,i):s[i]=t(s[i]))||s)(),g=((e=((t,s,r=null)=>r&&(t.integrity&&(w(t.integrity,r.integrity)||e(t,s,r.parent))&&!s.includes(t.path)||t.dependencies&&(t.dependencies.includes(r)||t.dependencies.some(t=>e(t,s,r))))&&s.push(t.path)))=>(t,s=null)=>{if(!s)return;s.dependencies||(s.dependencies=[]),s.dependencies.push(t);const r=[];e(t,r,s);const i=s.path;_(`Failed to resolve template module "${i}" with recursive or circular reference "${[i,...r.reverse(),i].join(" -> ")}"`,!r.length)})(),b=((e,t,s)=>t.cssRules?r(t.cssRules,t=>b(e,t,s)):e.insertRule(`${t.selectorText.split(",").map(e=>(e=e.trim())&&`${C.test(e)?e.replace(C,`[${s}]$1`):`${e}[${s}]`}, [${s}] ${e}`).join(", ")}{${t.style.cssText}}`)),C=/([\s:+>~])/,R=((e,t="",s=!1)=>{const r=document.createElement("style");return e&&(r.textContent=e),l.appendChild(r),r.disabled=s,r.setAttribute("name",t),$(r,"router",location.hash),$(r,"active",!s),r}),O=class{constructor(t={},s="",r="",i=null){this.name=r,this.module={[h]:this},this.state=f.unresolved,i?(this.resolveParent(i),this.path=i.path?`${i.path}.${r}`:r,this.baseElement=i.baseElement):(this.path=r,this.baseElement=l);const{integrity:o,uri:n,type:a}=t;let c=p[a];Reflect.has(t,"content")?this.content=t.content:n?(this.URIs=n,c||(c=!a)):_([`Failed to parse the config "%o" for module "${this.path}" as there is no valid "content" or "uri" definition`,t]),_(`The type of module "${this.path}" should be one of "json, namespace, script, style, template" instead of "${a}"`,c),a&&(this.type=a),e.integrity&&o&&(this.integrity=o),this.config=t,this.promise=new Promise(e=>this.resolver=e),this.base=new URL(t.base||s,(i||{}).base||document.baseURI).href,Reflect.has(t,"scoped")&&!t.scoped||(this.scoped=!0)}extract(e=null){if(!this.extracted)if(w(this.type,p.style))this.parent.styleModules.push(this.module),this.extracted=!0;else if(!w(this.type,p.template)){const e=w(this.type,p.namespace);e?(this.styleModules||(this.styleModules=[]),this.extracted=Object.assign(s(),...this.children.map(e=>e.extract()))):this.extracted=!T(this.module)||Array.isArray(this.module)?this.module:Object.assign(s(),this.module),this.extracted=!e&&this.config.anonymous?this.extracted:Object.assign(s(),{[this.name]:this.extracted})}return this.parent?(this.styleModules||[]).length&&(this.parent.styleModules=[...this.parent.styleModules||[],...this.styleModules]):e&&r(this.styleModules,t=>e.add(t)),this.extracted}fetch(e,t=null){Array.isArray(e)||(e=e.split("."));const s=e.shift().trim(),r=(this.children||[]).find(e=>w(e.name,s));return _(`Failed to fetch module "${s}" within namespace "${this.path||"[root]"}"`,!w(r)),g(r,t),e.length?r.resolve().then(s=>s.fetch(e,t)):r.resolve()}resolve(){if(!w(this.state,f.unresolved))return this.promise;this.resolveState(f.resolving);let e=[e=>this.resolveModule(e),e=>this.resolved(e)];if(Reflect.has(this,"content")){const t=this.content;[p.namespace,p.json].includes(this.type)?(_(`The config content of module "${this.path}" with type "${this.type}" should be valid "object"`,T(t)),e=[w(this.type,p.namespace)?this.resolveNamespace(t):t,...e]):e=[this.resolveContent(t),...e]}else e=[...this.URIs.map(e=>(_([`The "uri" of module "${this.path}" should be valid "string" instead of "%o"`,e],A(e)),(t,s)=>(s.stop=!!t)||this.resolveURI(e))),()=>_([`Failed to resolve uri of module "${this.path}" from "%o"`,this.URIs],w(this.state,f.resolved))];return x(e),this.promise}resolveContent(e){this.content=e.trim();const t=this.type;if(w(t,p.namespace))return this.baseElement=L(e),x([v(this.baseElement,this.base),({base:e,content:t})=>this.resolveNamespace(t,e)]);if(w(t,p.script)){const t=e.replace(u,(e,t)=>E(new URL(t,this.base)));return import(`data:text/javascript, ${encodeURIComponent(t)}`).catch(e=>_(`Failed to import dynamic script module "${this.path}" with resolved content "${t}"`))}if(w(t,p.template)){const t=L(e),s=[],r=this.config.style;return r&&s.push(Promise.all((Array.isArray(r)?r:[r]).map(e=>this.parent.fetch(e).then(t=>(_(`Failed to fetch style module "${e}" within namespace "${this.parent.path}"`,t&&w(t.type,p.style)),t.module.getAttribute("name"))))).then(e=>M(t,e.filter(e=>e)))),s.push(()=>{t[h]=this;const e=new z(t,this.parent);return Promise.all(e.promises||[]).then(()=>e)}),x(s)}return w(t,p.style)?R(e,`dg_style_module_content-${this.path.replace(/\./g,"_")}`,!0):w(t,p.json)?N(e):w(t,p.string)?this.content:void _(`Failed to resolve module "${this.path}" with unknown type "${t}"`)}resolved(e){return this.module=e,this.resolveState(f.resolved),this.resolver(this),this}resolveEmbeddedType(e){if(this.type)return;const{tagName:t,type:s}=e,r=w(t,"SCRIPT");if(w(t,"TEMPLATE"))this.type=p.template;else{if(r&&w(s,i.namespace))return this.type=p.namespace,this.resolveNamespace(N(e.innerHTML),e.getAttribute("base")||this.base);r&&w(s,i.script)?this.type=p.script:r&&w(s,i.json)?this.type=p.json:w(t,"STYLE")&&w(s,i.style)?this.type=p.style:this.type=p.string}}resolveModule(e){this.resolvedContent=e;let t=e;const i=this.type;if(w(i,p.namespace))t=s(),this.children=e,r(e,e=>t[e.name]=e.module);else if(w(i,p.style)){if(this.scoped){_(`It's invalid to use '$' in style module path "${this.path}"`,!this.path.includes("$"));const e=`dg_style_module-${this.path.replace(/\./g,"_")}`,s=R("",e,!0),i=s.sheet;r(t.sheet.cssRules,t=>b(i,t,e)),t=s}}else w(i,p.template)?_(`It's invalid to use '-' in template module path "${this.path}"`,!this.path.includes("-")):!w(i,p.string)&&this.config.converter&&(t=S(`$module => (${this.config.converter})`)(t));return t}resolveNamespace(e,t=this.base){this.parent&&y(e),this.children=Object.entries(e).map(([e,s])=>this.parent?new O(s,t,e,this):s.resolveParent(this));const s=this.config.customTags;return s&&(_(['The "customTags" should be "string array" instead of "%o"',s],Array.isArray(s)&&s.every(e=>A(e))),this.customTagSet=new Set(s)),Promise.all(this.children.map(e=>g(e,this)||e.resolve()).filter((e,t)=>{const s=this.children[t].config.prefetch;return!s||new RegExp(s).test(location.hash)}))}resolveRemoteType(e,t,s){this.base=s,this.type||(a.script.some(e=>t.includes(e))?this.type=p.script:t.includes(a.style)?this.type=p.style:t.includes(a.html)?(e=e.trim(),this.type=e.startsWith("<html>")||e.startsWith("<!DOCTYPE ")?p.namespace:p.template):t.includes(a.json)?this.type=p.json:this.type=p.string)}resolveParent(e){const t=this.name;return _(`The module name should be valid string matched RegExp "${c.toString()}" instead of "${t}"`,c.test(t)),e.module[t]=this.module,this.parent=e,this}resolveState(t){this.state=t,e.moduleLog&&U(`The module "${this.path||"[root]"}" is "${t}".`)}resolveURI(s=""){if(s=s.trim()){if(d.test(s))return this.parent.fetch(s,this).then(e=>(this.type||(this.type=e.type))&&(!w(this.type,p.namespace)||this.resolveModule(e.resolvedContent))&&this.resolved(e.module));{let r=null;if(m.test(s)){const t=n[this.integrity];if(t)r=[t.resolve(),()=>(this.type=t.type)&&t.resolvedContent];else{e.integrity&&this.integrity&&(n[this.integrity]=this);const t=new URL(s,this.base).href;r=[(e,s)=>x([j(t,this.integrity),e=>e||(s.stop=!0)]),({content:e,type:s})=>this.resolveRemoteType(e,s,t)||this.resolveContent(e)]}}else{const i=k(this.baseElement,s),o=t.get(i);o?(e.moduleLog&&I([`The module "${this.path}" and "${o.path}" refer to the same embedded element "%o"`,i]),r=[o.resolve(),e=>(this.type=e.type)&&e.resolvedContent]):(t.set(i,this),r=[this.resolveEmbeddedType(i)||this.resolveContent(i.innerHTML)])}return x([...r,e=>this.resolveModule(e),e=>this.resolved(e)])}}}})=>(R("[dg-cloak] { display: none !important; }","dg-global-style"),O.resolvedType=p,O.normalizeConfig=y,O))(),D=((e={checked:e=>w(e.tagName,"OPTION")?e.selected:e.checked,file:e=>(e.multiple?e.files:e.files[0])||null,selected:(e,{scope:t})=>{const{name:s,type:r,tagName:i}=e,o=w(i,"SELECT"),n=[...o?e.selectedOptions:k(t?k(document,t):document.body,`input[type="${r}"][name="${s}"]:checked`,!0,!0)].map(e=>P(e));return(o?e.multiple:w(r,"checkbox"))?n:n[0]},value:({type:e,value:t,valueAsNumber:s},{number:r,trim:i},{detail:o})=>o?null:w(e,"date")||w(e,"datetime-local")?new Date(s||0):r?Number.parseFloat(t||0):i?t.trim():t},s={1:"Left",2:"Right",4:"Middle",8:"Back",16:"Forward"},i=((e,t,r)=>{const{current:i,modifier:o,prevent:n,stop:l,stopImmediate:a}=r;if(n&&e.preventDefault(),l&&e.stopPropagation(),a&&e.stopImmediatePropagation(),i&&!w(e.target,e.currentTarget)||o&&e.getModifierState&&(Array.isArray(o)?o:[o]).some(t=>!e.getModifierState(t)))return;const c=T(e,KeyboardEvent);if(c||T(e,MouseEvent)){const{code:t,key:i}=r;if(c&&t&&!(Array.isArray(t)?t:[t]).every(t=>new RegExp(t).test(e.code)))return;if(i){const t=c?e.key:s[e.buttons];if(t&&!(Array.isArray(i)?i:[i]).every(e=>new RegExp(e).test(t)))return}}const h={...p};y({sensitive:r.sensitive||!1}),t(e),y(h)}),o=class{constructor(e,t={},s=null,r=-1,i=null,o=(s?s.scopes:[u,a]),n=null){this.profile=e,this.scopes=o,this.baseScopes=o,s?(this.parent=s,this.parentNode=n||s.node||s.parentNode,s.children[r]=this):this.parentNode=e.node.parentNode||e.landmark.parentNode;const{node:l,plain:c,moduleScope:h,raw:d,text:p,unique:m}=e;if(w(l.tagName,"HTML"))return this.closures=t,this.create();if(d)return this.resolveNode(m?l:l.cloneNode(!0));if(c)return h?this.resolveClosures(h,t):this.closures=t,this.resolveNode(m?l:l.cloneNode(!1),()=>this.resolveChildren());if(p)return this.closures=t,this.controller=new F(this,t),this.resolveNode(m?l:document.createTextNode(""),()=>this.controller.trigger());if(i)this.index=r,this.sliceScope=i,this.resolvedSliceScope=q.resolveScope(i),this.resolveClosures(this.resolvedSliceScope,t);else{h?this.resolveClosures(h,t):this.closures=t;const e=this.closures.each;if(e)return this.children=[],this.resolveLandmark(),this.controller=new F(this,e),this.controller.trigger(),this}this.baseClosures=this.closures;const f=this.closures.exist;f?(this.resolveLandmark(),this.existController=new F(this,f),this.existController.trigger()):this.create()}destructor(){const{plain:e,raw:t}=this.profile;t?this.node.remove():(this.destroy(),e||(this.landmark&&this.landmark.remove(),this.upperBoundary&&this.upperBoundary.remove(),this.existController&&this.existController.destructor())),b(this)}create(){let e=[()=>this.initialize()];const t=this.closures.loading;t&&(e=[t.processor(),e=>this.postLoad(e),...e]),x(e)}destroy(){const e=this.node,{unloading:t,unloaded:s}=this.closures.directives||{};this.sentry&&m.delete(this.sentry),Reflect.deleteProperty(this,"sentry"),t&&t.processor(e),this.removeChildren(),this.profile.plain||(this.controller&&(this.controller.destructor()||Reflect.deleteProperty(this,"controller")),this.childrenController&&(this.childrenController.destructor()||Reflect.deleteProperty(this,"childrenController")),r(this.controllers,e=>e.destructor())||Reflect.deleteProperty(this,"controllers"),r(this.eventHandlers,({target:e,parameters:t})=>e.removeEventListener(...t))||Reflect.deleteProperty(this,"eventHandlers")),e&&(this.landmark?e.replaceWith(this.landmark):e.remove()),delete this.node,s&&s.processor(e),this.baseClosures&&(this.closures=this.baseClosures),this.scopes=this.baseScopes}initialize(){if(!this.profile)return;const{node:e,unique:s,virtual:r}=this.profile,{child:i,loaded:n,sentry:l}=this.closures.directives||{};l&&(this.sentry={...l,owner:this},m.add(this.sentry)),w(e.tagName,"HTML")?(a=this.scopes[2]||q.resolveScope({}),t.map(e=>new o(e,S(g(e.closures,2))(u,a))),n&&n.processor()):(i&&(this.childrenController=new F(this,i)),this.resolveNode(!r&&(s?e:e.cloneNode(!1)),()=>this.resolveChildren()||this.resolveControllers()),n&&n.processor(this.node))}postLoad(e){let t=n;e&&(w(e.constructor,Object)||!e.constructor&&w(typeof e,"object"))&&(t=e),this.closures&&this.resolveClosures(q.resolveScope(t),this.closures.postLoad||this.closures)}removeChildren(){if((this.children||[]).length&&(r(this.children,e=>e&&e.destructor()),this.children.length=0),this.node)this.node.innerHTML="";else if(this.upperBoundary){let e=this.upperBoundary.nextSibling;for(;e&&!w(e,this.landmark);){const t=e.nextSibling;e.remove(),e=t}}}resolveChildren(){const e=this.profile.children;!this.children&&(e||w((this.childrenController||{}).name,"html"))&&(this.children=[]),this.childrenController?this.childrenController.trigger():r(e,(e,t)=>new o(e,(this.closures.children||[])[t],this,t))}resolveClosures(e,t){this.closures=t(e),this.scopes=[...this.scopes,e]}resolveControllers(){const{controllers:e=[],eventHandlers:t=[]}=this.closures.directives||{};this.controllers=e.map(e=>new F(this,e).trigger()),this.eventHandlers=t.map(e=>this.resolveEventHandler(e))}resolveEventHandler({event:e,decorators:t={},processor:s,name:r,options:o=!!r}){const n=t.target||this.node;_([`The target of event "${e}" defined on element "%o" is invalid`,this.node||this.profile.node],n);const l=[e,r?e=>this.update(e,r,s,t):e=>i(e,s,t),o];return n.addEventListener(...l),{target:n,parameters:l}}resolveLandmark(){if(this.landmark)return;const{index:e,parent:t,parentNode:s,profile:r}=this;let i=null;i=w(e,0)?t.upperBoundary.nextSibling:s.contains(r.landmark||null)?r.landmark:t&&(t.node?null:t.landmark),this.landmark=s.insertBefore(document.createTextNode(""),i),(r.each||r.virtual)&&(this.upperBoundary=s.insertBefore(document.createTextNode(""),this.landmark))}resolveNode(e,t=null){this.resolveLandmark(),e?(this.node=e,e[h]=this,t&&t(),e.isConnected||this.parentNode.insertBefore(e,this.landmark),e.removeAttribute&&e.removeAttribute("dg-cloak")):t&&t()}update(t,s,r,i){const o={...p};y(),r(e[s](this.node,i,t)),y(o)}})=>y()&&o)(),z=((t={$:"controller","+":"event"},l=o("checked","file","selected","value"),a=o("loaded","sentry","unloading","unloaded"),c=o("STYLE","SCRIPT"),d=(e=>`{ ${e} }`),u=(e=>e.trim().replace(/-[a-z]/g,e=>e[1].toUpperCase()).replace(/-[A-Z]/g,e=>`-${e[1].toLowerCase()}`)),p=((e,t)=>{const[s,r=!0]=e.split(":").map(e=>decodeURIComponent(u(e)));return t[s]=R(r),`${s}: ${A(t[s])&&!w(s,"target")?`\`${r}\``:r}`}),m=((e,s,r="")=>{e.removeAttribute(s),$(e,`${t[s[0]]||"meta"}-${decodeURIComponent(s.substr(1)).trim().replace(/[^\w]/g,"-")}`,r)}),y=((e,t=n,s="()")=>`{ processor: ${s} => { 'use strict';\r\nreturn ${e.trim()}; }, ${Object.entries(t).map(([e,t])=>`${e}: ${t}`).join(", ")} }`),v=class{constructor(t,i=null,o=null,n=null,l=!1,a=null){!n&&!o&&(this.root=!0),this.node=t,l&&(this.unique=l);const d=t.nodeType;if(this.promises=[],w(d,Node.TEXT_NODE)){const e=t.textContent.trim();if(!e)return;e.includes("${")&&e.includes("}")?(this.text=!0,o&&(this.root=!0)&&o.push(this)&&(o=null),this.closures=y(`\`${e}\``,{name:E("text")}),this.resolveLandmark(t,"string template replaced")):this.raw=!0}else if(w(d,Node.ELEMENT_NODE)){const e="dg-cloak",{attributes:n,nodeName:l}=t,h="@raw",d=n[h];if(d||c[l])this.raw=!0,o&&t.removeAttribute(e),d&&m(t,h);else{this.directives={controllers:[],eventHandlers:[]};const c=new Set,h=u(l.toLowerCase()),d=!(i&&i.customTagSet&&i.customTagSet.has(h))&&(T(t,HTMLUnknownElement)||/[A-Z-]/g.test(h));if((d||w(t.tagName,"TEMPLATE"))&&(this.virtual=!0),r([...n],({name:e,value:s})=>this.resolveDirective(t,i,e,s,c)),this.virtual)this.resolveLandmark(t,"virtual node removed");else if(c.has("style")){const e=t.style,i=[...e];i.length&&(this.inlineStyle=t.getAttribute("style"),this.styles=s(),r(i,t=>{const s=e[t],r=e.getPropertyPriority(t);this.styles[t]=r?`${s} !${r}`:s}))}this.landmark||this.loading||!w(Object.keys(this.directives).length,2)||this.directives.controllers.length||this.directives.eventHandlers.length?o&&(this.root=!0)&&o.push(this)&&(o=null):(this.plain=!0,o&&t.hasAttribute(e)&&(r(t.children,t=>t.setAttribute(e,""))||t.removeAttribute(e))),d?(_(`It is illegal to use "$html" or "$text" directive on template module "${h}"`,!this.directives.child),this.promises.push(i.fetch(h,a).then(e=>this.resolveTemplate(e)))):this.directives.child||w(t.tagName,"HTML")||this.resolveChildren(t,i,o,a)}}else if(w(d,Node.DOCUMENT_FRAGMENT_NODE))this.resolveChildren(t,i,o,t[h]);else if(w(d,Node.COMMENT_NODE)){if(!e.commentNode)return this.resolveLandmark(t,"comment node removed");this.raw=!0}else _(`The node type "${d}" is not supported`);if(n&&n.children.push(this),this.promises.length){const e=Promise.all(this.promises).then(()=>(this.root&&this.resolveClosures(),"closures resolved"));n&&n.promises.push(e)}else this.root&&this.resolveClosures(),delete this.promises}resolveChildren(e,t,s,i=null){const o=this.virtual?e.content.childNodes:e.childNodes;return o.length&&(this.children=[],r(o,e=>new v(e,t,s,this,!!this.unique,i)),this.plain&&this.children.every(e=>e.raw)&&(this.raw=!0)&&Reflect.deleteProperty(this,"plain")),this}resolveClosures(e=null){if(!this.closures){let t="";if(!this.raw){const s=", ",r=this.plain?"":Object.entries(this.directives||{}).map(([e,t])=>`${e}: ${Array.isArray(t)?`[${t.join(s)}]`:t}`).join(s);if(t=`${r?`directives: ${d(r)}, `:""}${this.children?`children: [${this.children.map(e=>e.resolveClosures(this.innerModuleScope)).join(s)}]`:""}`,this.loading){const e=t?g(d(t)):"";t=`loading: ${this.loading}, ${e&&`postLoad: ${e}`}`}this.exist&&(t=`exist: ${this.exist}, ${t}`),this.each&&(t=`each: ${this.each}, ${t?`slice: ${g(d(t))}`:""}`),t?(t=d(t),e&&(t=g(t))&&(this.moduleScope=e)):(this.raw=!0)&&Reflect.deleteProperty(this,"plain"),this.root&&(this.closures=t)}return t}return this.closures}resolveDirective(e,r,i,o,n){const c=t[i[0]];if(!c)return;this.virtual||m(e,i,o);const h=s(),[u,...f]=i.substr(1).split("#"),g=s(),v=f.filter(e=>e).map(e=>p(e,g)).join(", ");if(v&&(h.decorators=d(v)),w(c,"event")){h.event=E(u);const{capture:e,once:t,passive:s}=g;(e||t||s)&&(h.options=`{ capture: ${e||!1}, once: ${t||!1}, passive: ${s||!1} }`),this.directives.eventHandlers.push(y(o,h,A(g.event)?g.event:"$event"))}else if(w(u,"loading"))this.loading=y(o,h);else if(a[u]){const e=w(u,"sentry"),t=e?"next":"node",s=e?"$nextRouter":"$node";this.directives[u]=y(o,h,A(g[t])?g[t]:s)}else{w(u,"watch")||(h.name=E(u));const t=y(o,h);if(w(u,"each"))_(['It is illegal to use "$each" directive with "id" attribute together on node "%o"',e],!e.hasAttribute("id")),this.each=t,this.resolveLandmark(e,'"$each" node replaced'),delete this.unique;else if(w(u,"exist"))this.exist=t,this.resolveLandmark(e,'"$exist" node replaced');else if(w(u,"html")||w(u,"text"))this.namespace=r,this.directives.child=t;else if(this.directives.controllers.push(t),w(u,"class"))e.classList.length&&(this.classNames=[...e.classList].map(e=>e.trim()));else if(l[u]){const{tagName:t,type:s}=e,r=w(u,"checked"),i=w(u,"value"),n=w(u,"selected"),l=w(s,"checkbox")||w(s,"radio"),a=w(s,"file");(w(t,"INPUT")&&(a&&w(u,"file")||l&&(r||n)||!l&&!a&&i)||w(t,"OPTION")&&r||w(t,"SELECT")&&n||w(t,"TEXTAREA")&&i)&&(h.event=E(g.input?"input":"change"),this.directives.eventHandlers.push(y(`(() => { try { Object.is(${o}, $$_dg_data) || (${o} = $$_dg_data); } catch (error) {} })()`,h,"$$_dg_data")))}else n.add(u)}}resolveLandmark(e,t){this.landmark||(this.landmark=document.createTextNode(""),this.promises.push(Promise.resolve().then(()=>e.replaceWith(this.landmark)||t)))}resolveTemplate(e){const t=e.module;let o=f.get(t);if(!o){o=s();const i=T(t,v),n=i?t:(t||{}).template;_(`"${e.path}" or "${e.path}.template" is not a valid template module`,T(n,v)),o.namespace=i?e.parent:e,o.children=n.children,r(o.children,e=>e.namespace&&(e.namespace=o.namespace)),f.set(t,o),i||f.set(n,o)}return Object.assign(this,o),this.namespace.resolve().then(e=>this.innerModuleScope=i(e.extract()[this.namespace.name])),`template "${e.path}" resolved`}updateNamespace(e){this.namespace&&(this.namespace=e),r(this.children,t=>t.updateNamespace(e))}})=>v)(),q=((e={bubble:"bubble",self:"self",mutation:"mutation"},t=!1,i=!1,o=new Set([Array,Object]),l={get:(e,s)=>{const r=p.controller,i=Reflect.get(e,s),o=Reflect.getPrototypeOf(e);if(t||!r||a.has(s)||o&&Reflect.has(o,s)||T(i,Function))return i;const n=e[h];if(o)if(n.has(p.topology)){const e=p.topology.fetch(s);T(e,v)&&e.subscribe()}else n.forEach(e=>e.fetch(s).subscribe());else n[s].subscribe();return i},set:(e,t,s)=>{if(i||a.has(t))return Reflect.set(e,t,s);const r=p.topology,o=e[h];return T(o,Set)&&o.has(r)&&r.unsubscribe(),w(Reflect.get(e,t),s)||(s=y(s,e[h],t),Reflect.set(e,t,s),g(o,t,s)),!0},deleteProperty:(e,t)=>{const s=Reflect.has(e,t);return!!Reflect.deleteProperty(e,t)&&(s&&g(e[h],t),!0)}},a=new Set([h,Symbol.asyncIterator,Symbol.hasInstance,Symbol.isConcatSpreadable,Symbol.iterator,Symbol.match,Symbol.matchAll,Symbol.replace,Symbol.search,Symbol.species,Symbol.split,Symbol.toPrimitive,Symbol.toStringTag,Symbol.unscopables]),m=((e,t)=>{p.sensitive?e.trigger(t):d.has(e)||(d.add(e),queueMicrotask(()=>e.trigger(t)))}),f=((e=null,t="")=>e?e.fetch(t):new v),y=((e,t=null,n="")=>{const a=T(t,Set)||Array.isArray(t)?[...t].map(e=>f(e,n)):[f(t,n)];if(!T(e)||T(e,HTMLElement))i&&r(a,t=>t[h].value=e);else if(e[h])r(a,t=>e[h].add(t));else{const n=e.constructor;if(o.has(n)){const o=new Proxy(t?new n:s(),l);if(t)o[h]=new Set(a),i&&r(a,e=>e[h].value=o);else{const e=a[0];o[h]=e,e[h].value=o}return r(C(e),t=>o[t]=y(e[t],a,t)),t||Object.seal(o),o}e[h]=new Set(a)}return e}),g=((t,s,r)=>{if(T(t,Set))return t.forEach(e=>g(e,s,r));s&&(t=t.fetch(s)),t.update(r,e.self)}),v=class{constructor(e=null,t=""){if(e){e[t]=this;const s=e[h].path;this[h]={parent:e,path:s?`${s}.${t}`:t}}else this[h]={path:t}}destructor(){r(Object.keys(this),e=>this[e].destructor());const e=this[h];delete e.parent,e.controllerSet&&(e.controllerSet.clear(),delete e.controllerSet),b(this)}dispatch(t=e.bubble){const{controllerSet:s,parent:r}=this[h];if(s){const r=w(t,e.bubble);s.forEach(e=>m(e,r))}!w(t,e.mutation)&&r&&(_('It\'s illegal to modify fields of "$router"',c||!w(u.$router[h],r)),r[h].parent&&r.dispatch())}fetch(e){return this[e]||new v(this,e)}subscribe(){p.topology=this;const e=p.controller,{topologySet:t,visitedTopologySet:s}=e;if(s.has(this))return;const r=this[h],{controllerSet:i,parent:o}=r;o&&o[h].parent&&o.unsubscribe(e),t.add(this),s.add(this),i?i.add(e):r.controllerSet=new Set([e])}unsubscribe(e=p.controller){e.topologySet.delete(this);const t=this[h].controllerSet;t&&t.delete(e)}update(t,s=e.mutation){const i=this[h],o=i.value;w(o,t)||((!Reflect.has(i,"oldValue")||p.sensitive)&&(i.oldValue=o),i.value=t,T(o)&&!T(o,HTMLElement)&&o[h]&&o[h].delete(this)&&r(C(o),e=>this[e]&&this[e].update((t||n)[e])),T(t)&&!T(t,HTMLElement)&&t[h]&&t[h].add(this)&&r(C(t),e=>f(this,e).update((t||n)[e])),this.dispatch(s))}})=>{v.resolveScope=(e=>{i=!0;const t=y(e);return i=!1,t});const $=JSON.stringify;return JSON.stringify=((...e)=>{t=!0;const s=$(...e);return t=!1,s}),v})(),B=((n="",l=null,d=[],p=null,y=null,v=!1,b=null,N=null,E=null,j=null,L=null,M={aliases:{},default:"",hashPrefix:"#",overrideRelativeLinks:!0,redirects:{},scenarios:{}},O=((e=o("A","AREA"))=>t=>{const s=t.target;if(!e[s.tagName]||!s.hasAttribute("href"))return;const r=s.getAttribute("href").trim(),i=M.hashPrefix;r&&![i,".","/"].some(e=>r.startsWith(e))&&!w(r,new URL(r,document.baseURI).href)&&(s.href=`${i}${r}`)})(),P=((s=((s=o("$modules","$router","$validator"),h=((e,o)=>{r(Object.keys(u).filter(e=>!s[e]),e=>Reflect.deleteProperty(u,e));const n=new Set,l=e.extract(n)[e.name];if(Object.assign(u,l),u.$modules=l,c=!0,p?r(C(u.$router),e=>u.$router[e]=o[e]):u.$router=o,c=!1,r(Object.keys(l),e=>i(u[e])),r(d,e=>n.has(e)||(e.disabled=!0)&&$(e,"active",!1)),d=[...n],r(d,e=>(e.disabled=!1)||$(e,"active",!0)),p){r(t,t=>t.updateNamespace(e));const s=(p.closures.directives||{}).loaded;s&&s.processor()}else p=new D(y,S(g(y.closures,2))(u,a))}))=>()=>{e.routerLog&&U(`router changed from "${u.$router.path||"[root]"}" to "${b.path}"`),f.clear();const s=Object.assign({},...j.map(e=>e.modules));r(Object.keys(s),e=>T(s[e],H)||(s[e]=E.find(t=>t.resolveModule(e,n)).modules[e]));const i=new H({content:s,customTags:l,type:H.resolvedType.namespace},n),o=i.resolve().then(()=>h(i,q.resolveScope(b)));if(window.$ModuleProfile=(e=>new H({content:e,type:"namespace"},"","__demo__",i)),window.$Router=B,p){const{unloading:e,unloaded:t}=p.closures.directives||{};e&&e.processor(),t&&t.processor()}else r(N,e=>Reflect.construct(z,[e,i,t,null,!0])),I(['No node with valid directive was detected under root elements "%o"',N],t.length);return o})(),h=((t=((t,s,r)=>{const i=s.findIndex(e=>e);if(i<0)return;const o=t[i].owner;r.stop=!0,e.routerLog&&I(['The router redirect is prevented by "%o"',o.node||o.profile.node]),v=!0,location.hash=`${u.$router.hashPrefix}${u.$router.path}`}))=>e=>{const s=[...m];return Promise.all(s.map(e=>e.processor(b))).then(r=>t(s,r,e))})())=>(t=location.hash.replace(M.hashPrefix,""))=>{if(v)return void(v=!1);t.startsWith("/")||(t=`/${t}`);const{aliases:i,hashPrefix:o,redirects:n}=M,[l="",a=""]=t.split("?"),c=i[l]||n[l];if(c)return e.routerLog&&U(`router redirected from "${l}" to "${c}"`),t=a?`${c}?${a}`:c,i[l]||history.replaceState({path:t},t,`${o}${t}`),P(t);const d={},u=w(l,"/")?[""]:l.split("/");if(E=[],!L.match(E,d,u))return _(`The router "${l}" is invalid`,M.default),P(M.default);j=E.slice().reverse(),r(j,e=>e.initialize());const m={};a&&r([...new URLSearchParams(a)],([e,t])=>m[e]=R(t));const f=Object.assign({},...j.map(e=>e.variables),m,...j.map(e=>e.constants));b=Object.freeze({hash:t,hashPrefix:o,path:l,paths:u,query:a,queries:m,scenarios:d,schemes:f,identity:Symbol("identity")});const y={};x([p&&h(y),()=>s()],y)})(),F=((e={detail:!0},t=new CustomEvent("change",e),s=new CustomEvent("input",e))=>e=>w(e.target.tagName,"FORM")&&r(document.querySelectorAll("input, textarea"),e=>{e.dispatchEvent(s),e.dispatchEvent(t)}))(),B=class{constructor({children:e,path:t="",constants:s={},variables:i={},modules:o=null,tailable:n=!e},l=null){this.constants=s,this.variables=i,this.modules=o,this.tailable=n,this.scenarios=T(t)?Object.entries(t).map(([e,t])=>({scenario:e,regExp:new RegExp(t||"^$")})):[{scenario:t,regExp:new RegExp(`^${t}$`||"^$")}],l&&(this.parent=l,l.children.push(this)),e&&(_(['The router\'s children should be "array" instead of "%o"',e],Array.isArray(e)),this.children=[],r(e,e=>new B(e,this)))}initialize(){this.initialized||(this.initialized=!0,this.modules&&(this.modules=H.normalizeConfig(this.modules)))}match(e,t,s,r=s.length,i=0){const o=this.scenarios.length;if(r>=o&&this.scenarios.every(({scenario:e,regExp:r},o)=>{const n=s[i+o];if(r.test(n))return t[e]=n,!0})&&(w(r,i+=o)&&this.tailable||(this.children||[]).find(o=>o.match(e,t,s,r,i))))return e.push(this),!0}resolveModule(e,t){if(this.modules){const s=this.modules[e];return this.modules[e]=s&&(T(s,H)?s:new H(s,t,e)),this.modules[e]}}},W=((t={})=>{const{options:s={},rootSelectors:i=["title","body"],routing:o={}}=t;Object.assign(e,s),Object.assign(M,o),U(`Powered by "dagger V${Y}".`),_(['The "rootSelectors" should be "string array" instead of "%o"',i],Array.isArray(i)&&i.every(e=>A(e)));const{overrideRelativeLinks:a,scenarios:c}=M;a&&document.body.addEventListener("click",O,!0),document.body.addEventListener("reset",F),N=[...new Set(i.map(e=>[...k(document,e,!0)]).flat())];const h=document.querySelector("html");_(['It\'s illegal to set "%o" as root node',h],!N.includes(h)),r(N,e=>{const t=N.find(t=>!e.isSameNode(t)&&e.contains(t));_(['The root element "%o" contains another root node "%o"',e,t],!t)}),y=new z(h),({base:n,customTags:l}=t),L=new B(c),window.addEventListener("hashchange",()=>P()),P()}),Y="1.0.0 - RC")=>{const J=((e=((e,t)=>{const s=e[t];_([`"${t}" is not a valid method name of prototype object "%o"`,e],T(s,Function));const r=function(...e){const t=s.bind(this)(...e);return this[h]&&this[h].forEach(e=>e.dispatch()),t};Reflect.defineProperty(r,"name",{configurable:!0,value:t}),Reflect.defineProperty(e,t,{get:()=>r})}))=>(t,s)=>{_(['The 1st argument of "$dagger.register" should be valid "object" instead of "%o"',t],T(t)),_(['The 2nd argument of "$dagger.register" should be "string array" instead of "%o"',s],Array.isArray(s)&&s.every(e=>A(e)));const i=t.prototype;r(s,t=>e(i,t))})(),V=["set","delete"],Z=["add","delete"];return J(Date,["setDate","setFullYear","setHours","setMilliseconds","setMinutes","setMonth","setSeconds","setTime","setUTCDate","setUTCFullYear","setUTCHours","setUTCMilliseconds","setUTCMinutes","setUTCMonth","setUTCSeconds","setYear"])||J(Map,V)||J(Set,Z)||J(WeakMap,V)||J(WeakSet,Z),window.$dagger=Object.freeze(Object.assign(s(),{register:J,runtime:W,version:Y})),W})())=>l.querySelector('script[type="dagger/configs"]')?document.addEventListener("DOMContentLoaded",()=>x([v(l),({base:e,content:t})=>B(Object.assign({base:e},t))])):B)();