@dimina-kit/devkit 0.1.2-dev.20260522142649 → 0.1.2-dev.20260524104239

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 +1 @@
1
- var e=()=>new Promise(e=>requestAnimationFrame(()=>requestAnimationFrame(e))),t=(e,t,i=560)=>new Promise(a=>{const s=setTimeout(a,i),n=i=>{t&&i.propertyName!==t||(clearTimeout(s),e.removeEventListener("transitionend",n),a())};e.addEventListener("transitionend",n)}),i=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(i){if(!this.done)return;this.done=!1;const a=this.views[this.views.length-1];i.parent=this,this.views.push(i),i.el.style.zIndex=this.views.length,i.el.classList.add("dimina-native-view--before-enter"),this.window.appendChild(i.el),i?.viewDidLoad(),await e(),a.el.classList.remove("dimina-native-view--instage"),a.el.classList.add("dimina-native-view--slide-out"),a.el.classList.add("dimina-native-view--linear-anima"),i.el.classList.add("dimina-native-view--enter-anima"),i.el.classList.add("dimina-native-view--instage"),await t(i.el,"transform"),a.el.classList.remove("dimina-native-view--linear-anima"),i.el.classList.remove("dimina-native-view--before-enter"),i.el.classList.remove("dimina-native-view--enter-anima"),i.el.classList.remove("dimina-native-view--instage"),this.done=!0}async popView(){if(this.views.length<2)return;if(!this.done)return;this.done=!1;const e=this.views[this.views.length-2],i=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"),i.el.classList.remove("dimina-native-view--instage"),i.el.classList.add("dimina-native-view--before-enter"),i.el.classList.add("dimina-native-view--enter-anima"),await t(i.el,"transform"),this.views.pop(),this.window.removeChild(i.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(i,a){if(!this.done)return;this.done=!1;const s=this.views[this.views.length-1];i.parent=this,i.el.style.zIndex=this.views.length+1,i.el.classList.add("dimina-native-view--before-present"),i.el.classList.add("dimina-native-view--enter-anima"),s?.el.classList.add("dimina-native-view--before-presenting"),s?.el.classList.remove("dimina-native-view--instage"),s?.el.classList.add("dimina-native-view--enter-anima"),s?.onPresentOut(),i.onPresentIn(),!a&&this.el.appendChild(i.el),this.views.push(i),!a&&i.viewDidLoad&&i.viewDidLoad(),a&&i.restoreColorStyle(),await e(),s?.el.classList.add("dimina-native-view--presenting"),i.el.classList.add("dimina-native-view--instage"),await t(i.el,"transform"),i.el.classList.remove("dimina-native-view--before-present"),i.el.classList.remove("dimina-native-view--enter-anima"),s?.el.classList.remove("dimina-native-view--enter-anima"),s?.el.classList.remove("dimina-native-view--before-presenting"),this.done=!0}dismissView(e={}){return this._enqueue(()=>this._dismissView(e))}async _dismissView(i={}){if(!this.done)return;this.done=!1;const a=this.views[this.views.length-2],s=this.views[this.views.length-1],{destroy:n=!0}=i;s.el.classList.add("dimina-native-view--enter-anima"),a?.el.classList.add("dimina-native-view--enter-anima"),a?.el.classList.add("dimina-native-view--before-presenting"),await e(),s.el.classList.add("dimina-native-view--before-present"),s.el.classList.remove("dimina-native-view--instage"),a?.el.classList.remove("dimina-native-view--presenting"),a?.onPresentIn(),s?.onPresentOut(),await t(s.el,"transform"),n&&(s.destroy(),this.el.removeChild(s.el)),this.views.pop(),a?.el.classList.remove("dimina-native-view--enter-anima"),a?.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;const e=this.getActiveView();e?.restoreColorStyle?.(),e?.onPresentIn?.()}updateStatusBarColor(e){this.parent?.updateDeviceBarColor(e)}};var a=function(e){const t=/* @__PURE__ */new Map;return function(...i){const a=1===i.length?i[0]:JSON.stringify(i);if(t.has(a))return t.get(a);const s=e.apply(this,i);return t.set(a,s),s}}(async()=>{const e=await fetch("/appList.json").then(e=>e.json());return e.forEach(e=>{const t=JSON.stringify(e),i=sessionStorage.getItem(t);if(i)e.logo=i;else{const i=function(e){const t=[60,60],i=window.devicePixelRatio||1,a=document.createElement("canvas");a.style.width=t[0]+"px",a.style.height=t[1]+"px",a.width=t[0]*i,a.height=t[1]*i;const s=a.getContext("2d");s.scale(i,i),s.imageSmoothingEnabled=!0,s.imageSmoothingQuality="high",s.textRenderingOptimization="optimizeQuality",s.fillStyle=function(e){if(!e||0===e.length)return"#2196F3";let t=0;for(let o=0;o<e.length;o++)t=(t<<5)-t+e.charCodeAt(o),t|=0;const i=function(e,t,i){let a,s,n;const o=Math.floor(e/60),r=e/60-o,l=i*(1-t),c=i*(1-r*t),h=i*(1-(1-r)*t);switch(o%6){case 0:a=i,s=h,n=l;break;case 1:a=c,s=i,n=l;break;case 2:a=l,s=i,n=h;break;case 3:a=l,s=c,n=i;break;case 4:a=h,s=l,n=i;break;case 5:a=i,s=l,n=c}return[Math.round(255*a),Math.round(255*s),Math.round(255*n)]}(Math.abs(t%360),.7+Math.abs(t%3e3)/1e4,.8+Math.abs(t%2e3)/1e4);return a=i[0],s=i[1],n=i[2],`#${((1<<24)+(a<<16)+(s<<8)+n).toString(16).slice(1)}`;var a,s,n}(e.name),s.fillRect(0,0,t[0],t[1]),s.fillStyle="rgb(255,255,255)",s.font=.6*t[0]+"px Arial";const n=e.name.charAt(0),o=s.measureText(n),r=t[0]/2,l=t[1]/2+(o.actualBoundingBoxAscent-o.actualBoundingBoxDescent)/2;return s.textAlign="center",s.fillText(n,r,l),a.toDataURL("image/png",1)}(e);sessionStorage.setItem(t,i),e.logo=i}}),e});function s(){return Math.random().toString(36).slice(2,7)}function n(e){const t=e.split("?"),i=t[0],a=t[1],s={query:{},pagePath:i};return a?(a.split("&").forEach(e=>{const t=e.split("=")[0],i=e.split("=")[1];s.query[t]=i}),s):s}function o(e,t){const i={},a=e.window||{},s=t||{};return i.navigationBarTitleText=s.navigationBarTitleText||a.navigationBarTitleText||"",i.navigationBarBackgroundColor=s.navigationBarBackgroundColor||a.navigationBarBackgroundColor||"#000",i.navigationBarTextStyle=s.navigationBarTextStyle||a.navigationBarTextStyle||"white",i.backgroundColor=s.backgroundColor||a.backgroundColor||"#fff",i.navigationStyle=s.navigationStyle||a.navigationStyle||"default",i.usingComponents=s.usingComponents||{},i}var r=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){const{appId:i,path:s,scene:o,destroy:r,restoreStack:l}=e,{pagePath:c,query:h}=n(s),{name:d,logo:p}=await async function(e){const t=await a();for(const i of t)if(i.appId===e)return i}(i);if(r)for(const a of this.appStack)a.appId!==i&&(a.bridgeList.pop()?.destroy(),t.destroyRootView(a));const g=this.getAppById(i);if(g)t.presentView(g,!0);else{const e=new $({appId:i,scene:o,name:d,logo:p,pagePath:c,query:h,restoreStack:l});this.appStack.push(e),t.presentView(e,!1)}}static getAppById(e){for(const 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})}},l=(e=0)=>t=>`[${t+e}m`,c=(e=0)=>t=>`[${38+e};5;${t}m`,h=(e=0)=>(t,i,a)=>`[${38+e};2;${t};${i};${a}m`,d={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(d.modifier),Object.keys(d.color),Object.keys(d.bgColor);var p=function(){const e=/* @__PURE__ */new Map;for(const[t,i]of Object.entries(d)){for(const[t,a]of Object.entries(i))d[t]={open:`[${a[0]}m`,close:`[${a[1]}m`},i[t]=d[t],e.set(a[0],a[1]);Object.defineProperty(d,t,{value:i,enumerable:!1})}return Object.defineProperty(d,"codes",{value:e,enumerable:!1}),d.color.close="",d.bgColor.close="",d.color.ansi=l(),d.color.ansi256=c(),d.color.ansi16m=h(),d.bgColor.ansi=l(10),d.bgColor.ansi256=c(10),d.bgColor.ansi16m=h(10),Object.defineProperties(d,{rgbToAnsi256:{value:(e,t,i)=>e===t&&t===i?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(i/255*5),enumerable:!1},hexToRgb:{value(e){const t=/[a-f\d]{6}|[a-f\d]{3}/i.exec(e.toString(16));if(!t)return[0,0,0];let[i]=t;3===i.length&&(i=[...i].map(e=>e+e).join(""));const a=Number.parseInt(i,16);return[a>>16&255,a>>8&255,255&a]},enumerable:!1},hexToAnsi256:{value:e=>d.rgbToAnsi256(...d.hexToRgb(e)),enumerable:!1},ansi256ToAnsi:{value(e){if(e<8)return 30+e;if(e<16)return e-8+90;let t,i,a;if(e>=232)t=(10*(e-232)+8)/255,i=t,a=t;else{const s=(e-=16)%36;t=Math.floor(e/36)/5,i=Math.floor(s/6)/5,a=s%6/5}const s=2*Math.max(t,i,a);if(0===s)return 30;let n=30+(Math.round(a)<<2|Math.round(i)<<1|Math.round(t));return 2===s&&(n+=60),n},enumerable:!1},rgbToAnsi:{value:(e,t,i)=>d.ansi256ToAnsi(d.rgbToAnsi256(e,t,i)),enumerable:!1},hexToAnsi:{value:e=>d.ansi256ToAnsi(d.hexToAnsi256(e)),enumerable:!1}}),d}(),g=(()=>{if(!("navigator"in globalThis))return 0;if(globalThis.navigator.userAgentData){const e=navigator.userAgentData.brands.find(({brand:e})=>"Chromium"===e);if(e&&e.version>93)return 3}return/\b(Chrome|Chromium)\//.test(globalThis.navigator.userAgent)?1:0})(),m=0!==g&&{level:g,hasBasic:!0,has256:g>=2,has16m:g>=3},u={stdout:m,stderr:m};function b(e,t,i){let a=e.indexOf(t);if(-1===a)return e;const s=t.length;let n=0,o="";do{o+=e.slice(n,a)+t+i,n=a+s,a=e.indexOf(t,n)}while(-1!==a);return o+=e.slice(n),o}var{stdout:v,stderr:w}=u,f=Symbol("GENERATOR"),y=Symbol("STYLER"),_=Symbol("IS_EMPTY"),C=["ansi","ansi","ansi256","ansi16m"],S=Object.create(null),k=e=>{const t=(...e)=>e.join(" ");return((e,t={})=>{if(t.level&&!(Number.isInteger(t.level)&&t.level>=0&&t.level<=3))throw new Error("The `level` option should be an integer from 0 to 3");const i=v?v.level:0;e.level=void 0===t.level?i:t.level})(t,e),Object.setPrototypeOf(t,B.prototype),t};function B(e){return k(e)}Object.setPrototypeOf(B.prototype,Function.prototype);for(const[j,O]of Object.entries(p))S[j]={get(){const e=I(this,P(O.open,O.close,this[y]),this[_]);return Object.defineProperty(this,j,{value:e}),e}};S.visible={get(){const e=I(this,this[y],!0);return Object.defineProperty(this,"visible",{value:e}),e}};var L=(e,t,i,...a)=>"rgb"===e?"ansi16m"===t?p[i].ansi16m(...a):"ansi256"===t?p[i].ansi256(p.rgbToAnsi256(...a)):p[i].ansi(p.rgbToAnsi(...a)):"hex"===e?L("rgb",t,i,...p.hexToRgb(...a)):p[i][e](...a);for(const j of["rgb","hex","ansi256"]){S[j]={get(){const{level:e}=this;return function(...t){const i=P(L(j,C[e],"color",...t),p.color.close,this[y]);return I(this,i,this[_])}}};S["bg"+j[0].toUpperCase()+j.slice(1)]={get(){const{level:e}=this;return function(...t){const i=P(L(j,C[e],"bgColor",...t),p.bgColor.close,this[y]);return I(this,i,this[_])}}}}var T=Object.defineProperties(()=>{},{...S,level:{enumerable:!0,get(){return this[f].level},set(e){this[f].level=e}}}),P=(e,t,i)=>{let a,s;return void 0===i?(a=e,s=t):(a=i.openAll+e,s=t+i.closeAll),{open:e,close:t,openAll:a,closeAll:s,parent:i}},I=(e,t,i)=>{const a=(...e)=>M(a,1===e.length?""+e[0]:e.join(" "));return Object.setPrototypeOf(a,T),a[f]=e,a[y]=t,a[_]=i,a},M=(e,t)=>{if(e.level<=0||!t)return e[_]?"":t;let i=e[y];if(void 0===i)return t;const{openAll:a,closeAll:s}=i;if(t.includes(""))for(;void 0!==i;)t=b(t,i.close,i.open),i=i.parent;const n=t.indexOf("\n");return-1!==n&&(t=function(e,t,i,a){let s=0,n="";do{const o="\r"===e[a-1];n+=e.slice(s,o?a-1:a)+t+(o?"\r\n":"\n")+i,s=a+1,a=e.indexOf("\n",s)}while(-1!==a);return n+=e.slice(s),n}(t,s,a,n)),a+t+s};Object.defineProperties(B.prototype,S);B(),B({level:w?w.level:0});function E(e){return{all:e=e||/* @__PURE__ */new Map,on:function(t,i){var a=e.get(t);a?a.push(i):e.set(t,[i])},off:function(t,i){var a=e.get(t);a&&(i?a.splice(a.indexOf(i)>>>0,1):e.set(t,[]))},emit:function(t,i){var a=e.get(t);a&&a.slice().map(function(e){e(i)}),(a=e.get("*"))&&a.slice().map(function(e){e(t,i)})}}}var x=class{constructor(e){this.opts=e,this.id=`webview_${s()}`,this.el=document.createElement("div"),this.el.classList.add("dimina-native-view"),this.el.innerHTML='<div class="dimina-native-webview">\n\t\x3c!-- 导航区域 --\x3e\n\t<div class="dimina-native-webview__navigation">\n\t\t<div class="dimina-native-webview__navigation-content">\n\t\t\t<div class="dimina-native-webview__navigation-left-btn"></div>\n\t\t\t<h2 class="dimina-native-webview__navigation-title"></h2>\n\t\t</div>\n\t</div>\n\n\t\x3c!-- iframe --\x3e\n\t<div class="dimina-native-webview__body">\n\t\t<div class="dimina-native-webview__root">\n\t\t\t<iframe class="dimina-native-webview__window" title="pageFrame"></iframe>\n\t\t</div>\n\t</div>\n</div>',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=E(),this.bindBackEvent()}async init(e){await this.frameLoaded();const 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(){this.el.querySelector(".dimina-native-webview__navigation-left-btn").onclick=()=>{this.parent.parent.navigateBack()}}frameLoaded(){return new Promise(e=>{this.iframe.onload=()=>{e()}})}setInitialStyle(){const e=this.opts.configInfo,t=this.el.querySelector(".dimina-native-webview"),i=this.el.querySelector(".dimina-native-webview__navigation-title"),a=this.el.querySelector(".dimina-native-webview__navigation"),s=this.el.querySelector(".dimina-native-webview__navigation-left-btn"),n=this.el.querySelector(".dimina-native-webview__root");this.opts.isRoot?s.style.display="none":s.style.display="block","white"===e.navigationBarTextStyle?a.classList.add("dimina-native-webview__navigation--white"):a.classList.add("dimina-native-webview__navigation--black"),"custom"===e.navigationStyle&&t.classList.add("dimina-native-webview--custom-nav"),n.style.backgroundColor=e.backgroundColor,a.style.backgroundColor=e.navigationBarBackgroundColor,i.textContent=e.navigationBarTitleText}},A=class{constructor(e){this.id=`bridge_${s()}`,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){"string"==typeof e&&(e=JSON.parse(e));const{body:t,target:i}=e;t.bridgeId&&t.bridgeId!==this.id||("service"===i?this.jscore.postMessage(e):"render"===i&&this.webview.postMessage(e))}messageInvoke(e,t){"string"==typeof t&&(t=JSON.parse(t));const{type:i,body:a,target:s}=t;if(a.bridgeId&&a.bridgeId!==this.id)return;const n={type:i,body:{bridgeId:this.id,pagePath:this.opts.pagePath,scene:this.opts.scene,query:this.opts.query,...a}};if("service"===s){if("serviceResourceLoaded"===i){if(this.serviceResource=!0,!this.isResourceLoaded())return;n.type="resourceLoaded"}else if("renderResourceLoaded"===i){if(this.renderResource=!0,!this.isResourceLoaded())return;n.type="resourceLoaded"}this.jscore.postMessage(n)}else if("container"===s&&"invokeAPI"===i){const{name:e,params:t}=a;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=>{const t=new x({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}})}},q=class{constructor(e){this.parent=e,this.worker=null,this.event=E()}async init(){const e=this.parent.getApiNamespaces?.()||[],t=JSON.stringify({apiNamespaces:e});this.worker=new Worker("/assets/service.js",{type:"classic",name:t}),this.worker.onmessage=e=>{const 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()}},F=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){const t=e.indexOf("?");if(-1===t)return{pagePath:e,query:{}};const i=e.slice(0,t),a={};return new URLSearchParams(e.slice(t+1)).forEach((e,t)=>{a[t]=e}),{pagePath:i,query:a}}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,i=("undefined"!=typeof window?window.location.search:"")){const a=new URLSearchParams(this._normalizeSearch(i));if(this.ROUTE_QUERY_KEYS.forEach(e=>a.delete(e)),!e||!t?.length)return this._stringifySearchParams(a);const s=t[0],n=t[t.length-1];return a.set("appId",e),a.set("entry",this._encodePage(s.pagePath,s.query||{})),a.set("page",this._encodePage(n.pagePath,n.query||{})),this._stringifySearchParams(a)}static buildRouteURL(e,t,i=("undefined"!=typeof window?`${window.location.origin}${window.location.pathname}`:"")){const a=this.buildRouteSearch(e,t);return`${i}${a?`?${a}`:""}`}static syncStack(e,t){const i=this.buildRouteSearch(e,t);history.replaceState(null,"",`${window.location.pathname}${i?`?${i}`:""}`)}static clear(){const e=new URLSearchParams(this._normalizeSearch(window.location.search));this.ROUTE_QUERY_KEYS.forEach(t=>e.delete(t));const t=this._stringifySearchParams(e);history.replaceState(null,"",`${window.location.pathname}${t?`?${t}`:""}`)}static parseSearch(e){const t=new URLSearchParams(this._normalizeSearch(e)),i=t.get("appId"),a=t.get("entry"),s=t.get("page")||a;if(!i||!a)return null;const n=this._decodePage(a);if(!n.pagePath)return null;const o=[n];if(s&&s!==a){const e=this._decodePage(s);e.pagePath&&o.push(e)}return{appId:i,stack:o}}static parseHash(e){if(!e||e.length<=1)return null;const t=e.slice(1).split("|");if(t.length<2)return null;const i=t[0],a=t.slice(1).map(e=>this._decodePage(e));return i&&0!==a.length?{appId:i,stack:a}:null}static parse(e,t=("undefined"!=typeof window?window.location.search:"")){return this.parseSearch(t)||this.parseHash(e)}},R=(e,t,i=560)=>new Promise(a=>{const s=setTimeout(a,i),n=i=>{t&&i.propertyName!==t||(clearTimeout(s),e.removeEventListener("transitionend",n),a())};e.addEventListener("transitionend",n)}),$=class{constructor(e){this.appInfo=e,this.id=`mini_app_${s()}`,this.parent=null,this.appId=e.appId,this.appConfig=null,this.bridgeList=[],this.jscore=new q(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=/* @__PURE__ */new Map,this.tabBarConfig=null,this.tabBarPaths=[],this.tabBarBridges=/* @__PURE__ */new Map,this.currentTabPath=null,this.tabBarEl=null,this.tabBarHeight=0,this._modalStack=[],this._modalPendingTimers=/* @__PURE__ */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{const 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(){F.clear(),this.closeMiniAppMenu(),r.closeApp(this)}renderMiniAppMenu(){const e=this.el.querySelector(".dimina-mini-app-menu__app-name"),t=this.el.querySelector(".dimina-mini-app-menu__app-id"),i=this.el.querySelector(".dimina-mini-app-menu__app-desc"),a=this.el.querySelector(".dimina-mini-app-menu__app-logo-img"),s=this.el.querySelector(".dimina-mini-app-menu__quick-actions"),n=this.getCurrentPagePath(),o=this.getEntryPagePath(),r=this.getCurrentPageQuery(),l=n||o||"",c=F.buildRouteURL(this.appId,[{pagePath:o,query:this.appInfo.query||{}},{pagePath:l,query:r}]);e.textContent=this.appInfo.name||"未命名小程序",t.textContent=`AppID:${this.appId||"--"}`,i.textContent=`当前页面:${l||"--"}`,a.src=this.appInfo.logo||"";const h=[{label:"复制链接",icon:"↗",handler:()=>this.copyText(c,"链接已复制")},{label:"重新进入",icon:"↻",handler:()=>{this.closeMiniAppMenu(),this.reLaunch({url:o||n})}},{label:"关闭小程序",icon:"×",danger:!0,handler:()=>this.closeMiniProgram()}];s.innerHTML=h.map((e,t)=>`\n\t\t\t\t<button type="button" class="dimina-mini-app-menu__quick-action${e.danger?" is-danger":""}" data-quick-index="${t}">\n\t\t\t\t\t<span class="dimina-mini-app-menu__quick-action-icon">${e.icon}</span>\n\t\t\t\t\t<span class="dimina-mini-app-menu__quick-action-label">${e.label}</span>\n\t\t\t\t</button>\n\t\t\t`).join(""),s.querySelectorAll("[data-quick-index]").forEach((e,t)=>{e.onclick=()=>h[t].handler()})}openMiniAppMenu(){const 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(){const 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){const i=this.apiRegistry[e];i?i.call(this,t):"function"==typeof this[e]?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();const e="main",t=`${this.appInfo.appId}/${e}/app-config.json`,[i]=await Promise.all([(s=`/${t}`,new Promise(e=>{fetch(`${s}`).then(e=>e.text()).then(t=>{e(t)}).catch(()=>{e(null)})})),(a=560,new Promise(e=>{setTimeout(()=>{e()},a)}))]);var a,s;if(!i)return;this.appConfig=JSON.parse(i),this._initTabBar();const n=this.appInfo.pagePath||this.appConfig.app.entryPagePath,r=this.appConfig.modules[n],l=o(this.appConfig.app,r);this.updateTargetPageColorStyle(l);const c=await this.createBridge({pagePath:n,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:l});if(this.bridgeList.push(c),this._isTabBarPage(n)){const e=this._normalizePagePath(n);this.tabBarBridges.set(e,c),this.currentTabPath=e,this._setTabBarVisible(!0),this._updateTabBarSelection(e)}c.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++){const{pagePath:i,query:a}=e[t],s=t===e.length-1,n=i.startsWith("/")?i.slice(1):i,r=this.appConfig.modules[n],l=o(this.appConfig.app,r),c=await this.createBridge({pagePath:n,query:a,scene:this.appInfo.scene,jscore:this.jscore,isRoot:!1,root:r?.root||"main",appId:this.appInfo.appId,pages:this.appConfig.app.pages,configInfo:l}),h=this.bridgeList[this.bridgeList.length-1];h.webview.el.classList.remove("dimina-native-view--instage"),h.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"),s||c.webview.el.classList.add("dimina-native-view--slide-out"),c.start()}if(e.length>0){const e=this.bridgeList[this.bridgeList.length-1],t=this.appConfig.modules[e.opts.pagePath],i=o(this.appConfig.app,t);this.updateTargetPageColorStyle(i),this._isTabBarPage(e.opts.pagePath)||this._setTabBarVisible(!1)}}_syncHash(){const e=this.bridgeList.map(e=>({pagePath:e.opts.pagePath.startsWith("/")?e.opts.pagePath.slice(1):e.opts.pagePath,query:e.opts.query||{}}));F.syncStack(this.appId,e)}async createBridge(e){const{jscore:t,configInfo:i,isRoot:a,appId:s,pagePath:n,query:o,scene:r,pages:l,root:c}=e,h=new A({jscore:t,configInfo:i,isRoot:a,appId:s,pagePath:n,query:o,scene:r,pages:l,root:c});return h.parent=this,await h.init(),h}onPresentIn(){const e=this.bridgeList[this.bridgeList.length-1];e?.appShow(),e?.pageShow()}onPresentOut(){const e=this.bridgeList[this.bridgeList.length-1];e?.appHide(),e?.pageHide()}initPageFrame(){this.el.innerHTML='<div class="dimina-mini-app">\n\t\x3c!-- 右上方药丸按钮 --\x3e\n\t<ul class="dimina-mini-app-navigation__actions">\n\t\t<li class="dimina-mini-app-navigation__actions-variable"></li>\n\t\t<li class="dimina-mini-app-navigation__actions-close"></li>\n\t</ul>\n\n\t\x3c!-- webview挂载节点 --\x3e\n\t<div class="dimina-mini-app__webviews"></div>\n\n\t\x3c!-- TabBar 底部导航栏 --\x3e\n\t<div class="dimina-mini-app__tabbar" style="display: none;"></div>\n\n\t\x3c!-- 启动loading页面 --\x3e\n\t<div class="dimina-mini-app__launch-screen">\n\t\t<div class="dimina-mini-app__launch-screen-content">\n\t\t\t<div class="dimina-mini-app__logo">\n\t\t\t\t<div class="dimina-mini-app__logo-img">\n\t\t\t\t\t<img class="dimina-mini-app__logo-img-url" alt="logo" />\n\t\t\t\t</div>\n\t\t\t\t<div class="dimina-mini-app__logo-circle"></div>\n\t\t\t\t<span class="dimina-mini-app__green-point"></span>\n\t\t\t</div>\n\t\t\t<h1 class="dimina-mini-app__name"></h1>\n\t\t</div>\n\t</div>\n\n\t<div class="dimina-mini-app-menu__mask"></div>\n\t<div class="dimina-mini-app-menu">\n\t\t<div class="dimina-mini-app-menu__handle"></div>\n\t\t<div class="dimina-mini-app-menu__app">\n\t\t\t<div class="dimina-mini-app-menu__app-logo">\n\t\t\t\t<img class="dimina-mini-app-menu__app-logo-img" alt="logo" />\n\t\t\t</div>\n\t\t\t<div class="dimina-mini-app-menu__app-meta">\n\t\t\t\t<h2 class="dimina-mini-app-menu__app-name"></h2>\n\t\t\t\t<p class="dimina-mini-app-menu__app-id"></p>\n\t\t\t\t<p class="dimina-mini-app-menu__app-desc"></p>\n\t\t\t</div>\n\t\t</div>\n\t\t<div class="dimina-mini-app-menu__quick-actions"></div>\n\t\t<div class="dimina-mini-app-menu__footer">\n\t\t\t<button type="button" class="dimina-mini-app-menu__footer-btn dimina-mini-app-menu__footer-btn--cancel">取消</button>\n\t\t</div>\n\t</div>\n</div>\n'}updateTargetPageColorStyle(e){const{navigationBarTextStyle:t}=e;this.updateActionColorStyle(t)}showLaunchScreen(){const e=this.el.querySelector(".dimina-mini-app__launch-screen"),t=this.el.querySelector(".dimina-mini-app__name"),i=this.el.querySelector(".dimina-mini-app__logo-img-url");this.updateActionColorStyle("black"),t.innerHTML=this.appInfo.name,i.src=this.appInfo.logo,e.style.display="block"}hideLaunchScreen(){this.el.querySelector(".dimina-mini-app__launch-screen").style.display="none"}updateActionColorStyle(e){this.color=e;const t=this.el.querySelector(".dimina-mini-app-navigation__actions");"white"===e?(t.classList.remove("dimina-mini-app-navigation__actions--black"),t.classList.add("dimina-mini-app-navigation__actions--white")):"black"===e&&(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}})}}async navigateTo(e){const{url:t,success:i,fail:a,complete:s}=e,{query:r,pagePath:l}=n(t),c=this.createCallbackFunction(i),h=this.createCallbackFunction(a),d=this.createCallbackFunction(s);if(this._isTabBarPage(l))return h?.({errMsg:"navigateTo:fail can not navigateTo a tabbar page"}),void d?.();if(!this.webviewAnimaEnd)return;this.webviewAnimaEnd=!1;const p=this.appConfig.modules[l],g=o(this.appConfig.app,p);this.updateTargetPageColorStyle(g);const m=await this.createBridge({pagePath:l,query:r,scene:this.appInfo.scene,jscore:this.jscore,isRoot:!1,root:p?.root||"main",appId:this.appInfo.appId,pages:this.appConfig.app.pages,configInfo:g}),u=this.bridgeList[this.bridgeList.length-1],b=u.webview;this.bridgeList.push(m),m.start(),this._syncHash(),b.el.classList.remove("dimina-native-view--instage"),b.el.classList.add("dimina-native-view--slide-out"),b.el.classList.add("dimina-native-view--linear-anima"),u?.pageHide(),this._setTabBarVisible(!1),m.webview.el.style.zIndex=this.bridgeList.length+1,m.webview.el.classList.add("dimina-native-view--enter-anima"),m.webview.el.classList.add("dimina-native-view--instage"),await R(m.webview.el,"transform"),this.webviewAnimaEnd=!0,b.el.classList.remove("dimina-native-view--linear-anima"),m.webview.el.classList.remove("dimina-native-view--before-enter"),m.webview.el.classList.remove("dimina-native-view--enter-anima"),m.webview.el.classList.remove("dimina-native-view--instage"),c?.({errMsg:"navigateTo:ok"}),d?.()}reLaunch(e){if(!this.webviewAnimaEnd)return;this.webviewAnimaEnd=!1;const{url:t,success:i,fail:a,complete:s}=e,{query:r,pagePath:l}=n(t),c=this.createCallbackFunction(i),h=this.createCallbackFunction(a),d=this.createCallbackFunction(s);try{const e=this.appConfig.modules[l],t=o(this.appConfig.app,e);this.updateTargetPageColorStyle(t);const i=new Set([...this.bridgeList,...this.tabBarBridges.values()]);for(const a of i)a.destroy(),a.webview?.el?.remove();this.bridgeList.length=0,this.tabBarBridges.clear(),this.currentTabPath=null,this.webviewsContainer&&(this.webviewsContainer.innerHTML=""),this.createBridge({pagePath:l,query:r,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(l)){const t=this._normalizePagePath(l);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,c?.({errMsg:"reLaunch:ok"}),d?.()}).catch(e=>{h?.({errMsg:`reLaunch:fail ${e.message}`}),d?.(),this.webviewAnimaEnd=!0})}catch(p){h?.({errMsg:`reLaunch:fail ${p.message}`}),d?.(),this.webviewAnimaEnd=!0}}applyUpdate(){this.reLaunch({url:this.getEntryPagePath()})}redirectTo(e){const{url:t,success:i,fail:a,complete:s}=e,{query:r,pagePath:l}=n(t),c=this.createCallbackFunction(i),h=this.createCallbackFunction(a),d=this.createCallbackFunction(s);if(this._isTabBarPage(l))return h?.({errMsg:"redirectTo:fail can not redirectTo a tabbar page"}),void d?.();if(!this.webviewAnimaEnd)return;this.webviewAnimaEnd=!1;const p=this.bridgeList[this.bridgeList.length-1],g=this._normalizePagePath(p.opts.pagePath),m=this.appConfig.modules[l],u=o(this.appConfig.app,m);this.updateTargetPageColorStyle(u),p.destroy(),p.opts={...p.opts,pagePath:l,query:r,configInfo:u},p.resetStatus(),p.start(),this._syncHash(),this.tabBarBridges.get(g)===p&&(this.tabBarBridges.delete(g),this.currentTabPath===g&&(this.currentTabPath=null)),this._setBridgeTabBarInset(p,!1),this._setTabBarVisible(!1),this.webviewAnimaEnd=!0,c?.({errMsg:"redirectTo:ok"}),d?.()}async navigateBack(){if(this.bridgeList.length<2)return;if(!this.webviewAnimaEnd)return;this.webviewAnimaEnd=!1;const e=this.bridgeList.pop(),t=this.bridgeList[this.bridgeList.length-1],i=this.appConfig.modules[t.opts.pagePath],a=o(this.appConfig.app,i);if(this.updateTargetPageColorStyle(a),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)){const e=this._normalizePagePath(t.opts.pagePath);this.currentTabPath=e,this._setTabBarVisible(!0),this._updateTabBarSelection(e)}await R(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){const{url:t,success:i,fail:a,complete:s}=e,{query:r,pagePath:l}=n(t),c=this._normalizePagePath(l),h=this.createCallbackFunction(i),d=this.createCallbackFunction(a),p=this.createCallbackFunction(s);if(!this._isTabBarPage(c))return d?.({errMsg:`switchTab:fail not a tabBar page: ${c}`}),void p?.();if(!this.webviewAnimaEnd)return d?.({errMsg:"switchTab:fail busy"}),void p?.();if(this.currentTabPath===c&&1===this.bridgeList.length)return this._setTabBarVisible(!0),this._updateTabBarSelection(c),h?.({errMsg:"switchTab:ok"}),void p?.();this.webviewAnimaEnd=!1;try{const e=this.currentTabPath,t=e?this.tabBarBridges.get(e):null,i=!!t&&1===this.bridgeList.length&&this.bridgeList[0]===t;for(;this.bridgeList.length>0;){const 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(c)){i&&t.pageHide(),t.webview?.el&&(t.webview.el.style.display="none");const e=this.bridgeList.indexOf(t);e>=0&&this.bridgeList.splice(e,1)}let a=this.tabBarBridges.get(c);const s=this.appConfig.modules[c],n=o(this.appConfig.app,s);this.updateTargetPageColorStyle(n),a||(a=await this.createBridge({pagePath:c,query:r,scene:this.appInfo.scene,jscore:this.jscore,isRoot:!0,root:s?.root||"main",appId:this.appInfo.appId,pages:this.appConfig.app.pages,configInfo:n}),this.tabBarBridges.set(c,a),a.start());const l=a.webview.el;this._setBridgeTabBarInset(a,!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(a)||this.bridgeList.push(a),this.currentTabPath=c,a.pageShow(),this._setTabBarVisible(!0),this._updateTabBarSelection(c),this._syncHash(),h?.({errMsg:"switchTab:ok"})}catch(g){d?.({errMsg:`switchTab:fail ${g.message}`})}finally{this.webviewAnimaEnd=!0,p?.()}}_initTabBar(){const e=this.appConfig?.app?.tabBar;e&&Array.isArray(e.list)&&0!==e.list.length&&(this.tabBarConfig=e,this.tabBarPaths=e.list.map(e=>this._normalizePagePath(e.pagePath)),this._renderTabBar())}_renderTabBar(){if(this.tabBarEl=this.el.querySelector(".dimina-mini-app__tabbar"),!this.tabBarEl)return;const{color:e,backgroundColor:t,borderStyle:i,list:a}=this.tabBarConfig,s=this._sanitizeCssColor(e)||"#999999",n=this._sanitizeCssColor(t)||"#ffffff",o="white"===i?"#FFFFFF":"#E0E0E0";this.tabBarEl.textContent="";const r=document.createElement("div");r.className="dimina-tabbar",r.style.backgroundColor=n,r.style.borderTop=`0.5px solid ${o}`,a.forEach((e,t)=>{const i=this._normalizePagePath(e.pagePath),a=document.createElement("div");a.className="dimina-tabbar-item",a.dataset.path=i,a.dataset.index=String(t);const n=this._resolveTabBarIcon(e.iconPath);n&&a.appendChild(this._createTabBarIcon(n,"dimina-tabbar-icon-default"));const o=this._resolveTabBarIcon(e.selectedIconPath);o&&a.appendChild(this._createTabBarIcon(o,"dimina-tabbar-icon-selected"));const l=document.createElement("span");l.className="dimina-tabbar-text",l.style.color=s,l.textContent=e.text||"",a.appendChild(l),r.appendChild(a)}),this.tabBarEl.appendChild(r),this.tabBarEl.addEventListener("click",e=>{const t=e.target.closest(".dimina-tabbar-item");if(!t)return;const i=t.dataset.path;i&&i!==this.currentTabPath&&this.switchTab({url:`/${i}`})}),"undefined"!=typeof ResizeObserver&&(this._tabBarResizeObserver?.disconnect(),this._tabBarResizeObserver=new ResizeObserver(()=>this._syncTabBarHeightVar()),this._tabBarResizeObserver.observe(this.tabBarEl))}_createTabBarIcon(e,t){const i=document.createElement("img");return i.className=`dimina-tabbar-icon ${t}`,i.src=e,i.alt="",i.addEventListener("error",()=>{i.style.display="none"}),i}_sanitizeCssColor(e){if(!e||"string"!=typeof e)return"";const t=e.trim();return 0===t.length||t.length>64?"":/[<>"';{}()\\]/.test(t)?/^(?:rgb|rgba|hsl|hsla)\(\s*[\d.,%\s/-]+\)$/i.test(t)?t:"":t}_getTabBarHeight(){if(!this.tabBarEl)return this.tabBarHeight;let e=this.tabBarEl.getBoundingClientRect().height;if(!e&&"none"===this.tabBarEl.style.display){const t=this.tabBarEl.style.display,i=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=i}return e>0&&(this.tabBarHeight=e),this.tabBarHeight}_syncTabBarHeightVar(){const e=this._getTabBarHeight();this.el.style.setProperty("--dimina-tabbar-height",`${e}px`),this._syncTabBarBridgeInsets()}_setBridgeTabBarInset(e,t){const i=e?.webview?.el;i&&(t?i.style.bottom=`${this._getTabBarHeight()}px`:i.style.removeProperty("bottom"))}_syncTabBarBridgeInsets(){for(const 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||"string"!=typeof e)return null;const t=e.trim();if(!t)return null;if(/^(?:data:|blob:|https?:|\/\/)/i.test(t))return t;const i=t.replace(/^\/+/,"").replace(/^\.\//,""),a=`${this.appId}/`;return i.startsWith(a)?this._joinBaseUrl(i):this._joinBaseUrl(this.appId,"main",i)}_setTabBarVisible(e){this.tabBarEl&&(this.tabBarEl.style.display=e?"block":"none",this._syncTabBarHeightVar())}_updateTabBarSelection(e){if(!this.tabBarEl||!this.tabBarConfig)return;const t=this.tabBarConfig.color||"#999999",i=this.tabBarConfig.selectedColor||"#1890ff";this.tabBarEl.querySelectorAll(".dimina-tabbar-item").forEach(a=>{const s=a.getAttribute("data-path")===e,n=a.querySelector(".dimina-tabbar-text"),o=a.querySelector(".dimina-tabbar-icon-default"),r=a.querySelector(".dimina-tabbar-icon-selected");n&&(n.style.color=s?i:t),o&&(o.style.display=s?"none":"block"),r&&(r.style.display=s?"block":"none"),a.classList.toggle("dimina-tabbar-item--selected",s)})}setTabBarStyle(e={}){const{color:t,selectedColor:i,backgroundColor:a,borderStyle:s,success:n,fail:o,complete:r}=e,l=this.createCallbackFunction(n),c=this.createCallbackFunction(o),h=this.createCallbackFunction(r);if(!this.tabBarConfig||!this.tabBarEl)return c?.({errMsg:"setTabBarStyle:fail tabBar not configured"}),void h?.();const d="black"===s||"white"===s?s:null,p=void 0!==t?this._sanitizeCssColor(t):null,g=void 0!==i?this._sanitizeCssColor(i):null,m=void 0!==a?this._sanitizeCssColor(a):null;p&&(this.tabBarConfig.color=p),g&&(this.tabBarConfig.selectedColor=g),m&&(this.tabBarConfig.backgroundColor=m),d&&(this.tabBarConfig.borderStyle=d);const u=this.tabBarEl.querySelector(".dimina-tabbar");if(u&&(m&&(u.style.backgroundColor=m),d)){const e="white"===d?"#FFFFFF":"#E0E0E0";u.style.borderTop=`0.5px solid ${e}`}this._updateTabBarSelection(this.currentTabPath),l?.({errMsg:"setTabBarStyle:ok"}),h?.()}navigateToMiniProgram(e){const{appId:t,path:i}=e;r.openApp({appId:t,path:i,scene:1037},this.parent)}bindMoreEvent(){const e=this.el.querySelector(".dimina-mini-app-navigation__actions-variable"),t=this.el.querySelector(".dimina-mini-app-menu__mask"),i=this.el.querySelector(".dimina-mini-app-menu"),a=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(),a.onclick=()=>this.closeMiniAppMenu(),i.onclick=e=>e.stopPropagation()}bindCloseEvent(){this.el.querySelector(".dimina-mini-app-navigation__actions-close").onclick=()=>{this.closeMiniProgram()}}destroy(){this._destroyed=!0;for(const e of this._extSubscriptions.values())e?.();this._extSubscriptions.clear(),this._tabBarResizeObserver?.disconnect(),this._tabBarResizeObserver=null;for(const e of this._modalPendingTimers)clearTimeout(e);this._modalPendingTimers.clear();for(const e of this._modalStack)e.mask?.remove(),e.dialog?.remove();this._modalStack.length=0,this.hideToast({}),r.popView(),this.jscore.destroy()}getNetworkType(e){const{success:t}=e;this.createCallbackFunction(t)?.({networkType:"wifi"})}request({url:e,data:t,header:i={},timeout:a=0,method:s="GET",dataType:n="json",responseType:o="text",success:r,fail:l,complete:c}){const h={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:e,data:t,header:i,timeout:a,method:s,dataType:n,responseType:o})},d=this.createCallbackFunction(r),p=this.createCallbackFunction(l),g=this.createCallbackFunction(c);fetch("http://localhost:7788/proxy",h).then(e=>{if(!e.ok){const t=new Error(e.statusText);throw t.code=e.status,t}const t={};switch(e.headers.forEach((e,i)=>{t[i]=e}),n){case"json":return e.json().then(i=>({data:JSON.parse(i),header:t,statusCode:e.status}));case"arraybuffer":return e.arrayBuffer().then(i=>({data:i,header:t,statusCode:e.status}));default:return e.text().then(i=>({data:i,header:t,statusCode:e.status}))}}).then(e=>{d?.(e)}).catch(e=>{p?.({errMsg:e.message,errno:e.code})}).finally(()=>{g?.()})}getSystemInfoAsync(e){const t=this.parent.parent.root.querySelector(".iphone__status-bar").getBoundingClientRect(),i=this.parent.el.querySelector(".dimina-native-webview__root").getBoundingClientRect(),{success:a,complete:s}=e,n=this.createCallbackFunction(a),o=this.createCallbackFunction(s);n?.({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:i.width,height:i.height,top:i.top,bottom:i.bottom,left:i.left,right:i.right}}),o?.()}getMenuButtonBoundingClientRect(){const e=this.el.querySelector(".dimina-mini-app-navigation__actions").getBoundingClientRect(),t=(this.parent.parent.root.querySelector(".iphone__status-bar")?.getBoundingClientRect().height||20)+4,i=t+e.height;return{top:t,right:e.right,bottom:i,left:e.left,width:e.width,height:e.height,x:e.x,y:t}}getHostEnvSnapshot(){return{menuRect:this.getMenuButtonBoundingClientRect(),systemInfo:this.getSystemInfoSync()}}getSystemInfoSync(){const e=this.parent.parent.root.querySelector(".iphone__status-bar"),t=this.parent.el.querySelector(".dimina-native-webview__root")?.getBoundingClientRect(),i=t?.width||this.el.clientWidth||375,a=t?.height||this.el.clientHeight||667,s=e?.getBoundingClientRect().height||20;return{brand:"devtools",model:"web",platform:"devtools",system:"web",SDKVersion:"3.0.0",pixelRatio:globalThis.devicePixelRatio||1,screenWidth:i,screenHeight:a,windowWidth:i,windowHeight:a,statusBarHeight:s,safeArea:{left:0,right:i,top:s,bottom:a,width:i,height:Math.max(a-s,0)}}}showToast(e={}){const{title:t="",duration:i=1500,icon:a="success",mask:s=!1,success:n,complete:o}=e;if(!t)return;this.hideToast({});const r=this.createCallbackFunction(n),l=this.createCallbackFunction(o);let c=null;s&&(c=document.createElement("div"),c.className="dimina-toast-mask",this.el.appendChild(c));const h=document.createElement("div");h.className=`dimina-toast dimina-toast--${a}`,"none"===a&&h.classList.add("dimina-toast--text-only");const d=document.createElement("p");d.textContent=String(t),h.appendChild(d),this.el.appendChild(h),this.toastInfo.dom=h,this.toastInfo.maskEl=c,this.toastInfo.timer=setTimeout(()=>{h.remove(),c?.remove(),this.toastInfo.dom===h&&(this.toastInfo.dom=null,this.toastInfo.maskEl=null,this.toastInfo.timer=null)},i),r?.(),l?.()}hideToast(e={}){const{success:t,complete:i}=e,a=this.createCallbackFunction(t),s=this.createCallbackFunction(i);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),a?.(),s?.()}showLoading(e={}){this.showToast({...e,icon:"loading"})}hideLoading(e={}){this.hideToast(e)}showModal(e){if(this._destroyed)return;const t=this._mountModal(e||{});this._modalStack.push(t),this._updateModalView(),t.mask.classList.add("show");const i=setTimeout(()=>{this._modalPendingTimers.delete(i),this._destroyed||this._modalStack.includes(t)&&t.dialog.classList.add("show")},100);this._modalPendingTimers.add(i)}_updateModalView(){const e=this._modalStack.length-1;for(let t=0;t<this._modalStack.length;t++){const i=this._modalStack[t];t===e?(i.mask.classList.remove("dimina-modal--occluded"),i.dialog.classList.remove("dimina-modal--occluded")):(i.mask.classList.add("dimina-modal--occluded"),i.dialog.classList.add("dimina-modal--occluded"))}}_mountModal(e){const{title:t="",content:i="",showCancel:a=!0,cancelText:s="取消",cancelColor:n="#000",confirmText:o="确定",confirmColor:r="#576b95",success:l,complete:c}=e,h=this.createCallbackFunction(l),d=this.createCallbackFunction(c),p=document.createElement("div");p.className="dimina-dialog-mask";const g=document.createElement("div");g.className="dimina-dialog";const m=this._modalStack.length;if(p.style.zIndex=String(1100+20*m),g.style.zIndex=String(1110+20*m),t){const e=document.createElement("h2");e.className="dimina-dialog__title",e.textContent=String(t),g.appendChild(e)}if(i){const e=document.createElement("p");e.className="dimina-dialog__content",e.textContent=String(i),g.appendChild(e)}const u=document.createElement("div");u.className="dimina-dialog__buttons";let b=!1;const v={mask:p,dialog:g,close:null},w=e=>{if(b)return;b=!0;const t=this._modalStack.indexOf(v);t>=0&&this._modalStack.splice(t,1),0===this._modalStack.length?(p.classList.remove("show"),g.classList.remove("show"),setTimeout(()=>{p.remove(),g.remove()},200)):(p.remove(),g.remove()),this._updateModalView(),h?.(e),d?.()};if(v.close=w,a){const e=document.createElement("button");e.type="button",e.className="dimina-dialog__button",e.style.color=n,e.textContent=String(s),e.addEventListener("click",()=>{w({cancel:!0,confirm:!1,errMsg:"showModal:ok"})}),u.appendChild(e)}const f=document.createElement("button");return f.type="button",f.className="dimina-dialog__button",f.style.color=r,f.textContent=String(o),f.addEventListener("click",()=>{w({cancel:!1,confirm:!0,errMsg:"showModal:ok"})}),u.appendChild(f),g.appendChild(u),this.el.appendChild(p),this.el.appendChild(g),v}showActionSheet(e){const{itemList:t=[],itemColor:i="#000",success:a,fail:s,complete:n}=e||{};if(!Array.isArray(t)||0===t.length)return s&&this.createCallbackFunction(s)({errMsg:"showActionSheet:fail"}),void(n&&this.createCallbackFunction(n)());const o=document.createElement("div");o.className="dimina-action-sheet-mask";const r=document.createElement("div");r.className="dimina-action-sheet";const l=()=>{o.remove(),r.remove()};t.forEach((e,t)=>{const s=document.createElement("div");s.className="dimina-action-sheet-item",s.style.color=i,s.textContent=e,s.onclick=()=>{l(),a&&this.createCallbackFunction(a)({tapIndex:t}),n&&this.createCallbackFunction(n)()},r.appendChild(s)});const c=document.createElement("div");c.className="dimina-action-sheet-cancel",c.textContent="取消",c.onclick=()=>{l(),s&&this.createCallbackFunction(s)({errMsg:"showActionSheet:fail cancel"}),n&&this.createCallbackFunction(n)()},r.appendChild(c),o.onclick=l,this.el.appendChild(o),this.el.appendChild(r),requestAnimationFrame(()=>requestAnimationFrame(()=>{r.classList.add("show"),o.classList.add("show")}))}setNavigationBarTitle(e){const{title:t,success:i,fail:a,complete:s}=e,n=this.createCallbackFunction(i),o=this.createCallbackFunction(a),r=this.createCallbackFunction(s);try{const e=this.bridgeList[this.bridgeList.length-1].webview.el.querySelector(".dimina-native-webview__navigation-title");e?(e.textContent=t||"",n?.({errMsg:"setNavigationBarTitle:ok"})):o?.({errMsg:"setNavigationBarTitle:fail Navigation title element not found"})}catch(l){o?.({errMsg:`setNavigationBarTitle:fail ${l.message}`})}finally{r?.()}}setNavigationBarColor(e){const{frontColor:t,backgroundColor:i,success:a,fail:s,complete:n}=e,o=this.createCallbackFunction(a),r=this.createCallbackFunction(s),l=this.createCallbackFunction(n);try{const 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),i&&(e.style.backgroundColor=i),o?.({errMsg:"setNavigationBarColor:ok"})):r?.({errMsg:"setNavigationBarColor:fail Navigation element not found"})}catch(c){r?.({errMsg:`setNavigationBarColor:fail ${c.message}`})}finally{l?.()}}pageScrollTo(e){const{scrollTop:t,duration:i=300,success:a,fail:s,complete:n}=e,o=this.createCallbackFunction(a),r=this.createCallbackFunction(s),l=this.createCallbackFunction(n);try{const e=this.bridgeList[this.bridgeList.length-1].webview.iframe.contentWindow.document.documentElement;e?(e.scrollTo({top:t,behavior:i>0?"smooth":"auto"}),setTimeout(()=>{o?.({errMsg:"pageScrollTo:ok"}),l?.()},i)):(r?.({errMsg:"pageScrollTo:fail Webview root element not found"}),l?.())}catch(c){r?.({errMsg:`pageScrollTo:fail ${c.message}`}),l?.()}}setClipboardData(e){const{data:t,success:i,fail:a,complete:s}=e,n=this.createCallbackFunction(i),o=this.createCallbackFunction(a),r=this.createCallbackFunction(s);try{navigator.clipboard.writeText(t).then(()=>{n?.({errMsg:"setClipboardData:ok"}),r?.()}).catch(e=>{o?.({errMsg:`setClipboardData:fail ${e.message}`}),r?.()})}catch(l){o?.({errMsg:`setClipboardData:fail ${l.message}`}),r?.()}}getClipboardData(e){const{success:t,fail:i,complete:a}=e,s=this.createCallbackFunction(t),n=this.createCallbackFunction(i),o=this.createCallbackFunction(a);try{navigator.clipboard.readText().then(e=>{s?.({data:e,errMsg:"getClipboardData:ok"}),o?.()}).catch(e=>{n?.({errMsg:`getClipboardData:fail ${e.message}`}),o?.()})}catch(r){n?.({errMsg:`getClipboardData:fail ${r.message}`}),o?.()}}setStorage(e){const{key:t,data:i,success:a,fail:s,complete:n}=e,o=this.createCallbackFunction(a),r=this.createCallbackFunction(s),l=this.createCallbackFunction(n);try{const e=`${this.appId}_${t}`,a="object"==typeof i?JSON.stringify(i):String(i);localStorage.setItem(e,a),o?.({errMsg:"setStorage:ok"})}catch(c){r?.({errMsg:`setStorage:fail ${c.message}`})}finally{l?.()}}getStorage(e){const{key:t,success:i,fail:a,complete:s}=e,n=this.createCallbackFunction(i),o=this.createCallbackFunction(a),r=this.createCallbackFunction(s);try{const e=`${this.appId}_${t}`,i=localStorage.getItem(e);if(null!==i){let e=i;try{e=JSON.parse(i)}catch{}n?.({data:e,errMsg:"getStorage:ok"})}else o?.({errMsg:"getStorage:fail data not found"})}catch(l){o?.({errMsg:`getStorage:fail ${l.message}`})}finally{r?.()}}removeStorage(e){const{key:t,success:i,fail:a,complete:s}=e,n=this.createCallbackFunction(i),o=this.createCallbackFunction(a),r=this.createCallbackFunction(s);try{const e=`${this.appId}_${t}`;null!==localStorage.getItem(e)?(localStorage.removeItem(e),n?.({errMsg:"removeStorage:ok"})):n?.({errMsg:"removeStorage:ok"})}catch(l){o?.({errMsg:`removeStorage:fail ${l.message}`})}finally{r?.()}}clearStorage(e){const{success:t,fail:i,complete:a}=e||{},s=this.createCallbackFunction(t),n=this.createCallbackFunction(i),o=this.createCallbackFunction(a);try{const e=`${this.appId}_`,t=[];for(let i=0;i<localStorage.length;i++){const a=localStorage.key(i);a.startsWith(e)&&t.push(a)}t.forEach(e=>localStorage.removeItem(e)),s?.({errMsg:"clearStorage:ok"})}catch(r){n?.({errMsg:`clearStorage:fail ${r.message}`})}finally{o?.()}}getStorageInfo(e){const{success:t,fail:i,complete:a}=e||{},s=this.createCallbackFunction(t),n=this.createCallbackFunction(i),o=this.createCallbackFunction(a);try{const e=[];let t=0;const i=10485760,a=`${this.appId}_`;for(let s=0;s<localStorage.length;s++){const i=localStorage.key(s);if(i.startsWith(a)){const s=i.substring(a.length);e.push(s);const n=localStorage.getItem(i);t+=n?2*n.length:0}}s?.({keys:e,currentSize:t,limitSize:i,errMsg:"getStorageInfo:ok"})}catch(r){n?.({errMsg:`getStorageInfo:fail ${r.message}`})}finally{o?.()}}_parseExtEventKey(e){const t=r.getExtModules();for(const i of Object.keys(t)){const t=`${i}_`;if(e.startsWith(t))return{module:i,event:e.slice(t.length)}}return{module:null,event:null}}_handleExtCall(e,t={}){void 0!==t.module?this._extBridgeCall(e,t):t.success?this._extOnBridgeCall(e,t):this._extOffBridgeCall(e)}_extBridgeCall(e,t){const{module:i,data:a={},success:s,fail:n,complete:o}=t,l=this.createCallbackFunction(s),c=this.createCallbackFunction(n),h=this.createCallbackFunction(o),d=r.getExtModule(i);if(!d){const e=`extBridge:fail module "${i}" not registered`;return c?.({errMsg:e}),void h?.()}try{d({event:e,data:a,success:e=>{l?.(e),h?.()},fail:e=>{c?.(e),h?.()}})}catch(p){c?.({errMsg:`extBridge:fail ${p.message}`}),h?.()}}_extOnBridgeCall(e,t){const{success:i}=t,a=this.createCallbackFunction(i),{module:s,event:n}=this._parseExtEventKey(e);if(!s)return;const o=r.getExtModule(s);this._extSubscriptions.get(e)?.();try{const t=o({event:n,data:{isSustain:!0},success:e=>a?.(e),fail:()=>{}});this._extSubscriptions.set(e,t??null)}catch(l){}}_extOffBridgeCall(e){const t=this._extSubscriptions.get(e);t&&(t(),this._extSubscriptions.delete(e))}};export{i as Application,$ as MiniApp};
1
+ var e=()=>new Promise(e=>requestAnimationFrame(()=>requestAnimationFrame(e))),t=(e,t,i=560)=>new Promise(a=>{const s=setTimeout(a,i),n=i=>{t&&i.propertyName!==t||(clearTimeout(s),e.removeEventListener("transitionend",n),a())};e.addEventListener("transitionend",n)}),i=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(i){if(!this.done)return;this.done=!1;const a=this.views[this.views.length-1];i.parent=this,this.views.push(i),i.el.style.zIndex=this.views.length,i.el.classList.add("dimina-native-view--before-enter"),this.window.appendChild(i.el),i?.viewDidLoad(),await e(),a.el.classList.remove("dimina-native-view--instage"),a.el.classList.add("dimina-native-view--slide-out"),a.el.classList.add("dimina-native-view--linear-anima"),i.el.classList.add("dimina-native-view--enter-anima"),i.el.classList.add("dimina-native-view--instage"),await t(i.el,"transform"),a.el.classList.remove("dimina-native-view--linear-anima"),i.el.classList.remove("dimina-native-view--before-enter"),i.el.classList.remove("dimina-native-view--enter-anima"),i.el.classList.remove("dimina-native-view--instage"),this.done=!0}async popView(){if(this.views.length<2)return;if(!this.done)return;this.done=!1;const e=this.views[this.views.length-2],i=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"),i.el.classList.remove("dimina-native-view--instage"),i.el.classList.add("dimina-native-view--before-enter"),i.el.classList.add("dimina-native-view--enter-anima"),await t(i.el,"transform"),this.views.pop(),this.window.removeChild(i.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(i,a){if(!this.done)return;this.done=!1;const s=this.views[this.views.length-1];i.parent=this,i.el.style.zIndex=this.views.length+1,i.el.classList.add("dimina-native-view--before-present"),i.el.classList.add("dimina-native-view--enter-anima"),s?.el.classList.add("dimina-native-view--before-presenting"),s?.el.classList.remove("dimina-native-view--instage"),s?.el.classList.add("dimina-native-view--enter-anima"),s?.onPresentOut(),i.onPresentIn(),!a&&this.el.appendChild(i.el),this.views.push(i),!a&&i.viewDidLoad&&i.viewDidLoad(),a&&i.restoreColorStyle(),await e(),s?.el.classList.add("dimina-native-view--presenting"),i.el.classList.add("dimina-native-view--instage"),await t(i.el,"transform"),i.el.classList.remove("dimina-native-view--before-present"),i.el.classList.remove("dimina-native-view--enter-anima"),s?.el.classList.remove("dimina-native-view--enter-anima"),s?.el.classList.remove("dimina-native-view--before-presenting"),this.done=!0}dismissView(e={}){return this._enqueue(()=>this._dismissView(e))}async _dismissView(i={}){if(!this.done)return;this.done=!1;const a=this.views[this.views.length-2],s=this.views[this.views.length-1],{destroy:n=!0}=i;s.el.classList.add("dimina-native-view--enter-anima"),a?.el.classList.add("dimina-native-view--enter-anima"),a?.el.classList.add("dimina-native-view--before-presenting"),await e(),s.el.classList.add("dimina-native-view--before-present"),s.el.classList.remove("dimina-native-view--instage"),a?.el.classList.remove("dimina-native-view--presenting"),a?.onPresentIn(),s?.onPresentOut(),await t(s.el,"transform"),n&&(s.destroy(),this.el.removeChild(s.el)),this.views.pop(),a?.el.classList.remove("dimina-native-view--enter-anima"),a?.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;const e=this.getActiveView();e?.restoreColorStyle?.(),e?.onPresentIn?.()}updateStatusBarColor(e){this.parent?.updateDeviceBarColor(e)}};var a=function(e){const t=/* @__PURE__ */new Map;return function(...i){const a=1===i.length?i[0]:JSON.stringify(i);if(t.has(a))return t.get(a);const s=e.apply(this,i);return t.set(a,s),s}}(async()=>{const e=await fetch("/appList.json").then(e=>e.json());return e.forEach(e=>{const t=JSON.stringify(e),i=sessionStorage.getItem(t);if(i)e.logo=i;else{const i=function(e){const t=[60,60],i=window.devicePixelRatio||1,a=document.createElement("canvas");a.style.width=t[0]+"px",a.style.height=t[1]+"px",a.width=t[0]*i,a.height=t[1]*i;const s=a.getContext("2d");s.scale(i,i),s.imageSmoothingEnabled=!0,s.imageSmoothingQuality="high",s.textRenderingOptimization="optimizeQuality",s.fillStyle=function(e){if(!e||0===e.length)return"#2196F3";let t=0;for(let o=0;o<e.length;o++)t=(t<<5)-t+e.charCodeAt(o),t|=0;const i=function(e,t,i){let a,s,n;const o=Math.floor(e/60),r=e/60-o,l=i*(1-t),c=i*(1-r*t),h=i*(1-(1-r)*t);switch(o%6){case 0:a=i,s=h,n=l;break;case 1:a=c,s=i,n=l;break;case 2:a=l,s=i,n=h;break;case 3:a=l,s=c,n=i;break;case 4:a=h,s=l,n=i;break;case 5:a=i,s=l,n=c}return[Math.round(255*a),Math.round(255*s),Math.round(255*n)]}(Math.abs(t%360),.7+Math.abs(t%3e3)/1e4,.8+Math.abs(t%2e3)/1e4);return a=i[0],s=i[1],n=i[2],`#${((1<<24)+(a<<16)+(s<<8)+n).toString(16).slice(1)}`;var a,s,n}(e.name),s.fillRect(0,0,t[0],t[1]),s.fillStyle="rgb(255,255,255)",s.font=.6*t[0]+"px Arial";const n=e.name.charAt(0),o=s.measureText(n),r=t[0]/2,l=t[1]/2+(o.actualBoundingBoxAscent-o.actualBoundingBoxDescent)/2;return s.textAlign="center",s.fillText(n,r,l),a.toDataURL("image/png",1)}(e);sessionStorage.setItem(t,i),e.logo=i}}),e});function s(){return Math.random().toString(36).slice(2,7)}function n(e){const t=e.split("?"),i=t[0],a=t[1],s={query:{},pagePath:i};return a?(a.split("&").forEach(e=>{const t=e.split("=")[0],i=e.split("=")[1];s.query[t]=i}),s):s}function o(e,t){const i={},a=e.window||{},s=t||{};return i.navigationBarTitleText=s.navigationBarTitleText||a.navigationBarTitleText||"",i.navigationBarBackgroundColor=s.navigationBarBackgroundColor||a.navigationBarBackgroundColor||"#000",i.navigationBarTextStyle=s.navigationBarTextStyle||a.navigationBarTextStyle||"white",i.backgroundColor=s.backgroundColor||a.backgroundColor||"#fff",i.navigationStyle=s.navigationStyle||a.navigationStyle||"default",i.usingComponents=s.usingComponents||{},i}var r=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){const{appId:i,path:s,scene:o,destroy:r,restoreStack:l}=e,{pagePath:c,query:h}=n(s),{name:d,logo:p}=await async function(e){const t=await a();for(const i of t)if(i.appId===e)return i}(i);if(r)for(const a of this.appStack)a.appId!==i&&(a.bridgeList.pop()?.destroy(),t.destroyRootView(a));const g=this.getAppById(i);if(g)t.presentView(g,!0);else{const e=new $({appId:i,scene:o,name:d,logo:p,pagePath:c,query:h,restoreStack:l});this.appStack.push(e),t.presentView(e,!1)}}static getAppById(e){for(const 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})}},l=(e=0)=>t=>`[${t+e}m`,c=(e=0)=>t=>`[${38+e};5;${t}m`,h=(e=0)=>(t,i,a)=>`[${38+e};2;${t};${i};${a}m`,d={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(d.modifier),Object.keys(d.color),Object.keys(d.bgColor);var p=function(){const e=/* @__PURE__ */new Map;for(const[t,i]of Object.entries(d)){for(const[t,a]of Object.entries(i))d[t]={open:`[${a[0]}m`,close:`[${a[1]}m`},i[t]=d[t],e.set(a[0],a[1]);Object.defineProperty(d,t,{value:i,enumerable:!1})}return Object.defineProperty(d,"codes",{value:e,enumerable:!1}),d.color.close="",d.bgColor.close="",d.color.ansi=l(),d.color.ansi256=c(),d.color.ansi16m=h(),d.bgColor.ansi=l(10),d.bgColor.ansi256=c(10),d.bgColor.ansi16m=h(10),Object.defineProperties(d,{rgbToAnsi256:{value:(e,t,i)=>e===t&&t===i?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(i/255*5),enumerable:!1},hexToRgb:{value(e){const t=/[a-f\d]{6}|[a-f\d]{3}/i.exec(e.toString(16));if(!t)return[0,0,0];let[i]=t;3===i.length&&(i=[...i].map(e=>e+e).join(""));const a=Number.parseInt(i,16);return[a>>16&255,a>>8&255,255&a]},enumerable:!1},hexToAnsi256:{value:e=>d.rgbToAnsi256(...d.hexToRgb(e)),enumerable:!1},ansi256ToAnsi:{value(e){if(e<8)return 30+e;if(e<16)return e-8+90;let t,i,a;if(e>=232)t=(10*(e-232)+8)/255,i=t,a=t;else{const s=(e-=16)%36;t=Math.floor(e/36)/5,i=Math.floor(s/6)/5,a=s%6/5}const s=2*Math.max(t,i,a);if(0===s)return 30;let n=30+(Math.round(a)<<2|Math.round(i)<<1|Math.round(t));return 2===s&&(n+=60),n},enumerable:!1},rgbToAnsi:{value:(e,t,i)=>d.ansi256ToAnsi(d.rgbToAnsi256(e,t,i)),enumerable:!1},hexToAnsi:{value:e=>d.ansi256ToAnsi(d.hexToAnsi256(e)),enumerable:!1}}),d}(),g=(()=>{if(!("navigator"in globalThis))return 0;if(globalThis.navigator.userAgentData){const e=navigator.userAgentData.brands.find(({brand:e})=>"Chromium"===e);if(e&&e.version>93)return 3}return/\b(Chrome|Chromium)\//.test(globalThis.navigator.userAgent)?1:0})(),m=0!==g&&{level:g,hasBasic:!0,has256:g>=2,has16m:g>=3},u={stdout:m,stderr:m};function b(e,t,i){let a=e.indexOf(t);if(-1===a)return e;const s=t.length;let n=0,o="";do{o+=e.slice(n,a)+t+i,n=a+s,a=e.indexOf(t,n)}while(-1!==a);return o+=e.slice(n),o}var{stdout:v,stderr:w}=u,f=Symbol("GENERATOR"),y=Symbol("STYLER"),_=Symbol("IS_EMPTY"),C=["ansi","ansi","ansi256","ansi16m"],S=Object.create(null),k=e=>{const t=(...e)=>e.join(" ");return((e,t={})=>{if(t.level&&!(Number.isInteger(t.level)&&t.level>=0&&t.level<=3))throw new Error("The `level` option should be an integer from 0 to 3");const i=v?v.level:0;e.level=void 0===t.level?i:t.level})(t,e),Object.setPrototypeOf(t,B.prototype),t};function B(e){return k(e)}Object.setPrototypeOf(B.prototype,Function.prototype);for(const[j,O]of Object.entries(p))S[j]={get(){const e=I(this,P(O.open,O.close,this[y]),this[_]);return Object.defineProperty(this,j,{value:e}),e}};S.visible={get(){const e=I(this,this[y],!0);return Object.defineProperty(this,"visible",{value:e}),e}};var L=(e,t,i,...a)=>"rgb"===e?"ansi16m"===t?p[i].ansi16m(...a):"ansi256"===t?p[i].ansi256(p.rgbToAnsi256(...a)):p[i].ansi(p.rgbToAnsi(...a)):"hex"===e?L("rgb",t,i,...p.hexToRgb(...a)):p[i][e](...a);for(const j of["rgb","hex","ansi256"]){S[j]={get(){const{level:e}=this;return function(...t){const i=P(L(j,C[e],"color",...t),p.color.close,this[y]);return I(this,i,this[_])}}};S["bg"+j[0].toUpperCase()+j.slice(1)]={get(){const{level:e}=this;return function(...t){const i=P(L(j,C[e],"bgColor",...t),p.bgColor.close,this[y]);return I(this,i,this[_])}}}}var T=Object.defineProperties(()=>{},{...S,level:{enumerable:!0,get(){return this[f].level},set(e){this[f].level=e}}}),P=(e,t,i)=>{let a,s;return void 0===i?(a=e,s=t):(a=i.openAll+e,s=t+i.closeAll),{open:e,close:t,openAll:a,closeAll:s,parent:i}},I=(e,t,i)=>{const a=(...e)=>M(a,1===e.length?""+e[0]:e.join(" "));return Object.setPrototypeOf(a,T),a[f]=e,a[y]=t,a[_]=i,a},M=(e,t)=>{if(e.level<=0||!t)return e[_]?"":t;let i=e[y];if(void 0===i)return t;const{openAll:a,closeAll:s}=i;if(t.includes(""))for(;void 0!==i;)t=b(t,i.close,i.open),i=i.parent;const n=t.indexOf("\n");return-1!==n&&(t=function(e,t,i,a){let s=0,n="";do{const o="\r"===e[a-1];n+=e.slice(s,o?a-1:a)+t+(o?"\r\n":"\n")+i,s=a+1,a=e.indexOf("\n",s)}while(-1!==a);return n+=e.slice(s),n}(t,s,a,n)),a+t+s};Object.defineProperties(B.prototype,S);B(),B({level:w?w.level:0});function x(e){return{all:e=e||/* @__PURE__ */new Map,on:function(t,i){var a=e.get(t);a?a.push(i):e.set(t,[i])},off:function(t,i){var a=e.get(t);a&&(i?a.splice(a.indexOf(i)>>>0,1):e.set(t,[]))},emit:function(t,i){var a=e.get(t);a&&a.slice().map(function(e){e(i)}),(a=e.get("*"))&&a.slice().map(function(e){e(t,i)})}}}var E=class{constructor(e){this.opts=e,this.id=`webview_${s()}`,this.el=document.createElement("div"),this.el.classList.add("dimina-native-view"),this.el.innerHTML='<div class="dimina-native-webview">\n\t\x3c!-- 导航区域 --\x3e\n\t<div class="dimina-native-webview__navigation">\n\t\t<div class="dimina-native-webview__navigation-content">\n\t\t\t<div class="dimina-native-webview__navigation-left-btn"></div>\n\t\t\t<h2 class="dimina-native-webview__navigation-title"></h2>\n\t\t</div>\n\t</div>\n\n\t\x3c!-- iframe --\x3e\n\t<div class="dimina-native-webview__body">\n\t\t<div class="dimina-native-webview__root">\n\t\t\t<iframe class="dimina-native-webview__window" title="pageFrame"></iframe>\n\t\t</div>\n\t</div>\n</div>',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=x(),this.bindBackEvent()}async init(e){await this.frameLoaded();const 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(){this.el.querySelector(".dimina-native-webview__navigation-left-btn").onclick=()=>{this.parent.parent.navigateBack()}}frameLoaded(){return new Promise(e=>{this.iframe.onload=()=>{e()}})}setInitialStyle(){const e=this.opts.configInfo,t=this.el.querySelector(".dimina-native-webview"),i=this.el.querySelector(".dimina-native-webview__navigation-title"),a=this.el.querySelector(".dimina-native-webview__navigation"),s=this.el.querySelector(".dimina-native-webview__navigation-left-btn"),n=this.el.querySelector(".dimina-native-webview__root");this.opts.isRoot?s.style.display="none":s.style.display="block","white"===e.navigationBarTextStyle?a.classList.add("dimina-native-webview__navigation--white"):a.classList.add("dimina-native-webview__navigation--black"),"custom"===e.navigationStyle&&t.classList.add("dimina-native-webview--custom-nav"),n.style.backgroundColor=e.backgroundColor,a.style.backgroundColor=e.navigationBarBackgroundColor,i.textContent=e.navigationBarTitleText}},A=class{constructor(e){this.id=`bridge_${s()}`,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){"string"==typeof e&&(e=JSON.parse(e));const{body:t,target:i}=e;t.bridgeId&&t.bridgeId!==this.id||("service"===i?this.jscore.postMessage(e):"render"===i&&this.webview.postMessage(e))}messageInvoke(e,t){"string"==typeof t&&(t=JSON.parse(t));const{type:i,body:a,target:s}=t;if(a.bridgeId&&a.bridgeId!==this.id)return;const n={type:i,body:{bridgeId:this.id,pagePath:this.opts.pagePath,scene:this.opts.scene,query:this.opts.query,...a}};if("service"===s){if("serviceResourceLoaded"===i){if(this.serviceResource=!0,!this.isResourceLoaded())return;n.type="resourceLoaded"}else if("renderResourceLoaded"===i){if(this.renderResource=!0,!this.isResourceLoaded())return;n.type="resourceLoaded"}this.jscore.postMessage(n)}else if("container"===s&&"invokeAPI"===i){const{name:e,params:t}=a;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=>{const t=new E({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}})}},q=class{constructor(e){this.parent=e,this.worker=null,this.event=x()}async init(){const e=this.parent.getApiNamespaces?.()||[],t=JSON.stringify({apiNamespaces:e});this.worker=new Worker("/assets/service.js",{type:"classic",name:t}),this.worker.onmessage=e=>{const 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()}},R=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){const t=e.indexOf("?");if(-1===t)return{pagePath:e,query:{}};const i=e.slice(0,t),a={};return new URLSearchParams(e.slice(t+1)).forEach((e,t)=>{a[t]=e}),{pagePath:i,query:a}}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,i=("undefined"!=typeof window?window.location.search:"")){const a=new URLSearchParams(this._normalizeSearch(i));if(this.ROUTE_QUERY_KEYS.forEach(e=>a.delete(e)),!e||!t?.length)return this._stringifySearchParams(a);const s=t[0],n=t[t.length-1];return a.set("appId",e),a.set("entry",this._encodePage(s.pagePath,s.query||{})),a.set("page",this._encodePage(n.pagePath,n.query||{})),this._stringifySearchParams(a)}static buildRouteURL(e,t,i=("undefined"!=typeof window?`${window.location.origin}${window.location.pathname}`:"")){const a=this.buildRouteSearch(e,t);return`${i}${a?`?${a}`:""}`}static syncStack(e,t){const i=this.buildRouteSearch(e,t);history.replaceState(null,"",`${window.location.pathname}${i?`?${i}`:""}`)}static clear(){const e=new URLSearchParams(this._normalizeSearch(window.location.search));this.ROUTE_QUERY_KEYS.forEach(t=>e.delete(t));const t=this._stringifySearchParams(e);history.replaceState(null,"",`${window.location.pathname}${t?`?${t}`:""}`)}static parseSearch(e){const t=new URLSearchParams(this._normalizeSearch(e)),i=t.get("appId"),a=t.get("entry"),s=t.get("page")||a;if(!i||!a)return null;const n=this._decodePage(a);if(!n.pagePath)return null;const o=[n];if(s&&s!==a){const e=this._decodePage(s);e.pagePath&&o.push(e)}return{appId:i,stack:o}}static parseHash(e){if(!e||e.length<=1)return null;const t=e.slice(1).split("|");if(t.length<2)return null;const i=t[0],a=t.slice(1).map(e=>this._decodePage(e));return i&&0!==a.length?{appId:i,stack:a}:null}static parse(e,t=("undefined"!=typeof window?window.location.search:"")){return this.parseSearch(t)||this.parseHash(e)}},F=(e,t,i=560)=>new Promise(a=>{const s=setTimeout(a,i),n=i=>{t&&i.propertyName!==t||(clearTimeout(s),e.removeEventListener("transitionend",n),a())};e.addEventListener("transitionend",n)}),$=class{constructor(e){this.appInfo=e,this.id=`mini_app_${s()}`,this.parent=null,this.appId=e.appId,this.appConfig=null,this.bridgeList=[],this.jscore=new q(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=/* @__PURE__ */new Map,this.tabBarConfig=null,this.tabBarPaths=[],this.tabBarBridges=/* @__PURE__ */new Map,this.currentTabPath=null,this.tabBarEl=null,this.tabBarHeight=0,this._modalStack=[],this._modalPendingTimers=/* @__PURE__ */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{const 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(){R.clear(),this.closeMiniAppMenu(),r.closeApp(this)}renderMiniAppMenu(){const e=this.el.querySelector(".dimina-mini-app-menu__app-name"),t=this.el.querySelector(".dimina-mini-app-menu__app-id"),i=this.el.querySelector(".dimina-mini-app-menu__app-desc"),a=this.el.querySelector(".dimina-mini-app-menu__app-logo-img"),s=this.el.querySelector(".dimina-mini-app-menu__quick-actions"),n=this.getCurrentPagePath(),o=this.getEntryPagePath(),r=this.getCurrentPageQuery(),l=n||o||"",c=R.buildRouteURL(this.appId,[{pagePath:o,query:this.appInfo.query||{}},{pagePath:l,query:r}]);e.textContent=this.appInfo.name||"未命名小程序",t.textContent=`AppID:${this.appId||"--"}`,i.textContent=`当前页面:${l||"--"}`,a.src=this.appInfo.logo||"";const h=[{label:"复制链接",icon:"↗",handler:()=>this.copyText(c,"链接已复制")},{label:"重新进入",icon:"↻",handler:()=>{this.closeMiniAppMenu(),this.reLaunch({url:o||n})}},{label:"关闭小程序",icon:"×",danger:!0,handler:()=>this.closeMiniProgram()}];s.innerHTML=h.map((e,t)=>`\n\t\t\t\t<button type="button" class="dimina-mini-app-menu__quick-action${e.danger?" is-danger":""}" data-quick-index="${t}">\n\t\t\t\t\t<span class="dimina-mini-app-menu__quick-action-icon">${e.icon}</span>\n\t\t\t\t\t<span class="dimina-mini-app-menu__quick-action-label">${e.label}</span>\n\t\t\t\t</button>\n\t\t\t`).join(""),s.querySelectorAll("[data-quick-index]").forEach((e,t)=>{e.onclick=()=>h[t].handler()})}openMiniAppMenu(){const 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(){const 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){const i=this.apiRegistry[e];i?i.call(this,t):"function"==typeof this[e]?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();const e="main",t=`${this.appInfo.appId}/${e}/app-config.json`,[i]=await Promise.all([(s=`/${t}`,new Promise(e=>{fetch(`${s}`).then(e=>e.text()).then(t=>{e(t)}).catch(()=>{e(null)})})),(a=560,new Promise(e=>{setTimeout(()=>{e()},a)}))]);var a,s;if(!i)return;this.appConfig=JSON.parse(i),this._initTabBar();const n=this.appInfo.pagePath||this.appConfig.app.entryPagePath,r=this.appConfig.modules[n],l=o(this.appConfig.app,r);this.updateTargetPageColorStyle(l);const c=await this.createBridge({pagePath:n,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:l});if(this.bridgeList.push(c),this._isTabBarPage(n)){const e=this._normalizePagePath(n);this.tabBarBridges.set(e,c),this.currentTabPath=e,this._setTabBarVisible(!0),this._updateTabBarSelection(e)}c.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++){const{pagePath:i,query:a}=e[t],s=t===e.length-1,n=i.startsWith("/")?i.slice(1):i,r=this.appConfig.modules[n],l=o(this.appConfig.app,r),c=await this.createBridge({pagePath:n,query:a,scene:this.appInfo.scene,jscore:this.jscore,isRoot:!1,root:r?.root||"main",appId:this.appInfo.appId,pages:this.appConfig.app.pages,configInfo:l}),h=this.bridgeList[this.bridgeList.length-1];h.webview.el.classList.remove("dimina-native-view--instage"),h.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"),s||c.webview.el.classList.add("dimina-native-view--slide-out"),c.start()}if(e.length>0){const e=this.bridgeList[this.bridgeList.length-1],t=this.appConfig.modules[e.opts.pagePath],i=o(this.appConfig.app,t);this.updateTargetPageColorStyle(i),this._isTabBarPage(e.opts.pagePath)||this._setTabBarVisible(!1)}}_syncHash(){const e=this.bridgeList.map(e=>({pagePath:e.opts.pagePath.startsWith("/")?e.opts.pagePath.slice(1):e.opts.pagePath,query:e.opts.query||{}}));R.syncStack(this.appId,e)}async createBridge(e){const{jscore:t,configInfo:i,isRoot:a,appId:s,pagePath:n,query:o,scene:r,pages:l,root:c}=e,h=new A({jscore:t,configInfo:i,isRoot:a,appId:s,pagePath:n,query:o,scene:r,pages:l,root:c});return h.parent=this,await h.init(),h}onPresentIn(){const e=this.bridgeList[this.bridgeList.length-1];e?.appShow(),e?.pageShow()}onPresentOut(){const e=this.bridgeList[this.bridgeList.length-1];e?.appHide(),e?.pageHide()}initPageFrame(){this.el.innerHTML='<div class="dimina-mini-app">\n\t\x3c!-- 右上方药丸按钮 --\x3e\n\t<ul class="dimina-mini-app-navigation__actions">\n\t\t<li class="dimina-mini-app-navigation__actions-variable"></li>\n\t\t<li class="dimina-mini-app-navigation__actions-close"></li>\n\t</ul>\n\n\t\x3c!-- webview挂载节点 --\x3e\n\t<div class="dimina-mini-app__webviews"></div>\n\n\t\x3c!-- TabBar 底部导航栏 --\x3e\n\t<div class="dimina-mini-app__tabbar" style="display: none;"></div>\n\n\t\x3c!-- 启动loading页面 --\x3e\n\t<div class="dimina-mini-app__launch-screen">\n\t\t<div class="dimina-mini-app__launch-screen-content">\n\t\t\t<div class="dimina-mini-app__logo">\n\t\t\t\t<div class="dimina-mini-app__logo-img">\n\t\t\t\t\t<img class="dimina-mini-app__logo-img-url" alt="logo" />\n\t\t\t\t</div>\n\t\t\t\t<div class="dimina-mini-app__logo-circle"></div>\n\t\t\t\t<span class="dimina-mini-app__green-point"></span>\n\t\t\t</div>\n\t\t\t<h1 class="dimina-mini-app__name"></h1>\n\t\t</div>\n\t</div>\n\n\t<div class="dimina-mini-app-menu__mask"></div>\n\t<div class="dimina-mini-app-menu">\n\t\t<div class="dimina-mini-app-menu__handle"></div>\n\t\t<div class="dimina-mini-app-menu__app">\n\t\t\t<div class="dimina-mini-app-menu__app-logo">\n\t\t\t\t<img class="dimina-mini-app-menu__app-logo-img" alt="logo" />\n\t\t\t</div>\n\t\t\t<div class="dimina-mini-app-menu__app-meta">\n\t\t\t\t<h2 class="dimina-mini-app-menu__app-name"></h2>\n\t\t\t\t<p class="dimina-mini-app-menu__app-id"></p>\n\t\t\t\t<p class="dimina-mini-app-menu__app-desc"></p>\n\t\t\t</div>\n\t\t</div>\n\t\t<div class="dimina-mini-app-menu__quick-actions"></div>\n\t\t<div class="dimina-mini-app-menu__footer">\n\t\t\t<button type="button" class="dimina-mini-app-menu__footer-btn dimina-mini-app-menu__footer-btn--cancel">取消</button>\n\t\t</div>\n\t</div>\n</div>\n'}updateTargetPageColorStyle(e){const{navigationBarTextStyle:t}=e;this.updateActionColorStyle(t)}showLaunchScreen(){const e=this.el.querySelector(".dimina-mini-app__launch-screen"),t=this.el.querySelector(".dimina-mini-app__name"),i=this.el.querySelector(".dimina-mini-app__logo-img-url");this.updateActionColorStyle("black"),t.innerHTML=this.appInfo.name,i.src=this.appInfo.logo,e.style.display="block"}hideLaunchScreen(){this.el.querySelector(".dimina-mini-app__launch-screen").style.display="none"}updateActionColorStyle(e){this.color=e;const t=this.el.querySelector(".dimina-mini-app-navigation__actions");"white"===e?(t.classList.remove("dimina-mini-app-navigation__actions--black"),t.classList.add("dimina-mini-app-navigation__actions--white")):"black"===e&&(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}})}}async navigateTo(e){const{url:t,success:i,fail:a,complete:s}=e,{query:r,pagePath:l}=n(t),c=this.createCallbackFunction(i),h=this.createCallbackFunction(a),d=this.createCallbackFunction(s);if(this._isTabBarPage(l))return h?.({errMsg:"navigateTo:fail can not navigateTo a tabbar page"}),void d?.();if(!this.webviewAnimaEnd)return;this.webviewAnimaEnd=!1;const p=this.appConfig.modules[l],g=o(this.appConfig.app,p);this.updateTargetPageColorStyle(g);const m=await this.createBridge({pagePath:l,query:r,scene:this.appInfo.scene,jscore:this.jscore,isRoot:!1,root:p?.root||"main",appId:this.appInfo.appId,pages:this.appConfig.app.pages,configInfo:g}),u=this.bridgeList[this.bridgeList.length-1],b=u.webview;this.bridgeList.push(m),m.start(),this._syncHash(),b.el.classList.remove("dimina-native-view--instage"),b.el.classList.add("dimina-native-view--slide-out"),b.el.classList.add("dimina-native-view--linear-anima"),u?.pageHide(),this._setTabBarVisible(!1),m.webview.el.style.zIndex=this.bridgeList.length+1,m.webview.el.classList.add("dimina-native-view--enter-anima"),m.webview.el.classList.add("dimina-native-view--instage"),await F(m.webview.el,"transform"),this.webviewAnimaEnd=!0,b.el.classList.remove("dimina-native-view--linear-anima"),m.webview.el.classList.remove("dimina-native-view--before-enter"),m.webview.el.classList.remove("dimina-native-view--enter-anima"),m.webview.el.classList.remove("dimina-native-view--instage"),c?.({errMsg:"navigateTo:ok"}),d?.()}reLaunch(e){if(!this.webviewAnimaEnd)return;this.webviewAnimaEnd=!1;const{url:t,success:i,fail:a,complete:s}=e,{query:r,pagePath:l}=n(t),c=this.createCallbackFunction(i),h=this.createCallbackFunction(a),d=this.createCallbackFunction(s);try{const e=this.appConfig.modules[l],t=o(this.appConfig.app,e);this.updateTargetPageColorStyle(t);const i=new Set([...this.bridgeList,...this.tabBarBridges.values()]);for(const a of i)a.destroy(),a.webview?.el?.remove();this.bridgeList.length=0,this.tabBarBridges.clear(),this.currentTabPath=null,this.webviewsContainer&&(this.webviewsContainer.innerHTML=""),this.createBridge({pagePath:l,query:r,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(l)){const t=this._normalizePagePath(l);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,c?.({errMsg:"reLaunch:ok"}),d?.()}).catch(e=>{h?.({errMsg:`reLaunch:fail ${e.message}`}),d?.(),this.webviewAnimaEnd=!0})}catch(p){h?.({errMsg:`reLaunch:fail ${p.message}`}),d?.(),this.webviewAnimaEnd=!0}}applyUpdate(){this.reLaunch({url:this.getEntryPagePath()})}redirectTo(e){const{url:t,success:i,fail:a,complete:s}=e,{query:r,pagePath:l}=n(t),c=this.createCallbackFunction(i),h=this.createCallbackFunction(a),d=this.createCallbackFunction(s);if(this._isTabBarPage(l))return h?.({errMsg:"redirectTo:fail can not redirectTo a tabbar page"}),void d?.();if(!this.webviewAnimaEnd)return;this.webviewAnimaEnd=!1;const p=this.bridgeList[this.bridgeList.length-1],g=this._normalizePagePath(p.opts.pagePath),m=this.appConfig.modules[l],u=o(this.appConfig.app,m);this.updateTargetPageColorStyle(u),p.destroy(),p.opts={...p.opts,pagePath:l,query:r,configInfo:u},p.resetStatus(),p.start(),this._syncHash(),this.tabBarBridges.get(g)===p&&(this.tabBarBridges.delete(g),this.currentTabPath===g&&(this.currentTabPath=null)),this._setBridgeTabBarInset(p,!1),this._setTabBarVisible(!1),this.webviewAnimaEnd=!0,c?.({errMsg:"redirectTo:ok"}),d?.()}async navigateBack(){if(this.bridgeList.length<2)return;if(!this.webviewAnimaEnd)return;this.webviewAnimaEnd=!1;const e=this.bridgeList.pop(),t=this.bridgeList[this.bridgeList.length-1],i=this.appConfig.modules[t.opts.pagePath],a=o(this.appConfig.app,i);if(this.updateTargetPageColorStyle(a),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)){const e=this._normalizePagePath(t.opts.pagePath);this.currentTabPath=e,this._setTabBarVisible(!0),this._updateTabBarSelection(e)}await F(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){const{url:t,success:i,fail:a,complete:s}=e,{query:r,pagePath:l}=n(t),c=this._normalizePagePath(l),h=this.createCallbackFunction(i),d=this.createCallbackFunction(a),p=this.createCallbackFunction(s);if(!this._isTabBarPage(c))return d?.({errMsg:`switchTab:fail not a tabBar page: ${c}`}),void p?.();if(!this.webviewAnimaEnd)return d?.({errMsg:"switchTab:fail busy"}),void p?.();if(this.currentTabPath===c&&1===this.bridgeList.length)return this._setTabBarVisible(!0),this._updateTabBarSelection(c),h?.({errMsg:"switchTab:ok"}),void p?.();this.webviewAnimaEnd=!1;try{const e=this.currentTabPath,t=e?this.tabBarBridges.get(e):null,i=!!t&&1===this.bridgeList.length&&this.bridgeList[0]===t;for(;this.bridgeList.length>0;){const 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(c)){i&&t.pageHide(),t.webview?.el&&(t.webview.el.style.display="none");const e=this.bridgeList.indexOf(t);e>=0&&this.bridgeList.splice(e,1)}let a=this.tabBarBridges.get(c);const s=this.appConfig.modules[c],n=o(this.appConfig.app,s);this.updateTargetPageColorStyle(n),a||(a=await this.createBridge({pagePath:c,query:r,scene:this.appInfo.scene,jscore:this.jscore,isRoot:!0,root:s?.root||"main",appId:this.appInfo.appId,pages:this.appConfig.app.pages,configInfo:n}),this.tabBarBridges.set(c,a),a.start());const l=a.webview.el;this._setBridgeTabBarInset(a,!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(a)||this.bridgeList.push(a),this.currentTabPath=c,a.pageShow(),this._setTabBarVisible(!0),this._updateTabBarSelection(c),this._syncHash(),h?.({errMsg:"switchTab:ok"})}catch(g){d?.({errMsg:`switchTab:fail ${g.message}`})}finally{this.webviewAnimaEnd=!0,p?.()}}_initTabBar(){const e=this.appConfig?.app?.tabBar;e&&Array.isArray(e.list)&&0!==e.list.length&&(this.tabBarConfig=e,this.tabBarPaths=e.list.map(e=>this._normalizePagePath(e.pagePath)),this._renderTabBar())}_renderTabBar(){if(this.tabBarEl=this.el.querySelector(".dimina-mini-app__tabbar"),!this.tabBarEl)return;const{color:e,backgroundColor:t,list:i}=this.tabBarConfig,a=this._sanitizeCssColor(e)||"#999999",s=this._sanitizeCssColor(t)||"#ffffff";this.tabBarEl.textContent="";const n=document.createElement("div");n.className="dimina-tabbar",n.style.backgroundColor=s,i.forEach((e,t)=>{const i=this._normalizePagePath(e.pagePath),s=document.createElement("div");s.className="dimina-tabbar-item",s.dataset.path=i,s.dataset.index=String(t);const o=this._resolveTabBarIcon(e.iconPath);o&&s.appendChild(this._createTabBarIcon(o,"dimina-tabbar-icon-default"));const r=this._resolveTabBarIcon(e.selectedIconPath);r&&s.appendChild(this._createTabBarIcon(r,"dimina-tabbar-icon-selected"));const l=document.createElement("span");l.className="dimina-tabbar-text",l.style.color=a,l.textContent=e.text||"",s.appendChild(l),n.appendChild(s)}),this.tabBarEl.appendChild(n),this.tabBarEl.addEventListener("click",e=>{const t=e.target.closest(".dimina-tabbar-item");if(!t)return;const i=t.dataset.path;i&&i!==this.currentTabPath&&this.switchTab({url:`/${i}`})}),"undefined"!=typeof ResizeObserver&&(this._tabBarResizeObserver?.disconnect(),this._tabBarResizeObserver=new ResizeObserver(()=>this._syncTabBarHeightVar()),this._tabBarResizeObserver.observe(this.tabBarEl))}_createTabBarIcon(e,t){const i=document.createElement("img");return i.className=`dimina-tabbar-icon ${t}`,i.src=e,i.alt="",i.addEventListener("error",()=>{i.style.display="none"}),i}_sanitizeCssColor(e){if(!e||"string"!=typeof e)return"";const t=e.trim();return 0===t.length||t.length>64?"":/[<>"';{}()\\]/.test(t)?/^(?:rgb|rgba|hsl|hsla)\(\s*[\d.,%\s/-]+\)$/i.test(t)?t:"":t}_getTabBarHeight(){if(!this.tabBarEl)return this.tabBarHeight;let e=this.tabBarEl.getBoundingClientRect().height;if(!e&&"none"===this.tabBarEl.style.display){const t=this.tabBarEl.style.display,i=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=i}return e>0&&(this.tabBarHeight=e),this.tabBarHeight}_syncTabBarHeightVar(){const e=this._getTabBarHeight();this.el.style.setProperty("--dimina-tabbar-height",`${e}px`),this._syncTabBarBridgeInsets()}_setBridgeTabBarInset(e,t){const i=e?.webview?.el;i&&(t?i.style.bottom=`${this._getTabBarHeight()}px`:i.style.removeProperty("bottom"))}_syncTabBarBridgeInsets(){for(const 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||"string"!=typeof e)return null;const t=e.trim();if(!t)return null;if(/^(?:data:|blob:|https?:|\/\/)/i.test(t))return t;const i=t.replace(/^\/+/,"").replace(/^\.\//,""),a=`${this.appId}/`;return i.startsWith(a)?this._joinBaseUrl(i):this._joinBaseUrl(this.appId,"main",i)}_setTabBarVisible(e){this.tabBarEl&&(this.tabBarEl.style.display=e?"block":"none",this._syncTabBarHeightVar())}_updateTabBarSelection(e){if(!this.tabBarEl||!this.tabBarConfig)return;const t=this.tabBarConfig.color||"#999999",i=this.tabBarConfig.selectedColor||"#1890ff";this.tabBarEl.querySelectorAll(".dimina-tabbar-item").forEach(a=>{const s=a.getAttribute("data-path")===e,n=a.querySelector(".dimina-tabbar-text"),o=a.querySelector(".dimina-tabbar-icon-default"),r=a.querySelector(".dimina-tabbar-icon-selected");n&&(n.style.color=s?i:t),o&&(o.style.display=s?"none":"block"),r&&(r.style.display=s?"block":"none"),a.classList.toggle("dimina-tabbar-item--selected",s)})}setTabBarStyle(e={}){const{color:t,selectedColor:i,backgroundColor:a,borderStyle:s,success:n,fail:o,complete:r}=e,l=this.createCallbackFunction(n),c=this.createCallbackFunction(o),h=this.createCallbackFunction(r);if(!this.tabBarConfig||!this.tabBarEl)return c?.({errMsg:"setTabBarStyle:fail tabBar not configured"}),void h?.();const d="black"===s||"white"===s?s:null,p=void 0!==t?this._sanitizeCssColor(t):null,g=void 0!==i?this._sanitizeCssColor(i):null,m=void 0!==a?this._sanitizeCssColor(a):null;p&&(this.tabBarConfig.color=p),g&&(this.tabBarConfig.selectedColor=g),m&&(this.tabBarConfig.backgroundColor=m),d&&(this.tabBarConfig.borderStyle=d);const u=this.tabBarEl.querySelector(".dimina-tabbar");u&&m&&(u.style.backgroundColor=m),this._updateTabBarSelection(this.currentTabPath),l?.({errMsg:"setTabBarStyle:ok"}),h?.()}navigateToMiniProgram(e){const{appId:t,path:i}=e;r.openApp({appId:t,path:i,scene:1037},this.parent)}bindMoreEvent(){const e=this.el.querySelector(".dimina-mini-app-navigation__actions-variable"),t=this.el.querySelector(".dimina-mini-app-menu__mask"),i=this.el.querySelector(".dimina-mini-app-menu"),a=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(),a.onclick=()=>this.closeMiniAppMenu(),i.onclick=e=>e.stopPropagation()}bindCloseEvent(){this.el.querySelector(".dimina-mini-app-navigation__actions-close").onclick=()=>{this.closeMiniProgram()}}destroy(){this._destroyed=!0;for(const e of this._extSubscriptions.values())e?.();this._extSubscriptions.clear(),this._tabBarResizeObserver?.disconnect(),this._tabBarResizeObserver=null;for(const e of this._modalPendingTimers)clearTimeout(e);this._modalPendingTimers.clear();for(const e of this._modalStack)e.mask?.remove(),e.dialog?.remove();this._modalStack.length=0,this.hideToast({}),r.popView(),this.jscore.destroy()}getNetworkType(e){const{success:t}=e;this.createCallbackFunction(t)?.({networkType:"wifi"})}request({url:e,data:t,header:i={},timeout:a=0,method:s="GET",dataType:n="json",responseType:o="text",success:r,fail:l,complete:c}){const h={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:e,data:t,header:i,timeout:a,method:s,dataType:n,responseType:o})},d=this.createCallbackFunction(r),p=this.createCallbackFunction(l),g=this.createCallbackFunction(c);fetch("http://localhost:7788/proxy",h).then(e=>{if(!e.ok){const t=new Error(e.statusText);throw t.code=e.status,t}const t={};switch(e.headers.forEach((e,i)=>{t[i]=e}),n){case"json":return e.json().then(i=>({data:JSON.parse(i),header:t,statusCode:e.status}));case"arraybuffer":return e.arrayBuffer().then(i=>({data:i,header:t,statusCode:e.status}));default:return e.text().then(i=>({data:i,header:t,statusCode:e.status}))}}).then(e=>{d?.(e)}).catch(e=>{p?.({errMsg:e.message,errno:e.code})}).finally(()=>{g?.()})}getSystemInfoAsync(e){const t=this.parent.parent.root.querySelector(".iphone__status-bar").getBoundingClientRect(),i=this.parent.el.querySelector(".dimina-native-webview__root").getBoundingClientRect(),{success:a,complete:s}=e,n=this.createCallbackFunction(a),o=this.createCallbackFunction(s);n?.({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:i.width,height:i.height,top:i.top,bottom:i.bottom,left:i.left,right:i.right}}),o?.()}getMenuButtonBoundingClientRect(){const e=this.el.querySelector(".dimina-mini-app-navigation__actions").getBoundingClientRect(),t=(this.parent.parent.root.querySelector(".iphone__status-bar")?.getBoundingClientRect().height||20)+4,i=t+e.height;return{top:t,right:e.right,bottom:i,left:e.left,width:e.width,height:e.height,x:e.x,y:t}}getHostEnvSnapshot(){return{menuRect:this.getMenuButtonBoundingClientRect(),systemInfo:this.getSystemInfoSync()}}getSystemInfoSync(){const e=this.parent.parent.root.querySelector(".iphone__status-bar"),t=this.parent.el.querySelector(".dimina-native-webview__root")?.getBoundingClientRect(),i=t?.width||this.el.clientWidth||375,a=t?.height||this.el.clientHeight||667,s=e?.getBoundingClientRect().height||20;return{brand:"devtools",model:"web",platform:"devtools",system:"web",SDKVersion:"3.0.0",pixelRatio:globalThis.devicePixelRatio||1,screenWidth:i,screenHeight:a,windowWidth:i,windowHeight:a,statusBarHeight:s,safeArea:{left:0,right:i,top:s,bottom:a,width:i,height:Math.max(a-s,0)}}}showToast(e={}){const{title:t="",duration:i=1500,icon:a="success",mask:s=!1,success:n,complete:o}=e;if(!t)return;this.hideToast({});const r=this.createCallbackFunction(n),l=this.createCallbackFunction(o);let c=null;s&&(c=document.createElement("div"),c.className="dimina-toast-mask",this.el.appendChild(c));const h=document.createElement("div");h.className=`dimina-toast dimina-toast--${a}`,"none"===a&&h.classList.add("dimina-toast--text-only");const d=document.createElement("p");d.textContent=String(t),h.appendChild(d),this.el.appendChild(h),this.toastInfo.dom=h,this.toastInfo.maskEl=c,this.toastInfo.timer=setTimeout(()=>{h.remove(),c?.remove(),this.toastInfo.dom===h&&(this.toastInfo.dom=null,this.toastInfo.maskEl=null,this.toastInfo.timer=null)},i),r?.(),l?.()}hideToast(e={}){const{success:t,complete:i}=e,a=this.createCallbackFunction(t),s=this.createCallbackFunction(i);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),a?.(),s?.()}showLoading(e={}){this.showToast({...e,icon:"loading"})}hideLoading(e={}){this.hideToast(e)}showModal(e){if(this._destroyed)return;const t=this._mountModal(e||{});this._modalStack.push(t),this._updateModalView(),t.mask.classList.add("show");const i=setTimeout(()=>{this._modalPendingTimers.delete(i),this._destroyed||this._modalStack.includes(t)&&t.dialog.classList.add("show")},100);this._modalPendingTimers.add(i)}_updateModalView(){const e=this._modalStack.length-1;for(let t=0;t<this._modalStack.length;t++){const i=this._modalStack[t];t===e?(i.mask.classList.remove("dimina-modal--occluded"),i.dialog.classList.remove("dimina-modal--occluded")):(i.mask.classList.add("dimina-modal--occluded"),i.dialog.classList.add("dimina-modal--occluded"))}}_mountModal(e){const{title:t="",content:i="",showCancel:a=!0,cancelText:s="取消",cancelColor:n="#000",confirmText:o="确定",confirmColor:r="#576b95",success:l,complete:c}=e,h=this.createCallbackFunction(l),d=this.createCallbackFunction(c),p=document.createElement("div");p.className="dimina-dialog-mask";const g=document.createElement("div");g.className="dimina-dialog";const m=this._modalStack.length;if(p.style.zIndex=String(1100+20*m),g.style.zIndex=String(1110+20*m),t){const e=document.createElement("h2");e.className="dimina-dialog__title",e.textContent=String(t),g.appendChild(e)}if(i){const e=document.createElement("p");e.className="dimina-dialog__content",e.textContent=String(i),g.appendChild(e)}const u=document.createElement("div");u.className="dimina-dialog__buttons";let b=!1;const v={mask:p,dialog:g,close:null},w=e=>{if(b)return;b=!0;const t=this._modalStack.indexOf(v);t>=0&&this._modalStack.splice(t,1),0===this._modalStack.length?(p.classList.remove("show"),g.classList.remove("show"),setTimeout(()=>{p.remove(),g.remove()},200)):(p.remove(),g.remove()),this._updateModalView(),h?.(e),d?.()};if(v.close=w,a){const e=document.createElement("button");e.type="button",e.className="dimina-dialog__button",e.style.color=n,e.textContent=String(s),e.addEventListener("click",()=>{w({cancel:!0,confirm:!1,errMsg:"showModal:ok"})}),u.appendChild(e)}const f=document.createElement("button");return f.type="button",f.className="dimina-dialog__button",f.style.color=r,f.textContent=String(o),f.addEventListener("click",()=>{w({cancel:!1,confirm:!0,errMsg:"showModal:ok"})}),u.appendChild(f),g.appendChild(u),this.el.appendChild(p),this.el.appendChild(g),v}showActionSheet(e){const{itemList:t=[],itemColor:i="#000",success:a,fail:s,complete:n}=e||{};if(!Array.isArray(t)||0===t.length)return s&&this.createCallbackFunction(s)({errMsg:"showActionSheet:fail"}),void(n&&this.createCallbackFunction(n)());const o=document.createElement("div");o.className="dimina-action-sheet-mask";const r=document.createElement("div");r.className="dimina-action-sheet";const l=()=>{o.remove(),r.remove()};t.forEach((e,t)=>{const s=document.createElement("div");s.className="dimina-action-sheet-item",s.style.color=i,s.textContent=e,s.onclick=()=>{l(),a&&this.createCallbackFunction(a)({tapIndex:t}),n&&this.createCallbackFunction(n)()},r.appendChild(s)});const c=document.createElement("div");c.className="dimina-action-sheet-cancel",c.textContent="取消",c.onclick=()=>{l(),s&&this.createCallbackFunction(s)({errMsg:"showActionSheet:fail cancel"}),n&&this.createCallbackFunction(n)()},r.appendChild(c),o.onclick=l,this.el.appendChild(o),this.el.appendChild(r),requestAnimationFrame(()=>requestAnimationFrame(()=>{r.classList.add("show"),o.classList.add("show")}))}setNavigationBarTitle(e){const{title:t,success:i,fail:a,complete:s}=e,n=this.createCallbackFunction(i),o=this.createCallbackFunction(a),r=this.createCallbackFunction(s);try{const e=this.bridgeList[this.bridgeList.length-1].webview.el.querySelector(".dimina-native-webview__navigation-title");e?(e.textContent=t||"",n?.({errMsg:"setNavigationBarTitle:ok"})):o?.({errMsg:"setNavigationBarTitle:fail Navigation title element not found"})}catch(l){o?.({errMsg:`setNavigationBarTitle:fail ${l.message}`})}finally{r?.()}}setNavigationBarColor(e){const{frontColor:t,backgroundColor:i,success:a,fail:s,complete:n}=e,o=this.createCallbackFunction(a),r=this.createCallbackFunction(s),l=this.createCallbackFunction(n);try{const 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),i&&(e.style.backgroundColor=i),o?.({errMsg:"setNavigationBarColor:ok"})):r?.({errMsg:"setNavigationBarColor:fail Navigation element not found"})}catch(c){r?.({errMsg:`setNavigationBarColor:fail ${c.message}`})}finally{l?.()}}pageScrollTo(e){const{scrollTop:t,duration:i=300,success:a,fail:s,complete:n}=e,o=this.createCallbackFunction(a),r=this.createCallbackFunction(s),l=this.createCallbackFunction(n);try{const e=this.bridgeList[this.bridgeList.length-1].webview.iframe.contentWindow.document.documentElement;e?(e.scrollTo({top:t,behavior:i>0?"smooth":"auto"}),setTimeout(()=>{o?.({errMsg:"pageScrollTo:ok"}),l?.()},i)):(r?.({errMsg:"pageScrollTo:fail Webview root element not found"}),l?.())}catch(c){r?.({errMsg:`pageScrollTo:fail ${c.message}`}),l?.()}}setClipboardData(e){const{data:t,success:i,fail:a,complete:s}=e,n=this.createCallbackFunction(i),o=this.createCallbackFunction(a),r=this.createCallbackFunction(s);try{navigator.clipboard.writeText(t).then(()=>{n?.({errMsg:"setClipboardData:ok"}),r?.()}).catch(e=>{o?.({errMsg:`setClipboardData:fail ${e.message}`}),r?.()})}catch(l){o?.({errMsg:`setClipboardData:fail ${l.message}`}),r?.()}}getClipboardData(e){const{success:t,fail:i,complete:a}=e,s=this.createCallbackFunction(t),n=this.createCallbackFunction(i),o=this.createCallbackFunction(a);try{navigator.clipboard.readText().then(e=>{s?.({data:e,errMsg:"getClipboardData:ok"}),o?.()}).catch(e=>{n?.({errMsg:`getClipboardData:fail ${e.message}`}),o?.()})}catch(r){n?.({errMsg:`getClipboardData:fail ${r.message}`}),o?.()}}setStorage(e){const{key:t,data:i,success:a,fail:s,complete:n}=e,o=this.createCallbackFunction(a),r=this.createCallbackFunction(s),l=this.createCallbackFunction(n);try{const e=`${this.appId}_${t}`,a="object"==typeof i?JSON.stringify(i):String(i);localStorage.setItem(e,a),o?.({errMsg:"setStorage:ok"})}catch(c){r?.({errMsg:`setStorage:fail ${c.message}`})}finally{l?.()}}getStorage(e){const{key:t,success:i,fail:a,complete:s}=e,n=this.createCallbackFunction(i),o=this.createCallbackFunction(a),r=this.createCallbackFunction(s);try{const e=`${this.appId}_${t}`,i=localStorage.getItem(e);if(null!==i){let e=i;try{e=JSON.parse(i)}catch{}n?.({data:e,errMsg:"getStorage:ok"})}else o?.({errMsg:"getStorage:fail data not found"})}catch(l){o?.({errMsg:`getStorage:fail ${l.message}`})}finally{r?.()}}removeStorage(e){const{key:t,success:i,fail:a,complete:s}=e,n=this.createCallbackFunction(i),o=this.createCallbackFunction(a),r=this.createCallbackFunction(s);try{const e=`${this.appId}_${t}`;null!==localStorage.getItem(e)?(localStorage.removeItem(e),n?.({errMsg:"removeStorage:ok"})):n?.({errMsg:"removeStorage:ok"})}catch(l){o?.({errMsg:`removeStorage:fail ${l.message}`})}finally{r?.()}}clearStorage(e){const{success:t,fail:i,complete:a}=e||{},s=this.createCallbackFunction(t),n=this.createCallbackFunction(i),o=this.createCallbackFunction(a);try{const e=`${this.appId}_`,t=[];for(let i=0;i<localStorage.length;i++){const a=localStorage.key(i);a.startsWith(e)&&t.push(a)}t.forEach(e=>localStorage.removeItem(e)),s?.({errMsg:"clearStorage:ok"})}catch(r){n?.({errMsg:`clearStorage:fail ${r.message}`})}finally{o?.()}}getStorageInfo(e){const{success:t,fail:i,complete:a}=e||{},s=this.createCallbackFunction(t),n=this.createCallbackFunction(i),o=this.createCallbackFunction(a);try{const e=[];let t=0;const i=10485760,a=`${this.appId}_`;for(let s=0;s<localStorage.length;s++){const i=localStorage.key(s);if(i.startsWith(a)){const s=i.substring(a.length);e.push(s);const n=localStorage.getItem(i);t+=n?2*n.length:0}}s?.({keys:e,currentSize:t,limitSize:i,errMsg:"getStorageInfo:ok"})}catch(r){n?.({errMsg:`getStorageInfo:fail ${r.message}`})}finally{o?.()}}_parseExtEventKey(e){const t=r.getExtModules();for(const i of Object.keys(t)){const t=`${i}_`;if(e.startsWith(t))return{module:i,event:e.slice(t.length)}}return{module:null,event:null}}_handleExtCall(e,t={}){void 0!==t.module?this._extBridgeCall(e,t):t.success?this._extOnBridgeCall(e,t):this._extOffBridgeCall(e)}_extBridgeCall(e,t){const{module:i,data:a={},success:s,fail:n,complete:o}=t,l=this.createCallbackFunction(s),c=this.createCallbackFunction(n),h=this.createCallbackFunction(o),d=r.getExtModule(i);if(!d){const e=`extBridge:fail module "${i}" not registered`;return c?.({errMsg:e}),void h?.()}try{d({event:e,data:a,success:e=>{l?.(e),h?.()},fail:e=>{c?.(e),h?.()}})}catch(p){c?.({errMsg:`extBridge:fail ${p.message}`}),h?.()}}_extOnBridgeCall(e,t){const{success:i}=t,a=this.createCallbackFunction(i),{module:s,event:n}=this._parseExtEventKey(e);if(!s)return;const o=r.getExtModule(s);this._extSubscriptions.get(e)?.();try{const t=o({event:n,data:{isSustain:!0},success:e=>a?.(e),fail:()=>{}});this._extSubscriptions.set(e,t??null)}catch(l){}}_extOffBridgeCall(e){const t=this._extSubscriptions.get(e);t&&(t(),this._extSubscriptions.delete(e))}};export{i as Application,$ as MiniApp};
@@ -68,7 +68,7 @@ var e=10,t=(e=0)=>t=>`\u001B[${t+e}m`,n=(e=0)=>t=>`\u001B[${38+e};5;${t}m`,r=(e=
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}})}}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._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`,o=n===`white`?`#FFFFFF`:`#E0E0E0`;this.tabBarEl.textContent=``;let s=document.createElement(`div`);s.className=`dimina-tabbar`,s.style.backgroundColor=a,s.style.borderTop=`0.5px solid ${o}`,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 o=this._resolveTabBarIcon(e.selectedIconPath);o&&r.appendChild(this._createTabBarIcon(o,`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),s.appendChild(r)}),this.tabBarEl.appendChild(s),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}_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){this.tabBarEl&&(this.tabBarEl.style.display=e?`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)})}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`);if(h&&(m&&(h.style.backgroundColor=m),d)){let e=d===`white`?`#FFFFFF`:`#E0E0E0`;h.style.borderTop=`0.5px solid ${e}`}this._updateTabBarSelection(this.currentTabPath),c?.({errMsg:`setTabBarStyle:ok`}),u?.()}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)}}}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([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}})}}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._renderTabBar())}_renderTabBar(){if(this.tabBarEl=this.el.querySelector(`.dimina-mini-app__tabbar`),!this.tabBarEl)return;let{color:e,backgroundColor:t,list:n}=this.tabBarConfig,r=this._sanitizeCssColor(e)||`#999999`,i=this._sanitizeCssColor(t)||`#ffffff`;this.tabBarEl.textContent=``;let a=document.createElement(`div`);a.className=`dimina-tabbar`,a.style.backgroundColor=i,n.forEach((e,t)=>{let n=this._normalizePagePath(e.pagePath),i=document.createElement(`div`);i.className=`dimina-tabbar-item`,i.dataset.path=n,i.dataset.index=String(t);let o=this._resolveTabBarIcon(e.iconPath);o&&i.appendChild(this._createTabBarIcon(o,`dimina-tabbar-icon-default`));let s=this._resolveTabBarIcon(e.selectedIconPath);s&&i.appendChild(this._createTabBarIcon(s,`dimina-tabbar-icon-selected`));let c=document.createElement(`span`);c.className=`dimina-tabbar-text`,c.style.color=r,c.textContent=e.text||``,i.appendChild(c),a.appendChild(i)}),this.tabBarEl.appendChild(a),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}_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){this.tabBarEl&&(this.tabBarEl.style.display=e?`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)})}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),this._updateTabBarSelection(this.currentTabPath),c?.({errMsg:`setTabBarStyle:ok`}),u?.()}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)}}}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">
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>
@@ -1,6 +1,6 @@
1
- var service=(function(){var e=Object.defineProperty,t=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n||e(r,Symbol.toStringTag,{value:`Module`}),r};function n(e){return typeof e==`function`}function r(e){return typeof e==`string`}function i(e){return e==null}function a(e,t){if(e===t)return!0;if(typeof e!=`object`||typeof t!=`object`||e==null||t==null)return!1;let n=Object.keys(e),r=Object.keys(t);return n.length===r.length?n.every(n=>a(e[n],t[n])):!1}function o(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function s(e){return e===`__proto__`}function c(e){switch(typeof e){case`number`:case`symbol`:return!1;case`string`:return e.includes(`.`)||e.includes(`[`)||e.includes(`]`)}}function l(e,t=2**53-1){switch(typeof e){case`number`:return Number.isInteger(e)&&e>=0&&e<t;case`symbol`:return!1;case`string`:return/^(?:0|[1-9]\d*)$/.test(e)}}function u(e){return e!==null&&(typeof e==`object`||typeof e==`function`)}function d(e){return typeof e==`symbol`||Object.prototype.toString.call(e)===`[object Symbol]`}function ee(e,t){return e===t||Number.isNaN(e)&&Number.isNaN(t)}function f(e){return typeof e==`string`||typeof e==`symbol`?e:Object.is(e?.valueOf?.(),-0)?`-0`:String(e)}function p(e){if(Array.isArray(e))return e.map(f);if(typeof e==`symbol`)return[e];e=m(e);let t=[],n=e.length;if(n===0)return t;let r=0,i=``,a=``,o=!1;for(e.charCodeAt(0)===46&&(t.push(``),r++);r<n;){let s=e[r];a?s===`\\`&&r+1<n?(r++,i+=e[r]):s===a?a=``:i+=s:o?s===`"`||s===`'`?a=s:s===`]`?(o=!1,t.push(i),i=``):i+=s:s===`[`?(o=!0,i&&=(t.push(i),``)):s===`.`?i&&=(t.push(i),``):i+=s,r++}return i&&t.push(i),t}function m(e){if(e==null)return``;if(typeof e==`string`)return e;if(Array.isArray(e))return e.map(m).join(`,`);let t=String(e);return t===`0`&&Object.is(Number(e),-0)?`-0`:t}function te(e,t){return Array.isArray(e)?!1:typeof e==`number`||typeof e==`boolean`||e==null||d(e)?!0:typeof e==`string`&&(/^\w*$/.test(e)||!/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/.test(e))||t!=null&&o(t,e)}function ne(e,t,n){if(t.length===0)return n;let r=e;for(let e=0;e<t.length;e++){if(r==null||s(t[e]))return n;r=r[t[e]]}return r===void 0?n:r}function h(e,t){if(e!=null)switch(typeof t){case`string`:{if(s(t))return;let n=e[t];return n===void 0?c(t)?h(e,p(t)):void 0:n}case`number`:case`symbol`:{typeof t==`number`&&(t=f(t));let n=e[t];return n===void 0?void 0:n}default:{if(Array.isArray(t))return ne(e,t);if(t=Object.is(t?.valueOf(),-0)?`-0`:String(t),s(t))return;let n=e[t];return n===void 0?void 0:n}}}function re(e,t,n){ie(e,t,()=>n,()=>void 0)}function ie(e,t,n,r){if(e==null&&!u(e))return e;let i;i=te(t,e)?[t]:Array.isArray(t)?t:p(t);let a=n(h(e,i)),o=e;for(let t=0;t<i.length&&o!=null;t++){let n=f(i[t]);if(s(n))continue;let c;if(t===i.length-1)c=a;else{let a=o[n],s=r?.(a,n,e);c=s===void 0?u(a)?a:l(i[t+1])?[]:{}:s}ae(o,n,c),o=o[n]}return e}function ae(e,t,n){let r=e[t];(!(o(e,t)&&ee(r,n))||n===void 0&&!(t in e))&&(e[t]=n)}function g(){return Math.random().toString(36).slice(2,7)}function oe(e){return e.toLowerCase().replace(/-(.)/g,(e,t)=>t.toUpperCase())}function se(e){return e.replace(/([a-z])([A-Z])/g,`$1-$2`).toLowerCase()}var _=typeof window<`u`&&typeof navigator<`u`;_&&/Android/i.test(navigator.userAgent),_&&/iPad|iPhone|iPod/.test(navigator.userAgent),_&&/OpenHarmony|harmony/.test(navigator.userAgent),_&&/Android|iPad|iPhone|iPod|OpenHarmony|harmony|Mobile/.test(navigator.userAgent);var v=typeof WorkerGlobalScope<`u`&&globalThis instanceof WorkerGlobalScope;function ce(e,t){if(t.startsWith(`/`))return t.slice(1);let n=e.split(`/`),r=t.split(`/`);for(let e of r){let t=e;t===`..`?n.length>0&&n.pop():t!==`.`&&t!==``&&n.push(t)}return n.join(`/`)}function y(e,t){let n=e.split(`/`).slice(0,-1).join(`/`),r=t.split(`?`),i=r[0],a=r[1],o=ce(n,i);return a&&(o+=`?${a}`),o}function b(e){return typeof e==`number`&&Number.isFinite(e)&&!Number.isNaN(e)?`${e}px`:e}function le(e){if(typeof e!=`object`||!e)return e;let t=new WeakMap;function n(e){if(typeof e!=`object`||!e)return e;if(e instanceof Date)return new Date(e);if(e instanceof RegExp)return new RegExp(e.source,e.flags);if(Array.isArray(e)){if(t.has(e))return t.get(e);let r=[];return t.set(e,r),r.push(...e.map(n)),r}if(t.has(e))return t.get(e);let r=Object.create(Object.getPrototypeOf(e));return t.set(e,r),Object.assign(r,...Object.keys(e).map(t=>({[t]:n(e[t])})))}return n(e)}var x={},S=1,ue=2;function de(e,t){x[e]||(x[e]={factory:t,status:S,exports:void 0})}function C(e,t,r){if(typeof e!=`string`)throw TypeError(`require args must be a string`);let i=x[e];if(!i)throw Error(`module ${e} not found`);if(i.status===S){i.status=ue;let t={exports:{}},a;try{i.factory&&(a=i.factory.call(null,C,t,t.exports))}catch(t){i.status=S;let a=`
1
+ var service=(function(){var e=Object.defineProperty,t=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n||e(r,Symbol.toStringTag,{value:`Module`}),r};function n(e){return typeof e==`function`}function r(e){return typeof e==`string`}function i(e){return e==null}function a(e,t){if(e===t)return!0;if(typeof e!=`object`||typeof t!=`object`||e==null||t==null)return!1;let n=Object.keys(e),r=Object.keys(t);return n.length===r.length?n.every(n=>a(e[n],t[n])):!1}function o(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function s(e){return e===`__proto__`}function c(e){switch(typeof e){case`number`:case`symbol`:return!1;case`string`:return e.includes(`.`)||e.includes(`[`)||e.includes(`]`)}}function l(e,t=2**53-1){switch(typeof e){case`number`:return Number.isInteger(e)&&e>=0&&e<t;case`symbol`:return!1;case`string`:return/^(?:0|[1-9]\d*)$/.test(e)}}function u(e){return e!==null&&(typeof e==`object`||typeof e==`function`)}function d(e){return typeof e==`symbol`||Object.prototype.toString.call(e)===`[object Symbol]`}function f(e,t){return e===t||Number.isNaN(e)&&Number.isNaN(t)}function p(e){return typeof e==`string`||typeof e==`symbol`?e:Object.is(e?.valueOf?.(),-0)?`-0`:String(e)}function m(e){if(Array.isArray(e))return e.map(p);if(typeof e==`symbol`)return[e];e=h(e);let t=[],n=e.length;if(n===0)return t;let r=0,i=``,a=``,o=!1;for(e.charCodeAt(0)===46&&(t.push(``),r++);r<n;){let s=e[r];a?s===`\\`&&r+1<n?(r++,i+=e[r]):s===a?a=``:i+=s:o?s===`"`||s===`'`?a=s:s===`]`?(o=!1,t.push(i),i=``):i+=s:s===`[`?(o=!0,i&&=(t.push(i),``)):s===`.`?i&&=(t.push(i),``):i+=s,r++}return i&&t.push(i),t}function h(e){if(e==null)return``;if(typeof e==`string`)return e;if(Array.isArray(e))return e.map(h).join(`,`);let t=String(e);return t===`0`&&Object.is(Number(e),-0)?`-0`:t}function ee(e,t){return Array.isArray(e)?!1:typeof e==`number`||typeof e==`boolean`||e==null||d(e)?!0:typeof e==`string`&&(/^\w*$/.test(e)||!/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/.test(e))||t!=null&&o(t,e)}function te(e,t,n){if(t.length===0)return n;let r=e;for(let e=0;e<t.length;e++){if(r==null||s(t[e]))return n;r=r[t[e]]}return r===void 0?n:r}function g(e,t){if(e!=null)switch(typeof t){case`string`:{if(s(t))return;let n=e[t];return n===void 0?c(t)?g(e,m(t)):void 0:n}case`number`:case`symbol`:{typeof t==`number`&&(t=p(t));let n=e[t];return n===void 0?void 0:n}default:{if(Array.isArray(t))return te(e,t);if(t=Object.is(t?.valueOf(),-0)?`-0`:String(t),s(t))return;let n=e[t];return n===void 0?void 0:n}}}function ne(e,t,n){re(e,t,()=>n,()=>void 0)}function re(e,t,n,r){if(e==null&&!u(e))return e;let i;i=ee(t,e)?[t]:Array.isArray(t)?t:m(t);let a=n(g(e,i)),o=e;for(let t=0;t<i.length&&o!=null;t++){let n=p(i[t]);if(s(n))continue;let c;if(t===i.length-1)c=a;else{let a=o[n],s=r?.(a,n,e);c=s===void 0?u(a)?a:l(i[t+1])?[]:{}:s}ie(o,n,c),o=o[n]}return e}function ie(e,t,n){let r=e[t];(!(o(e,t)&&f(r,n))||n===void 0&&!(t in e))&&(e[t]=n)}function _(){return Math.random().toString(36).slice(2,7)}function ae(e){return e.toLowerCase().replace(/-(.)/g,(e,t)=>t.toUpperCase())}function oe(e){return e.replace(/([a-z])([A-Z])/g,`$1-$2`).toLowerCase()}var v=typeof window<`u`&&typeof navigator<`u`;v&&/Android/i.test(navigator.userAgent),v&&/iPad|iPhone|iPod/.test(navigator.userAgent),v&&/OpenHarmony|harmony/.test(navigator.userAgent),v&&/Android|iPad|iPhone|iPod|OpenHarmony|harmony|Mobile/.test(navigator.userAgent);var y=typeof WorkerGlobalScope<`u`&&globalThis instanceof WorkerGlobalScope;function se(e,t){if(t.startsWith(`/`))return t.slice(1);let n=e.split(`/`),r=t.split(`/`);for(let e of r){let t=e;t===`..`?n.length>0&&n.pop():t!==`.`&&t!==``&&n.push(t)}return n.join(`/`)}function b(e,t){let n=e.split(`/`).slice(0,-1).join(`/`),r=t.split(`?`),i=r[0],a=r[1],o=se(n,i);return a&&(o+=`?${a}`),o}function x(e){return typeof e==`number`&&Number.isFinite(e)&&!Number.isNaN(e)?`${e}px`:e}function ce(e){if(typeof e!=`object`||!e)return e;let t=new WeakMap;function n(e){if(typeof e!=`object`||!e)return e;if(e instanceof Date)return new Date(e);if(e instanceof RegExp)return new RegExp(e.source,e.flags);if(Array.isArray(e)){if(t.has(e))return t.get(e);let r=[];return t.set(e,r),r.push(...e.map(n)),r}if(t.has(e))return t.get(e);let r=Object.create(Object.getPrototypeOf(e));return t.set(e,r),Object.assign(r,...Object.keys(e).map(t=>({[t]:n(e[t])})))}return n(e)}var le={},S=1,ue=2;function de(e,t){le[e]||(le[e]={factory:t,status:S,exports:void 0})}function C(e,t,r){if(typeof e!=`string`)throw TypeError(`require args must be a string`);let i=le[e];if(!i)throw Error(`module ${e} not found`);if(i.status===S){i.status=ue;let t={exports:{}},a;try{i.factory&&(a=i.factory.call(null,C,t,t.exports))}catch(t){i.status=S;let a=`
2
2
  name: ${t.name}
3
3
  msg: ${t.message}
4
4
  stack:
5
5
  ${t.stack}
6
- `;console.error(`require ${e} error: ${a}`),n(r)&&r({mod:e,errMsg:t.message})}i.exports=t.exports===void 0?a:t.exports}return n(t)&&t(i.exports),i.exports}C.async=async e=>new Promise((t,n)=>{try{t(C(e))}catch(t){n(Error(`${t.message}: Failed to initialize asynchronous loading for module '${e}'`))}});var w=new class{constructor(){this.callbacks={}}store(e,t,n=g()){if(t){for(let[t,n]of Object.entries(this.callbacks))if(n.callback===e)return t}return this.callbacks[n]={callback:e,keep:t},n}invoke(e,t){if(e===void 0)return;let r=this.callbacks[e];r&&n(r.callback)&&(r.callback(t),r.keep||delete this.callbacks[e])}remove(e){e?Object.keys(this.callbacks).forEach(t=>{e===t&&delete this.callbacks[t]}):Object.entries(this.callbacks).forEach(([e,t])=>{t.keep&&delete this.callbacks[e]})}},T=new class{constructor(){this.reset()}reset(){this.active=!1,this.snapshot={systemInfo:null,menuRect:null}}init(e={}){this.active=!0,this.snapshot={...this.snapshot,...e}}update(e={}){this.snapshot={...this.snapshot,...e}}get(e){return this.active?this.snapshot[e]??null:null}getSystemInfo(){return this.get(`systemInfo`)}getMenuRect(){return this.get(`menuRect`)}};function fe(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)})}}}var E=new class e{constructor(){this.event=fe(),this.init()}init(){v?globalThis.onmessage=e=>{this.handleMsg(e.data)}:DiminaServiceBridge.onMessage=this.handleMsg.bind(this)}handleMsg(e){console.log(`[service] receive msg: `,v?e:JSON.stringify(e));let{type:t,body:n}=e;this.event.emit(t,n)}on(e,t){this.event.on(e,t)}off(e){this.event.off(e)}send(t){return v?e.prototype.send=function(e){e.method=`publish`,globalThis.postMessage(e)}:e.prototype.send=function(e){return DiminaServiceBridge.publish(e.body.bridgeId||``,e)},this.send(t)}invoke(t){return v?e.prototype.invoke=function(e){e.method=`invoke`,globalThis.postMessage(e)}:e.prototype.invoke=function(e){return DiminaServiceBridge.invoke(e)},this.invoke(t)}},D=new class{#e=[];#t=``;setInitId(e){this.#t=e}push(e,t){this.stack(t).push(e)}pop(){this.stack().length>0&&this.stack().pop()}getPageInfo(){let e=this.stack();return e[e.length-1]||{id:this.#t}}pushStack(e){let t={id:e,pages:[]};return this.#e.push(t),t}popStack(e){if(e){let t=this.#e.findIndex(t=>t.id===e);t!==-1&&this.#e.splice(t,1)}else this.#e.length>0&&this.#e.pop()}stack(e){if(e){let t=this.#e.find(t=>t.id===e);return t||=this.pushStack(e),t.pages}else{let e=this.#e[this.#e.length-1];return e?e.pages:this.pushStack(Date.now()).pages}}},pe={getWindowInfo:()=>T.getSystemInfo(),getSystemInfoSync:()=>T.getSystemInfo(),getAppBaseInfo:()=>T.getSystemInfo(),getDeviceInfo:()=>T.getSystemInfo(),getMenuButtonBoundingClientRect:()=>T.getMenuRect()};function O(e,t,r=`container`){let i=pe[e];if(r===`container`&&i){let e=i();if(e)return e}let a;if(t===void 0||typeof t==`string`||Array.isArray(t))a=t;else if(n(t))a={success:w.store(t,!0)};else{let{success:e,fail:r,complete:i,keep:o,evtId:s,...c}=t;a=c,n(e)?a.success=w.store(e,o,s):a.success=e,n(r)&&(a.fail=w.store(r,o,s)),n(i)&&(a.complete=w.store(i,o,s))}let o={type:`invokeAPI`,target:r,body:{name:e,bridgeId:D.getPageInfo().id,params:a}};return r===`container`?E.invoke(o):E.send(o)}var me=t({navigateBack:()=>ye,navigateTo:()=>ve,reLaunch:()=>ge,redirectTo:()=>_e,switchTab:()=>he});function he(e){e.url=y(D.getPageInfo().route,e.url),O(`switchTab`,e)}function ge(e){e.url=y(D.getPageInfo().route,e.url),O(`reLaunch`,e)}function _e(e){let t=y(D.getPageInfo().route,e.url);D.getPageInfo().route!==t&&(e.url=t,O(`redirectTo`,e))}function ve(e){e.url=y(D.getPageInfo().route,e.url),O(`navigateTo`,e)}function ye(e){O(`navigateBack`,e)}var be=t({offAppHide:()=>Ee,offAppShow:()=>Te,offError:()=>Se,onAppHide:()=>we,onAppRoute:()=>ke,onAppShow:()=>Ce,onError:()=>xe,onPageNotFound:()=>Oe,onUnhandledRejection:()=>De});function xe(e){O(`onError`,e)}function Se(e){O(`offError`,e)}function Ce(e){O(`onAppShow`,e)}function we(e){O(`onAppHide`,e)}function Te(e){O(`offAppShow`,e)}function Ee(e){O(`offAppHide`,e)}function De(){}function Oe(){}function ke(){}var Ae=t({canIUse:()=>Ne,env:()=>je});function je(){return{USER_DATA_PATH:`difile://`}}var Me=new Set([`nextTick`,`getUpdateManager`,`UpdateManager`,`UpdateManager.applyUpdate`,`UpdateManager.onCheckForUpdate`,`UpdateManager.onUpdateFailed`,`UpdateManager.onUpdateReady`,`getPerformance`]);function Ne(e){if(Me.has(e))return!0;try{return O(`canIUse`,e)}catch(t){return console.warn(`[canIUse] check ${e} error:`,t),!1}}var Pe=t({getPerformance:()=>Fe});function Fe(){return Ie.getInstance()}var Ie=class e{static#e=null;constructor(){if(e.#e)throw Error(`Cannot instantiate more than one Performance instance.`);this.entryList=new Le,e.#e=this}static getInstance(){return e.#e||=new e,e.#e}createObserver(e){let t=new Re(e);return e&&O(`addPerformanceObserver`,{success:w.store(e=>{let n=e?.data?.entryList&&JSON.parse(e?.data?.entryList)||[];n&&(this.entryList.push(n),t.notify(n))},!0)},`render`),t}getEntries(){return this.entryList.getEntries()}getEntriesByName(e,t){return this.entryList.getEntriesByName(e,t)}getEntriesByType(e){return this.entryList.getEntriesByType(e)}setBufferSize(e){this.entryList.maxEntrySize=e}},Le=class{constructor(){this._list=[],this.maxEntrySize=30}push(e){for(let t of e)this._list.length>=this.maxEntrySize&&this._list.shift(),this._list.push(t)}getEntriesByName(e,t){return this._entryFilter(e,t)}getEntriesByType(e){return this._entryFilter(null,e)}_entryFilter(e,t){return this._list.filter(n=>!(e&&e!==n.name||t&&t!==n.entryType))}getEntries(){return this._list}},Re=class{constructor(e){this.entryTypes=[],this.callback=e}observe(e){this.connected=!0,this.entryTypes=e.entryTypes}notify(e){if(this.connected){let t=new Le;t.push(e.filter(e=>{let t=!1;return this.entryTypes&&this.entryTypes.length>0&&this.entryTypes.forEach(n=>{e.entryType===n&&(t=!0)}),t})),this.callback(t)}}disconnect(){this.connected=!1}},ze=t({loadSubpackage:()=>Ve,preDownloadSubpackage:()=>Be});function Be(e){O(`preDownloadSubpackage`,e)}function Ve(e){O(`loadSubpackage`,e)}var He=t({getAppBaseInfo:()=>Ye,getDeviceInfo:()=>Xe,getSystemInfo:()=>Ke,getSystemInfoAsync:()=>Je,getSystemInfoSync:()=>qe,getWindowInfo:()=>We,openAppAuthorizeSetting:()=>Ge,openSystemBluetoothSetting:()=>Ue});function Ue(e){O(`openSystemBluetoothSetting`,e)}function We(e){return O(`getWindowInfo`,e)}function Ge(e){O(`openAppAuthorizeSetting`,e)}function Ke(e){return new Promise(t=>{t(O(`getSystemInfo`,e))})}function qe(){return O(`getSystemInfoSync`)}function Je(e){O(`getSystemInfoAsync`,e)}function Ye(){return O(`getAppBaseInfo`)}function Xe(){return O(`getDeviceInfo`)}var Ze=t({getUpdateManager:()=>rt}),Qe=`onUpdateStatusChange`,$e=`updatefail`,et=`updateready`,tt=`noupdate`,nt=`updating`;function rt(){return it.getInstance()}var it=class e{static#e=null;constructor(){if(e.#e)throw Error(`Cannot instantiate more than one UpdateManager instance.`);this.hasAppliedUpdate=!1,this.updateFailed=!1,this.updateReady=!1,this.checkForUpdateResult=null,this.updateFailedListeners=[],this.updateReadyListeners=[],this.checkForUpdateListeners=[],E.on(Qe,e=>this.handleUpdateStatusChange(e)),e.#e=this}handleUpdateStatusChange(e={}){let{event:t}=e;if(t===$e){this.updateFailed=!0,this.emit(this.updateFailedListeners);return}if(t===et){this.updateReady=!0,this.checkForUpdateResult={hasUpdate:!0},this.emit(this.checkForUpdateListeners,this.checkForUpdateResult),this.emit(this.updateReadyListeners);return}if(t===nt){this.checkForUpdateResult={hasUpdate:!0},this.emit(this.checkForUpdateListeners,this.checkForUpdateResult);return}if(t===tt){this.checkForUpdateResult={hasUpdate:!1},this.emit(this.checkForUpdateListeners,this.checkForUpdateResult);return}typeof e.hasUpdate==`boolean`&&(this.checkForUpdateResult={hasUpdate:e.hasUpdate},this.emit(this.checkForUpdateListeners,this.checkForUpdateResult))}emit(e,...t){e.slice().forEach(e=>{e(...t)})}static getInstance(){return e.#e||=new e,e.#e}applyUpdate(){if(!this.updateReady)console.error(`[applyUpdate]: update is not ready`);else if(this.hasAppliedUpdate)console.error(`[applyUpdate]: applyUpdate has been called`);else return this.hasAppliedUpdate=!0,O(`applyUpdate`)}onCheckForUpdate(e){typeof e==`function`&&(this.checkForUpdateListeners.push(e),this.checkForUpdateResult&&e(this.checkForUpdateResult))}onUpdateFailed(e){typeof e==`function`&&(this.updateFailedListeners.push(e),this.updateFailed&&e())}onUpdateReady(e){typeof e==`function`&&(this.updateReadyListeners.push(e),this.updateReady&&e())}};it.getInstance();var at=t({createCameraContext:()=>ot});function ot(){return new st}var st=class{constructor(){this.bridgeId=D.getPageInfo().id}takePhoto(e){O(`takePhoto`,e)}startRecord(){O(`startRecord`)}stopRecord(){O(`stopRecord`)}},ct=t({reportAnalytics:()=>lt,reportEvent:()=>ut});function lt(...e){O(`reportAnalytics`,e)}function ut(e,t){O(`reportAnalytics`,{eventId:e,data:t})}var dt=t({closeBluetoothAdapter:()=>St,getBluetoothAdapterState:()=>xt,getBluetoothDevices:()=>bt,getConnectedBluetoothDevices:()=>yt,offBluetoothAdapterStateChange:()=>vt,offBluetoothDeviceFound:()=>_t,onBluetoothAdapterStateChange:()=>gt,onBluetoothDeviceFound:()=>ht,openBluetoothAdapter:()=>mt,startBluetoothDevicesDiscovery:()=>pt,stopBluetoothDevicesDiscovery:()=>ft});function ft(e){O(`stopBluetoothDevicesDiscovery`,e)}function pt(e){O(`startBluetoothDevicesDiscovery`,e)}function mt(e){O(`openBluetoothAdapter`,e)}function ht(e){O(`onBluetoothDeviceFound`,e)}function gt(e){O(`onBluetoothAdapterStateChange`,e)}function _t(){O(`offBluetoothDeviceFound`)}function vt(){O(`offBluetoothAdapterStateChange`)}function yt(e){O(`getConnectedBluetoothDevices`,e)}function bt(e){O(`getBluetoothDevices`,e)}function xt(e){O(`getBluetoothAdapterState`,e)}function St(e){O(`closeBluetoothAdapter`,e)}var Ct=t({closeBLEConnection:()=>It,createBLEConnection:()=>Ft,getBLEDeviceCharacteristics:()=>Pt,getBLEDeviceRSSI:()=>Nt,getBLEDeviceServices:()=>Mt,notifyBLECharacteristicValueChange:()=>jt,offBLECharacteristicValueChange:()=>At,offBLEConnectionStateChange:()=>kt,onBLECharacteristicValueChange:()=>Ot,onBLEConnectionStateChange:()=>Dt,readBLECharacteristicValue:()=>Et,setBLEMTU:()=>Tt,writeBLECharacteristicValue:()=>wt});function wt(e){O(`writeBLECharacteristicValue`,e)}function Tt(e){O(`setBLEMTU`,e)}function Et(e){O(`readBLECharacteristicValue`,e)}function Dt(e){O(`onBLEConnectionStateChange`,e)}function Ot(e){O(`onBLECharacteristicValueChange`,e)}function kt(e){O(`offBLEConnectionStateChange`,e)}function At(){O(`offBLECharacteristicValueChange`)}function jt(e){O(`notifyBLECharacteristicValueChange`,e)}function Mt(e){O(`getBLEDeviceServices`,e)}function Nt(e){O(`getBLEDeviceRSSI`,e)}function Pt(e){O(`getBLEDeviceCharacteristics`,e)}function Ft(e){O(`createBLEConnection`,e)}function It(e){O(`closeBLEConnection`,e)}var Lt=t({getClipboardData:()=>zt,setClipboardData:()=>Rt});function Rt(e){O(`setClipboardData`,e)}function zt(e){O(`getClipboardData`,e)}var Bt=t({addPhoneContact:()=>Ht,chooseContact:()=>Vt});function Vt(e){O(`chooseContact`,e)}function Ht(e){O(`addPhoneContact`,e)}var Ut=t({hideKeyboard:()=>Wt});function Wt(e){O(`hideKeyboard`,e)}var Gt=t({offMemoryWarning:()=>qt,onMemoryWarning:()=>Kt});function Kt(e){O(`onMemoryWarning`,e)}function qt(e){O(`offMemoryWarning`,e)}var Jt=t({getNetworkType:()=>Yt});function Yt(e){O(`getNetworkType`,e)}var Xt=t({makePhoneCall:()=>Zt});function Zt(e){O(`makePhoneCall`,e)}var Qt=t({scanCode:()=>$t});function $t(e){O(`scanCode`,e)}var en=t({vibrateLong:()=>nn,vibrateShort:()=>tn});function tn(e){O(`vibrateShort`,e)}function nn(e){O(`vibrateLong`,e)}var rn=t({extBridge:()=>an,extOffBridge:()=>sn,extOnBridge:()=>on,offLoginStatusChanged:()=>ln,onLoginStatusChanged:()=>cn});function an({event:e,module:t,data:r={},success:i,fail:a,complete:o},s){let c,l,u;n(s)?(c=s,l=s):(c=i,l=a,u=o),O(e,{module:t,data:r,keep:r.isSustain??!0,success:c,fail:l,complete:u})}function on({event:e,module:t,callBack:n,isSustain:r=!0}){if(!t||t===`DMServiceBridgeModule`){console.error(`[ERROR]: extOnBridge \u53C2\u6570 module ${t?`\u503C${t}\u4E0D\u5408\u6CD5`:`为空`}`);return}if(!e){console.error(`[ERROR]: extOnBridge 参数 event 为空`);return}if(!n){console.error(`[ERROR]: extOnBridge 参数 callBack 为空`);return}let i=`${t}_${e}`;O(i,{evtId:i,keep:r,success:n})}function sn({event:e,module:t,callBack:n}){if(!t||t===`DMServiceBridgeModule`){console.error(`[ERROR]: extOffBridge \u53C2\u6570 module ${t?`\u503C${t}\u4E0D\u5408\u6CD5`:`为空`}`);return}if(!e){console.error(`[ERROR]: extOffBridge 参数 event 为空`);return}O(`${t}_${e}`,{success:n})}function cn(e){E.on(`notifyLoginStatusChanged`,t=>{e?.(t)})}function ln(){E.off(`notifyLoginStatusChanged`)}var un=t({USER_DATA_PATH:()=>dn,getFileSystemManager:()=>vn}),dn=`difile://`,fn=`not supported in simulator`,pn=class{constructor(e){this.size=e.size||0,this.mode=e.mode||438,this.lastAccessedTime=e.lastAccessedTime||0,this.lastModifiedTime=e.lastModifiedTime||0,this._isFile=e.isFile===void 0?!0:e.isFile,this._isDirectory=e.isDirectory===void 0?!1:e.isDirectory}isFile(){return this._isFile}isDirectory(){return this._isDirectory}};function k(e){throw Error(`FileSystemManager.${e} ${fn}`)}function A(e,t={}){let{fail:n,complete:r}=t;n?.({errMsg:`${e}:fail ${fn}`}),r?.()}function mn(e){return e&&new pn(e)}function hn(e){if(!e||typeof e!=`object`)return e;let t={};for(let[n,r]of Object.entries(e))t[n]=new pn(r);return t}var gn=class{access(e){O(`fsAccess`,e)}accessSync(){k(`accessSync`)}stat(e={}){let{success:t,recursive:n,...r}=e;O(`fsStat`,{...r,recursive:n,success:e=>{if(!t)return;let r=n?hn(e?.stats):mn(e?.stats);t({...e,stats:r})}})}statSync(){k(`statSync`)}readFile(e){O(`fsReadFile`,e)}readFileSync(){k(`readFileSync`)}writeFile(e){O(`fsWriteFile`,e)}writeFileSync(){k(`writeFileSync`)}appendFile(e){O(`fsAppendFile`,e)}appendFileSync(){k(`appendFileSync`)}copyFile(e){O(`fsCopyFile`,e)}copyFileSync(){k(`copyFileSync`)}rename(e){O(`fsRename`,e)}renameSync(){k(`renameSync`)}unlink(e){O(`fsUnlink`,e)}unlinkSync(){k(`unlinkSync`)}mkdir(e){O(`fsMkdir`,e)}mkdirSync(){k(`mkdirSync`)}rmdir(e){O(`fsRmdir`,e)}rmdirSync(){k(`rmdirSync`)}readdir(e){O(`fsReaddir`,e)}readdirSync(){k(`readdirSync`)}getFileInfo(e){O(`fsGetFileInfo`,e)}saveFile(e){O(`fsSaveFile`,e)}saveFileSync(){k(`saveFileSync`)}getSavedFileList(e){O(`fsGetSavedFileList`,e)}removeSavedFile(e){O(`fsRemoveSavedFile`,e)}truncate(e){O(`fsTruncate`,e)}truncateSync(){k(`truncateSync`)}unzip(e){O(`fsUnzip`,e)}open(e){A(`open`,e)}openSync(){k(`openSync`)}close(e){A(`close`,e)}closeSync(){k(`closeSync`)}read(e){A(`read`,e)}readSync(){k(`readSync`)}write(e){A(`write`,e)}writeSync(){k(`writeSync`)}fstat(e){A(`fstat`,e)}fstatSync(){k(`fstatSync`)}ftruncate(e){A(`ftruncate`,e)}ftruncateSync(){k(`ftruncateSync`)}readCompressedFile(e){A(`readCompressedFile`,e)}readCompressedFileSync(){k(`readCompressedFileSync`)}readZipEntry(e){A(`readZipEntry`,e)}},_n;function vn(){return _n||=new gn,_n}var yn=[`onLaunch`,`onShow`,`onHide`],bn=[`globalData`],xn=class{constructor(e,t){this.appModule=e,this.options=t,this.init()}init(){this.initGlobalData(),this.initLifecycle(),this.initCustomMethods(),this.invokeSomeLifecycle()}initGlobalData(){this.globalData=this.appModule.moduleInfo.globalData}initLifecycle(){yn.forEach(e=>{let t=this.appModule.moduleInfo[e];n(t)&&(this[e]=t.bind(this))})}initCustomMethods(){let e=this.appModule.moduleInfo;for(let t in e)yn.includes(t)||bn.includes(t)||(n(e[t])?this[t]=e[t].bind(this):this[t]=e[t])}invokeSomeLifecycle(){this.onLaunch?.(this.options),this.onShow?.(this.options)}appShow(){this.onShow?.(this.options)}appHide(){this.onHide?.()}},Sn=new Set([`2d`]),Cn=new Set([`webgl`,`experimental-webgl`,`webgl2`]),wn=new Set([`createLinearGradient`,`createPattern`,`createRadialGradient`]),Tn=new Set([`createBuffer`,`createFramebuffer`,`createProgram`,`createRenderbuffer`,`createShader`,`createTexture`]),En=new Set([`getAttribLocation`,`getUniformLocation`]),j={DEPTH_BUFFER_BIT:256,STENCIL_BUFFER_BIT:1024,COLOR_BUFFER_BIT:16384,FALSE:0,TRUE:1,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,ZERO:0,ONE:1,SRC_COLOR:768,ONE_MINUS_SRC_COLOR:769,SRC_ALPHA:770,ONE_MINUS_SRC_ALPHA:771,DST_ALPHA:772,ONE_MINUS_DST_ALPHA:773,DST_COLOR:774,ONE_MINUS_DST_COLOR:775,SRC_ALPHA_SATURATE:776,FUNC_ADD:32774,BLEND_EQUATION:32777,BLEND_EQUATION_RGB:32777,BLEND_EQUATION_ALPHA:34877,FUNC_SUBTRACT:32778,FUNC_REVERSE_SUBTRACT:32779,BLEND_DST_RGB:32968,BLEND_SRC_RGB:32969,BLEND_DST_ALPHA:32970,BLEND_SRC_ALPHA:32971,CONSTANT_COLOR:32769,ONE_MINUS_CONSTANT_COLOR:32770,CONSTANT_ALPHA:32771,ONE_MINUS_CONSTANT_ALPHA:32772,BLEND_COLOR:32773,ARRAY_BUFFER:34962,ELEMENT_ARRAY_BUFFER:34963,ARRAY_BUFFER_BINDING:34964,ELEMENT_ARRAY_BUFFER_BINDING:34965,STREAM_DRAW:35040,STATIC_DRAW:35044,DYNAMIC_DRAW:35048,BUFFER_SIZE:34660,BUFFER_USAGE:34661,CURRENT_VERTEX_ATTRIB:34342,FRONT:1028,BACK:1029,FRONT_AND_BACK:1032,CULL_FACE:2884,BLEND:3042,DITHER:3024,STENCIL_TEST:2960,DEPTH_TEST:2929,SCISSOR_TEST:3089,POLYGON_OFFSET_FILL:32823,SAMPLE_ALPHA_TO_COVERAGE:32926,SAMPLE_COVERAGE:32928,NO_ERROR:0,INVALID_ENUM:1280,INVALID_VALUE:1281,INVALID_OPERATION:1282,OUT_OF_MEMORY:1285,CW:2304,CCW:2305,LINE_WIDTH:2849,ALIASED_POINT_SIZE_RANGE:33901,ALIASED_LINE_WIDTH_RANGE:33902,CULL_FACE_MODE:2885,FRONT_FACE:2886,DEPTH_RANGE:2928,DEPTH_WRITEMASK:2930,DEPTH_CLEAR_VALUE:2931,DEPTH_FUNC:2932,STENCIL_CLEAR_VALUE:2961,STENCIL_FUNC:2962,STENCIL_FAIL:2964,STENCIL_PASS_DEPTH_FAIL:2965,STENCIL_PASS_DEPTH_PASS:2966,STENCIL_REF:2967,STENCIL_VALUE_MASK:2963,STENCIL_WRITEMASK:2968,STENCIL_BACK_FUNC:34816,STENCIL_BACK_FAIL:34817,STENCIL_BACK_PASS_DEPTH_FAIL:34818,STENCIL_BACK_PASS_DEPTH_PASS:34819,STENCIL_BACK_REF:36003,STENCIL_BACK_VALUE_MASK:36004,STENCIL_BACK_WRITEMASK:36005,VIEWPORT:2978,SCISSOR_BOX:3088,COLOR_CLEAR_VALUE:3106,COLOR_WRITEMASK:3107,UNPACK_ALIGNMENT:3317,PACK_ALIGNMENT:3333,MAX_TEXTURE_SIZE:3379,MAX_VIEWPORT_DIMS:3386,SUBPIXEL_BITS:3408,RED_BITS:3410,GREEN_BITS:3411,BLUE_BITS:3412,ALPHA_BITS:3413,DEPTH_BITS:3414,STENCIL_BITS:3415,POLYGON_OFFSET_UNITS:10752,POLYGON_OFFSET_FACTOR:32824,TEXTURE_BINDING_2D:32873,SAMPLE_BUFFERS:32936,SAMPLES:32937,SAMPLE_COVERAGE_VALUE:32938,SAMPLE_COVERAGE_INVERT:32939,COMPRESSED_TEXTURE_FORMATS:34467,DONT_CARE:4352,FASTEST:4353,NICEST:4354,GENERATE_MIPMAP_HINT:33170,BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,INT:5124,UNSIGNED_INT:5125,FLOAT:5126,DEPTH_COMPONENT:6402,ALPHA:6406,RGB:6407,RGBA:6408,LUMINANCE:6409,LUMINANCE_ALPHA:6410,UNSIGNED_SHORT_4_4_4_4:32819,UNSIGNED_SHORT_5_5_5_1:32820,UNSIGNED_SHORT_5_6_5:33635,FRAGMENT_SHADER:35632,VERTEX_SHADER:35633,MAX_VERTEX_ATTRIBS:34921,MAX_VERTEX_UNIFORM_VECTORS:36347,MAX_VARYING_VECTORS:36348,MAX_COMBINED_TEXTURE_IMAGE_UNITS:35661,MAX_VERTEX_TEXTURE_IMAGE_UNITS:35660,MAX_TEXTURE_IMAGE_UNITS:34930,MAX_FRAGMENT_UNIFORM_VECTORS:36349,SHADER_TYPE:35663,DELETE_STATUS:35712,LINK_STATUS:35714,VALIDATE_STATUS:35715,ATTACHED_SHADERS:35717,ACTIVE_UNIFORMS:35718,ACTIVE_ATTRIBUTES:35721,SHADING_LANGUAGE_VERSION:35724,CURRENT_PROGRAM:35725,NEVER:512,LESS:513,EQUAL:514,LEQUAL:515,GREATER:516,NOTEQUAL:517,GEQUAL:518,ALWAYS:519,KEEP:7680,REPLACE:7681,INCR:7682,DECR:7683,INVERT:5386,INCR_WRAP:34055,DECR_WRAP:34056,VENDOR:7936,RENDERER:7937,VERSION:7938,NEAREST:9728,LINEAR:9729,NEAREST_MIPMAP_NEAREST:9984,LINEAR_MIPMAP_NEAREST:9985,NEAREST_MIPMAP_LINEAR:9986,LINEAR_MIPMAP_LINEAR:9987,TEXTURE_MAG_FILTER:10240,TEXTURE_MIN_FILTER:10241,TEXTURE_WRAP_S:10242,TEXTURE_WRAP_T:10243,TEXTURE_2D:3553,TEXTURE:5890,TEXTURE_CUBE_MAP:34067,TEXTURE_BINDING_CUBE_MAP:34068,TEXTURE_CUBE_MAP_POSITIVE_X:34069,TEXTURE_CUBE_MAP_NEGATIVE_X:34070,TEXTURE_CUBE_MAP_POSITIVE_Y:34071,TEXTURE_CUBE_MAP_NEGATIVE_Y:34072,TEXTURE_CUBE_MAP_POSITIVE_Z:34073,TEXTURE_CUBE_MAP_NEGATIVE_Z:34074,MAX_CUBE_MAP_TEXTURE_SIZE:34076,TEXTURE0:33984,TEXTURE1:33985,TEXTURE2:33986,TEXTURE3:33987,TEXTURE4:33988,TEXTURE5:33989,TEXTURE6:33990,TEXTURE7:33991,TEXTURE8:33992,TEXTURE9:33993,TEXTURE10:33994,TEXTURE11:33995,TEXTURE12:33996,TEXTURE13:33997,TEXTURE14:33998,TEXTURE15:33999,TEXTURE16:34e3,TEXTURE17:34001,TEXTURE18:34002,TEXTURE19:34003,TEXTURE20:34004,TEXTURE21:34005,TEXTURE22:34006,TEXTURE23:34007,TEXTURE24:34008,TEXTURE25:34009,TEXTURE26:34010,TEXTURE27:34011,TEXTURE28:34012,TEXTURE29:34013,TEXTURE30:34014,TEXTURE31:34015,ACTIVE_TEXTURE:34016,REPEAT:10497,CLAMP_TO_EDGE:33071,MIRRORED_REPEAT:33648,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,INT_VEC2:35667,INT_VEC3:35668,INT_VEC4:35669,BOOL:35670,BOOL_VEC2:35671,BOOL_VEC3:35672,BOOL_VEC4:35673,FLOAT_MAT2:35674,FLOAT_MAT3:35675,FLOAT_MAT4:35676,SAMPLER_2D:35678,SAMPLER_CUBE:35680,LOW_FLOAT:36336,MEDIUM_FLOAT:36337,HIGH_FLOAT:36338,LOW_INT:36339,MEDIUM_INT:36340,HIGH_INT:36341,FRAMEBUFFER:36160,RENDERBUFFER:36161,RGBA4:32854,RGB5_A1:32855,RGB565:36194,DEPTH_COMPONENT16:33189,STENCIL_INDEX8:36168,DEPTH_STENCIL:34041,RENDERBUFFER_WIDTH:36162,RENDERBUFFER_HEIGHT:36163,RENDERBUFFER_INTERNAL_FORMAT:36164,RENDERBUFFER_RED_SIZE:36176,RENDERBUFFER_GREEN_SIZE:36177,RENDERBUFFER_BLUE_SIZE:36178,RENDERBUFFER_ALPHA_SIZE:36179,RENDERBUFFER_DEPTH_SIZE:36180,RENDERBUFFER_STENCIL_SIZE:36181,FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE:36048,FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:36049,FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL:36050,FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE:36051,COLOR_ATTACHMENT0:36064,DEPTH_ATTACHMENT:36096,STENCIL_ATTACHMENT:36128,DEPTH_STENCIL_ATTACHMENT:33306,NONE:0,FRAMEBUFFER_COMPLETE:36053,FRAMEBUFFER_INCOMPLETE_ATTACHMENT:36054,FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:36055,FRAMEBUFFER_INCOMPLETE_DIMENSIONS:36057,FRAMEBUFFER_UNSUPPORTED:36061,FRAMEBUFFER_BINDING:36006,RENDERBUFFER_BINDING:36007,MAX_RENDERBUFFER_SIZE:34024,INVALID_FRAMEBUFFER_OPERATION:1286,UNPACK_FLIP_Y_WEBGL:37440,UNPACK_PREMULTIPLY_ALPHA_WEBGL:37441,CONTEXT_LOST_WEBGL:37442,UNPACK_COLORSPACE_CONVERSION_WEBGL:37443,BROWSER_DEFAULT_WEBGL:37444,COMPILE_STATUS:35713},Dn=1,On=1;function M(){let e=D.getPageInfo();return e?.bridgeId||e?.id||``}function N(e,t,n){E.send({type:`invokeAPI`,target:`render`,body:{bridgeId:e,name:t,params:n}})}function kn(e){Promise.resolve().then(e)}function An(e){return Object.prototype.toString.call(e)===`[object Object]`}function jn(e){return typeof ArrayBuffer>`u`||!ArrayBuffer.isView(e)?null:e instanceof DataView?{__canvasTypedArray:`DataView`,data:Array.from(new Uint8Array(e.buffer,e.byteOffset,e.byteLength))}:{__canvasTypedArray:e.constructor.name,data:Array.from(e)}}function P(e){if(e==null)return e;if(e.__canvasResourceId)return{__canvasResourceId:e.__canvasResourceId};if(e.__diminaCanvasNode)return{__canvasNodeId:e.nodeId};let t=jn(e);if(t)return t;if(typeof ArrayBuffer<`u`&&e instanceof ArrayBuffer)return{__canvasArrayBuffer:!0,data:Array.from(new Uint8Array(e))};if(Array.isArray(e))return e.map(e=>P(e));if(An(e)){let t={};for(let[n,r]of Object.entries(e))t[n]=P(r);return t}return e}function F(e){return Array.from(e).map(e=>P(e))}function I(e=`canvas_resource`){return`${e}_${g()}`}var Mn=class{constructor(e,t){return this.__canvasResourceId=t,this.__canvasProxyValue=Dn++,this.canvas=e,new Proxy(this,{get(e,n){if(n in e)return e[n];if(typeof n!=`symbol`)return(...r)=>{e.canvas.enqueueOperation({op:`resourceCall`,resourceId:t,method:n,args:F(r)})}}})}valueOf(){return this.__canvasProxyValue}toString(){return String(this.__canvasProxyValue)}},Nn=class{constructor(e,t){this.__canvasResourceId=t,this.canvas=e,this.imageId=t,this.onload=null,this.onerror=null,this.width=0,this.height=0,this._src=``,this.canvas.enqueueOperation({op:`createImage`,imageId:t})}get src(){return this._src}set src(e){this._src=e;let t=w.store((e={})=>{this.width=e.width||this.width,this.height=e.height||this.height,n(this.onload)&&this.onload(e)}),r=w.store((e={})=>{n(this.onerror)&&this.onerror(e)});this.canvas.enqueueOperation({op:`imageSetSrc`,imageId:this.imageId,src:e,onload:t,onerror:r})}},Pn=class{constructor(e,t){return this.canvas=e,this.contextId=t,this.state={fillStyle:`#000000`,strokeStyle:`#000000`,font:`10px sans-serif`,globalAlpha:1,lineWidth:1},new Proxy(this,{get(e,t){if(t in e)return e[t];if(t in e.state)return e.state[t];if(typeof t!=`symbol`)return(...n)=>e.call(t,n)},set(e,n,r){return e.state[n]=r,e.canvas.enqueueOperation({op:`contextSetProperty`,contextId:t,prop:n,value:P(r)}),!0}})}call(e,t){if(e===`measureText`)return{width:String(t[0]??``).length*10};let n=wn.has(e)?I():void 0;if(this.canvas.enqueueOperation({op:`contextCall`,contextId:this.contextId,method:e,args:F(t),resultId:n}),n)return new Mn(this.canvas,n)}},Fn=class{constructor(e,t,n){return this.canvas=e,this.contextId=t,this.contextType=n,new Proxy(this,{get(e,t){if(t in e)return e[t];if(Object.prototype.hasOwnProperty.call(j,t))return j[t];if(t===`drawingBufferWidth`)return e.canvas.width;if(t===`drawingBufferHeight`)return e.canvas.height;if(typeof t!=`symbol`)return(...n)=>e.call(t,n)}})}call(e,t){switch(e){case`getParameter`:return this.getParameter(t[0]);case`getShaderParameter`:case`getProgramParameter`:return!0;case`getShaderInfoLog`:case`getProgramInfoLog`:return``;case`getError`:return j.NO_ERROR;case`isContextLost`:return!1;case`checkFramebufferStatus`:return j.FRAMEBUFFER_COMPLETE;case`getContextAttributes`:return{};case`getSupportedExtensions`:return[];case`getExtension`:return null;default:break}let n=Tn.has(e)||En.has(e)?I(`webgl_resource`):void 0;if(this.canvas.enqueueOperation({op:`contextCall`,contextId:this.contextId,method:e,args:F(t),resultId:n}),n)return new Mn(this.canvas,n)}getParameter(e){let{width:t,height:n}=this.canvas;switch(e){case j.VERSION:return`WebGL 1.0`;case j.SHADING_LANGUAGE_VERSION:return`WebGL GLSL ES 1.0`;case j.VENDOR:return`Dimina`;case j.RENDERER:return`Dimina WebGL Proxy`;case j.VIEWPORT:return[0,0,t,n];case j.MAX_VIEWPORT_DIMS:return[t||4096,n||4096];case j.ALIASED_POINT_SIZE_RANGE:return[1,64];case j.ALIASED_LINE_WIDTH_RANGE:return[1,1];case j.COLOR_CLEAR_VALUE:return[0,0,0,0];case j.COLOR_WRITEMASK:case j.DEPTH_WRITEMASK:return!0;case j.COMPRESSED_TEXTURE_FORMATS:return[];case j.MAX_TEXTURE_SIZE:case j.MAX_CUBE_MAP_TEXTURE_SIZE:case j.MAX_RENDERBUFFER_SIZE:return 4096;case j.MAX_VERTEX_ATTRIBS:return 16;case j.MAX_TEXTURE_IMAGE_UNITS:case j.MAX_VERTEX_TEXTURE_IMAGE_UNITS:case j.MAX_COMBINED_TEXTURE_IMAGE_UNITS:return 8;case j.MAX_VERTEX_UNIFORM_VECTORS:case j.MAX_FRAGMENT_UNIFORM_VECTORS:case j.MAX_VARYING_VECTORS:return 128;default:return 0}}},In=class{constructor({nodeId:e,bridgeId:t=M(),width:n=300,height:r=150,type:i=`2d`,offscreen:a=!1}){this.__diminaCanvasNode=!0,this.nodeId=e,this.bridgeId=t,this.type=i,this.offscreen=a,this.contexts=new Map,this.pendingOperations=[],this.flushScheduled=!1,this._width=n,this._height=r}get width(){return this._width}set width(e){this._width=e,this.enqueueOperation({op:`setCanvasProperty`,prop:`width`,value:e})}get height(){return this._height}set height(e){this._height=e,this.enqueueOperation({op:`setCanvasProperty`,prop:`height`,value:e})}getContext(e=`2d`,t){let n=String(e).toLowerCase();if(!Sn.has(n)&&!Cn.has(n))return null;if(this.contexts.has(n))return this.contexts.get(n);let r=I(`canvas_context`);this.enqueueOperation({op:`getContext`,contextId:r,contextType:n,attributes:P(t)});let i=Cn.has(n)?new Fn(this,r,n):new Pn(this,r);return this.contexts.set(n,i),i}createImage(){return new Nn(this,I(`canvas_image`))}requestAnimationFrame(e){let t=On++,r=w.store(t=>{n(e)&&e(t)});return N(this.bridgeId,`canvasNodeRequestAnimationFrame`,{nodeId:this.nodeId,requestId:t,callback:r}),t}cancelAnimationFrame(e){N(this.bridgeId,`canvasNodeCancelAnimationFrame`,{nodeId:this.nodeId,requestId:e})}enqueueOperation(e){this.pendingOperations.push(e),!this.flushScheduled&&(this.flushScheduled=!0,kn(()=>this.flushOperations()))}flushOperations(){if(this.flushScheduled=!1,this.pendingOperations.length===0)return;let e=this.pendingOperations;this.pendingOperations=[],N(this.bridgeId,`canvasNodeFlush`,{nodeId:this.nodeId,operations:e})}};function Ln(e,t=M()){return!e||e.__diminaNodeType!==`dimina-canvas-node`?e:new In({nodeId:e.nodeId,bridgeId:t,width:e.width,height:e.height,type:e.type})}function Rn(e,t=M()){return Array.isArray(e)?e.map(e=>Rn(e,t)):!e||typeof e!=`object`?e:e.node?{...e,node:Ln(e.node,t)}:e}function zn(e={}){let t=Number(e.width)||300,n=Number(e.height)||150,r=e.type||`2d`,i=I(`offscreen_canvas`),a=M();return N(a,`createOffscreenCanvas`,{nodeId:i,width:t,height:n,type:r}),new In({nodeId:i,bridgeId:a,width:t,height:n,type:r,offscreen:!0})}var Bn=t({createSelectorQuery:()=>L});function L(){return new Wn}function Vn(){return D.getPageInfo()}function Hn(){let e=Vn();return e?.__id__||e?.id}function Un(){let e=Vn();return e?.bridgeId||e?.id}var Wn=class{constructor(){this.__componentId=Hn(),this.__taskQueue=[],this.__cbQueue=[]}in(e){return this.__componentId=e.__id__,this}select(e){return new R(this,this.__componentId,e,!0)}selectAll(e){return new R(this,this.__componentId,e,!1)}selectViewport(){return new R(this,Hn(),``,!0)}__push(e,t,n,r,i){this.__taskQueue.push({moduleId:t,selector:e,single:n,fields:r}),this.__cbQueue.push(i)}exec(e){let t=this,r=Un();O(`selectorQuery`,{tasks:this.__taskQueue,success:i=>{let a=Rn(i,r)||[];a.forEach((e,r)=>{let i=t.__cbQueue[r];n(i)&&i.call(t,e)}),n(e)&&e.call(t,a)}},`render`)}},R=class{constructor(e,t,n,r){this.__selectorQuery=e,this.__moduleId=t,this.__selector=n,this.__single=r}fields(e,t){return this.__selectorQuery.__push(this.__selector,this.__moduleId,this.__single,e,t),this.__selectorQuery}boundingClientRect(e){return this.fields({id:!0,dataset:!0,rect:!0,size:!0},e)}context(e){return this.fields({context:!0},e)}node(e){return this.fields({node:!0},e)}scrollOffset(e){return this.fields({id:!0,dataset:!0,scrollOffset:!0},e)}},Gn=t({createIntersectionObserver:()=>Kn});function Kn(e,t={}){let{thresholds:n=[0],initialRatio:r=0,observeAll:i=!1}=t;return new qn(e,{thresholds:n,initialRatio:r,observeAll:i})}var qn=class{constructor(e,t){this._component=e,this._options=t,this._relativeInfo=[],this._observerId=null,this._disconnected=!1}relativeTo(e,t={left:0,right:0,top:0,bottom:0}){if(this._observerId!==null)throw Error(`Relative nodes cannot be added after "observe" call in IntersectionObserver`);return this._relativeInfo.push({selector:e,margins:[`left`,`right`,`top`,`bottom`].map(e=>`${t[e]===void 0?0:t[e]}px`).join(` `)}),this}relativeToViewport(e={left:0,right:0,top:0,bottom:0}){if(this._observerId!==null)throw Error(`Relative nodes cannot be added after "observe" call in IntersectionObserver`);return this._relativeInfo.push({selector:null,margins:[`left`,`right`,`top`,`bottom`].map(t=>`${e[t]===void 0?0:e[t]}px`).join(` `)}),this}observe(e,t){let n=this,r=w.store(e=>{n._disconnected||(n._observerId=e.observerId),e.info&&t.call(n,e.info)},!0);O(`addIntersectionObserver`,{moduleId:this._component.__id__,targetSelector:e,relativeInfo:this._relativeInfo,options:this._options,success:r},`render`)}disconnect(){O(`removeIntersectionObserver`,{observerId:this._observerId},`render`),this._disconnected=!0}},z=new Map;function B(e){return z.has(e)||z.set(e,{depth:0,scheduled:!1,updates:[],byModuleId:new Map,callbackIds:[]}),z.get(e)}function V(e,t){let r=(Array.isArray(t)?t:[t]).filter(n);if(r.length!==0)return w.store(()=>{r.forEach(t=>t.call(e))})}function Jn(e){let t=B(e);t.depth++}function Yn(e){let t=B(e);t.depth>0&&t.depth--,t.depth===0&&Xn(e)}function H(e,t,n,r){let i=B(e),a=i.byModuleId.get(t);if(a)Object.assign(a.data,n);else{let e={moduleId:t,data:{...n}};i.byModuleId.set(t,e),i.updates.push(e)}r&&i.callbackIds.push(r),i.depth===0&&!i.scheduled&&(i.scheduled=!0,Promise.resolve().then(()=>{i.scheduled=!1,i.depth===0&&Xn(e)}))}function Xn(e){let t=z.get(e);if(!t||t.updates.length===0)return;let n=t.updates,r=t.callbackIds;t.updates=[],t.byModuleId=new Map,t.callbackIds=[],t.scheduled=!1,E.send({type:`ub`,target:`render`,body:{bridgeId:e,updates:n,callbackIds:r}})}function Zn(e){let t=e.__mpxProxy?.options?.computed;if(t)for(let n of Object.keys(t))Object.prototype.hasOwnProperty.call(e.data,n)||(e.data[n]=null)}function U(e){return i(e)?e:Object.entries(e).reduce((e,[t,r])=>t.startsWith(`$`)?e:n(r)?(console.warn(`[service] 值不支持函数引用`,t),e):(Array.isArray(r)?e[t]=r.map(e=>typeof e==`object`&&e?e instanceof Date?e.getTime():U(e):e):r&&typeof r==`object`&&!Array.isArray(r)?r instanceof Date?e[t]=r.getTime():e[t]=U(r):e[t]=r,e),{})}function Qn(e){if(e){let t={};for(let r in e){let i=e[r];t[r]=t[r]||{};let a=i&&typeof i==`object`&&Object.prototype.hasOwnProperty.call(i,`type`)?W(i.type):W(i),o=null;if(o=Array.isArray(a)?[...a]:[a],i&&i.optionalTypes){let e=W(i.optionalTypes);Array.isArray(e)?o=[...e]:o.push(e)}t[r].type=o,t[r].type.length>0&&(i&&n(i.value)?t[r].default=i.value():i&&(t[r].default=i.value))}return t}}var $n=new Map([[String,`s`],[Number,`n`],[Boolean,`b`],[Object,`o`],[Array,`a`],[Function,`f`]]);function W(e){return Array.isArray(e)?e.map(e=>W(e)):e===null||e===``?null:$n.get(e)||(console.warn(`[service] ignore unknown props type ${e}`),null)}function er(e,t,n,r,i){let a=new Set;for(let o of e)for(let e in t){if(a.has(e))continue;let s=e.split(`,`).map(e=>e.trim());if(s.includes(o)){a.add(e);let c=t[e],l=s.map(e=>h(n,e));s.length===1?c.call(r,...l,i[o]):c.call(r,...l);continue}if(e===`**`){a.add(e),t[e].call(r,n);continue}let c=e.split(`.`),l=o.split(`.`),u=!0;for(let e=0;e<c.length&&!(c[e]===`**`||l[e]===void 0);e++)if(c[e]!==l[e]){u=!1;break}if(u&&c.length>1){a.add(e);let s=n;for(let e of c)e!==`**`&&(s=s?.[e]);e===o?t[e].call(r,s,i[o]):t[e].call(r,s)}}}function tr(e,t,n,r,i){for(let a in t){let o=t[a],s=a.split(`,`).map(e=>e.trim());if(s.includes(e)){let t=s.map(e=>h(n,e));s.length===1&&s[0]===e?o.call(r,...t,i):o.call(r,...t);continue}if(a===`**`){o.call(r,n);continue}let c=a.split(`.`),l=e.split(`.`),u=!0;for(let e=0;e<c.length&&!(c[e]===`**`||l[e]===void 0);e++)if(c[e]!==l[e]){u=!1;break}if(u){let t=n;for(let e of c)e!==`**`&&(t=t[e]);a===e?o.call(r,t,i):o.call(r,t);continue}let d=a.match(/^(.+)\[(\d+)\]$/);if(d){let t=d[1],i=Number.parseInt(d[2],10);if(t===e.split(`[`)[0]&&n[t]&&n[t][i]!==void 0){o.call(r,n[t][i]);continue}}if(e.startsWith(a)){let e=a.split(`.`).reduce((e,t)=>e&&e[t],n);if(e!==void 0){o.call(r,e);continue}}}}function nr(e={},t=``){let n=t.trim();if(!n)return;let r=n.replace(/-/g,``).toLowerCase(),i=[n,oe(n),se(n),r];for(let t of i)if(t&&e[t]!==void 0)return e[t]}function G(e,t,n){let r=e.__info__||{};if(r.behaviorObservers)for(let i in r.behaviorObservers){let a=r.behaviorObservers[i];if(!(!Array.isArray(a)||a.length===0))for(let r of t)a.forEach(t=>{tr(r,{[i]:t},e.data,e,n[r])})}}function rr(e,t,n){ar(e,t,n)}function ir(e,t,i){let a=[];for(let o of t){let t=e.__info__.properties?.[o]?.observer,s=e.data[o],c=i[o];r(t)?a.push(()=>e[t]?.(s,c)):n(t)&&a.push(()=>t.call(e,s,c))}return a}function ar(e,t,n){ir(e,t,n).reverse().forEach(e=>e())}function or(e,t){if(!Array.isArray(t))return;let r=new WeakMap;function i(e,t){let n={...e};for(let e in t)if(Object.prototype.hasOwnProperty.call(t,e)){let r=n[e],a=t[e];r&&typeof r==`object`&&!Array.isArray(r)&&a&&typeof a==`object`&&!Array.isArray(a)?n[e]=i(r,a):n[e]=a}return n}function a(e,t){if(typeof t==`string`){o(e,t);return}if(!t||typeof t!=`object`||r.has(t))return;r.set(t,!0),Array.isArray(t.behaviors)&&t.behaviors.forEach(t=>a(e,t)),t.properties&&(e.properties={...t.properties,...e.properties}),t.data&&(e.data||={},e.data=i(t.data,e.data));let s=[`created`,`attached`,`ready`,`detached`];e.behaviorLifetimes=e.behaviorLifetimes||{};for(let r of s)n(t[r])&&(e.behaviorLifetimes[r]=e.behaviorLifetimes[r]||[],e.behaviorLifetimes[r].push(t[r]));if(t.observers){e.behaviorObservers=e.behaviorObservers||{};for(let n in t.observers)e.behaviorObservers[n]||(e.behaviorObservers[n]=[]),e.behaviorObservers[n].push(t.observers[n])}if(t.methods&&(e.methods={...t.methods,...e.methods}),t.relations&&(e.relations={...e.relations,...t.relations}),t.export&&(e.export=t.export),t.pageLifetimes){e.behaviorPageLifetimes=e.behaviorPageLifetimes||{};for(let r of[`show`,`hide`,`resize`,`routeDone`])n(t.pageLifetimes[r])&&(e.behaviorPageLifetimes[r]=e.behaviorPageLifetimes[r]||[],e.behaviorPageLifetimes[r].push(t.pageLifetimes[r]))}}function o(e,t){switch(t){case`wx://component-export`:break;case`wx://form-field`:break;case`wx://form-field-button`:break;default:console.warn(`[service] 未知的内置 behavior: ${t}`)}}t.forEach(t=>a(e,t))}function K(e,t,n){let r=e;for(;r&&r.__parentId__;){if(r.__parentId__===t)return!0;r=n.find(e=>e.__id__===r.__parentId__)}return!1}function q(e,t){if(!e||!t)return!1;if(e.startsWith(`#`)){let n=e.slice(1);return t.id===n}if(e.startsWith(`.`)){let n=e.slice(1);return t.__targetInfo__?.class&&t.__targetInfo__.class.split(` `).includes(n)}if(e.startsWith(`[`)&&e.endsWith(`]`)){let n=e.slice(1,-1).match(/^(\w+)(?:=["']?([^"']*)["']?)?$/);if(n){let[,e,r]=n,i=t.__targetInfo__?.dataset||{};return r===void 0?Object.prototype.hasOwnProperty.call(i,e):i[e]===r}return!1}return t.is?t.is.split(`/`).pop()===e||t.is===e:!1}function sr(e,t){if(!e||!Array.isArray(e.dependencies))return!1;for(let n of e.dependencies){if(n in t)return!0;for(let e of Object.keys(t))if(e.startsWith(n+`.`)||e.startsWith(n+`[`)||n.startsWith(e+`.`)||n.startsWith(e+`[`))return!0}return!1}function cr(e,t){if(!(!e||!e.expression)){if(e.isSimple)return h(t,e.expression);try{return Function(`data`,`with(data) { return ${e.expression} }`)(t)}catch(t){console.warn(`[service] 计算表达式失败:`,e.expression,t);return}}}function J(e,t,n){let r=Object.values(t||{}),i=[];for(let t of r){if(!K(t,e.__id__,r)||t.__parentId__!==e.__id__)continue;let a=t.__info__?.properties||{},o={};for(let r in a){let i=e.__childPropsBindings__?.[t.__id__]?.[r];i&&sr(i,n)&&(o[r]=cr(i,e.data))}Object.keys(o).length>0&&(t.tO?.(o),t.__pendingSyncedProps__=t.__pendingSyncedProps__||{},Object.assign(t.__pendingSyncedProps__,o),i.push({child:t,data:o}))}return i}var lr=[`created`,`attached`,`ready`,`moved`,`detached`,`error`],ur=[`show`,`hide`,`resize`,`routeDone`],dr=class{constructor(e,t){this.initd=!1,this.opts=t,t.targetInfo&&(this.id=t.targetInfo.id,this.dataset=t.targetInfo.dataset,this.__targetInfo__=t.targetInfo),this.is=t.path,this.route=t.path,this.query=t.query,this.renderer=`webview`,this.bridgeId=t.bridgeId,this.id||=t.bridgeId,this.behaviors=e.behaviors,this.data=le(e.noReferenceData),Object.defineProperty(this,"properties",{get(){return this.data},enumerable:!0,configurable:!1}),this.__isComponent__=e.isComponent,this.__type__=e.type,this.__id__=this.opts.moduleId,this.__info__=e.moduleInfo,this.__eventAttr__=t.eventAttr,this.__pageId__=t.pageId,this.__parentId__=t.parentId,this.__relations__=new Map,this.__relationPaths__=new Map,this.__groupSetDataMode__=!1,this.__groupSetDataBuffer__={},this.__groupSetDataCallbacks__=[],this.__pendingInitSetDataCallbacks__=[],this.__childPropsBindings__={},this.__pendingSyncedProps__={},this.__initialPropertyObserversInvoked__=!1}init(){if(this.__isComponent__)for(let e in this.__info__.properties)!Object.prototype.hasOwnProperty.call(this.opts.properties,e)||this.opts.properties[e]===void 0?this.data[e]=this.__info__.properties[e]?.value??null:this.data[e]=this.opts.properties[e];return this.#d(),this.#f(),this.#t(),this.#e(),this.#m().then(()=>{Zn(this),E.send({type:this.__id__,target:`render`,body:{bridgeId:this.bridgeId,path:this.is,data:this.data}})})}flushInitSetDataCallbacks(){if(this.__pendingInitSetDataCallbacks__.length===0)return;let e=this.__pendingInitSetDataCallbacks__;this.__pendingInitSetDataCallbacks__=[],H(this.bridgeId,this.__id__,{},V(this,e))}#e(){this.hasBehavior(`wx://component-export`)&&this.__info__.export&&n(this.__info__.export)&&(this.export=this.__info__.export.bind(this))}#t(){let e=this.__info__.relations;if(!(!e||typeof e!=`object`))for(let[t]of Object.entries(e)){let e=this.#n(t);this.__relationPaths__.set(t,e),this.__relations__.has(t)||this.__relations__.set(t,[])}}#n(e){if(e.startsWith(`./`)){let t=this.is.lastIndexOf(`/`);return t===-1?e.substring(2):`${this.is.substring(0,t)}/${e.substring(2)}`}else if(e.startsWith(`../`)){let t=this.is.split(`/`),n=e.split(`/`),r=t.slice(0,-1);for(let e of n)e===`..`?r.pop():e!==`.`&&r.push(e);return r.join(`/`)}else return e}#r(){let e=this.__info__.relations;if(!e)return;let t=Object.values($.instances[this.bridgeId]||{});for(let[n,r]of Object.entries(e)){let{type:e,target:i}=r,a=this.__relationPaths__.get(n),o=t.filter(e=>i?e.hasBehavior&&e.hasBehavior(i):e.is===a||e.is.endsWith(`/${a}`)).filter(t=>this.#o(t,e)||this.#a(t,e));for(let e of o)this.#c(n,e,r)}this.#i()}#i(){let e=Object.values($.instances[this.bridgeId]||{});for(let t of e)t!==this&&t._checkRelationsWithTarget&&t._checkRelationsWithTarget(this)}_checkRelationsWithTarget(e){let t=this.__info__.relations;if(t)for(let[n,r]of Object.entries(t)){let{type:t,target:i}=r,a=this.__relationPaths__.get(n),o=!1;o=i?e.hasBehavior&&e.hasBehavior(i):e.is===a||e.is.endsWith(`/${a}`);let s=this.#o(e,t),c=this.#a(e,t);o&&(s||c)&&this.#c(n,e,r)}}#a(e,t){if(t!==`descendant`&&t!==`ancestor`)return!1;let n=t===`descendant`?`ancestor`:`descendant`,r=e.__info__?.relations;return r?Object.entries(r).some(([t,r])=>{let i=e.__relationPaths__?.get(t);return r.type===n&&(this.is===i||this.is.endsWith(`/${i}`))}):!1}#o(e,t){let n=Object.values($.instances[this.bridgeId]||{});switch(t){case`parent`:return e.__id__===this.__parentId__;case`child`:return e.__parentId__===this.__id__;case`ancestor`:return this.#s(e.__id__,this.__id__,n);case`descendant`:return this.#s(this.__id__,e.__id__,n);default:return!1}}#s(e,t,n){let r=n.find(e=>e.__id__===t);for(;r&&r.__parentId__;){if(r.__parentId__===e)return!0;r=n.find(e=>e.__id__===r.__parentId__)}return!1}#c(e,t,r){let i=this.__relations__.get(e)||[];if(!i.includes(t)&&(i.push(t),this.__relations__.set(e,i),n(r.linked)))try{r.linked.call(this,t)}catch(e){console.error(`[service] relation linked error:`,e)}}#l(e,t,r){let i=this.__relations__.get(e)||[],a=i.indexOf(t);if(a!==-1&&(i.splice(a,1),this.__relations__.set(e,i),n(r.unlinked)))try{r.unlinked.call(this,t)}catch(e){console.error(`[service] relation unlinked error:`,e)}}#u(e,t,r){if(n(r.linkChanged))try{r.linkChanged.call(this,t)}catch(e){console.error(`[service] relation linkChanged error:`,e)}}setData(e,t){let r=U(e),i={};for(let e in r)i[e]=this.data[e],re(this.data,e,r[e]);if(this.__info__.observers&&er(Object.keys(r),this.__info__.observers,this.data,this,i),G(this,Object.keys(r),i),rr(this,Object.keys(r),i),!this.initd){n(t)&&this.__pendingInitSetDataCallbacks__.push(t);return}if(this.__groupSetDataMode__){for(let e in r)this.__groupSetDataBuffer__[e]=r[e];n(t)&&this.__groupSetDataCallbacks__.push(t);return}let a=J(this,$.instances[this.bridgeId],r);H(this.bridgeId,this.__id__,r,V(this,t)),a.forEach(({child:e,data:t})=>{H(this.bridgeId,e.__id__,t)})}#d(){lr.forEach(e=>{let t=this.__info__.lifetimes?.[e]||this.__info__[e];n(t)&&(this[e]=t.bind(this))}),this.__isComponent__&&ur.forEach(e=>{let t=this.__info__.pageLifetimes?.[e];n(t)&&(e===`show`?e=`onShow`:e===`hide`&&(e=`onHide`),this[e]=t.bind(this))})}#f(){let e=this.__info__.methods;for(let t in e)n(e[t])&&(this[t]=e[t].bind(this))}#p(){if(!this.__isComponent__||!this.__info__.properties||this.__initialPropertyObserversInvoked__)return;let e=[];for(let t of Object.keys(this.__info__.properties)){let i=this.__info__.properties[t]?.observer,a=this.data[t];r(i)?e.push(()=>this[i]?.(a,void 0)):n(i)&&e.push(()=>i.call(this,a,void 0))}e.forEach(e=>e()),this.__initialPropertyObserversInvoked__=!0}async#m(){this.__isComponent__?(await this.componentCreated(),await this.componentAttached()):(await this.componentCreated(),await this.componentAttached(),await this.onLoad?.(this.opts.query||{})),this.initd=!0}tO(e){let t={};for(let[n,r]of Object.entries(e)){if(this.__pendingSyncedProps__&&Object.prototype.hasOwnProperty.call(this.__pendingSyncedProps__,n)&&a(this.__pendingSyncedProps__[n],r)){this.data[n]=r,delete this.__pendingSyncedProps__[n];continue}t[n]=r}if(Object.keys(t).length===0)return;let n=[],r={};for(let[e,i]of Object.entries(t)){let t=this.data[e];r[e]=t,this.data[e]=i,this.__info__.observers&&n.push(()=>tr(e,this.__info__.observers,this.data,this,t))}n.forEach(e=>e()),G(this,Object.keys(t),Object.fromEntries(Object.keys(t).map(e=>[e,void 0]))),ar(this,Object.keys(t),r)}getPageId(){return this.__id__}hasBehavior(e){let t=function(n){if(!Array.isArray(n))return!1;if(n.includes(e))return!0;for(let e of n)if(e&&e.behaviors&&t(e.behaviors))return!0;return!1};return t(this.behaviors)}createSelectorQuery(){return L().in(this)}selectComponent(e){let t=Object.values($.instances[this.bridgeId]),n=t.find(n=>K(n,this.__id__,t)&&q(e,n));return n?n.hasBehavior(`wx://component-export`)&&n.export?n.export():n:null}selectAllComponents(e){let t=Object.values($.instances[this.bridgeId]);return t.filter(n=>K(n,this.__id__,t)&&q(e,n))}selectOwnerComponent(){let e=Object.values($.instances[this.bridgeId]);for(let t of e)if(t.id===this.__parentId__)return t;return null}createIntersectionObserver(e){return Kn(this,e)}groupSetData(e){if(!n(e)){console.warn(`[service] groupSetData callback must be a function`);return}this.__groupSetDataMode__=!0,Jn(this.bridgeId),this.__groupSetDataBuffer__={},this.__groupSetDataCallbacks__=[];try{e.call(this)}catch(e){console.error(`[service] groupSetData callback error:`,e)}finally{if(this.__groupSetDataMode__=!1,this.__groupSetDataBuffer__&&Object.keys(this.__groupSetDataBuffer__).length>0){let e=this.__groupSetDataBuffer__,t=this.__groupSetDataCallbacks__;this.__groupSetDataBuffer__={},this.__groupSetDataCallbacks__=[];let n=J(this,$.instances[this.bridgeId],e);H(this.bridgeId,this.__id__,e,V(this,t)),n.forEach(({child:e,data:t})=>{H(this.bridgeId,e.__id__,t)})}else this.__groupSetDataBuffer__={},this.__groupSetDataCallbacks__=[];Yn(this.bridgeId)}}createMediaQueryObserver(){console.warn(`[service] 暂不支持 createMediaQueryObserver`)}getRelationNodes(e){return e?[...this.__relations__.get(e)||[]]:(console.warn(`[service] getRelationNodes 需要传入关系路径参数`),[])}animate(){console.warn(`[service] 暂不支持 animate`)}clearAnimation(){console.warn(`[service] 暂不支持 clearAnimation`)}async triggerEvent(e,t,n={}){if(!e)return;let r=e.trim(),i=nr(this.__eventAttr__,r);i&&await $.triggerEvent({bridgeId:this.bridgeId,moduleId:this.__pageId__,methodName:i,event:{type:r,detail:t,currentTarget:{id:this.id,dataset:this.dataset},target:{id:this.id,dataset:this.dataset}}}),n.bubbles&&await $.instances[this.bridgeId][this.__parentId__]?.triggerEvent(e,t),n.composed,n.capturePhase}pageReady(){this.__isComponent__||this.ready?.()}pageUnload(){this.__isComponent__||this.onUnload?.()}pageScrollTop(e){if(!this.__isComponent__){let{scrollTop:t}=e;this.onPageScroll?.({scrollTop:t})}}pageShow(){this.__info__.behaviorPageLifetimes?.show?.forEach(e=>e.call(this)),this.onShow?.()}pageHide(){this.__info__.behaviorPageLifetimes?.hide?.forEach(e=>e.call(this)),this.onHide?.()}pageResize(e){this.__info__.behaviorPageLifetimes?.resize?.forEach(t=>t.call(this,e)),this.resize?.(e)}componentRouteDone(){this.__info__.behaviorPageLifetimes?.routeDone?.forEach(e=>e.call(this)),this.routeDone?.()}async componentCreated(){this.__info__.behaviorLifetimes?.created?.forEach(e=>e.call(this)),await this.created?.()}async componentAttached(){this.__info__.behaviorLifetimes?.attached?.forEach(e=>e.call(this)),await this.attached?.(),this.#r()}componentReadied(){this.#p(),this.__info__.behaviorLifetimes?.ready?.forEach(e=>e.call(this)),this.ready?.()}componentMoved(){this.moved?.();let e=this.__info__.relations;if(e)for(let[t,n]of Object.entries(e)){let e=this.__relations__.get(t)||[];for(let r of e)this.#u(t,r,n)}}componentDetached(){let e=this.__info__.relations;if(e)for(let[t,n]of Object.entries(e)){let e=[...this.__relations__.get(t)||[]];for(let r of e)this.#l(t,r,n)}this.#h(),this.__info__.behaviorLifetimes?.detached?.forEach(e=>e.call(this)),this.detached?.(),this.initd=!1}#h(){let e=Object.values($.instances[this.bridgeId]||{});for(let t of e)if(!(t===this||!t.__relations__))for(let[e,r]of t.__relations__.entries()){let i=r.indexOf(this);if(i!==-1){r.splice(i,1),t.__relations__.set(e,r);let a=t.__info__.relations?.[e];if(a&&n(a.unlinked))try{a.unlinked.call(t,this)}catch(e){console.error(`[service] relation unlinked error:`,e)}}}}componentError(e){this.error?.(e)}},Y=class e{static type=`component`;constructor(t,n){this.moduleInfo=t,this.extraInfo=n,this.type=e.type,this.isComponent=this.extraInfo.component,this.behaviors=this.moduleInfo.behaviors,this.usingComponents=this.extraInfo.usingComponents,or(this.moduleInfo,this.behaviors),this.noReferenceData=U(this.moduleInfo.data||{})}getProps(){let e=Qn(this.moduleInfo.properties);if(Array.isArray(this.moduleInfo.externalClasses)&&this.moduleInfo.externalClasses.length>0){e||={};for(let t of this.moduleInfo.externalClasses)e[t]={type:[`s`],cls:!0}}return e}},fr=class{constructor(e,t){this.initd=!1,this.opts=t,this.is=t.path,this.route=t.path,this.bridgeId=t.bridgeId,this.id=t.bridgeId,this.query=t.query,this.data=le(e.noReferenceData),this.__type__=e.type,this.__id__=t.moduleId,this.__info__=e.moduleInfo,this.__childPropsBindings__={},this.__pendingInitSetDataCallbacks__=[]}init(){return this.#e(),this.#t().then(()=>{Zn(this),E.send({type:this.__id__,target:`render`,body:{bridgeId:this.bridgeId,path:this.is,data:this.data}})})}flushInitSetDataCallbacks(){if(this.__pendingInitSetDataCallbacks__.length===0)return;let e=this.__pendingInitSetDataCallbacks__;this.__pendingInitSetDataCallbacks__=[],H(this.bridgeId,this.__id__,{},V(this,e))}setData(e,t){let r=U(e),i={},a=this.__info__||{};for(let e in r)i[e]=this.data[e],re(this.data,e,r[e]);if(a.observers&&er(Object.keys(r),a.observers,this.data,this,i),G(this,Object.keys(r),i),!this.initd){n(t)&&this.__pendingInitSetDataCallbacks__.push(t);return}let o=J(this,$.instances[this.bridgeId],r);H(this.bridgeId,this.__id__,r,V(this,t)),o.forEach(({child:e,data:t})=>{H(this.bridgeId,e.__id__,t)})}createSelectorQuery(){return L().in(this)}selectComponent(e){let t=Object.values($.instances[this.bridgeId]||{}),n=t.find(n=>K(n,this.__id__,t)&&q(e,n));return n?n.hasBehavior&&n.hasBehavior(`wx://component-export`)&&n.export?n.export():n:null}selectAllComponents(e){let t=Object.values($.instances[this.bridgeId]||{});return t.filter(n=>K(n,this.__id__,t)&&q(e,n)).map(e=>e.hasBehavior&&e.hasBehavior(`wx://component-export`)&&e.export?e.export():e)}#e(){for(let e in this.__info__){let t=this.__info__[e];n(t)?this[e]=t.bind(this):this[e]=t}}async#t(){this.__info__.behaviorLifetimes?.created?.forEach(e=>e.call(this)),await this.created?.(),this.__info__.behaviorLifetimes?.attached?.forEach(e=>e.call(this)),await this.attached?.(),await this.onLoad?.(this.opts.query||{}),this.initd=!0}pageShow(){this.__info__.behaviorPageLifetimes?.show?.forEach(e=>e.call(this)),this.onShow?.()}pageHide(){this.__info__.behaviorPageLifetimes?.hide?.forEach(e=>e.call(this)),this.onHide?.()}pageReady(){this.__info__.behaviorLifetimes?.ready?.forEach(e=>e.call(this)),this.ready?.(),this.onReady?.()}pageUnload(){this.__info__.behaviorLifetimes?.detached?.forEach(e=>e.call(this)),this.detached?.(),this.onUnload?.(),this.initd=!1}pageScrollTop(e){let{scrollTop:t}=e;this.onPageScroll?.({scrollTop:t})}pageResize(e){this.__info__.behaviorPageLifetimes?.resize?.forEach(t=>t.call(this,e)),this.onResize?.(e)}},X=class e{static type=`page`;constructor(t,r){if(this.moduleInfo=t,this.extraInfo=r,this.type=e.type,this.behaviors=this.moduleInfo.behaviors,this.usingComponents=this.extraInfo.usingComponents,or(this.moduleInfo,this.behaviors),this.moduleInfo.methods)for(let[e,t]of Object.entries(this.moduleInfo.methods))!(e in this.moduleInfo)&&n(t)&&(this.moduleInfo[e]=t);this.noReferenceData=U(this.moduleInfo.data||{})}},Z=class{static type=`app`;constructor(e){this.moduleInfo=e}},Q=new class{constructor(){this.staticModules={}}loadResource(e){let{appId:t,bridgeId:n,pagePath:r,root:i,baseUrl:a}=e;if(v&&(this.isScriptLoaded=this.isScriptLoaded||{},!this.isScriptLoaded[i])){let e=`${a}${t}/${i}/logic.js`;globalThis.importScripts(e),this.isScriptLoaded[i]=!0}D.setInitId(n),C(`app`),C(r),E.invoke({type:`serviceResourceLoaded`,target:`service`,body:{bridgeId:n}})}createAppModule(e){let t=new Z(e);this.staticModules[Z.type]=t}createModule(e,t,n){let{path:r,usingComponents:i}=t;if(!this.staticModules[r]){if(i)for(let e of Object.values(i))C(e);if(n===X.type){let n=new X(e,t);this.staticModules[r]=n}else if(n===Y.type){let n=new Y(e,t);this.staticModules[r]=n}else console.error(`[service] createModule ${n} error`)}}getPropsByPath(e){let t={};return this.getComponentProps(t,e),t}getComponentProps(e,t){if(t)for(let n of Object.values(t)){let t=this.staticModules[n];!t||e[n]||(e[n]=t.getProps(),this.getComponentProps(e,t.usingComponents))}}getAppModule(){return this.staticModules[Z.type]}getModuleByPath(e){return this.staticModules[e]}},$=new class{constructor(){this.app=null,this.instances={}}queuePendingEvent(e,t){return e.__pendingRuntimeEvents__=e.__pendingRuntimeEvents__||[],new Promise((n,r)=>{e.__pendingRuntimeEvents__.push({...t,resolve:n,reject:r})})}async flushPendingEvents(e){let t=e?.__pendingRuntimeEvents__||[];e.__pendingRuntimeEvents__=[];for(let e of t)try{let t=await this.dispatchEvent(e);e.resolve(t)}catch(t){e.reject(t)}}async dispatchEvent({instance:e,bridgeId:t,moduleId:r,methodName:i,event:a}){if(n(e[i]))return await e[i](a);console.warn(`[service] triggerEvent ${t} ${r}, is: ${e.is}, method: ${i} is not exist`)}createApp(e){if(this.app){console.log(`[service] app instance already existed`);return}let{scene:t,pagePath:n,query:r}=e,i=Q.getAppModule();if(!i){console.log(`[service] app instance is not exist`);return}console.log(`[service] create app instance`),this.app=new xn(i,{scene:t,path:n,query:r})}appShow(){this.app?.appShow()}appHide(){this.app?.appHide()}stackShow(e){D.pushStack(e)}stackHide(e){D.popStack(e)}createInstance(e){let{bridgeId:t,moduleId:n,path:r,query:i,eventAttr:a,pageId:o,parentId:s,properties:c,targetInfo:l,stackId:u}=e,d=Q.getModuleByPath(r);if(!d){console.error(`[service] ${r} not exist`);return}if(console.log(`[service] create instance ${r}`),this.instances[t]=this.instances[t]||{},d.type===Y.type){let e=new dr(d,{bridgeId:t,moduleId:n,path:r,query:i,eventAttr:a,pageId:o,parentId:s,properties:c,targetInfo:l});return this.instances[t][n]=e,d.isComponent||D.push(e,u),e.init(),e}else if(d.type===X.type){let e=new fr(d,{bridgeId:t,moduleId:n,path:r,query:i});return this.instances[t][n]=e,D.push(e,u),e.init(),e}else console.error(`[service] ${d.type} instance is not exist.`)}moduleReady(e){let{bridgeId:t,moduleId:n,propBindings:r}=e,i=this.instances[t][n];if(i){if(r&&i.__parentId__){let e=this.instances[t]?.[i.__parentId__];e&&(e.__childPropsBindings__||={},e.__childPropsBindings__[n]=r)}if(i.__type__===Y.type){i.componentReadied(),i.__componentReadied__=!0,this.flushPendingEvents(i),i.flushInitSetDataCallbacks?.();let e=this.getPageInstance(t);e&&this.checkAndCallPageReady(t,e.__id__)}}}moduleUnmounted(e){let{bridgeId:t,moduleId:n}=e,r=this.instances[t][n];r&&(r.__type__===Y.type&&r.componentDetached(),delete this.instances[t][n])}pageShow(e){let{bridgeId:t}=e,n=this.instances[t];if(!n)return;let r=[];Object.values(n).forEach(e=>{e&&(e.__type__===X.type?r.push(e):e.__type__===Y.type&&(e.__isComponent__?e.pageShow():r.push(e)))}),r.forEach(e=>{e.pageShow()})}pageReady(e){let{bridgeId:t,moduleId:n}=e,r=this.instances[t][n];r&&(this.pageShow(e),r.__pageReadyPending__=!0,r.flushInitSetDataCallbacks?.(),this.checkAndCallPageReady(t,n))}getPageInstance(e){let t=this.instances[e];return t?Object.values(t).find(e=>e&&(e.__type__===X.type||e.__type__===Y.type&&!e.__isComponent__)):null}checkAndCallPageReady(e,t){let n=this.instances[e][t];if(!n||!n.__pageReadyPending__)return;let r=this.instances[e];if(!r){n.__pageReadyPending__=!1,n.pageReady();return}Object.values(r).filter(e=>e&&e.__type__===Y.type&&e.__isComponent__&&e.initd&&!e.__componentReadied__).length===0&&(n.__pageReadyPending__=!1,n.pageReady())}pageHide(e){let{bridgeId:t}=e,n=this.instances[t],r=[];Object.values(n).forEach(e=>{e&&(e.__type__===X.type?r.push(e):e.__type__===Y.type&&(e.__isComponent__?e.pageHide():r.push(e)))}),r.forEach(e=>{e&&e.pageHide()})}pageUnload(e){let{bridgeId:t}=e,n=this.instances[t];n&&(Object.values(n).forEach(e=>{e&&(e.__type__===Y.type&&e.componentDetached(),e.pageUnload())}),D.pop(),delete this.instances[t])}pageScroll(e){let{bridgeId:t,moduleId:n,scrollTop:r}=e,i=this.instances[t][n];i&&i.pageScrollTop({scrollTop:r})}pageResize(e){let{bridgeId:t,size:n}=e,r=this.instances[t];r&&Object.values(r).forEach(e=>{e&&(e.__type__===X.type?e.pageResize(n):e.__type__===Y.type&&(e.__isComponent__,e.pageResize(n)))})}componentError(e){let{bridgeId:t,moduleId:n}=e,r=this.instances[t][n];r&&r.__type__===Y.type&&r.componentError()}componentRouteDone(e){let{bridgeId:t}=e,n=this.instances[t];n&&Object.values(n).forEach(e=>{e?.__type__===Y.type&&e.componentRouteDone()})}async triggerEvent(e){let{bridgeId:t,moduleId:n,methodName:r,event:i}=e;if(r===void 0)return;let a=this.instances[t];if(!a){console.warn(`[service] No instances found for bridgeId: ${t}`);return}let o=a[n];if(!o){console.warn(`[service] triggerEvent ${t} ${n} ${r}, instance is not exist`);return}return o.__type__===Y.type&&o.__isComponent__&&!o.__componentReadied__?this.queuePendingEvent(o,{instance:o,bridgeId:t,moduleId:n,methodName:r,event:i}):this.dispatchEvent({instance:o,bridgeId:t,moduleId:n,methodName:r,event:i})}},pr=t({getEnterOptionsSync:()=>hr,getLaunchOptionsSync:()=>mr});function mr(){return $.app?.options}function hr(){return $.app?.options}var gr=t({getLocation:()=>_r,offLocationChange:()=>Sr,onLocationChange:()=>xr,openLocation:()=>yr,startLocationUpdate:()=>vr,stopLocationUpdate:()=>br});function _r(e){O(`getLocation`,e)}function vr(e){O(`startLocationUpdate`,e)}function yr(e){O(`openLocation`,e)}function br(e){O(`stopLocationUpdate`,e)}function xr(e){e&&O(`onLocationChange`,{success:w.store(e,!0)})}function Sr(e){if(e){let t=w.store(e,!0);O(`offLocationChange`,{success:t}),w.remove(t)}else O(`offLocationChange`),w.remove()}var Cr=t({createMapContext:()=>wr});function wr(e,t){return new Tr({mapId:e,obj:t})}var Tr=class{constructor(e){this.opts=e}addMarkers(e){O(`addMarkers`,e)}removeMarkers(e){O(`removeMarkers`,e)}includePoints(e){O(`includePoints`,e)}setCenterOffset(e){O(`setCenterOffset`,e)}getCenterLocation(e){O(`getCenterLocation`,e)}getScale(e){O(`getScale`,e)}moveToLocation(e){O(`moveToLocation`,e)}translateMarker(e){O(`translateMarker`,e)}addArc(e){O(`addArc`,e)}removeArc(e){O(`removeArc`,e)}},Er=t({createInnerAudioContext:()=>kr}),Dr=1,Or=class{constructor(){this._audioId=Dr++,this._src=``,this._startTime=0,this._autoplay=!1,this._loop=!1,this._volume=1,this._playbackRate=1,this._currentTime=0,this._duration=0,this._buffered=0,this._paused=!0,this._listeners={},O(`audioCreate`,{audioId:this._audioId}),O(`audioListen`,{audioId:this._audioId,evtId:`audio_${this._audioId}`,keep:!0,success:e=>this._dispatch(e)})}_dispatch(e){if(!e||typeof e!=`object`)return;this._currentTime=e.currentTime||0,this._duration=e.duration||0,this._buffered=e.buffered||0,this._paused=!!e.paused;let t=this._listeners[e.event];if(t)for(let n of t.slice())n(e)}get src(){return this._src}set src(e){this._src=e,O(`audioSetProp`,{audioId:this._audioId,prop:`src`,value:e,startTime:this._startTime,loop:this._loop,volume:this._volume,playbackRate:this._playbackRate,autoplay:this._autoplay})}get startTime(){return this._startTime}set startTime(e){this._startTime=Number(e)||0,O(`audioSetProp`,{audioId:this._audioId,prop:`startTime`,value:this._startTime})}get autoplay(){return this._autoplay}set autoplay(e){this._autoplay=!!e,O(`audioSetProp`,{audioId:this._audioId,prop:`autoplay`,value:this._autoplay})}get loop(){return this._loop}set loop(e){this._loop=!!e,O(`audioSetProp`,{audioId:this._audioId,prop:`loop`,value:this._loop})}get volume(){return this._volume}set volume(e){this._volume=Math.max(0,Math.min(1,Number(e)||0)),O(`audioSetProp`,{audioId:this._audioId,prop:`volume`,value:this._volume})}get playbackRate(){return this._playbackRate}set playbackRate(e){this._playbackRate=Number(e)||1,O(`audioSetProp`,{audioId:this._audioId,prop:`playbackRate`,value:this._playbackRate})}get duration(){return this._duration}get currentTime(){return this._currentTime}get paused(){return this._paused}get buffered(){return this._buffered}play(){this._paused=!1,O(`audioPlay`,{audioId:this._audioId,src:this._src})}pause(){this._paused=!0,O(`audioPause`,{audioId:this._audioId})}stop(){this._paused=!0,O(`audioStop`,{audioId:this._audioId})}seek(e){O(`audioSeek`,{audioId:this._audioId,position:Number(e)||0})}destroy(){O(`audioDestroy`,{audioId:this._audioId}),this._listeners={}}_on(e,t){typeof t==`function`&&(this._listeners[e]||(this._listeners[e]=[]),this._listeners[e].push(t))}_off(e,t){this._listeners[e]&&(t?this._listeners[e]=this._listeners[e].filter(e=>e!==t):this._listeners[e]=[])}onPlay(e){this._on(`play`,e)}onPause(e){this._on(`pause`,e)}onStop(e){this._on(`stop`,e)}onEnded(e){this._on(`ended`,e)}onError(e){this._on(`error`,e)}onTimeUpdate(e){this._on(`timeUpdate`,e)}onWaiting(e){this._on(`waiting`,e)}onSeeking(e){this._on(`seeking`,e)}onSeeked(e){this._on(`seeked`,e)}onCanplay(e){this._on(`canplay`,e)}offPlay(e){this._off(`play`,e)}offPause(e){this._off(`pause`,e)}offStop(e){this._off(`stop`,e)}offEnded(e){this._off(`ended`,e)}offError(e){this._off(`error`,e)}offTimeUpdate(e){this._off(`timeUpdate`,e)}offWaiting(e){this._off(`waiting`,e)}offSeeking(e){this._off(`seeking`,e)}offSeeked(e){this._off(`seeked`,e)}offCanplay(e){this._off(`canplay`,e)}};function kr(){return new Or}var Ar=t({chooseImage:()=>Pr,compressImage:()=>Nr,previewImage:()=>Mr,saveImageToPhotosAlbum:()=>jr});function jr(e){O(`saveImageToPhotosAlbum`,e)}function Mr(e){O(`previewImage`,e)}function Nr(e){O(`compressImage`,e)}function Pr(e){O(`chooseImage`,e)}var Fr=t({chooseMedia:()=>Rr,chooseVideo:()=>Lr,createVideoContext:()=>Ir});function Ir(e,t){return new zr({videoId:e,obj:t})}function Lr(e){O(`chooseVideo`,e)}function Rr(e){O(`chooseMedia`,e)}var zr=class{constructor(e){this.opts=e}play(){this.invoke(`play`)}pause(){this.invoke(`pause`)}stop(){this.invoke(`stop`)}seek(e){this.invoke(`seek`,{position:e})}playbackRate(e){this.invoke(`playbackRate`,{rate:e})}requestFullScreen(e={}){this.invoke(`requestFullScreen`,e)}exitFullScreen(){this.invoke(`exitFullScreen`)}requestBackgroundPlayback(e={}){this.invoke(`requestBackgroundPlayback`,e)}exitBackgroundPlayback(){this.invoke(`exitBackgroundPlayback`)}exitPictureInPicture(e={}){this.invoke(`exitPictureInPicture`,e)}showStatusBar(){this.invoke(`showStatusBar`)}hideStatusBar(){this.invoke(`hideStatusBar`)}invoke(e,t={}){O(`videoContext`,{type:`native/video`,id:this.opts.videoId,command:e,...t},`render`)}},Br=t({exitMiniProgram:()=>Wr,navigateBackMiniProgram:()=>Ur,navigateToMiniProgram:()=>Hr,restartMiniProgram:()=>Vr});function Vr(e){O(`restartMiniProgram`,e)}function Hr(e){O(`navigateToMiniProgram`,e)}function Ur(e){O(`navigateBackMiniProgram`,e)}function Wr(e){O(`exitMiniProgram`,e)}var Gr=t({downloadFile:()=>Kr});function Kr(e){O(`downloadFile`,e)}var qr=t({request:()=>Jr});function Jr(e){O(`request`,e)}var Yr=t({uploadFile:()=>Xr});function Xr(e){O(`uploadFile`,e)}var Zr=t({closeSocket:()=>ti,connectSocket:()=>$r,onSocketClose:()=>ai,onSocketError:()=>ii,onSocketMessage:()=>ri,onSocketOpen:()=>ni,sendSocketMessage:()=>ei}),Qr=class{constructor(e){this.socketId=e,this._readyState=0}send(e={}){let{data:t,success:r,fail:i,complete:a,...o}=e,s={socketId:this.socketId,data:t,...o};return n(r)&&(s.success=w.store(r)),n(i)&&(s.fail=w.store(i)),n(a)&&(s.complete=w.store(a)),O(`sendSocketMessage`,s)}close(e={}){let{code:t=1e3,reason:r=``,success:i,fail:a,complete:o,...s}=e,c={socketId:this.socketId,code:t,reason:r,...s};return n(i)&&(c.success=w.store(i)),n(a)&&(c.fail=w.store(a)),n(o)&&(c.complete=w.store(o)),O(`closeSocket`,c)}onOpen(e){if(n(e))return O(`onSocketOpen`,{socketId:this.socketId,callback:w.store(e,!0)})}offOpen(e){return O(`offSocketOpen`,{socketId:this.socketId,callback:e})}onMessage(e){if(n(e))return O(`onSocketMessage`,{socketId:this.socketId,callback:w.store(e,!0)})}offMessage(e){return O(`offSocketMessage`,{socketId:this.socketId,callback:e})}onError(e){if(n(e))return O(`onSocketError`,{socketId:this.socketId,callback:w.store(e,!0)})}offError(e){return O(`offSocketError`,{socketId:this.socketId,callback:e})}onClose(e){if(n(e))return O(`onSocketClose`,{socketId:this.socketId,callback:w.store(e,!0)})}offClose(e){return O(`offSocketClose`,{socketId:this.socketId,callback:e})}get readyState(){return this._readyState}static get CONNECTING(){return 0}static get OPEN(){return 1}static get CLOSING(){return 2}static get CLOSED(){return 3}};function $r(e={}){let{url:t,header:r={},protocols:i=[],tcpNoDelay:a=!1,perMessageDeflate:o=!1,timeout:s,forceCellularNetwork:c=!1,success:l,fail:u,complete:d,...ee}=e;if(!t){let e=Error(`url is required`);throw n(u)&&u(e),n(d)&&d(e),e}let f=`socket_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,p=new Qr(f),m={socketId:f,url:t,header:r,protocols:i,tcpNoDelay:a,perMessageDeflate:o,timeout:s,forceCellularNetwork:c,...ee};return n(l)&&(m.success=w.store(e=>{p._readyState=Qr.OPEN,l(e)})),n(u)&&(m.fail=w.store(e=>{p._readyState=Qr.CLOSED,u(e)})),n(d)&&(m.complete=w.store(d)),O(`connectSocket`,m),p}function ei(e){return O(`sendSocketMessage`,e)}function ti(e){return O(`closeSocket`,e)}function ni(e){return O(`onSocketOpen`,{callback:w.store(e,!0)})}function ri(e){return O(`onSocketMessage`,{callback:w.store(e,!0)})}function ii(e){return O(`onSocketError`,{callback:w.store(e,!0)})}function ai(e){return O(`onSocketClose`,{callback:w.store(e,!0)})}var oi=t({getAccountInfoSync:()=>si});function si(){return O(`getAccountInfoSync`)}var ci=t({authorize:()=>li});function li(e){O(`authorize`,e)}var ui=t({login:()=>di});function di(e){O(`login`,e)}var fi=t({login:()=>pi});function pi(e){O(`login`,e)}var mi=t({getPrivacySetting:()=>hi});function hi(e){O(`getPrivacySetting`,e)}var gi=t({getSetting:()=>vi,openSetting:()=>_i});function _i(e){O(`openSetting`,e)}function vi(e){O(`getSetting`,e)}var yi=t({getUserInfo:()=>bi});function bi(e){O(`getUserInfo`,e)}var xi=t({requestPayment:()=>Si});function Si(e){O(`requestPayment`,e)}var Ci=t({hideShareMenu:()=>Ei,showShareImageMenu:()=>Ti,showShareMenu:()=>wi});function wi(e){O(`shareShareMenu`,e)}function Ti(e){O(`showShareImageMenu`,e)}function Ei(e){O(`hideShareMenu`,e)}var Di=t({clearStorage:()=>Fi,clearStorageSync:()=>ji,getStorage:()=>Ni,getStorageInfo:()=>Li,getStorageInfoSync:()=>Ii,getStorageSync:()=>ki,removeStorage:()=>Pi,removeStorageSync:()=>Ai,setStorage:()=>Mi,setStorageSync:()=>Oi});function Oi(...e){O(`setStorageSync`,e)}function ki(e){return O(`getStorageSync`,e)}function Ai(e){return O(`removeStorageSync`,e)}function ji(){O(`clearStorageSync`)}function Mi(e){O(`setStorage`,e)}function Ni(e){O(`getStorage`,e)}function Pi(e){O(`removeStorage`,e)}function Fi(){O(`clearStorage`)}function Ii(){return O(`getStorageInfoSync`)}function Li(e){O(`getStorageInfo`,e)}var Ri=t({createAnimation:()=>zi});function zi(e={}){return new Bi(e)}var Bi=class{constructor({duration:e=400,timingFunction:t=`linear`,delay:n=0,transformOrigin:r=`50% 50% 0`}={}){this.actions=[],this.currentTransform={},this.currentStepAnimates=[],this.option={transition:{duration:e,timingFunction:t,delay:n},transformOrigin:r}}export(){let e=this.actions;return this.actions=[],{actions:e}}step(e={}){for(let e of this.currentStepAnimates)e.type===`style`?this.currentTransform[`${e.type}.${e.args[0]}`]=e:this.currentTransform[e.type]=e;return this.actions.push({animates:Object.keys(this.currentTransform).reduce((e,t)=>[].concat(...e,[this.currentTransform[t]]),[]),option:{transformOrigin:e.transformOrigin===void 0?this.option.transformOrigin:e.transformOrigin,transition:{duration:e.duration===void 0?this.option.transition.duration:e.duration,timingFunction:e.timingFunction===void 0?this.option.transition.timingFunction:e.timingFunction,delay:e.delay===void 0?this.option.transition.delay:e.delay}}}),this.currentStepAnimates=[],this}backgroundColor(e){return this.currentStepAnimates.push({type:`style`,args:[`background-color`,e]}),this}bottom(e){return this.currentStepAnimates.push({type:`style`,args:[`bottom`,b(e)]}),this}height(e){return this.currentStepAnimates.push({type:`style`,args:[`height`,b(e)]}),this}left(e){return this.currentStepAnimates.push({type:`style`,args:[`left`,b(e)]}),this}matrix(e=1,t=0,n=0,r=1,i=1,a=1){return this.currentStepAnimates.push({type:`matrix`,args:[e,t,n,r,i,a]}),this}matrix3d(e=1,t=0,n=0,r=0,i=0,a=1,o=0,s=0,c=0,l=0,u=1,d=0,ee=0,f=0,p=0,m=1){return this.currentStepAnimates.push({type:`matrix3d`,args:[e,t,n,r,i,a,o,s,c,l,u,d,ee,f,p,m]}),this}opacity(e){return this.currentStepAnimates.push({type:`style`,args:[`opacity`,e]}),this}right(e){return this.currentStepAnimates.push({type:`style`,args:[`right`,b(e)]}),this}rotate(e=0){return this.currentStepAnimates.push({type:`rotate`,args:[e]}),this}rotate3d(e=0,t=0,n=0,r=0){return this.currentStepAnimates.push({type:`rotate3d`,args:[e,t,n,r]}),this}rotateX(e){return this.currentStepAnimates.push({type:`rotateX`,args:[e]}),this}rotateY(e){return this.currentStepAnimates.push({type:`rotateY`,args:[e]}),this}rotateZ(e){return this.currentStepAnimates.push({type:`rotateZ`,args:[e]}),this}scale(e=1,t=1){return this.currentStepAnimates.push({type:`scale`,args:[e,t]}),this}scale3d(e=1,t=1,n=1){return this.currentStepAnimates.push({type:`scale3d`,args:[e,t,n]}),this}scaleX(e=1){return this.currentStepAnimates.push({type:`scaleX`,args:[e]}),this}scaleY(e=1){return this.currentStepAnimates.push({type:`scaleY`,args:[e]}),this}scaleZ(e=1){return this.currentStepAnimates.push({type:`scaleZ`,args:[e]}),this}skew(e=0,t=0){return this.currentStepAnimates.push({type:`skew`,args:[e,t]}),this}skewX(e=0){return this.currentStepAnimates.push({type:`skewX`,args:[e]}),this}skewY(e=0){return this.currentStepAnimates.push({type:`skewY`,args:[e]}),this}top(e){return this.currentStepAnimates.push({type:`style`,args:[`top`,b(e)]}),this}translate(e=0,t=0){return this.currentStepAnimates.push({type:`translate`,args:[e,t]}),this}translate3d(e=0,t=0,n=0){return this.currentStepAnimates.push({type:`translate3d`,args:[e,t,n]}),this}translateX(e=0){return this.currentStepAnimates.push({type:`translateX`,args:[e]}),this}translateY(e=0){return this.currentStepAnimates.push({type:`translateY`,args:[e]}),this}width(e){return this.currentStepAnimates.push({type:`style`,args:[`width`,b(e)]}),this}},Vi=t({setBackgroundColor:()=>Ui,setBackgroundTextStyle:()=>Hi});function Hi(e){O(`setBackgroundTextStyle`,e)}function Ui(e){O(`setBackgroundColor`,e)}var Wi=t({canvasToTempFilePath:()=>Ji,createCanvasContext:()=>Ki,createContext:()=>Gi,createOffscreenCanvas:()=>zn,drawCanvas:()=>qi});function Gi(){return new Xi}function Ki(e,t){return new Xi(e,Yi(t))}function qi(e={}){let t={...e,moduleId:e.moduleId||Yi(e.component)};delete t.component,O(`drawCanvas`,t,`render`)}function Ji(e={},t){let n={...e,moduleId:e.moduleId||Yi(t||e.component)};delete n.component,O(`canvasToTempFilePath`,n,`render`)}function Yi(e){return e?.__id__||D.getPageInfo()?.id}var Xi=class{constructor(e=``,t=null){this.canvasId=e,this.moduleId=t,this.actions=[]}pushAction(e,...t){return this.actions.push({type:e,args:t}),this}getActions(){return this.actions.slice()}draw(e=!1,t){this.canvasId&&(qi({canvasId:this.canvasId,moduleId:this.moduleId,actions:this.getActions(),reserve:e,success:t}),this.actions=[])}beginPath(){return this.pushAction(`beginPath`)}closePath(){return this.pushAction(`closePath`)}moveTo(e,t){return this.pushAction(`moveTo`,e,t)}lineTo(e,t){return this.pushAction(`lineTo`,e,t)}rect(e,t,n,r){return this.pushAction(`rect`,e,t,n,r)}arc(e,t,n,r,i,a=!1){return this.pushAction(`arc`,e,t,n,r,i,a)}quadraticCurveTo(e,t,n,r){return this.pushAction(`quadraticCurveTo`,e,t,n,r)}bezierCurveTo(e,t,n,r,i,a){return this.pushAction(`bezierCurveTo`,e,t,n,r,i,a)}fill(){return this.pushAction(`fill`)}stroke(){return this.pushAction(`stroke`)}clearRect(e,t,n,r){return this.pushAction(`clearRect`,e,t,n,r)}fillText(e,t,n,r){return this.pushAction(`fillText`,e,t,n,r)}drawImage(e,...t){return this.pushAction(`drawImage`,e,...t)}save(){return this.pushAction(`save`)}restore(){return this.pushAction(`restore`)}translate(e,t){return this.pushAction(`translate`,e,t)}rotate(e){return this.pushAction(`rotate`,e)}scale(e,t){return this.pushAction(`scale`,e,t)}setShadow(e,t,n,r){return this.pushAction(`setShadow`,e,t,n,r)}setFillStyle(e){return this.pushAction(`setFillStyle`,e)}setStrokeStyle(e){return this.pushAction(`setStrokeStyle`,e)}setGlobalAlpha(e){return this.pushAction(`setGlobalAlpha`,e)}setLineCap(e){return this.pushAction(`setLineCap`,e)}setLineJoin(e){return this.pushAction(`setLineJoin`,e)}setLineWidth(e){return this.pushAction(`setLineWidth`,e)}setMiterLimit(e){return this.pushAction(`setMiterLimit`,e)}setFontSize(e){return this.pushAction(`setFontSize`,e)}},Zi=t({nextTick:()=>ta}),Qi=[],$i=null;function ea(){let e=Qi;Qi=[],$i=null;for(let t=0;t<e.length;t++)e[t]()}function ta(e){n(e)&&(Qi.push(e),$i||=setTimeout(ea,0))}var na=t({disableAlertBeforeUnload:()=>ua,enableAlertBeforeUnload:()=>la,hideLoading:()=>ca,hideToast:()=>ia,showActionSheet:()=>sa,showLoading:()=>oa,showModal:()=>aa,showToast:()=>ra});function ra(e){O(`showToast`,e)}function ia(e){O(`hideToast`,e)}function aa(e){O(`showModal`,e)}function oa(e){O(`showLoading`,e)}function sa(e){O(`showActionSheet`,e)}function ca(e){O(`hideLoading`,e)}function la(e){O(`enableAlertBeforeUnload`,e)}function ua(e){O(`disableAlertBeforeUnload`,e)}var da=t({getMenuButtonBoundingClientRect:()=>pa,offMenuButtonBoundingClientRectWeightChange:()=>ha,onMenuButtonBoundingClientRectWeightChange:()=>ma}),fa=new Set;function pa(){return O(`getMenuButtonBoundingClientRect`)}function ma(e){n(e)&&fa.add(e)}function ha(e){n(e)?fa.delete(e):fa.clear()}var ga=t({hideNavigationBarLoading:()=>ba,setNavigationBarColor:()=>ya,setNavigationBarTitle:()=>va,showNavigationBarLoading:()=>_a});function _a(e){O(`showNavigationBarLoading`,e)}function va(e){O(`setNavigationBarTitle`,e)}function ya(e){O(`setNavigationBarColor`,e)}function ba(e){O(`hideNavigationBarLoading`,e)}var xa=t({startPullDownRefresh:()=>Ca,stopPullDownRefresh:()=>Sa});function Sa(e){O(`stopPullDownRefresh`,e)}function Ca(e){O(`startPullDownRefresh`,e)}var wa=t({pageScrollTo:()=>Ta});function Ta(e){O(`pageScrollTo`,e)}var Ea=t({hideTabBar:()=>Aa,hideTabBarRedDot:()=>Pa,removeTabBarBadge:()=>Ma,setTabBarBadge:()=>ja,setTabBarItem:()=>Oa,setTabBarStyle:()=>Da,showTabBar:()=>ka,showTabBarRedDot:()=>Na});function Da(e){O(`setTabBarStyle`,e)}function Oa(e){O(`setTabBarItem`,e)}function ka(e){O(`showTabBar`,e)}function Aa(e){O(`hideTabBar`,e)}function ja(e){O(`setTabBarBadge`,e)}function Ma(e){O(`removeTabBarBadge`,e)}function Na(e){O(`showTabBarRedDot`,e)}function Pa(e){O(`hideTabBarRedDot`,e)}var Fa=t({onWindowResize:()=>Ia});function Ia(e){e&&O(`onWindowResize`,{success:e})}var La=Object.assign({"./core/base/app-event/index.js":be,"./core/base/index.js":Ae,"./core/base/performance/index.js":Pe,"./core/base/subpackage/index.js":ze,"./core/base/system/index.js":He,"./core/base/update/index.js":Ze,"./core/camera/index.js":at,"./core/data-analysis/index.js":ct,"./core/device/bluetooth/index.js":dt,"./core/device/bluetooth-ble/index.js":Ct,"./core/device/clipboard/index.js":Lt,"./core/device/contact/index.js":Bt,"./core/device/keyboard/index.js":Ut,"./core/device/memory/index.js":Gt,"./core/device/network/index.js":Jt,"./core/device/phone/index.js":Xt,"./core/device/scan/index.js":Qt,"./core/device/vibrate/index.js":en,"./core/ext/index.js":rn,"./core/file/index.js":un,"./core/life-cycle/index.js":pr,"./core/location/index.js":gr,"./core/map/index.js":Cr,"./core/media/audio/index.js":Er,"./core/media/image/index.js":Ar,"./core/media/video/index.js":Fr,"./core/navigate/index.js":Br,"./core/network/download/index.js":Gr,"./core/network/request/index.js":qr,"./core/network/upload/index.js":Yr,"./core/network/websocket/index.js":Zr,"./core/open-api/account-info/index.js":oi,"./core/open-api/authorize/index.js":ci,"./core/open-api/index.js":ui,"./core/open-api/login/index.js":fi,"./core/open-api/privacy/index.js":mi,"./core/open-api/setting/index.js":gi,"./core/open-api/user-info/index.js":yi,"./core/payment/index.js":xi,"./core/route/index.js":me,"./core/share/index.js":Ci,"./core/storage/index.js":Di,"./core/ui/animation/index.js":Ri,"./core/ui/background/index.js":Vi,"./core/ui/canvas/index.js":Wi,"./core/ui/custom-component/index.js":Zi,"./core/ui/interaction/index.js":na,"./core/ui/menu/index.js":da,"./core/ui/navigation-bar/index.js":ga,"./core/ui/pull-down-refresh/index.js":xa,"./core/ui/scroll/index.js":wa,"./core/ui/tab-bar/index.js":Ea,"./core/ui/window/index.js":Fa,"./core/wxml/intersection-observer/index.js":Gn,"./core/wxml/selector-query/index.js":Bn}),Ra={};for(let e of Object.values(La))for(let[t,n]of Object.entries(e))Ra[t]=n;var za=new Proxy(Ra,{get(e,t,n){let r=Reflect.get(e,t,n);return typeof r==`function`||r!==void 0||t===`webpackJsonp`?r:(...e)=>O(t,...e)},set(e,t,n,r){return Reflect.set(e,t,n,r)}}),Ba=new class{constructor(){this.init()}init(){let e=globalThis.__diminaApiNamespaces||[];if(e.length===0&&globalThis.name)try{e=JSON.parse(globalThis.name).apiNamespaces||[]}catch{}for(let t of[`dd`,`wx`,...e])globalThis[t]=za;globalThis.modRequire=C,globalThis.modDefine=de,globalThis.global={},globalThis.App=e=>Q.createAppModule(e),globalThis.Page=e=>{Q.createModule(e,globalThis.__extraInfo,X.type)},globalThis.Component=e=>{Q.createModule(e,globalThis.__extraInfo,Y.type)},globalThis.Behavior=e=>e,globalThis.getApp=e=>{let t=$.app;return!t&&e?.allowDefault?{}:t},globalThis.getCurrentPages=()=>D.stack()}},Va={navigateBack:ye,navigateTo:ve,reLaunch:ge,redirectTo:_e,switchTab:he};return new class{constructor(){console.log(`[service] init`),this.env=Ba,this.message=E,this.init()}init(){this.message.on(`loadResource`,e=>{let{appId:t,bridgeId:n,pagePath:r,root:i=`.`,baseUrl:a=`/`,hostEnv:o}=e;o&&T.init(o),Q.loadResource({appId:t,bridgeId:n,pagePath:r,root:i,baseUrl:a})}),this.message.on(`t`,async e=>{let{bridgeId:t,moduleId:n,methodName:r,event:i,success:a}=e;if(r===void 0)return;let o=await $.triggerEvent({bridgeId:t,moduleId:n,methodName:r,event:i});o!==void 0&&this.message.send({type:`triggerCallback`,target:`render`,body:{bridgeId:t,moduleId:n,success:a,data:o}})}),this.message.on(`triggerCallback`,e=>{let{id:t,args:n}=e;w.invoke(t,n)}),this.onAppMsg(),this.onModuleMsg()}onAppMsg(){this.message.on(`resourceLoaded`,e=>{let{bridgeId:t,scene:n,pagePath:r,query:i,stackId:a}=e;$.createApp({scene:n,pagePath:r,query:i});let o=Q.getModuleByPath(r);if(!o){console.error(`[service] resourceLoaded: module not found, pagePath: ${r}`);return}let s=Q.getPropsByPath(o.usingComponents),c=`page_${g()}`;$.createInstance({bridgeId:t,moduleId:c,path:r,query:i,stackId:a}),E.send({type:`firstRender`,target:`render`,body:{bridgeId:t,pageId:c,pagePath:r,initialProps:s,query:i}})}),this.message.on(`appShow`,()=>{$.appShow()}),this.message.on(`appHide`,()=>{$.appHide()}),this.message.on(`stackShow`,({stackId:e})=>{$.stackShow(e)}),this.message.on(`stackHide`,({stackId:e})=>{$.stackHide(e)})}onModuleMsg(){this.message.on(`mC`,e=>{$.createInstance(e)}),this.message.on(`mR`,e=>{$.moduleReady(e)}),this.message.on(`mU`,e=>{$.moduleUnmounted(e)}),this.message.on(`pageUnload`,e=>{$.pageUnload(e)}),this.message.on(`pageShow`,e=>{$.pageShow(e)}),this.message.on(`pageReady`,e=>{$.pageReady(e)}),this.message.on(`pageHide`,e=>{$.pageHide(e)}),this.message.on(`pagePullDownRefresh`,()=>{}),this.message.on(`pageReachBottom`,()=>{}),this.message.on(`pageShareAppMessage`,()=>{}),this.message.on(`pageScroll`,e=>{$.pageScroll(e)}),this.message.on(`pageResize`,e=>{$.pageResize(e)}),this.message.on(`onTabItemTap`,()=>{}),this.message.on(`pageRouteDone`,e=>{let{bridgeId:t}=e;$.componentRouteDone({bridgeId:t})}),this.message.on(`componentError`,e=>{$.componentError(e)}),this.message.on(`h5SdkAction`,async(e={})=>{let t=e?.name?.replace(/h5/i,``),{url:n}=e?.params?.data?.params||{};if(e.params&&(e.params.data={...e.params?.data,...e.params?.data?.params||{}}),t===`postMessage`&&e.parentWebViewId){let{moduleId:t,attrs:n,params:r}=e,i={detail:{data:[r?.data?.params?.data]}},a=n.message,o=e.parentWebViewId,s=await $.triggerEvent({bridgeId:o,moduleId:t,methodName:a,event:i});s!==void 0&&this.message.send({type:`triggerCallback`,target:`service`,body:{bridgeId:o,moduleId:t,success:r?.success,data:s}})}Va[t]?.({url:n,...e.params})})}}})();
6
+ `;console.error(`require ${e} error: ${a}`),n(r)&&r({mod:e,errMsg:t.message})}i.exports=t.exports===void 0?a:t.exports}return n(t)&&t(i.exports),i.exports}C.async=async e=>new Promise((t,n)=>{try{t(C(e))}catch(t){n(Error(`${t.message}: Failed to initialize asynchronous loading for module '${e}'`))}});var w=new class{constructor(){this.callbacks={}}store(e,t,n=_()){if(t){for(let[t,n]of Object.entries(this.callbacks))if(n.callback===e)return t}return this.callbacks[n]={callback:e,keep:t},n}invoke(e,t){if(e===void 0)return;let r=this.callbacks[e];r&&n(r.callback)&&(r.callback(t),r.keep||delete this.callbacks[e])}remove(e){e?Object.keys(this.callbacks).forEach(t=>{e===t&&delete this.callbacks[t]}):Object.entries(this.callbacks).forEach(([e,t])=>{t.keep&&delete this.callbacks[e]})}},T=new class{constructor(){this.reset()}reset(){this.active=!1,this.snapshot={systemInfo:null,menuRect:null}}init(e={}){this.active=!0,this.snapshot={...this.snapshot,...e}}update(e={}){this.snapshot={...this.snapshot,...e}}get(e){return this.active?this.snapshot[e]??null:null}getSystemInfo(){return this.get(`systemInfo`)}getMenuRect(){return this.get(`menuRect`)}};function fe(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)})}}}var E=new class e{constructor(){this.event=fe(),this.init()}init(){y?globalThis.onmessage=e=>{this.handleMsg(e.data)}:DiminaServiceBridge.onMessage=this.handleMsg.bind(this)}handleMsg(e){console.log(`[service] receive msg: `,y?e:JSON.stringify(e));let{type:t,body:n}=e;this.event.emit(t,n)}on(e,t){this.event.on(e,t)}off(e){this.event.off(e)}send(t){return y?e.prototype.send=function(e){e.method=`publish`,globalThis.postMessage(e)}:e.prototype.send=function(e){return DiminaServiceBridge.publish(e.body.bridgeId||``,e)},this.send(t)}invoke(t){return y?e.prototype.invoke=function(e){e.method=`invoke`,globalThis.postMessage(e)}:e.prototype.invoke=function(e){return DiminaServiceBridge.invoke(e)},this.invoke(t)}},D=new class{#e=[];#t=``;setInitId(e){this.#t=e}push(e,t){this.stack(t).push(e)}pop(){this.stack().length>0&&this.stack().pop()}getPageInfo(){let e=this.stack();return e[e.length-1]||{id:this.#t}}pushStack(e){let t={id:e,pages:[]};return this.#e.push(t),t}popStack(e){if(e){let t=this.#e.findIndex(t=>t.id===e);t!==-1&&this.#e.splice(t,1)}else this.#e.length>0&&this.#e.pop()}stack(e){if(e){let t=this.#e.find(t=>t.id===e);return t||=this.pushStack(e),t.pages}else{let e=this.#e[this.#e.length-1];return e?e.pages:this.pushStack(Date.now()).pages}}},pe={getWindowInfo:()=>T.getSystemInfo(),getSystemInfoSync:()=>T.getSystemInfo(),getAppBaseInfo:()=>T.getSystemInfo(),getDeviceInfo:()=>T.getSystemInfo(),getMenuButtonBoundingClientRect:()=>T.getMenuRect()},me=new Set([`connectSocket`,`downloadFile`,`loadSubpackage`,`preDownloadSubpackage`,`request`,`uploadFile`]),he=new Set(`FileSystemManager.getSavedFileList,clearStorage,chooseImage,chooseMedia,chooseVideo,closeBluetoothAdapter,getClipboardData,getBluetoothAdapterState,getBluetoothDevices,getLocation,getNetworkType,getPrivacySetting,getStorageInfo,getSystemInfo,getSystemInfoAsync,getUserInfo,hideKeyboard,hideLoading,hideShareMenu,hideTabBar,hideToast,login,navigateBack,openAppAuthorizeSetting,openBluetoothAdapter,openSetting,openSystemBluetoothSetting,showNavigationBarLoading,showShareMenu,showTabBar,startPullDownRefresh,startRecord,stopPullDownRefresh,stopBluetoothDevicesDiscovery,stopLocationUpdate,stopRecord,vibrateLong,vibrateShort`.split(`,`));function ge(e){return Object.prototype.hasOwnProperty.call(e,`success`)||Object.prototype.hasOwnProperty.call(e,`fail`)||Object.prototype.hasOwnProperty.call(e,`complete`)}function _e(e,t){return me.has(e)||typeof e==`string`&&e.endsWith(`Sync`)?!1:t===void 0?he.has(e):!0}function ve(e,t,n){let r={type:`invokeAPI`,target:n,body:{name:e,bridgeId:D.getPageInfo().id,params:t}};return n===`container`?E.invoke(r):E.send(r)}function ye(e,t,n){return new Promise((r,i)=>{let a,o,s=()=>{w.remove(a),w.remove(o)};a=w.store(e=>{s(),r(e)}),o=w.store(e=>{s(),i(e)}),t.success=a,t.fail=o;try{ve(e,t,n)}catch(e){s(),i(e)}})}function O(e,t,r=`container`){let i=pe[e];if(r===`container`&&i){let e=i();if(e)return e}let a;if(t===void 0){if(_e(e,t))return ye(e,{},r);a=t}else if(typeof t==`string`||Array.isArray(t))a=t;else if(n(t))a={success:w.store(t,!0)};else if(ge(t)){let{success:e,fail:r,complete:i,keep:o,evtId:s,...c}=t;a=c,n(e)?a.success=w.store(e,o,s):a.success=e,n(r)&&(a.fail=w.store(r,o,s)),n(i)&&(a.complete=w.store(i,o,s))}else{let{keep:n,...i}=t;if(delete i.evtId,!n&&_e(e,t))return a={...i},ye(e,a,r);a=i}return ve(e,a,r)}var be=t({navigateBack:()=>Te,navigateTo:()=>we,reLaunch:()=>Se,redirectTo:()=>Ce,switchTab:()=>xe});function xe(e){return e.url=b(D.getPageInfo().route,e.url),O(`switchTab`,e)}function Se(e){return e.url=b(D.getPageInfo().route,e.url),O(`reLaunch`,e)}function Ce(e){let t=b(D.getPageInfo().route,e.url);if(D.getPageInfo().route!==t)return e.url=t,O(`redirectTo`,e)}function we(e){return e.url=b(D.getPageInfo().route,e.url),O(`navigateTo`,e)}function Te(e){return O(`navigateBack`,e)}var Ee=t({offAppHide:()=>Me,offAppShow:()=>je,offError:()=>Oe,onAppHide:()=>Ae,onAppRoute:()=>Fe,onAppShow:()=>ke,onError:()=>De,onPageNotFound:()=>Pe,onUnhandledRejection:()=>Ne});function De(e){return O(`onError`,e)}function Oe(e){return O(`offError`,e)}function ke(e){return O(`onAppShow`,e)}function Ae(e){return O(`onAppHide`,e)}function je(e){return O(`offAppShow`,e)}function Me(e){return O(`offAppHide`,e)}function Ne(){}function Pe(){}function Fe(){}var Ie=t({canIUse:()=>ze,env:()=>Le});function Le(){return{USER_DATA_PATH:`difile://`}}var Re=new Set([`nextTick`,`getUpdateManager`,`UpdateManager`,`UpdateManager.applyUpdate`,`UpdateManager.onCheckForUpdate`,`UpdateManager.onUpdateFailed`,`UpdateManager.onUpdateReady`,`getPerformance`]);function ze(e){if(Re.has(e))return!0;try{return O(`canIUse`,e)}catch(t){return console.warn(`[canIUse] check ${e} error:`,t),!1}}var Be=t({getPerformance:()=>Ve});function Ve(){return He.getInstance()}var He=class e{static#e=null;constructor(){if(e.#e)throw Error(`Cannot instantiate more than one Performance instance.`);this.entryList=new Ue,e.#e=this}static getInstance(){return e.#e||=new e,e.#e}createObserver(e){let t=new We(e);return e&&O(`addPerformanceObserver`,{success:w.store(e=>{let n=e?.data?.entryList&&JSON.parse(e?.data?.entryList)||[];n&&(this.entryList.push(n),t.notify(n))},!0)},`render`),t}getEntries(){return this.entryList.getEntries()}getEntriesByName(e,t){return this.entryList.getEntriesByName(e,t)}getEntriesByType(e){return this.entryList.getEntriesByType(e)}setBufferSize(e){this.entryList.maxEntrySize=e}},Ue=class{constructor(){this._list=[],this.maxEntrySize=30}push(e){for(let t of e)this._list.length>=this.maxEntrySize&&this._list.shift(),this._list.push(t)}getEntriesByName(e,t){return this._entryFilter(e,t)}getEntriesByType(e){return this._entryFilter(null,e)}_entryFilter(e,t){return this._list.filter(n=>!(e&&e!==n.name||t&&t!==n.entryType))}getEntries(){return this._list}},We=class{constructor(e){this.entryTypes=[],this.callback=e}observe(e){this.connected=!0,this.entryTypes=e.entryTypes}notify(e){if(this.connected){let t=new Ue;t.push(e.filter(e=>{let t=!1;return this.entryTypes&&this.entryTypes.length>0&&this.entryTypes.forEach(n=>{e.entryType===n&&(t=!0)}),t})),this.callback(t)}}disconnect(){this.connected=!1}},Ge=t({loadSubpackage:()=>qe,preDownloadSubpackage:()=>Ke});function Ke(e){return O(`preDownloadSubpackage`,e)}function qe(e){return O(`loadSubpackage`,e)}var Je=t({getAppBaseInfo:()=>tt,getDeviceInfo:()=>nt,getSystemInfo:()=>Qe,getSystemInfoAsync:()=>et,getSystemInfoSync:()=>$e,getWindowInfo:()=>Xe,openAppAuthorizeSetting:()=>Ze,openSystemBluetoothSetting:()=>Ye});function Ye(e){return O(`openSystemBluetoothSetting`,e)}function Xe(e){return O(`getWindowInfo`,e)}function Ze(e){return O(`openAppAuthorizeSetting`,e)}function Qe(e){return new Promise(t=>{t(O(`getSystemInfo`,e))})}function $e(){return O(`getSystemInfoSync`)}function et(e){return O(`getSystemInfoAsync`,e)}function tt(){return O(`getAppBaseInfo`)}function nt(){return O(`getDeviceInfo`)}var rt=t({getUpdateManager:()=>lt}),it=`onUpdateStatusChange`,at=`updatefail`,ot=`updateready`,st=`noupdate`,ct=`updating`;function lt(){return ut.getInstance()}var ut=class e{static#e=null;constructor(){if(e.#e)throw Error(`Cannot instantiate more than one UpdateManager instance.`);this.hasAppliedUpdate=!1,this.updateFailed=!1,this.updateReady=!1,this.checkForUpdateResult=null,this.updateFailedListeners=[],this.updateReadyListeners=[],this.checkForUpdateListeners=[],E.on(it,e=>this.handleUpdateStatusChange(e)),e.#e=this}handleUpdateStatusChange(e={}){let{event:t}=e;if(t===at){this.updateFailed=!0,this.emit(this.updateFailedListeners);return}if(t===ot){this.updateReady=!0,this.checkForUpdateResult={hasUpdate:!0},this.emit(this.checkForUpdateListeners,this.checkForUpdateResult),this.emit(this.updateReadyListeners);return}if(t===ct){this.checkForUpdateResult={hasUpdate:!0},this.emit(this.checkForUpdateListeners,this.checkForUpdateResult);return}if(t===st){this.checkForUpdateResult={hasUpdate:!1},this.emit(this.checkForUpdateListeners,this.checkForUpdateResult);return}typeof e.hasUpdate==`boolean`&&(this.checkForUpdateResult={hasUpdate:e.hasUpdate},this.emit(this.checkForUpdateListeners,this.checkForUpdateResult))}emit(e,...t){e.slice().forEach(e=>{e(...t)})}static getInstance(){return e.#e||=new e,e.#e}applyUpdate(){if(!this.updateReady)console.error(`[applyUpdate]: update is not ready`);else if(this.hasAppliedUpdate)console.error(`[applyUpdate]: applyUpdate has been called`);else return this.hasAppliedUpdate=!0,O(`applyUpdate`)}onCheckForUpdate(e){typeof e==`function`&&(this.checkForUpdateListeners.push(e),this.checkForUpdateResult&&e(this.checkForUpdateResult))}onUpdateFailed(e){typeof e==`function`&&(this.updateFailedListeners.push(e),this.updateFailed&&e())}onUpdateReady(e){typeof e==`function`&&(this.updateReadyListeners.push(e),this.updateReady&&e())}};ut.getInstance();var dt=t({createCameraContext:()=>ft});function ft(){return new pt}var pt=class{constructor(){this.bridgeId=D.getPageInfo().id}takePhoto(e){return O(`takePhoto`,e)}startRecord(){return O(`startRecord`)}stopRecord(){return O(`stopRecord`)}},mt=t({reportAnalytics:()=>ht,reportEvent:()=>gt});function ht(...e){return O(`reportAnalytics`,e)}function gt(e,t){return O(`reportAnalytics`,{eventId:e,data:t})}var _t=t({closeBluetoothAdapter:()=>Ot,getBluetoothAdapterState:()=>Dt,getBluetoothDevices:()=>Et,getConnectedBluetoothDevices:()=>Tt,offBluetoothAdapterStateChange:()=>wt,offBluetoothDeviceFound:()=>Ct,onBluetoothAdapterStateChange:()=>St,onBluetoothDeviceFound:()=>xt,openBluetoothAdapter:()=>bt,startBluetoothDevicesDiscovery:()=>yt,stopBluetoothDevicesDiscovery:()=>vt});function vt(e){return O(`stopBluetoothDevicesDiscovery`,e)}function yt(e){return O(`startBluetoothDevicesDiscovery`,e)}function bt(e){return O(`openBluetoothAdapter`,e)}function xt(e){return O(`onBluetoothDeviceFound`,e)}function St(e){return O(`onBluetoothAdapterStateChange`,e)}function Ct(){return O(`offBluetoothDeviceFound`)}function wt(){return O(`offBluetoothAdapterStateChange`)}function Tt(e){return O(`getConnectedBluetoothDevices`,e)}function Et(e){return O(`getBluetoothDevices`,e)}function Dt(e){return O(`getBluetoothAdapterState`,e)}function Ot(e){return O(`closeBluetoothAdapter`,e)}var kt=t({closeBLEConnection:()=>Ht,createBLEConnection:()=>Vt,getBLEDeviceCharacteristics:()=>Bt,getBLEDeviceRSSI:()=>zt,getBLEDeviceServices:()=>Rt,notifyBLECharacteristicValueChange:()=>Lt,offBLECharacteristicValueChange:()=>It,offBLEConnectionStateChange:()=>Ft,onBLECharacteristicValueChange:()=>Pt,onBLEConnectionStateChange:()=>Nt,readBLECharacteristicValue:()=>Mt,setBLEMTU:()=>jt,writeBLECharacteristicValue:()=>At});function At(e){return O(`writeBLECharacteristicValue`,e)}function jt(e){return O(`setBLEMTU`,e)}function Mt(e){return O(`readBLECharacteristicValue`,e)}function Nt(e){return O(`onBLEConnectionStateChange`,e)}function Pt(e){return O(`onBLECharacteristicValueChange`,e)}function Ft(e){return O(`offBLEConnectionStateChange`,e)}function It(){return O(`offBLECharacteristicValueChange`)}function Lt(e){return O(`notifyBLECharacteristicValueChange`,e)}function Rt(e){return O(`getBLEDeviceServices`,e)}function zt(e){return O(`getBLEDeviceRSSI`,e)}function Bt(e){return O(`getBLEDeviceCharacteristics`,e)}function Vt(e){return O(`createBLEConnection`,e)}function Ht(e){return O(`closeBLEConnection`,e)}var Ut=t({getClipboardData:()=>Gt,setClipboardData:()=>Wt});function Wt(e){return O(`setClipboardData`,e)}function Gt(e){return O(`getClipboardData`,e)}var Kt=t({addPhoneContact:()=>Jt,chooseContact:()=>qt});function qt(e){return O(`chooseContact`,e)}function Jt(e){return O(`addPhoneContact`,e)}var Yt=t({hideKeyboard:()=>Xt});function Xt(e){return O(`hideKeyboard`,e)}var Zt=t({offMemoryWarning:()=>$t,onMemoryWarning:()=>Qt});function Qt(e){return O(`onMemoryWarning`,e)}function $t(e){return O(`offMemoryWarning`,e)}var en=t({getNetworkType:()=>tn});function tn(e){return O(`getNetworkType`,e)}var nn=t({makePhoneCall:()=>rn});function rn(e){return O(`makePhoneCall`,e)}var an=t({scanCode:()=>on});function on(e){return O(`scanCode`,e)}var sn=t({vibrateLong:()=>ln,vibrateShort:()=>cn});function cn(e){return O(`vibrateShort`,e)}function ln(e){return O(`vibrateLong`,e)}var un=t({extBridge:()=>dn,extOffBridge:()=>pn,extOnBridge:()=>fn,offLoginStatusChanged:()=>hn,onLoginStatusChanged:()=>mn});function dn({event:e,module:t,data:r={},success:i,fail:a,complete:o},s){let c,l,u;return n(s)?(c=s,l=s):(c=i,l=a,u=o),O(e,{module:t,data:r,keep:r.isSustain??!0,success:c,fail:l,complete:u})}function fn({event:e,module:t,callBack:n,isSustain:r=!0}){if(!t||t===`DMServiceBridgeModule`){console.error(`[ERROR]: extOnBridge \u53C2\u6570 module ${t?`\u503C${t}\u4E0D\u5408\u6CD5`:`为空`}`);return}if(!e){console.error(`[ERROR]: extOnBridge 参数 event 为空`);return}if(!n){console.error(`[ERROR]: extOnBridge 参数 callBack 为空`);return}let i=`${t}_${e}`;O(i,{evtId:i,keep:r,success:n})}function pn({event:e,module:t,callBack:n}){if(!t||t===`DMServiceBridgeModule`){console.error(`[ERROR]: extOffBridge \u53C2\u6570 module ${t?`\u503C${t}\u4E0D\u5408\u6CD5`:`为空`}`);return}if(!e){console.error(`[ERROR]: extOffBridge 参数 event 为空`);return}O(`${t}_${e}`,{success:n})}function mn(e){E.on(`notifyLoginStatusChanged`,t=>{e?.(t)})}function hn(){E.off(`notifyLoginStatusChanged`)}var gn=t({USER_DATA_PATH:()=>_n,getFileSystemManager:()=>wn}),_n=`difile://`,vn=`not supported in simulator`,yn=class{constructor(e){this.size=e.size||0,this.mode=e.mode||438,this.lastAccessedTime=e.lastAccessedTime||0,this.lastModifiedTime=e.lastModifiedTime||0,this._isFile=e.isFile===void 0?!0:e.isFile,this._isDirectory=e.isDirectory===void 0?!1:e.isDirectory}isFile(){return this._isFile}isDirectory(){return this._isDirectory}};function k(e){throw Error(`FileSystemManager.${e} ${vn}`)}function A(e,t={}){let{fail:n,complete:r}=t;n?.({errMsg:`${e}:fail ${vn}`}),r?.()}function bn(e){return e&&new yn(e)}function xn(e){if(!e||typeof e!=`object`)return e;let t={};for(let[n,r]of Object.entries(e))t[n]=new yn(r);return t}var Sn=class{access(e){O(`fsAccess`,e)}accessSync(){k(`accessSync`)}stat(e={}){let{success:t,recursive:n,...r}=e;O(`fsStat`,{...r,recursive:n,success:e=>{if(!t)return;let r=n?xn(e?.stats):bn(e?.stats);t({...e,stats:r})}})}statSync(){k(`statSync`)}readFile(e){O(`fsReadFile`,e)}readFileSync(){k(`readFileSync`)}writeFile(e){O(`fsWriteFile`,e)}writeFileSync(){k(`writeFileSync`)}appendFile(e){O(`fsAppendFile`,e)}appendFileSync(){k(`appendFileSync`)}copyFile(e){O(`fsCopyFile`,e)}copyFileSync(){k(`copyFileSync`)}rename(e){O(`fsRename`,e)}renameSync(){k(`renameSync`)}unlink(e){O(`fsUnlink`,e)}unlinkSync(){k(`unlinkSync`)}mkdir(e){O(`fsMkdir`,e)}mkdirSync(){k(`mkdirSync`)}rmdir(e){O(`fsRmdir`,e)}rmdirSync(){k(`rmdirSync`)}readdir(e){O(`fsReaddir`,e)}readdirSync(){k(`readdirSync`)}getFileInfo(e){O(`fsGetFileInfo`,e)}saveFile(e){O(`fsSaveFile`,e)}saveFileSync(){k(`saveFileSync`)}getSavedFileList(e){O(`fsGetSavedFileList`,e)}removeSavedFile(e){O(`fsRemoveSavedFile`,e)}truncate(e){O(`fsTruncate`,e)}truncateSync(){k(`truncateSync`)}unzip(e){O(`fsUnzip`,e)}open(e){A(`open`,e)}openSync(){k(`openSync`)}close(e){A(`close`,e)}closeSync(){k(`closeSync`)}read(e){A(`read`,e)}readSync(){k(`readSync`)}write(e){A(`write`,e)}writeSync(){k(`writeSync`)}fstat(e){A(`fstat`,e)}fstatSync(){k(`fstatSync`)}ftruncate(e){A(`ftruncate`,e)}ftruncateSync(){k(`ftruncateSync`)}readCompressedFile(e){A(`readCompressedFile`,e)}readCompressedFileSync(){k(`readCompressedFileSync`)}readZipEntry(e){A(`readZipEntry`,e)}},Cn;function wn(){return Cn||=new Sn,Cn}var Tn=[`onLaunch`,`onShow`,`onHide`],En=[`globalData`],Dn=class{constructor(e,t){this.appModule=e,this.options=t,this.init()}init(){this.initGlobalData(),this.initLifecycle(),this.initCustomMethods(),this.invokeSomeLifecycle()}initGlobalData(){this.globalData=this.appModule.moduleInfo.globalData}initLifecycle(){Tn.forEach(e=>{let t=this.appModule.moduleInfo[e];n(t)&&(this[e]=t.bind(this))})}initCustomMethods(){let e=this.appModule.moduleInfo;for(let t in e)Tn.includes(t)||En.includes(t)||(n(e[t])?this[t]=e[t].bind(this):this[t]=e[t])}invokeSomeLifecycle(){this.onLaunch?.(this.options),this.onShow?.(this.options)}appShow(){this.onShow?.(this.options)}appHide(){this.onHide?.()}},On=new Set([`2d`]),kn=new Set([`webgl`,`experimental-webgl`,`webgl2`]),An=new Set([`createLinearGradient`,`createPattern`,`createRadialGradient`]),jn=new Set([`createBuffer`,`createFramebuffer`,`createProgram`,`createRenderbuffer`,`createShader`,`createTexture`]),Mn=new Set([`getAttribLocation`,`getUniformLocation`]),j={DEPTH_BUFFER_BIT:256,STENCIL_BUFFER_BIT:1024,COLOR_BUFFER_BIT:16384,FALSE:0,TRUE:1,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,ZERO:0,ONE:1,SRC_COLOR:768,ONE_MINUS_SRC_COLOR:769,SRC_ALPHA:770,ONE_MINUS_SRC_ALPHA:771,DST_ALPHA:772,ONE_MINUS_DST_ALPHA:773,DST_COLOR:774,ONE_MINUS_DST_COLOR:775,SRC_ALPHA_SATURATE:776,FUNC_ADD:32774,BLEND_EQUATION:32777,BLEND_EQUATION_RGB:32777,BLEND_EQUATION_ALPHA:34877,FUNC_SUBTRACT:32778,FUNC_REVERSE_SUBTRACT:32779,BLEND_DST_RGB:32968,BLEND_SRC_RGB:32969,BLEND_DST_ALPHA:32970,BLEND_SRC_ALPHA:32971,CONSTANT_COLOR:32769,ONE_MINUS_CONSTANT_COLOR:32770,CONSTANT_ALPHA:32771,ONE_MINUS_CONSTANT_ALPHA:32772,BLEND_COLOR:32773,ARRAY_BUFFER:34962,ELEMENT_ARRAY_BUFFER:34963,ARRAY_BUFFER_BINDING:34964,ELEMENT_ARRAY_BUFFER_BINDING:34965,STREAM_DRAW:35040,STATIC_DRAW:35044,DYNAMIC_DRAW:35048,BUFFER_SIZE:34660,BUFFER_USAGE:34661,CURRENT_VERTEX_ATTRIB:34342,FRONT:1028,BACK:1029,FRONT_AND_BACK:1032,CULL_FACE:2884,BLEND:3042,DITHER:3024,STENCIL_TEST:2960,DEPTH_TEST:2929,SCISSOR_TEST:3089,POLYGON_OFFSET_FILL:32823,SAMPLE_ALPHA_TO_COVERAGE:32926,SAMPLE_COVERAGE:32928,NO_ERROR:0,INVALID_ENUM:1280,INVALID_VALUE:1281,INVALID_OPERATION:1282,OUT_OF_MEMORY:1285,CW:2304,CCW:2305,LINE_WIDTH:2849,ALIASED_POINT_SIZE_RANGE:33901,ALIASED_LINE_WIDTH_RANGE:33902,CULL_FACE_MODE:2885,FRONT_FACE:2886,DEPTH_RANGE:2928,DEPTH_WRITEMASK:2930,DEPTH_CLEAR_VALUE:2931,DEPTH_FUNC:2932,STENCIL_CLEAR_VALUE:2961,STENCIL_FUNC:2962,STENCIL_FAIL:2964,STENCIL_PASS_DEPTH_FAIL:2965,STENCIL_PASS_DEPTH_PASS:2966,STENCIL_REF:2967,STENCIL_VALUE_MASK:2963,STENCIL_WRITEMASK:2968,STENCIL_BACK_FUNC:34816,STENCIL_BACK_FAIL:34817,STENCIL_BACK_PASS_DEPTH_FAIL:34818,STENCIL_BACK_PASS_DEPTH_PASS:34819,STENCIL_BACK_REF:36003,STENCIL_BACK_VALUE_MASK:36004,STENCIL_BACK_WRITEMASK:36005,VIEWPORT:2978,SCISSOR_BOX:3088,COLOR_CLEAR_VALUE:3106,COLOR_WRITEMASK:3107,UNPACK_ALIGNMENT:3317,PACK_ALIGNMENT:3333,MAX_TEXTURE_SIZE:3379,MAX_VIEWPORT_DIMS:3386,SUBPIXEL_BITS:3408,RED_BITS:3410,GREEN_BITS:3411,BLUE_BITS:3412,ALPHA_BITS:3413,DEPTH_BITS:3414,STENCIL_BITS:3415,POLYGON_OFFSET_UNITS:10752,POLYGON_OFFSET_FACTOR:32824,TEXTURE_BINDING_2D:32873,SAMPLE_BUFFERS:32936,SAMPLES:32937,SAMPLE_COVERAGE_VALUE:32938,SAMPLE_COVERAGE_INVERT:32939,COMPRESSED_TEXTURE_FORMATS:34467,DONT_CARE:4352,FASTEST:4353,NICEST:4354,GENERATE_MIPMAP_HINT:33170,BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,INT:5124,UNSIGNED_INT:5125,FLOAT:5126,DEPTH_COMPONENT:6402,ALPHA:6406,RGB:6407,RGBA:6408,LUMINANCE:6409,LUMINANCE_ALPHA:6410,UNSIGNED_SHORT_4_4_4_4:32819,UNSIGNED_SHORT_5_5_5_1:32820,UNSIGNED_SHORT_5_6_5:33635,FRAGMENT_SHADER:35632,VERTEX_SHADER:35633,MAX_VERTEX_ATTRIBS:34921,MAX_VERTEX_UNIFORM_VECTORS:36347,MAX_VARYING_VECTORS:36348,MAX_COMBINED_TEXTURE_IMAGE_UNITS:35661,MAX_VERTEX_TEXTURE_IMAGE_UNITS:35660,MAX_TEXTURE_IMAGE_UNITS:34930,MAX_FRAGMENT_UNIFORM_VECTORS:36349,SHADER_TYPE:35663,DELETE_STATUS:35712,LINK_STATUS:35714,VALIDATE_STATUS:35715,ATTACHED_SHADERS:35717,ACTIVE_UNIFORMS:35718,ACTIVE_ATTRIBUTES:35721,SHADING_LANGUAGE_VERSION:35724,CURRENT_PROGRAM:35725,NEVER:512,LESS:513,EQUAL:514,LEQUAL:515,GREATER:516,NOTEQUAL:517,GEQUAL:518,ALWAYS:519,KEEP:7680,REPLACE:7681,INCR:7682,DECR:7683,INVERT:5386,INCR_WRAP:34055,DECR_WRAP:34056,VENDOR:7936,RENDERER:7937,VERSION:7938,NEAREST:9728,LINEAR:9729,NEAREST_MIPMAP_NEAREST:9984,LINEAR_MIPMAP_NEAREST:9985,NEAREST_MIPMAP_LINEAR:9986,LINEAR_MIPMAP_LINEAR:9987,TEXTURE_MAG_FILTER:10240,TEXTURE_MIN_FILTER:10241,TEXTURE_WRAP_S:10242,TEXTURE_WRAP_T:10243,TEXTURE_2D:3553,TEXTURE:5890,TEXTURE_CUBE_MAP:34067,TEXTURE_BINDING_CUBE_MAP:34068,TEXTURE_CUBE_MAP_POSITIVE_X:34069,TEXTURE_CUBE_MAP_NEGATIVE_X:34070,TEXTURE_CUBE_MAP_POSITIVE_Y:34071,TEXTURE_CUBE_MAP_NEGATIVE_Y:34072,TEXTURE_CUBE_MAP_POSITIVE_Z:34073,TEXTURE_CUBE_MAP_NEGATIVE_Z:34074,MAX_CUBE_MAP_TEXTURE_SIZE:34076,TEXTURE0:33984,TEXTURE1:33985,TEXTURE2:33986,TEXTURE3:33987,TEXTURE4:33988,TEXTURE5:33989,TEXTURE6:33990,TEXTURE7:33991,TEXTURE8:33992,TEXTURE9:33993,TEXTURE10:33994,TEXTURE11:33995,TEXTURE12:33996,TEXTURE13:33997,TEXTURE14:33998,TEXTURE15:33999,TEXTURE16:34e3,TEXTURE17:34001,TEXTURE18:34002,TEXTURE19:34003,TEXTURE20:34004,TEXTURE21:34005,TEXTURE22:34006,TEXTURE23:34007,TEXTURE24:34008,TEXTURE25:34009,TEXTURE26:34010,TEXTURE27:34011,TEXTURE28:34012,TEXTURE29:34013,TEXTURE30:34014,TEXTURE31:34015,ACTIVE_TEXTURE:34016,REPEAT:10497,CLAMP_TO_EDGE:33071,MIRRORED_REPEAT:33648,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,INT_VEC2:35667,INT_VEC3:35668,INT_VEC4:35669,BOOL:35670,BOOL_VEC2:35671,BOOL_VEC3:35672,BOOL_VEC4:35673,FLOAT_MAT2:35674,FLOAT_MAT3:35675,FLOAT_MAT4:35676,SAMPLER_2D:35678,SAMPLER_CUBE:35680,LOW_FLOAT:36336,MEDIUM_FLOAT:36337,HIGH_FLOAT:36338,LOW_INT:36339,MEDIUM_INT:36340,HIGH_INT:36341,FRAMEBUFFER:36160,RENDERBUFFER:36161,RGBA4:32854,RGB5_A1:32855,RGB565:36194,DEPTH_COMPONENT16:33189,STENCIL_INDEX8:36168,DEPTH_STENCIL:34041,RENDERBUFFER_WIDTH:36162,RENDERBUFFER_HEIGHT:36163,RENDERBUFFER_INTERNAL_FORMAT:36164,RENDERBUFFER_RED_SIZE:36176,RENDERBUFFER_GREEN_SIZE:36177,RENDERBUFFER_BLUE_SIZE:36178,RENDERBUFFER_ALPHA_SIZE:36179,RENDERBUFFER_DEPTH_SIZE:36180,RENDERBUFFER_STENCIL_SIZE:36181,FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE:36048,FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:36049,FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL:36050,FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE:36051,COLOR_ATTACHMENT0:36064,DEPTH_ATTACHMENT:36096,STENCIL_ATTACHMENT:36128,DEPTH_STENCIL_ATTACHMENT:33306,NONE:0,FRAMEBUFFER_COMPLETE:36053,FRAMEBUFFER_INCOMPLETE_ATTACHMENT:36054,FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:36055,FRAMEBUFFER_INCOMPLETE_DIMENSIONS:36057,FRAMEBUFFER_UNSUPPORTED:36061,FRAMEBUFFER_BINDING:36006,RENDERBUFFER_BINDING:36007,MAX_RENDERBUFFER_SIZE:34024,INVALID_FRAMEBUFFER_OPERATION:1286,UNPACK_FLIP_Y_WEBGL:37440,UNPACK_PREMULTIPLY_ALPHA_WEBGL:37441,CONTEXT_LOST_WEBGL:37442,UNPACK_COLORSPACE_CONVERSION_WEBGL:37443,BROWSER_DEFAULT_WEBGL:37444,COMPILE_STATUS:35713},Nn=1,Pn=1;function M(){let e=D.getPageInfo();return e?.bridgeId||e?.id||``}function N(e,t,n){E.send({type:`invokeAPI`,target:`render`,body:{bridgeId:e,name:t,params:n}})}function Fn(e){Promise.resolve().then(e)}function In(e){return Object.prototype.toString.call(e)===`[object Object]`}function Ln(e){return typeof ArrayBuffer>`u`||!ArrayBuffer.isView(e)?null:e instanceof DataView?{__canvasTypedArray:`DataView`,data:Array.from(new Uint8Array(e.buffer,e.byteOffset,e.byteLength))}:{__canvasTypedArray:e.constructor.name,data:Array.from(e)}}function P(e){if(e==null)return e;if(e.__canvasResourceId)return{__canvasResourceId:e.__canvasResourceId};if(e.__diminaCanvasNode)return{__canvasNodeId:e.nodeId};let t=Ln(e);if(t)return t;if(typeof ArrayBuffer<`u`&&e instanceof ArrayBuffer)return{__canvasArrayBuffer:!0,data:Array.from(new Uint8Array(e))};if(Array.isArray(e))return e.map(e=>P(e));if(In(e)){let t={};for(let[n,r]of Object.entries(e))t[n]=P(r);return t}return e}function F(e){return Array.from(e).map(e=>P(e))}function I(e=`canvas_resource`){return`${e}_${_()}`}var Rn=class{constructor(e,t){return this.__canvasResourceId=t,this.__canvasProxyValue=Nn++,this.canvas=e,new Proxy(this,{get(e,n){if(n in e)return e[n];if(typeof n!=`symbol`)return(...r)=>{e.canvas.enqueueOperation({op:`resourceCall`,resourceId:t,method:n,args:F(r)})}}})}valueOf(){return this.__canvasProxyValue}toString(){return String(this.__canvasProxyValue)}},zn=class{constructor(e,t){this.__canvasResourceId=t,this.canvas=e,this.imageId=t,this.onload=null,this.onerror=null,this.width=0,this.height=0,this._src=``,this.canvas.enqueueOperation({op:`createImage`,imageId:t})}get src(){return this._src}set src(e){this._src=e;let t=w.store((e={})=>{this.width=e.width||this.width,this.height=e.height||this.height,n(this.onload)&&this.onload(e)}),r=w.store((e={})=>{n(this.onerror)&&this.onerror(e)});this.canvas.enqueueOperation({op:`imageSetSrc`,imageId:this.imageId,src:e,onload:t,onerror:r})}},Bn=class{constructor(e,t){return this.canvas=e,this.contextId=t,this.state={fillStyle:`#000000`,strokeStyle:`#000000`,font:`10px sans-serif`,globalAlpha:1,lineWidth:1},new Proxy(this,{get(e,t){if(t in e)return e[t];if(t in e.state)return e.state[t];if(typeof t!=`symbol`)return(...n)=>e.call(t,n)},set(e,n,r){return e.state[n]=r,e.canvas.enqueueOperation({op:`contextSetProperty`,contextId:t,prop:n,value:P(r)}),!0}})}call(e,t){if(e===`measureText`)return{width:String(t[0]??``).length*10};let n=An.has(e)?I():void 0;if(this.canvas.enqueueOperation({op:`contextCall`,contextId:this.contextId,method:e,args:F(t),resultId:n}),n)return new Rn(this.canvas,n)}},Vn=class{constructor(e,t,n){return this.canvas=e,this.contextId=t,this.contextType=n,new Proxy(this,{get(e,t){if(t in e)return e[t];if(Object.prototype.hasOwnProperty.call(j,t))return j[t];if(t===`drawingBufferWidth`)return e.canvas.width;if(t===`drawingBufferHeight`)return e.canvas.height;if(typeof t!=`symbol`)return(...n)=>e.call(t,n)}})}call(e,t){switch(e){case`getParameter`:return this.getParameter(t[0]);case`getShaderParameter`:case`getProgramParameter`:return!0;case`getShaderInfoLog`:case`getProgramInfoLog`:return``;case`getError`:return j.NO_ERROR;case`isContextLost`:return!1;case`checkFramebufferStatus`:return j.FRAMEBUFFER_COMPLETE;case`getContextAttributes`:return{};case`getSupportedExtensions`:return[];case`getExtension`:return null;default:break}let n=jn.has(e)||Mn.has(e)?I(`webgl_resource`):void 0;if(this.canvas.enqueueOperation({op:`contextCall`,contextId:this.contextId,method:e,args:F(t),resultId:n}),n)return new Rn(this.canvas,n)}getParameter(e){let{width:t,height:n}=this.canvas;switch(e){case j.VERSION:return`WebGL 1.0`;case j.SHADING_LANGUAGE_VERSION:return`WebGL GLSL ES 1.0`;case j.VENDOR:return`Dimina`;case j.RENDERER:return`Dimina WebGL Proxy`;case j.VIEWPORT:return[0,0,t,n];case j.MAX_VIEWPORT_DIMS:return[t||4096,n||4096];case j.ALIASED_POINT_SIZE_RANGE:return[1,64];case j.ALIASED_LINE_WIDTH_RANGE:return[1,1];case j.COLOR_CLEAR_VALUE:return[0,0,0,0];case j.COLOR_WRITEMASK:case j.DEPTH_WRITEMASK:return!0;case j.COMPRESSED_TEXTURE_FORMATS:return[];case j.MAX_TEXTURE_SIZE:case j.MAX_CUBE_MAP_TEXTURE_SIZE:case j.MAX_RENDERBUFFER_SIZE:return 4096;case j.MAX_VERTEX_ATTRIBS:return 16;case j.MAX_TEXTURE_IMAGE_UNITS:case j.MAX_VERTEX_TEXTURE_IMAGE_UNITS:case j.MAX_COMBINED_TEXTURE_IMAGE_UNITS:return 8;case j.MAX_VERTEX_UNIFORM_VECTORS:case j.MAX_FRAGMENT_UNIFORM_VECTORS:case j.MAX_VARYING_VECTORS:return 128;default:return 0}}},Hn=class{constructor({nodeId:e,bridgeId:t=M(),width:n=300,height:r=150,type:i=`2d`,offscreen:a=!1}){this.__diminaCanvasNode=!0,this.nodeId=e,this.bridgeId=t,this.type=i,this.offscreen=a,this.contexts=new Map,this.pendingOperations=[],this.flushScheduled=!1,this._width=n,this._height=r}get width(){return this._width}set width(e){this._width=e,this.enqueueOperation({op:`setCanvasProperty`,prop:`width`,value:e})}get height(){return this._height}set height(e){this._height=e,this.enqueueOperation({op:`setCanvasProperty`,prop:`height`,value:e})}getContext(e=`2d`,t){let n=String(e).toLowerCase();if(!On.has(n)&&!kn.has(n))return null;if(this.contexts.has(n))return this.contexts.get(n);let r=I(`canvas_context`);this.enqueueOperation({op:`getContext`,contextId:r,contextType:n,attributes:P(t)});let i=kn.has(n)?new Vn(this,r,n):new Bn(this,r);return this.contexts.set(n,i),i}createImage(){return new zn(this,I(`canvas_image`))}requestAnimationFrame(e){let t=Pn++,r=w.store(t=>{n(e)&&e(t)});return N(this.bridgeId,`canvasNodeRequestAnimationFrame`,{nodeId:this.nodeId,requestId:t,callback:r}),t}cancelAnimationFrame(e){N(this.bridgeId,`canvasNodeCancelAnimationFrame`,{nodeId:this.nodeId,requestId:e})}enqueueOperation(e){this.pendingOperations.push(e),!this.flushScheduled&&(this.flushScheduled=!0,Fn(()=>this.flushOperations()))}flushOperations(){if(this.flushScheduled=!1,this.pendingOperations.length===0)return;let e=this.pendingOperations;this.pendingOperations=[],N(this.bridgeId,`canvasNodeFlush`,{nodeId:this.nodeId,operations:e})}};function Un(e,t=M()){return!e||e.__diminaNodeType!==`dimina-canvas-node`?e:new Hn({nodeId:e.nodeId,bridgeId:t,width:e.width,height:e.height,type:e.type})}function Wn(e,t=M()){return Array.isArray(e)?e.map(e=>Wn(e,t)):!e||typeof e!=`object`?e:e.node?{...e,node:Un(e.node,t)}:e}function Gn(e={}){let t=Number(e.width)||300,n=Number(e.height)||150,r=e.type||`2d`,i=I(`offscreen_canvas`),a=M();return N(a,`createOffscreenCanvas`,{nodeId:i,width:t,height:n,type:r}),new Hn({nodeId:i,bridgeId:a,width:t,height:n,type:r,offscreen:!0})}var Kn=t({createSelectorQuery:()=>L});function L(){return new Xn}function qn(){return D.getPageInfo()}function Jn(){let e=qn();return e?.__id__||e?.id}function Yn(){let e=qn();return e?.bridgeId||e?.id}var Xn=class{constructor(){this.__componentId=Jn(),this.__taskQueue=[],this.__cbQueue=[]}in(e){return this.__componentId=e.__id__,this}select(e){return new R(this,this.__componentId,e,!0)}selectAll(e){return new R(this,this.__componentId,e,!1)}selectViewport(){return new R(this,Jn(),``,!0)}__push(e,t,n,r,i){this.__taskQueue.push({moduleId:t,selector:e,single:n,fields:r}),this.__cbQueue.push(i)}exec(e){let t=this,r=Yn();O(`selectorQuery`,{tasks:this.__taskQueue,success:i=>{let a=Wn(i,r)||[];a.forEach((e,r)=>{let i=t.__cbQueue[r];n(i)&&i.call(t,e)}),n(e)&&e.call(t,a)}},`render`)}},R=class{constructor(e,t,n,r){this.__selectorQuery=e,this.__moduleId=t,this.__selector=n,this.__single=r}fields(e,t){return this.__selectorQuery.__push(this.__selector,this.__moduleId,this.__single,e,t),this.__selectorQuery}boundingClientRect(e){return this.fields({id:!0,dataset:!0,rect:!0,size:!0},e)}context(e){return this.fields({context:!0},e)}node(e){return this.fields({node:!0},e)}scrollOffset(e){return this.fields({id:!0,dataset:!0,scrollOffset:!0},e)}},Zn=t({createIntersectionObserver:()=>Qn});function Qn(e,t={}){let{thresholds:n=[0],initialRatio:r=0,observeAll:i=!1}=t;return new $n(e,{thresholds:n,initialRatio:r,observeAll:i})}var $n=class{constructor(e,t){this._component=e,this._options=t,this._relativeInfo=[],this._observerId=null,this._disconnected=!1}relativeTo(e,t={left:0,right:0,top:0,bottom:0}){if(this._observerId!==null)throw Error(`Relative nodes cannot be added after "observe" call in IntersectionObserver`);return this._relativeInfo.push({selector:e,margins:[`left`,`right`,`top`,`bottom`].map(e=>`${t[e]===void 0?0:t[e]}px`).join(` `)}),this}relativeToViewport(e={left:0,right:0,top:0,bottom:0}){if(this._observerId!==null)throw Error(`Relative nodes cannot be added after "observe" call in IntersectionObserver`);return this._relativeInfo.push({selector:null,margins:[`left`,`right`,`top`,`bottom`].map(t=>`${e[t]===void 0?0:e[t]}px`).join(` `)}),this}observe(e,t){let n=this,r=w.store(e=>{n._disconnected||(n._observerId=e.observerId),e.info&&t.call(n,e.info)},!0);O(`addIntersectionObserver`,{moduleId:this._component.__id__,targetSelector:e,relativeInfo:this._relativeInfo,options:this._options,success:r},`render`)}disconnect(){O(`removeIntersectionObserver`,{observerId:this._observerId},`render`),this._disconnected=!0}},z=new Map;function B(e){return z.has(e)||z.set(e,{depth:0,scheduled:!1,updates:[],byModuleId:new Map,callbackIds:[]}),z.get(e)}function V(e,t){let r=(Array.isArray(t)?t:[t]).filter(n);if(r.length!==0)return w.store(()=>{r.forEach(t=>t.call(e))})}function er(e){let t=B(e);t.depth++}function tr(e){let t=B(e);t.depth>0&&t.depth--,t.depth===0&&nr(e)}function H(e,t,n,r){let i=B(e),a=i.byModuleId.get(t);if(a)Object.assign(a.data,n);else{let e={moduleId:t,data:{...n}};i.byModuleId.set(t,e),i.updates.push(e)}r&&i.callbackIds.push(r),i.depth===0&&!i.scheduled&&(i.scheduled=!0,Promise.resolve().then(()=>{i.scheduled=!1,i.depth===0&&nr(e)}))}function nr(e){let t=z.get(e);if(!t||t.updates.length===0)return;let n=t.updates,r=t.callbackIds;t.updates=[],t.byModuleId=new Map,t.callbackIds=[],t.scheduled=!1,E.send({type:`ub`,target:`render`,body:{bridgeId:e,updates:n,callbackIds:r}})}function rr(e){let t=e.__mpxProxy?.options?.computed;if(t)for(let n of Object.keys(t))Object.prototype.hasOwnProperty.call(e.data,n)||(e.data[n]=null)}function U(e){return i(e)?e:Object.entries(e).reduce((e,[t,r])=>t.startsWith(`$`)?e:n(r)?(console.warn(`[service] 值不支持函数引用`,t),e):(Array.isArray(r)?e[t]=r.map(e=>typeof e==`object`&&e?e instanceof Date?e.getTime():U(e):e):r&&typeof r==`object`&&!Array.isArray(r)?r instanceof Date?e[t]=r.getTime():e[t]=U(r):e[t]=r,e),{})}function ir(e){if(e){let t={};for(let r in e){let i=e[r];t[r]=t[r]||{};let a=i&&typeof i==`object`&&Object.prototype.hasOwnProperty.call(i,`type`)?W(i.type):W(i),o=null;if(o=Array.isArray(a)?[...a]:[a],i&&i.optionalTypes){let e=W(i.optionalTypes);Array.isArray(e)?o=[...e]:o.push(e)}t[r].type=o,t[r].type.length>0&&(i&&n(i.value)?t[r].default=i.value():i&&(t[r].default=i.value))}return t}}var ar=new Map([[String,`s`],[Number,`n`],[Boolean,`b`],[Object,`o`],[Array,`a`],[Function,`f`]]);function W(e){return Array.isArray(e)?e.map(e=>W(e)):e===null||e===``?null:ar.get(e)||(console.warn(`[service] ignore unknown props type ${e}`),null)}function or(e,t,n,r,i){let a=new Set;for(let o of e)for(let e in t){if(a.has(e))continue;let s=e.split(`,`).map(e=>e.trim());if(s.includes(o)){a.add(e);let c=t[e],l=s.map(e=>g(n,e));s.length===1?c.call(r,...l,i[o]):c.call(r,...l);continue}if(e===`**`){a.add(e),t[e].call(r,n);continue}let c=e.split(`.`),l=o.split(`.`),u=!0;for(let e=0;e<c.length&&!(c[e]===`**`||l[e]===void 0);e++)if(c[e]!==l[e]){u=!1;break}if(u&&c.length>1){a.add(e);let s=n;for(let e of c)e!==`**`&&(s=s?.[e]);e===o?t[e].call(r,s,i[o]):t[e].call(r,s)}}}function sr(e,t,n,r,i){for(let a in t){let o=t[a],s=a.split(`,`).map(e=>e.trim());if(s.includes(e)){let t=s.map(e=>g(n,e));s.length===1&&s[0]===e?o.call(r,...t,i):o.call(r,...t);continue}if(a===`**`){o.call(r,n);continue}let c=a.split(`.`),l=e.split(`.`),u=!0;for(let e=0;e<c.length&&!(c[e]===`**`||l[e]===void 0);e++)if(c[e]!==l[e]){u=!1;break}if(u){let t=n;for(let e of c)e!==`**`&&(t=t[e]);a===e?o.call(r,t,i):o.call(r,t);continue}let d=a.match(/^(.+)\[(\d+)\]$/);if(d){let t=d[1],i=Number.parseInt(d[2],10);if(t===e.split(`[`)[0]&&n[t]&&n[t][i]!==void 0){o.call(r,n[t][i]);continue}}if(e.startsWith(a)){let e=a.split(`.`).reduce((e,t)=>e&&e[t],n);if(e!==void 0){o.call(r,e);continue}}}}function cr(e={},t=``){let n=t.trim();if(!n)return;let r=n.replace(/-/g,``).toLowerCase(),i=[n,ae(n),oe(n),r];for(let t of i)if(t&&e[t]!==void 0)return e[t]}function G(e,t,n){let r=e.__info__||{};if(r.behaviorObservers)for(let i in r.behaviorObservers){let a=r.behaviorObservers[i];if(!(!Array.isArray(a)||a.length===0))for(let r of t)a.forEach(t=>{sr(r,{[i]:t},e.data,e,n[r])})}}function lr(e,t,n){dr(e,t,n)}function ur(e,t,i){let a=[];for(let o of t){let t=e.__info__.properties?.[o]?.observer,s=e.data[o],c=i[o];r(t)?a.push(()=>e[t]?.(s,c)):n(t)&&a.push(()=>t.call(e,s,c))}return a}function dr(e,t,n){ur(e,t,n).reverse().forEach(e=>e())}function fr(e,t){if(!Array.isArray(t))return;let r=new WeakMap;function i(e,t){let n={...e};for(let e in t)if(Object.prototype.hasOwnProperty.call(t,e)){let r=n[e],a=t[e];r&&typeof r==`object`&&!Array.isArray(r)&&a&&typeof a==`object`&&!Array.isArray(a)?n[e]=i(r,a):n[e]=a}return n}function a(e,t){if(typeof t==`string`){o(e,t);return}if(!t||typeof t!=`object`||r.has(t))return;r.set(t,!0),Array.isArray(t.behaviors)&&t.behaviors.forEach(t=>a(e,t)),t.properties&&(e.properties={...t.properties,...e.properties}),t.data&&(e.data||={},e.data=i(t.data,e.data));let s=[`created`,`attached`,`ready`,`detached`];e.behaviorLifetimes=e.behaviorLifetimes||{};for(let r of s)n(t[r])&&(e.behaviorLifetimes[r]=e.behaviorLifetimes[r]||[],e.behaviorLifetimes[r].push(t[r]));if(t.observers){e.behaviorObservers=e.behaviorObservers||{};for(let n in t.observers)e.behaviorObservers[n]||(e.behaviorObservers[n]=[]),e.behaviorObservers[n].push(t.observers[n])}if(t.methods&&(e.methods={...t.methods,...e.methods}),t.relations&&(e.relations={...e.relations,...t.relations}),t.export&&(e.export=t.export),t.pageLifetimes){e.behaviorPageLifetimes=e.behaviorPageLifetimes||{};for(let r of[`show`,`hide`,`resize`,`routeDone`])n(t.pageLifetimes[r])&&(e.behaviorPageLifetimes[r]=e.behaviorPageLifetimes[r]||[],e.behaviorPageLifetimes[r].push(t.pageLifetimes[r]))}}function o(e,t){switch(t){case`wx://component-export`:break;case`wx://form-field`:break;case`wx://form-field-button`:break;default:console.warn(`[service] 未知的内置 behavior: ${t}`)}}t.forEach(t=>a(e,t))}function K(e,t,n){let r=e;for(;r&&r.__parentId__;){if(r.__parentId__===t)return!0;r=n.find(e=>e.__id__===r.__parentId__)}return!1}function q(e,t){if(!e||!t)return!1;if(e.startsWith(`#`)){let n=e.slice(1);return t.id===n}if(e.startsWith(`.`)){let n=e.slice(1);return t.__targetInfo__?.class&&t.__targetInfo__.class.split(` `).includes(n)}if(e.startsWith(`[`)&&e.endsWith(`]`)){let n=e.slice(1,-1).match(/^(\w+)(?:=["']?([^"']*)["']?)?$/);if(n){let[,e,r]=n,i=t.__targetInfo__?.dataset||{};return r===void 0?Object.prototype.hasOwnProperty.call(i,e):i[e]===r}return!1}return t.is?t.is.split(`/`).pop()===e||t.is===e:!1}function pr(e,t){if(!e||!Array.isArray(e.dependencies))return!1;for(let n of e.dependencies){if(n in t)return!0;for(let e of Object.keys(t))if(e.startsWith(n+`.`)||e.startsWith(n+`[`)||n.startsWith(e+`.`)||n.startsWith(e+`[`))return!0}return!1}function mr(e,t){if(!(!e||!e.expression)){if(e.isSimple)return g(t,e.expression);try{return Function(`data`,`with(data) { return ${e.expression} }`)(t)}catch(t){console.warn(`[service] 计算表达式失败:`,e.expression,t);return}}}function hr(e,t,n){let r=Object.values(t||{}),i=[];for(let t of r){if(!K(t,e.__id__,r)||t.__parentId__!==e.__id__)continue;let a=t.__info__?.properties||{},o={};for(let r in a){let i=e.__childPropsBindings__?.[t.__id__]?.[r];i&&pr(i,n)&&(o[r]=mr(i,e.data))}Object.keys(o).length>0&&(t.tO?.(o),t.__pendingSyncedProps__=t.__pendingSyncedProps__||{},Object.assign(t.__pendingSyncedProps__,o),i.push({child:t,data:o}))}return i}var gr=[`created`,`attached`,`ready`,`moved`,`detached`,`error`],_r=[`show`,`hide`,`resize`,`routeDone`],vr=class{constructor(e,t){this.initd=!1,this.opts=t,t.targetInfo&&(this.id=t.targetInfo.id,this.dataset=t.targetInfo.dataset,this.__targetInfo__=t.targetInfo),this.is=t.path,this.route=t.path,this.query=t.query,this.renderer=`webview`,this.bridgeId=t.bridgeId,this.id||=t.bridgeId,this.behaviors=e.behaviors,this.data=ce(e.noReferenceData),Object.defineProperty(this,"properties",{get(){return this.data},enumerable:!0,configurable:!1}),this.__isComponent__=e.isComponent,this.__type__=e.type,this.__id__=this.opts.moduleId,this.__info__=e.moduleInfo,this.__eventAttr__=t.eventAttr,this.__pageId__=t.pageId,this.__parentId__=t.parentId,this.__relations__=new Map,this.__relationPaths__=new Map,this.__groupSetDataMode__=!1,this.__groupSetDataBuffer__={},this.__groupSetDataCallbacks__=[],this.__pendingInitSetDataCallbacks__=[],this.__childPropsBindings__={},this.__pendingSyncedProps__={},this.__initialPropertyObserversInvoked__=!1}init(){if(this.__isComponent__)for(let e in this.__info__.properties)!Object.prototype.hasOwnProperty.call(this.opts.properties,e)||this.opts.properties[e]===void 0?this.data[e]=this.__info__.properties[e]?.value??null:this.data[e]=this.opts.properties[e];return this.#d(),this.#f(),this.#t(),this.#e(),this.#m().then(()=>{rr(this),E.send({type:this.__id__,target:`render`,body:{bridgeId:this.bridgeId,path:this.is,data:this.data}})})}flushInitSetDataCallbacks(){if(this.__pendingInitSetDataCallbacks__.length===0)return;let e=this.__pendingInitSetDataCallbacks__;this.__pendingInitSetDataCallbacks__=[],H(this.bridgeId,this.__id__,{},V(this,e))}#e(){this.hasBehavior(`wx://component-export`)&&this.__info__.export&&n(this.__info__.export)&&(this.export=this.__info__.export.bind(this))}#t(){let e=this.__info__.relations;if(!(!e||typeof e!=`object`))for(let[t]of Object.entries(e)){let e=this.#n(t);this.__relationPaths__.set(t,e),this.__relations__.has(t)||this.__relations__.set(t,[])}}#n(e){if(e.startsWith(`./`)){let t=this.is.lastIndexOf(`/`);return t===-1?e.substring(2):`${this.is.substring(0,t)}/${e.substring(2)}`}else if(e.startsWith(`../`)){let t=this.is.split(`/`),n=e.split(`/`),r=t.slice(0,-1);for(let e of n)e===`..`?r.pop():e!==`.`&&r.push(e);return r.join(`/`)}else return e}#r(){let e=this.__info__.relations;if(!e)return;let t=Object.values(Z.instances[this.bridgeId]||{});for(let[n,r]of Object.entries(e)){let{type:e,target:i}=r,a=this.__relationPaths__.get(n),o=t.filter(e=>i?e.hasBehavior&&e.hasBehavior(i):e.is===a||e.is.endsWith(`/${a}`)).filter(t=>this.#o(t,e)||this.#a(t,e));for(let e of o)this.#c(n,e,r)}this.#i()}#i(){let e=Object.values(Z.instances[this.bridgeId]||{});for(let t of e)t!==this&&t._checkRelationsWithTarget&&t._checkRelationsWithTarget(this)}_checkRelationsWithTarget(e){let t=this.__info__.relations;if(t)for(let[n,r]of Object.entries(t)){let{type:t,target:i}=r,a=this.__relationPaths__.get(n),o=!1;o=i?e.hasBehavior&&e.hasBehavior(i):e.is===a||e.is.endsWith(`/${a}`);let s=this.#o(e,t),c=this.#a(e,t);o&&(s||c)&&this.#c(n,e,r)}}#a(e,t){if(t!==`descendant`&&t!==`ancestor`)return!1;let n=t===`descendant`?`ancestor`:`descendant`,r=e.__info__?.relations;return r?Object.entries(r).some(([t,r])=>{let i=e.__relationPaths__?.get(t);return r.type===n&&(this.is===i||this.is.endsWith(`/${i}`))}):!1}#o(e,t){let n=Object.values(Z.instances[this.bridgeId]||{});switch(t){case`parent`:return e.__id__===this.__parentId__;case`child`:return e.__parentId__===this.__id__;case`ancestor`:return this.#s(e.__id__,this.__id__,n);case`descendant`:return this.#s(this.__id__,e.__id__,n);default:return!1}}#s(e,t,n){let r=n.find(e=>e.__id__===t);for(;r&&r.__parentId__;){if(r.__parentId__===e)return!0;r=n.find(e=>e.__id__===r.__parentId__)}return!1}#c(e,t,r){let i=this.__relations__.get(e)||[];if(!i.includes(t)&&(i.push(t),this.__relations__.set(e,i),n(r.linked)))try{r.linked.call(this,t)}catch(e){console.error(`[service] relation linked error:`,e)}}#l(e,t,r){let i=this.__relations__.get(e)||[],a=i.indexOf(t);if(a!==-1&&(i.splice(a,1),this.__relations__.set(e,i),n(r.unlinked)))try{r.unlinked.call(this,t)}catch(e){console.error(`[service] relation unlinked error:`,e)}}#u(e,t,r){if(n(r.linkChanged))try{r.linkChanged.call(this,t)}catch(e){console.error(`[service] relation linkChanged error:`,e)}}setData(e,t){let r=U(e),i={};for(let e in r)i[e]=this.data[e],ne(this.data,e,r[e]);if(this.__info__.observers&&or(Object.keys(r),this.__info__.observers,this.data,this,i),G(this,Object.keys(r),i),lr(this,Object.keys(r),i),!this.initd){n(t)&&this.__pendingInitSetDataCallbacks__.push(t);return}if(this.__groupSetDataMode__){for(let e in r)this.__groupSetDataBuffer__[e]=r[e];n(t)&&this.__groupSetDataCallbacks__.push(t);return}let a=hr(this,Z.instances[this.bridgeId],r);H(this.bridgeId,this.__id__,r,V(this,t)),a.forEach(({child:e,data:t})=>{H(this.bridgeId,e.__id__,t)})}#d(){gr.forEach(e=>{let t=this.__info__.lifetimes?.[e]||this.__info__[e];n(t)&&(this[e]=t.bind(this))}),this.__isComponent__&&_r.forEach(e=>{let t=this.__info__.pageLifetimes?.[e];n(t)&&(e===`show`?e=`onShow`:e===`hide`&&(e=`onHide`),this[e]=t.bind(this))})}#f(){let e=this.__info__.methods;for(let t in e)n(e[t])&&(this[t]=e[t].bind(this))}#p(){if(!this.__isComponent__||!this.__info__.properties||this.__initialPropertyObserversInvoked__)return;let e=[];for(let t of Object.keys(this.__info__.properties)){let i=this.__info__.properties[t]?.observer,a=this.data[t];r(i)?e.push(()=>this[i]?.(a,void 0)):n(i)&&e.push(()=>i.call(this,a,void 0))}e.forEach(e=>e()),this.__initialPropertyObserversInvoked__=!0}async#m(){this.__isComponent__?(await this.componentCreated(),await this.componentAttached()):(await this.componentCreated(),await this.componentAttached(),await this.onLoad?.(this.opts.query||{})),this.initd=!0}tO(e){let t={};for(let[n,r]of Object.entries(e)){if(this.__pendingSyncedProps__&&Object.prototype.hasOwnProperty.call(this.__pendingSyncedProps__,n)&&a(this.__pendingSyncedProps__[n],r)){this.data[n]=r,delete this.__pendingSyncedProps__[n];continue}t[n]=r}if(Object.keys(t).length===0)return;let n=[],r={};for(let[e,i]of Object.entries(t)){let t=this.data[e];r[e]=t,this.data[e]=i,this.__info__.observers&&n.push(()=>sr(e,this.__info__.observers,this.data,this,t))}n.forEach(e=>e()),G(this,Object.keys(t),Object.fromEntries(Object.keys(t).map(e=>[e,void 0]))),dr(this,Object.keys(t),r)}getPageId(){return this.__id__}hasBehavior(e){let t=function(n){if(!Array.isArray(n))return!1;if(n.includes(e))return!0;for(let e of n)if(e&&e.behaviors&&t(e.behaviors))return!0;return!1};return t(this.behaviors)}createSelectorQuery(){return L().in(this)}selectComponent(e){let t=Object.values(Z.instances[this.bridgeId]),n=t.find(n=>K(n,this.__id__,t)&&q(e,n));return n?n.hasBehavior(`wx://component-export`)&&n.export?n.export():n:null}selectAllComponents(e){let t=Object.values(Z.instances[this.bridgeId]);return t.filter(n=>K(n,this.__id__,t)&&q(e,n))}selectOwnerComponent(){let e=Object.values(Z.instances[this.bridgeId]);for(let t of e)if(t.id===this.__parentId__)return t;return null}createIntersectionObserver(e){return Qn(this,e)}groupSetData(e){if(!n(e)){console.warn(`[service] groupSetData callback must be a function`);return}this.__groupSetDataMode__=!0,er(this.bridgeId),this.__groupSetDataBuffer__={},this.__groupSetDataCallbacks__=[];try{e.call(this)}catch(e){console.error(`[service] groupSetData callback error:`,e)}finally{if(this.__groupSetDataMode__=!1,this.__groupSetDataBuffer__&&Object.keys(this.__groupSetDataBuffer__).length>0){let e=this.__groupSetDataBuffer__,t=this.__groupSetDataCallbacks__;this.__groupSetDataBuffer__={},this.__groupSetDataCallbacks__=[];let n=hr(this,Z.instances[this.bridgeId],e);H(this.bridgeId,this.__id__,e,V(this,t)),n.forEach(({child:e,data:t})=>{H(this.bridgeId,e.__id__,t)})}else this.__groupSetDataBuffer__={},this.__groupSetDataCallbacks__=[];tr(this.bridgeId)}}createMediaQueryObserver(){console.warn(`[service] 暂不支持 createMediaQueryObserver`)}getRelationNodes(e){return e?[...this.__relations__.get(e)||[]]:(console.warn(`[service] getRelationNodes 需要传入关系路径参数`),[])}animate(){console.warn(`[service] 暂不支持 animate`)}clearAnimation(){console.warn(`[service] 暂不支持 clearAnimation`)}async triggerEvent(e,t,n={}){if(!e)return;let r=e.trim(),i=cr(this.__eventAttr__,r);i&&await Z.triggerEvent({bridgeId:this.bridgeId,moduleId:this.__pageId__,methodName:i,event:{type:r,detail:t,currentTarget:{id:this.id,dataset:this.dataset},target:{id:this.id,dataset:this.dataset}}}),n.bubbles&&await Z.instances[this.bridgeId][this.__parentId__]?.triggerEvent(e,t),n.composed,n.capturePhase}pageReady(){this.__isComponent__||this.ready?.()}pageUnload(){this.__isComponent__||this.onUnload?.()}pageScrollTop(e){if(!this.__isComponent__){let{scrollTop:t}=e;this.onPageScroll?.({scrollTop:t})}}pageShow(){this.__info__.behaviorPageLifetimes?.show?.forEach(e=>e.call(this)),this.onShow?.()}pageHide(){this.__info__.behaviorPageLifetimes?.hide?.forEach(e=>e.call(this)),this.onHide?.()}pageResize(e){this.__info__.behaviorPageLifetimes?.resize?.forEach(t=>t.call(this,e)),this.resize?.(e)}componentRouteDone(){this.__info__.behaviorPageLifetimes?.routeDone?.forEach(e=>e.call(this)),this.routeDone?.()}async componentCreated(){this.__info__.behaviorLifetimes?.created?.forEach(e=>e.call(this)),await this.created?.()}async componentAttached(){this.__info__.behaviorLifetimes?.attached?.forEach(e=>e.call(this)),await this.attached?.(),this.#r()}componentReadied(){this.#p(),this.__info__.behaviorLifetimes?.ready?.forEach(e=>e.call(this)),this.ready?.()}componentMoved(){this.moved?.();let e=this.__info__.relations;if(e)for(let[t,n]of Object.entries(e)){let e=this.__relations__.get(t)||[];for(let r of e)this.#u(t,r,n)}}componentDetached(){let e=this.__info__.relations;if(e)for(let[t,n]of Object.entries(e)){let e=[...this.__relations__.get(t)||[]];for(let r of e)this.#l(t,r,n)}this.#h(),this.__info__.behaviorLifetimes?.detached?.forEach(e=>e.call(this)),this.detached?.(),this.initd=!1}#h(){let e=Object.values(Z.instances[this.bridgeId]||{});for(let t of e)if(!(t===this||!t.__relations__))for(let[e,r]of t.__relations__.entries()){let i=r.indexOf(this);if(i!==-1){r.splice(i,1),t.__relations__.set(e,r);let a=t.__info__.relations?.[e];if(a&&n(a.unlinked))try{a.unlinked.call(t,this)}catch(e){console.error(`[service] relation unlinked error:`,e)}}}}componentError(e){this.error?.(e)}},J=class e{static type=`component`;constructor(t,n){this.moduleInfo=t,this.extraInfo=n,this.type=e.type,this.isComponent=this.extraInfo.component,this.behaviors=this.moduleInfo.behaviors,this.usingComponents=this.extraInfo.usingComponents,fr(this.moduleInfo,this.behaviors),this.noReferenceData=U(this.moduleInfo.data||{})}getProps(){let e=ir(this.moduleInfo.properties);if(Array.isArray(this.moduleInfo.externalClasses)&&this.moduleInfo.externalClasses.length>0){e||={};for(let t of this.moduleInfo.externalClasses)e[t]={type:[`s`],cls:!0}}return e}},yr=class{constructor(e,t){this.initd=!1,this.opts=t,this.is=t.path,this.route=t.path,this.bridgeId=t.bridgeId,this.id=t.bridgeId,this.query=t.query,this.data=ce(e.noReferenceData),this.__type__=e.type,this.__id__=t.moduleId,this.__info__=e.moduleInfo,this.__childPropsBindings__={},this.__pendingInitSetDataCallbacks__=[]}init(){return this.#e(),this.#t().then(()=>{rr(this),E.send({type:this.__id__,target:`render`,body:{bridgeId:this.bridgeId,path:this.is,data:this.data}})})}flushInitSetDataCallbacks(){if(this.__pendingInitSetDataCallbacks__.length===0)return;let e=this.__pendingInitSetDataCallbacks__;this.__pendingInitSetDataCallbacks__=[],H(this.bridgeId,this.__id__,{},V(this,e))}setData(e,t){let r=U(e),i={},a=this.__info__||{};for(let e in r)i[e]=this.data[e],ne(this.data,e,r[e]);if(a.observers&&or(Object.keys(r),a.observers,this.data,this,i),G(this,Object.keys(r),i),!this.initd){n(t)&&this.__pendingInitSetDataCallbacks__.push(t);return}let o=hr(this,Z.instances[this.bridgeId],r);H(this.bridgeId,this.__id__,r,V(this,t)),o.forEach(({child:e,data:t})=>{H(this.bridgeId,e.__id__,t)})}createSelectorQuery(){return L().in(this)}selectComponent(e){let t=Object.values(Z.instances[this.bridgeId]||{}),n=t.find(n=>K(n,this.__id__,t)&&q(e,n));return n?n.hasBehavior&&n.hasBehavior(`wx://component-export`)&&n.export?n.export():n:null}selectAllComponents(e){let t=Object.values(Z.instances[this.bridgeId]||{});return t.filter(n=>K(n,this.__id__,t)&&q(e,n)).map(e=>e.hasBehavior&&e.hasBehavior(`wx://component-export`)&&e.export?e.export():e)}#e(){for(let e in this.__info__){let t=this.__info__[e];n(t)?this[e]=t.bind(this):this[e]=t}}async#t(){this.__info__.behaviorLifetimes?.created?.forEach(e=>e.call(this)),await this.created?.(),this.__info__.behaviorLifetimes?.attached?.forEach(e=>e.call(this)),await this.attached?.(),await this.onLoad?.(this.opts.query||{}),this.initd=!0}pageShow(){this.__info__.behaviorPageLifetimes?.show?.forEach(e=>e.call(this)),this.onShow?.()}pageHide(){this.__info__.behaviorPageLifetimes?.hide?.forEach(e=>e.call(this)),this.onHide?.()}pageReady(){this.__info__.behaviorLifetimes?.ready?.forEach(e=>e.call(this)),this.ready?.(),this.onReady?.()}pageUnload(){this.__info__.behaviorLifetimes?.detached?.forEach(e=>e.call(this)),this.detached?.(),this.onUnload?.(),this.initd=!1}pageScrollTop(e){let{scrollTop:t}=e;this.onPageScroll?.({scrollTop:t})}pageResize(e){this.__info__.behaviorPageLifetimes?.resize?.forEach(t=>t.call(this,e)),this.onResize?.(e)}},Y=class e{static type=`page`;constructor(t,r){if(this.moduleInfo=t,this.extraInfo=r,this.type=e.type,this.behaviors=this.moduleInfo.behaviors,this.usingComponents=this.extraInfo.usingComponents,fr(this.moduleInfo,this.behaviors),this.moduleInfo.methods)for(let[e,t]of Object.entries(this.moduleInfo.methods))!(e in this.moduleInfo)&&n(t)&&(this.moduleInfo[e]=t);this.noReferenceData=U(this.moduleInfo.data||{})}},br=class{static type=`app`;constructor(e){this.moduleInfo=e}},X=new class{constructor(){this.staticModules={}}loadResource(e){let{appId:t,bridgeId:n,pagePath:r,root:i,baseUrl:a}=e;if(y&&(this.isScriptLoaded=this.isScriptLoaded||{},!this.isScriptLoaded[i])){let e=`${a}${t}/${i}/logic.js`;globalThis.importScripts(e),this.isScriptLoaded[i]=!0}D.setInitId(n),C(`app`),C(r),E.invoke({type:`serviceResourceLoaded`,target:`service`,body:{bridgeId:n}})}createAppModule(e){let t=new br(e);this.staticModules[br.type]=t}createModule(e,t,n){let{path:r,usingComponents:i}=t;if(!this.staticModules[r]){if(i)for(let e of Object.values(i))C(e);if(n===Y.type){let n=new Y(e,t);this.staticModules[r]=n}else if(n===J.type){let n=new J(e,t);this.staticModules[r]=n}else console.error(`[service] createModule ${n} error`)}}getPropsByPath(e){let t={};return this.getComponentProps(t,e),t}getComponentProps(e,t){if(t)for(let n of Object.values(t)){let t=this.staticModules[n];!t||e[n]||(e[n]=t.getProps(),this.getComponentProps(e,t.usingComponents))}}getAppModule(){return this.staticModules[br.type]}getModuleByPath(e){return this.staticModules[e]}},Z=new class{constructor(){this.app=null,this.instances={}}queuePendingEvent(e,t){return e.__pendingRuntimeEvents__=e.__pendingRuntimeEvents__||[],new Promise((n,r)=>{e.__pendingRuntimeEvents__.push({...t,resolve:n,reject:r})})}async flushPendingEvents(e){let t=e?.__pendingRuntimeEvents__||[];e.__pendingRuntimeEvents__=[];for(let e of t)try{let t=await this.dispatchEvent(e);e.resolve(t)}catch(t){e.reject(t)}}async dispatchEvent({instance:e,bridgeId:t,moduleId:r,methodName:i,event:a}){if(n(e[i]))return await e[i](a);console.warn(`[service] triggerEvent ${t} ${r}, is: ${e.is}, method: ${i} is not exist`)}createApp(e){if(this.app){console.log(`[service] app instance already existed`);return}let{scene:t,pagePath:n,query:r}=e,i=X.getAppModule();if(!i){console.log(`[service] app instance is not exist`);return}console.log(`[service] create app instance`),this.app=new Dn(i,{scene:t,path:n,query:r})}appShow(){this.app?.appShow()}appHide(){this.app?.appHide()}stackShow(e){D.pushStack(e)}stackHide(e){D.popStack(e)}createInstance(e){let{bridgeId:t,moduleId:n,path:r,query:i,eventAttr:a,pageId:o,parentId:s,properties:c,targetInfo:l,stackId:u}=e,d=X.getModuleByPath(r);if(!d){console.error(`[service] ${r} not exist`);return}if(console.log(`[service] create instance ${r}`),this.instances[t]=this.instances[t]||{},d.type===J.type){let e=new vr(d,{bridgeId:t,moduleId:n,path:r,query:i,eventAttr:a,pageId:o,parentId:s,properties:c,targetInfo:l});return this.instances[t][n]=e,d.isComponent||D.push(e,u),e.init(),e}else if(d.type===Y.type){let e=new yr(d,{bridgeId:t,moduleId:n,path:r,query:i});return this.instances[t][n]=e,D.push(e,u),e.init(),e}else console.error(`[service] ${d.type} instance is not exist.`)}moduleReady(e){let{bridgeId:t,moduleId:n,propBindings:r}=e,i=this.instances[t][n];if(i){if(r&&i.__parentId__){let e=this.instances[t]?.[i.__parentId__];e&&(e.__childPropsBindings__||={},e.__childPropsBindings__[n]=r)}if(i.__type__===J.type){i.componentReadied(),i.__componentReadied__=!0,this.flushPendingEvents(i),i.flushInitSetDataCallbacks?.();let e=this.getPageInstance(t);e&&this.checkAndCallPageReady(t,e.__id__)}}}moduleUnmounted(e){let{bridgeId:t,moduleId:n}=e,r=this.instances[t][n];r&&(r.__type__===J.type&&r.componentDetached(),delete this.instances[t][n])}pageShow(e){let{bridgeId:t}=e,n=this.instances[t];if(!n)return;let r=[];Object.values(n).forEach(e=>{e&&(e.__type__===Y.type?r.push(e):e.__type__===J.type&&(e.__isComponent__?e.pageShow():r.push(e)))}),r.forEach(e=>{e.pageShow()})}pageReady(e){let{bridgeId:t,moduleId:n}=e,r=this.instances[t][n];r&&(this.pageShow(e),r.__pageReadyPending__=!0,r.flushInitSetDataCallbacks?.(),this.checkAndCallPageReady(t,n))}getPageInstance(e){let t=this.instances[e];return t?Object.values(t).find(e=>e&&(e.__type__===Y.type||e.__type__===J.type&&!e.__isComponent__)):null}checkAndCallPageReady(e,t){let n=this.instances[e][t];if(!n||!n.__pageReadyPending__)return;let r=this.instances[e];if(!r){n.__pageReadyPending__=!1,n.pageReady();return}Object.values(r).filter(e=>e&&e.__type__===J.type&&e.__isComponent__&&e.initd&&!e.__componentReadied__).length===0&&(n.__pageReadyPending__=!1,n.pageReady())}pageHide(e){let{bridgeId:t}=e,n=this.instances[t],r=[];Object.values(n).forEach(e=>{e&&(e.__type__===Y.type?r.push(e):e.__type__===J.type&&(e.__isComponent__?e.pageHide():r.push(e)))}),r.forEach(e=>{e&&e.pageHide()})}pageUnload(e){let{bridgeId:t}=e,n=this.instances[t];n&&(Object.values(n).forEach(e=>{e&&(e.__type__===J.type&&e.componentDetached(),e.pageUnload())}),D.pop(),delete this.instances[t])}pageScroll(e){let{bridgeId:t,moduleId:n,scrollTop:r}=e,i=this.instances[t][n];i&&i.pageScrollTop({scrollTop:r})}pageResize(e){let{bridgeId:t,size:n}=e,r=this.instances[t];r&&Object.values(r).forEach(e=>{e&&(e.__type__===Y.type?e.pageResize(n):e.__type__===J.type&&(e.__isComponent__,e.pageResize(n)))})}componentError(e){let{bridgeId:t,moduleId:n}=e,r=this.instances[t][n];r&&r.__type__===J.type&&r.componentError()}componentRouteDone(e){let{bridgeId:t}=e,n=this.instances[t];n&&Object.values(n).forEach(e=>{e?.__type__===J.type&&e.componentRouteDone()})}async triggerEvent(e){let{bridgeId:t,moduleId:n,methodName:r,event:i}=e;if(r===void 0)return;let a=this.instances[t];if(!a){console.warn(`[service] No instances found for bridgeId: ${t}`);return}let o=a[n];if(!o){console.warn(`[service] triggerEvent ${t} ${n} ${r}, instance is not exist`);return}return o.__type__===J.type&&o.__isComponent__&&!o.__componentReadied__?this.queuePendingEvent(o,{instance:o,bridgeId:t,moduleId:n,methodName:r,event:i}):this.dispatchEvent({instance:o,bridgeId:t,moduleId:n,methodName:r,event:i})}},xr=t({getEnterOptionsSync:()=>Cr,getLaunchOptionsSync:()=>Sr});function Sr(){return Z.app?.options}function Cr(){return Z.app?.options}var wr=t({getLocation:()=>Tr,offLocationChange:()=>Ar,onLocationChange:()=>kr,openLocation:()=>Dr,startLocationUpdate:()=>Er,stopLocationUpdate:()=>Or});function Tr(e){return O(`getLocation`,e)}function Er(e){return O(`startLocationUpdate`,e)}function Dr(e){return O(`openLocation`,e)}function Or(e){return O(`stopLocationUpdate`,e)}function kr(e){e&&O(`onLocationChange`,{success:w.store(e,!0)})}function Ar(e){if(e){let t=w.store(e,!0);O(`offLocationChange`,{success:t}),w.remove(t)}else O(`offLocationChange`),w.remove()}var jr=t({createMapContext:()=>Mr});function Mr(e,t){return new Nr({mapId:e,obj:t})}var Nr=class{constructor(e){this.opts=e}addMarkers(e){return O(`addMarkers`,e)}removeMarkers(e){return O(`removeMarkers`,e)}includePoints(e){return O(`includePoints`,e)}setCenterOffset(e){return O(`setCenterOffset`,e)}getCenterLocation(e){return O(`getCenterLocation`,e)}getScale(e){return O(`getScale`,e)}moveToLocation(e){return O(`moveToLocation`,e)}translateMarker(e){return O(`translateMarker`,e)}addArc(e){return O(`addArc`,e)}removeArc(e){return O(`removeArc`,e)}},Pr=t({createInnerAudioContext:()=>Lr}),Fr=1,Ir=class{constructor(){this._audioId=Fr++,this._src=``,this._startTime=0,this._autoplay=!1,this._loop=!1,this._volume=1,this._playbackRate=1,this._currentTime=0,this._duration=0,this._buffered=0,this._paused=!0,this._listeners={},O(`audioCreate`,{audioId:this._audioId}),O(`audioListen`,{audioId:this._audioId,evtId:`audio_${this._audioId}`,keep:!0,success:e=>this._dispatch(e)})}_dispatch(e){if(!e||typeof e!=`object`)return;this._currentTime=e.currentTime||0,this._duration=e.duration||0,this._buffered=e.buffered||0,this._paused=!!e.paused;let t=this._listeners[e.event];if(t)for(let n of t.slice())n(e)}get src(){return this._src}set src(e){this._src=e,O(`audioSetProp`,{audioId:this._audioId,prop:`src`,value:e,startTime:this._startTime,loop:this._loop,volume:this._volume,playbackRate:this._playbackRate,autoplay:this._autoplay})}get startTime(){return this._startTime}set startTime(e){this._startTime=Number(e)||0,O(`audioSetProp`,{audioId:this._audioId,prop:`startTime`,value:this._startTime})}get autoplay(){return this._autoplay}set autoplay(e){this._autoplay=!!e,O(`audioSetProp`,{audioId:this._audioId,prop:`autoplay`,value:this._autoplay})}get loop(){return this._loop}set loop(e){this._loop=!!e,O(`audioSetProp`,{audioId:this._audioId,prop:`loop`,value:this._loop})}get volume(){return this._volume}set volume(e){this._volume=Math.max(0,Math.min(1,Number(e)||0)),O(`audioSetProp`,{audioId:this._audioId,prop:`volume`,value:this._volume})}get playbackRate(){return this._playbackRate}set playbackRate(e){this._playbackRate=Number(e)||1,O(`audioSetProp`,{audioId:this._audioId,prop:`playbackRate`,value:this._playbackRate})}get duration(){return this._duration}get currentTime(){return this._currentTime}get paused(){return this._paused}get buffered(){return this._buffered}play(){this._paused=!1,O(`audioPlay`,{audioId:this._audioId,src:this._src})}pause(){this._paused=!0,O(`audioPause`,{audioId:this._audioId})}stop(){this._paused=!0,O(`audioStop`,{audioId:this._audioId})}seek(e){O(`audioSeek`,{audioId:this._audioId,position:Number(e)||0})}destroy(){O(`audioDestroy`,{audioId:this._audioId}),this._listeners={}}_on(e,t){typeof t==`function`&&(this._listeners[e]||(this._listeners[e]=[]),this._listeners[e].push(t))}_off(e,t){this._listeners[e]&&(t?this._listeners[e]=this._listeners[e].filter(e=>e!==t):this._listeners[e]=[])}onPlay(e){this._on(`play`,e)}onPause(e){this._on(`pause`,e)}onStop(e){this._on(`stop`,e)}onEnded(e){this._on(`ended`,e)}onError(e){this._on(`error`,e)}onTimeUpdate(e){this._on(`timeUpdate`,e)}onWaiting(e){this._on(`waiting`,e)}onSeeking(e){this._on(`seeking`,e)}onSeeked(e){this._on(`seeked`,e)}onCanplay(e){this._on(`canplay`,e)}offPlay(e){this._off(`play`,e)}offPause(e){this._off(`pause`,e)}offStop(e){this._off(`stop`,e)}offEnded(e){this._off(`ended`,e)}offError(e){this._off(`error`,e)}offTimeUpdate(e){this._off(`timeUpdate`,e)}offWaiting(e){this._off(`waiting`,e)}offSeeking(e){this._off(`seeking`,e)}offSeeked(e){this._off(`seeked`,e)}offCanplay(e){this._off(`canplay`,e)}};function Lr(){return new Ir}var Rr=t({chooseImage:()=>Hr,compressImage:()=>Vr,previewImage:()=>Br,saveImageToPhotosAlbum:()=>zr});function zr(e){return O(`saveImageToPhotosAlbum`,e)}function Br(e){return O(`previewImage`,e)}function Vr(e){return O(`compressImage`,e)}function Hr(e){return O(`chooseImage`,e)}var Ur=t({chooseMedia:()=>Kr,chooseVideo:()=>Gr,createVideoContext:()=>Wr});function Wr(e,t){return new qr({videoId:e,obj:t})}function Gr(e){return O(`chooseVideo`,e)}function Kr(e){return O(`chooseMedia`,e)}var qr=class{constructor(e){this.opts=e}play(){this.invoke(`play`)}pause(){this.invoke(`pause`)}stop(){this.invoke(`stop`)}seek(e){this.invoke(`seek`,{position:e})}playbackRate(e){this.invoke(`playbackRate`,{rate:e})}requestFullScreen(e={}){this.invoke(`requestFullScreen`,e)}exitFullScreen(){this.invoke(`exitFullScreen`)}requestBackgroundPlayback(e={}){this.invoke(`requestBackgroundPlayback`,e)}exitBackgroundPlayback(){this.invoke(`exitBackgroundPlayback`)}exitPictureInPicture(e={}){this.invoke(`exitPictureInPicture`,e)}showStatusBar(){this.invoke(`showStatusBar`)}hideStatusBar(){this.invoke(`hideStatusBar`)}invoke(e,t={}){O(`videoContext`,{type:`native/video`,id:this.opts.videoId,command:e,...t},`render`)}},Jr=t({exitMiniProgram:()=>Qr,navigateBackMiniProgram:()=>Zr,navigateToMiniProgram:()=>Xr,restartMiniProgram:()=>Yr});function Yr(e){return O(`restartMiniProgram`,e)}function Xr(e){return O(`navigateToMiniProgram`,e)}function Zr(e){return O(`navigateBackMiniProgram`,e)}function Qr(e){return O(`exitMiniProgram`,e)}var $r=t({downloadFile:()=>ei});function ei(e){return O(`downloadFile`,e)}var ti=t({request:()=>ni});function ni(e){return O(`request`,e)}var ri=t({uploadFile:()=>si}),ii=1;function ai(){return`upload_${Date.now()}_${ii++}`}function oi(){let e=[];return{add(t){typeof t==`function`&&e.push(t)},remove(t){e=typeof t==`function`?e.filter(e=>e!==t):[]},dispatch(t){for(let n of e.slice())n(t)}}}function si(e={}){let t=ai(),n=oi(),r=oi(),i=w.store(e=>n.dispatch(e),!0,`${t}_progress`),a=w.store(e=>r.dispatch(e),!0,`${t}_headers`),o=e.complete,s=!1,c=e=>{s=!0,w.remove(i),w.remove(a),typeof o==`function`&&o(e)};return O(`uploadFile`,{...e,uploadId:t,progress:i,headersReceived:a,complete:c}),{abort(){s||O(`uploadFileAbort`,{uploadId:t})},onProgressUpdate(e){n.add(e)},offProgressUpdate(e){n.remove(e)},onHeadersReceived(e){r.add(e)},offHeadersReceived(e){r.remove(e)}}}var ci=t({closeSocket:()=>fi,connectSocket:()=>ui,onSocketClose:()=>gi,onSocketError:()=>hi,onSocketMessage:()=>mi,onSocketOpen:()=>pi,sendSocketMessage:()=>di}),li=class{constructor(e){this.socketId=e,this._readyState=0}send(e={}){let{data:t,success:r,fail:i,complete:a,...o}=e,s={socketId:this.socketId,data:t,...o};return n(r)&&(s.success=w.store(r)),n(i)&&(s.fail=w.store(i)),n(a)&&(s.complete=w.store(a)),O(`sendSocketMessage`,s)}close(e={}){let{code:t=1e3,reason:r=``,success:i,fail:a,complete:o,...s}=e,c={socketId:this.socketId,code:t,reason:r,...s};return n(i)&&(c.success=w.store(i)),n(a)&&(c.fail=w.store(a)),n(o)&&(c.complete=w.store(o)),O(`closeSocket`,c)}onOpen(e){if(n(e))return O(`onSocketOpen`,{socketId:this.socketId,callback:w.store(e,!0)})}offOpen(e){return O(`offSocketOpen`,{socketId:this.socketId,callback:e})}onMessage(e){if(n(e))return O(`onSocketMessage`,{socketId:this.socketId,callback:w.store(e,!0)})}offMessage(e){return O(`offSocketMessage`,{socketId:this.socketId,callback:e})}onError(e){if(n(e))return O(`onSocketError`,{socketId:this.socketId,callback:w.store(e,!0)})}offError(e){return O(`offSocketError`,{socketId:this.socketId,callback:e})}onClose(e){if(n(e))return O(`onSocketClose`,{socketId:this.socketId,callback:w.store(e,!0)})}offClose(e){return O(`offSocketClose`,{socketId:this.socketId,callback:e})}get readyState(){return this._readyState}static get CONNECTING(){return 0}static get OPEN(){return 1}static get CLOSING(){return 2}static get CLOSED(){return 3}};function ui(e={}){let{url:t,header:r={},protocols:i=[],tcpNoDelay:a=!1,perMessageDeflate:o=!1,timeout:s,forceCellularNetwork:c=!1,success:l,fail:u,complete:d,...f}=e;if(!t){let e=Error(`url is required`);throw n(u)&&u(e),n(d)&&d(e),e}let p=`socket_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,m=new li(p),h={socketId:p,url:t,header:r,protocols:i,tcpNoDelay:a,perMessageDeflate:o,timeout:s,forceCellularNetwork:c,...f};return n(l)&&(h.success=w.store(e=>{m._readyState=li.OPEN,l(e)})),n(u)&&(h.fail=w.store(e=>{m._readyState=li.CLOSED,u(e)})),n(d)&&(h.complete=w.store(d)),O(`connectSocket`,h),m}function di(e){return O(`sendSocketMessage`,e)}function fi(e){return O(`closeSocket`,e)}function pi(e){return O(`onSocketOpen`,{callback:w.store(e,!0)})}function mi(e){return O(`onSocketMessage`,{callback:w.store(e,!0)})}function hi(e){return O(`onSocketError`,{callback:w.store(e,!0)})}function gi(e){return O(`onSocketClose`,{callback:w.store(e,!0)})}var _i=t({getAccountInfoSync:()=>vi});function vi(){return O(`getAccountInfoSync`)}var yi=t({authorize:()=>bi});function bi(e){return O(`authorize`,e)}var xi=t({login:()=>Si});function Si(e){return O(`login`,e)}var Ci=t({login:()=>wi});function wi(e){return O(`login`,e)}var Ti=t({getPrivacySetting:()=>Ei});function Ei(e){return O(`getPrivacySetting`,e)}var Di=t({getSetting:()=>ki,openSetting:()=>Oi});function Oi(e){return O(`openSetting`,e)}function ki(e){return O(`getSetting`,e)}var Ai=t({getUserInfo:()=>ji});function ji(e){return O(`getUserInfo`,e)}var Mi=t({requestPayment:()=>Ni});function Ni(e){return O(`requestPayment`,e)}var Pi=t({hideShareMenu:()=>Li,showShareImageMenu:()=>Ii,showShareMenu:()=>Fi});function Fi(e){return O(`shareShareMenu`,e)}function Ii(e){return O(`showShareImageMenu`,e)}function Li(e){return O(`hideShareMenu`,e)}var Ri=t({clearStorage:()=>Ki,clearStorageSync:()=>Hi,getStorage:()=>Wi,getStorageInfo:()=>Ji,getStorageInfoSync:()=>qi,getStorageSync:()=>Bi,removeStorage:()=>Gi,removeStorageSync:()=>Vi,setStorage:()=>Ui,setStorageSync:()=>zi});function zi(...e){return O(`setStorageSync`,e)}function Bi(e){return O(`getStorageSync`,e)}function Vi(e){return O(`removeStorageSync`,e)}function Hi(){return O(`clearStorageSync`)}function Ui(e){return O(`setStorage`,e)}function Wi(e){return O(`getStorage`,e)}function Gi(e){return O(`removeStorage`,e)}function Ki(){return O(`clearStorage`)}function qi(){return O(`getStorageInfoSync`)}function Ji(e){return O(`getStorageInfo`,e)}var Yi=t({createAnimation:()=>Xi});function Xi(e={}){return new Zi(e)}var Zi=class{constructor({duration:e=400,timingFunction:t=`linear`,delay:n=0,transformOrigin:r=`50% 50% 0`}={}){this.actions=[],this.currentTransform={},this.currentStepAnimates=[],this.option={transition:{duration:e,timingFunction:t,delay:n},transformOrigin:r}}export(){let e=this.actions;return this.actions=[],{actions:e}}step(e={}){for(let e of this.currentStepAnimates)e.type===`style`?this.currentTransform[`${e.type}.${e.args[0]}`]=e:this.currentTransform[e.type]=e;return this.actions.push({animates:Object.keys(this.currentTransform).reduce((e,t)=>[].concat(...e,[this.currentTransform[t]]),[]),option:{transformOrigin:e.transformOrigin===void 0?this.option.transformOrigin:e.transformOrigin,transition:{duration:e.duration===void 0?this.option.transition.duration:e.duration,timingFunction:e.timingFunction===void 0?this.option.transition.timingFunction:e.timingFunction,delay:e.delay===void 0?this.option.transition.delay:e.delay}}}),this.currentStepAnimates=[],this}backgroundColor(e){return this.currentStepAnimates.push({type:`style`,args:[`background-color`,e]}),this}bottom(e){return this.currentStepAnimates.push({type:`style`,args:[`bottom`,x(e)]}),this}height(e){return this.currentStepAnimates.push({type:`style`,args:[`height`,x(e)]}),this}left(e){return this.currentStepAnimates.push({type:`style`,args:[`left`,x(e)]}),this}matrix(e=1,t=0,n=0,r=1,i=1,a=1){return this.currentStepAnimates.push({type:`matrix`,args:[e,t,n,r,i,a]}),this}matrix3d(e=1,t=0,n=0,r=0,i=0,a=1,o=0,s=0,c=0,l=0,u=1,d=0,f=0,p=0,m=0,h=1){return this.currentStepAnimates.push({type:`matrix3d`,args:[e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h]}),this}opacity(e){return this.currentStepAnimates.push({type:`style`,args:[`opacity`,e]}),this}right(e){return this.currentStepAnimates.push({type:`style`,args:[`right`,x(e)]}),this}rotate(e=0){return this.currentStepAnimates.push({type:`rotate`,args:[e]}),this}rotate3d(e=0,t=0,n=0,r=0){return this.currentStepAnimates.push({type:`rotate3d`,args:[e,t,n,r]}),this}rotateX(e){return this.currentStepAnimates.push({type:`rotateX`,args:[e]}),this}rotateY(e){return this.currentStepAnimates.push({type:`rotateY`,args:[e]}),this}rotateZ(e){return this.currentStepAnimates.push({type:`rotateZ`,args:[e]}),this}scale(e=1,t=1){return this.currentStepAnimates.push({type:`scale`,args:[e,t]}),this}scale3d(e=1,t=1,n=1){return this.currentStepAnimates.push({type:`scale3d`,args:[e,t,n]}),this}scaleX(e=1){return this.currentStepAnimates.push({type:`scaleX`,args:[e]}),this}scaleY(e=1){return this.currentStepAnimates.push({type:`scaleY`,args:[e]}),this}scaleZ(e=1){return this.currentStepAnimates.push({type:`scaleZ`,args:[e]}),this}skew(e=0,t=0){return this.currentStepAnimates.push({type:`skew`,args:[e,t]}),this}skewX(e=0){return this.currentStepAnimates.push({type:`skewX`,args:[e]}),this}skewY(e=0){return this.currentStepAnimates.push({type:`skewY`,args:[e]}),this}top(e){return this.currentStepAnimates.push({type:`style`,args:[`top`,x(e)]}),this}translate(e=0,t=0){return this.currentStepAnimates.push({type:`translate`,args:[e,t]}),this}translate3d(e=0,t=0,n=0){return this.currentStepAnimates.push({type:`translate3d`,args:[e,t,n]}),this}translateX(e=0){return this.currentStepAnimates.push({type:`translateX`,args:[e]}),this}translateY(e=0){return this.currentStepAnimates.push({type:`translateY`,args:[e]}),this}width(e){return this.currentStepAnimates.push({type:`style`,args:[`width`,x(e)]}),this}},Qi=t({setBackgroundColor:()=>ea,setBackgroundTextStyle:()=>$i});function $i(e){return O(`setBackgroundTextStyle`,e)}function ea(e){return O(`setBackgroundColor`,e)}var ta=t({canvasToTempFilePath:()=>aa,createCanvasContext:()=>ra,createContext:()=>na,createOffscreenCanvas:()=>Gn,drawCanvas:()=>ia});function na(){return new sa}function ra(e,t){return new sa(e,oa(t))}function ia(e={}){let t={...e,moduleId:e.moduleId||oa(e.component)};delete t.component,O(`drawCanvas`,t,`render`)}function aa(e={},t){let n={...e,moduleId:e.moduleId||oa(t||e.component)};return delete n.component,O(`canvasToTempFilePath`,n,`render`)}function oa(e){return e?.__id__||D.getPageInfo()?.id}var sa=class{constructor(e=``,t=null){this.canvasId=e,this.moduleId=t,this.actions=[]}pushAction(e,...t){return this.actions.push({type:e,args:t}),this}getActions(){return this.actions.slice()}draw(e=!1,t){this.canvasId&&(ia({canvasId:this.canvasId,moduleId:this.moduleId,actions:this.getActions(),reserve:e,success:t}),this.actions=[])}beginPath(){return this.pushAction(`beginPath`)}closePath(){return this.pushAction(`closePath`)}moveTo(e,t){return this.pushAction(`moveTo`,e,t)}lineTo(e,t){return this.pushAction(`lineTo`,e,t)}rect(e,t,n,r){return this.pushAction(`rect`,e,t,n,r)}arc(e,t,n,r,i,a=!1){return this.pushAction(`arc`,e,t,n,r,i,a)}quadraticCurveTo(e,t,n,r){return this.pushAction(`quadraticCurveTo`,e,t,n,r)}bezierCurveTo(e,t,n,r,i,a){return this.pushAction(`bezierCurveTo`,e,t,n,r,i,a)}fill(){return this.pushAction(`fill`)}stroke(){return this.pushAction(`stroke`)}clearRect(e,t,n,r){return this.pushAction(`clearRect`,e,t,n,r)}fillText(e,t,n,r){return this.pushAction(`fillText`,e,t,n,r)}drawImage(e,...t){return this.pushAction(`drawImage`,e,...t)}save(){return this.pushAction(`save`)}restore(){return this.pushAction(`restore`)}translate(e,t){return this.pushAction(`translate`,e,t)}rotate(e){return this.pushAction(`rotate`,e)}scale(e,t){return this.pushAction(`scale`,e,t)}setShadow(e,t,n,r){return this.pushAction(`setShadow`,e,t,n,r)}setFillStyle(e){return this.pushAction(`setFillStyle`,e)}setStrokeStyle(e){return this.pushAction(`setStrokeStyle`,e)}setGlobalAlpha(e){return this.pushAction(`setGlobalAlpha`,e)}setLineCap(e){return this.pushAction(`setLineCap`,e)}setLineJoin(e){return this.pushAction(`setLineJoin`,e)}setLineWidth(e){return this.pushAction(`setLineWidth`,e)}setMiterLimit(e){return this.pushAction(`setMiterLimit`,e)}setFontSize(e){return this.pushAction(`setFontSize`,e)}},ca=t({nextTick:()=>da}),Q=[],la=null;function ua(){let e=Q;Q=[],la=null;for(let t=0;t<e.length;t++)e[t]()}function da(e){n(e)&&(Q.push(e),la||=setTimeout(ua,0))}var fa=t({disableAlertBeforeUnload:()=>ba,enableAlertBeforeUnload:()=>ya,hideLoading:()=>va,hideToast:()=>ma,showActionSheet:()=>_a,showLoading:()=>ga,showModal:()=>ha,showToast:()=>pa});function pa(e){return O(`showToast`,e)}function ma(e){return O(`hideToast`,e)}function ha(e){return O(`showModal`,e)}function ga(e){return O(`showLoading`,e)}function _a(e){return O(`showActionSheet`,e)}function va(e){return O(`hideLoading`,e)}function ya(e){return O(`enableAlertBeforeUnload`,e)}function ba(e){return O(`disableAlertBeforeUnload`,e)}var xa=t({getMenuButtonBoundingClientRect:()=>Sa,offMenuButtonBoundingClientRectWeightChange:()=>wa,onMenuButtonBoundingClientRectWeightChange:()=>Ca}),$=new Set;function Sa(){return O(`getMenuButtonBoundingClientRect`)}function Ca(e){n(e)&&$.add(e)}function wa(e){n(e)?$.delete(e):$.clear()}var Ta=t({hideNavigationBarLoading:()=>ka,setNavigationBarColor:()=>Oa,setNavigationBarTitle:()=>Da,showNavigationBarLoading:()=>Ea});function Ea(e){return O(`showNavigationBarLoading`,e)}function Da(e){return O(`setNavigationBarTitle`,e)}function Oa(e){return O(`setNavigationBarColor`,e)}function ka(e){return O(`hideNavigationBarLoading`,e)}var Aa=t({startPullDownRefresh:()=>Ma,stopPullDownRefresh:()=>ja});function ja(e){return O(`stopPullDownRefresh`,e)}function Ma(e){return O(`startPullDownRefresh`,e)}var Na=t({pageScrollTo:()=>Pa});function Pa(e){return O(`pageScrollTo`,e)}var Fa=t({hideTabBar:()=>za,hideTabBarRedDot:()=>Ua,removeTabBarBadge:()=>Va,setTabBarBadge:()=>Ba,setTabBarItem:()=>La,setTabBarStyle:()=>Ia,showTabBar:()=>Ra,showTabBarRedDot:()=>Ha});function Ia(e){return O(`setTabBarStyle`,e)}function La(e){return O(`setTabBarItem`,e)}function Ra(e){return O(`showTabBar`,e)}function za(e){return O(`hideTabBar`,e)}function Ba(e){return O(`setTabBarBadge`,e)}function Va(e){return O(`removeTabBarBadge`,e)}function Ha(e){return O(`showTabBarRedDot`,e)}function Ua(e){return O(`hideTabBarRedDot`,e)}var Wa=t({onWindowResize:()=>Ga});function Ga(e){e&&O(`onWindowResize`,{success:e})}var Ka=Object.assign({"./core/base/app-event/index.js":Ee,"./core/base/index.js":Ie,"./core/base/performance/index.js":Be,"./core/base/subpackage/index.js":Ge,"./core/base/system/index.js":Je,"./core/base/update/index.js":rt,"./core/camera/index.js":dt,"./core/data-analysis/index.js":mt,"./core/device/bluetooth/index.js":_t,"./core/device/bluetooth-ble/index.js":kt,"./core/device/clipboard/index.js":Ut,"./core/device/contact/index.js":Kt,"./core/device/keyboard/index.js":Yt,"./core/device/memory/index.js":Zt,"./core/device/network/index.js":en,"./core/device/phone/index.js":nn,"./core/device/scan/index.js":an,"./core/device/vibrate/index.js":sn,"./core/ext/index.js":un,"./core/file/index.js":gn,"./core/life-cycle/index.js":xr,"./core/location/index.js":wr,"./core/map/index.js":jr,"./core/media/audio/index.js":Pr,"./core/media/image/index.js":Rr,"./core/media/video/index.js":Ur,"./core/navigate/index.js":Jr,"./core/network/download/index.js":$r,"./core/network/request/index.js":ti,"./core/network/upload/index.js":ri,"./core/network/websocket/index.js":ci,"./core/open-api/account-info/index.js":_i,"./core/open-api/authorize/index.js":yi,"./core/open-api/index.js":xi,"./core/open-api/login/index.js":Ci,"./core/open-api/privacy/index.js":Ti,"./core/open-api/setting/index.js":Di,"./core/open-api/user-info/index.js":Ai,"./core/payment/index.js":Mi,"./core/route/index.js":be,"./core/share/index.js":Pi,"./core/storage/index.js":Ri,"./core/ui/animation/index.js":Yi,"./core/ui/background/index.js":Qi,"./core/ui/canvas/index.js":ta,"./core/ui/custom-component/index.js":ca,"./core/ui/interaction/index.js":fa,"./core/ui/menu/index.js":xa,"./core/ui/navigation-bar/index.js":Ta,"./core/ui/pull-down-refresh/index.js":Aa,"./core/ui/scroll/index.js":Na,"./core/ui/tab-bar/index.js":Fa,"./core/ui/window/index.js":Wa,"./core/wxml/intersection-observer/index.js":Zn,"./core/wxml/selector-query/index.js":Kn}),qa={};for(let e of Object.values(Ka))for(let[t,n]of Object.entries(e))qa[t]=n;var Ja=new Proxy(qa,{get(e,t,n){let r=Reflect.get(e,t,n);return typeof r==`function`||r!==void 0||t===`webpackJsonp`?r:(...e)=>O(t,...e)},set(e,t,n,r){return Reflect.set(e,t,n,r)}}),Ya=new class{constructor(){this.init()}init(){let e=globalThis.__diminaApiNamespaces||[];if(e.length===0&&globalThis.name)try{e=JSON.parse(globalThis.name).apiNamespaces||[]}catch{}for(let t of[`dd`,`wx`,...e])globalThis[t]=Ja;globalThis.modRequire=C,globalThis.modDefine=de,globalThis.global={},globalThis.App=e=>X.createAppModule(e),globalThis.Page=e=>{X.createModule(e,globalThis.__extraInfo,Y.type)},globalThis.Component=e=>{X.createModule(e,globalThis.__extraInfo,J.type)},globalThis.Behavior=e=>e,globalThis.getApp=e=>{let t=Z.app;return!t&&e?.allowDefault?{}:t},globalThis.getCurrentPages=()=>D.stack()}},Xa={navigateBack:Te,navigateTo:we,reLaunch:Se,redirectTo:Ce,switchTab:xe};return new class{constructor(){console.log(`[service] init`),this.env=Ya,this.message=E,this.init()}init(){this.message.on(`loadResource`,e=>{let{appId:t,bridgeId:n,pagePath:r,root:i=`.`,baseUrl:a=`/`,hostEnv:o}=e;o&&T.init(o),X.loadResource({appId:t,bridgeId:n,pagePath:r,root:i,baseUrl:a})}),this.message.on(`t`,async e=>{let{bridgeId:t,moduleId:n,methodName:r,event:i,success:a}=e;if(r===void 0)return;let o=await Z.triggerEvent({bridgeId:t,moduleId:n,methodName:r,event:i});o!==void 0&&this.message.send({type:`triggerCallback`,target:`render`,body:{bridgeId:t,moduleId:n,success:a,data:o}})}),this.message.on(`triggerCallback`,e=>{let{id:t,args:n}=e;w.invoke(t,n)}),this.onAppMsg(),this.onModuleMsg()}onAppMsg(){this.message.on(`resourceLoaded`,e=>{let{bridgeId:t,scene:n,pagePath:r,query:i,stackId:a}=e;Z.createApp({scene:n,pagePath:r,query:i});let o=X.getModuleByPath(r);if(!o){console.error(`[service] resourceLoaded: module not found, pagePath: ${r}`);return}let s=X.getPropsByPath(o.usingComponents),c=`page_${_()}`;Z.createInstance({bridgeId:t,moduleId:c,path:r,query:i,stackId:a}),E.send({type:`firstRender`,target:`render`,body:{bridgeId:t,pageId:c,pagePath:r,initialProps:s,query:i}})}),this.message.on(`appShow`,()=>{Z.appShow()}),this.message.on(`appHide`,()=>{Z.appHide()}),this.message.on(`stackShow`,({stackId:e})=>{Z.stackShow(e)}),this.message.on(`stackHide`,({stackId:e})=>{Z.stackHide(e)})}onModuleMsg(){this.message.on(`mC`,e=>{Z.createInstance(e)}),this.message.on(`mR`,e=>{Z.moduleReady(e)}),this.message.on(`mU`,e=>{Z.moduleUnmounted(e)}),this.message.on(`pageUnload`,e=>{Z.pageUnload(e)}),this.message.on(`pageShow`,e=>{Z.pageShow(e)}),this.message.on(`pageReady`,e=>{Z.pageReady(e)}),this.message.on(`pageHide`,e=>{Z.pageHide(e)}),this.message.on(`pagePullDownRefresh`,()=>{}),this.message.on(`pageReachBottom`,()=>{}),this.message.on(`pageShareAppMessage`,()=>{}),this.message.on(`pageScroll`,e=>{Z.pageScroll(e)}),this.message.on(`pageResize`,e=>{Z.pageResize(e)}),this.message.on(`onTabItemTap`,()=>{}),this.message.on(`pageRouteDone`,e=>{let{bridgeId:t}=e;Z.componentRouteDone({bridgeId:t})}),this.message.on(`componentError`,e=>{Z.componentError(e)}),this.message.on(`h5SdkAction`,async(e={})=>{let t=e?.name?.replace(/h5/i,``),{url:n}=e?.params?.data?.params||{};if(e.params&&(e.params.data={...e.params?.data,...e.params?.data?.params||{}}),t===`postMessage`&&e.parentWebViewId){let{moduleId:t,attrs:n,params:r}=e,i={detail:{data:[r?.data?.params?.data]}},a=n.message,o=e.parentWebViewId,s=await Z.triggerEvent({bridgeId:o,moduleId:t,methodName:a,event:i});s!==void 0&&this.message.send({type:`triggerCallback`,target:`service`,body:{bridgeId:o,moduleId:t,success:r?.success,data:s}})}Xa[t]?.({url:n,...e.params})})}}})();
@@ -1,4 +1,4 @@
1
1
  {
2
- "diminaGitHash": "71be839e47318be572d3125895636f870249fd96",
3
- "inputFingerprint": "7e79accdb0b0776fcdf4b0d4cfb9bce3cdd0c32f9e04afdee1b93be1b433a6cf"
2
+ "diminaGitHash": "569bc43a9f4984984aa10dfde684f8cb51af7e32",
3
+ "inputFingerprint": "0cdbf72d417886e0c24fa1d1c597cf3331e09f4da7215784c8ad822a83ea7381"
4
4
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dimina-kit/devkit",
3
- "version": "0.1.2-dev.20260522142649",
3
+ "version": "0.1.2-dev.20260524104239",
4
4
  "description": "Development toolkit for Dimina mini-apps with H5 container preview",
5
5
  "keywords": [
6
6
  "dimina",