@micro-zoe/micro-app 1.0.0-alpha.6 → 1.0.0-alpha.7

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.
package/lib/index.umd.js CHANGED
@@ -1,2 +1,2 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).microApp={})}(this,(function(e){"use strict";const t="1.0.0-alpha.6",n="undefined"!=typeof window,o="undefined"!=typeof global?global:"undefined"!=typeof window?window:"undefined"!=typeof self?self:Function("return this")(),s=()=>{},r=()=>!1,i=Array.isArray,a=Object.assign,c=Object.defineProperty,l=Object.defineProperties,u=Object.prototype.hasOwnProperty;function p(e){return void 0===e}function h(e){return null===e}function d(e){return"string"==typeof e}function m(e){return"boolean"==typeof e}function f(e){return"function"==typeof e}function _(e){return"[object Object]"===toString.call(e)}function g(e){return"object"==typeof e}function w(e){return"[object Promise]"===toString.call(e)}function A(e){return f(e)&&0===e.name.indexOf("bound ")&&!e.hasOwnProperty("prototype")}function b(e){var t;if(f(e)){const n=e.toString();return(null===(t=e.prototype)||void 0===t?void 0:t.constructor)===e&&Object.getOwnPropertyNames(e.prototype).length>1||/^function\s+[A-Z]/.test(n)||/^class\s+/.test(n)}return!1}function y(e){return e instanceof URL}function v(e,t=null,...n){const o=t&&d(t)?` app ${t}:`:"";d(e)?console.error(`[micro-app]${o} ${e}`,...n):console.error(`[micro-app]${o}`,e,...n)}function E(e,t=null,...n){const o=t&&d(t)?` app ${t}:`:"";d(e)?console.warn(`[micro-app]${o} ${e}`,...n):console.warn(`[micro-app]${o}`,e,...n)}function R(e,...t){Promise.resolve().then(e.bind(null,...t))}const S=function(){class e extends URL{}return(t,n)=>n?new e(""+t,n):new e(""+t)}();function P(e){return e.startsWith("//")?`${o.location.protocol}${e}`:e}function M(e,t=null){if(!d(e)||!e)return"";try{const{origin:t,pathname:n,search:o}=S(P(e));if(/\.(\w+)$/.test(n))return`${t}${n}${o}`;const s=`${t}${n}/`.replace(/\/\/$/,"/");return/^https?:\/\//.test(s)?`${s}${o}`:""}catch(e){return v(e,t),""}}function N(e){return d(e)&&e?e.replace(/(^\d+)|([^\w\d-_])/gi,""):""}function C(e){const{origin:t,pathname:n}=S(e);if(/\.(\w+)$/.test(n)){const e=`${t}${n}`.split("/");return e.pop(),e.join("/")+"/"}return`${t}${n}/`.replace(/\/\/$/,"/")}function O(e,t){return!e||/^((((ht|f)tps?)|file):)?\/\//.test(e)||/^(data|blob):/.test(e)?e:S(e,C(P(t))).toString()}function D(e,t,n,o){let s=0;function r(){++s===e.length&&o&&o()}e.forEach(((e,o)=>{w(e)?e.then((e=>{t({data:e,index:o}),r()})).catch((e=>{n({error:e,index:o}),r()})):(t({data:e,index:o}),r())}))}const x=o.requestIdleCallback||function(e){const t=Date.now();return setTimeout((function(){e({didTimeout:!1,timeRemaining:()=>Math.max(0,50-(Date.now()-t))})}),1)};function I(e){return new Promise((t=>{x((()=>{e(t)}))}))}let L=null;function U(e){L=e}function T(e){L!==e&&(U(e),R((()=>{U(null)})))}function W(){return L}function k(){U(null)}function B(e,t){const n=document.createElement(e,t);return n.__MICRO_APP_NAME__&&delete n.__MICRO_APP_NAME__,n.__PURE_ELEMENT__=!0,n}function $(e,t,n){if(t.innerHTML="",n){const n=e.cloneNode(!0),o=document.createDocumentFragment();Array.from(n.childNodes).forEach((e=>{o.appendChild(e)})),t.appendChild(o)}else Array.from(e.childNodes).forEach((e=>{t.appendChild(e)}))}function F(e){return!e||/(^\d)|([^\w\d-_\u4e00-\u9fa5])/gi.test(e)}function H(e){return/^body$/i.test(e)||/^head$/i.test(e)||/^html$/i.test(e)}function K(e){return function(e){return"undefined"!=typeof ShadowRoot&&e instanceof ShadowRoot}(e)?e.host:e}function j(e){return e?e.replace(/^\s+|\s+$/g,""):""}function G(){return navigator.userAgent.indexOf("Firefox")>-1}function V(e){const t={},n=e.split("&");for(const e of n){const n=e.indexOf("="),o=n<0?e:e.slice(0,n),s=n<0?null:e.slice(n+1);if(o in t){let e=t[o];i(e)||(e=t[o]=[e]),e.push(s)}else t[o]=s}return t}function q(e){let t="";for(const n in e){const o=e[n];if(h(o))t+=(t.length?"&":"")+n;else{(i(o)?o:[o]).forEach((e=>{p(e)||(t+=(t.length?"&":"")+n,h(e)||(t+="="+e))}))}}return t}function Q(){const e=new Set;return{add:function(t){return e.add(t),()=>!!e.has(t)&&e.delete(t)},list:()=>e}}function z(e){const t=e.attributes,n=new Map;for(let e=0;e<t.length;e++)n.set(t[e].name,t[e].value);return n}function Y(e,t){e?e.push((()=>I((e=>{t(),e()})))):t()}function X(e){return(null==e?void 0:e.reduce(((e,t)=>e.then(t)),Promise.resolve()))||null}function J(e){return e.startsWith("inline-")}var Z,ee,te,ne;!function(e){e.NAME="name",e.URL="url"}(Z||(Z={})),function(e){e.CREATED="created",e.LOADING="loading",e.LOADED="loaded",e.LOAD_FAILED="load_failed",e.MOUNTING="mounting",e.MOUNTED="mounted",e.UNMOUNT="unmount"}(ee||(ee={})),function(e){e.CREATED="created",e.BEFOREMOUNT="beforemount",e.MOUNTED="mounted",e.UNMOUNT="unmount",e.ERROR="error",e.BEFORESHOW="beforeshow",e.AFTERSHOW="aftershow",e.AFTERHIDDEN="afterhidden"}(te||(te={})),function(e){e.KEEP_ALIVE_SHOW="keep_alive_show",e.KEEP_ALIVE_HIDDEN="keep_alive_hidden"}(ne||(ne={}));const oe="window,self,globalThis,Array,Object,String,Boolean,Math,Number,Symbol,Date,Function,Proxy,WeakMap,WeakSet,Set,Map,Reflect,Element,Node,Document,RegExp,Error,TypeError,JSON,isNaN,parseFloat,parseInt,performance,console,decodeURI,encodeURI,decodeURIComponent,encodeURIComponent,navigator,undefined,location,history";function se(e,t=null,n={}){return k(),f(an.options.fetch)?an.options.fetch(e,n,t):window.fetch(e,n).then((e=>e.text()))}class re{static getInstance(){return this.instance||(this.instance=new re),this.instance}run(e,t){const n=e.name,o=e.ssrUrl||e.url;se(o,n,{cache:"no-cache"}).then((s=>{if(!s){const t="html is empty, please check in detail";return e.onerror(new Error(t)),v(t,n)}s=this.formatHTML(o,s,n),t(s,e)})).catch((t=>{v(`Failed to fetch data from ${e.url}, micro-app stop rendering`,n,t),e.onLoadError(t)}))}formatHTML(e,t,n){return this.processHtml(e,t,n,an.options.plugins).replace(/<head[^>]*>[\s\S]*?<\/head>/i,(e=>e.replace(/<head/i,"<micro-app-head").replace(/<\/head>/i,"</micro-app-head>"))).replace(/<body[^>]*>[\s\S]*?<\/body>/i,(e=>e.replace(/<body/i,"<micro-app-body").replace(/<\/body>/i,"</micro-app-body>")))}processHtml(e,t,n,o){var s;if(!o)return t;const r=[];return o.global&&r.push(...o.global),(null===(s=o.modules)||void 0===s?void 0:s[n])&&r.push(...o.modules[n]),r.length>0?r.reduce(((t,n)=>_(n)&&f(n.processHtml)?n.processHtml(t,e):t),t):t}}const ie=/(^|\s+)(html|:root)(?=[\s>~[.#:]+|$)/,ae=/(^|\s+)((html[\s>~]+body)|body)(?=[\s>~[.#:]+|$)/;function ce(e,t){e=t?`${t} ${e}`:e;const n=new Error(e);throw n.reason=e,t&&(n.filename=t),n}class le{constructor(){this.cssText="",this.prefix="",this.baseURI="",this.linkPath="",this.result="",this.scopecssDisable=!1,this.scopecssDisableSelectors=[],this.scopecssDisableNextLine=!1,this.mediaRule=this.createMatcherForRuleWithChildRule(/^@media *([^{]+)/,"@media"),this.supportsRule=this.createMatcherForRuleWithChildRule(/^@supports *([^{]+)/,"@supports"),this.documentRule=this.createMatcherForRuleWithChildRule(/^@([-\w]+)?document *([^{]+)/,"@document"),this.hostRule=this.createMatcherForRuleWithChildRule(/^@host\s*/,"@host"),this.importRule=this.createMatcherForNoneBraceAtRule("import"),this.charsetRule=this.createMatcherForNoneBraceAtRule("charset"),this.namespaceRule=this.createMatcherForNoneBraceAtRule("namespace")}exec(e,t,n,o){return this.cssText=e,this.prefix=t,this.baseURI=n,this.linkPath=o||"",this.matchRules(),G()?decodeURIComponent(this.result):this.result}reset(){this.cssText=this.prefix=this.baseURI=this.linkPath=this.result="",this.scopecssDisable=this.scopecssDisableNextLine=!1,this.scopecssDisableSelectors=[]}matchRules(){for(this.matchLeadingSpaces(),this.matchComments();this.cssText.length&&"}"!==this.cssText.charAt(0)&&(this.matchAtRule()||this.matchStyleRule());)this.matchComments()}matchStyleRule(){const e=this.formatSelector(!0);return this.scopecssDisableNextLine=!1,e?(this.recordResult(e),this.matchComments(),this.styleDeclarations(),this.matchLeadingSpaces(),!0):ce("selector missing",this.linkPath)}formatSelector(e){const t=this.commonMatch(/^[^{]+/,e);return!!t&&t[0].replace(/(^|,[\n\s]*)([^,]+)/g,((e,t,n)=>(n=j(n),this.scopecssDisableNextLine||this.scopecssDisable&&(!this.scopecssDisableSelectors.length||this.scopecssDisableSelectors.includes(n))||ie.test(n)||(n=ae.test(n)?n.replace(ae,this.prefix+" micro-app-body"):this.prefix+" "+n),t+n)))}styleDeclarations(){return this.matchOpenBrace()?(this.matchAllDeclarations(),!!this.matchCloseBrace()||ce("Declaration missing '}'",this.linkPath)):ce("Declaration missing '{'",this.linkPath)}matchAllDeclarations(){let e=this.commonMatch(/^(?:url\(["']?(?:[^)"'}]+)["']?\)|[^}/])*/,!0)[0];if(e&&(this.scopecssDisableNextLine||this.scopecssDisable&&!this.scopecssDisableSelectors.length||(e=e.replace(/url\(["']?([^)"']+)["']?\)/gm,((e,t)=>/^((data|blob):|#)/.test(t)||/^(https?:)?\/\//.test(t)?e:(/^((\.\.?\/)|[^/])/.test(t)&&this.linkPath&&(this.baseURI=function(e){const t=e.split("/");return t.pop(),P(t.join("/")+"/")}(this.linkPath)),`url("${O(t,this.baseURI)}")`)))),this.recordResult(e)),this.scopecssDisableNextLine=!1,this.cssText&&"}"!==this.cssText.charAt(0))return"/"===this.cssText.charAt(0)&&"*"===this.cssText.charAt(1)?this.matchComments():this.commonMatch(/\/+/),this.matchAllDeclarations()}matchAtRule(){return"@"===this.cssText[0]&&(this.scopecssDisableNextLine=!1,this.keyframesRule()||this.mediaRule()||this.customMediaRule()||this.supportsRule()||this.importRule()||this.charsetRule()||this.namespaceRule()||this.documentRule()||this.pageRule()||this.hostRule()||this.fontFaceRule())}keyframesRule(){if(!this.commonMatch(/^@([-\w]+)?keyframes\s*/))return!1;if(!this.commonMatch(/^[^{]+/))return ce("@keyframes missing name",this.linkPath);if(this.matchComments(),!this.matchOpenBrace())return ce("@keyframes missing '{'",this.linkPath);for(this.matchComments();this.keyframeRule();)this.matchComments();return this.matchCloseBrace()?(this.matchLeadingSpaces(),!0):ce("@keyframes missing '}'",this.linkPath)}keyframeRule(){let e;const t=[];for(;e=this.commonMatch(/^((\d+\.\d+|\.\d+|\d+)%?|[a-z]+)\s*/);)t.push(e[1]),this.commonMatch(/^,\s*/);return!!t.length&&(this.styleDeclarations(),this.matchLeadingSpaces(),!0)}customMediaRule(){return!!this.commonMatch(/^@custom-media\s+(--[^\s]+)\s*([^{;]+);/)&&(this.matchLeadingSpaces(),!0)}pageRule(){return!!this.commonMatch(/^@page */)&&(this.formatSelector(!1),this.scopecssDisableNextLine=!1,this.commonHandlerForAtRuleWithSelfRule("page"))}fontFaceRule(){return!!this.commonMatch(/^@font-face\s*/)&&this.commonHandlerForAtRuleWithSelfRule("font-face")}createMatcherForRuleWithChildRule(e,t){return()=>!!this.commonMatch(e)&&(this.matchOpenBrace()?(this.matchComments(),this.matchRules(),this.matchCloseBrace()?(this.matchLeadingSpaces(),!0):ce(`${t} missing '}'`,this.linkPath)):ce(`${t} missing '{'`,this.linkPath))}createMatcherForNoneBraceAtRule(e){const t=new RegExp("^@"+e+"\\s*([^;]+);");return()=>!!this.commonMatch(t)&&(this.matchLeadingSpaces(),!0)}commonHandlerForAtRuleWithSelfRule(e){return this.matchOpenBrace()?(this.matchAllDeclarations(),this.matchCloseBrace()?(this.matchLeadingSpaces(),!0):ce(`@${e} missing '}'`,this.linkPath)):ce(`@${e} missing '{'`,this.linkPath)}matchComments(){for(;this.matchComment(););}matchComment(){if("/"!==this.cssText.charAt(0)||"*"!==this.cssText.charAt(1))return!1;this.scopecssDisableNextLine=!1;let e=2;for(;""!==this.cssText.charAt(e)&&("*"!==this.cssText.charAt(e)||"/"!==this.cssText.charAt(e+1));)++e;if(e+=2,""===this.cssText.charAt(e-1))return ce("End of comment missing",this.linkPath);let t=this.cssText.slice(2,e-2);if(this.recordResult(`/*${t}*/`),t=j(t.replace(/^\s*!/,"")),"scopecss-disable-next-line"===t)this.scopecssDisableNextLine=!0;else if(/^scopecss-disable/.test(t))if("scopecss-disable"===t)this.scopecssDisable=!0;else{this.scopecssDisable=!0;t.replace("scopecss-disable","").split(",").forEach((e=>{this.scopecssDisableSelectors.push(j(e))}))}else"scopecss-enable"===t&&(this.scopecssDisable=!1,this.scopecssDisableSelectors=[]);return this.cssText=this.cssText.slice(e),this.matchLeadingSpaces(),!0}commonMatch(e,t=!1){const n=e.exec(this.cssText);if(!n)return;const o=n[0];return this.cssText=this.cssText.slice(o.length),t||this.recordResult(o),n}matchOpenBrace(){return this.commonMatch(/^{\s*/)}matchCloseBrace(){return this.commonMatch(/^}/)}matchLeadingSpaces(){this.commonMatch(/^\s*/)}recordResult(e){G()?this.result+=encodeURIComponent(e):this.result+=e}}function ue(e,t,n,o,s){if(!e.__MICRO_APP_HAS_SCOPED__){e.__MICRO_APP_HAS_SCOPED__=!0;let r=null;try{r=pe.exec(e.textContent,n,o,s),pe.reset()}catch(e){pe.reset(),v("An error occurred while parsing CSS:\n",t,e)}r&&(e.textContent=r)}}let pe;function he(e,t,n){if(t.scopecss){const o=de(t.name);if(pe||(pe=new le),e.textContent)ue(e,t.name,o,t.url,n);else{const s=new MutationObserver((function(){s.disconnect(),e.textContent&&!e.hasAttribute("data-styled")&&ue(e,t.name,o,t.url,n)}));s.observe(e,{childList:!0})}}return e}function de(e,t=!1){const n=t?"\\":"";return`${an.tagName}${n}[name=${e}${n}]`}function me(e,t){Object.defineProperties(e,{currentTarget:{get:()=>t},srcElement:{get:()=>t},target:{get:()=>t}})}function fe(e){const t=new CustomEvent("load");me(t,e),f(e.onload)?e.onload(t):e.dispatchEvent(t)}function _e(e){const t=new CustomEvent("error");me(t,e),f(e.onerror)?e.onerror(t):e.dispatchEvent(t)}var ge=function(){const e=new Map,t=new Map;function n(e){return{setInfo(t,n){e.set(t,n)},getInfo(t){var n;return null!==(n=e.get(t))&&void 0!==n?n:null},hasInfo:t=>e.has(t),deleteInfo:t=>e.delete(t)}}return{link:n(e),script:Object.assign(Object.assign({},n(t)),{deleteInlineInfo(e){e.forEach((e=>{J(e)&&t.delete(e)}))}})}}();function we(e,t,n,o=!1){const s=e.getAttribute("rel");let r=e.getAttribute("href"),i=null;if("stylesheet"===s&&r){r=O(r,n.url);let t=ge.link.getInfo(r);const s={attrs:z(e)};if(t?t.appSpace[n.name]=t.appSpace[n.name]||s:t={code:"",appSpace:{[n.name]:s}},ge.link.setInfo(r,t),o)return{address:r,linkInfo:t};n.source.links.add(r),i=document.createComment(`link element with href=${r} move to micro-app-head as style element`),t.appSpace[n.name].placeholder=i}else s&&["prefetch","preload","prerender","icon","apple-touch-icon"].includes(s)?o?i=document.createComment(`link element with rel=${s}${r?" & href="+r:""} removed by micro-app`):t.removeChild(e):r&&e.setAttribute("href",O(r,n.url));return o?{replaceComment:i}:i?t.replaceChild(i,e):void 0}function Ae(e,t,n,o){const s=Array.from(t.source.links),r=s.map((e=>{const n=ge.link.getInfo(e);return n.code?n.code:se(e,t.name)})),i=t.isPrefetch||t.fiber?[]:null;D(r,(e=>{Y(i,(()=>function(e,t,n,o){const s=ge.link.getInfo(e);s.code=t;const r=s.appSpace[o.name],i=r.placeholder;if(i){const t=B("style");be(o,e,t,s,r.attrs),i.parentNode?i.parentNode.replaceChild(t,i):n.appendChild(t),r.placeholder=null}}(s[e.index],e.data,n,t)))}),(e=>{v(e,t.name)}),(()=>{i?o.then((()=>{i.push((()=>Promise.resolve(t.onLoad(e)))),X(i)})):t.onLoad(e)}))}function be(e,t,n,o,s){if(e.scopecss){const s=o.appSpace[e.name];if(s.prefix=s.prefix||de(e.name),s.parsedCode)n.textContent=s.parsedCode;else{const r=function(e,t,n){const o=n.appSpace;for(const n in o)if(n!==e){const e=o[n];if(e.parsedCode)return e.parsedCode.replaceAll(new RegExp(de(n,!0),"g"),t)}}(e.name,s.prefix,o);r?n.textContent=r:(n.textContent=o.code,he(n,e,t)),s.parsedCode=n.textContent}}else n.textContent=o.code;!function(e,t){t.forEach(((t,n)=>{"rel"!==n&&("href"===n&&(n="data-origin-href"),e.setAttribute(n,t))}))}(n,s)}class ye{constructor(){this.escapeSetterKeyList=["location"],this.staticEscapeProperties=["System","__cjsWrapper"],this.staticScopeProperties=["webpackJsonp","webpackHotUpdate","Vue"],this.injectReactHRMProperty()}injectReactHRMProperty(){"production"!==process.env.NODE_ENV&&(this.staticEscapeProperties.push("__REACT_ERROR_OVERLAY_GLOBAL_HOOK__"),Le.rawWindow.__REACT_ERROR_OVERLAY_GLOBAL_HOOK__&&(this.staticScopeProperties=this.staticScopeProperties.concat(["__REACT_ERROR_OVERLAY_GLOBAL_HOOK__","__reactRefreshInjected"])))}}function ve(e,t){const n=Object.getOwnPropertyDescriptor(e,"parentNode");n&&!n.configurable||Object.defineProperty(e,"parentNode",{value:t,configurable:!0})}const Ee=new WeakMap;function Re(e,t,n){if(t instanceof HTMLStyleElement){if(t.hasAttribute("exclude")){const e=document.createComment("style element with exclude attribute ignored by micro-app");return Ee.set(t,e),e}return n.scopecss&&!t.hasAttribute("ignore")?he(t,n):t}if(t instanceof HTMLLinkElement){if(t.hasAttribute("exclude")||je(t.getAttribute("href"),n.name)){const e=document.createComment("link element with exclude attribute ignored by micro-app");return Ee.set(t,e),e}if(t.hasAttribute("ignore")||Ge(t.getAttribute("href"),n.name)||t.href&&f(an.options.excludeAssetFilter)&&an.options.excludeAssetFilter(t.href))return t;const{address:o,linkInfo:s,replaceComment:r}=we(t,e,n,!0);if(o&&s){const e=function(e,t,n,o){const s=B("style"),r=()=>{be(t,e,s,n,n.appSpace[t.name].attrs),fe(o)};return n.code?R(r):se(e,t.name).then((e=>{n.code=e,r()})).catch((e=>{v(e,t.name),_e(o)})),s}(o,n,s,t);return Ee.set(t,e),e}return r?(Ee.set(t,r),r):t}if(t instanceof HTMLScriptElement){if(t.src&&f(an.options.excludeAssetFilter)&&an.options.excludeAssetFilter(t.src))return t;const{replaceComment:o,address:s,scriptInfo:r}=He(t,e,n,!0)||{};if(s&&r){const e=r.isExternal?function(e,t,n,o){const s=ke(t,n)?B("script"):document.createComment("dynamic script extract by micro-app"),r=()=>fe(o),i=()=>{const i=Object.getOwnPropertyDescriptor(Le.rawDocument,"currentScript");i&&!i.configurable||Object.defineProperty(Le.rawDocument,"currentScript",{value:o,configurable:!0}),qe(e,t,n,r,s),!We(t,n)&&r()};n.code?R(i):se(e,t.name).then((e=>{n.code=e,i()})).catch((e=>{v(e,t.name),_e(o)}));return s}(s,n,r,t):function(e,t,n){const o=ke(t,n)?B("script"):document.createComment("dynamic script extract by micro-app");return qe(e,t,n,void 0,o),o}(s,n,r);return Ee.set(t,e),e}return o?(Ee.set(t,o),o):t}return t}function Se(e,t,n,o,s){const r=function(e,t){var n,o;if(e===document.head)return null===(n=null==t?void 0:t.container)||void 0===n?void 0:n.querySelector("micro-app-head");if(e===document.body)return null===(o=null==t?void 0:t.container)||void 0===o?void 0:o.querySelector("micro-app-body");return null}(n,e);return r?s&&!r.contains(s)?Le.rawAppendChild.call(r,o):t!==Le.rawRemoveChild||r.contains(o)?("production"!==process.env.NODE_ENV&&o instanceof HTMLIFrameElement&&t===Le.rawAppendChild&&function(e){var t;if("production"!==process.env.NODE_ENV){const n=Le.rawWindow.__REACT_ERROR_OVERLAY_GLOBAL_HOOK__,o=null===(t=e.sandBox)||void 0===t?void 0:t.proxyWindow.__REACT_ERROR_OVERLAY_GLOBAL_HOOK__;n&&o&&(Le.rawWindow.__REACT_ERROR_OVERLAY_GLOBAL_HOOK__=o,R((()=>{Le.rawWindow.__REACT_ERROR_OVERLAY_GLOBAL_HOOK__=n})))}}(e),Pe(t,r,o,s)):n.contains(o)?t.call(n,o):o:Pe(t,n,o,s)}function Pe(e,t,n,o){return(s=e)===Le.rawAppend||s===Le.rawPrepend?e.call(t,n):e.call(t,n,o);var s}function Me(e){var t;return null!==(t=Ee.get(e))&&void 0!==t?t:e}function Ne(e,t,n,o){const s=W();if(t instanceof Node&&(t.__MICRO_APP_NAME__||s&&!t.__PURE_ELEMENT__)){t.__MICRO_APP_NAME__=t.__MICRO_APP_NAME__||s;const r=Jt.get(t.__MICRO_APP_NAME__);if(null==r?void 0:r.container)return t instanceof Element&&(/^(img|script)$/i.test(t.tagName)?(t.hasAttribute("src")&&Le.rawSetAttribute.call(t,"src",O(t.getAttribute("src"),r.url)),t.hasAttribute("srcset")&&Le.rawSetAttribute.call(t,"srcset",O(t.getAttribute("srcset"),r.url))):/^link$/i.test(t.tagName)&&t.hasAttribute("href")&&Le.rawSetAttribute.call(t,"href",O(t.getAttribute("href"),r.url))),Se(r,o,e,Re(e,t,r),n&&Me(n));if(o===Le.rawAppend||o===Le.rawPrepend)return o.call(e,t)}else if(o===Le.rawAppend||o===Le.rawPrepend){if(!(t instanceof Node)&&s){const n=Jt.get(s);if(null==n?void 0:n.container){if(e===document.head)return o.call(n.container.querySelector("micro-app-head"),t);if(e===document.body)return o.call(n.container.querySelector("micro-app-body"),t)}}return o.call(e,t)}return o.call(e,t,n)}function Ce(){!function(){const e=Le.rawDocument,t=Le.rawRootDocument;function n(t){return function(e){return"[object ProxyDocument]"===toString.call(e)}(t)?e:t}function o(t){var o,s,r,i;const a=n(this),c=W();return c&&(null===(o=Jt.get(c))||void 0===o?void 0:o.container)&&t&&!H(t)&&e===a?null!==(i=null===(r=null===(s=Jt.get(c))||void 0===s?void 0:s.container)||void 0===r?void 0:r.querySelector(t))&&void 0!==i?i:null:Le.rawQuerySelector.call(a,t)}function s(t){var o,s,r,i;const a=n(this),c=W();return c&&(null===(o=Jt.get(c))||void 0===o?void 0:o.container)&&t&&!H(t)&&e===a?null!==(i=null===(r=null===(s=Jt.get(c))||void 0===s?void 0:s.container)||void 0===r?void 0:r.querySelectorAll(t))&&void 0!==i?i:[]:Le.rawQuerySelectorAll.call(a,t)}t.prototype.createElement=function(e,t){return Oe(Le.rawCreateElement.call(n(this),e,t))},t.prototype.createElementNS=function(e,t,o){return Oe(Le.rawCreateElementNS.call(n(this),e,t,o))},t.prototype.createDocumentFragment=function(){return Oe(Le.rawCreateDocumentFragment.call(n(this)))},t.prototype.querySelector=o,t.prototype.querySelectorAll=s,t.prototype.getElementById=function(e){const t=n(this);if(!W()||F(e))return Le.rawGetElementById.call(t,e);try{return o.call(t,`#${e}`)}catch(n){return Le.rawGetElementById.call(t,e)}},t.prototype.getElementsByClassName=function(e){const t=n(this);if(!W()||F(e))return Le.rawGetElementsByClassName.call(t,e);try{return s.call(t,`.${e}`)}catch(n){return Le.rawGetElementsByClassName.call(t,e)}},t.prototype.getElementsByTagName=function(e){var t;const o=n(this),r=W();if(!r||H(e)||F(e)||!(null===(t=Jt.get(r))||void 0===t?void 0:t.inline)&&/^script$/i.test(e))return Le.rawGetElementsByTagName.call(o,e);try{return s.call(o,e)}catch(t){return Le.rawGetElementsByTagName.call(o,e)}},t.prototype.getElementsByName=function(e){const t=n(this);if(!W()||F(e))return Le.rawGetElementsByName.call(t,e);try{return s.call(t,`[name=${e}]`)}catch(n){return Le.rawGetElementsByName.call(t,e)}}}(),Element.prototype.appendChild=function(e){return Ne(this,e,null,Le.rawAppendChild)},Element.prototype.insertBefore=function(e,t){return Ne(this,e,t,Le.rawInsertBefore)},Element.prototype.replaceChild=function(e,t){return Ne(this,e,t,Le.rawReplaceChild)},Element.prototype.append=function(...e){let t=0;const n=e.length;for(;t<n;)Ne(this,e[t],null,Le.rawAppend),t++},Element.prototype.prepend=function(...e){let t=e.length;for(;t>0;)Ne(this,e[t-1],null,Le.rawPrepend),t--},Element.prototype.removeChild=function(e){var t;if(null==e?void 0:e.__MICRO_APP_NAME__){const n=Jt.get(e.__MICRO_APP_NAME__);if(null==n?void 0:n.container)return Se(n,Le.rawRemoveChild,this,Me(e));try{return Le.rawRemoveChild.call(this,e)}catch(n){return null===(t=null==e?void 0:e.parentNode)||void 0===t?void 0:t.removeChild(e)}}return Le.rawRemoveChild.call(this,e)},Element.prototype.cloneNode=function(e){const t=Le.rawCloneNode.call(this,e);return this.__MICRO_APP_NAME__&&(t.__MICRO_APP_NAME__=this.__MICRO_APP_NAME__),t}}function Oe(e){const t=W();return t&&(e.__MICRO_APP_NAME__=t),e}let De=!1;function xe(){k(),function(){const e=Le.rawRootDocument;e.prototype.createElement=Le.rawCreateElement,e.prototype.createElementNS=Le.rawCreateElementNS,e.prototype.createDocumentFragment=Le.rawCreateDocumentFragment,e.prototype.querySelector=Le.rawQuerySelector,e.prototype.querySelectorAll=Le.rawQuerySelectorAll,e.prototype.getElementById=Le.rawGetElementById,e.prototype.getElementsByClassName=Le.rawGetElementsByClassName,e.prototype.getElementsByTagName=Le.rawGetElementsByTagName,e.prototype.getElementsByName=Le.rawGetElementsByName}(),Element.prototype.appendChild=Le.rawAppendChild,Element.prototype.insertBefore=Le.rawInsertBefore,Element.prototype.replaceChild=Le.rawReplaceChild,Element.prototype.removeChild=Le.rawRemoveChild,Element.prototype.append=Le.rawAppend,Element.prototype.prepend=Le.rawPrepend,Element.prototype.cloneNode=Le.rawCloneNode}let Ie=!1;const Le={};function Ue(){if(n){const e=Function("return window")(),t=Function("return document")(),n=Function("return Document")(),o="noModule"in document.createElement("script"),s=Element.prototype.setAttribute,r=Element.prototype.appendChild,i=Element.prototype.insertBefore,c=Element.prototype.replaceChild,l=Element.prototype.removeChild,u=Element.prototype.append,p=Element.prototype.prepend,h=Element.prototype.cloneNode,d=n.prototype.createElement,m=n.prototype.createElementNS,f=n.prototype.createDocumentFragment,_=n.prototype.querySelector,g=n.prototype.querySelectorAll,w=n.prototype.getElementById,A=n.prototype.getElementsByClassName,b=n.prototype.getElementsByTagName,y=n.prototype.getElementsByName,v=new Proxy(Image,{construct(e,t){const n=new e(...t);return n.__MICRO_APP_NAME__=W(),n}}),E=e.addEventListener,R=e.removeEventListener,S=e.setInterval,P=e.setTimeout,M=e.clearInterval,N=e.clearTimeout,C=e.history.pushState,O=e.history.replaceState,D=t.addEventListener,x=t.removeEventListener;window.__MICRO_APP_BASE_APPLICATION__=!0,a(Le,{rawWindow:e,rawDocument:t,rawRootDocument:n,supportModuleScript:o,rawSetAttribute:s,rawAppendChild:r,rawInsertBefore:i,rawReplaceChild:c,rawRemoveChild:l,rawAppend:u,rawPrepend:p,rawCloneNode:h,rawCreateElement:d,rawCreateElementNS:m,rawCreateDocumentFragment:f,rawQuerySelector:_,rawQuerySelectorAll:g,rawGetElementById:w,rawGetElementsByClassName:A,rawGetElementsByTagName:b,rawGetElementsByName:y,ImageProxy:v,rawWindowAddEventListener:E,rawWindowRemoveEventListener:R,rawSetInterval:S,rawSetTimeout:P,rawClearInterval:M,rawClearTimeout:N,rawDocumentAddEventListener:D,rawDocumentRemoveEventListener:x,rawPushState:C,rawReplaceState:O}),function(){if(!Ie){Ie=!0;const e=B("style");Le.rawSetAttribute.call(e,"type","text/css"),e.textContent=`\n${an.tagName}, micro-app-body { display: block; } \nmicro-app-head { display: none; }`,Le.rawDocument.head.appendChild(e)}}()}}const Te=["text/javascript","text/ecmascript","application/javascript","application/ecmascript","module","systemjs-module","systemjs-importmap"];function We(e,t){return t.appSpace[e.name].module&&(!e.useSandbox||e.esmodule)}function ke(e,t){return e.inline||t.appSpace[e.name].inline||We(e,t)||function(e,t){return t.appSpace[e.name].attrs.has("id")}(e,t)}function Be(e,t,n){return function(e,t,n){const o=t.appSpace;for(const t in o)if(t!==e){const e=o[t];if(e.parsedCode===n&&e.parsedFunction)return e.parsedFunction}}(e.name,t,n)||new Function(n)}function $e(){const e="inline-"+Math.random().toString(36).substr(2,15);return ge.script.hasInfo(e)?$e():e}function Fe(e,t){return e.useSandbox&&!We(e,t)}function He(e,t,n,o=!1){let s=null,r=e.getAttribute("src");if(r&&(r=O(r,n.url)),e.hasAttribute("exclude")||je(r,n.name))s=document.createComment("script element with exclude attribute removed by micro-app");else{if(e.type&&!Te.includes(e.type)||e.hasAttribute("ignore")||Ge(r,n.name))return null;if(Le.supportModuleScript&&e.noModule||!Le.supportModuleScript&&"module"===e.type)s=document.createComment((e.noModule?"noModule":"module")+" script ignored by micro-app");else if(r){let t=ge.script.getInfo(r);const i={async:e.hasAttribute("async"),defer:e.defer||"module"===e.type,module:"module"===e.type,inline:e.hasAttribute("inline"),pure:e.hasAttribute("pure"),attrs:z(e)};if(t?t.appSpace[n.name]=t.appSpace[n.name]||i:t={code:"",isExternal:!0,appSpace:{[n.name]:i}},ge.script.setInfo(r,t),o)return{address:r,scriptInfo:t};n.source.scripts.add(r),s=document.createComment(`script with src='${r}' extract by micro-app`)}else if(e.textContent){const t=$e(),r={code:e.textContent,isExternal:!1,appSpace:{[n.name]:{async:!1,defer:"module"===e.type,module:"module"===e.type,inline:e.hasAttribute("inline"),pure:e.hasAttribute("pure"),attrs:z(e)}}};if(o)return{address:t,scriptInfo:r};n.source.scripts.add(t),ge.script.setInfo(t,r),s=document.createComment("inline script extract by micro-app")}else o||(s=document.createComment("script element removed by micro-app"))}return o?{replaceComment:s}:t.replaceChild(s,e)}function Ke(e){var t,n,o;return[...(null===(t=an.options.plugins)||void 0===t?void 0:t.global)||[],...(null===(o=null===(n=an.options.plugins)||void 0===n?void 0:n.modules)||void 0===o?void 0:o[e])||[]]}function je(e,t){if(!e)return!1;return(Ke(t)||[]).some((t=>!!t.excludeChecker&&t.excludeChecker(e)))}function Ge(e,t){if(!e)return!1;return(Ke(t)||[]).some((t=>!!t.ignoreChecker&&t.ignoreChecker(e)))}function Ve(e,t){const n=Array.from(t.source.scripts),o=[],s=[];for(const e of n){const n=ge.script.getInfo(e),r=n.appSpace[t.name];(!r.defer&&!r.async||t.isPrefetch)&&(o.push(n.code?n.code:se(e,t.name)),s.push([e,n]))}const r=t.isPrefetch||t.fiber?[]:null;o.length?D(o,(e=>{Y(r,(()=>function(e,t,n,o){if(t.code=n,o.isPrefetch){const s=t.appSpace[o.name];if(!s.parsedCode&&(s.parsedCode=Qe(e,o,n,t),s.wrapInSandBox=Fe(o,t),!ke(o,t)))try{s.parsedFunction=Be(o,t,s.parsedCode)}catch(e){E("Something went wrong while handling preloaded resources",o.name,"\n",e)}}}(s[e.index][0],s[e.index][1],e.data,t)))}),(e=>{v(e,t.name)}),(()=>{r?(r.push((()=>Promise.resolve(t.onLoad(e)))),X(r)):t.onLoad(e)})):t.onLoad(e)}function qe(e,t,n,o,s){var r;try{!function(e){!function(e){e.sandBox&&(Le.rawWindow.__MICRO_APP_PROXY_WINDOW__=e.sandBox.proxyWindow)}(e)}(t);const i=n.appSpace[t.name],a=Fe(t,n);if(i.parsedCode&&i.wrapInSandBox===a||(i.parsedCode=Qe(e,t,n.code,n),i.wrapInSandBox=a,i.parsedFunction=null),ke(t,n)){const a=s||B("script");!function(e,t,n,o,s,r){if(n){if(J(e)){const e=new Blob([t],{type:"text/javascript"});o.src=URL.createObjectURL(e)}else o.src=e;o.setAttribute("type","module"),r&&(r.moduleCount&&r.moduleCount--,o.onload=r.bind(o,0===r.moduleCount))}else o.textContent=t;!function(e,t){t.forEach(((t,n)=>{"type"===n&&"module"===t||"defer"===n||"async"===n||("src"===n&&(n="data-origin-src"),e.setAttribute(n,t))}))}(o,s)}(e,i.parsedCode,We(t,n),a,i.attrs,o),s||null===(r=t.container)||void 0===r||r.querySelector("micro-app-body").appendChild(a)}else!function(e,t){const n=t.appSpace[e.name];n.parsedFunction||(n.parsedFunction=Be(e,t,n.parsedCode));n.parsedFunction.call(window)}(t,n)}catch(n){console.error(`[micro-app from ${s?"runDynamicScript":"runScript"}] app ${t.name}: `,n,e)}}function Qe(e,t,n,o){return _(an.options.plugins)&&(n=function(e,t,n,o){var s;const r=ze(o.global,t,e);return ze(null===(s=o.modules)||void 0===s?void 0:s[n],r,e)}(e,n,t.name,an.options.plugins)),Fe(t,o)?`;(function(proxyWindow){with(proxyWindow.__MICRO_APP_WINDOW__){(function(${oe}){;${n}\n${J(e)?"":`//# sourceURL=${e}\n`}}).call(proxyWindow,${oe})}})(window.__MICRO_APP_PROXY_WINDOW__);`:n}function ze(e,t,n){return i(e)?e.reduce(((e,t)=>_(t)&&f(t.loader)?t.loader(e,n):e),t):t}function Ye(e,t,n,o){const s=Array.from(e.children);s.length&&s.forEach((e=>{Ye(e,t,n,o)}));for(const n of s)n instanceof HTMLLinkElement?n.hasAttribute("exclude")||je(n.getAttribute("href"),t.name)?e.replaceChild(document.createComment("link element with exclude attribute ignored by micro-app"),n):n.hasAttribute("ignore")||Ge(n.getAttribute("href"),t.name)?n.hasAttribute("href")&&n.setAttribute("href",O(n.getAttribute("href"),t.url)):we(n,e,t):n instanceof HTMLStyleElement?n.hasAttribute("exclude")?e.replaceChild(document.createComment("style element with exclude attribute ignored by micro-app"),n):t.scopecss&&!n.hasAttribute("ignore")&&Y(o,(()=>he(n,t))):n instanceof HTMLScriptElement?He(n,e,t):n instanceof HTMLMetaElement||n instanceof HTMLTitleElement?e.removeChild(n):n instanceof HTMLImageElement&&n.hasAttribute("src")&&n.setAttribute("src",O(n.getAttribute("src"),t.url))}function Xe(e,t){const n=function(e){const t=B("div");return t.innerHTML=e,t}(e),o=n.querySelector("micro-app-head"),s=n.querySelector("micro-app-body");if(!o||!s){const e=`element ${o?"body":"head"} is missing`;return t.onerror(new Error(e)),v(e,t.name)}const r=t.isPrefetch||t.fiber?[]:null;Ye(n,t,o,r);const i=X(r);t.source.links.size?Ae(n,t,o,i):i?i.then((()=>t.onLoad(n))):t.onLoad(n),t.source.scripts.size?Ve(n,t):t.onLoad(n)}const Je=new class{constructor(){this.eventList=new Map}isLegalName(e){return!!e||(v("event-center: Invalid name"),!1)}on(e,t,n=!1){if(this.isLegalName(e)){if(!f(t))return v("event-center: Invalid callback function");let o=this.eventList.get(e);o?n&&Object.getOwnPropertyNames(o.data).length&&t(o.data):(o={data:{},callbacks:new Set},this.eventList.set(e,o)),o.callbacks.add(t)}}off(e,t){if(this.isLegalName(e)){const n=this.eventList.get(e);n&&(f(t)?n.callbacks.delete(t):n.callbacks.clear())}}dispatch(e,t){if(this.isLegalName(e)){if(!_(t))return v("event-center: data must be object");let n=this.eventList.get(e);if(n){if(n.data!==t){n.data=t;for(const e of n.callbacks)e(t)}}else n={data:t,callbacks:new Set},this.eventList.set(e,n)}}getData(e){var t;const n=this.eventList.get(e);return null!==(t=null==n?void 0:n.data)&&void 0!==t?t:null}};function Ze(e,t){return d(e)&&e?t?`__from_base_app_${e}__`:`__from_micro_app_${e}__`:""}class et{addGlobalDataListener(e,t){const n=this.appName;n&&(e.__APP_NAME__=n,e.__AUTO_TRIGGER__=t),Je.on("global",e,t)}removeGlobalDataListener(e){f(e)&&Je.off("global",e)}setGlobalData(e){k(),Je.dispatch("global",e)}getGlobalData(){return Je.getData("global")}clearGlobalDataListener(){const e=this.appName,t=Je.eventList.get("global");if(t)for(const n of t.callbacks)(e&&e===n.__APP_NAME__||!e&&!n.__APP_NAME__)&&t.callbacks.delete(n)}}class tt extends et{addDataListener(e,t,n){Je.on(Ze(N(e),!1),t,n)}removeDataListener(e,t){f(t)&&Je.off(Ze(N(e),!1),t)}getData(e,t=!1){return Je.getData(Ze(N(e),t))}setData(e,t){Je.dispatch(Ze(N(e),!0),t)}clearDataListener(e){Je.off(Ze(N(e),!1))}}class nt extends et{constructor(e){super(),this.appName=N(e),!this.appName&&v(`Invalid appName ${e}`)}addDataListener(e,t){e.__AUTO_TRIGGER__=t,Je.on(Ze(this.appName,!0),e,t)}removeDataListener(e){f(e)&&Je.off(Ze(this.appName,!0),e)}getData(){return Je.getData(Ze(this.appName,!0))}dispatch(e){k(),Je.dispatch(Ze(this.appName,!1),e);const t=Jt.get(this.appName);if((null==t?void 0:t.container)&&_(e)){const n=new CustomEvent("datachange",{detail:{data:e}});K(t.container).dispatchEvent(n)}}clearDataListener(){Je.off(Ze(this.appName,!0))}}class ot{constructor(){this.appInstanceMap=Jt}static getInstance(){return this.instance||(this.instance=new ot),this.instance}get(e){return this.appInstanceMap.get(e)}set(e,t){this.appInstanceMap.set(e,t)}getAll(){return Array.from(this.appInstanceMap.values())}clear(){this.appInstanceMap.clear()}}function st(){rt(),ot.getInstance().getAll().forEach((e=>{e.container&&K(e.container).disconnectedCallback()})),!window.__MICRO_APP_UMD_MODE__&&ot.getInstance().clear()}function rt(){window.__MICRO_APP_ENVIRONMENT__&&window.removeEventListener("unmount",st,!1)}function it(e,t,n="WINDOW"){const o=`__MICRO_APP_BOUND_${n}_FUNCTION__`;if(t[o])return t[o];if(!function(e){return m(e.__MICRO_APP_IS_CONSTRUCTOR__)?e.__MICRO_APP_IS_CONSTRUCTOR__:e.__MICRO_APP_IS_CONSTRUCTOR__=b(e)}(t)&&!function(e){return m(e.__MICRO_APP_IS_BOUND_FUNCTION__)?e.__MICRO_APP_IS_BOUND_FUNCTION__:e.__MICRO_APP_IS_BOUND_FUNCTION__=A(e)}(t)){const n=t.bind(e);for(const e in t)n[e]=t[e];return t.hasOwnProperty("prototype")&&c(n,"prototype",{value:t.prototype,configurable:!0,enumerable:!1,writable:!0}),t[o]=n}return t}const at=["unmount","appstate-change"];function ct(e,t){var n;return at.includes(e)||("popstate"===e||"hashchange"===e)&&(null===(n=Jt.get(t))||void 0===n?void 0:n.useMemoryRouter)?`${e}-${t}`:e}const lt=new Map;let ut=!1;const pt=new Map;function ht(){const{rawDocument:e,rawDocumentAddEventListener:t,rawDocumentRemoveEventListener:n}=Le;!ut&&function(){if(ut=!0,Object.getOwnPropertyDescriptor(document,"onclick"))return E("Cannot redefine document property onclick");const e=document.onclick;document.onclick=null;let t=!1;function n(e){lt.forEach((t=>{f(t)&&t.call(document,e)}))}c(document,"onclick",{configurable:!0,enumerable:!0,get(){const e=W();return e?lt.get(e):lt.get("base")},set(e){const o=W();o?lt.set(o,e):lt.set("base",e),!t&&f(e)&&(t=!0,Le.rawDocumentAddEventListener.call(Le.rawDocument,"click",n,!1))}}),e&&(document.onclick=e)}(),document.addEventListener=function(n,o,s){var r;const i=W();if(i&&(!(null===(r=Jt.get(i))||void 0===r?void 0:r.umdMode)||!A(o))){const e=pt.get(i);if(e){const t=e.get(n);t?t.add(o):e.set(n,new Set([o]))}else pt.set(i,new Map([[n,new Set([o])]]));o&&(o.__MICRO_APP_MARK_OPTIONS__=s)}t.call(e,n,o,s)},document.removeEventListener=function(t,o,s){var r;const i=W();if(i&&(!(null===(r=Jt.get(i))||void 0===r?void 0:r.umdMode)||!A(o))){const e=pt.get(i);if(e){const n=e.get(t);(null==n?void 0:n.size)&&n.has(o)&&n.delete(o)}}n.call(e,t,o,s)}}function dt(e,t){const n=new Map,o=new Map,s=new Map,{rawWindow:r,rawDocument:i,rawWindowAddEventListener:a,rawWindowRemoveEventListener:c,rawSetInterval:l,rawSetTimeout:u,rawClearInterval:p,rawClearTimeout:h,rawDocumentRemoveEventListener:d}=Le;t.addEventListener=function(t,o,s){t=ct(t,e);const i=n.get(t);i?i.add(o):n.set(t,new Set([o])),o&&(o.__MICRO_APP_MARK_OPTIONS__=s),a.call(r,t,o,s)},t.removeEventListener=function(t,o,s){t=ct(t,e);const i=n.get(t);(null==i?void 0:i.size)&&i.has(o)&&i.delete(o),c.call(r,t,o,s)},t.setInterval=function(e,t,...n){const s=l.call(r,e,t,...n);return o.set(s,{handler:e,timeout:t,args:n}),s},t.setTimeout=function(e,t,...n){const o=u.call(r,e,t,...n);return s.set(o,{handler:e,timeout:t,args:n}),o},t.clearInterval=function(e){o.delete(e),p.call(r,e)},t.clearTimeout=function(e){s.delete(e),h.call(r,e)};const m=new Map,f=new Map;let _,g=new Map,w=new Map;return{recordUmdEffect:()=>{n.forEach(((e,t)=>{e.size&&m.set(t,new Set(e))})),o.size&&(g=new Map(o)),s.size&&(w=new Map(s)),_=lt.get(e);const t=pt.get(e);t&&t.forEach(((e,t)=>{e.size&&f.set(t,new Set(e))}))},rebuildUmdEffect:()=>{m.forEach(((e,n)=>{for(const o of e)t.addEventListener(n,o,null==o?void 0:o.__MICRO_APP_MARK_OPTIONS__)})),g.forEach((e=>{t.setInterval(e.handler,e.timeout,...e.args)})),w.forEach((e=>{t.setTimeout(e.handler,e.timeout,...e.args)})),_&&lt.set(e,_),f.forEach(((e,t)=>{for(const n of e)document.addEventListener(t,n,null==n?void 0:n.__MICRO_APP_MARK_OPTIONS__)})),m.clear(),g.clear(),w.clear(),f.clear(),_=null},releaseEffect:()=>{n.size&&(n.forEach(((e,t)=>{for(const n of e)c.call(r,t,n)})),n.clear()),o.size&&(o.forEach(((e,t)=>{p.call(r,t)})),o.clear()),s.size&&(s.forEach(((e,t)=>{h.call(r,t)})),s.clear()),lt.delete(e);const t=pt.get(e);t&&(t.forEach(((e,t)=>{for(const n of e)d.call(i,t,n)})),t.clear())}}}function mt(e,t){const n=Le.rawWindow.history.state,o={microAppState:a({},null==n?void 0:n.microAppState,{[e]:t})};return a({},n,o)}function ft(e){var t,n;return(null===(n=null===(t=Le.rawWindow.history.state)||void 0===t?void 0:t.microAppState)||void 0===n?void 0:n[e])||null}const _t=/&/g,gt=/=/g,wt=/%M1/g,At=/%M2/g;function bt(e){return encodeURIComponent(vt(e).replace(_t,"%M1").replace(gt,"%M2"))}function yt(e){return vt(e).replace(wt,"&").replace(At,"=")}function vt(e){try{const t=decodeURIComponent(e);return e===t||wt.test(t)||At.test(t)?t:vt(t)}catch(t){return e}}function Et(e){var t,n;const o=Le.rawWindow.location,s=St(o.search,o.hash),r=(null===(t=s.hashQuery)||void 0===t?void 0:t[e])||(null===(n=s.searchQuery)||void 0===n?void 0:n[e]);return d(r)?yt(r):null}function Rt(e,t){let{pathname:n,search:o,hash:s}=Le.rawWindow.location;const r=St(o,s),i=bt(t.pathname+t.search+t.hash);let a=!1;if(s&&!o){a=!0,r.hashQuery?r.hashQuery[e]=i:r.hashQuery={[e]:i};const t=s.includes("?")?s.slice(0,s.indexOf("?")+1):s+"?";s=t+q(r.hashQuery)}else r.searchQuery?r.searchQuery[e]=i:r.searchQuery={[e]:i},o="?"+q(r.searchQuery);return{fullPath:n+o+s,isAttach2Hash:a}}function St(e,t){const n={};return""!==e&&"?"!==e&&(n.searchQuery=V(e.slice(1))),t.includes("?")&&(n.hashQuery=V(t.slice(t.indexOf("?")+1))),n}function Pt(e){const t=Le.rawWindow,n=t=>{if(on(!0).includes(e)&&!t.onlyForBrowser){const t=Et(e),n=Jt.get(e).sandBox.proxyWindow;let o=!1;const s=n.location.href;if(t){const s=n.location.hash;$t(e,t,n.location),o=n.location.hash!==s}!function(e,t){const n=new PopStateEvent(ct("popstate",e),{state:ft(e)});Le.rawWindow.dispatchEvent(n),f(t.onpopstate)&&t.onpopstate(n)}(e,n),o&&function(e,t,n){const o=new HashChangeEvent(ct("hashchange",e),{newURL:t.location.href,oldURL:n});Le.rawWindow.dispatchEvent(o),f(t.onhashchange)&&t.onhashchange(o)}(e,n,s),k()}};return t.addEventListener("popstate",n),()=>{t.removeEventListener("popstate",n)}}function Mt(e,t){k(),function(e){const t=new PopStateEvent("popstate",{state:null});e&&(t.onlyForBrowser=!0),Le.rawWindow.dispatchEvent(t)}(e),t&&function(e){const t=new HashChangeEvent("hashchange",{newURL:Le.rawWindow.location.href,oldURL:e});Le.rawWindow.dispatchEvent(t)}(t)}function Nt(e,t){const n=Le.rawWindow.history;function o(n){return function(...o){if(d(o[2])||y(o[2])){const s=S(o[2],t.href);if(s.origin===t.origin){Ot(n,Rt(e,s),!0,mt(e,o[0]),o[1]);const r=s.pathname+s.search+s.hash;return void(r!==t.fullPath&&$t(e,r,t))}}Ct(n,o[2],o[0],o[1])}}const s=o("pushState"),r=o("replaceState");return new Proxy(n,{get(t,n){if("state"===n)return ft(e);if("pushState"===n)return s;if("replaceState"===n)return r;const o=Reflect.get(t,n);return f(o)?it(t,o,"HISTORY"):o},set:(e,t,n)=>(Reflect.set(e,t,n),!0)})}function Ct(e,t,n=null,o=""){("pushState"===e?Le.rawPushState:Le.rawReplaceState).call(Le.rawWindow.history,n,o,t)}function Ot(e,t,n,o,s){const r=Le.rawWindow.location,i=r.pathname+r.search+r.hash,a=t.isAttach2Hash&&i!==t.fullPath?r.href:null;Ct(e,t.fullPath,o,s),i!==t.fullPath&&Mt(n,a)}function Dt(e,t){Ot("replaceState",e,!0,t)}function xt(e){const t=Le.rawWindow;return function(...n){var o;if((null===(o=t.history.state)||void 0===o?void 0:o.microAppState)&&(!_(n[0])||!n[0].microAppState)&&(d(n[2])||y(n[2]))){const e=t.location.href;S(n[2],e).href===e&&(n[0]=a({},n[0],{microAppState:t.history.state.microAppState}))}e.apply(t.history,n),on(!0).forEach((e=>{const t=Jt.get(e);t.sandBox&&t.useMemoryRouter&&!Et(e)&&Dt(Rt(e,t.sandBox.proxyWindow.location),mt(e,ft(e)))})),k()}}const{router:It,executeNavigationGuard:Lt,clearRouterWhenUnmount:Ut}=function(){function e(e,t,n,o){Ot(t,Rt(e,n),!1,mt(e,null!=o?o:null)),k()}function t(t){return function(n){const o=N(n.name);if(o&&d(n.path)){const s=Jt.get(o);if(s&&(!s.sandBox||!s.useMemoryRouter))return v(`navigation failed, memory router of app ${o} is closed`);if(on().includes(o)){const r=s.sandBox.proxyWindow.location,i=S(n.path,r.href),a=i.pathname+i.search+i.hash;if(r.fullPath!==a||Et(o)!==a){e(o,t&&!1!==n.replace||!0===n.replace?"replaceState":"pushState",i,n.state)}}else{const t=Le.rawWindow.location,s=S(n.path,t.origin),r=s.pathname+s.search+s.hash;Et(o)!==r&&e(o,!1===n.replace?"pushState":"replaceState",s,n.state)}}else v("navigation failed, name & path are required when use router."+(t?"replace":"push"))}}function n(e){return function(...t){return Le.rawWindow.history[e](...t)}}const o=Q(),s=Q();function i(e,t,n,o){k();for(const s of o)f(s)?s(t,n,e):_(s)&&f(s[e])&&s[e](t,n)}function a(e){const t=Jt.get(e);t.sandBox&&t.useMemoryRouter&&Dt(Rt(e,t.sandBox.proxyWindow.location),mt(e,ft(e)))}const c=Object.assign(Object.assign({current:new Map,encode:bt,decode:yt,push:t(!1),replace:t(!0),go:n("go"),back:n("back"),forward:n("forward"),beforeEach:o.add,afterEach:s.add,attachToURL:function(e){(e=N(e))&&on().includes(e)&&a(e)},attachAllToURL:function(e=!1){on(!e).forEach((e=>a(e)))}},function(){const e=function(){const e=new Map;return{add:function(t,n){return e.set(t,n),()=>!!e.has(t)&&e.delete(t)},get:t=>e.get(t),delete:t=>!!e.has(t)&&e.delete(t)}}();return{setDefaultPage:function(t){const n=N(t.name);return n&&t.path?e.add(n,t.path):("production"!==process.env.NODE_ENV&&E(n?"setDefaultPage: path is required":`setDefaultPage: invalid appName "${n}"`),r)},removeDefaultPage:function(t){return!!(t=N(t))&&e.delete(t)},getDefaultPage:e.get}}()),function(){let e=null;return{setBaseAppRouter:function(t){g(t)?e=new Proxy(t,{get(e,t){k();const n=Reflect.get(e,t);return f(n)?it(e,n,"BASEROUTER"):n},set:(e,t,n)=>(Reflect.set(e,t,n),!0)}):"production"!==process.env.NODE_ENV&&E("setBaseAppRouter: Invalid base router")},getBaseAppRouter:()=>e}}());return{router:c,executeNavigationGuard:function(e,t,n){c.current.set(e,t),i(e,t,n,o.list()),x((()=>{i(e,t,n,s.list())}))},clearRouterWhenUnmount:function(e){c.current.delete(e)}}}(),Tt=["href","pathname","search","hash"],Wt=[...Tt,"host","hostname","port","protocol","search"],kt=[...Wt,"origin","fullPath"];function Bt(e,t){const n=a({name:e},t);for(const e of kt)n[e]=t[e];return n}function $t(e,t,n,o){const s=S(t,n.href),r=Bt(e,n);for(const e of Wt)Tt.includes(e)?n.shadowLocation[e]=s[e]:n[e]=s[e];const i=Bt(e,n);("auto"===o||r.fullPath!==i.fullPath&&"prevent"!==o)&&Lt(e,i,r)}function Ft(e,t){const n=function(e,t){const n=Le.rawWindow.location,o=S(t),r={href:o.href,pathname:o.pathname,search:o.search,hash:o.hash},i=(t,s)=>{const i=S(t,o.href);if(i.origin===o.origin){const o=Rt(e,i);if(i.pathname===r.pathname&&i.search===r.search){let e=null;return i.hash!==r.hash&&(o.isAttach2Hash&&(e=n.href),Ct(s,o.fullPath)),void(i.hash?Mt(!1,e):n.reload())}if(o.isAttach2Hash)return Ct(s,o.fullPath),void n.reload();t=o.fullPath}return t};function c(e,t){return{enumerable:!0,configurable:!0,get:e,set:t}}function u(o,s){const i=S(o,t);i[s]===r[s]&&r.hash?Mt(!1):(Ct(i[s]===r[s]?"replaceState":"pushState",Rt(e,i).fullPath),n.reload())}l(o,{href:c((()=>r.href),(e=>{const t=i(e,"pushState");t&&(n.href=t)})),pathname:c((()=>r.pathname),(e=>{u(("/"+e).replace(/^\/+/,"/")+r.search+r.hash,"pathname")})),search:c((()=>r.search),(e=>{u(r.pathname+("?"+e).replace(/^\?+/,"?")+r.hash,"search")})),hash:c((()=>r.hash),(n=>{const o=r.pathname+r.search+("#"+n).replace(/^#+/,"#"),s=S(o,t);s.hash!==r.hash&&Ot("pushState",Rt(e,s),!1)})),fullPath:c((()=>r.pathname+r.search+r.hash),s)});const p=e=>function(t){const o=i(t,"assign"===e?"pushState":"replaceState");o&&n[e](o)};return a(o,{assign:p("assign"),replace:p("replace"),reload:e=>n.reload(e),shadowLocation:r})}(e,t);return{microLocation:n,microHistory:Nt(e,n)}}function Ht(e,t,n){n&&$t(e,n,t,"prevent"),Dt(Rt(e,t),mt(e,null)),function(e,t){Lt(e,Bt(e,t),Bt(e,t))}(e,t)}function Kt(e){Dt(function(e,t){var n,o,s,r;let{pathname:i,search:a,hash:c}=t||Le.rawWindow.location;const l=St(a,c);let u=!1;if(null===(n=l.hashQuery)||void 0===n?void 0:n[e]){u=!0,null===(o=l.hashQuery)||void 0===o||delete o[e];const t=q(l.hashQuery);c=c.slice(0,c.indexOf("?")+Number(Boolean(t)))+t}else if(null===(s=l.searchQuery)||void 0===s?void 0:s[e]){null===(r=l.searchQuery)||void 0===r||delete r[e];const t=q(l.searchQuery);a=t?"?"+t:""}return{fullPath:i+a+c,isAttach2Hash:u}}(e),function(e,t){return _(null==t?void 0:t.microAppState)&&(p(t.microAppState[e])||delete t.microAppState[e],Object.keys(t.microAppState).length||delete t.microAppState),a({},t)}(e,Le.rawWindow.history.state))}function jt(e,t){const n=p(t)?Le.rawWindow.fetch:t;return f(n)?function(t,o,...s){return(d(t)||y(t))&&(t=S(t,e).toString()),k(),n.call(Le.rawWindow,t,o,...s)}:n}function Gt(e,t){const n=p(t)?Le.rawWindow.XMLHttpRequest:t;return b(n)?class extends n{open(t,n,...o){(d(n)&&!/^f(ile|tp):\/\//.test(n)||y(n))&&(n=S(n,e).toString()),k(),super.open(t,n,...o)}}:n}const{createMicroEventSource:Vt,clearMicroEventSource:qt}=function(){let e;return{createMicroEventSource:function(t,n,o){const s=p(o)?Le.rawWindow.EventSource:o;return b(s)?class extends s{constructor(o,s,...r){if((d(o)||y(o))&&(o=S(o,n).toString()),k(),super(o,s,...r),e){const n=e.get(t);n?n.add(this):e.set(t,new Set([this]))}else e=new Map([[t,new Set([this])]])}close(){var n;super.close(),null===(n=e.get(t))||void 0===n||n.delete(this)}}:s},clearMicroEventSource:function(t){const n=null==e?void 0:e.get(t);(null==n?void 0:n.size)&&(n.forEach((e=>{e.close()})),n.clear())}}}(),Qt=["window","self","globalThis"];class zt{constructor(e,t){this.scopeProperties=[],this.escapeProperties=[],this.injectedKeys=new Set,this.escapeKeys=new Set,this.active=!1,this.microAppWindow={},this.adapter=new ye,this.getSpecialProperties(e),this.proxyWindow=this.createProxyWindow(e),a(this,dt(e,this.microAppWindow)),this.initStaticGlobalKeys(this.microAppWindow,e,t)}start({umdMode:e,baseroute:t,useMemoryRouter:n,defaultPage:o,disablePatchRequest:s}){this.active||(this.active=!0,n?(p(this.microAppWindow.location)&&this.setMicroAppRouter(this.microAppWindow,this.microAppWindow.__MICRO_APP_NAME__,this.microAppWindow.__MICRO_APP_URL__),this.initRouteState(o),this.removeHistoryListener=Pt(this.microAppWindow.__MICRO_APP_NAME__)):this.microAppWindow.__MICRO_APP_BASE_ROUTE__=this.microAppWindow.__MICRO_APP_BASE_URL__=t,e||this.initGlobalKeysWhenStart(this.microAppWindow,this.microAppWindow.__MICRO_APP_NAME__,this.microAppWindow.__MICRO_APP_URL__,s),1==++zt.activeCount&&(ht(),Ce(),window.__MICRO_APP_ENVIRONMENT__&&(rt(),window.addEventListener("unmount",st,!1)),function(){const e=Le.rawWindow;e.history.pushState=xt(Le.rawPushState),e.history.replaceState=xt(Le.rawReplaceState)}()),Le.rawWindow._babelPolyfill&&(Le.rawWindow._babelPolyfill=!1))}stop({umdMode:e,keepRouteState:t,clearEventSource:n}){this.active&&(this.releaseEffect(),this.microAppWindow.microApp.clearDataListener(),this.microAppWindow.microApp.clearGlobalDataListener(),this.removeHistoryListener&&(this.clearRouteState(t),this.removeHistoryListener()),n&&qt(this.microAppWindow.__MICRO_APP_NAME__),e||(this.injectedKeys.forEach((e=>{Reflect.deleteProperty(this.microAppWindow,e)})),this.injectedKeys.clear(),this.escapeKeys.forEach((e=>{Reflect.deleteProperty(Le.rawWindow,e)})),this.escapeKeys.clear()),0==--zt.activeCount&&(document.addEventListener=Le.rawDocumentAddEventListener,document.removeEventListener=Le.rawDocumentRemoveEventListener,xe(),function(){const e=Le.rawWindow;e.history.pushState=Le.rawPushState,e.history.replaceState=Le.rawReplaceState}()),this.active=!1)}recordUmdSnapshot(){this.recordUmdEffect(),function(e){const t=e.appName;e.umdDataListeners={global:new Set,normal:new Set};const n=Je.eventList.get("global");if(n)for(const o of n.callbacks)t===o.__APP_NAME__&&e.umdDataListeners.global.add(o);const o=Je.eventList.get(Ze(t,!0));o&&(e.umdDataListeners.normal=new Set(o.callbacks))}(this.microAppWindow.microApp)}rebuildUmdSnapshot(){this.rebuildUmdEffect(),function(e){for(const t of e.umdDataListeners.global)e.addGlobalDataListener(t,t.__AUTO_TRIGGER__);for(const t of e.umdDataListeners.normal)e.addDataListener(t,t.__AUTO_TRIGGER__)}(this.microAppWindow.microApp)}getSpecialProperties(e){var t;this.scopeProperties=this.scopeProperties.concat(this.adapter.staticScopeProperties),_(an.options.plugins)&&(this.commonActionForSpecialProperties(an.options.plugins.global),this.commonActionForSpecialProperties(null===(t=an.options.plugins.modules)||void 0===t?void 0:t[e]))}commonActionForSpecialProperties(e){if(i(e))for(const t of e)_(t)&&(i(t.scopeProperties)&&(this.scopeProperties=this.scopeProperties.concat(t.scopeProperties)),i(t.escapeProperties)&&(this.escapeProperties=this.escapeProperties.concat(t.escapeProperties)))}createProxyWindow(e){const t=Le.rawWindow,n=new Map;return new Proxy(this.microAppWindow,{get:(n,o)=>{if(T(e),Reflect.has(n,o)||d(o)&&/^__MICRO_APP_/.test(o)||this.scopeProperties.includes(o))return Reflect.get(n,o);const s=Reflect.get(t,o);return f(s)?it(t,s):s},set:(e,n,o)=>{if(this.active){if(this.adapter.escapeSetterKeyList.includes(n))Reflect.set(t,n,o);else if(u.call(e,n)||!u.call(t,n)||this.scopeProperties.includes(n))Reflect.set(e,n,o),this.injectedKeys.add(n);else{const s=Object.getOwnPropertyDescriptor(t,n),{configurable:r,enumerable:i,writable:a,set:l}=s;c(e,n,{value:o,configurable:r,enumerable:i,writable:null!=a?a:!!l}),this.injectedKeys.add(n)}(this.escapeProperties.includes(n)||this.adapter.staticEscapeProperties.includes(n)&&!Reflect.has(t,n))&&!this.scopeProperties.includes(n)&&(Reflect.set(t,n,o),this.escapeKeys.add(n))}return!0},has:(e,n)=>this.scopeProperties.includes(n)?n in e:n in e||n in t,getOwnPropertyDescriptor:(e,o)=>{if(u.call(e,o))return n.set(o,"target"),Object.getOwnPropertyDescriptor(e,o);if(u.call(t,o)){n.set(o,"rawWindow");const e=Object.getOwnPropertyDescriptor(t,o);return e&&!e.configurable&&(e.configurable=!0),e}},defineProperty:(e,o,s)=>"rawWindow"===n.get(o)?Reflect.defineProperty(t,o,s):Reflect.defineProperty(e,o,s),ownKeys:e=>Reflect.ownKeys(t).concat(Reflect.ownKeys(e)).filter((function(e){return!(e in this)&&(this[e]=!0)}),Object.create(null)),deleteProperty:(e,n)=>!u.call(e,n)||(this.injectedKeys.has(n)&&this.injectedKeys.delete(n),this.escapeKeys.has(n)&&Reflect.deleteProperty(t,n),Reflect.deleteProperty(e,n))})}initStaticGlobalKeys(e,t,n){e.__MICRO_APP_ENVIRONMENT__=!0,e.__MICRO_APP_NAME__=t,e.__MICRO_APP_URL__=n,e.__MICRO_APP_PUBLIC_PATH__=C(n),e.__MICRO_APP_WINDOW__=e,e.rawWindow=Le.rawWindow,e.rawDocument=Le.rawDocument,e.microApp=a(new nt(t),{removeDomScope:k,pureCreateElement:B,router:It}),this.setProxyDocument(e,t),this.setMappingPropertiesWithRawDescriptor(e)}setProxyDocument(e,t){const{proxyDocument:n,MicroDocument:o}=this.createProxyDocument(t);l(e,{document:{configurable:!1,enumerable:!0,get:()=>(T(t),n)},Document:{configurable:!1,enumerable:!1,get:()=>(T(t),o)}})}setMappingPropertiesWithRawDescriptor(e){let t,n;const o=Le.rawWindow;o===o.parent?t=n=this.proxyWindow:(t=o.top,n=o.parent),c(e,"top",this.createDescriptorForMicroAppWindow("top",t)),c(e,"parent",this.createDescriptorForMicroAppWindow("parent",n)),Qt.forEach((t=>{c(e,t,this.createDescriptorForMicroAppWindow(t,this.proxyWindow))}))}createDescriptorForMicroAppWindow(e,t){const{configurable:n=!0,enumerable:o=!0,writable:s,set:r}=Object.getOwnPropertyDescriptor(Le.rawWindow,e)||{writable:!0};return{value:t,configurable:n,enumerable:o,writable:null!=s?s:!!r}}initGlobalKeysWhenStart(e,t,n,o){e.hasOwnProperty=t=>u.call(e,t)||u.call(Le.rawWindow,t),this.setHijackProperty(e,t),o||this.patchRequestApi(e,t,n)}setHijackProperty(e,t){let n,o;l(e,{eval:{configurable:!0,enumerable:!1,get:()=>(T(t),n||eval),set:e=>{n=e}},Image:{configurable:!0,enumerable:!1,get:()=>(T(t),o||Le.ImageProxy),set:e=>{o=e}}})}patchRequestApi(e,t,n){let o=jt(n),s=Gt(n),r=Vt(t,n);l(e,{fetch:{configurable:!0,enumerable:!0,get:()=>o,set(e){o=jt(n,e)}},XMLHttpRequest:{configurable:!0,enumerable:!0,get:()=>s,set(e){s=Gt(n,e)}},EventSource:{configurable:!0,enumerable:!0,get:()=>r,set(e){r=Vt(t,n,e)}}})}setMicroAppRouter(e,t,n){const{microLocation:o,microHistory:s}=Ft(t,n);l(e,{location:{configurable:!1,enumerable:!0,get:()=>o,set:e=>{Le.rawWindow.location=e}},history:{configurable:!0,enumerable:!0,get:()=>s}})}initRouteState(e){!function(e,t,n){const o=Et(e);o?$t(e,o,t,"auto"):Ht(e,t,n)}(this.proxyWindow.__MICRO_APP_NAME__,this.proxyWindow.location,e)}clearRouteState(e){!function(e,t,n,o){if(!o){const{pathname:o,search:s,hash:r}=S(t);$t(e,o+s+r,n,"prevent")}Kt(e),Ut(e)}(this.proxyWindow.__MICRO_APP_NAME__,this.proxyWindow.__MICRO_APP_URL__,this.proxyWindow.location,e)}setRouteInfoForKeepAliveApp(){Ht(this.proxyWindow.__MICRO_APP_NAME__,this.proxyWindow.location)}removeRouteInfoForKeepAliveApp(){Kt(this.proxyWindow.__MICRO_APP_NAME__)}createProxyDocument(e){const t=Le.rawDocument,n=Le.rawRootDocument,o=function(n,o){const s=Le.rawCreateElement.call(t,n,o);return s.__MICRO_APP_NAME__=e,s},s=new Proxy(t,{get:(n,r)=>{if(T(e),function(e){const t=Le.rawDocument.firstElementChild;t&&t.parentNode!==e&&(ve(t,e),R((()=>{ve(t,Le.rawDocument)})))}(s),"createElement"===r)return o;if(r===Symbol.toStringTag)return"ProxyDocument";if("defaultView"===r)return this.proxyWindow;const i=Reflect.get(n,r);return f(i)?it(t,i,"DOCUMENT"):i},set:(e,t,n)=>(Reflect.set(e,t,n),!0)});class r{static[Symbol.hasInstance](e){let t=e;for(;t=Object.getPrototypeOf(t);)if(t===r.prototype)return!0;return e===s||e instanceof n}}return Object.setPrototypeOf(r,n),Object.setPrototypeOf(r.prototype,new Proxy(n.prototype,{get(n,o){T(e);const s=Reflect.get(n,o);return f(s)?it(t,s,"DOCUMENT"):s},set:(e,t,n)=>(Reflect.set(e,t,n),!0)})),{proxyDocument:s,MicroDocument:r}}}function Yt(e,t,n,o){var s;if(!e)return v(`element does not exist in lifecycle ${n}`,t);e=K(e),k();const r=a({name:t,container:e},o&&{error:o}),i=new CustomEvent(n,{detail:r});!function(e,t){Object.defineProperties(e,{currentTarget:{get:()=>t},target:{get:()=>t}})}(i,e),f(null===(s=an.options.lifeCycles)||void 0===s?void 0:s[n])&&an.options.lifeCycles[n](i),e.dispatchEvent(i)}function Xt(e,t,n={}){const o=new CustomEvent(ct(e,t),{detail:n});window.dispatchEvent(o)}zt.activeCount=0;const Jt=new Map;class Zt{constructor({name:e,url:t,container:n,scopecss:o,useSandbox:s,inline:r,esmodule:i,ssrUrl:a,isPrefetch:c}){this.state=ee.CREATED,this.keepAliveState=null,this.keepAliveContainer=null,this.loadSourceLevel=0,this.umdHookMount=null,this.umdHookUnmount=null,this.libraryName=null,this.umdMode=!1,this.sandBox=null,this.keepRouteState=!1,this.fiber=!1,this.useMemoryRouter=!0,this.name=e,this.url=t,this.useSandbox=s,this.scopecss=this.useSandbox&&o,this.inline=null!=r&&r,this.esmodule=null!=i&&i,this.container=null!=n?n:null,this.ssrUrl=null!=a?a:"",this.isPrefetch=null!=c&&c,Jt.set(this.name,this),this.source={html:null,links:new Set,scripts:new Set},this.loadSourceCode(),this.useSandbox&&(this.sandBox=new zt(e,t))}loadSourceCode(){this.state=ee.LOADING,re.getInstance().run(this,Xe)}onLoad(e){2==++this.loadSourceLevel&&(this.source.html=e,this.state=ee.LOADED,this.isPrefetch||ee.UNMOUNT===this.state||K(this.container).mount(this))}onLoadError(e){this.loadSourceLevel=-1,ee.UNMOUNT!==this.state&&(this.onerror(e),this.state=ee.LOAD_FAILED)}mount({container:e,inline:t,esmodule:n,useMemoryRouter:o,baseroute:s,keepRouteState:r,defaultPage:i,disablePatchRequest:a,fiber:c}){var l,u;if(this.container=e,this.inline=t,this.esmodule=n,this.keepRouteState=r,this.fiber=c,this.useMemoryRouter=o,2!==this.loadSourceLevel)return void(this.state=ee.LOADING);let h;if(Yt(this.container,this.name,te.BEFOREMOUNT),this.state=ee.MOUNTING,$(this.source.html,this.container,!this.umdMode),null===(l=this.sandBox)||void 0===l||l.start({umdMode:this.umdMode,baseroute:s,useMemoryRouter:o,defaultPage:i,disablePatchRequest:a}),this.umdMode){null===(u=this.sandBox)||void 0===u||u.rebuildUmdSnapshot();try{h=this.umdHookMount()}catch(e){v("an error occurred in the mount function \n",this.name,e)}this.handleMounted(h)}else{let e=!1;!function(e,t){const n=e.fiber?[]:null,o=Array.from(e.source.scripts),s=[],r=[];for(const i of o){const o=ge.script.getInfo(i),a=o.appSpace[e.name];a.defer||a.async?(o.isExternal&&!o.code?s.push(se(i,e.name)):s.push(o.code),r.push([i,o]),We(e,o)&&(t.moduleCount=t.moduleCount?++t.moduleCount:1)):Y(n,(()=>{qe(i,e,o),t(!1)}))}s.length?D(s,(e=>{const t=r[e.index][1];t.code=t.code||e.data}),(n=>{t.errorCount=t.errorCount?++t.errorCount:1,v(n,e.name)}),(()=>{r.forEach((([o,s])=>{s.code&&Y(n,(()=>{qe(o,e,s,t),!We(e,s)&&t(!1)}))})),n?(n.push((()=>Promise.resolve(t(p(t.moduleCount)||t.errorCount===s.length)))),X(n)):t(p(t.moduleCount)||t.errorCount===s.length)})):n?(n.push((()=>Promise.resolve(t(!0)))),X(n)):t(!0)}(this,(t=>{if(!this.umdMode){const{mount:e,unmount:t}=this.getUmdLibraryHooks();if(this.umdHookUnmount=t,f(e)&&f(t)){this.umdHookMount=e,this.umdMode=!0,this.sandBox&&(this.sandBox.proxyWindow.__MICRO_APP_UMD_MODE__=!0);try{h=this.umdHookMount()}catch(e){v("an error occurred in the mount function \n",this.name,e)}}}e||!0!==t&&!this.umdMode||(e=!0,this.handleMounted(h))}))}}handleMounted(e){w(e)?e.then((()=>this.dispatchMountedEvent())).catch((e=>this.onerror(e))):this.dispatchMountedEvent()}dispatchMountedEvent(){ee.UNMOUNT!==this.state&&(this.state=ee.MOUNTED,Yt(this.container,this.name,te.MOUNTED))}unmount(e,t){let n;if(this.state===ee.LOAD_FAILED&&(e=!0),this.state=ee.UNMOUNT,this.keepAliveState=null,this.keepAliveContainer=null,f(this.umdHookUnmount))try{n=this.umdHookUnmount()}catch(e){v("an error occurred in the unmount function \n",this.name,e)}Xt("unmount",this.name),this.handleUnmounted(e,n,t)}handleUnmounted(e,t,n){w(t)?t.then((()=>this.actionsForUnmount(e,n))).catch((()=>this.actionsForUnmount(e,n))):this.actionsForUnmount(e,n)}actionsForUnmount(e,t){var n,o;e?this.actionsForCompletelyDestroy():this.umdMode&&this.container.childElementCount&&$(this.container,this.source.html,!1),this.umdMode&&(null===(n=this.sandBox)||void 0===n||n.recordUmdSnapshot()),null===(o=this.sandBox)||void 0===o||o.stop({umdMode:this.umdMode,keepRouteState:this.keepRouteState&&!e,clearEventSource:!this.umdMode||e}),on().length||(De=!1,Element.prototype.setAttribute=Le.rawSetAttribute),Yt(this.container,this.name,te.UNMOUNT),this.container.innerHTML="",this.container=null,t&&t()}actionsForCompletelyDestroy(){!this.useSandbox&&this.umdMode&&delete window[this.libraryName],Jt.delete(this.name)}hiddenKeepAliveApp(){var e;const t=this.container;$(this.container,this.keepAliveContainer?this.keepAliveContainer:this.keepAliveContainer=document.createElement("div"),!1),this.container=this.keepAliveContainer,this.keepAliveState=ne.KEEP_ALIVE_HIDDEN,Xt("appstate-change",this.name,{appState:"afterhidden"}),Yt(t,this.name,te.AFTERHIDDEN),null===(e=this.sandBox)||void 0===e||e.removeRouteInfoForKeepAliveApp()}showKeepAliveApp(e){var t;Xt("appstate-change",this.name,{appState:"beforeshow"}),Yt(e,this.name,te.BEFORESHOW),$(this.container,e,!1),this.container=e,this.keepAliveState=ne.KEEP_ALIVE_SHOW,null===(t=this.sandBox)||void 0===t||t.setRouteInfoForKeepAliveApp(),Xt("appstate-change",this.name,{appState:"aftershow"}),Yt(this.container,this.name,te.AFTERSHOW)}onerror(e){Yt(this.container,this.name,te.ERROR,e)}getAppState(){return this.state}getKeepAliveState(){return this.keepAliveState}getUmdLibraryHooks(){var e,t,n,o;if(ee.UNMOUNT!==this.state){const s=null!==(t=null===(e=this.sandBox)||void 0===e?void 0:e.proxyWindow)&&void 0!==t?t:Le.rawWindow;return this.libraryName=K(this.container).getAttribute("library")||`micro-app-${this.name}`,g(s[this.libraryName])?s[this.libraryName]:{mount:null===(n=this.sandBox)||void 0===n?void 0:n.proxyWindow.mount,unmount:null===(o=this.sandBox)||void 0===o?void 0:o.proxyWindow.unmount}}return{}}}function en(e){class n extends HTMLElement{constructor(){super(),this.isWaiting=!1,this.cacheData=null,this.connectedCount=0,this.connectStateMap=new Map,this.appName="",this.appUrl="",this.ssrUrl="",this.version=t,this.handleAttributeUpdate=()=>{if(this.isWaiting=!1,!this.connectStateMap.get(this.connectedCount))return;const e=N(this.getAttribute("name")),t=M(this.getAttribute("url"),this.appName);if(this.legalAttribute("name",e)&&this.legalAttribute("url",t)){const n=Jt.get(e);if(e!==this.appName&&n&&ee.UNMOUNT!==n.getAppState()&&ne.KEEP_ALIVE_HIDDEN!==n.getKeepAliveState()&&!n.isPrefetch)return this.setAttribute("name",this.appName),v(`app name conflict, an app named ${e} is running`,this.appName);e===this.appName&&t===this.appUrl||(e===this.appName?this.handleUnmount(!0,(()=>{this.actionsForAttributeChange(e,t,n)})):this.getKeepAliveModeResult()?(this.handleHiddenKeepAliveApp(),this.actionsForAttributeChange(e,t,n)):this.handleUnmount(this.getDestroyCompatibleResult(),(()=>{this.actionsForAttributeChange(e,t,n)})))}else e!==this.appName&&this.setAttribute("name",this.appName)},De||(De=!0,Element.prototype.setAttribute=function(e,t){if(/^micro-app(-\S+)?/i.test(this.tagName)&&"data"===e)if(_(t)){const e={};Object.getOwnPropertyNames(t).forEach((n=>{d(n)&&0===n.indexOf("__")||(e[n]=t[n])})),this.data=e}else"[object Object]"!==t&&E("property data must be an object",this.getAttribute("name"));else{const n=this.__MICRO_APP_NAME__||W();if(n&&Jt.has(n)&&(("src"===e||"srcset"===e)&&/^(img|script)$/i.test(this.tagName)||"href"===e&&/^link$/i.test(this.tagName))){const e=Jt.get(n);t=O(t,e.url)}Le.rawSetAttribute.call(this,e,t)}})}static get observedAttributes(){return["name","url"]}connectedCallback(){const e=++this.connectedCount;this.connectStateMap.set(e,!0),R((()=>{this.connectStateMap.get(e)&&(Yt(this,this.appName,te.CREATED),this.initialMount())}))}disconnectedCallback(){this.connectStateMap.set(this.connectedCount,!1);const e=Jt.get(this.appName);e&&e.getAppState()!==ee.UNMOUNT&&e.getKeepAliveState()!==ne.KEEP_ALIVE_HIDDEN&&(this.getKeepAliveModeResult()?this.handleHiddenKeepAliveApp():this.handleUnmount(this.getDestroyCompatibleResult()))}attributeChangedCallback(e,t,n){if(this.legalAttribute(e,n)&&this[e===Z.NAME?"appName":"appUrl"]!==n)if(e!==Z.URL||this.appUrl)if(e!==Z.NAME||this.appName)this.isWaiting||(this.isWaiting=!0,R(this.handleAttributeUpdate));else{const e=N(n);if(!e)return v(`Invalid attribute name ${n}`,this.appName);this.cacheData&&(an.setData(e,this.cacheData),this.cacheData=null),this.appName=e,e!==n&&this.setAttribute("name",this.appName),this.handleInitialNameAndUrl()}else{if(!(n=M(n,this.appName)))return v(`Invalid attribute url ${n}`,this.appName);this.appUrl=n,this.handleInitialNameAndUrl()}}handleInitialNameAndUrl(){this.connectStateMap.get(this.connectedCount)&&this.initialMount()}initialMount(){if(this.appName&&this.appUrl)if(this.getDisposeResult("shadowDOM")&&!this.shadowRoot&&f(this.attachShadow)&&this.attachShadow({mode:"open"}),this.updateSsrUrl(this.appUrl),Jt.has(this.appName)){const e=Jt.get(this.appName),t=e.ssrUrl||e.url,n=this.ssrUrl||this.appUrl;e.getKeepAliveState()===ne.KEEP_ALIVE_HIDDEN&&e.url===this.appUrl?this.handleShowKeepAliveApp(e):t===n&&(e.getAppState()===ee.UNMOUNT||e.isPrefetch&&e.scopecss===this.isScopecss()&&e.useSandbox===this.isSandbox())?this.handleAppMount(e):e.isPrefetch||e.getAppState()===ee.UNMOUNT?("production"!==process.env.NODE_ENV&&e.scopecss===this.isScopecss()&&e.useSandbox===this.isSandbox()&&E(`the ${e.isPrefetch?"prefetch":"unmounted"} app with url: ${t} replaced by a new app with url: ${n}`,this.appName),this.handleCreateApp()):v(`app name conflict, an app named: ${this.appName} with url: ${t} is running`,this.appName)}else this.handleCreateApp()}actionsForAttributeChange(e,t,n){var o;this.updateSsrUrl(t),this.appName=e,this.appUrl=t,(null!==(o=this.shadowRoot)&&void 0!==o?o:this).innerHTML="",e!==this.getAttribute("name")&&this.setAttribute("name",this.appName),n?n.getKeepAliveState()===ne.KEEP_ALIVE_HIDDEN?n.url===this.appUrl?this.handleShowKeepAliveApp(n):v(`app name conflict, an app named ${this.appName} is running`,this.appName):n.url===this.appUrl&&n.ssrUrl===this.ssrUrl?this.handleAppMount(n):this.handleCreateApp():this.handleCreateApp()}legalAttribute(e,t){return!(!d(t)||!t)||(v(`unexpected attribute ${e}, please check again`,this.appName),!1)}handleAppMount(e){e.isPrefetch=!1,R((()=>this.mount(e)))}mount(e){var t;e.mount({container:null!==(t=this.shadowRoot)&&void 0!==t?t:this,inline:this.getDisposeResult("inline"),esmodule:this.getDisposeResult("esmodule"),useMemoryRouter:!this.getDisposeResult("disable-memory-router"),baseroute:this.getBaseRouteCompatible(),keepRouteState:this.getDisposeResult("keep-router-state"),defaultPage:this.getDefaultPageValue(),hiddenRouter:this.getDisposeResult("hidden-router"),disablePatchRequest:this.getDisposeResult("disable-patch-request"),fiber:this.getDisposeResult("fiber")})}handleCreateApp(){var e;Jt.has(this.appName)&&Jt.get(this.appName).actionsForCompletelyDestroy(),new Zt({name:this.appName,url:this.appUrl,scopecss:this.isScopecss(),useSandbox:this.isSandbox(),inline:this.getDisposeResult("inline"),esmodule:this.getDisposeResult("esmodule"),container:null!==(e=this.shadowRoot)&&void 0!==e?e:this,ssrUrl:this.ssrUrl})}handleUnmount(e,t){const n=Jt.get(this.appName);n&&n.getAppState()!==ee.UNMOUNT&&n.unmount(e,t)}handleHiddenKeepAliveApp(){const e=Jt.get(this.appName);e&&e.getAppState()!==ee.UNMOUNT&&e.getKeepAliveState()!==ne.KEEP_ALIVE_HIDDEN&&e.hiddenKeepAliveApp()}handleShowKeepAliveApp(e){R((()=>{var t;return e.showKeepAliveApp(null!==(t=this.shadowRoot)&&void 0!==t?t:this)}))}getDisposeResult(e){return(this.compatibleSpecialProperties(e)||!!an.options[e])&&this.compatibleDisableSpecialProperties(e)}compatibleSpecialProperties(e){return"disable-scopecss"===e?this.hasAttribute("disable-scopecss")||this.hasAttribute("disableScopecss"):"disable-sandbox"===e?this.hasAttribute("disable-sandbox")||this.hasAttribute("disableSandbox"):this.hasAttribute(e)}compatibleDisableSpecialProperties(e){return"disable-scopecss"===e?"false"!==this.getAttribute("disable-scopecss")&&"false"!==this.getAttribute("disableScopecss"):"disable-sandbox"===e?"false"!==this.getAttribute("disable-sandbox")&&"false"!==this.getAttribute("disableSandbox"):"false"!==this.getAttribute(e)}isScopecss(){return!(this.getDisposeResult("disable-scopecss")||this.getDisposeResult("shadowDOM"))}isSandbox(){return!this.getDisposeResult("disable-sandbox")}getBaseRouteCompatible(){var e,t;return null!==(t=null!==(e=this.getAttribute("baseroute"))&&void 0!==e?e:this.getAttribute("baseurl"))&&void 0!==t?t:""}getDestroyCompatibleResult(){return this.getDisposeResult("destroy")||this.getDisposeResult("destory")}getKeepAliveModeResult(){return this.getDisposeResult("keep-alive")&&!this.getDestroyCompatibleResult()}updateSsrUrl(e){if(this.getDisposeResult("ssr"))if(this.getDisposeResult("disable-memory-router")||this.getDisposeResult("disableSandbox")){const t=Le.rawWindow.location;this.ssrUrl=O(t.pathname+t.search,e)}else{let t=function(e,t){const n=Et(e);if(!n)return"";const o=S(n,t);return o.origin+o.pathname+o.search}(this.appName,e);const n=this.getDefaultPageValue();if(!t&&n){const o=S(n,e);t=o.origin+o.pathname+o.search}this.ssrUrl=t}else this.ssrUrl&&(this.ssrUrl="")}getDefaultPageValue(){return It.getDefaultPage(this.appName)||this.getAttribute("default-page")||this.getAttribute("defaultPage")||""}set data(e){this.appName?an.setData(this.appName,e):this.cacheData=e}get data(){return this.appName?an.getData(this.appName,!0):this.cacheData?this.cacheData:null}}window.customElements.define(e,n)}function tn(e){if(!n)return v("preFetch is only supported in browser environment");x((()=>{f(e)&&(e=e()),i(e)&&e.reduce(((e,t)=>e.then((()=>{return e=t,I((t=>{var n,o,s,r,i,a;if(_(e)&&navigator.onLine)if(e.name=N(e.name),e.url=M(e.url,e.name),e.name&&e.url&&!Jt.has(e.name)){const c=new Zt({name:e.name,url:e.url,scopecss:!(null!==(o=null!==(n=e["disable-scopecss"])&&void 0!==n?n:e.disableScopecss)&&void 0!==o?o:an.options["disable-scopecss"]),useSandbox:!(null!==(r=null!==(s=e["disable-sandbox"])&&void 0!==s?s:e.disableSandbox)&&void 0!==r?r:an.options["disable-sandbox"]),inline:null!==(i=e.inline)&&void 0!==i?i:an.options.inline,esmodule:null!==(a=e.esmodule)&&void 0!==a?a:an.options.esmodule,isPrefetch:!0}),l=c.onLoad,u=c.onLoadError;c.onLoad=e=>{t(),l.call(c,e)},c.onLoadError=e=>{t(),u.call(c,e)}}else t();else t()}));var e}))),Promise.resolve())}))}function nn(e,t,n){if(i(e)){const o=e.filter((e=>d(e)&&e.includes(`.${t}`)&&!n.hasInfo(e)));D(o.map((e=>se(e))),(e=>{const s=o[e.index];"js"===t?n.hasInfo(s)||n.setInfo(s,{code:e.data,isExternal:!1,appSpace:{}}):n.hasInfo(s)||n.setInfo(s,{code:e.data,appSpace:{}})}),(e=>{v(e)}))}}function on(e=!1){const t=[];return Jt.forEach(((n,o)=>{ee.UNMOUNT===n.getAppState()||n.isPrefetch||e&&ne.KEEP_ALIVE_HIDDEN===n.getKeepAliveState()||t.push(o)})),t}function sn(e,t){const n=Jt.get(N(e));return new Promise((o=>{if(n)if(n.getAppState()===ee.UNMOUNT||n.isPrefetch)(null==t?void 0:t.destroy)&&n.actionsForCompletelyDestroy(),o();else if(n.getKeepAliveState()===ne.KEEP_ALIVE_HIDDEN)(null==t?void 0:t.destroy)?n.unmount(!0,o):(null==t?void 0:t.clearAliveState)?n.unmount(!1,o):o();else{const e=K(n.container),s=()=>{e.removeEventListener("unmount",s),e.removeEventListener("afterhidden",r),o()},r=()=>{e.removeEventListener("unmount",s),e.removeEventListener("afterhidden",r),o()};if(e.addEventListener("unmount",s),e.addEventListener("afterhidden",r),null==t?void 0:t.destroy){let t,n;e.hasAttribute("destroy")&&(t=e.getAttribute("destroy")),e.hasAttribute("destory")&&(n=e.getAttribute("destory")),e.setAttribute("destroy","true"),e.parentNode.removeChild(e),e.removeAttribute("destroy"),"string"==typeof t&&e.setAttribute("destroy",t),"string"==typeof n&&e.setAttribute("destory",n)}else if((null==t?void 0:t.clearAliveState)&&e.hasAttribute("keep-alive")){const t=e.getAttribute("keep-alive");e.removeAttribute("keep-alive"),e.parentNode.removeChild(e),e.setAttribute("keep-alive",t)}else e.parentNode.removeChild(e)}else E(`app ${e} does not exist`),o()}))}class rn extends tt{constructor(){super(...arguments),this.tagName="micro-app",this.options={},this.preFetch=tn,this.router=It}start(e){var t,o,s;if(!n||!window.customElements)return v("micro-app is not supported in this environment");if(null==e?void 0:e.tagName){if(!/^micro-app(-\S+)?/.test(e.tagName))return v(`${e.tagName} is invalid tagName`);this.tagName=e.tagName}if(window.customElements.get(this.tagName))return E(`element ${this.tagName} is already defined`);if(Ue(),_(e)&&(this.options=e,e["disable-scopecss"]=null!==(t=e["disable-scopecss"])&&void 0!==t?t:e.disableScopecss,e["disable-sandbox"]=null!==(o=e["disable-sandbox"])&&void 0!==o?o:e.disableSandbox,e.preFetchApps&&tn(e.preFetchApps),e.globalAssets&&(_(s=e.globalAssets)&&x((()=>{nn(s.js,"js",ge.script),nn(s.css,"css",ge.link)}))),_(e.plugins))){const t=e.plugins.modules;if(_(t))for(const e in t){const n=N(e);n&&e!==n&&(t[n]=t[e],delete t[e])}}en(this.tagName)}}var an=new rn;e.EventCenterForMicroApp=nt,e.MicroApp=rn,e.default=an,e.getActiveApps=on,e.getAllApps=function(){return Array.from(Jt.keys())},e.preFetch=tn,e.pureCreateElement=B,e.removeDomScope=k,e.unmountAllApps=function(e){return Array.from(Jt.keys()).reduce(((t,n)=>t.then((()=>sn(n,e)))),Promise.resolve())},e.unmountApp=sn,e.version=t,Object.defineProperty(e,"__esModule",{value:!0})}));
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).microApp={})}(this,(function(e){"use strict";const t="1.0.0-alpha.7",n="undefined"!=typeof window,o="undefined"!=typeof global?global:"undefined"!=typeof window?window:"undefined"!=typeof self?self:Function("return this")(),s=()=>{},r=()=>!1,i=Array.isArray,a=Object.assign,c=Object.defineProperty,l=Object.defineProperties,u=Object.prototype.hasOwnProperty;function p(e){return void 0===e}function h(e){return null===e}function d(e){return"string"==typeof e}function m(e){return"boolean"==typeof e}function f(e){return"function"==typeof e}function _(e){return"[object Object]"===toString.call(e)}function g(e){return"object"==typeof e}function A(e){return"[object Promise]"===toString.call(e)}function w(e){return f(e)&&0===e.name.indexOf("bound ")&&!e.hasOwnProperty("prototype")}function b(e){var t;if(f(e)){const n=e.toString();return(null===(t=e.prototype)||void 0===t?void 0:t.constructor)===e&&Object.getOwnPropertyNames(e.prototype).length>1||/^function\s+[A-Z]/.test(n)||/^class\s+/.test(n)}return!1}function y(e){return e instanceof URL}function v(e){return e instanceof Element}function E(e){return e instanceof Node}function R(e,t=null,...n){const o=t&&d(t)?` app ${t}:`:"";d(e)?console.error(`[micro-app]${o} ${e}`,...n):console.error(`[micro-app]${o}`,e,...n)}function S(e,t=null,...n){const o=t&&d(t)?` app ${t}:`:"";d(e)?console.warn(`[micro-app]${o} ${e}`,...n):console.warn(`[micro-app]${o}`,e,...n)}function P(e,...t){Promise.resolve().then(e.bind(null,...t))}const N=function(){class e extends URL{}return(t,n)=>n?new e(""+t,n):new e(""+t)}();function C(e){return e.startsWith("//")?`${o.location.protocol}${e}`:e}function D(e,t=null){if(!d(e)||!e)return"";try{const{origin:t,pathname:n,search:o}=N(C(e));if(/\.(\w+)$/.test(n))return`${t}${n}${o}`;const s=`${t}${n}/`.replace(/\/\/$/,"/");return/^https?:\/\//.test(s)?`${s}${o}`:""}catch(e){return R(e,t),""}}function M(e){return d(e)&&e?e.replace(/(^\d+)|([^\w\d-_])/gi,""):""}function O(e){const{origin:t,pathname:n}=N(e);if(/\.(\w+)$/.test(n)){const e=`${t}${n}`.split("/");return e.pop(),e.join("/")+"/"}return`${t}${n}/`.replace(/\/\/$/,"/")}function L(e,t){return!e||/^((((ht|f)tps?)|file):)?\/\//.test(e)||/^(data|blob):/.test(e)?e:N(e,O(C(t))).toString()}function x(e,t,n,o){let s=0;function r(){++s===e.length&&o&&o()}e.forEach(((e,o)=>{A(e)?e.then((e=>{t({data:e,index:o}),r()})).catch((e=>{n({error:e,index:o}),r()})):(t({data:e,index:o}),r())}))}const I=o.requestIdleCallback||function(e){const t=Date.now();return setTimeout((function(){e({didTimeout:!1,timeRemaining:()=>Math.max(0,50-(Date.now()-t))})}),1)};function U(e){return new Promise((t=>{I((()=>{e(t)}))}))}let T=null;function W(e){T=e}function k(e){T!==e&&(W(e),P((()=>{W(null)})))}function B(){return T}function $(){W(null)}function F(e,t){const n=document.createElement(e,t);return n.__MICRO_APP_NAME__&&delete n.__MICRO_APP_NAME__,n.__PURE_ELEMENT__=!0,n}function H(e,t,n){if(t.innerHTML="",n){const n=e.cloneNode(!0),o=document.createDocumentFragment();Array.from(n.childNodes).forEach((e=>{o.appendChild(e)})),t.appendChild(o)}else Array.from(e.childNodes).forEach((e=>{t.appendChild(e)}))}function K(e){return!e||/(^\d)|([^\w\d-_\u4e00-\u9fa5])/gi.test(e)}function j(e){return/^body$/i.test(e)||/^head$/i.test(e)||/^html$/i.test(e)}function G(e){return function(e){return"undefined"!=typeof ShadowRoot&&e instanceof ShadowRoot}(e)?e.host:e}function q(e){return e?e.replace(/^\s+|\s+$/g,""):""}function V(){return navigator.userAgent.indexOf("Firefox")>-1}function Q(e){const t={},n=e.split("&");for(const e of n){const n=e.indexOf("="),o=n<0?e:e.slice(0,n),s=n<0?null:e.slice(n+1);if(o in t){let e=t[o];i(e)||(e=t[o]=[e]),e.push(s)}else t[o]=s}return t}function Y(e){let t="";for(const n in e){const o=e[n];if(h(o))t+=(t.length?"&":"")+n;else{(i(o)?o:[o]).forEach((e=>{p(e)||(t+=(t.length?"&":"")+n,h(e)||(t+="="+e))}))}}return t}function z(){const e=new Set;return{add:function(t){return e.add(t),()=>!!e.has(t)&&e.delete(t)},list:()=>e}}function X(e){const t=e.attributes,n=new Map;for(let e=0;e<t.length;e++)n.set(t[e].name,t[e].value);return n}function J(e,t){e?e.push((()=>U((e=>{t(),e()})))):t()}function Z(e){return(null==e?void 0:e.reduce(((e,t)=>e.then(t)),Promise.resolve()))||null}function ee(e){return e.startsWith("inline-")}function te(e,t,n,...o){try{f(e)&&e(...o)}catch(e){R(`an error occurred in app ${t} ${n} \n`,null,e)}}var ne,oe,se,re,ie,ae;!function(e){e.NAME="name",e.URL="url"}(ne||(ne={})),function(e){e.CREATED="created",e.LOADING="loading",e.LOADED="loaded",e.LOAD_FAILED="load_failed",e.MOUNTING="mounting",e.MOUNTED="mounted",e.UNMOUNT="unmount"}(oe||(oe={})),function(e){e.CREATED="created",e.BEFOREMOUNT="beforemount",e.MOUNTED="mounted",e.UNMOUNT="unmount",e.ERROR="error",e.BEFORESHOW="beforeshow",e.AFTERSHOW="aftershow",e.AFTERHIDDEN="afterhidden"}(se||(se={})),function(e){e.ONMOUNT="onmount",e.ONUNMOUNT="onunmount"}(re||(re={})),function(e){e.KEEP_ALIVE_SHOW="keep_alive_show",e.KEEP_ALIVE_HIDDEN="keep_alive_hidden"}(ie||(ie={})),function(e){e.DESTROY="destroy",e.DESTORY="destory",e.INLINE="inline",e.DISABLESCOPECSS="disableScopecss",e.DISABLESANDBOX="disableSandbox",e.DISABLE_SCOPECSS="disable-scopecss",e.DISABLE_SANDBOX="disable-sandbox",e.DISABLE_MEMORY_ROUTER="disable-memory-router",e.DISABLE_PATCH_REQUEST="disable-patch-request",e.KEEP_ROUTER_STATE="keep-router-state",e.HIDDEN_ROUTER="hidden-router",e.KEEP_ALIVE="keep-alive",e.CLEAR_DATA="clear-data",e.ESMODULE="esmodule",e.SSR="ssr",e.FIBER="fiber"}(ae||(ae={}));const ce="window,self,globalThis,Array,Object,String,Boolean,Math,Number,Symbol,Date,Function,Proxy,WeakMap,WeakSet,Set,Map,Reflect,Element,Node,Document,RegExp,Error,TypeError,JSON,isNaN,parseFloat,parseInt,performance,console,decodeURI,encodeURI,decodeURIComponent,encodeURIComponent,navigator,undefined,location,history";function le(e,t=null,n={}){return $(),f(_n.options.fetch)?_n.options.fetch(e,n,t):window.fetch(e,n).then((e=>e.text()))}class ue{static getInstance(){return this.instance||(this.instance=new ue),this.instance}run(e,t){const n=e.name,o=e.ssrUrl||e.url;le(o,n,{cache:"no-cache"}).then((s=>{if(!s){const t="html is empty, please check in detail";return e.onerror(new Error(t)),R(t,n)}s=this.formatHTML(o,s,n),t(s,e)})).catch((t=>{R(`Failed to fetch data from ${e.url}, micro-app stop rendering`,n,t),e.onLoadError(t)}))}formatHTML(e,t,n){return this.processHtml(e,t,n,_n.options.plugins).replace(/<head[^>]*>[\s\S]*?<\/head>/i,(e=>e.replace(/<head/i,"<micro-app-head").replace(/<\/head>/i,"</micro-app-head>"))).replace(/<body[^>]*>[\s\S]*?<\/body>/i,(e=>e.replace(/<body/i,"<micro-app-body").replace(/<\/body>/i,"</micro-app-body>")))}processHtml(e,t,n,o){var s;if(!o)return t;const r=[];return o.global&&r.push(...o.global),(null===(s=o.modules)||void 0===s?void 0:s[n])&&r.push(...o.modules[n]),r.length>0?r.reduce(((t,n)=>_(n)&&f(n.processHtml)?n.processHtml(t,e):t),t):t}}const pe=/(^|\s+)(html|:root)(?=[\s>~[.#:]+|$)/,he=/(^|\s+)((html[\s>~]+body)|body)(?=[\s>~[.#:]+|$)/;function de(e,t){e=t?`${t} ${e}`:e;const n=new Error(e);throw n.reason=e,t&&(n.filename=t),n}class me{constructor(){this.cssText="",this.prefix="",this.baseURI="",this.linkPath="",this.result="",this.scopecssDisable=!1,this.scopecssDisableSelectors=[],this.scopecssDisableNextLine=!1,this.mediaRule=this.createMatcherForRuleWithChildRule(/^@media *([^{]+)/,"@media"),this.supportsRule=this.createMatcherForRuleWithChildRule(/^@supports *([^{]+)/,"@supports"),this.documentRule=this.createMatcherForRuleWithChildRule(/^@([-\w]+)?document *([^{]+)/,"@document"),this.hostRule=this.createMatcherForRuleWithChildRule(/^@host\s*/,"@host"),this.importRule=this.createMatcherForNoneBraceAtRule("import"),this.charsetRule=this.createMatcherForNoneBraceAtRule("charset"),this.namespaceRule=this.createMatcherForNoneBraceAtRule("namespace")}exec(e,t,n,o){return this.cssText=e,this.prefix=t,this.baseURI=n,this.linkPath=o||"",this.matchRules(),V()?decodeURIComponent(this.result):this.result}reset(){this.cssText=this.prefix=this.baseURI=this.linkPath=this.result="",this.scopecssDisable=this.scopecssDisableNextLine=!1,this.scopecssDisableSelectors=[]}matchRules(){for(this.matchLeadingSpaces(),this.matchComments();this.cssText.length&&"}"!==this.cssText.charAt(0)&&(this.matchAtRule()||this.matchStyleRule());)this.matchComments()}matchStyleRule(){const e=this.formatSelector(!0);return this.scopecssDisableNextLine=!1,e?(this.recordResult(e),this.matchComments(),this.styleDeclarations(),this.matchLeadingSpaces(),!0):de("selector missing",this.linkPath)}formatSelector(e){const t=this.commonMatch(/^[^{]+/,e);return!!t&&t[0].replace(/(^|,[\n\s]*)([^,]+)/g,((e,t,n)=>(n=q(n),this.scopecssDisableNextLine||this.scopecssDisable&&(!this.scopecssDisableSelectors.length||this.scopecssDisableSelectors.includes(n))||pe.test(n)||(n=he.test(n)?n.replace(he,this.prefix+" micro-app-body"):this.prefix+" "+n),t+n)))}styleDeclarations(){return this.matchOpenBrace()?(this.matchAllDeclarations(),!!this.matchCloseBrace()||de("Declaration missing '}'",this.linkPath)):de("Declaration missing '{'",this.linkPath)}matchAllDeclarations(){let e=this.commonMatch(/^(?:url\(["']?(?:[^)"'}]+)["']?\)|[^}/])*/,!0)[0];if(e&&(this.scopecssDisableNextLine||this.scopecssDisable&&!this.scopecssDisableSelectors.length||(e=e.replace(/url\(["']?([^)"']+)["']?\)/gm,((e,t)=>/^((data|blob):|#)/.test(t)||/^(https?:)?\/\//.test(t)?e:(/^((\.\.?\/)|[^/])/.test(t)&&this.linkPath&&(this.baseURI=function(e){const t=e.split("/");return t.pop(),C(t.join("/")+"/")}(this.linkPath)),`url("${L(t,this.baseURI)}")`)))),this.recordResult(e)),this.scopecssDisableNextLine=!1,this.cssText&&"}"!==this.cssText.charAt(0))return"/"===this.cssText.charAt(0)&&"*"===this.cssText.charAt(1)?this.matchComments():this.commonMatch(/\/+/),this.matchAllDeclarations()}matchAtRule(){return"@"===this.cssText[0]&&(this.scopecssDisableNextLine=!1,this.keyframesRule()||this.mediaRule()||this.customMediaRule()||this.supportsRule()||this.importRule()||this.charsetRule()||this.namespaceRule()||this.documentRule()||this.pageRule()||this.hostRule()||this.fontFaceRule())}keyframesRule(){if(!this.commonMatch(/^@([-\w]+)?keyframes\s*/))return!1;if(!this.commonMatch(/^[^{]+/))return de("@keyframes missing name",this.linkPath);if(this.matchComments(),!this.matchOpenBrace())return de("@keyframes missing '{'",this.linkPath);for(this.matchComments();this.keyframeRule();)this.matchComments();return this.matchCloseBrace()?(this.matchLeadingSpaces(),!0):de("@keyframes missing '}'",this.linkPath)}keyframeRule(){let e;const t=[];for(;e=this.commonMatch(/^((\d+\.\d+|\.\d+|\d+)%?|[a-z]+)\s*/);)t.push(e[1]),this.commonMatch(/^,\s*/);return!!t.length&&(this.styleDeclarations(),this.matchLeadingSpaces(),!0)}customMediaRule(){return!!this.commonMatch(/^@custom-media\s+(--[^\s]+)\s*([^{;]+);/)&&(this.matchLeadingSpaces(),!0)}pageRule(){return!!this.commonMatch(/^@page */)&&(this.formatSelector(!1),this.scopecssDisableNextLine=!1,this.commonHandlerForAtRuleWithSelfRule("page"))}fontFaceRule(){return!!this.commonMatch(/^@font-face\s*/)&&this.commonHandlerForAtRuleWithSelfRule("font-face")}createMatcherForRuleWithChildRule(e,t){return()=>!!this.commonMatch(e)&&(this.matchOpenBrace()?(this.matchComments(),this.matchRules(),this.matchCloseBrace()?(this.matchLeadingSpaces(),!0):de(`${t} missing '}'`,this.linkPath)):de(`${t} missing '{'`,this.linkPath))}createMatcherForNoneBraceAtRule(e){const t=new RegExp("^@"+e+"\\s*([^;]+);");return()=>!!this.commonMatch(t)&&(this.matchLeadingSpaces(),!0)}commonHandlerForAtRuleWithSelfRule(e){return this.matchOpenBrace()?(this.matchAllDeclarations(),this.matchCloseBrace()?(this.matchLeadingSpaces(),!0):de(`@${e} missing '}'`,this.linkPath)):de(`@${e} missing '{'`,this.linkPath)}matchComments(){for(;this.matchComment(););}matchComment(){if("/"!==this.cssText.charAt(0)||"*"!==this.cssText.charAt(1))return!1;this.scopecssDisableNextLine=!1;let e=2;for(;""!==this.cssText.charAt(e)&&("*"!==this.cssText.charAt(e)||"/"!==this.cssText.charAt(e+1));)++e;if(e+=2,""===this.cssText.charAt(e-1))return de("End of comment missing",this.linkPath);let t=this.cssText.slice(2,e-2);if(this.recordResult(`/*${t}*/`),t=q(t.replace(/^\s*!/,"")),"scopecss-disable-next-line"===t)this.scopecssDisableNextLine=!0;else if(/^scopecss-disable/.test(t))if("scopecss-disable"===t)this.scopecssDisable=!0;else{this.scopecssDisable=!0;t.replace("scopecss-disable","").split(",").forEach((e=>{this.scopecssDisableSelectors.push(q(e))}))}else"scopecss-enable"===t&&(this.scopecssDisable=!1,this.scopecssDisableSelectors=[]);return this.cssText=this.cssText.slice(e),this.matchLeadingSpaces(),!0}commonMatch(e,t=!1){const n=e.exec(this.cssText);if(!n)return;const o=n[0];return this.cssText=this.cssText.slice(o.length),t||this.recordResult(o),n}matchOpenBrace(){return this.commonMatch(/^{\s*/)}matchCloseBrace(){return this.commonMatch(/^}/)}matchLeadingSpaces(){this.commonMatch(/^\s*/)}recordResult(e){V()?this.result+=encodeURIComponent(e):this.result+=e}}function fe(e,t,n,o,s){if(!e.__MICRO_APP_HAS_SCOPED__){e.__MICRO_APP_HAS_SCOPED__=!0;let r=null;try{r=_e.exec(e.textContent,n,o,s),_e.reset()}catch(e){_e.reset(),R("An error occurred while parsing CSS:\n",t,e)}r&&(e.textContent=r)}}let _e;function ge(e,t,n){if(t.scopecss){const o=Ae(t.name);if(_e||(_e=new me),e.textContent)fe(e,t.name,o,t.url,n);else{const s=new MutationObserver((function(){s.disconnect(),e.textContent&&!e.hasAttribute("data-styled")&&fe(e,t.name,o,t.url,n)}));s.observe(e,{childList:!0})}}return e}function Ae(e,t=!1){const n=t?"\\":"";return`${_n.tagName}${n}[name=${e}${n}]`}function we(e,t){Object.defineProperties(e,{currentTarget:{get:()=>t},srcElement:{get:()=>t},target:{get:()=>t}})}function be(e){const t=new CustomEvent("load");we(t,e),f(e.onload)?e.onload(t):e.dispatchEvent(t)}function ye(e){const t=new CustomEvent("error");we(t,e),f(e.onerror)?e.onerror(t):e.dispatchEvent(t)}var ve=function(){const e=new Map,t=new Map;function n(e){return{setInfo(t,n){e.set(t,n)},getInfo(t){var n;return null!==(n=e.get(t))&&void 0!==n?n:null},hasInfo:t=>e.has(t),deleteInfo:t=>e.delete(t)}}return{link:n(e),script:Object.assign(Object.assign({},n(t)),{deleteInlineInfo(e){e.forEach((e=>{ee(e)&&t.delete(e)}))}})}}();function Ee(e,t,n,o=!1){const s=e.getAttribute("rel");let r=e.getAttribute("href"),i=null;if("stylesheet"===s&&r){r=L(r,n.url);let t=ve.link.getInfo(r);const s={attrs:X(e)};if(t?t.appSpace[n.name]=t.appSpace[n.name]||s:t={code:"",appSpace:{[n.name]:s}},ve.link.setInfo(r,t),o)return{address:r,linkInfo:t};n.source.links.add(r),i=document.createComment(`link element with href=${r} move to micro-app-head as style element`),t.appSpace[n.name].placeholder=i}else s&&["prefetch","preload","prerender","icon","apple-touch-icon"].includes(s)?o?i=document.createComment(`link element with rel=${s}${r?" & href="+r:""} removed by micro-app`):t.removeChild(e):r&&e.setAttribute("href",L(r,n.url));return o?{replaceComment:i}:i?t.replaceChild(i,e):void 0}function Re(e,t,n,o){const s=Array.from(t.source.links),r=s.map((e=>{const n=ve.link.getInfo(e);return n.code?n.code:le(e,t.name)})),i=t.isPrefetch||t.fiber?[]:null;x(r,(e=>{J(i,(()=>function(e,t,n,o){const s=ve.link.getInfo(e);s.code=t;const r=s.appSpace[o.name],i=r.placeholder;if(i){const t=F("style");Se(o,e,t,s,r.attrs),i.parentNode?i.parentNode.replaceChild(t,i):n.appendChild(t),r.placeholder=null}}(s[e.index],e.data,n,t)))}),(e=>{R(e,t.name)}),(()=>{i?o.then((()=>{i.push((()=>Promise.resolve(t.onLoad(e)))),Z(i)})):t.onLoad(e)}))}function Se(e,t,n,o,s){if(e.scopecss){const s=o.appSpace[e.name];if(s.prefix=s.prefix||Ae(e.name),s.parsedCode)n.textContent=s.parsedCode;else{const r=function(e,t,n){const o=n.appSpace;for(const n in o)if(n!==e){const e=o[n];if(e.parsedCode)return e.parsedCode.replaceAll(new RegExp(Ae(n,!0),"g"),t)}}(e.name,s.prefix,o);r?n.textContent=r:(n.textContent=o.code,ge(n,e,t)),s.parsedCode=n.textContent}}else n.textContent=o.code;!function(e,t){t.forEach(((t,n)=>{"rel"!==n&&("href"===n&&(n="data-origin-href"),e.setAttribute(n,t))}))}(n,s)}class Pe{constructor(){this.escapeSetterKeyList=["location"],this.staticEscapeProperties=["System","__cjsWrapper"],this.staticScopeProperties=["webpackJsonp","webpackHotUpdate","Vue"],this.injectReactHRMProperty()}injectReactHRMProperty(){"production"!==process.env.NODE_ENV&&(this.staticEscapeProperties.push("__REACT_ERROR_OVERLAY_GLOBAL_HOOK__"),Be.rawWindow.__REACT_ERROR_OVERLAY_GLOBAL_HOOK__&&(this.staticScopeProperties=this.staticScopeProperties.concat(["__REACT_ERROR_OVERLAY_GLOBAL_HOOK__","__reactRefreshInjected"])))}}function Ne(e,t){const n=Object.getOwnPropertyDescriptor(e,"parentNode");n&&!n.configurable||c(e,"parentNode",{value:t,configurable:!0})}const Ce=new WeakMap;function De(e,t,n){if(t instanceof HTMLStyleElement){if(t.hasAttribute("exclude")){const e=document.createComment("style element with exclude attribute ignored by micro-app");return Ce.set(t,e),e}return n.scopecss&&!t.hasAttribute("ignore")?ge(t,n):t}if(t instanceof HTMLLinkElement){if(t.hasAttribute("exclude")||Ye(t.getAttribute("href"),n.name)){const e=document.createComment("link element with exclude attribute ignored by micro-app");return Ce.set(t,e),e}if(t.hasAttribute("ignore")||ze(t.getAttribute("href"),n.name)||t.href&&f(_n.options.excludeAssetFilter)&&_n.options.excludeAssetFilter(t.href))return t;const{address:o,linkInfo:s,replaceComment:r}=Ee(t,e,n,!0);if(o&&s){const e=function(e,t,n,o){const s=F("style"),r=()=>{Se(t,e,s,n,n.appSpace[t.name].attrs),be(o)};return n.code?P(r):le(e,t.name).then((e=>{n.code=e,r()})).catch((e=>{R(e,t.name),ye(o)})),s}(o,n,s,t);return Ce.set(t,e),e}return r?(Ce.set(t,r),r):t}if(t instanceof HTMLScriptElement){if(t.src&&f(_n.options.excludeAssetFilter)&&_n.options.excludeAssetFilter(t.src))return t;const{replaceComment:o,address:s,scriptInfo:r}=Ve(t,e,n,!0)||{};if(s&&r){const e=r.isExternal?function(e,t,n,o){const s=Ke(t,n)?F("script"):document.createComment("dynamic script extract by micro-app"),r=()=>be(o),i=()=>{const i=Object.getOwnPropertyDescriptor(Be.rawDocument,"currentScript");i&&!i.configurable||Object.defineProperty(Be.rawDocument,"currentScript",{value:o,configurable:!0}),Je(e,t,n,r,s),!He(t,n)&&r()};n.code?P(i):le(e,t.name).then((e=>{n.code=e,i()})).catch((e=>{R(e,t.name),ye(o)}));return s}(s,n,r,t):function(e,t,n){const o=Ke(t,n)?F("script"):document.createComment("dynamic script extract by micro-app");return Je(e,t,n,void 0,o),o}(s,n,r);return Ce.set(t,e),e}return o?(Ce.set(t,o),o):t}return t}function Me(e,t,n,o,s){const r=function(e,t){var n,o;if(e===document.head)return null===(n=null==t?void 0:t.container)||void 0===n?void 0:n.querySelector("micro-app-head");if(e===document.body)return null===(o=null==t?void 0:t.container)||void 0===o?void 0:o.querySelector("micro-app-body");return null}(n,e);if(r){if("MICRO-APP-BODY"===r.tagName&&t!==Be.rawRemoveChild){const e=Object.getOwnPropertyDescriptor(o,"parentNode");e&&!e.configurable||c(o,"parentNode",{configurable:!0,get:()=>Element.prototype.removeChild===Be.rawRemoveChild?r:document.body})}return s&&!r.contains(s)?Be.rawAppendChild.call(r,o):t!==Be.rawRemoveChild||r.contains(o)?("production"!==process.env.NODE_ENV&&o instanceof HTMLIFrameElement&&t===Be.rawAppendChild&&function(e){var t;if("production"!==process.env.NODE_ENV){const n=Be.rawWindow.__REACT_ERROR_OVERLAY_GLOBAL_HOOK__,o=null===(t=e.sandBox)||void 0===t?void 0:t.proxyWindow.__REACT_ERROR_OVERLAY_GLOBAL_HOOK__;n&&o&&(Be.rawWindow.__REACT_ERROR_OVERLAY_GLOBAL_HOOK__=o,P((()=>{Be.rawWindow.__REACT_ERROR_OVERLAY_GLOBAL_HOOK__=n})))}}(e),Oe(t,r,o,s)):n.contains(o)?t.call(n,o):o}return Oe(t,n,o,s)}function Oe(e,t,n,o){return(s=e)===Be.rawAppend||s===Be.rawPrepend?e.call(t,n):e.call(t,n,o);var s}function Le(e){var t;return null!==(t=Ce.get(e))&&void 0!==t?t:e}function xe(e,t,n,o){const s=B();if(E(t)&&(t.__MICRO_APP_NAME__||s&&!t.__PURE_ELEMENT__)){t.__MICRO_APP_NAME__=t.__MICRO_APP_NAME__||s;const r=on.get(t.__MICRO_APP_NAME__);if(null==r?void 0:r.container)return v(t)&&(/^(img|script)$/i.test(t.tagName)?(t.hasAttribute("src")&&Be.rawSetAttribute.call(t,"src",L(t.getAttribute("src"),r.url)),t.hasAttribute("srcset")&&Be.rawSetAttribute.call(t,"srcset",L(t.getAttribute("srcset"),r.url))):/^link$/i.test(t.tagName)&&t.hasAttribute("href")&&Be.rawSetAttribute.call(t,"href",L(t.getAttribute("href"),r.url))),Me(r,o,e,De(e,t,r),n&&Le(n));if(o===Be.rawAppend||o===Be.rawPrepend)return o.call(e,t)}else if(o===Be.rawAppend||o===Be.rawPrepend){if(!E(t)&&s){const n=on.get(s);if(null==n?void 0:n.container){if(e===document.head)return o.call(n.container.querySelector("micro-app-head"),t);if(e===document.body)return o.call(n.container.querySelector("micro-app-body"),t)}}return o.call(e,t)}return o.call(e,t,n)}function Ie(){!function(){const e=Be.rawDocument,t=Be.rawRootDocument;function n(t){return function(e){return"[object ProxyDocument]"===toString.call(e)}(t)?e:t}function o(t){var o,s,r,i;const a=n(this),c=B();return c&&(null===(o=on.get(c))||void 0===o?void 0:o.container)&&t&&!j(t)&&e===a?null!==(i=null===(r=null===(s=on.get(c))||void 0===s?void 0:s.container)||void 0===r?void 0:r.querySelector(t))&&void 0!==i?i:null:Be.rawQuerySelector.call(a,t)}function s(t){var o,s,r,i;const a=n(this),c=B();return c&&(null===(o=on.get(c))||void 0===o?void 0:o.container)&&t&&!j(t)&&e===a?null!==(i=null===(r=null===(s=on.get(c))||void 0===s?void 0:s.container)||void 0===r?void 0:r.querySelectorAll(t))&&void 0!==i?i:[]:Be.rawQuerySelectorAll.call(a,t)}t.prototype.createElement=function(e,t){return Ue(Be.rawCreateElement.call(n(this),e,t))},t.prototype.createElementNS=function(e,t,o){return Ue(Be.rawCreateElementNS.call(n(this),e,t,o))},t.prototype.createDocumentFragment=function(){return Ue(Be.rawCreateDocumentFragment.call(n(this)))},t.prototype.querySelector=o,t.prototype.querySelectorAll=s,t.prototype.getElementById=function(e){const t=n(this);if(!B()||K(e))return Be.rawGetElementById.call(t,e);try{return o.call(t,`#${e}`)}catch(n){return Be.rawGetElementById.call(t,e)}},t.prototype.getElementsByClassName=function(e){const t=n(this);if(!B()||K(e))return Be.rawGetElementsByClassName.call(t,e);try{return s.call(t,`.${e}`)}catch(n){return Be.rawGetElementsByClassName.call(t,e)}},t.prototype.getElementsByTagName=function(e){var t;const o=n(this),r=B();if(!r||j(e)||K(e)||!(null===(t=on.get(r))||void 0===t?void 0:t.inline)&&/^script$/i.test(e))return Be.rawGetElementsByTagName.call(o,e);try{return s.call(o,e)}catch(t){return Be.rawGetElementsByTagName.call(o,e)}},t.prototype.getElementsByName=function(e){const t=n(this);if(!B()||K(e))return Be.rawGetElementsByName.call(t,e);try{return s.call(t,`[name=${e}]`)}catch(n){return Be.rawGetElementsByName.call(t,e)}}}(),Element.prototype.appendChild=function(e){return xe(this,e,null,Be.rawAppendChild)},Element.prototype.insertBefore=function(e,t){return xe(this,e,t,Be.rawInsertBefore)},Element.prototype.replaceChild=function(e,t){return xe(this,e,t,Be.rawReplaceChild)},Element.prototype.append=function(...e){let t=0;const n=e.length;for(;t<n;)xe(this,e[t],null,Be.rawAppend),t++},Element.prototype.prepend=function(...e){let t=e.length;for(;t>0;)xe(this,e[t-1],null,Be.rawPrepend),t--},Element.prototype.removeChild=function(e){var t;if(null==e?void 0:e.__MICRO_APP_NAME__){const n=on.get(e.__MICRO_APP_NAME__);if(null==n?void 0:n.container)return Me(n,Be.rawRemoveChild,this,Le(e));try{return Be.rawRemoveChild.call(this,e)}catch(n){return null===(t=null==e?void 0:e.parentNode)||void 0===t?void 0:t.removeChild(e)}}return Be.rawRemoveChild.call(this,e)},Element.prototype.cloneNode=function(e){const t=Be.rawCloneNode.call(this,e);return this.__MICRO_APP_NAME__&&(t.__MICRO_APP_NAME__=this.__MICRO_APP_NAME__),t}}function Ue(e){const t=B();return t&&(e.__MICRO_APP_NAME__=t),e}let Te=!1;function We(){$(),function(){const e=Be.rawRootDocument;e.prototype.createElement=Be.rawCreateElement,e.prototype.createElementNS=Be.rawCreateElementNS,e.prototype.createDocumentFragment=Be.rawCreateDocumentFragment,e.prototype.querySelector=Be.rawQuerySelector,e.prototype.querySelectorAll=Be.rawQuerySelectorAll,e.prototype.getElementById=Be.rawGetElementById,e.prototype.getElementsByClassName=Be.rawGetElementsByClassName,e.prototype.getElementsByTagName=Be.rawGetElementsByTagName,e.prototype.getElementsByName=Be.rawGetElementsByName}(),Element.prototype.appendChild=Be.rawAppendChild,Element.prototype.insertBefore=Be.rawInsertBefore,Element.prototype.replaceChild=Be.rawReplaceChild,Element.prototype.removeChild=Be.rawRemoveChild,Element.prototype.append=Be.rawAppend,Element.prototype.prepend=Be.rawPrepend,Element.prototype.cloneNode=Be.rawCloneNode}let ke=!1;const Be={};function $e(){if(n){const e=Function("return window")(),t=Function("return document")(),n=Function("return Document")(),o="noModule"in document.createElement("script"),s=Element.prototype.setAttribute,r=Element.prototype.appendChild,i=Element.prototype.insertBefore,c=Element.prototype.replaceChild,l=Element.prototype.removeChild,u=Element.prototype.append,p=Element.prototype.prepend,h=Element.prototype.cloneNode,d=n.prototype.createElement,m=n.prototype.createElementNS,f=n.prototype.createDocumentFragment,_=n.prototype.querySelector,g=n.prototype.querySelectorAll,A=n.prototype.getElementById,w=n.prototype.getElementsByClassName,b=n.prototype.getElementsByTagName,y=n.prototype.getElementsByName,v=new Proxy(Image,{construct(e,t){const n=new e(...t);return n.__MICRO_APP_NAME__=B(),n}}),E=e.addEventListener,R=e.removeEventListener,S=e.setInterval,P=e.setTimeout,N=e.clearInterval,C=e.clearTimeout,D=e.history.pushState,M=e.history.replaceState,O=t.addEventListener,L=t.removeEventListener;window.__MICRO_APP_BASE_APPLICATION__=!0,a(Be,{rawWindow:e,rawDocument:t,rawRootDocument:n,supportModuleScript:o,rawSetAttribute:s,rawAppendChild:r,rawInsertBefore:i,rawReplaceChild:c,rawRemoveChild:l,rawAppend:u,rawPrepend:p,rawCloneNode:h,rawCreateElement:d,rawCreateElementNS:m,rawCreateDocumentFragment:f,rawQuerySelector:_,rawQuerySelectorAll:g,rawGetElementById:A,rawGetElementsByClassName:w,rawGetElementsByTagName:b,rawGetElementsByName:y,ImageProxy:v,rawWindowAddEventListener:E,rawWindowRemoveEventListener:R,rawSetInterval:S,rawSetTimeout:P,rawClearInterval:N,rawClearTimeout:C,rawDocumentAddEventListener:O,rawDocumentRemoveEventListener:L,rawPushState:D,rawReplaceState:M}),function(){if(!ke){ke=!0;const e=F("style");Be.rawSetAttribute.call(e,"type","text/css"),e.textContent=`\n${_n.tagName}, micro-app-body { display: block; } \nmicro-app-head { display: none; }`,Be.rawDocument.head.appendChild(e)}}()}}const Fe=["text/javascript","text/ecmascript","application/javascript","application/ecmascript","module","systemjs-module","systemjs-importmap"];function He(e,t){return t.appSpace[e.name].module&&(!e.useSandbox||e.esmodule)}function Ke(e,t){return e.inline||t.appSpace[e.name].inline||He(e,t)||function(e,t){return t.appSpace[e.name].attrs.has("id")}(e,t)}function je(e,t,n){return function(e,t,n){const o=t.appSpace;for(const t in o)if(t!==e){const e=o[t];if(e.parsedCode===n&&e.parsedFunction)return e.parsedFunction}}(e.name,t,n)||new Function(n)}function Ge(){const e="inline-"+Math.random().toString(36).substr(2,15);return ve.script.hasInfo(e)?Ge():e}function qe(e,t){return e.useSandbox&&!He(e,t)}function Ve(e,t,n,o=!1){let s=null,r=e.getAttribute("src");if(r&&(r=L(r,n.url)),e.hasAttribute("exclude")||Ye(r,n.name))s=document.createComment("script element with exclude attribute removed by micro-app");else{if(e.type&&!Fe.includes(e.type)||e.hasAttribute("ignore")||ze(r,n.name))return null;if(Be.supportModuleScript&&e.noModule||!Be.supportModuleScript&&"module"===e.type)s=document.createComment((e.noModule?"noModule":"module")+" script ignored by micro-app");else if(r){let t=ve.script.getInfo(r);const i={async:e.hasAttribute("async"),defer:e.defer||"module"===e.type,module:"module"===e.type,inline:e.hasAttribute("inline"),pure:e.hasAttribute("pure"),attrs:X(e)};if(t?t.appSpace[n.name]=t.appSpace[n.name]||i:t={code:"",isExternal:!0,appSpace:{[n.name]:i}},ve.script.setInfo(r,t),o)return{address:r,scriptInfo:t};n.source.scripts.add(r),s=document.createComment(`script with src='${r}' extract by micro-app`)}else if(e.textContent){const t=Ge(),r={code:e.textContent,isExternal:!1,appSpace:{[n.name]:{async:!1,defer:"module"===e.type,module:"module"===e.type,inline:e.hasAttribute("inline"),pure:e.hasAttribute("pure"),attrs:X(e)}}};if(o)return{address:t,scriptInfo:r};n.source.scripts.add(t),ve.script.setInfo(t,r),s=document.createComment("inline script extract by micro-app")}else o||(s=document.createComment("script element removed by micro-app"))}return o?{replaceComment:s}:t.replaceChild(s,e)}function Qe(e){var t,n,o;return[...(null===(t=_n.options.plugins)||void 0===t?void 0:t.global)||[],...(null===(o=null===(n=_n.options.plugins)||void 0===n?void 0:n.modules)||void 0===o?void 0:o[e])||[]]}function Ye(e,t){if(!e)return!1;return(Qe(t)||[]).some((t=>!!t.excludeChecker&&t.excludeChecker(e)))}function ze(e,t){if(!e)return!1;return(Qe(t)||[]).some((t=>!!t.ignoreChecker&&t.ignoreChecker(e)))}function Xe(e,t){const n=Array.from(t.source.scripts),o=[],s=[];for(const e of n){const n=ve.script.getInfo(e),r=n.appSpace[t.name];(!r.defer&&!r.async||t.isPrefetch)&&(o.push(n.code?n.code:le(e,t.name)),s.push([e,n]))}const r=t.isPrefetch||t.fiber?[]:null;o.length?x(o,(e=>{J(r,(()=>function(e,t,n,o){if(t.code=n,o.isPrefetch){const s=t.appSpace[o.name];if(!s.parsedCode&&(s.parsedCode=Ze(e,o,n,t),s.wrapInSandBox=qe(o,t),!Ke(o,t)))try{s.parsedFunction=je(o,t,s.parsedCode)}catch(e){S("Something went wrong while handling preloaded resources",o.name,"\n",e)}}}(s[e.index][0],s[e.index][1],e.data,t)))}),(e=>{R(e,t.name)}),(()=>{r?(r.push((()=>Promise.resolve(t.onLoad(e)))),Z(r)):t.onLoad(e)})):t.onLoad(e)}function Je(e,t,n,o,s){var r;try{!function(e){!function(e){e.sandBox&&(Be.rawWindow.__MICRO_APP_PROXY_WINDOW__=e.sandBox.proxyWindow)}(e)}(t);const i=n.appSpace[t.name],a=qe(t,n);if(i.parsedCode&&i.wrapInSandBox===a||(i.parsedCode=Ze(e,t,n.code,n),i.wrapInSandBox=a,i.parsedFunction=null),Ke(t,n)){const a=s||F("script");!function(e,t,n,o,s,r){if(n){if(ee(e)){const e=new Blob([t],{type:"text/javascript"});o.src=URL.createObjectURL(e)}else o.src=e;o.setAttribute("type","module"),r&&(r.moduleCount&&r.moduleCount--,o.onload=r.bind(o,0===r.moduleCount))}else o.textContent=t;!function(e,t){t.forEach(((t,n)=>{"type"===n&&"module"===t||"defer"===n||"async"===n||("src"===n&&(n="data-origin-src"),e.setAttribute(n,t))}))}(o,s)}(e,i.parsedCode,He(t,n),a,i.attrs,o),s||null===(r=t.container)||void 0===r||r.querySelector("micro-app-body").appendChild(a)}else!function(e,t){const n=t.appSpace[e.name];n.parsedFunction||(n.parsedFunction=je(e,t,n.parsedCode));n.parsedFunction.call(window)}(t,n)}catch(n){console.error(`[micro-app from ${s?"runDynamicScript":"runScript"}] app ${t.name}: `,n,e)}}function Ze(e,t,n,o){return _(_n.options.plugins)&&(n=function(e,t,n,o){var s;const r=et(o.global,t,e);return et(null===(s=o.modules)||void 0===s?void 0:s[n],r,e)}(e,n,t.name,_n.options.plugins)),qe(t,o)?`;(function(proxyWindow){with(proxyWindow.__MICRO_APP_WINDOW__){(function(${ce}){;${n}\n${ee(e)?"":`//# sourceURL=${e}\n`}}).call(proxyWindow,${ce})}})(window.__MICRO_APP_PROXY_WINDOW__);`:n}function et(e,t,n){return i(e)?e.reduce(((e,t)=>_(t)&&f(t.loader)?t.loader(e,n):e),t):t}function tt(e,t,n,o){const s=Array.from(e.children);s.length&&s.forEach((e=>{tt(e,t,n,o)}));for(const n of s)n instanceof HTMLLinkElement?n.hasAttribute("exclude")||Ye(n.getAttribute("href"),t.name)?e.replaceChild(document.createComment("link element with exclude attribute ignored by micro-app"),n):n.hasAttribute("ignore")||ze(n.getAttribute("href"),t.name)?n.hasAttribute("href")&&n.setAttribute("href",L(n.getAttribute("href"),t.url)):Ee(n,e,t):n instanceof HTMLStyleElement?n.hasAttribute("exclude")?e.replaceChild(document.createComment("style element with exclude attribute ignored by micro-app"),n):t.scopecss&&!n.hasAttribute("ignore")&&J(o,(()=>ge(n,t))):n instanceof HTMLScriptElement?Ve(n,e,t):n instanceof HTMLMetaElement||n instanceof HTMLTitleElement?e.removeChild(n):n instanceof HTMLImageElement&&n.hasAttribute("src")&&n.setAttribute("src",L(n.getAttribute("src"),t.url))}function nt(e,t){const n=function(e){const t=F("div");return t.innerHTML=e,t}(e),o=n.querySelector("micro-app-head"),s=n.querySelector("micro-app-body");if(!o||!s){const e=`element ${o?"body":"head"} is missing`;return t.onerror(new Error(e)),R(e,t.name)}const r=t.isPrefetch||t.fiber?[]:null;tt(n,t,o,r);const i=Z(r);t.source.links.size?Re(n,t,o,i):i?i.then((()=>t.onLoad(n))):t.onLoad(n),t.source.scripts.size?Xe(n,t):t.onLoad(n)}const ot=new class{constructor(){this.eventList=new Map,this.queue=[],this.recordStep={},this.process=()=>{var e,t;let n;const o=this.recordStep,s=this.queue;for(this.recordStep={},this.queue=[];n=s.shift();){const s=this.eventList.get(n),r=s.tempData,i=s.force;if(s.tempData=null,s.force=!1,i||!this.isEqual(s.data,r)){s.data=r||s.data;for(const e of s.callbacks)e(s.data);null===(t=(e=o[n]).dispatchDataEvent)||void 0===t||t.call(e),o[n].nextStepList.forEach((e=>e()))}}}}isLegalName(e){return!!e||(R("event-center: Invalid name"),!1)}enqueue(e,t,n){this.recordStep[e]?(this.recordStep[e].nextStepList.push(t),n&&(this.recordStep[e].dispatchDataEvent=n)):this.recordStep[e]={nextStepList:[t],dispatchDataEvent:n},!this.queue.includes(e)&&1===this.queue.push(e)&&P(this.process)}isEqual(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&e[n]!==t[n])return!1;return!0}on(e,t,n=!1){if(this.isLegalName(e)){if(!f(t))return R("event-center: Invalid callback function");let o=this.eventList.get(e);o?n&&Object.keys(o.data).length&&(!this.queue.includes(e)||this.isEqual(o.data,o.tempData))&&t(o.data):(o={data:{},callbacks:new Set},this.eventList.set(e,o)),o.callbacks.add(t)}}off(e,t){if(this.isLegalName(e)){const n=this.eventList.get(e);n&&(f(t)?n.callbacks.delete(t):n.callbacks.clear())}}clearData(e){if(this.isLegalName(e)){const t=this.eventList.get(e);t&&(t.data={})}}dispatch(e,t,n,o,s){if(this.isLegalName(e)){if(!_(t))return R("event-center: data must be object");let r=this.eventList.get(e);r?(r.tempData=a({},r.tempData||r.data,t),!r.force&&(r.force=!!o)):(r={data:t,callbacks:new Set},this.eventList.set(e,r),r.force=!0),this.enqueue(e,n,s)}}getData(e){var t;const n=this.eventList.get(e);return null!==(t=null==n?void 0:n.data)&&void 0!==t?t:null}};function st(e,t){return d(e)&&e?t?`__from_base_app_${e}__`:`__from_micro_app_${e}__`:""}class rt{addGlobalDataListener(e,t){const n=this.appName;n&&(e.__APP_NAME__=n,e.__AUTO_TRIGGER__=t),ot.on("global",e,t)}removeGlobalDataListener(e){f(e)&&ot.off("global",e)}setGlobalData(e,t,n){$(),ot.dispatch("global",e,(()=>f(t)&&t()),n)}forceSetGlobalData(e,t){this.setGlobalData(e,t,!0)}getGlobalData(){return ot.getData("global")}clearGlobalData(){ot.clearData("global")}clearGlobalDataListener(){const e=this.appName,t=ot.eventList.get("global");if(t)for(const n of t.callbacks)(e&&e===n.__APP_NAME__||!e&&!n.__APP_NAME__)&&t.callbacks.delete(n)}}class it extends rt{addDataListener(e,t,n){ot.on(st(M(e),!1),t,n)}removeDataListener(e,t){f(t)&&ot.off(st(M(e),!1),t)}getData(e,t=!1){return ot.getData(st(M(e),t))}setData(e,t,n,o){ot.dispatch(st(M(e),!0),t,(()=>f(n)&&n()),o)}forceSetData(e,t,n){this.setData(e,t,n,!0)}clearData(e,t=!0){ot.clearData(st(M(e),t))}clearDataListener(e){ot.off(st(M(e),!1))}}class at extends rt{constructor(e){super(),this.appName=M(e),!this.appName&&R(`Invalid appName ${e}`)}addDataListener(e,t){e.__AUTO_TRIGGER__=t,ot.on(st(this.appName,!0),e,t)}removeDataListener(e){f(e)&&ot.off(st(this.appName,!0),e)}getData(e=!0){return ot.getData(st(this.appName,e))}dispatch(e,t,n){$(),ot.dispatch(st(this.appName,!1),e,(()=>f(t)&&t()),n,(()=>{const t=on.get(this.appName);if((null==t?void 0:t.container)&&_(e)){const e=new CustomEvent("datachange",{detail:{data:ot.getData(st(this.appName,!1))}});G(t.container).dispatchEvent(e)}}))}forceDispatch(e,t){this.dispatch(e,t,!0)}clearData(e=!1){ot.clearData(st(this.appName,e))}clearDataListener(){ot.off(st(this.appName,!0))}}class ct{constructor(){this.appInstanceMap=on}static getInstance(){return this.instance||(this.instance=new ct),this.instance}get(e){return this.appInstanceMap.get(e)}set(e,t){this.appInstanceMap.set(e,t)}getAll(){return Array.from(this.appInstanceMap.values())}clear(){this.appInstanceMap.clear()}}function lt(){ut(),ct.getInstance().getAll().forEach((e=>{e.container&&G(e.container).disconnectedCallback()})),!window.__MICRO_APP_UMD_MODE__&&ct.getInstance().clear()}function ut(){window.__MICRO_APP_ENVIRONMENT__&&window.removeEventListener("unmount",lt,!1)}function pt(e,t,n="WINDOW"){const o=`__MICRO_APP_BOUND_${n}_FUNCTION__`;if(t[o])return t[o];if(!function(e){return m(e.__MICRO_APP_IS_CONSTRUCTOR__)?e.__MICRO_APP_IS_CONSTRUCTOR__:e.__MICRO_APP_IS_CONSTRUCTOR__=b(e)}(t)&&!function(e){return m(e.__MICRO_APP_IS_BOUND_FUNCTION__)?e.__MICRO_APP_IS_BOUND_FUNCTION__:e.__MICRO_APP_IS_BOUND_FUNCTION__=w(e)}(t)){const n=t.bind(e);for(const e in t)n[e]=t[e];return t.hasOwnProperty("prototype")&&c(n,"prototype",{value:t.prototype,configurable:!0,enumerable:!1,writable:!0}),t[o]=n}return t}const ht=["unmount","appstate-change"];function dt(e,t){var n;return ht.includes(e)||("popstate"===e||"hashchange"===e)&&(null===(n=on.get(t))||void 0===n?void 0:n.useMemoryRouter)?`${e}-${t}`:e}const mt=new Map;let ft=!1;const _t=new Map;function gt(){const{rawDocument:e,rawDocumentAddEventListener:t,rawDocumentRemoveEventListener:n}=Be;!ft&&function(){if(ft=!0,Object.getOwnPropertyDescriptor(document,"onclick"))return S("Cannot redefine document property onclick");const e=document.onclick;document.onclick=null;let t=!1;function n(e){mt.forEach((t=>{f(t)&&t.call(document,e)}))}c(document,"onclick",{configurable:!0,enumerable:!0,get(){const e=B();return e?mt.get(e):mt.get("base")},set(e){const o=B();o?mt.set(o,e):mt.set("base",e),!t&&f(e)&&(t=!0,Be.rawDocumentAddEventListener.call(Be.rawDocument,"click",n,!1))}}),e&&(document.onclick=e)}(),document.addEventListener=function(n,o,s){var r;const i=B();if(i&&(!(null===(r=on.get(i))||void 0===r?void 0:r.umdMode)||!w(o))){const e=_t.get(i);if(e){const t=e.get(n);t?t.add(o):e.set(n,new Set([o]))}else _t.set(i,new Map([[n,new Set([o])]]));o&&(o.__MICRO_APP_MARK_OPTIONS__=s)}t.call(e,n,o,s)},document.removeEventListener=function(t,o,s){var r;const i=B();if(i&&(!(null===(r=on.get(i))||void 0===r?void 0:r.umdMode)||!w(o))){const e=_t.get(i);if(e){const n=e.get(t);(null==n?void 0:n.size)&&n.has(o)&&n.delete(o)}}n.call(e,t,o,s)}}function At(e,t){const n=new Map,o=new Map,s=new Map,{rawWindow:r,rawDocument:i,rawWindowAddEventListener:a,rawWindowRemoveEventListener:c,rawSetInterval:l,rawSetTimeout:u,rawClearInterval:p,rawClearTimeout:h,rawDocumentRemoveEventListener:d}=Be;t.addEventListener=function(t,o,s){t=dt(t,e);const i=n.get(t);i?i.add(o):n.set(t,new Set([o])),o&&(o.__MICRO_APP_MARK_OPTIONS__=s),a.call(r,t,o,s)},t.removeEventListener=function(t,o,s){t=dt(t,e);const i=n.get(t);(null==i?void 0:i.size)&&i.has(o)&&i.delete(o),c.call(r,t,o,s)},t.setInterval=function(e,t,...n){const s=l.call(r,e,t,...n);return o.set(s,{handler:e,timeout:t,args:n}),s},t.setTimeout=function(e,t,...n){const o=u.call(r,e,t,...n);return s.set(o,{handler:e,timeout:t,args:n}),o},t.clearInterval=function(e){o.delete(e),p.call(r,e)},t.clearTimeout=function(e){s.delete(e),h.call(r,e)};const m=new Map,f=new Map;let _,g=new Map,A=new Map;return{recordUmdEffect:()=>{n.forEach(((e,t)=>{e.size&&m.set(t,new Set(e))})),o.size&&(g=new Map(o)),s.size&&(A=new Map(s)),_=mt.get(e);const t=_t.get(e);t&&t.forEach(((e,t)=>{e.size&&f.set(t,new Set(e))}))},rebuildUmdEffect:()=>{m.forEach(((e,n)=>{for(const o of e)t.addEventListener(n,o,null==o?void 0:o.__MICRO_APP_MARK_OPTIONS__)})),g.forEach((e=>{t.setInterval(e.handler,e.timeout,...e.args)})),A.forEach((e=>{t.setTimeout(e.handler,e.timeout,...e.args)})),_&&mt.set(e,_),f.forEach(((e,t)=>{for(const n of e)document.addEventListener(t,n,null==n?void 0:n.__MICRO_APP_MARK_OPTIONS__)})),m.clear(),g.clear(),A.clear(),f.clear(),_=null},releaseEffect:()=>{n.size&&(n.forEach(((e,t)=>{for(const n of e)c.call(r,t,n)})),n.clear()),o.size&&(o.forEach(((e,t)=>{p.call(r,t)})),o.clear()),s.size&&(s.forEach(((e,t)=>{h.call(r,t)})),s.clear()),mt.delete(e);const t=_t.get(e);t&&(t.forEach(((e,t)=>{for(const n of e)d.call(i,t,n)})),t.clear())}}}function wt(e,t){const n=Be.rawWindow.history.state,o={microAppState:a({},null==n?void 0:n.microAppState,{[e]:t})};return a({},n,o)}function bt(e){var t,n;return(null===(n=null===(t=Be.rawWindow.history.state)||void 0===t?void 0:t.microAppState)||void 0===n?void 0:n[e])||null}const yt=/&/g,vt=/=/g,Et=/%M1/g,Rt=/%M2/g;function St(e){return encodeURIComponent(Nt(e).replace(yt,"%M1").replace(vt,"%M2"))}function Pt(e){return Nt(e).replace(Et,"&").replace(Rt,"=")}function Nt(e){try{const t=decodeURIComponent(e);return e===t||Et.test(t)||Rt.test(t)?t:Nt(t)}catch(t){return e}}function Ct(e){var t,n;const o=Be.rawWindow.location,s=Mt(o.search,o.hash),r=(null===(t=s.hashQuery)||void 0===t?void 0:t[e])||(null===(n=s.searchQuery)||void 0===n?void 0:n[e]);return d(r)?Pt(r):null}function Dt(e,t){let{pathname:n,search:o,hash:s}=Be.rawWindow.location;const r=Mt(o,s),i=St(t.pathname+t.search+t.hash);let a=!1;if(s&&!o){a=!0,r.hashQuery?r.hashQuery[e]=i:r.hashQuery={[e]:i};const t=s.includes("?")?s.slice(0,s.indexOf("?")+1):s+"?";s=t+Y(r.hashQuery)}else r.searchQuery?r.searchQuery[e]=i:r.searchQuery={[e]:i},o="?"+Y(r.searchQuery);return{fullPath:n+o+s,isAttach2Hash:a}}function Mt(e,t){const n={};return""!==e&&"?"!==e&&(n.searchQuery=Q(e.slice(1))),t.includes("?")&&(n.hashQuery=Q(t.slice(t.indexOf("?")+1))),n}function Ot(e){const t=Be.rawWindow,n=t=>{if(ln(!0).includes(e)&&!t.onlyForBrowser){const t=Ct(e),n=on.get(e).sandBox.proxyWindow;let o=!1;const s=n.location.href;if(t){const s=n.location.hash;Gt(e,t,n.location),o=n.location.hash!==s}!function(e,t){const n=new PopStateEvent(dt("popstate",e),{state:bt(e)});Be.rawWindow.dispatchEvent(n),f(t.onpopstate)&&t.onpopstate(n)}(e,n),o&&function(e,t,n){const o=new HashChangeEvent(dt("hashchange",e),{newURL:t.location.href,oldURL:n});Be.rawWindow.dispatchEvent(o),f(t.onhashchange)&&t.onhashchange(o)}(e,n,s),$()}};return t.addEventListener("popstate",n),()=>{t.removeEventListener("popstate",n)}}function Lt(e,t){$(),function(e){const t=new PopStateEvent("popstate",{state:null});e&&(t.onlyForBrowser=!0),Be.rawWindow.dispatchEvent(t)}(e),t&&function(e){const t=new HashChangeEvent("hashchange",{newURL:Be.rawWindow.location.href,oldURL:e});Be.rawWindow.dispatchEvent(t)}(t)}function xt(e,t){const n=Be.rawWindow.history;function o(n){return function(...o){if(d(o[2])||y(o[2])){const s=N(o[2],t.href);if(s.origin===t.origin){Ut(n,Dt(e,s),!0,wt(e,o[0]),o[1]);const r=s.pathname+s.search+s.hash;return void(r!==t.fullPath&&Gt(e,r,t))}}It(n,o[2],o[0],o[1])}}const s=o("pushState"),r=o("replaceState");return new Proxy(n,{get(t,n){if("state"===n)return bt(e);if("pushState"===n)return s;if("replaceState"===n)return r;const o=Reflect.get(t,n);return f(o)?pt(t,o,"HISTORY"):o},set:(e,t,n)=>(Reflect.set(e,t,n),!0)})}function It(e,t,n=null,o=""){("pushState"===e?Be.rawPushState:Be.rawReplaceState).call(Be.rawWindow.history,n,o,t)}function Ut(e,t,n,o,s){const r=Be.rawWindow.location,i=r.pathname+r.search+r.hash,a=t.isAttach2Hash&&i!==t.fullPath?r.href:null;It(e,t.fullPath,o,s),i!==t.fullPath&&Lt(n,a)}function Tt(e,t){Ut("replaceState",e,!0,t)}function Wt(e){const t=Be.rawWindow;return function(...n){var o;if((null===(o=t.history.state)||void 0===o?void 0:o.microAppState)&&(!_(n[0])||!n[0].microAppState)&&(d(n[2])||y(n[2]))){const e=t.location.href;N(n[2],e).href===e&&(n[0]=a({},n[0],{microAppState:t.history.state.microAppState}))}e.apply(t.history,n),ln(!0).forEach((e=>{const t=on.get(e);t.sandBox&&t.useMemoryRouter&&!Ct(e)&&Tt(Dt(e,t.sandBox.proxyWindow.location),wt(e,bt(e)))})),$()}}const{router:kt,executeNavigationGuard:Bt,clearRouterWhenUnmount:$t}=function(){function e(e,t,n,o){Ut(t,Dt(e,n),!1,wt(e,null!=o?o:null)),$()}function t(t){return function(n){const o=M(n.name);if(o&&d(n.path)){const s=on.get(o);if(s&&(!s.sandBox||!s.useMemoryRouter))return R(`navigation failed, memory router of app ${o} is closed`);if(ln().includes(o)){const r=s.sandBox.proxyWindow.location,i=N(n.path,r.href),a=i.pathname+i.search+i.hash;if(r.fullPath!==a||Ct(o)!==a){e(o,t&&!1!==n.replace||!0===n.replace?"replaceState":"pushState",i,n.state)}}else{const t=Be.rawWindow.location,s=N(n.path,t.origin),r=s.pathname+s.search+s.hash;Ct(o)!==r&&e(o,!1===n.replace?"pushState":"replaceState",s,n.state)}}else R("navigation failed, name & path are required when use router."+(t?"replace":"push"))}}function n(e){return function(...t){return Be.rawWindow.history[e](...t)}}const o=z(),s=z();function i(e,t,n,o){$();for(const s of o)f(s)?s(t,n,e):_(s)&&f(s[e])&&s[e](t,n)}function a(e){const t=on.get(e);t.sandBox&&t.useMemoryRouter&&Tt(Dt(e,t.sandBox.proxyWindow.location),wt(e,bt(e)))}const c=Object.assign(Object.assign({current:new Map,encode:St,decode:Pt,push:t(!1),replace:t(!0),go:n("go"),back:n("back"),forward:n("forward"),beforeEach:o.add,afterEach:s.add,attachToURL:function(e){(e=M(e))&&ln().includes(e)&&a(e)},attachAllToURL:function(e=!1){ln(!e).forEach((e=>a(e)))}},function(){const e=function(){const e=new Map;return{add:function(t,n){return e.set(t,n),()=>!!e.has(t)&&e.delete(t)},get:t=>e.get(t),delete:t=>!!e.has(t)&&e.delete(t)}}();return{setDefaultPage:function(t){const n=M(t.name);return n&&t.path?e.add(n,t.path):("production"!==process.env.NODE_ENV&&S(n?"setDefaultPage: path is required":`setDefaultPage: invalid appName "${n}"`),r)},removeDefaultPage:function(t){return!!(t=M(t))&&e.delete(t)},getDefaultPage:e.get}}()),function(){let e=null;return{setBaseAppRouter:function(t){g(t)?e=new Proxy(t,{get(e,t){$();const n=Reflect.get(e,t);return f(n)?pt(e,n,"BASEROUTER"):n},set:(e,t,n)=>(Reflect.set(e,t,n),!0)}):"production"!==process.env.NODE_ENV&&S("setBaseAppRouter: Invalid base router")},getBaseAppRouter:()=>e}}());return{router:c,executeNavigationGuard:function(e,t,n){c.current.set(e,t),i(e,t,n,o.list()),I((()=>{i(e,t,n,s.list())}))},clearRouterWhenUnmount:function(e){c.current.delete(e)}}}(),Ft=["href","pathname","search","hash"],Ht=[...Ft,"host","hostname","port","protocol","search"],Kt=[...Ht,"origin","fullPath"];function jt(e,t){const n=a({name:e},t);for(const e of Kt)n[e]=t[e];return n}function Gt(e,t,n,o){const s=N(t,n.href),r=jt(e,n);for(const e of Ht)Ft.includes(e)?n.shadowLocation[e]=s[e]:n[e]=s[e];const i=jt(e,n);("auto"===o||r.fullPath!==i.fullPath&&"prevent"!==o)&&Bt(e,i,r)}function qt(e,t){const n=function(e,t){const n=Be.rawWindow.location,o=N(t),r={href:o.href,pathname:o.pathname,search:o.search,hash:o.hash},i=(t,s)=>{const i=N(t,o.href);if(i.origin===o.origin){const o=Dt(e,i);if(i.pathname===r.pathname&&i.search===r.search){let e=null;return i.hash!==r.hash&&(o.isAttach2Hash&&(e=n.href),It(s,o.fullPath)),void(i.hash?Lt(!1,e):n.reload())}if(o.isAttach2Hash)return It(s,o.fullPath),void n.reload();t=o.fullPath}return t};function c(e,t){return{enumerable:!0,configurable:!0,get:e,set:t}}function u(o,s){const i=N(o,t);i[s]===r[s]&&r.hash?Lt(!1):(It(i[s]===r[s]?"replaceState":"pushState",Dt(e,i).fullPath),n.reload())}l(o,{href:c((()=>r.href),(e=>{const t=i(e,"pushState");t&&(n.href=t)})),pathname:c((()=>r.pathname),(e=>{u(("/"+e).replace(/^\/+/,"/")+r.search+r.hash,"pathname")})),search:c((()=>r.search),(e=>{u(r.pathname+("?"+e).replace(/^\?+/,"?")+r.hash,"search")})),hash:c((()=>r.hash),(n=>{const o=r.pathname+r.search+("#"+n).replace(/^#+/,"#"),s=N(o,t);s.hash!==r.hash&&Ut("pushState",Dt(e,s),!1)})),fullPath:c((()=>r.pathname+r.search+r.hash),s)});const p=e=>function(t){const o=i(t,"assign"===e?"pushState":"replaceState");o&&n[e](o)};return a(o,{assign:p("assign"),replace:p("replace"),reload:e=>n.reload(e),shadowLocation:r})}(e,t);return{microLocation:n,microHistory:xt(e,n)}}function Vt(e,t,n){n&&Gt(e,n,t,"prevent"),Tt(Dt(e,t),wt(e,null)),function(e,t){Bt(e,jt(e,t),jt(e,t))}(e,t)}function Qt(e){Tt(function(e,t){var n,o,s,r;let{pathname:i,search:a,hash:c}=t||Be.rawWindow.location;const l=Mt(a,c);let u=!1;if(null===(n=l.hashQuery)||void 0===n?void 0:n[e]){u=!0,null===(o=l.hashQuery)||void 0===o||delete o[e];const t=Y(l.hashQuery);c=c.slice(0,c.indexOf("?")+Number(Boolean(t)))+t}else if(null===(s=l.searchQuery)||void 0===s?void 0:s[e]){null===(r=l.searchQuery)||void 0===r||delete r[e];const t=Y(l.searchQuery);a=t?"?"+t:""}return{fullPath:i+a+c,isAttach2Hash:u}}(e),function(e,t){return _(null==t?void 0:t.microAppState)&&(p(t.microAppState[e])||delete t.microAppState[e],Object.keys(t.microAppState).length||delete t.microAppState),a({},t)}(e,Be.rawWindow.history.state))}function Yt(e,t){const n=p(t)?Be.rawWindow.fetch:t;return f(n)?function(t,o,...s){return(d(t)||y(t))&&(t=N(t,e).toString()),$(),n.call(Be.rawWindow,t,o,...s)}:n}function zt(e,t){const n=p(t)?Be.rawWindow.XMLHttpRequest:t;return b(n)?class extends n{open(t,n,...o){(d(n)&&!/^f(ile|tp):\/\//.test(n)||y(n))&&(n=N(n,e).toString()),$(),super.open(t,n,...o)}}:n}const{createMicroEventSource:Xt,clearMicroEventSource:Jt}=function(){let e;return{createMicroEventSource:function(t,n,o){const s=p(o)?Be.rawWindow.EventSource:o;return b(s)?class extends s{constructor(o,s,...r){if((d(o)||y(o))&&(o=N(o,n).toString()),$(),super(o,s,...r),e){const n=e.get(t);n?n.add(this):e.set(t,new Set([this]))}else e=new Map([[t,new Set([this])]])}close(){var n;super.close(),null===(n=e.get(t))||void 0===n||n.delete(this)}}:s},clearMicroEventSource:function(t){const n=null==e?void 0:e.get(t);(null==n?void 0:n.size)&&(n.forEach((e=>{e.close()})),n.clear())}}}(),Zt=["window","self","globalThis"];class en{constructor(e,t){this.scopeProperties=[],this.escapeProperties=[],this.injectedKeys=new Set,this.escapeKeys=new Set,this.active=!1,this.microAppWindow={},this.adapter=new Pe,this.getSpecialProperties(e),this.proxyWindow=this.createProxyWindow(e),a(this,At(e,this.microAppWindow)),this.initStaticGlobalKeys(this.microAppWindow,e,t)}start({umdMode:e,baseroute:t,useMemoryRouter:n,defaultPage:o,disablePatchRequest:s}){this.active||(this.active=!0,n?(p(this.microAppWindow.location)&&this.setMicroAppRouter(this.microAppWindow,this.microAppWindow.__MICRO_APP_NAME__,this.microAppWindow.__MICRO_APP_URL__),this.initRouteState(o),this.removeHistoryListener=Ot(this.microAppWindow.__MICRO_APP_NAME__)):this.microAppWindow.__MICRO_APP_BASE_ROUTE__=this.microAppWindow.__MICRO_APP_BASE_URL__=t,e||this.initGlobalKeysWhenStart(this.microAppWindow,this.microAppWindow.__MICRO_APP_NAME__,this.microAppWindow.__MICRO_APP_URL__,s),1==++en.activeCount&&(gt(),Ie(),window.__MICRO_APP_ENVIRONMENT__&&(ut(),window.addEventListener("unmount",lt,!1)),function(){const e=Be.rawWindow;e.history.pushState=Wt(Be.rawPushState),e.history.replaceState=Wt(Be.rawReplaceState)}()),Be.rawWindow._babelPolyfill&&(Be.rawWindow._babelPolyfill=!1))}stop({umdMode:e,keepRouteState:t,clearEventSource:n,clearData:o}){this.active&&(this.releaseEffect(),this.microAppWindow.microApp.clearDataListener(),this.microAppWindow.microApp.clearGlobalDataListener(),o&&this.microAppWindow.microApp.clearData(),this.removeHistoryListener&&(this.clearRouteState(t),this.removeHistoryListener()),n&&Jt(this.microAppWindow.__MICRO_APP_NAME__),e||(this.injectedKeys.forEach((e=>{Reflect.deleteProperty(this.microAppWindow,e)})),this.injectedKeys.clear(),this.escapeKeys.forEach((e=>{Reflect.deleteProperty(Be.rawWindow,e)})),this.escapeKeys.clear()),0==--en.activeCount&&(document.addEventListener=Be.rawDocumentAddEventListener,document.removeEventListener=Be.rawDocumentRemoveEventListener,We(),function(){const e=Be.rawWindow;e.history.pushState=Be.rawPushState,e.history.replaceState=Be.rawReplaceState}()),this.active=!1)}recordUmdSnapshot(){this.recordUmdEffect(),function(e){const t=e.appName;e.umdDataListeners={global:new Set,normal:new Set};const n=ot.eventList.get("global");if(n)for(const o of n.callbacks)t===o.__APP_NAME__&&e.umdDataListeners.global.add(o);const o=ot.eventList.get(st(t,!0));o&&(e.umdDataListeners.normal=new Set(o.callbacks))}(this.microAppWindow.microApp)}rebuildUmdSnapshot(){this.rebuildUmdEffect(),function(e){for(const t of e.umdDataListeners.global)e.addGlobalDataListener(t,t.__AUTO_TRIGGER__);for(const t of e.umdDataListeners.normal)e.addDataListener(t,t.__AUTO_TRIGGER__)}(this.microAppWindow.microApp)}getSpecialProperties(e){var t;this.scopeProperties=this.scopeProperties.concat(this.adapter.staticScopeProperties),_(_n.options.plugins)&&(this.commonActionForSpecialProperties(_n.options.plugins.global),this.commonActionForSpecialProperties(null===(t=_n.options.plugins.modules)||void 0===t?void 0:t[e]))}commonActionForSpecialProperties(e){if(i(e))for(const t of e)_(t)&&(i(t.scopeProperties)&&(this.scopeProperties=this.scopeProperties.concat(t.scopeProperties)),i(t.escapeProperties)&&(this.escapeProperties=this.escapeProperties.concat(t.escapeProperties)))}createProxyWindow(e){const t=Be.rawWindow,n=new Map;return new Proxy(this.microAppWindow,{get:(n,o)=>{if(k(e),Reflect.has(n,o)||d(o)&&/^__MICRO_APP_/.test(o)||this.scopeProperties.includes(o))return Reflect.get(n,o);const s=Reflect.get(t,o);return f(s)?pt(t,s):s},set:(e,n,o)=>{if(this.active){if(this.adapter.escapeSetterKeyList.includes(n))Reflect.set(t,n,o);else if(u.call(e,n)||!u.call(t,n)||this.scopeProperties.includes(n))Reflect.set(e,n,o),this.injectedKeys.add(n);else{const s=Object.getOwnPropertyDescriptor(t,n),{configurable:r,enumerable:i,writable:a,set:l}=s;c(e,n,{value:o,configurable:r,enumerable:i,writable:null!=a?a:!!l}),this.injectedKeys.add(n)}(this.escapeProperties.includes(n)||this.adapter.staticEscapeProperties.includes(n)&&!Reflect.has(t,n))&&!this.scopeProperties.includes(n)&&(Reflect.set(t,n,o),this.escapeKeys.add(n))}return!0},has:(e,n)=>this.scopeProperties.includes(n)?n in e:n in e||n in t,getOwnPropertyDescriptor:(e,o)=>{if(u.call(e,o))return n.set(o,"target"),Object.getOwnPropertyDescriptor(e,o);if(u.call(t,o)){n.set(o,"rawWindow");const e=Object.getOwnPropertyDescriptor(t,o);return e&&!e.configurable&&(e.configurable=!0),e}},defineProperty:(e,o,s)=>"rawWindow"===n.get(o)?Reflect.defineProperty(t,o,s):Reflect.defineProperty(e,o,s),ownKeys:e=>Reflect.ownKeys(t).concat(Reflect.ownKeys(e)).filter((function(e){return!(e in this)&&(this[e]=!0)}),Object.create(null)),deleteProperty:(e,n)=>!u.call(e,n)||(this.injectedKeys.has(n)&&this.injectedKeys.delete(n),this.escapeKeys.has(n)&&Reflect.deleteProperty(t,n),Reflect.deleteProperty(e,n))})}initStaticGlobalKeys(e,t,n){e.__MICRO_APP_ENVIRONMENT__=!0,e.__MICRO_APP_NAME__=t,e.__MICRO_APP_URL__=n,e.__MICRO_APP_PUBLIC_PATH__=O(n),e.__MICRO_APP_WINDOW__=e,e.rawWindow=Be.rawWindow,e.rawDocument=Be.rawDocument,e.microApp=a(new at(t),{removeDomScope:$,pureCreateElement:F,router:kt}),this.setProxyDocument(e,t),this.setMappingPropertiesWithRawDescriptor(e)}setProxyDocument(e,t){const{proxyDocument:n,MicroDocument:o}=this.createProxyDocument(t);l(e,{document:{configurable:!1,enumerable:!0,get:()=>(k(t),n)},Document:{configurable:!1,enumerable:!1,get:()=>(k(t),o)}})}setMappingPropertiesWithRawDescriptor(e){let t,n;const o=Be.rawWindow;o===o.parent?t=n=this.proxyWindow:(t=o.top,n=o.parent),c(e,"top",this.createDescriptorForMicroAppWindow("top",t)),c(e,"parent",this.createDescriptorForMicroAppWindow("parent",n)),Zt.forEach((t=>{c(e,t,this.createDescriptorForMicroAppWindow(t,this.proxyWindow))}))}createDescriptorForMicroAppWindow(e,t){const{configurable:n=!0,enumerable:o=!0,writable:s,set:r}=Object.getOwnPropertyDescriptor(Be.rawWindow,e)||{writable:!0};return{value:t,configurable:n,enumerable:o,writable:null!=s?s:!!r}}initGlobalKeysWhenStart(e,t,n,o){e.hasOwnProperty=t=>u.call(e,t)||u.call(Be.rawWindow,t),this.setHijackProperty(e,t),o||this.patchRequestApi(e,t,n)}setHijackProperty(e,t){let n,o;l(e,{eval:{configurable:!0,enumerable:!1,get:()=>(k(t),n||eval),set:e=>{n=e}},Image:{configurable:!0,enumerable:!1,get:()=>(k(t),o||Be.ImageProxy),set:e=>{o=e}}})}patchRequestApi(e,t,n){let o=Yt(n),s=zt(n),r=Xt(t,n);l(e,{fetch:{configurable:!0,enumerable:!0,get:()=>o,set(e){o=Yt(n,e)}},XMLHttpRequest:{configurable:!0,enumerable:!0,get:()=>s,set(e){s=zt(n,e)}},EventSource:{configurable:!0,enumerable:!0,get:()=>r,set(e){r=Xt(t,n,e)}}})}setMicroAppRouter(e,t,n){const{microLocation:o,microHistory:s}=qt(t,n);l(e,{location:{configurable:!1,enumerable:!0,get:()=>o,set:e=>{Be.rawWindow.location=e}},history:{configurable:!0,enumerable:!0,get:()=>s}})}initRouteState(e){!function(e,t,n){const o=Ct(e);o?Gt(e,o,t,"auto"):Vt(e,t,n)}(this.proxyWindow.__MICRO_APP_NAME__,this.proxyWindow.location,e)}clearRouteState(e){!function(e,t,n,o){if(!o){const{pathname:o,search:s,hash:r}=N(t);Gt(e,o+s+r,n,"prevent")}Qt(e),$t(e)}(this.proxyWindow.__MICRO_APP_NAME__,this.proxyWindow.__MICRO_APP_URL__,this.proxyWindow.location,e)}setRouteInfoForKeepAliveApp(){Vt(this.proxyWindow.__MICRO_APP_NAME__,this.proxyWindow.location)}removeRouteInfoForKeepAliveApp(){Qt(this.proxyWindow.__MICRO_APP_NAME__)}createProxyDocument(e){const t=Be.rawDocument,n=Be.rawRootDocument,o=function(n,o){const s=Be.rawCreateElement.call(t,n,o);return s.__MICRO_APP_NAME__=e,s},s=new Proxy(t,{get:(n,r)=>{if(k(e),function(e){const t=Be.rawDocument.firstElementChild;t&&t.parentNode!==e&&(Ne(t,e),P((()=>{Ne(t,Be.rawDocument)})))}(s),"createElement"===r)return o;if(r===Symbol.toStringTag)return"ProxyDocument";if("defaultView"===r)return this.proxyWindow;const i=Reflect.get(n,r);return f(i)?pt(t,i,"DOCUMENT"):i},set:(e,t,n)=>(Reflect.set(e,t,n),!0)});class r{static[Symbol.hasInstance](e){let t=e;for(;t=Object.getPrototypeOf(t);)if(t===r.prototype)return!0;return e===s||e instanceof n}}return Object.setPrototypeOf(r,n),Object.setPrototypeOf(r.prototype,new Proxy(n.prototype,{get(n,o){k(e);const s=Reflect.get(n,o);return f(s)?pt(t,s,"DOCUMENT"):s},set:(e,t,n)=>(Reflect.set(e,t,n),!0)})),{proxyDocument:s,MicroDocument:r}}}function tn(e,t,n,o){var s;if(!e)return R(`element does not exist in lifecycle ${n}`,t);e=G(e),$();const r=a({name:t,container:e},o&&{error:o}),i=new CustomEvent(n,{detail:r});!function(e,t){Object.defineProperties(e,{currentTarget:{get:()=>t},target:{get:()=>t}})}(i,e),f(null===(s=_n.options.lifeCycles)||void 0===s?void 0:s[n])&&_n.options.lifeCycles[n](i),e.dispatchEvent(i)}function nn(e,t,n={}){const o=new CustomEvent(dt(e,t),{detail:n});window.dispatchEvent(o)}en.activeCount=0;const on=new Map;class sn{constructor({name:e,url:t,container:n,scopecss:o,useSandbox:s,inline:r,esmodule:i,ssrUrl:a,isPrefetch:c}){this.state=oe.CREATED,this.keepAliveState=null,this.keepAliveContainer=null,this.loadSourceLevel=0,this.umdHookMount=null,this.umdHookUnmount=null,this.libraryName=null,this.umdMode=!1,this.sandBox=null,this.keepRouteState=!1,this.fiber=!1,this.useMemoryRouter=!0,this.name=e,this.url=t,this.useSandbox=s,this.scopecss=this.useSandbox&&o,this.inline=null!=r&&r,this.esmodule=null!=i&&i,this.container=null!=n?n:null,this.ssrUrl=null!=a?a:"",this.isPrefetch=null!=c&&c,on.set(this.name,this),this.source={html:null,links:new Set,scripts:new Set},this.loadSourceCode(),this.useSandbox&&(this.sandBox=new en(e,t))}loadSourceCode(){this.state=oe.LOADING,ue.getInstance().run(this,nt)}onLoad(e){2==++this.loadSourceLevel&&(this.source.html=e,this.state=oe.LOADED,this.isPrefetch||oe.UNMOUNT===this.state||G(this.container).mount(this))}onLoadError(e){this.loadSourceLevel=-1,oe.UNMOUNT!==this.state&&(this.onerror(e),this.state=oe.LOAD_FAILED)}mount({container:e,inline:t,esmodule:n,useMemoryRouter:o,baseroute:s,keepRouteState:r,defaultPage:i,disablePatchRequest:a,fiber:c}){var l,u;if(this.container=e,this.inline=t,this.esmodule=n,this.keepRouteState=r,this.fiber=c,this.useMemoryRouter=o,2!==this.loadSourceLevel)return void(this.state=oe.LOADING);let h;if(tn(this.container,this.name,se.BEFOREMOUNT),this.state=oe.MOUNTING,H(this.source.html,this.container,!this.umdMode),null===(l=this.sandBox)||void 0===l||l.start({umdMode:this.umdMode,baseroute:s,useMemoryRouter:o,defaultPage:i,disablePatchRequest:a}),this.umdMode){null===(u=this.sandBox)||void 0===u||u.rebuildUmdSnapshot();try{h=this.umdHookMount()}catch(e){R("an error occurred in the mount function \n",this.name,e)}this.handleMounted(h)}else{let e=!1;!function(e,t){const n=e.fiber?[]:null,o=Array.from(e.source.scripts),s=[],r=[];for(const i of o){const o=ve.script.getInfo(i),a=o.appSpace[e.name];a.defer||a.async?(o.isExternal&&!o.code?s.push(le(i,e.name)):s.push(o.code),r.push([i,o]),He(e,o)&&(t.moduleCount=t.moduleCount?++t.moduleCount:1)):J(n,(()=>{Je(i,e,o),t(!1)}))}s.length?x(s,(e=>{const t=r[e.index][1];t.code=t.code||e.data}),(n=>{t.errorCount=t.errorCount?++t.errorCount:1,R(n,e.name)}),(()=>{r.forEach((([o,s])=>{s.code&&J(n,(()=>{Je(o,e,s,t),!He(e,s)&&t(!1)}))})),n?(n.push((()=>Promise.resolve(t(p(t.moduleCount)||t.errorCount===s.length)))),Z(n)):t(p(t.moduleCount)||t.errorCount===s.length)})):n?(n.push((()=>Promise.resolve(t(!0)))),Z(n)):t(!0)}(this,(t=>{if(!this.umdMode){const{mount:e,unmount:t}=this.getUmdLibraryHooks();if(this.umdHookUnmount=t,f(e)&&f(t)){this.umdHookMount=e,this.umdMode=!0,this.sandBox&&(this.sandBox.proxyWindow.__MICRO_APP_UMD_MODE__=!0);try{h=this.umdHookMount(_n.getData(this.name,!0))}catch(e){R("an error occurred in the mount function \n",this.name,e)}}}e||!0!==t&&!this.umdMode||(e=!0,this.handleMounted(h))}))}}handleMounted(e){A(e)?e.then((()=>this.dispatchMountedEvent())).catch((e=>this.onerror(e))):this.dispatchMountedEvent()}dispatchMountedEvent(){oe.UNMOUNT!==this.state&&(this.state=oe.MOUNTED,te(this.getGlobalEventListener(re.ONMOUNT),this.name,`window.${re.ONMOUNT}`,_n.getData(this.name,!0)),tn(this.container,this.name,se.MOUNTED))}unmount({destroy:e,clearData:t,unmountcb:n}){let o;if(this.state===oe.LOAD_FAILED&&(e=!0),this.state=oe.UNMOUNT,this.keepAliveState=null,this.keepAliveContainer=null,f(this.umdHookUnmount))try{o=this.umdHookUnmount(_n.getData(this.name,!0))}catch(e){R("an error occurred in the unmount function \n",this.name,e)}te(this.getGlobalEventListener(re.ONUNMOUNT),this.name,`window.${re.ONUNMOUNT}`),nn("unmount",this.name),this.handleUnmounted(e,t,o,n)}handleUnmounted(e,t,n,o){A(n)?n.then((()=>this.actionsForUnmount(e,t,o))).catch((()=>this.actionsForUnmount(e,t,o))):this.actionsForUnmount(e,t,o)}actionsForUnmount(e,t,n){var o,s;e?this.actionsForCompletelyDestroy():this.umdMode&&this.container.childElementCount&&H(this.container,this.source.html,!1),this.umdMode&&(null===(o=this.sandBox)||void 0===o||o.recordUmdSnapshot()),(t||e)&&_n.clearData(this.name),null===(s=this.sandBox)||void 0===s||s.stop({umdMode:this.umdMode,keepRouteState:this.keepRouteState&&!e,clearEventSource:!this.umdMode||e,clearData:t||e}),ln().length||(Te=!1,Element.prototype.setAttribute=Be.rawSetAttribute),tn(this.container,this.name,se.UNMOUNT),this.container.innerHTML="",this.container=null,n&&n()}actionsForCompletelyDestroy(){!this.useSandbox&&this.umdMode&&delete window[this.libraryName],ve.script.deleteInlineInfo(this.source.scripts),on.delete(this.name)}hiddenKeepAliveApp(e){var t;const n=this.container;H(this.container,this.keepAliveContainer?this.keepAliveContainer:this.keepAliveContainer=document.createElement("div"),!1),this.container=this.keepAliveContainer,this.keepAliveState=ie.KEEP_ALIVE_HIDDEN,nn("appstate-change",this.name,{appState:"afterhidden"}),tn(n,this.name,se.AFTERHIDDEN),null===(t=this.sandBox)||void 0===t||t.removeRouteInfoForKeepAliveApp(),e&&e()}showKeepAliveApp(e){var t;nn("appstate-change",this.name,{appState:"beforeshow"}),tn(e,this.name,se.BEFORESHOW),H(this.container,e,!1),this.container=e,this.keepAliveState=ie.KEEP_ALIVE_SHOW,null===(t=this.sandBox)||void 0===t||t.setRouteInfoForKeepAliveApp(),nn("appstate-change",this.name,{appState:"aftershow"}),tn(this.container,this.name,se.AFTERSHOW)}onerror(e){tn(this.container,this.name,se.ERROR,e)}getAppState(){return this.state}getKeepAliveState(){return this.keepAliveState}getUmdLibraryHooks(){var e,t,n,o;if(oe.UNMOUNT!==this.state){const s=null!==(t=null===(e=this.sandBox)||void 0===e?void 0:e.proxyWindow)&&void 0!==t?t:Be.rawWindow;return this.libraryName=G(this.container).getAttribute("library")||`micro-app-${this.name}`,g(s[this.libraryName])?s[this.libraryName]:{mount:null===(n=this.sandBox)||void 0===n?void 0:n.proxyWindow.mount,unmount:null===(o=this.sandBox)||void 0===o?void 0:o.proxyWindow.unmount}}return{}}getGlobalEventListener(e){var t;const n=null===(t=this.sandBox)||void 0===t?void 0:t.proxyWindow[e];return f(n)?n:null}}function rn(e){class n extends HTMLElement{constructor(){super(),this.isWaiting=!1,this.cacheData=null,this.connectedCount=0,this.connectStateMap=new Map,this.appName="",this.appUrl="",this.ssrUrl="",this.version=t,this.handleAttributeUpdate=()=>{if(this.isWaiting=!1,!this.connectStateMap.get(this.connectedCount))return;const e=M(this.getAttribute("name")),t=D(this.getAttribute("url"),this.appName);if(this.legalAttribute("name",e)&&this.legalAttribute("url",t)){const n=on.get(e);if(e!==this.appName&&n&&oe.UNMOUNT!==n.getAppState()&&ie.KEEP_ALIVE_HIDDEN!==n.getKeepAliveState()&&!n.isPrefetch)return this.setAttribute("name",this.appName),R(`app name conflict, an app named ${e} is running`);e===this.appName&&t===this.appUrl||(e===this.appName?this.handleUnmount(!0,(()=>{this.actionsForAttributeChange(e,t,n)})):this.getKeepAliveModeResult()?(this.handleHiddenKeepAliveApp(),this.actionsForAttributeChange(e,t,n)):this.handleUnmount(this.getDestroyCompatibleResult(),(()=>{this.actionsForAttributeChange(e,t,n)})))}else e!==this.appName&&this.setAttribute("name",this.appName)},Te||(Te=!0,Element.prototype.setAttribute=function(e,t){if(/^micro-app(-\S+)?/i.test(this.tagName)&&"data"===e)if(_(t)){const e={};Object.getOwnPropertyNames(t).forEach((n=>{d(n)&&0===n.indexOf("__")||(e[n]=t[n])})),this.data=e}else"[object Object]"!==t&&S("property data must be an object",this.getAttribute("name"));else{const n=this.__MICRO_APP_NAME__||B();if(n&&on.has(n)&&(("src"===e||"srcset"===e)&&/^(img|script)$/i.test(this.tagName)||"href"===e&&/^link$/i.test(this.tagName))){const e=on.get(n);t=L(t,e.url)}Be.rawSetAttribute.call(this,e,t)}})}static get observedAttributes(){return["name","url"]}connectedCallback(){const e=++this.connectedCount;this.connectStateMap.set(e,!0),P((()=>{this.connectStateMap.get(e)&&(tn(this,this.appName,se.CREATED),this.handleConnected())}))}disconnectedCallback(){this.connectStateMap.set(this.connectedCount,!1),this.handleDisconnected()}reload(e){return new Promise((t=>{const n=()=>{this.removeEventListener(se.MOUNTED,n),this.removeEventListener(se.AFTERSHOW,n),t(!0)};this.addEventListener(se.MOUNTED,n),this.addEventListener(se.AFTERSHOW,n),this.handleDisconnected(e,(()=>{this.handleConnected()}))}))}handleDisconnected(e=!1,t){const n=on.get(this.appName);n&&n.getAppState()!==oe.UNMOUNT&&n.getKeepAliveState()!==ie.KEEP_ALIVE_HIDDEN&&(this.getKeepAliveModeResult()&&!e?this.handleHiddenKeepAliveApp(t):this.handleUnmount(e||this.getDestroyCompatibleResult(),t))}attributeChangedCallback(e,t,n){if(this.legalAttribute(e,n)&&this[e===ne.NAME?"appName":"appUrl"]!==n)if(e!==ne.URL||this.appUrl)if(e!==ne.NAME||this.appName)this.isWaiting||(this.isWaiting=!0,P(this.handleAttributeUpdate));else{const e=M(n);if(!e)return R(`Invalid attribute name ${n}`,this.appName);this.cacheData&&(_n.setData(e,this.cacheData),this.cacheData=null),this.appName=e,e!==n&&this.setAttribute("name",this.appName),this.handleInitialNameAndUrl()}else{if(!(n=D(n,this.appName)))return R(`Invalid attribute url ${n}`,this.appName);this.appUrl=n,this.handleInitialNameAndUrl()}}handleInitialNameAndUrl(){this.connectStateMap.get(this.connectedCount)&&this.handleConnected()}handleConnected(){if(this.appName&&this.appUrl)if(this.getDisposeResult("shadowDOM")&&!this.shadowRoot&&f(this.attachShadow)&&this.attachShadow({mode:"open"}),this.updateSsrUrl(this.appUrl),on.has(this.appName)){const e=on.get(this.appName),t=e.ssrUrl||e.url,n=this.ssrUrl||this.appUrl;e.getKeepAliveState()===ie.KEEP_ALIVE_HIDDEN&&e.url===this.appUrl?this.handleShowKeepAliveApp(e):t===n&&(e.getAppState()===oe.UNMOUNT||e.isPrefetch&&e.scopecss===this.isScopecss()&&e.useSandbox===this.isSandbox())?this.handleAppMount(e):e.isPrefetch||e.getAppState()===oe.UNMOUNT?("production"!==process.env.NODE_ENV&&e.scopecss===this.isScopecss()&&e.useSandbox===this.isSandbox()&&S(`the ${e.isPrefetch?"prefetch":"unmounted"} app with url: ${t} replaced by a new app with url: ${n}`,this.appName),this.handleCreateApp()):R(`app name conflict, an app named: ${this.appName} with url: ${t} is running`)}else this.handleCreateApp()}actionsForAttributeChange(e,t,n){var o;this.updateSsrUrl(t),this.appName=e,this.appUrl=t,(null!==(o=this.shadowRoot)&&void 0!==o?o:this).innerHTML="",e!==this.getAttribute("name")&&this.setAttribute("name",this.appName),n?n.getKeepAliveState()===ie.KEEP_ALIVE_HIDDEN?n.url===this.appUrl?this.handleShowKeepAliveApp(n):R(`app name conflict, an app named ${this.appName} is running`):n.url===this.appUrl&&n.ssrUrl===this.ssrUrl?this.handleAppMount(n):this.handleCreateApp():this.handleCreateApp()}legalAttribute(e,t){return!(!d(t)||!t)||(R(`unexpected attribute ${e}, please check again`,this.appName),!1)}handleCreateApp(){var e;on.has(this.appName)&&on.get(this.appName).actionsForCompletelyDestroy(),new sn({name:this.appName,url:this.appUrl,scopecss:this.isScopecss(),useSandbox:this.isSandbox(),inline:this.getDisposeResult("inline"),esmodule:this.getDisposeResult("esmodule"),container:null!==(e=this.shadowRoot)&&void 0!==e?e:this,ssrUrl:this.ssrUrl})}handleAppMount(e){e.isPrefetch=!1,P((()=>this.mount(e)))}mount(e){var t;e.mount({container:null!==(t=this.shadowRoot)&&void 0!==t?t:this,inline:this.getDisposeResult("inline"),esmodule:this.getDisposeResult("esmodule"),useMemoryRouter:!this.getDisposeResult("disable-memory-router"),baseroute:this.getBaseRouteCompatible(),keepRouteState:this.getDisposeResult("keep-router-state"),defaultPage:this.getDefaultPageValue(),hiddenRouter:this.getDisposeResult("hidden-router"),disablePatchRequest:this.getDisposeResult("disable-patch-request"),fiber:this.getDisposeResult("fiber")})}handleUnmount(e,t){const n=on.get(this.appName);n&&n.getAppState()!==oe.UNMOUNT&&n.unmount({destroy:e,clearData:this.getDisposeResult("clear-data"),unmountcb:t})}handleHiddenKeepAliveApp(e){const t=on.get(this.appName);t&&t.getAppState()!==oe.UNMOUNT&&t.getKeepAliveState()!==ie.KEEP_ALIVE_HIDDEN&&t.hiddenKeepAliveApp(e)}handleShowKeepAliveApp(e){P((()=>{var t;return e.showKeepAliveApp(null!==(t=this.shadowRoot)&&void 0!==t?t:this)}))}getDisposeResult(e){return(this.compatibleSpecialProperties(e)||!!_n.options[e])&&this.compatibleDisableSpecialProperties(e)}compatibleSpecialProperties(e){return"disable-scopecss"===e?this.hasAttribute("disable-scopecss")||this.hasAttribute("disableScopecss"):"disable-sandbox"===e?this.hasAttribute("disable-sandbox")||this.hasAttribute("disableSandbox"):this.hasAttribute(e)}compatibleDisableSpecialProperties(e){return"disable-scopecss"===e?"false"!==this.getAttribute("disable-scopecss")&&"false"!==this.getAttribute("disableScopecss"):"disable-sandbox"===e?"false"!==this.getAttribute("disable-sandbox")&&"false"!==this.getAttribute("disableSandbox"):"false"!==this.getAttribute(e)}isScopecss(){return!(this.getDisposeResult("disable-scopecss")||this.getDisposeResult("shadowDOM"))}isSandbox(){return!this.getDisposeResult("disable-sandbox")}getBaseRouteCompatible(){var e,t;return null!==(t=null!==(e=this.getAttribute("baseroute"))&&void 0!==e?e:this.getAttribute("baseurl"))&&void 0!==t?t:""}getDestroyCompatibleResult(){return this.getDisposeResult("destroy")||this.getDisposeResult("destory")}getKeepAliveModeResult(){return this.getDisposeResult("keep-alive")&&!this.getDestroyCompatibleResult()}updateSsrUrl(e){if(this.getDisposeResult("ssr"))if(this.getDisposeResult("disable-memory-router")||this.getDisposeResult("disableSandbox")){const t=Be.rawWindow.location;this.ssrUrl=L(t.pathname+t.search,e)}else{let t=function(e,t){const n=Ct(e);if(!n)return"";const o=N(n,t);return o.origin+o.pathname+o.search}(this.appName,e);const n=this.getDefaultPageValue();if(!t&&n){const o=N(n,e);t=o.origin+o.pathname+o.search}this.ssrUrl=t}else this.ssrUrl&&(this.ssrUrl="")}getDefaultPageValue(){return kt.getDefaultPage(this.appName)||this.getAttribute("default-page")||this.getAttribute("defaultPage")||""}set data(e){this.appName?_n.setData(this.appName,e):this.cacheData=e}get data(){return this.appName?_n.getData(this.appName,!0):this.cacheData?this.cacheData:null}}Be.rawWindow.customElements.define(e,n)}function an(e){if(!n)return R("preFetch is only supported in browser environment");I((()=>{f(e)&&(e=e()),i(e)&&e.reduce(((e,t)=>e.then((()=>{return e=t,U((t=>{var n,o,s,r,i,a;if(_(e)&&navigator.onLine)if(e.name=M(e.name),e.url=D(e.url,e.name),e.name&&e.url&&!on.has(e.name)){const c=new sn({name:e.name,url:e.url,scopecss:!(null!==(o=null!==(n=e["disable-scopecss"])&&void 0!==n?n:e.disableScopecss)&&void 0!==o?o:_n.options["disable-scopecss"]),useSandbox:!(null!==(r=null!==(s=e["disable-sandbox"])&&void 0!==s?s:e.disableSandbox)&&void 0!==r?r:_n.options["disable-sandbox"]),inline:null!==(i=e.inline)&&void 0!==i?i:_n.options.inline,esmodule:null!==(a=e.esmodule)&&void 0!==a?a:_n.options.esmodule,isPrefetch:!0}),l=c.onLoad,u=c.onLoadError;c.onLoad=e=>{t(),l.call(c,e)},c.onLoadError=e=>{t(),u.call(c,e)}}else t();else t()}));var e}))),Promise.resolve())}))}function cn(e,t,n){if(i(e)){const o=e.filter((e=>d(e)&&e.includes(`.${t}`)&&!n.hasInfo(e)));x(o.map((e=>le(e))),(e=>{const s=o[e.index];"js"===t?n.hasInfo(s)||n.setInfo(s,{code:e.data,isExternal:!1,appSpace:{}}):n.hasInfo(s)||n.setInfo(s,{code:e.data,appSpace:{}})}),(e=>{R(e)}))}}function ln(e=!1){const t=[];return on.forEach(((n,o)=>{oe.UNMOUNT===n.getAppState()||n.isPrefetch||e&&ie.KEEP_ALIVE_HIDDEN===n.getKeepAliveState()||t.push(o)})),t}function un(){return Array.from(on.keys())}function pn(e,t){const n=on.get(M(e));return new Promise((o=>{if(n)if(n.getAppState()===oe.UNMOUNT||n.isPrefetch)(null==t?void 0:t.destroy)&&n.actionsForCompletelyDestroy(),o(!0);else if(n.getKeepAliveState()===ie.KEEP_ALIVE_HIDDEN)(null==t?void 0:t.destroy)?n.unmount({destroy:!0,clearData:!0,unmountcb:o.bind(null,!0)}):(null==t?void 0:t.clearAliveState)?n.unmount({destroy:!1,clearData:!!t.clearData,unmountcb:o.bind(null,!0)}):o(!0);else{const e=G(n.container),s=()=>{e.removeEventListener(se.UNMOUNT,s),e.removeEventListener(se.AFTERHIDDEN,r),o(!0)},r=()=>{e.removeEventListener(se.UNMOUNT,s),e.removeEventListener(se.AFTERHIDDEN,r),o(!0)};if(e.addEventListener(se.UNMOUNT,s),e.addEventListener(se.AFTERHIDDEN,r),null==t?void 0:t.destroy){let t,n;e.hasAttribute("destroy")&&(t=e.getAttribute("destroy")),e.hasAttribute("destory")&&(n=e.getAttribute("destory")),e.setAttribute("destroy","true"),e.parentNode.removeChild(e),e.removeAttribute("destroy"),d(t)&&e.setAttribute("destroy",t),d(n)&&e.setAttribute("destory",n)}else if((null==t?void 0:t.clearAliveState)&&e.hasAttribute("keep-alive")){const n=e.getAttribute("keep-alive");let o;e.removeAttribute("keep-alive"),t.clearData&&(o=e.getAttribute("clear-data"),e.setAttribute("clear-data","true")),e.parentNode.removeChild(e),e.setAttribute("keep-alive",n),d(o)&&e.setAttribute("clear-data",o)}else{let n;(null==t?void 0:t.clearData)&&(n=e.getAttribute("clear-data"),e.setAttribute("clear-data","true")),e.parentNode.removeChild(e),d(n)&&e.setAttribute("clear-data",n)}}else S(`app ${e} does not exist`),o(!1)}))}function hn(e){return Array.from(on.keys()).reduce(((t,n)=>t.then((()=>pn(n,e)))),Promise.resolve(!0))}function dn(e,t){return new Promise((n=>{const o=on.get(M(e));if(o){const s=o.container&&G(o.container);s?n(s.reload(t)):(S(`app ${e} is not rendered, cannot use reload`),n(!1))}else S(`app ${e} does not exist`),n(!1)}))}function mn(e){return new Promise((t=>{if(!_(e))return R("renderApp options must be an object");const n=v(e.container)?e.container:d(e.container)?document.querySelector(e.container):null;if(!v(n))return R("Target container is not a DOM element.");const o=F(_n.tagName);for(const t in e)if("onDataChange"===t)f(e[t])&&o.addEventListener("datachange",e[t]);else if("lifeCycles"===t){const n=e[t];if(_(n))for(const e in n)e.toUpperCase()in se&&f(n[e])&&o.addEventListener(e.toLowerCase(),n[e])}else"container"!==t&&o.setAttribute(t,e[t]);const s=()=>{i(),t(!0)},r=()=>{i(),t(!1)},i=()=>{o.removeEventListener(se.MOUNTED,s),o.removeEventListener(se.ERROR,r)};o.addEventListener(se.MOUNTED,s),o.addEventListener(se.ERROR,r),n.appendChild(o)}))}class fn extends it{constructor(){super(...arguments),this.tagName="micro-app",this.options={},this.router=kt,this.preFetch=an,this.unmountApp=pn,this.unmountAllApps=hn,this.getActiveApps=ln,this.getAllApps=un,this.reload=dn,this.renderApp=mn}start(e){var t,o,s;if(!n||!window.customElements)return R("micro-app is not supported in this environment");if(null==e?void 0:e.tagName){if(!/^micro-app(-\S+)?/.test(e.tagName))return R(`${e.tagName} is invalid tagName`);this.tagName=e.tagName}if(window.customElements.get(this.tagName))return S(`element ${this.tagName} is already defined`);if($e(),_(e)&&(this.options=e,e["disable-scopecss"]=null!==(t=e["disable-scopecss"])&&void 0!==t?t:e.disableScopecss,e["disable-sandbox"]=null!==(o=e["disable-sandbox"])&&void 0!==o?o:e.disableSandbox,e.preFetchApps&&an(e.preFetchApps),e.globalAssets&&(_(s=e.globalAssets)&&I((()=>{cn(s.js,"js",ve.script),cn(s.css,"css",ve.link)}))),_(e.plugins))){const t=e.plugins.modules;if(_(t))for(const e in t){const n=M(e);n&&e!==n&&(t[n]=t[e],delete t[e])}}rn(this.tagName)}}const _n=new fn;e.EventCenterForMicroApp=at,e.MicroApp=fn,e.default=_n,e.getActiveApps=ln,e.getAllApps=un,e.preFetch=an,e.pureCreateElement=F,e.reload=dn,e.removeDomScope=$,e.renderApp=mn,e.unmountAllApps=hn,e.unmountApp=pn,e.version=t,Object.defineProperty(e,"__esModule",{value:!0})}));
2
2
  //# sourceMappingURL=index.umd.js.map