@micro-zoe/micro-app 1.0.0-beta.2 → 1.0.0-beta.3
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.d.ts +1 -1
- package/lib/index.esm.js +128 -80
- package/lib/index.esm.js.map +1 -1
- package/lib/index.min.js +1 -1
- package/lib/index.min.js.map +1 -1
- package/lib/index.umd.js +1 -1
- package/lib/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/typings/global.d.ts +7 -0
package/lib/index.umd.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).microApp={})}(this,(function(e){"use strict";const t="1.0.0-beta.2",n="undefined"!=typeof window,o="undefined"!=typeof global?global:"undefined"!=typeof window?window:"undefined"!=typeof self?self:Function("return this")(),r=()=>!1,i=Array.isArray,s=Object.assign,a=Object.defineProperty,c=Object.defineProperties,l=Object.prototype.hasOwnProperty;function u(e){return void 0===e}function p(e){return null===e}function h(e){return"string"==typeof e}function d(e){return"boolean"==typeof e}function m(e){return"number"==typeof e}function f(e){return"function"==typeof e}function _(e){return"[object Object]"===toString.call(e)}function A(e){return"object"==typeof e}function w(e){return"[object Promise]"===toString.call(e)}function y(e){var t;if(f(e)){const n=e.toString();return(null===(t=e.prototype)||void 0===t?void 0:t.constructor)===e&&Object.getOwnPropertyNames(e.prototype).length>1||/^function\s+[A-Z]/.test(n)||/^class\s+/.test(n)}return!1}function g(e){var t;return e instanceof URL||!!(null===(t=e)||void 0===t?void 0:t.href)}function b(e){var t;return e instanceof Element||h(null===(t=e)||void 0===t?void 0:t.tagName)}function v(e){var t;return e instanceof Node||m(null===(t=e)||void 0===t?void 0:t.nodeType)}function E(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 P(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 R(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 S(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 N(e,t=null,...n){const o=t&&h(t)?` app ${t}:`:"";h(e)?console.error(`[micro-app]${o} ${e}`,...n):console.error(`[micro-app]${o}`,e,...n)}function M(e,t=null,...n){const o=t&&h(t)?` app ${t}:`:"";h(e)?console.warn(`[micro-app]${o} ${e}`,...n):console.warn(`[micro-app]${o}`,e,...n)}function C(e,...t){Promise.resolve().then(e.bind(null,...t))}const D=function(){class e extends URL{}return(t,n)=>n?new e(""+t,n):new e(""+t)}();function O(e){return e.startsWith("//")?`${o.location.protocol}${e}`:e}function I(e,t=null){if(!h(e)||!e)return"";try{const{origin:t,pathname:n,search:o}=D(O(e));if(/\.(\w+)$/.test(n))return`${t}${n}${o}`;const r=`${t}${n}/`.replace(/\/\/$/,"/");return/^https?:\/\//.test(r)?`${r}${o}`:""}catch(e){return N(e,t),""}}function x(e){return h(e)&&e?e.replace(/(^\d+)|([^\w\d-_])/gi,""):""}function L(e){const{origin:t,pathname:n}=D(e);if(/\.(\w+)$/.test(n)){const e=`${t}${n}`.split("/");return e.pop(),e.join("/")+"/"}return`${t}${n}/`.replace(/\/\/$/,"/")}function W(e,t){return!e||/^((((ht|f)tps?)|file):)?\/\//.test(e)||/^(data|blob):/.test(e)?e:D(e,L(O(t))).toString()}function U(e,t,n,o){let r=0;function i(){++r===e.length&&o&&o()}e.forEach(((e,o)=>{w(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 T=o.requestIdleCallback||function(e){const t=Date.now();return setTimeout((function(){e({didTimeout:!1,timeRemaining:()=>Math.max(0,50-(Date.now()-t))})}),1)};function B(e){return new Promise((t=>{T((()=>{e(t)}))}))}let k=null;function H(e){k=e}function $(e){k!==e&&(H(e),C((()=>{H(null)})))}function F(){return k}function j(){H(null)}function K(e,t){const n=document.createElement(e,t);return n.__MICRO_APP_NAME__&&delete n.__MICRO_APP_NAME__,n.__PURE_ELEMENT__=!0,n}function q(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 G(e){return!e||/(^\d)|([^\w\d-_\u4e00-\u9fa5])/gi.test(e)}function Q(e){return/^body$/i.test(e)||/^head$/i.test(e)||/^html$/i.test(e)||/^title$/i.test(e)}function V(e){return function(e){return"undefined"!=typeof ShadowRoot&&e instanceof ShadowRoot}(e)?e.host:e}function z(e){return e?e.replace(/^\s+|\s+$/g,""):""}function X(){return navigator.userAgent.indexOf("Firefox")>-1}function Y(e){const t={},n=e.split("&");for(const e of n){const n=e.indexOf("="),o=n<0?e:e.slice(0,n),r=n<0?null:e.slice(n+1);if(o in t){let e=t[o];i(e)||(e=t[o]=[e]),e.push(r)}else t[o]=r}return t}function J(e){let t="";for(const n in e){const o=e[n];if(p(o))t+=(t.length?"&":"")+n;else{(i(o)?o:[o]).forEach((e=>{u(e)||(t+=(t.length?"&":"")+n,p(e)||(t+="="+e))}))}}return t}function Z(){const e=new Set;return{add:function(t){return e.add(t),()=>!!e.has(t)&&e.delete(t)},list:()=>e}}function ee(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 te(e,t){e?e.push((()=>B((e=>{t(),e()})))):t()}function ne(e){return(null==e?void 0:e.reduce(((e,t)=>e.then(t)),Promise.resolve()))||null}function oe(e){return e.startsWith("inline-")}function re(e,t,n,...o){try{f(e)&&e(...o)}catch(e){N(`An error occurred in app ${t} window.${n} \n`,null,e)}}var ie,se,ae,ce;!function(e){e.NAME="name",e.URL="url"}(ie||(ie={})),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"}(se||(se={})),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"}(ae||(ae={})),function(e){e.ONMOUNT="onmount",e.ONUNMOUNT="onunmount"}(ce||(ce={}));var le,ue;!function(e){e.KEEP_ALIVE_SHOW="keep_alive_show",e.KEEP_ALIVE_HIDDEN="keep_alive_hidden"}(le||(le={})),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"}(ue||(ue={}));const pe=[1,2,3],he="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 de(e,t=null,n={}){return j(),f(Qn.options.fetch)?Qn.options.fetch(e,n,t):window.fetch(e,n).then((e=>e.text()))}class me{static getInstance(){return this.instance||(this.instance=new me),this.instance}run(e,t){const n=e.name,o=e.ssrUrl||e.url;de(o,n,{cache:"no-cache"}).then((r=>{if(!r){const t="html is empty, please check in detail";return e.onerror(new Error(t)),N(t,n)}r=this.formatHTML(o,r,n),t(r,e)})).catch((t=>{N(`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)=>_(n)&&f(n.processHtml)?n.processHtml(t,e):t),t):t}}const fe=/(^|\s+)(html|:root)(?=[\s>~[.#:]+|$)/,_e=/(^|\s+)((html[\s>~]+body)|body)(?=[\s>~[.#:]+|$)/;function Ae(e,t){e=t?`${t} ${e}`:e;const n=new Error(e);throw n.reason=e,t&&(n.filename=t),n}class we{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(),X()?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):Ae("selector missing",this.linkPath)}formatSelector(e){const t=this.commonMatch(/^[^{]+/,e);return!!t&&t[0].replace(/(^|,[\n\s]*)([^,]+)/g,((e,t,n)=>(n=z(n),this.scopecssDisableNextLine||this.scopecssDisable&&(!this.scopecssDisableSelectors.length||this.scopecssDisableSelectors.includes(n))||fe.test(n)||(n=_e.test(n)?n.replace(_e,this.prefix+" micro-app-body"):this.prefix+" "+n),t+n)))}styleDeclarations(){return this.matchOpenBrace()?(this.matchAllDeclarations(),!!this.matchCloseBrace()||Ae("Declaration missing '}'",this.linkPath)):Ae("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(),O(t.join("/")+"/")}(this.linkPath)),`url("${W(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 Ae("@keyframes missing name",this.linkPath);if(this.matchComments(),!this.matchOpenBrace())return Ae("@keyframes missing '{'",this.linkPath);for(this.matchComments();this.keyframeRule();)this.matchComments();return this.matchCloseBrace()?(this.matchLeadingSpaces(),!0):Ae("@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):Ae(`${t} missing '}'`,this.linkPath)):Ae(`${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):Ae(`@${e} missing '}'`,this.linkPath)):Ae(`@${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 Ae("End of comment missing",this.linkPath);let t=this.cssText.slice(2,e-2);if(this.recordResult(`/*${t}*/`),t=z(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(z(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){X()?this.result+=encodeURIComponent(e):this.result+=e}}function ye(e,t,n,o,r){if(!e.__MICRO_APP_HAS_SCOPED__){e.__MICRO_APP_HAS_SCOPED__=!0;let i=null;try{i=ge.exec(e.textContent,n,o,r),ge.reset()}catch(e){ge.reset(),N("An error occurred while parsing CSS:\n",t,e)}i&&(e.textContent=i)}}let ge;function be(e,t,n){if(t.scopecss){const o=ve(t.name);if(ge||(ge=new we),e.textContent)ye(e,t.name,o,t.url,n);else{const r=new MutationObserver((function(){r.disconnect(),e.textContent&&!e.hasAttribute("data-styled")&&ye(e,t.name,o,t.url,n)}));r.observe(e,{childList:!0})}}return e}function ve(e,t=!1){const n=t?"\\":"";return`${Qn.tagName}${n}[name=${e}${n}]`}function Ee(e,t){Object.defineProperties(e,{currentTarget:{get:()=>t},srcElement:{get:()=>t},target:{get:()=>t}})}function Pe(e){const t=new CustomEvent("load");Ee(t,e),f(e.onload)?e.onload(t):e.dispatchEvent(t)}function Re(e){const t=new CustomEvent("error");Ee(t,e),f(e.onerror)?e.onerror(t):e.dispatchEvent(t)}var Se=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=>{oe(e)&&t.delete(e)}))}})}}();const Ne=["text/javascript","text/ecmascript","application/javascript","application/ecmascript","module","systemjs-module","systemjs-importmap"];function Me(e,t){return t.appSpace[e.name].module&&(!e.useSandbox||e.iframe)}function Ce(e,t){return e.inline||t.appSpace[e.name].inline||Me(e,t)||function(e,t){return t.appSpace[e.name].attrs.has("id")}(e,t)||e.iframe}function De(e){return e.iframe?e.sandBox.microAppWindow:at.rawWindow}function Oe(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(De(e).Function)(t)}(e,n)}function Ie(){const e="inline-"+Math.random().toString(36).substr(2,15);return Se.script.hasInfo(e)?Ie():e}function xe(e,t){return e.useSandbox&&!Me(e,t)}function Le(e,t){return xe(e,t)?e.iframe?"iframe":"with":"disable"}function We(e,t,n,o=!1){var r;let i=null,s=e.getAttribute("src");if(s&&(s=W(s,n.url)),e.hasAttribute("exclude")||Te(s,n.name))i=document.createComment("script element with exclude attribute removed by micro-app");else{if(e.type&&!Ne.includes(e.type)||e.hasAttribute("ignore")||Be(s,n.name))return(null===(r=at.rawDocument)||void 0===r?void 0:r.currentScript)&&delete at.rawDocument.currentScript,null;if(at.supportModuleScript&&e.noModule||!at.supportModuleScript&&"module"===e.type)i=document.createComment((e.noModule?"noModule":"module")+" script ignored by micro-app");else if(s){let t=Se.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:ee(e)};if(t?t.appSpace[n.name]=t.appSpace[n.name]||r:t={code:"",isExternal:!0,appSpace:{[n.name]:r}},Se.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=Ie(),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:ee(e)}}};if(o)return{address:t,scriptInfo:r};n.source.scripts.add(t),Se.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}:null==t?void 0:t.replaceChild(i,e)}function Ue(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 Te(e,t){if(!e)return!1;return(Ue(t)||[]).some((t=>!!t.excludeChecker&&t.excludeChecker(e)))}function Be(e,t){if(!e)return!1;return(Ue(t)||[]).some((t=>!!t.ignoreChecker&&t.ignoreChecker(e)))}function ke(e,t){const n=Array.from(t.source.scripts),o=[],r=[];for(const e of n){const n=Se.script.getInfo(e),i=n.appSpace[t.name];(!i.defer&&!i.async||t.isPrefetch&&!t.isPrerender)&&(o.push(n.code?n.code:de(e,t.name)),r.push([e,n]))}const i=t.isPrefetch||t.fiber?[]:null;o.length?U(o,(e=>{te(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=$e(e,o,n,t),r.sandboxType=Le(o,t),!Ce(o,t)))try{r.parsedFunction=Oe(o,t,r.parsedCode)}catch(e){N("Something went wrong while handling preloaded resources",o.name,"\n",e)}}}(r[e.index][0],r[e.index][1],e.data,t)))}),(e=>{N(e,t.name)}),(()=>{i?(i.push((()=>Promise.resolve(t.onLoad(e)))),ne(i)):t.onLoad(e)})):t.onLoad(e)}function He(e,t,n,o,r){try{!function(e){!function(e){e.sandBox&&(at.rawWindow.__MICRO_APP_PROXY_WINDOW__=e.sandBox.proxyWindow)}(e)}(t);const i=n.appSpace[t.name],s=Le(t,n);if(i.parsedCode&&i.sandboxType===s||(i.parsedCode=$e(e,t,n.code,n),i.sandboxType=s,i.parsedFunction=null),Ce(t,n)){const s=r||K("script");if(function(e,t,n,o,r,i){if(n){if(oe(e)){const e=new Blob([t],{type:"text/javascript"});o.src=URL.createObjectURL(e)}else o.src=e;at.rawSetAttribute.call(o,"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"),at.rawSetAttribute.call(e,n,t))}))}(o,r)}(e,i.parsedCode,Me(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=Oe(e,t,n.parsedCode));n.parsedFunction.call(De(e))}(t,n)}catch(n){console.error(`[micro-app from ${r?"runDynamicScript":"runScript"}] app ${t.name}: `,n,e)}}function $e(e,t,n,o){return _(Qn.options.plugins)&&(n=function(e,t,n,o){var r;const i=Fe(o.global,t,e);return Fe(null===(r=o.modules)||void 0===r?void 0:r[n],i,e)}(e,n,t.name,Qn.options.plugins)),xe(t,o)?t.iframe?`(function(window,self,global,location){;${n}\n${oe(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(${he}){;${n}\n${oe(e)?"":`//# sourceURL=${e}\n`}}).call(proxyWindow,${he})}})(window.__MICRO_APP_PROXY_WINDOW__);`:n}function Fe(e,t,n){return i(e)?e.reduce(((e,t)=>_(t)&&f(t.loader)?t.loader(e,n):e),t):t}class je{constructor(){this.escapeSetterKeyList=["location"],this.staticEscapeProperties=["System","__cjsWrapper"],this.staticScopeProperties=["webpackJsonp","webpackHotUpdate","Vue"],this.injectReactHMRProperty()}injectReactHMRProperty(){}}function Ke(e){const t=at.rawDocument.firstElementChild;(null==t?void 0:t.parentNode)===at.rawDocument&&(qe(t,e),C((()=>{qe(t,at.rawDocument)})))}function qe(e,t){const n=Object.getOwnPropertyDescriptor(e,"parentNode");n&&!n.configurable||a(e,"parentNode",{value:t,configurable:!0})}const Ge=["unmount","appstate-change"];function Qe(e,t){var n;return Un(t)||!Ge.includes(e)&&("popstate"!==e&&"hashchange"!==e||!(null===(n=Ln.get(t))||void 0===n?void 0:n.useMemoryRouter))?e:`${e}-${t}`}function Ve(e,t){const n=Array.from(e.children);n.length&&n.forEach((e=>{Ve(e,t)}));for(const e of n)ze(e,t)}function ze(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 v(e)&&!e.__MICRO_APP_NAME__&&!e.__PURE_ELEMENT__&&r&&(c(e,{baseURI:{configurable:!0,get:()=>r.location.href},__MICRO_APP_NAME__:{configurable:!0,writable:!0,value:t}}),Un(t)&&a(e,"ownerDocument",{configurable:!0,get:()=>r.document})),e}const Xe=new WeakMap;function Ye(e){var t;return null!==(t=Xe.get(e))&&void 0!==t?t:e}function Je(e,t){if(Xe.has(e))return Xe.get(e);if(P(e)){if(e.hasAttribute("exclude")){const t=document.createComment("style element with exclude attribute ignored by micro-app");return Xe.set(e,t),t}return t.scopecss&&!e.hasAttribute("ignore")?be(e,t):e}if(E(e)){if(e.hasAttribute("exclude")||Te(e.getAttribute("href"),t.name)){const t=document.createComment("link element with exclude attribute ignored by micro-app");return Xe.set(e,t),t}if(e.hasAttribute("ignore")||Be(e.getAttribute("href"),t.name)||e.href&&f(Qn.options.excludeAssetFilter)&&Qn.options.excludeAssetFilter(e.href))return e;const{address:n,linkInfo:o,replaceComment:r}=lt(e,null,t,!0);if(n&&o){const r=function(e,t,n,o){const r=K("style"),i=()=>{pt(t,e,r,n,n.appSpace[t.name].attrs),Pe(o)};n.code?C(i):de(e,t.name).then((e=>{n.code=e,i()})).catch((e=>{N(e,t.name),Re(o)}));return r}(n,t,o,e);return Xe.set(e,r),r}return r?(Xe.set(e,r),r):e}if(R(e)){if(e.src&&f(Qn.options.excludeAssetFilter)&&Qn.options.excludeAssetFilter(e.src))return e;const{replaceComment:n,address:o,scriptInfo:r}=We(e,null,t,!0)||{};if(o&&r){const n=r.isExternal?function(e,t,n,o){const r=Ce(t,n)?K("script"):document.createComment("dynamic script extract by micro-app"),i=()=>Pe(o),s=()=>{const s=Object.getOwnPropertyDescriptor(at.rawDocument,"currentScript");s&&!s.configurable||Object.defineProperty(at.rawDocument,"currentScript",{value:o,configurable:!0}),He(e,t,n,i,r),!Me(t,n)&&i()};return n.code||t.iframe&&n.appSpace[t.name].module?C(s):de(e,t.name).then((e=>{n.code=e,s()})).catch((e=>{N(e,t.name),Re(o)})),r}(o,t,r,e):function(e,t,n){const o=Ce(t,n)?K("script"):document.createComment("dynamic script extract by micro-app");return He(e,t,n,void 0,o),o}(o,t,r);return Xe.set(e,n),n}return n?(Xe.set(e,n),n):e}return e}function Ze(e,t,n,o,r){const i=et(n,o,e);if(i){if(!Un(e.name)&&S(i)&&t!==at.rawRemoveChild){const t=Object.getOwnPropertyDescriptor(o,"parentNode");t&&!t.configurable||o.__MICRO_APP_HAS_DPN__||c(o,{parentNode:{configurable:!0,get(){var t,n;const o=at.rawParentNodeDesc.get.call(this);return S(o)&&e.container?(null===(n=(t=Qn.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)?at.rawAppendChild.call(i,o):t!==at.rawRemoveChild||i.contains(o)?tt(t,i,o,r):n.contains(o)?t.call(n,o):o}return tt(t,n,o,r)}function et(e,t,n){if(n){if(e===document.head)return n.iframe&&R(t)?n.sandBox.microHead:n.querySelector("micro-app-head");if(e===document.body||e===document.body.parentNode)return n.iframe&&R(t)?n.sandBox.microBody:n.querySelector("micro-app-body");if(n.iframe&&R(t))return n.sandBox.microBody}return null}function tt(e,t,n,o){return(r=e)===at.rawAppend||r===at.rawPrepend?e.call(t,n):e.call(t,n,o);var r}function nt(e,t,n,o){const r=F();if(v(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 function(e,t){b(t)&&(/^(img|script)$/i.test(t.tagName)?(t.hasAttribute("src")&&at.rawSetAttribute.call(t,"src",W(t.getAttribute("src"),e.url)),t.hasAttribute("srcset")&&at.rawSetAttribute.call(t,"srcset",W(t.getAttribute("srcset"),e.url))):/^link$/i.test(t.tagName)&&t.hasAttribute("href")&&at.rawSetAttribute.call(t,"href",W(t.getAttribute("href"),e.url)))}(i,t),Ze(i,o,e,Je(t,i),n&&Ye(n))}return o===at.rawAppend||o===at.rawPrepend?o.call(e,t):o.call(e,t,n)}function ot(){!function(){const e=at.rawDocument,t=at.rawRootDocument;function n(t){return function(e){return"[object ProxyDocument]"===toString.call(e)}(t)?e:t}function o(t){var o,r;const i=n(this),s=F();return s&&t&&!Q(t)&&e===i?null!==(r=null===(o=Ln.get(s))||void 0===o?void 0:o.querySelector(t))&&void 0!==r?r:null:at.rawQuerySelector.call(i,t)}function r(t){var o,r;const i=n(this),s=F();return s&&t&&!Q(t)&&e===i?null!==(r=null===(o=Ln.get(s))||void 0===o?void 0:o.querySelectorAll(t))&&void 0!==r?r:[]:at.rawQuerySelectorAll.call(i,t)}t.prototype.createElement=function(e,t){return rt(at.rawCreateElement.call(n(this),e,t))},t.prototype.createElementNS=function(e,t,o){return rt(at.rawCreateElementNS.call(n(this),e,t,o))},t.prototype.createDocumentFragment=function(){return rt(at.rawCreateDocumentFragment.call(n(this)))},t.prototype.querySelector=o,t.prototype.querySelectorAll=r,t.prototype.getElementById=function(e){const t=n(this);if(!F()||G(e))return at.rawGetElementById.call(t,e);try{return o.call(t,`#${e}`)}catch(n){return at.rawGetElementById.call(t,e)}},t.prototype.getElementsByClassName=function(e){const t=n(this);if(!F()||G(e))return at.rawGetElementsByClassName.call(t,e);try{return r.call(t,`.${e}`)}catch(n){return at.rawGetElementsByClassName.call(t,e)}},t.prototype.getElementsByTagName=function(e){var t;const o=n(this),i=F();if(!i||Q(e)||G(e)||!(null===(t=Ln.get(i))||void 0===t?void 0:t.inline)&&/^script$/i.test(e))return at.rawGetElementsByTagName.call(o,e);try{return r.call(o,e)}catch(t){return at.rawGetElementsByTagName.call(o,e)}},t.prototype.getElementsByName=function(e){const t=n(this);if(!F()||G(e))return at.rawGetElementsByName.call(t,e);try{return r.call(t,`[name=${e}]`)}catch(n){return at.rawGetElementsByName.call(t,e)}}}();const e=at.rawRootElement;function t(e){const t=F();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}e.prototype.appendChild=function(e){return nt(this,e,null,at.rawAppendChild)},e.prototype.insertBefore=function(e,t){return nt(this,e,t,at.rawInsertBefore)},e.prototype.replaceChild=function(e,t){return nt(this,e,t,at.rawReplaceChild)},e.prototype.append=function(...e){let t=0;for(;t<e.length;){let n=e[t];n=v(n)?n:at.rawCreateTextNode.call(at.rawDocument,n),nt(this,rt(n),null,at.rawAppend),t++}},e.prototype.prepend=function(...e){let t=e.length;for(;t>0;){let n=e[t-1];n=v(n)?n:at.rawCreateTextNode.call(at.rawDocument,n),nt(this,rt(n),null,at.rawPrepend),t--}},e.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 Ze(t,at.rawRemoveChild,this,Ye(e));try{return at.rawRemoveChild.call(this,e)}catch(t){return(null==e?void 0:e.parentNode)&&at.rawRemoveChild.call(e.parentNode,e)}}return at.rawRemoveChild.call(this,e)},e.prototype.insertAdjacentElement=function(e,t){var n;if(null==t?void 0:t.__MICRO_APP_NAME__){const o=Ln.get(t.__MICRO_APP_NAME__);if(null==o?void 0:o.container){const r=null!==(n=et(this,t=Je(t,o),o))&&void 0!==n?n:this;return at.rawInsertAdjacentElement.call(r,e,t)}}return at.rawInsertAdjacentElement.call(this,e,t)},e.prototype.cloneNode=function(e){const t=at.rawCloneNode.call(this,e);return this.__MICRO_APP_NAME__&&(t.__MICRO_APP_NAME__=this.__MICRO_APP_NAME__),t},e.prototype.querySelector=function(e){var n;const o=null!==(n=t(this))&&void 0!==n?n:this;return at.rawElementQuerySelector.call(o,e)},e.prototype.querySelectorAll=function(e){var n;const o=null!==(n=t(this))&&void 0!==n?n:this;return at.rawElementQuerySelectorAll.call(o,e)},e.prototype.setAttribute=function(e,t){const n=this.__MICRO_APP_NAME__||F();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))){t=W(t,Ln.get(n).url)}at.rawSetAttribute.call(this,e,t)},a(e.prototype,"innerHTML",{configurable:!0,enumerable:!0,get(){return at.rawInnerHTMLDesc.get.call(this)},set(e){at.rawInnerHTMLDesc.set.call(this,e);const t=F();Array.from(this.children).forEach((e=>{b(e)&&t&&(e.__MICRO_APP_NAME__=t)}))}})}function rt(e){const t=F();return t&&(e.__MICRO_APP_NAME__=t),e}function it(){j(),function(){const e=at.rawRootDocument;e.prototype.createElement=at.rawCreateElement,e.prototype.createElementNS=at.rawCreateElementNS,e.prototype.createDocumentFragment=at.rawCreateDocumentFragment,e.prototype.querySelector=at.rawQuerySelector,e.prototype.querySelectorAll=at.rawQuerySelectorAll,e.prototype.getElementById=at.rawGetElementById,e.prototype.getElementsByClassName=at.rawGetElementsByClassName,e.prototype.getElementsByTagName=at.rawGetElementsByTagName,e.prototype.getElementsByName=at.rawGetElementsByName}();const e=at.rawRootElement;e.prototype.appendChild=at.rawAppendChild,e.prototype.insertBefore=at.rawInsertBefore,e.prototype.replaceChild=at.rawReplaceChild,e.prototype.removeChild=at.rawRemoveChild,e.prototype.append=at.rawAppend,e.prototype.prepend=at.rawPrepend,e.prototype.cloneNode=at.rawCloneNode,e.prototype.querySelector=at.rawElementQuerySelector,e.prototype.querySelectorAll=at.rawElementQuerySelectorAll,e.prototype.setAttribute=at.rawSetAttribute,a(e.prototype,"innerHTML",at.rawInnerHTMLDesc)}let st=!1;const at={__MICRO_APP_BASE_APPLICATION__:!0,activeSandbox:0};function ct(){if(n){const e=window.rawWindow||Function("return window")(),t=window.rawDocument||Function("return document")(),n=e.Document||Function("return Document")(),o=e.Element,r=e.Node,i=e.EventTarget,a=o.prototype.setAttribute,c=o.prototype.appendChild,l=o.prototype.insertBefore,u=o.prototype.replaceChild,p=o.prototype.removeChild,h=o.prototype.append,d=o.prototype.prepend,m=o.prototype.cloneNode,f=o.prototype.querySelector,_=o.prototype.querySelectorAll,A=o.prototype.insertAdjacentElement,w=Object.getOwnPropertyDescriptor(o.prototype,"innerHTML"),y=Object.getOwnPropertyDescriptor(r.prototype,"parentNode"),g=n.prototype.createElement,b=n.prototype.createElementNS,v=n.prototype.createDocumentFragment,E=n.prototype.createTextNode,P=n.prototype.querySelector,R=n.prototype.querySelectorAll,S=n.prototype.getElementById,N=n.prototype.getElementsByClassName,M=n.prototype.getElementsByTagName,C=n.prototype.getElementsByName,D=new Proxy(Image,{construct(e,t){const n=new e(...t),o=F();return o&&(n.__MICRO_APP_NAME__=o),n}}),O=e.setInterval,I=e.setTimeout,x=e.clearInterval,L=e.clearTimeout,W=e.history.pushState,U=e.history.replaceState,T=i.prototype.addEventListener,B=i.prototype.removeEventListener;s(at,{supportModuleScript:"noModule"in document.createElement("script"),rawWindow:e,rawDocument:t,rawRootDocument:n,rawRootElement:o,rawRootNode:r,rawSetAttribute:a,rawAppendChild:c,rawInsertBefore:l,rawReplaceChild:u,rawRemoveChild:p,rawAppend:h,rawPrepend:d,rawCloneNode:m,rawElementQuerySelector:f,rawElementQuerySelectorAll:_,rawInsertAdjacentElement:A,rawInnerHTMLDesc:w,rawParentNodeDesc:y,rawCreateElement:g,rawCreateElementNS:b,rawCreateDocumentFragment:v,rawCreateTextNode:E,rawQuerySelector:P,rawQuerySelectorAll:R,rawGetElementById:S,rawGetElementsByClassName:N,rawGetElementsByTagName:M,rawGetElementsByName:C,ImageProxy:D,rawSetInterval:O,rawSetTimeout:I,rawClearInterval:x,rawClearTimeout:L,rawPushState:W,rawReplaceState:U,rawAddEventListener:T,rawRemoveEventListener:B}),function(){if(!st){st=!0;const e=K("style");at.rawSetAttribute.call(e,"type","text/css"),e.textContent=`\n${Qn.tagName}, micro-app-body { display: block; } \nmicro-app-head { display: none; }`,at.rawDocument.head.appendChild(e)}}()}}function lt(e,t,n,o=!1){const r=e.getAttribute("rel");let i=e.getAttribute("href"),s=null;if("stylesheet"===r&&i){i=W(i,n.url);let t=Se.link.getInfo(i);const r={attrs:ee(e)};if(t?t.appSpace[n.name]=t.appSpace[n.name]||r:t={code:"",appSpace:{[n.name]:r}},Se.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`):null==t||t.removeChild(e):i&&at.rawSetAttribute.call(e,"href",W(i,n.url));return o?{replaceComment:s}:s?null==t?void 0:t.replaceChild(s,e):void 0}function ut(e,t,n,o){const r=Array.from(t.source.links),i=r.map((e=>{const n=Se.link.getInfo(e);return n.code?n.code:de(e,t.name)})),s=o?[]:null;U(i,(e=>{te(s,(()=>function(e,t,n,o){const r=Se.link.getInfo(e);r.code=t;const i=r.appSpace[o.name],s=i.placeholder;if(s){const t=K("style");pt(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=>{N(e,t.name)}),(()=>{o?o.then((()=>{s.push((()=>Promise.resolve(t.onLoad(e)))),ne(s)})):t.onLoad(e)}))}function pt(e,t,n,o,r){if(e.scopecss){const r=o.appSpace[e.name];if(r.prefix=r.prefix||ve(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(ve(n,!0),"g"),t)}}(e.name,r.prefix,o);i?n.textContent=i:(n.textContent=o.code,be(n,e,t)),r.parsedCode=n.textContent}}else n.textContent=o.code;!function(e,t){t.forEach(((t,n)=>{"rel"!==n&&("href"===n&&(n="data-origin-href"),at.rawSetAttribute.call(e,n,t))}))}(n,r)}function ht(e,t,n,o){const r=Array.from(e.children);r.length&&r.forEach((e=>{ht(e,t,n,o)}));for(const n of r)E(n)?n.hasAttribute("exclude")||Te(n.getAttribute("href"),t.name)?e.replaceChild(document.createComment("link element with exclude attribute ignored by micro-app"),n):n.hasAttribute("ignore")||Be(n.getAttribute("href"),t.name)?n.hasAttribute("href")&&at.rawSetAttribute.call(n,"href",W(n.getAttribute("href"),t.url)):lt(n,e,t):P(n)?n.hasAttribute("exclude")?e.replaceChild(document.createComment("style element with exclude attribute ignored by micro-app"),n):t.scopecss&&!n.hasAttribute("ignore")&&te(o,(()=>be(n,t))):R(n)?We(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")&&at.rawSetAttribute.call(n,"src",W(n.getAttribute("src"),t.url)));var i,s}function dt(e,t){const n=function(e){const t=K("div");return t.innerHTML=e,t}(e),o=at.rawElementQuerySelector.call(n,"micro-app-head"),r=at.rawElementQuerySelector.call(n,"micro-app-body");if(!o||!r){const e=`element ${o?"body":"head"} is missing`;return t.onerror(new Error(e)),N(e,t.name)}const i=t.isPrefetch||t.fiber?[]:null;ht(n,t,o,i);const s=ne(i);t.source.links.size?ut(n,t,o,s):s?s.then((()=>t.onLoad(n))):t.onLoad(n),t.source.scripts.size?ke(n,t):t.onLoad(n)}function mt(e){return d(e.__MICRO_APP_IS_BOUND_FUNCTION__)?e.__MICRO_APP_IS_BOUND_FUNCTION__:e.__MICRO_APP_IS_BOUND_FUNCTION__=f(t=e)&&0===t.name.indexOf("bound ")&&!t.hasOwnProperty("prototype");var t}function ft(e,t,n="WINDOW"){if(f(e)&&!function(e){return d(e.__MICRO_APP_IS_CONSTRUCTOR__)?e.__MICRO_APP_IS_CONSTRUCTOR__:e.__MICRO_APP_IS_CONSTRUCTOR__=y(e)}(e)&&!mt(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")&&a(r,"prototype",{value:e.prototype,configurable:!0,enumerable:!1,writable:!0}),e[o]=r}return e}const _t=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||(N("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)&&C(this.process)}isEqual(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&e[n]!==t[n])return!1;return!0}on(e,t,n=!1){if(this.isLegalName(e)){if(!f(t))return N("event-center: Invalid callback function");let o=this.eventList.get(e);o?n&&Object.keys(o.data).length&&(!this.queue.includes(e)||this.isEqual(o.data,o.tempData))&&t(o.data):(o={data:{},callbacks:new Set},this.eventList.set(e,o)),o.callbacks.add(t)}}off(e,t){if(this.isLegalName(e)){const n=this.eventList.get(e);n&&(f(t)?n.callbacks.delete(t):n.callbacks.clear())}}clearData(e){if(this.isLegalName(e)){const t=this.eventList.get(e);t&&(t.data={})}}dispatch(e,t,n,o,r){if(this.isLegalName(e)){if(!_(t))return N("event-center: data must be object");let i=this.eventList.get(e);i?(i.tempData=s({},i.tempData||i.data,t),!i.force&&(i.force=!!o)):(i={data:t,callbacks:new Set},this.eventList.set(e,i),i.force=!0),this.enqueue(e,n,r)}}getData(e){var t;const n=this.eventList.get(e);return null!==(t=null==n?void 0:n.data)&&void 0!==t?t:null}};function At(e,t){return h(e)&&e?t?`__from_base_app_${e}__`:`__from_micro_app_${e}__`:""}class wt{addGlobalDataListener(e,t){const n=this.appName;n&&(e.__APP_NAME__=n,e.__AUTO_TRIGGER__=t),_t.on("global",e,t)}removeGlobalDataListener(e){f(e)&&_t.off("global",e)}setGlobalData(e,t,n){j(),_t.dispatch("global",e,(e=>f(t)&&t(e)),n)}forceSetGlobalData(e,t){this.setGlobalData(e,t,!0)}getGlobalData(){return _t.getData("global")}clearGlobalData(){_t.clearData("global")}clearGlobalDataListener(){const e=this.appName,t=_t.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 yt extends wt{addDataListener(e,t,n){_t.on(At(x(e),!1),t,n)}removeDataListener(e,t){f(t)&&_t.off(At(x(e),!1),t)}getData(e,t=!1){return _t.getData(At(x(e),t))}setData(e,t,n,o){_t.dispatch(At(x(e),!0),t,(e=>f(n)&&n(e)),o)}forceSetData(e,t,n){this.setData(e,t,n,!0)}clearData(e,t=!0){_t.clearData(At(x(e),t))}clearDataListener(e){_t.off(At(x(e),!1))}}class gt extends wt{constructor(e){super(),this.appName=x(e),!this.appName&&N(`Invalid appName ${e}`)}addDataListener(e,t){e.__AUTO_TRIGGER__=t,_t.on(At(this.appName,!0),e,t)}removeDataListener(e){f(e)&&_t.off(At(this.appName,!0),e)}getData(e=!0){return _t.getData(At(this.appName,e))}dispatch(e,t,n){j(),_t.dispatch(At(this.appName,!1),e,(e=>f(t)&&t(e)),n,(()=>{const t=Ln.get(this.appName);if((null==t?void 0:t.container)&&_(e)){const e=new CustomEvent("datachange",{detail:{data:_t.getData(At(this.appName,!1))}});V(t.container).dispatchEvent(e)}}))}forceDispatch(e,t){this.dispatch(e,t,!0)}clearData(e=!1){_t.clearData(At(this.appName,e))}clearDataListener(){_t.off(At(this.appName,!0))}}function bt(e){if(e&&!e.umdDataListeners){e.umdDataListeners={global:new Set,normal:new Set};const t=_t.eventList.get("global");if(t)for(const n of t.callbacks)e.appName===n.__APP_NAME__&&e.umdDataListeners.global.add(n);const n=_t.eventList.get(At(e.appName,!0));n&&(e.umdDataListeners.normal=new Set(n.callbacks))}}function vt(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__);Et(e)}}function Et(e){delete e.umdDataListeners}class Pt{constructor(){this.appInstanceMap=Ln}static getInstance(){return this.instance||(this.instance=new Pt),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 Rt(){St(),Pt.getInstance().getAll().forEach((e=>{e.container&&V(e.container).disconnectedCallback()})),!window.__MICRO_APP_UMD_MODE__&&Pt.getInstance().clear()}function St(){window.__MICRO_APP_ENVIRONMENT__&&window.removeEventListener("unmount",Rt,!1)}function Nt(e,t){const{rawDocument:n,rawRootDocument:o}=at;class r{static[Symbol.hasInstance](e){let n=e;for(;n=Object.getPrototypeOf(n);)if(n===r.prototype)return!0;return e===t||e instanceof o}}return Object.setPrototypeOf(r,o),Object.setPrototypeOf(r.prototype,new Proxy(o.prototype,{get:(t,o)=>($(e),ft(Reflect.get(t,o),n,"DOCUMENT")),set:(e,t,n)=>(Reflect.set(e,t,n),!0)})),r}function Mt(e,t){const n=at.rawWindow.history.state,o={microAppState:s({},null==n?void 0:n.microAppState,{[e]:t})};return s({},n,o)}function Ct(e){var t,n;return(null===(n=null===(t=at.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=at.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 h(i)?Wt(i):null}function Bt(e,t){let{pathname:n,search:o,hash:r}=at.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+J(i.hashQuery)}else i.searchQuery?i.searchQuery[e]=s:i.searchQuery={[e]:s},o="?"+J(i.searchQuery);return{fullPath:n+o+r,isAttach2Hash:a}}function kt(e,t){const n={};return""!==e&&"?"!==e&&(n.searchQuery=Y(e.slice(1))),t.includes("?")&&(n.hashQuery=Y(t.slice(t.indexOf("?")+1))),n}function Ht(e){const t=Ln.get(e);return!(!t||t.isPrefetch)}function $t(e){const t=at.rawWindow,n=t=>{if(Hn({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(Qe("popstate",e),{state:Ct(e)});Un(e)?n.dispatchEvent(o):at.rawWindow.dispatchEvent(o);f(t.onpopstate)&&t.onpopstate(o)}(e,o,r),i&&function(e,t,n,o){const r=new HashChangeEvent(Qe("hashchange",e),{newURL:t.location.href,oldURL:o});Un(e)?n.dispatchEvent(r):at.rawWindow.dispatchEvent(r);f(t.onhashchange)&&t.onhashchange(r)}(e,o,r,s),j()}};return t.addEventListener("popstate",n),()=>{t.removeEventListener("popstate",n)}}function Ft(e,t,n){j(),Ht(e)&&(function(e){const t=new PopStateEvent("popstate",{state:null});e&&(t.onlyForBrowser=!0),at.rawWindow.dispatchEvent(t)}(t),n&&function(e){const t=new HashChangeEvent("hashchange",{newURL:at.rawWindow.location.href,oldURL:e});at.rawWindow.dispatchEvent(t)}(n))}function jt(e,t){const n=at.rawWindow.history;function o(n){return function(...o){var r,i,s;if(h(o[2])||g(o[2])){const a=D(o[2],t.href),c=a.pathname+a.search+a.hash;qt(e,n,Bt(e,a),!0,Mt(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 Kt(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:ft(Reflect.get(t,n),t,"HISTORY"),set:(e,t,n)=>(Reflect.set(e,t,n),!0)})}function Kt(e,t,n,o=null,r=""){if(Ht(e)){("pushState"===t?at.rawPushState:at.rawReplaceState).call(at.rawWindow.history,o,r,n)}}function qt(e,t,n,o,r,i){if(Ht(e)){const s=at.rawWindow.location,a=s.pathname+s.search+s.hash,c=n.isAttach2Hash&&a!==n.fullPath?s.href:null;Kt(e,t,n.fullPath,r,i),a!==n.fullPath&&Ft(e,o,c)}}function Gt(e,t,n){qt(e,"replaceState",t,!0,n)}function Qt(e){const t=at.rawWindow;return function(...n){var o;if((null===(o=t.history.state)||void 0===o?void 0:o.microAppState)&&(!_(n[0])||!n[0].microAppState)&&(h(n[2])||g(n[2]))){const e=t.location.href;D(n[2],e).href===e&&(n[0]=s({},n[0],{microAppState:t.history.state.microAppState}))}e.apply(t.history,n),Hn({excludeHiddenApp:!0,excludePreRender:!0}).forEach((e=>{const t=Ln.get(e);t.sandBox&&t.useMemoryRouter&&!Tt(e)&&Gt(e,Bt(e,t.sandBox.proxyWindow.location),Mt(e,Ct(e)))})),j()}}function Vt(){const e=at.rawWindow;e.history.pushState=Qt(at.rawPushState),e.history.replaceState=Qt(at.rawReplaceState)}function zt(){const e=at.rawWindow;e.history.pushState=at.rawPushState,e.history.replaceState=at.rawReplaceState}const{router:Xt,executeNavigationGuard:Yt,clearRouterWhenUnmount:Jt}=function(){function e(e,t,n,o){qt(e,t,Bt(e,n),!1,Mt(e,null!=o?o:null)),j()}function t(t){return function(n){const o=x(n.name);if(o&&h(n.path)){const r=Ln.get(o);if(r&&(!r.sandBox||!r.useMemoryRouter))return N(`navigation failed, memory router of app ${o} is closed`);if(Hn({excludePreRender:!0}).includes(o)){const i=r.sandBox.proxyWindow.location,s=D(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=at.rawWindow.location,r=D(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 N("navigation failed, name & path are required when use router."+(t?"replace":"push"))}}function n(e){return function(...t){return at.rawWindow.history[e](...t)}}const o=Z(),i=Z();function s(e,t,n,o){j();for(const r of o)f(r)?r(t,n,e):_(r)&&f(r[e])&&r[e](t,n)}function a(e){const t=Ln.get(e);t.sandBox&&t.useMemoryRouter&&Gt(e,Bt(e,t.sandBox.proxyWindow.location),Mt(e,Ct(e)))}const c=Object.assign(Object.assign({current:new Map,encode:Lt,decode:Wt,push:t(!1),replace:t(!0),go:n("go"),back:n("back"),forward:n("forward"),beforeEach:o.add,afterEach:i.add,attachToURL:function(e){(e=x(e))&&Hn().includes(e)&&a(e)},attachAllToURL:function({includeHiddenApp:e=!1,includePreRender:t=!1}){Hn({excludeHiddenApp:!e,excludePreRender:!t}).forEach((e=>a(e)))}},function(){const e=function(){const e=new Map;return{add:function(t,n){return e.set(t,n),()=>!!e.has(t)&&e.delete(t)},get:t=>e.get(t),delete:t=>!!e.has(t)&&e.delete(t)}}();return{setDefaultPage:function(t){const n=x(t.name);return n&&t.path?e.add(n,t.path):r},removeDefaultPage:function(t){return!!(t=x(t))&&e.delete(t)},getDefaultPage:e.get}}()),function(){let e=null;return{setBaseAppRouter:function(t){A(t)&&(e=new Proxy(t,{get:(e,t)=>(j(),ft(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,o.list()),T((()=>{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,i){const s=at.rawWindow.location,c=!!n,l=D(t);function u(){return c?n.location:l}function p(t,n){const o=D(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=s.href),Kt(e,n,t.fullPath)),void(o.hash?Ft(e,!1,r):_())}return t.isAttach2Hash?(Kt(e,n,t.fullPath),void _()):t.fullPath}return t}function h(n,o){const r=D(n,t);r[o]===A[o]&&A.hash?Ft(e,!1):(Kt(e,r[o]===A[o]?"replaceState":"pushState",Bt(e,r).fullPath),_())}const d=t=>function(n){if(Ht(e)){const e=p(n,"assign"===t?"pushState":"replaceState");e&&s[t](D(e,s.origin).href)}},m=d("assign"),f=d("replace"),_=e=>s.reload(e);a(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,i)}return"assign"===t?m:"replace"===t?f:"reload"===t?_:"self"===t?n:ft(Reflect.get(n,t),n,"LOCATION")},set:(n,o,r)=>{if(Ht(e)){const n=u();if("href"===o){const e=p(r,"pushState");e&&(s.href=D(e,s.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=D(n,t);o.hash!==A.hash&&qt(e,"pushState",Bt(e,o),!1)}else Reflect.set(n,o,r)}return!0}});return A}function _n(e,t){const n=s({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=D(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"):yn(e,t,n)}function yn(e,t,n){n&&An(e,n,t,"prevent"),Gt(e,Bt(e,t),Mt(e,null)),function(e,t){Yt(e,_n(e,t),_n(e,t))}(e,t)}function gn(e,t,n,o){if(!o){const{pathname:o,search:r,hash:i}=D(t);An(e,o+r+i,n,"prevent")}bn(e),Jt(e)}function bn(e){Gt(e,function(e,t){var n,o,r,i;let{pathname:s,search:a,hash:c}=t||at.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=J(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=J(l.searchQuery);a=t?"?"+t:""}return{fullPath:s+a+c,isAttach2Hash:u}}(e),function(e,t){return _(null==t?void 0:t.microAppState)&&(u(t.microAppState[e])||delete t.microAppState[e],Object.keys(t.microAppState).length||delete t.microAppState),s({},t)}(e,at.rawWindow.history.state))}function vn(e,t){const n=u(t)?at.rawWindow.fetch:t;return f(n)?function(t,o,...r){return(h(t)||g(t))&&(t=D(t,e).toString()),j(),n.call(at.rawWindow,t,o,...r)}:n}function En(e,t){const n=u(t)?at.rawWindow.XMLHttpRequest:t;return y(n)?class extends n{open(t,n,...o){(h(n)&&!/^f(ile|tp):\/\//.test(n)||g(n))&&(n=D(n,e).toString()),j(),super.open(t,n,...o)}}:n}const{createMicroEventSource:Pn,clearMicroEventSource:Rn}=function(){let e;return{createMicroEventSource:function(t,n,o){const r=u(o)?at.rawWindow.EventSource:o;return y(r)?class extends r{constructor(o,r,...i){if((h(o)||g(o))&&(o=D(o,n).toString()),j(),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 Nn{constructor(e,t){this.active=!1,this.scopeProperties=[],this.escapeProperties=[],this.escapeKeys=new Set,this.injectedKeys=new Set,this.microAppWindow={},this.adapter=new je,this.getSpecialProperties(e),this.windowEffect=this.patchWithWindow(e,this.microAppWindow),this.documentEffect=this.patchWithDocument(e,this.microAppWindow),this.initStaticGlobalKeys(e,t,this.microAppWindow)}start({umdMode:e,baseroute:t,useMemoryRouter:n,defaultPage:o,disablePatchRequest:r}){this.active||(this.active=!0,n?(u(this.microAppWindow.location)&&this.setMicroAppRouter(this.microAppWindow.__MICRO_APP_NAME__,this.microAppWindow.__MICRO_APP_URL__,this.microAppWindow),this.initRouteState(o),this.removeHistoryListener=$t(this.microAppWindow.__MICRO_APP_NAME__)):this.microAppWindow.__MICRO_APP_BASE_ROUTE__=this.microAppWindow.__MICRO_APP_BASE_URL__=t,e||this.initGlobalKeysWhenStart(this.microAppWindow.__MICRO_APP_NAME__,this.microAppWindow.__MICRO_APP_URL__,this.microAppWindow,r),1==++at.activeSandbox&&(ot(),Vt()),1==++Nn.activeCount&&window.__MICRO_APP_ENVIRONMENT__&&(St(),window.addEventListener("unmount",Rt,!1)),at.rawWindow._babelPolyfill&&(at.rawWindow._babelPolyfill=!1))}stop({umdMode:e,keepRouteState:t,destroy:n,clearData:o}){this.active&&(this.recordAndReleaseEffect({umdMode:e,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(at.rawWindow,e)})),this.escapeKeys.clear()),0==--at.activeSandbox&&(it(),zt()),--Nn.activeCount,this.active=!1)}initStaticGlobalKeys(e,t,n){n.__MICRO_APP_ENVIRONMENT__=!0,n.__MICRO_APP_NAME__=e,n.__MICRO_APP_URL__=t,n.__MICRO_APP_PUBLIC_PATH__=L(t),n.__MICRO_APP_BASE_ROUTE__="",n.__MICRO_APP_WINDOW__=n,n.__MICRO_APP_PRE_RENDER__=!1,n.__MICRO_APP_UMD_MODE__=!1,n.rawWindow=at.rawWindow,n.rawDocument=at.rawDocument,n.microApp=s(new gt(e),{removeDomScope:j,pureCreateElement:K,router:Xt}),this.setMappingPropertiesWithRawDescriptor(n)}recordAndReleaseEffect(e,t=!1){t?this.resetEffectSnapshot():this.recordEffectSnapshot(),this.releaseGlobalEffect(e)}resetEffectSnapshot(){this.windowEffect.reset(),this.documentEffect.reset(),Et(this.microAppWindow.microApp)}recordEffectSnapshot(){this.windowEffect.record(),this.documentEffect.record(),bt(this.microAppWindow.microApp)}rebuildEffectSnapshot(){this.windowEffect.rebuild(),this.documentEffect.rebuild(),vt(this.microAppWindow.microApp)}releaseGlobalEffect({umdMode:e=!1,clearData:t=!1,isPrerender:n=!1,keepAlive:o=!1,destroy:r=!1}){var i,s,a;this.windowEffect.release(!e&&!o&&!n||r),this.documentEffect.release(),null===(i=this.microAppWindow.microApp)||void 0===i||i.clearDataListener(),null===(s=this.microAppWindow.microApp)||void 0===s||s.clearGlobalDataListener(),t&&(Qn.clearData(this.microAppWindow.__MICRO_APP_NAME__),null===(a=this.microAppWindow.microApp)||void 0===a||a.clearData())}getSpecialProperties(e){var t;this.scopeProperties=this.scopeProperties.concat(this.adapter.staticScopeProperties),_(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(i(e))for(const t of e)_(t)&&(i(t.scopeProperties)&&(this.scopeProperties=this.scopeProperties.concat(t.scopeProperties)),i(t.escapeProperties)&&(this.escapeProperties=this.escapeProperties.concat(t.escapeProperties)))}createProxyWindow(e,t){const n=at.rawWindow,o=new Map;return new Proxy(t,{get:(t,o)=>($(e),Reflect.has(t,o)||h(o)&&/^__MICRO_APP_/.test(o)||this.scopeProperties.includes(o)?Reflect.get(t,o):ft(Reflect.get(n,o),n)),set:(e,t,o)=>{if(this.adapter.escapeSetterKeyList.includes(t))Reflect.set(n,t,o);else if(l.call(e,t)||!l.call(n,t)||this.scopeProperties.includes(t))!Reflect.has(e,t)&&this.injectedKeys.add(t),Reflect.set(e,t,o);else{const r=Object.getOwnPropertyDescriptor(n,t),{configurable:i,enumerable:s,writable:c,set:l}=r;a(e,t,{value:o,configurable:i,enumerable:s,writable:null!=c?c:!!l}),this.injectedKeys.add(t)}return(this.escapeProperties.includes(t)||this.adapter.staticEscapeProperties.includes(t)&&!Reflect.has(n,t))&&!this.scopeProperties.includes(t)&&(!Reflect.has(n,t)&&this.escapeKeys.add(t),Reflect.set(n,t,o)),!0},has:(e,t)=>this.scopeProperties.includes(t)?t in e:t in e||t in n,getOwnPropertyDescriptor:(e,t)=>{if(l.call(e,t))return o.set(t,"target"),Object.getOwnPropertyDescriptor(e,t);if(l.call(n,t)){o.set(t,"rawWindow");const e=Object.getOwnPropertyDescriptor(n,t);return e&&!e.configurable&&(e.configurable=!0),e}},defineProperty:(e,t,r)=>"rawWindow"===o.get(t)?Reflect.defineProperty(n,t,r):Reflect.defineProperty(e,t,r),ownKeys:e=>Reflect.ownKeys(n).concat(Reflect.ownKeys(e)).filter((function(e){return!(e in this)&&(this[e]=!0)}),Object.create(null)),deleteProperty:(e,t)=>!l.call(e,t)||(this.injectedKeys.has(t)&&this.injectedKeys.delete(t),this.escapeKeys.has(t)&&Reflect.deleteProperty(n,t),Reflect.deleteProperty(e,t))})}patchWithWindow(e,t){return this.proxyWindow=this.createProxyWindow(e,t),function(e,t){const n=new Map,o=new Map,r=new Map,i=new Map,{rawWindow:s,rawAddEventListener:a,rawRemoveEventListener:c,rawSetInterval:l,rawSetTimeout:u,rawClearInterval:p,rawClearTimeout:h}=at;t.addEventListener=function(t,o,r){t=Qe(t,e);const i=n.get(t);i?i.add(o):n.set(t,new Set([o])),o&&(o.__MICRO_APP_MARK_OPTIONS__=r),a.call(s,t,o,r)},t.removeEventListener=function(t,o,r){t=Qe(t,e);const i=n.get(t);(null==i?void 0:i.size)&&i.has(o)&&i.delete(o),c.call(s,t,o,r)},t.setInterval=function(e,t,...n){const o=l.call(s,e,t,...n);return r.set(o,{handler:e,timeout:t,args:n}),o},t.setTimeout=function(e,t,...n){const o=u.call(s,e,t,...n);return i.set(o,{handler:e,timeout:t,args:n}),o},t.clearInterval=function(e){r.delete(e),p.call(s,e)},t.clearTimeout=function(e){i.delete(e),h.call(s,e)};const d=()=>{o.clear()};return{reset:d,record:()=>{n.forEach(((e,t)=>{e.size&&o.set(t,new Set(e))}))},rebuild:()=>{o.forEach(((e,n)=>{for(const o of e)t.addEventListener(n,o,null==o?void 0:o.__MICRO_APP_MARK_OPTIONS__)})),d()},release:e=>{n.size&&(n.forEach(((e,t)=>{for(const n of e)c.call(s,t,n)})),n.clear()),e&&(r.forEach(((e,t)=>{p.call(s,t)})),i.forEach(((e,t)=>{h.call(s,t)})),r.clear(),i.clear())}}}(e,t)}patchWithDocument(e,t){const{proxyDocument:n,MicroDocument:o,documentEffect:r}=function(e,t){const n=new Map,o=new Map;let r=null,i=null;const{rawDocument:s,rawCreateElement:a,rawAddEventListener:c,rawRemoveEventListener:l}=at;function u(t,n){const o=a.call(s,t,n);return o.__MICRO_APP_NAME__=e,o}function p(e,t,o){const r=n.get(e);r?r.add(t):n.set(e,new Set([t])),t&&(t.__MICRO_APP_MARK_OPTIONS__=o),c.call(s,e,t,o)}function h(e,t,o){const r=n.get(e);(null==r?void 0:r.size)&&r.has(t)&&r.delete(t),l.call(s,e,t,o)}const d=()=>{o.clear(),i=null},m=new Proxy(s,{get:(n,o)=>($(e),Ke(m),"createElement"===o?u:o===Symbol.toStringTag?"ProxyDocument":"defaultView"===o?t.proxyWindow:"onclick"===o?r:"addEventListener"===o?p:"removeEventListener"===o?h:ft(Reflect.get(n,o),s,"DOCUMENT")),set:(e,t,n)=>("onclick"===t?(f(r)&&l.call(s,"click",r,!1),f(n)&&c.call(s,"click",n,!1),r=n):Reflect.set(e,t,n),!0)});return{proxyDocument:m,MicroDocument:Nt(e,m),documentEffect:{reset:d,record:()=>{i=i||r,n.forEach(((e,t)=>{e.size&&o.set(t,new Set(e))}))},rebuild:()=>{i&&(m.onclick=i),o.forEach(((e,t)=>{for(const n of e)m.addEventListener(t,n,null==n?void 0:n.__MICRO_APP_MARK_OPTIONS__)})),d()},release:()=>{f(r)&&(l.call(s,"click",r),r=null),n.size&&(n.forEach(((e,t)=>{for(const n of e)l.call(s,t,n)})),n.clear())}}}}(e,this);return c(t,{document:{configurable:!1,enumerable:!0,get:()=>n},Document:{configurable:!1,enumerable:!1,get:()=>o}}),r}setPreRenderState(e){this.microAppWindow.__MICRO_APP_PRE_RENDER__=e}markUmdMode(e){this.microAppWindow.__MICRO_APP_UMD_MODE__=e}setMappingPropertiesWithRawDescriptor(e){let t,n;const o=at.rawWindow;o===o.parent?t=n=this.proxyWindow:(t=o.top,n=o.parent),a(e,"top",this.createDescriptorForMicroAppWindow("top",t)),a(e,"parent",this.createDescriptorForMicroAppWindow("parent",n)),Sn.forEach((t=>{a(e,t,this.createDescriptorForMicroAppWindow(t,this.proxyWindow))}))}createDescriptorForMicroAppWindow(e,t){const{configurable:n=!0,enumerable:o=!0,writable:r,set:i}=Object.getOwnPropertyDescriptor(at.rawWindow,e)||{writable:!0};return{value:t,configurable:n,enumerable:o,writable:null!=r?r:!!i}}initGlobalKeysWhenStart(e,t,n,o){n.hasOwnProperty=e=>l.call(n,e)||l.call(at.rawWindow,e),this.setHijackProperty(e,n),o||this.patchRequestApi(e,t,n),this.setScopeProperties(n)}setHijackProperty(e,t){let n,o;c(t,{eval:{configurable:!0,enumerable:!1,get:()=>($(e),n||eval),set:e=>{n=e}},Image:{configurable:!0,enumerable:!1,get:()=>($(e),o||at.ImageProxy),set:e=>{o=e}}})}patchRequestApi(e,t,n){let o=vn(t),r=En(t),i=Pn(e,t);c(n,{fetch:{configurable:!0,enumerable:!0,get:()=>o,set(e){o=vn(t,e)}},XMLHttpRequest:{configurable:!0,enumerable:!0,get:()=>r,set(e){r=En(t,e)}},EventSource:{configurable:!0,enumerable:!0,get:()=>i,set(n){i=Pn(e,t,n)}}})}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:jt(e,n)}}(e,t);c(n,{location:{configurable:!1,enumerable:!0,get:()=>o,set:e=>{at.rawWindow.location=e}},history:{configurable:!0,enumerable:!0,get:()=>r}})}initRouteState(e){wn(this.microAppWindow.__MICRO_APP_NAME__,this.microAppWindow.location,e)}clearRouteState(e){gn(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){Ve(e,this.microAppWindow.__MICRO_APP_NAME__)}actionBeforeExecScripts(e){this.patchStaticElement(e)}}function Mn(e,t){const n=at.rawWindow;return Zt.forEach((e=>{t[e]=ft(n[e],n)})),Object.getOwnPropertyNames(t).filter((e=>(en.some((o=>{if(o.test(e)&&e in t.parent){if(f(n[e]))t[e]=ft(n[e],n);else{const{configurable:o,enumerable:r}=Object.getOwnPropertyDescriptor(t,e)||{configurable:!0,enumerable:!0};o&&a(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:i,set:s}=Object.getOwnPropertyDescriptor(t,o)||{enumerable:!0,writable:!0};try{a(t,o,{enumerable:r,configurable:!0,get:()=>n[o],set:(null!=i?i:s)?e=>{n[o]=f(e)?e.bind(t):e}:void 0})}catch(t){M(t,e)}})),function(e){const{rawWindow:t,rawAddEventListener:n,rawRemoveEventListener:o}=at,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=at.rawDocument,o=t.Document,r=t.document,i=o.prototype.createElement,s=o.prototype.createTextNode,a=o.prototype.querySelector,c=o.prototype.querySelectorAll,l=o.prototype.getElementById,u=o.prototype.getElementsByClassName,p=o.prototype.getElementsByTagName,h=o.prototype.getElementsByName;function d(e){return r!==e?e:n}function m(t){var n,o;if(!t||Q(t)||r!==this){const e=d(this);return a.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 f(t){var n,o;if(!t||Q(t)||r!==this){const e=d(this);return c.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 ze(i.call(this,t,n),e)},o.prototype.createTextNode=function(t){return ze(s.call(this,t),e)},o.prototype.querySelector=m,o.prototype.querySelectorAll=f,o.prototype.getElementById=function(e){const t=d(this);if(G(e))return l.call(t,e);try{return m.call(this,`#${e}`)}catch(n){return l.call(t,e)}},o.prototype.getElementsByClassName=function(e){const t=d(this);if(G(e))return u.call(t,e);try{return f.call(this,`.${e}`)}catch(n){return u.call(t,e)}},o.prototype.getElementsByTagName=function(t){var n;const o=d(this);if(Q(t)||G(t)||!(null===(n=Ln.get(e))||void 0===n?void 0:n.inline)&&/^script$/i.test(t))return p.call(o,t);try{return f.call(this,t)}catch(e){return p.call(o,t)}},o.prototype.getElementsByName=function(e){const t=d(this);if(G(e))return h.call(t,e);try{return f.call(this,`[name=${e}]`)}catch(n){return h.call(t,e)}}}(e,t),function(e,t,n){const o=at.rawDocument,r=t.Document,i=t.document,s=(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(i,"form")],["images",()=>r.prototype.querySelectorAll.call(i,"img")],["links",()=>r.prototype.querySelectorAll.call(i,"a")]].forEach((t=>{e[t[0]]=s(t[0],t[1])})),cn.forEach((t=>{e[t]=s(t,(()=>o[t]))})),ln.forEach((t=>{e[t]=s(t,(()=>ft(o[t],o,"DOCUMENT")))})),un.forEach((t=>{e[t]=s(t,(()=>o[t]))})),pn.forEach((t=>{e[t]=s(t,(()=>ft(o[t],o,"DOCUMENT")))})),e};c(r.prototype,l()),sn.forEach((e=>{a(i,e,{enumerable:!0,configurable:!0,get:()=>o[e],set:t=>{o[e]=t}})}))}(0,t,n),function(e,t){const{rawDocument:n,rawAddEventListener:o,rawRemoveEventListener:r}=at,i=new Map,s=new Map;let c=null,l=null;const u=t.Document,p=t.document;function h(e,t){return on.includes(e)?t:n}function d(e){return"onclick"===e?e=>{f(c)&&r.call(n,"click",c,!1),f(e)?(c=e.bind(p),o.call(n,"click",c,!1)):c=e}:t=>{n[e]=f(t)?t.bind(p):t}}u.prototype.addEventListener=function(e,t,n){const r=f(t)?t.__MICRO_APP_BOUND_FUNCTION__=t.__MICRO_APP_BOUND_FUNCTION__||t.bind(this):t,s=i.get(e);s?s.add(t):i.set(e,new Set([t])),t&&(t.__MICRO_APP_MARK_OPTIONS__=n),o.call(h(e,this),e,r,n)},u.prototype.removeEventListener=function(e,t,n){const o=i.get(e);(null==o?void 0:o.size)&&o.has(t)&&o.delete(t);const s=(null==t?void 0:t.__MICRO_APP_BOUND_FUNCTION__)||t;r.call(h(e,this),e,s,n)},Object.getOwnPropertyNames(u.prototype).filter((e=>/^on/.test(e)&&!rn.includes(e))).forEach((t=>{const{enumerable:o,writable:r,set:i}=Object.getOwnPropertyDescriptor(u.prototype,t)||{enumerable:!0,writable:!0};try{a(u.prototype,t,{enumerable:o,configurable:!0,get:()=>"onclick"===t?c:n[t],set:(null!=r?r:i)?d(t):void 0})}catch(t){M(t,e)}}));const m=()=>{s.clear(),l=null},_=()=>{l&&(p.onclick=l),s.forEach(((e,t)=>{for(const n of e)p.addEventListener(t,n,null==n?void 0:n.__MICRO_APP_MARK_OPTIONS__)})),m()};return{reset:m,record:()=>{l=l||c,i.forEach(((e,t)=>{e.size&&s.set(t,new Set(e))}))},rebuild:_,release:()=>{f(c)&&(r.call(n,"click",c),c=null),i.size&&(i.forEach(((e,t)=>{for(const n of e)r.call(h(t,p),t,(null==n?void 0:n.__MICRO_APP_BOUND_FUNCTION__)||n)})),i.clear())}}}(e,t)}function Dn(e,t,n,o){!function(e,t,n){const o=at.rawRootElement,r=at.rawDocument,i=t.document,s=t.Node,c=t.Element,l=s.prototype.appendChild,u=s.prototype.insertBefore,p=s.prototype.replaceChild,h=s.prototype.removeChild,d=c.prototype.append,m=c.prototype.prepend,f=c.prototype.insertAdjacentElement,_=s.prototype.cloneNode,A=Object.getOwnPropertyDescriptor(c.prototype,"innerHTML"),w=Object.getOwnPropertyDescriptor(s.prototype,"parentNode"),y=e=>(R(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__,g=e=>e===n.microHead?r.head:e===n.microBody?r.body:e;s.prototype.getRootNode=function(){return i},s.prototype.appendChild=function(t){return ze(t,e),y(t)?l.call(this,t):o.prototype.appendChild.call(g(this),t)},s.prototype.insertBefore=function(t,n){return ze(t,e),y(t)?u.call(this,t,n):o.prototype.insertBefore.call(g(this),t,n)},s.prototype.replaceChild=function(t,n){return ze(t,e),y(t)?p.call(this,t,n):o.prototype.replaceChild.call(g(this),t,n)},s.prototype.removeChild=function(e){return y(e)||this.contains(e)?h.call(this,e):o.prototype.removeChild.call(g(this),e)},c.prototype.append=function(...e){let t=0,n=!1;for(;t<e.length;)e[t]=v(e[t])?e[t]:i.createTextNode(e[t]),y(e[t])&&(n=!0),t++;return n?d.call(this,...e):o.prototype.append.call(g(this),...e)},c.prototype.prepend=function(...e){let t=0,n=!1;for(;t<e.length;)e[t]=v(e[t])?e[t]:i.createTextNode(e[t]),y(e[t])&&(n=!0),t++;return n?m.call(this,...e):o.prototype.prepend.call(g(this),...e)},c.prototype.insertAdjacentElement=function(t,n){return ze(n,e),y(n)?f.call(this,t,n):o.prototype.insertAdjacentElement.call(g(this),t,n)},s.prototype.cloneNode=function(t){return ze(_.call(this,t),e)},a(c.prototype,"innerHTML",{configurable:!0,enumerable:!0,get(){return A.get.call(this)},set(t){A.set.call(this,t),Array.from(this.children).forEach((t=>{b(t)&&ze(t,e)}))}}),a(s.prototype,"parentNode",{configurable:!0,enumerable:!0,get(){var t,n,o;Ke(i);const s=w.get.call(this);return S(s)&&(null===(t=Ln.get(e))||void 0===t?void 0:t.container)?(null===(o=(n=Qn.options).getRootElementParentNode)||void 0===o?void 0:o.call(n,this,e))||r.body:s}});const E=new Proxy(t.Image,{construct(t,n){const o=new t(...n);return ze(o,e),o}});a(t,"Image",{configurable:!0,writable:!0,value:E})}(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=W(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:i,set:s}=Object.getOwnPropertyDescriptor(e,n)||{enumerable:!0,configurable:!0};a(e,n,{enumerable:o,configurable:r,get:function(){return null==i?void 0:i.call(this)},set:function(e){null==s||s.call(this,W(e,t))}})}))}(0,t,n)}Nn.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=at.rawWindow.location,o=n.protocol+"//"+n.host;this.deleteIframeElement=this.createIframeElement(e,o),this.microAppWindow=this.iframe.contentWindow,this.patchIframe(this.microAppWindow,(n=>{this.createIframeTemplate(this.microAppWindow),this.getSpecialProperties(e),this.proxyLocation=function(e,t,n,o){const r=new URL(t),i=r.protocol+"//"+r.host,a=r.pathname+r.search+r.hash,c=n.history;return n.rawReplaceState=c.replaceState,s(c,jt(e,n.location)),An(e,a,n.location,"prevent"),fn(e,t,n,r,o,i)}(e,t,this.microAppWindow,o),this.proxyWindow=this.createProxyWindow(this.microAppWindow),this.initStaticGlobalKeys(e,t),this.windowEffect=Mn(e,this.microAppWindow),this.documentEffect=Cn(e,this.microAppWindow,this.proxyLocation),Dn(e,t,this.microAppWindow,this),n()}))}createIframeElement(e,t){this.iframe=K("iframe");const n={src:t,style:"display: none",id:e};return Object.keys(n).forEach((e=>this.iframe.setAttribute(e,n[e]))),at.rawDocument.body.appendChild(this.iframe),()=>C((()=>{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,this.initRouteState(n),this.removeHistoryListener=$t(this.microAppWindow.__MICRO_APP_NAME__),o||this.createIframeBase(),1==++at.activeSandbox&&(ot(),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(at.rawWindow,e)})),this.escapeKeys.clear()),0==--at.activeSandbox&&(it(),zt()),--On.activeCount,this.active=!1)}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__=L(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=at.rawWindow,this.microAppWindow.rawDocument=at.rawDocument,this.microAppWindow.microApp=s(new gt(e),{removeDomScope:j,pureCreateElement:K,location:this.proxyLocation,router:Xt})}recordAndReleaseEffect(e,t=!1){t?this.resetEffectSnapshot():this.recordEffectSnapshot(),this.releaseGlobalEffect(e)}resetEffectSnapshot(){this.windowEffect.reset(),this.documentEffect.reset(),Et(this.microAppWindow.microApp)}recordEffectSnapshot(){this.windowEffect.record(),this.documentEffect.record(),bt(this.microAppWindow.microApp)}rebuildEffectSnapshot(){this.windowEffect.rebuild(),this.documentEffect.rebuild(),vt(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}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=K("base"),this.updateIframeBase(),this.microHead.appendChild(this.baseElement)}createProxyWindow(e){const t=at.rawWindow;return new Proxy(e,{get:(e,t)=>"location"===t?this.proxyLocation:hn.includes(t.toString())?this.proxyWindow:ft(Reflect.get(e,t),e),set:(e,n,o)=>"location"===n?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)),!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;_(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(i(e))for(const t of e)_(t)&&i(t.escapeProperties)&&(this.escapeProperties=this.escapeProperties.concat(t.escapeProperties))}initRouteState(e){wn(this.microAppWindow.__MICRO_APP_NAME__,this.microAppWindow.location,e)}clearRouteState(e){gn(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){Ve(e,this.microAppWindow.__MICRO_APP_NAME__)}actionBeforeExecScripts(e){this.patchStaticElement(e)}}function In(e,t,n,o){var r;if(!e)return N(`element does not exist in lifecycle ${n}`,t);e=V(e),j();const i=s({name:t,container:e},o&&{error:o}),a=new CustomEvent(n,{detail:i});!function(e,t){Object.defineProperties(e,{currentTarget:{get:()=>t},target:{get:()=>t}})}(a,e),f(null===(r=Qn.options.lifeCycles)||void 0===r?void 0:r[n])&&Qn.options.lifeCycles[n](a),e.dispatchEvent(a)}function xn(e,t,n={}){const o=new CustomEvent(Qe(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=se.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(se.LOADING),me.getInstance().run(this,dt)}onLoad(e,t,n){var o;if(2==++this.loadSourceLevel)if(this.source.html=e,this.setAppState(se.LOADED),this.isPrefetch||se.UNMOUNT===this.state){if(this.isPrerender){const e=K("div");e.setAttribute("prerender","true"),null===(o=this.sandBox)||void 0===o||o.setPreRenderState(!0),this.mount({container:e,inline:this.inline,useMemoryRouter:!0,baseroute:"",fiber:!0,defaultPage:null!=t?t:"",disablePatchRequest:null!=n&&n})}}else V(this.container).mount(this)}onLoadError(e){this.loadSourceLevel=-1,se.UNMOUNT!==this.state&&(this.onerror(e),this.setAppState(se.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(se.LOADING);this.createSandbox();const a=()=>{var a,c,l,p,d,m,_;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(),q(this.container,e,!1),this.container=e,null===(c=this.preRenderEvents)||void 0===c||c.forEach((e=>e())),this.isPrerender=!1,this.preRenderEvents=null,Xt.attachToURL(this.name),null===(l=this.sandBox)||void 0===l||l.setPreRenderState(!1);else{this.container=e,this.inline=t,this.fiber=s,this.useMemoryRouter=n;const a=()=>In(this.container,this.name,ae.BEFOREMOUNT);if(this.isPrerender?(null!==(p=this.preRenderEvents)&&void 0!==p?p:this.preRenderEvents=[]).push(a):a(),this.setAppState(se.MOUNTING),q(this.source.html,this.container,!this.umdMode),null===(d=this.sandBox)||void 0===d||d.start({umdMode:this.umdMode,baseroute:r,useMemoryRouter:n,defaultPage:o,disablePatchRequest:i}),this.umdMode){null===(_=this.sandBox)||void 0===_||_.rebuildEffectSnapshot();try{this.handleMounted(this.umdHookMount(Qn.getData(this.name,!0)))}catch(e){N("An error occurred in window.mount \n",this.name,e)}}else null===(m=this.sandBox)||void 0===m||m.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=Se.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(de(s,e.name)),i.push([s,o]),Me(e,o)&&(t.moduleCount=t.moduleCount?++t.moduleCount:1)):te(n,(()=>{He(s,e,o),t(!1)}))}r.length?U(r,(e=>{const t=i[e.index][1];t.code=t.code||e.data}),(n=>{t.errorCount=t.errorCount?++t.errorCount:1,N(n,e.name)}),(()=>{i.forEach((([o,r])=>{h(r.code)&&te(n,(()=>{He(o,e,r,t),!Me(e,r)&&t(!1)}))})),n?(n.push((()=>Promise.resolve(t(u(t.moduleCount)||t.errorCount===r.length)))),ne(n)):t(u(t.moduleCount)||t.errorCount===r.length)})):n?(n.push((()=>Promise.resolve(t(!0)))),ne(n)):t(!0)}(this,(e=>{if(!this.umdMode){const{mount:t,unmount:n}=this.getUmdLibraryHooks();if(this.umdHookUnmount=n,f(t)&&f(n)){this.umdHookMount=t,this.sandBox.markUmdMode(this.umdMode=!0);try{this.handleMounted(this.umdHookMount(Qn.getData(this.name,!0)))}catch(e){N("An error occurred in window.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=()=>{w(e)?e.then((()=>this.dispatchMountedEvent())).catch((()=>this.dispatchMountedEvent())):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(){se.UNMOUNT!==this.state&&(this.setAppState(se.MOUNTED),re(this.getMicroAppGlobalHook(ce.ONMOUNT),this.name,ce.ONMOUNT,Qn.getData(this.name,!0)),In(this.container,this.name,ae.MOUNTED))}unmount({destroy:e,clearData:t,keepRouteState:n,unmountcb:o}){var r;e=e||this.state===se.LOAD_FAILED,this.setAppState(se.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){N("An error occurred in window.unmount \n",this.name,e)}xn(this,"unmount"),re(this.getMicroAppGlobalHook(ce.ONUNMOUNT),this.name,ce.ONUNMOUNT),this.handleUnmounted({destroy:e,clearData:t,keepRouteState:n,unmountcb:o,umdHookUnmountResult:i})}handleUnmounted({destroy:e,clearData:t,keepRouteState:n,unmountcb:o,umdHookUnmountResult:r}){const i=()=>this.actionsForUnmount({destroy:e,clearData:t,keepRouteState:n,unmountcb:o});w(r)?(j(),r.then(i).catch(i)):i()}actionsForUnmount({destroy:e,clearData:t,keepRouteState:n,unmountcb:o}){var r;this.umdMode&&this.container&&!e&&q(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}),In(this.container,this.name,ae.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(),j()}actionsForCompletelyDestroy(){var e,t;null===(t=null===(e=this.sandBox)||void 0===e?void 0:e.deleteIframeElement)||void 0===t||t.call(e),Se.script.deleteInlineInfo(this.source.scripts),Ln.delete(this.name)}hiddenKeepAliveApp(e){var t,n;this.setKeepAliveState(le.KEEP_ALIVE_HIDDEN),xn(this,"appstate-change",{appState:"afterhidden"}),In(this.container,this.name,ae.AFTERHIDDEN),this.useMemoryRouter&&(null===(t=this.sandBox)||void 0===t||t.removeRouteInfoForKeepAliveApp()),this.container=q(this.container,K("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,ae.BEFORESHOW),this.setKeepAliveState(le.KEEP_ALIVE_SHOW),this.container=q(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,ae.AFTERSHOW)}onerror(e){In(this.container,this.name,ae.ERROR,e)}createSandbox(){this.useSandbox&&!this.sandBox&&(this.iframe?this.sandBox=new On(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(se.UNMOUNT!==this.state&&this.sandBox){const e=V(this.container).getAttribute("library")||`micro-app-${this.name}`,t=this.sandBox.proxyWindow;return A(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 f(o)?o:null}querySelector(e){return this.container?at.rawElementQuerySelector.call(this.container,e):null}querySelectorAll(e){return this.container?at.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 n extends HTMLElement{constructor(){super(...arguments),this.isWaiting=!1,this.cacheData=null,this.connectedCount=0,this.connectStateMap=new Map,this.appName="",this.appUrl="",this.ssrUrl="",this.version=t,this.handleAttributeUpdate=()=>{if(this.isWaiting=!1,!this.connectStateMap.get(this.connectedCount))return;const e=x(this.getAttribute("name")),t=I(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()!==se.UNMOUNT&&n.getKeepAliveState()!==le.KEEP_ALIVE_HIDDEN&&!n.isPrefetch)return this.setAttribute("name",this.appName),N(`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)}}static get observedAttributes(){return["name","url"]}connectedCallback(){const e=++this.connectedCount;this.connectStateMap.set(e,!0);const t=this.appName&&this.appUrl;C((()=>{this.connectStateMap.get(e)&&(In(this,this.appName,ae.CREATED),t&&this.handleConnected())}))}disconnectedCallback(){this.connectStateMap.set(this.connectedCount,!1),this.handleDisconnected()}reload(e){return new Promise((t=>{const n=()=>{this.removeEventListener(ae.MOUNTED,n),this.removeEventListener(ae.AFTERSHOW,n),t(!0)};this.addEventListener(ae.MOUNTED,n),this.addEventListener(ae.AFTERSHOW,n),this.handleDisconnected(e,(()=>{this.handleConnected()}))}))}handleDisconnected(e=!1,t){const n=Ln.get(this.appName);n&&n.getAppState()!==se.UNMOUNT&&n.getKeepAliveState()!==le.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===ie.NAME?"appName":"appUrl"]!==n)if(e!==ie.URL||this.appUrl)if(e!==ie.NAME||this.appName)this.isWaiting||(this.isWaiting=!0,C(this.handleAttributeUpdate));else{const e=x(n);if(!e)return N(`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=I(n,this.appName)))return N(`Invalid attribute url ${n}`,this.appName);this.appUrl=n,this.handleInitialNameAndUrl()}}handleInitialNameAndUrl(){this.connectStateMap.get(this.connectedCount)&&this.handleConnected()}handleConnected(){if(this.appName&&this.appUrl)if(this.getDisposeResult("shadowDOM")&&!this.shadowRoot&&f(this.attachShadow)&&this.attachShadow({mode:"open"}),this.updateSsrUrl(this.appUrl),Ln.has(this.appName)){const e=Ln.get(this.appName),t=e.ssrUrl||e.url,n=this.ssrUrl||this.appUrl;e.getKeepAliveState()===le.KEEP_ALIVE_HIDDEN&&e.url===this.appUrl?this.handleShowKeepAliveApp(e):t===n&&(e.getAppState()===se.UNMOUNT||e.isPrefetch&&this.sameCoreOptions(e))?this.handleAppMount(e):e.isPrefetch||e.getAppState()===se.UNMOUNT?this.handleCreateApp():N(`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()===le.KEEP_ALIVE_HIDDEN?n.url===this.appUrl?this.handleShowKeepAliveApp(n):N(`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!(!h(t)||!t)||(N(`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,C((()=>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()!==se.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()!==se.UNMOUNT&&t.getKeepAliveState()!==le.KEEP_ALIVE_HIDDEN&&t.hiddenKeepAliveApp(e)}handleShowKeepAliveApp(e){C((()=>{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=at.rawWindow.location;this.ssrUrl=W(t.pathname+t.search,e)}else{let t=function(e,t){const n=Tt(e);if(!n)return"";const o=D(n,t);return o.origin+o.pathname+o.search}(this.appName,e);const n=this.getDefaultPageValue();if(!t&&n){const o=D(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")||""}setAttribute(e,t){if("data"===e)if(_(t)){const e={};Object.getOwnPropertyNames(t).forEach((n=>{h(n)&&0===n.indexOf("__")||(e[n]=t[n])})),this.data=e}else"[object Object]"!==t&&M("property data must be an object",this.appName);else at.rawSetAttribute.call(this,e,t)}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}}at.rawWindow.customElements.define(e,n)}function Bn(e,t){if(!n)return N("preFetch is only supported in browser environment");T((()=>{const n=m(t)?t:Qn.options.prefetchDelay;setTimeout((()=>{!function(e){f(e)&&(e=e()),i(e)&&e.reduce(((e,t)=>e.then((()=>{return e=t,B((t=>{var n,o,r,i,s,a;if(_(e)&&navigator.onLine)if(e.name=x(e.name),e.url=I(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&&pe.includes(e.level)?e.level:Qn.options.prefetchLevel&&pe.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())}(e)}),m(n)?n:3e3)}))}function kn(e,t,n){if(i(e)){const o=e.filter((e=>h(e)&&e.includes(`.${t}`)&&!n.hasInfo(e)));U(o.map((e=>de(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=>{N(e)}))}}function Hn({excludeHiddenApp:e=!1,excludePreRender:t=!1}={}){const n=[];return Ln.forEach(((o,r)=>{se.UNMOUNT===o.getAppState()||o.isPrefetch&&(!o.isPrerender||t)||e&&le.KEEP_ALIVE_HIDDEN===o.getKeepAliveState()||n.push(r)})),n}function $n(){return Array.from(Ln.keys())}function Fn(e,t){const n=Ln.get(x(e));return new Promise((o=>{if(n)if(n.getAppState()===se.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()===le.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=V(n.container),r=()=>{e.removeEventListener(ae.UNMOUNT,r),e.removeEventListener(ae.AFTERHIDDEN,i),o(!0)},i=()=>{e.removeEventListener(ae.UNMOUNT,r),e.removeEventListener(ae.AFTERHIDDEN,i),o(!0)};if(e.addEventListener(ae.UNMOUNT,r),e.addEventListener(ae.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"),h(t)&&e.setAttribute("destroy",t),h(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),h(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),h(n)&&e.setAttribute("clear-data",n)}}else M(`app ${e} does not exist`),o(!1)}))}function jn(e){return Array.from(Ln.keys()).reduce(((t,n)=>t.then((()=>Fn(n,e)))),Promise.resolve(!0))}function Kn(e,t){return new Promise((n=>{const o=Ln.get(x(e));if(o){const r=o.container&&V(o.container);r?n(r.reload(t)):(M(`app ${e} is not rendered, cannot use reload`),n(!1))}else M(`app ${e} does not exist`),n(!1)}))}function qn(e){return new Promise((t=>{if(!_(e))return N("renderApp options must be an object");const n=b(e.container)?e.container:h(e.container)?document.querySelector(e.container):null;if(!b(n))return N("Target container is not a DOM element.");const o=K(Qn.tagName);for(const t in e)if("onDataChange"===t)f(e[t])&&o.addEventListener("datachange",e[t]);else if("lifeCycles"===t){const n=e[t];if(_(n))for(const e in n)e.toUpperCase()in ae&&f(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(ae.MOUNTED,r),o.removeEventListener(ae.ERROR,i)};o.addEventListener(ae.MOUNTED,r),o.addEventListener(ae.ERROR,i),n.appendChild(o)}))}class Gn extends yt{constructor(){super(...arguments),this.tagName="micro-app",this.options={},this.router=Xt,this.preFetch=Bn,this.unmountApp=Fn,this.unmountAllApps=jn,this.getActiveApps=Hn,this.getAllApps=$n,this.reload=Kn,this.renderApp=qn}start(e){var t,o,r;if(!n||!window.customElements)return N("micro-app is not supported in this environment");if(null==e?void 0:e.tagName){if(!/^micro-app(-\S+)?/.test(e.tagName))return N(`${e.tagName} is invalid tagName`);this.tagName=e.tagName}if(ct(),at.rawWindow.customElements.get(this.tagName))return M(`element ${this.tagName} is already defined`);if(_(e)&&(this.options=e,e["disable-scopecss"]=null!==(t=e["disable-scopecss"])&&void 0!==t?t:e.disableScopecss,e["disable-sandbox"]=null!==(o=e["disable-sandbox"])&&void 0!==o?o:e.disableSandbox,e.preFetchApps&&Bn(e.preFetchApps),e.globalAssets&&(_(r=e.globalAssets)&&T((()=>{kn(r.js,"js",Se.script),kn(r.css,"css",Se.link)}))),_(e.plugins))){const t=e.plugins.modules;if(_(t))for(const e in t){const n=x(e);n&&e!==n&&(t[n]=t[e],delete t[e])}}Tn(this.tagName)}}const Qn=new Gn;e.EventCenterForMicroApp=gt,e.MicroApp=Gn,e.default=Qn,e.getActiveApps=Hn,e.getAllApps=$n,e.preFetch=Bn,e.pureCreateElement=K,e.reload=Kn,e.removeDomScope=j,e.renderApp=qn,e.unmountAllApps=jn,e.unmountApp=Fn,e.version=t,Object.defineProperty(e,"__esModule",{value:!0})}));
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).microApp={})}(this,(function(e){"use strict";const t="1.0.0-beta.3",n="undefined"!=typeof window,o="undefined"!=typeof global?global:"undefined"!=typeof window?window:"undefined"!=typeof self?self:Function("return this")(),r=()=>!1,i=Array.isArray,s=Object.assign,a=Object.defineProperty,c=Object.defineProperties,l=Object.prototype.hasOwnProperty;function u(e){return void 0===e}function p(e){return null===e}function h(e){return"string"==typeof e}function d(e){return"boolean"==typeof e}function m(e){return"number"==typeof e}function f(e){return"function"==typeof e}function _(e){return"[object Object]"===toString.call(e)}function A(e){return"object"==typeof e}function w(e){return"[object Promise]"===toString.call(e)}function y(e){var t;if(f(e)){const n=e.toString();return(null===(t=e.prototype)||void 0===t?void 0:t.constructor)===e&&Object.getOwnPropertyNames(e.prototype).length>1||/^function\s+[A-Z]/.test(n)||/^class\s+/.test(n)}return!1}function g(e){var t;return e instanceof URL||!!(null===(t=e)||void 0===t?void 0:t.href)}function b(e){var t;return e instanceof Element||h(null===(t=e)||void 0===t?void 0:t.tagName)}function v(e){var t;return e instanceof Node||m(null===(t=e)||void 0===t?void 0:t.nodeType)}function E(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 P(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 R(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 S(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 C(e,t=null,...n){const o=t&&h(t)?` app ${t}:`:"";h(e)?console.error(`[micro-app]${o} ${e}`,...n):console.error(`[micro-app]${o}`,e,...n)}function M(e,t=null,...n){const o=t&&h(t)?` app ${t}:`:"";h(e)?console.warn(`[micro-app]${o} ${e}`,...n):console.warn(`[micro-app]${o}`,e,...n)}function N(e,...t){Promise.resolve().then(e.bind(null,...t))}const D=function(){class e extends URL{}return(t,n)=>n?new e(""+t,n):new e(""+t)}();function O(e){return e.startsWith("//")?`${o.location.protocol}${e}`:e}function I(e,t=null){if(!h(e)||!e)return"";try{const{origin:t,pathname:n,search:o}=D(O(e));if(/\.(\w+)$/.test(n))return`${t}${n}${o}`;const r=`${t}${n}/`.replace(/\/\/$/,"/");return/^https?:\/\//.test(r)?`${r}${o}`:""}catch(e){return C(e,t),""}}function x(e){return h(e)&&e?e.replace(/(^\d+)|([^\w\d-_])/gi,""):""}function L(e){const{origin:t,pathname:n}=D(e);if(/\.(\w+)$/.test(n)){const e=`${t}${n}`.split("/");return e.pop(),e.join("/")+"/"}return`${t}${n}/`.replace(/\/\/$/,"/")}function W(e,t){return!e||/^((((ht|f)tps?)|file):)?\/\//.test(e)||/^(data|blob):/.test(e)?e:D(e,L(O(t))).toString()}function U(e,t,n,o){let r=0;function i(){++r===e.length&&o&&o()}e.forEach(((e,o)=>{w(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 T=o.requestIdleCallback||function(e){const t=Date.now();return setTimeout((function(){e({didTimeout:!1,timeRemaining:()=>Math.max(0,50-(Date.now()-t))})}),1)};function B(e){return new Promise((t=>{T((()=>{e(t)}))}))}let k=null;function H(e){k=e}function $(e){k!==e&&(H(e),N((()=>{H(null)})))}function F(){return k}function j(){H(null)}function K(e,t){const n=document.createElement(e,t);return n.__MICRO_APP_NAME__&&delete n.__MICRO_APP_NAME__,n.__PURE_ELEMENT__=!0,n}function q(e,t,n){if(e.innerHTML="",n){const n=t.cloneNode(!0),o=document.createDocumentFragment();Array.from(n.childNodes).forEach((e=>{o.appendChild(e)})),e.appendChild(o)}else Array.from(t.childNodes).forEach((t=>{e.appendChild(t)}));return e}function G(e){return!e||/(^\d)|([^\w\d-_\u4e00-\u9fa5])/gi.test(e)}function Q(e){return/^body$/i.test(e)||/^head$/i.test(e)||/^html$/i.test(e)||/^title$/i.test(e)}function z(e){return function(e){return"undefined"!=typeof ShadowRoot&&e instanceof ShadowRoot}(e)?e.host:e}function V(e){return e?e.replace(/^\s+|\s+$/g,""):""}function X(){return navigator.userAgent.indexOf("Firefox")>-1}function Y(e){const t={},n=e.split("&");for(const e of n){const n=e.indexOf("="),o=n<0?e:e.slice(0,n),r=n<0?null:e.slice(n+1);if(o in t){let e=t[o];i(e)||(e=t[o]=[e]),e.push(r)}else t[o]=r}return t}function J(e){let t="";for(const n in e){const o=e[n];if(p(o))t+=(t.length?"&":"")+n;else{(i(o)?o:[o]).forEach((e=>{u(e)||(t+=(t.length?"&":"")+n,p(e)||(t+="="+e))}))}}return t}function Z(){const e=new Set;return{add:function(t){return e.add(t),()=>!!e.has(t)&&e.delete(t)},list:()=>e}}function ee(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 te(e,t){e?e.push((()=>B((e=>{t(),e()})))):t()}function ne(e){return(null==e?void 0:e.reduce(((e,t)=>e.then(t)),Promise.resolve()))||null}function oe(e){return e.startsWith("inline-")}function re(e,t,n,...o){try{f(e)&&e(...o)}catch(e){C(`An error occurred in app ${t} window.${n} \n`,null,e)}}var ie,se,ae,ce;!function(e){e.NAME="name",e.URL="url"}(ie||(ie={})),function(e){e.CREATED="created",e.LOADING="loading",e.LOAD_FAILED="load_failed",e.MOUNTING="mounting",e.MOUNTED="mounted",e.UNMOUNT="unmount"}(se||(se={})),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"}(ae||(ae={})),function(e){e.ONMOUNT="onmount",e.ONUNMOUNT="onunmount"}(ce||(ce={}));var le,ue;!function(e){e.KEEP_ALIVE_SHOW="keep_alive_show",e.KEEP_ALIVE_HIDDEN="keep_alive_hidden"}(le||(le={})),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"}(ue||(ue={}));const pe=[1,2,3],he="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 de(e,t=null,n={}){return j(),f(Qn.options.fetch)?Qn.options.fetch(e,n,t):window.fetch(e,n).then((e=>e.text()))}class me{static getInstance(){return this.instance||(this.instance=new me),this.instance}run(e,t){const n=e.name,o=e.ssrUrl||e.url;de(o,n,{cache:"no-cache"}).then((r=>{if(!r){const t="html is empty, please check in detail";return e.onerror(new Error(t)),C(t,n)}r=this.formatHTML(o,r,n),t(r,e)})).catch((t=>{C(`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)=>_(n)&&f(n.processHtml)?n.processHtml(t,e):t),t):t}}const fe=/(^|\s+)(html|:root)(?=[\s>~[.#:]+|$)/,_e=/(^|\s+)((html[\s>~]+body)|body)(?=[\s>~[.#:]+|$)/;function Ae(e,t){e=t?`${t} ${e}`:e;const n=new Error(e);throw n.reason=e,t&&(n.filename=t),n}class we{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(),X()?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):Ae("selector missing",this.linkPath)}formatSelector(e){const t=this.commonMatch(/^[^{]+/,e);return!!t&&t[0].replace(/(^|,[\n\s]*)([^,]+)/g,((e,t,n)=>(n=V(n),this.scopecssDisableNextLine||this.scopecssDisable&&(!this.scopecssDisableSelectors.length||this.scopecssDisableSelectors.includes(n))||fe.test(n)||(n=_e.test(n)?n.replace(_e,this.prefix+" micro-app-body"):this.prefix+" "+n),t+n)))}styleDeclarations(){return this.matchOpenBrace()?(this.matchAllDeclarations(),!!this.matchCloseBrace()||Ae("Declaration missing '}'",this.linkPath)):Ae("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(),O(t.join("/")+"/")}(this.linkPath)),`url("${W(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 Ae("@keyframes missing name",this.linkPath);if(this.matchComments(),!this.matchOpenBrace())return Ae("@keyframes missing '{'",this.linkPath);for(this.matchComments();this.keyframeRule();)this.matchComments();return this.matchCloseBrace()?(this.matchLeadingSpaces(),!0):Ae("@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):Ae(`${t} missing '}'`,this.linkPath)):Ae(`${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):Ae(`@${e} missing '}'`,this.linkPath)):Ae(`@${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 Ae("End of comment missing",this.linkPath);let t=this.cssText.slice(2,e-2);if(this.recordResult(`/*${t}*/`),t=V(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(V(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){X()?this.result+=encodeURIComponent(e):this.result+=e}}function ye(e,t,n,o,r){if(!e.__MICRO_APP_HAS_SCOPED__){e.__MICRO_APP_HAS_SCOPED__=!0;let i=null;try{i=ge.exec(e.textContent,n,o,r),ge.reset()}catch(e){ge.reset(),C("An error occurred while parsing CSS:\n",t,e)}i&&(e.textContent=i)}}let ge;function be(e,t,n){if(t.scopecss){const o=ve(t.name);if(ge||(ge=new we),e.textContent)ye(e,t.name,o,t.url,n);else{const r=new MutationObserver((function(){r.disconnect(),e.textContent&&!e.hasAttribute("data-styled")&&ye(e,t.name,o,t.url,n)}));r.observe(e,{childList:!0})}}return e}function ve(e,t=!1){const n=t?"\\":"";return`${Qn.tagName}${n}[name=${e}${n}]`}function Ee(e,t){Object.defineProperties(e,{currentTarget:{get:()=>t},srcElement:{get:()=>t},target:{get:()=>t}})}function Pe(e){const t=new CustomEvent("load");Ee(t,e),f(e.onload)?e.onload(t):e.dispatchEvent(t)}function Re(e){const t=new CustomEvent("error");Ee(t,e),f(e.onerror)?e.onerror(t):e.dispatchEvent(t)}var Se=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=>{oe(e)&&t.delete(e)}))}})}}();const Ce=["text/javascript","text/ecmascript","application/javascript","application/ecmascript","module","systemjs-module","systemjs-importmap"];function Me(e,t){return t.appSpace[e.name].module&&(!e.useSandbox||e.iframe)}function Ne(e,t){return e.inline||t.appSpace[e.name].inline||Me(e,t)||function(e,t){return t.appSpace[e.name].attrs.has("id")}(e,t)||e.iframe}function De(e){return e.iframe?e.sandBox.microAppWindow:at.rawWindow}function Oe(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(De(e).Function)(t)}(e,n)}function Ie(){const e="inline-"+Math.random().toString(36).substr(2,15);return Se.script.hasInfo(e)?Ie():e}function xe(e,t){return e.useSandbox&&!Me(e,t)}function Le(e,t){return xe(e,t)?e.iframe?"iframe":"with":"disable"}function We(e,t,n,o=!1){var r;let i=null,s=e.getAttribute("src");if(s&&(s=W(s,n.url)),e.hasAttribute("exclude")||Te(s,n.name))i=document.createComment("script element with exclude attribute removed by micro-app");else{if(e.type&&!Ce.includes(e.type)||e.hasAttribute("ignore")||Be(s,n.name))return(null===(r=at.rawDocument)||void 0===r?void 0:r.currentScript)&&delete at.rawDocument.currentScript,null;if(at.supportModuleScript&&e.noModule||!at.supportModuleScript&&"module"===e.type)i=document.createComment((e.noModule?"noModule":"module")+" script ignored by micro-app");else if(s){let t=Se.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:ee(e)};if(t?t.appSpace[n.name]=t.appSpace[n.name]||r:t={code:"",isExternal:!0,appSpace:{[n.name]:r}},Se.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=Ie(),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:ee(e)}}};if(o)return{address:t,scriptInfo:r};n.source.scripts.add(t),Se.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}:null==t?void 0:t.replaceChild(i,e)}function Ue(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 Te(e,t){if(!e)return!1;return(Ue(t)||[]).some((t=>!!t.excludeChecker&&t.excludeChecker(e)))}function Be(e,t){if(!e)return!1;return(Ue(t)||[]).some((t=>!!t.ignoreChecker&&t.ignoreChecker(e)))}function ke(e,t){const n=Array.from(t.source.scripts),o=[],r=[];for(const e of n){const n=Se.script.getInfo(e),i=n.appSpace[t.name];(!i.defer&&!i.async||t.isPrefetch&&!t.isPrerender)&&(o.push(n.code?n.code:de(e,t.name)),r.push([e,n]))}const i=t.isPrefetch||t.fiber?[]:null;o.length?U(o,(e=>{te(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=$e(e,o,n,t),r.sandboxType=Le(o,t),!Ne(o,t)))try{r.parsedFunction=Oe(o,t,r.parsedCode)}catch(e){C("Something went wrong while handling preloaded resources",o.name,"\n",e)}}}(r[e.index][0],r[e.index][1],e.data,t)))}),(e=>{C(e,t.name)}),(()=>{i?(i.push((()=>Promise.resolve(t.onLoad(e)))),ne(i)):t.onLoad(e)})):t.onLoad(e)}function He(e,t,n,o,r){try{!function(e){!function(e){e.sandBox&&(at.rawWindow.__MICRO_APP_PROXY_WINDOW__=e.sandBox.proxyWindow)}(e)}(t);const i=n.appSpace[t.name],s=Le(t,n);if(i.parsedCode&&i.sandboxType===s||(i.parsedCode=$e(e,t,n.code,n),i.sandboxType=s,i.parsedFunction=null),Ne(t,n)){const s=r||K("script");if(function(e,t,n,o,r,i){if(n){if(oe(e)){const e=new Blob([t],{type:"text/javascript"});o.src=URL.createObjectURL(e)}else o.src=e;at.rawSetAttribute.call(o,"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"),at.rawSetAttribute.call(e,n,t))}))}(o,r)}(e,i.parsedCode,Me(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=Oe(e,t,n.parsedCode));n.parsedFunction.call(De(e))}(t,n)}catch(n){console.error(`[micro-app from ${r?"runDynamicScript":"runScript"}] app ${t.name}: `,n,e)}}function $e(e,t,n,o){return _(Qn.options.plugins)&&(n=function(e,t,n,o){var r;const i=Fe(o.global,t,e);return Fe(null===(r=o.modules)||void 0===r?void 0:r[n],i,e)}(e,n,t.name,Qn.options.plugins)),xe(t,o)?t.iframe?`(function(window,self,global,location){;${n}\n${oe(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(${he}){;${n}\n${oe(e)?"":`//# sourceURL=${e}\n`}}).call(proxyWindow,${he})}})(window.__MICRO_APP_PROXY_WINDOW__);`:n}function Fe(e,t,n){return i(e)?e.reduce(((e,t)=>_(t)&&f(t.loader)?t.loader(e,n):e),t):t}class je{constructor(){this.escapeSetterKeyList=["location"],this.staticEscapeProperties=["System","__cjsWrapper"],this.staticScopeProperties=["webpackJsonp","webpackHotUpdate","Vue"],this.injectReactHMRProperty()}injectReactHMRProperty(){}}function Ke(e){const t=at.rawDocument.firstElementChild;(null==t?void 0:t.parentNode)===at.rawDocument&&(qe(t,e),N((()=>{qe(t,at.rawDocument)})))}function qe(e,t){const n=Object.getOwnPropertyDescriptor(e,"parentNode");n&&!n.configurable||a(e,"parentNode",{value:t,configurable:!0})}const Ge=["unmount","appstate-change"];function Qe(e,t){var n;return Un(t)||!Ge.includes(e)&&("popstate"!==e&&"hashchange"!==e||!(null===(n=Ln.get(t))||void 0===n?void 0:n.useMemoryRouter))?e:`${e}-${t}`}function ze(e,t){const n=Array.from(e.children);n.length&&n.forEach((e=>{ze(e,t)}));for(const e of n)Ve(e,t)}function Ve(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 v(e)&&!e.__MICRO_APP_NAME__&&!e.__PURE_ELEMENT__&&r&&(c(e,{baseURI:{configurable:!0,get:()=>r.location.href},__MICRO_APP_NAME__:{configurable:!0,writable:!0,value:t}}),Un(t)&&a(e,"ownerDocument",{configurable:!0,get:()=>r.document})),e}const Xe=new WeakMap;function Ye(e){var t;return null!==(t=Xe.get(e))&&void 0!==t?t:e}function Je(e,t){if(Xe.has(e))return Xe.get(e);if(P(e)){if(e.hasAttribute("exclude")){const t=document.createComment("style element with exclude attribute ignored by micro-app");return Xe.set(e,t),t}return t.scopecss&&!e.hasAttribute("ignore")?be(e,t):e}if(E(e)){if(e.hasAttribute("exclude")||Te(e.getAttribute("href"),t.name)){const t=document.createComment("link element with exclude attribute ignored by micro-app");return Xe.set(e,t),t}if(e.hasAttribute("ignore")||Be(e.getAttribute("href"),t.name)||e.href&&f(Qn.options.excludeAssetFilter)&&Qn.options.excludeAssetFilter(e.href))return e;const{address:n,linkInfo:o,replaceComment:r}=lt(e,null,t,!0);if(n&&o){const r=function(e,t,n,o){const r=K("style"),i=()=>{pt(t,e,r,n,n.appSpace[t.name].attrs),Pe(o)};n.code?N(i):de(e,t.name).then((e=>{n.code=e,i()})).catch((e=>{C(e,t.name),Re(o)}));return r}(n,t,o,e);return Xe.set(e,r),r}return r?(Xe.set(e,r),r):e}if(R(e)){if(e.src&&f(Qn.options.excludeAssetFilter)&&Qn.options.excludeAssetFilter(e.src))return e;const{replaceComment:n,address:o,scriptInfo:r}=We(e,null,t,!0)||{};if(o&&r){const n=r.isExternal?function(e,t,n,o){const r=Ne(t,n)?K("script"):document.createComment("dynamic script extract by micro-app"),i=()=>Pe(o),s=()=>{const s=Object.getOwnPropertyDescriptor(at.rawDocument,"currentScript");s&&!s.configurable||Object.defineProperty(at.rawDocument,"currentScript",{value:o,configurable:!0}),He(e,t,n,i,r),!Me(t,n)&&i()};return n.code||Me(t,n)?N(s):de(e,t.name).then((e=>{n.code=e,s()})).catch((e=>{C(e,t.name),Re(o)})),r}(o,t,r,e):function(e,t,n){const o=Ne(t,n)?K("script"):document.createComment("dynamic script extract by micro-app");return He(e,t,n,void 0,o),o}(o,t,r);return Xe.set(e,n),n}return n?(Xe.set(e,n),n):e}return e}function Ze(e,t,n,o,r){const i=et(n,o,e);if(i){if(!Un(e.name)&&S(i)&&t!==at.rawRemoveChild){const t=Object.getOwnPropertyDescriptor(o,"parentNode");t&&!t.configurable||o.__MICRO_APP_HAS_DPN__||c(o,{parentNode:{configurable:!0,get(){var t,n;const o=at.rawParentNodeDesc.get.call(this);return S(o)&&e.container?(null===(n=(t=Qn.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)?at.rawAppendChild.call(i,o):t!==at.rawRemoveChild||i.contains(o)?tt(t,i,o,r):n.contains(o)?t.call(n,o):o}return tt(t,n,o,r)}function et(e,t,n){if(n){if(e===document.head)return n.iframe&&R(t)?n.sandBox.microHead:n.querySelector("micro-app-head");if(e===document.body||e===document.body.parentNode)return n.iframe&&R(t)?n.sandBox.microBody:n.querySelector("micro-app-body");if(n.iframe&&R(t))return n.sandBox.microBody}return null}function tt(e,t,n,o){return(r=e)===at.rawAppend||r===at.rawPrepend?e.call(t,n):e.call(t,n,o);var r}function nt(e,t,n,o){const r=F();if(v(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 function(e,t){b(t)&&(/^(img|script)$/i.test(t.tagName)?(t.hasAttribute("src")&&at.rawSetAttribute.call(t,"src",W(t.getAttribute("src"),e.url)),t.hasAttribute("srcset")&&at.rawSetAttribute.call(t,"srcset",W(t.getAttribute("srcset"),e.url))):/^link$/i.test(t.tagName)&&t.hasAttribute("href")&&at.rawSetAttribute.call(t,"href",W(t.getAttribute("href"),e.url)))}(i,t),Ze(i,o,e,Je(t,i),n&&Ye(n))}return o===at.rawAppend||o===at.rawPrepend?o.call(e,t):o.call(e,t,n)}function ot(){!function(){const e=at.rawDocument,t=at.rawRootDocument;function n(t){return function(e){return"[object ProxyDocument]"===toString.call(e)}(t)?e:t}function o(t){var o,r;const i=n(this),s=F();return s&&t&&!Q(t)&&e===i?null!==(r=null===(o=Ln.get(s))||void 0===o?void 0:o.querySelector(t))&&void 0!==r?r:null:at.rawQuerySelector.call(i,t)}function r(t){var o,r;const i=n(this),s=F();return s&&t&&!Q(t)&&e===i?null!==(r=null===(o=Ln.get(s))||void 0===o?void 0:o.querySelectorAll(t))&&void 0!==r?r:[]:at.rawQuerySelectorAll.call(i,t)}t.prototype.createElement=function(e,t){return rt(at.rawCreateElement.call(n(this),e,t))},t.prototype.createElementNS=function(e,t,o){return rt(at.rawCreateElementNS.call(n(this),e,t,o))},t.prototype.createDocumentFragment=function(){return rt(at.rawCreateDocumentFragment.call(n(this)))},t.prototype.querySelector=o,t.prototype.querySelectorAll=r,t.prototype.getElementById=function(e){const t=n(this);if(!F()||G(e))return at.rawGetElementById.call(t,e);try{return o.call(t,`#${e}`)}catch(n){return at.rawGetElementById.call(t,e)}},t.prototype.getElementsByClassName=function(e){const t=n(this);if(!F()||G(e))return at.rawGetElementsByClassName.call(t,e);try{return r.call(t,`.${e}`)}catch(n){return at.rawGetElementsByClassName.call(t,e)}},t.prototype.getElementsByTagName=function(e){var t;const o=n(this),i=F();if(!i||Q(e)||G(e)||!(null===(t=Ln.get(i))||void 0===t?void 0:t.inline)&&/^script$/i.test(e))return at.rawGetElementsByTagName.call(o,e);try{return r.call(o,e)}catch(t){return at.rawGetElementsByTagName.call(o,e)}},t.prototype.getElementsByName=function(e){const t=n(this);if(!F()||G(e))return at.rawGetElementsByName.call(t,e);try{return r.call(t,`[name=${e}]`)}catch(n){return at.rawGetElementsByName.call(t,e)}}}();const e=at.rawRootElement;function t(e){const t=F();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}e.prototype.appendChild=function(e){return nt(this,e,null,at.rawAppendChild)},e.prototype.insertBefore=function(e,t){return nt(this,e,t,at.rawInsertBefore)},e.prototype.replaceChild=function(e,t){return nt(this,e,t,at.rawReplaceChild)},e.prototype.append=function(...e){let t=0;for(;t<e.length;){let n=e[t];n=v(n)?n:at.rawCreateTextNode.call(at.rawDocument,n),nt(this,rt(n),null,at.rawAppend),t++}},e.prototype.prepend=function(...e){let t=e.length;for(;t>0;){let n=e[t-1];n=v(n)?n:at.rawCreateTextNode.call(at.rawDocument,n),nt(this,rt(n),null,at.rawPrepend),t--}},e.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 Ze(t,at.rawRemoveChild,this,Ye(e));try{return at.rawRemoveChild.call(this,e)}catch(t){return(null==e?void 0:e.parentNode)&&at.rawRemoveChild.call(e.parentNode,e)}}return at.rawRemoveChild.call(this,e)},e.prototype.insertAdjacentElement=function(e,t){var n;if((null==t?void 0:t.__MICRO_APP_NAME__)&&b(t)){const o=Ln.get(t.__MICRO_APP_NAME__);if(null==o?void 0:o.container){const r=Je(t,o);if(!b(r))return t;const i=null!==(n=et(this,r,o))&&void 0!==n?n:this;return at.rawInsertAdjacentElement.call(i,e,r)}}return at.rawInsertAdjacentElement.call(this,e,t)},e.prototype.cloneNode=function(e){const t=at.rawCloneNode.call(this,e);return this.__MICRO_APP_NAME__&&(t.__MICRO_APP_NAME__=this.__MICRO_APP_NAME__),t},e.prototype.querySelector=function(e){var n;const o=null!==(n=t(this))&&void 0!==n?n:this;return at.rawElementQuerySelector.call(o,e)},e.prototype.querySelectorAll=function(e){var n;const o=null!==(n=t(this))&&void 0!==n?n:this;return at.rawElementQuerySelectorAll.call(o,e)},e.prototype.setAttribute=function(e,t){const n=this.__MICRO_APP_NAME__||F();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))){t=W(t,Ln.get(n).url)}at.rawSetAttribute.call(this,e,t)},a(e.prototype,"innerHTML",{configurable:!0,enumerable:!0,get(){return at.rawInnerHTMLDesc.get.call(this)},set(e){at.rawInnerHTMLDesc.set.call(this,e);const t=F();Array.from(this.children).forEach((e=>{b(e)&&t&&(e.__MICRO_APP_NAME__=t)}))}})}function rt(e){const t=F();return t&&(e.__MICRO_APP_NAME__=t),e}function it(){j(),function(){const e=at.rawRootDocument;e.prototype.createElement=at.rawCreateElement,e.prototype.createElementNS=at.rawCreateElementNS,e.prototype.createDocumentFragment=at.rawCreateDocumentFragment,e.prototype.querySelector=at.rawQuerySelector,e.prototype.querySelectorAll=at.rawQuerySelectorAll,e.prototype.getElementById=at.rawGetElementById,e.prototype.getElementsByClassName=at.rawGetElementsByClassName,e.prototype.getElementsByTagName=at.rawGetElementsByTagName,e.prototype.getElementsByName=at.rawGetElementsByName}();const e=at.rawRootElement;e.prototype.appendChild=at.rawAppendChild,e.prototype.insertBefore=at.rawInsertBefore,e.prototype.replaceChild=at.rawReplaceChild,e.prototype.removeChild=at.rawRemoveChild,e.prototype.append=at.rawAppend,e.prototype.prepend=at.rawPrepend,e.prototype.cloneNode=at.rawCloneNode,e.prototype.querySelector=at.rawElementQuerySelector,e.prototype.querySelectorAll=at.rawElementQuerySelectorAll,e.prototype.setAttribute=at.rawSetAttribute,a(e.prototype,"innerHTML",at.rawInnerHTMLDesc)}let st=!1;const at={__MICRO_APP_BASE_APPLICATION__:!0,activeSandbox:0};function ct(){if(n){const e=window.rawWindow||Function("return window")(),t=window.rawDocument||Function("return document")(),n=e.Document||Function("return Document")(),o=e.Element,r=e.Node,i=e.EventTarget,a=o.prototype.setAttribute,c=o.prototype.appendChild,l=o.prototype.insertBefore,u=o.prototype.replaceChild,p=o.prototype.removeChild,h=o.prototype.append,d=o.prototype.prepend,m=o.prototype.cloneNode,f=o.prototype.querySelector,_=o.prototype.querySelectorAll,A=o.prototype.insertAdjacentElement,w=Object.getOwnPropertyDescriptor(o.prototype,"innerHTML"),y=Object.getOwnPropertyDescriptor(r.prototype,"parentNode"),g=n.prototype.createElement,b=n.prototype.createElementNS,v=n.prototype.createDocumentFragment,E=n.prototype.createTextNode,P=n.prototype.querySelector,R=n.prototype.querySelectorAll,S=n.prototype.getElementById,C=n.prototype.getElementsByClassName,M=n.prototype.getElementsByTagName,N=n.prototype.getElementsByName,D=new Proxy(Image,{construct(e,t){const n=new e(...t),o=F();return o&&(n.__MICRO_APP_NAME__=o),n}}),O=e.setInterval,I=e.setTimeout,x=e.clearInterval,L=e.clearTimeout,W=e.history.pushState,U=e.history.replaceState,T=i.prototype.addEventListener,B=i.prototype.removeEventListener;s(at,{supportModuleScript:"noModule"in document.createElement("script"),rawWindow:e,rawDocument:t,rawRootDocument:n,rawRootElement:o,rawRootNode:r,rawSetAttribute:a,rawAppendChild:c,rawInsertBefore:l,rawReplaceChild:u,rawRemoveChild:p,rawAppend:h,rawPrepend:d,rawCloneNode:m,rawElementQuerySelector:f,rawElementQuerySelectorAll:_,rawInsertAdjacentElement:A,rawInnerHTMLDesc:w,rawParentNodeDesc:y,rawCreateElement:g,rawCreateElementNS:b,rawCreateDocumentFragment:v,rawCreateTextNode:E,rawQuerySelector:P,rawQuerySelectorAll:R,rawGetElementById:S,rawGetElementsByClassName:C,rawGetElementsByTagName:M,rawGetElementsByName:N,ImageProxy:D,rawSetInterval:O,rawSetTimeout:I,rawClearInterval:x,rawClearTimeout:L,rawPushState:W,rawReplaceState:U,rawAddEventListener:T,rawRemoveEventListener:B}),function(){if(!st){st=!0;const e=K("style");at.rawSetAttribute.call(e,"type","text/css"),e.textContent=`\n${Qn.tagName}, micro-app-body { display: block; } \nmicro-app-head { display: none; }`,at.rawDocument.head.appendChild(e)}}()}}function lt(e,t,n,o=!1){const r=e.getAttribute("rel");let i=e.getAttribute("href"),s=null;if("stylesheet"===r&&i){i=W(i,n.url);let t=Se.link.getInfo(i);const r={attrs:ee(e)};if(t?t.appSpace[n.name]=t.appSpace[n.name]||r:t={code:"",appSpace:{[n.name]:r}},Se.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`):null==t||t.removeChild(e):i&&at.rawSetAttribute.call(e,"href",W(i,n.url));return o?{replaceComment:s}:s?null==t?void 0:t.replaceChild(s,e):void 0}function ut(e,t,n,o){const r=Array.from(t.source.links),i=r.map((e=>{const n=Se.link.getInfo(e);return n.code?n.code:de(e,t.name)})),s=o?[]:null;U(i,(e=>{te(s,(()=>function(e,t,n,o){const r=Se.link.getInfo(e);r.code=t;const i=r.appSpace[o.name],s=i.placeholder;if(s){const t=K("style");pt(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=>{C(e,t.name)}),(()=>{o?o.then((()=>{s.push((()=>Promise.resolve(t.onLoad(e)))),ne(s)})):t.onLoad(e)}))}function pt(e,t,n,o,r){if(e.scopecss){const r=o.appSpace[e.name];if(r.prefix=r.prefix||ve(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(ve(n,!0),"g"),t)}}(e.name,r.prefix,o);i?n.textContent=i:(n.textContent=o.code,be(n,e,t)),r.parsedCode=n.textContent}}else n.textContent=o.code;!function(e,t){t.forEach(((t,n)=>{"rel"!==n&&("href"===n&&(n="data-origin-href"),at.rawSetAttribute.call(e,n,t))}))}(n,r)}function ht(e,t,n,o){const r=Array.from(e.children);r.length&&r.forEach((e=>{ht(e,t,n,o)}));for(const n of r)E(n)?n.hasAttribute("exclude")||Te(n.getAttribute("href"),t.name)?e.replaceChild(document.createComment("link element with exclude attribute ignored by micro-app"),n):n.hasAttribute("ignore")||Be(n.getAttribute("href"),t.name)?n.hasAttribute("href")&&at.rawSetAttribute.call(n,"href",W(n.getAttribute("href"),t.url)):lt(n,e,t):P(n)?n.hasAttribute("exclude")?e.replaceChild(document.createComment("style element with exclude attribute ignored by micro-app"),n):t.scopecss&&!n.hasAttribute("ignore")&&te(o,(()=>be(n,t))):R(n)?We(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")&&at.rawSetAttribute.call(n,"src",W(n.getAttribute("src"),t.url)));var i,s}function dt(e,t){const n=function(e){const t=K("div");return t.innerHTML=e,t}(e),o=at.rawElementQuerySelector.call(n,"micro-app-head"),r=at.rawElementQuerySelector.call(n,"micro-app-body");if(!o||!r){const e=`element ${o?"body":"head"} is missing`;return t.onerror(new Error(e)),C(e,t.name)}const i=t.isPrefetch||t.fiber?[]:null;ht(n,t,o,i);const s=ne(i);t.source.links.size?ut(n,t,o,s):s?s.then((()=>t.onLoad(n))):t.onLoad(n),t.source.scripts.size?ke(n,t):t.onLoad(n)}function mt(e){return d(e.__MICRO_APP_IS_BOUND_FUNCTION__)?e.__MICRO_APP_IS_BOUND_FUNCTION__:e.__MICRO_APP_IS_BOUND_FUNCTION__=f(t=e)&&0===t.name.indexOf("bound ")&&!t.hasOwnProperty("prototype");var t}function ft(e,t,n="WINDOW"){if(f(e)&&!function(e){return d(e.__MICRO_APP_IS_CONSTRUCTOR__)?e.__MICRO_APP_IS_CONSTRUCTOR__:e.__MICRO_APP_IS_CONSTRUCTOR__=y(e)}(e)&&!mt(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")&&a(r,"prototype",{value:e.prototype,configurable:!0,enumerable:!1,writable:!0}),e[o]=r}return e}const _t=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||(C("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)&&N(this.process)}isEqual(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&e[n]!==t[n])return!1;return!0}on(e,t,n=!1){if(this.isLegalName(e)){if(!f(t))return C("event-center: Invalid callback function");let o=this.eventList.get(e);o?n&&Object.keys(o.data).length&&(!this.queue.includes(e)||this.isEqual(o.data,o.tempData))&&t(o.data):(o={data:{},callbacks:new Set},this.eventList.set(e,o)),o.callbacks.add(t)}}off(e,t){if(this.isLegalName(e)){const n=this.eventList.get(e);n&&(f(t)?n.callbacks.delete(t):n.callbacks.clear())}}clearData(e){if(this.isLegalName(e)){const t=this.eventList.get(e);t&&(t.data={})}}dispatch(e,t,n,o,r){if(this.isLegalName(e)){if(!_(t))return C("event-center: data must be object");let i=this.eventList.get(e);i?(i.tempData=s({},i.tempData||i.data,t),!i.force&&(i.force=!!o)):(i={data:t,callbacks:new Set},this.eventList.set(e,i),i.force=!0),this.enqueue(e,n,r)}}getData(e){var t;const n=this.eventList.get(e);return null!==(t=null==n?void 0:n.data)&&void 0!==t?t:null}};function At(e,t){return h(e)&&e?t?`__from_base_app_${e}__`:`__from_micro_app_${e}__`:""}class wt{addGlobalDataListener(e,t){const n=this.appName;n&&(e.__APP_NAME__=n,e.__AUTO_TRIGGER__=t),_t.on("global",e,t)}removeGlobalDataListener(e){f(e)&&_t.off("global",e)}setGlobalData(e,t,n){j(),_t.dispatch("global",e,(e=>f(t)&&t(e)),n)}forceSetGlobalData(e,t){this.setGlobalData(e,t,!0)}getGlobalData(){return _t.getData("global")}clearGlobalData(){_t.clearData("global")}clearGlobalDataListener(){const e=this.appName,t=_t.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 yt extends wt{addDataListener(e,t,n){_t.on(At(x(e),!1),t,n)}removeDataListener(e,t){f(t)&&_t.off(At(x(e),!1),t)}getData(e,t=!1){return _t.getData(At(x(e),t))}setData(e,t,n,o){_t.dispatch(At(x(e),!0),t,(e=>f(n)&&n(e)),o)}forceSetData(e,t,n){this.setData(e,t,n,!0)}clearData(e,t=!0){_t.clearData(At(x(e),t))}clearDataListener(e){_t.off(At(x(e),!1))}}class gt extends wt{constructor(e){super(),this.appName=x(e),!this.appName&&C(`Invalid appName ${e}`)}addDataListener(e,t){e.__AUTO_TRIGGER__=t,_t.on(At(this.appName,!0),e,t)}removeDataListener(e){f(e)&&_t.off(At(this.appName,!0),e)}getData(e=!0){return _t.getData(At(this.appName,e))}dispatch(e,t,n){j(),_t.dispatch(At(this.appName,!1),e,(e=>f(t)&&t(e)),n,(()=>{const t=Ln.get(this.appName);if((null==t?void 0:t.container)&&_(e)){const e=new CustomEvent("datachange",{detail:{data:_t.getData(At(this.appName,!1))}});z(t.container).dispatchEvent(e)}}))}forceDispatch(e,t){this.dispatch(e,t,!0)}clearData(e=!1){_t.clearData(At(this.appName,e))}clearDataListener(){_t.off(At(this.appName,!0))}}function bt(e){var t,n;if(e){e.umdDataListeners={global:new Set(null===(t=e.umdDataListeners)||void 0===t?void 0:t.global),normal:new Set(null===(n=e.umdDataListeners)||void 0===n?void 0:n.normal)};const o=_t.eventList.get("global");if(o)for(const t of o.callbacks)e.appName===t.__APP_NAME__&&e.umdDataListeners.global.add(t);const r=_t.eventList.get(At(e.appName,!0));if(r)for(const t of r.callbacks)e.umdDataListeners.normal.add(t)}}function vt(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__);Et(e)}}function Et(e){null==e||delete e.umdDataListeners}class Pt{constructor(){this.appInstanceMap=Ln}static getInstance(){return this.instance||(this.instance=new Pt),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 Rt(){St(),Pt.getInstance().getAll().forEach((e=>{e.container&&z(e.container).disconnectedCallback()})),!window.__MICRO_APP_UMD_MODE__&&Pt.getInstance().clear()}function St(){window.__MICRO_APP_ENVIRONMENT__&&window.removeEventListener("unmount",Rt,!1)}function Ct(e,t){const{rawDocument:n,rawRootDocument:o}=at;class r{static[Symbol.hasInstance](e){let n=e;for(;n=Object.getPrototypeOf(n);)if(n===r.prototype)return!0;return e===t||e instanceof o}}return Object.setPrototypeOf(r,o),Object.setPrototypeOf(r.prototype,new Proxy(o.prototype,{get:(t,o)=>($(e),ft(Reflect.get(t,o),n,"DOCUMENT")),set:(e,t,n)=>(Reflect.set(e,t,n),!0)})),r}function Mt(e,t){const n=at.rawWindow.history.state,o={microAppState:s({},null==n?void 0:n.microAppState,{[e]:t})};return s({},n,o)}function Nt(e){var t,n;return(null===(n=null===(t=at.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=at.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 h(i)?Wt(i):null}function Bt(e,t){let{pathname:n,search:o,hash:r}=at.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+J(i.hashQuery)}else i.searchQuery?i.searchQuery[e]=s:i.searchQuery={[e]:s},o="?"+J(i.searchQuery);return{fullPath:n+o+r,isAttach2Hash:a}}function kt(e,t){const n={};return""!==e&&"?"!==e&&(n.searchQuery=Y(e.slice(1))),t.includes("?")&&(n.hashQuery=Y(t.slice(t.indexOf("?")+1))),n}function Ht(e){const t=Ln.get(e);return!(!t||t.isPrefetch||t.isHidden())}function $t(e){const t=at.rawWindow,n=t=>{if(Hn({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(Qe("popstate",e),{state:Nt(e)});Un(e)?n.dispatchEvent(o):at.rawWindow.dispatchEvent(o);f(t.onpopstate)&&t.onpopstate(o)}(e,o,r),i&&function(e,t,n,o){const r=new HashChangeEvent(Qe("hashchange",e),{newURL:t.location.href,oldURL:o});Un(e)?n.dispatchEvent(r):at.rawWindow.dispatchEvent(r);f(t.onhashchange)&&t.onhashchange(r)}(e,o,r,s),j()}};return t.addEventListener("popstate",n),()=>{t.removeEventListener("popstate",n)}}function Ft(e,t,n){j(),Ht(e)&&(function(e){const t=new PopStateEvent("popstate",{state:null});e&&(t.onlyForBrowser=!0),at.rawWindow.dispatchEvent(t)}(t),n&&function(e){const t=new HashChangeEvent("hashchange",{newURL:at.rawWindow.location.href,oldURL:e});at.rawWindow.dispatchEvent(t)}(n))}function jt(e,t){const n=at.rawWindow.history;function o(n){return function(...o){var r,i,s;if(h(o[2])||g(o[2])){const a=D(o[2],t.href),c=a.pathname+a.search+a.hash;qt(e,n,Bt(e,a),!0,Mt(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 Kt(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?Nt(e):"pushState"===n?r:"replaceState"===n?i:ft(Reflect.get(t,n),t,"HISTORY"),set:(e,t,n)=>(Reflect.set(e,t,n),!0)})}function Kt(e,t,n,o=null,r=""){if(Ht(e)){("pushState"===t?at.rawPushState:at.rawReplaceState).call(at.rawWindow.history,o,r,n)}}function qt(e,t,n,o,r,i){if(Ht(e)){const s=at.rawWindow.location,a=s.pathname+s.search+s.hash,c=n.isAttach2Hash&&a!==n.fullPath?s.href:null;Kt(e,t,n.fullPath,r,i),a!==n.fullPath&&Ft(e,o,c)}}function Gt(e,t,n){qt(e,"replaceState",t,!0,n)}function Qt(e){const t=at.rawWindow;return function(...n){var o;if((null===(o=t.history.state)||void 0===o?void 0:o.microAppState)&&(!_(n[0])||!n[0].microAppState)&&(h(n[2])||g(n[2]))){const e=t.location.href;D(n[2],e).href===e&&(n[0]=s({},n[0],{microAppState:t.history.state.microAppState}))}e.apply(t.history,n),Hn({excludeHiddenApp:!0,excludePreRender:!0}).forEach((e=>{const t=Ln.get(e);t.sandBox&&t.useMemoryRouter&&!Tt(e)&&Gt(e,Bt(e,t.sandBox.proxyWindow.location),Mt(e,Nt(e)))})),j()}}function zt(){const e=at.rawWindow;e.history.pushState=Qt(at.rawPushState),e.history.replaceState=Qt(at.rawReplaceState)}function Vt(){const e=at.rawWindow;e.history.pushState=at.rawPushState,e.history.replaceState=at.rawReplaceState}const{router:Xt,executeNavigationGuard:Yt,clearRouterWhenUnmount:Jt}=function(){function e(e,t,n,o){qt(e,t,Bt(e,n),!1,Mt(e,null!=o?o:null)),j()}function t(t){return function(n){const o=x(n.name);if(o&&h(n.path)){const r=Ln.get(o);if(r&&(!r.sandBox||!r.useMemoryRouter))return C(`navigation failed, memory router of app ${o} is closed`);if(Hn({excludePreRender:!0}).includes(o)){const i=r.sandBox.proxyWindow.location,s=D(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=at.rawWindow.location,r=D(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 C("navigation failed, name & path are required when use router."+(t?"replace":"push"))}}function n(e){return function(...t){return at.rawWindow.history[e](...t)}}const o=Z(),i=Z();function s(e,t,n,o){j();for(const r of o)f(r)?r(t,n,e):_(r)&&f(r[e])&&r[e](t,n)}function a(e){const t=Ln.get(e);t.sandBox&&t.useMemoryRouter&&Gt(e,Bt(e,t.sandBox.proxyWindow.location),Mt(e,Nt(e)))}const c=Object.assign(Object.assign({current:new Map,encode:Lt,decode:Wt,push:t(!1),replace:t(!0),go:n("go"),back:n("back"),forward:n("forward"),beforeEach:o.add,afterEach:i.add,attachToURL:function(e){(e=x(e))&&Hn().includes(e)&&a(e)},attachAllToURL:function({includeHiddenApp:e=!1,includePreRender:t=!1}){Hn({excludeHiddenApp:!e,excludePreRender:!t}).forEach((e=>a(e)))}},function(){const e=function(){const e=new Map;return{add:function(t,n){return e.set(t,n),()=>!!e.has(t)&&e.delete(t)},get:t=>e.get(t),delete:t=>!!e.has(t)&&e.delete(t)}}();return{setDefaultPage:function(t){const n=x(t.name);return n&&t.path?e.add(n,t.path):r},removeDefaultPage:function(t){return!!(t=x(t))&&e.delete(t)},getDefaultPage:e.get}}()),function(){let e=null;return{setBaseAppRouter:function(t){A(t)&&(e=new Proxy(t,{get:(e,t)=>(j(),ft(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,o.list()),T((()=>{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,i){const s=at.rawWindow.location,c=!!n,l=D(t);function u(){return c?n.location:l}function p(t,n){const o=D(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=s.href),Kt(e,n,t.fullPath)),void(o.hash?Ft(e,!1,r):_())}return t.isAttach2Hash?(Kt(e,n,t.fullPath),void _()):t.fullPath}return t}function h(n,o){const r=D(n,t);r[o]===A[o]&&A.hash?Ft(e,!1):(Kt(e,r[o]===A[o]?"replaceState":"pushState",Bt(e,r).fullPath),_())}const d=t=>function(n){if(Ht(e)){const e=p(n,"assign"===t?"pushState":"replaceState");e&&s[t](D(e,s.origin).href)}},m=d("assign"),f=d("replace"),_=e=>s.reload(e);a(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,i)}return"assign"===t?m:"replace"===t?f:"reload"===t?_:"self"===t?n:ft(Reflect.get(n,t),n,"LOCATION")},set:(n,o,r)=>{if(Ht(e)){const n=u();if("href"===o){const e=p(r,"pushState");e&&(s.href=D(e,s.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=D(n,t);o.hash!==A.hash&&qt(e,"pushState",Bt(e,o),!1)}else Reflect.set(n,o,r)}return!0}});return A}function _n(e,t){const n=s({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=D(t,n.href);if(Un(e)){const t=Ln.get(e).sandBox.microAppWindow;null===(r=t.rawReplaceState)||void 0===r||r.call(t.history,Nt(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"):yn(e,t,n)}function yn(e,t,n){n&&An(e,n,t,"prevent"),Gt(e,Bt(e,t),Mt(e,null)),function(e,t){Yt(e,_n(e,t),_n(e,t))}(e,t)}function gn(e,t,n,o){if(!o){const{pathname:o,search:r,hash:i}=D(t);An(e,o+r+i,n,"prevent")}bn(e),Jt(e)}function bn(e){Gt(e,function(e,t){var n,o,r,i;let{pathname:s,search:a,hash:c}=t||at.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=J(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=J(l.searchQuery);a=t?"?"+t:""}return{fullPath:s+a+c,isAttach2Hash:u}}(e),function(e,t){return _(null==t?void 0:t.microAppState)&&(u(t.microAppState[e])||delete t.microAppState[e],Object.keys(t.microAppState).length||delete t.microAppState),s({},t)}(e,at.rawWindow.history.state))}function vn(e,t){const n=u(t)?at.rawWindow.fetch:t;return f(n)?function(t,o,...r){return(h(t)||g(t))&&(t=D(t,e).toString()),j(),n.call(at.rawWindow,t,o,...r)}:n}function En(e,t){const n=u(t)?at.rawWindow.XMLHttpRequest:t;return y(n)?class extends n{open(t,n,...o){(h(n)&&!/^f(ile|tp):\/\//.test(n)||g(n))&&(n=D(n,e).toString()),j(),super.open(t,n,...o)}}:n}const{createMicroEventSource:Pn,clearMicroEventSource:Rn}=function(){let e;return{createMicroEventSource:function(t,n,o){const r=u(o)?at.rawWindow.EventSource:o;return y(r)?class extends r{constructor(o,r,...i){if((h(o)||g(o))&&(o=D(o,n).toString()),j(),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 Cn{constructor(e,t){this.active=!1,this.scopeProperties=[],this.escapeProperties=[],this.escapeKeys=new Set,this.injectedKeys=new Set,this.microAppWindow={},this.adapter=new je,this.getSpecialProperties(e),this.windowEffect=this.patchWithWindow(e,this.microAppWindow),this.documentEffect=this.patchWithDocument(e,this.microAppWindow),this.initStaticGlobalKeys(e,t,this.microAppWindow)}start({umdMode:e,baseroute:t,useMemoryRouter:n,defaultPage:o,disablePatchRequest:r}){this.active||(this.active=!0,n?(u(this.microAppWindow.location)&&this.setMicroAppRouter(this.microAppWindow.__MICRO_APP_NAME__,this.microAppWindow.__MICRO_APP_URL__,this.microAppWindow),this.initRouteState(o),this.removeHistoryListener=$t(this.microAppWindow.__MICRO_APP_NAME__)):this.microAppWindow.__MICRO_APP_BASE_ROUTE__=this.microAppWindow.__MICRO_APP_BASE_URL__=t,e||this.initGlobalKeysWhenStart(this.microAppWindow.__MICRO_APP_NAME__,this.microAppWindow.__MICRO_APP_URL__,this.microAppWindow,r),1==++at.activeSandbox&&(ot(),zt()),1==++Cn.activeCount&&window.__MICRO_APP_ENVIRONMENT__&&(St(),window.addEventListener("unmount",Rt,!1)),at.rawWindow._babelPolyfill&&(at.rawWindow._babelPolyfill=!1))}stop({umdMode:e,keepRouteState:t,destroy:n,clearData:o}){this.active&&(this.recordAndReleaseEffect({umdMode:e,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(at.rawWindow,e)})),this.escapeKeys.clear()),0==--at.activeSandbox&&(it(),Vt()),--Cn.activeCount,this.active=!1)}initStaticGlobalKeys(e,t,n){n.__MICRO_APP_ENVIRONMENT__=!0,n.__MICRO_APP_NAME__=e,n.__MICRO_APP_URL__=t,n.__MICRO_APP_PUBLIC_PATH__=L(t),n.__MICRO_APP_BASE_ROUTE__="",n.__MICRO_APP_WINDOW__=n,n.__MICRO_APP_PRE_RENDER__=!1,n.__MICRO_APP_UMD_MODE__=!1,n.rawWindow=at.rawWindow,n.rawDocument=at.rawDocument,n.microApp=s(new gt(e),{removeDomScope:j,pureCreateElement:K,router:Xt}),this.setMappingPropertiesWithRawDescriptor(n)}recordAndReleaseEffect(e,t=!1){t?this.resetEffectSnapshot():this.recordEffectSnapshot(),this.releaseGlobalEffect(e)}resetEffectSnapshot(){this.windowEffect.reset(),this.documentEffect.reset(),Et(this.microAppWindow.microApp)}recordEffectSnapshot(){this.windowEffect.record(),this.documentEffect.record(),bt(this.microAppWindow.microApp)}rebuildEffectSnapshot(){this.windowEffect.rebuild(),this.documentEffect.rebuild(),vt(this.microAppWindow.microApp)}releaseGlobalEffect({umdMode:e=!1,clearData:t=!1,isPrerender:n=!1,keepAlive:o=!1,destroy:r=!1}){var i,s,a;this.windowEffect.release(!e&&!o&&!n||r),this.documentEffect.release(),null===(i=this.microAppWindow.microApp)||void 0===i||i.clearDataListener(),null===(s=this.microAppWindow.microApp)||void 0===s||s.clearGlobalDataListener(),t&&(Qn.clearData(this.microAppWindow.__MICRO_APP_NAME__),null===(a=this.microAppWindow.microApp)||void 0===a||a.clearData())}getSpecialProperties(e){var t;this.scopeProperties=this.scopeProperties.concat(this.adapter.staticScopeProperties),_(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(i(e))for(const t of e)_(t)&&(i(t.scopeProperties)&&(this.scopeProperties=this.scopeProperties.concat(t.scopeProperties)),i(t.escapeProperties)&&(this.escapeProperties=this.escapeProperties.concat(t.escapeProperties)))}createProxyWindow(e,t){const n=at.rawWindow,o=new Map;return new Proxy(t,{get:(t,o)=>($(e),Reflect.has(t,o)||h(o)&&/^__MICRO_APP_/.test(o)||this.scopeProperties.includes(o)?Reflect.get(t,o):ft(Reflect.get(n,o),n)),set:(e,t,o)=>{if(this.adapter.escapeSetterKeyList.includes(t))Reflect.set(n,t,o);else if(l.call(e,t)||!l.call(n,t)||this.scopeProperties.includes(t))!Reflect.has(e,t)&&this.injectedKeys.add(t),Reflect.set(e,t,o);else{const r=Object.getOwnPropertyDescriptor(n,t),{configurable:i,enumerable:s,writable:c,set:l}=r;a(e,t,{value:o,configurable:i,enumerable:s,writable:null!=c?c:!!l}),this.injectedKeys.add(t)}return(this.escapeProperties.includes(t)||this.adapter.staticEscapeProperties.includes(t)&&!Reflect.has(n,t))&&!this.scopeProperties.includes(t)&&(!Reflect.has(n,t)&&this.escapeKeys.add(t),Reflect.set(n,t,o)),!0},has:(e,t)=>this.scopeProperties.includes(t)?t in e:t in e||t in n,getOwnPropertyDescriptor:(e,t)=>{if(l.call(e,t))return o.set(t,"target"),Object.getOwnPropertyDescriptor(e,t);if(l.call(n,t)){o.set(t,"rawWindow");const e=Object.getOwnPropertyDescriptor(n,t);return e&&!e.configurable&&(e.configurable=!0),e}},defineProperty:(e,t,r)=>"rawWindow"===o.get(t)?Reflect.defineProperty(n,t,r):Reflect.defineProperty(e,t,r),ownKeys:e=>Reflect.ownKeys(n).concat(Reflect.ownKeys(e)).filter((function(e){return!(e in this)&&(this[e]=!0)}),Object.create(null)),deleteProperty:(e,t)=>!l.call(e,t)||(this.injectedKeys.has(t)&&this.injectedKeys.delete(t),this.escapeKeys.has(t)&&Reflect.deleteProperty(n,t),Reflect.deleteProperty(e,t))})}patchWithWindow(e,t){return this.proxyWindow=this.createProxyWindow(e,t),function(e,t){const n=new Map,o=new Map,r=new Map,i=new Map,{rawWindow:s,rawAddEventListener:a,rawRemoveEventListener:c,rawSetInterval:l,rawSetTimeout:u,rawClearInterval:p,rawClearTimeout:h}=at;t.addEventListener=function(t,o,r){t=Qe(t,e);const i=n.get(t);i?i.add(o):n.set(t,new Set([o])),o&&(o.__MICRO_APP_MARK_OPTIONS__=r),a.call(s,t,o,r)},t.removeEventListener=function(t,o,r){t=Qe(t,e);const i=n.get(t);(null==i?void 0:i.size)&&i.has(o)&&i.delete(o),c.call(s,t,o,r)},t.setInterval=function(e,t,...n){const o=l.call(s,e,t,...n);return r.set(o,{handler:e,timeout:t,args:n}),o},t.setTimeout=function(e,t,...n){const o=u.call(s,e,t,...n);return i.set(o,{handler:e,timeout:t,args:n}),o},t.clearInterval=function(e){r.delete(e),p.call(s,e)},t.clearTimeout=function(e){i.delete(e),h.call(s,e)};const d=()=>{o.clear()};return{reset:d,record:()=>{n.forEach(((e,t)=>{if(e.size){const n=o.get(t)||[];o.set(t,new Set([...n,...e]))}}))},rebuild:()=>{o.forEach(((e,n)=>{for(const o of e)t.addEventListener(n,o,null==o?void 0:o.__MICRO_APP_MARK_OPTIONS__)})),d()},release:e=>{n.size&&(n.forEach(((e,t)=>{for(const n of e)c.call(s,t,n)})),n.clear()),e&&(r.forEach(((e,t)=>{p.call(s,t)})),i.forEach(((e,t)=>{h.call(s,t)})),r.clear(),i.clear())}}}(e,t)}patchWithDocument(e,t){const{proxyDocument:n,MicroDocument:o,documentEffect:r}=function(e,t){const n=new Map,o=new Map;let r=null,i=null;const{rawDocument:s,rawCreateElement:a,rawAddEventListener:c,rawRemoveEventListener:l}=at;function u(t,n){const o=a.call(s,t,n);return o.__MICRO_APP_NAME__=e,o}function p(e,t,o){const r=n.get(e);r?r.add(t):n.set(e,new Set([t])),t&&(t.__MICRO_APP_MARK_OPTIONS__=o),c.call(s,e,t,o)}function h(e,t,o){const r=n.get(e);(null==r?void 0:r.size)&&r.has(t)&&r.delete(t),l.call(s,e,t,o)}const d=()=>{o.clear(),i=null},m=new Proxy(s,{get:(n,o)=>($(e),Ke(m),"createElement"===o?u:o===Symbol.toStringTag?"ProxyDocument":"defaultView"===o?t.proxyWindow:"onclick"===o?r:"addEventListener"===o?p:"removeEventListener"===o?h:ft(Reflect.get(n,o),s,"DOCUMENT")),set:(e,t,n)=>("onclick"===t?(f(r)&&l.call(s,"click",r,!1),f(n)&&c.call(s,"click",n,!1),r=n):Reflect.set(e,t,n),!0)});return{proxyDocument:m,MicroDocument:Ct(e,m),documentEffect:{reset:d,record:()=>{i=r||i,n.forEach(((e,t)=>{if(e.size){const n=o.get(t)||[];o.set(t,new Set([...n,...e]))}}))},rebuild:()=>{i&&!r&&(m.onclick=i),o.forEach(((e,t)=>{for(const n of e)m.addEventListener(t,n,null==n?void 0:n.__MICRO_APP_MARK_OPTIONS__)})),d()},release:()=>{f(r)&&l.call(s,"click",r),r=null,n.size&&(n.forEach(((e,t)=>{for(const n of e)l.call(s,t,n)})),n.clear())}}}}(e,this);return c(t,{document:{configurable:!1,enumerable:!0,get:()=>n},Document:{configurable:!1,enumerable:!1,get:()=>o}}),r}setPreRenderState(e){this.microAppWindow.__MICRO_APP_PRE_RENDER__=e}markUmdMode(e){this.microAppWindow.__MICRO_APP_UMD_MODE__=e}setMappingPropertiesWithRawDescriptor(e){let t,n;const o=at.rawWindow;o===o.parent?t=n=this.proxyWindow:(t=o.top,n=o.parent),a(e,"top",this.createDescriptorForMicroAppWindow("top",t)),a(e,"parent",this.createDescriptorForMicroAppWindow("parent",n)),Sn.forEach((t=>{a(e,t,this.createDescriptorForMicroAppWindow(t,this.proxyWindow))}))}createDescriptorForMicroAppWindow(e,t){const{configurable:n=!0,enumerable:o=!0,writable:r,set:i}=Object.getOwnPropertyDescriptor(at.rawWindow,e)||{writable:!0};return{value:t,configurable:n,enumerable:o,writable:null!=r?r:!!i}}initGlobalKeysWhenStart(e,t,n,o){n.hasOwnProperty=e=>l.call(n,e)||l.call(at.rawWindow,e),this.setHijackProperty(e,n),o||this.patchRequestApi(e,t,n),this.setScopeProperties(n)}setHijackProperty(e,t){let n,o;c(t,{eval:{configurable:!0,enumerable:!1,get:()=>($(e),n||eval),set:e=>{n=e}},Image:{configurable:!0,enumerable:!1,get:()=>($(e),o||at.ImageProxy),set:e=>{o=e}}})}patchRequestApi(e,t,n){let o=vn(t),r=En(t),i=Pn(e,t);c(n,{fetch:{configurable:!0,enumerable:!0,get:()=>o,set(e){o=vn(t,e)}},XMLHttpRequest:{configurable:!0,enumerable:!0,get:()=>r,set(e){r=En(t,e)}},EventSource:{configurable:!0,enumerable:!0,get:()=>i,set(n){i=Pn(e,t,n)}}})}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:jt(e,n)}}(e,t);c(n,{location:{configurable:!1,enumerable:!0,get:()=>o,set:e=>{at.rawWindow.location=e}},history:{configurable:!0,enumerable:!0,get:()=>r}})}initRouteState(e){wn(this.microAppWindow.__MICRO_APP_NAME__,this.microAppWindow.location,e)}clearRouteState(e){gn(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){ze(e,this.microAppWindow.__MICRO_APP_NAME__)}actionBeforeExecScripts(e){this.patchStaticElement(e)}}function Mn(e,t){const n=at.rawWindow;return Zt.forEach((e=>{t[e]=ft(n[e],n)})),Object.getOwnPropertyNames(t).filter((e=>(en.some((o=>{if(o.test(e)&&e in t.parent){if(f(n[e]))t[e]=ft(n[e],n);else{const{configurable:o,enumerable:r}=Object.getOwnPropertyDescriptor(t,e)||{configurable:!0,enumerable:!0};o&&a(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:i,set:s}=Object.getOwnPropertyDescriptor(t,o)||{enumerable:!0,writable:!0};try{a(t,o,{enumerable:r,configurable:!0,get:()=>n[o],set:(null!=i?i:s)?e=>{n[o]=f(e)?e.bind(t):e}:void 0})}catch(t){M(t,e)}})),function(e){const{rawWindow:t,rawAddEventListener:n,rawRemoveEventListener:o}=at,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)=>{if(e.size){const n=i.get(t)||[];i.set(t,new Set([...n,...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 Nn(e,t,n){return function(e,t){const n=at.rawDocument,o=t.Document,r=t.document,i=o.prototype.createElement,s=o.prototype.createTextNode,a=o.prototype.querySelector,c=o.prototype.querySelectorAll,l=o.prototype.getElementById,u=o.prototype.getElementsByClassName,p=o.prototype.getElementsByTagName,h=o.prototype.getElementsByName;function d(e){return r!==e?e:n}function m(t){var n,o;if(!t||Q(t)||r!==this){const e=d(this);return a.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 f(t){var n,o;if(!t||Q(t)||r!==this){const e=d(this);return c.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 Ve(i.call(this,t,n),e)},o.prototype.createTextNode=function(t){return Ve(s.call(this,t),e)},o.prototype.querySelector=m,o.prototype.querySelectorAll=f,o.prototype.getElementById=function(e){const t=d(this);if(G(e))return l.call(t,e);try{return m.call(this,`#${e}`)}catch(n){return l.call(t,e)}},o.prototype.getElementsByClassName=function(e){const t=d(this);if(G(e))return u.call(t,e);try{return f.call(this,`.${e}`)}catch(n){return u.call(t,e)}},o.prototype.getElementsByTagName=function(t){var n;const o=d(this);if(Q(t)||G(t)||!(null===(n=Ln.get(e))||void 0===n?void 0:n.inline)&&/^script$/i.test(t))return p.call(o,t);try{return f.call(this,t)}catch(e){return p.call(o,t)}},o.prototype.getElementsByName=function(e){const t=d(this);if(G(e))return h.call(t,e);try{return f.call(this,`[name=${e}]`)}catch(n){return h.call(t,e)}}}(e,t),function(e,t,n){const o=at.rawDocument,r=t.Document,i=t.document,s=(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(i,"form")],["images",()=>r.prototype.querySelectorAll.call(i,"img")],["links",()=>r.prototype.querySelectorAll.call(i,"a")]].forEach((t=>{e[t[0]]=s(t[0],t[1])})),cn.forEach((t=>{e[t]=s(t,(()=>o[t]))})),ln.forEach((t=>{e[t]=s(t,(()=>ft(o[t],o,"DOCUMENT")))})),un.forEach((t=>{e[t]=s(t,(()=>o[t]))})),pn.forEach((t=>{e[t]=s(t,(()=>ft(o[t],o,"DOCUMENT")))})),e};c(r.prototype,l()),sn.forEach((e=>{a(i,e,{enumerable:!0,configurable:!0,get:()=>o[e],set:t=>{o[e]=t}})}))}(0,t,n),function(e,t){const{rawDocument:n,rawAddEventListener:o,rawRemoveEventListener:r}=at,i=new Map,s=new Map;let c=null,l=null;const u=t.Document,p=t.document;function h(e,t){return on.includes(e)?t:n}function d(e){return"onclick"===e?e=>{f(c)&&r.call(n,"click",c,!1),f(e)?(c=e.bind(p),o.call(n,"click",c,!1)):c=e}:t=>{n[e]=f(t)?t.bind(p):t}}u.prototype.addEventListener=function(e,t,n){const r=f(t)?t.__MICRO_APP_BOUND_FUNCTION__=t.__MICRO_APP_BOUND_FUNCTION__||t.bind(this):t,s=i.get(e);s?s.add(t):i.set(e,new Set([t])),t&&(t.__MICRO_APP_MARK_OPTIONS__=n),o.call(h(e,this),e,r,n)},u.prototype.removeEventListener=function(e,t,n){const o=i.get(e);(null==o?void 0:o.size)&&o.has(t)&&o.delete(t);const s=(null==t?void 0:t.__MICRO_APP_BOUND_FUNCTION__)||t;r.call(h(e,this),e,s,n)},Object.getOwnPropertyNames(u.prototype).filter((e=>/^on/.test(e)&&!rn.includes(e))).forEach((t=>{const{enumerable:o,writable:r,set:i}=Object.getOwnPropertyDescriptor(u.prototype,t)||{enumerable:!0,writable:!0};try{a(u.prototype,t,{enumerable:o,configurable:!0,get:()=>"onclick"===t?c:n[t],set:(null!=r?r:i)?d(t):void 0})}catch(t){M(t,e)}}));const m=()=>{s.clear(),l=null},_=()=>{l&&!c&&(p.onclick=l),s.forEach(((e,t)=>{for(const n of e)p.addEventListener(t,n,null==n?void 0:n.__MICRO_APP_MARK_OPTIONS__)})),m()};return{reset:m,record:()=>{l=c||l,i.forEach(((e,t)=>{if(e.size){const n=s.get(t)||[];s.set(t,new Set([...n,...e]))}}))},rebuild:_,release:()=>{f(c)&&r.call(n,"click",c),c=null,i.size&&(i.forEach(((e,t)=>{for(const n of e)r.call(h(t,p),t,(null==n?void 0:n.__MICRO_APP_BOUND_FUNCTION__)||n)})),i.clear())}}}(e,t)}function Dn(e,t,n,o){!function(e,t,n){const o=at.rawRootElement,r=at.rawDocument,i=t.document,s=t.Node,c=t.Element,l=s.prototype.appendChild,u=s.prototype.insertBefore,p=s.prototype.replaceChild,h=s.prototype.removeChild,d=c.prototype.append,m=c.prototype.prepend,f=c.prototype.insertAdjacentElement,_=s.prototype.cloneNode,A=Object.getOwnPropertyDescriptor(c.prototype,"innerHTML"),w=Object.getOwnPropertyDescriptor(s.prototype,"parentNode"),y=e=>(R(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__,g=e=>e===n.microHead?r.head:e===n.microBody?r.body:e;s.prototype.getRootNode=function(){return i},s.prototype.appendChild=function(t){return Ve(t,e),y(t)?l.call(this,t):o.prototype.appendChild.call(g(this),t)},s.prototype.insertBefore=function(t,n){return Ve(t,e),y(t)?u.call(this,t,n):o.prototype.insertBefore.call(g(this),t,n)},s.prototype.replaceChild=function(t,n){return Ve(t,e),y(t)?p.call(this,t,n):o.prototype.replaceChild.call(g(this),t,n)},s.prototype.removeChild=function(e){return y(e)||this.contains(e)?h.call(this,e):o.prototype.removeChild.call(g(this),e)},c.prototype.append=function(...e){let t=0,n=!1;for(;t<e.length;)e[t]=v(e[t])?e[t]:i.createTextNode(e[t]),y(e[t])&&(n=!0),t++;return n?d.call(this,...e):o.prototype.append.call(g(this),...e)},c.prototype.prepend=function(...e){let t=0,n=!1;for(;t<e.length;)e[t]=v(e[t])?e[t]:i.createTextNode(e[t]),y(e[t])&&(n=!0),t++;return n?m.call(this,...e):o.prototype.prepend.call(g(this),...e)},c.prototype.insertAdjacentElement=function(t,n){return Ve(n,e),y(n)?f.call(this,t,n):o.prototype.insertAdjacentElement.call(g(this),t,n)},s.prototype.cloneNode=function(t){return Ve(_.call(this,t),e)},a(c.prototype,"innerHTML",{configurable:!0,enumerable:!0,get(){return A.get.call(this)},set(t){A.set.call(this,t),Array.from(this.children).forEach((t=>{b(t)&&Ve(t,e)}))}}),a(s.prototype,"parentNode",{configurable:!0,enumerable:!0,get(){var t,n,o;Ke(i);const s=w.get.call(this);return S(s)&&(null===(t=Ln.get(e))||void 0===t?void 0:t.container)?(null===(o=(n=Qn.options).getRootElementParentNode)||void 0===o?void 0:o.call(n,this,e))||r.body:s}});const E=new Proxy(t.Image,{construct(t,n){const o=new t(...n);return Ve(o,e),o}});a(t,"Image",{configurable:!0,writable:!0,value:E})}(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=W(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:i,set:s}=Object.getOwnPropertyDescriptor(e,n)||{enumerable:!0,configurable:!0};a(e,n,{enumerable:o,configurable:r,get:function(){return null==i?void 0:i.call(this)},set:function(e){null==s||s.call(this,W(e,t))}})}))}(0,t,n)}Cn.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=at.rawWindow.location,o=n.protocol+"//"+n.host;this.deleteIframeElement=this.createIframeElement(e,o),this.microAppWindow=this.iframe.contentWindow,this.patchIframe(this.microAppWindow,(n=>{this.createIframeTemplate(this.microAppWindow),this.getSpecialProperties(e),this.proxyLocation=function(e,t,n,o){const r=new URL(t),i=r.protocol+"//"+r.host,a=r.pathname+r.search+r.hash,c=n.history;return n.rawReplaceState=c.replaceState,s(c,jt(e,n.location)),An(e,a,n.location,"prevent"),fn(e,t,n,r,o,i)}(e,t,this.microAppWindow,o),this.proxyWindow=this.createProxyWindow(this.microAppWindow),this.initStaticGlobalKeys(e,t),this.windowEffect=Mn(e,this.microAppWindow),this.documentEffect=Nn(e,this.microAppWindow,this.proxyLocation),Dn(e,t,this.microAppWindow,this),n()}))}createIframeElement(e,t){this.iframe=K("iframe");const n={src:t,style:"display: none",id:e};return Object.keys(n).forEach((e=>this.iframe.setAttribute(e,n[e]))),at.rawDocument.body.appendChild(this.iframe),()=>N((()=>{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=$t(this.microAppWindow.__MICRO_APP_NAME__)):this.microAppWindow.__MICRO_APP_BASE_ROUTE__=this.microAppWindow.__MICRO_APP_BASE_URL__=e,o||this.createIframeBase(),1==++at.activeSandbox&&(ot(),zt()),++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(at.rawWindow,e)})),this.escapeKeys.clear()),0==--at.activeSandbox&&(it(),Vt()),--On.activeCount,this.active=!1)}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__=L(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=at.rawWindow,this.microAppWindow.rawDocument=at.rawDocument,this.microAppWindow.microApp=s(new gt(e),{removeDomScope:j,pureCreateElement:K,location:this.proxyLocation,router:Xt})}recordAndReleaseEffect(e,t=!1){t?this.resetEffectSnapshot():this.recordEffectSnapshot(),this.releaseGlobalEffect(e)}resetEffectSnapshot(){var e,t;null===(e=this.windowEffect)||void 0===e||e.reset(),null===(t=this.documentEffect)||void 0===t||t.reset(),Et(this.microAppWindow.microApp)}recordEffectSnapshot(){var e,t;null===(e=this.windowEffect)||void 0===e||e.record(),null===(t=this.documentEffect)||void 0===t||t.record(),bt(this.microAppWindow.microApp)}rebuildEffectSnapshot(){var e,t;null===(e=this.windowEffect)||void 0===e||e.rebuild(),null===(t=this.documentEffect)||void 0===t||t.rebuild(),vt(this.microAppWindow.microApp)}releaseGlobalEffect({clearData:e=!1}){var t,n,o,r,i;null===(t=this.windowEffect)||void 0===t||t.release(),null===(n=this.documentEffect)||void 0===n||n.release(),null===(o=this.microAppWindow.microApp)||void 0===o||o.clearDataListener(),null===(r=this.microAppWindow.microApp)||void 0===r||r.clearGlobalDataListener(),e&&(Qn.clearData(this.microAppWindow.__MICRO_APP_NAME__),null===(i=this.microAppWindow.microApp)||void 0===i||i.clearData())}setPreRenderState(e){this.microAppWindow.__MICRO_APP_PRE_RENDER__=e}markUmdMode(e){this.microAppWindow.__MICRO_APP_UMD_MODE__=e}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=K("base"),this.updateIframeBase(),this.microHead.appendChild(this.baseElement)}createProxyWindow(e){const t=at.rawWindow;return new Proxy(e,{get:(e,t)=>"location"===t?this.proxyLocation:hn.includes(t.toString())?this.proxyWindow:ft(Reflect.get(e,t),e),set:(e,n,o)=>"location"===n?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)),!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;_(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(i(e))for(const t of e)_(t)&&i(t.escapeProperties)&&(this.escapeProperties=this.escapeProperties.concat(t.escapeProperties))}initRouteState(e){wn(this.microAppWindow.__MICRO_APP_NAME__,this.microAppWindow.location,e)}clearRouteState(e){gn(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){ze(e,this.microAppWindow.__MICRO_APP_NAME__)}actionBeforeExecScripts(e){this.patchStaticElement(e)}}function In(e,t,n,o){var r;if(!e)return C(`element does not exist in lifecycle ${n}`,t);e=z(e),j();const i=s({name:t,container:e},o&&{error:o}),a=new CustomEvent(n,{detail:i});!function(e,t){Object.defineProperties(e,{currentTarget:{get:()=>t},target:{get:()=>t}})}(a,e),f(null===(r=Qn.options.lifeCycles)||void 0===r?void 0:r[n])&&Qn.options.lifeCycles[n](a),e.dispatchEvent(a)}function xn(e,t,n={}){const o=new CustomEvent(Qe(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=se.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(se.LOADING),me.getInstance().run(this,dt)}onLoad(e,t,n){var o;if(2==++this.loadSourceLevel)if(this.source.html=e,this.isPrefetch||this.isUnmounted()){if(this.isPrerender){const e=K("div");e.setAttribute("prerender","true"),null===(o=this.sandBox)||void 0===o||o.setPreRenderState(!0),this.mount({container:e,inline:this.inline,useMemoryRouter:!0,baseroute:"",fiber:!0,defaultPage:null!=t?t:"",disablePatchRequest:null!=n&&n})}}else z(this.container).mount(this)}onLoadError(e){this.loadSourceLevel=-1,this.isUnmounted()||(this.onerror(e),this.setAppState(se.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(se.LOADING);this.createSandbox();const a=()=>{var a,c,l,p,d,m,_;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(),q(e,this.container,!1),this.container=e,null===(c=this.preRenderEvents)||void 0===c||c.forEach((e=>e())),this.isPrerender=!1,this.preRenderEvents=null,Xt.attachToURL(this.name),null===(l=this.sandBox)||void 0===l||l.setPreRenderState(!1);else{this.container=e,this.inline=t,this.fiber=s,this.useMemoryRouter=n;const a=()=>In(this.container,this.name,ae.BEFOREMOUNT);if(this.isPrerender?(null!==(p=this.preRenderEvents)&&void 0!==p?p:this.preRenderEvents=[]).push(a):a(),this.setAppState(se.MOUNTING),q(this.container,this.source.html,!this.umdMode),null===(d=this.sandBox)||void 0===d||d.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){C("An error occurred in window.mount \n",this.name,e)}}else null===(m=this.sandBox)||void 0===m||m.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=Se.script.getInfo(s),a=o.appSpace[e.name];a.defer||a.async?(!o.isExternal||o.code||Me(e,o)?r.push(o.code):r.push(de(s,e.name)),i.push([s,o]),Me(e,o)&&(t.moduleCount=t.moduleCount?++t.moduleCount:1)):te(n,(()=>{He(s,e,o),t(!1)}))}r.length?U(r,(e=>{const t=i[e.index][1];t.code=t.code||e.data}),(n=>{t.errorCount=t.errorCount?++t.errorCount:1,C(n,e.name)}),(()=>{i.forEach((([o,r])=>{h(r.code)&&te(n,(()=>{He(o,e,r,t),!Me(e,r)&&t(!1)}))})),n?(n.push((()=>Promise.resolve(t(u(t.moduleCount)||t.errorCount===r.length)))),ne(n)):t(u(t.moduleCount)||t.errorCount===r.length)})):n?(n.push((()=>Promise.resolve(t(!0)))),ne(n)):t(!0)}(this,(e=>{if(!this.umdMode){const{mount:t,unmount:n}=this.getUmdLibraryHooks();if(this.umdHookUnmount=n,f(t)&&f(n)){this.umdHookMount=t,this.sandBox.markUmdMode(this.umdMode=!0);try{this.handleMounted(this.umdHookMount(Qn.getData(this.name,!0)))}catch(e){C("An error occurred in window.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=()=>{w(e)?e.then((()=>this.dispatchMountedEvent())).catch((()=>this.dispatchMountedEvent())):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(){var e;this.isUnmounted()||(this.setAppState(se.MOUNTED),re(this.getMicroAppGlobalHook(ce.ONMOUNT),this.name,ce.ONMOUNT,Qn.getData(this.name,!0)),In(this.container,this.name,ae.MOUNTED),this.isHidden()&&(null===(e=this.sandBox)||void 0===e||e.recordAndReleaseEffect({keepAlive:!0})))}unmount({destroy:e,clearData:t,keepRouteState:n,unmountcb:o}){var r;e=e||this.state===se.LOAD_FAILED,this.setAppState(se.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){C("An error occurred in window.unmount \n",this.name,e)}xn(this,"unmount"),re(this.getMicroAppGlobalHook(ce.ONUNMOUNT),this.name,ce.ONUNMOUNT),this.handleUnmounted({destroy:e,clearData:t,keepRouteState:n,unmountcb:o,umdHookUnmountResult:i})}handleUnmounted({destroy:e,clearData:t,keepRouteState:n,unmountcb:o,umdHookUnmountResult:r}){const i=()=>this.actionsForUnmount({destroy:e,clearData:t,keepRouteState:n,unmountcb:o});w(r)?(j(),r.then(i).catch(i)):i()}actionsForUnmount({destroy:e,clearData:t,keepRouteState:n,unmountcb:o}){var r;this.umdMode&&this.container&&!e&&q(this.source.html,this.container,!1),null===(r=this.sandBox)||void 0===r||r.stop({umdMode:this.umdMode,keepRouteState:n&&!e,destroy:e,clearData:t||e}),In(this.container,this.name,ae.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(),j()}actionsForCompletelyDestroy(){var e,t;null===(t=null===(e=this.sandBox)||void 0===e?void 0:e.deleteIframeElement)||void 0===t||t.call(e),Se.script.deleteInlineInfo(this.source.scripts),Ln.delete(this.name)}hiddenKeepAliveApp(e){var t,n;this.setKeepAliveState(le.KEEP_ALIVE_HIDDEN),xn(this,"appstate-change",{appState:"afterhidden"}),In(this.container,this.name,ae.AFTERHIDDEN),this.useMemoryRouter&&(null===(t=this.sandBox)||void 0===t||t.removeRouteInfoForKeepAliveApp()),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,ae.BEFORESHOW),this.setKeepAliveState(le.KEEP_ALIVE_SHOW),this.container=q(e,this.container,!1),this.useMemoryRouter&&(null===(n=this.sandBox)||void 0===n||n.setRouteInfoForKeepAliveApp()),xn(this,"appstate-change",{appState:"aftershow"}),In(this.container,this.name,ae.AFTERSHOW)}onerror(e){In(this.container,this.name,ae.ERROR,e)}createSandbox(){this.useSandbox&&!this.sandBox&&(this.iframe?this.sandBox=new On(this.name,this.url):this.sandBox=new Cn(this.name,this.url))}setAppState(e){this.state=e}getAppState(){return this.state}setKeepAliveState(e){this.keepAliveState=e}getKeepAliveState(){return this.keepAliveState}isUnmounted(){return se.UNMOUNT===this.state}isHidden(){return le.KEEP_ALIVE_HIDDEN===this.keepAliveState}getUmdLibraryHooks(){if(!this.isUnmounted()&&this.sandBox){const e=z(this.container).getAttribute("library")||`micro-app-${this.name}`,t=this.sandBox.proxyWindow;return A(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 f(o)?o:null}querySelector(e){return this.container?at.rawElementQuerySelector.call(this.container,e):null}querySelectorAll(e){return this.container?at.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 n extends HTMLElement{constructor(){super(...arguments),this.isWaiting=!1,this.cacheData=null,this.connectedCount=0,this.connectStateMap=new Map,this.appName="",this.appUrl="",this.ssrUrl="",this.version=t,this.handleAttributeUpdate=()=>{if(this.isWaiting=!1,!this.connectStateMap.get(this.connectedCount))return;const e=x(this.getAttribute("name")),t=I(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.isUnmounted()&&!n.isHidden()&&!n.isPrefetch)return this.setAttribute("name",this.appName),C(`app name conflict, an app named ${e} is running`);e===this.appName&&t===this.appUrl||(e===this.appName?this.unmount(!0,(()=>{this.actionsForAttributeChange(e,t,n)})):this.getKeepAliveModeResult()?(this.handleHiddenKeepAliveApp(),this.actionsForAttributeChange(e,t,n)):this.unmount(!1,(()=>{this.actionsForAttributeChange(e,t,n)})))}else e!==this.appName&&this.setAttribute("name",this.appName)}}static get observedAttributes(){return["name","url"]}connectedCallback(){const e=++this.connectedCount;this.connectStateMap.set(e,!0);const t=this.appName&&this.appUrl;N((()=>{this.connectStateMap.get(e)&&(In(this,this.appName,ae.CREATED),t&&this.handleConnected())}))}disconnectedCallback(){this.connectStateMap.set(this.connectedCount,!1),this.handleDisconnected()}reload(e){return new Promise((t=>{const n=()=>{this.removeEventListener(ae.MOUNTED,n),this.removeEventListener(ae.AFTERSHOW,n),t(!0)};this.addEventListener(ae.MOUNTED,n),this.addEventListener(ae.AFTERSHOW,n),this.handleDisconnected(e,(()=>{this.handleConnected()}))}))}handleDisconnected(e=!1,t){const n=Ln.get(this.appName);!n||n.isUnmounted()||n.isHidden()||(this.getKeepAliveModeResult()&&!e?this.handleHiddenKeepAliveApp(t):this.unmount(e,t))}attributeChangedCallback(e,t,n){if(this.legalAttribute(e,n)&&this[e===ie.NAME?"appName":"appUrl"]!==n)if(e!==ie.URL||this.appUrl)if(e!==ie.NAME||this.appName)this.isWaiting||(this.isWaiting=!0,N(this.handleAttributeUpdate));else{const e=x(n);if(!e)return C(`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=I(n,this.appName)))return C(`Invalid attribute url ${n}`,this.appName);this.appUrl=n,this.handleInitialNameAndUrl()}}handleInitialNameAndUrl(){this.connectStateMap.get(this.connectedCount)&&this.handleConnected()}handleConnected(){if(this.appName&&this.appUrl)if(this.getDisposeResult("shadowDOM")&&!this.shadowRoot&&f(this.attachShadow)&&this.attachShadow({mode:"open"}),this.updateSsrUrl(this.appUrl),Ln.has(this.appName)){const e=Ln.get(this.appName),t=e.ssrUrl||e.url,n=this.ssrUrl||this.appUrl;e.isHidden()&&e.url===this.appUrl?this.handleShowKeepAliveApp(e):t===n&&(e.isUnmounted()||e.isPrefetch&&this.sameCoreOptions(e))?this.handleMount(e):e.isPrefetch||e.isUnmounted()?this.handleCreateApp():C(`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.isHidden()?n.url===this.appUrl?this.handleShowKeepAliveApp(n):C(`app name conflict, an app named ${this.appName} is running`):n.url===this.appUrl&&n.ssrUrl===this.ssrUrl?this.handleMount(n):this.handleCreateApp():this.handleCreateApp()}legalAttribute(e,t){return!(!h(t)||!t)||(C(`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.unmount(!0,e):(t.actionsForCompletelyDestroy(),e()):e()}handleMount(e){e.isPrefetch=!1,N((()=>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")})}unmount(e,t){const n=Ln.get(this.appName);n&&!n.isUnmounted()&&n.unmount({destroy:e||this.getDestroyCompatibleResult(),clearData:this.getDisposeResult("clear-data"),keepRouteState:this.getDisposeResult("keep-router-state"),unmountcb:t})}handleHiddenKeepAliveApp(e){const t=Ln.get(this.appName);!t||t.isUnmounted()||t.isHidden()||t.hiddenKeepAliveApp(e)}handleShowKeepAliveApp(e){N((()=>{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=at.rawWindow.location;this.ssrUrl=W(t.pathname+t.search,e)}else{let t=function(e,t){const n=Tt(e);if(!n)return"";const o=D(n,t);return o.origin+o.pathname+o.search}(this.appName,e);const n=this.getDefaultPageValue();if(!t&&n){const o=D(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")||""}setAttribute(e,t){if("data"===e)if(_(t)){const e={};Object.getOwnPropertyNames(t).forEach((n=>{h(n)&&0===n.indexOf("__")||(e[n]=t[n])})),this.data=e}else"[object Object]"!==t&&M("property data must be an object",this.appName);else at.rawSetAttribute.call(this,e,t)}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}}at.rawWindow.customElements.define(e,n)}function Bn(e,t){if(!n)return C("preFetch is only supported in browser environment");T((()=>{const n=m(t)?t:Qn.options.prefetchDelay;setTimeout((()=>{!function(e){f(e)&&(e=e()),i(e)&&e.reduce(((e,t)=>e.then((()=>{return e=t,B((t=>{var n,o,r,i,s,a;if(_(e)&&navigator.onLine)if(e.name=x(e.name),e.url=I(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&&pe.includes(e.level)?e.level:Qn.options.prefetchLevel&&pe.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())}(e)}),m(n)?n:3e3)}))}function kn(e,t,n){if(i(e)){const o=e.filter((e=>h(e)&&e.includes(`.${t}`)&&!n.hasInfo(e)));U(o.map((e=>de(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=>{C(e)}))}}function Hn({excludeHiddenApp:e=!1,excludePreRender:t=!1}={}){const n=[];return Ln.forEach(((o,r)=>{o.isUnmounted()||o.isPrefetch&&(!o.isPrerender||t)||e&&o.isHidden()||n.push(r)})),n}function $n(){return Array.from(Ln.keys())}function Fn(e,t){const n=Ln.get(x(e));return new Promise((o=>{if(n)if(n.isUnmounted()||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.isHidden())(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=z(n.container),r=()=>{e.removeEventListener(ae.UNMOUNT,r),e.removeEventListener(ae.AFTERHIDDEN,i),o(!0)},i=()=>{e.removeEventListener(ae.UNMOUNT,r),e.removeEventListener(ae.AFTERHIDDEN,i),o(!0)};if(e.addEventListener(ae.UNMOUNT,r),e.addEventListener(ae.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"),h(t)&&e.setAttribute("destroy",t),h(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),h(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),h(n)&&e.setAttribute("clear-data",n)}}else M(`app ${e} does not exist`),o(!1)}))}function jn(e){return Array.from(Ln.keys()).reduce(((t,n)=>t.then((()=>Fn(n,e)))),Promise.resolve(!0))}function Kn(e,t){return new Promise((n=>{const o=Ln.get(x(e));if(o){const r=o.container&&z(o.container);r?n(r.reload(t)):(M(`app ${e} is not rendered, cannot use reload`),n(!1))}else M(`app ${e} does not exist`),n(!1)}))}function qn(e){return new Promise((t=>{if(!_(e))return C("renderApp options must be an object");const n=b(e.container)?e.container:h(e.container)?document.querySelector(e.container):null;if(!b(n))return C("Target container is not a DOM element.");const o=K(Qn.tagName);for(const t in e)if("onDataChange"===t)f(e[t])&&o.addEventListener("datachange",e[t]);else if("lifeCycles"===t){const n=e[t];if(_(n))for(const e in n)e.toUpperCase()in ae&&f(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(ae.MOUNTED,r),o.removeEventListener(ae.ERROR,i)};o.addEventListener(ae.MOUNTED,r),o.addEventListener(ae.ERROR,i),n.appendChild(o)}))}class Gn extends yt{constructor(){super(...arguments),this.tagName="micro-app",this.options={},this.router=Xt,this.preFetch=Bn,this.unmountApp=Fn,this.unmountAllApps=jn,this.getActiveApps=Hn,this.getAllApps=$n,this.reload=Kn,this.renderApp=qn}start(e){var t,o,r;if(!n||!window.customElements)return C("micro-app is not supported in this environment");if(null==e?void 0:e.tagName){if(!/^micro-app(-\S+)?/.test(e.tagName))return C(`${e.tagName} is invalid tagName`);this.tagName=e.tagName}if(ct(),at.rawWindow.customElements.get(this.tagName))return M(`element ${this.tagName} is already defined`);if(_(e)&&(this.options=e,e["disable-scopecss"]=null!==(t=e["disable-scopecss"])&&void 0!==t?t:e.disableScopecss,e["disable-sandbox"]=null!==(o=e["disable-sandbox"])&&void 0!==o?o:e.disableSandbox,e.preFetchApps&&Bn(e.preFetchApps),e.globalAssets&&(_(r=e.globalAssets)&&T((()=>{kn(r.js,"js",Se.script),kn(r.css,"css",Se.link)}))),_(e.plugins))){const t=e.plugins.modules;if(_(t))for(const e in t){const n=x(e);n&&e!==n&&(t[n]=t[e],delete t[e])}}Tn(this.tagName)}}const Qn=new Gn;e.EventCenterForMicroApp=gt,e.MicroApp=Gn,e.default=Qn,e.getActiveApps=Hn,e.getAllApps=$n,e.preFetch=Bn,e.pureCreateElement=K,e.reload=Kn,e.removeDomScope=j,e.renderApp=qn,e.unmountAllApps=jn,e.unmountApp=Fn,e.version=t,Object.defineProperty(e,"__esModule",{value:!0})}));
|
|
2
2
|
//# sourceMappingURL=index.umd.js.map
|