@micro-zoe/micro-app 1.0.0-beta.0 → 1.0.0-beta.1

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