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