@micro-zoe/micro-app 1.0.0-rc.13 → 1.0.0-rc.14

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