@dimina-kit/devkit 0.1.2-dev.20260706064107 → 0.1.2

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.
@@ -1,8 +1,8 @@
1
- var e=10,t=(e=0)=>t=>`\u001B[${t+e}m`,n=(e=0)=>t=>`\u001B[${38+e};5;${t}m`,r=(e=0)=>(t,n,r)=>`\u001B[${38+e};2;${t};${n};${r}m`,i={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};Object.keys(i.modifier);var a=Object.keys(i.color),o=Object.keys(i.bgColor);[...a,...o];function s(){let a=new Map;for(let[e,t]of Object.entries(i)){for(let[e,n]of Object.entries(t))i[e]={open:`\u001B[${n[0]}m`,close:`\u001B[${n[1]}m`},t[e]=i[e],a.set(n[0],n[1]);Object.defineProperty(i,e,{value:t,enumerable:!1})}return Object.defineProperty(i,"codes",{value:a,enumerable:!1}),i.color.close=`\x1B[39m`,i.bgColor.close=`\x1B[49m`,i.color.ansi=t(),i.color.ansi256=n(),i.color.ansi16m=r(),i.bgColor.ansi=t(e),i.bgColor.ansi256=n(e),i.bgColor.ansi16m=r(e),Object.defineProperties(i,{rgbToAnsi256:{value(e,t,n){return e===t&&t===n?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(t/255*5)+Math.round(n/255*5)},enumerable:!1},hexToRgb:{value(e){let t=/[a-f\d]{6}|[a-f\d]{3}/i.exec(e.toString(16));if(!t)return[0,0,0];let[n]=t;n.length===3&&(n=[...n].map(e=>e+e).join(``));let r=Number.parseInt(n,16);return[r>>16&255,r>>8&255,r&255]},enumerable:!1},hexToAnsi256:{value:e=>i.rgbToAnsi256(...i.hexToRgb(e)),enumerable:!1},ansi256ToAnsi:{value(e){if(e<8)return 30+e;if(e<16)return 90+(e-8);let t,n,r;if(e>=232)t=((e-232)*10+8)/255,n=t,r=t;else{e-=16;let i=e%36;t=Math.floor(e/36)/5,n=Math.floor(i/6)/5,r=i%6/5}let i=Math.max(t,n,r)*2;if(i===0)return 30;let a=30+(Math.round(r)<<2|Math.round(n)<<1|Math.round(t));return i===2&&(a+=60),a},enumerable:!1},rgbToAnsi:{value:(e,t,n)=>i.ansi256ToAnsi(i.rgbToAnsi256(e,t,n)),enumerable:!1},hexToAnsi:{value:e=>i.ansi256ToAnsi(i.hexToAnsi256(e)),enumerable:!1}}),i}var c=s(),l=(()=>{if(!(`navigator`in globalThis))return 0;if(globalThis.navigator.userAgentData){let e=navigator.userAgentData.brands.find(({brand:e})=>e===`Chromium`);if(e&&e.version>93)return 3}return+!!/\b(Chrome|Chromium)\//.test(globalThis.navigator.userAgent)})(),u=l!==0&&{level:l,hasBasic:!0,has256:l>=2,has16m:l>=3},d={stdout:u,stderr:u};function f(e,t,n){let r=e.indexOf(t);if(r===-1)return e;let i=t.length,a=0,o=``;do o+=e.slice(a,r)+t+n,a=r+i,r=e.indexOf(t,a);while(r!==-1);return o+=e.slice(a),o}function p(e,t,n,r){let i=0,a=``;do{let o=e[r-1]===`\r`;a+=e.slice(i,o?r-1:r)+t+(o?`\r
1
+ var e=(e=0)=>t=>`\u001B[${t+e}m`,t=(e=0)=>t=>`\u001B[${38+e};5;${t}m`,n=(e=0)=>(t,n,r)=>`\u001B[${38+e};2;${t};${n};${r}m`,r={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};Object.keys(r.modifier);var i=Object.keys(r.color),a=Object.keys(r.bgColor);[...i,...a];function o(){let i=new Map;for(let[e,t]of Object.entries(r)){for(let[e,n]of Object.entries(t))r[e]={open:`\u001B[${n[0]}m`,close:`\u001B[${n[1]}m`},t[e]=r[e],i.set(n[0],n[1]);Object.defineProperty(r,e,{value:t,enumerable:!1})}return Object.defineProperty(r,"codes",{value:i,enumerable:!1}),r.color.close=`\x1B[39m`,r.bgColor.close=`\x1B[49m`,r.color.ansi=e(),r.color.ansi256=t(),r.color.ansi16m=n(),r.bgColor.ansi=e(10),r.bgColor.ansi256=t(10),r.bgColor.ansi16m=n(10),Object.defineProperties(r,{rgbToAnsi256:{value(e,t,n){return e===t&&t===n?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(t/255*5)+Math.round(n/255*5)},enumerable:!1},hexToRgb:{value(e){let t=/[a-f\d]{6}|[a-f\d]{3}/i.exec(e.toString(16));if(!t)return[0,0,0];let[n]=t;n.length===3&&(n=[...n].map(e=>e+e).join(``));let r=Number.parseInt(n,16);return[r>>16&255,r>>8&255,r&255]},enumerable:!1},hexToAnsi256:{value:e=>r.rgbToAnsi256(...r.hexToRgb(e)),enumerable:!1},ansi256ToAnsi:{value(e){if(e<8)return 30+e;if(e<16)return 90+(e-8);let t,n,r;if(e>=232)t=((e-232)*10+8)/255,n=t,r=t;else{e-=16;let i=e%36;t=Math.floor(e/36)/5,n=Math.floor(i/6)/5,r=i%6/5}let i=Math.max(t,n,r)*2;if(i===0)return 30;let a=30+(Math.round(r)<<2|Math.round(n)<<1|Math.round(t));return i===2&&(a+=60),a},enumerable:!1},rgbToAnsi:{value:(e,t,n)=>r.ansi256ToAnsi(r.rgbToAnsi256(e,t,n)),enumerable:!1},hexToAnsi:{value:e=>r.ansi256ToAnsi(r.hexToAnsi256(e)),enumerable:!1}}),r}var s=o(),c=(()=>{if(!(`navigator`in globalThis))return 0;if(globalThis.navigator.userAgentData){let e=navigator.userAgentData.brands.find(({brand:e})=>e===`Chromium`);if(e&&e.version>93)return 3}return+!!/\b(Chrome|Chromium)\//.test(globalThis.navigator.userAgent)})(),l=c!==0&&{level:c,hasBasic:!0,has256:c>=2,has16m:c>=3},u={stdout:l,stderr:l};function d(e,t,n){let r=e.indexOf(t);if(r===-1)return e;let i=t.length,a=0,o=``;do o+=e.slice(a,r)+t+n,a=r+i,r=e.indexOf(t,a);while(r!==-1);return o+=e.slice(a),o}function f(e,t,n,r){let i=0,a=``;do{let o=e[r-1]===`\r`;a+=e.slice(i,o?r-1:r)+t+(o?`\r
2
2
  `:`
3
3
  `)+n,i=r+1,r=e.indexOf(`
4
- `,i)}while(r!==-1);return a+=e.slice(i),a}var{stdout:m,stderr:h}=d,g=Symbol(`GENERATOR`),_=Symbol(`STYLER`),v=Symbol(`IS_EMPTY`),y=[`ansi`,`ansi`,`ansi256`,`ansi16m`],b=Object.create(null),x=(e,t={})=>{if(t.level&&!(Number.isInteger(t.level)&&t.level>=0&&t.level<=3))throw Error("The `level` option should be an integer from 0 to 3");let n=m?m.level:0;e.level=t.level===void 0?n:t.level},S=e=>{let t=(...e)=>e.join(` `);return x(t,e),Object.setPrototypeOf(t,C.prototype),t};function C(e){return S(e)}Object.setPrototypeOf(C.prototype,Function.prototype);for(let[e,t]of Object.entries(c))b[e]={get(){let n=D(this,E(t.open,t.close,this[_]),this[v]);return Object.defineProperty(this,e,{value:n}),n}};b.visible={get(){let e=D(this,this[_],!0);return Object.defineProperty(this,"visible",{value:e}),e}};var w=(e,t,n,...r)=>e===`rgb`?t===`ansi16m`?c[n].ansi16m(...r):t===`ansi256`?c[n].ansi256(c.rgbToAnsi256(...r)):c[n].ansi(c.rgbToAnsi(...r)):e===`hex`?w(`rgb`,t,n,...c.hexToRgb(...r)):c[n][e](...r);for(let e of[`rgb`,`hex`,`ansi256`]){b[e]={get(){let{level:t}=this;return function(...n){let r=E(w(e,y[t],`color`,...n),c.color.close,this[_]);return D(this,r,this[v])}}};let t=`bg`+e[0].toUpperCase()+e.slice(1);b[t]={get(){let{level:t}=this;return function(...n){let r=E(w(e,y[t],`bgColor`,...n),c.bgColor.close,this[_]);return D(this,r,this[v])}}}}var T=Object.defineProperties(()=>{},{...b,level:{enumerable:!0,get(){return this[g].level},set(e){this[g].level=e}}}),E=(e,t,n)=>{let r,i;return n===void 0?(r=e,i=t):(r=n.openAll+e,i=t+n.closeAll),{open:e,close:t,openAll:r,closeAll:i,parent:n}},D=(e,t,n)=>{let r=(...e)=>ee(r,e.length===1?``+e[0]:e.join(` `));return Object.setPrototypeOf(r,T),r[g]=e,r[_]=t,r[v]=n,r},ee=(e,t)=>{if(e.level<=0||!t)return e[v]?``:t;let n=e[_];if(n===void 0)return t;let{openAll:r,closeAll:i}=n;if(t.includes(`\x1B`))for(;n!==void 0;)t=f(t,n.close,n.open),n=n.parent;let a=t.indexOf(`
5
- `);return a!==-1&&(t=p(t,i,r,a)),r+t+i};Object.defineProperties(C.prototype,b);var O=C();C({level:h?h.level:0});function k(e){return{all:e||=new Map,on:function(t,n){var r=e.get(t);r?r.push(n):e.set(t,[n])},off:function(t,n){var r=e.get(t);r&&(n?r.splice(r.indexOf(n)>>>0,1):e.set(t,[]))},emit:function(t,n){var r=e.get(t);r&&r.slice().map(function(e){e(n)}),(r=e.get(`*`))&&r.slice().map(function(e){e(t,n)})}}}function A(){return Math.random().toString(36).slice(2,7)}function j(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function M(e){let t=e.split(`?`),n=t[0],r=t[1],i={query:{},pagePath:n};return r&&r.split(`&`).forEach(e=>{let t=e.split(`=`)[0],n=e.split(`=`)[1];i.query[t]=n}),i}function N(e,t){let n=e;for(;n?.classList&&!n.classList.contains(t);)n=n.parentNode;return n===document?null:n}function te(e){return new Promise((t,n)=>{fetch(`${e}`).then(e=>e.text()).then(e=>{t(e)}).catch(()=>{t(null)})})}function P(e,t){let n={},r=e.window||{},i=t||{};return n.navigationBarTitleText=i.navigationBarTitleText||r.navigationBarTitleText||``,n.navigationBarBackgroundColor=i.navigationBarBackgroundColor||r.navigationBarBackgroundColor||`#000`,n.navigationBarTextStyle=i.navigationBarTextStyle||r.navigationBarTextStyle||`white`,n.backgroundColor=i.backgroundColor||r.backgroundColor||`#fff`,n.navigationStyle=i.navigationStyle||r.navigationStyle||`default`,n.usingComponents=i.usingComponents||{},n}var F=`<div class="dimina-native-webview">
4
+ `,i)}while(r!==-1);return a+=e.slice(i),a}var{stdout:p,stderr:m}=u,h=Symbol(`GENERATOR`),g=Symbol(`STYLER`),_=Symbol(`IS_EMPTY`),v=[`ansi`,`ansi`,`ansi256`,`ansi16m`],y=Object.create(null),b=(e,t={})=>{if(t.level&&!(Number.isInteger(t.level)&&t.level>=0&&t.level<=3))throw Error("The `level` option should be an integer from 0 to 3");let n=p?p.level:0;e.level=t.level===void 0?n:t.level},x=e=>{let t=(...e)=>e.join(` `);return b(t,e),Object.setPrototypeOf(t,S.prototype),t};function S(e){return x(e)}Object.setPrototypeOf(S.prototype,Function.prototype);for(let[e,t]of Object.entries(s))y[e]={get(){let n=E(this,T(t.open,t.close,this[g]),this[_]);return Object.defineProperty(this,e,{value:n}),n}};y.visible={get(){let e=E(this,this[g],!0);return Object.defineProperty(this,"visible",{value:e}),e}};var C=(e,t,n,...r)=>e===`rgb`?t===`ansi16m`?s[n].ansi16m(...r):t===`ansi256`?s[n].ansi256(s.rgbToAnsi256(...r)):s[n].ansi(s.rgbToAnsi(...r)):e===`hex`?C(`rgb`,t,n,...s.hexToRgb(...r)):s[n][e](...r);for(let e of[`rgb`,`hex`,`ansi256`]){y[e]={get(){let{level:t}=this;return function(...n){let r=T(C(e,v[t],`color`,...n),s.color.close,this[g]);return E(this,r,this[_])}}};let t=`bg`+e[0].toUpperCase()+e.slice(1);y[t]={get(){let{level:t}=this;return function(...n){let r=T(C(e,v[t],`bgColor`,...n),s.bgColor.close,this[g]);return E(this,r,this[_])}}}}var w=Object.defineProperties(()=>{},{...y,level:{enumerable:!0,get(){return this[h].level},set(e){this[h].level=e}}}),T=(e,t,n)=>{let r,i;return n===void 0?(r=e,i=t):(r=n.openAll+e,i=t+n.closeAll),{open:e,close:t,openAll:r,closeAll:i,parent:n}},E=(e,t,n)=>{let r=(...e)=>ee(r,e.length===1?``+e[0]:e.join(` `));return Object.setPrototypeOf(r,w),r[h]=e,r[g]=t,r[_]=n,r},ee=(e,t)=>{if(e.level<=0||!t)return e[_]?``:t;let n=e[g];if(n===void 0)return t;let{openAll:r,closeAll:i}=n;if(t.includes(`\x1B`))for(;n!==void 0;)t=d(t,n.close,n.open),n=n.parent;let a=t.indexOf(`
5
+ `);return a!==-1&&(t=f(t,i,r,a)),r+t+i};Object.defineProperties(S.prototype,y);var D=S();S({level:m?m.level:0});function O(e){return{all:e||=new Map,on:function(t,n){var r=e.get(t);r?r.push(n):e.set(t,[n])},off:function(t,n){var r=e.get(t);r&&(n?r.splice(r.indexOf(n)>>>0,1):e.set(t,[]))},emit:function(t,n){var r=e.get(t);r&&r.slice().map(function(e){e(n)}),(r=e.get(`*`))&&r.slice().map(function(e){e(t,n)})}}}function k(){return Math.random().toString(36).slice(2,7)}function A(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function j(e){let t=e.split(`?`),n=t[0],r=t[1],i={query:{},pagePath:n};return r&&r.split(`&`).forEach(e=>{let t=e.split(`=`)[0],n=e.split(`=`)[1];i.query[t]=n}),i}function M(e,t){let n=e;for(;n?.classList&&!n.classList.contains(t);)n=n.parentNode;return n===document?null:n}function N(e){return new Promise((t,n)=>{fetch(`${e}`).then(e=>e.text()).then(e=>{t(e)}).catch(()=>{t(null)})})}function P(e,t){let n={},r=e.window||{},i=t||{};return n.navigationBarTitleText=i.navigationBarTitleText||r.navigationBarTitleText||``,n.navigationBarBackgroundColor=i.navigationBarBackgroundColor||r.navigationBarBackgroundColor||`#000`,n.navigationBarTextStyle=i.navigationBarTextStyle||r.navigationBarTextStyle||`white`,n.backgroundColor=i.backgroundColor||r.backgroundColor||`#fff`,n.navigationStyle=i.navigationStyle||r.navigationStyle||`default`,n.usingComponents=i.usingComponents||{},n}var F=`<div class="dimina-native-webview">
6
6
  <!-- 导航区域 -->
7
7
  <div class="dimina-native-webview__navigation">
8
8
  <div class="dimina-native-webview__navigation-content">
@@ -17,7 +17,7 @@ var e=10,t=(e=0)=>t=>`\u001B[${t+e}m`,n=(e=0)=>t=>`\u001B[${38+e};5;${t}m`,r=(e=
17
17
  <iframe class="dimina-native-webview__window" title="pageFrame"></iframe>
18
18
  </div>
19
19
  </div>
20
- </div>`,I=class{constructor(e){this.opts=e,this.id=`webview_${A()}`,this.el=document.createElement(`div`),this.el.classList.add(`dimina-native-view`),this.el.innerHTML=F,this.setInitialStyle(),this.iframe=this.el.querySelector(`.dimina-native-webview__window`),this.iframe.src=`/pageFrame.html?vconsole=1`,this.iframe.name=this.id,this.event=k(),this.bindBackEvent()}async init(e){await this.frameLoaded();let t=window.frames[this.iframe.name];t.DiminaRenderBridge.invoke=e=>{this.event.emit(`invoke`,e)},t.DiminaRenderBridge.publish=e=>{this.event.emit(`publish`,e)},e?.()}invoke(e){this.event.on(`invoke`,e)}publish(e){this.event.on(`publish`,e)}postMessage(e){window.frames[this.iframe.name].DiminaRenderBridge.onMessage(e)}bindBackEvent(){let e=this.el.querySelector(`.dimina-native-webview__navigation-left-btn`);e.onclick=()=>{this.parent.parent.navigateBack()}}frameLoaded(){return new Promise(e=>{this.iframe.onload=()=>{e()}})}setInitialStyle(){let e=this.opts.configInfo,t=this.el.querySelector(`.dimina-native-webview`),n=this.el.querySelector(`.dimina-native-webview__navigation-title`),r=this.el.querySelector(`.dimina-native-webview__navigation`),i=this.el.querySelector(`.dimina-native-webview__navigation-left-btn`),a=this.el.querySelector(`.dimina-native-webview__root`);this.opts.isRoot?i.style.display=`none`:i.style.display=`block`,e.navigationBarTextStyle===`white`?r.classList.add(`dimina-native-webview__navigation--white`):r.classList.add(`dimina-native-webview__navigation--black`),e.navigationStyle===`custom`&&t.classList.add(`dimina-native-webview--custom-nav`),a.style.backgroundColor=e.backgroundColor,r.style.backgroundColor=e.navigationBarBackgroundColor,n.textContent=e.navigationBarTitleText}},L=class{constructor(e){this.id=`bridge_${A()}`,this.opts=e,this.webview=null,this.jscore=e.jscore,this.parent=null,this.resetStatus()}async init(){this.jscore.invoke(e=>this.messageInvoke(`service`,e)),this.jscore.publish(e=>this.messagePublish(e)),this.webview=await this.createWebview(),this.webview.invoke(e=>this.messageInvoke(`render`,e)),this.webview.publish(e=>this.messagePublish(e))}messagePublish(e){typeof e==`string`&&(e=JSON.parse(e));let{body:t,target:n}=e;t.bridgeId&&t.bridgeId!==this.id||(n===`service`?this.jscore.postMessage(e):n===`render`&&this.webview.postMessage(e))}messageInvoke(e,t){typeof t==`string`&&(t=JSON.parse(t));let{type:n,body:r,target:i}=t;if(r.bridgeId&&r.bridgeId!==this.id)return;console.log(O.green(`[container] receive msg from ${e}: `),t);let a={type:n,body:{bridgeId:this.id,pagePath:this.opts.pagePath,scene:this.opts.scene,query:this.opts.query,...r}};if(i===`service`){if(n===`serviceResourceLoaded`)if(this.serviceResource=!0,this.isResourceLoaded())a.type=`resourceLoaded`;else return;else if(n===`renderResourceLoaded`)if(this.renderResource=!0,this.isResourceLoaded())a.type=`resourceLoaded`;else return;this.jscore.postMessage(a)}else if(i===`container`&&n===`invokeAPI`){let{name:e,params:t}=r;this.parent.invokeApi(e,t)}}start(){this.webview.postMessage({type:`loadResource`,body:{bridgeId:this.id,appId:this.opts.appId,pagePath:this.opts.pagePath,root:this.opts.root,baseUrl:`/`}}),this.jscore.postMessage({type:`loadResource`,body:{bridgeId:this.id,appId:this.opts.appId,pagePath:this.opts.pagePath,root:this.opts.root,baseUrl:`/`,hostEnv:this.parent.getHostEnvSnapshot()}}),this.opts.isRoot&&this.jscore.postMessage({type:`onUpdateStatusChange`,body:{bridgeId:this.id,event:`noupdate`}})}resetStatus(){this.serviceResource=!1,this.renderResource=!1}createWebview(){return new Promise(e=>{let t=new I({configInfo:this.opts.configInfo,isRoot:this.opts.isRoot});t.parent=this,t.init(()=>{e(t)}),this.opts.isRoot||t.el.classList.add(`dimina-native-view--before-enter`),this.parent.webviewsContainer.appendChild(t.el)})}isResourceLoaded(){return this.serviceResource&&this.renderResource}appShow(){this.isResourceLoaded()&&this.jscore.postMessage({type:`appShow`,body:{}})}appHide(){this.isResourceLoaded()&&this.jscore.postMessage({type:`appHide`,body:{}})}pageShow(){this.isResourceLoaded()&&this.jscore.postMessage({type:`pageShow`,body:{bridgeId:this.id}})}pageHide(){this.isResourceLoaded()&&this.jscore.postMessage({type:`pageHide`,body:{bridgeId:this.id}})}destroy(){this.isResourceLoaded()&&this.jscore.postMessage({type:`pageUnload`,body:{bridgeId:this.id}})}},R=`/assets/service.js`,z=class{constructor(e){this.parent=e,this.worker=null,this.event=k()}async init(){let e=this.parent.getApiNamespaces?.()||[],t=Object.keys(this.parent.apiRegistry??{}),n=JSON.stringify({apiNamespaces:e,registeredApis:t});this.worker=new Worker(R,{type:`classic`,name:n}),this.worker.onmessage=e=>{let t=e.data;this.event.emit(t.method,t)}}invoke(e){this.event.on(`invoke`,e)}publish(e){this.event.on(`publish`,e)}postMessage(e){this.worker.postMessage(e)}destroy(){this.worker.terminate()}},B=class{static ROUTE_QUERY_KEYS=[`appId`,`entry`,`page`];static _encodePage(e,t){return t&&Object.keys(t).length>0?`${e}?${Object.entries(t).map(([e,t])=>`${encodeURIComponent(e)}=${encodeURIComponent(t)}`).join(`&`)}`:e}static _decodePage(e){let t=e.indexOf(`?`);if(t===-1)return{pagePath:e,query:{}};let n=e.slice(0,t),r={};return new URLSearchParams(e.slice(t+1)).forEach((e,t)=>{r[t]=e}),{pagePath:n,query:r}}static _encodeSearchValue(e){return encodeURIComponent(e).replace(/%2F/g,`/`)}static _normalizeSearch(e){return e?e.startsWith(`?`)?e.slice(1):e:``}static _stringifySearchParams(e){return Array.from(e.entries()).map(([e,t])=>`${encodeURIComponent(e)}=${this._encodeSearchValue(t)}`).join(`&`)}static buildRouteSearch(e,t,n=typeof window<`u`?window.location.search:``){let r=new URLSearchParams(this._normalizeSearch(n));if(this.ROUTE_QUERY_KEYS.forEach(e=>r.delete(e)),!e||!t?.length)return this._stringifySearchParams(r);let i=t[0],a=t[t.length-1];return r.set(`appId`,e),r.set(`entry`,this._encodePage(i.pagePath,i.query||{})),r.set(`page`,this._encodePage(a.pagePath,a.query||{})),this._stringifySearchParams(r)}static buildRouteURL(e,t,n=typeof window<`u`?`${window.location.origin}${window.location.pathname}`:``){let r=this.buildRouteSearch(e,t);return`${n}${r?`?${r}`:``}`}static syncStack(e,t){let n=this.buildRouteSearch(e,t);history.replaceState(null,``,`${window.location.pathname}${n?`?${n}`:``}`)}static clear(){let e=new URLSearchParams(this._normalizeSearch(window.location.search));this.ROUTE_QUERY_KEYS.forEach(t=>e.delete(t));let t=this._stringifySearchParams(e);history.replaceState(null,``,`${window.location.pathname}${t?`?${t}`:``}`)}static parseSearch(e){let t=new URLSearchParams(this._normalizeSearch(e)),n=t.get(`appId`),r=t.get(`entry`),i=t.get(`page`)||r;if(!n||!r)return null;let a=this._decodePage(r);if(!a.pagePath)return null;let o=[a];if(i&&i!==r){let e=this._decodePage(i);e.pagePath&&o.push(e)}return{appId:n,stack:o}}static parseHash(e){if(!e||e.length<=1)return null;let t=e.slice(1).split(`|`);if(t.length<2)return null;let n=t[0],r=t.slice(1).map(e=>this._decodePage(e));return!n||r.length===0?null:{appId:n,stack:r}}static parse(e,t=typeof window<`u`?window.location.search:``){return this.parseSearch(t)||this.parseHash(e)}},V=`<div class="dimina-mini-app">
20
+ </div>`,I=class{constructor(e){this.opts=e,this.id=`webview_${k()}`,this.el=document.createElement(`div`),this.el.classList.add(`dimina-native-view`),this.el.innerHTML=F,this.setInitialStyle(),this.iframe=this.el.querySelector(`.dimina-native-webview__window`),this.iframe.src=`/pageFrame.html?vconsole=1`,this.iframe.name=this.id,this.event=O(),this.bindBackEvent()}async init(e){await this.frameLoaded();let t=window.frames[this.iframe.name];t.DiminaRenderBridge.invoke=e=>{this.event.emit(`invoke`,e)},t.DiminaRenderBridge.publish=e=>{this.event.emit(`publish`,e)},e?.()}invoke(e){this.event.on(`invoke`,e)}publish(e){this.event.on(`publish`,e)}postMessage(e){window.frames[this.iframe.name].DiminaRenderBridge.onMessage(e)}bindBackEvent(){let e=this.el.querySelector(`.dimina-native-webview__navigation-left-btn`);e.onclick=()=>{this.parent.parent.navigateBack()}}frameLoaded(){return new Promise(e=>{this.iframe.onload=()=>{e()}})}setInitialStyle(){let e=this.opts.configInfo,t=this.el.querySelector(`.dimina-native-webview`),n=this.el.querySelector(`.dimina-native-webview__navigation-title`),r=this.el.querySelector(`.dimina-native-webview__navigation`),i=this.el.querySelector(`.dimina-native-webview__navigation-left-btn`),a=this.el.querySelector(`.dimina-native-webview__root`);this.opts.isRoot?i.style.display=`none`:i.style.display=`block`,e.navigationBarTextStyle===`white`?r.classList.add(`dimina-native-webview__navigation--white`):r.classList.add(`dimina-native-webview__navigation--black`),e.navigationStyle===`custom`&&t.classList.add(`dimina-native-webview--custom-nav`),a.style.backgroundColor=e.backgroundColor,r.style.backgroundColor=e.navigationBarBackgroundColor,n.textContent=e.navigationBarTitleText}},L=class{constructor(e){this.id=`bridge_${k()}`,this.opts=e,this.webview=null,this.jscore=e.jscore,this.parent=null,this.resetStatus()}async init(){this.jscore.invoke(e=>this.messageInvoke(`service`,e)),this.jscore.publish(e=>this.messagePublish(e)),this.webview=await this.createWebview(),this.webview.invoke(e=>this.messageInvoke(`render`,e)),this.webview.publish(e=>this.messagePublish(e))}messagePublish(e){typeof e==`string`&&(e=JSON.parse(e));let{body:t,target:n}=e;t.bridgeId&&t.bridgeId!==this.id||(n===`service`?this.jscore.postMessage(e):n===`render`&&this.webview.postMessage(e))}messageInvoke(e,t){typeof t==`string`&&(t=JSON.parse(t));let{type:n,body:r,target:i}=t;if(r.bridgeId&&r.bridgeId!==this.id)return;console.log(D.green(`[container] receive msg from ${e}: `),t);let a={type:n,body:{bridgeId:this.id,pagePath:this.opts.pagePath,scene:this.opts.scene,query:this.opts.query,...r}};if(i===`service`){if(n===`serviceResourceLoaded`)if(this.serviceResource=!0,this.isResourceLoaded())a.type=`resourceLoaded`;else return;else if(n===`renderResourceLoaded`)if(this.renderResource=!0,this.isResourceLoaded())a.type=`resourceLoaded`;else return;this.jscore.postMessage(a)}else if(i===`container`&&n===`invokeAPI`){let{name:e,params:t}=r;this.parent.invokeApi(e,t)}}start(){this.webview.postMessage({type:`loadResource`,body:{bridgeId:this.id,appId:this.opts.appId,pagePath:this.opts.pagePath,root:this.opts.root,baseUrl:`/`}}),this.jscore.postMessage({type:`loadResource`,body:{bridgeId:this.id,appId:this.opts.appId,pagePath:this.opts.pagePath,root:this.opts.root,baseUrl:`/`,hostEnv:this.parent.getHostEnvSnapshot()}}),this.opts.isRoot&&this.jscore.postMessage({type:`onUpdateStatusChange`,body:{bridgeId:this.id,event:`noupdate`}})}resetStatus(){this.serviceResource=!1,this.renderResource=!1}createWebview(){return new Promise(e=>{let t=new I({configInfo:this.opts.configInfo,isRoot:this.opts.isRoot});t.parent=this,t.init(()=>{e(t)}),this.opts.isRoot||t.el.classList.add(`dimina-native-view--before-enter`),this.parent.webviewsContainer.appendChild(t.el)})}isResourceLoaded(){return this.serviceResource&&this.renderResource}appShow(){this.isResourceLoaded()&&this.jscore.postMessage({type:`appShow`,body:{}})}appHide(){this.isResourceLoaded()&&this.jscore.postMessage({type:`appHide`,body:{}})}pageShow(){this.isResourceLoaded()&&this.jscore.postMessage({type:`pageShow`,body:{bridgeId:this.id}})}pageHide(){this.isResourceLoaded()&&this.jscore.postMessage({type:`pageHide`,body:{bridgeId:this.id}})}destroy(){this.isResourceLoaded()&&this.jscore.postMessage({type:`pageUnload`,body:{bridgeId:this.id}})}},R=`/assets/service.js`,z=class{constructor(e){this.parent=e,this.worker=null,this.event=O()}async init(){let e=this.parent.getApiNamespaces?.()||[],t=Object.keys(this.parent.apiRegistry??{}),n=JSON.stringify({apiNamespaces:e,registeredApis:t});this.worker=new Worker(R,{type:`classic`,name:n}),this.worker.onmessage=e=>{let t=e.data;this.event.emit(t.method,t)}}invoke(e){this.event.on(`invoke`,e)}publish(e){this.event.on(`publish`,e)}postMessage(e){this.worker.postMessage(e)}destroy(){this.worker.terminate()}},B=class{static ROUTE_QUERY_KEYS=[`appId`,`entry`,`page`];static _encodePage(e,t){return t&&Object.keys(t).length>0?`${e}?${Object.entries(t).map(([e,t])=>`${encodeURIComponent(e)}=${encodeURIComponent(t)}`).join(`&`)}`:e}static _decodePage(e){let t=e.indexOf(`?`);if(t===-1)return{pagePath:e,query:{}};let n=e.slice(0,t),r={};return new URLSearchParams(e.slice(t+1)).forEach((e,t)=>{r[t]=e}),{pagePath:n,query:r}}static _encodeSearchValue(e){return encodeURIComponent(e).replace(/%2F/g,`/`)}static _normalizeSearch(e){return e?e.startsWith(`?`)?e.slice(1):e:``}static _stringifySearchParams(e){return Array.from(e.entries()).map(([e,t])=>`${encodeURIComponent(e)}=${this._encodeSearchValue(t)}`).join(`&`)}static buildRouteSearch(e,t,n=typeof window<`u`?window.location.search:``){let r=new URLSearchParams(this._normalizeSearch(n));if(this.ROUTE_QUERY_KEYS.forEach(e=>r.delete(e)),!e||!t?.length)return this._stringifySearchParams(r);let i=t[0],a=t[t.length-1];return r.set(`appId`,e),r.set(`entry`,this._encodePage(i.pagePath,i.query||{})),r.set(`page`,this._encodePage(a.pagePath,a.query||{})),this._stringifySearchParams(r)}static buildRouteURL(e,t,n=typeof window<`u`?`${window.location.origin}${window.location.pathname}`:``){let r=this.buildRouteSearch(e,t);return`${n}${r?`?${r}`:``}`}static syncStack(e,t){let n=this.buildRouteSearch(e,t);history.replaceState(null,``,`${window.location.pathname}${n?`?${n}`:``}`)}static clear(){let e=new URLSearchParams(this._normalizeSearch(window.location.search));this.ROUTE_QUERY_KEYS.forEach(t=>e.delete(t));let t=this._stringifySearchParams(e);history.replaceState(null,``,`${window.location.pathname}${t?`?${t}`:``}`)}static parseSearch(e){let t=new URLSearchParams(this._normalizeSearch(e)),n=t.get(`appId`),r=t.get(`entry`),i=t.get(`page`)||r;if(!n||!r)return null;let a=this._decodePage(r);if(!a.pagePath)return null;let o=[a];if(i&&i!==r){let e=this._decodePage(i);e.pagePath&&o.push(e)}return{appId:n,stack:o}}static parseHash(e){if(!e||e.length<=1)return null;let t=e.slice(1).split(`|`);if(t.length<2)return null;let n=t[0],r=t.slice(1).map(e=>this._decodePage(e));return!n||r.length===0?null:{appId:n,stack:r}}static parse(e,t=typeof window<`u`?window.location.search:``){return this.parseSearch(t)||this.parseHash(e)}},V=`<div class="dimina-mini-app">
21
21
  <!-- 右上方药丸按钮 -->
22
22
  <ul class="dimina-mini-app-navigation__actions">
23
23
  <li class="dimina-mini-app-navigation__actions-variable"></li>
@@ -63,12 +63,12 @@ var e=10,t=(e=0)=>t=>`\u001B[${t+e}m`,n=(e=0)=>t=>`\u001B[${38+e};5;${t}m`,r=(e=
63
63
  </div>
64
64
  </div>
65
65
  </div>
66
- `,H=(e,t,n=560)=>new Promise(r=>{let i=setTimeout(r,n),a=n=>{(!t||n.propertyName===t)&&(clearTimeout(i),e.removeEventListener(`transitionend`,a),r())};e.addEventListener(`transitionend`,a)}),U=class{constructor(e){this.appInfo=e,this.id=`mini_app_${A()}`,this.parent=null,this.appId=e.appId,this.appConfig=null,this.bridgeList=[],this.jscore=new z(this),this.webviewsContainer=null,this.webviewAnimaEnd=!0,this.el=document.createElement(`div`),this.el.classList.add(`dimina-native-view`),this.toastInfo={dom:null,timer:null},this.color=null,this.apiRegistry={},this._extSubscriptions=new Map,this.tabBarConfig=null,this.tabBarPaths=[],this.tabBarBridges=new Map,this.currentTabPath=null,this.tabBarEl=null,this.tabBarHeight=0,this.tabBarBadges=[],this.tabBarRedDots=[],this.tabBarApiVisible=!0,this._modalStack=[],this._modalPendingTimers=new Set,this._destroyed=!1}_normalizePagePath(e){return e?e.startsWith(`/`)?e.slice(1):e:``}_isTabBarPage(e){return this.tabBarPaths.includes(this._normalizePagePath(e))}getCurrentPagePath(){return this.bridgeList[this.bridgeList.length-1]?.opts?.pagePath||this.appInfo.pagePath||this.appConfig?.app?.entryPagePath||``}getCurrentPageQuery(){return this.bridgeList[this.bridgeList.length-1]?.opts?.query||this.appInfo.query||{}}getEntryPagePath(){return this.appInfo.pagePath||this.appConfig?.app?.entryPagePath||``}async copyText(e,t){try{if(navigator.clipboard?.writeText)await navigator.clipboard.writeText(e);else{let t=document.createElement(`textarea`);t.value=e,t.setAttribute(`readonly`,`readonly`),t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t),t.select(),document.execCommand(`copy`),document.body.removeChild(t)}this.showToast({title:t,icon:`success`})}catch{this.showToast({title:`复制失败`,icon:`none`})}}closeMiniProgram(){B.clear(),this.closeMiniAppMenu(),Z.closeApp(this)}renderMiniAppMenu(){let e=this.el.querySelector(`.dimina-mini-app-menu__app-name`),t=this.el.querySelector(`.dimina-mini-app-menu__app-id`),n=this.el.querySelector(`.dimina-mini-app-menu__app-desc`),r=this.el.querySelector(`.dimina-mini-app-menu__app-logo-img`),i=this.el.querySelector(`.dimina-mini-app-menu__quick-actions`),a=this.getCurrentPagePath(),o=this.getEntryPagePath(),s=this.getCurrentPageQuery(),c=a||o||``,l=B.buildRouteURL(this.appId,[{pagePath:o,query:this.appInfo.query||{}},{pagePath:c,query:s}]);e.textContent=this.appInfo.name||`未命名小程序`,t.textContent=`AppID:${this.appId||`--`}`,n.textContent=`当前页面:${c||`--`}`,r.src=this.appInfo.logo||``;let u=[{label:`复制链接`,icon:`↗`,handler:()=>this.copyText(l,`链接已复制`)},{label:`重新进入`,icon:`↻`,handler:()=>{this.closeMiniAppMenu(),this.reLaunch({url:o||a})}},{label:`关闭小程序`,icon:`×`,danger:!0,handler:()=>this.closeMiniProgram()}];i.innerHTML=u.map((e,t)=>`
66
+ `,H=(e,t,n=560)=>new Promise(r=>{let i=setTimeout(r,n),a=n=>{(!t||n.propertyName===t)&&(clearTimeout(i),e.removeEventListener(`transitionend`,a),r())};e.addEventListener(`transitionend`,a)}),U=class{constructor(e){this.appInfo=e,this.id=`mini_app_${k()}`,this.parent=null,this.appId=e.appId,this.appConfig=null,this.bridgeList=[],this.jscore=new z(this),this.webviewsContainer=null,this.webviewAnimaEnd=!0,this.el=document.createElement(`div`),this.el.classList.add(`dimina-native-view`),this.toastInfo={dom:null,timer:null},this.color=null,this.apiRegistry={},this._extSubscriptions=new Map,this.tabBarConfig=null,this.tabBarPaths=[],this.tabBarBridges=new Map,this.currentTabPath=null,this.tabBarEl=null,this.tabBarHeight=0,this.tabBarBadges=[],this.tabBarRedDots=[],this.tabBarApiVisible=!0,this._modalStack=[],this._modalPendingTimers=new Set,this._destroyed=!1}_normalizePagePath(e){return e?e.startsWith(`/`)?e.slice(1):e:``}_isTabBarPage(e){return this.tabBarPaths.includes(this._normalizePagePath(e))}getCurrentPagePath(){return this.bridgeList[this.bridgeList.length-1]?.opts?.pagePath||this.appInfo.pagePath||this.appConfig?.app?.entryPagePath||``}getCurrentPageQuery(){return this.bridgeList[this.bridgeList.length-1]?.opts?.query||this.appInfo.query||{}}getEntryPagePath(){return this.appInfo.pagePath||this.appConfig?.app?.entryPagePath||``}async copyText(e,t){try{if(navigator.clipboard?.writeText)await navigator.clipboard.writeText(e);else{let t=document.createElement(`textarea`);t.value=e,t.setAttribute(`readonly`,`readonly`),t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t),t.select(),document.execCommand(`copy`),document.body.removeChild(t)}this.showToast({title:t,icon:`success`})}catch{this.showToast({title:`复制失败`,icon:`none`})}}closeMiniProgram(){B.clear(),this.closeMiniAppMenu(),Z.closeApp(this)}renderMiniAppMenu(){let e=this.el.querySelector(`.dimina-mini-app-menu__app-name`),t=this.el.querySelector(`.dimina-mini-app-menu__app-id`),n=this.el.querySelector(`.dimina-mini-app-menu__app-desc`),r=this.el.querySelector(`.dimina-mini-app-menu__app-logo-img`),i=this.el.querySelector(`.dimina-mini-app-menu__quick-actions`),a=this.getCurrentPagePath(),o=this.getEntryPagePath(),s=this.getCurrentPageQuery(),c=a||o||``,l=B.buildRouteURL(this.appId,[{pagePath:o,query:this.appInfo.query||{}},{pagePath:c,query:s}]);e.textContent=this.appInfo.name||`未命名小程序`,t.textContent=`AppID:${this.appId||`--`}`,n.textContent=`当前页面:${c||`--`}`,r.src=this.appInfo.logo||``;let u=[{label:`复制链接`,icon:`↗`,handler:()=>this.copyText(l,`链接已复制`)},{label:`重新进入`,icon:`↻`,handler:()=>{this.closeMiniAppMenu(),this.reLaunch({url:o||a})}},{label:`关闭小程序`,icon:`×`,danger:!0,handler:()=>this.closeMiniProgram()}];i.innerHTML=u.map((e,t)=>`
67
67
  <button type="button" class="dimina-mini-app-menu__quick-action${e.danger?` is-danger`:``}" data-quick-index="${t}">
68
68
  <span class="dimina-mini-app-menu__quick-action-icon">${e.icon}</span>
69
69
  <span class="dimina-mini-app-menu__quick-action-label">${e.label}</span>
70
70
  </button>
71
- `).join(``),i.querySelectorAll(`[data-quick-index]`).forEach((e,t)=>{e.onclick=()=>u[t].handler()})}openMiniAppMenu(){let e=this.el.querySelector(`.dimina-mini-app-menu__mask`),t=this.el.querySelector(`.dimina-mini-app-menu`);this.renderMiniAppMenu(),e.style.display=`block`,requestAnimationFrame(()=>{e.classList.add(`show`),t.classList.add(`show`)})}closeMiniAppMenu(){let e=this.el.querySelector(`.dimina-mini-app-menu__mask`),t=this.el.querySelector(`.dimina-mini-app-menu`);e.classList.remove(`show`),t.classList.remove(`show`)}registerApi(e,t){this.apiRegistry[e]=t}invokeApi(e,t){let n=this.apiRegistry[e];n?n.call(this,t):typeof this[e]==`function`?this[e](t):this._handleExtCall(e,t)}viewDidLoad(){this.initPageFrame(),this.webviewsContainer=this.el.querySelector(`.dimina-mini-app__webviews`),this.showLaunchScreen(),this.bindMoreEvent(),this.bindCloseEvent(),this.initApp()}async initApp(){await this.jscore.init();let e=`main`,t=`${this.appInfo.appId}/${e}/app-config.json`,[n]=await Promise.all([te(`/${t}`),j(560)]);if(!n)return;this.appConfig=JSON.parse(n),this._initTabBar();let r=this.appInfo.pagePath||this.appConfig.app.entryPagePath,i=this.appConfig.modules[r],a=P(this.appConfig.app,i);this.updateTargetPageColorStyle(a);let o=await this.createBridge({pagePath:r,query:this.appInfo.query,scene:this.appInfo.scene,jscore:this.jscore,isRoot:!0,root:e,appId:this.appInfo.appId,pages:this.appConfig.app.pages,configInfo:a});if(this.bridgeList.push(o),this._isTabBarPage(r)){let e=this._normalizePagePath(r);this.tabBarBridges.set(e,o),this.currentTabPath=e,this._setTabBarVisible(!0),this._updateTabBarSelection(e)}o.start(),this.appInfo.restoreStack&&this.appInfo.restoreStack.length>1&&await this.restorePageStack(this.appInfo.restoreStack.slice(1)),this._syncHash(),this.hideLaunchScreen()}async restorePageStack(e){for(let t=0;t<e.length;t++){let{pagePath:n,query:r}=e[t],i=t===e.length-1,a=n.startsWith(`/`)?n.slice(1):n,o=this.appConfig.modules[a],s=P(this.appConfig.app,o),c=await this.createBridge({pagePath:a,query:r,scene:this.appInfo.scene,jscore:this.jscore,isRoot:!1,root:o?.root||`main`,appId:this.appInfo.appId,pages:this.appConfig.app.pages,configInfo:s}),l=this.bridgeList[this.bridgeList.length-1];l.webview.el.classList.remove(`dimina-native-view--instage`),l.webview.el.classList.add(`dimina-native-view--slide-out`),this.bridgeList.push(c),c.webview.el.style.zIndex=this.bridgeList.length+1,c.webview.el.classList.remove(`dimina-native-view--before-enter`),i||c.webview.el.classList.add(`dimina-native-view--slide-out`),c.start()}if(e.length>0){let e=this.bridgeList[this.bridgeList.length-1],t=this.appConfig.modules[e.opts.pagePath],n=P(this.appConfig.app,t);this.updateTargetPageColorStyle(n),this._isTabBarPage(e.opts.pagePath)||this._setTabBarVisible(!1)}}_syncHash(){let e=this.bridgeList.map(e=>({pagePath:e.opts.pagePath.startsWith(`/`)?e.opts.pagePath.slice(1):e.opts.pagePath,query:e.opts.query||{}}));B.syncStack(this.appId,e)}async createBridge(e){let{jscore:t,configInfo:n,isRoot:r,appId:i,pagePath:a,query:o,scene:s,pages:c,root:l}=e,u=new L({jscore:t,configInfo:n,isRoot:r,appId:i,pagePath:a,query:o,scene:s,pages:c,root:l});return u.parent=this,await u.init(),u}onPresentIn(){let e=this.bridgeList[this.bridgeList.length-1];e?.appShow(),e?.pageShow()}onPresentOut(){let e=this.bridgeList[this.bridgeList.length-1];e?.appHide(),e?.pageHide()}initPageFrame(){this.el.innerHTML=V}updateTargetPageColorStyle(e){let{navigationBarTextStyle:t}=e;this.updateActionColorStyle(t)}showLaunchScreen(){let e=this.el.querySelector(`.dimina-mini-app__launch-screen`),t=this.el.querySelector(`.dimina-mini-app__name`),n=this.el.querySelector(`.dimina-mini-app__logo-img-url`);this.updateActionColorStyle(`black`),t.innerHTML=this.appInfo.name,n.src=this.appInfo.logo,e.style.display=`block`}hideLaunchScreen(){let e=this.el.querySelector(`.dimina-mini-app__launch-screen`);e.style.display=`none`}updateActionColorStyle(e){this.color=e;let t=this.el.querySelector(`.dimina-mini-app-navigation__actions`);e===`white`?(t.classList.remove(`dimina-mini-app-navigation__actions--black`),t.classList.add(`dimina-mini-app-navigation__actions--white`)):e===`black`&&(t.classList.remove(`dimina-mini-app-navigation__actions--white`),t.classList.add(`dimina-mini-app-navigation__actions--black`)),this.parent.updateStatusBarColor(e)}restoreColorStyle(){this.updateActionColorStyle(this.color)}createCallbackFunction(e){if(e)return t=>{this.jscore.postMessage({type:`triggerCallback`,body:{id:e,args:t}})}}_createApiCallbacks({success:e,fail:t,complete:n}={}){return{onSuccess:this.createCallbackFunction(e),onFail:this.createCallbackFunction(t),onComplete:this.createCallbackFunction(n)}}async navigateTo(e){let{url:t,success:n,fail:r,complete:i}=e,{query:a,pagePath:o}=M(t),s=this.createCallbackFunction(n),c=this.createCallbackFunction(r),l=this.createCallbackFunction(i);if(this._isTabBarPage(o)){c?.({errMsg:`navigateTo:fail can not navigateTo a tabbar page`}),l?.();return}if(!this.webviewAnimaEnd)return;this.webviewAnimaEnd=!1;let u=this.appConfig.modules[o],d=P(this.appConfig.app,u);this.updateTargetPageColorStyle(d);let f=await this.createBridge({pagePath:o,query:a,scene:this.appInfo.scene,jscore:this.jscore,isRoot:!1,root:u?.root||`main`,appId:this.appInfo.appId,pages:this.appConfig.app.pages,configInfo:d}),p=this.bridgeList[this.bridgeList.length-1],m=p.webview;this.bridgeList.push(f),f.start(),this._syncHash(),m.el.classList.remove(`dimina-native-view--instage`),m.el.classList.add(`dimina-native-view--slide-out`),m.el.classList.add(`dimina-native-view--linear-anima`),p?.pageHide(),this._setTabBarVisible(!1),f.webview.el.style.zIndex=this.bridgeList.length+1,f.webview.el.classList.add(`dimina-native-view--enter-anima`),f.webview.el.classList.add(`dimina-native-view--instage`),await H(f.webview.el,`transform`),this.webviewAnimaEnd=!0,m.el.classList.remove(`dimina-native-view--linear-anima`),f.webview.el.classList.remove(`dimina-native-view--before-enter`),f.webview.el.classList.remove(`dimina-native-view--enter-anima`),f.webview.el.classList.remove(`dimina-native-view--instage`),s?.({errMsg:`navigateTo:ok`}),l?.()}reLaunch(e){if(!this.webviewAnimaEnd)return;this.webviewAnimaEnd=!1;let{url:t,success:n,fail:r,complete:i}=e,{query:a,pagePath:o}=M(t),s=this.createCallbackFunction(n),c=this.createCallbackFunction(r),l=this.createCallbackFunction(i);try{let e=this.appConfig.modules[o],t=P(this.appConfig.app,e);this.updateTargetPageColorStyle(t);let n=new Set([...this.bridgeList,...this.tabBarBridges.values()]);for(let e of n)e.destroy(),e.webview?.el?.remove();this.bridgeList.length=0,this.tabBarBridges.clear(),this.currentTabPath=null,this.webviewsContainer&&(this.webviewsContainer.innerHTML=``),this.createBridge({pagePath:o,query:a,scene:this.appInfo.scene,jscore:this.jscore,isRoot:!0,root:e?.root||`main`,appId:this.appInfo.appId,pages:this.appConfig.app.pages,configInfo:t}).then(e=>{if(this.bridgeList.push(e),this._isTabBarPage(o)){let t=this._normalizePagePath(o);this.tabBarBridges.set(t,e),this.currentTabPath=t,this._setTabBarVisible(!0),this._updateTabBarSelection(t)}else this._setTabBarVisible(!1);e.start(),this._syncHash(),e.webview.el.style.zIndex=1,this.webviewAnimaEnd=!0,s?.({errMsg:`reLaunch:ok`}),l?.()}).catch(e=>{c?.({errMsg:`reLaunch:fail ${e.message}`}),l?.(),this.webviewAnimaEnd=!0})}catch(e){c?.({errMsg:`reLaunch:fail ${e.message}`}),l?.(),this.webviewAnimaEnd=!0}}applyUpdate(){this.reLaunch({url:this.getEntryPagePath()})}redirectTo(e){let{url:t,success:n,fail:r,complete:i}=e,{query:a,pagePath:o}=M(t),s=this.createCallbackFunction(n),c=this.createCallbackFunction(r),l=this.createCallbackFunction(i);if(this._isTabBarPage(o)){c?.({errMsg:`redirectTo:fail can not redirectTo a tabbar page`}),l?.();return}if(!this.webviewAnimaEnd)return;this.webviewAnimaEnd=!1;let u=this.bridgeList[this.bridgeList.length-1],d=this._normalizePagePath(u.opts.pagePath),f=this.appConfig.modules[o],p=P(this.appConfig.app,f);this.updateTargetPageColorStyle(p),u.destroy(),u.opts={...u.opts,pagePath:o,query:a,configInfo:p},u.resetStatus(),u.start(),this._syncHash(),this.tabBarBridges.get(d)===u&&(this.tabBarBridges.delete(d),this.currentTabPath===d&&(this.currentTabPath=null)),this._setBridgeTabBarInset(u,!1),this._setTabBarVisible(!1),this.webviewAnimaEnd=!0,s?.({errMsg:`redirectTo:ok`}),l?.()}async navigateBack(){if(this.bridgeList.length<2||!this.webviewAnimaEnd)return;this.webviewAnimaEnd=!1;let e=this.bridgeList.pop(),t=this.bridgeList[this.bridgeList.length-1],n=this.appConfig.modules[t.opts.pagePath],r=P(this.appConfig.app,n);if(this.updateTargetPageColorStyle(r),e.webview.el.classList.add(`dimina-native-view--before-enter`),e.webview.el.classList.add(`dimina-native-view--enter-anima`),e?.destroy(),t.webview.el.classList.remove(`dimina-native-view--slide-out`),t.webview.el.classList.add(`dimina-native-view--instage`),t.webview.el.classList.add(`dimina-native-view--enter-anima`),t?.pageShow(),this._syncHash(),this._isTabBarPage(t.opts.pagePath)){let e=this._normalizePagePath(t.opts.pagePath);this.currentTabPath=e,this._setTabBarVisible(!0),this._updateTabBarSelection(e)}await H(t.webview.el,`transform`),this.webviewAnimaEnd=!0,t.webview.el.classList.remove(`dimina-native-view--enter-anima`),t.webview.el.classList.remove(`dimina-native-view--instage`),e.webview.el.parentNode.removeChild(e.webview.el)}async switchTab(e){let{url:t,success:n,fail:r,complete:i}=e,{query:a,pagePath:o}=M(t),s=this._normalizePagePath(o),c=this.createCallbackFunction(n),l=this.createCallbackFunction(r),u=this.createCallbackFunction(i);if(!this._isTabBarPage(s)){l?.({errMsg:`switchTab:fail not a tabBar page: ${s}`}),u?.();return}if(!this.webviewAnimaEnd){l?.({errMsg:`switchTab:fail busy`}),u?.();return}if(this.currentTabPath===s&&this.bridgeList.length===1){this._setTabBarVisible(!0),this._updateTabBarSelection(s),c?.({errMsg:`switchTab:ok`}),u?.();return}this.webviewAnimaEnd=!1;try{let e=this.currentTabPath,t=e?this.tabBarBridges.get(e):null,n=!!t&&this.bridgeList.length===1&&this.bridgeList[0]===t;for(;this.bridgeList.length>0;){let e=this.bridgeList[this.bridgeList.length-1];if(this._isTabBarPage(e.opts.pagePath))break;e.pageHide(),e.destroy(),e.webview?.el?.remove(),this.bridgeList.pop()}if(t&&t!==this.tabBarBridges.get(s)){n&&t.pageHide(),t.webview?.el&&(t.webview.el.style.display=`none`);let e=this.bridgeList.indexOf(t);e>=0&&this.bridgeList.splice(e,1)}let r=this.tabBarBridges.get(s),i=this.appConfig.modules[s],o=P(this.appConfig.app,i);this.updateTargetPageColorStyle(o),r||(r=await this.createBridge({pagePath:s,query:a,scene:this.appInfo.scene,jscore:this.jscore,isRoot:!0,root:i?.root||`main`,appId:this.appInfo.appId,pages:this.appConfig.app.pages,configInfo:o}),this.tabBarBridges.set(s,r),r.start());let l=r.webview.el;this._setBridgeTabBarInset(r,!0),l.classList.remove(`dimina-native-view--before-enter`,`dimina-native-view--slide-out`,`dimina-native-view--enter-anima`,`dimina-native-view--linear-anima`,`dimina-native-view--instage`),l.style.display=``,l.style.zIndex=1,this.bridgeList.includes(r)||this.bridgeList.push(r),this.currentTabPath=s,r.pageShow(),this._setTabBarVisible(!0),this._updateTabBarSelection(s),this._syncHash(),c?.({errMsg:`switchTab:ok`})}catch(e){l?.({errMsg:`switchTab:fail ${e.message}`})}finally{this.webviewAnimaEnd=!0,u?.()}}_initTabBar(){let e=this.appConfig?.app?.tabBar;!e||!Array.isArray(e.list)||e.list.length===0||(this.tabBarConfig=e,this.tabBarPaths=e.list.map(e=>this._normalizePagePath(e.pagePath)),this.tabBarBadges=e.list.map(()=>``),this.tabBarRedDots=e.list.map(()=>!1),this.tabBarApiVisible=!0,this._renderTabBar())}_renderTabBar(){if(this.tabBarEl=this.el.querySelector(`.dimina-mini-app__tabbar`),!this.tabBarEl)return;let{color:e,backgroundColor:t,borderStyle:n,list:r}=this.tabBarConfig,i=this._sanitizeCssColor(e)||`#999999`,a=this._sanitizeCssColor(t)||`#ffffff`;this.tabBarEl.textContent=``;let o=document.createElement(`div`);o.className=`dimina-tabbar`,o.style.backgroundColor=a,o.style.borderTopColor=this._getTabBarBorderColor(n),r.forEach((e,t)=>{let n=this._normalizePagePath(e.pagePath),r=document.createElement(`div`);r.className=`dimina-tabbar-item`,r.dataset.path=n,r.dataset.index=String(t);let a=this._resolveTabBarIcon(e.iconPath);a&&r.appendChild(this._createTabBarIcon(a,`dimina-tabbar-icon-default`));let s=this._resolveTabBarIcon(e.selectedIconPath);s&&r.appendChild(this._createTabBarIcon(s,`dimina-tabbar-icon-selected`));let c=document.createElement(`span`);c.className=`dimina-tabbar-text`,c.style.color=i,c.textContent=e.text||``,r.appendChild(c);let l=document.createElement(`span`);l.className=`dimina-tabbar-badge`,l.hidden=!0,r.appendChild(l);let u=document.createElement(`span`);u.className=`dimina-tabbar-red-dot`,u.hidden=!0,r.appendChild(u),o.appendChild(r)}),this.tabBarEl.appendChild(o),this.tabBarEl.addEventListener(`click`,e=>{let t=e.target.closest(`.dimina-tabbar-item`);if(!t)return;let n=t.dataset.path;n&&n!==this.currentTabPath&&this.switchTab({url:`/${n}`})}),typeof ResizeObserver<`u`&&(this._tabBarResizeObserver?.disconnect(),this._tabBarResizeObserver=new ResizeObserver(()=>this._syncTabBarHeightVar()),this._tabBarResizeObserver.observe(this.tabBarEl))}_createTabBarIcon(e,t){let n=document.createElement(`img`);return n.className=`dimina-tabbar-icon ${t}`,n.src=e,n.alt=``,n.addEventListener(`error`,()=>{n.style.display=`none`}),n}_sanitizeCssColor(e){if(!e||typeof e!=`string`)return``;let t=e.trim();return t.length===0||t.length>64?``:/[<>"';{}()\\]/.test(t)?/^(?:rgb|rgba|hsl|hsla)\(\s*[\d.,%\s/-]+\)$/i.test(t)?t:``:t}_getTabBarBorderColor(e){return e===`white`?`#ffffff`:`#e0e0e0`}_getTabBarHeight(){if(!this.tabBarEl)return this.tabBarHeight;let e=this.tabBarEl.getBoundingClientRect().height;if(!e&&this.tabBarEl.style.display===`none`){let t=this.tabBarEl.style.display,n=this.tabBarEl.style.visibility;this.tabBarEl.style.visibility=`hidden`,this.tabBarEl.style.display=`block`,e=this.tabBarEl.getBoundingClientRect().height,this.tabBarEl.style.display=t,this.tabBarEl.style.visibility=n}return e>0&&(this.tabBarHeight=e),this.tabBarHeight}_syncTabBarHeightVar(){let e=this._getTabBarHeight();this.el.style.setProperty(`--dimina-tabbar-height`,`${e}px`),this._syncTabBarBridgeInsets()}_setBridgeTabBarInset(e,t){let n=e?.webview?.el;if(n){if(!t){n.style.removeProperty(`bottom`);return}n.style.bottom=`${this._getTabBarHeight()}px`}}_syncTabBarBridgeInsets(){for(let e of this.tabBarBridges.values())this._setBridgeTabBarInset(e,!0)}_joinBaseUrl(...e){return`${`/`.endsWith(`/`)?`/`:`//`}${e.map(e=>String(e).trim().replace(/^\/+|\/+$/g,``)).filter(Boolean).join(`/`)}`}_resolveTabBarIcon(e){if(!e||typeof e!=`string`)return null;let t=e.trim();if(!t)return null;if(/^(?:data:|blob:|https?:|\/\/)/i.test(t))return t;let n=t.replace(/^\/+/,``).replace(/^\.\//,``),r=`${this.appId}/`;return n.startsWith(r)?this._joinBaseUrl(n):this._joinBaseUrl(this.appId,`main`,n)}_setTabBarVisible(e){if(!this.tabBarEl)return;let t=this.bridgeList[this.bridgeList.length-1],n=this._normalizePagePath(t?.opts?.pagePath),r=!!n&&n===this.currentTabPath&&this._isTabBarPage(n),i=e&&this.tabBarApiVisible&&r;this.tabBarEl.style.display=i?`block`:`none`,this._syncTabBarHeightVar()}_updateTabBarSelection(e){if(!this.tabBarEl||!this.tabBarConfig)return;let t=this.tabBarConfig.color||`#999999`,n=this.tabBarConfig.selectedColor||`#1890ff`;this.tabBarEl.querySelectorAll(`.dimina-tabbar-item`).forEach(r=>{let i=r.getAttribute(`data-path`)===e,a=r.querySelector(`.dimina-tabbar-text`),o=r.querySelector(`.dimina-tabbar-icon-default`),s=r.querySelector(`.dimina-tabbar-icon-selected`);a&&(a.style.color=i?n:t),o&&(o.style.display=i?`none`:`block`),s&&(s.style.display=i?`block`:`none`),r.classList.toggle(`dimina-tabbar-item--selected`,i)})}_getTabBarItemEl(e){return this.tabBarEl?.querySelector(`.dimina-tabbar-item[data-index="${e}"]`)||null}_validateTabBarIndex(e,t,n,r){let i=this.tabBarConfig?.list?.length||0;if(!i||!this.tabBarEl)return n?.({errMsg:`${e}:fail tabBar not configured`}),r?.(),!1;let a=Number(t);return t==null||!Number.isInteger(a)||a<0||a>=i?(n?.({errMsg:`${e}:fail invalid index ${t}`}),r?.(),!1):!0}_replaceTabBarItemIcons(e,t){let n=e.querySelector(`.dimina-tabbar-text`);e.querySelectorAll(`.dimina-tabbar-icon-default, .dimina-tabbar-icon-selected`).forEach(e=>e.remove());let r=this._resolveTabBarIcon(t.iconPath);r&&e.insertBefore(this._createTabBarIcon(r,`dimina-tabbar-icon-default`),n);let i=this._resolveTabBarIcon(t.selectedIconPath);i&&e.insertBefore(this._createTabBarIcon(i,`dimina-tabbar-icon-selected`),n)}setTabBarStyle(e={}){let{color:t,selectedColor:n,backgroundColor:r,borderStyle:i,success:a,fail:o,complete:s}=e,c=this.createCallbackFunction(a),l=this.createCallbackFunction(o),u=this.createCallbackFunction(s);if(!this.tabBarConfig||!this.tabBarEl){l?.({errMsg:`setTabBarStyle:fail tabBar not configured`}),u?.();return}let d=i===`black`||i===`white`?i:null,f=t===void 0?null:this._sanitizeCssColor(t),p=n===void 0?null:this._sanitizeCssColor(n),m=r===void 0?null:this._sanitizeCssColor(r);f&&(this.tabBarConfig.color=f),p&&(this.tabBarConfig.selectedColor=p),m&&(this.tabBarConfig.backgroundColor=m),d&&(this.tabBarConfig.borderStyle=d);let h=this.tabBarEl.querySelector(`.dimina-tabbar`);h&&(m&&(h.style.backgroundColor=m),d&&(h.style.borderTopColor=this._getTabBarBorderColor(d))),this._updateTabBarSelection(this.currentTabPath),c?.({errMsg:`setTabBarStyle:ok`}),u?.()}setTabBarItem(e={}){let{index:t,text:n,iconPath:r,selectedIconPath:i}=e,{onSuccess:a,onFail:o,onComplete:s}=this._createApiCallbacks(e);if(!this._validateTabBarIndex(`setTabBarItem`,t,o,s))return;let c=Number(t),l=this.tabBarConfig.list[c],u={...l,text:n===void 0?l.text:n,iconPath:r===void 0?l.iconPath:r,selectedIconPath:i===void 0?l.selectedIconPath:i};this.tabBarConfig.list[c]=u;let d=this._getTabBarItemEl(c);if(d){let e=d.querySelector(`.dimina-tabbar-text`);e&&(e.textContent=u.text||``),(r!==void 0||i!==void 0)&&this._replaceTabBarItemIcons(d,u),this._updateTabBarSelection(this.currentTabPath)}a?.({errMsg:`setTabBarItem:ok`}),s?.()}showTabBar(e={}){let{onSuccess:t,onComplete:n}=this._createApiCallbacks(e);this.tabBarApiVisible=!0,this._setTabBarVisible(!0),t?.({errMsg:`showTabBar:ok`}),n?.()}hideTabBar(e={}){let{onSuccess:t,onComplete:n}=this._createApiCallbacks(e);this.tabBarApiVisible=!1,this._setTabBarVisible(!1),t?.({errMsg:`hideTabBar:ok`}),n?.()}setTabBarBadge(e={}){let{index:t,text:n=``}=e,{onSuccess:r,onFail:i,onComplete:a}=this._createApiCallbacks(e);if(!this._validateTabBarIndex(`setTabBarBadge`,t,i,a))return;let o=Number(t);this.tabBarBadges[o]=String(n),this.tabBarRedDots[o]=!1;let s=this._getTabBarItemEl(o),c=s?.querySelector(`.dimina-tabbar-badge`),l=s?.querySelector(`.dimina-tabbar-red-dot`);c&&(c.textContent=this.tabBarBadges[o],c.hidden=this.tabBarBadges[o].length===0),l&&(l.hidden=!0),r?.({errMsg:`setTabBarBadge:ok`}),a?.()}removeTabBarBadge(e={}){let{index:t}=e,{onSuccess:n,onFail:r,onComplete:i}=this._createApiCallbacks(e);if(!this._validateTabBarIndex(`removeTabBarBadge`,t,r,i))return;let a=Number(t);this.tabBarBadges[a]=``;let o=this._getTabBarItemEl(a)?.querySelector(`.dimina-tabbar-badge`);o&&(o.textContent=``,o.hidden=!0),n?.({errMsg:`removeTabBarBadge:ok`}),i?.()}showTabBarRedDot(e={}){let{index:t}=e,{onSuccess:n,onFail:r,onComplete:i}=this._createApiCallbacks(e);if(!this._validateTabBarIndex(`showTabBarRedDot`,t,r,i))return;let a=Number(t);this.tabBarRedDots[a]=!0,this.tabBarBadges[a]=``;let o=this._getTabBarItemEl(a),s=o?.querySelector(`.dimina-tabbar-badge`),c=o?.querySelector(`.dimina-tabbar-red-dot`);s&&(s.textContent=``,s.hidden=!0),c&&(c.hidden=!1),n?.({errMsg:`showTabBarRedDot:ok`}),i?.()}hideTabBarRedDot(e={}){let{index:t}=e,{onSuccess:n,onFail:r,onComplete:i}=this._createApiCallbacks(e);if(!this._validateTabBarIndex(`hideTabBarRedDot`,t,r,i))return;let a=Number(t);this.tabBarRedDots[a]=!1;let o=this._getTabBarItemEl(a)?.querySelector(`.dimina-tabbar-red-dot`);o&&(o.hidden=!0),n?.({errMsg:`hideTabBarRedDot:ok`}),i?.()}navigateToMiniProgram(e){let{appId:t,path:n}=e;Z.openApp({appId:t,path:n,scene:1037},this.parent)}bindMoreEvent(){let e=this.el.querySelector(`.dimina-mini-app-navigation__actions-variable`),t=this.el.querySelector(`.dimina-mini-app-menu__mask`),n=this.el.querySelector(`.dimina-mini-app-menu`),r=this.el.querySelector(`.dimina-mini-app-menu__footer-btn--cancel`);t.addEventListener(`transitionend`,()=>{t.classList.contains(`show`)||(t.style.display=`none`)}),e.onclick=()=>this.openMiniAppMenu(),t.onclick=()=>this.closeMiniAppMenu(),r.onclick=()=>this.closeMiniAppMenu(),n.onclick=e=>e.stopPropagation()}bindCloseEvent(){let e=this.el.querySelector(`.dimina-mini-app-navigation__actions-close`);e.onclick=()=>{this.closeMiniProgram()}}destroy(){this._destroyed=!0;for(let e of this._extSubscriptions.values())e?.();this._extSubscriptions.clear(),this._tabBarResizeObserver?.disconnect(),this._tabBarResizeObserver=null;for(let e of this._modalPendingTimers)clearTimeout(e);this._modalPendingTimers.clear();for(let e of this._modalStack)e.mask?.remove(),e.dialog?.remove();this._modalStack.length=0,this.hideToast({}),Z.popView(),this.jscore.destroy()}getNetworkType(e){let{success:t}=e;this.createCallbackFunction(t)?.({networkType:`wifi`})}request({url:e,data:t,header:n={},timeout:r=0,method:i=`GET`,dataType:a=`json`,responseType:o=`text`,success:s,fail:c,complete:l}){let u={method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({url:e,data:t,header:n,timeout:r,method:i,dataType:a,responseType:o})},d=this.createCallbackFunction(s),f=this.createCallbackFunction(c),p=this.createCallbackFunction(l);fetch(`http://localhost:7788/proxy`,u).then(e=>{if(!e.ok){let t=Error(e.statusText);throw t.code=e.status,t}let t={};switch(e.headers.forEach((e,n)=>{t[n]=e}),a){case`json`:return e.json().then(n=>({data:JSON.parse(n),header:t,statusCode:e.status}));case`arraybuffer`:return e.arrayBuffer().then(n=>({data:n,header:t,statusCode:e.status}));default:return e.text().then(n=>({data:n,header:t,statusCode:e.status}))}}).then(e=>{d?.(e)}).catch(e=>{f?.({errMsg:e.message,errno:e.code})}).finally(()=>{p?.()})}getSystemInfoAsync(e){let t=this.parent.parent.root.querySelector(`.iphone__status-bar`).getBoundingClientRect(),n=this.parent.el.querySelector(`.dimina-native-webview__root`).getBoundingClientRect(),{success:r,complete:i}=e,a=this.createCallbackFunction(r),o=this.createCallbackFunction(i);a?.({statusBarHeight:t.height,brand:`devtools`,mode:`default`,model:`web`,platform:`devtools`,system:`web`,deviceOrientation:`portrait`,SDKVersion:`3.0.0`,language:`zh_CN`,wifiEnabled:!0,safeArea:{width:n.width,height:n.height,top:n.top,bottom:n.bottom,left:n.left,right:n.right}}),o?.()}getMenuButtonBoundingClientRect(){let e=this.el.querySelector(`.dimina-mini-app-navigation__actions`).getBoundingClientRect(),t=(this.parent.parent.root.querySelector(`.iphone__status-bar`)?.getBoundingClientRect().height||20)+4,n=t+e.height;return{top:t,right:e.right,bottom:n,left:e.left,width:e.width,height:e.height,x:e.x,y:t}}getHostEnvSnapshot(){return{menuRect:this.getMenuButtonBoundingClientRect(),systemInfo:this.getSystemInfoSync()}}getSystemInfoSync(){let e=this.parent.parent.root.querySelector(`.iphone__status-bar`),t=this.parent.el.querySelector(`.dimina-native-webview__root`)?.getBoundingClientRect(),n=t?.width||this.el.clientWidth||375,r=t?.height||this.el.clientHeight||667,i=e?.getBoundingClientRect().height||20;return{brand:`devtools`,model:`web`,platform:`devtools`,system:`web`,SDKVersion:`3.0.0`,pixelRatio:globalThis.devicePixelRatio||1,screenWidth:n,screenHeight:r,windowWidth:n,windowHeight:r,statusBarHeight:i,safeArea:{left:0,right:n,top:i,bottom:r,width:n,height:Math.max(r-i,0)},enableDebug:!1,host:{appId:``},language:navigator.language||`zh_CN`,version:``,theme:globalThis.matchMedia?.(`(prefers-color-scheme: dark)`)?.matches?`dark`:`light`,fontSizeScaleFactor:1,fontSizeSetting:16}}showToast(e={}){let{title:t=``,duration:n=1500,icon:r=`success`,mask:i=!1,success:a,complete:o}=e;if(!t)return;this.hideToast({});let s=this.createCallbackFunction(a),c=this.createCallbackFunction(o),l=null;i&&(l=document.createElement(`div`),l.className=`dimina-toast-mask`,this.el.appendChild(l));let u=document.createElement(`div`);u.className=`dimina-toast dimina-toast--${r}`,r===`none`&&u.classList.add(`dimina-toast--text-only`);let d=document.createElement(`p`);d.textContent=String(t),u.appendChild(d),this.el.appendChild(u),this.toastInfo.dom=u,this.toastInfo.maskEl=l,this.toastInfo.timer=setTimeout(()=>{u.remove(),l?.remove(),this.toastInfo.dom===u&&(this.toastInfo.dom=null,this.toastInfo.maskEl=null,this.toastInfo.timer=null)},n),s?.(),c?.()}hideToast(e={}){let{success:t,complete:n}=e,r=this.createCallbackFunction(t),i=this.createCallbackFunction(n);this.toastInfo.dom&&(this.toastInfo.dom.remove(),this.toastInfo.dom=null),this.toastInfo.maskEl&&(this.toastInfo.maskEl.remove(),this.toastInfo.maskEl=null),this.toastInfo.timer&&(clearTimeout(this.toastInfo.timer),this.toastInfo.timer=null),r?.(),i?.()}showLoading(e={}){this.showToast({...e,icon:`loading`})}hideLoading(e={}){this.hideToast(e)}showModal(e){if(this._destroyed)return;let t=this._mountModal(e||{});this._modalStack.push(t),this._updateModalView(),t.mask.classList.add(`show`);let n=setTimeout(()=>{this._modalPendingTimers.delete(n),!this._destroyed&&this._modalStack.includes(t)&&t.dialog.classList.add(`show`)},100);this._modalPendingTimers.add(n)}_updateModalView(){let e=this._modalStack.length-1;for(let t=0;t<this._modalStack.length;t++){let n=this._modalStack[t];t===e?(n.mask.classList.remove(`dimina-modal--occluded`),n.dialog.classList.remove(`dimina-modal--occluded`)):(n.mask.classList.add(`dimina-modal--occluded`),n.dialog.classList.add(`dimina-modal--occluded`))}}_mountModal(e){let{title:t=``,content:n=``,showCancel:r=!0,cancelText:i=`取消`,cancelColor:a=`#000`,confirmText:o=`确定`,confirmColor:s=`#576b95`,success:c,complete:l}=e,u=this.createCallbackFunction(c),d=this.createCallbackFunction(l),f=document.createElement(`div`);f.className=`dimina-dialog-mask`;let p=document.createElement(`div`);p.className=`dimina-dialog`;let m=this._modalStack.length;if(f.style.zIndex=String(1100+m*20),p.style.zIndex=String(1110+m*20),t){let e=document.createElement(`h2`);e.className=`dimina-dialog__title`,e.textContent=String(t),p.appendChild(e)}if(n){let e=document.createElement(`p`);e.className=`dimina-dialog__content`,e.textContent=String(n),p.appendChild(e)}let h=document.createElement(`div`);h.className=`dimina-dialog__buttons`;let g=!1,_={mask:f,dialog:p,close:null},v=e=>{if(g)return;g=!0;let t=this._modalStack.indexOf(_);t>=0&&this._modalStack.splice(t,1),this._modalStack.length===0?(f.classList.remove(`show`),p.classList.remove(`show`),setTimeout(()=>{f.remove(),p.remove()},200)):(f.remove(),p.remove()),this._updateModalView(),u?.(e),d?.()};if(_.close=v,r){let e=document.createElement(`button`);e.type=`button`,e.className=`dimina-dialog__button`,e.style.color=a,e.textContent=String(i),e.addEventListener(`click`,()=>{v({cancel:!0,confirm:!1,errMsg:`showModal:ok`})}),h.appendChild(e)}let y=document.createElement(`button`);return y.type=`button`,y.className=`dimina-dialog__button`,y.style.color=s,y.textContent=String(o),y.addEventListener(`click`,()=>{v({cancel:!1,confirm:!0,errMsg:`showModal:ok`})}),h.appendChild(y),p.appendChild(h),this.el.appendChild(f),this.el.appendChild(p),_}showActionSheet(e){let{itemList:t=[],itemColor:n=`#000`,success:r,fail:i,complete:a}=e||{};if(!Array.isArray(t)||t.length===0){i&&this.createCallbackFunction(i)({errMsg:`showActionSheet:fail`}),a&&this.createCallbackFunction(a)();return}let o=document.createElement(`div`);o.className=`dimina-action-sheet-mask`;let s=document.createElement(`div`);s.className=`dimina-action-sheet`;let c=()=>{o.remove(),s.remove()};t.forEach((e,t)=>{let i=document.createElement(`div`);i.className=`dimina-action-sheet-item`,i.style.color=n,i.textContent=e,i.onclick=()=>{c(),r&&this.createCallbackFunction(r)({tapIndex:t}),a&&this.createCallbackFunction(a)()},s.appendChild(i)});let l=document.createElement(`div`);l.className=`dimina-action-sheet-cancel`,l.textContent=`取消`,l.onclick=()=>{c(),i&&this.createCallbackFunction(i)({errMsg:`showActionSheet:fail cancel`}),a&&this.createCallbackFunction(a)()},s.appendChild(l),o.onclick=c,this.el.appendChild(o),this.el.appendChild(s),requestAnimationFrame(()=>requestAnimationFrame(()=>{s.classList.add(`show`),o.classList.add(`show`)}))}setNavigationBarTitle(e){let{title:t,success:n,fail:r,complete:i}=e,a=this.createCallbackFunction(n),o=this.createCallbackFunction(r),s=this.createCallbackFunction(i);try{let e=this.bridgeList[this.bridgeList.length-1].webview.el.querySelector(`.dimina-native-webview__navigation-title`);e?(e.textContent=t||``,a?.({errMsg:`setNavigationBarTitle:ok`})):o?.({errMsg:`setNavigationBarTitle:fail Navigation title element not found`})}catch(e){o?.({errMsg:`setNavigationBarTitle:fail ${e.message}`})}finally{s?.()}}setNavigationBarColor(e){let{frontColor:t,backgroundColor:n,success:r,fail:i,complete:a}=e,o=this.createCallbackFunction(r),s=this.createCallbackFunction(i),c=this.createCallbackFunction(a);try{let e=this.bridgeList[this.bridgeList.length-1].webview.el.querySelector(`.dimina-native-webview__navigation`);e?(t&&(e.querySelector(`.dimina-native-webview__navigation-title`).style.color=t),n&&(e.style.backgroundColor=n),o?.({errMsg:`setNavigationBarColor:ok`})):s?.({errMsg:`setNavigationBarColor:fail Navigation element not found`})}catch(e){s?.({errMsg:`setNavigationBarColor:fail ${e.message}`})}finally{c?.()}}pageScrollTo(e){let{scrollTop:t,duration:n=300,success:r,fail:i,complete:a}=e,o=this.createCallbackFunction(r),s=this.createCallbackFunction(i),c=this.createCallbackFunction(a);try{let e=this.bridgeList[this.bridgeList.length-1].webview.iframe.contentWindow.document.documentElement;e?(e.scrollTo({top:t,behavior:n>0?`smooth`:`auto`}),setTimeout(()=>{o?.({errMsg:`pageScrollTo:ok`}),c?.()},n)):(s?.({errMsg:`pageScrollTo:fail Webview root element not found`}),c?.())}catch(e){s?.({errMsg:`pageScrollTo:fail ${e.message}`}),c?.()}}setClipboardData(e){let{data:t,success:n,fail:r,complete:i}=e,a=this.createCallbackFunction(n),o=this.createCallbackFunction(r),s=this.createCallbackFunction(i);try{navigator.clipboard.writeText(t).then(()=>{a?.({errMsg:`setClipboardData:ok`}),s?.()}).catch(e=>{o?.({errMsg:`setClipboardData:fail ${e.message}`}),s?.()})}catch(e){o?.({errMsg:`setClipboardData:fail ${e.message}`}),s?.()}}getClipboardData(e){let{success:t,fail:n,complete:r}=e,i=this.createCallbackFunction(t),a=this.createCallbackFunction(n),o=this.createCallbackFunction(r);try{navigator.clipboard.readText().then(e=>{i?.({data:e,errMsg:`getClipboardData:ok`}),o?.()}).catch(e=>{a?.({errMsg:`getClipboardData:fail ${e.message}`}),o?.()})}catch(e){a?.({errMsg:`getClipboardData:fail ${e.message}`}),o?.()}}setStorage(e){let{key:t,data:n,success:r,fail:i,complete:a}=e,o=this.createCallbackFunction(r),s=this.createCallbackFunction(i),c=this.createCallbackFunction(a);try{let e=`${this.appId}_${t}`,r=typeof n==`object`?JSON.stringify(n):String(n);localStorage.setItem(e,r),o?.({errMsg:`setStorage:ok`})}catch(e){s?.({errMsg:`setStorage:fail ${e.message}`})}finally{c?.()}}getStorage(e){let{key:t,success:n,fail:r,complete:i}=e,a=this.createCallbackFunction(n),o=this.createCallbackFunction(r),s=this.createCallbackFunction(i);try{let e=`${this.appId}_${t}`,n=localStorage.getItem(e);if(n!==null){let e=n;try{e=JSON.parse(n)}catch{}a?.({data:e,errMsg:`getStorage:ok`})}else o?.({errMsg:`getStorage:fail data not found`})}catch(e){o?.({errMsg:`getStorage:fail ${e.message}`})}finally{s?.()}}removeStorage(e){let{key:t,success:n,fail:r,complete:i}=e,a=this.createCallbackFunction(n),o=this.createCallbackFunction(r),s=this.createCallbackFunction(i);try{let e=`${this.appId}_${t}`;localStorage.getItem(e)===null||localStorage.removeItem(e),a?.({errMsg:`removeStorage:ok`})}catch(e){o?.({errMsg:`removeStorage:fail ${e.message}`})}finally{s?.()}}clearStorage(e){let{success:t,fail:n,complete:r}=e||{},i=this.createCallbackFunction(t),a=this.createCallbackFunction(n),o=this.createCallbackFunction(r);try{let e=`${this.appId}_`,t=[];for(let n=0;n<localStorage.length;n++){let r=localStorage.key(n);r.startsWith(e)&&t.push(r)}t.forEach(e=>localStorage.removeItem(e)),i?.({errMsg:`clearStorage:ok`})}catch(e){a?.({errMsg:`clearStorage:fail ${e.message}`})}finally{o?.()}}getStorageInfo(e){let{success:t,fail:n,complete:r}=e||{},i=this.createCallbackFunction(t),a=this.createCallbackFunction(n),o=this.createCallbackFunction(r);try{let e=[],t=0,n=`${this.appId}_`;for(let r=0;r<localStorage.length;r++){let i=localStorage.key(r);if(i.startsWith(n)){let r=i.substring(n.length);e.push(r);let a=localStorage.getItem(i);t+=a?a.length*2:0}}i?.({keys:e,currentSize:t,limitSize:10485760,errMsg:`getStorageInfo:ok`})}catch(e){a?.({errMsg:`getStorageInfo:fail ${e.message}`})}finally{o?.()}}_parseExtEventKey(e){let t=Z.getExtModules();for(let n of Object.keys(t)){let t=`${n}_`;if(e.startsWith(t))return{module:n,event:e.slice(t.length)}}return{module:null,event:null}}_handleExtCall(e,t={}){t.module===void 0?t.success?this._extOnBridgeCall(e,t):this._extOffBridgeCall(e):this._extBridgeCall(e,t)}_extBridgeCall(e,t){let{module:n,data:r={},success:i,fail:a,complete:o}=t,s=this.createCallbackFunction(i),c=this.createCallbackFunction(a),l=this.createCallbackFunction(o),u=Z.getExtModule(n);if(!u){let e=`extBridge:fail module "${n}" not registered`;console.error(`[container] ${e}`),c?.({errMsg:e}),l?.();return}try{u({event:e,data:r,success:e=>{s?.(e),l?.()},fail:e=>{c?.(e),l?.()}})}catch(e){c?.({errMsg:`extBridge:fail ${e.message}`}),l?.()}}_extOnBridgeCall(e,t){let{success:n}=t,r=this.createCallbackFunction(n),{module:i,event:a}=this._parseExtEventKey(e);if(!i){console.error(`[container] extOnBridge:fail no registered module matched for key "${e}"`);return}let o=Z.getExtModule(i);this._extSubscriptions.get(e)?.();try{let t=o({event:a,data:{isSustain:!0},success:e=>r?.(e),fail:t=>console.error(`[container] extOnBridge error (${e}):`,t)});this._extSubscriptions.set(e,t??null)}catch(e){console.error(`[container] extOnBridge:fail ${e.message}`)}}_extOffBridgeCall(e){let t=this._extSubscriptions.get(e);t&&(t(),this._extSubscriptions.delete(e))}};function W(e){let t=new Map;return function(...n){let r=n.length===1?n[0]:JSON.stringify(n);if(t.has(r))return t.get(r);let i=e.apply(this,n);return t.set(r,i),i}}var G=W(async()=>{let e=await fetch(`/appList.json`).then(e=>e.json());return e.forEach(e=>{let t=JSON.stringify(e),n=sessionStorage.getItem(t);if(n)e.logo=n;else{let n=X(e);sessionStorage.setItem(t,n),e.logo=n}}),e});async function K(e){let t=await G();for(let n of t)if(n.appId===e)return n}function q(e){if(!e||e.length===0)return`#2196F3`;let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;let n=J(Math.abs(t%360),.7+Math.abs(t%3e3)/1e4,.8+Math.abs(t%2e3)/1e4);return Y(n[0],n[1],n[2])}function J(e,t,n){let r,i,a,o=Math.floor(e/60),s=e/60-o,c=n*(1-t),l=n*(1-s*t),u=n*(1-(1-s)*t);switch(o%6){case 0:r=n,i=u,a=c;break;case 1:r=l,i=n,a=c;break;case 2:r=c,i=n,a=u;break;case 3:r=c,i=l,a=n;break;case 4:r=u,i=c,a=n;break;case 5:r=n,i=c,a=l;break}return[Math.round(r*255),Math.round(i*255),Math.round(a*255)]}function Y(e,t,n){return`#${((1<<24)+(e<<16)+(t<<8)+n).toString(16).slice(1)}`}function X(e){let t=[60,60],n=window.devicePixelRatio||1,r=document.createElement(`canvas`);r.style.width=t[0]+`px`,r.style.height=t[1]+`px`,r.width=t[0]*n,r.height=t[1]*n;let i=r.getContext(`2d`);i.scale(n,n),i.imageSmoothingEnabled=!0,i.imageSmoothingQuality=`high`,i.textRenderingOptimization=`optimizeQuality`,i.fillStyle=q(e.name),i.fillRect(0,0,t[0],t[1]),i.fillStyle=`rgb(255,255,255)`,i.font=`${t[0]*.6}px Arial`;let a=e.name.charAt(0),o=i.measureText(a),s=t[0]/2,c=t[1]/2+(o.actualBoundingBoxAscent-o.actualBoundingBoxDescent)/2;return i.textAlign=`center`,i.fillText(a,s,c),r.toDataURL(`image/png`,1)}var Z=class{static appStack=[];static _extModules={};static registerExtModule(e,t){this._extModules[e]=t}static getExtModule(e){return this._extModules[e]}static getExtModules(){return this._extModules}static async openApp(e,t){let{appId:n,path:r,scene:i,destroy:a,restoreStack:o}=e,{pagePath:s,query:c}=M(r),{name:l,logo:u}=await K(n);if(a)for(let e of this.appStack)e.appId!==n&&(e.bridgeList.pop()?.destroy(),t.destroyRootView(e));let d=this.getAppById(n);if(d)t.presentView(d,!0);else{let e=new U({appId:n,scene:i,name:l,logo:u,pagePath:s,query:c,restoreStack:o});this.appStack.push(e),t.presentView(e,!1)}}static getAppById(e){for(let t of this.appStack)if(t.appId===e)return t;return null}static popView(){this.appStack.pop()}static closeApp(e){e.parent.dismissView({destroy:!1})}},Q=()=>new Promise(e=>requestAnimationFrame(()=>requestAnimationFrame(e))),$=(e,t,n=560)=>new Promise(r=>{let i=setTimeout(r,n),a=n=>{(!t||n.propertyName===t)&&(clearTimeout(i),e.removeEventListener(`transitionend`,a),r())};e.addEventListener(`transitionend`,a)}),ne=class{constructor(){this.el=null,this.window=null,this.root=null,this.views=[],this.rootView=null,this.parent=null,this.done=!0,this.isSleeping=!1,this._queue=Promise.resolve(),this.init()}_enqueue(e){return this._queue=this._queue.then(()=>e()),this._queue}init(){this.el=document.createElement(`div`),this.el.classList.add(`dimina-application`),this.window=document.createElement(`div`),this.window.classList.add(`dimina-native-window`),this.el.appendChild(this.window)}initRootView(e){this.rootView=e,e.parent=this,e.el.classList.add(`dimina-native-view--instage`),e.el.style.zIndex=1,this.root=e,this.window.appendChild(e.el),e.viewDidLoad()}async pushView(e){if(!this.done)return;this.done=!1;let t=this.views[this.views.length-1];e.parent=this,this.views.push(e),e.el.style.zIndex=this.views.length,e.el.classList.add(`dimina-native-view--before-enter`),this.window.appendChild(e.el),e?.viewDidLoad(),await Q(),t.el.classList.remove(`dimina-native-view--instage`),t.el.classList.add(`dimina-native-view--slide-out`),t.el.classList.add(`dimina-native-view--linear-anima`),e.el.classList.add(`dimina-native-view--enter-anima`),e.el.classList.add(`dimina-native-view--instage`),await $(e.el,`transform`),t.el.classList.remove(`dimina-native-view--linear-anima`),e.el.classList.remove(`dimina-native-view--before-enter`),e.el.classList.remove(`dimina-native-view--enter-anima`),e.el.classList.remove(`dimina-native-view--instage`),this.done=!0}async popView(){if(this.views.length<2||!this.done)return;this.done=!1;let e=this.views[this.views.length-2],t=this.views[this.views.length-1];e.el.classList.remove(`dimina-native-view--slide-out`),e.el.classList.add(`dimina-native-view--instage`),e.el.classList.add(`dimina-native-view--enter-anima`),t.el.classList.remove(`dimina-native-view--instage`),t.el.classList.add(`dimina-native-view--before-enter`),t.el.classList.add(`dimina-native-view--enter-anima`),await $(t.el,`transform`),this.views.pop(),this.window.removeChild(t.el),e.el.classList.remove(`dimina-native-view--enter-anima`),this.done=!0}presentView(e,t){return this._enqueue(()=>this._presentView(e,t))}async _presentView(e,t){if(!this.done)return;this.done=!1;let n=this.views[this.views.length-1];e.parent=this,e.el.style.zIndex=this.views.length+1,e.el.classList.add(`dimina-native-view--before-present`),e.el.classList.add(`dimina-native-view--enter-anima`),n?.el.classList.add(`dimina-native-view--before-presenting`),n?.el.classList.remove(`dimina-native-view--instage`),n?.el.classList.add(`dimina-native-view--enter-anima`),n?.onPresentOut(),e.onPresentIn(),!t&&this.el.appendChild(e.el),this.views.push(e),!t&&e.viewDidLoad&&e.viewDidLoad(),t&&e.restoreColorStyle(),await Q(),n?.el.classList.add(`dimina-native-view--presenting`),e.el.classList.add(`dimina-native-view--instage`),await $(e.el,`transform`),e.el.classList.remove(`dimina-native-view--before-present`),e.el.classList.remove(`dimina-native-view--enter-anima`),n?.el.classList.remove(`dimina-native-view--enter-anima`),n?.el.classList.remove(`dimina-native-view--before-presenting`),this.done=!0}dismissView(e={}){return this._enqueue(()=>this._dismissView(e))}async _dismissView(e={}){if(!this.done)return;this.done=!1;let t=this.views[this.views.length-2],n=this.views[this.views.length-1],{destroy:r=!0}=e;n.el.classList.add(`dimina-native-view--enter-anima`),t?.el.classList.add(`dimina-native-view--enter-anima`),t?.el.classList.add(`dimina-native-view--before-presenting`),await Q(),n.el.classList.add(`dimina-native-view--before-present`),n.el.classList.remove(`dimina-native-view--instage`),t?.el.classList.remove(`dimina-native-view--presenting`),t?.onPresentIn(),n?.onPresentOut(),await $(n.el,`transform`),r&&(n.destroy(),this.el.removeChild(n.el)),this.views.pop(),t?.el.classList.remove(`dimina-native-view--enter-anima`),t?.el.classList.remove(`dimina-native-view--before-presenting`),this.done=!0}async destroyRootView(e){e.destroy(),this.el.removeChild(e.el)}getActiveView(){return this.views[this.views.length-1]||this.rootView}sleepActiveView(){this.isSleeping||(this.isSleeping=!0,this.getActiveView()?.onPresentOut?.())}wakeActiveView(){if(!this.isSleeping)return;this.isSleeping=!1;let e=this.getActiveView();e?.restoreColorStyle?.(),e?.onPresentIn?.()}updateStatusBarColor(e){this.parent?.updateDeviceBarColor(e)}},re=`<div class="dimina-app__page-view dimina-app__mini">
71
+ `).join(``),i.querySelectorAll(`[data-quick-index]`).forEach((e,t)=>{e.onclick=()=>u[t].handler()})}openMiniAppMenu(){let e=this.el.querySelector(`.dimina-mini-app-menu__mask`),t=this.el.querySelector(`.dimina-mini-app-menu`);this.renderMiniAppMenu(),e.style.display=`block`,requestAnimationFrame(()=>{e.classList.add(`show`),t.classList.add(`show`)})}closeMiniAppMenu(){let e=this.el.querySelector(`.dimina-mini-app-menu__mask`),t=this.el.querySelector(`.dimina-mini-app-menu`);e.classList.remove(`show`),t.classList.remove(`show`)}registerApi(e,t){this.apiRegistry[e]=t}invokeApi(e,t){let n=this.apiRegistry[e];n?n.call(this,t):typeof this[e]==`function`?this[e](t):this._handleExtCall(e,t)}viewDidLoad(){this.initPageFrame(),this.webviewsContainer=this.el.querySelector(`.dimina-mini-app__webviews`),this.showLaunchScreen(),this.bindMoreEvent(),this.bindCloseEvent(),this.initApp()}async initApp(){await this.jscore.init();let e=`main`,t=`${this.appInfo.appId}/${e}/app-config.json`,[n]=await Promise.all([N(`/${t}`),A(560)]);if(!n)return;this.appConfig=JSON.parse(n),this._initTabBar();let r=this.appInfo.pagePath||this.appConfig.app.entryPagePath,i=this.appConfig.modules[r],a=P(this.appConfig.app,i);this.updateTargetPageColorStyle(a);let o=await this.createBridge({pagePath:r,query:this.appInfo.query,scene:this.appInfo.scene,jscore:this.jscore,isRoot:!0,root:e,appId:this.appInfo.appId,pages:this.appConfig.app.pages,configInfo:a});if(this.bridgeList.push(o),this._isTabBarPage(r)){let e=this._normalizePagePath(r);this.tabBarBridges.set(e,o),this.currentTabPath=e,this._setTabBarVisible(!0),this._updateTabBarSelection(e)}o.start(),this.appInfo.restoreStack&&this.appInfo.restoreStack.length>1&&await this.restorePageStack(this.appInfo.restoreStack.slice(1)),this._syncHash(),this.hideLaunchScreen()}async restorePageStack(e){for(let t=0;t<e.length;t++){let{pagePath:n,query:r}=e[t],i=t===e.length-1,a=n.startsWith(`/`)?n.slice(1):n,o=this.appConfig.modules[a],s=P(this.appConfig.app,o),c=await this.createBridge({pagePath:a,query:r,scene:this.appInfo.scene,jscore:this.jscore,isRoot:!1,root:o?.root||`main`,appId:this.appInfo.appId,pages:this.appConfig.app.pages,configInfo:s}),l=this.bridgeList[this.bridgeList.length-1];l.webview.el.classList.remove(`dimina-native-view--instage`),l.webview.el.classList.add(`dimina-native-view--slide-out`),this.bridgeList.push(c),c.webview.el.style.zIndex=this.bridgeList.length+1,c.webview.el.classList.remove(`dimina-native-view--before-enter`),i||c.webview.el.classList.add(`dimina-native-view--slide-out`),c.start()}if(e.length>0){let e=this.bridgeList[this.bridgeList.length-1],t=this.appConfig.modules[e.opts.pagePath],n=P(this.appConfig.app,t);this.updateTargetPageColorStyle(n),this._isTabBarPage(e.opts.pagePath)||this._setTabBarVisible(!1)}}_syncHash(){let e=this.bridgeList.map(e=>({pagePath:e.opts.pagePath.startsWith(`/`)?e.opts.pagePath.slice(1):e.opts.pagePath,query:e.opts.query||{}}));B.syncStack(this.appId,e)}async createBridge(e){let{jscore:t,configInfo:n,isRoot:r,appId:i,pagePath:a,query:o,scene:s,pages:c,root:l}=e,u=new L({jscore:t,configInfo:n,isRoot:r,appId:i,pagePath:a,query:o,scene:s,pages:c,root:l});return u.parent=this,await u.init(),u}onPresentIn(){let e=this.bridgeList[this.bridgeList.length-1];e?.appShow(),e?.pageShow()}onPresentOut(){let e=this.bridgeList[this.bridgeList.length-1];e?.appHide(),e?.pageHide()}initPageFrame(){this.el.innerHTML=V}updateTargetPageColorStyle(e){let{navigationBarTextStyle:t}=e;this.updateActionColorStyle(t)}showLaunchScreen(){let e=this.el.querySelector(`.dimina-mini-app__launch-screen`),t=this.el.querySelector(`.dimina-mini-app__name`),n=this.el.querySelector(`.dimina-mini-app__logo-img-url`);this.updateActionColorStyle(`black`),t.innerHTML=this.appInfo.name,n.src=this.appInfo.logo,e.style.display=`block`}hideLaunchScreen(){let e=this.el.querySelector(`.dimina-mini-app__launch-screen`);e.style.display=`none`}updateActionColorStyle(e){this.color=e;let t=this.el.querySelector(`.dimina-mini-app-navigation__actions`);e===`white`?(t.classList.remove(`dimina-mini-app-navigation__actions--black`),t.classList.add(`dimina-mini-app-navigation__actions--white`)):e===`black`&&(t.classList.remove(`dimina-mini-app-navigation__actions--white`),t.classList.add(`dimina-mini-app-navigation__actions--black`)),this.parent.updateStatusBarColor(e)}restoreColorStyle(){this.updateActionColorStyle(this.color)}createCallbackFunction(e){if(e)return t=>{this.jscore.postMessage({type:`triggerCallback`,body:{id:e,args:t}})}}_createApiCallbacks({success:e,fail:t,complete:n}={}){return{onSuccess:this.createCallbackFunction(e),onFail:this.createCallbackFunction(t),onComplete:this.createCallbackFunction(n)}}async navigateTo(e){let{url:t,success:n,fail:r,complete:i}=e,{query:a,pagePath:o}=j(t),s=this.createCallbackFunction(n),c=this.createCallbackFunction(r),l=this.createCallbackFunction(i);if(this._isTabBarPage(o)){c?.({errMsg:`navigateTo:fail can not navigateTo a tabbar page`}),l?.();return}if(!this.webviewAnimaEnd)return;this.webviewAnimaEnd=!1;let u=this.appConfig.modules[o],d=P(this.appConfig.app,u);this.updateTargetPageColorStyle(d);let f=await this.createBridge({pagePath:o,query:a,scene:this.appInfo.scene,jscore:this.jscore,isRoot:!1,root:u?.root||`main`,appId:this.appInfo.appId,pages:this.appConfig.app.pages,configInfo:d}),p=this.bridgeList[this.bridgeList.length-1],m=p.webview;this.bridgeList.push(f),f.start(),this._syncHash(),m.el.classList.remove(`dimina-native-view--instage`),m.el.classList.add(`dimina-native-view--slide-out`),m.el.classList.add(`dimina-native-view--linear-anima`),p?.pageHide(),this._setTabBarVisible(!1),f.webview.el.style.zIndex=this.bridgeList.length+1,f.webview.el.classList.add(`dimina-native-view--enter-anima`),f.webview.el.classList.add(`dimina-native-view--instage`),await H(f.webview.el,`transform`),this.webviewAnimaEnd=!0,m.el.classList.remove(`dimina-native-view--linear-anima`),f.webview.el.classList.remove(`dimina-native-view--before-enter`),f.webview.el.classList.remove(`dimina-native-view--enter-anima`),f.webview.el.classList.remove(`dimina-native-view--instage`),s?.({errMsg:`navigateTo:ok`}),l?.()}reLaunch(e){if(!this.webviewAnimaEnd)return;this.webviewAnimaEnd=!1;let{url:t,success:n,fail:r,complete:i}=e,{query:a,pagePath:o}=j(t),s=this.createCallbackFunction(n),c=this.createCallbackFunction(r),l=this.createCallbackFunction(i);try{let e=this.appConfig.modules[o],t=P(this.appConfig.app,e);this.updateTargetPageColorStyle(t);let n=new Set([...this.bridgeList,...this.tabBarBridges.values()]);for(let e of n)e.destroy(),e.webview?.el?.remove();this.bridgeList.length=0,this.tabBarBridges.clear(),this.currentTabPath=null,this.webviewsContainer&&(this.webviewsContainer.innerHTML=``),this.createBridge({pagePath:o,query:a,scene:this.appInfo.scene,jscore:this.jscore,isRoot:!0,root:e?.root||`main`,appId:this.appInfo.appId,pages:this.appConfig.app.pages,configInfo:t}).then(e=>{if(this.bridgeList.push(e),this._isTabBarPage(o)){let t=this._normalizePagePath(o);this.tabBarBridges.set(t,e),this.currentTabPath=t,this._setTabBarVisible(!0),this._updateTabBarSelection(t)}else this._setTabBarVisible(!1);e.start(),this._syncHash(),e.webview.el.style.zIndex=1,this.webviewAnimaEnd=!0,s?.({errMsg:`reLaunch:ok`}),l?.()}).catch(e=>{c?.({errMsg:`reLaunch:fail ${e.message}`}),l?.(),this.webviewAnimaEnd=!0})}catch(e){c?.({errMsg:`reLaunch:fail ${e.message}`}),l?.(),this.webviewAnimaEnd=!0}}applyUpdate(){this.reLaunch({url:this.getEntryPagePath()})}redirectTo(e){let{url:t,success:n,fail:r,complete:i}=e,{query:a,pagePath:o}=j(t),s=this.createCallbackFunction(n),c=this.createCallbackFunction(r),l=this.createCallbackFunction(i);if(this._isTabBarPage(o)){c?.({errMsg:`redirectTo:fail can not redirectTo a tabbar page`}),l?.();return}if(!this.webviewAnimaEnd)return;this.webviewAnimaEnd=!1;let u=this.bridgeList[this.bridgeList.length-1],d=this._normalizePagePath(u.opts.pagePath),f=this.appConfig.modules[o],p=P(this.appConfig.app,f);this.updateTargetPageColorStyle(p),u.destroy(),u.opts={...u.opts,pagePath:o,query:a,configInfo:p},u.resetStatus(),u.start(),this._syncHash(),this.tabBarBridges.get(d)===u&&(this.tabBarBridges.delete(d),this.currentTabPath===d&&(this.currentTabPath=null)),this._setBridgeTabBarInset(u,!1),this._setTabBarVisible(!1),this.webviewAnimaEnd=!0,s?.({errMsg:`redirectTo:ok`}),l?.()}async navigateBack(){if(this.bridgeList.length<2||!this.webviewAnimaEnd)return;this.webviewAnimaEnd=!1;let e=this.bridgeList.pop(),t=this.bridgeList[this.bridgeList.length-1],n=this.appConfig.modules[t.opts.pagePath],r=P(this.appConfig.app,n);if(this.updateTargetPageColorStyle(r),e.webview.el.classList.add(`dimina-native-view--before-enter`),e.webview.el.classList.add(`dimina-native-view--enter-anima`),e?.destroy(),t.webview.el.classList.remove(`dimina-native-view--slide-out`),t.webview.el.classList.add(`dimina-native-view--instage`),t.webview.el.classList.add(`dimina-native-view--enter-anima`),t?.pageShow(),this._syncHash(),this._isTabBarPage(t.opts.pagePath)){let e=this._normalizePagePath(t.opts.pagePath);this.currentTabPath=e,this._setTabBarVisible(!0),this._updateTabBarSelection(e)}await H(t.webview.el,`transform`),this.webviewAnimaEnd=!0,t.webview.el.classList.remove(`dimina-native-view--enter-anima`),t.webview.el.classList.remove(`dimina-native-view--instage`),e.webview.el.parentNode.removeChild(e.webview.el)}async switchTab(e){let{url:t,success:n,fail:r,complete:i}=e,{query:a,pagePath:o}=j(t),s=this._normalizePagePath(o),c=this.createCallbackFunction(n),l=this.createCallbackFunction(r),u=this.createCallbackFunction(i);if(!this._isTabBarPage(s)){l?.({errMsg:`switchTab:fail not a tabBar page: ${s}`}),u?.();return}if(!this.webviewAnimaEnd){l?.({errMsg:`switchTab:fail busy`}),u?.();return}if(this.currentTabPath===s&&this.bridgeList.length===1){this._setTabBarVisible(!0),this._updateTabBarSelection(s),c?.({errMsg:`switchTab:ok`}),u?.();return}this.webviewAnimaEnd=!1;try{let e=this.currentTabPath,t=e?this.tabBarBridges.get(e):null,n=!!t&&this.bridgeList.length===1&&this.bridgeList[0]===t;for(;this.bridgeList.length>0;){let e=this.bridgeList[this.bridgeList.length-1];if(this._isTabBarPage(e.opts.pagePath))break;e.pageHide(),e.destroy(),e.webview?.el?.remove(),this.bridgeList.pop()}if(t&&t!==this.tabBarBridges.get(s)){n&&t.pageHide(),t.webview?.el&&(t.webview.el.style.display=`none`);let e=this.bridgeList.indexOf(t);e>=0&&this.bridgeList.splice(e,1)}let r=this.tabBarBridges.get(s),i=this.appConfig.modules[s],o=P(this.appConfig.app,i);this.updateTargetPageColorStyle(o),r||(r=await this.createBridge({pagePath:s,query:a,scene:this.appInfo.scene,jscore:this.jscore,isRoot:!0,root:i?.root||`main`,appId:this.appInfo.appId,pages:this.appConfig.app.pages,configInfo:o}),this.tabBarBridges.set(s,r),r.start());let l=r.webview.el;this._setBridgeTabBarInset(r,!0),l.classList.remove(`dimina-native-view--before-enter`,`dimina-native-view--slide-out`,`dimina-native-view--enter-anima`,`dimina-native-view--linear-anima`,`dimina-native-view--instage`),l.style.display=``,l.style.zIndex=1,this.bridgeList.includes(r)||this.bridgeList.push(r),this.currentTabPath=s,r.pageShow(),this._setTabBarVisible(!0),this._updateTabBarSelection(s),this._syncHash(),c?.({errMsg:`switchTab:ok`})}catch(e){l?.({errMsg:`switchTab:fail ${e.message}`})}finally{this.webviewAnimaEnd=!0,u?.()}}_initTabBar(){let e=this.appConfig?.app?.tabBar;!e||!Array.isArray(e.list)||e.list.length===0||(this.tabBarConfig=e,this.tabBarPaths=e.list.map(e=>this._normalizePagePath(e.pagePath)),this.tabBarBadges=e.list.map(()=>``),this.tabBarRedDots=e.list.map(()=>!1),this.tabBarApiVisible=!0,this._renderTabBar())}_renderTabBar(){if(this.tabBarEl=this.el.querySelector(`.dimina-mini-app__tabbar`),!this.tabBarEl)return;let{color:e,backgroundColor:t,borderStyle:n,list:r}=this.tabBarConfig,i=this._sanitizeCssColor(e)||`#999999`,a=this._sanitizeCssColor(t)||`#ffffff`;this.tabBarEl.textContent=``;let o=document.createElement(`div`);o.className=`dimina-tabbar`,o.style.backgroundColor=a,o.style.borderTopColor=this._getTabBarBorderColor(n),r.forEach((e,t)=>{let n=this._normalizePagePath(e.pagePath),r=document.createElement(`div`);r.className=`dimina-tabbar-item`,r.dataset.path=n,r.dataset.index=String(t);let a=this._resolveTabBarIcon(e.iconPath);a&&r.appendChild(this._createTabBarIcon(a,`dimina-tabbar-icon-default`));let s=this._resolveTabBarIcon(e.selectedIconPath);s&&r.appendChild(this._createTabBarIcon(s,`dimina-tabbar-icon-selected`));let c=document.createElement(`span`);c.className=`dimina-tabbar-text`,c.style.color=i,c.textContent=e.text||``,r.appendChild(c);let l=document.createElement(`span`);l.className=`dimina-tabbar-badge`,l.hidden=!0,r.appendChild(l);let u=document.createElement(`span`);u.className=`dimina-tabbar-red-dot`,u.hidden=!0,r.appendChild(u),o.appendChild(r)}),this.tabBarEl.appendChild(o),this.tabBarEl.addEventListener(`click`,e=>{let t=e.target.closest(`.dimina-tabbar-item`);if(!t)return;let n=t.dataset.path;n&&n!==this.currentTabPath&&this.switchTab({url:`/${n}`})}),typeof ResizeObserver<`u`&&(this._tabBarResizeObserver?.disconnect(),this._tabBarResizeObserver=new ResizeObserver(()=>this._syncTabBarHeightVar()),this._tabBarResizeObserver.observe(this.tabBarEl))}_createTabBarIcon(e,t){let n=document.createElement(`img`);return n.className=`dimina-tabbar-icon ${t}`,n.src=e,n.alt=``,n.addEventListener(`error`,()=>{n.style.display=`none`}),n}_sanitizeCssColor(e){if(!e||typeof e!=`string`)return``;let t=e.trim();return t.length===0||t.length>64?``:/[<>"';{}()\\]/.test(t)?/^(?:rgb|rgba|hsl|hsla)\(\s*[\d.,%\s/-]+\)$/i.test(t)?t:``:t}_getTabBarBorderColor(e){return e===`white`?`#ffffff`:`#e0e0e0`}_getTabBarHeight(){if(!this.tabBarEl)return this.tabBarHeight;let e=this.tabBarEl.getBoundingClientRect().height;if(!e&&this.tabBarEl.style.display===`none`){let t=this.tabBarEl.style.display,n=this.tabBarEl.style.visibility;this.tabBarEl.style.visibility=`hidden`,this.tabBarEl.style.display=`block`,e=this.tabBarEl.getBoundingClientRect().height,this.tabBarEl.style.display=t,this.tabBarEl.style.visibility=n}return e>0&&(this.tabBarHeight=e),this.tabBarHeight}_syncTabBarHeightVar(){let e=this._getTabBarHeight();this.el.style.setProperty(`--dimina-tabbar-height`,`${e}px`),this._syncTabBarBridgeInsets()}_setBridgeTabBarInset(e,t){let n=e?.webview?.el;if(n){if(!t){n.style.removeProperty(`bottom`);return}n.style.bottom=`${this._getTabBarHeight()}px`}}_syncTabBarBridgeInsets(){for(let e of this.tabBarBridges.values())this._setBridgeTabBarInset(e,!0)}_joinBaseUrl(...e){return`${`/`.endsWith(`/`)?`/`:`//`}${e.map(e=>String(e).trim().replace(/^\/+|\/+$/g,``)).filter(Boolean).join(`/`)}`}_resolveTabBarIcon(e){if(!e||typeof e!=`string`)return null;let t=e.trim();if(!t)return null;if(/^(?:data:|blob:|https?:|\/\/)/i.test(t))return t;let n=t.replace(/^\/+/,``).replace(/^\.\//,``),r=`${this.appId}/`;return n.startsWith(r)?this._joinBaseUrl(n):this._joinBaseUrl(this.appId,`main`,n)}_setTabBarVisible(e){if(!this.tabBarEl)return;let t=this.bridgeList[this.bridgeList.length-1],n=this._normalizePagePath(t?.opts?.pagePath),r=!!n&&n===this.currentTabPath&&this._isTabBarPage(n),i=e&&this.tabBarApiVisible&&r;this.tabBarEl.style.display=i?`block`:`none`,this._syncTabBarHeightVar()}_updateTabBarSelection(e){if(!this.tabBarEl||!this.tabBarConfig)return;let t=this.tabBarConfig.color||`#999999`,n=this.tabBarConfig.selectedColor||`#1890ff`;this.tabBarEl.querySelectorAll(`.dimina-tabbar-item`).forEach(r=>{let i=r.getAttribute(`data-path`)===e,a=r.querySelector(`.dimina-tabbar-text`),o=r.querySelector(`.dimina-tabbar-icon-default`),s=r.querySelector(`.dimina-tabbar-icon-selected`);a&&(a.style.color=i?n:t),o&&(o.style.display=i?`none`:`block`),s&&(s.style.display=i?`block`:`none`),r.classList.toggle(`dimina-tabbar-item--selected`,i)})}_getTabBarItemEl(e){return this.tabBarEl?.querySelector(`.dimina-tabbar-item[data-index="${e}"]`)||null}_validateTabBarIndex(e,t,n,r){let i=this.tabBarConfig?.list?.length||0;if(!i||!this.tabBarEl)return n?.({errMsg:`${e}:fail tabBar not configured`}),r?.(),!1;let a=Number(t);return t==null||!Number.isInteger(a)||a<0||a>=i?(n?.({errMsg:`${e}:fail invalid index ${t}`}),r?.(),!1):!0}_replaceTabBarItemIcons(e,t){let n=e.querySelector(`.dimina-tabbar-text`);e.querySelectorAll(`.dimina-tabbar-icon-default, .dimina-tabbar-icon-selected`).forEach(e=>e.remove());let r=this._resolveTabBarIcon(t.iconPath);r&&e.insertBefore(this._createTabBarIcon(r,`dimina-tabbar-icon-default`),n);let i=this._resolveTabBarIcon(t.selectedIconPath);i&&e.insertBefore(this._createTabBarIcon(i,`dimina-tabbar-icon-selected`),n)}setTabBarStyle(e={}){let{color:t,selectedColor:n,backgroundColor:r,borderStyle:i,success:a,fail:o,complete:s}=e,c=this.createCallbackFunction(a),l=this.createCallbackFunction(o),u=this.createCallbackFunction(s);if(!this.tabBarConfig||!this.tabBarEl){l?.({errMsg:`setTabBarStyle:fail tabBar not configured`}),u?.();return}let d=i===`black`||i===`white`?i:null,f=t===void 0?null:this._sanitizeCssColor(t),p=n===void 0?null:this._sanitizeCssColor(n),m=r===void 0?null:this._sanitizeCssColor(r);f&&(this.tabBarConfig.color=f),p&&(this.tabBarConfig.selectedColor=p),m&&(this.tabBarConfig.backgroundColor=m),d&&(this.tabBarConfig.borderStyle=d);let h=this.tabBarEl.querySelector(`.dimina-tabbar`);h&&(m&&(h.style.backgroundColor=m),d&&(h.style.borderTopColor=this._getTabBarBorderColor(d))),this._updateTabBarSelection(this.currentTabPath),c?.({errMsg:`setTabBarStyle:ok`}),u?.()}setTabBarItem(e={}){let{index:t,text:n,iconPath:r,selectedIconPath:i}=e,{onSuccess:a,onFail:o,onComplete:s}=this._createApiCallbacks(e);if(!this._validateTabBarIndex(`setTabBarItem`,t,o,s))return;let c=Number(t),l=this.tabBarConfig.list[c],u={...l,text:n===void 0?l.text:n,iconPath:r===void 0?l.iconPath:r,selectedIconPath:i===void 0?l.selectedIconPath:i};this.tabBarConfig.list[c]=u;let d=this._getTabBarItemEl(c);if(d){let e=d.querySelector(`.dimina-tabbar-text`);e&&(e.textContent=u.text||``),(r!==void 0||i!==void 0)&&this._replaceTabBarItemIcons(d,u),this._updateTabBarSelection(this.currentTabPath)}a?.({errMsg:`setTabBarItem:ok`}),s?.()}showTabBar(e={}){let{onSuccess:t,onComplete:n}=this._createApiCallbacks(e);this.tabBarApiVisible=!0,this._setTabBarVisible(!0),t?.({errMsg:`showTabBar:ok`}),n?.()}hideTabBar(e={}){let{onSuccess:t,onComplete:n}=this._createApiCallbacks(e);this.tabBarApiVisible=!1,this._setTabBarVisible(!1),t?.({errMsg:`hideTabBar:ok`}),n?.()}setTabBarBadge(e={}){let{index:t,text:n=``}=e,{onSuccess:r,onFail:i,onComplete:a}=this._createApiCallbacks(e);if(!this._validateTabBarIndex(`setTabBarBadge`,t,i,a))return;let o=Number(t);this.tabBarBadges[o]=String(n),this.tabBarRedDots[o]=!1;let s=this._getTabBarItemEl(o),c=s?.querySelector(`.dimina-tabbar-badge`),l=s?.querySelector(`.dimina-tabbar-red-dot`);c&&(c.textContent=this.tabBarBadges[o],c.hidden=this.tabBarBadges[o].length===0),l&&(l.hidden=!0),r?.({errMsg:`setTabBarBadge:ok`}),a?.()}removeTabBarBadge(e={}){let{index:t}=e,{onSuccess:n,onFail:r,onComplete:i}=this._createApiCallbacks(e);if(!this._validateTabBarIndex(`removeTabBarBadge`,t,r,i))return;let a=Number(t);this.tabBarBadges[a]=``;let o=this._getTabBarItemEl(a)?.querySelector(`.dimina-tabbar-badge`);o&&(o.textContent=``,o.hidden=!0),n?.({errMsg:`removeTabBarBadge:ok`}),i?.()}showTabBarRedDot(e={}){let{index:t}=e,{onSuccess:n,onFail:r,onComplete:i}=this._createApiCallbacks(e);if(!this._validateTabBarIndex(`showTabBarRedDot`,t,r,i))return;let a=Number(t);this.tabBarRedDots[a]=!0,this.tabBarBadges[a]=``;let o=this._getTabBarItemEl(a),s=o?.querySelector(`.dimina-tabbar-badge`),c=o?.querySelector(`.dimina-tabbar-red-dot`);s&&(s.textContent=``,s.hidden=!0),c&&(c.hidden=!1),n?.({errMsg:`showTabBarRedDot:ok`}),i?.()}hideTabBarRedDot(e={}){let{index:t}=e,{onSuccess:n,onFail:r,onComplete:i}=this._createApiCallbacks(e);if(!this._validateTabBarIndex(`hideTabBarRedDot`,t,r,i))return;let a=Number(t);this.tabBarRedDots[a]=!1;let o=this._getTabBarItemEl(a)?.querySelector(`.dimina-tabbar-red-dot`);o&&(o.hidden=!0),n?.({errMsg:`hideTabBarRedDot:ok`}),i?.()}navigateToMiniProgram(e){let{appId:t,path:n}=e;Z.openApp({appId:t,path:n,scene:1037},this.parent)}bindMoreEvent(){let e=this.el.querySelector(`.dimina-mini-app-navigation__actions-variable`),t=this.el.querySelector(`.dimina-mini-app-menu__mask`),n=this.el.querySelector(`.dimina-mini-app-menu`),r=this.el.querySelector(`.dimina-mini-app-menu__footer-btn--cancel`);t.addEventListener(`transitionend`,()=>{t.classList.contains(`show`)||(t.style.display=`none`)}),e.onclick=()=>this.openMiniAppMenu(),t.onclick=()=>this.closeMiniAppMenu(),r.onclick=()=>this.closeMiniAppMenu(),n.onclick=e=>e.stopPropagation()}bindCloseEvent(){let e=this.el.querySelector(`.dimina-mini-app-navigation__actions-close`);e.onclick=()=>{this.closeMiniProgram()}}destroy(){this._destroyed=!0;for(let e of this._extSubscriptions.values())e?.();this._extSubscriptions.clear(),this._tabBarResizeObserver?.disconnect(),this._tabBarResizeObserver=null;for(let e of this._modalPendingTimers)clearTimeout(e);this._modalPendingTimers.clear();for(let e of this._modalStack)e.mask?.remove(),e.dialog?.remove();this._modalStack.length=0,this.hideToast({}),Z.popView(),this.jscore.destroy()}getNetworkType(e){let{success:t}=e;this.createCallbackFunction(t)?.({networkType:`wifi`})}request({url:e,data:t,header:n={},timeout:r=0,method:i=`GET`,dataType:a=`json`,responseType:o=`text`,success:s,fail:c,complete:l}){let u={method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({url:e,data:t,header:n,timeout:r,method:i,dataType:a,responseType:o})},d=this.createCallbackFunction(s),f=this.createCallbackFunction(c),p=this.createCallbackFunction(l);fetch(`http://localhost:7788/proxy`,u).then(e=>{if(!e.ok){let t=Error(e.statusText);throw t.code=e.status,t}let t={};switch(e.headers.forEach((e,n)=>{t[n]=e}),a){case`json`:return e.json().then(n=>({data:JSON.parse(n),header:t,statusCode:e.status}));case`arraybuffer`:return e.arrayBuffer().then(n=>({data:n,header:t,statusCode:e.status}));default:return e.text().then(n=>({data:n,header:t,statusCode:e.status}))}}).then(e=>{d?.(e)}).catch(e=>{f?.({errMsg:e.message,errno:e.code})}).finally(()=>{p?.()})}getSystemInfoAsync(e){let t=this.parent.parent.root.querySelector(`.iphone__status-bar`).getBoundingClientRect(),n=this.parent.el.querySelector(`.dimina-native-webview__root`).getBoundingClientRect(),{success:r,complete:i}=e,a=this.createCallbackFunction(r),o=this.createCallbackFunction(i);a?.({statusBarHeight:t.height,brand:`devtools`,mode:`default`,model:`web`,platform:`devtools`,system:`web`,deviceOrientation:`portrait`,SDKVersion:`3.0.0`,language:`zh_CN`,wifiEnabled:!0,safeArea:{width:n.width,height:n.height,top:n.top,bottom:n.bottom,left:n.left,right:n.right}}),o?.()}getMenuButtonBoundingClientRect(){let e=this.el.querySelector(`.dimina-mini-app-navigation__actions`).getBoundingClientRect(),t=(this.parent.parent.root.querySelector(`.iphone__status-bar`)?.getBoundingClientRect().height||20)+4,n=t+e.height;return{top:t,right:e.right,bottom:n,left:e.left,width:e.width,height:e.height,x:e.x,y:t}}getHostEnvSnapshot(){return{menuRect:this.getMenuButtonBoundingClientRect(),systemInfo:this.getSystemInfoSync()}}getSystemInfoSync(){let e=this.parent.parent.root.querySelector(`.iphone__status-bar`),t=this.parent.el.querySelector(`.dimina-native-webview__root`)?.getBoundingClientRect(),n=t?.width||this.el.clientWidth||375,r=t?.height||this.el.clientHeight||667,i=e?.getBoundingClientRect().height||20;return{brand:`devtools`,model:`web`,platform:`devtools`,system:`web`,SDKVersion:`3.0.0`,pixelRatio:globalThis.devicePixelRatio||1,screenWidth:n,screenHeight:r,windowWidth:n,windowHeight:r,statusBarHeight:i,safeArea:{left:0,right:n,top:i,bottom:r,width:n,height:Math.max(r-i,0)},enableDebug:!1,host:{appId:``},language:navigator.language||`zh_CN`,version:``,theme:globalThis.matchMedia?.(`(prefers-color-scheme: dark)`)?.matches?`dark`:`light`,fontSizeScaleFactor:1,fontSizeSetting:16}}showToast(e={}){let{title:t=``,duration:n=1500,icon:r=`success`,mask:i=!1,success:a,complete:o}=e;if(!t)return;this.hideToast({});let s=this.createCallbackFunction(a),c=this.createCallbackFunction(o),l=null;i&&(l=document.createElement(`div`),l.className=`dimina-toast-mask`,this.el.appendChild(l));let u=document.createElement(`div`);u.className=`dimina-toast dimina-toast--${r}`,r===`none`&&u.classList.add(`dimina-toast--text-only`);let d=document.createElement(`p`);d.textContent=String(t),u.appendChild(d),this.el.appendChild(u),this.toastInfo.dom=u,this.toastInfo.maskEl=l,this.toastInfo.timer=setTimeout(()=>{u.remove(),l?.remove(),this.toastInfo.dom===u&&(this.toastInfo.dom=null,this.toastInfo.maskEl=null,this.toastInfo.timer=null)},n),s?.(),c?.()}hideToast(e={}){let{success:t,complete:n}=e,r=this.createCallbackFunction(t),i=this.createCallbackFunction(n);this.toastInfo.dom&&(this.toastInfo.dom.remove(),this.toastInfo.dom=null),this.toastInfo.maskEl&&(this.toastInfo.maskEl.remove(),this.toastInfo.maskEl=null),this.toastInfo.timer&&(clearTimeout(this.toastInfo.timer),this.toastInfo.timer=null),r?.(),i?.()}showLoading(e={}){this.showToast({...e,icon:`loading`})}hideLoading(e={}){this.hideToast(e)}showModal(e){if(this._destroyed)return;let t=this._mountModal(e||{});this._modalStack.push(t),this._updateModalView(),t.mask.classList.add(`show`);let n=setTimeout(()=>{this._modalPendingTimers.delete(n),!this._destroyed&&this._modalStack.includes(t)&&t.dialog.classList.add(`show`)},100);this._modalPendingTimers.add(n)}_updateModalView(){let e=this._modalStack.length-1;for(let t=0;t<this._modalStack.length;t++){let n=this._modalStack[t];t===e?(n.mask.classList.remove(`dimina-modal--occluded`),n.dialog.classList.remove(`dimina-modal--occluded`)):(n.mask.classList.add(`dimina-modal--occluded`),n.dialog.classList.add(`dimina-modal--occluded`))}}_mountModal(e){let{title:t=``,content:n=``,showCancel:r=!0,cancelText:i=`取消`,cancelColor:a=`#000`,confirmText:o=`确定`,confirmColor:s=`#576b95`,success:c,complete:l}=e,u=this.createCallbackFunction(c),d=this.createCallbackFunction(l),f=document.createElement(`div`);f.className=`dimina-dialog-mask`;let p=document.createElement(`div`);p.className=`dimina-dialog`;let m=this._modalStack.length;if(f.style.zIndex=String(1100+m*20),p.style.zIndex=String(1110+m*20),t){let e=document.createElement(`h2`);e.className=`dimina-dialog__title`,e.textContent=String(t),p.appendChild(e)}if(n){let e=document.createElement(`p`);e.className=`dimina-dialog__content`,e.textContent=String(n),p.appendChild(e)}let h=document.createElement(`div`);h.className=`dimina-dialog__buttons`;let g=!1,_={mask:f,dialog:p,close:null},v=e=>{if(g)return;g=!0;let t=this._modalStack.indexOf(_);t>=0&&this._modalStack.splice(t,1),this._modalStack.length===0?(f.classList.remove(`show`),p.classList.remove(`show`),setTimeout(()=>{f.remove(),p.remove()},200)):(f.remove(),p.remove()),this._updateModalView(),u?.(e),d?.()};if(_.close=v,r){let e=document.createElement(`button`);e.type=`button`,e.className=`dimina-dialog__button`,e.style.color=a,e.textContent=String(i),e.addEventListener(`click`,()=>{v({cancel:!0,confirm:!1,errMsg:`showModal:ok`})}),h.appendChild(e)}let y=document.createElement(`button`);return y.type=`button`,y.className=`dimina-dialog__button`,y.style.color=s,y.textContent=String(o),y.addEventListener(`click`,()=>{v({cancel:!1,confirm:!0,errMsg:`showModal:ok`})}),h.appendChild(y),p.appendChild(h),this.el.appendChild(f),this.el.appendChild(p),_}showActionSheet(e){let{itemList:t=[],itemColor:n=`#000`,success:r,fail:i,complete:a}=e||{};if(!Array.isArray(t)||t.length===0){i&&this.createCallbackFunction(i)({errMsg:`showActionSheet:fail`}),a&&this.createCallbackFunction(a)();return}let o=document.createElement(`div`);o.className=`dimina-action-sheet-mask`;let s=document.createElement(`div`);s.className=`dimina-action-sheet`;let c=()=>{o.remove(),s.remove()};t.forEach((e,t)=>{let i=document.createElement(`div`);i.className=`dimina-action-sheet-item`,i.style.color=n,i.textContent=e,i.onclick=()=>{c(),r&&this.createCallbackFunction(r)({tapIndex:t}),a&&this.createCallbackFunction(a)()},s.appendChild(i)});let l=document.createElement(`div`);l.className=`dimina-action-sheet-cancel`,l.textContent=`取消`,l.onclick=()=>{c(),i&&this.createCallbackFunction(i)({errMsg:`showActionSheet:fail cancel`}),a&&this.createCallbackFunction(a)()},s.appendChild(l),o.onclick=c,this.el.appendChild(o),this.el.appendChild(s),requestAnimationFrame(()=>requestAnimationFrame(()=>{s.classList.add(`show`),o.classList.add(`show`)}))}setNavigationBarTitle(e){let{title:t,success:n,fail:r,complete:i}=e,a=this.createCallbackFunction(n),o=this.createCallbackFunction(r),s=this.createCallbackFunction(i);try{let e=this.bridgeList[this.bridgeList.length-1].webview.el.querySelector(`.dimina-native-webview__navigation-title`);e?(e.textContent=t||``,a?.({errMsg:`setNavigationBarTitle:ok`})):o?.({errMsg:`setNavigationBarTitle:fail Navigation title element not found`})}catch(e){o?.({errMsg:`setNavigationBarTitle:fail ${e.message}`})}finally{s?.()}}setNavigationBarColor(e){let{frontColor:t,backgroundColor:n,success:r,fail:i,complete:a}=e,o=this.createCallbackFunction(r),s=this.createCallbackFunction(i),c=this.createCallbackFunction(a);try{let e=this.bridgeList[this.bridgeList.length-1].webview.el.querySelector(`.dimina-native-webview__navigation`);e?(t&&(e.querySelector(`.dimina-native-webview__navigation-title`).style.color=t),n&&(e.style.backgroundColor=n),o?.({errMsg:`setNavigationBarColor:ok`})):s?.({errMsg:`setNavigationBarColor:fail Navigation element not found`})}catch(e){s?.({errMsg:`setNavigationBarColor:fail ${e.message}`})}finally{c?.()}}pageScrollTo(e){let{scrollTop:t,duration:n=300,success:r,fail:i,complete:a}=e,o=this.createCallbackFunction(r),s=this.createCallbackFunction(i),c=this.createCallbackFunction(a);try{let e=this.bridgeList[this.bridgeList.length-1].webview.iframe.contentWindow.document.documentElement;e?(e.scrollTo({top:t,behavior:n>0?`smooth`:`auto`}),setTimeout(()=>{o?.({errMsg:`pageScrollTo:ok`}),c?.()},n)):(s?.({errMsg:`pageScrollTo:fail Webview root element not found`}),c?.())}catch(e){s?.({errMsg:`pageScrollTo:fail ${e.message}`}),c?.()}}setClipboardData(e){let{data:t,success:n,fail:r,complete:i}=e,a=this.createCallbackFunction(n),o=this.createCallbackFunction(r),s=this.createCallbackFunction(i);try{navigator.clipboard.writeText(t).then(()=>{a?.({errMsg:`setClipboardData:ok`}),s?.()}).catch(e=>{o?.({errMsg:`setClipboardData:fail ${e.message}`}),s?.()})}catch(e){o?.({errMsg:`setClipboardData:fail ${e.message}`}),s?.()}}getClipboardData(e){let{success:t,fail:n,complete:r}=e,i=this.createCallbackFunction(t),a=this.createCallbackFunction(n),o=this.createCallbackFunction(r);try{navigator.clipboard.readText().then(e=>{i?.({data:e,errMsg:`getClipboardData:ok`}),o?.()}).catch(e=>{a?.({errMsg:`getClipboardData:fail ${e.message}`}),o?.()})}catch(e){a?.({errMsg:`getClipboardData:fail ${e.message}`}),o?.()}}setStorage(e){let{key:t,data:n,success:r,fail:i,complete:a}=e,o=this.createCallbackFunction(r),s=this.createCallbackFunction(i),c=this.createCallbackFunction(a);try{let e=`${this.appId}_${t}`,r=typeof n==`object`?JSON.stringify(n):String(n);localStorage.setItem(e,r),o?.({errMsg:`setStorage:ok`})}catch(e){s?.({errMsg:`setStorage:fail ${e.message}`})}finally{c?.()}}getStorage(e){let{key:t,success:n,fail:r,complete:i}=e,a=this.createCallbackFunction(n),o=this.createCallbackFunction(r),s=this.createCallbackFunction(i);try{let e=`${this.appId}_${t}`,n=localStorage.getItem(e);if(n!==null){let e=n;try{e=JSON.parse(n)}catch{}a?.({data:e,errMsg:`getStorage:ok`})}else o?.({errMsg:`getStorage:fail data not found`})}catch(e){o?.({errMsg:`getStorage:fail ${e.message}`})}finally{s?.()}}removeStorage(e){let{key:t,success:n,fail:r,complete:i}=e,a=this.createCallbackFunction(n),o=this.createCallbackFunction(r),s=this.createCallbackFunction(i);try{let e=`${this.appId}_${t}`;localStorage.getItem(e)===null||localStorage.removeItem(e),a?.({errMsg:`removeStorage:ok`})}catch(e){o?.({errMsg:`removeStorage:fail ${e.message}`})}finally{s?.()}}clearStorage(e){let{success:t,fail:n,complete:r}=e||{},i=this.createCallbackFunction(t),a=this.createCallbackFunction(n),o=this.createCallbackFunction(r);try{let e=`${this.appId}_`,t=[];for(let n=0;n<localStorage.length;n++){let r=localStorage.key(n);r.startsWith(e)&&t.push(r)}t.forEach(e=>localStorage.removeItem(e)),i?.({errMsg:`clearStorage:ok`})}catch(e){a?.({errMsg:`clearStorage:fail ${e.message}`})}finally{o?.()}}getStorageInfo(e){let{success:t,fail:n,complete:r}=e||{},i=this.createCallbackFunction(t),a=this.createCallbackFunction(n),o=this.createCallbackFunction(r);try{let e=[],t=0,n=`${this.appId}_`;for(let r=0;r<localStorage.length;r++){let i=localStorage.key(r);if(i.startsWith(n)){let r=i.substring(n.length);e.push(r);let a=localStorage.getItem(i);t+=a?a.length*2:0}}i?.({keys:e,currentSize:t,limitSize:10485760,errMsg:`getStorageInfo:ok`})}catch(e){a?.({errMsg:`getStorageInfo:fail ${e.message}`})}finally{o?.()}}_parseExtEventKey(e){let t=Z.getExtModules();for(let n of Object.keys(t)){let t=`${n}_`;if(e.startsWith(t))return{module:n,event:e.slice(t.length)}}return{module:null,event:null}}_handleExtCall(e,t={}){t.module===void 0?t.success?this._extOnBridgeCall(e,t):this._extOffBridgeCall(e):this._extBridgeCall(e,t)}_extBridgeCall(e,t){let{module:n,data:r={},success:i,fail:a,complete:o}=t,s=this.createCallbackFunction(i),c=this.createCallbackFunction(a),l=this.createCallbackFunction(o),u=Z.getExtModule(n);if(!u){let e=`extBridge:fail module "${n}" not registered`;console.error(`[container] ${e}`),c?.({errMsg:e}),l?.();return}try{u({event:e,data:r,success:e=>{s?.(e),l?.()},fail:e=>{c?.(e),l?.()}})}catch(e){c?.({errMsg:`extBridge:fail ${e.message}`}),l?.()}}_extOnBridgeCall(e,t){let{success:n}=t,r=this.createCallbackFunction(n),{module:i,event:a}=this._parseExtEventKey(e);if(!i){console.error(`[container] extOnBridge:fail no registered module matched for key "${e}"`);return}let o=Z.getExtModule(i);this._extSubscriptions.get(e)?.();try{let t=o({event:a,data:{isSustain:!0},success:e=>r?.(e),fail:t=>console.error(`[container] extOnBridge error (${e}):`,t)});this._extSubscriptions.set(e,t??null)}catch(e){console.error(`[container] extOnBridge:fail ${e.message}`)}}_extOffBridgeCall(e){let t=this._extSubscriptions.get(e);t&&(t(),this._extSubscriptions.delete(e))}};function W(e){let t=new Map;return function(...n){let r=n.length===1?n[0]:JSON.stringify(n);if(t.has(r))return t.get(r);let i=e.apply(this,n);return t.set(r,i),i}}var G=W(async()=>{let e=await fetch(`/appList.json`).then(e=>e.json());return e.forEach(e=>{let t=JSON.stringify(e),n=sessionStorage.getItem(t);if(n)e.logo=n;else{let n=X(e);sessionStorage.setItem(t,n),e.logo=n}}),e});async function K(e){let t=await G();for(let n of t)if(n.appId===e)return n}function q(e){if(!e||e.length===0)return`#2196F3`;let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;let n=J(Math.abs(t%360),.7+Math.abs(t%3e3)/1e4,.8+Math.abs(t%2e3)/1e4);return Y(n[0],n[1],n[2])}function J(e,t,n){let r,i,a,o=Math.floor(e/60),s=e/60-o,c=n*(1-t),l=n*(1-s*t),u=n*(1-(1-s)*t);switch(o%6){case 0:r=n,i=u,a=c;break;case 1:r=l,i=n,a=c;break;case 2:r=c,i=n,a=u;break;case 3:r=c,i=l,a=n;break;case 4:r=u,i=c,a=n;break;case 5:r=n,i=c,a=l;break}return[Math.round(r*255),Math.round(i*255),Math.round(a*255)]}function Y(e,t,n){return`#${((1<<24)+(e<<16)+(t<<8)+n).toString(16).slice(1)}`}function X(e){let t=[60,60],n=window.devicePixelRatio||1,r=document.createElement(`canvas`);r.style.width=t[0]+`px`,r.style.height=t[1]+`px`,r.width=t[0]*n,r.height=t[1]*n;let i=r.getContext(`2d`);i.scale(n,n),i.imageSmoothingEnabled=!0,i.imageSmoothingQuality=`high`,i.textRenderingOptimization=`optimizeQuality`,i.fillStyle=q(e.name),i.fillRect(0,0,t[0],t[1]),i.fillStyle=`rgb(255,255,255)`,i.font=`${t[0]*.6}px Arial`;let a=e.name.charAt(0),o=i.measureText(a),s=t[0]/2,c=t[1]/2+(o.actualBoundingBoxAscent-o.actualBoundingBoxDescent)/2;return i.textAlign=`center`,i.fillText(a,s,c),r.toDataURL(`image/png`,1)}var Z=class{static appStack=[];static _extModules={};static registerExtModule(e,t){this._extModules[e]=t}static getExtModule(e){return this._extModules[e]}static getExtModules(){return this._extModules}static async openApp(e,t){let{appId:n,path:r,scene:i,destroy:a,restoreStack:o}=e,{pagePath:s,query:c}=j(r),{name:l,logo:u}=await K(n);if(a)for(let e of this.appStack)e.appId!==n&&(e.bridgeList.pop()?.destroy(),t.destroyRootView(e));let d=this.getAppById(n);if(d)t.presentView(d,!0);else{let e=new U({appId:n,scene:i,name:l,logo:u,pagePath:s,query:c,restoreStack:o});this.appStack.push(e),t.presentView(e,!1)}}static getAppById(e){for(let t of this.appStack)if(t.appId===e)return t;return null}static popView(){this.appStack.pop()}static closeApp(e){e.parent.dismissView({destroy:!1})}},Q=()=>new Promise(e=>requestAnimationFrame(()=>requestAnimationFrame(e))),$=(e,t,n=560)=>new Promise(r=>{let i=setTimeout(r,n),a=n=>{(!t||n.propertyName===t)&&(clearTimeout(i),e.removeEventListener(`transitionend`,a),r())};e.addEventListener(`transitionend`,a)}),te=class{constructor(){this.el=null,this.window=null,this.root=null,this.views=[],this.rootView=null,this.parent=null,this.done=!0,this.isSleeping=!1,this._queue=Promise.resolve(),this.init()}_enqueue(e){return this._queue=this._queue.then(()=>e()),this._queue}init(){this.el=document.createElement(`div`),this.el.classList.add(`dimina-application`),this.window=document.createElement(`div`),this.window.classList.add(`dimina-native-window`),this.el.appendChild(this.window)}initRootView(e){this.rootView=e,e.parent=this,e.el.classList.add(`dimina-native-view--instage`),e.el.style.zIndex=1,this.root=e,this.window.appendChild(e.el),e.viewDidLoad()}async pushView(e){if(!this.done)return;this.done=!1;let t=this.views[this.views.length-1];e.parent=this,this.views.push(e),e.el.style.zIndex=this.views.length,e.el.classList.add(`dimina-native-view--before-enter`),this.window.appendChild(e.el),e?.viewDidLoad(),await Q(),t.el.classList.remove(`dimina-native-view--instage`),t.el.classList.add(`dimina-native-view--slide-out`),t.el.classList.add(`dimina-native-view--linear-anima`),e.el.classList.add(`dimina-native-view--enter-anima`),e.el.classList.add(`dimina-native-view--instage`),await $(e.el,`transform`),t.el.classList.remove(`dimina-native-view--linear-anima`),e.el.classList.remove(`dimina-native-view--before-enter`),e.el.classList.remove(`dimina-native-view--enter-anima`),e.el.classList.remove(`dimina-native-view--instage`),this.done=!0}async popView(){if(this.views.length<2||!this.done)return;this.done=!1;let e=this.views[this.views.length-2],t=this.views[this.views.length-1];e.el.classList.remove(`dimina-native-view--slide-out`),e.el.classList.add(`dimina-native-view--instage`),e.el.classList.add(`dimina-native-view--enter-anima`),t.el.classList.remove(`dimina-native-view--instage`),t.el.classList.add(`dimina-native-view--before-enter`),t.el.classList.add(`dimina-native-view--enter-anima`),await $(t.el,`transform`),this.views.pop(),this.window.removeChild(t.el),e.el.classList.remove(`dimina-native-view--enter-anima`),this.done=!0}presentView(e,t){return this._enqueue(()=>this._presentView(e,t))}async _presentView(e,t){if(!this.done)return;this.done=!1;let n=this.views[this.views.length-1];e.parent=this,e.el.style.zIndex=this.views.length+1,e.el.classList.add(`dimina-native-view--before-present`),e.el.classList.add(`dimina-native-view--enter-anima`),n?.el.classList.add(`dimina-native-view--before-presenting`),n?.el.classList.remove(`dimina-native-view--instage`),n?.el.classList.add(`dimina-native-view--enter-anima`),n?.onPresentOut(),e.onPresentIn(),!t&&this.el.appendChild(e.el),this.views.push(e),!t&&e.viewDidLoad&&e.viewDidLoad(),t&&e.restoreColorStyle(),await Q(),n?.el.classList.add(`dimina-native-view--presenting`),e.el.classList.add(`dimina-native-view--instage`),await $(e.el,`transform`),e.el.classList.remove(`dimina-native-view--before-present`),e.el.classList.remove(`dimina-native-view--enter-anima`),n?.el.classList.remove(`dimina-native-view--enter-anima`),n?.el.classList.remove(`dimina-native-view--before-presenting`),this.done=!0}dismissView(e={}){return this._enqueue(()=>this._dismissView(e))}async _dismissView(e={}){if(!this.done)return;this.done=!1;let t=this.views[this.views.length-2],n=this.views[this.views.length-1],{destroy:r=!0}=e;n.el.classList.add(`dimina-native-view--enter-anima`),t?.el.classList.add(`dimina-native-view--enter-anima`),t?.el.classList.add(`dimina-native-view--before-presenting`),await Q(),n.el.classList.add(`dimina-native-view--before-present`),n.el.classList.remove(`dimina-native-view--instage`),t?.el.classList.remove(`dimina-native-view--presenting`),t?.onPresentIn(),n?.onPresentOut(),await $(n.el,`transform`),r&&(n.destroy(),this.el.removeChild(n.el)),this.views.pop(),t?.el.classList.remove(`dimina-native-view--enter-anima`),t?.el.classList.remove(`dimina-native-view--before-presenting`),this.done=!0}async destroyRootView(e){e.destroy(),this.el.removeChild(e.el)}getActiveView(){return this.views[this.views.length-1]||this.rootView}sleepActiveView(){this.isSleeping||(this.isSleeping=!0,this.getActiveView()?.onPresentOut?.())}wakeActiveView(){if(!this.isSleeping)return;this.isSleeping=!1;let e=this.getActiveView();e?.restoreColorStyle?.(),e?.onPresentIn?.()}updateStatusBarColor(e){this.parent?.updateDeviceBarColor(e)}},ne=`<div class="dimina-app__page-view dimina-app__mini">
72
72
  <div class="dimina-app-navigation">
73
73
  <div class="dimina-app-navigation__content">
74
74
  <div class="dimina-app-navigation__left-btn"></div>
@@ -89,7 +89,7 @@ var e=10,t=(e=0)=>t=>`\u001B[${t+e}m`,n=(e=0)=>t=>`\u001B[${38+e};5;${t}m`,r=(e=
89
89
  </div>
90
90
  </div>
91
91
  </div>
92
- `,ie=class{constructor(){this.parent=null,this.el=document.createElement(`div`),this.el.classList.add(`dimina-native-view`),this.appList=[],this.filteredAppList=[],this.searchKeyword=``}viewDidLoad(){this.el.innerHTML=re,this.createAppList(),this.bindSearchEvent(),this.bindOpenMiniApp()}createAppList(){this.setListState(`加载中...`),G().then(e=>{this.appList=e,this.renderFilteredAppList()}).catch(()=>{this.appList=[],this.renderAppList([]),this.setListState(`应用列表加载失败`)})}bindSearchEvent(){this.el.querySelector(`.dimina-app__mini-search-input-placeholder`).addEventListener(`input`,e=>{this.searchKeyword=e.target.value.trim().toLocaleLowerCase(),this.renderFilteredAppList()})}bindOpenMiniApp(){let e=this.el.querySelector(`.dimina-app__mini-used-list`);e.onclick=async e=>{let t=N(e.target,`dimina-app__mini-used-list-item`);if(!t)return;let n=t.getAttribute(`data-appid`),r=await K(n);r&&Z.openApp({appId:n,path:r.path,scene:1001,destroy:!0},this.parent)}}onPresentOut(){}onPresentIn(){this.parent.updateStatusBarColor(`black`)}renderFilteredAppList(){let e=this.searchKeyword;this.filteredAppList=e?this.appList.filter(t=>{let n=t.name?.toLocaleLowerCase()??``,r=t.appId?.toLocaleLowerCase()??``;return n.includes(e)||r.includes(e)}):this.appList,this.renderAppList(this.filteredAppList),this.appList.length?this.filteredAppList.length?this.setListState(``):this.setListState(`未找到匹配的小程序`):this.setListState(`暂无应用`)}renderAppList(e){let t=this.el.querySelector(`.dimina-app__mini-used-list`),n=document.createDocumentFragment();e.forEach(e=>{let t=document.createElement(`li`);t.className=`dimina-app__mini-used-list-item`,t.dataset.appid=e.appId;let r=document.createElement(`div`);r.className=`dimina-app__mini-used-logo`;let i=document.createElement(`img`);i.src=e.logo,i.alt=`${e.name} logo`,i.loading=`lazy`,i.draggable=!1,r.appendChild(i);let a=document.createElement(`p`);a.className=`dimina-app__mini-used-name`,a.textContent=e.name,t.append(r,a),n.appendChild(t)}),t.replaceChildren(n)}setListState(e){let t=this.el.querySelector(`.dimina-app__mini-used-state`);t.textContent=e,t.hidden=!e}},ae=`<!-- 手机本体 -->
92
+ `,re=class{constructor(){this.parent=null,this.el=document.createElement(`div`),this.el.classList.add(`dimina-native-view`),this.appList=[],this.filteredAppList=[],this.searchKeyword=``}viewDidLoad(){this.el.innerHTML=ne,this.createAppList(),this.bindSearchEvent(),this.bindOpenMiniApp()}createAppList(){this.setListState(`加载中...`),G().then(e=>{this.appList=e,this.renderFilteredAppList()}).catch(()=>{this.appList=[],this.renderAppList([]),this.setListState(`应用列表加载失败`)})}bindSearchEvent(){this.el.querySelector(`.dimina-app__mini-search-input-placeholder`).addEventListener(`input`,e=>{this.searchKeyword=e.target.value.trim().toLocaleLowerCase(),this.renderFilteredAppList()})}bindOpenMiniApp(){let e=this.el.querySelector(`.dimina-app__mini-used-list`);e.onclick=async e=>{let t=M(e.target,`dimina-app__mini-used-list-item`);if(!t)return;let n=t.getAttribute(`data-appid`),r=await K(n);r&&Z.openApp({appId:n,path:r.path,scene:1001,destroy:!0},this.parent)}}onPresentOut(){}onPresentIn(){this.parent.updateStatusBarColor(`black`)}renderFilteredAppList(){let e=this.searchKeyword;this.filteredAppList=e?this.appList.filter(t=>{let n=t.name?.toLocaleLowerCase()??``,r=t.appId?.toLocaleLowerCase()??``;return n.includes(e)||r.includes(e)}):this.appList,this.renderAppList(this.filteredAppList),this.appList.length?this.filteredAppList.length?this.setListState(``):this.setListState(`未找到匹配的小程序`):this.setListState(`暂无应用`)}renderAppList(e){let t=this.el.querySelector(`.dimina-app__mini-used-list`),n=document.createDocumentFragment();e.forEach(e=>{let t=document.createElement(`li`);t.className=`dimina-app__mini-used-list-item`,t.dataset.appid=e.appId;let r=document.createElement(`div`);r.className=`dimina-app__mini-used-logo`;let i=document.createElement(`img`);i.src=e.logo,i.alt=`${e.name} logo`,i.loading=`lazy`,i.draggable=!1,r.appendChild(i);let a=document.createElement(`p`);a.className=`dimina-app__mini-used-name`,a.textContent=e.name,t.append(r,a),n.appendChild(t)}),t.replaceChildren(n)}setListState(e){let t=this.el.querySelector(`.dimina-app__mini-used-state`);t.textContent=e,t.hidden=!e}},ie=`<!-- 手机本体 -->
93
93
  <div id="iphone">
94
94
  <!-- 手机屏幕 -->
95
95
  <div class="iphone__screen">
@@ -131,4 +131,4 @@ var e=10,t=(e=0)=>t=>`\u001B[${t+e}m`,n=(e=0)=>t=>`\u001B[${38+e};5;${t}m`,r=(e=
131
131
  <!-- 电源键 -->
132
132
  <button class="power-btn" type="button" aria-label="电源键" aria-pressed="false"></button>
133
133
  </div>
134
- `,oe=class{constructor(){this.appContainer=null,this.application=null,this.isScreenSleeping=!1,this.root=document.querySelector(`#root`),this.init()}init(){this.root.innerHTML=ae,this.appContainer=this.root.querySelector(`.iphone__apps`),this.updateDeviceBarColor(`black`),this.updateStatusBarTime(),this.outerGlow(),this.bindPowerButton()}updateStatusBarTime(){let e=this.root.querySelector(`.status-bar__time`),t=()=>{let t=new Date;e.textContent=`${t.getHours().toString().padStart(2,`0`)}:${t.getMinutes().toString().padStart(2,`0`)}`};t(),setInterval(t,6e4)}outerGlow(){let e=this.root.querySelector(`.iphone__screen_dynamic-island`);e.addEventListener(`click`,()=>{window.open(`https://github.com/didi/dimina`,`_blank`)}),e.addEventListener(`mouseenter`,()=>{e.classList.add(`island-hover`)}),e.addEventListener(`mouseleave`,()=>{e.classList.remove(`island-hover`)});let t=null,n=0;document.body.addEventListener(`pointermove`,({x:e,y:r})=>{t={pointerX:e,pointerY:r},!n&&(n=requestAnimationFrame(()=>{let{pointerX:e,pointerY:r}=t,i=e.toFixed(2),a=r.toFixed(2),o=(e/window.innerWidth).toFixed(2),s=(r/window.innerHeight).toFixed(2);document.documentElement.style.setProperty(`--x`,i),document.documentElement.style.setProperty(`--xp`,o),document.documentElement.style.setProperty(`--y`,a),document.documentElement.style.setProperty(`--yp`,s),n=0}))})}bindPowerButton(){let e=this.root.querySelector(`.power-btn`);e?.addEventListener(`pointerdown`,e=>{e.preventDefault(),this.toggleScreen()}),e?.addEventListener(`keydown`,e=>{e.repeat||e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),this.toggleScreen())})}toggleScreen(){this.isScreenSleeping?this.wakeScreen():this.sleepScreen()}sleepScreen(){this.isScreenSleeping||(this.isScreenSleeping=!0,this.root.querySelector(`.iphone__screen`)?.classList.add(`iphone__screen--sleeping`),this.root.querySelector(`.power-btn`)?.setAttribute(`aria-pressed`,`true`),this.application?.sleepActiveView?.())}wakeScreen(){this.isScreenSleeping&&(this.isScreenSleeping=!1,this.root.querySelector(`.iphone__screen`)?.classList.remove(`iphone__screen--sleeping`),this.root.querySelector(`.power-btn`)?.setAttribute(`aria-pressed`,`false`),this.application?.wakeActiveView?.())}updateDeviceBarColor(e){let t=this.root.querySelector(`.iphone__status-bar`);e===`black`?(t.classList.remove(`iphone__status-bar--white`),t.classList.add(`iphone__status-bar--black`)):e===`white`&&(t.classList.add(`iphone__status-bar--white`),t.classList.remove(`iphone__status-bar--black`))}open(e){this.application=e,e.parent=this,this.appContainer.appendChild(e.el)}};Z.registerExtModule(`DemoNativeModule`,({event:e,data:t,success:n,fail:r})=>{if(e===`getUserInfo`){setTimeout(()=>{n?.({uid:t?.uid??`unknown`,name:`Mock User`,level:3})},300);return}if(e===`onTickEvent`){let e=0,t=setInterval(()=>{e++,n?.({tick:e,timestamp:Date.now()})},1e3);return()=>clearInterval(t)}r?.({errMsg:`DemoNativeModule: unknown event "${e}"`})}),window.onload=function(){let e=new oe,t=new ne,n=new ie;t.initRootView(n),e.open(t);let r=B.parse(window.location.hash,window.location.search);if(r){let e=r.stack[0],n=e.query&&Object.keys(e.query).length>0?`${e.pagePath}?${Object.entries(e.query).map(([e,t])=>`${e}=${encodeURIComponent(t)}`).join(`&`)}`:e.pagePath;Z.openApp({appId:r.appId,path:n,scene:1001,destroy:!0,restoreStack:r.stack},t)}};
134
+ `,ae=class{constructor(){this.appContainer=null,this.application=null,this.isScreenSleeping=!1,this.root=document.querySelector(`#root`),this.init()}init(){this.root.innerHTML=ie,this.appContainer=this.root.querySelector(`.iphone__apps`),this.updateDeviceBarColor(`black`),this.updateStatusBarTime(),this.outerGlow(),this.bindPowerButton()}updateStatusBarTime(){let e=this.root.querySelector(`.status-bar__time`),t=()=>{let t=new Date,n=t.getHours().toString().padStart(2,`0`),r=t.getMinutes().toString().padStart(2,`0`);e.textContent=`${n}:${r}`};t(),setInterval(t,6e4)}outerGlow(){let e=this.root.querySelector(`.iphone__screen_dynamic-island`);e.addEventListener(`click`,()=>{window.open(`https://github.com/didi/dimina`,`_blank`)}),e.addEventListener(`mouseenter`,()=>{e.classList.add(`island-hover`)}),e.addEventListener(`mouseleave`,()=>{e.classList.remove(`island-hover`)});let t=null,n=0;document.body.addEventListener(`pointermove`,({x:e,y:r})=>{t={pointerX:e,pointerY:r},!n&&(n=requestAnimationFrame(()=>{let{pointerX:e,pointerY:r}=t,i=e.toFixed(2),a=r.toFixed(2),o=(e/window.innerWidth).toFixed(2),s=(r/window.innerHeight).toFixed(2);document.documentElement.style.setProperty(`--x`,i),document.documentElement.style.setProperty(`--xp`,o),document.documentElement.style.setProperty(`--y`,a),document.documentElement.style.setProperty(`--yp`,s),n=0}))})}bindPowerButton(){let e=this.root.querySelector(`.power-btn`);e?.addEventListener(`pointerdown`,e=>{e.preventDefault(),this.toggleScreen()}),e?.addEventListener(`keydown`,e=>{e.repeat||e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),this.toggleScreen())})}toggleScreen(){this.isScreenSleeping?this.wakeScreen():this.sleepScreen()}sleepScreen(){this.isScreenSleeping||(this.isScreenSleeping=!0,this.root.querySelector(`.iphone__screen`)?.classList.add(`iphone__screen--sleeping`),this.root.querySelector(`.power-btn`)?.setAttribute(`aria-pressed`,`true`),this.application?.sleepActiveView?.())}wakeScreen(){this.isScreenSleeping&&(this.isScreenSleeping=!1,this.root.querySelector(`.iphone__screen`)?.classList.remove(`iphone__screen--sleeping`),this.root.querySelector(`.power-btn`)?.setAttribute(`aria-pressed`,`false`),this.application?.wakeActiveView?.())}updateDeviceBarColor(e){let t=this.root.querySelector(`.iphone__status-bar`);e===`black`?(t.classList.remove(`iphone__status-bar--white`),t.classList.add(`iphone__status-bar--black`)):e===`white`&&(t.classList.add(`iphone__status-bar--white`),t.classList.remove(`iphone__status-bar--black`))}open(e){this.application=e,e.parent=this,this.appContainer.appendChild(e.el)}};Z.registerExtModule(`DemoNativeModule`,({event:e,data:t,success:n,fail:r})=>{if(e===`getUserInfo`){setTimeout(()=>{n?.({uid:t?.uid??`unknown`,name:`Mock User`,level:3})},300);return}if(e===`onTickEvent`){let e=0,t=setInterval(()=>{e++,n?.({tick:e,timestamp:Date.now()})},1e3);return()=>clearInterval(t)}r?.({errMsg:`DemoNativeModule: unknown event "${e}"`})}),window.onload=function(){let e=new ae,t=new te,n=new re;t.initRootView(n),e.open(t);let r=B.parse(window.location.hash,window.location.search);if(r){let e=r.stack[0],n=e.query&&Object.keys(e.query).length>0?`${e.pagePath}?${Object.entries(e.query).map(([e,t])=>`${e}=${encodeURIComponent(t)}`).join(`&`)}`:e.pagePath;Z.openApp({appId:r.appId,path:n,scene:1001,destroy:!0,restoreStack:r.stack},t)}};