@micro-zoe/micro-app 1.0.0-rc.1 → 1.0.0-rc.11

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