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