@micro-zoe/micro-app 1.0.0-alpha.8 → 1.0.0-alpha.9

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