UNPKG

@jmodule/client

Version:
16 lines (15 loc) 38.5 kB
var S=(r=>(r.Style="text/css",r.Script="text/javascript",r))(S||{}),v=(r=>(r.Init="Init",r.InitScriptLoaded="InitScriptLoaded",r.InitScriptError="InitScriptError",r.ApplyScript="ApplyScript",r.ApplyStyle="ApplyStyle",r.ScriptResolved="ScriptResolved",r.StyleResolved="StyleResolved",r.StyleRemoved="StyleRemoved",r.ScriptError="ScriptError",r.Initializing="Initializing",r.Initialized="Initialized",r.Preloading="Preloading",r.Preloaded="Preloaded",r.InitializeFailed="InitializeFailed",r.PreloadFailed="PreloadFailed",r.StyleError="StyleError",r.StyleRemoveBefore="StyleRemoveBefore",r.StyleDisabled="StyleDisabled",r.StyleEnabled="StyleEnabled",r))(v||{}),f=(r=>(r.bootFailure="bootFailure",r.loadFailure="loadFailure",r.init="init",r.initializing="initializing",r.initialized="initialized",r.initializeFailed="initializeFailed",r.loading="loading",r.loaded="loaded",r.defined="defined",r.booting="booting",r.done="done",r))(f||{});const H={Initializing:"initializing",Initialized:"initialized",InitializeFailed:"initializeFailed",ScriptError:"loadFailure",ScriptResolved:"loaded"},_e=f;var M=(r=>(r[r.Fetch=0]="Fetch",r[r.Element=1]="Element",r))(M||{}),Ue=(r,e,t)=>new Promise((n,i)=>{var o=s=>{try{u(t.next(s))}catch(l){i(l)}},a=s=>{try{u(t.throw(s))}catch(l){i(l)}},u=s=>s.done?n(s.value):Promise.resolve(s.value).then(o,a);u((t=t.apply(r,e)).next())});const $={};function te(r,e){return Ue(this,arguments,function*(t,n,i=[]){const o=i[n];return o?te(yield o(...t),n+1,i):t})}function re(r,e,t=[]){const n=t[e];return n?re(n(...r),e+1,t):r}let A=class{static addHook(e,t){$[e]=$[e]||[],$[e].push(t)}static removeHook(e,t){const n=$[e].indexOf(t);$[e]=$[e]||[],n>-1&&$[e].splice(n,1)}static clearHooks(e){$[e]=[]}static runHook(e,...t){return te(t,0,$[e]).catch(n=>{throw console.error(`\u6267\u884C hook.${e} \u65F6\u51FA\u73B0\u5F02\u5E38\uFF0C\u540E\u7EED\u8FC7\u7A0B\u5C06\u7EC8\u6B62`),console.error(n),n})}static runHookSync(e,...t){try{return re(t,0,$[e])}catch(n){throw console.error(`\u6267\u884C hook.${e} \u65F6\u51FA\u73B0\u5F02\u5E38\uFF0C\u540E\u7EED\u8FC7\u7A0B\u5C06\u7EC8\u6B62`),console.error(n),n}}};function B(r){return`background: ${r};color:#fff;padding: 0 3px; border-radius: 2px;`}const D={timestamp:"color: #999",key:B("rgb(42,154,243)"),message:"#333",type:{success:B("green"),error:B("red"),log:B("#999"),warning:B("#b39500")},space:"background: initial"};function Ie(){return`[${new Date().toISOString().slice(11,-1)}]`}function ne({key:r,message:e,instance:t,type:n="log"}){console.debug(`%c${Ie()} %c${n}%c %c${r}%c ${e} %O`,D.timestamp,D.type[n],D.space,D.key,D.message,t)}var Le=Object.defineProperty,Ne=Object.defineProperties,Te=Object.getOwnPropertyDescriptors,_=Object.getOwnPropertySymbols,ie=Object.prototype.hasOwnProperty,se=Object.prototype.propertyIsEnumerable,oe=(r,e,t)=>e in r?Le(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,ue=(r,e)=>{for(var t in e||(e={}))ie.call(e,t)&&oe(r,t,e[t]);if(_)for(var t of _(e))se.call(e,t)&&oe(r,t,e[t]);return r},Je=(r,e)=>Ne(r,Te(e)),ze=(r,e)=>{var t={};for(var n in r)ie.call(r,n)&&e.indexOf(n)<0&&(t[n]=r[n]);if(r!=null&&_)for(var n of _(r))e.indexOf(n)<0&&se.call(r,n)&&(t[n]=r[n]);return t};let U=!1;function He(r){if(!r)return"";let e;try{e=JSON.parse(JSON.stringify(r)),e._=r,e.__proto__=r.__proto__}catch(t){e=ue({},r)}return e}class w{static print(e){if(!U||!e)return;const t=e,{instance:n}=t,i=ze(t,["instance"]);ne(Je(ue({},i),{instance:He(n)}))}static printContinue(e){U&&console.debug(` - %c${e}`,"color: #555")}static enable(){U=!0}static disable(){U=!1}}var Ke=(r,e,t)=>new Promise((n,i)=>{var o=s=>{try{u(t.next(s))}catch(l){i(l)}},a=s=>{try{u(t.throw(s))}catch(l){i(l)}},u=s=>s.done?n(s.value):Promise.resolve(s.value).then(o,a);u((t=t.apply(r,e)).next())});function I(r,e,t){return Ke(this,null,function*(){const n=window.JModuleManager.resource(e);if(n.isESM(r))return w.print({key:r,type:"warning",instance:n,message:` ESM\u811A\u672C\u4E0D\u9002\u7528 fetch \u65B9\u5F0F\u52A0\u8F7D\u811A\u672C,\u8FD9\u610F\u5473\u7740\u8BE5\u8D44\u6E90\u5C06\u5FFD\u7565\u4EE5\u4E0Bhook: resource:getFetchOptions\u3001 resource:transformFetchResult\u3001 resource:insertPrivateVariable.`}),r;if(n.cachedUrlMap[r])return n.cachedUrlMap[r];const[i]=yield n.constructor.runHook("resource:getFetchOptions",{currentUrl:r,type:t,resource:n,fetchOptions:{}}),o=yield fetch(r,i.fetchOptions).catch(d=>{throw w.print({key:r,type:"error",instance:n,message:d.message}),d});if(!o.ok)throw w.print({key:r,type:"error",instance:n,message:o.statusText}),new Error(`LoadScriptError: ${r}`);const a=o.headers.get("Content-Type");if(t===S.Script&&!(a!=null&&a.includes("javascript"))||t===S.Style&&!(a!=null&&a.includes("style"))&&!(a!=null&&a.includes("css")))throw w.print({key:r,type:"error",instance:n,message:`${r} is not a ${t}`}),new Error(`LoadScriptError: ${r} is not a ${t}`);const u=yield o.arrayBuffer(),[s]=yield n.constructor.runHook("resource:transformFetchResult",{currentUrl:r,sourceUrl:e,type:a||t,resource:n,buffer:new Uint8Array(u)}),l=new Blob([s.buffer],{type:a||t}),c=URL.createObjectURL(l);return n.cachedUrlMap[r]=c,c})}function qe(r,e,t){return new Proxy(t,{apply(n,i,o){const a=t(o[0],o[1]);if(!["script","link","style"].includes(o[0])||(a.dataset.jmoduleFrom=r,a.dataset.loadedBy=e,o[0]==="style"))return a;const u=o[0]==="script"?"src":"href",s=o[0]==="script"?S.Script:S.Style;return Object.defineProperty(a,u,{get(){return a.dataset.srcRaw},set(l){const c=window.JModuleManager.resource(r),d=(c==null?void 0:c.resolveUrl(l))||new URL(l,e||r).href;return a.dataset.srcRaw=d,I(d,r,s).then(p=>{a.setAttribute(u,p)}),!0}}),a}})}function Ve(r,e,t){return new Proxy(t,{get(n,i){if(i==="src")return e;const o=Reflect.get(t,i);return o instanceof Function?o.bind(t):o}})}function Xe(r,e,{sourceUrl:t,currentUrl:n}){return new Proxy(r,{get(i,o){if(o==="__origin__")return r;if(o==="createElement")return qe(t,n,e);const a=Reflect.get(i,o,r);return o==="currentScript"?Ve(t,n,a):o==="createTreeWalker"?(u,...s)=>{a.bind(r)(u.__origin__||u,...s)}:a instanceof Function?a.bind(i):a},set(i,o,a){return Reflect.set(i,o,a),!0}})}var ae=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{},le={exports:{}},K={exports:{}},ce;function We(){return ce||(ce=1,function(r,e){(function(t,n){r.exports=n()})(ae,function(){function t(h){return!isNaN(parseFloat(h))&&isFinite(h)}function n(h){return h.charAt(0).toUpperCase()+h.substring(1)}function i(h){return function(){return this[h]}}var o=["isConstructor","isEval","isNative","isToplevel"],a=["columnNumber","lineNumber"],u=["fileName","functionName","source"],s=["args"],l=["evalOrigin"],c=o.concat(a,u,s,l);function d(h){if(h)for(var g=0;g<c.length;g++)h[c[g]]!==void 0&&this["set"+n(c[g])](h[c[g]])}d.prototype={getArgs:function(){return this.args},setArgs:function(h){if(Object.prototype.toString.call(h)!=="[object Array]")throw new TypeError("Args must be an Array");this.args=h},getEvalOrigin:function(){return this.evalOrigin},setEvalOrigin:function(h){if(h instanceof d)this.evalOrigin=h;else if(h instanceof Object)this.evalOrigin=new d(h);else throw new TypeError("Eval Origin must be an Object or StackFrame")},toString:function(){var h=this.getFileName()||"",g=this.getLineNumber()||"",C=this.getColumnNumber()||"",R=this.getFunctionName()||"";return this.getIsEval()?h?"[eval] ("+h+":"+g+":"+C+")":"[eval]:"+g+":"+C:R?R+" ("+h+":"+g+":"+C+")":h+":"+g+":"+C}},d.fromString=function(g){var C=g.indexOf("("),R=g.lastIndexOf(")"),ke=g.substring(0,C),je=g.substring(C+1,R).split(","),ee=g.substring(R+1);if(ee.indexOf("@")===0)var z=/@(.+?)(?::(\d+))?(?::(\d+))?$/.exec(ee,""),Re=z[1],Be=z[2],De=z[3];return new d({functionName:ke,args:je||void 0,fileName:Re,lineNumber:Be||void 0,columnNumber:De||void 0})};for(var p=0;p<o.length;p++)d.prototype["get"+n(o[p])]=i(o[p]),d.prototype["set"+n(o[p])]=function(h){return function(g){this[h]=Boolean(g)}}(o[p]);for(var m=0;m<a.length;m++)d.prototype["get"+n(a[m])]=i(a[m]),d.prototype["set"+n(a[m])]=function(h){return function(g){if(!t(g))throw new TypeError(h+" must be a Number");this[h]=Number(g)}}(a[m]);for(var y=0;y<u.length;y++)d.prototype["get"+n(u[y])]=i(u[y]),d.prototype["set"+n(u[y])]=function(h){return function(g){this[h]=String(g)}}(u[y]);return d})}(K)),K.exports}(function(r,e){(function(t,n){r.exports=n(We())})(ae,function(n){var i=/(^|@)\S+:\d+/,o=/^\s*at .*(\S+:\d+|\(native\))/m,a=/^(eval@)?(\[native code])?$/;return{parse:function(s){if(typeof s.stacktrace!="undefined"||typeof s["opera#sourceloc"]!="undefined")return this.parseOpera(s);if(s.stack&&s.stack.match(o))return this.parseV8OrIE(s);if(s.stack)return this.parseFFOrSafari(s);throw new Error("Cannot parse given Error object")},extractLocation:function(s){if(s.indexOf(":")===-1)return[s];var l=/(.+?)(?::(\d+))?(?::(\d+))?$/,c=l.exec(s.replace(/[()]/g,""));return[c[1],c[2]||void 0,c[3]||void 0]},parseV8OrIE:function(s){var l=s.stack.split(` `).filter(function(c){return!!c.match(o)},this);return l.map(function(c){c.indexOf("(eval ")>-1&&(c=c.replace(/eval code/g,"eval").replace(/(\(eval at [^()]*)|(,.*$)/g,""));var d=c.replace(/^\s+/,"").replace(/\(eval code/g,"(").replace(/^.*?\s+/,""),p=d.match(/ (\(.+\)$)/);d=p?d.replace(p[0],""):d;var m=this.extractLocation(p?p[1]:d),y=p&&d||void 0,h=["eval","<anonymous>"].indexOf(m[0])>-1?void 0:m[0];return new n({functionName:y,fileName:h,lineNumber:m[1],columnNumber:m[2],source:c})},this)},parseFFOrSafari:function(s){var l=s.stack.split(` `).filter(function(c){return!c.match(a)},this);return l.map(function(c){if(c.indexOf(" > eval")>-1&&(c=c.replace(/ line (\d+)(?: > eval line \d+)* > eval:\d+:\d+/g,":$1")),c.indexOf("@")===-1&&c.indexOf(":")===-1)return new n({functionName:c});var d=/((.*".+"[^@]*)?[^@]*)(?:@)/,p=c.match(d),m=p&&p[1]?p[1]:void 0,y=this.extractLocation(c.replace(d,""));return new n({functionName:m,fileName:y[0],lineNumber:y[1],columnNumber:y[2],source:c})},this)},parseOpera:function(s){return!s.stacktrace||s.message.indexOf(` `)>-1&&s.message.split(` `).length>s.stacktrace.split(` `).length?this.parseOpera9(s):s.stack?this.parseOpera11(s):this.parseOpera10(s)},parseOpera9:function(s){for(var l=/Line (\d+).*script (?:in )?(\S+)/i,c=s.message.split(` `),d=[],p=2,m=c.length;p<m;p+=2){var y=l.exec(c[p]);y&&d.push(new n({fileName:y[2],lineNumber:y[1],source:c[p]}))}return d},parseOpera10:function(s){for(var l=/Line (\d+).*script (?:in )?(\S+)(?:: In function (\S+))?$/i,c=s.stacktrace.split(` `),d=[],p=0,m=c.length;p<m;p+=2){var y=l.exec(c[p]);y&&d.push(new n({functionName:y[3]||void 0,fileName:y[2],lineNumber:y[1],source:c[p]}))}return d},parseOpera11:function(s){var l=s.stack.split(` `).filter(function(c){return!!c.match(i)&&!c.match(/^Error created at/)},this);return l.map(function(c){var d=c.split("@"),p=this.extractLocation(d.pop()),m=d.shift()||"",y=m.replace(/<anonymous function(: (\w+))?>/,"$2").replace(/\([^)]*\)/g,"")||void 0,h;m.match(/\(([^)]*)\)/)&&(h=m.replace(/^[^(]+\(([^)]*)\)$/,"$1"));var g=h===void 0||h==="[arguments not available]"?void 0:h.split(",");return new n({functionName:y,args:g,fileName:p[0],lineNumber:p[1],columnNumber:p[2],source:c})},this)}}})})(le);var Ge=le.exports;function Ye(r){const e=Error.stackTraceLimit;Error.stackTraceLimit=100;const t=new Error("[JModule]");Error.stackTraceLimit=e;let n;return(Ge.parse(t)||[]).find(({fileName:i})=>(i&&(n=r.getResourceUrlByUrl(i)),!!n)),n}function Qe(r){const e=window.JModuleManager;document.createElement.__original__||(document.createElement.__original__=r,document.createElement=new Proxy(document.createElement,{apply(t,n,i){const o=r(i[0],i[1]);if(!["script","link","style"].includes(i[0]))return o;const a=Ye(e);if(o.dataset.jmoduleFrom=a,i[0]==="style")return o;const u=i[0]==="script"?"src":"href",s=Object.getOwnPropertyDescriptor(o,u);return s&&!s.configurable||Object.defineProperty(o,u,{get(){return o.getAttribute(u)},set(l){const[c,d]=e.findResolvedUrlByUrl(l);if(d!==a&&console.warn(`[JModule]: \u5BF9\u8D44\u6E90${l}\u8FDB\u884C\u5730\u5740\u4FEE\u6B63\u65F6\u9047\u5230\u4E00\u4E9B\u975E\u786E\u5B9A\u56E0\u7D20, \u8BF7\u68C0\u67E5\u5176\u52A0\u8F7D\u60C5\u51B5`),!d&&a){const p=e.resource(a);o.setAttribute(u,(p==null?void 0:p.resolveUrl(l))||l);return}o.setAttribute(u,c)}}),o}}))}function P(r,e){return new Promise((t,n)=>{e&&setTimeout(()=>n(new Error(`\u4E8B\u4EF6${r}\u8D85\u65F6: ${e}ms`)),e),window.addEventListener(r,function i(o){if(window.removeEventListener(r,i),o.detail instanceof Error){n(o.detail);return}t(o.detail)})})}var Ze=(r,e,t)=>new Promise((n,i)=>{var o=s=>{try{u(t.next(s))}catch(l){i(l)}},a=s=>{try{u(t.throw(s))}catch(l){i(l)}},u=s=>s.done?n(s.value):Promise.resolve(s.value).then(o,a);u((t=t.apply(r,e)).next())});function et(r,e){return Ze(this,null,function*(){const{key:t}=r,n=r.constructor.runHook;w.print({key:t,message:"\u5F00\u59CB\u6267\u884C\u521D\u59CB\u5316\u51FD\u6570",instance:e});try{return typeof e.init=="function"&&(w.printContinue("\u6267\u884C init \u51FD\u6570"),yield e.init(r)),yield n("afterInit",r,e),(e.imports||[]).forEach(i=>{w.printContinue("\u52A0\u8F7D\u4F9D\u8D56\u6A21\u5757"),this.waitModuleComplete(i).then(o=>o.load())}),yield n("afterImports",r,e),this.cacheModuleExport(t,e.exports),yield n("afterExports",r,e),r}catch(i){throw console.error(i),w.print({type:"error",key:t,message:i.message||"\u672A\u627E\u5230\u6A21\u5757\u6CE8\u518C\u4FE1\u606F, \u6216\u6A21\u5757\u53C2\u6570\u9519\u8BEF",instance:i}),i}})}function tt(r,e){let t,n;return e?(t=r,n=e):(t=r.key,n=r),(this.jmodule(t)?Promise.resolve(this.jmodule(t)):P(`module.${r}.${f.init}`)).then(i=>(i.bootstrap=()=>{i.status=f.booting;const o=i.constructor;let a=o.runHook("beforeDefine",i,n).then(()=>et.bind(this)(i,n)).then(()=>(o.runHook("afterDefine",i,n),i.status=f.done,i)).catch(u=>{throw i.status=f.bootFailure,u});return i.bootstrap=()=>a,a},i.status=f.defined,i.autoBootstrap?i.bootstrap():i))}const rt=tt;var nt=(r,e,t)=>new Promise((n,i)=>{var o=s=>{try{u(t.next(s))}catch(l){i(l)}},a=s=>{try{u(t.throw(s))}catch(l){i(l)}},u=s=>s.done?n(s.value):Promise.resolve(s.value).then(o,a);u((t=t.apply(r,e)).next())});const q=[],V=(()=>{let r,e=!0;return t=>{e&&(e=!1,window.postMessage({type:"jmodule:page",action:"jmodule:ready"})),q.push(t),clearTimeout(r),r=setTimeout(()=>nt(void 0,null,function*(){window.postMessage({type:"jmodule:page",action:"jmodule:change"})}),300)}})();function it(){q.push([Date.now(),"__global__","startRecord",""]),window.addEventListener("module.afterRegister",({detail:r})=>{(r||[]).forEach(({key:e,status:t}={})=>{e&&(V([Date.now(),e,"module",f[t]]),window.addEventListener(`module.${e}.statusChange`,({detail:n})=>{V([Date.now(),e,"module",f[n.status]])}),window.addEventListener(`resource.${e}.statusChange`,({detail:n})=>{V([Date.now(),e,"resource",v[n.status]])}))})})}function st(){it(),window.__jmodule_devtool__||(window.__jmodule_devtool__={getActionsFromIndex(r=0){return q.slice(r)},getDefinition(){return{ModuleStatus:f,ResourceStatus:v,ResourceLoadStrategy:M}}})}var ot=Object.defineProperty,de=Object.getOwnPropertySymbols,ut=Object.prototype.hasOwnProperty,at=Object.prototype.propertyIsEnumerable,pe=(r,e,t)=>e in r?ot(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,he=(r,e)=>{for(var t in e||(e={}))ut.call(e,t)&&pe(r,t,e[t]);if(de)for(var t of de(e))at.call(e,t)&&pe(r,t,e[t]);return r};const fe=new Set,L={};let N=class Pe{constructor(e={}){if(e instanceof Pe)return e;const t=Object.keys(e).sort()||[],n=JSON.stringify(t.map(i=>[i,e[i]])).replace(/^\[|\]$/g,"");fe.add(n),this.hash=n}get matched(){return[...fe].filter(e=>this.hash.indexOf(e)>-1).sort((e,t)=>e.length>t.length?1:-1)}cache(e){L[this.hash]=he(he({},L[this.hash]||{}),e)}getCache(e=!0){return e?Object.assign({},...this.matched.map(t=>L[t])):L[this.hash]}};const X={};let W=class{constructor(e,t={}){if(!e||typeof e!="function")throw new Error("DepResolver \u53C2\u6570\u9519\u8BEF\uFF0C\u5FC5\u987B\u4E3A\u51FD\u6570");const{cacheBy:n}=t;this.resolver=e,this.cacheBy=n,this.result=void 0}resolve(e={}){const{cacheBy:t}=this,n=t&&e[t];if(n&&X[n])return X[n];const i=this.resolver(e);return n&&(X[n]=i),i}};var me=(r,e,t)=>new Promise((n,i)=>{var o=s=>{try{u(t.next(s))}catch(l){i(l)}},a=s=>{try{u(t.throw(s))}catch(l){i(l)}},u=s=>s.done?n(s.value):Promise.resolve(s.value).then(o,a);u((t=t.apply(r,e)).next())});const G=document,ye=G.createElement.bind(G),lt=(window.JModule||{}).config||{},ve=class extends A{static createDocument(e){return Xe(G,ye,e)}static getInitialConfig(){return lt}static setFileMapCache(e,t){var n;const i=(n=this.fileMapCache[e])==null?void 0:n[0];if(i&&i!==t[0]){const o=`\u5EFA\u7ACB\u5F02\u6B65\u7EC4\u4EF6\u7D22\u5F15 "${e}" \u51FA\u73B0\u51B2\u7A81\uFF0C\u53EF\u80FD\u4F1A\u5BFC\u81F4\u5F02\u6B65\u7EC4\u4EF6\u52A0\u8F7D\u5F02\u5E38`;console.error(o,t)}return this.fileMapCache[e]=t}static appendFileList(e){this.fileListCache.push(e)}static findResolvedUrlByUrl(e){const t=this.fileListCache.find(n=>n&&e.includes(n));return!t||!this.fileMapCache[t]?[e]:this.fileMapCache[t]}static getResourceUrlByUrl(e){if(!e)return;if(this.resourceCache[e])return e;let t;for(const n of document.scripts)if(n.src===e){t=n.getAttribute("data-jmodule-from")||void 0;break}return t}static resource(e,t){if(t===null){delete this.resourceCache[e];return}return t?(this.resourceCache[e]=t,t):this.resourceCache[e]}static jmodule(e,t){if(t===null){delete this.jmoduleCache[e];return}return t?(this.jmoduleCache[e]=t,t):this.jmoduleCache[e]}static get registeredModules(){return Object.keys(this.jmoduleCache).map(e=>this.jmodule(e)).filter(e=>!!e)}static mapResourceUrlAndModuleKey(e,t){this.resourceUrlAndModuleKeyMap[e]=[...this.resourceUrlAndModuleKeyMap[e]||[],t]}static getModulesByResourceUrl(e){return(this.resourceUrlAndModuleKeyMap[e]||[]).map(t=>this.jmodule(t)).filter(t=>!!t)}static getJModuleConstructor(e){const t=this.jmodule(e);if(!t)throw new Error(`Module ${e} not found`);return t.constructor}static registerJModule(e){return this.defaultJModule||(this.defaultJModule=e),this.nextJModuleId++}static cacheModuleExport(e,t){Object.assign(this.moduleExports,{[e]:t})}static waitModuleComplete(e){return me(this,null,function*(){const t=this.jmodule(e);return t&&t.status===f.done?Promise.resolve(t):P(`module.${e}.${f.done}`)})}static require(e){return me(this,null,function*(){const t=e.split(".");if(yield this.waitModuleComplete(t[0]),!this.moduleExportsCache[e]){const n=t.reduce((i,o)=>(i||{})[o],this.moduleExports);this.moduleExportsCache[e]=n}return this.moduleExportsCache[e]})}static export(e={},t={}){new N(t).cache(e)}static import(e="",t={}){const n=new N(t).getCache(),i=e.split(".").reduce((o,a)=>(o||{})[a],n);return i&&i instanceof W?i.resolve(t):i}};let b=ve;b.resourceCache={},b.jmoduleCache={},b.resourceUrlAndModuleKeyMap={},b.fileMapCache={},b.fileListCache=[],b.moduleExportsCache={},b.moduleExports={},b.nextJModuleId=0,b.define=rt.bind(ve),window.JModuleManager||(window.JModuleManager=b,Qe(ye),st());var E=window.JModuleManager,ct=Object.defineProperty,dt=Object.defineProperties,pt=Object.getOwnPropertyDescriptors,T=Object.getOwnPropertySymbols,ge=Object.prototype.hasOwnProperty,Ee=Object.prototype.propertyIsEnumerable,we=(r,e,t)=>e in r?ct(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,be=(r,e)=>{for(var t in e||(e={}))ge.call(e,t)&&we(r,t,e[t]);if(T)for(var t of T(e))Ee.call(e,t)&&we(r,t,e[t]);return r},Se=(r,e)=>dt(r,pt(e)),ht=(r,e)=>{var t={};for(var n in r)ge.call(r,n)&&e.indexOf(n)<0&&(t[n]=r[n]);if(r!=null&&T)for(var n of T(r))e.indexOf(n)<0&&Ee.call(r,n)&&(t[n]=r[n]);return t},ft=(r,e,t)=>new Promise((n,i)=>{var o=s=>{try{u(t.next(s))}catch(l){i(l)}},a=s=>{try{u(t.throw(s))}catch(l){i(l)}},u=s=>s.done?n(s.value):Promise.resolve(s.value).then(o,a);u((t=t.apply(r,e)).next())});const mt="((context) => {const document = JModuleManager?.createDocument?.(context) || document;",yt=(r,e)=>` })({ sourceUrl: '${r}', currentUrl: '${e}' })`;function vt(r){return ft(this,null,function*(){const e=r,{buffer:t,resource:n}=e,i=ht(e,["buffer","resource"]);if(!r.type.includes("javascript")||!(t instanceof Uint8Array)||n.isESM(r.currentUrl))return[r];const o=new TextEncoder,[{code:a=""}]=yield n.constructor.runHook("resource:insertPrivateVariable",Se(be({},r),{code:""}));return[Se(be({},i),{resource:n,buffer:new Uint8Array([...o.encode(mt),...o.encode(a),...t,...o.encode(`${yt(r.sourceUrl,r.currentUrl)}`)])})]})}var Y=(r,e,t)=>new Promise((n,i)=>{var o=s=>{try{u(t.next(s))}catch(l){i(l)}},a=s=>{try{u(t.throw(s))}catch(l){i(l)}},u=s=>s.done?n(s.value):Promise.resolve(s.value).then(o,a);u((t=t.apply(r,e)).next())});function gt(r,e){return Y(this,null,function*(){const t=yield(yield fetch(e)).json(),n=`(window.JModuleManager && window.JModuleManager.defaultJModule || window.JModule).applyResource(${JSON.stringify(t)}, "${r.url}")`,i=new Blob([n],{type:"text/javascript"});return URL.createObjectURL(i)})}function Et(r,e){return Y(this,null,function*(){const t=yield fetch(e),[n]=(t.headers.get("Content-Type")||"").split(";");return r.type=n.split("/").pop()||r.type,URL.createObjectURL(yield t.blob())})}function wt(r){const e={};return[...r].forEach(t=>e[t.name]=t.value),e}const bt=(r,e)=>{const t=new DOMParser().parseFromString(r,"text/html"),n={},i=/(\bimport\b[\r\n\s]+[^'"]*\bfrom\b[\r\n\s]+['"])([^'"]+)(['"])/gm,o=[...t.scripts].map(u=>{var s;let l;if(u.attributes.getNamedItem("src")&&(l=(s=u.attributes.getNamedItem("src"))==null?void 0:s.value),u.textContent){if(u.type==="importmap")return;if(u.type==="module"){const c=u.textContent.replace(i,(d,p,m,y)=>p&&m&&y?`${p}${new URL(m,e).href}${y}`:d);l=URL.createObjectURL(new Blob([c],{type:"text/javascript"}))}else l=URL.createObjectURL(new Blob([u.textContent],{type:"text/javascript"}))}return l&&(n[l]=wt(u.attributes)),l}).filter(u=>!!u),a=[...t.querySelectorAll('style, link[rel="stylesheet"]')].map(u=>{var s;if(u.tagName==="LINK")return(s=u.attributes.getNamedItem("href"))==null?void 0:s.value;if(u.tagName==="STYLE"&&u.textContent)return URL.createObjectURL(new Blob([u.textContent],{type:"text/css"}))});return{js:o,css:a,jsAttributes:n}};function St(r,e){return Y(this,null,function*(){const t=yield fetch(e),[n]=(t.headers.get("Content-Type")||"").split(";");n.includes("html")||console.warn(`\u8D44\u6E90 ${e} \u5B9E\u9645\u7C7B\u578B\u4E3A ${n}, \u671F\u671B\u662F 'text/html', \u8BF7\u6CE8\u610F\u68C0\u67E5`);const i=bt(yield t.text(),e),o=`(window.JModuleManager && window.JModuleManager.defaultJModule || window.JModule).applyResource(${JSON.stringify(i)}, "${r.url}")`;return URL.createObjectURL(new Blob([o],{type:"text/javascript"}))})}const $t=[["auto",Et],["json",gt],["html",St]];var Ft=(r,e,t)=>new Promise((n,i)=>{var o=s=>{try{u(t.next(s))}catch(l){i(l)}},a=s=>{try{u(t.throw(s))}catch(l){i(l)}},u=s=>s.done?n(s.value):Promise.resolve(s.value).then(o,a);u((t=t.apply(r,e)).next())});function Ct(r,e,t){return Ft(this,null,function*(){return(yield Promise.allSettled(r.map(n=>new Promise((i,o)=>{const a=n.href||n.src;n.onload=()=>i(n),n.onerror=()=>o(new Error(`LoadError: ${a}`)),e&&e(n)})))).reduce((n,i)=>(i.status==="fulfilled"&&(n.results.push(i.value),t&&t(i.value)),i.status==="rejected"&&n.errors.push(i.reason),n),{results:[],errors:[]})})}function $e(r,e){return new Promise((t,n)=>{setTimeout(()=>{if(e instanceof Error){n(e);return}t(e)},r)})}function Mt(r,e){return!r||!e?!0:["js","css","asyncFiles"].some(t=>(r[t]||[]).sort().join(",")!==(e[t]||[]).sort().join(","))}var k=(r,e,t)=>new Promise((n,i)=>{var o=s=>{try{u(t.next(s))}catch(l){i(l)}},a=s=>{try{u(t.throw(s))}catch(l){i(l)}},u=s=>s.done?n(s.value):Promise.resolve(s.value).then(o,a);u((t=t.apply(r,e)).next())});function Fe(r,e,t,n){const i=document.createElement("script");return i.setAttribute("src",r),i.async=!1,i.dataset.jmoduleFrom=e,Object.keys(t||{}).forEach(o=>{["src","async"].includes(o)||i.setAttribute(o,t[o])}),n&&n(i),document.body.appendChild(i),new Promise((o,a)=>{i.onerror=()=>a(new Error(`LoadScriptError: ${r}`)),i.onload=()=>o(i)})}function At(r,e,t){const n=document.createElement("link");return n.setAttribute("rel","preload"),n.setAttribute("as","style"),n.setAttribute("href",r),n.dataset.jmoduleFrom=e,t&&t(n),n}function Ot(r){return`${new URL(r,window.location.href)}${r.indexOf("?")>0?"&":"?"}__v__=${Date.now()}`}const xt=/\?.+$/;function Pt(r){const{asyncFiles:e=[]}=r.metadata||{};e.forEach(t=>{const n=t.replace(xt,""),i=r.resolveUrl(t);E.setFileMapCache(n,[i,r.url]),E.appendFileList(n)})}const kt={},O=class extends A{constructor(e,t){var n,i;if(super(),this.appliedScript=!1,this.resolvedUrlMap={},this.url="",this.styleElements=[],this.scriptElements=[],this.styleMounted=!1,this.status=v.Init,this.cachedUrlMap={},!e&&typeof e!="string")throw new Error("\u521B\u5EFA Resource \u5B9E\u4F8B\u5F02\u5E38, \u7F3A\u5C11sourceUrl");const{href:o,origin:a}=new URL(e,window.location.href);if(E.resource(o))return E.resource(o);this.url=o,this.server=a;const u=((n=e.split(".").pop())==null?void 0:n.replace(/\s|(\?.*$)/g,""))||"";this.type=(t==null?void 0:t.type)||(["js","json"].includes(u)?u:"auto"),this.afterApplyScript=new Promise((s,l)=>{this.resolveScript=s,this.rejectScript=l}),this.strategy=(i=t==null?void 0:t.strategy)!=null?i:M.Element,this.initTimeout=(t==null?void 0:t.initTimeout)||O.initTimeout,E.resource(this.url,this)}static enableAsyncChunk(){console.warn("Resource.enableAsyncChunk() is deprecated, just remove it")}static getResource(e){return console.warn("Resource.getResource() is deprecated, use JModuleManager.getInstance() instead"),e?E.resource(e):void 0}static getTrueResourceUrl(e){let t,n;return Object.keys(O.asyncFilesMap).some(i=>{if(e.includes(i))return t=O.asyncFilesMap[i],n=i,!0}),t&&n?{resource:t,filepath:n}:void 0}static setResourceData(e,t){var n;const i=E.resource(t);if(!i)throw new Error(`\u672A\u627E\u5230${t}\u5BF9\u5E94\u7684 resource \u5B9E\u4F8B`);return i.metadata&&Mt(i.metadata,e)&&(O.runHookSync("resource:upgrade",i),i.resetStyleStatus()),(n=i.resolveInit)==null||n.call(i,e),i}static defineType(e,t){O.addHook("resource:resolveEntry",(n,i)=>k(this,null,function*(){return n.type===e&&typeof t=="function"?[n,yield t(n,i)]:[n,i]}))}prepareInit(){this.status===v.Initializing&&this.rejectInit&&this.rejectInit(new Error("ResourceInit:Aborted")),this.setStatus(v.Initializing),this.afterInit=new Promise((e,t)=>{this.resolveInit=n=>{this.status===v.Initializing&&(this.metadata=n,this.setStatus(v.Initialized),e())},this.rejectInit=n=>{this.setStatus(v.InitializeFailed),console.error(`${this.url} \u52A0\u8F7D\u5931\u8D25: ${n.message}`),t(n)}})}init(e=!1){return k(this,null,function*(){var t;if(this.status===v.Initializing)return this.afterInit;if(this.afterInit&&!e)return this.afterInit;this.prepareInit();try{const[,n]=yield O.runHook("resource:resolveEntry",this,Ot(this.url));yield Fe(n,this.url,{},i=>{i.async=!0,this.initScriptElement=i,kt[this.url]=i}),yield Promise.race([$e(this.initTimeout,new Error("ResourceInit:Timeout")),this.afterInit])}catch(n){throw(t=this.rejectInit)==null||t.call(this,n),n}})}resolveUrl(e){var t;let n=e;try{e.startsWith("X_WEBPACK_SERVER")&&(console.warn("X_WEBPACK_SERVER \u5DF2\u5E9F\u5F03, \u4E0B\u4E2A\u7248\u672C\u5C06\u5F03\u7528"),(t=this.metadata)!=null&&t.asyncFiles?e=e.replace(/^X_WEBPACK_SERVER\/?/,""):e=e.replace(/^X_WEBPACK_SERVER/,"")),this.urlAdapter?n=this.urlAdapter(e,this):n=new URL(e,this.url).href}catch(i){}return this.resolvedUrlMap[n]=e,n}setStatus(e){this.status!==e&&(this.status=e,E.getModulesByResourceUrl(this.url).forEach(t=>{e in H&&(t.status=H[e]),window.dispatchEvent(new CustomEvent(`resource.${t.key}.statusChange`,{detail:this}))}))}applyScript(e){return k(this,null,function*(){if(!this.metadata)return Promise.reject(new Error(`no resource metadata: ${this.url}`));if(this.appliedScript)return Promise.resolve(this.scriptElements);if(this.scriptLoading)return this.scriptLoading;this.setStatus(v.ApplyScript),this.scriptElements=[];const t=(this.metadata.js||[]).map(o=>{var a,u;return(u=(a=this.metadata)==null?void 0:a.jsAttributes)==null?void 0:u[o]}),n=(this.metadata.js||[]).map(o=>this.resolveUrl(o)),i=()=>k(this,null,function*(){return this.strategy===M.Fetch?yield Promise.all(n.map(o=>I(o,this.url,S.Script))):(Pt(this),n)});return this.scriptLoading=i().then(o=>Promise.all(o.map((a,u)=>Fe(a,this.url,t[u],e)))).then(o=>(this.setStatus(v.ScriptResolved),this.resolveScript(o),this.scriptElements=o,this.appliedScript=!0,this.scriptElements)).catch(o=>{throw this.setStatus(v.ScriptError),this.scriptLoading=void 0,this.rejectScript(o),o}),this.scriptLoading})}applyStyle(e){return k(this,null,function*(){var t;if(!this.metadata)return Promise.reject(new Error("no resource metadata"));const{css:n=[]}=this.metadata,{length:i}=this.styleElements;if(!this.styleLoading){if(this.setStatus(v.ApplyStyle),n.length!==i){const a=(this.metadata.css||[]).map(s=>this.resolveUrl(s)),u=yield(()=>k(this,null,function*(){return this.strategy===M.Fetch?yield Promise.all(a.map(s=>I(s,this.url,S.Style))):a}))();this.styleElements=u.map(s=>At(s,this.url,e))}const o=Ct(this.styleElements,a=>document.head.appendChild(a),a=>a.setAttribute("rel","stylesheet"));(t=this.appendedAsyncStyleElements)==null||t.forEach(a=>document.head.appendChild(a)),this.styleMounted=!0,this.styleLoading=o.then(a=>(this.setStatus(v.StyleResolved),a.errors.length&&(this.setStatus(v.StyleError),console.error(a.errors)),a.results))}return this.status===v.StyleDisabled&&this.setStyleStatus("enabled"),this.styleLoading})}isESM(e){var t,n;const i=this.resolvedUrlMap[e]||e,o=(n=(t=this.metadata)==null?void 0:t.jsAttributes)==null?void 0:n[i];return o?o.type==="module":!!document.querySelector(`script[type="module"][data-src-raw="${e}"]`)}preload(e){if(!this.metadata)throw new Error("no resource metadata");if(this.status===v.Preloading)return;this.setStatus(v.Preloading);const{css:t=[],js:n=[]}=this.metadata,i=[{type:"script",urls:n},{type:"style",urls:t}].map(({type:o,urls:a})=>{const u=a.map(s=>{const l=this.resolveUrl(s);if(this.strategy===M.Fetch){const c=o==="script"?S.Script:S.Style;return I(l,this.url,c).then(d=>{this.cachedUrlMap[l]=d})}else return new Promise((c,d)=>{const p=document.createElement("link");p.setAttribute("href",l),p.rel="preload",p.as=o,p.onload=c,p.onerror=d,document.head.appendChild((e==null||e(p),p))})});return Promise.all(u)});Promise.all(i).then(()=>{this.setStatus(v.Preloaded)}).catch(()=>{this.setStatus(v.PreloadFailed)})}removeStyle(){if(!this.styleLoading)return;this.setStatus(v.StyleRemoveBefore),(this.styleElements||[]).forEach(t=>t.remove());const e=document.querySelectorAll(`link[data-jmodule-from="${this.url}"], style[data-jmodule-from="${this.url}"]`);e.forEach(t=>t.remove()),this.appendedAsyncStyleElements=e,this.styleMounted=!1,this.styleLoading=void 0,this.setStatus(v.StyleRemoved)}setStyleStatus(e){const t=e==="disabled",n=[...this.styleElements||[],...this.appendedAsyncStyleElements||[]];[...document.styleSheets].forEach(i=>{n.includes(i.ownerNode)&&(i.disabled=t)}),this.setStatus(t?v.StyleDisabled:v.StyleEnabled)}resetStyleStatus(){this.styleLoading=void 0,this.styleMounted=!1,this.styleElements=[],this.appendedAsyncStyleElements=void 0}destroy(){this.removeStyle(),this.initScriptElement=void 0,this.scriptElements=[],this.styleElements=[],E.resource(this.url,null)}};let F=O;F.asyncFilesMap={},F.initTimeout=1e4,F.addHook("resource:transformFetchResult",vt),$t.forEach(([r,e])=>{F.defineType(r,e)});var Ce=Object.getOwnPropertySymbols,jt=Object.prototype.hasOwnProperty,Rt=Object.prototype.propertyIsEnumerable,Bt=(r,e)=>{var t={};for(var n in r)jt.call(r,n)&&e.indexOf(n)<0&&(t[n]=r[n]);if(r!=null&&Ce)for(var n of Ce(r))e.indexOf(n)<0&&Rt.call(r,n)&&(t[n]=r[n]);return t},J=(r,e,t)=>new Promise((n,i)=>{var o=s=>{try{u(t.next(s))}catch(l){i(l)}},a=s=>{try{u(t.throw(s))}catch(l){i(l)}},u=s=>s.done?n(s.value):Promise.resolve(s.value).then(o,a);u((t=t.apply(r,e)).next())});const Me=()=>{var r,e;return((r=document.currentScript)==null?void 0:r.src)||((e=import.meta)==null?void 0:e.url)||""},Ae=document.currentScript,Q={},Oe={[f.init]:"\u5DF2\u521B\u5EFA\u6A21\u5757\u5B9E\u4F8B",[f.initializing]:"\u6B63\u5728\u83B7\u53D6\u8D44\u6E90\u5217\u8868",[f.initialized]:"\u8D44\u6E90\u521D\u59CB\u5316\u5B8C\u6210",[f.initializeFailed]:"\u8D44\u6E90\u521D\u59CB\u5316\u5931\u8D25",[f.loading]:"\u6B63\u5728\u52A0\u8F7D\u6A21\u5757\u8D44\u6E90",[f.loaded]:"\u6A21\u5757\u52A0\u8F7D\u5B8C\u6210",[f.loadFailure]:"\u6A21\u5757\u52A0\u8F7D\u6216\u89E3\u6790\u5931\u8D25",[f.defined]:"\u89E3\u6790\u6A21\u5757\u5B9A\u4E49",[f.booting]:"\u6B63\u5728\u6302\u8F7D\u6A21\u5757",[f.done]:"\u6A21\u5757\u5DF2\u6302\u8F7D",[f.bootFailure]:"\u6302\u8F7D\u6A21\u5757\u8FC7\u7A0B\u5F02\u5E38"},{filter:Z,debug:Dt}=E.getInitialConfig(),_t=r=>{const{key:e}=r;let t;return(!e||Q[e])&&(t="\u91CD\u590D\u6CE8\u518C\u6216moduleKey\u672A\u5B9A\u4E49"),Z&&typeof Z=="function"&&!Z(r)&&(t="\u4E3B\u52A8\u8FC7\u6EE4"),t?(w.print({key:e,message:t,instance:r}),!1):!0},xe=/^((?:http|https):\/\/[^/]+)(\/.*)?$/g;function Ut(r=""){return xe.test(r)?r.replace(xe,(e,t)=>t):""}const x=class extends A{constructor(r){var e=r,{key:t,url:n,server:i,name:o,autoBootstrap:a=!0,resourceType:u,resource:s,type:l,resourceLoadStrategy:c}=e,d=Bt(e,["key","url","server","name","autoBootstrap","resourceType","resource","type","resourceLoadStrategy"]);const p=i||Ut(n),m=p!=="/";super(),this.hooks={complete:void 0},this.type=l,this.key=t,this.name=o,this.url=n,this.status=f.init,this.server=p,this.isRemoteModule=m,this.domain=p,this.resource=s&&s instanceof F?s:new F(n,{type:u,strategy:c}),this.autoBootstrap=a,this.bootstrap=void 0,this.metadata=d,E.mapResourceUrlAndModuleKey(this.resource.url,this.key),E.jmodule(this.key,this)}set status(r){if(r===f.loaded&&this._status!==f.loading)return;this._status=r,r===f.loaded&&setTimeout(()=>{this.status===f.loaded&&w.print({type:"warning",key:this.key,message:"JModule.define \u53EF\u80FD\u65E0\u6CD5\u6B63\u5E38\u6267\u884C, \u8BF7\u68C0\u67E5\u5B50\u5E94\u7528\u8D44\u6E90\u54CD\u5E94\u662F\u5426\u6B63\u5E38\u3001\u662F\u5426\u6267\u884C\u5F02\u5E38\u3001\u662F\u5426\u80FD\u6267\u884CJModule.define",instance:this})},5e3);const e={detail:this};w.print({type:r!==f.loadFailure?r!==f.loading?"success":"log":"error",key:this.key,message:Oe[r],instance:this}),window.dispatchEvent(new CustomEvent(`module.${this.key}.statusChange`,e)),window.dispatchEvent(new CustomEvent(`module.${this.key}.${r}`,e))}get status(){return this._status}static set debug(r){x._debug=r,r?w.enable():w.disable()}static get debug(){return x._debug||!1}static defineType(r,e){x.addHook("afterDefine",(t,n)=>{if(t.type===r&&typeof e=="function"){const{activate:i,deactivate:o}=e(t,n)||{};t.activate=i,t.deactivate=o}return[t,n]})}static get registeredModules(){return Object.values(Q)}static getModule(r){return E.jmodule(r)}static getModuleAsync(r,e){return J(this,null,function*(){const t=E.jmodule(r);return t?Promise.resolve(t):new Promise((n,i)=>{if(e){const a=setTimeout(()=>{clearTimeout(a),E.jmodule(r)||i(new Error(`Timeout:getModuleAsync('${r}', ${e})`))},e)}function o(){E.jmodule(r)&&(window.removeEventListener("module.afterRegister",o),n(E.jmodule(r)))}window.addEventListener("module.afterRegister",o)})})}static require(r){return J(this,null,function*(){return E.require(r)})}static registerModules(){return J(this,arguments,function*(r=[]){w.print({type:"log",key:"registerModules",message:"\u8BF7\u6C42\u6CE8\u518C\u6A21\u5757",instance:r}),yield A.runHook("beforeFilterModules",r);const e=r.filter(_t);yield A.runHook("beforeRegisterModules",e);const t=e.map(n=>n instanceof x?n:new this(n));return t.forEach(n=>{n.key&&(Q[n.key]=n)}),window.dispatchEvent(new CustomEvent("module.afterRegister",{detail:t})),yield A.runHook("afterRegisterModules",t),t})}static export(r={},e={}){return new N(e).cache(r),x}static applyResource(r,e){const t=e||Me();if(!t)throw new Error("JModule.applyResource \u6267\u884C\u5F02\u5E38: \u65E0\u6CD5\u627E\u5230\u811A\u672C\u52A0\u8F7D\u6E90\u5E76\u5173\u8054\u5230\u5BF9\u5E94\u7684\u8D44\u6E90\u5B9E\u4F8B");return F.setResourceData(r,t.replace(/(\?|&)__v__=\d+$/,""))}static getMeta(){const r=Me();return r?{url:r,server:new URL(r).origin}:{}}static import(r="",e={},t=!1){if(r==="$module.meta")return this.getMeta();if(!t&&this===window.JModule)return this.import(r,e,!0);if(!t&&this!==E.defaultJModule&&Ae){const{dataset:o}=Ae,a=(o==null?void 0:o.jmoduleFrom)||"",[u]=E.getModulesByResourceUrl(a)||[];return u&&u.constructor!==x?u.constructor.import(r,e,!0):this.import(r,e,!0)}const n=new N(e).getCache(),i=r.split(".").reduce((o,a)=>(o||{})[a],n);return!i&&this!==E.defaultJModule?E.import(r,e):i&&i instanceof W?i.resolve(e):i}static _import(r="",e={}){return console.warn("JModule._import is deprecated"),this.import(r,e)}setCompleteHook(){this.hooks.complete=Promise.race([P(`module.${this.key}.${f.done}`),P(`module.${this.key}.${f.loadFailure}`),P(`module.${this.key}.${f.bootFailure}`)]).then(()=>{if(this._status!==f.done)throw new Error(Oe[this._status]);return this})}load(){return J(this,arguments,function*(r="load",e={autoApplyStyle:!0}){const{resource:t}=this,{loading:n,defined:i,booting:o,done:a,loaded:u,initializeFailed:s,loadFailure:l,bootFailure:c}=f;if([n,i,o,a,u].includes(this.status))return r==="load"&&e.autoApplyStyle&&t.applyStyle(),yield r!=="load"?Promise.resolve():this.hooks.complete,t;if(yield t.init([l,c,s].includes(this.status)),r==="preload"&&(window.requestIdleCallback?window.requestIdleCallback(()=>t.preload(e.elementModifier)):window.setTimeout(()=>t.preload(e.elementModifier),500)),r==="load"){this.status=f.loading,this.setCompleteHook(),t.applyScript(e.elementModifier),e.autoApplyStyle&&t.applyStyle(e.elementModifier);try{yield this.hooks.complete}catch(d){throw t.removeStyle(),t.resetStyleStatus(),d}}return t})}};let j=x;j.define=E.define,j.id=E.registerJModule(j),j.debug=Dt;var It=j;export{W as DepResolver,j as JModule,b as JModuleManager,_e as MODULE_STATUS,A as ModuleHook,f as ModuleStatus,F as Resource,M as ResourceLoadStrategy,v as ResourceStatus,S as ResourceType,It as default,P as eventToPromise,ne as printDebugInfo,H as statusFromResourceToModule,$e as timeoutToPromise}; //# sourceMappingURL=index.esm.js.map