@micro-zoe/micro-app
Version:
A lightweight, efficient and powerful micro front-end framework
1 lines • 115 kB
JavaScript
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const e="1.0.0-rc.27",t="undefined"!=typeof window,n="undefined"!=typeof global?global:"undefined"!=typeof window?window:"undefined"!=typeof self?self:Function("return this")(),o=()=>!1,r=Array.isArray,i=Object.assign,s=Object.defineProperty,a=Object.defineProperties,c=Object.prototype.toString,l=Object.prototype.hasOwnProperty,u=e=>c.call(e);function p(e){return void 0===e}function h(e){return null===e}function d(e){return"string"==typeof e}function m(e){return"boolean"==typeof e}function f(e){return"number"==typeof e}function _(e){return"function"==typeof e}function g(e){return"[object Object]"===u(e)}function w(e){return"[object Promise]"===u(e)}function A(e){var t;if(_(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 y(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||f(null===(t=e)||void 0===t?void 0:t.nodeType)}function E(e){return"[object HTMLStyleElement]"===u(e)}function P(e){return"[object HTMLScriptElement]"===u(e)}function R(e){return"[object DocumentFragment]"===u(e)}function S(e){return v(e)&&"MICRO-APP-BODY"===e.tagName.toUpperCase()}function M(e,t){try{return I(e).pathname.split(".").pop()===t}catch(n){return!1}}function C(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 N(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 O(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 D(e,...t){Promise.resolve().then(e.bind(null,...t))}const I=function(){class e extends URL{}return(t,n)=>n?new e(""+t,n):new e(""+t)}();function x(e){return e.startsWith("//")?`${n.location.protocol}${e}`:e}function L(e,t=null){if(!d(e)||!e)return"";try{const{origin:t,pathname:n,search:o}=I(x(e),(window.rawWindow||window).location.href),r=`${t}${n}${o}`;return/^https?:\/\//.test(r)?r:""}catch(n){return N(n,t),""}}function T(e){return d(e)&&e?e.replace(/(^\d+)|([^\w\d-_])/gi,""):""}function W(e){const{origin:t,pathname:n}=I(e);if(/\.(\w+)$/.test(n)){const e=`${t}${n}`.split("/");return e.pop(),e.join("/")+"/"}return`${t}${n}/`.replace(/\/\/$/,"/")}function U(e,t){return!e||/^((((ht|f)tps?)|file):)?\/\//.test(e)||/^(data|blob):/.test(e)?e:I(e,W(x(t))).toString()}function B(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 k=n.requestIdleCallback||function(e){const t=Date.now();return setTimeout((function(){e({didTimeout:!1,timeRemaining:()=>Math.max(0,50-(Date.now()-t))})}),1)};function H(e){return new Promise((t=>{k((()=>{e(t)}))}))}let F=null;function j(e){F=e}function $(){return F}function K(e){F===e||V()||(j(e),D((()=>{j(null)})))}let q=null;function G(e){q=e}function Q(){return q}function z(e){q===e||V()||(G(e),D((()=>{G(null)})))}let X=!1;function V(){return X}function Y(e){!1!==e?(j(null),G(null),e&&!X&&(X=!0,D((()=>{X=!1})))):X=!1}function J(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 Z(e){return!e||/(^\d)|([^\w\d-_\u4e00-\u9fa5])/gi.test(e)}function ee(e){return/^body$/i.test(e)||/^head$/i.test(e)||/^html$/i.test(e)||/^title$/i.test(e)||/^:root$/i.test(e)}function te(e){return function(e){return"undefined"!=typeof ShadowRoot&&e instanceof ShadowRoot}(e)?e.host:e}function ne(e){return e?e.replace(/^\s+|\s+$/g,""):""}function oe(){return navigator.userAgent.indexOf("Firefox")>-1}function re(e){const t={},n=e.split("&");for(const o of n){const e=o.indexOf("="),n=e<0?o:o.slice(0,e),i=e<0?null:o.slice(e+1);if(n in t){let e=t[n];r(e)||(e=t[n]=[e]),e.push(i)}else t[n]=i}return t}function ie(e){let t="";for(const n in e){const o=e[n];if(h(o))t+=(t.length?"&":"")+n;else{(r(o)?o:[o]).forEach((e=>{p(e)||(t+=(t.length?"&":"")+n,h(e)||(t+="="+e))}))}}return t}function se(){const e=new Set;return{add:function(t){return e.add(t),()=>!!e.has(t)&&e.delete(t)},list:()=>e}}function ae(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 ce(e,t){e?e.push((()=>H((e=>{t(),e()})))):t()}function le(e){return(null==e?void 0:e.reduce(((e,t)=>e.then(t)),Promise.resolve()))||null}function ue(e){return e.startsWith("inline-")}function pe(e,t,n,...o){try{_(e)&&e(...o)}catch(r){N(`An error occurred in app ${t} window.${n} \n`,null,r)}}function he(e,t){if(null==e)return!1;if(!_(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 de=["mounted","unmount"];function me(e,t){return de.includes(e)?`${e}-${t}`:e}function fe(e,t,n,o){var r;if(!e)return O(`element does not exist in lifecycle ${n}`,t);e=te(e),Y();const s=i({name:t,container:e},o&&{error:o}),a=new CustomEvent(n,{detail:s});!function(e,t){Object.defineProperties(e,{currentTarget:{get:()=>t},target:{get:()=>t}})}(a,e),_(null===(r=Mo.options.lifeCycles)||void 0===r?void 0:r[n])&&Mo.options.lifeCycles[n](a,t),e.dispatchEvent(a)}function _e(e,t,n={}){var o;const r=new CustomEvent(me(t,e.name),{detail:n});null===(o=e.sandBox)||void 0===o||o.microAppWindow.dispatchEvent(r)}function ge(e,t=null,n={}){return Y(),_(Mo.options.fetch)?Mo.options.fetch(e,n,t):window.fetch(e,n).then((e=>e.text()))}class we{static getInstance(){return this.instance||(this.instance=new we),this.instance}run(e,t){const n=e.name,o=e.ssrUrl||e.url;(M(o,"js")?Promise.resolve(`<micro-app-head><script src='${o}'><\/script></micro-app-head><micro-app-body></micro-app-body>`):ge(o,n,{cache:"no-cache"})).then((r=>{if(!r){const t="html is empty, please check in detail";return e.onerror(new Error(t)),N(t,n)}r=this.formatHTML(o,r,n),t(r,e)})).catch((t=>{N(`Failed to fetch data from ${e.url}, micro-app stop rendering`,n,t),e.onLoadError(t)}))}formatHTML(e,t,n){return this.processHtml(e,t,n,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)=>g(n)&&_(n.processHtml)?n.processHtml(t,e):t),t):t}}const Ae=/(^|\s+)(html|:root)(?=[\s>~[.#:]+|$)/,ye=/(^|\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(),oe()?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,r)=>{const i=`__mock_${t}_${r}Value__`;return n[i]=o,e.replace(o,i)})).replace(/(^|,[\n\s]*)([^,]+)/g,((e,t,o)=>((o=(o=ne(o)).replace(/\[[^\]=]+(?:=([^\]]+))?\]/g,((e,t)=>n[t]?e.replace(t,n[t]):e)))&&!(this.scopecssDisableNextLine||this.scopecssDisable&&(!this.scopecssDisableSelectors.length||this.scopecssDisableSelectors.includes(o))||Ae.test(o))&&(o=ye.test(o)?o.replace(ye,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(),x(t.join("/")+"/")}(this.linkPath)),`url("${U(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=ne(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(ne(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){oe()?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 be(e,t,n,o,r){if(!e.__MICRO_APP_HAS_SCOPED__){e.__MICRO_APP_HAS_SCOPED__=!0;let s=null;try{s=Ee.exec(e.textContent,n,o,r),Ee.reset()}catch(i){Ee.reset(),N("An error occurred while parsing CSS:\n",t,i)}s&&(e.textContent=s)}}let Ee;function Pe(e,t,n){if(t.scopecss){const o=Re(t.name);Ee||(Ee=new ve);const r=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");if(e.textContent){be(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,Pe(e,t,n))}));i.observe(e,{childList:!0,characterData:!0})}else{const r=new MutationObserver((function(){r.disconnect(),e.textContent&&!e.hasAttribute("data-styled")&&be(e,t.name,o,t.url,n)}));r.observe(e,{childList:!0})}}return e}function Re(e,t=!1){const n=t?"\\":"";return`${Mo.tagName}${n}[name=${e}${n}]`}function Se(e,t){Object.defineProperties(e,{currentTarget:{get:()=>t},srcElement:{get:()=>t},target:{get:()=>t}})}function Me(e){const t=new CustomEvent("load");Se(t,e),_(e.onload)?e.onload(t):e.dispatchEvent(t)}function Ce(e){const t=new CustomEvent("error");Se(t,e),_(e.onerror)?e.onerror(t):e.dispatchEvent(t)}var Ne,Oe,De,Ie,xe,Le,Te=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=>{ue(e)&&t.delete(e)}))}})}}();function We(e,t,n,o=!1){const r=e.getAttribute("rel");let i=e.getAttribute("href"),s=null;if("stylesheet"===r&&i){i=U(i,n.url);let t=Te.link.getInfo(i);const r={attrs:ae(e)};if(t?t.appSpace[n.name]=t.appSpace[n.name]||r:t={code:"",appSpace:{[n.name]:r}},Te.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",U(i,n.url));return o?{replaceComment:s}:s?null==t?void 0:t.replaceChild(s,e):void 0}function Ue(e,t,n,o){const r=Array.from(t.source.links),i=r.map((e=>{const n=Te.link.getInfo(e);return n.code?n.code:ge(e,t.name)})),s=o?[]:null;B(i,(e=>{ce(s,(()=>function(e,t,n,o){const r=Te.link.getInfo(e);r.code=t;const i=r.appSpace[o.name],s=i.placeholder;if(s){const t=J("style");Be(o,e,t,r,i.attrs),s.parentNode?s.parentNode.replaceChild(t,s):n.appendChild(t),i.placeholder=null}}(r[e.index],e.data,n,t)))}),(e=>{N(e,t.name)}),(()=>{o?o.then((()=>{s.push((()=>Promise.resolve(t.onLoad({html:e})))),le(s)})):t.onLoad({html:e})}))}function Be(e,t,n,o,r){if(e.scopecss){const r=o.appSpace[e.name];if(r.prefix=r.prefix||Re(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(Re(r,!0),"g"),t)}}(e.name,r.prefix,o);i?n.textContent=i:(n.textContent=o.code,Pe(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"}(Ne||(Ne={})),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"}(Oe||(Oe={})),function(e){e.CREATED="created",e.BEFOREMOUNT="beforemount",e.MOUNTED="mounted",e.UNMOUNT="unmount",e.ERROR="error",e.BEFORESHOW="beforeshow",e.AFTERSHOW="aftershow",e.AFTERHIDDEN="afterhidden"}(De||(De={})),function(e){e.ONMOUNT="onmount",e.ONUNMOUNT="onunmount"}(Ie||(Ie={})),function(e){e.KEEP_ALIVE_SHOW="keep_alive_show",e.KEEP_ALIVE_HIDDEN="keep_alive_hidden"}(xe||(xe={})),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 ke="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=[1,2,3],Fe="state",je="search",$e="native",Ke="native-scope",qe="pure",Ge=[je,Fe,$e,Ke,qe],Qe=["popstate","hashchange","load","unload","unmount","appstate-change","statechange","mounted","error"],ze=Qe,Xe=Qe.concat(["unhandledrejection","message"]),Ve=["onpopstate","onhashchange","onload","onunload","onerror"],Ye=Ve,Je=Ve.concat(["onunhandledrejection"]),Ze=["DOMContentLoaded","readystatechange"],et=["onreadystatechange"],tt=["window","self","globalThis"],nt=["rawWindow","rawDocument"],ot=["host","hostname","port","protocol","origin"],rt=["text/javascript","text/ecmascript","application/javascript","application/ecmascript","module","systemjs-module","systemjs-importmap"];function it(e,t){return t.appSpace[e.name].module&&(!e.useSandbox||e.iframe)}function st(e,t){return e.inline||t.appSpace[e.name].inline||it(e,t)||function(e,t){return t.appSpace[e.name].attrs.has("id")}(e,t)}function at(e){return e.iframe?e.sandBox.microAppWindow:fo.rawWindow}function ct(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(at(e).Function)(t)}(e,n)}function lt(){const e="inline-"+Math.random().toString(36).substr(2,15);return Te.script.hasInfo(e)?lt():e}function ut(e,t){return e.useSandbox&&!it(e,t)}function pt(e,t){return ut(e,t)?e.iframe?"iframe":"with":"disable"}function ht(e,t,n,o=!1){var r;let i=null,s=e.getAttribute("src");if(s&&(s=U(s,n.url)),e.hasAttribute("exclude")||mt(s,n.name))i=document.createComment("script element with exclude attribute removed by micro-app");else{if(e.type&&!rt.includes(e.type)||e.hasAttribute("ignore")||ft(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=Te.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:ae(e)};if(t?t.appSpace[n.name]=t.appSpace[n.name]||r:t={code:"",isExternal:!0,appSpace:{[n.name]:r}},Te.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=lt(),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:ae(e)}}};if(o)return{address:t,scriptInfo:r};n.source.scripts.add(t),Te.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 dt(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 mt(e,t){if(!e)return!1;return(dt(t)||[]).some((t=>!!t.excludeChecker&&t.excludeChecker(e)))}function ft(e,t){if(!e)return!1;return(dt(t)||[]).some((t=>!!t.ignoreChecker&&t.ignoreChecker(e)))}function _t(e,t){const n=Array.from(t.source.scripts),o=[],r=[];for(const s of n){const e=Te.script.getInfo(s),n=e.appSpace[t.name];(!n.defer&&!n.async||t.isPrefetch&&!t.isPrerender)&&(o.push(e.code?e.code:ge(s,t.name)),r.push([s,e]))}const i=t.isPrefetch||t.fiber?[]:null;o.length?B(o,(e=>{ce(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=wt(e,o,n,t),i.sandboxType=pt(o,t),!st(o,t)))try{i.parsedFunction=ct(o,t,i.parsedCode)}catch(r){N("Something went wrong while handling preloaded resources",o.name,"\n",r)}}}(r[e.index][0],r[e.index][1],e.data,t)))}),(e=>{N(e,t.name)}),(()=>{i?(i.push((()=>Promise.resolve(t.onLoad({html:e})))),le(i)):t.onLoad({html:e})})):t.onLoad({html:e})}function gt(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=pt(t,n);if(s.parsedCode&&s.sandboxType===a||(s.parsedCode=wt(e,t,n.code,n),s.sandboxType=a,s.parsedFunction=null),st(t,n)){const a=r||J("script");if(function(e,t,n,o,r,i){if(n){if(fo.rawSetAttribute.call(o,"type","module"),ue(e)?o.textContent=t:o.src=e,i){const t=()=>{i.moduleCount&&i.moduleCount--,i(0===i.moduleCount)};ue(e)?D(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,it(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=ct(e,t,n.parsedCode));n.parsedFunction.call(at(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 wt(e,t,n,o){return g(Mo.options.plugins)&&(n=function(e,t,n,o){var r;const i=At(o.global,t,e);return At(null===(r=o.modules)||void 0===r?void 0:r[n],i,e)}(e,n,t.name,Mo.options.plugins)),ut(t,o)?t.iframe?`(function(window,self,global,location){;${n}\n${ue(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(${ke}){;${n}\n${ue(e)?"":`//# sourceURL=${e}\n`}}).call(proxyWindow,${ke})}})(window.__MICRO_APP_PROXY_WINDOW__);`:n}function At(e,t,n){return r(e)?e.reduce(((e,t)=>g(t)&&_(t.loader)?t.loader(e,n):e),t):t}function yt(e,t,n){if(!e||"[object HTMLBodyElement]"!==u(e))return;Array.from(e.getElementsByTagName("link")).map((e=>(e.hasAttribute("exclude")||mt(e.getAttribute("href"),t.name)?e.parentElement.replaceChild(document.createComment("link element with exclude attribute ignored by micro-app"),e):e.hasAttribute("ignore")||ft(e.getAttribute("href"),t.name)?e.hasAttribute("href")&&fo.rawSetAttribute.call(e,"href",U(e.getAttribute("href"),t.url)):We(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")&&ce(n,(()=>Pe(e,t))),e)));Array.from(e.getElementsByTagName("script")).map((e=>(ht(e,e.parentElement,t),e)));Array.from(e.getElementsByTagName("img")).map((e=>(e.hasAttribute("src")&&fo.rawSetAttribute.call(e,"src",U(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)),N(e,t.name)}const i=t.isPrefetch||t.fiber?[]:null;yt(n,t,i);const s=le(i);t.source.links.size?Ue(n,t,o,s):s?s.then((()=>t.onLoad({html:n}))):t.onLoad({html:n}),t.source.scripts.size?_t(n,t):t.onLoad({html:n})}const bt=new class{constructor(){this.eventList=new Map,this.queue=[],this.recordStep={},this.process=()=>{var e,t;let n;const o=this.recordStep,r=this.queue;for(this.recordStep={},this.queue=[];n=r.shift();){const r=this.eventList.get(n),i=r.tempData,s=r.force;let a;if(r.tempData=null,r.force=!1,s||!this.isEqual(r.data,i)){r.data=i||r.data;for(const e of r.callbacks){const t=e(r.data);t&&(null!=a?a:a=[]).push(t)}null===(t=(e=o[n]).dispatchDataEvent)||void 0===t||t.call(e),o[n].nextStepList.forEach((e=>e(a)))}}}}isLegalName(e){return!!e||(N("event-center: Invalid name"),!1)}enqueue(e,t,n){this.recordStep[e]?(this.recordStep[e].nextStepList.push(t),n&&(this.recordStep[e].dispatchDataEvent=n)):this.recordStep[e]={nextStepList:[t],dispatchDataEvent:n},!this.queue.includes(e)&&1===this.queue.push(e)&&D(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(!_(t))return N("event-center: Invalid callback function");let o=this.eventList.get(e);o?n&&Object.keys(o.data).length&&(!this.queue.includes(e)||this.isEqual(o.data,o.tempData))&&t(o.data):(o={data:{},callbacks:new Set},this.eventList.set(e,o)),o.callbacks.add(t)}}off(e,t){if(this.isLegalName(e)){const n=this.eventList.get(e);n&&(_(t)?n.callbacks.delete(t):n.callbacks.clear())}}clearData(e){if(this.isLegalName(e)){const t=this.eventList.get(e);t&&(t.data={})}}dispatch(e,t,n,o,r){if(this.isLegalName(e)){if(!g(t))return N("event-center: data must be object");let s=this.eventList.get(e);s?(s.tempData=i({},s.tempData||s.data,t),!s.force&&(s.force=!!o)):(s={data:t,callbacks:new Set},this.eventList.set(e,s),s.force=!0),this.enqueue(e,n,r)}}getData(e){var t;const n=this.eventList.get(e);return null!==(t=null==n?void 0:n.data)&&void 0!==t?t:null}};function Et(e,t){return d(e)&&e?t?`__${e}_from_base_app__`:`__${e}_from_micro_app__`:""}class Pt{addGlobalDataListener(e,t){const n=this.appName;n&&(e.__APP_NAME__=n,e.__AUTO_TRIGGER__=t),bt.on("global",e,t)}removeGlobalDataListener(e){_(e)&&bt.off("global",e)}setGlobalData(e,t,n){Y(),bt.dispatch("global",e,(e=>_(t)&&t(e)),n)}forceSetGlobalData(e,t){this.setGlobalData(e,t,!0)}getGlobalData(){return bt.getData("global")}clearGlobalData(){bt.clearData("global")}clearGlobalDataListener(){const e=this.appName,t=bt.eventList.get("global");if(t)for(const n of t.callbacks)(e&&e===n.__APP_NAME__||!e&&!n.__APP_NAME__)&&t.callbacks.delete(n)}}class Rt extends Pt{addDataListener(e,t,n){bt.on(Et(T(e),!1),t,n)}removeDataListener(e,t){_(t)&&bt.off(Et(T(e),!1),t)}getData(e,t=!1){return bt.getData(Et(T(e),t))}setData(e,t,n,o){bt.dispatch(Et(T(e),!0),t,(e=>_(n)&&n(e)),o)}forceSetData(e,t,n){this.setData(e,t,n,!0)}clearData(e,t=!0){bt.clearData(Et(T(e),t))}clearDataListener(e){bt.off(Et(T(e),!1))}changeEventAppName(e,t){const n=Et(T(e),!0),o=Et(T(t),!0);bt.eventList.has(o)&&(bt.eventList.set(n,bt.eventList.get(o)),bt.eventList.delete(o))}}class St extends Pt{constructor(e){super(),this.appName=T(e),!this.appName&&N(`Invalid appName ${e}`)}addDataListener(e,t){e.__AUTO_TRIGGER__=t,bt.on(Et(this.appName,!0),e,t)}removeDataListener(e){_(e)&&bt.off(Et(this.appName,!0),e)}getData(e=!0){return bt.getData(Et(this.appName,e))}dispatch(e,t,n){Y(),bt.dispatch(Et(this.appName,!1),e,(e=>_(t)&&t(e)),n,(()=>{const t=eo.get(this.appName);if((null==t?void 0:t.container)&&g(e)){const e=new CustomEvent("datachange",{detail:{data:bt.getData(Et(this.appName,!1))}});te(t.container).dispatchEvent(e)}}))}forceDispatch(e,t){this.dispatch(e,t,!0)}clearData(e=!1){bt.clearData(Et(this.appName,e))}clearDataListener(){bt.off(Et(this.appName,!0))}}function Mt(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=bt.eventList.get("global");if(o)for(const t of o.callbacks)e.appName===t.__APP_NAME__&&e.umdDataListeners.global.add(t);const r=bt.eventList.get(Et(e.appName,!0));if(r)for(const t of r.callbacks)e.umdDataListeners.normal.add(t)}}function Ct(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__);Nt(e)}}function Nt(e){null==e||delete e.umdDataListeners}class Ot{constructor(){this.appInstanceMap=eo}static getInstance(){return this.instance||(this.instance=new Ot),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 Dt(){It(),Ot.getInstance().getAll().forEach((e=>{e.container&&te(e.container).disconnectedCallback()})),!window.__MICRO_APP_UMD_MODE__&&Ot.getInstance().clear()}function It(){window.__MICRO_APP_ENVIRONMENT__&&window.removeEventListener("unmount",Dt,!1)}function xt(e){return m(e.__MICRO_APP_IS_BOUND_FUNCTION__)?e.__MICRO_APP_IS_BOUND_FUNCTION__:e.__MICRO_APP_IS_BOUND_FUNCTION__=_(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(_(e)&&!function(e){return m(e.__MICRO_APP_IS_CONSTRUCTOR__)?e.__MICRO_APP_IS_CONSTRUCTOR__:e.__MICRO_APP_IS_CONSTRUCTOR__=A(e)}(e)&&!xt(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")&&s(r,"prototype",{value:e.prototype,configurable:!0,enumerable:!1,writable:!0}),e[o]=r}return e}class Tt{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 Wt{}function Ut(e,t){const n=Array.from(e.childNodes);n.length&&n.forEach((e=>{Ut(e,t)})),Bt(e,t)}function Bt(e,t){var n,o;if(t&&b(e)&&e.__MICRO_APP_NAME__!==t&&!e.__PURE_ELEMENT__&&!V()){const r={__MICRO_APP_NAME__:{configurable:!0,enumerable:!0,writable:!0,value:t}};if("[object HTMLAnchorElement]"===u(e)){Ot.getInstance().get(t)&&(r.href={get(){return this.getAttribute("href")},set(e){void 0!==e&&this.setAttribute("href",e)}})}if(a(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&&a(e,{baseURI:{configurable:!0,enumerable:!0,get:()=>r.location.href},ownerDocument:{configurable:!0,enumerable:!0,get:()=>e!==r.document?r.document:null},parentNode:kt(t,fo.rawParentNodeDesc),getRootNode:{configurable:!0,enumerable:!0,writable:!0,value:function(){return r.document}}})}}return e}function kt(e,t){return{configurable:!0,enumerable:!0,get(){var n,o,r,i,s,a,c;z(e);const l=null===(n=t.get)||void 0===n?void 0:n.call(this);if(S(l)&&(null===(o=eo.get(e))||void 0===o?void 0:o.container)){const t=null===(i=(r=Mo.options).getRootElementParentNode)||void 0===i?void 0:i.call(r,this,e);return t||(!0!==(null===(s=null==Mo?void 0:Mo.options)||void 0===s?void 0:s.inheritBaseBody)&&(null===(c=null===(a=eo.get(e))||void 0===a?void 0:a.container)||void 0===c?void 0:c.querySelector("micro-app-body"))||fo.rawDocument.body)}return l}}}function Ht(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 Bt(a.call(s,t,n),e)}function h(t,n,o){return Bt(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},g=()=>{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&&(v.onclick=i),o.forEach(((e,t)=>{for(const n of e)v.addEventListener(t,n,null==n?void 0:n.__MICRO_APP_MARK_OPTIONS__)})),f()},A=()=>{_(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=>{_(r)&&u.call(s,"click",r,!1),_(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])})(),v=new Proxy(s,{get:(n,o)=>{var i;return K(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:v,documentEffect:{reset:f,record:g,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)=>(K(e),Lt(Reflect.get(t,o),n,"DOCUMENT")),set:(e,t,n)=>(Reflect.set(e,t,n),!0)})),r}(e,o);return a(t,{document:{configurable:!1,enumerable:!0,get:()=>o},Document:{configurable:!1,enumerable:!1,get:()=>i}}),r}function Ft(e,t,n){return function(e){const t=fo.rawWindow;Object.getOwnPropertyNames(t).filter((e=>/^on/.test(e)&&!Ye.includes(e))).forEach((n=>{const{enumerable:o,writable:r,set:i}=Object.getOwnPropertyDescriptor(t,n)||{enumerable:!0,writable:!0};s(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)=>(K(e),Reflect.has(t,r)||d(r)&&/^__MICRO_APP_/.test(r)||C(n.scopeProperties,r)?(C(nt,r)&&Y(),Reflect.get(t,r)):Lt(Reflect.get(o,r),o)),set:(e,t,r)=>{if(C(n.rawWindowScopeKeyList,t))Reflect.set(o,t,r);else if(l.call(e,t)||!l.call(o,t)||C(n.scopeProperties,t))Reflect.has(e,t)&&!C(n.scopeProperties,t)||n.injectedKeys.add(t),Reflect.set(e,t,r);else{const i=Object.getOwnPropertyDescriptor(o,t),{configurable:a,enumerable:c,writable:l,set:u}=i;s(e,t,{value:r,configurable:a,enumerable:c,writable:null!=l?l:!!u}),n.injectedKeys.add(t)}return(C(n.escapeProperties,t)||C(n.staticEscapeProperties,t)&&!Reflect.has(o,t))&&!C(n.scopeProperties,t)&&(!Reflect.has(o,t)&&n.escapeKeys.add(t),Reflect.set(o,t,r)),!0},has:(e,t)=>C(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(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,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 ze.includes(e)&&(null===(n=eo.get(t))||void 0===n?void 0:n.container)?te(eo.get(t).container):s}e.addEventListener=function(e,o,r){e=me(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=me(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 jt(e,t,n){const o=fo.rawWindow.history.state,r={__MICRO_APP_STATE__:i({},null==o?void 0:o.__MICRO_APP_STATE__,{[e]:{fullPath:n?n.pathname+n.search+n.hash:null,state:null!=t?t:null,mode:rn(e)}})};return i({},o,r)}function $t(e,t){return g(null==t?void 0:t.__MICRO_APP_STATE__)&&(p(t.__MICRO_APP_STATE__[e])||delete t.__MICRO_APP_STATE__[e],Object.keys(t.__MICRO_APP_STATE__).length||delete t.__MICRO_APP_STATE__),g(n=t)&&Object.keys(n).length?i({},t):null;var n}function Kt(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 qt(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 Gt=/&/g,Qt=/=/g,zt=/%M1/g,Xt=/%M2/g;function Vt(e){return encodeURIComponent(Jt(e).replace(Gt,"%M1").replace(Qt,"%M2"))}function Yt(e){return Jt(e).replace(zt,"&").replace(Xt,"=")}function Jt(e){try{const t=decodeURIComponent(e);return e===t||zt.test(t)||Xt.test(t)?t:Jt(t)}catch(t){return e}}function Zt(e){return e}function en(e){var t,n,o,r;const i=fo.rawWindow.location,s=fo.rawWindow.history.state;if(sn(e)){const o=nn(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 d(r)?Yt(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)||(un(e)?i.pathname+i.search+i.hash:null)}function tn(e,t){const n=fo.rawWindow.location;let o=t.pathname+t.search+t.hash,r=!1;if(sn(e)){let{pathname:t,search:i,hash:s}=n;const a=nn(i,s),c=Vt(o);if(s&&!i){r=!0,a.hashQuery?a.hashQuery[e]=c:a.hashQuery={[Zt(e)]:c};const t=s.includes("?")?s.slice(0,s.indexOf("?")+1):s+"?";s=t+ie(a.hashQuery)}else a.searchQuery?a.searchQuery[e]=c:a.searchQuery={[Zt(e)]:c},i="?"+ie(a.searchQuery);return{fullPath:t+i+s,isAttach2Hash:r}}return(an(e)||ln(e))&&(o=n.pathname+n.search+n.hash),{fullPath:o,isAttach2Hash:r}}function nn(e,t){const n={};return""!==e&&"?"!==e&&(n.searchQuery=re(e.slice(1))),t.includes("?")&&(n.hashQuery=re(t.slice(t.indexOf("?")+1))),n}function on(e){const t=eo.get(e);return!(!t||t.isPrefetch)}function rn(e){var t;return null===(t=eo.get(e))||void 0===t?void 0:t.routerMode}function sn(e){return rn(e)===je}function an(e){return rn(e)===Fe}function cn(e){return rn(e)===$e}function ln(e){return rn(e)===qe}function un(e){return cn(e)||function(e){return rn(e)===Ke}(e)}function pn(e,t){const n=t&&$e||e||Mo.options["disable-memory-router"]&&$e||Mo.options["router-mode"]||je;return Ge.includes(n)?n:je}function hn(e){const t=fo.rawWindow,n=t=>{var n,o,r;if(yo({excludeHiddenApp:!0,excludePreRender:!0}).includes(e)&&!t.onlyForBrowser&&(!un(e)||!fo.rawWindow.history.state||qt(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)}((()=>dn(e,en(e))),null!==(r=null===(o=t&&te(t))||void 0===o?void 0:o.getRouterEventDelay())&&void 0!==r?r:0)}};return t.addEventListener("popstate",n),()=>{t.removeEventListener("popstate",n)}}function dn(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;Cn(e,t,r.location),i=o.location.hash!==n}!function(e,t,n){const o=new PopStateEvent("popstate",{state:Kt(e)});n.dispatchEvent(o),no(e)||_(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)||_(t.onhashchange)&&t.onhashchange(r)}(e,o,r,s),Y()}}function mn(e,t,n){Y(),on(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 fn(e,t){const n=fo.rawWindow.history;function o(n){return function(...o){var r,i,s;o[2]=p(o[2])||h(o[2])||""+o[2]==""?t.href:""+o[2];const a=I(o[2],t.href),c=a.pathname+a.search+a.hash;ln(e)||gn(e,n,tn(e,a),!0,jt(e,o[0],a),o[1]),c!==t.fullPath&&Cn(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)?i({go:e=>n.go(e)},r):new Proxy(n,{get:(t,n)=>"pushState"===n||"replaceState"===n?r[n]:"state"===n?Kt(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 _n(e,t,n,o=null,r=""){if(on(e)){("pushState"===t?fo.rawPushState:fo.rawReplaceState).call(fo.rawWindow.history,o,r,n)}}function gn(e,t,n,o,r,i){if(on(e)){const s=fo.rawWindow.location,a=s.pathname+s.search+s.hash,c=n.isAttach2Hash&&a!==n.fullPath?s.href:null;_n(e,t,n.fullPath,r,i),a!==n.fullPath&&sn(e)&&mn(e,o,c)}}function wn(e,t,n){gn(e,"replaceState",t,!0,n)}function An(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__)&&(!g(n[0])||!n[0].__MICRO_APP_STATE__)&&(d(n[2])||y(n[2]))){const e=t.location.href;I(n[2],e).href===e&&(n[0]=i({},n[0],{__MICRO_APP_STATE__:t.history.state.__MICRO_APP_STATE__}))}e.apply(t.history,n),yo({excludeHiddenApp:!0,excludePreRender:!0}).forEach((e=>{if((sn(e)||an(e))&&!en(e)){const t=eo.get(e);wn(e,tn(e,t.sandBox.proxyWindow.location),jt(e,Kt(e),t.sandBox.proxyWindow.location))}un(e)&&!qt(e)&&_n(e,"replaceState",t.location.href,jt(e))})),Y()}}function yn(){const e=fo.rawWindow;e.history.pushState=An(fo.rawPushState),e.history.replaceState=An(fo.rawReplaceState)}function vn(){const e=fo.rawWindow;e.history.pushState=fo.rawPushState,e.history.replaceState=fo.rawReplaceState}const{router:bn,executeNavigationGuard:En,clearRouterWhenUnmount:Pn}=function(){function e(e,t,n,o){const r=t.sandBox.proxyWindow.location,i=I(n.path,r.href),s=r.pathname+r.search+r.hash,a=i.pathname+i.search+i.hash;if(s!==a||en(e)!==a){if(!ln(e)){!function(e,t,n,o){gn(e,t,tn(e,n),!1,jt(e,null!=o?o:null,n)),Y()}(e,o&&!1!==n.replace||!0===n.replace?"replaceState":"pushState",i,n.state)}sn(e)||dn(e,a)}}function t(t){return function(n){return new Promise(((o,r)=>{const i=T(n.name);if(i&&d(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(N("导航失败,请确保子应用渲染后再调用此方法"));else r(N("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 r=se(),i=se();function s(e,t,n,o){Y();for(const r of o)_(r)?r(t,n,e):g(r)&&_(r[e])&&r[e](t,n)}function a(e){if(sn(e)||an(e)){const t=eo.get(e);wn(e,tn(e,t.sandBox.proxyWindow.location),jt(e,Kt(e),t.sandBox.proxyWindow.location))}}const c=Object.assign(Object.assign({current:new Map,encode:Vt,decode:Yt,push:t(!1),replace:t(!0),go:n("go"),back:n("back"),forward:n("forward"),beforeEach:r.add,afterEach:i.add,attachToURL:function(e){(e=T(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=T(t.name);return n&&t.path?e.add(n,t.path):o},removeDefaultPage:function(t){return!!(t=T(t))&&e.delete(t)},getDefaultPage:e.get}}()),function(){let e=null;return{setBaseAppRouter:function(t){var n;h(n=t)||"object"!=typeof n||(e=new Proxy(t,{get:(e,t)=>(Y(),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,r.list()),k((()=>{s(e,t,n,i.list())}))},clearRouterWhenUnmount:function(e){c.current.delete(e)}}}(),Rn=["href","pathname","search","hash","host","hostname","port","protocol","search","origin","fullPath"];function Sn(e,t,n,o,r,i){const a=fo.rawWindow.location,c=!!n,l=I(t);function u(){return c?n.location:l}function p(t,n){const o=I(t,g.href);if(o.origin===g.origin){const t=tn(e,o);if(!un(e)){if(n=ln(e)?"replaceState":n,o.pathname===g.pathname&&o.search===g.search){let r=null;return(o.hash!==g.hash||ln(e))&&(t.isAttach2Hash&&(r=a.href),ln(e)&&o.hash||_n(e,n,t.fullPath,sn(e)?null:jt(e,null,o))),void(o.hash?sn(e)?mn(e,!1,r):dn(e,o.pathname+o.search+o.hash):_())}return _n(e,n,t.fullPath,sn(e)?null:jt(e,null,o)),void _()}return t.fullPath}return t}function h(n,o){const r=I(n,t);r[o]===g[o]&&g.hash?mn(e,!1):(_n(e,r[o]===g[o]||ln(e)?"replaceState":"pushState",tn(e,r).fullPath,sn(e)?null:jt(e,null,r)),_())}const d=t=>function(n){if(on(e)){const e=p(n,"assign"===t?"pushState":"replaceState");e&&a[t](I(e,a.origin).href)}},m=d("assign"),f=d("replace"),_=e=>a.reload(e);s(u(),"fullPath",{enumerable:!0,configurable:!0,get:()=>g.pathname+g.search+g.hash});const g=new Proxy({},{get:(t,n)=>{const s=u();if("assign"===n)return m;if("replace"===n)return f;if("reload"===n)return _;if("self"===n)return s;if("fullPath"===n)return s.fullPath;if(ot.includes(n)){if(cn(e))return a[n];if(c)return o[n]}if("href"===n){if(cn(e))return s[n].replace(s.origin,a.origin);if(c)return s[n].replace(r,i)}return Lt(Reflect.get(s,n),s,"LOCATION")},set:(n,o,r)=>{if(on(e)){const n=u();if("href"===o){const e=p(r,"pushState");e&&(a.href=I(e,a.origin).href)}else if("pathname"===o)if(un(e))a.pathname=r;else{h(("/"+r).replace(/^\/+/,"/")+g.search+g.hash,"pathname")}else if("search"===o)if(un(e))a.search=r;else{h(g.pathname+("?"+r).replace(/^\?+/,"?")+g.hash,"search")}else if("hash"===o)if(un(e))a.hash=r;else{const n=g.pathname+g.search+("#"+r).replace(/^#+/,"#"),o=I(n,t);o.hash!==g.hash&&(ln(e)||gn(e,"pushState",tn(e,o),!1,jt(e,null,o)),sn(e)||dn(e,o.pathname+o.search+o.hash))}else Reflect.set(n,o,r)}return!0}});return g}function Mn(e,t){const n=i({name:e},t);for(const o of Rn)n[o]=t[o];return n}function Cn(e,t,n,o){var r;const i=Mn(e,n),s=I(t,n.href);if(no(e)){const t=eo.get(e).sandBox.microAppWindow;nul