qsh-webview-sdk 2.4.5 → 2.4.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -8
- package/dist/index.d.ts +114 -0
- package/dist/qsh-webview-sdk.es.js +1766 -1560
- package/dist/qsh-webview-sdk.es.js.map +1 -1
- package/dist/qsh-webview-sdk.umd.js +1 -1
- package/dist/qsh-webview-sdk.umd.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(R,C){typeof exports=="object"&&typeof module!="undefined"?module.exports=C():typeof define=="function"&&define.amd?define(C):(R=typeof globalThis!="undefined"?globalThis:R||self,R.qsh=C())})(this,function(){"use strict";var qi=Object.defineProperty,ji=Object.defineProperties;var Ji=Object.getOwnPropertyDescriptors;var Jt=Object.getOwnPropertySymbols;var Hi=Object.prototype.hasOwnProperty,zi=Object.prototype.propertyIsEnumerable;var je=(R,C,m)=>C in R?qi(R,C,{enumerable:!0,configurable:!0,writable:!0,value:m}):R[C]=m,g=(R,C)=>{for(var m in C||(C={}))Hi.call(C,m)&&je(R,m,C[m]);if(Jt)for(var m of Jt(C))zi.call(C,m)&&je(R,m,C[m]);return R},w=(R,C)=>ji(R,Ji(C));var H=(R,C,m)=>je(R,typeof C!="symbol"?C+"":C,m);var A=(R,C,m)=>new Promise((ce,Q)=>{var ue=$=>{try{ee(m.next($))}catch(W){Q(W)}},le=$=>{try{ee(m.throw($))}catch(W){Q(W)}},ee=$=>$.done?ce($.value):Promise.resolve($.value).then(ue,le);ee((m=m.apply(R,C)).next())});function R(){return typeof window!="undefined"?window:void 0}function C(){return typeof navigator=="undefined"?"":navigator.userAgent||""}function m(){const t=R();if(!t)return!1;if(t.__wxjs_environment==="miniprogram"||t.wx&&t.wx.miniProgram)return!0;const e=C();return!!(e&&/micromessenger/i.test(e)&&/miniProgram/i.test(e))}function ce(){const t=R();return!!(t&&t.plus)}function Q(){const t=R();return!!(t&&(t.__dcloud_weex_postMessage||t.__dcloud_weex_))}function ue(){const t=R();return!!(t&&(t.__uniapp_x_postMessage||t.__uniapp_x_))}function le(){const t=C();return/uni-app/i.test(t)}function ee(){const t=C();return/Html5Plus/i.test(t)}function $(){return le()||ee()}function W(){const t=R();if(!t)return!1;if(t.__offline_bridge_postMessage)return!0;try{const e=t.location&&t.location.hostname;if(e&&/\.?offline\.?/i.test(e))return!0}catch(e){}return!1}function Ht(){return ue()?"uvue":Q()?"nvue":m()?"weixin":W()?"offline":ce()?"plus":$()?"webview":le()?"UniApp":"h5"}let Me=null;function z(t=!1){return Me&&!t||(Me={isWeixinMiniProgram:m(),isAppPlus:ce(),isNvue:Q(),isUvue:ue(),isUniApp:le(),isHtml5Plus:ee(),isUniAppWebView:$(),isOfflineWebview:W(),type:Ht()}),Me}const u=z(),L={PLATFORM_NOT_SUPPORTED:"PLATFORM_NOT_SUPPORTED",API_CALL_FAILED:"API_CALL_FAILED",BRIDGE_NOT_READY:"BRIDGE_NOT_READY",INVALID_PARAMETERS:"INVALID_PARAMETERS",NETWORK_ERROR:"NETWORK_ERROR"};class b extends Error{constructor(e,r,n={},i=null){super(r),this.name="QshError",this.type=e,this.context=n,this.originalError=i,this.timestamp=new Date().toISOString(),Error.captureStackTrace&&Error.captureStackTrace(this,b)}toJSON(){return{name:this.name,type:this.type,message:this.message,context:this.context,timestamp:this.timestamp,stack:this.stack}}}const N=class N{static setDebugMode(e){N.isDebugMode=e}static addErrorCallback(e){typeof e=="function"&&N.errorCallbacks.push(e)}static removeErrorCallback(e){const r=N.errorCallbacks.indexOf(e);r>-1&&N.errorCallbacks.splice(r,1)}static handleApiError(e,r={}){let n;return e instanceof b?n=e:e instanceof Error?n=new b(L.API_CALL_FAILED,e.message,r,e):n=new b(L.API_CALL_FAILED,String(e),r),N.logError(n),N.notifyCallbacks(n),n}static handlePlatformNotSupported(e,r){const n=new b(L.PLATFORM_NOT_SUPPORTED,`API "${r}" is not supported on platform "${e}"`,{platformType:e,apiName:r});return N.logError(n),N.notifyCallbacks(n),n}static handleBridgeNotReady(e){const r=new b(L.BRIDGE_NOT_READY,`Bridge is not ready when calling "${e}"`,{apiName:e});return N.logError(r),N.notifyCallbacks(r),r}static handleInvalidParameters(e,r,n,i){const s=new b(L.INVALID_PARAMETERS,`Invalid parameter "${r}" in "${e}": expected ${n}, got ${typeof i}`,{apiName:e,paramName:r,expectedType:n,actualValue:i});return N.logError(s),N.notifyCallbacks(s),s}static safeExecute(e,r={}){try{return e()}catch(n){return N.handleApiError(n,r)}}static safeExecuteAsync(n){return A(this,arguments,function*(e,r={}){try{return yield e()}catch(i){return N.handleApiError(i,r)}})}static logError(e){if(typeof console!="undefined"){const r=`[QSH-SDK Error] ${e.type}: ${e.message}`;N.isDebugMode?console.error(r,{context:e.context,originalError:e.originalError,stack:e.stack,timestamp:e.timestamp}):console.error(r)}}static notifyCallbacks(e){N.errorCallbacks.forEach(r=>{try{r(e)}catch(n){typeof console!="undefined"&&console.error("[QSH-SDK] Error in error callback:",n)}})}static createErrorDecorator(e={}){return function(r,n,i){const s=i.value;return i.value=function(...o){return N.safeExecute(()=>s.apply(this,o),w(g({},e),{method:n,target:r.constructor.name}))},i}}};H(N,"isDebugMode",!1),H(N,"errorCallbacks",[]);let l=N;const U={UNINITIALIZED:"uninitialized",INITIALIZING:"initializing",READY:"ready",ERROR:"error"};class zt{constructor(){this.state=U.UNINITIALIZED,this.readyPromise=null,this.readyCallbacks=[],this.errorCallbacks=[],this.initializationError=null,this.handleBridgeReady=this.handleBridgeReady.bind(this),this.handleInitializationError=this.handleInitializationError.bind(this)}getState(){return this.state}isReady(){return this.state===U.READY}isInitializing(){return this.state===U.INITIALIZING}hasError(){return this.state===U.ERROR}getInitializationError(){return this.initializationError}waitForReady(){return this.isReady()?Promise.resolve():this.hasError()?Promise.reject(this.initializationError):(this.readyPromise||(this.readyPromise=new Promise((e,r)=>{this.isReady()?e():this.hasError()?r(this.initializationError):(this.readyCallbacks.push(e),this.errorCallbacks.push(r))})),this.readyPromise)}startInitialization(e){return A(this,null,function*(){if(this.state!==U.UNINITIALIZED)return this.waitForReady();this.state=U.INITIALIZING;try{yield e(),this.handleBridgeReady()}catch(r){throw this.handleInitializationError(r),r}return this.waitForReady()})}handleBridgeReady(){this.state===U.INITIALIZING&&(this.state=U.READY,this.readyCallbacks.forEach(e=>{try{e()}catch(r){l.handleApiError(r,{context:"StateManager.handleBridgeReady"})}}),this.readyCallbacks=[],this.errorCallbacks=[])}handleInitializationError(e){this.state=U.ERROR,this.initializationError=e,this.errorCallbacks.forEach(r=>{try{r(e)}catch(n){l.handleApiError(n,{context:"StateManager.handleInitializationError"})}}),this.readyCallbacks=[],this.errorCallbacks=[]}reset(){this.state=U.UNINITIALIZED,this.readyPromise=null,this.readyCallbacks=[],this.errorCallbacks=[],this.initializationError=null}onStateChange(e,r){if(this.state===e)return setTimeout(()=>r(this.state),0),()=>{};const n=()=>{this.state===e&&r(this.state)};return e===U.READY?this.readyCallbacks.push(n):e===U.ERROR&&this.errorCallbacks.push(n),()=>{const i=this.readyCallbacks.indexOf(n);i>-1&&this.readyCallbacks.splice(i,1);const s=this.errorCallbacks.indexOf(n);s>-1&&this.errorCallbacks.splice(s,1)}}getStats(){return{state:this.state,readyCallbacksCount:this.readyCallbacks.length,errorCallbacksCount:this.errorCallbacks.length,hasReadyPromise:!!this.readyPromise,hasInitializationError:!!this.initializationError}}}const te=new zt,Je=()=>te.waitForReady(),Yt=()=>te.isReady(),Xt=()=>te.getState(),_={ERROR:0,WARN:1,INFO:2,DEBUG:3,TRACE:4},me={[_.ERROR]:"ERROR",[_.WARN]:"WARN",[_.INFO]:"INFO",[_.DEBUG]:"DEBUG",[_.TRACE]:"TRACE"},h=class h{static setLevel(e){e>=_.ERROR&&e<=_.TRACE&&(h.currentLevel=e,h.log(_.INFO,"Logger",`日志级别设置为: ${me[e]}`))}static enableDevMode(){h.setLevel(_.DEBUG),h.log(_.INFO,"Logger","开发模式已启用")}static enableProdMode(){h.setLevel(_.WARN),h.log(_.INFO,"Logger","生产模式已启用")}static enableModule(e){h.enabledModules.add(e),h.log(_.INFO,"Logger",`模块日志已启用: ${e}`)}static disableModule(e){h.enabledModules.delete(e),h.log(_.INFO,"Logger",`模块日志已禁用: ${e}`)}static shouldLog(e,r){return e>h.currentLevel?!1:r&&h.enabledModules.size>0?h.enabledModules.has(r):!0}static log(e,r,n,...i){if(!h.shouldLog(e,r))return;const s=new Date().toISOString(),o=me[e],f=r?`[${r}]`:"",d=`${h.prefix} ${f} ${n}`,p={timestamp:s,level:e,levelName:o,module:r,message:n,args:i};if(h.addToHistory(p),typeof h.reporter=="function")try{h.reporter(p)}catch(S){}h.outputToConsole(e,d,...i)}static addToHistory(e){h.logHistory.push(e),h.logHistory.length>h.maxHistorySize&&h.logHistory.shift()}static outputToConsole(e,r,...n){if(typeof console=="undefined")return;const i=n&&n.length>0;switch(e){case _.ERROR:i?console.error(r,...n):console.error(r);break;case _.WARN:i?console.warn(r,...n):console.warn(r);break;case _.INFO:i?console.info(r,...n):console.info(r);break;case _.DEBUG:case _.TRACE:i?console.log(r,...n):console.log(r);break}}static error(e,r,...n){h.log(_.ERROR,e,r,...n)}static warn(e,r,...n){h.log(_.WARN,e,r,...n)}static info(e,r,...n){h.log(_.INFO,e,r,...n)}static debug(e,r,...n){h.log(_.DEBUG,e,r,...n)}static trace(e,r,...n){h.log(_.TRACE,e,r,...n)}static getHistory(e){return e&&e>0?h.logHistory.slice(-e):[...h.logHistory]}static clearHistory(){h.logHistory=[],h.log(_.INFO,"Logger","日志历史已清空")}static getStats(){const e={currentLevel:h.currentLevel,currentLevelName:me[h.currentLevel],enabledModules:Array.from(h.enabledModules),historySize:h.logHistory.length,maxHistorySize:h.maxHistorySize},r={};for(const n of Object.keys(me))r[me[n]]=0;return h.logHistory.forEach(n=>{r[n.levelName]++}),e.levelCounts=r,e}static exportToJSON(e){const r=h.getHistory(e),n=h.getStats();return JSON.stringify({exportTime:new Date().toISOString(),stats:n,logs:r},null,2)}static createModuleLogger(e){return{error:(r,...n)=>h.error(e,r,...n),warn:(r,...n)=>h.warn(e,r,...n),info:(r,...n)=>h.info(e,r,...n),debug:(r,...n)=>h.debug(e,r,...n),trace:(r,...n)=>h.trace(e,r,...n)}}static setReporter(e){h.reporter=typeof e=="function"?e:null}};H(h,"currentLevel",_.ERROR),H(h,"enabledModules",new Set),H(h,"logHistory",[]),H(h,"maxHistorySize",1e3),H(h,"prefix","[QSH-SDK]"),H(h,"reporter",null);let D=h;if(typeof window!="undefined"){const t=window.location&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"||window.location.hostname.includes("192.168.")),e=window.location&&(window.location.search.includes("debug=true")||window.location.search.includes("qsh_debug=1"));let r=!1;try{r=localStorage&&localStorage.getItem("qsh_debug")==="true"}catch(n){}(t||e||r)&&D.enableDevMode()}const P=D.createModuleLogger("Bridge"),E=D.createModuleLogger("Platform"),a=D.createModuleLogger("API"),F=D.createModuleLogger("State"),Re=/complete|loaded|interactive/;function Zt(t){if(!W())return!1;P.debug("检测到离线包环境,开始初始化");const e=()=>{t()};if(Re.test(document.readyState))P.debug("离线包环境 DOM 已就绪,立即初始化"),setTimeout(e,0);else{P.debug("离线包环境,等待 DOMContentLoaded");let r=!1;const n=()=>{r||(r=!0,e())};document.addEventListener("DOMContentLoaded",n),setTimeout(n,500)}return!0}function Qt(t){return le()||ee()?(P.debug("检测到 APP 环境,开始初始化"),window.__uniapp_x_postMessage||window.__uniapp_x_||window.__dcloud_weex_postMessage||window.__dcloud_weex_?(P.debug("NVUE/UVUE 环境,等待 DOMContentLoaded"),document.addEventListener("DOMContentLoaded",t)):window.plus&&Re.test(document.readyState)?(P.debug("Plus 环境已就绪,立即初始化"),setTimeout(t,0)):window.plus?(P.debug("Plus 环境,等待 plusready 事件"),document.addEventListener("plusready",t)):Re.test(document.readyState)?setTimeout(t,0):document.addEventListener("DOMContentLoaded",t,{once:!0}),!0):!1}function er(t){return window.wx&&window.wx.miniProgram?(P.debug("检测到微信小程序环境,开始初始化"),window.WeixinJSBridge&&window.WeixinJSBridge.invoke?(P.debug("微信 JSBridge 已就绪,立即初始化"),setTimeout(t,0)):(P.debug("微信 JSBridge 未就绪,等待 WeixinJSBridgeReady 事件"),document.addEventListener("WeixinJSBridgeReady",t)),!0):!1}function tr(t){return P.info("开始初始化 JSBridge"),Zt(t)?(P.info("使用离线包环境初始化"),!0):Qt(t)?(P.info("使用 APP 环境初始化"),!0):er(t)?(P.info("使用微信小程序环境初始化"),!0):(P.debug("使用默认 H5 环境初始化"),Re.test(document.readyState)?(P.debug("DOM 已就绪,立即初始化"),setTimeout(t,0)):(P.debug("DOM 未就绪,等待 DOMContentLoaded"),document.addEventListener("DOMContentLoaded",t)),!0)}function rr(){return te.waitForReady()}function He(){return te.startInitialization(()=>A(null,null,function*(){return new Promise((t,e)=>{const r=()=>{t()},n=i=>{const s=l.handleApiError(i,{context:"bridge initialization"});e(s)};try{tr(()=>{r()})}catch(i){n(i)}})}))}const v={UNINITIALIZED:"uninitialized",CONFIGURING:"configuring",CONFIGURED:"configured",ERROR:"error"};function G(){return typeof window=="undefined"||!window.wx?!1:typeof window.wx.config=="function"&&typeof window.wx.ready=="function"&&typeof window.wx.error=="function"}class nr{constructor(){this.state=v.UNINITIALIZED,this.configPromise=null,this.readyCallbacks=[],this.errorCallbacks=[],this.lastError=null,this.configVersion=0,this.configuredConfigKey=null,this.runtimeConfig={clientId:null,isProd:!1,debug:!1,url:""},this.CONFIG_API_URL=this.getConfigApiUrl(this.runtimeConfig.isProd),this.DEFAULT_JS_API_LIST=["chooseImage","uploadImage","previewImage","downloadImage","getLocalImgData","scanQRCode","getLocation","openLocation","updateAppMessageShareData","updateTimelineShareData"],this.handleConfigSuccess=this.handleConfigSuccess.bind(this),this.handleConfigError=this.handleConfigError.bind(this)}configure(e={}){if(!e||typeof e!="object"||Array.isArray(e))throw new b(L.INVALID_PARAMETERS,"config参数异常",{config:e});if(!Object.prototype.hasOwnProperty.call(e,"clientId"))throw this.createMissingClientIdError();if(typeof e.clientId!="string"||!e.clientId.trim())throw new b(L.INVALID_PARAMETERS,"clientId参数异常",{clientId:e.clientId});if(Object.prototype.hasOwnProperty.call(e,"isProd")&&typeof e.isProd!="boolean")throw new b(L.INVALID_PARAMETERS,"isProd参数异常",{isProd:e.isProd});if(Object.prototype.hasOwnProperty.call(e,"debug")&&typeof e.debug!="boolean")throw new b(L.INVALID_PARAMETERS,"debug参数异常",{debug:e.debug});if(Object.prototype.hasOwnProperty.call(e,"url")&&typeof e.url!="string")throw new b(L.INVALID_PARAMETERS,"url参数异常",{url:e.url});const r=e.clientId.trim(),n=e.isProd===!0,i=n?!1:e.debug===!0,s=typeof e.url=="string"?e.url.trim():"",o=r!==this.runtimeConfig.clientId||n!==this.runtimeConfig.isProd||i!==this.runtimeConfig.debug||s!==this.runtimeConfig.url;return this.runtimeConfig=w(g({},this.runtimeConfig),{clientId:r,isProd:n,debug:i,url:s}),this.CONFIG_API_URL=this.getConfigApiUrl(n),(this.state===v.ERROR||o&&(this.state===v.CONFIGURING||this.state===v.CONFIGURED))&&this.reset({preserveCallbacks:!0}),E.info("Updated Weixin runtime config",{clientId:this.runtimeConfig.clientId,isProd:this.runtimeConfig.isProd,debug:this.runtimeConfig.debug,url:this.runtimeConfig.url,configApiUrl:this.CONFIG_API_URL}),this.getRuntimeConfig()}getRuntimeConfig(){return g({},this.runtimeConfig)}getEffectiveConfigUrl(e={}){const{requireWindow:r=!1}=e;return this.runtimeConfig.url?this.runtimeConfig.url:r?this.getCurrentPageUrl():typeof window=="undefined"||!window.location?"":this.getCurrentPageUrl()}getRuntimeConfigKey(){return JSON.stringify({clientId:this.runtimeConfig.clientId,isProd:this.runtimeConfig.isProd,debug:this.runtimeConfig.debug,url:this.getEffectiveConfigUrl()})}isCurrentConfigRun(e,r){return e===this.configVersion&&r===this.getRuntimeConfigKey()}hasClientId(){return typeof this.runtimeConfig.clientId=="string"&&this.runtimeConfig.clientId.length>0}hasRequiredConfig(){return this.isTestMode()||this.hasClientId()}createMissingClientIdError(){return new b(L.INVALID_PARAMETERS,"clientId错误",{field:"clientId"})}getConfigApiUrl(e=!1){return e?"https://tyck-service.xj-agri.gov.cn/api/wechat/mp/jssdk-sign":"https://unified-platform-service.xjy2.cn/api/wechat/mp/jssdk-sign"}getCurrentPageUrl(){if(typeof window=="undefined"||!window.location)throw new Error("无法获取当前页面URL");const e=window.location.href,r=e.indexOf("#");return r!==-1?e.substring(0,r):e}fetchWeixinConfig(){return A(this,null,function*(){const e=this.getEffectiveConfigUrl({requireWindow:!0});if(this.isTestMode())return E.info("使用测试模式,返回模拟配置"),this.getMockConfig();if(!this.hasClientId())throw this.createMissingClientIdError();const r=this.getConfigApiUrl(this.runtimeConfig.isProd);this.CONFIG_API_URL=r;const n=`${r}?clientId=${this.runtimeConfig.clientId}&url=${encodeURIComponent(e)}`;E.debug("请求微信配置",{url:n});try{const i=yield fetch(n);if(!i.ok)throw new Error(`HTTP ${i.status}: ${i.statusText}`);const s=yield i.json();if(E.debug("微信配置响应",s),!s.success||s.code!==200)throw new Error(`配置获取失败: ${s.message||"未知错误"}`);const{data:o}=s;if(!o||!o.appId||!o.timestamp||!o.nonceStr||!o.signature)throw new Error("配置数据格式不正确,缺少必需字段");return o}catch(i){if(E.error("获取微信配置失败",i),this.shouldUseTestMode(i))return E.warn("网络请求失败,降级到测试模式"),this.getMockConfig();throw new b(L.NETWORK_ERROR,`获取微信配置失败: ${i.message}`,{url:n,originalError:i})}})}isTestMode(){if(typeof window=="undefined")return!1;if(new URLSearchParams(window.location.search).get("qsh_test")==="true")return!0;try{if(localStorage.getItem("qsh_test")==="true")return!0}catch(r){}return!1}shouldUseTestMode(e){if(typeof window=="undefined")return!1;const r=window.location.hostname==="localhost"||window.location.hostname.includes("natappfree.cc"),n=!window.wx||!window.wx.miniProgram,i=e.message.includes("CORS")||e.message.includes("Failed to fetch");return r&&n&&i}getMockConfig(){return{appId:"wx_test_app_id",timestamp:Math.floor(Date.now()/1e3).toString(),nonceStr:Math.random().toString(36).substring(2,15),signature:"test_signature_"+Math.random().toString(36).substring(2,10)}}executeWeixinConfig(e,r,n){if(this.isTestMode()||e.appId==="wx_test_app_id"){E.info("测试模式:模拟微信配置成功"),setTimeout(()=>{this.handleConfigSuccess(r,n)},100);return}if(!G())throw new Error("微信JS-SDK未加载");const i={debug:this.runtimeConfig.debug,appId:e.appId,timestamp:parseInt(e.timestamp),nonceStr:e.nonceStr,signature:e.signature,jsApiList:this.DEFAULT_JS_API_LIST};E.info("执行微信配置",i),window.wx.ready(()=>this.handleConfigSuccess(r,n)),window.wx.error(s=>this.handleConfigError(s,r,n)),window.wx.config(i)}handleConfigSuccess(e=this.configVersion,r=this.getRuntimeConfigKey()){if(!this.isCurrentConfigRun(e,r)){E.debug("忽略过期的微信配置成功回调");return}E.info("微信配置成功"),this.state=v.CONFIGURED,this.configuredConfigKey=r,this.lastError=null,this.configPromise=null;const n=[...this.readyCallbacks];this.readyCallbacks=[],this.errorCallbacks=[],n.forEach(i=>{try{i()}catch(s){l.handleApiError(s,{context:"WeixinConfigManager.handleConfigSuccess"})}})}handleConfigError(e,r=this.configVersion,n=this.getRuntimeConfigKey()){if(!this.isCurrentConfigRun(r,n)){E.debug("忽略过期的微信配置错误回调",e);return}const i=`微信配置验证失败: ${JSON.stringify(e)}`;E.error(i,e);const s=new b(L.API_CALL_FAILED,i,{weixinErrorResponse:e});this.state=v.ERROR,this.lastError=s,this.configPromise=null;const o=[...this.errorCallbacks];this.readyCallbacks=[],this.errorCallbacks=[],o.forEach(f=>{try{f(s)}catch(d){l.handleApiError(d,{context:"WeixinConfigManager.handleConfigError"})}})}autoConfig(){return A(this,null,function*(){if(!this.hasRequiredConfig())return E.warn("clientId为空,等待qsh.config({ clientId })"),Promise.resolve();if(this.isReady())return Promise.resolve();if(this.state===v.CONFIGURED&&this.reset({preserveCallbacks:!0}),this.state===v.ERROR)return Promise.reject(this.lastError);if(this.configPromise)return this.configPromise;this.state=v.CONFIGURING;const e=this.configVersion,r=this.getRuntimeConfigKey();return this.configPromise=this.performAutoConfig(e,r),this.configPromise})}performAutoConfig(e,r){return A(this,null,function*(){try{if(typeof window=="undefined")throw new Error("非浏览器环境无法执行微信配置");if(!G())throw new Error("微信JS-SDK未加载,无法执行配置");const n=yield this.fetchWeixinConfig();if(!this.isCurrentConfigRun(e,r)){E.debug("忽略过期的微信配置响应");return}return this.executeWeixinConfig(n,e,r),yield new Promise((i,s)=>{if(this.isReady()){i();return}if(this.state===v.ERROR){s(this.lastError);return}this.readyCallbacks.push(i),this.errorCallbacks.push(s)})}catch(n){if(!this.isCurrentConfigRun(e,r)){E.debug("忽略过期的微信配置异常",n);return}const i=n instanceof b?n:l.handleApiError(n,{context:"WeixinConfigManager.performAutoConfig"});this.state=v.ERROR,this.lastError=i,this.configPromise=null;const s=[...this.errorCallbacks];throw this.readyCallbacks=[],this.errorCallbacks=[],s.forEach(o=>{try{o(i)}catch(f){l.handleApiError(f,{context:"WeixinConfigManager.performAutoConfig.errorCallback"})}}),i}})}waitForReady(){return this.isReady()?Promise.resolve():(this.state===v.CONFIGURED&&this.reset({preserveCallbacks:!0}),this.state===v.ERROR?Promise.reject(this.lastError):this.hasRequiredConfig()?this.state===v.UNINITIALIZED?this.autoConfig():new Promise((e,r)=>{this.readyCallbacks.push(e),this.errorCallbacks.push(r)}):Promise.reject(this.createMissingClientIdError()))}isReady(){return this.state===v.CONFIGURED&&this.configuredConfigKey===this.getRuntimeConfigKey()}getState(){return this.state}getLastError(){return this.lastError}reset(e={}){const{preserveCallbacks:r=!1}=e;this.configVersion+=1,this.state=v.UNINITIALIZED,this.configPromise=null,r||(this.readyCallbacks=[],this.errorCallbacks=[]),this.lastError=null,this.configuredConfigKey=null,E.debug("微信配置管理器已重置")}getStats(){return{state:this.state,readyCallbacksCount:this.readyCallbacks.length,errorCallbacksCount:this.errorCallbacks.length,hasConfigPromise:!!this.configPromise,hasLastError:!!this.lastError,configVersion:this.configVersion,configuredConfigKey:this.configuredConfigKey,configApiUrl:this.CONFIG_API_URL,clientId:this.runtimeConfig.clientId,isProd:this.runtimeConfig.isProd,debug:this.runtimeConfig.debug,url:this.runtimeConfig.url,effectiveUrl:this.getEffectiveConfigUrl(),jsApiList:this.DEFAULT_JS_API_LIST}}}const x=new nr;let fe=!1,we=!1,k=null,Se=!1;function ir(t){return new Promise(e=>{let r=!1,n=null;const i=f=>A(null,null,function*(){if(!r){if(r=!0,n&&clearTimeout(n),fe=!1,we=f,f)try{yield ze()}catch(d){E.error("微信配置失败,将使用消息桥作为后备",d)}e()}}),s=()=>i(G()),o=()=>{E.warn("已存在的微信 JS-SDK 脚本加载失败,SDK 将使用消息桥作为后备"),i(!1)};t.addEventListener("load",s,{once:!0}),t.addEventListener("error",o,{once:!0}),setTimeout(()=>{G()&&s()},0),n=setTimeout(()=>{i(G())},3e3)})}function xe(){return A(this,arguments,function*(t={}){const{force:e=!1,recoverFromError:r=!1}=t;if(yield Ye({force:e}),!G())throw new Error("微信 JS-SDK 未正确加载,无法执行配置");r&&sr()})}function ar(t=!1){if(typeof window=="undefined")return!1;if(G())return we=!0,!1;if(we||W())return!1;if(t)return!0;const e=navigator.userAgent||"",r=/micromessenger/i.test(e),n=/miniProgram/i.test(e),i=typeof window.__wxjs_environment!="undefined"&&window.__wxjs_environment==="miniprogram",s=!!(window.wx&&window.wx.miniProgram);return r&&(n||i||s)}function sr(){x.getState()==="error"&&(x.reset(),Se=!1)}function ze(){return A(this,null,function*(){if(Se)return x.waitForReady();Se=!0,E.info("开始自动配置微信JS-SDK");try{yield x.autoConfig(),E.info("微信JS-SDK自动配置完成")}catch(t){E.error("微信JS-SDK自动配置失败",t)}})}function Ye(t={}){const{force:e=!1}=t;if(typeof window=="undefined")return Promise.resolve();if(G())return we=!0,Promise.resolve();const r=document.getElementById("weixin-jssdk");return r?k||(fe=!0,k=ir(r).finally(()=>{k=null}),k):ar(e)?k||(k=new Promise(n=>{fe=!0;try{const i=document.createElement("script");i.id="weixin-jssdk",i.type="text/javascript",i.async=!0,i.src="https://res.wx.qq.com/open/js/jweixin-1.6.2.js",i.onload=function(){return A(this,null,function*(){we=!0,fe=!1,E.info("微信 JS-SDK 已自动加载");try{yield ze()}catch(o){E.error("微信配置失败,将使用消息桥作为后备",o)}n()})},i.onerror=function(){fe=!1,E.warn("微信 JS-SDK 加载失败,SDK 将使用消息桥作为后备"),n()},(document.getElementsByTagName("head")[0]||document.documentElement).appendChild(i)}catch(i){fe=!1,E.error("注入微信 JS-SDK 失败",i),n()}}).finally(()=>{k=null}),k):Promise.resolve()}function re(){return xe({force:!0,recoverFromError:!0}).then(()=>x.waitForReady())}function Xe(t={}){const e=x.configure(t);return typeof window=="undefined"||xe({force:!0,recoverFromError:x.getState()==="error"}).then(()=>{if(!x.isReady())return x.waitForReady().catch(r=>{E.error("Failed to auto-configure Weixin after qsh.config()",r)});window.wx&&!G()&&E.warn("window.wx 已存在,但微信 JS-SDK 尚未就绪,跳过自动配置")}).catch(r=>{E.error("Failed to preload Weixin JS-SDK",r)}),e}function de(){return x.isReady()}function or(){return x.getState()}function De(){return x}function cr(){return A(this,null,function*(){return E.info("手动重试微信配置"),x.reset(),Se=!1,yield xe({force:!0}),x.waitForReady()})}class ur{constructor(){this.plugins=new Map,this.installed=new Set,this.installOrder=[],a.debug("插件管理器已初始化")}register(e){return l.safeExecute(()=>{this.validatePlugin(e);const{name:r,version:n}=e;if(this.plugins.has(r)){const i=this.plugins.get(r);a.warn(`插件 ${r} 已注册(版本 ${i.version}),将被覆盖为版本 ${n}`)}return this.plugins.set(r,e),a.info(`插件已注册: ${r}@${n}`),this},{context:"PluginManager.register",pluginName:e==null?void 0:e.name})}validatePlugin(e){if(!e||typeof e!="object")throw new Error("插件必须是一个对象");if(!e.name||typeof e.name!="string")throw new Error("插件必须有 name 属性(字符串)");if(!e.version||typeof e.version!="string")throw new Error(`插件 ${e.name} 必须有 version 属性(字符串)`);if(!e.install||typeof e.install!="function")throw new Error(`插件 ${e.name} 必须实现 install 方法`);if(e.dependencies&&!Array.isArray(e.dependencies))throw new Error(`插件 ${e.name} 的 dependencies 必须是数组`)}install(e,r){return A(this,null,function*(){return l.safeExecute(()=>A(this,null,function*(){if(!this.plugins.has(e))throw new Error(`插件 ${e} 未注册`);if(this.installed.has(e)){a.debug(`插件 ${e} 已安装,跳过`);return}const n=this.plugins.get(e);if(n.dependencies&&n.dependencies.length>0){a.debug(`安装插件 ${e} 的依赖:`,n.dependencies);for(const i of n.dependencies)yield this.install(i,r)}a.info(`开始安装插件: ${e}@${n.version}`),yield n.install(r),this.installed.add(e),this.installOrder.push(e),a.info(`插件安装成功: ${e}@${n.version}`)}),{context:"PluginManager.install",pluginName:e})})}uninstall(e,r){return A(this,null,function*(){return l.safeExecute(()=>A(this,null,function*(){if(!this.installed.has(e)){a.debug(`插件 ${e} 未安装,跳过卸载`);return}const n=this.plugins.get(e);n.uninstall&&typeof n.uninstall=="function"&&(a.info(`开始卸载插件: ${e}`),yield n.uninstall(r)),this.installed.delete(e);const i=this.installOrder.indexOf(e);i>-1&&this.installOrder.splice(i,1),a.info(`插件已卸载: ${e}`)}),{context:"PluginManager.uninstall",pluginName:e})})}uninstallAll(e){return A(this,null,function*(){const r=[...this.installOrder].reverse();for(const n of r)yield this.uninstall(n,e)})}registerAll(e){if(!Array.isArray(e))throw new Error("plugins 必须是数组");return e.forEach(r=>this.register(r)),this}installAll(e,r){return A(this,null,function*(){if(!Array.isArray(e))throw new Error("names 必须是数组");for(const n of e)yield this.install(n,r)})}isRegistered(e){return this.plugins.has(e)}isInstalled(e){return this.installed.has(e)}getPlugin(e){return this.plugins.get(e)}getPluginList(){return Array.from(this.plugins.entries()).map(([e,r])=>({name:e,version:r.version,installed:this.installed.has(e),dependencies:r.dependencies||[]}))}getStats(){return{registered:this.plugins.size,installed:this.installed.size,plugins:this.getPluginList()}}clear(){this.plugins.clear(),this.installed.clear(),this.installOrder=[]}}const Ee=new ur;class lr{constructor(){this.requestInterceptors=[],this.responseInterceptors=[],a.debug("拦截器链已初始化")}useRequest(e,r={}){if(typeof e!="function")throw new Error("拦截器必须是函数");const{priority:n=0}=r;return this.requestInterceptors.push({fn:e,priority:n}),this.requestInterceptors.sort((i,s)=>s.priority-i.priority),a.debug("请求拦截器已注册",{priority:n}),()=>{const i=this.requestInterceptors.findIndex(s=>s.fn===e);i>-1&&(this.requestInterceptors.splice(i,1),a.debug("请求拦截器已移除"))}}useResponse(e,r={}){if(typeof e!="function")throw new Error("拦截器必须是函数");const{priority:n=0}=r;return this.responseInterceptors.push({fn:e,priority:n}),this.responseInterceptors.sort((i,s)=>s.priority-i.priority),a.debug("响应拦截器已注册",{priority:n}),()=>{const i=this.responseInterceptors.findIndex(s=>s.fn===e);i>-1&&(this.responseInterceptors.splice(i,1),a.debug("响应拦截器已移除"))}}runRequest(e){return A(this,null,function*(){let r=g({},e);for(const{fn:n}of this.requestInterceptors){if(r.abort){a.debug("请求被中止",{apiName:r.apiName});break}try{const i=yield n(r);i&&(r=i)}catch(i){a.error("请求拦截器执行失败",i),r.abort=!0,r.error=i;break}}return r})}runResponse(e,r){return A(this,null,function*(){let n=e;for(const{fn:i}of this.responseInterceptors)try{const s=yield i(n,r);s!==void 0&&(n=s)}catch(s){a.error("响应拦截器执行失败",s)}return n})}clear(){this.requestInterceptors=[],this.responseInterceptors=[],a.debug("所有拦截器已清空")}getStats(){return{requestInterceptors:this.requestInterceptors.length,responseInterceptors:this.responseInterceptors.length}}}const ne=new lr,fr={request:t=>(t.startTime=Date.now(),a.debug(`[API 调用] ${t.apiName}`,{params:t.params}),t),response:(t,e)=>{const r=Date.now()-e.startTime;return a.debug(`[API 完成] ${e.apiName}`,{duration:`${r}ms`,success:t==null?void 0:t.success}),t}},Y={metrics:new Map,request:t=>(t.perfStartTime=performance.now(),t),response:(t,e)=>{const r=performance.now()-e.perfStartTime;Y.metrics.has(e.apiName)||Y.metrics.set(e.apiName,{count:0,totalTime:0,minTime:1/0,maxTime:0,avgTime:0});const n=Y.metrics.get(e.apiName);return n.count++,n.totalTime+=r,n.minTime=Math.min(n.minTime,r),n.maxTime=Math.max(n.maxTime,r),n.avgTime=n.totalTime/n.count,t},getReport:()=>{const t={};return Y.metrics.forEach((e,r)=>{t[r]=g({},e)}),t},clearMetrics:()=>{Y.metrics.clear()}};function dr(t={}){const{maxRetries:e=3,retryDelay:r=1e3,shouldRetry:n=i=>!i.success}=t;return{response:(i,s)=>A(null,null,function*(){return s.retryCount||(s.retryCount=0),n(i)&&s.retryCount<e&&(s.retryCount++,a.warn(`API 调用失败,第 ${s.retryCount} 次重试: ${s.apiName}`),yield new Promise(o=>setTimeout(o,r)),i.shouldRetry=!0,i.retryContext=s),i})}}function gr(t={}){return{request:e=>{const r=t[e.apiName];if(r&&typeof r=="function"){const n=r(e.params);n&&(a.error(`参数验证失败: ${e.apiName}`,n),e.abort=!0,e.validationError=n)}return e}}}class hr{constructor(){this.state={sdk:{status:"uninitialized",version:"2.0.5",error:null},platform:{type:u.type,isWeixinMiniProgram:u.isWeixinMiniProgram,isAppPlus:u.isAppPlus,isNvue:u.isNvue,isUvue:u.isUvue,isOfflineWebview:u.isOfflineWebview,features:{}},weixin:{configStatus:"pending",jsApiList:[],configError:null},network:{online:typeof navigator!="undefined"?navigator.onLine:!0,type:"unknown"},permissions:{camera:"prompt",location:"prompt",album:"prompt"},api:{}},this.listeners=new Map,this.wildcardListeners=new Set,this.initNetworkListener(),F.debug("状态仓库已初始化")}get(e){return e.split(".").reduce((n,i)=>n!=null?n[i]:void 0,this.state)}set(e,r){const n=e.split("."),i=n.pop(),s=n.reduce((f,d)=>((!f[d]||typeof f[d]!="object")&&(f[d]={}),f[d]),this.state),o=s[i];o!==r&&(s[i]=r,F.debug(`状态已更新: ${e}`,{oldValue:o,newValue:r}),this.notify(e,r,o))}batchUpdate(e){Object.entries(e).forEach(([r,n])=>{this.set(r,n)})}subscribe(e,r){if(typeof r!="function")throw new Error("listener 必须是函数");return e==="*"?(this.wildcardListeners.add(r),F.debug("添加通配符订阅者"),()=>{this.wildcardListeners.delete(r),F.debug("移除通配符订阅者")}):(this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e).add(r),F.debug(`添加订阅者: ${e}`),()=>{const n=this.listeners.get(e);n&&(n.delete(r),n.size===0&&this.listeners.delete(e),F.debug(`移除订阅者: ${e}`))})}subscribeOnce(e,r){const n=this.subscribe(e,(i,s,o)=>{r(i,s,o),n()});return n}notify(e,r,n){const i=this.listeners.get(e);i&&i.forEach(o=>{try{o(r,n,e)}catch(f){F.error("订阅者执行失败",f)}});const s=e.split(".");for(let o=1;o<s.length;o++){const f=s.slice(0,o).join("."),d=this.listeners.get(f);if(d){const p=this.get(f);d.forEach(S=>{try{S(p,void 0,f)}catch(M){F.error("父路径订阅者执行失败",M)}})}}this.wildcardListeners.forEach(o=>{try{o(r,n,e)}catch(f){F.error("通配符订阅者执行失败",f)}})}initNetworkListener(){if(typeof window!="undefined"&&(window.addEventListener("online",()=>{this.set("network.online",!0)}),window.addEventListener("offline",()=>{this.set("network.online",!1)}),navigator.connection)){const e=navigator.connection,r=()=>{this.set("network.type",e.effectiveType||"unknown")};e.addEventListener("change",r),r()}}setApiLoading(e,r=!0){const n=`api.${e}`,i=this.get(n)||{};this.set(n,w(g({},i),{loading:r,lastCall:r?Date.now():i.lastCall}))}setApiResult(e,r){const n=`api.${e}`,i=this.get(n)||{};this.set(n,w(g({},i),{loading:!1,lastResult:r,lastCallEnd:Date.now()}))}getSnapshot(){return JSON.parse(JSON.stringify(this.state))}reset(){const{platform:e}=this.state;this.state={sdk:{status:"uninitialized",version:"2.0.5",error:null},platform:e,weixin:{configStatus:"pending",jsApiList:[],configError:null},network:{online:typeof navigator!="undefined"?navigator.onLine:!0,type:"unknown"},permissions:{camera:"prompt",location:"prompt",album:"prompt"},api:{}},F.debug("状态已重置")}getStats(){return{listeners:this.listeners.size,wildcardListeners:this.wildcardListeners.size,apiStates:Object.keys(this.state.api).length}}}const K=new hr,c={SDK_NOT_READY:"E_SDK_001",SDK_INIT_FAILED:"E_SDK_002",SDK_CONFIG_FAILED:"E_SDK_003",PLATFORM_NOT_SUPPORTED:"E_SDK_004",NETWORK_ERROR:"E_NET_001",NETWORK_TIMEOUT:"E_NET_002",NETWORK_OFFLINE:"E_NET_003",IMAGE_CANCELLED:"E_IMG_001",IMAGE_NO_PERMISSION:"E_IMG_002",IMAGE_SIZE_EXCEED:"E_IMG_003",IMAGE_COUNT_EXCEED:"E_IMG_004",IMAGE_FORMAT_ERROR:"E_IMG_005",IMAGE_CONFIG_NOT_READY:"E_IMG_006",LOCATION_CANCELLED:"E_LOC_001",LOCATION_NO_PERMISSION:"E_LOC_002",LOCATION_UNAVAILABLE:"E_LOC_003",LOCATION_TIMEOUT:"E_LOC_004",SCAN_CANCELLED:"E_SCAN_001",SCAN_NO_PERMISSION:"E_SCAN_002",SCAN_INVALID_CODE:"E_SCAN_003",SCAN_CONFIG_NOT_READY:"E_SCAN_004",PERMISSION_DENIED:"E_PERM_001",PERMISSION_CAMERA:"E_PERM_002",PERMISSION_LOCATION:"E_PERM_003",PERMISSION_ALBUM:"E_PERM_004",PERMISSION_MICROPHONE:"E_PERM_005",PARAM_INVALID:"E_PARAM_001",PARAM_MISSING:"E_PARAM_002",PARAM_TYPE_ERROR:"E_PARAM_003",API_TIMEOUT:"E_TIMEOUT_001",UNKNOWN_ERROR:"E_UNKNOWN_999"},Ue={[c.SDK_NOT_READY]:"SDK 未就绪",[c.SDK_INIT_FAILED]:"SDK 初始化失败",[c.SDK_CONFIG_FAILED]:"SDK 配置失败",[c.PLATFORM_NOT_SUPPORTED]:"当前平台不支持此功能",[c.NETWORK_ERROR]:"网络错误",[c.NETWORK_TIMEOUT]:"网络超时",[c.NETWORK_OFFLINE]:"网络已断开",[c.IMAGE_CANCELLED]:"用户取消选择图片",[c.IMAGE_NO_PERMISSION]:"无相机/相册权限",[c.IMAGE_SIZE_EXCEED]:"图片大小超出限制",[c.IMAGE_COUNT_EXCEED]:"图片数量超出限制",[c.IMAGE_FORMAT_ERROR]:"图片格式不支持",[c.IMAGE_CONFIG_NOT_READY]:"微信配置未完成",[c.LOCATION_CANCELLED]:"用户取消定位",[c.LOCATION_NO_PERMISSION]:"无定位权限",[c.LOCATION_UNAVAILABLE]:"定位服务不可用",[c.LOCATION_TIMEOUT]:"定位超时",[c.SCAN_CANCELLED]:"用户取消扫码",[c.SCAN_NO_PERMISSION]:"无相机权限",[c.SCAN_INVALID_CODE]:"无效的二维码/条形码",[c.SCAN_CONFIG_NOT_READY]:"微信配置未完成",[c.PERMISSION_DENIED]:"权限被拒绝",[c.PERMISSION_CAMERA]:"无相机权限",[c.PERMISSION_LOCATION]:"无定位权限",[c.PERMISSION_ALBUM]:"无相册权限",[c.PERMISSION_MICROPHONE]:"无麦克风权限",[c.PARAM_INVALID]:"参数无效",[c.PARAM_MISSING]:"缺少必需参数",[c.PARAM_TYPE_ERROR]:"参数类型错误",[c.API_TIMEOUT]:"API 调用超时",[c.UNKNOWN_ERROR]:"未知错误"},B={USER_CANCEL:"user_cancel",PERMISSION:"permission",NETWORK:"network",PARAM:"param",SYSTEM:"system",CONFIG:"config",UNKNOWN:"unknown"},pr={"IMAGE/USER_CANCEL":c.IMAGE_CANCELLED,"IMAGE/PERMISSION_DENIED":c.IMAGE_NO_PERMISSION,"COMMON/UNKNOWN":c.UNKNOWN_ERROR,"COMMON/CONFIG_NOT_READY":c.IMAGE_CONFIG_NOT_READY,"COMMON/PLATFORM_NOT_SUPPORTED":c.PLATFORM_NOT_SUPPORTED},Ze={weixin:{patterns:[{pattern:/cancel/i,code:c.IMAGE_CANCELLED},{pattern:/permission|auth\s*deny/i,code:c.IMAGE_NO_PERMISSION},{pattern:/config/i,code:c.IMAGE_CONFIG_NOT_READY},{pattern:/timeout/i,code:c.API_TIMEOUT},{pattern:/network/i,code:c.NETWORK_ERROR}],default:c.UNKNOWN_ERROR},uniapp:{patterns:[{pattern:/cancel/i,code:c.IMAGE_CANCELLED},{pattern:/permission|denied/i,code:c.IMAGE_NO_PERMISSION},{pattern:/timeout/i,code:c.API_TIMEOUT},{pattern:/network/i,code:c.NETWORK_ERROR},{pattern:/not_in_container/i,code:c.PLATFORM_NOT_SUPPORTED}],default:c.UNKNOWN_ERROR},offline:{patterns:[{pattern:/cancel/i,code:c.IMAGE_CANCELLED},{pattern:/permission|denied/i,code:c.IMAGE_NO_PERMISSION},{pattern:/timeout/i,code:c.API_TIMEOUT},{pattern:/network/i,code:c.NETWORK_ERROR},{pattern:/not_in_container/i,code:c.PLATFORM_NOT_SUPPORTED}],default:c.UNKNOWN_ERROR}},Qe={chooseImage:{"fail cancel":c.IMAGE_CANCELLED,"fail auth deny":c.IMAGE_NO_PERMISSION,"fail No Permission":c.IMAGE_NO_PERMISSION,NOT_IN_CONTAINER:c.PLATFORM_NOT_SUPPORTED},scanCode:{"fail cancel":c.SCAN_CANCELLED,"fail auth deny":c.SCAN_NO_PERMISSION,"fail No Permission":c.SCAN_NO_PERMISSION,NOT_IN_CONTAINER:c.PLATFORM_NOT_SUPPORTED}};function et(t){return t?t.includes("CANCEL")?B.USER_CANCEL:t.includes("PERM")||t.includes("PERMISSION")?B.PERMISSION:t.includes("NET")||t.includes("NETWORK")?B.NETWORK:t.includes("PARAM")?B.PARAM:t.includes("CONFIG")?B.CONFIG:t.includes("SDK")||t.includes("PLATFORM")?B.SYSTEM:B.UNKNOWN:B.UNKNOWN}function mr(t){return t.includes("NET_")||t.includes("TIMEOUT")||t===c.NETWORK_ERROR||t===c.NETWORK_TIMEOUT||t===c.API_TIMEOUT}function wr(t){return t.includes("CANCEL")||et(t)===B.USER_CANCEL}function ge(t){return Ue[t]||Ue[c.UNKNOWN_ERROR]}class V extends Error{constructor(e,r,n={}){super(r),this.name="StandardError",this.code=e,this.message=r||ge(e),this.platform=n.platform||u.type,this.apiName=n.apiName,this.category=n.category||et(e),this.retriable=n.retriable!==void 0?n.retriable:mr(e),this.originalError=n.originalError,this.details=n.details||{},this.timestamp=Date.now()}isRetriable(){return this.retriable}isUserAction(){return wr(this.code)}toJSON(){return g({code:this.code,message:this.message,platform:this.platform,apiName:this.apiName,category:this.category,retriable:this.retriable,timestamp:this.timestamp,details:this.details},process.env.NODE_ENV!=="production"&&this.originalError?{originalError:this.originalError}:{})}}function tt(t,e={}){if(t instanceof V)return t;const{apiName:r,platform:n=u.type}=e;return t&&typeof t.code=="string"&&t.code.includes("/")?Er(t,{apiName:r,platform:n}):t&&(t.errMsg||t.message)?yr(t,{apiName:r,platform:n}):typeof t=="string"?new V(c.UNKNOWN_ERROR,t,{apiName:r,platform:n,originalError:t}):new V(c.UNKNOWN_ERROR,"未知错误",{apiName:r,platform:n,originalError:t,details:{errorType:typeof t}})}function Er(t,e){const{apiName:r,platform:n}=e,i=t.code,s=pr[i]||c.UNKNOWN_ERROR;return a.debug("转换旧版错误码",{legacy:i,new:s}),new V(s,t.message||ge(s),{apiName:r,platform:t.platform||n,originalError:t,details:g({legacyCode:i,legacyVersion:t.version},t.details)})}function yr(t,e){const{apiName:r,platform:n}=e,i=(t.errMsg||t.message||"").toLowerCase();if(r&&Qe[r]){const f=Qe[r];for(const[d,p]of Object.entries(f))if(i.includes(d.toLowerCase()))return new V(p,ge(p),{apiName:r,platform:n,originalError:t})}const s=Ze[n]||Ze.uniapp;for(const{pattern:f,code:d}of s.patterns)if(f.test(i))return new V(d,ge(d),{apiName:r,platform:n,originalError:t});const o=s.default||c.UNKNOWN_ERROR;return new V(o,t.errMsg||t.message||ge(o),{apiName:r,platform:n,originalError:t})}const rt={response:(t,e)=>{if(!t.success&&t.error){const r=tt(t.error,{apiName:e.apiName,platform:u.type});t.error=r.toJSON(),t.errorCode=r.code,t.errorCategory=r.category,t.retriable=r.isRetriable(),a.debug("错误已标准化",{api:e.apiName,code:r.code,category:r.category})}return t}};function Ir(t,e={}){return new V(t,ge(t),e)}function Ar(t){return t instanceof V}function Pr(t,e,r){return e?Promise.race([t(),new Promise((n,i)=>setTimeout(()=>i(new Error(`Init task timeout: ${r}`)),e))]):t()}function Cr(){return A(this,arguments,function*(t=[],e={}){for(const r of t){const n=(r==null?void 0:r.name)||"anonymous-task",i=(r==null?void 0:r.run)||r;if(typeof i=="function")try{yield Pr(()=>Promise.resolve().then(()=>i()),r.timeoutMs,n),typeof r.onSuccess=="function"&&r.onSuccess()}catch(s){if(typeof r.onError=="function"&&r.onError(s),typeof e.onError=="function")e.onError(s,r);else throw s}}})}class nt{constructor(e){this.name=e}processNavigationOptions(e={}){const{url:r,delta:n=1}=e,i=r&&encodeURI(r),s=parseInt(n)||1;return w(g({},e),{url:i,delta:s})}processMessageOptions(e={}){const{data:r={}}=e;return{data:r}}navigateTo(e){const r=this.processNavigationOptions(e);return this.performNavigation("navigateTo",r)}navigateBack(e={}){const r=this.processNavigationOptions(e);return this.performNavigation("navigateBack",r)}switchTab(e){const r=this.processNavigationOptions(e);return this.performNavigation("switchTab",r)}reLaunch(e){const r=this.processNavigationOptions(e);return this.performNavigation("reLaunch",r)}redirectTo(e){const r=this.processNavigationOptions(e);return this.performNavigation("redirectTo",r)}postMessage(e={}){const r=this.processMessageOptions(e);return this.performPostMessage(r)}getEnv(e){return this.performGetEnv(e)}performNavigation(e,r){throw new Error(`${this.name} platform must implement performNavigation method`)}performPostMessage(e){throw new Error(`${this.name} platform must implement performPostMessage method`)}performGetEnv(e){throw new Error(`${this.name} platform must implement performGetEnv method`)}}let ye=[];function _r(){if(ye.length===0&&window.plus){const t=plus.webview.currentWebview();if(!t)throw new Error("plus.webview.currentWebview() is undefined");const e=t.parent(),r=e?e.id:t.id;ye.push(r)}return ye}function Mr(t,e){const r={options:{timestamp:+new Date},name:t,arg:e};if(t==="postMessage"){const i={data:e};return window.__uniapp_x_postMessage?window.__uniapp_x_postMessage(i):window.__uniapp_x_.postMessage(JSON.stringify(i))}const n={type:"WEB_INVOKE_APPSERVICE",args:{data:r,webviewIds:ye}};window.__uniapp_x_postMessage?window.__uniapp_x_postMessageToService(n):window.__uniapp_x_.postMessageToService(JSON.stringify(n))}function Rr(t,e){const r={options:{timestamp:+new Date},name:t,arg:e};if(t==="postMessage"){const i={data:[e]};return window.__dcloud_weex_postMessage?window.__dcloud_weex_postMessage(i):window.__dcloud_weex_.postMessage(JSON.stringify(i))}const n={type:"WEB_INVOKE_APPSERVICE",args:{data:r,webviewIds:ye}};window.__dcloud_weex_postMessage?window.__dcloud_weex_postMessageToService(n):window.__dcloud_weex_.postMessageToService(JSON.stringify(n))}function Sr(t,e){const r={options:{timestamp:+new Date},name:t,arg:e},n=_r();if(plus.webview.getWebviewById("__uniapp__service"))plus.webview.postMessageToUniNView({type:"WEB_INVOKE_APPSERVICE",args:{data:r,webviewIds:n}},"__uniapp__service");else{const i=JSON.stringify(r),s=JSON.stringify(n);plus.webview.getLaunchWebview().evalJS(`UniPlusBridge.subscribeHandler("WEB_INVOKE_APPSERVICE",${i},${s});`)}}function Or(t,e){const r={options:{timestamp:+new Date},name:t,arg:e};window.parent.postMessage({type:"WEB_INVOKE_APPSERVICE",data:r,pageId:""},"*")}function Nr(t){return!!(t&&typeof t=="object"&&t.type==="qsh_api_call"&&typeof t.api=="string"&&typeof t.callbackId=="string")}function Tr(t,e){const r={options:{timestamp:+new Date},name:t,arg:e};if(t==="postMessage"&&Nr(e))return window.__offline_bridge_postMessage(e);window.__offline_bridge_postMessage({type:"WEB_INVOKE_APPSERVICE",data:r,pageId:""})}function Ie(t,e){ue()?Mr(t,e):Q()?Rr(t,e):W()?Tr(t,e):ce()?Sr(t,e):Or(t,e)}class it extends nt{constructor(){super("weixin")}isWeixinApiAvailable(){return typeof window!="undefined"&&window.wx&&window.wx.miniProgram}performNavigation(e,r){return l.safeExecute(()=>{const{url:n,delta:i}=r;if(E.debug(`微信平台执行导航操作: ${e}`,r),this.isWeixinApiAvailable()){const o=window.wx.miniProgram[e];if(typeof o=="function"){E.debug(`使用微信原生 API: wx.miniProgram.${e}`);const f=e==="navigateBack"?{delta:i}:{url:n};return o.call(window.wx.miniProgram,f)}}E.debug(`使用消息桥接执行: ${e}`),Ie(e,e==="navigateBack"?{delta:i}:{url:n})},{platform:this.name,method:"performNavigation",navigationType:e,options:r})}performPostMessage(e){return l.safeExecute(()=>{const{data:r}=e;if(this.isWeixinApiAvailable())return window.wx.miniProgram.postMessage({data:r});Ie("postMessage",r)},{platform:this.name,method:"performPostMessage",options:e})}performGetEnv(e){return l.safeExecute(()=>{if(!e||typeof e!="function")throw new Error("Callback function is required for getEnv");if(this.isWeixinApiAvailable()&&window.wx.miniProgram.getEnv)return window.wx.miniProgram.getEnv(e);e({miniprogram:!0,weixin:!0})},{platform:this.name,method:"performGetEnv"})}}const ie=new it;var at=Object.freeze({__proto__:null,WeixinPlatform:it,getEnv:t=>ie.getEnv(t),navigateBack:t=>ie.navigateBack(t),navigateTo:t=>ie.navigateTo(t),postMessage:t=>ie.postMessage(t),reLaunch:t=>ie.reLaunch(t),redirectTo:t=>ie.redirectTo(t),switchTab:t=>ie.switchTab(t)});class st extends nt{constructor(){super("app")}performNavigation(e,r){return l.safeExecute(()=>{const{url:n,delta:i}=r;Ie(e,e==="navigateBack"?{delta:i}:{url:n})},{platform:this.name,method:"performNavigation",navigationType:e,options:r})}performPostMessage(e){return l.safeExecute(()=>{const{data:r}=e;Ie("postMessage",r)},{platform:this.name,method:"performPostMessage",options:e})}performGetEnv(e){return l.safeExecute(()=>{if(!e||typeof e!="function")throw new Error("Callback function is required for getEnv");const r={};let n=!1;ue()?(r.uvue=!0,n=!0):Q()?(r.nvue=!0,n=!0):ce()?(r.plus=!0,n=!0):W()&&(r.offline=!0,n=!0),n?r.app=!0:r.h5=!0,e(r)},{platform:this.name,method:"performGetEnv"})}}const ae=new st;var ot=Object.freeze({__proto__:null,AppPlatform:st,getEnv:t=>ae.getEnv(t),navigateBack:t=>ae.navigateBack(t),navigateTo:t=>ae.navigateTo(t),postMessage:t=>ae.postMessage(t),reLaunch:t=>ae.reLaunch(t),redirectTo:t=>ae.redirectTo(t),switchTab:t=>ae.switchTab(t)});function Ae(){return m()?at:ot}function br(t){return Ae().navigateTo(t)}function vr(t){return Ae().navigateBack(t)}function Lr(t){return Ae().switchTab(t)}function xr(t){return Ae().reLaunch(t)}function Dr(t){return Ae().redirectTo(t)}function ct(){return m()?at:ot}function Ur(t={}){return ct().postMessage(t)}function Wr(t){return ct().getEnv(t)}function $r(t){return t&&typeof t=="object"&&t.__v_raw?t.__v_raw:t}function Fr(){return"qsh_callback_"+Date.now()+"_"+Math.random().toString(36).substring(2,9)}class kr{constructor(){this.callbacks=new Map,this.timeouts=new Map,this.persistentCallbacksByApi=new Map,this.defaultTimeout=3e4,typeof window!="undefined"&&(window.qshWebviewCallbacks||(window.qshWebviewCallbacks={})),P.debug("WebView 桥接器已初始化")}callApi(i){return A(this,arguments,function*(e,r={},n={}){return l.safeExecute(()=>A(this,null,function*(){var p;if(typeof window!="undefined"&&window===window.parent&&!window.plus&&!window.__uniapp_x_postMessage&&!window.__uniapp_x_&&!window.__dcloud_weex_postMessage&&!window.__dcloud_weex_&&!W()){const S=new b(L.PLATFORM_NOT_SUPPORTED,"当前不在宿主 WebView 容器中,无法发送消息");n&&typeof n.fail=="function"&&n.fail({errMsg:S.message,code:"NOT_IN_CONTAINER"}),n&&typeof n.complete=="function"&&n.complete({success:!1,error:{errMsg:S.message}});return}const o={apiName:e,params:r,callbacks:n,timestamp:Date.now(),abort:!1,metadata:{}};K.setApiLoading(e,!0);const f=yield ne.runRequest(o);if(f.abort){P.warn("API 调用被拦截器中止",{api:e}),K.setApiLoading(e,!1),n.fail&&n.fail({errMsg:((p=f.error)==null?void 0:p.message)||"API 调用被中止",code:"INTERCEPTED"}),n.complete&&n.complete({success:!1});return}const d=Fr();if(n.success||n.fail||n.complete){if(this.callbacks.set(d,w(g({},n),{context:f})),window.qshWebviewCallbacks[d]=q=>{this.handleCallback(d,q)},r.isPersistent&&(this.persistentCallbacksByApi.has(e)||this.persistentCallbacksByApi.set(e,new Set),this.persistentCallbacksByApi.get(e).add(d)),r.isPersistent||r.disableTimeout)P.info(`API ${e} 禁用超时清理,将等待回调返回后清理`,{callbackId:d,isPersistent:r.isPersistent,disableTimeout:r.disableTimeout});else{const q=setTimeout(()=>{P.warn("API 调用超时,自动清理回调",{api:e,callbackId:d}),n.fail&&n.fail({errMsg:`API ${e} 调用超时`,code:"TIMEOUT"}),this.cleanupCallback(d)},r.timeout||this.defaultTimeout);this.timeouts.set(d,q)}const M={type:"qsh_api_call",api:e,params:f.params,callbackId:d,timestamp:Date.now()};P.info("发送 API 调用消息",{api:e,callbackId:d,hasSuccess:!!n.success,hasFail:!!n.fail}),console.log("message:",JSON.stringify($r(M),null,2)),Ie("postMessage",M)}}),{context:"WebViewBridge.callApi",api:e})})}handleCallback(e,r){return A(this,null,function*(){return l.safeExecute(()=>A(this,null,function*(){var S,M;const n=this.callbacks.get(e);if(!n){P.warn("未找到回调函数",{callbackId:e});return}const{success:i,fail:s,complete:o,context:f}=n;P.debug("处理回调",{callbackId:e,result:r});const d=yield ne.runResponse(r,f);f&&K.setApiResult(f.apiName,d),d.success&&i?i(d.data):!d.success&&s&&s(d.error||{errMsg:"操作失败"}),o&&o(d),((M=(S=n.context)==null?void 0:S.params)==null?void 0:M.isPersistent)?P.debug("持久监听API:保留回调",{callbackId:e}):(this.cleanupCallback(e),P.debug("回调执行完成,已清理",{callbackId:e}))}),{context:"WebViewBridge.handleCallback",callbackId:e})})}cleanupCallback(e){const r=this.timeouts.get(e);if(r&&(clearTimeout(r),this.timeouts.delete(e)),this.callbacks.delete(e),typeof window!="undefined"&&window.qshWebviewCallbacks&&delete window.qshWebviewCallbacks[e],this.persistentCallbacksByApi&&this.persistentCallbacksByApi.size>0){const n=[];this.persistentCallbacksByApi.forEach((i,s)=>{i.has(e)&&(i.delete(e),i.size===0&&n.push(s))}),n.forEach(i=>this.persistentCallbacksByApi.delete(i))}}clearCallbacks(){P.debug("清理所有回调",{count:this.callbacks.size}),this.timeouts.forEach(e=>clearTimeout(e)),this.timeouts.clear(),this.callbacks.clear(),this.persistentCallbacksByApi&&this.persistentCallbacksByApi.clear(),typeof window!="undefined"&&window.qshWebviewCallbacks&&Object.keys(window.qshWebviewCallbacks).forEach(e=>{e.startsWith("qsh_callback_")&&delete window.qshWebviewCallbacks[e]})}cleanupPersistentCallbacksByApi(e){const r=this.persistentCallbacksByApi.get(e);if(!r||r.size===0)return 0;const n=Array.from(r);return n.forEach(i=>this.cleanupCallback(i)),this.persistentCallbacksByApi.delete(e),P.info("已清理持久回调",{api:e,count:n.length}),n.length}getStatus(){return{isSupported:typeof window!="undefined"&&window.uni&&typeof window.uni.postMessage=="function",activeCallbacks:this.callbacks.size,globalCallbacksCount:typeof window!="undefined"&&window.qshWebviewCallbacks?Object.keys(window.qshWebviewCallbacks).length:0}}}const ut=new kr,T=(t,e,r)=>ut.callApi(t,e,r),he=t=>ut.cleanupPersistentCallbacksByApi(t);function lt(){return z(!0)}function Br(t){return t==="offline"}function Gr(t={}){return l.safeExecute(()=>{a.debug("Call getCode through offline webview bridge",{clientId:t.clientId}),T("getCode",{clientId:t.clientId},{success:e=>{var r;a.info("Get code success"),(r=t.success)==null||r.call(t,e)},fail:e=>{var r;a.error("Get code failed",e),(r=t.fail)==null||r.call(t,e)},complete:t.complete})},{context:"getCodeInHost",platform:lt().type})}function Kr(t={}){return l.safeExecute(()=>{var n,i;const e=lt(),r=String((t==null?void 0:t.clientId)||"").trim();if(!r){const s={errMsg:"clientId is required",code:"APP_KEY_MISSING"};a.error("Get code missing clientId"),(n=t.fail)==null||n.call(t,s);return}if(!Br(e.type)){const s={errMsg:`Current environment (${e.type}) does not support getCode`,code:"PLATFORM_NOT_SUPPORTED"};a.error("Platform does not support getCode",{platform:e.type}),(i=t.fail)==null||i.call(t,s);return}Gr(w(g({},t),{clientId:r}))},{context:"getCode",options:t})}function ft(){return z(!0)}const dt=["release","trial","develop"];function Vr(t={}){const e=String((t==null?void 0:t.appid)||"").trim(),r=(t==null?void 0:t.path)==null?"":t.path,n=t==null?void 0:t.env,i=n==null||n===""?void 0:String(n).trim();if(!e)throw{errMsg:"appid is required",code:"PARAM_MISSING"};if(typeof r!="string")throw{errMsg:"path must be a string",code:"PARAM_TYPE_ERROR"};if(i!==void 0&&!dt.includes(i))throw{errMsg:`env must be one of ${dt.join("/")}`,code:"PARAM_INVALID"};return w(g({},t),{appid:e,path:r.trim(),env:i})}function qr(){return typeof window!="undefined"&&window.wx&&window.wx.miniProgram&&typeof window.wx.miniProgram.postMessage=="function"&&typeof window.wx.miniProgram.navigateBack=="function"}function jr(t={}){return l.safeExecute(()=>{var r;if(!qr()){const n={errMsg:"wx.miniProgram.postMessage or wx.miniProgram.navigateBack is not available",code:"PLATFORM_NOT_SUPPORTED"};a.error("Weixin web-view relay APIs are not available"),(r=t.fail)==null||r.call(t,n);return}const e={type:"qsh_api_call",api:"navigateToMiniProgram",params:{appid:t.appid,path:t.path,env:t.env},timestamp:Date.now()};return a.debug("Relay navigateToMiniProgram through wx.miniProgram.postMessage",{appid:t.appid,path:t.path,env:t.env}),new Promise((n,i)=>{var s;try{window.wx.miniProgram.postMessage({data:e})}catch(o){a.error("Post navigateToMiniProgram message failed",o),(s=t.fail)==null||s.call(t,o),i(o);return}window.wx.miniProgram.navigateBack({delta:1,success:o=>{var d;const f=w(g({},o),{errMsg:(o==null?void 0:o.errMsg)||"navigateToMiniProgram:queued"});a.info("Navigate to mini program request queued in weixin web-view",{appid:t.appid,path:t.path,env:t.env}),(d=t.success)==null||d.call(t,f),n(f)},fail:o=>{var f;a.error("Navigate back after posting mini program message failed",o),(f=t.fail)==null||f.call(t,o),i(o)},complete:t.complete})})},{context:"navigateToMiniProgramInWeixin",platform:"weixin"})}function Jr(t={}){return l.safeExecute(()=>(a.debug("Call navigateToMiniProgram through webview bridge",{appid:t.appid,path:t.path,env:t.env}),new Promise((e,r)=>{T("navigateToMiniProgram",{appid:t.appid,path:t.path,env:t.env},{success:n=>{var i;a.info("Navigate to mini program success"),(i=t.success)==null||i.call(t,n),e(n)},fail:n=>{var i;a.error("Navigate to mini program failed",n),(i=t.fail)==null||i.call(t,n),r(n)},complete:t.complete})})),{context:"navigateToMiniProgramInHost",platform:ft().type})}function Hr(t={}){return l.safeExecute(()=>{var n;const e=ft();let r;try{r=Vr(t)}catch(i){a.error("Navigate to mini program params validation failed",i),(n=t.fail)==null||n.call(t,i);return}return a.info("Start navigateToMiniProgram",{platform:e.type,appid:r.appid,path:r.path,env:r.env}),e.isWeixinMiniProgram?jr(r):Jr(r)},{context:"navigateToMiniProgram",options:t})}function zr(t=""){return/^https?:\/\//i.test(String(t||"").trim())}function Yr(t){if(t==null||t==="")return!1;if(typeof t=="boolean")return t;const e=String(t).trim().toLowerCase();return e==="true"||e==="1"}function Xr(){return typeof window!="undefined"&&window.wx&&window.wx.miniProgram&&typeof window.wx.miniProgram.postMessage=="function"&&typeof window.wx.miniProgram.navigateBack=="function"}function Zr(t={}){if(!t||typeof t!="object")throw{errMsg:"manualShare options must be an object",code:"PARAM_TYPE_ERROR"};const e=String(t.title||"").trim(),r=String(t.h5Url||"").trim(),n=String(t.clientId||"").trim(),i=Yr(t.isPublic),s=String(t.imageUrl||"").trim(),o=String(t.description||t.desc||"").trim();if(!e)throw{errMsg:"manualShare: title is required",code:"PARAM_MISSING"};if(!r)throw{errMsg:"manualShare: h5Url is required",code:"PARAM_MISSING"};if(!n)throw{errMsg:"manualShare: clientId is required",code:"PARAM_MISSING"};if(r&&!zr(r))throw{errMsg:"manualShare: h5Url must be a valid http(s) url",code:"PARAM_INVALID"};return{title:e,h5Url:r,clientId:n,isPublic:i,imageUrl:s,description:o,success:t.success,fail:t.fail,complete:t.complete}}function Qr(t){return{type:"qsh_api_call",api:"manualShare",params:{title:t.title,h5Url:t.h5Url,clientId:t.clientId,isPublic:t.isPublic,imageUrl:t.imageUrl,description:t.description},timestamp:Date.now()}}function en(t){return new Promise((e,r)=>{const n=Qr(t);a.debug("Relay manualShare through wx.miniProgram.postMessage",n);try{window.wx.miniProgram.postMessage({data:n})}catch(i){a.error("Post manualShare message failed",i),r(i);return}window.wx.miniProgram.navigateBack({delta:1,success:i=>{const s=w(g({},i||{}),{success:!0,errMsg:(i==null?void 0:i.errMsg)||"manualShare:queued"});a.info("manualShare request queued in weixin web-view",{h5Url:t.h5Url,clientId:t.clientId,isPublic:t.isPublic}),e(s)},fail:i=>{a.error("Navigate back after posting manualShare message failed",i),r(i)}})})}function gt(t={}){return l.safeExecute(()=>{var n,i,s,o,f,d;const e=z(!0);let r;try{r=Zr(t)}catch(p){return(n=t.fail)==null||n.call(t,p),(i=t.complete)==null||i.call(t,p),Promise.reject(p)}if(!e.isWeixinMiniProgram){const p={errMsg:"manualShare only supports Weixin mini-program web-view environment",code:"ENV_NOT_SUPPORTED"};return(s=r.fail)==null||s.call(r,p),(o=r.complete)==null||o.call(r,p),Promise.reject(p)}if(!Xr()){const p={errMsg:"wx.miniProgram.postMessage or wx.miniProgram.navigateBack is not available",code:"PLATFORM_NOT_SUPPORTED"};return(f=r.fail)==null||f.call(r,p),(d=r.complete)==null||d.call(r,p),Promise.reject(p)}return en(r).then(p=>{var S,M;return(S=r.success)==null||S.call(r,p),(M=r.complete)==null||M.call(r,p),p}).catch(p=>{var S,M;return(S=r.fail)==null||S.call(r,p),(M=r.complete)==null||M.call(r,p),Promise.reject(p)})},{context:"manualShare",options:t})}function tn(t={}){return new Promise((e,r)=>{gt(w(g({},t),{success:e,fail:r}))})}const Oe={ALBUM:"album",CAMERA:"camera"},Ne={ORIGINAL:"original",COMPRESSED:"compressed"},rn={count:9,sizeType:[Ne.ORIGINAL,Ne.COMPRESSED],sourceType:[Oe.ALBUM,Oe.CAMERA]};function nn(t={}){const e=g(g({},rn),t);return Array.isArray(e.sizeType)||(e.sizeType=[e.sizeType].filter(Boolean)),Array.isArray(e.sourceType)||(e.sourceType=[e.sourceType].filter(Boolean)),e.count=Math.max(1,Math.min(9,parseInt(e.count)||1)),e.sizeType.length===0&&(e.sizeType=[Ne.COMPRESSED]),e.sourceType.length===0&&(e.sourceType=[Oe.ALBUM]),e}function ht(){return["weixin","webview","UniApp","plus","nvue","uvue","offline"].includes(u.type)}function pt(t){return l.safeExecute(()=>{var e;if(!window.wx){const r={errMsg:"微信JS-SDK未加载",code:"WEIXIN_SDK_NOT_LOADED"};(e=t.fail)==null||e.call(t,r);return}if(!de()){a.info("等待微信配置完成"),re().then(()=>pt(t)).catch(r=>{var n;a.error("微信配置失败",r),(n=t.fail)==null||n.call(t,{errMsg:`微信配置失败: ${r.message}`})});return}a.debug("调用微信图片选择",t),window.wx.chooseImage({count:t.count,sizeType:t.sizeType,sourceType:t.sourceType,success:r=>{var n,i;a.info("微信图片选择成功",{count:((n=r.localIds)==null?void 0:n.length)||0}),(i=t.success)==null||i.call(t,r)},fail:r=>{var n;a.error("微信图片选择失败",r),(n=t.fail)==null||n.call(t,r)},complete:t.complete})},{context:"chooseImageInWeixin",platform:"weixin"})}function an(t){return l.safeExecute(()=>{a.debug("通过 WebView 桥接调用图片选择",t),T("chooseImage",w(g({},t),{disableTimeout:!0}),{success:e=>{var r,n;a.info("UniApp 图片选择成功",{count:((r=e==null?void 0:e.tempFilePaths)==null?void 0:r.length)||0}),(n=t.success)==null||n.call(t,e)},fail:e=>{var r;a.error("UniApp 图片选择失败",e),(r=t.fail)==null||r.call(t,e)},complete:t.complete})},{context:"chooseImageInUniApp",platform:"uniapp"})}function sn(t={}){return l.safeExecute(()=>{var r;if(!ht()){const n={errMsg:`当前环境 (${u.type}) 不支持图片选择功能`,code:"PLATFORM_NOT_SUPPORTED"};a.error("平台不支持图片选择",{platform:u.type}),(r=t.fail)==null||r.call(t,n);return}const e=nn(t);a.info("开始选择图片",{platform:u.type,count:e.count,sizeType:e.sizeType,sourceType:e.sourceType}),m()?pt(e):an(e)},{context:"chooseImage",options:t})}function on(){return{supported:ht(),environment:u.type,implementation:m()?"weixin":"webview",features:{multipleSelection:!0,sizeTypeSelection:!0,sourceTypeSelection:!0,asyncSupport:!0}}}const se={QR_CODE:"qrCode",BAR_CODE:"barCode",DATA_MATRIX:"datamatrix",PDF417:"pdf417"},cn={onlyFromCamera:!0,scanType:[se.QR_CODE,se.BAR_CODE]};function un(t={}){const e=g(g({},cn),t);return Array.isArray(e.scanType)||(e.scanType=[e.scanType].filter(Boolean)),e.scanType.length===0&&(e.scanType=[se.QR_CODE,se.BAR_CODE]),e.onlyFromCamera=!!e.onlyFromCamera,e}function mt(){return["weixin","webview","UniApp","plus","nvue","uvue","offline"].includes(u.type)}function wt(t){return l.safeExecute(()=>{var e;if(!window.wx){const r={errMsg:"微信JS-SDK未加载",code:"WEIXIN_SDK_NOT_LOADED"};(e=t.fail)==null||e.call(t,r);return}if(!de()){a.info("等待微信配置完成"),re().then(()=>wt(t)).catch(r=>{var n;a.error("微信配置失败",r),(n=t.fail)==null||n.call(t,{errMsg:`微信配置失败: ${r.message}`})});return}a.debug("调用微信扫码",t),window.wx.scanQRCode({needResult:1,scanType:t.scanType,success:r=>{var i;a.info("微信扫码成功",{result:r.resultStr});const n={result:r.resultStr,scanType:ln(r.resultStr),charSet:"utf-8",errMsg:"scanCode:ok"};(i=t.success)==null||i.call(t,n)},fail:r=>{var n;a.error("微信扫码失败",r),(n=t.fail)==null||n.call(t,r)},complete:t.complete})},{context:"scanCodeInWeixin",platform:"weixin"})}function ln(t){return t?t.length>50||/[^\d]/.test(t)?se.QR_CODE:se.BAR_CODE:"unknown"}function fn(t){return l.safeExecute(()=>{a.debug("通过 WebView 桥接调用扫码",t),T("scanCode",w(g({},t),{disableTimeout:!0}),{success:e=>{var r;a.info("UniApp 扫码成功",{result:e==null?void 0:e.result,scanType:e==null?void 0:e.scanType}),(r=t.success)==null||r.call(t,e)},fail:e=>{var r;a.error("UniApp 扫码失败",e),(r=t.fail)==null||r.call(t,e)},complete:t.complete})},{context:"scanCodeInUniApp",platform:"uniapp"})}function dn(t={}){return l.safeExecute(()=>{var r;if(!mt()){const n={errMsg:`当前环境 (${u.type}) 不支持扫码功能`,code:"PLATFORM_NOT_SUPPORTED"};a.error("平台不支持扫码",{platform:u.type}),(r=t.fail)==null||r.call(t,n);return}const e=un(t);a.info("开始扫码",{platform:u.type,onlyFromCamera:e.onlyFromCamera,scanType:e.scanType}),m()?wt(e):fn(e)},{context:"scanCode",options:t})}function gn(){return{supported:mt(),environment:u.type,implementation:m()?"weixin":"webview",features:{onlyFromCamera:!0,scanTypeSelection:!0,multipleTypes:!0,asyncSupport:!0}}}const pe={WGS84:"wgs84",GCJ02:"gcj02",BD09:"bd09"},hn={type:pe.WGS84,altitude:!1},pn={scale:18};function mn(t={}){const e=g(g({},hn),t);return Object.values(pe).includes(e.type)||(e.type=pe.WGS84),e.altitude=!!e.altitude,e}function wn(t={}){const e=g({},t);return Object.values(pe).includes(e.type)||(e.type=pe.WGS84),e.needFullAccuracy=!!e.needFullAccuracy,e}function En(t={}){const e=g(g({},pn),t);if(e.latitude===void 0||e.latitude===null)throw{errMsg:"缺少必需参数:latitude(纬度)",code:"PARAM_MISSING"};if(typeof e.latitude!="number")throw{errMsg:`latitude 参数类型错误:期望 number,实际 ${typeof e.latitude}`,code:"PARAM_TYPE_ERROR",details:{param:"latitude",expected:"number",actual:typeof e.latitude,value:e.latitude}};if(e.latitude<-90||e.latitude>90)throw{errMsg:`latitude 超出范围:有效范围 -90 ~ 90,实际值 ${e.latitude}`,code:"PARAM_INVALID",details:{param:"latitude",value:e.latitude,validRange:"-90 ~ 90"}};if(e.longitude===void 0||e.longitude===null)throw{errMsg:"缺少必需参数:longitude(经度)",code:"PARAM_MISSING"};if(typeof e.longitude!="number")throw{errMsg:`longitude 参数类型错误:期望 number,实际 ${typeof e.longitude}`,code:"PARAM_TYPE_ERROR",details:{param:"longitude",expected:"number",actual:typeof e.longitude,value:e.longitude}};if(e.longitude<-180||e.longitude>180)throw{errMsg:`longitude 超出范围:有效范围 -180 ~ 180,实际值 ${e.longitude}`,code:"PARAM_INVALID",details:{param:"longitude",value:e.longitude,validRange:"-180 ~ 180"}};if(e.scale!==void 0&&e.scale!==null){const r=Number(e.scale);isNaN(r)?(a.warn("scale 参数无效,使用默认值 18",{scale:e.scale}),e.scale=18):e.scale=Math.max(1,Math.min(28,Math.floor(r)))}return e}function We(){return["weixin","webview","UniApp","plus","nvue","uvue","offline"].includes(u.type)}function Et(t){return l.safeExecute(()=>{var e;if(!window.wx){const r={errMsg:"微信JS-SDK未加载",code:"WEIXIN_SDK_NOT_LOADED"};(e=t.fail)==null||e.call(t,r);return}if(!de()){a.info("等待微信配置完成"),re().then(()=>Et(t)).catch(r=>{var n;a.error("微信配置失败",r),(n=t.fail)==null||n.call(t,{errMsg:`微信配置失败: ${r.message}`})});return}a.debug("调用微信定位",t),window.wx.getLocation({type:t.type,success:r=>{var n;a.info("微信定位成功",{latitude:r.latitude,longitude:r.longitude}),(n=t.success)==null||n.call(t,r)},fail:r=>{var n;a.error("微信定位失败",r),(n=t.fail)==null||n.call(t,r)},complete:t.complete})},{context:"getLocationInWeixin",platform:"weixin"})}function yt(t){return l.safeExecute(()=>{var e;if(!window.wx){const r={errMsg:"微信JS-SDK未加载",code:"WEIXIN_SDK_NOT_LOADED"};(e=t.fail)==null||e.call(t,r);return}if(!de()){a.info("等待微信配置完成"),re().then(()=>yt(t)).catch(r=>{var n;a.error("微信配置失败",r),(n=t.fail)==null||n.call(t,{errMsg:`微信配置失败: ${r.message}`})});return}a.debug("调用微信查看位置",t),window.wx.openLocation({latitude:t.latitude,longitude:t.longitude,name:t.name||"",address:t.address||"",scale:t.scale||18,infoUrl:t.infoUrl||"",success:r=>{var n;a.info("微信查看位置成功"),(n=t.success)==null||n.call(t,r)},fail:r=>{var n;a.error("微信查看位置失败",r),(n=t.fail)==null||n.call(t,r)},complete:t.complete})},{context:"openLocationInWeixin",platform:"weixin"})}function yn(t){return l.safeExecute(()=>{a.debug("通过 WebView 桥接调用获取位置",t),T("getLocation",t,{success:e=>{var r;a.info("UniApp 获取位置成功",{latitude:e==null?void 0:e.latitude,longitude:e==null?void 0:e.longitude}),(r=t.success)==null||r.call(t,e)},fail:e=>{var r;a.error("UniApp 获取位置失败",e),(r=t.fail)==null||r.call(t,e)},complete:t.complete})},{context:"getLocationInUniApp",platform:"uniapp"})}function In(t){return l.safeExecute(()=>{a.debug("通过 WebView 桥接调用查看位置",t),T("openLocation",t,{success:e=>{var r;a.info("UniApp 查看位置成功"),(r=t.success)==null||r.call(t,e)},fail:e=>{var r;a.error("UniApp 查看位置失败",e),(r=t.fail)==null||r.call(t,e)},complete:t.complete})},{context:"openLocationInUniApp",platform:"uniapp"})}function An(t={}){return l.safeExecute(()=>{var r;if(!We()){const n={errMsg:`当前环境 (${u.type}) 不支持定位功能`,code:"PLATFORM_NOT_SUPPORTED"};a.error("平台不支持定位",{platform:u.type}),(r=t.fail)==null||r.call(t,n);return}const e=mn(t);a.info("开始获取位置",{platform:u.type,type:e.type,altitude:e.altitude}),m()?Et(e):yn(e)},{context:"getLocation",options:t})}function Pn(t={}){return l.safeExecute(()=>{var r,n,i;if(!We()){const s={errMsg:`当前环境 (${u.type}) 不支持查看位置功能`,code:"PLATFORM_NOT_SUPPORTED"};a.error("平台不支持查看位置",{platform:u.type}),(r=t.fail)==null||r.call(t,s);return}let e;try{e=En(t)}catch(s){a.error("参数验证失败",s),(n=t.fail)==null||n.call(t,s),(i=t.complete)==null||i.call(t);return}a.info("开始查看位置",{platform:u.type,latitude:e.latitude,longitude:e.longitude,name:e.name}),m()?yt(e):In(e)},{context:"openLocation",options:t})}function Cn(){const t=m();return{supported:We(),environment:u.type,implementation:t?"weixin":"webview",features:{getLocation:!0,openLocation:!0,coordinateTypes:!0,altitudeSupport:!0,asyncSupport:!0,onLocationChange:!t}}}const X=new Set,Z=new Set;function It(t,e,r){t.forEach(n=>{if(typeof n=="function"){l.safeExecute(()=>n(e),{context:r});return}a.warn("监听回调不是函数,已跳过",{type:typeof n})})}function _n(t={}){return l.safeExecute(()=>{var r,n;if(m()){const i={errMsg:`当前环境 (${u.type}) 不支持该接口`,code:"PLATFORM_NOT_SUPPORTED"};a.error("当前环境不支持此接口",{platform:u.type}),(r=t.fail)==null||r.call(t,i),(n=t.complete)==null||n.call(t,i);return}const e=wn(t);a.info("正在开启定位监听"),T("startLocationUpdate",{type:e.type,needFullAccuracy:e.needFullAccuracy},{success:i=>{var s;a.info("定位监听已启动"),(s=t.success)==null||s.call(t,i)},fail:i=>{var s;return(s=t.fail)==null?void 0:s.call(t,i)},complete:t.complete})},{context:"startLocationUpdate"})}function Mn(t={}){return l.safeExecute(()=>{var e,r;if(m()){const n={errMsg:`当前环境 (${u.type}) 不支持该接口`,code:"PLATFORM_NOT_SUPPORTED"};a.error("当前环境不支持此接口",{platform:u.type}),(e=t.fail)==null||e.call(t,n),(r=t.complete)==null||r.call(t,n);return}a.info("正在停止定位监听"),T("stopLocationUpdate",t,{success:n=>{var i;a.info("定位监听已停止"),(i=t.success)==null||i.call(t,n)},fail:n=>{var i;return(i=t.fail)==null?void 0:i.call(t,n)},complete:t.complete})},{context:"stopLocationUpdate"})}function Rn(t){return l.safeExecute(()=>{if(m()){a.warn("当前环境不支持此接口",{platform:u.type});return}if(typeof t!="function")throw a.error("onLocationChange 回调不是函数",{type:typeof t}),{errMsg:"onLocationChange 回调必须是函数",code:"INVALID_CALLBACK"};const e=X.size>0;X.add(t),e||(a.debug("注册实时位置变化监听器"),T("onLocationChange",{isPersistent:!0},{success:r=>{a.debug("收到实时位置推送",r),It(X,r,"onLocationChange")},fail:r=>{a.warn("位置变化监听出错,请通过 onLocationChangeError 监听错误",r),X.delete(t),X.size===0&&he("onLocationChange")}}))},{context:"onLocationChange"})}function Sn(t){return l.safeExecute(()=>{if(m()){a.warn("当前环境不支持此接口",{platform:u.type});return}if(t&&typeof t!="function")throw a.error("offLocationChange 回调不是函数",{type:typeof t}),{errMsg:"offLocationChange 回调必须是函数",code:"INVALID_CALLBACK"};t?X.delete(t):X.clear(),!(X.size>0)&&(a.info("移除位置变化监听器"),T("offLocationChange",{},{success:()=>{a.info("位置变化监听已移除"),he("onLocationChange")},fail:e=>{a.error("移除位置变化监听失败",e),he("onLocationChange")}}))},{context:"offLocationChange"})}function On(t){return l.safeExecute(()=>{if(m()){a.warn("当前环境不支持此接口",{platform:u.type});return}if(typeof t!="function")throw a.error("onLocationChangeError 回调不是函数",{type:typeof t}),{errMsg:"onLocationChangeError 回调必须是函数",code:"INVALID_CALLBACK"};const e=Z.size>0;Z.add(t),e||(a.debug("注册位置更新错误监听器"),T("onLocationChangeError",{isPersistent:!0},{success:r=>{a.warn("持续定位发生异常",r),It(Z,r,"onLocationChangeError")},fail:r=>{a.warn("位置更新错误监听注册失败",r),Z.delete(t),Z.size===0&&he("onLocationChangeError")}}))},{context:"onLocationChangeError"})}function Nn(t){return l.safeExecute(()=>{if(m()){a.warn("当前环境不支持此接口",{platform:u.type});return}if(t&&typeof t!="function")throw a.error("offLocationChangeError 回调不是函数",{type:typeof t}),{errMsg:"offLocationChangeError 回调必须是函数",code:"INVALID_CALLBACK"};t?Z.delete(t):Z.clear(),!(Z.size>0)&&(a.info("移除定位错误监听器"),T("offLocationChangeError",{},{success:()=>{a.info("定位错误监听已移除"),he("onLocationChangeError")},fail:e=>{a.error("移除定位错误监听失败",e),he("onLocationChangeError")}}))},{context:"offLocationChangeError"})}const Tn={latitude:null,longitude:null};function bn(t={}){const e=g(g({},Tn),t);return e.latitude!==null&&e.latitude!==void 0&&(typeof e.latitude!="number"?(a.warn("latitude 参数类型错误,已忽略",{latitude:e.latitude}),e.latitude=null):(e.latitude<-90||e.latitude>90)&&(a.warn("latitude 超出范围,已忽略",{latitude:e.latitude}),e.latitude=null)),e.longitude!==null&&e.longitude!==void 0&&(typeof e.longitude!="number"?(a.warn("longitude 参数类型错误,已忽略",{longitude:e.longitude}),e.longitude=null):(e.longitude<-180||e.longitude>180)&&(a.warn("longitude 超出范围,已忽略",{longitude:e.longitude}),e.longitude=null)),e}function At(){return["webview","UniApp","plus","nvue","uvue","offline"].includes(u.type)}function vn(t){return l.safeExecute(()=>{a.debug("通过 WebView 桥接调用位置选择",t);const e={disableTimeout:!0,success:r=>{var n;a.info("UniApp 位置选择成功",{name:r==null?void 0:r.name,address:r==null?void 0:r.address,latitude:r==null?void 0:r.latitude,longitude:r==null?void 0:r.longitude}),(n=t.success)==null||n.call(t,r)},fail:r=>{var n;a.error("UniApp 位置选择失败",r),(n=t.fail)==null||n.call(t,r)},complete:t.complete};t.latitude!==null&&t.latitude!==void 0&&(e.latitude=t.latitude),t.longitude!==null&&t.longitude!==void 0&&(e.longitude=t.longitude),T("chooseLocation",e,{success:r=>{e.success(r)},fail:r=>{e.fail(r)},complete:e.complete})},{context:"chooseLocationInUniApp",platform:"uniapp"})}function Ln(t={}){return l.safeExecute(()=>{var r;if(!At()){const n={errMsg:`当前环境 (${u.type}) 不支持位置选择功能`,code:"PLATFORM_NOT_SUPPORTED"};a.error("平台不支持位置选择",{platform:u.type}),(r=t.fail)==null||r.call(t,n);return}const e=bn(t);a.info("开始选择位置",{platform:u.type,latitude:e.latitude,longitude:e.longitude}),m()||vn(e)},{context:"chooseLocation",options:t})}function xn(){return{supported:At(),environment:u.type,implementation:m()?"weixin":"webview",features:{chooseLocation:!0,centerPoint:!0,asyncSupport:!0}}}const Pt="https://iafs.xjy2.cn/img/bg.143351f0.jpg";function Dn(t){return t==="timeline"||Number(t)===1?1:0}function Te(t="",e="targetPath"){if(!t||typeof t!="string")throw{errMsg:`share: ${e} 必须是最终小程序页面路径`,code:"PARAM_INVALID"};const r=t.trim(),[,n=""]=r.split("?");return{path:r,query:n}}function Ct(t="",e="webTarget"){if(!t||typeof t!="string")throw{errMsg:`share: ${e} 必须是公网链接,例如 https://example.com/path?a=1`,code:"PARAM_INVALID"};const r=t.trim();if(!/^https?:\/\//.test(r))throw{errMsg:`share: ${e} 必须是公网链接,例如 https://example.com/path?a=1`,code:"PARAM_INVALID"};return r}function Un(){return new Promise((t,e)=>{var s,o;const r=typeof window!="undefined"?window:null;if(!r)return e({errMsg:"当前环境不支持 plus",code:"PLUS_UNAVAILABLE"});if(r.plus)return t(r.plus);const n=setTimeout(()=>{var f,d;(d=(f=r.document)==null?void 0:f.removeEventListener)==null||d.call(f,"plusready",i),e({errMsg:"等待 plusready 超时",code:"PLUS_READY_TIMEOUT"})},8e3);function i(){clearTimeout(n),t(r.plus)}(o=(s=r.document)==null?void 0:s.addEventListener)==null||o.call(s,"plusready",i,{once:!0})})}function Wn(){return new Promise((t,e)=>{const r=typeof window!="undefined"?window.plus:null;if(!r||!r.share||typeof r.share.getServices!="function")return e({errMsg:"当前环境不支持 plus.share",code:"PLUS_SHARE_UNSUPPORTED"});r.share.getServices(n=>{const i=n.find(s=>s.id==="weixin");if(!i)return e({errMsg:"未找到微信分享服务",code:"WEIXIN_SERVICE_NOT_FOUND"});t(i)},n=>e(n||{errMsg:"获取分享服务失败",code:"GET_SHARE_SERVICES_FAILED"}))})}function $n(t){return t.isWeixinMiniProgram?"已同步分享内容,请点击右上角“···”选择发送给朋友或分享到朋友圈。":"正在拉起微信分享面板,请选择聊天框或朋友圈。"}function Fn(t={}){if(!t||typeof t!="object")throw{errMsg:"shareDirected 参数必须是对象",code:"PARAM_TYPE_ERROR"};const e=String(t.kind||"").trim(),r=t.payload||{},n=Dn(t.scene);if(!["web","image","text"].includes(e))throw{errMsg:'shareDirected: kind 仅支持 "web"|"image"|"text"',code:"PARAM_INVALID"};if(![0,1].includes(n))throw{errMsg:"shareDirected: scene 仅支持 0|1",code:"PARAM_INVALID"};if(e==="web"&&(!r.title||!r.description||!r.imageUrl))throw{errMsg:"shareDirected(web): title/description/imageUrl 必填",code:"PARAM_MISSING"};if(e==="image"&&!r.imageUrl)throw{errMsg:"shareDirected(image): payload.imageUrl 必填",code:"PARAM_MISSING"};if(e==="text"&&!r.description)throw{errMsg:"shareDirected(text): payload.description 必填",code:"PARAM_MISSING"};return{kind:e,scene:n,payload:r,resolvedTargetPath:"",resolvedWebTarget:"",success:t.success,fail:t.fail,complete:t.complete}}function kn(t,e){const{payload:r}=t;if(e.isWeixinMiniProgram)try{const n=Te(r.target,"target");return t.resolvedTargetPath=n.path,t}catch(n){throw{errMsg:(n==null?void 0:n.errMsg)||"shareDirected: 小程序环境下 payload.target 不合法",code:(n==null?void 0:n.code)||"PARAM_INVALID"}}if(e.isAppPlus){const n=(o,f)=>{try{return Ct(o,f)}catch(d){return""}},i=n(r.target,"target");if(i)return t.resolvedWebTarget=i,t;const s=n(r.webTarget,"webTarget");if(s)return t.resolvedWebTarget=s,t;throw{errMsg:"shareDirected: App 环境下 payload.target 必须是公网链接;若 target 不存在或不合法,则 payload.webTarget 也必须是公网链接",code:"PARAM_INVALID"}}return t}function Bn(t){const{kind:e,payload:r,resolvedTargetPath:n}=t,i=Te(n||r.target,"target"),s=r.imageUrl||Pt;return{title:r.title||"分享",path:i.path,query:i.query,imageUrl:s,custom:{kind:e,target:i.path,webTarget:r.webTarget||"",description:r.description||""}}}function Gn(t){const{kind:e,scene:r,payload:n,resolvedWebTarget:i}=t,s=r===1?"WXSceneTimeline":"WXSceneSession",o=n.imageUrl||Pt;return e==="image"?{message:{type:"image",pictures:[n.imageUrl],extra:{scene:s}},degradedFromText:!1}:{message:{type:"web",title:n.title||"分享",content:n.description||"",href:i,thumbs:[o],extra:{scene:s}},degradedFromText:e==="text"}}function Kn(t){return A(this,null,function*(){yield Un();const e=yield Wn(),{message:r,degradedFromText:n}=Gn(t);return new Promise((i,s)=>{e.send(r,()=>i({success:!0,data:{degradedFromText:n,hint:n?"纯文字已自动降级为图文分享,避免微信通道不支持纯文本":void 0}}),o=>s(o||{errMsg:"微信分享失败",code:"WEIXIN_SHARE_FAILED"}))})})}function _t(t,e="share"){const r=typeof window!="undefined"&&window.wx&&window.wx.miniProgram;if(!r||typeof r.postMessage!="function")throw{errMsg:`当前微信小程序容器未注入 postMessage 能力,无法发起 ${e}`,code:"MINIPROGRAM_BRIDGE_UNAVAILABLE"};r.postMessage({data:t})}function Vn(t,e){return{type:"qsh_api_call",api:"shareDirected",params:{miniProgramShare:Bn(t),rowCustom:e},timestamp:Date.now()}}function qn(t={}){if(!t||typeof t!="object")throw{errMsg:"shareMiniProgramCard 参数必须是对象",code:"PARAM_TYPE_ERROR"};const e=t.payload||{};if(!e.title)throw{errMsg:"shareMiniProgramCard: payload.title 必填",code:"PARAM_MISSING"};if(!e.imageUrl)throw{errMsg:"shareMiniProgramCard: payload.imageUrl 必填",code:"PARAM_MISSING"};if(!e.targetPath)throw{errMsg:"shareMiniProgramCard: payload.targetPath 必填",code:"PARAM_MISSING"};return Te(e.targetPath,"targetPath"),{payload:e,success:t.success,fail:t.fail,complete:t.complete}}function jn(t){switch(String(t||"release").trim().toLowerCase()){case"develop":case"development":case"test":return"test";case"trial":case"preview":case"experience":return"preview";case"release":case"formal":case"production":return"release";default:throw{errMsg:'shareMiniProgramCard: payload.envVersion 仅支持 "develop"|"trial"|"release"',code:"PARAM_INVALID"}}}function Jn(t){switch(String(t||"release").trim().toLowerCase()){case"develop":case"development":case"test":return 1;case"trial":case"preview":case"experience":return 2;case"release":case"formal":case"production":return 0;default:throw{errMsg:'shareMiniProgramCard: payload.envVersion 仅支持 "develop"|"trial"|"release"',code:"PARAM_INVALID"}}}function Hn(t){const{payload:e}=t;if(!e.appid)throw{errMsg:"shareMiniProgramCard: App 环境下 payload.appid 必填",code:"PARAM_MISSING"};try{Ct(e.webUrl,"webUrl")}catch(r){throw{errMsg:"shareMiniProgramCard: App 环境下 payload.webUrl 必填,且必须是公网链接",code:(r==null?void 0:r.code)||"PARAM_INVALID"}}return jn(e.envVersion),t}function zn(t){const{payload:e}=t,r=Te(e.targetPath,"targetPath");return{title:e.title,path:r.path,query:r.query,imageUrl:e.imageUrl}}function Yn(t){const{payload:e}=t;return{provider:"weixin",scene:"WXSceneSession",type:5,title:e.title,imageUrl:e.imageUrl,miniProgram:{id:e.appid,path:e.targetPath,type:Jn(e.envVersion),webUrl:e.webUrl}}}function Xn(t,e){return{type:"qsh_api_call",api:"shareMiniProgramCard",params:{miniProgramShare:zn(t),rowCustom:e},timestamp:Date.now()}}function Zn(t){return A(this,null,function*(){return new Promise((e,r)=>{T("shareMiniProgramCard",{appShare:Yn(t)},{success:n=>e(n||{}),fail:n=>r(n)})})})}function Mt(t={}){return l.safeExecute(()=>{var s,o,f,d,p,S,M,q,Ce,O,j;let e;try{e=Fn(t)}catch(y){return(s=t.fail)==null||s.call(t,y),Promise.reject(y)}const r=z(!0);try{e=kn(e,r)}catch(y){return(o=e.fail)==null||o.call(e,y),(f=e.complete)==null||f.call(e,y),Promise.reject(y)}const n=$n(r);if(r.isAppPlus)return Kn(e).then(y=>{var _e,jt;const J=w(g({},(y==null?void 0:y.data)||{}),{hint:n});return(_e=e.success)==null||_e.call(e,J),(jt=e.complete)==null||jt.call(e,J),J}).catch(y=>{var J,_e;return(J=e.fail)==null||J.call(e,y),(_e=e.complete)==null||_e.call(e,y),Promise.reject(y)});if(r.isWeixinMiniProgram)try{_t(Vn(e,t.rowCustom),"shareDirected");const y={success:!0,hint:n};return(d=e.success)==null||d.call(e,y),(p=e.complete)==null||p.call(e,y),Promise.resolve(y)}catch(y){return(S=e.fail)==null||S.call(e,y),(M=e.complete)==null||M.call(e,y),Promise.reject(y)}if(r.type==="h5"&&!r.isUniAppWebView&&!r.isOfflineWebview){const y={errMsg:"当前页面不在宿主 WebView 中,无法分享。请在 unified-platform-app 内打开该 H5 再重试。",code:"NOT_IN_CONTAINER"};return(q=e.fail)==null||q.call(e,y),(Ce=e.complete)==null||Ce.call(e,y),Promise.reject(y)}const i={errMsg:"当前环境暂不支持 shareDirected,请在 App 或微信小程序容器内使用。",code:"ENV_NOT_SUPPORTED"};return(O=e.fail)==null||O.call(e,i),(j=e.complete)==null||j.call(e,i),Promise.reject(i)},{context:"shareDirected",options:t})}function Qn(t={}){return new Promise((e,r)=>{Mt(w(g({},t),{success:e,fail:r}))})}function Rt(t={}){return l.safeExecute(()=>{var s,o,f,d,p,S,M,q,Ce;let e;try{e=qn(t)}catch(O){return(s=t.fail)==null||s.call(t,O),Promise.reject(O)}const r=z(!0);if(r.isAppPlus)try{e=Hn(e)}catch(O){return(o=e.fail)==null||o.call(e,O),(f=e.complete)==null||f.call(e,O),Promise.reject(O)}const n=r.isWeixinMiniProgram?"已同步小程序卡片内容,请点击右上角“···”后发送给朋友。":"正在拉起微信发送给朋友面板,请继续完成小程序卡片分享。";if(r.isAppPlus)return Zn(e).then(O=>{var y,J;const j=w(g({},O||{}),{hint:n});return(y=e.success)==null||y.call(e,j),(J=e.complete)==null||J.call(e,j),j}).catch(O=>{var j,y;return(j=e.fail)==null||j.call(e,O),(y=e.complete)==null||y.call(e,O),Promise.reject(O)});if(r.isWeixinMiniProgram)try{_t(Xn(e,t.rowCustom),"shareMiniProgramCard");const O={success:!0,hint:n};return(d=e.success)==null||d.call(e,O),(p=e.complete)==null||p.call(e,O),Promise.resolve(O)}catch(O){return(S=e.fail)==null||S.call(e,O),(M=e.complete)==null||M.call(e,O),Promise.reject(O)}const i={errMsg:"当前环境暂不支持 shareMiniProgramCard,请在 App 或微信小程序容器内使用。",code:"ENV_NOT_SUPPORTED"};return(q=e.fail)==null||q.call(e,i),(Ce=e.complete)==null||Ce.call(e,i),Promise.reject(i)},{context:"shareMiniProgramCard",options:t})}function ei(t={}){return new Promise((e,r)=>{Rt(w(g({},t),{success:e,fail:r}))})}const ti={OFF:"off",ON:"on",UNAVAILABLE:"unavailable",UNAUTHORIZED:"unauthorized"},ri={allowDuplicatesKey:!1,services:[]};function be(t={}){return g(g({},ri),t)}function Pe(){return["weixin","webview","UniApp","plus","nvue","uvue","offline"].includes(u.type)}function ni(t){return l.safeExecute(()=>A(null,null,function*(){var e;if(!window.wx){const r={errMsg:"微信JS-SDK未加载",code:"WEIXIN_SDK_NOT_LOADED"};(e=t.fail)==null||e.call(t,r);return}de()||(a.info("等待微信配置完成"),yield re()),wx.openBluetoothAdapter({success:()=>{a.info("微信蓝牙适配器已打开"),St(t)},fail:r=>{var n;a.error("蓝牙适配器打开失败",r),(n=t.fail)==null||n.call(t,r)}})}),{context:"openBluetoothAdapterInWeixin"})}function ii(t){return l.safeExecute(()=>{a.debug("通过 WebView 桥接调用蓝牙功能",t),T("bluetooth",t,{success:e=>{var r;a.info("UniApp 蓝牙调用成功",e),(r=t.success)==null||r.call(t,e)},fail:e=>{var r;a.error("UniApp 蓝牙调用失败",e),(r=t.fail)==null||r.call(t,e)},complete:t.complete})},{context:"bluetoothInUniApp"})}function ai(t){return l.safeExecute(()=>{var e;a.debug("通过 WebView 桥接调用蓝牙设备搜索功能",t),T("bluetoothDevicesDiscovery",{action:"startBluetoothDevicesDiscovery",params:{services:t.services||[],allowDuplicatesKey:(e=t.allowDuplicatesKey)!=null?e:!1}},{success:r=>{var n;console.log("[Bluetooth] 设备开启搜索成功:",r),a.info("UniApp 蓝牙设备开启搜索成功",r),(n=t.success)==null||n.call(t,r)},fail:r=>{var n;console.error("[Bluetooth] 设备开启搜索失败:",r),a.error("UniApp 蓝牙设备开启搜索失败",r),(n=t.fail)==null||n.call(t,r)},complete:t.complete})},{context:"startBluetoothDevicesDiscoveryInUniApp"})}const ve=new Set;function si(t,e={}){return l.safeExecute(()=>{var r;return ve.add(t),ve.size===1&&T("onBluetoothDeviceFound",{action:"onBluetoothDeviceFound",isPersistent:!0,params:{services:e.services||[],allowDuplicatesKey:(r=e.allowDuplicatesKey)!=null?r:!1}},{success:n=>{ve.forEach(i=>{typeof i=="function"?l.safeExecute(()=>i(n),{context:"BluetoothDeviceCallback"}):console.warn("[BluetoothDeviceCallback] 不是函数:",i)})},fail:n=>{var i;console.error("[Bluetooth] 搜索失败:",n),(i=e.fail)==null||i.call(e,n)},complete:e.complete}),()=>ve.delete(t)},{context:"qsh_onBluetoothDeviceFound"})}function oi(t){return l.safeExecute(()=>{var e;a.debug("通过 WebView 桥接调用蓝牙连接功能",t),T("bluetoothConnection",{action:"createBLEConnection",params:{deviceId:t.deviceId,name:t.name,autoConnect:(e=t.autoConnect)!=null?e:!1}},{success:r=>{var n;console.log("[Bluetooth] 蓝牙连接成功:",r),a.info("UniApp 蓝牙连接成功",r),(n=t.success)==null||n.call(t,r)},fail:r=>{var n;console.error("[Bluetooth] 蓝牙连接失败:",r),a.error("UniApp 蓝牙连接失败",r),(n=t.fail)==null||n.call(t,r)},complete:t.complete})},{context:"createBLEConnectionInUniApp"})}function ci(t={}){return l.safeExecute(()=>{var r;if(!Pe()){const n={errMsg:`当前环境 (${u.type}) 不支持蓝牙功能`,code:"PLATFORM_NOT_SUPPORTED"};a.error("平台不支持蓝牙",{platform:u.type}),(r=t.fail)==null||r.call(t,n);return}const e=be(t);a.info("开始蓝牙操作",{platform:u.type,services:e.services,allowDuplicatesKey:e.allowDuplicatesKey}),m()?ni(e):ii(e)},{context:"openBluetoothAdapter",options:t})}function ui(t={}){return l.safeExecute(()=>{var r,n;if(!Pe()){const i={errMsg:`当前环境 (${u.type}) 不支持蓝牙功能`,code:"PLATFORM_NOT_SUPPORTED"};a.error("平台不支持蓝牙",{platform:u.type}),(r=t.fail)==null||r.call(t,i),(n=t.complete)==null||n.call(t,i);return}const e=be(t);a.info("开始搜索蓝牙设备",{platform:u.type,services:e.services,allowDuplicatesKey:e.allowDuplicatesKey}),m()?startBluetoothDevicesDiscoveryInWeixin(e):ai(e)},{context:"startBluetoothDevicesDiscovery",options:t})}function St(t,e={}){return l.safeExecute(()=>{var n,i;if(!Pe()){const s={errMsg:`当前环境 (${u.type}) 不支持蓝牙功能`,code:"PLATFORM_NOT_SUPPORTED"};a.error("平台不支持蓝牙",{platform:u.type}),(n=e.fail)==null||n.call(e,s),(i=e.complete)==null||i.call(e,s);return}const r=be(e);a.info("注册蓝牙设备发现监听",{platform:u.type}),m()?onBluetoothDeviceFoundInWeixin(r):si(t,r)},{context:"onBluetoothDeviceFound",options:e})}function li(t={}){return l.safeExecute(()=>{var s,o,f,d;if(!Pe()){const p={errMsg:`当前环境 (${u.type}) 不支持蓝牙功能`,code:"PLATFORM_NOT_SUPPORTED"};a.error("平台不支持蓝牙连接",{platform:u.type}),(s=t.fail)==null||s.call(t,p),(o=t.complete)==null||o.call(t,p);return}const e=be(t),{name:r,deviceId:n,autoConnect:i=!1}=e;if(!n){const p={errMsg:"缺少 deviceId 参数",code:"INVALID_PARAMS"};(f=t.fail)==null||f.call(t,p),(d=t.complete)==null||d.call(t,p);return}a.info("创建蓝牙连接",{deviceId:n,autoConnect:i,platform:u.type}),m()?uni.createBLEConnection({deviceId:n,autoConnect:i,success:t.success,fail:t.fail,complete:t.complete}):oi(e)},{context:"createBLEConnection",options:t})}function fi(){return{supported:Pe(),environment:u.type,implementation:m()?"weixin":"webview",features:{discovery:!0,connect:!0,readWrite:!0,notify:!0,asyncSupport:!0}}}const di={};function gi(t={}){return g(g({},di),t)}function Ot(){return["webview","UniApp","plus","nvue","uvue","offline"].includes(u.type)}function hi(t){return l.safeExecute(()=>{a.debug("通过 WebView 桥接调用打印PDF",t),T("printPdf",w(g({},t),{isPersistent:!0}),{success:e=>{var r;a.info("UniApp 打印PDF成功",e),(r=t.success)==null||r.call(t,e)},fail:e=>{var r;a.error("UniApp 打印PDF失败",e),(r=t.fail)==null||r.call(t,e)},complete:t.complete})},{context:"printPdfInUniApp",platform:"uniapp"})}function pi(t={}){return l.safeExecute(()=>{var r;if(!Ot()){const n={errMsg:`当前环境 (${u.type}) 不支持打印PDF功能`,code:"PLATFORM_NOT_SUPPORTED"};a.error("平台不支持打印PDF",{platform:u.type}),(r=t.fail)==null||r.call(t,n);return}const e=gi(t);a.info("开始打印PDF",{platform:u.type}),hi(e)},{context:"printPdf",options:t})}function mi(){return{supported:Ot(),environment:u.type,implementation:"uniapp",features:{asyncSupport:!0}}}const $e="/pages/face/index";function wi(t={}){const e=g({},t);if(!e.name||typeof e.name!="string"||!e.name.trim())throw{errMsg:"缺少必需参数:name(姓名)",code:"PARAM_MISSING"};if(e.name=e.name.trim(),!e.idCardNumber||typeof e.idCardNumber!="string"||!e.idCardNumber.trim())throw{errMsg:"缺少必需参数:idCardNumber(身份证号)",code:"PARAM_MISSING"};return e.idCardNumber=e.idCardNumber.trim(),e}function Nt(){return["weixin","webview","UniApp","plus","nvue","uvue"].includes(u.type)}function Ei(){return typeof window!="undefined"&&window.wx&&window.wx.miniProgram&&typeof window.wx.miniProgram.navigateTo=="function"}function yi(t){const e=w(g({},t),{title:document.title||"",url:window.location.href||""}),r=Object.entries(e).filter(([,n])=>n!=null&&n!=="").map(([n,i])=>`${encodeURIComponent(n)}=${encodeURIComponent(String(i))}`).join("&");return r?`${$e}?${r}`:$e}function Ii(t){return l.safeExecute(()=>{if(!Ei()){a.error("微信小程序导航API不可用");return}const e=yi(t);a.debug("跳转宿主人脸识别页面",{name:t.name,targetUrl:e}),window.wx.miniProgram.navigateTo({url:e,success:()=>{a.info("已跳转到宿主人脸识别页面",{targetUrl:e})},fail:r=>{a.error("跳转宿主人脸识别页面失败",r)}})},{context:"faceVerifyInWeixin",platform:"weixin"})}function Ai(t){return l.safeExecute(()=>{a.debug("通过 WebView 桥接调用人脸识别",{platform:u.type,name:t.name}),T("faceVerify",g({},t),{success:e=>{a.info("UniApp 人脸识别调用成功",e)},fail:e=>{a.error("UniApp 人脸识别调用失败",e)}})},{context:"faceVerifyInUniApp",platform:"uniapp"})}function Pi(t={}){return l.safeExecute(()=>{if(!Nt()){a.error("平台不支持人脸识别",{platform:u.type});return}let e;try{e=wi(t)}catch(r){a.error("人脸识别参数校验失败",r);return}if(a.info("开始人脸识别",{platform:u.type,name:e.name,pagePath:$e}),m()){Ii(e);return}Ai(e)},{context:"faceVerify",options:t})}function Ci(){let t="weixin";return u.type==="UniApp"&&(t="uniapp"),{supported:Nt(),environment:u.type,implementation:t,features:{asyncSupport:!0,hostPageNavigation:m(),hostBridge:u.type==="UniApp"}}}const Tt=z();function _i(){if(typeof window=="undefined"||!z(!0).isWeixinMiniProgram)return!1;const e=De().getRuntimeConfig();return typeof e.clientId=="string"&&e.clientId.length>0}function Mi(){return A(this,null,function*(){yield rr(),_i()&&(yield re())})}ne.useResponse(rt.response,{priority:1e3});let bt=!1;function vt(){if(bt)return;bt=!0,Cr([{name:"load-weixin-sdk",run:Ye,timeoutMs:8e3},{name:"init-bridge",run:He,timeoutMs:8e3}],{onError:(e,r)=>{console.error(`[QSH-SDK] 初始化失败(${(r==null?void 0:r.name)||"unknown"}):`,e)}})}typeof window!="undefined"&&(document.readyState==="complete"||document.readyState==="interactive"?setTimeout(vt,0):document.addEventListener("DOMContentLoaded",vt));function I(t,{apiName:e}={}){return function(r={},...n){const i=r&&typeof r=="object"&&(typeof r.success=="function"||typeof r.fail=="function"||typeof r.complete=="function"),s=r&&typeof r=="object"?r:{},o=()=>i?t(s,...n):new Promise((d,p)=>{const S=w(g({},s),{success:M=>{typeof s.success=="function"&&s.success(M),d(M)},fail:M=>{typeof s.fail=="function"&&s.fail(M),p(M)},complete:s.complete});t(S,...n)});return(typeof window=="undefined"?Promise.resolve():Je()).then(()=>o()).catch(d=>{throw console.error(`[QSH-SDK] ${e||"API"} call failed:`,d),d})}}function Le(t){return typeof t=="function"?{success:t}:t&&typeof t=="object"?t:{}}const Lt=I(br),xt=I(vr),Dt=I(Lr),Ut=I(xr),Wt=I(Dr),$t=I(Ur);function Ft(t){const e=()=>Wr(t);return(typeof window=="undefined"?Promise.resolve():Je()).then(()=>e())}const Fe=I(Kr,{apiName:"getCode"});function Ri(t={}){return new Promise((e,r)=>{Fe(w(g({},t),{success:e,fail:r}))})}const ke=I(Hr,{apiName:"navigateToMiniProgram"});function Si(t={}){return new Promise((e,r)=>{ke(w(g({},t),{success:e,fail:r}))})}const Be=I(sn);function Oi(t={}){return new Promise((e,r)=>{Be(w(g({},t),{success:e,fail:r}))})}const kt=I(pi);function Ni(t={}){return new Promise((e,r)=>{kt(w(g({},t),{success:e,fail:r}))})}const Ge=I(dn),Ti=I(Pi);function bi(t={}){return new Promise((e,r)=>{Ge(w(g({},t),{success:e,fail:r}))})}const vi=I(Mt,{apiName:"shareDirected"}),Li=I(Qn,{apiName:"shareDirectedAsync"}),xi=I(gt,{apiName:"manualShare"}),Di=I(tn,{apiName:"manualShareAsync"}),Ke=I(An);function Ui(t={}){return new Promise((e,r)=>{Ke(w(g({},t),{success:e,fail:r}))})}const Ve=I(Pn);function Wi(t={}){return new Promise((e,r)=>{Ve(w(g({},t),{success:e,fail:r}))})}const qe=I(Ln);function $i(t={}){return new Promise((e,r)=>{qe(w(g({},t),{success:e,fail:r}))})}const Bt=I(ci);function Fi(t={}){return new Promise((e,r)=>{Bt(w(g({},t),{success:e,fail:r}))})}const Gt=I(ui);function ki(t={}){return new Promise((e,r)=>{Gt(w(g({},t),{success:e,fail:r}))})}const Kt=I(St);function Bi(t={}){return new Promise((e,r)=>{Kt(w(g({},t),{success:e,fail:r}))})}const Vt=I(li);function Gi(t={}){return new Promise((e,r)=>{Vt(w(g({},t),{success:e,fail:r}))})}const Ki=I(Rt,{apiName:"shareMiniProgramCard"}),Vi=I(ei,{apiName:"shareMiniProgramCardAsync"}),oe={navigateTo:Lt,navigateBack:xt,switchTab:Dt,reLaunch:Ut,redirectTo:Wt,postMessage:$t,getEnv:Ft,getCode:Fe,getCodeAsync:Ri,navigateToMiniProgram:ke,navigateToMiniProgramAsync:Si,chooseImage:Be,chooseImageAsync:Oi,scanCode:Ge,scanCodeAsync:bi,getLocation:Ke,getLocationAsync:Ui,openLocation:Ve,openLocationAsync:Wi,chooseLocation:qe,chooseLocationAsync:$i,onLocationChange:t=>I((e={})=>Rn(e.success),{apiName:"onLocationChange"})(Le(t)),offLocationChange:t=>I((e={})=>Sn(e.success),{apiName:"offLocationChange"})(Le(t)),onLocationChangeError:t=>I((e={})=>On(e.success),{apiName:"onLocationChangeError"})(Le(t)),offLocationChangeError:t=>I((e={})=>Nn(e.success),{apiName:"offLocationChangeError"})(Le(t)),startLocationUpdate:I(_n,{apiName:"startLocationUpdate"}),stopLocationUpdate:I(Mn,{apiName:"stopLocationUpdate"}),environment:Tt,ready:Mi,init:He,isReady:Yt,getState:Xt,config:Xe,weixin:{config:Xe,waitForConfig:re,isConfigReady:de,getConfigState:or,retryConfig:cr},webView:null,ImageSourceTypes:Oe,ImageSizeTypes:Ne,getImageCapabilities:on,ScanTypes:se,getScanCapabilities:gn,CoordinateTypes:pe,getLocationCapabilities:Cn,getChooseLocationCapabilities:xn,openBluetoothAdapter:Bt,openBluetoothAdapterAsync:Fi,startBluetoothDevicesDiscovery:Gt,startBluetoothDevicesDiscoveryAsync:ki,onBluetoothDeviceFound:Kt,onBluetoothDeviceFoundAsync:Bi,createBLEConnection:Vt,createBLEConnectionAsync:Gi,BluetoothStates:ti,shareDirected:vi,shareDirectedAsync:Li,manualShare:xi,manualShareAsync:Di,shareMiniProgramCard:Ki,shareMiniProgramCardAsync:Vi,getBluetoothCapabilities:fi,printPdf:kt,printPdfAsync:Ni,getPrintCapabilities:mi,faceVerify:Ti,getFaceCapabilities:Ci,plugins:{manager:Ee,register:t=>Ee.register(t),install:t=>Ee.install(t,oe),list:()=>Ee.getPluginList()},interceptors:{chain:ne,useRequest:(t,e)=>ne.useRequest(t,e),useResponse:(t,e)=>ne.useResponse(t,e),builtin:{logging:fr,performance:Y,createRetry:dr,createValidation:gr,errorNormalizer:rt}},metrics:{getPerformanceReport:()=>Y.getReport(),clearPerformanceMetrics:()=>Y.clearMetrics()},errors:{codes:c,messages:Ue,categories:B,normalize:tt,create:Ir,isStandard:Ar},store:{instance:K,get:t=>K.get(t),set:(t,e)=>K.set(t,e),subscribe:(t,e)=>K.subscribe(t,e),getSnapshot:()=>K.getSnapshot()},debug:{logger:D,setLogReporter:t=>D.setReporter(t),errorHandler:l,stateManager:te,enableDevMode:()=>D.enableDevMode(),getLogs:t=>D.getHistory(t),getStats:()=>({logger:D.getStats(),state:te.getStats(),weixinConfig:De().getStats(),plugins:Ee.getStats(),interceptors:ne.getStats(),store:K.getStats()}),getWeixinConfigManager:De,exportDebugInfo:()=>D.exportToJSON()}};Tt.isWeixinMiniProgram?oe.webView=window.wx&&window.wx.miniProgram:oe.webView={navigateTo:Lt,navigateBack:xt,switchTab:Dt,reLaunch:Ut,redirectTo:Wt,postMessage:$t,getEnv:Ft,getCode:Fe,navigateToMiniProgram:ke,chooseImage:Be,scanCode:Ge,getLocation:Ke,openLocation:Ve,chooseLocation:qe};const qt=typeof window.uni!="undefined"?window.uni:{};return Object.keys(qt).forEach(t=>{oe.hasOwnProperty(t)||(oe[t]=qt[t])}),typeof window!="undefined"&&(window.qsh=oe),oe});
|
|
1
|
+
(function(R,M){typeof exports=="object"&&typeof module!="undefined"?module.exports=M():typeof define=="function"&&define.amd?define(M):(R=typeof globalThis!="undefined"?globalThis:R||self,R.qsh=M())})(this,function(){"use strict";var la=Object.defineProperty,fa=Object.defineProperties;var da=Object.getOwnPropertyDescriptors;var tr=Object.getOwnPropertySymbols;var ga=Object.prototype.hasOwnProperty,ha=Object.prototype.propertyIsEnumerable;var Ye=(R,M,p)=>M in R?la(R,M,{enumerable:!0,configurable:!0,writable:!0,value:p}):R[M]=p,g=(R,M)=>{for(var p in M||(M={}))ga.call(M,p)&&Ye(R,p,M[p]);if(tr)for(var p of tr(M))ha.call(M,p)&&Ye(R,p,M[p]);return R},w=(R,M)=>fa(R,da(M));var X=(R,M,p)=>Ye(R,typeof M!="symbol"?M+"":M,p);var I=(R,M,p)=>new Promise((le,te)=>{var fe=k=>{try{re(p.next(k))}catch(F){te(F)}},de=k=>{try{re(p.throw(k))}catch(F){te(F)}},re=k=>k.done?le(k.value):Promise.resolve(k.value).then(fe,de);re((p=p.apply(R,M)).next())});function R(){return typeof window!="undefined"?window:void 0}function M(){return typeof navigator=="undefined"?"":navigator.userAgent||""}function p(){const t=R();if(!t)return!1;if(t.__wxjs_environment==="miniprogram"||t.wx&&t.wx.miniProgram)return!0;const e=M();return!!(e&&/micromessenger/i.test(e)&&/miniProgram/i.test(e))}function le(){const t=R();return!!(t&&t.plus)}function te(){const t=R();return!!(t&&(t.__dcloud_weex_postMessage||t.__dcloud_weex_))}function fe(){const t=R();return!!(t&&(t.__uniapp_x_postMessage||t.__uniapp_x_))}function de(){const t=M();return/uni-app/i.test(t)}function re(){const t=M();return/Html5Plus/i.test(t)}function k(){return de()||re()}function F(){const t=R();if(!t)return!1;if(t.__offline_bridge_postMessage)return!0;try{const e=t.location&&t.location.hostname;if(e&&/\.?offline\.?/i.test(e))return!0}catch(e){}return!1}function rr(){return fe()?"uvue":te()?"nvue":p()?"weixin":F()?"offline":le()?"plus":k()?"webview":de()?"UniApp":"h5"}let Re=null;function V(t=!1){return Re&&!t||(Re={isWeixinMiniProgram:p(),isAppPlus:le(),isNvue:te(),isUvue:fe(),isUniApp:de(),isHtml5Plus:re(),isUniAppWebView:k(),isOfflineWebview:F(),type:rr()}),Re}const f=V(),L={PLATFORM_NOT_SUPPORTED:"PLATFORM_NOT_SUPPORTED",API_CALL_FAILED:"API_CALL_FAILED",BRIDGE_NOT_READY:"BRIDGE_NOT_READY",INVALID_PARAMETERS:"INVALID_PARAMETERS",NETWORK_ERROR:"NETWORK_ERROR"};class v extends Error{constructor(e,r,i={},n=null){super(r),this.name="QshError",this.type=e,this.context=i,this.originalError=n,this.timestamp=new Date().toISOString(),Error.captureStackTrace&&Error.captureStackTrace(this,v)}toJSON(){return{name:this.name,type:this.type,message:this.message,context:this.context,timestamp:this.timestamp,stack:this.stack}}}const b=class b{static setDebugMode(e){b.isDebugMode=e}static addErrorCallback(e){typeof e=="function"&&b.errorCallbacks.push(e)}static removeErrorCallback(e){const r=b.errorCallbacks.indexOf(e);r>-1&&b.errorCallbacks.splice(r,1)}static handleApiError(e,r={}){let i;return e instanceof v?i=e:e instanceof Error?i=new v(L.API_CALL_FAILED,e.message,r,e):i=new v(L.API_CALL_FAILED,String(e),r),b.logError(i),b.notifyCallbacks(i),i}static handlePlatformNotSupported(e,r){const i=new v(L.PLATFORM_NOT_SUPPORTED,`API "${r}" is not supported on platform "${e}"`,{platformType:e,apiName:r});return b.logError(i),b.notifyCallbacks(i),i}static handleBridgeNotReady(e){const r=new v(L.BRIDGE_NOT_READY,`Bridge is not ready when calling "${e}"`,{apiName:e});return b.logError(r),b.notifyCallbacks(r),r}static handleInvalidParameters(e,r,i,n){const a=new v(L.INVALID_PARAMETERS,`Invalid parameter "${r}" in "${e}": expected ${i}, got ${typeof n}`,{apiName:e,paramName:r,expectedType:i,actualValue:n});return b.logError(a),b.notifyCallbacks(a),a}static safeExecute(e,r={}){try{return e()}catch(i){return b.handleApiError(i,r)}}static safeExecuteAsync(i){return I(this,arguments,function*(e,r={}){try{return yield e()}catch(n){return b.handleApiError(n,r)}})}static logError(e){if(typeof console!="undefined"){const r=`[QSH-SDK Error] ${e.type}: ${e.message}`;b.isDebugMode?console.error(r,{context:e.context,originalError:e.originalError,stack:e.stack,timestamp:e.timestamp}):console.error(r)}}static notifyCallbacks(e){b.errorCallbacks.forEach(r=>{try{r(e)}catch(i){typeof console!="undefined"&&console.error("[QSH-SDK] Error in error callback:",i)}})}static createErrorDecorator(e={}){return function(r,i,n){const a=n.value;return n.value=function(...o){return b.safeExecute(()=>a.apply(this,o),w(g({},e),{method:i,target:r.constructor.name}))},n}}};X(b,"isDebugMode",!1),X(b,"errorCallbacks",[]);let l=b;const $={UNINITIALIZED:"uninitialized",INITIALIZING:"initializing",READY:"ready",ERROR:"error"};class ir{constructor(){this.state=$.UNINITIALIZED,this.readyPromise=null,this.readyCallbacks=[],this.errorCallbacks=[],this.initializationError=null,this.handleBridgeReady=this.handleBridgeReady.bind(this),this.handleInitializationError=this.handleInitializationError.bind(this)}getState(){return this.state}isReady(){return this.state===$.READY}isInitializing(){return this.state===$.INITIALIZING}hasError(){return this.state===$.ERROR}getInitializationError(){return this.initializationError}waitForReady(){return this.isReady()?Promise.resolve():this.hasError()?Promise.reject(this.initializationError):(this.readyPromise||(this.readyPromise=new Promise((e,r)=>{this.isReady()?e():this.hasError()?r(this.initializationError):(this.readyCallbacks.push(e),this.errorCallbacks.push(r))})),this.readyPromise)}startInitialization(e){return I(this,null,function*(){if(this.state!==$.UNINITIALIZED)return this.waitForReady();this.state=$.INITIALIZING;try{yield e(),this.handleBridgeReady()}catch(r){throw this.handleInitializationError(r),r}return this.waitForReady()})}handleBridgeReady(){this.state===$.INITIALIZING&&(this.state=$.READY,this.readyCallbacks.forEach(e=>{try{e()}catch(r){l.handleApiError(r,{context:"StateManager.handleBridgeReady"})}}),this.readyCallbacks=[],this.errorCallbacks=[])}handleInitializationError(e){this.state=$.ERROR,this.initializationError=e,this.errorCallbacks.forEach(r=>{try{r(e)}catch(i){l.handleApiError(i,{context:"StateManager.handleInitializationError"})}}),this.readyCallbacks=[],this.errorCallbacks=[]}reset(){this.state=$.UNINITIALIZED,this.readyPromise=null,this.readyCallbacks=[],this.errorCallbacks=[],this.initializationError=null}onStateChange(e,r){if(this.state===e)return setTimeout(()=>r(this.state),0),()=>{};const i=()=>{this.state===e&&r(this.state)};return e===$.READY?this.readyCallbacks.push(i):e===$.ERROR&&this.errorCallbacks.push(i),()=>{const n=this.readyCallbacks.indexOf(i);n>-1&&this.readyCallbacks.splice(n,1);const a=this.errorCallbacks.indexOf(i);a>-1&&this.errorCallbacks.splice(a,1)}}getStats(){return{state:this.state,readyCallbacksCount:this.readyCallbacks.length,errorCallbacksCount:this.errorCallbacks.length,hasReadyPromise:!!this.readyPromise,hasInitializationError:!!this.initializationError}}}const ie=new ir,Xe=()=>ie.waitForReady(),nr=()=>ie.isReady(),ar=()=>ie.getState(),C={ERROR:0,WARN:1,INFO:2,DEBUG:3,TRACE:4},we={[C.ERROR]:"ERROR",[C.WARN]:"WARN",[C.INFO]:"INFO",[C.DEBUG]:"DEBUG",[C.TRACE]:"TRACE"},h=class h{static setLevel(e){e>=C.ERROR&&e<=C.TRACE&&(h.currentLevel=e,h.log(C.INFO,"Logger",`日志级别设置为: ${we[e]}`))}static enableDevMode(){h.setLevel(C.DEBUG),h.log(C.INFO,"Logger","开发模式已启用")}static enableProdMode(){h.setLevel(C.WARN),h.log(C.INFO,"Logger","生产模式已启用")}static enableModule(e){h.enabledModules.add(e),h.log(C.INFO,"Logger",`模块日志已启用: ${e}`)}static disableModule(e){h.enabledModules.delete(e),h.log(C.INFO,"Logger",`模块日志已禁用: ${e}`)}static shouldLog(e,r){return e>h.currentLevel?!1:r&&h.enabledModules.size>0?h.enabledModules.has(r):!0}static log(e,r,i,...n){if(!h.shouldLog(e,r))return;const a=new Date().toISOString(),o=we[e],c=r?`[${r}]`:"",d=`${h.prefix} ${c} ${i}`,m={timestamp:a,level:e,levelName:o,module:r,message:i,args:n};if(h.addToHistory(m),typeof h.reporter=="function")try{h.reporter(m)}catch(O){}h.outputToConsole(e,d,...n)}static addToHistory(e){h.logHistory.push(e),h.logHistory.length>h.maxHistorySize&&h.logHistory.shift()}static outputToConsole(e,r,...i){if(typeof console=="undefined")return;const n=i&&i.length>0;switch(e){case C.ERROR:n?console.error(r,...i):console.error(r);break;case C.WARN:n?console.warn(r,...i):console.warn(r);break;case C.INFO:n?console.info(r,...i):console.info(r);break;case C.DEBUG:case C.TRACE:n?console.log(r,...i):console.log(r);break}}static error(e,r,...i){h.log(C.ERROR,e,r,...i)}static warn(e,r,...i){h.log(C.WARN,e,r,...i)}static info(e,r,...i){h.log(C.INFO,e,r,...i)}static debug(e,r,...i){h.log(C.DEBUG,e,r,...i)}static trace(e,r,...i){h.log(C.TRACE,e,r,...i)}static getHistory(e){return e&&e>0?h.logHistory.slice(-e):[...h.logHistory]}static clearHistory(){h.logHistory=[],h.log(C.INFO,"Logger","日志历史已清空")}static getStats(){const e={currentLevel:h.currentLevel,currentLevelName:we[h.currentLevel],enabledModules:Array.from(h.enabledModules),historySize:h.logHistory.length,maxHistorySize:h.maxHistorySize},r={};for(const i of Object.keys(we))r[we[i]]=0;return h.logHistory.forEach(i=>{r[i.levelName]++}),e.levelCounts=r,e}static exportToJSON(e){const r=h.getHistory(e),i=h.getStats();return JSON.stringify({exportTime:new Date().toISOString(),stats:i,logs:r},null,2)}static createModuleLogger(e){return{error:(r,...i)=>h.error(e,r,...i),warn:(r,...i)=>h.warn(e,r,...i),info:(r,...i)=>h.info(e,r,...i),debug:(r,...i)=>h.debug(e,r,...i),trace:(r,...i)=>h.trace(e,r,...i)}}static setReporter(e){h.reporter=typeof e=="function"?e:null}};X(h,"currentLevel",C.ERROR),X(h,"enabledModules",new Set),X(h,"logHistory",[]),X(h,"maxHistorySize",1e3),X(h,"prefix","[QSH-SDK]"),X(h,"reporter",null);let W=h;if(typeof window!="undefined"){const t=window.location&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"||window.location.hostname.includes("192.168.")),e=window.location&&(window.location.search.includes("debug=true")||window.location.search.includes("qsh_debug=1"));let r=!1;try{r=localStorage&&localStorage.getItem("qsh_debug")==="true"}catch(i){}(t||e||r)&&W.enableDevMode()}const P=W.createModuleLogger("Bridge"),E=W.createModuleLogger("Platform"),s=W.createModuleLogger("API"),B=W.createModuleLogger("State"),Oe=/complete|loaded|interactive/;function sr(t){if(!F())return!1;P.debug("检测到离线包环境,开始初始化");const e=()=>{t()};if(Oe.test(document.readyState))P.debug("离线包环境 DOM 已就绪,立即初始化"),setTimeout(e,0);else{P.debug("离线包环境,等待 DOMContentLoaded");let r=!1;const i=()=>{r||(r=!0,e())};document.addEventListener("DOMContentLoaded",i),setTimeout(i,500)}return!0}function or(t){return de()||re()?(P.debug("检测到 APP 环境,开始初始化"),window.__uniapp_x_postMessage||window.__uniapp_x_||window.__dcloud_weex_postMessage||window.__dcloud_weex_?(P.debug("NVUE/UVUE 环境,等待 DOMContentLoaded"),document.addEventListener("DOMContentLoaded",t)):window.plus&&Oe.test(document.readyState)?(P.debug("Plus 环境已就绪,立即初始化"),setTimeout(t,0)):window.plus?(P.debug("Plus 环境,等待 plusready 事件"),document.addEventListener("plusready",t)):Oe.test(document.readyState)?setTimeout(t,0):document.addEventListener("DOMContentLoaded",t,{once:!0}),!0):!1}function cr(t){return window.wx&&window.wx.miniProgram?(P.debug("检测到微信小程序环境,开始初始化"),window.WeixinJSBridge&&window.WeixinJSBridge.invoke?(P.debug("微信 JSBridge 已就绪,立即初始化"),setTimeout(t,0)):(P.debug("微信 JSBridge 未就绪,等待 WeixinJSBridgeReady 事件"),document.addEventListener("WeixinJSBridgeReady",t)),!0):!1}function ur(t){return P.info("开始初始化 JSBridge"),sr(t)?(P.info("使用离线包环境初始化"),!0):or(t)?(P.info("使用 APP 环境初始化"),!0):cr(t)?(P.info("使用微信小程序环境初始化"),!0):(P.debug("使用默认 H5 环境初始化"),Oe.test(document.readyState)?(P.debug("DOM 已就绪,立即初始化"),setTimeout(t,0)):(P.debug("DOM 未就绪,等待 DOMContentLoaded"),document.addEventListener("DOMContentLoaded",t)),!0)}function lr(){return ie.waitForReady()}function Ze(){return ie.startInitialization(()=>I(null,null,function*(){return new Promise((t,e)=>{const r=()=>{t()},i=n=>{const a=l.handleApiError(n,{context:"bridge initialization"});e(a)};try{ur(()=>{r()})}catch(n){i(n)}})}))}const x={UNINITIALIZED:"uninitialized",CONFIGURING:"configuring",CONFIGURED:"configured",ERROR:"error"};function q(){return typeof window=="undefined"||!window.wx?!1:typeof window.wx.config=="function"&&typeof window.wx.ready=="function"&&typeof window.wx.error=="function"}class fr{constructor(){this.state=x.UNINITIALIZED,this.configPromise=null,this.readyCallbacks=[],this.errorCallbacks=[],this.lastError=null,this.configVersion=0,this.configuredConfigKey=null,this.runtimeConfig={clientId:null,isProd:!1,debug:!1,url:""},this.CONFIG_API_URL=this.getConfigApiUrl(this.runtimeConfig.isProd),this.DEFAULT_JS_API_LIST=["chooseImage","uploadImage","previewImage","downloadImage","getLocalImgData","scanQRCode","getLocation","openLocation","updateAppMessageShareData","updateTimelineShareData"],this.handleConfigSuccess=this.handleConfigSuccess.bind(this),this.handleConfigError=this.handleConfigError.bind(this)}configure(e={}){if(!e||typeof e!="object"||Array.isArray(e))throw new v(L.INVALID_PARAMETERS,"config参数异常",{config:e});if(!Object.prototype.hasOwnProperty.call(e,"clientId"))throw this.createMissingClientIdError();if(typeof e.clientId!="string"||!e.clientId.trim())throw new v(L.INVALID_PARAMETERS,"clientId参数异常",{clientId:e.clientId});if(Object.prototype.hasOwnProperty.call(e,"isProd")&&typeof e.isProd!="boolean")throw new v(L.INVALID_PARAMETERS,"isProd参数异常",{isProd:e.isProd});if(Object.prototype.hasOwnProperty.call(e,"debug")&&typeof e.debug!="boolean")throw new v(L.INVALID_PARAMETERS,"debug参数异常",{debug:e.debug});if(Object.prototype.hasOwnProperty.call(e,"url")&&typeof e.url!="string")throw new v(L.INVALID_PARAMETERS,"url参数异常",{url:e.url});const r=e.clientId.trim(),i=e.isProd===!0,n=i?!1:e.debug===!0,a=typeof e.url=="string"?e.url.trim():"",o=r!==this.runtimeConfig.clientId||i!==this.runtimeConfig.isProd||n!==this.runtimeConfig.debug||a!==this.runtimeConfig.url;return this.runtimeConfig=w(g({},this.runtimeConfig),{clientId:r,isProd:i,debug:n,url:a}),this.CONFIG_API_URL=this.getConfigApiUrl(i),(this.state===x.ERROR||o&&(this.state===x.CONFIGURING||this.state===x.CONFIGURED))&&this.reset({preserveCallbacks:!0}),E.info("Updated Weixin runtime config",{clientId:this.runtimeConfig.clientId,isProd:this.runtimeConfig.isProd,debug:this.runtimeConfig.debug,url:this.runtimeConfig.url,configApiUrl:this.CONFIG_API_URL}),this.getRuntimeConfig()}getRuntimeConfig(){return g({},this.runtimeConfig)}getEffectiveConfigUrl(e={}){const{requireWindow:r=!1}=e;return this.runtimeConfig.url?this.runtimeConfig.url:r?this.getCurrentPageUrl():typeof window=="undefined"||!window.location?"":this.getCurrentPageUrl()}getRuntimeConfigKey(){return JSON.stringify({clientId:this.runtimeConfig.clientId,isProd:this.runtimeConfig.isProd,debug:this.runtimeConfig.debug,url:this.getEffectiveConfigUrl()})}isCurrentConfigRun(e,r){return e===this.configVersion&&r===this.getRuntimeConfigKey()}hasClientId(){return typeof this.runtimeConfig.clientId=="string"&&this.runtimeConfig.clientId.length>0}hasRequiredConfig(){return this.isTestMode()||this.hasClientId()}createMissingClientIdError(){return new v(L.INVALID_PARAMETERS,"clientId错误",{field:"clientId"})}getConfigApiUrl(e=!1){return e?"https://tyck-service.xj-agri.gov.cn/api/wechat/mp/jssdk-sign":"https://unified-platform-service.xjy2.cn/api/wechat/mp/jssdk-sign"}getCurrentPageUrl(){if(typeof window=="undefined"||!window.location)throw new Error("无法获取当前页面URL");const e=window.location.href,r=e.indexOf("#");return r!==-1?e.substring(0,r):e}fetchWeixinConfig(){return I(this,null,function*(){const e=this.getEffectiveConfigUrl({requireWindow:!0});if(this.isTestMode())return E.info("使用测试模式,返回模拟配置"),this.getMockConfig();if(!this.hasClientId())throw this.createMissingClientIdError();const r=this.getConfigApiUrl(this.runtimeConfig.isProd);this.CONFIG_API_URL=r;const i=`${r}?clientId=${this.runtimeConfig.clientId}&url=${encodeURIComponent(e)}`;E.debug("请求微信配置",{url:i});try{const n=yield fetch(i);if(!n.ok)throw new Error(`HTTP ${n.status}: ${n.statusText}`);const a=yield n.json();if(E.debug("微信配置响应",a),!a.success||a.code!==200)throw new Error(`配置获取失败: ${a.message||"未知错误"}`);const{data:o}=a;if(!o||!o.appId||!o.timestamp||!o.nonceStr||!o.signature)throw new Error("配置数据格式不正确,缺少必需字段");return o}catch(n){if(E.error("获取微信配置失败",n),this.shouldUseTestMode(n))return E.warn("网络请求失败,降级到测试模式"),this.getMockConfig();throw new v(L.NETWORK_ERROR,`获取微信配置失败: ${n.message}`,{url:i,originalError:n})}})}isTestMode(){if(typeof window=="undefined")return!1;if(new URLSearchParams(window.location.search).get("qsh_test")==="true")return!0;try{if(localStorage.getItem("qsh_test")==="true")return!0}catch(r){}return!1}shouldUseTestMode(e){if(typeof window=="undefined")return!1;const r=window.location.hostname==="localhost"||window.location.hostname.includes("natappfree.cc"),i=!window.wx||!window.wx.miniProgram,n=e.message.includes("CORS")||e.message.includes("Failed to fetch");return r&&i&&n}getMockConfig(){return{appId:"wx_test_app_id",timestamp:Math.floor(Date.now()/1e3).toString(),nonceStr:Math.random().toString(36).substring(2,15),signature:"test_signature_"+Math.random().toString(36).substring(2,10)}}executeWeixinConfig(e,r,i){if(this.isTestMode()||e.appId==="wx_test_app_id"){E.info("测试模式:模拟微信配置成功"),setTimeout(()=>{this.handleConfigSuccess(r,i)},100);return}if(!q())throw new Error("微信JS-SDK未加载");const n={debug:this.runtimeConfig.debug,appId:e.appId,timestamp:parseInt(e.timestamp),nonceStr:e.nonceStr,signature:e.signature,jsApiList:this.DEFAULT_JS_API_LIST};E.info("执行微信配置",n),window.wx.ready(()=>this.handleConfigSuccess(r,i)),window.wx.error(a=>this.handleConfigError(a,r,i)),window.wx.config(n)}handleConfigSuccess(e=this.configVersion,r=this.getRuntimeConfigKey()){if(!this.isCurrentConfigRun(e,r)){E.debug("忽略过期的微信配置成功回调");return}E.info("微信配置成功"),this.state=x.CONFIGURED,this.configuredConfigKey=r,this.lastError=null,this.configPromise=null;const i=[...this.readyCallbacks];this.readyCallbacks=[],this.errorCallbacks=[],i.forEach(n=>{try{n()}catch(a){l.handleApiError(a,{context:"WeixinConfigManager.handleConfigSuccess"})}})}handleConfigError(e,r=this.configVersion,i=this.getRuntimeConfigKey()){if(!this.isCurrentConfigRun(r,i)){E.debug("忽略过期的微信配置错误回调",e);return}const n=`微信配置验证失败: ${JSON.stringify(e)}`;E.error(n,e);const a=new v(L.API_CALL_FAILED,n,{weixinErrorResponse:e});this.state=x.ERROR,this.lastError=a,this.configPromise=null;const o=[...this.errorCallbacks];this.readyCallbacks=[],this.errorCallbacks=[],o.forEach(c=>{try{c(a)}catch(d){l.handleApiError(d,{context:"WeixinConfigManager.handleConfigError"})}})}autoConfig(){return I(this,null,function*(){if(!this.hasRequiredConfig())return E.warn("clientId为空,等待qsh.config({ clientId })"),Promise.resolve();if(this.isReady())return Promise.resolve();if(this.state===x.CONFIGURED&&this.reset({preserveCallbacks:!0}),this.state===x.ERROR)return Promise.reject(this.lastError);if(this.configPromise)return this.configPromise;this.state=x.CONFIGURING;const e=this.configVersion,r=this.getRuntimeConfigKey();return this.configPromise=this.performAutoConfig(e,r),this.configPromise})}performAutoConfig(e,r){return I(this,null,function*(){try{if(typeof window=="undefined")throw new Error("非浏览器环境无法执行微信配置");if(!q())throw new Error("微信JS-SDK未加载,无法执行配置");const i=yield this.fetchWeixinConfig();if(!this.isCurrentConfigRun(e,r)){E.debug("忽略过期的微信配置响应");return}return this.executeWeixinConfig(i,e,r),yield new Promise((n,a)=>{if(this.isReady()){n();return}if(this.state===x.ERROR){a(this.lastError);return}this.readyCallbacks.push(n),this.errorCallbacks.push(a)})}catch(i){if(!this.isCurrentConfigRun(e,r)){E.debug("忽略过期的微信配置异常",i);return}const n=i instanceof v?i:l.handleApiError(i,{context:"WeixinConfigManager.performAutoConfig"});this.state=x.ERROR,this.lastError=n,this.configPromise=null;const a=[...this.errorCallbacks];throw this.readyCallbacks=[],this.errorCallbacks=[],a.forEach(o=>{try{o(n)}catch(c){l.handleApiError(c,{context:"WeixinConfigManager.performAutoConfig.errorCallback"})}}),n}})}waitForReady(){return this.isReady()?Promise.resolve():(this.state===x.CONFIGURED&&this.reset({preserveCallbacks:!0}),this.state===x.ERROR?Promise.reject(this.lastError):this.hasRequiredConfig()?this.state===x.UNINITIALIZED?this.autoConfig():new Promise((e,r)=>{this.readyCallbacks.push(e),this.errorCallbacks.push(r)}):Promise.reject(this.createMissingClientIdError()))}isReady(){return this.state===x.CONFIGURED&&this.configuredConfigKey===this.getRuntimeConfigKey()}getState(){return this.state}getLastError(){return this.lastError}reset(e={}){const{preserveCallbacks:r=!1}=e;this.configVersion+=1,this.state=x.UNINITIALIZED,this.configPromise=null,r||(this.readyCallbacks=[],this.errorCallbacks=[]),this.lastError=null,this.configuredConfigKey=null,E.debug("微信配置管理器已重置")}getStats(){return{state:this.state,readyCallbacksCount:this.readyCallbacks.length,errorCallbacksCount:this.errorCallbacks.length,hasConfigPromise:!!this.configPromise,hasLastError:!!this.lastError,configVersion:this.configVersion,configuredConfigKey:this.configuredConfigKey,configApiUrl:this.CONFIG_API_URL,clientId:this.runtimeConfig.clientId,isProd:this.runtimeConfig.isProd,debug:this.runtimeConfig.debug,url:this.runtimeConfig.url,effectiveUrl:this.getEffectiveConfigUrl(),jsApiList:this.DEFAULT_JS_API_LIST}}}const D=new fr;let ge=!1,Ee=!1,G=null,Se=!1;function dr(t){return new Promise(e=>{let r=!1,i=null;const n=c=>I(null,null,function*(){if(!r){if(r=!0,i&&clearTimeout(i),ge=!1,Ee=c,c)try{yield Qe()}catch(d){E.error("微信配置失败,将使用消息桥作为后备",d)}e()}}),a=()=>n(q()),o=()=>{E.warn("已存在的微信 JS-SDK 脚本加载失败,SDK 将使用消息桥作为后备"),n(!1)};t.addEventListener("load",a,{once:!0}),t.addEventListener("error",o,{once:!0}),setTimeout(()=>{q()&&a()},0),i=setTimeout(()=>{n(q())},3e3)})}function We(){return I(this,arguments,function*(t={}){const{force:e=!1,recoverFromError:r=!1}=t;if(yield et({force:e}),!q())throw new Error("微信 JS-SDK 未正确加载,无法执行配置");r&&hr()})}function gr(t=!1){if(typeof window=="undefined")return!1;if(q())return Ee=!0,!1;if(Ee||F())return!1;if(t)return!0;const e=navigator.userAgent||"",r=/micromessenger/i.test(e),i=/miniProgram/i.test(e),n=typeof window.__wxjs_environment!="undefined"&&window.__wxjs_environment==="miniprogram",a=!!(window.wx&&window.wx.miniProgram);return r&&(i||n||a)}function hr(){D.getState()==="error"&&(D.reset(),Se=!1)}function Qe(){return I(this,null,function*(){if(Se)return D.waitForReady();Se=!0,E.info("开始自动配置微信JS-SDK");try{yield D.autoConfig(),E.info("微信JS-SDK自动配置完成")}catch(t){E.error("微信JS-SDK自动配置失败",t)}})}function et(t={}){const{force:e=!1}=t;if(typeof window=="undefined")return Promise.resolve();if(q())return Ee=!0,Promise.resolve();const r=document.getElementById("weixin-jssdk");return r?G||(ge=!0,G=dr(r).finally(()=>{G=null}),G):gr(e)?G||(G=new Promise(i=>{ge=!0;try{const n=document.createElement("script");n.id="weixin-jssdk",n.type="text/javascript",n.async=!0,n.src="https://res.wx.qq.com/open/js/jweixin-1.6.2.js",n.onload=function(){return I(this,null,function*(){Ee=!0,ge=!1,E.info("微信 JS-SDK 已自动加载");try{yield Qe()}catch(o){E.error("微信配置失败,将使用消息桥作为后备",o)}i()})},n.onerror=function(){ge=!1,E.warn("微信 JS-SDK 加载失败,SDK 将使用消息桥作为后备"),i()},(document.getElementsByTagName("head")[0]||document.documentElement).appendChild(n)}catch(n){ge=!1,E.error("注入微信 JS-SDK 失败",n),i()}}).finally(()=>{G=null}),G):Promise.resolve()}function ne(){return We({force:!0,recoverFromError:!0}).then(()=>D.waitForReady())}function tt(t={}){const e=D.configure(t);return typeof window=="undefined"||We({force:!0,recoverFromError:D.getState()==="error"}).then(()=>{if(!D.isReady())return D.waitForReady().catch(r=>{E.error("Failed to auto-configure Weixin after qsh.config()",r)});window.wx&&!q()&&E.warn("window.wx 已存在,但微信 JS-SDK 尚未就绪,跳过自动配置")}).catch(r=>{E.error("Failed to preload Weixin JS-SDK",r)}),e}function he(){return D.isReady()}function mr(){return D.getState()}function $e(){return D}function pr(){return I(this,null,function*(){return E.info("手动重试微信配置"),D.reset(),Se=!1,yield We({force:!0}),D.waitForReady()})}class wr{constructor(){this.plugins=new Map,this.installed=new Set,this.installOrder=[],s.debug("插件管理器已初始化")}register(e){return l.safeExecute(()=>{this.validatePlugin(e);const{name:r,version:i}=e;if(this.plugins.has(r)){const n=this.plugins.get(r);s.warn(`插件 ${r} 已注册(版本 ${n.version}),将被覆盖为版本 ${i}`)}return this.plugins.set(r,e),s.info(`插件已注册: ${r}@${i}`),this},{context:"PluginManager.register",pluginName:e==null?void 0:e.name})}validatePlugin(e){if(!e||typeof e!="object")throw new Error("插件必须是一个对象");if(!e.name||typeof e.name!="string")throw new Error("插件必须有 name 属性(字符串)");if(!e.version||typeof e.version!="string")throw new Error(`插件 ${e.name} 必须有 version 属性(字符串)`);if(!e.install||typeof e.install!="function")throw new Error(`插件 ${e.name} 必须实现 install 方法`);if(e.dependencies&&!Array.isArray(e.dependencies))throw new Error(`插件 ${e.name} 的 dependencies 必须是数组`)}install(e,r){return I(this,null,function*(){return l.safeExecute(()=>I(this,null,function*(){if(!this.plugins.has(e))throw new Error(`插件 ${e} 未注册`);if(this.installed.has(e)){s.debug(`插件 ${e} 已安装,跳过`);return}const i=this.plugins.get(e);if(i.dependencies&&i.dependencies.length>0){s.debug(`安装插件 ${e} 的依赖:`,i.dependencies);for(const n of i.dependencies)yield this.install(n,r)}s.info(`开始安装插件: ${e}@${i.version}`),yield i.install(r),this.installed.add(e),this.installOrder.push(e),s.info(`插件安装成功: ${e}@${i.version}`)}),{context:"PluginManager.install",pluginName:e})})}uninstall(e,r){return I(this,null,function*(){return l.safeExecute(()=>I(this,null,function*(){if(!this.installed.has(e)){s.debug(`插件 ${e} 未安装,跳过卸载`);return}const i=this.plugins.get(e);i.uninstall&&typeof i.uninstall=="function"&&(s.info(`开始卸载插件: ${e}`),yield i.uninstall(r)),this.installed.delete(e);const n=this.installOrder.indexOf(e);n>-1&&this.installOrder.splice(n,1),s.info(`插件已卸载: ${e}`)}),{context:"PluginManager.uninstall",pluginName:e})})}uninstallAll(e){return I(this,null,function*(){const r=[...this.installOrder].reverse();for(const i of r)yield this.uninstall(i,e)})}registerAll(e){if(!Array.isArray(e))throw new Error("plugins 必须是数组");return e.forEach(r=>this.register(r)),this}installAll(e,r){return I(this,null,function*(){if(!Array.isArray(e))throw new Error("names 必须是数组");for(const i of e)yield this.install(i,r)})}isRegistered(e){return this.plugins.has(e)}isInstalled(e){return this.installed.has(e)}getPlugin(e){return this.plugins.get(e)}getPluginList(){return Array.from(this.plugins.entries()).map(([e,r])=>({name:e,version:r.version,installed:this.installed.has(e),dependencies:r.dependencies||[]}))}getStats(){return{registered:this.plugins.size,installed:this.installed.size,plugins:this.getPluginList()}}clear(){this.plugins.clear(),this.installed.clear(),this.installOrder=[]}}const ye=new wr;class Er{constructor(){this.requestInterceptors=[],this.responseInterceptors=[],s.debug("拦截器链已初始化")}useRequest(e,r={}){if(typeof e!="function")throw new Error("拦截器必须是函数");const{priority:i=0}=r;return this.requestInterceptors.push({fn:e,priority:i}),this.requestInterceptors.sort((n,a)=>a.priority-n.priority),s.debug("请求拦截器已注册",{priority:i}),()=>{const n=this.requestInterceptors.findIndex(a=>a.fn===e);n>-1&&(this.requestInterceptors.splice(n,1),s.debug("请求拦截器已移除"))}}useResponse(e,r={}){if(typeof e!="function")throw new Error("拦截器必须是函数");const{priority:i=0}=r;return this.responseInterceptors.push({fn:e,priority:i}),this.responseInterceptors.sort((n,a)=>a.priority-n.priority),s.debug("响应拦截器已注册",{priority:i}),()=>{const n=this.responseInterceptors.findIndex(a=>a.fn===e);n>-1&&(this.responseInterceptors.splice(n,1),s.debug("响应拦截器已移除"))}}runRequest(e){return I(this,null,function*(){let r=g({},e);for(const{fn:i}of this.requestInterceptors){if(r.abort){s.debug("请求被中止",{apiName:r.apiName});break}try{const n=yield i(r);n&&(r=n)}catch(n){s.error("请求拦截器执行失败",n),r.abort=!0,r.error=n;break}}return r})}runResponse(e,r){return I(this,null,function*(){let i=e;for(const{fn:n}of this.responseInterceptors)try{const a=yield n(i,r);a!==void 0&&(i=a)}catch(a){s.error("响应拦截器执行失败",a)}return i})}clear(){this.requestInterceptors=[],this.responseInterceptors=[],s.debug("所有拦截器已清空")}getStats(){return{requestInterceptors:this.requestInterceptors.length,responseInterceptors:this.responseInterceptors.length}}}const ae=new Er,yr={request:t=>(t.startTime=Date.now(),s.debug(`[API 调用] ${t.apiName}`,{params:t.params}),t),response:(t,e)=>{const r=Date.now()-e.startTime;return s.debug(`[API 完成] ${e.apiName}`,{duration:`${r}ms`,success:t==null?void 0:t.success}),t}},Z={metrics:new Map,request:t=>(t.perfStartTime=performance.now(),t),response:(t,e)=>{const r=performance.now()-e.perfStartTime;Z.metrics.has(e.apiName)||Z.metrics.set(e.apiName,{count:0,totalTime:0,minTime:1/0,maxTime:0,avgTime:0});const i=Z.metrics.get(e.apiName);return i.count++,i.totalTime+=r,i.minTime=Math.min(i.minTime,r),i.maxTime=Math.max(i.maxTime,r),i.avgTime=i.totalTime/i.count,t},getReport:()=>{const t={};return Z.metrics.forEach((e,r)=>{t[r]=g({},e)}),t},clearMetrics:()=>{Z.metrics.clear()}};function Ar(t={}){const{maxRetries:e=3,retryDelay:r=1e3,shouldRetry:i=n=>!n.success}=t;return{response:(n,a)=>I(null,null,function*(){return a.retryCount||(a.retryCount=0),i(n)&&a.retryCount<e&&(a.retryCount++,s.warn(`API 调用失败,第 ${a.retryCount} 次重试: ${a.apiName}`),yield new Promise(o=>setTimeout(o,r)),n.shouldRetry=!0,n.retryContext=a),n})}}function Ir(t={}){return{request:e=>{const r=t[e.apiName];if(r&&typeof r=="function"){const i=r(e.params);i&&(s.error(`参数验证失败: ${e.apiName}`,i),e.abort=!0,e.validationError=i)}return e}}}class Pr{constructor(){this.state={sdk:{status:"uninitialized",version:"2.0.5",error:null},platform:{type:f.type,isWeixinMiniProgram:f.isWeixinMiniProgram,isAppPlus:f.isAppPlus,isNvue:f.isNvue,isUvue:f.isUvue,isOfflineWebview:f.isOfflineWebview,features:{}},weixin:{configStatus:"pending",jsApiList:[],configError:null},network:{online:typeof navigator!="undefined"?navigator.onLine:!0,type:"unknown"},permissions:{camera:"prompt",location:"prompt",album:"prompt"},api:{}},this.listeners=new Map,this.wildcardListeners=new Set,this.initNetworkListener(),B.debug("状态仓库已初始化")}get(e){return e.split(".").reduce((i,n)=>i!=null?i[n]:void 0,this.state)}set(e,r){const i=e.split("."),n=i.pop(),a=i.reduce((c,d)=>((!c[d]||typeof c[d]!="object")&&(c[d]={}),c[d]),this.state),o=a[n];o!==r&&(a[n]=r,B.debug(`状态已更新: ${e}`,{oldValue:o,newValue:r}),this.notify(e,r,o))}batchUpdate(e){Object.entries(e).forEach(([r,i])=>{this.set(r,i)})}subscribe(e,r){if(typeof r!="function")throw new Error("listener 必须是函数");return e==="*"?(this.wildcardListeners.add(r),B.debug("添加通配符订阅者"),()=>{this.wildcardListeners.delete(r),B.debug("移除通配符订阅者")}):(this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e).add(r),B.debug(`添加订阅者: ${e}`),()=>{const i=this.listeners.get(e);i&&(i.delete(r),i.size===0&&this.listeners.delete(e),B.debug(`移除订阅者: ${e}`))})}subscribeOnce(e,r){const i=this.subscribe(e,(n,a,o)=>{r(n,a,o),i()});return i}notify(e,r,i){const n=this.listeners.get(e);n&&n.forEach(o=>{try{o(r,i,e)}catch(c){B.error("订阅者执行失败",c)}});const a=e.split(".");for(let o=1;o<a.length;o++){const c=a.slice(0,o).join("."),d=this.listeners.get(c);if(d){const m=this.get(c);d.forEach(O=>{try{O(m,void 0,c)}catch(_){B.error("父路径订阅者执行失败",_)}})}}this.wildcardListeners.forEach(o=>{try{o(r,i,e)}catch(c){B.error("通配符订阅者执行失败",c)}})}initNetworkListener(){if(typeof window!="undefined"&&(window.addEventListener("online",()=>{this.set("network.online",!0)}),window.addEventListener("offline",()=>{this.set("network.online",!1)}),navigator.connection)){const e=navigator.connection,r=()=>{this.set("network.type",e.effectiveType||"unknown")};e.addEventListener("change",r),r()}}setApiLoading(e,r=!0){const i=`api.${e}`,n=this.get(i)||{};this.set(i,w(g({},n),{loading:r,lastCall:r?Date.now():n.lastCall}))}setApiResult(e,r){const i=`api.${e}`,n=this.get(i)||{};this.set(i,w(g({},n),{loading:!1,lastResult:r,lastCallEnd:Date.now()}))}getSnapshot(){return JSON.parse(JSON.stringify(this.state))}reset(){const{platform:e}=this.state;this.state={sdk:{status:"uninitialized",version:"2.0.5",error:null},platform:e,weixin:{configStatus:"pending",jsApiList:[],configError:null},network:{online:typeof navigator!="undefined"?navigator.onLine:!0,type:"unknown"},permissions:{camera:"prompt",location:"prompt",album:"prompt"},api:{}},B.debug("状态已重置")}getStats(){return{listeners:this.listeners.size,wildcardListeners:this.wildcardListeners.size,apiStates:Object.keys(this.state.api).length}}}const j=new Pr,u={SDK_NOT_READY:"E_SDK_001",SDK_INIT_FAILED:"E_SDK_002",SDK_CONFIG_FAILED:"E_SDK_003",PLATFORM_NOT_SUPPORTED:"E_SDK_004",NETWORK_ERROR:"E_NET_001",NETWORK_TIMEOUT:"E_NET_002",NETWORK_OFFLINE:"E_NET_003",IMAGE_CANCELLED:"E_IMG_001",IMAGE_NO_PERMISSION:"E_IMG_002",IMAGE_SIZE_EXCEED:"E_IMG_003",IMAGE_COUNT_EXCEED:"E_IMG_004",IMAGE_FORMAT_ERROR:"E_IMG_005",IMAGE_CONFIG_NOT_READY:"E_IMG_006",LOCATION_CANCELLED:"E_LOC_001",LOCATION_NO_PERMISSION:"E_LOC_002",LOCATION_UNAVAILABLE:"E_LOC_003",LOCATION_TIMEOUT:"E_LOC_004",SCAN_CANCELLED:"E_SCAN_001",SCAN_NO_PERMISSION:"E_SCAN_002",SCAN_INVALID_CODE:"E_SCAN_003",SCAN_CONFIG_NOT_READY:"E_SCAN_004",PERMISSION_DENIED:"E_PERM_001",PERMISSION_CAMERA:"E_PERM_002",PERMISSION_LOCATION:"E_PERM_003",PERMISSION_ALBUM:"E_PERM_004",PERMISSION_MICROPHONE:"E_PERM_005",PARAM_INVALID:"E_PARAM_001",PARAM_MISSING:"E_PARAM_002",PARAM_TYPE_ERROR:"E_PARAM_003",API_TIMEOUT:"E_TIMEOUT_001",UNKNOWN_ERROR:"E_UNKNOWN_999"},Fe={[u.SDK_NOT_READY]:"SDK 未就绪",[u.SDK_INIT_FAILED]:"SDK 初始化失败",[u.SDK_CONFIG_FAILED]:"SDK 配置失败",[u.PLATFORM_NOT_SUPPORTED]:"当前平台不支持此功能",[u.NETWORK_ERROR]:"网络错误",[u.NETWORK_TIMEOUT]:"网络超时",[u.NETWORK_OFFLINE]:"网络已断开",[u.IMAGE_CANCELLED]:"用户取消选择图片",[u.IMAGE_NO_PERMISSION]:"无相机/相册权限",[u.IMAGE_SIZE_EXCEED]:"图片大小超出限制",[u.IMAGE_COUNT_EXCEED]:"图片数量超出限制",[u.IMAGE_FORMAT_ERROR]:"图片格式不支持",[u.IMAGE_CONFIG_NOT_READY]:"微信配置未完成",[u.LOCATION_CANCELLED]:"用户取消定位",[u.LOCATION_NO_PERMISSION]:"无定位权限",[u.LOCATION_UNAVAILABLE]:"定位服务不可用",[u.LOCATION_TIMEOUT]:"定位超时",[u.SCAN_CANCELLED]:"用户取消扫码",[u.SCAN_NO_PERMISSION]:"无相机权限",[u.SCAN_INVALID_CODE]:"无效的二维码/条形码",[u.SCAN_CONFIG_NOT_READY]:"微信配置未完成",[u.PERMISSION_DENIED]:"权限被拒绝",[u.PERMISSION_CAMERA]:"无相机权限",[u.PERMISSION_LOCATION]:"无定位权限",[u.PERMISSION_ALBUM]:"无相册权限",[u.PERMISSION_MICROPHONE]:"无麦克风权限",[u.PARAM_INVALID]:"参数无效",[u.PARAM_MISSING]:"缺少必需参数",[u.PARAM_TYPE_ERROR]:"参数类型错误",[u.API_TIMEOUT]:"API 调用超时",[u.UNKNOWN_ERROR]:"未知错误"},K={USER_CANCEL:"user_cancel",PERMISSION:"permission",NETWORK:"network",PARAM:"param",SYSTEM:"system",CONFIG:"config",UNKNOWN:"unknown"},Mr={"IMAGE/USER_CANCEL":u.IMAGE_CANCELLED,"IMAGE/PERMISSION_DENIED":u.IMAGE_NO_PERMISSION,"COMMON/UNKNOWN":u.UNKNOWN_ERROR,"COMMON/CONFIG_NOT_READY":u.IMAGE_CONFIG_NOT_READY,"COMMON/PLATFORM_NOT_SUPPORTED":u.PLATFORM_NOT_SUPPORTED},rt={weixin:{patterns:[{pattern:/cancel/i,code:u.IMAGE_CANCELLED},{pattern:/permission|auth\s*deny/i,code:u.IMAGE_NO_PERMISSION},{pattern:/config/i,code:u.IMAGE_CONFIG_NOT_READY},{pattern:/timeout/i,code:u.API_TIMEOUT},{pattern:/network/i,code:u.NETWORK_ERROR}],default:u.UNKNOWN_ERROR},uniapp:{patterns:[{pattern:/cancel/i,code:u.IMAGE_CANCELLED},{pattern:/permission|denied/i,code:u.IMAGE_NO_PERMISSION},{pattern:/timeout/i,code:u.API_TIMEOUT},{pattern:/network/i,code:u.NETWORK_ERROR},{pattern:/not_in_container/i,code:u.PLATFORM_NOT_SUPPORTED}],default:u.UNKNOWN_ERROR},offline:{patterns:[{pattern:/cancel/i,code:u.IMAGE_CANCELLED},{pattern:/permission|denied/i,code:u.IMAGE_NO_PERMISSION},{pattern:/timeout/i,code:u.API_TIMEOUT},{pattern:/network/i,code:u.NETWORK_ERROR},{pattern:/not_in_container/i,code:u.PLATFORM_NOT_SUPPORTED}],default:u.UNKNOWN_ERROR}},it={chooseImage:{"fail cancel":u.IMAGE_CANCELLED,"fail auth deny":u.IMAGE_NO_PERMISSION,"fail No Permission":u.IMAGE_NO_PERMISSION,NOT_IN_CONTAINER:u.PLATFORM_NOT_SUPPORTED},scanCode:{"fail cancel":u.SCAN_CANCELLED,"fail auth deny":u.SCAN_NO_PERMISSION,"fail No Permission":u.SCAN_NO_PERMISSION,NOT_IN_CONTAINER:u.PLATFORM_NOT_SUPPORTED}};function nt(t){return t?t.includes("CANCEL")?K.USER_CANCEL:t.includes("PERM")||t.includes("PERMISSION")?K.PERMISSION:t.includes("NET")||t.includes("NETWORK")?K.NETWORK:t.includes("PARAM")?K.PARAM:t.includes("CONFIG")?K.CONFIG:t.includes("SDK")||t.includes("PLATFORM")?K.SYSTEM:K.UNKNOWN:K.UNKNOWN}function Cr(t){return t.includes("NET_")||t.includes("TIMEOUT")||t===u.NETWORK_ERROR||t===u.NETWORK_TIMEOUT||t===u.API_TIMEOUT}function _r(t){return t.includes("CANCEL")||nt(t)===K.USER_CANCEL}function me(t){return Fe[t]||Fe[u.UNKNOWN_ERROR]}class J extends Error{constructor(e,r,i={}){super(r),this.name="StandardError",this.code=e,this.message=r||me(e),this.platform=i.platform||f.type,this.apiName=i.apiName,this.category=i.category||nt(e),this.retriable=i.retriable!==void 0?i.retriable:Cr(e),this.originalError=i.originalError,this.details=i.details||{},this.timestamp=Date.now()}isRetriable(){return this.retriable}isUserAction(){return _r(this.code)}toJSON(){return g({code:this.code,message:this.message,platform:this.platform,apiName:this.apiName,category:this.category,retriable:this.retriable,timestamp:this.timestamp,details:this.details},process.env.NODE_ENV!=="production"&&this.originalError?{originalError:this.originalError}:{})}}function at(t,e={}){if(t instanceof J)return t;const{apiName:r,platform:i=f.type}=e;return t&&typeof t.code=="string"&&t.code.includes("/")?Rr(t,{apiName:r,platform:i}):t&&(t.errMsg||t.message)?Or(t,{apiName:r,platform:i}):typeof t=="string"?new J(u.UNKNOWN_ERROR,t,{apiName:r,platform:i,originalError:t}):new J(u.UNKNOWN_ERROR,"未知错误",{apiName:r,platform:i,originalError:t,details:{errorType:typeof t}})}function Rr(t,e){const{apiName:r,platform:i}=e,n=t.code,a=Mr[n]||u.UNKNOWN_ERROR;return s.debug("转换旧版错误码",{legacy:n,new:a}),new J(a,t.message||me(a),{apiName:r,platform:t.platform||i,originalError:t,details:g({legacyCode:n,legacyVersion:t.version},t.details)})}function Or(t,e){const{apiName:r,platform:i}=e,n=(t.errMsg||t.message||"").toLowerCase();if(r&&it[r]){const c=it[r];for(const[d,m]of Object.entries(c))if(n.includes(d.toLowerCase()))return new J(m,me(m),{apiName:r,platform:i,originalError:t})}const a=rt[i]||rt.uniapp;for(const{pattern:c,code:d}of a.patterns)if(c.test(n))return new J(d,me(d),{apiName:r,platform:i,originalError:t});const o=a.default||u.UNKNOWN_ERROR;return new J(o,t.errMsg||t.message||me(o),{apiName:r,platform:i,originalError:t})}const st={response:(t,e)=>{if(!t.success&&t.error){const r=at(t.error,{apiName:e.apiName,platform:f.type});t.error=r.toJSON(),t.errorCode=r.code,t.errorCategory=r.category,t.retriable=r.isRetriable(),s.debug("错误已标准化",{api:e.apiName,code:r.code,category:r.category})}return t}};function Sr(t,e={}){return new J(t,me(t),e)}function Nr(t){return t instanceof J}function br(t,e,r){return e?Promise.race([t(),new Promise((i,n)=>setTimeout(()=>n(new Error(`Init task timeout: ${r}`)),e))]):t()}function vr(){return I(this,arguments,function*(t=[],e={}){for(const r of t){const i=(r==null?void 0:r.name)||"anonymous-task",n=(r==null?void 0:r.run)||r;if(typeof n=="function")try{yield br(()=>Promise.resolve().then(()=>n()),r.timeoutMs,i),typeof r.onSuccess=="function"&&r.onSuccess()}catch(a){if(typeof r.onError=="function"&&r.onError(a),typeof e.onError=="function")e.onError(a,r);else throw a}}})}class ot{constructor(e){this.name=e}processNavigationOptions(e={}){const{url:r,delta:i=1}=e,n=r&&encodeURI(r),a=parseInt(i)||1;return w(g({},e),{url:n,delta:a})}processMessageOptions(e={}){const{data:r={}}=e;return{data:r}}navigateTo(e){const r=this.processNavigationOptions(e);return this.performNavigation("navigateTo",r)}navigateBack(e={}){const r=this.processNavigationOptions(e);return this.performNavigation("navigateBack",r)}switchTab(e){const r=this.processNavigationOptions(e);return this.performNavigation("switchTab",r)}reLaunch(e){const r=this.processNavigationOptions(e);return this.performNavigation("reLaunch",r)}redirectTo(e){const r=this.processNavigationOptions(e);return this.performNavigation("redirectTo",r)}postMessage(e={}){const r=this.processMessageOptions(e);return this.performPostMessage(r)}getEnv(e){return this.performGetEnv(e)}performNavigation(e,r){throw new Error(`${this.name} platform must implement performNavigation method`)}performPostMessage(e){throw new Error(`${this.name} platform must implement performPostMessage method`)}performGetEnv(e){throw new Error(`${this.name} platform must implement performGetEnv method`)}}let Ae=[];function Tr(){if(Ae.length===0&&window.plus){const t=plus.webview.currentWebview();if(!t)throw new Error("plus.webview.currentWebview() is undefined");const e=t.parent(),r=e?e.id:t.id;Ae.push(r)}return Ae}function xr(t,e){const r={options:{timestamp:+new Date},name:t,arg:e};if(t==="postMessage"){const n={data:e};return window.__uniapp_x_postMessage?window.__uniapp_x_postMessage(n):window.__uniapp_x_.postMessage(JSON.stringify(n))}const i={type:"WEB_INVOKE_APPSERVICE",args:{data:r,webviewIds:Ae}};window.__uniapp_x_postMessage?window.__uniapp_x_postMessageToService(i):window.__uniapp_x_.postMessageToService(JSON.stringify(i))}function Lr(t,e){const r={options:{timestamp:+new Date},name:t,arg:e};if(t==="postMessage"){const n={data:[e]};return window.__dcloud_weex_postMessage?window.__dcloud_weex_postMessage(n):window.__dcloud_weex_.postMessage(JSON.stringify(n))}const i={type:"WEB_INVOKE_APPSERVICE",args:{data:r,webviewIds:Ae}};window.__dcloud_weex_postMessage?window.__dcloud_weex_postMessageToService(i):window.__dcloud_weex_.postMessageToService(JSON.stringify(i))}function Dr(t,e){const r={options:{timestamp:+new Date},name:t,arg:e},i=Tr();if(plus.webview.getWebviewById("__uniapp__service"))plus.webview.postMessageToUniNView({type:"WEB_INVOKE_APPSERVICE",args:{data:r,webviewIds:i}},"__uniapp__service");else{const n=JSON.stringify(r),a=JSON.stringify(i);plus.webview.getLaunchWebview().evalJS(`UniPlusBridge.subscribeHandler("WEB_INVOKE_APPSERVICE",${n},${a});`)}}function Ur(t,e){const r={options:{timestamp:+new Date},name:t,arg:e};window.parent.postMessage({type:"WEB_INVOKE_APPSERVICE",data:r,pageId:""},"*")}function Wr(t){return!!(t&&typeof t=="object"&&t.type==="qsh_api_call"&&typeof t.api=="string"&&typeof t.callbackId=="string")}function $r(t,e){const r={options:{timestamp:+new Date},name:t,arg:e};if(t==="postMessage"&&Wr(e))return window.__offline_bridge_postMessage(e);window.__offline_bridge_postMessage({type:"WEB_INVOKE_APPSERVICE",data:r,pageId:""})}function Ie(t,e){fe()?xr(t,e):te()?Lr(t,e):F()?$r(t,e):le()?Dr(t,e):Ur(t,e)}class ct extends ot{constructor(){super("weixin")}isWeixinApiAvailable(){return typeof window!="undefined"&&window.wx&&window.wx.miniProgram}performNavigation(e,r){return l.safeExecute(()=>{const{url:i,delta:n}=r;if(E.debug(`微信平台执行导航操作: ${e}`,r),this.isWeixinApiAvailable()){const o=window.wx.miniProgram[e];if(typeof o=="function"){E.debug(`使用微信原生 API: wx.miniProgram.${e}`);const c=e==="navigateBack"?{delta:n}:{url:i};return o.call(window.wx.miniProgram,c)}}E.debug(`使用消息桥接执行: ${e}`),Ie(e,e==="navigateBack"?{delta:n}:{url:i})},{platform:this.name,method:"performNavigation",navigationType:e,options:r})}performPostMessage(e){return l.safeExecute(()=>{const{data:r}=e;if(this.isWeixinApiAvailable())return window.wx.miniProgram.postMessage({data:r});Ie("postMessage",r)},{platform:this.name,method:"performPostMessage",options:e})}performGetEnv(e){return l.safeExecute(()=>{if(!e||typeof e!="function")throw new Error("Callback function is required for getEnv");if(this.isWeixinApiAvailable()&&window.wx.miniProgram.getEnv)return window.wx.miniProgram.getEnv(e);e({miniprogram:!0,weixin:!0})},{platform:this.name,method:"performGetEnv"})}}const se=new ct;var ut=Object.freeze({__proto__:null,WeixinPlatform:ct,getEnv:t=>se.getEnv(t),navigateBack:t=>se.navigateBack(t),navigateTo:t=>se.navigateTo(t),postMessage:t=>se.postMessage(t),reLaunch:t=>se.reLaunch(t),redirectTo:t=>se.redirectTo(t),switchTab:t=>se.switchTab(t)});class lt extends ot{constructor(){super("app")}performNavigation(e,r){return l.safeExecute(()=>{const{url:i,delta:n}=r;Ie(e,e==="navigateBack"?{delta:n}:{url:i})},{platform:this.name,method:"performNavigation",navigationType:e,options:r})}performPostMessage(e){return l.safeExecute(()=>{const{data:r}=e;Ie("postMessage",r)},{platform:this.name,method:"performPostMessage",options:e})}performGetEnv(e){return l.safeExecute(()=>{if(!e||typeof e!="function")throw new Error("Callback function is required for getEnv");const r={};let i=!1;fe()?(r.uvue=!0,i=!0):te()?(r.nvue=!0,i=!0):le()?(r.plus=!0,i=!0):F()&&(r.offline=!0,i=!0),i?r.app=!0:r.h5=!0,e(r)},{platform:this.name,method:"performGetEnv"})}}const oe=new lt;var ft=Object.freeze({__proto__:null,AppPlatform:lt,getEnv:t=>oe.getEnv(t),navigateBack:t=>oe.navigateBack(t),navigateTo:t=>oe.navigateTo(t),postMessage:t=>oe.postMessage(t),reLaunch:t=>oe.reLaunch(t),redirectTo:t=>oe.redirectTo(t),switchTab:t=>oe.switchTab(t)});function Pe(){return p()?ut:ft}function Fr(t){return Pe().navigateTo(t)}function kr(t){return Pe().navigateBack(t)}function Br(t){return Pe().switchTab(t)}function Gr(t){return Pe().reLaunch(t)}function Kr(t){return Pe().redirectTo(t)}function dt(){return p()?ut:ft}function Vr(t={}){return dt().postMessage(t)}function qr(t){return dt().getEnv(t)}function jr(t){return t&&typeof t=="object"&&t.__v_raw?t.__v_raw:t}function Jr(){return"qsh_callback_"+Date.now()+"_"+Math.random().toString(36).substring(2,9)}class Hr{constructor(){this.callbacks=new Map,this.timeouts=new Map,this.persistentCallbacksByApi=new Map,this.defaultTimeout=3e4,typeof window!="undefined"&&(window.qshWebviewCallbacks||(window.qshWebviewCallbacks={})),P.debug("WebView 桥接器已初始化")}callApi(n){return I(this,arguments,function*(e,r={},i={}){return l.safeExecute(()=>I(this,null,function*(){var m;if(typeof window!="undefined"&&window===window.parent&&!window.plus&&!window.__uniapp_x_postMessage&&!window.__uniapp_x_&&!window.__dcloud_weex_postMessage&&!window.__dcloud_weex_&&!F()){const O=new v(L.PLATFORM_NOT_SUPPORTED,"当前不在宿主 WebView 容器中,无法发送消息");i&&typeof i.fail=="function"&&i.fail({errMsg:O.message,code:"NOT_IN_CONTAINER"}),i&&typeof i.complete=="function"&&i.complete({success:!1,error:{errMsg:O.message}});return}const o={apiName:e,params:r,callbacks:i,timestamp:Date.now(),abort:!1,metadata:{}};j.setApiLoading(e,!0);const c=yield ae.runRequest(o);if(c.abort){P.warn("API 调用被拦截器中止",{api:e}),j.setApiLoading(e,!1),i.fail&&i.fail({errMsg:((m=c.error)==null?void 0:m.message)||"API 调用被中止",code:"INTERCEPTED"}),i.complete&&i.complete({success:!1});return}const d=Jr();if(i.success||i.fail||i.complete){if(this.callbacks.set(d,w(g({},i),{context:c})),window.qshWebviewCallbacks[d]=H=>{this.handleCallback(d,H)},r.isPersistent&&(this.persistentCallbacksByApi.has(e)||this.persistentCallbacksByApi.set(e,new Set),this.persistentCallbacksByApi.get(e).add(d)),r.isPersistent||r.disableTimeout)P.info(`API ${e} 禁用超时清理,将等待回调返回后清理`,{callbackId:d,isPersistent:r.isPersistent,disableTimeout:r.disableTimeout});else{const H=setTimeout(()=>{P.warn("API 调用超时,自动清理回调",{api:e,callbackId:d}),i.fail&&i.fail({errMsg:`API ${e} 调用超时`,code:"TIMEOUT"}),this.cleanupCallback(d)},r.timeout||this.defaultTimeout);this.timeouts.set(d,H)}const _={type:"qsh_api_call",api:e,params:c.params,callbackId:d,timestamp:Date.now()};P.info("发送 API 调用消息",{api:e,callbackId:d,hasSuccess:!!i.success,hasFail:!!i.fail}),console.log("message:",JSON.stringify(jr(_),null,2)),Ie("postMessage",_)}}),{context:"WebViewBridge.callApi",api:e})})}handleCallback(e,r){return I(this,null,function*(){return l.safeExecute(()=>I(this,null,function*(){var O,_;const i=this.callbacks.get(e);if(!i){P.warn("未找到回调函数",{callbackId:e});return}const{success:n,fail:a,complete:o,context:c}=i;P.debug("处理回调",{callbackId:e,result:r});const d=yield ae.runResponse(r,c);c&&j.setApiResult(c.apiName,d),d.success&&n?n(d.data):!d.success&&a&&a(d.error||{errMsg:"操作失败"}),o&&o(d),((_=(O=i.context)==null?void 0:O.params)==null?void 0:_.isPersistent)?P.debug("持久监听API:保留回调",{callbackId:e}):(this.cleanupCallback(e),P.debug("回调执行完成,已清理",{callbackId:e}))}),{context:"WebViewBridge.handleCallback",callbackId:e})})}cleanupCallback(e){const r=this.timeouts.get(e);if(r&&(clearTimeout(r),this.timeouts.delete(e)),this.callbacks.delete(e),typeof window!="undefined"&&window.qshWebviewCallbacks&&delete window.qshWebviewCallbacks[e],this.persistentCallbacksByApi&&this.persistentCallbacksByApi.size>0){const i=[];this.persistentCallbacksByApi.forEach((n,a)=>{n.has(e)&&(n.delete(e),n.size===0&&i.push(a))}),i.forEach(n=>this.persistentCallbacksByApi.delete(n))}}clearCallbacks(){P.debug("清理所有回调",{count:this.callbacks.size}),this.timeouts.forEach(e=>clearTimeout(e)),this.timeouts.clear(),this.callbacks.clear(),this.persistentCallbacksByApi&&this.persistentCallbacksByApi.clear(),typeof window!="undefined"&&window.qshWebviewCallbacks&&Object.keys(window.qshWebviewCallbacks).forEach(e=>{e.startsWith("qsh_callback_")&&delete window.qshWebviewCallbacks[e]})}cleanupPersistentCallbacksByApi(e){const r=this.persistentCallbacksByApi.get(e);if(!r||r.size===0)return 0;const i=Array.from(r);return i.forEach(n=>this.cleanupCallback(n)),this.persistentCallbacksByApi.delete(e),P.info("已清理持久回调",{api:e,count:i.length}),i.length}getStatus(){return{isSupported:typeof window!="undefined"&&window.uni&&typeof window.uni.postMessage=="function",activeCallbacks:this.callbacks.size,globalCallbacksCount:typeof window!="undefined"&&window.qshWebviewCallbacks?Object.keys(window.qshWebviewCallbacks).length:0}}}const gt=new Hr,N=(t,e,r)=>gt.callApi(t,e,r),pe=t=>gt.cleanupPersistentCallbacksByApi(t);function ht(){return V(!0)}function zr(t){return t==="offline"}function Yr(t={}){return l.safeExecute(()=>{s.debug("Call getCode through offline webview bridge",{clientId:t.clientId}),N("getCode",{clientId:t.clientId},{success:e=>{var r;s.info("Get code success"),(r=t.success)==null||r.call(t,e)},fail:e=>{var r;s.error("Get code failed",e),(r=t.fail)==null||r.call(t,e)},complete:t.complete})},{context:"getCodeInHost",platform:ht().type})}function Xr(t={}){return l.safeExecute(()=>{var i,n;const e=ht(),r=String((t==null?void 0:t.clientId)||"").trim();if(!r){const a={errMsg:"clientId is required",code:"APP_KEY_MISSING"};s.error("Get code missing clientId"),(i=t.fail)==null||i.call(t,a);return}if(!zr(e.type)){const a={errMsg:`Current environment (${e.type}) does not support getCode`,code:"PLATFORM_NOT_SUPPORTED"};s.error("Platform does not support getCode",{platform:e.type}),(n=t.fail)==null||n.call(t,a);return}Yr(w(g({},t),{clientId:r}))},{context:"getCode",options:t})}function mt(){return V(!0)}const pt=["release","trial","develop"];function Zr(t={}){const e=String((t==null?void 0:t.appid)||"").trim(),r=(t==null?void 0:t.path)==null?"":t.path,i=t==null?void 0:t.env,n=i==null||i===""?void 0:String(i).trim();if(!e)throw{errMsg:"appid is required",code:"PARAM_MISSING"};if(typeof r!="string")throw{errMsg:"path must be a string",code:"PARAM_TYPE_ERROR"};if(n!==void 0&&!pt.includes(n))throw{errMsg:`env must be one of ${pt.join("/")}`,code:"PARAM_INVALID"};return w(g({},t),{appid:e,path:r.trim(),env:n})}function Qr(){return typeof window!="undefined"&&window.wx&&window.wx.miniProgram&&typeof window.wx.miniProgram.postMessage=="function"&&typeof window.wx.miniProgram.navigateBack=="function"}function ei(t={}){return l.safeExecute(()=>{var r;if(!Qr()){const i={errMsg:"wx.miniProgram.postMessage or wx.miniProgram.navigateBack is not available",code:"PLATFORM_NOT_SUPPORTED"};s.error("Weixin web-view relay APIs are not available"),(r=t.fail)==null||r.call(t,i);return}const e={type:"qsh_api_call",api:"navigateToMiniProgram",params:{appid:t.appid,path:t.path,env:t.env},timestamp:Date.now()};return s.debug("Relay navigateToMiniProgram through wx.miniProgram.postMessage",{appid:t.appid,path:t.path,env:t.env}),new Promise((i,n)=>{var a;try{window.wx.miniProgram.postMessage({data:e})}catch(o){s.error("Post navigateToMiniProgram message failed",o),(a=t.fail)==null||a.call(t,o),n(o);return}window.wx.miniProgram.navigateBack({delta:1,success:o=>{var d;const c=w(g({},o),{errMsg:(o==null?void 0:o.errMsg)||"navigateToMiniProgram:queued"});s.info("Navigate to mini program request queued in weixin web-view",{appid:t.appid,path:t.path,env:t.env}),(d=t.success)==null||d.call(t,c),i(c)},fail:o=>{var c;s.error("Navigate back after posting mini program message failed",o),(c=t.fail)==null||c.call(t,o),n(o)},complete:t.complete})})},{context:"navigateToMiniProgramInWeixin",platform:"weixin"})}function ti(t={}){return l.safeExecute(()=>(s.debug("Call navigateToMiniProgram through webview bridge",{appid:t.appid,path:t.path,env:t.env}),new Promise((e,r)=>{N("navigateToMiniProgram",{appid:t.appid,path:t.path,env:t.env},{success:i=>{var n;s.info("Navigate to mini program success"),(n=t.success)==null||n.call(t,i),e(i)},fail:i=>{var n;s.error("Navigate to mini program failed",i),(n=t.fail)==null||n.call(t,i),r(i)},complete:t.complete})})),{context:"navigateToMiniProgramInHost",platform:mt().type})}function ri(t={}){return l.safeExecute(()=>{var i;const e=mt();let r;try{r=Zr(t)}catch(n){s.error("Navigate to mini program params validation failed",n),(i=t.fail)==null||i.call(t,n);return}return s.info("Start navigateToMiniProgram",{platform:e.type,appid:r.appid,path:r.path,env:r.env}),e.isWeixinMiniProgram?ei(r):ti(r)},{context:"navigateToMiniProgram",options:t})}function wt(){return V(!0)}function ii(t={}){const e=String((t==null?void 0:t.url)||"").trim(),r=(t==null?void 0:t.showMenu)==null?!1:t.showMenu;if(!e)throw{errMsg:"url is required",code:"PARAM_MISSING"};if(typeof r!="boolean")throw{errMsg:"showMenu must be a boolean",code:"PARAM_TYPE_ERROR"};return w(g({},t),{url:e,showMenu:r})}function ni(){return typeof window!="undefined"&&window.wx&&window.wx.miniProgram&&typeof window.wx.miniProgram.postMessage=="function"&&typeof window.wx.miniProgram.navigateBack=="function"}function ai(t={}){return l.safeExecute(()=>{var r;if(!ni()){const i={errMsg:"wx.miniProgram.postMessage or wx.miniProgram.navigateBack is not available",code:"PLATFORM_NOT_SUPPORTED"};s.error("Weixin web-view relay APIs are not available"),(r=t.fail)==null||r.call(t,i);return}const e={type:"qsh_api_call",api:"filePreview",params:{url:t.url,showMenu:t.showMenu},timestamp:Date.now()};return s.debug("Relay filePreview through wx.miniProgram.postMessage",{url:t.url,showMenu:t.showMenu}),new Promise((i,n)=>{var a;try{window.wx.miniProgram.postMessage({data:e})}catch(o){s.error("Post filePreview message failed",o),(a=t.fail)==null||a.call(t,o),n(o);return}window.wx.miniProgram.navigateBack({delta:1,success:o=>{var d;const c=w(g({},o),{errMsg:(o==null?void 0:o.errMsg)||"filePreview:queued"});s.info("File preview request queued in weixin web-view",{url:t.url,showMenu:t.showMenu}),(d=t.success)==null||d.call(t,c),i(c)},fail:o=>{var c;s.error("Navigate back after posting filePreview message failed",o),(c=t.fail)==null||c.call(t,o),n(o)},complete:t.complete})})},{context:"filePreviewInWeixin",platform:"weixin"})}function si(t={}){return l.safeExecute(()=>(s.debug("Call filePreview through webview bridge",{url:t.url,showMenu:t.showMenu}),new Promise((e,r)=>{N("filePreview",{url:t.url,showMenu:t.showMenu},{success:i=>{var n;s.info("File preview success"),(n=t.success)==null||n.call(t,i),e(i)},fail:i=>{var n;s.error("File preview failed",i),(n=t.fail)==null||n.call(t,i),r(i)},complete:t.complete})})),{context:"filePreviewInHost",platform:wt().type})}function oi(t={}){return l.safeExecute(()=>{var i;const e=wt();let r;try{r=ii(t)}catch(n){s.error("File preview params validation failed",n),(i=t.fail)==null||i.call(t,n);return}return s.info("Start filePreview",{platform:e.type,url:r.url,showMenu:r.showMenu}),e.isWeixinMiniProgram?ai(r):si(r)},{context:"filePreview",options:t})}function ci(t=""){return/^https?:\/\//i.test(String(t||"").trim())}function ui(t){if(t==null||t==="")return!1;if(typeof t=="boolean")return t;const e=String(t).trim().toLowerCase();return e==="true"||e==="1"}function li(){return typeof window!="undefined"&&window.wx&&window.wx.miniProgram&&typeof window.wx.miniProgram.postMessage=="function"&&typeof window.wx.miniProgram.navigateBack=="function"}function fi(t={}){if(!t||typeof t!="object")throw{errMsg:"manualShare options must be an object",code:"PARAM_TYPE_ERROR"};const e=String(t.title||"").trim(),r=String(t.h5Url||"").trim(),i=String(t.clientId||"").trim(),n=ui(t.isPublic),a=String(t.imageUrl||"").trim(),o=String(t.description||t.desc||"").trim();if(!e)throw{errMsg:"manualShare: title is required",code:"PARAM_MISSING"};if(!r)throw{errMsg:"manualShare: h5Url is required",code:"PARAM_MISSING"};if(!i)throw{errMsg:"manualShare: clientId is required",code:"PARAM_MISSING"};if(r&&!ci(r))throw{errMsg:"manualShare: h5Url must be a valid http(s) url",code:"PARAM_INVALID"};return{title:e,h5Url:r,clientId:i,isPublic:n,imageUrl:a,description:o,success:t.success,fail:t.fail,complete:t.complete}}function di(t){return{type:"qsh_api_call",api:"manualShare",params:{title:t.title,h5Url:t.h5Url,clientId:t.clientId,isPublic:t.isPublic,imageUrl:t.imageUrl,description:t.description},timestamp:Date.now()}}function gi(t){return new Promise((e,r)=>{const i=di(t);s.debug("Relay manualShare through wx.miniProgram.postMessage",i);try{window.wx.miniProgram.postMessage({data:i})}catch(n){s.error("Post manualShare message failed",n),r(n);return}window.wx.miniProgram.navigateBack({delta:1,success:n=>{const a=w(g({},n||{}),{success:!0,errMsg:(n==null?void 0:n.errMsg)||"manualShare:queued"});s.info("manualShare request queued in weixin web-view",{h5Url:t.h5Url,clientId:t.clientId,isPublic:t.isPublic}),e(a)},fail:n=>{s.error("Navigate back after posting manualShare message failed",n),r(n)}})})}function Et(t={}){return l.safeExecute(()=>{var i,n,a,o,c,d;const e=V(!0);let r;try{r=fi(t)}catch(m){return(i=t.fail)==null||i.call(t,m),(n=t.complete)==null||n.call(t,m),Promise.reject(m)}if(!e.isWeixinMiniProgram){const m={errMsg:"manualShare only supports Weixin mini-program web-view environment",code:"ENV_NOT_SUPPORTED"};return(a=r.fail)==null||a.call(r,m),(o=r.complete)==null||o.call(r,m),Promise.reject(m)}if(!li()){const m={errMsg:"wx.miniProgram.postMessage or wx.miniProgram.navigateBack is not available",code:"PLATFORM_NOT_SUPPORTED"};return(c=r.fail)==null||c.call(r,m),(d=r.complete)==null||d.call(r,m),Promise.reject(m)}return gi(r).then(m=>{var O,_;return(O=r.success)==null||O.call(r,m),(_=r.complete)==null||_.call(r,m),m}).catch(m=>{var O,_;return(O=r.fail)==null||O.call(r,m),(_=r.complete)==null||_.call(r,m),Promise.reject(m)})},{context:"manualShare",options:t})}function hi(t={}){return new Promise((e,r)=>{Et(w(g({},t),{success:e,fail:r}))})}const Ne={ALBUM:"album",CAMERA:"camera"},be={ORIGINAL:"original",COMPRESSED:"compressed"},mi={count:9,sizeType:[be.ORIGINAL,be.COMPRESSED],sourceType:[Ne.ALBUM,Ne.CAMERA]};function pi(t={}){const e=g(g({},mi),t);return Array.isArray(e.sizeType)||(e.sizeType=[e.sizeType].filter(Boolean)),Array.isArray(e.sourceType)||(e.sourceType=[e.sourceType].filter(Boolean)),e.count=Math.max(1,Math.min(9,parseInt(e.count)||1)),e.sizeType.length===0&&(e.sizeType=[be.COMPRESSED]),e.sourceType.length===0&&(e.sourceType=[Ne.ALBUM]),e}function yt(){return["weixin","webview","UniApp","plus","nvue","uvue","offline"].includes(f.type)}function At(t){return l.safeExecute(()=>{var e;if(!window.wx){const r={errMsg:"微信JS-SDK未加载",code:"WEIXIN_SDK_NOT_LOADED"};(e=t.fail)==null||e.call(t,r);return}if(!he()){s.info("等待微信配置完成"),ne().then(()=>At(t)).catch(r=>{var i;s.error("微信配置失败",r),(i=t.fail)==null||i.call(t,{errMsg:`微信配置失败: ${r.message}`})});return}s.debug("调用微信图片选择",t),window.wx.chooseImage({count:t.count,sizeType:t.sizeType,sourceType:t.sourceType,success:r=>{var i,n;s.info("微信图片选择成功",{count:((i=r.localIds)==null?void 0:i.length)||0}),(n=t.success)==null||n.call(t,r)},fail:r=>{var i;s.error("微信图片选择失败",r),(i=t.fail)==null||i.call(t,r)},complete:t.complete})},{context:"chooseImageInWeixin",platform:"weixin"})}function wi(t){return l.safeExecute(()=>{s.debug("通过 WebView 桥接调用图片选择",t),N("chooseImage",w(g({},t),{disableTimeout:!0}),{success:e=>{var r,i;s.info("UniApp 图片选择成功",{count:((r=e==null?void 0:e.tempFilePaths)==null?void 0:r.length)||0}),(i=t.success)==null||i.call(t,e)},fail:e=>{var r;s.error("UniApp 图片选择失败",e),(r=t.fail)==null||r.call(t,e)},complete:t.complete})},{context:"chooseImageInUniApp",platform:"uniapp"})}function Ei(t={}){return l.safeExecute(()=>{var r;if(!yt()){const i={errMsg:`当前环境 (${f.type}) 不支持图片选择功能`,code:"PLATFORM_NOT_SUPPORTED"};s.error("平台不支持图片选择",{platform:f.type}),(r=t.fail)==null||r.call(t,i);return}const e=pi(t);s.info("开始选择图片",{platform:f.type,count:e.count,sizeType:e.sizeType,sourceType:e.sourceType}),p()?At(e):wi(e)},{context:"chooseImage",options:t})}function yi(){return{supported:yt(),environment:f.type,implementation:p()?"weixin":"webview",features:{multipleSelection:!0,sizeTypeSelection:!0,sourceTypeSelection:!0,asyncSupport:!0}}}const ce={QR_CODE:"qrCode",BAR_CODE:"barCode",DATA_MATRIX:"datamatrix",PDF417:"pdf417"},Ai={onlyFromCamera:!0,scanType:[ce.QR_CODE,ce.BAR_CODE]};function Ii(t={}){const e=g(g({},Ai),t);return Array.isArray(e.scanType)||(e.scanType=[e.scanType].filter(Boolean)),e.scanType.length===0&&(e.scanType=[ce.QR_CODE,ce.BAR_CODE]),e.onlyFromCamera=!!e.onlyFromCamera,e}function It(){return["weixin","webview","UniApp","plus","nvue","uvue","offline"].includes(f.type)}function Pt(t){return l.safeExecute(()=>{var e;if(!window.wx){const r={errMsg:"微信JS-SDK未加载",code:"WEIXIN_SDK_NOT_LOADED"};(e=t.fail)==null||e.call(t,r);return}if(!he()){s.info("等待微信配置完成"),ne().then(()=>Pt(t)).catch(r=>{var i;s.error("微信配置失败",r),(i=t.fail)==null||i.call(t,{errMsg:`微信配置失败: ${r.message}`})});return}s.debug("调用微信扫码",t),window.wx.scanQRCode({needResult:1,scanType:t.scanType,success:r=>{var n;s.info("微信扫码成功",{result:r.resultStr});const i={result:r.resultStr,scanType:Pi(r.resultStr),charSet:"utf-8",errMsg:"scanCode:ok"};(n=t.success)==null||n.call(t,i)},fail:r=>{var i;s.error("微信扫码失败",r),(i=t.fail)==null||i.call(t,r)},complete:t.complete})},{context:"scanCodeInWeixin",platform:"weixin"})}function Pi(t){return t?t.length>50||/[^\d]/.test(t)?ce.QR_CODE:ce.BAR_CODE:"unknown"}function Mi(t){return l.safeExecute(()=>{s.debug("通过 WebView 桥接调用扫码",t),N("scanCode",w(g({},t),{disableTimeout:!0}),{success:e=>{var r;s.info("UniApp 扫码成功",{result:e==null?void 0:e.result,scanType:e==null?void 0:e.scanType}),(r=t.success)==null||r.call(t,e)},fail:e=>{var r;s.error("UniApp 扫码失败",e),(r=t.fail)==null||r.call(t,e)},complete:t.complete})},{context:"scanCodeInUniApp",platform:"uniapp"})}function Ci(t={}){return l.safeExecute(()=>{var r;if(!It()){const i={errMsg:`当前环境 (${f.type}) 不支持扫码功能`,code:"PLATFORM_NOT_SUPPORTED"};s.error("平台不支持扫码",{platform:f.type}),(r=t.fail)==null||r.call(t,i);return}const e=Ii(t);s.info("开始扫码",{platform:f.type,onlyFromCamera:e.onlyFromCamera,scanType:e.scanType}),p()?Pt(e):Mi(e)},{context:"scanCode",options:t})}function _i(){return{supported:It(),environment:f.type,implementation:p()?"weixin":"webview",features:{onlyFromCamera:!0,scanTypeSelection:!0,multipleTypes:!0,asyncSupport:!0}}}const T=3.141592653589793,ve=6378245,Te=.006693421622965943;function Mt(t,e){t=+t,e=+e;let r=-100+2*t+3*e+.2*e*e+.1*t*e+.2*Math.sqrt(Math.abs(t));return r+=(20*Math.sin(6*t*T)+20*Math.sin(2*t*T))*2/3,r+=(20*Math.sin(e*T)+40*Math.sin(e/3*T))*2/3,r+=(160*Math.sin(e/12*T)+320*Math.sin(e*T/30))*2/3,r}function Ct(t,e){t=+t,e=+e;let r=300+t+2*e+.1*t*t+.1*t*e+.1*Math.sqrt(Math.abs(t));return r+=(20*Math.sin(6*t*T)+20*Math.sin(2*t*T))*2/3,r+=(20*Math.sin(t*T)+40*Math.sin(t/3*T))*2/3,r+=(150*Math.sin(t/12*T)+300*Math.sin(t/30*T))*2/3,r}function _t(t,e){return t=+t,e=+e,!(t>73.66&&t<135.05&&e>3.86&&e<53.55)}function Ri(t,e){if(t=+t,e=+e,_t(t,e))return[t,e];let r=Mt(t-105,e-35),i=Ct(t-105,e-35);const n=e/180*T;let a=Math.sin(n);a=1-Te*a*a;const o=Math.sqrt(a);r=r*180/(ve*(1-Te)/(a*o)*T),i=i*180/(ve/o*Math.cos(n)*T);const c=e+r;return[t+i,c]}function Oi(t,e){if(t=+t,e=+e,_t(t,e))return[t,e];let r=Mt(t-105,e-35),i=Ct(t-105,e-35);const n=e/180*T;let a=Math.sin(n);a=1-Te*a*a;const o=Math.sqrt(a);r=r*180/(ve*(1-Te)/(a*o)*T),i=i*180/(ve/o*Math.cos(n)*T);const c=e+r,d=t+i;return[t*2-d,e*2-c]}const U={WGS84:"wgs84",GCJ02:"gcj02",BD09:"bd09"},Si={type:U.WGS84,altitude:!1},Ni={type:U.WGS84,scale:12},bi=[U.WGS84,U.GCJ02];function vi(t={}){const e=g(g({},Si),t);return Object.values(U).includes(e.type)||(e.type=U.WGS84),e.altitude=!!e.altitude,e}function Ti(t={}){const e=g({},t);return Object.values(U).includes(e.type)||(e.type=U.WGS84),e.needFullAccuracy=!!e.needFullAccuracy,e}function xi(t={}){const e=g(g({},Ni),t);if(bi.includes(e.type)||(e.type=U.WGS84),e.latitude===void 0||e.latitude===null)throw{errMsg:"缺少必需参数:latitude(纬度)",code:"PARAM_MISSING"};if(typeof e.latitude!="number")throw{errMsg:`latitude 参数类型错误:期望 number,实际 ${typeof e.latitude}`,code:"PARAM_TYPE_ERROR",details:{param:"latitude",expected:"number",actual:typeof e.latitude,value:e.latitude}};if(e.latitude<-90||e.latitude>90)throw{errMsg:`latitude 超出范围:有效范围 -90 ~ 90,实际值 ${e.latitude}`,code:"PARAM_INVALID",details:{param:"latitude",value:e.latitude,validRange:"-90 ~ 90"}};if(e.longitude===void 0||e.longitude===null)throw{errMsg:"缺少必需参数:longitude(经度)",code:"PARAM_MISSING"};if(typeof e.longitude!="number")throw{errMsg:`longitude 参数类型错误:期望 number,实际 ${typeof e.longitude}`,code:"PARAM_TYPE_ERROR",details:{param:"longitude",expected:"number",actual:typeof e.longitude,value:e.longitude}};if(e.longitude<-180||e.longitude>180)throw{errMsg:`longitude 超出范围:有效范围 -180 ~ 180,实际值 ${e.longitude}`,code:"PARAM_INVALID",details:{param:"longitude",value:e.longitude,validRange:"-180 ~ 180"}};if(e.scale!==void 0&&e.scale!==null){const r=Number(e.scale);isNaN(r)?(s.warn("scale 参数无效,使用默认值 12",{scale:e.scale}),e.scale=12):e.scale=Math.max(1,Math.min(28,Math.floor(r)))}return e}function Li(t){if(t.type!==U.WGS84)return t;const[e,r]=Ri(t.longitude,t.latitude);return w(g({},t),{latitude:r,longitude:e,type:U.GCJ02})}function Di(t){if(t.type!==U.GCJ02)return t;const[e,r]=Oi(t.longitude,t.latitude);return w(g({},t),{latitude:r,longitude:e,type:U.WGS84})}function ke(){return["weixin","webview","UniApp","plus","nvue","uvue","offline"].includes(f.type)}function Rt(t){return l.safeExecute(()=>{var e;if(!window.wx){const r={errMsg:"微信JS-SDK未加载",code:"WEIXIN_SDK_NOT_LOADED"};(e=t.fail)==null||e.call(t,r);return}if(!he()){s.info("等待微信配置完成"),ne().then(()=>Rt(t)).catch(r=>{var i;s.error("微信配置失败",r),(i=t.fail)==null||i.call(t,{errMsg:`微信配置失败: ${r.message}`})});return}s.debug("调用微信定位",t),window.wx.getLocation({type:t.type,success:r=>{var i;s.info("微信定位成功",{latitude:r.latitude,longitude:r.longitude}),(i=t.success)==null||i.call(t,r)},fail:r=>{var i;s.error("微信定位失败",r),(i=t.fail)==null||i.call(t,r)},complete:t.complete})},{context:"getLocationInWeixin",platform:"weixin"})}function Ot(t){return l.safeExecute(()=>{var r;if(!window.wx){const i={errMsg:"微信JS-SDK未加载",code:"WEIXIN_SDK_NOT_LOADED"};(r=t.fail)==null||r.call(t,i);return}if(!he()){s.info("等待微信配置完成"),ne().then(()=>Ot(t)).catch(i=>{var n;s.error("微信配置失败",i),(n=t.fail)==null||n.call(t,{errMsg:`微信配置失败: ${i.message}`})});return}const e=Li(t);s.debug("调用微信查看位置",e),window.wx.openLocation({latitude:e.latitude,longitude:e.longitude,name:e.name||"",address:e.address||"",scale:e.scale||12,infoUrl:e.infoUrl||"",success:i=>{var n;s.info("微信查看位置成功"),(n=t.success)==null||n.call(t,i)},fail:i=>{var n;s.error("微信查看位置失败",i),(n=t.fail)==null||n.call(t,i)},complete:t.complete})},{context:"openLocationInWeixin",platform:"weixin"})}function Ui(t){return l.safeExecute(()=>{s.debug("通过 WebView 桥接调用获取位置",t),N("getLocation",t,{success:e=>{var r;s.info("UniApp 获取位置成功",{latitude:e==null?void 0:e.latitude,longitude:e==null?void 0:e.longitude}),(r=t.success)==null||r.call(t,e)},fail:e=>{var r;s.error("UniApp 获取位置失败",e),(r=t.fail)==null||r.call(t,e)},complete:t.complete})},{context:"getLocationInUniApp",platform:"uniapp"})}function Wi(t){return l.safeExecute(()=>{const e=Di(t);s.debug("通过 WebView 桥接调用查看位置",e),N("openLocation",e,{success:r=>{var i;s.info("UniApp 查看位置成功"),(i=t.success)==null||i.call(t,r)},fail:r=>{var i;s.error("UniApp 查看位置失败",r),(i=t.fail)==null||i.call(t,r)},complete:t.complete})},{context:"openLocationInUniApp",platform:"uniapp"})}function $i(t={}){return l.safeExecute(()=>{var r;if(!ke()){const i={errMsg:`当前环境 (${f.type}) 不支持定位功能`,code:"PLATFORM_NOT_SUPPORTED"};s.error("平台不支持定位",{platform:f.type}),(r=t.fail)==null||r.call(t,i);return}const e=vi(t);s.info("开始获取位置",{platform:f.type,type:e.type,altitude:e.altitude}),p()?Rt(e):Ui(e)},{context:"getLocation",options:t})}function Fi(t={}){return l.safeExecute(()=>{var r,i,n;if(!ke()){const a={errMsg:`当前环境 (${f.type}) 不支持查看位置功能`,code:"PLATFORM_NOT_SUPPORTED"};s.error("平台不支持查看位置",{platform:f.type}),(r=t.fail)==null||r.call(t,a);return}let e;try{e=xi(t)}catch(a){s.error("参数验证失败",a),(i=t.fail)==null||i.call(t,a),(n=t.complete)==null||n.call(t);return}s.info("开始查看位置",{platform:f.type,type:e.type,latitude:e.latitude,longitude:e.longitude,name:e.name}),p()?Ot(e):Wi(e)},{context:"openLocation",options:t})}function ki(){const t=p();return{supported:ke(),environment:f.type,implementation:t?"weixin":"webview",features:{getLocation:!0,openLocation:!0,coordinateTypes:!0,altitudeSupport:!0,asyncSupport:!0,onLocationChange:!t}}}const Q=new Set,ee=new Set;function St(t,e,r){t.forEach(i=>{if(typeof i=="function"){l.safeExecute(()=>i(e),{context:r});return}s.warn("监听回调不是函数,已跳过",{type:typeof i})})}function Bi(t={}){return l.safeExecute(()=>{var r,i;if(p()){const n={errMsg:`当前环境 (${f.type}) 不支持该接口`,code:"PLATFORM_NOT_SUPPORTED"};s.error("当前环境不支持此接口",{platform:f.type}),(r=t.fail)==null||r.call(t,n),(i=t.complete)==null||i.call(t,n);return}const e=Ti(t);s.info("正在开启定位监听"),N("startLocationUpdate",{type:e.type,needFullAccuracy:e.needFullAccuracy},{success:n=>{var a;s.info("定位监听已启动"),(a=t.success)==null||a.call(t,n)},fail:n=>{var a;return(a=t.fail)==null?void 0:a.call(t,n)},complete:t.complete})},{context:"startLocationUpdate"})}function Gi(t={}){return l.safeExecute(()=>{var e,r;if(p()){const i={errMsg:`当前环境 (${f.type}) 不支持该接口`,code:"PLATFORM_NOT_SUPPORTED"};s.error("当前环境不支持此接口",{platform:f.type}),(e=t.fail)==null||e.call(t,i),(r=t.complete)==null||r.call(t,i);return}s.info("正在停止定位监听"),N("stopLocationUpdate",t,{success:i=>{var n;s.info("定位监听已停止"),(n=t.success)==null||n.call(t,i)},fail:i=>{var n;return(n=t.fail)==null?void 0:n.call(t,i)},complete:t.complete})},{context:"stopLocationUpdate"})}function Ki(t){return l.safeExecute(()=>{if(p()){s.warn("当前环境不支持此接口",{platform:f.type});return}if(typeof t!="function")throw s.error("onLocationChange 回调不是函数",{type:typeof t}),{errMsg:"onLocationChange 回调必须是函数",code:"INVALID_CALLBACK"};const e=Q.size>0;Q.add(t),e||(s.debug("注册实时位置变化监听器"),N("onLocationChange",{isPersistent:!0},{success:r=>{s.debug("收到实时位置推送",r),St(Q,r,"onLocationChange")},fail:r=>{s.warn("位置变化监听出错,请通过 onLocationChangeError 监听错误",r),Q.delete(t),Q.size===0&&pe("onLocationChange")}}))},{context:"onLocationChange"})}function Vi(t){return l.safeExecute(()=>{if(p()){s.warn("当前环境不支持此接口",{platform:f.type});return}if(t&&typeof t!="function")throw s.error("offLocationChange 回调不是函数",{type:typeof t}),{errMsg:"offLocationChange 回调必须是函数",code:"INVALID_CALLBACK"};t?Q.delete(t):Q.clear(),!(Q.size>0)&&(s.info("移除位置变化监听器"),N("offLocationChange",{},{success:()=>{s.info("位置变化监听已移除"),pe("onLocationChange")},fail:e=>{s.error("移除位置变化监听失败",e),pe("onLocationChange")}}))},{context:"offLocationChange"})}function qi(t){return l.safeExecute(()=>{if(p()){s.warn("当前环境不支持此接口",{platform:f.type});return}if(typeof t!="function")throw s.error("onLocationChangeError 回调不是函数",{type:typeof t}),{errMsg:"onLocationChangeError 回调必须是函数",code:"INVALID_CALLBACK"};const e=ee.size>0;ee.add(t),e||(s.debug("注册位置更新错误监听器"),N("onLocationChangeError",{isPersistent:!0},{success:r=>{s.warn("持续定位发生异常",r),St(ee,r,"onLocationChangeError")},fail:r=>{s.warn("位置更新错误监听注册失败",r),ee.delete(t),ee.size===0&&pe("onLocationChangeError")}}))},{context:"onLocationChangeError"})}function ji(t){return l.safeExecute(()=>{if(p()){s.warn("当前环境不支持此接口",{platform:f.type});return}if(t&&typeof t!="function")throw s.error("offLocationChangeError 回调不是函数",{type:typeof t}),{errMsg:"offLocationChangeError 回调必须是函数",code:"INVALID_CALLBACK"};t?ee.delete(t):ee.clear(),!(ee.size>0)&&(s.info("移除定位错误监听器"),N("offLocationChangeError",{},{success:()=>{s.info("定位错误监听已移除"),pe("onLocationChangeError")},fail:e=>{s.error("移除定位错误监听失败",e),pe("onLocationChangeError")}}))},{context:"offLocationChangeError"})}const Ji={latitude:null,longitude:null};function Hi(t={}){const e=g(g({},Ji),t);return e.latitude!==null&&e.latitude!==void 0&&(typeof e.latitude!="number"?(s.warn("latitude 参数类型错误,已忽略",{latitude:e.latitude}),e.latitude=null):(e.latitude<-90||e.latitude>90)&&(s.warn("latitude 超出范围,已忽略",{latitude:e.latitude}),e.latitude=null)),e.longitude!==null&&e.longitude!==void 0&&(typeof e.longitude!="number"?(s.warn("longitude 参数类型错误,已忽略",{longitude:e.longitude}),e.longitude=null):(e.longitude<-180||e.longitude>180)&&(s.warn("longitude 超出范围,已忽略",{longitude:e.longitude}),e.longitude=null)),e}function Nt(){return["webview","UniApp","plus","nvue","uvue","offline"].includes(f.type)}function zi(t){return l.safeExecute(()=>{s.debug("通过 WebView 桥接调用位置选择",t);const e={disableTimeout:!0,success:r=>{var i;s.info("UniApp 位置选择成功",{name:r==null?void 0:r.name,address:r==null?void 0:r.address,latitude:r==null?void 0:r.latitude,longitude:r==null?void 0:r.longitude}),(i=t.success)==null||i.call(t,r)},fail:r=>{var i;s.error("UniApp 位置选择失败",r),(i=t.fail)==null||i.call(t,r)},complete:t.complete};t.latitude!==null&&t.latitude!==void 0&&(e.latitude=t.latitude),t.longitude!==null&&t.longitude!==void 0&&(e.longitude=t.longitude),N("chooseLocation",e,{success:r=>{e.success(r)},fail:r=>{e.fail(r)},complete:e.complete})},{context:"chooseLocationInUniApp",platform:"uniapp"})}function Yi(t={}){return l.safeExecute(()=>{var r;if(!Nt()){const i={errMsg:`当前环境 (${f.type}) 不支持位置选择功能`,code:"PLATFORM_NOT_SUPPORTED"};s.error("平台不支持位置选择",{platform:f.type}),(r=t.fail)==null||r.call(t,i);return}const e=Hi(t);s.info("开始选择位置",{platform:f.type,latitude:e.latitude,longitude:e.longitude}),p()||zi(e)},{context:"chooseLocation",options:t})}function Xi(){return{supported:Nt(),environment:f.type,implementation:p()?"weixin":"webview",features:{chooseLocation:!0,centerPoint:!0,asyncSupport:!0}}}const bt="https://iafs.xjy2.cn/img/bg.143351f0.jpg";function Zi(t){return t==="timeline"||Number(t)===1?1:0}function xe(t="",e="targetPath"){if(!t||typeof t!="string")throw{errMsg:`share: ${e} 必须是最终小程序页面路径`,code:"PARAM_INVALID"};const r=t.trim(),[,i=""]=r.split("?");return{path:r,query:i}}function vt(t="",e="webTarget"){if(!t||typeof t!="string")throw{errMsg:`share: ${e} 必须是公网链接,例如 https://example.com/path?a=1`,code:"PARAM_INVALID"};const r=t.trim();if(!/^https?:\/\//.test(r))throw{errMsg:`share: ${e} 必须是公网链接,例如 https://example.com/path?a=1`,code:"PARAM_INVALID"};return r}function Qi(){return new Promise((t,e)=>{var a,o;const r=typeof window!="undefined"?window:null;if(!r)return e({errMsg:"当前环境不支持 plus",code:"PLUS_UNAVAILABLE"});if(r.plus)return t(r.plus);const i=setTimeout(()=>{var c,d;(d=(c=r.document)==null?void 0:c.removeEventListener)==null||d.call(c,"plusready",n),e({errMsg:"等待 plusready 超时",code:"PLUS_READY_TIMEOUT"})},8e3);function n(){clearTimeout(i),t(r.plus)}(o=(a=r.document)==null?void 0:a.addEventListener)==null||o.call(a,"plusready",n,{once:!0})})}function en(){return new Promise((t,e)=>{const r=typeof window!="undefined"?window.plus:null;if(!r||!r.share||typeof r.share.getServices!="function")return e({errMsg:"当前环境不支持 plus.share",code:"PLUS_SHARE_UNSUPPORTED"});r.share.getServices(i=>{const n=i.find(a=>a.id==="weixin");if(!n)return e({errMsg:"未找到微信分享服务",code:"WEIXIN_SERVICE_NOT_FOUND"});t(n)},i=>e(i||{errMsg:"获取分享服务失败",code:"GET_SHARE_SERVICES_FAILED"}))})}function tn(t){return t.isWeixinMiniProgram?"已同步分享内容,请点击右上角“···”选择发送给朋友或分享到朋友圈。":"正在拉起微信分享面板,请选择聊天框或朋友圈。"}function rn(t={}){if(!t||typeof t!="object")throw{errMsg:"shareDirected 参数必须是对象",code:"PARAM_TYPE_ERROR"};const e=String(t.kind||"").trim(),r=t.payload||{},i=Zi(t.scene);if(!["web","image","text"].includes(e))throw{errMsg:'shareDirected: kind 仅支持 "web"|"image"|"text"',code:"PARAM_INVALID"};if(![0,1].includes(i))throw{errMsg:"shareDirected: scene 仅支持 0|1",code:"PARAM_INVALID"};if(e==="web"&&(!r.title||!r.description||!r.imageUrl))throw{errMsg:"shareDirected(web): title/description/imageUrl 必填",code:"PARAM_MISSING"};if(e==="image"&&!r.imageUrl)throw{errMsg:"shareDirected(image): payload.imageUrl 必填",code:"PARAM_MISSING"};if(e==="text"&&!r.description)throw{errMsg:"shareDirected(text): payload.description 必填",code:"PARAM_MISSING"};return{kind:e,scene:i,payload:r,resolvedTargetPath:"",resolvedWebTarget:"",success:t.success,fail:t.fail,complete:t.complete}}function nn(t,e){const{payload:r}=t;if(e.isWeixinMiniProgram)try{const i=xe(r.target,"target");return t.resolvedTargetPath=i.path,t}catch(i){throw{errMsg:(i==null?void 0:i.errMsg)||"shareDirected: 小程序环境下 payload.target 不合法",code:(i==null?void 0:i.code)||"PARAM_INVALID"}}if(e.isAppPlus){const i=(o,c)=>{try{return vt(o,c)}catch(d){return""}},n=i(r.target,"target");if(n)return t.resolvedWebTarget=n,t;const a=i(r.webTarget,"webTarget");if(a)return t.resolvedWebTarget=a,t;throw{errMsg:"shareDirected: App 环境下 payload.target 必须是公网链接;若 target 不存在或不合法,则 payload.webTarget 也必须是公网链接",code:"PARAM_INVALID"}}return t}function an(t){const{kind:e,payload:r,resolvedTargetPath:i}=t,n=xe(i||r.target,"target"),a=r.imageUrl||bt;return{title:r.title||"分享",path:n.path,query:n.query,imageUrl:a,custom:{kind:e,target:n.path,webTarget:r.webTarget||"",description:r.description||""}}}function sn(t){const{kind:e,scene:r,payload:i,resolvedWebTarget:n}=t,a=r===1?"WXSceneTimeline":"WXSceneSession",o=i.imageUrl||bt;return e==="image"?{message:{type:"image",pictures:[i.imageUrl],extra:{scene:a}},degradedFromText:!1}:{message:{type:"web",title:i.title||"分享",content:i.description||"",href:n,thumbs:[o],extra:{scene:a}},degradedFromText:e==="text"}}function on(t){return I(this,null,function*(){yield Qi();const e=yield en(),{message:r,degradedFromText:i}=sn(t);return new Promise((n,a)=>{e.send(r,()=>n({success:!0,data:{degradedFromText:i,hint:i?"纯文字已自动降级为图文分享,避免微信通道不支持纯文本":void 0}}),o=>a(o||{errMsg:"微信分享失败",code:"WEIXIN_SHARE_FAILED"}))})})}function Tt(t,e="share"){const r=typeof window!="undefined"&&window.wx&&window.wx.miniProgram;if(!r||typeof r.postMessage!="function")throw{errMsg:`当前微信小程序容器未注入 postMessage 能力,无法发起 ${e}`,code:"MINIPROGRAM_BRIDGE_UNAVAILABLE"};r.postMessage({data:t})}function cn(t,e){return{type:"qsh_api_call",api:"shareDirected",params:{miniProgramShare:an(t),rowCustom:e},timestamp:Date.now()}}function un(t={}){if(!t||typeof t!="object")throw{errMsg:"shareMiniProgramCard 参数必须是对象",code:"PARAM_TYPE_ERROR"};const e=t.payload||{};if(!e.title)throw{errMsg:"shareMiniProgramCard: payload.title 必填",code:"PARAM_MISSING"};if(!e.imageUrl)throw{errMsg:"shareMiniProgramCard: payload.imageUrl 必填",code:"PARAM_MISSING"};if(!e.targetPath)throw{errMsg:"shareMiniProgramCard: payload.targetPath 必填",code:"PARAM_MISSING"};return xe(e.targetPath,"targetPath"),{payload:e,success:t.success,fail:t.fail,complete:t.complete}}function ln(t){switch(String(t||"release").trim().toLowerCase()){case"develop":case"development":case"test":return"test";case"trial":case"preview":case"experience":return"preview";case"release":case"formal":case"production":return"release";default:throw{errMsg:'shareMiniProgramCard: payload.envVersion 仅支持 "develop"|"trial"|"release"',code:"PARAM_INVALID"}}}function fn(t){switch(String(t||"release").trim().toLowerCase()){case"develop":case"development":case"test":return 1;case"trial":case"preview":case"experience":return 2;case"release":case"formal":case"production":return 0;default:throw{errMsg:'shareMiniProgramCard: payload.envVersion 仅支持 "develop"|"trial"|"release"',code:"PARAM_INVALID"}}}function dn(t){const{payload:e}=t;if(!e.appid)throw{errMsg:"shareMiniProgramCard: App 环境下 payload.appid 必填",code:"PARAM_MISSING"};try{vt(e.webUrl,"webUrl")}catch(r){throw{errMsg:"shareMiniProgramCard: App 环境下 payload.webUrl 必填,且必须是公网链接",code:(r==null?void 0:r.code)||"PARAM_INVALID"}}return ln(e.envVersion),t}function gn(t){const{payload:e}=t,r=xe(e.targetPath,"targetPath");return{title:e.title,path:r.path,query:r.query,imageUrl:e.imageUrl}}function hn(t){const{payload:e}=t;return{provider:"weixin",scene:"WXSceneSession",type:5,title:e.title,imageUrl:e.imageUrl,miniProgram:{id:e.appid,path:e.targetPath,type:fn(e.envVersion),webUrl:e.webUrl}}}function mn(t,e){return{type:"qsh_api_call",api:"shareMiniProgramCard",params:{miniProgramShare:gn(t),rowCustom:e},timestamp:Date.now()}}function pn(t){return I(this,null,function*(){return new Promise((e,r)=>{N("shareMiniProgramCard",{appShare:hn(t)},{success:i=>e(i||{}),fail:i=>r(i)})})})}function xt(t={}){return l.safeExecute(()=>{var a,o,c,d,m,O,_,H,Ce,S,z;let e;try{e=rn(t)}catch(A){return(a=t.fail)==null||a.call(t,A),Promise.reject(A)}const r=V(!0);try{e=nn(e,r)}catch(A){return(o=e.fail)==null||o.call(e,A),(c=e.complete)==null||c.call(e,A),Promise.reject(A)}const i=tn(r);if(r.isAppPlus)return on(e).then(A=>{var _e,er;const Y=w(g({},(A==null?void 0:A.data)||{}),{hint:i});return(_e=e.success)==null||_e.call(e,Y),(er=e.complete)==null||er.call(e,Y),Y}).catch(A=>{var Y,_e;return(Y=e.fail)==null||Y.call(e,A),(_e=e.complete)==null||_e.call(e,A),Promise.reject(A)});if(r.isWeixinMiniProgram)try{Tt(cn(e,t.rowCustom),"shareDirected");const A={success:!0,hint:i};return(d=e.success)==null||d.call(e,A),(m=e.complete)==null||m.call(e,A),Promise.resolve(A)}catch(A){return(O=e.fail)==null||O.call(e,A),(_=e.complete)==null||_.call(e,A),Promise.reject(A)}if(r.type==="h5"&&!r.isUniAppWebView&&!r.isOfflineWebview){const A={errMsg:"当前页面不在宿主 WebView 中,无法分享。请在 unified-platform-app 内打开该 H5 再重试。",code:"NOT_IN_CONTAINER"};return(H=e.fail)==null||H.call(e,A),(Ce=e.complete)==null||Ce.call(e,A),Promise.reject(A)}const n={errMsg:"当前环境暂不支持 shareDirected,请在 App 或微信小程序容器内使用。",code:"ENV_NOT_SUPPORTED"};return(S=e.fail)==null||S.call(e,n),(z=e.complete)==null||z.call(e,n),Promise.reject(n)},{context:"shareDirected",options:t})}function wn(t={}){return new Promise((e,r)=>{xt(w(g({},t),{success:e,fail:r}))})}function Lt(t={}){return l.safeExecute(()=>{var a,o,c,d,m,O,_,H,Ce;let e;try{e=un(t)}catch(S){return(a=t.fail)==null||a.call(t,S),Promise.reject(S)}const r=V(!0);if(r.isAppPlus)try{e=dn(e)}catch(S){return(o=e.fail)==null||o.call(e,S),(c=e.complete)==null||c.call(e,S),Promise.reject(S)}const i=r.isWeixinMiniProgram?"已同步小程序卡片内容,请点击右上角“···”后发送给朋友。":"正在拉起微信发送给朋友面板,请继续完成小程序卡片分享。";if(r.isAppPlus)return pn(e).then(S=>{var A,Y;const z=w(g({},S||{}),{hint:i});return(A=e.success)==null||A.call(e,z),(Y=e.complete)==null||Y.call(e,z),z}).catch(S=>{var z,A;return(z=e.fail)==null||z.call(e,S),(A=e.complete)==null||A.call(e,S),Promise.reject(S)});if(r.isWeixinMiniProgram)try{Tt(mn(e,t.rowCustom),"shareMiniProgramCard");const S={success:!0,hint:i};return(d=e.success)==null||d.call(e,S),(m=e.complete)==null||m.call(e,S),Promise.resolve(S)}catch(S){return(O=e.fail)==null||O.call(e,S),(_=e.complete)==null||_.call(e,S),Promise.reject(S)}const n={errMsg:"当前环境暂不支持 shareMiniProgramCard,请在 App 或微信小程序容器内使用。",code:"ENV_NOT_SUPPORTED"};return(H=e.fail)==null||H.call(e,n),(Ce=e.complete)==null||Ce.call(e,n),Promise.reject(n)},{context:"shareMiniProgramCard",options:t})}function En(t={}){return new Promise((e,r)=>{Lt(w(g({},t),{success:e,fail:r}))})}const yn={OFF:"off",ON:"on",UNAVAILABLE:"unavailable",UNAUTHORIZED:"unauthorized"},An={allowDuplicatesKey:!1,services:[]};function Le(t={}){return g(g({},An),t)}function Me(){return["weixin","webview","UniApp","plus","nvue","uvue","offline"].includes(f.type)}function In(t){return l.safeExecute(()=>I(null,null,function*(){var e;if(!window.wx){const r={errMsg:"微信JS-SDK未加载",code:"WEIXIN_SDK_NOT_LOADED"};(e=t.fail)==null||e.call(t,r);return}he()||(s.info("等待微信配置完成"),yield ne()),wx.openBluetoothAdapter({success:()=>{s.info("微信蓝牙适配器已打开"),Dt(t)},fail:r=>{var i;s.error("蓝牙适配器打开失败",r),(i=t.fail)==null||i.call(t,r)}})}),{context:"openBluetoothAdapterInWeixin"})}function Pn(t){return l.safeExecute(()=>{s.debug("通过 WebView 桥接调用蓝牙功能",t),N("bluetooth",t,{success:e=>{var r;s.info("UniApp 蓝牙调用成功",e),(r=t.success)==null||r.call(t,e)},fail:e=>{var r;s.error("UniApp 蓝牙调用失败",e),(r=t.fail)==null||r.call(t,e)},complete:t.complete})},{context:"bluetoothInUniApp"})}function Mn(t){return l.safeExecute(()=>{var e;s.debug("通过 WebView 桥接调用蓝牙设备搜索功能",t),N("bluetoothDevicesDiscovery",{action:"startBluetoothDevicesDiscovery",params:{services:t.services||[],allowDuplicatesKey:(e=t.allowDuplicatesKey)!=null?e:!1}},{success:r=>{var i;console.log("[Bluetooth] 设备开启搜索成功:",r),s.info("UniApp 蓝牙设备开启搜索成功",r),(i=t.success)==null||i.call(t,r)},fail:r=>{var i;console.error("[Bluetooth] 设备开启搜索失败:",r),s.error("UniApp 蓝牙设备开启搜索失败",r),(i=t.fail)==null||i.call(t,r)},complete:t.complete})},{context:"startBluetoothDevicesDiscoveryInUniApp"})}const De=new Set;function Cn(t,e={}){return l.safeExecute(()=>{var r;return De.add(t),De.size===1&&N("onBluetoothDeviceFound",{action:"onBluetoothDeviceFound",isPersistent:!0,params:{services:e.services||[],allowDuplicatesKey:(r=e.allowDuplicatesKey)!=null?r:!1}},{success:i=>{De.forEach(n=>{typeof n=="function"?l.safeExecute(()=>n(i),{context:"BluetoothDeviceCallback"}):console.warn("[BluetoothDeviceCallback] 不是函数:",n)})},fail:i=>{var n;console.error("[Bluetooth] 搜索失败:",i),(n=e.fail)==null||n.call(e,i)},complete:e.complete}),()=>De.delete(t)},{context:"qsh_onBluetoothDeviceFound"})}function _n(t){return l.safeExecute(()=>{var e;s.debug("通过 WebView 桥接调用蓝牙连接功能",t),N("bluetoothConnection",{action:"createBLEConnection",params:{deviceId:t.deviceId,name:t.name,autoConnect:(e=t.autoConnect)!=null?e:!1}},{success:r=>{var i;console.log("[Bluetooth] 蓝牙连接成功:",r),s.info("UniApp 蓝牙连接成功",r),(i=t.success)==null||i.call(t,r)},fail:r=>{var i;console.error("[Bluetooth] 蓝牙连接失败:",r),s.error("UniApp 蓝牙连接失败",r),(i=t.fail)==null||i.call(t,r)},complete:t.complete})},{context:"createBLEConnectionInUniApp"})}function Rn(t={}){return l.safeExecute(()=>{var r;if(!Me()){const i={errMsg:`当前环境 (${f.type}) 不支持蓝牙功能`,code:"PLATFORM_NOT_SUPPORTED"};s.error("平台不支持蓝牙",{platform:f.type}),(r=t.fail)==null||r.call(t,i);return}const e=Le(t);s.info("开始蓝牙操作",{platform:f.type,services:e.services,allowDuplicatesKey:e.allowDuplicatesKey}),p()?In(e):Pn(e)},{context:"openBluetoothAdapter",options:t})}function On(t={}){return l.safeExecute(()=>{var r,i;if(!Me()){const n={errMsg:`当前环境 (${f.type}) 不支持蓝牙功能`,code:"PLATFORM_NOT_SUPPORTED"};s.error("平台不支持蓝牙",{platform:f.type}),(r=t.fail)==null||r.call(t,n),(i=t.complete)==null||i.call(t,n);return}const e=Le(t);s.info("开始搜索蓝牙设备",{platform:f.type,services:e.services,allowDuplicatesKey:e.allowDuplicatesKey}),p()?startBluetoothDevicesDiscoveryInWeixin(e):Mn(e)},{context:"startBluetoothDevicesDiscovery",options:t})}function Dt(t,e={}){return l.safeExecute(()=>{var i,n;if(!Me()){const a={errMsg:`当前环境 (${f.type}) 不支持蓝牙功能`,code:"PLATFORM_NOT_SUPPORTED"};s.error("平台不支持蓝牙",{platform:f.type}),(i=e.fail)==null||i.call(e,a),(n=e.complete)==null||n.call(e,a);return}const r=Le(e);s.info("注册蓝牙设备发现监听",{platform:f.type}),p()?onBluetoothDeviceFoundInWeixin(r):Cn(t,r)},{context:"onBluetoothDeviceFound",options:e})}function Sn(t={}){return l.safeExecute(()=>{var a,o,c,d;if(!Me()){const m={errMsg:`当前环境 (${f.type}) 不支持蓝牙功能`,code:"PLATFORM_NOT_SUPPORTED"};s.error("平台不支持蓝牙连接",{platform:f.type}),(a=t.fail)==null||a.call(t,m),(o=t.complete)==null||o.call(t,m);return}const e=Le(t),{name:r,deviceId:i,autoConnect:n=!1}=e;if(!i){const m={errMsg:"缺少 deviceId 参数",code:"INVALID_PARAMS"};(c=t.fail)==null||c.call(t,m),(d=t.complete)==null||d.call(t,m);return}s.info("创建蓝牙连接",{deviceId:i,autoConnect:n,platform:f.type}),p()?uni.createBLEConnection({deviceId:i,autoConnect:n,success:t.success,fail:t.fail,complete:t.complete}):_n(e)},{context:"createBLEConnection",options:t})}function Nn(){return{supported:Me(),environment:f.type,implementation:p()?"weixin":"webview",features:{discovery:!0,connect:!0,readWrite:!0,notify:!0,asyncSupport:!0}}}const bn={};function vn(t={}){return g(g({},bn),t)}function Ut(){return["webview","UniApp","plus","nvue","uvue","offline"].includes(f.type)}function Tn(t){return l.safeExecute(()=>{s.debug("通过 WebView 桥接调用打印PDF",t),N("printPdf",w(g({},t),{isPersistent:!0}),{success:e=>{var r;s.info("UniApp 打印PDF成功",e),(r=t.success)==null||r.call(t,e)},fail:e=>{var r;s.error("UniApp 打印PDF失败",e),(r=t.fail)==null||r.call(t,e)},complete:t.complete})},{context:"printPdfInUniApp",platform:"uniapp"})}function xn(t={}){return l.safeExecute(()=>{var r;if(!Ut()){const i={errMsg:`当前环境 (${f.type}) 不支持打印PDF功能`,code:"PLATFORM_NOT_SUPPORTED"};s.error("平台不支持打印PDF",{platform:f.type}),(r=t.fail)==null||r.call(t,i);return}const e=vn(t);s.info("开始打印PDF",{platform:f.type}),Tn(e)},{context:"printPdf",options:t})}function Ln(){return{supported:Ut(),environment:f.type,implementation:"uniapp",features:{asyncSupport:!0}}}const Be="/pages/face/index";function Dn(t={}){const e=g({},t);if(!e.name||typeof e.name!="string"||!e.name.trim())throw{errMsg:"缺少必需参数:name(姓名)",code:"PARAM_MISSING"};if(e.name=e.name.trim(),!e.idCardNumber||typeof e.idCardNumber!="string"||!e.idCardNumber.trim())throw{errMsg:"缺少必需参数:idCardNumber(身份证号)",code:"PARAM_MISSING"};return e.idCardNumber=e.idCardNumber.trim(),e}function Wt(){return["weixin","webview","UniApp","plus","nvue","uvue"].includes(f.type)}function Un(){return typeof window!="undefined"&&window.wx&&window.wx.miniProgram&&typeof window.wx.miniProgram.navigateTo=="function"}function Wn(t){const e=w(g({},t),{title:document.title||"",url:window.location.href||""}),r=Object.entries(e).filter(([,i])=>i!=null&&i!=="").map(([i,n])=>`${encodeURIComponent(i)}=${encodeURIComponent(String(n))}`).join("&");return r?`${Be}?${r}`:Be}function $n(t){return l.safeExecute(()=>{if(!Un()){s.error("微信小程序导航API不可用");return}const e=Wn(t);s.debug("跳转宿主人脸识别页面",{name:t.name,targetUrl:e}),window.wx.miniProgram.navigateTo({url:e,success:()=>{s.info("已跳转到宿主人脸识别页面",{targetUrl:e})},fail:r=>{s.error("跳转宿主人脸识别页面失败",r)}})},{context:"faceVerifyInWeixin",platform:"weixin"})}function Fn(t){return l.safeExecute(()=>{s.debug("通过 WebView 桥接调用人脸识别",{platform:f.type,name:t.name}),N("faceVerify",g({},t),{success:e=>{s.info("UniApp 人脸识别调用成功",e)},fail:e=>{s.error("UniApp 人脸识别调用失败",e)}})},{context:"faceVerifyInUniApp",platform:"uniapp"})}function kn(t={}){return l.safeExecute(()=>{if(!Wt()){s.error("平台不支持人脸识别",{platform:f.type});return}let e;try{e=Dn(t)}catch(r){s.error("人脸识别参数校验失败",r);return}if(s.info("开始人脸识别",{platform:f.type,name:e.name,pagePath:Be}),p()){$n(e);return}Fn(e)},{context:"faceVerify",options:t})}function Bn(){let t="weixin";return f.type==="UniApp"&&(t="uniapp"),{supported:Wt(),environment:f.type,implementation:t,features:{asyncSupport:!0,hostPageNavigation:p(),hostBridge:f.type==="UniApp"}}}const $t=V();function Gn(){if(typeof window=="undefined"||!V(!0).isWeixinMiniProgram)return!1;const e=$e().getRuntimeConfig();return typeof e.clientId=="string"&&e.clientId.length>0}function Kn(){return I(this,null,function*(){yield lr(),Gn()&&(yield ne())})}ae.useResponse(st.response,{priority:1e3});let Ft=!1;function kt(){if(Ft)return;Ft=!0,vr([{name:"load-weixin-sdk",run:et,timeoutMs:8e3},{name:"init-bridge",run:Ze,timeoutMs:8e3}],{onError:(e,r)=>{console.error(`[QSH-SDK] 初始化失败(${(r==null?void 0:r.name)||"unknown"}):`,e)}})}typeof window!="undefined"&&(document.readyState==="complete"||document.readyState==="interactive"?setTimeout(kt,0):document.addEventListener("DOMContentLoaded",kt));function y(t,{apiName:e}={}){return function(r={},...i){const n=r&&typeof r=="object"&&(typeof r.success=="function"||typeof r.fail=="function"||typeof r.complete=="function"),a=r&&typeof r=="object"?r:{},o=()=>n?t(a,...i):new Promise((d,m)=>{const O=w(g({},a),{success:_=>{typeof a.success=="function"&&a.success(_),d(_)},fail:_=>{typeof a.fail=="function"&&a.fail(_),m(_)},complete:a.complete});t(O,...i)});return(typeof window=="undefined"?Promise.resolve():Xe()).then(()=>o()).catch(d=>{throw console.error(`[QSH-SDK] ${e||"API"} call failed:`,d),d})}}function Ue(t){return typeof t=="function"?{success:t}:t&&typeof t=="object"?t:{}}const Bt=y(Fr),Gt=y(kr),Kt=y(Br),Vt=y(Gr),qt=y(Kr),jt=y(Vr);function Jt(t){const e=()=>qr(t);return(typeof window=="undefined"?Promise.resolve():Xe()).then(()=>e())}const Ge=y(Xr,{apiName:"getCode"});function Vn(t={}){return new Promise((e,r)=>{Ge(w(g({},t),{success:e,fail:r}))})}const Ke=y(ri,{apiName:"navigateToMiniProgram"});function qn(t={}){return new Promise((e,r)=>{Ke(w(g({},t),{success:e,fail:r}))})}const Ve=y(oi,{apiName:"filePreview"});function jn(t={}){return new Promise((e,r)=>{Ve(w(g({},t),{success:e,fail:r}))})}const qe=y(Ei);function Jn(t={}){return new Promise((e,r)=>{qe(w(g({},t),{success:e,fail:r}))})}const Ht=y(xn);function Hn(t={}){return new Promise((e,r)=>{Ht(w(g({},t),{success:e,fail:r}))})}const je=y(Ci),zn=y(kn);function Yn(t={}){return new Promise((e,r)=>{je(w(g({},t),{success:e,fail:r}))})}const Xn=y(xt,{apiName:"shareDirected"}),Zn=y(wn,{apiName:"shareDirectedAsync"}),Qn=y(Et,{apiName:"manualShare"}),ea=y(hi,{apiName:"manualShareAsync"}),Je=y($i);function ta(t={}){return new Promise((e,r)=>{Je(w(g({},t),{success:e,fail:r}))})}const He=y(Fi);function ra(t={}){return new Promise((e,r)=>{He(w(g({},t),{success:e,fail:r}))})}const ze=y(Yi);function ia(t={}){return new Promise((e,r)=>{ze(w(g({},t),{success:e,fail:r}))})}const zt=y(Rn);function na(t={}){return new Promise((e,r)=>{zt(w(g({},t),{success:e,fail:r}))})}const Yt=y(On);function aa(t={}){return new Promise((e,r)=>{Yt(w(g({},t),{success:e,fail:r}))})}const Xt=y(Dt);function sa(t={}){return new Promise((e,r)=>{Xt(w(g({},t),{success:e,fail:r}))})}const Zt=y(Sn);function oa(t={}){return new Promise((e,r)=>{Zt(w(g({},t),{success:e,fail:r}))})}const ca=y(Lt,{apiName:"shareMiniProgramCard"}),ua=y(En,{apiName:"shareMiniProgramCardAsync"}),ue={navigateTo:Bt,navigateBack:Gt,switchTab:Kt,reLaunch:Vt,redirectTo:qt,postMessage:jt,getEnv:Jt,getCode:Ge,getCodeAsync:Vn,navigateToMiniProgram:Ke,navigateToMiniProgramAsync:qn,filePreview:Ve,filePreviewAsync:jn,chooseImage:qe,chooseImageAsync:Jn,scanCode:je,scanCodeAsync:Yn,getLocation:Je,getLocationAsync:ta,openLocation:He,openLocationAsync:ra,chooseLocation:ze,chooseLocationAsync:ia,onLocationChange:t=>y((e={})=>Ki(e.success),{apiName:"onLocationChange"})(Ue(t)),offLocationChange:t=>y((e={})=>Vi(e.success),{apiName:"offLocationChange"})(Ue(t)),onLocationChangeError:t=>y((e={})=>qi(e.success),{apiName:"onLocationChangeError"})(Ue(t)),offLocationChangeError:t=>y((e={})=>ji(e.success),{apiName:"offLocationChangeError"})(Ue(t)),startLocationUpdate:y(Bi,{apiName:"startLocationUpdate"}),stopLocationUpdate:y(Gi,{apiName:"stopLocationUpdate"}),environment:$t,ready:Kn,init:Ze,isReady:nr,getState:ar,config:tt,weixin:{config:tt,waitForConfig:ne,isConfigReady:he,getConfigState:mr,retryConfig:pr},webView:null,ImageSourceTypes:Ne,ImageSizeTypes:be,getImageCapabilities:yi,ScanTypes:ce,getScanCapabilities:_i,CoordinateTypes:U,getLocationCapabilities:ki,getChooseLocationCapabilities:Xi,openBluetoothAdapter:zt,openBluetoothAdapterAsync:na,startBluetoothDevicesDiscovery:Yt,startBluetoothDevicesDiscoveryAsync:aa,onBluetoothDeviceFound:Xt,onBluetoothDeviceFoundAsync:sa,createBLEConnection:Zt,createBLEConnectionAsync:oa,BluetoothStates:yn,shareDirected:Xn,shareDirectedAsync:Zn,manualShare:Qn,manualShareAsync:ea,shareMiniProgramCard:ca,shareMiniProgramCardAsync:ua,getBluetoothCapabilities:Nn,printPdf:Ht,printPdfAsync:Hn,getPrintCapabilities:Ln,faceVerify:zn,getFaceCapabilities:Bn,plugins:{manager:ye,register:t=>ye.register(t),install:t=>ye.install(t,ue),list:()=>ye.getPluginList()},interceptors:{chain:ae,useRequest:(t,e)=>ae.useRequest(t,e),useResponse:(t,e)=>ae.useResponse(t,e),builtin:{logging:yr,performance:Z,createRetry:Ar,createValidation:Ir,errorNormalizer:st}},metrics:{getPerformanceReport:()=>Z.getReport(),clearPerformanceMetrics:()=>Z.clearMetrics()},errors:{codes:u,messages:Fe,categories:K,normalize:at,create:Sr,isStandard:Nr},store:{instance:j,get:t=>j.get(t),set:(t,e)=>j.set(t,e),subscribe:(t,e)=>j.subscribe(t,e),getSnapshot:()=>j.getSnapshot()},debug:{logger:W,setLogReporter:t=>W.setReporter(t),errorHandler:l,stateManager:ie,enableDevMode:()=>W.enableDevMode(),getLogs:t=>W.getHistory(t),getStats:()=>({logger:W.getStats(),state:ie.getStats(),weixinConfig:$e().getStats(),plugins:ye.getStats(),interceptors:ae.getStats(),store:j.getStats()}),getWeixinConfigManager:$e,exportDebugInfo:()=>W.exportToJSON()}};$t.isWeixinMiniProgram?ue.webView=window.wx&&window.wx.miniProgram:ue.webView={navigateTo:Bt,navigateBack:Gt,switchTab:Kt,reLaunch:Vt,redirectTo:qt,postMessage:jt,getEnv:Jt,getCode:Ge,navigateToMiniProgram:Ke,filePreview:Ve,chooseImage:qe,scanCode:je,getLocation:Je,openLocation:He,chooseLocation:ze};const Qt=typeof window.uni!="undefined"?window.uni:{};return Object.keys(Qt).forEach(t=>{ue.hasOwnProperty(t)||(ue[t]=Qt[t])}),typeof window!="undefined"&&(window.qsh=ue),ue});
|
|
2
2
|
//# sourceMappingURL=qsh-webview-sdk.umd.js.map
|