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