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