@micro-zoe/micro-app 1.0.0-rc.2 → 1.0.0-rc.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -17
- package/README.zh-cn.md +18 -18
- package/lib/index.d.ts +43 -20
- package/lib/index.esm.js +2077 -1082
- 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 +4 -4
- package/typings/global.d.ts +64 -46
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-rc.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 d(e){return"string"==typeof e}function h(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 v(e){var t;return e instanceof Element||d(null===(t=e)||void 0===t?void 0:t.tagName)}function b(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&&d(t)?` app ${t}:`:"";d(e)?console.error(`[micro-app]${o} ${e}`,...n):console.error(`[micro-app]${o}`,e,...n)}function M(e,t=null,...n){const o=t&&d(t)?` app ${t}:`:"";d(e)?console.warn(`[micro-app]${o} ${e}`,...n):console.warn(`[micro-app]${o}`,e,...n)}function N(e,...t){Promise.resolve().then(e.bind(null,...t))}const O=function(){class e extends URL{}return(t,n)=>n?new e(""+t,n):new e(""+t)}();function D(e){return e.startsWith("//")?`${o.location.protocol}${e}`:e}function I(e,t=null){if(!d(e)||!e)return"";try{const{origin:t,pathname:n,search:o}=O(D(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 d(e)&&e?e.replace(/(^\d+)|([^\w\d-_])/gi,""):""}function L(e){const{origin:t,pathname:n}=O(e);if(/\.(\w+)$/.test(n)){const e=`${t}${n}`.split("/");return e.pop(),e.join("/")+"/"}return`${t}${n}/`.replace(/\/\/$/,"/")}function T(e,t){return!e||/^((((ht|f)tps?)|file):)?\/\//.test(e)||/^(data|blob):/.test(e)?e:O(e,L(D(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 W=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=>{W((()=>{e(t)}))}))}let k=null;function F(e){k=e}function H(e){k!==e&&(F(e),N((()=>{F(null)})))}function $(){return k}function j(){F(null)}function K(e,t){const n=(window.rawDocument||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)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)||/^:root$/i.test(e)}function z(e){return function(e){return"undefined"!=typeof ShadowRoot&&e instanceof ShadowRoot}(e)?e.host:e}function X(e){return e?e.replace(/^\s+|\s+$/g,""):""}function V(){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)}}function ie(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=Vn.options.lifeCycles)||void 0===r?void 0:r[n])&&Vn.options.lifeCycles[n](a),e.dispatchEvent(a)}function se(e,t,n={}){var o;const r=new CustomEvent(t,{detail:n});null===(o=e.sandBox)||void 0===o||o.microAppWindow.dispatchEvent(r)}function ae(e,t=null,n={}){return j(),f(Vn.options.fetch)?Vn.options.fetch(e,n,t):window.fetch(e,n).then((e=>e.text()))}class ce{static getInstance(){return this.instance||(this.instance=new ce),this.instance}run(e,t){const n=e.name,o=e.ssrUrl||e.url;ae(o,n,{cache:"no-cache"}).then((r=>{if(!r){const t="html is empty, please check in detail";return e.onerror(new Error(t)),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,Vn.options.plugins).replace(/<head[^>]*>[\s\S]*?<\/head>/i,(e=>e.replace(/<head/i,"<micro-app-head").replace(/<\/head>/i,"</micro-app-head>"))).replace(/<body[^>]*>[\s\S]*?<\/body>/i,(e=>e.replace(/<body/i,"<micro-app-body").replace(/<\/body>/i,"</micro-app-body>")))}processHtml(e,t,n,o){var r;if(!o)return t;const i=[];return o.global&&i.push(...o.global),(null===(r=o.modules)||void 0===r?void 0:r[n])&&i.push(...o.modules[n]),i.length>0?i.reduce(((t,n)=>_(n)&&f(n.processHtml)?n.processHtml(t,e):t),t):t}}const le=/(^|\s+)(html|:root)(?=[\s>~[.#:]+|$)/,ue=/(^|\s+)((html[\s>~]+body)|body)(?=[\s>~[.#:]+|$)/;function pe(e,t){e=t?`${t} ${e}`:e;const n=new Error(e);throw n.reason=e,t&&(n.filename=t),n}class de{constructor(){this.cssText="",this.prefix="",this.baseURI="",this.linkPath="",this.result="",this.scopecssDisable=!1,this.scopecssDisableSelectors=[],this.scopecssDisableNextLine=!1,this.mediaRule=this.createMatcherForRuleWithChildRule(/^@media *([^{]+)/,"@media"),this.supportsRule=this.createMatcherForRuleWithChildRule(/^@supports *([^{]+)/,"@supports"),this.documentRule=this.createMatcherForRuleWithChildRule(/^@([-\w]+)?document *([^{]+)/,"@document"),this.hostRule=this.createMatcherForRuleWithChildRule(/^@host\s*/,"@host"),this.importRule=this.createMatcherForNoneBraceAtRule("import"),this.charsetRule=this.createMatcherForNoneBraceAtRule("charset"),this.namespaceRule=this.createMatcherForNoneBraceAtRule("namespace"),this.containerRule=this.createMatcherForRuleWithChildRule(/^@container *([^{]+)/,"@container")}exec(e,t,n,o){return this.cssText=e,this.prefix=t,this.baseURI=n,this.linkPath=o||"",this.matchRules(),V()?decodeURIComponent(this.result):this.result}reset(){this.cssText=this.prefix=this.baseURI=this.linkPath=this.result="",this.scopecssDisable=this.scopecssDisableNextLine=!1,this.scopecssDisableSelectors=[]}matchRules(){for(this.matchLeadingSpaces(),this.matchComments();this.cssText.length&&"}"!==this.cssText.charAt(0)&&(this.matchAtRule()||this.matchStyleRule());)this.matchComments()}matchStyleRule(){const e=this.formatSelector(!0);return this.scopecssDisableNextLine=!1,e?(this.recordResult(e),this.matchComments(),this.styleDeclarations(),this.matchLeadingSpaces(),!0):pe("selector missing",this.linkPath)}formatSelector(e){const t=this.commonMatch(/^[^{]+/,e);return!!t&&t[0].replace(/(^|,[\n\s]*)([^,]+)/g,((e,t,n)=>(n=X(n),this.scopecssDisableNextLine||this.scopecssDisable&&(!this.scopecssDisableSelectors.length||this.scopecssDisableSelectors.includes(n))||le.test(n)||(n=ue.test(n)?n.replace(ue,this.prefix+" micro-app-body"):this.prefix+" "+n),t+n)))}styleDeclarations(){return this.matchOpenBrace()?(this.matchAllDeclarations(),!!this.matchCloseBrace()||pe("Declaration missing '}'",this.linkPath)):pe("Declaration missing '{'",this.linkPath)}matchAllDeclarations(){let e=this.commonMatch(/^(?:url\(["']?(?:[^)"'}]+)["']?\)|[^}/])*/,!0)[0];if(e&&(this.scopecssDisableNextLine||this.scopecssDisable&&!this.scopecssDisableSelectors.length||(e=e.replace(/url\(["']?([^)"']+)["']?\)/gm,((e,t)=>/^((data|blob):|#)/.test(t)||/^(https?:)?\/\//.test(t)?e:(/^((\.\.?\/)|[^/])/.test(t)&&this.linkPath&&(this.baseURI=function(e){const t=e.split("/");return t.pop(),D(t.join("/")+"/")}(this.linkPath)),`url("${T(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.containerRule()||this.documentRule()||this.pageRule()||this.hostRule()||this.fontFaceRule())}keyframesRule(){if(!this.commonMatch(/^@([-\w]+)?keyframes\s*/))return!1;if(!this.commonMatch(/^[^{]+/))return pe("@keyframes missing name",this.linkPath);if(this.matchComments(),!this.matchOpenBrace())return pe("@keyframes missing '{'",this.linkPath);for(this.matchComments();this.keyframeRule();)this.matchComments();return this.matchCloseBrace()?(this.matchLeadingSpaces(),!0):pe("@keyframes missing '}'",this.linkPath)}keyframeRule(){let e;const t=[];for(;e=this.commonMatch(/^((\d+\.\d+|\.\d+|\d+)%?|[a-z]+)\s*/);)t.push(e[1]),this.commonMatch(/^,\s*/);return!!t.length&&(this.styleDeclarations(),this.matchLeadingSpaces(),!0)}customMediaRule(){return!!this.commonMatch(/^@custom-media\s+(--[^\s]+)\s*([^{;]+);/)&&(this.matchLeadingSpaces(),!0)}pageRule(){return!!this.commonMatch(/^@page */)&&(this.formatSelector(!1),this.scopecssDisableNextLine=!1,this.commonHandlerForAtRuleWithSelfRule("page"))}fontFaceRule(){return!!this.commonMatch(/^@font-face\s*/)&&this.commonHandlerForAtRuleWithSelfRule("font-face")}createMatcherForRuleWithChildRule(e,t){return()=>!!this.commonMatch(e)&&(this.matchOpenBrace()?(this.matchComments(),this.matchRules(),this.matchCloseBrace()?(this.matchLeadingSpaces(),!0):pe(`${t} missing '}'`,this.linkPath)):pe(`${t} missing '{'`,this.linkPath))}createMatcherForNoneBraceAtRule(e){const t=new RegExp("^@"+e+"\\s*([^;]+);");return()=>!!this.commonMatch(t)&&(this.matchLeadingSpaces(),!0)}commonHandlerForAtRuleWithSelfRule(e){return this.matchOpenBrace()?(this.matchAllDeclarations(),this.matchCloseBrace()?(this.matchLeadingSpaces(),!0):pe(`@${e} missing '}'`,this.linkPath)):pe(`@${e} missing '{'`,this.linkPath)}matchComments(){for(;this.matchComment(););}matchComment(){if("/"!==this.cssText.charAt(0)||"*"!==this.cssText.charAt(1))return!1;this.scopecssDisableNextLine=!1;let e=2;for(;""!==this.cssText.charAt(e)&&("*"!==this.cssText.charAt(e)||"/"!==this.cssText.charAt(e+1));)++e;if(e+=2,""===this.cssText.charAt(e-1))return pe("End of comment missing",this.linkPath);let t=this.cssText.slice(2,e-2);if(this.recordResult(`/*${t}*/`),t=X(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(X(e))}))}else"scopecss-enable"===t&&(this.scopecssDisable=!1,this.scopecssDisableSelectors=[]);return this.cssText=this.cssText.slice(e),this.matchLeadingSpaces(),!0}commonMatch(e,t=!1){const n=e.exec(this.cssText);if(!n)return;const o=n[0];return this.cssText=this.cssText.slice(o.length),t||this.recordResult(o),n}matchOpenBrace(){return this.commonMatch(/^{\s*/)}matchCloseBrace(){return this.commonMatch(/^}/)}matchLeadingSpaces(){this.commonMatch(/^\s*/)}recordResult(e){V()?this.result+=encodeURIComponent(e):this.result+=e}}function he(e,t,n,o,r){if(!e.__MICRO_APP_HAS_SCOPED__){e.__MICRO_APP_HAS_SCOPED__=!0;let i=null;try{i=me.exec(e.textContent,n,o,r),me.reset()}catch(e){me.reset(),C("An error occurred while parsing CSS:\n",t,e)}i&&(e.textContent=i)}}let me;function fe(e,t,n){if(t.scopecss){const o=_e(t.name);if(me||(me=new de),e.textContent)he(e,t.name,o,t.url,n);else{const r=new MutationObserver((function(){r.disconnect(),e.textContent&&!e.hasAttribute("data-styled")&&he(e,t.name,o,t.url,n)}));r.observe(e,{childList:!0})}}return e}function _e(e,t=!1){const n=t?"\\":"";return`${Vn.tagName}${n}[name=${e}${n}]`}function Ae(e,t){Object.defineProperties(e,{currentTarget:{get:()=>t},srcElement:{get:()=>t},target:{get:()=>t}})}function we(e){const t=new CustomEvent("load");Ae(t,e),f(e.onload)?e.onload(t):e.dispatchEvent(t)}function ye(e){const t=new CustomEvent("error");Ae(t,e),f(e.onerror)?e.onerror(t):e.dispatchEvent(t)}var ge,ve,be,Ee,Pe,Re,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)}))}})}}();function Ce(e,t,n,o=!1){const r=e.getAttribute("rel");let i=e.getAttribute("href"),s=null;if("stylesheet"===r&&i){i=T(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"].includes(r)?o?s=document.createComment(`link element with rel=${r}${i?" & href="+i:""} removed by micro-app`):null==t||t.removeChild(e):i&&Bn.rawSetAttribute.call(e,"href",T(i,n.url));return o?{replaceComment:s}:s?null==t?void 0:t.replaceChild(s,e):void 0}function Me(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:ae(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");Ne(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 Ne(e,t,n,o,r){if(e.scopecss){const r=o.appSpace[e.name];if(r.prefix=r.prefix||_e(e.name),r.parsedCode)n.textContent=r.parsedCode;else{const 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(_e(n,!0),"g"),t)}}(e.name,r.prefix,o);i?n.textContent=i:(n.textContent=o.code,fe(n,e,t)),r.parsedCode=n.textContent}}else n.textContent=o.code;!function(e,t){t.forEach(((t,n)=>{"rel"!==n&&("href"===n&&(n="data-origin-href"),Bn.rawSetAttribute.call(e,n,t))}))}(n,r)}!function(e){e.NAME="name",e.URL="url"}(ge||(ge={})),function(e){e.CREATED="created",e.LOADING="loading",e.LOAD_FAILED="load_failed",e.BEFORE_MOUNT="before_mount",e.MOUNTING="mounting",e.MOUNTED="mounted",e.UNMOUNT="unmount"}(ve||(ve={})),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"}(be||(be={})),function(e){e.ONMOUNT="onmount",e.ONUNMOUNT="onunmount"}(Ee||(Ee={})),function(e){e.KEEP_ALIVE_SHOW="keep_alive_show",e.KEEP_ALIVE_HIDDEN="keep_alive_hidden"}(Pe||(Pe={})),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"}(Re||(Re={}));const Oe=[1,2,3],De="search",Ie="custom",xe=[De,"history",Ie],Le=["popstate","hashchange","load","beforeunload","unload","unmount","appstate-change"],Te=["onpopstate","onhashchange","onload","onbeforeunload","onunload"],Ue=["DOMContentLoaded","readystatechange"],We=["onreadystatechange"],Be=["window","self","globalThis"],ke=["rawWindow","rawDocument"],Fe="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",He=["text/javascript","text/ecmascript","application/javascript","application/ecmascript","module","systemjs-module","systemjs-importmap"];function $e(e,t){return t.appSpace[e.name].module&&(!e.useSandbox||e.iframe)}function je(e,t){return e.inline||t.appSpace[e.name].inline||$e(e,t)||function(e,t){return t.appSpace[e.name].attrs.has("id")}(e,t)}function Ke(e){return e.iframe?e.sandBox.microAppWindow:Bn.rawWindow}function qe(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(Ke(e).Function)(t)}(e,n)}function Ge(){const e="inline-"+Math.random().toString(36).substr(2,15);return Se.script.hasInfo(e)?Ge():e}function Qe(e,t){return e.useSandbox&&!$e(e,t)}function ze(e,t){return Qe(e,t)?e.iframe?"iframe":"with":"disable"}function Xe(e,t,n,o=!1){var r;let i=null,s=e.getAttribute("src");if(s&&(s=T(s,n.url)),e.hasAttribute("exclude")||Ye(s,n.name))i=document.createComment("script element with exclude attribute removed by micro-app");else{if(e.type&&!He.includes(e.type)||e.hasAttribute("ignore")||Je(s,n.name))return(null===(r=Bn.rawDocument)||void 0===r?void 0:r.currentScript)&&delete Bn.rawDocument.currentScript,null;if(Bn.supportModuleScript&&e.noModule||!Bn.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=Ge(),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 Ve(e){var t,n,o;return[...(null===(t=Vn.options.plugins)||void 0===t?void 0:t.global)||[],...(null===(o=null===(n=Vn.options.plugins)||void 0===n?void 0:n.modules)||void 0===o?void 0:o[e])||[]]}function Ye(e,t){if(!e)return!1;return(Ve(t)||[]).some((t=>!!t.excludeChecker&&t.excludeChecker(e)))}function Je(e,t){if(!e)return!1;return(Ve(t)||[]).some((t=>!!t.ignoreChecker&&t.ignoreChecker(e)))}function Ze(e,t){const n=Array.from(t.source.scripts),o=[],r=[];for(const e of n){const n=Se.script.getInfo(e),i=n.appSpace[t.name];(!i.defer&&!i.async||t.isPrefetch&&!t.isPrerender)&&(o.push(n.code?n.code:ae(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=tt(e,o,n,t),r.sandboxType=ze(o,t),!je(o,t)))try{r.parsedFunction=qe(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 et(e,t,n,o,r){try{!function(e){!function(e){e.sandBox&&(Bn.rawWindow.__MICRO_APP_PROXY_WINDOW__=e.sandBox.proxyWindow)}(e)}(t);const i=n.appSpace[t.name],s=ze(t,n);if(i.parsedCode&&i.sandboxType===s||(i.parsedCode=tt(e,t,n.code,n),i.sandboxType=s,i.parsedFunction=null),je(t,n)){const s=r||K("script");if(function(e,t,n,o,r,i){if(n){if(Bn.rawSetAttribute.call(o,"type","module"),oe(e)?o.textContent=t:o.src=e,i){const t=()=>{i.moduleCount&&i.moduleCount--,i(0===i.moduleCount)};oe(e)?N(t):o.onload=t}}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"),Bn.rawSetAttribute.call(e,n,t))}))}(o,r)}(e,i.parsedCode,$e(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=qe(e,t,n.parsedCode));n.parsedFunction.call(Ke(e))}(t,n)}catch(n){console.error(`[micro-app from ${r?"runDynamicScript":"runScript"}] app ${t.name}: `,n,e)}}function tt(e,t,n,o){return _(Vn.options.plugins)&&(n=function(e,t,n,o){var r;const i=nt(o.global,t,e);return nt(null===(r=o.modules)||void 0===r?void 0:r[n],i,e)}(e,n,t.name,Vn.options.plugins)),Qe(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(${Fe}){;${n}\n${oe(e)?"":`//# sourceURL=${e}\n`}}).call(proxyWindow,${Fe})}})(window.__MICRO_APP_PROXY_WINDOW__);`:n}function nt(e,t,n){return i(e)?e.reduce(((e,t)=>_(t)&&f(t.loader)?t.loader(e,n):e),t):t}function ot(e,t,n,o){const r=Array.from(e.children);r.length&&r.forEach((e=>{ot(e,t,n,o)}));for(const n of r)E(n)?n.hasAttribute("exclude")||Ye(n.getAttribute("href"),t.name)?e.replaceChild(document.createComment("link element with exclude attribute ignored by micro-app"),n):n.hasAttribute("ignore")||Je(n.getAttribute("href"),t.name)?n.hasAttribute("href")&&Bn.rawSetAttribute.call(n,"href",T(n.getAttribute("href"),t.url)):Ce(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,(()=>fe(n,t))):R(n)?Xe(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")&&Bn.rawSetAttribute.call(n,"src",T(n.getAttribute("src"),t.url)));var i,s}function rt(e,t){const n=function(e){const t=K("div");return t.innerHTML=e,t}(e),o=Bn.rawElementQuerySelector.call(n,"micro-app-head"),r=Bn.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;ot(n,t,o,i);const s=ne(i);t.source.links.size?Me(n,t,o,s):s?s.then((()=>t.onLoad(n))):t.onLoad(n),t.source.scripts.size?Ze(n,t):t.onLoad(n)}const it=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 st(e,t){return d(e)&&e?t?`__from_base_app_${e}__`:`__from_micro_app_${e}__`:""}class at{addGlobalDataListener(e,t){const n=this.appName;n&&(e.__APP_NAME__=n,e.__AUTO_TRIGGER__=t),it.on("global",e,t)}removeGlobalDataListener(e){f(e)&&it.off("global",e)}setGlobalData(e,t,n){j(),it.dispatch("global",e,(e=>f(t)&&t(e)),n)}forceSetGlobalData(e,t){this.setGlobalData(e,t,!0)}getGlobalData(){return it.getData("global")}clearGlobalData(){it.clearData("global")}clearGlobalDataListener(){const e=this.appName,t=it.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 ct extends at{addDataListener(e,t,n){it.on(st(x(e),!1),t,n)}removeDataListener(e,t){f(t)&&it.off(st(x(e),!1),t)}getData(e,t=!1){return it.getData(st(x(e),t))}setData(e,t,n,o){it.dispatch(st(x(e),!0),t,(e=>f(n)&&n(e)),o)}forceSetData(e,t,n){this.setData(e,t,n,!0)}clearData(e,t=!0){it.clearData(st(x(e),t))}clearDataListener(e){it.off(st(x(e),!1))}}class lt extends at{constructor(e){super(),this.appName=x(e),!this.appName&&C(`Invalid appName ${e}`)}addDataListener(e,t){e.__AUTO_TRIGGER__=t,it.on(st(this.appName,!0),e,t)}removeDataListener(e){f(e)&&it.off(st(this.appName,!0),e)}getData(e=!0){return it.getData(st(this.appName,e))}dispatch(e,t,n){j(),it.dispatch(st(this.appName,!1),e,(e=>f(t)&&t(e)),n,(()=>{const t=Pn.get(this.appName);if((null==t?void 0:t.container)&&_(e)){const e=new CustomEvent("datachange",{detail:{data:it.getData(st(this.appName,!1))}});z(t.container).dispatchEvent(e)}}))}forceDispatch(e,t){this.dispatch(e,t,!0)}clearData(e=!1){it.clearData(st(this.appName,e))}clearDataListener(){it.off(st(this.appName,!0))}}function ut(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=it.eventList.get("global");if(o)for(const t of o.callbacks)e.appName===t.__APP_NAME__&&e.umdDataListeners.global.add(t);const r=it.eventList.get(st(e.appName,!0));if(r)for(const t of r.callbacks)e.umdDataListeners.normal.add(t)}}function pt(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__);dt(e)}}function dt(e){null==e||delete e.umdDataListeners}class ht{constructor(){this.appInstanceMap=Pn}static getInstance(){return this.instance||(this.instance=new ht),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 mt(){ft(),ht.getInstance().getAll().forEach((e=>{e.container&&z(e.container).disconnectedCallback()})),!window.__MICRO_APP_UMD_MODE__&&ht.getInstance().clear()}function ft(){window.__MICRO_APP_ENVIRONMENT__&&window.removeEventListener("unmount",mt,!1)}function _t(e){return h(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 At(e,t,n="WINDOW"){if(f(e)&&!function(e){return h(e.__MICRO_APP_IS_CONSTRUCTOR__)?e.__MICRO_APP_IS_CONSTRUCTOR__:e.__MICRO_APP_IS_CONSTRUCTOR__=y(e)}(e)&&!_t(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}function wt(e,t,n){const{proxyDocument: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}=Bn;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 d(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 h=()=>{o.clear(),i=null},m=()=>{i=r||i,n.forEach(((e,t)=>{if(e.size){const n=o.get(t)||[];o.set(t,new Set([...n,...e]))}}))},_=()=>{i&&!r&&(y.onclick=i),o.forEach(((e,t)=>{for(const n of e)y.addEventListener(t,n,null==n?void 0:n.__MICRO_APP_MARK_OPTIONS__)})),h()},A=()=>{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())},w=(()=>{var e;const t=new Map([["onclick",e=>{f(r)&&l.call(s,"click",r,!1),f(e)&&c.call(s,"click",e,!1),r=e}]]),n=(null===(e=Vn.options)||void 0===e?void 0:e.customProxyDocumentProps)||new Map;return new Map([...t,...n])})(),y=new Proxy(s,{get:(n,o)=>{var i;return H(e),"createElement"===o?u:o===Symbol.toStringTag?"ProxyDocument":"defaultView"===o?t.proxyWindow:"onclick"===o?r:"addEventListener"===o?p:"removeEventListener"===o?d:"microAppElement"===o?null===(i=Pn.get(e))||void 0===i?void 0:i.container:"__MICRO_APP_NAME__"===o?e:At(Reflect.get(n,o),s,"DOCUMENT")},set:(e,t,n)=>{if(w.has(t)){w.get(t)(n)}else"microAppElement"!==t&&Reflect.set(e,t,n);return!0}});return{proxyDocument:y,documentEffect:{reset:h,record:m,rebuild:_,release:A}}}(e,n),i=function(e,t){const{rawDocument:n,rawRootDocument:o}=Bn;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)=>(H(e),At(Reflect.get(t,o),n,"DOCUMENT")),set:(e,t,n)=>(Reflect.set(e,t,n),!0)})),r}(e,o);return c(t,{document:{configurable:!1,enumerable:!0,get:()=>o},Document:{configurable:!1,enumerable:!1,get:()=>i}}),r}function yt(e,t,n){return function(e){const t=Bn.rawWindow;Object.getOwnPropertyNames(t).filter((e=>/^on/.test(e)&&!Te.includes(e))).forEach((n=>{const{enumerable:o,writable:r,set:i}=Object.getOwnPropertyDescriptor(t,n)||{enumerable:!0,writable:!0};a(e,n,{enumerable:o,configurable:!0,get:()=>t[n],set:(null!=r?r:i)?e=>{t[n]=e}:void 0})}))}(t),function(e,t,n){const o=Bn.rawWindow,r=new Map,i=new Proxy(t,{get:(t,r)=>(H(e),Reflect.has(t,r)||d(r)&&/^__MICRO_APP_/.test(r)||n.scopeProperties.includes(r)?(ke.includes(r)&&j(),Reflect.get(t,r)):At(Reflect.get(o,r),o)),set:(e,t,r)=>{if(n.adapter.escapeSetterKeyList.includes(t))Reflect.set(o,t,r);else if(l.call(e,t)||!l.call(o,t)||n.scopeProperties.includes(t))!Reflect.has(e,t)&&n.injectedKeys.add(t),Reflect.set(e,t,r);else{const i=Object.getOwnPropertyDescriptor(o,t),{configurable:s,enumerable:c,writable:l,set:u}=i;a(e,t,{value:r,configurable:s,enumerable:c,writable:null!=l?l:!!u}),n.injectedKeys.add(t)}return(n.escapeProperties.includes(t)||n.adapter.staticEscapeProperties.includes(t)&&!Reflect.has(o,t))&&!n.scopeProperties.includes(t)&&(!Reflect.has(o,t)&&n.escapeKeys.add(t),Reflect.set(o,t,r)),!0},has:(e,t)=>n.scopeProperties.includes(t)?n.adapter.staticScopeProperties.includes(t)?!!e[t]:t in e:t in e||t in o,getOwnPropertyDescriptor:(e,t)=>{if(l.call(e,t))return r.set(t,"target"),Object.getOwnPropertyDescriptor(e,t);if(l.call(o,t)){r.set(t,"rawWindow");const e=Object.getOwnPropertyDescriptor(o,t);return e&&!e.configurable&&(e.configurable=!0),e}},defineProperty:(e,t,n)=>"rawWindow"===r.get(t)?Reflect.defineProperty(o,t,n):Reflect.defineProperty(e,t,n),ownKeys:e=>Reflect.ownKeys(o).concat(Reflect.ownKeys(e)).filter((function(e){return!(e in this)&&(this[e]=!0)}),Object.create(null)),deleteProperty:(e,t)=>!l.call(e,t)||(n.injectedKeys.has(t)&&n.injectedKeys.delete(t),n.escapeKeys.has(t)&&Reflect.deleteProperty(o,t),Reflect.deleteProperty(e,t))});n.proxyWindow=i}(e,t,n),function(e){const t=new Map,n=new Map,o=new Map,r=new Map,{rawWindow:i,rawAddEventListener:s,rawRemoveEventListener:a,rawDispatchEvent:c,rawSetInterval:l,rawSetTimeout:u,rawClearInterval:p,rawClearTimeout:d}=Bn;function h(t){return Le.includes(t)?e:i}e.addEventListener=function(e,n,o){const r=t.get(e);r?r.add(n):t.set(e,new Set([n])),n&&(n.__MICRO_APP_MARK_OPTIONS__=o),s.call(h(e),e,n,o)},e.removeEventListener=function(e,n,o){const r=t.get(e);(null==r?void 0:r.size)&&r.has(n)&&r.delete(n),a.call(h(e),e,n,o)},e.dispatchEvent=function(e){return c.call(h(null==e?void 0:e.type),e)},e.setInterval=function(e,t,...n){const r=l.call(i,e,t,...n);return o.set(r,{handler:e,timeout:t,args:n}),r},e.setTimeout=function(e,t,...n){const o=u.call(i,e,t,...n);return r.set(o,{handler:e,timeout:t,args:n}),o},e.clearInterval=function(e){o.delete(e),p.call(i,e)},e.clearTimeout=function(e){r.delete(e),d.call(i,e)};const m=()=>{n.clear()},f=()=>{n.forEach(((t,n)=>{for(const o of t)e.addEventListener(n,o,null==o?void 0:o.__MICRO_APP_MARK_OPTIONS__)})),m()};return{reset:m,record:()=>{t.forEach(((e,t)=>{if(e.size){const o=n.get(t)||[];n.set(t,new Set([...o,...e]))}}))},rebuild:f,release:e=>{t.size&&(t.forEach(((e,t)=>{for(const n of e)a.call(h(t),t,n)})),t.clear()),e&&(o.forEach(((e,t)=>{p.call(i,t)})),r.forEach(((e,t)=>{d.call(i,t)})),o.clear(),r.clear())}}}(t)}function gt(e,t){if(!xt(e)){const n=Bn.rawWindow.history.state,o={microAppState:s({},null==n?void 0:n.microAppState,{[e]:t})};return s({},n,o)}return t}function vt(e){var t;const n=Bn.rawWindow.history.state;return xt(e)?n:(null===(t=null==n?void 0:n.microAppState)||void 0===t?void 0:t[e])||null}const bt=/&/g,Et=/=/g,Pt=/%M1/g,Rt=/%M2/g;function St(e){return encodeURIComponent(Mt(e).replace(bt,"%M1").replace(Et,"%M2"))}function Ct(e){return Mt(e).replace(Pt,"&").replace(Rt,"=")}function Mt(e){try{const t=decodeURIComponent(e);return e===t||Pt.test(t)||Rt.test(t)?t:Mt(t)}catch(t){return e}}function Nt(e){var t,n;const o=Bn.rawWindow.location;if(!xt(e)){const r=Dt(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 d(i)?Ct(i):null}return o.pathname+o.search+o.hash}function Ot(e,t){const n=t.pathname+t.search+t.hash;let o=!1;if(!xt(e)){let{pathname:t,search:r,hash:i}=Bn.rawWindow.location;const s=Dt(r,i),a=St(n);if(i&&!r){o=!0,s.hashQuery?s.hashQuery[e]=a:s.hashQuery={[e]:a};const t=i.includes("?")?i.slice(0,i.indexOf("?")+1):i+"?";i=t+J(s.hashQuery)}else s.searchQuery?s.searchQuery[e]=a:s.searchQuery={[e]:a},r="?"+J(s.searchQuery);return{fullPath:t+r+i,isAttach2Hash:o}}return{fullPath:n,isAttach2Hash:o}}function Dt(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 It(e){const t=Pn.get(e);return!(!t||t.isPrefetch)}function xt(e){const t=Pn.get(e);return!t||!t.sandBox||t.routerMode===Ie}function Lt(e,t){let n;return n=t?t.getDisposeResult("disable-memory-router")?Ie:e||Vn.options["router-mode"]||"":Vn.options["disable-memory-router"]?Ie:e||Vn.options["router-mode"]||"",xe.includes(n)?n:De}function Tt(e){const t=Bn.rawWindow,n=t=>{jn({excludeHiddenApp:!0,excludePreRender:!0}).includes(e)&&!t.onlyForBrowser&&Ut(e,Nt(e))};return t.addEventListener("popstate",n),()=>{t.removeEventListener("popstate",n)}}function Ut(e,t){const n=Pn.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("popstate",{state:vt(e)});n.dispatchEvent(o),Sn(e)||f(t.onpopstate)&&t.onpopstate(o)}(e,o,r),i&&function(e,t,n,o){const r=new HashChangeEvent("hashchange",{newURL:t.location.href,oldURL:o});n.dispatchEvent(r),Sn(e)||f(t.onhashchange)&&t.onhashchange(r)}(e,o,r,s),j()}function Wt(e,t,n){j(),It(e)&&(function(e){const t=new PopStateEvent("popstate",{state:null});e&&(t.onlyForBrowser=!0),Bn.rawWindow.dispatchEvent(t)}(t),n&&function(e){const t=new HashChangeEvent("hashchange",{newURL:Bn.rawWindow.location.href,oldURL:e});Bn.rawWindow.dispatchEvent(t)}(n))}function Bt(e,t){const n=Bn.rawWindow.history;function o(n){return function(...o){var r,i,s;if(d(o[2])||g(o[2])){const a=O(o[2],t.href),c=a.pathname+a.search+a.hash;Ft(e,n,Ot(e,a),!0,gt(e,o[0]),o[1]),c!==t.fullPath&&an(e,c,t),null===(s=null===(r=Pn.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 Sn(e)?{pushState:r,replaceState:i}:new Proxy(n,{get:(t,n)=>"state"===n?vt(e):"pushState"===n?r:"replaceState"===n?i:At(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(It(e)){("pushState"===t?Bn.rawPushState:Bn.rawReplaceState).call(Bn.rawWindow.history,o,r,n)}}function Ft(e,t,n,o,r,i){if(It(e)){const s=Bn.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||xt(e)||Wt(e,o,c)}}function Ht(e,t,n){Ft(e,"replaceState",t,!0,n)}function $t(e){const t=Bn.rawWindow;return function(...n){var o;if((null===(o=t.history.state)||void 0===o?void 0:o.microAppState)&&(!_(n[0])||!n[0].microAppState)&&(d(n[2])||g(n[2]))){const e=t.location.href;O(n[2],e).href===e&&(n[0]=s({},n[0],{microAppState:t.history.state.microAppState}))}e.apply(t.history,n),jn({excludeHiddenApp:!0,excludePreRender:!0}).forEach((e=>{if(!xt(e)&&!Nt(e)){Ht(e,Ot(e,Pn.get(e).sandBox.proxyWindow.location),gt(e,vt(e)))}})),j()}}function jt(){const e=Bn.rawWindow;e.history.pushState=$t(Bn.rawPushState),e.history.replaceState=$t(Bn.rawReplaceState)}function Kt(){const e=Bn.rawWindow;e.history.pushState=Bn.rawPushState,e.history.replaceState=Bn.rawReplaceState}const{router:qt,executeNavigationGuard:Gt,clearRouterWhenUnmount:Qt}=function(){function e(e,t,n,o){const r=t.sandBox.proxyWindow.location,i=O(n.path,r.href),s=r.pathname+r.search+r.hash,a=i.pathname+i.search+i.hash;if(s!==a||Nt(e)!==a){!function(e,t,n,o){Ft(e,t,Ot(e,n),!1,gt(e,null!=o?o:null)),j()}(e,o&&!1!==n.replace||!0===n.replace?"replaceState":"pushState",i,n.state),xt(e)&&Ut(e,a)}}function t(t){return function(n){const o=x(n.name);if(o&&d(n.path))if(jn({excludeHiddenApp:!0,excludePreRender:!0}).includes(o)){const r=Pn.get(o),i=()=>e(o,r,n,t);r.iframe?r.sandBox.sandboxReady.then(i):i()}else M("navigation failed, app does not exist or is inactive");else C("navigation failed, name & path are required when use router."+(t?"replace":"push"))}}function n(e){return function(...t){return Bn.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){if(!xt(e)){Ht(e,Ot(e,Pn.get(e).sandBox.proxyWindow.location),gt(e,vt(e)))}}const c=Object.assign(Object.assign({current:new Map,encode:St,decode:Ct,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))&&jn().includes(e)&&a(e)},attachAllToURL:function({includeHiddenApp:e=!1,includePreRender:t=!1}){jn({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(),At(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()),W((()=>{s(e,t,n,i.list())}))},clearRouterWhenUnmount:function(e){c.current.delete(e)}}}(),zt=["getComputedStyle","visualViewport","matchMedia","ResizeObserver","IntersectionObserver"],Xt=[/animationFrame$/i,/mutationObserver$/i,/height$|width$/i,/offset$/i,/selection$/i,/^range/i,/^screen/i,/^scroll/i,/X$|Y$/],Vt=["body","head","html","title"],Yt=["host","hostname","port","protocol","origin"],Jt=["childElementCount","children","firstElementChild","firstChild","lastElementChild","activeElement","fullscreenElement","pictureInPictureElement","pointerLockElement","styleSheets"],Zt=["append","contains","replaceChildren","createRange","getSelection","elementFromPoint","elementsFromPoint","getAnimations"],en=["characterSet","compatMode","contentType","designMode","dir","doctype","embeds","fullscreenEnabled","hidden","implementation","lastModified","pictureInPictureEnabled","plugins","readyState","referrer","visibilityState","fonts"],tn=["execCommand","createRange","exitFullscreen","exitPictureInPicture","getElementsByTagNameNS","hasFocus","prepend"],nn=["href","pathname","search","hash","host","hostname","port","protocol","search"],on=[...nn,"origin","fullPath"];function rn(e,t,n,o,r,i){const s=Bn.rawWindow.location,c=!!n,l=O(t);function u(){return c?n.location:l}function p(t,n){const o=O(t,A.href);if(o.origin===A.origin){const t=Ot(e,o);if(!xt(e)){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?Wt(e,!1,r):_())}if(t.isAttach2Hash)return kt(e,n,t.fullPath),void _()}return t.fullPath}return t}function d(n,o){const r=O(n,t);r[o]===A[o]&&A.hash?Wt(e,!1):(kt(e,r[o]===A[o]?"replaceState":"pushState",Ot(e,r).fullPath),_())}const h=t=>function(n){if(It(e)){const e=p(n,"assign"===t?"pushState":"replaceState");e&&s[t](O(e,s.origin).href)}},m=h("assign"),f=h("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(Yt.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:At(Reflect.get(n,t),n,"LOCATION")},set:(n,o,r)=>{if(It(e)){const n=u();if("href"===o){const e=p(r,"pushState");e&&(s.href=O(e,s.origin).href)}else if("pathname"===o)if(xt(e))s.pathname=r;else{d(("/"+r).replace(/^\/+/,"/")+A.search+A.hash,"pathname")}else if("search"===o)if(xt(e))s.search=r;else{d(A.pathname+("?"+r).replace(/^\?+/,"?")+A.hash,"search")}else if("hash"===o)if(xt(e))s.hash=r;else{const n=A.pathname+A.search+("#"+r).replace(/^#+/,"#"),o=O(n,t);o.hash!==A.hash&&Ft(e,"pushState",Ot(e,o),!1)}else Reflect.set(n,o,r)}return!0}});return A}function sn(e,t){const n=s({name:e},t);for(const e of on)n[e]=t[e];return n}function an(e,t,n,o){var r;const i=sn(e,n),s=O(t,n.href);if(Sn(e)){const t=Pn.get(e).sandBox.microAppWindow;null===(r=t.rawReplaceState)||void 0===r||r.call(t.history,vt(e),"",s.href)}else for(const e of nn)n.self[e]=s[e];const a=sn(e,n);("auto"===o||i.fullPath!==a.fullPath&&"prevent"!==o)&&Gt(e,a,i)}function cn(e,t,n){const o=Nt(e);o?an(e,o,t,"auto"):ln(e,t,n)}function ln(e,t,n){n&&an(e,n,t,"prevent"),Ht(e,Ot(e,t),gt(e,null)),function(e,t){Gt(e,sn(e,t),sn(e,t))}(e,t)}function un(e,t,n,o){if(!xt(e)){if(!o){const{pathname:o,search:r,hash:i}=O(t);an(e,o+r+i,n,"prevent")}pn(e)}Qt(e)}function pn(e){Ht(e,function(e,t){var n,o,r,i;let{pathname:s,search:a,hash:c}=t||Bn.rawWindow.location,l=!1;if(!xt(e)){const t=Dt(a,c);if(null===(n=t.hashQuery)||void 0===n?void 0:n[e]){l=!0,null===(o=t.hashQuery)||void 0===o||delete o[e];const n=J(t.hashQuery);c=c.slice(0,c.indexOf("?")+Number(Boolean(n)))+n}else if(null===(r=t.searchQuery)||void 0===r?void 0:r[e]){null===(i=t.searchQuery)||void 0===i||delete i[e];const n=J(t.searchQuery);a=n?"?"+n:""}}return{fullPath:s+a+c,isAttach2Hash:l}}(e),function(e,t){return xt(e)?t:(_(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,Bn.rawWindow.history.state))}class dn{constructor(){this.escapeSetterKeyList=["location"],this.staticEscapeProperties=["System","__cjsWrapper"],this.staticScopeProperties=["webpackJsonp","webpackHotUpdate","Vue"],this.injectReactHMRProperty()}injectReactHMRProperty(){}}function hn(e,t){const n=Array.from(e.children);n.length&&n.forEach((e=>{hn(e,t)}));for(const e of n)mn(e,t)}function mn(e,t){var n,o;const r=null===(o=null===(n=Pn.get(t))||void 0===n?void 0:n.sandBox)||void 0===o?void 0:o.proxyWindow;return b(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}}),Sn(t)&&a(e,"ownerDocument",{configurable:!0,get:()=>r.document})),e}function fn(e,t){const n=u(t)?Bn.rawWindow.fetch:t;return f(n)?function(t,o,...r){return(d(t)||g(t))&&(t=O(t,e).toString()),j(),n.call(Bn.rawWindow,t,o,...r)}:n}function _n(e,t){const n=u(t)?Bn.rawWindow.XMLHttpRequest:t;return y(n)?class extends n{open(t,n,...o){(d(n)&&!/^f(ile|tp):\/\//.test(n)||g(n))&&(n=O(n,e).toString()),j(),super.open(t,n,...o)}}:n}const{createMicroEventSource:An,clearMicroEventSource:wn}=function(){let e;return{createMicroEventSource:function(t,n,o){const r=u(o)?Bn.rawWindow.EventSource:o;return y(r)?class extends r{constructor(o,r,...i){if((d(o)||g(o))&&(o=O(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())}}}();class yn{constructor(e,t){this.active=!1,this.scopeProperties=[],this.escapeProperties=[],this.escapeKeys=new Set,this.injectedKeys=new Set,this.microAppWindow=new EventTarget,this.adapter=new dn,this.getSpecialProperties(e),this.patchRouter(e,t,this.microAppWindow),this.windowEffect=yt(e,this.microAppWindow,this),this.documentEffect=wt(e,this.microAppWindow,this),this.initStaticGlobalKeys(e,t,this.microAppWindow)}start({umdMode:e,baseroute:t,defaultPage:n,disablePatchRequest:o}){this.active||(this.active=!0,this.initRouteState(n),this.removeHistoryListener=Tt(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,o),1==++Bn.activeSandbox&&(Ln(),jt()),1==++yn.activeCount&&window.__MICRO_APP_ENVIRONMENT__&&(ft(),window.addEventListener("unmount",mt,!1)),Bn.rawWindow._babelPolyfill&&(Bn.rawWindow._babelPolyfill=!1))}stop({umdMode:e,keepRouteState:t,destroy:n,clearData:o}){var r;this.active&&(this.recordAndReleaseEffect({umdMode:e,clearData:o,destroy:n},!e||n),this.clearRouteState(t),null===(r=this.removeHistoryListener)||void 0===r||r.call(this),e&&!n||(wn(this.microAppWindow.__MICRO_APP_NAME__),this.injectedKeys.forEach((e=>{Reflect.deleteProperty(this.microAppWindow,e)})),this.injectedKeys.clear(),this.escapeKeys.forEach((e=>{Reflect.deleteProperty(Bn.rawWindow,e)})),this.escapeKeys.clear()),0==--Bn.activeSandbox&&(Un(),Kt()),--yn.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.__MICRO_APP_SANDBOX__=this,n.__MICRO_APP_SANDBOX_TYPE__="with",n.rawWindow=Bn.rawWindow,n.rawDocument=Bn.rawDocument,n.microApp=s(new lt(e),{removeDomScope:j,pureCreateElement:K,router:qt}),this.setMappingPropertiesWithRawDescriptor(n)}recordAndReleaseEffect(e,t=!1){t?this.resetEffectSnapshot():this.recordEffectSnapshot(),this.releaseGlobalEffect(e)}resetEffectSnapshot(){this.windowEffect.reset(),this.documentEffect.reset(),dt(this.microAppWindow.microApp)}recordEffectSnapshot(){this.windowEffect.record(),this.documentEffect.record(),ut(this.microAppWindow.microApp)}rebuildEffectSnapshot(){this.windowEffect.rebuild(),this.documentEffect.rebuild(),pt(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&&(Vn.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),_(Vn.options.plugins)&&(this.commonActionForSpecialProperties(Vn.options.plugins.global),this.commonActionForSpecialProperties(null===(t=Vn.options.plugins.modules)||void 0===t?void 0:t[e]))}commonActionForSpecialProperties(e){if(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)))}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=Bn.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)),Be.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(Bn.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(Bn.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:()=>(H(e),n||Bn.rawWindow.eval),set:e=>{n=e}},Image:{configurable:!0,enumerable:!1,get:()=>(H(e),o||Bn.ImageProxy),set:e=>{o=e}}})}patchRequestApi(e,t,n){let o=fn(t),r=_n(t),i=An(e,t);c(n,{fetch:{configurable:!0,enumerable:!0,get:()=>o,set(e){o=fn(t,e)}},XMLHttpRequest:{configurable:!0,enumerable:!0,get:()=>r,set(e){r=_n(t,e)}},EventSource:{configurable:!0,enumerable:!0,get:()=>i,set(n){i=An(e,t,n)}}})}setScopeProperties(e){this.scopeProperties.forEach((t=>{Reflect.set(e,t,e[t])}))}patchRouter(e,t,n){const{microLocation:o,microHistory:r}=function(e,t){const n=rn(e,t);return{microLocation:n,microHistory:Bt(e,n)}}(e,t);c(n,{location:{configurable:!1,enumerable:!0,get:()=>o,set:e=>{Bn.rawWindow.location=e}},history:{configurable:!0,enumerable:!0,get:()=>r}})}initRouteState(e){cn(this.microAppWindow.__MICRO_APP_NAME__,this.microAppWindow.location,e)}clearRouteState(e){un(this.microAppWindow.__MICRO_APP_NAME__,this.microAppWindow.__MICRO_APP_URL__,this.microAppWindow.location,e)}setRouteInfoForKeepAliveApp(){ln(this.microAppWindow.__MICRO_APP_NAME__,this.microAppWindow.location)}removeRouteInfoForKeepAliveApp(){pn(this.microAppWindow.__MICRO_APP_NAME__)}patchStaticElement(e){hn(e,this.microAppWindow.__MICRO_APP_NAME__)}actionBeforeExecScripts(e){this.patchStaticElement(e)}}function gn(e,t,n){return function(e,t){const n=Bn.rawWindow;zt.forEach((e=>{t[e]=At(n[e],n)})),Object.getOwnPropertyNames(t).filter((e=>(Xt.some((o=>{if(o.test(e)&&e in t.parent){if(f(n[e]))t[e]=At(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)&&!Te.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)}}))}(e,t),function(e,t){const n=Bn.rawWindow,o=[],r=new Proxy(e,{get:(e,n)=>"location"===n?t.proxyLocation:Be.includes(n.toString())?r:o.includes(n)?Reflect.get(e,n):At(Reflect.get(e,n),e),set:(e,r,i)=>"location"===r?Reflect.set(n,r,i):(Reflect.has(e,r)||o.push(r),Reflect.set(e,r,i),t.escapeProperties.includes(r)&&(!Reflect.has(n,r)&&t.escapeKeys.add(r),Reflect.set(n,r,i)),!0),has:(e,t)=>t in e,deleteProperty:(e,o)=>!Reflect.has(e,o)||(t.escapeKeys.has(o)&&Reflect.deleteProperty(n,o),Reflect.deleteProperty(e,o))});t.proxyWindow=r}(t,n),function(e){const{rawWindow:t,rawAddEventListener:n,rawRemoveEventListener:o}=Bn,r=new Map,i=new Map;function s(n){return Le.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 vn(e,t,n){return function(e,t){const n=Bn.rawDocument,o=t.Document,r=t.document,i=o.prototype.createElement,s=o.prototype.createTextNode,a=o.prototype.createComment,c=o.prototype.querySelector,l=o.prototype.querySelectorAll,u=o.prototype.getElementById,p=o.prototype.getElementsByClassName,d=o.prototype.getElementsByTagName,h=o.prototype.getElementsByName,m=o.prototype.elementFromPoint,f=o.prototype.caretRangeFromPoint;function _(e){return r!==e?e:n}function A(t){var n,o;if(!t||Q(t)||r!==this){const e=_(this);return c.call(e,t)}return null!==(o=null===(n=Pn.get(e))||void 0===n?void 0:n.querySelector(t))&&void 0!==o?o:null}function w(t){var n,o;if(!t||Q(t)||r!==this){const e=_(this);return l.call(e,t)}return null!==(o=null===(n=Pn.get(e))||void 0===n?void 0:n.querySelectorAll(t))&&void 0!==o?o:[]}o.prototype.caretRangeFromPoint=function(t,o){const r=m.call(n,t,o),i=f.call(n,t,o);return mn(r,e),i},o.prototype.createElement=function(t,n){return mn(i.call(this,t,n),e)},o.prototype.createTextNode=function(t){return mn(s.call(this,t),e)},o.prototype.createComment=function(t){return mn(a.call(this,t),e)},o.prototype.querySelector=A,o.prototype.querySelectorAll=w,o.prototype.getElementById=function(e){const t=_(this);if(G(e))return u.call(t,e);try{return A.call(this,`#${e}`)}catch(n){return u.call(t,e)}},o.prototype.getElementsByClassName=function(e){const t=_(this);if(G(e))return p.call(t,e);try{return w.call(this,`.${e}`)}catch(n){return p.call(t,e)}},o.prototype.getElementsByTagName=function(e){const t=_(this);if(Q(e)||G(e))return d.call(t,e);if(/^script|base$/i.test(e))return d.call(r,e);try{return w.call(this,e)}catch(n){return d.call(t,e)}},o.prototype.getElementsByName=function(e){const t=_(this);if(G(e))return h.call(t,e);try{return w.call(this,`[name=${e}]`)}catch(n){return h.call(t,e)}}}(e,t),function(e,t,n){const o=Bn.rawDocument,r=t.Document,i=t.document,s=(e,t)=>{const{enumerable:n}=Object.getOwnPropertyDescriptor(r.prototype,e)||{enumerable:!0};return{configurable:!0,enumerable:n,get:t}},l=()=>{const t={};return[["documentURI",()=>n.proxyLocation.href],["URL",()=>n.proxyLocation.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")],["microAppElement",()=>{var t;return null===(t=Pn.get(e))||void 0===t?void 0:t.container}],["__MICRO_APP_NAME__",()=>e]].forEach((e=>{t[e[0]]=s(e[0],e[1])})),Jt.forEach((e=>{t[e]=s(e,(()=>o[e]))})),Zt.forEach((e=>{t[e]=s(e,(()=>At(o[e],o,"DOCUMENT")))})),en.forEach((e=>{t[e]=s(e,(()=>o[e]))})),tn.forEach((e=>{t[e]=s(e,(()=>At(o[e],o,"DOCUMENT")))})),t};c(r.prototype,l()),Vt.forEach((e=>{a(i,e,{enumerable:!0,configurable:!0,get:()=>o[e],set:t=>{o[e]=t}})}))}(e,t,n),function(e,t){const{rawDocument:n,rawAddEventListener:o,rawRemoveEventListener:r}=Bn,i=new Map,s=new Map;let c=null,l=null;const u=t.Document,p=t.document;function d(e,t){return Ue.includes(e)?t:n}function h(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(d(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(d(e,this),e,s,n)},Object.getOwnPropertyNames(u.prototype).filter((e=>/^on/.test(e)&&!We.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)?h(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(d(t,p),t,(null==n?void 0:n.__MICRO_APP_BOUND_FUNCTION__)||n)})),i.clear())}}}(e,t)}function bn(e,t,n,o){!function(e,t,n){const o=Bn.rawRootElement,r=Bn.rawDocument,i=t.document,s=t.Node,c=t.Element,l=s.prototype.appendChild,u=s.prototype.insertBefore,p=s.prototype.replaceChild,d=s.prototype.removeChild,h=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 mn(t,e),y(t)?l.call(this,t):o.prototype.appendChild.call(g(this),t)},s.prototype.insertBefore=function(t,n){return mn(t,e),y(t)?u.call(this,t,n):o.prototype.insertBefore.call(g(this),t,n)},s.prototype.replaceChild=function(t,n){return mn(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)?d.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]=b(e[t])?e[t]:i.createTextNode(e[t]),y(e[t])&&(n=!0),t++;return n?h.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]=b(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 mn(n,e),y(n)?f.call(this,t,n):o.prototype.insertAdjacentElement.call(g(this),t,n)},s.prototype.cloneNode=function(t){return mn(_.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=>{v(t)&&mn(t,e)}))}}),a(s.prototype,"parentNode",{configurable:!0,enumerable:!0,get(){var t,n,o;H(e);const i=w.get.call(this);return S(i)&&(null===(t=Pn.get(e))||void 0===t?void 0:t.container)?(null===(o=(n=Vn.options).getRootElementParentNode)||void 0===o?void 0:o.call(n,this,e))||r.body:i}});const E=new Proxy(t.Image,{construct(t,n){const o=new t(...n);return mn(o,e),o}});a(t,"Image",{configurable:!0,writable:!0,value:E})}(e,n,o),function(e,t){const n=t.Element,o=n.prototype.setAttribute;n.prototype.setAttribute=function(t,n){(("src"===t||"srcset"===t)&&/^(img|script)$/i.test(this.tagName)||"href"===t&&/^link$/i.test(this.tagName))&&(n=T(n,e)),o.call(this,t,n)};const r=[[t.HTMLImageElement.prototype,"src"],[t.HTMLScriptElement.prototype,"src"],[t.HTMLLinkElement.prototype,"href"]];r.forEach((([t,n])=>{const{enumerable:o,configurable:r,get:i,set:s}=Object.getOwnPropertyDescriptor(t,n)||{enumerable:!0,configurable:!0};a(t,n,{enumerable:o,configurable:r,get:function(){return null==i?void 0:i.call(this)},set:function(t){null==s||s.call(this,T(t,e))}})}))}(t,n)}yn.activeCount=0;class En{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=Bn.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,Bt(e,n.location)),an(e,a,n.location,"prevent"),rn(e,t,n,r,o,i)}(e,t,this.microAppWindow,o),this.windowEffect=gn(e,this.microAppWindow,this),this.documentEffect=vn(e,this.microAppWindow,this),bn(e,t,this.microAppWindow,this),this.initStaticGlobalKeys(e,t,this.microAppWindow),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]))),Bn.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,defaultPage:t,disablePatchRequest:n}){this.active||(this.active=!0,this.initRouteState(t),this.removeHistoryListener=Tt(this.microAppWindow.__MICRO_APP_NAME__),this.microAppWindow.__MICRO_APP_BASE_ROUTE__=this.microAppWindow.__MICRO_APP_BASE_URL__=e,n||this.createIframeBase(),1==++Bn.activeSandbox&&(Ln(),jt()),++En.activeCount)}stop({umdMode:e,keepRouteState:t,destroy:n,clearData:o}){var r;this.active&&(this.recordAndReleaseEffect({clearData:o},!e||n),this.clearRouteState(t),null===(r=this.removeHistoryListener)||void 0===r||r.call(this),e&&!n||(this.deleteIframeElement(),this.escapeKeys.forEach((e=>{Reflect.deleteProperty(Bn.rawWindow,e)})),this.escapeKeys.clear()),0==--Bn.activeSandbox&&(Un(),Kt()),--En.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.__MICRO_APP_PROXY_WINDOW__=this.proxyWindow,n.__MICRO_APP_SANDBOX__=this,n.__MICRO_APP_SANDBOX_TYPE__="iframe",n.rawWindow=Bn.rawWindow,n.rawDocument=Bn.rawDocument,n.microApp=s(new lt(e),{removeDomScope:j,pureCreateElement:K,location:this.proxyLocation,router:qt})}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(),dt(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(),ut(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(),pt(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&&(Vn.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)}getSpecialProperties(e){var t;_(Vn.options.plugins)&&(this.commonActionForSpecialProperties(Vn.options.plugins.global),this.commonActionForSpecialProperties(null===(t=Vn.options.plugins.modules)||void 0===t?void 0:t[e]))}commonActionForSpecialProperties(e){if(i(e))for(const t of e)_(t)&&i(t.escapeProperties)&&(this.escapeProperties=this.escapeProperties.concat(t.escapeProperties))}initRouteState(e){cn(this.microAppWindow.__MICRO_APP_NAME__,this.microAppWindow.location,e)}clearRouteState(e){un(this.microAppWindow.__MICRO_APP_NAME__,this.microAppWindow.__MICRO_APP_URL__,this.microAppWindow.location,e)}setRouteInfoForKeepAliveApp(){ln(this.microAppWindow.__MICRO_APP_NAME__,this.microAppWindow.location)}removeRouteInfoForKeepAliveApp(){pn(this.microAppWindow.__MICRO_APP_NAME__)}patchStaticElement(e){hn(e,this.microAppWindow.__MICRO_APP_NAME__)}actionBeforeExecScripts(e){this.patchStaticElement(e)}}En.activeCount=0;const Pn=new Map;class Rn{constructor({name:e,url:t,container:n,scopecss:o,useSandbox:r,inline:i,iframe:s,ssrUrl:a,isPrefetch:c,prefetchLevel:l,routerMode:u}){this.state=ve.CREATED,this.keepAliveState=null,this.loadSourceLevel=0,this.umdHookMount=null,this.umdHookUnmount=null,this.umdMode=!1,this.sandBox=null,this.fiber=!1,Pn.set(e,this),this.name=e,this.url=t,this.useSandbox=r,this.scopecss=this.useSandbox&&o,this.iframe=null!=s&&s,this.inline=this.getInlineModeState(i),this.routerMode=u||De,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(ve.LOADING),ce.getInstance().run(this,rt)}onLoad(e,t,n,o,r){var i;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===(i=this.sandBox)||void 0===i||i.setPreRenderState(!0),this.mount({container:e,inline:this.inline,routerMode:o,baseroute:r||"",fiber:!0,defaultPage:t||"",disablePatchRequest:null!=n&&n})}}else z(this.container).mount(this)}onLoadError(e){this.loadSourceLevel=-1,this.isUnmounted()||(this.onerror(e),this.setAppState(ve.LOAD_FAILED))}mount({container:e,inline:t,routerMode:n,defaultPage:o,baseroute:r,disablePatchRequest:i,fiber:s}){if(2!==this.loadSourceLevel)return this.container=e,this.isPrerender=!1,this.setAppState(ve.LOADING);this.createSandbox(),this.setAppState(ve.BEFORE_MOUNT);const a=()=>{var a,c,l,p,h,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,qt.attachToURL(this.name),null===(l=this.sandBox)||void 0===l||l.setPreRenderState(!1);else{this.container=e,this.inline=this.getInlineModeState(t),this.fiber=s,this.routerMode=n;const a=()=>ie(this.container,this.name,be.BEFOREMOUNT);if(this.isPrerender?(null!==(p=this.preRenderEvents)&&void 0!==p?p:this.preRenderEvents=[]).push(a):a(),this.setAppState(ve.MOUNTING),q(this.container,this.source.html,!this.umdMode),null===(h=this.sandBox)||void 0===h||h.start({umdMode:this.umdMode,baseroute:r,defaultPage:o,disablePatchRequest:i}),this.umdMode){null===(_=this.sandBox)||void 0===_||_.rebuildEffectSnapshot();try{this.handleMounted(this.umdHookMount(Vn.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||$e(e,o)?r.push(o.code):r.push(ae(s,e.name)),i.push([s,o]),$e(e,o)&&(t.moduleCount=t.moduleCount?++t.moduleCount:1)):te(n,(()=>{et(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])=>{d(r.code)&&te(n,(()=>{et(o,e,r,t),!$e(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(Vn.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((e=>{C("An error occurred in window.mount \n",this.name,e),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(ve.MOUNTED),re(this.getMicroAppGlobalHook(Ee.ONMOUNT),this.name,Ee.ONMOUNT,Vn.getData(this.name,!0)),ie(this.container,this.name,be.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===ve.LOAD_FAILED,this.setAppState(ve.UNMOUNT);let i=null;try{i=null===(r=this.umdHookUnmount)||void 0===r?void 0:r.call(this,Vn.getData(this.name,!0))}catch(e){C("An error occurred in window.unmount \n",this.name,e)}se(this,"unmount"),re(this.getMicroAppGlobalHook(Ee.ONUNMOUNT),this.name,Ee.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}),ie(this.container,this.name,be.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),Pn.delete(this.name)}hiddenKeepAliveApp(e){var t,n;this.setKeepAliveState(Pe.KEEP_ALIVE_HIDDEN),se(this,"appstate-change",{appState:"afterhidden"}),ie(this.container,this.name,be.AFTERHIDDEN),this.routerMode!==Ie&&(null===(t=this.sandBox)||void 0===t||t.removeRouteInfoForKeepAliveApp()),2!==this.loadSourceLevel?z(this.container).unmount():(this.container=q(K("div"),this.container,!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(),se(this,"appstate-change",{appState:"beforeshow"}),ie(e,this.name,be.BEFORESHOW),this.setKeepAliveState(Pe.KEEP_ALIVE_SHOW),this.container=q(e,this.container,!1),this.routerMode!==Ie&&(null===(n=this.sandBox)||void 0===n||n.setRouteInfoForKeepAliveApp()),se(this,"appstate-change",{appState:"aftershow"}),ie(this.container,this.name,be.AFTERSHOW)}onerror(e){ie(this.container,this.name,be.ERROR,e)}createSandbox(){this.useSandbox&&!this.sandBox&&(this.iframe?this.sandBox=new En(this.name,this.url):this.sandBox=new yn(this.name,this.url))}setAppState(e){this.state=e}getAppState(){return this.state}setKeepAliveState(e){this.keepAliveState=e}getKeepAliveState(){return this.keepAliveState}isUnmounted(){return ve.UNMOUNT===this.state}isHidden(){return Pe.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?Bn.rawElementQuerySelector.call(this.container,e):null}querySelectorAll(e){return this.container?Bn.rawElementQuerySelectorAll.call(this.container,e):[]}getInlineModeState(e){var t;return null!==(t=this.iframe||e)&&void 0!==t&&t}}function Sn(e){var t,n;return null!==(n=null===(t=Pn.get(e))||void 0===t?void 0:t.iframe)&&void 0!==n&&n}const Cn=new WeakMap;function Mn(e){var t;return null!==(t=Cn.get(e))&&void 0!==t?t:e}function Nn(e,t){if(Cn.has(e))return Cn.get(e);if(P(e)){if(e.hasAttribute("exclude")){const t=document.createComment("style element with exclude attribute ignored by micro-app");return Cn.set(e,t),t}return t.scopecss&&!e.hasAttribute("ignore")?fe(e,t):e}if(E(e)){if(e.hasAttribute("exclude")||Ye(e.getAttribute("href"),t.name)){const t=document.createComment("link element with exclude attribute ignored by micro-app");return Cn.set(e,t),t}if(e.hasAttribute("ignore")||Je(e.getAttribute("href"),t.name)||e.href&&f(Vn.options.excludeAssetFilter)&&Vn.options.excludeAssetFilter(e.href))return e;const{address:n,linkInfo:o,replaceComment:r}=Ce(e,null,t,!0);if(n&&o){const r=function(e,t,n,o){const r=K("style"),i=()=>{Ne(t,e,r,n,n.appSpace[t.name].attrs),we(o)};return n.code?N(i):ae(e,t.name).then((e=>{n.code=e,i()})).catch((e=>{C(e,t.name),ye(o)})),r}(n,t,o,e);return Cn.set(e,r),r}return r?(Cn.set(e,r),r):e}if(R(e)){if(e.src&&f(Vn.options.excludeAssetFilter)&&Vn.options.excludeAssetFilter(e.src))return e;const{replaceComment:n,address:o,scriptInfo:r}=Xe(e,null,t,!0)||{};if(o&&r){const n=r.isExternal?function(e,t,n,o){const r=je(t,n)?K("script"):document.createComment("dynamic script extract by micro-app"),i=()=>we(o),s=()=>{const s=Object.getOwnPropertyDescriptor(Bn.rawDocument,"currentScript");s&&!s.configurable||Object.defineProperty(Bn.rawDocument,"currentScript",{value:o,configurable:!0}),et(e,t,n,i,r),!$e(t,n)&&i()};return n.code||$e(t,n)?N(s):ae(e,t.name).then((e=>{n.code=e,s()})).catch((e=>{C(e,t.name),ye(o)})),r}(o,t,r,e):function(e,t,n){const o=je(t,n)?K("script"):document.createComment("dynamic script extract by micro-app");return et(e,t,n,void 0,o),o}(o,t,r);return Cn.set(e,n),n}return n?(Cn.set(e,n),n):e}return e}function On(e,t,n,o,r){const i=Dn(n,o,e);if(i){if(!Sn(e.name)&&S(i)&&t!==Bn.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=Bn.rawParentNodeDesc.get.call(this);return S(o)&&e.container?(null===(n=(t=Vn.options).getRootElementParentNode)||void 0===n?void 0:n.call(t,this,e.name))||document.body:o}},__MICRO_APP_HAS_DPN__:{configurable:!0,get:()=>!0}})}return r&&!i.contains(r)?Bn.rawAppendChild.call(i,o):t!==Bn.rawRemoveChild||i.contains(o)?In(t,i,o,r):n.contains(o)?t.call(n,o):o}return In(t,n,o,r)}function Dn(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 In(e,t,n,o){return(r=e)===Bn.rawAppend||r===Bn.rawPrepend?e.call(t,n):e.call(t,n,o);var r}function xn(e,t,n,o){const r=$();if(b(t)&&!t.__PURE_ELEMENT__&&(t.__MICRO_APP_NAME__||r)){t.__MICRO_APP_NAME__=t.__MICRO_APP_NAME__||r;const i=Pn.get(t.__MICRO_APP_NAME__);if(null==i?void 0:i.container)return function(e,t){v(t)&&(/^(img|script)$/i.test(t.tagName)?(t.hasAttribute("src")&&Bn.rawSetAttribute.call(t,"src",T(t.getAttribute("src"),e.url)),t.hasAttribute("srcset")&&Bn.rawSetAttribute.call(t,"srcset",T(t.getAttribute("srcset"),e.url))):/^link$/i.test(t.tagName)&&t.hasAttribute("href")&&Bn.rawSetAttribute.call(t,"href",T(t.getAttribute("href"),e.url)))}(i,t),On(i,o,e,Nn(t,i),n&&Mn(n))}return o===Bn.rawAppend||o===Bn.rawPrepend?o.call(e,t):o.call(e,t,n)}function Ln(){!function(){const e=Bn.rawDocument,t=Bn.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=$();return s&&t&&!Q(t)&&e===i?null!==(r=null===(o=Pn.get(s))||void 0===o?void 0:o.querySelector(t))&&void 0!==r?r:null:Bn.rawQuerySelector.call(i,t)}function r(t){var o,r;const i=n(this),s=$();return s&&t&&!Q(t)&&e===i?null!==(r=null===(o=Pn.get(s))||void 0===o?void 0:o.querySelectorAll(t))&&void 0!==r?r:[]:Bn.rawQuerySelectorAll.call(i,t)}t.prototype.createElement=function(e,t){return Tn(Bn.rawCreateElement.call(n(this),e,t))},t.prototype.createElementNS=function(e,t,o){return Tn(Bn.rawCreateElementNS.call(n(this),e,t,o))},t.prototype.createDocumentFragment=function(){return Tn(Bn.rawCreateDocumentFragment.call(n(this)))},t.prototype.createComment=function(e){return Tn(Bn.rawCreateComment.call(n(this),e))},t.prototype.querySelector=o,t.prototype.querySelectorAll=r,t.prototype.getElementById=function(e){const t=n(this);if(!$()||G(e))return Bn.rawGetElementById.call(t,e);try{return o.call(t,`#${e}`)}catch(n){return Bn.rawGetElementById.call(t,e)}},t.prototype.getElementsByClassName=function(e){const t=n(this);if(!$()||G(e))return Bn.rawGetElementsByClassName.call(t,e);try{return r.call(t,`.${e}`)}catch(n){return Bn.rawGetElementsByClassName.call(t,e)}},t.prototype.getElementsByTagName=function(e){var t;const o=n(this),i=$();if(!i||Q(e)||G(e)||!(null===(t=Pn.get(i))||void 0===t?void 0:t.inline)&&/^script$/i.test(e))return Bn.rawGetElementsByTagName.call(o,e);try{return r.call(o,e)}catch(t){return Bn.rawGetElementsByTagName.call(o,e)}},t.prototype.getElementsByName=function(e){const t=n(this);if(!$()||G(e))return Bn.rawGetElementsByName.call(t,e);try{return r.call(t,`[name=${e}]`)}catch(n){return Bn.rawGetElementsByName.call(t,e)}}}();const e=Bn.rawRootElement,t=Bn.rawRootNode;function n(e){const t=$();if((e===document.body||e===document.head)&&t){const n=Pn.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 xn(this,e,null,Bn.rawAppendChild)},e.prototype.insertBefore=function(e,t){return xn(this,e,t,Bn.rawInsertBefore)},e.prototype.replaceChild=function(e,t){return xn(this,e,t,Bn.rawReplaceChild)},e.prototype.append=function(...e){let t=0;for(;t<e.length;){let n=e[t];n=b(n)?n:Bn.rawCreateTextNode.call(Bn.rawDocument,n),xn(this,Tn(n),null,Bn.rawAppend),t++}},e.prototype.prepend=function(...e){let t=e.length;for(;t>0;){let n=e[t-1];n=b(n)?n:Bn.rawCreateTextNode.call(Bn.rawDocument,n),xn(this,Tn(n),null,Bn.rawPrepend),t--}},e.prototype.removeChild=function(e){if(null==e?void 0:e.__MICRO_APP_NAME__){const t=Pn.get(e.__MICRO_APP_NAME__);if(null==t?void 0:t.container)return On(t,Bn.rawRemoveChild,this,Mn(e));try{return Bn.rawRemoveChild.call(this,e)}catch(t){return(null==e?void 0:e.parentNode)&&Bn.rawRemoveChild.call(e.parentNode,e)}}return Bn.rawRemoveChild.call(this,e)},e.prototype.insertAdjacentElement=function(e,t){var n;if((null==t?void 0:t.__MICRO_APP_NAME__)&&v(t)){const o=Pn.get(t.__MICRO_APP_NAME__);if(null==o?void 0:o.container){const r=Nn(t,o);if(!v(r))return t;const i=null!==(n=Dn(this,r,o))&&void 0!==n?n:this;return Bn.rawInsertAdjacentElement.call(i,e,r)}}return Bn.rawInsertAdjacentElement.call(this,e,t)},e.prototype.cloneNode=function(e){const t=Bn.rawCloneNode.call(this,e);return this.__MICRO_APP_NAME__&&(t.__MICRO_APP_NAME__=this.__MICRO_APP_NAME__),t},e.prototype.querySelector=function(e){var t;const o=null!==(t=n(this))&&void 0!==t?t:this;return Bn.rawElementQuerySelector.call(o,e)},e.prototype.querySelectorAll=function(e){var t;const o=null!==(t=n(this))&&void 0!==t?t:this;return Bn.rawElementQuerySelectorAll.call(o,e)},e.prototype.setAttribute=function(e,t){const n=this.__MICRO_APP_NAME__||$();if(n&&Pn.has(n)&&(("src"===e||"srcset"===e)&&/^(img|script|video|audio|source|embed)$/i.test(this.tagName)||"href"===e&&/^link$/i.test(this.tagName))){t=T(t,Pn.get(n).url)}Bn.rawSetAttribute.call(this,e,t)},a(e.prototype,"innerHTML",{configurable:!0,enumerable:!0,get(){return Bn.rawInnerHTMLDesc.get.call(this)},set(e){Bn.rawInnerHTMLDesc.set.call(this,e);const t=$();Array.from(this.children).forEach((e=>{v(e)&&t&&(e.__MICRO_APP_NAME__=t)}))}}),a(t.prototype,"parentNode",{configurable:!0,enumerable:!0,get(){var e,t,n;const o=$();if(o&&this===Bn.rawDocument.firstElementChild){const r=null===(n=null===(t=null===(e=Pn.get(o))||void 0===e?void 0:e.sandBox)||void 0===t?void 0:t.proxyWindow)||void 0===n?void 0:n.document;if(r)return r}return Bn.rawParentNodeDesc.get.call(this)}})}function Tn(e){const t=$();return t&&(e.__MICRO_APP_NAME__=t),e}function Un(){j(),function(){const e=Bn.rawRootDocument;e.prototype.createElement=Bn.rawCreateElement,e.prototype.createElementNS=Bn.rawCreateElementNS,e.prototype.createDocumentFragment=Bn.rawCreateDocumentFragment,e.prototype.querySelector=Bn.rawQuerySelector,e.prototype.querySelectorAll=Bn.rawQuerySelectorAll,e.prototype.getElementById=Bn.rawGetElementById,e.prototype.getElementsByClassName=Bn.rawGetElementsByClassName,e.prototype.getElementsByTagName=Bn.rawGetElementsByTagName,e.prototype.getElementsByName=Bn.rawGetElementsByName}();const e=Bn.rawRootElement,t=Bn.rawRootNode;e.prototype.appendChild=Bn.rawAppendChild,e.prototype.insertBefore=Bn.rawInsertBefore,e.prototype.replaceChild=Bn.rawReplaceChild,e.prototype.removeChild=Bn.rawRemoveChild,e.prototype.append=Bn.rawAppend,e.prototype.prepend=Bn.rawPrepend,e.prototype.cloneNode=Bn.rawCloneNode,e.prototype.querySelector=Bn.rawElementQuerySelector,e.prototype.querySelectorAll=Bn.rawElementQuerySelectorAll,e.prototype.setAttribute=Bn.rawSetAttribute,a(e.prototype,"innerHTML",Bn.rawInnerHTMLDesc),a(t.prototype,"parentNode",Bn.rawParentNodeDesc)}let Wn=!1;const Bn={activeSandbox:0};function kn(){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,d=o.prototype.append,h=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,v=n.prototype.createElementNS,b=n.prototype.createDocumentFragment,E=n.prototype.createTextNode,P=n.prototype.createComment,R=n.prototype.querySelector,S=n.prototype.querySelectorAll,C=n.prototype.getElementById,M=n.prototype.getElementsByClassName,N=n.prototype.getElementsByTagName,O=n.prototype.getElementsByName,D=new Proxy(Image,{construct(e,t){const n=new e(...t),o=$();return o&&(n.__MICRO_APP_NAME__=o),n}}),I=e.setInterval,x=e.setTimeout,L=e.clearInterval,T=e.clearTimeout,U=e.history.pushState,W=e.history.replaceState,B=i.prototype.addEventListener,k=i.prototype.removeEventListener,F=i.prototype.dispatchEvent;window.__MICRO_APP_BASE_APPLICATION__=!0,s(Bn,{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:d,rawPrepend:h,rawCloneNode:m,rawElementQuerySelector:f,rawElementQuerySelectorAll:_,rawInsertAdjacentElement:A,rawInnerHTMLDesc:w,rawParentNodeDesc:y,rawCreateElement:g,rawCreateElementNS:v,rawCreateDocumentFragment:b,rawCreateTextNode:E,rawCreateComment:P,rawQuerySelector:R,rawQuerySelectorAll:S,rawGetElementById:C,rawGetElementsByClassName:M,rawGetElementsByTagName:N,rawGetElementsByName:O,ImageProxy:D,rawSetInterval:I,rawSetTimeout:x,rawClearInterval:L,rawClearTimeout:T,rawPushState:U,rawReplaceState:W,rawAddEventListener:B,rawRemoveEventListener:k,rawDispatchEvent:F}),function(){if(!Wn){Wn=!0;const e=K("style");Bn.rawSetAttribute.call(e,"type","text/css"),e.textContent=`\n${Vn.tagName}, micro-app-body { display: block; } \nmicro-app-head { display: none; }`,Bn.rawDocument.head.appendChild(e)}}()}}function Fn(e){class n extends(function(){var e;return(null===(e=window.rawWindow)||void 0===e?void 0:e.HTMLElement)||window.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=()=>{this.isWaiting=!1;const e=x(this.getAttribute("name")),t=I(this.getAttribute("url"),this.appName);if(this.legalAttribute("name",e)&&this.legalAttribute("url",t)){const n=Pn.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)&&(ie(this,this.appName,be.CREATED),t&&this.handleConnected())}))}disconnectedCallback(){this.connectStateMap.set(this.connectedCount,!1),this.handleDisconnected()}reload(e){return new Promise((t=>{const n=()=>{this.removeEventListener(be.MOUNTED,n),this.removeEventListener(be.AFTERSHOW,n),t(!0)};this.addEventListener(be.MOUNTED,n),this.addEventListener(be.AFTERSHOW,n),this.handleDisconnected(e,(()=>{this.handleConnected()}))}))}handleDisconnected(e=!1,t){const n=Pn.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===ge.NAME?"appName":"appUrl"]!==n)if(e!==ge.URL||this.appUrl&&this.connectStateMap.get(this.connectedCount))if(e!==ge.NAME||this.appName&&this.connectStateMap.get(this.connectedCount))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&&(Vn.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),Pn.has(this.appName)){const e=Pn.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!(!d(t)||!t)||(C(`unexpected attribute ${e}, please check again`,this.appName),!1)}handleCreateApp(){const e=()=>{var e;return new Rn({name:this.appName,url:this.appUrl,container:null!==(e=this.shadowRoot)&&void 0!==e?e:this,scopecss:this.useScopecss(),useSandbox:this.useSandbox(),inline:this.getDisposeResult("inline"),iframe:this.getDisposeResult("iframe"),ssrUrl:this.ssrUrl,routerMode:this.getMemoryRouterMode()})},t=Pn.get(this.appName);t?t.isPrerender?this.unmount(!0,e):(t.actionsForCompletelyDestroy(),e()):e()}handleMount(e){e.isPrefetch=!1,e.setAppState(ve.BEFORE_MOUNT),N((()=>this.mount(e)))}mount(e){var t;e.mount({container:null!==(t=this.shadowRoot)&&void 0!==t?t:this,inline:this.getDisposeResult("inline"),routerMode:this.getMemoryRouterMode(),baseroute:this.getBaseRouteCompatible(),defaultPage:this.getDefaultPage(),disablePatchRequest:this.getDisposeResult("disable-patch-request"),fiber:this.getDisposeResult("fiber")})}unmount(e,t){const n=Pn.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=Pn.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)||!!Vn.options[e])&&this.compatibleDisableProperties(e)}compatibleProperties(e){return"disable-scopecss"===e?this.hasAttribute("disable-scopecss")||this.hasAttribute("disableScopecss"):"disable-sandbox"===e?this.hasAttribute("disable-sandbox")||this.hasAttribute("disableSandbox"):this.hasAttribute(e)}compatibleDisableProperties(e){return"disable-scopecss"===e?"false"!==this.getAttribute("disable-scopecss")&&"false"!==this.getAttribute("disableScopecss"):"disable-sandbox"===e?"false"!==this.getAttribute("disable-sandbox")&&"false"!==this.getAttribute("disableSandbox"):"false"!==this.getAttribute(e)}useScopecss(){return!(this.getDisposeResult("disable-scopecss")||this.getDisposeResult("shadowDOM"))}useSandbox(){return!this.getDisposeResult("disable-sandbox")}sameCoreOptions(e){return e.scopecss===this.useScopecss()&&e.useSandbox===this.useSandbox()&&e.iframe===this.getDisposeResult("iframe")}getBaseRouteCompatible(){var e,t;return null!==(t=null!==(e=this.getAttribute("baseroute"))&&void 0!==e?e:this.getAttribute("baseurl"))&&void 0!==t?t:""}getDestroyCompatibleResult(){return this.getDisposeResult("destroy")||this.getDisposeResult("destory")}getKeepAliveModeResult(){return this.getDisposeResult("keep-alive")&&!this.getDestroyCompatibleResult()}updateSsrUrl(e){if(this.getDisposeResult("ssr"))if(this.getDisposeResult("disable-memory-router")||this.getDisposeResult("disableSandbox")){const t=Bn.rawWindow.location;this.ssrUrl=T(t.pathname+t.search,e)}else{let t=function(e,t){const n=Nt(e);if(!n)return"";const o=O(n,t);return o.origin+o.pathname+o.search}(this.appName,e);const n=this.getDefaultPage();if(!t&&n){const o=O(n,e);t=o.origin+o.pathname+o.search}this.ssrUrl=t}else this.ssrUrl&&(this.ssrUrl="")}getDefaultPage(){return qt.getDefaultPage(this.appName)||this.getAttribute("default-page")||this.getAttribute("defaultPage")||""}getMemoryRouterMode(){return Lt(this.getAttribute("router-mode"),this)}setAttribute(e,t){if("data"===e)if(_(t)){const e={};Object.getOwnPropertyNames(t).forEach((n=>{d(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 Bn.rawSetAttribute.call(this,e,t)}set data(e){this.appName?Vn.setData(this.appName,e):this.cacheData=e}get data(){return this.appName?Vn.getData(this.appName,!0):this.cacheData?this.cacheData:null}}Bn.rawWindow.customElements.define(e,n)}function Hn(e,t){if(!n)return C("preFetch is only supported in browser environment");W((()=>{const n=m(t)?t:Vn.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&&!Pn.has(e.name)){const c=new Rn({name:e.name,url:e.url,isPrefetch:!0,scopecss:!(null!==(o=null!==(n=e["disable-scopecss"])&&void 0!==n?n:e.disableScopecss)&&void 0!==o?o:Vn.options["disable-scopecss"]),useSandbox:!(null!==(i=null!==(r=e["disable-sandbox"])&&void 0!==r?r:e.disableSandbox)&&void 0!==i?i:Vn.options["disable-sandbox"]),inline:null!==(s=e.inline)&&void 0!==s?s:Vn.options.inline,iframe:null!==(a=e.iframe)&&void 0!==a?a:Vn.options.iframe,prefetchLevel:e.level&&Oe.includes(e.level)?e.level:Vn.options.prefetchLevel&&Oe.includes(Vn.options.prefetchLevel)?Vn.options.prefetchLevel:2}),l=c.onLoad,u=c.onLoadError;c.onLoad=n=>{t(),l.call(c,n,e["default-page"],e["disable-patch-request"],Lt(e["router-mode"]),e.baseroute)},c.onLoadError=(...e)=>{t(),u.call(c,...e)}}else t();else t()}));var e}))),Promise.resolve())}(e)}),m(n)?n:3e3)}))}function $n(e,t,n){if(i(e)){const o=e.filter((e=>d(e)&&e.includes(`.${t}`)&&!n.hasInfo(e)));U(o.map((e=>ae(e))),(e=>{const r=o[e.index];"js"===t?n.hasInfo(r)||n.setInfo(r,{code:e.data,isExternal:!1,appSpace:{}}):n.hasInfo(r)||n.setInfo(r,{code:e.data,appSpace:{}})}),(e=>{C(e)}))}}function jn({excludeHiddenApp:e=!1,excludePreRender:t=!1}={}){const n=[];return Pn.forEach(((o,r)=>{o.isUnmounted()||o.isPrefetch&&(!o.isPrerender||t)||e&&o.isHidden()||n.push(r)})),n}function Kn(){return Array.from(Pn.keys())}function qn(e,t){const n=Pn.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(be.UNMOUNT,r),e.removeEventListener(be.AFTERHIDDEN,i),o(!0)},i=()=>{e.removeEventListener(be.UNMOUNT,r),e.removeEventListener(be.AFTERHIDDEN,i),o(!0)};if(e.addEventListener(be.UNMOUNT,r),e.addEventListener(be.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"),d(t)&&e.setAttribute("destroy",t),d(n)&&e.setAttribute("destory",n)}else if((null==t?void 0:t.clearAliveState)&&e.hasAttribute("keep-alive")){const n=e.getAttribute("keep-alive");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),d(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),d(n)&&e.setAttribute("clear-data",n)}}else M(`app ${e} does not exist`),o(!1)}))}function Gn(e){return Array.from(Pn.keys()).reduce(((t,n)=>t.then((()=>qn(n,e)))),Promise.resolve(!0))}function Qn(e,t){return new Promise((n=>{const o=Pn.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 zn(e){return new Promise((t=>{if(!_(e))return C("renderApp options must be an object");const n=v(e.container)?e.container:d(e.container)?document.querySelector(e.container):null;if(!v(n))return C("Target container is not a DOM element.");const o=K(Vn.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 be&&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(be.MOUNTED,r),o.removeEventListener(be.ERROR,i)};o.addEventListener(be.MOUNTED,r),o.addEventListener(be.ERROR,i),n.appendChild(o)}))}class Xn extends ct{constructor(){super(...arguments),this.tagName="micro-app",this.hasInit=!1,this.options={},this.router=qt,this.preFetch=Hn,this.unmountApp=qn,this.unmountAllApps=Gn,this.getActiveApps=jn,this.getAllApps=Kn,this.reload=Qn,this.renderApp=zn}start(e){var t,o,r;if(!n||!window.customElements)return C("micro-app is not supported in this environment");if(this.hasInit)return C("microApp.start executed repeatedly");if(this.hasInit=!0,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(kn(),Bn.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&&Hn(e.preFetchApps),e.globalAssets&&(_(r=e.globalAssets)&&W((()=>{$n(r.js,"js",Se.script),$n(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])}}Fn(this.tagName)}}const Vn=new Xn;e.EventCenterForMicroApp=lt,e.MicroApp=Xn,e.default=Vn,e.getActiveApps=jn,e.getAllApps=Kn,e.preFetch=Hn,e.pureCreateElement=K,e.reload=Qn,e.removeDomScope=j,e.renderApp=zn,e.unmountAllApps=Gn,e.unmountApp=qn,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-rc.21",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.toString,u=Object.prototype.hasOwnProperty,p=e=>l.call(e);function h(e){return void 0===e}function d(e){return null===e}function m(e){return"string"==typeof e}function f(e){return"boolean"==typeof e}function _(e){return"number"==typeof e}function g(e){return"function"==typeof e}function w(e){return"[object Object]"===p(e)}function A(e){return"[object Promise]"===p(e)}function y(e){var t;if(g(e)){const n=e.toString();return(null===(t=e.prototype)||void 0===t?void 0:t.constructor)===e&&Object.getOwnPropertyNames(e.prototype).length>1||/^function\s+[A-Z]/.test(n)||/^class\s+/.test(n)}return!1}function b(e){var t;return e instanceof URL||!!(null===(t=e)||void 0===t?void 0:t.href)}function v(e){var t;return e instanceof Element||m(null===(t=e)||void 0===t?void 0:t.tagName)}function E(e){var t;return e instanceof Node||_(null===(t=e)||void 0===t?void 0:t.nodeType)}function P(e){return"[object HTMLStyleElement]"===p(e)}function R(e){return"[object HTMLScriptElement]"===p(e)}function S(e){return"[object DocumentFragment]"===p(e)}function M(e){return v(e)&&"MICRO-APP-BODY"===e.tagName.toUpperCase()}function C(e,t){try{return x(e).pathname.split(".").pop()===t}catch(n){return!1}}function N(e,t,n){if(null==e)throw new TypeError("includes target is null or undefined");const o=Object(e),r=parseInt(o.length,10)||0;if(0===r)return!1;n=parseInt(n,10)||0;let i=Math.max(n>=0?n:r+n,0);for(;i<r;){if(t===o[i]||t!=t&&o[i]!=o[i])return!0;i++}return!1}function O(e,t=null,...n){const o=t&&m(t)?` app ${t}:`:"";m(e)?console.error(`[micro-app]${o} ${e}`,...n):console.error(`[micro-app]${o}`,e,...n)}function D(e,t=null,...n){const o=t&&m(t)?` app ${t}:`:"";m(e)?console.warn(`[micro-app]${o} ${e}`,...n):console.warn(`[micro-app]${o}`,e,...n)}function I(e,...t){Promise.resolve().then(e.bind(null,...t))}const x=function(){class e extends URL{}return(t,n)=>n?new e(""+t,n):new e(""+t)}();function T(e){return e.startsWith("//")?`${o.location.protocol}${e}`:e}function L(e,t=null){if(!m(e)||!e)return"";try{const{origin:t,pathname:n,search:o}=x(T(e),(window.rawWindow||window).location.href),r=`${t}${n}${o}`;return/^https?:\/\//.test(r)?r:""}catch(n){return O(n,t),""}}function W(e){return m(e)&&e?e.replace(/(^\d+)|([^\w\d-_])/gi,""):""}function U(e){const{origin:t,pathname:n}=x(e);if(/\.(\w+)$/.test(n)){const e=`${t}${n}`.split("/");return e.pop(),e.join("/")+"/"}return`${t}${n}/`.replace(/\/\/$/,"/")}function B(e,t){return!e||/^((((ht|f)tps?)|file):)?\/\//.test(e)||/^(data|blob):/.test(e)?e:x(e,U(T(t))).toString()}function k(e,t,n,o){let r=0;function i(){++r===e.length&&o&&o()}e.forEach(((e,o)=>{A(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 H=o.requestIdleCallback||function(e){const t=Date.now();return setTimeout((function(){e({didTimeout:!1,timeRemaining:()=>Math.max(0,50-(Date.now()-t))})}),1)};function F(e){return new Promise((t=>{H((()=>{e(t)}))}))}let j=null;function $(e){j=e}function K(){return j}function q(e){j===e||Y()||($(e),I((()=>{$(null)})))}let G=null;function Q(e){G=e}function z(){return G}function X(e){G===e||Y()||(Q(e),I((()=>{Q(null)})))}let V=!1;function Y(){return V}function J(e){!1!==e?($(null),Q(null),e&&!V&&(V=!0,I((()=>{V=!1})))):V=!1}function Z(e,t){const n=(window.rawDocument||document).createElement(e,t);return n.__MICRO_APP_NAME__&&delete n.__MICRO_APP_NAME__,n.__PURE_ELEMENT__=!0,n}function ee(e){return!e||/(^\d)|([^\w\d-_\u4e00-\u9fa5])/gi.test(e)}function te(e){return/^body$/i.test(e)||/^head$/i.test(e)||/^html$/i.test(e)||/^title$/i.test(e)||/^:root$/i.test(e)}function ne(e){return function(e){return"undefined"!=typeof ShadowRoot&&e instanceof ShadowRoot}(e)?e.host:e}function oe(e){return e?e.replace(/^\s+|\s+$/g,""):""}function re(){return navigator.userAgent.indexOf("Firefox")>-1}function ie(e){const t={},n=e.split("&");for(const o of n){const e=o.indexOf("="),n=e<0?o:o.slice(0,e),r=e<0?null:o.slice(e+1);if(n in t){let e=t[n];i(e)||(e=t[n]=[e]),e.push(r)}else t[n]=r}return t}function se(e){let t="";for(const n in e){const o=e[n];if(d(o))t+=(t.length?"&":"")+n;else{(i(o)?o:[o]).forEach((e=>{h(e)||(t+=(t.length?"&":"")+n,d(e)||(t+="="+e))}))}}return t}function ae(){const e=new Set;return{add:function(t){return e.add(t),()=>!!e.has(t)&&e.delete(t)},list:()=>e}}function ce(e){const t=e.attributes,n=new Map;for(let o=0;o<t.length;o++)n.set(t[o].name,t[o].value);return n}function le(e,t){e?e.push((()=>F((e=>{t(),e()})))):t()}function ue(e){return(null==e?void 0:e.reduce(((e,t)=>e.then(t)),Promise.resolve()))||null}function pe(e){return e.startsWith("inline-")}function he(e,t,n,...o){try{g(e)&&e(...o)}catch(r){O(`An error occurred in app ${t} window.${n} \n`,null,r)}}function de(e,t){if(null==e)return!1;if(!g(t))throw new TypeError("Right-hand side of 'instanceof' is not callable");if("number"==typeof e||"string"==typeof e||"boolean"==typeof e)return!1;let n=Object.getPrototypeOf(e);for(;n;){if(n===t.prototype)return!0;n=Object.getPrototypeOf(n)}return!1}const me=["mounted","unmount"];function fe(e,t){return me.includes(e)?`${e}-${t}`:e}function _e(e,t,n,o){var r;if(!e)return D(`element does not exist in lifecycle ${n}`,t);e=ne(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),g(null===(r=Mo.options.lifeCycles)||void 0===r?void 0:r[n])&&Mo.options.lifeCycles[n](a,t),e.dispatchEvent(a)}function ge(e,t,n={}){var o;const r=new CustomEvent(fe(t,e.name),{detail:n});null===(o=e.sandBox)||void 0===o||o.microAppWindow.dispatchEvent(r)}function we(e,t=null,n={}){return J(),g(Mo.options.fetch)?Mo.options.fetch(e,n,t):window.fetch(e,n).then((e=>e.text()))}class Ae{static getInstance(){return this.instance||(this.instance=new Ae),this.instance}run(e,t){const n=e.name,o=e.ssrUrl||e.url;(C(o,"js")?Promise.resolve(`<micro-app-head><script src='${o}'><\/script></micro-app-head><micro-app-body></micro-app-body>`):we(o,n,{cache:"no-cache"})).then((r=>{if(!r){const t="html is empty, please check in detail";return e.onerror(new Error(t)),O(t,n)}r=this.formatHTML(o,r,n),t(r,e)})).catch((t=>{O(`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,Mo.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)=>w(n)&&g(n.processHtml)?n.processHtml(t,e):t),t):t}}const ye=/(^|\s+)(html|:root)(?=[\s>~[.#:]+|$)/,be=/(^|\s+)((html[\s>~]+body)|body)(?=[\s>~[.#:]+|$)/;class ve{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"),this.containerRule=this.createMatcherForRuleWithChildRule(/^@container *([^{]+)/,"@container")}exec(e,t,n,o){return this.cssText=e,this.prefix=t,this.baseURI=n,this.linkPath=o||"",this.matchRules(),re()?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):this.printError("selector missing",this.linkPath)}formatSelector(e){const t=this.commonMatch(/^[^{]+/,e);if(!t)return!1;const n={};return t[0].replace(/\[([^\]=]+)(?:=([^\]]+))?\]/g,((e,t,o)=>{const r=`__mock_${t}Value__`;return n[r]=o,e.replace(o,r)})).replace(/(^|,[\n\s]*)([^,]+)/g,((e,t,o)=>((o=(o=oe(o)).replace(/\[[^\]=]+(?:=([^\]]+))?\]/g,((e,t)=>n[t]?e.replace(t,n[t]):e)))&&!(this.scopecssDisableNextLine||this.scopecssDisable&&(!this.scopecssDisableSelectors.length||this.scopecssDisableSelectors.includes(o))||ye.test(o))&&(o=be.test(o)?o.replace(be,this.prefix+" micro-app-body"):this.prefix+" "+o),t+o)))}styleDeclarations(){return this.matchOpenBrace()?(this.matchAllDeclarations(),!!this.matchCloseBrace()||this.printError("Declaration missing '}'",this.linkPath)):this.printError("Declaration missing '{'",this.linkPath)}matchAllDeclarations(e=0){let t=this.commonMatch(/^(?:url\(["']?(?:[^)"'}]+)["']?\)|[^{}/])*/,!0)[0];if(t&&(this.scopecssDisableNextLine||this.scopecssDisable&&!this.scopecssDisableSelectors.length||(t=t.replace(/url\((["']?)(.*?)\1\)/gm,((e,t,n)=>/^((data|blob):|#|%23)/.test(n)||/^(https?:)?\/\//.test(n)?e:(/^((\.\.?\/)|[^/])/.test(n)&&this.linkPath&&(this.baseURI=function(e){const t=e.split("/");return t.pop(),T(t.join("/")+"/")}(this.linkPath)),`url("${B(n,this.baseURI)}")`)))),this.recordResult(t)),this.scopecssDisableNextLine=!1,this.cssText.length){if("/"===this.cssText.charAt(0))"*"===this.cssText.charAt(1)?this.matchComments():this.commonMatch(/\/+/);else if("{"===this.cssText.charAt(0))this.matchOpenBrace(),e++;else if("}"===this.cssText.charAt(0)){if(e<1)return;this.matchCloseBrace(),e--}return this.matchAllDeclarations(e)}}matchAtRule(){return"@"===this.cssText[0]&&(this.scopecssDisableNextLine=!1,this.keyframesRule()||this.mediaRule()||this.customMediaRule()||this.supportsRule()||this.importRule()||this.charsetRule()||this.namespaceRule()||this.containerRule()||this.documentRule()||this.pageRule()||this.hostRule()||this.fontFaceRule()||this.layerRule())}keyframesRule(){if(!this.commonMatch(/^@([-\w]+)?keyframes\s*/))return!1;if(!this.commonMatch(/^[^{]+/))return this.printError("@keyframes missing name",this.linkPath);if(this.matchComments(),!this.matchOpenBrace())return this.printError("@keyframes missing '{'",this.linkPath);for(this.matchComments();this.keyframeRule();)this.matchComments();return this.matchCloseBrace()?(this.matchLeadingSpaces(),!0):this.printError("@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")}layerRule(){return!!this.commonMatch(/^@layer\s*([^{;]+)/)&&(this.matchOpenBrace()?(this.matchComments(),this.matchRules(),this.matchCloseBrace()?(this.matchLeadingSpaces(),!0):this.printError("@layer missing '}'",this.linkPath)):!!this.commonMatch(/^[;]+/))}createMatcherForRuleWithChildRule(e,t){return()=>!!this.commonMatch(e)&&(this.matchOpenBrace()?(this.matchComments(),this.matchRules(),this.matchCloseBrace()?(this.matchLeadingSpaces(),!0):this.printError(`${t} missing '}'`,this.linkPath)):this.printError(`${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):this.printError(`@${e} missing '}'`,this.linkPath)):this.printError(`@${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 this.printError("End of comment missing",this.linkPath);let t=this.cssText.slice(2,e-2);if(this.recordResult(`/*${t}*/`),t=oe(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(oe(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(/^}\s*/)}matchLeadingSpaces(){this.commonMatch(/^\s*/)}recordResult(e){re()?this.result+=encodeURIComponent(e):this.result+=e}printError(e,t){this.cssText.length&&function(e,t){e=t?`${t} ${e}`:e;const n=new Error(e);throw n.reason=e,t&&(n.filename=t),n}(e,t)}}function Ee(e,t,n,o,r){if(!e.__MICRO_APP_HAS_SCOPED__){e.__MICRO_APP_HAS_SCOPED__=!0;let s=null;try{s=Pe.exec(e.textContent,n,o,r),Pe.reset()}catch(i){Pe.reset(),O("An error occurred while parsing CSS:\n",t,i)}s&&(e.textContent=s)}}let Pe;function Re(e,t,n){if(t.scopecss){const o=Se(t.name);Pe||(Pe=new ve);const r=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");if(e.textContent){Ee(e,t.name,o,t.url,n);const i=new MutationObserver((()=>{const s=r(o),a=e.textContent&&new RegExp(s).test(e.textContent);i.disconnect(),a||(e.__MICRO_APP_HAS_SCOPED__=!1,Re(e,t,n))}));i.observe(e,{childList:!0,characterData:!0})}else{const r=new MutationObserver((function(){r.disconnect(),e.textContent&&!e.hasAttribute("data-styled")&&Ee(e,t.name,o,t.url,n)}));r.observe(e,{childList:!0})}}return e}function Se(e,t=!1){const n=t?"\\":"";return`${Mo.tagName}${n}[name=${e}${n}]`}function Me(e,t){Object.defineProperties(e,{currentTarget:{get:()=>t},srcElement:{get:()=>t},target:{get:()=>t}})}function Ce(e){const t=new CustomEvent("load");Me(t,e),g(e.onload)?e.onload(t):e.dispatchEvent(t)}function Ne(e){const t=new CustomEvent("error");Me(t,e),g(e.onerror)?e.onerror(t):e.dispatchEvent(t)}var Oe,De,Ie,xe,Te,Le,We=function(){const e=new Map,t=new Map;function n(e){return{setInfo(t,n){e.set(t,n)},getInfo(t){var n;return null!==(n=e.get(t))&&void 0!==n?n:null},hasInfo:t=>e.has(t),deleteInfo:t=>e.delete(t)}}return{link:n(e),script:Object.assign(Object.assign({},n(t)),{deleteInlineInfo(e){e.forEach((e=>{pe(e)&&t.delete(e)}))}})}}();function Ue(e,t,n,o=!1){const r=e.getAttribute("rel");let i=e.getAttribute("href"),s=null;if("stylesheet"===r&&i){i=B(i,n.url);let t=We.link.getInfo(i);const r={attrs:ce(e)};if(t?t.appSpace[n.name]=t.appSpace[n.name]||r:t={code:"",appSpace:{[n.name]:r}},We.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","modulepreload","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&&fo.rawSetAttribute.call(e,"href",B(i,n.url));return o?{replaceComment:s}:s?null==t?void 0:t.replaceChild(s,e):void 0}function Be(e,t,n,o){const r=Array.from(t.source.links),i=r.map((e=>{const n=We.link.getInfo(e);return n.code?n.code:we(e,t.name)})),s=o?[]:null;k(i,(e=>{le(s,(()=>function(e,t,n,o){const r=We.link.getInfo(e);r.code=t;const i=r.appSpace[o.name],s=i.placeholder;if(s){const t=Z("style");ke(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=>{O(e,t.name)}),(()=>{o?o.then((()=>{s.push((()=>Promise.resolve(t.onLoad({html:e})))),ue(s)})):t.onLoad({html:e})}))}function ke(e,t,n,o,r){if(e.scopecss){const r=o.appSpace[e.name];if(r.prefix=r.prefix||Se(e.name),r.parsedCode)n.textContent=r.parsedCode;else{const i=function(e,t,n){const o=n.appSpace;for(const r in o)if(r!==e){const e=o[r];if(e.parsedCode)return e.parsedCode.replace(new RegExp(Se(r,!0),"g"),t)}}(e.name,r.prefix,o);i?n.textContent=i:(n.textContent=o.code,Re(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"),fo.rawSetAttribute.call(e,n,t))}))}(n,r)}!function(e){e.NAME="name",e.URL="url"}(Oe||(Oe={})),function(e){e.CREATED="created",e.LOADING="loading",e.LOAD_FAILED="load_failed",e.BEFORE_MOUNT="before_mount",e.MOUNTING="mounting",e.MOUNTED="mounted",e.UNMOUNT="unmount"}(De||(De={})),function(e){e.CREATED="created",e.BEFOREMOUNT="beforemount",e.MOUNTED="mounted",e.UNMOUNT="unmount",e.ERROR="error",e.BEFORESHOW="beforeshow",e.AFTERSHOW="aftershow",e.AFTERHIDDEN="afterhidden"}(Ie||(Ie={})),function(e){e.ONMOUNT="onmount",e.ONUNMOUNT="onunmount"}(xe||(xe={})),function(e){e.KEEP_ALIVE_SHOW="keep_alive_show",e.KEEP_ALIVE_HIDDEN="keep_alive_hidden"}(Te||(Te={})),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.KEEP_ALIVE="keep-alive",e.CLEAR_DATA="clear-data",e.SSR="ssr",e.FIBER="fiber"}(Le||(Le={}));const 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",Fe=[1,2,3],je="state",$e="search",Ke="native",qe="native-scope",Ge="pure",Qe=[$e,je,Ke,qe,Ge],ze=["popstate","hashchange","load","unload","unmount","appstate-change","statechange","mounted"],Xe=ze,Ve=ze.concat(["unhandledrejection","message"]),Ye=["onpopstate","onhashchange","onload","onunload","onerror"],Je=Ye,Ze=Ye.concat(["onunhandledrejection"]),et=["DOMContentLoaded","readystatechange"],tt=["onreadystatechange"],nt=["window","self","globalThis"],ot=["rawWindow","rawDocument"],rt=["host","hostname","port","protocol","origin"],it=["text/javascript","text/ecmascript","application/javascript","application/ecmascript","module","systemjs-module","systemjs-importmap"];function st(e,t){return t.appSpace[e.name].module&&(!e.useSandbox||e.iframe)}function at(e,t){return e.inline||t.appSpace[e.name].inline||st(e,t)||function(e,t){return t.appSpace[e.name].attrs.has("id")}(e,t)}function ct(e){return e.iframe?e.sandBox.microAppWindow:fo.rawWindow}function lt(e,t,n){return function(e,t,n){const o=t.appSpace;for(const r in o)if(r!==e.name){const e=o[r];if(e.parsedCode===n&&e.parsedFunction)return e.parsedFunction}}(e,t,n)||function(e,t){return new(ct(e).Function)(t)}(e,n)}function ut(){const e="inline-"+Math.random().toString(36).substr(2,15);return We.script.hasInfo(e)?ut():e}function pt(e,t){return e.useSandbox&&!st(e,t)}function ht(e,t){return pt(e,t)?e.iframe?"iframe":"with":"disable"}function dt(e,t,n,o=!1){var r;let i=null,s=e.getAttribute("src");if(s&&(s=B(s,n.url)),e.hasAttribute("exclude")||ft(s,n.name))i=document.createComment("script element with exclude attribute removed by micro-app");else{if(e.type&&!it.includes(e.type)||e.hasAttribute("ignore")||_t(s,n.name))return(null===(r=fo.rawDocument)||void 0===r?void 0:r.currentScript)&&delete fo.rawDocument.currentScript,null;if(fo.supportModuleScript&&e.noModule||!fo.supportModuleScript&&"module"===e.type)i=document.createComment((e.noModule?"noModule":"module")+" script ignored by micro-app");else if(s){let t=We.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:ce(e)};if(t?t.appSpace[n.name]=t.appSpace[n.name]||r:t={code:"",isExternal:!0,appSpace:{[n.name]:r}},We.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=ut(),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:ce(e)}}};if(o)return{address:t,scriptInfo:r};n.source.scripts.add(t),We.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 mt(e){var t,n,o;return[...(null===(t=Mo.options.plugins)||void 0===t?void 0:t.global)||[],...(null===(o=null===(n=Mo.options.plugins)||void 0===n?void 0:n.modules)||void 0===o?void 0:o[e])||[]]}function ft(e,t){if(!e)return!1;return(mt(t)||[]).some((t=>!!t.excludeChecker&&t.excludeChecker(e)))}function _t(e,t){if(!e)return!1;return(mt(t)||[]).some((t=>!!t.ignoreChecker&&t.ignoreChecker(e)))}function gt(e,t){const n=Array.from(t.source.scripts),o=[],r=[];for(const s of n){const e=We.script.getInfo(s),n=e.appSpace[t.name];(!n.defer&&!n.async||t.isPrefetch&&!t.isPrerender)&&(o.push(e.code?e.code:we(s,t.name)),r.push([s,e]))}const i=t.isPrefetch||t.fiber?[]:null;o.length?k(o,(e=>{le(i,(()=>function(e,t,n,o){if(t.code=n,o.isPrefetch&&2===o.prefetchLevel){const i=t.appSpace[o.name];if(!i.parsedCode&&(i.parsedCode=At(e,o,n,t),i.sandboxType=ht(o,t),!at(o,t)))try{i.parsedFunction=lt(o,t,i.parsedCode)}catch(r){O("Something went wrong while handling preloaded resources",o.name,"\n",r)}}}(r[e.index][0],r[e.index][1],e.data,t)))}),(e=>{O(e,t.name)}),(()=>{i?(i.push((()=>Promise.resolve(t.onLoad({html:e})))),ue(i)):t.onLoad({html:e})})):t.onLoad({html:e})}function wt(e,t,n,o,r){var i,s;try{!function(e){!function(e){e.sandBox&&(fo.rawWindow.__MICRO_APP_PROXY_WINDOW__=e.sandBox.proxyWindow)}(e)}(t);const s=n.appSpace[t.name],a=ht(t,n);if(s.parsedCode&&s.sandboxType===a||(s.parsedCode=At(e,t,n.code,n),s.sandboxType=a,s.parsedFunction=null),at(t,n)){const a=r||Z("script");if(function(e,t,n,o,r,i){if(n){if(fo.rawSetAttribute.call(o,"type","module"),pe(e)?o.textContent=t:o.src=e,i){const t=()=>{i.moduleCount&&i.moduleCount--,i(0===i.moduleCount)};pe(e)?I(t):o.onload=t}}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"),fo.rawSetAttribute.call(e,n,t))}))}(o,r)}(e,s.parsedCode,st(t,n),a,s.attrs,o),!r){const e=t.iframe?null===(i=t.sandBox)||void 0===i?void 0:i.microBody:t.querySelector("micro-app-body");null==e||e.appendChild(a)}}else!function(e,t){const n=t.appSpace[e.name];n.parsedFunction||(n.parsedFunction=lt(e,t,n.parsedCode));n.parsedFunction.call(ct(e))}(t,n)}catch(a){console.warn(`[micro-app from ${r?"runDynamicScript":"runScript"}] app ${t.name}: `,a,e);const n=a;let o=!0;if("function"==typeof(null===(s=null==Mo?void 0:Mo.options)||void 0===s?void 0:s.excludeRunScriptFilter)&&(o=!0!==Mo.options.excludeRunScriptFilter(e,n,t.name,t.url)),o)throw a}}function At(e,t,n,o){return w(Mo.options.plugins)&&(n=function(e,t,n,o){var r;const i=yt(o.global,t,e);return yt(null===(r=o.modules)||void 0===r?void 0:r[n],i,e)}(e,n,t.name,Mo.options.plugins)),pt(t,o)?t.iframe?`(function(window,self,global,location){;${n}\n${pe(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${pe(e)?"":`//# sourceURL=${e}\n`}}).call(proxyWindow,${He})}})(window.__MICRO_APP_PROXY_WINDOW__);`:n}function yt(e,t,n){return i(e)?e.reduce(((e,t)=>w(t)&&g(t.loader)?t.loader(e,n):e),t):t}function bt(e,t,n){if(!e||"[object HTMLBodyElement]"!==p(e))return;Array.from(e.getElementsByTagName("link")).map((e=>(e.hasAttribute("exclude")||ft(e.getAttribute("href"),t.name)?e.parentElement.replaceChild(document.createComment("link element with exclude attribute ignored by micro-app"),e):e.hasAttribute("ignore")||_t(e.getAttribute("href"),t.name)?e.hasAttribute("href")&&fo.rawSetAttribute.call(e,"href",B(e.getAttribute("href"),t.url)):Ue(e,e.parentElement,t),e)));Array.from(e.getElementsByTagName("style")).map((e=>(e.hasAttribute("exclude")?e.parentElement.replaceChild(document.createComment("style element with exclude attribute ignored by micro-app"),e):t.scopecss&&!e.hasAttribute("ignore")&&le(n,(()=>Re(e,t))),e)));Array.from(e.getElementsByTagName("script")).map((e=>(dt(e,e.parentElement,t),e)));Array.from(e.getElementsByTagName("img")).map((e=>(e.hasAttribute("src")&&fo.rawSetAttribute.call(e,"src",B(e.getAttribute("src"),t.url)),e)))}function vt(e,t){const n=t.parseHtmlString(e),o=fo.rawElementQuerySelector.call(n,"micro-app-head"),r=fo.rawElementQuerySelector.call(n,"micro-app-body");if(!o||!r){const e=`element ${o?"body":"head"} is missing`;return t.onerror(new Error(e)),O(e,t.name)}const i=t.isPrefetch||t.fiber?[]:null;bt(n,t,i);const s=ue(i);t.source.links.size?Be(n,t,o,s):s?s.then((()=>t.onLoad({html:n}))):t.onLoad({html:n}),t.source.scripts.size?gt(n,t):t.onLoad({html:n})}const Et=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||(O("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)&&I(this.process)}isEqual(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&e[n]!==t[n])return!1;return!0}on(e,t,n=!1){if(this.isLegalName(e)){if(!g(t))return O("event-center: Invalid callback function");let o=this.eventList.get(e);o?n&&Object.keys(o.data).length&&(!this.queue.includes(e)||this.isEqual(o.data,o.tempData))&&t(o.data):(o={data:{},callbacks:new Set},this.eventList.set(e,o)),o.callbacks.add(t)}}off(e,t){if(this.isLegalName(e)){const n=this.eventList.get(e);n&&(g(t)?n.callbacks.delete(t):n.callbacks.clear())}}clearData(e){if(this.isLegalName(e)){const t=this.eventList.get(e);t&&(t.data={})}}dispatch(e,t,n,o,r){if(this.isLegalName(e)){if(!w(t))return O("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 Pt(e,t){return m(e)&&e?t?`__${e}_from_base_app__`:`__${e}_from_micro_app__`:""}class Rt{addGlobalDataListener(e,t){const n=this.appName;n&&(e.__APP_NAME__=n,e.__AUTO_TRIGGER__=t),Et.on("global",e,t)}removeGlobalDataListener(e){g(e)&&Et.off("global",e)}setGlobalData(e,t,n){J(),Et.dispatch("global",e,(e=>g(t)&&t(e)),n)}forceSetGlobalData(e,t){this.setGlobalData(e,t,!0)}getGlobalData(){return Et.getData("global")}clearGlobalData(){Et.clearData("global")}clearGlobalDataListener(){const e=this.appName,t=Et.eventList.get("global");if(t)for(const n of t.callbacks)(e&&e===n.__APP_NAME__||!e&&!n.__APP_NAME__)&&t.callbacks.delete(n)}}class St extends Rt{addDataListener(e,t,n){Et.on(Pt(W(e),!1),t,n)}removeDataListener(e,t){g(t)&&Et.off(Pt(W(e),!1),t)}getData(e,t=!1){return Et.getData(Pt(W(e),t))}setData(e,t,n,o){Et.dispatch(Pt(W(e),!0),t,(e=>g(n)&&n(e)),o)}forceSetData(e,t,n){this.setData(e,t,n,!0)}clearData(e,t=!0){Et.clearData(Pt(W(e),t))}clearDataListener(e){Et.off(Pt(W(e),!1))}}class Mt extends Rt{constructor(e){super(),this.appName=W(e),!this.appName&&O(`Invalid appName ${e}`)}addDataListener(e,t){e.__AUTO_TRIGGER__=t,Et.on(Pt(this.appName,!0),e,t)}removeDataListener(e){g(e)&&Et.off(Pt(this.appName,!0),e)}getData(e=!0){return Et.getData(Pt(this.appName,e))}dispatch(e,t,n){J(),Et.dispatch(Pt(this.appName,!1),e,(e=>g(t)&&t(e)),n,(()=>{const t=eo.get(this.appName);if((null==t?void 0:t.container)&&w(e)){const e=new CustomEvent("datachange",{detail:{data:Et.getData(Pt(this.appName,!1))}});ne(t.container).dispatchEvent(e)}}))}forceDispatch(e,t){this.dispatch(e,t,!0)}clearData(e=!1){Et.clearData(Pt(this.appName,e))}clearDataListener(){Et.off(Pt(this.appName,!0))}}function Ct(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=Et.eventList.get("global");if(o)for(const t of o.callbacks)e.appName===t.__APP_NAME__&&e.umdDataListeners.global.add(t);const r=Et.eventList.get(Pt(e.appName,!0));if(r)for(const t of r.callbacks)e.umdDataListeners.normal.add(t)}}function Nt(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__);Ot(e)}}function Ot(e){null==e||delete e.umdDataListeners}class Dt{constructor(){this.appInstanceMap=eo}static getInstance(){return this.instance||(this.instance=new Dt),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 It(){xt(),Dt.getInstance().getAll().forEach((e=>{e.container&&ne(e.container).disconnectedCallback()})),!window.__MICRO_APP_UMD_MODE__&&Dt.getInstance().clear()}function xt(){window.__MICRO_APP_ENVIRONMENT__&&window.removeEventListener("unmount",It,!1)}function Tt(e){return f(e.__MICRO_APP_IS_BOUND_FUNCTION__)?e.__MICRO_APP_IS_BOUND_FUNCTION__:e.__MICRO_APP_IS_BOUND_FUNCTION__=g(t=e)&&0===(null===(n=t.name)||void 0===n?void 0:n.indexOf("bound "))&&!t.hasOwnProperty("prototype");var t,n}function Lt(e,t,n="WINDOW"){if(g(e)&&!function(e){return f(e.__MICRO_APP_IS_CONSTRUCTOR__)?e.__MICRO_APP_IS_CONSTRUCTOR__:e.__MICRO_APP_IS_CONSTRUCTOR__=y(e)}(e)&&!Tt(e)&&e.bind){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}class Wt{constructor(e,t){this.rawWindowScopeKeyList=["location"],this.staticEscapeProperties=["System","__cjsWrapper"],this.staticScopeProperties=["webpackJsonp","webpackHotUpdate","Vue","onpopstate","onhashchange","event"],this.scopeProperties=Array.from(this.staticScopeProperties),this.escapeProperties=[],this.injectedKeys=new Set,this.escapeKeys=new Set,this.appName=e,this.url=t,this.injectReactHMRProperty()}injectReactHMRProperty(){}}class Ut{}function Bt(e,t){const n=Array.from(e.childNodes);n.length&&n.forEach((e=>{Bt(e,t)})),kt(e,t)}function kt(e,t){var n,o;if(t&&E(e)&&e.__MICRO_APP_NAME__!==t&&!e.__PURE_ELEMENT__&&!Y()){const r={__MICRO_APP_NAME__:{configurable:!0,enumerable:!0,writable:!0,value:t}};if("[object HTMLAnchorElement]"===p(e)){Dt.getInstance().get(t)&&(r.href={get(){return this.getAttribute("href")},set(e){void 0!==e&&this.setAttribute("href",e)}})}if(c(e,r),no(t)){const r=null===(o=null===(n=eo.get(t))||void 0===n?void 0:n.sandBox)||void 0===o?void 0:o.proxyWindow;r&&c(e,{baseURI:{configurable:!0,enumerable:!0,get:()=>r.location.href},ownerDocument:{configurable:!0,enumerable:!0,get:()=>e!==r.document?r.document:null},parentNode:Ht(t,fo.rawParentNodeDesc),getRootNode:{configurable:!0,enumerable:!0,writable:!0,value:function(){return r.document}}})}}return e}function Ht(e,t){return{configurable:!0,enumerable:!0,get(){var n,o,r,i;X(e);const s=null===(n=t.get)||void 0===n?void 0:n.call(this);return M(s)&&(null===(o=eo.get(e))||void 0===o?void 0:o.container)?(null===(i=(r=Mo.options).getRootElementParentNode)||void 0===i?void 0:i.call(r,this,e))||fo.rawDocument.body:s}}}function Ft(e,t,n){const{proxyDocument:o,documentEffect:r}=function(e,t){const n=new Map,o=new Map;let r=null,i=null;const{rawDocument:s,rawCreateElement:a,rawCreateElementNS:c,rawAddEventListener:l,rawRemoveEventListener:u}=fo;function p(t,n){return kt(a.call(s,t,n),e)}function h(t,n,o){return kt(c.call(s,t,n,o),e)}function d(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),l.call(s,e,t,o)}function m(e,t,o){const r=n.get(e);(null==r?void 0:r.size)&&r.has(t)&&r.delete(t),u.call(s,e,t,o)}const f=()=>{o.clear(),i=null},_=()=>{i=r||i,n.forEach(((e,t)=>{if(e.size){const n=o.get(t)||[];o.set(t,new Set([...n,...e]))}}))},w=()=>{i&&!r&&(b.onclick=i),o.forEach(((e,t)=>{for(const n of e)b.addEventListener(t,n,null==n?void 0:n.__MICRO_APP_MARK_OPTIONS__)})),f()},A=()=>{g(r)&&u.call(s,"click",r),r=null,n.size&&(n.forEach(((e,t)=>{for(const n of e)u.call(s,t,n)})),n.clear())},y=(()=>{var e;const t=new Map([["onclick",e=>{g(r)&&u.call(s,"click",r,!1),g(e)&&l.call(s,"click",e,!1),r=e}]]),n=(null===(e=Mo.options)||void 0===e?void 0:e.customProxyDocumentProps)||new Map;return new Map([...t,...n])})(),b=new Proxy(s,{get:(n,o)=>{var i;return q(e),"createElement"===o?p:"createElementNS"===o?h:o===Symbol.toStringTag?"ProxyDocument":"defaultView"===o?t.proxyWindow:"onclick"===o?r:"addEventListener"===o?d:"removeEventListener"===o?m:"microAppElement"===o?null===(i=eo.get(e))||void 0===i?void 0:i.container:"__MICRO_APP_NAME__"===o?e:Lt(Reflect.get(n,o),s,"DOCUMENT")},set:(e,t,n)=>{if(y.has(t)){y.get(t)(n)}else"microAppElement"!==t&&Reflect.set(e,t,n);return!0}});return{proxyDocument:b,documentEffect:{reset:f,record:_,rebuild:w,release:A}}}(e,n),i=function(e,t){const{rawDocument:n,rawRootDocument:o}=fo;class r{static[Symbol.hasInstance](e){let n=e;for(;n;)if(n=Object.getPrototypeOf(n),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)=>(q(e),Lt(Reflect.get(t,o),n,"DOCUMENT")),set:(e,t,n)=>(Reflect.set(e,t,n),!0)})),r}(e,o);return c(t,{document:{configurable:!1,enumerable:!0,get:()=>o},Document:{configurable:!1,enumerable:!1,get:()=>i}}),r}function jt(e,t,n){return function(e){const t=fo.rawWindow;Object.getOwnPropertyNames(t).filter((e=>/^on/.test(e)&&!Je.includes(e))).forEach((n=>{const{enumerable:o,writable:r,set:i}=Object.getOwnPropertyDescriptor(t,n)||{enumerable:!0,writable:!0};a(e,n,{enumerable:o,configurable:!0,get:()=>t[n],set:(null!=r?r:i)?e=>{t[n]=e}:void 0})}))}(t),function(e,t,n){const o=fo.rawWindow,r=new Map,i=new Proxy(t,{get:(t,r)=>(q(e),Reflect.has(t,r)||m(r)&&/^__MICRO_APP_/.test(r)||N(n.scopeProperties,r)?(N(ot,r)&&J(),Reflect.get(t,r)):Lt(Reflect.get(o,r),o)),set:(e,t,r)=>{if(N(n.rawWindowScopeKeyList,t))Reflect.set(o,t,r);else if(u.call(e,t)||!u.call(o,t)||N(n.scopeProperties,t))Reflect.has(e,t)&&!N(n.scopeProperties,t)||n.injectedKeys.add(t),Reflect.set(e,t,r);else{const i=Object.getOwnPropertyDescriptor(o,t),{configurable:s,enumerable:c,writable:l,set:u}=i;a(e,t,{value:r,configurable:s,enumerable:c,writable:null!=l?l:!!u}),n.injectedKeys.add(t)}return(N(n.escapeProperties,t)||N(n.staticEscapeProperties,t)&&!Reflect.has(o,t))&&!N(n.scopeProperties,t)&&(!Reflect.has(o,t)&&n.escapeKeys.add(t),Reflect.set(o,t,r)),!0},has:(e,t)=>N(n.scopeProperties,t)?n.injectedKeys.has(t)?Reflect.has(e,t):!!e[t]:Reflect.has(e,t)||Reflect.has(o,t),getOwnPropertyDescriptor:(e,t)=>{if(u.call(e,t))return r.set(t,"target"),Object.getOwnPropertyDescriptor(e,t);if(u.call(o,t)){r.set(t,"rawWindow");const e=Object.getOwnPropertyDescriptor(o,t);return e&&!e.configurable&&(e.configurable=!0),e}},defineProperty:(e,t,n)=>"rawWindow"===r.get(t)?Reflect.defineProperty(o,t,n):Reflect.defineProperty(e,t,n),ownKeys:e=>Reflect.ownKeys(o).concat(Reflect.ownKeys(e)).filter((function(e){return!(e in this)&&(this[e]=!0)}),Object.create(null)),deleteProperty:(e,t)=>!u.call(e,t)||(n.injectedKeys.has(t)&&n.injectedKeys.delete(t),n.escapeKeys.has(t)&&Reflect.deleteProperty(o,t),Reflect.deleteProperty(e,t))});n.proxyWindow=i}(e,t,n),function(e,t){const n=new Map,o=new Map,r=new Map,i=new Map,{rawWindow:s,rawAddEventListener:a,rawRemoveEventListener:c,rawDispatchEvent:l,rawSetInterval:u,rawSetTimeout:p,rawClearInterval:h,rawClearTimeout:d}=fo;function m(e){var n;return Xe.includes(e)&&(null===(n=eo.get(t))||void 0===n?void 0:n.container)?ne(eo.get(t).container):s}e.addEventListener=function(e,o,r){e=fe(e,t);const i=n.get(e);i?i.add(o):n.set(e,new Set([o])),o&&(o.__MICRO_APP_MARK_OPTIONS__=r),a.call(m(e),e,o,r)},e.removeEventListener=function(e,o,r){e=fe(e,t);const i=n.get(e);(null==i?void 0:i.size)&&i.has(o)&&i.delete(o),c.call(m(e),e,o,r)},e.dispatchEvent=function(e){return l.call(m(null==e?void 0:e.type),e)},e.setInterval=function(e,t,...n){const o=u.call(s,e,t,...n);return r.set(o,{handler:e,timeout:t,args:n}),o},e.setTimeout=function(e,t,...n){const o=function(...t){i.delete(a),"function"==typeof e&&e(...t)},r="string"==typeof e?e:o,a=p.call(s,r,t,...n);return i.set(a,{handler:r,timeout:t,args:n}),a},e.clearInterval=function(e){r.delete(e),h.call(s,e)},e.clearTimeout=function(e){i.delete(e),d.call(s,e)};const f=()=>{o.clear()},_=()=>{o.forEach(((t,n)=>{for(const o of t)e.addEventListener(n,o,null==o?void 0:o.__MICRO_APP_MARK_OPTIONS__)})),f()};return{reset:f,record:()=>{n.forEach(((e,t)=>{if(e.size){const n=o.get(t)||[];o.set(t,new Set([...n,...e]))}}))},rebuild:_,release:e=>{n.size&&(n.forEach(((e,t)=>{for(const n of e)c.call(m(t),t,n)})),n.clear()),e&&(r.forEach(((e,t)=>{h.call(s,t)})),i.forEach(((e,t)=>{d.call(s,t)})),r.clear(),i.clear())}}}(t,e)}function $t(e,t,n){const o=fo.rawWindow.history.state,r={__MICRO_APP_STATE__:s({},null==o?void 0:o.__MICRO_APP_STATE__,{[e]:{fullPath:n?n.pathname+n.search+n.hash:null,state:null!=t?t:null,mode:sn(e)}})};return s({},o,r)}function Kt(e,t){return w(null==t?void 0:t.__MICRO_APP_STATE__)&&(h(t.__MICRO_APP_STATE__[e])||delete t.__MICRO_APP_STATE__[e],Object.keys(t.__MICRO_APP_STATE__).length||delete t.__MICRO_APP_STATE__),w(n=t)&&Object.keys(n).length?s({},t):null;var n}function qt(e){var t,n;const o=fo.rawWindow.history.state;return(null===(n=null===(t=null==o?void 0:o.__MICRO_APP_STATE__)||void 0===t?void 0:t[e])||void 0===n?void 0:n.state)||null}function Gt(e){var t;const n=fo.rawWindow.history.state;return(null===(t=null==n?void 0:n.__MICRO_APP_STATE__)||void 0===t?void 0:t[e])||null}const Qt=/&/g,zt=/=/g,Xt=/%M1/g,Vt=/%M2/g;function Yt(e){return encodeURIComponent(Zt(e).replace(Qt,"%M1").replace(zt,"%M2"))}function Jt(e){return Zt(e).replace(Xt,"&").replace(Vt,"=")}function Zt(e){try{const t=decodeURIComponent(e);return e===t||Xt.test(t)||Vt.test(t)?t:Zt(t)}catch(t){return e}}function en(e){return e}function tn(e){var t,n,o,r;const i=fo.rawWindow.location,s=fo.rawWindow.history.state;if(an(e)){const o=on(i.search,i.hash),r=(null===(t=o.hashQuery)||void 0===t?void 0:t[e])||(null===(n=o.searchQuery)||void 0===n?void 0:n[e]);return m(r)?Jt(r):null}return(null===(r=null===(o=null==s?void 0:s.__MICRO_APP_STATE__)||void 0===o?void 0:o[e])||void 0===r?void 0:r.fullPath)||(pn(e)?i.pathname+i.search+i.hash:null)}function nn(e,t){const n=fo.rawWindow.location;let o=t.pathname+t.search+t.hash,r=!1;if(an(e)){let{pathname:t,search:i,hash:s}=n;const a=on(i,s),c=Yt(o);if(s&&!i){r=!0,a.hashQuery?a.hashQuery[e]=c:a.hashQuery={[en(e)]:c};const t=s.includes("?")?s.slice(0,s.indexOf("?")+1):s+"?";s=t+se(a.hashQuery)}else a.searchQuery?a.searchQuery[e]=c:a.searchQuery={[en(e)]:c},i="?"+se(a.searchQuery);return{fullPath:t+i+s,isAttach2Hash:r}}return(cn(e)||un(e))&&(o=n.pathname+n.search+n.hash),{fullPath:o,isAttach2Hash:r}}function on(e,t){const n={};return""!==e&&"?"!==e&&(n.searchQuery=ie(e.slice(1))),t.includes("?")&&(n.hashQuery=ie(t.slice(t.indexOf("?")+1))),n}function rn(e){const t=eo.get(e);return!(!t||t.isPrefetch)}function sn(e){var t;return null===(t=eo.get(e))||void 0===t?void 0:t.routerMode}function an(e){return sn(e)===$e}function cn(e){return sn(e)===je}function ln(e){return sn(e)===Ke}function un(e){return sn(e)===Ge}function pn(e){return ln(e)||function(e){return sn(e)===qe}(e)}function hn(e,t){const n=t&&Ke||e||Mo.options["disable-memory-router"]&&Ke||Mo.options["router-mode"]||$e;return Qe.includes(n)?n:$e}function dn(e){const t=fo.rawWindow,n=t=>{var n,o,r;if(yo({excludeHiddenApp:!0,excludePreRender:!0}).includes(e)&&!t.onlyForBrowser&&(!pn(e)||!fo.rawWindow.history.state||Gt(e))){const t=null===(n=eo.get(e))||void 0===n?void 0:n.container;!function(e,t=0,...n){setTimeout(e.bind(null,...n),t)}((()=>mn(e,tn(e))),null!==(r=null===(o=t&&ne(t))||void 0===o?void 0:o.getRouterEventDelay())&&void 0!==r?r:0)}};return t.addEventListener("popstate",n),()=>{t.removeEventListener("popstate",n)}}function mn(e,t){const n=eo.get(e);if(null==n?void 0:n.sandBox){const o=n.sandBox.proxyWindow,r=n.sandBox.microAppWindow;let i=!1;const s=o.location.href;if(t){const n=o.location.hash;Nn(e,t,r.location),i=o.location.hash!==n}!function(e,t,n){const o=new PopStateEvent("popstate",{state:qt(e)});n.dispatchEvent(o),no(e)||g(t.onpopstate)&&t.onpopstate(o)}(e,o,r),i&&function(e,t,n,o){const r=new HashChangeEvent("hashchange",{newURL:t.location.href,oldURL:o});n.dispatchEvent(r),no(e)||g(t.onhashchange)&&t.onhashchange(r)}(e,o,r,s),J()}}function fn(e,t,n){J(),rn(e)&&(function(e){const t=new PopStateEvent("popstate",{state:null});e&&(t.onlyForBrowser=!0),fo.rawWindow.dispatchEvent(t)}(t),n&&function(e){const t=new HashChangeEvent("hashchange",{newURL:fo.rawWindow.location.href,oldURL:e});fo.rawWindow.dispatchEvent(t)}(n))}function _n(e,t){const n=fo.rawWindow.history;function o(n){return function(...o){var r,i,s;o[2]=h(o[2])||d(o[2])||""+o[2]==""?t.href:""+o[2];const a=x(o[2],t.href),c=a.pathname+a.search+a.hash;un(e)||wn(e,n,nn(e,a),!0,$t(e,o[0],a),o[1]),c!==t.fullPath&&Nn(e,c,t),null===(s=null===(r=eo.get(e))||void 0===r?void 0:(i=r.sandBox).updateIframeBase)||void 0===s||s.call(i)}}const r={pushState:o("pushState"),replaceState:o("replaceState")};return no(e)?s({go:e=>n.go(e)},r):new Proxy(n,{get:(t,n)=>"pushState"===n||"replaceState"===n?r[n]:"state"===n?qt(e):Lt(Reflect.get(t,n),t,"HISTORY"),set:(e,t,n)=>("pushState"===t||"replaceState"===t?r[t]=n:Reflect.set(e,t,n),!0)})}function gn(e,t,n,o=null,r=""){if(rn(e)){("pushState"===t?fo.rawPushState:fo.rawReplaceState).call(fo.rawWindow.history,o,r,n)}}function wn(e,t,n,o,r,i){if(rn(e)){const s=fo.rawWindow.location,a=s.pathname+s.search+s.hash,c=n.isAttach2Hash&&a!==n.fullPath?s.href:null;gn(e,t,n.fullPath,r,i),a!==n.fullPath&&an(e)&&fn(e,o,c)}}function An(e,t,n){wn(e,"replaceState",t,!0,n)}function yn(e){const t=fo.rawWindow;return function(...n){var o;if((null===(o=t.history.state)||void 0===o?void 0:o.__MICRO_APP_STATE__)&&(!w(n[0])||!n[0].__MICRO_APP_STATE__)&&(m(n[2])||b(n[2]))){const e=t.location.href;x(n[2],e).href===e&&(n[0]=s({},n[0],{__MICRO_APP_STATE__:t.history.state.__MICRO_APP_STATE__}))}e.apply(t.history,n),yo({excludeHiddenApp:!0,excludePreRender:!0}).forEach((e=>{if((an(e)||cn(e))&&!tn(e)){const t=eo.get(e);An(e,nn(e,t.sandBox.proxyWindow.location),$t(e,qt(e),t.sandBox.proxyWindow.location))}pn(e)&&!Gt(e)&&gn(e,"replaceState",t.location.href,$t(e))})),J()}}function bn(){const e=fo.rawWindow;e.history.pushState=yn(fo.rawPushState),e.history.replaceState=yn(fo.rawReplaceState)}function vn(){const e=fo.rawWindow;e.history.pushState=fo.rawPushState,e.history.replaceState=fo.rawReplaceState}const{router:En,executeNavigationGuard:Pn,clearRouterWhenUnmount:Rn}=function(){function e(e,t,n,o){const r=t.sandBox.proxyWindow.location,i=x(n.path,r.href),s=r.pathname+r.search+r.hash,a=i.pathname+i.search+i.hash;if(s!==a||tn(e)!==a){if(!un(e)){!function(e,t,n,o){wn(e,t,nn(e,n),!1,$t(e,null!=o?o:null,n)),J()}(e,o&&!1!==n.replace||!0===n.replace?"replaceState":"pushState",i,n.state)}an(e)||mn(e,a)}}function t(t){return function(n){return new Promise(((o,r)=>{const i=W(n.name);if(i&&m(n.path))if(yo({excludeHiddenApp:!0,excludePreRender:!0}).includes(i)){const r=eo.get(i);o(r.sandBox.sandboxReady.then((()=>e(i,r,n,t))))}else r(O("导航失败,请确保子应用渲染后再调用此方法"));else r(O("navigation failed, name & path are required when use router."+(t?"replace":"push")))}))}}function n(e){return function(...t){return fo.rawWindow.history[e](...t)}}const o=ae(),i=ae();function s(e,t,n,o){J();for(const r of o)g(r)?r(t,n,e):w(r)&&g(r[e])&&r[e](t,n)}function a(e){if(an(e)||cn(e)){const t=eo.get(e);An(e,nn(e,t.sandBox.proxyWindow.location),$t(e,qt(e),t.sandBox.proxyWindow.location))}}const c=Object.assign(Object.assign({current:new Map,encode:Yt,decode:Jt,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=W(e))&&yo().includes(e)&&a(e)},attachAllToURL:function({includeHiddenApp:e=!1,includePreRender:t=!1}){yo({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=W(t.name);return n&&t.path?e.add(n,t.path):r},removeDefaultPage:function(t){return!!(t=W(t))&&e.delete(t)},getDefaultPage:e.get}}()),function(){let e=null;return{setBaseAppRouter:function(t){var n;d(n=t)||"object"!=typeof n||(e=new Proxy(t,{get:(e,t)=>(J(),Lt(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()),H((()=>{s(e,t,n,i.list())}))},clearRouterWhenUnmount:function(e){c.current.delete(e)}}}(),Sn=["href","pathname","search","hash","host","hostname","port","protocol","search","origin","fullPath"];function Mn(e,t,n,o,r,i){const s=fo.rawWindow.location,c=!!n,l=x(t);function u(){return c?n.location:l}function p(t,n){const o=x(t,g.href);if(o.origin===g.origin){const t=nn(e,o);if(!pn(e)){if(n=un(e)?"replaceState":n,o.pathname===g.pathname&&o.search===g.search){let r=null;return(o.hash!==g.hash||un(e))&&(t.isAttach2Hash&&(r=s.href),un(e)&&o.hash||gn(e,n,t.fullPath,an(e)?null:$t(e,null,o))),void(o.hash?an(e)?fn(e,!1,r):mn(e,o.pathname+o.search+o.hash):_())}return gn(e,n,t.fullPath,an(e)?null:$t(e,null,o)),void _()}return t.fullPath}return t}function h(n,o){const r=x(n,t);r[o]===g[o]&&g.hash?fn(e,!1):(gn(e,r[o]===g[o]||un(e)?"replaceState":"pushState",nn(e,r).fullPath,an(e)?null:$t(e,null,r)),_())}const d=t=>function(n){if(rn(e)){const e=p(n,"assign"===t?"pushState":"replaceState");e&&s[t](x(e,s.origin).href)}},m=d("assign"),f=d("replace"),_=e=>s.reload(e);a(u(),"fullPath",{enumerable:!0,configurable:!0,get:()=>g.pathname+g.search+g.hash});const g=new Proxy({},{get:(t,n)=>{const a=u();if("assign"===n)return m;if("replace"===n)return f;if("reload"===n)return _;if("self"===n)return a;if("fullPath"===n)return a.fullPath;if(rt.includes(n)){if(ln(e))return s[n];if(c)return o[n]}if("href"===n){if(ln(e))return a[n].replace(a.origin,s.origin);if(c)return a[n].replace(r,i)}return Lt(Reflect.get(a,n),a,"LOCATION")},set:(n,o,r)=>{if(rn(e)){const n=u();if("href"===o){const e=p(r,"pushState");e&&(s.href=x(e,s.origin).href)}else if("pathname"===o)if(pn(e))s.pathname=r;else{h(("/"+r).replace(/^\/+/,"/")+g.search+g.hash,"pathname")}else if("search"===o)if(pn(e))s.search=r;else{h(g.pathname+("?"+r).replace(/^\?+/,"?")+g.hash,"search")}else if("hash"===o)if(pn(e))s.hash=r;else{const n=g.pathname+g.search+("#"+r).replace(/^#+/,"#"),o=x(n,t);o.hash!==g.hash&&(un(e)||wn(e,"pushState",nn(e,o),!1,$t(e,null,o)),an(e)||mn(e,o.pathname+o.search+o.hash))}else Reflect.set(n,o,r)}return!0}});return g}function Cn(e,t){const n=s({name:e},t);for(const o of Sn)n[o]=t[o];return n}function Nn(e,t,n,o){var r;const i=Cn(e,n),s=x(t,n.href);if(no(e)){const t=eo.get(e).sandBox.microAppWindow;null===(r=t.rawReplaceState)||void 0===r||r.call(t.history,qt(e),"",s.href)}else{let e=s.href;n.self.origin!==s.origin&&(e=e.replace(s.origin,n.self.origin)),n.self.href=e}const a=fo.rawWindow.location;pn(e)&&t!==a.pathname+a.search+a.hash&&"prevent"!==o&&gn(e,"replaceState",t,fo.rawWindow.history.state);const c=Cn(e,n);("auto"===o||i.fullPath!==c.fullPath&&"prevent"!==o)&&Pn(e,c,i)}function On(e,t,n){const o=tn(e);o?(Nn(e,o,t,"auto"),un(e)&&xn(e)):Dn(e,t,n)}function Dn(e,t,n){n&&Nn(e,n,t,"prevent"),un(e)||An(e,nn(e,t),$t(e,null,t)),function(e,t){Pn(e,Cn(e,t),Cn(e,t))}(e,t)}function In(e,t,n,o){if(!o&&!pn(e)){const{pathname:o,search:r,hash:i}=x(t);Nn(e,o+r+i,n,"prevent")}un(e)||xn(e),Rn(e)}function xn(e){An(e,function(e){var t,n,o,r;let{pathname:i,search:s,hash:a}=fo.rawWindow.location,c=!1;if(an(e)){const i=on(s,a);if(null===(t=i.hashQuery)||void 0===t?void 0:t[e]){c=!0,null===(n=i.hashQuery)||void 0===n||delete n[e];const t=se(i.hashQuery);a=a.slice(0,a.indexOf("?")+Number(Boolean(t)))+t}else if(null===(o=i.searchQuery)||void 0===o?void 0:o[e]){null===(r=i.searchQuery)||void 0===r||delete r[e];const t=se(i.searchQuery);s=t?"?"+t:""}}return{fullPath:i+s+a,isAttach2Hash:c}}(e),Kt(e,fo.rawWindow.history.state))}function Tn(e,t){const n=h(t)?fo.rawWindow.fetch:t;return g(n)?function(t,o,...r){return(m(t)||b(t))&&(t=x(t,e).toString()),J(),n.call(fo.rawWindow,t,o,...r)}:n}function Ln(e,t){const n=h(t)?fo.rawWindow.XMLHttpRequest:t;return y(n)?class extends n{open(t,n,...o){(m(n)&&!/^f(ile|tp):\/\//.test(n)||b(n))&&(n=x(n,e).toString()),J(),super.open(t,n,...o)}}:n}const{createMicroEventSource:Wn,clearMicroEventSource:Un}=function(){let e;return{createMicroEventSource:function(t,n,o){const r=h(o)?fo.rawWindow.EventSource:o;return y(r)?class extends r{constructor(o,r,...i){if((m(o)||b(o))&&(o=x(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())}}}();class Bn extends Wt{constructor(e,t){super(e,t),this.active=!1,this.microAppWindow=new Ut,this.patchWith((n=>{this.getSpecialProperties(e),this.patchRouter(e,t,this.microAppWindow),this.windowEffect=jt(e,this.microAppWindow,this),this.documentEffect=Ft(e,this.microAppWindow,this),this.setMappingPropertiesWithRawDescriptor(this.microAppWindow),this.initStaticGlobalKeys(e,t,this.microAppWindow),n()}))}start({umdMode:e,baseroute:t,defaultPage:n,disablePatchRequest:o}){this.active||(this.active=!0,this.initRouteState(n),this.removeHistoryListener=dn(this.microAppWindow.__MICRO_APP_NAME__),pn(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,o),1==++fo.activeSandbox&&(uo(),bn()),1==++Bn.activeCount&&window.__MICRO_APP_ENVIRONMENT__&&(xt(),window.addEventListener("unmount",It,!1)),fo.rawWindow._babelPolyfill&&(fo.rawWindow._babelPolyfill=!1))}stop({umdMode:e,keepRouteState:t,destroy:n,clearData:o}){var r;this.active&&(this.recordAndReleaseEffect({umdMode:e,clearData:o,destroy:n},!e||n),this.clearRouteState(t),null===(r=this.removeHistoryListener)||void 0===r||r.call(this),e&&!n||(Un(this.microAppWindow.__MICRO_APP_NAME__),this.injectedKeys.forEach((e=>{Reflect.deleteProperty(this.microAppWindow,e)})),this.injectedKeys.clear(),this.escapeKeys.forEach((e=>{Reflect.deleteProperty(fo.rawWindow,e)})),this.escapeKeys.clear(),this.clearHijackUmdHooks()),0==--fo.activeSandbox&&(ho(),vn()),--Bn.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__=U(t),n.__MICRO_APP_BASE_ROUTE__="",n.__MICRO_APP_WINDOW__=n,n.__MICRO_APP_PRE_RENDER__=!1,n.__MICRO_APP_UMD_MODE__=!1,n.__MICRO_APP_PROXY_WINDOW__=this.proxyWindow,n.__MICRO_APP_SANDBOX__=this,n.__MICRO_APP_SANDBOX_TYPE__="with",n.rawWindow=fo.rawWindow,n.rawDocument=fo.rawDocument,n.microApp=s(new Mt(e),{removeDomScope:J,pureCreateElement:Z,location:n.location,router:En})}recordAndReleaseEffect(e,t=!1){t?this.resetEffectSnapshot():this.recordEffectSnapshot(),this.releaseGlobalEffect(e)}resetEffectSnapshot(){this.windowEffect.reset(),this.documentEffect.reset(),Ot(this.microAppWindow.microApp)}recordEffectSnapshot(){this.windowEffect.record(),this.documentEffect.record(),Ct(this.microAppWindow.microApp)}rebuildEffectSnapshot(){this.windowEffect.rebuild(),this.documentEffect.rebuild(),Nt(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&&(Mo.clearData(this.microAppWindow.__MICRO_APP_NAME__),null===(a=this.microAppWindow.microApp)||void 0===a||a.clearData())}getSpecialProperties(e){var t;w(Mo.options.plugins)&&(this.commonActionForSpecialProperties(Mo.options.plugins.global),this.commonActionForSpecialProperties(null===(t=Mo.options.plugins.modules)||void 0===t?void 0:t[e]))}commonActionForSpecialProperties(e){if(i(e))for(const t of e)w(t)&&(i(t.scopeProperties)&&(this.scopeProperties=this.scopeProperties.concat(t.scopeProperties)),i(t.escapeProperties)&&(this.escapeProperties=this.escapeProperties.concat(t.escapeProperties)))}setPreRenderState(e){this.microAppWindow.__MICRO_APP_PRE_RENDER__=e}markUmdMode(e){this.microAppWindow.__MICRO_APP_UMD_MODE__=e}patchWith(e){this.sandboxReady=new Promise((t=>e(t)))}setMappingPropertiesWithRawDescriptor(e){let t,n;const o=fo.rawWindow;o===o.parent?t=n=this.proxyWindow:(t=o.top,n=o.parent),c(e,{top:this.createDescriptorForMicroAppWindow("top",t),parent:this.createDescriptorForMicroAppWindow("parent",n)}),nt.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(fo.rawWindow,e)||{writable:!0};return{value:t,configurable:n,enumerable:o,writable:null!=r?r:!!i}}initGlobalKeysWhenStart(e,t,n,o){n.hasOwnProperty=e=>u.call(n,e)||u.call(fo.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:()=>(q(e),n||fo.rawWindow.eval),set:e=>{n=e}},Image:{configurable:!0,enumerable:!1,get:()=>(q(e),o||fo.ImageProxy),set:e=>{o=e}}})}patchRequestApi(e,t,n){let o=Tn(t),r=Ln(t),i=Wn(e,t);c(n,{fetch:{configurable:!0,enumerable:!0,get:()=>o,set(e){o=Tn(t,e)}},XMLHttpRequest:{configurable:!0,enumerable:!0,get:()=>r,set(e){r=Ln(t,e)}},EventSource:{configurable:!0,enumerable:!0,get:()=>i,set(n){i=Wn(e,t,n)}}})}setScopeProperties(e){this.scopeProperties.forEach((t=>{Reflect.set(e,t,e[t])}))}patchRouter(e,t,n){const{microLocation:o,microHistory:r}=function(e,t){const n=Mn(e,t);return{microLocation:n,microHistory:_n(e,n)}}(e,t);c(n,{location:{configurable:!1,enumerable:!0,get:()=>o,set:e=>{fo.rawWindow.location=e}},history:{configurable:!0,enumerable:!0,get:()=>r}})}initRouteState(e){On(this.microAppWindow.__MICRO_APP_NAME__,this.microAppWindow.location,e)}clearRouteState(e){In(this.microAppWindow.__MICRO_APP_NAME__,this.microAppWindow.__MICRO_APP_URL__,this.microAppWindow.location,e)}setRouteInfoForKeepAliveApp(){Dn(this.microAppWindow.__MICRO_APP_NAME__,this.microAppWindow.location)}removeRouteInfoForKeepAliveApp(){xn(this.microAppWindow.__MICRO_APP_NAME__)}patchStaticElement(e){Bt(e,this.microAppWindow.__MICRO_APP_NAME__)}actionsBeforeExecScripts(e,t){this.patchStaticElement(e),this.clearHijackUmdHooks=this.hijackUmdHooks(this.appName,this.microAppWindow,t)}hijackUmdHooks(e,t,n){let o,r,i;return c(t,{mount:{configurable:!0,get:()=>o,set:e=>{this.active&&g(e)&&!o&&n(o=e,r)}},unmount:{configurable:!0,get:()=>r,set:e=>{this.active&&g(e)&&!r&&n(o,r=e)}},[`micro-app-${e}`]:{configurable:!0,get:()=>i,set:e=>{this.active&&w(e)&&!i&&(i=e,n(i.mount,i.unmount))}}}),()=>{o=r=i=null}}setStaticAppState(e){this.microAppWindow.__MICRO_APP_STATE__=e}}Bn.activeCount=0;const kn=["Array"],Hn=["getComputedStyle","DOMParser","visualViewport","matchMedia","ResizeObserver","IntersectionObserver"],Fn=[/animationFrame$/i,/mutationObserver$/i,/height$|width$/i,/offset$/i,/selection$/i,/^range/i,/^screen/i,/^scroll/i,/X$|Y$/],jn=["body","head","html","title"],$n=["childElementCount","children","firstElementChild","firstChild","lastElementChild","activeElement","fullscreenElement","pictureInPictureElement","pointerLockElement","styleSheets"],Kn=["append","contains","replaceChildren","createRange","getSelection","elementFromPoint","elementsFromPoint","getAnimations"],qn=["characterSet","compatMode","contentType","designMode","dir","doctype","embeds","fullscreenEnabled","hidden","implementation","lastModified","pictureInPictureEnabled","plugins","readyState","referrer","visibilityState","fonts"],Gn=["execCommand","createRange","exitFullscreen","exitPictureInPicture","getElementsByTagNameNS","hasFocus","prepend"],Qn=["blob:"],zn=window.Worker;const Xn=new Proxy(zn,{construct(e,t){let[n,o]=t;o=o||{};const r=K();let i=n;if(r){i=B(n,eo.get(r).url)}if(i&&!function(e){try{const t=e instanceof URL?e:new URL(e);return!!Qn.includes(t.protocol)||t.protocol===window.location.protocol&&t.hostname===window.location.hostname&&t.port===window.location.port}catch(t){return!1}}(i)){const t=function(e){let t;try{t=new Blob([e],{type:"application/javascript"})}catch(n){const o=new(window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder||window.MSBlobBuilder);o.append(e),t=o.getBlob("application/javascript")}return(window.URL||window.webkitURL).createObjectURL(t)}(`import "${n}";`);return o.type="module",new e(t,o)}return new e(n,o)}});function Vn(e,t,n){return function(e,t,n){const o=fo.rawWindow;Hn.forEach((e=>{t[e]=Lt(o[e],o)})),Object.getOwnPropertyNames(t).filter((e=>(Fn.some((n=>{if(n.test(e)&&e in t.parent){if(g(o[e]))t[e]=Lt(o[e],o);else{const{configurable:n,enumerable:r}=Object.getOwnPropertyDescriptor(t,e)||{configurable:!0,enumerable:!0};n&&a(t,e,{configurable:n,enumerable:r,get:()=>o[e],set:t=>{o[e]=t}})}return!0}return!1})),y(t[e])&&e in o&&!kn.includes(e)&&a(t[e],Symbol.hasInstance,{configurable:!0,enumerable:!1,value:n=>de(n,o[e])||de(n,t[e])}),/^on/.test(e)&&!Ze.includes(e)))).forEach((n=>{const{enumerable:r,writable:i,set:s}=Object.getOwnPropertyDescriptor(t,n)||{enumerable:!0,writable:!0};try{a(t,n,{enumerable:r,configurable:!0,get:()=>o[n],set:(null!=i?i:s)?e=>{o[n]=g(e)?e.bind(t):e}:void 0})}catch(c){D(c,e)}})),n.escapeProperties.forEach((e=>{let n=t[e];a(t,e,{enumerable:!0,configurable:!0,get:()=>null!=n?n:Lt(o[e],o),set(e){n=e}})}))}(e,t,n),function(e,t){const n=fo.rawWindow,o=new Set;Object.defineProperty(e,"Worker",{value:Xn,configurable:!0,writable:!0});const r=new Proxy(e,{get:(e,i)=>"Worker"===i?Xn:"location"===i?t.proxyLocation:N(nt,i)?r:o.has(i)?Reflect.get(e,i):N(t.escapeProperties,i)&&!Reflect.get(e,i)?Lt(Reflect.get(n,i),n):Lt(Reflect.get(e,i),e),set:(e,t,r)=>"location"===t?Reflect.set(n,t,r):(Reflect.has(e,t)||o.add(t),Reflect.set(e,t,r),!0),has:(e,t)=>t in e,deleteProperty:(e,t)=>!Reflect.has(e,t)||Reflect.deleteProperty(e,t)});t.proxyWindow=r}(t,n),function(e){const{rawWindow:t,rawAddEventListener:n,rawRemoveEventListener:o,rawDispatchEvent:r}=fo,i=new Map,s=new Map;function a(n){return Ve.includes(n)?e:t}e.addEventListener=function(e,t,o){const r=i.get(e);r?r.add(t):i.set(e,new Set([t])),t&&(t.__MICRO_APP_MARK_OPTIONS__=o),n.call(a(e),e,t,o)},e.removeEventListener=function(e,t,n){const r=i.get(e);(null==r?void 0:r.size)&&r.has(t)&&r.delete(t),o.call(a(e),e,t,n)},e.dispatchEvent=function(e){return r.call(a(null==e?void 0:e.type),e)};const c=()=>{s.clear()},l=()=>{s.forEach(((t,n)=>{for(const o of t)e.addEventListener(n,o,null==o?void 0:o.__MICRO_APP_MARK_OPTIONS__)})),c()};return{reset:c,record:()=>{i.forEach(((e,t)=>{if(e.size){const n=s.get(t)||[];s.set(t,new Set([...n,...e]))}}))},rebuild:l,release:()=>{i.size&&(i.forEach(((e,t)=>{for(const n of e)o.call(a(t),t,n)})),i.clear())}}}(t)}function Yn(e,t,n){return function(e,t){const n=fo.rawDocument,o=t.Document,r=t.document,i=o.prototype.createElement,s=o.prototype.createElementNS,a=o.prototype.createTextNode,c=o.prototype.createDocumentFragment,l=o.prototype.createComment,u=o.prototype.querySelector,h=o.prototype.querySelectorAll,d=o.prototype.getElementById,m=o.prototype.getElementsByClassName,f=o.prototype.getElementsByTagName,_=o.prototype.getElementsByName,g=o.prototype.elementFromPoint,w=o.prototype.caretRangeFromPoint;function A(t){return X(e),r===t?n:t}function y(t){var o;const i=A(this);if("body"===t)return this.body;if(!t||te(t)||n!==i)return u.call(i,t);const s=null===(o=eo.get(e))||void 0===o?void 0:o.querySelector(t);return s||"base"===t?s:u.call(r,t)}function b(t){var o,i;const s=A(this);if(!t||te(t)||n!==s)return h.call(s,t);const a=null!==(i=null===(o=eo.get(e))||void 0===o?void 0:o.querySelectorAll(t))&&void 0!==i?i:[];return a.length||"base"===t?a:h.call(r,t)}o.prototype.caretRangeFromPoint=function(t,o){const r=g.call(n,t,o),i=w.call(n,t,o);return kt(r,e),i},o.prototype.createElement=function(t,o){let r=i.call(this,t,o);return function(e){let t="[object HTMLElement]"===p(e);if(t){const n=e.tagName.toUpperCase();t=t&&!n.startsWith("MICRO-APP")}return t}(r)&&(r=i.call(n,t,o)),kt(r,e)},o.prototype.createElementNS=function(t,n,o){return kt(s.call(this,t,n,o),e)},o.prototype.createTextNode=function(t){return kt(a.call(this,t),e)},o.prototype.createDocumentFragment=function(){return kt(c.call(this),e)},o.prototype.createComment=function(t){return kt(l.call(this,t),e)},o.prototype.querySelector=y,o.prototype.querySelectorAll=b,o.prototype.getElementById=function(e){const t=A(this);if(ee(e))return d.call(t,e);try{return y.call(this,`#${e}`)}catch(n){return d.call(t,e)}},o.prototype.getElementsByClassName=function(e){const t=A(this);if(ee(e))return m.call(t,e);try{return b.call(this,`.${e}`)}catch(n){return m.call(t,e)}},o.prototype.getElementsByTagName=function(e){const t=A(this);if(te(e)||ee(e))return f.call(t,e);if(/^script$/i.test(e))return f.call(r,e);try{return b.call(this,e)}catch(n){return f.call(t,e)}},o.prototype.getElementsByName=function(e){const t=A(this);if(ee(e))return _.call(t,e);try{return b.call(this,`[name=${e}]`)}catch(n){return _.call(t,e)}}}(e,t),function(e,t,n){const o=fo.rawDocument,r=t.Document,i=t.document,s=(e,t)=>{const{enumerable:n}=Object.getOwnPropertyDescriptor(r.prototype,e)||{enumerable:!0};return{configurable:!0,enumerable:n,get:t}},l=()=>{const t={};return[["documentURI",()=>n.proxyLocation.href],["URL",()=>n.proxyLocation.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")],["microAppElement",()=>{var t;return null===(t=eo.get(e))||void 0===t?void 0:t.container}],["__MICRO_APP_NAME__",()=>e]].forEach((e=>{t[e[0]]=s(e[0],e[1])})),$n.forEach((e=>{t[e]=s(e,(()=>o[e]))})),Kn.forEach((e=>{t[e]=s(e,(()=>Lt(o[e],o,"DOCUMENT")))})),qn.forEach((e=>{t[e]=s(e,(()=>o[e]))})),Gn.forEach((e=>{t[e]=s(e,(()=>Lt(o[e],o,"DOCUMENT")))})),t};c(r.prototype,l()),jn.forEach((t=>{a(i,t,{enumerable:!0,configurable:!0,get:()=>{var r;return X(e),"body"===t&&(null===(r=n.options.container)||void 0===r?void 0:r.querySelector("micro-app-body"))||o[t]},set:e=>{o[t]=e}})}))}(e,t,n),function(e,t){const{rawDocument:n,rawAddEventListener:o,rawRemoveEventListener:r,rawDispatchEvent:i}=fo,s=new Map,c=new Map;let l=null,u=null;const p=t.Document,h=t.document;function d(e,t){return et.includes(e)?t:n}function m(e){return"onclick"===e?e=>{g(l)&&r.call(n,"click",l,!1),g(e)?(l=e.bind(h),o.call(n,"click",l,!1)):l=e}:t=>{n[e]=g(t)?t.bind(h):t}}p.prototype.addEventListener=function(e,t,n){const r=g(t)?t.__MICRO_APP_BOUND_FUNCTION__=t.__MICRO_APP_BOUND_FUNCTION__||t.bind(this):t,i=s.get(e);i?i.add(t):s.set(e,new Set([t])),t&&(t.__MICRO_APP_MARK_OPTIONS__=n),o.call(d(e,this),e,r,n)},p.prototype.removeEventListener=function(e,t,n){const o=s.get(e);(null==o?void 0:o.size)&&o.has(t)&&o.delete(t);const i=(null==t?void 0:t.__MICRO_APP_BOUND_FUNCTION__)||t;r.call(d(e,this),e,i,n)},p.prototype.dispatchEvent=function(e){return i.call(d(null==e?void 0:e.type,this),e)},Object.getOwnPropertyNames(p.prototype).filter((e=>/^on/.test(e)&&!tt.includes(e))).forEach((t=>{const{enumerable:o,writable:r,set:i}=Object.getOwnPropertyDescriptor(p.prototype,t)||{enumerable:!0,writable:!0};try{a(p.prototype,t,{enumerable:o,configurable:!0,get:()=>"onclick"===t?l:n[t],set:(null!=r?r:i)?m(t):void 0})}catch(s){D(s,e)}}));const f=()=>{c.clear(),u=null},_=()=>{u&&!l&&(h.onclick=u),c.forEach(((e,t)=>{for(const n of e)h.addEventListener(t,n,null==n?void 0:n.__MICRO_APP_MARK_OPTIONS__)})),f()};return{reset:f,record:()=>{u=l||u,s.forEach(((e,t)=>{if(e.size){const n=c.get(t)||[];c.set(t,new Set([...n,...e]))}}))},rebuild:_,release:()=>{g(l)&&r.call(n,"click",l),l=null,s.size&&(s.forEach(((e,t)=>{for(const n of e)r.call(d(t,h),t,(null==n?void 0:n.__MICRO_APP_BOUND_FUNCTION__)||n)})),s.clear())}}}(e,t)}function Jn(e,t,o,r){!function(e,t,n){const o=fo.rawRootElement,r=fo.rawRootNode,i=fo.rawDocument,s=t.document,c=t.Node,l=t.Element,u=t.DocumentFragment,h=c.prototype.appendChild,d=c.prototype.insertBefore,m=c.prototype.replaceChild,f=c.prototype.removeChild,_=l.prototype.append,g=l.prototype.prepend,w=u.prototype.append,A=u.prototype.prepend,y=l.prototype.insertAdjacentElement,b=c.prototype.cloneNode,P=Object.getOwnPropertyDescriptor(l.prototype,"innerHTML"),M=Object.getOwnPropertyDescriptor(c.prototype,"parentNode"),C=Object.getOwnPropertyDescriptor(c.prototype,"ownerDocument"),N=e=>(R(e)||function(e){return"[object HTMLBaseElement]"===p(e)}(e))&&e.__PURE_ELEMENT__,O=e=>e===n.microHead?i.head:e===n.microBody?i.body:e;c.prototype.appendChild=function(t){return kt(t,e),N(t)?h.call(this,t):r.prototype.appendChild.call(O(this),t)},c.prototype.insertBefore=function(t,n){return kt(t,e),N(t)?d.call(this,t,n):r.prototype.insertBefore.call(O(this),t,n)},c.prototype.replaceChild=function(t,n){return kt(t,e),N(t)?m.call(this,t,n):r.prototype.replaceChild.call(O(this),t,n)},c.prototype.removeChild=function(e){return N(e)||this.contains(e)?f.call(this,e):r.prototype.removeChild.call(O(this),e)},u.prototype.append=l.prototype.append=function(...e){let t=0,n=!1;for(;t<e.length;)e[t]=E(e[t])?e[t]:s.createTextNode(e[t]),N(e[t])&&(n=!0),t++;return n?(S(this)?w:_).call(this,...e):o.prototype.append.call(O(this),...e)},u.prototype.prepend=l.prototype.prepend=function(...e){let t=0,n=!1;for(;t<e.length;)e[t]=E(e[t])?e[t]:s.createTextNode(e[t]),N(e[t])&&(n=!0),t++;return n?(S(this)?A:g).call(this,...e):o.prototype.prepend.call(O(this),...e)},l.prototype.insertAdjacentElement=function(t,n){return kt(n,e),N(n)?y.call(this,t,n):o.prototype.insertAdjacentElement.call(O(this),t,n)},a(c.prototype,"baseURI",{configurable:!0,enumerable:!0,get:()=>n.proxyWindow.location.href}),a(c.prototype,"ownerDocument",{configurable:!0,enumerable:!0,get(){var e;return this.__PURE_ELEMENT__||this===s?null===(e=C.get)||void 0===e?void 0:e.call(this):s}}),a(c.prototype,"parentNode",Ht(e,M)),c.prototype.getRootNode=function(){return s},c.prototype.cloneNode=function(t){return kt(b.call(this,t),e)},a(l.prototype,"innerHTML",{configurable:!0,enumerable:!0,get(){var e;return null===(e=P.get)||void 0===e?void 0:e.call(this)},set(t){var n;null===(n=P.set)||void 0===n||n.call(this,t),Array.from(this.children).forEach((t=>{v(t)&&kt(t,e)}))}});const D=new Proxy(t.Image,{construct(t,n){const o=new t(...n);return kt(o,e),o}});a(t,"Image",{configurable:!0,writable:!0,value:D})}(e,o,r),function(e,t,o){const r=t.Element,s=r.prototype.setAttribute;r.prototype.setAttribute=function(t,a){var c,l,u,p;if(/^micro-app(-\S+)?/i.test(this.tagName)&&"data"===t&&this.setAttribute!==r.prototype.setAttribute)this.setAttribute(t,a);else{let r=null===(u=null===(l=null===(c=null==Mo?void 0:Mo.options)||void 0===c?void 0:c.plugins)||void 0===l?void 0:l.modules)||void 0===u?void 0:u[o];i(r)||(r=[]);const h=null===(p=r[0])||void 0===p?void 0:p.aHrefResolver;if("href"===t&&/^a$/i.test(this.tagName)&&"function"==typeof h)a=h(a,o,e);else if(("src"===t||"srcset"===t)&&/^(img|script|video|audio|source|embed)$/i.test(this.tagName)||"href"===t&&/^(link|image)$/i.test(this.tagName)||"href"===t&&/^(a)$/i.test(this.tagName)&&!/^#/.test(a)){let o=e;n&&"href"===t&&/^a$/i.test(this.tagName)&&g(Mo.options.excludeAssetFilter)&&Mo.options.excludeAssetFilter(a)&&(o=document.baseURI),a=B(a,o)}s.call(this,t,a)}};const c=[[t.HTMLImageElement.prototype,"src"],[t.HTMLScriptElement.prototype,"src"],[t.HTMLLinkElement.prototype,"href"],[t.SVGImageElement.prototype,"href"]];c.forEach((([t,n])=>{const{enumerable:o,configurable:r,get:i,set:s}=Object.getOwnPropertyDescriptor(t,n)||{enumerable:!0,configurable:!0};a(t,n,{enumerable:o,configurable:r,get:function(){return null==i?void 0:i.call(this)},set:function(t){null==s||s.call(this,B(t,e))}})}))}(t,o,e)}class Zn{constructor(e,t,n){this.active=!1,this.escapeProperties=[],this.updateIframeBase=()=>{var e;null===(e=this.baseElement)||void 0===e||e.setAttribute("href",x(this.url).origin+this.proxyLocation.pathname)},this.appName=e,this.url=t,this.options=n;const o=fo.rawWindow.location,r=o.protocol+"//"+o.host;this.deleteIframeElement=this.createIframeElement(e,r+o.pathname,n),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=fo.rawWindow.history,i=x(t),a=i.protocol+"//"+i.host,l=i.pathname+i.search+i.hash,u=n.history;return n.rawReplaceState=u.replaceState,s(u,_n(e,n.location)),c(u,{scrollRestoration:{configurable:!0,enumerable:!0,get:()=>r.scrollRestoration,set(e){r.scrollRestoration=e}}}),Nn(e,l,n.location,"prevent"),Mn(e,t,n,i,o,a)}(e,t,this.microAppWindow,r),this.windowEffect=Vn(e,this.microAppWindow,this),this.documentEffect=Yn(e,this.microAppWindow,this),Jn(e,t,this.microAppWindow,this),this.initStaticGlobalKeys(e,t,this.microAppWindow),n()}))}createIframeElement(e,t,n){this.iframe=Z("iframe");const o=Object.assign(Object.assign({},null==n?void 0:n.attrs),{id:e,src:Mo.options.iframeSrc||t,style:"display: none","powered-by":"micro-app"});return Object.keys(o).forEach((e=>this.iframe.setAttribute(e,o[e]))),fo.rawDocument.body.appendChild(this.iframe),()=>I((()=>{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,defaultPage:t,disablePatchRequest:n}){this.active||(this.active=!0,this.initRouteState(t),this.removeHistoryListener=dn(this.microAppWindow.__MICRO_APP_NAME__),pn(this.microAppWindow.__MICRO_APP_NAME__)&&(this.microAppWindow.__MICRO_APP_BASE_ROUTE__=this.microAppWindow.__MICRO_APP_BASE_URL__=e),n||this.createIframeBase(),1==++fo.activeSandbox&&(uo(),bn()),++Zn.activeCount)}stop({umdMode:e,keepRouteState:t,destroy:n,clearData:o}){var r;this.active&&(this.recordAndReleaseEffect({clearData:o},!e||n),this.clearRouteState(t),null===(r=this.removeHistoryListener)||void 0===r||r.call(this),e&&!n||(this.deleteIframeElement(),this.clearHijackUmdHooks()),0==--fo.activeSandbox&&(ho(),vn()),--Zn.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__=U(t),n.__MICRO_APP_BASE_ROUTE__="",n.__MICRO_APP_WINDOW__=n,n.__MICRO_APP_PRE_RENDER__=!1,n.__MICRO_APP_UMD_MODE__=!1,n.__MICRO_APP_PROXY_WINDOW__=this.proxyWindow,n.__MICRO_APP_SANDBOX__=this,n.__MICRO_APP_SANDBOX_TYPE__="iframe",n.rawWindow=fo.rawWindow,n.rawDocument=fo.rawDocument,n.microApp=s(new Mt(e),{removeDomScope:J,pureCreateElement:Z,location:this.proxyLocation,router:En})}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(),Ot(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(),Ct(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(),Nt(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&&(Mo.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(i){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=Z("base"),this.updateIframeBase(),this.microHead.appendChild(this.baseElement)}getSpecialProperties(e){var t;w(Mo.options.plugins)&&(this.commonActionForSpecialProperties(Mo.options.plugins.global),this.commonActionForSpecialProperties(null===(t=Mo.options.plugins.modules)||void 0===t?void 0:t[e]))}commonActionForSpecialProperties(e){if(i(e))for(const t of e)w(t)&&i(t.escapeProperties)&&(this.escapeProperties=this.escapeProperties.concat(t.escapeProperties))}initRouteState(e){On(this.microAppWindow.__MICRO_APP_NAME__,this.microAppWindow.location,e)}clearRouteState(e){In(this.microAppWindow.__MICRO_APP_NAME__,this.microAppWindow.__MICRO_APP_URL__,this.microAppWindow.location,e)}setRouteInfoForKeepAliveApp(){Dn(this.microAppWindow.__MICRO_APP_NAME__,this.microAppWindow.location)}removeRouteInfoForKeepAliveApp(){xn(this.microAppWindow.__MICRO_APP_NAME__)}patchStaticElement(e){Bt(e,this.microAppWindow.__MICRO_APP_NAME__)}actionsBeforeExecScripts(e,t){this.patchStaticElement(e),this.clearHijackUmdHooks=this.hijackUmdHooks(this.appName,this.microAppWindow,t)}hijackUmdHooks(e,t,n){let o,r,i;return c(t,{mount:{configurable:!0,get:()=>o,set:e=>{this.active&&g(e)&&!o&&n(o=e,r)}},unmount:{configurable:!0,get:()=>r,set:e=>{this.active&&g(e)&&!r&&n(o,r=e)}},[`micro-app-${e}`]:{configurable:!0,get:()=>i,set:e=>{this.active&&w(e)&&!i&&(i=e,n(i.mount,i.unmount))}}}),()=>{o=r=i=null}}setStaticAppState(e){this.microAppWindow.__MICRO_APP_STATE__=e}}Zn.activeCount=0;const eo=new Map;class to{constructor({name:e,url:t,container:n,scopecss:o,useSandbox:r,inline:i,iframe:s,ssrUrl:a,isPrefetch:c,prefetchLevel:l,routerMode:u,attrs:p}){this.state=De.CREATED,this.keepAliveState=null,this.loadSourceLevel=0,this.umdHookMount=null,this.umdHookUnmount=null,this.umdMode=!1,this.sandBox=null,this.fiber=!1,this.isReloading=!1,eo.set(e,this),this.name=e,this.url=t,this.useSandbox=r,this.scopecss=this.useSandbox&&o,this.attrs=p,this.iframe=null!=s&&s,this.inline=this.getInlineModeState(i),this.isReloading=!1,this.routerMode=u||$e,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(De.LOADING),Ae.getInstance().run(this,vt)}onLoad({html:e,defaultPage:t,routerMode:n,baseroute:o,disablePatchRequest:r}){var i;if(2==++this.loadSourceLevel){if(this.source.html=e,this.isUnmounted())return;if(this.isPrefetch){if(this.isPrerender){const e=Z("div");e.setAttribute("prerender","true"),null===(i=this.sandBox)||void 0===i||i.setPreRenderState(!0),this.mount({container:e,inline:this.inline,fiber:!0,defaultPage:t||"",disablePatchRequest:null!=r&&r,routerMode:n,baseroute:o||""})}}else ne(this.container).mount(this)}}onLoadError(e){this.loadSourceLevel=-1,this.isUnmounted()||(this.onerror(e),this.setAppState(De.LOAD_FAILED))}mount({container:e,inline:t,routerMode:n,defaultPage:o,baseroute:r,disablePatchRequest:i,fiber:s}){if(2!==this.loadSourceLevel)return this.container=e,this.isPrerender=!1,ge(this,"statechange",{appState:De.LOADING}),this.setAppState(De.LOADING);this.createSandbox(),this.setAppState(De.BEFORE_MOUNT);const a=()=>{var a,c,l,u,d,f,_,w;if(this.isPrerender&&(w=this.container,"[object HTMLDivElement]"===p(w))&&this.container.hasAttribute("prerender"))this.container=this.cloneContainer(e,this.container,!1),null===(a=this.sandBox)||void 0===a||a.rebuildEffectSnapshot(),null===(c=this.preRenderEvents)||void 0===c||c.forEach((e=>e())),this.isPrerender=!1,this.preRenderEvents=null,En.attachToURL(this.name),null===(l=this.sandBox)||void 0===l||l.setPreRenderState(!1);else{this.container=e,this.inline=this.getInlineModeState(t),this.fiber=s,this.routerMode=n;const a=()=>{_e(this.container,this.name,Ie.BEFOREMOUNT)};if(this.isPrerender?(null!==(u=this.preRenderEvents)&&void 0!==u?u:this.preRenderEvents=[]).push(a):a(),this.setAppState(De.MOUNTING),ge(this,"statechange",{appState:De.MOUNTING}),this.cloneContainer(this.container,this.source.html,!this.umdMode),null===(d=this.sandBox)||void 0===d||d.start({umdMode:this.umdMode,baseroute:r,defaultPage:o,disablePatchRequest:i}),this.umdMode){null===(_=this.sandBox)||void 0===_||_.rebuildEffectSnapshot();try{this.handleMounted(this.umdHookMount(Mo.getData(this.name,!0)))}catch(A){O("An error occurred when mount \n",this.name,A)}}else null===(f=this.sandBox)||void 0===f||f.actionsBeforeExecScripts(this.container,((e,t)=>{var n;if(!this.umdMode&&!this.isUnmounted()&&(this.umdHookMount=g(e)?e:null,this.umdHookUnmount=g(t)?t:null,g(this.umdHookMount)&&g(this.umdHookUnmount))){null===(n=this.sandBox)||void 0===n||n.markUmdMode(this.umdMode=!0);try{this.getAppState()===De.MOUNTED?this.umdHookMount(Mo.getData(this.name,!0)):this.handleMounted(this.umdHookMount(Mo.getData(this.name,!0)))}catch(A){O("An error occurred when mount \n",this.name,A)}}})),function(e,t){const n=e.fiber?[]:null,o=Array.from(e.source.scripts),r=[],i=[];for(const s of o){const o=We.script.getInfo(s),a=o.appSpace[e.name];a.defer||a.async?(!o.isExternal||o.code||st(e,o)?r.push(o.code):r.push(we(s,e.name)),i.push([s,o]),st(e,o)&&(t.moduleCount=t.moduleCount?++t.moduleCount:1)):le(n,(()=>{wt(s,e,o),t(!1)}))}r.length?k(r,(e=>{const t=i[e.index][1];t.code=t.code||e.data}),(n=>{t.errorCount=t.errorCount?++t.errorCount:1,O(n,e.name)}),(()=>{i.forEach((([o,r])=>{m(r.code)&&le(n,(()=>{wt(o,e,r,t),!st(e,r)&&t(!1)}))})),n?(n.push((()=>Promise.resolve(t(h(t.moduleCount)||t.errorCount===r.length)))),ue(n)):t(h(t.moduleCount)||t.errorCount===r.length)})):n?(n.push((()=>Promise.resolve(t(!0)))),ue(n)):t(!0)}(this,(e=>{this.umdMode||!0!==e||this.handleMounted()}))}};this.sandBox?this.sandBox.sandboxReady.then((()=>!this.isUnmounted()&&a())):a()}handleMounted(e){var t,n;const o=()=>{const t=()=>this.actionsAfterMounted();A(e)?e.then(t).catch((e=>{O("An error occurred in window.mount \n",this.name,e),t()})):t()};this.isPrerender?(null===(t=this.preRenderEvents)||void 0===t||t.push(o),null===(n=this.sandBox)||void 0===n||n.recordAndReleaseEffect({isPrerender:!0})):o()}actionsAfterMounted(){var e;this.isUnmounted()||(this.setAppState(De.MOUNTED),he(this.getMicroAppGlobalHook(xe.ONMOUNT),this.name,xe.ONMOUNT,Mo.getData(this.name,!0)),ge(this,"statechange",{appState:De.MOUNTED}),ge(this,"mounted"),_e(this.container,this.name,Ie.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===De.LOAD_FAILED,this.setAppState(De.UNMOUNT);try{this.handleUnmounted(e,t,n,o,null===(r=this.umdHookUnmount)||void 0===r?void 0:r.call(this,Mo.getData(this.name,!0)))}catch(i){O("An error occurred when unmount \n",this.name,i)}}handleUnmounted(e,t,n,o,r){ge(this,"statechange",{appState:De.UNMOUNT}),ge(this,"unmount"),he(this.getMicroAppGlobalHook(xe.ONUNMOUNT),this.name,xe.ONUNMOUNT);const i=()=>this.actionsAfterUnmounted({destroy:e,clearData:t,keepRouteState:n,unmountcb:o});A(r)?(J(),r.then(i).catch((e=>{O("An error occurred in window.unmount \n",this.name,e),i()}))):i()}actionsAfterUnmounted({destroy:e,clearData:t,keepRouteState:n,unmountcb:o}){var r;this.umdMode&&this.container&&!e&&this.cloneContainer(this.source.html,this.container,!1);const i=!this.isReloading&&(t||e);null===(r=this.sandBox)||void 0===r||r.stop({umdMode:this.umdMode,keepRouteState:n&&!e,destroy:e,clearData:i}),_e(this.container,this.name,Ie.UNMOUNT),this.clearOptions(e),null==o||o()}clearOptions(e){var t,n;this.isPrerender=!1,this.preRenderEvents=null,this.setKeepAliveState(null),this.container?(this.container.innerHTML="",this.container=null):this.umdMode||null===(n=null===(t=this.sandBox)||void 0===t?void 0:t.deleteIframeElement)||void 0===n||n.call(t),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),We.script.deleteInlineInfo(this.source.scripts),eo.delete(this.name)}hiddenKeepAliveApp(e){var t,n;this.setKeepAliveState(Te.KEEP_ALIVE_HIDDEN),ge(this,"appstate-change",{appState:"afterhidden"}),_e(this.container,this.name,Ie.AFTERHIDDEN),an(this.name)&&(null===(t=this.sandBox)||void 0===t||t.removeRouteInfoForKeepAliveApp()),2!==this.loadSourceLevel?ne(this.container).unmount():(this.container=this.cloneContainer(Z("div"),this.container,!1),null===(n=this.sandBox)||void 0===n||n.recordAndReleaseEffect({keepAlive:!0})),null==e||e()}showKeepAliveApp(e){var t,n;const o=this.container;this.container=e,null===(t=this.sandBox)||void 0===t||t.rebuildEffectSnapshot(),ge(this,"appstate-change",{appState:"beforeshow"}),_e(e,this.name,Ie.BEFORESHOW),this.setKeepAliveState(Te.KEEP_ALIVE_SHOW),this.cloneContainer(this.container,o,!1),an(this.name)&&(null===(n=this.sandBox)||void 0===n||n.setRouteInfoForKeepAliveApp()),ge(this,"appstate-change",{appState:"aftershow"}),_e(this.container,this.name,Ie.AFTERSHOW)}onerror(e){ge(this,"statechange",{appState:De.LOAD_FAILED}),_e(this.container,this.name,Ie.ERROR,e)}parseHtmlString(e){var t;return(new((null===(t=this.sandBox)||void 0===t?void 0:t.proxyWindow)?this.sandBox.proxyWindow.DOMParser:fo.rawWindow.DOMParser)).parseFromString(e,"text/html").body}cloneContainer(e,t,n){return t&&e&&(e.innerHTML="",Array.from(n?this.parseHtmlString(t.innerHTML).childNodes:t.childNodes).forEach((t=>{e.appendChild(t)}))),e}createSandbox(){if(this.useSandbox&&!this.sandBox){const e={attrs:this.attrs,container:this.container};this.sandBox=this.iframe?new Zn(this.name,this.url,e):new Bn(this.name,this.url)}}setAppState(e){var t;this.state=e,null===(t=this.sandBox)||void 0===t||t.setStaticAppState(e)}getAppState(){return this.state}setKeepAliveState(e){this.keepAliveState=e}getKeepAliveState(){return this.keepAliveState}isUnmounted(){return De.UNMOUNT===this.state}isHidden(){return Te.KEEP_ALIVE_HIDDEN===this.keepAliveState}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 g(o)?o:null}querySelector(e){return this.container?fo.rawElementQuerySelector.call(this.container,e):null}querySelectorAll(e){return this.container?fo.rawElementQuerySelectorAll.call(this.container,e):[]}getInlineModeState(e){var t;return null!==(t=this.iframe||e)&&void 0!==t&&t}}function no(e){var t,n;return null!==(n=null===(t=eo.get(e))||void 0===t?void 0:t.iframe)&&void 0!==n&&n}const oo=new WeakMap;function ro(e){var t;return null!==(t=oo.get(e))&&void 0!==t?t:e}function io(e,t){if(oo.has(e))return oo.get(e);if(P(e)){if(e.hasAttribute("exclude")){const t=document.createComment("style element with exclude attribute ignored by micro-app");return oo.set(e,t),t}return t.scopecss&&!e.hasAttribute("ignore")?Re(e,t):e}if("[object HTMLLinkElement]"===p(e)){if(e.hasAttribute("exclude")||ft(e.getAttribute("href"),t.name)){const t=document.createComment("link element with exclude attribute ignored by micro-app");return oo.set(e,t),t}if(e.hasAttribute("ignore")||_t(e.getAttribute("href"),t.name)||e.href&&g(Mo.options.excludeAssetFilter)&&Mo.options.excludeAssetFilter(e.href))return e;const{address:n,linkInfo:o,replaceComment:r}=Ue(e,null,t,!0);if(n&&o){const r=function(e,t,n,o){const r=Z("style"),i=()=>{ke(t,e,r,n,n.appSpace[t.name].attrs),Ce(o)};return n.code?I(i):we(e,t.name).then((e=>{n.code=e,i()})).catch((e=>{O(e,t.name),Ne(o)})),r}(n,t,o,e);return oo.set(e,r),r}return r?(oo.set(e,r),r):e}if(R(e)){if(e.src&&g(Mo.options.excludeAssetFilter)&&Mo.options.excludeAssetFilter(e.src))return e;const{replaceComment:n,address:o,scriptInfo:r}=dt(e,null,t,!0)||{};if(o&&r){const n=r.isExternal?function(e,t,n,o){const r=at(t,n)?Z("script"):document.createComment(`dynamic script with src='${e}' extract by micro-app`),i=()=>Ce(o),s=()=>{const s=Object.getOwnPropertyDescriptor(fo.rawDocument,"currentScript");s&&!s.configurable||Object.defineProperty(fo.rawDocument,"currentScript",{value:o,configurable:!0}),wt(e,t,n,i,r),!st(t,n)&&i()};return n.code||st(t,n)?I(s):we(e,t.name).then((e=>{n.code=e,s()})).catch((e=>{O(e,t.name),Ne(o)})),r}(o,t,r,e):function(e,t,n){const o=at(t,n)?Z("script"):document.createComment("dynamic inline script extract by micro-app");return wt(e,t,n,void 0,o),o}(o,t,r);return oo.set(e,n),n}return n?(oo.set(e,n),n):e}return e}function so(e,t,n,o,r){const i=ao(n,o,e);if(i){if(!no(e.name)&&M(i)&&t!==fo.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=fo.rawParentNodeDesc.get.call(this);return M(o)&&e.container?(null===(n=(t=Mo.options).getRootElementParentNode)||void 0===n?void 0:n.call(t,this,e.name))||document.body:o}},__MICRO_APP_HAS_DPN__:{configurable:!0,get:()=>!0}})}if(r&&!i.contains(r)){if(t===fo.rawInsertBefore&&n.contains(r)){const s=Array.from(n.childNodes).indexOf(r);if(i.childNodes[s])return co(t,i,o,i.childNodes[s],e)}return fo.rawAppendChild.call(i,o)}return t!==fo.rawRemoveChild||i.contains(o)?co(t,i,o,r,e):n.contains(o)?t.call(o.parentElement,o):o}return co(t,n,o,r,e)}function ao(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 co(e,t,n,o,r){return(i=e)===fo.rawAppend||i===fo.rawPrepend||i===fo.rawFragmentAppend||i===fo.rawFragmentPrepend?((null==r?void 0:r.iframe)&&R(n)&&(e===fo.rawFragmentAppend?e=fo.rawAppend:e===fo.rawFragmentPrepend&&(e=fo.rawPrepend)),e.call(t,n)):e.call(t,n,o);var i}function lo(e,t,n,o){const r=K();if(E(t)&&!t.__PURE_ELEMENT__&&(t.__MICRO_APP_NAME__||r)){kt(t,t.__MICRO_APP_NAME__||r);const i=eo.get(t.__MICRO_APP_NAME__);if(null==i?void 0:i.container)return P(t)&&e.getRootNode()instanceof ShadowRoot&&t.setAttribute("ignore","true"),function(e,t){v(t)&&(/^(img|script)$/i.test(t.tagName)?(t.hasAttribute("src")&&fo.rawSetAttribute.call(t,"src",B(t.getAttribute("src"),e.url)),t.hasAttribute("srcset")&&fo.rawSetAttribute.call(t,"srcset",B(t.getAttribute("srcset"),e.url))):(/^(link|image)$/i.test(t.tagName)&&t.hasAttribute("href")||/^(a)$/i.test(t.tagName)&&t.hasAttribute("href")&&!/^#/.test(t.getAttribute("href")||""))&&fo.rawSetAttribute.call(t,"href",B(t.getAttribute("href"),e.url)))}(i,t),so(i,o,e,io(t,i),n&&ro(n))}return co(o,e,t,n)}function uo(){!function(){const e=fo.rawDocument,t=fo.rawRootDocument;function n(t){return function(e){return"[object ProxyDocument]"===p(e)}(t)?e:t}function o(t){var o,r;const i=n(this),s=K();return s&&t&&!te(t)&&e===i?null!==(r=null===(o=eo.get(s))||void 0===o?void 0:o.querySelector(t))&&void 0!==r?r:null:fo.rawQuerySelector.call(i,t)}function r(t){var o,r;const i=n(this),s=K();return s&&t&&!te(t)&&e===i?null!==(r=null===(o=eo.get(s))||void 0===o?void 0:o.querySelectorAll(t))&&void 0!==r?r:[]:fo.rawQuerySelectorAll.call(i,t)}t.prototype.createElement=function(e,t){return po(fo.rawCreateElement.call(n(this),e,t))},t.prototype.createElementNS=function(e,t,o){return po(fo.rawCreateElementNS.call(n(this),e,t,o))},t.prototype.createDocumentFragment=function(){return po(fo.rawCreateDocumentFragment.call(n(this)))},t.prototype.createComment=function(e){return po(fo.rawCreateComment.call(n(this),e))},t.prototype.querySelector=o,t.prototype.querySelectorAll=r,t.prototype.getElementById=function(e){const t=n(this);if(!K()||ee(e))return fo.rawGetElementById.call(t,e);try{return o.call(t,`#${e}`)}catch(r){return fo.rawGetElementById.call(t,e)}},t.prototype.getElementsByClassName=function(e){const t=n(this);if(!K()||ee(e))return fo.rawGetElementsByClassName.call(t,e);try{return r.call(t,`.${e}`)}catch(o){return fo.rawGetElementsByClassName.call(t,e)}},t.prototype.getElementsByTagName=function(e){var t;const o=n(this),i=K();if(!i||te(e)||ee(e)||!(null===(t=eo.get(i))||void 0===t?void 0:t.inline)&&/^script$/i.test(e))return fo.rawGetElementsByTagName.call(o,e);try{return r.call(o,e)}catch(s){return fo.rawGetElementsByTagName.call(o,e)}},t.prototype.getElementsByName=function(e){const t=n(this);if(!K()||ee(e))return fo.rawGetElementsByName.call(t,e);try{return r.call(t,`[name=${e}]`)}catch(o){return fo.rawGetElementsByName.call(t,e)}}}();const e=fo.rawRootElement,t=fo.rawRootNode,n=fo.rawDocumentFragment;function o(e){const t=z()||K();if((e===document.body||e===document.head)&&t){const n=eo.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 e}function r(e,t,n,o,r){if(e){const e=z()||K();if(e&&no(e)){const n=eo.get(e);if(v(i=t)&&"MICRO-APP-HEAD"===i.tagName.toUpperCase())return n.sandBox.microHead[r](o);if(M(t))return n.sandBox.microBody[r](o)}}var i;return n}t.prototype.appendChild=function(e){return lo(this,e,null,fo.rawAppendChild)},t.prototype.insertBefore=function(e,t){return lo(this,e,t,fo.rawInsertBefore)},t.prototype.replaceChild=function(e,t){return lo(this,e,t,fo.rawReplaceChild)},t.prototype.removeChild=function(e){if(null==e?void 0:e.__MICRO_APP_NAME__){const n=eo.get(e.__MICRO_APP_NAME__);if(null==n?void 0:n.container)return so(n,fo.rawRemoveChild,this,ro(e));try{return fo.rawRemoveChild.call(this,e)}catch(t){return(null==e?void 0:e.parentNode)&&fo.rawRemoveChild.call(e.parentNode,e)}}return fo.rawRemoveChild.call(this,e)},n.prototype.append=e.prototype.append=function(...e){let t=0;for(;t<e.length;){let n=e[t];n=E(n)?n:fo.rawCreateTextNode.call(fo.rawDocument,n),lo(this,po(n),null,S(this)?fo.rawFragmentAppend:fo.rawAppend),t++}},n.prototype.prepend=e.prototype.prepend=function(...e){let t=e.length,n=fo.rawPrepend;for((S(this)||function(e){return"[object ShadowRoot]"===p(e)}(this))&&(n=fo.rawFragmentPrepend);t>0;){let o=e[t-1];o=E(o)?o:fo.rawCreateTextNode.call(fo.rawDocument,o),lo(this,po(o),null,n),t--}},e.prototype.insertAdjacentElement=function(e,t){var n;if((null==t?void 0:t.__MICRO_APP_NAME__)&&v(t)){const o=eo.get(t.__MICRO_APP_NAME__);if(null==o?void 0:o.container){const r=io(t,o);if(!v(r))return t;const i=null!==(n=ao(this,r,o))&&void 0!==n?n:this;return fo.rawInsertAdjacentElement.call(i,e,r)}}return fo.rawInsertAdjacentElement.call(this,e,t)},e.prototype.querySelector=function(e){var t;const n=null!==(t=o(this))&&void 0!==t?t:this,i=fo.rawElementQuerySelector.call(n,e);return r(d(i)&&n!==this,n,i,e,"querySelector")},e.prototype.querySelectorAll=function(e){var t;const n=null!==(t=o(this))&&void 0!==t?t:this,i=fo.rawElementQuerySelectorAll.call(n,e);return r(!i.length&&n!==this,n,i,e,"querySelectorAll")},e.prototype.setAttribute=function(t,n){var o;if(/^micro-app(-\S+)?/i.test(this.tagName)&&"data"===t&&this.setAttribute!==e.prototype.setAttribute)this.setAttribute(t,n);else{const e=this.__MICRO_APP_NAME__||K();if(e&&eo.has(e)&&(("src"===t||"srcset"===t)&&/^(img|script|video|audio|source|embed)$/i.test(this.tagName)||"href"===t&&/^(link|image)$/i.test(this.tagName)||"href"===t&&/^(a)$/i.test(this.tagName)&&!/^#/.test(n))){n=B(n,eo.get(e).url)}if(fo.rawSetAttribute.call(this,t,n),"[object HTMLImageElement]"===p(this)||function(e){return"[object HTMLVideoElement]"===p(e)}(this)||function(e){return"[object HTMLAudioElement]"===p(e)}(this)){let e=!1;(null===(o=null==Mo?void 0:Mo.options)||void 0===o?void 0:o.includeCrossOrigin)&&g(Mo.options.includeCrossOrigin)&&(e=Mo.options.includeCrossOrigin(n)),e&&(node.crossOrigin="anonymous")}}},a(t.prototype,"parentNode",{configurable:!0,enumerable:!0,get(){var e,t,n;const o=z()||K();if(o&&this===fo.rawDocument.firstElementChild){const r=null===(n=null===(t=null===(e=eo.get(o))||void 0===e?void 0:e.sandBox)||void 0===t?void 0:t.proxyWindow)||void 0===n?void 0:n.document;if(r)return r}return fo.rawParentNodeDesc.get.call(this)}}),a(e.prototype,"innerHTML",{configurable:!0,enumerable:!0,get(){return fo.rawInnerHTMLDesc.get.call(this)},set(e){fo.rawInnerHTMLDesc.set.call(this,e);const t=this.__MICRO_APP_NAME__||z()||K();Array.from(this.children).forEach((e=>{v(e)&&t&&kt(e,t)}))}}),t.prototype.cloneNode=function(e){return kt(fo.rawCloneNode.call(this,e),this.__MICRO_APP_NAME__)}}function po(e){return kt(e,K())}function ho(){J(),function(){const e=fo.rawRootDocument;e.prototype.createElement=fo.rawCreateElement,e.prototype.createElementNS=fo.rawCreateElementNS,e.prototype.createDocumentFragment=fo.rawCreateDocumentFragment,e.prototype.querySelector=fo.rawQuerySelector,e.prototype.querySelectorAll=fo.rawQuerySelectorAll,e.prototype.getElementById=fo.rawGetElementById,e.prototype.getElementsByClassName=fo.rawGetElementsByClassName,e.prototype.getElementsByTagName=fo.rawGetElementsByTagName,e.prototype.getElementsByName=fo.rawGetElementsByName}();const e=fo.rawRootElement,t=fo.rawRootNode;t.prototype.appendChild=fo.rawAppendChild,t.prototype.insertBefore=fo.rawInsertBefore,t.prototype.replaceChild=fo.rawReplaceChild,t.prototype.removeChild=fo.rawRemoveChild,t.prototype.cloneNode=fo.rawCloneNode,e.prototype.append=fo.rawAppend,e.prototype.prepend=fo.rawPrepend,e.prototype.querySelector=fo.rawElementQuerySelector,e.prototype.querySelectorAll=fo.rawElementQuerySelectorAll,e.prototype.setAttribute=fo.rawSetAttribute,a(t.prototype,"parentNode",fo.rawParentNodeDesc),a(e.prototype,"innerHTML",fo.rawInnerHTMLDesc)}let mo=!1;const fo={activeSandbox:0};function _o(){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=e.DocumentFragment,c=r.prototype.appendChild,l=r.prototype.insertBefore,u=r.prototype.replaceChild,p=r.prototype.removeChild,h=o.prototype.setAttribute,d=o.prototype.append,m=o.prototype.prepend,f=a.prototype.append,_=a.prototype.prepend,g=r.prototype.cloneNode,w=o.prototype.querySelector,A=o.prototype.querySelectorAll,y=o.prototype.insertAdjacentElement,b=Object.getOwnPropertyDescriptor(o.prototype,"innerHTML"),v=Object.getOwnPropertyDescriptor(r.prototype,"parentNode"),E=n.prototype.createElement,P=n.prototype.createElementNS,R=n.prototype.createTextNode,S=n.prototype.createDocumentFragment,M=n.prototype.createComment,C=n.prototype.querySelector,N=n.prototype.querySelectorAll,O=n.prototype.getElementById,D=n.prototype.getElementsByClassName,I=n.prototype.getElementsByTagName,x=n.prototype.getElementsByName,T=new Proxy(e.Image,{construct:(e,t)=>kt(new e(...t),K())}),L=e.setInterval,W=e.setTimeout,U=e.clearInterval,B=e.clearTimeout,k=e.history.pushState,H=e.history.replaceState,F=i.prototype.addEventListener,j=i.prototype.removeEventListener,$=i.prototype.dispatchEvent;window.__MICRO_APP_BASE_APPLICATION__=!0,s(fo,{supportModuleScript:"noModule"in document.createElement("script"),rawWindow:e,rawDocument:t,rawRootDocument:n,rawRootElement:o,rawRootNode:r,rawDocumentFragment:a,rawSetAttribute:h,rawAppendChild:c,rawInsertBefore:l,rawReplaceChild:u,rawRemoveChild:p,rawAppend:d,rawPrepend:m,rawFragmentAppend:f,rawFragmentPrepend:_,rawCloneNode:g,rawElementQuerySelector:w,rawElementQuerySelectorAll:A,rawInsertAdjacentElement:y,rawInnerHTMLDesc:b,rawParentNodeDesc:v,rawCreateElement:E,rawCreateElementNS:P,rawCreateDocumentFragment:S,rawCreateTextNode:R,rawCreateComment:M,rawQuerySelector:C,rawQuerySelectorAll:N,rawGetElementById:O,rawGetElementsByClassName:D,rawGetElementsByTagName:I,rawGetElementsByName:x,ImageProxy:T,rawSetInterval:L,rawSetTimeout:W,rawClearInterval:U,rawClearTimeout:B,rawPushState:k,rawReplaceState:H,rawAddEventListener:F,rawRemoveEventListener:j,rawDispatchEvent:$}),function(){if(!mo){mo=!0;const e=Z("style");fo.rawSetAttribute.call(e,"type","text/css"),e.textContent=`\n${Mo.tagName}, micro-app-body { display: block; } \nmicro-app-head { display: none; }`,fo.rawDocument.head.appendChild(e)}}()}}function go(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=()=>{this.isWaiting=!1;const e=W(this.getAttribute("name")),t=L(this.getAttribute("url"),this.appName);if(this.legalAttribute("name",e)&&this.legalAttribute("url",t)){const n=eo.get(e);if(e!==this.appName&&n&&!n.isUnmounted()&&!n.isHidden()&&!n.isPrefetch)return this.setAttribute("name",this.appName),O(`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(){Object.getPrototypeOf(this)!==n.prototype&&Object.setPrototypeOf(this,n.prototype);const e=++this.connectedCount;this.connectStateMap.set(e,!0);const t=this.appName&&this.appUrl;I((()=>{this.connectStateMap.get(e)&&(_e(this,this.appName,Ie.CREATED),t&&this.handleConnected())}))}disconnectedCallback(){this.connectStateMap.set(this.connectedCount,!1),this.handleDisconnected()}reload(e){return new Promise((t=>{const n=()=>{this.removeEventListener(Ie.MOUNTED,n),this.removeEventListener(Ie.AFTERSHOW,n),t(!0)};this.addEventListener(Ie.MOUNTED,n),this.addEventListener(Ie.AFTERSHOW,n),this.handleDisconnected(e,(()=>{this.handleConnected()}))}))}handleDisconnected(e=!1,t){const n=eo.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===Oe.NAME?"appName":"appUrl"]!==n)if(e!==Oe.URL||this.appUrl&&this.connectStateMap.get(this.connectedCount))if(e!==Oe.NAME||this.appName&&this.connectStateMap.get(this.connectedCount))this.isWaiting||(this.isWaiting=!0,I(this.handleAttributeUpdate));else{const e=W(n);if(!e)return O(`Invalid attribute name ${n}`,this.appName);this.cacheData&&(Mo.setData(e,this.cacheData),this.cacheData=null),this.appName=e,e!==n&&this.setAttribute("name",this.appName),this.handleInitialNameAndUrl()}else{if(!(n=L(n,this.appName)))return O(`Invalid attribute url ${n}`,this.appName);this.appUrl=n,this.handleInitialNameAndUrl()}}handleInitialNameAndUrl(){this.connectStateMap.get(this.connectedCount)&&this.handleConnected()}handleConnected(){if(this.appName&&this.appUrl)if(this.getDisposeResult("shadowDOM")&&!this.shadowRoot&&g(this.attachShadow)&&this.attachShadow({mode:"open"}),this.updateSsrUrl(this.appUrl),eo.has(this.appName)){const e=eo.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():O(`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):O(`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!(!m(t)||!t)||(O(`unexpected attribute ${e}, please check again`,this.appName),!1)}handleCreateApp(){const e={};Array.prototype.slice.call(this.attributes).forEach((({name:t,value:n})=>{t.startsWith("data-")&&(e[t]=n)}));const t=()=>{var t;return new to({name:this.appName,url:this.appUrl,container:null!==(t=this.shadowRoot)&&void 0!==t?t:this,scopecss:this.useScopecss(),useSandbox:this.useSandbox(),inline:this.getDisposeResult("inline"),iframe:this.getDisposeResult("iframe"),ssrUrl:this.ssrUrl,routerMode:this.getMemoryRouterMode(),attrs:e})},n=eo.get(this.appName);n?n.isPrerender?this.unmount(!0,t):(n.actionsForCompletelyDestroy(),t()):t()}handleMount(e){e.isPrefetch=!1,e.setAppState(De.BEFORE_MOUNT),I((()=>this.mount(e)))}mount(e){var t;e.mount({container:null!==(t=this.shadowRoot)&&void 0!==t?t:this,inline:this.getDisposeResult("inline"),routerMode:this.getMemoryRouterMode(),baseroute:this.getBaseRouteCompatible(),defaultPage:this.getDefaultPage(),disablePatchRequest:this.getDisposeResult("disable-patch-request"),fiber:this.getDisposeResult("fiber")})}unmount(e,t){const n=eo.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=eo.get(this.appName);!t||t.isUnmounted()||t.isHidden()||t.hiddenKeepAliveApp(e)}handleShowKeepAliveApp(e){I((()=>{var t;return e.showKeepAliveApp(null!==(t=this.shadowRoot)&&void 0!==t?t:this)}))}getDisposeResult(e){return(this.compatibleProperties(e)||!!Mo.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=fo.rawWindow.location;this.ssrUrl=B(t.pathname+t.search,e)}else{let t=function(e,t){const n=tn(e);if(!n)return"";const o=x(n,t);return o.origin+o.pathname+o.search}(this.appName,e);const n=this.getDefaultPage();if(!t&&n){const o=x(n,e);t=o.origin+o.pathname+o.search}this.ssrUrl=t}else this.ssrUrl&&(this.ssrUrl="")}getDefaultPage(){return En.getDefaultPage(this.appName)||this.getAttribute("default-page")||this.getAttribute("defaultPage")||""}getMemoryRouterMode(){return hn(this.getAttribute("router-mode"),this.compatibleProperties("disable-memory-router")&&this.compatibleDisableProperties("disable-memory-router"))}setAttribute(e,t){if("data"===e)if(w(t)){const e={};Object.getOwnPropertyNames(t).forEach((n=>{m(n)&&0===n.indexOf("__")||(e[n]=t[n])})),this.data=e}else"[object Object]"!==t&&D("property data must be an object",this.appName);else fo.rawSetAttribute.call(this,e,t)}getRouterEventDelay(){let e=parseInt(this.getAttribute("router-event-delay"));return isNaN(e)&&(e=parseInt(g(Mo.options["router-event-delay"])?Mo.options["router-event-delay"](this.appName):Mo.options["router-event-delay"])),isNaN(e)?0:e}set data(e){this.appName?Mo.setData(this.appName,e):this.cacheData=e}get data(){return this.appName?Mo.getData(this.appName,!0):this.cacheData?this.cacheData:null}get publicPath(){return U(this.appUrl)}get baseRoute(){return this.getBaseRouteCompatible()}}window.customElements.define(e,n)}function wo(e,t){if(!n)return O("preFetch is only supported in browser environment");H((()=>{const n=_(t)?t:Mo.options.prefetchDelay;setTimeout((()=>{!function(e){g(e)&&(e=e()),i(e)&&e.reduce(((e,t)=>e.then((()=>{return e=t,F((t=>{var n,o,r,i,a,c;if(w(e)&&navigator.onLine)if(e.name=W(e.name),e.url=L(e.url,e.name),e.name&&e.url&&!eo.has(e.name)){const l=new to({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:Mo.options["disable-scopecss"]),useSandbox:!(null!==(i=null!==(r=e["disable-sandbox"])&&void 0!==r?r:e.disableSandbox)&&void 0!==i?i:Mo.options["disable-sandbox"]),inline:null!==(a=e.inline)&&void 0!==a?a:Mo.options.inline,iframe:null!==(c=e.iframe)&&void 0!==c?c:Mo.options.iframe,prefetchLevel:e.level&&Fe.includes(e.level)?e.level:Mo.options.prefetchLevel&&Fe.includes(Mo.options.prefetchLevel)?Mo.options.prefetchLevel:2}),u=l.onLoad,p=l.onLoadError;l.onLoad=n=>{l.isPrerender&&s(n,{defaultPage:e["default-page"],routerMode:hn(e["router-mode"]),baseroute:e.baseroute,disablePatchRequest:e["disable-patch-request"]}),t(),u.call(l,n)},l.onLoadError=(...e)=>{t(),p.call(l,...e)}}else t();else t()}));var e}))),Promise.resolve())}(e)}),_(n)?n:3e3)}))}function Ao(e,t,n){if(i(e)){const o=e.filter((e=>m(e)&&C(e,t)&&!n.hasInfo(e)));k(o.map((e=>we(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=>{O(e)}))}}function yo({excludeHiddenApp:e=!1,excludePreRender:t=!1}={}){const n=[];return eo.forEach(((o,r)=>{o.isUnmounted()||o.isPrefetch&&(!o.isPrerender||t)||e&&o.isHidden()||n.push(r)})),n}function bo(){return Array.from(eo.keys())}function vo(e,t){const n=eo.get(W(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=ne(n.container),r=()=>{e.removeEventListener(Ie.UNMOUNT,r),e.removeEventListener(Ie.AFTERHIDDEN,i),o(!0)},i=()=>{e.removeEventListener(Ie.UNMOUNT,r),e.removeEventListener(Ie.AFTERHIDDEN,i),o(!0)};if(e.addEventListener(Ie.UNMOUNT,r),e.addEventListener(Ie.AFTERHIDDEN,i),null==t?void 0:t.destroy){let t,n;e.hasAttribute("destroy")&&(t=e.getAttribute("destroy")),e.hasAttribute("destory")&&(n=e.getAttribute("destory")),e.setAttribute("destroy","true"),e.parentNode.removeChild(e),e.removeAttribute("destroy"),m(t)&&e.setAttribute("destroy",t),m(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),m(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),m(n)&&e.setAttribute("clear-data",n)}}else D(`app ${e} does not exist when unmountApp`),o(!1)}))}function Eo(e){return Array.from(eo.keys()).reduce(((t,n)=>t.then((()=>vo(n,e)))),Promise.resolve(!0))}function Po(e,t){return new Promise((n=>{const o=eo.get(W(e));if(o){const r=o.container&&ne(o.container);if(r){const i=Mo.getData(e);o.isReloading=!0,r.reload(t).then((()=>{i&&Mo.setData(e,i),o.isReloading=!1,n(!0)}))}else D(`app ${e} is not rendered, cannot use reload`),n(!1)}else D(`app ${e} does not exist when reload app`),n(!1)}))}function Ro(e){return new Promise((t=>{if(!w(e))return O("renderApp options must be an object");const n=v(e.container)?e.container:m(e.container)?document.querySelector(e.container):null;if(!v(n))return O("Target container is not a DOM element.");const o=Z(Mo.tagName);for(const a in e)if("onDataChange"===a)g(e[a])&&o.addEventListener("datachange",e[a]);else if("lifeCycles"===a){const t=e[a];if(w(t))for(const e in t)e.toUpperCase()in Ie&&g(t[e])&&o.addEventListener(e.toLowerCase(),t[e])}else"container"!==a&&o.setAttribute(a,e[a]);const r=()=>{s(),t(!0)},i=()=>{s(),t(!1)},s=()=>{o.removeEventListener(Ie.MOUNTED,r),o.removeEventListener(Ie.ERROR,i)};o.addEventListener(Ie.MOUNTED,r),o.addEventListener(Ie.ERROR,i),n.appendChild(o)}))}class So extends St{constructor(){super(...arguments),this.tagName="micro-app",this.hasInit=!1,this.options={},this.router=En,this.preFetch=wo,this.unmountApp=vo,this.unmountAllApps=Eo,this.getActiveApps=yo,this.getAllApps=bo,this.reload=Po,this.renderApp=Ro}start(e){var t,o,r;if(!n||!window.customElements)return O("micro-app is not supported in this environment");if(this.hasInit)return O("microApp.start executed repeatedly");if(this.hasInit=!0,null==e?void 0:e.tagName){if(!/^micro-app(-\S+)?/.test(e.tagName))return O(`${e.tagName} is invalid tagName`);this.tagName=e.tagName}if(_o(),window.customElements.get(this.tagName))return D(`element ${this.tagName} is already defined`);if(w(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&&wo(e.preFetchApps),e.globalAssets&&(w(r=e.globalAssets)&&H((()=>{Ao(r.js,"js",We.script),Ao(r.css,"css",We.link)}))),w(e.plugins))){const t=e.plugins.modules;if(w(t))for(const e in t){const n=W(e);n&&e!==n&&(t[n]=t[e],delete t[e])}}go(this.tagName)}}const Mo=new So;e.EventCenterForMicroApp=Mt,e.MicroApp=So,e.default=Mo,e.getActiveApps=yo,e.getAllApps=bo,e.preFetch=wo,e.pureCreateElement=Z,e.reload=Po,e.removeDomScope=J,e.renderApp=Ro,e.unmountAllApps=Eo,e.unmountApp=vo,e.version=t,Object.defineProperty(e,"__esModule",{value:!0})}));
|
|
2
2
|
//# sourceMappingURL=index.umd.js.map
|